Makefile changes to support putting data into the initrd, such as terminfo.

Signed-off-by: Matthew Drobnak <matthew@drobnak.com>
This commit is contained in:
Matthew Drobnak 2024-06-12 13:42:17 +00:00
parent 19a705c179
commit 6e148cb7f2
No known key found for this signature in database
GPG Key ID: 20C3618D656E7853

View File

@ -175,11 +175,12 @@ endif
# Create a temporary directory for the initrd # Create a temporary directory for the initrd
initrd_dir := $(BOARD) initrd_dir := $(BOARD)
initrd_tmp_dir := $(shell mktemp -d) initrd_tmp_dir := $(shell mktemp -d)
initrd_data_dir := $(initrd_tmp_dir)/etc/terminfo/l
initrd_lib_dir := $(initrd_tmp_dir)/lib initrd_lib_dir := $(initrd_tmp_dir)/lib
initrd_bin_dir := $(initrd_tmp_dir)/bin initrd_bin_dir := $(initrd_tmp_dir)/bin
modules-y += initrd modules-y += initrd
$(shell mkdir -p "$(initrd_lib_dir)" "$(initrd_bin_dir)") $(shell mkdir -p "$(initrd_lib_dir)" "$(initrd_bin_dir)" "$(initrd_data_dir)")
# We are running our own version of make, # We are running our own version of make,
# proceed with the build. # proceed with the build.
@ -291,6 +292,9 @@ include modules/*
define bins = define bins =
$(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_output))) $(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_output)))
endef endef
define data =
$(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_data)))
endef
define libs = define libs =
$(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_libraries))) $(foreach m,$1,$(call prefix,$(build)/$($m_dir)/,$($m_libraries)))
endef endef
@ -298,6 +302,7 @@ endef
define outputs = define outputs =
$(foreach m,$1,\ $(foreach m,$1,\
$(call bins,$m)\ $(call bins,$m)\
$(call data,$m)\
$(call libs,$m)\ $(call libs,$m)\
) )
endef endef
@ -577,6 +582,11 @@ $(initrd_bin_dir)/$(notdir $1): $1
initrd_bins += $(initrd_bin_dir)/$(notdir $1) initrd_bins += $(initrd_bin_dir)/$(notdir $1)
endef endef
define initrd_data_add =
$(initrd_data_dir)/$(notdir $1): $1
$(call do,INSTALL-DATA,$$(<:$(pwd)/%=%),cp -a --remove-destination "$$<" "$$@")
initrd_data += $(initrd_data_dir)/$(notdir $1)
endef
define initrd_lib_add = define initrd_lib_add =
$(initrd_lib_dir)/$(notdir $1): $1 $(initrd_lib_dir)/$(notdir $1): $1
@ -622,6 +632,10 @@ $(foreach m, $(bin_modules-y), \
$(call map,initrd_bin_add,$(call bins,$m)) \ $(call map,initrd_bin_add,$(call bins,$m)) \
) )
# Install the data for every module that we have built
$(foreach m, $(modules-y), \
$(call map,initrd_data_add,$(call data,$m)) \
)
# Install the libraries for every module that we have built # Install the libraries for every module that we have built
$(foreach m, $(modules-y), \ $(foreach m, $(modules-y), \
$(call map,initrd_lib_add,$(call libs,$m)) \ $(call map,initrd_lib_add,$(call libs,$m)) \
@ -727,9 +741,11 @@ $(build)/$(initrd_dir)/heads.cpio: FORCE
# #
$(build)/$(initrd_dir)/tools.cpio: \ $(build)/$(initrd_dir)/tools.cpio: \
$(initrd_bins) \ $(initrd_bins) \
$(initrd_data) \
$(initrd_libs) \ $(initrd_libs) \
$(initrd_tmp_dir)/etc/config \ $(initrd_tmp_dir)/etc/config \
$(info Used **BINS**: $(initrd_bins))
$(call do-cpio,$@,$(initrd_tmp_dir)) $(call do-cpio,$@,$(initrd_tmp_dir))
@$(RM) -rf "$(initrd_tmp_dir)" @$(RM) -rf "$(initrd_tmp_dir)"