我在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 \- includeRegrouping 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/libIn 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.
更多推荐
发布评论