functions.mk 1.5 KB
Newer Older
1
# globals
2
PKGDIR ?= $(GLOBAL_BUILDDIR)/pkg
3

4
# duplicated from metaprofile makefiles for the sake of "local" builds
5
ARCH ?= $(shell arch | sed 's/i686/i586/; s/armv.*/arm/; s/ppc.*/ppc/')
6
DATE ?= $(shell date +%Y%m%d)
7

8 9 10
# prefix pkglist name with its directory to form a path (relative/absolute)
rlist = $(1:%=lists/%)
list  = $(addprefix $(PKGDIR)/,$(call rlist,$(1)))
11

12 13 14
# prefix/suffix group name to form a path (relative/absolute)
rgroup = $(1:%=groups/%.directory)
group  = $(addprefix $(PKGDIR)/,$(call rgroup,$(1)))
Michael Shigorin's avatar
Michael Shigorin committed
15

16 17 18 19
# prefix/suffix pkg profile name to form a path (relative/absolute)
rprofile = $(1:%=profiles/%.directory)
profile  = $(addprefix $(PKGDIR)/,$(call rprofile,$(1)))

Michael Shigorin's avatar
Michael Shigorin committed
20 21 22
# map first argument (a function) onto second one (an argument list)
map = $(foreach a,$(2),$(call $(1),$(a)))

23 24 25 26 27 28 29 30 31
# happens at least twice, and variables are the same by design
groups2lists = $(shell $(groups2lists_body))
define groups2lists_body
{ if [ -n "$(THE_GROUPS)$(MAIN_GROUPS)" ]; then \
	  sed -rn 's,^X-Alterator-PackageList=(.*)$$,\1,p' \
		$(call map,group,$(THE_GROUPS) $(MAIN_GROUPS)); \
fi; }
endef

Michael Shigorin's avatar
Michael Shigorin committed
32 33 34
# kernel package list generation; see also #24669
NULL :=
SPACE := $(NULL) # the officially documented way of getting a space
Michael Shigorin's avatar
Michael Shigorin committed
35
COMMA := ,
36

Michael Shigorin's avatar
Michael Shigorin committed
37
list2re = $(subst $(SPACE),|,$(strip $(1)))
38

Michael Shigorin's avatar
Michael Shigorin committed
39 40 41 42
# args: KFLAVOURS, KMODULES
# NB: $(2) could be empty
kpackages = $(and $(1), \
	^kernel-(image|modules-($(call list2re,$(2))))-($(call list2re,$(1)))$$)
43 44

# arg: branding subpackages
45
branding = $(and $(1),^branding-$(BRANDING)-($(call list2re,$(1)))$$)