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 |
| 6 | |
Gaurav Shah | 27bfc8b | 2010-02-17 14:19:24 -0800 | [diff] [blame] | 7 | export CC ?= gcc |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 8 | export CXX ?= g++ |
Chris Sosa | 9f1973e | 2011-01-26 18:54:57 -0800 | [diff] [blame] | 9 | export CFLAGS = -Wall -Werror |
Che-Liang Chiou | 440ad51 | 2011-01-27 10:23:51 +0800 | [diff] [blame] | 10 | |
Chris Sosa | 9f1973e | 2011-01-26 18:54:57 -0800 | [diff] [blame] | 11 | ifeq (${DEBUG},) |
| 12 | CFLAGS += -O3 |
| 13 | else |
Che-Liang Chiou | 34be827 | 2011-01-27 16:44:36 +0800 | [diff] [blame] | 14 | CFLAGS += -O0 -g |
| 15 | endif |
| 16 | |
| 17 | # Override CC and CFLAGS only if FIRMWARE_CONFIG_PATH is not empty, but we |
| 18 | # wish to preserve -D flags (so move all -D flags after this). |
| 19 | ifneq (${FIRMWARE_CONFIG_PATH},) |
| 20 | include ${FIRMWARE_CONFIG_PATH} |
| 21 | endif |
| 22 | |
| 23 | ifeq ($(FIRMWARE_ARCH),) |
| 24 | CFLAGS += -DCHROMEOS_ENVIRONMENT |
| 25 | endif |
| 26 | |
| 27 | ifneq (${DEBUG},) |
| 28 | CFLAGS += -DVBOOT_DEBUG |
vbendeb | b2b0fcc | 2010-07-15 15:09:47 -0700 | [diff] [blame] | 29 | endif |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 30 | |
vbendeb | b2b0fcc | 2010-07-15 15:09:47 -0700 | [diff] [blame] | 31 | ifeq (${DISABLE_NDEBUG},) |
| 32 | CFLAGS += -DNDEBUG |
| 33 | endif |
| 34 | |
Gaurav Shah | 7ca31f3 | 2010-02-16 19:04:11 -0800 | [diff] [blame] | 35 | export TOP = $(shell pwd) |
Randall Spangler | 620c38c | 2010-06-17 14:45:22 -0700 | [diff] [blame] | 36 | export FWDIR=$(TOP)/firmware |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 37 | export HOSTDIR=$(TOP)/host |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 38 | ifeq ($(FIRMWARE_ARCH),) |
Randall Spangler | d0dae7a | 2010-06-21 18:25:31 -0700 | [diff] [blame] | 39 | export INCLUDES = -I$(FWDIR)/include -I$(FWDIR)/stub/include |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 40 | else |
| 41 | export INCLUDES = -I$(FWDIR)/include -I$(FWDIR)/arch/$(FIRMWARE_ARCH)/include |
| 42 | endif |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 43 | |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 44 | export BUILD = ${TOP}/build |
| 45 | export FWLIB = ${BUILD}/vboot_fw.a |
Che-Liang Chiou | 8967860 | 2010-11-09 08:33:36 +0800 | [diff] [blame] | 46 | export HOSTLIB = ${BUILD}/vboot_host.a |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 47 | |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 48 | ifeq ($(FIRMWARE_ARCH),) |
Randall Spangler | 39f6611 | 2010-07-14 09:10:23 -0700 | [diff] [blame] | 49 | SUBDIRS = firmware host utility cgpt tests tests/tpm_lite |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 50 | else |
| 51 | SUBDIRS = firmware |
| 52 | endif |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 53 | |
| 54 | all: |
Louis Yung-Chieh Lo | b31ddce | 2010-05-21 16:35:44 +0800 | [diff] [blame] | 55 | set -e; \ |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 56 | for d in $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; |\ |
| 57 | sort -u); do \ |
| 58 | newdir=${BUILD}/$$d; \ |
| 59 | if [ ! -d $$newdir ]; then \ |
| 60 | mkdir -p $$newdir; \ |
| 61 | fi; \ |
Luigi Semenzato | 5896b96 | 2010-08-25 07:16:03 -0700 | [diff] [blame] | 62 | done; \ |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 63 | [ -z "$(FIRMWARE_ARCH)" ] && make -C utility update_tlcl_structures; \ |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 64 | for i in $(SUBDIRS); do \ |
Louis Yung-Chieh Lo | b31ddce | 2010-05-21 16:35:44 +0800 | [diff] [blame] | 65 | make -C $$i; \ |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 66 | done |
| 67 | |
| 68 | clean: |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 69 | /bin/rm -rf ${BUILD} |
Bill Richardson | 371df8b | 2010-05-27 14:19:47 -0700 | [diff] [blame] | 70 | |
| 71 | install: |
| 72 | $(MAKE) -C utility install |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 73 | $(MAKE) -C cgpt install |
Gaurav Shah | e642198 | 2010-06-03 07:49:32 -0700 | [diff] [blame] | 74 | |
| 75 | runtests: |
| 76 | $(MAKE) -C tests runtests |
Luigi Semenzato | 18b814d | 2010-07-08 17:17:02 -0700 | [diff] [blame] | 77 | |
| 78 | rbtest: |
| 79 | $(MAKE) -C tests rbtest |
Bill Richardson | 856e072 | 2011-02-07 15:39:45 -0800 | [diff] [blame] | 80 | |
| 81 | runbmptests: |
| 82 | $(MAKE) -C tests runbmptests |