嵌套文件夹的 Automake - 递归是必须的吗?

Automake for nested folders - is recursion a must?

我目前在我的项目中有以下文件夹结构:

   .
   |-examples
   |-nbis
   |---bozorth3
   |-----include
   |-----src
   |-------bin
   |---------bozorth3
   |-------lib
   |---------bozorth3
   |-zfm20

我想用 autotools 构建它,所以我有一个文件 Makefile.am 包含以下内容:

AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = zfm20 examples nbis

我对 zfm20examples 没有任何问题。我的问题是关于文件夹 nbis。这是 nbis/Makefile.am 的样子:

BZ3_LIBDIR = bozorth3/src/lib/bozorth3/
BZ3_BINDIR = bozorth3/src/bin/bozorth3/
BZ3_INCLUDES = bozorth3/include/bozorth3.h bozorth3/include/bz_array.h

lib_LTLIBRARIES = libbozorth.la
libbozorth_la_SOURCES = $(BZ3_INCLUDES) $(BZ3_LIBDIR)bozorth3.c $(BZ3_LIBDIR)bz_alloc.c $(BZ3_LIBDIR)bz_drvrs.c $(BZ3_LIBDIR)bz_gbls.c $(BZ3_LIBDIR)bz_io.c $(BZ3_LIBDIR)bz_sort.c

bin_PROGRAMS = bozorth3
bozorth3_SOURCES = $(BZ3_INCLUDES) $(BZ3_BINDIR)bz3.c $(BZ3_BINDIR)usage.c
bozorth3_LDADD = libbozorth.la

但好像不是这样。这是 make 的输出:

Making all in nbis
make[2]: Entering directory '/home/pi/git/figure_fingerprint_sensor/nbis'
Makefile:382: .deps/bozorth3/src/bin/bozorth3/bz3.Po: Datei oder Verzeichnis nicht gefunden
Makefile:383: .deps/bozorth3/src/bin/bozorth3/usage.Po: Datei oder Verzeichnis nicht gefunden
Makefile:384: .deps/bozorth3/src/lib/bozorth3/bozorth3.Plo: Datei oder Verzeichnis nicht gefunden
Makefile:385: .deps/bozorth3/src/lib/bozorth3/bz_alloc.Plo: Datei oder Verzeichnis nicht gefunden
Makefile:386: .deps/bozorth3/src/lib/bozorth3/bz_drvrs.Plo: Datei oder Verzeichnis nicht gefunden
Makefile:387: .deps/bozorth3/src/lib/bozorth3/bz_gbls.Plo: Datei oder Verzeichnis nicht gefunden
Makefile:388: .deps/bozorth3/src/lib/bozorth3/bz_io.Plo: Datei oder Verzeichnis nicht gefunden
Makefile:389: .deps/bozorth3/src/lib/bozorth3/bz_sort.Plo: Datei oder Verzeichnis nicht gefunden
make[2]: *** No rule to make target '.deps/bozorth3/src/lib/bozorth3/bz_sort.Plo'.  Schluss.
make[2]: Leaving directory '/home/pi/git/figure_fingerprint_sensor/nbis'
Makefile:324: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/pi/git/figure_fingerprint_sensor'
Makefile:255: recipe for target 'all' failed
make: *** [all] Error 2

如果查看文件夹 .deps,我会看到:

$(BZ3_LIBDIR)bz_sort.Plo
$(BZ3_LIBDIR)bz_io.Plo
$(BZ3_LIBDIR)bz_gbls.Plo
$(BZ3_LIBDIR)bz_drvrs.Plo
$(BZ3_LIBDIR)bz_alloc.Plo
$(BZ3_LIBDIR)bozorth3.Plo
$(BZ3_BINDIR)usage.Po
$(BZ3_BINDIR)bz3.Po

我真的需要在每个嵌套文件夹中都有一个 Makefile.am 才能使其正常工作,还是我只是用变量弄乱了文件?

编辑:这似乎是a bug in automake itself,无论您是否使用subdir-objects都会发生,所以这个答案中的说明实际上是错误的。正确的选择是停止使用 _SOURCES 列表中的变量,因为对象列表未被正确收集。

原回答如下。

认为它可以通过为 automake 启用 subdir-objects 选项来解决。

configure.ac中:

AM_INIT_AUTOMAKE([subdir-objects])

这种方式不是寻找 .deps/bozorth3/src/lib/bozorth3/bz_sort.Plo 而是寻找 bozorth3/src/lib/bozorth3/.deps/bz_sort.Plo.