# # configure.ad # # Author: Pekka Riikonen # # Copyright (C) 2000 - 2008 Pekka Riikonen # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # AD_INIT AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE AC_PREREQ(2.52) AC_CONFIG_HEADERS(runtimedefs.h) AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_LN_S AC_PROG_EGREP AC_SUBST(LN_S) AC_PATH_PROG(sedpath, sed) AC_PROG_CC AM_PROG_AS AC_C_INLINE AC_C_CONST AC_PROG_RANLIB #ifdef SILC_DIST_INPLACE AC_DISABLE_SHARED #endif SILC_DIST_INPLACE AC_PROG_LIBTOOL SILC_TOP_SRCDIR=`pwd` ## ## Library versioning. ## # Do the releases and library versioning according to following rules: # # - If any code has changed in library, increment RUNTIME_REVISION # - If API were added, removed or changed, set RUNTIME_REVISION to 0 # - If API were added, removed or changed, increment RUNTIME_CURRENT # - If APi were added, increment RUNTIME_AGE # - If API were removed, set RUNTIME_AGE to 0 # # Base version for library. RUNTIME_BASE_VERSION=1.2 # libsilc versions RUNTIME_CURRENT=1 # prev = 0 RUNTIME_REVISION=0 # prev = 0 RUNTIME_AGE=0 # prev = 0 # Substitute the version numbers AC_SUBST(RUNTIME_BASE_VERSION) AC_SUBST(RUNTIME_CURRENT) AC_SUBST(RUNTIME_REVISION) AC_SUBST(RUNTIME_AGE) ## ## Installation ## # Default installation destination AC_PREFIX_DEFAULT(/usr/local) if test "x$prefix" != xNONE; then silc_prefix="$prefix" else silc_prefix="$ac_default_prefix" prefix="$silc_prefix" fi ## ## Detect CPU ## # Disable all CPU feature optimizations AC_MSG_CHECKING(whether to enable CPU feature optimizations) AC_ARG_ENABLE(cpu-optimizations, [ --disable-cpu-optimizations do not use any CPU feature optimizations], [ AC_MSG_RESULT(no) AC_DEFINE([SILC_NO_CPU_OPTIMIZATIONS], [], [SILC_NO_CPU_OPTIMIZATIONS]) want_cpu_optimizations=false ], [ AC_MSG_RESULT(yes) want_cpu_optimizations=true ]) AM_CONDITIONAL(SILC_NO_CPU_OPTIMIZATIONS, test x$want_cpu_optimizations = xfalse) SILC_SYSTEM_IS_SMP(AC_DEFINE([SILC_SMP], [], [SILC_SMP]), [], AC_DEFINE([SILC_SMP], [], [SILC_SMP])) cpu_i386=false cpu_i486=false cpu_i586=false cpu_i686=false cpu_i786=false cpu_x86_64=false cpu_ppc=false cpu_ia64=false case "$host_cpu" in # All following Intels are considered 32-bit CPUs. i?86) # All CPUs of today are considered i386 and i486 compatible */ AC_DEFINE([SILC_I386], [], [SILC_I386]) AC_DEFINE([SILC_I486], [], [SILC_I486]) cpu_i386=true cpu_i486=true if test "x$host_cpu" = "xi586"; then AC_DEFINE([SILC_I586], [], [SILC_I586]) cpu_i586=true fi if test "x$host_cpu" = "xi686"; then AC_DEFINE([SILC_I586], [], [SILC_I586]) AC_DEFINE([SILC_I686], [], [SILC_I686]) cpu_i586=true cpu_i686=true fi if test "x$host_cpu" = "xi786"; then AC_DEFINE([SILC_I586], [], [SILC_I586]) AC_DEFINE([SILC_I686], [], [SILC_I686]) AC_DEFINE([SILC_I786], [], [SILC_I786]) cpu_i586=true cpu_i686=true cpu_i786=true fi # Check for specific CPU features SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), []) SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), []) SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), []) SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), []) SILC_CPU_FLAG(sse4a, true, AC_DEFINE([SILC_CPU_SSE4A], [], [SILC_CPU_SSE4A]), []) SILC_CPU_FLAG(sse4_1, true, AC_DEFINE([SILC_CPU_SSE41], [], [SILC_CPU_SSE41]), []) SILC_CPU_FLAG(sse4_2, true, AC_DEFINE([SILC_CPU_SSE42], [], [SILC_CPU_SSE42]), []) SILC_CPU_FLAG(sse5, true, AC_DEFINE([SILC_CPU_SSE5], [], [SILC_CPU_SSE5]), []) ;; # Intel IA-64, 64-bit CPU (not x86_64 compatible) ia64) AC_DEFINE([SILC_IA64], [], [SILC_IA64]) cpu_ia64=true ;; # AMD/Intel x86_64, 64-bit CPU x86_64) AC_DEFINE([SILC_X86_64], [], [SILC_X86_64]) cpu_x86_64=true # Check for specific CPU features SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), []) SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), []) SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), []) SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), []) SILC_CPU_FLAG(sse4a, true, AC_DEFINE([SILC_CPU_SSE4A], [], [SILC_CPU_SSE4A]), []) SILC_CPU_FLAG(sse4_1, true, AC_DEFINE([SILC_CPU_SSE41], [], [SILC_CPU_SSE41]), []) SILC_CPU_FLAG(sse4_2, true, AC_DEFINE([SILC_CPU_SSE42], [], [SILC_CPU_SSE42]), []) SILC_CPU_FLAG(sse5, true, AC_DEFINE([SILC_CPU_SSE5], [], [SILC_CPU_SSE5]), []) ;; # PowerPC, 32-bit and 64-bit CPUs powerpc*) AC_DEFINE([SILC_POWERPC], [], [SILC_POWERPC]) cpu_ppc=true ;; esac AM_CONDITIONAL(SILC_I386, test x$cpu_i386 = xtrue) AM_CONDITIONAL(SILC_I486, test x$cpu_i486 = xtrue) AM_CONDITIONAL(SILC_I586, test x$cpu_i586 = xtrue) AM_CONDITIONAL(SILC_I686, test x$cpu_i686 = xtrue) AM_CONDITIONAL(SILC_7686, test x$cpu_i786 = xtrue) AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue) AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue) AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue) if test x$want_cpu_optimizations = xtrue; then # Set some compiler options based on CPU if test "x$CC" = "xicc"; then # ICC flags if test x$x_have_cpu_sse4_1 = xtrue; then SILC_ADD_CFLAGS(-axS) fi if test x$x_have_cpu_ssse3 = xtrue; then SILC_ADD_CFLAGS(-axT) elif test x$x_have_cpu_pni = xtrue; then SILC_ADD_CFLAGS(-axP) elif test x$x_have_cpu_sse2 = xtrue; then SILC_ADD_CFLAGS(-axW) fi else # Other compilers if test x$x_have_cpu_sse2 = xtrue; then SILC_ADD_CFLAGS(-msse2) SILC_ADD_CFLAGS(-ftree-vectorize) fi if test x$x_have_cpu_pni = xtrue; then SILC_ADD_CFLAGS(-msse3) SILC_ADD_CFLAGS(-ftree-vectorize) fi if test x$x_have_cpu_ssse3 = xtrue; then SILC_ADD_CFLAGS(-mssse3) SILC_ADD_CFLAGS(-ftree-vectorize) fi if test x$x_have_cpu_sse4_1 = xtrue; then SILC_ADD_CFLAGS(-msse4) SILC_ADD_CFLAGS(-ftree-vectorize) fi if test x$x_have_cpu_sse4_2 = xtrue; then SILC_ADD_CFLAGS(-msse4) SILC_ADD_CFLAGS(-ftree-vectorize) fi if test x$x_have_cpu_sse5 = xtrue; then SILC_ADD_CFLAGS(-msse5) SILC_ADD_CFLAGS(-ftree-vectorize) fi fi fi ## ## Put here any platform specific stuff ## case "$target" in *-*-linux*) check_threads=true CFLAGS=`echo $CFLAGS -D_GNU_SOURCE` ;; *-*-freebsd*) check_threads=true ;; *-*-netbsd*) check_threads=true ;; *-*-*bsd*) check_threads=false ;; *-*-*darwin*) check_threads=true ;; *) check_threads=true ;; esac ## ## Header checking ## AC_HEADER_STDC AC_HEADER_TIME AC_HEADER_STAT # More header checking # AC_CHECK_HEADERS(unistd.h string.h errno.h fcntl.h assert.h execinfo.h) AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h) AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h sys/resource.h) AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h) AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h dirent.h) AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h) ## ## Data type checking ## AC_TYPE_SIGNAL AC_TYPE_SIZE_T AC_TYPE_MODE_T AC_TYPE_UID_T AC_TYPE_PID_T AC_CHECK_SIZEOF(long long, 0) AC_SUBST(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long) AC_CHECK_SIZEOF(long, 0) AC_SUBST(SILC_SIZEOF_LONG, $ac_cv_sizeof_long) AC_CHECK_SIZEOF(int, 0) AC_SUBST(SILC_SIZEOF_INT, $ac_cv_sizeof_int) AC_CHECK_SIZEOF(short, 0) AC_SUBST(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short) AC_CHECK_SIZEOF(char, 0) AC_SUBST(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char) AC_CHECK_SIZEOF(void *, 0) AC_SUBST(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p) AC_CHECK_TYPES(long long) AC_CHECK_TYPES(long double) # Check for big-endian machines AC_C_BIGENDIAN ## ## Compiler and compiler flag checks ## # Disable all compiler optimizations AC_MSG_CHECKING(whether to enable compiler optimizations) AC_ARG_ENABLE(optimizations, [ --disable-optimizations do not use any compiler optimizations], [ AC_MSG_RESULT(no) AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS]) want_cc_optimizations=false ], [ AC_MSG_RESULT(yes) want_cc_optimizations=true ]) AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse) if test "$GCC"; then # GCC specific options if test "x$summary_debug" = "xyes"; then SILC_ADD_CFLAGS(-g) else SILC_ADD_CFLAGS(-g) fi SILC_ADD_CFLAGS(-Wall -finline-functions) SILC_ADD_CFLAGS(-Wno-pointer-sign) else # Other compilers case "$target" in alpha*-dec-osf*) SILC_ADD_CFLAGS(-g3) ;; mips*-sgi-irix*) SILC_ADD_CFLAGS(-g3) ;; *) SILC_ADD_CFLAGS(-g) ;; esac # Intel C++ Compiler flags if test "x$CC" = "xicc"; then SILC_ADD_CFLAGS(-restrict) SILC_ADD_CFLAGS(-finline-functions) # Don't define __GNUC__ except for system includes SILC_ADD_CFLAGS(-gcc-sys) fi fi if test x$want_cc_optimizations = xtrue; then if test "$GCC"; then # GCC specific options if test "x$summary_debug" = "xyes"; then SILC_ADD_CFLAGS(-O) else SILC_ADD_CFLAGS(-O2) fi else # Other compilers case "$target" in alpha*-dec-osf*) SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O)) ;; mips*-sgi-irix*) SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O)) ;; *) SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O)) ;; esac fi fi ## ## Function and libary checking ## AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport) AC_CHECK_FUNCS(poll select listen bind shutdown close connect setsockopt) AC_CHECK_FUNCS(setrlimit time ctime utime gettimeofday getrusage) AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror) AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid sched_yield) AC_CHECK_FUNCS(setgroups initgroups nl_langinfo nanosleep) AC_CHECK_FUNCS(strchr snprintf strstr strcpy strncpy memcpy memset memmove) AC_CHECK_FUNCS(setenv getenv putenv unsetenv clearenv backtrace) # Check getopt_long AC_CHECK_FUNC(getopt_long, [ AC_DEFINE([HAVE_GETOPT_LONG], [], [HAVE_GETOPT_LONG]) have_getopt_long=1 ], have_getopt_long=0 ) # Check gethostbyname AC_CHECK_FUNC(gethostbyname, [], [ AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl") AC_CHECK_FUNC(res_gethostbyname, [], AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv") ) ]) # Check socket AC_CHECK_FUNC(socket, [], AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") ) # Check clock_gettime AC_CHECK_FUNC(clock_gettime, [], [ AC_CHECK_LIB(rt, clock_gettime, [ LIBS="$LIBS -lrt" AC_DEFINE([HAVE_CLOCK_GETTIME], [], [HAVE_CLOCK_GETTIME])]) ]) # Check for epoll_wait and verify that epoll_create works AC_CHECK_FUNC(epoll_wait, [ AC_RUN_IFELSE([AC_LANG_SOURCE( [ #include int main() { int ret = epoll_create(5); if (ret < 0) return 1; close(ret); return 0; } ])], [ AC_DEFINE([HAVE_EPOLL_WAIT], [1], [HAVE_EPOLL_WAIT]) ], ) ]) # Check for va_copy va_copy=false __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) dest = src" AC_MSG_CHECKING(for va_copy) AC_TRY_COMPILE( [ #include #include ], [ int t(int x, ...) { va_list va, cp; va_start(va, x); va_copy(cp, va); if (va_arg(cp, int) != 0xff11) return 1; va_end(va); va_end(cp); return 0; } int main() { return t(0, 0xff11); } ], [ __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) va_copy(dest, src)" AC_MSG_RESULT(yes) va_copy=true ], [ AC_MSG_RESULT(no) va_copy=false ] ) if test x$va_copy = xfalse; then AC_MSG_CHECKING(for __va_copy) AC_TRY_COMPILE( [ #include #include ], [ int t(int x, ...) { va_list va, cp; va_start(va, x); __va_copy(cp, va); if (va_arg(cp, int) != 0xff11) return 1; va_end(va); va_end(cp); return 0; } int main() { return t(0, 0xff11); } ], [ __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) __va_copy(dest, src)" AC_MSG_RESULT(yes) va_copy=true ], [ AC_MSG_RESULT(no) va_copy=false ] ) fi if test x$va_copy = xfalse; then AC_RUN_IFELSE([AC_LANG_SOURCE( [ #include #include int t(int x, ...) { va_list va, cp; va_start(va, x); cp = va; if (va_arg(cp, int) != 0xff11) return 1; va_end(va); va_end(cp); return 0; } int main() { return t(0, 0xff11); } ])], [va_copy=false], [ AC_DEFINE([SILC_VA_COPY_ARRAY], [], [SILC_VA_COPY_ARRAY]) __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) memmove(dest, src, sizeof(va_list))" ], [va=copy=false] ) fi AC_SUBST(__SILC_VA_COPY) # Check for timezone and tm_gmtoff for timezone information AC_MSG_CHECKING(whether system has timezone) AC_RUN_IFELSE([AC_LANG_SOURCE( [ #include #include int main() { timezone = 0; return 0; } ])], [ AC_MSG_RESULT(yes) AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(no) ] ) AC_MSG_CHECKING(whether system has tm_gmtoff) AC_RUN_IFELSE([AC_LANG_SOURCE( [ #include #include int main() { struct tm tm; tm.tm_gmtoff = 0; return 0; } ])], [ AC_MSG_RESULT(yes) AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(no) ] ) AC_MSG_CHECKING(whether system has __tm_gmtoff) AC_RUN_IFELSE([AC_LANG_SOURCE( [ #include #include int main() { struct tm tm; tm.__tm_gmtoff = 0; return 0; } ])], [ AC_MSG_RESULT(yes) AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(no) ] ) AC_MSG_CHECKING(whether system has __tm_gmtoff__) AC_RUN_IFELSE([AC_LANG_SOURCE( [ #include #include int main() { struct tm tm; tm.__tm_gmtoff__ = 0; return 0; } ])], [ AC_MSG_RESULT(yes) AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(no) ] ) # Check for dlopen() and friends AC_CHECK_HEADERS(dlfcn.h, [ AC_CHECK_LIB(dl, dlopen, [ AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN]) LIBS="$LIBS -ldl" ], [ AC_CHECK_LIB(c, dlopen, [ AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN]) ]) ]) ]) __SILC_ENABLE_DEBUG="" runtimever=`echo $VERSION | sed 's/\./ /g'` maj=0 min=0 bld=0 for v in $runtimever do if test $maj -eq 0; then maj=$v continue fi if test $min -eq 0; then min=$v continue fi if test $bld -eq 0; then bld=$v continue fi done __RUNTIME_PACKAGE_VERSION="#define __SILC_RUNTIME_VERSION SILC_VERSION($maj,$min,$bld)" ## ## Enable/disable checking ## # IPv6 support AC_MSG_CHECKING(whether to enable IPv6 support) AC_ARG_ENABLE(ipv6, [ --enable-ipv6 enable IPv6 support], [ case "${enableval}" in yes) want_ipv6=true check_ipv6=false summary_ipv6="yes" AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6]) AC_MSG_RESULT(yes) ;; *) want_ipv6=false check_ipv6=false summary_ipv6="no" AC_MSG_RESULT(no) ;; esac ], check_ipv6=true ) if test x$check_ipv6 = xtrue; then summary_ipv6="no" AC_TRY_COMPILE( [ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_NETINET_TCP_H #include #endif #ifdef HAVE_NETDB_H #include #endif #include #ifdef HAVE_NETINET_IN_H #include #endif ], [ struct sockaddr_in6 sin6; int family = AF_INET6; ], [ AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6]) AC_MSG_RESULT(yes) summary_ipv6="yes" ], AC_MSG_RESULT(no) ) fi # Memory alignment. User can specify what alignment memory allocation and # SilcStack allocation use. Default is system default alignemnt. AC_ARG_WITH(alignment, [ --with-alignment=NUMBER Memory alignment in bytes], [ AC_DEFINE_UNQUOTED([SILC_ALIGNMENT], [$withval], [SILC_ALIGNMENT]) AC_MSG_RESULT(Memory allocation alignment is $withval bytes) ], [ AC_DEFINE([SILC_ALIGNMENT], SILC_SIZEOF_VOID_P, [SILC_ALIGNMENT]) ]) # Memory trace checking __SILC_ENABLE_MEMTRACE="" AC_MSG_CHECKING(whether to enable memory tracing) AC_ARG_ENABLE(mem-trace, [ --enable-mem-trace enable memory tracing], [ case "${enableval}" in yes) AC_MSG_RESULT(yes) AC_DEFINE([SILC_MEMTRACE], [], [SILC_MEMTRACE]) __SILC_ENABLE_MEMTRACE="#define __SILC_ENABLE_MEMTRACE 1" CFLAGS="$CFLAGS -rdynamic" PC_CFLAGS="$PC_CFLAGS -rdynamic" ;; *) AC_MSG_RESULT(no) ;; esac ], AC_MSG_RESULT(no) ) #ifdef SILC_DIST_INPLACE # # Profiling options (never delivered to distributions) # AC_MSG_CHECKING(whether to enable gprof) AC_ARG_ENABLE(gprof, [ --enable-gprof enable gprof profiling], [ case "${enableval}" in yes) AC_MSG_RESULT(yes) SILC_ADD_CFLAGS(-pg) LIBS="$LIBS -pg" ;; *) AC_MSG_RESULT(no) ;; esac ], [ AC_MSG_RESULT(no) ]) AC_MSG_CHECKING(whether to enable gcov) AC_ARG_ENABLE(gcov, [ --enable-gcov enable gcov], [ case "${enableval}" in yes) AC_MSG_RESULT(yes) SILC_ADD_CFLAGS(-fprofile-arcs) LIBS="$LIBS -lgcov" ;; *) AC_MSG_RESULT(no) ;; esac ], [ AC_MSG_RESULT(no) ]) AC_MSG_CHECKING(whether to have verbose compilation) AC_ARG_ENABLE(verbose, [ --enable-verbose have verbose compilation], [ case "${enableval}" in yes) AC_MSG_RESULT(yes) # Add here any options to give verbose compilation output SILC_ADD_CFLAGS(-ftree-vectorizer-verbose=2) ;; *) AC_MSG_RESULT(no) ;; esac ], [ AC_MSG_RESULT(no) ]) #endif SILC_DIST_INPLACE # Debug checking AC_MSG_CHECKING(whether to enable debugging) summary_debug="no" __SILC_ENABLE_DEBUG="" AC_ARG_ENABLE(debug, [ --enable-debug enable debugging], [ case "${enableval}" in yes) AC_MSG_RESULT(yes) AC_DEFINE([SILC_DEBUG], [], [enable-debug]) PC_CFLAGS="$PC_CFLAGS -DSILC_DEBUG" summary_debug="yes" __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1" ;; *) AC_MSG_RESULT(no) ;; esac ], [ AC_MSG_RESULT(no) ]) # Disable all assembler optimizations AC_MSG_CHECKING(whether to enable assembler optimizations) AC_ARG_ENABLE(asm, [ --disable-asm do not use assembler optimizations], [ AC_MSG_RESULT(no) AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM]) want_asm=false ], [ AC_MSG_RESULT(yes) want_asm=true ]) AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse) # Check for assembler SILC_ASSEMBLER="" have_assembler=false if test x$want_asm = xtrue; then AC_PATH_PROG([NASM], [nasm], [no]) if test "x$NASM" != "xno"; then if test x$cpu_x86_64 = xtrue; then SILC_ASSEMBLER="$NASM -O2 -felf64" else SILC_ASSEMBLER="$NASM -O2 -felf" fi have_assembler=true fi AC_PATH_PROG([YASM], [yasm], [no]) if test "x$YASM" != "xno"; then if test x$cpu_x86_64 = xtrue; then SILC_ASSEMBLER="$YASM -Xgnu -felf64" else SILC_ASSEMBLER="$YASM -Xgnu -felf" fi have_assembler=true fi fi AC_SUBST(SILC_ASSEMBLER) ## ## With/without checkings ## LIBSUBDIR=lib LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS" SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/contrib" SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcutil" SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silchttp" # Check for iconv support check_iconv=true has_iconv=false SAVE_LIBS="$LIBS" SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" SAVE_CPPFLAGS="$CPPFLAGS" AC_MSG_CHECKING(whether to implicit search for libiconv) AC_ARG_WITH(iconv, [[ --with-iconv[=DIR] use libiconv [search in DIR/include and DIR/lib]]], [ case "${withval}" in no) AC_MSG_RESULT(no) AC_CHECK_HEADERS(iconv.h, [ AC_CHECK_FUNC(iconv, has_iconv=true) ]) check_iconv=false ;; *) AC_MSG_RESULT(yes) if test -d $withval/include; then CPPFLAGS="$CPPFLAGS -I$withval/include" CFLAGS="$CFLAGS -I$withval/include" fi if test -d $withval/lib; then LDFLAGS="$LDFLAGS -L$withval/lib" fi ;; esac ], [ AC_MSG_RESULT(no) AC_CHECK_HEADERS(iconv.h, [ # Default check for iconv in C-library AC_CHECK_FUNCS(iconv iconv_open iconv_close, [ has_iconv=true check_iconv=false ]) ]) ]) if test x$check_iconv = xtrue; then # Check for iconv in libiconv installed under /usr AC_MSG_RESULT(Searching for iconv...) # XXX unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true AC_CHECK_HEADERS(iconv.h, [ LIBS="$LIBS -liconv" LDFLAGS="$LDFLAGS -L/usr/lib" CFLAGS="$CFLAGS -I/usr/include" CPPLAGS="$CPPFLAGS -I/usr/include" AC_MSG_CHECKING(for iconv in -liconv) AC_TRY_LINK( [ #include #include ], [ iconv_t cd = iconv_open("", ""); iconv(cd, NULL, NULL, NULL, NULL); iconv_close(cd); ], [ echo "yes" AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.]) has_iconv=true check_iconv=false ], [ echo "no" LIBS="$SAVE_LIBS" CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" CPPFLAGS="$SAVE_CPPFLAGS" ]) ]) fi if test x$check_iconv = xtrue; then # search for iconv library.. SAVE_LIBS="$LIBS" SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" SAVE_CPPFLAGS="$CPPFLAGS" for dir in `echo "/usr/local /usr/pkg /usr/contrib /opt/local"`; do if test x$has_iconv = xfalse; then AC_MSG_RESULT(searching in $dir...) if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include" CFLAGS="$CFLAGS -I$dir/include" fi if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib" fi # XXX unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true AC_CHECK_HEADERS(iconv.h, [ LIBS="$LIBS -liconv" AC_MSG_CHECKING(for iconv in -liconv) AC_TRY_LINK( [ #include #include ], [ iconv_t cd = iconv_open("", ""); iconv(cd, NULL, NULL, NULL, NULL); iconv_close(cd); ], [ echo "yes" has_iconv=true AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.]) ], [ echo "no" has_iconv=false LIBS="$SAVE_LIBS" CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" CPPFLAGS="$SAVE_CPPFLAGS" ]) ], [ CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" CPPFLAGS="$SAVE_CPPFLAGS" ]) fi done fi if test x$has_iconv = xtrue; then # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8. # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3). # AC_CACHE_CHECK([whether this iconv is good enough], ac_cv_iconv_good, AC_TRY_RUN( [ #include int main() { iconv_t cd; changequote(, )dnl char buf[4]; changequote([, ])dnl char *ob; size_t obl; ob = buf, obl = sizeof(buf); return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) && (iconv(cd, 0, 0, &ob, &obl) || !(ob == buf && obl == sizeof(buf)) || iconv_close(cd))); } ], [ ac_cv_iconv_good=yes ], [ ac_cv_iconv_good=no ], [ ac_cv_iconv_good=yes ]) ) if test x$ac_cv_iconv_good = xno; then AC_MSG_RESULT(Try using libiconv instead.) fi fi # Check for POSIX threads support AC_MSG_CHECKING(whether to search for POSIX threads) AC_ARG_WITH(pthreads, [[ --with-pthreads[=DIR] use POSIX threads [search in DIR/include and DIR/lib]]], [ case "${withval}" in no) check_threads=false ;; *) if test -d $withval/include; then CPPFLAGS="$CPPFLAGS -I$withval/include" CFLAGS="$CFLAGS -I$withval/include" fi if test -d $withval/lib; then LDFLAGS="$LDFLAGS -L$withval/lib" fi check_threads=true ;; esac ]) if test x$check_threads = xtrue; then has_threads=false SAVE_LIBS="$LIBS" SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" SAVE_CPPFLAGS="$CPPFLAGS" AC_MSG_RESULT(yes) AC_CHECK_HEADERS(pthread.h, [ LIBS="$LIBS -lpthread" AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true, [ # FreeBSD case "${target}" in *-*-freebsd*) LIBS="$SAVE_LIBS -pthread" AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true, LIBS="$SAVE_LIBS") ;; *) LIBS="$SAVE_LIBS" ;; esac ]) ], [ # search for pthread library.. for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do if test x$has_threads = xfalse; then AC_MSG_RESULT(searching in $dir...) if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include" CFLAGS="$CFLAGS -I$dir/include" fi if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib" fi # XXX unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true AC_CHECK_HEADERS(pthread.h, [ LIBS="$LIBS -lpthread" AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true, [ has_threads=false LIBS="$SAVE_LIBS" CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" CPPFLAGS="$SAVE_CPPFLAGS" ]) ], [ CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" CPPFLAGS="$SAVE_CPPFLAGS" ]) fi done ]) else AC_MSG_RESULT(no) has_threads=false fi __SILC_HAVE_PTHREAD="" AM_CONDITIONAL(SILC_THREADS, test x$has_threads = xtrue) if test x$has_threads = xtrue; then CFLAGS="$CFLAGS -D_REENTRANT" # XXX possibly incomplete case "${target}" in *-*-aix*) CFLAGS="$CFLAGS -D_THREAD_SAFE" if test x"$GCC" = xyes; then CFLAGS="$CFLAGS -mthreads" fi ;; *-*-freebsd*) CFLAGS="$CFLAGS -D_THREAD_SAFE" ;; *-*-sysv5uw7*) # UnixWare 7 if test "$GCC" != "yes"; then CFLAGS="$CFLAGS -Kthread" else CFLAGS="$CFLAGS -pthread" fi ;; *-dg-dgux*) # DG/UX CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE" ;; esac # Check for threads AC_CHECK_FUNCS(pthread_create pthread_key_create pthread_once) # Check for read/write locks AC_CHECK_FUNC(pthread_rwlock_init, [ AC_RUN_IFELSE([AC_LANG_SOURCE( [ #include int main() { pthread_rwlock_t rwlock; pthread_rwlock_init(&rwlock, NULL); pthread_rwlock_destroy(&rwlock); return 0; } ])], [], [ # Rwlock not defined CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600" ] ) ], [ # Rwlock not defined CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600" ]) AC_DEFINE([SILC_HAVE_PTHREAD], [], [HAVE_PTHREAD]) AC_DEFINE([SILC_THREADS], [], [HAVE_THREAD]) __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1" PC_CFLAGS="$PC_CFLAGS -DSILC_THREADS" fi # Check for Expat AC_ARG_WITH(expat, [[ --with-expat[=DIR] use Expat XML [search in DIR/include and DIR/lib]]], [ case "${withval}" in no) ;; *) if test -d $withval/include; then CPPFLAGS="$CPPFLAGS -I$withval/include" CFLAGS="$CFLAGS -I$withval/include" fi if test -d $withval/lib; then LDFLAGS="$LDFLAGS -L$withval/lib" fi ;; esac ]) AC_CHECK_HEADERS(expat.h, [ LIBS="$LIBS -lexpat" ], [ AC_MSG_ERROR(Expat XML Library is required to compile SRT) ]) ## ## Native WIN32 compilation under cygwin ## AC_MSG_CHECKING(whether to compile native WIN32 code) AC_ARG_WITH(win32, [ --with-win32 compile native WIN32 (MinGW) code (-mno-cygwin)], [ AC_MSG_RESULT(yes) AC_DEFINE([SILC_WIN32], [], [SILC_WIN32]) win32_support=true CFLAGS="-mno-cygwin $CFLAGS" LIBS="$LIBS -lwsock32" ], [ AC_MSG_RESULT(no) win32_support=false ]) AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue) ## ## Outputs and substitutions ## AC_SUBST(LIBSUBDIR) AC_SUBST(SILC_TOP_SRCDIR) AC_SUBST(LDFLAGS) AC_SUBST(LIBS) AC_SUBST(SILC_LIB_INCLUDES) AC_SUBST(PC_CFLAGS) AC_SUBST(__SILC_ENABLE_DEBUG) AC_SUBST(__SILC_ENABLE_MEMTRACE) AC_SUBST(__SILC_HAVE_PTHREAD) AC_SUBST(__RUNTIME_PACKAGE_VERSION) # Native Symbian OS support (disabled by default) AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue) # Make enable-shared aware AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes) ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR` AC_SUBST(ETCDIR) AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR]) DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR` AC_SUBST(DOCDIR) AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR]) INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int" AC_SUBST(INCLUDE_DEFINES_INT) DATE=`date` AC_SUBST(DATE) # # Makefile outputs # AC_CONFIG_FILES( Makefile doc/Makefile doc/runtime.in/index.html doc/runtime.in/manual.html Makefile.defines Makefile.defines_int includes/Makefile apps/Makefile win32/Makefile ) AC_CONFIG_FILES( lib/Makefile lib/contrib/Makefile lib/silcutil/silcruntime.h lib/silcutil/Makefile lib/silcutil/tests/Makefile lib/silcutil/unix/Makefile lib/silcutil/win32/Makefile lib/silcutil/symbian/Makefile lib/silchttp/Makefile lib/silchttp/tests/Makefile lib/srt.pc ) AC_OUTPUT ## ## Summary output ## s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir` s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir` s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir` s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir` echo "" echo "SILC Runtime Toolkit configuration summary:" echo "------------------------------------------" echo " Target host ...................: $target" echo " Compiler ......................: $CC" echo " CFLAGS ........................: $CFLAGS" echo " LDFLAGS .......................: $LDFLAGS" echo " LIBS ..........................: $LIBS" echo "" echo " Installation prefix ...........: $prefix" echo " bin directory .................: $s_bindir" echo " sbin directory ................: $s_sbindir" echo " etc directory .................: $ETCDIR" echo " man directory .................: $s_mandir" echo " doc directory .................: $DOCDIR" echo " include directory .............: $s_includedir" echo "" echo " IPv6 support ..................: $summary_ipv6" if test x$has_iconv = xfalse; then iconv_support="no" else iconv_support="yes" fi echo " Iconv support .................: $iconv_support" if test x$want_asm = xfalse; then summary_asm="no" else summary_asm="yes" fi echo " Assembler optimizations .......: $summary_asm" if test x$want_cc_optimizations = xfalse; then summary_cc_opt="no" else summary_cc_opt="yes" fi echo " Compiler optimizations ........: $summary_cc_opt" if test x$want_cpu_optimizations = xfalse; then summary_cpu_opt="no" else summary_cpu_opt="yes" fi echo " CPU feature optimizations .....: $summary_cpu_opt" threads="no" if test x$has_threads = xtrue; then threads="yes" fi echo " Multi-threads support .........: $threads" echo " Debugging enabled .............: $summary_debug" echo "" echo "Compile the sources with 'make' or 'gmake' command."