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