Mac OS X >= 10.7 support
[runtime.git] / configure.ad
index 4899dd6ef42369fa5a10c6e7f44c829c72929da9..fd047ab08a69e5fdf278853ede6571c0b51cb83e 100644 (file)
@@ -149,20 +149,16 @@ case "$host_cpu" in
     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(sse4, true, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), [])
+    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
-
-    # 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(sse4, true, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), [])
     ;;
 
   # AMD/Intel x86_64, 64-bit CPU
@@ -175,7 +171,10 @@ case "$host_cpu" in
     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(sse4, true, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), [])
+    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
@@ -197,31 +196,41 @@ 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_sse2 = xtrue; then
-      SILC_ADD_CFLAGS(-axW)
-    fi
-    if test x$x_have_cpu_sse3 = xtrue; then
-      SILC_ADD_CFLAGS(-axP)
+    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)
-    fi
-    if test x$x_have_cpu_sse4 = xtrue; then
-      SILC_ADD_CFLAGS(-axS)
+    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 = xtrue; then
+    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
@@ -245,6 +254,9 @@ case "$target" in
   *-*-*bsd*)
     check_threads=false
     ;;
+  *-*-*darwin*)
+    check_threads=true
+    ;;
   *)
     check_threads=true
     ;;
@@ -260,7 +272,7 @@ AC_HEADER_STAT
 
 # More header checking
 #
