build: fix build with byacc
authorRan Benita <ran@unusedvar.com>
Tue, 18 Feb 2020 12:12:20 +0000 (14:12 +0200)
committerRan Benita <ran@unusedvar.com>
Tue, 18 Feb 2020 12:12:20 +0000 (14:12 +0200)
We apparently broke byacc support in the switch to meson.

byacc only supports short option names. And to make things fun, bison
only supports long option for `--defines`.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/133
Signed-off-by: Ran Benita <ran@unusedvar.com>
meson.build

index ac70663..6f48c65 100644 (file)
@@ -135,13 +135,26 @@ have_version_script = cc.links(
 
 # libxkbcommon.
 # Note: we use some yacc extensions, which work with either GNU bison
-# (preferred) or byacc. Other yacc's may or may not work.
-yacc = find_program('bison', 'win_bison', 'byacc')
-yacc_gen = generator(
-    yacc,
-    output: ['@BASENAME@.c', '@BASENAME@.h'],
-    arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@', '-p _xkbcommon_'],
-)
+# (preferred) or byacc (with backtracking enabled).
+bison = find_program('bison', 'win_bison', required: false)
+if bison.found()
+    yacc_gen = generator(
+        bison,
+        output: ['@BASENAME@.c', '@BASENAME@.h'],
+        arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@', '-p _xkbcommon_'],
+    )
+else
+    byacc = find_program('byacc', required: false)
+    if byacc.found()
+        yacc_gen = generator(
+            byacc,
+            output: ['@BASENAME@.c', '@BASENAME@.h'],
+            arguments: ['@INPUT@', '-H', '@OUTPUT1@', '-o', '@OUTPUT0@', '-p _xkbcommon_'],
+        )
+    else
+        error('Could not find a compatible YACC program (bison or byacc)')
+    endif
+endif
 libxkbcommon_sources = [
     'src/compose/parser.c',
     'src/compose/parser.h',