Skip to content

Commit

Permalink
Makefile.am: avoid POSIX-incompatible pattern rules.
Browse files Browse the repository at this point in the history
This is to fix building with bmake on FreeBSD.

Replace all pattern rules with POSIX-compatible suffix rules. As the latter are
much less flexible than pattern rules, this required creating copies or symlinks
with appropriate names for source files that don't fit into the naming scheme
implied by suffix rules.

Also, dependencies on custom build scripts had to be dropped, as suffix rules
don't allow additional prerequisites.
  • Loading branch information
skvadrik committed Nov 18, 2024
1 parent cf7e2c7 commit 7f26edd
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 22 deletions.
29 changes: 13 additions & 16 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ re2c_BOOT = \
bootstrap/src/parse/conf_parser.cc

# custom sources
re2c_CUSTOM_HELP = doc/help.rst
re2c_CUSTOM = \
$(re2c_CUSTOM_HELP) \
src/msg/ver_to_vernum.re \
src/options/parse_opts.re \
src/parse/lexer.re \
Expand All @@ -219,7 +217,6 @@ re2c_CUSTOM = \
src/parse/conf_parser.ypp

# docs
re2c_SRC_DOC = doc/manpage.rst
# To build the list of examples for all backends, run:
# find examples -regex '.*\.re\|.*\(state\|01_basic\|definitions\)\..*' -printf '\t%p \\\n' | sort
re2c_SRC_DOC_EXT = \
Expand Down Expand Up @@ -569,6 +566,7 @@ if WITH_ZIG
DOCS += doc/re2zig.1
HELP += src/msg/help_re2zig.cc
endif
BUILT_SOURCES += $(HELP)

man_MANS = $(DOCS)

Expand Down Expand Up @@ -625,13 +623,13 @@ CLEANFILES = \
if REBUILD_SYNTAX
STX2CPP = $(top_srcdir)/build/stx2cpp.py
# generate C++ sources from syntax configs and update bootstrap files
src/default_syntax_%.cc : $(top_srcdir)/include/syntax/% $(STX2CPP)
.stx.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(STX2CPP) $< $@
$(AM_V_GEN)cp -f $@ $(top_srcdir)/bootstrap/$@
else
# copy bootstrap files
src/default_syntax_%.cc : bootstrap/src/default_syntax_%.cc
.stx.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$@ $(@D)
$(AM_V_at)echo "Reconfigure with --enable-syntax to regenerate $@"
Expand Down Expand Up @@ -677,32 +675,31 @@ bootstrap: all

.PHONY: docs
if REBUILD_DOCS
docs: $(DOCS) $(HELP)
RST2TXT = $(top_srcdir)/build/rst2txt.py
RST2MAN = $(top_srcdir)/build/rst2man.py
SPLITMAN = $(top_srcdir)/build/split_man.py
docs: $(DOCS) $(HELP) $(SPLITMAN) $(RST2MAN) $(RST2TXT)
# generate manpage
doc/re2%.1: $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT) $(SPLITMAN) $(RST2MAN)
.rst.1:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$(re2c_SRC_DOC) $(top_builddir)/$@.rst \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$@.rst > $@ \
&& cp $@ $(top_srcdir)/bootstrap/$@ \
&& rm $(top_builddir)/$@.rst
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$< $(top_builddir)/$< \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$< > $@ \
&& cp $@ $(top_srcdir)/bootstrap/$@
# generate help
src/msg/help_re2%.cc: $(re2c_CUSTOM_HELP) $(re2c_SRC_DOC_EXT) $(RST2TXT)
.rst.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$(re2c_CUSTOM_HELP) $(<D)/$(@F).rst \
&& $(PYTHON) $(RST2TXT) --variable-name=help $(<D)/$(@F).rst $@ \
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$< $(top_builddir)/$< \
&& $(PYTHON) $(RST2TXT) --variable-name=help $(top_builddir)/$< $@ \
&& cp $@ $(top_srcdir)/bootstrap/$@
else
docs: $(DOCS) $(HELP)
$(AM_V_at)echo "Reconfigure with --enable-docs to rebuild docs"
# copy bootstrap manpage
doc/re2%.1: bootstrap/doc/re2%.1
.rst.1:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$@ $@
# copy bootstrap help
src/msg/help_re2%.cc: $(top_srcdir)/bootstrap/src/msg/help_re2%.cc
.rst.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$@ $@
endif
Expand Down
3 changes: 2 additions & 1 deletion build/stx2cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
output = sys.argv[2]

