+AC_MSG_CHECKING(for IPv6 support)
+AC_ARG_ENABLE(ipv6,
+ [ --enable-ipv6 enable IPv6 support],
+ [
+ case "${enableval}" in
+ yes)
+ want_ipv6=true
+ check_ipv6=false
+ AC_DEFINE(HAVE_IPV6)
+ AC_MSG_RESULT(yes)
+ ;;
+ *)
+ want_ipv6=false
+ check_ipv6=false
+ AC_MSG_RESULT(no)
+ ;;
+ esac
+ ],
+ check_ipv6=true
+ )
+
+if test x$check_ipv6 = xtrue; then
+ AC_TRY_COMPILE(
+ [
+ #ifdef HAVE_NETINET_TCP_H
+ #include <netinet/tcp.h>
+ #endif
+ #ifdef HAVE_NETDB_H
+ #include <netdb.h>
+ #endif
+ #include <sys/socket.h>
+ #ifdef HAVE_NETDB_IN_H
+ #include <netinet/in.h>
+ #endif
+ ],
+ [
+ struct sockaddr_in6 sin6;
+ int family = AF_INET6;
+ ],
+ [
+ AC_DEFINE(HAVE_IPV6)
+ AC_MSG_RESULT(yes)
+ ],
+ AC_MSG_RESULT(no)
+ )
+fi
+
+# Debug checking
+#
+AC_MSG_CHECKING(for enabled debugging)
+AC_ARG_ENABLE(debug,
+ [ --enable-debug enable debugging],
+ [
+ case "${enableval}" in
+ yes)
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(SILC_DEBUG)
+ CFLAGS="-O -g $CFLAGS"
+ ;;
+ *)
+ AC_MSG_RESULT(no)
+ CFLAGS="-O2 -g $CFLAGS"
+ ;;
+ esac
+ ],
+ [
+ CFLAGS="-O2 -g $CFLAGS"
+ AC_MSG_RESULT(no)
+ ])
+
+# Stack trace checking
+#
+AC_MSG_CHECKING(for enabled stack tracing)
+AC_ARG_ENABLE(stack-trace,
+ [ --enable-stack-trace enable memory stack trace],
+ [
+ case "${enableval}" in
+ yes)
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(SILC_STACKTRACE)
+ ;;
+ *)
+ AC_MSG_RESULT(no)
+ ;;
+ esac
+ ],
+ AC_MSG_RESULT(no)
+ )
+
+# Disable all assembler optimizations
+#
+AC_ARG_ENABLE(asm,
+ [ --disable-asm do not use assembler optimizations])
+
+# Threads support
+#
+want_threads=false
+AC_ARG_ENABLE(threads,
+ [ --disable-threads do not compile with multi-thread support],
+ [
+ case "${enableval}" in
+ yes)
+ want_threads=true
+ check_threads=true
+ ;;
+ *)
+ check_threads=false
+ ;;
+ esac
+ ])
+
+if test x$check_threads = xtrue; then
+AC_CHECK_HEADERS(pthread.h,
+ [
+ AC_DEFINE(SILC_HAVE_PTHREAD)
+ want_threads=true
+ ],
+ [
+ if test -f /usr/pkg/include/pthread.h ; then
+ AC_DEFINE(SILC_HAVE_PTHREAD)
+ want_threads=true
+ AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
+ CFLAGS="$CFLAGS -I/usr/pkg/include"
+ elif test -f /usr/contrib/include/pthread.h ; then
+ AC_DEFINE(SILC_HAVE_PTHREAD)
+ want_threads=true
+ AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
+ CFLAGS="$CFLAGS -I/usr/contrib/include"
+ fi
+ ])
+fi
+
+AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
+if test x$want_threads = xtrue; then
+ TMP_LIBS="$LIBS"
+ LIBS="-lpthread"
+ AC_TRY_LINK(
+ [
+ #include <pthread.h>
+ ],
+ [
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ ],
+ [
+ AC_DEFINE(SILC_THREADS)
+ ],
+ [
+ LIBS="-L/usr/pkg/lib -lpthread"
+ AC_TRY_LINK(
+ [
+ #include <pthread.h>
+ ],
+ [
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ ],
+ [
+ AC_DEFINE(SILC_THREADS)
+ ],
+ [
+ LIBS="-L/usr/contrib/lib -lpthread"
+ AC_TRY_LINK(
+ [
+ #include <pthread.h>
+ ],
+ [
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ ],
+ [
+ AC_DEFINE(SILC_THREADS)
+ ],
+ LIBS=""
+ )
+ ])
+ ])
+
+ CFLAGS="$CFLAGS -D_REENTRANT"
+ case $host in
+ *-aix*)
+ CFLAGS="$CFLAGS -D_THREAD_SAFE"
+ if test x"$GCC" = xyes; then
+ CFLAGS="$CFLAGS -mthreads"
+ fi
+ ;;
+ *-freebsd2.2*)
+ CFLAGS="$CFLAGS -D_THREAD_SAFE"
+ ;;
+ *-sysv5uw7*) # UnixWare 7
+ if test "$GCC" != "yes"; then
+ CFLAGS="$CFLAGS -Kthread"
+ else
+ CFLAGS="$CFLAGS -pthread"
+ fi
+ ;;
+ *-dg-dgux*) # DG/UX
+ CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
+ ;;
+ esac
+ LIBS="$TMP_LIBS $LIBS"
+fi
+
+
+##
+## Installation
+##