From 16ecac68e5923dcfcd98d1c6ae7f580eb9585d3b Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Mon, 1 Feb 2010 10:33:28 -0500
Subject: [PATCH 06/14] Split off libcollection into a shared library

---
 common/collection/Makefile.am    |   16 ++++++++++------
 common/collection/README         |    2 ++
 common/collection/configure.ac   |    2 +-
 server/Makefile.am               |   17 +++++++++++------
 server/configure.ac              |    1 +
 server/external/libcollection.m4 |   12 ++++++++++++
 6 files changed, 37 insertions(+), 13 deletions(-)
 create mode 100644 common/collection/README
 create mode 100644 server/external/libcollection.m4

diff --git a/common/collection/Makefile.am b/common/collection/Makefile.am
index bd7186b..2734a71 100644
--- a/common/collection/Makefile.am
+++ b/common/collection/Makefile.am
@@ -16,12 +16,16 @@ ACLOCAL_AMFLAGS = -I m4
 
 # Set up the pkg-config file
 pkgconfigdir = $(libdir)/pkgconfig
-dist_noinst_DATA = \
-    collection.pc \
-    m4
+dist_pkgconfig_DATA = collection.pc
+
+dist_include_HEADERS = \
+    collection.h \
+    collection_tools.h
+
+dist_noinst_DATA = m4
 
 # Build library
-noinst_LTLIBRARIES = libcollection.la
+lib_LTLIBRARIES = libcollection.la
 libcollection_la_SOURCES = \
     collection.c \
     collection_tools.c \
@@ -30,12 +34,12 @@ libcollection_la_SOURCES = \
     collection_stack.c \
     collection_cmp.c \
     collection_iter.c \
-    collection.h \
-    collection_tools.h \
     collection_priv.h \
     collection_queue.h \
     collection_stack.h \
     ../trace/trace.h
+libcollection_la_LDFLAGS = \
+    -version-info 1:0:0
 
 # Build unit test
 check_PROGRAMS = collection_ut collection_stack_ut collection_queue_ut
diff --git a/common/collection/README b/common/collection/README
new file mode 100644
index 0000000..83a7b92
--- /dev/null
+++ b/common/collection/README
@@ -0,0 +1,2 @@
+Documentation for libcollection can be found in collection.h and
+collection_tools.h
diff --git a/common/collection/configure.ac b/common/collection/configure.ac
index 3ba1eb7..2ec6c01 100644
--- a/common/collection/configure.ac
+++ b/common/collection/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([collection],[0.3.3],[sssd-devel@lists.fedorahosted.org])
+AC_INIT([collection],[0.4.0],[sssd-devel@lists.fedorahosted.org])
 AC_CONFIG_SRCDIR([collection.c])
 AC_CONFIG_AUX_DIR([build])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
diff --git a/server/Makefile.am b/server/Makefile.am
index 7ba7ffa..9ebc985 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -132,12 +132,17 @@ dist_noinst_DATA = \
 ###############################
 # Global compilation settings #
 ###############################
-COLLECTION_CFLAGS = \
-    -I$(srcdir)/../common/collection \
-    -I$(srcdir)/../common/trace
-COLLECTION_LIBS = \
-    -L$(builddir)/../common/collection/.libs/ \
-    -lcollection
+
+if HAVE_SYSTEM_COLLECTION
+    COLLECTION_CFLAGS = $(SYSTEM_COLLECTION_CFLAGS)
+    COLLECTION_LIBS = $(SYSTEM_COLLECTION_LIBS)
+else
+    COLLECTION_CFLAGS = \
+        -I$(srcdir)/../common/collection
+    COLLECTION_LIBS = \
+        -L$(builddir)/../common/collection \
+        -lcollection
+endif
 
 INI_CFG_CFLAGS = \
     -I$(srcdir)/../common/ini
diff --git a/server/configure.ac b/server/configure.ac
index 75c07da..a67dd15 100644
--- a/server/configure.ac
+++ b/server/configure.ac
@@ -66,6 +66,7 @@ m4_include([external/libtdb.m4])
 m4_include([external/libtevent.m4])
 m4_include([external/libldb.m4])
 m4_include([external/libdhash.m4])
+m4_include([external/libcollection.m4])
 m4_include([external/pam.m4])
 m4_include([external/ldap.m4])
 m4_include([external/libpcre.m4])
diff --git a/server/external/libcollection.m4 b/server/external/libcollection.m4
new file mode 100644
index 0000000..8fc37e8
--- /dev/null
+++ b/server/external/libcollection.m4
@@ -0,0 +1,12 @@
+AC_SUBST(SYSTEM_COLLECTION_OBJ)
+AC_SUBST(SYSTEM_COLLECTION_CFLAGS)
+AC_SUBST(SYSTEM_COLLECTION_LIBS)
+
+PKG_CHECK_MODULES(SYSTEM_COLLECTION, collection >= 0.4.0,
+    have_system_collection=true,
+    have_system_collection=false
+    )
+# This is future-compatible. Right now, we'll force the use of our
+# in-tree copy. When collection is split off as its own source package, we'll
+# fix this test
+AM_CONDITIONAL(HAVE_SYSTEM_COLLECTION, test x$have_system_collection = xtrue_FORCE_IN_TREE)
-- 
1.6.6

