List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:January 27 2010 8:44am
Subject:bzr commit into mysql-6.0-codebase-bugfixing branch (tor.didriksen:3651)
View as plain text  
#At file:///export/home/didrik/mysqldev-6.0-codebase/6.0-codebase-bf-gtest/my-6.0-codebase-bugfixing-gtest-dup/ based on revid:tor.didriksen@stripped

 3651 Tor Didriksen	2010-01-27
      Cleanup gtest.m4
     @ config/ac-macros/gtest.m4
        Use /bin/bash for solaris only.
        Add help string to --with-gtest flag.

    modified:
      config/ac-macros/gtest.m4
=== modified file 'config/ac-macros/gtest.m4'
--- a/config/ac-macros/gtest.m4	2010-01-18 12:24:42 +0000
+++ b/config/ac-macros/gtest.m4	2010-01-27 08:44:27 +0000
@@ -2,29 +2,48 @@ dnl
 dnl Autoconf macros for detecting the Google C++ Testing Framework
 dnl
 
+dnl MY_PUSH_VAR(variable, value)
 AC_DEFUN([MY_PUSH_VAR],
 [
   my_save_$1="$[$1]" 
   [$1]="$[$1] [$2]" 
 ])
 
+dnl MY_POP_VAR(variable)
 AC_DEFUN([MY_POP_VAR],
 [
   [$1]="$[my_save_$1]" 
 ])
 
-dnl MYSQL_COMPILE_GTEST([action-if-found],[action-if-not-found])
+
+dnl MY_SET_GTEST_COMMAND(commandline-var, path-to-gtest-config)
+dnl On some platforms we need to override /bin/sh in gtest-config,
+dnl because it uses some posix features.
+AC_DEFUN([MY_SET_GTEST_COMMAND],
+[
+  case "$target_os" in
+    *solaris*)
+       $1="/bin/bash $2" ;;
+    *)
+       $1="$2" ;;
+  esac
+])
+
+
+dnl MYSQL_COMPILE_GTEST(gtest-config-command,
+dnl                     [action-if-found],[action-if-not-found])
 dnl
-dnl Given the absolute pathname to gtest-config, try to compile a gtest program.
+dnl Given a command to execute gtest-config, try to compile a gtest program.
 dnl Export variables which contain the compilation flags required by gtest.
