summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2008-08-07 15:28:31 +0000
committerStefan Reinauer <stepan@openbios.org>2008-08-07 15:28:31 +0000
commit85c7aec73ea37136a158fd7fd98249ddedaffba5 (patch)
tree42096c308fc5937b223ec04aa11af76a3e01ac3e
parentc359124ef465e714f1cd7c6ad31429071847b074 (diff)
fix stack protection detection with Jordan's suggestion
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
-rw-r--r--payloads/libpayload/Makefile15
1 files changed, 14 insertions, 1 deletions
diff --git a/payloads/libpayload/Makefile b/payloads/libpayload/Makefile
index 8c6d14871c..04ebbb0195 100644
--- a/payloads/libpayload/Makefile
+++ b/payloads/libpayload/Makefile
@@ -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