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