$NetBSD: patch-aa,v 1.9 2011/10/17 20:14:50 spz Exp $

--- configure.in.orig	2006-09-12 17:40:57.000000000 +0000
+++ configure.in
@@ -13,7 +13,7 @@ case "${host_os}" in
     freebsd2* )
 	disable_thread=yes
     ;;
-    solaris*|linux*|freebsd* )
+    solaris*|linux*|freebsd*|dragonfly*|netbsd* )
 	disable_thread=no
     ;;
     * ) 
@@ -21,17 +21,22 @@ case "${host_os}" in
     ;;
 esac
 
-AC_ARG_ENABLE(thread,
-[  --disable-thread        disable thread always],
-[disable_thread=yes],)
-
-AC_ARG_ENABLE(thread,
-[  --enable-thread         enable thread (on non-solaris platform)],
-[disable_thread=no],)
-
-AC_ARG_ENABLE(wall,
-[  --disable-wall          disable -Wall option always],
-[disable_wall=yes],)
+AC_ARG_ENABLE([thread],
+AS_HELP_STRING([--enable-thread],[enable thread (on non-solaris platform)]))
+
+AC_ARG_ENABLE([thread],
+AS_HELP_STRING([--disable-thread],[disable thread always]))
+
+AS_IF([test "x$enable_thread" = "xyes"], [
+    disable_thread=no
+])
+AS_IF([test "x$enable_thread" = "xno"], [
+    disable_thread=yes
+])
+
+
+AC_ARG_ENABLE([wall],
+AS_HELP_STRING([--disable-wall],[disable -Wall option always]))
 
 pwd=`pwd`
 pwd=`basename $pwd`
@@ -52,7 +57,7 @@ MODULES=""
 
 EXTRA_INCLUDE_DIRS=""
 EXTRA_LIBS=""
-CPPFLAGS="-DFUNCPROTO -I../../include"
+CPPFLAGS="$CPPFLAGS -DFUNCPROTO -I../../include"
 dnl defining FUNCPROTO ensures that struct library uses portotype
 dnl we don't expect non-ANSI (K&R) C compilers to be used
 dnl Some compiles may define __STDC__ by itself which makes it enable, 
@@ -66,7 +71,7 @@ dnl    CFLAGS="-g -O"
 dnl fi
 
 AC_MSG_CHECKING(for -Wall option)
-if test "$disable_wall" = yes; then
+if test "x$enable_wall" = "xno"; then
    if test "$GCC" != "yes"; then
 dnl shut up SUN WorkShop Compilers
        CFLAGS="$CFLAGS -w"
@@ -83,7 +88,7 @@ fi
 QUANTIFY="quantify"
 PURIFY="purify"
 
-AC_DEFUN(AC_FILE_EXIST, [
+AC_DEFUN([AC_FILE_EXIST], [
 if test -f "$1" >/dev/null 2>&1; then
   ifelse([$2], , :, [$2])
   ifelse([$3], , , [else $3])
@@ -109,33 +114,17 @@ dnl	fi
 esac
 
 case "${host_os}" in
-    solaris* )
-	CRYPT_LIB="-lcrypt"
-    ;;
     bsdi* )
         LIBS="$LIBS -lipc"
     ;;
-    freebsd*|netbsd*|openbsd* )
-        if test "$disable_thread" != yes; then
-		LDFLAGS="$LDFLAGS -pthread"
-                THREAD_CFLAGS="-D_THREAD_SAFE -pthread"
-        fi
-	CRYPT_LIB="-lcrypt"
-        ac_pthrlib="c_r"
-    ;;
-    linux* )
+    solaris*|freebsd*|dragonfly*|netbsd*|openbsd*|linux* )
 	CRYPT_LIB="-lcrypt"
     ;;
     osf* )
 	if test $CC = "cc" ; then
-           CPPFLAGS="$CPPFLAGS -taso -pthread"
+            CPPFLAGS="$CPPFLAGS -taso"
         fi
