Imported Debian patch 2.5.2p1-1
[debian/amanda] / config / acinclude.m4i
index bcc27129d7fbe091d831cadbab11be3e3f9197e6..e8e9029cad0a878478635157d977beeb29bd6ec0 100644 (file)
@@ -191,47 +191,6 @@ main() {
     ]
 )
 
-dnl Find out how {awk,gawk,nawk,mawk} likes to assign variables, if it
-dnl can do so at all.
-AC_DEFUN([AMANDA_PROG_AWK_VAR],
-    [
-       AC_REQUIRE([AC_PROG_AWK])
-       AC_CACHE_CHECK(
-           [for $AWK command line variable assignment],
-           amanda_cv_awk_var_assignment,
-           [
-               echo 'BEGIN{print i; exit}' > conftest.awk
-               result=`$AWK -f conftest.awk i=xx | wc -c`
-               if test "$result" -le 1; then
-                   result=`$AWK -f conftest.awk -v i=xx | wc -c`
-                   if test "$result" -le 1; then
-                       amanda_cv_awk_var_assignment=no
-                   else
-                       amanda_cv_awk_var_assignment="yes with -v"
-                   fi
-               else
-                   amanda_cv_awk_var_assignment="yes"
-               fi
-               rm -fr conftest.awk
-           ]
-       )
-       AWK_VAR_ASSIGNMENT_OPT=
-       case "$amanda_cv_awk_var_assignment" in
-           no)
-               HAVE_AWK_WITH_VAR=no
-               ;;
-           yes)
-               HAVE_AWK_WITH_VAR=yes
-               ;;
-           "yes with -v")
-               HAVE_AWK_WITH_VAR=yes
-               AWK_VAR_ASSIGNMENT_OPT=-v
-               ;;
-       esac
-       AC_SUBST(AWK_VAR_ASSIGNMENT_OPT)
-    ]
-)      
-
 dnl Check for the one or two argument version of gettimeofday.
 AC_DEFUN([AMANDA_FUNC_GETTIMEOFDAY_ARGS],
     [
@@ -271,29 +230,6 @@ AC_DEFUN([AMANDA_FUNC_GETTIMEOFDAY_ARGS],
 
 
 
-dnl Check if the compiler understands volatile.
-AC_DEFUN([AMANDA_C_VOLATILE],
-    [
-       AC_CACHE_CHECK(
-           [for working volatile],
-           amanda_cv_c_volatile,
-           [
-               AC_TRY_COMPILE(,
-                   [
-                       volatile int aaa = 0;
-                   ],
-                   amanda_cv_c_volatile=yes,
-                   amanda_cv_c_volatile=no
-               )
-           ]
-       )
-       if test $amanda_cv_c_volatile = no; then
-           AC_DEFINE(volatile, [],[Define to empty if the compiler does not support volatile. ])
-       fi
-    ]
-)
-
-
 dnl Check for if pid_t is a long, int, or short.
 AC_DEFUN([AMANDA_TYPE_PID_T],
     [
@@ -439,7 +375,33 @@ if test $cf_cv_arg_union_wait = yes; then
        AC_DEFINE(WAIT_USES_UNION,1,[Defined if wait() puts the status in a union wait instead of int. ])
 fi
 ])dnl
+AC_DEFUN([CF_WAIT_INT],
+[
+AC_REQUIRE([AC_TYPE_PID_T])
+AC_HAVE_HEADERS(sys/wait.h wait.h)
+AC_CACHE_CHECK([whether wait uses int], [cf_cv_arg_int],
+        [AC_TRY_COMPILE([
+#include <sys/types.h>
+
+#if HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#else
+# if HAVE_WAIT_H
+#  include <wait.h>
+# endif
+#endif
 
+#ifdef __STDC__
+pid_t wait(int *);
+#endif
+], [
+  int x; int i;
+  wait(&x); i = WIFEXITED(x)
+], [cf_cv_arg_int=yes], [cf_cv_arg_int=no])])
+if test $cf_cv_arg_int = yes; then
+        AC_DEFINE(WAIT_USES_INT,1,[Defined if wait() puts the status in a int instead of a union wait. ])
+fi
+])dnl
 
 dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]
 dnl
@@ -473,9 +435,94 @@ dnl Remember, if the system already had a valid <stdint.h>, the generated
 dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
 dnl
 dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
-dnl @version $Id: acinclude.m4i,v 1.1.2.5.6.2 2004/04/29 20:47:40 martinea Exp $
+dnl @version Id: ax_create_stdint_h.m4,v 1.5 2005/01/06 18:27:27 guidod Exp
 dnl @author  Guido Draheim <guidod@gmx.de> 
 
+AC_DEFUN([AX_CHECK_DATA_MODEL],[
+   AC_CHECK_SIZEOF(char)
+   AC_CHECK_SIZEOF(short)
+   AC_CHECK_SIZEOF(int)
+   AC_CHECK_SIZEOF(long)
+   AC_CHECK_SIZEOF(void*)
+   ac_cv_char_data_model=""
+   ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char"
+   ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short"
+   ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int"
+   ac_cv_long_data_model=""
+   ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int"
+   ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long"
+   ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp"
+   AC_MSG_CHECKING([data model])
+   case "$ac_cv_char_data_model/$ac_cv_long_data_model" in
+    122/242)     ac_cv_data_model="IP16"  ; n="standard 16bit machine" ;;
+    122/244)     ac_cv_data_model="LP32"  ; n="standard 32bit machine" ;;
+    122/*)       ac_cv_data_model="i16"   ; n="unusual int16 model" ;;
+    124/444)     ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;;
+    124/488)     ac_cv_data_model="LP64"  ; n="standard 64bit unixish" ;;
+    124/448)     ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;;
+    124/*)       ac_cv_data_model="i32"   ; n="unusual int32 model" ;;
+    128/888)     ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;;
+    128/*)       ac_cv_data_model="i64"   ; n="unusual int64 model" ;;         
+    222/*2)      ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;;
+    333/*3)      ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;;
+    444/*4)      ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;;
+    666/*6)      ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;;
+    888/*8)      ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;;
+    222/*|333/*|444/*|666/*|888/*) :
+                 ac_cv_data_model="iDSP"  ; n="unusual dsptype" ;;
+     *)          ac_cv_data_model="none"  ; n="very unusual model" ;;
+   esac
+   AC_MSG_RESULT([$ac_cv_data_model ($ac_cv_long_data_model, $n)])
+])
+
+dnl AX_CHECK_HEADER_STDINT_X([HEADERLIST][,ACTION-IF])
+AC_DEFUN([AX_CHECK_HEADER_STDINT_X],[
+AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
+ ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
+  AC_MSG_RESULT([(..)])
+  for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h]) ; do
+   unset ac_cv_type_uintptr_t 
+   unset ac_cv_type_uint64_t
+   AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>])
+   AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
+   m4_ifvaln([$1],[$1]) break
+  done
+  AC_MSG_CHECKING([for stdint uintptr_t])
+ ])
+])
+
+AC_DEFUN([AX_CHECK_HEADER_STDINT_O],[
+AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
+ ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
+  AC_MSG_RESULT([(..)])
+  for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h stdint.h]) ; do
+   unset ac_cv_type_uint32_t
+   unset ac_cv_type_uint64_t
+   AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>])
+   AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
+   m4_ifvaln([$1],[$1]) break
+   break;
+  done
+  AC_MSG_CHECKING([for stdint uint32_t])
+ ])
+])
+
+AC_DEFUN([AX_CHECK_HEADER_STDINT_U],[
+AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
+ ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
+  AC_MSG_RESULT([(..)])
+  for i in m4_ifval([$1],[$1],[sys/types.h inttypes.h sys/inttypes.h]) ; do
+   unset ac_cv_type_u_int32_t
+   unset ac_cv_type_u_int64_t
+   AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],continue,[#include <$i>])
+   AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
+   m4_ifvaln([$1],[$1]) break
+   break;
+  done
+  AC_MSG_CHECKING([for stdint u_int32_t])
+ ])
+])
+
 AC_DEFUN([AX_CREATE_STDINT_H],
 [# ------ AX CREATE STDINT H -------------------------------------
 AC_MSG_CHECKING([for stdint types])
@@ -509,94 +556,35 @@ fi
 if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
 
 dnl .....intro message done, now do a few system checks.....
-dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore
-dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead
+dnl btw, all old CHECK_TYPE macros do automatically "DEFINE" a type, 
+dnl therefore we use the autoconf implementation detail CHECK_TYPE_NEW 
+dnl instead that is triggered with 3 or more arguments (see types.m4)
 
 inttype_headers=`echo $2 | sed -e 's/,/ /g'`
 
 ac_cv_stdint_result="(no helpful system typedefs seen)"
-AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
- ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
-  AC_MSG_RESULT([(..)])
-  for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers ; do
-   unset ac_cv_type_uintptr_t 
-   unset ac_cv_type_uint64_t
-   _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
-     continue,[#include <$i>])
-   AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
-   ac_cv_stdint_result="(seen uintptr_t$and64 in $i)"
-   break;
-  done
-  AC_MSG_CHECKING([for stdint uintptr_t])
- ])
+AX_CHECK_HEADER_STDINT_X(dnl
+   stdint.h inttypes.h sys/inttypes.h $inttype_headers,
+   ac_cv_stdint_result="(seen uintptr_t$and64 in $i)")
 
 if test "_$ac_cv_header_stdint_x" = "_" ; then
-AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
- ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
-  AC_MSG_RESULT([(..)])
-  for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers ; do
-   unset ac_cv_type_uint32_t
-   unset ac_cv_type_uint64_t
-   AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
-     continue,[#include <$i>])
-   AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
-   ac_cv_stdint_result="(seen uint32_t$and64 in $i)"
-   break;
-  done
-  AC_MSG_CHECKING([for stdint uint32_t])
- ])
+AX_CHECK_HEADER_STDINT_O(dnl,
+   inttypes.h sys/inttypes.h stdint.h $inttype_headers,
+   ac_cv_stdint_result="(seen uint32_t$and64 in $i)")
 fi
 
 if test "_$ac_cv_header_stdint_x" = "_" ; then
 if test "_$ac_cv_header_stdint_o" = "_" ; then
-AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
- ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
-  AC_MSG_RESULT([(..)])
-  for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do
-   unset ac_cv_type_u_int32_t
-   unset ac_cv_type_u_int64_t
-   AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
-     continue,[#include <$i>])
-   AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
-   ac_cv_stdint_result="(seen u_int32_t$and64 in $i)"
-   break;
-  done
-  AC_MSG_CHECKING([for stdint u_int32_t])
- ])
+AX_CHECK_HEADER_STDINT_U(dnl,
+   sys/types.h inttypes.h sys/inttypes.h $inttype_headers,
+   ac_cv_stdint_result="(seen u_int32_t$and64 in $i)")
 fi fi
 
 dnl if there was no good C99 header file, do some typedef checks...
 if test "_$ac_cv_header_stdint_x" = "_" ; then
    AC_MSG_CHECKING([for stdint datatype model])
    AC_MSG_RESULT([(..)])
-   AC_CHECK_SIZEOF(char)
-   AC_CHECK_SIZEOF(short)
-   AC_CHECK_SIZEOF(int)
-   AC_CHECK_SIZEOF(long)
-   AC_CHECK_SIZEOF(void*)
-   ac_cv_stdint_char_model=""
-   ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char"
-   ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short"
-   ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int"
-   ac_cv_stdint_long_model=""
-   ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int"
-   ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long"
-   ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp"
-   name="$ac_cv_stdint_long_model"
-   case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in
-    122/242)     name="$name,  IP16 (standard 16bit machine)" ;;
-    122/244)     name="$name,  LP32 (standard 32bit mac/win)" ;;
-    122/*)       name="$name        (unusual int16 model)" ;; 
-    124/444)     name="$name, ILP32 (standard 32bit unixish)" ;;
-    124/488)     name="$name,  LP64 (standard 64bit unixish)" ;;
-    124/448)     name="$name, LLP64 (unusual  64bit unixish)" ;;
-    124/*)       name="$name        (unusual int32 model)" ;; 
-    128/888)     name="$name, ILP64 (unusual  64bit numeric)" ;;
-    128/*)       name="$name        (unusual int64 model)" ;; 
-    222/*|444/*) name="$name        (unusual dsptype)" ;;
-     *)          name="$name        (very unusal model)" ;;
-   esac
-   AC_MSG_RESULT([combined for stdint datatype model...  $name])
+   AX_CHECK_DATA_MODEL
 fi
 
 if test "_$ac_cv_header_stdint_x" != "_" ; then
@@ -629,6 +617,7 @@ fi
 AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
 $ac_cv_stdint_result])
 
+dnl -----------------------------------------------------------------
 # ----------------- DONE inttypes.h checks START header -------------
 AC_CONFIG_COMMANDS([$ac_stdint_h],[
 AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
@@ -641,7 +630,10 @@ echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
 echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
 if test "_$ac_cv_header_stdint_t" != "_" ; then 
 echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
-fi
+echo "#include <stdint.h>" >>$ac_stdint
+echo "#endif" >>$ac_stdint
+echo "#endif" >>$ac_stdint
+else
 
 cat >>$ac_stdint <<STDINT_EOF
 
@@ -701,9 +693,9 @@ fi
 echo "" >>$ac_stdint
 
 echo "/* which type model has been detected */" >>$ac_stdint
-if test "_$ac_cv_stdint_char_model" != "_" ; then
-echo "#define   _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint
-echo "#define   _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint
+if test "_$ac_cv_char_data_model" != "_" ; then
+echo "#define   _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdint
+echo "#define   _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdint
 else
 echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
 echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
@@ -788,6 +780,7 @@ typedef u_int64_t uint64_t;
 /* .. here are some common heuristics using compiler runtime specifics */
 #if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
 #define _HAVE_UINT64_T
+#define _HAVE_LONGLONG_UINT64_T
 typedef long long int64_t;
 typedef unsigned long long uint64_t;
 
@@ -801,12 +794,14 @@ typedef unsigned __int64 uint64_t;
 /* note: all ELF-systems seem to have loff-support which needs 64-bit */
 #if !defined _NO_LONGLONG
 #define _HAVE_UINT64_T
+#define _HAVE_LONGLONG_UINT64_T
 typedef long long int64_t;
 typedef unsigned long long uint64_t;
 #endif
 
 #elif defined __alpha || (defined __mips && defined _ABIN32)
 #if !defined _NO_LONGLONG
+#define _HAVE_UINT64_T
 typedef long int64_t;
 typedef unsigned long uint64_t;
 #endif
@@ -892,6 +887,7 @@ typedef          int     int32_t;
 /* assuming the system has a "long long" */
 #ifndef _HAVE_UINT64_T
 #define _HAVE_UINT64_T
+#define _HAVE_LONGLONG_UINT64_T
 typedef unsigned long long uint64_t;
 typedef          long long  int64_t;
 #endif
@@ -977,12 +973,87 @@ typedef           long   intptr_t;
 #endif
 #endif
 
+/* The ISO C99 standard specifies that in C++ implementations these
+   should only be defined if explicitly requested.  */
+#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
+#ifndef UINT32_C
+
+/* Signed.  */
+# define INT8_C(c)      c
+# define INT16_C(c)     c
+# define INT32_C(c)     c
+# ifdef _HAVE_LONGLONG_UINT64_T
+#  define INT64_C(c)    c ## L
+# else
+#  define INT64_C(c)    c ## LL
+# endif
+
+/* Unsigned.  */
+# define UINT8_C(c)     c ## U
+# define UINT16_C(c)    c ## U
+# define UINT32_C(c)    c ## U
+# ifdef _HAVE_LONGLONG_UINT64_T
+#  define UINT64_C(c)   c ## UL
+# else
+#  define UINT64_C(c)   c ## ULL
+# endif
+
+/* Maximal type.  */
+# ifdef _HAVE_LONGLONG_UINT64_T
+#  define INTMAX_C(c)   c ## L
+#  define UINTMAX_C(c)  c ## UL
+# else
+#  define INTMAX_C(c)   c ## LL
+#  define UINTMAX_C(c)  c ## ULL
+# endif
+
+  /* literalnumbers */
+#endif
+#endif
+
+/* These limits are merily those of a two complement byte-oriented system */
+
+/* Minimum of signed integral types.  */
+# define INT8_MIN               (-128)
+# define INT16_MIN              (-32767-1)
+# define INT32_MIN              (-2147483647-1)
+# define INT64_MIN              (-__INT64_C(9223372036854775807)-1)
+/* Maximum of signed integral types.  */
+# define INT8_MAX               (127)
+# define INT16_MAX              (32767)
+# define INT32_MAX              (2147483647)
+# define INT64_MAX              (__INT64_C(9223372036854775807))
+
+/* Maximum of unsigned integral types.  */
+# define UINT8_MAX              (255)
+# define UINT16_MAX             (65535)
+# define UINT32_MAX             (4294967295U)
+# define UINT64_MAX             (__UINT64_C(18446744073709551615))
+
+/* Minimum of signed integral types having a minimum size.  */
+# define INT_LEAST8_MIN         INT8_MIN
+# define INT_LEAST16_MIN        INT16_MIN
+# define INT_LEAST32_MIN        INT32_MIN
+# define INT_LEAST64_MIN        INT64_MIN
+/* Maximum of signed integral types having a minimum size.  */
+# define INT_LEAST8_MAX         INT8_MAX
+# define INT_LEAST16_MAX        INT16_MAX
+# define INT_LEAST32_MAX        INT32_MAX
+# define INT_LEAST64_MAX        INT64_MAX
+
+/* Maximum of unsigned integral types having a minimum size.  */
+# define UINT_LEAST8_MAX        UINT8_MAX
+# define UINT_LEAST16_MAX       UINT16_MAX
+# define UINT_LEAST32_MAX       UINT32_MAX
+# define UINT_LEAST64_MAX       UINT64_MAX
+
   /* shortcircuit*/
 #endif
   /* once */
 #endif
 #endif
 STDINT_EOF
+fi
     if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
       AC_MSG_NOTICE([$ac_stdint_h is unchanged])
     else
@@ -1003,10 +1074,183 @@ ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
 ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
 ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
 ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
-ac_cv_stdint_char_model="$ac_cv_stdint_char_model"
-ac_cv_stdint_long_model="$ac_cv_stdint_long_model"
+ac_cv_char_data_model="$ac_cv_char_data_model"
+ac_cv_long_data_model="$ac_cv_long_data_model"
 ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
 ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
 ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
 ])
 ])
