# Checks for programs.
AC_PROG_MAKE_SET
LT_INIT(win32-dll)
-AC_PROG_YACC
-AC_PROG_LEX
AC_PROG_MKDIR_P
AC_PROG_LN_S
sys/socket.h \
])
-if test ! -f "$srcdir/plugins/ctf/common/metadata/parser.h"; then
- if test x"$(basename "$YACC")" != "xbison -y"; then
- AC_MSG_ERROR([[bison not found and is required when building from git.
- Please install bison]])
- fi
- AC_PATH_PROG([BISON],[bison])
- AX_PROG_BISON_VERSION([2.4], [],[
- AC_MSG_ERROR([[Bison >= 2.4 is required when building from git]])
- ])
-fi
+# set $IN_GIT_REPO if we're in the Git repository; the `bootstrap` file
+# is not distributed in tarballs
+AS_IF([test -f "$srcdir/bootstrap"], [in_git_repo=yes], [in_git_repo=no])
+AM_CONDITIONAL([IN_GIT_REPO], [test "x$in_git_repo" = "xyes"])
-if test ! -f "$srcdir/plugins/ctf/common/metadata/lexer.c"; then
- if test x"$LEX" != "xflex"; then
- AC_MSG_ERROR([[flex not found and is required when building from git.
- Please install flex]])
- fi
- AC_PATH_PROG([FLEX],[flex])
- AX_PROG_FLEX_VERSION([2.5.35], [],[
- AC_MSG_ERROR([[Flex >= 2.5.35 is required when building from git]])
- ])
-fi
+# check for bison
+AC_PROG_YACC
+AX_PROG_BISON_VERSION([2.4], [have_bison=yes])
+
+AS_IF([test "x$have_bison" != "xyes"], [
+ AS_IF([test "x$in_git_repo" = "xyes"], [
+ AC_MSG_FAILURE([
+Bison >= 2.4 is required when building from the Git repository. You can
+set the YACC variable to override automatic detection.
+ ])
+ ], [
+ AC_MSG_WARN([
+Missing Bison >= 2.4. Note that the parser files are already built in
+this distribution tarball, so Bison is only needed if you intend to
+modify their sources. You can set the YACC variable to override automatic
+detection.
+ ])
+ ])
+])
+AM_CONDITIONAL([HAVE_BISON], [test "x$have_bison" = "xyes"])
+
+# check for flex
+AC_PROG_LEX
+AX_PROG_FLEX_VERSION([2.5.35], [have_flex=yes])
+
+AS_IF([test "x$have_flex" != "xyes"], [
+ AS_IF([test "x$in_git_repo" = "xyes"], [
+ AC_MSG_FAILURE([
+Flex >= 2.5.35 is required when building from the Git repository. You can
+set the LEX variable to override automatic detection.
+ ])
+ ], [
+ AC_MSG_WARN([
+Missing Flex >= 2.5.35. Note that the lexer files are already built in
+this distribution tarball, so Flex is only needed if you intend to
+modify their sources. You can set the LEX variable to override automatic
+detection.
+ ])
+ ])
+])
+AM_CONDITIONAL([HAVE_FLEX], [test "x$have_flex" = "xyes"])
AM_PATH_GLIB_2_0(2.22.0, ,AC_MSG_ERROR([glib is required in order to compile BabelTrace - download it from ftp://ftp.gtk.org/pub/gtk]) , gmodule-no-export)
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_prog_bison_version.html
+# https://www.gnu.org/software/autoconf-archive/ax_prog_bison_version.html
# ===========================================================================
#
# SYNOPSIS
# Makes sure that bison version is greater or equal to the version
# indicated. If true the shell commands in ACTION-IF-TRUE are executed. If
# not the shell commands in commands in ACTION-IF-TRUE are executed. If
-# not the shell commands in ACTION-IF-FALSE are run. Note if $BISON is not
-# set (for example by running AC_CHECK_PROG or AC_PATH_PROG) the macro
+# not the shell commands in ACTION-IF-FALSE are run. Note if $YACC is not
+# set (for example by running AC_PROG_YACC or AC_PATH_PROG) the macro
# will fail.
#
# Example:
#
-# AC_PATH_PROG([BISON],[bison])
+# AC_PROG_YACC
# AX_PROG_BISON_VERSION([3.0.2],[ ... ],[ ... ])
#
# This will check to make sure that the bison you have is at least version
# 3.0.2 or greater.
#
-# NOTE: This macro uses the $BISON variable to perform the check.
+# NOTE: This macro uses the $YACC variable to perform the check, if it's
+# empty it will failover to the $BISON variable for backwards compatibility.
#
# LICENSE
#
# Copyright (c) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
+# 2017 Michael Jeanson <mjeanson@efficios.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 2
+#serial 4
AC_DEFUN([AX_PROG_BISON_VERSION],[
AC_REQUIRE([AC_PROG_SED])
AC_REQUIRE([AC_PROG_GREP])
- AS_IF([test -n "$BISON"],[
+ AS_IF([test -z "$YACC"],[
+ AS_IF([test -n "$BISON"],[
+ YACC=$BISON
+ ])
+ ])
+
+ AS_IF([test -n "$YACC"],[
ax_bison_version="$1"
AC_MSG_CHECKING([for bison version])
changequote(<<,>>)
- bison_version=`$BISON --version 2>&1 \
+ bison_version=`$YACC --version 2>&1 \
| $SED -n -e '/bison (GNU Bison)/b inspect
b
: inspect
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_prog_flex_version.html
+# https://www.gnu.org/software/autoconf-archive/ax_prog_flex_version.html
# ===========================================================================
#
# SYNOPSIS
# Makes sure that flex version is greater or equal to the version
# indicated. If true the shell commands in ACTION-IF-TRUE are executed. If
# not the shell commands in commands in ACTION-IF-TRUE are executed. If
-# not the shell commands in ACTION-IF-FALSE are run. Note if $FLEX is not
-# set (for example by running AC_CHECK_PROG or AC_PATH_PROG) the macro
+# not the shell commands in ACTION-IF-FALSE are run. Note if $LEX is not
+# set (for example by running AC_PROG_LEX or AC_PATH_PROG) the macro
# will fail.
#
# Example:
#
-# AC_PATH_PROG([FLEX],[flex])
+# AC_PROG_LEX
# AX_PROG_FLEX_VERSION([2.5.39],[ ... ],[ ... ])
#
# This will check to make sure that the flex you have is at least version
# 2.5.39 or greater.
#
-# NOTE: This macro uses the $FLEX variable to perform the check.
+# NOTE: This macro uses the $LEX variable to perform the check, if it's
+# empty it will failover to the $FLEX variable for backwards compatibility.
#
# LICENSE
#
# Copyright (c) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
+# 2017 Michael Jeanson <mjeanson@efficios.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 1
+#serial 3
AC_DEFUN([AX_PROG_FLEX_VERSION],[
AC_REQUIRE([AC_PROG_SED])
AC_REQUIRE([AC_PROG_GREP])
- AS_IF([test -n "$FLEX"],[
+ AS_IF([test -z "$LEX"],[
+ AS_IF([test -n "$FLEX"],[
+ LEX=$FLEX
+ ])
+ ])
+
+ AS_IF([test -n "$LEX"],[
ax_flex_version="$1"
AC_MSG_CHECKING([for flex version])
changequote(<<,>>)
- flex_version=`$FLEX --version 2>&1 \
+ flex_version=`$LEX --version 2>&1 \
| $SED -n -e '/flex /b inspect
b
: inspect
AM_CPPFLAGS += -I$(builddir) -I$(srcdir)
-BUILT_SOURCES = parser.h parser.c lexer.c
AM_YFLAGS = -t -d -v
noinst_LTLIBRARIES = libctf-parser.la libctf-ast.la
+BUILT_SOURCES = parser.h
+
libctf_parser_la_SOURCES = lexer.l parser.y objstack.c
-# ctf-scanner-symbols.h is included to prefix generated yy_* symbols
+# scanner-symbols.h is included to prefix generated yy_* symbols
# with bt_.
libctf_parser_la_CPPFLAGS = $(AM_CPPFLAGS) \
-include $(srcdir)/scanner-symbols.h
libctf_ast_la_LIBADD += -lrpcrt4 -lintl -liconv -lole32 $(POPT_LIBS)
endif
-CLEANFILES = $(BUILT_SOURCES) parser.output
+# start with empty files to clean
+CLEANFILES =
+
+if HAVE_BISON
+# we have bison: we can clean the generated parser files
+CLEANFILES += parser.c parser.h parser.output
+else # HAVE_BISON
+# create target used to stop the build if we want to build the parser,
+# but we don't have the necessary tool to do so
+ERR_MSG = "Error: Cannot build target because bison is missing."
+ERR_MSG += "Make sure bison is installed and run the configure script again."
+
+parser.c parser.h: parser.y
+ @echo $(ERR_MSG)
+ @false
+
+all-local: parser.c parser.h
+endif # HAVE_BISON
+
+if HAVE_FLEX
+# we have flex: we can clean the generated lexer files
+CLEANFILES += lexer.c
+else # HAVE_FLEX
+# create target used to stop the build if we want to build the lexer,
+# but we don't have the necessary tool to do so
+ERR_MSG = "Error: Cannot build target because flex is missing."
+ERR_MSG += "Make sure flex is installed and run the configure script again."
+
+filter-lexer.c: lexer.l
+ @echo $(ERR_MSG)
+ @false
+
+all-local: lexer.c
+endif # HAVE_FLEX