summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-11-15 17:26:07 -0800
committerGerrit <chrome-bot@google.com>2011-11-16 13:38:42 -0800
commit25c36746a2c91831e8d7a36246e7413420bec6f8 (patch)
tree8b56d62ab38d2b37a6e6b0a0ffb6732fb7f9dfb6
parent4c1f3c8e540beab8f44e48877611a01e98fd9a40 (diff)
downloadvboot-25c36746a2c91831e8d7a36246e7413420bec6f8.tar.gz
Revert "Revert "Break out common compile flags""
This reverts commit 45e1067502da0c3cbf77d8b6aafc9d17b461cea3 Change-Id: I00e7bb9dd02287db868bc291e25d27066fc486da Reviewed-on: https://gerrit.chromium.org/gerrit/11746 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
-rw-r--r--Makefile50
1 files changed, 28 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 0d381d35..7652bde8 100644
--- a/Makefile
+++ b/Makefile
@@ -5,39 +5,43 @@
export FIRMWARE_ARCH
export MOCK_TPM
-export CC ?= gcc
-export CXX ?= g++
-export CFLAGS = -Wall -Werror
-
-ifeq (${DEBUG},)
-CFLAGS += -O3
-else
-CFLAGS += -O0 -g
-endif
-
+#
+# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
+# please add them after this point (e.g., -DVBOOT_DEBUG).
#
# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
# temporarily. As we are still investigating which flags are necessary for
# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
#
-# Override CC and CFLAGS for firmware builds; if you have any -D flags, please
-# add them after this point (e.g., -DVBOOT_DEBUG).
+# As a first step, this makes the setting of CC and CFLAGS here optional, to
+# permit a calling script or Makefile to set these.
#
+# Flag ordering: arch, then -f, then -m, then -W
+DEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
+COMMON_FLAGS := -nostdinc -pipe \
+ -ffreestanding -fno-builtin -fno-stack-protector \
+ -Werror -Wall -Wstrict-prototypes $(DEBUG_FLAGS)
+
ifeq ($(FIRMWARE_ARCH), arm)
-CC = armv7a-cros-linux-gnueabi-gcc
-CFLAGS = -g -Os -fno-common -ffixed-r8 -msoft-float -fno-builtin \
- -ffreestanding -nostdinc \
- -pipe -marm -mabi=aapcs-linux -mno-thumb-interwork -march=armv5 \
- -Werror -Wall -Wstrict-prototypes -fno-stack-protector
+CC ?= armv7a-cros-linux-gnueabi-gcc
+CFLAGS ?= -march=armv5 \
+ -fno-common -ffixed-r8 \
+ -msoft-float -marm -mabi=aapcs-linux -mno-thumb-interwork \
+ $(COMMON_FLAGS)
endif
ifeq ($(FIRMWARE_ARCH), i386)
-CC = i686-pc-linux-gnu-gcc
-CFLAGS = -g -Os -ffunction-sections -fvisibility=hidden -fno-builtin \
- -ffreestanding -nostdinc -pipe -Wstrict-prototypes -mregparm=3 \
- -fomit-frame-pointer -fno-stack-protector \
- -mpreferred-stack-boundary=2 -fno-dwarf2-cfi-asm -Werror -Wall
+CC ?= i686-pc-linux-gnu-gcc
+# Drop -march=i386 to permit use of SSE instructions
+CFLAGS ?= \
+ -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \
+ -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \
+ -mpreferred-stack-boundary=2 -mregparm=3 \
+ $(COMMON_FLAGS)
endif
+CC ?= gcc
+CXX ?= g++
+
# Fix compiling directly on host (outside of emake)
ifeq ($(ARCH),)
export ARCH=amd64
@@ -55,6 +59,8 @@ ifeq (${DISABLE_NDEBUG},)
CFLAGS += -DNDEBUG
endif
+export CC CXX CFLAGS
+
export TOP = $(shell pwd)
export FWDIR=$(TOP)/firmware
export HOSTDIR=$(TOP)/host