File: Makefile

package info (click to toggle)
cgreen 1.6.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,588 kB
  • sloc: ansic: 12,276; sh: 558; makefile: 474; cpp: 403; python: 181; xml: 33; sed: 13
file content (311 lines) | stat: -rw-r--r-- 9,465 bytes parent folder | download | duplicates (2)
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# This Makefile generates source and output that is part of Cgreen
# documentation. Files here are included in the asciidoc source so be
# careful with what you commit, it might thrash the documentation. In
# particular, be aware that non-UTF-8 characters in them (usually)
# makes generation of PDF impossible.  'stream2' and 'stream5' might
# generate random data as 'actual' values in the output file. That is
# the way it is supposed to be to work as documentation examples.
# Take care data for those examples is printable but looks random.

CFLAGS = -Wall -g

.IGNORE :
.SILENT :

CGREEN_ROOT=../..

# Point to MySQL includes and linking for the MySQL examples
ifeq ($(shell uname),Darwin)
MYSQL_INCLUDE = /opt/local/include/mysql56/mysql
MYSQL_LIB = /opt/local/lib/mysql56/mysql
else
ifeq ($(shell uname -o),Cygwin)
MYSQL_INCLUDE = /usr/include/mysql
MYSQL_LIB = /usr/lib
else
MYSQLROOT = /usr
MYSQL_INCLUDE = $(MYSQLROOT)/include/mysql
MYSQL_LIB = $(MYSQLROOT)/lib
endif
endif

CGREEN_BIN=$(CGREEN_ROOT)/build
CC = gcc -c -g -Wall -I$(CGREEN_ROOT)/include -I$(CGREEN_ROOT)/src -I$(MYSQL_INCLUDE) $(FPIC)
LINK = gcc -g
LIBDIRS = -L$(CGREEN_BIN)/src -L$(MYSQL_LIB)

# Enviroment dependent fixup of the various paths to use bins & libs in this development tree
FPIC = -fPIC	# required on Linux, Darwin, ...
ifeq ($(shell uname),Darwin)
LDPATH = DYLD_LIBRARY_PATH="$(CGREEN_BIN)/src:$(MYSQL_LIB)"
else
ifeq ($(shell uname -o),Cygwin)
FPIC=
LDPATH = PATH="$(CGREEN_BIN)/src:$(MYSQL_LIB)"
else
LDPATH = LD_LIBRARY_PATH="$(CGREEN_BIN)/src:$(MYSQL_LIB)"
endif
endif

RUNNER = $(LDPATH) $(CGREEN_BIN)/tools/cgreen-runner


all: with_main with_runner special
	echo
	echo "NOTE: 'stream2.out' and 'stream5.out' should contain a simulation"
	echo "NOTE: of random memory as the actual value. Don't commit changes that do"
	echo "NOTE: not. But also note that PDF generation of the documentation"
	echo "NOTE: will fail if there are non-UTF-8 characters in them."
	echo "NOTE: Edit by hand to reasonable values if needed."

# Since we have multiple files for the same tutorial example, distinguished by a number,
# we need to remove that number from all output
REMOVE_NUMBERS=-e 's/\([a-z]\)[0-9]\+\"/\1\"/' -e 's/\([a-z]\)[0-9]\+\.c/\1\.c/'

# To minimize the diffs we also need to normalize execution times
NORMALIZE_DURATION=-e 's/\ in\ [0-9]\+ms/\ in\ 42ms/g'

# And batch that together in one symbol
SED=sed $(REMOVE_NUMBERS) $(NORMALIZE_DURATION)

with_main:  first0 first1 \
		words0 words1 words2 words3 words4 words5 words6 words7 words8 words9 \
		strlen1 strlen2 strlen3 strlen4 strlen5 strlen6 strlen7 \
		double1 \
		schema1 schema2 \
		crash1 crash2 crash3 \
		suite1 \
		test_as_xml0 \
		test_as_xml1 \
		test_as_xml2 \
		test_as_xml3 \
		test_as_xml4 \
		custom_constraint1 \
		custom_constraint2 \
		custom_constraint3
	for f in $^ ; do echo $$f; $(LDPATH) ./$$f | $(SED) > $$f.out; done

# Most tests built to run with the runner we can run here, but some need special care
# They have their output produced directly in their build rules below and are run using
# the 'special' rule
with_runner: set_content side_effect stream0 stream1 stream2 stream3 stream4 stream6 \
		multiple_streams1 multiple_streams2 \
		formatter0 formatter1 formatter2 formatter3 formatter4 formatter5 formatter6 \
		struct_parameters
	for f in $^ ; do echo $$f; $(RUNNER) $$f.so | $(SED) > $$f.out; done

special: runner1 runner2 runner3 stream5 learning_mocks

clean:
	rm -f *.exe *.o *.out *.so *.stackdump *~

