#! /bin/sh /usr/share/dpatch/dpatch-run
## fix-bdb-version-detection.dpatch by <peter@p12n.org>
##
## DP: Do not rely on apu-config to print "-ldb4.3" or whatever - see #378105.
## DP: Instead, include -laprutil-1 in the compile line.
## DP:
## DP: I don't think this can be sent upstream, as it won't work when
## DP: compiling aprutil in-tree.  But I'm not certain.

@DPATCH@
--- a/build/ac-macros/berkeley-db.m4
+++ b/build/ac-macros/berkeley-db.m4
@@ -183,7 +183,7 @@
     SVN_DB_LIBS=["${SVN_DB_LIBS-`$apu_config --libs | $SED -e 's/.*\(-ldb[^[:space:]]*\).*/\1/' | $EGREP -- '-ldb[^[:space:]]*'`}"]
 
     CPPFLAGS="$SVN_DB_INCLUDES $SVN_APRUTIL_INCLUDES $CPPFLAGS" 
-    LIBS="`$apu_config --ldflags` $SVN_DB_LIBS $LIBS"
+    LIBS="`$apu_config --ldflags --link-ld` $SVN_DB_LIBS $LIBS"
 
     if test -n "$svn_berkeley_db_header"; then
       SVN_DB_HEADER="#include <$svn_berkeley_db_header>"
