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