apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r501380 - in /apr/apr-util/trunk: CHANGES Makefile.in build.conf build/dbd.m4 configure.in dbd/apr_dbd.c
Date Tue, 30 Jan 2007 11:54:53 GMT
Author: jorton
Date: Tue Jan 30 03:54:52 2007
New Revision: 501380

URL: http://svn.apache.org/viewvc?view=rev&rev=501380
Log:
Add support for loading DBD drivers as DSOs:

* build.conf: Only add apr_dbd.c to OBJECTS by default.  Add module
sections to define DBD DSOs.

* build/dbd.m4 (APU_CHECK_DBD_*): Add DBD-specific libraries to
LDADD_dbd_*.
(APU_CHECK_DBD_DSO): New macro.

* configure.in: Use APU_CHECK_DBD_DSO.  Export APU_HAVE_MODULES,
APU_DSO_LIBDIR, APU_MODULES, EXTRA_OBJECTS for supporting DSO builds.

* Makefile.in: Pick up newly exported variables; define LINK_MODULE.
(install-modules, install-modules-yes, install-modules-no): New targets.
($(TARGET_LIB)): Link against and depend on EXTRA_OBJECTS.

* dbd/apr_dbd.c: Clean up #includes; use APU_DSO_BUILD throughout
to dictate use of drivers as DSOs.
(apr_dbd_get_driver): Take the mutex before using the hash.
Use absolute path to DSO.  Fix cast warning.

Submitted by: jorton, bojan

Modified:
    apr/apr-util/trunk/CHANGES
    apr/apr-util/trunk/Makefile.in
    apr/apr-util/trunk/build.conf
    apr/apr-util/trunk/build/dbd.m4
    apr/apr-util/trunk/configure.in
    apr/apr-util/trunk/dbd/apr_dbd.c

Modified: apr/apr-util/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/CHANGES?view=diff&rev=501380&r1=501379&r2=501380
==============================================================================
--- apr/apr-util/trunk/CHANGES (original)
+++ apr/apr-util/trunk/CHANGES Tue Jan 30 03:54:52 2007
@@ -1,5 +1,8 @@
 Changes with APR-util 1.3.0
 
+  *) Support building DBD drivers as DSOs; use --enable-dbd-dso flag
+     to configure.  [Joe Orton, Bojan Smojver]
+
   *) Rewrite detection of expat in configure to fix build on e.g. biarch
      Linux platforms.  PR 28205.  [Joe Orton]
 

Modified: apr/apr-util/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/Makefile.in?view=diff&rev=501380&r1=501379&r2=501380
==============================================================================
--- apr/apr-util/trunk/Makefile.in (original)
+++ apr/apr-util/trunk/Makefile.in Tue Jan 30 03:54:52 2007
@@ -22,7 +22,19 @@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 
-TARGETS = $(TARGET_LIB) aprutil.exp apu-config.out
+APU_MODULES = @APU_MODULES@
+LINK_MODULE = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(LT_LDFLAGS) $(ALL_CFLAGS) $(ALL_LDFLAGS)
$(APRUTIL_LDFLAGS) -release $(APRUTIL_MAJOR_VERSION) -module -rpath $(APU_DSO_LIBDIR)
+APU_DSO_LIBDIR = @APU_DSO_LIBDIR@
+
+EXTRA_OBJECTS = @EXTRA_OBJECTS@
+
+LDADD_dbd_pgsql = @LDADD_dbd_pgsql@
+LDADD_dbd_oracle = @LDADD_dbd_oracle@
+LDADD_dbd_sqlite2 = @LDADD_dbd_sqlite2@
+LDADD_dbd_sqlite3 = @LDADD_dbd_sqlite3@
+LDADD_dbd_mysql = @LDADD_dbd_mysql@
+
+TARGETS = $(TARGET_LIB) aprutil.exp apu-config.out $(APU_MODULES)
 
 # bring in rules.mk for standard functionality
 @INCLUDE_RULES@
@@ -53,7 +65,7 @@
 apu-config.out: $(APU_CONFIG)
 	sed 's,^\(location=\).*$$,\1installed,' < $(APU_CONFIG) > $@
 
