-
Notifications
You must be signed in to change notification settings - Fork 17
/
package-graph.mk
35 lines (28 loc) · 958 Bytes
/
package-graph.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
override packages := openssh
-include package/*/*.mk
.PHONY: all config
.SHELLFLAGS = -e -c
.ONESHELL:
#############################################
# Dynamically declare dependencies between packages
#############################################
define declaredeps =
$(eval .PHONY: $1)
$(eval $1 : $(foreach dep,$($1/DEPENDS),$(dep)); +'$(MAKE)' -f package.mk package_name='$1')
$(foreach dep,$($1/DEPENDS),$(call declareonce,$(dep)))
endef
define declareonce =
$(if $($1_done),,$(call declaredeps,$1) $(eval $1_done=1))
endef
$(foreach pkg,$(packages),$(call declareonce,$(pkg)))
#############################################
# Targets
#############################################
all: $(packages)
config:
$(foreach \
var,\
$(filter %/VERSION,$(filter-out __all__/%,$(.VARIABLES))),\
[ -z "$($(var))" ] && { echo "$(var) is empty" >&2; exit 1; };\
printf 'export %s := %s\n' '$(var)' '$($(var))' >> '$(config_file)';\
)