Project

General

Profile

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
# 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
##### General targets
27

    
28
all:
29

    
30
.SUFFIXES: # turn off built-in suffix rules
31
.SECONDARY: # don't automatically delete intermediate files
32
.DELETE_ON_ERROR: # delete target if recipe fails
33

    
34
_always:
35
.PHONY: _always
36

    
37
##### SVN
38

    
39
# Adds a new datasource
40
# Must come before $(subdir)% to override it
41
%/add: _always
42
	$(call addDir,$*)
43
	$(subMake)
44

    
45
##### Input data
46

    
47
rsyncSrcs := $(rsync) --include="/*/" --include="/*/src/" --include="/*/src/**"\
48
--exclude="**"
49

    
50
upload: _always
51
	$(rsyncSrcs) $(local) $(remote)
52
download: _always
53
	$(rsyncSrcs) $(remote) $(local)
54

    
55
##### Subdir forwarding
56

    
57
subdirs := $(wildcard */)
58

    
59
define subdirTargets
60
$(subdir): _always
61
	+$$(subMake)
62

    
63
$(subdir)%: _always
64
	+$$(subMake)
65
.PRECIOUS: $(subdir)% # let subdir's Makefile decide whether to delete on error
66
endef
67
$(foreach subdir,$(subdirs),$(eval $(subdirTargets)))
68

    
69
Makefile: ;
70

    
71
%: $(addsuffix %,$(subdirs)) _always ;
(2-2/4)