-        if test "$disable_thread" != yes; then
-		LDFLAGS="$LDFLAGS -lc_r"
-                THREAD_CFLAGS="-D_THREAD_SAFE"
-	fi
         CPPFLAGS="$CPPFLAGS -L/usr/shlib"
-        ac_pthrlib="pthreads"
     ;;
 
 esac
@@ -153,34 +142,44 @@ fi
 AC_SUBST(MAKEDEPCLEAN)
 
 dnl Checks for pthread libraries. (linux has pthread.h only, so ...)
-if test "$disable_thread" = yes; then
-  AC_MSG_CHECKING(for thread support)
-  AC_MSG_RESULT(disabled)
-else
-  if test ! -n "$ac_pthrlib"; then 
-    ac_pthrlib="pthread"
-  fi;
-  AC_CHECK_LIB($ac_pthrlib, pthread_create, [
-    AC_CHECK_HEADERS(pthread.h, [pthread="yes"])])
-fi
-
-AC_MSG_CHECKING(for thread support)
-if test "$pthread" = yes; then
-  AC_MSG_RESULT(yes)
-  AC_DEFINE(HAVE_LIBPTHREAD)
-  CFLAGS="$CFLAGS $THREAD_CFLAGS"
-  CPPFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS $CPPFLAGS"
-  QUANTIFY="$QUANTIFY -threads=yes -max-threads=80"
-  PURIFY="$PURIFY -threads=yes -max-threads=80"
-  THREADLIBS="-l$ac_pthrlib"
-  LIBS="$LIBS $THREADLIBS"
-dnl at least FreeBSD 3.1 doesn't have this
-  AC_CHECK_LIB($ac_pthrlib, pthread_attr_setscope, 
-	       AC_DEFINE(HAVE_PTHREAD_ATTR_SETSCOPE))
-  AC_CHECK_FUNCS(thr_setconcurrency)
-else
-  AC_MSG_RESULT(no)
-fi
+AS_IF([test "x$disable_thread" = "xyes"],[
+    AC_MSG_CHECKING(for thread support)
+    AC_MSG_RESULT(disabled)
+],[
+    case "${host_os}" in
+        osf*)
+	    THREAD_CFLAGS="-D_THREAD_SAFE"
+	;;
+	*)
+	    THREAD_CFLAGS="$PTHREAD_CFLAGS"
+    esac
+
+    ac_pthrlib="$PTHREAD_LIBS"
+    if test ! -n "$ac_pthrlib"; then
+	ac_pthrlib="pthread"
+    fi
+
+    THREADLIBS="$PTHREAD_LIBS"
+    AC_CHECK_LIB($ac_pthrlib, pthread_create, [
+	AC_CHECK_HEADERS(pthread.h, [pthread="yes"])])
+
+    AC_MSG_CHECKING(for thread support)
+    if test "$pthread" = yes; then
+        AC_MSG_RESULT(yes)
+        AC_DEFINE([HAVE_LIBPTHREAD],[],[Define if you have pthread library (-lpthread)])
+        CFLAGS="$CFLAGS $THREAD_CFLAGS"
+        CPPFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS $CPPFLAGS"
+        QUANTIFY="$QUANTIFY -threads=yes -max-threads=80"
+        PURIFY="$PURIFY -threads=yes -max-threads=80"
+        LIBS="$LIBS $THREADLIBS"
+        dnl at least FreeBSD 3.1 doesn't have this
+        AC_CHECK_LIB($ac_pthrlib, pthread_attr_setscope, 
+	   AC_DEFINE([HAVE_PTHREAD_ATTR_SETSCOPE],[],[Define if you have pthread_attr_setscope]))
+        AC_CHECK_FUNCS(thr_setconcurrency)
+    else
+        AC_MSG_RESULT(no)
+    fi
+])
 
 dnl Checks for various functions
 
