parallel make fixes and hacks, which seem to work and reduce excessive remaking (issue #394)

This commit is contained in:
Trammell hudson 2018-05-02 11:38:39 -04:00
parent 8108e419fe
commit a772b27e5d
Failed to extract signature
14 changed files with 152 additions and 144 deletions

143
Makefile
View File

@ -65,9 +65,11 @@ endif
# Create a temporary directory for the initrd # Create a temporary directory for the initrd
initrd_dir := $(shell mktemp -d) initrd_dir := $(BOARD)
initrd_lib_dir := $(initrd_dir)/lib initrd_tmp_dir := $(shell mktemp -d)
initrd_bin_dir := $(initrd_dir)/bin initrd_lib_dir := $(initrd_tmp_dir)/lib
initrd_bin_dir := $(initrd_tmp_dir)/bin
modules-y += initrd
$(shell mkdir -p "$(initrd_lib_dir)" "$(initrd_bin_dir)") $(shell mkdir -p "$(initrd_lib_dir)" "$(initrd_bin_dir)")
@ -112,11 +114,8 @@ else
$(error "$(BOARD): neither CONFIG_COREBOOT nor CONFIG_LINUXBOOT is set?") $(error "$(BOARD): neither CONFIG_COREBOOT nor CONFIG_LINUXBOOT is set?")
endif endif
# helpful targets for common uses
linux: $(build)/$(BOARD)/bzImage
cpio: $(build)/$(BOARD)/initrd.cpio.xz
# Disable all built in rules # Disable all built in rules
.INTERMEDIATE:
.SUFFIXES: .SUFFIXES:
FORCE: FORCE:
@ -133,10 +132,6 @@ endef
# as part of creating the Heads firmware image. # as part of creating the Heads firmware image.
include modules/* include 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-y),$m.intermediate)
define bins = define bins =
$(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_output))) $(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_output)))
endef endef
@ -169,17 +164,20 @@ define do-cpio =
@if ! cmp --quiet "$1.tmp" "$1" ; then \ @if ! cmp --quiet "$1.tmp" "$1" ; then \
mv "$1.tmp" "$1" ; \ mv "$1.tmp" "$1" ; \
else \ else \
echo "$(DATE) UNCHANGED $(1:$(pwd)/%=%)" ; \
rm "$1.tmp" ; \ rm "$1.tmp" ; \
fi fi
endef endef
define do-copy = define do-copy =
$(call do,COPY,$1 => $2',\ $(call do,INSTALL ,$1 => $2',\
sha256sum "$(1:$(pwd)/%=%)" ; \
if ! cmp --quiet "$1" "$2" ; then \ if ! cmp --quiet "$1" "$2" ; then \
cp -a "$1" "$2"; \ cp -a "$1" "$2"; \
else \
echo "$(DATE) UNCHANGED $(1:$(pwd)/%=%)" ; \
fi fi
) )
@sha256sum "$(2:$(pwd)/%=%)"
endef endef
@ -190,21 +188,25 @@ endef
# expansion during the first evaluation. # expansion during the first evaluation.
# #
define define_module = define define_module =
# if they have not defined a separate base dir, define it
# as the same as their build dir.
$(eval $1_base_dir := $(or $($1_base_dir),$($1_dir)))
ifneq ("$($1_repo)","") ifneq ("$($1_repo)","")
# Checkout the tree instead and touch the canary file so that we know # Checkout the tree instead and touch the canary file so that we know
# that the files are all present. No signature hashes are checked in # that the files are all present. No signature hashes are checked in
# this case, since we don't have a stable version to compare against. # this case, since we don't have a stable version to compare against.
$(build)/$($1_dir)/.canary: $(build)/$($1_base_dir)/.canary:
git clone $($1_repo) "$(build)/$($1_dir)" git clone $($1_repo) "$(build)/$($1_dir)"
if [ -r patches/$1.patch ]; then \ if [ -r patches/$1.patch ]; then \
( cd $(build)/$($1_dir) ; patch -p1 ) \ ( cd $(build)/$($1_base_dir) ; patch -p1 ) \
< patches/$1.patch; \ < patches/$1.patch; \
fi fi
if [ -d patches/$1 ] && \ if [ -d patches/$1 ] && \
[ -r patches/$1 ] ; then \ [ -r patches/$1 ] ; then \
for patch in patches/$1/*.patch ; do \ for patch in patches/$1/*.patch ; do \
echo "Applying patch file : $$$$patch " ; \ echo "Applying patch file : $$$$patch " ; \
( cd $(build)/$($1_dir) ; patch -p1 ) \ ( cd $(build)/$($1_base_dir) ; patch -p1 ) \
< $$$$patch ; \ < $$$$patch ; \
done ; \ done ; \
fi fi
@ -219,17 +221,17 @@ define define_module =
# Unpack the tar file and touch the canary so that we know # Unpack the tar file and touch the canary so that we know
# that the files are all present # that the files are all present
$(build)/$($1_dir)/.canary: $(packages)/.$1-$($1_version)_verify $(build)/$($1_base_dir)/.canary: $(packages)/.$1-$($1_version)_verify
tar -xf "$(packages)/$($1_tar)" -C "$(build)" tar -xf "$(packages)/$($1_tar)" -C "$(build)"
if [ -r patches/$1-$($1_version).patch ]; then \ if [ -r patches/$1-$($1_version).patch ]; then \
( cd $(build)/$($1_dir) ; patch -p1 ) \ ( cd $(build)/$(1_base_dir) ; patch -p1 ) \
< patches/$1-$($1_version).patch; \ < patches/$1-$($1_version).patch; \
fi fi
if [ -d patches/$1-$($1_version) ] && \ if [ -d patches/$1-$($1_version) ] && \
[ -r patches/$1-$($1_version) ] ; then \ [ -r patches/$1-$($1_version) ] ; then \
for patch in patches/$1-$($1_version)/*.patch ; do \ for patch in patches/$1-$($1_version)/*.patch ; do \
echo "Applying patch file : $$$$patch " ; \ echo "Applying patch file : $$$$patch " ; \
( cd $(build)/$($1_dir) ; patch -p1 ) \ ( cd $(build)/$($1_base_dir) ; patch -p1 ) \
< $$$$patch ; \ < $$$$patch ; \
done ; \ done ; \
fi fi
@ -242,21 +244,20 @@ define define_module =
ifeq "$($1_config)" "" ifeq "$($1_config)" ""
# There is no official .config file # There is no official .config file
$($1_config_file_path): $(build)/$($1_dir)/.canary $($1_config_file_path): $(build)/$($1_base_dir)/.canary
@mkdir -p $$(dir $$@) @mkdir -p $$(dir $$@)
@touch "$$@" @touch "$$@"
else else
# Copy the stored config file into the unpacked directory # Copy the stored config file into the unpacked directory
$($1_config_file_path): $($1_config) $(build)/$($1_dir)/.canary $($1_config_file_path): $($1_config) $(build)/$($1_base_dir)/.canary
@mkdir -p $$(dir $$@) @mkdir -p $$(dir $$@)
$(call do-copy,$($1_config),$$@) $(call do-copy,$($1_config),$$@)
endif endif
# Use the module's configure variable to build itself # Use the module's configure variable to build itself
$(dir $($1_config_file_path)).configured: \ $(dir $($1_config_file_path)).configured: \
$(build)/$($1_dir)/.canary \ $(build)/$($1_base_dir)/.canary \
$($1_config_file_path) \ $($1_config_file_path) \
$(foreach d,$($1_depends),$(call outputs,$d)) \
modules/$1 modules/$1
@echo "$(DATE) CONFIG $1" @echo "$(DATE) CONFIG $1"
@( \ @( \
@ -270,19 +271,26 @@ define define_module =
$(VERBOSE_REDIRECT) $(VERBOSE_REDIRECT)
@touch "$$@" @touch "$$@"
# All of the outputs should result from building the intermediate target # Short hand for our module build target
$(call outputs,$1): $1.intermediate $1: \
$(build)/$($1_dir)/.build \
# Short hand target for the module $(call outputs,$1) \
#$1: $(call outputs,$1)
# Target for all of the outputs, which depend on their dependent modules # Target for all of the outputs, which depend on their dependent modules
$1.intermediate: \ # being built, as well as this module being configured
$(foreach d,$($1_depends),$d.intermediate) \ $(call outputs,$1): $(build)/$($1_dir)/.build
$(foreach d,$($1_depends),$(call outputs,$d)) \
# If any of the outputs are missing, we should force a rebuild
# of the entire module
$(eval $1.force = $(shell \
stat $(call outputs,$1) >/dev/null 2>/dev/null || echo FORCE \
))
$(build)/$($1_dir)/.build: $($1.force) \
$(foreach d,$($1_depends),$(build)/$($d_dir)/.build) \
$(dir $($1_config_file_path)).configured \ $(dir $($1_config_file_path)).configured \
@echo "$(DATE) MAKE $1" @echo "$(DATE) MAKE $1 --- @=$$@"
+@( \ +@( \
echo "$(MAKE) \ echo "$(MAKE) \
-C \"$(build)/$($1_dir)\" \ -C \"$(build)/$($1_dir)\" \
@ -301,7 +309,11 @@ define define_module =
tail -20 "$(log_dir)/$1.log"; \ tail -20 "$(log_dir)/$1.log"; \
exit 1; \ exit 1; \
) )
@echo "$(DATE) DONE $1" $(call do,DONE,$1,\
touch $(build)/$($1_dir)/.build \
)
$1.clean: $1.clean:
-$(RM) "$(build)/$($1_dir)/.configured" -$(RM) "$(build)/$($1_dir)/.configured"
@ -368,7 +380,6 @@ $(foreach m, $(modules-y), \
# hack to install busybox into the initrd if busybox is configured # hack to install busybox into the initrd if busybox is configured
ifeq "$(CONFIG_BUSYBOX)" "y" ifeq "$(CONFIG_BUSYBOX)" "y"
$(build)/$(BOARD)/heads.cpio: busybox.intermediate
initrd_bins += $(initrd_bin_dir)/busybox initrd_bins += $(initrd_bin_dir)/busybox
endif endif
@ -386,7 +397,7 @@ $(initrd_bin_dir)/busybox: $(build)/$(busybox_dir)/busybox
# this must be built *AFTER* musl, but since coreboot depends on other things # this must be built *AFTER* musl, but since coreboot depends on other things
# that depend on musl it should be ok. # that depend on musl it should be ok.
# #
COREBOOT_UTIL_DIR=$(build)/$(coreboot_dir)/util COREBOOT_UTIL_DIR=$(build)/$(coreboot_base_dir)/util
ifeq ($(CONFIG_COREBOOT),y) ifeq ($(CONFIG_COREBOOT),y)
$(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/cbmem/cbmem)) $(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/cbmem/cbmem))
#$(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/superiotool/superiotool)) #$(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/superiotool/superiotool))
@ -396,14 +407,16 @@ endif
$(COREBOOT_UTIL_DIR)/cbmem/cbmem \ $(COREBOOT_UTIL_DIR)/cbmem/cbmem \
$(COREBOOT_UTIL_DIR)/superiotool/superiotool \ $(COREBOOT_UTIL_DIR)/superiotool/superiotool \
$(COREBOOT_UTIL_DIR)/inteltool/inteltool \ $(COREBOOT_UTIL_DIR)/inteltool/inteltool \
: $(build)/$(coreboot_dir)/.canary \ : $(build)/$(coreboot_base_dir)/.canary \
musl.intermediate $(build)/$(musl_dir)/.build
+$(call do,MAKE,$(notdir $@),\ +$(call do,MAKE,$(notdir $@),\
$(MAKE) -C "$(dir $@)" $(CROSS_TOOLS) \ $(MAKE) -C "$(dir $@)" $(CROSS_TOOLS) \
) )
# superio depends on zlib and pciutils # superio depends on zlib and pciutils
$(COREBOOT_UTIL_DIR)/superiotool/superiotool: zlib.intermediate pciutils.intermediate $(COREBOOT_UTIL_DIR)/superiotool/superiotool: \
$(build)/$(zlib_dir)/.build \
$(build)/$(pciutils_dir)/.build \
# #
# initrd image creation # initrd image creation
@ -423,28 +436,35 @@ $(COREBOOT_UTIL_DIR)/superiotool/superiotool: zlib.intermediate pciutils.interme
# #
initrd-y += $(pwd)/blobs/dev.cpio initrd-y += $(pwd)/blobs/dev.cpio
initrd-y += $(build)/$(BOARD)/modules.cpio initrd-y += $(build)/$(initrd_dir)/modules.cpio
initrd-y += $(build)/$(BOARD)/tools.cpio initrd-y += $(build)/$(initrd_dir)/tools.cpio
initrd-$(CONFIG_HEADS) += $(build)/$(BOARD)/heads.cpio initrd-$(CONFIG_HEADS) += $(build)/$(initrd_dir)/heads.cpio
initrd.intermediate: $(build)/$(BOARD)/initrd.cpio.xz #$(build)/$(initrd_dir)/.build: $(build)/$(initrd_dir)/initrd.cpio.xz
$(build)/$(BOARD)/initrd.cpio.xz: $(initrd-y)
$(call do,CPIO-CLEAN,$@,\ $(build)/$(initrd_dir)/initrd.cpio.xz: $(initrd-y)
$(call do,CPIO-XZ ,$@,\
$(pwd)/bin/cpio-clean \ $(pwd)/bin/cpio-clean \
$^ \ $^ \
| xz \ | xz \
--check=crc32 \ --check=crc32 \
--lzma2=dict=1MiB \ --lzma2=dict=1MiB \
-9 \ -9 \
| dd bs=512 conv=sync > "$@" \ | dd bs=512 conv=sync status=none > "$@.tmp" \
) )
@sha256sum "$(@:$(pwd)/%=%)" @if ! cmp --quiet "$@.tmp" "$@" ; then \
mv "$@.tmp" "$@" ; \
sha256sum "$(@:$(pwd)/%=%)" ; \
else \
echo "$(DATE) UNCHANGED $(@:$(pwd)/%=%)" ; \
rm "$@.tmp" ; \
fi
# #
# The heads.cpio is built from the initrd directory in the # The heads.cpio is built from the initrd directory in the
# Heads tree. # Heads tree.
# #
$(build)/$(BOARD)/heads.cpio: FORCE $(build)/$(initrd_dir)/heads.cpio: FORCE
$(call do-cpio,$@,$(pwd)/initrd) $(call do-cpio,$@,$(pwd)/initrd)
@ -452,28 +472,31 @@ $(build)/$(BOARD)/heads.cpio: FORCE
# The tools initrd is made from all of the things that we've # The tools initrd is made from all of the things that we've
# created during the submodule build. # created during the submodule build.
# #
$(build)/$(BOARD)/tools.cpio: \ $(build)/$(initrd_dir)/tools.cpio: \
$(initrd_bins) \ $(initrd_bins) \
$(initrd_libs) \ $(initrd_libs) \
$(call do,INSTALL,$(CONFIG), \ $(call do,INSTALL,$(CONFIG), \
mkdir -p "$(initrd_dir)/etc" ; \ mkdir -p "$(initrd_tmp_dir)/etc" ; \
export \ export \
| grep ' CONFIG_' \ | grep ' CONFIG_' \
| sed -e 's/^declare -x /export /' \ | sed -e 's/^declare -x /export /' \
-e 's/\\\"//g' \ -e 's/\\\"//g' \
> "$(initrd_dir)/etc/config" \ > "$(initrd_tmp_dir)/etc/config" \
) )
$(call do-cpio,$@,$(initrd_dir)) $(call do-cpio,$@,$(initrd_tmp_dir))
@$(RM) -rf "$(initrd_dir)" @$(RM) -rf "$(initrd_tmp_dir)"
# Ensure that the initrd depends on all of the modules that produce
# binaries for it
$(build)/$(initrd_dir)/tools.cpio: $(foreach d,$(bin_modules-y),$(build)/$($d_dir)/.build)
# This produces a ROM image that is written with the flashrom program # This produces a ROM image that is written with the flashrom program
$(build)/$(BOARD)/coreboot.rom: $(build)/$(coreboot_dir)/$(BOARD)/coreboot.rom $(build)/$(BOARD)/coreboot.rom: $(build)/$(coreboot_dir)/.build
"$(build)/$(coreboot_dir)/$(BOARD)/cbfstool" "$<" print "$(build)/$(coreboot_dir)/cbfstool" "$(dir $<)coreboot.rom" print
$(call do,EXTRACT,$@,mv "$<" "$@") $(call do-copy,$(dir $<)coreboot.rom,$@)
@sha256sum "$(@:$(pwd)/%=%)" @touch $@ # update the time stamp
# List of all modules, excluding the slow to-build modules # List of all modules, excluding the slow to-build modules
modules-slow := musl musl-cross kernel_headers modules-slow := musl musl-cross kernel_headers
@ -501,10 +524,6 @@ real.clean:
done done
rm -rf ./install rm -rf ./install
bootstrap:
+$(MAKE) \
musl-cross.intermediate \
$(build)/$(coreboot_dir)/util/crossgcc/xgcc/bin/i386-elf-gcc \
else else
# Wrong make version detected -- build our local version # Wrong make version detected -- build our local version
@ -515,7 +534,7 @@ HEADS_MAKE := $(build)/$(make_dir)/make
# Once we have a proper Make, we can just pass arguments into it # Once we have a proper Make, we can just pass arguments into it
all bootstrap linux cpio: $(HEADS_MAKE) all bootstrap linux cpio: $(HEADS_MAKE)
LANG=C MAKE=$(HEADS_MAKE) $(HEADS_MAKE) $(MAKE_JOBS) $@ LANG=C MAKE=$(HEADS_MAKE) $(HEADS_MAKE) $(MAKE_JOBS) $@
%.clean %.intermediate %.vol: $(HEADS_MAKE) %.clean %.vol: $(HEADS_MAKE)
LANG=C MAKE=$(HEADS_MAKE) $(HEADS_MAKE) $@ LANG=C MAKE=$(HEADS_MAKE) $(HEADS_MAKE) $@
# How to download and build the correct version of make # How to download and build the correct version of make

View File

@ -16,7 +16,7 @@ CONFIG_QRENCODE=y
CONFIG_TPMTOTP=y CONFIG_TPMTOTP=y
endif endif
#CONFIG_FLASHROM=y CONFIG_FLASHROM=y
CONFIG_FLASHTOOLS=y CONFIG_FLASHTOOLS=y
CONFIG_GPG=y CONFIG_GPG=y
CONFIG_KEXEC=y CONFIG_KEXEC=y

View File

@ -14,14 +14,14 @@ CONFIG_ZLIB=n
CONFIG_MUSL=n CONFIG_MUSL=n
else else
# These don't fit if u-root is turned on # These don't fit if u-root is turned on
CONFIG_CRYPTSETUP=y #CONFIG_CRYPTSETUP=y
CONFIG_FLASHROM=y #CONFIG_FLASHROM=y
CONFIG_FLASHTOOLS=y CONFIG_FLASHTOOLS=y
CONFIG_GPG=y CONFIG_GPG=y
CONFIG_KEXEC=y CONFIG_KEXEC=y
CONFIG_UTIL_LINUX=y CONFIG_UTIL_LINUX=y
CONFIG_LVM2=y #CONFIG_LVM2=y
CONFIG_MBEDTLS=y #CONFIG_MBEDTLS=y
CONFIG_PCIUTILS=y CONFIG_PCIUTILS=y
CONFIG_POPT=y CONFIG_POPT=y
#CONFIG_QRENCODE=y #CONFIG_QRENCODE=y
@ -44,7 +44,7 @@ export CONFIG_BOOT_REQ_ROLLBACK=n
export CONFIG_BOOT_DEV="/dev/sda1" export CONFIG_BOOT_DEV="/dev/sda1"
export CONFIG_USB_BOOT_DEV="/dev/sdb1" export CONFIG_USB_BOOT_DEV="/dev/sdb1"
$(build)/$(BOARD)/linuxboot.rom: linuxboot.intermediate #$(build)/$(BOARD)/linuxboot.rom: $(build)/$(linuxboot_dir)/
# No 0x on these since the flasher doesn't handle that # No 0x on these since the flasher doesn't handle that
dxe_offset := 860000 dxe_offset := 860000

View File

@ -2,7 +2,7 @@
BOARD=x230.flash BOARD=x230.flash
export CONFIG_COREBOOT=y export CONFIG_COREBOOT=y
CONFIG_FLASHROM=y #CONFIG_FLASHROM=y
CONFIG_FLASHTOOLS=y CONFIG_FLASHTOOLS=y
CONFIG_PCIUTILS=y CONFIG_PCIUTILS=y
CONFIG_MBEDTLS=y CONFIG_MBEDTLS=y

View File

@ -37,10 +37,10 @@ export CONFIG_USB_BOOT_DEV="/dev/sdb1"
# to separate files for these pieces. # to separate files for these pieces.
all: $(build)/$(BOARD)/$(BOARD)-8.rom all: $(build)/$(BOARD)/$(BOARD)-8.rom
$(build)/$(BOARD)/$(BOARD)-8.rom: $(build)/$(BOARD)/coreboot.rom $(build)/$(BOARD)/$(BOARD)-8.rom: $(build)/$(BOARD)/coreboot.rom
dd of=$@ if=$< bs=65536 count=128 skip=0 $(call do,DD 8MB,$@,dd of=$@ if=$< bs=65536 count=128 skip=0 status=none)
sha256sum $@ @sha256sum $@
all: $(build)/$(BOARD)/$(BOARD)-4.rom all: $(build)/$(BOARD)/$(BOARD)-4.rom
$(build)/$(BOARD)/$(BOARD)-4.rom: $(build)/$(BOARD)/coreboot.rom $(build)/$(BOARD)/$(BOARD)-4.rom: $(build)/$(BOARD)/coreboot.rom
dd of=$@ if=$< bs=65536 count=64 skip=128 $(call do,DD 4MB,$@,dd of=$@ if=$< bs=65536 count=64 skip=128 status=none)
sha256sum $@ @sha256sum $@

View File

@ -13,7 +13,7 @@ busybox_config := config/busybox.config
busybox_output := busybox busybox_output := busybox
busybox_target := \ busybox_target := \
$(CROSS_TOOLS) \ $(CROSS_TOOLS) \
CONFIG_PREFIX="$(initrd_dir)" \ CONFIG_PREFIX="$(initrd_tmp_dir)" \
$(MAKE_JOBS) \ $(MAKE_JOBS) \
install install

View File

@ -3,7 +3,8 @@ modules-$(CONFIG_COREBOOT) += coreboot
#coreboot_version := git #coreboot_version := git
#coreboot_repo := https://github.com/osresearch/coreboot #coreboot_repo := https://github.com/osresearch/coreboot
coreboot_version := 4.7 coreboot_version := 4.7
coreboot_dir := coreboot-$(coreboot_version) coreboot_base_dir := coreboot-$(coreboot_version)
coreboot_dir := $(coreboot_base_dir)/$(BOARD)
coreboot_tar := coreboot-$(coreboot_version).tar.xz coreboot_tar := coreboot-$(coreboot_version).tar.xz
coreboot_url := https://www.coreboot.org/releases/$(coreboot_tar) coreboot_url := https://www.coreboot.org/releases/$(coreboot_tar)
coreboot_hash := d68a83f8f687e8ea212b8c5bb501e24444b57c3f73896042d09628188c851368 coreboot_hash := d68a83f8f687e8ea212b8c5bb501e24444b57c3f73896042d09628188c851368
@ -15,49 +16,46 @@ CONFIG_COREBOOT_CONFIG ?= config/coreboot-$(BOARD).config
EXTRA_FLAGS := -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches EXTRA_FLAGS := -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches
coreboot_configure := \ coreboot_configure := \
$(MAKE) \ $(MAKE) -C $(build)/$(coreboot_base_dir) \
oldconfig \ oldconfig \
obj=./$(BOARD) \ obj=$(build)/$(coreboot_dir) \
DOTCONFIG=../../$(CONFIG_COREBOOT_CONFIG) \ DOTCONFIG=../../$(CONFIG_COREBOOT_CONFIG) \
BUILD_TIMELESS=1 \ BUILD_TIMELESS=1 \
CFLAGS_x86_32="$(EXTRA_FLAGS)" \ CFLAGS_x86_32="$(EXTRA_FLAGS)" \
CFLAGS_x86_64="$(EXTRA_FLAGS)" \ CFLAGS_x86_64="$(EXTRA_FLAGS)" \
coreboot_target := \ coreboot_target := \
obj=./$(BOARD) \ -C $(build)/$(coreboot_base_dir) \
obj=$(build)/$(coreboot_dir) \
DOTCONFIG=../../$(CONFIG_COREBOOT_CONFIG) \ DOTCONFIG=../../$(CONFIG_COREBOOT_CONFIG) \
BUILD_TIMELESS=1 \ BUILD_TIMELESS=1 \
CFLAGS_x86_32="$(EXTRA_FLAGS)" \ CFLAGS_x86_32="$(EXTRA_FLAGS)" \
CFLAGS_x86_64="$(EXTRA_FLAGS)" \ CFLAGS_x86_64="$(EXTRA_FLAGS)" \
$(MAKE_JOBS) $(MAKE_JOBS)
coreboot_output := $(BOARD)/coreboot.rom coreboot_output := coreboot.rom
coreboot_depend += linux initrd
# hack to force a build dependency on the cross compiler # hack to force a build dependency on the cross compiler
$(build)/$(coreboot_dir)/.configured: $(build)/$(coreboot_dir)/util/crossgcc/xgcc/bin/i386-elf-gcc $(build)/$(coreboot_dir)/.configured: $(build)/$(coreboot_base_dir)/util/crossgcc/xgcc/bin/i386-elf-gcc
$(build)/$(coreboot_dir)/util/crossgcc/xgcc/bin/i386-elf-gcc: $(build)/$(coreboot_dir)/.canary $(build)/$(coreboot_base_dir)/util/crossgcc/xgcc/bin/i386-elf-gcc: $(build)/$(coreboot_base_dir)/.canary
echo '******* Building crossgcc-i386 (this might take a while) ******' echo '******* Building crossgcc-i386 (this might take a while) ******'
$(MAKE) -C "$(build)/$(coreboot_dir)" CPUS=`nproc` crossgcc-i386 $(MAKE) -C "$(build)/$(coreboot_base_dir)" CPUS=`nproc` crossgcc-i386
#echo '******* Building crossgcc-arm (this might take a while) ******' #echo '******* Building crossgcc-arm (this might take a while) ******'
#$(MAKE) -C "$(build)/$(coreboot_dir)" crossgcc-arm #$(MAKE) -C "$(build)/$(coreboot_base_dir)" crossgcc-arm
# Force a rebuild if the inputs have changed
$(build)/$(coreboot_dir)/.build: \
$(build)/$(BOARD)/bzImage \
$(build)/$(BOARD)/initrd.cpio.xz \
# The coreboot-blobs must be unpacked before we can build coreboot
# if we are using a tar file; git checkout will clone the submodule.
# The Linux kernel and Heads initrd must be built before linuxboot
# unless the user has specified "FAST=1" on the make command line,
# which will assume that the kernel and initrd are fresh
ifneq "$(FAST)" "1"
coreboot_depends := linux initrd
coreboot.intermediate: $(build)/$(BOARD)/bzImage
coreboot.intermediate: $(build)/$(BOARD)/initrd.cpio.xz
endif
# #
# Helpful target for reconfiguring the coreboot target # Helpful target for reconfiguring the coreboot target
# #
coreboot.menuconfig: coreboot.menuconfig:
$(MAKE) \ $(MAKE) \
-C "$(build)/$(coreboot_dir)" \ -C "$(build)/$(coreboot_base_dir)" \
DOTCONFIG="../../$(CONFIG_COREBOOT_CONFIG)" \ DOTCONFIG="../../$(CONFIG_COREBOOT_CONFIG)" \
menuconfig menuconfig

View File

@ -25,6 +25,6 @@ dropbear_target := \
DESTDIR="$(INSTALL)" \ DESTDIR="$(INSTALL)" \
dbclient scp dropbear \ dbclient scp dropbear \
&& \ && \
cp $(build)/$(dropbear_dir)/dbclient $(build)/$(dropbear_dir)/ssh cp -a $(build)/$(dropbear_dir)/dbclient $(build)/$(dropbear_dir)/ssh
dropbear_depends := zlib $(musl_dep) dropbear_depends := zlib $(musl_dep)

View File

@ -1,7 +1,17 @@
modules-y += linux modules-y += linux
linux_version := 4.9.80 linux_version := 4.9.80
linux_dir := linux-$(linux_version) linux_base_dir := linux-$(linux_version)
# TODO: fixup the patch process
# input file in the heads config/ dir
# Allow board config to specialize Linux configuration if necessary
linux_kconfig := $(or $(CONFIG_LINUX_CONFIG),config/linux.config)
# Output directory for the Linux kernel build is based on the
# configuration file name, not the board name
linux_dir := $(linux_base_dir)/$(notdir $(basename $(linux_kconfig)))
linux_tar := linux-$(linux_version).tar.xz linux_tar := linux-$(linux_version).tar.xz
linux_url := https://cdn.kernel.org/pub/linux/kernel/v4.x/$(linux_tar) linux_url := https://cdn.kernel.org/pub/linux/kernel/v4.x/$(linux_tar)
@ -10,28 +20,17 @@ linux-4.9.80_hash := 9e2e83ccc0afc3f23340ed5e58a35d8c6300a7c58aa98ca913848de4122
linux_hash := $(linux-$(linux_version)_hash) linux_hash := $(linux-$(linux_version)_hash)
# input file in the heads config/ dir
# Allow board config to specialize Linux configuration if necessary
linux_kconfig := $(or $(CONFIG_LINUX_CONFIG),config/linux.config)
# Output directory for the Linux kernel build is based on the
# configuration file name, not the board name
linux_board_dir := $(build)/$(linux_dir)/$(notdir $(basename $(linux_kconfig)))
# temp file in the build dir to show that we have run make oldconfig # temp file in the build dir to show that we have run make oldconfig
linux_config_file := $(notdir $(basename $(linux_kconfig))/.config-$(BOARD)) linux_config_file := $(notdir $(basename $(linux_kconfig))/.config-$(BOARD))
linux_configure := \ linux_configure := \
$(MAKE) \ $(MAKE) -C .. \
CROSS_COMPILE="$(CROSS)" \ CROSS_COMPILE="$(CROSS)" \
O="$(linux_board_dir)" \ O="$(build)/$(linux_dir)" \
KCONFIG_CONFIG="$(pwd)/$(linux_kconfig)" \ KCONFIG_CONFIG="$(pwd)/$(linux_kconfig)" \
oldconfig \ oldconfig \
linux_output += $(build)/$(BOARD)/bzImage linux_output += arch/x86/boot/bzImage
# linux.intermediate: $(linux_output)
#linux_output += $(build)/$(BOARD)/modules.cpio
# qemu # qemu
@ -87,7 +86,7 @@ linux_modules-$(CONFIG_LINUX_MEI) += drivers/misc/mei/mei-me.ko
EXTRA_FLAGS := -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches EXTRA_FLAGS := -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches
linux_target := \ linux_target := \
O="$(linux_board_dir)" \ O="$(build)/$(linux_dir)" \
KCONFIG_CONFIG="$(pwd)/$(linux_kconfig)" \ KCONFIG_CONFIG="$(pwd)/$(linux_kconfig)" \
CROSS_COMPILE="$(CROSS)" \ CROSS_COMPILE="$(CROSS)" \
AFLAGS_KERNEL="$(EXTRA_FLAGS)" \ AFLAGS_KERNEL="$(EXTRA_FLAGS)" \
@ -115,13 +114,13 @@ FOO := $(shell mkdir -p "$(module_initrd_lib_dir)")
define linux_module = define linux_module =
# Each module depends on building the Linux kernel # Each module depends on building the Linux kernel
$(linux_board_dir)/$1: linux.intermediate # $(build)/$(BOARD)/bzImage $(build)/$(linux_dir)/$1: $(build)/$(BOARD)/bzImage
# The cpio file will depend on every module # The cpio file will depend on every module
$(build)/$(BOARD)/modules.cpio: $(module_initrd_lib_dir)/$(notdir $1) $(build)/$(BOARD)/modules.cpio: $(module_initrd_lib_dir)/$(notdir $1)
# Strip the modules when we install them so that they will be extra small # Strip the modules when we install them so that they will be extra small
$(module_initrd_lib_dir)/$(notdir $1): $(linux_board_dir)/$1 $(module_initrd_lib_dir)/$(notdir $1): $(build)/$(linux_dir)/$1
$(call do,INSTALL-MODULE,$1, \ $(call do,INSTALL-MODULE,$1, \
$(CROSS)strip \ $(CROSS)strip \
--preserve-dates \ --preserve-dates \
@ -134,7 +133,7 @@ endef
$(call map,linux_module,$(linux_modules-y)) $(call map,linux_module,$(linux_modules-y))
# We can't rebuild the module initrd until the kernel has been rebuilt # We can't rebuild the module initrd until the kernel has been rebuilt
$(build)/$(BOARD)/modules.cpio: linux.intermediate $(build)/$(BOARD)/modules.cpio: $(build)/$(linux_dir)/.build
$(call do-cpio,$@,$(module_initrd_dir)) $(call do-cpio,$@,$(module_initrd_dir))
@$(RM) -rf "$(module_initrd_dir)" @$(RM) -rf "$(module_initrd_dir)"
@ -142,15 +141,14 @@ $(build)/$(BOARD)/modules.cpio: linux.intermediate
# The output of the linux.intermediate is the bzImage in the # The output of the linux.intermediate is the bzImage in the
# linus build directory. We need to copy it into our board # linus build directory. We need to copy it into our board
# specific directory for ease of locating it later. # specific directory for ease of locating it later.
$(linux_board_dir)/arch/x86/boot/bzImage: linux.intermediate $(build)/$(BOARD)/bzImage: $(build)/$(linux_dir)/arch/x86/boot/bzImage
$(build)/$(BOARD)/bzImage: $(linux_board_dir)/arch/x86/boot/bzImage
$(call do-copy,$<,$@) $(call do-copy,$<,$@)
# menuconfig target allows us to easily reconfigure this Linux kernel # menuconfig target allows us to easily reconfigure this Linux kernel
linux.menuconfig: linux.menuconfig:
$(MAKE) \ $(MAKE) \
-C "$(build)/$(linux_dir)" \ -C "$(build)/$(linux_base_dir)" \
O="$(linux_board_dir)" \ O="$(build)/$(linux_dir)" \
KCONFIG_CONFIG="$(pwd)/$(linux_kconfig)" \ KCONFIG_CONFIG="$(pwd)/$(linux_kconfig)" \
menuconfig \ menuconfig \

View File

@ -45,33 +45,24 @@ ifneq "y" "$(shell [ -r '$(CONFIG_LINUXBOOT_ROM)' ] && echo y)"
$(error $(CONFIG_LINUXBOOT_ROM): you must provide a ROM file) $(error $(CONFIG_LINUXBOOT_ROM): you must provide a ROM file)
endif endif
# Force a rebuild of the LinuxBoot ROM if the vendor ROM changes
linuxboot.intermediate: $(CONFIG_LINUXBOOT_ROM)
endif endif
# The output file from the LinuxBoot build is a full ROM # The output file from the LinuxBoot build is a full ROM
# ready to flash onto the mainboard. There might be partial # ready to flash onto the mainboard. There might be partial
# firmware volumes as well, but that depends on the board # firmware volumes as well, but that depends on the board
# so this only retrieves the final one # so this only retrieves the final one
linuxboot_output := $(build)/$(linuxboot_dir)/build/$(linuxboot_board)/linuxboot.rom linuxboot_output := build/$(linuxboot_board)/linuxboot.rom
linuxboot_rom := $(build)/$(linuxboot_dir)/$(linuxboot_output)
$(linuxboot_output): linuxboot.intermediate $(build)/$(BOARD)/linuxboot.rom: $(linuxboot_rom)
$(build)/$(BOARD)/linuxboot.rom: $(linuxboot_output)
$(call do-copy,$<,$@) $(call do-copy,$<,$@)
# The Linux kernel and Heads initrd must be built before linuxboot # Also force a rebuild if any of the input files are updated
# unless the user has specified "FAST=1" on the make command line, $(build)/$(linuxboot_dir)/.build: \
# which will assume that the kernel and initrd are fresh $(CONFIG_LINUXBOOT_ROM) \
# $(build)/$(BOARD)/bzImage \
# There is not an explicit dependency of linuxboot on linux $(build)/$(BOARD)/initrd.cpio.xz \
# or initrd so that the configuration can pre-build all of edk2
# overlapping with the other builds.
ifneq "$(FAST)" "1"
linuxboot.intermediate: $(build)/$(BOARD)/bzImage
linuxboot.intermediate: $(build)/$(BOARD)/initrd.cpio.xz
endif
linuxboot.run: $(build)/$(BOARD)/linuxboot.rom linuxboot.run: $(build)/$(BOARD)/linuxboot.rom

View File

@ -38,8 +38,9 @@ musl_depends := musl-cross
# Fake a target so that musl will force a header install by the # Fake a target so that musl will force a header install by the
# Linux kernel sources. # Linux kernel sources.
musl.intermediate: $(INSTALL)/include/linux/limits.h $(build)/$(musl_dir)/.build: $(INSTALL)/include/linux/limits.h
$(INSTALL)/include/linux/limits.h: $(build)/$(linux_dir)/.canary
$(INSTALL)/include/linux/limits.h: $(build)/$(linux_base_dir)/.canary
$(MAKE) \ $(MAKE) \
-C "$(build)/$(linux_dir)" \ -C "$(build)/$(linux_dir)" \
INSTALL_HDR_PATH="$(INSTALL)" \ INSTALL_HDR_PATH="$(INSTALL)" \

View File

@ -17,7 +17,7 @@ endif
# The cross compiler has already been built, so the musl-cross target # The cross compiler has already been built, so the musl-cross target
# is a NOP. # is a NOP.
musl-cross.intermediate: #musl-cross.intermediate:
else else
@ -28,8 +28,9 @@ musl-cross_version := git
musl-cross_dir := musl-cross-$(musl-cross_version) musl-cross_dir := musl-cross-$(musl-cross_version)
musl-cross_repo := https://github.com/GregorR/musl-cross musl-cross_repo := https://github.com/GregorR/musl-cross
CROSS := $(build)/../crossgcc/x86_64-linux-musl/bin/x86_64-musl-linux- CROSS_TOP := crossgcc/x86_64-linux-musl/bin/x86_64-musl-linux-
musl-cross_output := $(CROSS)gcc CROSS := $(build)/../$(CROSS_TOP)
musl-cross_output := ../../$(CROSS_TOP)gcc
musl-cross_configure := \ musl-cross_configure := \
/bin/echo -e > Makefile \ /bin/echo -e > Makefile \

View File

@ -42,6 +42,6 @@ pciutils_output := \
lspci \ lspci \
pciutils_libraries := \ pciutils_libraries := \
../../install/lib/libpci.so.3 \ lib/libpci.so.3.5.4 \
pciutils_configure := pciutils_configure :=

View File

@ -47,7 +47,7 @@ CONFIG_HEADS=n
# Since we do not include u-root in modules-y, we have to define our # Since we do not include u-root in modules-y, we have to define our
# own intermediate and clean targets here # own intermediate and clean targets here
u-root.intermediate: $(u-root_output) $(build)/$(u-root_dir)/.build: $(u-root_output)
u-root.clean: u-root.clean:
$(RM) $(u-root_output) $(RM) $(u-root_output)
endif endif