4 TRIM := sed "s/ \\+$$//"
6 XOA_CONF := ground_2/xoa.conf.xml
7 XOA_TARGETS := ground_2/notation/xoa_notation.ma ground_2/xoa/xoa.ma
9 XOA_DIR := ../../../components/binaries/xoa
11 XOA_OPTS := ../../matita.conf.xml $(XOA_CONF)
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)
18 DEP_DIR := ../../../components/binaries/matitadep
19 DEP := matitadep.native
22 MAC_DIR := ../../../components/binaries/mac
26 PRB_DIR := ../../../components/binaries/probe
28 PRB_OPTS := $(XOA_OPTS) -g
31 ORIGS := basic_2/basic_1.orig
33 TAGS := all xoa xoa2 orig elim deps top leaf stats tbls trim
35 PACKAGES := ground_2 basic_2 apps_2
37 LDWS := $(shell find -name "*.ldw.xml")
38 TBLS := $(shell find -name "*.tbl")
43 # MAS ########################################################################
46 MAS_$(1) := $$(shell find $(1) -name "*.ma")
49 $(1)/$(1)_probe.txt: $$(MAS_$(1))
51 $$(H)$$(PRB_DIR)/$$(PRB) $$(PRB_OPTS) $(1) -sn -on -i > $$@
53 $(1)/$(1)_mac.txt: $$(MAS_$(1))
55 $$(H)$$(MAC_DIR)/$$(MAC) $$(MAC_OPTS) $$^ > $$@
58 $(foreach PKG, $(PACKAGES), $(eval $(call MAS_TEMPLATE,$(PKG))))
60 # xoa ########################################################################
64 $(XOA_TARGETS): $(XOA_CONF)
65 @echo " EXEC $(XOA) $(XOA_CONF)"
66 $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA_OPTS)
68 # xoa2 #######################################################################
72 $(XOA2_TARGETS): $(XOA2_CONF)
73 @echo " EXEC $(XOA) $(XOA2_CONF)"
74 $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA2_OPTS)
76 # elim #######################################################################
80 $(H)grep "elim (.*?)" $(MAS) || true
82 # orig #######################################################################
86 $(H)$(ORIG) basic_2 < $<
88 # dep input ##################################################################
92 $(H)grep "include \"" $^ > $(DEP_INPUT)
94 # dep ########################################################################
98 $(H)$(DEP_DIR)/$(DEP) -c $(DEP_OPTS) < $<
100 # top ########################################################################
103 @echo " MATITADEP -t"
104 $(H)$(DEP_DIR)/$(DEP) -t $(DEP_OPTS) < $<
106 # leaf #######################################################################
109 @echo " MATITADEP -l"
110 $(H)$(DEP_DIR)/$(DEP) -l $(DEP_OPTS) < $<
112 # stats ######################################################################
114 define STATS_TEMPLATE
115 STT_$(1) := $(1).stats
118 $$(STT_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
119 $$(STT_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
120 $$(STT_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
121 $$(STT_$(1)): P1 = $$(shell grep "^theorem " $$(MAS_$(1)) | wc -l)
122 $$(STT_$(1)): P2 = $$(shell grep "^lemma " $$(MAS_$(1)) | wc -l)
123 $$(STT_$(1)): P3 = $$(shell grep "^fact " $$(MAS_$(1)) | wc -l)
124 $$(STT_$(1)): P4 = $$(shell grep qed $$(MAS_$(1)) | wc -l)
125 $$(STT_$(1)): C1 = $$(shell grep "^inductive \|^record " $$(MAS_$(1)) | wc -l)
126 $$(STT_$(1)): C2 = $$(shell grep "^definition \|^let rec " $$(MAS_$(1)) | wc -l)
127 $$(STT_$(1)): M1 = $$(shell grep "^axiom " $$(MAS_$(1)) | wc -l)
128 $$(STT_$(1)): M2 = $$(shell grep "$$(OPEN)\*[^*:]*$$$$" $$(MAS_$(1)) | wc -l)
129 $$(STT_$(1)): M3 = $$(shell grep "(\*\*)" $$(MAS_$(1)) | wc -l)
131 $$(STT_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
132 @printf '\x1B[1;40;37m'
133 @printf '%-15s %-47s' 'Statistics for:' $(1)
135 @printf '\x1B[1;40;35m'
136 @printf '%-8s %6i' Chars $$(word 1, $$(S1))
137 @printf ' %-8s %4i' Pages $$(word 2, $$(S1))
138 @printf ' %-7s %7i' Nodes $$(word 3, $$(S0))
141 @printf '\x1B[1;40;36m'
142 @printf '%-8s %6i' Files $$(S4)
143 @printf ' %-8s %4i' Sources $$(word 1, $$(S0))
144 @printf ' %-7s %7i' Objects $$(word 2, $$(S0))
147 @printf '\x1B[1;40;32m'
148 @printf '%-8s %6i' Theorems $$(P1)
149 @printf ' %-8s %4i' Lemmas $$(P2)
150 @printf ' %-7s %7i' Facts $$(P3)
151 @printf ' %-6s %4i' Proofs $$(P4)
153 @printf '\x1B[1;40;33m'
154 @printf '%-8s %6i' Declared $$(C1)
155 @printf ' %-8s %4i' Defined $$(C2)
158 @printf '\x1B[1;40;31m'
159 @printf '%-8s %6i' Axioms $$(M1)
160 @printf ' %-8s %4i' Comments $$(M2)
161 @printf ' %-7s %7i' Marks $$(M3)
168 ifeq ($(MAKECMDGOALS), stats)
169 $(foreach PKG, $(PACKAGES), $(eval $(call STATS_TEMPLATE,$(PKG))))
174 # summary ####################################################################
176 define SUMMARY_TEMPLATE
177 SUM_$(1) := $(1)/web/$(1)_sum.tbl
180 $$(SUM_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
181 $$(SUM_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
182 $$(SUM_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
183 $$(SUM_$(1)): C1 = $$(shell grep "^inductive \|^record " $$(MAS_$(1)) | wc -l)
184 $$(SUM_$(1)): C2 = $$(shell grep "^definition \|^let rec " $$(MAS_$(1)) | wc -l)
185 $$(SUM_$(1)): C3 = $$(shell grep "^inductive \|^record \|^definition \|^let rec " $$(MAS_$(1)) | wc -l)
186 $$(SUM_$(1)): P1 = $$(shell grep "^theorem " $$(MAS_$(1)) | wc -l)
187 $$(SUM_$(1)): P2 = $$(shell grep "^lemma " $$(MAS_$(1)) | wc -l)
188 $$(SUM_$(1)): P3 = $$(shell grep "^lemma \|^theorem " $$(MAS_$(1)) | wc -l)
190 $$(SUM_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
191 @printf ' SUMMARY $(1)\n'
192 @printf 'name "$$(basename $$(@F))"\n\n' > $$@
193 @printf 'table {\n' >> $$@
194 @printf ' class "grey" [ "category"\n' >> $$@
195 @printf ' [ "objects" * ]\n' >> $$@
196 @printf ' ]\n' >> $$@
197 @printf ' class "cyan" [ "sizes"\n' >> $$@
198 @printf ' [ "files" "$$(S4)" ]\n' >> $$@
199 @printf ' [ "characters" "$$(word 1, $$(S1))" ]\n' >> $$@
200 @printf ' [ "nodes" "$$(word 3, $$(S0))" ]\n' >> $$@
201 @printf ' ]\n' >> $$@
202 @printf ' class "green" [ "propositions"\n' >> $$@
203 @printf ' [ "theorems" "$$(P1)" ]\n' >> $$@
204 @printf ' [ "lemmas" "$$(P2)" ]\n' >> $$@
205 @printf ' [ "total" "$$(P3)" ]\n' >> $$@
206 @printf ' ]\n' >> $$@
207 @printf ' class "yellow" [ "concepts"\n' >> $$@
208 @printf ' [ "declared" "$$(C1)" ]\n' >> $$@
209 @printf ' [ "defined" "$$(C2)" ]\n' >> $$@
210 @printf ' [ "total" "$$(C3)" ]\n' >> $$@
211 @printf ' ]\n' >> $$@
212 @printf '}\n\n' >> $$@
213 @printf 'class "component" { 0 }\n\n' >> $$@
214 @printf 'class "plane" { 1 } { 3 } { 5 }\n\n' >> $$@
215 @printf 'class "number" { 2 } { 4 } { 6 }\n' >> $$@
220 ifeq ($(MAKECMDGOALS), tbls)
221 $(foreach PKG, $(PACKAGES), $(eval $(call SUMMARY_TEMPLATE,$(PKG))))
226 # trim #######################################################################
228 TRIMS := $(MAS) $(TBLS) $(LDWS)
231 $(H)expand $< | $(TRIM) > $@
232 $(H)if diff $< $@ > /dev/null; then $(RM) $@; else echo " TRIM $<" & mv $@ $<; fi
234 trim: $(TRIMS:%=%.trimmed)
236 ##############################################################################