File: Makefile.am

package info (click to toggle)
msc-generator 8.6.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 180,484 kB
  • sloc: cpp: 129,931; yacc: 23,655; ansic: 7,464; sh: 5,026; makefile: 948
file content (242 lines) | stat: -rw-r--r-- 14,015 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
check_PROGRAMS = pngdiff contours
dist_check_SCRIPTS = hint.sh ppt2png.sh

AM_CPPFLAGS = -I$(top_srcdir)/src/libcgencommon -I$(top_builddir)/src/libcgencommon
AM_CPPFLAGS += -include arm_vector.h
AM_CXXFLAGS += $(CAIRO_CFLAGS)
AM_DEFAULT_SOURCE_EXT = .cpp

pngdiff_LDADD = $(CAIRO_LIBS)

contours_SOURCES = contour_test_experiment.cpp contour_unit_test.cpp contour_test.cpp contours.cpp contour_test.h
contours_LDADD = ../src/libcgencommon/libcgencommon.a -lpthread $(CAIRO_LIBS) $(LIBPNG_LIBS) $(ZIP_LIBS) $(TINYXML_LIBS)
if HAS_FONTCONFIG
contours_LDADD += -lfontconfig
endif HAS_FONTCONFIG

EXTRA_PROGRAMS = perftest
perftest_SOURCES = contour_test_perf.cpp
perftest_LDADD = ../src/libcgencommon/libcgencommon.a -lpthread -lbenchmark $(CAIRO_LIBS) $(LIBPNG_LIBS) $(ZIP_LIBS)
perftest_CXXFLAGS = $(AM_CXXFLAGS) -O3

# Test control variables with defaults to allow putting them either in the environment or specify as an argument to `make`
MSC_TEST_ALLOWFAIL ?=        # show failing test stats but continue
MSC_TEST_COLLECT_CHANGED ?=  # collect all evidence of failing tests to changed/
MSC_TEST_DUMP_DIFF ?= 0      # dump this many PNG diffs and _new artifacts as text
MSC_TEST_NOFONT ?=           # compare to NOFONT variants in pngdiff

MSCGEN = $(top_builddir)/src/unix-msc-gen/msc-gen
MSCGEN_OPTS = -T png -s=4 --nocopyright -Pno --nopaths -F 'Nimbus Sans'
CONTOURS_OPTS = -F'DejaVu Sans'
MSC_SUBDIRS = doc basic notes procedures blocks
MSC_SUFFICES = signalling block graph

TIMEOUT_CMD = $(TIMEOUT_CMD_$(MSC_TEST_ALLOWFAIL))
TIMEOUT_CMD_1 = timeout -k 3 --preserve-status -v 30m

canon = $(dir $(1))canonical/$(notdir $(1))
rmcanon = $(subst canonical/,,$(1))
addsrc = $(addprefix $(srcdir)/,$(1))
rmsrc = $(patsubst $(srcdir)/%,%,$(1))

## singlepage(DIR,SUFFIX)
##  dir/ is required in the first target to be able to change first prereq's dir part
define singlepage
$(1)/%.png: $(call addsrc,$(1)/%.$(2)) $$(MSCGEN)
	$$(AM_V_at)$$(MKDIR_P) $(1)
	$$(AM_V_GEN)$$(TIMEOUT_CMD) $$(MSCGEN) $$(MSCGEN_OPTS) -o $$@ $$< 2>$$(basename $$@).err || touch $$@ $$(basename $$@).err
	$$(AM_V_at)[ "$$(MSC_TEST_NOFONT)" != 1 ] || MSCGEN_NOFONT=1 $$(TIMEOUT_CMD) $$(MSCGEN) $$(MSCGEN_OPTS) -o $$@_nofont $$< 2>/dev/null || true
%.exit: %.png pngdiff
	$$(AM_V_at){ orig=$$(call addsrc,$$(call canon,$$*)); e=$$*.err_new; d=$$*.err_diff; \
	  { [[ -f $$$$orig.err ]] && cat $$$$orig.err || echo Success.; } | \
	  { $(WORD_DIFF) <(sort) <(sort $$*.err) >$$$$d \
	    && { rm $$$$d; ./pngdiff $$< $$$$orig.png `[ ! -f $$<_nofont ] || echo $$<_nofont` && echo 0 || { echo $$$$?; mv $$< $$(patsubst %.png,%_new.png,$$<); } } \
	    || { echo 4; mv $$*.err $$$$e; \
	         [[ $(AHA) != : ]] && $(AHA) -b -w <$$$$d >$$$$d.html && $(AHA) -b -w <$$$$e >$$$$e.html || true; } \
	  } >$$@; }
