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