-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
147 lines (113 loc) · 4.35 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Makefile for the autorevision project
# `a2x / asciidoc` is required to generate the Man page.
# `markdown` is required for the `docs` target, though it is not
# strictly necessary for packaging since unless you are planning on
# serving the docs on a web site they are more readable not as html.
# `shipper` and `gpg` are required for the `release` target, which
# should only be used if you are shipping tarballs (you probably are
# not).
# Get the version number
VERS := $(shell ./autorevision.sh -s VCS_TAG -o ./autorevision.cache | sed -e 's:v/::')
# Date for documentation
DOCDATE := $(shell ./autorevision.sh -s VCS_DATE -o ./autorevision.cache -f | sed -e 's:T.*::')
# Find a md5 program
MD5 := $(shell if command -v "md5" > /dev/null 2>&1; then echo "md5 -q"; elif command -v "md5sum" > /dev/null 2>&1; then echo "md5sum"; fi)
# Find a sha256 program
SHA256 := $(shell if command -v "shasum" > /dev/null 2>&1; then echo "shasum -a 256"; elif command -v "openssl" > /dev/null 2>&1; then echo "openssl sha256"; fi)
.SUFFIXES: .md .html
.md.html:
markdown $< > $@
# `prefix`, `mandir` & `DESTDIR` can and should be set on the command line to control installation locations
prefix ?= /usr/local
mandir ?= /share/man
target = $(DESTDIR)$(prefix)
DOCS = \
NEWS \
autorevision.asciidoc \
README.md \
CONTRIBUTING.md \
COPYING.md
SOURCES = \
$(DOCS) \
autorevision.sh \
Makefile \
control
EXTRA_DIST = \
logo.svg.in \
contribs \
AUTHORS.txt \
autorevision.cache
TEXT_PRODUCTS = \
autorevision.1
all : cmd man logo.svg
# The script
cmd: autorevision
# Insert the version number
autorevision: autorevision.sh
sed -e 's:&&ARVERSION&&:$(VERS):g' autorevision.sh > autorevision
chmod +x autorevision
# The Man Page
man: autorevision.1.gz
autorevision.1.gz: autorevision.1
gzip --no-name < autorevision.1 > autorevision.1.gz
autorevision.1: autorevision.asciidoc
a2x --attribute="revdate=$(DOCDATE)" --attribute="revnumber=$(VERS)" -f manpage autorevision.asciidoc
# HTML representation of the man page
autorevision.html: autorevision.asciidoc
asciidoc --attribute="revdate=$(DOCDATE)" --attribute="footer-style=revdate" --attribute="revnumber=$(VERS)" --doctype=manpage --backend=xhtml11 autorevision.asciidoc
# Authors
auth: AUTHORS.txt
AUTHORS.txt: .mailmap autorevision.cache
git log --format='%aN <%aE>' | sort -f | uniq -c | sort -rn | sed 's:^ *[0-9]* *::' > AUTHORS.txt
autorevision.sed: autorevision.cache
./autorevision.sh -f -t sed -o $< > $@
logo.svg: logo.svg.in autorevision.sed
sed -f autorevision.sed $< > $@
# The tarball signed and sealed
dist: autorevision-$(VERS).tgz autorevision-$(VERS).tgz.md5 autorevision-$(VERS).tgz.sha256 autorevision-$(VERS).tgz.sig
# The tarball
tarball: autorevision-$(VERS).tgz
# Make an md5 checksum
autorevision-$(VERS).tgz.md5: autorevision-$(VERS).tgz
$(MD5) autorevision-$(VERS).tgz > autorevision-$(VERS).tgz.md5
# Make an sha256 checksum
: autorevision-$(VERS).tgz
$(SHA256) autorevision-$(VERS).tgz > autorevision-$(VERS).tgz.sha256
# Make a detached gpg sig
autorevision-$(VERS).tgz.sig: autorevision-$(VERS).tgz
gpg --armour --detach-sign --output "autorevision-$(VERS).tgz.sig" "autorevision-$(VERS).tgz"
# The actual tarball
autorevision-$(VERS).tgz: $(SOURCES) all auth
mkdir autorevision-$(VERS)
cp -pR $(SOURCES) $(EXTRA_DIST) $(TEXT_PRODUCTS) autorevision-$(VERS)/
@COPYFILE_DISABLE=1 GZIP=-n9 tar -czf autorevision-$(VERS).tgz --exclude=".DS_Store" autorevision-$(VERS)
rm -fr autorevision-$(VERS)
install: all
install -d "$(target)/bin"
install -m 755 autorevision "$(target)/bin/autorevision"
install -d "$(target)$(mandir)/man1"
install -m 644 autorevision.1.gz "$(target)$(mandir)/man1/autorevision.1.gz"
uninstall:
rm -f "$(target)/bin/autorevision" "$(target)$(mandir)/man1/autorevision.1.gz"
clean:
rm -f autorevision autorevision.html autorevision.1 autorevision.1.gz
rm -f autorevision.sed logo.svg
rm -f *.tgz *.md5 *.sig
rm -f docbook-xsl.css
rm -f CONTRIBUTING.html COPYING.html README.html
rm -f *~ index.html
# Not safe to run in a tarball
devclean: clean
rm -f autorevision.cache
rm -f AUTHORS AUTHORS.txt
rm -f *.orig ./*/*.orig
# HTML versions of doc files suitable for use on a website
docs: \
autorevision.html \
README.html \
CONTRIBUTING.html \
COPYING.html
# Tag with `git tag -s v/<number>` before running this.
release: docs dist
git tag -v "v/$(VERS)"
# shipper version=$(VERS) | sh -e -x