Project

General

Profile

1
##### Configuration
2

    
3
src_server ?= vegbiendev
4
src_user ?= $(USER)
5
test ?=
6

    
7
##### Vars/functions
8

    
9
# Make
10
null :=
11
space := $(null) $(null)
12
comma := ,
13
pathParts = $(shell path="$(1)"; echo "$${path%%/*}" "$${path\#*/}")
14
topDir = $(word 1,$(pathParts))
15
subPath = $(word 2,$(pathParts))
16
subMake = $(MAKE) $(call subPath,$@) --directory=$(call topDir,$@) \
17
--makefile=../input.Makefile
18
# input.Makefile path is relative to subdir
19

    
20
# Formatting
21
sed = sed -$(if $(filter Darwin,$(os)),E,r)
22
_2Space = $(subst _,$(space),$(1))
23
*2Space = $(call _2Space,$*)
24

    
25
# Filesystem
26
wildcard/ = $(shell bash -c 'shopt -s nullglob; echo $(1)')
27
    # needed because builtin $(wildcard) doesn't do / suffix correctly
28
no/ = $(1:/=)# remove trailing /
29
+w = $(wildcard $+)# existing items in $+
30
CP := cp -p
31
cp = $(CP) $< $@
32

    
33
# System
34
os := $(shell uname)
35
forOs = $(patsubst %,%-$(filter Linux Darwin,$(os)),$(1))
36
date = $(shell date +"%Y-%m-%d-%H-%M-%S")
37

    
38
## SVN
39

    
40
addFile = $(if $(wildcard $(1)),,touch $(1) && )svn add $(1)
41
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
42
add* = $(if $(1),svn add --depth=empty $(1))
43

    
44
# Revisions
45
revision = $(shell svn info $(1)|$(sed) -n 's/^Last Changed Rev: (.*)$$/\1/p')
46
rootRevision = $(call revision,$(root))
47
initRootRevision := $(if $(root),$(rootRevision))
48
rootRevisionsEqual := $(filter $(rootRevision),$(initRootRevision))
49
rootRevisions = $(foreach rootRevision,$(rootRevision),$(if\
50
$(rootRevisionsEqual),$(initRootRevision),$(initRootRevision)-$(rootRevision)))
51
    # only evaluate $(rootRevision) once
52
version = $(date).r$(rootRevisions)
53

    
54
# rsync
55
rsync* := "time" rsync$(if $(test), --dry-run) --archive --update --verbose\
56
--itemize-changes --progress
57
rsync := $(rsync*) --exclude=".svn/" --exclude="*\#" --exclude=".DS_Store"
58
local := ./
59
localDirName := $(notdir $(realpath $(local)))
60
remote := $(src_user)@$(src_server):/home/bien/svn/$(localDirName)/
61

    
62
##### General targets
63

    
64
all: # must be first target in Makefile, so add an empty version here
65

    
66
.SUFFIXES: # turn off built-in suffix rules
67
.SECONDARY: # don't automatically delete intermediate files
68
.DELETE_ON_ERROR: # delete target if recipe fails
69

    
70
_always:
71
.PHONY: _always
72

    
73
clean: # make sure `make clean` always works
(9-9/47)