automake: Conditional Libtool Sources
1
1 8.3.4 Libtool Libraries with Conditional Sources
1 ------------------------------------------------
1
1 Conditional compilation of sources in a library can be achieved in the
11 same way as conditional compilation of sources in a program (⇒
Conditional Sources). The only difference is that ‘_LIBADD’ should be
1 used instead of ‘_LDADD’ and that it should mention libtool objects
1 (‘.lo’ files).
1
1 So, to mimic the ‘hello’ example from ⇒Conditional Sources, we
1 could build a ‘libhello.la’ library using either ‘hello-linux.c’ or
1 ‘hello-generic.c’ with the following ‘Makefile.am’.
1
1 lib_LTLIBRARIES = libhello.la
1 libhello_la_SOURCES = hello-common.c
1 EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c
1 libhello_la_LIBADD = $(HELLO_SYSTEM)
1 libhello_la_DEPENDENCIES = $(HELLO_SYSTEM)
1
1 And make sure ‘configure’ defines ‘HELLO_SYSTEM’ as either
1 ‘hello-linux.lo’ or ‘hello-generic.lo’.
1
1 Or we could simply use an Automake conditional as follows.
1
1 lib_LTLIBRARIES = libhello.la
1 libhello_la_SOURCES = hello-common.c
1 if LINUX
1 libhello_la_SOURCES += hello-linux.c
1 else
1 libhello_la_SOURCES += hello-generic.c
1 endif
1