with open(output, 'w') as output_file:
name = os.path.splitext(os.path.basename(input))[0].upper()
output_file.write("#include \"src/parse/conf_parser.h\"\n")
output_file.write("const char* DEFAULT_SYNTAX_" + os.path.basename(input).upper() + " =\n")
output_file.write("const char* " + name + " =\n")

# write input file line by line as a string, escaping characters as needed
with open(input, 'r') as input_file:
Expand Down
51 changes: 46 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,59 @@ AC_CONFIG_FILES([
benchmarks/submatch_dfa_aot/Makefile
benchmarks/submatch_dfa_jit/Makefile
benchmarks/submatch_java/Makefile
doc/manpage.rst
doc/help.rst
])
AC_CONFIG_FILES([run_tests.py],
[chmod +x run_tests.py])
AC_CONFIG_FILES([benchmarks/submatch_dfa_aot/run.py],
[chmod +x benchmarks/submatch_dfa_aot/run.py])
AC_CONFIG_FILES([benchmarks/submatch_java/run.py],
[chmod +x benchmarks/submatch_java/run.py])


AC_CONFIG_LINKS([benchmarks/submatch_java/chart.js:benchmarks/submatch_java/chart.js])
# Custom names are needed to accommodate POSIX Make suffix rules (bmake in
# particular) instead of the more generic and flexible GNU Make pattern rules.
# Copies are needed to patch them in-place with build/split_man.py.
AC_CONFIG_FILES([
src/msg/help_re2c.rst:doc/help.rst.in
src/msg/help_re2d.rst:doc/help.rst.in
src/msg/help_re2go.rst:doc/help.rst.in
src/msg/help_re2hs.rst:doc/help.rst.in
src/msg/help_re2java.rst:doc/help.rst.in
src/msg/help_re2js.rst:doc/help.rst.in
src/msg/help_re2ocaml.rst:doc/help.rst.in
src/msg/help_re2py.rst:doc/help.rst.in
src/msg/help_re2rust.rst:doc/help.rst.in
src/msg/help_re2v.rst:doc/help.rst.in
src/msg/help_re2zig.rst:doc/help.rst.in
doc/re2c.rst:doc/manpage.rst.in
doc/re2d.rst:doc/manpage.rst.in
doc/re2go.rst:doc/manpage.rst.in
doc/re2hs.rst:doc/manpage.rst.in
doc/re2java.rst:doc/manpage.rst.in
doc/re2js.rst:doc/manpage.rst.in
doc/re2ocaml.rst:doc/manpage.rst.in
doc/re2py.rst:doc/manpage.rst.in
doc/re2rust.rst:doc/manpage.rst.in
doc/re2v.rst:doc/manpage.rst.in
doc/re2zig.rst:doc/manpage.rst.in
])
# Custom names are needed to accommodate POSIX Make suffix rules (bmake in
# particular) instead of the more generic and flexible GNU Make pattern rules.
AC_CONFIG_LINKS([
src/default_syntax_c.stx:include/syntax/c
src/default_syntax_d.stx:include/syntax/d
src/default_syntax_go.stx:include/syntax/go
src/default_syntax_haskell.stx:include/syntax/haskell
src/default_syntax_java.stx:include/syntax/java
src/default_syntax_js.stx:include/syntax/js
src/default_syntax_ocaml.stx:include/syntax/ocaml
src/default_syntax_python.stx:include/syntax/python
src/default_syntax_rust.stx:include/syntax/rust
src/default_syntax_v.stx:include/syntax/v
src/default_syntax_zig.stx:include/syntax/zig
])
AC_CONFIG_LINKS([
benchmarks/submatch_java/chart.js:benchmarks/submatch_java/chart.js
])


LT_INIT([dlopen win32-dll])
Expand Down

0 comments on commit 7f26edd

Please sign in to comment.