3 include ../Makefile.defs
14 OCAML_FLAGS = -pp $(CAMLP5O) -rectypes $(ANNOTOPTION)
15 OCAMLDEP_FLAGS = -pp $(CAMLP5O)
16 PKGS = -package "$(MATITA_REQUIRES)"
17 CPKGS = -package "$(MATITA_CREQUIRES)"
18 OCAML_THREADS_FLAGS = -thread
19 OCAML_DEBUG_FLAGS = -g
21 #OCAMLOPT_DEBUG_FLAGS = -p
22 OCAMLC_FLAGS = $(OCAML_FLAGS) $(OCAML_THREADS_FLAGS)
23 OCAMLC = $(OCAMLFIND) ocamlc$(OCAML_PROF) $(OCAMLC_FLAGS) $(OCAML_DEBUG_FLAGS)
24 OCAMLOPT = $(OCAMLFIND) opt $(OCAMLC_FLAGS) $(OCAMLOPT_DEBUG_FLAGS)
25 OCAMLDEP = $(OCAMLFIND) ocamldep $(OCAMLDEP_FLAGS)
26 INSTALL_PROGRAMS= matita matitac
27 INSTALL_PROGRAMS_LINKS_MATITA=
28 INSTALL_PROGRAMS_LINKS_MATITAC= matitaclean
30 MATITA_FLAGS = -noprofile
40 applyTransformation.mli \
47 predefined_virtuals.mli \
55 applyTransformation.mli \
63 # objects for matita (GTK GUI)
64 ML = buildTimeConf.ml matitaGeneratedGui.ml $(MLI:%.mli=%.ml)
65 # objects for matitac (batch compiler)
66 CML = buildTimeConf.ml $(CMLI:%.mli=%.ml)
67 MAINCML = $(MAINCMLI:%.mli=%.ml)
70 matita matitac matitaclean
71 PROGRAMS = $(PROGRAMS_BYTE)
72 PROGRAMS_OPT = $(patsubst %,%.opt,$(PROGRAMS_BYTE))
74 NOINST_PROGRAMS_OPT = $(patsubst %,%.opt,$(EXTRA_PROGRAMS))
77 all: $(PROGRAMS) $(NOINST_PROGRAMS)
79 CMOS = $(ML:%.ml=%.cmo)
80 CCMOS = $(CML:%.ml=%.cmo)
81 MAINCMOS = $(MAINCML:%.ml=%.cmo)
82 CMXS = $(patsubst %.cmo,%.cmx,$(CMOS))
83 CCMXS = $(patsubst %.cmo,%.cmx,$(CCMOS))
84 MAINCMXS = $(patsubst %.cmo,%.cmx,$(MAINCMOS))
86 $(CMXOS): $(LIBX_DEPS)
88 LIB_DEPS := $(shell $(OCAMLFIND) query -recursive -predicates "byte" -format "%d/%a" $(MATITA_REQUIRES))
89 LIBX_DEPS := $(shell $(OCAMLFIND) query -recursive -predicates "native" -format "%d/%a" $(MATITA_REQUIRES))
90 CLIB_DEPS := $(shell $(OCAMLFIND) query -recursive -predicates "byte" -format "%d/%a" $(MATITA_CREQUIRES))
91 CLIBX_DEPS := $(shell $(OCAMLFIND) query -recursive -predicates "native" -format "%d/%a" $(MATITA_CREQUIRES))
92 opt: $(PROGRAMS_OPT) $(NOINST_PROGRAMS_OPT)
96 ifeq ($(HAVE_OCAMLOPT),yes)
97 world: depend.opt opt links
104 $(H)for X in $(INSTALL_PROGRAMS_LINKS_MATITAC) \
105 $(INSTALL_PROGRAMS_LINKS_MATITA); do\
108 $(H)ln -sf matita.opt matita
109 $(H)ln -sf matitac.opt matitac
112 $(H)echo " OCAMLC matita.ml"
113 $(H)$(OCAMLC) $(PKGS) -linkpkg -o matita $(CMOS) $(OCAML_DEBUG_FLAGS) matita.ml
114 $(H)echo " OCAMLC matitac.ml"
115 $(H)$(OCAMLC) $(CPKGS) -linkpkg -o matitac $(CCMOS) $(MAINCMOS) $(OCAML_DEBUG_FLAGS) matitac.ml
117 matita: matita.ml $(LIB_DEPS) $(CMOS)
118 $(H)echo " OCAMLC $<"
119 $(H)$(OCAMLC) $(PKGS) -linkpkg -o $@ $(CMOS) matita.ml
120 matita.opt: matita.ml $(LIBX_DEPS) $(CMXS)
121 $(H)echo " OCAMLOPT $<"
122 $(H)$(OCAMLOPT) $(PKGS) -linkpkg -o $@ $(CMXS) matita.ml
124 matitac: matitac.ml $(CLIB_DEPS) $(CCMOS) $(MAINCMOS)
125 $(H)echo " OCAMLC $<"
126 $(H)$(OCAMLC) $(CPKGS) -linkpkg -o $@ $(CCMOS) $(MAINCMOS) matitac.ml
127 matitac.opt: matitac.ml $(CLIBX_DEPS) $(CCMXS) $(MAINCMXS)
128 $(H)echo " OCAMLOPT $<"
129 $(H)$(OCAMLOPT) $(CPKGS) -linkpkg -o $@ $(CCMXS) $(MAINCMXS) matitac.ml
131 rottener: rottener.ml $(CLIB_DEPS) $(CCMOS) $(MAINCMOS)
132 $(H)echo " OCAMLC $<"
133 $(H)$(OCAMLC) $(CPKGS) -package lablgtk2 -linkpkg -o $@ $(CCMOS) $(MAINCMOS) rottener.ml
134 rottener.opt: rottener.ml $(CLIBX_DEPS) $(CCMXS) $(MAINCMXS)
135 $(H)echo " OCAMLOPT $<"
136 $(H)$(OCAMLOPT) $(CPKGS) -package lablgtk2 -linkpkg -o $@ $(CCMXS) $(MAINCMXS) rottener.ml
138 find . -type f -name "*.ma.*.rottened" -exec rm {} \;
141 $(H)test -f $@ || ln -s $< $@
142 matitaclean.opt: matitac.opt
143 $(H)test -f $@ || ln -s $< $@
145 matitaGeneratedGui.ml: matita.glade.utf8
146 $(H)$(LABLGLADECC) -embed $< > matitaGeneratedGui.ml
148 matita.glade.utf8: matita.glade
149 $(H)xmllint --encode UTF8 $< > $@
153 $(H)rm -rf *.cma *.cmo *.cmi *.cmx *.cmxa *.a *.o \
154 $(PROGRAMS) $(PROGRAMS_OPT) \
155 rottener rottener.opt \
156 $(NOINST_PROGRAMS) $(NOINST_PROGRAMS_OPT) \
164 $(H)$(MAKE) -C dist/ clean
165 $(H)rm -f matitaGeneratedGui.ml matitaGeneratedGui.mli
166 $(H)rm -f buildTimeConf.ml
167 $(H)rm -f matita.glade.bak matita.gladep.bak
168 $(H)rm -f matita.conf.xml.sample
179 contribs/RELATIONAL \
187 # contribs/LAMBDA-TYPES \
190 .PHONY: tests tests.opt cleantests cleantests.opt
191 tests: $(foreach d,$(TEST_DIRS),$(d)-test)
192 tests.opt: $(foreach d,$(TEST_DIRS_OPT),$(d)-test-opt)
193 cleantests: $(foreach d,$(TEST_DIRS),$(d)-cleantests)
194 cleantests.opt: $(foreach d,$(TEST_DIRS_OPT),$(d)-cleantests-opt)
196 %-test: matitac matitaclean
197 -cd $* && make -k clean all
198 %-test-opt: matitac.opt matitaclean.opt
199 -cd $* && make -k clean.opt opt
200 %-cleantests: matitaclean
202 %-cleantests-opt: matitaclean.opt
203 -cd $* && make clean.opt
205 # {{{ Distribution stuff
207 ifeq ($(DISTRIBUTED),yes)
210 dist_library: install_preliminaries
212 $(H)cd $(WHERE)/ma/standard-library;(HOME=$(WHERE) USER=builder MATITA_RT_BASE_DIR=$(WHERE) MATITA_FLAGS='$(MATITA_CFLAGS)' $(WHERE)/matitac -system -noinnertypes)
214 $(H)cd $(WHERE)/ma/standard-library;(HOME=$(WHERE) USER=builder MATITA_RT_BASE_DIR=$(WHERE) MATITA_FLAGS='$(MATITA_CFLAGS)' $(WHERE)/matitaclean)
216 $(H)cp $(WHERE)/.matita/matita.db $(WHERE)/metadata.db || true
217 #$(H)rm -rf $(WHERE)/.matita/
222 dist_pre: matitaGeneratedGui.ml
223 $(MAKE) -C dist/ dist_pre
225 WHERE = $(DESTDIR)/$(RT_BASE_DIR)
235 gtkmathview.matita.conf.xml \
240 ifeq ($(HAVE_OCAMLOPT),yes)
241 INSTALL_STUFF_BIN = $(INSTALL_PROGRAMS:%=%.opt)
243 INSTALL_STUFF_BIN = $(INSTALL_PROGRAMS)
246 install-arch: install_preliminaries
249 install_preliminaries : install_preliminaries.stamp
251 install_preliminaries.stamp:
252 $(H)install -d $(WHERE)/ma/
253 $(H)cp -a $(INSTALL_STUFF) $(WHERE)
254 ifeq ($(HAVE_OCAMLOPT),yes)
255 $(H)install -s $(INSTALL_STUFF_BIN) $(WHERE)
256 $(H)for p in $(INSTALL_PROGRAMS); do ln -fs $$p.opt $(WHERE)/$$p; done
258 $(H)install $(INSTALL_STUFF_BIN) $(WHERE)
260 $(H)for p in $(INSTALL_PROGRAMS_LINKS_MATITAC); do \
261 ln -fs matitac $(WHERE)/$$p;\
263 $(H)for p in $(INSTALL_PROGRAMS_LINKS_MATITA); do \
264 ln -fs matita $(WHERE)/$$p;\
266 $(H)cp -a library/ $(WHERE)/ma/standard-library
267 $(H)cp -a nlibrary/ $(WHERE)/ma/new-standard-library
269 $(H)touch install_preliminaries.stamp
274 STATIC_LINK = dist/static_link/static_link
278 gtkmathview_gmetadom mathview mathview_backend_gtk mathview_frontend_gmetadom \
280 gdome gmetadom_gdome_cpp_smart \
285 STATIC_EXTRA_LIBS = -cclib -lt1x -cclib -lstdc++
291 STATIC_CLIBS_PROVER = \
300 PROGRAMS_STATIC = $(patsubst %,%.static,$(PROGRAMS_OPT))
301 PROGRAMS_UPX = $(patsubst %,%.upx,$(PROGRAMS_STATIC))
303 ifeq ($(HAVE_OCAMLOPT),yes)
304 static: $(STATIC_LINK) $(PROGRAMS_STATIC)
307 $(H)echo "Native code compilation is disabled"
309 $(H)echo "Native code compilation is disabled"
313 $(MAKE) -C dist/ $(STATIC_LINK)
315 matita.opt.static: $(STATIC_LINK) $(LIBX_DEPS) $(CMXS) matita.ml
316 $(STATIC_LINK) $(STATIC_LIBS) -- \
317 $(OCAMLOPT) $(PKGS) -linkpkg -o $@ $(CMXS) matita.ml \
320 matitac.opt.static: $(STATIC_LINK) $(CLIBX_DEPS) $(CCMXS) $(MAINCMXS) matitac.ml
321 $(STATIC_LINK) $(STATIC_CLIBS) -- \
322 $(OCAMLOPT) $(CPKGS) -linkpkg -o $@ $(CCMXS) $(MAINCMXS) matitac.ml \
323 $(STATIC_EXTRA_CLIBS)
325 matitaclean.opt.static: matitac.opt.static
326 $(H)test -f $@ || ln -s $< $@
333 # }}} End of distribution stuff
335 # {{{ Deps and automatic rules
339 $(H)cd ..; otags -vi -r components/ matita/
345 $(H)$(OCAMLDEP) *.ml *.mli > .depend
347 $(H)echo " OCAMLDEP -native"
348 $(H)$(OCAMLDEP) -native *.ml *.mli > .depend.opt
350 # this should be sligtly better, since should work with 'make all opt'
351 MAKECMDGOALS_DELIM=$(addprefix _x_,$(addsuffix _x_,$(MAKECMDGOALS)))
352 ifneq (,$(findstring _x_all_x_,$(MAKECMDGOALS_DELIM)))
353 # if we 'make all opt' the deps for 'all' should be fine also for opt
354 # if we 'make opt all' it should not work...
355 INCLUDE_MANDATORY=yes
357 TO_DEPEND_ON=$(LIB_DEPS)
358 else ifneq (,$(findstring _x_opt_x_,$(MAKECMDGOALS_DELIM)))
359 INCLUDE_MANDATORY=yes
360 TO_INCLUDE+=.depend.opt
361 TO_DEPEND_ON=$(LIBX_DEPS)
362 else ifneq (,$(findstring _x_world_x_,$(MAKECMDGOALS_DELIM)))
363 ifeq ($(HAVE_OCAMLOPT),yes)
364 INCLUDE_MANDATORY=yes
365 TO_INCLUDE+=.depend.opt
366 TO_DEPEND_ON=$(LIBX_DEPS)
368 INCLUDE_MANDATORY=yes
370 TO_DEPEND_ON=$(LIB_DEPS)
375 TO_DEPEND_ON=$(LIB_DEPS)
378 $(MLI:%.mli=%.cmi) $(ML:%.ml=%.cmo) $(ML:%.ml=%.cmx): $(TO_DEPEND_ON)
380 ifeq (no,$(INCLUDE_MANDATORY))
381 -include $(TO_INCLUDE)
383 include $(TO_INCLUDE)
387 $(H)echo " OCAMLC $<"
388 $(H)$(OCAMLC) $(PKGS) -c $<
390 $(H)echo " OCAMLC $<"
391 $(H)$(OCAMLC) $(PKGS) -c $<
393 $(H)echo " OCAMLOPT $<"
394 $(H)$(OCAMLOPT) $(PKGS) -c $<
396 $(H)echo " OCAMLC -dtypes $<"
397 $(H)$(OCAMLC) -dtypes $(PKGS) -c $<
402 ./dep2dot.rb < $< | tred > $@
404 # }}} End of deps and automatic rules
406 # vim: set foldmethod=marker: