2020-10-21 15:04:27 +00:00
|
|
|
# Need to set CB_OUTPUT_FILE before board .config included so
|
|
|
|
# that target overrides in x230/x430-flash (eg) are properly handled
|
|
|
|
GIT_HASH := $(shell git rev-parse HEAD)
|
|
|
|
GIT_STATUS := $(shell \
|
|
|
|
if git diff --exit-code >/dev/null ; then \
|
|
|
|
echo clean ; \
|
|
|
|
else \
|
|
|
|
echo dirty ; \
|
|
|
|
fi)
|
2022-10-20 15:00:33 +00:00
|
|
|
HEADS_GIT_VERSION := $(shell git describe --abbrev=7 --tags --dirty)
|
2020-10-21 15:04:27 +00:00
|
|
|
|
2023-06-21 18:19:41 +00:00
|
|
|
# Override BRAND_NAME to set the name displayed in the UI, filenames, versions, etc.
|
|
|
|
BRAND_NAME ?= Heads
|
|
|
|
|
|
|
|
CB_OUTPUT_BASENAME := $(shell echo $(BRAND_NAME) | tr A-Z a-z)-$(BOARD)-$(HEADS_GIT_VERSION)
|
2022-07-07 19:11:47 +00:00
|
|
|
CB_OUTPUT_FILE := $(CB_OUTPUT_BASENAME).rom
|
|
|
|
CB_OUTPUT_FILE_GPG_INJ := $(CB_OUTPUT_BASENAME)-gpg-injected.rom
|
|
|
|
CB_BOOTBLOCK_FILE := $(CB_OUTPUT_BASENAME).bootblock
|
2021-07-20 20:48:08 +00:00
|
|
|
LB_OUTPUT_FILE := linuxboot-$(BOARD)-$(HEADS_GIT_VERSION).rom
|
2020-10-21 15:04:27 +00:00
|
|
|
|
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-02-05 16:27:45 +00:00
|
|
|
config := $(pwd)/config
|
2021-07-22 22:25:55 +00:00
|
|
|
# These are dynamic, must not expand right here
|
|
|
|
build = $(pwd)/build/$(CONFIG_TARGET_ARCH)
|
|
|
|
packages = $(pwd)/packages/$(CONFIG_TARGET_ARCH)
|
|
|
|
INSTALL = $(pwd)/install/$(CONFIG_TARGET_ARCH)
|
|
|
|
log_dir = $(build)/log
|
2021-07-22 22:24:55 +00:00
|
|
|
board_build = $(build)/$(BOARD)
|
2017-03-29 20:58:45 +00:00
|
|
|
|
2018-04-19 23:37:45 +00:00
|
|
|
# Controls how many parallel jobs are invoked in subshells
|
2020-09-25 19:52:31 +00:00
|
|
|
CPUS ?= $(shell nproc)
|
2021-12-01 17:37:27 +00:00
|
|
|
MAKE_JOBS ?= -j$(CPUS) --max-load 16
|
2018-04-19 23:37:45 +00:00
|
|
|
|
2018-09-18 10:33:15 +00:00
|
|
|
WGET ?= wget
|
|
|
|
|
2022-01-31 15:57:24 +00:00
|
|
|
# Timestamps should be in ISO format
|
|
|
|
DATE=`date --rfc-3339=seconds`
|
|
|
|
|
2023-06-23 18:00:02 +00:00
|
|
|
BOARD ?= qemu-coreboot-fbwhiptail-tpm1
|
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
|
|
|
|
|
2021-07-22 22:25:55 +00:00
|
|
|
# By default, we are building for x86, up to a board to change this variable
|
|
|
|
CONFIG_TARGET_ARCH := x86
|
|
|
|
|
2018-02-05 16:27:45 +00:00
|
|
|
include $(CONFIG)
|
|
|
|
|
2023-11-13 21:42:05 +00:00
|
|
|
# Default update package extension is 'zip' unless a brand wants a branded
|
|
|
|
# extension
|
|
|
|
CONFIG_BRAND_UPDATE_PKG_EXT ?= zip
|
|
|
|
CB_UPDATE_PKG_FILE := $(CB_OUTPUT_BASENAME).$(CONFIG_BRAND_UPDATE_PKG_EXT)
|
|
|
|
|
2018-02-13 22:46:48 +00:00
|
|
|
# Unless otherwise specified, we are building for heads
|
|
|
|
CONFIG_HEADS ?= y
|
|
|
|
|
2023-03-01 21:07:03 +00:00
|
|
|
# Unless otherwise specified, we are building bash to have non-interactive shell for scripts (arrays and bashisms)
|
|
|
|
CONFIG_BASH ?= y
|
|
|
|
|
2021-07-18 17:34:20 +00:00
|
|
|
# Determine arch part for a host triplet
|
|
|
|
ifeq "$(CONFIG_TARGET_ARCH)" "x86"
|
|
|
|
MUSL_ARCH := x86_64
|
|
|
|
else ifeq "$(CONFIG_TARGET_ARCH)" "ppc64"
|
|
|
|
MUSL_ARCH := powerpc64le
|
|
|
|
else
|
|
|
|
$(error "Unexpected value of $$(CONFIG_TARGET_ARCH): $(CONFIG_TARGET_ARCH)")
|
|
|
|
endif
|
|
|
|
|
2021-07-22 22:25:55 +00:00
|
|
|
# Create directories if they don't already exist
|
|
|
|
BUILD_LOG := $(shell mkdir -p "$(log_dir)")
|
|
|
|
PACKAGES := $(shell mkdir -p "$(packages)")
|
|
|
|
|
2018-09-18 16:08:16 +00:00
|
|
|
# record the build date / git hashes and other files here
|
2021-07-22 22:24:55 +00:00
|
|
|
HASHES := $(board_build)/hashes.txt
|
2023-06-27 14:01:01 +00:00
|
|
|
SIZES := $(board_build)/sizes.txt
|
2018-09-18 16:08:16 +00:00
|
|
|
|
|
|
|
# Create the board output directory if it doesn't already exist
|
|
|
|
BOARD_LOG := $(shell \
|
2021-07-22 22:24:55 +00:00
|
|
|
mkdir -p "$(board_build)" ; \
|
2018-09-18 16:08:16 +00:00
|
|
|
echo "$(DATE) $(GIT_HASH) $(GIT_STATUS)" > "$(HASHES)" ; \
|
2023-06-27 14:01:01 +00:00
|
|
|
echo "$(DATE) $(GIT_HASH) $(GIT_STATUS)" > "$(SIZES)" ; \
|
2018-09-18 16:08:16 +00:00
|
|
|
)
|
|
|
|
|
2021-07-18 17:35:59 +00:00
|
|
|
ifeq "y" "$(CONFIG_LINUX_BUNDLED)"
|
|
|
|
# Create empty initrd for initial kernel "without" initrd.
|
2021-07-22 22:24:55 +00:00
|
|
|
$(shell cpio -o < /dev/null > $(board_build)/initrd.cpio)
|
2021-07-18 17:35:59 +00:00
|
|
|
endif
|
2017-03-31 16:06:59 +00:00
|
|
|
|
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-03-31 15:18:46 +00:00
|
|
|
# Create a temporary directory for the initrd
|
2018-05-02 15:38:39 +00:00
|
|
|
initrd_dir := $(BOARD)
|
|
|
|
initrd_tmp_dir := $(shell mktemp -d)
|
|
|
|
initrd_lib_dir := $(initrd_tmp_dir)/lib
|
|
|
|
initrd_bin_dir := $(initrd_tmp_dir)/bin
|
|
|
|
modules-y += initrd
|
2017-03-31 15:18:46 +00:00
|
|
|
|
|
|
|
$(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
|
2022-12-28 14:58:57 +00:00
|
|
|
SHELL := /usr/bin/env bash
|
2017-03-20 18:47:47 +00:00
|
|
|
.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
|
|
|
|
|
2020-01-08 16:08:15 +00:00
|
|
|
musl_dep := musl-cross
|
2022-08-25 18:43:31 +00:00
|
|
|
target := $(shell echo $(CROSS) | grep -Eoe '([^/]*?)-linux-musl')
|
|
|
|
arch := $(subst -linux-musl, , $(target))
|
2020-01-08 16:08:15 +00:00
|
|
|
heads_cc := $(CROSS)gcc \
|
2017-01-28 18:14:56 +00:00
|
|
|
-fdebug-prefix-map=$(pwd)=heads \
|
|
|
|
-gno-record-gcc-switches \
|
2018-02-26 16:42:07 +00:00
|
|
|
-D__MUSL__ \
|
2020-10-21 14:04:00 +00:00
|
|
|
-isystem $(INSTALL)/include \
|
2020-01-08 16:08:15 +00:00
|
|
|
-L$(INSTALL)/lib \
|
2017-01-28 18:14:56 +00:00
|
|
|
|
2023-02-21 18:46:03 +00:00
|
|
|
# Cross-compiling with pkg-config requires clearing PKG_CONFIG_PATH and setting
|
|
|
|
# both PKG_CONFIG_LIBDIR and PKG_CONFIG_SYSROOT_DIR.
|
|
|
|
# https://autotools.info/pkgconfig/cross-compiling.html
|
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" \
|
2023-02-21 18:46:03 +00:00
|
|
|
PKG_CONFIG_PATH= \
|
|
|
|
PKG_CONFIG_LIBDIR="$(INSTALL)/lib/pkgconfig" \
|
2018-03-29 21:21:51 +00:00
|
|
|
PKG_CONFIG_SYSROOT_DIR="$(INSTALL)" \
|
2017-04-08 17:23:34 +00:00
|
|
|
|
|
|
|
CROSS_TOOLS := \
|
|
|
|
CC="$(heads_cc)" \
|
|
|
|
$(CROSS_TOOLS_NOCC) \
|
|
|
|
|
2022-08-25 18:43:31 +00:00
|
|
|
# Targets to build payload only
|
|
|
|
.PHONY: payload
|
|
|
|
payload: $(build)/$(BOARD)/bzImage $(build)/$(initrd_dir)/initrd.cpio.xz
|
2016-12-29 23:23:08 +00:00
|
|
|
|
2020-10-21 15:04:27 +00:00
|
|
|
ifeq ($(CONFIG_COREBOOT), y)
|
2021-07-20 20:48:08 +00:00
|
|
|
|
2023-11-13 21:42:05 +00:00
|
|
|
# Coreboot targets create an update package that can be applied with integrity
|
|
|
|
# verification before flashing (see flash-gui.sh). The ZIP package format
|
|
|
|
# allows other metadata that might be needed to added in the future without
|
|
|
|
# breaking backward compatibility.
|
|
|
|
$(board_build)/$(CB_UPDATE_PKG_FILE): $(board_build)/$(CB_OUTPUT_FILE)
|
|
|
|
rm -rf "$(board_build)/update_pkg"
|
|
|
|
mkdir -p "$(board_build)/update_pkg"
|
|
|
|
cp "$<" "$(board_build)/update_pkg/"
|
|
|
|
cd "$(board_build)/update_pkg" && sha256sum "$(CB_OUTPUT_FILE)" >sha256sum.txt
|
|
|
|
cd "$(board_build)/update_pkg" && zip -9 "$@" "$(CB_OUTPUT_FILE)" sha256sum.txt
|
|
|
|
|
|
|
|
all: $(board_build)/$(CB_OUTPUT_FILE) $(board_build)/$(CB_UPDATE_PKG_FILE)
|
2021-07-20 20:48:08 +00:00
|
|
|
ifneq ($(CONFIG_COREBOOT_BOOTBLOCK),)
|
2021-07-22 22:24:55 +00:00
|
|
|
all: $(board_build)/$(CB_BOOTBLOCK_FILE)
|
2021-07-20 20:48:08 +00:00
|
|
|
endif
|
|
|
|
|
2020-10-21 15:04:27 +00:00
|
|
|
else ifeq ($(CONFIG_LINUXBOOT), y)
|
2021-07-22 22:24:55 +00:00
|
|
|
all: $(board_build)/$(LB_OUTPUT_FILE)
|
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
|
|
|
|
2022-08-25 18:43:31 +00:00
|
|
|
all payload:
|
2018-09-18 17:07:40 +00:00
|
|
|
@sha256sum $< | tee -a "$(HASHES)"
|
2023-06-27 14:01:01 +00:00
|
|
|
@stat -c "%8s:%n" $< | tee -a "$(SIZES)"
|
2018-09-18 16:08:16 +00:00
|
|
|
|
2016-11-29 16:19:48 +00:00
|
|
|
# Disable all built in rules
|
2018-05-02 15:38:39 +00:00
|
|
|
.INTERMEDIATE:
|
2016-11-29 16:19:48 +00:00
|
|
|
.SUFFIXES:
|
2017-03-29 20:58:45 +00:00
|
|
|
FORCE:
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2022-08-16 16:39:33 +00:00
|
|
|
# Copies config while replacing predefined placeholders with actual values
|
|
|
|
define install_config =
|
2021-07-22 22:24:55 +00:00
|
|
|
sed -e 's!@BOARD_BUILD_DIR@!$(board_build)!g' \
|
2022-08-16 16:39:33 +00:00
|
|
|
-e 's!@BLOB_DIR@!$(pwd)/blobs!g' \
|
2023-09-14 00:16:52 +00:00
|
|
|
-e 's!@BRAND_DIR@!$(pwd)/branding/$(BRAND_NAME)!g' \
|
2023-06-21 18:19:41 +00:00
|
|
|
-e 's!@BRAND_NAME@!$(BRAND_NAME)!g' \
|
2022-08-16 16:39:33 +00:00
|
|
|
"$1" > "$2"
|
|
|
|
endef
|
|
|
|
|
2017-03-29 20:58:45 +00:00
|
|
|
# Make helpers to operate on lists of things
|
2020-01-08 16:08:15 +00:00
|
|
|
# Prefix is "smart" and doesn't add the prefix for absolute file paths
|
2017-03-29 20:58:45 +00:00
|
|
|
define prefix =
|
2020-01-08 16:08:15 +00:00
|
|
|
$(foreach _, $2, $(if $(patsubst /%,,$_),$1$_,$_))
|
2017-03-29 20:58:45 +00:00
|
|
|
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-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 =
|
2018-05-02 15:38:39 +00:00
|
|
|
$(call do,CPIO ,$1,\
|
2018-02-05 16:27:45 +00:00
|
|
|
( 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 \
|
2018-05-02 15:38:39 +00:00
|
|
|
echo "$(DATE) UNCHANGED $(1:$(pwd)/%=%)" ; \
|
2018-02-05 16:27:45 +00:00
|
|
|
rm "$1.tmp" ; \
|
|
|
|
fi
|
2018-09-18 17:07:40 +00:00
|
|
|
@sha256sum "$1" | tee -a "$(HASHES)"
|
2023-06-27 14:01:01 +00:00
|
|
|
@stat -c "%8s:%n" "$1" | tee -a "$(SIZES)"
|
2018-09-18 17:07:40 +00:00
|
|
|
$(call do,HASHES , $1,\
|
2018-09-18 16:08:16 +00:00
|
|
|
( cd "$2"; \
|
2018-09-18 17:07:40 +00:00
|
|
|
echo "-----" ; \
|
2018-09-18 16:08:16 +00:00
|
|
|
find . -type f -print0 \
|
2018-09-18 17:07:40 +00:00
|
|
|
| xargs -0 sha256sum ; \
|
|
|
|
echo "-----" ; \
|
2018-09-18 16:35:19 +00:00
|
|
|
) >> "$(HASHES)" \
|
2018-09-18 16:08:16 +00:00
|
|
|
)
|
2023-06-27 14:01:01 +00:00
|
|
|
$(call do,SIZES , $1,\
|
|
|
|
( cd "$2"; \
|
|
|
|
echo "-----" ; \
|
|
|
|
find . -type f -print0 \
|
|
|
|
| xargs -0 stat -c "%8s:%n" ; \
|
|
|
|
echo "-----" ; \
|
|
|
|
) >> "$(SIZES)" \
|
|
|
|
)
|
2018-02-05 16:27:45 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define do-copy =
|
2018-05-04 18:36:56 +00:00
|
|
|
$(call do,INSTALL ,$1 => $2,\
|
|
|
|
if cmp --quiet "$1" "$2" ; then \
|
2018-05-02 15:38:39 +00:00
|
|
|
echo "$(DATE) UNCHANGED $(1:$(pwd)/%=%)" ; \
|
2018-05-04 16:31:21 +00:00
|
|
|
fi ; \
|
2023-02-21 20:15:25 +00:00
|
|
|
cp -a --remove-destination "$1" "$2" ; \
|
2018-02-05 16:27:45 +00:00
|
|
|
)
|
2018-05-02 15:38:39 +00:00
|
|
|
@sha256sum "$(2:$(pwd)/%=%)"
|
2023-06-27 14:01:01 +00:00
|
|
|
@stat -c "%8s:%n" "$(2:$(pwd)/%=%)"
|
2018-02-05 16:27:45 +00:00
|
|
|
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 =
|
2018-05-02 15:38:39 +00:00
|
|
|
# if they have not defined a separate base dir, define it
|
|
|
|
# as the same as their build dir.
|
2018-05-02 18:30:58 +00:00
|
|
|
$(eval $1_base_dir = $(or $($1_base_dir),$($1_dir)))
|
2023-08-10 20:48:05 +00:00
|
|
|
# Dynamically defined modules must tell us what module file defined them
|
|
|
|
$(eval $1_module_file = $(or $($1_module_file),$1))
|
2018-05-02 15:38:39 +00:00
|
|
|
|
2016-08-19 15:31:07 +00:00
|
|
|
ifneq ("$($1_repo)","")
|
2021-06-30 21:13:27 +00:00
|
|
|
$(eval $1_patch_name = $1$(if $($1_patch_version),-$($1_patch_version),))
|
2023-06-01 21:36:16 +00:00
|
|
|
# First time:
|
|
|
|
# Checkout the tree instead and create the canary file with repo and
|
|
|
|
# revision so that we know that the files are all present and their
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# Other times:
|
|
|
|
# If .canary contains the same repo and revision combination, do nothing.
|
|
|
|
# Otherwise, pull a new revision and checkout with update of submodules
|
|
|
|
#
|
|
|
|
# No signature hashes are checked in this case, since we don't have a
|
|
|
|
# stable version to compare against.
|
|
|
|
#
|
|
|
|
# XXX: "git clean -dffx" is a hack for coreboot during commit switching, need
|
|
|
|
# module-specific cleanup action to get rid of it.
|
|
|
|
$(build)/$($1_base_dir)/.canary: FORCE
|
|
|
|
if [ ! -e "$$@" ]; then \
|
|
|
|
git clone $($1_repo) "$(build)/$($1_base_dir)"; \
|
|
|
|
git -C "$(build)/$($1_base_dir)" reset --hard $($1_commit_hash) && git submodule update --init --checkout; \
|
|
|
|
echo -n '$($1_repo)|$($1_commit_hash)' > "$$@"; \
|
|
|
|
elif [ "$$$$(cat "$$@")" != '$($1_repo)|$($1_commit_hash)' ]; then \
|
|
|
|
echo "Switching $1 to $($1_repo) at $($1_commit_hash)" && \
|
2023-08-18 15:39:48 +00:00
|
|
|
git -C "$(build)/$($1_base_dir)" reset --hard HEAD^ && \
|
|
|
|
echo "git fetch $($1_repo) $($1_commit_hash) --recurse-submodules=no" && \
|
|
|
|
git -C "$(build)/$($1_base_dir)" fetch $($1_repo) $($1_commit_hash) --recurse-submodules=no && \
|
|
|
|
echo "git reset --hard $($1_commit_hash)" && \
|
2023-06-01 21:36:16 +00:00
|
|
|
git -C "$(build)/$($1_base_dir)" reset --hard $($1_commit_hash) && \
|
2023-08-18 15:39:48 +00:00
|
|
|
echo "git clean" && \
|
2023-06-01 21:36:16 +00:00
|
|
|
git -C "$(build)/$($1_base_dir)" clean -df && \
|
|
|
|
git -C "$(build)/$($1_base_dir)" clean -dffx payloads util/cbmem && \
|
2023-08-18 15:39:48 +00:00
|
|
|
echo "git submodule sync" && \
|
2023-06-01 21:36:16 +00:00
|
|
|
git -C "$(build)/$($1_base_dir)" submodule sync && \
|
2023-08-18 15:39:48 +00:00
|
|
|
echo "git submodule update" && \
|
2023-06-01 21:36:16 +00:00
|
|
|
git -C "$(build)/$($1_base_dir)" submodule update --init --checkout && \
|
|
|
|
echo -n '$($1_repo)|$($1_commit_hash)' > "$$@"; \
|
2017-01-31 16:56:14 +00:00
|
|
|
fi
|
2023-06-01 21:36:16 +00:00
|
|
|
if [ ! -e "$(build)/$($1_base_dir)/.patched" ]; then \
|
|
|
|
if [ -r patches/$($1_patch_name).patch ]; then \
|
2022-08-30 21:53:57 +00:00
|
|
|
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) ) \
|
2023-06-01 21:36:16 +00:00
|
|
|
< patches/$($1_patch_name).patch \
|
2018-07-17 10:22:52 +00:00
|
|
|
|| exit 1 ; \
|
2023-06-01 21:36:16 +00:00
|
|
|
fi && \
|
|
|
|
if [ -d patches/$($1_patch_name) ] && \
|
|
|
|
[ -r patches/$($1_patch_name) ] ; then \
|
|
|
|
for patch in patches/$($1_patch_name)/*.patch ; do \
|
|
|
|
echo "Applying patch file : $$$$patch " ; \
|
|
|
|
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) ) \
|
|
|
|
< $$$$patch \
|
|
|
|
|| exit 1 ; \
|
|
|
|
done ; \
|
|
|
|
fi && \
|
|
|
|
touch "$(build)/$($1_base_dir)/.patched"; \
|
2018-03-08 20:37:17 +00:00
|
|
|
fi
|
2016-08-19 15:31:07 +00:00
|
|
|
else
|
2023-08-11 14:02:03 +00:00
|
|
|
# Versioned modules (each version a separate module) don't need to include
|
|
|
|
# the version a second time. (The '-' separator is also omitted then.)
|
|
|
|
# $1_patch_version can still be defined manually.
|
|
|
|
$(eval $1_patch_version ?= $(if $(filter %-$($1_version),$1),,$($1_version)))
|
|
|
|
$(eval $1_patch_name = $1$(if $($1_patch_version),-,)$($1_patch_version))
|
2016-08-19 15:31:07 +00:00
|
|
|
# Fetch and verify the source tar file
|
2018-05-29 21:09:26 +00:00
|
|
|
# wget creates it early, so we have to cleanup if it fails
|
2016-08-19 15:31:07 +00:00
|
|
|
$(packages)/$($1_tar):
|
2018-05-29 21:09:26 +00:00
|
|
|
$(call do,WGET,$($1_url),\
|
2018-09-18 10:33:15 +00:00
|
|
|
if ! $(WGET) -O "$$@.tmp" $($1_url) ; then \
|
2018-05-29 21:09:26 +00:00
|
|
|
exit 1 ; \
|
2018-09-18 10:33:15 +00:00
|
|
|
fi ; \
|
2018-09-18 11:14:02 +00:00
|
|
|
mv "$$@.tmp" "$$@" \
|
2018-05-29 21:09:26 +00:00
|
|
|
)
|
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
|
2018-05-02 15:38:39 +00:00
|
|
|
$(build)/$($1_base_dir)/.canary: $(packages)/.$1-$($1_version)_verify
|
2019-10-29 12:15:56 +00:00
|
|
|
mkdir -p "$$(dir $$@)"
|
2019-12-03 09:48:10 +00:00
|
|
|
tar -xf "$(packages)/$($1_tar)" $(or $($1_tar_opt),--strip 1) -C "$$(dir $$@)"
|
2021-06-30 21:13:27 +00:00
|
|
|
if [ -r patches/$($1_patch_name).patch ]; then \
|
2022-08-30 21:53:57 +00:00
|
|
|
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) ) \
|
2021-06-30 21:13:27 +00:00
|
|
|
< patches/$($1_patch_name).patch \
|
2018-07-17 10:22:52 +00:00
|
|
|
|| exit 1 ; \
|
2016-08-03 22:10:44 +00:00
|
|
|
fi
|
2021-06-30 21:13:27 +00:00
|
|
|
if [ -d patches/$($1_patch_name) ] && \
|
|
|
|
[ -r patches/$($1_patch_name) ] ; then \
|
|
|
|
for patch in patches/$($1_patch_name)/*.patch ; do \
|
2018-03-08 20:37:17 +00:00
|
|
|
echo "Applying patch file : $$$$patch " ; \
|
2022-08-30 21:53:57 +00:00
|
|
|
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) ) \
|
2018-07-17 10:22:52 +00:00
|
|
|
< $$$$patch \
|
|
|
|
|| exit 1 ; \
|
2018-03-08 20:37:17 +00:00
|
|
|
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-05-02 15:38:39 +00:00
|
|
|
$($1_config_file_path): $(build)/$($1_base_dir)/.canary
|
2018-02-05 20:28:33 +00:00
|
|
|
@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-05-02 15:38:39 +00:00
|
|
|
$($1_config_file_path): $($1_config) $(build)/$($1_base_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
|
|
|
|
2018-05-02 18:30:58 +00:00
|
|
|
# The first time we have to wait for all the dependencies to be built
|
|
|
|
# before we can configure the target. Once the dep has been built,
|
|
|
|
# we only depend on it for a rebuild.
|
|
|
|
$(eval $1_config_wait := $(foreach d,$($1_depends),\
|
|
|
|
$(shell [ -r $(build)/$($d_dir)/.build ] || echo $d)))
|
|
|
|
|
2016-08-02 23:25:47 +00:00
|
|
|
# Use the module's configure variable to build itself
|
2018-05-02 18:30:58 +00:00
|
|
|
# this has to wait for the dependencies to be built since
|
|
|
|
# cross compilers and libraries might be messed up
|
2018-02-05 22:27:12 +00:00
|
|
|
$(dir $($1_config_file_path)).configured: \
|
2018-05-02 15:38:39 +00:00
|
|
|
$(build)/$($1_base_dir)/.canary \
|
2018-05-02 18:30:58 +00:00
|
|
|
$(foreach d,$($1_config_wait),$(build)/$($d_dir)/.build) \
|
2018-02-05 20:28:33 +00:00
|
|
|
$($1_config_file_path) \
|
2023-08-10 20:48:05 +00:00
|
|
|
modules/$($1_module_file)
|
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
|
|
|
|
2018-05-02 15:38:39 +00:00
|
|
|
# Short hand for our module build target
|
|
|
|
$1: \
|
|
|
|
$(build)/$($1_dir)/.build \
|
|
|
|
$(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
|
2018-05-02 15:38:39 +00:00
|
|
|
# being built, as well as this module being configured
|
2018-05-04 16:31:21 +00:00
|
|
|
$(call outputs,$1): $(build)/$($1_dir)/.build
|
2018-05-02 15:38:39 +00:00
|
|
|
|
|
|
|
# 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) \
|
2018-02-05 22:27:12 +00:00
|
|
|
$(dir $($1_config_file_path)).configured \
|
2018-02-05 20:28:33 +00:00
|
|
|
|
2018-05-04 16:31:21 +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; \
|
|
|
|
)
|
2018-05-02 15:38:39 +00:00
|
|
|
$(call do,DONE,$1,\
|
|
|
|
touch $(build)/$($1_dir)/.build \
|
|
|
|
)
|
|
|
|
|
|
|
|
|
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
|
2018-05-02 18:30:58 +00:00
|
|
|
#$(build)/$(musl_dir)/.configured: $(build)/$(musl-cross_dir)/../../crossgcc/x86_64-linux-musl/bin/x86_64-musl-linux-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)"
|
2023-02-21 20:15:25 +00:00
|
|
|
$(call do,INSTALL,$2,cp -a --remove-destination "$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
|
2023-02-21 20:15:25 +00:00
|
|
|
$(call do,INSTALL-BIN,$$(<:$(pwd)/%=%),cp -a --remove-destination "$$<" "$$@")
|
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?
|
2020-01-08 16:08:15 +00:00
|
|
|
#bin_modules-$(CONFIG_MUSL) += musl-cross
|
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
|
2021-07-25 15:30:19 +00:00
|
|
|
bin_modules-$(CONFIG_CRYPTSETUP2) += cryptsetup2
|
2017-03-31 16:06:59 +00:00
|
|
|
bin_modules-$(CONFIG_GPG) += gpg
|
2018-09-18 09:12:47 +00:00
|
|
|
bin_modules-$(CONFIG_GPG2) += gpg2
|
2018-09-19 11:21:02 +00:00
|
|
|
bin_modules-$(CONFIG_PINENTRY) += pinentry
|
2017-03-31 16:06:59 +00:00
|
|
|
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
|
2020-06-11 13:54:10 +00:00
|
|
|
bin_modules-$(CONFIG_HOTPKEY) += hotp-verification
|
2019-07-30 13:36:57 +00:00
|
|
|
bin_modules-$(CONFIG_MSRTOOLS) += msrtools
|
2020-10-19 14:47:22 +00:00
|
|
|
bin_modules-$(CONFIG_NKSTORECLI) += nkstorecli
|
2023-03-24 20:41:39 +00:00
|
|
|
bin_modules-$(CONFIG_UTIL_LINUX) += util-linux
|
2022-08-25 18:43:31 +00:00
|
|
|
bin_modules-$(CONFIG_OPENSSL) += openssl
|
|
|
|
bin_modules-$(CONFIG_TPM2_TOOLS) += tpm2-tools
|
2023-03-07 16:02:45 +00:00
|
|
|
bin_modules-$(CONFIG_BASH) += bash
|
2023-06-05 21:53:18 +00:00
|
|
|
bin_modules-$(CONFIG_POWERPC_UTILS) += powerpc-utils
|
Introduce io386 to heads and use it to finalize chipset at runtime
On some newer platforms of intel (confirmed on nehalem, sandy/ivy
bridge), coreboot after commit [2ac149d294af795710eb4bb20f093e9920604abd](https://review.coreboot.org/cgit/coreboot.git/commit/?id=2ac149d294af795710eb4bb20f093e9920604abd)
registers an SMI to lockdown some registers on the chipset, as well
as access to the SPI flash, optionally. The SMI will always be triggered
by coreboot during S3 resume, but can be triggered by either coreboot
or the payload during normal boot path.
Enabling lockdown access to SPI flash will effectly write-protect it,
but there is no runtime option for coreboot to control it, so letting
coreboot to trigger such SMI will leave the owner of the machine lost
any possibility to program the SPI flash with its own OS, and becomes
a nightmare if the machine is uneasy to disassemble, so a scheme could
be implement, in which the SMI to lockdown chipset and SPI flash is left
for a payload to trigger, and temporarily disabling such triggering in
order to program the SPI flash needs authentication.
I have implemented a passcode-protected runtime-disableable lockdown
with grub, described [here](https://github.com/hardenedlinux/Debian-GNU-Linux-Profiles/blob/master/docs/hardened_boot/grub-for-coreboot.md#update-for-coreboot-after-commit-2ac149d294af795710eb4bb20f093e9920604abd). In order to implement a similar scheme for
Heads, I wrote [io386](https://github.com/hardenedlinux/io386).
With this commit, io386 will be called before entering boot routine
to trigger the SMI to finalize the chipset and write protect the SPI
flash at the same time. Entering recovery shell will leave the flash
writable.
(The authentication routine implemented in previous revisions has been
split as an independent commit.)
Originally proposed under PR#326
2018-01-17 08:16:18 +00:00
|
|
|
bin_modules-$(CONFIG_IO386) += io386
|
2022-11-28 20:06:16 +00:00
|
|
|
bin_modules-$(CONFIG_IOPORT) += ioport
|
2023-08-09 20:06:08 +00:00
|
|
|
bin_modules-$(CONFIG_KBD) += kbd
|
2023-06-20 19:29:10 +00:00
|
|
|
bin_modules-$(CONFIG_ZSTD) += zstd
|
2023-07-19 22:48:03 +00:00
|
|
|
bin_modules-$(CONFIG_E2FSPROGS) += e2fsprogs
|
|
|
|
bin_modules-$(CONFIG_EXFATPROGS) += exfatprogs
|
2023-04-19 08:24:54 +00:00
|
|
|
bin_modules-$(CONFIG_IOTOOLS) += iotools
|
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
|
|
|
|
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-05-02 15:38:39 +00:00
|
|
|
COREBOOT_UTIL_DIR=$(build)/$(coreboot_base_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 \
|
2021-11-25 15:38:15 +00:00
|
|
|
: $(build)/$(coreboot_base_dir)/.canary musl-cross
|
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
|
2018-05-02 15:38:39 +00:00
|
|
|
$(COREBOOT_UTIL_DIR)/superiotool/superiotool: \
|
|
|
|
$(build)/$(zlib_dir)/.build \
|
|
|
|
$(build)/$(pciutils_dir)/.build \
|
2018-03-02 14:37:31 +00:00
|
|
|
|
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
|
2018-05-02 15:38:39 +00:00
|
|
|
initrd-y += $(build)/$(initrd_dir)/modules.cpio
|
|
|
|
initrd-y += $(build)/$(initrd_dir)/tools.cpio
|
2022-11-28 20:15:38 +00:00
|
|
|
initrd-y += $(build)/$(initrd_dir)/board.cpio
|
2018-05-02 15:38:39 +00:00
|
|
|
initrd-$(CONFIG_HEADS) += $(build)/$(initrd_dir)/heads.cpio
|
2018-02-05 16:27:45 +00:00
|
|
|
|
2018-05-02 15:38:39 +00:00
|
|
|
#$(build)/$(initrd_dir)/.build: $(build)/$(initrd_dir)/initrd.cpio.xz
|
|
|
|
|
|
|
|
$(build)/$(initrd_dir)/initrd.cpio.xz: $(initrd-y)
|
|
|
|
$(call do,CPIO-XZ ,$@,\
|
2018-02-05 16:27:45 +00:00
|
|
|
$(pwd)/bin/cpio-clean \
|
|
|
|
$^ \
|
|
|
|
| xz \
|
|
|
|
--check=crc32 \
|
|
|
|
--lzma2=dict=1MiB \
|
|
|
|
-9 \
|
2018-05-02 15:38:39 +00:00
|
|
|
| dd bs=512 conv=sync status=none > "$@.tmp" \
|
2017-03-29 19:15:03 +00:00
|
|
|
)
|
2018-05-02 15:38:39 +00:00
|
|
|
@if ! cmp --quiet "$@.tmp" "$@" ; then \
|
|
|
|
mv "$@.tmp" "$@" ; \
|
|
|
|
else \
|
|
|
|
echo "$(DATE) UNCHANGED $(@:$(pwd)/%=%)" ; \
|
|
|
|
rm "$@.tmp" ; \
|
|
|
|
fi
|
2018-09-18 17:07:40 +00:00
|
|
|
@sha256sum "$(@:$(pwd)/%=%)" | tee -a "$(HASHES)"
|
2023-06-27 14:01:01 +00:00
|
|
|
@stat -c "%8s:%n" "$(@:$(pwd)/%=%)" | tee -a "$(SIZES)"
|
2016-11-29 16:19:48 +00:00
|
|
|
|
2021-07-18 17:35:59 +00:00
|
|
|
#
|
|
|
|
# At the moment PowerPC can only load initrd bundled with the kernel.
|
|
|
|
#
|
2021-07-22 22:24:55 +00:00
|
|
|
bundle-$(CONFIG_LINUX_BUNDLED) += $(board_build)/$(LINUX_IMAGE_FILE).bundled
|
2021-07-18 17:35:59 +00:00
|
|
|
all: $(bundle-y)
|
|
|
|
|
2022-11-28 20:15:38 +00:00
|
|
|
# The board.cpio is built from the board's initrd/ directory. It contains
|
|
|
|
# board-specific support scripts.
|
|
|
|
|
|
|
|
ifeq ($(wildcard $(pwd)/boards/$(BOARD)/initrd),)
|
|
|
|
$(build)/$(initrd_dir)/board.cpio:
|
|
|
|
cpio -H newc -o </dev/null >"$@"
|
|
|
|
else
|
|
|
|
$(build)/$(initrd_dir)/board.cpio: FORCE
|
|
|
|
$(call do-cpio,$@,$(pwd)/boards/$(BOARD)/initrd)
|
|
|
|
endif
|
|
|
|
|
2018-02-05 16:27:45 +00:00
|
|
|
#
|
|
|
|
# The heads.cpio is built from the initrd directory in the
|
|
|
|
# Heads tree.
|
|
|
|
#
|
2018-05-02 15:38:39 +00:00
|
|
|
$(build)/$(initrd_dir)/heads.cpio: FORCE
|
2018-02-05 16:27:45 +00:00
|
|
|
$(call do-cpio,$@,$(pwd)/initrd)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# The tools initrd is made from all of the things that we've
|
|
|
|
# created during the submodule build.
|
|
|
|
#
|
2018-05-02 15:38:39 +00:00
|
|
|
$(build)/$(initrd_dir)/tools.cpio: \
|
2018-02-05 16:27:45 +00:00
|
|
|
$(initrd_bins) \
|
|
|
|
$(initrd_libs) \
|
2018-05-04 18:36:56 +00:00
|
|
|
$(initrd_tmp_dir)/etc/config \
|
|
|
|
|
|
|
|
$(call do-cpio,$@,$(initrd_tmp_dir))
|
|
|
|
@$(RM) -rf "$(initrd_tmp_dir)"
|
2018-02-05 16:27:45 +00:00
|
|
|
|
2018-05-04 18:36:56 +00:00
|
|
|
$(initrd_tmp_dir)/etc/config: FORCE
|
|
|
|
@mkdir -p $(dir $@)
|
2018-02-05 16:27:45 +00:00
|
|
|
$(call do,INSTALL,$(CONFIG), \
|
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-05-04 18:36:56 +00:00
|
|
|
> $@ \
|
|
|
|
)
|
2018-05-11 21:08:31 +00:00
|
|
|
$(call do,HASH,$(GIT_HASH) $(GIT_STATUS) $(BOARD), \
|
2018-05-04 18:36:56 +00:00
|
|
|
echo export GIT_HASH=\'$(GIT_HASH)\' \
|
|
|
|
>> $@ ; \
|
|
|
|
echo export GIT_STATUS=$(GIT_STATUS) \
|
|
|
|
>> $@ ; \
|
2018-05-11 21:08:31 +00:00
|
|
|
echo export CONFIG_BOARD=$(BOARD) \
|
|
|
|
>> $@ ; \
|
2023-06-21 18:19:41 +00:00
|
|
|
echo export CONFIG_BRAND_NAME=$(BRAND_NAME) \
|
|
|
|
>> $@ ; \
|
2018-02-05 16:27:45 +00:00
|
|
|
)
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2018-05-02 15:38:39 +00:00
|
|
|
# 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)
|
2017-04-03 18:53:29 +00:00
|
|
|
|
2018-02-05 16:56:15 +00:00
|
|
|
|
2018-03-29 22:05:57 +00:00
|
|
|
# List of all modules, excluding the slow to-build modules
|
|
|
|
modules-slow := musl musl-cross kernel_headers
|
|
|
|
module_dirs := $(foreach m,$(filter-out $(modules-slow),$(modules-y)),$($m_dir))
|
2016-08-14 20:02:15 +00:00
|
|
|
|
2018-03-29 22:05:57 +00:00
|
|
|
echo_modules:
|
|
|
|
echo $(module_dirs)
|
2017-04-08 21:46:54 +00:00
|
|
|
|
|
|
|
modules.clean:
|
|
|
|
for dir in $(module_dirs) \
|
2017-02-28 23:02:10 +00:00
|
|
|
; do \
|
2023-05-09 11:52:51 +00:00
|
|
|
$(MAKE) -C "build/${CONFIG_TARGET_ARCH}/$$dir" clean ; \
|
|
|
|
rm -f "build/${CONFIG_TARGET_ARCH}/$$dir/.configured" ; \
|
2017-01-04 15:31:27 +00:00
|
|
|
done
|
2017-01-27 21:17:03 +00:00
|
|
|
|
2022-07-07 19:11:47 +00:00
|
|
|
# Inject a GPG key into the image - this is most useful when testing in qemu,
|
|
|
|
# since we can't reflash the firmware in qemu to update the keychain. Instead,
|
|
|
|
# inject the public key ahead of time. Specify the location of the key with
|
|
|
|
# PUBKEY_ASC.
|
2021-07-22 22:24:55 +00:00
|
|
|
inject_gpg: $(board_build)/$(CB_OUTPUT_FILE_GPG_INJ)
|
2022-07-07 19:11:47 +00:00
|
|
|
|
2021-07-22 22:24:55 +00:00
|
|
|
$(board_build)/$(CB_OUTPUT_BASENAME)-gpg-injected.rom: $(board_build)/$(CB_OUTPUT_FILE)
|
|
|
|
cp "$(board_build)/$(CB_OUTPUT_FILE)" \
|
|
|
|
"$(board_build)/$(CB_OUTPUT_FILE_GPG_INJ)"
|
2022-07-07 19:11:47 +00:00
|
|
|
./bin/inject_gpg_key.sh --cbfstool "$(build)/$(coreboot_dir)/cbfstool" \
|
2021-07-22 22:24:55 +00:00
|
|
|
"$(board_build)/$(CB_OUTPUT_FILE_GPG_INJ)" "$(PUBKEY_ASC)"
|
2022-07-07 19:11:47 +00:00
|
|
|
|
2017-04-08 21:46:54 +00:00
|
|
|
real.clean:
|
|
|
|
for dir in \
|
|
|
|
$(module_dirs) \
|
|
|
|
$(kernel_headers) \
|
|
|
|
; do \
|
|
|
|
if [ ! -z "$$dir" ]; then \
|
2023-05-09 11:52:51 +00:00
|
|
|
rm -rf "build/${CONFIG_TARGET_ARCH}/$$dir"; \
|
2017-04-08 21:46:54 +00:00
|
|
|
fi; \
|
|
|
|
done
|
2018-11-21 13:24:54 +00:00
|
|
|
cd install && rm -rf -- *
|