This is G o o g l e's cache of http://www.lrde.epita.fr/people/akim/compil/gnuprog2/Using-Flex-with-the-GNU-Build-System.html.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:pZcDdh6YNAEC:www.lrde.epita.fr/people/akim/compil/gnuprog2/Using-Flex-with-the-GNU-Build-System.html+&hl=en&ie=UTF-8


Google is not affiliated with the authors of this page nor responsible for its content.

Using Flex with the GNU Build System

Noeud:Using Flex with the GNU Build System, Noeud «Next»:, Noeud «Previous»:Advanced Use of Flex, Noeud «Up»:Scanning with Flex



Using Flex with the GNU Build System

Autoconf and Automake provide some generic Lex support, but no Flex dedicated support. In particular Automake expects lex.yy.c as output file, which makes it go through various hoops to prevent several concurrent invocations of lex to overwrite each others' output.

As Gperf, Lex and Flex are maintainer requirements: someone changing the package needs them, but their result is shipped so that a regular user does not need them. I have already emphasized that you should not bother with vendor Lexes, Flex alone will fulfill all your needs, and keep you away from troubles. If you use Automake's AM_PROG_LEX, then if flex or else lex is found, it is used as is, otherwise missing is used to invoke flex. Unfortunately, if lex is available, but not good enough to handle your files, then the output scanner will be destroyed. Therefore, to avoid this, we really want to wrap the lex invocations with missing. I suggest:

# Sometimes Flex is installed as Lex, e.g., NetBSD.
AC_CHECK_PROG([FLEX], [flex lex], [flex])
# Force the use of `missing' to wrap Flex invocations.
AM_MISSING_PROG([LEX], [$FLEX])
# Perform all the tests Automake and Autoconf need.
AM_PROG_LEX

Then, in your Makefile.am, forget your Flex sources need a special handling, Automake takes care of it all. Merely list them as ordinary source files:

LDFLAGS = -no-undefined

pkglibexec_LTLIBRARIES	= yleval.la
yleval_la_SOURCES = ylparse.y ylscan.l yleval.c yleval.h ylparse.h
yleval_la_LDFLAGS = -module

and that's all. In particular, do not bother with LEXLIB at all: configure defines it to -ll or -lfl, but we already emphasized that Flex' output is self-contained and portable, see Using Flex.