fix stack protection detection with Jordan's suggestion
authorStefan Reinauer <stepan@coresystems.de>
Thu, 7 Aug 2008 15:28:31 +0000 (15:28 +0000)
committerStefan Reinauer <stepan@openbios.org>
Thu, 7 Aug 2008 15:28:31 +0000 (15:28 +0000)
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3478 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

payloads/libpayload/Makefile

index 8c6d14871c8ef9bb7b1152f4df3b77f6efdefde7..04ebbb0195780789585db355c107d024fd326ff5 100644 (file)
@@ -63,8 +63,21 @@ include $(PLATFORM-y) $(BUILD-y)
 
 INCLUDES := -I./include
 INCLUDES += -I$(shell $(CC) -print-search-dirs | head -n 1 | cut -d' ' -f2)include
+
+try-run= $(shell set -e; \
+TMP=".$$$$.tmp"; \
+if ($(1)) > /dev/null 2>&1; \
+then echo "$(2)"; \
+else echo "$(3)"; \
+fi; rm -rf "$$TMP")
+
+cc-option= $(call try-run,\
+$(CC) $(1) -S -xc /dev/null -o "$$TMP", $(1), $(2))
+
+STACKPROTECT += $(call cc-option, -fno-stack-protector,)
+
 # TODO: Re-add -Os as soon as we find out why it caused problems.
-CFLAGS := -Wall -Werror -fno-stack-protector -nostdinc $(INCLUDES)
+CFLAGS := -Wall -Werror $(STACKPROTECT) -nostdinc $(INCLUDES)
 
 lib: lib/libpayload.a lib/$(ARCHDIR-y)/head.o