]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/Makefile
syntactic components detached from basic_2 become static_2
[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_OPTS    := ../../matita.conf.xml $(XOA2_CONF)
15
16 DEP_INPUT    := .depend
17 DEP_DIR      := ../../../components/binaries/matitadep
18 DEP          := matitadep.native
19 DEP_OPTS     :=
20
21 PRB_DIR      := ../../../components/binaries/probe
22 PRB          := probe.native
23 PRB_OPTS     := $(XOA_OPTS) -g -i
24
25 ORIG         := . ./orig.sh 
26 ORIGS        := basic_2/basic_1.orig
27
28 CONTRIB      := lambdadelta_2
29
30 WWW          := ../../../../helm/www/lambdadelta
31
32 TAGS := all xoa xoa2 orig elim deps top leaf stats tbls trim contrib clean \
33         www up-html
34
35 PACKAGES  := ground_2 basic_2 static_2 apps_2 alpha_1
36 XPACKAGES := ground_2 basic_2
37
38 LDWS := $(shell find -name "*.ldw.xml")
39 TBLS := $(shell find -name "*.tbl")
40
41 all:
42         @echo "  MATITAC $(PACKAGES)"
43         $(H)../../matitac.opt $(PACKAGES)
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 -sc -on -oc -f > $$@
54 endef
55
56 $(foreach PKG, $(PACKAGES), $(eval $(call MAS_TEMPLATE,$(PKG))))
57
58 # XMAS #######################################################################
59
60 define XMAS_TEMPLATE
61   XMAS += $$(MAS_$(1))
62 endef
63
64 $(foreach PKG, $(XPACKAGES), $(eval $(call XMAS_TEMPLATE,$(PKG))))
65
66 # xoa ########################################################################
67
68 xoa: $(XOA_TARGETS)
69
70 $(XOA_TARGETS): $(XOA_CONF)
71         @echo "  EXEC $(XOA) $(XOA_CONF)"
72         $(H)$(XOA_DIR)/$(XOA) $(XOA_OPTS)
73
74 # xoa2 #######################################################################
75
76 xoa2: $(XOA2_CONF)
77         @echo "  EXEC $(XOA) $(XOA2_CONF)"
78         $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) -s $(XOA2_OPTS)
79
80 # elim #######################################################################
81
82 elim:
83         @echo "  GREP elim"
84         $(H)grep "elim (.*?)" $(MAS) || true
85
86 # orig #######################################################################
87
88 orig: $(ORIGS)
89         @echo "  ORIG basic_2"
90         $(H)$(ORIG) basic_2 < $<
91
92 # dep input ##################################################################
93
94 $(DEP_INPUT): LINE = $(MAS:%=%:include \"\".)
95
96 $(DEP_INPUT): $(MAS) Makefile
97         @echo "  GREP include"
98         $(H)grep "include \"" $^ > $(DEP_INPUT)
99         $(H)echo "$(LINE)" | sed -e 's/\"\. /\"\.\n/g' >> $(DEP_INPUT) 
100
101 # dep ########################################################################
102
103 deps: $(DEP_INPUT)
104         @echo "  MATITADEP -c"
105         $(H)$(DEP_DIR)/$(DEP) -c $(DEP_OPTS) < $<
106
107 # top ########################################################################
108
109 top: $(DEP_INPUT)
110         @echo "  MATITADEP -t"
111         $(H)$(DEP_DIR)/$(DEP) -t $(DEP_OPTS) < $<
112
113 # leaf #######################################################################
114
115 leaf: $(DEP_INPUT)
116         @echo "  MATITADEP -l"
117         $(H)$(DEP_DIR)/$(DEP) -l $(DEP_OPTS) < $<
118
119 # stats ######################################################################
120
121 define STATS_TEMPLATE
122   STT_$(1) := $(1).stats
123   STTS     += $$(STT_$(1))
124
125   $$(STT_$(1)): C0 = $$(shell cat $(1)/$(1)_probe.txt)
126   $$(STT_$(1)): C2 = $$(word 2, $$(C0))
127   $$(STT_$(1)): C3 = $$(word 4, $$(C0))
128   $$(STT_$(1)): O1 = $$(shell ls $$(MAS_$(1)) | wc -l)
129   $$(STT_$(1)): O2 = $$(word 1, $$(C0))
130   $$(STT_$(1)): O3 = $$(word 3, $$(C0))
131   $$(STT_$(1)): P1 = $$(word 10, $$(C0))
132   $$(STT_$(1)): P2 = $$(word 9, $$(C0))
133   $$(STT_$(1)): P3 = $$(word 8, $$(C0))
134   $$(STT_$(1)): P4 = $$(shell grep "qed[.-]" $$(MAS_$(1)) | wc -l)
135   $$(STT_$(1)): D1 = $$(word 5, $$(C0))
136   $$(STT_$(1)): D2 = $$(word 7, $$(C0))
137   $$(STT_$(1)): D3 = $$(shell grep "defined[.-]" $$(MAS_$(1)) | wc -l)  
138   $$(STT_$(1)): M1 = $$(word 6, $$(C0))
139   $$(STT_$(1)): M2 = $$(shell grep "$$(OPEN)\*[^*:]*$$$$" $$(MAS_$(1)) | wc -l)
140   $$(STT_$(1)): M3 = $$(shell grep "(\*\*)" $$(MAS_$(1)) | wc -l)
141
142 $$(STT_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt
143         @printf '\x1B[1;40;37m'
144         @printf '%-15s %-46s' 'Statistics for:' $(1)
145         @printf '\x1B[0m\n'
146         @printf '\x1B[1;40;35m'
147         @printf '%-12s' '' 
148         @printf '   %-8s %6i' Chars $$(C2)
149         @printf '   %-7s %7i' Nodes $$(C3)
150         @printf '   %-11s' ''
151         @printf '\x1B[0m\n'
152         @printf '\x1B[1;40;36m'
153         @printf '%-8s %3i' Files $$(O1)
154         @printf '   %-8s %6i' Sources $$(O2)
155         @printf '   %-7s %7i' Objects $$(O3)
156         @printf '   %-11s' ''
157         @printf '\x1B[0m\n'     
158         @printf '\x1B[1;40;32m'
159         @printf '%-8s %3i' Theorems $$(P1)
160         @printf '   %-8s %6i' Lemmas $$(P2)
161         @printf '   %-7s %7i' Facts $$(P3)
162         @printf '   %-6s %4i' Proofs $$(P4)
163         @printf '\x1B[0m\n'     
164         @printf '\x1B[1;40;33m'
165         @printf '%-8s %3i' Declared $$(D1)
166         @printf '   %-8s %6i' Defined $$(D2)    
167         @printf '   %-7s %7i' Proved $$(D3)
168         @printf '   %-11s' ''
169         @printf '\x1B[0m\n'
170         @printf '\x1B[1;40;31m'
171         @printf '%-8s %3i' Axioms $$(M1)
172         @printf '   %-8s %6i' Comments $$(M2)
173         @printf '   %-7s %7i' Marks $$(M3)
174         @printf '   %-11s' ''
175         @printf '\x1B[0m\n'
176
177 .PHONY: $$(STT_$(1))
178 endef
179
180 ifeq ($(MAKECMDGOALS), stats)
181    $(foreach PKG, $(PACKAGES), $(eval $(call STATS_TEMPLATE,$(PKG))))
182 endif
183
184 stats: $(STTS)
185
186 # summary ####################################################################
187
188 define SUMMARY_TEMPLATE
189   SUM_$(1) := $(1)/web/$(1)_sum.tbl  
190   SUMS     += $$(SUM_$(1))
191
192   $$(SUM_$(1)): C0 = $$(shell cat $(1)/$(1)_probe.txt)
193   $$(SUM_$(1)): S1 = $$(word 1, $$(C0))
194   $$(SUM_$(1)): S2 = $$(word 2, $$(C0))
195   $$(SUM_$(1)): S3 = $$(word 3, $$(C0))
196   $$(SUM_$(1)): S4 = $$(word 4, $$(C0))
197   $$(SUM_$(1)): S5 = $$(shell printf "%.1f" `echo "scale=2;$$(S4)/$$(S2)"|bc`)
198   $$(SUM_$(1)): C1 = $$(word 5, $$(C0))
199   $$(SUM_$(1)): C2 = $$(word 7, $$(C0))
200   $$(SUM_$(1)): C3 = $$(shell echo "$$(C1)+$$(C2)"|bc)
201   $$(SUM_$(1)): P1 = $$(word 10, $$(C0))
202   $$(SUM_$(1)): P2 = $$(word 9, $$(C0))
203   $$(SUM_$(1)): P3 = $$(shell echo "$$(P1)+$$(P2)"|bc)
204
205   $$(SUM_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt Makefile
206         @printf '  SUMMARY $(1)\n'
207         @printf 'name "$$(basename $$(@F))"\n\n'                        >  $$@
208         @printf 'table {\n'                                             >> $$@
209         @printf '   class "gray"  [ "category"\n'                       >> $$@
210         @printf '      [ "units" * ]\n'                                 >> $$@
211         @printf '   ]\n'                                                >> $$@
212         @printf '   class "water" [ "sizes"\n'                          >> $$@
213         @printf '      [ "characters (files)"    "$$(S2) ($$(S1))" ]\n' >> $$@
214         @printf '      [ "nodes (objects)"       "$$(S4) ($$(S3))" ]\n' >> $$@
215         @printf '      [ "intrinsic loss factor" "$$(S5)" ]\n'          >> $$@
216         @printf '   ]\n'                                                >> $$@  
217         @printf '   class "green" [ "propositions"\n'                   >> $$@
218         @printf '      [ "theorems" "$$(P1)" ]\n'                       >> $$@
219         @printf '      [ "lemmas"   "$$(P2)" ]\n'                       >> $$@
220         @printf '      [ "total"    "$$(P3)" ]\n'                       >> $$@
221         @printf '   ]\n'                                                >> $$@
222         @printf '   class "grass" [ "concepts"\n'                       >> $$@
223         @printf '      [ "declared" "$$(C1)" ]\n'                       >> $$@
224         @printf '      [ "defined"  "$$(C2)" ]\n'                       >> $$@
225         @printf '      [ "total"    "$$(C3)" ]\n'                       >> $$@
226         @printf '   ]\n'                                                >> $$@
227         @printf '}\n\n'                                                 >> $$@
228         @printf 'class "capitalize italic" { 0 }\n\n'                   >> $$@
229         @printf 'class "italic"            { 1 } { 3 } { 5 }\n\n'       >> $$@
230         @printf 'class "right italic"      { 2 } { 4 } { 6 }\n'         >> $$@
231
232 .PHONY: $$(SUM_$(1))
233 endef
234
235 ifeq ($(MAKECMDGOALS), tbls)
236    $(foreach PKG, $(PACKAGES), $(eval $(call SUMMARY_TEMPLATE,$(PKG))))
237 endif
238
239 tbls: $(SUMS)
240
241 # trim #######################################################################
242
243 TRIMS := $(MAS) $(TBLS) $(LDWS)
244
245 %.trimmed: %
246         $(H)expand $< | $(TRIM) > $@
247         $(H)if diff $< $@ > /dev/null; then $(RM) $@; else echo "  TRIM $<" & mv $@ $<; fi
248
249 trim: $(TRIMS:%=%.trimmed)
250
251 # contrib ####################################################################
252
253 contrib:
254         @echo "  TAR -czf $(CONTRIB).tar.gz root $(XPACKAGES)"
255         $(H)tar -czf $(CONTRIB).tar.gz root $(XMAS)
256
257 # clean ######################################################################
258
259 clean:
260         $(H)$(RM) `find -name "*~" -type f -print`
261
262 # www ######################################################################
263
264 www:
265         $(H)$(MAKE) --no-print-directory -C $(WWW) www
266
267 # www ######################################################################
268
269 up-html:
270         $(H)$(MAKE) --no-print-directory -C $(WWW) up-html
271
272 ##############################################################################
273
274 .PHONY: $(TAGS)
275
276 .SUFFIXES: