diff --git a/Makefile b/Makefile index e8f783392f..f0c4a20d17 100644 --- a/Makefile +++ b/Makefile @@ -96,6 +96,7 @@ CC := $(CC_$(ARCH)) AS := $(AS_$(ARCH)) LD := $(LD_$(ARCH)) OBJCOPY := $(OBJCOPY_$(ARCH)) +CFLAGS += $(CFLAGS_$(ARCH)) CPPFLAGS := $(LINUXBIOSINCLUDE) CFLAGS += $(LINUXBIOSINCLUDE) diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile index 143545c167..fa14f4bd11 100755 --- a/util/xcompile/xcompile +++ b/util/xcompile/xcompile @@ -25,6 +25,15 @@ ARCH=`uname -m | sed -e s/i.86/x86/ -e s/sun4u/sparc64/ \ -e s/s390x/s390/ -e s/parisc64/parisc/ \ -e s/ppc.*/powerpc/ -e s/mips.*/mips/` +testcc() +{ + TMP=".$$$$.tmp" + $1 $2 -S -xc /dev/null -o $TMP > /dev/null 2>&1 + ret=$? + rm -rf $TMP + return $ret +} + searchgnu() { # $1 short name @@ -45,18 +54,23 @@ searchgnu() case "$ARCH" in "x86_64") echo "CC_x86 := gcc -m32" + CC="gcc -m32" + searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as) --32" searchgnu ld >/dev/null && echo "LD_x86 := $(searchgnu ld) -b elf32-i386 -melf_i386" searchgnu objcopy >/dev/null && echo "OBJCOPY_x86 := $(searchgnu objcopy)" ;; "x86") echo "CC_x86 := gcc" + CC="gcc" + searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as)" searchgnu ld >/dev/null && echo "LD_x86 := $(searchgnu ld)" searchgnu objcopy >/dev/null && echo "OBJCOPY_x86 := $(searchgnu objcopy)" ;; *) # FIXME: This should be detected. + CC="i386-linux-gcc" echo "CC_x86 := i386-linux-gcc" echo "AS_x86 := i386-linux-as" echo "LD_x86 := i386-linux-ld" @@ -64,6 +78,13 @@ case "$ARCH" in ;; esac +# This is where we test for various flags and other things + +CFLAGS="" +testcc "$CC" "-fno-stack-protector" && CFLAGS="$CFLAGS-fno-stack-protector " + +echo "CFLAGS_x86 := $CFLAGS" + # TODO: The same as above for PowerPC, and other architectures # as soon as they are supported by LinuxBIOSv3.