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 3584 aaronmk
# rsync
21
rsync := rsync$(if $(test), --dry-run) --archive --update --verbose\
22
--itemize-changes --progress --exclude=".*"
23
local := ./
24
remote := $(src_user)@$(src_server):/home/bien/svn/inputs/
25
26 785 aaronmk
##### General targets
27 410 aaronmk
28
all:
29
30 1260 aaronmk
.SUFFIXES: # turn off built-in suffix rules
31
.SECONDARY: # don't automatically delete intermediate files
32 1354 aaronmk
.DELETE_ON_ERROR: # delete target if recipe fails
33 410 aaronmk
34
_always:
35
.PHONY: _always
36
37 1591 aaronmk
##### SVN
38
39
# Adds a new datasource
40
# Must come before $(subdir)% to override it
41 1594 aaronmk
%/add: _always
42
	$(call addDir,$*)
43
	$(subMake)
44 1591 aaronmk
45 3375 aaronmk
##### Input data
46
47 3584 aaronmk
rsyncSrcs := $(rsync) --include="/*/" --include="/*/src/" --include="/*/src/**"\
48
--exclude="**"
49 3375 aaronmk
50 3584 aaronmk
upload: _always
51
	$(rsyncSrcs) $(local) $(remote)
52 3375 aaronmk
download: _always
53 3584 aaronmk
	$(rsyncSrcs) $(remote) $(local)
54 3375 aaronmk
55 1591 aaronmk
##### Subdir forwarding
56
57 623 aaronmk
subdirs := $(wildcard */)
58
59 410 aaronmk
define subdirTargets
60
$(subdir): _always
61
	+$$(subMake)
62
63
$(subdir)%: _always
64
	+$$(subMake)
65 1628 aaronmk
.PRECIOUS: $(subdir)% # let subdir's Makefile decide whether to delete on error
66 410 aaronmk
endef
67 623 aaronmk
$(foreach subdir,$(subdirs),$(eval $(subdirTargets)))
68 410 aaronmk
69 416 aaronmk
Makefile: ;
70
71 623 aaronmk
%: $(addsuffix %,$(subdirs)) _always ;