clean, simplify, clean, sort, clean, unify, clean, ...
[silc.git] / configure.in.pre
1 #
2 #  configure.in.pre
3 #
4 #  Author: Pekka Riikonen <priikone@silcnet.org>
5 #
6 #  Copyright (C) 2000 - 2002 Pekka Riikonen
7 #
8 #  This program is free software; you can redistribute it and/or modify
9 #  it under the terms of the GNU General Public License as published by
10 #  the Free Software Foundation; either version 2 of the License, or
11 #  (at your option) any later version.
12 #
13 #  This program is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #  GNU General Public License for more details.
17 #
18
19 AC_INIT(includes/silcversion.h)
20
21 # Put here any platform specific stuff
22 #
23 AC_CANONICAL_SYSTEM
24 case "$target" in
25   *-*-*bsd*)
26     check_threads=false
27     ;;
28   *)
29     check_threads=true
30     ;;
31 esac
32
33 # ./prepare script will automatically put the correct version. Do not edit!
34 #
35 AM_INIT_AUTOMAKE(SILC_PACKAGE, SILC_VERSION)
36 AC_PREREQ(2.52)
37 AM_CONFIG_HEADER(includes/silcdefs.h)
38
39 AC_PROG_CC
40 AC_C_INLINE
41 AC_C_CONST
42
43 AC_PROG_LN_S
44 AC_SUBST(LN_S)
45
46 # Distribution definition. ./prepare will automatically add here a correct
47 # value. Do not edit!
48 #
49 silc_dist=SILC_PACKAGE
50 SILC_DIST_SUBDIRS="SILC_DISTRIBUTION_SUBDIRS"
51 AC_DEFINE(SILC_DIST_DEFINE)
52
53 # XXX
54 # Compiler flags
55 #
56 if test "$GCC"; then
57   CFLAGS="-Wall -finline-functions $CFLAGS"
58 fi
59
60 # Program checking
61 #
62 AC_PROG_INSTALL
63 AC_PROG_RANLIB
64 AC_PROG_MAKE_SET
65 AC_PROG_LIBTOOL
66 AC_PATH_PROG(sedpath, sed)
67
68 # Header checking
69 #
70 AC_HEADER_STDC
71 AC_HEADER_TIME
72 AC_HEADER_STAT
73
74 # More header checking
75 #
76 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
77 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
78 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
79 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
80 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h)
81 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
82
83 # Data type checking
84 #
85 AC_TYPE_SIGNAL
86 AC_TYPE_SIZE_T
87 AC_TYPE_MODE_T
88 AC_TYPE_UID_T
89 AC_TYPE_PID_T
90
91 AC_CHECK_SIZEOF(long long, 0)
92 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
93 AC_CHECK_SIZEOF(long, 0)
94 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
95 AC_CHECK_SIZEOF(int, 0)
96 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
97 AC_CHECK_SIZEOF(short, 0)
98 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
99 AC_CHECK_SIZEOF(char, 0)
100 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
101 AC_CHECK_SIZEOF(void *, 0)
102 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
103
104 # Function and library checking
105 #
106 AC_CHECK_FUNC(gethostbyname, [],
107   [
108     AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
109     AC_CHECK_FUNC(res_gethostbyname, [],
110        AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
111     )
112   ])
113 AC_CHECK_FUNC(socket, [],
114   AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
115 )
116 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
117 AC_CHECK_FUNCS(select listen bind shutdown close connect setsockopt)
118 AC_CHECK_FUNCS(time ctime utime gettimeofday)
119 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
120 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
121 AC_CHECK_FUNCS(setgroups initgroups pthread_create nl_langinfo)
122 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
123
124 # SIM support checking
125 # XXX These needs to be changed as more supported platforms appear.
126 # XXX This probably needs to be made platform dependant check.
127 #
128 sim_support=false
129 AC_CHECKING(for SIM support)
130 AC_CHECK_HEADERS(dlfcn.h,
131   AC_CHECK_LIB(dl, dlopen,
132     [
133       AC_DEFINE(SILC_SIM)
134       sim_support=true
135       LIBS="$LIBS -ldl"
136     ],
137     [
138       AC_CHECK_LIB(c, dlopen,
139         [
140           AC_DEFINE(SILC_SIM)
141           sim_support=true
142         ])
143     ])
144   )
145
146 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
147 if test x$sim_support = xtrue; then
148   AC_MSG_RESULT(Enabled SIM support.)
149 else
150   AC_MSG_RESULT(No SIM support found.)
151 fi
152
153 # lib/contrib conditionals
154 #
155 AC_CHECK_HEADER(regex.h, have_regex=1, have_regex=0)
156 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
157 AC_CHECK_FUNC(getopt_long, have_getopt_long=1, have_getopt_long=0)
158 AM_CONDITIONAL(HAVE_GETOPT_LONG, test x$have_getopt_long = x1)
159
160 # Installation
161 #
162
163 # Default installation destination
164 #
165 AC_PREFIX_DEFAULT(/usr/local/silc)
166 if test "x$prefix" != xNONE; then
167   silc_prefix="$prefix"
168 else
169   silc_prefix="$ac_default_prefix"
170 fi
171
172 # etc directory
173 #
174 if test "x$sysconfdir" != 'x${prefix}/etc'; then
175   ETCDIR="$sysconfdir"
176 else
177   ETCDIR="$silc_prefix/etc"
178 fi
179
180 AC_ARG_WITH(etcdir,
181   [  --with-etcdir[=PATH]      Directory for system files [/etc/silc]],
182   [
183     case "$withval" in
184       no)
185         ;;
186       yes)
187         ETCDIR="$withval"
188         ;;
189       *)
190         ETCDIR="$withval"
191         ;;
192     esac
193   ])
194 AC_SUBST(ETCDIR)
195 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
196
197 # help directory
198 #
199 HELPDIR="$silc_prefix/help"
200 AC_ARG_WITH(helpdir,
201   [  --with-helpdir[=PATH]     Directory for SILC help files [PREFIX/help]],
202   [
203     case "$withval" in
204       no)
205         ;;
206       yes)
207         HELPDIR="$withval"
208         ;;
209       *)
210        HELPDIR="$withval"
211        ;;
212     esac
213   ])
214 AC_SUBST(HELPDIR)
215 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
216
217 # doc directory
218 #
219 DOCDIR="$silc_prefix/doc"
220 AC_ARG_WITH(docdir,
221   [  --with-docdir[=PATH]      Directory for SILC documentation [PREFIX/doc]],
222   [
223     case "$withval" in
224       no)
225         ;;
226       yes)
227         DOCDIR="$withval"
228         ;;
229       *)
230         DOCDIR="$withval"
231         ;;
232     esac
233   ])
234 AC_SUBST(DOCDIR)
235 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
236
237 # SIM modules directory
238 #
239 MODULESDIR="$silc_prefix/modules"
240 AC_ARG_WITH(simdir,
241   [  --with-simdir[=PATH]      Directory for SIM modules [PREFIX/modules]],
242   [
243     case "$withval" in
244       no)
245         ;;
246       yes)
247         MODULESDIR="$withval"
248         ;;
249       *)
250         MODULESDIR="$withval"
251         ;;
252     esac
253   ])
254 AC_SUBST(MODULESDIR)
255 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
256
257 # Logs directory
258 #
259 LOGSDIR="$silc_prefix/logs"
260 AC_ARG_WITH(logsdir,
261   [  --with-logsdir[=PATH]     Directory for Server logs [PREFIX/logs]],
262   [
263     case "$withval" in
264       no)
265         ;;
266       yes)
267         LOGSDIR="$withval"
268         ;;
269       *)
270         LOGSDIR="$withval"
271         ;;
272     esac
273   ])
274 AC_SUBST(LOGSDIR)
275 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
276
277 # SOCKS4 support checking
278 #
279 AC_MSG_CHECKING(whether to support SOCKS4)
280 AC_ARG_WITH(socks4,
281   [  --with-socks4[=PATH]      Compile with SOCKS4 support],
282   [
283     case "$withval" in
284       no)
285         AC_MSG_RESULT(no)
286         ;;
287       *)
288         AC_MSG_RESULT(yes)
289         socks=4
290     
291         if test -d "$withval/include"; then
292           CFLAGS="$CFLAGS -I$withval/include"
293         else
294           CFLAGS="$CFLAGS -I$withval"
295         fi
296         if test -d "$withval/lib"; then
297           withval="-L$withval/lib -lsocks"
298         else
299           withval="-L$withval -lsocks"
300         fi
301     
302         LIBS="$withval $LIBS"
303         AC_TRY_LINK([],
304           [
305             Rconnect();
306           ], [],
307           [
308             AC_MSG_ERROR(Could not find SOCKS4 library.)
309           ])
310         ;;
311     esac
312   ],
313     AC_MSG_RESULT(no)
314   )
315
316 # SOCKS5 support checking
317 #
318 AC_MSG_CHECKING(whether to support SOCKS5)
319 AC_ARG_WITH(socks5,
320   [  --with-socks5[=PATH]      Compile with SOCKS5 support],
321   [
322     case "$withval" in
323       no)
324         AC_MSG_RESULT(no)
325         ;;
326       *)
327         AC_MSG_RESULT(yes)
328         socks=5
329
330         if test -d "$withval/include"; then
331           CFLAGS="$CFLAGS -I$withval/include"
332         else
333           CFLAGS="$CFLAGS -I$withval"
334         fi
335         if test -d "$withval/lib"; then
336           withval="-L$withval/lib -lsocks5"
337         else
338           withval="-L$withval -lsocks5"
339         fi
340
341         LIBS="$withval $LIBS"
342         AC_TRY_LINK([],
343           [
344             SOCKSconnect();
345           ], [],
346           [
347             AC_MSG_ERROR(Could not find SOCKS5 library.)
348           ])
349         ;;
350     esac
351   ],
352     AC_MSG_RESULT(no)
353   )
354
355 if test "x$socks" = "x4"; then
356   AC_DEFINE(SOCKS)
357   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
358 fi
359
360 if test "x$socks" = "x5"; then
361   AC_DEFINE(SOCKS)
362   AC_DEFINE(SOCKS5)
363   AC_DEFINE(Rconnect, SOCKSconnect)
364   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
365   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
366   AC_DEFINE(Rbind, SOCKSbind)
367   AC_DEFINE(Raccept, SOCKSaccept)
368   AC_DEFINE(Rlisten, SOCKSlisten)
369   AC_DEFINE(Rselect, SOCKSselect)
370   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
371   AC_DEFINE(Rsendto, SOCKSsendto)
372   AC_DEFINE(Rrecv, SOCKSrecv)
373   AC_DEFINE(Rsend, SOCKSsend)
374   AC_DEFINE(Rread, SOCKSread)
375   AC_DEFINE(Rwrite, SOCKSwrite)
376   AC_DEFINE(Rrresvport, SOCKSrresvport)
377   AC_DEFINE(Rshutdown, SOCKSshutdown)
378   AC_DEFINE(Rlisten, SOCKSlisten)
379   AC_DEFINE(Rclose, SOCKSclose)
380   AC_DEFINE(Rdup, SOCKSdup)
381   AC_DEFINE(Rdup2, SOCKSdup2)
382   AC_DEFINE(Rfclose, SOCKSfclose)
383   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
384 fi
385
386 # MP library checking. First check whether user wants to use GMP and use
387 # it if found. If not or not defined then compile the MPI library in the
388 # source tree.
389 #
390 mp_gmp=false
391 AC_MSG_CHECKING(whether to support GMP)
392 AC_ARG_WITH(gmp,
393   [  --with-gmp[=PATH]         Compile with GMP support instead of MPI],
394   [
395     case "$withval" in
396       no)
397         AC_MSG_RESULT(no)
398         ;;
399       *)
400         AC_MSG_RESULT(yes)
401     
402         if test -d "$withval/include"; then
403           CFLAGS="$CFLAGS -I$withval/include"
404         else
405           CFLAGS="$CFLAGS -I$withval"
406         fi
407         if test -d "$withval/lib"; then
408           withval="-L$withval/lib -lgmp"
409         else
410           withval="-L$withval -lgmp"
411         fi
412     
413         LIBS="$withval $LIBS"
414         AC_CHECK_LIB(gmp, __gmpz_init,
415           [
416             mp_gmp=true
417             AC_DEFINE(SILC_MP_GMP)
418             AC_MSG_RESULT(Using GMP as MP library.)
419           ])
420         ;;
421     esac
422   ],
423     AC_MSG_RESULT(no)
424   )
425
426 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
427 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
428 if test x$mp_gmp = xfalse; then
429   AC_DEFINE(SILC_MP_NSS_MPI)
430   AC_MSG_RESULT(Using NSS MPI as MP library.)
431 fi
432
433 # iconv support
434 #
435 AC_ARG_WITH(iconv,
436   [  --with-iconv[=PATH]       Search for libiconv in DIR/include and DIR/lib],
437   [
438     for dir in `echo "$withval" | tr : ' '`; do
439       if test -d $dir/include; then
440         CPPFLAGS="$CPPFLAGS -I$dir/include"
441         CFLAGS="$CFLAGS -I$dir/include"
442       fi
443       if test -d $dir/lib; then
444         LDFLAGS="$LDFLAGS -L$dir/lib"
445       fi
446     done
447   ])
448
449 AC_CHECK_HEADER(iconv.h,
450   [
451     AC_DEFINE(HAVE_ICONV_H, 1, [Define if you have the iconv.h header.])
452     AC_CHECK_FUNC(iconv, ac_iconv_found=1,
453       [
454         LIBS="$LIBS -liconv"
455         AC_MSG_CHECKING(for iconv in -liconv)
456         AC_TRY_LINK(
457           [
458             #include <stdlib.h>
459             #include <iconv.h>
460           ],
461           [
462             iconv_t cd = iconv_open("", "");
463             iconv(cd, NULL, NULL, NULL, NULL);
464             iconv_close(cd);
465           ],
466           [
467             echo "yes"
468             AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
469           ])
470       ])
471    ])
472
473 if test x$ac_iconv_found = x1; then
474
475   # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
476   # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
477   #     obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
478   #
479   AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
480     AC_TRY_RUN(
481       [
482         #include <iconv.h>
483         int main() {
484           iconv_t cd;
485         changequote(, )dnl
486           char buf[4];
487         changequote([, ])dnl
488           char *ob;
489           size_t obl;
490           ob = buf, obl = sizeof(buf);
491           return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
492                  (iconv(cd, 0, 0, &ob, &obl) ||
493                  !(ob == buf && obl == sizeof(buf)) ||
494                  iconv_close(cd)));
495         }
496       ],
497       [
498         ac_iconv_good=yes
499       ],
500       [
501         ac_iconv_good=no
502       ],
503       [
504         ac_iconv_good=yes
505       ])
506     )
507
508   if test x$ac_iconv_good = xno; then
509     AC_MSG_ERROR(Try using libiconv instead.)
510   fi
511 fi
512
513 # silcd config file checking
514 #
515 AC_ARG_WITH(silcd-config-file,
516   [  --with-silcd-config-file[=PATH]
517                           Use PATH as default configuration file in SILC
518                           server [/etc/silc/silcd.conf]],
519     AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval")
520   )
521
522 # silcd pid file checking
523 #
524 if test "x$localstatedir" != 'x${prefix}/var'; then
525   PIDFILE="$localstatedir/silcd.pid"
526 else
527   PIDFILE="$silc_prefix/var/silcd.pid"
528 fi
529
530 AC_ARG_WITH(silcd-pid-file,
531   [  --with-silcd-pid-file[=PATH]
532                           Use PATH as default pid file in SILC
533                           server [/var/run/silcd.pid]],
534   [
535     case "$withval" in
536       no)
537         ;;
538       yes)
539         PIDFILE="$withval"
540         ;;
541       *)
542         PIDFILE="$withval"
543         ;;
544     esac
545   ])
546 AC_SUBST(PIDFILE)
547
548 # Native WIN32 compilation under cygwin
549 #
550 AC_ARG_WITH(win32,
551   [  --with-win32            Compile native WIN32 code (-mno-cygwin)],
552   [
553     AC_DEFINE(SILC_WIN32)
554     win32_support=true
555     CFLAGS="-mno-cygwin $CFLAGS"
556     LIBS="$LIBS -lwsock32"
557   ])
558 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
559
560 # Native EPOC support (disabled by default)
561 #
562 AM_CONDITIONAL(SILC_EPOC, test xfalse = xtrue)
563
564 # Native BeOS support (disabled by default)
565 #
566 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
567
568 # Native OS2 support (disabled by default)
569 #
570 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
571
572 # --without-irssi
573 #
574 without_irssi=false
575 AC_ARG_WITH(irssi,
576   [  --without-irssi         Compile without Irssi SILC Client],
577   [
578     without_irssi=true
579     SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/irssi//'`
580   ])
581
582 # --without-silcd
583 #
584 without_silcd=false
585 AC_ARG_WITH(silcd,
586   [  --without-silcd         Compile without SILC Server],
587   [
588     without_silcd=true
589     SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/silcd//'`
590   ])
591
592 # Disable all assembler optimizations
593 #
594 AC_ARG_ENABLE(asm,
595   [  --disable-asm           Do not use assembler optimizations ])
596
597 # Threads support
598 #
599 want_threads=false
600 AC_ARG_ENABLE(threads,
601   [  --disable-threads       Do not compile with multi-thread support ],
602   [
603     case "${enableval}" in
604       yes)
605         want_threads=true
606         check_threads=true
607         ;;
608       *)
609         check_threads=false
610         ;;
611     esac
612   ])
613
614 if test x$check_threads = xtrue; then
615 AC_CHECK_HEADERS(pthread.h,
616   [
617     AC_DEFINE(SILC_HAVE_PTHREAD)
618     want_threads=true
619   ],
620   [
621     if test -f /usr/pkg/include/pthread.h ; then
622       AC_DEFINE(SILC_HAVE_PTHREAD)
623       want_threads=true
624       AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
625       CFLAGS="$CFLAGS -I/usr/pkg/include"
626     elif test -f /usr/contrib/include/pthread.h ; then
627       AC_DEFINE(SILC_HAVE_PTHREAD)
628       want_threads=true
629       AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
630       CFLAGS="$CFLAGS -I/usr/contrib/include"
631     fi
632   ])
633 fi
634
635 AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
636 if test x$want_threads = xtrue; then
637   TMP_LIBS="$LIBS"
638   LIBS="-lpthread"
639   AC_TRY_LINK(
640     [
641       #include <pthread.h>
642     ],
643     [
644       pthread_attr_t attr;
645       pthread_attr_init(&attr);
646     ],
647     [
648       AC_DEFINE(SILC_THREADS)
649     ],
650     [
651       LIBS="-L/usr/pkg/lib -lpthread"
652       AC_TRY_LINK(
653         [
654           #include <pthread.h>
655         ],
656         [
657           pthread_attr_t attr;
658           pthread_attr_init(&attr);
659         ],
660         [
661           AC_DEFINE(SILC_THREADS)
662         ],
663         [
664           LIBS="-L/usr/contrib/lib -lpthread"
665           AC_TRY_LINK(
666             [
667               #include <pthread.h>
668             ],
669             [
670               pthread_attr_t attr;
671               pthread_attr_init(&attr);
672             ],
673             [
674               AC_DEFINE(SILC_THREADS)
675             ],
676               LIBS=""
677             )
678          ])
679     ])
680
681   CFLAGS="$CFLAGS -D_REENTRANT"
682   case $host in
683     *-aix*)
684       CFLAGS="$CFLAGS -D_THREAD_SAFE"
685       if test x"$GCC" = xyes; then
686         CFLAGS="$CFLAGS -mthreads"
687       fi
688       ;;
689     *-freebsd2.2*)
690       CFLAGS="$CFLAGS -D_THREAD_SAFE"
691       ;;
692     *-sysv5uw7*)  # UnixWare 7
693       if test "$GCC" != "yes"; then
694         CFLAGS="$CFLAGS -Kthread"
695       else
696         CFLAGS="$CFLAGS -pthread"
697       fi
698       ;;
699     *-dg-dgux*)  # DG/UX
700       CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
701       ;;
702   esac
703   LIBS="$TMP_LIBS $LIBS"
704 fi
705
706 # IPv6 support
707 #
708 AC_MSG_CHECKING(for IPv6 support)
709 AC_ARG_ENABLE(ipv6,
710   [  --enable-ipv6           Enable IPv6 support],
711   [
712     case "${enableval}" in
713       yes)
714         want_ipv6=true
715         check_ipv6=false
716         AC_DEFINE(HAVE_IPV6)
717         AC_MSG_RESULT(yes)
718         ;;
719       *)
720         want_ipv6=false
721         check_ipv6=false
722         AC_MSG_RESULT(no)
723         ;;
724     esac
725   ],
726     check_ipv6=true
727   )
728
729 if test x$check_ipv6 = xtrue; then
730   AC_TRY_COMPILE(
731     [
732       #ifdef HAVE_NETINET_TCP_H
733       #include <netinet/tcp.h>
734       #endif
735       #ifdef HAVE_NETDB_H
736       #include <netdb.h>
737       #endif
738       #include <sys/socket.h>
739       #ifdef HAVE_NETDB_IN_H
740       #include <netinet/in.h>
741       #endif
742     ],
743     [
744       struct sockaddr_in6 sin6;
745       int family = AF_INET6;
746     ],
747     [
748       AC_DEFINE(HAVE_IPV6)
749       AC_MSG_RESULT(yes)
750     ],
751       AC_MSG_RESULT(no)
752     )
753 fi
754
755 # Debug checking
756 #
757 AC_MSG_CHECKING(for enabled debugging)
758 AC_ARG_ENABLE(debug,
759   [  --enable-debug          Enable debugging],
760   [
761     case "${enableval}" in
762       yes)
763         AC_MSG_RESULT(yes)
764         AC_DEFINE(SILC_DEBUG)
765         CFLAGS="-O -g $CFLAGS"
766       ;;
767     *)
768       AC_MSG_RESULT(no)
769       CFLAGS="-O2 -g $CFLAGS"
770       ;;
771     esac
772   ],
773   [
774     CFLAGS="-O2 -g $CFLAGS"
775     AC_MSG_RESULT(no)
776   ])
777
778 # Stack trace checking
779 #
780 AC_MSG_CHECKING(for enabled stack tracing)
781 AC_ARG_ENABLE(stack-trace,
782   [  --enable-stack-trace    Enable memory stack trace],
783   [
784     case "${enableval}" in
785     yes)
786       AC_MSG_RESULT(yes)
787       AC_DEFINE(SILC_STACKTRACE)
788       ;;
789     *)
790       AC_MSG_RESULT(no)
791       ;;
792     esac
793   ],
794     AC_MSG_RESULT(no)
795   )
796
797 # Other configure scripts
798 #
799 if test x$without_irssi = xfalse; then
800   if test "x$silc_dist" = "xsilc-client" ||
801      test "x$silc_dist" = "xsilc-toolkit"; then
802     AC_CONFIG_SUBDIRS(irssi)
803   fi
804 fi
805
806 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
807 #AC_CONFIG_SUBDIRS(lib/zlib)
808
809 SILC_TOP_SRCDIR=`pwd`
810 AC_SUBST(SILC_TOP_SRCDIR)
811 #SILC_INSTALL_PREFIX=$ac_default_prefix
812 #AC_SUBST(SILC_INSTALL_PREFIX)
813 AC_SUBST(LIBS)
814 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
815 AC_SUBST(INCLUDE_DEFINES_INT)
816 AC_SUBST(SILC_DIST_SUBDIRS)
817
818 # Makefile outputs
819 #
820 AC_CONFIG_FILES(
821 Makefile
822 Makefile.defines
823 Makefile.defines_int
824 doc/Makefile
825 includes/Makefile
826 lib/Makefile
827 lib/contrib/Makefile
828 lib/silccore/Makefile
829 lib/silccrypt/Makefile
830 lib/silcmath/Makefile
831 lib/silcmath/mpi/Makefile.defines
832 lib/silcmath/mpi/Makefile.defines_int
833 lib/silcsim/Makefile
834 lib/silcske/Makefile
835 lib/silcutil/Makefile
836 lib/silcutil/unix/Makefile
837 lib/silcutil/win32/Makefile
838 lib/silcutil/beos/Makefile
839 lib/silcutil/os2/Makefile
840 lib/silcutil/epoc/Makefile
841 lib/silcsftp/Makefile
842 lib/silcsftp/tests/Makefile
843 doc/example_silcd.conf
844 )
845
846 if test "x$silc_dist" = "xsilc-client" ||
847    test "x$silc_dist" = "xsilc-toolkit"; then
848   AC_CONFIG_FILES(lib/silcclient/Makefile)
849 fi
850
851 if test x$without_irssi = xfalse ; then
852   if test "x$silc_dist" = "xsilc-client" ||
853      test "x$silc_dist" = "xsilc-toolkit"; then
854     AC_CONFIG_FILES(
855 irssi/Makefile.defines
856 irssi/Makefile.defines_int
857 )
858   fi
859 fi
860
861 if test x$without_silcd = xfalse ; then
862   if test "x$silc_dist" = "xsilc-server" ||
863      test "x$silc_dist" = "xsilc-toolkit"; then
864     AC_CONFIG_FILES(
865 silcd/Makefile
866 )
867   fi
868 fi
869
870 if test "x$silc_dist" = "xsilc-toolkit"; then
871   AC_CONFIG_FILES(
872 silc/Makefile
873 win32/Makefile
874 win32/libsilc/Makefile
875 win32/libsilcclient/Makefile
876 )
877 fi
878
879 AC_OUTPUT