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