--- avahi-0.6.12-orig/configure.ac	2006-07-22 13:39:40.000000000 +0100
+++ avahi-0.6.12/configure.ac	2006-08-04 09:32:17.573397000 +0100
@@ -481,6 +481,18 @@
 #
 # GDBM
 #
+#
+# Check for dbm
+#
+AC_ARG_ENABLE(dbm,
+        AS_HELP_STRING([--disable-dbm],[Disable use of DBM]),
+        [case "${enableval}" in
+                yes) HAVE_DBM=yes ;;
+                no)  HAVE_DBM=no ;;
+                *) AC_MSG_ERROR(bad value ${enableval} for --enable-dbm) ;;
+        esac],
+        [HAVE_DBM=no]) 
+
 AC_ARG_ENABLE(gdbm,
         AS_HELP_STRING([--disable-gdbm],[Disable use of GDBM]),
         [case "${enableval}" in
@@ -491,14 +503,27 @@
         [HAVE_GDBM=yes]) 
 
 if test "x$HAVE_GDBM" = "xyes" ; then
+    if test "x$HAVE_DBM" = "xyes" ; then
+        AC_MSG_ERROR([*** enable-gdbm and enable-dbm both specified ***])
+    fi
     AC_CHECK_LIB(gdbm, gdbm_open, [ AC_CHECK_HEADERS(gdbm.h, have_gdbm=true, have_gdbm=false) ], have_gdbm=false)
 
     if ! $have_gdbm ; then
         AC_MSG_ERROR([*** libgdbm not found ***])
     fi
     AC_DEFINE([HAVE_GDBM],[],[Support for GDBM])
+else
+    if test "x$HAVE_DBM" = "xyes" ; then
+        AC_CHECK_HEADERS(ndbm.h, have_dbm=true, have_dbm=false)
+
+        if ! $have_dbm ; then
+            AC_MSG_ERROR([*** dbm not found ***])
+        fi
+        AC_DEFINE([HAVE_DBM],[],[Support for DBM])
+    fi
 fi
 AM_CONDITIONAL(HAVE_GDBM, test "x$HAVE_GDBM" = "xyes")
+AM_CONDITIONAL(HAVE_DBM, test "x$HAVE_DBM" = "xyes")
 
 #
 # libdaemon
@@ -568,6 +593,9 @@
         if test "x$HAVE_GDBM" = "xyes"; then
             AM_CHECK_PYMOD(gdbm,,,[AC_MSG_ERROR(Could not find Python module gdbm)])
         fi
+        if test "x$HAVE_DBM" = "xyes"; then
+            AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)])
+        fi
     fi
 fi
 AM_CONDITIONAL(HAVE_PYTHON, [test "x$HAVE_PYTHON" = "xyes" ])
@@ -818,6 +846,7 @@
     Enable D-BUS:           ${HAVE_DBUS}
     Enable Expat:           ${HAVE_EXPAT}
     Enable GDBM:            ${HAVE_GDBM}
+    Enable DBM:             ${HAVE_DBM}
     Enable libdaemon:       ${HAVE_LIBDAEMON}
     Enable Python:          ${HAVE_PYTHON}
     Enable pygtk:           ${HAVE_PYGTK}
--- avahi-0.6.12-orig/avahi-utils/Makefile.am	2005-11-16 22:36:56.000000000 +0000
+++ avahi-0.6.12/avahi-utils/Makefile.am	2006-08-04 09:44:17.716538000 +0100
@@ -36,6 +36,11 @@
 avahi_browse_LDADD += -lgdbm
 endif
 
+if HAVE_DBM
+avahi_browse_SOURCES += stdb.h stdb.c
+avahi_browse_CFLAGS += -DDATABASE_FILE=\"$(pkgdatadir)/service-types.db\"
+endif
+
 avahi_resolve_SOURCES = avahi-resolve.c sigint.c sigint.h
 avahi_resolve_CFLAGS = $(AM_CFLAGS)
 avahi_resolve_LDADD = $(AM_LDADD) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la
--- avahi-0.6.12-orig/avahi-utils/stdb.c	2005-10-27 23:50:08.000000000 +0100
+++ avahi-0.6.12/avahi-utils/stdb.c	2006-08-04 10:02:31.753517000 +0100
@@ -19,7 +19,14 @@
   USA.
 ***/
 
+#include <config.h>
+#ifdef HAVE_GDBM
 #include <gdbm.h>
+#endif
+#ifdef HAVE_DBM
+#include <ndbm.h>
+#include <fcntl.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <locale.h>
@@ -29,16 +36,30 @@
 
 #include "stdb.h"
 
+#ifdef HAVE_GDBM
 static GDBM_FILE gdbm_file = NULL;
