Project

General

Profile

1 785 aaronmk
##### Vars/functions
2
3 410 aaronmk
# Make
4 625 aaronmk
pathParts = $(shell path="$(1)"; echo "$${path%%/*}" "$${path\#*/}")
5 874 aaronmk
topDir = $(word 1,$(pathParts))
6
subPath = $(word 2,$(pathParts))
7 625 aaronmk
subMake = $(MAKE) $(call subPath,$@) --directory=$(call topDir,$@) \
8
--makefile=../input.Makefile
9 623 aaronmk
# input.Makefile path is relative to subdir
10 410 aaronmk
11 1590 aaronmk
# SVN
12 1594 aaronmk
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
13 1590 aaronmk
14 785 aaronmk
##### General targets
15 410 aaronmk
16
all:
17
18 1260 aaronmk
.SUFFIXES: # turn off built-in suffix rules
19
.SECONDARY: # don't automatically delete intermediate files
20 1354 aaronmk
.DELETE_ON_ERROR: # delete target if recipe fails
21 410 aaronmk
22
_always:
23
.PHONY: _always
24
25 1591 aaronmk
##### SVN
26
27
# Adds a new datasource
28
# Must come before $(subdir)% to override it
29 1594 aaronmk
%/add: _always
30
	$(call addDir,$*)
31
	$(subMake)
32 1591 aaronmk
33
##### Subdir forwarding
34
35 623 aaronmk
subdirs := $(wildcard */)
36
37 410 aaronmk
define subdirTargets
38
$(subdir): _always
39
	+$$(subMake)
40
41
$(subdir)%: _always
42
	+$$(subMake)
43 1628 aaronmk
.PRECIOUS: $(subdir)% # let subdir's Makefile decide whether to delete on error
44 410 aaronmk
endef
45 623 aaronmk
$(foreach subdir,$(subdirs),$(eval $(subdirTargets)))
46 410 aaronmk
47 416 aaronmk
Makefile: ;
48
49 623 aaronmk
%: $(addsuffix %,$(subdirs)) _always ;