heads/modules/u-root

55 lines
1.5 KiB
Plaintext

#
# 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))
$(GOPATH):
$(call do,GO GET,$(u-root_url),\
go get $(u-root_url) \
)
#
# 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
$(u-root_uinit): boards/$(BOARD)/uinit.go
$(call install,$<,$@)
endif
$(u-root_output): $(GOPATH) $(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
u-root.intermediate: $(u-root_output)
u-root.clean:
$(RM) $(u-root_output)
endif