[project @ 2003-08-18 13:15:53 by panne]
[ghc-hetmet.git] / aclocal.m4
index 3019dee..4f3259c 100644 (file)
@@ -1,61 +1,17 @@
-dnl $Id: aclocal.m4,v 1.113 2003/01/27 16:41:18 simonmar Exp $
-dnl 
-dnl Extra autoconf macros for the Glasgow fptools
-dnl
-dnl To be a good autoconf citizen, names of local macros have
-dnl prefixed with FPTOOLS_ to ensure we don't clash
-dnl with any pre-supplied autoconf ones.
-
-dnl
-dnl Is timezone around? (in a header file)
-dnl 
-AC_DEFUN(FPTOOLS_HAVE_TIMEZONE,
-[AC_CACHE_CHECK([timezone], fptools_cv_have_timezone,
-[AC_TRY_COMPILE([#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-], [return timezone;], 
-fptools_cv_have_timezone=yes, fptools_cv_have_timezone=no)])
-if test "$fptools_cv_have_timezone" = yes; then
-  AC_DEFINE(HAVE_TIMEZONE)
-fi
-])
-
-dnl
-dnl Has timezone the type time_t or long (HP-UX 10.20 apparently
-dnl has `long'..)
-dnl 
-AC_DEFUN(FPTOOLS_TYPE_TIMEZONE,
-[AC_CACHE_CHECK([type of timezone], fptools_cv_type_timezone,
-[AC_TRY_COMPILE([#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-extern time_t timezone;        
-],
-[int i;], fptools_cv_type_timezone=time_t, fptools_cv_type_timezone=long)])
-AC_DEFINE_UNQUOTED(TYPE_TIMEZONE, $fptools_cv_type_timezone)
-])
-
-dnl *** Is altzone available? ***
-dnl 
-AC_DEFUN(FPTOOLS_ALTZONE,
-[AC_CACHE_CHECK([altzone], fptools_cv_altzone,
-[AC_TRY_LINK([#if TIME_WITH_SYS_TIME
+# Extra autoconf macros for the Glasgow fptools
+#
+# To be a good autoconf citizen, names of local macros have prefixed with FP_ to
+# ensure we don't clash with any pre-supplied autoconf ones.
+
+
+# FP_ALTZONE
+# -------------------
+# Defines HAVE_DECL_ALTZONE to 1 if declared, 0 otherwise.
+# Used by base package.
+AC_DEFUN([FP_ALTZONE],
+[AC_REQUIRE([AC_HEADER_TIME])dnl
+AC_CHECK_HEADERS([sys/time.h])
+AC_CHECK_DECLS([altzone], [], [],[#if TIME_WITH_SYS_TIME
 # include <sys/time.h>
 # include <time.h>
 #else
 # include <sys/time.h>
 # include <time.h>
 #else
@@ -64,34 +20,8 @@ AC_DEFUN(FPTOOLS_ALTZONE,
 # else
 #  include <time.h>
 # endif
 # else
 #  include <time.h>
 # endif
-#endif
-], [return altzone;], 
-fptools_cv_altzone=yes, fptools_cv_altzone=no)])
-if test "$fptools_cv_altzone" = yes; then
-  AC_DEFINE(HAVE_ALTZONE)
-fi
-])
-
-
-dnl *** Does libc contain GNU regex? ***
-dnl 
-AC_DEFUN(FPTOOLS_REGEX_IN_LIBC,
-[AC_CACHE_CHECK([for GNU regex in libc], fptools_cv_have_regex,
-[AC_TRY_LINK([#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <regex.h>
-],[ struct re_pattern_buffer patbuf; 
-    re_compile_pattern("",0,&patbuf);
-    re_search_2 (&patbuf, "", 0, "",0, 0,0,0,0); ],
-fptools_cv_have_regex=yes, fptools_cv_have_regex=no)])
-if test "$fptools_cv_have_regex" = yes; then
-       HaveGNURegex=YES
-else
-       HaveGNURegex=NO
-fi
-AC_SUBST(HaveGNURegex)
-])
+#endif])
+])# FP_ALTZONE
 
 
 dnl ** check for leading underscores in symbol names
 
 
 dnl ** check for leading underscores in symbol names
@@ -106,6 +36,8 @@ dnl a leading underscore sometimes (eg. FreeBSD).  We therefore have
 dnl to work around this by checking for *no* leading underscore first.
 dnl Sigh.  --SDM
 dnl
 dnl to work around this by checking for *no* leading underscore first.
 dnl Sigh.  --SDM
 dnl
+dnl Similarly on OpenBSD, but this test doesn't help. -- dons
+dnl
 AC_DEFUN(FPTOOLS_UNDERSCORE,
 [AC_CHECK_LIB(elf, nlist, LIBS="-lelf $LIBS")dnl
 AC_CACHE_CHECK([leading underscore in symbol names], fptools_cv_lead_uscore,
 AC_DEFUN(FPTOOLS_UNDERSCORE,
 [AC_CHECK_LIB(elf, nlist, LIBS="-lelf $LIBS")dnl
 AC_CACHE_CHECK([leading underscore in symbol names], fptools_cv_lead_uscore,
@@ -119,6 +51,11 @@ dnl the underscoredness of that "platform"
 changequote(<<, >>)dnl
 <<
 case $HostPlatform in
 changequote(<<, >>)dnl
 <<
 case $HostPlatform in
+*openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore
+    case $build in
+        i386-*2\.[[0-9]] | i386-*3\.[[0-3]] ) fptools_cv_lead_uscore='yes' ;;
+        *)      fptools_cv_lead_uscore='no' ;;
+    esac ;;
 alpha-dec-osf*) fptools_cv_lead_uscore='no';;
 *cygwin32) fptools_cv_lead_uscore='yes';;
 *mingw32) fptools_cv_lead_uscore='yes';;
 alpha-dec-osf*) fptools_cv_lead_uscore='no';;
 *cygwin32) fptools_cv_lead_uscore='yes';;
 *mingw32) fptools_cv_lead_uscore='yes';;
@@ -188,6 +125,28 @@ fi
 
 
 dnl
 
 
 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.
 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.
@@ -243,6 +202,41 @@ dnl do without it for now.
 ])
 
 dnl
 ])
 
 dnl
+dnl Check for Alex and version.  If we're building GHC, then we need
+dnl at least Alex version 2.0.  If there's no installed Alex, we look
+dnl for a alex source tree and point the build system at that instead.
+dnl
+AC_DEFUN(FPTOOLS_ALEX,
+[
+if test -d $srcdir/alex; then
+   SrcTreeAlexCmd=$hardtop/alex/src/alex-inplace
+fi
+if test x"$UseSrcTreeAlex" = xYES; then
+  AlexCmd=$SrcTreeAlexCmd
+else
+  AC_PATH_PROG(AlexCmd,alex,$SrcTreeAlexCmd)
+fi
+AC_CACHE_CHECK([for version of alex], fptools_cv_alex_version,
+changequote(, )dnl
+[if test x"$AlexCmd" = x"$SrcTreeAlexCmd"; then
+   fptools_cv_alex_version=`grep '^ProjectVersion[     ]*=' $srcdir/alex/mk/version.mk | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`;
+elif test x"$AlexCmd" != x; then
+   fptools_cv_alex_version="`$AlexCmd -v |
+                         grep 'Alex [Vv]ersion' | sed -e 's/Alex [Vv]ersion \([0-9\.]*\).*/\1/g'`" ;
+else
+   fptools_cv_alex_version="";
+fi;
+changequote([, ])dnl
+])
+dnl if test -d $srcdir/ghc -a ! -f $srcdir/ghc/compiler/parser/Lexer.hs; then
+dnl   FPTOOLS_PROG_CHECK_VERSION([$fptools_cv_alex_version],-lt,[2.0],
+dnl   [AC_MSG_ERROR([Alex version 2.0 or later is required to compile GHC.])])dnl
+dnl fi
+AlexVersion=$fptools_cv_alex_version;
+AC_SUBST(AlexVersion)
+])
+
+dnl
 dnl What's the best way of doing context diffs?
 dnl
 dnl (NB: NeXTStep thinks diff'ing a file against itself is "trouble")
 dnl What's the best way of doing context diffs?
 dnl
 dnl (NB: NeXTStep thinks diff'ing a file against itself is "trouble")
@@ -337,7 +331,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
     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
     ArCmdArgs="clqsZ"
     NeedRanLib=''
 elif $ArCmdRaw clqs conftest.a >/dev/null 2>/dev/null; then
@@ -663,6 +663,14 @@ AC_CACHE_VAL(AC_CV_NAME,
 # include <GL/gl.h>
 #endif
 
 # include <GL/gl.h>
 #endif
 
+#ifdef HAVE_OPENGL_GL_H
+# include <OpenGL/gl.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
 typedef $1 testing;
 
 main() {
 typedef $1 testing;
 
 main() {
@@ -763,11 +771,11 @@ AC_CACHE_VAL(fptools_cv_have_o_binary,
 [
 AC_LANG_SAVE
 AC_LANG_C
 [
 AC_LANG_SAVE
 AC_LANG_C
-AC_TRY_COMPILE(,
+AC_TRY_COMPILE(
 [#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 [#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
 fptools_cv_have_o_binary=yes,
 fptools_cv_have_o_binary=no)
 AC_LANG_RESTORE
@@ -1004,9 +1012,7 @@ esac
 ])
 
 dnl ######################################################################
 ])
 
 dnl ######################################################################
-dnl Some notes about the heavily changed OpenGL test below:
-dnl  * Caching has been completely rewritten, but is still no perfect yet.
-dnl  * Version detection for GL and GLU has been added.
+dnl Note: Caching has been completely rewritten, but is still no perfect yet.
 dnl ######################################################################
 
 dnl ########################### -*- Mode: M4 -*- #######################
 dnl ######################################################################
 
 dnl ########################### -*- Mode: M4 -*- #######################
@@ -1103,9 +1109,10 @@ dnl Check for Mesa first if we were asked to.
 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 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.
+dnl and GL_X_LIBS/GLUT_X_LIBS.
     GL_CFLAGS="$CPPFLAGS $X_CFLAGS"
     GL_CFLAGS="$CPPFLAGS $X_CFLAGS"
-    GL_X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext -lXmu -lXt -lXi $X_EXTRA_LIBS $LIBM"
+    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"
   fi
   GL_save_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="$GL_CFLAGS"
@@ -1113,126 +1120,9 @@ dnl and GL_X_LIBS.
   GL_save_LIBS="$LIBS"
   LIBS="$GL_X_LIBS"
 
   GL_save_LIBS="$LIBS"
   LIBS="$GL_X_LIBS"
 
-  dnl Including <GL/glut.h> instead of plain <GL/gl.h> avoids problems on
-  dnl platforms like WinDoze where special headers like <windows.h> or
-  dnl some macro trickery would be needed
-  FPTOOLS_SEARCH_LIBS([#include <GL/glut.h>], glEnd, $GL_search_list, have_GL=yes, have_GL=no)
-
-  dnl TODO: The tests for GL features should better be cascaded and the
-  dnl results should be cached. A new macro would be helpful here.
-
-  AC_MSG_CHECKING(glTexSubImage1D)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [glTexSubImage1D(GL_TEXTURE_1D,0,0,2,GL_INTENSITY,GL_BYTE,(void*)0)],
-              fptools_gl_texsubimage1d=yes,
-              fptools_gl_texsubimage1d=no);
-  AC_MSG_RESULT($fptools_gl_texsubimage1d)
-
-  AC_MSG_CHECKING(glDrawRangeElements)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [glDrawRangeElements(GL_QUADS,0,0,0,GL_UNSIGNED_BYTE,(void*)0)],
-              fptools_gl_drawrangeelements=yes,
-              fptools_gl_drawrangeelements=no);
-  AC_MSG_RESULT($fptools_gl_drawrangeelements)
-
-  AC_MSG_CHECKING(glActiveTexture)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [glActiveTexture(GL_TEXTURE1)],
-              fptools_gl_activetexture=yes,
-              fptools_gl_activetexture=no);
-  AC_MSG_RESULT($fptools_gl_activetexture)
-
-  AC_MSG_CHECKING(glMultiDrawArrays)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [glMultiDrawArrays(GL_TRIANGLES, (GLint*)0, (GLsizei*)0, 0)],
-              fptools_gl_multidrawarrays=yes,
-              fptools_gl_multidrawarrays=no);
-  AC_MSG_RESULT($fptools_gl_multidrawarrays)
-
-  if test x"$fptools_gl_texsubimage1d" != xyes; then
-    fptools_gl_version=1.0
-  else
-     if test x"$fptools_gl_drawrangeelements" != xyes; then
-        fptools_gl_version=1.1
-     else
-       if test x"$fptools_gl_activetexture" != xyes; then
-          fptools_gl_version=1.2
-       else
-         if test x"$fptools_gl_multidrawarrays" != xyes; then
-            fptools_gl_version=1.3
-         else
-            fptools_gl_version=1.4
-         fi
-       fi
-     fi
-  fi
-  echo "It looks like GL version ${fptools_gl_version}"
-
-  dnl TODO: Cache the results of the tests for the imaging subset.
-
-  AC_MSG_CHECKING(EXT_blend_color)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [glBlendColorEXT((GLclampf)0.0,(GLclampf)0.0,(GLclampf)0.0,(GLclampf)0.0)],
-              hopengl_EXT_blend_color=yes,
-              hopengl_EXT_blend_color=no);
-  AC_MSG_RESULT($hopengl_EXT_blend_color)
-
-  AC_MSG_CHECKING(EXT_blend_minmax)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [glBlendEquationEXT(GL_FUNC_ADD_EXT)],
-              hopengl_EXT_blend_minmax=yes,
-              hopengl_EXT_blend_minmax=no);
-  AC_MSG_RESULT($hopengl_EXT_blend_minmax)
-
-  AC_MSG_CHECKING(EXT_blend_subtract)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [glBlendEquationEXT(GL_FUNC_SUBTRACT_EXT)],
-              hopengl_EXT_blend_subtract=yes,
-              hopengl_EXT_blend_subtract=no);
-  AC_MSG_RESULT($hopengl_EXT_blend_subtract)
-
-  FPTOOLS_SEARCH_LIBS([#include <GL/glu.h>], gluNewQuadric, $GLU_search_list, have_GLU=yes,  have_GLU=no)
-
-  dnl TODO: Cascade and cache...
-
-  AC_MSG_CHECKING(gluGetString)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [gluGetString(GLU_EXTENSIONS)],
-              fptools_glu_getstring=yes,
-              fptools_glu_getstring=no);
-  AC_MSG_RESULT($fptools_glu_getstring)
-
-  AC_MSG_CHECKING(gluTessEndPolygon)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [gluTessEndPolygon((GLUtesselator*)0)],
-              fptools_glu_tessendpolygon=yes,
-              fptools_glu_tessendpolygon=no);
-  AC_MSG_RESULT($fptools_glu_tessendpolygon)
-
-  AC_MSG_CHECKING(gluUnProject4)
-  AC_TRY_LINK([#include <GL/glut.h>],
-              [gluUnProject4(0.0,0.0,0.0,0.0,(GLdouble*)0,(GLdouble*)0,(GLint*)0,0.0,0.0,(GLdouble*)0,(GLdouble*)0,(GLdouble*)0,(GLdouble*)0)],
-              fptools_glu_unproject4=yes,
-              fptools_glu_unproject4=no);
-  AC_MSG_RESULT($fptools_glu_unproject4)
-
-  if test x"$fptools_glu_getstring" != xyes; then
-    fptools_glu_version=1.0
-  else
-     if test x"$fptools_glu_tessendpolygon" != xyes; then
-        fptools_glu_version=1.1
-     else
-       if test x"$fptools_glu_unproject4" != xyes; then
-          fptools_glu_version=1.2
-       else
-            fptools_glu_version=1.3
-       fi
-     fi
-  fi
-  echo "It looks like GLU version ${fptools_glu_version}"
-
+  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/glx.h>],  glXWaitX,      $GLX_search_list, have_GLX=yes,  have_GLX=no)
-  FPTOOLS_SEARCH_LIBS([#include <GL/glut.h>], glutMainLoop,  glut32 glut,      have_glut=yes, have_glut=no)
 
   if test -n "$LIBS"; then
     GL_LIBS="$LDFLAGS $LIBS"
 
   if test -n "$LIBS"; then
     GL_LIBS="$LDFLAGS $LIBS"
@@ -1241,16 +1131,28 @@ dnl and GL_X_LIBS.
     GL_CFLAGS=
   fi
 
     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([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=
 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"
 
   LIBS="$GL_save_LIBS"
   CPPFLAGS="$GL_save_CPPFLAGS"