Good afternoon,

I've got the lex/yacc files for a parser written, and I know that they work, as I tested them separately, and I need to integrate these into a Qt4 project. that part's fine if I use qmake to generate the makefile, and then hack the makefile to make the damned thing compile properly.

The problem I'm having is that qmake changes the filenames of the outputs, as well as the default prefixes for most of the lex/yacc stuff (such as the yylex() function, and yylval for example...), and I'd like it to not do that. I'd like to be able to go through qmake so that I don't have to hack at the makefile in order to make it work again.

anyways, here's the project file I'm using for this parser, using a small quick and dirty test class I wrote.

Qt Code:
  1. TEMPLATE = app
  2. TARGET +=
  3. DEPENDPATH += .
  4. INCLUDEPATH += .
  5.  
  6. # Input
  7. HEADERS += parse.h parser.y.h parseTest.h
  8. LEXSOURCES += parser.l
  9. YACCSOURCES += parser.y
  10. SOURCES += main.cpp parseTest.cpp
  11.  
  12. # Flex/bison specifics
  13.  
  14. QMAKE_LEX = flex
  15. QMAKE_YACC = bison
  16.  
  17. QMAKE_YACCFLAGS = -d -o y.tab.c
  18. QMAKE_YACC_HEADER =
  19. QMAKE_YACC_SOURCE =
To copy to clipboard, switch view to plain text mode 

This will generate a makefile that assumes you already know what kind of mangling qmake will do to your filenames (which I didn't, and I would prefer to not have to rewrite the code to make it work)

Basically, these are the offending lines in the makefile that I don't want to be like that.

Qt Code:
  1. parser_yacc.cpp: parser.y
  2. $(YACC) $(YACCFLAGS) -p parser -b parser parser.y
  3. -$(DEL_FILE) parser_yacc.cpp parser_yacc.h
  4. -$(MOVE) parser.tab.h parser_yacc.h
  5. -$(MOVE) parser.tab.c parser_yacc.cpp
  6.  
  7. parser_yacc.h: parser_yacc.cpp
  8.  
  9. parser_lex.cpp: parser.l
  10. $(LEX) $(LEXFLAGS) -Pparser parser.l
  11. -$(DEL_FILE) parser_lex.cpp
  12. -$(MOVE) lex.parser.c parser_lex.cpp
To copy to clipboard, switch view to plain text mode 

I do not want the -Pparser flag in the lex lines, nor the -p and -b tags in the yacc lines. I also want the makefile to contain the standard default lex.yy.c output for the lex output, and y.tab.h and y.tab.cpp as the yacc output, since I use C++ code for the parser, although the lexer contains only C code, and can probably run through g++ anyways.

So to recap, I need a way to get qmake to not touch the filenames of the lex and yacc (or in this case, flex and bison) output, and to recognize that it hasn't touched the filenames in order to create the proper targets in the makefile for lex.yy.c (or lex.yy.cpp), y.tab.h, and y.tab.cpp

I've spent the past day on this problem, scouring google, and trying as many different things as I could find. Hacking the makefile each time is an unacceptable solution, I need something that you could add to the project file itself, or at least something scriptable.

Thanks.