capture information in changelog about bugs that this upload should close
[debian/amanda] / configure.in
index 850c2ef104768f4d9758c5b1b5ee2b3b3076c642..a15742a6a5ce97e1f904bac18fc4006ecf030ca3 100644 (file)
@@ -1,4 +1,3 @@
-dnl Process this file with autoconf to produce a configure script.
 
 AC_INIT
 AC_CONFIG_SRCDIR([common-src/amanda.h])
@@ -14,10 +13,10 @@ AC_DEFINE_UNQUOTED(CONFIGURE_COMMAND,"$CONFIGURE_COMMAND",
          [Saves the original ./configure command line arguments])
 AC_SUBST(CONFIGURE_COMMAND)
 
-AM_INIT_AUTOMAKE(amanda, 2.4.4p3)
+AM_INIT_AUTOMAKE(amanda, 2.5.2p1)
 AM_CONFIG_HEADER(config/config.h)
 
-AC_PREREQ(2.57)                dnl Minimum Autoconf version required.
+AC_PREREQ(2.59)                dnl Minimum Autoconf version required.
 
 if test -f "$srcdir/SNAPSHOT"; then
   cat < "$srcdir/SNAPSHOT"
@@ -55,17 +54,120 @@ AC_SUBST(VERSION_COMMENT)
 AC_SUBST(VERSION_SUFFIX)
 
 dnl
-dnl runtime and compile time
+dnl runtime and compile time paths
 dnl
-SYSPATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd:/etc:/usr/etc"
+SYSPATH="/bin:/usr/bin:/sbin:/usr/sbin:/opt/SUNWspro/bin:/usr/ucb:/usr/bsd:/etc:/usr/etc"
 LOCPATH=`(
     test "x$prefix" = xNONE && prefix=$ac_default_prefix
     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
-    eval echo "$libexecdir:$PATH:/usr/local/sbin:/usr/local/bin"
+    eval echo "$libexecdir:$PATH:/usr/local/sbin:/usr/local/bin:/usr/ccs/bin"
 )`
 SYSLOCPATH="$SYSPATH:$LOCPATH"
 LOCSYSPATH="$LOCPATH:$SYSPATH"
 
+dnl
+dnl Set up compiler location, basic CFLAGS, and include locations
+dnl and library locations before we start checking the system
+dnl configuration in more detail...
+dnl
+
+AC_ARG_WITH(cflags,
+    [  --with-cflags=CFLAGS   arguments to the c compiler (-Wall, -g, etc)],
+    [
+       case "$withval" in
+       "" | y | ye | yes | n | no)
+           AC_MSG_ERROR([*** You must supply an argument to the --with-cflags option.])
+           ;;
+       esac
+       CFLAGS="$withval"
+    ])
+
+CFLAGS="-D_GNU_SOURCE $CFLAGS"
+
+AC_PROG_CC
+gl_EARLY
+gl_INIT
+AC_OBJEXT
+AC_EXEEXT
+AC_SYS_LARGEFILE
+
+dnl
+dnl Process tool locations for tools we need right away to configure.
+dnl
+AC_PATH_PROGS(GREP,grep,,$LOCSYSPATH)
+if test -z "$GREP"; then
+    GREP=grep
+fi
+AC_DEFINE_UNQUOTED(GREP,"$GREP",[Define the location of the grep program. ])
+AC_PATH_PROGS(EGREP,egrep,,$LOCSYSPATH)
+
+AC_PATH_PROGS(AMLINT,lint,,/opt/SUNWspro/bin:$SYSLOCPATH)
+if test ! -z "$AMLINT"; then
+  $AMLINT -flags | $GREP -- '-errfmt=' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AMLINTFLAGS="-n -s -u -m -x"
+    AMLINTFLAGS="$AMLINTFLAGS -errchk=%all"
+    AMLINTFLAGS="$AMLINTFLAGS -errfmt=macro"
+    AMLINTFLAGS="$AMLINTFLAGS -errhdr=no%/usr/include"
+    AMLINTFLAGS="$AMLINTFLAGS -errhdr=%user"
+    AMLINTFLAGS="$AMLINTFLAGS -errsecurity=extended"
+    AMLINTFLAGS="$AMLINTFLAGS -errtags=yes"
+    AMLINTFLAGS="$AMLINTFLAGS -Ncheck=%all"
+    AMLINTFLAGS="$AMLINTFLAGS -Nlevel=2"
+    AMLINTFLAGS="$AMLINTFLAGS -erroff=E_ASGN_NEVER_USED"
+    AMLINTFLAGS="$AMLINTFLAGS,E_ASGN_RESET"
+    AMLINTFLAGS="$AMLINTFLAGS,E_CAST_INT_CONST_TO_SMALL_INT"
+    AMLINTFLAGS="$AMLINTFLAGS,E_CAST_INT_TO_SMALL_INT"
+    AMLINTFLAGS="$AMLINTFLAGS,E_CAST_UINT_TO_SIGNED_INT"
+    AMLINTFLAGS="$AMLINTFLAGS,E_CONSTANT_CONDITION"
+    AMLINTFLAGS="$AMLINTFLAGS,E_ENUM_UNUSE"
+    AMLINTFLAGS="$AMLINTFLAGS,E_EXPR_NULL_EFFECT"
+    AMLINTFLAGS="$AMLINTFLAGS,E_FUNC_RET_ALWAYS_IGNOR"
+    AMLINTFLAGS="$AMLINTFLAGS,E_FUNC_RET_MAYBE_IGNORED"
+    AMLINTFLAGS="$AMLINTFLAGS,E_H_C_CHECK0"
+    AMLINTFLAGS="$AMLINTFLAGS,E_H_C_CHECK1"
+    AMLINTFLAGS="$AMLINTFLAGS,E_H_C_CHECK2"
+    AMLINTFLAGS="$AMLINTFLAGS,E_INCL_MNUSD"
+    AMLINTFLAGS="$AMLINTFLAGS,E_INCL_NUSD"
+    AMLINTFLAGS="$AMLINTFLAGS,E_MCR_NODIFF"
+    AMLINTFLAGS="$AMLINTFLAGS,E_NAME_MULTIPLY_DEF"
+    AMLINTFLAGS="$AMLINTFLAGS,E_P_REF_NULL_PSBL"
+    AMLINTFLAGS="$AMLINTFLAGS,E_P_REF_SUSP"
+    AMLINTFLAGS="$AMLINTFLAGS,E_PTRDIFF_OVERFLOW"
+    AMLINTFLAGS="$AMLINTFLAGS,E_P_USE_NULL_PSBL"
+    AMLINTFLAGS="$AMLINTFLAGS,E_P_USE_SUSP"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_ACCESS_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_CHDIR_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_CHMOD_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_CREAT_WITHOUT_EXCL"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_EXEC_PATH"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_EXEC_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_FOPEN_MODE"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_GETENV_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_MKDIR_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_PRINTF_VAR_FMT"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_RAND_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_SCANF_VAR_FMT"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_SELECT_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_SHELL_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_STRNCPY_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_UMASK_WARN"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SEC_USE_AFTER_STAT"
+    AMLINTFLAGS="$AMLINTFLAGS,E_SIGN_EXTENSION_PSBL"
+    AMLINTFLAGS="$AMLINTFLAGS,E_TYPEDEF_UNUSE"
+    AMLINTFLAGS="$AMLINTFLAGS,E_UNCAL_F"
+  else
+    AMLINTFLAGS=""
+  fi
+else
+  AC_PATH_PROGS(AMLINT,splint,,$SYSLOCPATH)
+  if test ! -z "$AMLINT"; then
+    AMLINT="splint"
+  fi
+  AMLINTFLAGS='+show-scan +unixlib -weak -globs +usedef +usereleased +impouts -paramimptemp -varuse -warnposix -redef -preproc -fixedformalarray -retval -unrecog -usevarargs -formatcode'
+fi
+AC_SUBST(AMLINTFLAGS)
+
 AC_ARG_WITH(includes,
     [  --with-includes=DIR    site header files for readline, etc in DIR],
     [
@@ -102,7 +204,7 @@ if test "$LIBRARY_DIRS"; then
        for dir in $LIBRARY_DIRS; do
            if test -d "$dir"; then
                case "$target" in
-                 *-solaris2*)
+                 *-solaris2*,*-netbsd*)
                        AMANDA_LDFLAGS="$AMANDA_LDFLAGS -R$dir"
                        ;;
                esac
@@ -113,8 +215,35 @@ if test "$LIBRARY_DIRS"; then
        done
 fi
 
