Allow non-operator infix pattern synonyms
[ghc.git] / configure.ac
1 dnl == autoconf source for the Glasgow FP tools ==
2 dnl (run "grep '^dnl \*' configure.ac | sed -e 's/dnl / /g; s/\*\*/   +/g;'"
3 dnl  (or some such) to see the outline of this file)
4 dnl
5 #
6 # (c) The University of Glasgow 1994-2012
7 #
8 # Configure script template for GHC
9 #
10 # Process with 'autoreconf' to get a working configure script.
11 #
12 # For the generated configure script, do "./configure --help" to
13 # see what flags are available. (Better yet, read the documentation!)
14 #
15
16 AC_INIT([The Glorious Glasgow Haskell Compilation System], [7.11], [glasgow-haskell-bugs@haskell.org], [ghc])
17
18 # Set this to YES for a released version, otherwise NO
19 : ${RELEASE=NO}
20
21 # The primary version (e.g. 7.5, 7.4.1) is set in the AC_INIT line
22 # above.  If this is not a released version, then we will append the
23 # date to the version number (e.g. 7.4.20111220).  The date is
24 # constructed by finding the date of the most recent patch in the
25 # git repository.  If this is a source distribution (not a git
26 # checkout), then we ship a file 'VERSION' containing the full version
27 # when the source distribution was created.
28
29 if test ! -f mk/config.h.in; then
30    echo "mk/config.h.in doesn't exist: perhaps you haven't run 'perl boot'?"
31    exit 1
32 fi
33
34 AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
35
36 dnl ----------------------------------------------------------
37 dnl ** Find unixy sort and find commands,
38 dnl ** which are needed by FP_SETUP_PROJECT_VERSION
39
40 dnl ** Find find command (for Win32's benefit)
41 FP_PROG_FIND
42 FP_PROG_SORT
43
44 dnl ----------------------------------------------------------
45 FP_SETUP_PROJECT_VERSION
46
47 # Hmmm, we fix the RPM release number to 1 here... Is this convenient?
48 AC_SUBST([release], [1])
49
50 # First off, a distrib sanity check..
51 AC_CONFIG_SRCDIR([mk/config.mk.in])
52
53 dnl * We require autoconf version 2.60
54 dnl We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE.
55 dnl We need 2.52 due to the use of AS_TR_CPP and AS_TR_SH.
56 dnl Using autoconf 2.59 started to give nonsense like this
57 dnl  #define SIZEOF_CHAR 0
58 dnl recently.
59 AC_PREREQ([2.60])
60
61 # -------------------------------------------------------------------------
62 # Prepare to generate the following header files
63 #
64 #
65 AC_CONFIG_HEADER(mk/config.h)
66
67 # No, semi-sadly, we don't do `--srcdir'...
68 if test x"$srcdir" != 'x.' ; then
69     echo "This configuration does not support the \`--srcdir' option.."
70     exit 1
71 fi
72
73 dnl --------------------------------------------------------------
74 dnl * Project specific configuration options
75 dnl --------------------------------------------------------------
76 dnl What follows is a bunch of options that can either be configured
77 dnl through command line options to the configure script or by
78 dnl supplying defns in the build tree's mk/build.mk. Having the option to
79 dnl use either is considered a Feature.
80
81 dnl ** What command to use to compile compiler sources ?
82 dnl --------------------------------------------------------------
83
84 AC_ARG_WITH([ghc],
85 [AC_HELP_STRING([--with-ghc=ARG],
86   [Use ARG as the path to GHC  [default=autodetect]])],
87   [WithGhc="$withval"],
88   [if test "$GHC" = ""; then
89     AC_PATH_PROG([GHC], [ghc])
90   fi
91   WithGhc="$GHC"])
92
93 dnl ** Tell the make system which OS we are using
94 dnl $OSTYPE is set by the operating system to "msys" or "cygwin" or something
95 AC_SUBST(OSTYPE)
96
97 AC_ARG_ENABLE(bootstrap-with-devel-snapshot,
98 [AC_HELP_STRING([--enable-bootstrap-with-devel-snapshot],
99                 [Allow bootstrapping using a development snapshot of GHC.  This is not guaranteed to work.])],
100         EnableBootstrapWithDevelSnaphost=YES,
101         EnableBootstrapWithDevelSnaphost=NO
102 )
103
104 AC_ARG_ENABLE(tarballs-autodownload,
105 [AC_HELP_STRING([--enable-tarballs-autodownload],
106                 [Automatically download Windows distribution binaries if needed.])],
107         TarballsAutodownload=YES,
108         TarballsAutodownload=NO
109 )
110 if test "$WithGhc" != ""; then
111   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
112
113   if test "$GhcMajVersion" = "unknown" -o "$GhcMinVersion" = "unknown"; then
114      AC_MSG_ERROR([Cannot determine the version of $WithGhc.  Is it really GHC?])
115   fi
116
117   AC_SUBST(GhcVersion)dnl
118   AC_SUBST(GhcMajVersion)dnl
119   AC_SUBST(GhcMinVersion)dnl
120   AC_SUBST(GhcPatchLevel)dnl
121   GhcMinVersion2=`echo "$GhcMinVersion" | sed 's/^\\(.\\)$/0\\1/'`
122   GhcCanonVersion="$GhcMajVersion$GhcMinVersion2"
123
124   BOOTSTRAPPING_GHC_INFO_FIELD([CC_STAGE0],[C compiler command])
125   dnl ToDo, once "ld command" is reliably available.
126   dnl Then, we can remove the LD_STAGE0 hack in mk/build-package-date.mk
127   dnl BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[ld command])
128   BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command])
129   BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags])
130   BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file])
131 fi
132
133 dnl ** Must have GHC to build GHC
134 if test "$WithGhc" = ""
135 then
136     AC_MSG_ERROR([GHC is required.])
137 fi
138 FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.8],
139     [AC_MSG_ERROR([GHC version 7.8 or later is required to compile GHC.])])
140
141 if test `expr $GhcMinVersion % 2` = "1"
142 then
143     if test "$EnableBootstrapWithDevelSnaphost" = "NO"
144     then
145         AC_MSG_ERROR([
146      $WithGhc is a development snapshot of GHC, version $GhcVersion.
147      Bootstrapping using this version of GHC is not supported, and may not
148      work.  Use --enable-bootstrap-with-devel-snapshot to try it anyway,
149      or --with-ghc to specify a different GHC to use.])
150     fi
151 fi
152
153 GHC_PACKAGE_DB_FLAG=package-db
154 AC_SUBST(GHC_PACKAGE_DB_FLAG)
155
156 # GHC 7.7+ needs -fcmm-sink when compiling Parser.hs. See #8182
157 FP_COMPARE_VERSIONS([$GhcVersion],[-gt],[7.7],
158                     CMM_SINK_BOOTSTRAP_IS_NEEDED=YES,
159                     CMM_SINK_BOOTSTRAP_IS_NEEDED=NO)
160 AC_SUBST(CMM_SINK_BOOTSTRAP_IS_NEEDED)
161
162 FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.9],
163                     SUPPORTS_PACKAGE_KEY=NO,
164                     SUPPORTS_PACKAGE_KEY=YES)
165 AC_SUBST(SUPPORTS_PACKAGE_KEY)
166
167 # GHC is passed to Cabal, so we need a native path
168 if test "${WithGhc}" != ""
169 then
170     ghc_host_os=`"${WithGhc}" +RTS --info | grep 'Host OS' | sed -e 's/.*, "//' -e 's/")//'`
171
172     if test "$ghc_host_os" = "mingw32"
173     then
174         if test "${OSTYPE}" = "msys"
175         then
176             WithGhc=`echo "${WithGhc}" | sed "s#^/\([a-zA-Z]\)/#\1:/#"`
177         else
178             # Canonicalise to <drive>:/path/to/ghc
179             WithGhc=`cygpath -m "${WithGhc}"`
180         fi
181         echo "GHC path canonicalised to: ${WithGhc}"
182     fi
183 fi
184 AC_SUBST([WithGhc])
185
186 dnl ** Without optimization some INLINE trickery fails for GHCi
187 SRC_CC_OPTS="-O"
188
189 dnl--------------------------------------------------------------------
190 dnl * Choose host(/target/build) platform
191 dnl--------------------------------------------------------------------
192 dnl If we aren't explicitly told what values to use with configure flags,
193 dnl we ask the bootstrapping compiler what platform it is for
194
195 if test "${WithGhc}" != ""
196 then
197         bootstrap_host=`"${WithGhc}" +RTS --info | grep '^ ,("Host platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
198         bootstrap_target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
199         if test "$bootstrap_host" != "$bootstrap_target"
200         then
201                 echo "Bootstrapping GHC is a cross compiler. This probably isn't going to work"
202         fi
203 fi
204
205 # We have to run these unconditionally, but we may discard their
206 # results in the following code
207 AC_CANONICAL_BUILD
208 AC_CANONICAL_HOST
209 AC_CANONICAL_TARGET
210
211 FPTOOLS_SET_PLATFORM_VARS
212
213 # Verify that the installed (bootstrap) GHC is capable of generating
214 # code for the requested build platform.
215 if test "$BuildPlatform" != "$bootstrap_target"
216 then
217     echo "This GHC (${WithGhc}) does not generate code for the build platform"
218     echo "   GHC target platform    : $bootstrap_target"
219     echo "   Desired build platform : $BuildPlatform"
220     exit 1
221 fi
222
223 # Testing if we shall enable shared libs support on Solaris.
224 # Anything older than SunOS 5.11 aka Solaris 11 (Express) is broken.
225
226 SOLARIS_BROKEN_SHLD=NO
227
228 case $host in
229      i386-*-solaris2)
230      # here we go with the test
231      MINOR=`uname -r|cut -d '.' -f 2-`
232      if test "$MINOR" -lt "11"; then
233          SOLARIS_BROKEN_SHLD=YES
234      fi
235      ;;
236 esac
237
238 AC_SUBST(SOLARIS_BROKEN_SHLD)
239
240 dnl ** Do an unregisterised build?
241 dnl --------------------------------------------------------------
242 case "$HostArch" in
243     i386|x86_64|powerpc|powerpc64|powerpc64le|arm)
244         UnregisterisedDefault=NO
245         ;;
246     *)
247         UnregisterisedDefault=YES
248         ;;
249 esac
250 AC_ARG_ENABLE(unregisterised,
251 [AC_HELP_STRING([--enable-unregisterised],
252 [Build an unregisterised compiler (enabled by default on platforms without registerised support) [default="$UnregisterisedDefault"]])],
253 [ if test x"$enableval" = x"yes"; then
254         Unregisterised=YES
255   else
256         Unregisterised=NO
257   fi
258 ],
259 [Unregisterised="$UnregisterisedDefault"]
260 )
261 AC_SUBST(Unregisterised)
262
263 AC_ARG_WITH(hc,
264 [AC_HELP_STRING([--with-hc=ARG],
265         [Use ARG as the path to the compiler for compiling ordinary
266          Haskell code  (default= value of --with-ghc)])],
267 [WithHc="$withval"],
268 [WithHc=$WithGhc]
269 )
270 AC_SUBST(WithHc)
271
272 # This uses GHC, so put it after the "GHC is required" check above:
273 FP_INTREE_GHC_PWD
274 FP_FIND_ROOT
275
276 fail() {
277     echo >&2
278     echo "$1" >&2
279     exit 1
280 }
281
282 download_file() {
283     local file_url="$1"
284     local file_md5="$2"
285     local dest_file="$3"
286     local description="$4"
287     local extra_curl_opts="$5"
288     local dest_dir="$(dirname $dest_file)"
289
290     if ! test -f "${dest_file}"
291     then
292         local curl_cmd="curl -L ${file_url} -o ${dest_file} --create-dirs -# ${extra_curl_opts}"
293         if test "$TarballsAutodownload" = "NO"
294         then
295             echo >&2
296             echo "ERROR: ${description} not found." >&2
297             echo "Please rerun configure with --enable-tarballs-autodownload, or perform the download manually:" >&2
298             echo "  $curl_cmd" >&2
299             exit 1
300         fi
301         AC_MSG_NOTICE([Downloading ${description} to ${dest_dir}...])
302         $curl_cmd || {
303             rm -f "${dest_file}"
304             fail "ERROR: Download failed."
305         }
306     else
307         AC_MSG_NOTICE([Using ${description} found in ${dest_dir}...])
308     fi
309
310     echo "${file_md5} *${dest_file}" | md5sum --quiet -c - ||
311         fail "ERROR: ${description} appears to be corrupted, please delete it and try again."
312 }
313
314
315 if test "$HostOS" = "mingw32"
316 then
317     # Find the mingw-w64 7z file to extract.
318     # NB. If you update the tarballs to a new version of gcc, don't
319     # forget to tweak the paths in driver/gcc/gcc.c.
320     if test "$HostArch" = "i386"
321     then
322         mingw_arch="i686"
323         tarball_dest_dir="mingw-w64/x86"
324         tarball_mingw_dir="mingw32"
325     else
326         mingw_arch="x86_64"
327         tarball_dest_dir="mingw-w64/x86_64"
328         tarball_mingw_dir="mingw64"
329     fi
330
331     tarball_dir='ghc-tarballs'
332 fi
333
334 download_and_extract() {
335     local mingw_url="$1"
336     local file_md5sum_x86="$2"
337     local file_md5sum_x64="$3"
338
339     if test "$HostArch" = "i386"
340     then
341         local file_md5sum="${file_md5sum_x86}"
342     else
343         local file_md5sum="${file_md5sum_x64}"
344     fi
345
346     local mingw_toolchain="$(basename $mingw_url)"
347     local mingw_w64="${tarball_dir}/${tarball_dest_dir}/${mingw_toolchain}"
348
349     download_file "${mingw_url}" "${file_md5sum}" "${mingw_w64}" "${mingw_toolchain}"
350
351     # Mark the tree as needing updates by deleting the folder
352     if test -d inplace/mingw && test inplace/mingw -ot "$mingw_w64"
353     then
354         AC_MSG_NOTICE([In-tree MinGW-w64 tree requires updates...])
355         rm -rf inplace/mingw
356     fi
357 }
358
359 set_up_tarballs() {
360     local mingw_base_url="https://downloads.haskell.org/~ghc/mingw"
361     local package_prefix="mingw-w64"
362
363     local format_url="${mingw_base_url}/${mingw_arch}/${package_prefix}-${mingw_arch}"
364
365     download_and_extract "${format_url}-crt-git-5.0.0.4531.49c7046-1-any.pkg.tar.xz"           "dd39323140c0c1b3e065e9edb1a66779" "ac22cedd38229bcd57f5999e4734054f"
366     download_and_extract "${format_url}-winpthreads-git-5.0.0.4538.78dca70-1-any.pkg.tar.xz"   "0b14fe27790e94db454fbb3564e79a73" "65cf07b6f42a1a62d1844e08190cab0d"
367     download_and_extract "${format_url}-headers-git-5.0.0.4531.49c7046-1-any.pkg.tar.xz"       "6ee9e3c2f9d3e507f60ee33d19417dc2" "f49a19cdea93998c33ac90ceb9570350"
368     download_and_extract "${format_url}-libwinpthread-git-5.0.0.4538.78dca70-1-any.pkg.tar.xz" "fbb2114aa7fbb5507e21d8a2ea265cfd" "31ed10e2d8891f6251d968f81bfdd274"
369     download_and_extract "${format_url}-zlib-1.2.8-8-any.pkg.tar.xz"                           "7f519cb6defa27a90c5353160cf088d4" "6a2f4a70ccb24acca70a01da331699a6"
370     download_and_extract "${format_url}-isl-0.14.1-2-any.pkg.tar.xz"                           "4cd20fe75ed9ef03e260d529042cb742" "dc0e0a7fd23a8193cccb0bf8d7267685"
371     download_and_extract "${format_url}-mpc-1.0.3-2-any.pkg.tar.xz"                            "719e76fa7a54a8676d2e60af3bb13c45" "df1a7d4050568d83c265ae78c32ef30b"
372     download_and_extract "${format_url}-mpfr-3.1.3.p0-2-any.pkg.tar.xz"                        "e9cbd2402ac1afe6e86c102223b90dcb" "6e3b9ec27edab394aa41536839afdafe"
373     download_and_extract "${format_url}-gmp-6.0.0-3-any.pkg.tar.xz"                            "c02f9759cd0140a6d8ea69ef5a88e167" "2970d4d8b176f8f36ae2d39269b25cce"
374     download_and_extract "${format_url}-gcc-libs-5.2.0-3-any.pkg.tar.xz"                       "a9bd2e65cb350cc8f8a6deb6d3b346a8" "9c2ed24989e14fdf0c548a5215374660"
375     download_and_extract "${format_url}-binutils-2.25.1-1-any.pkg.tar.xz"                      "997e9c2166fb851916cd8ac1bc9c6180" "7cb9f5f50a7103da41f7ec7547c09707"
376     download_and_extract "${format_url}-libiconv-1.14-5-any.pkg.tar.xz"                        "2c99a163689ba8257627bb07274b3f86" "37418c6be92ef20be17cdc9fe844af35"
377     download_and_extract "${format_url}-gcc-5.2.0-3-any.pkg.tar.xz"                            "efe6d6afc18aab89dc01e7ddcd2523a6" "0b697ce61112ba6e5a3c4d565957ea4e"
378
379     # Extract all the tarballs in one go
380     if ! test -d inplace/mingw
381     then
382         AC_MSG_NOTICE([Extracting Windows toolchain from archives (may take a while)...])
383         rm -rf inplace/mingw
384         local base_dir="../${tarball_dir}/${tarball_dest_dir}"
385         ( cd inplace &&
386         find "${base_dir}" -name "*.tar.xz" -exec tar xfJ {} \; &&
387         rm ".MTREE" &&
388         rm ".PKGINFO" &&
389         cd .. ) || fail "Error: Could not extract Windows toolchains."
390
391         mv "inplace/${tarball_mingw_dir}" inplace/mingw &&
392         touch inplace/mingw
393
394         # NB. Now since the GCC is hardcoded to use /mingw32 we need to
395         # make a wrapper around it to give it the proper paths
396         mv inplace/mingw/bin/gcc.exe inplace/mingw/bin/realgcc.exe
397         PATH=`pwd`/inplace/mingw/bin:$PATH
398         inplace/mingw/bin/realgcc.exe driver/gcc/gcc.c driver/utils/cwrapper.c driver/utils/getLocation.c -Idriver/utils -o inplace/mingw/bin/gcc.exe
399
400         AC_MSG_NOTICE([In-tree MingW-w64 tree created])
401     fi
402 }
403
404 if test "$HostOS" = "mingw32"
405 then
406     test -d inplace || mkdir inplace
407
408     # NB. Download and extract the MingW-w64 distribution if required
409     set_up_tarballs
410
411     mingwbin="$hardtop/inplace/mingw/bin/"
412     CC="${mingwbin}gcc.exe"
413     LD="${mingwbin}ld.exe"
414     NM="${mingwbin}nm.exe"
415     RANLIB="${mingwbin}ranlib.exe"
416     OBJDUMP="${mingwbin}objdump.exe"
417     fp_prog_ar="${mingwbin}ar.exe"
418
419     # NB. Download the perl binaries if required
420     download_file "https://github.com/ghc/ghc-tarballs/blob/master/perl/ghc-perl-1.tar.gz?raw=true" "b21d1681b61cf7a024e854096285b02e" "ghc-tarballs/perl/ghc-perl-1.tar.gz" "Windows Perl binary distributions" "--insecure"
421
422     if ! test -d inplace/perl ||
423          test inplace/perl -ot ghc-tarballs/perl/ghc-perl*.tar.gz
424     then
425         AC_MSG_NOTICE([Making in-tree perl tree])
426         rm -rf inplace/perl
427         mkdir inplace/perl
428         (
429             cd inplace/perl &&
430             tar -zxf ../../ghc-tarballs/perl/ghc-perl*.tar.gz
431         )
432         AC_MSG_NOTICE([In-tree perl tree created])
433     fi
434 fi
435
436 FP_ICONV
437 FP_GMP
438 FP_CURSES
439
440 XCODE_VERSION()
441
442 SplitObjsBroken=NO
443 if test "$TargetOS_CPP" = "darwin"
444 then
445     # Split objects is broken (#4013) with XCode < 3.2
446     if test "$XCodeVersion1" -lt 3
447     then
448         SplitObjsBroken=YES
449     else
450         if test "$XCodeVersion1" -eq 3
451         then
452             if test "$XCodeVersion2" -lt 2
453             then
454                 SplitObjsBroken=YES
455             fi
456         fi
457     fi
458 fi
459 AC_SUBST([SplitObjsBroken])
460
461 dnl ** Building a cross compiler?
462 dnl --------------------------------------------------------------
463 CrossCompiling=NO
464 # If 'host' and 'target' differ, then this means we are building a cross-compiler.
465 if test "$target" != "$host" ; then
466     CrossCompiling=YES
467     cross_compiling=yes   # This tells configure that it can accept just 'target',
468                           # otherwise you get
469                           #   configure: error: cannot run C compiled programs.
470                           #   If you meant to cross compile, use `--host'.
471 fi
472 if test "$build" != "$host" ; then
473    AC_MSG_ERROR([
474 You've selected:
475
476   BUILD:  $build   (the architecture we're building on)
477   HOST:   $host    (the architecture the compiler we're building will execute on)
478   TARGET: $target  (the architecture the compiler we're building will produce code for)
479
480 BUILD must equal HOST; that is, we do not support building GHC itself
481 with a cross-compiler.  To cross-compile GHC itself, set TARGET: stage
482 1 will be a cross-compiler, and stage 2 will be the cross-compiled
483 GHC.
484 ])
485 fi
486 if test "$CrossCompiling" = "YES"
487 then
488   CrossCompilePrefix="${target}-"
489 else
490   CrossCompilePrefix=""
491 fi
492 TargetPlatformFull="${target}"
493 AC_SUBST(CrossCompiling)
494 AC_SUBST(CrossCompilePrefix)
495 AC_SUBST(TargetPlatformFull)
496
497 dnl ** Which gcc to use?
498 dnl --------------------------------------------------------------
499 FIND_GCC([WhatGccIsCalled], [gcc], [gcc])
500 CC="$WhatGccIsCalled"
501 export CC
502
503 # If --with-gcc was used, and we're not cross-compiling, then it also
504 # applies to the stage0 compiler.
505 MAYBE_OVERRIDE_STAGE0([gcc],[CC_STAGE0])
506 MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0])
507
508 dnl ** figure out how to invoke the C preprocessor (i.e. `gcc -E`)
509 AC_PROG_CPP
510
511 # --with-hs-cpp/--with-hs-cpp-flags
512 FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
513 AC_SUBST([HaskellCPPCmd])
514 AC_SUBST([HaskellCPPArgs])
515
516 dnl ** Which ld to use?
517 dnl --------------------------------------------------------------
518 FIND_LD([LdCmd])
519 AC_SUBST([LdCmd])
520
521 dnl ** Which nm to use?
522 dnl --------------------------------------------------------------
523 FP_ARG_WITH_PATH_GNU_PROG([NM], [nm], [nm])
524 NmCmd="$NM"
525 AC_SUBST([NmCmd])
526
527 dnl ** Which ar to use?
528 dnl --------------------------------------------------------------
529 FP_ARG_WITH_PATH_GNU_PROG([AR], [ar], [ar])
530 ArCmd="$AR"
531 fp_prog_ar="$AR"
532 AC_SUBST([ArCmd])
533
534 dnl ** Which ranlib to use?
535 dnl --------------------------------------------------------------
536 FP_ARG_WITH_PATH_GNU_PROG([RANLIB], [ranlib], [ranlib])
537 RanlibCmd="$RANLIB"
538 RANLIB="$RanlibCmd"
539
540
541 # Note: we may not have objdump on OS X, and we only need it on Windows (for DLL checks)
542 case $HostOS_CPP in
543 cygwin32|mingw32)
544     dnl ** Which objdump to use?
545     dnl --------------------------------------------------------------
546     FP_ARG_WITH_PATH_GNU_PROG([OBJDUMP], [objdump], [objdump])
547     ObjdumpCmd="$OBJDUMP"
548     AC_SUBST([ObjdumpCmd])
549     ;;
550 esac
551
552 # Here is where we re-target which specific version of the LLVM
553 # tools we are looking for. In the past, GHC supported a number of
554 # versions of LLVM simultaneously, but that stopped working around
555 # 3.5/3.6 release of LLVM.
556 LlvmVersion=3.6
557 AC_SUBST([LlvmVersion])
558
559 dnl ** Which LLVM llc to use?
560 dnl --------------------------------------------------------------
561 FIND_LLVM_PROG([LLC], [llc], [llc], [$LlvmVersion])
562 LlcCmd="$LLC"
563 AC_SUBST([LlcCmd])
564
565 dnl ** Which LLVM opt to use?
566 dnl --------------------------------------------------------------
567 FIND_LLVM_PROG([OPT], [opt], [opt], [$LlvmVersion])
568 OptCmd="$OPT"
569 AC_SUBST([OptCmd])
570
571 dnl --------------------------------------------------------------
572 dnl End of configure script option section
573 dnl --------------------------------------------------------------
574
575
576 dnl --------------------------------------------------------------
577 dnl * General configuration checks
578 dnl --------------------------------------------------------------
579
580 dnl ** Bug 9439: Some GHC 7.8 releases had broken LLVM code generator.
581 dnl Unfortunately we don't know whether the user is going to request a
582 dnl build with the LLVM backend as this is only given in build.mk.
583 dnl
584 dnl Instead, we try to do as much work as possible here, checking
585 dnl whether -fllvm is the stage 0 compiler's default. If so we
586 dnl fail. If not, we check whether -fllvm is affected explicitly and
587 dnl if so set a flag. The build system will later check this flag
588 dnl after the desired build flags are known.
589
590 dnl This problem is further complicated by the fact that the llvm
591 dnl version used by the bootstrap compiler may be different from the
592 dnl version we arre trying to compile GHC against. Therefore, we need
593 dnl to find the boostrap compiler's `settings` file then check to see
594 dnl if the `opt` and `llc` command strings are non-empty and if these
595 dnl programs exist. Only if they exist to we test for bug #9439.
596
597 FIND_GHC_BOOTSTRAP_PROG([BootstrapLlcCmd], [${WithGhc}], "LLVM llc command")
598 FIND_GHC_BOOTSTRAP_PROG([BootstrapOptCmd], [${WithGhc}], "LLVM opt command")
599
600 if test -n "$BootstrapLlcCmd" && test -n "$BootstrapOptCmd"
601 then
602     AC_MSG_CHECKING(whether bootstrap compiler is affected by bug 9439)
603     echo "main = putStrLn \"%function\"" > conftestghc.hs
604
605     # Check whether LLVM backend is default for this platform
606     "${WithGhc}" -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" conftestghc.hs 2>&1 >/dev/null
607     res=`./conftestghc`
608     if test "x$res" = "x%object"
609     then
610         AC_MSG_RESULT(yes)
611         echo "Buggy bootstrap compiler"
612         echo ""
613         echo "The stage 0 compiler $WithGhc is affected by GHC Bug \#9439"
614         echo "and therefore will miscompile the LLVM backend if -fllvm is"
615         echo "used."
616         echo
617         echo "Please use another bootstrap compiler"
618         exit 1
619     fi
620
621     # -fllvm is not the default, but set a flag so the Makefile can check
622     # -for it in the build flags later on
623     "${WithGhc}" -fforce-recomp -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" -fllvm conftestghc.hs 2>&1 >/dev/null
624     if test $? = 0
625     then
626         res=`./conftestghc`
627         if test "x$res" = "x%object"
628         then
629             AC_MSG_RESULT(yes)
630             GHC_LLVM_AFFECTED_BY_9439=1
631         elif test "x$res" = "x%function"
632         then
633             AC_MSG_RESULT(no)
634             GHC_LLVM_AFFECTED_BY_9439=0
635         else
636             AC_MSG_WARN(unexpected output $res)
637         fi
638     else
639         AC_MSG_RESULT(failed to compile, assuming no)
640     fi
641 fi
642 AC_SUBST([GHC_LLVM_AFFECTED_BY_9439])
643
644 dnl ** Can the unix package be built?
645 dnl --------------------------------------------------------------
646
647 if test "$TargetOS" = "mingw32"
648 then
649     GhcLibsWithUnix=NO
650 else
651     GhcLibsWithUnix=YES
652 fi
653 AC_SUBST([GhcLibsWithUnix])
654
655 dnl ** does #! work?
656 AC_SYS_INTERPRETER()
657
658 dnl ** look for `perl'
659 case $HostOS_CPP in
660 cygwin32|mingw32)
661     PerlCmd=$hardtop/inplace/perl/perl
662     ;;
663 *)
664     AC_PATH_PROG(PerlCmd,perl)
665     if test -z "$PerlCmd"
666     then
667         echo "You must install perl before you can continue"
668         echo "Perhaps it is already installed, but not in your PATH?"
669         exit 1
670     else
671         FPTOOLS_CHECK_PERL_VERSION
672     fi
673     ;;
674 esac
675
676 dnl ** look for GCC and find out which version
677 dnl     Figure out which C compiler to use.  Gcc is preferred.
678 dnl     If gcc, make sure it's at least 3.0
679 dnl
680 FP_GCC_VERSION
681
682 dnl ** look to see if we have a C compiler using an llvm back end.
683 dnl
684 FP_CC_LLVM_BACKEND
685
686 FP_PROG_LD_IS_GNU
687 FP_PROG_LD_BUILD_ID
688 FP_PROG_LD_NO_COMPACT_UNWIND
689 FP_PROG_LD_FILELIST
690
691
692 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
693 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
694 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
695 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
696 # Stage 3 won't be supported by cross-compilation
697
698 FP_GCC_EXTRA_FLAGS
699
700 AC_SUBST(CONF_CC_OPTS_STAGE0)
701 AC_SUBST(CONF_CC_OPTS_STAGE1)
702 AC_SUBST(CONF_CC_OPTS_STAGE2)
703 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
704 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
705 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
706 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
707 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
708 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
709 AC_SUBST(CONF_CPP_OPTS_STAGE0)
710 AC_SUBST(CONF_CPP_OPTS_STAGE1)
711 AC_SUBST(CONF_CPP_OPTS_STAGE2)
712
713 dnl ** Set up the variables for the platform in the settings file.
714 dnl May need to use gcc to find platform details.
715 dnl --------------------------------------------------------------
716 FPTOOLS_SET_HASKELL_PLATFORM_VARS
717
718 dnl ** figure out how to do context diffs
719 FP_PROG_CONTEXT_DIFF
720
721 dnl Let's make sure install-sh is executable here.  If we got it from
722 dnl a darcs repo, it might not be (see bug #978).
723 chmod +x install-sh
724 dnl ** figure out how to do a BSD-ish install
725 AC_PROG_INSTALL
726
727 dnl ** how to invoke `ar' and `ranlib'
728 FP_PROG_AR_SUPPORTS_ATFILE
729 FP_PROG_AR_NEEDS_RANLIB
730
731 dnl ** Check to see whether ln -s works
732 AC_PROG_LN_S
733
734 FP_SETTINGS
735
736 dnl ** Find the path to sed
737 AC_PATH_PROGS(SedCmd,gsed sed,sed)
738
739
740 dnl ** check for time command
741 AC_PATH_PROG(TimeCmd,time)
742
743 dnl ** check for tar
744 dnl   if GNU tar is named gtar, look for it first.
745 AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar)
746
747 dnl ** check for patch
748 dnl if GNU patch is named gpatch, look for it first
749 AC_PATH_PROGS(PatchCmd,gpatch patch, patch)
750
751 dnl ** check for dtrace (currently only implemented for Mac OS X)
752 HaveDtrace=NO
753 AC_PATH_PROG(DtraceCmd,dtrace)
754 if test -n "$DtraceCmd"; then
755   if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then
756     HaveDtrace=YES
757   fi
758 fi
759 AC_SUBST(HaveDtrace)
760
761 AC_PATH_PROG(HSCOLOUR,HsColour)
762 # HsColour is passed to Cabal, so we need a native path
763 if test "$HostOS"      = "mingw32" && \
764    test "${OSTYPE}"   != "msys"    && \
765    test "${HSCOLOUR}" != ""
766 then
767     # Canonicalise to <drive>:/path/to/gcc
768     HSCOLOUR=`cygpath -m ${HSCOLOUR}`
769 fi
770
771 dnl ** check for Sphinx toolchain
772 AC_PATH_PROG(SPHINXBUILD,sphinx-build)
773
774 dnl ** check for xelatex
775 AC_PATH_PROG(XELATEX,xelatex)
776
777 dnl ** check for ghc-pkg command
778 FP_PROG_GHC_PKG
779
780 dnl ** check for installed happy binary + version
781 FPTOOLS_HAPPY
782
783 dnl ** check for installed alex binary + version
784 FPTOOLS_ALEX
785
786 dnl --------------------------------------------------
787 dnl ### program checking section ends here ###
788 dnl --------------------------------------------------
789
790 dnl --------------------------------------------------
791 dnl * Platform header file and syscall feature tests
792 dnl ### checking the state of the local header files and syscalls ###
793
794 dnl ** check for full ANSI header (.h) files
795 AC_HEADER_STDC
796
797 dnl ** Enable large file support.  NB. do this before testing the type of
798 dnl    off_t, because it will affect the result of that test.
799 AC_SYS_LARGEFILE
800
801 dnl ** check for specific header (.h) files that we are interested in
802 AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h time.h utime.h windows.h winsock.h sched.h])
803
804 dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
805 AC_CHECK_HEADERS([sys/cpuset.h], [], [],
806 [[#if HAVE_SYS_PARAM_H
807 # include <sys/param.h>
808 #endif
809 ]])
810
811 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
812 AC_HEADER_TIME
813
814 dnl ** do we have long longs?
815 AC_CHECK_TYPES([long long])
816
817 dnl ** what are the sizes of various types
818 AC_CHECK_SIZEOF(char,               1)
819 AC_CHECK_SIZEOF(double,             8)
820 AC_CHECK_SIZEOF(float,              4)
821 AC_CHECK_SIZEOF(int,                4)
822 AC_CHECK_SIZEOF(long,               4)
823 if test "$ac_cv_type_long_long" = yes; then
824 AC_CHECK_SIZEOF(long long,          8)
825 fi
826 AC_CHECK_SIZEOF(short,              2)
827 AC_CHECK_SIZEOF(unsigned char,      1)
828 AC_CHECK_SIZEOF(unsigned int,       4)
829 AC_CHECK_SIZEOF(unsigned long,      4)
830 if test "$ac_cv_type_long_long" = yes; then
831 AC_CHECK_SIZEOF(unsigned long long, 8)
832 fi
833 AC_CHECK_SIZEOF(unsigned short,     2)
834 AC_CHECK_SIZEOF(void *,             4)
835
836 dnl for use in settings.in
837 WordSize=$ac_cv_sizeof_void_p
838 AC_SUBST(WordSize)
839
840 dnl ** what are alignment constraints on various types
841 FP_CHECK_ALIGNMENT(char)
842 FP_CHECK_ALIGNMENT(double)
843 FP_CHECK_ALIGNMENT(float)
844 FP_CHECK_ALIGNMENT(int)
845 FP_CHECK_ALIGNMENT(long)
846 if test "$ac_cv_type_long_long" = yes; then
847 FP_CHECK_ALIGNMENT(long long)
848 fi
849 FP_CHECK_ALIGNMENT(short)
850 FP_CHECK_ALIGNMENT(unsigned char)
851 FP_CHECK_ALIGNMENT(unsigned int)
852 FP_CHECK_ALIGNMENT(unsigned long)
853 if test "$ac_cv_type_long_long" = yes; then
854 FP_CHECK_ALIGNMENT(unsigned long long)
855 fi
856 FP_CHECK_ALIGNMENT(unsigned short)
857 FP_CHECK_ALIGNMENT(void *)
858
859 FP_CHECK_FUNC([WinExec],
860   [@%:@include <windows.h>], [WinExec("",0)])
861
862 FP_CHECK_FUNC([GetModuleFileName],
863   [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
864
865 dnl ** check for more functions
866 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
867 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity setlocale])
868
869 dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
870 dnl ** _POSIX_C_SOURCE is defined
871 AC_CHECK_DECLS([ctime_r], , ,
872 [#define _POSIX_SOURCE 1
873 #define _POSIX_C_SOURCE 199506L
874 #include <time.h>])
875
876 dnl ** check for mingwex library
877 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
878 AC_SUBST(HaveLibMingwEx)
879
880 if test $HaveLibMingwEx = YES ; then
881   AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
882 fi
883
884 dnl ** check for math library
885 dnl    Keep that check as early as possible.
886 dnl    as we need to know whether we need libm
887 dnl    for math functions or not
888 dnl    (see http://ghc.haskell.org/trac/ghc/ticket/3730)
889 AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO)
890 if test $HaveLibM = YES
891 then
892   AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])
893 fi
894
895 FP_BFD_SUPPORT
896
897 dnl ################################################################
898 dnl Check for libraries
899 dnl ################################################################
900
901 # system libffi
902
903 AC_ARG_WITH([system-libffi],
904 [AC_HELP_STRING([--with-system-libffi],
905   [Use system provided libffi for RTS [default=no]])
906 ])
907
908 AS_IF([test "x$with_system_libffi" = "xyes"],
909   [UseSystemLibFFI="YES"], [UseSystemLibFFI="NO"]
910 )
911
912
913 AC_SUBST(UseSystemLibFFI)
914
915 AC_ARG_WITH([ffi-includes],
916 [AC_HELP_STRING([--with-ffi-includes=ARG],
917   [Find includes for libffi in ARG [default=system default]])
918 ],
919 [
920  if test "x$UseSystemLibFFI" != "xYES"; then
921     AC_MSG_WARN([--with-ffi-includes will be ignored, --with-system-libffi not set])
922  else
923     FFIIncludeDir="$withval"
924     LIBFFI_CFLAGS="-I$withval"
925  fi
926 ])
927
928 AC_SUBST(FFIIncludeDir)
929
930 AC_ARG_WITH([ffi-libraries],
931 [AC_HELP_STRING([--with-ffi-libraries=ARG],
932   [Find libffi in ARG [default=system default]])
933 ],
934 [
935  if test "x$UseSystemLibFFI" != "xYES"; then
936     AC_MSG_WARN([--with-ffi-libraries will be ignored, --with-system-libffi not set])
937  else
938     FFILibDir="$withval" LIBFFI_LDFLAGS="-L$withval"
939  fi
940 ])
941
942 AC_SUBST(FFILibDir)
943
944 AS_IF([test "$UseSystemLibFFI" = "YES"], [
945  CFLAGS2="$CFLAGS"
946  CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
947  LDFLAGS2="$LDFLAGS"
948  LDFLAGS="$LIBFFI_LDFLAGS $LDFLAGS"
949  AC_CHECK_LIB(ffi, ffi_call,
950   [AC_CHECK_HEADERS([ffi.h], [break], [])
951    AC_DEFINE([HAVE_LIBFFI], [1], [Define to 1 if you have libffi.])],
952   [AC_MSG_ERROR([Cannot find system libffi])])
953  CFLAGS="$CFLAGS2"
954  LDFLAGS="$LDFLAGS2"
955 ])
956
957 dnl ** check whether we need -ldl to get dlopen()
958 AC_CHECK_LIB(dl, dlopen)
959
960 dnl --------------------------------------------------
961 dnl * Miscellaneous feature tests
962 dnl --------------------------------------------------
963
964 dnl ** can we get alloca?
965 AC_FUNC_ALLOCA
966
967 dnl ** working vfork?
968 AC_FUNC_FORK
969
970 dnl ** determine whether or not const works
971 AC_C_CONST
972
973 dnl ** are we big endian?
974 AC_C_BIGENDIAN
975 FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
976
977 dnl ** check for leading underscores in symbol names
978 FP_LEADING_UNDERSCORE
979
980 FP_VISIBILITY_HIDDEN
981
982 dnl ** check for librt
983 AC_CHECK_LIB(rt, clock_gettime)
984 AC_CHECK_FUNCS(clock_gettime timer_settime)
985 FP_CHECK_TIMER_CREATE
986
987 dnl ** check for Apple's "interesting" long double compatibility scheme
988 AC_MSG_CHECKING(for printf\$LDBLStub)
989 AC_TRY_LINK_FUNC(printf\$LDBLStub,
990     [
991         AC_MSG_RESULT(yes)
992         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
993             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
994     ],
995     [
996         AC_MSG_RESULT(no)
997         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
998             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
999     ])
1000
1001 dnl ** pthread_setname_np is a recent addition to glibc, and OS X has
1002 dnl    a different single-argument version.
1003 AC_CHECK_LIB(pthread, pthread_setname_np)
1004 AC_MSG_CHECKING(for pthread_setname_np)
1005 AC_TRY_LINK(
1006 [
1007 #define _GNU_SOURCE
1008 #include <pthread.h>
1009 ],
1010 [pthread_setname_np(pthread_self(), "name");],
1011     AC_MSG_RESULT(yes)
1012     AC_DEFINE([HAVE_PTHREAD_SETNAME_NP], [1],
1013       [Define to 1 if you have the glibc version of pthread_setname_np]),
1014     AC_MSG_RESULT(no)
1015 )
1016
1017 dnl ** check for eventfd which is needed by the I/O manager
1018 AC_CHECK_HEADERS([sys/eventfd.h])
1019 AC_CHECK_FUNCS([eventfd])
1020
1021 dnl ** Check for __thread support in the compiler
1022 AC_MSG_CHECKING(for __thread support)
1023 AC_COMPILE_IFELSE(
1024   [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ],
1025   [
1026    AC_MSG_RESULT(yes)
1027    AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported])
1028   ],
1029   [
1030    AC_MSG_RESULT(no)
1031    AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported])
1032   ])
1033
1034
1035 dnl ** checking for PAPI
1036 AC_CHECK_LIB(papi, PAPI_library_init, HavePapiLib=YES, HavePapiLib=NO)
1037 AC_CHECK_HEADER([papi.h], [HavePapiHeader=YES], [HavePapiHeader=NO])
1038 AC_SUBST(HavePapiLib)
1039 AC_SUBST(HavePapiHeader)
1040
1041 AC_CHECK_FUNCS(__mingw_vfprintf)
1042
1043 if test "$HavePapiLib" = "YES" -a "$HavePapiHeader" = "YES"; then
1044    HavePapi=YES
1045 else
1046    HavePapi=NO
1047 fi
1048 AC_SUBST(HavePapi)
1049
1050 dnl large address space support (see includes/rts/storage/MBlock.h)
1051 dnl
1052 dnl Darwin has vm_allocate/vm_protect
1053 dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED)
1054 dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE
1055 dnl (They also have MADV_DONTNEED, but it means something else!)
1056 dnl
1057 dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however
1058 dnl it counts page-table space as committed memory, and so quickly
1059 dnl runs out of paging file when we have multiple processes reserving
1060 dnl 1TB of address space, we get the following error:
1061 dnl    VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete.
1062 dnl
1063
1064 AC_ARG_ENABLE(large-address-space,
1065     [AC_HELP_STRING([--enable-large-address-space],
1066         [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])],
1067     EnableLargeAddressSpace=$enableval,
1068     EnableLargeAddressSpace=yes
1069 )
1070
1071 use_large_address_space=no
1072 if test "$ac_cv_sizeof_void_p" -eq 8 ; then
1073     if test "x$EnableLargeAddressSpace" = "xyes" ; then
1074         if test "$ghc_host_os" = "darwin" ; then
1075             use_large_address_space=yes
1076         else
1077             AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[],
1078                 [
1079                 #include <unistd.h>
1080                 #include <sys/types.h>
1081                 #include <sys/mman.h>
1082                 #include <fcntl.h>
1083             ])
1084             if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" &&
1085                 test "$ac_cv_have_decl_MADV_FREE" = "yes" ||
1086                 test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then
1087                     use_large_address_space=yes
1088             fi
1089         fi
1090     fi
1091 fi
1092 if test "$use_large_address_space" = "yes" ; then
1093    AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support])
1094 fi
1095
1096 if test -n "$SPHINXBUILD"; then
1097     BUILD_MAN=YES
1098     BUILD_SPHINX_HTML=YES
1099     if test -n "$XELATEX"; then
1100         BUILD_SPHINX_PDF=YES
1101     else
1102         BUILD_SPHINX_PDF=NO
1103     fi
1104 else
1105     BUILD_MAN=NO
1106     BUILD_SPHINX_HTML=NO
1107     BUILD_SPHINX_PDF=NO
1108 fi
1109 AC_SUBST(BUILD_MAN)
1110 AC_SUBST(BUILD_SPHINX_HTML)
1111 AC_SUBST(BUILD_SPHINX_PDF)
1112
1113 LIBRARY_VERSION(base)
1114 LIBRARY_VERSION(Cabal, Cabal/Cabal)
1115 LIBRARY_VERSION(ghc-prim)
1116 LIBRARY_ghc_VERSION="$ProjectVersion"
1117 AC_SUBST(LIBRARY_ghc_VERSION)
1118
1119 if grep '       ' compiler/ghc.cabal.in 2>&1 >/dev/null; then
1120    AC_MSG_ERROR([compiler/ghc.cabal.in contains tab characters; please remove them])
1121 fi
1122
1123 AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal utils/runghc/runghc.cabal settings docs/users_guide/ghc_config.py docs/index.html libraries/prologue.txt distrib/configure.ac])
1124 AC_OUTPUT
1125
1126 # We got caught by
1127 #     http://savannah.gnu.org/bugs/index.php?1516
1128 #     $(eval ...) inside conditionals causes errors
1129 # with make 3.80, so warn the user if it looks like they're about to
1130 # try to use it.
1131 # We would use "grep -q" here, but Solaris's grep doesn't support it.
1132 checkMake380() {
1133     if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
1134     then
1135         echo
1136         echo "WARNING: It looks like \"$1\" is GNU make 3.80."
1137         echo "This version cannot be used to build GHC."
1138         echo "Please use GNU make >= 3.81."
1139     fi
1140 }
1141
1142 checkMake380 make
1143 checkMake380 gmake
1144
1145 echo ["
1146 ----------------------------------------------------------------------
1147 Configure completed successfully.
1148
1149    Building GHC version  : $ProjectVersion
1150           Git commit id  : $ProjectGitCommitId
1151
1152    Build platform        : $BuildPlatform
1153    Host platform         : $HostPlatform
1154    Target platform       : $TargetPlatform
1155 "]
1156
1157 echo ["\
1158    Bootstrapping using   : $WithGhc
1159       which is version   : $GhcVersion
1160 "]
1161
1162 if test "x$CC_LLVM_BACKEND" = "x1"; then
1163     if test "x$CC_CLANG_BACKEND" = "x1"; then
1164         CompilerName="clang        "
1165     else
1166         CompilerName="llvm-gcc     "
1167     fi
1168 else
1169     CompilerName="gcc          "
1170 fi
1171
1172 echo ["\
1173    Using $CompilerName       : $WhatGccIsCalled
1174       which is version       : $GccVersion
1175    Building a cross compiler : $CrossCompiling
1176    hs-cpp       : $HaskellCPPCmd
1177    hs-cpp-flags : $HaskellCPPArgs
1178    ld           : $LdCmd
1179    Happy        : $HappyCmd ($HappyVersion)
1180    Alex         : $AlexCmd ($AlexVersion)
1181    Perl         : $PerlCmd
1182    sphinx-build : $SPHINXBUILD
1183    xelatex      : $XELATEX
1184
1185    Using LLVM tools
1186       llc   : $LlcCmd
1187       opt   : $OptCmd"]
1188
1189 if test "$HSCOLOUR" = ""; then
1190 echo ["
1191    HsColour was not found; documentation will not contain source links
1192 "]
1193 else
1194 echo ["\
1195    HsColour : $HSCOLOUR
1196 "]
1197 fi
1198
1199 echo ["\
1200    Tools to build Sphinx HTML documentation available: $BUILD_SPHINX_HTML
1201    Tools to build Sphinx PDF documentation available: $BUILD_SPHINX_PDF"]
1202
1203 echo ["----------------------------------------------------------------------
1204 "]
1205
1206 echo "\
1207 For a standard build of GHC (fully optimised with profiling), type (g)make.
1208
1209 To make changes to the default build configuration, copy the file
1210 mk/build.mk.sample to mk/build.mk, and edit the settings in there.
1211
1212 For more information on how to configure your GHC build, see
1213    http://ghc.haskell.org/trac/ghc/wiki/Building
1214 "