[Mesa-dev] [PATCH] configure.ac: add and use AC_PROG_BISON/FLEX macros

Gaetan Nadon memsize at videotron.ca
Wed Jan 11 16:49:55 PST 2012


On 12-01-11 01:16 AM, Matt Turner wrote:
> Defining these macros lets us use AC_PROG_YACC/LEX which makes automake
> easier while still specifically requiring bison and flex.
>
> Based on bison.m4 and flex.m4 found in LLVM's tree.
>
> Signed-off-by: Matt Turner <mattst88 at gmail.com>
> ---
>  configure.ac |    9 ++++-----
>  m4/bison.m4  |   16 ++++++++++++++++
>  m4/flex.m4   |   16 ++++++++++++++++
>  3 files changed, 36 insertions(+), 5 deletions(-)
>  create mode 100644 m4/bison.m4
>  create mode 100644 m4/flex.m4
>
> diff --git a/configure.ac b/configure.ac
> index 511d147..c0abeb9 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -45,11 +45,10 @@ if test "x$MKDEP" = "x"; then
>      AC_MSG_ERROR([makedepend is required to build Mesa])
>  fi
>  
> -AC_PATH_PROG([FLEX], [flex])
> -test "x$FLEX" = "x" && AC_MSG_ERROR([flex is needed to build Mesa])
> -
> -AC_PATH_PROG([BISON], [bison])
> -test "x$BISON" = "x" && AC_MSG_ERROR([bison is needed to build Mesa])
> +m4_include([m4/bison.m4])
> +AC_PROG_BISON
> +m4_include([m4/flex.m4])
> +AC_PROG_FLEX
>  
>  dnl Our fallback install-sh is a symlink to minstall. Use the existing
>  dnl configuration in that case.
> diff --git a/m4/bison.m4 b/m4/bison.m4
> new file mode 100644
> index 0000000..641d438
> --- /dev/null
> +++ b/m4/bison.m4
> @@ -0,0 +1,16 @@
> +#
> +# Check for Bison.
> +#
> +# This macro verifies that Bison is installed.  If successful, then
> +# 1) YACC is set to bison -y (to emulate YACC calls)
> +# 2) BISON is set to bison
> +#
> +AC_DEFUN([AC_PROG_BISON],
> +[AC_PROG_YACC()
> +if test "$YACC" != "bison -y"; then
This may rule out some tools. In my previous distro I had byacc which I
think was suitable. An alternative is to take what AC_PROG_YACC gives
you and do a "feature test" to verify that the tool can handle the
special situation for the glx compiler. This concept is used for the
grep command, for example.

> +  AC_SUBST(BISON,[])
> +  AC_MSG_WARN([bison not found])
This will prevent mesa to build from a tarball (./configure) when bison
is not installed. The lex & yacc generated code should be included in
the tarball. Even more important if some platforms don't have the bison
tool you expect.

Check xorg/lib/libxkbcommon. It takes care of all the situations. You
would only need to add the feature test.
> +else
> +  AC_SUBST(BISON,[bison])
> +fi
> +])
> diff --git a/m4/flex.m4 b/m4/flex.m4
> new file mode 100644
> index 0000000..6a2a004
> --- /dev/null
> +++ b/m4/flex.m4
> @@ -0,0 +1,16 @@
> +#
> +# Check for FLEX.
> +#
> +# This macro verifies that flex is installed.  If successful, then
> +# 1) LEX is set to flex (to emulate lex calls)
> +# 2) FLEX is set to flex
> +#
> +AC_DEFUN([AC_PROG_FLEX],
> +[AC_PROG_LEX()
> +if test "$LEX" != "flex"; then
> +  AC_SUBST(FLEX,[])
> +  AC_MSG_ERROR([flex not found])
> +else
> +  AC_SUBST(FLEX,[flex])
> +fi
> +])



More information about the mesa-dev mailing list