Automake Yacc 输出文件名困境
问题:
我有一个项目,正在从 Solaris/Lex/Yacc 移植到 Linux/Flex/Bison + Autotools。 我遇到了以下问题,我想知道是否有人知道如何解决它。给定这样的目标(仅包括必要的细节):
bin_PROGRAMS=my_prog
my_prog_YFLAGS=-d
my_prog_SOURCES=\
main.cpp \
parser.ypp \
scanner.lpp
Automake 正在从 lpp 和 ypp 生成以下源文件:
- scanner.lpp -> Scanner.cpp (按照 Automake 手册)
- parser.ypp -> my_prog-parser.cpp 和 my_prog-parser.h (为什么?)
尝试的解决方案:
使用 bison 的 -b 和 -o 选项来更改输出文件名。问题在于,automake 似乎采用默认输出名称 (parser.tab.c) 并使用脚本移动文件。如果我用 bison 更改输出文件名,则当 automake 尝试重命名不存在的文件时,构建会失败。
有什么选择或我缺少的东西吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案:
所以我实际上需要阅读 automake 源代码本身(如果好奇,请查看 handle_single_transform 函数)。如果为给定源类型指定了每个目标选项,automake 会自动将项目名称添加到任何生成的文件中。
因此,更改:
使
automake 正确生成规则,从而导致 parser.ypp 生成:
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:
to
Causes automake to properly generate rules causing parser.ypp to generate: