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