从脚本中查找由 autotools 定义的 $pkgdatadir
我的应用程序使用 autotools
在 $pkgdatadir
中安装运行时所需的数据文件。应用程序的一部分是用 C 编写的,数据目录的路径是通过 Makefile.am 中的以下语句设置的:
AM_CPPFLAGS = -DAM_DATADIR='"$(pkgdatadir)"'
但我还需要从各种 Perl 和 shell 访问此数据目录脚本。除了在安装过程中修改脚本之外,是否有解决此问题的通用方法?
My application uses autotools
to install data files that are needed at runtime in $pkgdatadir
. Part of the application is written in C, and the path to the data directory is set by the following statement in Makefile.am
:
AM_CPPFLAGS = -DAM_DATADIR='"$(pkgdatadir)"'
But I also need to have access to this data directory from various Perl and shell scripts. Is there a common approach to this problem other modifying the scripts during installation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
autoconf 文档中提到了这个问题,建议的解决方案是在 make 时(安装之前)构建脚本。我不清楚这个解决方案是否是您所说的“在安装过程中修改脚本”的意思,但这确实是唯一可行的解决方案,因为 pkgdatadir 仅在 Makefile 中定义,因此必须使用 make (除非您想采用尝试在 Makefile 之外复制 pkgdatadir 的定义是极其脆弱的方法。)
这是我现在能找到的最好的链接:http://www.delorie.com/gnu/docs/autoconf/autoconf_24.html。相关部分描述了以下示例 make 片段来构建 autoconf 和 autoheader:
This problem is mentioned in the autoconf documentation, and the recommended solution is to build the scripts during make time (before install). It's not clear to me if this solution is what you mean by "modifying the scripts during installation", but this is really the only viable solution since pkgdatadir is only defined in the Makefile, so make must be used (unless you want to adopt the extremely fragile approach of attempting to duplicate the definition of pkgdatadir outside of the Makefile.)
This is the best link I could find just now: http://www.delorie.com/gnu/docs/autoconf/autoconf_24.html. The relevant portion describes the following sample make snippet to build autoconf and autoheader: