From 6b12fd134f1c8ad6590a4180fcf82b34a149a611 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Thu, 19 Apr 2007 23:29:30 +0000 Subject: [PATCH] - new function in xcompile: searchgnu that looks for g$1, gnu$1 and $1 and checks if they're GNU (by grepping for GNU in --version) - use searchgnu to find objcopy, gnu ld, gnu as. - set $(LEX) to flex - add some search path to get whoami on solaris - replace dnsdomainname with domainname if dnsdomainname is missing - use $(OBJCOPY) instead of objcopy Signed-off-by: Patrick Georgi Signed-off-by: Stefan Reinauer Acked-by: Uwe Hermann git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@284 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- Makefile | 22 ++++++++++++++------- arch/x86/Makefile | 6 ++++-- mainboard/emulation/qemu-x86/Makefile | 2 +- util/xcompile/xcompile | 28 +++++++++++++++++++++++---- 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index ca88efb9d0..cb50709eeb 100644 --- a/Makefile +++ b/Makefile @@ -46,8 +46,11 @@ HOSTCXX := g++ HOSTCFLAGS := -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ -Wno-unused -Wno-sign-compare -Wno-pointer-sign -LYX := lyx -DOXYGEN := doxygen +LEX := flex + +LYX := lyx +DOXYGEN := doxygen + DOXYGEN_OUTPUT_DIR := doxygen # make is silent per default. make V=1 will show all compiler calls. @@ -85,11 +88,16 @@ LINUXBIOSINCLUDE := -I$(src) -Iinclude \ ifneq ($(strip $(have_dotxcompile)),) include $(src)/.xcompile - CC := $(CC_$(ARCH)) - AS := $(AS_$(ARCH)) - LD := $(LD_$(ARCH)) +else + include $(shell $(src)/util/xcompile/xcompile > $(src)/.xcompile || \ + { echo "complete\\ toolchain" && rm -f $(src)/.xcompile && exit 1; }; echo $(src)/.xcompile) endif +CC := $(CC_$(ARCH)) +AS := $(AS_$(ARCH)) +LD := $(LD_$(ARCH)) +OBJCOPY := $(OBJCOPY_$(ARCH)) + CPPFLAGS := $(LINUXBIOSINCLUDE) CFLAGS += $(LINUXBIOSINCLUDE) @@ -128,9 +136,9 @@ prepare2: $(Q)printf "#define LINUXBIOS_ASSEMBLER \"$(shell LANG= $(AS) --version | head -n1)\"\n" >> $(obj)/build.h $(Q)printf "#define LINUXBIOS_LINKER \"$(shell LANG= $(LD) --version | head -n1)\"\n" >> $(obj)/build.h $(Q)printf "#define LINUXBIOS_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.h - $(Q)printf "#define LINUXBIOS_COMPILE_BY \"$(shell whoami)\"\n" >> $(obj)/build.h + $(Q)printf "#define LINUXBIOS_COMPILE_BY \"$(shell PATH=$$PATH:/usr/ucb whoami)\"\n" >> $(obj)/build.h $(Q)printf "#define LINUXBIOS_COMPILE_HOST \"$(shell hostname)\"\n" >> $(obj)/build.h - $(Q)printf "#define LINUXBIOS_COMPILE_DOMAIN \"$(shell dnsdomainname)\"\n" >> $(obj)/build.h + $(Q)printf "#define LINUXBIOS_COMPILE_DOMAIN \"$(shell which dnsdomainname 1>/dev/null && dnsdomainname || domainname)\"\n" >> $(obj)/build.h clean: diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 51c302d3c1..ebcb209b37 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -90,7 +90,7 @@ $(obj)/stage0.init: $(STAGE0_OBJ) $(STAGE0_OBJ) -o $(obj)/stage0.o $(Q)printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n" - $(Q)objcopy -O binary $(obj)/stage0.o $(obj)/stage0.init + $(Q)$(OBJCOPY) -O binary $(obj)/stage0.o $(obj)/stage0.init $(Q)printf " TEST $(subst $(shell pwd)/,,$(@))\n" $(Q)test `wc -c < $(obj)/stage0.init` -gt 16128 && \ @@ -122,7 +122,9 @@ STAGE2_OBJ := $(patsubst %,$(obj)/lib/%,$(STAGE2_LIB_OBJ)) \ STAGE2_OBJ += $(STAGE2_CHIPSET_OBJ) # x86emu wants libgcc +ifneq ($(strip $(CC)),) LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name) +endif STAGE2_OBJ += $(obj)/util/x86emu/libx86emu.a $(LIBGCC_FILE_NAME) $(obj)/linuxbios.stage2: $(obj)/stage0.init $(STAGE2_OBJ) @@ -131,7 +133,7 @@ $(obj)/linuxbios.stage2: $(obj)/stage0.init $(STAGE2_OBJ) $(Q)$(LD) -R $(obj)/stage0.o -Ttext 0x1000 --entry=stage2 \ -o $(obj)/linuxbios.stage2.o $(STAGE2_OBJ) $(Q)printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n" - $(Q)objcopy -O binary $(obj)/linuxbios.stage2.o $(obj)/linuxbios.stage2 + $(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.stage2.o $(obj)/linuxbios.stage2 # diff --git a/mainboard/emulation/qemu-x86/Makefile b/mainboard/emulation/qemu-x86/Makefile index 4c3a78c647..f30013a6e1 100644 --- a/mainboard/emulation/qemu-x86/Makefile +++ b/mainboard/emulation/qemu-x86/Makefile @@ -43,7 +43,7 @@ $(obj)/linuxbios.initram: $(obj)/stage0.init $(obj)/stage0.o $(obj)/mainboard/$( $(obj)/mainboard/$(MAINBOARDDIR)/initram.o \ --entry=main -o $(obj)/linuxbios.initram.o $(Q)printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n" - $(Q)objcopy -O binary $(obj)/linuxbios.initram.o \ + $(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \ $(obj)/linuxbios.initram # diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile index 041e288032..8aaeecb23b 100755 --- a/util/xcompile/xcompile +++ b/util/xcompile/xcompile @@ -25,22 +25,42 @@ 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/` +function searchgnu() +{ + # $1 short name + # result: GNU version of that tool on stdout + # or no output if no GNU version was found + for i in "$1" "g$1" "gnu$1"; do + if test -x "`which $i 2>/dev/null`"; then + if test `$i --version 2>/dev/null |grep -c GNU` -gt 0; then + echo $i + return + fi + fi + done + echo "ERROR: Missing toolchain: $1" > &3 + exit 1 +} + case "$ARCH" in "x86_64") echo "CC_x86 := gcc -m32" - echo "AS_x86 := as --32" - echo "LD_x86 := ld -b elf32-i386 -melf_i386" + 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" - echo "AS_x86 := as" - echo "LD_x86 := ld" + 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. echo "CC_x86 := i386-linux-gcc" echo "AS_x86 := i386-linux-as" echo "LD_x86 := i386-linux-ld" + echo "OBJCOPY_x86 := i386-linux-objcopy" ;; esac