[msitools: 1/18] configure: explicitly check for bison



commit dfeab527567320728a4e275e6e35d4358bcf6720
Author: Daniel P. Berrangé <berrange redhat com>
Date:   Wed Feb 13 10:51:29 2019 +0000

    configure: explicitly check for bison
    
    The AC_PROG_YACC macro allows for 'bison -y', 'byacc' and
    'yacc' but building with byacc fails with a syntax error:
    
      YACC     sql-parser.c
    byacc: e - line 76 of "/home/berrange/src/virt/msitools/libmsi/sql-parser.y", syntax error
    %define api.prefix {sql_}
    ^
    
    Replace AC_PROG_YACC with an explicit check for bison -y
    which is able to successfully generate the parser. An
    added benefit of this custom check is that we can abort
    configure with an error if it is not found instead of
    using a hardcoded default of 'yacc' without checking if
    it exists or not.
    
    Signed-off-by: Daniel P. Berrangé <berrange redhat com>

 .gitlab-ci.yml |  2 +-
 configure.ac   | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2fee143..e0798c2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,7 +5,7 @@ variables:
                 glib2-devel gobject-introspection-devel
                 libuuid-devel vala libgsf-devel
                 libgcab1-devel git libtool make
-                redhat-rpm-config byacc
+                redhat-rpm-config
                 bison bison-devel bison-runtime
 
 build_stable:
diff --git a/configure.ac b/configure.ac
index 6ff65d5..fb3d716 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,21 @@ AM_CONDITIONAL([WIN32], [test $win32 = yes])
 
 AC_USE_SYSTEM_EXTENSIONS
 AC_PROG_CC
-AC_PROG_YACC
+
+AC_CHECK_PROGS(YACC, 'bison -y')
+AC_ARG_VAR(YACC,
+           [The `Yet Another Compiler Compiler' implementation to use.
+           Defaults to`bison -y'])
+
+AC_ARG_VAR(YFLAGS,
+           [The list of arguments that will be passed by default to $YACC.
+           This script will default YFLAGS to the empty string to avoid
+           a default value of `-d' given by some make applications.])
+
+if test -z "$YACC"
+then
+    AC_MSG_ERROR([bison is required to build msitools])
+fi
 
 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.12])
 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 gio-2.0 >= 2.14])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]