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
It looks like you must have forgotten to add
stages_lib/Makefileandstages_lib/lib/Makefileto theAC_CONFIG_FILESlist in yourconfigure.ac. Supposing that you have aMakefile.amin each directory mentioned, and no directories have escaped mention, you want something along these lines:configurecould not have generated those files within your build directory without also creating thestages_libdirectory, butmakeis denying that that directory exists.Additional notes:
Automake already knows how to clean. Only in exceptional cases do you need to use
CLEANFILESto tell it about files to clean -- generally this is when you have added custom rules. But when you do useCLEANFILESfor that purpose you should specify the actual file names, not globs.To the best of my knowledge,
CLEANDIRSis not meaningful to Automake. It's certainly not documented in the current manual.you can put
-Loptions either infoo_LDFLAGSor infoo_LIBADD, but-loptions should go only infoo_LIBADD(or infoo_LDADDiffoois a program).