+dnl
+dnl Process configuration flags
+dnl
+
+AC_ARG_WITH(dumperdir,
+    [  --with-dumperdir=DIR   where we install the dumpers [[EPREFIX/dumper]]],
+    [
+       case "$withval" in
+       "" | y | ye | yes | n | no)
+           AC_MSG_ERROR([*** You must supply an argument to the --with-dumperdir option.])
+         ;;
+       esac
+       DUMPER_DIR="$withval"
+    ], [
+        test "x$prefix" = xNONE && prefix=$ac_default_prefix
+        test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
+        DUMPER_DIR=$exec_prefix/dumper
+    ]
+)
+DUMPER_DIR=`(
+    test "x$prefix" = xNONE && prefix=$ac_default_prefix
+    test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
+    eval echo "$DUMPER_DIR"
+)`
+AC_DEFINE_UNQUOTED(DUMPER_DIR,"$DUMPER_DIR",[Directory in which dumper interfaces should be installed and searched. ])
+AC_SUBST(DUMPER_DIR)
+
 AC_ARG_WITH(configdir,
-    [  --with-configdir=DIR   runtime config files in DIR [sysconfdir/amanda]],
+    [  --with-configdir=DIR   runtime config files in DIR [[sysconfdir/amanda]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -124,7 +253,7 @@ AC_ARG_WITH(configdir,
          ;;
        esac
     ],
-    : ${CONFIG_DIR=$sysconfdir/amanda}
+    : ${CONFIG_DIR="$sysconfdir/amanda"}
 )
 CONFIG_DIR=`(
     test "x$prefix" = xNONE && prefix=$ac_default_prefix
@@ -162,7 +291,7 @@ y | ye | yes)
 
     program_suffix="-$VERSION"
     # This is from the output of configure.in.
-    if test "$program_transform_name" = s,x,x,; then
+    if test "x$program_transform_name" = xs,x,x,; then
        program_transform_name=
     else
        # Double any \ or $.  echo might interpret backslashes.
@@ -172,14 +301,14 @@ EOF_SED
        program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
        rm -f conftestsed
     fi
-    test "$program_prefix" != NONE &&
+    test "x$program_prefix" != xNONE &&
        program_transform_name="s,^,${program_prefix},; $program_transform_name"
     # Use a double $ so make ignores it.
-    test "$program_suffix" != NONE &&
+    test "x$program_suffix" != xNONE &&
        program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
 
     # sed with no file args requires a program.
-    test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+    test "x$program_transform_name" = "" && program_transform_name="xs,x,x,"
     # Remove empty command
     cat <<\EOF_SED > conftestsed
 s,\;\;,\;,g; s,\; \$,,g; s,\;$,,g
@@ -242,6 +371,9 @@ AC_ARG_WITH(server,
        esac
     ]
 )
+if test "x${NO_SERVER_MODE+set}" != xset ; then
+   NO_SERVER_MODE=false
+fi
 
 AC_ARG_WITH(restore,
     [  --without-restore      do not build amrestore nor amidxtaped],
@@ -255,6 +387,20 @@ AC_ARG_WITH(restore,
        esac
     ]
 )
+if test "x${NO_RESTORE_MODE+set}" != xset ; then
+   NO_RESTORE_MODE=${NO_SERVER_MODE-false}
+fi
+
+if ${NO_SERVER_MODE-false}; then
+   if ${NO_RESTORE_MODE-false}; then
+      dnl
+      dnl --without-server and --without-restore is OK
+      dnl
+      true
+   else
+      AC_MSG_ERROR([*** --without-server requires --without-restore])
+   fi
+fi
 
 AC_ARG_WITH(amrecover,
     [  --without-amrecover    do not build amrecover],
@@ -274,7 +420,7 @@ AC_ARG_WITH(amrecover,
 )
 
 AC_ARG_WITH(index-server,
-   [  --with-index-server=HOST default amanda index server [`uname -n`]],
+   [  --with-index-server=HOST default amanda index server [[`uname -n`]]],
    [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -305,7 +451,7 @@ n | no) :
 esac
 
 AC_ARG_WITH(user,
-    [  --with-user=USER       force execution to USER on client systems [required]],
+    [  --with-user=USER       force execution to USER on client systems [[required]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -324,7 +470,7 @@ AC_DEFINE_UNQUOTED(CLIENT_LOGIN,"$CLIENT_LOGIN",
 AC_SUBST(CLIENT_LOGIN)
 
 AC_ARG_WITH(group,
-    [  --with-group=GROUP     group allowed to execute setuid-root programs [required]],
+    [  --with-group=GROUP     group allowed to execute setuid-root programs [[required]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -341,7 +487,7 @@ fi
 AC_SUBST(SETUID_GROUP)
 
 AC_ARG_WITH(owner,
-    [  --with-owner=USER       force ownership of files to USER [default == --with-user value]],
+    [  --with-owner=USER       force ownership of files to USER [[default == --with-user value]]],
     [
         case "$withval" in
         "" | y | ye | yes | n | no)
@@ -370,7 +516,7 @@ AC_ARG_WITH(rundump,
 )
 
 AC_ARG_WITH(config,
-   [  --with-config=CONFIG   default configuration [DailySet1]],
+   [  --with-config=CONFIG   default configuration [[DailySet1]]],
    [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -387,7 +533,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_CONFIG,"$DEFAULT_CONFIG",
 AC_SUBST(DEFAULT_CONFIG)
 
 AC_ARG_WITH(tape-server,
-    [  --with-tape-server=HOST default restoring tape server is HOST [same as --with-index-server]],
+    [  --with-tape-server=HOST default restoring tape server is HOST [[same as --with-index-server]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -412,58 +558,17 @@ AC_ARG_WITH(tape-device,
        *) DEFAULT_TAPE_DEVICE="$withval"
          ;;
        esac
-    ],
-    [
-       if test -z "$DEFAULT_TAPE_DEVICE"; then
-           AC_MSG_CHECKING(for non-rewinding tape device)
-           dnl Check for the /dev/rmt directory and use what's in there.
-           dnl Otherwise look for tape devices in /dev.  For the devices
-           dnl in /dev/rmt, we want to use the Berkeley behavior of
-           dnl reading the first record of the next tape file after 0
-           dnl bytes are returned upon reading to the next tape mark,
-           dnl instead of returning an error.  Look for devices that have
-           dnl a 'b' in their name.
-           tape_dev=/dev/null
-           nr_tape_dev=/dev/null
-           if test -d /dev/rmt; then
-
-               dnl See if we can find two devices, one being the norewind
-               dnl version of the other.  Devices in this directory are
-               dnl normally a digit followed by some characters.  We also
-               dnl want the Berkely behavior, since Amanda needs it for
-               dnl amrestore.
-
-               for num in 9 8 7 6 5 4 3 2 1 0; do
-                   td=/dev/rmt/${num}b
-                   ntd=/dev/rmt/${num}bn
-                   if test -r $td -a -r $ntd; then
-                       tape_dev=$td
-                       nr_tape_dev=$ntd
-                   fi
-               done
-           else
-               dnl Look for tape devices in /dev.
-               for num in 9 8 7 6 5 4 3 2 1 0; do
-                   td=/dev/rst${num}
-                   ntd=/dev/nrst${num}
-                   if test -r $td -a -r $ntd; then
-                       tape_dev=$td
-                       nr_tape_dev=$ntd
-                   fi
-               done
-           fi
-           DEFAULT_TAPE_DEVICE=$nr_tape_dev
-           AC_MSG_RESULT($DEFAULT_TAPE_DEVICE)
-       fi
     ]
 )
 
-if test -z "$DEFAULT_TAPE_DEVICE"; then
-    DEFAULT_TAPE_DEVICE=/dev/null
+if test ! -z "$DEFAULT_TAPE_DEVICE"; then
+    AC_DEFINE_UNQUOTED(DEFAULT_TAPE_DEVICE,"$DEFAULT_TAPE_DEVICE",[This is the default no-rewinding tape device. ])
+    AC_SUBST(DEFAULT_TAPE_DEVICE)
+    EXAMPLE_TAPEDEV=$DEFAULT_TAPE_DEVICE
+else
+    EXAMPLE_TAPEDEV="/dev/null"
 fi
-
-AC_DEFINE_UNQUOTED(DEFAULT_TAPE_DEVICE,"$DEFAULT_TAPE_DEVICE",[This is the default no-rewinding tape device. ])
-AC_SUBST(DEFAULT_TAPE_DEVICE)
+AC_SUBST(EXAMPLE_TAPEDEV)
 
 AC_ARG_WITH(ftape-raw-device,
     [  --with-ftape-rawdevice=ARG raw device on tape server HOST's if using Linux ftape >=3.04d],
@@ -479,7 +584,7 @@ AC_ARG_WITH(ftape-raw-device,
     [
        if test -z "$DEFAULT_RAW_TAPE_DEVICE"; then
            AC_MSG_CHECKING(for raw ftape device)
-           dnl Look for tape devices in /dev.  
+           dnl Look for tape devices in /dev.
            raw_tape_dev=/dev/null
                dnl Look for tape devices in /dev.
                for num in 3 2 1 0 ; do
@@ -513,7 +618,7 @@ AC_ARG_WITH(norew-tape,
     ],)
 
 AC_ARG_WITH(changer-device,
-    [  --with-changer-device=ARG default tape changer device [/dev/ch0 if it exists]],
+    [  --with-changer-device=ARG default tape changer device [[/dev/ch0 if it exists]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -566,8 +671,31 @@ y |  ye | yes) AC_DEFINE(HAVE_BROKEN_FSF,1,[Define this if issuing a fsf on a ta
   ;;
 esac
 
+AC_ARG_WITH(reuseports,
+    [  --without-reuseaddr    Don't closed network connections to be reused until full timeout period.],
+    [ case "$withval" in
+        y | ye | yes)
+          REUSEADDR=no;;
+        n | no)
+          REUSEADDR=yes;;
+        *)
+          REUSEADDR=no;;
+      esac
+    ],
+    [ REUSEADDR=yes; ])
+case "$REUSEADDR" in
+n | no) :
+    ;;
+y |  ye | yes)
+    AC_DEFINE(USE_REUSEADDR,1,[Define to set SO_REUSEADDR on network connections.])
+    ;;
+*)
+    AC_MSG_ERROR([*** You must not supply an argument to --with-reuseports option.])
+    ;;
+esac
+
 AC_ARG_WITH(gnutar,
-    [  --with-gnutar[=PROG]     use PROG as GNU tar executable [default: looks for one]],
+    [  --with-gnutar[[=PROG]]      use PROG as GNU tar executable [[default: looks for one]]],
     [
        case "$withval" in
            /*) GNUTAR="$withval";;
@@ -578,28 +706,13 @@ AC_ARG_WITH(gnutar,
     ]
 )
 
-AC_ARG_WITH(qde,
-    [   --with-qde                use quick-and-dirty estimates for gnutar ],
-    USE_QUICK_AND_DIRTY_ESTIMATES=$withval,
-    : ${USE_QUICK_AND_DIRTY_ESTIMATES=no}
-)
-case "$USE_QUICK_AND_DIRTY_ESTIMATES" in
-n | no) : USE_QUICK_AND_DIRTY_ESTIMATES=no;;
-y |  ye | yes) : USE_QUICK_AND_DIRTY_ESTIMATES=yes
-       AC_DEFINE(USE_QUICK_AND_DIRTY_ESTIMATES,1,[ Define if you want to use amqde instead of gnutar for estimates ])
-  ;;
-*) AC_MSG_ERROR([*** You must not supply an argument to --with-qde option.])
-  ;;
-esac
-
-
 AC_ARG_WITH(smbclient,
-    [  --with-smbclient[=PROG]   use PROG as Samba's smbclient executable [default: looks for one]],
+    [  --with-smbclient[[=PROG]]   use PROG as Samba's smbclient executable [[default: looks for one]]],
     [
        case "$withval" in
            /*) SAMBA_CLIENT="$withval";;
            y|ye|yes) :;;
-           n|no) SAMBA_CLIENT="no";;
+           n|no) SAMBA_CLIENT=;;
            *)  AC_MSG_ERROR([*** You must supply a full pathname to --with-smbclient]);;
        esac
     ]
@@ -612,7 +725,7 @@ AC_ARG_WITH(samba-user,
 )
 
 AC_ARG_WITH(gnutar-listdir,
-   [  --with-gnutar-listdir=DIR  gnutar directory lists go in DIR [localstatedir/amanda/gnutar-lists]],
+   [  --with-gnutar-listdir=DIR  gnutar directory lists go in DIR [[localstatedir/amanda/gnutar-lists]]],
    [
        case "$withval" in
            n | no)             unset GNUTAR_LISTDIR ;;
@@ -621,7 +734,7 @@ AC_ARG_WITH(gnutar-listdir,
            *)                  AC_MSG_ERROR([*** You must supply a full pathname to --with-gnutar-listdir])
        esac
     ],
-    : ${GNUTAR_LISTDIR=$localstatedir/amanda/gnutar-lists}
+    : ${GNUTAR_LISTDIR="$localstatedir/amanda/gnutar-lists"}
 )
 if test "$GNUTAR_LISTDIR"; then
     GNUTAR_LISTDIR=`(
@@ -640,6 +753,8 @@ AC_ARG_WITH(gnutar-listed-incremental,
    [    AC_MSG_ERROR([*** The gnutar-listed-incremental option was deprecated, use gnutar-listdir instead])
    ]
 )
+GNUTAR_LISTED_INCREMENTAL_DIR=$GNUTAR_LISTDIR
+AC_SUBST(GNUTAR_LISTED_INCREMENTAL_DIR)
 
 AC_ARG_WITH(bsd-security,
     [  --without-bsd-security do not use BSD rsh/rlogin style security],
@@ -671,6 +786,48 @@ y |  ye | yes) :
   ;;
 esac
 
+dnl Specify --with-dbmalloc if you desire dbmalloc to be linked in
+
+AC_ARG_WITH(dbmalloc,
+    [  --with-dbmalloc=DIR  Location of dbmalloc libs and headers],
+    DBMALLOC="$withval",
+    : ${DBMALLOC=no}
+)
+
+case "$DBMALLOC" in
+n | no)
+    DBMALLOCCFLAGS=""
+    DBMALLOCLIBS=""
+    ;;
+*) 
+    AC_CHECK_LIB(dbmalloc,malloc)
+    if test "x$ac_cv_lib_dbmalloc_malloc" != "xyes"; then
+      AC_MSG_WARN([*** dbmalloc library not found - no malloc debugging support!])
+      DBMALLOCCFLAGS=""
+      DBMALLOCLIBS=""
+    else
+      DBMALLOCCFLAGS="-I$DBMALLOC -DUSE_DBMALLOC"
+      DBMALLOCLIBS="-L$DBMALLOC -ldbmalloc"
+    fi
+    ;;
+esac
+
+AC_ARG_WITH(ipv6,
+    AS_HELP_STRING([--with-ipv6],
+                  [If IPv6 must be enabled (Default)])
+AS_HELP_STRING([--without-ipv6],
+              [If IPv6 must be disable]),
+    [
+       case "$withval" in
+       y | ye | yes) amanda_ipv6=true;;
+       n | no) amanda_ipv6=false;;
+       *)
+           AC_MSG_ERROR([*** You must not supply an argument to --with-ipv6 option.])
+         ;;
+       esac
+    ]
+)
+
 dnl Specify --with-krb4-security if Kerberos software is in somewhere
 dnl other than the listed KRB4_SPOTS.  We only compile kerberos support in
 dnl if the right files are there.
