]> Git — Sourcephile - comptalang.git/blob - GNUmakefile
Ajout : Calculus.Lambda.Omega.Explicit.
[comptalang.git] / GNUmakefile
1 all: install
2 .PHONY: .
3 .SECONDARY:
4 .SUFFIXES:
5 MAKEFLAGS += -r
6 .SHELLFLAGS += -e
7
8 #
9 ## environment
10 ###
11 CABAL_SANDBOX:=.cabal-sandbox
12 GHC_PKG:=ghc-pkg
13 GHC_PROF_CATEGORIES:=hc hm hd hy hr hb
14 GHC_PROF_CPUS:=
15 GHC_PROF_PS_WIDTH:=11in
16 GHC_PROF_RATE:=0.1
17 GHC_PROF_CC_LENGTH:=50
18 HCOMPTA_CLI_PROF:=$(CABAL_SANDBOX)/bin/hcompta-prof
19 HCOMPTA_COMMANDS:=balance gl journal
20 HCOMPTA_PACKAGES:=lib jcc ledger cli web
21 HCOMPTA_IN_FORMATS:=jcc ledger
22 commit:=$(shell if which git >/dev/null; then git describe --long; else echo COMMIT; fi)
23
24 #
25 ## helpers
26 ###
27 if_arg=$(if $2,$1 $2)
28 rmw=$(call if_arg,rm,$(wildcard $1))
29 rmdirw=$(call if_arg,rmdir -p --ignore-fail-on-non-empty,$(wildcard $1))
30
31 #
32 ## install
33 ###
34 install: cabal/install $(HCOMPTA_PACKAGES:=/install)
35 cabal/install:
36 cabal $(CABAL_FLAGS) update $(CABAL_UPDATE_FLAGS)
37 cabal $(CABAL_FLAGS) install -v $(CABAL_INSTALL_FLAGS) cabal
38 .PHONY: $(HCOMPTA_PACKAGES)
39 lib lib/install: \
40 cli/unregister \
41 web/unregister \
42 ledger/unregister \
43 jcc/unregister \
44 cli/unregister/sandbox \
45 web/unregister/sandbox \
46 ledger/unregister/sandbox \
47 jcc/unregister/sandbox
48 cabal $(CABAL_FLAGS) install -v $(CABAL_INSTALL_FLAGS) ./lib
49 jcc jcc/install: \
50 cli/unregister \
51 web/unregister \
52 cli/unregister/sandbox \
53 web/unregister/sandbox
54 cabal $(CABAL_FLAGS) install -v $(CABAL_INSTALL_FLAGS) ./jcc
55 ledger ledger/install: \
56 cli/unregister \
57 web/unregister \
58 cli/unregister/sandbox \
59 web/unregister/sandbox
60 cabal $(CABAL_FLAGS) install -v $(CABAL_INSTALL_FLAGS) ./ledger
61 cli cli/install:
62 cabal $(CABAL_FLAGS) install -v $(CABAL_INSTALL_FLAGS) ./cli
63 web web/install:
64 cabal $(CABAL_FLAGS) install -v $(CABAL_INSTALL_FLAGS) alex happy
65 cabal $(CABAL_FLAGS) install -v $(CABAL_INSTALL_FLAGS) ./web
66
67 %/recomp: CABAL_INSTALL_FLAGS+=--ghc-options -fforce-recomp
68 %/recomp: %
69
70
71 #
72 ## clean
73 ###
74 clean: lib/clean $(HCOMPTA_PACKAGES:=/clean)
75 lib/clean:
76 (cd lib && cabal clean)
77 jcc/clean:
78 (cd jcc && cabal clean)
79 ledger/clean:
80 (cd ledger && cabal clean)
81 cli/clean:
82 (cd cli && cabal clean)
83 web/clean:
84 (cd web && cabal clean)
85
86 #
87 ## test
88 ###
89 test: $(HCOMPTA_PACKAGES:=/test)
90 lib/test:
91 (cd lib && cabal $(CABAL_FLAGS) test --show-details=always $(CABAL_TEST_FLAGS))
92 jcc/test:
93 (cd jcc && cabal $(CABAL_FLAGS) test --show-details=always $(CABAL_TEST_FLAGS))
94 ledger/test:
95 (cd ledger && cabal $(CABAL_FLAGS) test --show-details=always $(CABAL_TEST_FLAGS))
96 cli/test:
97 (cd cli && cabal $(CABAL_FLAGS) test --show-details=always $(CABAL_TEST_FLAGS))
98 web/test:
99 (cd web && cabal $(CABAL_FLAGS) test --show-details=always $(CABAL_TEST_FLAGS))
100 %/install/test: CABAL_INSTALL_FLAGS+=--enable-tests
101 %/install/test: %/install
102
103
104 #
105 ## doc
106 ###
107 .PHONY: doc
108 doc: doc/xhtml $(HCOMPTA_PACKAGES:=/doc)
109
110 lib/doc:
111 (cd lib && \
112 cabal $(CABAL_FLAGS) configure $(CABAL_CONFIGURE_FLAGS) && \
113 cabal $(CABAL_FLAGS) haddock --hyperlink-source $(CABAL_HADDOCK_FLAGS))
114 jcc/doc:
115 (cd jcc && \
116 cabal $(CABAL_FLAGS) configure $(CABAL_CONFIGURE_FLAGS) && \
117 cabal $(CABAL_FLAGS) haddock --hyperlink-source $(CABAL_HADDOCK_FLAGS))
118 ledger/doc:
119 (cd ledger && \
120 cabal $(CABAL_FLAGS) configure $(CABAL_CONFIGURE_FLAGS) && \
121 cabal $(CABAL_FLAGS) haddock --hyperlink-source $(CABAL_HADDOCK_FLAGS))
122 cli/doc:
123 (cd cli && \
124 cabal $(CABAL_FLAGS) configure $(CABAL_CONFIGURE_FLAGS) && \
125 cabal $(CABAL_FLAGS) haddock --hyperlink-source $(CABAL_HADDOCK_FLAGS))
126 web/doc:
127 (cd web && \
128 cabal $(CABAL_FLAGS) configure $(CABAL_CONFIGURE_FLAGS) && \
129 cabal $(CABAL_FLAGS) haddock --hyperlink-source $(CABAL_HADDOCK_FLAGS))
130 doc/%: .
131 $(MAKE) -C doc $*
132
133 #
134 ## dev
135 ###
136 %/dev: CABAL_INSTALL_FLAGS+=-fdev
137 %/dev: %
138
139
140 #
141 ## dump
142 ###
143 %/dump: CABAL_INSTALL_FLAGS+=-fdump
144 %/dump: %
145
146
147 #
148 ## hlint
149 ###
150 hlint: $(HCOMPTA_PACKAGES:=/hlint.html)
151 %/hlint: %/hlint.html
152
153 %/hlint.html: .
154 if hlint \
155 -i 'Redundant $$' \
156 -i 'Redundant bracket' \
157 -i 'Redundant do' \
158 -i 'Redundant lambda' \
159 -i "Use camelCase" \
160 -i 'Use if' \
161 -i 'Use String' \
162 -i 'Use string literal' \
163 --quiet --report="$@" \
164 "$*"/Hcompta; \
165 then rm -f "$@"; \
166 else echo; echo "BROWSE REPORT AT: file://$(abspath $@)"; fi
167
168 #
169 ## prof
170 ###
171 .PHONY: prof
172 prof: $(addprefix prof/,$(HCOMPTA_COMMANDS))
173
174 prof/commit/$(commit):
175 mkdir -p "$@"
176
177 lib/install/prof: CABAL_INSTALL_FLAGS+=-fprof --enable-library-profiling
178 lib/install/prof: cli/unregister/sandbox lib/install | $(CABAL_SANDBOX)
179
180
181 jcc/install/prof: CABAL_INSTALL_FLAGS+=-fprof --enable-library-profiling
182 jcc/install/prof: cli/unregister/sandbox web/unregister/sandbox jcc/install | $(CABAL_SANDBOX)
183
184
185 ledger/install/prof: CABAL_INSTALL_FLAGS+=-fprof --enable-library-profiling
186 ledger/install/prof: cli/unregister/sandbox web/unregister/sandbox ledger/install | $(CABAL_SANDBOX)
187
188
189 cli/install/prof: CABAL_INSTALL_FLAGS+=-fprof --enable-library-profiling --enable-executable-profiling
190 cli/install/prof: cli/install | $(CABAL_SANDBOX)
191 mv \
192 $(CABAL_SANDBOX)/bin/hcompta \
193 $(HCOMPTA_CLI_PROF)
194
195 define prof/command
196 prof/clean: prof/$(command)/clean
197
198 endef
199
200 define prof/in
201 prof/%.$(in)/clean: \
202 $(foreach command,$(HCOMPTA_COMMANDS), \
203 $(foreach journal,$(HCOMPTA_IN_FORMATS), \
204 prof/%.$(in)/$(command)/clean ))
205
206
207 endef
208
209 define prof/command/in
210
211 prof/%.$(in)/$(command)/clean: \
212 $(foreach hC,$(GHC_PROF_CATEGORIES), \
213 prof/%.$(in)/$(command)/$(hC)/clean \
214 )
215 $$(call rmw, \
216 prof/$$*.$(in).$(command) \
217 )
218
219 endef
220
221 define prof/command/hC
222 prof/$(command): prof/$(command)/$(hC)
223 prof/$(command)/clean: prof/$(command)/$(hC)/clean
224 prof/$(command)/$(hC): \
225 $(addsuffix /$(command)/$(hC),$(wildcard prof/*.$(in)))
226 prof/$(command)/$(hC)/clean:
227 $$(call rmw, \
228 prof/commit/$$(commit)/*.$(in).$(command).$(hC).aux \
229 prof/commit/$$(commit)/*.$(in).$(command).$(hC).hp \
230 prof/commit/$$(commit)/*.$(in).$(command).$(hC).prof \
231 prof/commit/$$(commit)/*.$(in).$(command).$(hC).ps \
232 prof/commit/$$(commit)/*.$(in).$(command).$(hC).stats \
233 )
234
235 endef
236
237 define prof/command/in/hC
238 prof/%.$(in)/$(command): prof/%.$(in).$(command)/$(hC)
239 prof/%.$(in)/$(command)/$(hC): prof/commit/$$(commit)/%.$(in).$(command).$(hC).ps
240
241
242 prof/%.$(in).$(command): \
243 prof/commit/$$(commit)/%.$(in).$(command).$(hC).hs
244
245 prof/commit/$$(commit)/%.$(in).$(command).$(hC).hp \
246 prof/%.$(in).$(command): \
247 $$(HCOMPTA_CLI_PROF) \
248 prof/%.$(in) \
249 | prof/commit/$$(commit)
250 GHCRTS=' \
251 -$(hC)$$(GHC_PROF_$(hC)) \
252 -i$$(GHC_PROF_RATE) \
253 -L$$(GHC_PROF_CC_LENGTH) \
254 -N$$(GHC_PROF_CPUS) \
255 -tprof/commit/$(commit)/$$*.$(in).$(command).$(hC).stats \
256 -p \
257 $$(GHCRTS)' \
258 $$(HCOMPTA_CLI_PROF) $$(HCOMPTA_FLAGS) \
259 $(command) $$(HCOMPTA_COMMAND_FLAGS) $$(filter %.$(in),$$^) \
260 >prof/$$*.$(in).$(command)
261 mv $(notdir $(HCOMPTA_CLI_PROF)).hp prof/commit/$(commit)/$$*.$(in).$(command).$(hC).hp
262 mv $(notdir $(HCOMPTA_CLI_PROF)).prof prof/commit/$(commit)/$$*.$(in).$(command).$(hC).prof
263
264 prof/%.$(in)/$(command)/$(hC)/clean:
265 $$(call rmw, \
266 prof/commit/$$(commit)/$$*.$(in).$(command).$(hC).aux \
267 prof/commit/$$(commit)/$$*.$(in).$(command).$(hC).hp \
268 prof/commit/$$(commit)/$$*.$(in).$(command).$(hC).prof \
269 prof/commit/$$(commit)/$$*.$(in).$(command).$(hC).ps \
270 prof/commit/$$(commit)/$$*.$(in).$(command).$(hC).stats \
271 )
272
273 endef
274
275 $(foreach in,$(HCOMPTA_IN_FORMATS), \
276 $(eval $(call prof/in)) )
277 $(foreach command,$(HCOMPTA_COMMANDS), \
278 $(eval $(call prof/command)) \
279 $(foreach hC,$(GHC_PROF_CATEGORIES), \
280 $(eval $(call prof/command/hC)) ) \
281 $(foreach in,$(HCOMPTA_IN_FORMATS), \
282 $(eval $(call prof/command/in)) \
283 $(foreach hC,$(GHC_PROF_CATEGORIES), \
284 $(eval $(call prof/command/in/hC)) )))
285
286 %.hC.hp: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).hp)
287
288 %.hC.ps: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).ps)
289
290 %.ps: %.hp
291 (cd $(@D) && hp2ps -b -c -e$(GHC_PROF_PS_WIDTH) -g $(notdir $*.hp))
292
293 #
294 ## not-threaded
295 ###
296 %/not-threaded: CABAL_INSTALL_FLAGS+=-f-threaded
297 %/not-threaded: %
298
299
300 #
301 ## ghc-pkg
302 ###
303 unregister: $(HCOMPTA_PACKAGES:=/unregister)
304
305 %/unregister: .
306 if $(GHC_PKG) list hcompta-$* | grep -q '^ * hcompta-$*-' ; \
307 then $(GHC_PKG) unregister hcompta-$* ; \
308 fi
309
310 %/unregister/sandbox: GHC_PKG:=cabal sandbox hc-pkg
311 %/unregister/sandbox: .
312 if $(GHC_PKG) list hcompta-$* | grep -q '^ * hcompta-$*-' ; \
313 then $(GHC_PKG) unregister hcompta-$* ; \
314 fi
315
316 #
317 ## sandbox
318 ###
319 $(CABAL_SANDBOX):
320 cabal $(CABAL_FLAGS) sandbox --sandbox="$@" $(CABAL_SANDBOX_FLAGS) init
321
322 %/sandbox: GHC_PKG:=cabal sandbox hc-pkg
323 %/sandbox: %
324
325
326 #
327 ## stats
328 ###
329 .PHONY: stats
330 stats:
331 gitstats . $@