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