Project

General

Profile

1 3375 aaronmk
##### Configuration
2
3
src_server ?= vegbiendev
4
src_user ?= $(USER)
5
test ?=
6
7 785 aaronmk
##### Vars/functions
8
9 410 aaronmk
# Make
10 625 aaronmk
pathParts = $(shell path="$(1)"; echo "$${path%%/*}" "$${path\#*/}")
11 874 aaronmk
topDir = $(word 1,$(pathParts))
12
subPath = $(word 2,$(pathParts))
13 625 aaronmk
subMake = $(MAKE) $(call subPath,$@) --directory=$(call topDir,$@) \
14
--makefile=../input.Makefile
15 623 aaronmk
# input.Makefile path is relative to subdir
16 410 aaronmk
17 1590 aaronmk
# SVN
18 1594 aaronmk
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
19 1590 aaronmk
20 785 aaronmk
##### General targets
21 410 aaronmk
22
all:
23
24 1260 aaronmk
.SUFFIXES: # turn off built-in suffix rules
25
.SECONDARY: # don't automatically delete intermediate files
26 1354 aaronmk
.DELETE_ON_ERROR: # delete target if recipe fails
27 410 aaronmk
28
_always:
29
.PHONY: _always
30
31 1591 aaronmk
##### SVN
32
33
# Adds a new datasource
34
# Must come before $(subdir)% to override it
35 1594 aaronmk
%/add: _always
36
	$(call addDir,$*)
37
	$(subMake)
38 1591 aaronmk
39 3375 aaronmk
##### 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 1591 aaronmk
##### Subdir forwarding
51
52 623 aaronmk
subdirs := $(wildcard */)
53
54 410 aaronmk
define subdirTargets
55
$(subdir): _always
56
	+$$(subMake)
57
58
$(subdir)%: _always
59
	+$$(subMake)
60 1628 aaronmk
.PRECIOUS: $(subdir)% # let subdir's Makefile decide whether to delete on error
61 410 aaronmk
endef
62 623 aaronmk
$(foreach subdir,$(subdirs),$(eval $(subdirTargets)))
63 410 aaronmk
64 416 aaronmk
Makefile: ;
65
66 623 aaronmk
%: $(addsuffix %,$(subdirs)) _always ;