1SUBDIRS = . 2 3# stdlib directory 4stdlibdir = $(datadir)/re2c/stdlib 5 6# do not add compiler options/warnings here, add them in configure.ac 7AM_CXXFLAGS = $(CXXFLAGSDEFAULT) 8AM_CXXFLAGS += -DRE2C_STDLIB_DIR='"$(stdlibdir)/"' 9if DEBUG 10AM_CXXFLAGS += -DRE2C_DEBUG 11endif 12 13RE2CFLAGS = -br -W -Wno-match-empty-string 14 15# binary 16bin_PROGRAMS = re2c 17noinst_PROGRAMS = 18 19# sources 20re2c_HDR = \ 21 src/constants.h \ 22 src/codegen/code.h \ 23 src/codegen/helpers.h \ 24 src/options/opt.h \ 25 src/options/symtab.h \ 26 src/adfa/adfa.h \ 27 src/cfg/cfg.h \ 28 src/dfa/closure_leftmost.h \ 29 src/dfa/closure_posix.h \ 30 src/dfa/determinization.h \ 31 src/dfa/dfa.h \ 32 src/dfa/posix_precedence.h \ 33 src/dfa/stacmd.h \ 34 src/dfa/tag_history.h \ 35 src/dfa/tagver_table.h \ 36 src/dfa/tcmd.h \ 37 src/nfa/nfa.h \ 38 src/encoding/case.h \ 39 src/encoding/ebcdic/ebcdic.h \ 40 src/encoding/ebcdic/ebcdic_regexp.h \ 41 src/encoding/enc.h \ 42 src/encoding/range_suffix.h \ 43 src/encoding/utf8/utf8.h \ 44 src/encoding/utf8/utf8_regexp.h \ 45 src/encoding/utf16/utf16_regexp.h \ 46 src/encoding/utf16/utf16.h \ 47 src/msg/location.h \ 48 src/msg/msg.h \ 49 src/msg/ver_to_vernum.h \ 50 src/msg/warn.h \ 51 src/regexp/re.h \ 52 src/regexp/rule.h \ 53 src/regexp/tag.h \ 54 src/compile.h \ 55 src/skeleton/mtag_trie.h \ 56 src/skeleton/path.h \ 57 src/skeleton/skeleton.h \ 58 src/parse/ast.h \ 59 src/parse/input.h \ 60 src/parse/parse.h \ 61 src/parse/scanner.h \ 62 src/parse/unescape.h \ 63 src/debug/debug.h \ 64 src/util/allocate.h \ 65 src/util/attribute.h \ 66 src/util/c99_stdint.h \ 67 src/util/file_utils.h \ 68 src/util/fixed_allocator.h \ 69 src/util/forbid_copy.h \ 70 src/util/free_list.h \ 71 src/util/hash32.h \ 72 src/util/local_increment.h \ 73 src/util/lookup.h \ 74 src/util/range.h \ 75 src/util/s_to_n32_unsafe.h \ 76 src/util/slab_allocator.h \ 77 src/util/smart_ptr.h \ 78 src/util/static_assert.h \ 79 src/util/string_utils.h \ 80 src/util/temp_file.h \ 81 src/util/u32lim.h \ 82 src/util/uniq_vector.h 83re2c_SRC = \ 84 src/codegen/code_goto.cc \ 85 src/codegen/combine.cc \ 86 src/codegen/gen_bitmaps.cc \ 87 src/codegen/gen_delayed.cc \ 88 src/codegen/gen_dfa.cc \ 89 src/codegen/gen_goto.cc \ 90 src/codegen/gen_program.cc \ 91 src/codegen/gen_state.cc \ 92 src/codegen/helpers.cc \ 93 src/codegen/render.cc \ 94 src/options/opt.cc \ 95 src/options/symtab.cc \ 96 src/nfa/estimate_size.cc \ 97 src/nfa/re_to_nfa.cc \ 98 src/adfa/adfa.cc \ 99 src/debug/dump_adfa.cc \ 100 src/debug/dump_cfg.cc \ 101 src/debug/dump_dfa.cc \ 102 src/debug/dump_dfa_tree.cc \ 103 src/debug/dump_interf.cc \ 104 src/debug/dump_nfa.cc \ 105 src/cfg/cfg.cc \ 106 src/cfg/compact.cc \ 107 src/cfg/dce.cc \ 108 src/cfg/freeze.cc \ 109 src/cfg/interfere.cc \ 110 src/cfg/liveanal.cc \ 111 src/cfg/normalize.cc \ 112 src/cfg/optimize.cc \ 113 src/cfg/rename.cc \ 114 src/cfg/varalloc.cc \ 115 src/dfa/closure.cc \ 116 src/dfa/dead_rules.cc \ 117 src/dfa/determinization.cc \ 118 src/dfa/fallback_tags.cc \ 119 src/dfa/fillpoints.cc \ 120 src/dfa/find_state.cc \ 121 src/dfa/minimization.cc \ 122 src/dfa/stacmd.cc \ 123 src/dfa/tagver_table.cc \ 124 src/dfa/tcmd.cc \ 125 src/encoding/ebcdic/ebcdic_regexp.cc \ 126 src/encoding/enc.cc \ 127 src/encoding/range_suffix.cc \ 128 src/encoding/utf8/utf8_regexp.cc \ 129 src/encoding/utf8/utf8.cc \ 130 src/encoding/utf16/utf16_regexp.cc \ 131 src/encoding/utf16/utf16.cc \ 132 src/msg/msg.cc \ 133 src/msg/warn.cc \ 134 src/regexp/ast_to_re.cc \ 135 src/regexp/default_tags.cc \ 136 src/regexp/fixed_tags.cc \ 137 src/regexp/nullable.cc \ 138 src/regexp/re.cc \ 139 src/regexp/rule.cc \ 140 src/regexp/split_charset.cc \ 141 src/regexp/tag.cc \ 142 src/compile.cc \ 143 src/skeleton/control_flow.cc \ 144 src/skeleton/generate_code.cc \ 145 src/skeleton/generate_data.cc \ 146 src/skeleton/maxpath.cc \ 147 src/skeleton/skeleton.cc \ 148 src/parse/ast.cc \ 149 src/parse/input.cc \ 150 src/parse/parse.cc \ 151 src/parse/scanner.cc \ 152 src/parse/unescape.cc \ 153 src/util/file_utils.cc \ 154 src/util/s_to_n32_unsafe.cc \ 155 src/util/temp_file.cc \ 156 src/util/range.cc 157re2c_SOURCES = \ 158 src/main.cc \ 159 $(re2c_HDR) \ 160 $(re2c_SRC) 161 162# autogenerated sources 163re2c_GEN_HELP = src/msg/help.cc 164re2c_GEN_LEX = src/parse/lex.cc 165re2c_GEN_PARSER = src/parse/parser.cc 166re2c_GEN_PARSER_HDR = src/parse/parser.h 167re2c_GEN_VER_TO_VERNUM = src/msg/ver_to_vernum.cc 168re2c_GEN_SRC = \ 169 $(re2c_GEN_HELP) \ 170 $(re2c_GEN_LEX) \ 171 $(re2c_GEN_PARSER) \ 172 $(re2c_GEN_VER_TO_VERNUM) \ 173 src/parse/lex_conf.cc \ 174 src/options/parse_opts.cc 175re2c_GEN_HDR = \ 176 src/parse/lex.h \ 177 $(re2c_GEN_PARSER_HDR) 178re2c_GEN = \ 179 $(re2c_GEN_SRC) \ 180 $(re2c_GEN_HDR) 181nodist_re2c_SOURCES = $(re2c_GEN) 182 183# custom rules create headers and must go before normal rules 184BUILT_SOURCES = $(re2c_GEN_SRC) 185 186# bootstrap sources 187re2c_BOOT_PARSER = bootstrap/src/parse/parser.cc 188re2c_BOOT_PARSER_HDR = bootstrap/src/parse/parser.h 189re2c_BOOT_DOC_C = bootstrap/doc/re2c.1 190re2c_BOOT_DOC_GO = bootstrap/doc/re2go.1 191re2c_BOOT_HELP = bootstrap/src/msg/help.cc 192re2c_BOOT = \ 193 $(re2c_BOOT_DOC_C) \ 194 $(re2c_BOOT_DOC_GO) \ 195 $(re2c_BOOT_HELP) \ 196 $(re2c_BOOT_PARSER) \ 197 $(re2c_BOOT_PARSER_HDR) \ 198 bootstrap/src/parse/lex.cc \ 199 bootstrap/src/parse/lex.h \ 200 bootstrap/src/parse/lex_conf.cc \ 201 bootstrap/src/options/parse_opts.cc \ 202 bootstrap/src/msg/ver_to_vernum.cc 203 204# custom sources 205re2c_CUSTOM_PARSER = src/parse/parser.ypp 206re2c_CUSTOM_HELP = doc/help.rst 207re2c_CUSTOM = \ 208 $(re2c_CUSTOM_PARSER) \ 209 $(re2c_CUSTOM_HELP) \ 210 src/parse/lex.re \ 211 src/parse/lex_conf.re \ 212 src/options/parse_opts.re \ 213 src/msg/ver_to_vernum.re 214 215# docs 216re2c_SRC_DOC = doc/manpage.rst 217re2c_SRC_DOC_EXT = \ 218 doc/manual/api/interface.rst_ \ 219 doc/manual/conditions/conditions.rst_ \ 220 doc/manual/configurations/configurations.rst_ \ 221 doc/manual/directives/directives.rst_ \ 222 doc/manual/dot/dot.rst_ \ 223 doc/manual/encodings/encodings.rst_ \ 224 doc/manual/eof/01_sentinel.rst_ \ 225 doc/manual/eof/02_bounds_checking.rst_ \ 226 doc/manual/eof/03_eof_rule.rst_ \ 227 doc/manual/eof/04_generic_api.rst_ \ 228 doc/manual/eof/eof.rst_ \ 229 doc/manual/fill/01_fill.rst_ \ 230 doc/manual/fill/02_fill.rst_ \ 231 doc/manual/fill/fill.rst_ \ 232 doc/manual/headers/headers.rst_ \ 233 doc/manual/includes/includes.rst_ \ 234 doc/manual/options/debug.rst_ \ 235 doc/manual/options/internal.rst_ \ 236 doc/manual/options/options.rst_ \ 237 doc/manual/regexps/regular_expressions.rst_ \ 238 doc/manual/reuse/reuse.rst_ \ 239 doc/manual/skeleton/skeleton.rst_ \ 240 doc/manual/state/state.rst_ \ 241 doc/manual/submatch/submatch_example_mtags.rst_ \ 242 doc/manual/submatch/submatch_example_posix.rst_ \ 243 doc/manual/submatch/submatch_example_stags.rst_ \ 244 doc/manual/submatch/submatch_example_stags_fill.rst_ \ 245 doc/manual/submatch/submatch.rst_ \ 246 doc/manual/syntax/syntax.rst_ \ 247 doc/manual/syntax/api1.rst_ \ 248 doc/manual/syntax/api2_c.rst_ \ 249 doc/manual/syntax/api2_go.rst_ \ 250 doc/manual/syntax/api3.rst_ \ 251 doc/manual/warnings/warnings_general.rst_ \ 252 doc/manual/warnings/warnings_list.rst_ \ 253 examples/c/01_basic.re \ 254 examples/c/conditions/parse_u32_conditions.re \ 255 examples/c/encodings/unicode_identifier.re \ 256 examples/c/eof/01_sentinel.re \ 257 examples/c/eof/02_bounds_checking.re \ 258 examples/c/eof/03_eof_rule.re \ 259 examples/c/eof/05_generic_api_eof_rule.re \ 260 examples/c/fill/01_fill.re \ 261 examples/c/fill/02_fill.re \ 262 examples/c/headers/header.re \ 263 examples/c/headers/src/lexer/lexer.h \ 264 examples/c/includes/include.re \ 265 examples/c/includes/definitions.h \ 266 examples/c/reuse/reuse.re \ 267 examples/c/reuse/usedir.re \ 268 examples/c/state/push.re \ 269 examples/c/submatch/01_stags.re \ 270 examples/c/submatch/01_stags_fill.re \ 271 examples/c/submatch/02_mtags.re \ 272 examples/c/submatch/03_posix.re \ 273 examples/go/01_basic.re \ 274 examples/go/conditions/parse_u32_conditions.re \ 275 examples/go/encodings/unicode_identifier.re \ 276 examples/go/eof/01_sentinel.re \ 277 examples/go/eof/02_bounds_checking.re \ 278 examples/go/eof/03_eof_rule.re \ 279 examples/go/eof/05_generic_api_eof_rule.re \ 280 examples/go/fill/01_fill.re \ 281 examples/go/fill/02_fill.re \ 282 examples/go/headers/header.re \ 283 examples/go/headers/src/lexer/lexer.go \ 284 examples/go/includes/include.re \ 285 examples/go/includes/definitions.go \ 286 examples/go/reuse/reuse.re \ 287 examples/go/reuse/usedir.re \ 288 examples/go/state/push.re \ 289 examples/go/submatch/01_stags.re \ 290 examples/go/submatch/02_mtags.re \ 291 examples/go/submatch/03_posix.re 292 293DOC_C = doc/re2c.1 294DOCS = $(DOC_C) 295if WITH_GOLANG 296DOC_GO = doc/re2go.1 297DOCS += $(DOC_GO) 298endif 299man_MANS = $(DOCS) 300 301# include files (stdlib) 302dist_stdlib_DATA = include/unicode_categories.re 303 304CMAKEFILES := \ 305 CMakeLists.txt \ 306 cmake 307 308EXTRA_DIST = \ 309 $(re2c_BOOT) \ 310 $(re2c_CUSTOM) \ 311 $(re2c_SRC_DOC_EXT) \ 312 $(CMAKEFILES) \ 313 CHANGELOG \ 314 LICENSE \ 315 NO_WARRANTY \ 316 README.md \ 317 autogen.sh \ 318 build \ 319 examples \ 320 test 321 322CLEANFILES = \ 323 $(re2c_GEN) \ 324 $(DOCS) 325 326if REBUILD_LEXERS 327# generate lexer and update bootstrap files 328.re.cc: 329 $(AM_V_at)$(MKDIR_P) $(@D) 330 $(AM_V_GEN)if test -x $(RE2C_FOR_BUILD); \ 331 then \ 332 $(RE2C_FOR_BUILD) $(RE2CFLAGS) -o $@ $< && \ 333 cp $(@:cc=[ch]*) $(top_srcdir)/bootstrap/$(@D); \ 334 else \ 335 echo "RE2C is not an executable file" && exit 1 ; \ 336 fi 337else 338# copy bootstrap files 339.re.cc: 340 $(AM_V_at)$(MKDIR_P) $(@D) 341 $(AM_V_GEN)cp $(top_srcdir)/bootstrap/$(@:cc=*) $(@D) 342 $(AM_V_at)echo "Reconfigure with --enable-lexers to regenerate $@" 343endif 344 345# cannot update bootstrap with distcheck (it makes srcdir readonly), 346# so we update bootstrap only on incremental build (if re2c binary exists) 347.ypp.cc: 348 $(AM_V_at)$(MKDIR_P) $(@D) 349 $(AM_V_GEN)if test $(BISON) = "no"; \ 350 then \ 351 cp $(top_srcdir)/bootstrap/$(@:cc=*) $(@D); \ 352 else \ 353 $(BISON) --output=$@ --defines=$(@:cc=h) $< && \ 354 if test -x $(top_builddir)/re2c$(EXEEXT); then \ 355 cp $@ $(@:cc=h) $(top_srcdir)/bootstrap/$(@D); \ 356 fi; \ 357 fi 358 359# lexer depends on bison-generated header 360$(re2c_GEN_LEX): $(re2c_GEN_PARSER) 361 362# rebuild all re2c sources using newly built re2c 363.PHONY: bootstrap 364bootstrap: all 365 rm $(re2c_GEN) 366 $(MAKE) all 367 368.PHONY: docs 369if REBUILD_DOCS 370docs: $(DOCS) $(re2c_GEN_HELP) 371GENHELP = $(top_srcdir)/build/gen_help.sh 372SPLITMAN = $(top_srcdir)/build/split_man.sh 373# generate manpage for C 374$(DOC_C): $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT) $(SPLITMAN) 375 $(AM_V_at)$(MKDIR_P) $(@D) 376 $(AM_V_GEN)$(SPLITMAN) $(top_builddir)/$(re2c_SRC_DOC) $(top_builddir)/$(re2c_SRC_DOC).c c \ 377 && $(RST2MAN) --tab-width=4 $(top_builddir)/$(re2c_SRC_DOC).c > $@ \ 378 && cp $@ $(top_srcdir)/$(re2c_BOOT_DOC_C) \ 379 && rm $(top_builddir)/$(re2c_SRC_DOC).c 380# generate manpage for Go 381$(DOC_GO): $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT) $(SPLITMAN) 382 $(AM_V_at)$(MKDIR_P) $(@D) 383 $(AM_V_GEN)$(SPLITMAN) $(top_builddir)/$(re2c_SRC_DOC) $(top_builddir)/$(re2c_SRC_DOC).go go \ 384 && $(RST2MAN) --tab-width=4 $(top_builddir)/$(re2c_SRC_DOC).go > $@ \ 385 && cp $@ $(top_srcdir)/$(re2c_BOOT_DOC_GO) \ 386 && rm $(top_builddir)/$(re2c_SRC_DOC).go 387# generate help 388$(re2c_GEN_HELP): $(re2c_CUSTOM_HELP) $(GENHELP) 389 $(AM_V_at)$(MKDIR_P) $(@D) 390 $(AM_V_GEN)$(RST2MAN) $(top_builddir)/$(re2c_CUSTOM_HELP) > $@.1 \ 391 && $(GENHELP) $@.1 $@ \ 392 && cp $@ $(top_srcdir)/$(re2c_BOOT_HELP) \ 393 && rm $@.1 394else 395docs: $(DOCS) $(re2c_GEN_HELP) 396 $(AM_V_at)echo "Reconfigure with --enable-docs to rebuild docs" 397# copy bootstrap manpage for C 398$(DOC_C): $(re2c_BOOT_DOC_C) 399 $(AM_V_at)$(MKDIR_P) $(@D) 400 $(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_DOC_C) $@ 401# copy bootstrap manpage for Go 402$(DOC_GO): $(re2c_BOOT_DOC_GO) 403 $(AM_V_at)$(MKDIR_P) $(@D) 404 $(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_DOC_GO) $@ 405# copy bootstrap help 406$(re2c_GEN_HELP): $(re2c_BOOT_HELP) 407 $(AM_V_at)$(MKDIR_P) $(@D) 408 $(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_HELP) $@ 409endif 410 411all-local: docs $(re2c_BOOT_PARSER) 412 413# tests 414re2c_TESTSUITE = run_tests.py 415.PHONY: tests 416tests: all $(re2c_TESTSUITE) 417 $(top_builddir)/$(re2c_TESTSUITE) 418.PHONY: vtests 419vtests: all $(re2c_TESTSUITE) 420 $(top_builddir)/$(re2c_TESTSUITE) --valgrind 421.PHONY: wtests 422wtests: all $(re2c_TESTSUITE) 423 $(top_builddir)/$(re2c_TESTSUITE) --wine -j1 424 425re2c_test_range_SOURCES = \ 426 src/test/range/test-impl.h \ 427 src/test/range/test.cc \ 428 src/test/range/test.h \ 429 src/util/range.cc\ 430 src/util/range.h \ 431 src/util/static_assert.h 432 433re2c_test_s_to_n32_unsafe_SOURCES = \ 434 src/test/s_to_n32_unsafe/test.cc \ 435 src/util/s_to_n32_unsafe.cc 436 437re2c_test_ver_to_vernum_SOURCES = \ 438 src/test/ver_to_vernum/test.cc \ 439 $(re2c_GEN_VER_TO_VERNUM) 440 441re2c_test_argsubst_SOURCES = \ 442 src/test/argsubst/test.cc 443 444check_PROGRAMS = \ 445 re2c_test_range \ 446 re2c_test_s_to_n32_unsafe \ 447 re2c_test_ver_to_vernum \ 448 re2c_test_argsubst 449 450TESTS = \ 451 $(re2c_TESTSUITE) \ 452 $(check_PROGRAMS) 453 454# benchmarks 455if WITH_BENCHMARKS 456SUBDIRS += benchmarks/submatch_dfa_aot 457EXTRA_DIST += benchmarks/submatch_dfa_aot 458endif 459 460# libre2c 461if WITH_LIBS 462ACLOCAL_AMFLAGS = -I m4 463lib_LTLIBRARIES = 464include $(top_srcdir)/Makefile.lib.am 465endif 466 467# re2go 468if WITH_GOLANG 469bin_PROGRAMS += re2go 470re2go_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=LANG_GO 471re2go_SOURCES = $(re2c_SOURCES) 472nodist_re2go_SOURCES = $(nodist_re2c_SOURCES) 473endif 474