updates.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 9 Aug 2007 14:30:16 +0000 (14:30 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 9 Aug 2007 14:30:16 +0000 (14:30 +0000)
configure.ad
silc.m4

index d98e4db2d2713e44f0f23e614ac7648303f08831..373a6b982e0690d004a55a9facbac2de6d4f91ca 100644 (file)
@@ -53,7 +53,8 @@ case "$target" in
 esac
 
 # Get CPU
-SILC_SYSTEM_IS_SMP(AC_DEFINE([SILC_SMP], [], [SILC_SMP]), [])
+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
@@ -141,6 +142,17 @@ AC_PROG_CC
 AC_C_INLINE
 AC_C_CONST
 
+# Set some compiler options based on CPU
+if test x$x_have_cpu_sse2 = xtrue; then
+  SILC_ADD_CFLAGS(-msse2)
+fi
+if test x$x_have_cpu_sse3 = xtrue; then
+  SILC_ADD_CFLAGS(-msse3)
+fi
+if test x$x_have_cpu_ssse3 = xtrue; then
+  SILC_ADD_CFLAGS(-mssse3)
+fi
+
 __SILC_HAVE_PTHREAD=""
 __SILC_HAVE_SIM=""
 __SILC_ENABLE_DEBUG=""
diff --git a/silc.m4 b/silc.m4
index e84ea0c0d35e40ac4c8d3f0002d69d9fecbae1ae..c05aa2ab00d233918880816f6813e13e0c0d5b6e 100644 (file)
--- a/silc.m4
+++ b/silc.m4
 #
 
 # Function to check if system has SMP kernel.
-# Usage: SILC_SYSTEM_IS_SMP([ACTION-IF-FOUND] [, ACTION-IF-NOT-FOUND])
+#
+# Usage: SILC_SYSTEM_IS_SMP([ACTION-IF-FOUND] [, ACTION-IF-NOT-FOUND]
+#                           [, ACTION-IF-NOT-DETECTED])
+#
+# The ACTION-IF-NOT-DETECTED is called if we could not detect whether or 
+# not the system is SMP.
+#
+# x_is_smp variable is set to true or false as a result for calling this
+# function.  Caller may use the variable to check for the result in the 
+# code.
+#
 AC_DEFUN([SILC_SYSTEM_IS_SMP],
 [
   AC_MSG_CHECKING(whether system has SMP kernel)
+  x_is_smp=false
 
   case "$target" in
     *-*-linux*)
@@ -29,6 +40,7 @@ AC_DEFUN([SILC_SYSTEM_IS_SMP],
         if test $cpucount -gt 1; then
           AC_DEFINE([SILC_SMP], [], [SILC_SMP])
           AC_MSG_RESULT(yes)
+          x_is_smp=true
           ifelse([$1], , :, [$1])
         else
           AC_MSG_RESULT(no)
@@ -42,11 +54,13 @@ AC_DEFUN([SILC_SYSTEM_IS_SMP],
 
     *-*-*bsd*)
       # BSDs can have SMP info in sysctl 'kern.smp.cpus' variable
-      cpucount=`/sbin/sysctl kern.smp.cpus 2> /dev/null | \
-         cut -d'=' -f2 | cut -d' ' -f2`
+      sysctl="sysctl -n kern.smp.cpus"
+      cpucount=`(/sbin/$sysctl 2> /dev/null || \
+                 /usr/sbin/$sysctl 2> /dev/null || echo -n 0)`
       if test $cpucount -gt 1; then
         AC_DEFINE([SILC_SMP], [], [SILC_SMP])
         AC_MSG_RESULT(yes)
+         x_is_smp=true
         ifelse([$1], , :, [$1])
       else
         AC_MSG_RESULT(no)
@@ -55,17 +69,24 @@ AC_DEFUN([SILC_SYSTEM_IS_SMP],
       ;;
 
     *)
-      AC_MSG_RESULT(no)
-      ifelse([$2], , :, [$2])
+      AC_MSG_RESULT(cannot detect on this system)
+      ifelse([$3], , :, [$3])
       ;;
   esac
 ])
 
 # Function to check for CPU feature flags.
+#
 # Usage: SILC_CPU_FLAG(flag [, ACTION-IF-FOUND] [, ACTION-IF-NOT-FOUND])
+#
+# x_have_cpu_<flag> variable is set to true or false value as a result for
+# calling this function for the <flag>.  Caller may use the variable to
+# check the result in the code.
+#
 AC_DEFUN([SILC_CPU_FLAG],
 [
   AC_MSG_CHECKING(whether CPU supports $1)
+  x_have_cpu_$1=false
 
   case "$target" in
     *-*-linux*)
@@ -77,6 +98,7 @@ AC_DEFUN([SILC_CPU_FLAG],
           ifelse([$3], , :, [$3])
         else
           AC_MSG_RESULT(yes)
+          x_have_cpu_$1=true
           ifelse([$2], , :, [$2])
         fi
       else
@@ -93,19 +115,24 @@ AC_DEFUN([SILC_CPU_FLAG],
         ifelse([$3], , :, [$3])
       else
         AC_MSG_RESULT(yes)
+          x_have_cpu_$1=true
         ifelse([$2], , :, [$2])
       fi
       ;;
 
     *)
-      AC_MSG_RESULT(no)
+      AC_MSG_RESULT(no, cannot detect on this system)
       ifelse([$3], , :, [$3])
       ;;
   esac
 ])
 
-# Function to check if compiler flag works
+# Function to check if compiler option works with the compiler.  If you
+# want the option added to some other than CFLAGS variable use the
+# SILC_ADD_CC_FLAGS which supports to specifiable destination variable.
+#
 # Usage: SILC_ADD_CFLAGS(FLAGS, [ACTION-IF-FAILED])
+#
 AC_DEFUN([SILC_ADD_CFLAGS],
 [ tmp_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS $1"
@@ -116,8 +143,11 @@ AC_DEFUN([SILC_ADD_CFLAGS],
   unset tmp_CFLAGS
 ])
 
-# Function to check if compiler flag works, destination specifiable
+# Function to check if compiler option works with the compiler,
+# destination variable specifiable
+#
 # Usage: SILC_ADD_CC_FLAGS(VAR, FLAGS, [ACTION-IF-FAILED])
+#
 AC_DEFUN([SILC_ADD_CC_FLAGS],
 [ tmp_CFLAGS="$1_CFLAGS"
   $1_CFLAGS="${$1_CFLAGS} $2"