summaryrefslogtreecommitdiff
path: root/Makefile.am
blob: 40cb2e79246d8aa64e024cc4e9f193bc449a806c (plain)
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385

# stdlib directory
stdlibdir = $(datadir)/re2c/stdlib

# do not add compiler options/warnings here, add them in configure.ac
AM_CXXFLAGS = $(CXXFLAGSDEFAULT)
AM_CXXFLAGS += -DRE2C_STDLIB_DIR='"$(stdlibdir)/"'
if DEBUG
AM_CXXFLAGS += -DRE2C_DEBUG
endif

RE2CFLAGS = -br -W

# binary
bin_PROGRAMS = re2c
noinst_PROGRAMS =
RE2C = re2c$(EXEEXT)

# sources
re2c_HDR = \
	src/codegen/bitmap.h \
	src/codegen/emit.h \
	src/codegen/go.h \
	src/codegen/input_api.h \
	src/codegen/label.h \
	src/codegen/output.h \
	src/codegen/print.h \
	src/options/opt.h \
	src/adfa/action.h \
	src/adfa/adfa.h \
	src/cfg/cfg.h \
	src/dfa/closure_leftmost.h \
	src/dfa/closure_posix.h \
	src/dfa/determinization.h \
	src/dfa/dfa.h \
	src/dfa/posix_precedence.h \
	src/dfa/tag_history.h \
	src/dfa/tagver_table.h \
	src/dfa/tcmd.h \
	src/nfa/nfa.h \
	src/encoding/case.h \
	src/encoding/ebcdic/ebcdic.h \
	src/encoding/ebcdic/ebcdic_regexp.h \
	src/encoding/enc.h \
	src/encoding/range_suffix.h \
	src/encoding/utf8/utf8.h \
	src/encoding/utf8/utf8_regexp.h \
	src/encoding/utf16/utf16_regexp.h \
	src/encoding/utf16/utf16.h \
	src/msg/location.h \
	src/msg/msg.h \
	src/msg/ver_to_vernum.h \
	src/msg/warn.h \
	src/regexp/empty_class_policy.h \
	src/regexp/re.h \
	src/regexp/rule.h \
	src/regexp/tag.h \
	src/compile.h \
	src/skeleton/path.h \
	src/skeleton/skeleton.h \
	src/parse/ast.h \
	src/parse/input.h \
	src/parse/parse.h \
	src/parse/scanner.h \
	src/parse/unescape.h \
	src/debug/debug.h \
	src/util/allocate.h \
	src/util/attribute.h \
	src/util/c99_stdint.h \
	src/util/counter.h \
	src/util/fixed_allocator.h \
	src/util/forbid_copy.h \
	src/util/free_list.h \
	src/util/get_dir.h \
	src/util/hash32.h \
	src/util/local_increment.h \
	src/util/lookup.h \
	src/util/range.h \
	src/util/s_to_n32_unsafe.h \
	src/util/slab_allocator.h \
	src/util/smart_ptr.h \
	src/util/static_assert.h \
	src/util/string_utils.h \
	src/util/temp_file.h \
	src/util/u32lim.h \
	src/util/uniq_vector.h \
	src/util/wrap_iter.h
