4 # Author: Pekka Riikonen <priikone@silcnet.org>
6 # Copyright (C) 2000 - 2007, 2009 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`
62 AC_DEFINE([SILC_I386], [], [SILC_I386])
63 AC_DEFINE([SILC_I486], [], [SILC_I486])
68 AC_DEFINE([SILC_I486], [], [SILC_I486])
72 AC_DEFINE([SILC_X86_64], [], [SILC_X86_64])
76 AC_DEFINE([SILC_POWERPC], [], [SILC_POWERPC])
80 AC_DEFINE([SILC_IA64], [], [SILC_IA64])
84 AM_CONDITIONAL(SILC_I386, test x$cpu_i386 = xtrue)
85 AM_CONDITIONAL(SILC_I486, test x$cpu_ix86 = xtrue)
86 AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue)
87 AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue)
88 AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue)
90 # Control compiler optimizations
91 CFLAGS=`echo $CFLAGS | sed 's/-O[ 0123456789s]*//g'`
97 __SILC_HAVE_PTHREAD=""
99 __SILC_ENABLE_DEBUG=""
101 #ifdef SILC_DIST_TOOLKIT
102 toolkitver=`echo $VERSION | sed 's/\./ /g'`
108 if test $maj -eq 0; then
112 if test $min -eq 0; then
116 if test $bld -eq 0; then
121 __SILC_PACKAGE_VERSION="#define __SILC_TOOLKIT_VERSION SILC_VERSION($maj,$min,$bld)"
122 #endif SILC_DIST_TOOLKIT
126 #ifndef SILC_DIST_TOOLKIT
128 #endif SILC_DIST_TOOLKIT
129 #ifdef SILC_DIST_INPLACE
131 #endif SILC_DIST_INPLACE
139 # More header checking
141 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
142 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
143 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h sys/resource.h)
144 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
145 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h)
146 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
156 AC_CHECK_SIZEOF(long long, 0)
157 AC_SUBST(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
158 AC_CHECK_SIZEOF(long, 0)
159 AC_SUBST(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
160 AC_CHECK_SIZEOF(int, 0)
161 AC_SUBST(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
162 AC_CHECK_SIZEOF(short, 0)
163 AC_SUBST(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
164 AC_CHECK_SIZEOF(char, 0)
165 AC_SUBST(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
166 AC_CHECK_SIZEOF(void *, 0)
167 AC_SUBST(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
168 AC_CHECK_TYPES(long long)
169 AC_CHECK_TYPES(long double)
171 # Function to check if compiler flag works
172 # Usage: SILC_ADD_CFLAGS(FLAGS, [ACTION-IF-FAILED])
173 AC_DEFUN([SILC_ADD_CFLAGS],
174 [ tmp_CFLAGS="$CFLAGS"
176 AC_MSG_CHECKING(whether $CC accepts $1 flag)
177 AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
183 # Function to check if compiler flag works, destination specifiable
184 # Usage: SILC_ADD_CC_FLAGS(VAR, FLAGS, [ACTION-IF-FAILED])
185 AC_DEFUN([SILC_ADD_CC_FLAGS],
186 [ tmp_CFLAGS="$1_CFLAGS"
187 $1_CFLAGS="${$1_CFLAGS} $2"
188 AC_MSG_CHECKING(whether $CC accepts $2 flag)
189 AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
190 $1_CFLAGS="$tmp_CFLAGS"
195 # Function and library checking
197 AC_CHECK_FUNC(gethostbyname, [],
199 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
200 AC_CHECK_FUNC(res_gethostbyname, [],
201 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
204 AC_CHECK_FUNC(socket, [],
205 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
207 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
208 AC_CHECK_FUNCS(poll select listen bind shutdown close connect setsockopt)
209 AC_CHECK_FUNCS(setrlimit time ctime utime gettimeofday getrusage)
210 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror posix_memalign)
211 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid sched_yield)
212 AC_CHECK_FUNCS(setgroups initgroups nl_langinfo nanosleep backtrace)
213 AC_CHECK_FUNCS(strchr snprintf strstr strcpy strncpy memcpy memset memmove)
215 # lib/contrib conditionals
217 AC_CHECK_HEADER(regex.h,
219 AC_DEFINE([HAVE_REGEX_H], [], [HAVE_REGEX_H])
223 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
225 AC_CHECK_FUNC(getopt_long,
227 AC_DEFINE([HAVE_GETOPT_LONG], [], [HAVE_GETOPT_LONG])
229 ], have_getopt_long=0
232 AC_CHECK_FUNC(getopt,
234 AC_DEFINE([HAVE_GETOPT], [], [HAVE_GETOPT])
240 ## Enable/disable checking
245 AC_MSG_CHECKING(whether to enable IPv6 support)
247 [ --enable-ipv6 enable IPv6 support],
249 case "${enableval}" in
254 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
268 if test x$check_ipv6 = xtrue; then
272 #ifdef HAVE_SYS_TYPES_H
273 #include <sys/types.h>
275 #ifdef HAVE_NETINET_TCP_H
276 #include <netinet/tcp.h>
281 #include <sys/socket.h>
282 #ifdef HAVE_NETINET_IN_H
283 #include <netinet/in.h>
287 struct sockaddr_in6 sin6;
288 int family = AF_INET6;
291 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
301 AC_MSG_CHECKING(whether to enable debugging)
303 __SILC_ENABLE_DEBUG=""
305 [ --enable-debug enable debugging],
307 case "${enableval}" in
310 AC_DEFINE([SILC_DEBUG], [], [enable-debug])
312 __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1"
323 # Disable all compiler optimizations
325 AC_MSG_CHECKING(whether to enable compiler optimizations)
326 want_cc_optimizations=true
327 AC_ARG_ENABLE(optimizations,
328 [ --disable-optimizations do not use any compiler optimizations],
331 AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS])
332 want_cc_optimizations=false
336 want_cc_optimizations=true
338 AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse)
340 # Disable all assembler optimizations
342 AC_MSG_CHECKING(whether to enable assembler optimizations)
345 [ --disable-asm do not use assembler optimizations],
348 AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM])
355 AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse)
357 # Check for assembler
361 if test x$want_asm = xtrue; then
362 AC_PATH_PROG([NASM], [nasm], [no])
363 if test "x$NASM" != "xno"; then
364 if test x$cpu_x86_64 = xtrue; then
365 SILC_ASSEMBLER="$NASM -O2 -felf64"
367 SILC_ASSEMBLER="$NASM -O2 -felf"
372 AC_PATH_PROG([YASM], [yasm], [no])
373 if test "x$YASM" != "xno"; then
374 if test x$cpu_x86_64 = xtrue; then
375 SILC_ASSEMBLER="$YASM -Xgnu -felf64"
377 SILC_ASSEMBLER="$YASM -Xgnu -felf"
382 AC_SUBST(SILC_ASSEMBLER)
388 AC_MSG_CHECKING(for va_copy)
400 if (va_arg(cp, int) != 0xff11)
412 AC_DEFINE([HAVE_VA_COPY], [], [HAVE_VA_COPY])
422 if test x$va_copy = xfalse; then
423 AC_MSG_CHECKING(for __va_copy)
435 if (va_arg(cp, int) != 0xff11)
447 AC_DEFINE([HAVE___VA_COPY], [], [HAVE___VA_COPY])
458 if test x$va_copy = xfalse; then
468 if (va_arg(cp, int) != 0xff11)
481 AC_DEFINE([SILC_VA_COPY_ARRAY], [], [SILC_VA_COPY_ARRAY])
488 ## Compiler and compiler flag checks
492 # GCC specific options
493 if test "x$summary_debug" = "xyes"; then
498 SILC_ADD_CFLAGS(-Wall -finline-functions)
499 SILC_ADD_CFLAGS(-Wno-pointer-sign)
514 # Intel C++ Compiler needs -restrict
515 if test "x$CC" = "xicc"; then
516 SILC_ADD_CFLAGS(-restrict)
520 if test x$want_cc_optimizations = xtrue; then
522 # GCC specific options
523 if test "x$summary_debug" = "xyes"; then
532 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
535 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
538 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
545 # Workaround a bug in GCC 2.x which causes memory exhaustion
546 # when compiling sha1 with optimizations on UltraSPARC.
549 if test "$GCC" -a "$host_cpu" = "sparc64"; then
550 AC_MSG_CHECKING(whether to enable GCC 2.x workaround for SHA1)
553 #if defined(__sparc64__) && (__GNUC__ == 2)
567 #endif SILC_DIST_COMPILER
573 # Default installation destination
575 AC_PREFIX_DEFAULT(/usr/local)
576 if test "x$prefix" != xNONE; then
577 silc_prefix="$prefix"
579 silc_prefix="$ac_default_prefix"
580 prefix="$silc_prefix"
583 #ifndef SILC_DIST_AUTODIST
584 ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR`
586 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
588 DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR`
590 AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR])
591 #endif SILC_DIST_AUTODIST
593 #ifdef SILC_DIST_COMPILER
595 ## With/without checkings
599 # SILC library checking
603 #ifndef SILC_DIST_TOOLKIT
604 AC_ARG_WITH(silc-includes,
605 [ --with-silc-includes=DIR SILC Toolkit includes [search in DIR]],
606 [ac_silc_includes="$withval"], [ac_silc_includes="no"])
607 AC_ARG_WITH(silc-libs,
608 [ --with-silc-libs=DIR SILC Toolkit libraries [search in DIR]],
609 [ac_silc_libs="$withval"], [ac_silc_libs="no"])
611 if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then
613 # Manually provided libs
614 if test "$ac_silc_includes" != "no"; then
616 SILC_LIB_INCLUDES="-I$ac_silc_includes"
619 if test "$ac_silc_libs" != "no"; then
622 LDFLAGS="-L$ac_silc_libs $LDFLAGS"
624 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
627 # Check libs to link against
628 f=`$EGREP __SILC_HAVE_PTHREAD $ac_silc_includes/silc.h`
629 if test -n "$f"; then
630 LIBS="$LIBS -lpthread"
634 f=`$EGREP __SILC_HAVE_SIM $ac_silc_includes/silc.h`
635 if test -n "$f"; then
641 PKG_CHECK_MODULES(SILC, [silc >= 1.1], compile_libs=false, compile_libs=true)
642 #ifdef SILC_DIST_CLIENTLIB
643 PKG_CHECK_MODULES(SILCCLIENT, [silcclient >= 1.1.1], compile_libs=false, compile_libs=true)
644 #endif SILC_DIST_CLIENTLIB
645 #ifdef SILC_DIST_SERVERLIB
646 PKG_CHECK_MODULES(SILCSERVER, silcserver, compile_libs=false, compile_libs=true)
647 #endif SILC_DIST_SERVERLIB
649 if test x$compile_libs = xfalse; then
651 LIBS="$SILC_LIBS $LIBS"
652 CFLAGS="$CFLAGS $SILC_CFLAGS"
653 #ifdef SILC_DIST_CLIENTLIB
654 LIBS="$SILCCLIENT_LIBS $LIBS"
655 CFLAGS="$CFLAGS $SILCCLIENT_CFLAGS"
656 #endif SILC_DIST_CLIENTLIB
657 #ifdef SILC_DIST_SERVERLIB
658 LIBS="$LIBS $SILCSERVER_LIBS"
659 CFLAGS="$CFLAGS $SILCSERVER_CFLAGS"
660 #endif SILC_DIST_SERVERLIB
662 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
665 #else SILC_DIST_TOOLKIT
666 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
667 #endif SILC_DIST_TOOLKIT
670 # SIM support checking
671 # XXX These needs to be changed as more supported platforms appear.
672 # XXX This probably needs to be made platform dependant check.
675 AC_MSG_CHECKING(for SIM support)
677 AC_CHECK_HEADERS(dlfcn.h,
679 AC_CHECK_LIB(dl, dlopen,
681 AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
686 AC_CHECK_LIB(c, dlopen,
688 AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
694 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
695 if test x$sim_support = xtrue; then
696 AC_MSG_RESULT(Enabled SIM support.)
697 __SILC_HAVE_SIM="#define __SILC_HAVE_SIM 1"
699 AC_MSG_RESULT(No SIM support found.)
703 # SOCKS4 support checking
706 SAVE_CFLAGS="$CFLAGS"
707 SAVE_LDFLAGS="$LDFLAGS"
708 AC_MSG_CHECKING(whether to support SOCKS4)
710 [[ --with-socks4[=DIR] with SOCKS4 support [search in DIR/lib and DIR/include]]],
720 if test -d "$withval/include"; then
721 CFLAGS="$CFLAGS -I$withval/include"
723 if test -d "$withval/lib"; then
724 LDFLAGS="$LDFLAGS -L$withval/lib"
736 AC_MSG_ERROR(Could not find SOCKS4 library.)
738 CFLAGS="$SAVE_CFLAGS"
739 LDFLAGS="$SAVE_LDFLAGS"
745 # SOCKS5 support checking
748 SAVE_CFLAGS="$CFLAGS"
749 SAVE_LDFLAGS="$LDFLAGS"
750 AC_MSG_CHECKING(whether to support SOCKS5)
752 [[ --with-socks5[=DIR] with SOCKS5 support [search in DIR/lib and DIR/include]]],
762 if test -d "$withval/include"; then
763 CFLAGS="$CFLAGS -I$withval/include"
765 if test -d "$withval/lib"; then
766 LDFLAGS="$LDFLAGS -L$withval/lib"
769 LIBS="-lsocks5 $LIBS"
778 AC_MSG_ERROR(Could not find SOCKS5 library.)
780 CFLAGS="$SAVE_CFLAGS"
781 LDFLAGS="$SAVE_LDFLAGS"
787 if test "x$socks" = "x4"; then
788 AC_DEFINE([SOCKS], [], [Socks])
789 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
792 if test "x$socks" = "x5"; then
793 AC_DEFINE([SOCKS], [], [Socks])
794 AC_DEFINE([SOCKS5], [], [Socks5])
795 AC_DEFINE([Rconnect], [SOCKSconnect], [Socks])
796 AC_DEFINE([Rgetsockname], [SOCKSgetsockname], [Socks])
797 AC_DEFINE([Rgetpeername], [SOCKSgetpeername], [Socks])
798 AC_DEFINE([Rbind], [SOCKSbind], [Socks])
799 AC_DEFINE([Raccept], [SOCKSaccept], [Socks])
800 AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
801 AC_DEFINE([Rselect], [SOCKSselect], [Socks])
802 AC_DEFINE([Rrecvfrom], [SOCKSrecvfrom], [Socks])
803 AC_DEFINE([Rsendto], [SOCKSsendto], [Socks])
804 AC_DEFINE([Rrecv], [SOCKSrecv], [Socks])
805 AC_DEFINE([Rsend], [SOCKSsend], [Socks])
806 AC_DEFINE([Rread], [SOCKSread], [Socks])
807 AC_DEFINE([Rwrite], [SOCKSwrite], [Socks])
808 AC_DEFINE([Rrresvport], [SOCKSrresvport], [Socks])
809 AC_DEFINE([Rshutdown], [SOCKSshutdown], [Socks])
810 AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
811 AC_DEFINE([Rclose], [SOCKSclose], [Socks])
812 AC_DEFINE([Rdup], [SOCKSdup], [Socks])
813 AC_DEFINE([Rdup2], [SOCKSdup2], [Socks])
814 AC_DEFINE([Rfclose], [SOCKSfclose], [Socks])
815 AC_DEFINE([Rgethostbyname], [SOCKSgethostbyname], [Socks])
818 #ifdef SILC_DIST_MATH
819 # MP library checking. First check whether user wants to use GMP and use
820 # it if found. If not or not defined then compile the default library in the
825 SAVE_CFLAGS="$CFLAGS"
826 SAVE_LDFLAGS="$LDFLAGS"
827 AC_MSG_CHECKING(whether to search for GMP)
829 [[ --with-gmp[=DIR] use GMP instead of SILC Math [search in DIR/lib and DIR/include]]],
838 if test -d "$withval/include"; then
839 CFLAGS="$CFLAGS -I$withval/include"
841 if test -d "$withval/lib"; then
842 LDFLAGS="$LDFLAGS -L$withval/lib"
849 AC_CHECK_LIB(gmp, __gmpz_init,
852 AC_DEFINE([SILC_MP_GMP], [], [GMP])
853 AC_MSG_RESULT(Using GMP as a MP library.)
857 CFLAGS="$SAVE_CFLAGS"
858 LDFLAGS="$SAVE_LDFLAGS"
864 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
865 AM_CONDITIONAL(SILC_MP_SILCMATH, test x$mp_gmp = xfalse)
866 if test x$mp_gmp = xfalse; then
867 AC_DEFINE([SILC_MP_SILCMATH], [], [SILCMATH])
868 AC_MSG_RESULT(Using SILC Math as a MP library.)
870 #endif SILC_DIST_MATH
877 SAVE_CFLAGS="$CFLAGS"
878 SAVE_LDFLAGS="$LDFLAGS"
879 SAVE_CPPFLAGS="$CPPFLAGS"
880 AC_MSG_CHECKING(whether to implicit search for libiconv)
882 [[ --with-iconv[=DIR] use libiconv [search in DIR/include and DIR/lib]]],
887 AC_CHECK_HEADERS(iconv.h,
889 AC_CHECK_FUNC(iconv, has_iconv=true)
895 if test -d $withval/include; then
896 CPPFLAGS="$CPPFLAGS -I$withval/include"
897 CFLAGS="$CFLAGS -I$withval/include"
899 if test -d $withval/lib; then
900 LDFLAGS="$LDFLAGS -L$withval/lib"
907 AC_CHECK_HEADERS(iconv.h,
909 AC_CHECK_FUNCS(iconv,
917 if test x$check_iconv = xtrue; then
918 AC_MSG_RESULT(Searching for iconv...)
921 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
923 AC_CHECK_HEADERS(iconv.h,
926 AC_MSG_CHECKING(for iconv in -liconv)
933 iconv_t cd = iconv_open("", "");
934 iconv(cd, NULL, NULL, NULL, NULL);
939 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
946 CFLAGS="$SAVE_CFLAGS"
947 LDFLAGS="$SAVE_LDFLAGS"
948 CPPFLAGS="$SAVE_CPPFLAGS"
953 if test x$check_iconv = xtrue; then
954 # search for iconv library..
956 SAVE_CFLAGS="$CFLAGS"
957 SAVE_LDFLAGS="$LDFLAGS"
958 SAVE_CPPFLAGS="$CPPFLAGS"
960 for dir in `echo "/usr/local /usr/pkg /usr/contrib"`; do
961 if test x$has_iconv = xfalse; then
962 AC_MSG_RESULT(searching in $dir...)
964 if test -d $dir/include; then
965 CPPFLAGS="$CPPFLAGS -I$dir/include"
966 CFLAGS="$CFLAGS -I$dir/include"
968 if test -d $dir/lib; then
969 LDFLAGS="$LDFLAGS -L$dir/lib"
973 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
975 AC_CHECK_HEADERS(iconv.h,
978 AC_MSG_CHECKING(for iconv in -liconv)
985 iconv_t cd = iconv_open("", "");
986 iconv(cd, NULL, NULL, NULL, NULL);
992 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
999 CFLAGS="$SAVE_CFLAGS"
1000 LDFLAGS="$SAVE_LDFLAGS"
1001 CPPFLAGS="$SAVE_CPPFLAGS"
1005 CFLAGS="$SAVE_CFLAGS"
1006 LDFLAGS="$SAVE_LDFLAGS"
1007 CPPFLAGS="$SAVE_CPPFLAGS"
1013 if test x$has_iconv = xtrue; then
1014 # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
1015 # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
1016 # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
1018 AC_CACHE_CHECK([whether this iconv is good enough], ac_cv_iconv_good,
1026 changequote([, ])dnl
1029 ob = buf, obl = sizeof(buf);
1030 return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
1031 (iconv(cd, 0, 0, &ob, &obl) ||
1032 !(ob == buf && obl == sizeof(buf)) ||
1037 ac_cv_iconv_good=yes
1043 ac_cv_iconv_good=yes
1047 if test x$ac_cv_iconv_good = xno; then
1048 AC_MSG_RESULT(Try using libiconv instead.)
1052 # POSIX threads support
1054 AC_MSG_CHECKING(whether to search for POSIX threads)
1055 AC_ARG_WITH(pthreads,
1056 [[ --with-pthreads[=DIR] use POSIX threads [search in DIR/include and DIR/lib]]],
1058 case "${withval}" in
1063 if test -d $withval/include; then
1064 CPPFLAGS="$CPPFLAGS -I$withval/include"
1065 CFLAGS="$CFLAGS -I$withval/include"
1067 if test -d $withval/lib; then
1068 LDFLAGS="$LDFLAGS -L$withval/lib"
1076 if test x$check_threads = xtrue; then
1079 SAVE_CFLAGS="$CFLAGS"
1080 SAVE_LDFLAGS="$LDFLAGS"
1081 SAVE_CPPFLAGS="$CPPFLAGS"
1084 AC_CHECK_HEADERS(pthread.h,
1086 LIBS="$LIBS -lpthread"
1087 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1092 LIBS="$SAVE_LIBS -pthread"
1093 AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true, LIBS="$SAVE_LIBS")
1102 # search for pthread library..
1103 for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do
1104 if test x$has_threads = xfalse; then
1105 AC_MSG_RESULT(searching in $dir...)
1107 if test -d $dir/include; then
1108 CPPFLAGS="$CPPFLAGS -I$dir/include"
1109 CFLAGS="$CFLAGS -I$dir/include"
1111 if test -d $dir/lib; then
1112 LDFLAGS="$LDFLAGS -L$dir/lib"
1116 unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true
1118 AC_CHECK_HEADERS(pthread.h,
1120 LIBS="$LIBS -lpthread"
1121 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1126 CFLAGS="$SAVE_CFLAGS"
1127 LDFLAGS="$SAVE_LDFLAGS"
1128 CPPFLAGS="$SAVE_CPPFLAGS"
1132 CFLAGS="$SAVE_CFLAGS"
1133 LDFLAGS="$SAVE_LDFLAGS"
1134 CPPFLAGS="$SAVE_CPPFLAGS"
1144 __SILC_HAVE_PTHREAD=""
1145 AM_CONDITIONAL(SILC_THREADS, test x$has_threads = xtrue)
1146 if test x$has_threads = xtrue; then
1147 CFLAGS="$CFLAGS -D_REENTRANT"
1149 # XXX possibly incomplete
1152 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1153 if test x"$GCC" = xyes; then
1154 CFLAGS="$CFLAGS -mthreads"
1158 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1160 *-*-sysv5uw7*) # UnixWare 7
1161 if test "$GCC" != "yes"; then
1162 CFLAGS="$CFLAGS -Kthread"
1164 CFLAGS="$CFLAGS -pthread"
1168 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
1173 AC_CHECK_FUNC(pthread_create)
1175 # Check for read/write locks
1176 AC_CHECK_FUNC(pthread_rwlock_init,
1180 #include <pthread.h>
1183 pthread_rwlock_t rwlock;
1184 pthread_rwlock_init(&rwlock, NULL);
1185 pthread_rwlock_destroy(&rwlock);
1191 # Rwlock not defined
1192 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1197 # Rwlock not defined
1198 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1201 AC_DEFINE([SILC_HAVE_PTHREAD], [], [HAVE_PTHREAD])
1202 AC_DEFINE([SILC_THREADS], [], [HAVE_THREAD])
1203 __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1"
1207 # Check for timezone and tm_gmtoff for timezone information
1209 AC_MSG_CHECKING(whether system has timezone)
1220 [ AC_MSG_RESULT(yes)
1221 AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ],
1222 [ AC_MSG_RESULT(no) ],
1223 [ AC_MSG_RESULT(no) ]
1225 AC_MSG_CHECKING(whether system has tm_gmtoff)
1237 [ AC_MSG_RESULT(yes)
1238 AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ],
1239 [ AC_MSG_RESULT(no) ],
1240 [ AC_MSG_RESULT(no) ]
1242 AC_MSG_CHECKING(whether system has __tm_gmtoff)
1254 [ AC_MSG_RESULT(yes)
1255 AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ],
1256 [ AC_MSG_RESULT(no) ],
1257 [ AC_MSG_RESULT(no) ]
1259 AC_MSG_CHECKING(whether system has __tm_gmtoff__)
1267 tm.__tm_gmtoff__ = 0;
1271 [ AC_MSG_RESULT(yes)
1272 AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ],
1273 [ AC_MSG_RESULT(no) ],
1274 [ AC_MSG_RESULT(no) ]
1277 # Native WIN32 compilation under cygwin
1279 AC_MSG_CHECKING(whether to compile native WIN32 code)
1281 [ --with-win32 compile native WIN32 (MinGW) code (-mno-cygwin)],
1284 AC_DEFINE([SILC_WIN32], [], [SILC_WIN32])
1286 CFLAGS="-mno-cygwin $CFLAGS"
1287 LIBS="$LIBS -lwsock32"
1292 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
1294 # Native Symbian OS support (disabled by default)
1296 AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue)
1298 # Native BeOS support (disabled by default)
1300 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
1302 # Native OS2 support (disabled by default)
1304 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
1306 #ifdef SILC_DIST_SERVER
1308 #endif SILC_DIST_SERVER
1309 #ifdef SILC_DIST_CLIENT
1310 AM_CONDITIONAL(with_irssi, true)
1311 #endif SILC_DIST_CLIENT
1312 #ifdef SILC_DIST_INPLACE
1315 #endif SILC_DIST_INPLACE
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)
1347 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
1348 AC_SUBST(INCLUDE_DEFINES_INT)
1350 #endif SILC_DIST_COMPILER
1357 #ifdef SILC_DIST_DOC
1359 #endif SILC_DIST_DOC
1360 #ifdef SILC_DIST_COMPILER
1362 Makefile.defines_int
1364 includes/silcversion.h
1366 #endif SILC_DIST_COMPILER
1367 #ifdef SILC_DIST_APPS
1369 #endif SILC_DIST_APPS
1372 #ifdef SILC_DIST_TOOLKIT
1375 win32/libsilc/Makefile
1376 win32/libsilcclient/Makefile
1378 tutorial/Makefile.defines
1379 tutorial/Makefile.defines_int
1381 #endif SILC_DIST_TOOLKIT
1385 #ifdef SILC_DIST_COMPILER
1387 s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir`
1388 s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir`
1389 s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir`
1390 s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir`
1393 echo "$PACKAGE Configuration Summary:"
1394 echo "---------------------------"
1395 echo " Target host ...................: $target"
1396 echo " Compiler ......................: $CC"
1397 echo " CFLAGS ........................: $CFLAGS"
1398 echo " LDFLAGS .......................: $LDFLAGS"
1399 echo " LIBS ..........................: $LIBS"
1401 echo " Installation prefix ...........: $prefix"
1402 echo " bin directory .................: $s_bindir"
1403 echo " sbin directory ................: $s_sbindir"
1404 echo " etc directory .................: $ETCDIR"
1405 echo " man directory .................: $s_mandir"
1406 echo " doc directory .................: $DOCDIR"
1407 #ifdef SILC_DIST_SIM
1408 echo " SIM directory .................: $MODULESDIR"
1409 #endif SILC_DIST_SIM
1410 #ifdef SILC_DIST_INCLUDES
1411 echo " include directory .............: $s_includedir"
1412 #endif SILC_DIST_INCLUDES
1415 #ifdef SILC_DIST_CLIENT
1416 if test x$without_irssi = xtrue; then
1419 echo " Compile SILC Client ...........: $irssi"
1420 #endif SILC_DIST_CLIENT
1422 #ifdef SILC_DIST_SERVER
1423 if test x$without_silcd = xtrue; then
1426 echo " Compile SILC Server ...........: $silcd"
1427 #endif SILC_DIST_SERVER
1429 #ifdef SILC_DIST_SIM
1430 if test x$sim_support = xfalse; then
1435 echo " SIM support ...................: $sim_support"
1436 #endif SILC_DIST_SIM
1438 echo " IPv6 support ..................: $summary_ipv6"
1440 if test x$has_iconv = xfalse; then
1445 echo " Iconv support .................: $iconv_support"
1447 if test x$want_asm = xfalse; then
1452 echo " Assembler optimizations .......: $summary_asm"
1454 #ifdef SILC_DIST_MATH
1455 if test x$mp_gmp = xtrue; then
1456 echo " Arithmetic library ............: GMP"
1458 #endif SILC_DIST_MATH
1461 if test x$has_threads = xtrue; then
1464 echo " Multi-threads support .........: $threads"
1465 echo " Debugging enabled .............: $summary_debug"
1467 echo "Compile the sources with 'make' or 'gmake' command."
1468 #endif SILC_DIST_COMPILER