1
|
##### Configuration
|
2
|
|
3
|
src_server ?= vegbiendev
|
4
|
src_user ?= $(USER)
|
5
|
test ?=
|
6
|
|
7
|
##### Vars/functions
|
8
|
|
9
|
# Make
|
10
|
pathParts = $(shell path="$(1)"; echo "$${path%%/*}" "$${path\#*/}")
|
11
|
topDir = $(word 1,$(pathParts))
|
12
|
subPath = $(word 2,$(pathParts))
|
13
|
subMake = $(MAKE) $(call subPath,$@) --directory=$(call topDir,$@) \
|
14
|
--makefile=../input.Makefile
|
15
|
# input.Makefile path is relative to subdir
|
16
|
|
17
|
# SVN
|
18
|
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
|
19
|
|
20
|
##### General targets
|
21
|
|
22
|
all:
|
23
|
|
24
|
.SUFFIXES: # turn off built-in suffix rules
|
25
|
.SECONDARY: # don't automatically delete intermediate files
|
26
|
.DELETE_ON_ERROR: # delete target if recipe fails
|
27
|
|
28
|
_always:
|
29
|
.PHONY: _always
|
30
|
|
31
|
##### SVN
|
32
|
|
33
|
# Adds a new datasource
|
34
|
# Must come before $(subdir)% to override it
|
35
|
%/add: _always
|
36
|
$(call addDir,$*)
|
37
|
$(subMake)
|
38
|
|
39
|
##### Input data
|
40
|
|
41
|
rsync = rsync$(if $(test), --dry-run) --archive --update --verbose\
|
42
|
--itemize-changes --progress --exclude=".*" $(1)\
|
43
|
$(src_user)@$(src_server):/home/bien/svn/inputs/ ./
|
44
|
|
45
|
download: _always
|
46
|
$(download)
|
47
|
download := $(call rsync,--include="/*/" --include="/*/src/"\
|
48
|
--include="/*/src/**" --exclude="**")
|
49
|
|
50
|
##### Subdir forwarding
|
51
|
|
52
|
subdirs := $(wildcard */)
|
53
|
|
54
|
define subdirTargets
|
55
|
$(subdir): _always
|
56
|
+$$(subMake)
|
57
|
|
58
|
$(subdir)%: _always
|
59
|
+$$(subMake)
|
60
|
.PRECIOUS: $(subdir)% # let subdir's Makefile decide whether to delete on error
|
61
|
endef
|
62
|
$(foreach subdir,$(subdirs),$(eval $(subdirTargets)))
|
63
|
|
64
|
Makefile: ;
|
65
|
|
66
|
%: $(addsuffix %,$(subdirs)) _always ;
|