re2c_SRC = \
	src/codegen/bitmap.cc \
	src/codegen/emit_action.cc \
	src/codegen/emit_dfa.cc \
	src/codegen/label.cc \
	src/codegen/go_construct.cc \
	src/codegen/go_destruct.cc \
	src/codegen/go_emit.cc \
	src/codegen/go_used_labels.cc \
	src/codegen/input_api.cc \
	src/codegen/output.cc \
	src/codegen/print.cc \
	src/options/opt.cc \
	src/nfa/estimate_size.cc \
	src/nfa/re_to_nfa.cc \
	src/adfa/adfa.cc \
	src/adfa/prepare.cc \
	src/debug/dump_adfa.cc \
	src/debug/dump_cfg.cc \
	src/debug/dump_dfa.cc \
	src/debug/dump_interf.cc \
	src/debug/dump_nfa.cc \
	src/cfg/cfg.cc \
	src/cfg/compact.cc \
	src/cfg/dce.cc \
	src/cfg/freeze.cc \
	src/cfg/interfere.cc \
	src/cfg/liveanal.cc \
	src/cfg/normalize.cc \
	src/cfg/optimize.cc \
	src/cfg/rename.cc \
	src/cfg/varalloc.cc \
	src/dfa/closure.cc \
	src/dfa/dead_rules.cc \
	src/dfa/determinization.cc \
	src/dfa/fallback_tags.cc \
	src/dfa/fillpoints.cc \
	src/dfa/find_state.cc \
	src/dfa/minimization.cc \
	src/dfa/tagver_table.cc \
	src/dfa/tcmd.cc \
	src/encoding/ebcdic/ebcdic_regexp.cc \
	src/encoding/enc.cc \
	src/encoding/range_suffix.cc \
	src/encoding/utf8/utf8_regexp.cc \
	src/encoding/utf8/utf8.cc \
	src/encoding/utf16/utf16_regexp.cc \
	src/encoding/utf16/utf16.cc \
	src/msg/msg.cc \
	src/msg/warn.cc \
	src/regexp/ast_to_re.cc \
	src/regexp/default_tags.cc \
	src/regexp/fixed_tags.cc \
	src/regexp/nullable.cc \
	src/regexp/rule.cc \
	src/regexp/split_charset.cc \
	src/regexp/tag.cc \
	src/compile.cc \
	src/skeleton/control_flow.cc \
	src/skeleton/generate_code.cc \
	src/skeleton/generate_data.cc \
	src/skeleton/maxpath.cc \
	src/skeleton/skeleton.cc \
	src/parse/ast.cc \
	src/parse/input.cc \
	src/parse/normalize.cc \
	src/parse/scanner.cc \
	src/parse/unescape.cc \
	src/parse/validate.cc \
	src/util/get_dir.cc \
	src/util/s_to_n32_unsafe.cc \
	src/util/temp_file.cc \
	src/util/range.cc
re2c_SOURCES = \
	src/main.cc \
	$(re2c_HDR) \
	$(re2c_SRC)

# autogenerated sources
re2c_GEN_HELP = src/msg/help.cc
re2c_GEN_LEX = src/parse/lex.cc
re2c_GEN_PARSER = src/parse/parser.cc
re2c_GEN_PARSER_HDR = src/parse/parser.h
re2c_GEN_VER_TO_VERNUM = src/msg/ver_to_vernum.cc
re2c_GEN_SRC = \
	$(re2c_GEN_HELP) \
	$(re2c_GEN_LEX) \
	$(re2c_GEN_PARSER) \
	$(re2c_GEN_VER_TO_VERNUM) \
	src/parse/lex_conf.cc \
	src/options/parse_opts.cc
re2c_GEN_HDR = \
	src/parse/lex.h \
	$(re2c_GEN_PARSER_HDR)
re2c_GEN = \
	$(re2c_GEN_SRC) \
	$(re2c_GEN_HDR)
nodist_re2c_SOURCES = $(re2c_GEN)

# custom rules create headers and must go before normal rules
BUILT_SOURCES = $(re2c_GEN_SRC)

# bootstrap sources
re2c_BOOT_PARSER = bootstrap/src/parse/parser.cc
re2c_BOOT_PARSER_HDR = bootstrap/src/parse/parser.h
re2c_BOOT_DOC = bootstrap/doc/re2c.1
re2c_BOOT_HELP = bootstrap/src/msg/help.cc
re2c_BOOT = \
	$(re2c_BOOT_DOC) \
	$(re2c_BOOT_HELP) \
	$(re2c_BOOT_PARSER) \
	$(re2c_BOOT_PARSER_HDR) \
	bootstrap/src/parse/lex.cc \
	bootstrap/src/parse/lex.h \
	bootstrap/src/parse/lex_conf.cc \
	bootstrap/src/options/parse_opts.cc \
	bootstrap/src/msg/ver_to_vernum.cc

