4 # Author: Pekka Riikonen <priikone@silcnet.org>
6 # Copyright (C) 2000 - 2007 Pekka Riikonen
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.
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.
22 AC_CONFIG_HEADERS(silcdefs.h)
30 AC_PATH_PROG(sedpath, sed)
32 #ifdef SILC_DIST_COMPILER
33 # Put here any platform specific stuff
58 AC_DEFINE([SILC_I386], [], [SILC_I386])
59 AC_DEFINE([SILC_I486], [], [SILC_I486])
64 AC_DEFINE([SILC_I486], [], [SILC_I486])
68 AC_DEFINE([SILC_X86_64], [], [SILC_X86_64])
72 AC_DEFINE([SILC_POWERPC], [], [SILC_POWERPC])
76 AC_DEFINE([SILC_IA64], [], [SILC_IA64])
80 AM_CONDITIONAL(SILC_I386, test x$cpu_i386 = xtrue)
81 AM_CONDITIONAL(SILC_I486, test x$cpu_ix86 = xtrue)
82 AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue)
83 AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue)
84 AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue)
86 # Control compiler optimizations
87 CFLAGS=`echo $CFLAGS | sed 's/-O[ 0123456789s]*//g'`
93 __SILC_HAVE_PTHREAD=""
95 __SILC_ENABLE_DEBUG=""
97 #ifdef SILC_DIST_TOOLKIT
98 toolkitver=`echo $VERSION | sed 's/\./ /g'`
104 if test $maj -eq 0; then
108 if test $min -eq 0; then
112 if test $bld -eq 0; then
117 __SILC_PACKAGE_VERSION="#define __SILC_TOOLKIT_VERSION SILC_VERSION($maj,$min,$bld)"
118 #endif SILC_DIST_TOOLKIT
121 #ifndef SILC_DIST_TOOLKIT
123 #endif SILC_DIST_TOOLKIT
124 #ifdef SILC_DIST_INPLACE
126 #endif SILC_DIST_INPLACE
135 # More header checking
137 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
138 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
139 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h sys/resource.h)
140 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
141 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h)
142 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
152 AC_CHECK_SIZEOF(long long, 0)
153 AC_SUBST(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
154 AC_CHECK_SIZEOF(long, 0)
155 AC_SUBST(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
156 AC_CHECK_SIZEOF(int, 0)
157 AC_SUBST(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
158 AC_CHECK_SIZEOF(short, 0)
159 AC_SUBST(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
160 AC_CHECK_SIZEOF(char, 0)
161 AC_SUBST(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
162 AC_CHECK_SIZEOF(void *, 0)
163 AC_SUBST(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
164 AC_CHECK_TYPES(long long)
165 AC_CHECK_TYPES(long double)
167 # Function to check if compiler flag works
168 # Usage: SILC_ADD_CFLAGS(FLAGS, [ACTION-IF-FAILED])
169 AC_DEFUN([SILC_ADD_CFLAGS],
170 [ tmp_CFLAGS="$CFLAGS"
172 AC_MSG_CHECKING(whether $CC accepts $1 flag)
173 AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
179 # Function to check if compiler flag works, destination specifiable
180 # Usage: SILC_ADD_CC_FLAGS(VAR, FLAGS, [ACTION-IF-FAILED])
181 AC_DEFUN([SILC_ADD_CC_FLAGS],
182 [ tmp_CFLAGS="$1_CFLAGS"
183 $1_CFLAGS="${$1_CFLAGS} $2"
184 AC_MSG_CHECKING(whether $CC accepts $2 flag)
185 AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
186 $1_CFLAGS="$tmp_CFLAGS"
191 # Function and library checking
193 AC_CHECK_FUNC(gethostbyname, [],
195 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
196 AC_CHECK_FUNC(res_gethostbyname, [],
197 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
200 AC_CHECK_FUNC(socket, [],
201 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
203 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
204 AC_CHECK_FUNCS(poll select listen bind shutdown close connect setsockopt)
205 AC_CHECK_FUNCS(setrlimit time ctime utime gettimeofday getrusage)
206 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
207 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid sched_yield)
208 AC_CHECK_FUNCS(setgroups initgroups nl_langinfo nanosleep)
209 AC_CHECK_FUNCS(strchr snprintf strstr strcpy strncpy memcpy memset memmove)
211 # lib/contrib conditionals
213 AC_CHECK_HEADER(regex.h,
215 AC_DEFINE([HAVE_REGEX_H], [], [HAVE_REGEX_H])
219 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
221 AC_CHECK_FUNC(getopt_long,
223 AC_DEFINE([HAVE_GETOPT_LONG], [], [HAVE_GETOPT_LONG])
225 ], have_getopt_long=0
228 AC_CHECK_FUNC(getopt,
230 AC_DEFINE([HAVE_GETOPT], [], [HAVE_GETOPT])
236 ## Enable/disable checking
241 AC_MSG_CHECKING(whether to enable IPv6 support)
243 [ --enable-ipv6 enable IPv6 support],
245 case "${enableval}" in
250 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
264 if test x$check_ipv6 = xtrue; then
268 #ifdef HAVE_SYS_TYPES_H
269 #include <sys/types.h>
271 #ifdef HAVE_NETINET_TCP_H
272 #include <netinet/tcp.h>
277 #include <sys/socket.h>
278 #ifdef HAVE_NETINET_IN_H
279 #include <netinet/in.h>
283 struct sockaddr_in6 sin6;
284 int family = AF_INET6;
287 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
297 AC_MSG_CHECKING(whether to enable debugging)
299 __SILC_ENABLE_DEBUG=""
301 [ --enable-debug enable debugging],
303 case "${enableval}" in
306 AC_DEFINE([SILC_DEBUG], [], [enable-debug])
308 __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1"
319 # Disable all compiler optimizations
321 AC_MSG_CHECKING(whether to enable compiler optimizations)
322 want_cc_optimizations=true
323 AC_ARG_ENABLE(optimizations,
324 [ --disable-optimizations do not use any compiler optimizations],
327 AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS])
328 want_cc_optimizations=false
332 want_cc_optimizations=true
334 AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse)
336 # Disable all assembler optimizations
338 AC_MSG_CHECKING(whether to enable assembler optimizations)
341 [ --disable-asm do not use assembler optimizations],
344 AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM])
351 AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse)
353 # Check for assembler
357 if test x$want_asm = xtrue; then
358 AC_PATH_PROG([NASM], [nasm], [no])
359 if test "x$NASM" != "xno"; then
360 SILC_ASSEMBLER="$NASM -O2 -felf"
364 AC_PATH_PROG([YASM], [yasm], [no])
365 if test "x$YASM" != "xno"; then
366 SILC_ASSEMBLER="$YASM -Xgnu -felf"
370 AC_SUBST(SILC_ASSEMBLER)
376 AC_MSG_CHECKING(for va_copy)
388 if (va_arg(cp, int) != 0xff11)
400 AC_DEFINE([HAVE_VA_COPY], [], [HAVE_VA_COPY])
410 if test x$va_copy = xfalse; then
411 AC_MSG_CHECKING(for __va_copy)
423 if (va_arg(cp, int) != 0xff11)
435 AC_DEFINE([HAVE___VA_COPY], [], [HAVE___VA_COPY])
446 if test x$va_copy = xfalse; then
456 if (va_arg(cp, int) != 0xff11)
469 AC_DEFINE([SILC_VA_COPY_ARRAY], [], [SILC_VA_COPY_ARRAY])
476 ## Compiler and compiler flag checks
480 # GCC specific options
481 if test "x$summary_debug" = "xyes"; then
486 SILC_ADD_CFLAGS(-Wall -finline-functions)
487 SILC_ADD_CFLAGS(-Wno-pointer-sign)
502 # Intel C++ Compiler needs -restrict
503 if test "x$CC" = "xicc"; then
504 SILC_ADD_CFLAGS(-restrict)
508 if test x$want_cc_optimizations = xtrue; then
510 # GCC specific options
511 if test "x$summary_debug" = "xyes"; then
520 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
523 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
526 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
533 # Workaround a bug in GCC 2.x which causes memory exhaustion
534 # when compiling sha1 with optimizations on UltraSPARC.
537 if test "$GCC" -a "$host_cpu" = "sparc64"; then
538 AC_MSG_CHECKING(whether to enable GCC 2.x workaround for SHA1)
541 #if defined(__sparc64__) && (__GNUC__ == 2)
555 #endif SILC_DIST_COMPILER
561 # Default installation destination
563 AC_PREFIX_DEFAULT(/usr/local)
564 if test "x$prefix" != xNONE; then
565 silc_prefix="$prefix"
567 silc_prefix="$ac_default_prefix"
568 prefix="$silc_prefix"
571 #ifndef SILC_DIST_AUTODIST
572 ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR`
574 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
576 DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR`
578 AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR])
579 #endif SILC_DIST_AUTODIST
581 #ifdef SILC_DIST_COMPILER
583 ## With/without checkings
587 # SILC library checking
591 #ifndef SILC_DIST_TOOLKIT
592 AC_ARG_WITH(silc-includes,
593 [ --with-silc-includes=DIR SILC Toolkit includes [search in DIR]],
594 [ac_silc_includes="$withval"], [ac_silc_includes="no"])
595 AC_ARG_WITH(silc-libs,
596 [ --with-silc-libs=DIR SILC Toolkit libraries [search in DIR]],
597 [ac_silc_libs="$withval"], [ac_silc_libs="no"])
599 if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then
601 # Manually provided libs
602 if test "$ac_silc_includes" != "no"; then
604 SILC_LIB_INCLUDES="-I$ac_silc_includes"
607 if test "$ac_silc_libs" != "no"; then
610 LDFLAGS="-L$ac_silc_libs $LDFLAGS"
612 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
615 # Check libs to link against
616 f=`$EGREP __SILC_HAVE_PTHREAD $ac_silc_includes/silc.h`
617 if test -n "$f"; then
618 LIBS="$LIBS -lpthread"
622 f=`$EGREP __SILC_HAVE_SIM $ac_silc_includes/silc.h`
623 if test -n "$f"; then
629 PKG_CHECK_MODULES(SILC, [silc >= 1.1], compile_libs=false, compile_libs=true)
630 #ifdef SILC_DIST_CLIENTLIB
631 PKG_CHECK_MODULES(SILCCLIENT, [silcclient >= 1.1.1], compile_libs=false, compile_libs=true)
632 #endif SILC_DIST_CLIENTLIB
633 #ifdef SILC_DIST_SERVERLIB
634 PKG_CHECK_MODULES(SILCSERVER, silcserver, compile_libs=false, compile_libs=true)
635 #endif SILC_DIST_SERVERLIB
637 if test x$compile_libs = xfalse; then
639 LIBS="$SILC_LIBS $LIBS"
640 CFLAGS="$CFLAGS $SILC_CFLAGS"
641 #ifdef SILC_DIST_CLIENTLIB
642 LIBS="$SILCCLIENT_LIBS $LIBS"
643 CFLAGS="$CFLAGS $SILCCLIENT_CFLAGS"
644 #endif SILC_DIST_CLIENTLIB
645 #ifdef SILC_DIST_SERVERLIB
646 LIBS="$LIBS $SILCSERVER_LIBS"
647 CFLAGS="$CFLAGS $SILCSERVER_CFLAGS"
648 #endif SILC_DIST_SERVERLIB
650 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
653 #else SILC_DIST_TOOLKIT
654 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
655 #endif SILC_DIST_TOOLKIT
658 # SIM support checking
659 # XXX These needs to be changed as more supported platforms appear.
660 # XXX This probably needs to be made platform dependant check.
663 AC_MSG_CHECKING(for SIM support)
665 AC_CHECK_HEADERS(dlfcn.h,
667 AC_CHECK_LIB(dl, dlopen,
669 AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
674 AC_CHECK_LIB(c, dlopen,
676 AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
682 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
683 if test x$sim_support = xtrue; then
684 AC_MSG_RESULT(Enabled SIM support.)
685 __SILC_HAVE_SIM="#define __SILC_HAVE_SIM 1"
687 AC_MSG_RESULT(No SIM support found.)
691 # SOCKS4 support checking
694 SAVE_CFLAGS="$CFLAGS"
695 SAVE_LDFLAGS="$LDFLAGS"
696 AC_MSG_CHECKING(whether to support SOCKS4)
698 [[ --with-socks4[=DIR] with SOCKS4 support [search in DIR/lib and DIR/include]]],
708 if test -d "$withval/include"; then
709 CFLAGS="$CFLAGS -I$withval/include"
711 if test -d "$withval/lib"; then
712 LDFLAGS="$LDFLAGS -L$withval/lib"
724 AC_MSG_ERROR(Could not find SOCKS4 library.)
726 CFLAGS="$SAVE_CFLAGS"
727 LDFLAGS="$SAVE_LDFLAGS"
733 # SOCKS5 support checking
736 SAVE_CFLAGS="$CFLAGS"
737 SAVE_LDFLAGS="$LDFLAGS"
738 AC_MSG_CHECKING(whether to support SOCKS5)
740 [[ --with-socks5[=DIR] with SOCKS5 support [search in DIR/lib and DIR/include]]],
750 if test -d "$withval/include"; then
751 CFLAGS="$CFLAGS -I$withval/include"
753 if test -d "$withval/lib"; then
754 LDFLAGS="$LDFLAGS -L$withval/lib"
757 LIBS="-lsocks5 $LIBS"
766 AC_MSG_ERROR(Could not find SOCKS5 library.)
768 CFLAGS="$SAVE_CFLAGS"
769 LDFLAGS="$SAVE_LDFLAGS"
775 if test "x$socks" = "x4"; then
776 AC_DEFINE([SOCKS], [], [Socks])
777 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
780 if test "x$socks" = "x5"; then
781 AC_DEFINE([SOCKS], [], [Socks])
782 AC_DEFINE([SOCKS5], [], [Socks5])
783 AC_DEFINE([Rconnect], [SOCKSconnect], [Socks])
784 AC_DEFINE([Rgetsockname], [SOCKSgetsockname], [Socks])
785 AC_DEFINE([Rgetpeername], [SOCKSgetpeername], [Socks])
786 AC_DEFINE([Rbind], [SOCKSbind], [Socks])
787 AC_DEFINE([Raccept], [SOCKSaccept], [Socks])
788 AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
789 AC_DEFINE([Rselect], [SOCKSselect], [Socks])
790 AC_DEFINE([Rrecvfrom], [SOCKSrecvfrom], [Socks])
791 AC_DEFINE([Rsendto], [SOCKSsendto], [Socks])
792 AC_DEFINE([Rrecv], [SOCKSrecv], [Socks])
793 AC_DEFINE([Rsend], [SOCKSsend], [Socks])
794 AC_DEFINE([Rread], [SOCKSread], [Socks])
795 AC_DEFINE([Rwrite], [SOCKSwrite], [Socks])
796 AC_DEFINE([Rrresvport], [SOCKSrresvport], [Socks])
797 AC_DEFINE([Rshutdown], [SOCKSshutdown], [Socks])
798 AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
799 AC_DEFINE([Rclose], [SOCKSclose], [Socks])
800 AC_DEFINE([Rdup], [SOCKSdup], [Socks])
801 AC_DEFINE([Rdup2], [SOCKSdup2], [Socks])
802 AC_DEFINE([Rfclose], [SOCKSfclose], [Socks])
803 AC_DEFINE([Rgethostbyname], [SOCKSgethostbyname], [Socks])
806 #ifdef SILC_DIST_MATH
807 # MP library checking. First check whether user wants to use GMP and use
808 # it if found. If not or not defined then compile the default library in the
813 SAVE_CFLAGS="$CFLAGS"
814 SAVE_LDFLAGS="$LDFLAGS"
815 AC_MSG_CHECKING(whether to search for GMP)
817 [[ --with-gmp[=DIR] use GMP instead of SILC Math [search in DIR/lib and DIR/include]]],
826 if test -d "$withval/include"; then
827 CFLAGS="$CFLAGS -I$withval/include"
829 if test -d "$withval/lib"; then
830 LDFLAGS="$LDFLAGS -L$withval/lib"
837 AC_CHECK_LIB(gmp, __gmpz_init,
840 AC_DEFINE([SILC_MP_GMP], [], [GMP])
841 AC_MSG_RESULT(Using GMP as a MP library.)
845 CFLAGS="$SAVE_CFLAGS"
846 LDFLAGS="$SAVE_LDFLAGS"
852 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
853 AM_CONDITIONAL(SILC_MP_SILCMATH, test x$mp_gmp = xfalse)
854 if test x$mp_gmp = xfalse; then
855 AC_DEFINE([SILC_MP_SILCMATH], [], [SILCMATH])
856 AC_MSG_RESULT(Using SILC Math as a MP library.)
858 #endif SILC_DIST_MATH
865 SAVE_CFLAGS="$CFLAGS"
866 SAVE_LDFLAGS="$LDFLAGS"
867 SAVE_CPPFLAGS="$CPPFLAGS"
868 AC_MSG_CHECKING(whether to implicit search for libiconv)
870 [[ --with-iconv[=DIR] use libiconv [search in DIR/include and DIR/lib]]],
875 AC_CHECK_HEADERS(iconv.h,
877 AC_CHECK_FUNC(iconv, has_iconv=true)
883 if test -d $withval/include; then
884 CPPFLAGS="$CPPFLAGS -I$withval/include"
885 CFLAGS="$CFLAGS -I$withval/include"
887 if test -d $withval/lib; then
888 LDFLAGS="$LDFLAGS -L$withval/lib"
895 AC_CHECK_HEADERS(iconv.h,
897 AC_CHECK_FUNCS(iconv,
905 if test x$check_iconv = xtrue; then
906 AC_MSG_RESULT(Searching for iconv...)
909 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
911 AC_CHECK_HEADERS(iconv.h,
914 AC_MSG_CHECKING(for iconv in -liconv)
921 iconv_t cd = iconv_open("", "");
922 iconv(cd, NULL, NULL, NULL, NULL);
927 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
934 CFLAGS="$SAVE_CFLAGS"
935 LDFLAGS="$SAVE_LDFLAGS"
936 CPPFLAGS="$SAVE_CPPFLAGS"
941 if test x$check_iconv = xtrue; then
942 # search for iconv library..
944 SAVE_CFLAGS="$CFLAGS"
945 SAVE_LDFLAGS="$LDFLAGS"
946 SAVE_CPPFLAGS="$CPPFLAGS"
948 for dir in `echo "/usr/local /usr/pkg /usr/contrib"`; do
949 if test x$has_iconv = xfalse; then
950 AC_MSG_RESULT(searching in $dir...)
952 if test -d $dir/include; then
953 CPPFLAGS="$CPPFLAGS -I$dir/include"
954 CFLAGS="$CFLAGS -I$dir/include"
956 if test -d $dir/lib; then
957 LDFLAGS="$LDFLAGS -L$dir/lib"
961 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
963 AC_CHECK_HEADERS(iconv.h,
966 AC_MSG_CHECKING(for iconv in -liconv)
973 iconv_t cd = iconv_open("", "");
974 iconv(cd, NULL, NULL, NULL, NULL);
980 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
987 CFLAGS="$SAVE_CFLAGS"
988 LDFLAGS="$SAVE_LDFLAGS"
989 CPPFLAGS="$SAVE_CPPFLAGS"
993 CFLAGS="$SAVE_CFLAGS"
994 LDFLAGS="$SAVE_LDFLAGS"
995 CPPFLAGS="$SAVE_CPPFLAGS"
1001 if test x$has_iconv = xtrue; then
1002 # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
1003 # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
1004 # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
1006 AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
1014 changequote([, ])dnl
1017 ob = buf, obl = sizeof(buf);
1018 return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
1019 (iconv(cd, 0, 0, &ob, &obl) ||
1020 !(ob == buf && obl == sizeof(buf)) ||
1035 if test x$ac_iconv_good = xno; then
1036 AC_MSG_RESULT(Try using libiconv instead.)
1040 # POSIX threads support
1042 AC_MSG_CHECKING(whether to search for POSIX threads)
1043 AC_ARG_WITH(pthreads,
1044 [[ --with-pthreads[=DIR] use POSIX threads [search in DIR/include and DIR/lib]]],
1046 case "${withval}" in
1051 if test -d $withval/include; then
1052 CPPFLAGS="$CPPFLAGS -I$withval/include"
1053 CFLAGS="$CFLAGS -I$withval/include"
1055 if test -d $withval/lib; then
1056 LDFLAGS="$LDFLAGS -L$withval/lib"
1064 if test x$check_threads = xtrue; then
1067 SAVE_CFLAGS="$CFLAGS"
1068 SAVE_LDFLAGS="$LDFLAGS"
1069 SAVE_CPPFLAGS="$CPPFLAGS"
1072 AC_CHECK_HEADERS(pthread.h,
1074 LIBS="$LIBS -lpthread"
1075 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1080 LIBS="$SAVE_LIBS -pthread"
1081 AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true, LIBS="$SAVE_LIBS")
1090 # search for pthread library..
1091 for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do
1092 if test x$has_threads = xfalse; then
1093 AC_MSG_RESULT(searching in $dir...)
1095 if test -d $dir/include; then
1096 CPPFLAGS="$CPPFLAGS -I$dir/include"
1097 CFLAGS="$CFLAGS -I$dir/include"
1099 if test -d $dir/lib; then
1100 LDFLAGS="$LDFLAGS -L$dir/lib"
1104 unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true
1106 AC_CHECK_HEADERS(pthread.h,
1108 LIBS="$LIBS -lpthread"
1109 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1114 CFLAGS="$SAVE_CFLAGS"
1115 LDFLAGS="$SAVE_LDFLAGS"
1116 CPPFLAGS="$SAVE_CPPFLAGS"
1120 CFLAGS="$SAVE_CFLAGS"
1121 LDFLAGS="$SAVE_LDFLAGS"
1122 CPPFLAGS="$SAVE_CPPFLAGS"
1132 __SILC_HAVE_PTHREAD=""
1133 AM_CONDITIONAL(SILC_THREADS, test x$has_threads = xtrue)
1134 if test x$has_threads = xtrue; then
1135 CFLAGS="$CFLAGS -D_REENTRANT"
1137 # XXX possibly incomplete
1140 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1141 if test x"$GCC" = xyes; then
1142 CFLAGS="$CFLAGS -mthreads"
1146 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1148 *-*-sysv5uw7*) # UnixWare 7
1149 if test "$GCC" != "yes"; then
1150 CFLAGS="$CFLAGS -Kthread"
1152 CFLAGS="$CFLAGS -pthread"
1156 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
1161 AC_CHECK_FUNC(pthread_create)
1163 # Check for read/write locks
1164 AC_CHECK_FUNC(pthread_rwlock_init,
1168 #include <pthread.h>
1171 pthread_rwlock_t rwlock;
1172 pthread_rwlock_init(&rwlock, NULL);
1173 pthread_rwlock_destroy(&rwlock);
1179 # Rwlock not defined
1180 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1185 # Rwlock not defined
1186 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1189 AC_DEFINE([SILC_HAVE_PTHREAD], [], [HAVE_PTHREAD])
1190 AC_DEFINE([SILC_THREADS], [], [HAVE_THREAD])
1191 __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1"
1195 # Check for timezone and tm_gmtoff for timezone information
1197 AC_MSG_CHECKING(whether system has timezone)
1208 [ AC_MSG_RESULT(yes)
1209 AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ],
1210 [ AC_MSG_RESULT(no) ],
1211 [ AC_MSG_RESULT(no) ]
1213 AC_MSG_CHECKING(whether system has tm_gmtoff)
1225 [ AC_MSG_RESULT(yes)
1226 AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ],
1227 [ AC_MSG_RESULT(no) ],
1228 [ AC_MSG_RESULT(no) ]
1230 AC_MSG_CHECKING(whether system has __tm_gmtoff)
1242 [ AC_MSG_RESULT(yes)
1243 AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ],
1244 [ AC_MSG_RESULT(no) ],
1245 [ AC_MSG_RESULT(no) ]
1247 AC_MSG_CHECKING(whether system has __tm_gmtoff__)
1255 tm.__tm_gmtoff__ = 0;
1259 [ AC_MSG_RESULT(yes)
1260 AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ],
1261 [ AC_MSG_RESULT(no) ],
1262 [ AC_MSG_RESULT(no) ]
1265 # Native WIN32 compilation under cygwin
1267 AC_MSG_CHECKING(whether to compile native WIN32 code)
1269 [ --with-win32 compile native WIN32 (MinGW) code (-mno-cygwin)],
1272 AC_DEFINE([SILC_WIN32], [], [SILC_WIN32])
1274 CFLAGS="-mno-cygwin $CFLAGS"
1275 LIBS="$LIBS -lwsock32"
1280 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
1282 # Native Symbian OS support (disabled by default)
1284 AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue)
1286 # Native BeOS support (disabled by default)
1288 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
1290 # Native OS2 support (disabled by default)
1292 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
1294 #ifdef SILC_DIST_SERVER
1296 #endif SILC_DIST_SERVER
1297 #ifdef SILC_DIST_CLIENT
1298 AM_CONDITIONAL(with_irssi, true)
1299 #endif SILC_DIST_CLIENT
1300 #ifdef SILC_DIST_INPLACE
1303 #endif SILC_DIST_INPLACE
1306 AC_MSG_CHECKING(whether to do libtoolfix)
1307 AC_ARG_WITH(libtoolfix,
1308 [ --without-libtoolfix Do not fix libtool, for package builders],
1318 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
1319 #endif SILC_DIST_COMPILER
1325 # Make enable-shared aware
1326 AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes)
1328 SILC_TOP_SRCDIR=`pwd`
1330 # Included configure scripts
1331 AD_INCLUDE_CONFIGURE
1333 #ifdef SILC_DIST_COMPILER
1338 AC_SUBST(SILC_TOP_SRCDIR)
1341 AC_SUBST(SILC_LIB_INCLUDES)
1342 AC_SUBST(__SILC_HAVE_PTHREAD)
1343 AC_SUBST(__SILC_HAVE_SIM)
1344 AC_SUBST(__SILC_ENABLE_DEBUG)
1345 AC_SUBST(__SILC_PACKAGE_VERSION)
1348 # Fix the libtool to support run-time configuration. This allows us
1349 # to in run-time specify when to compile shared/static libraries without
1350 # need to reconfigure the entire libtool.
1352 if test x$libtoolfix = xtrue; then
1353 ./libtoolfix $SILC_TOP_SRCDIR/ltmain.sh
1355 AM_CONDITIONAL(SILC_LIBTOOLFIX, test x$libtoolfix = xtrue)
1357 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
1358 AC_SUBST(INCLUDE_DEFINES_INT)
1360 #endif SILC_DIST_COMPILER
1367 #ifdef SILC_DIST_DOC
1369 #endif SILC_DIST_DOC
1370 #ifdef SILC_DIST_COMPILER
1372 Makefile.defines_int
1374 includes/silcversion.h
1376 #endif SILC_DIST_COMPILER
1377 #ifdef SILC_DIST_APPS
1379 #endif SILC_DIST_APPS
1382 #ifdef SILC_DIST_TOOLKIT
1385 win32/libsilc/Makefile
1386 win32/libsilcclient/Makefile
1388 tutorial/Makefile.defines
1389 tutorial/Makefile.defines_int
1391 #endif SILC_DIST_TOOLKIT
1395 #ifdef SILC_DIST_COMPILER
1396 s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir`
1397 s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir`
1398 s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir`
1399 s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir`
1402 echo "$PACKAGE Configuration Summary:"
1403 echo "---------------------------"
1404 echo " Target host ...................: $target"
1405 echo " Compiler ......................: $CC"
1406 echo " CFLAGS ........................: $CFLAGS"
1407 echo " LDFLAGS .......................: $LDFLAGS"
1408 echo " LIBS ..........................: $LIBS"
1410 echo " Installation prefix ...........: $prefix"
1411 echo " bin directory .................: $s_bindir"
1412 echo " sbin directory ................: $s_sbindir"
1413 echo " etc directory .................: $ETCDIR"
1414 echo " man directory .................: $s_mandir"
1415 echo " doc directory .................: $DOCDIR"
1416 #ifdef SILC_DIST_SIM
1417 echo " SIM directory .................: $MODULESDIR"
1418 #endif SILC_DIST_SIM
1419 #ifdef SILC_DIST_INCLUDES
1420 echo " include directory .............: $s_includedir"
1421 #endif SILC_DIST_INCLUDES
1424 #ifdef SILC_DIST_CLIENT
1425 if test x$without_irssi = xtrue; then
1428 echo " Compile SILC Client ...........: $irssi"
1429 #endif SILC_DIST_CLIENT
1431 #ifdef SILC_DIST_SERVER
1432 if test x$without_silcd = xtrue; then
1435 echo " Compile SILC Server ...........: $silcd"
1436 #endif SILC_DIST_SERVER
1438 #ifdef SILC_DIST_SIM
1439 if test x$sim_support = xfalse; then
1444 echo " SIM support ...................: $sim_support"
1445 #endif SILC_DIST_SIM
1447 echo " IPv6 support ..................: $summary_ipv6"
1449 if test x$has_iconv = xfalse; then
1454 echo " Iconv support .................: $iconv_support"
1456 if test x$want_asm = xfalse; then
1461 echo " Assembler optimizations .......: $summary_asm"
1463 #ifdef SILC_DIST_MATH
1464 if test x$mp_gmp = xtrue; then
1465 echo " Arithmetic library ............: GMP"
1467 #endif SILC_DIST_MATH
1470 if test x$has_threads = xtrue; then
1473 echo " Multi-threads support .........: $threads"
1474 echo " Debugging enabled .............: $summary_debug"
1476 echo "Compile the sources with 'make' or 'gmake' command."
1477 #endif SILC_DIST_COMPILER