@@ -231,13 +230,13 @@ AC_PATH_PROG(SENDMAIL_PATH,sendmail,no,$
 if test $SENDMAIL_PATH = no; then
     SENDMAIL_PATH=""
 else
-    AC_DEFINE(HAVE_SENDMAIL)
+    AC_DEFINE([HAVE_SENDMAIL],[],[Define if you have any sendmail program])
 fi
 AC_PATH_PROG(MAIL_PATH,mail,no)
 if test $MAIL_PATH = no; then
     MAIL_PATH=""
 else
-    AC_DEFINE(HAVE_MAIL)
+    AC_DEFINE([HAVE_MAIL],[],[Define if you have the mail program])
 fi
 
 dnl Prefer GPG, second choice PGP version 5
@@ -287,7 +286,7 @@ else
 	PGPS_PATH=""
 	PGPV_PATH=""
 	PGPDIR=gpg
-	AC_DEFINE(PGP)
+	AC_DEFINE([PGP],[],[Define if you have any pgp program])
 fi
 AC_SUBST(PGP)
 AC_SUBST(PGPDIR)
@@ -300,19 +299,19 @@ AC_PATH_PROG(GZIP_PATH,gzip,no)
 if test $GZIP_PATH = no; then
     GZIP_PATH=""
 else
-    AC_DEFINE(HAVE_GZIP)
+    AC_DEFINE([HAVE_GZIP],[],[Define if you have gzip])
 fi
 AC_PATH_PROG(IRRDCACHER_PATH,irrdcacher,no)
 if test $IRRDCACHER_PATH = no; then
     IRRDCACHER_PATH=""
 else
-    AC_DEFINE(HAVE_IRRDCACHER)
+    AC_DEFINE([HAVE_IRRDCACHER],[],[Define if you have irrdcacher])
 fi
 AC_PATH_PROG(WGET_PATH,wget,no)
 if test $WGET_PATH = no; then
     WGET_PATH=""
 else
-    AC_DEFINE(HAVE_WGET)
+    AC_DEFINE([HAVE_WGET],[],[Define if you have wget])
 fi
 AC_SUBST(SENDMAIL_PATH)
 AC_SUBST(MAIL_PATH)
@@ -340,11 +339,11 @@ AC_STRUCT_TM
 dnl u_char, u_int, u_short, and u_long
 AC_MSG_CHECKING([u_char, u_int, u_short, and u_long])
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]], [[
-  u_char c; u_int i; u_short s; u_long l;]])],[AC_DEFINE(HAVE_U_TYPES) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)]);
+  u_char c; u_int i; u_short s; u_long l;]])],[AC_DEFINE([HAVE_U_TYPES],[],[Define if you have u_char, u_int, u_short, and u_long]) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)]);
 
 dnl Check for in6_addr structure definition
 AC_EGREP_HEADER(struct in6_addr, netinet/in.h,
-                  AC_DEFINE(HAVE_STRUCT_IN6_ADDR))
+                  AC_DEFINE([HAVE_STRUCT_IN6_ADDR],[],[Define if you have struct in6_addr]))
 
 dnl Checks for library functions.
 AC_CHECK_FUNCS(localtime_r strtok_r gethostbyname_r gethostbyaddr_r)
@@ -358,12 +357,12 @@ AC_CHECK_FUNCS(mkdtemp)
 AC_CHECK_FUNCS(snprintf)
 AC_CHECK_FUNCS(dirname basename)
 
-AC_DEFUN(AC_TYPE_SOCKLEN_T,
+AC_DEFUN([AC_TYPE_SOCKLEN_T],
 [AC_CACHE_CHECK(for socklen_t in sys/socket.h, ac_cv_type_socklen_t,
 [AC_EGREP_HEADER(socklen_t, sys/socket.h,
   ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no)])
 if test $ac_cv_type_socklen_t = no; then
-  AC_DEFINE(socklen_t, int)
+  AC_DEFINE([socklen_t], [int], [define socklen_t if necessary])
 fi
 ])
 
