From 387412a0fa9f34be9aba91694acc574787a35605 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 16 Jul 2007 22:42:21 +0000 Subject: [PATCH] This patch fixes compilation on OS X Signed-off-by: Stefan Reinauer Acked-by: Uwe Hermann git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@456 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- HACKING | 12 ++++++++++++ Makefile | 4 +++- util/dtc/data.c | 2 +- util/dtc/dtc.h | 2 +- util/dtc/flattree.c | 4 ++-- util/dtc/ftdump.c | 4 ++-- util/dtc/libdt.c | 4 ++-- util/kconfig/Makefile | 12 ++++++------ util/xcompile/xcompile | 30 +++++++++++++++++++++++++----- 9 files changed, 54 insertions(+), 20 deletions(-) diff --git a/HACKING b/HACKING index 185d794f69..019d37f21c 100644 --- a/HACKING +++ b/HACKING @@ -32,6 +32,18 @@ Required software: * dot (>= 1.8.10) http://www.graphviz.org/ +Building on Mac OS X +------------------- + +You have to install MacPorts (tried with 1.4). + +Then you go + + $ sudo port install gettext + $ sudo port install bison + $ sudo port install i386-elf-binutils + $ sudo port install i386-elf-gcc + $ rehash Third-party Code and License Overview ------------------------------------- diff --git a/Makefile b/Makefile index 37613c9972..239289b173 100644 --- a/Makefile +++ b/Makefile @@ -96,6 +96,8 @@ CC := $(CC_$(ARCH)) AS := $(AS_$(ARCH)) LD := $(LD_$(ARCH)) OBJCOPY := $(OBJCOPY_$(ARCH)) +AR := $(AR_$(ARCH)) + CFLAGS += $(CFLAGS_$(ARCH)) CPPFLAGS := $(LINUXBIOSINCLUDE) @@ -144,7 +146,7 @@ prepare2: $(Q)printf "#define LINUXBIOS_COMPILE_TIME \"`LANG= date +%T`\"\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 which dnsdomainname 1>/dev/null && dnsdomainname || domainname)\"\n" >> $(obj)/build.h + $(Q)printf "#define LINUXBIOS_COMPILE_DOMAIN \"$(shell test `uname -s` == "Linux" && dnsdomainname || domainname)\"\n" >> $(obj)/build.h clean: $(Q)printf " CLEAN $(subst $(shell pwd)/,,$(obj))\n" diff --git a/util/dtc/data.c b/util/dtc/data.c index 1389710aea..1e6c3fb6a9 100644 --- a/util/dtc/data.c +++ b/util/dtc/data.c @@ -237,7 +237,7 @@ struct data data_append_zeroes(struct data d, int len) struct data data_append_align(struct data d, int align) { - int newlen = ALIGN(d.len, align); + int newlen = DALIGN(d.len, align); return data_append_zeroes(d, newlen - d.len); } diff --git a/util/dtc/dtc.h b/util/dtc/dtc.h index 171d094d42..a375ff8bcb 100644 --- a/util/dtc/dtc.h +++ b/util/dtc/dtc.h @@ -90,7 +90,7 @@ typedef u32 cell_t; #define streq(a, b) (strcmp((char *)(a), (char *)(b)) == 0) #define strneq(a, b, n) (strncmp((char *)(a), (char *)(b), (n)) == 0) -#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) +#define DALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /* Data blobs */ diff --git a/util/dtc/flattree.c b/util/dtc/flattree.c index 074d9616d0..828b1ed175 100644 --- a/util/dtc/flattree.c +++ b/util/dtc/flattree.c @@ -960,7 +960,7 @@ static void make_bph(struct boot_param_header *bph, bph->last_comp_version = cpu_to_be32(vi->last_comp_version); /* Reserve map should be doubleword aligned */ - reserve_off = ALIGN(vi->hdr_size, 8); + reserve_off = DALIGN(vi->hdr_size, 8); bph->off_mem_rsvmap = cpu_to_be32(reserve_off); bph->off_dt_struct = cpu_to_be32(reserve_off + reservesize); @@ -1395,7 +1395,7 @@ static void flat_realign(struct inbuf *inb, int align) { int off = inb->ptr - inb->base; - inb->ptr = inb->base + ALIGN(off, align); + inb->ptr = inb->base + DALIGN(off, align); if (inb->ptr > inb->limit) die("Premature end of data parsing flat device tree\n"); } diff --git a/util/dtc/ftdump.c b/util/dtc/ftdump.c index 4d4354b68c..c82450379a 100644 --- a/util/dtc/ftdump.c +++ b/util/dtc/ftdump.c @@ -25,8 +25,8 @@ #define be64_to_cpu(x) bswap_64(x) #endif -#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) -#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) +#define DALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) +#define PALIGN(p, a) ((void *)(DALIGN((unsigned long)(p), (a)))) #define GET_CELL(p) (p += 4, *((uint32_t *)(p-4))) static int is_printable_string(const void *data, int len) diff --git a/util/dtc/libdt.c b/util/dtc/libdt.c index d187ca95f2..5136bcf374 100644 --- a/util/dtc/libdt.c +++ b/util/dtc/libdt.c @@ -23,8 +23,8 @@ #include "flat_dt.h" -#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) -#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) +#define DALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) +#define PALIGN(p, a) ((void *)(DALIGN((unsigned long)(p), (a)))) #define GET_CELL(p) (p += 4, *((uint32_t *)(p-4))) static char *skip_name(char *p) diff --git a/util/kconfig/Makefile b/util/kconfig/Makefile index 9a61e6a61c..93b1ef5cef 100644 --- a/util/kconfig/Makefile +++ b/util/kconfig/Makefile @@ -102,7 +102,7 @@ gconf-objects := gconf.o kconfig_load.o zconf.tab.o $(obj)/util/kconfig/mconf: $(patsubst %,$(obj)/util/kconfig/%,$(mconf-objects)) $(Q)printf " HOSTCC $(subst $(shell pwd)/,,$(@))\n" - $(Q)$(HOSTCC) $(CURSESLIBS) -o $@ $^ + $(Q)$(HOSTCC) $(CURSESLIBS) $(INTLLIBS) -o $@ $^ $(obj)/util/kconfig/conf: $(patsubst %,$(obj)/util/kconfig/%,$(conf-objects)) $(Q)printf " HOSTCC $(subst $(shell pwd)/,,$(@))\n" @@ -121,17 +121,17 @@ $(obj)/util/kconfig/gconf: $(patsubst %,$(obj)/util/kconfig/%,$(gconf-objects)) $(obj)/util/kconfig/mconf.o: $(src)/util/kconfig/mconf.c $(Q)mkdir -p $(obj)/util/kconfig $(Q)printf " HOSTCC $(subst $(shell pwd)/,,$(@))\n" - $(Q)$(HOSTCC) -I$(src)/util/kconfig -c -o $@ $< + $(Q)$(HOSTCC) $(HOSTCFLAGS) $(INTLCFLAGS) -I$(src)/util/kconfig -c -o $@ $< $(obj)/util/kconfig/conf.o: $(src)/util/kconfig/conf.c $(Q)mkdir -p $(obj)/util/kconfig $(Q)printf " HOSTCC $(subst $(shell pwd)/,,$(@))\n" - $(Q)$(HOSTCC) -I$(src)/util/kconfig -c -o $@ $< + $(Q)$(HOSTCC) $(HOSTCFLAGS) -I$(src)/util/kconfig -c -o $@ $< $(obj)/util/kconfig/kconfig_load.o: $(src)/util/kconfig/kconfig_load.c $(Q)mkdir -p $(obj)/util/kconfig $(Q)printf " HOSTCC $(subst $(shell pwd)/,,$(@))\n" - $(Q)$(HOSTCC) -I$(obj)/util/kconfig -I$(src)/util/kconfig -c -o $@ $< + $(Q)$(HOSTCC) $(HOSTCFLAGS) -I$(obj)/util/kconfig -I$(src)/util/kconfig -c -o $@ $< $(obj)/util/kconfig/qconf.o: $(src)/util/kconfig/qconf.cc $(obj)/util/kconfig/qconf.moc $(obj)/util/kconfig/lkc_defs.h $(Q)mkdir -p $(obj)/util/kconfig @@ -142,7 +142,7 @@ $(obj)/util/kconfig/qconf.o: $(src)/util/kconfig/qconf.cc $(obj)/util/kconfig/qc $(obj)/util/kconfig/gconf.o: $(src)/util/kconfig/gconf.c $(obj)/util/kconfig/lkc_defs.h $(Q)mkdir -p $(obj)/util/kconfig $(Q)printf " HOSTCC $(subst $(shell pwd)/,,$(@))\n" - $(Q)$(HOSTCC) `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ + $(Q)$(HOSTCC) $(HOSTCFLAGS) `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ -D LKC_DIRECT_LINK -I$(obj) -I$(src)/util/kconfig -c -o $@ $< $(obj)/util/kconfig/%.moc: $(src)/util/kconfig/%.h @@ -158,7 +158,7 @@ $(obj)/util/kconfig/lkc_defs.h: $(src)/util/kconfig/lkc_proto.h $(obj)/util/kconfig/zconf.tab.o: $(obj)/util/kconfig/zconf.tab.c $(obj)/util/kconfig/zconf.hash.c $(obj)/util/kconfig/lex.zconf.c $(Q)mkdir -p $(obj)/util/kconfig $(Q)printf " HOSTCC $(subst $(shell pwd)/,,$(@))\n" - $(Q)$(HOSTCC) -I$(src)/util/kconfig -c -o $@ $(obj)/util/kconfig/zconf.tab.c + $(Q)$(HOSTCC) $(HOSTCFLAGS) $(INTLCFLAGS) -I$(src)/util/kconfig -c -o $@ $(obj)/util/kconfig/zconf.tab.c $(obj)/util/kconfig/lex.zconf.c: $(src)/util/kconfig/lex.zconf.c_shipped $(Q)mkdir -p $(obj)/util/kconfig diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile index fa14f4bd11..2663b09ca3 100755 --- a/util/xcompile/xcompile +++ b/util/xcompile/xcompile @@ -25,6 +25,8 @@ 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/` +OS=`uname -s` + testcc() { TMP=".$$$$.tmp" @@ -56,22 +58,40 @@ case "$ARCH" in echo "CC_x86 := gcc -m32" CC="gcc -m32" + searchgnu ar >/dev/null && echo "AR_x86 := $(searchgnu ar)" 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" + if [ "$OS" != "Darwin" ]; then + 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)" + searchgnu ar >/dev/null && echo "AR_x86 := $(searchgnu ar)" + 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)" + else + CC=`find /opt/local/bin/ -name "i386-elf-gcc-*"` + if [ "$CC" == "" ]; then + echo "ERROR: Please install i386-elf-gcc from MacPorts" >&2 + exit 1 + fi + echo "CC_x86 := $CC" + echo "AR_x86 := i386-elf-ar" + echo "AS_x86 := i386-elf-as" + echo "LD_x86 := i386-elf-ld" + echo "OBJCOPY_x86 := i386-elf-objcopy" + echo "INTLCFLAGS := -I/opt/local/include" + echo "INTLLIBS := -L/opt/local/lib -lintl" + fi ;; *) # FIXME: This should be detected. CC="i386-linux-gcc" echo "CC_x86 := i386-linux-gcc" + echo "AR_x86 := i386-linux-ar" echo "AS_x86 := i386-linux-as" echo "LD_x86 := i386-linux-ld" echo "OBJCOPY_x86 := i386-linux-objcopy"