]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/Makefile
- wrong version of drop was used in four places
[helm.git] / matita / matita / contribs / lambdadelta / Makefile
1 OPEN := (
2 H    := @
3
4 TRIM := sed "s/ \\+$$//"
5
6 XOA_CONF     := ground_2/xoa.conf.xml
7 XOA_TARGETS  := ground_2/notation/xoa_notation.ma ground_2/xoa/xoa.ma
8
9 XOA_DIR      := ../../../components/binaries/xoa
10 XOA          := xoa.native
11 XOA_OPTS     := ../../matita.conf.xml $(XOA_CONF)
12
13 XOA2_CONF    := ground_2/xoa2.conf.xml
14 XOA2_TARGETS := ground_2/notation/xoa2_notation.ma ground_2/xoa/xoa2.ma
15 XOA2_OPTS    := ../../matita.conf.xml $(XOA2_CONF)
16
17 DEP_INPUT    := .depend
18 DEP_DIR      := ../../../components/binaries/matitadep
19 DEP          := matitadep.native
20 DEP_OPTS     :=
21
22 MAC_DIR      := ../../../components/binaries/mac
23 MAC          := mac.native
24 MAC_OPTS     :=
25
26 PRB_DIR      := ../../../components/binaries/probe
27 PRB          := probe.native
28 PRB_OPTS     := $(XOA_OPTS) -g 
29
30 ORIG         := . ./orig.sh 
31 ORIGS        := basic_2/basic_1.orig
32
33 CONTRIB      := lambdadelta_2
34
35 TAGS := all xoa xoa2 orig elim deps top leaf stats tbls trim contrib
36
37 PACKAGES := ground_2 basic_2 apps_2
38
39 LDWS := $(shell find -name "*.ldw.xml")
40 TBLS := $(shell find -name "*.tbl")
41
42 all:
43         ../../matitac.opt
44
45 # MAS ########################################################################
46
47 define MAS_TEMPLATE
48   MAS_$(1) := $$(shell find $(1) -name "*.ma")
49   MAS      += $$(MAS_$(1))
50
51 $(1)/$(1)_probe.txt: $$(MAS_$(1))
52         @echo "  PROBE $(1)"
53         $$(H)$$(PRB_DIR)/$$(PRB) $$(PRB_OPTS) $(1) -sn -on -i > $$@
54
55 $(1)/$(1)_mac.txt: $$(MAS_$(1))
56         @echo "  MAC $(1)"
57         $$(H)$$(MAC_DIR)/$$(MAC) $$(MAC_OPTS) $$^ > $$@
58 endef
59
60 $(foreach PKG, $(PACKAGES), $(eval $(call MAS_TEMPLATE,$(PKG))))
61
62 # xoa ########################################################################
63
64 xoa: $(XOA_TARGETS)
65
66 $(XOA_TARGETS): $(XOA_CONF)
67         @echo "  EXEC $(XOA) $(XOA_CONF)"
68         $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA_OPTS)
69
70 # xoa2 #######################################################################
71
72 xoa2: $(XOA2_TARGETS)
73
74 $(XOA2_TARGETS): $(XOA2_CONF)
75         @echo "  EXEC $(XOA) $(XOA2_CONF)"
76         $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA2_OPTS)
77
78 # elim #######################################################################
79
80 elim:
81         @echo "  GREP elim"
82         $(H)grep "elim (.*?)" $(MAS) || true
83
84 # orig #######################################################################
85
86 orig: $(ORIGS)
87         @echo "  ORIG basic_2"
88         $(H)$(ORIG) basic_2 < $<
89
90 # dep input ##################################################################
91
92 $(DEP_INPUT): $(MAS)
93         @echo "  GREP include"
94         $(H)grep "include \"" $^ > $(DEP_INPUT)
95
96 # dep ########################################################################
97
98 deps: $(DEP_INPUT)
99         @echo "  MATITADEP -c"
100         $(H)$(DEP_DIR)/$(DEP) -c $(DEP_OPTS) < $<
101
102 # top ########################################################################
103
104 top: $(DEP_INPUT)
105         @echo "  MATITADEP -t"
106         $(H)$(DEP_DIR)/$(DEP) -t $(DEP_OPTS) < $<
107
108 # leaf #######################################################################
109
110 leaf: $(DEP_INPUT)
111         @echo "  MATITADEP -l"
112         $(H)$(DEP_DIR)/$(DEP) -l $(DEP_OPTS) < $<
113
114 # stats ######################################################################
115
116 define STATS_TEMPLATE
117   STT_$(1) := $(1).stats
118   STTS     += $$(STT_$(1))
119
120   $$(STT_$(1)): S0  = $$(shell cat $(1)/$(1)_probe.txt)
121   $$(STT_$(1)): S1  = $$(shell cat $(1)/$(1)_mac.txt)
122   $$(STT_$(1)): S4  = $$(shell ls $$(MAS_$(1)) | wc -l)
123   $$(STT_$(1)): P1  = $$(shell grep "^theorem " $$(MAS_$(1)) | wc -l)
124   $$(STT_$(1)): P2  = $$(shell grep "^lemma " $$(MAS_$(1)) | wc -l)
125   $$(STT_$(1)): P3  = $$(shell grep "^fact " $$(MAS_$(1)) | wc -l)
126   $$(STT_$(1)): P4  = $$(shell grep qed $$(MAS_$(1)) | wc -l)
127   $$(STT_$(1)): C1  = $$(shell grep "^inductive \|^record " $$(MAS_$(1)) | wc -l)
128   $$(STT_$(1)): C2  = $$(shell grep "^definition \|^let rec " $$(MAS_$(1)) | wc -l)
129   $$(STT_$(1)): M1  = $$(shell grep "^axiom " $$(MAS_$(1)) | wc -l)
130   $$(STT_$(1)): M2  = $$(shell grep "$$(OPEN)\*[^*:]*$$$$" $$(MAS_$(1)) | wc -l)
131   $$(STT_$(1)): M3  = $$(shell grep "(\*\*)" $$(MAS_$(1)) | wc -l)
132
133 $$(STT_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
134         @printf '\x1B[1;40;37m'
135         @printf '%-15s %-47s' 'Statistics for:' $(1)
136         @printf '\x1B[0m\n'
137         @printf '\x1B[1;40;35m'
138         @printf '%-8s %6i' Chars $$(word 1, $$(S1))
139         @printf '   %-8s %4i' Pages $$(word 2, $$(S1))
140         @printf '   %-7s %7i' Nodes $$(word 3, $$(S0))
141         @printf '   %-11s' ''
142         @printf '\x1B[0m\n'
143         @printf '\x1B[1;40;36m'
144         @printf '%-8s %6i' Files $$(S4)
145         @printf '   %-8s %4i' Sources $$(word 1, $$(S0))
146         @printf '   %-7s %7i' Objects $$(word 2, $$(S0))
147         @printf '   %-11s' ''
148         @printf '\x1B[0m\n'     
149         @printf '\x1B[1;40;32m'
150         @printf '%-8s %6i' Theorems $$(P1)
151         @printf '   %-8s %4i' Lemmas $$(P2)
152         @printf '   %-7s %7i' Facts $$(P3)
153         @printf '   %-6s %4i' Proofs $$(P4)
154         @printf '\x1B[0m\n'     
155         @printf '\x1B[1;40;33m'
156         @printf '%-8s %6i' Declared $$(C1)
157         @printf '   %-8s %4i' Defined $$(C2)    
158         @printf '   %-29s' ''
159         @printf '\x1B[0m\n'
160         @printf '\x1B[1;40;31m'
161         @printf '%-8s %6i' Axioms $$(M1)
162         @printf '   %-8s %4i' Comments $$(M2)
163         @printf '   %-7s %7i' Marks $$(M3)
164         @printf '   %-11s' ''
165         @printf '\x1B[0m\n'
166
167 .PHONY: $$(STT_$(1))
168 endef
169
170 ifeq ($(MAKECMDGOALS), stats)
171    $(foreach PKG, $(PACKAGES), $(eval $(call STATS_TEMPLATE,$(PKG))))
172 endif
173
174 stats: $(STTS)
175
176 # summary ####################################################################
177
178 define SUMMARY_TEMPLATE
179   SUM_$(1) := $(1)/web/$(1)_sum.tbl  
180   SUMS     += $$(SUM_$(1))
181
182   $$(SUM_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
183   $$(SUM_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
184   $$(SUM_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
185   $$(SUM_$(1)): C1 = $$(shell grep "^inductive \|^record " $$(MAS_$(1)) | wc -l)
186   $$(SUM_$(1)): C2 = $$(shell grep "^definition \|^let rec " $$(MAS_$(1)) | wc -l)
187   $$(SUM_$(1)): C3 = $$(shell grep "^inductive \|^record \|^definition \|^let rec " $$(MAS_$(1)) | wc -l)
188   $$(SUM_$(1)): P1 = $$(shell grep "^theorem " $$(MAS_$(1)) | wc -l)
189   $$(SUM_$(1)): P2 = $$(shell grep "^lemma " $$(MAS_$(1)) | wc -l)
190   $$(SUM_$(1)): P3 = $$(shell grep "^lemma \|^theorem " $$(MAS_$(1)) | wc -l)
191
192   $$(SUM_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
193         @printf '  SUMMARY $(1)\n'
194         @printf 'name "$$(basename $$(@F))"\n\n'                >  $$@
195         @printf 'table {\n'                                     >> $$@
196         @printf '   class "gray"   [ "category"\n'              >> $$@
197         @printf '      [ "objects" * ]\n'                       >> $$@
198         @printf '   ]\n'                                        >> $$@
199         @printf '   class "cyan"   [ "sizes"\n'                 >> $$@
200         @printf '      [ "files"      "$$(S4)" ]\n'             >> $$@
201         @printf '      [ "characters" "$$(word 1, $$(S1))" ]\n' >> $$@
202         @printf '      [ "nodes"      "$$(word 3, $$(S0))" ]\n' >> $$@
203         @printf '   ]\n'                                        >> $$@  
204         @printf '   class "green"  [ "propositions"\n'          >> $$@
205         @printf '      [ "theorems" "$$(P1)" ]\n'               >> $$@
206         @printf '      [ "lemmas"   "$$(P2)" ]\n'               >> $$@
207         @printf '      [ "total"    "$$(P3)" ]\n'               >> $$@
208         @printf '   ]\n'                                        >> $$@
209         @printf '   class "yellow" [ "concepts"\n'              >> $$@
210         @printf '      [ "declared" "$$(C1)" ]\n'               >> $$@
211         @printf '      [ "defined"  "$$(C2)" ]\n'               >> $$@
212         @printf '      [ "total"    "$$(C3)" ]\n'               >> $$@
213         @printf '   ]\n'                                        >> $$@
214         @printf '}\n\n'                                         >> $$@
215         @printf 'class "component" { 0 }\n\n'                   >> $$@
216         @printf 'class "plane"     { 1 } { 3 } { 5 }\n\n'       >> $$@
217         @printf 'class "number"    { 2 } { 4 } { 6 }\n'         >> $$@
218
219 .PHONY: $$(SUM_$(1))
220 endef
221
222 ifeq ($(MAKECMDGOALS), tbls)
223    $(foreach PKG, $(PACKAGES), $(eval $(call SUMMARY_TEMPLATE,$(PKG))))
224 endif
225
226 tbls: $(SUMS)
227
228 # trim #######################################################################
229
230 TRIMS := $(MAS) $(TBLS) $(LDWS)
231
232 %.trimmed: %
233         $(H)expand $< | $(TRIM) > $@
234         $(H)if diff $< $@ > /dev/null; then $(RM) $@; else echo "  TRIM $<" & mv $@ $<; fi
235
236 trim: $(TRIMS:%=%.trimmed)
237
238 # contrib ####################################################################
239
240 contrib:
241         @echo "  TAR -czf $(CONTRIB).tar.gz root *.ma"
242         $(H)tar -czf $(CONTRIB).tar.gz root $(MAS)
243
244 ##############################################################################
245
246 .PHONY: $(TAGS)
247
248 .SUFFIXES: