Summary: _AC_PROG_LEX_YYTEXT_DECL fails to compute LEXLIB
correctly using the original AT&T lex if Xcode's flex is installed
Submitted by: None
Submitted on: Tue 23 May 2017 01:04:53 AM UTC
Priority: 5 - Normal
Severity: 3 - Normal
Assigned to: None
Originator Email: [hidden email] Open/Closed: Open
Discussion Lock: Any
Operating System: Mac OS
Mac OS installs flex (obsolete version 2.5.35) as a part of Xcode's command
line tools, with it's library installed as /usr/lib/libl.a.
I have a copy of a more recent flex (version 2.6.1) installed in
/usr/local/bin, with its library installed as /usr/local/lib/libfl.a.
I also have a copy of the 4.3BSD version of lex installed in /usr/local/bin,
with it's library installed as /usr/local/lib/libl.a.
I have a package that I want to be able to build with either lex or flex.
If I force AC_PROG_LEX to use lex rather than flex when running configure, the
AC_LINK_IFELSE test located in _AC_PROG_LEX_YYTEXT_DECL fails for all choices
('', -lfl, -ll) but the AC_PROG_LEX macro completes with output message "none
needed" (and with LEXLIB empty).
It took me a bit of head scratching until I understood what was happening: The
loop running AC_LINK_IFELSE is not distinguishing between termination with
success ("break" out of the loop) and termination with failure (normal
completion of the loop). The AC_LINK_IFELSE fails when I force the use of lex
because it tries to use the (incorrectly named) 'flex' link library
/usr/lib/libl.a, since the default library search path is /usr/lib then
I can, of course, work around this defect in _AC_PROG_LEX_YYTEXT_DECL by
setting LDFLAGS="-L/usr/local/lib" on the configure command line.
However, it would have been nice if configure pointed out my error