revert mistakenly changed --with-silcd-conf back to --with-silcd-config-file
[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
161 ##
162 ##  Enable/disable checking
163 ##
164
165 # IPv6 support
166 #
167 AC_MSG_CHECKING(for IPv6 support)
168 AC_ARG_ENABLE(ipv6,
169   [  --enable-ipv6           enable IPv6 support],
170   [
171     case "${enableval}" in
172       yes)
173         want_ipv6=true
174         check_ipv6=false
175         AC_DEFINE(HAVE_IPV6)
176         AC_MSG_RESULT(yes)
177         ;;
178       *)
179         want_ipv6=false
180         check_ipv6=false
181         AC_MSG_RESULT(no)
182         ;;
183     esac
184   ],
185     check_ipv6=true
186   )
187
188 if test x$check_ipv6 = xtrue; then
189   AC_TRY_COMPILE(
190     [
191       #ifdef HAVE_NETINET_TCP_H
192       #include <netinet/tcp.h>
193       #endif
194       #ifdef HAVE_NETDB_H
195       #include <netdb.h>
196       #endif
197       #include <sys/socket.h>
198       #ifdef HAVE_NETDB_IN_H
199       #include <netinet/in.h>
200       #endif
201     ],
202     [
203       struct sockaddr_in6 sin6;
204       int family = AF_INET6;
205     ],
206     [
207       AC_DEFINE(HAVE_IPV6)
208       AC_MSG_RESULT(yes)
209     ],
210       AC_MSG_RESULT(no)
211     )
212 fi
213
214 # Debug checking
215 #
216 AC_MSG_CHECKING(for enabled debugging)
217 AC_ARG_ENABLE(debug,
218   [  --enable-debug          enable debugging],
219   [
220     case "${enableval}" in
221       yes)
222         AC_MSG_RESULT(yes)
223         AC_DEFINE(SILC_DEBUG)
224         CFLAGS="-O -g $CFLAGS"
225         ;;
226       *)
227         AC_MSG_RESULT(no)
228         CFLAGS="-O2 -g $CFLAGS"
229         ;;
230     esac
231   ],
232   [
233     CFLAGS="-O2 -g $CFLAGS"
234     AC_MSG_RESULT(no)
235   ])
236
237 # Stack trace checking
238 #
239 AC_MSG_CHECKING(for enabled stack tracing)
240 AC_ARG_ENABLE(stack-trace,
241   [  --enable-stack-trace    enable memory stack trace],
242   [
243     case "${enableval}" in
244     yes)
245       AC_MSG_RESULT(yes)
246       AC_DEFINE(SILC_STACKTRACE)
247       ;;
248     *)
249       AC_MSG_RESULT(no)
250       ;;
251     esac
252   ],
253     AC_MSG_RESULT(no)
254   )
255
256 # Disable all assembler optimizations
257 #
258 AC_ARG_ENABLE(asm,
259   [  --disable-asm           do not use assembler optimizations])
260
261 # Threads support
262 #
263 want_threads=false
264 AC_ARG_ENABLE(threads,
265   [  --disable-threads       do not compile with multi-thread support],
266   [
267     case "${enableval}" in
268       yes)
269         want_threads=true
270         check_threads=true
271         ;;
272       *)
273         check_threads=false
274         ;;
275     esac
276   ])
277
278 if test x$check_threads = xtrue; then
279 AC_CHECK_HEADERS(pthread.h,
280   [
281     AC_DEFINE(SILC_HAVE_PTHREAD)
282     want_threads=true
283   ],
284   [
285     if test -f /usr/pkg/include/pthread.h ; then
286       AC_DEFINE(SILC_HAVE_PTHREAD)
287       want_threads=true
288       AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
289       CFLAGS="$CFLAGS -I/usr/pkg/include"
290     elif test -f /usr/contrib/include/pthread.h ; then
291       AC_DEFINE(SILC_HAVE_PTHREAD)
292       want_threads=true
293       AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
294       CFLAGS="$CFLAGS -I/usr/contrib/include"
295     fi
296   ])
297 fi
298
299 AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
300 if test x$want_threads = xtrue; then
301   TMP_LIBS="$LIBS"
302   LIBS="-lpthread"
303   AC_TRY_LINK(
304     [
305       #include <pthread.h>
306     ],
307     [
308       pthread_attr_t attr;
309       pthread_attr_init(&attr);
310     ],
311     [
312       AC_DEFINE(SILC_THREADS)
313     ],
314     [
315       LIBS="-L/usr/pkg/lib -lpthread"
316       AC_TRY_LINK(
317         [
318           #include <pthread.h>
319         ],
320         [
321           pthread_attr_t attr;
322           pthread_attr_init(&attr);
323         ],
324         [
325           AC_DEFINE(SILC_THREADS)
326         ],
327         [
328           LIBS="-L/usr/contrib/lib -lpthread"
329           AC_TRY_LINK(
330             [
331               #include <pthread.h>
332             ],
333             [
334               pthread_attr_t attr;
335               pthread_attr_init(&attr);
336             ],
337             [
338               AC_DEFINE(SILC_THREADS)
339             ],
340               LIBS=""
341             )
342          ])
343     ])
344
345   CFLAGS="$CFLAGS -D_REENTRANT"
346   case $host in
347     *-aix*)
348       CFLAGS="$CFLAGS -D_THREAD_SAFE"
349       if test x"$GCC" = xyes; then
350         CFLAGS="$CFLAGS -mthreads"
351       fi
352       ;;
353     *-freebsd2.2*)
354       CFLAGS="$CFLAGS -D_THREAD_SAFE"
355       ;;
356     *-sysv5uw7*)  # UnixWare 7
357       if test "$GCC" != "yes"; then
358         CFLAGS="$CFLAGS -Kthread"
359       else
360         CFLAGS="$CFLAGS -pthread"
361       fi
362       ;;
363     *-dg-dgux*)  # DG/UX
364       CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
365       ;;
366   esac
367   LIBS="$TMP_LIBS $LIBS"
368 fi
369
370
371 ##
372 ##  Installation
373 ##
374
375 # Default installation destination
376 #
377 AC_PREFIX_DEFAULT(/usr/local/silc)
378 if test "x$prefix" != xNONE; then
379   silc_prefix="$prefix"
380 else
381   silc_prefix="$ac_default_prefix"
382 fi
383
384 # etc directory
385 #
386 if test "x$sysconfdir" != 'x${prefix}/etc'; then
387   ETCDIR="$sysconfdir"
388 else
389   ETCDIR="$silc_prefix/etc"
390 fi
391
392 AC_ARG_WITH(etcdir,
393   [[  --with-etcdir=DIR       directory for system files [/etc/silc]]],
394   [
395     case "$withval" in
396       no)
397         ;;
398       *)
399         ETCDIR="$withval"
400         ;;
401     esac
402   ])
403 AC_SUBST(ETCDIR)
404 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
405
406 # help directory
407 #
408 HELPDIR="$silc_prefix/help"
409 AC_ARG_WITH(helpdir,
410   [[  --with-helpdir=DIR      directory for SILC help files [PREFIX/help]]],
411   [
412     case "$withval" in
413       no)
414         ;;
415       *)
416        HELPDIR="$withval"
417        ;;
418     esac
419   ])
420 AC_SUBST(HELPDIR)
421 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
422
423 # doc directory
424 #
425 DOCDIR="$silc_prefix/doc"
426 AC_ARG_WITH(docdir,
427   [[  --with-docdir=DIR       directory for SILC documentation [PREFIX/doc]]],
428   [
429     case "$withval" in
430       no)
431         ;;
432       *)
433         DOCDIR="$withval"
434         ;;
435     esac
436   ])
437 AC_SUBST(DOCDIR)
438 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
439
440 # SIM modules directory
441 #
442 MODULESDIR="$silc_prefix/modules"
443 AC_ARG_WITH(simdir,
444   [[  --with-simdir=DIR       directory for SIM modules [PREFIX/modules]]],
445   [
446     case "$withval" in
447       no)
448         ;;
449       *)
450         MODULESDIR="$withval"
451         ;;
452     esac
453   ])
454 AC_SUBST(MODULESDIR)
455 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
456
457 # Logs directory
458 #
459 LOGSDIR="$silc_prefix/logs"
460 AC_ARG_WITH(logsdir,
461   [[  --with-logsdir=DIR      directory for SILC Server logs [PREFIX/logs]]],
462   [
463     case "$withval" in
464       no)
465         ;;
466       *)
467         LOGSDIR="$withval"
468         ;;
469     esac
470   ])
471 AC_SUBST(LOGSDIR)
472 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
473
474 # silcd config file checking
475 #
476 AC_ARG_WITH(silcd-config-file,
477   [[  --with-silcd-config-file=FILE  use FILE as default configuration file
478                                  for SILC Server [/etc/silc/silcd.conf]]],
479     AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval")
480   )
481
482 # silcd pid file checking
483 #
484 if test "x$localstatedir" != 'x${prefix}/var'; then
485   PIDFILE="$localstatedir/silcd.pid"
486 else
487   PIDFILE="$silc_prefix/var/silcd.pid"
488 fi
489
490 AC_ARG_WITH(silcd-pid-file,
491   [[  --with-silcd-pid-file=FILE     use FILE as default pid file for SILC
492                                  Server [/var/run/silcd.pid]]],
493   [
494     case "$withval" in
495       no)
496         ;;
497       *)
498         PIDFILE="$withval"
499         ;;
500     esac
501   ])
502 AC_SUBST(PIDFILE)
503
504
505 ##
506 ##  With/without checkings
507 ##
508
509 # SOCKS4 support checking
510 #
511 AC_MSG_CHECKING(whether to support SOCKS4)
512 AC_ARG_WITH(socks4,
513   [[  --with-socks4[=DIR]     with SOCKS4 support [search in DIR/lib and DIR/include]]],
514   [
515     case "$withval" in
516       no)
517         AC_MSG_RESULT(no)
518         ;;
519       *)
520         AC_MSG_RESULT(yes)
521         socks=4
522     
523         if test -d "$withval/include"; then
524           CFLAGS="$CFLAGS -I$withval/include"
525         else
526           CFLAGS="$CFLAGS -I$withval"
527         fi
528         if test -d "$withval/lib"; then
529           withval="-L$withval/lib -lsocks"
530         else
531           withval="-L$withval -lsocks"
532         fi
533     
534         LIBS="$withval $LIBS"
535         AC_TRY_LINK([],
536           [
537             Rconnect();
538           ], [],
539           [
540             AC_MSG_ERROR(Could not find SOCKS4 library.)
541           ])
542         ;;
543     esac
544   ],
545     AC_MSG_RESULT(no)
546   )
547
548 # SOCKS5 support checking
549 #
550 AC_MSG_CHECKING(whether to support SOCKS5)
551 AC_ARG_WITH(socks5,
552   [[  --with-socks5[=DIR]     with SOCKS5 support [search in DIR/lib and DIR/include]]],
553   [
554     case "$withval" in
555       no)
556         AC_MSG_RESULT(no)
557         ;;
558       *)
559         AC_MSG_RESULT(yes)
560         socks=5
561
562         if test -d "$withval/include"; then
563           CFLAGS="$CFLAGS -I$withval/include"
564         else
565           CFLAGS="$CFLAGS -I$withval"
566         fi
567         if test -d "$withval/lib"; then
568           withval="-L$withval/lib -lsocks5"
569         else
570           withval="-L$withval -lsocks5"
571         fi
572
573         LIBS="$withval $LIBS"
574         AC_TRY_LINK([],
575           [
576             SOCKSconnect();
577           ], [],
578           [
579             AC_MSG_ERROR(Could not find SOCKS5 library.)
580           ])
581         ;;
582     esac
583   ],
584     AC_MSG_RESULT(no)
585   )
586
587 if test "x$socks" = "x4"; then
588   AC_DEFINE(SOCKS)
589   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
590 fi
591
592 if test "x$socks" = "x5"; then
593   AC_DEFINE(SOCKS)
594   AC_DEFINE(SOCKS5)
595   AC_DEFINE(Rconnect, SOCKSconnect)
596   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
597   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
598   AC_DEFINE(Rbind, SOCKSbind)
599   AC_DEFINE(Raccept, SOCKSaccept)
600   AC_DEFINE(Rlisten, SOCKSlisten)
601   AC_DEFINE(Rselect, SOCKSselect)
602   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
603   AC_DEFINE(Rsendto, SOCKSsendto)
604   AC_DEFINE(Rrecv, SOCKSrecv)
605   AC_DEFINE(Rsend, SOCKSsend)
606   AC_DEFINE(Rread, SOCKSread)
607   AC_DEFINE(Rwrite, SOCKSwrite)
608   AC_DEFINE(Rrresvport, SOCKSrresvport)
609   AC_DEFINE(Rshutdown, SOCKSshutdown)
610   AC_DEFINE(Rlisten, SOCKSlisten)
611   AC_DEFINE(Rclose, SOCKSclose)
612   AC_DEFINE(Rdup, SOCKSdup)
613   AC_DEFINE(Rdup2, SOCKSdup2)
614   AC_DEFINE(Rfclose, SOCKSfclose)
615   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
616 fi
617
618 # MP library checking. First check whether user wants to use GMP and use
619 # it if found. If not or not defined then compile the MPI library in the
620 # source tree.
621 #
622 mp_gmp=false
623 AC_MSG_CHECKING(whether to support GMP)
624 AC_ARG_WITH(gmp,
625   [[  --with-gmp[=DIR]        use GMP instead of MPI [search in DIR/lib and DIR/include]]],
626   [
627     case "$withval" in
628       no)
629         AC_MSG_RESULT(no)
630         ;;
631       *)
632         AC_MSG_RESULT(yes)
633     
634         if test -d "$withval/include"; then
635           CFLAGS="$CFLAGS -I$withval/include"
636         else
637           CFLAGS="$CFLAGS -I$withval"
638         fi
639         if test -d "$withval/lib"; then
640           withval="-L$withval/lib -lgmp"
641         else
642           withval="-L$withval -lgmp"
643         fi
644     
645         LIBS="$withval $LIBS"
646         AC_CHECK_LIB(gmp, __gmpz_init,
647           [
648             mp_gmp=true
649             AC_DEFINE(SILC_MP_GMP)
650             AC_MSG_RESULT(Using GMP as a MP library.)
651           ])
652         ;;
653     esac
654   ],
655     AC_MSG_RESULT(no)
656   )
657
658 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
659 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
660 if test x$mp_gmp = xfalse; then
661   AC_DEFINE(SILC_MP_NSS_MPI)
662   AC_MSG_RESULT(Using NSS MPI as a MP library.)
663 fi
664
665 # iconv support
666 #
667 AC_ARG_WITH(iconv,
668   [[  --with-iconv[=DIR]      use libiconv [search in DIR/include and DIR/lib]]],
669   [
670     if test -d $dir/include; then
671       CPPFLAGS="$CPPFLAGS -I$dir/include"
672       CFLAGS="$CFLAGS -I$dir/include"
673     fi
674     if test -d $dir/lib; then
675       LDFLAGS="$LDFLAGS -L$dir/lib"
676     fi
677   ])
678
679 AC_CHECK_HEADER(iconv.h,
680   [
681     AC_DEFINE(HAVE_ICONV_H, 1, [Define if you have the iconv.h header.])
682     AC_CHECK_FUNC(iconv, ac_iconv_found=1,
683       [
684         LIBS="$LIBS -liconv"
685         AC_MSG_CHECKING(for iconv in -liconv)
686         AC_TRY_LINK(
687           [
688             #include <stdlib.h>
689             #include <iconv.h>
690           ],
691           [
692             iconv_t cd = iconv_open("", "");
693             iconv(cd, NULL, NULL, NULL, NULL);
694             iconv_close(cd);
695           ],
696           [
697             echo "yes"
698             AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
699           ])
700       ])
701    ])
702
703 if test x$ac_iconv_found = x1; then
704
705   # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
706   # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
707   #     obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
708   #
709   AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
710     AC_TRY_RUN(
711       [
712         #include <iconv.h>
713         int main() {
714           iconv_t cd;
715         changequote(, )dnl
716           char buf[4];
717         changequote([, ])dnl
718           char *ob;
719           size_t obl;
720           ob = buf, obl = sizeof(buf);
721           return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
722                  (iconv(cd, 0, 0, &ob, &obl) ||
723                  !(ob == buf && obl == sizeof(buf)) ||
724                  iconv_close(cd)));
725         }
726       ],
727       [
728         ac_iconv_good=yes
729       ],
730       [
731         ac_iconv_good=no
732       ],
733       [
734         ac_iconv_good=yes
735       ])
736     )
737
738   if test x$ac_iconv_good = xno; then
739     AC_MSG_ERROR(Try using libiconv instead.)
740   fi
741 fi
742
743 # Native WIN32 compilation under cygwin
744 #
745 AC_ARG_WITH(win32,
746   [  --with-win32            compile native WIN32 code (-mno-cygwin)],
747   [
748     AC_DEFINE(SILC_WIN32)
749     win32_support=true
750     CFLAGS="-mno-cygwin $CFLAGS"
751     LIBS="$LIBS -lwsock32"
752   ])
753 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
754
755 # Native EPOC support (disabled by default)
756 #
757 AM_CONDITIONAL(SILC_EPOC, test xfalse = xtrue)
758
759 # Native BeOS support (disabled by default)
760 #
761 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
762
763 # Native OS2 support (disabled by default)
764 #
765 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
766
767 # --without-irssi
768 #
769 without_irssi=false
770 AC_ARG_WITH(irssi,
771   [  --without-irssi         compile without Irssi SILC Client],
772   [
773     without_irssi=true
774     SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/irssi//'`
775   ])
776
777 # --without-silcd
778 #
779 without_silcd=false
780 AC_ARG_WITH(silcd,
781   [  --without-silcd         compile without SILC Server],
782   [
783     without_silcd=true
784     SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/silcd//'`
785   ])
786
787
788 ##
789 ##  Misc
790 ##
791
792 # Other configure scripts
793 #
794 if test x$without_irssi = xfalse; then
795   if test "x$silc_dist" = "xsilc-client" ||
796      test "x$silc_dist" = "xsilc-toolkit"; then
797     AC_CONFIG_SUBDIRS(irssi)
798   fi
799 fi
800
801 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
802 #AC_CONFIG_SUBDIRS(lib/zlib)
803
804 SILC_TOP_SRCDIR=`pwd`
805 AC_SUBST(SILC_TOP_SRCDIR)
806 #SILC_INSTALL_PREFIX=$ac_default_prefix
807 #AC_SUBST(SILC_INSTALL_PREFIX)
808 AC_SUBST(LIBS)
809 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
810 AC_SUBST(INCLUDE_DEFINES_INT)
811 AC_SUBST(SILC_DIST_SUBDIRS)
812
813 # Makefile outputs
814 #
815 AC_CONFIG_FILES(
816 Makefile
817 Makefile.defines
818 Makefile.defines_int
819 doc/Makefile
820 includes/Makefile
821 lib/Makefile
822 lib/contrib/Makefile
823 lib/silccore/Makefile
824 lib/silccrypt/Makefile
825 lib/silcmath/Makefile
826 lib/silcmath/mpi/Makefile.defines
827 lib/silcmath/mpi/Makefile.defines_int
828 lib/silcsim/Makefile
829 lib/silcske/Makefile
830 lib/silcutil/Makefile
831 lib/silcutil/unix/Makefile
832 lib/silcutil/win32/Makefile
833 lib/silcutil/beos/Makefile
834 lib/silcutil/os2/Makefile
835 lib/silcutil/epoc/Makefile
836 lib/silcsftp/Makefile
837 lib/silcsftp/tests/Makefile
838 doc/example_silcd.conf
839 )
840
841 if test "x$silc_dist" = "xsilc-client" ||
842    test "x$silc_dist" = "xsilc-toolkit"; then
843   AC_CONFIG_FILES(lib/silcclient/Makefile)
844 fi
845
846 if test x$without_irssi = xfalse ; then
847   if test "x$silc_dist" = "xsilc-client" ||
848      test "x$silc_dist" = "xsilc-toolkit"; then
849     AC_CONFIG_FILES(
850 irssi/Makefile.defines
851 irssi/Makefile.defines_int
852 )
853   fi
854 fi
855
856 if test x$without_silcd = xfalse ; then
857   if test "x$silc_dist" = "xsilc-server" ||
858      test "x$silc_dist" = "xsilc-toolkit"; then
859     AC_CONFIG_FILES(
860 silcd/Makefile
861 )
862   fi
863 fi
864
865 if test "x$silc_dist" = "xsilc-toolkit"; then
866   AC_CONFIG_FILES(
867 silc/Makefile
868 win32/Makefile
869 win32/libsilc/Makefile
870 win32/libsilcclient/Makefile
871 )
872 fi
873
874 AC_OUTPUT