-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
174 lines (140 loc) · 3.8 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# ------------------------------------------------------------------------------
# The version number is automatically set to the current date,
# unless DATE is defined on the command line.
DATE := $(shell /bin/date +%Y%m%d)
# The project's name.
THIS := pprint
# The archive's URL (https).
ARCHIVE := https://github.com/fpottier/$(THIS)/archive/$(DATE).tar.gz
# ------------------------------------------------------------------------------
.PHONY: all
all:
@ dune build @all
.PHONY: clean
clean:
@ git clean -fdX
.PHONY: test
test:
@ dune exec test/PPrintTest.exe
.PHONY: bench
bench:
@ make -C benchmark_old $@
@ make -C benchmark_new $@
.PHONY: install
install:
@ dune clean
@ dune build -p $(THIS)
@ dune install -p $(THIS)
.PHONY: uninstall
uninstall:
@ ocamlfind remove $(THIS) || true
.PHONY: reinstall
reinstall: uninstall
@ make install
.PHONY: show
show: reinstall
@ echo "#require \"pprint\";;\n#show PPrint;;" | ocaml
.PHONY: pin
pin:
@ opam pin add $(THIS) . --yes
.PHONY: unpin
unpin:
@ opam pin remove $(THIS) --yes
# ------------------------------------------------------------------------------
# Documentation.
DOCDIR = _build/default/_doc/_html
DOC = $(DOCDIR)/index.html
.PHONY: doc
doc:
@ rm -rf _build/default/_doc
@ dune clean
@ dune build @doc
@ echo "You can view the documentation by typing 'make view'".
.PHONY: view
view: doc
@ echo Attempting to open $(DOC)...
@ if command -v firefox > /dev/null ; then \
firefox $(DOC) ; \
else \
open -a /Applications/Firefox.app/ $(DOC) ; \
fi
.PHONY: export
export: doc
ssh yquem.inria.fr rm -rf public_html/$(THIS)/doc
scp -r $(DOCDIR) yquem.inria.fr:public_html/$(THIS)/doc
# ------------------------------------------------------------------------------
# [make versions] compiles the package under many versions of OCaml,
# whose list is specified below.
# This requires appropriate opam switches to exist. A missing switch
# can be created like this:
# opam switch create 4.03.0
VERSIONS := \
4.03.0 \
4.04.2 \
4.05.0 \
4.06.1 \
4.07.1 \
4.08.1 \
4.09.1 \
4.09.0+bytecode-only \
4.10.0 \
4.11.1 \
4.12.0 \
4.13.0 \
4.14.1 \
5.0.0 \
5.1.0 \
5.2.0 \
.PHONY: versions
versions:
@(echo "(lang dune 2.0)" && \
for v in $(VERSIONS) ; do \
echo "(context (opam (switch $$v)))" ; \
done) > dune-workspace.versions
@ dune build --workspace dune-workspace.versions
# ------------------------------------------------------------------------------
# [make headache] updates the headers.
HEADACHE := headache
HEADER := header
.PHONY: headache
headache:
@ for f in {src,benchmark_old}/*.{ml,mli} benchmark_new/*.ml ; do \
$(HEADACHE) -h $(HEADER) $$f ; \
done
# -------------------------------------------------------------------------
# Publishing a release.
.PHONY: release
release:
# Make sure the current version can be compiled and installed.
@ make uninstall
@ make clean
@ make install
# Check the current package description.
@ opam lint
# Check if everything has been committed.
@ if [ -n "$$(git status --porcelain)" ] ; then \
echo "Error: there remain uncommitted changes." ; \
git status ; \
exit 1 ; \
else \
echo "Now making a release..." ; \
fi
# Create a git tag.
@ git tag -a $(DATE) -m "Release $(DATE)."
# Upload. (This automatically makes a .tar.gz archive available on gitlab.)
@ git push
@ git push --tags
# Done.
@ echo "Done."
@ echo "If happy, please type:"
@ echo " \"make publish\" to publish a new opam package"
@ echo " \"make export\" to upload the documentation to yquem.inria.fr"
.PHONY: publish
publish:
# Publish an opam description.
@ opam publish -v $(DATE) $(THIS) $(ARCHIVE) .
.PHONY: undo
undo:
# Undo the last release (assuming it was done on the same date).
@ git tag -d $(DATE)
@ git push -u origin :$(DATE)