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 CONTRIB := lambdadelta_2
35 TAGS := all xoa xoa2 orig elim deps top leaf stats tbls trim contrib
37 PACKAGES := ground_2 basic_2 apps_2 alpha_1
38 XPACKAGES := ground_2 basic_2
40 LDWS := $(shell find -name "*.ldw.xml")
41 TBLS := $(shell find -name "*.tbl")
46 # MAS ########################################################################
49 MAS_$(1) := $$(shell find $(1) -name "*.ma")
52 $(1)/$(1)_probe.txt: $$(MAS_$(1))
54 $$(H)$$(PRB_DIR)/$$(PRB) $$(PRB_OPTS) $(1) -sn -on -i > $$@
56 $(1)/$(1)_mac.txt: $$(MAS_$(1))
58 $$(H)$$(MAC_DIR)/$$(MAC) $$(MAC_OPTS) $$^ > $$@
61 $(foreach PKG, $(PACKAGES), $(eval $(call MAS_TEMPLATE,$(PKG))))
63 # XMAS #######################################################################
69 $(foreach PKG, $(XPACKAGES), $(eval $(call XMAS_TEMPLATE,$(PKG))))
71 # xoa ########################################################################
75 $(XOA_TARGETS): $(XOA_CONF)
76 @echo " EXEC $(XOA) $(XOA_CONF)"
77 $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA_OPTS)
79 # xoa2 #######################################################################
83 $(XOA2_TARGETS): $(XOA2_CONF)
84 @echo " EXEC $(XOA) $(XOA2_CONF)"
85 $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA2_OPTS)
87 # elim #######################################################################
91 $(H)grep "elim (.*?)" $(MAS) || true
93 # orig #######################################################################
97 $(H)$(ORIG) basic_2 < $<
99 # dep input ##################################################################
102 @echo " GREP include"
103 $(H)grep "include \"" $^ > $(DEP_INPUT)
105 # dep ########################################################################
108 @echo " MATITADEP -c"
109 $(H)$(DEP_DIR)/$(DEP) -c $(DEP_OPTS) < $<
111 # top ########################################################################
114 @echo " MATITADEP -t"
115 $(H)$(DEP_DIR)/$(DEP) -t $(DEP_OPTS) < $<
117 # leaf #######################################################################
120 @echo " MATITADEP -l"
121 $(H)$(DEP_DIR)/$(DEP) -l $(DEP_OPTS) < $<
123 # stats ######################################################################
125 define STATS_TEMPLATE
126 STT_$(1) := $(1).stats
129 $$(STT_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
130 $$(STT_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
131 $$(STT_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
132 $$(STT_$(1)): P1 = $$(shell grep "^theorem " $$(MAS_$(1)) | wc -l)
133 $$(STT_$(1)): P2 = $$(shell grep "^lemma " $$(MAS_$(1)) | wc -l)
134 $$(STT_$(1)): P3 = $$(shell grep "^fact " $$(MAS_$(1)) | wc -l)
135 $$(STT_$(1)): P4 = $$(shell grep "qed[.-]" $$(MAS_$(1)) | wc -l)
136 $$(STT_$(1)): C1 = $$(shell grep "^inductive \|^record " $$(MAS_$(1)) | wc -l)
137 $$(STT_$(1)): C2 = $$(shell grep "^definition \|^let rec " $$(MAS_$(1)) | wc -l)
138 $$(STT_$(1)): C3 = $$(shell grep "defined[.-]" $$(MAS_$(1)) | wc -l)
139 $$(STT_$(1)): M1 = $$(shell grep "^axiom " $$(MAS_$(1)) | wc -l)
140 $$(STT_$(1)): M2 = $$(shell grep "$$(OPEN)\*[^*:]*$$$$" $$(MAS_$(1)) | wc -l)
141 $$(STT_$(1)): M3 = $$(shell grep "(\*\*)" $$(MAS_$(1)) | wc -l)
143 $$(STT_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
144 @printf '\x1B[1;40;37m'
145 @printf '%-15s %-47s' 'Statistics for:' $(1)
147 @printf '\x1B[1;40;35m'
148 @printf '%-8s %6i' Chars $$(word 1, $$(S1))
149 @printf ' %-8s %4i' Pages $$(word 2, $$(S1))
150 @printf ' %-7s %7i' Nodes $$(word 3, $$(S0))
153 @printf '\x1B[1;40;36m'
154 @printf '%-8s %6i' Files $$(S4)
155 @printf ' %-8s %4i' Sources $$(word 1, $$(S0))
156 @printf ' %-7s %7i' Objects $$(word 2, $$(S0))
159 @printf '\x1B[1;40;32m'
160 @printf '%-8s %6i' Theorems $$(P1)
161 @printf ' %-8s %4i' Lemmas $$(P2)
162 @printf ' %-7s %7i' Facts $$(P3)
163 @printf ' %-6s %4i' Proofs $$(P4)
165 @printf '\x1B[1;40;33m'
166 @printf '%-8s %6i' Declared $$(C1)
167 @printf ' %-8s %4i' Defined $$(C2)
168 @printf ' %-7s %7i' Proved $$(C3)
171 @printf '\x1B[1;40;31m'
172 @printf '%-8s %6i' Axioms $$(M1)
173 @printf ' %-8s %4i' Comments $$(M2)
174 @printf ' %-7s %7i' Marks $$(M3)
181 ifeq ($(MAKECMDGOALS), stats)
182 $(foreach PKG, $(PACKAGES), $(eval $(call STATS_TEMPLATE,$(PKG))))
187 # summary ####################################################################
189 define SUMMARY_TEMPLATE
190 SUM_$(1) := $(1)/web/$(1)_sum.tbl
193 $$(SUM_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
194 $$(SUM_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
195 $$(SUM_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
196 $$(SUM_$(1)): C1 = $$(shell grep "^inductive \|^record " $$(MAS_$(1)) | wc -l)
197 $$(SUM_$(1)): C2 = $$(shell grep "^definition \|^let rec " $$(MAS_$(1)) | wc -l)
198 $$(SUM_$(1)): C3 = $$(shell grep "^inductive \|^record \|^definition \|^let rec " $$(MAS_$(1)) | wc -l)
199 $$(SUM_$(1)): P1 = $$(shell grep "^theorem " $$(MAS_$(1)) | wc -l)
200 $$(SUM_$(1)): P2 = $$(shell grep "^lemma " $$(MAS_$(1)) | wc -l)
201 $$(SUM_$(1)): P3 = $$(shell grep "^lemma \|^theorem " $$(MAS_$(1)) | wc -l)
203 $$(SUM_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
204 @printf ' SUMMARY $(1)\n'
205 @printf 'name "$$(basename $$(@F))"\n\n' > $$@
206 @printf 'table {\n' >> $$@
207 @printf ' class "gray" [ "category"\n' >> $$@
208 @printf ' [ "objects" * ]\n' >> $$@
209 @printf ' ]\n' >> $$@
210 @printf ' class "cyan" [ "sizes"\n' >> $$@
211 @printf ' [ "files" "$$(S4)" ]\n' >> $$@
212 @printf ' [ "characters" "$$(word 1, $$(S1))" ]\n' >> $$@
213 @printf ' [ "nodes" "$$(word 3, $$(S0))" ]\n' >> $$@
214 @printf ' ]\n' >> $$@
215 @printf ' class "green" [ "propositions"\n' >> $$@
216 @printf ' [ "theorems" "$$(P1)" ]\n' >> $$@
217 @printf ' [ "lemmas" "$$(P2)" ]\n' >> $$@
218 @printf ' [ "total" "$$(P3)" ]\n' >> $$@
219 @printf ' ]\n' >> $$@
220 @printf ' class "yellow" [ "concepts"\n' >> $$@
221 @printf ' [ "declared" "$$(C1)" ]\n' >> $$@
222 @printf ' [ "defined" "$$(C2)" ]\n' >> $$@
223 @printf ' [ "total" "$$(C3)" ]\n' >> $$@
224 @printf ' ]\n' >> $$@
225 @printf '}\n\n' >> $$@
226 @printf 'class "capitalize italic" { 0 }\n\n' >> $$@
227 @printf 'class "italic" { 1 } { 3 } { 5 }\n\n' >> $$@
228 @printf 'class "right italic" { 2 } { 4 } { 6 }\n' >> $$@
233 ifeq ($(MAKECMDGOALS), tbls)
234 $(foreach PKG, $(PACKAGES), $(eval $(call SUMMARY_TEMPLATE,$(PKG))))
239 # trim #######################################################################
241 TRIMS := $(MAS) $(TBLS) $(LDWS)
244 $(H)expand $< | $(TRIM) > $@
245 $(H)if diff $< $@ > /dev/null; then $(RM) $@; else echo " TRIM $<" & mv $@ $<; fi
247 trim: $(TRIMS:%=%.trimmed)
249 # contrib ####################################################################
252 @echo " TAR -czf $(CONTRIB).tar.gz root $(XPACKAGES)"
253 $(H)tar -czf $(CONTRIB).tar.gz root $(XMAS)
255 ##############################################################################