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