AC_PATH_PROG([PGREP], [pgrep], [no])
AM_CONDITIONAL([HAS_PGREP], [test "x$PGREP" != "xno"])
-if test ! -f "$srcdir/src/lib/lttng-ctl/filter/filter-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]])
+# check for bison
+have_bison=yes
+
+AS_IF([test "x$(basename "$YACC")" != "xbison -y"], [have_bison=no])
+AC_PATH_PROG([BISON], [bison])
+AX_PROG_BISON_VERSION([2.4], [], [have_bison=no])
+
+AS_IF([test "x$have_bison" = "xno"], [
+ AS_IF([test "x$in_git_repo" = "xyes"], [
+ AC_MSG_ERROR([Bison >= 2.4 is required when building from the Git repository.])
+ ], [
+ 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.
+ ])
])
-fi
+])
-if test ! -f "$srcdir/src/lib/lttng-ctl/filter/filter-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]])
+# export bison condition
+AM_CONDITIONAL([HAVE_BISON], [test "x$have_bison" = "xyes"])
+
+# check for flex
+have_flex=yes
+
+AS_IF([test "x$LEX" != "xflex"], [have_flex=no])
+AC_PATH_PROG([FLEX], [flex])
+AX_PROG_FLEX_VERSION([2.5.35], [], [have_flex=no])
+
+AS_IF([test "x$have_flex" = "xno"], [
+ AS_IF([test "x$in_git_repo" = "xyes"], [
+ AC_MSG_ERROR([Flex >= 2.5.35 is required when building from the Git repository.])
+ ], [
+ 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.
+ ])
])
-fi
+])
+
+# export flex condition
+AM_CONDITIONAL([HAVE_FLEX], [test "x$have_flex" = "xyes"])
CFLAGS="-Wall $CFLAGS -g -fno-strict-aliasing"
filter-symbols.h
BUILT_SOURCES = filter-parser.h
-AM_YFLAGS = -t -d -v
-libfilter_la_SOURCES = filter-lexer.l filter-parser.y \
+libfilter_la_SOURCES = \
+ filter-parser.y filter-lexer.l \
filter-visitor-set-parent.c \
filter-visitor-xml.c \
filter-visitor-generate-ir.c \
memstream.h
libfilter_la_CFLAGS = -include filter-symbols.h
+AM_YFLAGS = -t -d -v
+
+# start with empty files to clean
+CLEANFILES =
+
+if HAVE_BISON
+# we have bison: we can clean the generated parser files
+CLEANFILES += filter-parser.c filter-parser.h filter-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."
+
+filter-parser.c filter-parser.h: filter-parser.y
+ @echo $(ERR_MSG)
+ @false
+
+all-local: filter-parser.c filter-parser.h
+endif # HAVE_BISON
+
+if HAVE_FLEX
+# we have flex: we can clean the generated lexer files
+CLEANFILES += filter-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: filter-lexer.l
+ @echo $(ERR_MSG)
+ @false
+
+all-local: filter-lexer.c
+endif # HAVE_FLEX
+
filter_grammar_test_SOURCES = filter-grammar-test.c
filter_grammar_test_LDADD = libfilter.la
-
-CLEANFILES = filter-lexer.c filter-parser.c filter-parser.h filter-parser.output