-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
91 lines (72 loc) · 2.05 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
project = contacts
srcdir = Sources/contacts-cli
mansubdir = man
binsubdir = bin
prefix ?= /usr/local
mandir ?= $(prefix)/share/$(mansubdir)/man1
mans = $(addprefix $(mansubdir)/,*.1)
srcfiles = $(addprefix $(srcdir)/,main.swift)
versionfiles = $(addprefix $(srcdir)/,version.json)
# distribution variables
VERSIONNUM:=$(shell test -d .git && git describe --abbrev=0 --tags)
BUILDNUM:=$(shell test -d .git && git rev-parse --short HEAD)
distdir = $(project)-$(VERSIONNUM)
# ronn/man variables
rdate = `date +'%Y-%m-%d'`
rmanual = contacts
rorg = protozoic
all: docs $(binsubdir)/contacts
docs: $(mans)
test:
echo $(VERSIONNUM)
echo ${prefix}
echo ${mandir}
version: $(versionfiles)
./version-update.sh $(srcdir)/version.json
# run xcodebuild if src has changed. Make bin/ if it doesn't exist.
$(binsubdir)/contacts: $(srcfiles) | $(binsubdir) version
./version-update.sh $(srcdir)/version.json
swift build -c release
mv .build/release/contacts bin/
# make bin/
$(binsubdir):
-mkdir -p $(binsubdir)
# make man/
$(mansubdir):
-mkdir -p $(mansubdir)
# copy man files to man/ - make man/ if it doesn't exist.
$(mansubdir)/%.1: $(srcdir)/%.1 | $(mansubdir)
cp $< $(mansubdir)/
# install files to their proper locations.
install: bin/contacts man
-mkdir -p $(prefix)
-mkdir -p $(prefix)/bin
-mkdir -p $(mandir)
install $(binsubdir)/* $(prefix)/bin/
install -m 644 $(mansubdir)/* $(mandir)
# make the man files from the ronn files if needed
$(srcdir)/%.1: $(srcdir)/%.1.ronn
ronn -r --date=$(rdate) --manual="$(rmanual)" --organization="$(rorg)" $(srcdir)/$*.1.ronn
# remove generated man files
cleanroff: cleanman
-rm $(srcdir)/*.1
# remove installed man files
cleanman:
-rm -rf $(mansubdir)
dist: all
-mkdir -p $(distdir)
git archive master | tar -x -C $(distdir)
tar czf $(distdir).tgz $(distdir)
rm -rf $(distdir)
distdev: all
-mkdir -p $(distdir)
git archive develop | tar -x -C $(distdir)
tar czf $(distdir).tgz $(distdir)
rm -rf $(distdir)
distclean: clean cleantgz
clean: cleanman
-rm -rf build
-rm -rf bin
-rm -f *~
cleantgz:
-rm -f $(distdir).tgz