[project @ 2004-11-20 16:02:41 by panne]
[ghc-hetmet.git] / ghc / aclocal.m4
1 # FP_SETUP_PROJECT_INFO
2 # ---------------------
3 AC_DEFUN([FP_SETUP_PROJECT_INFO],
4 [# Some renamings
5 AC_SUBST([ProjectName], [$PACKAGE_NAME])
6 AC_SUBST([ProjectNameShort], [$PACKAGE_TARNAME])
7 AC_SUBST([ProjectVersion], [$PACKAGE_VERSION])
8
9 # Split PACKAGE_VERSION into (possibly empty) parts
10 VERSION_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
11 VERSION_TMP=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
12 VERSION_MINOR=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
13 ProjectPatchLevel=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
14
15 # Calculate project version as an integer, using 2 digits for minor version
16 case $VERSION_MINOR in
17   ?) ProjectVersionInt=${VERSION_MAJOR}0${VERSION_MINOR} ;;
18   ??) ProjectVersionInt=${VERSION_MAJOR}${VERSION_MINOR} ;;
19   *) AC_MSG_ERROR([bad minor version in $PACKAGE_VERSION]) ;;
20 esac
21 AC_SUBST([ProjectVersionInt])
22
23 # The project patchlevel is zero unless stated otherwise
24 test -z "$ProjectPatchLevel" && ProjectPatchLevel=0
25 AC_SUBST([ProjectPatchLevel])
26 ])# FP_SETUP_PROJECT_INFO
27
28
29 # FP_PROG_GHC_PKG
30 # ----------------
31 # Try to find a ghc-pkg matching the ghc mentioned in the environment variable
32 # WithGhc. If the latter is unset or no matching ghc-pkg can be found, try to
33 # find a plain ghc-pkg. Sets the output variable GhcPkgCmd.
34 AC_DEFUN([FP_PROG_GHC_PKG],
35 [AC_CACHE_CHECK([for ghc-pkg matching $WithGhc], fp_cv_matching_ghc_pkg,
36 [fp_ghc_pkg_guess=`echo $WithGhc | sed 's,ghc\(@<:@^/\\@:>@*\)$,ghc-pkg\1,'`
37 if "$fp_ghc_pkg_guess" -l > /dev/null 2>&1; then
38   fp_cv_matching_ghc_pkg=$fp_ghc_pkg_guess
39 else
40   fp_cv_matching_ghc_pkg=no
41 fi])
42 if test x"$fp_cv_matching_ghc_pkg" = xno; then
43   AC_PATH_PROG([GhcPkgCmd], [ghc-pkg])
44 else
45   GhcPkgCmd=$fp_cv_matching_ghc_pkg
46 fi])# FP_PROG_GHC_PKG
47
48
49 # FP_GHC_HAS_READLINE
50 # -------------------
51 AC_DEFUN(FP_GHC_HAS_READLINE,
52 [AC_REQUIRE([FP_PROG_GHC_PKG])
53 AC_CACHE_CHECK([whether ghc has readline package], [fp_cv_ghc_has_readline],
54 [if "${GhcPkgCmd-ghc-pkg}" --show-package readline >/dev/null 2>&1; then
55   fp_cv_ghc_has_readline=yes
56 else
57   fp_cv_ghc_has_readline=no
58  fi])
59 AC_SUBST([GhcHasReadline], [`echo $fp_cv_ghc_has_readline | sed 'y/yesno/YESNO/'`])
60 ])# FP_GHC_HAS_READLINE
61
62
63 # FP_COMPARE_VERSIONS(VERSION1, TEST, VERSION2, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
64 # ----------------------------------------------------------------------------------
65 # Compare dotted version numbers VERSION1 and VERSION2 lexicographically according
66 # to TEST (one of -eq, -ne, -lt, -le, -gt, or -ge).
67 AC_DEFUN([FP_COMPARE_VERSIONS],
68 [fp_version1=$1; fp_version2=$3
69 fp_save_IFS=$IFS; IFS='.'
70 while test x"$fp_version1" != x || test x"$fp_version2" != x
71 do
72
73   set dummy $fp_version1; shift
74   fp_num1=""
75   test $[@%:@] = 0 || { fp_num1="[$]1"; shift; }
76   test x"$fp_num1" = x && fp_num1="0"
77   fp_version1="[$]*"
78
79   set dummy $fp_version2; shift
80   fp_num2=""
81   test $[@%:@] = 0 || { fp_num2="[$]1"; shift; }
82   test x"$fp_num2" = x && fp_num2="0"
83   fp_version2="[$]*"
84
85   test "$fp_num1" = "$fp_num2" || break;
86 done
87 IFS=$fp_save_IFS
88 AS_IF([test "$fp_num1" $2 "$fp_num2"], [$4], [$5])[]dnl
89 ])# FP_COMPARE_VERSIONS
90
91
92 # FP_HAVE_GCC
93 # -----------
94 # Extra testing of the result AC_PROG_CC, testing the gcc version no. Sets the
95 # output variables HaveGcc and GccVersion.
96 AC_DEFUN([FP_HAVE_GCC],
97 [AC_REQUIRE([AC_PROG_CC])
98 AC_CACHE_CHECK([whether your gcc is OK], [fp_cv_have_gcc],
99 [if test -z "$GCC"; then
100   fp_cv_have_gcc='no'
101   AC_MSG_WARN([You would be better off with gcc, perhaps it is already installed, but not in your PATH?])
102 else
103   fp_cv_have_gcc='yes'
104   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' `"
105   FP_COMPARE_VERSIONS([$gcc_version_str], [-lt], [2.0],
106     [AC_MSG_ERROR([Need at least gcc version 2.0 (2.95.3 recommend)])])
107 fi])
108 AC_SUBST([HaveGcc], [`echo $fp_cv_have_gcc | sed 'y/yesno/YESNO/'`])
109 AC_SUBST([GccVersion], [`gcc --version | grep mingw | cut -f 3 -d ' '`])
110 ])# FP_HAVE_GCC
111
112
113 # FP_GCC_NEEDS_NO_OMIT_LFPTR
114 # --------------------------
115 # Some OSs (Mandrake Linux, in particular) configure GCC with
116 # -momit-leaf-frame-pointer on by default. If this is the case, we need to turn
117 # it off for mangling to work. The test is currently a bit crude, using only the
118 # version number of gcc. Defines HAVE_GCC_MNO_OMIT_LFPTR.
119 AC_DEFUN([FP_GCC_NEEDS_NO_OMIT_LFPTR],
120 [AC_REQUIRE([FP_HAVE_GCC])
121 AC_CACHE_CHECK([whether gcc needs -mno-omit-leaf-frame-pointer], [fp_cv_gcc_needs_no_omit_lfptr],
122 [FP_COMPARE_VERSIONS([$gcc_version_str], [-ge], [3.2],
123   [fp_cv_gcc_needs_no_omit_lfptr=yes],
124   [fp_cv_gcc_needs_no_omit_lfptr=no])])
125 if test "$fp_cv_gcc_needs_no_omit_lfptr" = "yes"; then
126    AC_DEFINE([HAVE_GCC_MNO_OMIT_LFPTR], [1], [Define to 1 if gcc supports -mno-omit-leaf-frame-pointer.])
127 fi])# FP_GCC_NEEDS_NO_OMIT_LFPTR