crossgcc: Fix MPFR download location
[coreboot.git] / Makefile
index b3e3e42cb980463e6772895217ad7c40d16f1930..8216146debe8b5a98d6b9ca09663236959c7cfdf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -35,7 +35,7 @@ export top := $(shell pwd)
 export src := $(top)/src
 export srck := $(top)/util/kconfig
 export obj := $(top)/build
-export objk := $(top)/build/util/kconfig
+export objk := $(obj)/util/kconfig
 export sconfig := $(top)/util/sconfig
 export yapps2_py := $(sconfig)/yapps2.py
 export config_g := $(sconfig)/config.g
@@ -159,49 +159,49 @@ endef
 
 define objs_c_template
 $(obj)/$(1)%.o: src/$(1)%.c
-       @printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+       @printf "    CC         $$(subst $$(obj)/,,$$(@))\n"
        $(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define objs_S_template
 $(obj)/$(1)%.o: src/$(1)%.S
-       @printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+       @printf "    CC         $$(subst $$(obj)/,,$$(@))\n"
        $(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define initobjs_c_template
 $(obj)/$(1)%.o: src/$(1)%.c
-       @printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+       @printf "    CC         $$(subst $$(obj)/,,$$(@))\n"
        $(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define initobjs_S_template
 $(obj)/$(1)%.o: src/$(1)%.S
-       @printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+       @printf "    CC         $$(subst $$(obj)/,,$$(@))\n"
        $(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define drivers_c_template
 $(obj)/$(1)%.o: src/$(1)%.c
-       @printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+       @printf "    CC         $$(subst $$(obj)/,,$$(@))\n"
        $(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define drivers_S_template
 $(obj)/$(1)%.o: src/$(1)%.S
-       @printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+       @printf "    CC         $$(subst $$(obj)/,,$$(@))\n"
        $(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define smmobjs_c_template
 $(obj)/$(1)%.o: src/$(1)%.c
-       @printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+       @printf "    CC         $$(subst $$(obj)/,,$$(@))\n"
        $(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define smmobjs_S_template
 $(obj)/$(1)%.o: src/$(1)%.S
-       @printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+       @printf "    CC         $$(subst $$(obj)/,,$$(@))\n"
        $(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
@@ -247,6 +247,9 @@ CFLAGS = $(STACKPROTECT) $(INCLUDES) -Os -nostdinc
 CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
 CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs 
 CFLAGS += -Wstrict-aliasing -Wshadow 
+ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
+CFLAGS += -Werror
+endif
 CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
 
 CBFS_COMPRESS_FLAG:=l
@@ -265,7 +268,7 @@ prepare:
        test -n "$(alldirs)" && mkdir -p $(alldirs) || true
 
 prepare2:
-       @printf "    GEN        $(subst $(shell pwd)/,,$(obj)/build.h)\n"
+       @printf "    GEN        build.h\n"
        printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" > $(obj)/build.h
        printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.h
        printf "#define COREBOOT_V2 \"$(COREBOOT_V2)\"\n" >> $(obj)/build.h
@@ -289,30 +292,38 @@ doxygen-clean:
        rm -rf $(DOXYGEN_OUTPUT_DIR)
 
 clean: doxygen-clean
-       rm -f $(allobjs) build/coreboot* .xcompile
-       rm -f build/option_table.* build/crt0_includes.h build/ldscript
+       rm -f $(allobjs) $(obj)/coreboot*
+       rm -f $(obj)/option_table.* $(obj)/crt0_includes.h $(obj)/ldscript
        rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot
        rm -f $(obj)/mainboard/$(MAINBOARDDIR)/auto.inc $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm
        rmdir -p $(alldirs) 2>/dev/null >/dev/null || true
+       $(MAKE) -C util/sconfig clean
 
 distclean: clean
-       rm -rf build
+       rm -rf $(obj) .xcompile
        rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig*
 
 update:
-       dongle.py -c /dev/term/1 build/coreboot.rom EOF
+       dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF
 
 # This include must come _before_ the pattern rules below!
 # Order _does_ matter for pattern rules.
 include util/kconfig/Makefile
 
 $(obj)/ldoptions: $(obj)/config.h
-#      cat $(obj)/config.h  | grep -v \" |grep -v AUTOCONF_INCLUDED | grep \#define | sed s/\#define\ // | sed s/\ /\ =\ / | sed 's/$$/;/' > $(obj)/ldoptions
-       awk '/^#define ([^"])* ([^"])*$$/ {print $$2 " = " $$3 ";";}' $< > $@
+       awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
 
+_OS=$(shell uname -s |cut -c-7)
+STACK=
+ifeq ($(_OS),MINGW32)
+       STACK=-Wl,--stack,16384000
+endif
+ifeq ($(_OS),CYGWIN_)
+       STACK=-Wl,--stack,16384000
+endif
 $(obj)/romcc: $(top)/util/romcc/romcc.c
-       @printf "    HOSTCC     romcc"
-       $(HOSTCC) -g -O2 -Wall -o $@ $<
+       @printf "    HOSTCC     $(subst $(obj)/,,$(@)) (this may take a while)\n"
+       $(HOSTCC) -g -O2 $(STACK) -Wall -o $@ $<
 
 .PHONY: $(PHONY) prepare prepare2 clean distclean doxygen doxy coreboot