Project

General

Profile

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