[project @ 2004-01-06 18:39:12 by panne]
[ghc-hetmet.git] / aclocal.m4
index 5e5d4c9..526bc04 100644 (file)
@@ -758,6 +758,25 @@ undefine([AC_CV_NAME])dnl
 undefine([AC_CV_NAME_supported])dnl
 ])
 
+
+# FP_CHECK_FUNC(FUNCTION, PROLOGUE, BODY, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------------------------------
+# A variant of AC_CHECK_FUNCS, limited to a single FUNCTION, but with the
+# additional flexibility of specifying the PROLOGUE and BODY.
+AC_DEFUN([FP_CHECK_FUNC],
+[AS_VAR_PUSHDEF([fp_func], [fp_cv_func_$1])dnl
+AC_CACHE_CHECK([for $1], fp_func,
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], [$3])],
+                [AS_VAR_SET(fp_func, yes)],
+                [AS_VAR_SET(fp_func, no)])])
+AS_IF([test AS_VAR_GET(fp_func) = yes],
+      [AC_DEFINE(AS_TR_CPP(HAVE_$1), [1],
+                [Define to 1 if you have the `]$1[' function.]) $4],
+      [$5])dnl
+AS_VAR_POPDEF([fp_func])dnl
+])# FP_CHECK_FUNC
+
+
 dnl Based on AC_TRY_LINK - run iftrue if links cleanly with no warning
 
 dnl FPTOOLS_TRY_LINK_NOWARN(flags,main?,iftrue,iffalse)
@@ -990,7 +1009,7 @@ else
   esac
 
   if test x"$use_quartz_opengl" != xyes; then
-    AC_CHECK_LIB([m], [main], [GL_LIBS="-lm $GL_LIBS"])
+    AC_CHECK_LIB([m], [atan], [GL_LIBS="-lm $GL_LIBS"])
 
     if test x"$no_x" != xyes; then
       test -n "$x_includes" && GL_CFLAGS="-I$x_includes $GL_CFLAGS"
@@ -999,16 +1018,19 @@ else
 
     FP_CHECK_GL_HELPER([GL], [-lGL -lopengl32], [@%:@include <GL/gl.h>], [glEnd()])
 
-    # Ugly: To get wglGetProcAddress on Windows, we have to link with
-    # opengl32.dll, too, even when we are using Cygwin with X11.
-    case "$GL_LIBS" in
-      *-lopengl32*|*opengl32.lib*) ;;
-      *) fp_save_LIBS="$LIBS"
-         LIBS="$LIBS -lopengl32"
-         AC_TRY_LINK([@%:@include <GL/gl.h>], [glEnd()], [GL_LIBS="$GL_LIBS -lopengl32"])
-         LIBS="$fp_save_LIBS"
-         ;;
-    esac
+    if test x"$no_GL" != xyes; then
+      # Ugly: To get wglGetProcAddress on Windows, we have to link with
+      # opengl32.dll, too, even when we are using Cygwin with X11.
+      case "$GL_LIBS" in
+        *-lopengl32*|*opengl32.lib*) ;;
+        *) fp_save_LIBS="$LIBS"
+           LIBS="$LIBS -lopengl32"
+           AC_TRY_LINK([@%:@include <GL/gl.h>], [glEnd()],
+             [GL_LIBS="$GL_LIBS -lopengl32"; GL_LIBS0="$GL_LIBS0 -lopengl32"])
+           LIBS="$fp_save_LIBS"
+           ;;
+      esac
+    fi
   fi
 fi