使用libtool便利库时“没有规则来制作目标`distclean'”

时间:2013-05-01 16:29:33

标签: c++ autotools libtool

我正在使用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。

一切正常(configuremakemake check),make distcheck除了{my}返回No rule to make target distclean后进入mypkg / src / mybiglib / mysmalllib1。

更准确地说,这是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.

为什么“在small1中制造distclean”会出现两次?这个错误似乎来自于它第一次运行良好的事实,因此第二次失败了吗?

这是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_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

1 个答案:

答案 0 :(得分:1)

问题是由于“mypkg /”中的Makefile.am已经在其变量SUBDIRS中包含“src / big / small1”和“src / big / small2”。为了解决这个问题,我只需要从变量中删除这两个。文件“mypkg / Makefile.am”现在看起来像这样:

SUBDIRS = src/big src

User @ ldav1s表明,在任何情况下,对整个项目使用单个非递归Makefile.am可能更好(更多细节here)。