-dnl The exported variables are: GTEST_CPPFLAGS, GTEST_CXXFLAGS, GTEST_LIBS.
+dnl The exported variables are: 
+dnl   GTEST_CPPFLAGS, GTEST_CXXFLAGS, GTEST_LDFLAGS, GTEST_LIBS.
 dnl
 AC_DEFUN([MYSQL_COMPILE_GTEST], [
   dnl Retrieve compilation flags
-  GTEST_CPPFLAGS=`${POSIX_SHELL} ${GTEST_CONFIG} --cppflags`
-  GTEST_CXXFLAGS=`${POSIX_SHELL} ${GTEST_CONFIG}  --cxxflags`
-  GTEST_LDFLAGS=`${POSIX_SHELL} ${GTEST_CONFIG}  --ldflags`
-  GTEST_LIBS=`${POSIX_SHELL} ${GTEST_CONFIG}  --libs`
+  GTEST_CPPFLAGS=`$1 --cppflags`
+  GTEST_CXXFLAGS=`$1  --cxxflags`
+  GTEST_LDFLAGS=`$1  --ldflags`
+  GTEST_LIBS=`$1  --libs`
 
   AC_SUBST(GTEST_CPPFLAGS)
   AC_SUBST(GTEST_CXXFLAGS)
@@ -39,8 +58,8 @@ AC_DEFUN([MYSQL_COMPILE_GTEST], [
   AC_LANG_PUSH([C++])
   AC_MSG_CHECKING([for ::testing::InitGoogleTest])
 
-dnl Would like to use AC_LINK_IFELSE here but dnl gtest-config --libs
-dnl returns name of libtools library rather than real library.
+dnl We would like to use AC_LINK_IFELSE here but 'gtest-config --libs'
+dnl returns name of libtools library rather than the real library.
   AC_COMPILE_IFELSE([
     AC_LANG_PROGRAM([[
       #include <gtest/gtest.h>
@@ -52,11 +71,11 @@ dnl returns name of libtools library rat
     ]])],
     [
       AC_MSG_RESULT([yes])
-      $1
+      $2
     ],
     [
       AC_MSG_RESULT([no])
-      $2
+      $3
     ])
 
   MY_POP_VAR([CPPFLAGS])
@@ -73,44 +92,49 @@ dnl Look for gtest-config and verify the
 dnl
 AC_DEFUN([MYSQL_CHECK_GTEST_CONFIG], [
   AC_ARG_WITH([gtest],
-  [AS_HELP_STRING([--with-gtest],
-                  [Enable unit tests using the Google C++ Testing Framework.])])
-  AC_MSG_CHECKING([whether to use the Google C++ Testing Framework])
-  if test "x${with_gtest}" != xno; then
-    AC_MSG_RESULT([yes])
+    [AS_HELP_STRING([--with-gtest[[=/path/to/gtest]]],
+                    [Enable unit tests using the Google C++ Testing Framework.])
+    ],
+    [],
+    [with_gtest=check]
+  )
 
-    dnl If a path is supplied, it must exist there.
-    if test "x${with_gtest}" != x && test "x${with_gtest}" != xyes; then
+  AC_MSG_CHECKING([whether to use the Google C++ Testing Framework])
+  if test "x${with_gtest}" = xno; then
+    AC_MSG_RESULT([no])
+  else
+    dnl If a path is supplied, it must exist.
+    if test "x$with_gtest" != xcheck; then
       GTEST_CONFIG_PATH="${with_gtest}/bin/:${with_gtest}/scripts"
     else
       GTEST_CONFIG_PATH=$PATH
     fi
 
+    AC_MSG_RESULT([yes])
+
     dnl Look for the absolute name of gtest-config.
     AC_PATH_PROG([GTEST_CONFIG], [gtest-config], [], [$GTEST_CONFIG_PATH])
-    dnl Consider using posix-shell.m4 to find a shell.
-    POSIX_SHELL="/bin/bash"
 
     if test "x$GTEST_CONFIG" = x; then
       dnl Fail if gtest was requested but gtest-config couldn't be found.
-      if test "x${with_gtest}" != x; then
-        AC_MSG_ERROR(
-          [Google Test was enabled, but gtest-config could not be found.])
+      if test "x$with_gtest" != xcheck; then
+        AC_MSG_ERROR([Could not find gtest-config in $GTEST_CONFIG_PATH])
+      else
+        AC_MSG_WARN([Could not find gtest-config in $PATH])
       fi
     else
+      MY_SET_GTEST_COMMAND(GTEST_CONFIG_CMD, $GTEST_CONFIG)
       AC_MSG_CHECKING([whether gtest-config is at least version $1])
-      if $POSIX_SHELL $GTEST_CONFIG --min-version=$1 >/dev/null 2>&1
-      then :
+      if $GTEST_CONFIG_CMD --min-version=$1 >/dev/null 2>&1
+      then
+        AC_MSG_RESULT([yes])
+        MYSQL_COMPILE_GTEST($GTEST_CONFIG_CMD, [have_gtest=yes], [have_gtest=no])
       else
         AC_MSG_RESULT([no])
         AC_MSG_ERROR(
           [The installed version of the Google Testing Framework is too old.])
       fi
-      AC_MSG_RESULT([yes])
-      MYSQL_COMPILE_GTEST([have_gtest=yes], [have_gtest=no])
     fi
-  else
-    AC_MSG_RESULT([no])
   fi
   AM_CONDITIONAL([HAVE_GTEST], [test "x$have_gtest" = "xyes"])
 ])


Attachment: [text/bzr-bundle] bzr/tor.didriksen@sun.com-20100127084427-inab1dwwi13b2brk.bundle
Thread
bzr commit into mysql-6.0-codebase-bugfixing branch (tor.didriksen:3651) Tor Didriksen27 Jan