3
votes

I have a recursive autoconf + automake project that is structured like this:

+
|- configure.ac
|- Makefile.am
|- Makefile.in
|- ...
|-- (subdir1) --+
|               |- Makefile.am
|               |- source.c
|               |- ...
|
|-- (subdir2) --+
|               |- Makefile.am
                |- source.c
                |- ...

The top level configure/Makefile checks if various libraries are available (AC_CHECK_LIB), then builds the libraries in the subdirs (if selected).

The problem is the LIBS variable that is passed down to each subdir make contains the union of all required libraries, ie:

# each subdir sees:
LIBS = -lfoo -lbar -lbaz -lbif

But what I want is:

# subdir1 gets
LIBS = -lfoo -lbar

# subdir2 gets
    LIBS = -lbaz -lbif

Is there a mechanism to specify per subproject LIBS?

1

1 Answers

2
votes

In your toplevel Makefile.am use a variable name per library

LIBFOO = -lfoo

LIBBAR = -lbar

in the subdirectories refer to $(LIBFOO) and $(LIBBAR)