]> matita.cs.unibo.it Git - helm.git/blob - matita/Makefile
added elp to distribution
[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         help/                           \
236         matita.gtkrc                    \
237         matita.lang                     \
238         matita.ma.templ                 \
239         core_notation.moo               \
240         matita.conf.xml                 \
241         closed.xml                      \
242         gtkmathview.matita.conf.xml     \
243         template_makefile.in            \
244         AUTHORS                         \
245         LICENSE                         \
246         $(NULL)
247
248
249 ifeq ($(HAVE_OCAMLOPT),yes)
250 INSTALL_STUFF_BIN = $(PROGRAMS_OPT)
251 else
252 INSTALL_STUFF_BIN = $(PROGRAMS_BYTE)
253 endif
254
255 install: install_preliminaries 
256         #dist_library 
257
258 install_preliminaries:
259         install -d $(DESTDIR)/ma/
260         cp -a $(INSTALL_STUFF) $(DESTDIR)
261         install -s $(INSTALL_STUFF_BIN) $(DESTDIR)
262 ifeq ($(HAVE_OCAMLOPT),yes)
263         for p in $(PROGRAMS_BYTE); do ln -fs $$p.opt $(DESTDIR)/$$p; done
264 endif
265         cp -a library/ $(DESTDIR)/ma/standard-library
266         cp -a contribs/ $(DESTDIR)/ma/
267
268 uninstall:
269         rm -rf $(DESTDIR)
270
271 STATIC_LINK = dist/static_link/static_link
272 # for matita
273 STATIC_LIBS =   \
274         t1 t1x  \
275         gtkmathview_gmetadom mathview mathview_backend_gtk mathview_frontend_gmetadom \
276         gtksourceview-1.0 \
277         gdome gmetadom_gdome_cpp_smart \
278         stdc++ \
279         mysqlclient \
280         expat \
281         $(NULL)
282 STATIC_EXTRA_LIBS = -cclib -lt1x -cclib -lstdc++
283 # for matitac & co
284 STATIC_CLIBS = \
285         gdome \
286         mysqlclient \
287         $(NULL)
288 STATIC_EXTRA_CLIBS =
289 PROGRAMS_STATIC = $(patsubst %,%.static,$(PROGRAMS_OPT))
290 PROGRAMS_UPX = $(patsubst %,%.upx,$(PROGRAMS_STATIC))
291
292 ifeq ($(HAVE_OCAMLOPT),yes)
293 static: $(STATIC_LINK) $(PROGRAMS_STATIC)
294 else
295 upx:
296         @echo "Native code compilation is disabled"
297 static:
298         @echo "Native code compilation is disabled"
299 endif
300
301 $(STATIC_LINK):
302         $(MAKE) -C dist/ $(STATIC_LINK)
303
304 matita.opt.static: $(STATIC_LINK) $(LIBX_DEPS) $(CMXS) matita.ml
305         $(STATIC_LINK) $(STATIC_LIBS) -- \
306                 $(OCAMLOPT) $(PKGS) -linkpkg -o $@ $(CMXS) matita.ml \
307                 $(STATIC_EXTRA_LIBS)
308         strip $@
309 dump_moo.opt.static: $(STATIC_LINK) buildTimeConf.cmx dump_moo.ml
310         $(STATIC_LINK) $(STATIC_CLIBS) -- \
311                 $(OCAMLOPT) $(PKGS) -linkpkg -o $@ $^ \
312                 $(STATIC_EXTRA_CLIBS)
313         strip $@
314 matitac.opt.static: $(STATIC_LINK) $(CLIBX_DEPS) $(CCMXS) $(MAINCMXS) matitac.ml
315         $(STATIC_LINK) $(STATIC_CLIBS) -- \
316                 $(OCAMLOPT) $(CPKGS) -linkpkg -o $@ $(CCMXS) $(MAINCMXS) matitac.ml \
317                 $(STATIC_EXTRA_CLIBS)
318         strip $@
319 matitadep.opt.static: matitac.opt.static
320         @test -f $@ || ln -s $< $@
321 matitaclean.opt.static: matitac.opt.static
322         @test -f $@ || ln -s $< $@
323 matitamake.opt.static: matitac.opt.static
324         @test -f $@ || ln -s $< $@
325 cicbrowser.opt.static: matita.opt.static
326         @test -f $@ || ln -s $< $@
327 cicbrowser.opt.static.upx: matita.opt.static.upx
328         @test -f $@ || ln -s $< $@
329
330 %.upx: %
331         cp $< $@
332         strip $@
333         upx $@
334
335 # }}} End of distribution stuff
336
337 tags: TAGS
338 .PHONY: TAGS
339 TAGS:
340         cd ..; otags -vi -r components/ matita/
341
342 #.depend: matitaGeneratedGui.ml matitaGeneratedGui.mli *.ml *.mli
343
344 .PHONY: depend
345 depend:
346         $(OCAMLDEP) *.ml *.mli > .depend
347
348 include .depend
349
350 %.cmi: %.mli
351         @echo "  OCAMLC $<"
352         $(H)$(OCAMLC) $(PKGS) -c $<
353 %.cmo %.cmi: %.ml
354         @echo "  OCAMLC $<"
355         $(H)$(OCAMLC) $(PKGS) -c $<
356 %.cmx: %.ml
357         @echo "  OCAMLOPT $<"
358         $(H)$(OCAMLOPT) $(PKGS) -c $<
359 %.annot: %.ml
360         @echo "  OCAMLC -dtypes $<"
361         $(H)$(OCAMLC) -dtypes $(PKGS) -c $<
362
363 $(CMOS): $(LIB_DEPS)
364 $(CMOS:%.cmo=%.cmx): $(LIBX_DEPS)
365
366 ifeq ($(MAKECMDGOALS),all)
367    $(CMOS:%.cmo=%.cmi): $(LIB_DEPS)
368 endif
369 ifeq ($(MAKECMDGOALS),)
370    $(CMOS:%.cmo=%.cmi): $(LIB_DEPS)
371 endif
372 ifeq ($(MAKECMDGOALS),opt)
373    $(CMOS:%.cmo=%.cmi): $(LIBX_DEPS)
374 endif
375
376 # vim: set foldmethod=marker: