Add testcc() function to xcompile to check for various compiler flags and set them in the CFLAGS variable if they are located.

Added check for -fno-stack-protector flag.

Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Marc Jones <marc.jones@amd.com>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@434 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
Marc Jones 2007-07-05 17:27:23 +00:00
commit c133c1bf2b
2 changed files with 22 additions and 0 deletions

View file

@ -96,6 +96,7 @@ CC := $(CC_$(ARCH))
AS := $(AS_$(ARCH))
LD := $(LD_$(ARCH))
OBJCOPY := $(OBJCOPY_$(ARCH))
CFLAGS += $(CFLAGS_$(ARCH))
CPPFLAGS := $(LINUXBIOSINCLUDE)
CFLAGS += $(LINUXBIOSINCLUDE)

View file

@ -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.