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 echo $(1)|grep -vF '*')# emulate `shopt -s nullglob`
|
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
|
|
43
|
# Revisions
|
44
|
revision = $(shell svn info $(1)|$(sed) -n 's/^Last Changed Rev: (.*)$$/\1/p')
|
45
|
rootRevision = $(call revision,$(root))
|
46
|
initRootRevision := $(if $(root),$(rootRevision))
|
47
|
rootRevisionsEqual := $(filter $(rootRevision),$(initRootRevision))
|
48
|
rootRevisions = $(foreach rootRevision,$(rootRevision),$(if\
|
49
|
$(rootRevisionsEqual),$(initRootRevision),$(initRootRevision)-$(rootRevision)))
|
50
|
# only evaluate $(rootRevision) once
|
51
|
version = $(date).r$(rootRevisions)
|
52
|
|
53
|
# rsync
|
54
|
rsync* := "time" rsync$(if $(test), --dry-run) --archive --update --verbose\
|
55
|
--itemize-changes --progress
|
56
|
rsync := $(rsync*) --exclude=".*"
|
57
|
local := ./
|
58
|
localDirName := $(notdir $(realpath $(local)))
|
59
|
remote := $(src_user)@$(src_server):/home/bien/svn/$(localDirName)/
|
60
|
|
61
|
##### General targets
|
62
|
|
63
|
all: # must be first target in Makefile, so add an empty version here
|
64
|
|
65
|
.SUFFIXES: # turn off built-in suffix rules
|
66
|
.SECONDARY: # don't automatically delete intermediate files
|
67
|
.DELETE_ON_ERROR: # delete target if recipe fails
|
68
|
|
69
|
_always:
|
70
|
.PHONY: _always
|
71
|
|
72
|
clean: # make sure `make clean` always works
|