mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-18 20:47:55 +00:00
build the linux kernel after building the initrd
This commit is contained in:
parent
f7067d876c
commit
426cd8f94f
86
Makefile
86
Makefile
@ -11,6 +11,7 @@ include modules/kexec
|
||||
include modules/tpmtotp
|
||||
include modules/mbedtls
|
||||
include modules/busybox
|
||||
include modules/linux
|
||||
|
||||
all: $(modules)
|
||||
|
||||
@ -53,13 +54,92 @@ define define_module =
|
||||
cd "$(build)/$($1_dir)" ; $($1_configure)
|
||||
touch "$$@"
|
||||
|
||||
# Actually build the target
|
||||
$(call outputs,$1): $(build)/$($1_dir)/.configured $(call outputs,$($1_depends))
|
||||
# Build the target after any dependencies
|
||||
$(call outputs,$1): \
|
||||
$(build)/$($1_dir)/.configured \
|
||||
$(call outputs,$($1_depends))
|
||||
make -C "$(build)/$($1_dir)" $($1_target)
|
||||
|
||||
# Short hand target for the module
|
||||
$1: $(call outputs,$1)
|
||||
|
||||
# Update any dependencies
|
||||
endef
|
||||
|
||||
$(foreach _, $(modules), $(eval $(call define_module,$_)))
|
||||
|
||||
|
||||
#
|
||||
# Files that should be copied into the initrd
|
||||
# THis should probably be done in a more scalable manner
|
||||
#
|
||||
define initrd_bin =
|
||||
initrd/bin/$(notdir $1): $1
|
||||
cmp --quiet "$$@" "$$^" || \
|
||||
cp -a "$$^" "$$@"
|
||||
initrd_bins += initrd/bin/$(notdir $1)
|
||||
endef
|
||||
|
||||
$(foreach _, $(call outputs,kexec), $(eval $(call initrd_bin,$_)))
|
||||
$(foreach _, $(call outputs,tpmtotp), $(eval $(call initrd_bin,$_)))
|
||||
|
||||
# hack to install busybox into the initrd
|
||||
initrd_bins += initrd/bin/busybox
|
||||
|
||||
initrd/bin/busybox: $(build)/$(busybox_dir)/busybox
|
||||
cmp --quiet "$@" "$^" || \
|
||||
make \
|
||||
-C $(build)/$(busybox_dir) \
|
||||
CONFIG_PREFIX="$(pwd)/initrd" \
|
||||
install
|
||||
|
||||
|
||||
# Update all of the libraries in the initrd based on the executables
|
||||
# that were installed.
|
||||
initrd_libs:
|
||||
./populate-lib \
|
||||
./initrd/lib/x86-64-linux-gnu/ \
|
||||
initrd/bin/* \
|
||||
initrd/sbin/* \
|
||||
|
||||
|
||||
#
|
||||
# We also have to include some real /dev files; the minimal
|
||||
# set should be determined.
|
||||
#
|
||||
initrd_devs += /dev/console
|
||||
initrd_devs += /dev/mem
|
||||
initrd_devs += /dev/null
|
||||
initrd_devs += /dev/tty
|
||||
initrd_devs += /dev/tty0
|
||||
initrd_devs += /dev/ttyS0
|
||||
|
||||
#
|
||||
# initrd image creation
|
||||
#
|
||||
# The initrd is constructed from various bits and pieces
|
||||
# Note the touch and sort operation on the find output -- this
|
||||
# ensures that the files always have the same timestamp and
|
||||
# appear in the same order.
|
||||
#
|
||||
# This breaks on the files in /dev.
|
||||
#
|
||||
#
|
||||
initrd.cpio: $(initrd_bins) initrd_libs
|
||||
find ./initrd -type f -print0 \
|
||||
| xargs -0 touch -d "1970-01-01"
|
||||
cd ./initrd; \
|
||||
find . $(initrd_devs) \
|
||||
| sort \
|
||||
| cpio --quiet -H newc -o \
|
||||
> "../$@.tmp"
|
||||
if ! cmp --quiet "$@" "$@.tmp"; then \
|
||||
mv "$@.tmp" "$@"; \
|
||||
else \
|
||||
echo "$@: Unchanged"; \
|
||||
rm "$@.tmp"; \
|
||||
fi
|
||||
|
||||
|
||||
# hack for the linux kernel to depend on the initrd image
|
||||
# this will change once coreboot can link in the initrd separately
|
||||
$(call outputs,linux): initrd.cpio
|
||||
|
@ -138,7 +138,7 @@ CONFIG_ARCH_SUPPORTS_INT128=y
|
||||
# CONFIG_SYSFS_DEPRECATED is not set
|
||||
# CONFIG_RELAY is not set
|
||||
CONFIG_BLK_DEV_INITRD=y
|
||||
CONFIG_INITRAMFS_SOURCE="../initrd"
|
||||
CONFIG_INITRAMFS_SOURCE="../../initrd.cpio"
|
||||
CONFIG_INITRAMFS_ROOT_UID=0
|
||||
CONFIG_INITRAMFS_ROOT_GID=0
|
||||
# CONFIG_RD_GZIP is not set
|
||||
|
10
modules/linux
Normal file
10
modules/linux
Normal file
@ -0,0 +1,10 @@
|
||||
modules += linux
|
||||
|
||||
linux_version := 4.6.4
|
||||
linux_dir := linux-$(linux_version)
|
||||
linux_tar := linux-$(linux_version).tar.xz
|
||||
linux_url := https://cdn.kernel.org/pub/linux/kernel/v4.x/$(linux_tar)
|
||||
linux_hash := 8568d41c7104e941989b14a380d167129f83db42c04e950d8d9337fe6012ff7e
|
||||
|
||||
linux_configure := make oldconfig
|
||||
linux_output := arch/x86/boot/bzImage
|
Loading…
Reference in New Issue
Block a user