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
addFile = $(if $(wildcard $(1)),,touch $(1) && )svn add $(1)
39
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
40
revision = $(shell svn info $(1)|$(sed) -n 's/^Last Changed Rev: (.*)$$/\1/p')
41
rootRevision = $(call revision,$(root))
42
version = $(date).r$(rootRevision)
43

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

    
52
##### General targets
53

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

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

    
60
_always:
61
.PHONY: _always
62

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