[project @ 2005-03-10 14:03:28 by simonmar]
[ghc-hetmet.git] / aclocal.m4
index a615c55..8f087d1 100644 (file)
@@ -248,9 +248,15 @@ AC_DEFUN(FPTOOLS_HAPPY,
 [
 if test -d $srcdir/happy; then
    SrcTreeHappyCmd=$hardtop/happy/src/happy-inplace
+else
+   SrcTreeHappyCmd=""
 fi
 if test x"$UseSrcTreeHappy" = xYES; then
-  HappyCmd=$SrcTreeHappyCmd
+  if test x"$SrcTreeHappyCmd" != x; then
+     HappyCmd=$SrcTreeHappyCmd
+  else
+     AC_MSG_ERROR([--enable-src-tree-happy given, but happy not found in source tree])
+  fi
 else
   AC_PATH_PROG(HappyCmd,happy,$SrcTreeHappyCmd)
 fi
@@ -267,8 +273,8 @@ fi;
 changequote([, ])dnl
 ])
 if test -d $srcdir/ghc -a ! -f $srcdir/ghc/compiler/parser/Parser.hs; then
-  FP_COMPARE_VERSIONS([$fptools_cv_happy_version],[-lt],[1.14],
-  [AC_MSG_ERROR([Happy version 1.14 or later is required to compile GHC.])])[]dnl
+  FP_COMPARE_VERSIONS([$fptools_cv_happy_version],[-lt],[1.15],
+  [AC_MSG_ERROR([Happy version 1.15 or later is required to compile GHC.])])[]dnl
 fi
 HappyVersion=$fptools_cv_happy_version;
 AC_SUBST(HappyVersion)
