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