LinuxBoot: refactor payload
Clean and refactor the structure of the LinuxBoot payload integration, to make it more modular and readable. The kernel and initramfs should handled in separated makefiles. tested with: - qemu-i440fx (x86, x86_64) - cavium CN8100 (arm64) Change-Id: I41d0275a5f7efb920e881f43b0acda29f41ee221 Signed-off-by: Marcello Sylvester Bauer <info@marcellobauer.com> Reviewed-on: https://review.coreboot.org/c/29581 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
This commit is contained in:
committed by
Philipp Deppenwiese
parent
5d8f02f3ef
commit
78d0256f1d
99
payloads/external/LinuxBoot/Makefile
vendored
99
payloads/external/LinuxBoot/Makefile
vendored
@@ -1,6 +1,7 @@
|
||||
## This file is part of the coreboot project.
|
||||
##
|
||||
## Copyright (C) 2017 Facebook Inc.
|
||||
## Copyright (C) 2018 9elements Cyber Security
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@@ -12,90 +13,48 @@
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
kernel_tarball=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-$(CONFIG_LINUXBOOT_KERNEL_VERSION).tar.xz
|
||||
project_dir=linuxboot
|
||||
kernel_dir=$(project_dir)/kernel
|
||||
|
||||
unexport $(COREBOOT_EXPORTS)
|
||||
unexport MAKEFLAGS
|
||||
|
||||
XGCCPATH?=$(PWD)/util/crossgcc/xgcc/bin
|
||||
ifeq ($(CONFIG_LINUXBOOT_ARCH),386)
|
||||
LINUXBOOT_COMPILE?=$(XGCCPATH)/i386-linux-
|
||||
ARCH?=x86
|
||||
else ifeq ($(CONFIG_LINUXBOOT_ARCH),amd64)
|
||||
LINUXBOOT_COMPILE?=$(XGCCPATH)/x86_64-linux-
|
||||
ARCH?=x86_64
|
||||
else ifeq ($(CONFIG_LINUXBOOT_ARCH),arm64)
|
||||
LINUXBOOT_COMPILE?=$(XGCCPATH)/aarch64-linux-
|
||||
ARCH?=arm64
|
||||
endif
|
||||
|
||||
OBJCOPY:=$(LINUXBOOT_COMPILE)objcopy
|
||||
|
||||
all: linuxboot
|
||||
|
||||
toolchain:
|
||||
if [[ ! -x "$(LINUXBOOT_COMPILE)gcc" ]]; then \
|
||||
echo "Toolchain '$(LINUXBOOT_COMPILE)*' is missing."; \
|
||||
u-root:
|
||||
$(MAKE) -f targets/u-root.mk
|
||||
|
||||
ifeq ($(CONFIG_LINUXBOOT_BUILD_INITRAMFS),y)
|
||||
ifeq ($(CONFIG_LINUXBOOT_UROOT),y)
|
||||
initramfs: u-root
|
||||
endif
|
||||
else
|
||||
ifneq ($(CONFIG_LINUXBOOT_INITRAMFS),)
|
||||
initramfs:
|
||||
if [[ ! -f "$(top)/$(CONFIG_LINUXBOOT_INITRAMFS)" ]]; then \
|
||||
echo "<< Linux initramfs '$(CONFIG_LINUXBOOT_INITRAMFS)' is missing. >>"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
$(kernel_dir)/.config:
|
||||
echo " WWW Download Linux $(CONFIG_LINUXBOOT_KERNEL_VERSION)"
|
||||
mkdir -p $(kernel_dir)
|
||||
ifeq ("$(wildcard $(kernel_dir)/README)","")
|
||||
curl -s $(kernel_tarball) | tar xJ -C $(kernel_dir) --strip 1
|
||||
endif
|
||||
endif
|
||||
|
||||
config: $(kernel_dir)/.config
|
||||
echo " CONFIG Linux $(CONFIG_LINUXBOOT_KERNEL_VERSION)"
|
||||
ifneq ($(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE),)
|
||||
cp $(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE) $(kernel_dir)/.config
|
||||
else ifeq ($(CONFIG_LINUXBOOT_ARCH),386)
|
||||
cp x86/defconfig $(kernel_dir)/.config
|
||||
else ifeq ($(CONFIG_LINUXBOOT_ARCH),amd64)
|
||||
cp x86_64/defconfig $(kernel_dir)/.config
|
||||
else ifeq ($(CONFIG_LINUXBOOT_ARCH),arm64)
|
||||
cp arm64/defconfig $(kernel_dir)/.config
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(CONFIG_LINUXBOOT_ARCH),386 amd64))
|
||||
$(kernel_dir)/arch/x86/boot/bzImage: config toolchain
|
||||
else ifeq ($(CONFIG_LINUXBOOT_ARCH),arm64)
|
||||
$(kernel_dir)/vmlinux: config toolchain
|
||||
endif
|
||||
echo " MAKE Kernel $(CONFIG_LINUXBOOT_KERNEL_VERSION)"
|
||||
$(MAKE) -C $(kernel_dir) olddefconfig CROSS_COMPILE=$(LINUXBOOT_COMPILE) ARCH=$(ARCH)
|
||||
$(MAKE) -C $(kernel_dir) -j $(CPUS) CROSS_COMPILE=$(LINUXBOOT_COMPILE) ARCH=$(ARCH)
|
||||
|
||||
ifneq (,$(filter $(CONFIG_LINUXBOOT_ARCH),386 amd64))
|
||||
$(project_dir)/kernel-image: $(kernel_dir)/arch/x86/boot/bzImage
|
||||
cp $< $@
|
||||
else ifeq ($(CONFIG_LINUXBOOT_ARCH),arm64)
|
||||
$(project_dir)/vmlinux.bin: $(kernel_dir)/vmlinux
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
$(project_dir)/target.dtb: $(PWD)/$(CONFIG_LINUXBOOT_DTB_FILE)
|
||||
cp $< $@
|
||||
|
||||
$(project_dir)/vmlinux.bin.lzma: $(project_dir)/vmlinux.bin
|
||||
xz -c -k -f --format=lzma --lzma1=dict=1MiB,lc=3,lp=0,pb=3 $< > $@
|
||||
|
||||
$(project_dir)/kernel-image: $(project_dir)/vmlinux.bin.lzma $(project_dir)/../arm64/kernel_fdt_lzma.its $(project_dir)/target.dtb $(PWD)/$(CONFIG_LINUX_INITRD)
|
||||
cp $(project_dir)/../arm64/kernel_fdt_lzma.its $(project_dir)
|
||||
mkimage -f $(project_dir)/kernel_fdt_lzma.its $@
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LINUXBOOT_UROOT),y)
|
||||
$(PWD)/$(CONFIG_LINUX_INITRD):
|
||||
$(MAKE) -f targets/u-root.mk
|
||||
ifeq ($(CONFIG_LINUXBOOT_COMPILE_KERNEL),y)
|
||||
ifeq ($(CONFIG_LINUXBOOT_ARCH),arm64)
|
||||
kernel: initramfs
|
||||
$(MAKE) -f targets/linux.mk
|
||||
else
|
||||
$(PWD)/$(CONFIG_LINUX_INITRD):
|
||||
echo "Building without u-root support"
|
||||
kernel:
|
||||
$(MAKE) -f targets/linux.mk
|
||||
endif
|
||||
else
|
||||
kernel:
|
||||
if [[ ! -f "$(top)/$(CONFIG_LINUXBOOT_KERNEL)" ]]; then \
|
||||
echo "<< Linux kernel '$(CONFIG_LINUXBOOT_KERNEL)' is missing. >>"; \
|
||||
exit 1; \
|
||||
fi
|
||||
endif
|
||||
|
||||
linuxboot: $(project_dir)/kernel-image $(PWD)/$(CONFIG_LINUX_INITRD)
|
||||
linuxboot: kernel initramfs
|
||||
|
||||
clean:
|
||||
if [ -d "$(kernel_dir)" ]; then rm -rf $(kernel_dir); fi
|
||||
@@ -104,4 +63,4 @@ clean:
|
||||
distclean:
|
||||
rm -rf $(project_dir)
|
||||
|
||||
.PHONY: config patch payload clean distclean clone fetch all toolchain
|
||||
.PHONY: linuxboot kernel initramfs u-root clean distclean
|
||||
|
Reference in New Issue
Block a user