@@ -678,7 +835,7 @@ dnl if the right files are there.
 : ${KRB4_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"}
 
 AC_ARG_WITH(krb4-security,
-    [  --with-krb4-security=DIR   Location of Kerberos software [/usr/kerberos /usr/cygnus /usr /opt/kerberos]],
+    [  --with-krb4-security=DIR   Location of Kerberos software [[/usr/kerberos /usr/cygnus /usr /opt/kerberos]]],
     KRB4_SECURITY="$withval",
     : ${KRB4_SECURITY=no}
 )
@@ -692,7 +849,7 @@ y | ye | yes) : ;;
 esac
 
 AC_MSG_CHECKING(for Kerberos and Amanda kerberos4 bits)
-if test "${KRB4_SECURITY}" = yes -a -f  ${srcdir-.}/common-src/krb4-security.c ; then
+if test "x${KRB4_SECURITY}" = xyes -a -f  ${srcdir-.}/common-src/krb4-security.c ; then
     for dir in $KRB4_SPOTS; do
        if test -f ${dir}/lib/libkrb.a -a -f ${dir}/lib/libdes.a ; then
            #
@@ -711,12 +868,9 @@ if test "${KRB4_SECURITY}" = yes -a -f  ${srcdir-.}/common-src/krb4-security.c ;
            fi
            KRB4LDFLAGS=-L$dir/lib
            KRB4LIBS="-lkrb -ldes"
-           if test -f ${dir}/lib/libcom_err.a ; then
+           if test -f ${dir}/lib/libcom_err.a; then
                KRB4LIBS="$KRB4LIBS -lcom_err"
            fi
-           if test -f ${dir}/lib/libroken.a ; then
-               KRB4LIBS="$KRB4LIBS -lroken"
-           fi
            break
        elif test -f ${dir}/lib/libkrb4.a &&
             test -f ${dir}/lib/libcrypto.a &&
@@ -736,36 +890,110 @@ if test "${KRB4_SECURITY}" = yes -a -f  ${srcdir-.}/common-src/krb4-security.c ;
                KRB4LIBS="-lkrb4 -lcrypto -ldes425"
            fi
            break
-       elif test -f ${dir}/lib/libkrb4.dylib &&
-            test -f ${dir}/lib/libcrypto.dylib &&
-            test -f ${dir}/lib/libdes425.dylib ; then
-           #
-           # This is Kerberos 5 with Kerberos 4 back-support for Mac OS X.
-           #
-           AC_MSG_RESULT(found in $dir)
-           KRB4_SECURITY=yes
-           AC_DEFINE(KRB4_SECURITY, 1, [Enable Kerberos security. ])
-           KRB4INCLUDES="-I$dir/include -I$dir/include/kerberosIV"
-           KRB4LDFLAGS=-L$dir/lib
-           if test -f ${dir}/lib/libkrb5.dylib &&
-               test -f ${dir}/lib/libcom_err.dylib; then
-               KRB4LIBS="-lkrb4 -lkrb5 -lcrypto -ldes425 -lcom_err"
-           else
-               KRB4LIBS="-lkrb4 -lcrypto -ldes425"
-           fi
-           break
        fi
     done
 
-    if test "$KRB4LDFLAGS" = "" ; then
-       AC_MSG_ERROR([*** Kerberos IV not found.])
+    if test "x$KRB4LDFLAGS" = "x" ; then
+       AC_MSG_RESULT(no libraries found)
     fi
 else
     AC_MSG_RESULT(no)
 fi
 
