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)
6 # (c) The University of Glasgow 1994-2012
8 # Configure script template for GHC
10 # Process with 'autoreconf' to get a working configure script.
12 # For the generated configure script, do "./configure --help" to
13 # see what flags are available. (Better yet, read the documentation!)
16 AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.0.1], [glasgow-haskell-bugs@haskell.org], [ghc-AC_PACKAGE_VERSION])
18 # Set this to YES for a released version, otherwise NO
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.
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'?"
34 AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
36 dnl ----------------------------------------------------------
37 dnl ** Find unixy sort and find commands,
38 dnl ** which are needed by FP_SETUP_PROJECT_VERSION
40 dnl ** Find find command (for Win32's benefit)
44 dnl ----------------------------------------------------------
45 FP_SETUP_PROJECT_VERSION
47 # Hmmm, we fix the RPM release number to 1 here... Is this convenient?
48 AC_SUBST([release], [1])
50 # First off, a distrib sanity check..
51 AC_CONFIG_SRCDIR([mk/config.mk.in])
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
61 # -------------------------------------------------------------------------
62 # Prepare to generate the following header files
65 AC_CONFIG_HEADER(mk/config.h)
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.."
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.
81 dnl ** What command to use to compile compiler sources ?
82 dnl --------------------------------------------------------------
85 [AC_HELP_STRING([--with-ghc=ARG],
86 [Use ARG as the path to GHC [default=autodetect]])],
88 [if test "$GHC" = ""; then
89 AC_PATH_PROG([GHC], [ghc])
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
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
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
110 if test "$WithGhc" != ""; then
111 FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
113 if test "$GhcMajVersion" = "unknown" -o "$GhcMinVersion" = "unknown"; then
114 AC_MSG_ERROR([Cannot determine the version of $WithGhc. Is it really GHC?])
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"
124 BOOTSTRAPPING_GHC_INFO_FIELD([CC_STAGE0],[C compiler command])
125 BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[ld command])
126 BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command])
127 BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags])
128 BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file])
131 dnl ** Must have GHC to build GHC
132 if test "$WithGhc" = ""
134 AC_MSG_ERROR([GHC is required.])
136 FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.8],
137 [AC_MSG_ERROR([GHC version 7.8 or later is required to compile GHC.])])
139 if test `expr $GhcMinVersion % 2` = "1"
141 if test "$EnableBootstrapWithDevelSnaphost" = "NO"
144 $WithGhc is a development snapshot of GHC, version $GhcVersion.
145 Bootstrapping using this version of GHC is not supported, and may not
146 work. Use --enable-bootstrap-with-devel-snapshot to try it anyway,
147 or --with-ghc to specify a different GHC to use.])
151 GHC_PACKAGE_DB_FLAG=package-db
152 AC_SUBST(GHC_PACKAGE_DB_FLAG)
154 # GHC 7.7+ needs -fcmm-sink when compiling Parser.hs. See #8182
155 FP_COMPARE_VERSIONS([$GhcVersion],[-gt],[7.7],
156 CMM_SINK_BOOTSTRAP_IS_NEEDED=YES,
157 CMM_SINK_BOOTSTRAP_IS_NEEDED=NO)
158 AC_SUBST(CMM_SINK_BOOTSTRAP_IS_NEEDED)
160 FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.9],
161 SUPPORTS_COMPONENT_ID=NO,
162 SUPPORTS_COMPONENT_ID=YES)
163 AC_SUBST(SUPPORTS_COMPONENT_ID)
165 FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.11],
166 SUPPORTS_THIS_UNIT_ID=NO,
167 SUPPORTS_THIS_UNIT_ID=YES)
168 AC_SUBST(SUPPORTS_THIS_UNIT_ID)
170 # GHC is passed to Cabal, so we need a native path
171 if test "${WithGhc}" != ""
173 ghc_host_os=`"${WithGhc}" +RTS --info | grep 'Host OS' | sed -e 's/.*, "//' -e 's/")//'`
175 if test "$ghc_host_os" = "mingw32"
177 if test "${OSTYPE}" = "msys"
179 WithGhc=`echo "${WithGhc}" | sed "s#^/\([a-zA-Z]\)/#\1:/#"`
181 # Canonicalise to <drive>:/path/to/ghc
182 WithGhc=`cygpath -m "${WithGhc}"`
184 echo "GHC path canonicalised to: ${WithGhc}"
189 dnl ** Without optimization some INLINE trickery fails for GHCi
192 dnl--------------------------------------------------------------------
193 dnl * Choose host(/target/build) platform
194 dnl--------------------------------------------------------------------
195 dnl If we aren't explicitly told what values to use with configure flags,
196 dnl we ask the bootstrapping compiler what platform it is for
198 if test "${WithGhc}" != ""
200 bootstrap_host=`"${WithGhc}" +RTS --info | grep '^ ,("Host platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
201 bootstrap_target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
202 if test "$bootstrap_host" != "$bootstrap_target"
204 echo "Bootstrapping GHC is a cross compiler. This probably isn't going to work"
208 # We have to run these unconditionally, but we may discard their
209 # results in the following code
214 FPTOOLS_SET_PLATFORM_VARS
216 # Verify that the installed (bootstrap) GHC is capable of generating
217 # code for the requested build platform.
218 if test "$BuildPlatform" != "$bootstrap_target"
220 echo "This GHC (${WithGhc}) does not generate code for the build platform"
221 echo " GHC target platform : $bootstrap_target"
222 echo " Desired build platform : $BuildPlatform"
226 # Testing if we shall enable shared libs support on Solaris.
227 # Anything older than SunOS 5.11 aka Solaris 11 (Express) is broken.
229 SOLARIS_BROKEN_SHLD=NO
233 # here we go with the test
234 MINOR=`uname -r|cut -d '.' -f 2-`
235 if test "$MINOR" -lt "11"; then
236 SOLARIS_BROKEN_SHLD=YES
241 AC_SUBST(SOLARIS_BROKEN_SHLD)
243 dnl ** Do an unregisterised build?
244 dnl --------------------------------------------------------------
246 i386|x86_64|powerpc|powerpc64|powerpc64le|arm)
247 UnregisterisedDefault=NO
250 UnregisterisedDefault=YES
253 AC_ARG_ENABLE(unregisterised,
254 [AC_HELP_STRING([--enable-unregisterised],
255 [Build an unregisterised compiler (enabled by default on platforms without registerised support) [default="$UnregisterisedDefault"]])],
256 [ if test x"$enableval" = x"yes"; then
262 [Unregisterised="$UnregisterisedDefault"]
264 AC_SUBST(Unregisterised)
267 [AC_HELP_STRING([--with-hc=ARG],
268 [Use ARG as the path to the compiler for compiling ordinary
269 Haskell code (default= value of --with-ghc)])],
275 # This uses GHC, so put it after the "GHC is required" check above:
286 if test "$HostOS" = "mingw32"
288 # Find the mingw-w64 7z file to extract.
289 # NB. If you update the tarballs to a new version of gcc, don't
290 # forget to tweak the paths in driver/gcc/gcc.c.
291 if test "$HostArch" = "i386"
294 tarball_dest_dir="mingw-w64/x86"
295 tarball_mingw_dir="mingw32"
298 tarball_dest_dir="mingw-w64/x86_64"
299 tarball_mingw_dir="mingw64"
304 AC_MSG_NOTICE([Checking for Windows toolchain tarballs...])
306 if test "$TarballsAutodownload" = "NO"
312 mk/get-win32-tarballs.sh $action $HostArch > missing-win32-tarballs
315 rm missing-win32-tarballs
320 echo "Needed msys2 tarballs are missing. You have a few options to get them,"
322 echo " * run configure with the --enable-tarballs-autodownload option"
324 echo " * run mk/get-win32-tarballs.sh download ${HostArch}"
326 echo " * manually download the files listed in ./missing-win32-tarballs and place"
327 echo " them in the ghc-tarballs directory."
333 echo "Error fetching msys2 tarballs; see errors above."
338 # Extract all the tarballs in one go
339 if ! test -d inplace/mingw
341 AC_MSG_NOTICE([Extracting Windows toolchain from archives (may take a while)...])
343 local base_dir="../ghc-tarballs/${tarball_dest_dir}"
345 find "${base_dir}" -name "*.tar.xz" -exec tar xfJ {} \; &&
348 cd .. ) || fail "Error: Could not extract Windows toolchains."
350 mv "inplace/${tarball_mingw_dir}" inplace/mingw &&
353 # NB. Now since the GCC is hardcoded to use /mingw32 we need to
354 # make a wrapper around it to give it the proper paths
355 mv inplace/mingw/bin/gcc.exe inplace/mingw/bin/realgcc.exe
356 PATH=`pwd`/inplace/mingw/bin:$PATH
357 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
359 AC_MSG_NOTICE([In-tree MingW-w64 tree created])
363 if test "$HostOS" = "mingw32"
365 test -d inplace || mkdir inplace
367 # NB. Download and extract the MingW-w64 distribution if required
370 mingwbin="$hardtop/inplace/mingw/bin/"
371 CC="${mingwbin}gcc.exe"
372 LD="${mingwbin}ld.exe"
373 NM="${mingwbin}nm.exe"
374 RANLIB="${mingwbin}ranlib.exe"
375 OBJDUMP="${mingwbin}objdump.exe"
376 fp_prog_ar="${mingwbin}ar.exe"
378 # NB. Download the perl binaries if required
379 if ! test -d inplace/perl ||
380 test inplace/perl -ot ghc-tarballs/perl/ghc-perl*.tar.gz
382 AC_MSG_NOTICE([Making in-tree perl tree])
387 tar -zxf ../../ghc-tarballs/perl/ghc-perl*.tar.gz
389 AC_MSG_NOTICE([In-tree perl tree created])
400 if test "$TargetOS_CPP" = "darwin"
402 # Split objects is broken (#4013) with XCode < 3.2
403 if test "$XCodeVersion1" -lt 3
407 if test "$XCodeVersion1" -eq 3
409 if test "$XCodeVersion2" -lt 2
416 AC_SUBST([SplitObjsBroken])
418 dnl ** Building a cross compiler?
419 dnl --------------------------------------------------------------
421 # If 'host' and 'target' differ, then this means we are building a cross-compiler.
422 if test "$target" != "$host" ; then
424 cross_compiling=yes # This tells configure that it can accept just 'target',
426 # configure: error: cannot run C compiled programs.
427 # If you meant to cross compile, use `--host'.
429 if test "$build" != "$host" ; then
433 BUILD: $build (the architecture we're building on)
434 HOST: $host (the architecture the compiler we're building will execute on)
435 TARGET: $target (the architecture the compiler we're building will produce code for)
437 BUILD must equal HOST; that is, we do not support building GHC itself
438 with a cross-compiler. To cross-compile GHC itself, set TARGET: stage
439 1 will be a cross-compiler, and stage 2 will be the cross-compiled
443 if test "$CrossCompiling" = "YES"
445 CrossCompilePrefix="${target}-"
447 CrossCompilePrefix=""
449 TargetPlatformFull="${target}"
450 AC_SUBST(CrossCompiling)
451 AC_SUBST(CrossCompilePrefix)
452 AC_SUBST(TargetPlatformFull)
454 dnl ** Which gcc to use?
455 dnl --------------------------------------------------------------
456 FIND_GCC([WhatGccIsCalled], [gcc], [gcc])
457 CC="$WhatGccIsCalled"
460 # If --with-gcc was used, and we're not cross-compiling, then it also
461 # applies to the stage0 compiler.
462 MAYBE_OVERRIDE_STAGE0([gcc],[CC_STAGE0])
463 MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0])
465 dnl make extensions visible to allow feature-tests to detect them lateron
466 AC_USE_SYSTEM_EXTENSIONS
468 dnl ** figure out how to invoke the C preprocessor (i.e. `gcc -E`)
471 # --with-hs-cpp/--with-hs-cpp-flags
472 FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
473 AC_SUBST([HaskellCPPCmd])
474 AC_SUBST([HaskellCPPArgs])
476 dnl ** Which ld to use?
477 dnl --------------------------------------------------------------
481 dnl ** Which nm to use?
482 dnl --------------------------------------------------------------
483 FP_ARG_WITH_PATH_GNU_PROG([NM], [nm], [nm])
487 dnl ** Which objdump to use?
488 dnl --------------------------------------------------------------
489 FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([OBJDUMP], [objdump], [objdump])
490 ObjdumpCmd="$OBJDUMP"
491 AC_SUBST([ObjdumpCmd])
493 dnl ** Which ar to use?
494 dnl --------------------------------------------------------------
495 FP_ARG_WITH_PATH_GNU_PROG([AR], [ar], [ar])
500 dnl ** Which ranlib to use?
501 dnl --------------------------------------------------------------
502 FP_ARG_WITH_PATH_GNU_PROG([RANLIB], [ranlib], [ranlib])
507 # Note: we may not have objdump on OS X, and we only need it on Windows (for DLL checks)
510 dnl ** Which objdump to use?
511 dnl --------------------------------------------------------------
512 FP_ARG_WITH_PATH_GNU_PROG([OBJDUMP], [objdump], [objdump])
513 ObjdumpCmd="$OBJDUMP"
514 AC_SUBST([ObjdumpCmd])
518 # Here is where we re-target which specific version of the LLVM
519 # tools we are looking for. In the past, GHC supported a number of
520 # versions of LLVM simultaneously, but that stopped working around
521 # 3.5/3.6 release of LLVM.
523 AC_SUBST([LlvmVersion])
524 sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/')
525 AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number])
527 dnl ** Which LLVM llc to use?
528 dnl --------------------------------------------------------------
529 FIND_LLVM_PROG([LLC], [llc], [llc], [$LlvmVersion])
533 dnl ** Which LLVM opt to use?
534 dnl --------------------------------------------------------------
535 FIND_LLVM_PROG([OPT], [opt], [opt], [$LlvmVersion])
539 dnl --------------------------------------------------------------
540 dnl End of configure script option section
541 dnl --------------------------------------------------------------
544 dnl --------------------------------------------------------------
545 dnl * General configuration checks
546 dnl --------------------------------------------------------------
548 dnl ** Bug 9439: Some GHC 7.8 releases had broken LLVM code generator.
549 dnl Unfortunately we don't know whether the user is going to request a
550 dnl build with the LLVM backend as this is only given in build.mk.
552 dnl Instead, we try to do as much work as possible here, checking
553 dnl whether -fllvm is the stage 0 compiler's default. If so we
554 dnl fail. If not, we check whether -fllvm is affected explicitly and
555 dnl if so set a flag. The build system will later check this flag
556 dnl after the desired build flags are known.
558 dnl This problem is further complicated by the fact that the llvm
559 dnl version used by the bootstrap compiler may be different from the
560 dnl version we arre trying to compile GHC against. Therefore, we need
561 dnl to find the boostrap compiler's `settings` file then check to see
562 dnl if the `opt` and `llc` command strings are non-empty and if these
563 dnl programs exist. Only if they exist to we test for bug #9439.
565 FIND_GHC_BOOTSTRAP_PROG([BootstrapLlcCmd], [${WithGhc}], "LLVM llc command")
566 FIND_GHC_BOOTSTRAP_PROG([BootstrapOptCmd], [${WithGhc}], "LLVM opt command")
568 if test -n "$BootstrapLlcCmd" && test -n "$BootstrapOptCmd"
570 AC_MSG_CHECKING(whether bootstrap compiler is affected by bug 9439)
571 echo "main = putStrLn \"%function\"" > conftestghc.hs
573 # Check whether LLVM backend is default for this platform
574 "${WithGhc}" -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" conftestghc.hs 2>&1 >/dev/null
576 if test "x$res" = "x%object"
579 echo "Buggy bootstrap compiler"
581 echo "The stage 0 compiler $WithGhc is affected by GHC Bug \#9439"
582 echo "and therefore will miscompile the LLVM backend if -fllvm is"
585 echo "Please use another bootstrap compiler"
589 # -fllvm is not the default, but set a flag so the Makefile can check
590 # -for it in the build flags later on
591 "${WithGhc}" -fforce-recomp -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" -fllvm conftestghc.hs 2>&1 >/dev/null
595 if test "x$res" = "x%object"
598 GHC_LLVM_AFFECTED_BY_9439=1
599 elif test "x$res" = "x%function"
602 GHC_LLVM_AFFECTED_BY_9439=0
604 AC_MSG_WARN(unexpected output $res)
607 AC_MSG_RESULT(failed to compile, assuming no)
610 AC_SUBST([GHC_LLVM_AFFECTED_BY_9439])
612 dnl ** Can the unix package be built?
613 dnl --------------------------------------------------------------
615 if test "$TargetOS" = "mingw32"
621 AC_SUBST([GhcLibsWithUnix])
626 dnl ** look for `perl'
629 PerlCmd=$hardtop/inplace/perl/perl
632 AC_PATH_PROG(PerlCmd,perl)
633 if test -z "$PerlCmd"
635 echo "You must install perl before you can continue"
636 echo "Perhaps it is already installed, but not in your PATH?"
639 FPTOOLS_CHECK_PERL_VERSION
644 dnl ** look for GCC and find out which version
645 dnl Figure out which C compiler to use. Gcc is preferred.
646 dnl If gcc, make sure it's at least 3.0
650 dnl ** look to see if we have a C compiler using an llvm back end.
656 FP_PROG_LD_NO_COMPACT_UNWIND
660 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
661 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
662 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
663 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
664 # Stage 3 won't be supported by cross-compilation
668 AC_SUBST(CONF_CC_OPTS_STAGE0)
669 AC_SUBST(CONF_CC_OPTS_STAGE1)
670 AC_SUBST(CONF_CC_OPTS_STAGE2)
671 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
672 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
673 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
674 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
675 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
676 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
677 AC_SUBST(CONF_CPP_OPTS_STAGE0)
678 AC_SUBST(CONF_CPP_OPTS_STAGE1)
679 AC_SUBST(CONF_CPP_OPTS_STAGE2)
681 dnl ** Set up the variables for the platform in the settings file.
682 dnl May need to use gcc to find platform details.
683 dnl --------------------------------------------------------------
684 FPTOOLS_SET_HASKELL_PLATFORM_VARS
686 dnl ** figure out how to do context diffs
689 dnl Let's make sure install-sh is executable here. If we got it from
690 dnl a darcs repo, it might not be (see bug #978).
692 dnl ** figure out how to do a BSD-ish install
695 dnl ** how to invoke `ar' and `ranlib'
696 FP_PROG_AR_SUPPORTS_ATFILE
697 FP_PROG_AR_NEEDS_RANLIB
699 dnl ** Check to see whether ln -s works
704 dnl ** Find the path to sed
705 AC_PATH_PROGS(SedCmd,gsed sed,sed)
708 dnl ** check for time command
709 AC_PATH_PROG(TimeCmd,time)
712 dnl if GNU tar is named gtar, look for it first.
713 AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar)
715 dnl ** check for patch
716 dnl if GNU patch is named gpatch, look for it first
717 AC_PATH_PROGS(PatchCmd,gpatch patch, patch)
719 dnl ** check for dtrace (currently only implemented for Mac OS X)
721 AC_PATH_PROG(DtraceCmd,dtrace)
722 if test -n "$DtraceCmd"; then
723 if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then
729 AC_PATH_PROG(HSCOLOUR,HsColour)
730 # HsColour is passed to Cabal, so we need a native path
731 if test "$HostOS" = "mingw32" && \
732 test "${OSTYPE}" != "msys" && \
733 test "${HSCOLOUR}" != ""
735 # Canonicalise to <drive>:/path/to/gcc
736 HSCOLOUR=`cygpath -m ${HSCOLOUR}`
739 dnl ** check for Sphinx toolchain
740 AC_PATH_PROG(SPHINXBUILD,sphinx-build)
741 AC_CACHE_CHECK([for version of sphinx-build], fp_cv_sphinx_version,
743 [if test -n "$SPHINXBUILD"; then
744 fp_cv_sphinx_version=`"$SPHINXBUILD" --version 2>&1 | sed 's/Sphinx\( (sphinx-build)\)\? v\?\([0-9]\.[0-9]\.[0-9]\)/\2/' | head -n1`;
748 FP_COMPARE_VERSIONS([$fp_cv_sphinx_version],-lt,1.0.0,
749 [AC_MSG_WARN([Sphinx version 1.0.0 or later is required to build documentation]); SPHINXBUILD=;])
751 dnl ** check for xelatex
752 AC_PATH_PROG(XELATEX,xelatex)
754 dnl ** check for ghc-pkg command
757 dnl ** check for installed happy binary + version
760 dnl ** check for installed alex binary + version
763 dnl --------------------------------------------------
764 dnl ### program checking section ends here ###
765 dnl --------------------------------------------------
767 dnl --------------------------------------------------
768 dnl * Platform header file and syscall feature tests
769 dnl ### checking the state of the local header files and syscalls ###
771 dnl ** check for full ANSI header (.h) files
774 dnl ** Enable large file support. NB. do this before testing the type of
775 dnl off_t, because it will affect the result of that test.
778 dnl ** check for specific header (.h) files that we are interested in
779 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])
781 dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
782 AC_CHECK_HEADERS([sys/cpuset.h], [], [],
783 [[#if HAVE_SYS_PARAM_H
784 # include <sys/param.h>
788 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
791 dnl ** do we have long longs?
792 AC_CHECK_TYPES([long long])
794 dnl ** what are the sizes of various types
795 AC_CHECK_SIZEOF(char, 1)
796 AC_CHECK_SIZEOF(double, 8)
797 AC_CHECK_SIZEOF(float, 4)
798 AC_CHECK_SIZEOF(int, 4)
799 AC_CHECK_SIZEOF(long, 4)
800 if test "$ac_cv_type_long_long" = yes; then
801 AC_CHECK_SIZEOF(long long, 8)
803 AC_CHECK_SIZEOF(short, 2)
804 AC_CHECK_SIZEOF(unsigned char, 1)
805 AC_CHECK_SIZEOF(unsigned int, 4)
806 AC_CHECK_SIZEOF(unsigned long, 4)
807 if test "$ac_cv_type_long_long" = yes; then
808 AC_CHECK_SIZEOF(unsigned long long, 8)
810 AC_CHECK_SIZEOF(unsigned short, 2)
811 AC_CHECK_SIZEOF(void *, 4)
813 dnl for use in settings.in
814 WordSize=$ac_cv_sizeof_void_p
817 dnl ** what are alignment constraints on various types
818 FP_CHECK_ALIGNMENT(char)
819 FP_CHECK_ALIGNMENT(double)
820 FP_CHECK_ALIGNMENT(float)
821 FP_CHECK_ALIGNMENT(int)
822 FP_CHECK_ALIGNMENT(long)
823 if test "$ac_cv_type_long_long" = yes; then
824 FP_CHECK_ALIGNMENT(long long)
826 FP_CHECK_ALIGNMENT(short)
827 FP_CHECK_ALIGNMENT(unsigned char)
828 FP_CHECK_ALIGNMENT(unsigned int)
829 FP_CHECK_ALIGNMENT(unsigned long)
830 if test "$ac_cv_type_long_long" = yes; then
831 FP_CHECK_ALIGNMENT(unsigned long long)
833 FP_CHECK_ALIGNMENT(unsigned short)
834 FP_CHECK_ALIGNMENT(void *)
836 FP_CHECK_FUNC([WinExec],
837 [@%:@include <windows.h>], [WinExec("",0)])
839 FP_CHECK_FUNC([GetModuleFileName],
840 [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
842 dnl ** check for more functions
843 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
844 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity setlocale])
846 dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
847 dnl ** _POSIX_C_SOURCE is defined
848 AC_CHECK_DECLS([ctime_r], , ,
849 [#define _POSIX_SOURCE 1
850 #define _POSIX_C_SOURCE 199506L
853 dnl ** check for mingwex library
854 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
855 AC_SUBST(HaveLibMingwEx)
857 if test $HaveLibMingwEx = YES ; then
858 AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
861 dnl ** check for math library
862 dnl Keep that check as early as possible.
863 dnl as we need to know whether we need libm
864 dnl for math functions or not
865 dnl (see http://ghc.haskell.org/trac/ghc/ticket/3730)
866 AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO)
867 if test $HaveLibM = YES
869 AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])
874 dnl ################################################################
875 dnl Check for libraries
876 dnl ################################################################
880 AC_ARG_WITH([system-libffi],
881 [AC_HELP_STRING([--with-system-libffi],
882 [Use system provided libffi for RTS [default=no]])
885 AS_IF([test "x$with_system_libffi" = "xyes"],
886 [UseSystemLibFFI="YES"], [UseSystemLibFFI="NO"]
890 AC_SUBST(UseSystemLibFFI)
892 AC_ARG_WITH([ffi-includes],
893 [AC_HELP_STRING([--with-ffi-includes=ARG],
894 [Find includes for libffi in ARG [default=system default]])
897 if test "x$UseSystemLibFFI" != "xYES"; then
898 AC_MSG_WARN([--with-ffi-includes will be ignored, --with-system-libffi not set])
900 FFIIncludeDir="$withval"
901 LIBFFI_CFLAGS="-I$withval"
905 AC_SUBST(FFIIncludeDir)
907 AC_ARG_WITH([ffi-libraries],
908 [AC_HELP_STRING([--with-ffi-libraries=ARG],
909 [Find libffi in ARG [default=system default]])
912 if test "x$UseSystemLibFFI" != "xYES"; then
913 AC_MSG_WARN([--with-ffi-libraries will be ignored, --with-system-libffi not set])
915 FFILibDir="$withval" LIBFFI_LDFLAGS="-L$withval"
921 AS_IF([test "$UseSystemLibFFI" = "YES"], [
923 CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
925 LDFLAGS="$LIBFFI_LDFLAGS $LDFLAGS"
926 if test "$HostOS" = "openbsd";
928 # OpenBSD's libffi is not directly linked to the libpthread but
929 # still requires pthread functionality. This means that any client
930 # binary which links with libffi also needs to link with
931 # libpthread. If it does not, then linking fails with unresolved
933 LDFLAGS="$LDFLAGS -lpthread"
935 AC_CHECK_LIB(ffi, ffi_call,
936 [AC_CHECK_HEADERS([ffi.h], [break], [])
937 AC_DEFINE([HAVE_LIBFFI], [1], [Define to 1 if you have libffi.])],
938 [AC_MSG_ERROR([Cannot find system libffi])])
943 dnl ** check whether we need -ldl to get dlopen()
944 AC_CHECK_LIB(dl, dlopen)
946 dnl --------------------------------------------------
947 dnl * Miscellaneous feature tests
948 dnl --------------------------------------------------
950 dnl ** can we get alloca?
953 dnl ** working vfork?
956 dnl ** determine whether or not const works
959 dnl ** are we big endian?
961 FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
963 dnl ** check for leading underscores in symbol names
964 FP_LEADING_UNDERSCORE
968 dnl ** check for librt
969 AC_CHECK_LIB(rt, clock_gettime)
970 AC_CHECK_FUNCS(clock_gettime timer_settime)
971 FP_CHECK_TIMER_CREATE
973 dnl ** check for Apple's "interesting" long double compatibility scheme
974 AC_MSG_CHECKING(for printf\$LDBLStub)
975 AC_TRY_LINK_FUNC(printf\$LDBLStub,
978 AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
979 [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
983 AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
984 [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
987 dnl ** pthread_setname_np is a recent addition to glibc, and OS X has
988 dnl a different single-argument version.
989 AC_CHECK_LIB(pthread, pthread_setname_np)
990 AC_MSG_CHECKING(for pthread_setname_np)
996 [pthread_setname_np(pthread_self(), "name");],
998 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP], [1],
999 [Define to 1 if you have the glibc version of pthread_setname_np]),
1003 dnl ** check for eventfd which is needed by the I/O manager
1004 AC_CHECK_HEADERS([sys/eventfd.h])
1005 AC_CHECK_FUNCS([eventfd])
1007 dnl ** Check for __thread support in the compiler
1008 AC_MSG_CHECKING(for __thread support)
1010 [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ],
1013 AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported])
1017 AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported])
1020 dnl large address space support (see includes/rts/storage/MBlock.h)
1022 dnl Darwin has vm_allocate/vm_protect
1023 dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED)
1024 dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE
1025 dnl (They also have MADV_DONTNEED, but it means something else!)
1027 dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however
1028 dnl it counts page-table space as committed memory, and so quickly
1029 dnl runs out of paging file when we have multiple processes reserving
1030 dnl 1TB of address space, we get the following error:
1031 dnl VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete.
1034 AC_ARG_ENABLE(large-address-space,
1035 [AC_HELP_STRING([--enable-large-address-space],
1036 [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])],
1037 EnableLargeAddressSpace=$enableval,
1038 EnableLargeAddressSpace=yes
1041 use_large_address_space=no
1042 if test "$ac_cv_sizeof_void_p" -eq 8 ; then
1043 if test "x$EnableLargeAddressSpace" = "xyes" ; then
1044 if test "$ghc_host_os" = "darwin" ; then
1045 use_large_address_space=yes
1046 elif test "$ghc_host_os" = "openbsd" ; then
1047 # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE.
1048 # The flag MAP_NORESERVE is supported for source compatibility reasons,
1049 # but is completely ignored by OS mmap
1050 use_large_address_space=no
1052 AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[],
1055 #include <sys/types.h>
1056 #include <sys/mman.h>
1059 if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" &&
1060 test "$ac_cv_have_decl_MADV_FREE" = "yes" ||
1061 test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then
1062 use_large_address_space=yes
1067 if test "$use_large_address_space" = "yes" ; then
1068 AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support])
1072 dnl --------------------------------------------------------------
1073 AC_ARG_ENABLE(libdw,
1074 [AC_HELP_STRING([--enable-dwarf-unwind],
1075 [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])],
1076 [AC_CHECK_LIB(dw, dwfl_attach_state, [HaveLibdw=YES], [HaveLibdw=NO])],
1081 if test -n "$SPHINXBUILD"; then
1083 BUILD_SPHINX_HTML=YES
1084 if test -n "$XELATEX"; then
1085 BUILD_SPHINX_PDF=YES
1091 BUILD_SPHINX_HTML=NO
1095 AC_SUBST(BUILD_SPHINX_HTML)
1096 AC_SUBST(BUILD_SPHINX_PDF)
1098 LIBRARY_VERSION(base)
1099 LIBRARY_VERSION(Cabal, Cabal/Cabal)
1100 LIBRARY_VERSION(ghc-prim)
1101 LIBRARY_ghc_VERSION="$ProjectVersion"
1102 AC_SUBST(LIBRARY_ghc_VERSION)
1104 if grep ' ' compiler/ghc.cabal.in 2>&1 >/dev/null; then
1105 AC_MSG_ERROR([compiler/ghc.cabal.in contains tab characters; please remove them])
1108 # Create the configuration for the Shake-based build system if it is present
1109 if test -e shake-build/cfg/system.config.in; then
1110 AC_CONFIG_FILES([shake-build/cfg/system.config])
1114 # http://savannah.gnu.org/bugs/index.php?1516
1115 # $(eval ...) inside conditionals causes errors
1116 # with make 3.80, so warn the user if it looks like they're about to
1118 # We would use "grep -q" here, but Solaris's grep doesn't support it.
1119 print_make_warning=""
1121 make_ver=`$1 --version 2>&1 | head -1`
1122 if echo "$make_ver" | grep 'GNU Make 3\.80' > /dev/null
1124 print_make_warning="true"
1126 if echo "$make_ver" | grep 'GNU Make' > /dev/null
1136 AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal utils/runghc/runghc.cabal libraries/ghc-boot/ghc-boot.cabal libraries/ghc-boot-th/ghc-boot-th.cabal libraries/ghci/ghci.cabal settings docs/users_guide/ghc_config.py docs/index.html libraries/prologue.txt distrib/configure.ac])
1139 if test "$print_make_warning" = "true"; then
1141 echo "WARNING: It looks like \"$MakeCmd\" is GNU make 3.80."
1142 echo "This version cannot be used to build GHC."
1143 echo "Please use GNU make >= 3.81."
1147 ----------------------------------------------------------------------
1148 Configure completed successfully.
1150 Building GHC version : $ProjectVersion
1151 Git commit id : $ProjectGitCommitId
1153 Build platform : $BuildPlatform
1154 Host platform : $HostPlatform
1155 Target platform : $TargetPlatform
1159 Bootstrapping using : $WithGhc
1160 which is version : $GhcVersion
1163 if test "x$CC_LLVM_BACKEND" = "x1"; then
1164 if test "x$CC_CLANG_BACKEND" = "x1"; then
1165 CompilerName="clang "
1167 CompilerName="llvm-gcc "
1174 Using $CompilerName : $WhatGccIsCalled
1175 which is version : $GccVersion
1176 Building a cross compiler : $CrossCompiling
1177 hs-cpp : $HaskellCPPCmd
1178 hs-cpp-flags : $HaskellCPPArgs
1181 objdump : $ObjdumpCmd
1182 Happy : $HappyCmd ($HappyVersion)
1183 Alex : $AlexCmd ($AlexVersion)
1185 sphinx-build : $SPHINXBUILD
1192 if test "$HSCOLOUR" = ""; then
1194 HsColour was not found; documentation will not contain source links
1198 HsColour : $HSCOLOUR
1203 Tools to build Sphinx HTML documentation available: $BUILD_SPHINX_HTML
1204 Tools to build Sphinx PDF documentation available: $BUILD_SPHINX_PDF"]
1206 echo ["----------------------------------------------------------------------
1210 For a standard build of GHC (fully optimised with profiling), type (g)make.
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.
1215 For more information on how to configure your GHC build, see
1216 http://ghc.haskell.org/trac/ghc/wiki/Building