4 # Author: Pekka Riikonen <priikone@silcnet.org>
6 # Copyright (C) 2000 - 2008 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(runtimedefs.h)
30 AC_PATH_PROG(sedpath, sed)
38 #ifdef SILC_DIST_INPLACE
40 #endif SILC_DIST_INPLACE
46 ## Library versioning.
49 # Do the releases and library versioning according to following rules:
51 # - If any code has changed in library, increment RUNTIME_REVISION
52 # - If API were added, removed or changed, set RUNTIME_REVISION to 0
53 # - If API were added, removed or changed, increment RUNTIME_CURRENT
54 # - If APi were added, increment RUNTIME_AGE
55 # - If API were removed, set RUNTIME_AGE to 0
58 # Base version for library.
59 RUNTIME_BASE_VERSION=1.2
62 RUNTIME_CURRENT=1 # prev = 0
63 RUNTIME_REVISION=0 # prev = 0
64 RUNTIME_AGE=0 # prev = 0
66 # Substitute the version numbers
67 AC_SUBST(RUNTIME_BASE_VERSION)
68 AC_SUBST(RUNTIME_CURRENT)
69 AC_SUBST(RUNTIME_REVISION)
77 # Default installation destination
78 AC_PREFIX_DEFAULT(/usr/local)
79 if test "x$prefix" != xNONE; then
82 silc_prefix="$ac_default_prefix"
91 # Disable all CPU feature optimizations
92 AC_MSG_CHECKING(whether to enable CPU feature optimizations)
93 AC_ARG_ENABLE(cpu-optimizations,
94 [ --disable-cpu-optimizations do not use any CPU feature optimizations],
97 AC_DEFINE([SILC_NO_CPU_OPTIMIZATIONS], [], [SILC_NO_CPU_OPTIMIZATIONS])
98 want_cpu_optimizations=false
102 want_cpu_optimizations=true
104 AM_CONDITIONAL(SILC_NO_CPU_OPTIMIZATIONS,
105 test x$want_cpu_optimizations = xfalse)
107 SILC_SYSTEM_IS_SMP(AC_DEFINE([SILC_SMP], [], [SILC_SMP]), [],
108 AC_DEFINE([SILC_SMP], [], [SILC_SMP]))
118 # All following Intels are considered 32-bit CPUs.
120 # All CPUs of today are considered i386 and i486 compatible */
121 AC_DEFINE([SILC_I386], [], [SILC_I386])
122 AC_DEFINE([SILC_I486], [], [SILC_I486])
126 if test "x$host_cpu" = "xi586"; then
127 AC_DEFINE([SILC_I586], [], [SILC_I586])
131 if test "x$host_cpu" = "xi686"; then
132 AC_DEFINE([SILC_I586], [], [SILC_I586])
133 AC_DEFINE([SILC_I686], [], [SILC_I686])
138 if test "x$host_cpu" = "xi786"; then
139 AC_DEFINE([SILC_I586], [], [SILC_I586])
140 AC_DEFINE([SILC_I686], [], [SILC_I686])
141 AC_DEFINE([SILC_I786], [], [SILC_I786])
147 # Check for specific CPU features
148 SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), [])
149 SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
150 SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
151 SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
152 SILC_CPU_FLAG(sse4a, true, AC_DEFINE([SILC_CPU_SSE4A], [], [SILC_CPU_SSE4A]), [])
153 SILC_CPU_FLAG(sse4_1, true, AC_DEFINE([SILC_CPU_SSE41], [], [SILC_CPU_SSE41]), [])
154 SILC_CPU_FLAG(sse4_2, true, AC_DEFINE([SILC_CPU_SSE42], [], [SILC_CPU_SSE42]), [])
155 SILC_CPU_FLAG(sse5, true, AC_DEFINE([SILC_CPU_SSE5], [], [SILC_CPU_SSE5]), [])
158 # Intel IA-64, 64-bit CPU (not x86_64 compatible)
160 AC_DEFINE([SILC_IA64], [], [SILC_IA64])
164 # AMD/Intel x86_64, 64-bit CPU
166 AC_DEFINE([SILC_X86_64], [], [SILC_X86_64])
169 # Check for specific CPU features
170 SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), [])
171 SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
172 SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
173 SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
174 SILC_CPU_FLAG(sse4a, true, AC_DEFINE([SILC_CPU_SSE4A], [], [SILC_CPU_SSE4A]), [])
175 SILC_CPU_FLAG(sse4_1, true, AC_DEFINE([SILC_CPU_SSE41], [], [SILC_CPU_SSE41]), [])
176 SILC_CPU_FLAG(sse4_2, true, AC_DEFINE([SILC_CPU_SSE42], [], [SILC_CPU_SSE42]), [])
177 SILC_CPU_FLAG(sse5, true, AC_DEFINE([SILC_CPU_SSE5], [], [SILC_CPU_SSE5]), [])
180 # PowerPC, 32-bit and 64-bit CPUs
182 AC_DEFINE([SILC_POWERPC], [], [SILC_POWERPC])
186 AM_CONDITIONAL(SILC_I386, test x$cpu_i386 = xtrue)
187 AM_CONDITIONAL(SILC_I486, test x$cpu_i486 = xtrue)
188 AM_CONDITIONAL(SILC_I586, test x$cpu_i586 = xtrue)
189 AM_CONDITIONAL(SILC_I686, test x$cpu_i686 = xtrue)
190 AM_CONDITIONAL(SILC_7686, test x$cpu_i786 = xtrue)
191 AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue)
192 AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue)
193 AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue)
195 if test x$want_cpu_optimizations = xtrue; then
196 # Set some compiler options based on CPU
197 if test "x$CC" = "xicc"; then
199 if test x$x_have_cpu_sse4_1 = xtrue; then
200 SILC_ADD_CFLAGS(-axS)
202 if test x$x_have_cpu_ssse3 = xtrue; then
203 SILC_ADD_CFLAGS(-axT)
204 elif test x$x_have_cpu_pni = xtrue; then
205 SILC_ADD_CFLAGS(-axP)
206 elif test x$x_have_cpu_sse2 = xtrue; then
207 SILC_ADD_CFLAGS(-axW)
211 if test x$x_have_cpu_sse2 = xtrue; then
212 SILC_ADD_CFLAGS(-msse2)
213 SILC_ADD_CFLAGS(-ftree-vectorize)
215 if test x$x_have_cpu_pni = xtrue; then
216 SILC_ADD_CFLAGS(-msse3)
217 SILC_ADD_CFLAGS(-ftree-vectorize)
219 if test x$x_have_cpu_ssse3 = xtrue; then
220 SILC_ADD_CFLAGS(-mssse3)
221 SILC_ADD_CFLAGS(-ftree-vectorize)
223 if test x$x_have_cpu_sse4_1 = xtrue; then
224 SILC_ADD_CFLAGS(-msse4)
225 SILC_ADD_CFLAGS(-ftree-vectorize)
227 if test x$x_have_cpu_sse4_2 = xtrue; then
228 SILC_ADD_CFLAGS(-msse4)
229 SILC_ADD_CFLAGS(-ftree-vectorize)
231 if test x$x_have_cpu_sse5 = xtrue; then
232 SILC_ADD_CFLAGS(-msse5)
233 SILC_ADD_CFLAGS(-ftree-vectorize)
240 ## Put here any platform specific stuff
246 CFLAGS=`echo $CFLAGS -D_GNU_SOURCE`
273 # More header checking
275 AC_CHECK_HEADERS(unistd.h string.h errno.h fcntl.h assert.h execinfo.h)
276 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
277 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h sys/resource.h)
278 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
279 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h dirent.h)
280 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
284 ## Data type checking
291 AC_CHECK_SIZEOF(long long, 0)
292 AC_SUBST(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
293 AC_CHECK_SIZEOF(long, 0)
294 AC_SUBST(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
295 AC_CHECK_SIZEOF(int, 0)
296 AC_SUBST(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
297 AC_CHECK_SIZEOF(short, 0)
298 AC_SUBST(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
299 AC_CHECK_SIZEOF(char, 0)
300 AC_SUBST(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
301 AC_CHECK_SIZEOF(void *, 0)
302 AC_SUBST(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
303 AC_CHECK_TYPES(long long)
304 AC_CHECK_TYPES(long double)
306 # Check for big-endian machines
311 ## Compiler and compiler flag checks
314 # Disable all compiler optimizations
315 AC_MSG_CHECKING(whether to enable compiler optimizations)
316 AC_ARG_ENABLE(optimizations,
317 [ --disable-optimizations do not use any compiler optimizations],
320 AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS])
321 want_cc_optimizations=false
325 want_cc_optimizations=true
327 AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse)
330 # GCC specific options
331 if test "x$summary_debug" = "xyes"; then
336 SILC_ADD_CFLAGS(-Wall -finline-functions)
337 SILC_ADD_CFLAGS(-Wno-pointer-sign)
352 # Intel C++ Compiler flags
353 if test "x$CC" = "xicc"; then
354 SILC_ADD_CFLAGS(-restrict)
355 SILC_ADD_CFLAGS(-finline-functions)
357 # Don't define __GNUC__ except for system includes
358 SILC_ADD_CFLAGS(-gcc-sys)
362 if test x$want_cc_optimizations = xtrue; then
364 # GCC specific options
365 if test "x$summary_debug" = "xyes"; then
374 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
377 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
380 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
388 ## Function and libary checking
390 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
391 AC_CHECK_FUNCS(poll select listen bind shutdown close connect setsockopt)
392 AC_CHECK_FUNCS(setrlimit time ctime utime gettimeofday getrusage)
393 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
394 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid sched_yield)
395 AC_CHECK_FUNCS(setgroups initgroups nl_langinfo nanosleep)
396 AC_CHECK_FUNCS(strchr snprintf strstr strcpy strncpy memcpy memset memmove)
397 AC_CHECK_FUNCS(setenv getenv putenv unsetenv clearenv backtrace)
400 AC_CHECK_FUNC(getopt_long,
402 AC_DEFINE([HAVE_GETOPT_LONG], [], [HAVE_GETOPT_LONG])
404 ], have_getopt_long=0
407 # Check gethostbyname
408 AC_CHECK_FUNC(gethostbyname, [],
410 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
411 AC_CHECK_FUNC(res_gethostbyname, [],
412 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
417 AC_CHECK_FUNC(socket, [],
418 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
421 # Check clock_gettime
422 AC_CHECK_FUNC(clock_gettime, [],
424 AC_CHECK_LIB(rt, clock_gettime,
426 AC_DEFINE([HAVE_CLOCK_GETTIME], [], [HAVE_CLOCK_GETTIME])])
429 # Check for epoll_wait and verify that epoll_create works
430 AC_CHECK_FUNC(epoll_wait,
432 AC_RUN_IFELSE([AC_LANG_SOURCE(
434 #include <sys/epoll.h>
437 int ret = epoll_create(5);
445 AC_DEFINE([HAVE_EPOLL_WAIT], [1], [HAVE_EPOLL_WAIT])
452 __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) dest = src"
453 AC_MSG_CHECKING(for va_copy)
465 if (va_arg(cp, int) != 0xff11)
477 __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) va_copy(dest, src)"
487 if test x$va_copy = xfalse; then
488 AC_MSG_CHECKING(for __va_copy)
500 if (va_arg(cp, int) != 0xff11)
512 __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) __va_copy(dest, src)"
523 if test x$va_copy = xfalse; then
524 AC_RUN_IFELSE([AC_LANG_SOURCE(
533 if (va_arg(cp, int) != 0xff11)
546 AC_DEFINE([SILC_VA_COPY_ARRAY], [], [SILC_VA_COPY_ARRAY])
547 __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) memmove(dest, src, sizeof(va_list))"
552 AC_SUBST(__SILC_VA_COPY)
554 # Check for timezone and tm_gmtoff for timezone information
555 AC_MSG_CHECKING(whether system has timezone)
556 AC_RUN_IFELSE([AC_LANG_SOURCE(
567 AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ],
568 [ AC_MSG_RESULT(no) ],
569 [ AC_MSG_RESULT(no) ]
571 AC_MSG_CHECKING(whether system has tm_gmtoff)
572 AC_RUN_IFELSE([AC_LANG_SOURCE(
584 AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ],
585 [ AC_MSG_RESULT(no) ],
586 [ AC_MSG_RESULT(no) ]
588 AC_MSG_CHECKING(whether system has __tm_gmtoff)
589 AC_RUN_IFELSE([AC_LANG_SOURCE(
601 AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ],
602 [ AC_MSG_RESULT(no) ],
603 [ AC_MSG_RESULT(no) ]
605 AC_MSG_CHECKING(whether system has __tm_gmtoff__)
606 AC_RUN_IFELSE([AC_LANG_SOURCE(
613 tm.__tm_gmtoff__ = 0;
618 AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ],
619 [ AC_MSG_RESULT(no) ],
620 [ AC_MSG_RESULT(no) ]
623 # Check for dlopen() and friends
624 AC_CHECK_HEADERS(dlfcn.h,
626 AC_CHECK_LIB(dl, dlopen,
628 AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN])
632 AC_CHECK_LIB(c, dlopen,
634 AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN])
639 __SILC_ENABLE_DEBUG=""
641 runtimever=`echo $VERSION | sed 's/\./ /g'`
647 if test $maj -eq 0; then
651 if test $min -eq 0; then
655 if test $bld -eq 0; then
660 __RUNTIME_PACKAGE_VERSION="#define __SILC_RUNTIME_VERSION SILC_VERSION($maj,$min,$bld)"
664 ## Enable/disable checking
668 AC_MSG_CHECKING(whether to enable IPv6 support)
670 [ --enable-ipv6 enable IPv6 support],
672 case "${enableval}" in
677 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
691 if test x$check_ipv6 = xtrue; then
695 #ifdef HAVE_SYS_TYPES_H
696 #include <sys/types.h>
698 #ifdef HAVE_NETINET_TCP_H
699 #include <netinet/tcp.h>
704 #include <sys/socket.h>
705 #ifdef HAVE_NETINET_IN_H
706 #include <netinet/in.h>
710 struct sockaddr_in6 sin6;
711 int family = AF_INET6;
714 AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6])
722 # Memory alignment. User can specify what alignment memory allocation and
723 # SilcStack allocation use. Default is system default alignemnt.
724 AC_ARG_WITH(alignment,
725 [ --with-alignment=NUMBER Memory alignment in bytes],
727 AC_DEFINE_UNQUOTED([SILC_ALIGNMENT], [$withval], [SILC_ALIGNMENT])
728 AC_MSG_RESULT(Memory allocation alignment is $withval bytes)
731 AC_DEFINE([SILC_ALIGNMENT], SILC_SIZEOF_VOID_P, [SILC_ALIGNMENT])
734 # Memory trace checking
735 __SILC_ENABLE_MEMTRACE=""
736 AC_MSG_CHECKING(whether to enable memory tracing)
737 AC_ARG_ENABLE(mem-trace,
738 [ --enable-mem-trace enable memory tracing],
740 case "${enableval}" in
743 AC_DEFINE([SILC_MEMTRACE], [], [SILC_MEMTRACE])
744 __SILC_ENABLE_MEMTRACE="#define __SILC_ENABLE_MEMTRACE 1"
745 CFLAGS="$CFLAGS -rdynamic"
746 PC_CFLAGS="$PC_CFLAGS -rdynamic"
756 #ifdef SILC_DIST_INPLACE
758 # Profiling options (never delivered to distributions)
760 AC_MSG_CHECKING(whether to enable gprof)
762 [ --enable-gprof enable gprof profiling],
764 case "${enableval}" in
779 AC_MSG_CHECKING(whether to enable gcov)
781 [ --enable-gcov enable gcov],
783 case "${enableval}" in
786 SILC_ADD_CFLAGS(-fprofile-arcs)
798 AC_MSG_CHECKING(whether to have verbose compilation)
799 AC_ARG_ENABLE(verbose,
800 [ --enable-verbose have verbose compilation],
802 case "${enableval}" in
806 # Add here any options to give verbose compilation output
807 SILC_ADD_CFLAGS(-ftree-vectorizer-verbose=2)
817 #endif SILC_DIST_INPLACE
820 AC_MSG_CHECKING(whether to enable debugging)
822 __SILC_ENABLE_DEBUG=""
824 [ --enable-debug enable debugging],
826 case "${enableval}" in
829 AC_DEFINE([SILC_DEBUG], [], [enable-debug])
830 PC_CFLAGS="$PC_CFLAGS -DSILC_DEBUG"
832 __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1"
843 # Disable all assembler optimizations
844 AC_MSG_CHECKING(whether to enable assembler optimizations)
846 [ --disable-asm do not use assembler optimizations],
849 AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM])
856 AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse)
858 # Check for assembler
861 if test x$want_asm = xtrue; then
862 AC_PATH_PROG([NASM], [nasm], [no])
863 if test "x$NASM" != "xno"; then
864 if test x$cpu_x86_64 = xtrue; then
865 SILC_ASSEMBLER="$NASM -O2 -felf64"
867 SILC_ASSEMBLER="$NASM -O2 -felf"
872 AC_PATH_PROG([YASM], [yasm], [no])
873 if test "x$YASM" != "xno"; then
874 if test x$cpu_x86_64 = xtrue; then
875 SILC_ASSEMBLER="$YASM -Xgnu -felf64"
877 SILC_ASSEMBLER="$YASM -Xgnu -felf"
882 AC_SUBST(SILC_ASSEMBLER)
886 ## With/without checkings
890 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
892 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/contrib"
893 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcutil"
894 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silchttp"
897 # Check for iconv support
901 SAVE_CFLAGS="$CFLAGS"
902 SAVE_LDFLAGS="$LDFLAGS"
903 SAVE_CPPFLAGS="$CPPFLAGS"
904 AC_MSG_CHECKING(whether to implicit search for libiconv)
906 [[ --with-iconv[=DIR] use libiconv [search in DIR/include and DIR/lib]]],
911 AC_CHECK_HEADERS(iconv.h,
913 AC_CHECK_FUNC(iconv, has_iconv=true)
919 if test -d $withval/include; then
920 CPPFLAGS="$CPPFLAGS -I$withval/include"
921 CFLAGS="$CFLAGS -I$withval/include"
923 if test -d $withval/lib; then
924 LDFLAGS="$LDFLAGS -L$withval/lib"
931 AC_CHECK_HEADERS(iconv.h,
933 # Default check for iconv in C-library
934 AC_CHECK_FUNCS(iconv iconv_open iconv_close,
942 if test x$check_iconv = xtrue; then
943 # Check for iconv in libiconv installed under /usr
944 AC_MSG_RESULT(Searching for iconv...)
947 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
949 AC_CHECK_HEADERS(iconv.h,
952 LDFLAGS="$LDFLAGS -L/usr/lib"
953 CFLAGS="$CFLAGS -I/usr/include"
954 CPPLAGS="$CPPFLAGS -I/usr/include"
956 AC_MSG_CHECKING(for iconv in -liconv)
963 iconv_t cd = iconv_open("", "");
964 iconv(cd, NULL, NULL, NULL, NULL);
969 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
976 CFLAGS="$SAVE_CFLAGS"
977 LDFLAGS="$SAVE_LDFLAGS"
978 CPPFLAGS="$SAVE_CPPFLAGS"
983 if test x$check_iconv = xtrue; then
984 # search for iconv library..
986 SAVE_CFLAGS="$CFLAGS"
987 SAVE_LDFLAGS="$LDFLAGS"
988 SAVE_CPPFLAGS="$CPPFLAGS"
990 for dir in `echo "/usr/local /usr/pkg /usr/contrib /opt/local"`; do
991 if test x$has_iconv = xfalse; then
992 AC_MSG_RESULT(searching in $dir...)
994 if test -d $dir/include; then
995 CPPFLAGS="$CPPFLAGS -I$dir/include"
996 CFLAGS="$CFLAGS -I$dir/include"
998 if test -d $dir/lib; then
999 LDFLAGS="$LDFLAGS -L$dir/lib"
1003 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
1005 AC_CHECK_HEADERS(iconv.h,
1007 LIBS="$LIBS -liconv"
1008 AC_MSG_CHECKING(for iconv in -liconv)
1015 iconv_t cd = iconv_open("", "");
1016 iconv(cd, NULL, NULL, NULL, NULL);
1022 AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
1029 CFLAGS="$SAVE_CFLAGS"
1030 LDFLAGS="$SAVE_LDFLAGS"
1031 CPPFLAGS="$SAVE_CPPFLAGS"
1035 CFLAGS="$SAVE_CFLAGS"
1036 LDFLAGS="$SAVE_LDFLAGS"
1037 CPPFLAGS="$SAVE_CPPFLAGS"
1043 if test x$has_iconv = xtrue; then
1044 # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
1045 # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
1046 # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
1048 AC_CACHE_CHECK([whether this iconv is good enough], ac_cv_iconv_good,
1056 changequote([, ])dnl
1059 ob = buf, obl = sizeof(buf);
1060 return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
1061 (iconv(cd, 0, 0, &ob, &obl) ||
1062 !(ob == buf && obl == sizeof(buf)) ||
1067 ac_cv_iconv_good=yes
1073 ac_cv_iconv_good=yes
1077 if test x$ac_cv_iconv_good = xno; then
1078 AC_MSG_RESULT(Try using libiconv instead.)
1082 # Check for POSIX threads support
1083 AC_MSG_CHECKING(whether to search for POSIX threads)
1084 AC_ARG_WITH(pthreads,
1085 [[ --with-pthreads[=DIR] use POSIX threads [search in DIR/include and DIR/lib]]],
1087 case "${withval}" in
1092 if test -d $withval/include; then
1093 CPPFLAGS="$CPPFLAGS -I$withval/include"
1094 CFLAGS="$CFLAGS -I$withval/include"
1096 if test -d $withval/lib; then
1097 LDFLAGS="$LDFLAGS -L$withval/lib"
1105 if test x$check_threads = xtrue; then
1108 SAVE_CFLAGS="$CFLAGS"
1109 SAVE_LDFLAGS="$LDFLAGS"
1110 SAVE_CPPFLAGS="$CPPFLAGS"
1113 AC_CHECK_HEADERS(pthread.h,
1115 LIBS="$LIBS -lpthread"
1116 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1121 LIBS="$SAVE_LIBS -pthread"
1122 AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true, LIBS="$SAVE_LIBS")
1131 # search for pthread library..
1132 for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do
1133 if test x$has_threads = xfalse; then
1134 AC_MSG_RESULT(searching in $dir...)
1136 if test -d $dir/include; then
1137 CPPFLAGS="$CPPFLAGS -I$dir/include"
1138 CFLAGS="$CFLAGS -I$dir/include"
1140 if test -d $dir/lib; then
1141 LDFLAGS="$LDFLAGS -L$dir/lib"
1145 unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true
1147 AC_CHECK_HEADERS(pthread.h,
1149 LIBS="$LIBS -lpthread"
1150 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
1155 CFLAGS="$SAVE_CFLAGS"
1156 LDFLAGS="$SAVE_LDFLAGS"
1157 CPPFLAGS="$SAVE_CPPFLAGS"
1161 CFLAGS="$SAVE_CFLAGS"
1162 LDFLAGS="$SAVE_LDFLAGS"
1163 CPPFLAGS="$SAVE_CPPFLAGS"
1173 __SILC_HAVE_PTHREAD=""
1174 AM_CONDITIONAL(SILC_THREADS, test x$has_threads = xtrue)
1175 if test x$has_threads = xtrue; then
1176 CFLAGS="$CFLAGS -D_REENTRANT"
1178 # XXX possibly incomplete
1181 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1182 if test x"$GCC" = xyes; then
1183 CFLAGS="$CFLAGS -mthreads"
1187 CFLAGS="$CFLAGS -D_THREAD_SAFE"
1189 *-*-sysv5uw7*) # UnixWare 7
1190 if test "$GCC" != "yes"; then
1191 CFLAGS="$CFLAGS -Kthread"
1193 CFLAGS="$CFLAGS -pthread"
1197 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
1202 AC_CHECK_FUNCS(pthread_create pthread_key_create pthread_once)
1204 # Check for read/write locks
1205 AC_CHECK_FUNC(pthread_rwlock_init,
1207 AC_RUN_IFELSE([AC_LANG_SOURCE(
1209 #include <pthread.h>
1212 pthread_rwlock_t rwlock;
1213 pthread_rwlock_init(&rwlock, NULL);
1214 pthread_rwlock_destroy(&rwlock);
1220 # Rwlock not defined
1221 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1226 # Rwlock not defined
1227 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
1230 AC_DEFINE([SILC_HAVE_PTHREAD], [], [HAVE_PTHREAD])
1231 AC_DEFINE([SILC_THREADS], [], [HAVE_THREAD])
1232 __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1"
1233 PC_CFLAGS="$PC_CFLAGS -DSILC_THREADS"
1239 [[ --with-expat[=DIR] use Expat XML [search in DIR/include and DIR/lib]]],
1241 case "${withval}" in
1245 if test -d $withval/include; then
1246 CPPFLAGS="$CPPFLAGS -I$withval/include"
1247 CFLAGS="$CFLAGS -I$withval/include"
1249 if test -d $withval/lib; then
1250 LDFLAGS="$LDFLAGS -L$withval/lib"
1256 AC_CHECK_HEADERS(expat.h,
1257 [ LIBS="$LIBS -lexpat" ],
1258 [ AC_MSG_ERROR(Expat XML Library is required to compile SRT) ])
1262 ## Native WIN32 compilation under cygwin
1264 AC_MSG_CHECKING(whether to compile native WIN32 code)
1266 [ --with-win32 compile native WIN32 (MinGW) code (-mno-cygwin)],
1269 AC_DEFINE([SILC_WIN32], [], [SILC_WIN32])
1271 CFLAGS="-mno-cygwin $CFLAGS"
1272 LIBS="$LIBS -lwsock32"
1278 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
1282 ## Outputs and substitutions
1286 AC_SUBST(SILC_TOP_SRCDIR)
1289 AC_SUBST(SILC_LIB_INCLUDES)
1291 AC_SUBST(__SILC_ENABLE_DEBUG)
1292 AC_SUBST(__SILC_ENABLE_MEMTRACE)
1293 AC_SUBST(__SILC_HAVE_PTHREAD)
1294 AC_SUBST(__RUNTIME_PACKAGE_VERSION)
1296 # Native Symbian OS support (disabled by default)
1297 AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue)
1299 # Make enable-shared aware
1300 AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes)
1302 ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR`
1304 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
1306 DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR`
1308 AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR])
1310 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
1311 AC_SUBST(INCLUDE_DEFINES_INT)
1323 doc/runtime.in/index.html
1324 doc/runtime.in/manual.html
1326 Makefile.defines_int
1334 lib/contrib/Makefile
1335 lib/silcutil/silcruntime.h
1336 lib/silcutil/Makefile
1337 lib/silcutil/tests/Makefile
1338 lib/silcutil/unix/Makefile
1339 lib/silcutil/win32/Makefile
1340 lib/silcutil/symbian/Makefile
1341 lib/silchttp/Makefile
1342 lib/silchttp/tests/Makefile
1353 s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir`
1354 s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir`
1355 s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir`
1356 s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir`
1359 echo "SILC Runtime Toolkit configuration summary:"
1360 echo "------------------------------------------"
1361 echo " Target host ...................: $target"
1362 echo " Compiler ......................: $CC"
1363 echo " CFLAGS ........................: $CFLAGS"
1364 echo " LDFLAGS .......................: $LDFLAGS"
1365 echo " LIBS ..........................: $LIBS"
1367 echo " Installation prefix ...........: $prefix"
1368 echo " bin directory .................: $s_bindir"
1369 echo " sbin directory ................: $s_sbindir"
1370 echo " etc directory .................: $ETCDIR"
1371 echo " man directory .................: $s_mandir"
1372 echo " doc directory .................: $DOCDIR"
1373 echo " include directory .............: $s_includedir"
1375 echo " IPv6 support ..................: $summary_ipv6"
1377 if test x$has_iconv = xfalse; then
1382 echo " Iconv support .................: $iconv_support"
1384 if test x$want_asm = xfalse; then
1389 echo " Assembler optimizations .......: $summary_asm"
1391 if test x$want_cc_optimizations = xfalse; then
1394 summary_cc_opt="yes"
1396 echo " Compiler optimizations ........: $summary_cc_opt"
1398 if test x$want_cpu_optimizations = xfalse; then
1399 summary_cpu_opt="no"
1401 summary_cpu_opt="yes"
1403 echo " CPU feature optimizations .....: $summary_cpu_opt"
1406 if test x$has_threads = xtrue; then
1409 echo " Multi-threads support .........: $threads"
1410 echo " Debugging enabled .............: $summary_debug"
1412 echo "Compile the sources with 'make' or 'gmake' command."