+AC_ARG_WITH(rsh-security,
+    [  --with-rsh-security use rsh as a transport],
+    RSH_SECURITY=$withval,
+    : ${RSH_SECURITY=yes}
+)
+case "$RSH_SECURITY" in
+n | no) : ;;
+y |  ye | yes) AC_DEFINE(RSH_SECURITY,1,[Define if RSH transport should be enabled. ])
+  ;;
+*) AC_MSG_ERROR([*** You must not supply an argument the to --with-rsh-security option.])
+  ;;
+esac
+
+AC_ARG_WITH(ssh-security,
+    [  --with-ssh-security use ssh as a transport],
+    SSH_SECURITY=$withval,
+    : ${SSH_SECURITY=no}
+)
+case "$SSH_SECURITY" in
+n | no) : ;;
+y |  ye | yes) AC_DEFINE(SSH_SECURITY,1,[Define if SSH transport should be enabled. ])
+              SSH_SECURITY_SET=true
+  ;;
+*) AC_MSG_ERROR([*** You must not supply an argument to --with-ssh-security.])
+  ;;
+esac
+
+# find SSH and check for SSH options if we're using SSH security
+if test x"$SSH_SECURITY" = "xyes"; then
+    AC_PATH_PROGS(SSH, ssh, , $LOCSYSPATH)
+    AC_DEFINE_UNQUOTED(SSH, "$SSH", [Path to the SSH binary])
+
+    AC_ARG_WITH(ssh-options,
+    AS_HELP_STRING([--with-ssh-options=@<:@OPTIONS@:>@],
+                  [Use these ssh options for ssh security; the default should work]),
+       [ SSH_OPTIONS="$withval" ],
+       [ SSH_OPTIONS='' ]
+    )
+
+    case "$SSH_OPTIONS" in
+       y | ye | yes | n | no)
+           AC_MSG_ERROR([*** You must supply an argument to --with-ssh-options.]);;
+       *) : ;;
+    esac
+
+    AC_MSG_CHECKING([SSH options])
+    # if we didn't get SSH options from the user, figure them out for ourselves
+    if test -z "$SSH_OPTIONS"; then
+       # TODO - quote these (or break them up in ssh-security??)
+       case `$SSH -V 2>&1` in
+           OpenSSH*) SSH_OPTIONS='-x -o BatchMode=yes -o PreferredAuthentications=publickey';;
+           *) SSH_OPTIONS='-x -o BatchMode=yes'
+       esac
+    fi
+
+    # now convert that to a comma-separated list of C strings
+    eval "set dummy ${SSH_OPTIONS}"; shift
+    SSH_OPTIONS=''
+    for i in "${@}"; do SSH_OPTIONS="${SSH_OPTIONS}${SSH_OPTIONS:+, }\"${i/\"/\\\"}\""; done
+    AC_MSG_RESULT($SSH_OPTIONS)
+
+    AC_DEFINE_UNQUOTED(SSH_OPTIONS, $SSH_OPTIONS, [Arguments to ssh])
+fi
+
+AC_ARG_WITH(bsdtcp-security,
+    [  --with-bsdtcp-security use tcp as a transport],
+    BSDTCP_SECURITY=$withval,
+    : ${BSDTCP_SECURITY=yes}
+)
+case "$BSDTCP_SECURITY" in
+n | no) : ;;
+y |  ye | yes) AC_DEFINE(BSDTCP_SECURITY,1,[Define if BSDTCP transport should be enabled. ])
+              BSDTCP_SECURITY_SET=true
+  ;;
+*) AC_MSG_ERROR([*** You must not supply an argument the to --with-bsdtcp-security option.])
+  ;;
+esac
+
+AC_ARG_WITH(bsdudp-security,
+    [  --with-bsdudp-security use udp as a transport],
+    BSDUDP_SECURITY=$withval,
+    : ${BSDUDP_SECURITY=yes}
+)
+case "$BSDUDP_SECURITY" in
+n | no) : ;;
+y |  ye | yes) AC_DEFINE(BSDUDP_SECURITY,1,[Define if BSDUDP transport should be enabled. ])
+              BSDUDP_SECURITY_SET=true
+  ;;
+*) AC_MSG_ERROR([*** You must not supply an argument the to --with-bsdudp-security option.])
+  ;;
+esac
+
 AC_ARG_WITH(server-principal,
-    [    --with-server-principal=ARG    server host principal  ["amanda"]],
+    [    --with-server-principal=ARG    server host principal  [["amanda"]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -781,7 +1009,7 @@ AC_ARG_WITH(server-principal,
 AC_DEFINE_UNQUOTED(SERVER_HOST_PRINCIPLE,"$SERVER_HOST_PRINCIPLE",[The Kerberos server principle. ])
 
 AC_ARG_WITH(server-instance,
-    [    --with-server-instance=ARG     server host instance   ["amanda"]],
+    [    --with-server-instance=ARG     server host instance   [["amanda"]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -796,7 +1024,7 @@ AC_ARG_WITH(server-instance,
 AC_DEFINE_UNQUOTED(SERVER_HOST_INSTANCE,"$SERVER_HOST_INSTANCE",[The Kerberos server instance. ])
 
 AC_ARG_WITH(server-keyfile,
-    [    --with-server-keyfile=ARG      server host key file   ["/.amanda"]],
+    [    --with-server-keyfile=ARG      server host key file   [["/.amanda"]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -811,7 +1039,7 @@ AC_ARG_WITH(server-keyfile,
 AC_DEFINE_UNQUOTED(SERVER_HOST_KEY_FILE,"$SERVER_HOST_KEY_FILE",[The Kerberos server key file. ])
 
 AC_ARG_WITH(client-principal,
-    [    --with-client-principal=ARG    client host principal  ["rcmd"]],
+    [    --with-client-principal=ARG    client host principal  [["rcmd"]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -826,7 +1054,7 @@ AC_ARG_WITH(client-principal,
 AC_DEFINE_UNQUOTED(CLIENT_HOST_PRINCIPLE,"$CLIENT_HOST_PRINCIPLE",[The Kerberos client host principle. ])
 
 AC_ARG_WITH(client-instance,
-    [    --with-client-instance=ARG     client host instance   [HOSTNAME_INSTANCE]],
+    [    --with-client-instance=ARG     client host instance   [[HOSTNAME_INSTANCE]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -841,7 +1069,7 @@ AC_ARG_WITH(client-instance,
 AC_DEFINE_UNQUOTED(CLIENT_HOST_INSTANCE,$CLIENT_HOST_INSTANCE,[The Kerberos client host instance. ])
 
 AC_ARG_WITH(client-keyfile,
-    [    --with-client-keyfile=ARG      client host key file   [KEYFILE]],
+    [    --with-client-keyfile=ARG      client host key file   [[KEYFILE]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -855,14 +1083,14 @@ AC_ARG_WITH(client-keyfile,
 )
 
 # Assume it's either KEYFILE (defined in krb.h), or a string filename...
-if test "$CLIENT_HOST_KEY_FILE" != "KEYFILE"; then
+if test "x$CLIENT_HOST_KEY_FILE" != "xKEYFILE"; then
   CLIENT_HOST_KEY_FILE="\"$CLIENT_HOST_KEY_FILE\""
 fi
 
 AC_DEFINE_UNQUOTED(CLIENT_HOST_KEY_FILE,$CLIENT_HOST_KEY_FILE,[The Kerberos client host key file. ])
 
 AC_ARG_WITH(ticket-lifetime,
-    [    --with-ticket-lifetime=ARG     ticket lifetime        [128]],
+    [    --with-ticket-lifetime=ARG     ticket lifetime        [[128]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -876,15 +1104,119 @@ AC_ARG_WITH(ticket-lifetime,
 )
 AC_DEFINE_UNQUOTED(TICKET_LIFETIME,$TICKET_LIFETIME,[The Kerberos ticket lifetime. ])
 
+dnl Specify --with-krb5-security if Kerberos software is in somewhere
+dnl other than the listed KRB5_SPOTS.  We only compile kerberos support in
+dnl if the right files are there.
+
+: ${KRB5_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"}
 
-AC_ARG_WITH(portrange,
-    [  --with-portrange=low,high     bind unreserved TCP server sockets to ports within this range [unlimited]],
+AC_ARG_WITH(krb5-security,
+    [  --with-krb5-security=DIR   Location of Kerberos V software [[/usr/kerberos /usr/cygnus /usr /opt/kerberos]]],
+    KRB5_SECURITY="$withval",
+    : ${KRB5_SECURITY=no}
+)
+
+case "$KRB5_SECURITY" in
+n | no) KRB5_SECURITY=no
+        KRB5_SPOTS=""
+       ;;
+y | ye | yes) : ;;
+*) KRB5_SPOTS="$KRB5_SECURITY"
+   KRB5_SECURITY=yes
+   ;;
+esac
+
+# if found, force the static versions of these libs (.a) by linking directly
+# with the .a files.  I don't know how to get -R dependancies checked
+# in autoconf at this time. -kashmir
+AC_MSG_CHECKING(for Kerberos V)
+KRB5_DIR_FOUND=""
+KRB5_CFLAGS=""
+for dir in $KRB5_SPOTS; do
+  for lib in lib lib64; do
+    k5libdir=${dir}/${lib}
+    if test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libgssapi_krb5.a -a -f ${k5libdir}/libcom_err.a; then
+       if test -f ${k5libdir}/libk5crypto.a; then
+           K5CRYPTO=-lk5crypto
+       elif test -f ${k5libdir}/libcrypto.a; then
+           K5CRYPTO=-lcrypto
+       else
+           K5CRYPTO=""
+       fi
+       if test -f ${k5libdir}/libkrb5support.a; then
+           K5SUPPORT=-lkrb5support
+       else
+           K5SUPPORT=""
+       fi
+       KRB5_DIR_FOUND=$dir
+       KRB5LIBS="-lgssapi_krb5 -lkrb5 $K5CRYPTO $K5SUPPORT -lcom_err"
+       KRB5CFLAGS=""
+       break
+    elif test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libasn1.a -a -f ${k5libdir}/libgssapi.a; then
+       KRB5_DIR_FOUND=$dir
+       KRB5LIBS="-lgssapi.a -lkrb5.a -lasn1.a"
+       KRB5_CFLAGS="-DKRB5_HEIMDAL_INCLUDES"
+       break
+    fi
+  done
+done
+
+if test "$KRB5_DIR_FOUND"; then
+       AC_MSG_RESULT(found in $KRB5_DIR_FOUND)
+       KRB5_SECURITY=yes
+       AC_DEFINE(KRB5_SECURITY,1,[Define if Kerberos 5 security is to be enabled. ])
+       #
+       # some OS's, such as NetBSD, stick krb5 includes out of the way...
+       # should probably just use autoconf to look for various include
+       # options and set them, but don't quite want to do that until I've
+       # dug into it a bit more.
+       #
+       if test -d "$KRB5_DIR_FOUND/krb5" ; then
+               KRB5INCLUDES="-I$KRB5_DIR_FOUND/include/krb5"
+       else
+               KRB5INCLUDES="-I$KRB5_DIR_FOUND/include"
+       fi
+       if test "$KRB5_CFLAGS" ; then
+               KRB5INCLUDES="$KRB5INCLUDES $KRB5_CFLAGS"
+       fi
+        AC_CHECK_LIB(krb5support,main)
+       KRB5LDFLAGS=-L$k5libdir
+       break
+fi
+
+if test "x$KRB5LDFLAGS" = "x" ; then
+    AC_MSG_RESULT(no krb5 system libraries found)
+fi
+
+
+AC_ARG_WITH(low-tcpportrange,
+    [  --with-low-tcpportrange=low,high     bind reserved TCP server sockets to ports within this range [unlimited] (mainly for amrecover)],
     [
-       TCPPORTRANGE="$withval"
+       LOW_TCPPORTRANGE="$withval"
     ]
 )
+if test x"${LOW_TCPPORTRANGE+set}" = x"set"; then
+    if test x`echo "$LOW_TCPPORTRANGE" | sed 's/[[0-9]][[0-9]]*,[[0-9]][[0-9]]*//'` != x""; then
+       AC_MSG_ERROR([*** --with-low-tcpportrange requires two comma-separated positive numbers])
+    fi
+    min_low_tcp_port=`echo "$LOW_TCPPORTRANGE" | sed 's/,.*//'`
+    max_low_tcp_port=`echo "$LOW_TCPPORTRANGE" | sed 's/.*,//'`
+    if test $min_low_tcp_port -gt $max_low_tcp_port; then
+       AC_MSG_ERROR([*** the second TCP port number must be greater than the first in --with-low-tcpportrange])
+    fi
+    if test $min_low_tcp_port -lt 512; then
+       AC_MSG_WARN([*** the low TCP port range should be 512 or greater in --with-low-tcpportrange])
+    fi
+    if test $max_low_tcp_port -ge 1024; then
+       AC_MSG_WARN([*** the low TCP port range should be less than 1024 in --with-low-tcpportrange])
+    fi
+    AC_DEFINE_UNQUOTED(LOW_TCPPORTRANGE,$LOW_TCPPORTRANGE,[A comma-separated list of two integers, determining the minimum and
+   maximum reserved TCP port numbers sockets should be bound to. (mainly for amrecover) ])
+fi
+
 AC_ARG_WITH(tcpportrange,
-    [  --with-tcpportrange=low,high  bind unreserved TCP server sockets to ports within this range [unlimited]],
+    [  --with-tcpportrange=low,high  bind unreserved TCP server sockets to ports within this range [[unlimited]]],
     [
        TCPPORTRANGE="$withval"
     ]
@@ -909,7 +1241,7 @@ if test x"${TCPPORTRANGE+set}" = x"set"; then
 fi
 
 AC_ARG_WITH(udpportrange,
-    [  --with-udpportrange=low,high  bind reserved UDP server sockets to ports within this range [unlimited]],
+    [  --with-udpportrange=low,high  bind reserved UDP server sockets to ports within this range [[unlimited]]],
     [
        UDPPORTRANGE="$withval"
     ]
@@ -945,7 +1277,7 @@ AC_DEFINE_UNQUOTED(MAX_TAPE_BLOCK_KB,($MAXTAPEBLOCKSIZE),[Maximum size of a tape
 AC_SUBST(MAXTAPEBLOCKSIZE)
 
 AC_ARG_WITH(db,
-    [  --with-db={text,db,dbm,gdbm,ndbm} use the selected database format [text]],
+    [  --with-db={text,db,dbm,gdbm,ndbm} use the selected database format [[text]]],
     [
        case "$withval" in
        "" | y | ye | yes | n | no)
@@ -1005,7 +1337,7 @@ y |  ye | yes) AC_DEFINE(ASSERTIONS,1,[Define if you want assertion checking. ])
 esac
 
 AC_ARG_WITH(tmpdir,
-    [  --with-tmpdir[=/temp/dir] area Amanda can use for temp files [/tmp/amanda]],
+    [  --with-tmpdir[=/temp/dir] area Amanda can use for temp files [[/tmp/amanda]]],
     tmpdir="$withval",
     : ${tmpdir=yes}
 )
@@ -1026,7 +1358,7 @@ AC_DEFINE_UNQUOTED(AMANDA_TMPDIR,"$AMANDA_TMPDIR",[The directory in which Amanda
 AC_SUBST(AMANDA_TMPDIR)
 
 AC_ARG_WITH(debugging,
-    [  --with[out]-debugging[=/debug/dir] [do not] record runtime debugging information in specified directory [--with-tmpdir]],
+    [  --with[[out]]-debugging[[=/debug/dir]] [[do not]] record runtime debugging information in specified directory [[--with-tmpdir]]],
     debugging="$withval",
     : ${debugging=yes}
 )
@@ -1037,8 +1369,8 @@ debugging=`(
 )`
 case "$debugging" in
 n | no) AMANDA_DBGDIR="";;
-y |  ye | yes) AMANDA_DBGDIR="$AMANDA_TMPDIR" ;;
-/*) AMANDA_DBGDIR="$debugging" ;;
+y |  ye | yes) AMANDA_DBGDIR="$AMANDA_TMPDIR";;
+/*) AMANDA_DBGDIR="$debugging";;
 *) AC_MSG_ERROR([*** You must supply a full pathname to --with-debugging option.])
   ;;
 esac
@@ -1050,7 +1382,7 @@ case "$AMANDA_DBGDIR" in
 esac
 
 AC_ARG_WITH(debug_days,
-    [  --with-debug-days=NN    number of days to keep debugging files [default=4]],
+    [  --with-debug-days=NN    number of days to keep debugging files [[default=4]]],
     debug_days="$withval",
     : ${debug_days=4}
 )
@@ -1065,7 +1397,7 @@ AC_DEFINE_UNQUOTED(AMANDA_DEBUG_DAYS,$AMANDA_DEBUG_DAYS,[Number of days to keep
 AC_SUBST(AMANDA_DEBUG_DAYS)
 
 AC_ARG_WITH(testing,
-    [  --with-testing[=suffix] use alternate service names],
+    [  --with-testing[[=suffix]] use alternate service names],
     TESTING="$withval",
     : ${TESTING=no}
 )
@@ -1099,10 +1431,6 @@ AC_DEFINE_UNQUOTED(KAMANDA_SERVICE_NAME, "$KAMANDA_SERVICE_NAME", [The name for
     AC_DEFINE_UNQUOTED(mandir,"$tmp",[Directory in which man-pages should be installed])
 )
 
-AC_PROG_CC
-AC_OBJEXT
-AC_EXEEXT
-
 dnl Set the order of dump programs to look for.  Finding the proper file
 dnl system dumping program is problematic.  Some systems, notably HP-UX
 dnl and AIX, have both the backup and dump programs.  HP-UX can't use the
@@ -1155,6 +1483,12 @@ case "$target" in
                        ;;
   *-pc-linux-*)
                        ;;
+  *-redhat-linux-*)
+                       ;;
+  *-suse-linux-*)
+                       ;;
+  x86_64-*-linux-*)
+                       ;;
   alpha*-*-linux-*)
                        ;;
   sparc*-*-linux-*)
@@ -1205,6 +1539,7 @@ case "$target" in
                        AC_DEFINE(DONT_SUID_ROOT,1,[Define on Cygwin. ])
                        NEED_SETUID_CLIENT=false
                        NEED_RUNTIME_PSEUDO_RELOC=true
+                       BROKEN_IPV6=true
                        ;;
   *)
                        cat <<END
@@ -1230,10 +1565,10 @@ if test -n "$xenix_tapeio"; then
   AC_DEFINE(XENIX_TAPEIO,1,[Define on XENIX/ISC. ])
 fi
 
-AMANDA_CFLAGS="$AMANDA_CFLAGS $KRB4INCLUDES"
-AMANDA_CPPFLAGS="$AMANDA_CPPFLAGS $KRB4INCLUDES"
-AMANDA_LDFLAGS="$AMANDA_LDFLAGS $KRB4LDFLAGS"
-AMANDA_LIBS="$KRB4LIBS $AMANDA_LIBS"
+AMANDA_CFLAGS="$AMANDA_CFLAGS $KRB4INCLUDES $KRB5INCLUDES $DBMALLOCCFLAGS"
+AMANDA_CPPFLAGS="$AMANDA_CPPFLAGS $KRB4INCLUDES $KRB5INCLUDES $DBMALLOCINCLUDES"
+AMANDA_LDFLAGS="$AMANDA_LDFLAGS $KRB4LDFLAGS $KRB5LDFLAGS"
+AMANDA_LIBS="$KRB4LIBS $KRB5LIBS $DBMALLOCLIBS $AMANDA_LIBS"
 CFLAGS="$CFLAGS $AMANDA_CFLAGS"
 CPPFLAGS="$CPPFLAGS $AMANDA_CPPFLAGS"
 LDFLAGS="$LDFLAGS $AMANDA_LDFLAGS"
@@ -1253,12 +1588,6 @@ dnl Check for programs.
 AC_PATH_PROGS(AR,ar,,$LOCSYSPATH)
 
 AC_PROG_AWK
-AMANDA_PROG_AWK_VAR
-if test "$amanda_cv_awk_var_assignment" = no; then
-    NO_AMPLOT_MODE=true
-    AC_MSG_WARN([*** Your $awk cannot do command line variable assignment.  Amplot will not be installed.])
-fi
-
 AC_PROG_YACC
 AC_PATH_PROGS(CAT,cat,,$LOCSYSPATH)
 if test -z "$CAT"; then
@@ -1266,20 +1595,28 @@ if test -z "$CAT"; then
 fi
 AC_PATH_PROGS(COMPRESS,compress,,$LOCSYSPATH)
 AC_PATH_PROGS(DD,dd,,$LOCSYSPATH)
-AC_PATH_PROGS(EGREP,egrep,,$LOCSYSPATH)
 AC_PATH_PROGS(GETCONF,getconf,,$SYSPATH)
 
-AC_PATH_PROGS(GNUPLOT,gnuplot,,$LOCSYSPATH)
-if test -z "$GNUPLOT"; then
-    NO_AMPLOT_MODE=true
-    AC_MSG_WARN([*** You do not have gnuplot.  Amplot will not be installed.])
-fi
+AC_ARG_WITH(gnuplot,
+AS_HELP_STRING([--with-gnuplot=PATH],
+               [use gnuplot executable at PATH in amplot]),
+    [ ac_with_gnuplot=$withval; ],
+    [ ac_with_gnuplot=maybe; ])
 
-AC_PATH_PROGS(GREP,grep,,$LOCSYSPATH)
-if test -z "$GREP"; then
-    GREP=grep
+if test "$ac_with_gnuplot" = "yes" -o "$ac_with_gnuplot" = "maybe"; then
+    AC_PATH_PROGS(GNUPLOT,gnuplot,,$LOCSYSPATH)
+else
+    if test "$ac_with_gnuplot" != "no"; then
+        if test -x "$ac_with_gnuplot"; then
+            GNUPLOT="$ac_with_gnuplot";
+        else
+            AC_MSG_WARN([Specified gnuplot of $ac_with_gnuplot isn't])
+            AC_MSG_WARN([executable, searching for an alternative.])
+           AC_PATH_PROGS(GNUPLOT,gnuplot,,$LOCSYSPATH)
+        fi
+    fi
 fi
-AC_DEFINE_UNQUOTED(GREP,"$GREP",[Define the location of the grep program. ])
+AC_SUBST(GNUPLOT)
 
 AC_PATH_PROGS(GNUTAR,gtar gnutar tar,,$LOCSYSPATH)
 if test ! -z "$GNUTAR"; then
@@ -1294,10 +1631,7 @@ if test ! -z "$GNUTAR"; then
   esac
 fi
 
-if test "x$SAMBA_CLIENT" != "xno"
-then AC_PATH_PROGS(SAMBA_CLIENT,smbclient,,$LOCSYSPATH)
-else SAMBA_CLIENT=
-fi
+AC_PATH_PROGS(SAMBA_CLIENT,smbclient,,$LOCSYSPATH)
 if test ! -z "$SAMBA_CLIENT"; then
   case "`\"$SAMBA_CLIENT\" '\\\\not.a.host.name\\notashare' -U nosuchuser -N -Tx /dev/null 2>&1`" in
   *"Unknown host"*)
@@ -1316,10 +1650,8 @@ if test ! -z "$SAMBA_CLIENT"; then
     AC_DEFINE_UNQUOTED(SAMBA_VERSION, $smbversion,
       [Not the actual samba version, just a number that should be increased whenever we start to rely on a new samba feature. ])
   fi
-
 fi
 
-
 AC_PATH_PROGS(GZIP,gzip,,$LOCSYSPATH)
 if test "$GZIP"; then
     AC_DEFINE(HAVE_GZIP,1,[Define if Amanda is using the gzip program. ])
@@ -1357,6 +1689,16 @@ AC_DEFINE_UNQUOTED(COMPRESS_BEST_OPT,"$COMPRESS_BEST_OPT",[Define as the command
 AC_DEFINE_UNQUOTED(UNCOMPRESS_PATH,"$UNCOMPRESS_PATH",[Define as the exact path to the gzip or compress command. ])
 AC_DEFINE_UNQUOTED(UNCOMPRESS_OPT,"$UNCOMPRESS_OPT",[Define as any optional arguments to get UNCOMPRESS_PATH to uncompress. ])
 
+AC_PATH_PROGS(SORT,sort,,$LOCSYSPATH)
+if test -z "$SORT"; then
+    if $NO_SERVER_MODE; then
+       SORT="NONE"
+    else
+       AC_MSG_ERROR([Set SORT to the path of the sort program.])
+    fi
+fi
+AC_DEFINE_UNQUOTED(SORT_PATH,"$SORT",[Define to the exact path to the sort program. ])
+
 AC_PATH_PROGS(MAILER,Mail mailx mail)
 if test -z "$MAILER"; then
     if $NO_SERVER_MODE; then
@@ -1403,6 +1745,14 @@ dnl AC_PATH_PROGS(MAKEINFO,makeinfo,,$LOCSYSPATH)
 dnl AC_PATH_PROGS(TEXI2DVI,texi2dvi,,$LOCSYSPATH)
 
 AC_PATH_PROGS(DUMP,$DUMP_PROGRAMS,,$SYSLOCPATH)
+if test -n "$DUMP"; then
+  if test "`basename $DUMP`" = "backup"; then
+    backup_gnutar=`$DUMP --version | $GREP "GNU tar"`
+    if test $? -eq 0; then
+      DUMP=
+    fi
+  fi
+fi
 AC_PATH_PROGS(RESTORE,ufsrestore restore,,$SYSLOCPATH)
 if test "$DUMP" -a "$RESTORE"; then
     AC_DEFINE_UNQUOTED(DUMP,"$DUMP",[Define the location of the ufsdump, backup, or dump program. ])
@@ -1446,7 +1796,7 @@ if test "$DUMP" -a "$RESTORE"; then
        AC_MSG_WARN([*** $DUMP is not executable, cannot run -E/-S test])
        amanda_cv_dump_estimate=no
     fi
-    if test "$amanda_cv_dump_estimate" != no; then
+    if test "x$amanda_cv_dump_estimate" != xno; then
        AC_DEFINE_UNQUOTED(HAVE_DUMP_ESTIMATE, "$amanda_cv_dump_estimate",[Define to the string that enables dump estimates. ])
     fi
 
@@ -1484,7 +1834,7 @@ if test "$DUMP" -a "$RESTORE"; then
        AC_MSG_WARN([*** $DUMP is not executable, cannot run -h test])
        amanda_cv_honor_nodump=no
       fi
-      if test "$amanda_cv_honor_nodump" = yes; then
+      if test "x$amanda_cv_honor_nodump" = xyes; then
        AC_DEFINE(HAVE_HONOR_NODUMP,1,[Define this if dump accepts -h for honoring nodump. ])
       fi
     ])
@@ -1539,6 +1889,43 @@ AC_SUBST(AMPLOT_CAT_GZIP)
 AC_SUBST(AMPLOT_CAT_COMPRESS)
 AC_SUBST(AMPLOT_CAT_PACK)
 
+AC_SOCKADDR_STORAGE
+
+# Determine the printf format characters to use when printing
+# values of type long long. This will normally be "ll", but where
+# the compiler treats "long long" as a alias for "long" and printf
+# doesn't know about "long long" use "l".  Hopefully the sprintf
+# will produce a inconsistant result in the later case.  If the compiler
+# fails due to seeing "%lld" we fall back to "l".
+#
+# Win32 uses "%I64d", but that's defined elsewhere since we don't use
+# configure on Win32.
+#
+AC_MSG_CHECKING(printf format modifier for 64-bit integers)
+AC_TRY_RUN([
+#include <stdio.h>
+main() {
+       long long int j = 0;
+       char buf[100];
+       buf[0] = 0;
+       sprintf(buf, "%lld", j);
+       exit((sizeof(long long int) != sizeof(long int))? 0 :
+            (strcmp(buf, "0") != 0));
+} 
+],
+       [AC_MSG_RESULT(ll)
+       LL_FMT="%lld"; LL_RFMT="lld"],
+       [AC_MSG_RESULT(l)
+       LL_FMT="%ld"; LL_RFMT="ld"],
+       [AC_MSG_RESULT(assuming target platform uses ll)
+       LL_FMT="%lld"; LL_RFMT="lld"])
+AC_DEFINE_UNQUOTED(LL_FMT,"$LL_FMT",
+  [Format for a long long printf. ])
+AC_DEFINE_UNQUOTED(LL_RFMT,"$LL_RFMT",
+  [Format for a long long printf. ])
+AC_SUBST(LL_FMT)
+AC_SUBST(LL_RFMT)
+
 dnl Empty GZIP so that make dist works.
 GZIP=
 
@@ -1584,50 +1971,43 @@ AC_CACHE_CHECK(
        fi
     ]
 )
-if test "$need_resetofs" = yes; then
+if test "x$need_resetofs" = xyes; then
     AC_DEFINE(NEED_RESETOFS,1,[Define if we have to reset tape offsets when reacing 2GB. ])
 fi
+
+
 CFLAGS="$amanda_cv_LFS_CFLAGS $CFLAGS"
-CPPFLAGS="$amanda_cv_LFS_CFLAGS $CPPFLAGS"
+CPPFLAGS="$amanda_cv_LFS_CPPFLAGS $CPPFLAGS"
 LDFLAGS="$amanda_cv_LFS_LDFLAGS $LDFLAGS"
 LIBS="$amanda_cv_LFS_LIBS $LIBS"
 
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+AC_CHECK_SIZEOF(intmax_t)
+AC_CHECK_SIZEOF(off_t)
+AC_CHECK_SIZEOF(size_t)
+AC_CHECK_SIZEOF(ssize_t)
+AC_CHECK_SIZEOF(time_t)
+
 AM_PROG_LIBTOOL
 AC_SUBST(LIBTOOL_DEPS)
 
 AC_PROG_GCC_TRADITIONAL
 AC_C_CONST
-AMANDA_C_VOLATILE
 AMANDA_C_UNSIGNED_LONG_CONSTANTS
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 
-dnl We don't have an acconfig.h template since we moved all define templates
-dnl into the third argument of AC_DEFINE.  However, AC_CHECK_TYPE calls
-dnl AC_DEFINE without such an argument, so autoheader complains about no
-dnl template being available.  This is an ugly work-around.
-
-pushdef([AC_DEFINE_SAVED],defn([AC_DEFINE]))
-pushdef([AC_DEFINE],[AC_DEFINE_SAVED([$1],[$2],[Define to $2 if $1 is not defined])])
-
-AC_CHECK_TYPE(ssize_t, int)
-
-dnl there is a push to avoid depending on long longs, so in general it's
-dnl better to convert numbers to kilobytes for consistancies sake.  This
-dnl is primarily checked for for client-src/amqde.c
-AC_CHECK_TYPES(unsigned long long)
-
-popdef([AC_DEFINE])
-popdef([AC_DEFINE_SAVED])
-
-dnl End ugly AC_CHECK_TYPE work-around.
-
 AC_TYPE_UID_T
 AC_TYPE_SIGNAL
 AC_STRUCT_TM
 AM_PROG_LEX
 
+dnl From here on we need to know about STDC_HEADERS
+AC_HEADER_STDC
+
 dnl AC_CHECK_TYPE does not work for socklen_t because it does not look
 dnl in <sys/socket.h>, so this is a variant that adds another header.
 AC_DEFUN([AMANDA_CHECK_TYPE],
@@ -1644,16 +2024,17 @@ changequote([,]), [#include <sys/types.h>
 #endif
 #include <$3>], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
 AC_MSG_RESULT($ac_cv_type_$1)
-if test $ac_cv_type_$1 = no; then
+if test "x$ac_cv_type_$1" = xno; then
   AC_DEFINE($1, $2, [Define if $1 is not a standard system type])
 fi
 ])
 AMANDA_CHECK_TYPE(socklen_t, int, sys/socket.h)
+AMANDA_CHECK_TYPE(sa_family_t, unsigned short, sys/socket.h)
 
 dnl Checks for header files.
-AC_HEADER_STDC
 AC_HEADER_DIRENT
 CF_WAIT
+CF_WAIT_INT
 AC_HEADER_TIME
 AC_CHECK_HEADERS(\
        arpa/inet.h \
@@ -1669,8 +2050,10 @@ AC_CHECK_HEADERS(\
        grp.h \
        history.h \
        libc.h \
+       libgen.h \
        limits.h \
        linux/zftape.h \
+       math.h \
        mntent.h \
        mnttab.h \
        ndbm.h \
@@ -1681,6 +2064,7 @@ AC_CHECK_HEADERS(\
        readline/readline.h \
        scsi/sg.h \
        scsi/scsi_ioctl.h \
+       stdarg.h \
        stdlib.h \
        string.h \
        strings.h \
@@ -1708,6 +2092,7 @@ AC_CHECK_HEADERS(\
        sys/tape.h \
        sys/time.h \
        sys/types.h \
+       sys/uio.h \
        sys/vfs.h \
        sys/vfstab.h \
        syslog.h \
@@ -1782,6 +2167,7 @@ if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
        AC_CACHE_CHECK([for Linux like scsi support (sg)],
        amanda_cv_linux_sg_scsi,
        [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/types.h>
 #include <scsi/sg.h>
 #include <sys/mtio.h>
 ]], [[
@@ -1849,7 +2235,7 @@ dnl Solaris  SCSI
 dnl
 if test x"$ac_cv_header_sys_mtio_h" = x"yes" &&
    test x"$ac_cv_header_sys_scsi_impl_uscsi_h" = x"yes"; then 
-       AC_CACHE_CHECK([for Solaris like scsi support],
+       AC_CACHE_CHECK([for Solaris-like scsi support],
        amanda_cv_solaris_scsi,
        [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
@@ -1914,6 +2300,7 @@ if test x"$ac_cv_header_cam_cam_h" = x"yes";then
        fi
 fi
 
+
 dnl
 dnl BSD SCSI
 dnl
@@ -1963,6 +2350,7 @@ case "$target" in
                        AC_CHECK_LIB(socket,main)
                        ;;
     *)
+                       AC_CHECK_LIB(resolv,main)
                        AC_CHECK_LIB(nsl,main)
                        AC_CHECK_LIB(socket,main)
                        AC_CHECK_LIB(sun,main)
@@ -1970,33 +2358,30 @@ case "$target" in
 esac
 
 AC_CHECK_LIB(termcap,tgetent)
-if test "$ac_cv_lib_termcap_tgetent" != yes; then
+if test "x$ac_cv_lib_termcap_tgetent" != xyes; then
     AC_CHECK_LIB(curses,tgetent)
-    if test "$ac_cv_lib_curses_tgetent" != yes; then
+    if test "x$ac_cv_lib_curses_tgetent" != xyes; then
        AC_CHECK_LIB(ncurses,tgetent)
     fi
 fi
-if test "$ac_cv_lib_termcap_tgetent" = yes ||
-   test "$ac_cv_lib_curses_tgetent" = yes ||
-   test "$ac_cv_lib_ncurses_tgetent" = yes; then
+if test "x$ac_cv_lib_termcap_tgetent" = xyes ||
+   test "x$ac_cv_lib_curses_tgetent" = xyes ||
+   test "x$ac_cv_lib_ncurses_tgetent" = xyes; then
     AC_CHECK_LIB(readline,readline)
-    if test "$ac_cv_lib_readline_readline" != yes; then
+    if test "x$ac_cv_lib_readline_readline" = xyes; then
+       READLINE_LIBS="-lreadline"
+       AC_SUBST(READLINE_LIBS)
+    else
        AC_MSG_WARN([*** No readline library, no history and command line editing in amrecover!])
     fi
 else
     AC_MSG_WARN([*** No terminal library, no history and command line editing in amrecover!])
 fi
 
-if test "$ac_cv_lib_readline_readline" = yes; then
-    READLINE_LIBS=-lreadline
-    LIBS=`echo $LIBS | sed s/-lreadline//`
-    AC_SUBST(READLINE_LIBS)
-fi
-
-if test "$ac_cv_header_linux_zftape_h" = yes; then
-    if test "$ac_cv_header_vtblc_h" = yes; then
+if test "x$ac_cv_header_linux_zftape_h" = xyes; then
+    if test "x$ac_cv_header_vtblc_h" = xyes; then
         AC_CHECK_LIB(vtblc,main)
-        if test "$ac_cv_lib_vtblc_main" != yes; then
+        if test "x$ac_cv_lib_vtblc_main" != xyes; then
             AC_MSG_WARN([*** vtblc library not found - no QIC volume table support!])
         fi
     else
@@ -2097,11 +2482,11 @@ LIBS="$save_LIBS"
 
 case "$DB_STYLE" in
     db)
-       if test "$ac_cv_header_db_h" = yes; then
+       if test "x$ac_cv_header_db_h" = xyes; then
            AC_CHECK_LIB(db,main)
-           if test "$ac_cv_lib_db_main" = yes; then
+           if test "x$ac_cv_lib_db_main" = xyes; then
                AC_CHECK_LIB(db,dbm_open)
-               if test "$ac_cv_lib_db_dbm_open" = yes; then
+               if test "x$ac_cv_lib_db_dbm_open" = xyes; then
                    DB_HEADER=db.h
                    DB_LIB=db
                else
@@ -2109,7 +2494,7 @@ case "$DB_STYLE" in
                    AC_MSG_WARN([*** db database library requested but dbm_open not found in -ldb.])
                fi
            else
-               if test "$ac_cv_lib_c_dbm_open" = yes; then
+               if test "x$ac_cv_lib_c_dbm_open" = xyes; then
                    DB_HEADER=db.h
                    DB_LIB=c
                else
@@ -2124,11 +2509,11 @@ case "$DB_STYLE" in
        ;;
 
     dbm)
-       if test "$ac_cv_header_dbm_h" = yes; then
+       if test "x$ac_cv_header_dbm_h" = xyes; then
            AC_CHECK_LIB(dbm,main)
-           if test "$ac_cv_lib_dbm_main" = yes; then
+           if test "x$ac_cv_lib_dbm_main" = xyes; then
                AC_CHECK_LIB(dbm,dbm_open)
-               if test "$ac_cv_lib_dbm_dbm_open" = yes; then
+               if test "x$ac_cv_lib_dbm_dbm_open" = xyes; then
                    DB_HEADER=dbm.h
                    DB_LIB=dbm
                else
@@ -2136,7 +2521,7 @@ case "$DB_STYLE" in
                    AC_MSG_WARN([*** dbm database library requested but dbm_open not found in -ldbm.])
                fi
            else
-               if test "$ac_cv_lib_c_dbm_open" = yes; then
+               if test "x$ac_cv_lib_c_dbm_open" = xyes; then
                    DB_HEADER=dbm.h
                    DB_LIB=c
                else
@@ -2151,11 +2536,11 @@ case "$DB_STYLE" in
        ;;
 
     gdbm)
-       if test "$ac_cv_header_ndbm_h" = yes; then
+       if test "x$ac_cv_header_ndbm_h" = xyes; then
            AC_CHECK_LIB(gdbm,main)
-           if test "$ac_cv_lib_gdbm_main" = yes; then
+           if test "x$ac_cv_lib_gdbm_main" = xyes; then
                AC_CHECK_LIB(gdbm,dbm_open)
-               if test "$ac_cv_lib_gdbm_dbm_open" = yes; then
+               if test "x$ac_cv_lib_gdbm_dbm_open" = xyes; then
                    DB_HEADER=ndbm.h
                    DB_LIB=gdbm
                else
@@ -2163,7 +2548,7 @@ case "$DB_STYLE" in
                    AC_MSG_WARN([*** gdbm database library requested but -lgdbm not found.])
                fi
            else
-               if test "$ac_cv_lib_c_dbm_open" = yes; then
+               if test "x$ac_cv_lib_c_dbm_open" = xyes; then
                    DB_HEADER=ndbm.h
                    DB_LIB=c
                else
@@ -2178,11 +2563,11 @@ case "$DB_STYLE" in
        ;;
 
     ndbm)
-       if test "$ac_cv_header_ndbm_h" = yes; then
+       if test "x$ac_cv_header_ndbm_h" = xyes; then
            AC_CHECK_LIB(ndbm,main)
-           if test "$ac_cv_lib_ndbm_main" = yes; then
+           if test "x$ac_cv_lib_ndbm_main" = xyes; then
                AC_CHECK_LIB(ndbm,dbm_open)
-               if test "$ac_cv_lib_ndbm_dbm_open" = yes; then
+               if test "x$ac_cv_lib_ndbm_dbm_open" = xyes; then
                    DB_HEADER=ndbm.h
                    DB_LIB=ndbm
                else
@@ -2190,7 +2575,7 @@ case "$DB_STYLE" in
                    AC_MSG_WARN([*** ndbm database library requested but -lndbm not found.])
                fi
            else
-               if test "$ac_cv_lib_c_dbm_open" = yes; then
+               if test "x$ac_cv_lib_c_dbm_open" = xyes; then
                    DB_HEADER=ndbm.h
                    DB_LIB=c
                else
@@ -2220,52 +2605,52 @@ if test -z "$DB_STYLE"; then
     DB_LIB=
 fi
 
-dnl if test -z "$DB_STYLE" -a "$ac_cv_header_ndbm_h" = yes; then
+dnl if test -z "$DB_STYLE" -a "x$ac_cv_header_ndbm_h" = xyes; then
 dnl     AC_CHECK_LIB(ndbm,dbm_open)
-dnl     if test "$ac_cv_lib_ndbm_dbm_open" = yes; then
+dnl     if test "x$ac_cv_lib_ndbm_dbm_open" = xyes; then
 dnl    DB_STYLE=ndbm
 dnl    DB_HEADER=ndbm.h
 dnl    DB_LIB=ndbm
-dnl     elif test "$ac_cv_lib_c_dbm_open" = yes; then
+dnl     elif test "x$ac_cv_lib_c_dbm_open" = xyes; then
 dnl    DB_STYLE=ndbm
 dnl    DB_HEADER=ndbm.h
 dnl    DB_LIB=c
 dnl    fi
 dnl fi
 dnl
-dnl if test -z "$DB_STYLE" -a "$ac_cv_header_db_h" = yes; then
+dnl if test -z "$DB_STYLE" -a "x$ac_cv_header_db_h" = xyes; then
 dnl    AC_CHECK_LIB(db,dbm_open)
-dnl    if test "$ac_cv_lib_db_dbm_open" = yes; then
+dnl    if test "x$ac_cv_lib_db_dbm_open" = xyes; then
 dnl    DB_STYLE=db
 dnl    DB_HEADER=db.h
 dnl    DB_LIB=db
-dnl    elif test "$ac_cv_lib_c_dbm_open" = yes; then
+dnl    elif test "x$ac_cv_lib_c_dbm_open" = xyes; then
 dnl    DB_STYLE=db
 dnl    DB_HEADER=db.h
 dnl    DB_LIB=c
 dnl    fi
 dnl fi
 dnl
-dnl if test -z "$DB_STYLE" -a "$ac_cv_header_dbm_h" = yes; then
+dnl if test -z "$DB_STYLE" -a "x$ac_cv_header_dbm_h" = xyes; then
 dnl    AC_CHECK_LIB(dbm,dbm_open)
-dnl    if test "$ac_cv_lib_db_dbm_open" = yes; then
+dnl    if test "x$ac_cv_lib_db_dbm_open" = xyes; then
 dnl    DB_STYLE=dbm
 dnl    DB_HEADER=dbm.h
 dnl    DB_LIB=dbm
-dnl    elif test "$ac_cv_lib_c_dbm_open" = yes; then
+dnl    elif test "x$ac_cv_lib_c_dbm_open" = xyes; then
 dnl    DB_STYLE=dbm
 dnl    DB_HEADER=dbm.h
 dnl    DB_LIB=c
 dnl    fi
 dnl fi
 dnl
-dnl if test -z "$DB_STYLE" -a "$ac_cv_header_ndbm_h" = yes; then
+dnl if test -z "$DB_STYLE" -a "x$ac_cv_header_ndbm_h" = xyes; then
 dnl    AC_CHECK_LIB(gdbm,dbm_open)
-dnl    if test "$ac_cv_lib_gdbm_dbm_open" = yes; then
+dnl    if test "x$ac_cv_lib_gdbm_dbm_open" = xyes; then
 dnl    DB_STYLE=gdbm
 dnl    DB_HEADER=ndbm.h
 dnl    DB_LIB=gdbm
-dnl    elif test "$ac_cv_lib_c_dbm_open" = yes; then
+dnl    elif test "x$ac_cv_lib_c_dbm_open" = xyes; then
 dnl    DB_STYLE=gdbm
 dnl    DB_HEADER=ndbm.h
 dnl    DB_LIB=c
@@ -2273,7 +2658,7 @@ dnl    fi
 dnl fi
 dnl
 dnl if test -z "$DB_STYLE"; then
-dnl    if test "$ac_cv_lib_c_dbm_open" = yes; then
+dnl    if test "x$ac_cv_lib_c_dbm_open" = xyes; then
 dnl    AC_MSG_WARN([*** A dbm_open() routine was found in -lc, but no header])
 dnl    AC_MSG_WARN([*** files exist.  Please remedy the situation.])
 dnl    else
@@ -2288,7 +2673,7 @@ dnl    DB_HEADER=
 dnl    DB_LIB=
 dnl fi
 
-if test "$DB_STYLE" = text; then
+if test "x$DB_STYLE" = xtext; then
     AC_DEFINE(TEXTDB,1,[Define to enable the text-based database format. ])
 else
     AC_MSG_CHECKING([for database])
@@ -2321,7 +2706,7 @@ else
                ]])],[amanda_cv_struct_datum=yes],[amanda_cv_struct_datum=no
            ])
        ])
-    if test "$amanda_cv_struct_datum" = yes; then
+    if test "x$amanda_cv_struct_datum" = xyes; then
        AC_DEFINE(HAVE_STRUCT_DATUM,1,[Define if the database header declares struct datum. ])
     fi
 fi
@@ -2343,7 +2728,7 @@ AC_CACHE_CHECK(whether _POSIX2_RE_DUP_MAX is defined,
   yes
 #endif
 ], amanda_cv_have__posix2_re_dup_max=yes, amanda_cv_have__posix2_re_dup_max=no))
-if test "$amanda_cv_have__posix2_re_dup_max" = yes; then
+if test "x$amanda_cv_have__posix2_re_dup_max" = xyes; then
     AC_DEFINE(HAVE__POSIX2_RE_DUP_MAX,1,[Define if limits.h defines _POSIX2_RE_DUP_MAX. ])
 fi
 
@@ -2355,7 +2740,7 @@ AC_CACHE_CHECK(whether CHAR_MIN is defined,
   yes
 #endif
 ], amanda_cv_have_char_min=yes, amanda_cv_have_char_min=no))
-if test "$amanda_cv_have_char_min" = yes; then
+if test "x$amanda_cv_have_char_min" = xyes; then
     AC_DEFINE(HAVE_CHAR_MIN,1,[Define if limits.h defines CHAR_MIN. ])
 fi
 
@@ -2367,7 +2752,7 @@ AC_CACHE_CHECK(whether CHAR_MAX is defined,
   yes
 #endif
 ], amanda_cv_have_char_max=yes, amanda_cv_have_char_max=no))
-if test "$amanda_cv_have_char_max" = yes; then
+if test "x$amanda_cv_have_char_max" = xyes; then
     AC_DEFINE(HAVE_CHAR_MAX,1,[Define if limits.h defines CHAR_MAX. ])
 fi
 
@@ -2379,7 +2764,7 @@ AC_CACHE_CHECK(whether CHAR_BIT is defined,
   yes
 #endif
 ], amanda_cv_have_char_bit=yes, amanda_cv_have_char_bit=no))
-if test "$amanda_cv_have_char_bit" = yes; then
+if test "x$amanda_cv_have_char_bit" = xyes; then
     AC_DEFINE(HAVE_CHAR_BIT,1,[Define if limits.h defines CHAR_BIT. ])
 fi
 
@@ -2390,6 +2775,11 @@ ICE_CHECK_DECL(accept,sys/types.h sys/socket.h)
 AC_FUNC_ALLOCA
 AC_CHECK_FUNCS(atexit)
 ICE_CHECK_DECL(atof,stdlib.h)
+ICE_CHECK_DECL(atoi,stdlib.h)
+ICE_CHECK_DECL(atol,stdlib.h)
+ICE_CHECK_DECL(atoll,stdlib.h)
+ICE_CHECK_DECL(strtol,stdlib.h)
+ICE_CHECK_DECL(strtoll,stdlib.h)
 AC_CHECK_FUNCS(basename)
 ICE_CHECK_DECL(bind,sys/types.h sys/socket.h)
 ICE_CHECK_DECL(bcopy,string.h strings.h stdlib.h)
@@ -2408,7 +2798,6 @@ ICE_CHECK_DECL(fputs,stdio.h)
 ICE_CHECK_DECL(fread,stdio.h stdlib.h)
 ICE_CHECK_DECL(fseek,stdio.h)
 ICE_CHECK_DECL(fwrite,stdio.h stdlib.h)
-AC_REPLACE_FUNCS(getcwd)
 AC_CHECK_FUNCS(getfsent)
 ICE_CHECK_DECL(gethostname,unistd.h)
 AC_FUNC_GETMNTENT
@@ -2423,15 +2812,15 @@ AMANDA_FUNC_GETTIMEOFDAY_ARGS
 AC_CHECK_FUNCS(getvfsent initgroups isascii)
 ICE_CHECK_DECL(initgroups,grp.h sys/types.h unistd.h libc.h)
 ICE_CHECK_DECL(ioctl,sys/ioctl.h unistd.h libc.h)
+ICE_CHECK_DECL(isnormal,math.h)
 ICE_CHECK_DECL(listen,sys/types.h sys/socket.h)
 ICE_CHECK_DECL(lstat,sys/types.h sys/stat.h)
 ICE_CHECK_DECL(malloc,stdlib.h)
-AC_REPLACE_FUNCS(memmove)
 ICE_CHECK_DECL(memmove,string.h strings.h)
 ICE_CHECK_DECL(memset,string.h strings.h)
 AC_CHECK_FUNCS(mkdir)
+ICE_CHECK_DECL(mkstemp,stdlib.h)
 ICE_CHECK_DECL(mktemp,stdlib.h)
-AC_REPLACE_FUNCS(mktime)
 ICE_CHECK_DECL(mktime,time.h sys/time.h)
 AC_FUNC_MMAP
 dnl atexit() is prefered, sunos (maybe others?) define on_exit
@@ -2455,8 +2844,12 @@ ICE_CHECK_DECL(sendto,sys/types.h sys/socket.h)
 ICE_CHECK_DECL(setegid,unistd.h)
 ICE_CHECK_DECL(seteuid,unistd.h)
 AC_CHECK_FUNCS(setmntent)
+AC_CHECK_FUNCS(shquote)
+
 ICE_CHECK_DECL(setresgid,unistd.h)
 ICE_CHECK_DECL(setresuid,unistd.h)
+ICE_CHECK_DECL(snprintf,stdio.h)
+ICE_CHECK_DECL(vsnprintf,stdio.h)
 
 dnl arguments for setpgrp or not
 AC_CHECK_FUNC(setpgid, [
@@ -2483,10 +2876,10 @@ ICE_CHECK_DECL(shmctl,sys/types.h sys/ipc.h sys/shm.h)
 ICE_CHECK_DECL(shmdt,sys/types.h sys/ipc.h sys/shm.h)
 ICE_CHECK_DECL(shmget,sys/types.h sys/ipc.h sys/shm.h)
 
-if test "$ac_cv_func_mmap_fixed_mapped" != yes; then
+if test "x$ac_cv_func_mmap_fixed_mapped" != xyes; then
     case "$FORCE_MMAP" in
     n | no)
-       if test "$ac_cv_func_shmget" != yes; then
+       if test "x$ac_cv_func_shmget" != xyes; then
            AC_MSG_WARN([*** Neither shmget() nor mmap() found!])
            AC_MSG_WARN([*** This system will not support the Amanda server.])
            NO_SERVER_MODE=true
@@ -2500,34 +2893,15 @@ if test "$ac_cv_func_mmap_fixed_mapped" != yes; then
     esac
 fi
 
-ICE_CHECK_DECL(shquote, stdlib.h)
-
-dnl Some systems have snprintf but not vsnprintf.  If either snprintf or
-dnl vsnprintf are missing, then use the snprintf.c we provide.
-ICE_CHECK_DECL(snprintf,stdio.h)
-ICE_CHECK_DECL(vsnprintf,stdio.h)
-if test x"$ice_have_snprintf" != x"yes" ||
-   test x"$ice_have_vsnprintf" != x"yes"; then
-    AC_LIBOBJ([snprintf])
-    if false; then :
-       dnl so that automake includes snprintf.c in the distribution
-       AC_REPLACE_FUNCS(snprintf) 
-    fi
-fi
-
 AC_CHECK_FUNCS(sigaction sigemptyset sigvec)
 ICE_CHECK_DECL(socket,sys/types.h sys/socket.h)
 ICE_CHECK_DECL(socketpair,sys/types.h sys/socket.h)
 ICE_CHECK_DECL(sscanf,stdio.h)
 AC_CHECK_FUNCS(statfs statvfs)
-AC_REPLACE_FUNCS(strerror)
 ICE_CHECK_DECL(strerror,string.h strings.h)
 AC_FUNC_STRFTIME
-AC_REPLACE_FUNCS(strftime)
 ICE_CHECK_DECL(strftime,time.h sys/time.h)
-AC_REPLACE_FUNCS(strncasecmp)
 ICE_CHECK_DECL(strncasecmp,string.h strings.h)
-AC_REPLACE_FUNCS(strstr)
 ICE_CHECK_DECL(syslog,syslog.h)
 ICE_CHECK_DECL(system,stdlib.h)
 ICE_CHECK_DECL(time,time.h sys/time.h)
@@ -2539,15 +2913,12 @@ ICE_CHECK_DECL(vfprintf,stdio.h stdlib.h)
 ICE_CHECK_DECL(vprintf,stdio.h stdlib.h)
 ICE_CHECK_DECL(vsprintf,stdio.h stdlib.h)
 AC_CHECK_FUNC(wait4)
-AC_REPLACE_FUNCS(waitpid)
-AC_REPLACE_FUNCS(strcasecmp)
+#AC_REPLACE_FUNCS(writev)
+ICE_CHECK_DECL(writev, unistd.h sys/uio.h)
 ICE_CHECK_DECL(strcasecmp,string.h strings.h)
 
 AC_CHECK_FUNCS(fnmatch)
 
-if test "$ac_cv_func_fnmatch" != yes -a "$USE_QUICK_AND_DIRTY_ESTIMATES" != yes ; then
-    AC_MSG_WARN([--with-qde and no fnmatch -- gnutar exclude files will not work])
-fi
 
 dnl disk device prefixes
 AC_MSG_CHECKING(disk device prefixes)
@@ -2559,7 +2930,7 @@ dfline=`(
     df / | while read line; do
        set -- $line
        while test $# -gt 0; do
-           if test "$1" = "/"; then
+           if test "x$1" = "x/"; then
                echo $line
                break 2
            fi
@@ -2652,7 +3023,7 @@ AC_CACHE_CHECK(
 ])
     rm -f /tmp/conftest.lock
 ])
-if test "$amanda_cv_posix_filelocking" = yes; then
+if test "x$amanda_cv_posix_filelocking" = xyes; then
     AC_DEFINE(USE_POSIX_FCNTL,1,[Define to use Posix fcntl for file locking.])
     HAS_WORKING_FILE_LOCK=1
 fi
@@ -2676,7 +3047,7 @@ if test -z "$HAS_WORKING_FILE_LOCK"; then
 ])
        rm -f /tmp/conftest.lock
 ])
-    if test "$amanda_cv_flock_filelocking" = yes; then
+    if test "x$amanda_cv_flock_filelocking" = xyes; then
        AC_DEFINE(USE_FLOCK,1,[Define to use flock for file locking.])
        HAS_WORKING_FILE_LOCK=1
     fi
@@ -2701,7 +3072,7 @@ if test -z "$HAS_WORKING_FILE_LOCK"; then
 ])
        rm -f /tmp/conftest.lock
 ])
-    if test "$amanda_cv_lockf_filelocking" = yes; then
+    if test "x$amanda_cv_lockf_filelocking" = xyes; then
        AC_DEFINE(USE_LOCKF,1,[Define to use lockf for file locking.])
        HAS_WORKING_FILE_LOCK=1
     fi
@@ -2729,7 +3100,7 @@ if test -z "$HAS_WORKING_FILE_LOCK"; then
 ])
        rm -f /tmp/conftest.lock
 ])
-    if test "$amanda_cv_lnlock_filelocking" = yes; then
+    if test "x$amanda_cv_lnlock_filelocking" = xyes; then
        AC_DEFINE(USE_LNLOCK,1,[Define to use a hard-link based approach for file locking.])
        HAS_WORKING_FILE_LOCK=1
     fi
@@ -2758,6 +3129,7 @@ AM_CONDITIONAL(WANT_CHG_SCSI, test x"$NO_SCSI_CHANGER_MODE" != x"true")
 AM_CONDITIONAL(WANT_CHIO_SCSI, test x"$NO_CHIO_CHANGER_MODE" != x"true")
 AM_CONDITIONAL(WANT_RUNTIME_PSEUDO_RELOC, test x"$NEED_RUNTIME_PSEUDO_RELOC" = x"true")
 AM_CONDITIONAL(WANT_SETUID_CLIENT, test x"$NEED_SETUID_CLIENT" != x"false")
+AM_CONDITIONAL(WANT_SSH_SECURITY, test x"$SSH_SECURITY_SET" = x"true")
 
 case "${FORCE_USE_RUNDUMP-${USE_RUNDUMP}}" in
 y |  ye | yes) AC_DEFINE(USE_RUNDUMP,1,[Define to invoke rundump (setuid-root) instead of DUMP program directly. ]);;
@@ -2774,10 +3146,154 @@ AC_SUBST(LTLIBOBJS)
 LTALLOCA=`echo "$ALLOCA" | sed 's/\.'"${ac_objext}"'/\.lo/g'`
 AC_SUBST(LTALLOCA)
 
+## This stuff is needed for the documentation.
+DOC_BUILD_DATE=`date '+%d-%m-%Y'`
+AC_SUBST(DOC_BUILD_DATE)
+
+AC_ARG_ENABLE(manpage-build,
+AS_HELP_STRING([--enable-manpage-build],
+              [Build the manpages from their XML source (shipped manpages are usually sufficient)]),
+    [ ENABLE_MANPAGE_BUILD=$enableval ],
+    [ ENABLE_MANPAGE_BUILD=no ])
+
+AC_PROG_XSLTPROC([--nonet])
+AC_CHECK_DOCBOOK_XSLT([1.72.0])
+AC_CHECK_DOCBOOK_DTD([4.1.2])
+AC_CHECK_DOCBOOK_DTD([4.2])
+
+# and ensure that everything docbook-related is OK if we'll be using it
+if test "x$ENABLE_MANPAGE_BUILD" = "xyes"; then
+    if test -z "$XSLTPROC"; then
+       AC_MSG_ERROR([Cannot build manpages: 'xsltproc' was not found.])
+    fi
+
+    if test "x$HAVE_DOCBOOK_XSLT_1_72_0" = "xno"; then
+       AC_MSG_ERROR([Cannot build manpages: docbook version 1.72.0 was not found.])
+    fi
+
+    if test "x$HAVE_DOCBOOK_DTD_4_1_2" = "xno" || test "x$HAVE_DOCBOOK_DTD_4_2" = "xno"; then
+       AC_MSG_WARN([Docbook DTD versions 4.1.2 and 4.2 are required for manpage validation; disabling validation])
+       XSLTPROC_FLAGS="$XSLTPROC_FLAGS --novalid"
+    fi
+fi
+AM_CONDITIONAL(ENABLE_MANPAGE_BUILD, test "x$ENABLE_MANPAGE_BUILD" = "xyes")
+
+AC_CACHE_CHECK([for working IPv6],
+              amanda_working_ipv6,
+  [AC_TRY_RUN([#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <errno.h>
+
+main()
+{
+   int aa;
+   aa = socket(AF_INET6, SOCK_STREAM, 0);
+   if (aa > 0) return 0;
+   return aa;
+}],amanda_working_ipv6=yes,
+   amanda_working_ipv6=no,
+   amanda_working_ipv6=yes
+  )
+  ]
+)
+
+if test "$BROKEN_IPV6" = true; then
+    amanda_working_ipv6=no;
+fi
+
+if test "$amanda_working_ipv6" = yes; then
+    if test "$amanda_ipv6" != false; then
+       AC_DEFINE(WORKING_IPV6,1,[Define if IPv6 is working. ])
+    fi
+else
+    if test "$amanda_ipv6" = true; then
+        AC_MSG_ERROR([Asked for IPv6 but it is not working.])
+    fi
+fi
+
+AM_CONDITIONAL([GCC_COMPILER], [test "x$CC" = "xgcc"])
+
+#### Enforce amanda code cleanliness rules.
+#### Done here to allow configuration code to remain intact.
+if test "x$CC" = "xgcc"; then
+  AM_CFLAGS="$AM_CFLAGS -Wall"
+  $CC -v --help 2>&1 | $GREP -- '-Wextra ' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wextra"
+  else
+   AM_CFLAGS="$AM_CFLAGS -W"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-Wparentheses' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wparentheses"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-Wdeclaration-after-statement' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wdeclaration-after-statement"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-Wmissing-prototypes ' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wmissing-prototypes"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-Wstrict-prototypes ' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wstrict-prototypes"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-Wmissing-declarations ' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wmissing-declarations"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-Wformat' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wformat"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-Wsign-compare' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wsign-compare"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-fno-strict-aliasing' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -fno-strict-aliasing"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-Wfloat-equal' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wfloat-equal"
+  fi
+
+  $CC -v --help 2>&1 | $GREP -- '-Wold-style-definition' 2>&1 > /dev/null
+  if test $? -eq 0; then
+    AM_CFLAGS="$AM_CFLAGS -Wold-style-definition"
+  fi
+fi
+AC_SUBST(AM_CFLAGS)
+
 AC_CONFIG_FILES([\
+       gnulib/Makefile                                                 \
+                                                                       \
        amplot/amcat.awk                amplot/amplot.sh                \
        amplot/Makefile                                                 \
                                                                        \
+       amandad-src/Makefile                                            \
+                                                                       \
        changer-src/chg-manual.sh       changer-src/chg-multi.sh        \
        changer-src/chg-mtx.sh          changer-src/chg-chs.sh          \
        changer-src/chg-rth.pl          changer-src/chg-chio.pl         \
@@ -2785,30 +3301,25 @@ AC_CONFIG_FILES([\
        changer-src/chg-juke.sh         changer-src/chg-rait.sh         \
        changer-src/chg-null.sh         changer-src/chg-mcutil.sh       \
        changer-src/chg-disk.sh         changer-src/chg-iomega.pl       \
+    changer-src/chg-lib.sh                                  \
                                                                        \
        client-src/patch-system.sh      client-src/Makefile             \
                                                                        \
+        dumper-src/amgtar.pl           dumper-src/generic-dumper.pl    \
+       dumper-src/Makefile                                             \
+                                                                       \
        common-src/versuff.c            common-src/Makefile             \
                                                                        \
        example/amanda.conf             example/Makefile                \
-       example/amanda.conf.chg-scsi    example/chg-scsi-linux.conf     \
-       example/chg-scsi-solaris.conf   example/chg-scsi-hpux.conf      \
-       example/chg-mcutil.conf                                         \
+       example/chg-mcutil.conf         example/amanda-client.conf      \
                                                                        \
-       man/amadmin.8                   man/amanda.8                    \
-       man/amcheck.8                   man/amcheckdb.8                 \
-       man/amcleanup.8                 man/amdump.8                    \
-       man/amflush.8                   man/amlabel.8                   \
-       man/amoverview.8                man/amrecover.8                 \
-       man/amrmtape.8                  man/amtoc.8                     \
-       man/amverify.8                  man/Makefile                    \
-       man/amstatus.8                  man/amreport.8                  \
-       man/amgetconf.8                 man/amverifyrun.8               \
-       man/amtapetype.8                                                \
+       man/Makefile                                                    \
                                                                        \
        docs/Makefile                                                   \
                                                                        \
        recover-src/Makefile                                            \
+
+       oldrecover-src/Makefile                                         \
                                                                        \
        restore-src/Makefile                                            \
                                                                        \
@@ -2817,9 +3328,11 @@ AC_CONFIG_FILES([\
        server-src/amoverview.pl        server-src/amrmtape.sh          \
        server-src/amtoc.pl             server-src/amverify.sh          \
        server-src/Makefile             server-src/amstatus.pl          \
-       server-src/amverifyrun.sh                                       \
-                                                                       \
+       server-src/amverifyrun.sh       server-src/amcrypt.sh           \
+       server-src/amaespipe.sh         server-src/amcrypt-ossl.sh      \
+       server-src/amcrypt-ossl-asym.sh                                 \
        tape-src/Makefile                                               \
                                                                        \
        config/Makefile                 Makefile])
+
 AC_OUTPUT