Project

General

Profile

1
##### Vars/functions
2

    
3
# Make
4
pathParts = $(shell path="$(1)"; echo "$${path%%/*}" "$${path\#*/}")
5
topDir = $(word 1,$(pathParts))
6
subPath = $(word 2,$(pathParts))
7
subMake = $(MAKE) $(call subPath,$@) --directory=$(call topDir,$@) \
8
--makefile=../input.Makefile
9
# input.Makefile path is relative to subdir
10

    
11
# SVN
12
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
13

    
14
##### General targets
15

    
16
all:
17

    
18
.SUFFIXES: # turn off built-in suffix rules
19
.SECONDARY: # don't automatically delete intermediate files
20
.DELETE_ON_ERROR: # delete target if recipe fails
21

    
22
_always:
23
.PHONY: _always
24

    
25
##### SVN
26

    
27
# Adds a new datasource
28
# Must come before $(subdir)% to override it
29
%/add: _always
30
	$(call addDir,$*)
31
	$(subMake)
32

    
33
##### Subdir forwarding
34

    
35
subdirs := $(wildcard */)
36

    
37
define subdirTargets
38
$(subdir): _always
39
	+$$(subMake)
40

    
41
$(subdir)%: _always
42
	+$$(subMake)
43
.PRECIOUS: $(subdir)% # let subdir's Makefile decide whether to delete on error
44
endef
45
$(foreach subdir,$(subdirs),$(eval $(subdirTargets)))
46

    
47
Makefile: ;
48

    
49
%: $(addsuffix %,$(subdirs)) _always ;
(1-1/2)