pidl: fix formatting in idl.yp
[ira/wip.git] / source3 / configure.in
index f98091166639ee76bee268841b494ad789e4f134..7cfd3fb2d94cd1344920b57faee1d66abb791196 100644 (file)
@@ -24,32 +24,6 @@ m4_include(pkg.m4)
 
 AC_LIBREPLACE_CC_CHECKS
 
-AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc], [Enable external talloc [default=auto]])], 
-[ enable_external_libtalloc=$enableval ], [ enable_external_libtalloc=auto ])
-
-if test "x$enable_external_libtalloc" != xno
-then
-       PKG_CHECK_MODULES(TALLOC, talloc >= 1.3.0, 
-               [ enable_external_libtalloc=yes ],
-               [ if test x$enable_external_libtalloc = xyes; then
-                       AC_MSG_ERROR([Unable to find libtalloc])
-             else 
-                       enable_external_libtalloc=no
-                 fi
-               ])
-fi
-
-if test "x$enable_external_libtalloc" = xno
-then
-       m4_include(../lib/talloc/libtalloc.m4)
-fi
-
-LIBTALLOC_OBJ0=""
-for obj in ${TALLOC_OBJ}; do
-       LIBTALLOC_OBJ0="${LIBTALLOC_OBJ0} ${tallocdir}/${obj}"
-done
-AC_SUBST(LIBTALLOC_OBJ0)
-
 m4_include(../lib/tevent/libtevent.m4)
 
 LIBTEVENT_OBJ0=""
@@ -59,27 +33,9 @@ done
 AC_SUBST(LIBTEVENT_OBJ0)
 LIBS="${LIBS} ${TEVENT_LIBS}"
 
-# TODO: These should come from m4_include(lib/tdb/libtdb.m4)
-# but currently this fails: things have to get merged from s4.
-tdbdir="../lib/tdb"
-AC_SUBST(tdbdir)
-TDB_CFLAGS="-I${srcdir-.}/$tdbdir/include"
-AC_SUBST(TDB_CFLAGS)
-
-LIBTDB_OBJ0=""
-for o in common/tdb.o common/dump.o common/transaction.o common/error.o \
-            common/traverse.o common/freelist.o common/freelistcheck.o \
-                common/io.o common/lock.o common/open.o; 
-do 
-       LIBTDB_OBJ0="$LIBTDB_OBJ0 $tdbdir/$o"
-done
-
-AC_SUBST(LIBTDB_OBJ0)
 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/replace"
-SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TEVENT_CFLAGS}"
-SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/.."
@@ -140,6 +96,9 @@ AC_SUBST(EXTRA_BIN_PROGS)
 AC_SUBST(CIFSMOUNT_PROGS)
 AC_SUBST(INSTALL_CIFSMOUNT)
 AC_SUBST(UNINSTALL_CIFSMOUNT)
+AC_SUBST(CIFSUMOUNT_PROGS)
+AC_SUBST(INSTALL_CIFSUMOUNT)
+AC_SUBST(UNINSTALL_CIFSUMOUNT)
 AC_SUBST(CIFSUPCALL_PROGS)
 AC_SUBST(INSTALL_CIFSUPCALL)
 AC_SUBST(UNINSTALL_CIFSUPCALL)
@@ -178,7 +137,7 @@ if test x"$ac_cv_prog_gcc" = x"yes" ; then
            int main(void)
            {
                return 0;
-           }],[-Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
+           }],[$CFLAGS -Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_Wdeclaration_after_statement=yes,
            samba_cv_HAVE_Wdeclaration_after_statement=no,
            samba_cv_HAVE_Wdeclaration_after_statement=cross)
@@ -196,7 +155,7 @@ if test x"$ac_cv_prog_gcc" = x"yes" ; then
            int main(void)
            {
                return 0;
-           }],[-Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
+           }],[$CFLAGS -Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_Werror_implicit_function_declaration=yes,
            samba_cv_HAVE_Werror_implicit_function_declaration=no,
            samba_cv_HAVE_Werror_implicit_function_declaration=cross)
@@ -216,16 +175,6 @@ if test x"$ac_cv_prog_gcc" = x"yes" ; then
        fi
 fi
 
-AC_ARG_ENABLE(dmalloc, [AS_HELP_STRING([--enable-dmalloc], [Enable heap debugging [default=no]])])
-
-if test "x$enable_dmalloc" = xyes
-then
-       AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
-       AC_DEFINE(DMALLOC_FUNC_CHECK, 1,
-                  [Define to check invariants around some common functions])
-       LIBS="$LIBS -ldmalloc"  
-fi
-
 #################################################
 # check for a shared memory profiling support
 AC_MSG_CHECKING(whether to use profiling)
