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