endef

## multipage(PNG,MSC)
##  almost the copy of singlepage, with some target file name changes
define multipage
$(1): $(call addsrc,$(2)) $$(MSCGEN)
	$$(AM_V_at)$$(MKDIR_P) $(dir $(1))
	$$(AM_V_GEN)$$(TIMEOUT_CMD) $$(MSCGEN) $$(MSCGEN_OPTS) -o $$(basename $(2)).png $$< 2>$$(basename $(2)).err || touch $$(basename $(2)).png $$(basename $(2)).err
	$$(AM_V_at)[ "$$(MSC_TEST_NOFONT)" != 1 ] || MSCGEN_NOFONT=1 $$(TIMEOUT_CMD) $$(MSCGEN) $$(MSCGEN_OPTS) -o $$(basename $(2)).png_nofont $$< 2>/dev/null || true
$(basename $(1)).exit: $(1) pngdiff
	$$(AM_V_at){ err=$(call addsrc,$(call canon,$(basename $(2)))).err; e=$(basename $(2)).err; d=$$(basename $$@).err_diff; \
	  { [[ -f $$$$err ]] && cat $$$$err || echo Success.; } | \
	  { $(WORD_DIFF) <(sort) <(sort $$$$e) >$$$$d \
	    && { rm $$$$d; ./pngdiff $$< $$(call addsrc,$$(call canon,$$<)) `[ ! -f $$<_nofont ] || echo $$<_nofont` && echo 0 || { echo $$$$?; mv $$< $$(patsubst %.png,%_new.png,$$<); } } \
	    || { echo 4; cp $$$$e $$$${e}_new; \
	         [[ $(AHA) != : ]] && $(AHA) -b -w <$$$$d >$$$$d.html && $(AHA) -b -w <$$$${e}_new >$$$${e}_new.html || true; } \
	  } >$$@; }
endef
## would have been tempting to put a `PNGS += $(1)` into the rule but automake removes '+=' lines when producing Makefile.in

## diffonly(PNG)
##  almost-copy of the pngdiff part
define diffonly
$(1): unit_tests
$(basename $(1)).exit: $(1) pngdiff
	$$(AM_V_at){ ./pngdiff $$< $$(call addsrc,$$(call canon,$$<)) && echo 0 || { echo $$$$?; mv $$< $$(patsubst %.png,%_new.png,$$<); } } >$$@
endef

$(foreach d,$(MSC_SUBDIRS),$(foreach s,$(MSC_SUFFICES),$(eval $(call singlepage,$(d),$(s)))))

