add tex4ht.fls to the svn:ignore list
[openwrt/svn-archive/archive.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 define subtarget
29 $(call warn_eval,$(1),t,T,$(1)/$(2): $($(1)/) $(foreach bd,$(if $($(1)/builddirs-$(2)),$($(1)/builddirs-$(2)),$($(1)/builddirs)),$(1)/$(bd)/$(2)))
30
31 endef
32
33 # Parameters: <subdir>
34 define subdir
35 $(call warn,$(1),d,D $(1))
36 $(foreach bd,$($(1)/builddirs),
37 $(call warn,$(1),d,BD $(1)/$(bd))
38 $(foreach target,$(SUBTARGETS),
39 $(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(target): $($(1)/$(bd)/$(target)) $(call $(1)//$(target),$(1)/$(bd)))
40 @+$$(MAKE) -j1 -C $(1)/$(bd) $(target)
41
42 # legacy targets
43 $(call warn_eval,$(1)/$(bd),l,T,$(1)/$(bd)-$(target): $(1)/$(bd)/$(target))
44 )
45 )
46 $(foreach target,$(SUBTARGETS),$(call subtarget,$(1),$(target)))
47 endef
48
49 # Parameters: <subdir> <name>
50 define stampfile
51 $(1)/stamp:=$(STAGING_DIR)/stampfiles/.$(2)_installed
52 $(call rdep,$(1),$$($(1)/stamp))
53
54 $$($(1)/stamp):
55 @+$(MAKE) $(1)/install
56 @mkdir -p $$$$(dirname $$($(1)/stamp))
57 @touch $$($(1)/stamp)
58 .PRECIOUS: $$($(1)/stamp) # work around a make bug
59
60 $(1)//clean:=$(1)/stamp/clean
61 $(1)/stamp/clean: FORCE
62 @rm -f $$($(1)/stamp)
63
64 endef