Rework Makefile a bit.

rename TARGET to BOARD (fix #55)
use .INTERMEDIATE trick to avoid building multiple times (fix #52)
Don't touch build/*/.config if we don't have to (fix #51)
This commit is contained in:
Trammell Hudson 2016-11-29 11:19:48 -05:00
parent 4a83273744
commit e55a6a4df4
Failed to extract signature
14 changed files with 31 additions and 26 deletions

View File

@ -5,9 +5,12 @@ build := $(pwd)/build
config := $(pwd)/build config := $(pwd)/build
# Currently supported targets are x230, chell and qemu # Currently supported targets are x230, chell and qemu
TARGET ?= x230 BOARD ?= x230
all: $(TARGET).rom all: $(BOARD).rom
# Disable all built in rules
.SUFFIXES:
# Bring in all of the module definitions; # Bring in all of the module definitions;
@ -15,7 +18,9 @@ all: $(TARGET).rom
# as part of creating the Heads firmware image. # as part of creating the Heads firmware image.
include modules/* include modules/*
all: $(modules) # These will be built via their intermediate targets
# This increases the build time, so it is commented out for now
#all: $(foreach m,$(modules),$m.intermediate)
define prefix = define prefix =
$(foreach _, $2, $1$_) $(foreach _, $2, $1$_)
@ -68,8 +73,14 @@ define define_module =
endif endif
# Copy our stored config file into the unpacked directory # Copy our stored config file into the unpacked directory
$(build)/$($1_dir)/.config: config/$($1_config) $(build)/$($1_dir)/.canary ifdef $1_config
cp "$$<" "$$@" $(build)/$($1_dir)/.config: config/$($1_config) $(build)/$($1_dir)/.canary
cp -a "$$<" "$$@"
else
$(build)/$($1_dir)/.config: $(build)/$($1_dir)/.canary
touch "$$@"
endif
# Use the module's configure variable to build itself # Use the module's configure variable to build itself
$(build)/$($1_dir)/.configured: \ $(build)/$($1_dir)/.configured: \
@ -79,14 +90,18 @@ define define_module =
touch "$$@" touch "$$@"
# Build the target after any dependencies # Build the target after any dependencies
$(call outputs,$1): \ $(call outputs,$1): $1.intermediate
$(build)/$($1_dir)/.configured \
$(call outputs,$($1_depends))
make -C "$(build)/$($1_dir)" $($1_target)
# Short hand target for the module # Short hand target for the module
$1: $(call outputs,$1) #$1: $(call outputs,$1)
# Target for all of the outputs, which depend on their dependent modules
$1.intermediate: \
$(build)/$($1_dir)/.configured \
$(foreach d,$($1_depends),$d.intermediate)
make -C "$(build)/$($1_dir)" $($1_target)
.INTERMEDIATE: $1.intermediate
endef endef
$(foreach _, $(modules), $(eval $(call define_module,$_))) $(foreach _, $(modules), $(eval $(call define_module,$_)))
@ -208,6 +223,8 @@ initrd.cpio: $(initrd_bins) $(initrd_libs) initrd_lib_install
echo "$@: Unchanged"; \ echo "$@: Unchanged"; \
rm "$@.tmp"; \ rm "$@.tmp"; \
fi fi
initrd.intermediate: initrd.cpio
# populate the coreboot initrd image from the one we built. # populate the coreboot initrd image from the one we built.

View File

@ -1 +0,0 @@
# nothing

View File

@ -1 +0,0 @@
# nothing

View File

@ -1 +0,0 @@
# nothing

View File

@ -1 +0,0 @@
# nothing

View File

@ -1 +0,0 @@
# nothing

View File

@ -1 +0,0 @@
# Nothing

View File

@ -11,15 +11,15 @@ coreboot_repo := https://github.com/osresearch/coreboot
# Coreboot builds are specialized on a per-target basis. # Coreboot builds are specialized on a per-target basis.
# The builds are done in a per-target subdirectory # The builds are done in a per-target subdirectory
coreboot_config := coreboot-$(TARGET).config #coreboot_config := coreboot-$(TARGET).config
coreboot_configure := \ coreboot_configure := \
make oldconfig obj=./$(TARGET) DOTCONFIG=../../config/coreboot-$(TARGET).config make oldconfig obj=./$(BOARD) DOTCONFIG=../../config/coreboot-$(BOARD).config
coreboot_target := \ coreboot_target := \
obj=./$(TARGET) DOTCONFIG=../../config/coreboot-$(TARGET).config -j 8 obj=./$(BOARD) DOTCONFIG=../../config/coreboot-$(BOARD).config -j 8
coreboot_output := $(TARGET)/coreboot.rom coreboot_output := $(BOARD)/coreboot.rom
# hack to force a build dependency on the cross compiler # hack to force a build dependency on the cross compiler

View File

@ -7,5 +7,4 @@ cryptsetup_url := https://www.kernel.org/pub/linux/utils/cryptsetup/v1.7/cryptse
cryptsetup_hash := dbb35dbf5f0c1749168c86c913fe98e872247bfc8425314b494c2423e7e43342 cryptsetup_hash := dbb35dbf5f0c1749168c86c913fe98e872247bfc8425314b494c2423e7e43342
cryptsetup_configure := ./configure cryptsetup_configure := ./configure
cryptsetup_config := cryptsetup.config
cryptsetup_output := cryptsetup_output :=

View File

@ -8,4 +8,3 @@ kexec_hash := cc7b60dad0da202004048a6179d8a53606943062dd627a2edba45a8ea3a85135
kexec_configure := ./configure kexec_configure := ./configure
kexec_output := build/sbin/kexec kexec_output := build/sbin/kexec
kexec_config := kexec.config

View File

@ -11,4 +11,3 @@ mbedtls_libraries := \
mbedtls_configure := mbedtls_configure :=
mbedtls_target := SHARED=1 mbedtls_target := SHARED=1
mbedtls_config := mbedtls.config

View File

@ -8,4 +8,3 @@ qrencode_hash := e794e26a96019013c0e3665cb06b18992668f352c5553d0a553f5d144f7f2a7
qrencode_output := .libs/libqrencode.so.$(qrencode_version) qrencode_output := .libs/libqrencode.so.$(qrencode_version)
qrencode_configure := ./configure --without-tools qrencode_configure := ./configure --without-tools
qrencode_config := qrencode.config

View File

@ -42,4 +42,3 @@ tpmtotp_libraries := \
libtpm/libtpm.so \ libtpm/libtpm.so \
tpmtotp_configure := tpmtotp_configure :=
tpmtotp_config := tpmtotp.config

View File

@ -11,4 +11,3 @@ xen_hash := 02badfce9a037bd1bd4a94210c1f6b85467746216c71795805102b514bcf1fc4
xen_output := xen.gz xen_output := xen.gz
xen_configure := xen_configure :=
xen_target := -j 8 xen_target := -j 8
xen_config := xen.config