MSCS = $(foreach d,$(MSC_SUBDIRS),$(wildcard $(foreach s,$(MSC_SUFFICES),$(srcdir)/$(d)/*.$(s))))
EXTRA_DIST = $(MSCS) $(shell find $(srcdir) -type d -name canonical)
PNGS =
# Handle 2-page examples separately
if MSC_CHECK_FONTS
PNGS += $(filter-out doc/ex28.png \
                    basic/basic.png basic/ex28_color.png basic/ex28_color3.png basic/pagebreak.png basic/Problem.png \
                    procedures/pagebreak_proc.png procedures/Problem_proc.png procedures/basic_graph_proc.png \
                    ,$(addsuffix .png,$(call rmsrc,$(basename $(MSCS)))))
# Exceptions from doc/
$(eval $(call multipage,doc/ex2801.png,doc/ex28.signalling))
$(eval $(call multipage,doc/ex2802.png,doc/ex28.signalling))
PNGS += doc/ex2801.png doc/ex2802.png
# ... basic/
$(eval $(call multipage,basic/basic01.png,basic/basic.graph))
$(eval $(call multipage,basic/basic02.png,basic/basic.graph))
$(eval $(call multipage,basic/Problem01.png,basic/Problem.signalling))
$(eval $(call multipage,basic/Problem02.png,basic/Problem.signalling))
$(eval $(call multipage,basic/pagebreak01.png,basic/pagebreak.signalling))
$(eval $(call multipage,basic/pagebreak02.png,basic/pagebreak.signalling))
$(eval $(call multipage,basic/ex28_color01.png,basic/ex28_color.signalling))
$(eval $(call multipage,basic/ex28_color02.png,basic/ex28_color.signalling))
$(eval $(call multipage,basic/ex28_color301.png,basic/ex28_color3.signalling))
$(eval $(call multipage,basic/ex28_color302.png,basic/ex28_color3.signalling))
PNGS += basic/basic01.png basic/basic02.png basic/Problem01.png basic/Problem02.png basic/pagebreak01.png basic/pagebreak02.png \
        basic/ex28_color01.png basic/ex28_color02.png basic/ex28_color301.png basic/ex28_color302.png
# ... and procedures/
$(eval $(call multipage,procedures/pagebreak_proc01.png,procedures/pagebreak_proc.signalling))
$(eval $(call multipage,procedures/pagebreak_proc02.png,procedures/pagebreak_proc.signalling))
$(eval $(call multipage,procedures/Problem_proc01.png,procedures/Problem_proc.signalling))
$(eval $(call multipage,procedures/Problem_proc02.png,procedures/Problem_proc.signalling))
$(eval $(call multipage,procedures/basic_graph_proc01.png,procedures/basic_graph_proc.graph))
$(eval $(call multipage,procedures/basic_graph_proc02.png,procedures/basic_graph_proc.graph))
PNGS += procedures/pagebreak_proc01.png procedures/pagebreak_proc02.png \
        procedures/Problem_proc01.png procedures/Problem_proc02.png \
        procedures/basic_graph_proc01.png procedures/basic_graph_proc02.png

# Unit tests
UNIT_PNGS = $(addprefix contour/,$(notdir $(wildcard $(srcdir)/contour/canonical/*.png)))
$(foreach f,$(UNIT_PNGS),$(eval $(call diffonly,$(f))))
PNGS += $(UNIT_PNGS)
endif

# Hinting
HINTS_ORIG = $(shell find $(srcdir) -name '*.hints' | grep '/canonical/')
HINTS = $(call rmsrc,$(call rmcanon,$(HINTS_ORIG)))
define hinting
$(1): $(call addsrc,$(basename $(1))) $$(MSCGEN)
	$$(AM_V_at)$$(MKDIR_P) $(dir $(1))
	$$(AM_V_GEN)[ x$(SKIP_HINT_CHECKS) = x1 ] && touch $$@ || MSCGEN=$$(MSCGEN) $$(TIMEOUT_CMD) $$(srcdir)/hint.sh $$< >$$@ 2>$$@.err
$(1).exit: $(1)
	$$(AM_V_at)[ x$(SKIP_HINT_CHECKS) = x1 ] && echo 6 >$$@ || { d=$$<_diff; e=$$<.err; \
	  { echo Success. | cmp -s $$$$e - && \
	      { $(WORD_DIFF) $$(call addsrc,$$(call canon,$$<)) $$< >$$$$d && rm $$$$d && echo 0 || echo 5; } || \
	      { echo 4; [[ $(AHA) != : ]] && $(AHA) -b -w <$$$$e >$$$${e}_new.html || mv $$$$e $$$${e}_new; } } >$$@; \
	  [[ -s $$$$d ]] && mv $$< $$<_new && \
	    [[ $(AHA) != : ]] && $(AHA) -b -w <$$$$d >$$$$d.html && $(AHA) -b -w <$$<_new >$$<_new.html || true; }
endef
$(foreach f,$(HINTS),$(eval $(call hinting,$(f))))
EXTRA_DIST += $(basename $(call addsrc,$(HINTS)))

# TEI-mode, copies `hinting' machinery except the skip-test
TEI_ORIG = $(shell find $(srcdir) -name '*.tei' | grep '/canonical/' | grep -v International1_utf16.tei)
TEI = $(call rmsrc,$(call rmcanon,$(TEI_ORIG)))
define tei
$(1)/%.tei: $(call addsrc,$(1)/%.$(2)) $$(MSCGEN)
	$$(AM_V_at)$$(MKDIR_P) $(1)
	$$(AM_V_GEN){ [[ $$< =~ tei-mode/ ]] || echo CE; cat $$<; } | $$(TIMEOUT_CMD) $$(MSCGEN) --tei-mode --nopaths -S $(2) >$$@ 2>$$@.err || touch $$@ $$@.err
$(1)/%.tei.exit: $(1)/%.tei
	$$(AM_V_at){ d=$$<_diff; e=$$<.err; \
	  { echo Success. | cmp -s $$$$e - && \
	      { $(WORD_DIFF) $$(call addsrc,$$(call canon,$$<)) $$< >$$$$d && rm $$$$d && echo 0 || echo 5; } || \
	      { echo 4; [[ $(AHA) != : ]] && $(AHA) -b -w <$$$$e >$$$${e}_new.html || mv $$$$e $$$${e}_new; } } >$$@; \
	  [[ -s $$$$d ]] && mv $$< $$<_new && \
	    [[ $(AHA) != : ]] && $(AHA) -b -w <$$$$d >$$$$d.html && $(AHA) -b -w <$$<_new >$$<_new.html || true; }
endef
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
$(foreach d,$(call uniq,$(patsubst %/,%,$(dir $(TEI)))),$(foreach s,$(MSC_SUFFICES),$(eval $(call tei,$(d),$(s)))))
EXTRA_DIST += $(wildcard $(foreach f,$(basename $(call addsrc,$(TEI))),$(foreach s,$(MSC_SUFFICES),$(f).$(s))))

PPTX_ORIG = $(shell find $(srcdir) -name '*.pptx' | grep '/canonical/')
PPTX = $(call rmsrc,$(call rmcanon,$(PPTX_ORIG)))
define ppt
$(1)/%.pptx: $(call addsrc,$(1)/%.$(2)) $$(MSCGEN)
	$$(AM_V_at)$$(MKDIR_P) $(1)
	$$(AM_V_GEN)$$(TIMEOUT_CMD) $$(MSCGEN) -s=1 -s=auto $$(MSCGEN_OPTS) -Tppt -S $(2) -o $$@ $$< 2>$$@.err || touch $$@ $$@.err
	$$(AM_V_at)[ "$$(MSC_TEST_NOFONT)" != 1 ] || MSCGEN_NOFONT=1 $$(TIMEOUT_CMD) $$(MSCGEN) -s=1 -s=auto $$(MSCGEN_OPTS) -Tppt -S $(2) -o $$@_nofont $$< 2>/dev/null || true
$(1)/%.pptx.exit: $(1)/%.pptx
	$$(AM_V_at)e=$$<.err; err4=; oe=$$(call addsrc,$$(call canon,$$(<:.pptx=.err))); \
	  { { [ -f $$$$oe ] && cat $$$$oe || echo Success.; } | cmp -s $$$$e - && \
	    { ox=$$(call addsrc,$$(call canon,$$<)); op=$$(basename $$<)_pptx.png; np=$$(basename $$<)_pptx_new.png; \
	      cmp -s $$$$ox $$< && echo 0 || \
	        { cp $$< $$(<:.pptx=_new.pptx); \
	          { export LOFFICE=$(LOFFICE); $$(TIMEOUT_CMD) $$(srcdir)/ppt2png.sh $$$$ox $$$$op; $$(TIMEOUT_CMD) $$(srcdir)/ppt2png.sh $$< $$$$np; } 2>$$$$e; \
	          [ ! -f $$<_nofont ] || { export LOFFICE=$(LOFFICE); $$(TIMEOUT_CMD) $$(srcdir)/ppt2png.sh $$<_nofont $$$${np}_nofont; } 2>/dev/null; \
	          [ -s $$$$e ] && err4=1 || \
	            { [ -s $$$$op -a -s $$$$np ] \
	                && { ./pngdiff $$$$op $$$$np `[ ! -f $$$${np}_nofont ] || echo $$$${np}_nofont` && { rm -f $$(<:.pptx=_new.pptx) $$$$np $$$${np}_nofont; echo 0; } || echo $$$$?; } \
	                || echo 1; } \
	        } \
	    } || err4=1; \
	    [ x$$$$err4 = x ] || { echo 4; [[ $(AHA) != : ]] && $(AHA) -b -w <$$$$e >$$$${e}_new.html || mv $$$$e $$$${e}_new; } } >$$@
endef
$(foreach d,$(call uniq,$(patsubst %/,%,$(dir $(PPTX)))),$(foreach s,$(MSC_SUFFICES),$(eval $(call ppt,$(d),$(s)))))

check-local: $(PNGS:.png=.exit) $(HINTS:=.exit) $(TEI:=.exit) $(PPTX:=.exit)
	$(AM_V_at)[ "$(MSC_TEST_COLLECT_CHANGED)" != 1 ] || { \
	  rm -rf changed 2>/dev/null; \
	  $(MKDIR_P) changed; \
	  [[ ! -s unit_tests ]] || cp unit_tests changed/contour_err.txt; \
	  find $(builddir) -name '*_diff*' | xargs -r cp --parent -t changed; \
	  for new in `find $(builddir) -name '*_new*'`; do \
	    f=$${new#$(builddir)/}; \
	    d=$${f%/*}; \
	    $(MKDIR_P) changed/$$d; \
	    g=$${f/_new}; \
	    cp $$new changed/$$g; \
	    o=$(srcdir)/$$d/canonical/$${g##*/}; \
	    [[ -f $$o ]] || o=$(builddir)/$$d/$${g##*/}; \
	    [[ ! -f $$o ]] || cp $$o changed/$${f/_new/_old}; \
	  done; \
	}
	$(AM_V_at)[ $(MSC_TEST_DUMP_DIFF) -lt 1 ] || find $(builddir) -name '*_diff.png' -o -name '*_new*' | shuf -n$(MSC_TEST_DUMP_DIFF) | xargs -r -I% sh -c 'echo BEGIN %; base64 %; echo END'
	$(AM_V_at)echo $^ | xargs grep -Hv 0 |\
	  sed -e 's,^./,,' -e 's/.tei.exit:/.tei:/' -e 's/.hints.exit:/.hints:/' -e 's/.exit:/.png:/' | awk '{split($$0,a,"[/]");print length(a),$$0}' | sort -k 1n,2 | cut -f2 -d' ' |\
	  sed -re 's/^(.*):1/DIFF:     \1/' -e 's/^(.*):2/DIFFSIZE: \1/' -e 's/^(.*):3/MISSING:  \1/' -e 's/^(.*):4/ERR_MSG:  \1/' -e 's/^(.*):5/TEI:      \1/' -e 's/^(.*):6/SKIP:     \1/'
	$(AM_V_at)[ ! -s unit_tests ] || tail -n +2 unit_tests | sed 's/^/UNIT:     /'
	$(AM_V_at)echo $^ | xargs cat | sort -n <(tail -n +2 unit_tests | sed 's/.*/9/') - | uniq -c |\
	  awk 'BEGIN{print "Summary:"} \
	       $$2 == "0" {print "no difference:",$$1;next} \
	       $$2 == "6" {print "skipped:",$$1;next} \
	       {e = 1} \
	       $$2 == "1" {print "different pixels:",$$1} \
	       $$2 == "2" {print "different size:",$$1} \
	       $$2 == "3" {print "file reading error:",$$1} \
	       $$2 == "4" {print "compile error:",$$1} \
	       $$2 == "5" {print "TEI error:",$$1} \
	       $$2 == "9" {print "unit tests failed:",$$1} \
	       END{exit e}' \
	  && [ ! -s unit_tests ] \
	  || [ "$(MSC_TEST_ALLOWFAIL)" = 1 ]

clean-local:
	$(AM_V_at)find -name '*.exit' -o -name '*.err' -o -name '*.png' -o -name '*.tei' -o -name '*.hints' -o -name '*.pptx' | xargs -r rm

unit_tests: contours
	$(AM_V_at)$(MKDIR_P) contour
	$(AM_V_GEN){ j=$$(echo "$(MAKEFLAGS)" | awk '{for(i=1;i<=NF;++i)if($$i~/^-j[0-9]+$$/)print "-j" int((substr($$i,3)+1)/2)}'); \
	  export MSCGEN_NOFONT=$(shell [ "$(MSC_TEST_NOFONT)" = 1 ] && echo 1 || echo $${MSCGEN_NOFONT-1}); \
	  $(AM_V_P) && (cd contour && $(TIMEOUT_CMD) ../contours $(CONTOURS_OPTS) $$j) 2>$@ || (cd contour && $(TIMEOUT_CMD) ../contours $(CONTOURS_OPTS) $$j)>/dev/null 2>$@; } 


new_canon: $(PNGS) $(HINTS) $(TEI) $(PPTX)
	$(AM_V_GEN)echo $^ | tr ' ' '\n' | xargs $$(echo "$(MAKEFLAGS)" | sed -E 's/^.*-j([0-9]+).*$$/-P\1/;t;d') -I@ sh -c 'cp @ $(top_srcdir)/tests/`dirname @`/canonical'

CLEANFILES = unit_tests contour/unit_tests