makefileautotoolsautomake

automake -- SUBDIRS -- "No such file or directory"


I am using autoconf/automake for my build system. So far it has been working just fine. However, I want to split some code out into another lib that I will be loading dynamically from within my main library. This is where I have run into an issue. The Makefile.am structure is as follows:

# Makefile.am
SUBDIRS = lib test bin stages_lib
ACLOCAL_AMFLAGS = -I m4
CLEANFILES = *.o
CLEANDIRS = deps/ .lib/
# stages_lib/Makefile.am
SUBDIRS = lib
# stages_lib/lib/Makefile.am
lib_LTLIBRARIES = libstages_lib.la

libstages_lib_la_CPPFLAGS = -Werror -Wall -pedantic \
    -I$(abs_top_srcdir)/include/ \
    -I$(abs_top_srcdir)/stages_lib/include \
    -I$(abs_top_srcdir)/deps/build/boost/include

libstages_lib_la_SOURCES = print_stage.cxx

libstages_lib_la_LDFLAGS = -L$(abs_top_srcdir)/deps/build/boost/lib
if LINUX
libstages_lib_la_LDFLAGS += -L$(abs_top_srcdir)/deps/build/openssl/lib64
else
libstages_lib_la_LDFLAGS += -L$(abs_top_srcdir)/deps/build/openssl/lib
endif
libstages_lib_la_LDFLAGS += -libdag_scheduler -lboost_filesystem -lboost_log -lboost_system \
    -lboost_thread -lssl -lcrypto -pthread

if LINUX
libstages_lib_la_LIBADD = $(INIT_LIBS) -lm
else
libstages_lib_la_LIBADD = $(INIT_LIBS)
endif

With this setup, noting that the lib, test, and bin SUBDIRS build just fine. When I run the following from the root directory of my project:

> autoreconf -i
> rm -rf ./build && mkdir -p ./build
> cd build/ && ../configure
> cd ../
> make -C build

I now get the following error:

Making all in stages_lib
/bin/sh: line 0: cd: stages_lib: No such file or directory
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Solution

  • It looks like you must have forgotten to add stages_lib/Makefile and stages_lib/lib/Makefile to the AC_CONFIG_FILES list in your configure.ac. Supposing that you have a Makefile.am in each directory mentioned, and no directories have escaped mention, you want something along these lines:

    AC_CONFIG_FILES([
      Makefile
      lib/Makefile
      test/Makefile
      bin/Makefile
      stages_lib/Makefile
      stages_lib/lib/Makefile
    ])
    

    configure could not have generated those files within your build directory without also creating the stages_lib directory, but make is denying that that directory exists.

    Additional notes: