make only needs to read Makefile.incs once, thanks to the

SECONDEXPANSION feature of GNU make (and we rely on GNU make for lots of
things already)

File paths are relative to the root directory, which simplifies
debugging (make V=1 gives shorter command lines) and helps ccache
finding matches for checkouts in different directories (even though it
should normalize paths itself)

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5304 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Patrick Georgi 2010-03-27 17:18:39 +00:00
parent 9417cc05fc
commit 51e142fef4
8 changed files with 38 additions and 68 deletions

View File

@ -33,9 +33,9 @@ HOSTCXX:=$(CC_real) --hostcxx
endif
export top := $(PWD)
export src := $(top)/src
export src := src
export srck := $(top)/util/kconfig
export obj ?= $(top)/build
export obj ?= build
export objk := $(obj)/util/kconfig
export sconfig := $(top)/util/sconfig
export yapps2_py := $(sconfig)/yapps2.py
@ -136,9 +136,12 @@ all:
chmod +x .ccwrap
scan-build $(CONFIG_SCANBUILD_REPORT_LOCATION) -analyze-headers --use-cc=$(top)/.ccwrap --use-c++=$(top)/.ccwrap $(MAKE) INNER_SCANBUILD=y
else
all: $(obj)/config.h coreboot
all: $(obj)/config.h $(obj)/build.h coreboot
endif
# must come rather early
.SECONDEXPANSION:
$(obj)/config.h:
$(MAKE) oldconfig
@ -156,7 +159,7 @@ $(obj)/mainboard/$(MAINBOARDDIR)/config.py: $(yapps2_py) $(config_g)
# Creation of these is architecture and mainboard independent
$(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb $(obj)/mainboard/$(MAINBOARDDIR)/config.py
mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
(cd $(obj)/mainboard/$(MAINBOARDDIR) ; PYTHONPATH=$(top)/util/sconfig export PYTHONPATH; python config.py $(MAINBOARDDIR) $(top) $(obj)/mainboard/$(MAINBOARDDIR))
(PYTHONPATH=$(top)/util/sconfig python $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(MAINBOARDDIR) $(top) $(obj)/mainboard/$(MAINBOARDDIR))
objs:=$(obj)/mainboard/$(MAINBOARDDIR)/static.o
initobjs:=
@ -173,9 +176,9 @@ includemakefiles= \
$(foreach type,$(2), $(eval $(type)-y:=)) \
$(eval subdirs-y:=) \
$(eval -include $(1)) \
$(if $(strip $(3)), \
$(foreach type,$(2), \
$(eval $(type)s+= \
$$(subst $(top)/,, \
$$(abspath $$(patsubst src/%, \
$(obj)/%, \
$$(addprefix $(dir $(1)),$$($(type)-y))))))) \
@ -187,12 +190,12 @@ evaluate_subdirs= \
$(eval cursubdirs:=$(subdirs)) \
$(eval subdirs:=) \
$(foreach dir,$(cursubdirs), \
$(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types),$(1)))) \
$(if $(subdirs),$(eval $(call evaluate_subdirs, $(1))))
$(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types)))) \
$(if $(subdirs),$(eval $(call evaluate_subdirs)))
# collect all object files eligible for building
subdirs:=$(PLATFORM-y) $(BUILD-y)
$(eval $(call evaluate_subdirs, modify))
$(eval $(call evaluate_subdirs))
initobjs:=$(addsuffix .initobj.o, $(basename $(initobjs)))
drivers:=$(addsuffix .driver.o, $(basename $(drivers)))
@ -203,17 +206,10 @@ alldirs:=$(sort $(abspath $(dir $(allobjs))))
source_with_ext=$(patsubst $(obj)/%.o,src/%.$(1),$(allobjs))
allsrc=$(wildcard $(call source_with_ext,c) $(call source_with_ext,S))
POST_EVALUATION:=y
# fetch rules (protected in POST_EVALUATION) that rely on the variables filled above
subdirs:=$(PLATFORM-y) $(BUILD-y)
$(eval $(call evaluate_subdirs))
define objs_asl_template
$(obj)/$(1)%.o: src/$(1)%.asl
@printf " IASL $$(subst $(top)/,,$$(@))\n"
$(CPP) -D__ACPI__ -P -include $(obj)/config.h -I$(src) -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl
$(CPP) -D__ACPI__ -P -include $(abspath $(obj)/config.h) -I$(src) -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl
iasl -p $$(basename $$@) -tc $$(basename $$@).asl
mv $$(basename $$@).hex $$(basename $$@).c
$(CC) $$(CFLAGS) $$(if $$(subst dsdt,,$$(basename $$(notdir $$@))), -DAmlCode=AmlCode_$$(basename $$(notdir $$@))) -c -o $$@ $$(basename $$@).c
@ -226,7 +222,7 @@ define create_cc_template
# $3 .o infix ("" ".initobj", ...)
# $4 additional compiler flags
de$(EMPTY)fine $(1)_$(2)_template
$(obj)/$$(1)%$(3).o: src/$$(1)%.$(2) $(obj)/config.h
$(obj)/$$(1)%$(3).o: src/$$(1)%.$(2) | $(obj)/build.h $(obj)/config.h
printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
$(CC) $(4) -MMD $$$$(CFLAGS) -c -o $$$$@ $$$$<
en$(EMPTY)def
@ -270,9 +266,10 @@ printcrt0s:
@echo $(patsubst $(top)/%,%,$(crt0s))
OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y))
INCLUDES := -I$(top)/src -I$(top)/src/include -I$(obj) -I$(top)/src/arch/$(ARCHDIR-y)/include
INCLUDES += -I$(top)/src/devices/oprom/include
INCLUDES += -include $(obj)/config.h
INCLUDES := -Isrc -Isrc/include -I$(obj) -Isrc/arch/$(ARCHDIR-y)/include
INCLUDES += -Isrc/devices/oprom/include
# abspath is a workaround for romcc
INCLUDES += -include $(abspath $(obj)/config.h) -include $(abspath $(obj)/build.h)
CFLAGS = $(INCLUDES) -Os -nostdinc -pipe
CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
@ -298,7 +295,7 @@ prepare:
mkdir -p $(obj)/util/kconfig/lxdialog $(obj)/util/cbfstool
test -n "$(alldirs)" && mkdir -p $(alldirs) || true
$(obj)/build.h: .xcompile
$(obj)/build.h $(abspath $(obj)/build.h): .xcompile
@printf " GEN build.h\n"
rm -f $(obj)/build.h
printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht

View File

@ -1,5 +1,3 @@
ifdef POST_EVALUATION
#######################################################################
# Build the final rom image
@ -14,11 +12,11 @@ $(obj)/coreboot.bootblock: $(obj)/coreboot
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
$(OBJCOPY) -O binary $< $@
$(obj)/ldscript.ld: $(ldscripts) $(obj)/ldoptions
$(obj)/ldscript.ld: $$(ldscripts) $(obj)/ldoptions
printf 'INCLUDE "ldoptions"\n' > $@
printf '$(foreach ldscript,$(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' >> $@
$(obj)/crt0_includes.h: $(crt0s)
$(obj)/crt0_includes.h: $$(crt0s)
@printf " GEN $(subst $(obj)/,,$(@))\n"
printf '$(foreach crt0,config.h $(crt0s),#include "$(crt0:$(obj)/%=%)"\n)' > $@
@ -30,9 +28,8 @@ $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s: $(src)/arch/i386/init/crt0.S.lb $(obj)/
@printf " CC $(subst $(obj)/,,$(@))\n"
$(CC) -MMD -x assembler-with-cpp -DASSEMBLY -E -I$(src)/include -I$(src)/arch/i386/include -I$(obj) -include $(obj)/config.h -I. -I$(src) $< > $@.new && mv $@.new $@
$(obj)/coreboot: $(initobjs) $(obj)/ldscript.ld
$(obj)/coreboot: $$(initobjs) $(obj)/ldscript.ld
@printf " LINK $(subst $(obj)/,,$(@))\n"
$(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(obj)/ldscript.ld $(initobjs)
$(NM) -n $(obj)/coreboot | sort > $(obj)/coreboot.map
endif

View File

@ -1,5 +1,3 @@
ifdef POST_EVALUATION
#######################################################################
# Build the final rom image
@ -49,12 +47,12 @@ ifeq ($(CONFIG_SSE),y)
bootblock_romccflags := -mcpu=k7 -msse -O2
endif
$(obj)/bootblock/ldscript.ld: $(bootblock_ldscripts) $(obj)/ldoptions
$(obj)/bootblock/ldscript.ld: $$(bootblock_lds) $(obj)/ldoptions
@printf " GEN $(subst $(obj)/,,$(@))\n"
mkdir -p $(obj)/bootblock
printf '$(foreach ldscript,ldoptions $(bootblock_lds),INCLUDE "$(ldscript)"\n)' > $@
$(obj)/bootblock/bootblock.c: $(bootblock_inc)
$(obj)/bootblock/bootblock.c: $$(bootblock_inc)
@printf " GEN $(subst $(obj)/,,$(@))\n"
mkdir -p $(obj)/bootblock
printf '$(foreach crt0,config.h $(bootblock_inc),#include "$(crt0)"\n)' > $@
@ -80,7 +78,7 @@ $(obj)/bootblock.elf: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o $(obj)/bootbl
#######################################################################
# Build the romstage
$(obj)/coreboot.romstage: $(obj)/coreboot.pre1 $(initobjs) $(obj)/romstage/ldscript.ld
$(obj)/coreboot.romstage: $(obj)/coreboot.pre1 $$(initobjs) $(obj)/romstage/ldscript.ld
@printf " LINK $(subst $(obj)/,,$(@))\n"
printf "CONFIG_ROMBASE = 0x0;\nAUTO_XIP_ROM_BASE = 0x0;\n" > $(obj)/location.ld
$(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/ldscript.ld $(initobjs)
@ -93,12 +91,12 @@ $(obj)/coreboot.romstage: $(obj)/coreboot.pre1 $(initobjs) $(obj)/romstage/ldscr
$(NM) -n $(obj)/romstage.elf | sort > $(obj)/romstage.map
$(OBJCOPY) -O binary $(obj)/romstage.elf $@
$(obj)/romstage/ldscript.ld: $(ldscripts) $(obj)/ldoptions
$(obj)/romstage/ldscript.ld: $$(ldscripts) $(obj)/ldoptions
@printf " GEN $(subst $(obj)/,,$(@))\n"
mkdir -p $(obj)/romstage
printf '$(foreach ldscript,ldoptions location.ld $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' > $@
$(obj)/romstage/crt0_includes.h: $(crt0s)
$(obj)/romstage/crt0_includes.h: $$(crt0s)
@printf " GEN $(subst $(obj)/,,$(@))\n"
mkdir -p $(obj)/romstage
printf '$(foreach crt0,config.h $(crt0s),#include "$(crt0:$(obj)/%=%)"\n)' > $@
@ -111,4 +109,3 @@ $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s: $(src)/arch/i386/init/crt0.S.lb $(obj)/
@printf " CC $(subst $(obj)/,,$(@))\n"
$(CC) -x assembler-with-cpp -DASSEMBLY -E -I$(src)/include -I$(src)/arch/i386/include -I$(obj) -I$(obj)/romstage -include $(obj)/config.h -I. -I$(src) $< > $@.new && mv $@.new $@
endif

View File

@ -7,8 +7,6 @@ subdirs-y += smp
obj-$(CONFIG_HAVE_OPTION_TABLE) += ../../option_table.o
ifdef POST_EVALUATION
#######################################################################
# Build the final rom image
COREBOOT_ROM_DEPENDENCIES:=
@ -73,14 +71,14 @@ $(obj)/coreboot_ram: $(obj)/coreboot_ram.o $(src)/arch/i386/coreboot_ram.ld #ldo
$(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/i386/coreboot_ram.ld $(obj)/coreboot_ram.o
$(NM) -n $(obj)/coreboot_ram | sort > $(obj)/coreboot_ram.map
$(obj)/coreboot_ram.o: $(obj)/arch/i386/lib/c_start.o $(drivers) $(obj)/coreboot.a $(LIBGCC_FILE_NAME)
$(obj)/coreboot_ram.o: $(obj)/arch/i386/lib/c_start.o $$(drivers) $(obj)/coreboot.a $(LIBGCC_FILE_NAME)
@printf " CC $(subst $(obj)/,,$(@))\n"
$(CC) -nostdlib -r -o $@ $(obj)/arch/i386/lib/c_start.o $(drivers) -Wl,--start-group $(obj)/coreboot.a $(LIBGCC_FILE_NAME) -Wl,--end-group
$(obj)/coreboot.a: $(objs)
$(obj)/coreboot.a: $$(objs)
@printf " AR $(subst $(obj)/,,$(@))\n"
rm -f $(obj)/coreboot.a
$(AR) cr $(obj)/coreboot.a $(objs)
$(AR) cr $(obj)/coreboot.a $^
#######################################################################
# done
@ -195,7 +193,7 @@ ROMCCFLAGS ?= -mcpu=p2 -O2
$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(obj)/romcc $(OPTION_TABLE_H) $(obj)/build.h
printf " ROMCC romstage.inc\n"
$(ROMCC) -c -S $(ROMCCFLAGS) -include $(obj)/build.h -I. $(INCLUDES) $< -o $@
$(ROMCC) -c -S $(ROMCCFLAGS) -I. $(INCLUDES) $< -o $@
else
@ -205,7 +203,7 @@ $(obj)/mainboard/$(MAINBOARDDIR)/ap_romstage.o: $(src)/mainboard/$(MAINBOARDDIR)
$(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h
printf " CC romstage.inc\n"
$(CC) -MMD $(CFLAGS) -include $(obj)/build.h -I$(src) -I. -c -S $< -o $@
$(CC) -MMD $(CFLAGS) -I$(src) -I. -c -S $< -o $@
$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc
printf " POST romstage.inc\n"
@ -213,9 +211,6 @@ $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(obj)/mainboard/$(MAINBOARDDIR)/
mv $@.tmp $@
endif
else
# Only in first pass
# Things that appear in every board
initobjs += $(obj)/mainboard/$(MAINBOARDDIR)/crt0.o
objs += $(obj)/mainboard/$(MAINBOARDDIR)/mainboard.o
@ -249,8 +244,6 @@ ifeq ($(CONFIG_HAVE_BUS_CONFIG),y)
objs += $(obj)/mainboard/$(MAINBOARDDIR)/get_bus_conf.o
endif
endif
ifeq ($(CONFIG_TINY_BOOTBLOCK),y)
include $(src)/arch/i386/Makefile.bootblock.inc
else

View File

@ -8,8 +8,3 @@ obj-y += exception.o
initobj-y += printk_init.o
initobj-y += cbfs_and_run.o
ifdef POST_EVALUATION
$(obj)/arch/i386/lib/console.o :: $(obj)/build.h
endif

View File

@ -25,9 +25,7 @@ smmobj-y += smmhandler.o
smmobj-y += smihandler.o
smmobj-y += smiutil.o
ifdef POST_EVALUATION
$(obj)/cpu/x86/smm/smm.o: $(smmobjs)
$(obj)/cpu/x86/smm/smm.o: $$(smmobjs)
$(CC) $(LDFLAGS) -nostdlib -r -o $@ $^
$(obj)/cpu/x86/smm/smm: $(obj)/cpu/x86/smm/smm.o $(src)/cpu/x86/smm/smm.ld $(obj)/ldoptions
@ -42,5 +40,3 @@ $(obj)/cpu/x86/smm/smm_bin.o: $(obj)/cpu/x86/smm/smm_bin.c
@printf " CC $(subst $(obj)/,,$(@))\n"
$(CC) $(CFLAGS) -c -o $@ $<
endif

View File

@ -18,7 +18,7 @@ ABUILD_DATE="January 29th, 2010"
ABUILD_VERSION="0.9"
# Where shall we place all the build trees?
TARGET=$( pwd )/coreboot-builds
TARGET=coreboot-builds
XMLFILE=$( pwd )/abuild.xml
# path to payload. Should be more generic

View File

@ -1,6 +1,3 @@
ifdef POST_EVALUATION
cbfsobj :=
cbfsobj += common.o
cbfsobj += compress.o
@ -53,5 +50,3 @@ $(obj)/util/cbfstool/cbfstool: $(obj)/util/cbfstool $(addprefix $(obj)/util/cbfs
printf " HOSTCXX $(subst $(obj)/,,$(@)) (link)\n"
$(HOSTCXX) $(CBFSTOOLFLAGS) -o $@ $(addprefix $(obj)/util/cbfstool/,$(cbfsobj))
endif