You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by mt...@apache.org on 2010/05/21 08:20:43 UTC

svn commit: r946892 - in /trafficserver/traffic/trunk: build/common.m4 configure.ac

Author: mturk
Date: Fri May 21 06:20:43 2010
New Revision: 946892

URL: http://svn.apache.org/viewvc?rev=946892&view=rev
Log:
Add a better architecture detection and configuration

Modified:
    trafficserver/traffic/trunk/build/common.m4
    trafficserver/traffic/trunk/configure.ac

Modified: trafficserver/traffic/trunk/build/common.m4
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/build/common.m4?rev=946892&r1=946891&r2=946892&view=diff
==============================================================================
--- trafficserver/traffic/trunk/build/common.m4 (original)
+++ trafficserver/traffic/trunk/build/common.m4 Fri May 21 06:20:43 2010
@@ -508,14 +508,14 @@ dnl  setting to 1 or 0, we set FLAG-TO-S
 dnl
 AC_DEFUN([ATS_FLAG_HEADERS], [
 AC_CHECK_HEADERS($1)
-for aprt_i in $1
+for tsc_i in $1
 do
-    ac_safe=`echo "$aprt_i" | sed 'y%./+-%__p_%'`
-    atst_2=`echo "$aprt_i" | sed -e 's%/%_%g' -e 's/\.//g' -e 's/-//g'`
+    ac_safe=`echo "$tsc_i" | sed 'y%./+-%__p_%'`
+    tsc_2=`echo "$tsc_i" | sed -e 's%/%_%g' -e 's/\.//g' -e 's/-//g'`
     if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-       eval "ifelse($2,,$atst_2,$2)=ifelse($3,yes,yes,1)"
+       eval "ifelse($2,,$tsc_2,$2)=ifelse($3,yes,yes,1)"
     else
-       eval "ifelse($2,,$atst_2,$2)=ifelse($3,yes,no,0)"
+       eval "ifelse($2,,$tsc_2,$2)=ifelse($3,yes,no,0)"
     fi
 done
 ])
@@ -529,13 +529,13 @@ dnl  to yes or no.
 dnl
 AC_DEFUN([ATS_FLAG_FUNCS], [
 AC_CHECK_FUNCS($1)
-for atct_j in $1
+for tsc_j in $1
 do
-    atct_3="have_$aprt_j"
-    if eval "test \"`echo '$ac_cv_func_'$atst_j`\" = yes"; then
-       eval "ifelse($2,,$atst_3,$2)=ifelse($3,yes,yes,1)"
+    tsc_3="have_$tsc_j"
+    if eval "test \"`echo '$ac_cv_func_'$tsc_j`\" = yes"; then
+       eval "ifelse($2,,$tsc_3,$2)=ifelse($3,yes,yes,1)"
     else
-       eval "ifelse($2,,$atst_3,$2)=ifelse($3,yes,no,0)"
+       eval "ifelse($2,,$tsc_3,$2)=ifelse($3,yes,no,0)"
     fi
 done
 ])

Modified: trafficserver/traffic/trunk/configure.ac
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/configure.ac?rev=946892&r1=946891&r2=946892&view=diff
==============================================================================
--- trafficserver/traffic/trunk/configure.ac (original)
+++ trafficserver/traffic/trunk/configure.ac Fri May 21 06:20:43 2010
@@ -496,41 +496,69 @@ SHARED_LDFLAGS=-shared
 SHARED_CXXFLAGS=-fPIC
 SHARED_CXXLINKFLAGS=-shared
 
-
-#
-# Here are all the extra linux-specific C(XX)FLAGS additions and
-# so forth.
-# TODO cpu architecture settings separate from operating system settings
-#
-
-# Examine the current CXXFLAGS / CFLAGS for patterns we might need
-# ToDo: This needs to be made conditional on compiler used (only gcc is supported here)
-AS_IF([test "x$with_architecture" != "xno"],
-  [CFLAGS="$CFLAGS -march=$with_architecture"; CXXFLAGS="$CXXFLAGS -march=$with_architecture"]
-)
-
 dnl Checks for pointer size
 AC_CHECK_SIZEOF(void*, 4)
 
 if test "x$ac_cv_sizeof_voidp" == "x"; then
-    AC_ERROR([Cannot determine size of void*])
+  AC_ERROR([Cannot determine size of void*])
 fi
 
