mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-20 05:28:08 +00:00
major rearranging of Makefile, bin, library and busybox installation
This commit is contained in:
parent
8f63763e53
commit
4901ccd89c
128
Makefile
128
Makefile
@ -5,10 +5,14 @@ build := $(pwd)/build
|
|||||||
config := $(pwd)/build
|
config := $(pwd)/build
|
||||||
INSTALL := $(pwd)/install
|
INSTALL := $(pwd)/install
|
||||||
log_dir := $(build)/log
|
log_dir := $(build)/log
|
||||||
|
initrd_lib_dir := initrd/lib
|
||||||
|
initrd_bin_dir := initrd/bin
|
||||||
|
|
||||||
|
# Controls how many parallel jobs are invoked in subshells
|
||||||
MAKE_JOBS ?= -j8 --max-load 24
|
MAKE_JOBS ?= -j8 --max-load 24
|
||||||
|
|
||||||
# Create the log directory if it doesn't already exist
|
# Create the log directory if it doesn't already exist
|
||||||
BUILD_LOG := $(shell [ -d "$(log_dir)" ] || mkdir "$(log_dir)")
|
BUILD_LOG := $(shell [ -d "$(log_dir)" ] || mkdir -p "$(log_dir)")
|
||||||
|
|
||||||
# If V is set in the environment, do not redirect the tee
|
# If V is set in the environment, do not redirect the tee
|
||||||
# command to /dev/null.
|
# command to /dev/null.
|
||||||
@ -52,16 +56,24 @@ heads_cc := $(INSTALL)/bin/musl-gcc \
|
|||||||
|
|
||||||
CROSS := $(build)/../crossgcc/x86_64-linux-musl/bin/x86_64-musl-linux-
|
CROSS := $(build)/../crossgcc/x86_64-linux-musl/bin/x86_64-musl-linux-
|
||||||
|
|
||||||
#heads_cc := $(HOME)/install/x86_64-linux-musl/x86_64-linux-musl/bin/gcc
|
|
||||||
|
|
||||||
all: $(BOARD).rom
|
all: $(BOARD).rom
|
||||||
|
|
||||||
# Disable all built in rules
|
# Disable all built in rules
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
FORCE:
|
||||||
|
|
||||||
# Timestamps should be in ISO format
|
# Timestamps should be in ISO format
|
||||||
DATE=`date --rfc-3339=seconds`
|
DATE=`date --rfc-3339=seconds`
|
||||||
|
|
||||||
|
# Make helpers to operate on lists of things
|
||||||
|
define prefix =
|
||||||
|
$(foreach _, $2, $1$_)
|
||||||
|
endef
|
||||||
|
define map =
|
||||||
|
$(foreach _,$2,$(eval $(call $1,$_)))
|
||||||
|
endef
|
||||||
|
|
||||||
# Bring in all of the module definitions;
|
# Bring in all of the module definitions;
|
||||||
# these are the external pieces that will be downloaded and built
|
# these are the external pieces that will be downloaded and built
|
||||||
# as part of creating the Heads firmware image.
|
# as part of creating the Heads firmware image.
|
||||||
@ -71,10 +83,6 @@ include modules/*
|
|||||||
# This increases the build time, so it is commented out for now
|
# This increases the build time, so it is commented out for now
|
||||||
#all: $(foreach m,$(modules),$m.intermediate)
|
#all: $(foreach m,$(modules),$m.intermediate)
|
||||||
|
|
||||||
define prefix =
|
|
||||||
$(foreach _, $2, $1$_)
|
|
||||||
endef
|
|
||||||
|
|
||||||
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
|
||||||
@ -106,14 +114,14 @@ define define_module =
|
|||||||
( cd $(build)/$($1_dir) ; patch -p1 ) \
|
( cd $(build)/$($1_dir) ; patch -p1 ) \
|
||||||
< patches/$1.patch; \
|
< patches/$1.patch; \
|
||||||
fi
|
fi
|
||||||
touch "$$@"
|
@touch "$$@"
|
||||||
else
|
else
|
||||||
# Fetch and verify the source tar file
|
# Fetch and verify the source tar file
|
||||||
$(packages)/$($1_tar):
|
$(packages)/$($1_tar):
|
||||||
wget -O "$$@" $($1_url)
|
wget -O "$$@" $($1_url)
|
||||||
$(packages)/.$1_verify: $(packages)/$($1_tar)
|
$(packages)/.$1_verify: $(packages)/$($1_tar)
|
||||||
echo "$($1_hash) $$^" | sha256sum --check -
|
echo "$($1_hash) $$^" | sha256sum --check -
|
||||||
touch "$$@"
|
@touch "$$@"
|
||||||
|
|
||||||
# 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
|
||||||
@ -123,24 +131,24 @@ define define_module =
|
|||||||
( cd $(build)/$($1_dir) ; patch -p1 ) \
|
( cd $(build)/$($1_dir) ; patch -p1 ) \
|
||||||
< patches/$1-$($1_version).patch; \
|
< patches/$1-$($1_version).patch; \
|
||||||
fi
|
fi
|
||||||
touch "$$@"
|
@touch "$$@"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq "$($1_config)" ""
|
ifeq "$($1_config)" ""
|
||||||
# There is no official .config file
|
# There is no official .config file
|
||||||
$(build)/$($1_dir)/.config: $(build)/$($1_dir)/.canary
|
$(build)/$($1_dir)/.config: $(build)/$($1_dir)/.canary
|
||||||
touch "$$@"
|
@touch "$$@"
|
||||||
else
|
else
|
||||||
# Copy the stored config file into the unpacked directory
|
# Copy the stored config file into the unpacked directory
|
||||||
$(build)/$($1_dir)/.config: config/$($1_config) $(build)/$($1_dir)/.canary
|
$(build)/$($1_dir)/.config: config/$($1_config) $(build)/$($1_dir)/.canary
|
||||||
cp -a "$$<" "$$@"
|
$(call do,COPY,"$$<",cp -a "$$<" "$$@")
|
||||||
endif
|
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: \
|
||||||
$(build)/$($1_dir)/.canary \
|
$(build)/$($1_dir)/.canary \
|
||||||
$(build)/$($1_dir)/.config
|
$(build)/$($1_dir)/.config
|
||||||
@echo "$(DATE) Configuring $1"
|
@echo "$(DATE) CONFIG $1"
|
||||||
@( \
|
@( \
|
||||||
cd "$(build)/$($1_dir)" ; \
|
cd "$(build)/$($1_dir)" ; \
|
||||||
echo "$($1_configure)"; \
|
echo "$($1_configure)"; \
|
||||||
@ -150,7 +158,7 @@ define define_module =
|
|||||||
2>&1 \
|
2>&1 \
|
||||||
| tee "$(log_dir)/$1.configure.log" \
|
| tee "$(log_dir)/$1.configure.log" \
|
||||||
$(VERBOSE_REDIRECT)
|
$(VERBOSE_REDIRECT)
|
||||||
touch "$$@"
|
@touch "$$@"
|
||||||
|
|
||||||
# All of the outputs should result from building the intermediate target
|
# All of the outputs should result from building the intermediate target
|
||||||
$(call outputs,$1): $1.intermediate
|
$(call outputs,$1): $1.intermediate
|
||||||
@ -190,16 +198,15 @@ define define_module =
|
|||||||
.INTERMEDIATE: $1.intermediate
|
.INTERMEDIATE: $1.intermediate
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach _, $(modules), $(eval $(call define_module,$_)))
|
$(call map, define_module, $(modules))
|
||||||
|
|
||||||
initrd_lib_dir := initrd/lib
|
|
||||||
initrd_bin_dir := initrd/bin
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Install a file into the initrd, if it changed from
|
# Install a file into the initrd, if it changed from
|
||||||
# the destination file.
|
# the destination file.
|
||||||
#
|
#
|
||||||
define install =
|
define install =
|
||||||
|
@-mkdir -p "$(dir $2)"
|
||||||
$(call do,INSTALL,$2,cp "$1" "$2")
|
$(call do,INSTALL,$2,cp "$1" "$2")
|
||||||
endef
|
endef
|
||||||
|
|
||||||
@ -209,18 +216,16 @@ endef
|
|||||||
#
|
#
|
||||||
define initrd_bin_add =
|
define initrd_bin_add =
|
||||||
$(initrd_bin_dir)/$(notdir $1): $1
|
$(initrd_bin_dir)/$(notdir $1): $1
|
||||||
@if [ ! -d "$(initrd_bin_dir)" ]; \
|
$(call do,INSTALL-BIN,$$<,cp -a "$$<" "$$@")
|
||||||
then mkdir -p "$(initrd_bin_dir)"; \
|
@$(CROSS)strip "$$@" 2>&-; true
|
||||||
fi
|
|
||||||
$(call install,$$<,$$@)
|
|
||||||
initrd_bins += $(initrd_bin_dir)/$(notdir $1)
|
initrd_bins += $(initrd_bin_dir)/$(notdir $1)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
define initrd_lib_add =
|
define initrd_lib_add =
|
||||||
$(initrd_lib_dir)/$(notdir $1): $1
|
$(initrd_lib_dir)/$(notdir $1): $1
|
||||||
@mkdir -p "$(initrd_lib_dir)"
|
@-mkdir -p "$(dir $$@)"
|
||||||
$(call do,INSTALL-STRIP,$1,$(CROSS)strip -o "$$@" "$$<")
|
$(call do,INSTALL-LIB,$$@,$(CROSS)strip -o "$$@" "$$<")
|
||||||
initrd_libs += $(initrd_lib_dir)/$(notdir $1)
|
initrd_libs += $(initrd_lib_dir)/$(notdir $1)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
@ -231,29 +236,30 @@ $(foreach _, $(call bins,gpg), $(eval $(call initrd_bin_add,$_)))
|
|||||||
$(foreach _, $(call bins,lvm2), $(eval $(call initrd_bin_add,$_)))
|
$(foreach _, $(call bins,lvm2), $(eval $(call initrd_bin_add,$_)))
|
||||||
|
|
||||||
# Install the libraries for every module that we have built
|
# Install the libraries for every module that we have built
|
||||||
$(foreach m, $(modules), \
|
$(foreach m, $(modules), $(call map,initrd_lib_add,$(call libs,$m)))
|
||||||
$(foreach _, $(call libs,$m), $(eval $(call initrd_lib_add,$_))) \
|
|
||||||
)
|
|
||||||
|
|
||||||
#$(foreach _, $(call outputs,xen), $(eval $(call initrd_bin,$_)))
|
#$(foreach _, $(call outputs,xen), $(eval $(call initrd_bin,$_)))
|
||||||
|
|
||||||
# hack to install busybox into the initrd
|
# hack to install busybox into the initrd
|
||||||
initrd_bins += initrd/bin/busybox
|
initrd.cpio: busybox.intermediate
|
||||||
|
initrd_bins += $(initrd_bin_dir)/busybox
|
||||||
|
|
||||||
initrd/bin/busybox: $(build)/$(busybox_dir)/busybox
|
$(initrd_bin_dir)/busybox: $(build)/$(busybox_dir)/busybox
|
||||||
cmp --quiet "$@" "$^" || \
|
$(do,SYMLINK,$@,$(MAKE) \
|
||||||
$(MAKE) \
|
|
||||||
-C $(build)/$(busybox_dir) \
|
-C $(build)/$(busybox_dir) \
|
||||||
CC="$(heads_cc)" \
|
CC="$(heads_cc)" \
|
||||||
CONFIG_PREFIX="$(pwd)/initrd" \
|
CONFIG_PREFIX="$(pwd)/initrd" \
|
||||||
$(MAKE_JOBS) \
|
install \
|
||||||
install
|
)
|
||||||
|
|
||||||
|
#
|
||||||
# hack to build cbmem from coreboot
|
# hack to build cbmem from coreboot
|
||||||
# this must be built *AFTER* musl
|
# this must be built *AFTER* musl, but since coreboot depends on other things
|
||||||
initrd_bins += initrd/bin/cbmem
|
# that depend on musl it should be ok.
|
||||||
initrd/bin/cbmem: $(build)/$(coreboot_dir)/util/cbmem/cbmem
|
#
|
||||||
cp "$^" "$@"
|
initrd_bins += $(initrd_bin_dir)/cbmem
|
||||||
|
$(initrd_bin_dir)/cbmem: $(build)/$(coreboot_dir)/util/cbmem/cbmem
|
||||||
|
$(call install,$<,$@)
|
||||||
$(build)/$(coreboot_dir)/util/cbmem/cbmem: \
|
$(build)/$(coreboot_dir)/util/cbmem/cbmem: \
|
||||||
$(build)/$(coreboot_dir)/.canary \
|
$(build)/$(coreboot_dir)/.canary \
|
||||||
musl.intermediate
|
musl.intermediate
|
||||||
@ -261,6 +267,22 @@ $(build)/$(coreboot_dir)/util/cbmem/cbmem: \
|
|||||||
$(MAKE) -C "$(dir $@)" CC="$(heads_cc)" \
|
$(MAKE) -C "$(dir $@)" CC="$(heads_cc)" \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Linux kernel module installation
|
||||||
|
#
|
||||||
|
# This is special cases since we have to do a special strip operation on
|
||||||
|
# the kernel modules to make them fit into the ROM image.
|
||||||
|
#
|
||||||
|
define linux_module =
|
||||||
|
$(build)/$(linux_dir)/$1: linux.intermediate
|
||||||
|
initrd.cpio: $(initrd_lib_dir)/modules/$(notdir $1)
|
||||||
|
$(initrd_lib_dir)/modules/$(notdir $1): $(build)/$(linux_dir)/$1
|
||||||
|
@-mkdir -p "$(initrd_lib_dir)/modules"
|
||||||
|
$(call do,INSTALL-MODULE,$$@,$(CROSS)strip --strip-debug -o "$$@" "$$<")
|
||||||
|
endef
|
||||||
|
$(call map,linux_module,$(linux_modules))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# initrd image creation
|
# initrd image creation
|
||||||
@ -276,7 +298,7 @@ $(build)/$(coreboot_dir)/util/cbmem/cbmem: \
|
|||||||
# unlikely that their device file has a different major/minor)
|
# unlikely that their device file has a different major/minor)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
initrd.cpio: $(initrd_bins) $(initrd_libs) linux_modules
|
initrd.cpio: $(initrd_bins) $(initrd_libs) dev.cpio FORCE
|
||||||
$(call do,CPIO,$@, \
|
$(call do,CPIO,$@, \
|
||||||
cd ./initrd ; \
|
cd ./initrd ; \
|
||||||
find . \
|
find . \
|
||||||
@ -287,24 +309,11 @@ initrd.cpio: $(initrd_bins) $(initrd_libs) linux_modules
|
|||||||
|
|
||||||
initrd.intermediate: initrd.cpio
|
initrd.intermediate: initrd.cpio
|
||||||
|
|
||||||
linux_modules: linux.intermediate
|
|
||||||
@-mkdir -p initrd/lib/modules
|
|
||||||
|
|
||||||
define linux_module =
|
#
|
||||||
$(build)/$(linux_dir)/$1: linux.intermediate
|
# Compress the initrd into a xz file that can be included by coreboot.
|
||||||
initrd.cpio: initrd/lib/modules/$(notdir $1)
|
# The extra options are necessary to let the Linux kernel decompress it.
|
||||||
initrd/lib/modules/$(notdir $1): $(build)/$(linux_dir)/$1
|
#
|
||||||
$(call do,INSTALL-STRIP,$$@,$(CROSS)strip --strip-debug -o "$$@" "$$<")
|
|
||||||
endef
|
|
||||||
define map =
|
|
||||||
$(foreach _,$2,$(eval $(call $1,$_)))
|
|
||||||
endef
|
|
||||||
$(call map,linux_module,$(linux_modules))
|
|
||||||
|
|
||||||
|
|
||||||
# populate the coreboot initrd image from the one we built.
|
|
||||||
# 4.4 doesn't allow this, but building from head does.
|
|
||||||
#$(call outputs,linux): initrd.cpio
|
|
||||||
coreboot.intermediate: $(build)/$(coreboot_dir)/initrd.cpio.xz
|
coreboot.intermediate: $(build)/$(coreboot_dir)/initrd.cpio.xz
|
||||||
$(build)/$(coreboot_dir)/initrd.cpio.xz: initrd.cpio
|
$(build)/$(coreboot_dir)/initrd.cpio.xz: initrd.cpio
|
||||||
$(call do,COMPRESS,$<,\
|
$(call do,COMPRESS,$<,\
|
||||||
@ -323,11 +332,8 @@ $(build)/$(coreboot_dir)/bzImage: $(build)/$(linux_dir)/arch/x86/boot/bzImage
|
|||||||
coreboot.intermediate: $(build)/$(coreboot_dir)/bzImage
|
coreboot.intermediate: $(build)/$(coreboot_dir)/bzImage
|
||||||
|
|
||||||
|
|
||||||
# The coreboot gcc won't work for us since it doesn't have libc
|
# Each board output has its own fixup required to turn the coreboot.rom
|
||||||
#XGCC := $(build)/$(coreboot_dir)/util/crossgcc/xgcc/
|
# into a flashable image.
|
||||||
#export CC := $(XGCC)/bin/x86_64-elf-gcc
|
|
||||||
#export LDFLAGS := -L/lib/x86_64-linux-gnu
|
|
||||||
|
|
||||||
x230.rom: $(build)/$(coreboot_dir)/x230/coreboot.rom
|
x230.rom: $(build)/$(coreboot_dir)/x230/coreboot.rom
|
||||||
"$(build)/$(coreboot_dir)/$(BOARD)/cbfstool" "$<" print
|
"$(build)/$(coreboot_dir)/$(BOARD)/cbfstool" "$<" print
|
||||||
$(call do,EXTRACT,$@,dd if="$<" of="$@" bs=1M skip=8)
|
$(call do,EXTRACT,$@,dd if="$<" of="$@" bs=1M skip=8)
|
||||||
@ -340,7 +346,7 @@ qemu.rom: $(build)/$(coreboot_dir)/qemu/coreboot.rom
|
|||||||
@sha256sum "$@"
|
@sha256sum "$@"
|
||||||
|
|
||||||
|
|
||||||
clean-modules:
|
modules.clean:
|
||||||
for dir in \
|
for dir in \
|
||||||
$(busybox_dir) \
|
$(busybox_dir) \
|
||||||
$(cryptsetup_dir) \
|
$(cryptsetup_dir) \
|
||||||
@ -371,14 +377,14 @@ all:
|
|||||||
|
|
||||||
# How to download and build the correct version of make
|
# How to download and build the correct version of make
|
||||||
$(HEADS_MAKE): $(build)/$(make_dir)/Makefile
|
$(HEADS_MAKE): $(build)/$(make_dir)/Makefile
|
||||||
make -C "`dirname $@`" $(MAKE_JOBS) \
|
make -C "$(dir $@)" $(MAKE_JOBS) \
|
||||||
2>&1 \
|
2>&1 \
|
||||||
| tee "$(log_dir)/make.log" \
|
| tee "$(log_dir)/make.log" \
|
||||||
$(VERBOSE_REDIRECT)
|
$(VERBOSE_REDIRECT)
|
||||||
|
|
||||||
$(build)/$(make_dir)/Makefile: $(packages)/$(make_tar)
|
$(build)/$(make_dir)/Makefile: $(packages)/$(make_tar)
|
||||||
tar xf "$<" -C build/
|
tar xf "$<" -C build/
|
||||||
cd "`dirname $@`" ; ./configure \
|
cd "$(dir $@)" ; ./configure \
|
||||||
2>&1 \
|
2>&1 \
|
||||||
| tee "$(log_dir)/make.configure.log" \
|
| tee "$(log_dir)/make.configure.log" \
|
||||||
$(VERBOSE_REDIRECT)
|
$(VERBOSE_REDIRECT)
|
||||||
|
Loading…
Reference in New Issue
Block a user