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 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)
80 # orig #######################################################################
84 $(H)$(ORIG) basic_2 < $<
86 # dep ########################################################################
88 deps: $(DEP_DIR)/$(DEP)
90 $(H)grep "include \"" $(MAS) | $<
92 # stats ######################################################################
95 STT_$(1) := $(1).stats
98 $$(STT_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
99 $$(STT_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
100 $$(STT_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
101 $$(STT_$(1)): P1 = $$(shell grep "theorem " $$(MAS_$(1)) | wc -l)
102 $$(STT_$(1)): P2 = $$(shell grep "lemma " $$(MAS_$(1)) | wc -l)
103 $$(STT_$(1)): P3 = $$(shell grep "fact " $$(MAS_$(1)) | wc -l)
104 $$(STT_$(1)): P4 = $$(shell grep qed $$(MAS_$(1)) | wc -l)
105 $$(STT_$(1)): C1 = $$(shell grep "inductive \|record " $$(MAS_$(1)) | wc -l)
106 $$(STT_$(1)): C2 = $$(shell grep "definition \|let rec " $$(MAS_$(1)) | wc -l)
107 $$(STT_$(1)): M1 = $$(shell grep "axiom " $$(MAS_$(1)) | wc -l)
108 $$(STT_$(1)): M2 = $$(shell grep "$$(OPEN)\*[^*:]*$$$$" $$(MAS_$(1)) | wc -l)
109 $$(STT_$(1)): M3 = $$(shell grep "(\*\*)" $$(MAS_$(1)) | wc -l)
111 $$(STT_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
112 @printf '\x1B[1;40;37m'
113 @printf '%-15s %-47s' 'Statistics for:' $(1)
115 @printf '\x1B[1;40;35m'
116 @printf '%-8s %6i' Chars $$(word 1, $$(S1))
117 @printf ' %-8s %4i' Pages $$(word 2, $$(S1))
118 @printf ' %-7s %7i' Nodes $$(word 3, $$(S0))
121 @printf '\x1B[1;40;36m'
122 @printf '%-8s %6i' Files $$(S4)
123 @printf ' %-8s %4i' Sources $$(word 1, $$(S0))
124 @printf ' %-7s %7i' Objects $$(word 2, $$(S0))
127 @printf '\x1B[1;40;32m'
128 @printf '%-8s %6i' Theorems $$(P1)
129 @printf ' %-8s %4i' Lemmas $$(P2)
130 @printf ' %-7s %7i' Facts $$(P3)
131 @printf ' %-6s %4i' Proofs $$(P4)
133 @printf '\x1B[1;40;33m'
134 @printf '%-8s %6i' Declared $$(C1)
135 @printf ' %-8s %4i' Defined $$(C2)
138 @printf '\x1B[1;40;31m'
139 @printf '%-8s %6i' Axioms $$(M1)
140 @printf ' %-8s %4i' Comments $$(M2)
141 @printf ' %-7s %7i' Marks $$(M3)
148 ifeq ($(MAKECMDGOALS), stats)
149 $(foreach PKG, $(PACKAGES), $(eval $(call STATS_TEMPLATE,$(PKG))))
154 # summary ####################################################################
156 define SUMMARY_TEMPLATE
157 SUM_$(1) := $(1)/web/$(1)_sum.tbl
160 $$(SUM_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
161 $$(SUM_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
162 $$(SUM_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
163 $$(SUM_$(1)): C1 = $$(shell grep "inductive \|record " $$(MAS_$(1)) | wc -l)
164 $$(SUM_$(1)): C2 = $$(shell grep "definition \|let rec " $$(MAS_$(1)) | wc -l)
165 $$(SUM_$(1)): C3 = $$(shell grep "inductive \|record \|definition \|let rec " $$(MAS_$(1)) | wc -l)
166 $$(SUM_$(1)): P1 = $$(shell grep "theorem " $$(MAS_$(1)) | wc -l)
167 $$(SUM_$(1)): P2 = $$(shell grep "lemma " $$(MAS_$(1)) | wc -l)
168 $$(SUM_$(1)): P3 = $$(shell grep "lemma \|theorem " $$(MAS_$(1)) | wc -l)
170 $$(SUM_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
171 @printf ' SUMMARY $(1)\n'
172 @printf 'name "$$(basename $$(@F))"\n\n' > $$@
173 @printf 'table {\n' >> $$@
174 @printf ' class "grey" [ "category"\n' >> $$@
175 @printf ' [ "objects" * ]\n' >> $$@
176 @printf ' ]\n' >> $$@
177 @printf ' class "cyan" [ "sizes"\n' >> $$@
178 @printf ' [ "files" "$$(S4)" ]\n' >> $$@
179 @printf ' [ "characters" "$$(word 1, $$(S1))" ]\n' >> $$@
180 @printf ' [ "nodes" "$$(word 3, $$(S0))" ]\n' >> $$@
181 @printf ' ]\n' >> $$@
182 @printf ' class "green" [ "propositions"\n' >> $$@
183 @printf ' [ "theorems" "$$(P1)" ]\n' >> $$@
184 @printf ' [ "lemmas" "$$(P2)" ]\n' >> $$@
185 @printf ' [ "total" "$$(P3)" ]\n' >> $$@
186 @printf ' ]\n' >> $$@
187 @printf ' class "yellow" [ "concepts"\n' >> $$@
188 @printf ' [ "declared" "$$(C1)" ]\n' >> $$@
189 @printf ' [ "defined" "$$(C2)" ]\n' >> $$@
190 @printf ' [ "total" "$$(C3)" ]\n' >> $$@
191 @printf ' ]\n' >> $$@
192 @printf '}\n\n' >> $$@
193 @printf 'class "component" { 0 }\n\n' >> $$@
194 @printf 'class "plane" { 1 } { 3 } { 5 }\n\n' >> $$@
195 @printf 'class "number" { 2 } { 4 } { 6 }\n' >> $$@
200 ifeq ($(MAKECMDGOALS), tbls)
201 $(foreach PKG, $(PACKAGES), $(eval $(call SUMMARY_TEMPLATE,$(PKG))))
206 # trim #######################################################################
208 TRIMS := $(MAS) $(TBLS) $(LDWS)
211 $(H)expand $< | $(TRIM) > $@
212 $(H)if diff $< $@ > /dev/null; then $(RM) $@; else echo " TRIM $<" & mv $@ $<; fi
214 trim: $(TRIMS:%=%.trimmed)
216 ##############################################################################