updates.
[silc.git] / configure.in.pre
1 #
2 #  configure.in
3 #
4 #  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
5 #
6 #  Copyright (C) 2000 - 2001 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/version.h)
20
21 #
22 # Put here any platform specific stuff
23 #
24 AC_CANONICAL_SYSTEM
25 case "$target" in
26   *-*-*bsd*)
27     check_threads=false
28     ;;
29   *)
30     check_threads=true
31     ;;
32 esac
33
34 # ./prepare script will automatically put the correct version. Do not edit!
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 silc_dist=SILC_PACKAGE
49 AC_DEFINE(SILC_DIST_DEFINE)
50
51 # XXX
52 # Compiler flags
53 if test "$GCC"; then
54   CFLAGS="-Wall -finline-functions $CFLAGS"
55 fi
56
57 # Program checking
58 AC_PROG_INSTALL
59 AC_PROG_RANLIB
60 AC_PROG_MAKE_SET
61
62 # Header checking
63 AC_HEADER_STDC
64 AC_HEADER_TIME
65 AC_HEADER_STAT
66
67 # More header checking
68 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
69 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h)
70 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
71 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
72 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h)
73 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h)
74
75 # Data type checking
76 AC_TYPE_SIGNAL
77 AC_TYPE_SIZE_T
78 AC_TYPE_MODE_T
79 AC_TYPE_UID_T
80 AC_TYPE_PID_T
81
82 AC_CHECK_SIZEOF(long long, 0)
83 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
84 AC_CHECK_SIZEOF(long, 0)
85 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
86 AC_CHECK_SIZEOF(int, 0)
87 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
88 AC_CHECK_SIZEOF(short, 0)
89 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
90 AC_CHECK_SIZEOF(char, 0)
91 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
92 AC_CHECK_SIZEOF(void *, 0)
93 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
94
95 dnl Curses detection: Munged from Midnight Commander's configure.in
96 AC_DEFUN(AC_CHECK_CURSES,[
97         search_ncurses=true
98         screen_manager=""
99         has_curses=false
100
101         CFLAGS=${CFLAGS--O}
102
103         AC_SUBST(CURSES_LIBS)
104         AC_SUBST(CURSES_INCLUDEDIR)
105
106         AC_ARG_WITH(sunos-curses,
107           [  --with-sunos-curses     Used to force SunOS 4.x curses],[
108           if test x$withval = xyes; then
109                 AC_USE_SUNOS_CURSES
110           fi
111         ])
112
113         AC_ARG_WITH(osf1-curses,
114           [  --with-osf1-curses      Used to force OSF/1 curses],[
115           if test x$withval = xyes; then
116                 AC_USE_OSF1_CURSES
117           fi
118         ])
119
120         AC_ARG_WITH(vcurses,
121           [  --with-vcurses[=incdir] Used to force SysV curses],
122           if test x$withval != xyes; then
123                 CURSES_INCLUDEDIR="-I$withval"
124           fi
125           AC_USE_SYSV_CURSES
126         )
127
128         AC_ARG_WITH(ncurses,
129           [  --with-ncurses[=dir]    Compile with ncurses/locate base dir],
130           if test x$withval = xno ; then
131                 search_ncurses=false
132           elif test x$withval != xyes ; then
133                 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
134           fi
135         )
136
137         if $search_ncurses
138         then
139                 AC_SEARCH_NCURSES()
140         fi
141 ])
142
143
144 AC_DEFUN(AC_USE_SUNOS_CURSES, [
145         search_ncurses=false
146         screen_manager="SunOS 4.x /usr/5include curses"
147         AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
148         AC_DEFINE(USE_SUNOS_CURSES)
149         AC_DEFINE(HAS_CURSES)
150         has_curses=true
151         AC_DEFINE(NO_COLOR_CURSES)
152         AC_DEFINE(USE_SYSV_CURSES)
153         CURSES_INCLUDEDIR="-I/usr/5include"
154         CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
155         AC_MSG_RESULT(Please note that some screen refreshs may fail)
156 ])
157
158 AC_DEFUN(AC_USE_OSF1_CURSES, [
159        AC_MSG_RESULT(Using OSF1 curses)
160        search_ncurses=false
161        screen_manager="OSF1 curses"
162        AC_DEFINE(HAS_CURSES)
163        has_curses=true
164        AC_DEFINE(NO_COLOR_CURSES)
165        AC_DEFINE(USE_SYSV_CURSES)
166        CURSES_LIBS="-lcurses"
167 ])
168
169 AC_DEFUN(AC_USE_SYSV_CURSES, [
170         AC_MSG_RESULT(Using SysV curses)
171         AC_DEFINE(HAS_CURSES)
172         has_curses=true
173         AC_DEFINE(USE_SYSV_CURSES)
174         search_ncurses=false
175         screen_manager="SysV/curses"
176         CURSES_LIBS="-lcurses"
177 ])
178
179 dnl
180 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
181 dnl
182 AC_DEFUN(AC_NCURSES, [
183     if $search_ncurses
184     then
185         if test -f $1/$2
186         then
187             AC_MSG_RESULT(Found ncurses on $1/$2)
188
189             CURSES_LIBS="$3"
190             AC_CHECK_LIB(ncurses, initscr, , [
191                 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
192                 AC_CHECK_LIB(curses, initscr, [
193                         CURSES_LIBS="$CHECKLIBS"
194                 ],, $CHECKLIBS)
195             ], $CURSES_LIBS)
196             CURSES_INCLUDEDIR="$4"
197             search_ncurses=false
198             screen_manager=$5
199             AC_DEFINE(HAS_CURSES)
200             has_curses=true
201             has_ncurses=true
202             AC_DEFINE(USE_NCURSES)
203         fi
204     fi
205 ])
206
207 AC_DEFUN(AC_SEARCH_NCURSES, [
208     AC_CHECKING("location of ncurses.h file")
209
210     AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
211     AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
212     AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
213     AC_NCURSES(/usr/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
214     AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
215     AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
216
217     AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
218
219     AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
220
221     dnl
222     dnl We couldn't find ncurses, try SysV curses
223     dnl
224     if $search_ncurses 
225     then
226         AC_EGREP_HEADER(init_color, /usr/include/curses.h,
227             AC_USE_SYSV_CURSES)
228         AC_EGREP_CPP(USE_NCURSES,[
229 #include <curses.h>
230 #ifdef __NCURSES_H
231 #undef USE_NCURSES
232 USE_NCURSES
233 #endif
234 ],[
235         CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
236         AC_DEFINE(HAS_CURSES)
237         has_curses=true
238         has_ncurses=true
239         AC_DEFINE(USE_NCURSES)
240         search_ncurses=false
241         screen_manager="ncurses installed as curses"
242 ])
243     fi
244
245     dnl
246     dnl Try SunOS 4.x /usr/5{lib,include} ncurses
247     dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
248     dnl should be replaced by a more fine grained selection routine
249     dnl
250     if $search_ncurses
251     then
252         if test -f /usr/5include/curses.h
253         then
254             AC_USE_SUNOS_CURSES
255         fi
256     fi
257
258     dnl use whatever curses there happens to be
259     if $search_ncurses
260     then
261         if test -f /usr/include/curses.h
262         then
263           CURSES_LIBS="-lcurses"
264           AC_DEFINE(HAS_CURSES)
265           has_curses=true
266           search_ncurses=false
267           screen_manager="curses"
268         fi
269     fi
270 ])
271
272 AC_CHECK_CURSES
273 LIBS="$LIBS $CURSES_LIBS"
274
275 # Function and library checking
276 AC_CHECK_FUNC(gethostbyname, ac_gethostbyname_found=1,
277 ac_gethostbyname_found=0)
278 if test x$ac_gethostbyname_found = x0; then
279     AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
280     AC_CHECK_FUNC(res_gethostbyname, ac_res_ghbn_found=1, ac_res_ghbn_found=0)
281     if test x$ac_res_ghbn_found = x0; then
282         AC_CHECK_LIB(resolv, res_gethostbyname,  LIBS="$LIBS -lresolv")
283     fi
284 fi
285 AC_CHECK_FUNC(socket, ac_socket_found=1, ac_socket_found=0)
286 if test x$ac_socket_found = x0; then
287     AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
288 fi
289 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
290 AC_CHECK_FUNCS(select listen bind shutdown close connect)
291 AC_CHECK_FUNCS(fcntl setsockopt)
292 AC_CHECK_FUNCS(getopt_long time)
293 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
294 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
295 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
296 AC_CHECK_FUNCS(pthread_create)
297
298 # SIM support checking
299 # XXX These needs to be changed as more supported platforms appear.
300 # XXX This probably needs to be made platform dependant check.
301 sim_support=false
302 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
303 AC_CHECKING(for SIM support)
304 AC_CHECK_HEADERS(dlfcn.h, 
305   AC_CHECK_LIB(dl, dlopen, 
306     AC_DEFINE(SILC_SIM) 
307     sim_support=true
308     AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
309     AC_MSG_RESULT(enabled SIM support)
310     LIBS="$LIBS -ldl",
311     AC_MSG_RESULT(no SIM support found)),
312   AC_MSG_RESULT(no SIM support found))
313
314 #
315 # Installation
316 #
317
318 # Default installation destination
319 AC_PREFIX_DEFAULT(/usr/local/silc)
320
321 if test "x$prefix" != xNONE; then
322         silc_prefix="$prefix"
323 else
324         silc_prefix="$ac_default_prefix"
325 fi
326
327 # etc directory
328 #ETCDIR="/etc/silc"
329 if test "x$sysconfdir" != 'x${prefix}/etc'; then
330         ETCDIR="$sysconfdir"
331 else
332         ETCDIR="$silc_prefix/etc"
333 fi
334 AC_ARG_WITH(etcdir,
335 [  --with-etcdir[=PATH]    Directory for system files [/etc/silc]],
336 [ case "$withval" in
337   no)
338     ;;
339   yes)
340     ETCDIR="$withval"
341     ;;
342   *)
343     ETCDIR="$withval"
344     ;;
345   esac ],
346 )
347 AC_SUBST(ETCDIR)
348 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
349
350 # help directory
351 #HELPDIR="help"
352 HELPDIR="$silc_prefix/help"
353 AC_ARG_WITH(helpdir,
354 [  --with-helpdir[=PATH]   Directory for SILC help files [PREFIX/help]],
355 [ case "$withval" in
356   no)
357     ;;
358   yes)
359     HELPDIR="$withval"
360     ;;
361   *)
362     HELPDIR="$withval"
363     ;;
364   esac ],
365 )
366 AC_SUBST(HELPDIR)
367 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
368
369 # doc directory
370 #DOCDIR="doc"
371 DOCDIR="$silc_prefix/doc"
372 AC_ARG_WITH(docdir,
373 [  --with-docdir[=PATH]    Directory for SILC documentation [PREFIX/doc]],
374 [ case "$withval" in
375   no)
376     ;;
377   yes)
378     DOCDIR="$withval"
379     ;;
380   *)
381     DOCDIR="$withval"
382     ;;
383   esac ],
384 )
385 AC_SUBST(DOCDIR)
386 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
387
388 # SIM modules directory
389 #MODULESDIR="modules"
390 MODULESDIR="$silc_prefix/modules"
391 AC_ARG_WITH(simdir,
392 [  --with-simdir[=PATH]    Directory for SIM modules [PREFIX/modules]],
393 [ case "$withval" in
394   no)
395     ;;
396   yes)
397     MODULESDIR="$withval"
398     ;;
399   *)
400     MODULESDIR="$withval"
401     ;;
402   esac ],
403 )
404 AC_SUBST(MODULESDIR)
405 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
406
407 # Logs directory
408 #LOGSDIR="logs"
409 LOGSDIR="$silc_prefix/logs"
410 AC_ARG_WITH(logsdir,
411 [  --with-logsdir[=PATH]   Directory for Server logs [PREFIX/logs]],
412 [ case "$withval" in
413   no)
414     ;;
415   yes)
416     LOGSDIR="$withval"
417     ;;
418   *)
419     LOGSDIR="$withval"
420     ;;
421   esac ],
422 )
423 AC_SUBST(LOGSDIR)
424 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
425
426 # SOCKS4 support checking
427 AC_MSG_CHECKING(whether to support SOCKS4)
428 AC_ARG_WITH(socks4,
429 [  --with-socks4[=PATH]    Compile with SOCKS4 support],
430 [ case "$withval" in
431   no)
432     AC_MSG_RESULT(no)
433     ;;
434   *)
435     AC_MSG_RESULT(yes)
436     socks=4
437
438     if test -d "$withval/include"; then
439       CFLAGS="$CFLAGS -I$withval/include"
440     else
441       CFLAGS="$CFLAGS -I$withval"
442     fi
443     if test -d "$withval/lib"; then
444       withval="-L$withval/lib -lsocks"
445     else
446       withval="-L$withval -lsocks"
447     fi
448
449     LIBS="$withval $LIBS"
450
451     AC_TRY_LINK([],
452                 [ Rconnect(); ],
453                 [],
454                 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
455       ;;
456   esac ],
457   AC_MSG_RESULT(no)
458 )   
459
460 # SOCKS5 support checking
461 AC_MSG_CHECKING(whether to support SOCKS5)
462 AC_ARG_WITH(socks5,
463 [  --with-socks5[=PATH]    Compile with SOCKS5 support],
464 [ case "$withval" in
465   no)
466     AC_MSG_RESULT(no)
467     ;;
468   *)
469     AC_MSG_RESULT(yes)
470     socks=5
471
472     if test -d "$withval/include"; then
473       CFLAGS="$CFLAGS -I$withval/include"
474     else
475       CFLAGS="$CFLAGS -I$withval"
476     fi
477     if test -d "$withval/lib"; then
478       withval="-L$withval/lib -lsocks5"
479     else
480       withval="-L$withval -lsocks5"
481     fi 
482
483     LIBS="$withval $LIBS"
484
485     AC_TRY_LINK([],
486                 [ SOCKSconnect(); ],
487                 [],
488                 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
489       ;;
490   esac ],
491   AC_MSG_RESULT(no)
492 )   
493
494 if test "x$socks" = "x4"; then
495   AC_DEFINE(SOCKS)
496   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
497 fi
498
499 if test "x$socks" = "x5"; then
500   AC_DEFINE(SOCKS)
501   AC_DEFINE(SOCKS5)
502   AC_DEFINE(Rconnect, SOCKSconnect)
503   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
504   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
505   AC_DEFINE(Rbind, SOCKSbind)
506   AC_DEFINE(Raccept, SOCKSaccept)
507   AC_DEFINE(Rlisten, SOCKSlisten)
508   AC_DEFINE(Rselect, SOCKSselect)
509   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
510   AC_DEFINE(Rsendto, SOCKSsendto)
511   AC_DEFINE(Rrecv, SOCKSrecv)
512   AC_DEFINE(Rsend, SOCKSsend)
513   AC_DEFINE(Rread, SOCKSread)
514   AC_DEFINE(Rwrite, SOCKSwrite)
515   AC_DEFINE(Rrresvport, SOCKSrresvport)
516   AC_DEFINE(Rshutdown, SOCKSshutdown)
517   AC_DEFINE(Rlisten, SOCKSlisten)
518   AC_DEFINE(Rclose, SOCKSclose)
519   AC_DEFINE(Rdup, SOCKSdup)
520   AC_DEFINE(Rdup2, SOCKSdup2)
521   AC_DEFINE(Rfclose, SOCKSfclose)
522   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
523 fi
524
525 #
526 # MP library checking. First check whether user wants to use GMP and use
527 # it if found. If not or not defined then compile the MPI library in the
528 # source tree.
529 #
530 AC_MSG_CHECKING(whether to support GMP)
531 AC_ARG_WITH(gmp,
532 [  --with-gmp[=PATH]       Compile with GMP support instead of MPI],
533 [ case "$withval" in
534   no)
535     AC_MSG_RESULT(no)
536     mp_gmp=false
537     ;;
538   *)
539     AC_MSG_RESULT(yes)
540
541     if test -d "$withval/include"; then
542       CFLAGS="$CFLAGS -I$withval/include"
543     else
544       CFLAGS="$CFLAGS -I$withval"
545     fi
546     if test -d "$withval/lib"; then
547       withval="-L$withval/lib -lgmp"
548     else
549       withval="-L$withval -lgmp"
550     fi
551
552     LIBS="$withval $LIBS"
553     mp_gmp=false
554     AC_CHECK_LIB(gmp, __gmpz_init,
555       mp_gmp=true
556       AC_DEFINE(SILC_MP_GMP)
557       AC_MSG_RESULT(Using GMP as MP library)
558     )
559       ;;
560   esac ],
561   AC_MSG_RESULT(no)
562   mp_gmp=false
563 )
564
565 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
566 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
567 if test x$mp_gmp = xfalse; then
568   AC_DEFINE(SILC_MP_NSS_MPI)
569   AC_MSG_RESULT(Using NSS MPI as MP library)
570 fi
571
572 AC_ARG_WITH(silcd-config-file,
573 [  --with-silcd-config-file[=PATH]
574                           Use PATH as default configuration file in SILC
575                           server [/etc/silc/silcd.conf]],
576 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
577
578 #
579 # Native WIN32 compilation under cygwin
580 #
581 AC_ARG_WITH(win32,
582 [  --with-win32            Compile native WIN32 code (-mno-cygwin)],
583 [ AC_DEFINE(SILC_WIN32)
584   win32-support = true
585   CFLAGS="-mno-cygwin $CFLAGS" 
586   LIBS="$LIBS -lwsock32" ])
587
588 AM_CONDITIONAL(SILC_WIN32, test x$win32-support = xtrue)
589
590 #
591 # Debug checking
592 #
593 AC_MSG_CHECKING(for enabled debugging)
594 AC_ARG_ENABLE(debug,
595 [  --enable-debug          Enable debugging (warning: it is heavy!)],
596 [ case "${enableval}" in
597   yes) 
598     AC_MSG_RESULT(yes)
599     AC_DEFINE(SILC_DEBUG)
600     CFLAGS="-O -g $CFLAGS"
601     ;;
602   *)
603     AC_MSG_RESULT(no)
604     CFLAGS="-O2 -g $CFLAGS"
605     ;;
606 esac ], CFLAGS="-O2 -g $CFLAGS"
607         AC_MSG_RESULT(no))
608
609 #
610 # Disable all assembler optimizations
611 #
612 AC_ARG_ENABLE(asm,
613 [  --disable-asm           Do not use assembler optimizations ],
614 [])
615
616 #
617 # Threads support
618 #
619 AC_ARG_ENABLE(threads,
620 [  --disable-threads       Do not compile with multi-thread support],
621 [ case "${enableval}" in
622   yes)
623     want_threads=true
624     check_threads=true
625     ;;
626   *)
627     want_threads=false
628     check_threads=false
629     ;;
630 esac ])
631
632 if test x$check_threads = xtrue; then
633 want_threads=false
634 AC_CHECK_HEADERS(pthread.h, 
635         [ AC_DEFINE(SILC_HAVE_PTHREAD) 
636           want_threads=true ],
637         [ if test -f /usr/pkg/include/pthread.h ; then
638             AC_DEFINE(SILC_HAVE_PTHREAD)
639             AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
640             CFLAGS="$CFLAGS -I/usr/pkg/include"
641             want_threads=true
642           elif test -f /usr/contrib/include/pthread.h ; then
643             AC_DEFINE(SILC_HAVE_PTHREAD)
644             AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
645             CFLAGS="$CFLAGS -I/usr/contrib/include"
646             want_threads=true
647           fi
648         ])
649
650 AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
651 if test x$want_threads = xtrue; then
652   TMP_LIBS="$LIBS"
653   LIBS="-lpthread"
654   AC_TRY_LINK([#include <pthread.h>],
655               [pthread_attr_t attr; pthread_attr_init(&attr);], 
656   AC_DEFINE(SILC_THREADS),
657   LIBS="-L/usr/pkg/lib -lpthread"
658   AC_TRY_LINK([#include <pthread.h>],
659               [pthread_attr_t attr; pthread_attr_init(&attr);],
660   AC_DEFINE(SILC_THREADS),
661   LIBS="-L/usr/contrib/lib -lpthread"
662   AC_TRY_LINK([#include <pthread.h>],
663               [pthread_attr_t attr; pthread_attr_init(&attr);], 
664   AC_DEFINE(SILC_THREADS),
665   LIBS=""
666   )))
667
668   CFLAGS="$CFLAGS -D_REENTRANT"
669   case $host in
670     *-aix*)
671       CFLAGS="$CFLAGS -D_THREAD_SAFE"
672       if test x"$GCC" = xyes; then
673         CFLAGS="$CFLAGS -mthreads"  
674       fi
675       ;;
676     *-freebsd2.2*)
677       CFLAGS="$CFLAGS -D_THREAD_SAFE"
678       ;;
679     *-sysv5uw7*)  # UnixWare 7
680       if test "$GCC" != "yes"; then
681         CFLAGS="$CFLAGS -Kthread"
682       else
683         CFLAGS="$CFLAGS -pthread"
684       fi
685       ;;
686     *-dg-dgux*)  # DG/UX
687       CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
688       ;;
689     esac
690
691   LIBS="$TMP_LIBS $LIBS"
692 fi
693 fi
694
695 #
696 # Other configure scripts
697 #
698 AC_CONFIG_SUBDIRS(lib/dotconf)
699 AC_CONFIG_SUBDIRS(lib/trq)
700 AC_CONFIG_SUBDIRS(irssi)
701 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
702 #AC_CONFIG_SUBDIRS(lib/zlib)
703
704 SILC_TOP_SRCDIR=`pwd`
705 AC_SUBST(SILC_TOP_SRCDIR)
706 #SILC_INSTALL_PREFIX=$ac_default_prefix
707 #AC_SUBST(SILC_INSTALL_PREFIX)
708 AC_SUBST(LIBS)
709 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
710 AC_SUBST(INCLUDE_DEFINES_INT)
711
712 #
713 # Makefile outputs
714 #
715 AC_CONFIG_FILES( \
716 Makefile
717 Makefile.defines
718 Makefile.defines_int
719 doc/Makefile  
720 includes/Makefile
721 lib/Makefile
722 lib/contrib/Makefile
723 lib/silccore/Makefile
724 lib/silccrypt/Makefile 
725 lib/silcmath/Makefile
726 lib/silcmath/mpi/Makefile.defines
727 lib/silcmath/mpi/Makefile.defines_int
728 lib/silcsim/Makefile
729 lib/silcsim/modules/Makefile
730 lib/silcske/Makefile
731 lib/silcutil/Makefile
732 lib/silcutil/unix/Makefile
733 lib/silcutil/win32/Makefile
734 lib/silcsftp/Makefile
735 lib/silcsftp/tests/Makefile
736 doc/example_silc.conf
737 doc/example_silcd.conf
738 )     
739
740 if test "x$silc_dist" = "xsilc-client" || 
741    test "x$silc_dist" = "xsilc-toolkit"; then
742 AC_CONFIG_FILES( \
743 lib/silcclient/Makefile
744 irssi/Makefile.defines
745 irssi/Makefile.defines_int
746 )
747 fi
748
749 if test "x$silc_dist" = "xsilc-server" ||
750    test "x$silc_dist" = "xsilc-toolkit"; then
751 AC_CONFIG_FILES( \
752 silcd/Makefile
753 )
754 fi
755
756 if test "x$silc_dist" = "xsilc-toolkit"; then
757 AC_CONFIG_FILES( \
758 silc/Makefile
759 win32/Makefile
760 win32/libsilc/Makefile
761 win32/libsilcclient/Makefile
762 )
763 fi
764
765 AC_OUTPUT