4 TRIM := sed "s/ \\+$$//"
6 XOA_CONF := ground_2/xoa.conf.xml
7 XOA_TARGETS := ground_2/xoa_notation.ma ground_2/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/xoa2_notation.ma ground_2/xoa2.ma
15 XOA2_OPTS := ../../matita.conf.xml $(XOA2_CONF)
17 DEP_DIR := ../../../components/binaries/matitadep
18 DEP := matitadep.native
20 MAC_DIR := ../../../components/binaries/mac
24 PRB_DIR := ../../../components/binaries/probe
26 PRB_OPTS := $(XOA_OPTS) -g
29 ORIGS := basic_2/basic_1.orig
31 TAGS := all xoa xoa2 orig elim deps top stats tbls trim
33 PACKAGES := ground_2 basic_2 apps_2
35 LDWS := $(shell find -name "*.ldw.xml")
36 TBLS := $(shell find -name "*.tbl")
41 # MAS ########################################################################
44 MAS_$(1) := $$(shell find $(1) -name "*.ma")
47 $(1)/$(1)_probe.txt: $$(MAS_$(1))
49 $$(H)$$(PRB_DIR)/$$(PRB) $$(PRB_OPTS) $(1) -sn -on -i > $$@
51 $(1)/$(1)_mac.txt: $$(MAS_$(1))
53 $$(H)$$(MAC_DIR)/$$(MAC) $$(MAC_OPTS) $$^ > $$@
56 $(foreach PKG, $(PACKAGES), $(eval $(call MAS_TEMPLATE,$(PKG))))
58 # xoa ########################################################################
62 $(XOA_TARGETS): $(XOA_CONF)
63 @echo " EXEC $(XOA) $(XOA_CONF)"
64 $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA_OPTS)
66 # xoa2 #######################################################################
70 $(XOA2_TARGETS): $(XOA2_CONF)
71 @echo " EXEC $(XOA) $(XOA2_CONF)"
72 $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA2_OPTS)
74 # elim #######################################################################
78 $(H)grep "elim (.*?)" $(MAS) || true
80 # orig #######################################################################
84 $(H)$(ORIG) basic_2 < $<
86 # dep ########################################################################
88 deps: $(DEP_DIR)/$(DEP)
90 $(H)grep "include \"" $(MAS) | $<
92 # top ########################################################################
94 top: $(DEP_DIR)/$(DEP)
96 $(H)grep "include \"" $(MAS) | $< -t
98 # stats ######################################################################
100 define STATS_TEMPLATE
101 STT_$(1) := $(1).stats
104 $$(STT_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
105 $$(STT_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
106 $$(STT_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
107 $$(STT_$(1)): P1 = $$(shell grep "theorem " $$(MAS_$(1)) | wc -l)
108 $$(STT_$(1)): P2 = $$(shell grep "lemma " $$(MAS_$(1)) | wc -l)
109 $$(STT_$(1)): P3 = $$(shell grep "fact " $$(MAS_$(1)) | wc -l)
110 $$(STT_$(1)): P4 = $$(shell grep qed $$(MAS_$(1)) | wc -l)
111 $$(STT_$(1)): C1 = $$(shell grep "inductive \|record " $$(MAS_$(1)) | wc -l)
112 $$(STT_$(1)): C2 = $$(shell grep "definition \|let rec " $$(MAS_$(1)) | wc -l)
113 $$(STT_$(1)): M1 = $$(shell grep "axiom " $$(MAS_$(1)) | wc -l)
114 $$(STT_$(1)): M2 = $$(shell grep "$$(OPEN)\*[^*:]*$$$$" $$(MAS_$(1)) | wc -l)
115 $$(STT_$(1)): M3 = $$(shell grep "(\*\*)" $$(MAS_$(1)) | wc -l)
117 $$(STT_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
118 @printf '\x1B[1;40;37m'
119 @printf '%-15s %-47s' 'Statistics for:' $(1)
121 @printf '\x1B[1;40;35m'
122 @printf '%-8s %6i' Chars $$(word 1, $$(S1))
123 @printf ' %-8s %4i' Pages $$(word 2, $$(S1))
124 @printf ' %-7s %7i' Nodes $$(word 3, $$(S0))
127 @printf '\x1B[1;40;36m'
128 @printf '%-8s %6i' Files $$(S4)
129 @printf ' %-8s %4i' Sources $$(word 1, $$(S0))
130 @printf ' %-7s %7i' Objects $$(word 2, $$(S0))
133 @printf '\x1B[1;40;32m'
134 @printf '%-8s %6i' Theorems $$(P1)
135 @printf ' %-8s %4i' Lemmas $$(P2)
136 @printf ' %-7s %7i' Facts $$(P3)
137 @printf ' %-6s %4i' Proofs $$(P4)
139 @printf '\x1B[1;40;33m'
140 @printf '%-8s %6i' Declared $$(C1)
141 @printf ' %-8s %4i' Defined $$(C2)
144 @printf '\x1B[1;40;31m'
145 @printf '%-8s %6i' Axioms $$(M1)
146 @printf ' %-8s %4i' Comments $$(M2)
147 @printf ' %-7s %7i' Marks $$(M3)
154 ifeq ($(MAKECMDGOALS), stats)
155 $(foreach PKG, $(PACKAGES), $(eval $(call STATS_TEMPLATE,$(PKG))))
160 # summary ####################################################################
162 define SUMMARY_TEMPLATE
163 SUM_$(1) := $(1)/web/$(1)_sum.tbl
166 $$(SUM_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
167 $$(SUM_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
168 $$(SUM_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
169 $$(SUM_$(1)): C1 = $$(shell grep "inductive \|record " $$(MAS_$(1)) | wc -l)
170 $$(SUM_$(1)): C2 = $$(shell grep "definition \|let rec " $$(MAS_$(1)) | wc -l)
171 $$(SUM_$(1)): C3 = $$(shell grep "inductive \|record \|definition \|let rec " $$(MAS_$(1)) | wc -l)
172 $$(SUM_$(1)): P1 = $$(shell grep "theorem " $$(MAS_$(1)) | wc -l)
173 $$(SUM_$(1)): P2 = $$(shell grep "lemma " $$(MAS_$(1)) | wc -l)
174 $$(SUM_$(1)): P3 = $$(shell grep "lemma \|theorem " $$(MAS_$(1)) | wc -l)
176 $$(SUM_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
177 @printf ' SUMMARY $(1)\n'
178 @printf 'name "$$(basename $$(@F))"\n\n' > $$@
179 @printf 'table {\n' >> $$@
180 @printf ' class "grey" [ "category"\n' >> $$@
181 @printf ' [ "objects" * ]\n' >> $$@
182 @printf ' ]\n' >> $$@
183 @printf ' class "cyan" [ "sizes"\n' >> $$@
184 @printf ' [ "files" "$$(S4)" ]\n' >> $$@
185 @printf ' [ "characters" "$$(word 1, $$(S1))" ]\n' >> $$@
186 @printf ' [ "nodes" "$$(word 3, $$(S0))" ]\n' >> $$@
187 @printf ' ]\n' >> $$@
188 @printf ' class "green" [ "propositions"\n' >> $$@
189 @printf ' [ "theorems" "$$(P1)" ]\n' >> $$@
190 @printf ' [ "lemmas" "$$(P2)" ]\n' >> $$@
191 @printf ' [ "total" "$$(P3)" ]\n' >> $$@
192 @printf ' ]\n' >> $$@
193 @printf ' class "yellow" [ "concepts"\n' >> $$@
194 @printf ' [ "declared" "$$(C1)" ]\n' >> $$@
195 @printf ' [ "defined" "$$(C2)" ]\n' >> $$@
196 @printf ' [ "total" "$$(C3)" ]\n' >> $$@
197 @printf ' ]\n' >> $$@
198 @printf '}\n\n' >> $$@
199 @printf 'class "component" { 0 }\n\n' >> $$@
200 @printf 'class "plane" { 1 } { 3 } { 5 }\n\n' >> $$@
201 @printf 'class "number" { 2 } { 4 } { 6 }\n' >> $$@
206 ifeq ($(MAKECMDGOALS), tbls)
207 $(foreach PKG, $(PACKAGES), $(eval $(call SUMMARY_TEMPLATE,$(PKG))))
212 # trim #######################################################################
214 TRIMS := $(MAS) $(TBLS) $(LDWS)
217 $(H)expand $< | $(TRIM) > $@
218 $(H)if diff $< $@ > /dev/null; then $(RM) $@; else echo " TRIM $<" & mv $@ $<; fi
220 trim: $(TRIMS:%=%.trimmed)
222 ##############################################################################