updates.
[silc.git] / configure.ad
1 #
2 #  configure.ad
3 #
4 #  Author: Pekka Riikonen <priikone@silcnet.org>
5 #
6 #  Copyright (C) 2000 - 2007 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; version 2 of the License.
11 #
12 #  This program is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #  GNU General Public License for more details.
16 #
17
18 AD_INIT
19 AC_CANONICAL_SYSTEM
20 AM_INIT_AUTOMAKE
21 AC_PREREQ(2.52)
22 AC_CONFIG_HEADERS(silcdefs.h)
23
24 AC_PROG_INSTALL
25 AC_PROG_MAKE_SET
26
27 AC_PROG_LN_S
28 AC_PROG_EGREP
29 AC_SUBST(LN_S)
30 AC_PATH_PROG(sedpath, sed)
31
32 #ifdef SILC_DIST_COMPILER
33
34 # Put here any platform specific stuff
35 #
36 case "$target" in
37   *-*-linux*)
38     check_threads=true
39     CFLAGS=`echo $CFLAGS -D_GNU_SOURCE`
40     ;;
41   *-*-freebsd*)
42     check_threads=true
43     ;;
44   *-*-netbsd*)
45     check_threads=true
46     ;;
47   *-*-*bsd*)
48     check_threads=false
49     ;;
50   *)
51     check_threads=true
52     ;;
53 esac
54
55 # Get CPU
56 SILC_SYSTEM_IS_SMP(AC_DEFINE([SILC_SMP], [], [SILC_SMP]), [],
57                    AC_DEFINE([SILC_SMP], [], [SILC_SMP]))
58 cpu_i386=false
59 cpu_i486=false
60 cpu_i586=false
61 cpu_i686=false
62 cpu_i786=false
63 cpu_x86_64=false
64 cpu_ppc=false
65 cpu_ia64=false
66 case "$host_cpu" in
67   # All following Intels are considered 32-bit CPUs.
68   i?86)
69     AC_DEFINE([SILC_I386], [], [SILC_I386])
70     AC_DEFINE([SILC_I486], [], [SILC_I486])
71     cpu_i386=true
72     cpu_i486=true
73
74     if test "x$host_cpu" = "xi586"; then
75       AC_DEFINE([SILC_I586], [], [SILC_I586])
76       cpu_i586=true
77     fi
78
79     if test "x$host_cpu" = "xi686"; then
80       AC_DEFINE([SILC_I586], [], [SILC_I586])
81       AC_DEFINE([SILC_I686], [], [SILC_I686])
82       cpu_i586=true
83       cpu_i686=true
84     fi
85
86     if test "x$host_cpu" = "xi786"; then
87       AC_DEFINE([SILC_I586], [], [SILC_I586])
88       AC_DEFINE([SILC_I686], [], [SILC_I686])
89       AC_DEFINE([SILC_I786], [], [SILC_I786])
90       cpu_i586=true
91       cpu_i686=true
92       cpu_i786=true
93     fi
94
95     # Check for specific CPU features
96     SILC_CPU_FLAG(sse2, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
97     SILC_CPU_FLAG(sse3, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
98     SILC_CPU_FLAG(ssse3, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
99     ;;
100
101   # Intel IA-64, 64-bit CPU (not x86_64 compatible)
102   ia64)
103     AC_DEFINE([SILC_IA64], [], [SILC_IA64])
104     cpu_ia64=true
105
106     # Check for specific CPU features
107     SILC_CPU_FLAG(sse2, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
108     SILC_CPU_FLAG(sse3, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
109     SILC_CPU_FLAG(ssse3, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
110     ;;
111
112   # AMD/Intel x86_64, 64-bit CPU
113   x86_64)
114     AC_DEFINE([SILC_X86_64], [], [SILC_X86_64])
115     cpu_x86_64=true
116
117     # Check for specific CPU features
118     SILC_CPU_FLAG(sse2, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
119     SILC_CPU_FLAG(sse3, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
120     SILC_CPU_FLAG(ssse3, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
121     ;;
122
123   # PowerPC, 32-bit and 64-bit CPUs
124   powerpc*)
125     AC_DEFINE([SILC_POWERPC], [], [SILC_POWERPC])
126     cpu_ppc=true
127     ;;
128 esac
129 AM_CONDITIONAL(SILC_I386, test x$cpu_i386 = xtrue)
130 AM_CONDITIONAL(SILC_I486, test x$cpu_i486 = xtrue)
131 AM_CONDITIONAL(SILC_I586, test x$cpu_i586 = xtrue)
132 AM_CONDITIONAL(SILC_I686, test x$cpu_i686 = xtrue)
133 AM_CONDITIONAL(SILC_7686, test x$cpu_i786 = xtrue)
134 AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue)
135 AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue)
136 AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue)
137
138 # Control compiler optimizations
139 CFLAGS=`echo $CFLAGS | sed 's/-O[ 0123456789s]*//g'`
140
141 AC_PROG_CC
142 AC_C_INLINE
143 AC_C_CONST
144
145 # Set some compiler options based on CPU
146 if test x$x_have_cpu_sse2 = xtrue; then
147   SILC_ADD_CFLAGS(-msse2)
148 fi
149 if test x$x_have_cpu_sse3 = xtrue; then
150   SILC_ADD_CFLAGS(-msse3)
151 fi
152 if test x$x_have_cpu_ssse3 = xtrue; then
153   SILC_ADD_CFLAGS(-mssse3)
154 fi
155
156 __SILC_HAVE_PTHREAD=""
157 __SILC_HAVE_SIM=""
158 __SILC_ENABLE_DEBUG=""
159
160 #ifdef SILC_DIST_TOOLKIT
161 toolkitver=`echo $VERSION | sed 's/\./ /g'`
162 maj=0
163 min=0
164 bld=0
165 for v in $toolkitver
166 do
167   if test $maj -eq 0; then
168     maj=$v
169     continue
170   fi
171   if test $min -eq 0; then
172     min=$v
173     continue
174   fi
175   if test $bld -eq 0; then
176     bld=$v
177     continue
178   fi
179 done
180 __SILC_PACKAGE_VERSION="#define __SILC_TOOLKIT_VERSION SILC_VERSION($maj,$min,$bld)"
181 #endif SILC_DIST_TOOLKIT
182
183 AC_PROG_RANLIB
184 #ifndef SILC_DIST_TOOLKIT
185 AC_DISABLE_SHARED
186 #endif SILC_DIST_TOOLKIT
187 #ifdef SILC_DIST_INPLACE
188 AC_DISABLE_SHARED
189 #endif SILC_DIST_INPLACE
190 AC_PROG_LIBTOOL
191
192 # Header checking
193 #
194 AC_HEADER_STDC
195 AC_HEADER_TIME
196 AC_HEADER_STAT
197
198 # More header checking
199 #
200 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
201 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
202 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h sys/resource.h)
203 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
204 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h)
205 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
206
207 # Data type checking
208 #
209 AC_TYPE_SIGNAL
210 AC_TYPE_SIZE_T
211 AC_TYPE_MODE_T
212 AC_TYPE_UID_T
213 AC_TYPE_PID_T
214
215 AC_CHECK_SIZEOF(long long, 0)
216 AC_SUBST(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
217 AC_CHECK_SIZEOF(long, 0)
218 AC_SUBST(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
219 AC_CHECK_SIZEOF(int, 0)
220 AC_SUBST(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
221 AC_CHECK_SIZEOF(short, 0)
222 AC_SUBST(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
223 AC_CHECK_SIZEOF(char, 0)
224 AC_SUBST(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
225 AC_CHECK_SIZEOF(void *, 0)
226 AC_SUBST(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
227 AC_CHECK_TYPES(long long)
228 AC_CHECK_TYPES(long double)
229
230 # Function and library checking
231 #
232 AC_CHECK_FUNC(gethostbyname, [],
233   [
234     AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
235     AC_CHECK_FUNC(res_gethostbyname, [],
236        AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
237     )
238   ])
239 AC_CHECK_FUNC(socket, [],
240   AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
241 )
242 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
243 AC_CHECK_FUNCS(poll select listen bind shutdown close connect setsockopt)
244 AC_CHECK_FUNCS(setrlimit time ctime utime gettimeofday getrusage)
245 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
246 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid sched_yield)
247 AC_CHECK_FUNCS(setgroups initgroups nl_langinfo nanosleep)
248 AC_CHECK_FUNCS(strchr snprintf strstr strcpy strncpy memcpy memset memmove)
249 AC_CHECK_FUNCS(setenv getenv putenv unsetenv clearenv)
250
251 # lib/contrib conditionals
252 #
253 AC_CHECK_HEADER(regex.h,
254   [
255     AC_DEFINE([HAVE_REGEX_H], [], [HAVE_REGEX_H])
256     have_regex=1
257   ], have_regex=0
258 )
259 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
260
261 AC_CHECK_FUNC(getopt_long,
262   [
263     AC_DEFINE([HAVE_GETOPT_LONG], [], [HAVE_GETOPT_LONG])
264     have_getopt_long=1
265   ], have_getopt_long=0
266 )
267
268 AC_CHECK_FUNC(getopt,
269   [
270     AC_DEFINE([HAVE_GETOPT], [], [HAVE_GETOPT])
271     have_getopt=1
272   ], have_getopt=0
273 )
274
275 ##
276 ##  Enable/disable checking
277 ##
278
279 # IPv6 support
280 #
281 AC_MSG_CHECKING(whether to enable IPv6 support)
282 AC_ARG_ENABLE(ipv6,
283   [  --enable-ipv6           enable IPv6 support],
284   [
285     case "${enableval}" in
286       yes)
287         want_ipv6=true
288         check_ipv6=false
289         summary_ipv6="yes"
290         AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
291         AC_MSG_RESULT(yes)
292         ;;
293       *)
294         want_ipv6=false
295         check_ipv6=false
296         summary_ipv6="no"
297         AC_MSG_RESULT(no)
298         ;;
299     esac
300   ],
301     check_ipv6=true
302   )
303
304 if test x$check_ipv6 = xtrue; then
305   summary_ipv6="no"
306   AC_TRY_COMPILE(
307     [
308       #ifdef HAVE_SYS_TYPES_H
309       #include <sys/types.h>
310       #endif
311       #ifdef HAVE_NETINET_TCP_H
312       #include <netinet/tcp.h>
313       #endif
314       #ifdef HAVE_NETDB_H
315       #include <netdb.h>
316       #endif
317       #include <sys/socket.h>
318       #ifdef HAVE_NETINET_IN_H
319       #include <netinet/in.h>
320       #endif
321     ],
322     [
323       struct sockaddr_in6 sin6;
324       int family = AF_INET6;
325     ],
326     [
327       AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
328       AC_MSG_RESULT(yes)
329       summary_ipv6="yes"
330     ],
331       AC_MSG_RESULT(no)
332     )
333 fi
334
335 # Debug checking
336 #
337 AC_MSG_CHECKING(whether to enable debugging)
338 summary_debug="no"
339 __SILC_ENABLE_DEBUG=""
340 AC_ARG_ENABLE(debug,
341   [  --enable-debug          enable debugging],
342   [
343     case "${enableval}" in
344       yes)
345         AC_MSG_RESULT(yes)
346         AC_DEFINE([SILC_DEBUG], [], [enable-debug])
347         summary_debug="yes"
348         __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1"
349         ;;
350       *)
351         AC_MSG_RESULT(no)
352         ;;
353     esac
354   ],
355   [
356     AC_MSG_RESULT(no)
357   ])
358
359 # Disable all compiler optimizations
360 #
361 AC_MSG_CHECKING(whether to enable compiler optimizations)
362 want_cc_optimizations=true
363 AC_ARG_ENABLE(optimizations,
364   [  --disable-optimizations do not use any compiler optimizations],
365   [
366     AC_MSG_RESULT(no)
367     AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS])
368     want_cc_optimizations=false
369   ],
370   [
371     AC_MSG_RESULT(yes)
372     want_cc_optimizations=true
373   ])
374 AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse)
375
376 # Disable all assembler optimizations
377 #
378 AC_MSG_CHECKING(whether to enable assembler optimizations)
379 want_asm=true
380 AC_ARG_ENABLE(asm,
381   [  --disable-asm           do not use assembler optimizations],
382   [
383     AC_MSG_RESULT(no)
384     AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM])
385     want_asm=false
386   ],
387   [
388     AC_MSG_RESULT(yes)
389     want_asm=true
390   ])
391 AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse)
392
393 # Check for assembler
394 #
395 SILC_ASSEMBLER=""
396 have_assembler=false
397 if test x$want_asm = xtrue; then
398   AC_PATH_PROG([NASM], [nasm], [no])
399   if test "x$NASM" != "xno"; then
400     SILC_ASSEMBLER="$NASM -O2 -felf"
401     have_assembler=true
402   fi
403
404   AC_PATH_PROG([YASM], [yasm], [no])
405   if test "x$YASM" != "xno"; then
406     SILC_ASSEMBLER="$YASM -Xgnu -felf"
407     have_assembler=true
408   fi
409 fi
410 AC_SUBST(SILC_ASSEMBLER)
411
412 ##
413 ## va_copy checks
414 ##
415 va_copy=false
416 AC_MSG_CHECKING(for va_copy)
417 AC_TRY_COMPILE(
418   [
419     #include <stdarg.h>
420     #include <stdlib.h>
421   ],
422   [
423     int t(int x, ...)
424     {
425       va_list va, cp;
426       va_start(va, x);
427       va_copy(cp, va);
428       if (va_arg(cp, int) != 0xff11)
429         return 1;
430       va_end(va);
431       va_end(cp);
432       return 0;
433     }
434     int main()
435     {
436       return t(0, 0xff11);
437     }
438   ],
439   [
440     AC_DEFINE([HAVE_VA_COPY], [], [HAVE_VA_COPY])
441     AC_MSG_RESULT(yes)
442     va_copy=true
443   ],
444   [
445     AC_MSG_RESULT(no)
446     va_copy=false
447   ]
448 )
449
450 if test x$va_copy = xfalse; then
451   AC_MSG_CHECKING(for __va_copy)
452   AC_TRY_COMPILE(
453   [
454     #include <stdarg.h>
455     #include <stdlib.h>
456   ],
457   [
458     int t(int x, ...)
459     {
460       va_list va, cp;
461       va_start(va, x);
462       __va_copy(cp, va);
463       if (va_arg(cp, int) != 0xff11)
464         return 1;
465       va_end(va);
466       va_end(cp);
467       return 0;
468     }
469     int main()
470     {
471       return t(0, 0xff11);
472     }
473   ],
474   [
475     AC_DEFINE([HAVE___VA_COPY], [], [HAVE___VA_COPY])
476     AC_MSG_RESULT(yes)
477     va_copy=true
478   ],
479   [
480     AC_MSG_RESULT(no)
481     va_copy=false
482   ]
483   )
484 fi
485
486 if test x$va_copy = xfalse; then
487   AC_RUN_IFELSE(
488     [
489       #include <stdarg.h>
490       #include <stdlib.h>
491       int t(int x, ...)
492       {
493         va_list va, cp;
494         va_start(va, x);
495         cp = va;
496         if (va_arg(cp, int) != 0xff11)
497           return 1;
498         va_end(va);
499         va_end(cp);
500         return 0;
501       }
502       int main()
503       {
504         return t(0, 0xff11);
505       }
506     ],
507     [va_copy=false],
508     [
509       AC_DEFINE([SILC_VA_COPY_ARRAY], [], [SILC_VA_COPY_ARRAY])
510     ],
511     [va=copy=false]
512   )
513 fi
514
515 ##
516 ## Compiler and compiler flag checks
517 ##
518
519 if test "$GCC"; then
520   # GCC specific options
521   if test "x$summary_debug" = "xyes"; then
522     SILC_ADD_CFLAGS(-g)
523   else
524     SILC_ADD_CFLAGS(-g)
525   fi
526   SILC_ADD_CFLAGS(-Wall -finline-functions)
527   SILC_ADD_CFLAGS(-Wno-pointer-sign)
528 else
529   # Other compilers
530   case "$target" in
531     alpha*-dec-osf*)
532       SILC_ADD_CFLAGS(-g3)
533       ;;
534     mips*-sgi-irix*)
535       SILC_ADD_CFLAGS(-g3)
536       ;;
537     *)
538       SILC_ADD_CFLAGS(-g)
539       ;;
540   esac
541
542   # Intel C++ Compiler needs -restrict
543   if test "x$CC" = "xicc"; then
544     SILC_ADD_CFLAGS(-restrict)
545   fi
546 fi
547
548 if test x$want_cc_optimizations = xtrue; then
549   if test "$GCC"; then
550     # GCC specific options
551     if test "x$summary_debug" = "xyes"; then
552       SILC_ADD_CFLAGS(-O)
553     else
554       SILC_ADD_CFLAGS(-O2)
555     fi
556   else
557     # Other compilers
558     case "$target" in
559       alpha*-dec-osf*)
560         SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
561         ;;
562       mips*-sgi-irix*)
563         SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
564         ;;
565       *)
566         SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
567         ;;
568     esac
569   fi
570 fi
571
572 #
573 # Workaround a bug in GCC 2.x which causes memory exhaustion
574 # when compiling sha1 with optimizations on UltraSPARC.
575 #
576 FIX_SHA1='#'
577 if test "$GCC" -a "$host_cpu" = "sparc64"; then
578   AC_MSG_CHECKING(whether to enable GCC 2.x workaround for SHA1)
579   AC_TRY_COMPILE(
580     [
581       #if defined(__sparc64__) && (__GNUC__ == 2)
582       #else
583       choke me
584       #endif
585     ],
586     [],
587     [
588       FIX_SHA1=''
589       AC_MSG_RESULT(yes)
590     ],
591       AC_MSG_RESULT(no)
592     )
593 fi
594 AC_SUBST(FIX_SHA1)
595 #endif SILC_DIST_COMPILER
596
597 ##
598 ##  Installation
599 ##
600
601 # Default installation destination
602 #
603 AC_PREFIX_DEFAULT(/usr/local)
604 if test "x$prefix" != xNONE; then
605   silc_prefix="$prefix"
606 else
607   silc_prefix="$ac_default_prefix"
608   prefix="$silc_prefix"
609 fi
610
611 #ifndef SILC_DIST_AUTODIST
612 ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR`
613 AC_SUBST(ETCDIR)
614 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
615
616 DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR`
617 AC_SUBST(DOCDIR)
618 AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR])
619 #endif SILC_DIST_AUTODIST
620
621 #ifdef SILC_DIST_COMPILER
622 ##
623 ##  With/without checkings
624 ##
625
626 #
627 # SILC library checking
628 compile_libs=true
629 LIBSUBDIR=lib
630
631 #ifndef SILC_DIST_TOOLKIT
632 AC_ARG_WITH(silc-includes,
633   [  --with-silc-includes=DIR SILC Toolkit includes [search in DIR]],
634   [ac_silc_includes="$withval"], [ac_silc_includes="no"])
635 AC_ARG_WITH(silc-libs,
636   [  --with-silc-libs=DIR     SILC Toolkit libraries [search in DIR]],
637   [ac_silc_libs="$withval"], [ac_silc_libs="no"])
638
639 if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then
640
641   # Manually provided libs
642   if test "$ac_silc_includes" != "no"; then
643     compile_libs=false
644     SILC_LIB_INCLUDES="-I$ac_silc_includes"
645     LIBSUBDIR=
646   fi
647   if test "$ac_silc_libs" != "no"; then
648     compile_libs=false
649     LIBSUBDIR=
650     LDFLAGS="-L$ac_silc_libs $LDFLAGS"
651   else
652     LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
653   fi
654
655   # Check libs to link against
656   f=`$EGREP __SILC_HAVE_PTHREAD $ac_silc_includes/silc.h`
657   if test -n "$f"; then
658     LIBS="$LIBS -lpthread"
659     check_threads=false
660     has_threads=true
661   fi
662   f=`$EGREP __SILC_HAVE_SIM $ac_silc_includes/silc.h`
663   if test -n "$f"; then
664     LIBS="$LIBS -ldl"
665   fi
666
667 else
668   # pkg-config check
669   PKG_CHECK_MODULES(SILC, [silc >= 1.1], compile_libs=false, compile_libs=true)
670 #ifdef SILC_DIST_CLIENTLIB
671   PKG_CHECK_MODULES(SILCCLIENT, [silcclient >= 1.1.1], compile_libs=false, compile_libs=true)
672 #endif SILC_DIST_CLIENTLIB
673 #ifdef SILC_DIST_SERVERLIB
674   PKG_CHECK_MODULES(SILCSERVER, silcserver, compile_libs=false, compile_libs=true)
675 #endif SILC_DIST_SERVERLIB
676
677   if test x$compile_libs = xfalse; then
678     LIBSUBDIR=
679     LIBS="$SILC_LIBS $LIBS"
680     CFLAGS="$CFLAGS $SILC_CFLAGS"
681 #ifdef SILC_DIST_CLIENTLIB
682     LIBS="$SILCCLIENT_LIBS $LIBS"
683     CFLAGS="$CFLAGS $SILCCLIENT_CFLAGS"
684 #endif SILC_DIST_CLIENTLIB
685 #ifdef SILC_DIST_SERVERLIB
686     LIBS="$LIBS $SILCSERVER_LIBS"
687     CFLAGS="$CFLAGS $SILCSERVER_CFLAGS"
688 #endif SILC_DIST_SERVERLIB
689   else
690     LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
691   fi
692 fi
693 #else SILC_DIST_TOOLKIT
694 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
695 #endif SILC_DIST_TOOLKIT
696
697 #ifdef SILC_DIST_SIM
698 # SIM support checking
699 # XXX These needs to be changed as more supported platforms appear.
700 # XXX This probably needs to be made platform dependant check.
701 #
702 sim_support=false
703 AC_MSG_CHECKING(for SIM support)
704 AC_MSG_RESULT()
705 AC_CHECK_HEADERS(dlfcn.h,
706   [
707     AC_CHECK_LIB(dl, dlopen,
708       [
709         AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
710         AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN])
711         sim_support=true
712         LIBS="$LIBS -ldl"
713       ],
714       [
715         AC_CHECK_LIB(c, dlopen,
716           [
717             AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
718             AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN])
719             sim_support=true
720           ])
721       ])
722    ])
723
724 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
725 if test x$sim_support = xtrue; then
726   AC_MSG_RESULT(Enabled SIM support.)
727   __SILC_HAVE_SIM="#define __SILC_HAVE_SIM 1"
728 else
729   AC_MSG_RESULT(No SIM support found.)
730 fi
731 #endif SILC_DIST_SIM
732
733 # SOCKS4 support checking
734 #
735 SAVE_LIBS="$LIBS"
736 SAVE_CFLAGS="$CFLAGS"
737 SAVE_LDFLAGS="$LDFLAGS"
738 AC_MSG_CHECKING(whether to support SOCKS4)
739 AC_ARG_WITH(socks4,
740   [[  --with-socks4[=DIR]     with SOCKS4 support [search in DIR/lib and DIR/include]]],
741   [
742     case "$withval" in
743       no)
744         AC_MSG_RESULT(no)
745         ;;
746       *)
747         AC_MSG_RESULT(yes)
748         socks=4
749
750         if test -d "$withval/include"; then
751           CFLAGS="$CFLAGS -I$withval/include"
752         fi
753         if test -d "$withval/lib"; then
754           LDFLAGS="$LDFLAGS -L$withval/lib"
755         fi
756
757         LIBS="-lsocks $LIBS"
758         ;;
759     esac
760
761     AC_TRY_LINK([],
762       [
763         Rconnect();
764       ], [],
765       [
766         AC_MSG_ERROR(Could not find SOCKS4 library.)
767         LIBS="$SAVE_LIBS"
768         CFLAGS="$SAVE_CFLAGS"
769         LDFLAGS="$SAVE_LDFLAGS"
770       ])
771   ],
772     AC_MSG_RESULT(no)
773   )
774
775 # SOCKS5 support checking
776 #
777 SAVE_LIBS="$LIBS"
778 SAVE_CFLAGS="$CFLAGS"
779 SAVE_LDFLAGS="$LDFLAGS"
780 AC_MSG_CHECKING(whether to support SOCKS5)
781 AC_ARG_WITH(socks5,
782   [[  --with-socks5[=DIR]     with SOCKS5 support [search in DIR/lib and DIR/include]]],
783   [
784     case "$withval" in
785       no)
786         AC_MSG_RESULT(no)
787         ;;
788       *)
789         AC_MSG_RESULT(yes)
790         socks=5
791
792         if test -d "$withval/include"; then
793           CFLAGS="$CFLAGS -I$withval/include"
794         fi
795         if test -d "$withval/lib"; then
796           LDFLAGS="$LDFLAGS -L$withval/lib"
797         fi
798
799         LIBS="-lsocks5 $LIBS"
800         ;;
801     esac
802
803     AC_TRY_LINK([],
804       [
805         SOCKSconnect();
806       ], [],
807       [
808         AC_MSG_ERROR(Could not find SOCKS5 library.)
809         LIBS="$SAVE_LIBS"
810         CFLAGS="$SAVE_CFLAGS"
811         LDFLAGS="$SAVE_LDFLAGS"
812       ])
813   ],
814     AC_MSG_RESULT(no)
815   )
816
817 if test "x$socks" = "x4"; then
818   AC_DEFINE([SOCKS], [], [Socks])
819   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
820 fi
821
822 if test "x$socks" = "x5"; then
823   AC_DEFINE([SOCKS], [], [Socks])
824   AC_DEFINE([SOCKS5], [], [Socks5])
825   AC_DEFINE([Rconnect], [SOCKSconnect], [Socks])
826   AC_DEFINE([Rgetsockname], [SOCKSgetsockname], [Socks])
827   AC_DEFINE([Rgetpeername], [SOCKSgetpeername], [Socks])
828   AC_DEFINE([Rbind], [SOCKSbind], [Socks])
829   AC_DEFINE([Raccept], [SOCKSaccept], [Socks])
830   AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
831   AC_DEFINE([Rselect], [SOCKSselect], [Socks])
832   AC_DEFINE([Rrecvfrom], [SOCKSrecvfrom], [Socks])
833   AC_DEFINE([Rsendto], [SOCKSsendto], [Socks])
834   AC_DEFINE([Rrecv], [SOCKSrecv], [Socks])
835   AC_DEFINE([Rsend], [SOCKSsend], [Socks])
836   AC_DEFINE([Rread], [SOCKSread], [Socks])
837   AC_DEFINE([Rwrite], [SOCKSwrite], [Socks])
838   AC_DEFINE([Rrresvport], [SOCKSrresvport], [Socks])
839   AC_DEFINE([Rshutdown], [SOCKSshutdown], [Socks])
840   AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
841   AC_DEFINE([Rclose], [SOCKSclose], [Socks])
842   AC_DEFINE([Rdup], [SOCKSdup], [Socks])
843   AC_DEFINE([Rdup2], [SOCKSdup2], [Socks])
844   AC_DEFINE([Rfclose], [SOCKSfclose], [Socks])
845   AC_DEFINE([Rgethostbyname], [SOCKSgethostbyname], [Socks])
846 fi
847
848 #ifdef SILC_DIST_MATH
849 # MP library checking. First check whether user wants to use GMP and use
850 # it if found. If not or not defined then compile the default library in the
851 # source tree.
852 #
853 mp_gmp=false
854 SAVE_LIBS="$LIBS"
855 SAVE_CFLAGS="$CFLAGS"
856 SAVE_LDFLAGS="$LDFLAGS"
857 AC_MSG_CHECKING(whether to search for GMP)
858 AC_ARG_WITH(gmp,
859   [[  --with-gmp[=DIR]        use GMP instead of SILC Math [search in DIR/lib and DIR/include]]],
860   [
861     case "$withval" in
862       no)
863         AC_MSG_RESULT(no)
864         ;;
865       *)
866         AC_MSG_RESULT(yes)
867
868         if test -d "$withval/include"; then
869           CFLAGS="$CFLAGS -I$withval/include"
870         fi
871         if test -d "$withval/lib"; then
872           LDFLAGS="$LDFLAGS -L$withval/lib"
873         fi
874
875         LIBS="-lgmp $LIBS"
876         ;;
877     esac
878
879     AC_CHECK_LIB(gmp, __gmpz_init,
880       [
881         mp_gmp=true
882         AC_DEFINE([SILC_MP_GMP], [], [GMP])
883         AC_MSG_RESULT(Using GMP as a MP library.)
884       ],
885       [
886         LIBS="$SAVE_LIBS"
887         CFLAGS="$SAVE_CFLAGS"
888         LDFLAGS="$SAVE_LDFLAGS"
889       ])
890   ],
891     AC_MSG_RESULT(no)
892   )
893
894 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
895 AM_CONDITIONAL(SILC_MP_SILCMATH, test x$mp_gmp = xfalse)
896 if test x$mp_gmp = xfalse; then
897   AC_DEFINE([SILC_MP_SILCMATH], [], [SILCMATH])
898   AC_MSG_RESULT(Using SILC Math as a MP library.)
899 fi
900 #endif SILC_DIST_MATH
901
902 # iconv support
903 #
904 check_iconv=true
905 has_iconv=false
906 SAVE_LIBS="$LIBS"
907 SAVE_CFLAGS="$CFLAGS"
908 SAVE_LDFLAGS="$LDFLAGS"
909 SAVE_CPPFLAGS="$CPPFLAGS"
910 AC_MSG_CHECKING(whether to implicit search for libiconv)
911 AC_ARG_WITH(iconv,
912   [[  --with-iconv[=DIR]      use libiconv [search in DIR/include and DIR/lib]]],
913   [
914     case "${withval}" in
915       no)
916         AC_MSG_RESULT(no)
917         AC_CHECK_HEADERS(iconv.h,
918           [
919             AC_CHECK_FUNC(iconv, has_iconv=true)
920           ])
921         check_iconv=false
922         ;;
923       *)
924         AC_MSG_RESULT(yes)
925         if test -d $withval/include; then
926           CPPFLAGS="$CPPFLAGS -I$withval/include"
927           CFLAGS="$CFLAGS -I$withval/include"
928         fi
929         if test -d $withval/lib; then
930           LDFLAGS="$LDFLAGS -L$withval/lib"
931         fi
932         ;;
933     esac
934   ],
935   [
936     AC_MSG_RESULT(no)
937     AC_CHECK_HEADERS(iconv.h,
938       [
939         AC_CHECK_FUNCS(iconv,
940           [
941             has_iconv=true
942             check_iconv=false
943           ])
944       ])
945   ])
946
947 if test x$check_iconv = xtrue; then
948   AC_MSG_RESULT(Searching for iconv...)
949
950   # XXX
951   unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
952
953   AC_CHECK_HEADERS(iconv.h,
954     [
955       LIBS="$LIBS -liconv"
956       AC_MSG_CHECKING(for iconv in -liconv)
957       AC_TRY_LINK(
958         [
959           #include <stdlib.h>
960           #include <iconv.h>
961         ],
962         [
963           iconv_t cd = iconv_open("", "");
964           iconv(cd, NULL, NULL, NULL, NULL);
965           iconv_close(cd);
966         ],
967         [
968           echo "yes"
969           AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
970           has_iconv=true
971           check_iconv=false
972         ],
973         [
974           echo "no"
975           LIBS="$SAVE_LIBS"
976           CFLAGS="$SAVE_CFLAGS"
977           LDFLAGS="$SAVE_LDFLAGS"
978           CPPFLAGS="$SAVE_CPPFLAGS"
979         ])
980      ])
981 fi
982
983 if test x$check_iconv = xtrue; then
984   # search for iconv library..
985   SAVE_LIBS="$LIBS"
986   SAVE_CFLAGS="$CFLAGS"
987   SAVE_LDFLAGS="$LDFLAGS"
988   SAVE_CPPFLAGS="$CPPFLAGS"
989
990   for dir in `echo "/usr/local /usr/pkg /usr/contrib"`; do
991     if test x$has_iconv = xfalse; then
992       AC_MSG_RESULT(searching in $dir...)
993
994       if test -d $dir/include; then
995         CPPFLAGS="$CPPFLAGS -I$dir/include"
996         CFLAGS="$CFLAGS -I$dir/include"
997       fi
998       if test -d $dir/lib; then
999         LDFLAGS="$LDFLAGS -L$dir/lib"
1000       fi
1001
1002       # XXX
1003       unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
1004
1005       AC_CHECK_HEADERS(iconv.h,
1006         [
1007           LIBS="$LIBS -liconv"
1008           AC_MSG_CHECKING(for iconv in -liconv)
1009           AC_TRY_LINK(
1010             [
1011               #include <stdlib.h>
1012               #include <iconv.h>
1013             ],
1014             [
1015               iconv_t cd = iconv_open("", "");
1016               iconv(cd, NULL, NULL, NULL, NULL);
1017               iconv_close(cd);
1018             ],
1019             [
1020               echo "yes"
1021               has_iconv=true
1022               AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
1023             ],
1024             [
1025               echo "no"
1026               has_iconv=false
1027
1028               LIBS="$SAVE_LIBS"
1029               CFLAGS="$SAVE_CFLAGS"
1030               LDFLAGS="$SAVE_LDFLAGS"
1031               CPPFLAGS="$SAVE_CPPFLAGS"
1032             ])
1033          ],
1034          [
1035            CFLAGS="$SAVE_CFLAGS"
1036            LDFLAGS="$SAVE_LDFLAGS"
1037            CPPFLAGS="$SAVE_CPPFLAGS"
1038          ])
1039       fi
1040     done
1041 fi
1042
1043 if test x$has_iconv = xtrue; then
1044   # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
1045   # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
1046   #     obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
1047   #
1048   AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
1049     AC_TRY_RUN(
1050       [
1051         #include <iconv.h>
1052         int main() {
1053           iconv_t cd;
1054         changequote(, )dnl
1055           char buf[4];
1056         changequote([, ])dnl
1057           char *ob;
1058           size_t obl;
1059           ob = buf, obl = sizeof(buf);
1060           return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
1061                  (iconv(cd, 0, 0, &ob, &obl) ||
1062                  !(ob == buf && obl == sizeof(buf)) ||
1063                  iconv_close(cd)));
1064         }
1065       ],
1066       [
1067         ac_iconv_good=yes
1068       ],
1069       [
1070         ac_iconv_good=no
1071       ],
1072       [
1073         ac_iconv_good=yes
1074       ])
1075     )
1076
1077   if test x$ac_iconv_good = xno; then
1078     AC_MSG_RESULT(Try using libiconv instead.)
1079   fi
1080 fi
1081
1082 # POSIX threads support
1083 #
1084 AC_MSG_CHECKING(whether to search for POSIX threads)
1085 AC_ARG_WITH(pthreads,
1086   [[  --with-pthreads[=DIR]   use POSIX threads [search in DIR/include and DIR/lib]]],
1087   [
1088     case "${withval}" in
1089       no)
1090         check_threads=false
1091         ;;
1092       *)
1093         if test -d $withval/include; then
1094           CPPFLAGS="$CPPFLAGS -I$withval/include"
1095           CFLAGS="$CFLAGS -I$withval/include"
1096         fi
1097         if test -d $withval/lib; then
1098           LDFLAGS="$LDFLAGS -L$withval/lib"
1099         fi
1100
1101         check_threads=true
1102         ;;
1103     esac
1104   ])
1105
1106 if test x$check_threads = xtrue; then
1107   has_threads=false
1108   SAVE_LIBS="$LIBS"
1109   SAVE_CFLAGS="$CFLAGS"
1110   SAVE_LDFLAGS="$LDFLAGS"
1111   SAVE_CPPFLAGS="$CPPFLAGS"
1112
1113   AC_MSG_RESULT(yes)
1114   AC_CHECK_HEADERS(pthread.h,
1115     [
1116       LIBS="$LIBS -lpthread"
1117       AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1118         [
1119           # FreeBSD
1120           case "${target}" in
1121             *-*-freebsd*)
1122               LIBS="$SAVE_LIBS -pthread"
1123               AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true, LIBS="$SAVE_LIBS")
1124               ;;
1125             *)
1126               LIBS="$SAVE_LIBS"
1127               ;;
1128           esac
1129         ])
1130     ],
1131     [
1132       # search for pthread library..
1133       for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do
1134         if test x$has_threads = xfalse; then
1135           AC_MSG_RESULT(searching in $dir...)
1136
1137           if test -d $dir/include; then
1138             CPPFLAGS="$CPPFLAGS -I$dir/include"
1139             CFLAGS="$CFLAGS -I$dir/include"
1140           fi
1141           if test -d $dir/lib; then
1142             LDFLAGS="$LDFLAGS -L$dir/lib"
1143           fi
1144
1145           # XXX
1146           unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true
1147
1148           AC_CHECK_HEADERS(pthread.h,
1149             [
1150               LIBS="$LIBS -lpthread"
1151               AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1152                 [
1153                   has_threads=false
1154
1155                   LIBS="$SAVE_LIBS"
1156                   CFLAGS="$SAVE_CFLAGS"
1157                   LDFLAGS="$SAVE_LDFLAGS"
1158                   CPPFLAGS="$SAVE_CPPFLAGS"
1159                 ])
1160             ],
1161             [
1162               CFLAGS="$SAVE_CFLAGS"
1163               LDFLAGS="$SAVE_LDFLAGS"
1164               CPPFLAGS="$SAVE_CPPFLAGS"
1165             ])
1166         fi
1167       done
1168     ])
1169 else
1170   AC_MSG_RESULT(no)
1171   has_threads=false
1172 fi
1173
1174 __SILC_HAVE_PTHREAD=""
1175 AM_CONDITIONAL(SILC_THREADS, test x$has_threads = xtrue)
1176 if test x$has_threads = xtrue; then
1177   CFLAGS="$CFLAGS -D_REENTRANT"
1178
1179   # XXX possibly incomplete
1180   case "${target}" in
1181     *-*-aix*)
1182       CFLAGS="$CFLAGS -D_THREAD_SAFE"
1183       if test x"$GCC" = xyes; then
1184         CFLAGS="$CFLAGS -mthreads"
1185       fi
1186       ;;
1187     *-*-freebsd*)
1188       CFLAGS="$CFLAGS -D_THREAD_SAFE"
1189       ;;
1190     *-*-sysv5uw7*)  # UnixWare 7
1191       if test "$GCC" != "yes"; then
1192         CFLAGS="$CFLAGS -Kthread"
1193       else
1194         CFLAGS="$CFLAGS -pthread"
1195       fi
1196       ;;
1197     *-dg-dgux*)  # DG/UX
1198       CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
1199       ;;
1200    esac
1201
1202   # Check for threads
1203   AC_CHECK_FUNC(pthread_create)
1204
1205   # Check for read/write locks
1206   AC_CHECK_FUNC(pthread_rwlock_init,
1207   [
1208     AC_RUN_IFELSE(
1209       [
1210         #include <pthread.h>
1211         int main()
1212         {
1213           pthread_rwlock_t rwlock;
1214           pthread_rwlock_init(&rwlock, NULL);
1215           pthread_rwlock_destroy(&rwlock);
1216           return 0;
1217         }
1218       ],
1219       [],
1220       [
1221         # Rwlock not defined
1222         CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1223       ]
1224     )
1225   ],
1226   [
1227     # Rwlock not defined
1228     CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1229   ])
1230
1231   AC_DEFINE([SILC_HAVE_PTHREAD], [], [HAVE_PTHREAD])
1232   AC_DEFINE([SILC_THREADS], [], [HAVE_THREAD])
1233   __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1"
1234 fi
1235
1236 #
1237 # Check for timezone and tm_gmtoff for timezone information
1238 #
1239 AC_MSG_CHECKING(whether system has timezone)
1240 AC_RUN_IFELSE(
1241   [
1242     #include <stdio.h>
1243     #include <time.h>
1244     int main()
1245     {
1246       timezone = 0;
1247       return 0;
1248     }
1249   ],
1250   [ AC_MSG_RESULT(yes)
1251     AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ],
1252   [ AC_MSG_RESULT(no) ],
1253   [ AC_MSG_RESULT(no) ]
1254 )
1255 AC_MSG_CHECKING(whether system has tm_gmtoff)
1256 AC_RUN_IFELSE(
1257   [
1258     #include <stdio.h>
1259     #include <time.h>
1260     int main()
1261     {
1262       struct tm tm;
1263       tm.tm_gmtoff = 0;
1264       return 0;
1265     }
1266   ],
1267   [ AC_MSG_RESULT(yes)
1268     AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ],
1269   [ AC_MSG_RESULT(no) ],
1270   [ AC_MSG_RESULT(no) ]
1271 )
1272 AC_MSG_CHECKING(whether system has __tm_gmtoff)
1273 AC_RUN_IFELSE(
1274   [
1275     #include <stdio.h>
1276     #include <time.h>
1277     int main()
1278     {
1279       struct tm tm;
1280       tm.__tm_gmtoff = 0;
1281       return 0;
1282     }
1283   ],
1284   [ AC_MSG_RESULT(yes)
1285     AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ],
1286   [ AC_MSG_RESULT(no) ],
1287   [ AC_MSG_RESULT(no) ]
1288 )
1289 AC_MSG_CHECKING(whether system has __tm_gmtoff__)
1290 AC_RUN_IFELSE(
1291   [
1292     #include <stdio.h>
1293     #include <time.h>
1294     int main()
1295     {
1296       struct tm tm;
1297       tm.__tm_gmtoff__ = 0;
1298       return 0;
1299     }
1300   ],
1301   [ AC_MSG_RESULT(yes)
1302     AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ],
1303   [ AC_MSG_RESULT(no) ],
1304   [ AC_MSG_RESULT(no) ]
1305 )
1306
1307 # Native WIN32 compilation under cygwin
1308 #
1309 AC_MSG_CHECKING(whether to compile native WIN32 code)
1310 AC_ARG_WITH(win32,
1311   [  --with-win32            compile native WIN32 (MinGW) code (-mno-cygwin)],
1312   [
1313     AC_MSG_RESULT(yes)
1314     AC_DEFINE([SILC_WIN32], [], [SILC_WIN32])
1315     win32_support=true
1316     CFLAGS="-mno-cygwin $CFLAGS"
1317     LIBS="$LIBS -lwsock32"
1318   ],
1319   [
1320     AC_MSG_RESULT(no)
1321   ])
1322 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
1323
1324 # Native Symbian OS support (disabled by default)
1325 #
1326 AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue)
1327
1328 # Native BeOS support (disabled by default)
1329 #
1330 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
1331
1332 # Native OS2 support (disabled by default)
1333 #
1334 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
1335
1336 #ifdef SILC_DIST_SERVER
1337 without_silcd=false
1338 #endif SILC_DIST_SERVER
1339 #ifdef SILC_DIST_CLIENT
1340 AM_CONDITIONAL(with_irssi, true)
1341 #endif SILC_DIST_CLIENT
1342 #ifdef SILC_DIST_INPLACE
1343 without_irssi=false
1344 without_silcd=false
1345 #endif SILC_DIST_INPLACE
1346
1347 libtoolfix=true
1348 AC_MSG_CHECKING(whether to do libtoolfix)
1349 AC_ARG_WITH(libtoolfix,
1350   [  --without-libtoolfix    Do not fix libtool, for package builders],
1351   [
1352     AC_MSG_RESULT(no)
1353     libtoolfix=false
1354   ],
1355   [
1356     AC_MSG_RESULT(yes)
1357   ])
1358
1359 AC_SUBST(ETCDIR)
1360 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
1361 #endif SILC_DIST_COMPILER
1362
1363 ##
1364 ##  Misc
1365 ##
1366
1367 # Make enable-shared aware
1368 AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes)
1369
1370 SILC_TOP_SRCDIR=`pwd`
1371
1372 # Included configure scripts
1373 AD_INCLUDE_CONFIGURE
1374
1375 #ifdef SILC_DIST_COMPILER
1376 #
1377 # Substitutions
1378 #
1379 AC_SUBST(LIBSUBDIR)
1380 AC_SUBST(SILC_TOP_SRCDIR)
1381 AC_SUBST(LDFLAGS)
1382 AC_SUBST(LIBS)
1383 AC_SUBST(SILC_LIB_INCLUDES)
1384 AC_SUBST(__SILC_HAVE_PTHREAD)
1385 AC_SUBST(__SILC_HAVE_SIM)
1386 AC_SUBST(__SILC_ENABLE_DEBUG)
1387 AC_SUBST(__SILC_PACKAGE_VERSION)
1388
1389 #
1390 # Fix the libtool to support run-time configuration.  This allows us
1391 # to in run-time specify when to compile shared/static libraries without
1392 # need to reconfigure the entire libtool.
1393 #
1394 if test x$libtoolfix = xtrue; then
1395   ./libtoolfix $SILC_TOP_SRCDIR/ltmain.sh
1396 fi
1397 AM_CONDITIONAL(SILC_LIBTOOLFIX, test x$libtoolfix = xtrue)
1398
1399 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
1400 AC_SUBST(INCLUDE_DEFINES_INT)
1401
1402 #endif SILC_DIST_COMPILER
1403
1404 #
1405 # Makefile outputs
1406 #
1407 AC_CONFIG_FILES(
1408 Makefile
1409 #ifdef SILC_DIST_DOC
1410 doc/Makefile
1411 #endif SILC_DIST_DOC
1412 #ifdef SILC_DIST_COMPILER
1413 Makefile.defines
1414 Makefile.defines_int
1415 includes/Makefile
1416 includes/silcversion.h
1417 includes/silc.h
1418 #endif SILC_DIST_COMPILER
1419 #ifdef SILC_DIST_APPS
1420 apps/Makefile
1421 #endif SILC_DIST_APPS
1422 )
1423
1424 #ifdef SILC_DIST_TOOLKIT
1425 AC_CONFIG_FILES(
1426 win32/Makefile
1427 win32/libsilc/Makefile
1428 win32/libsilcclient/Makefile
1429 tutorial/Makefile
1430 tutorial/Makefile.defines
1431 tutorial/Makefile.defines_int
1432 )
1433 #endif SILC_DIST_TOOLKIT
1434
1435 AC_OUTPUT
1436
1437 #ifdef SILC_DIST_COMPILER
1438 s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir`
1439 s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir`
1440 s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir`
1441 s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir`
1442
1443 echo ""
1444 echo "$PACKAGE Configuration Summary:"
1445 echo "---------------------------"
1446 echo " Target host ...................: $target"
1447 echo " Compiler ......................: $CC"
1448 echo " CFLAGS ........................: $CFLAGS"
1449 echo " LDFLAGS .......................: $LDFLAGS"
1450 echo " LIBS ..........................: $LIBS"
1451 echo ""
1452 echo " Installation prefix ...........: $prefix"
1453 echo " bin directory .................: $s_bindir"
1454 echo " sbin directory ................: $s_sbindir"
1455 echo " etc directory .................: $ETCDIR"
1456 echo " man directory .................: $s_mandir"
1457 echo " doc directory .................: $DOCDIR"
1458 #ifdef SILC_DIST_SIM
1459 echo " SIM directory .................: $MODULESDIR"
1460 #endif SILC_DIST_SIM
1461 #ifdef SILC_DIST_INCLUDES
1462 echo " include directory .............: $s_includedir"
1463 #endif SILC_DIST_INCLUDES
1464 echo ""
1465
1466 #ifdef SILC_DIST_CLIENT
1467 if test x$without_irssi = xtrue; then
1468   irssi="no"
1469 fi
1470 echo " Compile SILC Client ...........: $irssi"
1471 #endif SILC_DIST_CLIENT
1472
1473 #ifdef SILC_DIST_SERVER
1474 if test x$without_silcd = xtrue; then
1475   silcd="no"
1476 fi
1477 echo " Compile SILC Server ...........: $silcd"
1478 #endif SILC_DIST_SERVER
1479
1480 #ifdef SILC_DIST_SIM
1481 if test x$sim_support = xfalse; then
1482   sim_support="no"
1483 else
1484   sim_support="yes"
1485 fi
1486 echo " SIM support ...................: $sim_support"
1487 #endif SILC_DIST_SIM
1488
1489 echo " IPv6 support ..................: $summary_ipv6"
1490
1491 if test x$has_iconv = xfalse; then
1492   iconv_support="no"
1493 else
1494   iconv_support="yes"
1495 fi
1496 echo " Iconv support .................: $iconv_support"
1497
1498 if test x$want_asm = xfalse; then
1499   summary_asm="no"
1500 else
1501   summary_asm="yes"
1502 fi
1503 echo " Assembler optimizations .......: $summary_asm"
1504
1505 #ifdef SILC_DIST_MATH
1506 if test x$mp_gmp = xtrue; then
1507   echo " Arithmetic library ............: GMP"
1508 fi
1509 #endif SILC_DIST_MATH
1510
1511 threads="no"
1512 if test x$has_threads = xtrue; then
1513   threads="yes"
1514 fi
1515 echo " Multi-threads support .........: $threads"
1516 echo " Debugging enabled .............: $summary_debug"
1517 echo ""
1518 echo "Compile the sources with 'make' or 'gmake' command."
1519 #endif SILC_DIST_COMPILER