从脚本中查找由 autotools 定义的 $pkgdatadir

发布于 2024-11-16 06:57:17 字数 271 浏览 4 评论 0原文

我的应用程序使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁与争疯 2024-11-23 06:57:17

autoconf 文档中提到了这个问题,建议的解决方案是在 make 时(安装之前)构建脚本。我不清楚这个解决方案是否是您所说的“在安装过程中修改脚本”的意思,但这确实是唯一可行的解​​决方案,因为 pkgdatadir 仅在 Makefile 中定义,因此必须使用 make (除非您想采用尝试在 Makefile 之外复制 pkgdatadir 的定义是极其脆弱的方法。)

这是我现在能找到的最好的链接:http://www.delorie.com/gnu/docs/autoconf/autoconf_24.html。相关部分描述了以下示例 make 片段来构建 autoconf 和 autoheader:

edit = sed \
        -e 's,@datadir[@],$(pkgdatadir),g' \
        -e 's,@prefix[@],$(prefix),g'

autoconf: Makefile $(srcdir)/autoconf.in
        rm -f autoconf autoconf.tmp
        $(edit) $(srcdir)/autoconf.in >autoconf.tmp
        chmod +x autoconf.tmp
        mv autoconf.tmp autoconf

autoheader: Makefile $(srcdir)/autoheader.in
        rm -f autoheader autoheader.tmp
        $(edit) $(srcdir)/autoconf.in >autoheader.tmp
        chmod +x autoheader.tmp
        mv autoheader.tmp 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:

edit = sed \
        -e 's,@datadir[@],$(pkgdatadir),g' \
        -e 's,@prefix[@],$(prefix),g'

autoconf: Makefile $(srcdir)/autoconf.in
        rm -f autoconf autoconf.tmp
        $(edit) $(srcdir)/autoconf.in >autoconf.tmp
        chmod +x autoconf.tmp
        mv autoconf.tmp autoconf

autoheader: Makefile $(srcdir)/autoheader.in
        rm -f autoheader autoheader.tmp
        $(edit) $(srcdir)/autoconf.in >autoheader.tmp
        chmod +x autoheader.tmp
        mv autoheader.tmp autoheader
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文