[cgma-dev] r3157 - in cgm/trunk: . m4

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Mon Sep 21 11:33:47 CDT 2009


Author: kraftche
Date: 2009-09-21 11:33:47 -0500 (Mon, 21 Sep 2009)
New Revision: 3157

Modified:
   cgm/trunk/configure.ac
   cgm/trunk/m4/acis.m4
Log:
Fix ACIS config tests:
  a) Make things work with libtool 2.x.x, for which we cannot use
     ./libtool during the configuration process
  b) Separate tests for linkability of ACIS libraries from check
     for ACIS version.  Thus if we for some reason cannot run an
     executable linked against ACIS (didn't get LD_LIBRARY_PATH
     equvialent set correctly, are cross-compiling, etc.), the
     linkability check is still done and the version check can
     be skipped by specifying --with-acis-version option.



Modified: cgm/trunk/configure.ac
===================================================================
--- cgm/trunk/configure.ac	2009-09-21 14:10:26 UTC (rev 3156)
+++ cgm/trunk/configure.ac	2009-09-21 16:33:47 UTC (rev 3157)
@@ -158,7 +158,7 @@
              AC_HELP_STRING([--with-ACIS],[DEPRECATED.  Use --wtih-acis (small case)]),
              [ACIS_DIR=$withval
               DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-acis=\"${withval}\""] )
-AC_ARG_WITH( ACIS-system, AC_HELP_STRING([--with-acis-system=SYS], 
+AC_ARG_WITH( acis-system, AC_HELP_STRING([--with-acis-system=SYS], 
           [Specify ACIS system name (e.g. linux_so), default is to autodetect.]),
              [ACIS_SYSTEM=$withval],[ACIS_SYSTEM=] )
 AC_ARG_WITH( acis-version, AC_HELP_STRING([--with-acis-version=INT],
@@ -167,7 +167,7 @@
   AC_MSG_ERROR("ACIS-version must be an integer greater than 600.")
  fi
  ACIS_VERSION=$withval],
-[ACIS_VERSION=0])
+[ACIS_VERSION=])
 if test "x$ACIS_DIR" == "x"; then 
   ACIS_DIR=no
 fi          

Modified: cgm/trunk/m4/acis.m4
===================================================================
--- cgm/trunk/m4/acis.m4	2009-09-21 14:10:26 UTC (rev 3156)
+++ cgm/trunk/m4/acis.m4	2009-09-21 16:33:47 UTC (rev 3157)
@@ -21,31 +21,43 @@
   dir_list="$ACIS_DIR/bin/$ACIS_SYSTEM"
 fi
 
+AC_MSG_CHECKING([for ACIS library directory])
+snl_acis_link_success=no
 for dir in $dir_list; do
+  if test "x$snl_acis_link_success" = "xyes"; then
+    break
+  fi
     # first try non-debug libraries
   case "$dir" in
     *_debug)
       ;;
     *)
-      if ! test "$ACIS_VERSION" -gt "600"; then
-        SNL_ACIS_VERSION( [$dir] )
-        ACIS_LIB_DIR="$dir"
-      fi
+      SNL_ACIS_LIBDIR( [$dir] )
       ;;
   esac
     # next try debug libraries
   case "$dir" in
     *_debug)
-      if ! test "$ACIS_VERSION" -gt "600"; then
-        SNL_ACIS_VERSION( [$dir] )
-        ACIS_DEBUG_LIB_DIR="$dir"
-      fi
+      SNL_ACIS_LIBDIR( [$dir] )
       ;;
   esac
 done
 
