Rename PACKAGE_KEY and LIB_NAME in build system.
[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_COMPONENT_ID=NO,
164                     SUPPORTS_COMPONENT_ID=YES)
165 AC_SUBST(SUPPORTS_COMPONENT_ID)
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.7
557 AC_SUBST([LlvmVersion])
558 sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/')
559 AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number])
560
561 dnl ** Which LLVM llc to use?
562 dnl --------------------------------------------------------------
563 FIND_LLVM_PROG([LLC], [llc], [llc], [$LlvmVersion])
564 LlcCmd="$LLC"
565 AC_SUBST([LlcCmd])
566
567 dnl ** Which LLVM opt to use?
568 dnl --------------------------------------------------------------
569 FIND_LLVM_PROG([OPT], [opt], [opt], [$LlvmVersion])
570 OptCmd="$OPT"
571 AC_SUBST([OptCmd])
572
573 dnl --------------------------------------------------------------
574 dnl End of configure script option section
575 dnl --------------------------------------------------------------
576
577
578 dnl --------------------------------------------------------------
579 dnl * General configuration checks
580 dnl --------------------------------------------------------------
581
582 dnl ** Bug 9439: Some GHC 7.8 releases had broken LLVM code generator.
583 dnl Unfortunately we don't know whether the user is going to request a
584 dnl build with the LLVM backend as this is only given in build.mk.
585 dnl
586 dnl Instead, we try to do as much work as possible here, checking
587 dnl whether -fllvm is the stage 0 compiler's default. If so we
588 dnl fail. If not, we check whether -fllvm is affected explicitly and
589 dnl if so set a flag. The build system will later check this flag
590 dnl after the desired build flags are known.
591
592 dnl This problem is further complicated by the fact that the llvm
593 dnl version used by the bootstrap compiler may be different from the
594 dnl version we arre trying to compile GHC against. Therefore, we need
595 dnl to find the boostrap compiler's `settings` file then check to see
596 dnl if the `opt` and `llc` command strings are non-empty and if these
597 dnl programs exist. Only if they exist to we test for bug #9439.
598
599 FIND_GHC_BOOTSTRAP_PROG([BootstrapLlcCmd], [${WithGhc}], "LLVM llc command")
600 FIND_GHC_BOOTSTRAP_PROG([BootstrapOptCmd], [${WithGhc}], "LLVM opt command")
601
602 if test -n "$BootstrapLlcCmd" && test -n "$BootstrapOptCmd"
603 then
604     AC_MSG_CHECKING(whether bootstrap compiler is affected by bug 9439)
605     echo "main = putStrLn \"%function\"" > conftestghc.hs
606
607     # Check whether LLVM backend is default for this platform
608     "${WithGhc}" -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" conftestghc.hs 2>&1 >/dev/null
609     res=`./conftestghc`
610     if test "x$res" = "x%object"
611     then
612         AC_MSG_RESULT(yes)
613         echo "Buggy bootstrap compiler"
614         echo ""
615         echo "The stage 0 compiler $WithGhc is affected by GHC Bug \#9439"
616         echo "and therefore will miscompile the LLVM backend if -fllvm is"
617         echo "used."
618         echo
619         echo "Please use another bootstrap compiler"
620         exit 1
621     fi
622
623     # -fllvm is not the default, but set a flag so the Makefile can check
624     # -for it in the build flags later on
625     "${WithGhc}" -fforce-recomp -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" -fllvm conftestghc.hs 2>&1 >/dev/null
626     if test $? = 0
627     then
628         res=`./conftestghc`
629         if test "x$res" = "x%object"
630         then
631             AC_MSG_RESULT(yes)
632             GHC_LLVM_AFFECTED_BY_9439=1
633         elif test "x$res" = "x%function"
634         then
635             AC_MSG_RESULT(no)
636             GHC_LLVM_AFFECTED_BY_9439=0
637         else
638             AC_MSG_WARN(unexpected output $res)
639         fi
640     else
641         AC_MSG_RESULT(failed to compile, assuming no)
642     fi
643 fi
644 AC_SUBST([GHC_LLVM_AFFECTED_BY_9439])
645
646 dnl ** Can the unix package be built?
647 dnl --------------------------------------------------------------
648
649 if test "$TargetOS" = "mingw32"
650 then
651     GhcLibsWithUnix=NO
652 else
653     GhcLibsWithUnix=YES
654 fi
655 AC_SUBST([GhcLibsWithUnix])
656
657 dnl ** does #! work?
658 AC_SYS_INTERPRETER()
659
660 dnl ** look for `perl'
661 case $HostOS_CPP in
662 cygwin32|mingw32)
663     PerlCmd=$hardtop/inplace/perl/perl
664     ;;
665 *)
666     AC_PATH_PROG(PerlCmd,perl)
667     if test -z "$PerlCmd"
668     then
669         echo "You must install perl before you can continue"
670         echo "Perhaps it is already installed, but not in your PATH?"
671         exit 1
672     else
673         FPTOOLS_CHECK_PERL_VERSION
674     fi
675     ;;
676 esac
677
678 dnl ** look for GCC and find out which version
679 dnl     Figure out which C compiler to use.  Gcc is preferred.
680 dnl     If gcc, make sure it's at least 3.0
681 dnl
682 FP_GCC_VERSION
683
684 dnl ** look to see if we have a C compiler using an llvm back end.
685 dnl
686 FP_CC_LLVM_BACKEND
687
688 FP_PROG_LD_IS_GNU
689 FP_PROG_LD_BUILD_ID
690 FP_PROG_LD_NO_COMPACT_UNWIND
691 FP_PROG_LD_FILELIST
692
693
694 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
695 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
696 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
697 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
698 # Stage 3 won't be supported by cross-compilation
699
700 FP_GCC_EXTRA_FLAGS
701
702 AC_SUBST(CONF_CC_OPTS_STAGE0)
703 AC_SUBST(CONF_CC_OPTS_STAGE1)
704 AC_SUBST(CONF_CC_OPTS_STAGE2)
705 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
706 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
707 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
708 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
709 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
710 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
711 AC_SUBST(CONF_CPP_OPTS_STAGE0)
712 AC_SUBST(CONF_CPP_OPTS_STAGE1)
713 AC_SUBST(CONF_CPP_OPTS_STAGE2)
714
715 dnl ** Set up the variables for the platform in the settings file.
716 dnl May need to use gcc to find platform details.
717 dnl --------------------------------------------------------------
718 FPTOOLS_SET_HASKELL_PLATFORM_VARS
719
720 dnl ** figure out how to do context diffs
721 FP_PROG_CONTEXT_DIFF
722
723 dnl Let's make sure install-sh is executable here.  If we got it from
724 dnl a darcs repo, it might not be (see bug #978).
725 chmod +x install-sh
726 dnl ** figure out how to do a BSD-ish install
727 AC_PROG_INSTALL
728
729 dnl ** how to invoke `ar' and `ranlib'
730 FP_PROG_AR_SUPPORTS_ATFILE
731 FP_PROG_AR_NEEDS_RANLIB
732
733 dnl ** Check to see whether ln -s works
734 AC_PROG_LN_S
735
736 FP_SETTINGS
737
738 dnl ** Find the path to sed
739 AC_PATH_PROGS(SedCmd,gsed sed,sed)
740
741
742 dnl ** check for time command
743 AC_PATH_PROG(TimeCmd,time)
744
745 dnl ** check for tar
746 dnl   if GNU tar is named gtar, look for it first.
747 AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar)
748
749 dnl ** check for patch
750 dnl if GNU patch is named gpatch, look for it first
751 AC_PATH_PROGS(PatchCmd,gpatch patch, patch)
752
753 dnl ** check for dtrace (currently only implemented for Mac OS X)
754 HaveDtrace=NO
755 AC_PATH_PROG(DtraceCmd,dtrace)
756 if test -n "$DtraceCmd"; then
757   if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then
758     HaveDtrace=YES
759   fi
760 fi
761 AC_SUBST(HaveDtrace)
762
763 AC_PATH_PROG(HSCOLOUR,HsColour)
764 # HsColour is passed to Cabal, so we need a native path
765 if test "$HostOS"      = "mingw32" && \
766    test "${OSTYPE}"   != "msys"    && \
767    test "${HSCOLOUR}" != ""
768 then
769     # Canonicalise to <drive>:/path/to/gcc
770     HSCOLOUR=`cygpath -m ${HSCOLOUR}`
771 fi
772
773 dnl ** check for Sphinx toolchain
774 AC_PATH_PROG(SPHINXBUILD,sphinx-build)
775
776 dnl ** check for xelatex
777 AC_PATH_PROG(XELATEX,xelatex)
778
779 dnl ** check for ghc-pkg command
780 FP_PROG_GHC_PKG
781
782 dnl ** check for installed happy binary + version
783 FPTOOLS_HAPPY
784
785 dnl ** check for installed alex binary + version
786 FPTOOLS_ALEX
787
788 dnl --------------------------------------------------
789 dnl ### program checking section ends here ###
790 dnl --------------------------------------------------
791
792 dnl --------------------------------------------------
793 dnl * Platform header file and syscall feature tests
794 dnl ### checking the state of the local header files and syscalls ###
795
796 dnl ** check for full ANSI header (.h) files
797 AC_HEADER_STDC
798
799 dnl ** Enable large file support.  NB. do this before testing the type of
800 dnl    off_t, because it will affect the result of that test.
801 AC_SYS_LARGEFILE
802
803 dnl ** check for specific header (.h) files that we are interested in
804 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])
805
806 dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
807 AC_CHECK_HEADERS([sys/cpuset.h], [], [],
808 [[#if HAVE_SYS_PARAM_H
809 # include <sys/param.h>
810 #endif
811 ]])
812
813 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
814 AC_HEADER_TIME
815
816 dnl ** do we have long longs?
817 AC_CHECK_TYPES([long long])
818
819 dnl ** what are the sizes of various types
820 AC_CHECK_SIZEOF(char,               1)
821 AC_CHECK_SIZEOF(double,             8)
822 AC_CHECK_SIZEOF(float,              4)
823 AC_CHECK_SIZEOF(int,                4)
824 AC_CHECK_SIZEOF(long,               4)
825 if test "$ac_cv_type_long_long" = yes; then
826 AC_CHECK_SIZEOF(long long,          8)
827 fi
828 AC_CHECK_SIZEOF(short,              2)
829 AC_CHECK_SIZEOF(unsigned char,      1)
830 AC_CHECK_SIZEOF(unsigned int,       4)
831 AC_CHECK_SIZEOF(unsigned long,      4)
832 if test "$ac_cv_type_long_long" = yes; then
833 AC_CHECK_SIZEOF(unsigned long long, 8)
834 fi
835 AC_CHECK_SIZEOF(unsigned short,     2)
836 AC_CHECK_SIZEOF(void *,             4)
837
838 dnl for use in settings.in
839 WordSize=$ac_cv_sizeof_void_p
840 AC_SUBST(WordSize)
841
842 dnl ** what are alignment constraints on various types
843 FP_CHECK_ALIGNMENT(char)
844 FP_CHECK_ALIGNMENT(double)
845 FP_CHECK_ALIGNMENT(float)
846 FP_CHECK_ALIGNMENT(int)
847 FP_CHECK_ALIGNMENT(long)
848 if test "$ac_cv_type_long_long" = yes; then
849 FP_CHECK_ALIGNMENT(long long)
850 fi
851 FP_CHECK_ALIGNMENT(short)
852 FP_CHECK_ALIGNMENT(unsigned char)
853 FP_CHECK_ALIGNMENT(unsigned int)
854 FP_CHECK_ALIGNMENT(unsigned long)
855 if test "$ac_cv_type_long_long" = yes; then
856 FP_CHECK_ALIGNMENT(unsigned long long)
857 fi
858 FP_CHECK_ALIGNMENT(unsigned short)
859 FP_CHECK_ALIGNMENT(void *)
860
861 FP_CHECK_FUNC([WinExec],
862   [@%:@include <windows.h>], [WinExec("",0)])
863
864 FP_CHECK_FUNC([GetModuleFileName],
865   [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
866
867 dnl ** check for more functions
868 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
869 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity setlocale])
870
871 dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
872 dnl ** _POSIX_C_SOURCE is defined
873 AC_CHECK_DECLS([ctime_r], , ,
874 [#define _POSIX_SOURCE 1
875 #define _POSIX_C_SOURCE 199506L
876 #include <time.h>])
877
878 dnl ** check for mingwex library
879 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
880 AC_SUBST(HaveLibMingwEx)
881
882 if test $HaveLibMingwEx = YES ; then
883   AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
884 fi
885
886 dnl ** check for math library
887 dnl    Keep that check as early as possible.
888 dnl    as we need to know whether we need libm
889 dnl    for math functions or not
890 dnl    (see http://ghc.haskell.org/trac/ghc/ticket/3730)
891 AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO)
892 if test $HaveLibM = YES
893 then
894   AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])
895 fi
896
897 FP_BFD_SUPPORT
898
899 dnl ################################################################
900 dnl Check for libraries
901 dnl ################################################################
902
903 # system libffi
904
905 AC_ARG_WITH([system-libffi],
906 [AC_HELP_STRING([--with-system-libffi],
907   [Use system provided libffi for RTS [default=no]])
908 ])
909
910 AS_IF([test "x$with_system_libffi" = "xyes"],
911   [UseSystemLibFFI="YES"], [UseSystemLibFFI="NO"]
912 )
913
914
915 AC_SUBST(UseSystemLibFFI)
916
917 AC_ARG_WITH([ffi-includes],
918 [AC_HELP_STRING([--with-ffi-includes=ARG],
919   [Find includes for libffi in ARG [default=system default]])
920 ],
921 [
922  if test "x$UseSystemLibFFI" != "xYES"; then
923     AC_MSG_WARN([--with-ffi-includes will be ignored, --with-system-libffi not set])
924  else
925     FFIIncludeDir="$withval"
926     LIBFFI_CFLAGS="-I$withval"
927  fi
928 ])
929
930 AC_SUBST(FFIIncludeDir)
931
932 AC_ARG_WITH([ffi-libraries],
933 [AC_HELP_STRING([--with-ffi-libraries=ARG],
934   [Find libffi in ARG [default=system default]])
935 ],
936 [
937  if test "x$UseSystemLibFFI" != "xYES"; then
938     AC_MSG_WARN([--with-ffi-libraries will be ignored, --with-system-libffi not set])
939  else
940     FFILibDir="$withval" LIBFFI_LDFLAGS="-L$withval"
941  fi
942 ])
943
944 AC_SUBST(FFILibDir)
945
946 AS_IF([test "$UseSystemLibFFI" = "YES"], [
947  CFLAGS2="$CFLAGS"
948  CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
949  LDFLAGS2="$LDFLAGS"
950  LDFLAGS="$LIBFFI_LDFLAGS $LDFLAGS"
951  AC_CHECK_LIB(ffi, ffi_call,
952   [AC_CHECK_HEADERS([ffi.h], [break], [])
953    AC_DEFINE([HAVE_LIBFFI], [1], [Define to 1 if you have libffi.])],
954   [AC_MSG_ERROR([Cannot find system libffi])])
955  CFLAGS="$CFLAGS2"
956  LDFLAGS="$LDFLAGS2"
957 ])
958
959 dnl ** check whether we need -ldl to get dlopen()
960 AC_CHECK_LIB(dl, dlopen)
961
962 dnl --------------------------------------------------
963 dnl * Miscellaneous feature tests
964 dnl --------------------------------------------------
965
966 dnl ** can we get alloca?
967 AC_FUNC_ALLOCA
968
969 dnl ** working vfork?
970 AC_FUNC_FORK
971
972 dnl ** determine whether or not const works
973 AC_C_CONST
974
975 dnl ** are we big endian?
976 AC_C_BIGENDIAN
977 FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
978
979 dnl ** check for leading underscores in symbol names
980 FP_LEADING_UNDERSCORE
981
982 FP_VISIBILITY_HIDDEN
983
984 dnl ** check for librt
985 AC_CHECK_LIB(rt, clock_gettime)
986 AC_CHECK_FUNCS(clock_gettime timer_settime)
987 FP_CHECK_TIMER_CREATE
988
989 dnl ** check for Apple's "interesting" long double compatibility scheme
990 AC_MSG_CHECKING(for printf\$LDBLStub)
991 AC_TRY_LINK_FUNC(printf\$LDBLStub,
992     [
993         AC_MSG_RESULT(yes)
994         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
995             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
996     ],
997     [
998         AC_MSG_RESULT(no)
999         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
1000             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
1001     ])
1002
1003 dnl ** pthread_setname_np is a recent addition to glibc, and OS X has
1004 dnl    a different single-argument version.
1005 AC_CHECK_LIB(pthread, pthread_setname_np)
1006 AC_MSG_CHECKING(for pthread_setname_np)
1007 AC_TRY_LINK(
1008 [
1009 #define _GNU_SOURCE
1010 #include <pthread.h>
1011 ],
1012 [pthread_setname_np(pthread_self(), "name");],
1013     AC_MSG_RESULT(yes)
1014     AC_DEFINE([HAVE_PTHREAD_SETNAME_NP], [1],
1015       [Define to 1 if you have the glibc version of pthread_setname_np]),
1016     AC_MSG_RESULT(no)
1017 )
1018
1019 dnl ** check for eventfd which is needed by the I/O manager
1020 AC_CHECK_HEADERS([sys/eventfd.h])
1021 AC_CHECK_FUNCS([eventfd])
1022
1023 dnl ** Check for __thread support in the compiler
1024 AC_MSG_CHECKING(for __thread support)
1025 AC_COMPILE_IFELSE(
1026   [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ],
1027   [
1028    AC_MSG_RESULT(yes)
1029    AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported])
1030   ],
1031   [
1032    AC_MSG_RESULT(no)
1033    AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported])
1034   ])
1035
1036
1037 dnl ** checking for PAPI
1038 AC_CHECK_LIB(papi, PAPI_library_init, HavePapiLib=YES, HavePapiLib=NO)
1039 AC_CHECK_HEADER([papi.h], [HavePapiHeader=YES], [HavePapiHeader=NO])
1040 AC_SUBST(HavePapiLib)
1041 AC_SUBST(HavePapiHeader)
1042
1043 AC_CHECK_FUNCS(__mingw_vfprintf)
1044
1045 if test "$HavePapiLib" = "YES" -a "$HavePapiHeader" = "YES"; then
1046    HavePapi=YES
1047 else
1048    HavePapi=NO
1049 fi
1050 AC_SUBST(HavePapi)
1051
1052 dnl large address space support (see includes/rts/storage/MBlock.h)
1053 dnl
1054 dnl Darwin has vm_allocate/vm_protect
1055 dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED)
1056 dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE
1057 dnl (They also have MADV_DONTNEED, but it means something else!)
1058 dnl
1059 dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however
1060 dnl it counts page-table space as committed memory, and so quickly
1061 dnl runs out of paging file when we have multiple processes reserving
1062 dnl 1TB of address space, we get the following error:
1063 dnl    VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete.
1064 dnl
1065
1066 AC_ARG_ENABLE(large-address-space,
1067     [AC_HELP_STRING([--enable-large-address-space],
1068         [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])],
1069     EnableLargeAddressSpace=$enableval,
1070     EnableLargeAddressSpace=yes
1071 )
1072
1073 use_large_address_space=no
1074 if test "$ac_cv_sizeof_void_p" -eq 8 ; then
1075     if test "x$EnableLargeAddressSpace" = "xyes" ; then
1076         if test "$ghc_host_os" = "darwin" ; then
1077             use_large_address_space=yes
1078         else
1079             AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[],
1080                 [
1081                 #include <unistd.h>
1082                 #include <sys/types.h>
1083                 #include <sys/mman.h>
1084                 #include <fcntl.h>
1085             ])
1086             if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" &&
1087                 test "$ac_cv_have_decl_MADV_FREE" = "yes" ||
1088                 test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then
1089                     use_large_address_space=yes
1090             fi
1091         fi
1092     fi
1093 fi
1094 if test "$use_large_address_space" = "yes" ; then
1095    AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support])
1096 fi
1097
1098 if test -n "$SPHINXBUILD"; then
1099     BUILD_MAN=YES
1100     BUILD_SPHINX_HTML=YES
1101     if test -n "$XELATEX"; then
1102         BUILD_SPHINX_PDF=YES
1103     else
1104         BUILD_SPHINX_PDF=NO
1105     fi
1106 else
1107     BUILD_MAN=NO
1108     BUILD_SPHINX_HTML=NO
1109     BUILD_SPHINX_PDF=NO
1110 fi
1111 AC_SUBST(BUILD_MAN)
1112 AC_SUBST(BUILD_SPHINX_HTML)
1113 AC_SUBST(BUILD_SPHINX_PDF)
1114
1115 LIBRARY_VERSION(base)
1116 LIBRARY_VERSION(Cabal, Cabal/Cabal)
1117 LIBRARY_VERSION(ghc-prim)
1118 LIBRARY_ghc_VERSION="$ProjectVersion"
1119 AC_SUBST(LIBRARY_ghc_VERSION)
1120
1121 if grep '       ' compiler/ghc.cabal.in 2>&1 >/dev/null; then
1122    AC_MSG_ERROR([compiler/ghc.cabal.in contains tab characters; please remove them])
1123 fi
1124
1125 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])
1126 AC_OUTPUT
1127
1128 # We got caught by
1129 #     http://savannah.gnu.org/bugs/index.php?1516
1130 #     $(eval ...) inside conditionals causes errors
1131 # with make 3.80, so warn the user if it looks like they're about to
1132 # try to use it.
1133 # We would use "grep -q" here, but Solaris's grep doesn't support it.
1134 checkMake380() {
1135     if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
1136     then
1137         echo
1138         echo "WARNING: It looks like \"$1\" is GNU make 3.80."
1139         echo "This version cannot be used to build GHC."
1140         echo "Please use GNU make >= 3.81."
1141     fi
1142 }
1143
1144 checkMake380 make
1145 checkMake380 gmake
1146
1147 echo ["
1148 ----------------------------------------------------------------------
1149 Configure completed successfully.
1150
1151    Building GHC version  : $ProjectVersion
1152           Git commit id  : $ProjectGitCommitId
1153
1154    Build platform        : $BuildPlatform
1155    Host platform         : $HostPlatform
1156    Target platform       : $TargetPlatform
1157 "]
1158
1159 echo ["\
1160    Bootstrapping using   : $WithGhc
1161       which is version   : $GhcVersion
1162 "]
1163
1164 if test "x$CC_LLVM_BACKEND" = "x1"; then
1165     if test "x$CC_CLANG_BACKEND" = "x1"; then
1166         CompilerName="clang        "
1167     else
1168         CompilerName="llvm-gcc     "
1169     fi
1170 else
1171     CompilerName="gcc          "
1172 fi
1173
1174 echo ["\
1175    Using $CompilerName       : $WhatGccIsCalled
1176       which is version       : $GccVersion
1177    Building a cross compiler : $CrossCompiling
1178    hs-cpp       : $HaskellCPPCmd
1179    hs-cpp-flags : $HaskellCPPArgs
1180    ld           : $LdCmd
1181    Happy        : $HappyCmd ($HappyVersion)
1182    Alex         : $AlexCmd ($AlexVersion)
1183    Perl         : $PerlCmd
1184    sphinx-build : $SPHINXBUILD
1185    xelatex      : $XELATEX
1186
1187    Using LLVM tools
1188       llc   : $LlcCmd
1189       opt   : $OptCmd"]
1190
1191 if test "$HSCOLOUR" = ""; then
1192 echo ["
1193    HsColour was not found; documentation will not contain source links
1194 "]
1195 else
1196 echo ["\
1197    HsColour : $HSCOLOUR
1198 "]
1199 fi
1200
1201 echo ["\
1202    Tools to build Sphinx HTML documentation available: $BUILD_SPHINX_HTML
1203    Tools to build Sphinx PDF documentation available: $BUILD_SPHINX_PDF"]
1204
1205 echo ["----------------------------------------------------------------------
1206 "]
1207
1208 echo "\
1209 For a standard build of GHC (fully optimised with profiling), type (g)make.
1210
1211 To make changes to the default build configuration, copy the file
1212 mk/build.mk.sample to mk/build.mk, and edit the settings in there.
1213
1214 For more information on how to configure your GHC build, see
1215    http://ghc.haskell.org/trac/ghc/wiki/Building
1216 "