[project @ 2003-07-24 15:12:35 by simonmar]
[ghc-hetmet.git] / aclocal.m4
index 647c077..d67dc28 100644 (file)
@@ -1,4 +1,4 @@
-dnl $Id: aclocal.m4,v 1.111 2003/01/08 12:03:28 simonmar Exp $
+dnl $Id: aclocal.m4,v 1.120 2003/07/20 16:33:24 panne Exp $
 dnl 
 dnl Extra autoconf macros for the Glasgow fptools
 dnl
@@ -188,6 +188,28 @@ fi
 
 
 dnl
+dnl Check for Greencard and version.
+dnl
+AC_DEFUN(FPTOOLS_GREENCARD,
+[
+AC_PATH_PROG(GreencardCmd,greencard)
+AC_CACHE_CHECK([for version of greencard], fptools_cv_greencard_version,
+changequote(, )dnl
+[if test x"$GreencardCmd" != x; then
+   fptools_cv_greencard_version="`$GreencardCmd --version |
+                         grep 'version' | sed -e 's/greencard. version \([^ ]*\).*/\1/g'`"
+else
+   fptools_cv_greencard_version=""
+fi
+changequote([, ])dnl
+])
+FPTOOLS_PROG_CHECK_VERSION([$fptools_cv_greencard_version],-lt,$1,
+  [AC_MSG_ERROR([greencard version $1 or later is required (found '$fptools_cv_greencard_version')])])dnl
+GreencardVersion=$fptools_cv_greencard_version
+AC_SUBST(GreencardVersion)
+])
+
+dnl
 dnl Check for Happy and version.  If we're building GHC, then we need
 dnl at least Happy version 1.13.  If there's no installed Happy, we look
 dnl for a happy source tree and point the build system at that instead.
@@ -337,7 +359,13 @@ if test -z "$ArCmdRaw"; then
     echo "You don't seem to have ar in your PATH...I have no idea how to make a library"
     exit 1;
 fi
-if $ArCmdRaw clqsZ conftest.a >/dev/null 2>/dev/null; then
+dnl GNU ar needs special treatment: it appears to have problems with
+dnl object files with the same name if you use the 's' modifier, but
+dnl simple 'ar q' works fine, and doesn't need a separate ranlib.
+if $ArCmdRaw --version | grep 'GNU' >/dev/null 2>/dev/null; then
+    ArCmdArgs='q'
+    NeedRanLib=''
+elif $ArCmdRaw clqsZ conftest.a >/dev/null 2>/dev/null; then
     ArCmdArgs="clqsZ"
     NeedRanLib=''
 elif $ArCmdRaw clqs conftest.a >/dev/null 2>/dev/null; then
@@ -663,6 +691,10 @@ AC_CACHE_VAL(AC_CV_NAME,
 # include <GL/gl.h>
 #endif
 
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
 typedef $1 testing;
 
 main() {
@@ -763,11 +795,11 @@ AC_CACHE_VAL(fptools_cv_have_o_binary,
 [
 AC_LANG_SAVE
 AC_LANG_C
-AC_TRY_COMPILE(,
+AC_TRY_COMPILE(
 [#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
-#endif
-int x = O_BINARY;],
+#endif],
+[int x = O_BINARY;],
 fptools_cv_have_o_binary=yes,
 fptools_cv_have_o_binary=no)
 AC_LANG_RESTORE
@@ -1004,9 +1036,7 @@ esac
 ])
 
 dnl ######################################################################
-dnl NOTE: Because of portability issues between different autoconf
-dnl versions the AC_HELP_STRING macro has been removed from FPTOOLS_HAVE_OPENGL.
-dnl Furthermore, caching has been completely rewritten.
+dnl Note: Caching has been completely rewritten, but is still no perfect yet.
 dnl ######################################################################
 
 dnl ########################### -*- Mode: M4 -*- #######################
@@ -1034,8 +1064,8 @@ dnl ####################################################################
 dnl @synopsis FPTOOLS_HAVE_OPENGL
 dnl 
 dnl Search for OpenGL.  We search first for Mesa (a GPL'ed version of
-dnl OpenGL) before a vendor's version of OpenGL, unless we were
-dnl specifically asked not to with `--with-Mesa=no' or `--without-Mesa'.
+dnl OpenGL) before a vendor's version of OpenGL if we were specifically
+dnl asked to with `--with-Mesa=yes' or `--with-Mesa'.
 dnl
 dnl The four "standard" OpenGL libraries are searched for: "-lGL",
 dnl "-lGLU", "-lGLX" (or "-lMesaGL", "-lMesaGLU" as the case may be) and
@@ -1079,12 +1109,13 @@ AC_DEFUN(FPTOOLS_HAVE_OPENGL,
   AC_REQUIRE([AC_PATH_XTRA])
   AC_REQUIRE([FPTOOLS_CHECK_LIBM])
 
-dnl Check for Mesa first, unless we were asked not to.
-dnl    AC_HELP_STRING([--with-Mesa],
-dnl                   [Prefer the Mesa library over a vendors native OpenGL library (default=yes)],
-dnl                   with_Mesa_help_string)
-dnl    AC_ARG_ENABLE(Mesa, $with_Mesa_help_string, use_Mesa=$enableval, use_Mesa=yes)
-  AC_ARG_ENABLE(Mesa, [  --with-Mesa             Prefer the Mesa library over a vendors native OpenGL library (default=no)], use_Mesa=$enableval, use_Mesa=no)
+dnl Check for Mesa first if we were asked to.
+  AC_ARG_ENABLE(Mesa,
+[  --enable-mesa
+       Prefer Mesa over a vendor's native OpenGL library (default=no)
+],
+                use_Mesa=$enableval,
+                use_Mesa=no)
 
   if test x"$use_Mesa" = xyes; then
      GL_search_list="MesaGL  GL  opengl32"
@@ -1102,9 +1133,10 @@ dnl    AC_ARG_ENABLE(Mesa, $with_Mesa_help_string, use_Mesa=$enableval, use_Mesa
 dnl If we are running under X11 then add in the appropriate libraries.
   if test x"$no_x" != xyes; then
 dnl Add everything we need to compile and link X programs to GL_CFLAGS
-dnl and GL_X_LIBS.
-    GL_CFLAGS="$X_CFLAGS"
-    GL_X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext -lXmu -lXt -lXi $X_EXTRA_LIBS $LIBM"
+dnl and GL_X_LIBS/GLUT_X_LIBS.
+    GL_CFLAGS="$CPPFLAGS $X_CFLAGS"
+    GL_X_LIBS="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBM"
+    GLUT_X_LIBS="$X_LIBS $X_PRE_LIBS -lXmu -lXt -lXi -lXext -lX11 $X_EXTRA_LIBS $LIBM"
   fi
   GL_save_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="$GL_CFLAGS"
@@ -1115,25 +1147,36 @@ dnl and GL_X_LIBS.
   FPTOOLS_SEARCH_LIBS([#include <GL/gl.h>],   glEnd,         $GL_search_list,  have_GL=yes,   have_GL=no)
   FPTOOLS_SEARCH_LIBS([#include <GL/glu.h>],  gluNewQuadric, $GLU_search_list, have_GLU=yes,  have_GLU=no)
   FPTOOLS_SEARCH_LIBS([#include <GL/glx.h>],  glXWaitX,      $GLX_search_list, have_GLX=yes,  have_GLX=no)
-  FPTOOLS_SEARCH_LIBS([#include <GL/glut.h>], glutMainLoop,  glut glut32,      have_glut=yes, have_glut=no)
 
   if test -n "$LIBS"; then
-    GL_LIBS="$LIBS"
+    GL_LIBS="$LDFLAGS $LIBS"
   else
-    GL_LIBS=
+    GL_LIBS="$LDFLAGS"
     GL_CFLAGS=
   fi
 
+  LIBS="$GLUT_X_LIBS"
+
+  FPTOOLS_SEARCH_LIBS([#include <GL/glut.h>], glutMainLoop,  glut32 glut,      have_glut=yes, have_glut=no)
+
+  if test -n "$LIBS"; then
+    GLUT_LIBS="$LDFLAGS $LIBS"
+  fi
+
   AC_CACHE_CHECK([OpenGL flags], mdl_cv_gl_cflags, [mdl_cv_gl_cflags="$GL_CFLAGS"])
   GL_CFLAGS="$mdl_cv_gl_cflags"
   AC_SUBST(GL_CFLAGS)
   AC_CACHE_CHECK([OpenGL libs],  mdl_cv_gl_libs,   [mdl_cv_gl_libs="$GL_LIBS"])
   GL_LIBS="$mdl_cv_gl_libs"
   AC_SUBST(GL_LIBS)
+  AC_CACHE_CHECK([GLUT libs],  mdl_cv_glut_libs,   [mdl_cv_glut_libs="$GLUT_LIBS"])
+  GLUT_LIBS="$mdl_cv_glut_libs"
+  AC_SUBST(GLUT_LIBS)
 
-dnl Reset GL_X_LIBS regardless, since it was just a temporary variable
+dnl Reset GL_X_LIBS/GLUT_X_LIBS regardless, since they were just temporary variables
 dnl and we don't want to be global namespace polluters.
   GL_X_LIBS=
+  GLUT_X_LIBS=
 
   LIBS="$GL_save_LIBS"
   CPPFLAGS="$GL_save_CPPFLAGS"
@@ -1159,7 +1202,7 @@ fi
 
 dnl
 dnl Check to see whether CC (gcc) supports a particular option.
-dnl 
+dnl
 AC_DEFUN(FPTOOLS_CC_FLAG,
 [
 AC_CACHE_CHECK([whether $CC accepts $1], [ac_cv_cc_$2],