【发布时间】:2018-09-19 14:11:27
【问题描述】:
如何在Makefile.am 文件中正确定义外部条件源?
例如,在 GNU MPFR 中,我们目前在src/Makefile.am:
if MINI_GMP
nodist_include_HEADERS += $(mini_gmp_path)/mini-gmp.h
noinst_LTLIBRARIES = libminigmp.la
nodist_libminigmp_la_SOURCES = $(mini_gmp_path)/mini-gmp.h $(mini_gmp_path)/mini-gmp.c
libmpfr_la_LIBADD += libminigmp.la
endif
当mini_gmp_path 被定义时,MINI_GMP 为真。目标是选择性地针对 libminigmp 库 (mini-gmp) 构建 MPFR,该库本身是使用 autotools 机器构建的(与 MPFR 相同的编译器、相同的选项等)。
一切似乎都运行良好,除非您不想针对 mini-gmp 进行构建。在这种情况下,生成的 configure 脚本失败并显示:
configure: creating ./config.status
config.status: creating Makefile
config.status: creating mpfr.pc
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating tune/Makefile
config.status: creating src/mparam.h
config.status: creating tools/bench/Makefile
config.status: executing depfiles commands
config.status: error: in `/home/vlefevre/software/mpfr':
config.status: error: Something went wrong bootstrapping makefile fragments
for automatic dependency tracking. Try re-running configure with the
'--disable-dependency-tracking' option to at least be able to build
the package (albeit without support for automatic dependency tracking).
See `config.log' for more details
在config.log 文件中:
config.status:19572: executing depfiles commands
config.status:19647: cd src && sed -e '/# am--include-marker/d' Makefile | make -f - am--depfiles
/bin/mkdir: cannot create directory '/.deps': Permission denied
make: *** [/tmp/GmlvxQJQ:720: /.deps/mini-gmp.Plo] Error 1
原因是生成的src/Makefile 文件包含$(mini_gmp_path)/$(DEPDIR)/mini-gmp.Plo 之类的内容,而mini_gmp_path 未定义。但由于不想针对 mini-gmp 构建,因此有关 mini-gmp.Plo 的此类信息是不正确的,即当 MINI_GMP 为 false 时,应该完全忽略 mini-gmp 文件以进行自动依赖跟踪。
作为一种解决方法,我们目前在configure.ac 中定义mini_gmp_path 到.,当不针对mini-gmp 构建时,这样$(mini_gmp_path)/$(DEPDIR) 目录就存在,避免configure 失败。但这不是一个干净的解决方案,它可能会干扰可以添加到 MPFR 源代码树中的mini-gmp.{c,h} 文件。该解决方案应该完全摆脱mini-gmp.Plo。
【问题讨论】:
标签: makefile autotools configure automake