+#endif
+#ifdef HAVE_DBM
+static DBM *dbm_file = NULL;
+#endif
 static char *buffer = NULL;
 
 static int init(void) {
 
+#ifdef HAVE_GDBM
     if (gdbm_file)
         return 0;
 
     if (!(gdbm_file = gdbm_open((char*) DATABASE_FILE, 0, GDBM_READER, 0, NULL)))
         return -1;
+#endif
+#ifdef HAVE_DBM
+    if (dbm_file)
+        return 0;
+
+    if (!(dbm_file = dbm_open((char*) DATABASE_FILE, O_RDONLY, 0)))
+        return -1;
+#endif
 
     return 0;
 }
@@ -59,7 +80,12 @@
         snprintf(k, sizeof(k), "%s[%s]", name, loc);
         key.dptr = k;
         key.dsize = strlen(k);
+#ifdef HAVE_GDBM
         data = gdbm_fetch(gdbm_file, key);
+#endif
+#ifdef HAVE_DBM
+        data = dbm_fetch(dbm_file, key);
+#endif
 
         if (!data.dptr) {
             char l[32], *e;
@@ -70,7 +96,12 @@
                 snprintf(k, sizeof(k), "%s[%s]", name, l);
                 key.dptr = k;
                 key.dsize = strlen(k);
+#ifdef HAVE_GDBM
                 data = gdbm_fetch(gdbm_file, key);
+#endif
+#ifdef HAVE_DBM
+                data = dbm_fetch(dbm_file, key);
+#endif
             }
 
             if (!data.dptr) {
@@ -79,7 +110,12 @@
                     snprintf(k, sizeof(k), "%s[%s]", name, l);
                     key.dptr = k;
                     key.dsize = strlen(k);
+#ifdef HAVE_GDBM
                     data = gdbm_fetch(gdbm_file, key);
+#endif
+#ifdef HAVE_DBM
+                    data = dbm_fetch(dbm_file, key);
+#endif
                 }
             }
         }
@@ -88,7 +124,12 @@
     if (!data.dptr) {
         key.dptr = (char*) name;
         key.dsize = strlen(name);
+#ifdef HAVE_GDBM
         data = gdbm_fetch(gdbm_file, key);
+#endif
+#ifdef HAVE_DBM
+        data = dbm_fetch(dbm_file, key);
+#endif
     }
 
     if (!data.dptr)
@@ -106,8 +147,14 @@
 }
 
 void stdb_shutdown(void) {
+#ifdef HAVE_GDBM
     if (gdbm_file)
         gdbm_close(gdbm_file);
+#endif
+#ifdef HAVE_DBM
+    if (dbm_file)
+        dbm_close(dbm_file);
+#endif
 
     avahi_free(buffer);
 }
--- avahi-0.6.12-orig/avahi-utils/avahi-resolve.c	2005-11-16 22:34:54.000000000 +0000
+++ avahi-0.6.12/avahi-utils/avahi-resolve.c	2006-08-04 09:55:37.438919000 +0100
@@ -43,7 +43,7 @@
 
 #include "sigint.h"
 
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
 #include "stdb.h"
 #endif
 
--- avahi-0.6.12-orig/avahi-utils/avahi-browse.c	2006-07-09 22:32:15.000000000 +0100
+++ avahi-0.6.12/avahi-utils/avahi-browse.c	2006-08-04 09:57:22.562292000 +0100
@@ -43,7 +43,7 @@
 
 #include "sigint.h"
 
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
 #include "stdb.h"
 #endif
 
@@ -65,7 +65,7 @@
     Command command;
     int resolve;
     int no_fail;
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
     int no_db_lookup;
 #endif
 } Config;
@@ -138,7 +138,7 @@
 static void print_service_line(Config *config, char c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain) {
     char ifname[IF_NAMESIZE];
 
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
     if (!config->no_db_lookup)
         type = stdb_lookup(type);
 #endif
@@ -596,7 +596,7 @@
             "    -l --ignore-local    Ignore local services\n"
             "    -r --resolve         Resolve services found\n"
             "    -f --no-fail         Don't fail if the daemon is not available\n"
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
             "    -k --no-db-lookup    Don't lookup service types\n"
 #endif
             );
@@ -617,7 +617,7 @@
         { "ignore-local",   no_argument,       NULL, 'l' },
         { "resolve",        no_argument,       NULL, 'r' },
         { "no-fail",        no_argument,       NULL, 'f' },
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
         { "no-db-lookup",   no_argument,       NULL, 'k' },
 #endif
         { NULL, 0, NULL, 0 }
