-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.maintainer
125 lines (99 loc) · 4.42 KB
/
Makefile.maintainer
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
include sanity.mk
# Recipies for developing, packing up, and distributing the instrument
# source library. It's super simple so the package benefits from having
# only the sources, not the related article or maintainer stuff.
# Allow use of bashisms.
SHELL = /bin/bash
# In certain situations (e.g. foreach in a define block or recipe, eval,
# when we want newlines in Make error or warning function output) we want
# to write newlines that are seen by make itself. This can be done by
# including a literal newline, but that breaks the line and is confusing
# as hell if you don't already know whats going on, so we define a varialbe
# to keep all the craziness in one place.
define nl
endef
SOURCES = $(wildcard *.h *.c)
AUTOGENED_ADOCS = $(patsubst %,%.adoc,$(wildcard *.h *.c))
HTML_FILES = \
$(patsubst \
%.adoc, \
%.html, \
$(filter-out $(AUTOGENED_ADOCS),$(wildcard *.adoc)) $(AUTOGENED_ADOCS))
# The only annoying thing with this is it pulls the browser window onto the
# current desktop. But it can just be moved back, then updates itself when
# more changes are done. FIXXME: grip --export would just produce HTML and
# let us do the viewing our own way...
.PHONY: view_readme_locally
view_readme_locally:
( \
(grip -b &>>/tmp/grip_log) \
|| \
(echo grip failed, maybe a running copy needs to be killed? 1>&2) \
) \
&
define AUTOGENED_ADOC_TEMPLATE
// WARNING -- AUTOMATICALLY GENERATED FROM $< -- DO NOT EDIT
= $<
:nofooter: // Prevent obnoxious "last modified" thing by not having footer
:source-highlighter: pygments
[source, C]
----
include::$<[]
----
endef
$(AUTOGENED_ADOCS): %.adoc: % Makefile.maintainer
echo -e '$(subst $(nl),\n,$(AUTOGENED_ADOC_TEMPLATE))' >$@
$(HTML_FILES): %.html: %.adoc asciidoc.css Makefile.maintainer
gem which pygments # Die if the syntax highlighter isn't installed
asciidoctor -a stylesheet=asciidoc.css $<
# Here's how to not use a style sheet:
#asciidoctor -a stylesheet! $<
all_html_files.stamp: $(HTML_FILES)
touch $@
.PHONY: view_document_root
view_document_root: all_html_files.stamp
$(WEB_BROWSER) ditch_your_debugger.html
GIT_DESCRIPTION = `git describe --dirty --tags --always`
# Files to be shipped in the release tarball (i.e. non-maintainer-only files)
PACKING_LIST = Makefile $(SOURCES)
.PHONY: tarball
tarball: $(PACKING_LIST)
# Requre VERSION variable to be set
[ -n "$(VERSION)" ] || (echo VERSION not set 1>&2 && false)
# Requre the git repo to be clean
echo $(GIT_DESCRIPTION) | grep -v -e '-dirty'
# Requre the git repo to be tagged with specified version
[ "$(GIT_DESCRIPTION)" = "version_$(VERSION)" ]
mkdir instrument-$(VERSION)
cp $(PACKING_LIST) instrument-$(VERSION)
tar czvf instrument-$(VERSION).tar.gz instrument-$(VERSION)/
rm -rf instrument-$(VERSION)
# Web Host to upload to
WHOST = [email protected]
# web Dir (on $(WHOST)) to upload to
WDIR = public_html/instrument
.PHONY: upload_tarball
upload_tarball: RELEASES_DIR = $(WDIR)/releases/
upload_tarball: RELEASES_SCP_TARGET = $(WHOST):$(RELEASES_DIR)
upload_tarball: RELEASE_FILE = instrument-$(VERSION).tar.gz
upload_tarball: RELEASE_PATH = $(RELEASES_DIR)/$(RELEASE_FILE)
upload_tarball: LATEST_LINK_PATH = $(RELEASES_DIR)/LATEST_IS_$(RELEASE_FILE)
upload_tarball: tarball upload_html
# scp give a confusing warning if target dir !exist, so check first
ssh $(WHOST) test -d $(RELEASES_DIR)
scp instrument-$(VERSION).tar.gz $(RELEASES_SCP_TARGET)
ssh $(WHOST) rm -f '$(RELEASES_DIR)/LATEST_IS_*'
ssh $(WHOST) ln -s $(RELEASE_FILE) $(LATEST_LINK_PATH)
# NOTE: we aren't religious about making sure the uploaded HTML corresponds
# to any particular git-tagged release.
.PHONY: upload_html
upload_html: HTML_SCP_DIR = $(WHOST):$(WDIR)/
upload_html: $(HTML_FILES)
ssh $(WHOST) rm -rf $(WDIR)/*.html
scp $+ $(HTML_SCP_DIR)
.PHONY: upload
upload: upload_tarball upload_html
.PHONY: clean
clean:
$(MAKE) clean
rm -f *.tar.gz all_html_files.stamp $(HTML_FILES) $(AUTOGENED_ADOCS)