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

标签 autotools autoconf automake

我的应用程序使用 autotools$pkgdatadir 中安装运行时所需的数据文件。应用程序的部分内容是用 C 编写的,数据目录的路径由 Makefile.am 中的以下语句设置:

AM_CPPFLAGS = -DAM_DATADIR='"$(pkgdatadir)"'

但我还需要从各种 Perl 和 shell 脚本访问此数据目录。除了在安装过程中修改脚本之外,是否有解决此问题的通用方法?

最佳答案

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

关于autotools - 从脚本中查找由 autotools 定义的 $pkgdatadir,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6428989/

相关文章:

c - 涉及 float 的 autoconf 检查的非常量存储大小?

build - X-I。 : command not found, 构建某种软件失败,怎么回事?

自动工具包括路径

带有自动工具的 CDT 中的 C++11

linux - 为什么 autoconf 会错误地找到一个以后不可用的功能?

c - Linux 上的 Autoreconf 和 <math.h>

configuration - 如何禁用Automake文档?

linux - 构建 Xenomai 时如何修复目标 "' 的错误 "doc/automake-1.14.1' 配方失败“

c++ - 非递归(non-recursive) Automake

c++ - 使用 GNU AutoTools 设置和使用数据目录路径