On Sat, 2009-05-16 at 23:06 +0200, Hans Nieser wrote:
> Hi list,
> 
> I recently started using lex/yacc and I'm having some trouble figuring
> out how to make it possible to link two parsers into the same executable
> using automake.
> 
<...>

I did some more googling and it turns out that although there is an
option that I can specify in the lex file itself to use a different
prefix for symbols [1], it will actually affect the output filename as
well which seems to break the ylwrap script (it fails silently, but I am
guessing it's because of the different filename).

Another complication of compiling the lex C source directly is that I'd
also need to make yacc produce the header file and include it in the lex
source, which I guess means I have to add some explicit dependencies in
my Makefile.am (actually I'm not sure how that works at all since ylwrap
is called in a subdirectory?.. hmm)

I've now just resorted to the following, I'm not sure if it's the best
way to go but it seems to work and is hopefully still portable:

bin_PROGRAMS = foo

foo_sources = foo.c parser1_yacc.y


parser1_yacc.c: parser1_lex.c

parser1_lex.c: parser1_lex.l
        $(LEX) -o parser1_lex.c parser1_lex.l


I'm not really sure if I can mix and match explicit make rules like
this, hopefully someone can tell me if there's anything terribly wrong
with doing it this way :)


[1] http://sources.redhat.com/ml/automake/1999-11/msg00132.html




Reply via email to