@@ -282,9 +288,15 @@ AC_DEFUN(FPTOOLS_HADDOCK,
 [
 if test -d $srcdir/haddock; then
    SrcTreeHaddockCmd=$hardtop/haddock/src/haddock-inplace
+else
+   SrcTreeHaddockCmd=""
 fi
 if test x"$UseSrcTreeHaddock" = xYES; then
-  HaddockCmd=$SrcTreeHaddockCmd
+  if test x"$SrcTreeHaddockCmd" != x; then
+     HaddockCmd=$SrcTreeHaddockCmd
+  else
+     AC_MSG_ERROR([--enable-src-tree-haddock given, but haddock not found in source tree])
+  fi
 else
   AC_PATH_PROG(HaddockCmd,haddock,$SrcTreeHaddockCmd)
 fi
@@ -303,9 +315,15 @@ AC_DEFUN(FPTOOLS_ALEX,
 [
 if test -d $srcdir/alex; then
    SrcTreeAlexCmd=$hardtop/alex/src/alex-inplace
+else
+   SrcTreeAlexCmd=""
 fi
 if test x"$UseSrcTreeAlex" = xYES; then
-  AlexCmd=$SrcTreeAlexCmd
+  if test x"$SrcTreeAlexCmd" != x; then
+     AlexCmd=$SrcTreeAlexCmd
+  else
+     AC_MSG_ERROR([--enable-src-tree-alex given, but alex not found in source tree])
+  fi
 else
   AC_PATH_PROG(AlexCmd,alex,$SrcTreeAlexCmd)
 fi
@@ -330,28 +348,65 @@ AC_SUBST(AlexVersion)
 ])
 
 
-dnl
-dnl Check whether ld supports -x
-dnl
-AC_DEFUN(FPTOOLS_LD_X,
-[AC_CACHE_CHECK([whether ld understands -x], fptools_cv_ld_x,
-[
-echo 'foo() {}' > conftest.c
+# FP_PROG_LD
+# ----------
+# Sets the output variable LdCmd to the (non-Cygwin version of the) full path
+# of ld. Exits if no ld can be found
+AC_DEFUN([FP_PROG_LD],
+[AC_PATH_PROG([fp_prog_ld_raw], [ld])
+if test -z "$fp_prog_ld_raw"; then
+  AC_MSG_ERROR([cannot find ld in your PATH, no idea how to link])
+fi
+LdCmd=$fp_prog_ld_raw
+case $HostPlatform in
+  *mingw32) if test x${OSTYPE} != xmsys; then
+             LdCmd="`cygpath -w ${fp_prog_ld_raw} | sed -e 's@\\\\@/@g'`"
+              AC_MSG_NOTICE([normalized ld command to $LdCmd])
+            fi
+            ;;
+esac
+AC_SUBST([LdCmd])
+])# FP_PROG_LD
+
+
+# FP_PROG_LD_X
+# ------------
+# Sets the output variable LdXFlag to -x if ld supports this flag, otherwise the
+# variable's value is empty.
+AC_DEFUN([FP_PROG_LD_X],
+[AC_REQUIRE([FP_PROG_LD])
+AC_CACHE_CHECK([whether ld understands -x], [fp_cv_ld_x],
+[echo 'foo() {}' > conftest.c
 ${CC-cc} -c conftest.c
-if ${LdCmd} -r -x -o foo.o conftest.o; then
-   fptools_cv_ld_x=yes
+if ${LdCmd} -r -x -o conftest2.o conftest.o; then
+   fp_cv_ld_x=yes
 else
-   fptools_cv_ld_x=no
+   fp_cv_ld_x=no
 fi
-rm -rf conftest.c conftest.o foo.o
-])
-if test "$fptools_cv_ld_x" = yes; then
-       LdXFlag=-x
+rm -rf conftest*])
+if test "$fp_cv_ld_x" = yes; then
+  LdXFlag=-x
 else
-       LdXFlag=
+  LdXFlag=
 fi
-AC_SUBST(LdXFlag)
-])
+AC_SUBST([LdXFlag])
+])# FP_PROG_LD_X
+
+
+# FP_PROG_LD_IS_GNU
+# -----------------
+# Sets the output variable LdIsGNULd to YES or NO, depending on whether it is
+# GNU ld or not.
+AC_DEFUN([FP_PROG_LD_IS_GNU],
+[AC_REQUIRE([FP_PROG_LD])
+AC_CACHE_CHECK([whether ld is GNU ld], [fp_cv_gnu_ld],
+[if ${LdCmd} --version 2> /dev/null | grep "GNU" > /dev/null 2>&1; then
+  fp_cv_gnu_ld=yes
+else
+  fp_cv_gnu_ld=no
+fi])
+AC_SUBST([LdIsGNULd], [`echo $fp_cv_gnu_ld | sed 'y/yesno/YESNO/'`])
+])# FP_PROG_LD_IS_GNU
 
 
 # FP_PROG_AR
@@ -429,9 +484,14 @@ AC_SUBST([ArCmd], ["$fp_prog_ar $fp_prog_ar_args"])
 AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],
 [AC_REQUIRE([FP_PROG_AR_IS_GNU])
 AC_REQUIRE([FP_PROG_AR_ARGS])
+AC_REQUIRE([AC_PROG_CC])
 AC_CACHE_CHECK([whether ranlib is needed], [fp_cv_prog_ar_needs_ranlib],
 [if test $fp_prog_ar_is_gnu = yes; then
   fp_cv_prog_ar_needs_ranlib=no
+elif test $TargetPlatform = powerpc-apple-darwin; then
+  # It's quite tedious to check for Apple's crazy timestamps in .a files,
+  # so we hardcode it.
+  fp_cv_prog_ar_needs_ranlib=yes
 elif echo $fp_prog_ar_args | grep "s" > /dev/null 2> /dev/null; then
   fp_cv_prog_ar_needs_ranlib=no
 else
@@ -497,18 +557,25 @@ rm -f conftest
 # output variables HaveGcc and GccVersion.
 AC_DEFUN([FP_HAVE_GCC],
 [AC_REQUIRE([AC_PROG_CC])
-AC_CACHE_CHECK([whether your gcc is OK], [fp_cv_have_gcc],
-[if test -z "$GCC"; then
-  fp_cv_have_gcc='no'
-  AC_MSG_WARN([You would be better off with gcc, perhaps it is already installed, but not in your PATH?])
+if test -z "$GCC"; then
+   fp_have_gcc=NO
 else
-  fp_cv_have_gcc='yes'
-  gcc_version_str="`$CC -v 2>&1 | grep 'version ' | sed -e 's/.*version [[^0-9]]*\([[0-9]][[0-9]]*\)\.\([[0-9]][[0-9]]*\).*/\1\.\2/g' `"
-  FP_COMPARE_VERSIONS([$gcc_version_str], [-lt], [2.0],
-    [AC_MSG_ERROR([Need at least gcc version 2.0 (2.95.3 recommend)])])
-fi])
-AC_SUBST([HaveGcc], [`echo $fp_cv_have_gcc | sed 'y/yesno/YESNO/'`])
-AC_SUBST([GccVersion], [`gcc --version | grep mingw | cut -f 3 -d ' '`])
+   fp_have_gcc=YES
+fi
+if test "$fp_have_gcc" = "NO" -a -d $srcdir/ghc; then
+  AC_MSG_ERROR([gcc is required])
+fi
+AC_CACHE_CHECK([version of gcc], [fp_gcc_version],
+[if test "$fp_have_gcc" = "YES"; then
+   fp_gcc_version="`$CC -v 2>&1 | grep 'version ' | sed -e 's/.*version [[^0-9]]*\([[0-9]][[0-9]]*\(\.[[0-9]][[0-9]]*\)*\).*/\1/g' `"
+   FP_COMPARE_VERSIONS([$fp_gcc_version], [-lt], [2.0],
+     [AC_MSG_ERROR([Need at least gcc version 2.0 (3.4+ recommended)])])
+ else
+   fp_gcc_version="not-installed"
+ fi
+])
+AC_SUBST([HaveGcc], [$fp_have_gcc])
+AC_SUBST([GccVersion], [$fp_gcc_version])
 ])# FP_HAVE_GCC
 
 AC_DEFUN([FP_MINGW_GCC],
@@ -581,6 +648,25 @@ AC_SUBST([FindCmd])[]dnl
 ])# FP_PROG_FIND
 
 
+# FP_PROG_SORT
+# ------------
+# Find a Unix-like sort
+AC_DEFUN([FP_PROG_SORT],
+[AC_PATH_PROG([fp_prog_sort], [sort])
+echo conwip > conftest.txt
+$fp_prog_sort -f conftest.txt > conftest.out 2>&1
+if grep 'conwip' conftest.out > /dev/null 2>&1 ; then
+  # The goods
+  SortCmd="$fp_prog_sort"
+else
+  # Summink else..pick next one.
+  AC_MSG_WARN([$fp_prog_sort looks like a non-*nix sort, ignoring it])
+  FP_CHECK_PROG([SortCmd], [sort], [], [], [$fp_prog_sort])
+fi
+rm -f conftest.txt conftest.out
+AC_SUBST([SortCmd])[]dnl
+])# FP_PROG_SORT
+
 dnl
 dnl FPTOOLS_NOCACHE_CHECK prints a message, then sets the
 dnl values of the second argument to the result of running