blob: 125b9294b610e2e936f431d7225602d43a99ca03 [file] [log] [blame]
Gaurav Shah322536d2010-01-28 15:01:23 -08001# 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 Chiou0a0e8d02010-11-30 09:30:45 +08005export FIRMWARE_ARCH
Che-Liang Chiou8511f782011-04-22 16:01:38 +08006export MOCK_TPM
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +08007
Gaurav Shah27bfc8b2010-02-17 14:19:24 -08008export CC ?= gcc
Bill Richardsonf1372d92010-06-11 09:15:55 -07009export CXX ?= g++
Chris Sosa9f1973e2011-01-26 18:54:57 -080010export CFLAGS = -Wall -Werror
Che-Liang Chiou440ad512011-01-27 10:23:51 +080011
Chris Sosa9f1973e2011-01-26 18:54:57 -080012ifeq (${DEBUG},)
13CFLAGS += -O3
14else
Che-Liang Chiou34be8272011-01-27 16:44:36 +080015CFLAGS += -O0 -g
16endif
17
Che-Liang Chiou74359b72011-06-21 15:25:51 -070018#
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#
26ifeq ($(FIRMWARE_ARCH), "arm")
27CC = armv7a-cros-linux-gnueabi-gcc
28CFLAGS = -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
33endif
34ifeq ($(FIRMWARE_ARCH), "i386")
35CC = i686-pc-linux-gnu-gcc
36CFLAGS = -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 Chiou34be8272011-01-27 16:44:36 +080043endif
44
Randall Spangler287beae2011-04-11 12:46:40 -070045# Fix compiling directly on host (outside of emake)
46ifeq ($(ARCH),)
47export ARCH=amd64
48endif
49
Che-Liang Chiou34be8272011-01-27 16:44:36 +080050ifeq ($(FIRMWARE_ARCH),)
51CFLAGS += -DCHROMEOS_ENVIRONMENT
52endif
53
54ifneq (${DEBUG},)
55CFLAGS += -DVBOOT_DEBUG
vbendebb2b0fcc2010-07-15 15:09:47 -070056endif
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080057
vbendebb2b0fcc2010-07-15 15:09:47 -070058ifeq (${DISABLE_NDEBUG},)
59CFLAGS += -DNDEBUG
60endif
61
Gaurav Shah7ca31f32010-02-16 19:04:11 -080062export TOP = $(shell pwd)
Randall Spangler620c38c2010-06-17 14:45:22 -070063export FWDIR=$(TOP)/firmware
Randall Spanglerd1836442010-06-10 09:59:04 -070064export HOSTDIR=$(TOP)/host
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080065ifeq ($(FIRMWARE_ARCH),)
Randall Spanglerd0dae7a2010-06-21 18:25:31 -070066export INCLUDES = -I$(FWDIR)/include -I$(FWDIR)/stub/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080067else
68export INCLUDES = -I$(FWDIR)/include -I$(FWDIR)/arch/$(FIRMWARE_ARCH)/include
69endif
Gaurav Shah322536d2010-01-28 15:01:23 -080070
vbendeb70e95092010-06-14 15:41:27 -070071export BUILD = ${TOP}/build
72export FWLIB = ${BUILD}/vboot_fw.a
Che-Liang Chiou89678602010-11-09 08:33:36 +080073export HOSTLIB = ${BUILD}/vboot_host.a
Bill Richardson0b8f35c2010-05-26 09:18:38 -070074
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080075ifeq ($(FIRMWARE_ARCH),)
Randall Spangler39f66112010-07-14 09:10:23 -070076SUBDIRS = firmware host utility cgpt tests tests/tpm_lite
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080077else
78SUBDIRS = firmware
79endif
Gaurav Shah322536d2010-01-28 15:01:23 -080080
81all:
Louis Yung-Chieh Lob31ddce2010-05-21 16:35:44 +080082 set -e; \
vbendeb70e95092010-06-14 15:41:27 -070083 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 Semenzato5896b962010-08-25 07:16:03 -070089 done; \
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080090 [ -z "$(FIRMWARE_ARCH)" ] && make -C utility update_tlcl_structures; \
Gaurav Shah322536d2010-01-28 15:01:23 -080091 for i in $(SUBDIRS); do \
Louis Yung-Chieh Lob31ddce2010-05-21 16:35:44 +080092 make -C $$i; \
Gaurav Shah322536d2010-01-28 15:01:23 -080093 done
94
95clean:
vbendeb70e95092010-06-14 15:41:27 -070096 /bin/rm -rf ${BUILD}
Bill Richardson371df8b2010-05-27 14:19:47 -070097
98install:
99 $(MAKE) -C utility install
Bill Richardsonf1372d92010-06-11 09:15:55 -0700100 $(MAKE) -C cgpt install
Gaurav Shahe6421982010-06-03 07:49:32 -0700101
102runtests:
103 $(MAKE) -C tests runtests
Luigi Semenzato18b814d2010-07-08 17:17:02 -0700104
105rbtest:
106 $(MAKE) -C tests rbtest
Bill Richardson856e0722011-02-07 15:39:45 -0800107
108runbmptests:
109 $(MAKE) -C tests runbmptests