@@ -320,7 +269,7 @@ AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
   int main(void)
   {
        return 0;
-  }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
+  }],[$CFLAGS -Werror],[$CPPFLAGS],[$LDFLAGS],
   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
    Werror_FLAGS="-Werror"
@@ -331,7 +280,7 @@ AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
   int main(void)
   {
        return 0;
-  }],[-w2],[$CPPFLAGS],[$LDFLAGS],
+  }],[$CFLAGS -w2],[$CPPFLAGS],[$LDFLAGS],
   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
 if test x"$samba_cv_HAVE_w2" = x"yes"; then
    Werror_FLAGS="-w2"
@@ -342,7 +291,7 @@ AC_CACHE_CHECK([that the C compiler understands -errwarn],samba_cv_HAVE_errwarn,
    int main(void)
    {
        return 0;
-   }],[-errwarn=%all],[$CPPFLAGS],[$LDFLAGS],
+   }],[$CFLAGS -errwarn=%all],[$CPPFLAGS],[$LDFLAGS],
    samba_cv_HAVE_errwarn=yes,samba_cv_HAVE_errwarn=no,samba_cv_HAVE_errwarn=cross)])
 if test x"$samba_cv_HAVE_errwarn" = x"yes"; then
    Werror_FLAGS="-errwarn=%all"
@@ -438,7 +387,7 @@ dnl These are preferably build shared, and static if dlopen() is not available
 default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb vfs_smb_traffic_analyzer vfs_preopen"
 
 if test "x$developer" = xyes; then
-   default_static_modules="$default_static_modules rpc_rpcecho"
+   default_static_modules="$default_static_modules rpc_rpcecho pdb_ads"
    default_shared_modules="$default_shared_modules charset_weird perfcount_test"
 fi
 
@@ -673,6 +622,10 @@ exit(1);
         fi
       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
     ;;
+    *qnx*)
+        CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
+        AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
+        ;;
 
 esac
 
@@ -3804,7 +3757,7 @@ if test x"$with_ads_support" != x"no"; then
                        if (str) free (str); 
                        return 0;
                }
-               ],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+               ],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
                smb_krb5_cv_enctype_to_string_takes_krb5_context_arg=yes,
                smb_krb5_cv_enctype_to_string_takes_krb5_context_arg=no)])
 
@@ -3822,7 +3775,7 @@ if test x"$with_ads_support" != x"no"; then
                        krb5_enctype_to_string(1, buf, 256);
                        return 0;
                }
-               ],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+               ],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
                smb_krb5_cv_enctype_to_string_takes_size_t_arg=yes,
                smb_krb5_cv_enctype_to_string_takes_size_t_arg=no)])
 
@@ -4039,9 +3992,9 @@ AC_ARG_WITH(automount,
 CIFSMOUNT_PROGS=""
 INSTALL_CIFSMOUNT=""
 UNINSTALL_CIFSMOUNT=""
-AC_MSG_CHECKING(whether to build mount.cifs and umount.cifs)
+AC_MSG_CHECKING(whether to build mount.cifs)
 AC_ARG_WITH(cifsmount,
-[AS_HELP_STRING([--with-cifsmount], [Include mount.cifs and umount.cifs (Linux only) support (default=yes)])],
+[AS_HELP_STRING([--with-cifsmount], [Include mount.cifs (Linux only) support (default=yes)])],
 [ case "$withval" in
   no)
        AC_MSG_RESULT(no)
@@ -4050,8 +4003,8 @@ AC_ARG_WITH(cifsmount,
        case "$host_os" in
        *linux*)
                AC_MSG_RESULT(yes)
-               AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
-               CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
+               AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs])
+               CIFSMOUNT_PROGS="bin/mount.cifs"
                INSTALL_CIFSMOUNT="installcifsmount"
                UNINSTALL_CIFSMOUNT="uninstallcifsmount"
                ;;
@@ -4064,8 +4017,8 @@ AC_ARG_WITH(cifsmount,
 [ case "$host_os" in
   *linux*)
        AC_MSG_RESULT(yes)
-       AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
-       CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
+       AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs])
+       CIFSMOUNT_PROGS="bin/mount.cifs"
        INSTALL_CIFSMOUNT="installcifsmount"
        UNINSTALL_CIFSMOUNT="uninstallcifsmount"
        ;;
@@ -4075,6 +4028,34 @@ AC_ARG_WITH(cifsmount,
   esac ]
 )
 
