2018-02-08 00:03:40 +00:00
|
|
|
all:
|
2018-02-02 20:56:46 +00:00
|
|
|
-include .config
|
|
|
|
|
2017-03-31 15:18:46 +00:00
|
|
|
modules-y :=
|
2016-08-02 23:25:47 +00:00
|
|
|
pwd := $(shell pwd)
|
2018-03-08 06:16:28 +00:00
|
|
|
packages ?= $(pwd)/packages
|
2016-08-02 23:25:47 +00:00
|
|
|
build := $(pwd)/build
|
2018-02-05 16:27:45 +00:00
|
|
|
config := $(pwd)/config
|
2016-12-28 17:45:12 +00:00
|
|
|
INSTALL := $(pwd)/install
|
2017-02-28 23:02:10 +00:00
|
|
|
log_dir := $(build)/log
|
2017-03-29 20:58:45 +00:00
|
|
|
|
2018-02-08 00:03:40 +00:00
|
|
|
BOARD ?= qemu-coreboot
|
2018-03-12 09:26:23 +00:00
|
|
|
CONFIG := $(pwd)/boards/$(BOARD)/$(BOARD).config
|
2018-02-05 16:27:45 +00:00
|
|
|
|
|
|
|
ifneq "y" "$(shell [ -r '$(CONFIG)' ] && echo y)"
|
|
|
|
$(error $(CONFIG): board configuration does not exist)
|
|
|
|
endif
|
|
|
|
|
|
|
|
include $(CONFIG)
|
|
|
|
|
2018-02-13 22:46:48 +00:00
|
|
|
# Unless otherwise specified, we are building for heads
|
|
|
|
CONFIG_HEADS ?= y
|
|
|
|
|
2017-03-29 20:58:45 +00:00
|
|
|
# Controls how many parallel jobs are invoked in subshells
|
2017-04-06 14:50:43 +00:00
|
|
|
CPUS := $(shell nproc)
|
2018-03-15 22:10:15 +00:00
|
|
|
#MAKE_JOBS ?= -j$(CPUS) --max-load 16
|
2017-02-28 23:02:10 +00:00
|
|
|
|
|
|
|
# Create the log directory if it doesn't already exist
|
2018-02-05 16:27:45 +00:00
|
|
|
BUILD_LOG := $(shell mkdir -p "$(log_dir)" "$(build)/$(BOARD)" )
|
2017-02-28 23:02:10 +00:00
|
|
|
|
2018-02-02 20:56:46 +00:00
|
|
|
# Some things want usernames, we use the current checkout
|
|
|
|
# so that they are reproducible
|
|
|
|
GIT_HASH := $(shell git rev-parse HEAD)
|
|
|
|
|
2017-03-31 16:06:59 +00:00
|
|
|
# Timestamps should be in ISO format
|
|
|
|
DATE=`date --rfc-3339=seconds`
|
|
|
|
|
2017-02-28 23:02:10 +00:00
|
|
|
# If V is set in the environment, do not redirect the tee
|
|
|
|
# command to /dev/null.
|
|
|
|
ifeq "$V" ""
|
|
|
|
VERBOSE_REDIRECT := > /dev/null
|
2017-03-29 19:15:03 +00:00
|
|
|
# Not verbose, so we only show the header
|
|
|
|
define do =
|
2018-02-05 16:27:45 +00:00
|
|
|
@echo "$(DATE) $1 $(2:$(pwd)/%=%)"
|
2017-03-29 19:15:03 +00:00
|
|
|
@$3
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
# Verbose, so we display what we are doing
|
|
|
|
define do =
|
2018-02-05 16:27:45 +00:00
|
|
|
@echo "$(DATE) $1 $(2:$(pwd)/%=%)"
|
2017-03-29 19:15:03 +00:00
|
|
|
$3
|
|
|
|
endef
|
2017-02-28 23:02:10 +00:00
|
|
|
endif
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2017-03-29 19:15:03 +00:00
|
|
|
|
2017-01-27 21:17:03 +00:00
|
|
|
# Check that we have a correct version of make
|
|
|
|
LOCAL_MAKE_VERSION := $(shell $(MAKE) --version | head -1 | cut -d' ' -f3)
|
|
|
|
include modules/make
|
|
|
|
|
|
|
|
ifeq "$(LOCAL_MAKE_VERSION)" "$(make_version)"
|
2017-03-31 15:18:46 +00:00
|
|
|
|
|
|
|
# Create a temporary directory for the initrd
|
|
|
|
initrd_dir := $(shell mktemp -d)
|
|
|
|
initrd_lib_dir := $(initrd_dir)/lib
|
|
|
|
initrd_bin_dir := $(initrd_dir)/bin
|
|
|
|
|
|
|
|
$(shell mkdir -p "$(initrd_lib_dir)" "$(initrd_bin_dir)")
|
|
|
|
|
2017-01-27 21:17:03 +00:00
|
|
|
# We are running our own version of make,
|
|
|
|
# proceed with the build.
|
|
|
|
|
2017-03-20 18:47:47 +00:00
|
|
|
# Force pipelines to fail if any of the commands in the pipe fail
|
|
|
|
SHELL := /bin/bash
|
|
|
|
.SHELLFLAGS := -o pipefail -c
|
|
|
|
|
2018-03-16 16:59:24 +00:00
|
|
|
# Include the musl-cross module early so that $(CROSS) will
|
|
|
|
# be defined prior to any other module.
|
|
|
|
include modules/musl-cross
|
|
|
|
|
2016-12-29 23:23:08 +00:00
|
|
|
musl_dep := musl
|
2017-01-28 18:14:56 +00:00
|
|
|
heads_cc := $(INSTALL)/bin/musl-gcc \
|
|
|
|
-fdebug-prefix-map=$(pwd)=heads \
|
|
|
|
-gno-record-gcc-switches \
|
2018-02-26 16:42:07 +00:00
|
|
|
-D__MUSL__ \
|
2017-01-28 18:14:56 +00:00
|
|
|
|
2017-04-08 17:23:34 +00:00
|
|
|
CROSS_TOOLS_NOCC := \
|
|
|
|
AR="$(CROSS)ar" \
|
|
|
|
LD="$(CROSS)ld" \
|
|
|
|
STRIP="$(CROSS)strip" \
|
|
|
|
NM="$(CROSS)nm" \
|
|
|
|
OBJCOPY="$(CROSS)objcopy" \
|
|
|
|
OBJDUMP="$(CROSS)objdump" \
|
2018-03-29 21:21:51 +00:00
|
|
|
PKG_CONFIG_PATH="$(INSTALL)/lib/pkgconfig" \
|
|
|
|
PKG_CONFIG_SYSROOT_DIR="$(INSTALL)" \
|
2017-04-08 17:23:34 +00:00
|
|
|
|
|
|
|
CROSS_TOOLS := \
|
|
|
|
CC="$(heads_cc)" \
|
|
|
|
$(CROSS_TOOLS_NOCC) \
|
|
|
|
|
2017-01-31 19:57:41 +00:00
|
|
|
|
2016-12-29 23:23:08 +00:00
|
|
|
|
2017-11-20 22:28:35 +00:00
|
|
|
ifeq "$(CONFIG_COREBOOT)" "y"
|
2018-02-05 16:56:15 +00:00
|
|
|
all: $(build)/$(BOARD)/coreboot.rom
|
2018-02-05 16:27:45 +00:00
|
|
|
else ifeq "$(CONFIG_LINUXBOOT)" "y"
|
|
|
|
all: $(build)/$(BOARD)/linuxboot.rom
|
2017-11-20 22:28:35 +00:00
|
|
|
else
|
2018-02-05 16:27:45 +00:00
|
|
|
$(error "$(BOARD): neither CONFIG_COREBOOT nor CONFIG_LINUXBOOT is set?")
|
2017-11-20 22:28:35 +00:00
|
|
|
endif
|
2016-11-29 16:19:48 +00:00
|
|
|
|
2018-02-13 18:20:04 +00:00
|
|
|
# helpful targets for common uses
|
|
|
|
linux: $(build)/$(BOARD)/bzImage
|
2018-02-14 22:43:35 +00:00
|
|
|
cpio: $(build)/$(BOARD)/initrd.cpio.xz
|
2018-02-13 18:20:04 +00:00
|
|
|
|
2016-11-29 16:19:48 +00:00
|
|
|
# Disable all built in rules
|
|
|
|
.SUFFIXES:
|
2017-03-29 20:58:45 +00:00
|
|
|
FORCE:
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2017-03-29 20:58:45 +00:00
|
|
|
# Make helpers to operate on lists of things
|
|
|
|
define prefix =
|
|
|
|
$(foreach _, $2, $1$_)
|
|
|
|
endef
|
|
|
|
define map =
|
|
|
|
$(foreach _,$2,$(eval $(call $1,$_)))
|
|
|
|
endef
|
|
|
|
|
2016-11-23 17:11:08 +00:00
|
|
|
# Bring in all of the module definitions;
|
|
|
|
# these are the external pieces that will be downloaded and built
|
|
|
|
# as part of creating the Heads firmware image.
|
2016-08-03 12:40:51 +00:00
|
|
|
include modules/*
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2016-11-29 16:19:48 +00:00
|
|
|
# These will be built via their intermediate targets
|
|
|
|
# This increases the build time, so it is commented out for now
|
2017-03-31 15:18:46 +00:00
|
|
|
#all: $(foreach m,$(modules-y),$m.intermediate)
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2016-09-10 21:36:36 +00:00
|
|
|
define bins =
|
2016-08-03 12:40:51 +00:00
|
|
|
$(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_output)))
|
2016-08-02 23:25:47 +00:00
|
|
|
endef
|
2016-09-10 21:36:36 +00:00
|
|
|
define libs =
|
|
|
|
$(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_libraries)))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define outputs =
|
|
|
|
$(foreach m,$1,\
|
|
|
|
$(call bins,$m)\
|
|
|
|
$(call libs,$m)\
|
|
|
|
)
|
|
|
|
endef
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2018-02-05 16:27:45 +00:00
|
|
|
#
|
|
|
|
# Build a cpio from a directory
|
|
|
|
#
|
|
|
|
define do-cpio =
|
|
|
|
$(call do,CPIO,$1,\
|
|
|
|
( cd "$2"; \
|
|
|
|
find . \
|
|
|
|
| cpio \
|
|
|
|
--quiet \
|
|
|
|
-H newc \
|
|
|
|
-o \
|
2018-03-15 15:46:42 +00:00
|
|
|
) \
|
|
|
|
| ./bin/cpio-clean \
|
|
|
|
> "$1.tmp" \
|
2018-02-05 16:27:45 +00:00
|
|
|
)
|
|
|
|
@if ! cmp --quiet "$1.tmp" "$1" ; then \
|
|
|
|
mv "$1.tmp" "$1" ; \
|
|
|
|
else \
|
|
|
|
rm "$1.tmp" ; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
|
|
|
define do-copy =
|
2018-02-05 22:27:12 +00:00
|
|
|
$(call do,COPY,$1 => $2',\
|
2018-02-05 16:27:45 +00:00
|
|
|
sha256sum "$(1:$(pwd)/%=%)" ; \
|
|
|
|
if ! cmp --quiet "$1" "$2" ; then \
|
|
|
|
cp -a "$1" "$2"; \
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
2016-08-02 23:25:47 +00:00
|
|
|
#
|
|
|
|
# Generate the targets for a module.
|
|
|
|
#
|
|
|
|
# Special variables like $@ must be written as $$@ to avoid
|
|
|
|
# expansion during the first evaluation.
|
|
|
|
#
|
|
|
|
define define_module =
|
2016-08-19 15:31:07 +00:00
|
|
|
ifneq ("$($1_repo)","")
|
|
|
|
# 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
|
|
|
|
# this case, since we don't have a stable version to compare against.
|
|
|
|
$(build)/$($1_dir)/.canary:
|
2017-09-20 18:25:19 +00:00
|
|
|
git clone $($1_repo) "$(build)/$($1_dir)"
|
2017-01-31 16:56:14 +00:00
|
|
|
if [ -r patches/$1.patch ]; then \
|
|
|
|
( cd $(build)/$($1_dir) ; patch -p1 ) \
|
|
|
|
< patches/$1.patch; \
|
|
|
|
fi
|
2018-03-08 20:37:17 +00:00
|
|
|
if [ -d patches/$1 ] && \
|
|
|
|
[ -r patches/$1 ] ; then \
|
|
|
|
for patch in patches/$1/*.patch ; do \
|
|
|
|
echo "Applying patch file : $$$$patch " ; \
|
|
|
|
( cd $(build)/$($1_dir) ; patch -p1 ) \
|
|
|
|
< $$$$patch ; \
|
|
|
|
done ; \
|
|
|
|
fi
|
2017-03-29 20:58:45 +00:00
|
|
|
@touch "$$@"
|
2016-08-19 15:31:07 +00:00
|
|
|
else
|
|
|
|
# Fetch and verify the source tar file
|
|
|
|
$(packages)/$($1_tar):
|
2016-08-02 23:25:47 +00:00
|
|
|
wget -O "$$@" $($1_url)
|
2017-07-18 18:03:43 +00:00
|
|
|
$(packages)/.$1-$($1_version)_verify: $(packages)/$($1_tar)
|
2017-01-27 20:47:08 +00:00
|
|
|
echo "$($1_hash) $$^" | sha256sum --check -
|
2017-03-29 20:58:45 +00:00
|
|
|
@touch "$$@"
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2016-08-19 15:31:07 +00:00
|
|
|
# Unpack the tar file and touch the canary so that we know
|
|
|
|
# that the files are all present
|
2017-07-18 18:03:43 +00:00
|
|
|
$(build)/$($1_dir)/.canary: $(packages)/.$1-$($1_version)_verify
|
2016-08-03 12:52:23 +00:00
|
|
|
tar -xf "$(packages)/$($1_tar)" -C "$(build)"
|
2016-08-03 22:10:44 +00:00
|
|
|
if [ -r patches/$1-$($1_version).patch ]; then \
|
2016-12-29 23:23:08 +00:00
|
|
|
( cd $(build)/$($1_dir) ; patch -p1 ) \
|
|
|
|
< patches/$1-$($1_version).patch; \
|
2016-08-03 22:10:44 +00:00
|
|
|
fi
|
2018-03-08 20:37:17 +00:00
|
|
|
if [ -d patches/$1-$($1_version) ] && \
|
|
|
|
[ -r patches/$1-$($1_version) ] ; then \
|
|
|
|
for patch in patches/$1-$($1_version)/*.patch ; do \
|
|
|
|
echo "Applying patch file : $$$$patch " ; \
|
|
|
|
( cd $(build)/$($1_dir) ; patch -p1 ) \
|
|
|
|
< $$$$patch ; \
|
|
|
|
done ; \
|
|
|
|
fi
|
2017-03-29 20:58:45 +00:00
|
|
|
@touch "$$@"
|
2016-08-19 15:31:07 +00:00
|
|
|
endif
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2018-02-05 20:28:33 +00:00
|
|
|
# Allow the module to override the destination configuration file
|
|
|
|
# via a relative path. Linux uses this to have a per-board build.
|
|
|
|
$(eval $1_config_file_path := $(build)/$($1_dir)/$(or $($1_config_file),.config))
|
|
|
|
|
2016-12-01 19:03:55 +00:00
|
|
|
ifeq "$($1_config)" ""
|
|
|
|
# There is no official .config file
|
2018-02-05 20:28:33 +00:00
|
|
|
$($1_config_file_path): $(build)/$($1_dir)/.canary
|
|
|
|
@mkdir -p $$(dir $$@)
|
2017-03-29 20:58:45 +00:00
|
|
|
@touch "$$@"
|
2016-12-01 19:03:55 +00:00
|
|
|
else
|
|
|
|
# Copy the stored config file into the unpacked directory
|
2018-02-05 20:59:26 +00:00
|
|
|
$($1_config_file_path): $($1_config) $(build)/$($1_dir)/.canary
|
2018-02-05 20:28:33 +00:00
|
|
|
@mkdir -p $$(dir $$@)
|
2018-02-05 21:27:48 +00:00
|
|
|
$(call do-copy,$($1_config),$$@)
|
2016-11-29 16:19:48 +00:00
|
|
|
endif
|
2016-12-13 18:10:21 +00:00
|
|
|
|
2016-08-02 23:25:47 +00:00
|
|
|
# Use the module's configure variable to build itself
|
2018-02-05 22:27:12 +00:00
|
|
|
$(dir $($1_config_file_path)).configured: \
|
2016-08-02 23:25:47 +00:00
|
|
|
$(build)/$($1_dir)/.canary \
|
2018-02-05 20:28:33 +00:00
|
|
|
$($1_config_file_path) \
|
2017-04-08 21:46:54 +00:00
|
|
|
$(foreach d,$($1_depends),$(call outputs,$d)) \
|
2017-04-07 14:34:57 +00:00
|
|
|
modules/$1
|
2017-03-29 20:58:45 +00:00
|
|
|
@echo "$(DATE) CONFIG $1"
|
2017-03-21 18:24:00 +00:00
|
|
|
@( \
|
|
|
|
cd "$(build)/$($1_dir)" ; \
|
|
|
|
echo "$($1_configure)"; \
|
|
|
|
$($1_configure) \
|
|
|
|
) \
|
2017-03-20 18:47:47 +00:00
|
|
|
< /dev/null \
|
2017-02-28 23:02:10 +00:00
|
|
|
2>&1 \
|
|
|
|
| tee "$(log_dir)/$1.configure.log" \
|
|
|
|
$(VERBOSE_REDIRECT)
|
2017-03-29 20:58:45 +00:00
|
|
|
@touch "$$@"
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2017-03-20 21:52:54 +00:00
|
|
|
# All of the outputs should result from building the intermediate target
|
2016-11-29 16:19:48 +00:00
|
|
|
$(call outputs,$1): $1.intermediate
|
2016-08-03 01:23:18 +00:00
|
|
|
|
|
|
|
# Short hand target for the module
|
2016-11-29 16:19:48 +00:00
|
|
|
#$1: $(call outputs,$1)
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2016-11-29 16:19:48 +00:00
|
|
|
# Target for all of the outputs, which depend on their dependent modules
|
2016-12-28 17:45:12 +00:00
|
|
|
$1.intermediate: \
|
2016-12-29 23:23:08 +00:00
|
|
|
$(foreach d,$($1_depends),$d.intermediate) \
|
2017-03-20 21:52:54 +00:00
|
|
|
$(foreach d,$($1_depends),$(call outputs,$d)) \
|
2018-02-05 22:27:12 +00:00
|
|
|
$(dir $($1_config_file_path)).configured \
|
2018-02-05 20:28:33 +00:00
|
|
|
|
2017-03-29 19:15:03 +00:00
|
|
|
@echo "$(DATE) MAKE $1"
|
2018-03-15 22:10:15 +00:00
|
|
|
+@( \
|
2017-03-21 18:24:00 +00:00
|
|
|
echo "$(MAKE) \
|
|
|
|
-C \"$(build)/$($1_dir)\" \
|
|
|
|
$($1_target)" ; \
|
|
|
|
$(MAKE) \
|
|
|
|
-C "$(build)/$($1_dir)" \
|
|
|
|
$($1_target) \
|
2017-02-28 23:02:10 +00:00
|
|
|
) \
|
2017-03-20 18:47:47 +00:00
|
|
|
< /dev/null \
|
2017-02-28 23:02:10 +00:00
|
|
|
2>&1 \
|
|
|
|
| tee "$(log_dir)/$1.log" \
|
2017-03-20 18:47:47 +00:00
|
|
|
$(VERBOSE_REDIRECT) \
|
|
|
|
|| ( \
|
|
|
|
echo "tail $(log_dir)/$1.log"; \
|
|
|
|
echo "-----"; \
|
|
|
|
tail -20 "$(log_dir)/$1.log"; \
|
|
|
|
exit 1; \
|
|
|
|
)
|
2017-04-08 21:46:54 +00:00
|
|
|
@echo "$(DATE) DONE $1"
|
2016-11-29 16:19:48 +00:00
|
|
|
|
2017-01-31 16:56:14 +00:00
|
|
|
$1.clean:
|
2017-01-31 19:57:41 +00:00
|
|
|
-$(RM) "$(build)/$($1_dir)/.configured"
|
2017-01-31 16:56:14 +00:00
|
|
|
-$(MAKE) -C "$(build)/$($1_dir)" clean
|
|
|
|
|
2016-08-02 23:25:47 +00:00
|
|
|
endef
|
|
|
|
|
2017-03-31 15:18:46 +00:00
|
|
|
$(call map, define_module, $(modules-y))
|
2016-07-25 14:08:53 +00:00
|
|
|
|
2017-04-08 19:19:26 +00:00
|
|
|
# hack to force musl-cross to be built before musl
|
|
|
|
#$(build)/$(musl_dir)/.configured: $(build)/$(musl-cross_dir)/../../crossgcc/x86_64-linux-musl/bin/x86_64-linux-musl-gcc
|
2016-09-10 21:36:36 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install a file into the initrd, if it changed from
|
|
|
|
# the destination file.
|
|
|
|
#
|
|
|
|
define install =
|
2017-03-29 20:58:45 +00:00
|
|
|
@-mkdir -p "$(dir $2)"
|
2017-04-08 21:46:54 +00:00
|
|
|
$(call do,INSTALL,$2,cp -a "$1" "$2")
|
2016-09-10 21:36:36 +00:00
|
|
|
endef
|
2016-08-03 01:23:18 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Files that should be copied into the initrd
|
|
|
|
# THis should probably be done in a more scalable manner
|
|
|
|
#
|
2016-09-10 21:36:36 +00:00
|
|
|
define initrd_bin_add =
|
|
|
|
$(initrd_bin_dir)/$(notdir $1): $1
|
2018-02-05 16:27:45 +00:00
|
|
|
$(call do,INSTALL-BIN,$$(<:$(pwd)/%=%),cp -a "$$<" "$$@")
|
2017-04-08 21:46:54 +00:00
|
|
|
@$(CROSS)strip --preserve-dates "$$@" 2>&-; true
|
2016-09-10 21:36:36 +00:00
|
|
|
initrd_bins += $(initrd_bin_dir)/$(notdir $1)
|
2016-08-03 01:23:18 +00:00
|
|
|
endef
|
|
|
|
|
2016-09-10 21:36:36 +00:00
|
|
|
|
|
|
|
define initrd_lib_add =
|
|
|
|
$(initrd_lib_dir)/$(notdir $1): $1
|
2018-02-05 16:27:45 +00:00
|
|
|
$(call do,INSTALL-LIB,$(1:$(pwd)/%=%),\
|
|
|
|
$(CROSS)strip --preserve-dates -o "$$@" "$$<")
|
2016-09-10 21:36:36 +00:00
|
|
|
initrd_libs += $(initrd_lib_dir)/$(notdir $1)
|
|
|
|
endef
|
|
|
|
|
2017-03-30 22:39:18 +00:00
|
|
|
# Only some modules have binaries that we install
|
2018-02-05 16:27:45 +00:00
|
|
|
# Shouldn't this be specified in the module file?
|
2017-03-31 16:06:59 +00:00
|
|
|
bin_modules-$(CONFIG_KEXEC) += kexec
|
|
|
|
bin_modules-$(CONFIG_TPMTOTP) += tpmtotp
|
|
|
|
bin_modules-$(CONFIG_PCIUTILS) += pciutils
|
|
|
|
bin_modules-$(CONFIG_FLASHROM) += flashrom
|
|
|
|
bin_modules-$(CONFIG_CRYPTSETUP) += cryptsetup
|
|
|
|
bin_modules-$(CONFIG_GPG) += gpg
|
|
|
|
bin_modules-$(CONFIG_LVM2) += lvm2
|
2017-04-07 13:53:02 +00:00
|
|
|
bin_modules-$(CONFIG_DROPBEAR) += dropbear
|
2018-02-26 16:42:07 +00:00
|
|
|
bin_modules-$(CONFIG_FLASHTOOLS) += flashtools
|
2018-02-20 00:39:42 +00:00
|
|
|
bin_modules-$(CONFIG_NEWT) += newt
|
2018-03-06 19:57:00 +00:00
|
|
|
bin_modules-$(CONFIG_CAIRO) += cairo
|
|
|
|
bin_modules-$(CONFIG_FBWHIPTAIL) += fbwhiptail
|
2017-03-31 16:06:59 +00:00
|
|
|
|
|
|
|
$(foreach m, $(bin_modules-y), \
|
2017-03-30 22:39:18 +00:00
|
|
|
$(call map,initrd_bin_add,$(call bins,$m)) \
|
|
|
|
)
|
2016-09-10 21:36:36 +00:00
|
|
|
|
2017-03-29 19:15:03 +00:00
|
|
|
# Install the libraries for every module that we have built
|
2017-03-31 15:18:46 +00:00
|
|
|
$(foreach m, $(modules-y), \
|
2017-03-30 22:39:18 +00:00
|
|
|
$(call map,initrd_lib_add,$(call libs,$m)) \
|
|
|
|
)
|
2016-09-10 21:36:36 +00:00
|
|
|
|
2018-03-08 16:41:28 +00:00
|
|
|
# hack to install busybox into the initrd if busybox is configured
|
|
|
|
ifeq "$(CONFIG_BUSYBOX)" "y"
|
2018-02-05 16:27:45 +00:00
|
|
|
$(build)/$(BOARD)/heads.cpio: busybox.intermediate
|
2017-03-29 20:58:45 +00:00
|
|
|
initrd_bins += $(initrd_bin_dir)/busybox
|
2018-03-08 16:41:28 +00:00
|
|
|
endif
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2017-03-29 20:58:45 +00:00
|
|
|
$(initrd_bin_dir)/busybox: $(build)/$(busybox_dir)/busybox
|
|
|
|
$(do,SYMLINK,$@,$(MAKE) \
|
2016-08-03 01:23:18 +00:00
|
|
|
-C $(build)/$(busybox_dir) \
|
2016-12-29 23:23:08 +00:00
|
|
|
CC="$(heads_cc)" \
|
2016-08-03 01:23:18 +00:00
|
|
|
CONFIG_PREFIX="$(pwd)/initrd" \
|
2017-03-21 18:29:07 +00:00
|
|
|
$(MAKE_JOBS) \
|
2017-03-29 20:58:45 +00:00
|
|
|
install \
|
|
|
|
)
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2017-03-29 20:58:45 +00:00
|
|
|
#
|
2016-08-04 21:38:00 +00:00
|
|
|
# hack to build cbmem from coreboot
|
2017-03-29 20:58:45 +00:00
|
|
|
# this must be built *AFTER* musl, but since coreboot depends on other things
|
|
|
|
# that depend on musl it should be ok.
|
|
|
|
#
|
2018-03-02 14:37:31 +00:00
|
|
|
COREBOOT_UTIL_DIR=$(build)/$(coreboot_dir)/util
|
2017-09-22 20:17:05 +00:00
|
|
|
ifeq ($(CONFIG_COREBOOT),y)
|
2018-03-02 14:37:31 +00:00
|
|
|
$(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/cbmem/cbmem))
|
2018-03-08 09:32:23 +00:00
|
|
|
#$(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/superiotool/superiotool))
|
2018-03-02 14:37:31 +00:00
|
|
|
#$(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/inteltool/inteltool))
|
2017-09-22 20:17:05 +00:00
|
|
|
endif
|
|
|
|
|
2018-03-02 14:37:31 +00:00
|
|
|
$(COREBOOT_UTIL_DIR)/cbmem/cbmem \
|
|
|
|
$(COREBOOT_UTIL_DIR)/superiotool/superiotool \
|
|
|
|
$(COREBOOT_UTIL_DIR)/inteltool/inteltool \
|
|
|
|
: $(build)/$(coreboot_dir)/.canary \
|
|
|
|
musl.intermediate
|
2018-03-15 22:10:15 +00:00
|
|
|
+$(call do,MAKE,$(notdir $@),\
|
2018-03-02 14:37:31 +00:00
|
|
|
$(MAKE) -C "$(dir $@)" $(CROSS_TOOLS) \
|
2018-02-26 16:42:07 +00:00
|
|
|
)
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2018-03-02 14:37:31 +00:00
|
|
|
# superio depends on zlib and pciutils
|
|
|
|
$(COREBOOT_UTIL_DIR)/superiotool/superiotool: zlib.intermediate pciutils.intermediate
|
|
|
|
|
2016-08-03 01:23:18 +00:00
|
|
|
#
|
|
|
|
# initrd image creation
|
|
|
|
#
|
|
|
|
# The initrd is constructed from various bits and pieces
|
2016-11-23 17:11:08 +00:00
|
|
|
# The cpio-clean program is used ensure that the files
|
|
|
|
# always have the same timestamp and appear in the same order.
|
2016-08-03 01:23:18 +00:00
|
|
|
#
|
2018-03-15 15:46:42 +00:00
|
|
|
# The blobs/dev.cpio is also included in the Linux kernel
|
|
|
|
# and has a reproducible version of /dev/console.
|
|
|
|
#
|
|
|
|
# The xz parameters are copied from the Linux kernel build scripts.
|
|
|
|
# Without them the kernel will not decompress the initrd.
|
|
|
|
#
|
|
|
|
# The padding is to ensure that if anyone wants to cat another
|
|
|
|
# file onto the initrd then the kernel will be able to find it.
|
2016-08-03 01:23:18 +00:00
|
|
|
#
|
2018-02-05 16:27:45 +00:00
|
|
|
|
|
|
|
initrd-y += $(pwd)/blobs/dev.cpio
|
|
|
|
initrd-y += $(build)/$(BOARD)/modules.cpio
|
|
|
|
initrd-y += $(build)/$(BOARD)/tools.cpio
|
2018-02-13 22:46:48 +00:00
|
|
|
initrd-$(CONFIG_HEADS) += $(build)/$(BOARD)/heads.cpio
|
2018-02-05 16:27:45 +00:00
|
|
|
|
|
|
|
initrd.intermediate: $(build)/$(BOARD)/initrd.cpio.xz
|
2018-02-13 22:46:48 +00:00
|
|
|
$(build)/$(BOARD)/initrd.cpio.xz: $(initrd-y)
|
2018-02-05 16:27:45 +00:00
|
|
|
$(call do,CPIO-CLEAN,$@,\
|
|
|
|
$(pwd)/bin/cpio-clean \
|
|
|
|
$^ \
|
|
|
|
| xz \
|
|
|
|
--check=crc32 \
|
|
|
|
--lzma2=dict=1MiB \
|
|
|
|
-9 \
|
|
|
|
| dd bs=512 conv=sync > "$@" \
|
2017-03-29 19:15:03 +00:00
|
|
|
)
|
2018-02-05 16:27:45 +00:00
|
|
|
@sha256sum "$(@:$(pwd)/%=%)"
|
2016-11-29 16:19:48 +00:00
|
|
|
|
2018-02-05 16:27:45 +00:00
|
|
|
#
|
|
|
|
# The heads.cpio is built from the initrd directory in the
|
|
|
|
# Heads tree.
|
|
|
|
#
|
|
|
|
$(build)/$(BOARD)/heads.cpio: FORCE
|
|
|
|
$(call do-cpio,$@,$(pwd)/initrd)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# The tools initrd is made from all of the things that we've
|
|
|
|
# created during the submodule build.
|
|
|
|
#
|
|
|
|
$(build)/$(BOARD)/tools.cpio: \
|
|
|
|
$(initrd_bins) \
|
|
|
|
$(initrd_libs) \
|
|
|
|
|
|
|
|
$(call do,INSTALL,$(CONFIG), \
|
|
|
|
mkdir -p "$(initrd_dir)/etc" ; \
|
2018-02-28 19:57:46 +00:00
|
|
|
export \
|
|
|
|
| grep ' CONFIG_' \
|
2018-03-01 07:13:01 +00:00
|
|
|
| sed -e 's/^declare -x /export /' \
|
|
|
|
-e 's/\\\"//g' \
|
2018-02-28 19:57:46 +00:00
|
|
|
> "$(initrd_dir)/etc/config" \
|
2018-02-05 16:27:45 +00:00
|
|
|
)
|
|
|
|
$(call do-cpio,$@,$(initrd_dir))
|
|
|
|
@$(RM) -rf "$(initrd_dir)"
|
2016-12-13 18:10:21 +00:00
|
|
|
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2017-04-03 18:53:29 +00:00
|
|
|
|
|
|
|
# This produces a ROM image that is written with the flashrom program
|
2018-02-05 16:56:15 +00:00
|
|
|
$(build)/$(BOARD)/coreboot.rom: $(build)/$(coreboot_dir)/$(BOARD)/coreboot.rom
|
2017-04-03 18:53:29 +00:00
|
|
|
"$(build)/$(coreboot_dir)/$(BOARD)/cbfstool" "$<" print
|
|
|
|
$(call do,EXTRACT,$@,mv "$<" "$@")
|
2018-02-05 16:56:15 +00:00
|
|
|
@sha256sum "$(@:$(pwd)/%=%)"
|
|
|
|
|
2016-08-14 20:02:15 +00:00
|
|
|
|
2017-04-08 21:46:54 +00:00
|
|
|
module_dirs := \
|
2017-02-28 23:02:10 +00:00
|
|
|
$(busybox_dir) \
|
|
|
|
$(cryptsetup_dir) \
|
2017-04-07 13:53:02 +00:00
|
|
|
$(dropbear_dir) \
|
|
|
|
$(flashrom_dir) \
|
2017-04-09 05:38:22 +00:00
|
|
|
$(gpg_dir) \
|
2017-02-28 23:02:10 +00:00
|
|
|
$(kexec_dir) \
|
2017-04-07 13:53:02 +00:00
|
|
|
$(libusb_dir) \
|
|
|
|
$(libusb-compat_dir) \
|
2017-02-28 23:02:10 +00:00
|
|
|
$(lvm2_dir) \
|
|
|
|
$(mbedtls_dir) \
|
2017-04-07 13:53:02 +00:00
|
|
|
$(pciutils_dir) \
|
2017-02-28 23:02:10 +00:00
|
|
|
$(popt_dir) \
|
|
|
|
$(qrencode_dir) \
|
|
|
|
$(tpmtotp_dir) \
|
2017-04-07 13:53:02 +00:00
|
|
|
$(util-linux_dir) \
|
|
|
|
$(zlib_dir) \
|
2017-04-08 21:46:54 +00:00
|
|
|
$(kernel-headers_dir) \
|
2018-02-20 00:39:42 +00:00
|
|
|
$(slang_dir) \
|
|
|
|
$(newt_dir) \
|
2018-03-06 19:57:00 +00:00
|
|
|
$(libpng_dir) \
|
|
|
|
$(pixman_dir) \
|
|
|
|
$(cairo_dir) \
|
|
|
|
$(fbwhiptail_dir)
|
2017-04-08 21:46:54 +00:00
|
|
|
|
|
|
|
modules.clean:
|
|
|
|
for dir in $(module_dirs) \
|
2017-02-28 23:02:10 +00:00
|
|
|
; do \
|
|
|
|
$(MAKE) -C "build/$$dir" clean ; \
|
|
|
|
rm "build/$$dir/.configured" ; \
|
2017-01-04 15:31:27 +00:00
|
|
|
done
|
2017-01-27 21:17:03 +00:00
|
|
|
|
2017-04-08 21:46:54 +00:00
|
|
|
real.clean:
|
|
|
|
for dir in \
|
|
|
|
$(module_dirs) \
|
|
|
|
$(musl_dir) \
|
|
|
|
$(kernel_headers) \
|
|
|
|
; do \
|
|
|
|
if [ ! -z "$$dir" ]; then \
|
|
|
|
rm -rf "build/$$dir"; \
|
|
|
|
fi; \
|
|
|
|
done
|
2017-04-09 05:38:22 +00:00
|
|
|
rm -rf ./install
|
2017-04-08 21:46:54 +00:00
|
|
|
|
2017-04-08 19:19:26 +00:00
|
|
|
bootstrap:
|
2018-03-15 22:10:15 +00:00
|
|
|
+$(MAKE) \
|
2017-04-08 19:19:26 +00:00
|
|
|
musl-cross.intermediate \
|
|
|
|
$(build)/$(coreboot_dir)/util/crossgcc/xgcc/bin/i386-elf-gcc \
|
|
|
|
|
2017-01-27 21:17:03 +00:00
|
|
|
else
|
|
|
|
# Wrong make version detected -- build our local version
|
|
|
|
# and re-invoke the Makefile with it instead.
|
2017-03-31 17:28:20 +00:00
|
|
|
$(eval $(shell echo >&2 "$(DATE) Wrong make detected: $(LOCAL_MAKE_VERSION)"))
|
2017-01-27 21:17:03 +00:00
|
|
|
HEADS_MAKE := $(build)/$(make_dir)/make
|
|
|
|
|
|
|
|
# Once we have a proper Make, we can just pass arguments into it
|
2018-02-13 18:20:04 +00:00
|
|
|
all bootstrap linux cpio: $(HEADS_MAKE)
|
2017-03-31 17:28:20 +00:00
|
|
|
LANG=C MAKE=$(HEADS_MAKE) $(HEADS_MAKE) $@
|
2017-12-04 20:29:00 +00:00
|
|
|
%.clean %.intermediate %.vol: $(HEADS_MAKE)
|
2017-01-27 21:17:03 +00:00
|
|
|
LANG=C MAKE=$(HEADS_MAKE) $(HEADS_MAKE) $@
|
|
|
|
|
|
|
|
# How to download and build the correct version of make
|
|
|
|
$(HEADS_MAKE): $(build)/$(make_dir)/Makefile
|
2017-03-29 20:58:45 +00:00
|
|
|
make -C "$(dir $@)" $(MAKE_JOBS) \
|
2017-02-28 23:02:10 +00:00
|
|
|
2>&1 \
|
|
|
|
| tee "$(log_dir)/make.log" \
|
|
|
|
$(VERBOSE_REDIRECT)
|
|
|
|
|
2017-01-27 21:17:03 +00:00
|
|
|
$(build)/$(make_dir)/Makefile: $(packages)/$(make_tar)
|
|
|
|
tar xf "$<" -C build/
|
2017-03-29 20:58:45 +00:00
|
|
|
cd "$(dir $@)" ; ./configure \
|
2017-02-28 23:02:10 +00:00
|
|
|
2>&1 \
|
|
|
|
| tee "$(log_dir)/make.configure.log" \
|
|
|
|
$(VERBOSE_REDIRECT)
|
|
|
|
|
2017-01-27 21:17:03 +00:00
|
|
|
$(packages)/$(make_tar):
|
|
|
|
wget -O "$@" "$(make_url)"
|
|
|
|
if ! echo "$(make_hash) $@" | sha256sum --check -; then \
|
|
|
|
$(MV) "$@" "$@.failed"; \
|
|
|
|
false; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
endif
|