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>
		
	
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
| ## SPDX-License-Identifier: GPL-2.0-only
 | |
| 
 | |
| uroot_package = github.com/u-root/u-root
 | |
| uroot_build = build/go/src/$(uroot_package)
 | |
| 
 | |
| UROOT_ARCH-$(CONFIG_LIBUXBOOT_X86_64)      = amd64
 | |
| UROOT_ARCH-$(CONFIG_LINUXBOOT_X86)         = 386
 | |
| UROOT_ARCH-$(CONFIG_LINUXBOOT_ARM64)       = arm64
 | |
| UROOT_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV64)  = riscv64
 | |
| 
 | |
| go_version = $(shell go version | sed -nr 's/.*go([0-9]+\.[0-9]+.?[0-9]?).*/\1/p' )
 | |
| go_version_major = $(shell echo $(go_version) |  sed -nr 's/^([0-9]+)\.([0-9]+)\.?([0-9]*)$$/\1/p')
 | |
| go_version_minor = $(shell echo $(go_version) |  sed -nr 's/^([0-9]+)\.([0-9]+)\.?([0-9]*)$$/\2/p')
 | |
| 
 | |
| uroot_args += -build=$(CONFIG_LINUXBOOT_UROOT_FORMAT)
 | |
| uroot_args += -initcmd $(CONFIG_LINUXBOOT_UROOT_INITCMD)
 | |
| uroot_args += -uinitcmd=$(CONFIG_LINUXBOOT_UROOT_UINITCMD)
 | |
| uroot_args += -defaultsh $(CONFIG_LINUXBOOT_UROOT_SHELL)
 | |
| ifneq (CONFIG_LINUXBOOT_UROOT_FILES,)
 | |
| uroot_args += $(foreach file,$(CONFIG_LINUXBOOT_UROOT_FILES),-files $(PWD)/$(file))
 | |
| endif
 | |
| 
 | |
| uroot_cmds = $(CONFIG_LINUXBOOT_UROOT_COMMANDS)
 | |
| 
 | |
| version:
 | |
| ifeq ("$(go_version)","")
 | |
| 	printf "\n<<Please install Golang >= 1.9 for u-root mode>>\n\n"
 | |
| 	exit 1
 | |
| endif
 | |
| ifeq ($(shell if [ $(go_version_major) -eq 1 ]; then echo y; fi),y)
 | |
| ifeq ($(shell if [ $(go_version_minor) -lt 9 ]; then echo y; fi),y)
 | |
| 	printf "\n  Golang version $(go_version) currently installed.\n\
 | |
| 	<<Please install Golang >= 1.9 for u-root mode>>\n\n"
 | |
| 	exit 1
 | |
| endif
 | |
| endif
 | |
| 
 | |
| $(uroot_build):
 | |
| 	git clone https://$(uroot_package) $(uroot_build)
 | |
| 	git -C $(uroot_build) checkout --quiet $(CONFIG_LINUXBOOT_UROOT_VERSION)
 | |
| 
 | |
| $(uroot_build)/u-root: $(uroot_build)
 | |
| 	cd $(uroot_build); \
 | |
| 	go build -o u-root .
 | |
| 
 | |
| #$(CONFIG_LINUXBOOT_INITRAMFS_PATH)
 | |
| build/initramfs_u-root.cpio: $(uroot_build)/u-root
 | |
| 	GOARCH=$(UROOT_ARCH-y) $(uroot_build)/u-root \
 | |
| 	-uroot-source $(uroot_build) \
 | |
| 	$(uroot_args) -o build/initramfs_u-root.cpio $(uroot_cmds)
 |