xref: /netbsd-src/external/bsd/flex/dist/tests/Makefile.am (revision 9616dacfef448e70e3fbbd865bddf60d54b656c5)
1# This file is part of flex.
2
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions
5# are met:
6
7# 1. Redistributions of source code must retain the above copyright
8#    notice, this list of conditions and the following disclaimer.
9# 2. Redistributions in binary form must reproduce the above copyright
10#    notice, this list of conditions and the following disclaimer in the
11#    documentation and/or other materials provided with the distribution.
12
13# Neither the name of the University nor the names of its contributors
14# may be used to endorse or promote products derived from this software
15# without specific prior written permission.
16
17# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20# PURPOSE.
21
22AM_CFLAGS = $(WARNINGFLAGS)
23
24TESTS = $(check_PROGRAMS) options.cn
25
26# The script testwrapper.sh will run most tests as is. A couple tests
27# in the suite end in .reject, .table and the like so that we can pass
28# different arguments to the test runner. We list those extensions so
29# automake knows how to distinguish between the various kinds of tests
30# we have.
31
32TEST_EXTENSIONS = .reject .table .direct .cn .i3 .pthread .one .opt .ser .ver
33
34LOG_COMPILER = $(srcdir)/testwrapper.sh
35AM_LOG_FLAGS = -d $(srcdir) -r
36
37REJECT_LOG_COMPILER = $(srcdir)/testwrapper.sh
38AM_REJECT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/reject.txt -r
39
40TABLE_LOG_COMPILER = $(srcdir)/testwrapper.sh
41AM_TABLE_LOG_FLAGS = -d $(builddir) -i $(srcdir)/reject.txt -t
42
43DIRECT_LOG_COMPILER=$(srcdir)/testwrapper-direct.sh
44AM_DIRECT_LOG_FLAGS = -b $(abs_builddir) -s $(srcdir)
45
46CN_LOG_COMPILER=$(srcdir)/options.cn
47AM_CN_LOG_FLAGS=$(FLEX)
48
49I3_LOG_COMPILER=$(srcdir)/testwrapper.sh
50AM_I3_LOG_FLAGS=-i $(srcdir)/cxx_yywrap.txt -i $(srcdir)/cxx_yywrap.txt -i $(srcdir)/cxx_yywrap.txt
51
52PTHREAD_LOG_COMPILER=$(srcdir)/testwrapper.sh
53AM_PTHREAD_LOG_FLAGS=-i $(srcdir)/pthread_1.txt -i $(srcdir)/pthread_2.txt -i $(srcdir)/pthread_3.txt -i $(srcdir)/pthread_4.txt -i $(srcdir)/pthread_5.txt
54
55ONE_LOG_COMPILER = $(srcdir)/testwrapper.sh
56AM_ONE_LOG_FLAGS = -1 -d $(srcdir)
57
58AM_YFLAGS = -d -p test
59AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src
60
61check_PROGRAMS = $(simple_tests) $(reject_tests) $(TABLE_TESTS) $(DIRECT_TESTS) $(I3_TESTS) $(PTHREAD_TESTS) $(ONE_TESTS) $(TABLEOPTS_TESTS)
62
63simple_tests = \
64	alloc_extra \
65	array_nr \
66	array_r \
67	basic_nr \
68	basic_r \
69	bison_nr \
70	bison_yylloc \
71	bison_yylval \
72	c_cxx_nr \
73	c_cxx_r \
74	ccl \
75	cxx_basic \
76	cxx_multiple_scanners \
77	cxx_restart \
78	debug_nr \
79	debug_r \
80	extended \
81	header_nr \
82	header_r \
83	mem_nr \
84	mem_r \
85	multiple_scanners_nr \
86	multiple_scanners_r \
87	posix \
88	posixly_correct \
89	prefix_nr \
90	prefix_r \
91	quote_in_comment \
92	quotes \
93	string_nr \
94	string_r \
95	top \
96	yyextra
97
98reject_tests = \
99	reject_nr.reject \
100	reject_r.reject
101
102TABLE_TESTS = \
103	reject_ver.table \
104	reject_ser.table
105
106DIRECT_TESTS = \
107	include_by_buffer.direct \
108	include_by_push.direct \
109	include_by_reentrant.direct \
110	rescan_nr.direct \
111	rescan_r.direct
112
113I3_TESTS = \
114	cxx_yywrap.i3
115
116if want_pthread
117PTHREAD_TESTS = \
118	pthread.pthread
119endif
120
121ONE_TESTS = \
122	lineno_nr.one \
123	lineno_r.one \
124	lineno_trailing.one
125
126quote_in_comment_SOURCES = quote_in_comment.l
127alloc_extra_SOURCES = alloc_extra.l
128array_nr_SOURCES = array_nr.l
129array_r_SOURCES = array_r.l
130basic_nr_SOURCES = basic_nr.l
131basic_r_SOURCES = basic_r.l
132bison_nr_SOURCES = bison_nr_scanner.l bison_nr_parser.y bison_nr_main.c
133bison_yylloc_SOURCES = bison_yylloc_scanner.l bison_yylloc_parser.y bison_yylloc_main.c
134bison_yylval_SOURCES = bison_yylval_scanner.l bison_yylval_parser.y bison_yylval_main.c
135c_cxx_nr_SOURCES = c_cxx_nr.lll
136c_cxx_r_SOURCES = c_cxx_r.lll
137ccl_SOURCES = ccl.l
138cxx_basic_SOURCES = cxx_basic.ll
139cxx_restart_SOURCES = cxx_restart.ll
140cxx_multiple_scanners_SOURCES = cxx_multiple_scanners_main.cc cxx_multiple_scanners_1.ll cxx_multiple_scanners_2.ll
141cxx_yywrap_i3_SOURCES = cxx_yywrap.ll
142debug_nr_SOURCES = debug_nr.l
143debug_r_SOURCES = debug_r.l
144extended_SOURCES = extended.l
145header_nr_SOURCES = header_nr_scanner.l header_nr_main.c
146header_r_SOURCES = header_r_scanner.l header_r_main.c
147include_by_buffer_direct_SOURCES = include_by_buffer.direct.l
148include_by_push_direct_SOURCES = include_by_push.direct.l
149include_by_reentrant_direct_SOURCES = include_by_reentrant.direct.l
150lineno_nr_one_SOURCES = lineno_nr.l
151lineno_r_one_SOURCES = lineno_r.l
152lineno_trailing_one_SOURCES = lineno_trailing.l
153mem_nr_SOURCES = mem_nr.l
154mem_r_SOURCES = mem_r.l
155multiple_scanners_nr_SOURCES = multiple_scanners_nr_main.c multiple_scanners_nr_1.l multiple_scanners_nr_2.l
156multiple_scanners_r_SOURCES = multiple_scanners_r_main.c multiple_scanners_r_1.l multiple_scanners_r_2.l
157posix_SOURCES = posix.l
158posixly_correct_SOURCES = posixly_correct.l
159prefix_nr_SOURCES = prefix_nr.l
160prefix_r_SOURCES = prefix_r.l
161pthread_pthread_SOURCES = pthread.l
162quotes_SOURCES = quotes.l
163reject_nr_reject_SOURCES = reject.l4
164reject_r_reject_SOURCES = reject.l4
165reject_ver_table_SOURCES = reject.l4
166reject_ser_table_SOURCES = reject.l4
167rescan_nr_direct_SOURCES = rescan_nr.direct.l
168rescan_r_direct_SOURCES = rescan_r.direct.l
169string_nr_SOURCES = string_nr.l
170string_r_SOURCES = string_r.l
171top_SOURCES = top.l top_main.c
172yyextra_SOURCES = yyextra.l
173
174BUILT_SOURCES = \
175	bison_nr_parser.h \
176	bison_nr_scanner.h \
177	bison_yylloc_parser.h \
178	bison_yylloc_scanner.h \
179	bison_yylval_parser.h \
180	bison_yylval_scanner.h \
181	header_nr_scanner.h \
182	header_r_scanner.h \
183	multiple_scanners_nr_1.h \
184	multiple_scanners_nr_2.h \
185	multiple_scanners_r_1.h \
186	multiple_scanners_r_2.h \
187	top.h
188
189# Normally, automake would distribute files built by flex. Since the
190# point of the test suite is to test the files that flex builds, and
191# since anyone who has the flex distribution can build a flex binary
192# without having a flex binary, we want to not distribute the files
193# built by flex in the test suite. The dist-hook target accomplishes
194# this goal. It's also handy to have the list of files to clean since
195# automake doesn't know about the whacky ways in which we're abusing
196# it.
197
198CLEANFILES = \
199	array_nr.c \
200	array_r.c \
201	basic_nr.c \
202	basic_r.c \
203	bison_nr_parser.c \
204	bison_nr_parser.h \
205	bison_nr_scanner.c \
206	bison_nr_scanner.h \
207	bison_yylloc_parser.c \
208	bison_yylloc_parser.h \
209	bison_yylloc_scanner.c \
210	bison_yylloc_scanner.h \
211	bison_yylval_parser.c \
212	bison_yylval_parser.h \
213	bison_yylval_scanner.c \
214	bison_yylval_scanner.h \
215	c_cxx_nr.cc \
216	c_cxx_r.cc \
217	ccl.c \
218	cxx_basic.cc \
219	cxx_multiple_scanners_1.cc \
220	cxx_multiple_scanners_2.cc \
221	cxx_restart.cc \
222	cxx_yywrap.cc \
223	debug_nr.c \
224	debug_r.c \
225	extended.c \
226	header_nr_scanner.c \
227	header_nr_scanner.h \
228	header_r_scanner.c \
229	header_r_scanner.h \
230	include_by_buffer.direct.c \
231	include_by_push.direct.c \
232	include_by_reentrant.direct.c \
233	lineno_nr.c \
234	lineno_r.c \
235	lineno_trailing.c \
236	mem_nr.c \
237	mem_r.c \
238	multiple_scanners_nr_1.c \
239	multiple_scanners_nr_1.h \
240	multiple_scanners_nr_2.c \
241	multiple_scanners_nr_2.h \
242	multiple_scanners_r_1.c \
243	multiple_scanners_r_1.h \
244	multiple_scanners_r_2.c \
245	multiple_scanners_r_2.h \
246	posix.c \
247	posixly_correct.c \
248	prefix_nr.c \
249	prefix_r.c \
250	pthread.c \
251	quote_in_comment.c \
252	quotes.c \
253	reject_nr.reject.c \
254	reject_r.reject.c \
255	reject_ser.table.c \
256	reject_ser.table.tables \
257	reject_ver.table.c \
258	reject_ver.table.tables \
259	rescan_nr.direct.c \
260	rescan_r.direct.c \
261	string_nr.c \
262	string_r.c \
263	top.c \
264	top.h  \
265	yyextra.c \
266alloc_extra.c \
267	$(tableopts_c) \
268	$(tableopts_tables)
269
270dist-hook:
271	for file in $(CLEANFILES) ; do \
272	rm -f $(distdir)/$$file \
273	; done
274
275EXTRA_DIST = \
276	README \
277	alloc_extra.txt \
278	array_nr.txt \
279	array_r.txt \
280	basic_nr.txt \
281	basic_r.txt \
282	bison_nr.txt \
283	bison_yylloc.txt \
284	bison_yylval.txt \
285	c_cxx_nr.txt \
286	c_cxx_r.txt \
287	ccl.txt \
288	cxx_basic.txt \
289	cxx_multiple_scanners.txt \
290	cxx_restart.txt \
291	cxx_yywrap.txt \
292	debug_nr.txt \
293	debug_r.txt \
294	extended.txt \
295	header_nr.txt \
296	header_r.txt \
297	include_by_buffer.direct.txt \
298	include_by_buffer.direct_2.txt \
299	include_by_buffer.direct_3.txt \
300	include_by_push.direct.txt \
301	include_by_push.direct_2.txt \
302	include_by_push.direct_3.txt \
303	include_by_reentrant.direct.txt \
304	include_by_reentrant.direct_2.txt \
305	include_by_reentrant.direct_3.txt \
306	lineno_nr.one.txt \
307	lineno_r.one.txt \
308	lineno_trailing.one.txt \
309	mem_nr.txt \
310	mem_r.txt \
311	prefix_nr.txt \
312	prefix_r.txt \
313	pthread_1.txt \
314	pthread_2.txt \
315	pthread_3.txt \
316	pthread_4.txt \
317	pthread_5.txt \
318	reject.txt \
319	rescan_nr.direct.txt \
320	rescan_r.direct.txt \
321	quote_in_comment.txt \
322	quotes.txt \
323	top.txt \
324	yyextra.txt \
325	tableopts.txt
326
327dist_noinst_SCRIPTS = \
328	tableopts.sh
329
330dist_check_SCRIPTS = \
331	options.cn \
332	testwrapper-direct.sh \
333	testwrapper.sh
334
335pthread_pthread_LDADD = -lpthread
336
337# specify how to process .l files in order to test the flex built by make all
338
339FLEX = $(top_builddir)/src/flex
340
341.l.c: $(FLEX)
342	$(FLEX) -o $@ $<
343
344.ll.cc: $(FLEX)
345	$(FLEX) -+ -o $@ $<
346
347bison_nr_main.($OBJEXT): bison_nr_parser.h bison_nr_scanner.h
348bison_nr_scanner.h: bison_nr_scanner.c
349
350bison_yylloc_main.$(OBJEXT): bison_yylloc_parser.h bison_yylloc_scanner.h
351bison_yylloc_scanner.h: bison_yylloc_scanner.c
352
353bison_yylval_main.$(OBJEXT): bison_yylval_parser.h bison_yylval_scanner.h
354bison_yylval_scanner.h: bison_yylval_scanner.c
355
356# automake does not support compiling flex scanners output in C as C++
357# so we explicitly sayhow, using the .lll suffix for the lex input file
358
359.lll.cc: $(FLEX)
360	$(FLEX) -o $@ $<
361
362header_nr_main.$(OBJEXT): header_nr_scanner.h
363header_nr_scanner.h: header_nr_scanner.c
364
365header_r_main.$(OBJEXT): header_r_scanner.h
366header_r_scanner.h: header_r_scanner.c
367
368multiple_scanners_nr_main.$(OBJEXT): multiple_scanners_nr_1.h multiple_scanners_nr_2.h
369multiple_scanners_nr_1.h: multiple_scanners_nr_1.c
370multiple_scanners_nr_2.h: multiple_scanners_nr_2.c
371
372multiple_scanners_r_main.$(OBJEXT): multiple_scanners_r_1.h multiple_scanners_r_2.h
373multiple_scanners_r_1.h: multiple_scanners_r_1.c
374multiple_scanners_r_2.h: multiple_scanners_r_2.c
375
376posixly_correct.c: posixly_correct.l $(FLEX)
377	POSIXLY_CORRECT=1 $(FLEX) -o $@ $<
378
379reject_nr.reject.c: reject.l4 $(FLEX)
380	$(FLEX) --unsafe-no-m4-sect3-escape -o $@ $<
381
382reject_nr.reject$(EXEEXT): reject_nr.reject.$(OBJEXT)
383	$(LINK) $^
384
385reject_r.reject.c: reject.l4 $(FLEX)
386	$(FLEX) --unsafe-no-m4-sect3-escape --reentrant -o $@ $<
387
388reject_r.reject.$(OBJEXT): reject_r.reject.c
389	$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $<
390
391reject_r.reject$(EXEEXT): reject_r.reject.$(OBJEXT)
392	$(LINK) $^
393
394reject_ver.table.c: reject.l4 $(FLEX)
395	$(FLEX) --unsafe-no-m4-sect3-escape -o $@ --tables-verify --tables-file=$(basename $@).tables $<
396
397reject_ver.table.$(OBJEXT): reject_ver.table.c
398	$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
399
400reject_ver.table$(EXEEXT): reject_ver.table.$(OBJEXT)
401	$(LINK) $^
402
403reject_ser.table.c: reject.l4 $(FLEX)
404	$(FLEX) -o $@ --unsafe-no-m4-sect3-escape --tables-file=$(basename $@).tables $<
405
406reject_ser.table.$(OBJEXT): reject_ser.table.c
407	$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
408
409reject_ser.table$(EXEEXT): reject_ser.table.$(OBJEXT)
410	$(LINK) $^
411
412top_main.$(OBJEXT): top.h
413top.h: top.c
414
415# We separate out the tableopts _SOURCES variables and the linking
416# rules for those programs because automake has no way to specify such
417# things with a loop in a variable (even though make can do such
418# things) and the resultant list is both long an unenlightening. And
419# it can be / is generated by a shell script, tableopts.sh.
420
421tableopts.am: tableopts.sh
422	$(srcdir)/tableopts.sh > $(srcdir)/tableopts.am
423
424include $(srcdir)/tableopts.am
425
426tableopts   := -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem
427tableopts_opt_tests :=  $(foreach opt,$(tableopts), tableopts_opt_nr$(opt) tableopts_opt_r$(opt))
428tableopts_sertests :=  $(foreach opt,$(tableopts), tableopts_ser_nr$(opt) tableopts_ser_r$(opt))
429tableopts_vertests :=  $(foreach opt,$(tableopts), tableopts_ver_nr$(opt) tableopts_ver_r$(opt))
430tableopts_tests  := $(tableopts_opttests) $(tableopts_vertests) $(tableopts_sertests)
431
432tableopts_c := $(addsuffix .c,$(tableopts_tests))
433
434OPT_LOG_COMPILER = $(srcdir)/testwrapper.sh
435AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r
436
437tableopts_opt_nr%.c: tableopts.l4 $(FLEX)
438	$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $* -o $@ $<
439
440tableopts_opt_nr%.$(OBJEXT): tableopts_opt_nr%.c
441	$(COMPILE) -c -o $@ $<
442
443tableopts_opt_r%.c: tableopts.l4 $(FLEX)
444	$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $*  -o $@ $<
445
446tableopts_opt_r%.$(OBJEXT):  tableopts_opt_r%.c
447	$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $<
448
449SER_LOG_COMPILER = $(srcdir)/testwrapper.sh
450AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t
451
452tableopts_ser_nr%.c: tableopts.l4 $(FLEX)
453	$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables"  $* -o $@ $<
454
455tableopts_ser_nr%.$(OBJEXT): tableopts_ser_nr%.c
456	$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
457
458tableopts_ser_r%.c: tableopts.l4 $(FLEX)
459	$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $*  -o $@ $<
460
461tableopts_ser_r%.$(OBJEXT):  tableopts_ser_r%.c
462	$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $<
463
464VER_LOG_COMPILER = $(srcdir)/testwrapper.sh
465AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t
466
467tableopts_ver_nr%.c: tableopts.l4 $(FLEX)
468	$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $* -o $@ $<
469
470tableopts_ver_nr%.$(OBJEXT): tableopts_ver_nr%.c
471	$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
472
473tableopts_ver_nr%.ver$(EXEEXT): tableopts_ver_nr%.$(OBJEXT)
474	$(LINK) -o $@ $^
475
476tableopts_ver_r%.c: tableopts.l4 $(FLEX)
477	$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $*  -o $@ $<
478
479tableopts_ver_r%.$(OBJEXT):  tableopts_ver_r%.c
480	$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $<
481