| 1 | # SYNOPSIS |
| 2 | # |
| 3 | # AX_PROG_BISON_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE]) |
| 4 | # |
| 5 | # DESCRIPTION |
| 6 | # |
| 7 | # Makes sure that bison version is greater or equal to the version indicated. |
| 8 | # If true the shell commands in ACTION-IF-TRUE are executed. If not the shell |
| 9 | # commands in commands in ACTION-IF-TRUE are executed. If not the shell |
| 10 | # commands in ACTION-IF-FALSE are run. Note if $BISON is not set (for example |
| 11 | # by running AC_CHECK_PROG or AC_PATH_PROG) the macro will fail. |
| 12 | # |
| 13 | # Example: |
| 14 | # |
| 15 | # AC_PATH_PROG([BISON],[bison]) |
| 16 | # AX_PROG_BISON_VERSION([3.0.2],[ ... ],[ ... ]) |
| 17 | # |
| 18 | # This will check to make sure that the bison you have is at least |
| 19 | # version 3.0.2 or greater. |
| 20 | # |
| 21 | # NOTE: This macro uses the $BISON variable to perform the check. |
| 22 | # |
| 23 | # LICENSE |
| 24 | # |
| 25 | # Copyright (c) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
| 26 | # |
| 27 | # Copying and distribution of this file, with or without modification, are |
| 28 | # permitted in any medium without royalty provided the copyright notice |
| 29 | # and this notice are preserved. This file is offered as-is, without any |
| 30 | # warranty. |
| 31 | |
| 32 | #serial 12 |
| 33 | |
| 34 | AC_DEFUN([AX_PROG_BISON_VERSION],[ |
| 35 | AC_REQUIRE([AC_PROG_SED]) |
| 36 | AC_REQUIRE([AC_PROG_GREP]) |
| 37 | |
| 38 | AS_IF([test -n "$BISON"],[ |
| 39 | ax_bison_version="$1" |
| 40 | |
| 41 | AC_MSG_CHECKING([for bison version]) |
| 42 | changequote(<<,>>) |
| 43 | bison_version=`$BISON --version 2>&1 \ |
| 44 | | $SED -n -e '/bison (GNU Bison)/b inspect |
| 45 | b |
| 46 | : inspect |
| 47 | s/.* (\{0,1\}\([0-9]*\.[0-9]*\.[0-9]*\))\{0,1\}.*/\1/;p'` |
| 48 | changequote([,]) |
| 49 | AC_MSG_RESULT($bison_version) |
| 50 | |
| 51 | AC_SUBST([BISON_VERSION],[$bison_version]) |
| 52 | |
| 53 | AX_COMPARE_VERSION([$bison_version],[ge],[$ax_bison_version],[ |
| 54 | : |
| 55 | $2 |
| 56 | ],[ |
| 57 | : |
| 58 | $3 |
| 59 | ]) |
| 60 | ],[ |
| 61 | AC_MSG_WARN([could not find bison]) |
| 62 | $3 |
| 63 | ]) |
| 64 | ]) |