[Saga-devel] saga SVN commit 3285: /trunk/adaptors/default/

amerzky at cct.lsu.edu amerzky at cct.lsu.edu
Thu Jan 15 03:45:51 CST 2009


User: amerzky
Date: 2009/01/15 03:45 AM

Modified:
 /trunk/adaptors/default/
  configure, configure.in
 /trunk/adaptors/default/config/
  saga_postgresql.m4

Log:
 fix postgres detection.
 Thanks Kate :-)

File Changes:

Directory: /trunk/adaptors/default/config/
==========================================

File [modified]: saga_postgresql.m4
Delta lines: +30 -17
===================================================================
--- trunk/adaptors/default/config/saga_postgresql.m4	2009-01-15 08:47:26 UTC (rev 3284)
+++ trunk/adaptors/default/config/saga_postgresql.m4	2009-01-15 09:45:37 UTC (rev 3285)
@@ -115,24 +115,37 @@
         POSTGRESQL_LOCATION=$tmp_path
 
         AC_MSG_CHECKING(for postgresql version)
-        # check for version > 8.x
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <pg_config.h>]],
-                                           [[#if PG_VERSION_NUM < 80000
-                                             # error "using postgres version 7.x
-                                             #endif]])],
-                                           old_postgres="no",
-                                           old_postgres="yes")
+        AC_LANG_PUSH(C++)
+        AC_RUN_IFELSE(
+            [AC_LANG_PROGRAM([[#include <pg_config.h>
+                               #include <fstream>]], 
+                             [[std::fstream out;
+                               out.open ("conftest.out", std::fstream::out);
+                               out << PG_VERSION << std::endl;
+                               out.close ();
+                               return 0; ]])],
+            [POSTGRESQL_VERSION=`cat conftest.out`],
+            [POSTGRESQL_VERSION=""])
+        AC_LANG_POP
 
-        if test "x$old_postgres" = "xyes"; then
-          HAVE_POSTGRESQL=no
-          AC_MSG_RESULT([older than 8.0])
-          AC_DEFINE(SOCI_PGSQL_NOPARAMS,  1)
-          AC_DEFINE(SOCI_PGSQL_NOPREPARE, 1)
-          AGE_POSTGRESQL="(older than 8.0)"
+        if test "$POSTGRESQL_VERSION" = ""; then
+          AC_MSG_RESULT([unknown])
         else
-          HAVE_POSTGRESQL=yes
-          AC_MSG_RESULT([newer than 8.0])
-          AGE_POSTGRESQL="(newer than 8.0)"
+          # check for version > 8.x
+          PQ_VERSION_MAJ=`echo $POSTGRESQL_VERSION | cut -f 1 -d .`
+          PQ_VERSION_MIN=`echo $POSTGRESQL_VERSION | cut -f 2 -d .`
+          PQ_VERSION_SUB=`echo $POSTGRESQL_VERSION | cut -f 3 -d .`
+
+          if test "$PQ_VERSION_MAJ" -lt "8"; then
+            HAVE_POSTGRESQL=no
+            POSTGRESQL_VERSION="$POSTGRESQL_VERSION - too old"
+            AC_MSG_RESULT([$POSTGRESQL_VERSION - older than 8.0])
+            AC_DEFINE(SOCI_PGSQL_NOPARAMS,  1)
+            AC_DEFINE(SOCI_PGSQL_NOPREPARE, 1)
+          else
+            HAVE_POSTGRESQL=yes
+            AC_MSG_RESULT([$POSTGRESQL_VERSION - newer than 8.0])
+          fi
         fi
 
         AC_MSG_CHECKING(for static lib postgresql)
@@ -145,7 +158,7 @@
 
         export HAVE_POSTGRESQL
         AC_SUBST(HAVE_POSTGRESQL)
-        AC_SUBST(AGE_POSTGRESQL)
+        AC_SUBST(POSTGRESQL_VERSION)
         AC_SUBST(POSTGRESQL_LOCATION)
         AC_SUBST(POSTGRESQL_CPPFLAGS)
         AC_SUBST(POSTGRESQL_LDFLAGS)

Directory: /trunk/adaptors/default/
===================================

File [modified]: configure
Delta lines: +76 -34
===================================================================
--- trunk/adaptors/default/configure	2009-01-15 08:47:26 UTC (rev 3284)
+++ trunk/adaptors/default/configure	2009-01-15 09:45:37 UTC (rev 3285)
@@ -635,7 +635,7 @@
 HAVE_SQLITE3_DTOR_TYPE
 POSTGRESQL_LOCATION
 HAVE_POSTGRESQL
-AGE_POSTGRESQL
+POSTGRESQL_VERSION
 POSTGRESQL_CPPFLAGS
 POSTGRESQL_LDFLAGS
 POSTGRESQL_S_LIBS
@@ -2902,69 +2902,106 @@
 
         { echo "$as_me:$LINENO: checking for postgresql version" >&5
 echo $ECHO_N "checking for postgresql version... $ECHO_C" >&6; }
-        # check for version > 8.x
-        cat >conftest.$ac_ext <<_ACEOF
+        ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+        if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <pg_config.h>
+                               #include <fstream>
 int
 main ()
 {
-#if PG_VERSION_NUM < 80000
-                                             # error "using postgres version 7.x
-                                             #endif
+std::fstream out;
+                               out.open ("conftest.out", std::fstream::out);
+                               out << PG_VERSION << std::endl;
+                               out.close ();
+                               return 0;
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_cxx_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  old_postgres="no"
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  POSTGRESQL_VERSION=`cat conftest.out`
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	old_postgres="yes"
+( exit $ac_status )
+POSTGRESQL_VERSION=""
 fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-        if test "x$old_postgres" = "xyes"; then
-          HAVE_POSTGRESQL=no
-          { echo "$as_me:$LINENO: result: older than 8.0" >&5
-echo "${ECHO_T}older than 8.0" >&6; }
-          cat >>confdefs.h <<\_ACEOF
+        ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+        if test "$POSTGRESQL_VERSION" = ""; then
+          { echo "$as_me:$LINENO: result: unknown" >&5
+echo "${ECHO_T}unknown" >&6; }
+        else
+          # check for version > 8.x
+          PQ_VERSION_MAJ=`echo $POSTGRESQL_VERSION | cut -f 1 -d .`
+          PQ_VERSION_MIN=`echo $POSTGRESQL_VERSION | cut -f 2 -d .`
+          PQ_VERSION_SUB=`echo $POSTGRESQL_VERSION | cut -f 3 -d .`
+
+          if test "$PQ_VERSION_MAJ" -lt "8"; then
+            HAVE_POSTGRESQL=no
+            POSTGRESQL_VERSION="$POSTGRESQL_VERSION - too old"
+            { echo "$as_me:$LINENO: result: $POSTGRESQL_VERSION - older than 8.0" >&5
+echo "${ECHO_T}$POSTGRESQL_VERSION - older than 8.0" >&6; }
+            cat >>confdefs.h <<\_ACEOF
 #define SOCI_PGSQL_NOPARAMS 1
 _ACEOF
 
-          cat >>confdefs.h <<\_ACEOF
+            cat >>confdefs.h <<\_ACEOF
 #define SOCI_PGSQL_NOPREPARE 1
 _ACEOF
 
-          AGE_POSTGRESQL="(older than 8.0)"
-        else
-          HAVE_POSTGRESQL=yes
-          { echo "$as_me:$LINENO: result: newer than 8.0" >&5
-echo "${ECHO_T}newer than 8.0" >&6; }
-          AGE_POSTGRESQL="(newer than 8.0)"
+          else
+            HAVE_POSTGRESQL=yes
+            { echo "$as_me:$LINENO: result: $POSTGRESQL_VERSION - newer than 8.0" >&5
+echo "${ECHO_T}$POSTGRESQL_VERSION - newer than 8.0" >&6; }
+          fi
         fi
 
         { echo "$as_me:$LINENO: checking for static lib postgresql" >&5
@@ -3583,7 +3620,12 @@
   fi
 fi
 
+if test "x$POSTGRESQL_VERSION" != "x"; then
+  POSTGRESQL_VERSION_S="($POSTGRESQL_VERSION)"
+fi
 
+
+
 # create output files
 ac_config_files="$ac_config_files advert/default_advert_adaptor.ini"
 
@@ -4276,7 +4318,7 @@
 HAVE_SQLITE3_DTOR_TYPE!$HAVE_SQLITE3_DTOR_TYPE$ac_delim
 POSTGRESQL_LOCATION!$POSTGRESQL_LOCATION$ac_delim
 HAVE_POSTGRESQL!$HAVE_POSTGRESQL$ac_delim
-AGE_POSTGRESQL!$AGE_POSTGRESQL$ac_delim
+POSTGRESQL_VERSION!$POSTGRESQL_VERSION$ac_delim
 POSTGRESQL_CPPFLAGS!$POSTGRESQL_CPPFLAGS$ac_delim
 POSTGRESQL_LDFLAGS!$POSTGRESQL_LDFLAGS$ac_delim
 POSTGRESQL_S_LIBS!$POSTGRESQL_S_LIBS$ac_delim
@@ -4799,7 +4841,7 @@
 echo "                                                                 " | $TEE $OUT
 echo " Using SAGA from       : $TMP_SAGA_LOCATION ($TMP_SAGA_INSTTYPE) " | $TEE $OUT
 echo "                                                                 " | $TEE $OUT
-echo " PostgreSQL Found      : $HAVE_POSTGRESQL $AGE_POSTGRESQL        " | $TEE $OUT
+echo " PostgreSQL Found      : $HAVE_POSTGRESQL $POSTGRESQL_VERSION_S  " | $TEE $OUT
 echo " PostgreSQL Location   : $POSTGRESQL_LOCATION                    " | $TEE $OUT
 echo "                                                                 " | $TEE $OUT
 echo " SQLite3 (>3.3) Found  : $HAVE_SQLITE3                           " | $TEE $OUT

File [modified]: configure.in
Delta lines: +6 -1
===================================================================
--- trunk/adaptors/default/configure.in	2009-01-15 08:47:26 UTC (rev 3284)
+++ trunk/adaptors/default/configure.in	2009-01-15 09:45:37 UTC (rev 3285)
@@ -159,7 +159,12 @@
   fi
 fi
 
+if test "x$POSTGRESQL_VERSION" != "x"; then
+  POSTGRESQL_VERSION_S="($POSTGRESQL_VERSION)"
+fi
 
+
+
 # create output files
 AC_CONFIG_FILES([advert/default_advert_adaptor.ini])
 AC_CONFIG_FILES([replica/default_replica_adaptor.ini])
@@ -179,7 +184,7 @@
 echo "                                                                 " | $TEE $OUT
 echo " Using SAGA from       : $TMP_SAGA_LOCATION ($TMP_SAGA_INSTTYPE) " | $TEE $OUT
 echo "                                                                 " | $TEE $OUT
-echo " PostgreSQL Found      : $HAVE_POSTGRESQL $AGE_POSTGRESQL        " | $TEE $OUT
+echo " PostgreSQL Found      : $HAVE_POSTGRESQL $POSTGRESQL_VERSION_S  " | $TEE $OUT
 echo " PostgreSQL Location   : $POSTGRESQL_LOCATION                    " | $TEE $OUT
 echo "                                                                 " | $TEE $OUT
 echo " SQLite3 (>3.3) Found  : $HAVE_SQLITE3                           " | $TEE $OUT



More information about the saga-devel mailing list