add missing flag
[openwrt/openwrt.git] / include / subdir.mk
1 # debug flags:
2 #
3 # d: show subdirectory tree
4 # t: show added targets
5 # l: show legacy targets
6
7 ifeq ($(DEBUG),all)
8 build_debug:=dlt
9 else
10 build_debug:=$(DEBUG)
11 endif
12
13 define debug
14 $$(findstring $(2),$$(if $$(DEBUG_DIR),$$(if $$(filter $$(DEBUG_DIR)%,$(1)),$(build_debug)),$(build_debug)))
15 endef
16
17 define warn
18 $$(if $(call debug,$(1),$(2)),$$(warning $(3)))
19 endef
20
21 define warn_eval
22 $(call warn,$(1),$(2),$(3) $(4))
23 $(4)
24 endef
25
26 SUBTARGETS:=clean download prepare compile install update refresh prereq
27
28 # Parameters: <subdir>
29 define subdir
30 $(call warn,$(1),d,D $(1))
31 $(foreach bd,$($(1)/builddirs),
32 $(call warn,$(1),d,BD $(1)/$(bd))
33 $(foreach target,$(SUBTARGETS),
34 $(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(target): $($(1)/$(bd)/$(target)) $(call $(1)//$(target),$(1)/$(bd)))
35 @$$(MAKE) -j1 -C $(1)/$(bd) $(target)
36
37 # legacy targets
38 $(call warn_eval,$(1)/$(bd),l,T,$(1)/$(bd)-$(target): $(1)/$(bd)/$(target))
39 )
40 )
41 $(foreach target,$(SUBTARGETS),
42 $(call warn_eval,$(1),t,T,$(1)/$(target): $($(1)/) $(foreach bd,$($(1)/builddirs),$(1)/$(bd)/$(target)))
43 )
44 endef
45
46 # Parameters: <subdir> <name>
47 define stampfile
48 $(1)/stamp:=$(STAGING_DIR)/stampfiles/.$(2)_installed
49 $(call rdep,$(1),$$($(1)/stamp))
50
51 $$($(1)/stamp):
52 @$(MAKE) $(1)/install
53 @mkdir -p $$$$(dirname $$($(1)/stamp))
54 @touch $$($(1)/stamp)
55 .PRECIOUS: $$($(1)/stamp) # work around a make bug
56
57 $(1)//clean:=$(1)/stamp/clean
58 $(1)/stamp/clean: FORCE
59 @rm -f $$($(1)/stamp)
60
61 endef