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
BUILD-y += util/cbfstool
BUILD-$(CONFIG_ARCH_X86) += src/pc80
+ifneq ($(CONFIG_LOCALVERSION),"")
+COREBOOT_EXTRA_VERSION := -$(shell echo $(CONFIG_LOCALVERSION))
+endif
+
# The primary target needs to be here before we include the
# other files
$(eval $(call evaluate_subdirs))
+define c_dsl_template
+$(obj)/$(1)%.c: src/$(1)%.dsl
+ @printf " IASL $$(subst $$(shell pwd)/,,$$(@))\n"
+ iasl -p $$(basename $$@) -tc $$<
+ perl -pi -e 's/AmlCode/AmlCode_$$(notdir $$(basename $$@))/g' $$(basename $$@).hex
+ mv $$(basename $$@).hex $$@
+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
usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d)))))
usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call $(1)_$(2)_template,$(subst $(obj)/,,$(d)))))
+$(eval $(call usetemplate,c,dsl))
$(eval $(call usetemplate,objs,c))
$(eval $(call usetemplate,objs,S))
$(eval $(call usetemplate,initobjs,c))
STACKPROTECT += $(call cc-option, -fno-stack-protector,)
-CFLAGS = $(STACKPROTECT) $(INCLUDES) $(MAINBOARD_OPTIONS) -Os -nostdinc
+CFLAGS = $(STACKPROTECT) $(INCLUDES) -Os -nostdinc
CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS +=-Wwrite-strings -Wredundant-decls -Wno-trigraphs
-CFLAGS += -Werror-implicit-function-declaration -Wstrict-aliasing -Wshadow
+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:=
-ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y)
CBFS_COMPRESS_FLAG:=l
+CBFS_PAYLOAD_COMPRESS_FLAG:=
+ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y)
+CBFS_PAYLOAD_COMPRESS_FLAG:=l
endif
coreboot: prepare prepare2 $(obj)/coreboot.rom
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
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* .xcompile
+ rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.*
+ 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)
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