automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

automake & flex's -P option


From: Richard Dawe
Subject: automake & flex's -P option
Date: Mon, 03 Mar 2003 23:11:03 +0000

Hello.

I recently converted one of my projects to autoconf 2.57 & automake 1.7.3. I'm
not bothered about portability to systems other than DJGPP or Linux. In
particular I've been using switches that are particular to flex and bison:
those to set the prefix of the lexer and parser's function and varibable
names. This works fine with bison. But not with flex, because it modifies the
output file name from lexyy.c to lexfoo.c. ($LEX_OUTPUT_ROOT == lexyy for
DJGPP.)

What would be good is if automake allowed me to use flex's -P option.

The current solution I've adopted for my project is to copy the
automake-generated rules and make the COMPILE line use flex's -o option to
write the output to ${LEX_OUTPUT_ROOT}.c, so that the other commands run as
normal. I.e.:

# Ick. Override the default rule, since -P<foo> changes the output file's
# name.
.l.c:
        $(LEXCOMPILE) -o$(LEX_OUTPUT_ROOT).c \
            `test -f $< || echo '$(srcdir)/'`$<
        sed '/^#/ s|$(LEX_OUTPUT_ROOT)\.c|$@|' $(LEX_OUTPUT_ROOT).c >$@
        rm -f $(LEX_OUTPUT_ROOT).c

But that's non-portable.

Looking at the Single Unix Specification v2 and drafts of the new POSIX
standard, it seems that lex has a -t option to redirect to stdout. So rather
than using -o, perhaps something like this could be used:

.l.c:
        ($(LEXCOMPILE) -t `test -f $< || echo '$(srcdir)/'`$< \
            > $(LEX_OUTPUT_ROOT).c) || (rm -f $(LEX_OUTPUT_ROOT).c; false)
        sed '/^#/ s|$(LEX_OUTPUT_ROOT)\.c|$@|' $(LEX_OUTPUT_ROOT).c >$@
        rm -f $(LEX_OUTPUT_ROOT).c

Does this seem like a good idea?

Does anyone know how portable "lex -t" is? Are there any bad side-effects of
using "lex -t"?

Thanks, bye, Rich =]

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]