From ffdfde559d3590aeac6b6a56dd2c3a1898e9e759 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Tue, 12 May 2009 11:56:27 -0400
Subject: [PATCH 2/4] Enable building a single libsssd_utils.so from common

---
 common/Makefile.am            |   19 ++++++++++++++++++-
 common/collection/Makefile.am |    8 +++++++-
 common/configure.ac           |   17 +++++++++++++----
 3 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/common/Makefile.am b/common/Makefile.am
index 276bbb2..47d7c4a 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -1,2 +1,19 @@
-SUBDIRS = collection ini trace dhash
 ACLOCAL_AMFLAGS = -I m4
+
+if SINGLELIB
+# Build all components as a single shared library
+lib_LTLIBRARIES = libsssd_util.la
+libsssd_util_la_SOURCES = \
+    collection/collection.c \
+    collection/collection_tools.c \
+    ini/ini_config.c \
+    dhash/dhash.c
+libsssd_util_la_CFLAGS = $(AM_CFLAGS) \
+    -I ./collection \
+    -I ./ini \
+    -I ./dhash \
+    -I ./trace
+else
+SUBDIRS = collection ini trace dhash
+endif
+
diff --git a/common/collection/Makefile.am b/common/collection/Makefile.am
index 1d8f937..37d3ddf 100644
--- a/common/collection/Makefile.am
+++ b/common/collection/Makefile.am
@@ -11,7 +11,13 @@ pkgconfig_DATA = collection.pc
 
 # Build library
 lib_LTLIBRARIES = libcollection.la
-libcollection_la_SOURCES = collection.c collection_tools.c collection_tools.h collection_class.h
+libcollection_la_SOURCES = \
+    collection.c \
+    collection_tools.c
+
+noinst_HEADERS = \
+    collection_priv.h
+
 include_HEADERS = collection.h collection_tools.h
 
 # Build unit test
diff --git a/common/configure.ac b/common/configure.ac
index a5fa3d5..e321399 100644
--- a/common/configure.ac
+++ b/common/configure.ac
@@ -23,8 +23,17 @@ AC_CONFIG_FILES([Makefile
 
 AC_CONFIG_SUBDIRS([collection dhash ini])
 
-AC_OUTPUT
-
-
-
+AC_DEFUN([WITH_SINGLELIB],
+  [ AC_ARG_WITH([singlelib],
+                [AC_HELP_STRING([--with-singlelib],
+                                [Whether to build a shared object containing all sssd_utils [no]]
+                               )
+                ],
+                [],
+                with_singlelib=yes
+               )
+  ])
+
+AM_CONDITIONAL([SINGLELIB], [test x$with_singlelib = xyes ])
 
+AC_OUTPUT
-- 
1.6.2.2

