changeset 289:4a7e214aa62a octave-forge

Make it work for old and new versions of autoconf (I hope)
author pkienzle
date Fri, 12 Apr 2002 20:21:43 +0000
parents cd358128ebe2
children ea47b51c9643
files main/geometry/configure.add
diffstat 1 files changed, 34 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/main/geometry/configure.add	Fri Apr 12 20:16:12 2002 +0000
+++ b/main/geometry/configure.add	Fri Apr 12 20:21:43 2002 +0000
@@ -1,53 +1,45 @@
 dnl The following check fails because qhull wants qh_version to be
 dnl defined by the user!?!
-dnl    AC_CHECK_LIB(qhull,qh_qhull,, HAVE_LIBQHULL=0)
+dnl    AC_CHECK_HEADERS(qhull/qhull_a.h)
+dnl    AC_CHECK_LIB(qhull,qh_qhull,HAVE_LIBQHULL)
 dnl Instead we use the following mess cribbed from acgeneral.m4:
 
 dnl
-dnl AC_CHECK_QHULL(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
-dnl              [, OTHER-LIBRARIES]]])
+dnl AC_CHECK_QHULL
 AC_DEFUN(AC_CHECK_QHULL,
-[AC_MSG_CHECKING([for $2 in -l$1])
-dnl Use a cache variable name containing both the library and function name,
-dnl because the test really is for library $1 defining function $2, not
-dnl just for library $1.  Separate tests with the same $1 and different $2s
-dnl may have different results.
-ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
-AC_CACHE_VAL(ac_cv_lib_$ac_lib_var,
-[ac_save_LIBS="$LIBS"
-LIBS="-l$1 $5 $LIBS"
-AC_TRY_LINK(dnl
-ifelse(AC_LANG, [FORTRAN77], ,
-ifelse([$2], [main], , dnl Avoid conflicting decl of main.
-[/* Override any gcc2 internal prototype to avoid an error.  */
-]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C"
-#endif
+[AC_MSG_CHECKING([for qh_qhull in -lqhull])
+AC_CACHE_VAL(ac_cv_lib_qhull_qh_qhull,
+[changequote(, )dnl
+cat > conftest.c <<EOF
+#include <stdio.h>
+#include <qhull/qhull.h>
+char qh_version[] = "version";
+int 
+main(argc, argv)
+  int argc;
+  char *argv[];
+{
+  qh_qhull();
+  return 0;
+}
+EOF
+changequote([, ])dnl
+ac_try="${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.c -o conftest -lqhull $LIBS"
+if AC_TRY_EVAL(ac_try) && test -s conftest ; then
+    ac_cv_lib_qhull_qh_qhull=yes
+else
+    ac_cv_lib_qhull_qh_qhull=no
+fi
 ])dnl
-[/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char qh_version;
-char $2();
-])),
-            [$2()],
-            eval "ac_cv_lib_$ac_lib_var=yes",
-            eval "ac_cv_lib_$ac_lib_var=no")
-LIBS="$ac_save_LIBS"
-])dnl
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+if test "$ac_cv_lib_qhull_qh_qhull" = "yes"; then
   AC_MSG_RESULT(yes)
-  ifelse([$3], ,
-[changequote(, )dnl
-  ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
-changequote([, ])dnl
-  AC_DEFINE_UNQUOTED($ac_tr_lib)
-  LIBS="-l$1 $LIBS"
-], [$3])
+  ifelse([$1], ,[
+  AC_DEFINE(HAVE_LIBQHULL)
+  LIBS="-lqhull $LIBS"
+], [$1])
 else
   AC_MSG_RESULT(no)
-ifelse([$4], , , [$4
-])dnl
+  ifelse([$2], , , [$2])
 fi
 ])
 
@@ -59,11 +51,8 @@
 else
 	dnl Do we have libqhull?
 	AC_SUBST(DEFHAVE_LIBQHULL)
-	HAVE_LIBQHULL=1
-	AC_CHECK_HEADERS(qhull/qhull_a.h,, HAVE_LIBQHULL=0)
-	AC_CHECK_QHULL(qhull,qh_qhull,, HAVE_LIBQHULL=0)
-
-	if test $HAVE_LIBQHULL = 1 ; then
+	AC_CHECK_QHULL(HAVE_LIBQHULL=1)
+	if test "$HAVE_LIBQHULL" = "1" ; then
 		DEFHAVE_LIBQHULL="HAVE_LIBQHULL=1"
 		STATUS=yes
 	else