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
34 # Put here any platform specific stuff
39 CFLAGS=`echo $CFLAGS -D_GNU_SOURCE`
56 SILC_SYSTEM_IS_SMP(AC_DEFINE([SILC_SMP], [], [SILC_SMP]), [],
57 AC_DEFINE([SILC_SMP], [], [SILC_SMP]))
67 # All following Intels are considered 32-bit CPUs.
69 # All CPUs of today are considered i386 and i486 compatible */
70 AC_DEFINE([SILC_I386], [], [SILC_I386])
71 AC_DEFINE([SILC_I486], [], [SILC_I486])
75 if test "x$host_cpu" = "xi586"; then
76 AC_DEFINE([SILC_I586], [], [SILC_I586])
80 if test "x$host_cpu" = "xi686"; then
81 AC_DEFINE([SILC_I586], [], [SILC_I586])
82 AC_DEFINE([SILC_I686], [], [SILC_I686])
87 if test "x$host_cpu" = "xi786"; then
88 AC_DEFINE([SILC_I586], [], [SILC_I586])
89 AC_DEFINE([SILC_I686], [], [SILC_I686])
90 AC_DEFINE([SILC_I786], [], [SILC_I786])
96 # Check for specific CPU features
97 SILC_CPU_FLAG(mmx, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), [])
98 SILC_CPU_FLAG(sse2, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
99 SILC_CPU_FLAG(pni, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
100 SILC_CPU_FLAG(ssse3, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
101 SILC_CPU_FLAG(sse4, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), [])
104 # Intel IA-64, 64-bit CPU (not x86_64 compatible)
106 AC_DEFINE([SILC_IA64], [], [SILC_IA64])
109 # Check for specific CPU features
110 SILC_CPU_FLAG(mmx, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), [])
111 SILC_CPU_FLAG(sse2, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
112 SILC_CPU_FLAG(pni, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
113 SILC_CPU_FLAG(ssse3, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
114 SILC_CPU_FLAG(sse4, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), [])
117 # AMD/Intel x86_64, 64-bit CPU
119 AC_DEFINE([SILC_X86_64], [], [SILC_X86_64])
122 # Check for specific CPU features
123 SILC_CPU_FLAG(mmx, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), [])
124 SILC_CPU_FLAG(sse2, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
125 SILC_CPU_FLAG(pni, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
126 SILC_CPU_FLAG(ssse3, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
127 SILC_CPU_FLAG(sse4, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), [])
130 # PowerPC, 32-bit and 64-bit CPUs
132 AC_DEFINE([SILC_POWERPC], [], [SILC_POWERPC])
136 AM_CONDITIONAL(SILC_I386, test x$cpu_i386 = xtrue)
137 AM_CONDITIONAL(SILC_I486, test x$cpu_i486 = xtrue)
138 AM_CONDITIONAL(SILC_I586, test x$cpu_i586 = xtrue)
139 AM_CONDITIONAL(SILC_I686, test x$cpu_i686 = xtrue)
140 AM_CONDITIONAL(SILC_7686, test x$cpu_i786 = xtrue)
141 AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue)
142 AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue)
143 AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue)
145 # Control compiler optimizations
146 CFLAGS=`echo $CFLAGS | sed 's/-O[ 0123456789s]*//g'`
152 # Set some compiler options based on CPU
153 if test "x$CC" = "xicc"; then
155 if test x$x_have_cpu_sse2 = xtrue; then
156 SILC_ADD_CFLAGS(-axW)
158 if test x$x_have_cpu_sse3 = xtrue; then
159 SILC_ADD_CFLAGS(-axP)
161 if test x$x_have_cpu_ssse3 = xtrue; then
162 SILC_ADD_CFLAGS(-axT)
164 if test x$x_have_cpu_sse4 = xtrue; then
165 SILC_ADD_CFLAGS(-axS)
169 if test x$x_have_cpu_sse2 = xtrue; then
170 SILC_ADD_CFLAGS(-msse2)
172 if test x$x_have_cpu_pni = xtrue; then
173 SILC_ADD_CFLAGS(-msse3)
175 if test x$x_have_cpu_ssse3 = xtrue; then
176 SILC_ADD_CFLAGS(-mssse3)
178 if test x$x_have_cpu_sse4 = xtrue; then
179 SILC_ADD_CFLAGS(-msse3)
183 __SILC_HAVE_PTHREAD=""
185 __SILC_ENABLE_DEBUG=""
187 #ifdef SILC_DIST_TOOLKIT
188 toolkitver=`echo $VERSION | sed 's/\./ /g'`
194 if test $maj -eq 0; then
198 if test $min -eq 0; then
202 if test $bld -eq 0; then
207 __SILC_PACKAGE_VERSION="#define __SILC_TOOLKIT_VERSION SILC_VERSION($maj,$min,$bld)"
208 #endif SILC_DIST_TOOLKIT
211 #ifndef SILC_DIST_TOOLKIT
213 #endif SILC_DIST_TOOLKIT
214 #ifdef SILC_DIST_INPLACE
216 #endif SILC_DIST_INPLACE
225 # More header checking
227 AC_CHECK_HEADERS(unistd.h string.h errno.h fcntl.h assert.h)
228 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
229 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h sys/resource.h)
230 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
231 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h)
232 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
242 AC_CHECK_SIZEOF(long long, 0)
243 AC_SUBST(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
244 AC_CHECK_SIZEOF(long, 0)
245 AC_SUBST(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
246 AC_CHECK_SIZEOF(int, 0)
247 AC_SUBST(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
248 AC_CHECK_SIZEOF(short, 0)
249 AC_SUBST(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
250 AC_CHECK_SIZEOF(char, 0)
251 AC_SUBST(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
252 AC_CHECK_SIZEOF(void *, 0)
253 AC_SUBST(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
254 AC_CHECK_TYPES(long long)
255 AC_CHECK_TYPES(long double)
257 # Function and library checking
259 AC_CHECK_FUNC(gethostbyname, [],
261 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
262 AC_CHECK_FUNC(res_gethostbyname, [],
263 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
266 AC_CHECK_FUNC(socket, [],
267 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
269 AC_CHECK_FUNC(clock_gettime, [],
271 AC_CHECK_LIB(rt, clock_gettime,
273 AC_DEFINE([HAVE_CLOCK_GETTIME], [], [HAVE_CLOCK_GETTIME])])
275 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
276 AC_CHECK_FUNCS(poll select listen bind shutdown close connect setsockopt)
277 AC_CHECK_FUNCS(setrlimit time ctime utime gettimeofday getrusage)
278 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
279 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid sched_yield)
280 AC_CHECK_FUNCS(setgroups initgroups nl_langinfo nanosleep)
281 AC_CHECK_FUNCS(strchr snprintf strstr strcpy strncpy memcpy memset memmove)
282 AC_CHECK_FUNCS(setenv getenv putenv unsetenv clearenv)
284 # lib/contrib conditionals
286 AC_CHECK_HEADER(regex.h,
288 AC_DEFINE([HAVE_REGEX_H], [], [HAVE_REGEX_H])
292 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
294 AC_CHECK_FUNC(getopt_long,
296 AC_DEFINE([HAVE_GETOPT_LONG], [], [HAVE_GETOPT_LONG])
298 ], have_getopt_long=0
302 ## Enable/disable checking
307 AC_MSG_CHECKING(whether to enable IPv6 support)
309 [ --enable-ipv6 enable IPv6 support],
311 case "${enableval}" in
316 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
330 if test x$check_ipv6 = xtrue; then
334 #ifdef HAVE_SYS_TYPES_H
335 #include <sys/types.h>
337 #ifdef HAVE_NETINET_TCP_H
338 #include <netinet/tcp.h>
343 #include <sys/socket.h>
344 #ifdef HAVE_NETINET_IN_H
345 #include <netinet/in.h>
349 struct sockaddr_in6 sin6;
350 int family = AF_INET6;
353 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
363 AC_MSG_CHECKING(whether to enable debugging)
365 __SILC_ENABLE_DEBUG=""
367 [ --enable-debug enable debugging],
369 case "${enableval}" in
372 AC_DEFINE([SILC_DEBUG], [], [enable-debug])
374 __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1"
385 # Disable all compiler optimizations
387 AC_MSG_CHECKING(whether to enable compiler optimizations)
388 want_cc_optimizations=true
389 AC_ARG_ENABLE(optimizations,
390 [ --disable-optimizations do not use any compiler optimizations],
393 AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS])
394 want_cc_optimizations=false
398 want_cc_optimizations=true
400 AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse)
402 # Disable all assembler optimizations
404 AC_MSG_CHECKING(whether to enable assembler optimizations)
407 [ --disable-asm do not use assembler optimizations],
410 AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM])
417 AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse)
419 # Check for assembler
423 if test x$want_asm = xtrue; then
424 AC_PATH_PROG([NASM], [nasm], [no])
425 if test "x$NASM" != "xno"; then
426 if test x$cpu_x86_64 = xtrue; then
427 SILC_ASSEMBLER="$NASM -O2 -felf64"
429 SILC_ASSEMBLER="$NASM -O2 -felf"
434 AC_PATH_PROG([YASM], [yasm], [no])
435 if test "x$YASM" != "xno"; then
436 if test x$cpu_x86_64 = xtrue; then
437 SILC_ASSEMBLER="$YASM -Xgnu -felf64"
439 SILC_ASSEMBLER="$YASM -Xgnu -felf"
444 AC_SUBST(SILC_ASSEMBLER)
450 AC_MSG_CHECKING(for va_copy)
462 if (va_arg(cp, int) != 0xff11)
474 AC_DEFINE([HAVE_VA_COPY], [], [HAVE_VA_COPY])
484 if test x$va_copy = xfalse; then
485 AC_MSG_CHECKING(for __va_copy)
497 if (va_arg(cp, int) != 0xff11)
509 AC_DEFINE([HAVE___VA_COPY], [], [HAVE___VA_COPY])
520 if test x$va_copy = xfalse; then
530 if (va_arg(cp, int) != 0xff11)
543 AC_DEFINE([SILC_VA_COPY_ARRAY], [], [SILC_VA_COPY_ARRAY])
550 ## Compiler and compiler flag checks
554 # GCC specific options
555 if test "x$summary_debug" = "xyes"; then
560 SILC_ADD_CFLAGS(-Wall -finline-functions)
561 SILC_ADD_CFLAGS(-Wno-pointer-sign)
576 # Intel C++ Compiler flags
577 if test "x$CC" = "xicc"; then
578 SILC_ADD_CFLAGS(-restrict)
579 SILC_ADD_CFLAGS(-finline-functions)
581 # Don't define __GNUC__ except for system includes
582 SILC_ADD_CFLAGS(-gcc-sys)
586 if test x$want_cc_optimizations = xtrue; then
588 # GCC specific options
589 if test "x$summary_debug" = "xyes"; then
598 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
601 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
604 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
611 # Workaround a bug in GCC 2.x which causes memory exhaustion
612 # when compiling sha1 with optimizations on UltraSPARC.
615 if test "$GCC" -a "$host_cpu" = "sparc64"; then
616 AC_MSG_CHECKING(whether to enable GCC 2.x workaround for SHA1)
619 #if defined(__sparc64__) && (__GNUC__ == 2)
633 #endif SILC_DIST_COMPILER
639 # Default installation destination
641 AC_PREFIX_DEFAULT(/usr/local)
642 if test "x$prefix" != xNONE; then
643 silc_prefix="$prefix"
645 silc_prefix="$ac_default_prefix"
646 prefix="$silc_prefix"
649 #ifndef SILC_DIST_AUTODIST
650 ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR`
652 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
654 DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR`
656 AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR])
657 #endif SILC_DIST_AUTODIST
659 #ifdef SILC_DIST_COMPILER
661 ## With/without checkings
665 # SILC library checking
669 #ifndef SILC_DIST_TOOLKIT
670 AC_ARG_WITH(silc-includes,
671 [ --with-silc-includes=DIR SILC Toolkit includes [search in DIR]],
672 [ac_silc_includes="$withval"], [ac_silc_includes="no"])
673 AC_ARG_WITH(silc-libs,
674 [ --with-silc-libs=DIR SILC Toolkit libraries [search in DIR]],
675 [ac_silc_libs="$withval"], [ac_silc_libs="no"])
677 if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then
679 # Manually provided libs
680 if test "$ac_silc_includes" != "no"; then
682 SILC_LIB_INCLUDES="-I$ac_silc_includes"
685 if test "$ac_silc_libs" != "no"; then
688 LDFLAGS="-L$ac_silc_libs $LDFLAGS"
690 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
693 # Check libs to link against
694 f=`$EGREP __SILC_HAVE_PTHREAD $ac_silc_includes/silc.h`
695 if test -n "$f"; then
696 LIBS="$LIBS -lpthread"
700 f=`$EGREP __SILC_HAVE_SIM $ac_silc_includes/silc.h`
701 if test -n "$f"; then
707 PKG_CHECK_MODULES(SILC, [silc >= 1.1], compile_libs=false, compile_libs=true)
708 #ifdef SILC_DIST_CLIENTLIB
709 PKG_CHECK_MODULES(SILCCLIENT, [silcclient >= 1.1.1], compile_libs=false, compile_libs=true)
710 #endif SILC_DIST_CLIENTLIB
711 #ifdef SILC_DIST_SERVERLIB
712 PKG_CHECK_MODULES(SILCSERVER, silcserver, compile_libs=false, compile_libs=true)
713 #endif SILC_DIST_SERVERLIB
715 if test x$compile_libs = xfalse; then
717 LIBS="$SILC_LIBS $LIBS"
718 CFLAGS="$CFLAGS $SILC_CFLAGS"
719 #ifdef SILC_DIST_CLIENTLIB
720 LIBS="$SILCCLIENT_LIBS $LIBS"
721 CFLAGS="$CFLAGS $SILCCLIENT_CFLAGS"
722 #endif SILC_DIST_CLIENTLIB
723 #ifdef SILC_DIST_SERVERLIB
724 LIBS="$LIBS $SILCSERVER_LIBS"
725 CFLAGS="$CFLAGS $SILCSERVER_CFLAGS"
726 #endif SILC_DIST_SERVERLIB
728 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
732 #else SILC_DIST_TOOLKIT
733 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
734 #endif SILC_DIST_TOOLKIT
737 # SIM support checking
738 # XXX These needs to be changed as more supported platforms appear.
739 # XXX This probably needs to be made platform dependant check.
742 AC_MSG_CHECKING(for SIM support)
744 AC_CHECK_HEADERS(dlfcn.h,
746 AC_CHECK_LIB(dl, dlopen,
748 AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
749 AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN])
754 AC_CHECK_LIB(c, dlopen,
756 AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
757 AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN])
763 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
764 if test x$sim_support = xtrue; then
765 AC_MSG_RESULT(Enabled SIM support.)
766 __SILC_HAVE_SIM="#define __SILC_HAVE_SIM 1"
768 AC_MSG_RESULT(No SIM support found.)
772 # SOCKS4 support checking
775 SAVE_CFLAGS="$CFLAGS"
776 SAVE_LDFLAGS="$LDFLAGS"
777 AC_MSG_CHECKING(whether to support SOCKS4)
779 [[ --with-socks4[=DIR] with SOCKS4 support [search in DIR/lib and DIR/include]]],
789 if test -d "$withval/include"; then
790 CFLAGS="$CFLAGS -I$withval/include"
792 if test -d "$withval/lib"; then
793 LDFLAGS="$LDFLAGS -L$withval/lib"
805 AC_MSG_ERROR(Could not find SOCKS4 library.)
807 CFLAGS="$SAVE_CFLAGS"
808 LDFLAGS="$SAVE_LDFLAGS"
814 # SOCKS5 support checking
817 SAVE_CFLAGS="$CFLAGS"
818 SAVE_LDFLAGS="$LDFLAGS"
819 AC_MSG_CHECKING(whether to support SOCKS5)
821 [[ --with-socks5[=DIR] with SOCKS5 support [search in DIR/lib and DIR/include]]],
831 if test -d "$withval/include"; then
832 CFLAGS="$CFLAGS -I$withval/include"
834 if test -d "$withval/lib"; then
835 LDFLAGS="$LDFLAGS -L$withval/lib"
838 LIBS="-lsocks5 $LIBS"
847 AC_MSG_ERROR(Could not find SOCKS5 library.)
849 CFLAGS="$SAVE_CFLAGS"
850 LDFLAGS="$SAVE_LDFLAGS"
856 if test "x$socks" = "x4"; then
857 AC_DEFINE([SOCKS], [], [Socks])
858 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
861 if test "x$socks" = "x5"; then
862 AC_DEFINE([SOCKS], [], [Socks])
863 AC_DEFINE([SOCKS5], [], [Socks5])
864 AC_DEFINE([Rconnect], [SOCKSconnect], [Socks])
865 AC_DEFINE([Rgetsockname], [SOCKSgetsockname], [Socks])
866 AC_DEFINE([Rgetpeername], [SOCKSgetpeername], [Socks])
867 AC_DEFINE([Rbind], [SOCKSbind], [Socks])
868 AC_DEFINE([Raccept], [SOCKSaccept], [Socks])
869 AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
870 AC_DEFINE([Rselect], [SOCKSselect], [Socks])
871 AC_DEFINE([Rrecvfrom], [SOCKSrecvfrom], [Socks])
872 AC_DEFINE([Rsendto], [SOCKSsendto], [Socks])
873 AC_DEFINE([Rrecv], [SOCKSrecv], [Socks])
874 AC_DEFINE([Rsend], [SOCKSsend], [Socks])
875 AC_DEFINE([Rread], [SOCKSread], [Socks])
876 AC_DEFINE([Rwrite], [SOCKSwrite], [Socks])
877 AC_DEFINE([Rrresvport], [SOCKSrresvport], [Socks])
878 AC_DEFINE([Rshutdown], [SOCKSshutdown], [Socks])
879 AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
880 AC_DEFINE([Rclose], [SOCKSclose], [Socks])
881 AC_DEFINE([Rdup], [SOCKSdup], [Socks])
882 AC_DEFINE([Rdup2], [SOCKSdup2], [Socks])
883 AC_DEFINE([Rfclose], [SOCKSfclose], [Socks])
884 AC_DEFINE([Rgethostbyname], [SOCKSgethostbyname], [Socks])
887 #ifdef SILC_DIST_MATH
888 # MP library checking. First check whether user wants to use GMP and use
889 # it if found. If not or not defined then compile the default library in the
894 SAVE_CFLAGS="$CFLAGS"
895 SAVE_LDFLAGS="$LDFLAGS"
896 AC_MSG_CHECKING(whether to search for GMP)
898 [[ --with-gmp[=DIR] use GMP instead of SILC Math [search in DIR/lib and DIR/include]]],
907 if test -d "$withval/include"; then
908 CFLAGS="$CFLAGS -I$withval/include"
910 if test -d "$withval/lib"; then
911 LDFLAGS="$LDFLAGS -L$withval/lib"
918 AC_CHECK_LIB(gmp, __gmpz_init,
921 AC_DEFINE([SILC_MP_GMP], [], [GMP])
922 AC_MSG_RESULT(Using GMP as a MP library.)
926 CFLAGS="$SAVE_CFLAGS"
927 LDFLAGS="$SAVE_LDFLAGS"
933 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
934 AM_CONDITIONAL(SILC_MP_SILCMATH, test x$mp_gmp = xfalse)
935 if test x$mp_gmp = xfalse; then
936 AC_DEFINE([SILC_MP_SILCMATH], [], [SILCMATH])
937 AC_MSG_RESULT(Using SILC Math as a MP library.)
939 #endif SILC_DIST_MATH
946 SAVE_CFLAGS="$CFLAGS"
947 SAVE_LDFLAGS="$LDFLAGS"
948 SAVE_CPPFLAGS="$CPPFLAGS"
949 AC_MSG_CHECKING(whether to implicit search for libiconv)
951 [[ --with-iconv[=DIR] use libiconv [search in DIR/include and DIR/lib]]],
956 AC_CHECK_HEADERS(iconv.h,
958 AC_CHECK_FUNC(iconv, has_iconv=true)
964 if test -d $withval/include; then
965 CPPFLAGS="$CPPFLAGS -I$withval/include"
966 CFLAGS="$CFLAGS -I$withval/include"
968 if test -d $withval/lib; then
969 LDFLAGS="$LDFLAGS -L$withval/lib"
976 AC_CHECK_HEADERS(iconv.h,
978 AC_CHECK_FUNCS(iconv,
986 if test x$check_iconv = xtrue; then
987 AC_MSG_RESULT(Searching for iconv...)
990 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
992 AC_CHECK_HEADERS(iconv.h,
995 AC_MSG_CHECKING(for iconv in -liconv)
1002 iconv_t cd = iconv_open("", "");
1003 iconv(cd, NULL, NULL, NULL, NULL);
1008 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
1015 CFLAGS="$SAVE_CFLAGS"
1016 LDFLAGS="$SAVE_LDFLAGS"
1017 CPPFLAGS="$SAVE_CPPFLAGS"
1022 if test x$check_iconv = xtrue; then
1023 # search for iconv library..
1025 SAVE_CFLAGS="$CFLAGS"
1026 SAVE_LDFLAGS="$LDFLAGS"
1027 SAVE_CPPFLAGS="$CPPFLAGS"
1029 for dir in `echo "/usr/local /usr/pkg /usr/contrib"`; do
1030 if test x$has_iconv = xfalse; then
1031 AC_MSG_RESULT(searching in $dir...)
1033 if test -d $dir/include; then
1034 CPPFLAGS="$CPPFLAGS -I$dir/include"
1035 CFLAGS="$CFLAGS -I$dir/include"
1037 if test -d $dir/lib; then
1038 LDFLAGS="$LDFLAGS -L$dir/lib"
1042 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
1044 AC_CHECK_HEADERS(iconv.h,
1046 LIBS="$LIBS -liconv"
1047 AC_MSG_CHECKING(for iconv in -liconv)
1054 iconv_t cd = iconv_open("", "");
1055 iconv(cd, NULL, NULL, NULL, NULL);
1061 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
1068 CFLAGS="$SAVE_CFLAGS"
1069 LDFLAGS="$SAVE_LDFLAGS"
1070 CPPFLAGS="$SAVE_CPPFLAGS"
1074 CFLAGS="$SAVE_CFLAGS"
1075 LDFLAGS="$SAVE_LDFLAGS"
1076 CPPFLAGS="$SAVE_CPPFLAGS"
1082 if test x$has_iconv = xtrue; then
1083 # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
1084 # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
1085 # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
1087 AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
1095 changequote([, ])dnl
1098 ob = buf, obl = sizeof(buf);
1099 return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
1100 (iconv(cd, 0, 0, &ob, &obl) ||
1101 !(ob == buf && obl == sizeof(buf)) ||
1116 if test x$ac_iconv_good = xno; then
1117 AC_MSG_RESULT(Try using libiconv instead.)
1121 # POSIX threads support
1123 AC_MSG_CHECKING(whether to search for POSIX threads)
1124 AC_ARG_WITH(pthreads,
1125 [[ --with-pthreads[=DIR] use POSIX threads [search in DIR/include and DIR/lib]]],
1127 case "${withval}" in
1132 if test -d $withval/include; then
1133 CPPFLAGS="$CPPFLAGS -I$withval/include"
1134 CFLAGS="$CFLAGS -I$withval/include"
1136 if test -d $withval/lib; then
1137 LDFLAGS="$LDFLAGS -L$withval/lib"
1145 if test x$check_threads = xtrue; then
1148 SAVE_CFLAGS="$CFLAGS"
1149 SAVE_LDFLAGS="$LDFLAGS"
1150 SAVE_CPPFLAGS="$CPPFLAGS"
1153 AC_CHECK_HEADERS(pthread.h,
1155 LIBS="$LIBS -lpthread"
1156 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1161 LIBS="$SAVE_LIBS -pthread"
1162 AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true, LIBS="$SAVE_LIBS")
1171 # search for pthread library..
1172 for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do
1173 if test x$has_threads = xfalse; then
1174 AC_MSG_RESULT(searching in $dir...)
1176 if test -d $dir/include; then
1177 CPPFLAGS="$CPPFLAGS -I$dir/include"
1178 CFLAGS="$CFLAGS -I$dir/include"
1180 if test -d $dir/lib; then
1181 LDFLAGS="$LDFLAGS -L$dir/lib"
1185 unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true
1187 AC_CHECK_HEADERS(pthread.h,
1189 LIBS="$LIBS -lpthread"
1190 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1195 CFLAGS="$SAVE_CFLAGS"
1196 LDFLAGS="$SAVE_LDFLAGS"
1197 CPPFLAGS="$SAVE_CPPFLAGS"
1201 CFLAGS="$SAVE_CFLAGS"
1202 LDFLAGS="$SAVE_LDFLAGS"
1203 CPPFLAGS="$SAVE_CPPFLAGS"
1213 __SILC_HAVE_PTHREAD=""
1214 AM_CONDITIONAL(SILC_THREADS, test x$has_threads = xtrue)
1215 if test x$has_threads = xtrue; then
1216 CFLAGS="$CFLAGS -D_REENTRANT"
1218 # XXX possibly incomplete
1221 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1222 if test x"$GCC" = xyes; then
1223 CFLAGS="$CFLAGS -mthreads"
1227 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1229 *-*-sysv5uw7*) # UnixWare 7
1230 if test "$GCC" != "yes"; then
1231 CFLAGS="$CFLAGS -Kthread"
1233 CFLAGS="$CFLAGS -pthread"
1237 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
1242 AC_CHECK_FUNCS(pthread_create pthread_key_create pthread_once)
1244 # Check for read/write locks
1245 AC_CHECK_FUNC(pthread_rwlock_init,
1249 #include <pthread.h>
1252 pthread_rwlock_t rwlock;
1253 pthread_rwlock_init(&rwlock, NULL);
1254 pthread_rwlock_destroy(&rwlock);
1260 # Rwlock not defined
1261 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1266 # Rwlock not defined
1267 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1270 AC_DEFINE([SILC_HAVE_PTHREAD], [], [HAVE_PTHREAD])
1271 AC_DEFINE([SILC_THREADS], [], [HAVE_THREAD])
1272 __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1"
1276 # Check for timezone and tm_gmtoff for timezone information
1278 AC_MSG_CHECKING(whether system has timezone)
1289 [ AC_MSG_RESULT(yes)
1290 AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ],
1291 [ AC_MSG_RESULT(no) ],
1292 [ AC_MSG_RESULT(no) ]
1294 AC_MSG_CHECKING(whether system has tm_gmtoff)
1306 [ AC_MSG_RESULT(yes)
1307 AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ],
1308 [ AC_MSG_RESULT(no) ],
1309 [ AC_MSG_RESULT(no) ]
1311 AC_MSG_CHECKING(whether system has __tm_gmtoff)
1323 [ AC_MSG_RESULT(yes)
1324 AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ],
1325 [ AC_MSG_RESULT(no) ],
1326 [ AC_MSG_RESULT(no) ]
1328 AC_MSG_CHECKING(whether system has __tm_gmtoff__)
1336 tm.__tm_gmtoff__ = 0;
1340 [ AC_MSG_RESULT(yes)
1341 AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ],
1342 [ AC_MSG_RESULT(no) ],
1343 [ AC_MSG_RESULT(no) ]
1346 # Native WIN32 compilation under cygwin
1348 AC_MSG_CHECKING(whether to compile native WIN32 code)
1350 [ --with-win32 compile native WIN32 (MinGW) code (-mno-cygwin)],
1353 AC_DEFINE([SILC_WIN32], [], [SILC_WIN32])
1355 CFLAGS="-mno-cygwin $CFLAGS"
1356 LIBS="$LIBS -lwsock32"
1361 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
1363 # Native Symbian OS support (disabled by default)
1365 AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue)
1367 # Native BeOS support (disabled by default)
1369 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
1371 # Native OS2 support (disabled by default)
1373 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
1375 #ifdef SILC_DIST_SERVER
1377 #endif SILC_DIST_SERVER
1378 #ifdef SILC_DIST_CLIENT
1379 AM_CONDITIONAL(with_irssi, true)
1380 #endif SILC_DIST_CLIENT
1381 #ifdef SILC_DIST_INPLACE
1384 #endif SILC_DIST_INPLACE
1387 AC_MSG_CHECKING(whether to do libtoolfix)
1388 AC_ARG_WITH(libtoolfix,
1389 [ --without-libtoolfix Do not fix libtool, for package builders],
1399 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
1400 #endif SILC_DIST_COMPILER
1406 # Make enable-shared aware
1407 AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes)
1409 SILC_TOP_SRCDIR=`pwd`
1411 # Included configure scripts
1412 AD_INCLUDE_CONFIGURE
1414 #ifdef SILC_DIST_COMPILER
1419 AC_SUBST(SILC_TOP_SRCDIR)
1422 AC_SUBST(SILC_LIB_INCLUDES)
1423 AC_SUBST(__SILC_HAVE_PTHREAD)
1424 AC_SUBST(__SILC_HAVE_SIM)
1425 AC_SUBST(__SILC_ENABLE_DEBUG)
1426 AC_SUBST(__SILC_PACKAGE_VERSION)
1429 # Fix the libtool to support run-time configuration. This allows us
1430 # to in run-time specify when to compile shared/static libraries without
1431 # need to reconfigure the entire libtool.
1433 if test x$libtoolfix = xtrue; then
1434 ./libtoolfix $SILC_TOP_SRCDIR/ltmain.sh
1436 AM_CONDITIONAL(SILC_LIBTOOLFIX, test x$libtoolfix = xtrue)
1438 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
1439 AC_SUBST(INCLUDE_DEFINES_INT)
1441 #endif SILC_DIST_COMPILER
1448 #ifdef SILC_DIST_DOC
1450 #endif SILC_DIST_DOC
1451 #ifdef SILC_DIST_COMPILER
1453 Makefile.defines_int
1455 includes/silcversion.h
1457 #endif SILC_DIST_COMPILER
1458 #ifdef SILC_DIST_APPS
1460 #endif SILC_DIST_APPS
1463 #ifdef SILC_DIST_TOOLKIT
1466 win32/libsilc/Makefile
1467 win32/libsilcclient/Makefile
1469 tutorial/Makefile.defines
1470 tutorial/Makefile.defines_int
1472 #endif SILC_DIST_TOOLKIT
1476 #ifdef SILC_DIST_COMPILER
1477 s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir`
1478 s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir`
1479 s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir`
1480 s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir`
1483 echo "$PACKAGE Configuration Summary:"
1484 echo "---------------------------"
1485 echo " Target host ...................: $target"
1486 echo " Compiler ......................: $CC"
1487 echo " CFLAGS ........................: $CFLAGS"
1488 echo " LDFLAGS .......................: $LDFLAGS"
1489 echo " LIBS ..........................: $LIBS"
1491 echo " Installation prefix ...........: $prefix"
1492 echo " bin directory .................: $s_bindir"
1493 echo " sbin directory ................: $s_sbindir"
1494 echo " etc directory .................: $ETCDIR"
1495 echo " man directory .................: $s_mandir"
1496 echo " doc directory .................: $DOCDIR"
1497 #ifdef SILC_DIST_SIM
1498 echo " SIM directory .................: $MODULESDIR"
1499 #endif SILC_DIST_SIM
1500 #ifdef SILC_DIST_INCLUDES
1501 echo " include directory .............: $s_includedir"
1502 #endif SILC_DIST_INCLUDES
1505 #ifdef SILC_DIST_CLIENT
1506 if test x$without_irssi = xtrue; then
1509 echo " Compile SILC Client ...........: $irssi"
1510 #endif SILC_DIST_CLIENT
1512 #ifdef SILC_DIST_SERVER
1513 if test x$without_silcd = xtrue; then
1516 echo " Compile SILC Server ...........: $silcd"
1517 #endif SILC_DIST_SERVER
1519 #ifdef SILC_DIST_SIM
1520 if test x$sim_support = xfalse; then
1525 echo " SIM support ...................: $sim_support"
1526 #endif SILC_DIST_SIM
1528 echo " IPv6 support ..................: $summary_ipv6"
1530 if test x$has_iconv = xfalse; then
1535 echo " Iconv support .................: $iconv_support"
1537 if test x$want_asm = xfalse; then
1542 echo " Assembler optimizations .......: $summary_asm"
1544 #ifdef SILC_DIST_MATH
1545 if test x$mp_gmp = xtrue; then
1546 echo " Arithmetic library ............: GMP"
1548 #endif SILC_DIST_MATH
1551 if test x$has_threads = xtrue; then
1554 echo " Multi-threads support .........: $threads"
1555 echo " Debugging enabled .............: $summary_debug"
1557 echo "Compile the sources with 'make' or 'gmake' command."
1558 #endif SILC_DIST_COMPILER