Verify minimum required version of sphinx-build
[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 AC_CACHE_CHECK([for version of sphinx-build], sphinx_version,
776 changequote(, )dnl
777 [if test -n "$SPHINXBUILD"; then
778   sphinx_version=`"$SPHINXBUILD" --version | sed 's/Sphinx (sphinx-build) \([0-9]\.[0-9]\.[0-9]\)/\1/'`;
779 fi;
780 changequote([, ])dnl
781 ])
782 FP_COMPARE_VERSIONS([$sphinx_version],-lt,1.0.0,
783     [AC_MSG_ERROR([Sphinx version 1.0.0 or later is required to build documentation]); SPHINXBUILD=;])
784
785 dnl ** check for xelatex
786 AC_PATH_PROG(XELATEX,xelatex)
787
788 dnl ** check for ghc-pkg command
789 FP_PROG_GHC_PKG
790
791 dnl ** check for installed happy binary + version
792 FPTOOLS_HAPPY
793
794 dnl ** check for installed alex binary + version
795 FPTOOLS_ALEX
796
797 dnl --------------------------------------------------
798 dnl ### program checking section ends here ###
799 dnl --------------------------------------------------
800
801 dnl --------------------------------------------------
802 dnl * Platform header file and syscall feature tests
803 dnl ### checking the state of the local header files and syscalls ###
804
805 dnl ** check for full ANSI header (.h) files
806 AC_HEADER_STDC
807
808 dnl ** Enable large file support.  NB. do this before testing the type of
809 dnl    off_t, because it will affect the result of that test.
810 AC_SYS_LARGEFILE
811
812 dnl ** check for specific header (.h) files that we are interested in
813 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])
814
815 dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
816 AC_CHECK_HEADERS([sys/cpuset.h], [], [],
817 [[#if HAVE_SYS_PARAM_H
818 # include <sys/param.h>
819 #endif
820 ]])
821
822 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
823 AC_HEADER_TIME
824
825 dnl ** do we have long longs?
826 AC_CHECK_TYPES([long long])
827
828 dnl ** what are the sizes of various types
829 AC_CHECK_SIZEOF(char,               1)
830 AC_CHECK_SIZEOF(double,             8)
831 AC_CHECK_SIZEOF(float,              4)
832 AC_CHECK_SIZEOF(int,                4)
833 AC_CHECK_SIZEOF(long,               4)
834 if test "$ac_cv_type_long_long" = yes; then
835 AC_CHECK_SIZEOF(long long,          8)
836 fi
837 AC_CHECK_SIZEOF(short,              2)
838 AC_CHECK_SIZEOF(unsigned char,      1)
839 AC_CHECK_SIZEOF(unsigned int,       4)
840 AC_CHECK_SIZEOF(unsigned long,      4)
841 if test "$ac_cv_type_long_long" = yes; then
842 AC_CHECK_SIZEOF(unsigned long long, 8)
843 fi
844 AC_CHECK_SIZEOF(unsigned short,     2)
845 AC_CHECK_SIZEOF(void *,             4)
846
847 dnl for use in settings.in
848 WordSize=$ac_cv_sizeof_void_p
849 AC_SUBST(WordSize)
850
851 dnl ** what are alignment constraints on various types
852 FP_CHECK_ALIGNMENT(char)
853 FP_CHECK_ALIGNMENT(double)
854 FP_CHECK_ALIGNMENT(float)
855 FP_CHECK_ALIGNMENT(int)
856 FP_CHECK_ALIGNMENT(long)
857 if test "$ac_cv_type_long_long" = yes; then
858 FP_CHECK_ALIGNMENT(long long)
859 fi
860 FP_CHECK_ALIGNMENT(short)
861 FP_CHECK_ALIGNMENT(unsigned char)
862 FP_CHECK_ALIGNMENT(unsigned int)
863 FP_CHECK_ALIGNMENT(unsigned long)
864 if test "$ac_cv_type_long_long" = yes; then
865 FP_CHECK_ALIGNMENT(unsigned long long)
866 fi
867 FP_CHECK_ALIGNMENT(unsigned short)
868 FP_CHECK_ALIGNMENT(void *)
869
870 FP_CHECK_FUNC([WinExec],
871   [@%:@include <windows.h>], [WinExec("",0)])
872
873 FP_CHECK_FUNC([GetModuleFileName],
874   [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
875
876 dnl ** check for more functions
877 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
878 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity setlocale])
879
880 dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
881 dnl ** _POSIX_C_SOURCE is defined
882 AC_CHECK_DECLS([ctime_r], , ,
883 [#define _POSIX_SOURCE 1
884 #define _POSIX_C_SOURCE 199506L
885 #include <time.h>])
886
887 dnl ** check for mingwex library
888 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
889 AC_SUBST(HaveLibMingwEx)
890
891 if test $HaveLibMingwEx = YES ; then
892   AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
893 fi
894
895 dnl ** check for math library
896 dnl    Keep that check as early as possible.
897 dnl    as we need to know whether we need libm
898 dnl    for math functions or not
899 dnl    (see http://ghc.haskell.org/trac/ghc/ticket/3730)
900 AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO)
901 if test $HaveLibM = YES
902 then
903   AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])
904 fi
905
906 FP_BFD_SUPPORT
907
908 dnl ################################################################
909 dnl Check for libraries
910 dnl ################################################################
911
912 # system libffi
913
914 AC_ARG_WITH([system-libffi],
915 [AC_HELP_STRING([--with-system-libffi],
916   [Use system provided libffi for RTS [default=no]])
917 ])
918
919 AS_IF([test "x$with_system_libffi" = "xyes"],
920   [UseSystemLibFFI="YES"], [UseSystemLibFFI="NO"]
921 )
922
923
924 AC_SUBST(UseSystemLibFFI)
925
926 AC_ARG_WITH([ffi-includes],
927 [AC_HELP_STRING([--with-ffi-includes=ARG],
928   [Find includes for libffi in ARG [default=system default]])
929 ],
930 [
931  if test "x$UseSystemLibFFI" != "xYES"; then
932     AC_MSG_WARN([--with-ffi-includes will be ignored, --with-system-libffi not set])
933  else
934     FFIIncludeDir="$withval"
935     LIBFFI_CFLAGS="-I$withval"
936  fi
937 ])
938
939 AC_SUBST(FFIIncludeDir)
940
941 AC_ARG_WITH([ffi-libraries],
942 [AC_HELP_STRING([--with-ffi-libraries=ARG],
943   [Find libffi in ARG [default=system default]])
944 ],
945 [
946  if test "x$UseSystemLibFFI" != "xYES"; then
947     AC_MSG_WARN([--with-ffi-libraries will be ignored, --with-system-libffi not set])
948  else
949     FFILibDir="$withval" LIBFFI_LDFLAGS="-L$withval"
950  fi
951 ])
952
953 AC_SUBST(FFILibDir)
954
955 AS_IF([test "$UseSystemLibFFI" = "YES"], [
956  CFLAGS2="$CFLAGS"
957  CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
958  LDFLAGS2="$LDFLAGS"
959  LDFLAGS="$LIBFFI_LDFLAGS $LDFLAGS"
960  AC_CHECK_LIB(ffi, ffi_call,
961   [AC_CHECK_HEADERS([ffi.h], [break], [])
962    AC_DEFINE([HAVE_LIBFFI], [1], [Define to 1 if you have libffi.])],
963   [AC_MSG_ERROR([Cannot find system libffi])])
964  CFLAGS="$CFLAGS2"
965  LDFLAGS="$LDFLAGS2"
966 ])
967
968 dnl ** check whether we need -ldl to get dlopen()
969 AC_CHECK_LIB(dl, dlopen)
970
971 dnl --------------------------------------------------
972 dnl * Miscellaneous feature tests
973 dnl --------------------------------------------------
974
975 dnl ** can we get alloca?
976 AC_FUNC_ALLOCA
977
978 dnl ** working vfork?
979 AC_FUNC_FORK
980
981 dnl ** determine whether or not const works
982 AC_C_CONST
983
984 dnl ** are we big endian?
985 AC_C_BIGENDIAN
986 FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
987
988 dnl ** check for leading underscores in symbol names
989 FP_LEADING_UNDERSCORE
990
991 FP_VISIBILITY_HIDDEN
992
993 dnl ** check for librt
994 AC_CHECK_LIB(rt, clock_gettime)
995 AC_CHECK_FUNCS(clock_gettime timer_settime)
996 FP_CHECK_TIMER_CREATE
997
998 dnl ** check for Apple's "interesting" long double compatibility scheme
999 AC_MSG_CHECKING(for printf\$LDBLStub)
1000 AC_TRY_LINK_FUNC(printf\$LDBLStub,
1001     [
1002         AC_MSG_RESULT(yes)
1003         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
1004             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
1005     ],
1006     [
1007         AC_MSG_RESULT(no)
1008         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
1009             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
1010     ])
1011
1012 dnl ** pthread_setname_np is a recent addition to glibc, and OS X has
1013 dnl    a different single-argument version.
1014 AC_CHECK_LIB(pthread, pthread_setname_np)
1015 AC_MSG_CHECKING(for pthread_setname_np)
1016 AC_TRY_LINK(
1017 [
1018 #define _GNU_SOURCE
1019 #include <pthread.h>
1020 ],
1021 [pthread_setname_np(pthread_self(), "name");],
1022     AC_MSG_RESULT(yes)
1023     AC_DEFINE([HAVE_PTHREAD_SETNAME_NP], [1],
1024       [Define to 1 if you have the glibc version of pthread_setname_np]),
1025     AC_MSG_RESULT(no)
1026 )
1027
1028 dnl ** check for eventfd which is needed by the I/O manager
1029 AC_CHECK_HEADERS([sys/eventfd.h])
1030 AC_CHECK_FUNCS([eventfd])
1031
1032 dnl ** Check for __thread support in the compiler
1033 AC_MSG_CHECKING(for __thread support)
1034 AC_COMPILE_IFELSE(
1035   [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ],
1036   [
1037    AC_MSG_RESULT(yes)
1038    AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported])
1039   ],
1040   [
1041    AC_MSG_RESULT(no)
1042    AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported])
1043   ])
1044
1045
1046 dnl ** checking for PAPI
1047 AC_CHECK_LIB(papi, PAPI_library_init, HavePapiLib=YES, HavePapiLib=NO)
1048 AC_CHECK_HEADER([papi.h], [HavePapiHeader=YES], [HavePapiHeader=NO])
1049 AC_SUBST(HavePapiLib)
1050 AC_SUBST(HavePapiHeader)
1051
1052 AC_CHECK_FUNCS(__mingw_vfprintf)
1053
1054 if test "$HavePapiLib" = "YES" -a "$HavePapiHeader" = "YES"; then
1055    HavePapi=YES
1056 else
1057    HavePapi=NO
1058 fi
1059 AC_SUBST(HavePapi)
1060
1061 dnl large address space support (see includes/rts/storage/MBlock.h)
1062 dnl
1063 dnl Darwin has vm_allocate/vm_protect
1064 dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED)
1065 dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE
1066 dnl (They also have MADV_DONTNEED, but it means something else!)
1067 dnl
1068 dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however
1069 dnl it counts page-table space as committed memory, and so quickly
1070 dnl runs out of paging file when we have multiple processes reserving
1071 dnl 1TB of address space, we get the following error:
1072 dnl    VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete.
1073 dnl
1074
1075 AC_ARG_ENABLE(large-address-space,
1076     [AC_HELP_STRING([--enable-large-address-space],
1077         [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])],
1078     EnableLargeAddressSpace=$enableval,
1079     EnableLargeAddressSpace=yes
1080 )
1081
1082 use_large_address_space=no
1083 if test "$ac_cv_sizeof_void_p" -eq 8 ; then
1084     if test "x$EnableLargeAddressSpace" = "xyes" ; then
1085         if test "$ghc_host_os" = "darwin" ; then
1086             use_large_address_space=yes
1087         else
1088             AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[],
1089                 [
1090                 #include <unistd.h>
1091                 #include <sys/types.h>
1092                 #include <sys/mman.h>
1093                 #include <fcntl.h>
1094             ])
1095             if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" &&
1096                 test "$ac_cv_have_decl_MADV_FREE" = "yes" ||
1097                 test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then
1098                     use_large_address_space=yes
1099             fi
1100         fi
1101     fi
1102 fi
1103 if test "$use_large_address_space" = "yes" ; then
1104    AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support])
1105 fi
1106
1107 AC_CHECK_LIB(dw, dwfl_begin, [HaveLibdw=YES], [HaveLibdw=NO])
1108 AC_SUBST(HaveLibdw)
1109
1110 if test -n "$SPHINXBUILD"; then
1111     BUILD_MAN=YES
1112     BUILD_SPHINX_HTML=YES
1113     if test -n "$XELATEX"; then
1114         BUILD_SPHINX_PDF=YES
1115     else
1116         BUILD_SPHINX_PDF=NO
1117     fi
1118 else
1119     BUILD_MAN=NO
1120     BUILD_SPHINX_HTML=NO
1121     BUILD_SPHINX_PDF=NO
1122 fi
1123 AC_SUBST(BUILD_MAN)
1124 AC_SUBST(BUILD_SPHINX_HTML)
1125 AC_SUBST(BUILD_SPHINX_PDF)
1126
1127 LIBRARY_VERSION(base)
1128 LIBRARY_VERSION(Cabal, Cabal/Cabal)
1129 LIBRARY_VERSION(ghc-prim)
1130 LIBRARY_ghc_VERSION="$ProjectVersion"
1131 AC_SUBST(LIBRARY_ghc_VERSION)
1132
1133 if grep '       ' compiler/ghc.cabal.in 2>&1 >/dev/null; then
1134    AC_MSG_ERROR([compiler/ghc.cabal.in contains tab characters; please remove them])
1135 fi
1136
1137 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])
1138 AC_OUTPUT
1139
1140 # We got caught by
1141 #     http://savannah.gnu.org/bugs/index.php?1516
1142 #     $(eval ...) inside conditionals causes errors
1143 # with make 3.80, so warn the user if it looks like they're about to
1144 # try to use it.
1145 # We would use "grep -q" here, but Solaris's grep doesn't support it.
1146 checkMake380() {
1147     if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
1148     then
1149         echo
1150         echo "WARNING: It looks like \"$1\" is GNU make 3.80."
1151         echo "This version cannot be used to build GHC."
1152         echo "Please use GNU make >= 3.81."
1153     fi
1154 }
1155
1156 checkMake380 make
1157 checkMake380 gmake
1158
1159 echo ["
1160 ----------------------------------------------------------------------
1161 Configure completed successfully.
1162
1163    Building GHC version  : $ProjectVersion
1164           Git commit id  : $ProjectGitCommitId
1165
1166    Build platform        : $BuildPlatform
1167    Host platform         : $HostPlatform
1168    Target platform       : $TargetPlatform
1169 "]
1170
1171 echo ["\
1172    Bootstrapping using   : $WithGhc
1173       which is version   : $GhcVersion
1174 "]
1175
1176 if test "x$CC_LLVM_BACKEND" = "x1"; then
1177     if test "x$CC_CLANG_BACKEND" = "x1"; then
1178         CompilerName="clang        "
1179     else
1180         CompilerName="llvm-gcc     "
1181     fi
1182 else
1183     CompilerName="gcc          "
1184 fi
1185
1186 echo ["\
1187    Using $CompilerName       : $WhatGccIsCalled
1188       which is version       : $GccVersion
1189    Building a cross compiler : $CrossCompiling
1190    hs-cpp       : $HaskellCPPCmd
1191    hs-cpp-flags : $HaskellCPPArgs
1192    ld           : $LdCmd
1193    Happy        : $HappyCmd ($HappyVersion)
1194    Alex         : $AlexCmd ($AlexVersion)
1195    Perl         : $PerlCmd
1196    sphinx-build : $SPHINXBUILD
1197    xelatex      : $XELATEX
1198
1199    Using LLVM tools
1200       llc   : $LlcCmd
1201       opt   : $OptCmd"]
1202
1203 if test "$HSCOLOUR" = ""; then
1204 echo ["
1205    HsColour was not found; documentation will not contain source links
1206 "]
1207 else
1208 echo ["\
1209    HsColour : $HSCOLOUR
1210 "]
1211 fi
1212
1213 echo ["\
1214    Tools to build Sphinx HTML documentation available: $BUILD_SPHINX_HTML
1215    Tools to build Sphinx PDF documentation available: $BUILD_SPHINX_PDF"]
1216
1217 echo ["----------------------------------------------------------------------
1218 "]
1219
1220 echo "\
1221 For a standard build of GHC (fully optimised with profiling), type (g)make.
1222
1223 To make changes to the default build configuration, copy the file
1224 mk/build.mk.sample to mk/build.mk, and edit the settings in there.
1225
1226 For more information on how to configure your GHC build, see
1227    http://ghc.haskell.org/trac/ghc/wiki/Building
1228 "