make it compile on mingw32.
[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 #
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 AC_PROG_LIBTOOL
62
63 # Header checking
64 AC_HEADER_STDC
65 AC_HEADER_TIME
66 AC_HEADER_STAT
67
68 # More header checking
69 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
70 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
71 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
72 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
73 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h)
74 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h)
75
76 # Data type checking
77 AC_TYPE_SIGNAL
78 AC_TYPE_SIZE_T
79 AC_TYPE_MODE_T
80 AC_TYPE_UID_T
81 AC_TYPE_PID_T
82
83 AC_CHECK_SIZEOF(long long, 0)
84 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
85 AC_CHECK_SIZEOF(long, 0)
86 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
87 AC_CHECK_SIZEOF(int, 0)
88 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
89 AC_CHECK_SIZEOF(short, 0)
90 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
91 AC_CHECK_SIZEOF(char, 0)
92 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
93 AC_CHECK_SIZEOF(void *, 0)
94 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
95
96 dnl Curses detection: Munged from Midnight Commander's configure.in
97 AC_DEFUN(AC_CHECK_CURSES,[
98         search_ncurses=true
99         screen_manager=""
100         has_curses=false
101
102         CFLAGS=${CFLAGS--O}
103
104         AC_SUBST(CURSES_LIBS)
105         AC_SUBST(CURSES_INCLUDEDIR)
106
107         AC_ARG_WITH(sunos-curses,
108           [  --with-sunos-curses     Used to force SunOS 4.x curses],[
109           if test x$withval = xyes; then
110                 AC_USE_SUNOS_CURSES
111           fi
112         ])
113
114         AC_ARG_WITH(osf1-curses,
115           [  --with-osf1-curses      Used to force OSF/1 curses],[
116           if test x$withval = xyes; then
117                 AC_USE_OSF1_CURSES
118           fi
119         ])
120
121         AC_ARG_WITH(vcurses,
122           [  --with-vcurses[=incdir] Used to force SysV curses],
123           if test x$withval != xyes; then
124                 CURSES_INCLUDEDIR="-I$withval"
125           fi
126           AC_USE_SYSV_CURSES
127         )
128
129         AC_ARG_WITH(ncurses,
130           [  --with-ncurses[=dir]    Compile with ncurses/locate base dir],
131           if test x$withval = xno ; then
132                 search_ncurses=false
133           elif test x$withval != xyes ; then
134                 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
135           fi
136         )
137
138         if $search_ncurses
139         then
140                 AC_SEARCH_NCURSES()
141         fi
142 ])
143
144
145 AC_DEFUN(AC_USE_SUNOS_CURSES, [
146         search_ncurses=false
147         screen_manager="SunOS 4.x /usr/5include curses"
148         AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
149         AC_DEFINE(USE_SUNOS_CURSES)
150         AC_DEFINE(HAS_CURSES)
151         has_curses=true
152         AC_DEFINE(NO_COLOR_CURSES)
153         AC_DEFINE(USE_SYSV_CURSES)
154         CURSES_INCLUDEDIR="-I/usr/5include"
155         CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
156         AC_MSG_RESULT(Please note that some screen refreshs may fail)
157 ])
158
159 AC_DEFUN(AC_USE_OSF1_CURSES, [
160        AC_MSG_RESULT(Using OSF1 curses)
161        search_ncurses=false
162        screen_manager="OSF1 curses"
163        AC_DEFINE(HAS_CURSES)
164        has_curses=true
165        AC_DEFINE(NO_COLOR_CURSES)
166        AC_DEFINE(USE_SYSV_CURSES)
167        CURSES_LIBS="-lcurses"
168 ])
169
170 AC_DEFUN(AC_USE_SYSV_CURSES, [
171         AC_MSG_RESULT(Using SysV curses)
172         AC_DEFINE(HAS_CURSES)
173         has_curses=true
174         AC_DEFINE(USE_SYSV_CURSES)
175         search_ncurses=false
176         screen_manager="SysV/curses"
177         CURSES_LIBS="-lcurses"
178 ])
179
180 dnl
181 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
182 dnl
183 AC_DEFUN(AC_NCURSES, [
184     if $search_ncurses
185     then
186         if test -f $1/$2
187         then
188             AC_MSG_RESULT(Found ncurses on $1/$2)
189
190             CURSES_LIBS="$3"
191             AC_CHECK_LIB(ncurses, initscr, , [
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(chmod stat fstat getenv putenv strerror ctime gettimeofday)
295 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid setgroups initgroups)
296 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
297 AC_CHECK_FUNCS(pthread_create)
298
299 # SIM support checking
300 # XXX These needs to be changed as more supported platforms appear.
301 # XXX This probably needs to be made platform dependant check.
302 sim_support=false
303 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
304 AC_CHECKING(for SIM support)
305 AC_CHECK_HEADERS(dlfcn.h, 
306   AC_CHECK_LIB(dl, dlopen, 
307     AC_DEFINE(SILC_SIM) 
308     sim_support=true
309     AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
310     AC_MSG_RESULT(enabled SIM support)
311     LIBS="$LIBS -ldl",
312     AC_MSG_RESULT(no SIM support found)),
313   AC_MSG_RESULT(no SIM support found))
314
315 #
316 # Installation
317 #
318
319 # Default installation destination
320 AC_PREFIX_DEFAULT(/usr/local/silc)
321
322 if test "x$prefix" != xNONE; then
323         silc_prefix="$prefix"
324 else
325         silc_prefix="$ac_default_prefix"
326 fi
327
328 # etc directory
329 #ETCDIR="/etc/silc"
330 if test "x$sysconfdir" != 'x${prefix}/etc'; then
331         ETCDIR="$sysconfdir"
332 else
333         ETCDIR="$silc_prefix/etc"
334 fi
335 AC_ARG_WITH(etcdir,
336 [  --with-etcdir[=PATH]    Directory for system files [/etc/silc]],
337 [ case "$withval" in
338   no)
339     ;;
340   yes)
341     ETCDIR="$withval"
342     ;;
343   *)
344     ETCDIR="$withval"
345     ;;
346   esac ],
347 )
348 AC_SUBST(ETCDIR)
349 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
350
351 # help directory
352 #HELPDIR="help"
353 HELPDIR="$silc_prefix/help"
354 AC_ARG_WITH(helpdir,
355 [  --with-helpdir[=PATH]   Directory for SILC help files [PREFIX/help]],
356 [ case "$withval" in
357   no)
358     ;;
359   yes)
360     HELPDIR="$withval"
361     ;;
362   *)
363     HELPDIR="$withval"
364     ;;
365   esac ],
366 )
367 AC_SUBST(HELPDIR)
368 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
369
370 # doc directory
371 #DOCDIR="doc"
372 DOCDIR="$silc_prefix/doc"
373 AC_ARG_WITH(docdir,
374 [  --with-docdir[=PATH]    Directory for SILC documentation [PREFIX/doc]],
375 [ case "$withval" in
376   no)
377     ;;
378   yes)
379     DOCDIR="$withval"
380     ;;
381   *)
382     DOCDIR="$withval"
383     ;;
384   esac ],
385 )
386 AC_SUBST(DOCDIR)
387 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
388
389 # SIM modules directory
390 #MODULESDIR="modules"
391 MODULESDIR="$silc_prefix/modules"
392 AC_ARG_WITH(simdir,
393 [  --with-simdir[=PATH]    Directory for SIM modules [PREFIX/modules]],
394 [ case "$withval" in
395   no)
396     ;;
397   yes)
398     MODULESDIR="$withval"
399     ;;
400   *)
401     MODULESDIR="$withval"
402     ;;
403   esac ],
404 )
405 AC_SUBST(MODULESDIR)
406 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
407
408 # Logs directory
409 #LOGSDIR="logs"
410 LOGSDIR="$silc_prefix/logs"
411 AC_ARG_WITH(logsdir,
412 [  --with-logsdir[=PATH]   Directory for Server logs [PREFIX/logs]],
413 [ case "$withval" in
414   no)
415     ;;
416   yes)
417     LOGSDIR="$withval"
418     ;;
419   *)
420     LOGSDIR="$withval"
421     ;;
422   esac ],
423 )
424 AC_SUBST(LOGSDIR)
425 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
426
427 # SOCKS4 support checking
428 AC_MSG_CHECKING(whether to support SOCKS4)
429 AC_ARG_WITH(socks4,
430 [  --with-socks4[=PATH]    Compile with SOCKS4 support],
431 [ case "$withval" in
432   no)
433     AC_MSG_RESULT(no)
434     ;;
435   *)
436     AC_MSG_RESULT(yes)
437     socks=4
438
439     if test -d "$withval/include"; then
440       CFLAGS="$CFLAGS -I$withval/include"
441     else
442       CFLAGS="$CFLAGS -I$withval"
443     fi
444     if test -d "$withval/lib"; then
445       withval="-L$withval/lib -lsocks"
446     else
447       withval="-L$withval -lsocks"
448     fi
449
450     LIBS="$withval $LIBS"
451
452     AC_TRY_LINK([],
453                 [ Rconnect(); ],
454                 [],
455                 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
456       ;;
457   esac ],
458   AC_MSG_RESULT(no)
459 )   
460
461 # SOCKS5 support checking
462 AC_MSG_CHECKING(whether to support SOCKS5)
463 AC_ARG_WITH(socks5,
464 [  --with-socks5[=PATH]    Compile with SOCKS5 support],
465 [ case "$withval" in
466   no)
467     AC_MSG_RESULT(no)
468     ;;
469   *)
470     AC_MSG_RESULT(yes)
471     socks=5
472
473     if test -d "$withval/include"; then
474       CFLAGS="$CFLAGS -I$withval/include"
475     else
476       CFLAGS="$CFLAGS -I$withval"
477     fi
478     if test -d "$withval/lib"; then
479       withval="-L$withval/lib -lsocks5"
480     else
481       withval="-L$withval -lsocks5"
482     fi 
483
484     LIBS="$withval $LIBS"
485
486     AC_TRY_LINK([],
487                 [ SOCKSconnect(); ],
488                 [],
489                 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
490       ;;
491   esac ],
492   AC_MSG_RESULT(no)
493 )   
494
495 if test "x$socks" = "x4"; then
496   AC_DEFINE(SOCKS)
497   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
498 fi
499
500 if test "x$socks" = "x5"; then
501   AC_DEFINE(SOCKS)
502   AC_DEFINE(SOCKS5)
503   AC_DEFINE(Rconnect, SOCKSconnect)
504   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
505   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
506   AC_DEFINE(Rbind, SOCKSbind)
507   AC_DEFINE(Raccept, SOCKSaccept)
508   AC_DEFINE(Rlisten, SOCKSlisten)
509   AC_DEFINE(Rselect, SOCKSselect)
510   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
511   AC_DEFINE(Rsendto, SOCKSsendto)
512   AC_DEFINE(Rrecv, SOCKSrecv)
513   AC_DEFINE(Rsend, SOCKSsend)
514   AC_DEFINE(Rread, SOCKSread)
515   AC_DEFINE(Rwrite, SOCKSwrite)
516   AC_DEFINE(Rrresvport, SOCKSrresvport)
517   AC_DEFINE(Rshutdown, SOCKSshutdown)
518   AC_DEFINE(Rlisten, SOCKSlisten)
519   AC_DEFINE(Rclose, SOCKSclose)
520   AC_DEFINE(Rdup, SOCKSdup)
521   AC_DEFINE(Rdup2, SOCKSdup2)
522   AC_DEFINE(Rfclose, SOCKSfclose)
523   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
524 fi
525
526 #
527 # MP library checking. First check whether user wants to use GMP and use
528 # it if found. If not or not defined then compile the MPI library in the
529 # source tree.
530 #
531 AC_MSG_CHECKING(whether to support GMP)
532 AC_ARG_WITH(gmp,
533 [  --with-gmp[=PATH]       Compile with GMP support instead of MPI],
534 [ case "$withval" in
535   no)
536     AC_MSG_RESULT(no)
537     mp_gmp=false
538     ;;
539   *)
540     AC_MSG_RESULT(yes)
541
542     if test -d "$withval/include"; then
543       CFLAGS="$CFLAGS -I$withval/include"
544     else
545       CFLAGS="$CFLAGS -I$withval"
546     fi
547     if test -d "$withval/lib"; then
548       withval="-L$withval/lib -lgmp"
549     else
550       withval="-L$withval -lgmp"
551     fi
552
553     LIBS="$withval $LIBS"
554     mp_gmp=false
555     AC_CHECK_LIB(gmp, __gmpz_init,
556       mp_gmp=true
557       AC_DEFINE(SILC_MP_GMP)
558       AC_MSG_RESULT(Using GMP as MP library)
559     )
560       ;;
561   esac ],
562   AC_MSG_RESULT(no)
563   mp_gmp=false
564 )
565
566 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
567 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
568 if test x$mp_gmp = xfalse; then
569   AC_DEFINE(SILC_MP_NSS_MPI)
570   AC_MSG_RESULT(Using NSS MPI as MP library)
571 fi
572
573 AC_ARG_WITH(silcd-config-file,
574 [  --with-silcd-config-file[=PATH]
575                           Use PATH as default configuration file in SILC
576                           server [/etc/silc/silcd.conf]],
577 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
578
579 if test "x$localstatedir" != 'x${prefix}/var'; then
580         PIDFILE="$localstatedir/silcd.pid"
581 else
582         PIDFILE="$silc_prefix/var/silcd.pid"
583 fi
584 AC_ARG_WITH(silcd-pid-file,
585 [  --with-silcd-pid-file[=PATH]
586                           Use PATH as default pid file in SILC
587                           server [/var/run/silcd.pid]],
588 [ case "$withval" in
589         no)
590                 ;;
591         yes)
592                 PIDFILE="$withval"
593                 ;;
594         *)
595                 PIDFILE="$withval"
596                 ;;
597         esac ],
598 )
599 AC_SUBST(PIDFILE)
600
601 #
602 # Native WIN32 compilation under cygwin
603 #
604 AC_ARG_WITH(win32,
605 [  --with-win32            Compile native WIN32 code (-mno-cygwin)],
606 [ AC_DEFINE(SILC_WIN32)
607   win32_support=true
608   CFLAGS="-mno-cygwin $CFLAGS" 
609   LIBS="$LIBS -lwsock32" ])
610
611 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
612
613 #
614 # Native EPOC support (disabled by default)
615 #
616 AM_CONDITIONAL(SILC_EPOC, test xfalse = xtrue)
617
618 #
619 # Native BeOS support (disabled by default)
620 #
621 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
622
623 #
624 # Native OS2 support (disabled by default)
625 #
626 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
627
628 #
629 # IPv6 support
630 #
631 AC_MSG_CHECKING(for IPv6 support)
632 AC_ARG_ENABLE(ipv6,
633 [  --enable-ipv6           Enable IPv6 support],
634 [ case "${enableval}" in
635   yes) 
636     want_ipv6=true
637     check_ipv6=false
638     AC_DEFINE(HAVE_IPV6)
639     AC_MSG_RESULT(yes)
640     ;;
641   *)
642     want_ipv6=false
643     check_ipv6=false
644     AC_MSG_RESULT(no)
645     ;;
646 esac ], check_ipv6=true)
647
648 if test x$check_ipv6 = xtrue; then
649   AC_TRY_COMPILE([#ifdef HAVE_NETINET_TCP_H
650                   #include <netinet/tcp.h>
651                   #endif
652                   #ifdef HAVE_NETDB_H
653                   #include <netdb.h>
654                   #endif
655                   #include <sys/socket.h>
656                   #ifdef HAVE_NETDB_IN_H
657                   #include <netinet/in.h>
658                   #endif],
659                   [struct sockaddr_in6 sin6;
660                    int family = AF_INET6;
661                   ], [AC_DEFINE(HAVE_IPV6)
662                       AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
663 fi
664
665 #
666 # Debug checking
667 #
668 AC_MSG_CHECKING(for enabled debugging)
669 AC_ARG_ENABLE(debug,
670 [  --enable-debug          Enable debugging],
671 [ case "${enableval}" in
672   yes) 
673     AC_MSG_RESULT(yes)
674     AC_DEFINE(SILC_DEBUG)
675     CFLAGS="-O -g $CFLAGS"
676     ;;
677   *)
678     AC_MSG_RESULT(no)
679     CFLAGS="-O2 -g $CFLAGS"
680     ;;
681 esac ], CFLAGS="-O2 -g $CFLAGS"
682         AC_MSG_RESULT(no))
683
684 #
685 # Disable all assembler optimizations
686 #
687 AC_ARG_ENABLE(asm,
688 [  --disable-asm           Do not use assembler optimizations ],
689 [])
690
691 #
692 # Threads support
693 #
694 AC_ARG_ENABLE(threads,
695 [  --disable-threads       Do not compile with multi-thread support],
696 [ case "${enableval}" in
697   yes)
698     want_threads=true
699     check_threads=true
700     ;;
701   *)
702     want_threads=false
703     check_threads=false
704     ;;
705 esac ])
706
707 if test x$check_threads = xtrue; then
708 want_threads=false
709 AC_CHECK_HEADERS(pthread.h, 
710         [ AC_DEFINE(SILC_HAVE_PTHREAD) 
711           want_threads=true ],
712         [ if test -f /usr/pkg/include/pthread.h ; then
713             AC_DEFINE(SILC_HAVE_PTHREAD)
714             AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
715             CFLAGS="$CFLAGS -I/usr/pkg/include"
716             want_threads=true
717           elif test -f /usr/contrib/include/pthread.h ; then
718             AC_DEFINE(SILC_HAVE_PTHREAD)
719             AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
720             CFLAGS="$CFLAGS -I/usr/contrib/include"
721             want_threads=true
722           fi
723         ])
724
725 AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
726 if test x$want_threads = xtrue; then
727   TMP_LIBS="$LIBS"
728   LIBS="-lpthread"
729   AC_TRY_LINK([#include <pthread.h>],
730               [pthread_attr_t attr; pthread_attr_init(&attr);], 
731   AC_DEFINE(SILC_THREADS),
732   LIBS="-L/usr/pkg/lib -lpthread"
733   AC_TRY_LINK([#include <pthread.h>],
734               [pthread_attr_t attr; pthread_attr_init(&attr);],
735   AC_DEFINE(SILC_THREADS),
736   LIBS="-L/usr/contrib/lib -lpthread"
737   AC_TRY_LINK([#include <pthread.h>],
738               [pthread_attr_t attr; pthread_attr_init(&attr);], 
739   AC_DEFINE(SILC_THREADS),
740   LIBS=""
741   )))
742
743   CFLAGS="$CFLAGS -D_REENTRANT"
744   case $host in
745     *-aix*)
746       CFLAGS="$CFLAGS -D_THREAD_SAFE"
747       if test x"$GCC" = xyes; then
748         CFLAGS="$CFLAGS -mthreads"  
749       fi
750       ;;
751     *-freebsd2.2*)
752       CFLAGS="$CFLAGS -D_THREAD_SAFE"
753       ;;
754     *-sysv5uw7*)  # UnixWare 7
755       if test "$GCC" != "yes"; then
756         CFLAGS="$CFLAGS -Kthread"
757       else
758         CFLAGS="$CFLAGS -pthread"
759       fi
760       ;;
761     *-dg-dgux*)  # DG/UX
762       CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
763       ;;
764     esac
765
766   LIBS="$TMP_LIBS $LIBS"
767 fi
768 fi
769
770 #
771 # Other configure scripts
772 #
773 if test "x$silc_dist" = "xsilc-client" || 
774    test "x$silc_dist" = "xsilc-toolkit"; then
775 AC_CONFIG_SUBDIRS(irssi)
776 fi
777 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
778 #AC_CONFIG_SUBDIRS(lib/zlib)
779
780 SILC_TOP_SRCDIR=`pwd`
781 AC_SUBST(SILC_TOP_SRCDIR)
782 #SILC_INSTALL_PREFIX=$ac_default_prefix
783 #AC_SUBST(SILC_INSTALL_PREFIX)
784 AC_SUBST(LIBS)
785 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
786 AC_SUBST(INCLUDE_DEFINES_INT)
787
788 #
789 # Makefile outputs
790 #
791 AC_CONFIG_FILES( \
792 Makefile
793 Makefile.defines
794 Makefile.defines_int
795 doc/Makefile  
796 includes/Makefile
797 lib/Makefile
798 lib/contrib/Makefile
799 lib/silccore/Makefile
800 lib/silccrypt/Makefile 
801 lib/silcmath/Makefile
802 lib/silcmath/mpi/Makefile.defines
803 lib/silcmath/mpi/Makefile.defines_int
804 lib/silcsim/Makefile
805 lib/silcske/Makefile
806 lib/silcutil/Makefile
807 lib/silcutil/unix/Makefile
808 lib/silcutil/win32/Makefile
809 lib/silcutil/beos/Makefile
810 lib/silcutil/os2/Makefile
811 lib/silcutil/epoc/Makefile
812 lib/silcsftp/Makefile
813 lib/silcsftp/tests/Makefile
814 doc/example_silcd.conf
815 )
816
817 if test "x$silc_dist" = "xsilc-client" || 
818    test "x$silc_dist" = "xsilc-toolkit"; then
819 AC_CONFIG_FILES( \
820 lib/silcclient/Makefile
821 irssi/Makefile.defines
822 irssi/Makefile.defines_int
823 )
824 fi
825
826 if test "x$silc_dist" = "xsilc-server" ||
827    test "x$silc_dist" = "xsilc-toolkit"; then
828 AC_CONFIG_FILES( \
829 silcd/Makefile
830 )
831 fi
832
833 if test "x$silc_dist" = "xsilc-toolkit"; then
834 AC_CONFIG_FILES( \
835 silc/Makefile
836 win32/Makefile
837 win32/libsilc/Makefile
838 win32/libsilcclient/Makefile
839 )
840 fi
841
842 AC_OUTPUT