]> matita.cs.unibo.it Git - helm.git/blob - matita/Makefile
Huge commit for the release. Includes:
[helm.git] / matita / Makefile
1 export SHELL=/bin/bash
2
3 include ../Makefile.defs
4
5 NULL =
6 H=@
7
8 OCAML_FLAGS = -pp $(CAMLP4O)
9 PKGS = -package "$(MATITA_REQUIRES)"
10 CPKGS = -package "$(MATITA_CREQUIRES)"
11 OCAML_THREADS_FLAGS = -thread
12 OCAML_DEBUG_FLAGS = -g
13 OCAMLC_FLAGS = $(OCAML_FLAGS) $(OCAML_THREADS_FLAGS)
14 OCAMLC = $(OCAMLFIND) ocamlc $(OCAMLC_FLAGS) $(OCAML_DEBUG_FLAGS)
15 OCAMLOPT = $(OCAMLFIND) opt $(OCAMLC_FLAGS)
16 OCAMLDEP = $(OCAMLFIND) ocamldep $(OCAML_FLAGS)
17
18 MATITA_FLAGS = -noprofile
19 NODB=false
20 ifeq ($(NODB),true)
21         MATITA_FLAGS += -nodb
22 endif
23
24 # objects for matita (GTK GUI)
25 CMOS =                          \
26         buildTimeConf.cmo       \
27         matitaTypes.cmo         \
28         matitaMisc.cmo          \
29         matitamakeLib.cmo       \
30         matitaInit.cmo          \
31         matitaExcPp.cmo         \
32         matitaEngine.cmo        \
33         matitacLib.cmo          \
34         matitaScript.cmo        \
35         matitaGeneratedGui.cmo  \
36         matitaGtkMisc.cmo       \
37         applyTransformation.cmo \
38         matitaMathView.cmo      \
39         matitaGui.cmo           \
40         $(NULL)
41 # objects for matitac (batch compiler)
42 CCMOS =                         \
43         buildTimeConf.cmo       \
44         matitaTypes.cmo         \
45         matitaMisc.cmo          \
46         matitamakeLib.cmo       \
47         matitaInit.cmo          \
48         matitaExcPp.cmo         \
49         matitaEngine.cmo        \
50         matitacLib.cmo          \
51         $(NULL)
52 MAINCMOS =                      \
53         matitadep.cmo           \
54         matitaclean.cmo         \
55         matitamake.cmo          \
56         gragrep.cmo             \
57         $(NULL)
58 PROGRAMS_BYTE = \
59         matita matitac cicbrowser matitadep matitaclean matitamake
60 PROGRAMS = $(PROGRAMS_BYTE) matitatop
61 PROGRAMS_OPT = $(patsubst %,%.opt,$(PROGRAMS_BYTE))
62 NOINST_PROGRAMS = dump_moo gragrep
63 NOINST_PROGRAMS_OPT = $(patsubst %,%.opt,$(EXTRA_PROGRAMS))
64
65 .PHONY: all
66 all: $(PROGRAMS) $(NOINST_PROGRAMS)
67 #  all: matita.conf.xml $(PROGRAMS) coq.moo
68
69 #  matita.conf.xml: matita.conf.xml.sample
70 #          @if diff matita.conf.xml.sample matita.conf.xml 1>/dev/null 2>/dev/null; then\
71 #                  touch matita.conf.xml;\
72 #          else\
73 #                  echo;\
74 #                  echo "matita.conf.xml.sample is newer than matita.conf.xml";\
75 #                  echo;\
76 #                  echo "PLEASE update your configuration file!";\
77 #                  echo "(copying matita.conf.xml.sample should work)";\
78 #                  echo;\
79 #                  false;\
80 #          fi
81
82 #  coq.moo: library/legacy/coq.ma matitac
83 #          ./matitac $(MATITA_FLAGS) $<
84 #  coq.moo.opt: library/legacy/coq.ma matitac.opt
85 #          ./matitac.opt $(MATITA_FLAGS) $<
86
87 CMXS = $(patsubst %.cmo,%.cmx,$(CMOS))
88 CCMXS = $(patsubst %.cmo,%.cmx,$(CCMOS))
89 MAINCMXS = $(patsubst %.cmo,%.cmx,$(MAINCMOS))
90 LIB_DEPS := $(shell $(OCAMLFIND) query -recursive -predicates "byte" -format "%d/%a" $(MATITA_REQUIRES))
91 LIBX_DEPS := $(shell $(OCAMLFIND) query -recursive -predicates "native" -format "%d/%a" $(MATITA_REQUIRES))
92 CLIB_DEPS := $(shell $(OCAMLFIND) query -recursive -predicates "byte" -format "%d/%a" $(MATITA_CREQUIRES))
93 CLIBX_DEPS := $(shell $(OCAMLFIND) query -recursive -predicates "native" -format "%d/%a" $(MATITA_CREQUIRES))
94 opt: $(PROGRAMS_OPT) $(NOINST_PROGRAMS_OPT)
95 upx: $(PROGRAMS_UPX)
96 .PHONY: opt upx
97
98 ifeq ($(HAVE_OCAMLOPT),yes)
99 world: all opt
100 else
101 world: all
102 endif
103
104 matita: matita.ml $(LIB_DEPS) $(CMOS)
105         @echo "  OCAMLC $<"
106         $(H)$(OCAMLC) $(PKGS) -linkpkg -o $@ $(CMOS) matita.ml
107 matita.opt: matita.ml $(LIBX_DEPS) $(CMXS)
108         @echo "  OCAMLOPT $<"
109         $(H)$(OCAMLOPT) $(PKGS) -linkpkg -o $@ $(CMXS) matita.ml
110
111 dump_moo: dump_moo.ml buildTimeConf.cmo
112         @echo "  OCAMLC $<"
113         $(H)$(OCAMLC) $(PKGS) -linkpkg -o $@ buildTimeConf.cmo $<
114 dump_moo.opt: dump_moo.ml buildTimeConf.cmx
115         @echo "OCAMLOPT $<"
116         $(H)$(OCAMLOPT) $(PKGS) -linkpkg -o $@ buildTimeConf.cmx $<
117
118 matitac: matitac.ml $(CLIB_DEPS) $(CCMOS) $(MAINCMOS)
119         @echo "  OCAMLC $<"
120         $(H)$(OCAMLC) $(CPKGS) -linkpkg -o $@ $(CCMOS) $(MAINCMOS) matitac.ml
121 matitac.opt: matitac.ml $(CLIBX_DEPS) $(CCMXS) $(MAINCMXS)
122         @echo "  OCAMLOPT $<"
123         $(H)$(OCAMLOPT) $(CPKGS) -linkpkg -o $@ $(CCMXS) $(MAINCMXS) matitac.ml
124
125 matitatop: matitatop.ml $(CLIB_DEPS) $(CCMOS)
126         @echo "  OCAMLC $<"
127         $(H)$(OCAMLC) $(CPKGS) -linkpkg -o $@ toplevellib.cma $(CCMOS) $<
128
129 matitadep: matitac
130         @test -f $@ || ln -s $< $@
131 matitadep.opt: matitac.opt
132         @test -f $@ || ln -s $< $@
133
134 matitaclean: matitac
135         @test -f $@ || ln -s $< $@
136 matitaclean.opt: matitac.opt
137         @test -f $@ || ln -s $< $@
138
139 matitamake: matitac
140         @test -f $@ || ln -s $< $@
141 matitamake.opt: matitac.opt
142         @test -f $@ || ln -s $< $@
143         
144 gragrep: matitac
145         @test -f $@ || ln -s $< $@
146 gragrep.opt: matitac.opt
147         @test -f $@ || ln -s $< $@
148         
149 cicbrowser: matita
150         @test -f $@ || ln -s $< $@
151 cicbrowser.opt: matita.opt
152         @test -f $@ || ln -s $< $@
153
154 matitaGeneratedGui.ml matitaGeneratedGui.mli: matita.glade
155         $(LABLGLADECC) -embed $< > matitaGeneratedGui.ml
156         $(OCAMLC) $(PKGS) -i matitaGeneratedGui.ml > matitaGeneratedGui.mli
157
158 .PHONY: clean
159 clean:
160         rm -rf *.cma *.cmo *.cmi *.cmx *.cmxa *.a *.o \
161                 $(PROGRAMS) $(PROGRAMS_OPT) \
162                 $(NOINST_PROGRAMS) $(NOINST_PROGRAMS_OPT) \
163                 $(PROGRAMS_STATIC) \
164                 $(PROGRAMS_UPX) \
165                 $(NULL)
166
167 .PHONY: distclean
168 distclean: clean
169         $(MAKE) -C dist/ clean
170         rm -f matitaGeneratedGui.ml matitaGeneratedGui.mli
171         rm -f buildTimeConf.ml
172         rm -f matita.glade.bak matita.gladep.bak
173         rm -f matita.conf.xml.sample
174         rm -rf .matita
175
176 TEST_DIRS =                             \
177         library                         \
178         tests                           \
179         tests/bad_tests                 \
180         contribs/LAMBDA-TYPES           \
181         contribs/PREDICATIVE-TOPOLOGY   \
182         $(NULL)
183
184 .PHONY: tests tests.opt cleantests cleantests.opt
185 tests: $(foreach d,$(TEST_DIRS),$(d)-test)
186 tests.opt: $(foreach d,$(TEST_DIRS),$(d)-test-opt)
187 cleantests: $(foreach d,$(TEST_DIRS),$(d)-cleantests)
188 cleantests.opt: $(foreach d,$(TEST_DIRS),$(d)-cleantests-opt)
189
190 %-test: matitac matitadep matitaclean 
191         -cd $* && make -k clean all
192 %-test-opt: matitac.opt matitadep.opt matitaclean.opt
193         -cd $* && make -k clean.opt opt
194 %-cleantests: matitaclean
195         -cd $* && make clean
196 %-cleantests-opt: matitaclean.opt
197         -cd $* && make clean.opt
198
199 # {{{ Distribution stuff
200
201 ifeq ($(HAVE_OCAMLOPT),yes)
202 BEST=opt
203 BEST_EXT=.opt
204 else
205 BEST=all
206 BEST_EXT=
207 endif
208
209 ifeq ($(DISTRIBUTED),yes)
210
211 dist_library: dist_library@library
212 dist_library@%:
213         @echo "MATITAMAKE init $*"
214         $(H)MATITA_RT_BASE_DIR=`pwd` \
215                 MATITA_FLAGS="-conffile `pwd`/matita.conf.xml" \
216                 ./matitamake$(BEST_EXT) -conffile `pwd`/matita.conf.xml \
217                         init $* `pwd`/$*
218         @echo "MATITAMAKE publish $*"
219         $(H)MATITA_RT_BASE_DIR=`pwd` \
220                 MATITA_FLAGS="-conffile `pwd`/matita.conf.xml" \
221                 ./matitamake$(BEST_EXT) -conffile `pwd`/matita.conf.xml \
222                         publish $*
223         @echo "MATITAMAKE destroy $*"
224         $(H)MATITA_RT_BASE_DIR=`pwd` \
225                 MATITA_FLAGS="-conffile `pwd`/matita.conf.xml" \
226                 ./matitamake$(BEST_EXT) -conffile `pwd`/matita.conf.xml \
227                         destroy $*
228         touch $@
229
230 endif
231
232 DESTDIR = $(RT_BASE_DIR)
233 INSTALL_STUFF =                         \
234         icons/                          \
235         matita.gtkrc                    \
236         matita.lang                     \
237         matita.ma.templ                 \
238         core_notation.moo               \
239         matita.conf.xml                 \
240         closed.xml                      \
241         gtkmathview.matita.conf.xml     \
242         template_makefile.in            \
243         AUTHORS                         \
244         LICENSE                         \
245         $(NULL)
246
247
248 ifeq ($(HAVE_OCAMLOPT),yes)
249 INSTALL_STUFF_BIN = $(PROGRAMS_OPT)
250 else
251 INSTALL_STUFF_BIN = $(PROGRAMS_BYTE)
252 endif
253
254 install: install_preliminaries 
255         #dist_library 
256
257 install_preliminaries:
258         install -d $(DESTDIR)/ma/
259         cp -a $(INSTALL_STUFF) $(DESTDIR)
260         install -s $(INSTALL_STUFF_BIN) $(DESTDIR)
261 ifeq ($(HAVE_OCAMLOPT),yes)
262         for p in $(PROGRAMS_BYTE); do ln -fs $$p.opt $(DESTDIR)/$$p; done
263 endif
264         cp -a library/ $(DESTDIR)/ma/standard-library
265         cp -a contribs/ $(DESTDIR)/ma/
266
267 uninstall:
268         rm -rf $(DESTDIR)
269
270 STATIC_LINK = dist/static_link/static_link
271 # for matita
272 STATIC_LIBS =   \
273         t1 t1x  \
274         gtkmathview_gmetadom mathview mathview_backend_gtk mathview_frontend_gmetadom \
275         gtksourceview-1.0 \
276         gdome gmetadom_gdome_cpp_smart \
277         stdc++ \
278         mysqlclient \
279         expat \
280         $(NULL)
281 STATIC_EXTRA_LIBS = -cclib -lt1x -cclib -lstdc++
282 # for matitac & co
283 STATIC_CLIBS = \
284         gdome \
285         mysqlclient \
286         $(NULL)
287 STATIC_EXTRA_CLIBS =
288 PROGRAMS_STATIC = $(patsubst %,%.static,$(PROGRAMS_OPT))
289 PROGRAMS_UPX = $(patsubst %,%.upx,$(PROGRAMS_STATIC))
290
291 ifeq ($(HAVE_OCAMLOPT),yes)
292 static: $(STATIC_LINK) $(PROGRAMS_STATIC)
293 else
294 upx:
295         @echo "Native code compilation is disabled"
296 static:
297         @echo "Native code compilation is disabled"
298 endif
299
300 $(STATIC_LINK):
301         $(MAKE) -C dist/ $(STATIC_LINK)
302
303 matita.opt.static: $(STATIC_LINK) $(LIBX_DEPS) $(CMXS) matita.ml
304         $(STATIC_LINK) $(STATIC_LIBS) -- \
305                 $(OCAMLOPT) $(PKGS) -linkpkg -o $@ $(CMXS) matita.ml \
306                 $(STATIC_EXTRA_LIBS)
307         strip $@
308 dump_moo.opt.static: $(STATIC_LINK) buildTimeConf.cmx dump_moo.ml
309         $(STATIC_LINK) $(STATIC_CLIBS) -- \
310                 $(OCAMLOPT) $(PKGS) -linkpkg -o $@ $^ \
311                 $(STATIC_EXTRA_CLIBS)
312         strip $@
313 matitac.opt.static: $(STATIC_LINK) $(CLIBX_DEPS) $(CCMXS) $(MAINCMXS) matitac.ml
314         $(STATIC_LINK) $(STATIC_CLIBS) -- \
315                 $(OCAMLOPT) $(CPKGS) -linkpkg -o $@ $(CCMXS) $(MAINCMXS) matitac.ml \
316                 $(STATIC_EXTRA_CLIBS)
317         strip $@
318 matitadep.opt.static: matitac.opt.static
319         @test -f $@ || ln -s $< $@
320 matitaclean.opt.static: matitac.opt.static
321         @test -f $@ || ln -s $< $@
322 matitamake.opt.static: matitac.opt.static
323         @test -f $@ || ln -s $< $@
324 cicbrowser.opt.static: matita.opt.static
325         @test -f $@ || ln -s $< $@
326 cicbrowser.opt.static.upx: matita.opt.static.upx
327         @test -f $@ || ln -s $< $@
328
329 %.upx: %
330         cp $< $@
331         strip $@
332         upx $@
333
334 # }}} End of distribution stuff
335
336 tags: TAGS
337 .PHONY: TAGS
338 TAGS:
339         cd ..; otags -vi -r components/ matita/
340
341 #.depend: matitaGeneratedGui.ml matitaGeneratedGui.mli *.ml *.mli
342
343 .PHONY: depend
344 depend:
345         $(OCAMLDEP) *.ml *.mli > .depend
346
347 include .depend
348
349 %.cmi: %.mli
350         @echo "  OCAMLC $<"
351         $(H)$(OCAMLC) $(PKGS) -c $<
352 %.cmo %.cmi: %.ml
353         @echo "  OCAMLC $<"
354         $(H)$(OCAMLC) $(PKGS) -c $<
355 %.cmx: %.ml
356         @echo "  OCAMLOPT $<"
357         $(H)$(OCAMLOPT) $(PKGS) -c $<
358 %.annot: %.ml
359         @echo "  OCAMLC -dtypes $<"
360         $(H)$(OCAMLC) -dtypes $(PKGS) -c $<
361
362 $(CMOS): $(LIB_DEPS)
363 $(CMOS:%.cmo=%.cmx): $(LIBX_DEPS)
364
365 ifeq ($(MAKECMDGOALS),all)
366    $(CMOS:%.cmo=%.cmi): $(LIB_DEPS)
367 endif
368 ifeq ($(MAKECMDGOALS),)
369    $(CMOS:%.cmo=%.cmi): $(LIB_DEPS)
370 endif
371 ifeq ($(MAKECMDGOALS),opt)
372    $(CMOS:%.cmo=%.cmi): $(LIBX_DEPS)
373 endif
374
375 # vim: set foldmethod=marker: