user318904
user318904

Reputation: 3066

Autotools per subproject LIBS possible?

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?

Upvotes: 3

Views: 193

Answers (1)

arved
arved

Reputation: 4576

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

LIBFOO = -lfoo

LIBBAR = -lbar

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

Upvotes: 2

Related Questions