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.3)
37 AM_CONFIG_HEADER(includes/silcdefs.h)
38
39 AC_PROG_CC
40 AC_C_INLINE
41 AC_C_CONST
42 AC_ARG_PROGRAM
43
44 AC_PROG_LN_S
45 AC_SUBST(LN_S)
46
47 # Distribution definition. ./prepare will automatically add here a correct
48 # value. Do not edit!
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             ], [
192                 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
193                 AC_CHECK_LIB(curses, initscr, [
194                         CURSES_LIBS="$CHECKLIBS"
195                 ],, $CHECKLIBS)
196             ], $CURSES_LIBS)
197             CURSES_INCLUDEDIR="$4"
198             search_ncurses=false
199             screen_manager=$5
200             AC_DEFINE(HAS_CURSES)
201             has_curses=true
202             has_ncurses=true
203             AC_DEFINE(USE_NCURSES)
204         fi
205     fi
206 ])
207
208 AC_DEFUN(AC_SEARCH_NCURSES, [
209     AC_CHECKING("location of ncurses.h file")
210
211     AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
212     AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
213     AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
214     AC_NCURSES(/usr/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
215     AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
216     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")
217
218     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")
219
220     AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
221
222     dnl
223     dnl We couldn't find ncurses, try SysV curses
224     dnl
225     if $search_ncurses 
226     then
227         AC_EGREP_HEADER(init_color, /usr/include/curses.h,
228             AC_USE_SYSV_CURSES)
229         AC_EGREP_CPP(USE_NCURSES,[
230 #include <curses.h>
231 #ifdef __NCURSES_H
232 #undef USE_NCURSES
233 USE_NCURSES
234 #endif
235 ],[
236         CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
237         AC_DEFINE(HAS_CURSES)
238         has_curses=true
239         has_ncurses=true
240         AC_DEFINE(USE_NCURSES)
241         search_ncurses=false
242         screen_manager="ncurses installed as curses"
243 ])
244     fi
245
246     dnl
247     dnl Try SunOS 4.x /usr/5{lib,include} ncurses
248     dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
249     dnl should be replaced by a more fine grained selection routine
250     dnl
251     if $search_ncurses
252     then
253         if test -f /usr/5include/curses.h
254         then
255             AC_USE_SUNOS_CURSES
256         fi
257     fi
258
259     dnl use whatever curses there happens to be
260     if $search_ncurses
261     then
262         if test -f /usr/include/curses.h
263         then
264           CURSES_LIBS="-lcurses"
265           AC_DEFINE(HAS_CURSES)
266           has_curses=true
267           search_ncurses=false
268           screen_manager="curses"
269         fi
270     fi
271 ])
272
273 AC_CHECK_CURSES
274 LIBS="$LIBS $CURSES_LIBS"
275
276 # Function and library checking
277 AC_CHECK_FUNC(gethostbyname, ac_gethostbyname_found=1,
278 ac_gethostbyname_found=0)
279 if test x$ac_gethostbyname_found = x0; then
280     AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
281     AC_CHECK_FUNC(res_gethostbyname, ac_res_ghbn_found=1, ac_res_ghbn_found=0)
282     if test x$ac_res_ghbn_found = x0; then
283         AC_CHECK_LIB(resolv, res_gethostbyname,  LIBS="$LIBS -lresolv")
284     fi
285 fi
286 AC_CHECK_FUNC(socket, ac_socket_found=1, ac_socket_found=0)
287 if test x$ac_socket_found = x0; then
288     AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
289 fi
290 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
291 AC_CHECK_FUNCS(select listen bind shutdown close connect)
292 AC_CHECK_FUNCS(fcntl setsockopt)
293 AC_CHECK_FUNCS(getopt_long time)
294 AC_CHECK_FUNCS(mlock munlock)
295 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
296 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
297 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
298 AC_CHECK_FUNCS(pthread_create)
299
300 # SIM support checking
301 # XXX These needs to be changed as more supported platforms appear.
302 # XXX This probably needs to be made platform dependant check.
303 sim_support=false
304 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
305 AC_CHECKING(for SIM support)
306 AC_CHECK_HEADERS(dlfcn.h, 
307   AC_CHECK_LIB(dl, dlopen, 
308     AC_DEFINE(SILC_SIM) 
309     sim_support=true
310     AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
311     AC_MSG_RESULT(enabled SIM support)
312     LIBS="$LIBS -ldl",
313     AC_MSG_RESULT(no SIM support found)),
314   AC_MSG_RESULT(no SIM support found))
315
316 #
317 # Installation
318 #
319
320 # Default installation destination
321 AC_PREFIX_DEFAULT(/usr/local/silc)
322
323 # etc directory
324 ETCDIR="/etc/silc"
325 AC_ARG_WITH(etcdir,
326 [  --with-etcdir[=PATH]    Directory for system files [/etc/silc]],
327 [ case "$withval" in
328   no)
329     ;;
330   yes)
331     ETCDIR="$withval"
332     ;;
333   *)
334     ETCDIR="$withval"
335     ;;
336   esac ],
337 )
338 AC_SUBST(ETCDIR)
339 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
340
341 # help directory
342 HELPDIR="help"
343 AC_ARG_WITH(helpdir,
344 [  --with-helpdir[=PATH]   Directory for SILC help files [PREFIX/help]],
345 [ case "$withval" in
346   no)
347     ;;
348   yes)
349     HELPDIR="$withval"
350     ;;
351   *)
352     HELPDIR="$withval"
353     ;;
354   esac ],
355 )
356 AC_SUBST(HELPDIR)
357 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
358
359 # doc directory
360 DOCDIR="doc"
361 AC_ARG_WITH(docdir,
362 [  --with-docdir[=PATH]    Directory for SILC documentation [PREFIX/doc]],
363 [ case "$withval" in
364   no)
365     ;;
366   yes)
367     DOCDIR="$withval"
368     ;;
369   *)
370     DOCDIR="$withval"
371     ;;
372   esac ],
373 )
374 AC_SUBST(DOCDIR)
375 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
376
377 # SIM modules directory
378 MODULESDIR="modules"
379 AC_ARG_WITH(simdir,
380 [  --with-simdir[=PATH]    Directory for SIM modules [PREFIX/modules]],
381 [ case "$withval" in
382   no)
383     ;;
384   yes)
385     MODULESDIR="$withval"
386     ;;
387   *)
388     MODULESDIR="$withval"
389     ;;
390   esac ],
391 )
392 AC_SUBST(MODULESDIR)
393 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
394
395 # Logs directory
396 LOGSDIR="logs"
397 AC_ARG_WITH(logsdir,
398 [  --with-logsdir[=PATH]   Directory for Server logs [PREFIX/logs]],
399 [ case "$withval" in
400   no)
401     ;;
402   yes)
403     LOGSDIR="$withval"
404     ;;
405   *)
406     LOGSDIR="$withval"
407     ;;
408   esac ],
409 )
410 AC_SUBST(LOGSDIR)
411 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
412
413 # SOCKS4 support checking
414 AC_MSG_CHECKING(whether to support SOCKS4)
415 AC_ARG_WITH(socks4,
416 [  --with-socks4[=PATH]    Compile with SOCKS4 support],
417 [ case "$withval" in
418   no)
419     AC_MSG_RESULT(no)
420     ;;
421   *)
422     AC_MSG_RESULT(yes)
423     socks=4
424
425     if test -d "$withval/include"; then
426       CFLAGS="$CFLAGS -I$withval/include"
427     else
428       CFLAGS="$CFLAGS -I$withval"
429     fi
430     if test -d "$withval/lib"; then
431       withval="-L$withval/lib -lsocks"
432     else
433       withval="-L$withval -lsocks"
434     fi
435
436     LIBS="$withval $LIBS"
437
438     AC_TRY_LINK([],
439                 [ Rconnect(); ],
440                 [],
441                 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
442       ;;
443   esac ],
444   AC_MSG_RESULT(no)
445 )   
446
447 # SOCKS5 support checking
448 AC_MSG_CHECKING(whether to support SOCKS5)
449 AC_ARG_WITH(socks5,
450 [  --with-socks5[=PATH]    Compile with SOCKS5 support],
451 [ case "$withval" in
452   no)
453     AC_MSG_RESULT(no)
454     ;;
455   *)
456     AC_MSG_RESULT(yes)
457     socks=5
458
459     if test -d "$withval/include"; then
460       CFLAGS="$CFLAGS -I$withval/include"
461     else
462       CFLAGS="$CFLAGS -I$withval"
463     fi
464     if test -d "$withval/lib"; then
465       withval="-L$withval/lib -lsocks5"
466     else
467       withval="-L$withval -lsocks5"
468     fi 
469
470     LIBS="$withval $LIBS"
471
472     AC_TRY_LINK([],
473                 [ SOCKSconnect(); ],
474                 [],
475                 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
476       ;;
477   esac ],
478   AC_MSG_RESULT(no)
479 )   
480
481 if test "x$socks" = "x4"; then
482   AC_DEFINE(SOCKS)
483   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
484 fi
485
486 if test "x$socks" = "x5"; then
487   AC_DEFINE(SOCKS)
488   AC_DEFINE(SOCKS5)
489   AC_DEFINE(Rconnect, SOCKSconnect)
490   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
491   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
492   AC_DEFINE(Rbind, SOCKSbind)
493   AC_DEFINE(Raccept, SOCKSaccept)
494   AC_DEFINE(Rlisten, SOCKSlisten)
495   AC_DEFINE(Rselect, SOCKSselect)
496   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
497   AC_DEFINE(Rsendto, SOCKSsendto)
498   AC_DEFINE(Rrecv, SOCKSrecv)
499   AC_DEFINE(Rsend, SOCKSsend)
500   AC_DEFINE(Rread, SOCKSread)
501   AC_DEFINE(Rwrite, SOCKSwrite)
502   AC_DEFINE(Rrresvport, SOCKSrresvport)
503   AC_DEFINE(Rshutdown, SOCKSshutdown)
504   AC_DEFINE(Rlisten, SOCKSlisten)
505   AC_DEFINE(Rclose, SOCKSclose)
506   AC_DEFINE(Rdup, SOCKSdup)
507   AC_DEFINE(Rdup2, SOCKSdup2)
508   AC_DEFINE(Rfclose, SOCKSfclose)
509   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
510 fi
511
512 #
513 # MP library checking. First check whether user wants to use GMP and use
514 # it if found. If not or not defined then compile the MPI library in the
515 # source tree.
516 #
517 AC_MSG_CHECKING(whether to support GMP)
518 AC_ARG_WITH(gmp,
519 [  --with-gmp[=PATH]       Compile with GMP support instead of MPI],
520 [ case "$withval" in
521   no)
522     AC_MSG_RESULT(no)
523     mp_gmp=false
524     ;;
525   *)
526     AC_MSG_RESULT(yes)
527
528     if test -d "$withval/include"; then
529       CFLAGS="$CFLAGS -I$withval/include"
530     else
531       CFLAGS="$CFLAGS -I$withval"
532     fi
533     if test -d "$withval/lib"; then
534       withval="-L$withval/lib -lgmp"
535     else
536       withval="-L$withval -lgmp"
537     fi
538
539     LIBS="$withval $LIBS"
540     mp_gmp=false
541     AC_CHECK_LIB(gmp, __gmpz_init,
542       mp_gmp=true
543       AC_DEFINE(SILC_MP_GMP)
544       AC_MSG_RESULT(Using GMP as MP library)
545     )
546       ;;
547   esac ],
548   AC_MSG_RESULT(no)
549   mp_gmp=false
550 )
551
552 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
553 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
554 if test x$mp_gmp = xfalse; then
555   AC_DEFINE(SILC_MP_NSS_MPI)
556   AC_MSG_RESULT(Using NSS MPI as MP library)
557 fi
558
559 AC_ARG_WITH(silcd-config-file,
560 [  --with-silcd-config-file[=PATH]
561                           Use PATH as default configuration file in SILC
562                           server [/etc/silc/silcd.conf]],
563 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
564
565 #
566 # Native WIN32 compilation under cygwin
567 #
568 AC_ARG_WITH(win32,
569 [  --with-win32            Compile native WIN32 code (-mno-cygwin)],
570 [ AC_DEFINE(SILC_WIN32)
571   win32-support = true
572   CFLAGS="-mno-cygwin $CFLAGS" 
573   LIBS="$LIBS -lwsock32" ])
574
575 AM_CONDITIONAL(SILC_WIN32, test x$win32-support = xtrue)
576
577 #
578 # Debug checking
579 #
580 AC_MSG_CHECKING(for enabled debugging)
581 AC_ARG_ENABLE(debug,
582 [  --enable-debug          Enable debugging (warning: it is heavy!)],
583 [ case "${enableval}" in
584   yes) 
585     AC_MSG_RESULT(yes)
586     AC_DEFINE(SILC_DEBUG)
587     CFLAGS="-O -g $CFLAGS"
588     ;;
589   *)
590     AC_MSG_RESULT(no)
591     CFLAGS="-O2 -g $CFLAGS"
592     ;;
593 esac ], CFLAGS="-O2 -g $CFLAGS"
594         AC_MSG_RESULT(no))
595
596 #
597 # Threads support
598 #
599 AC_ARG_ENABLE(threads,
600 [  --disable-threads       Do not compile with multi-thread support],
601 [ case "${enableval}" in
602   yes)
603     want_threads=true
604     check_threads=true
605     ;;
606   *)
607     want_threads=false
608     check_threads=false
609     ;;
610 esac ])
611
612 if test x$check_threads = xtrue; then
613 want_threads=false
614 AC_CHECK_HEADERS(pthread.h, 
615         [ AC_DEFINE(SILC_HAVE_PTHREAD) 
616           want_threads=true ],
617         [ if test -f /usr/pkg/include/pthread.h ; then
618             AC_DEFINE(SILC_HAVE_PTHREAD)
619             AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
620             CFLAGS="$CFLAGS -I/usr/pkg/include"
621             want_threads=true
622           elif test -f /usr/contrib/include/pthread.h ; then
623             AC_DEFINE(SILC_HAVE_PTHREAD)
624             AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
625             CFLAGS="$CFLAGS -I/usr/contrib/include"
626             want_threads=true
627           fi
628         ])
629
630 AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
631 if test x$want_threads = xtrue; then
632   TMP_LIBS="$LIBS"
633   LIBS="-lpthread"
634   AC_TRY_LINK([#include <pthread.h>],
635               [pthread_attr_t attr; pthread_attr_init(&attr);], 
636   AC_DEFINE(SILC_THREADS),
637   LIBS="-L/usr/pkg/lib -lpthread"
638   AC_TRY_LINK([#include <pthread.h>],
639               [pthread_attr_t attr; pthread_attr_init(&attr);],
640   AC_DEFINE(SILC_THREADS),
641   LIBS="-L/usr/contrib/lib -lpthread"
642   AC_TRY_LINK([#include <pthread.h>],
643               [pthread_attr_t attr; pthread_attr_init(&attr);], 
644   AC_DEFINE(SILC_THREADS),
645   LIBS=""
646   )))
647
648   CFLAGS="$CFLAGS -D_REENTRANT"
649   case $host in
650     *-aix*)
651       CFLAGS="$CFLAGS -D_THREAD_SAFE"
652       if test x"$GCC" = xyes; then
653         CFLAGS="$CFLAGS -mthreads"  
654       fi
655       ;;
656     *-freebsd2.2*)
657       CFLAGS="$CFLAGS -D_THREAD_SAFE"
658       ;;
659     *-sysv5uw7*)  # UnixWare 7
660       if test "$GCC" != "yes"; then
661         CFLAGS="$CFLAGS -Kthread"
662       else
663         CFLAGS="$CFLAGS -pthread"
664       fi
665       ;;
666     *-dg-dgux*)  # DG/UX
667       CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
668       ;;
669     esac
670
671   LIBS="$TMP_LIBS $LIBS"
672 fi
673 fi
674
675 #
676 # Other configure scripts
677 #
678 AC_CONFIG_SUBDIRS(lib/dotconf)
679 AC_CONFIG_SUBDIRS(lib/trq)
680 AC_CONFIG_SUBDIRS(irssi)
681 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
682 #AC_CONFIG_SUBDIRS(lib/zlib)
683
684 SILC_TOP_SRCDIR=`pwd`
685 AC_SUBST(SILC_TOP_SRCDIR)
686 #SILC_INSTALL_PREFIX=$ac_default_prefix
687 #AC_SUBST(SILC_INSTALL_PREFIX)
688 AC_SUBST(LIBS)
689 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
690 AC_SUBST(INCLUDE_DEFINES_INT)
691
692 #
693 # Makefile outputs
694 #
695 AC_OUTPUT( \
696 Makefile
697 Makefile.defines
698 Makefile.defines_int
699 irssi/Makefile.defines
700 irssi/Makefile.defines_int
701 doc/Makefile
702 doc/whitepaper/Makefile
703 includes/Makefile
704 lib/Makefile
705 lib/contrib/Makefile
706 lib/silcclient/Makefile
707 lib/silccore/Makefile
708 lib/silccrypt/Makefile
709 lib/silcmath/Makefile
710 lib/silcmath/mpi/Makefile.defines
711 lib/silcmath/mpi/Makefile.defines_int
712 lib/silcsim/Makefile
713 lib/silcsim/modules/Makefile
714 lib/silcske/Makefile
715 lib/silcutil/Makefile
716 lib/silcutil/unix/Makefile
717 lib/silcutil/win32/Makefile
718 silc/Makefile
719 silcd/Makefile
720 win32/Makefile
721 win32/libsilc/Makefile
722 win32/libsilcclient/Makefile)