+CIFSUMOUNT_PROGS=""
+INSTALL_CIFSUMOUNT=""
+UNINSTALL_CIFSUMOUNT=""
+AC_MSG_CHECKING(whether to build umount.cifs)
+AC_ARG_WITH(cifsumount,
+[AS_HELP_STRING([--with-cifsumount], [Include umount.cifs (Linux only) support (default=no)])],
+[ case "$withval" in
+  yes)
+       case "$host_os" in
+       *linux*)
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(WITH_CIFSUMOUNT,1,[Whether to build umount.cifs])
+               CIFSUMOUNT_PROGS="bin/umount.cifs"
+               INSTALL_CIFSUMOUNT="installcifsumount"
+               UNINSTALL_CIFSUMOUNT="uninstallcifsumount"
+               ;;
+       *)
+               AC_MSG_ERROR(not on a linux system!)
+               ;;
+       esac
+       ;;
+  *)
+       AC_MSG_RESULT(no)
+       ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)
+
 #################################################
 # check for cifs.upcall support
 AC_CHECK_HEADERS([keyutils.h], [HAVE_KEYUTILS_H=1], [HAVE_KEYUTILS_H=0])
@@ -4486,7 +4467,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_4A 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/../tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
     samba_cv_SYSQUOTA_FOUND=yes;
@@ -4501,7 +4482,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_4B 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/../tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
@@ -4517,7 +4498,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_3 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/../tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
@@ -4755,12 +4736,124 @@ LINK_LIBSMBCLIENT=STATIC
 #  TODO: for talloc and tdb (at least), these should
 #  be extracted from their respective source directories
 #
-SMB_LIBRARY(talloc, 1)
-SMB_LIBRARY(tdb, 1)
+AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc], [Enable external talloc [default=auto]])], 
+[ enable_external_libtalloc=$enableval ], [ enable_external_libtalloc=auto ])
+
+if test "x$enable_external_libtalloc" != xno
+then
+       PKG_CHECK_MODULES(LIBTALLOC, talloc >= 1.4.0, 
+               [ enable_external_libtalloc=yes ],
+               [ if test x$enable_external_libtalloc = xyes; then
+                       AC_MSG_ERROR([Unable to find libtalloc])
+             else 
+                       enable_external_libtalloc=no
+                 fi
+               ])
+fi
+
+if test "x$enable_external_libtalloc" = xno
+then
+       m4_include(../lib/talloc/libtalloc.m4)
+       LINK_LIBTALLOC=STATIC
+       SMB_LIBRARY(talloc, 1)
+       LIBTALLOC_OBJ0=""
+       for obj in ${TALLOC_OBJ}; do
+               LIBTALLOC_OBJ0="${LIBTALLOC_OBJ0} ${tallocdir}/${obj}"
+       done
+       SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}"
+       AC_SUBST(LIBTALLOC_OBJ0)
+
+       TALLOCTORT="bin/talloctort\$(EXEEXT)"
+       AC_SUBST(TALLOCTORT)
+fi
+
+
+AC_ARG_ENABLE(external_libtdb,
+       [AS_HELP_STRING([--enable-external-libtdb],
+               [Enable external tdb [default=auto]])],
+               [ enable_external_libtalloc=$enableval ],
+               [ enable_external_libtalloc=auto ])
+
+if test "x$enable_external_libtdb" != xno
+then
+       PKG_CHECK_MODULES(LIBTDB, tdb >= 1.1.4,
+               [ enable_external_libtdb=yes ],
+               [
+               if test x$enable_external_libtdb = xyes; then
+                       AC_MSG_ERROR([Unable to find libtdb])
+               else
+                       enable_external_libtdb=no
+               fi
+               ])
+fi
+
+AC_SUBST(LIBTDB_OBJ0)
+if test "x$enable_external_libtdb" = xno
+then
+       m4_include(../lib/tdb/libtdb.m4)
+       LINK_LIBTDB=STATIC
+       SMB_LIBRARY(tdb, 1)
+       LIBTDB_OBJ0=""
+       for obj in ${TDB_OBJ}; do
+               LIBTDB_OBJ0="${LIBTDB_OBJ0} ${tdbdir}/${obj}"
+       done
+       AC_SUBST(LIBTDB_OBJ0)
+       SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
+
+       TDBBACKUP="bin/tdbbackup\$(EXEEXT)"
+       AC_SUBST(TDBBACKUP)
+       TDBDUMP="bin/tdbdump\$(EXEEXT)"
+       AC_SUBST(TDBDUMP)
+       TDBTOOL="bin/tdbtool\$(EXEEXT)"
+       AC_SUBST(TDBTOOL)
+       TDBTORTURE="bin/tdbtorture\$(EXEEXT)"
+       AC_SUBST(TDBTORTURE)
+fi
+
+
+AC_ARG_ENABLE(external_liblua,
+       [AS_HELP_STRING([--enable-external-liblua],
+               [Enable external lua [default=auto]])],
+               [ enable_external_liblua=$enableval ],
+               [ enable_external_liblua=auto ])
+
+if test "x$enable_external_liblua" != xno
+then
+       PKG_CHECK_MODULES(LIBLUA, lua5.1 >= 5.1.4,
+               [ enable_external_liblua=yes ],
+               [
+               if test x$enable_external_liblua = xyes; then
+                       AC_MSG_ERROR([Unable to find liblua])
+               else
+                       enable_external_liblua=no
+               fi
+               ])
+fi
+
+AC_SUBST(LIBLUA_OBJ0)
+if test "x$enable_external_liblua" = xno
+then
+       LINK_LIBLUA=STATIC
+       SMB_LIBRARY(lua, 0)
+       LIBLUA_OBJ0="lua-5.1.4/src/lapi.o lua-5.1.4/src/lauxlib.o \
+               lua-5.1.4/src/lbaselib.o lua-5.1.4/src/lcode.o \
+               lua-5.1.4/src/ldblib.o lua-5.1.4/src/ldebug.o lua-5.1.4/src/ldo.o \
+               lua-5.1.4/src/ldump.o lua-5.1.4/src/lfunc.o lua-5.1.4/src/lgc.o \
+               lua-5.1.4/src/linit.o lua-5.1.4/src/liolib.o lua-5.1.4/src/llex.o \
+               lua-5.1.4/src/lmathlib.o lua-5.1.4/src/lmem.o \
+               lua-5.1.4/src/loadlib.o lua-5.1.4/src/lobject.o \
+               lua-5.1.4/src/lopcodes.o lua-5.1.4/src/loslib.o \
+               lua-5.1.4/src/lparser.o lua-5.1.4/src/lstate.o \
+               lua-5.1.4/src/lstring.o lua-5.1.4/src/lstrlib.o \
+               lua-5.1.4/src/ltable.o lua-5.1.4/src/ltablib.o lua-5.1.4/src/ltm.o \
+               lua-5.1.4/src/lundump.o lua-5.1.4/src/lvm.o \
+               lua-5.1.4/src/lzio.o lua-5.1.4/src/print.o"
+       AC_SUBST(LIBLUA_OBJ0)
+fi
+
 SMB_LIBRARY(netapi, 0)
 SMB_LIBRARY(smbclient, 0)
 SMB_LIBRARY(smbsharemodes, 0)
