2018-02-13 20:47:31 +00:00
|
|
|
#
|
|
|
|
# u-root go runtime
|
|
|
|
#
|
|
|
|
# This is not a normal Heads module, since it builds all of its
|
|
|
|
# own dependencies.
|
|
|
|
#
|
|
|
|
u-root_url := github.com/u-root/u-root
|
2018-02-13 22:46:48 +00:00
|
|
|
u-root_output := $(build)/$(BOARD)/u-root.cpio
|
2018-03-12 13:27:43 +00:00
|
|
|
UROOT_CMDS ?=
|
2018-02-13 20:47:31 +00:00
|
|
|
|
|
|
|
export GOPATH=$(build)/go
|
2018-03-15 19:29:36 +00:00
|
|
|
u-root_src_cmds := $(foreach cmd,$(UROOT_CMDS),github.com/u-root/u-root/cmds/$(cmd))
|
2018-02-13 20:47:31 +00:00
|
|
|
|
2018-04-30 12:48:24 +00:00
|
|
|
u-root_build := $(GOPATH)/bin/u-root
|
|
|
|
|
|
|
|
$(GOPATH)/bin/u-root:
|
|
|
|
go get github.com/u-root/u-root/...
|
2018-03-15 19:29:36 +00:00
|
|
|
#
|
|
|
|
# If the board directory has its own go commands, copy them
|
|
|
|
# into the u-root tree so that they will be bundled into the go initrd
|
|
|
|
# TODO: generalize this to support more commands
|
|
|
|
# TODO: fix this sort that it doesn't leave commands lying around
|
|
|
|
#
|
|
|
|
ifeq "y" "$(shell [ -r 'boards/$(BOARD)/uinit.go' ] && echo y)"
|
|
|
|
u-root_uinit := $(GOPATH)/src/github.com/u-root/u-root/cmds/uinit/uinit.go
|
2018-04-30 12:48:24 +00:00
|
|
|
$(u-root_uinit): $(u-root_build) boards/$(BOARD)/uinit.go
|
2018-04-30 14:14:18 +00:00
|
|
|
$(call install,boards/$(BOARD)/uinit.go,$@)
|
2018-03-12 13:27:43 +00:00
|
|
|
endif
|
2018-03-15 19:29:36 +00:00
|
|
|
|
2018-04-29 18:56:33 +00:00
|
|
|
$(u-root_output): $(u-root_build) $(u-root_uinit)
|
2018-02-13 20:47:31 +00:00
|
|
|
$(call do,U-ROOT,$@,\
|
|
|
|
$(GOPATH)/bin/u-root \
|
|
|
|
-build=bb \
|
|
|
|
-format=cpio \
|
2018-03-12 13:27:43 +00:00
|
|
|
-o $@ \
|
2018-03-15 19:29:36 +00:00
|
|
|
$(u-root_src_cmds)\
|
2018-02-13 20:47:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Override the initrd inputs and add in the kernel modules
|
2018-02-13 22:46:48 +00:00
|
|
|
initrd-$(CONFIG_UROOT) += $(u-root_output)
|
2018-02-13 20:47:31 +00:00
|
|
|
|
|
|
|
|
2018-02-13 22:46:48 +00:00
|
|
|
ifeq "$(CONFIG_UROOT)" "y"
|
2018-03-15 19:29:36 +00:00
|
|
|
# If we are building for u-root, disable the default CONFIG_HEADS
|
|
|
|
# so that the heads/initrd/etc directories will not be included
|
2018-02-13 22:46:48 +00:00
|
|
|
CONFIG_HEADS=n
|
2018-03-15 19:29:36 +00:00
|
|
|
|
|
|
|
# Since we do not include u-root in modules-y, we have to define our
|
|
|
|
# own intermediate and clean targets here
|
2018-05-02 15:38:39 +00:00
|
|
|
$(build)/$(u-root_dir)/.build: $(u-root_output)
|
2018-03-15 19:29:36 +00:00
|
|
|
u-root.clean:
|
|
|
|
$(RM) $(u-root_output)
|
2018-02-13 20:47:31 +00:00
|
|
|
endif
|