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