-if ! test "$ACIS_VERSION" -gt "600"; then
-  AC_MSG_ERROR([ACIS configuration failed.  Verify ACIS directory.  Try specifying ACIS system and version])
+if test "xyes" != "x$snl_acis_link_success"; then
+  AC_MSG_ERROR([failed.])
+else 
+  ACIS_LIB_DIR="$dir"
+  AC_MSG_RESULT([$ACIS_LIB_DIR])
+  
+  AC_MSG_CHECKING([ACIS version])
+  AC_MSG_RESULT([$ACIS_VERSION])
+  if test "x0" = "x$ACIS_VERSION"; then
+    AC_MSG_ERROR([Failed to detect ACIS version.  Try --with-acis-version."])
+  else 
+    if test "0$ACIS_VERSION" -lt "0600"; then
+      AC_MSG_ERROR([Invalid ACIS version.])
+    fi
+  fi
 fi
 
 # If either ACIS_LIB_DIR or ACIS_DEBUG_LIB_DIR is not defined,
@@ -125,37 +137,55 @@
 #######################################################################################
 # Macro to get ACIS_VERSION
 # Expected arguments: ACIS library path
+# Sets variables:
+#  snl_acis_link_success=yes/no
+#  ACIS_VERSION=version/0
+#  If ACIS_VERSION is alreay set, it will NOT be modified by
+#  this function.
 #######################################################################################
-AC_DEFUN([SNL_ACIS_VERSION], [
+AC_DEFUN([SNL_ACIS_LIBDIR], [
 AC_REQUIRE([AC_PROG_LIBTOOL])
-AC_LANG_SAVE
-AC_LANG_CPLUSPLUS
-AC_MSG_CHECKING([ACIS version of $1])
-src=conftest.cc
-exe=conftest
-
-cat <<END_SNL_ACIS_VERSION_SRC  >$src
+AC_LANG_PUSH([C++])
+snl_acis_libdir=$1
+snl_acis_link_success=no
+old_LDFLAGS="$LDFLAGS"
+old_LIBS="$LIBS"
+LDFLAGS="-L$1"
+LIBS="-lSpaBase"
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[
 #include <stdio.h>
 int get_major_version();
 int get_minor_version();
 int get_point_version();
-int main(int,char**) { printf("%d\n", 
+]],[[
+printf("%d\n", 
 100*get_major_version() +
  10*get_minor_version() +
-    get_point_version()); 
-return 0;}
-
-END_SNL_ACIS_VERSION_SRC
-
-FLAGS="$CXXFLAGS $LDFLAGS -L$1 -R$1"
-if ./libtool --mode=link $CXX $FLAGS $src -lSpaBase -o $exe >/dev/null 2>/dev/null; then
-  ACIS_VERSION=`./$exe || echo 0`
-  AC_MSG_RESULT($ACIS_VERSION)
-else
-  ACIS_VERSION=0
-  AC_MSG_RESULT(failed)
-fi
-
-#rm -f $src $exe
-AC_LANG_RESTORE
-]) # SNL_ACIS_VERSION
+    get_point_version());  
+]])],
+[snl_acis_link_success=yes
+ if test "x" = "x$ACIS_VERSION"; then
+   echo "************************"
+   echo "ACIS_VERSION=$ACIS_VERSION"
+   echo "************************"
+   old_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
+   old_SHLIB_PATH="$SH_LIBPATH"
+   old_PATH="$PATH"  # windows!
+   LD_LIBRARY_PATH="${snl_acis_libdir}:$LD_LIBRARY_PATH"
+   SHLIB_PATH="${snl_acis_libdir}:$SHLIB_PATH"
+   PATH="${snl_acis_libdir}:$PATH"
+   export LD_LIBRARY_PATH
+   export SHLIB_PATH
+   export PATH
+   ACIS_VERSION=`./conftest` || ACIS_VERSION=0
+   LD_LIBRARY_PATH="$old_LD_LIBRARY_PATH"
+   SHLIB_PATH="$old_SHLIB_PATH"
+   PATH="$old_PATH"
+   export LD_LIBRARY_PATH
+   export SHLIB_PATH
+   export PATH
+ fi
+], [snl_acis_link_success=no])
+AC_LANG_POP
+]) # SNL_ACIS_LIBDIR



More information about the cgma-dev mailing list