Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automake Yacc Output Filename Quandary

Problem:

I have a project which I'm porting from Solaris/Lex/Yacc to Linux/Flex/Bison + Autotools. I'm running into the following issue, and I wonder if anyone out there knows how to get around it. Given a target like so (only necessary details included):

bin_PROGRAMS=my_prog

my_prog_YFLAGS=-d
my_prog_SOURCES=\
   main.cpp \
   parser.ypp \
   scanner.lpp

Automake is generating the following source files from the lpp and ypp:

  • scanner.lpp -> scanner.cpp (as per Automake manual)
  • parser.ypp -> my_prog-parser.cpp and my_prog-parser.h (why?)

Attempted Solutions:

Using bison's -b and -o options to alter output file names. The problem with this is that automake appears to assume default output names (parser.tab.c) and move the files with a script. If I alter the output file names with bison, the build fails when automake attempts to rename the files that aren't there.

Is there some option or something I am missing?

like image 780
acanaday Avatar asked Nov 26 '25 21:11

acanaday


1 Answers

Solution:

So it took me actually reading through the automake source itself (for the curious, look at the handle_single_transform function). If there are per-target options specified for a given source-type, automake automatically prepends the project name to any generated files.

Therefore, changing:

my_prog_YFLAGS=-d

to

AM_YFLAGS=-d

Causes automake to properly generate rules causing parser.ypp to generate:

  • parser.cpp
  • parser.h
like image 102
acanaday Avatar answered Nov 28 '25 10:11

acanaday