-SMB_LIBRARY(lua, 0)
 SMB_LIBRARY(addns, 0, no, [undefined API])
 
 
@@ -6050,7 +6143,6 @@ fi
 AC_ARG_ENABLE(avahi,
 [AS_HELP_STRING([--enable-avahi], [Enable Avahi support (default=auto)])])
 
-AC_SUBST(AVAHI_LIBS)
 if test x"$enable_avahi" != x"no"; then
     have_avahi_support=yes
 
@@ -6064,12 +6156,18 @@ if test x"$enable_avahi" != x"no"; then
        have_avahi_support=no
     fi
 
-    AC_CHECK_LIB_EXT(avahi-client, AVAHI_LIBS, avahi_client_new)
-    if test x"$ac_cv_lib_ext_avahi_client_avahi_client_new" != x"yes"; then
+    save_LIBS="$LIBS"
+    AC_CHECK_LIB(avahi-client, avahi_client_new)
+    AC_CHECK_LIB(avahi-common, avahi_strerror)
+    LIBS="$save_LIBS"
+
+    if test x"$ac_cv_lib_ext_avahi_client_avahi_client_new" != x"yes" -o \
+       x"$ac_cv_lib_ext_avahi_common_avahi_strerror" != x"yes" ; then
        have_avahi_support=no
     fi
 
     if test x"$have_avahi_support" = x"yes"; then
+        AC_SUBST(AVAHI_LIBS, "-lavahi-client -lavahi-common")
        AC_DEFINE(WITH_AVAHI_SUPPORT, 1,
                [Whether to enable avahi support])
        AC_SUBST(AVAHI_OBJ, "lib/avahi.o smbd/avahi_register.o")
@@ -6212,6 +6310,7 @@ fi
 
 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB,
                   [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
+SMB_MODULE(pdb_ads, passdb/pdb_ads.o \$(TLDAP_OBJ), "bin/ads.$SHLIBEXT", PDB)
 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
 SMB_MODULE(pdb_wbc_sam, passdb/pdb_wbc_sam.o, "bin/wbc_sam.$SHLIBEXT", PDB)
@@ -6458,6 +6557,16 @@ AC_ZLIB([ZLIB_OBJS=""], [
        CFLAGS="-I../lib/zlib $CFLAGS"
 ])
 
+AC_ARG_ENABLE(dmalloc, [AS_HELP_STRING([--enable-dmalloc], [Enable heap debugging [default=no]])])
+
+if test "x$enable_dmalloc" = xyes
+then
+       AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
+       AC_DEFINE(DMALLOC_FUNC_CHECK, 1,
+                  [Define to check invariants around some common functions])
+       LIBS="$LIBS -ldmalloc"
+fi
+
 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
 LIB_REMOVE_USR_LIB(LDFLAGS)
 LIB_REMOVE_USR_LIB(LIBS)