Debian Codegraph @

doc/tutorial_src/Makefile

raw symbols SCIP
1 # This Makefile generates source and output that is part of Cgreen
2 # documentation. Files here are included in the asciidoc source so be
3 # careful with what you commit, it might thrash the documentation. In
4 # particular, be aware that non-UTF-8 characters in them (usually)
5 # makes generation of PDF impossible. 'stream2' and 'stream5' might
6 # generate random data as 'actual' values in the output file. That is
7 # the way it is supposed to be to work as documentation examples.
8 # Take care data for those examples is printable but looks random.
9
10 CFLAGS = -Wall -g
11
12 .IGNORE :
13 .SILENT :
14
15 CGREEN_ROOT=../..
16
17 # Point to MySQL includes and linking for the MySQL examples
18 ifeq ($(shell uname),Darwin)
19 MYSQL_INCLUDE = /opt/local/include/mysql56/mysql
20 MYSQL_LIB = /opt/local/lib/mysql56/mysql
21 else
22 ifeq ($(shell uname -o),Cygwin)
23 MYSQL_INCLUDE = /usr/include/mysql
24 MYSQL_LIB = /usr/lib
25 else
26 MYSQLROOT = /usr
27 MYSQL_INCLUDE = $(MYSQLROOT)/include/mysql
28 MYSQL_LIB = $(MYSQLROOT)/lib
29 endif
30 endif
31
32 CGREEN_BIN=$(CGREEN_ROOT)/build
33 CC = gcc -c -g -Wall -I$(CGREEN_ROOT)/include -I$(CGREEN_ROOT)/src -I$(MYSQL_INCLUDE) $(FPIC)
34 LINK = gcc -g
35 LIBDIRS = -L$(CGREEN_BIN)/src -L$(MYSQL_LIB)
36
37 # Enviroment dependent fixup of the various paths to use bins & libs in this development tree
38 FPIC = -fPIC # required on Linux, Darwin, ...
39 ifeq ($(shell uname),Darwin)
40 LDPATH = DYLD_LIBRARY_PATH="$(CGREEN_BIN)/src:$(MYSQL_LIB)"
41 else
42 ifeq ($(shell uname -o),Cygwin)
43 FPIC=
44 LDPATH = PATH="$(CGREEN_BIN)/src:$(MYSQL_LIB)"
45 else
46 LDPATH = LD_LIBRARY_PATH="$(CGREEN_BIN)/src:$(MYSQL_LIB)"
47 endif
48 endif
49
50 RUNNER = $(LDPATH) $(CGREEN_BIN)/tools/cgreen-runner
51
52
53 all: with_main with_runner special
54 echo
55 echo "NOTE: 'stream2.out' and 'stream5.out' should contain a simulation"
56 echo "NOTE: of random memory as the actual value. Don't commit changes that do"
57 echo "NOTE: not. But also note that PDF generation of the documentation"
58 echo "NOTE: will fail if there are non-UTF-8 characters in them."
59 echo "NOTE: Edit by hand to reasonable values if needed."
60
61 # Since we have multiple files for the same tutorial example, distinguished by a number,
62 # we need to remove that number from all output
63 REMOVE_NUMBERS=-e 's/\([a-z]\)[0-9]\+\"/\1\"/' -e 's/\([a-z]\)[0-9]\+\.c/\1\.c/'
64
65 # To minimize the diffs we also need to normalize execution times
66 NORMALIZE_DURATION=-e 's/\ in\ [0-9]\+ms/\ in\ 42ms/g'
67
68 # And batch that together in one symbol
69 SED=sed $(REMOVE_NUMBERS) $(NORMALIZE_DURATION)
70
71 with_main: first0 first1 \
72 words0 words1 words2 words3 words4 words5 words6 words7 words8 words9 \
73 strlen1 strlen2 strlen3 strlen4 strlen5 strlen6 strlen7 \
74 double1 \
75 schema1 schema2 \
76 crash1 crash2 crash3 \
77 suite1 \
78 test_as_xml0 \
79 test_as_xml1 \
80 test_as_xml2 \
81 test_as_xml3 \
82 test_as_xml4 \
83 custom_constraint1 \
84 custom_constraint2 \
85 custom_constraint3
86 for f in $^ ; do echo $$f; $(LDPATH) ./$$f | $(SED) > $$f.out; done
87
88 # Most tests built to run with the runner we can run here, but some need special care
89 # They have their output produced directly in their build rules below and are run using
90 # the 'special' rule
91 with_runner: set_content side_effect stream0 stream1 stream2 stream3 stream4 stream6 \
92 multiple_streams1 multiple_streams2 \
93 formatter0 formatter1 formatter2 formatter3 formatter4 formatter5 formatter6 \
94 struct_parameters
95 for f in $^ ; do echo $$f; $(RUNNER) $$f.so | $(SED) > $$f.out; done
96
97 special: runner1 runner2 runner3 stream5 learning_mocks
98
99 clean:
100 rm -f *.exe *.o *.out *.so *.stackdump *~
101
102 first_tests0.o: first_tests0.c
103 $(CC) -o $@ -c $^ $(CFLAGS) -Wno-unused-variable
104
105 first0: first_tests0.o
106 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
107
108 first1: first_tests1.o
109 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
110
111 words_tests0.o: words_tests0.c
112 $(CC) -o $@ -c $^ $(CFLAGS) -Wno-unused-variable
113
114 words0: all_tests.o words_tests0.o
115 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
116
117 words1: all_tests.o words_tests1.o words1.o
118 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
119
120 words2: all_tests.o words_tests1.o words2.o
121 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
122
123 words3: all_tests.o words_tests2.o words2.o
124 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
125
126 words4: all_tests.o words_tests2.o words3.o
127 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
128
129 words5: all_tests.o words_tests2.o words4.o
130 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
131
132 words6: all_tests.o words_tests3.o words5.o
133 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
134
135 words7: all_tests.o words_tests3.o words6.o
136 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
137
138 words8: all_tests.o words_tests4.o words6.o
139 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
140
141 words9: all_tests.o words_tests4.o words7.o
142 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
143
144 strlen1: strlen_tests1.o
145 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
146
147 strlen2: strlen_tests2.o
148 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
149
150 strlen3: strlen_tests3.o
151 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
152
153 strlen4: strlen_tests4.o
154 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
155
156 strlen5: strlen_tests5.o
157 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
158
159 strlen6: strlen_tests6.o
160 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
161
162 strlen7: strlen_tests7.o
163 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
164
165 double1: double_tests1.o
166 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
167
168 schema1: schema_tests1.o person.h
169 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen -lmysqlclient
170
171 schema2: schema_tests2.o person.h
172 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen -lmysqlclient
173
174 crash1: crash_tests1.o
175 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
176
177 crash2: crash_tests2.o
178 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
179
180 crash3: crash_tests3.o
181 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
182
183 suite1: suite1.o suite_person_tests.o suite_strlen_tests.o
184 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen -lmysqlclient
185
186 test_as_xml0: test_as_xml0.o
187 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
188
189 test_as_xml1: test_as_xml1.o xml_reporter1.o
190 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
191
192 test_as_xml2: test_as_xml1.o xml_reporter2.o
193 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
194
195 test_as_xml3: test_as_xml1.o xml_reporter3.o
196 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
197
198 test_as_xml4: test_as_xml1.o xml_reporter4.o
199 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
200
201 custom_constraint1: custom_constraint1.o
202 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
203
204 custom_constraint2: custom_constraint2.o
205 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
206
207 custom_constraint3: custom_constraint3.o
208 $(LINK) -o $@ $^ $(LIBDIRS) -lcgreen
209
210
211
212 ###########################################################
213 # With runner
214 #
215 # All these examples run using the runner which automatically outputs the file name
216 # Since that includes the example #, which we don't want in the tutorial, we use
217 # sed to remove that number from the file name in the output
218 .PHONY: set_content
219 set_content: stream_tests0.o read_paragraph1.o
220 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
221
222 .PHONY: side_effect
223 side_effect: stream_tests0.o read_paragraph1.o
224 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
225
226 .PHONY: stream0
227 stream0: stream_tests0.o read_paragraph1.o
228 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
229
230 .PHONY: stream1
231 stream1: stream_tests1.o read_paragraph1.o
232 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
233
234 .PHONY: stream2
235 stream2: stream_tests2.o read_paragraph1.o
236 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
237
238 .PHONY: stream3
239 stream3: stream_tests2.o read_paragraph2.o
240 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
241
242 .PHONY: stream4
243 stream4: stream_tests3.o read_paragraph2.o
244 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
245
246 .PHONY: stream5
247 # This test generates random characters read from memory so we need to tidy that up
248 stream5: stream_tests4.o read_paragraph2.o
249 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
250 $(RUNNER) [email protected] | $(SED) > [email protected]
251 echo "Trying to remove non-characters from stream5.out"
252 echo "Check manually if the following sed fails:"
253 cp [email protected] [email protected] && LANG='' sed -e 's/^[^[[:space:]].*"]/"]/g' [email protected] > [email protected] && mv [email protected] [email protected]
254 rm [email protected]
255
256 .PHONY: stream6
257 stream6: stream_tests4.o read_paragraph3.o
258 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
259
260 .PHONY: multiple_streams1
261 multiple_streams1: multiple_streams1.o
262 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
263
264 .PHONY: multiple_streams2
265 multiple_streams2: multiple_streams2.o
266 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
267
268 .PHONY: runner1
269 runner1: first_tests2.o
270 $(LINK) -shared -o first_tests.so $^ $(LIBDIRS) -lcgreen
271 $(RUNNER) first_tests.so | $(SED) > [email protected]
272
273 .PHONY: runner2
274 runner2: first_tests2.o
275 $(LINK) -shared -o first_tests.so $^ $(LIBDIRS) -lcgreen
276 $(RUNNER) first_tests.so Cgreen:fails_this_test | $(SED) > [email protected]
277
278 .PHONY: runner3
279 runner3: first_tests2.o
280 $(LINK) -shared -o first_tests.so $^ $(LIBDIRS) -lcgreen
281 $(RUNNER) -v first_tests.so Cgreen:fails_this_test | $(SED) > [email protected]
282
283 .PHONY: formatter0
284 formatter0: stream1.o formatter_tests0.o
285 $(LINK) -shared -o formatter_tests.so $^ $(LIBDIRS) -lcgreen
286
287 .PHONY: formatter1
288 formatter1: stream1.o formatter_tests1.o
289 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
290
291 formatter2: stream1.o formatter_tests2.o
292 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
293
294 formatter3: stream1.o formatter_tests3.o
295 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
296
297 formatter4: stream1.o formatter_tests4.o
298 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
299
300 formatter5: stream1.o formatter_tests5.o
301 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
302
303 formatter6: stream2.o formatter_tests5.o
304 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
305
306 struct_parameters: struct_parameters.o
307 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
308
309 learning_mocks: learning_mocks.o
310 $(LINK) -shared -o [email protected] $^ $(LIBDIRS) -lcgreen
311 $(RUNNER) [email protected]