# custom sources
re2c_CUSTOM_PARSER = src/parse/parser.ypp
re2c_CUSTOM_HELP = doc/help.rst
re2c_CUSTOM = \
	$(re2c_CUSTOM_PARSER) \
	$(re2c_CUSTOM_HELP) \
	src/parse/lex.re \
	src/parse/lex_conf.re \
	src/options/parse_opts.re \
	src/msg/ver_to_vernum.re

# docs
re2c_SRC_DOC = doc/manpage.rst
re2c_SRC_DOC_EXT = \
	doc/manual/api/api.rst_ \
	doc/manual/api/interface.rst_ \
	doc/manual/conditions/conditions.rst_ \
	doc/manual/configurations/configurations.rst_ \
	doc/manual/directives/directives.rst_ \
	doc/manual/dot/dot.rst_ \
	doc/manual/encodings/encodings.rst_ \
	doc/manual/eof/01_sentinel.re \
	doc/manual/eof/01_sentinel.rst_ \
	doc/manual/eof/02_bounds_checking.re \
	doc/manual/eof/02_bounds_checking.rst_ \
	doc/manual/eof/03_eof_rule.re \
	doc/manual/eof/03_eof_rule.rst_ \
	doc/manual/eof/04_generic_api.re \
	doc/manual/eof/04_generic_api.rst_ \
	doc/manual/eof/eof.rst_ \
	doc/manual/fill/01_fill.re \
	doc/manual/fill/01_fill.rst_ \
	doc/manual/fill/02_fill.re \
	doc/manual/fill/02_fill.rst_ \
	doc/manual/fill/fill.rst_ \
	doc/manual/fill/input.txt \
	doc/manual/headers/headers.rst_ \
	doc/manual/includes/includes.rst_ \
	doc/manual/options/options_list.rst_ \
	doc/manual/regexps/regular_expressions.rst_ \
	doc/manual/reuse/reuse.re \
	doc/manual/reuse/reuse.rst_ \
	doc/manual/skeleton/skeleton.rst_ \
	doc/manual/state/push.re \
	doc/manual/state/state.rst_ \
	doc/manual/submatch/mtags.re \
	doc/manual/submatch/posix.re \
	doc/manual/submatch/stags.re \
	doc/manual/submatch/submatch_example_mtags.rst_ \
	doc/manual/submatch/submatch_example_posix.rst_ \
	doc/manual/submatch/submatch_example_stags.rst_ \
	doc/manual/submatch/submatch.rst_ \
	doc/manual/syntax/syntax.rst_ \
	doc/manual/warnings/warnings_general.rst_ \
	doc/manual/warnings/warnings_list.rst_

DOC = doc/re2c.1
man_MANS = $(DOC)

# include files (stdlib)
dist_stdlib_DATA = include/unicode_categories.re

EXTRA_DIST = \
	$(re2c_BOOT) \
	$(re2c_CUSTOM) \
	$(re2c_SRC_DOC_EXT) \
	CHANGELOG \
	NO_WARRANTY \
	README.md \
	autogen.sh \
	genhelp.sh \
	examples \
	test

CLEANFILES = \
	$(re2c_GEN) \
	$(DOC)

.re.cc:
	$(AM_V_at)$(MKDIR_P) $(@D)
	$(AM_V_GEN) if test -x $(RE2C); \
	then \
		$(top_builddir)/$(RE2C) $(RE2CFLAGS) -o $@ $< && \
		cp $(@:cc=[ch]*) $(top_srcdir)/bootstrap/$(@D); \
	else \
		cp $(top_srcdir)/bootstrap/$(@:cc=*) $(@D); \
	fi

