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
39 LDWS := $(shell find -name "*.ldw.xml")
40 TBLS := $(shell find -name "*.tbl")
45 # MAS ########################################################################
48 MAS_$(1) := $$(shell find $(1) -name "*.ma")
51 $(1)/$(1)_probe.txt: $$(MAS_$(1))
53 $$(H)$$(PRB_DIR)/$$(PRB) $$(PRB_OPTS) $(1) -sn -on -i > $$@
55 $(1)/$(1)_mac.txt: $$(MAS_$(1))
57 $$(H)$$(MAC_DIR)/$$(MAC) $$(MAC_OPTS) $$^ > $$@
60 $(foreach PKG, $(PACKAGES), $(eval $(call MAS_TEMPLATE,$(PKG))))
62 # xoa ########################################################################
66 $(XOA_TARGETS): $(XOA_CONF)
67 @echo " EXEC $(XOA) $(XOA_CONF)"
68 $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA_OPTS)
70 # xoa2 #######################################################################
74 $(XOA2_TARGETS): $(XOA2_CONF)
75 @echo " EXEC $(XOA) $(XOA2_CONF)"
76 $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA2_OPTS)
78 # elim #######################################################################
82 $(H)grep "elim (.*?)" $(MAS) || true
84 # orig #######################################################################
88 $(H)$(ORIG) basic_2 < $<
90 # dep input ##################################################################
94 $(H)grep "include \"" $^ > $(DEP_INPUT)
96 # dep ########################################################################
100 $(H)$(DEP_DIR)/$(DEP) -c $(DEP_OPTS) < $<
102 # top ########################################################################
105 @echo " MATITADEP -t"
106 $(H)$(DEP_DIR)/$(DEP) -t $(DEP_OPTS) < $<
108 # leaf #######################################################################
111 @echo " MATITADEP -l"
112 $(H)$(DEP_DIR)/$(DEP) -l $(DEP_OPTS) < $<
114 # stats ######################################################################
116 define STATS_TEMPLATE
117 STT_$(1) := $(1).stats
120 $$(STT_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
121 $$(STT_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
122 $$(STT_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
123 $$(STT_$(1)): P1 = $$(shell grep "^theorem " $$(MAS_$(1)) | wc -l)
124 $$(STT_$(1)): P2 = $$(shell grep "^lemma " $$(MAS_$(1)) | wc -l)
125 $$(STT_$(1)): P3 = $$(shell grep "^fact " $$(MAS_$(1)) | wc -l)
126 $$(STT_$(1)): P4 = $$(shell grep qed $$(MAS_$(1)) | wc -l)
127 $$(STT_$(1)): C1 = $$(shell grep "^inductive \|^record " $$(MAS_$(1)) | wc -l)
128 $$(STT_$(1)): C2 = $$(shell grep "^definition \|^let rec " $$(MAS_$(1)) | wc -l)
129 $$(STT_$(1)): M1 = $$(shell grep "^axiom " $$(MAS_$(1)) | wc -l)
130 $$(STT_$(1)): M2 = $$(shell grep "$$(OPEN)\*[^*:]*$$$$" $$(MAS_$(1)) | wc -l)
131 $$(STT_$(1)): M3 = $$(shell grep "(\*\*)" $$(MAS_$(1)) | wc -l)
133 $$(STT_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
134 @printf '\x1B[1;40;37m'
135 @printf '%-15s %-47s' 'Statistics for:' $(1)
137 @printf '\x1B[1;40;35m'
138 @printf '%-8s %6i' Chars $$(word 1, $$(S1))
139 @printf ' %-8s %4i' Pages $$(word 2, $$(S1))
140 @printf ' %-7s %7i' Nodes $$(word 3, $$(S0))
143 @printf '\x1B[1;40;36m'
144 @printf '%-8s %6i' Files $$(S4)
145 @printf ' %-8s %4i' Sources $$(word 1, $$(S0))
146 @printf ' %-7s %7i' Objects $$(word 2, $$(S0))
149 @printf '\x1B[1;40;32m'
150 @printf '%-8s %6i' Theorems $$(P1)
151 @printf ' %-8s %4i' Lemmas $$(P2)
152 @printf ' %-7s %7i' Facts $$(P3)
153 @printf ' %-6s %4i' Proofs $$(P4)
155 @printf '\x1B[1;40;33m'
156 @printf '%-8s %6i' Declared $$(C1)
157 @printf ' %-8s %4i' Defined $$(C2)
160 @printf '\x1B[1;40;31m'
161 @printf '%-8s %6i' Axioms $$(M1)
162 @printf ' %-8s %4i' Comments $$(M2)
163 @printf ' %-7s %7i' Marks $$(M3)
170 ifeq ($(MAKECMDGOALS), stats)
171 $(foreach PKG, $(PACKAGES), $(eval $(call STATS_TEMPLATE,$(PKG))))
176 # summary ####################################################################
178 define SUMMARY_TEMPLATE
179 SUM_$(1) := $(1)/web/$(1)_sum.tbl
182 $$(SUM_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
183 $$(SUM_$(1)): S1 = $$(shell cat $(1)/$(1)_mac.txt)
184 $$(SUM_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
185 $$(SUM_$(1)): C1 = $$(shell grep "^inductive \|^record " $$(MAS_$(1)) | wc -l)
186 $$(SUM_$(1)): C2 = $$(shell grep "^definition \|^let rec " $$(MAS_$(1)) | wc -l)
187 $$(SUM_$(1)): C3 = $$(shell grep "^inductive \|^record \|^definition \|^let rec " $$(MAS_$(1)) | wc -l)
188 $$(SUM_$(1)): P1 = $$(shell grep "^theorem " $$(MAS_$(1)) | wc -l)
189 $$(SUM_$(1)): P2 = $$(shell grep "^lemma " $$(MAS_$(1)) | wc -l)
190 $$(SUM_$(1)): P3 = $$(shell grep "^lemma \|^theorem " $$(MAS_$(1)) | wc -l)
192 $$(SUM_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt $(1)/$(1)_mac.txt
193 @printf ' SUMMARY $(1)\n'
194 @printf 'name "$$(basename $$(@F))"\n\n' > $$@
195 @printf 'table {\n' >> $$@
196 @printf ' class "gray" [ "category"\n' >> $$@
197 @printf ' [ "objects" * ]\n' >> $$@
198 @printf ' ]\n' >> $$@
199 @printf ' class "cyan" [ "sizes"\n' >> $$@
200 @printf ' [ "files" "$$(S4)" ]\n' >> $$@
201 @printf ' [ "characters" "$$(word 1, $$(S1))" ]\n' >> $$@
202 @printf ' [ "nodes" "$$(word 3, $$(S0))" ]\n' >> $$@
203 @printf ' ]\n' >> $$@
204 @printf ' class "green" [ "propositions"\n' >> $$@
205 @printf ' [ "theorems" "$$(P1)" ]\n' >> $$@
206 @printf ' [ "lemmas" "$$(P2)" ]\n' >> $$@
207 @printf ' [ "total" "$$(P3)" ]\n' >> $$@
208 @printf ' ]\n' >> $$@
209 @printf ' class "yellow" [ "concepts"\n' >> $$@
210 @printf ' [ "declared" "$$(C1)" ]\n' >> $$@
211 @printf ' [ "defined" "$$(C2)" ]\n' >> $$@
212 @printf ' [ "total" "$$(C3)" ]\n' >> $$@
213 @printf ' ]\n' >> $$@
214 @printf '}\n\n' >> $$@
215 @printf 'class "component" { 0 }\n\n' >> $$@
216 @printf 'class "plane" { 1 } { 3 } { 5 }\n\n' >> $$@
217 @printf 'class "number" { 2 } { 4 } { 6 }\n' >> $$@
222 ifeq ($(MAKECMDGOALS), tbls)
223 $(foreach PKG, $(PACKAGES), $(eval $(call SUMMARY_TEMPLATE,$(PKG))))
228 # trim #######################################################################
230 TRIMS := $(MAS) $(TBLS) $(LDWS)
233 $(H)expand $< | $(TRIM) > $@
234 $(H)if diff $< $@ > /dev/null; then $(RM) $@; else echo " TRIM $<" & mv $@ $<; fi
236 trim: $(TRIMS:%=%.trimmed)
238 # contrib ####################################################################
241 @echo " TAR -czf $(CONTRIB).tar.gz root *.ma"
242 $(H)tar -czf $(CONTRIB).tar.gz root $(MAS)
244 ##############################################################################