【问题标题】:How to fully include another project(s) with autotools build system?如何使用 autotools 构建系统完全包含另一个项目?
【发布时间】:2020-03-16 04:03:14
【问题描述】:

我的项目依赖于 C 语言中的第三方库 (-ies),它本身有一个基于自动工具的独立构建系统。

我想在源代码树中拥有一个第三方库的副本,并为我的项目编写基于自动工具的通用构建系统,这样我就可以拥有一个配置和所有常用的自动工具捆绑来完成一个完整的一次性构建。

这个系统会以某种方式首先构建第三方库(使用第三方的 configure.ac 等,就好像它是独立构建的一样),然后编译并将我的所有源与第三方库链接(我愿意只需将我的程序静态链接到第三方库,而不是将第三方库安装在系统位置的任何位置,例如 /usr/local 等)。

所以我假设一个项目的目录结构如下:

project/
    src/
        folder_with_my_source_code/
        third-party/
            third-party-lib-1/
                src/
                Makefile.am  // native lib-1 files, prefer to keep unmodified
                configure.ac // native lib-1 files, prefer to keep unmodified
            third-party-lib-2/
                src/
                Makefile.am  // native lib-2 files, prefer to keep unmodified
                configure.ac // native lib-2 files, prefer to keep unmodified
            Makefile.am   // do I need this at all ?

        Makefile.am //this should describe how to build my files
    Makefile.am  // project's root makefile
    configure.ac // this, probably, should somehow include instructions on how to build lib-1 and lib-2 with their supplied configure.ac's ?

如何创建这种类似链的依赖构建?

【问题讨论】:

  • 嘿@psb,你可以在这里阅读how to ask。一般来说,关于 SO 的问题应该针对特定的问题。例如在这里你可以问How can I use autoconf to configure and build sub-projects (that also use autoconf) recursively ? (如果这确实是你的问题,我不熟悉autoconf我可能误解了你的意图)而不是征求人们的意见。

标签: autotools build-system


【解决方案1】:

你可以使用AC_CONFIG_SUBDIRS:

在大多数情况下,调用AC_OUTPUT 足以在子目录中生成makefile。但是,控制多个独立包的configure 脚本可以使用AC_CONFIG_SUBDIRS 为子目录中的其他包运行configure 脚本。

— 宏:AC_CONFIG_SUBDIRS (dir ...)
在给定的空白或换行符分隔列表中的每个子目录 dir 中使 AC_OUTPUT 运行 configure

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-04
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 2013-10-04
    • 2015-02-01
    • 2021-11-04
    • 1970-01-01
    相关资源
    最近更新 更多