]> matita.cs.unibo.it Git - helm.git/blob - helm/software/lambda-delta/Makefile.common
basic topologies are trivially o-basic topologies
[helm.git] / helm / software / lambda-delta / Makefile.common
1 H=@
2
3 DIRECTORIES = $(shell cat Make)
4
5 INCLUDES = $(DIRECTORIES:%=-I %) 
6
7 OCAMLDEP  = ocamlfind ocamldep -native $(INCLUDES)
8 OCAMLOPT  = ocamlfind opt -linkpkg -package "$(REQUIRES)" $(INCLUDES)
9 OCAMLLEX  = ocamllex.opt
10 OCAMLYACC = ocamlyacc -v
11 TAR       = tar -czf $(MAIN:%=%.tgz)
12 GZIP      = gzip
13
14 define DIR_TEMPLATE
15    MODULES += $$(addprefix $(1)/,$$(shell cat $(1)/Make))
16 endef
17
18 define MOD_TEMPLATE
19    SOURCES += $$(if $$(wildcard $(1).ml[yi]),$(1).mli $(1).ml,$(1).ml)  
20    CMXS    += $(1).cmx
21    CLEAN   += $(1).cmi $(1).cmx $(1).o 
22    CLEAN   += $$(if $$(wildcard $(1).ml[ly]),$(1).ml,)
23    CLEAN   += $$(if $$(wildcard $(1).mly),$(1).mli $(1).output,)
24    KEEP    += $$(if $$(wildcard $(1).mly),$(1).mly,\
25                $$(if $$(wildcard $(1).mll),$(1).mll,\
26                 $$(if $$(wildcard $(1).mli),$(1).mli $(1).ml,$(1).ml)\
27                )\
28               )
29 endef
30
31 $(foreach DIR,$(DIRECTORIES),$(eval $(call DIR_TEMPLATE, $(DIR))))
32 $(foreach MOD,$(MODULES),$(eval $(call MOD_TEMPLATE, $(MOD))))
33
34 OBJECTS = $(patsubst %.ml,%.cmx,$(SOURCES:%.mli=%.cmi))
35 CLEAN += $(MAIN).opt
36
37 all opt: .depend.opt
38         @$(MAKE) --no-print-directory $(MAIN).opt
39
40 $(MAIN).opt: $(OBJECTS)
41         @echo "  OCAMLOPT -o $(MAIN).opt"
42         $(H)$(OCAMLOPT) -o $(MAIN).opt $(CMXS)
43
44 .depend.opt: $(SOURCES) 
45         @echo "  OCAMLDEP -native"
46         $(H)$(OCAMLDEP) $^ > .depend.opt
47
48 clean:
49         @echo "  CLEAN . $(DIRECTORIES)"
50         $(H)find -name "*~" | xargs $(RM) $(CLEAN)
51
52 tgz: clean
53         @echo "  TAR -czf $(MAIN:%=%.tgz) . $(DIRECTORIES)" 
54         $(H)find -name "Make*" | xargs $(TAR) $(KEEP)
55
56 %.ml %.mli: %.mly
57         @echo "  OCAMLYACC $<"
58         $(H)$(OCAMLYACC) $<
59 %.ml: %.mll
60         @echo "  OCAMLLEX $<"
61         $(H)$(OCAMLLEX) $<
62 %.cmi: %.mli
63         @echo "  OCAMLOPT $<"
64         $(H)$(OCAMLOPT) -c $<
65 %.cmx: %.ml
66         @echo "  OCAMLOPT $<"
67         $(H)$(OCAMLOPT) -c $<
68
69 ifeq ($(MAKECMDGOALS), $(MAIN).opt)
70   include .depend.opt
71 endif