| 1 |
|
| 2 |
|
| 3 |
uroot_package = github.com/u-root/u-root |
| 4 |
uroot_build = build/go/src/$(uroot_package) |
| 5 |
|
| 6 |
UROOT_ARCH-$(CONFIG_LINUXBOOT_X86_64) = amd64 |
| 7 |
UROOT_ARCH-$(CONFIG_LINUXBOOT_X86) = 386 |
| 8 |
UROOT_ARCH-$(CONFIG_LINUXBOOT_ARM64) = arm64 |
| 9 |
UROOT_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV64) = riscv64 |
| 10 |
|
| 11 |
go_version = $(shell go version | sed -nr 's/.*go([0-9]+\.[0-9]+.?[0-9]?).*/\1/p' ) |
| 12 |
go_version_major = $(shell echo $(go_version) | sed -nr 's/^([0-9]+)\.([0-9]+)\.?([0-9]*)$$/\1/p') |
| 13 |
go_version_minor = $(shell echo $(go_version) | sed -nr 's/^([0-9]+)\.([0-9]+)\.?([0-9]*)$$/\2/p') |
| 14 |
|
| 15 |
uroot_args += -build=$(CONFIG_LINUXBOOT_UROOT_FORMAT) |
| 16 |
uroot_args += -initcmd $(CONFIG_LINUXBOOT_UROOT_INITCMD) |
| 17 |
uroot_args += -uinitcmd=$(CONFIG_LINUXBOOT_UROOT_UINITCMD) |
| 18 |
uroot_args += -defaultsh $(CONFIG_LINUXBOOT_UROOT_SHELL) |
| 19 |
ifneq (CONFIG_LINUXBOOT_UROOT_FILES,) |
| 20 |
uroot_args += $(foreach file,$(CONFIG_LINUXBOOT_UROOT_FILES),-files $(PWD)/$(file)) |
| 21 |
endif |
| 22 |
|
| 23 |
uroot_cmds = $(CONFIG_LINUXBOOT_UROOT_COMMANDS) |
| 24 |
|
| 25 |
version: |
| 26 |
ifeq ("$(go_version)","") |
| 27 |
printf "\n<<Please install Golang >= 1.9 for u-root mode>>\n\n" |
| 28 |
exit 1 |
| 29 |
endif |
| 30 |
ifeq ($(shell if [ $(go_version_major) -eq 1 ]; then echo y; fi),y) |
| 31 |
ifeq ($(shell if [ $(go_version_minor) -lt 9 ]; then echo y; fi),y) |
| 32 |
printf "\n Golang version $(go_version) currently installed.\n\ |
| 33 |
<<Please install Golang >= 1.9 for u-root mode>>\n\n" |
| 34 |
exit 1 |
| 35 |
endif |
| 36 |
endif |
| 37 |
|
| 38 |
$(uroot_build): | build/ |
| 39 |
git clone https://$(uroot_package) $(uroot_build) |
| 40 |
git -C $(uroot_build) checkout --quiet $(CONFIG_LINUXBOOT_UROOT_VERSION) |
| 41 |
|
| 42 |
$(uroot_build)/u-root: | $(uroot_build) |
| 43 |
cd $(uroot_build); \ |
| 44 |
go build -o u-root . |
| 45 |
|
| 46 |
build/initramfs_u-root.cpio: $(uroot_build)/u-root |
| 47 |
cd $(uroot_build); \ |
| 48 |
echo "GOARCH=$(UROOT_ARCH-y) ./u-root $(uroot_args) -o initramfs_u-root.cpio $(uroot_cmds)" |
| 49 |
cd $(uroot_build); \ |
| 50 |
GOARCH=$(UROOT_ARCH-y) ./u-root $(uroot_args) -o initramfs_u-root.cpio $(uroot_cmds) |
| 51 |
cp $(uroot_build)/initramfs_u-root.cpio $@ |