-install: $(TARGETS)
+install: $(TARGETS) install-modules
 	$(APR_MKDIR) $(DESTDIR)$(includedir) $(DESTDIR)$(libdir)/pkgconfig \
 		     $(DESTDIR)$(libdir) $(DESTDIR)$(bindir)
 	for f in $(top_srcdir)/include/*.h $(top_blddir)/include/*.h; do \
@@ -67,8 +79,16 @@
 	$(INSTALL_DATA) aprutil.exp $(DESTDIR)$(libdir)
 	$(INSTALL) -m 755 apu-config.out $(DESTDIR)$(bindir)/$(APU_CONFIG)
 
-$(TARGET_LIB): $(OBJECTS)
-	$(LINK) @lib_target@ $(ALL_LIBS) $(APRUTIL_LDFLAGS) $(APRUTIL_LIBS)
+$(TARGET_LIB): $(OBJECTS) $(EXTRA_OBJECTS)
+	$(LINK) @lib_target@ $(EXTRA_OBJECTS) $(ALL_LIBS) $(APRUTIL_LDFLAGS) $(APRUTIL_LIBS)
+
+install-modules: install-modules-@APU_HAVE_MODULES@
+
+install-modules-no:
+
+install-modules-yes: $(APU_MODULES)
+	$(APR_MKDIR) $(DESTDIR)$(APU_DSO_LIBDIR)
+	@for m in $(APU_MODULES); do $(LIBTOOL) $(LT_LTFLAGS) $(LTFLAGS) --mode=install $(INSTALL)
-m 755 $$m $(DESTDIR)$(APU_DSO_LIBDIR); done
 
 exports.c: $(HEADERS)
 	$(APR_MKEXPORT) $(HEADERS) > $@
@@ -89,3 +109,5 @@
 test: check
 check: $(TARGET_LIB)
 	cd test && $(MAKE) check
+
+.PHONY: install-modules install-modules-yes install-modules-no dox test check

Modified: apr/apr-util/trunk/build.conf
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/build.conf?view=diff&rev=501380&r1=501379&r2=501380
==============================================================================
--- apr/apr-util/trunk/build.conf (original)
+++ apr/apr-util/trunk/build.conf Tue Jan 30 03:54:52 2007
@@ -19,7 +19,7 @@
   xml/*.c
   strmatch/*.c
   xlate/*.c
-  dbd/*.c
+  dbd/apr_dbd.c
   ssl/*.c
 
 # we have no platform-specific subdirs
@@ -28,7 +28,29 @@
 # the public headers
 headers = include/*.h include/private/*.h
 
+modules = dbd_pgsql dbd_sqlite2 dbd_sqlite3 dbd_oracle dbd_mysql
+
 # gen_uri_delim.c
 
 # we have a recursive makefile for the test files (for now)
 # test/*.c
+
+[dbd_pgsql]
+paths = dbd/apr_dbd_pgsql.c
+target = dbd/apr_dbd_pgsql.la
+
+[dbd_sqlite2]
+paths = dbd/apr_dbd_sqlite2.c
+target = dbd/apr_dbd_sqlite2.la
+
+[dbd_sqlite3]
+paths = dbd/apr_dbd_sqlite3.c
+target = dbd/apr_dbd_sqlite3.la
+
+[dbd_oracle]
+paths = dbd/apr_dbd_oracle.c
+target = dbd/apr_dbd_oracle.la
+
+[dbd_mysql]
+paths = dbd/apr_dbd_mysql.c
+target = dbd/apr_dbd_mysql.la

Modified: apr/apr-util/trunk/build/dbd.m4
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/build/dbd.m4?view=diff&rev=501380&r1=501379&r2=501380
==============================================================================
--- apr/apr-util/trunk/build/dbd.m4 (original)
+++ apr/apr-util/trunk/build/dbd.m4 Tue Jan 30 03:54:52 2007
@@ -69,9 +69,9 @@
   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
   dnl we know the library is there.
   if test "$apu_have_pgsql" = "1"; then
-    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lpq])
-    APR_ADDTO(APRUTIL_LIBS,[-lpq])
+    LDADD_dbd_pgsql=-lpq
   fi
+  AC_SUBST(LDADD_dbd_pgsql)
 ])
 dnl
 AC_DEFUN([APU_CHECK_DBD_MYSQL], [
@@ -100,7 +100,6 @@
         else
           if test "x$MYSQL_CONFIG" != 'x'; then
             APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
-            APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
           fi
         fi
 
@@ -128,14 +127,12 @@
         AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
         if test "$apu_have_mysql" != "0"; then
           APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
-          APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
         fi
 
         if test "$apu_have_mysql" != "1"; then
           AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
           if test "$apu_have_mysql" != "0"; then
             APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/mysql])
-            APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
           fi
         fi
 
@@ -162,7 +159,6 @@
       if test "$apu_have_mysql" != "0"; then
         if test "x$MYSQL_CONFIG" != 'x'; then
           APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS])
-          APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS])
         fi
       fi
 
@@ -176,9 +172,9 @@
   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
   dnl we know the library is there.
   if test "$apu_have_mysql" = "1"; then
-    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lmysqlclient_r])
-    APR_ADDTO(APRUTIL_LIBS,[-lmysqlclient_r])
+    LDADD_dbd_mysql=$mysql_LDFLAGS
   fi
+  AC_SUBST(LDADD_dbd_mysql)
 ])
 dnl
 AC_DEFUN([APU_CHECK_DBD_SQLITE3], [
@@ -221,9 +217,9 @@
   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
   dnl we know the library is there.
   if test "$apu_have_sqlite3" = "1"; then
-    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lsqlite3])
-    APR_ADDTO(APRUTIL_LIBS,[-lsqlite3])
+    LDADD_dbd_sqlite3="-lsqlite3"
   fi
+  AC_SUBST(LDADD_dbd_sqlite3)
 ])
 dnl
 AC_DEFUN([APU_CHECK_DBD_SQLITE2], [
@@ -266,9 +262,9 @@
   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
   dnl we know the library is there.
   if test "$apu_have_sqlite2" = "1"; then
-    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lsqlite])
-    APR_ADDTO(APRUTIL_LIBS,[-lsqlite])
+    LDADD_dbd_sqlite2="-lsqlite"
   fi
+  AC_SUBST(LDADD_dbd_sqlite2)
 ])
 dnl
 AC_DEFUN([APU_CHECK_DBD_ORACLE], [
@@ -294,8 +290,7 @@
         unset ac_cv_lib_clntsh_OCIEnvCreate
         AC_CHECK_LIB(clntsh, OCIEnvCreate, [
           apu_have_oracle=1
-          APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lnnz10])
-          APR_ADDTO(APRUTIL_LIBS,[-lnnz10])
+          LDADD_dbd_oracle="-lnnz10"
         ],,[-lnnz10])
       ]))
 
@@ -322,8 +317,7 @@
         unset ac_cv_lib_clntsh_OCIEnvCreate
         AC_CHECK_LIB(clntsh, OCIEnvCreate, [
           apu_have_oracle=1
-          APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lnnz10])
-          APR_ADDTO(APRUTIL_LIBS,[-lnnz10])
+          LDADD_dbd_oracle="-lnnz10"
         ],,[-lnnz10])
       ]))
       if test "$apu_have_oracle" != "0"; then
@@ -354,8 +348,7 @@
       unset ac_cv_lib_clntsh_OCIEnvCreate
       AC_CHECK_LIB(clntsh, OCIEnvCreate, [
         apu_have_oracle=1
-        APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lnnz10])
-        APR_ADDTO(APRUTIL_LIBS,[-lnnz10])
+        LDADD_dbd_oracle=-lnnz10
       ],,[-lnnz10])
     ]))
 
@@ -367,8 +360,39 @@
   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
   dnl we know the library is there.
   if test "$apu_have_oracle" = "1"; then
-    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lclntsh])
-    APR_ADDTO(APRUTIL_LIBS,[-lclntsh])
+    LDADD_dbd_oracle="$LDADD_dbd_oracle -lclntsh"
+  fi
+  AC_SUBST(LDADD_dbd_oracle)
+])
+
+AC_DEFUN([APU_CHECK_DBD_DSO], [
+
+  AC_ARG_ENABLE([dbd-dso], 
+     APR_HELP_STRING([--enable-dbd-dso], [build DBD drivers as DSOs]))
+
+  if test $enable_dbd_dso = yes; then
+     AC_DEFINE([APU_DSO_BUILD], 1, [Define if DBD drivers are built as DSOs])
+     
+     dsos=
+     test $apu_have_oracle = 1 && dsos="$dsos dbd/apr_dbd_oracle.la"
+     test $apu_have_pgsql = 1 && dsos="$dsos dbd/apr_dbd_pgsql.la"
+     test $apu_have_mysql = 1 && dsos="$dsos dbd/apr_dbd_mysql.la"
+     test $apu_have_sqlite2 = 1 && dsos="$dsos dbd/apr_dbd_sqlite2.la"
+     test $apu_have_sqlite3 = 1 && dsos="$dsos dbd/apr_dbd_sqlite3.la"
+
+     APU_MODULES="$APU_MODULES $dsos"
+  else
+     # Statically link the DBD drivers:
+
+     objs=
+     test $apu_have_oracle = 1 && objs="$objs dbd/apr_dbd_oracle.lo"
+     test $apu_have_pgsql = 1 && objs="$objs dbd/apr_dbd_pgsql.lo"
+     test $apu_have_mysql = 1 && objs="$objs dbd/apr_dbd_mysql.lo"
+     test $apu_have_sqlite2 = 1 && objs="$objs dbd/apr_dbd_sqlite2.lo"
+     test $apu_have_sqlite3 = 1 && objs="$objs dbd/apr_dbd_sqlite3.lo"
+     EXTRA_OBJECTS="$EXTRA_OBJECTS $objs"
+
+     APRUTIL_LIBS="$APRUTIL_LIBS '$(LDADD_dbd_pgsql) $(LDADD_dbd_sqlite2) $(LDADD_dbd_sqlite3)
$(LDADD_dbd_oracle) $(LDADD_dbd_mysql)'"
+     APRUTIL_EXPORT_LIBS="$APRUTIL_EXPORT_LIBS '$(LDADD_dbd_pgsql) $(LDADD_dbd_sqlite2) $(LDADD_dbd_sqlite3)
$(LDADD_dbd_oracle) $(LDADD_dbd_mysql)'"
   fi
 ])
-dnl

Modified: apr/apr-util/trunk/configure.in
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/configure.in?view=diff&rev=501380&r1=501379&r2=501380
==============================================================================
--- apr/apr-util/trunk/configure.in (original)
+++ apr/apr-util/trunk/configure.in Tue Jan 30 03:54:52 2007
@@ -141,6 +141,8 @@
 APU_CHECK_DBD_SQLITE3
 APU_CHECK_DBD_SQLITE2
 APU_CHECK_DBD_ORACLE
+dnl Enable DSO build; must be last:
+APU_CHECK_DBD_DSO
 APU_FIND_EXPAT
 APU_FIND_ICONV
 
@@ -168,6 +170,23 @@
 
 APRUTIL_LIBNAME="aprutil${libsuffix}"
 AC_SUBST(APRUTIL_LIBNAME)
+
+# Set up destination directory for DSOs.
+APU_DSO_LIBDIR="\${libdir}/apr-util-${APRUTIL_MAJOR_VERSION}"
+# Set APU_HAVE_MODULES appropriately for the Makefile
+if test -n "$APU_MODULES"; then 
+   APU_HAVE_MODULES=yes
+else
+   APU_HAVE_MODULES=no
+fi
+# Define expanded libdir for apu_config.h
+APR_EXPAND_VAR(abs_dso_libdir, $APU_DSO_LIBDIR)
+AC_DEFINE_UNQUOTED([APU_DSO_LIBDIR], ["$abs_dso_libdir"],
+                   [Define to be absolute path to DSO directory])
+AC_SUBST(APU_HAVE_MODULES)
+AC_SUBST(APU_DSO_LIBDIR)
+AC_SUBST(APU_MODULES)
+AC_SUBST(EXTRA_OBJECTS)
 
 dnl
 dnl Prep all the flags and stuff for compilation and export to other builds

Modified: apr/apr-util/trunk/dbd/apr_dbd.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd.c?view=diff&rev=501380&r1=501379&r2=501380
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd.c Tue Jan 30 03:54:52 2007
@@ -16,23 +16,23 @@
 
 #include <stdio.h>
 
+#include "apu_config.h"
 #include "apu.h"
+
 #include "apr_pools.h"
-#include "apr_dbd_internal.h"
-#include "apr_dbd.h"
-#include "apr_hash.h"
-#include "apr_thread_mutex.h"
 #include "apr_dso.h"
 #include "apr_strings.h"
+#include "apr_hash.h"
+#include "apr_thread_mutex.h"
+
+#include "apr_dbd_internal.h"
+#include "apr_dbd.h"
+#include "apu_version.h"
 
 static apr_hash_t *drivers = NULL;
 
 #define CLEANUP_CAST (apr_status_t (*)(void*))
 
-/* Once the autofoo supports building it for dynamic load, we can use
- * #define APR_DSO_BUILD APR_HAS_DSO
- */
-
 #if APR_HAS_THREADS
 static apr_thread_mutex_t* mutex = NULL;
 apr_status_t apr_dbd_mutex_lock()