-AC_CHECK_HEADERS(unistd.h string.h errno.h fcntl.h assert.h)
+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)
@@ -382,7 +394,7 @@ 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)
+AC_CHECK_FUNCS(setenv getenv putenv unsetenv clearenv backtrace)
 
 # Check getopt_long
 AC_CHECK_FUNC(getopt_long,
@@ -417,7 +429,7 @@ AC_CHECK_FUNC(clock_gettime, [],
 # Check for epoll_wait and verify that epoll_create works
 AC_CHECK_FUNC(epoll_wait,
   [
-    AC_RUN_IFELSE(
+    AC_RUN_IFELSE([AC_LANG_SOURCE(
       [
         #include <sys/epoll.h>
         int main()
@@ -428,7 +440,7 @@ AC_CHECK_FUNC(epoll_wait,
           close(ret);
           return 0;
         }
-      ],
+      ])],
       [
         AC_DEFINE([HAVE_EPOLL_WAIT], [1], [HAVE_EPOLL_WAIT])
       ],
@@ -437,6 +449,7 @@ AC_CHECK_FUNC(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(
   [
@@ -461,7 +474,7 @@ AC_TRY_COMPILE(
     }
   ],
   [
-    AC_DEFINE([HAVE_VA_COPY], [], [HAVE_VA_COPY])
+    __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) va_copy(dest, src)"
     AC_MSG_RESULT(yes)
     va_copy=true
   ],
@@ -496,7 +509,7 @@ if test x$va_copy = xfalse; then
     }
   ],
   [
-    AC_DEFINE([HAVE___VA_COPY], [], [HAVE___VA_COPY])
+    __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) __va_copy(dest, src)"
     AC_MSG_RESULT(yes)
     va_copy=true
   ],
@@ -508,7 +521,7 @@ if test x$va_copy = xfalse; then
 fi
 
 if test x$va_copy = xfalse; then
-  AC_RUN_IFELSE(
+  AC_RUN_IFELSE([AC_LANG_SOURCE(
     [
       #include <stdarg.h>
       #include <stdlib.h>
@@ -527,18 +540,20 @@ if test x$va_copy = xfalse; then
       {
         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_RUN_IFELSE([AC_LANG_SOURCE(
   [
     #include <stdio.h>
     #include <time.h>
@@ -547,14 +562,14 @@ AC_RUN_IFELSE(
       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_RUN_IFELSE([AC_LANG_SOURCE(
   [
     #include <stdio.h>
     #include <time.h>
@@ -564,14 +579,14 @@ AC_RUN_IFELSE(
       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_RUN_IFELSE([AC_LANG_SOURCE(
   [
     #include <stdio.h>
     #include <time.h>
@@ -581,14 +596,14 @@ AC_RUN_IFELSE(
       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_RUN_IFELSE([AC_LANG_SOURCE(
   [
     #include <stdio.h>
     #include <time.h>
@@ -598,7 +613,7 @@ AC_RUN_IFELSE(
       tm.__tm_gmtoff__ = 0;
       return 0;
     }
-  ],
+  ])],
   [ AC_MSG_RESULT(yes)
     AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ],
   [ AC_MSG_RESULT(no) ],
@@ -716,15 +731,19 @@ AC_ARG_WITH(alignment,
     AC_DEFINE([SILC_ALIGNMENT], SILC_SIZEOF_VOID_P, [SILC_ALIGNMENT])
   ])
 
-# Stack trace checking
-AC_MSG_CHECKING(whether to enable stack tracing)
-AC_ARG_ENABLE(stack-trace,
-  [  --enable-stack-trace    enable memory stack trace],
+# 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_STACKTRACE], [], [SILC_STACKTRACE])
+      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)
@@ -775,6 +794,26 @@ AC_ARG_ENABLE(gcov,
   [
     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
@@ -788,6 +827,7 @@ AC_ARG_ENABLE(debug,
       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"
         ;;
@@ -851,6 +891,7 @@ 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
@@ -889,7 +930,8 @@ AC_ARG_WITH(iconv,
     AC_MSG_RESULT(no)
     AC_CHECK_HEADERS(iconv.h,
       [
-        AC_CHECK_FUNCS(iconv,
+       # Default check for iconv in C-library
+        AC_CHECK_FUNCS(iconv iconv_open iconv_close,
           [
             has_iconv=true
             check_iconv=false
@@ -898,6 +940,7 @@ AC_ARG_WITH(iconv,
   ])
 
 if test x$check_iconv = xtrue; then
+  # Check for iconv in libiconv installed under /usr
   AC_MSG_RESULT(Searching for iconv...)
 
   # XXX
@@ -906,6 +949,10 @@ if test x$check_iconv = xtrue; then
   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(
         [
@@ -940,7 +987,7 @@ if test x$check_iconv = xtrue; then
   SAVE_LDFLAGS="$LDFLAGS"
   SAVE_CPPFLAGS="$CPPFLAGS"
 
-  for dir in `echo "/usr/local /usr/pkg /usr/contrib"`; do
+  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...)
 
@@ -998,7 +1045,7 @@ if test x$has_iconv = xtrue; then
   # (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_iconv_good,
+  AC_CACHE_CHECK([whether this iconv is good enough], ac_cv_iconv_good,
     AC_TRY_RUN(
       [
         #include <iconv.h>
@@ -1017,17 +1064,17 @@ if test x$has_iconv = xtrue; then
         }
       ],
       [
-        ac_iconv_good=yes
+        ac_cv_iconv_good=yes
       ],
       [
-        ac_iconv_good=no
+        ac_cv_iconv_good=no
       ],
       [
-        ac_iconv_good=yes
+        ac_cv_iconv_good=yes
       ])
     )
 
-  if test x$ac_iconv_good = xno; then
+  if test x$ac_cv_iconv_good = xno; then
     AC_MSG_RESULT(Try using libiconv instead.)
   fi
 fi
@@ -1157,7 +1204,7 @@ if test x$has_threads = xtrue; then
   # Check for read/write locks
   AC_CHECK_FUNC(pthread_rwlock_init,
   [
-    AC_RUN_IFELSE(
+    AC_RUN_IFELSE([AC_LANG_SOURCE(
       [
         #include <pthread.h>
         int main()
@@ -1167,7 +1214,7 @@ if test x$has_threads = xtrue; then
           pthread_rwlock_destroy(&rwlock);
           return 0;
         }
-      ],
+      ])],
       [],
       [
        # Rwlock not defined
@@ -1183,9 +1230,34 @@ if test x$has_threads = xtrue; then
   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
 ##
@@ -1215,7 +1287,9 @@ 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)
 
@@ -1247,6 +1321,7 @@ AC_CONFIG_FILES(
 Makefile
 doc/Makefile
 doc/runtime.in/index.html
+doc/runtime.in/manual.html
 Makefile.defines
 Makefile.defines_int
 includes/Makefile
@@ -1263,6 +1338,8 @@ 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
 )