I am trying to build a static library from several sources. The problem is that for some sources I have to use different CFLAGS
.
In the beginning I thought about creating several noinst_LIBRARIES
and finally combine them to one in lib_LIBRARIES
using LIBADD
. This approach fails because there is no way to combine static libraries using ar
without extracting them.
This is how my Makefile.am
currently looks:
noinst_LIBRARIES = lib1.a lib2.a
lib_LIBRARIES = final.a
final_a_CFLAGS = -Werror
final_a_SOURCES = mainlib/src.c
final_a_LIBADD = lib1.a lib2.a
lib1_a_CFLAGS = -O0
lib1_a_SOURCES = lib1/src11.c lib1/src12.c
lib2_a_CFLAGS = -O3
lib2_a_SOURCES = lib2/src21.c
I have already thought about substituting AR
with an ar
wrapper that will first extract the libraries and then combine them in the final.a
. But I do not like this approach, so is there a correct way to achieve this?
You probably want convenience libraries. They are documented in the manual.