]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/Makefile
- improved Makefile esp. with the "trim" function
[helm.git] / matita / matita / contribs / lambdadelta / Makefile
1 OPEN := (
2 H    := @
3
4 TRIM := sed "s/ \\+$$//"
5
6 XOA_DIR  := ../../../components/binaries/xoa
7 XOA      := xoa.native
8 DEP_DIR  := ../../../components/binaries/matitadep
9 DEP      := matitadep.native
10 MAC_DIR  := ../../../components/binaries/mac
11 MAC      := mac.native
12 PRB_DIR  := ../../../components/binaries/probe
13 PRB      := probe.native
14 PRB_OPTS := ../../matita.conf.xml -g
15
16 XOA_CONF    := ground_2/xoa.conf.xml
17 XOA_TARGETS := ground_2/xoa_notation.ma ground_2/xoa.ma
18
19 ORIG     := . ./orig.sh 
20
21 ORIGS    := basic_2/basic_1.orig
22
23 TAGS     := all xoa orig deps stats tbls trim
24
25 PACKAGES := ground_2 basic_2 apps_2
26
27 LDWS := $(shell find -name "*.ldw.xml")
28 TBLS := $(shell find -name "*.tbl")
29
30 all:
31         ../../matitac.opt
32
33 # MAS ########################################################################
34
35 define MAS_TEMPLATE
36   MAS_$(1) := $$(shell find $(1) -name "*.ma")
37   MAS      += $$(MAS_$(1))
38
39 $(1)/$(1)_probe.txt: $$(MAS_$(1))
40         @echo "  PROBE $(1)"
41         $$(H)$$(PRB_DIR)/$$(PRB) $$(PRB_OPTS) $(1) -sn -on -i > $$@
42 endef
43
44 $(foreach PKG, $(PACKAGES), $(eval $(call MAS_TEMPLATE,$(PKG))))
45
46 # xoa ########################################################################
47
48 xoa: $(XOA_TARGETS)
49
50 $(XOA_TARGETS): $(XOA_CONF)
51         @echo "  EXEC $(XOA) $(XOA_CONF)"
52         $(H)MATITA_RT_BASE_DIR=../.. $(XOA_DIR)/$(XOA) $(XOA_CONF)
53
54 # orig #######################################################################
55
56 orig: $(ORIGS)
57         @echo "  ORIG basic_2"
58         $(H)$(ORIG) basic_2 < $<
59
60 # dep ########################################################################
61
62 deps: $(DEP_DIR)/$(DEP)
63         @echo "  MATITADEP"
64         $(H)grep "include \"" $(MAS) | $<
65
66 # stats ######################################################################
67
68 define STATS_TEMPLATE
69   STT_$(1) := $(1).stats
70   STTS     += $$(STT_$(1))
71
72   $$(STT_$(1)): S1 := $$(shell $$(MAC_DIR)/$$(MAC) $$(MAS_$(1)))
73   $$(STT_$(1)): S2  = $$(shell echo $$$$(($$(S1) / 5120)))
74   $$(STT_$(1)): S4  = $$(shell ls $$(MAS_$(1)) | wc -l)
75   $$(STT_$(1)): S5  = $$(shell cat $(1)/$(1)_probe.txt)  
76   $$(STT_$(1)): P1  = $$(shell grep "theorem " $$(MAS_$(1)) | wc -l)
77   $$(STT_$(1)): P2  = $$(shell grep "lemma " $$(MAS_$(1)) | wc -l)
78   $$(STT_$(1)): P3  = $$(shell grep "fact " $$(MAS_$(1)) | wc -l)
79   $$(STT_$(1)): P4  = $$(shell grep qed $$(MAS_$(1)) | wc -l)
80   $$(STT_$(1)): C1  = $$(shell grep "inductive \|record " $$(MAS_$(1)) | wc -l)
81   $$(STT_$(1)): C2  = $$(shell grep "definition \|let rec " $$(MAS_$(1)) | wc -l)
82   $$(STT_$(1)): M1  = $$(shell grep "axiom " $$(MAS_$(1)) | wc -l)
83   $$(STT_$(1)): M2  = $$(shell grep "$$(OPEN)\*[^*:]*$$$$" $$(MAS_$(1)) | wc -l)
84   $$(STT_$(1)): M3  = $$(shell grep "(\*\*)" $$(MAS_$(1)) | wc -l)
85
86 $$(STT_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt
87         @printf '\x1B[1;40;37m'
88         @printf '%-15s %-47s' 'Statistics for:' $(1)
89         @printf '\x1B[0m\n'
90         @printf '\x1B[1;40;35m'
91         @printf '%-8s %6i' Chars $$(S1)
92         @printf '   %-8s %4i' Pages $$(S2)
93         @printf '   %-7s %7i' Nodes $$(word 3, $$(S5))
94         @printf '   %-11s' ''
95         @printf '\x1B[0m\n'
96         @printf '\x1B[1;40;36m'
97         @printf '%-8s %6i' Files $$(S4)
98         @printf '   %-8s %4i' Sources $$(word 1, $$(S5))
99         @printf '   %-7s %7i' Objects $$(word 2, $$(S5))
100         @printf '   %-11s' ''
101         @printf '\x1B[0m\n'     
102         @printf '\x1B[1;40;32m'
103         @printf '%-8s %6i' Theorems $$(P1)
104         @printf '   %-8s %4i' Lemmas $$(P2)
105         @printf '   %-7s %7i' Facts $$(P3)
106         @printf '   %-6s %4i' Proofs $$(P4)
107         @printf '\x1B[0m\n'     
108         @printf '\x1B[1;40;33m'
109         @printf '%-8s %6i' Declared $$(C1)
110         @printf '   %-8s %4i' Defined $$(C2)    
111         @printf '   %-29s' ''
112         @printf '\x1B[0m\n'
113         @printf '\x1B[1;40;31m'
114         @printf '%-8s %6i' Axioms $$(M1)
115         @printf '   %-8s %4i' Comments $$(M2)
116         @printf '   %-7s %7i' Marks $$(M3)
117         @printf '   %-11s' ''
118         @printf '\x1B[0m\n'
119
120 .PHONY: $$(STT_$(1))
121 endef
122
123 ifeq ($(MAKECMDGOALS), stats)
124    $(foreach PKG, $(PACKAGES), $(eval $(call STATS_TEMPLATE,$(PKG))))
125 endif
126
127 stats: $(STTS)
128
129 # summary ####################################################################
130
131 define SUMMARY_TEMPLATE
132   SUM_$(1) := $(1)/web/$(1)_sum.tbl  
133   SUMS     += $$(SUM_$(1))
134
135   $$(SUM_$(1)): S1 = $$(shell ls $$(MAS_$(1)) | wc -l)
136   $$(SUM_$(1)): S2 = $$(shell $$(MAC_DIR)/$$(MAC) $$(MAS_$(1)))
137   $$(SUM_$(1)): S3 = $$(shell cat $(1)/$(1)_probe.txt)
138   $$(SUM_$(1)): C1 = $$(shell grep "inductive \|record " $$(MAS_$(1)) | wc -l)
139   $$(SUM_$(1)): C2 = $$(shell grep "definition \|let rec " $$(MAS_$(1)) | wc -l)
140   $$(SUM_$(1)): C3 = $$(shell grep "inductive \|record \|definition \|let rec " $$(MAS_$(1)) | wc -l)
141   $$(SUM_$(1)): P1 = $$(shell grep "theorem " $$(MAS_$(1)) | wc -l)
142   $$(SUM_$(1)): P2 = $$(shell grep "lemma " $$(MAS_$(1)) | wc -l)
143   $$(SUM_$(1)): P3 = $$(shell grep "lemma \|theorem " $$(MAS_$(1)) | wc -l)
144
145   $$(SUM_$(1)): $$(MAS_$(1)) $(1)/$(1)_probe.txt
146         @printf '  SUMMARY $(1)\n'
147         @printf 'name "$$(basename $$(@F))"\n\n'           >  $$@
148         @printf 'table {\n'                                >> $$@
149         @printf '   class "grey" [ "category"\n'           >> $$@
150         @printf '      [ "objects" * ]\n'                  >> $$@
151         @printf '   ]\n'                                   >> $$@
152         @printf '   class "cyan" [ "sizes"\n'              >> $$@
153         @printf '      [ "files" "$$(S1)" ]\n'             >> $$@
154         @printf '      [ "characters" "$$(S2)" ]\n'        >> $$@
155         @printf '      [ "nodes" "$$(word 3, $$(S5))" ]\n' >> $$@
156         @printf '   ]\n'                                   >> $$@       
157         @printf '   class "green" [ "propositions"\n'      >> $$@
158         @printf '      [ "theorems" "$$(P1)" ]\n'          >> $$@
159         @printf '      [ "lemmas"   "$$(P2)" ]\n'          >> $$@
160         @printf '      [ "total"    "$$(P3)" ]\n'          >> $$@
161         @printf '   ]\n'                                   >> $$@
162         @printf '   class "yellow" [ "concepts"\n'         >> $$@
163         @printf '      [ "declared" "$$(C1)" ]\n'          >> $$@
164         @printf '      [ "defined"  "$$(C2)" ]\n'          >> $$@
165         @printf '      [ "total"    "$$(C3)" ]\n'          >> $$@
166         @printf '   ]\n'                                   >> $$@
167         @printf '}\n\n'                                    >> $$@
168         @printf 'class "component" { 0 }\n\n'              >> $$@
169         @printf 'class "plane" { 1 } { 3 } { 5 }\n\n'      >> $$@
170         @printf 'class "number" { 2 } { 4 } { 6 }\n\n'     >> $$@
171 endef
172
173 ifeq ($(MAKECMDGOALS), tbls)
174    $(foreach PKG, $(PACKAGES), $(eval $(call SUMMARY_TEMPLATE,$(PKG))))
175 endif
176
177 tbls: $(SUMS)
178
179 # trim #######################################################################
180
181 TRIMS := $(MAS) $(TBLS) $(LDWS)
182
183 %.trimmed: %
184         $(H)expand $< | $(TRIM) > $@
185         $(H)if diff $< $@ > /dev/null; then $(RM) $@; else echo "  TRIM $<" & mv $@ $<; fi
186
187 trim: $(TRIMS:%=%.trimmed)
188
189 ##############################################################################
190
191 .PHONY: $(TAGS)
192
193 .SUFFIXES: