Merged silc_1_0_branch to trunk.
[silc.git] / configure.ad
similarity index 78%
rename from configure.in.pre
rename to configure.ad
index c8230507246b051b77b65d5e76b4fbb64be71852..410d19f23c4205d405c4eba874ac7a3c1693220e 100644 (file)
@@ -1,14 +1,13 @@
 #
-#  configure.in.pre
+#  configure.ad
 #
 #  Author: Pekka Riikonen <priikone@silcnet.org>
 #
-#  Copyright (C) 2000 - 2002 Pekka Riikonen
+#  Copyright (C) 2000 - 2005 Pekka Riikonen
 #
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#  the Free Software Foundation; version 2 of the License.
 #
 #  This program is distributed in the hope that it will be useful,
 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
 #  GNU General Public License for more details.
 #
 
-AC_INIT(includes/silcversion.h)
+AD_INIT
+AC_CANONICAL_SYSTEM
+AM_INIT_AUTOMAKE
+AC_PREREQ(2.52)
+AC_CONFIG_HEADERS(silcdefs.h)
+
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
 
+AC_PROG_LN_S
+AC_SUBST(LN_S)
+AC_PATH_PROG(sedpath, sed)
+
+#ifdef SILC_DIST_COMPILER
 # Put here any platform specific stuff
 #
-AC_CANONICAL_SYSTEM
 case "$target" in
   *-*-freebsd*)
     check_threads=true
@@ -33,79 +43,18 @@ case "$target" in
     ;;
 esac
 
-# ./prepare script will automatically put the correct version. Do not edit!
-#
-AM_INIT_AUTOMAKE(SILC_PACKAGE, SILC_VERSION)
-AC_PREREQ(2.52)
-AC_CONFIG_HEADERS(includes/silcdefs.h)
-
 CFLAGS=
 AC_PROG_CC
 AC_C_INLINE
 AC_C_CONST
 
-AC_PROG_LN_S
-AC_SUBST(LN_S)
-
-##
-## Distribution definition. ./prepare will automatically add here a correct
-## value. Do not edit!
-##
-silc_dist=SILC_PACKAGE
-SILC_DIST_SUBDIRS="SILC_DISTRIBUTION_SUBDIRS"
-AC_DEFINE(SILC_DIST_DEFINE)
-
-
-##
-## Library versioning.
-##
-# Do the releases and library versioning according to following rules:
-#
-#  - If any code has changed in library, increment [LIB]_REVISION
-#  - If functions were added, set [LIB]_REVISION to 0
-#  - If functions were added, removed or changed, increment [LIB]_CURRENT
-#  - If functions were added, increment [LIB]_AGE
-#  - If functions were removed, set [LIB]_AGE to 0
-#
-# where [LIB] is LIBSILC and LIBSILCCLIENT, and where "functions" means
-# functions public interfaces.
-#
-# The LIB_BASE_VERSION defines the SILC software major.minor version and 
-# it is increment only when these version numbers actually change.
-#
-
-# Base version for libraries.  Do not change this unless SILC version
-# changes too.
-LIB_BASE_VERSION=1.0
-
-# libsilc versions
-LIBSILC_CURRENT=2
-LIBSILC_REVISION=0
-LIBSILC_AGE=0
-
-# libsilcclient versions
-LIBSILCCLIENT_CURRENT=2
-LIBSILCCLIENT_REVISION=0
-LIBSILCCLIENT_AGE=0
-
-# Substitute the version numbers
-AC_SUBST(LIB_BASE_VERSION)
-AC_SUBST(LIBSILC_CURRENT)
-AC_SUBST(LIBSILC_REVISION)
-AC_SUBST(LIBSILC_AGE)
-AC_SUBST(LIBSILCCLIENT_CURRENT)
-AC_SUBST(LIBSILCCLIENT_REVISION)
-AC_SUBST(LIBSILCCLIENT_AGE)
+__SILC_HAVE_PTHREAD=""
+__SILC_HAVE_SIM=""
+__SILC_ENABLE_DEBUG=""
 
-#
-# Program checking
-#
-AC_PROG_INSTALL
 AC_PROG_RANLIB
-AC_PROG_MAKE_SET
 AC_DISABLE_SHARED
 AC_PROG_LIBTOOL
-AC_PATH_PROG(sedpath, sed)
 
 # Header checking
 #
@@ -117,7 +66,7 @@ AC_HEADER_STAT
 #
 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
-AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
+AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h sys/resource.h)
 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h)
 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
@@ -157,12 +106,13 @@ AC_CHECK_FUNC(socket, [],
 )
 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
 AC_CHECK_FUNCS(select listen bind shutdown close connect setsockopt)
-AC_CHECK_FUNCS(time ctime utime gettimeofday)
+AC_CHECK_FUNCS(time ctime utime gettimeofday getrusage)
 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
 AC_CHECK_FUNCS(setgroups initgroups nl_langinfo)
 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
 
+#ifdef SILC_DIST_SIM
 # SIM support checking
 # XXX These needs to be changed as more supported platforms appear.
 # XXX This probably needs to be made platform dependant check.
@@ -174,14 +124,14 @@ AC_CHECK_HEADERS(dlfcn.h,
   [
     AC_CHECK_LIB(dl, dlopen,
       [
-        AC_DEFINE(SILC_SIM)
+        AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
         sim_support=true
         LIBS="$LIBS -ldl"
       ],
       [
         AC_CHECK_LIB(c, dlopen,
           [
-            AC_DEFINE(SILC_SIM)
+            AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
             sim_support=true
           ])
       ])
@@ -190,15 +140,28 @@ AC_CHECK_HEADERS(dlfcn.h,
 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
 if test x$sim_support = xtrue; then
   AC_MSG_RESULT(Enabled SIM support.)
+  __SILC_HAVE_SIM="#define __SILC_HAVE_SIM 1"
 else
   AC_MSG_RESULT(No SIM support found.)
 fi
+#endif SILC_DIST_SIM
 
 # lib/contrib conditionals
 #
-AC_CHECK_HEADER(regex.h, have_regex=1, have_regex=0)
+AC_CHECK_HEADER(regex.h,
+  [
+    AC_DEFINE([HAVE_REGEX], [], [HAVE_REGEX])
+    have_regex=1
+  ], have_regex=0
+)
 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
-AC_CHECK_FUNC(getopt_long, have_getopt_long=1, have_getopt_long=0)
+
+AC_CHECK_FUNC(getopt_long,
+  [
+    AC_DEFINE([HAVE_GETOPT_LONG], [], [HAVE_GETOPT_LONG])
+    have_getopt_long=1
+  ], have_getopt_long=0
+)
 AM_CONDITIONAL(HAVE_GETOPT_LONG, test x$have_getopt_long = x1)
 
 ##
@@ -216,7 +179,7 @@ AC_ARG_ENABLE(ipv6,
         want_ipv6=true
         check_ipv6=false
        summary_ipv6="yes"
-        AC_DEFINE(HAVE_IPV6)
+        AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
         AC_MSG_RESULT(yes)
         ;;
       *)
@@ -253,7 +216,7 @@ if test x$check_ipv6 = xtrue; then
       int family = AF_INET6;
     ],
     [
-      AC_DEFINE(HAVE_IPV6)
+      AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
       AC_MSG_RESULT(yes)
       summary_ipv6="yes"
     ],
@@ -265,14 +228,16 @@ fi
 #
 AC_MSG_CHECKING(whether to enable debugging)
 summary_debug="no"
+__SILC_ENABLE_DEBUG=""
 AC_ARG_ENABLE(debug,
   [  --enable-debug          enable debugging],
   [
     case "${enableval}" in
       yes)
         AC_MSG_RESULT(yes)
-        AC_DEFINE(SILC_DEBUG)
+        AC_DEFINE([SILC_DEBUG], [], [enable-debug])
        summary_debug="yes"
+        __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1"
         ;;
       *)
         AC_MSG_RESULT(no)
@@ -283,53 +248,32 @@ AC_ARG_ENABLE(debug,
     AC_MSG_RESULT(no)
   ])
 
-# Stack trace checking
-#
-AC_MSG_CHECKING(whether to enable stack tracing)
-summary_stacktrace="no"
-AC_ARG_ENABLE(stack-trace,
-  [  --enable-stack-trace    enable memory stack trace],
-  [
-    case "${enableval}" in
-    yes)
-      AC_MSG_RESULT(yes)
-      AC_DEFINE(SILC_STACKTRACE)
-      summary_stacktrace="yes"
-      ;;
-    *)
-      AC_MSG_RESULT(no)
-      ;;
-    esac
-  ],
-    AC_MSG_RESULT(no)
-  )
-
 # Disable all assembler optimizations
 #
 AC_MSG_CHECKING(whether to enable assembler optimizations)
-summary_asm="no"
+want_asm=true
 AC_ARG_ENABLE(asm,
   [  --disable-asm           do not use assembler optimizations],
   [
     AC_MSG_RESULT(no)
+    want_asm=false
   ],
   [
     AC_MSG_RESULT(yes)
-    summary_asm="yes"
+    want_asm=true
   ])
 
-
 ##
 ## Compiler and compiler flag checks
 ##
 
 # Function to check if compiler flag works
 # Usage: SILC_ADD_CFLAGS(FLAGS, [ACTION-IF-FAILED])
-AC_DEFUN(SILC_ADD_CFLAGS,
+AC_DEFUN([SILC_ADD_CFLAGS],
 [ tmp_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS $1"
   AC_MSG_CHECKING(whether $CC accepts $1 flag)
-  AC_TRY_LINK(, , AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
+  AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
                                       CFLAGS="$tmp_CFLAGS"
                                       $2])
   unset tmp_CFLAGS
@@ -384,6 +328,7 @@ if test "$GCC" -a "$host_cpu" = "sparc64"; then
     )
 fi
 AC_SUBST(FIX_SHA1)
+#endif SILC_DIST_COMPILER
 
 ##
 ##  Installation
@@ -391,13 +336,18 @@ AC_SUBST(FIX_SHA1)
 
 # Default installation destination
 #
+#ifdef SILC_DIST_AUTODIST
+AC_PREFIX_DEFAULT(/usr/local)
+#else !SILC_DIST_AUTODIST
 AC_PREFIX_DEFAULT(/usr/local/silc)
+#endif SILC_DIST_AUTODIST
 if test "x$prefix" != xNONE; then
   silc_prefix="$prefix"
 else
   silc_prefix="$ac_default_prefix"
 fi
 
+#ifndef SILC_DIST_AUTODIST
 # etc directory
 #
 if test "x$sysconfdir" != 'x${prefix}/etc'; then
@@ -418,42 +368,46 @@ AC_ARG_WITH(etcdir,
     esac
   ])
 AC_SUBST(ETCDIR)
-AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
+AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
 
-# help directory
+# doc directory
 #
-HELPDIR="$silc_prefix/help"
-AC_ARG_WITH(helpdir,
-  [[  --with-helpdir=DIR      directory for SILC help files [PREFIX/help]]],
+DOCDIR="$silc_prefix/doc"
+AC_ARG_WITH(docdir,
+  [[  --with-docdir=DIR       directory for SILC documentation [PREFIX/doc]]],
   [
     case "$withval" in
       no|yes)
         ;;
       *)
-       HELPDIR="$withval"
-       ;;
+        DOCDIR="$withval"
+        ;;
     esac
   ])
-AC_SUBST(HELPDIR)
-AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
+AC_SUBST(DOCDIR)
+AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR])
+#endif SILC_DIST_AUTODIST
 
-# doc directory
+#ifdef SILC_DIST_CLIENT
+# help directory
 #
-DOCDIR="$silc_prefix/doc"
-AC_ARG_WITH(docdir,
-  [[  --with-docdir=DIR       directory for SILC documentation [PREFIX/doc]]],
+HELPDIR="$silc_prefix/help"
+AC_ARG_WITH(helpdir,
+  [[  --with-helpdir=DIR      directory for SILC help files [PREFIX/help]]],
   [
     case "$withval" in
       no|yes)
         ;;
       *)
-        DOCDIR="$withval"
-        ;;
+       HELPDIR="$withval"
+       ;;
     esac
   ])
-AC_SUBST(DOCDIR)
-AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
+AC_SUBST(HELPDIR)
+AC_DEFINE_UNQUOTED([SILC_HELPDIR], "$HELPDIR", [SILC_HELPDIR])
+#endif SILC_DIST_CLIENT
 
+#ifdef SILC_DIST_SIM
 # SIM modules directory
 #
 MODULESDIR="$silc_prefix/modules"
@@ -469,8 +423,10 @@ AC_ARG_WITH(simdir,
     esac
   ])
 AC_SUBST(MODULESDIR)
-AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
+AC_DEFINE_UNQUOTED([SILC_MODULESDIR], "$MODULESDIR", [SILC_MODULESDIR])
+#endif SILC_DIST_SIM
 
+#ifdef SILC_DIST_SERVER
 # Logs directory
 #
 LOGSDIR="$silc_prefix/logs"
@@ -486,7 +442,7 @@ AC_ARG_WITH(logsdir,
     esac
   ])
 AC_SUBST(LOGSDIR)
-AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
+AC_DEFINE_UNQUOTED([SILC_LOGSDIR], "$LOGSDIR", [SILC_LOGSDIR])
 
 # silcd config file checking
 #
@@ -494,7 +450,7 @@ summary_silcd_configfile="/etc/silc/silcd.conf"
 AC_ARG_WITH(silcd-config-file,
   [[  --with-silcd-config-file=FILE  use FILE as default configuration file
                                  for SILC Server [/etc/silc/silcd.conf]]],
-    AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval")
+    AC_DEFINE_UNQUOTED([SILC_SERVER_CONFIG_FILE], "$withval", [SILC_SERVER_CONFIG_FILE])
     summary_silcd_configfile="$withval"
   )
 
@@ -519,12 +475,45 @@ AC_ARG_WITH(silcd-pid-file,
     esac
   ])
 AC_SUBST(PIDFILE)
+#endif SILC_DIST_SERVER
 
-
+#ifdef SILC_DIST_COMPILER
 ##
 ##  With/without checkings
 ##
 
+#
+# SILC library checking
+compile_libs=true
+
+#ifndef SILC_DIST_TOOLKIT
+
+AC_ARG_WITH(silc-includes, 
+  [  --with-silc-includes=DIR SILC Toolkit includes [search in DIR]],
+  [ac_silc_includes="$withval"], [ac_silc_includes="no"])
+AC_ARG_WITH(silc-libs,
+  [  --with-silc-libs=DIR     SILC Toolkit libraries [search in DIR]],
+  [ac_silc_libs="$withval"], [ac_silc_libs="no"])
+
+#
+# XXX missing checking the __SILC_WITH_XXX defines from the provided libs
+# in order to determine correct libs to link.
+
+#
+# XXX missing pkg-config check.
+
+if test "$ac_silc_includes" != "no"; then
+  compile_libs=false
+  SILC_LIB_INCLUDES="-I$ac_silc_includes"
+fi
+if test "$ac_silc_libs" != "no"; then
+  compile_libs=false
+  LIBS="$LIBS -L$ac_silc_libs"
+fi
+
+#endif SILC_DIST_TOOLKIT
+
+
 # SOCKS4 support checking
 #
 SAVE_LIBS="$LIBS"
@@ -541,14 +530,14 @@ AC_ARG_WITH(socks4,
       *)
         AC_MSG_RESULT(yes)
         socks=4
-    
+
         if test -d "$withval/include"; then
           CFLAGS="$CFLAGS -I$withval/include"
         fi
         if test -d "$withval/lib"; then
           LDFLAGS="$LDFLAGS -L$withval/lib"
         fi
-    
+
         LIBS="-lsocks $LIBS"
         ;;
     esac
@@ -610,36 +599,37 @@ AC_ARG_WITH(socks5,
   )
 
 if test "x$socks" = "x4"; then
-  AC_DEFINE(SOCKS)
+  AC_DEFINE([SOCKS], [], [Socks])
   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
 fi
 
 if test "x$socks" = "x5"; then
-  AC_DEFINE(SOCKS)
-  AC_DEFINE(SOCKS5)
-  AC_DEFINE(Rconnect, SOCKSconnect)
-  AC_DEFINE(Rgetsockname, SOCKSgetsockname)
-  AC_DEFINE(Rgetpeername, SOCKSgetpeername)
-  AC_DEFINE(Rbind, SOCKSbind)
-  AC_DEFINE(Raccept, SOCKSaccept)
-  AC_DEFINE(Rlisten, SOCKSlisten)
-  AC_DEFINE(Rselect, SOCKSselect)
-  AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
-  AC_DEFINE(Rsendto, SOCKSsendto)
-  AC_DEFINE(Rrecv, SOCKSrecv)
-  AC_DEFINE(Rsend, SOCKSsend)
-  AC_DEFINE(Rread, SOCKSread)
-  AC_DEFINE(Rwrite, SOCKSwrite)
-  AC_DEFINE(Rrresvport, SOCKSrresvport)
-  AC_DEFINE(Rshutdown, SOCKSshutdown)
-  AC_DEFINE(Rlisten, SOCKSlisten)
-  AC_DEFINE(Rclose, SOCKSclose)
-  AC_DEFINE(Rdup, SOCKSdup)
-  AC_DEFINE(Rdup2, SOCKSdup2)
-  AC_DEFINE(Rfclose, SOCKSfclose)
-  AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
+  AC_DEFINE([SOCKS], [], [Socks])
+  AC_DEFINE([SOCKS5], [], [Socks5])
+  AC_DEFINE([Rconnect], [SOCKSconnect], [Socks])
+  AC_DEFINE([Rgetsockname], [SOCKSgetsockname], [Socks])
+  AC_DEFINE([Rgetpeername], [SOCKSgetpeername], [Socks])
+  AC_DEFINE([Rbind], [SOCKSbind], [Socks])
+  AC_DEFINE([Raccept], [SOCKSaccept], [Socks])
+  AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
+  AC_DEFINE([Rselect], [SOCKSselect], [Socks])
+  AC_DEFINE([Rrecvfrom], [SOCKSrecvfrom], [Socks])
+  AC_DEFINE([Rsendto], [SOCKSsendto], [Socks])
+  AC_DEFINE([Rrecv], [SOCKSrecv], [Socks])
+  AC_DEFINE([Rsend], [SOCKSsend], [Socks])
+  AC_DEFINE([Rread], [SOCKSread], [Socks])
+  AC_DEFINE([Rwrite], [SOCKSwrite], [Socks])
+  AC_DEFINE([Rrresvport], [SOCKSrresvport], [Socks])
+  AC_DEFINE([Rshutdown], [SOCKSshutdown], [Socks])
+  AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
+  AC_DEFINE([Rclose], [SOCKSclose], [Socks])
+  AC_DEFINE([Rdup], [SOCKSdup], [Socks])
+  AC_DEFINE([Rdup2], [SOCKSdup2], [Socks])
+  AC_DEFINE([Rfclose], [SOCKSfclose], [Socks])
+  AC_DEFINE([Rgethostbyname], [SOCKSgethostbyname], [Socks])
 fi
 
+#ifdef SILC_DIST_MATH
 # MP library checking. First check whether user wants to use GMP and use
 # it if found. If not or not defined then compile the MPI library in the
 # source tree.
@@ -658,14 +648,14 @@ AC_ARG_WITH(gmp,
         ;;
       *)
         AC_MSG_RESULT(yes)
-    
+
         if test -d "$withval/include"; then
           CFLAGS="$CFLAGS -I$withval/include"
         fi
         if test -d "$withval/lib"; then
           LDFLAGS="$LDFLAGS -L$withval/lib"
         fi
-    
+
         LIBS="-lgmp $LIBS"
         ;;
     esac
@@ -673,7 +663,7 @@ AC_ARG_WITH(gmp,
     AC_CHECK_LIB(gmp, __gmpz_init,
       [
         mp_gmp=true
-        AC_DEFINE(SILC_MP_GMP)
+        AC_DEFINE([SILC_MP_GMP], [], [GMP])
         AC_MSG_RESULT(Using GMP as a MP library.)
       ],
       [
@@ -688,9 +678,10 @@ AC_ARG_WITH(gmp,
 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
 if test x$mp_gmp = xfalse; then
-  AC_DEFINE(SILC_MP_NSS_MPI)
+  AC_DEFINE([SILC_MP_NSS_MPI], [], [MPI])
   AC_MSG_RESULT(Using NSS MPI as a MP library.)
 fi
+#endif SILC_DIST_MATH
 
 # iconv support
 #
@@ -738,7 +729,7 @@ AC_ARG_WITH(iconv,
   ])
 
 if test x$check_iconv = xtrue; then
-  AC_MSG_RESULT(starting search...)
+  AC_MSG_RESULT(Searching for iconv...)
 
   # XXX
   unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
@@ -759,7 +750,7 @@ if test x$check_iconv = xtrue; then
         ],
         [
           echo "yes"
-          AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
+          AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
           has_iconv=true
           check_iconv=false
         ],
@@ -779,11 +770,11 @@ if test x$check_iconv = xtrue; then
   SAVE_CFLAGS="$CFLAGS"
   SAVE_LDFLAGS="$LDFLAGS"
   SAVE_CPPFLAGS="$CPPFLAGS"
-    
+
   for dir in `echo "/usr/local /usr/pkg /usr/contrib"`; do
     if test x$has_iconv = xfalse; then
       AC_MSG_RESULT(searching in $dir...)
-     
+
       if test -d $dir/include; then
         CPPFLAGS="$CPPFLAGS -I$dir/include"
         CFLAGS="$CFLAGS -I$dir/include"
@@ -791,10 +782,10 @@ if test x$check_iconv = xtrue; then
       if test -d $dir/lib; then
         LDFLAGS="$LDFLAGS -L$dir/lib"
       fi
-    
+
       # XXX
       unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
-      
+
       AC_CHECK_HEADERS(iconv.h,
         [
           LIBS="$LIBS -liconv"
@@ -811,14 +802,14 @@ if test x$check_iconv = xtrue; then
             ],
             [
               echo "yes"
-              has_iconv=true 
-              AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
+              has_iconv=true
+              AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
             ],
             [
               echo "no"
               has_iconv=false
-              LIBS="$SAVE_LIBS"    
+
+              LIBS="$SAVE_LIBS"
               CFLAGS="$SAVE_CFLAGS"
               LDFLAGS="$SAVE_LDFLAGS"
               CPPFLAGS="$SAVE_CPPFLAGS"
@@ -878,7 +869,7 @@ has_threads=false
 AC_MSG_CHECKING(whether to search for POSIX threads)
 AC_ARG_WITH(pthreads,
   [[  --with-pthreads[=DIR]   use POSIX threads [search in DIR/include and DIR/lib]]],
-  [ 
+  [
     case "${withval}" in
       no)
         check_threads=false
@@ -902,7 +893,7 @@ if test x$check_threads = xtrue; then
   SAVE_CFLAGS="$CFLAGS"
   SAVE_LDFLAGS="$LDFLAGS"
   SAVE_CPPFLAGS="$CPPFLAGS"
-  
+
   AC_MSG_RESULT(yes)
   AC_CHECK_HEADERS(pthread.h,
     [
@@ -926,7 +917,7 @@ if test x$check_threads = xtrue; then
       for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do
         if test x$has_threads = xfalse; then
           AC_MSG_RESULT(searching in $dir...)
-  
+
           if test -d $dir/include; then
             CPPFLAGS="$CPPFLAGS -I$dir/include"
             CFLAGS="$CFLAGS -I$dir/include"
@@ -939,7 +930,7 @@ if test x$check_threads = xtrue; then
           unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true
 
           AC_CHECK_HEADERS(pthread.h,
-            [ 
+            [
               LIBS="$LIBS -lpthread"
               AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
                 [
@@ -964,6 +955,7 @@ else
   has_threads=false
 fi
 
+__SILC_HAVE_PTHREAD=""
 AM_CONDITIONAL(SILC_THREADS, test x$has_threads = xtrue)
 if test x$has_threads = xtrue; then
   CFLAGS="$CFLAGS -D_REENTRANT"
@@ -992,8 +984,9 @@ if test x$has_threads = xtrue; then
    esac
 
   AC_CHECK_FUNC(pthread_create)
-  AC_DEFINE(SILC_HAVE_PTHREAD)
-  AC_DEFINE(SILC_THREADS)
+  AC_DEFINE([SILC_HAVE_PTHREAD], [], [HAVE_PTHREAD])
+  AC_DEFINE([SILC_THREADS], [], [HAVE_THREAD])
+  __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1"
 fi
 
 # Native WIN32 compilation under cygwin
@@ -1003,7 +996,7 @@ AC_ARG_WITH(win32,
   [  --with-win32            compile native WIN32 (MinGW) code (-mno-cygwin)],
   [
     AC_MSG_RESULT(yes)
-    AC_DEFINE(SILC_WIN32)
+    AC_DEFINE([SILC_WIN32], [], [SILC_WIN32])
     win32_support=true
     CFLAGS="-mno-cygwin $CFLAGS"
     LIBS="$LIBS -lwsock32"
@@ -1025,6 +1018,8 @@ AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
 #
 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
 
+#ifdef SILC_DIST_TOOLKIT
+
 # --without-irssi
 #
 without_irssi=false
@@ -1034,7 +1029,6 @@ AC_ARG_WITH(irssi,
   [
     AC_MSG_RESULT(no)
     without_irssi=true
-    SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/irssi//'`
   ],
   [
     AC_MSG_RESULT(yes)
@@ -1049,23 +1043,26 @@ AC_ARG_WITH(silcd,
   [
     AC_MSG_RESULT(no)
     without_silcd=true
-    SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/silcd//'`
   ],
   [
     AC_MSG_RESULT(yes)
   ])
 
+#endif SILC_DIST_TOOLKIT
+
+#ifdef SILC_DIST_CLIENT
 # Irssi perl support
 #
 AC_ARG_WITH(perl,
   [[  --with-perl[=yes|no|module]  Build with Perl support - also specifies
                                if it should be built into main silc binary
                                (static, default) or as a module]])
+#endif SILC_DIST_CLIENT
 
 libtoolfix=true
 AC_MSG_CHECKING(whether to do libtoolfix)
 AC_ARG_WITH(libtoolfix,
-  [  --without-libtoolfix     Do not fix libtool, for package builders],
+  [  --without-libtoolfix    Do not fix libtool, for package builders],
   [
     AC_MSG_RESULT(no)
     libtoolfix=false
@@ -1075,9 +1072,9 @@ AC_ARG_WITH(libtoolfix,
   ])
 
 AC_SUBST(ETCDIR)
-AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
-
+AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
 
+#endif SILC_DIST_COMPILER
 
 ##
 ##  Misc
@@ -1085,27 +1082,33 @@ AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
 
 # Other configure scripts
 #
+
+#ifdef SILC_DIST_TOOLKIT
 if test x$without_irssi = xfalse; then
-  if test "x$silc_dist" = "xsilc-client" ||
-     test "x$silc_dist" = "xsilc-toolkit"; then
-    AC_CONFIG_SUBDIRS(irssi)
-  fi
+#endif SILC_DIST_TOOLKIT
+#ifdef SILC_DIST_CLIENT
+  AC_CONFIG_SUBDIRS(irssi)
+  irssi="yes"
+#endif SILC_DIST_CLIENT
+#ifdef SILC_DIST_TOOLKIT
 fi
+#endif SILC_DIST_TOOLKIT
 
-if test x$mp_gmp = xfalse; then
-  AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
-fi
+SILC_TOP_SRCDIR=`pwd`
 
-#AC_CONFIG_SUBDIRS(lib/zlib)
+# Included configure scripts
+AD_INCLUDE_CONFIGURE
 
-SILC_TOP_SRCDIR=`pwd`
+#ifdef SILC_DIST_COMPILER
+#
+# Substitutions
+#
 AC_SUBST(SILC_TOP_SRCDIR)
-#SILC_INSTALL_PREFIX=$ac_default_prefix
-#AC_SUBST(SILC_INSTALL_PREFIX)
 AC_SUBST(LIBS)
-INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
-AC_SUBST(INCLUDE_DEFINES_INT)
-AC_SUBST(SILC_DIST_SUBDIRS)
+AC_SUBST(SILC_LIB_INCLUDES)
+AC_SUBST(__SILC_HAVE_PTHREAD)
+AC_SUBST(__SILC_HAVE_SIM)
+AC_SUBST(__SILC_ENABLE_DEBUG)
 
 #
 # Fix the libtool to support run-time configuration.  This allows us
@@ -1117,66 +1120,59 @@ if test x$libtoolfix = xtrue; then
 fi
 AM_CONDITIONAL(SILC_LIBTOOLFIX, test x$libtoolfix = xtrue)
 
+INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
+AC_SUBST(INCLUDE_DEFINES_INT)
+
+#endif SILC_DIST_COMPILER
 
 #
 # Makefile outputs
 #
 AC_CONFIG_FILES(
 Makefile
+#ifdef SILC_DIST_DOC
+doc/Makefile
+#endif SILC_DIST_DOC
+#ifdef SILC_DIST_COMPILER
 Makefile.defines
 Makefile.defines_int
-doc/Makefile
 includes/Makefile
-lib/Makefile
-lib/contrib/Makefile
-lib/silccore/Makefile
-lib/silccore/tests/Makefile
-lib/silccrypt/Makefile
-lib/silccrypt/tests/Makefile
-lib/silcmath/Makefile
-lib/silcmath/mpi/Makefile.defines
-lib/silcmath/mpi/Makefile.defines_int
-lib/silcsim/Makefile
-lib/silcske/Makefile
-lib/silcutil/Makefile
-lib/silcutil/unix/Makefile
-lib/silcutil/win32/Makefile
-lib/silcutil/beos/Makefile
-lib/silcutil/os2/Makefile
-lib/silcutil/epoc/Makefile
-lib/silcsftp/Makefile
-lib/silcsftp/tests/Makefile
-doc/example_silcd.conf
+includes/silcversion.h
 includes/silcincludes.h
-silcmap/Makefile
+#endif SILC_DIST_COMPILER
+#ifdef SILC_DIST_APPS
+apps/Makefile
+#endif SILC_DIST_APPS
 )
 
-if test "x$silc_dist" = "xsilc-client" ||
-   test "x$silc_dist" = "xsilc-toolkit"; then
-  AC_CONFIG_FILES(lib/silcclient/Makefile)
-fi
-
+#ifdef SILC_DIST_TOOLKIT
 if test x$without_irssi = xfalse ; then
-  if test "x$silc_dist" = "xsilc-client" ||
-     test "x$silc_dist" = "xsilc-toolkit"; then
-    AC_CONFIG_FILES(
+#endif SILC_DIST_TOOLKIT
+#ifdef SILC_DIST_CLIENT
+  AC_CONFIG_FILES(
 irssi/Makefile.defines
 irssi/Makefile.defines_int
 )
-  fi
+#endif SILC_DIST_CLIENT
+#ifdef SILC_DIST_TOOLKIT
 fi
+#endif SILC_DIST_TOOLKIT
 
+#ifdef SILC_DIST_TOOLKIT
 if test x$without_silcd = xfalse ; then
-  if test "x$silc_dist" = "xsilc-server" ||
-     test "x$silc_dist" = "xsilc-toolkit"; then
-    AC_CONFIG_FILES(
+#endif SILC_DIST_TOOLKIT
+#ifdef SILC_DIST_SERVER
+  AC_CONFIG_FILES(
 silcd/Makefile
+doc/example_silcd.conf
 )
-  fi
+#endif SILC_DIST_SERVER
+#ifdef SILC_DIST_TOOLKIT
 fi
+#endif SILC_DIST_TOOLKIT
 
-if test "x$silc_dist" = "xsilc-toolkit"; then
-  AC_CONFIG_FILES(
+#ifdef SILC_DIST_TOOLKIT
+AC_CONFIG_FILES(
 silc/Makefile
 win32/Makefile
 win32/libsilc/Makefile
@@ -1185,17 +1181,18 @@ tutorial/Makefile
 tutorial/Makefile.defines
 tutorial/Makefile.defines_int
 )
-fi
+#endif SILC_DIST_TOOLKIT
 
 AC_OUTPUT
 
+#ifdef SILC_DIST_COMPILER
 s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir`
 s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir`
 s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir`
 s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir`
 
 echo ""
-echo "SILC Configuration Summary:"
+echo "$PACKAGE Configuration Summary:"
 echo "---------------------------"
 echo " Target host ...................: $target"
 echo " Compiler ......................: $CC"
@@ -1209,53 +1206,76 @@ echo " bin directory .................: $s_bindir"
 echo " sbin directory ................: $s_sbindir"
 echo " etc directory .................: $ETCDIR"
 echo " man directory .................: $s_mandir"
-echo " help directory ................: $HELPDIR"
 echo " doc directory .................: $DOCDIR"
+#ifdef SILC_DIST_CLIENT
+echo " help directory ................: $HELPDIR"
+#endif SILC_DIST_CLIENT
+#ifdef SILC_DIST_SERVER
 echo " logs directory ................: $LOGSDIR"
+#endif SILC_DIST_SERVER
+#ifdef SILC_DIST_SIM
 echo " SIM directory .................: $MODULESDIR"
+#endif SILC_DIST_SIM
+#ifdef SILC_DIST_INCLUDES
 echo " include directory .............: $s_includedir"
+#endif SILC_DIST_INCLUDES
 echo ""
 
-if test "x$silc_dist" = "xsilc-client" ||
-   test "x$silc_dist" = "xsilc-toolkit"; then
-  irssi="yes"
-  if test x$without_irssi = xtrue; then
-    irssi="no"
-  fi
-echo " Compile SILC Client ...........: $irssi"
+#ifdef SILC_DIST_SERVER
+silcd="yes"
+#endif SILC_DIST_SERVER
+
+#ifdef SILC_DIST_TOOLKIT
+if test x$without_irssi = xtrue; then
+  irssi="no"
 fi
+if test x$without_silcd = xtrue; then
+  silcd="no"
+fi
+#endif SILC_DIST_TOOLKIT
 
-if test "x$silc_dist" = "xsilc-server" ||
-   test "x$silc_dist" = "xsilc-toolkit"; then
-  silcd="yes"
-  if test x$without_silcd = xtrue; then
-    silcd="no"
-  fi
+#ifdef SILC_DIST_CLIENT
+echo " Compile SILC Client ...........: $irssi"
+#endif SILC_DIST_CLIENT
+
+#ifdef SILC_DIST_SERVER
 echo " Compile SILC Server ...........: $silcd"
 echo " Server configuration file .....: $summary_silcd_configfile"
 echo " Server PID file ...............: $PIDFILE"
-fi
+#endif SILC_DIST_SERVER
 
+#ifdef SILC_DIST_SIM
 if test x$sim_support = xfalse; then
   sim_support="no"
 else
   sim_support="yes"
 fi
+echo " SIM support ...................: $sim_support"
+#endif SILC_DIST_SIM
+
+echo " IPv6 support ..................: $summary_ipv6"
+
 if test x$has_iconv = xfalse; then
   iconv_support="no"
 else
   iconv_support="yes"
 fi
-echo " SIM support ...................: $sim_support"
-echo " IPv6 support ..................: $summary_ipv6"
 echo " Iconv support .................: $iconv_support"
+
+if test x$want_asm = xfalse; then
+  summary_asm="no"
+else
+  summary_asm="yes"
+fi
 echo " Assembler optimizations .......: $summary_asm"
 
+#ifdef SILC_DIST_MATH
 mp="MPI"
 if test x$mp_gmp = xtrue; then
   mp="GMP"
 fi
 echo " Arithmetic library ............: $mp"
+#endif SILC_DIST_MATH
 
 threads="no"
 if test x$has_threads = xtrue; then
@@ -1263,10 +1283,7 @@ if test x$has_threads = xtrue; then
 fi
 echo " Multi-threads support .........: $threads"
 echo " Debugging enabled .............: $summary_debug"
-echo " Stack-trace enabled ...........: $summary_stacktrace"
 echo ""
-if test "x$silc_dist" = "xsilc-client"; then
-  echo "Compile the sources with 'make' or 'gmake' command (GNU make is required)."
-else
-  echo "Compile the sources with 'make' or 'gmake' command."
-fi
+echo "Compile the sources with 'make' or 'gmake' command."
+#endif SILC_DIST_COMPILER
+