开发者

Automake Yacc Output Filename Quandary

开发者 https://www.devze.com 2023-02-17 16:59 出处:网络
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.

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.cp开发者_如何学运维p 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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号