lib/functions.mk: initial xport()

A few too many downstream makefiles employed the pattern
of "export GLOBAL_VAR := $(VAR)"; macroize that.
This commit is contained in:
Michael Shigorin 2012-06-26 01:10:12 +03:00
parent fcf41f2201
commit e36792ac90
5 changed files with 11 additions and 3 deletions

View File

@ -1,3 +1,4 @@
# hooked from ../../lib/sugar.mk
use/build-vm:
@$(call add_feature)
@$(call xport,ROOTPW)

View File

@ -1,5 +1,6 @@
use/cleanup:
@$(call add_feature)
@$(call xport,CLEANUP_PACKAGES)
use/cleanup/installer: use/cleanup
@$(call add,CLEANUP_PACKAGES,'installer-*')

View File

@ -5,6 +5,7 @@ use/install2: use/stage2 sub/stage2/install2 use/metadata use/cleanup/installer
@$(call add,INSTALL2_PACKAGES,branding-$$(BRANDING)-alterator)
@$(call add,BASE_PACKAGES,branding-$$(BRANDING)-release)
@$(call add,BASE_LISTS,$(call tags,basesystem))
@$(call xport,BASE_BOOTLOADER)
use/install2/net: use/install2
@$(call add,INSTALL2_PACKAGES,curl)

View File

@ -8,9 +8,6 @@ MKI_PACK_RESULTS = squash:altinst
# also removed in a cleanup hook but to spare a few cycles...
HSH_EXCLUDE_DOCS = 1
# pass downstream
GLOBAL_BASE_BOOTLOADER := $(BASE_BOOTLOADER)
debug::
@echo "** install2: IMAGE_PACKAGES: $(IMAGE_PACKAGES)"
@echo "** install2: IMAGE_PACKAGES_REGEXP: $(IMAGE_PACKAGES_REGEXP)"

View File

@ -36,6 +36,14 @@ define try_body
printf '%s ?= %s\n' '$(1)' '$(2)' >> "$(CONFIG)"; }
endef
# xport() requests a variable to be exported to the scripts
xport = $(and $(1),$(xport_body))
define xport_body
{ $(log_body); \
v='$(1:GLOBAL_%=%)'; \
printf 'export GLOBAL_%s = $$(%s)\n' "$$v" "$$v" >> "$(CONFIG)"; }
endef
# if the rule being executed isn't logged yet, log it
define log_body
{ [ -s "$(CONFIG)" ] && \