summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2016-11-26 23:47:12 +0800
committerWill Estes <westes575@gmail.com>2016-12-29 17:26:07 -0500
commitadddfba7ab9f640e9d02819909e53b7a220766ba (patch)
tree5a52f6438922449d72dbe87aca7cd9125966d145
parent6964073c594cf999d3747993b73f707e4702e024 (diff)
build: New configure option '--disable-bootstrap'.
If configure is run with '--disable-bootstrap', then stage1flex won't be built and stage1scan.c will be generated by sed'ing scan.c. This option is intended to workaround bootstrap bugs rather than to fix the bootstrapping issues which are proving subtler and harder to fix than anyone would like.
-rw-r--r--configure.ac9
-rw-r--r--src/Makefile.am15
2 files changed, 20 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 7d742c5..901339f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,6 +66,15 @@ AC_ARG_ENABLE([libfl],
[], [enable_libfl=yes])
AM_CONDITIONAL([ENABLE_LIBFL], [test "x$enable_libfl" = xyes])
+# --disable-bootstrap is intended only to workaround problems with bootstrap
+# (e.g. when cross-compiling flex or when bootstrapping has bugs).
+# Ideally we should be able to bootstrap even when cross-compiling.
+AC_ARG_ENABLE([bootstrap],
+ [AS_HELP_STRING([--disable-bootstrap],
+ [don't perform a bootstrap when building flex])],
+ [], [enable_bootstrap=yes])
+AM_CONDITIONAL([ENABLE_BOOTSTRAP], [test "x$enable_bootstrap" = xyes])
+
AC_PATH_PROG([BISON], bison, no)
AS_IF([test "$BISON" != no],[],
[ AC_SUBST([BISON], [\${top_srcdir}/build-aux/missing bison])
diff --git a/src/Makefile.am b/src/Makefile.am
index a4742fd..3b5e362 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,9 @@ LIBS = @LIBS@
m4 = @M4@
bin_PROGRAMS = flex
+if ENABLE_BOOTSTRAP
noinst_PROGRAMS = stage1flex
+endif
if ENABLE_LIBFL
lib_LTLIBRARIES = libfl.la
@@ -82,16 +84,21 @@ skel.c: flex.skl mkskel.sh flexint.h tables_shared.h tables_shared.c
$(SHELL) $(srcdir)/mkskel.sh > $@.tmp
mv $@.tmp $@
+if ENABLE_BOOTSTRAP
stage1scan.c: scan.l stage1flex$(EXEEXT)
./stage1flex$(EXEEXT) $(AM_LFLAGS) $(LFLAGS) -o $@ $<
+else
+stage1scan.c: scan.c
+ sed 's|^\(#line .*\)"'`printf %s $< | sed 's|[][\\\\.*]|\\\\&|g'`'"|\1"$@"|g' $< > $@
+endif
# make needs to be told to make parse.h so that parallelized runs will
# not fail.
-main.c : parse.h
-scan.c : parse.h
-stage1scan.c : parse.h
-yylex.c : parse.h
+main.c: parse.h
+yylex.c: parse.h
+stage1flex-scan.$(OBJEXT): parse.h
+flex-stage1scan.$(OBJEXT): parse.h
# Run GNU indent on sources. Don't run this unless all the sources compile cleanly.
#