Add support for linking talloc library statically or dynamically into samba.
authorMichael Adam <obnox@samba.org>
Fri, 8 Feb 2008 13:41:30 +0000 (14:41 +0100)
committerMichael Adam <obnox@samba.org>
Wed, 13 Feb 2008 08:25:31 +0000 (09:25 +0100)
commit71b990d9d687b517dec3d4eff67b6a3fe417a12a
treeca9c10e769b7c2f179a6eb8f839d8934d7a31169
parent880238c65c13c8b280e2f34431aa331a16af4a7b
Add support for linking talloc library statically or dynamically into samba.

This also establishes a general configure mechanism to control static vs
dynamic linking of internal subsystems built as libraries:
This first simple approach is as follows.

* It applies only to "subsystems" that we build as libraries and for
  that linking samba against the libraries (as opposed to linking in
  the plain object files) has been configured in Makefile.in.

* If we do build the shared library, then we link dynamically by default.

* We only link statically if we don't build shared or if the library
  appears in the new --with-static-libs configure option
  (comma-separated list).

Example (currently only one):
  --with-static-libs=talloc makes use of libtalloc.a instead
  of linking the dynamic variant with -ltalloc.

A possilble way to setup linking against libraries in Makefile.in is this:
For a subsystem, "mylib" say, we build bin/libmylib.a and bin/libmylib.so.
The subsystem usually has a MYLIB_OBJ definition in Makefile.in.  Define
LIBMYLIB_STATIC=bin/libmylib.a and and LIBMYLIB_LIBS=-lmylib in configure.in
as controlled by presence of "mylib" in the list given to --with-static-libs
and change uses of $(MYLIB_OBJ) to @LIBMYLIB_STATIC@ in Makefile.in and
add @LIBMYLIB_LIBS@ to the link targets as needed.

In the example of talloc, which is needed everywhere, I have simply
added @LIBTALLOC_LIBS@ to the definition of "LIBS" in Makefile.in.
For other subsystems, one will have to be more careful.

Michael
source/Makefile.in
source/configure.in