Added silc_mp_format and silc_mp_unformat MP integer encoder/decoder
[crypto.git] / configure.ad
index 48bf498bd43a8c3c8f2e153f9b44ccb9837f66bc..f10074a8b83f5ecacb7d4b1fe68a66c1a71f26b4 100644 (file)
@@ -79,6 +79,59 @@ else
 fi
 
 
+##
+##  Required dependencies
+##
+
+LIBSUBDIR=lib
+LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
+
+SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silccrypt"
+SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcasn1"
+SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcacc"
+SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcskr"
+SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcmath"
+#ifdef SILC_DIST_SSH
+SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcssh"
+#endif SILC_DIST_SSH
+#ifdef SILC_DIST_PGP
+SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcpgp"
+#endif SILC_DIST_PGP
+#ifdef SILC_DIST_PKIX
+SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcpkix"
+#endif SILC_DIST_PKIX
+
+# SILC Runtime Toolkit checking
+AC_ARG_WITH(srt-includes,
+  [  --with-srt-includes=DIR  SILC Runtime Toolkit includes [search in DIR]],
+  [ac_srt_includes="$withval"], [ac_srt_includes="no"])
+AC_ARG_WITH(srt-libs,
+  [  --with-srt-libs=DIR      SILC Runtime Toolkit libraries [search in DIR]],
+  [ac_srt_libs="$withval"], [ac_srt_libs="no"])
+
+if test -n "$with_srt_includes" || test -n "$with_srt_libs"; then
+  # Manually provided libs
+  if test "$ac_srt_includes" != "no"; then
+    SILC_LIB_INCLUDES="-I$ac_srt_includes"
+  fi
+  if test "$ac_srt_libs" != "no"; then
+    LDFLAGS="-L$ac_srt_libs $LDFLAGS"
+  fi
+
+  # Check libs to link against
+  f=`$EGREP __SILC_HAVE_PTHREAD $ac_srt_includes/silc.h`
+  if test -n "$f"; then
+    LIBS="$LIBS -lpthread"
+    has_threads=true
+  fi
+else
+  # pkg-config check
+  PKG_CHECK_MODULES(SRT, [srt >= 1.2])
+  LIBS="$SRT_LIBS $LIBS"
+  CFLAGS="$CFLAGS $SRT_CFLAGS"
+fi
+
+
 ##
 ## Detect CPU
 ##
@@ -136,20 +189,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
@@ -161,7 +210,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
@@ -182,7 +234,10 @@ 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 = xtrue; then
+    if test x$x_have_cpu_sse4_1 = xtrue; then
+      SILC_ADD_CFLAGS(-axS)
+    fi
+    if test x$x_have_cpu_sse4_2 = xtrue; then
       SILC_ADD_CFLAGS(-axS)
     fi
     if test x$x_have_cpu_ssse3 = xtrue; then
@@ -203,7 +258,10 @@ if test x$want_cpu_optimizations = xtrue; then
     if test x$x_have_cpu_ssse3 = xtrue; then
       SILC_ADD_CFLAGS(-mssse3)
     fi
-    if test x$x_have_cpu_sse4 = xtrue; then
+    if test x$x_have_cpu_sse4_1 = xtrue; then
+      SILC_ADD_CFLAGS(-msse4)
+    fi
+    if test x$x_have_cpu_sse4_2 = xtrue; then
       SILC_ADD_CFLAGS(-msse4)
     fi
   fi
@@ -455,12 +513,29 @@ AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse)
 SILC_ASSEMBLER=""
 have_assembler=false
 if test x$want_asm = xtrue; then
+  ASM_FLAGS=
+  if test x$x_have_cpu_sse2 = xtrue; then
+    ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSE2"
+  fi
+  if test x$x_have_cpu_pni = xtrue; then
+    ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSE3"
+  fi
+  if test x$x_have_cpu_ssse3 = xtrue; then
+    ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSSE3"
+  fi
+  if test x$x_have_cpu_sse4_1 = xtrue; then
+    ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSE41"
+  fi
+  if test x$x_have_cpu_sse4_2 = xtrue; then
+    ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSE42"
+  fi
+
   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"
+      SILC_ASSEMBLER="$NASM -O2 -felf64 $ASM_FLAGS"
     else
-      SILC_ASSEMBLER="$NASM -O2 -felf"
+      SILC_ASSEMBLER="$NASM -O2 -felf $ASM_FLAGS"
     fi
     have_assembler=true
   fi
@@ -468,9 +543,9 @@ if test x$want_asm = xtrue; then
   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"
+      SILC_ASSEMBLER="$YASM -Xgnu -felf64 $ASM_FLAGS"
     else
-      SILC_ASSEMBLER="$YASM -Xgnu -felf"
+      SILC_ASSEMBLER="$YASM -Xgnu -felf $ASM_FLAGS"
     fi
     have_assembler=true
   fi
@@ -481,54 +556,6 @@ 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/silccrypt"
-SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcasn1"
-SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcacc"
-SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcskr"
-SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcmath"
-#ifdef SILC_DIST_SSH
-SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcssh"
-#endif SILC_DIST_SSH
-#ifdef SILC_DIST_PGP
-SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcpgp"
-#endif SILC_DIST_PGP
-#ifdef SILC_DIST_PKIX
-SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcpkix"
-#endif SILC_DIST_PKIX
-
-# SILC Runtime Toolkit checking
-AC_ARG_WITH(srt-includes,
-  [  --with-srt-includes=DIR  SILC Runtime Toolkit includes [search in DIR]],
-  [ac_srt_includes="$withval"], [ac_srt_includes="no"])
-AC_ARG_WITH(srt-libs,
-  [  --with-srt-libs=DIR      SILC Runtime Toolkit libraries [search in DIR]],
-  [ac_srt_libs="$withval"], [ac_srt_libs="no"])
-
-if test -n "$with_srt_includes" || test -n "$with_srt_libs"; then
-  # Manually provided libs
-  if test "$ac_srt_includes" != "no"; then
-    SILC_LIB_INCLUDES="-I$ac_srt_includes"
-  fi
-  if test "$ac_srt_libs" != "no"; then
-    LDFLAGS="-L$ac_srt_libs $LDFLAGS"
-  fi
-
-  # Check libs to link against
-  f=`$EGREP __SILC_HAVE_PTHREAD $ac_srt_includes/silc.h`
-  if test -n "$f"; then
-    LIBS="$LIBS -lpthread"
-    has_threads=true
-  fi
-else
-  # pkg-config check
-  PKG_CHECK_MODULES(SRT, [srt >= 1.2])
-  LIBS="$SRT_LIBS $LIBS"
-  CFLAGS="$CFLAGS $SRT_CFLAGS"
-fi
-
 # MP library checking. First check whether user wants to use GMP and use
 # it if found. If not or not defined then compile the default library in the
 # source tree.