Reputation: 763
We have a large code base that I'm converting to autotools to help target multiple platforms / configurations. Basically, we have:
|-- configure.ac
|-- Makefile.am
|-- dependency1
| `-- Makefile.am
|-- dependency2
| `-- Makefile.am
`-- dependency3
`-- Makefile.am
The dependency folders are common across many projects, so The Makefile.am
files create libdependencyX.la
files. In the root Makefile.am
, I then use LIBADD
to combine everything to create a final shared library. This all works create.
We have the need to create both shared and static versions of our library. How would I go about this? All of the dependencies just use LTLIBRARIES
to make everything.
The original solution was just a giant Makefile that created a series of .o
files and then building the resulting .so
or .a
in the end.
Update 2015-03-11
The issue I'm having is that I can get static or shared, but not both. The root Makefile.am
looks like this for the final library.
lib_LTLIBRARIES = libroot.la
libroot_la_SOURCES = root.c
libroot_la_LIBADD = dependency1/libdependency1.la \
dependency2/libdependency2.la \
dependency3/libdependency3.la
libroot_la_LDFLAGS = -shared
Switching the -shared
to -static
gives me the .a
, but how can I get both? --enable-shared / --enable-static
doesn't seem to change anything.
Upvotes: 3
Views: 1824
Reputation: 763
It seems my issue is with the libretto_la_LDFLAGS
line. Leaving that out and using make install
gives both the .a and .so files in the prefix specified.
Upvotes: 1