+
+# AC_PROG_XSLTPROC
+# -----------------------------------------------------------------
+# Find an xsltproc executable.
+#
+# Input:
+#  $1 is the default $XSLTPROC_FLAGS, which will be overridden if the
+#  user specifies --with-xsltproc-flags.
+# Output:
+#  $XSLTPROC contains the path to xsltproc, or is empty if none was
+#  found or the user specified --without-xsltproc. $XSLTPROC_FLAGS 
+#  contains the flags to use with xsltproc.
+
+AC_DEFUN([AC_PROG_XSLTPROC],
+[
+XSLTPROC_FLAGS="$1"
+AC_SUBST(XSLTPROC_FLAGS)
+
+# The (lack of) whitespace and overquoting here are all necessary for
+# proper formatting.
+AC_ARG_WITH(xsltproc,
+AS_HELP_STRING([--with-xsltproc[[[[[=PATH]]]]]],
+               [Use the xsltproc binary in in PATH.]),
+    [ ac_with_xsltproc=$withval; ],
+    [ ac_with_xsltproc=maybe; ])
+
+AC_ARG_WITH(xsltproc-flags,
+AS_HELP_STRING([  --with-xsltproc-flags=FLAGS],
+               [Flags to pass to xsltproc (default $1)]),
+    [ if test "x$withval" == "xno"; then
+       XSLTPROC_FLAGS=''
+    else
+       if test "x$withval" != "xyes"; then
+           XSLTPROC_FLAGS="$withval"
+       fi
+    fi
+       ])
+
+# search for xsltproc if it wasn't specified
+if test "$ac_with_xsltproc" = "yes" -o "$ac_with_xsltproc" = "maybe"; then
+    AC_PATH_PROGS(XSLTPROC,xsltproc,,$LOCSYSPATH)
+else
+    if test "$ac_with_xsltproc" != "no"; then
+        if test -x "$ac_with_xsltproc"; then
+            XSLTPROC="$ac_with_xsltproc";
+        else
+            AC_MSG_WARN([Specified xsltproc of $ac_with_xsltproc isn't])
+            AC_MSG_WARN([executable; searching for an alternative.])
+            AC_PATH_PROGS(XSLTPROC,xsltproc,,$LOCSYSPATH)
+        fi
+    fi
+fi
+])
+
+# AC_CHECK_DOCBOOK_XSLT
+# -----------------------------------------------------------------
+# Check for access to docbook stylesheets of a particular revision.
+# This macro can be used for multiple versions within the same script.
+#
+# Input:
+#  $1 is the version of docbook to search for; default 'current'
+# Output:
+#  $HAVE_DOCBOOK_XSLT_VERS will be set to 'yes' or 'no' depending
+#  on the results of the test, where VERS is $1, with '_' substituted
+#  for '.'  $HAVE_DOCBOOK_XSLT will also be set to the same value.
+AC_DEFUN([AC_CHECK_DOCBOOK_XSLT],
+[
+    AC_REQUIRE([AC_PROG_XSLTPROC])
+
+    dnl define a temporary variable for the version, so this macro can be
+    dnl used with multiple versions
+    define([_VERS], $1)
+    ifelse(_VERS, [], [define([_VERS], [current])])
+    define([ac_cv_docbook_xslt_VERS], patsubst([ac_cv_docbook_xslt_]_VERS, [\.], [_]))
+    define([HAVE_DOCBOOK_XSLT_VERS], patsubst([HAVE_DOCBOOK_XSLT_]_VERS, [\.], [_]))
+
+    AC_CACHE_CHECK([for Docbook XSLT version ]_VERS, [ac_cv_docbook_xslt_VERS],
+    [
+       ac_cv_docbook_xslt_VERS=no
+       if test -n "$XSLTPROC"; then
+           echo "Trying '$XSLTPROC $XSLTPROC_FLAGS http://docbook.sourceforge.net/release/xsl/_VERS/xhtml/docbook.xsl'" >&AS_MESSAGE_LOG_FD
+           $XSLTPROC $XSLTPROC_FLAGS http://docbook.sourceforge.net/release/xsl/_VERS/xhtml/docbook.xsl >&AS_MESSAGE_LOG_FD 2>&1
+
+           if test "$?" = 0; then
+               ac_cv_docbook_xslt_VERS=yes
+           fi
+       fi
+    ])
+
+    HAVE_DOCBOOK_XSLT_VERS="$ac_cv_docbook_xslt_VERS"
+    HAVE_DOCBOOK_XSLT=HAVE_DOCBOOK_XSLT_VERS
+    undefine([_VERS])
+])
+
+# AC_CHECK_DOCBOOK_DTD
+# -----------------------------------------------------------------
+# Check for access to docbook DTD of a particular revision.
+# This macro can be used for multiple versions within the same script.
+#
+# Input:
+#  $1 is the version of docbook to search for; default 'current'
+# Output:
+#  $HAVE_DOCBOOK_DTD_VERS will be set to 'yes' or 'no' depending
+#  on the results of the test, where VERS is $1, with '_' substituted
+#  for '.'  $HAVE_DOCBOOK_DTD will also be set to the same value.
+AC_DEFUN([AC_CHECK_DOCBOOK_DTD],
+[
+    AC_REQUIRE([AC_PROG_XSLTPROC])
+
+    dnl define a temporary variable for the version, so this macro can be
+    dnl used with multiple versions
+    define([_VERS], $1)
+    ifelse(_VERS, [], [define([_VERS], [current])])
+    define([ac_cv_docbook_dtd_VERS], patsubst([ac_cv_docbook_dtd_]_VERS, [\.], [_]))
+    define([HAVE_DOCBOOK_DTD_VERS], patsubst([HAVE_DOCBOOK_DTD_]_VERS, [\.], [_]))
+
+    AC_CACHE_CHECK([for Docbook DTD version ]_VERS, [ac_cv_docbook_dtd_VERS],
+    [
+       ac_cv_docbook_dtd_VERS=no
+       if test -n "$XSLTPROC"; then
+           MY_XSLTPROC_FLAGS=`echo "" $XSLTPROC_FLAGS|sed -e s/--novalid//g`
+           cat <<EOF >conftest.xml
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V[]_VERS//EN" "http://www.oasis-open.org/docbook/xml/_VERS/docbookx.dtd">
+<book id="empty">
+</book>
+EOF
+           echo "Trying '$XSLTPROC $MY_XSLTPROC_FLAGS conftest.xml'" >&AS_MESSAGE_LOG_FD
+           $XSLTPROC $MY_XSLTPROC_FLAGS conftest.xml >conftest.out 2>&1
+           if test "$?" = 0; then
+               # failing to load the DTD is just a warning, so check for it in the output.
+               if grep 'warning: failed to load external entity' conftest_out >/dev/null 2>&1; then
+                   : # no good..
+               else
+                   ac_cv_docbook_dtd_VERS=yes
+               fi
+           fi
+           cat conftest.out >&AS_MESSAGE_LOG_FD
+
+           rm -f conftest.xml conftest.out
+       fi
+    ])
+
+    HAVE_DOCBOOK_DTD_VERS="$ac_cv_docbook_dtd_VERS"
+    HAVE_DOCBOOK_DTD=HAVE_DOCBOOK_DTD_VERS
+    undefine([_VERS])
+])
+dnl
+dnl Checks to see if there's a sockaddr_storage structure
+dnl
+dnl usage:
+dnl
+dnl    AC_SOCKADDR_STORAGE
+dnl
+dnl results:
+dnl
+dnl    HAVE_SOCKADDR_STORAGE (defined)
+dnl
+AC_DEFUN([AC_SOCKADDR_STORAGE],
+    [AC_MSG_CHECKING(if sockaddr_storage struct exists)
+    AC_CACHE_VAL(ac_cv_has_sockaddr_storage,
+       AC_TRY_COMPILE([
+#      include <sys/types.h>
+#      include <sys/socket.h>],
+       [u_int i = sizeof (struct sockaddr_storage)],
+       ac_cv_has_sockaddr_storage=yes,
+       ac_cv_has_sockaddr_storage=no))
+    AC_MSG_RESULT($ac_cv_has_sockaddr_storage)
+    if test $ac_cv_has_sockaddr_storage = yes ; then
+           AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists])
+    fi])
+
+