first_tests0.o: first_tests0.c
	$(CC) -o $@ -c $^ $(CFLAGS) -Wno-unused-variable

first0: first_tests0.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

first1: first_tests1.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words_tests0.o: words_tests0.c
	$(CC) -o $@ -c $^ $(CFLAGS) -Wno-unused-variable

words0: all_tests.o words_tests0.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words1: all_tests.o words_tests1.o words1.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words2: all_tests.o words_tests1.o words2.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words3: all_tests.o words_tests2.o words2.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words4: all_tests.o words_tests2.o words3.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words5: all_tests.o words_tests2.o words4.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words6: all_tests.o words_tests3.o words5.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words7: all_tests.o words_tests3.o words6.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words8: all_tests.o words_tests4.o words6.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

words9: all_tests.o words_tests4.o words7.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

strlen1: strlen_tests1.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

strlen2: strlen_tests2.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

strlen3: strlen_tests3.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

strlen4: strlen_tests4.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

strlen5: strlen_tests5.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

strlen6: strlen_tests6.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

strlen7: strlen_tests7.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

double1: double_tests1.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

schema1: schema_tests1.o person.h
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen -lmysqlclient

schema2: schema_tests2.o person.h
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen -lmysqlclient

crash1: crash_tests1.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

crash2: crash_tests2.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

crash3: crash_tests3.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

suite1: suite1.o suite_person_tests.o suite_strlen_tests.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen -lmysqlclient

test_as_xml0: test_as_xml0.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

test_as_xml1: test_as_xml1.o xml_reporter1.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

test_as_xml2: test_as_xml1.o xml_reporter2.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

test_as_xml3: test_as_xml1.o xml_reporter3.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

test_as_xml4: test_as_xml1.o xml_reporter4.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

custom_constraint1: custom_constraint1.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

custom_constraint2: custom_constraint2.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen

custom_constraint3: custom_constraint3.o
	$(LINK) -o $@ $^ $(LIBDIRS) -lcgreen



###########################################################
# With runner
#
# All these examples run using the runner which automatically outputs the file name
# Since that includes the example #, which we don't want in the tutorial, we use
# sed to remove that number from the file name in the output
.PHONY: set_content
set_content: stream_tests0.o read_paragraph1.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: side_effect
side_effect: stream_tests0.o read_paragraph1.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: stream0
stream0: stream_tests0.o read_paragraph1.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: stream1
stream1: stream_tests1.o read_paragraph1.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: stream2
stream2: stream_tests2.o read_paragraph1.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: stream3
stream3: stream_tests2.o read_paragraph2.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: stream4
stream4: stream_tests3.o read_paragraph2.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: stream5
# This test generates random characters read from memory so we need to tidy that up
stream5: stream_tests4.o read_paragraph2.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen
	$(RUNNER) $@.so | $(SED) > $@.out
	echo "Trying to remove non-characters from stream5.out"
	echo "Check manually if the following sed fails:"
	cp $@.out $@.bak && LANG='' sed -e 's/^[^[[:space:]].*"]/"]/g' $@.bak > $@.bak2 && mv $@.bak2 $@.out
	rm $@.bak

.PHONY: stream6
stream6: stream_tests4.o read_paragraph3.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: multiple_streams1
multiple_streams1: multiple_streams1.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: multiple_streams2
multiple_streams2: multiple_streams2.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

.PHONY: runner1
runner1: first_tests2.o
	$(LINK) -shared -o first_tests.so $^ $(LIBDIRS) -lcgreen
	$(RUNNER) first_tests.so | $(SED) > $@.out

.PHONY: runner2
runner2: first_tests2.o
	$(LINK) -shared -o first_tests.so $^ $(LIBDIRS) -lcgreen
	$(RUNNER) first_tests.so Cgreen:fails_this_test | $(SED) > $@.out

.PHONY: runner3
runner3: first_tests2.o
	$(LINK) -shared -o first_tests.so $^ $(LIBDIRS) -lcgreen
	$(RUNNER) -v first_tests.so Cgreen:fails_this_test | $(SED) > $@.out

.PHONY: formatter0
formatter0: stream1.o formatter_tests0.o
	$(LINK) -shared -o formatter_tests.so $^ $(LIBDIRS) -lcgreen

.PHONY: formatter1
formatter1: stream1.o formatter_tests1.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

formatter2: stream1.o formatter_tests2.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

formatter3: stream1.o formatter_tests3.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

formatter4: stream1.o formatter_tests4.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

formatter5: stream1.o formatter_tests5.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

formatter6: stream2.o formatter_tests5.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

struct_parameters: struct_parameters.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen

learning_mocks: learning_mocks.o
	$(LINK) -shared -o $@.so $^ $(LIBDIRS) -lcgreen
	$(RUNNER) $@.so