ecbed4b23a
The new make-4.4 does not reset '$(1)', '$(2)', etc. when do recursively
expanding. So the functions fire spontaneously. The reason for recursive
expanding might be to use $(shell ...).
To protect the code from spontaneous execution, we add a match check
'$(0)' to the function name. The '$(0)' variable must always have the
name of our function at the time of the call. If this is not the case,
then we are out of the $(call ...) context.
From make documentation:
| The syntax of the 'call' function is:
|
| $(call VARIABLE,PARAM,PARAM,...)
|
| When 'make' expands this function, it assigns each PARAM to temporary
| variables '$(1)', '$(2)', etc. The variable '$(0)' will contain
| VARIABLE.
Fix ALT bug 44561
See also:
60afcd997a
81 lines
2.0 KiB
Makefile
81 lines
2.0 KiB
Makefile
ifneq (clean,$(MAKECMDGOALS))
|
|
ifneq (distclean,$(MAKECMDGOALS))
|
|
|
|
ifeq (,$(INCLUDED_FUNCTIONS_MK))
|
|
INCLUDED_FUNCTIONS_MK = 1
|
|
|
|
# globals
|
|
PKGDIR ?= $(GLOBAL_BUILDDIR)/pkg
|
|
|
|
# duplicated from metaprofile makefiles for the sake of "local" builds
|
|
ARCH ?= $(shell arch | sed 's/i686/i586/; s/armv.*/arm/')
|
|
DATE ?= $(shell date +%Y%m%d)
|
|
|
|
# prefix pkglist name with its directory to form a path (relative/absolute)
|
|
define rlist
|
|
$(if $(filter rlist,$(0)),$(1:%=lists/%))
|
|
endef
|
|
|
|
define list
|
|
$(if $(filter list,$(0)),$(addprefix $(PKGDIR)/,$(call rlist,$(1))))
|
|
endef
|
|
|
|
# prefix/suffix group name to form a path (relative/absolute)
|
|
define rgroup
|
|
$(if $(filter rgroup,$(0)),$(1:%=groups/%.directory))
|
|
endef
|
|
|
|
define group
|
|
$(if $(filter group,$(0)),$(addprefix $(PKGDIR)/,$(call rgroup,$(1))))
|
|
endef
|
|
|
|
# prefix/suffix pkg profile name to form a path (relative/absolute)
|
|
define rprofile
|
|
$(if $(filter rprofile,$(0)),$(1:%=profiles/%.directory))
|
|
endef
|
|
|
|
define profile
|
|
$(if $(filter profile,$(0)),$(addprefix $(PKGDIR)/,$(call rprofile,$(1))))
|
|
endef
|
|
|
|
# map first argument (a function) onto second one (an argument list)
|
|
define map
|
|
$(if $(filter map,$(0)),$(foreach a,$(2),$(call $(1),$(a))))
|
|
endef
|
|
|
|
# happens at least twice, and variables are the same by design
|
|
define groups2lists
|
|
$(if $(filter groups2lists,$(0)),$(shell \
|
|
if [ -n "$(THE_GROUPS)$(MAIN_GROUPS)" ]; then \
|
|
sed -rn 's,^X-Alterator-PackageList=(.*)$$,\1,p' \
|
|
$(call map,group,$(THE_GROUPS) $(MAIN_GROUPS)) | \
|
|
sed 's/;/\n/g'; \
|
|
fi; \
|
|
))
|
|
endef
|
|
|
|
# kernel package list generation; see also #24669
|
|
NULL :=
|
|
SPACE := $(NULL) # the officially documented way of getting a space
|
|
COMMA := ,
|
|
|
|
define list2re
|
|
$(if $(filter list2re,$(0)),$(subst $(SPACE),|,$(strip $(1))))
|
|
endef
|
|
|
|
# args: KFLAVOURS, KMODULES
|
|
# NB: $(2) could be empty
|
|
define kpackages
|
|
$(if $(filter kpackages,$(0)),$(and $(1), \
|
|
^kernel-(image|modules-($(call list2re,$(2))))-($(call list2re,$(1)))$$))
|
|
endef
|
|
|
|
# arg: branding subpackages
|
|
define branding
|
|
$(if $(filter branding,$(0)),$(and $(1),^branding-$(BRANDING)-($(call list2re,$(1)))$$))
|
|
endef
|
|
|
|
endif
|
|
endif
|
|
endif
|