Project

General

Profile

« Previous | Next » 

Revision 6915

Makefiles: Factored out common vars/functions into lib/common.Makefile

View differences:

inputs/input.Makefile
34 34

  
35 35
# Terminal
36 36
termCols := $(shell tput cols)
37
esc := '['
38
reset := $(esc)'0m'
39
emph := $(esc)'7m '
40
endEmph := ' '$(reset)
41 37

  
42
# User interaction
43

  
44
confirm = $(if $(shell read -p $(emph)"$(1)"$(endEmph)$$'$(if\
45
$(2),\n$(2))\nContinue? (y/n) ' REPLY; test "$$REPLY" = y && echo t),,\
46
$(error Aborting))
47

  
48 38
# Commands
49 39
MKDIR = mkdir -p
50 40
mkdir = $(MKDIR) $(@D)
51
CP = cp -p
52 41
diff = diff --unified=2
53 42
diffIgnoreSpace = $(diff) --ignore-space-change
54 43
diffVerbose = $(if $(verbose),diff --side-by-side --left-column\
......
63 52
inDatasrc := echo 'SET search_path TO "$(datasrc)";'
64 53

  
65 54
# SVN
66
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
67 55
setSvnIgnore = svn propset svn:ignore $(2) $(1)
68 56
define addDirWithIgnore
69 57
$(addDir)
backups/Makefile
14 14
SHELL := /bin/bash
15 15

  
16 16
# OS
17
os := $(shell uname)
18 17
isMac := $(filter Darwin,$(os))
19 18

  
20 19
# System
......
22 21
mtime = $(shell $(if $(isMac),stat -f %Sm -t "$(dateFmt)" $(1),date\
23 22
--reference=$(1) +"$(dateFmt)"))
24 23

  
25
# Terminal
26
esc := '['
27
reset := $(esc)'0m'
28
emph := $(esc)'7m '
29
endEmph := ' '$(reset)
30

  
31
# User interaction
32

  
33
confirm = $(if $(shell read -p $(emph)"$(1)"$(endEmph)$$'$(if\
34
$(2),\n$(2))\nContinue? (y/n) ' REPLY; test "$$REPLY" = y && echo t),,\
35
$(error Aborting))
36

  
37 24
# Paths
38 25
bin := $(root)/bin
39 26

  
lib/common.Makefile
30 30
CP := cp -p
31 31
cp = $(CP) $< $@
32 32

  
33
# File editing
34
sudoAppend = echo $$'$(2)'|sudo tee -a $(1) >/dev/null
35

  
33 36
# System
34 37
os := $(shell uname)
35 38
forOs = $(patsubst %,%-$(filter Linux Darwin,$(os)),$(1))
36 39
date = $(shell date +"%Y-%m-%d-%H-%M-%S")
37 40

  
41
# Terminal
42
esc := '['
43
reset := $(esc)'0m'
44
emph := $(esc)'7m '
45
endEmph := ' '$(reset)
46

  
47
# User interaction
48

  
49
done = echo; echo $(emph)"Finished $@"$(endEmph); echo
50

  
51
wait := read -p $(emph)'Press ENTER to continue:'$(endEmph) REPLY
52

  
53
confirm = $(if $(shell read -p $(emph)"$(1)"$(endEmph)$$'$(if\
54
$(2),\n$(2))\nContinue? (y/n) ' REPLY; test "$$REPLY" = y && echo t),,\
55
$(error Aborting))
56

  
38 57
## SVN
39 58

  
40 59
addFile = $(if $(wildcard $(1)),,touch $(1) && )svn add $(1)
......
59 78
localDirName := $(notdir $(realpath $(local)))
60 79
remote := $(src_user)@$(src_server):/home/bien/svn/$(localDirName)/
61 80

  
81
# DB
82
mkSchemaCmd = 'CREATE SCHEMA $(1);'
83
rmSchemaCmd = 'DROP SCHEMA IF EXISTS "$(1)" CASCADE;'
84

  
62 85
##### General targets
63 86

  
64 87
all: # must be first target in Makefile, so add an empty version here
Makefile
11 11
# Paths
12 12
bin := bin
13 13

  
14
# Terminal
15
esc := '['
16
reset := $(esc)'0m'
17
emph := $(esc)'7m '
18
endEmph := ' '$(reset)
19

  
20
# User interaction
21

  
22
done = echo; echo $(emph)"Finished $@"$(endEmph); echo
23

  
24
wait := read -p $(emph)'Press ENTER to continue:'$(endEmph) REPLY
25

  
26
confirm = $(if $(shell read -p $(emph)"$(1)"$(endEmph)$$'$(if\
27
$(2),\n$(2))\nContinue? (y/n) ' REPLY; test "$$REPLY" = y && echo t),,\
28
$(error Aborting))
29

  
30
# File editing
31
sudoAppend = echo $$'$(2)'|sudo tee -a $(1) >/dev/null
32

  
33
# DB
34
mkSchemaCmd = 'CREATE SCHEMA $(1);'
35
rmSchemaCmd = 'DROP SCHEMA IF EXISTS "$(1)" CASCADE;'
36

  
37 14
##### Environment
38 15

  
39 16
export PGOPTIONS = --client-min-messages=WARNING

Also available in: Unified diff