@@ -52,7 +52,7 @@
 }
 #endif
 
-#ifndef APR_DSO_BUILD
+#ifndef APU_DSO_BUILD
 #define DRIVER_LOAD(name,driver,pool) \
     {   \
         extern const apr_dbd_driver_t driver; \
@@ -91,8 +91,8 @@
     /* This already registers a pool cleanup */
 #endif
 
-#ifndef APR_DSO_BUILD
-
+#ifndef APU_DSO_BUILD
+    /* Load statically-linked drivers: */
 #if APU_HAVE_MYSQL
     DRIVER_LOAD("mysql", apr_dbd_mysql_driver, pool);
 #endif
@@ -111,62 +111,67 @@
 #if APU_HAVE_SOME_OTHER_BACKEND
     DRIVER_LOAD("firebird", apr_dbd_other_driver, pool);
 #endif
-#endif /* APR_DSO_BUILD */
+#endif /* APU_DSO_BUILD */
+
     return ret;
 }
+
+#if defined(APR_DSO_BUILD) && APR_HAS_THREADS
+#define dbd_drivers_lock(m) apr_thread_mutex_lock(m)
+#define dbd_drivers_unlock(m) apr_thread_mutex_unlock(m)
+#else
+#define dbd_drivers_lock(m) APR_SUCCESS
+#define dbd_drivers_unlock(m) APR_SUCCESS
+#endif
+
 APU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name,
                                              const apr_dbd_driver_t **driver)
 {
-#if APR_DSO_BUILD
+#ifdef APR_DSO_BUILD
     char path[80];
     apr_dso_handle_t *dlhandle = NULL;
+    apr_dso_handle_sym_t symbol;
 #endif
     apr_status_t rv;
 
-   *driver = apr_hash_get(drivers, name, APR_HASH_KEY_STRING);
-    if (*driver) {
+    rv = dbd_drivers_lock(mutex);
+    if (rv) {
         return APR_SUCCESS;
     }
 
-#if APR_DSO_BUILD
-
-#if APR_HAS_THREADS
-    rv = apr_thread_mutex_lock(mutex);
-    if (rv != APR_SUCCESS) {
-        goto unlock;
-    }
-    *driver = apr_hash_get(drivers, name, APR_HASH_KEY_STRING);
+   *driver = apr_hash_get(drivers, name, APR_HASH_KEY_STRING);
     if (*driver) {
-        goto unlock;
+        dbd_drivers_unlock(mutex);
+        return APR_SUCCESS;
     }
-#endif
+
+#ifdef APR_DSO_BUILD
 
 #ifdef WIN32
     sprintf(path, "apr_dbd_%s.dll", name);
 #else
-    sprintf(path, "apr_dbd_%s.so", name);
+    apr_snprintf(path, sizeof path, APU_DSO_LIBDIR "/apr_dbd_%s.so", name);
 #endif
     rv = apr_dso_load(&dlhandle, path, pool);
     if (rv != APR_SUCCESS) { /* APR_EDSOOPEN */
         goto unlock;
     }
     sprintf(path, "apr_dbd_%s_driver", name);
-    rv = apr_dso_sym((void*)driver, dlhandle, path);
+    rv = apr_dso_sym(&symbol, dlhandle, path);
     if (rv != APR_SUCCESS) { /* APR_ESYMNOTFOUND */
         apr_dso_unload(dlhandle);
         goto unlock;
     }
+    *driver = symbol;
     if ((*driver)->init) {
         (*driver)->init(pool);
     }
     apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver);
 
 unlock:
-#if APR_HAS_THREADS
-    apr_thread_mutex_unlock(mutex);
-#endif
+    dbd_drivers_unlock(mutex);
 
-#else	/* APR_DSO_BUILD - so if it wasn't already loaded, it's NOTIMPL */
+#else /* not builtin and !APR_HAS_DSO => not implemented */
     rv = APR_ENOTIMPL;
 #endif
 



Mime
View raw message