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
pathParts = $(shell path="$(1)"; echo "$${path%%/*}" "$${path\#*/}")
13
topDir = $(word 1,$(pathParts))
14
subPath = $(word 2,$(pathParts))
15
subMake = $(MAKE) $(call subPath,$@) --directory=$(call topDir,$@) \
16
--makefile=../input.Makefile
17
# input.Makefile path is relative to subdir
18

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

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

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

    
37
## SVN
38

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

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

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

    
60
##### General targets
61

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

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

    
68
_always:
69
.PHONY: _always
70

    
71
clean: # make sure `make clean` always works
(7-7/42)