Debian Codegraph @

Makefile

raw
1 # ------------------------------------------------------------------------------
2
3 # The version number is automatically set to the current date,
4 # unless DATE is defined on the command line.
5 DATE := $(shell /bin/date +%Y%m%d)
6
7 # The project's name.
8 THIS := pprint
9
10 # The archive's URL (https).
11 ARCHIVE := https://github.com/fpottier/$(THIS)/archive/$(DATE).tar.gz
12
13 # ------------------------------------------------------------------------------
14
15 .PHONY: all
16 all:
17 @ dune build @all
18
19 .PHONY: clean
20 clean:
21 @ git clean -fdX
22
23 .PHONY: test
24 test:
25 @ dune exec test/PPrintTest.exe
26
27 .PHONY: bench
28 bench:
29 @ make -C benchmark_old $@
30 @ make -C benchmark_new $@
31
32 .PHONY: install
33 install: all
34 @ dune install -p $(THIS)
35
36 .PHONY: uninstall
37 uninstall:
38 @ ocamlfind remove $(THIS) || true
39
40 .PHONY: reinstall
41 reinstall: uninstall
42 @ make install
43
44 .PHONY: show
45 show: reinstall
46 @ echo "#require \"pprint\";;\n#show PPrint;;" | ocaml
47
48 .PHONY: pin
49 pin:
50 @ opam pin add $(THIS) . --yes
51
52 .PHONY: unpin
53 unpin:
54 @ opam pin remove $(THIS) --yes
55
56 # ------------------------------------------------------------------------------
57
58 # Documentation.
59
60 DOCDIR = _build/default/_doc/_html
61 DOC = $(DOCDIR)/index.html
62
63 .PHONY: doc
64 doc:
65 @ rm -rf _build/default/_doc
66 @ dune clean
67 @ dune build @doc
68 @ echo "You can view the documentation by typing 'make view'".
69
70 .PHONY: view
71 view: doc
72 @ echo Attempting to open $(DOC)...
73 @ if command -v firefox > /dev/null ; then \
74 firefox $(DOC) ; \
75 else \
76 open -a /Applications/Firefox.app/ $(DOC) ; \
77 fi
78
79 .PHONY: export
80 export: doc
81 ssh yquem.inria.fr rm -rf public_html/$(THIS)/doc
82 scp -r $(DOCDIR) yquem.inria.fr:public_html/$(THIS)/doc
83
84 # ------------------------------------------------------------------------------
85
86 # [make versions] compiles the package under many versions of OCaml,
87 # whose list is specified below.
88
89 # This requires appropriate opam switches to exist. A missing switch
90 # can be created like this:
91 # opam switch create 4.03.0
92
93 VERSIONS := \
94 4.03.0 \
95 4.04.2 \
96 4.05.0 \
97 4.06.1 \
98 4.07.1 \
99 4.08.1 \
100 4.09.1 \
101 4.09.0+bytecode-only \
102 4.10.0 \
103 4.11.1 \
104 4.12.0 \
105 4.13.0 \
106 4.14.1 \
107 5.0.0 \
108
109 .PHONY: versions
110 versions:
111 @(echo "(lang dune 2.0)" && \
112 for v in $(VERSIONS) ; do \
113 echo "(context (opam (switch $$v)))" ; \
114 done) > dune-workspace.versions
115 @ dune build --workspace dune-workspace.versions
116
117 # ------------------------------------------------------------------------------
118
119 # [make headache] updates the headers.
120
121 HEADACHE := headache
122 HEADER := header
123
124 .PHONY: headache
125 headache:
126 @ for f in {src,benchmark_old}/*.{ml,mli} benchmark_new/*.ml ; do \
127 $(HEADACHE) -h $(HEADER) $$f ; \
128 done
129
130 # -------------------------------------------------------------------------
131
132 # Publishing a release.
133
134 .PHONY: release
135 release:
136 # Make sure the current version can be compiled and installed.
137 @ make uninstall
138 @ make clean
139 @ make install
140 # Check the current package description.
141 @ opam lint
142 # Check if everything has been committed.
143 @ if [ -n "$$(git status --porcelain)" ] ; then \
144 echo "Error: there remain uncommitted changes." ; \
145 git status ; \
146 exit 1 ; \
147 else \
148 echo "Now making a release..." ; \
149 fi
150 # Create a git tag.
151 @ git tag -a $(DATE) -m "Release $(DATE)."
152 # Upload. (This automatically makes a .tar.gz archive available on gitlab.)
153 @ git push
154 @ git push --tags
155 # Done.
156 @ echo "Done."
157 @ echo "If happy, please type:"
158 @ echo " \"make publish\" to publish a new opam package"
159 @ echo " \"make export\" to upload the documentation to yquem.inria.fr"
160
161 .PHONY: publish
162 publish:
163 # Publish an opam description.
164 @ opam publish -v $(DATE) $(THIS) $(ARCHIVE) .
165
166 .PHONY: undo
167 undo:
168 # Undo the last release (assuming it was done on the same date).
169 @ git tag -d $(DATE)
170 @ git push -u origin :$(DATE)
171
172 # -------------------------------------------------------------------------
173
174 # Copying pprint into Menhir's working directory.
175
176 MENHIR_WORKING_COPY=$(HOME)/dev/menhir
177 PPRINT_COPY=$(MENHIR_WORKING_COPY)/pprint
178
179 UNNECESSARY= \
180 .git \
181 .gitignore \
182 Makefile \
183 README.md \
184 TODO.md \
185 benchmark_old \
186 benchmark_new \
187 blog \
188 header \
189 test \
190 src/Makefile \
191
192 .PHONY: menhir
193 menhir: clean
194 # Copy our source files to the Menhir repository.
195 @ rm -rf $(PPRINT_COPY)
196 @ cp -r $(shell pwd) $(PPRINT_COPY)
197 # Remove a number of unneeded files and subdirectories.
198 @ (cd $(PPRINT_COPY) && rm -rf $(UNNECESSARY))