+#
+# Here are all the extra linux-specific C(XX)FLAGS additions and
+# so forth.
+# TODO cpu architecture settings separate from operating system settings
+#
+cpu_architecture=""
 # GCC: add a default march if there is not one set
 if test "x${GCC}" = "xyes"; then
- if test "${ac_cv_sizeof_voidp}" = "4"; then
-  case $CFLAGS in
-    *\-march=*) : ;;
-    *) CFLAGS="$CFLAGS -march=i586" ;;
-  esac
-
-  case $CXXFLAGS in
-    *\-march=*) : ;;
-    *) CXXFLAGS="$CXXFLAGS -march=i586" ;;
-  esac
- fi
+  if test "${ac_cv_sizeof_voidp}" = "4"; then
+    case "$host_cpu" in
+      i?86* | k[5-8]* | pentium* | athlon)
+        cpu_architecture="-march=i586"
+      ;;
+      *sparc*)
+        cpu_architecture="-mv8"
+      ;;
+    esac
+  else
+    case "$host_cpu" in
+      x86_64 | amd64)
+        cpu_architecture="-march=native"
+      ;;
+      *sparc*)
+        cpu_architecture="-march=ultrasparc"
+      ;;
+    esac
+  fi
+  # TODO: Add support for other compilers
+  #
 fi
 
+# Overrride detected architecture with the user suplied one
+#
+AC_ARG_WITH(architecture, [AC_HELP_STRING([--with-architecture=ARCH],[use a specific CPU architecture])],
+[
+  if test "x$withval" != "xyes" && test "x$withval" != "xno"; then
+    case "$withval" in
+      -*)
+        cpu_architecture="$withval"
+      ;;
+      *)
+        cpu_architecture="-march=$withval"
+      ;;
+    esac
+  elif test "x$withval" = "x"; then
+    AC_MSG_ERROR([--with-architecture requires an param])
+  fi
+])
+
+AS_IF([test "x$cpu_architecture" != "x"],
+[
+  ATS_ADDTO(CFLAGS, [$cpu_architecture])
+  ATS_ADDTO(CXXFLAGS [$cpu_architecture])
+]
+)
+
 # GCC atomics
 AC_CACHE_CHECK([for gcc atomic builtins],[support_cv_atomic],
 [AC_LINK_IFELSE([AC_LANG_PROGRAM([],[[
@@ -665,11 +693,11 @@ if test "x${enable_sqlite3}" != "xyes"; 
   fi
 fi
 
-AC_CHECK_FUNCS([clock_gettime kqueue epoll_ctl posix_memalign lrand48_r srand48_r port_create])
-AC_CHECK_FUNCS([strndup])
+ATS_FLAG_FUNCS([clock_gettime kqueue epoll_ctl posix_memalign lrand48_r srand48_r port_create])
+ATS_FLAG_FUNCS([strndup])
 
 AS_IF([test "x$enable_eventfd" = "xyes"],
-  [AC_CHECK_FUNCS([eventfd])]
+  [ATS_FLAG_FUNCS([eventfd])]
 )
 
 #
@@ -761,7 +789,7 @@ fi
 # -----------------------------------------------------------------------------
 # 5. CHECK FOR HEADER FILES
 
-AC_CHECK_HEADERS([sys/epoll.h \
+ATS_FLAG_HEADERS([sys/epoll.h \
                   sys/event.h \
                   machine/endian.h \
                   endian.h \
@@ -798,7 +826,7 @@ AC_CHECK_HEADERS([sys/epoll.h \
                   net/ppp_defs.h \
                   ], [], [])
 
-AC_CHECK_HEADERS([netinet/ip.h], [], [],
+ATS_FLAG_HEADERS([netinet/ip.h], [], [],
                  [[#ifdef HAVE_SYS_TYPES_H
                     #include <sys/types.h>
                    #endif
@@ -807,7 +835,7 @@ AC_CHECK_HEADERS([netinet/ip.h], [], [],
                    #endif
                  ]])
 
-AC_CHECK_HEADERS([netinet/ip_icmp.h], [], [],
+ATS_FLAG_HEADERS([netinet/ip_icmp.h], [], [],
                  [[#ifdef HAVE_SYS_TYPES_H
                     #include <sys/types.h>
                    #endif
@@ -823,7 +851,7 @@ AC_CHECK_HEADERS([netinet/ip_icmp.h], []
                  ]])
 
 if test "x${with_profiler}" = "xyes"; then
-AC_CHECK_HEADERS([google/profiler.h \
+ATS_FLAG_HEADERS([google/profiler.h \
                   ], [], [])
 fi