如何在子包设置中传播automake变量?(How can I propagate automake variables in a sub

编程入门 行业动态 更新时间:2024-10-28 16:26:54
如何在子包设置中传播automake变量?(How can I propagate automake variables in a sub-package setup?)

我在autotools存储库中有一个子包设置,其中几个相关的项目使用master configure.ac和Makefile.am粘在一起。

除了通过AC_CONFIG_SUBDIRS()宏轻松完成的编译顺序之外,还需要导出这些过度耦合的子项目之间所需的标头和库位置。

--- configure.ac |- Makefile.am |- subproj1 --- configure.ac | |- Makefile.am | |- src | \- include [...] | \- subprojN --- configure.ac // requires -I${top_srcdir}/subprojX/include and |- Makefile.am // -L${top_srcdir}/subprojX/src |- src \- include

不幸的是,重新组合这些包不是一种选择。 我尝试使用AC_SUBST()和/或make的导出命令导出变量,但无济于事。

我可以在每个子项目Makefile中获得这些标志的唯一方法是将CPPFLAGS和LDFLAGS传递到根配置调用(通过命令行)。 但是,我希望有一种方法可以将这些值保存在autotools中,而不必为它们创建单独的脚本。

PS:类似于automake和项目依赖

I have a sub-package setup in my autotools repository, in which several related projects are glued together using a master configure.ac and Makefile.am.

Aside from the compilation ordering, easily done via AC_CONFIG_SUBDIRS() macro, there is the need to export headers and library locations required between these excessively coupled sub-projects.

--- configure.ac |- Makefile.am |- subproj1 --- configure.ac | |- Makefile.am | |- src | \- include [...] | \- subprojN --- configure.ac // requires -I${top_srcdir}/subprojX/include and |- Makefile.am // -L${top_srcdir}/subprojX/src |- src \- include

Regrouping these packages as one is not an option, unfortunately. I tried exporting variables using AC_SUBST() and/or make's export command, for no avail.

The only way I could get these flags available into every sub-project Makefile was passing CPPFLAGS and LDFLAGS into the root configure invocation (via command-line). However, I'd hope if there is a way to keep these values inside autotools stuff, instead of having to create a separate script for them.

PS: similar to automake and project dependencies

最满意答案

autotools实际上并不是一个包管理系统,所以这是一个尴尬的用法,但是可以在子项目中引用构建树之外的相对路径。 换句话说,在subprojN / Makefile.am中,您可以添加:

AM_CPPFLAGS = -I$(srcdir)/../subprojX/include AM_LDFLAGS = -L$(srcdir)/../subprojX/lib

在这种情况下,如果subprojN / configure试图找到libsubprojX,它将失败,除非您将../subprojX/{include,lib}添加到CPPFLAGS和LDFLAGS进行配置,这可以在configure.ac中完成:

CPPFLAGS="$CPPFLAGS -I${srcdir}/../subprojX/include LDFLAGS="$LDFLAGS -L${srcdir}/../subprojX/lib"

如果子项目的配置脚本没有检查耦合子项目中的库,那么在Makefile.am中指定LDADD以获取必要的库链接可能会更清晰。

The autotools are not really designed to be a package management system, so this is an awkward usage, but it is possible to reference relative paths outside of the build tree in the sub-projects. In other words, in subprojN/Makefile.am, you can add:

AM_CPPFLAGS = -I$(srcdir)/../subprojX/include AM_LDFLAGS = -L$(srcdir)/../subprojX/lib

In this scenario, if subprojN/configure is trying to find libsubprojX, it will fail unless you instead add ../subprojX/{include,lib} to CPPFLAGS and LDFLAGS for configure, which can be done in configure.ac:

CPPFLAGS="$CPPFLAGS -I${srcdir}/../subprojX/include LDFLAGS="$LDFLAGS -L${srcdir}/../subprojX/lib"

If the configure scripts of the subprojects are not checking for the libraries in the coupled subprojects, it would probably be cleaner to specify LDADD in Makefile.am to get the necessary libraries linked.

更多推荐

本文发布于:2023-07-16 00:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1120988.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   如何在   variables   automake   propagate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!