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 DEP_DIR := ../../../components/binaries/matitadep
14 DEP := matitadep.native
16 MAC_DIR := ../../../components/binaries/mac
19 PRB_DIR := ../../../components/binaries/probe
21 PRB_OPTS := $(XOA_OPTS) -g
24 ORIGS := basic_2/basic_1.orig
26 TAGS := all xoa orig deps stats tbls trim
28 PACKAGES := ground_2 basic_2 apps_2
30 LDWS := $(shell find -name "*.ldw.xml")
31 TBLS := $(shell find -name "*.tbl")
36 # MAS ########################################################################
39 MAS_$(1) := $$(shell find $(1) -name "*.ma")
42 $(1)/$(1)_probe.txt: $$(MAS_$(1))
44 $$(H)$$(PRB_DIR)/$$(PRB) $$(PRB_OPTS) $(1) -sn -on -i > $$@
47 $(foreach PKG, $(PACKAGES), $(eval $(call MAS_TEMPLATE,$(PKG))))
49 # xoa ########################################################################
53 $(XOA_TARGETS): $(XOA_CONF)
54 @echo " EXEC $(XOA) $(XOA_CONF)"
55 $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA_OPTS)
57 # orig #######################################################################
61 $(H)$(ORIG) basic_2 < $<
63 # dep ########################################################################
65 deps: $(DEP_DIR)/$(DEP)
67 $(H)grep "include \"" $(MAS) | $<
69 # stats ######################################################################
72 STT_$(1) := $(1).stats
75 $$(STT_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
76 $$(STT_$(1)): S1 := $$(shell $$(MAC_DIR)/$$(MAC) $$(MAS_$(1)))
77 $$(STT_$(1)): S3 = $$(shell echo $$$$(($$(S1) / 5120)))
78 $$(STT_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
79 $$(STT_$(1)): P1 = $$(shell grep "theorem " $$(MAS_$(1)) | wc -l)
80 $$(STT_$(1)): P2 = $$(shell grep "lemma " $$(MAS_$(1)) | wc -l)
81 $$(STT_$(1)): P3 = $$(shell grep "fact " $$(MAS_$(1)) | wc -l)
82 $$(STT_$(1)): P4 = $$(shell grep qed $$(MAS_$(1)) | wc -l)
83 $$(STT_$(1)): C1 = $$(shell grep "inductive \|record " $$(MAS_$(1)) | wc -l)
84 $$(STT_$(1)): C2 = $$(shell grep "definition \|let rec " $$(MAS_$(1)) | wc -l)
85 $$(STT_$(1)): M1 = $$(shell grep "axiom " $$(MAS_$(1)) | wc -l)
86 $$(STT_$(1)): M2 = $$(shell grep "$$(OPEN)\*[^*:]*$$$$" $$(MAS_$(1)) | wc -l)
87 $$(STT_$(1)): M3 = $$(shell grep "(\*\*)" $$(MAS_$(1)) | wc -l)
89 $$(STT_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt
90 @printf '\x1B[1;40;37m'
91 @printf '%-15s %-47s' 'Statistics for:' $(1)
93 @printf '\x1B[1;40;35m'
94 @printf '%-8s %6i' Chars $$(S1)
95 @printf ' %-8s %4i' Pages $$(S3)
96 @printf ' %-7s %7i' Nodes $$(word 3, $$(S0))
99 @printf '\x1B[1;40;36m'
100 @printf '%-8s %6i' Files $$(S4)
101 @printf ' %-8s %4i' Sources $$(word 1, $$(S0))
102 @printf ' %-7s %7i' Objects $$(word 2, $$(S0))
105 @printf '\x1B[1;40;32m'
106 @printf '%-8s %6i' Theorems $$(P1)
107 @printf ' %-8s %4i' Lemmas $$(P2)
108 @printf ' %-7s %7i' Facts $$(P3)
109 @printf ' %-6s %4i' Proofs $$(P4)
111 @printf '\x1B[1;40;33m'
112 @printf '%-8s %6i' Declared $$(C1)
113 @printf ' %-8s %4i' Defined $$(C2)
116 @printf '\x1B[1;40;31m'
117 @printf '%-8s %6i' Axioms $$(M1)
118 @printf ' %-8s %4i' Comments $$(M2)
119 @printf ' %-7s %7i' Marks $$(M3)
126 ifeq ($(MAKECMDGOALS), stats)
127 $(foreach PKG, $(PACKAGES), $(eval $(call STATS_TEMPLATE,$(PKG))))
132 # summary ####################################################################
134 define SUMMARY_TEMPLATE
135 SUM_$(1) := $(1)/web/$(1)_sum.tbl
138 $$(SUM_$(1)): S0 = $$(shell cat $(1)/$(1)_probe.txt)
139 $$(SUM_$(1)): S1 = $$(shell $$(MAC_DIR)/$$(MAC) $$(MAS_$(1)))
140 $$(SUM_$(1)): S4 = $$(shell ls $$(MAS_$(1)) | wc -l)
141 $$(SUM_$(1)): C1 = $$(shell grep "inductive \|record " $$(MAS_$(1)) | wc -l)
142 $$(SUM_$(1)): C2 = $$(shell grep "definition \|let rec " $$(MAS_$(1)) | wc -l)
143 $$(SUM_$(1)): C3 = $$(shell grep "inductive \|record \|definition \|let rec " $$(MAS_$(1)) | wc -l)
144 $$(SUM_$(1)): P1 = $$(shell grep "theorem " $$(MAS_$(1)) | wc -l)
145 $$(SUM_$(1)): P2 = $$(shell grep "lemma " $$(MAS_$(1)) | wc -l)
146 $$(SUM_$(1)): P3 = $$(shell grep "lemma \|theorem " $$(MAS_$(1)) | wc -l)
148 $$(SUM_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt
149 @printf ' SUMMARY $(1)\n'
150 @printf 'name "$$(basename $$(@F))"\n\n' > $$@
151 @printf 'table {\n' >> $$@
152 @printf ' class "grey" [ "category"\n' >> $$@
153 @printf ' [ "objects" * ]\n' >> $$@
154 @printf ' ]\n' >> $$@
155 @printf ' class "cyan" [ "sizes"\n' >> $$@
156 @printf ' [ "files" "$$(S4)" ]\n' >> $$@
157 @printf ' [ "characters" "$$(S1)" ]\n' >> $$@
158 @printf ' [ "nodes" "$$(word 3, $$(S0))" ]\n' >> $$@
159 @printf ' ]\n' >> $$@
160 @printf ' class "green" [ "propositions"\n' >> $$@
161 @printf ' [ "theorems" "$$(P1)" ]\n' >> $$@
162 @printf ' [ "lemmas" "$$(P2)" ]\n' >> $$@
163 @printf ' [ "total" "$$(P3)" ]\n' >> $$@
164 @printf ' ]\n' >> $$@
165 @printf ' class "yellow" [ "concepts"\n' >> $$@
166 @printf ' [ "declared" "$$(C1)" ]\n' >> $$@
167 @printf ' [ "defined" "$$(C2)" ]\n' >> $$@
168 @printf ' [ "total" "$$(C3)" ]\n' >> $$@
169 @printf ' ]\n' >> $$@
170 @printf '}\n\n' >> $$@
171 @printf 'class "component" { 0 }\n\n' >> $$@
172 @printf 'class "plane" { 1 } { 3 } { 5 }\n\n' >> $$@
173 @printf 'class "number" { 2 } { 4 } { 6 }\n' >> $$@
176 ifeq ($(MAKECMDGOALS), tbls)
177 $(foreach PKG, $(PACKAGES), $(eval $(call SUMMARY_TEMPLATE,$(PKG))))
182 # trim #######################################################################
184 TRIMS := $(MAS) $(TBLS) $(LDWS)
187 $(H)expand $< | $(TRIM) > $@
188 $(H)if diff $< $@ > /dev/null; then $(RM) $@; else echo " TRIM $<" & mv $@ $<; fi
190 trim: $(TRIMS:%=%.trimmed)
192 ##############################################################################