]> matita.cs.unibo.it Git - helm.git/blob - helm/software/helena/Makefile.common
more results towards the "big-tree" theorem ...
[helm.git] / helm / software / helena / Makefile.common
1 H=@
2 ifeq ($(origin OCAMLPATH), undefined)
3    OCAMLFIND = OCAMLPATH=$(HOME)/svn/claudio/components/METAS ocamlfind
4 else
5    OCAMLFIND = ocamlfind
6 endif
7
8 RELISE = $(MAIN:%=%_$(shell cat MakeVersion))
9
10 DOWNDIR = $(HOME)/svn/helm_stable/www/lambdadelta/download
11
12 DIRECTORIES = $(addprefix $(SRC)/,$(shell cat $(SRC)/Make))
13
14 INCLUDES = $(DIRECTORIES:%=-I %) 
15
16 OCAMLDEP  = $(OCAMLFIND) ocamldep -native $(INCLUDES)
17 OCAMLOPT  = $(OCAMLFIND) opt $(OCAMLOPTIONS) -linkpkg -package "$(REQUIRES)" $(INCLUDES)
18 OCAMLLEX  = ocamllex.opt
19 OCAMLYACC = ocamlyacc -v
20 TAR       = tar -czf etc/$(MAIN:%=%.tgz)
21
22 define DIR_TEMPLATE
23    MODULES += $$(addprefix $(1)/,$$(shell cat $(1)/Make))
24 endef
25
26 define MOD_TEMPLATE
27    SOURCES += $$(if $$(wildcard $(1).ml[yi]),$(1).mli $(1).ml,$(1).ml)  
28    CMXS    += $(1).cmx
29    CLEAN   += $(1).cmi $(1).cmx $(1).o 
30    CLEAN   += $$(if $$(wildcard $(1).ml[ly]),$(1).ml,)
31    CLEAN   += $$(if $$(wildcard $(1).mly),$(1).mli $(1).output,)
32    KEEP    += $$(if $$(wildcard $(1).mly),$(1).mly,\
33                $$(if $$(wildcard $(1).mll),$(1).mll,\
34                 $$(if $$(wildcard $(1).mli),$(1).mli $(1).ml,$(1).ml)\
35                )\
36               )
37 endef
38
39 define INCLUDE_TEMPLATE
40    ifeq ($(MAKECMDGOALS), $(1))
41       include .depend.opt
42    endif
43 endef
44
45 $(foreach DIR, $(DIRECTORIES), $(eval $(call DIR_TEMPLATE, $(DIR))))
46 $(foreach MOD, $(MODULES), $(eval $(call MOD_TEMPLATE, $(MOD))))
47
48 OBJECTS = $(patsubst %.ml,%.cmx,$(SOURCES:%.mli=%.cmi))
49 CLEAN += $(MAIN).opt
50
51 all opt: .depend.opt
52         @$(MAKE) --no-print-directory $(MAIN).opt
53
54 $(MAIN).opt: $(OBJECTS)
55         @echo "  OCAMLOPT -o $(MAIN).opt"
56         $(H)$(OCAMLOPT) -o $(MAIN).opt $(CMXS)
57
58 .depend.opt: $(SOURCES) 
59         @echo "  OCAMLDEP -native"
60         $(H)$(OCAMLDEP) $^ > .depend.opt
61
62 clean:
63         @echo "  CLEAN . $(SRC)"
64         $(H)find -name "*~" | xargs $(RM) $(CLEAN)
65
66 relise: clean
67         @echo "  RELISE $(RELISE)"
68         $(H)mkdir -p $(RELISE)
69         $(H)$(foreach FILE, $(shell cat Make), cp --parents $(FILE) $(RELISE);)
70         $(H)tar -czf etc/$(RELISE).tar.gz $(RELISE)
71         $(H)scp etc/$(RELISE).tar.gz $(DOWNDIR)
72
73 tgz: clean
74         @echo "  TAR -czf $(MAIN:%=%.tgz) . $(DIRECTORIES)" 
75         $(H)find -name "Make*" | xargs $(TAR) $(KEEP)
76
77 etc:
78         @echo "  MKDIR etc"
79         $(H)mkdir etc
80
81 %.ml %.mli: %.mly
82         @echo "  OCAMLYACC $<"
83         $(H)$(OCAMLYACC) $<
84 %.ml: %.mll
85         @echo "  OCAMLLEX $<"
86         $(H)$(OCAMLLEX) $<
87 %.cmi: %.mli
88         @echo "  OCAMLOPT $<"
89         $(H)$(OCAMLOPT) -c $<
90 %.cmx: %.ml
91         @echo "  OCAMLOPT $<"
92         $(H)$(OCAMLOPT) -c $<
93
94 TAGS += $(MAIN).opt
95
96 $(foreach TAG, $(TAGS), $(eval $(call INCLUDE_TEMPLATE, $(TAG))))