diff -u --recursive netatalk-2.0.4-vanilla/bin/uniconv/Makefile.am netatalk-2.0.4/bin/uniconv/Makefile.am
--- netatalk-2.0.4-vanilla/bin/uniconv/Makefile.am	2009-06-23 09:59:44.000000000 -0400
+++ netatalk-2.0.4/bin/uniconv/Makefile.am	2009-06-24 10:44:00.000000000 -0400
@@ -6,3 +6,9 @@
 
 uniconv_SOURCES = uniconv.c iso8859_1_adapted.c
 uniconv_LDADD = $(top_builddir)/libatalk/cnid/libcnid.la $(top_builddir)/libatalk/libatalk.la
+
+LIBS = @LIBS@ @BDB_LIBS@
+
+CFLAGS = @CFLAGS@ @BDB_CFLAGS@
+
+
diff -u --recursive netatalk-2.0.4-vanilla/etc/afpd/Makefile.am netatalk-2.0.4/etc/afpd/Makefile.am
--- netatalk-2.0.4-vanilla/etc/afpd/Makefile.am	2009-06-23 09:59:44.000000000 -0400
+++ netatalk-2.0.4/etc/afpd/Makefile.am	2009-06-24 18:21:53.000000000 -0400
@@ -17,7 +17,7 @@
 	 filedir.h fork.h globals.h icon.h mangle.h misc.h status.h switch.h \
 	 uam_auth.h uid.h unix.h volume.h
 
-LIBS = @LIBS@ @QUOTA_LIBS@ @SLP_LIBS@ @WRAP_LIBS@ @LIBADD_DL@
+LIBS = @LIBS@ @QUOTA_LIBS@ @SLP_LIBS@ @WRAP_LIBS@ @LIBADD_DL@ @BDB_LIBS@
 
 CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/sys \
 	 @CFLAGS@ @SLP_CFLAGS@ \
@@ -27,4 +27,5 @@
 	 -D_PATH_AFPDCONF=\"$(pkgconfdir)/afpd.conf\" \
 	 -D_PATH_AFPDUAMPATH=\"$(UAMS_PATH)/\" \
 	 -DAPPLCNAME \
-	 -DSERVERTEXT=\"$(SERVERTEXT)/\"
+	 -DSERVERTEXT=\"$(SERVERTEXT)/\" \
+         @BDB_CFLAGS@
diff -u --recursive netatalk-2.0.4-vanilla/macros/db3-check.m4 netatalk-2.0.4/macros/db3-check.m4
--- netatalk-2.0.4-vanilla/macros/db3-check.m4	2009-06-23 09:59:43.000000000 -0400
+++ netatalk-2.0.4/macros/db3-check.m4	2009-06-23 10:14:44.000000000 -0400
@@ -25,44 +25,49 @@
 dnl -- Try to link and run with lib with version taken from
 dnl -- $atalk_cv_bdb_MAJOR and $atalk_cv_bdb_MINOR
 AC_DEFUN([NETATALK_BDB_TRY_LINK],[
-    atalk_cv_bdb_version=no
-    maj=$atalk_cv_bdb_MAJOR
-    min=$atalk_cv_bdb_MINOR
-    atalk_cv_bdb_try_libs="-ldb$maj$min -ldb$maj.$min -ldb-$maj$min -ldb-$maj.$min"
-
-    for lib in $atalk_cv_bdb_try_libs ; do
-        LIBS="$lib $savedlibs"
-        AC_MSG_CHECKING([Berkeley DB library ($lib)])
-        AC_TRY_RUN([
-            #include <stdio.h>
-            #include <db.h>
-            int main(void) {
-                int major, minor, patch;
-                char *version_str;
-                version_str = db_version(&major, &minor, &patch);
-                if (major < DB_MAJOR_REQ || minor < DB_MINOR_REQ || patch < DB_PATCH_REQ) {
-                    printf("linking wrong library version (%d.%d.%d), ",major, minor, patch);
-                    return (2);
-                }
-                if ( major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR || patch != DB_VERSION_PATCH) {
-                    printf("header/library version mismatch (%d.%d.%d/%d.%d.%d), ",
-                        DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, major, minor, patch);
-                    return (3);
-                }
-                printf("%d.%d.%d ... ",major, minor, patch);
-                return (0);
-            }
-        ],[
-
-            AC_MSG_RESULT(yes)
-            atalk_cv_bdb_version="yes"
-            atalk_cv_lib_db="$lib"
-            break
-        ],[
-            AC_MSG_RESULT(no)
-        ])
-    done
-    LIBS="$savedlibs"
+    if test "${atalk_cv_bdb_version+set}" = set \
+            -a "${atalk_cv_lib_db+set}" = set; then
+        :
+    else
+        atalk_cv_bdb_version=no
+        maj=$atalk_cv_bdb_MAJOR
+        min=$atalk_cv_bdb_MINOR
+        atalk_cv_bdb_try_libs="-ldb$maj$min -ldb$maj.$min -ldb-$maj$min -ldb-$maj.$min"
+
+        for lib in $atalk_cv_bdb_try_libs ; do
+            LIBS="$lib $savedlibs"
+            AC_MSG_CHECKING([Berkeley DB library ($lib)])
+            AC_TRY_RUN([
+                #include <stdio.h>
+                #include <db.h>
+                int main(void) {
+                     int major, minor, patch;
+                     char *version_str;
+                     version_str = db_version(&major, &minor, &patch);
+                     if (major < DB_MAJOR_REQ || minor < DB_MINOR_REQ || patch < DB_PATCH_REQ) {
+                         printf("linking wrong library version (%d.%d.%d), ",major, minor, patch);
+                         return (2);
+                     }
+                     if ( major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR || patch != DB_VERSION_PATCH) {
+                         printf("header/library version mismatch (%d.%d.%d/%d.%d.%d), ",
+                             DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, major, minor, patch);
+                         return (3);
+                     }
+                     printf("%d.%d.%d ... ",major, minor, patch);
+                     return (0);
+                 }
+             ],[
+
+                 AC_MSG_RESULT(yes)
+                 atalk_cv_bdb_version="yes"
+                 atalk_cv_lib_db="$lib"
+                 break
+             ],[
+                 AC_MSG_RESULT(no)
+             ])
+         done
+         LIBS="$savedlibs"
+    fi
 ])
 
 dnl -- This is called from configure
