Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 1 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 5 | export FIRMWARE_ARCH |
Che-Liang Chiou | 8511f78 | 2011-04-22 16:01:38 +0800 | [diff] [blame] | 6 | export MOCK_TPM |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 7 | |
Gaurav Shah | 27bfc8b | 2010-02-17 14:19:24 -0800 | [diff] [blame] | 8 | export CC ?= gcc |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 9 | export CXX ?= g++ |
Chris Sosa | 9f1973e | 2011-01-26 18:54:57 -0800 | [diff] [blame] | 10 | export CFLAGS = -Wall -Werror |
Che-Liang Chiou | 440ad51 | 2011-01-27 10:23:51 +0800 | [diff] [blame] | 11 | |
Chris Sosa | 9f1973e | 2011-01-26 18:54:57 -0800 | [diff] [blame] | 12 | ifeq (${DEBUG},) |
| 13 | CFLAGS += -O3 |
| 14 | else |
Che-Liang Chiou | 34be827 | 2011-01-27 16:44:36 +0800 | [diff] [blame] | 15 | CFLAGS += -O0 -g |
| 16 | endif |
| 17 | |
Che-Liang Chiou | 74359b7 | 2011-06-21 15:25:51 -0700 | [diff] [blame^] | 18 | # |
| 19 | # TODO We hard-code u-boot's compiler flags here just temporarily. As we are |
| 20 | # still investigating which flags are necessary for maintaining a compatible |
| 21 | # ABI, etc. between u-boot and vboot_reference. |
| 22 | # |
| 23 | # Override CC and CFLAGS for firmware builds; if you have any -D flags, please |
| 24 | # add them after this point (e.g., -DVBOOT_DEBUG). |
| 25 | # |
| 26 | ifeq ($(FIRMWARE_ARCH), "arm") |
| 27 | CC = armv7a-cros-linux-gnueabi-gcc |
| 28 | CFLAGS = -g -Os -fno-common -ffixed-r8 -msoft-float -fno-builtin \ |
| 29 | -ffreestanding -nostdinc \ |
| 30 | -isystem /usr/lib/gcc/armv7a-cros-linux-gnueabi/4.4.3/gcc/armv7a-cros-linux-gnueabi/4.4.3/include \ |
| 31 | -pipe -marm -mabi=aapcs-linux -mno-thumb-interwork -march=armv5 \ |
| 32 | -Werror -Wall -Wstrict-prototypes -fno-stack-protector |
| 33 | endif |
| 34 | ifeq ($(FIRMWARE_ARCH), "i386") |
| 35 | CC = i686-pc-linux-gnu-gcc |
| 36 | CFLAGS = -g -Os -ffunction-sections -fvisibility=hidden -fno-builtin \ |
| 37 | -ffreestanding -nostdinc \ |
| 38 | -isystem /usr/lib/gcc/i686-pc-linux-gnu/4.4.3/gcc/i686-pc-linux-gnu/4.4.3/include \ |
| 39 | -pipe -fno-strict-aliasing -Wstrict-prototypes -mregparm=3 \ |
| 40 | -fomit-frame-pointer -ffreestanding -fno-toplevel-reorder \ |
| 41 | -fno-stack-protector -mpreferred-stack-boundary=2 -fno-dwarf2-cfi-asm \ |
| 42 | -march=i386 -Werror -Wall -Wstrict-prototypes -fno-stack-protector |
Che-Liang Chiou | 34be827 | 2011-01-27 16:44:36 +0800 | [diff] [blame] | 43 | endif |
| 44 | |
Randall Spangler | 287beae | 2011-04-11 12:46:40 -0700 | [diff] [blame] | 45 | # Fix compiling directly on host (outside of emake) |
| 46 | ifeq ($(ARCH),) |
| 47 | export ARCH=amd64 |
| 48 | endif |
| 49 | |
Che-Liang Chiou | 34be827 | 2011-01-27 16:44:36 +0800 | [diff] [blame] | 50 | ifeq ($(FIRMWARE_ARCH),) |
| 51 | CFLAGS += -DCHROMEOS_ENVIRONMENT |
| 52 | endif |
| 53 | |
| 54 | ifneq (${DEBUG},) |
| 55 | CFLAGS += -DVBOOT_DEBUG |
vbendeb | b2b0fcc | 2010-07-15 15:09:47 -0700 | [diff] [blame] | 56 | endif |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 57 | |
vbendeb | b2b0fcc | 2010-07-15 15:09:47 -0700 | [diff] [blame] | 58 | ifeq (${DISABLE_NDEBUG},) |
| 59 | CFLAGS += -DNDEBUG |
| 60 | endif |
| 61 | |
Gaurav Shah | 7ca31f3 | 2010-02-16 19:04:11 -0800 | [diff] [blame] | 62 | export TOP = $(shell pwd) |
Randall Spangler | 620c38c | 2010-06-17 14:45:22 -0700 | [diff] [blame] | 63 | export FWDIR=$(TOP)/firmware |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 64 | export HOSTDIR=$(TOP)/host |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 65 | ifeq ($(FIRMWARE_ARCH),) |
Randall Spangler | d0dae7a | 2010-06-21 18:25:31 -0700 | [diff] [blame] | 66 | export INCLUDES = -I$(FWDIR)/include -I$(FWDIR)/stub/include |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 67 | else |
| 68 | export INCLUDES = -I$(FWDIR)/include -I$(FWDIR)/arch/$(FIRMWARE_ARCH)/include |
| 69 | endif |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 70 | |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 71 | export BUILD = ${TOP}/build |
| 72 | export FWLIB = ${BUILD}/vboot_fw.a |
Che-Liang Chiou | 8967860 | 2010-11-09 08:33:36 +0800 | [diff] [blame] | 73 | export HOSTLIB = ${BUILD}/vboot_host.a |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 74 | |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 75 | ifeq ($(FIRMWARE_ARCH),) |
Randall Spangler | 39f6611 | 2010-07-14 09:10:23 -0700 | [diff] [blame] | 76 | SUBDIRS = firmware host utility cgpt tests tests/tpm_lite |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 77 | else |
| 78 | SUBDIRS = firmware |
| 79 | endif |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 80 | |
| 81 | all: |
Louis Yung-Chieh Lo | b31ddce | 2010-05-21 16:35:44 +0800 | [diff] [blame] | 82 | set -e; \ |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 83 | for d in $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; |\ |
| 84 | sort -u); do \ |
| 85 | newdir=${BUILD}/$$d; \ |
| 86 | if [ ! -d $$newdir ]; then \ |
| 87 | mkdir -p $$newdir; \ |
| 88 | fi; \ |
Luigi Semenzato | 5896b96 | 2010-08-25 07:16:03 -0700 | [diff] [blame] | 89 | done; \ |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 90 | [ -z "$(FIRMWARE_ARCH)" ] && make -C utility update_tlcl_structures; \ |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 91 | for i in $(SUBDIRS); do \ |
Louis Yung-Chieh Lo | b31ddce | 2010-05-21 16:35:44 +0800 | [diff] [blame] | 92 | make -C $$i; \ |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 93 | done |
| 94 | |
| 95 | clean: |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 96 | /bin/rm -rf ${BUILD} |
Bill Richardson | 371df8b | 2010-05-27 14:19:47 -0700 | [diff] [blame] | 97 | |
| 98 | install: |
| 99 | $(MAKE) -C utility install |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 100 | $(MAKE) -C cgpt install |
Gaurav Shah | e642198 | 2010-06-03 07:49:32 -0700 | [diff] [blame] | 101 | |
| 102 | runtests: |
| 103 | $(MAKE) -C tests runtests |
Luigi Semenzato | 18b814d | 2010-07-08 17:17:02 -0700 | [diff] [blame] | 104 | |
| 105 | rbtest: |
| 106 | $(MAKE) -C tests rbtest |
Bill Richardson | 856e072 | 2011-02-07 15:39:45 -0800 | [diff] [blame] | 107 | |
| 108 | runbmptests: |
| 109 | $(MAKE) -C tests runbmptests |