# cannot update bootstrap with distcheck (it makes srcdir readonly),
# so we update bootstrap only on incremental build (if re2c binary exists)
.ypp.cc:
	$(AM_V_at)$(MKDIR_P) $(@D)
	$(AM_V_GEN) if test $(BISON) = "no"; \
	then \
		cp $(top_srcdir)/bootstrap/$(@:cc=*) $(@D); \
	else \
		$(BISON) --output=$@ --defines=$(@:cc=h) $< && \
		if test -x $(RE2C); then \
			cp $@ $(@:cc=h) $(top_srcdir)/bootstrap/$(@D); \
		fi; \
	fi

# lexer depends on bison-generated header
$(re2c_GEN_LEX): $(re2c_GEN_PARSER)

# rebuild all re2c sources using newly built re2c
.PHONY: bootstrap
bootstrap: all
	rm $(re2c_GEN)
	$(MAKE) all

.PHONY: docs
if REBUILD_DOCS
docs: $(DOC) $(re2c_GEN_HELP)
$(DOC): $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT)
	$(AM_V_at)$(MKDIR_P) $(@D)
	$(RST2MAN) $(top_builddir)/$(re2c_SRC_DOC) > $@
	$(AM_V_GEN)cp $@ $(top_srcdir)/$(re2c_BOOT_DOC)
$(re2c_GEN_HELP): $(re2c_CUSTOM_HELP)
	$(AM_V_at)$(MKDIR_P) $(@D)
	$(RST2MAN) $(top_builddir)/$(re2c_CUSTOM_HELP) > $@.1
	$(top_srcdir)/genhelp.sh $@.1 $@
	$(AM_V_GEN)cp $@ $(top_srcdir)/$(re2c_BOOT_HELP)
else
docs: $(DOC) $(re2c_GEN_HELP)
	$(AM_V_at)echo "Reconfigure to rebuild docs: ./configure --enable-docs"
$(DOC): $(re2c_BOOT_DOC)
	$(AM_V_at)$(MKDIR_P) $(@D)
	$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_DOC) $@
$(re2c_GEN_HELP): $(re2c_BOOT_HELP)
	$(AM_V_at)$(MKDIR_P) $(@D)
	$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_HELP) $@
endif

all-local: docs $(re2c_BOOT_PARSER)

# tests
re2c_TESTSUITE = run_tests.sh
.PHONY: tests
tests: all $(re2c_TESTSUITE)
	$(top_builddir)/$(re2c_TESTSUITE)
.PHONY: vtests
vtests: all $(re2c_TESTSUITE)
	$(top_builddir)/$(re2c_TESTSUITE) --valgrind
.PHONY: wtests
wtests: all $(re2c_TESTSUITE)
	$(top_builddir)/$(re2c_TESTSUITE) --wine -j1

re2c_test_range_SOURCES = \
	src/test/range/test-impl.h \
	src/test/range/test.cc \
	src/test/range/test.h \
	src/util/range.cc\
	src/util/range.h \
	src/util/static_assert.h

re2c_test_s_to_n32_unsafe_SOURCES = \
	src/test/s_to_n32_unsafe/test.cc \
	src/util/s_to_n32_unsafe.cc

re2c_test_ver_to_vernum_SOURCES = \
	src/test/ver_to_vernum/test.cc \
	$(re2c_GEN_VER_TO_VERNUM)

check_PROGRAMS = \
	re2c_test_range \
	re2c_test_s_to_n32_unsafe \
	re2c_test_ver_to_vernum

TESTS = \
	$(re2c_TESTSUITE) \
	$(check_PROGRAMS)

# libraries go here (in included .am files)
if WITH_LIBS
ACLOCAL_AMFLAGS = -I m4
lib_LTLIBRARIES =
include $(top_srcdir)/Makefile.lib.am
endif