1 |
3697
|
aaronmk
|
##### Configuration
|
2 |
|
|
|
3 |
|
|
src_server ?= vegbiendev
|
4 |
|
|
src_user ?= $(USER)
|
5 |
|
|
test ?=
|
6 |
|
|
|
7 |
|
|
##### Vars/functions
|
8 |
|
|
|
9 |
|
|
# Make
|
10 |
3763
|
aaronmk
|
null :=
|
11 |
|
|
space := $(null) $(null)
|
12 |
3697
|
aaronmk
|
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 |
3763
|
aaronmk
|
# Formatting
|
20 |
5452
|
aaronmk
|
sed = sed -$(if $(filter Darwin,$(os)),E,r)
|
21 |
3763
|
aaronmk
|
_2Space = $(subst _,$(space),$(1))
|
22 |
|
|
*2Space = $(call _2Space,$*)
|
23 |
|
|
|
24 |
3792
|
aaronmk
|
# Filesystem
|
25 |
4136
|
aaronmk
|
wildcard/ = $(shell echo $(1)|grep -vF '*')# emulate `shopt -s nullglob`
|
26 |
|
|
# needed because builtin $(wildcard) doesn't do / suffix correctly
|
27 |
4602
|
aaronmk
|
no/ = $(1:/=)# remove trailing /
|
28 |
4603
|
aaronmk
|
+w = $(wildcard $+)# existing items in $+
|
29 |
3794
|
aaronmk
|
CP := cp -p
|
30 |
|
|
cp = $(CP) $< $@
|
31 |
3792
|
aaronmk
|
|
32 |
5451
|
aaronmk
|
# System
|
33 |
5458
|
aaronmk
|
os := $(shell uname)
|
34 |
|
|
forOs = $(patsubst %,%-$(filter Linux Darwin,$(os)),$(1))
|
35 |
5451
|
aaronmk
|
date = $(shell date +"%Y-%m-%d-%H-%M-%S")
|
36 |
|
|
|
37 |
5460
|
aaronmk
|
## SVN
|
38 |
|
|
|
39 |
4222
|
aaronmk
|
addFile = $(if $(wildcard $(1)),,touch $(1) && )svn add $(1)
|
40 |
3697
|
aaronmk
|
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
|
41 |
5460
|
aaronmk
|
|
42 |
|
|
# Revisions
|
43 |
5454
|
aaronmk
|
revision = $(shell svn info $(1)|$(sed) -n 's/^Last Changed Rev: (.*)$$/\1/p')
|
44 |
5455
|
aaronmk
|
rootRevision = $(call revision,$(root))
|
45 |
5460
|
aaronmk
|
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 |
3697
|
aaronmk
|
|
52 |
|
|
# rsync
|
53 |
5084
|
aaronmk
|
rsync* := "time" rsync$(if $(test), --dry-run) --archive --update --verbose\
|
54 |
|
|
--itemize-changes --progress
|
55 |
|
|
rsync := $(rsync*) --exclude=".*"
|
56 |
3697
|
aaronmk
|
local := ./
|
57 |
3700
|
aaronmk
|
localDirName := $(notdir $(realpath $(local)))
|
58 |
|
|
remote := $(src_user)@$(src_server):/home/bien/svn/$(localDirName)/
|
59 |
3697
|
aaronmk
|
|
60 |
|
|
##### General targets
|
61 |
|
|
|
62 |
3765
|
aaronmk
|
all: # must be first target in Makefile, so add an empty version here
|
63 |
3697
|
aaronmk
|
|
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 |
3765
|
aaronmk
|
|
71 |
|
|
clean: # make sure `make clean` always works
|