Commit | Line | Data |
---|---|---|
1a3ad29b | 1 | # =========================================================================== |
8a121625 | 2 | # https://www.gnu.org/software/autoconf-archive/ax_prog_flex_version.html |
1a3ad29b JR |
3 | # =========================================================================== |
4 | # | |
33bdeb6a JR |
5 | # SYNOPSIS |
6 | # | |
7 | # AX_PROG_FLEX_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE]) | |
8 | # | |
9 | # DESCRIPTION | |
10 | # | |
1a3ad29b JR |
11 | # Makes sure that flex version is greater or equal to the version |
12 | # indicated. If true the shell commands in ACTION-IF-TRUE are executed. If | |
13 | # not the shell commands in commands in ACTION-IF-TRUE are executed. If | |
8a121625 MJ |
14 | # not the shell commands in ACTION-IF-FALSE are run. Note if $LEX is not |
15 | # set (for example by running AC_PROG_LEX or AC_PATH_PROG) the macro | |
1a3ad29b | 16 | # will fail. |
33bdeb6a JR |
17 | # |
18 | # Example: | |
19 | # | |
8a121625 | 20 | # AC_PROG_LEX |
33bdeb6a JR |
21 | # AX_PROG_FLEX_VERSION([2.5.39],[ ... ],[ ... ]) |
22 | # | |
1a3ad29b JR |
23 | # This will check to make sure that the flex you have is at least version |
24 | # 2.5.39 or greater. | |
33bdeb6a | 25 | # |
8a121625 MJ |
26 | # NOTE: This macro uses the $LEX variable to perform the check, if it's |
27 | # empty it will failover to the $FLEX variable for backwards compatibility. | |
33bdeb6a JR |
28 | # |
29 | # LICENSE | |
30 | # | |
31 | # Copyright (c) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> | |
8a121625 | 32 | # 2017 Michael Jeanson <mjeanson@efficios.com> |
33bdeb6a JR |
33 | # |
34 | # Copying and distribution of this file, with or without modification, are | |
35 | # permitted in any medium without royalty provided the copyright notice | |
36 | # and this notice are preserved. This file is offered as-is, without any | |
37 | # warranty. | |
38 | ||
8a121625 | 39 | #serial 3 |
33bdeb6a JR |
40 | |
41 | AC_DEFUN([AX_PROG_FLEX_VERSION],[ | |
42 | AC_REQUIRE([AC_PROG_SED]) | |
43 | AC_REQUIRE([AC_PROG_GREP]) | |
44 | ||
8a121625 MJ |
45 | AS_IF([test -z "$LEX"],[ |
46 | AS_IF([test -n "$FLEX"],[ | |
47 | LEX=$FLEX | |
48 | ]) | |
49 | ]) | |
50 | ||
51 | AS_IF([test -n "$LEX"],[ | |
33bdeb6a JR |
52 | ax_flex_version="$1" |
53 | ||
54 | AC_MSG_CHECKING([for flex version]) | |
55 | changequote(<<,>>) | |
8a121625 | 56 | flex_version=`$LEX --version 2>&1 \ |
33bdeb6a JR |
57 | | $SED -n -e '/flex /b inspect |
58 | b | |
59 | : inspect | |
60 | s/.* (\{0,1\}\([0-9]*\.[0-9]*\.[0-9]*\))\{0,1\}.*/\1/;p'` | |
61 | changequote([,]) | |
62 | AC_MSG_RESULT($flex_version) | |
63 | ||
64 | AC_SUBST([FLEX_VERSION],[$flex_version]) | |
65 | ||
66 | AX_COMPARE_VERSION([$flex_version],[ge],[$ax_flex_version],[ | |
67 | : | |
68 | $2 | |
69 | ],[ | |
70 | : | |
71 | $3 | |
72 | ]) | |
73 | ],[ | |
74 | AC_MSG_WARN([could not find flex]) | |
75 | $3 | |
76 | ]) | |
77 | ]) |