There were some issues with the current Linuxboot Makefiles.
- multithreaded compilation didn't work, because some prerequisites
were missing
- initramfs wasn't added for x86 qemu boot.
- riscv support was incomplete
It began with separate patches, but resulted in a clean up patch, that
is hard to separate. The most important changes are the following:
- Instead of phony targets, actual files are now used as prerequisites
- riscv can now be used as target
- initramfs works now also for x86
- instead of querying the most recent version from the internet, I set a
known working version (because I tested it) that can be customized
and/or upgraded in the future. The reasons:
- querying the version from the internet requires a constant
connection to the internet even after linux kernel is already
build (aka subsequent builds).
- one usually wants to use a known working version, but optionally
still have the posibillity to choose a custom one. This patch
introduces this possibility in its most simple form.
- I removed as much ifeq statements as possible and moved that
responsibility to Kconfig, because they tend to make the
Makefile less readable.
Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Change-Id: I25e757108e0dd473969fe5a192ad0733f1fe6286
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76150
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
63 lines
2.3 KiB
Makefile
63 lines
2.3 KiB
Makefile
## SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
SHELL := /bin/sh
|
|
|
|
OBJCOPY:=$(CONFIG_LINUXBOOT_CROSS_COMPILE)objcopy
|
|
KERNEL_MAKE_FLAGS = \
|
|
CROSS_COMPILE=$(CONFIG_LINUXBOOT_CROSS_COMPILE) \
|
|
ARCH=$(LINUX_ARCH-y) \
|
|
KBUILD_BUILD_USER="coreboot" \
|
|
KBUILD_BUILD_HOST="reproducible" \
|
|
KBUILD_BUILD_TIMESTAMP="$(shell perl -e 'print scalar gmtime($(SOURCE_DATE_EPOCH))')" \
|
|
KBUILD_BUILD_VERSION="0"
|
|
|
|
kernel_version = $(CONFIG_LINUXBOOT_KERNEL_VERSION)
|
|
kernel_dir = build/kernel-$(subst .,_,$(kernel_version))
|
|
kernel_tarball = linux-$(kernel_version).tar
|
|
kernel_mirror = https://mirrors.edge.kernel.org/pub/linux/kernel
|
|
|
|
ifeq ($(findstring x2.6.,x$(kernel_version)),x2.6.)
|
|
kernel_mirror_path := $(kernel_mirror)/v2.6
|
|
else ifeq ($(findstring x3.,x$(kernel_version)),x3.)
|
|
kernel_mirror_path := $(kernel_mirror)/v3.x
|
|
else ifeq ($(findstring x4.,x$(kernel_version)),x4.)
|
|
kernel_mirror_path := $(kernel_mirror)/v4.x
|
|
else ifeq ($(findstring x5.,x$(kernel_version)),x5.)
|
|
kernel_mirror_path := $(kernel_mirror)/v5.x
|
|
else ifeq ($(findstring x6.,x$(kernel_version)),x6.)
|
|
kernel_mirror_path := $(kernel_mirror)/v6.x
|
|
endif
|
|
|
|
build/$(kernel_tarball).xz:
|
|
echo " Test $(kernel_version)"
|
|
echo " WWW $(kernel_mirror_path)/$(kernel_tarball).xz";
|
|
curl -OLSs --output-dir build "$(kernel_mirror_path)/$(kernel_tarball).xz";
|
|
|
|
$(kernel_dir): build/$(kernel_tarball).xz
|
|
echo " XZ $(kernel_tarball).xz";
|
|
mkdir $(kernel_dir);
|
|
tar xJf build/$(kernel_tarball).xz --strip 1 -C $(kernel_dir);
|
|
|
|
$(kernel_dir)/.config: $(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE) | $(kernel_dir)
|
|
@echo " CONFIG Linux $(kernel_version)"
|
|
cp $(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE) $(kernel_dir)/.config
|
|
$(MAKE) -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) olddefconfig
|
|
|
|
$(kernel_dir)/vmlinux : $(kernel_dir)/.config | $(kernel_dir)
|
|
@echo " MAKE Linux $(kernel_version)"
|
|
echo "$(MAKE) -j 4 -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) vmlinux"
|
|
$(MAKE) -j 4 -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) vmlinux
|
|
|
|
build/vmlinux.bin: $(kernel_dir)/vmlinux | build
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
build/vmlinux.bin.lzma: build/vmlinux.bin
|
|
xz -c -k -f --format=lzma --lzma1=dict=1MiB,lc=3,lp=0,pb=3 $< > $@
|
|
|
|
$(kernel_dir)/arch/x86/boot/bzImage: $(kernel_dir)/.config
|
|
@echo " MAKE Linux $(kernel_version)"
|
|
echo "$(MAKE) -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) bzImage"
|
|
$(MAKE) -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) bzImage
|
|
|
|
.PHONY: kernel
|