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

Matt Turner mattst88 at gmail.com
Wed Jan 11 09:14:27 PST 2012


On Wed, Jan 11, 2012 at 1:49 AM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> On 01/10/2012 10:16 PM, 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)
>
>
> I don't think we want to emulate POSIX yacc.  We're not using -y today, and
> I expect it'd only break things...
>
>
>> +# 2) BISON is set to bison
>> +#
>> +AC_DEFUN([AC_PROG_BISON],
>> +[AC_PROG_YACC()
>> +if test "$YACC" != "bison -y"; then
>> +  AC_SUBST(BISON,[])
>> +  AC_MSG_WARN([bison not found])
>> +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
>> +])
>
>
> I like the idea of AC_PROG_FLEX and AC_PROG_BISON macros, but I don't care
> for this implementation.  I would expect them to perform some kind of
> feature check, or ask the program whether it's flex/bison.  This just
> matches on the name, so if I had flex installed only as "lex", or bison
> installed as "bison25" or such, this would break.
>
> Maybe this is okay, but at least in my mind, only allowing one name seems to
> kind of defeat the point of a configure check.  Not entirely, but still.

Agree, this isn't very good.

Using AC_PROG_PATH for bison and flex doesn't make automake happy, but
using AC_PROG_YACC/LEX works fine. Oh, and when experimenting with
this I discovered that bison -y worked while plain bison didn't. Who
knows.

I suggest we just do what my previous automake patch does with
AC_PROG_YACC/LEX and just let builders ensure that they're using flex
and bison. In Gentoo, we've found that this is very common.

Matt


More information about the mesa-dev mailing list