Question

I am writing a C++ package with the GNU Autotools. I'm incorporating several external libraries to ship with the package. As I don't want to install each of those libraries separately, I instead use a "libtool convenience library". The directory hierarchy looks roughly like this:

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

with the aim that only libbig.la will be installed in /usr/local/lib, while only small1.hpp and small2.hpp will be installed in /usr/local/include.

Everything works well (configure, make, make check), except make distcheck which returns No rule to make target distclean after entering inside mypkg/src/mybiglib/mysmalllib1.

More precisely, here is the output of 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.

Why does "Making distclean in small1" occurs twice? The error seems to come from the fact that it worked well the first time, and thus fails the second?

Here is the Makefile.am inside mypkg/src/big/small1/:

AM_CXXFLAGS = -I$(top_srcdir)/src/big @AM_CXXFLAGS@
noinst_LTLIBRARIES = libsmall1.la
libirls_la_SOURCES = small1.cpp

Here is the Makefile.am inside mypkg/src/big/:

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

Here is the Makefile.am inside mypkg/src/:

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)

Here is the Makefile.am inside mypkg/:

SUBDIRS = src/big/small1 src/big/small2 src/big src

Where am I forgetting something? Or maybe I should no include "small1/" and "small2/" in SUBDIRS of the last Makefile.am?

ps: automake v1.13.1 ; autoconf v2.69 ; libtool v2.4.2

Was it helpful?

Solution

The problem was due to the fact that the Makefile.am in "mypkg/" was already containing "src/big/small1" and "src/big/small2" in its variable SUBDIRS. To solve the problem, I only had to remove these two from the variable. The file "mypkg/Makefile.am" now looks like this:

SUBDIRS = src/big src

User @ldav1s indicates that, in any case, it may be better to use a single, non-recursive Makefile.am for the whole project (more details here).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top