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
38 CFLAGS=`echo $CFLAGS -D_GNU_SOURCE`
64 # All following Intels are considered 32-bit CPUs.
66 AC_DEFINE([SILC_I386], [], [SILC_I386])
67 AC_DEFINE([SILC_I486], [], [SILC_I486])
71 if test "x$host_cpu" = "xi586"; then
72 AC_DEFINE([SILC_I586], [], [SILC_I586])
76 if test "x$host_cpu" = "xi686"; then
77 AC_DEFINE([SILC_I586], [], [SILC_I586])
78 AC_DEFINE([SILC_I686], [], [SILC_I686])
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])
93 # Intel IA-64, 64-bit CPU (not x86_64 compatible)
95 AC_DEFINE([SILC_IA64], [], [SILC_IA64])
99 # AMD/Intel x86_64, 64-bit CPU
101 AC_DEFINE([SILC_X86_64], [], [SILC_X86_64])
105 # PowerPC, 32-bit and 64-bit CPUs
107 AC_DEFINE([SILC_POWERPC], [], [SILC_POWERPC])
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)
120 # Control compiler optimizations
121 CFLAGS=`echo $CFLAGS | sed 's/-O[ 0123456789s]*//g'`
127 __SILC_HAVE_PTHREAD=""
129 __SILC_ENABLE_DEBUG=""
131 #ifdef SILC_DIST_TOOLKIT
132 toolkitver=`echo $VERSION | sed 's/\./ /g'`
138 if test $maj -eq 0; then
142 if test $min -eq 0; then
146 if test $bld -eq 0; then
151 __SILC_PACKAGE_VERSION="#define __SILC_TOOLKIT_VERSION SILC_VERSION($maj,$min,$bld)"
152 #endif SILC_DIST_TOOLKIT
155 #ifndef SILC_DIST_TOOLKIT
157 #endif SILC_DIST_TOOLKIT
158 #ifdef SILC_DIST_INPLACE
160 #endif SILC_DIST_INPLACE
169 # More header checking
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)
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)
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"
206 AC_MSG_CHECKING(whether $CC accepts $1 flag)
207 AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
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"
225 # Function and library checking
227 AC_CHECK_FUNC(gethostbyname, [],
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")
234 AC_CHECK_FUNC(socket, [],
235 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
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)
246 # lib/contrib conditionals
248 AC_CHECK_HEADER(regex.h,
250 AC_DEFINE([HAVE_REGEX_H], [], [HAVE_REGEX_H])
254 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
256 AC_CHECK_FUNC(getopt_long,
258 AC_DEFINE([HAVE_GETOPT_LONG], [], [HAVE_GETOPT_LONG])
260 ], have_getopt_long=0
263 AC_CHECK_FUNC(getopt,
265 AC_DEFINE([HAVE_GETOPT], [], [HAVE_GETOPT])
271 ## Enable/disable checking
276 AC_MSG_CHECKING(whether to enable IPv6 support)
278 [ --enable-ipv6 enable IPv6 support],
280 case "${enableval}" in
285 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
299 if test x$check_ipv6 = xtrue; then
303 #ifdef HAVE_SYS_TYPES_H
304 #include <sys/types.h>
306 #ifdef HAVE_NETINET_TCP_H
307 #include <netinet/tcp.h>
312 #include <sys/socket.h>
313 #ifdef HAVE_NETINET_IN_H
314 #include <netinet/in.h>
318 struct sockaddr_in6 sin6;
319 int family = AF_INET6;
322 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
332 AC_MSG_CHECKING(whether to enable debugging)
334 __SILC_ENABLE_DEBUG=""
336 [ --enable-debug enable debugging],
338 case "${enableval}" in
341 AC_DEFINE([SILC_DEBUG], [], [enable-debug])
343 __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1"
354 # Disable all compiler optimizations
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],
362 AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS])
363 want_cc_optimizations=false
367 want_cc_optimizations=true
369 AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse)
371 # Disable all assembler optimizations
373 AC_MSG_CHECKING(whether to enable assembler optimizations)
376 [ --disable-asm do not use assembler optimizations],
379 AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM])
386 AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse)
388 # Check for assembler
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"
399 AC_PATH_PROG([YASM], [yasm], [no])
400 if test "x$YASM" != "xno"; then
401 SILC_ASSEMBLER="$YASM -Xgnu -felf"
405 AC_SUBST(SILC_ASSEMBLER)
411 AC_MSG_CHECKING(for va_copy)
423 if (va_arg(cp, int) != 0xff11)
435 AC_DEFINE([HAVE_VA_COPY], [], [HAVE_VA_COPY])
445 if test x$va_copy = xfalse; then
446 AC_MSG_CHECKING(for __va_copy)
458 if (va_arg(cp, int) != 0xff11)
470 AC_DEFINE([HAVE___VA_COPY], [], [HAVE___VA_COPY])
481 if test x$va_copy = xfalse; then
491 if (va_arg(cp, int) != 0xff11)
504 AC_DEFINE([SILC_VA_COPY_ARRAY], [], [SILC_VA_COPY_ARRAY])
511 ## Compiler and compiler flag checks
515 # GCC specific options
516 if test "x$summary_debug" = "xyes"; then
521 SILC_ADD_CFLAGS(-Wall -finline-functions)
522 SILC_ADD_CFLAGS(-Wno-pointer-sign)
537 # Intel C++ Compiler needs -restrict
538 if test "x$CC" = "xicc"; then
539 SILC_ADD_CFLAGS(-restrict)
543 if test x$want_cc_optimizations = xtrue; then
545 # GCC specific options
546 if test "x$summary_debug" = "xyes"; then
555 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
558 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
561 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
568 # Workaround a bug in GCC 2.x which causes memory exhaustion
569 # when compiling sha1 with optimizations on UltraSPARC.
572 if test "$GCC" -a "$host_cpu" = "sparc64"; then
573 AC_MSG_CHECKING(whether to enable GCC 2.x workaround for SHA1)
576 #if defined(__sparc64__) && (__GNUC__ == 2)
590 #endif SILC_DIST_COMPILER
596 # Default installation destination
598 AC_PREFIX_DEFAULT(/usr/local)
599 if test "x$prefix" != xNONE; then
600 silc_prefix="$prefix"
602 silc_prefix="$ac_default_prefix"
603 prefix="$silc_prefix"
606 #ifndef SILC_DIST_AUTODIST
607 ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR`
609 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
611 DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR`
613 AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR])
614 #endif SILC_DIST_AUTODIST
616 #ifdef SILC_DIST_COMPILER
618 ## With/without checkings
622 # SILC library checking
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"])
634 if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then
636 # Manually provided libs
637 if test "$ac_silc_includes" != "no"; then
639 SILC_LIB_INCLUDES="-I$ac_silc_includes"
642 if test "$ac_silc_libs" != "no"; then
645 LDFLAGS="-L$ac_silc_libs $LDFLAGS"
647 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
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"
657 f=`$EGREP __SILC_HAVE_SIM $ac_silc_includes/silc.h`
658 if test -n "$f"; then
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
672 if test x$compile_libs = xfalse; then
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
685 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
688 #else SILC_DIST_TOOLKIT
689 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
690 #endif SILC_DIST_TOOLKIT
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.
698 AC_MSG_CHECKING(for SIM support)
700 AC_CHECK_HEADERS(dlfcn.h,
702 AC_CHECK_LIB(dl, dlopen,
704 AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
705 AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN])
710 AC_CHECK_LIB(c, dlopen,
712 AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
713 AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN])
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"
724 AC_MSG_RESULT(No SIM support found.)
728 # SOCKS4 support checking
731 SAVE_CFLAGS="$CFLAGS"
732 SAVE_LDFLAGS="$LDFLAGS"
733 AC_MSG_CHECKING(whether to support SOCKS4)
735 [[ --with-socks4[=DIR] with SOCKS4 support [search in DIR/lib and DIR/include]]],
745 if test -d "$withval/include"; then
746 CFLAGS="$CFLAGS -I$withval/include"
748 if test -d "$withval/lib"; then
749 LDFLAGS="$LDFLAGS -L$withval/lib"
761 AC_MSG_ERROR(Could not find SOCKS4 library.)
763 CFLAGS="$SAVE_CFLAGS"
764 LDFLAGS="$SAVE_LDFLAGS"
770 # SOCKS5 support checking
773 SAVE_CFLAGS="$CFLAGS"
774 SAVE_LDFLAGS="$LDFLAGS"
775 AC_MSG_CHECKING(whether to support SOCKS5)
777 [[ --with-socks5[=DIR] with SOCKS5 support [search in DIR/lib and DIR/include]]],
787 if test -d "$withval/include"; then
788 CFLAGS="$CFLAGS -I$withval/include"
790 if test -d "$withval/lib"; then
791 LDFLAGS="$LDFLAGS -L$withval/lib"
794 LIBS="-lsocks5 $LIBS"
803 AC_MSG_ERROR(Could not find SOCKS5 library.)
805 CFLAGS="$SAVE_CFLAGS"
806 LDFLAGS="$SAVE_LDFLAGS"
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"
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])
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
850 SAVE_CFLAGS="$CFLAGS"
851 SAVE_LDFLAGS="$LDFLAGS"
852 AC_MSG_CHECKING(whether to search for GMP)
854 [[ --with-gmp[=DIR] use GMP instead of SILC Math [search in DIR/lib and DIR/include]]],
863 if test -d "$withval/include"; then
864 CFLAGS="$CFLAGS -I$withval/include"
866 if test -d "$withval/lib"; then
867 LDFLAGS="$LDFLAGS -L$withval/lib"
874 AC_CHECK_LIB(gmp, __gmpz_init,
877 AC_DEFINE([SILC_MP_GMP], [], [GMP])
878 AC_MSG_RESULT(Using GMP as a MP library.)
882 CFLAGS="$SAVE_CFLAGS"
883 LDFLAGS="$SAVE_LDFLAGS"
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.)
895 #endif SILC_DIST_MATH
902 SAVE_CFLAGS="$CFLAGS"
903 SAVE_LDFLAGS="$LDFLAGS"
904 SAVE_CPPFLAGS="$CPPFLAGS"
905 AC_MSG_CHECKING(whether to implicit search for libiconv)
907 [[ --with-iconv[=DIR] use libiconv [search in DIR/include and DIR/lib]]],
912 AC_CHECK_HEADERS(iconv.h,
914 AC_CHECK_FUNC(iconv, has_iconv=true)
920 if test -d $withval/include; then
921 CPPFLAGS="$CPPFLAGS -I$withval/include"
922 CFLAGS="$CFLAGS -I$withval/include"
924 if test -d $withval/lib; then
925 LDFLAGS="$LDFLAGS -L$withval/lib"
932 AC_CHECK_HEADERS(iconv.h,
934 AC_CHECK_FUNCS(iconv,
942 if test x$check_iconv = xtrue; then
943 AC_MSG_RESULT(Searching for iconv...)
946 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
948 AC_CHECK_HEADERS(iconv.h,
951 AC_MSG_CHECKING(for iconv in -liconv)
958 iconv_t cd = iconv_open("", "");
959 iconv(cd, NULL, NULL, NULL, NULL);
964 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
971 CFLAGS="$SAVE_CFLAGS"
972 LDFLAGS="$SAVE_LDFLAGS"
973 CPPFLAGS="$SAVE_CPPFLAGS"
978 if test x$check_iconv = xtrue; then
979 # search for iconv library..
981 SAVE_CFLAGS="$CFLAGS"
982 SAVE_LDFLAGS="$LDFLAGS"
983 SAVE_CPPFLAGS="$CPPFLAGS"
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...)
989 if test -d $dir/include; then
990 CPPFLAGS="$CPPFLAGS -I$dir/include"
991 CFLAGS="$CFLAGS -I$dir/include"
993 if test -d $dir/lib; then
994 LDFLAGS="$LDFLAGS -L$dir/lib"
998 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
1000 AC_CHECK_HEADERS(iconv.h,
1002 LIBS="$LIBS -liconv"
1003 AC_MSG_CHECKING(for iconv in -liconv)
1010 iconv_t cd = iconv_open("", "");
1011 iconv(cd, NULL, NULL, NULL, NULL);
1017 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
1024 CFLAGS="$SAVE_CFLAGS"
1025 LDFLAGS="$SAVE_LDFLAGS"
1026 CPPFLAGS="$SAVE_CPPFLAGS"
1030 CFLAGS="$SAVE_CFLAGS"
1031 LDFLAGS="$SAVE_LDFLAGS"
1032 CPPFLAGS="$SAVE_CPPFLAGS"
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).
1043 AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
1051 changequote([, ])dnl
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)) ||
1072 if test x$ac_iconv_good = xno; then
1073 AC_MSG_RESULT(Try using libiconv instead.)
1077 # POSIX threads support
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]]],
1083 case "${withval}" in
1088 if test -d $withval/include; then
1089 CPPFLAGS="$CPPFLAGS -I$withval/include"
1090 CFLAGS="$CFLAGS -I$withval/include"
1092 if test -d $withval/lib; then
1093 LDFLAGS="$LDFLAGS -L$withval/lib"
1101 if test x$check_threads = xtrue; then
1104 SAVE_CFLAGS="$CFLAGS"
1105 SAVE_LDFLAGS="$LDFLAGS"
1106 SAVE_CPPFLAGS="$CPPFLAGS"
1109 AC_CHECK_HEADERS(pthread.h,
1111 LIBS="$LIBS -lpthread"
1112 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1117 LIBS="$SAVE_LIBS -pthread"
1118 AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true, LIBS="$SAVE_LIBS")
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...)
1132 if test -d $dir/include; then
1133 CPPFLAGS="$CPPFLAGS -I$dir/include"
1134 CFLAGS="$CFLAGS -I$dir/include"
1136 if test -d $dir/lib; then
1137 LDFLAGS="$LDFLAGS -L$dir/lib"
1141 unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true
1143 AC_CHECK_HEADERS(pthread.h,
1145 LIBS="$LIBS -lpthread"
1146 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1151 CFLAGS="$SAVE_CFLAGS"
1152 LDFLAGS="$SAVE_LDFLAGS"
1153 CPPFLAGS="$SAVE_CPPFLAGS"
1157 CFLAGS="$SAVE_CFLAGS"
1158 LDFLAGS="$SAVE_LDFLAGS"
1159 CPPFLAGS="$SAVE_CPPFLAGS"
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"
1174 # XXX possibly incomplete
1177 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1178 if test x"$GCC" = xyes; then
1179 CFLAGS="$CFLAGS -mthreads"
1183 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1185 *-*-sysv5uw7*) # UnixWare 7
1186 if test "$GCC" != "yes"; then
1187 CFLAGS="$CFLAGS -Kthread"
1189 CFLAGS="$CFLAGS -pthread"
1193 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
1198 AC_CHECK_FUNC(pthread_create)
1200 # Check for read/write locks
1201 AC_CHECK_FUNC(pthread_rwlock_init,
1205 #include <pthread.h>
1208 pthread_rwlock_t rwlock;
1209 pthread_rwlock_init(&rwlock, NULL);
1210 pthread_rwlock_destroy(&rwlock);
1216 # Rwlock not defined
1217 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1222 # Rwlock not defined
1223 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1226 AC_DEFINE([SILC_HAVE_PTHREAD], [], [HAVE_PTHREAD])
1227 AC_DEFINE([SILC_THREADS], [], [HAVE_THREAD])
1228 __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1"
1232 # Check for timezone and tm_gmtoff for timezone information
1234 AC_MSG_CHECKING(whether system has timezone)
1245 [ AC_MSG_RESULT(yes)
1246 AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ],
1247 [ AC_MSG_RESULT(no) ],
1248 [ AC_MSG_RESULT(no) ]
1250 AC_MSG_CHECKING(whether system has tm_gmtoff)
1262 [ AC_MSG_RESULT(yes)
1263 AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ],
1264 [ AC_MSG_RESULT(no) ],
1265 [ AC_MSG_RESULT(no) ]
1267 AC_MSG_CHECKING(whether system has __tm_gmtoff)
1279 [ AC_MSG_RESULT(yes)
1280 AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ],
1281 [ AC_MSG_RESULT(no) ],
1282 [ AC_MSG_RESULT(no) ]
1284 AC_MSG_CHECKING(whether system has __tm_gmtoff__)
1292 tm.__tm_gmtoff__ = 0;
1296 [ AC_MSG_RESULT(yes)
1297 AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ],
1298 [ AC_MSG_RESULT(no) ],
1299 [ AC_MSG_RESULT(no) ]
1302 # Native WIN32 compilation under cygwin
1304 AC_MSG_CHECKING(whether to compile native WIN32 code)
1306 [ --with-win32 compile native WIN32 (MinGW) code (-mno-cygwin)],
1309 AC_DEFINE([SILC_WIN32], [], [SILC_WIN32])
1311 CFLAGS="-mno-cygwin $CFLAGS"
1312 LIBS="$LIBS -lwsock32"
1317 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
1319 # Native Symbian OS support (disabled by default)
1321 AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue)
1323 # Native BeOS support (disabled by default)
1325 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
1327 # Native OS2 support (disabled by default)
1329 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
1331 #ifdef SILC_DIST_SERVER
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
1340 #endif SILC_DIST_INPLACE
1343 AC_MSG_CHECKING(whether to do libtoolfix)
1344 AC_ARG_WITH(libtoolfix,
1345 [ --without-libtoolfix Do not fix libtool, for package builders],
1355 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
1356 #endif SILC_DIST_COMPILER
1362 # Make enable-shared aware
1363 AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes)
1365 SILC_TOP_SRCDIR=`pwd`
1367 # Included configure scripts
1368 AD_INCLUDE_CONFIGURE
1370 #ifdef SILC_DIST_COMPILER
1375 AC_SUBST(SILC_TOP_SRCDIR)
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)
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.
1389 if test x$libtoolfix = xtrue; then
1390 ./libtoolfix $SILC_TOP_SRCDIR/ltmain.sh
1392 AM_CONDITIONAL(SILC_LIBTOOLFIX, test x$libtoolfix = xtrue)
1394 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
1395 AC_SUBST(INCLUDE_DEFINES_INT)
1397 #endif SILC_DIST_COMPILER
1404 #ifdef SILC_DIST_DOC
1406 #endif SILC_DIST_DOC
1407 #ifdef SILC_DIST_COMPILER
1409 Makefile.defines_int
1411 includes/silcversion.h
1413 #endif SILC_DIST_COMPILER
1414 #ifdef SILC_DIST_APPS
1416 #endif SILC_DIST_APPS
1419 #ifdef SILC_DIST_TOOLKIT
1422 win32/libsilc/Makefile
1423 win32/libsilcclient/Makefile
1425 tutorial/Makefile.defines
1426 tutorial/Makefile.defines_int
1428 #endif SILC_DIST_TOOLKIT
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`
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"
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
1461 #ifdef SILC_DIST_CLIENT
1462 if test x$without_irssi = xtrue; then
1465 echo " Compile SILC Client ...........: $irssi"
1466 #endif SILC_DIST_CLIENT
1468 #ifdef SILC_DIST_SERVER
1469 if test x$without_silcd = xtrue; then
1472 echo " Compile SILC Server ...........: $silcd"
1473 #endif SILC_DIST_SERVER
1475 #ifdef SILC_DIST_SIM
1476 if test x$sim_support = xfalse; then
1481 echo " SIM support ...................: $sim_support"
1482 #endif SILC_DIST_SIM
1484 echo " IPv6 support ..................: $summary_ipv6"
1486 if test x$has_iconv = xfalse; then
1491 echo " Iconv support .................: $iconv_support"
1493 if test x$want_asm = xfalse; then
1498 echo " Assembler optimizations .......: $summary_asm"
1500 #ifdef SILC_DIST_MATH
1501 if test x$mp_gmp = xtrue; then
1502 echo " Arithmetic library ............: GMP"
1504 #endif SILC_DIST_MATH
1507 if test x$has_threads = xtrue; then
1510 echo " Multi-threads support .........: $threads"
1511 echo " Debugging enabled .............: $summary_debug"
1513 echo "Compile the sources with 'make' or 'gmake' command."
1514 #endif SILC_DIST_COMPILER