我正在使用 GNU Autotools 编写 C++ 程序包。我合并了几个外部库以随包一起提供。因为我不想单独安装这些库中的每一个,所以我使用了“libtool convenience library”。目录层次结构大致如下所示:
mypkg/
configure.ac
Makefile.am
src/
Makefile.am
myprogram.cpp
big/
Makefile.am
small1/
Makefile.am
small1.hpp
small1.cpp
small2/
Makefile.am
small2.hpp
small2.cpp
目的是在/usr/local/lib中只安装libbig.la,而在/usr/local/include中只安装small1.hpp和small2.hpp。
一切正常(configure
、make
、make check
),除了返回 的
。make distcheck
>进入 mypkg/src/mybiglib/mysmalllib1 后,没有规则使目标 distclean
更准确地说,这里是 make distcheck 的输出:
make[1]: Entering directory `~/mypkg/mypkg-1.3/_build'
Making distclean in src/big/small1
make[2]: Entering directory `~/mypkg/mypkg-1.3/_build/src/big/small1'
rm -rf .libs _libs
test -z "libsmall1.la" || rm -f libsmall1.la
rm -f ./so_locations
rm -f *.o
rm -f *.lo
rm -f *.tab.c
test -z "" || rm -f
test . = "../../../../src/big/small1" || test -z "" || rm -f
rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
rm -rf ./.deps
rm -f Makefile
make[2]: Leaving directory `~/mypkg/mypkg-1.3/_build/src/big/small1'
Making distclean in src/big/small2
make[2]: Entering directory `~/mypkg/mypkg-1.3/_build/src/big/small2'
... # similar as for small1 above
make[2]: Leaving directory `~/mypkg/mypkg-1.3/_build/src/big/small2'
Making distclean in src/big
make[2]: Entering directory `~/mypkg/mypkg-1.3/_build/src/big'
Making distclean in small1
make[3]: Entering directory `~/mypkg/mypkg-1.3/_build/src/big/small1'
make[3]: *** No rule to make target `distclean'. Stop.
为什么“Making distclean in small1”出现两次?错误似乎是因为它第一次运行良好,因此第二次失败了?
这是 mypkg/src/big/small1/中的 Makefile.am:
AM_CXXFLAGS = -I$(top_srcdir)/src/big @AM_CXXFLAGS@
noinst_LTLIBRARIES = libsmall1.la
libirls_la_SOURCES = small1.cpp
这是 mypkg/src/big/中的 Makefile.am:
SUBDIRS = small1 small2
lib_LTLIBRARIES = libbig.la
libeqtlbma_la_SOURCES = small1/small1.hpp \
small2/small2.hpp
nodist_EXTRA_libbig_la_SOURCES = dummy.cxx
libeqtlbma_la_LIBADD = small1/small1.la small2/small2.la
这是 mypkg/src/中的 Makefile.am:
AM_CXXFLAGS = -I$(top_srcdir)/src/big -fopenmp @AM_CXXFLAGS@
bin_PROGRAMS = myprogram
myprogram_SOURCES = myprogram.cpp
myprogram_CPPFLAGS = -fopenmp
myprogram_LDFLAGS = -fopenmp
myprogram_LDADD = $(top_builddir)/src/big/libbig.la $(AM_LDFLAGS)
这是 mypkg/中的 Makefile.am:
SUBDIRS = src/big/small1 src/big/small2 src/big src
我哪里忘记了什么?或者我不应该在最后一个 Makefile.am 的 SUBDIRS 中包含“small1/”和“small2/”?
ps: automake v1.13.1 ; autoconf v2.69 ; libtool v2.4.2
最佳答案
问题是由于“mypkg/”中的 Makefile.am 在其变量 SUBDIRS 中已经包含“src/big/small1”和“src/big/small2”。为了解决这个问题,我只需要从变量中删除这两个。文件“mypkg/Makefile.am”现在看起来像这样:
SUBDIRS = src/big src
用户@ldav1s 表示,无论如何,对整个项目使用单个非递归 Makefile.am 可能更好(更多详细信息 here)。
关于c++ - "No rule to make target ` distclean '"使用 libtool 便利库时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16322242/