如何使用 automake 安装 D 库的 .d 文件?

How to install .d files of a D library using automake?

使用 Makefile.am 安装(系统范围)D 库(至少在 GNU 系统上)的正确方法是什么?

这是我安装静态库和共享库的代码:

install-data-local:
        install librdf_dlang.a librdf_dlang.so $(libdir)

剩下的问题是如何安装 .d 文件供开发人员使用我的库?

特别是 .d 个文件的安装目录应该是什么?

根据Filesystem Hierarchy Standard (and e.g. this SO question)

/usr/local/include

在 "linux/unix-like system" 上看起来是个不错的候选人。具体见note 9:

Historically and strictly according to the standard, /usr/local is for data that must be stored on the local host (as opposed to /usr, which may be mounted across a network). Most of the time /usr/local is used for installing software/data that are not part of the standard operating system distribution (in such case, /usr would only contain software/data that are part of the standard operating system distribution). It is possible that the FHS standard may in the future be changed to reflect this de facto convention.

我不知道 Windows。

如果你正在系统范围内安装 D 库和源代码(我假设是接口文件),那么最常见的地方是 /usr/include/<project name>/usr/local/include/<project name> 只要不冲突一些现有的 C/C++ 项目在那里存储头文件。一些 D 程序员也更喜欢 /usr/include/d//usr/local/include/d/...

例如,我为此目的使用了 /usr/di(D 导入),我的库项目的所有接口文件都在那里。我将解释为什么我不喜欢在那里有单独的项目目录。

无论选择哪个目录,都需要更新编译器搜索路径。

这是我的一部分 dmd.conf:

[Environment64]
DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -I/usr/di -L-L/usr/lib64 -L--export-dynamic -fPIC

,而 ldc2.conf 看起来像:

    // default switches appended after all explicit command-line switches
    post-switches = [
        "-I/usr/include/d/ldc",
        "-I/usr/include/d",
        "-I/usr/di",
        "-L-L/usr/lib64",
    ];

如果您希望每个项目都有一个单独的目录,那么每个项目最终都会有 -I<path>。 - 我真的不喜欢这种方法。但是,它在开发人员中非常流行,因此如何组织 D 导入文件完全取决于您。我知道有多少开发人员不喜欢使用 domain.product.packages 的 Java 方法,但这很好地适合所有 D 接口文件所在的单一位置,最重要的是没有冲突,因为 domain/product部分...