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

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

    
47
##### General targets
48

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

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

    
55
_always:
56
.PHONY: _always
57

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