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


目的是仅将libbig.la安装在/ usr / local / lib中,而仅small1.hpp和small2.hpp安装在/ usr / local / include中。

一切正常(configuremakemake check),除了make distcheck在进入mypkg / src / mybiglib / mysmalllib1内部后返回No rule to make target 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.


为什么“在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:

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++ - 使用libtool便捷库时,“没有使目标'distclean'的规则”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16322242/

10-16 19:17