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
date = $(shell date +"%Y-%m-%d-%H-%M-%S")
34

    
35
# SVN
36
addFile = $(if $(wildcard $(1)),,touch $(1) && )svn add $(1)
37
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
38
revision = $(shell svn info $(1)|$(sed) -n 's/^Last Changed Rev: (.*)$$/\1/p')
39
rootRevision = $(call revision,$(root))
40
version = $(date).r$(rootRevision)
41

    
42
# rsync
43
rsync* := "time" rsync$(if $(test), --dry-run) --archive --update --verbose\
44
--itemize-changes --progress
45
rsync := $(rsync*) --exclude=".*"
46
local := ./
47
localDirName := $(notdir $(realpath $(local)))
48
remote := $(src_user)@$(src_server):/home/bien/svn/$(localDirName)/
49

    
50
##### General targets
51

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

    
54
.SUFFIXES: # turn off built-in suffix rules
55
.SECONDARY: # don't automatically delete intermediate files
56
.DELETE_ON_ERROR: # delete target if recipe fails
57

    
58
_always:
59
.PHONY: _always
60

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