2018-06-19 20:22:32 +02:00
|
|
|
## This file is part of the coreboot project.
|
|
|
|
##
|
|
|
|
## Copyright (C) 2017 Facebook Inc.
|
|
|
|
##
|
|
|
|
## 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
|
|
|
|
## the Free Software Foundation; version 2 of the License.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## 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)
|
2018-03-13 11:22:26 +01:00
|
|
|
unexport MAKEFLAGS
|
|
|
|
|
|
|
|
XGCCPATH?=$(PWD)/util/crossgcc/xgcc/bin
|
|
|
|
ifeq ($(CONFIG_LINUXBOOT_ARCH),386)
|
2018-07-30 22:49:33 +02:00
|
|
|
LINUXBOOT_COMPILE?=$(XGCCPATH)/i386-linux-
|
2018-03-13 11:22:26 +01:00
|
|
|
ARCH?=x86
|
|
|
|
else ifeq ($(CONFIG_LINUXBOOT_ARCH),amd64)
|
2018-07-30 22:49:33 +02:00
|
|
|
LINUXBOOT_COMPILE?=$(XGCCPATH)/x86_64-linux-
|
2018-03-13 11:22:26 +01:00
|
|
|
ARCH?=x86_64
|
|
|
|
else ifeq ($(CONFIG_LINUXBOOT_ARCH),arm64)
|
2018-07-30 22:49:33 +02:00
|
|
|
LINUXBOOT_COMPILE?=$(XGCCPATH)/aarch64-linux-
|
2018-03-13 11:22:26 +01:00
|
|
|
ARCH?=arm64
|
|
|
|
endif
|
|
|
|
|
2018-07-30 22:49:33 +02:00
|
|
|
OBJCOPY:=$(LINUXBOOT_COMPILE)objcopy
|
2018-06-19 20:22:32 +02:00
|
|
|
|
2018-11-04 11:24:28 +01:00
|
|
|
all: linuxboot
|
2018-06-19 20:22:32 +02:00
|
|
|
|
2018-03-13 11:22:26 +01:00
|
|
|
toolchain:
|
2018-07-30 22:49:33 +02:00
|
|
|
if [[ ! -x "$(LINUXBOOT_COMPILE)gcc" ]]; then \
|
|
|
|
echo "Toolchain '$(LINUXBOOT_COMPILE)*' is missing."; \
|
2018-03-13 11:22:26 +01:00
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
|
2018-06-19 20:22:32 +02:00
|
|
|
$(kernel_dir)/.config:
|
|
|
|
echo " WWW Download Linux $(CONFIG_LINUXBOOT_KERNEL_VERSION)"
|
|
|
|
mkdir -p $(kernel_dir)
|
|
|
|
ifeq ("$(wildcard $(kernel_dir)/README)","")
|
2018-11-01 14:12:01 +01:00
|
|
|
curl -s $(kernel_tarball) | tar xJ -C $(kernel_dir) --strip 1
|
2018-06-19 20:22:32 +02:00
|
|
|
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
|
2018-11-01 13:07:23 +01:00
|
|
|
else ifeq ($(CONFIG_LINUXBOOT_ARCH),386)
|
2018-06-19 20:22:32 +02:00
|
|
|
cp x86/defconfig $(kernel_dir)/.config
|
|
|
|
else ifeq ($(CONFIG_LINUXBOOT_ARCH),amd64)
|
|
|
|
cp x86_64/defconfig $(kernel_dir)/.config
|
2018-03-13 11:22:26 +01:00
|
|
|
else ifeq ($(CONFIG_LINUXBOOT_ARCH),arm64)
|
|
|
|
cp arm64/defconfig $(kernel_dir)/.config
|
2018-06-19 20:22:32 +02:00
|
|
|
endif
|
|
|
|
|
2018-03-13 11:22:26 +01:00
|
|
|
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
|
2018-06-19 20:22:32 +02:00
|
|
|
echo " MAKE Kernel $(CONFIG_LINUXBOOT_KERNEL_VERSION)"
|
2018-07-30 22:49:33 +02:00
|
|
|
$(MAKE) -C $(kernel_dir) olddefconfig CROSS_COMPILE=$(LINUXBOOT_COMPILE) ARCH=$(ARCH)
|
|
|
|
$(MAKE) -C $(kernel_dir) -j $(CPUS) CROSS_COMPILE=$(LINUXBOOT_COMPILE) ARCH=$(ARCH)
|
2018-03-13 11:22:26 +01:00
|
|
|
|
|
|
|
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 $< $@
|
|
|
|
|
2018-08-30 23:07:02 +02:00
|
|
|
$(project_dir)/target.dtb: $(PWD)/$(CONFIG_LINUXBOOT_DTB_FILE)
|
2018-03-13 11:22:26 +01:00
|
|
|
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 $< > $@
|
|
|
|
|
2018-11-06 12:32:14 +01:00
|
|
|
$(project_dir)/kernel-image: $(project_dir)/vmlinux.bin.lzma $(project_dir)/../arm64/kernel_fdt_lzma.its $(project_dir)/target.dtb $(PWD)/$(CONFIG_LINUX_INITRD)
|
2018-03-13 11:22:26 +01:00
|
|
|
cp $(project_dir)/../arm64/kernel_fdt_lzma.its $(project_dir)
|
|
|
|
mkimage -f $(project_dir)/kernel_fdt_lzma.its $@
|
2018-06-19 20:22:32 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_LINUXBOOT_UROOT),y)
|
2018-11-06 12:32:14 +01:00
|
|
|
$(PWD)/$(CONFIG_LINUX_INITRD):
|
2018-06-19 20:22:32 +02:00
|
|
|
$(MAKE) -f targets/u-root.mk
|
2018-03-13 11:22:26 +01:00
|
|
|
else
|
2018-11-06 12:32:14 +01:00
|
|
|
$(PWD)/$(CONFIG_LINUX_INITRD):
|
2018-03-13 11:22:26 +01:00
|
|
|
echo "Building without u-root support"
|
2018-06-19 20:22:32 +02:00
|
|
|
endif
|
|
|
|
|
2018-11-06 12:32:14 +01:00
|
|
|
linuxboot: $(project_dir)/kernel-image $(PWD)/$(CONFIG_LINUX_INITRD)
|
2018-03-13 11:22:26 +01:00
|
|
|
|
2018-06-19 20:22:32 +02:00
|
|
|
clean:
|
2018-07-30 22:49:33 +02:00
|
|
|
if [ -d "$(kernel_dir)" ]; then rm -rf $(kernel_dir); fi
|
2018-06-19 20:22:32 +02:00
|
|
|
rm -f $(project_dir)/initramfs.cpio.xz
|
|
|
|
|
|
|
|
distclean:
|
|
|
|
rm -rf $(project_dir)
|
|
|
|
|
2018-03-13 11:22:26 +01:00
|
|
|
.PHONY: config patch payload clean distclean clone fetch all toolchain
|