@@ -634,13 +634,13 @@
         c->no_fail = 0;
     c->domain = c->stype = NULL;
 
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
     c->no_db_lookup = 0;
 #endif
     
     opterr = 0;
     while ((o = getopt_long(argc, argv, "hVd:avtclrDf"
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
                             "k"
 #endif
                             , long_options, NULL)) >= 0) {
@@ -680,7 +680,7 @@
             case 'f':
                 c->no_fail = 1;
                 break;
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
             case 'k':
                 c->no_db_lookup = 1;
                 break;
@@ -783,7 +783,7 @@
 
     avahi_string_list_free(browsed_types);
 
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
     stdb_shutdown();
 #endif    
 
--- avahi-0.6.12-orig/service-type-database/Makefile.am	2006-05-04 20:41:05.000000000 +0100
+++ avahi-0.6.12/service-type-database/Makefile.am	2006-08-04 11:09:13.285810000 +0100
@@ -28,7 +28,8 @@
 pkgdata_DATA+=service-types.db
 
 build-db: build-db.in
-	sed -e 's,@PYTHON\@,$(PYTHON),g' $< > $@
+	sed -e 's,@PYTHON\@,$(PYTHON),g' \
+	    -e 's,@DBM\@,gdbm,g' $< > $@
 	chmod +x $@
 
 service-types.db: service-types build-db
@@ -37,4 +38,20 @@
 CLEANFILES = service-types.db build-db
 
 endif
+if HAVE_DBM
+
+noinst_SCRIPTS=build-db
+pkgdata_DATA+=service-types.db.*
+
+build-db: build-db.in
+	sed -e 's,@PYTHON\@,$(PYTHON),g' \
+	    -e 's,@DBM\@,dbm,g' $< > $@
+	chmod +x $@
+
+service-types.db: service-types build-db
+	$(PYTHON) build-db $(srcdir)/$< $@
+
+CLEANFILES = service-types.db* build-db
+
+endif
 endif
--- avahi-0.6.12-orig/service-type-database/build-db.in	2005-09-25 21:34:48.000000000 +0100
+++ avahi-0.6.12/service-type-database/build-db.in	2006-08-04 10:38:08.085049000 +0100
@@ -19,7 +19,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
-import gdbm, sys
+import @DBM@, sys
 
 if len(sys.argv) > 1:
     infn = sys.argv[1]
@@ -31,7 +31,7 @@
 else:
     outfn = infn + ".db"
 
-db = gdbm.open(outfn, "n")
+db = @DBM@.open(outfn, "n")
 
 for ln in file(infn, "r"):
     ln = ln.strip(" \r\n\t")
--- avahi-0.6.12-orig/avahi-python/avahi/Makefile.am	2005-11-15 00:40:25.000000000 +0000
+++ avahi-0.6.12/avahi-python/avahi/Makefile.am	2006-08-04 10:58:04.827262000 +0100
@@ -25,10 +25,27 @@
 
 avahi_SCRIPTS = ServiceTypeDatabase.py
 
+if HAVE_GDBM
 ServiceTypeDatabase.py: ServiceTypeDatabase.py.in
 	sed -e 's,@PYTHON\@,$(PYTHON),g' \
+		-e 's,@DBM\@,gdbm,g' \
+		-e 's,@FIRST_KEY\@,key = self.db.firstkey(),g' \
+		-e 's,@CHECK_KEY\@,while key is not None:,g' \
+		-e 's,@NEXT_KEY\@,key = self.db.nextkey(),g' \
 		-e 's,@pkgdatadir\@,$(pkgdatadir),g' $< > $@
 	chmod +x $@
+endif
+
+if HAVE_DBM
+ServiceTypeDatabase.py: ServiceTypeDatabase.py.in
+	sed -e 's,@PYTHON\@,$(PYTHON),g' \
+		-e 's,@DBM\@,dbm,g' \
+		-e 's,@FIRST_KEY\@,keys = self.db.keys(),g' \
+		-e 's,@CHECK_KEY\@,for key in keys:,g' \
+		-e 's,@NEXT_KEY\@,,g' \
+		-e 's,@pkgdatadir\@,$(pkgdatadir),g' $< > $@
+	chmod +x $@
+endif
 
 if HAVE_PYGTK
 if HAVE_PYTHON_DBUS
--- avahi-0.6.12-orig/avahi-python/avahi/ServiceTypeDatabase.py.in	2006-04-22 13:57:42.000000000 +0100
+++ avahi-0.6.12/avahi-python/avahi/ServiceTypeDatabase.py.in	2006-08-04 10:50:14.094897000 +0100
@@ -19,7 +19,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
-import gdbm
+import @DBM@
 import locale
 import re
 
@@ -29,7 +29,7 @@
 
     def __init__(self, filename = "@pkgdatadir@/service-types.db"):
 
-        self.db = gdbm.open(filename, "r")
+        self.db = @DBM@.open(filename, "r")
 
         l = locale.getlocale(locale.LC_MESSAGES)
 
@@ -69,12 +69,12 @@
     def items(self):
 
         items = []
-        key = self.db.firstkey()
-        while key is not None:
+        @FIRST_KEY@
+        @CHECK_KEY@
             if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key) and not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key):
                 localized_service_name = self[key]
                 items.append((key, localized_service_name))
-            key = self.db.nextkey(key)
+            @NEXT_KEY@
         return items
 
     def has_key(self, key):
