Q:

How to link against just built libraries in autotools project

How can I link an executable in say test subdirectory of an autotools project  against a library, say libfoo, that is just built from files in src directory of same project?
Makefile.am looks like:
SUBDIRS = src . test
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4

src/Makefile.am:
ACLCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
lib_LTLIBRARIES = libfoo.la
libfoo_la_SOURCES = \
    foo.cpp
foo_includedir = $(includedir)/foo
foo_include_HEADERS = \
    foo.hpp

test/Makefile.am:
ACLCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
check_PROGRAMS = footest
footest_SOURCES = \
    main.cpp
footest_LDADD = ?????

A:

That's easy: footest_LDADD = ../src/libfoo.la
This works for 'out-of-tree' builds, e.g., if you invoke configure from another directory (not ./configure).

