[英]Autotools and a nested project project with ordinary Makefile
This question extends question How to handle subprojects with autotools? 这个问题扩展了问题: 如何使用自动工具处理子项目?
So I have some project with its own Makefile (not GNU autotools) in modules/libfoo 所以我在modules / libfoo中有一些带有自己的Makefile(不是GNU autotools)的项目
I added SUBDIRS = include/jsonbox Makefile.am and it compiles fine, but only if I invoke ./configure and make from top dir. 我添加了SUBDIRS = include / jsonbox Makefile.am,它可以正常编译,但前提是我调用./configure并从顶层目录进行make。
If I create a subdir, say build, and run ../configure from it I got an error during make: 如果创建一个子目录,请说build,然后从中运行../configure,在make时会出错:
Making all in modules/libfoo
/bin/sh: line 17: cd: modules/libfoo: No such file or directory
make: *** [all-recursive] Error 1
Is it possible to handle this? 有可能处理吗? I need several build dirs for different archs and CFLAGS. 我需要针对不同的拱门和CFLAGS的多个构建目录。
EDIT: As it sugected in docs I created a GNUmakefile.in in a nested project. 编辑:由于它在文档中建议,我在一个嵌套项目中创建了一个GNUmakefile.in。 But it still doesn't work with VPATH: 但是它仍然不能与VPATH一起使用:
Making all in modules/libfoo
make[1]: Entering directory `/home/galadog/test/build/moudles/libfoo'
GNUmakefile:2: Makefile: No such file or directory
make[1]: *** No rule to make target `Makefile'. Stop.
make[1]: Leaving directory `/home/galadog/test/build/moudles/libfoo'
make: *** [all-recursive] Error 1
Edit2 The actual Makefile can be seen here: https://github.com/anhero/JsonBox/blob/master/Makefile Edit2实际的Makefile可以在这里看到: https : //github.com/anhero/JsonBox/blob/master/Makefile
Sadly, you can't achieve this correctly without either: 可悲的是,没有以下任何一项,您将无法正确实现:
The docs you linked are mostly focused on working around the issues with make distcheck
, without supporting actual builds. 您链接的文档主要侧重于使用make distcheck
解决问题,而不支持实际构建。
There's, however, one simple hack which would work with minimal work required -- it is to copy the whole sub-tree to the build directory. 但是,有一个简单的技巧可以用最少的工作量来完成-将整个子树复制到build目录。 It is not a very good solution but it will make sub-tree builds working: 这不是一个很好的解决方案,但是它将使子树构建正常工作:
SUBDIRS = modules/libfoo
# and possibly all other -recursive targets you'll be using
all-recursive: copy-libfoo
copy-libfoo:
mkdir -p modules
cp -R -H $(top_srcdir)/modules/libfoo modules/
But as I said, it's ugly. 但是正如我所说,这很丑。 The upstream Makefile still needs to define correct automake targets ( all
, install
etc.), so in your case you would as well to need to add a GNUmakefile
in the project subdir like: 上游Makefile仍然需要定义正确的automake目标( all
, install
等),因此,在您的情况下,还需要在项目GNUmakefile
中添加GNUmakefile
,例如:
include Makefile
INSTALL:
which would provide a dummy target to avoid *** No rule to make target 'install'
; 这将提供一个虚拟目标以避免*** No rule to make target 'install'
; and possibly that as well. 可能也是这样。 Then EXTRA_DIST
if you want to use make dist
but that's all covered in the linked doc. 如果要使用make dist
,则使用EXTRA_DIST
,但这已在链接文档中进行了介绍。
Honestly, you're on a slippery ground. 老实说,您在湿滑的地面上。 If I were you, I would either simply not use that project and ignore it because maintaining it will be harder than writing the same thing from scratch. 如果我是您,我要么只是不使用那个项目,要么忽略它,因为维护它比从头开始写相同的东西要困难。
The second solution I would consider, and one which would work correct would be to duplicate the Makefile in your main Makefile.am
and not use recursive automake for that subdirectory: 我会考虑的第二种解决方案是正确的一种方法是在主Makefile.am
复制Makefile.am
,而不对该子目录使用递归automake:
LIBRARIES = modules/libfoo/libfoo.a
modules_libfoo_libfoo_a_SOURCES = modules/libfoo/src/a.c # ...
# and possibly some...
EXTRA_DIST = # ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.