(automake-1.16.info)Conditional Libtool Sources


Next: Libtool Convenience Libraries Prev: Conditional Libtool Libraries Up: A Shared Library
Enter node , (file) or (file)node

8.3.4 Libtool Libraries with Conditional Sources
------------------------------------------------

Conditional compilation of sources in a library can be achieved in the
same way as conditional compilation of sources in a program (Note:
Conditional Sources).  The only difference is that ‘_LIBADD’ should be
used instead of ‘_LDADD’ and that it should mention libtool objects
(‘.lo’ files).

   So, to mimic the ‘hello’ example from Note: Conditional Sources, we
could build a ‘libhello.la’ library using either ‘hello-linux.c’ or
‘hello-generic.c’ with the following ‘Makefile.am’.

     lib_LTLIBRARIES = libhello.la
     libhello_la_SOURCES = hello-common.c
     EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c
     libhello_la_LIBADD = $(HELLO_SYSTEM)
     libhello_la_DEPENDENCIES = $(HELLO_SYSTEM)

And make sure ‘configure’ defines ‘HELLO_SYSTEM’ as either
‘hello-linux.lo’ or ‘hello-generic.lo’.

   Or we could simply use an Automake conditional as follows.

     lib_LTLIBRARIES = libhello.la
     libhello_la_SOURCES = hello-common.c
     if LINUX
     libhello_la_SOURCES += hello-linux.c
     else
     libhello_la_SOURCES += hello-generic.c
     endif


automatically generated by info2www version 1.2.2.9