heads/modules/u-root

54 lines
1.5 KiB
Makefile
Raw Normal View History

#
# 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
u-root_output := $(build)/$(BOARD)/u-root.cpio
UROOT_CMDS ?=
export GOPATH=$(build)/go
u-root_src_cmds := $(foreach cmd,$(UROOT_CMDS),github.com/u-root/u-root/cmds/$(cmd))
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/...
#
# 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,$@)
endif
2018-04-29 18:56:33 +00:00
$(u-root_output): $(u-root_build) $(u-root_uinit)
$(call do,U-ROOT,$@,\
$(GOPATH)/bin/u-root \
-build=bb \
-format=cpio \
-o $@ \
$(u-root_src_cmds)\
)
# Override the initrd inputs and add in the kernel modules
initrd-$(CONFIG_UROOT) += $(u-root_output)
ifeq "$(CONFIG_UROOT)" "y"
# If we are building for u-root, disable the default CONFIG_HEADS
# so that the heads/initrd/etc directories will not be included
CONFIG_HEADS=n
# Since we do not include u-root in modules-y, we have to define our
# own intermediate and clean targets here
$(build)/$(u-root_dir)/.build: $(u-root_output)
u-root.clean:
$(RM) $(u-root_output)
endif