# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1231837189 0
# Node ID 27e9687c5b3d7499a629b14571df917af32dbd86
# Parent 0e448d0a41ff66288a257c3c654f4d881388264f
build: Define cc-option-add to immediately add options to CFLAGS
without deferring the test execution of CC. This avoids extra
executions of CC every time CFLAGS is expanded.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
Config.mk | 13 +++++++++++--
tools/firmware/Rules.mk | 6 +++---
tools/tests/blowfish.mk | 6 +++---
tools/vnet/libxutil/Makefile | 3 ++-
xen/arch/x86/Rules.mk | 6 +++---
5 files changed, 22 insertions(+), 12 deletions(-)
diff -r 0e448d0a41ff -r 27e9687c5b3d Config.mk
--- a/Config.mk Tue Jan 13 08:40:42 2009 +0000
+++ b/Config.mk Tue Jan 13 08:59:49 2009 +0000
@@ -38,6 +38,15 @@ cc-option = $(shell if test -z "`$(1) $(
cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
/dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;)
+# cc-option-add: Add an option to compilation flags, but only if supported.
+# Usage: $(call cc-option-add CFLAGS,CC,-march=winchip-c6)
+cc-option-add = $(eval $(call cc-option-add-closure,$(1),$(2),$(3)))
+define cc-option-add-closure
+ ifneq ($$(call cc-option,$$($(2)),$(3),n),n)
+ $(1) += $(3)
+ endif
+endef
+
# cc-ver: Check compiler is at least specified version. Return boolean 'y'/'n'.
# Usage: ifeq ($(call cc-ver,$(CC),0x030400),y)
cc-ver = $(shell if [ $$((`$(1) -dumpversion | awk -F. \
@@ -84,8 +93,8 @@ CFLAGS += -Wall -Wstrict-prototypes
# result of any casted expression causes a warning.
CFLAGS += -Wno-unused-value
-HOSTCFLAGS += $(call cc-option,$(HOSTCC),-Wdeclaration-after-statement,)
-CFLAGS += $(call cc-option,$(CC),-Wdeclaration-after-statement,)
+$(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wdeclaration-after-statement)
+$(call cc-option-add,CFLAGS,CC,-Wdeclaration-after-statement)
LDFLAGS += $(foreach i, $(EXTRA_LIB), -L$(i))
CFLAGS += $(foreach i, $(EXTRA_INCLUDES), -I$(i))
diff -r 0e448d0a41ff -r 27e9687c5b3d tools/firmware/Rules.mk
--- a/tools/firmware/Rules.mk Tue Jan 13 08:40:42 2009 +0000
+++ b/tools/firmware/Rules.mk Tue Jan 13 08:59:49 2009 +0000
@@ -13,9 +13,9 @@ CFLAGS += -Werror
CFLAGS += -Werror
# Disable PIE/SSP if GCC supports them. They can break us.
-CFLAGS += $(call cc-option,$(CC),-nopie,)
-CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
-CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
+$(call cc-option-add,CFLAGS,CC,-nopie)
+$(call cc-option-add,CFLAGS,CC,-fno-stack-protector)
+$(call cc-option-add,CFLAGS,CC,-fno-stack-protector-all)
# Extra CFLAGS suitable for an embedded type of environment.
CFLAGS += -fno-builtin -msoft-float
diff -r 0e448d0a41ff -r 27e9687c5b3d tools/tests/blowfish.mk
--- a/tools/tests/blowfish.mk Tue Jan 13 08:40:42 2009 +0000
+++ b/tools/tests/blowfish.mk Tue Jan 13 08:59:49 2009 +0000
@@ -5,9 +5,9 @@ include $(XEN_ROOT)/tools/Rules.mk
include $(XEN_ROOT)/tools/Rules.mk
# Disable PIE/SSP if GCC supports them. They can break us.
-CFLAGS += $(call cc-option,$(CC),-nopie,)
-CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
-CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
+$(call cc-option-add,CFLAGS,CC,-nopie)
+$(call cc-option-add,CFLAGS,CC,-fno-stack-protector)
+$(call cc-option-add,CFLAGS,CC,-fno-stack-protector-all)
CFLAGS += -fno-builtin -msoft-float
diff -r 0e448d0a41ff -r 27e9687c5b3d tools/vnet/libxutil/Makefile
--- a/tools/vnet/libxutil/Makefile Tue Jan 13 08:40:42 2009 +0000
+++ b/tools/vnet/libxutil/Makefile Tue Jan 13 08:59:49 2009 +0000
@@ -24,7 +24,8 @@ LIB_OBJS := $(LIB_SRCS:.c=.o)
LIB_OBJS := $(LIB_SRCS:.c=.o)
PIC_OBJS := $(LIB_SRCS:.c=.opic)
-CFLAGS += -Werror -fno-strict-aliasing $(call
cc-option,$(CC),-fgnu89-inline,)
+$(call cc-option-add,CFLAGS,CC,-fgnu89-inline)
+CFLAGS += -Werror -fno-strict-aliasing
CFLAGS += -O3
#CFLAGS += -g
diff -r 0e448d0a41ff -r 27e9687c5b3d xen/arch/x86/Rules.mk
--- a/xen/arch/x86/Rules.mk Tue Jan 13 08:40:42 2009 +0000
+++ b/xen/arch/x86/Rules.mk Tue Jan 13 08:59:49 2009 +0000
@@ -26,9 +26,9 @@ CFLAGS += -msoft-float
CFLAGS += -msoft-float
# Disable PIE/SSP if GCC supports them. They can break us.
-CFLAGS += $(call cc-option,$(CC),-nopie,)
-CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
-CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
+$(call cc-option-add,CFLAGS,CC,-nopie)
+$(call cc-option-add,CFLAGS,CC,-fno-stack-protector)
+$(call cc-option-add,CFLAGS,CC,-fno-stack-protector-all)
ifeq ($(supervisor_mode_kernel),y)
CFLAGS += -DCONFIG_X86_SUPERVISOR_MODE_KERNEL=1
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|