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], [7.7], [glasgow-haskell-bugs@haskell.org], [ghc])
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 if test "$WithGhc" != ""; then
105 FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
107 if test "$GhcMajVersion" = "unknown" -o "$GhcMinVersion" = "unknown"; then
108 AC_MSG_ERROR([Cannot determine the version of $WithGhc. Is it really GHC?])
111 AC_SUBST(GhcVersion)dnl
112 AC_SUBST(GhcMajVersion)dnl
113 AC_SUBST(GhcMinVersion)dnl
114 AC_SUBST(GhcPatchLevel)dnl
115 GhcMinVersion2=`echo "$GhcMinVersion" | sed 's/^\\(.\\)$/0\\1/'`
116 GhcCanonVersion="$GhcMajVersion$GhcMinVersion2"
118 BOOTSTRAPPING_GHC_INFO_FIELD([OS_STAGE0],[target os])
119 BOOTSTRAPPING_GHC_INFO_FIELD([CC_STAGE0],[C compiler command])
120 dnl ToDo, once "ld command" is reliably available.
121 dnl Then, we can remove the LD_STAGE0 hack in mk/build-package-date.mk
122 dnl BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[ld command])
123 if test "x$OS_STAGE0" != "xOSDarwin"; then
124 BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command])
125 BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags])
126 BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file])
129 AR_OPTS_STAGE0='$(AR_OPTS)'
130 ArSupportsAtFile_STAGE0='$(ArSupportsAtFile)'
134 dnl ** Must have GHC to build GHC
135 if test "$WithGhc" = ""
137 AC_MSG_ERROR([GHC is required.])
139 FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.4],
140 [AC_MSG_ERROR([GHC version 7.4 or later is required to compile GHC.])])dnl
142 if test `expr $GhcMinVersion % 2` = "1"
144 if test "$EnableBootstrapWithDevelSnaphost" = "NO"
147 $WithGhc is a development snapshot of GHC, version $GhcVersion.
148 Bootstrapping using this version of GHC is not supported, and may not
149 work. Use --enable-bootstrap-with-devel-snapshot to try it anyway,
150 or --with-ghc to specify a different GHC to use.])
154 FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.5],
155 GHC_PACKAGE_DB_FLAG=package-conf,
156 GHC_PACKAGE_DB_FLAG=package-db)
157 AC_SUBST(GHC_PACKAGE_DB_FLAG)
159 # GHC 7.7+ needs -fcmm-sink when compiling Parser.hs. See #8182
160 FP_COMPARE_VERSIONS([$GhcVersion],[-gt],[7.7],
161 CMM_SINK_BOOTSTRAP_IS_NEEDED=YES,
162 CMM_SINK_BOOTSTRAP_IS_NEEDED=NO)
163 AC_SUBST(CMM_SINK_BOOTSTRAP_IS_NEEDED)
165 # GHC is passed to Cabal, so we need a native path
166 if test "${WithGhc}" != ""
168 ghc_host_os=`"${WithGhc}" +RTS --info | grep 'Host OS' | sed -e 's/.*, "//' -e 's/")//'`
170 if test "$ghc_host_os" = "mingw32"
172 if test "${OSTYPE}" = "msys"
174 WithGhc=`echo "${WithGhc}" | sed "s#^/\([a-zA-Z]\)/#\1:/#"`
176 # Canonicalise to <drive>:/path/to/ghc
177 WithGhc=`cygpath -m "${WithGhc}"`
179 echo "GHC path canonicalised to: ${WithGhc}"
184 dnl ** Without optimization some INLINE trickery fails for GHCi
187 dnl--------------------------------------------------------------------
188 dnl * Choose host(/target/build) platform
189 dnl--------------------------------------------------------------------
190 dnl If we aren't explicitly told what values to use with configure flags,
191 dnl we ask the bootstrapping compiler what platform it is for
193 if test "${WithGhc}" != ""
195 bootstrap_host=`"${WithGhc}" +RTS --info | grep '^ ,("Host platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
196 bootstrap_target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
197 if test "$bootstrap_host" != "$bootstrap_target"
199 echo "Bootstrapping GHC is a cross compiler. This probably isn't going to work"
203 # We have to run these unconditionally, but we may discard their
204 # results in the following code
209 FPTOOLS_SET_PLATFORM_VARS
211 # Verify that the installed (bootstrap) GHC is capable of generating
212 # code for the requested build platform.
213 if test "$BuildPlatform" != "$bootstrap_target"
215 echo "This GHC (${WithGhc}) does not generate code for the build platform"
216 echo " GHC target platform : $bootstrap_target"
217 echo " Desired build platform : $BuildPlatform"
221 # Testing if we shall enable shared libs support on Solaris.
222 # Anything older than SunOS 5.11 aka Solaris 11 (Express) is broken.
224 SOLARIS_BROKEN_SHLD=NO
228 # here we go with the test
229 MINOR=`uname -r|cut -d '.' -f 2-`
230 if test "$MINOR" -lt "11"; then
231 SOLARIS_BROKEN_SHLD=YES
236 AC_SUBST(SOLARIS_BROKEN_SHLD)
238 dnl ** Do an unregisterised build?
239 dnl --------------------------------------------------------------
241 i386|x86_64|powerpc|arm)
242 UnregisterisedDefault=NO
245 UnregisterisedDefault=YES
248 AC_ARG_ENABLE(unregisterised,
249 [AC_HELP_STRING([--enable-unregisterised],
250 [Build an unregisterised compiler (enabled by default on platforms without registerised support) [default="$UnregisterisedDefault"]])],
251 [ if test x"$enableval" = x"yes"; then
257 [Unregisterised="$UnregisterisedDefault"]
259 AC_SUBST(Unregisterised)
262 [AC_HELP_STRING([--with-hc=ARG],
263 [Use ARG as the path to the compiler for compiling ordinary
264 Haskell code (default= value of --with-ghc)])],
270 # This uses GHC, so put it after the "GHC is required" check above:
274 if test "$HostOS" = "mingw32"
276 test -d inplace || mkdir inplace
278 if test "$HostArch" = "i386"
280 # NB. If you update the tarballs to a new version of gcc, don't
281 # forget to tweak the paths in driver/gcc/gcc.c.
282 if ! test -d inplace/mingw ||
283 test inplace/mingw -ot ghc-tarballs/mingw/binutils*.tar.lzma ||
284 test inplace/mingw -ot ghc-tarballs/mingw/gcc-core*.tar.lzma ||
285 test inplace/mingw -ot ghc-tarballs/mingw/gcc-c++*.tar.lzma ||
286 test inplace/mingw -ot ghc-tarballs/mingw/libgcc*.tar.gz ||
287 test inplace/mingw -ot ghc-tarballs/mingw/libgmp*.tar.gz ||
288 test inplace/mingw -ot ghc-tarballs/mingw/libmpc*.tar.gz ||
289 test inplace/mingw -ot ghc-tarballs/mingw/libmpfr*.tar.gz ||
290 test inplace/mingw -ot ghc-tarballs/mingw/libstdc*.tar.lzma ||
291 test inplace/mingw -ot ghc-tarballs/mingw/mingwrt*-dev.tar.gz ||
292 test inplace/mingw -ot ghc-tarballs/mingw/mingwrt*-dll.tar.gz ||
293 test inplace/mingw -ot ghc-tarballs/mingw/w32api*.tar.lzma
295 AC_MSG_NOTICE([Making in-tree mingw tree])
300 tar --lzma -xf ../../ghc-tarballs/mingw/binutils*.tar.lzma &&
301 tar --lzma -xf ../../ghc-tarballs/mingw/gcc-core*.tar.lzma &&
302 tar --lzma -xf ../../ghc-tarballs/mingw/gcc-c++*.tar.lzma &&
303 tar --lzma -xf ../../ghc-tarballs/mingw/libgcc*.tar.lzma &&
304 tar --lzma -xf ../../ghc-tarballs/mingw/libgmp*.tar.lzma &&
305 tar --lzma -xf ../../ghc-tarballs/mingw/libmpc*.tar.lzma &&
306 tar --lzma -xf ../../ghc-tarballs/mingw/libmpfr*.tar.lzma &&
307 tar --lzma -xf ../../ghc-tarballs/mingw/libstdc*.tar.lzma &&
308 tar -z -xf ../../ghc-tarballs/mingw/mingwrt*-dev.tar.gz &&
309 tar -z -xf ../../ghc-tarballs/mingw/mingwrt*-dll.tar.gz &&
310 tar --lzma -xf ../../ghc-tarballs/mingw/w32api*.tar.lzma &&
311 mv bin/gcc.exe bin/realgcc.exe
313 PATH=`pwd`/inplace/mingw/bin:$PATH 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
314 AC_MSG_NOTICE([In-tree mingw tree created])
317 # NB. If you update the tarballs to a new version of gcc, don't
318 # forget to tweak the paths in driver/gcc/gcc.c.
319 if ! test -d inplace/mingw ||
320 test inplace/mingw -ot ghc-tarballs/mingw64/*.tar.bz2
322 AC_MSG_NOTICE([Making in-tree mingw tree])
327 tar -jxf ../../ghc-tarballs/mingw64/*.tar.bz2
329 AC_MSG_NOTICE([In-tree mingw tree created])
333 mingwbin="$hardtop/inplace/mingw/bin/"
334 CC="${mingwbin}gcc.exe"
335 LD="${mingwbin}ld.exe"
336 NM="${mingwbin}nm.exe"
337 RANLIB="${mingwbin}ranlib.exe"
338 OBJDUMP="${mingwbin}objdump.exe"
339 fp_prog_ar="${mingwbin}ar.exe"
341 if ! test -d inplace/perl ||
342 test inplace/perl -ot ghc-tarballs/perl/ghc-perl*.tar.gz
344 AC_MSG_NOTICE([Making in-tree perl tree])
349 tar -zxf ../../ghc-tarballs/perl/ghc-perl*.tar.gz
351 AC_MSG_NOTICE([In-tree perl tree created])
357 AC_ARG_WITH([system-libffi],
358 [AC_HELP_STRING([--with-system-libffi],
359 [Use system provided libffi for RTS [default=no]])
362 AS_IF([test "x$with_system_libffi" = "xyes"],
363 [UseSystemLibFFI="YES"], [UseSystemLibFFI="NO"]
367 AC_SUBST(UseSystemLibFFI)
369 AC_ARG_WITH([ffi-includes],
370 [AC_HELP_STRING([--with-ffi-includes=ARG]
371 [Find includes for libffi in ARG [default=system default]])
374 if test "x$UseSystemLibFFI" != "xYES"; then
375 AC_MSG_WARN([--with-ffi-includes will be ignored, --with-system-libffi not set])
377 FFIIncludeDir="$withval"
378 LIBFFI_CFLAGS="-I $withval"
382 AC_SUBST(FFIIncludeDir)
384 AC_ARG_WITH([ffi-libraries],
385 [AC_HELP_STRING([--with-ffi-libraries=ARG]
386 [Find libffi in ARG [default=system default]])
389 if test "x$UseSystemLibFFI" != "xYES"; then
390 AC_MSG_WARN([--with-ffi-libraries will be ignored, --with-system-libffi not set])
392 FFILibDir="$withval" LIBFFI_LDFLAGS="-L$withval"
398 AS_IF([test "$UseSystemLibFFI" = "YES"], [
400 CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
402 LDFLAGS="$LIBFFI_LDFLAGS $LDFLAGS"
403 AC_CHECK_LIB(ffi, ffi_call,
404 [AC_CHECK_HEADERS([ffi.h], [break], [])
405 AC_DEFINE([HAVE_LIBFFI], [1], [Define to 1 if you have libffi.])],
406 [AC_MSG_ERROR([Cannot find system libffi])])
417 if test "$TargetOS_CPP" = "darwin"
419 # Split objects is broken (#4013) with XCode < 3.2
420 if test "$XCodeVersion1" -lt 3
424 if test "$XCodeVersion1" -eq 3
426 if test "$XCodeVersion2" -lt 2
433 AC_SUBST([SplitObjsBroken])
435 dnl ** Building a cross compiler?
436 dnl --------------------------------------------------------------
438 # If 'host' and 'target' differ, then this means we are building a cross-compiler.
439 if test "$target" != "$host" ; then
441 cross_compiling=yes # This tells configure that it can accept just 'target',
443 # configure: error: cannot run C compiled programs.
444 # If you meant to cross compile, use `--host'.
446 if test "$build" != "$host" ; then
450 BUILD: $build (the architecture we're building on)
451 HOST: $host (the architecture the compiler we're building will execute on)
452 TARGET: $target (the architecture the compiler we're building will produce code for)
454 BUILD must equal HOST; that is, we do not support building GHC itself
455 with a cross-compiler. To cross-compile GHC itself, set TARGET: stage
456 1 will be a cross-compiler, and stage 2 will be the cross-compiled
460 if test "$CrossCompiling" = "YES"
462 CrossCompilePrefix="${target}-"
464 CrossCompilePrefix=""
466 TargetPlatformFull="${target}"
467 AC_SUBST(CrossCompiling)
468 AC_SUBST(CrossCompilePrefix)
469 AC_SUBST(TargetPlatformFull)
471 dnl ** Which gcc to use?
472 dnl --------------------------------------------------------------
473 FIND_GCC([WhatGccIsCalled], [gcc], [gcc])
474 CC="$WhatGccIsCalled"
477 dnl ** Which ld to use?
478 dnl --------------------------------------------------------------
479 FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
483 dnl ** Which nm to use?
484 dnl --------------------------------------------------------------
485 FP_ARG_WITH_PATH_GNU_PROG([NM], [nm], [nm])
489 # Note: we may not have objdump on OS X, and we only need it on Windows (for DLL checks)
492 dnl ** Which objdump to use?
493 dnl --------------------------------------------------------------
494 FP_ARG_WITH_PATH_GNU_PROG([OBJDUMP], [objdump], [objdump])
495 ObjdumpCmd="$OBJDUMP"
496 AC_SUBST([ObjdumpCmd])
500 dnl ** Which LLVM llc to use?
501 dnl --------------------------------------------------------------
502 FIND_LLVM_PROG([LLC], [llc], [llc])
506 dnl ** Which LLVM opt to use?
507 dnl --------------------------------------------------------------
508 FIND_LLVM_PROG([OPT], [opt], [opt])
512 dnl --------------------------------------------------------------
513 dnl End of configure script option section
514 dnl --------------------------------------------------------------
517 dnl --------------------------------------------------------------
518 dnl * General configuration checks
519 dnl --------------------------------------------------------------
521 dnl ** Can the unix package be built?
522 dnl --------------------------------------------------------------
524 if test "$TargetOS" = "mingw32"
530 AC_SUBST([GhcLibsWithUnix])
535 dnl ** look for `perl'
538 PerlCmd=$hardtop/inplace/perl/perl
541 AC_PATH_PROG(PerlCmd,perl)
542 if test -z "$PerlCmd"
544 echo "You must install perl before you can continue"
545 echo "Perhaps it is already installed, but not in your PATH?"
548 FPTOOLS_CHECK_PERL_VERSION
553 dnl ** look for GCC and find out which version
554 dnl Figure out which C compiler to use. Gcc is preferred.
555 dnl If gcc, make sure it's at least 3.0
559 dnl ** look to see if we have a C compiler using an llvm back end.
565 FP_PROG_LD_NO_COMPACT_UNWIND
569 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
570 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
571 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
572 # Stage 3 won't be supported by cross-compilation
573 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
577 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
580 AC_SUBST(CONF_CC_OPTS_STAGE0)
581 AC_SUBST(CONF_CC_OPTS_STAGE1)
582 AC_SUBST(CONF_CC_OPTS_STAGE2)
583 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
584 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
585 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
586 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
587 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
588 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
589 AC_SUBST(CONF_CPP_OPTS_STAGE0)
590 AC_SUBST(CONF_CPP_OPTS_STAGE1)
591 AC_SUBST(CONF_CPP_OPTS_STAGE2)
593 dnl ** Set up the variables for the platform in the settings file.
594 dnl May need to use gcc to find platform details.
595 dnl --------------------------------------------------------------
596 FPTOOLS_SET_HASKELL_PLATFORM_VARS
598 dnl ** figure out how to do context diffs
601 dnl Let's make sure install-sh is executable here. If we got it from
602 dnl a darcs repo, it might not be (see bug #978).
604 dnl ** figure out how to do a BSD-ish install
607 dnl If you can run configure, you certainly have /bin/sh
608 AC_DEFINE([HAVE_BIN_SH], [1], [Define to 1 if you have /bin/sh.])
610 dnl ** how to invoke `ar' and `ranlib'
611 FP_PROG_AR_SUPPORTS_ATFILE
612 FP_PROG_AR_NEEDS_RANLIB
614 dnl ** Check to see whether ln -s works
619 dnl ** Find the path to sed
620 AC_PATH_PROGS(SedCmd,gsed sed,sed)
623 dnl ** check for time command
624 AC_PATH_PROG(TimeCmd,time)
627 dnl if GNU tar is named gtar, look for it first.
628 AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar)
630 dnl ** check for patch
631 dnl if GNU patch is named gpatch, look for it first
632 AC_PATH_PROGS(PatchCmd,gpatch patch, patch)
634 dnl ** check for dtrace (currently only implemented for Mac OS X)
636 AC_PATH_PROG(DtraceCmd,dtrace)
637 if test -n "$DtraceCmd"; then
638 if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then
644 AC_PATH_PROG(HSCOLOUR,HsColour)
645 # HsColour is passed to Cabal, so we need a native path
646 if test "$HostOS" = "mingw32" && \
647 test "${OSTYPE}" != "msys" && \
648 test "${HSCOLOUR}" != ""
650 # Canonicalise to <drive>:/path/to/gcc
651 HSCOLOUR=`cygpath -m ${HSCOLOUR}`
654 dnl ** check for DocBook toolchain
659 dnl ** check for ghc-pkg command
662 dnl ** check for installed happy binary + version
665 dnl ** check for installed alex binary + version
668 dnl --------------------------------------------------
669 dnl ### program checking section ends here ###
670 dnl --------------------------------------------------
672 dnl --------------------------------------------------
673 dnl * Platform header file and syscall feature tests
674 dnl ### checking the state of the local header files and syscalls ###
676 dnl ** check for full ANSI header (.h) files
679 dnl ** Enable large file support. NB. do this before testing the type of
680 dnl off_t, because it will affect the result of that test.
683 dnl ** check for specific header (.h) files that we are interested in
684 AC_CHECK_HEADERS([bfd.h 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])
686 dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
687 AC_CHECK_HEADERS([sys/cpuset.h], [], [],
688 [[#if HAVE_SYS_PARAM_H
689 # include <sys/param.h>
693 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
696 dnl ** do we have long longs?
697 AC_CHECK_TYPES([long long])
699 dnl ** what are the sizes of various types
700 AC_CHECK_SIZEOF(char, 1)
701 AC_CHECK_SIZEOF(double, 8)
702 AC_CHECK_SIZEOF(float, 4)
703 AC_CHECK_SIZEOF(int, 4)
704 AC_CHECK_SIZEOF(long, 4)
705 if test "$ac_cv_type_long_long" = yes; then
706 AC_CHECK_SIZEOF(long long, 8)
708 AC_CHECK_SIZEOF(short, 2)
709 AC_CHECK_SIZEOF(unsigned char, 1)
710 AC_CHECK_SIZEOF(unsigned int, 4)
711 AC_CHECK_SIZEOF(unsigned long, 4)
712 if test "$ac_cv_type_long_long" = yes; then
713 AC_CHECK_SIZEOF(unsigned long long, 8)
715 AC_CHECK_SIZEOF(unsigned short, 2)
716 AC_CHECK_SIZEOF(void *, 4)
718 dnl for use in settings.in
719 WordSize=$ac_cv_sizeof_void_p
722 dnl ** what are alignment constraints on various types
723 FP_CHECK_ALIGNMENT(char)
724 FP_CHECK_ALIGNMENT(double)
725 FP_CHECK_ALIGNMENT(float)
726 FP_CHECK_ALIGNMENT(int)
727 FP_CHECK_ALIGNMENT(long)
728 if test "$ac_cv_type_long_long" = yes; then
729 FP_CHECK_ALIGNMENT(long long)
731 FP_CHECK_ALIGNMENT(short)
732 FP_CHECK_ALIGNMENT(unsigned char)
733 FP_CHECK_ALIGNMENT(unsigned int)
734 FP_CHECK_ALIGNMENT(unsigned long)
735 if test "$ac_cv_type_long_long" = yes; then
736 FP_CHECK_ALIGNMENT(unsigned long long)
738 FP_CHECK_ALIGNMENT(unsigned short)
739 FP_CHECK_ALIGNMENT(void *)
741 FP_CHECK_FUNC([WinExec],
742 [@%:@include <windows.h>], [WinExec("",0)])
744 FP_CHECK_FUNC([GetModuleFileName],
745 [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
747 dnl ** check return type of signal handlers
748 dnl Foo: assumes we can use prototypes.
749 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
750 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
751 dnl [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
752 dnl #include <signal.h>
756 dnl void (*signal (int, void (*)(int)))(int);
759 dnl [ac_cv_type_signal_handler=void_int],
760 dnl [ac_cv_type_signal_handler=int_void])])
761 dnl if test "$ac_cv_type_signal_handler" = void_int; then
762 dnl AC_DEFINE(VOID_INT_SIGNALS)
765 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
767 if test "$ac_cv_type_signal" = void; then
768 AC_DEFINE([VOID_INT_SIGNALS], [1], [Define to 1 if signal handlers have type void (*)(int). Otherwise, they're assumed to have type int (*)(void).])
771 dnl ** check for more functions
772 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
773 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity setlocale])
775 dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
776 dnl ** _POSIX_C_SOURCE is defined
777 AC_CHECK_DECLS([ctime_r], , ,
778 [#define _POSIX_SOURCE 1
779 #define _POSIX_C_SOURCE 199506L
782 dnl ** check for mingwex library
783 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
784 AC_SUBST(HaveLibMingwEx)
786 if test $HaveLibMingwEx = YES ; then
787 AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
790 dnl ** check for math library
791 dnl Keep that check as early as possible.
792 dnl as we need to know whether we need libm
793 dnl for math functions or not
794 dnl (see http://hackage.haskell.org/trac/ghc/ticket/3730)
795 AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO)
796 if test $HaveLibM = YES
798 AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])
801 dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
802 dnl the order of these tests matters: bfd needs libiberty
803 AC_CHECK_LIB(iberty, xmalloc)
804 AC_CHECK_LIB(bfd, bfd_uncompress_section_contents)
806 dnl ################################################################
807 dnl Check for libraries
808 dnl ################################################################
810 dnl ** check whether we need -ldl to get dlopen()
812 AC_CHECK_LIB(dl, dlopen,
814 AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if you need -ldl to get dlopen().])
819 dnl --------------------------------------------------
820 dnl * Miscellaneous feature tests
821 dnl --------------------------------------------------
823 dnl ** can we get alloca?
826 dnl ** working vfork?
829 dnl ** determine whether or not const works
832 dnl ** are we big endian?
834 FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
836 dnl ** check for leading underscores in symbol names
837 FP_LEADING_UNDERSCORE
841 dnl ** check for librt
842 AC_CHECK_LIB(rt, clock_gettime)
843 AC_CHECK_FUNCS(clock_gettime timer_settime)
844 FP_CHECK_TIMER_CREATE
846 dnl ** check for Apple's "interesting" long double compatibility scheme
847 AC_MSG_CHECKING(for printf\$LDBLStub)
848 AC_TRY_LINK_FUNC(printf\$LDBLStub,
851 AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
852 [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
856 AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
857 [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
860 dnl ** check for eventfd which is needed by the I/O manager
861 AC_CHECK_HEADERS([sys/eventfd.h])
862 AC_CHECK_FUNCS([eventfd])
865 AC_CHECK_LIB(papi, PAPI_library_init, HavePapiLib=YES, HavePapiLib=NO)
866 AC_CHECK_HEADER([papi.h], [HavePapiHeader=YES], [HavePapiHeader=NO])
867 AC_SUBST(HavePapiLib)
868 AC_SUBST(HavePapiHeader)
870 AC_CHECK_FUNCS(__mingw_vfprintf)
872 if test "$HavePapiLib" = "YES" -a "$HavePapiHeader" = "YES"; then
879 if test "$HAVE_DOCBOOK_XSL" = "NO" ||
880 test "$XsltprocCmd" = ""
882 BUILD_DOCBOOK_HTML=NO
884 BUILD_DOCBOOK_HTML=YES
886 AC_SUBST(BUILD_DOCBOOK_HTML)
888 if test "$DblatexCmd" = ""
894 BUILD_DOCBOOK_PDF=YES
896 AC_SUBST(BUILD_DOCBOOK_PS)
897 AC_SUBST(BUILD_DOCBOOK_PDF)
899 LIBRARY_VERSION(base)
900 LIBRARY_VERSION(Cabal, Cabal/Cabal)
901 LIBRARY_VERSION(ghc-prim)
902 LIBRARY_ghc_VERSION="$ProjectVersion"
903 AC_SUBST(LIBRARY_ghc_VERSION)
905 if grep ' ' compiler/ghc.cabal.in 2>&1 >/dev/null; then
906 AC_MSG_ERROR([compiler/ghc.cabal.in contains tab characters; please remove them])
909 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])
913 # http://savannah.gnu.org/bugs/index.php?1516
914 # $(eval ...) inside conditionals causes errors
915 # with make 3.80, so warn the user if it looks like they're about to
917 # We would use "grep -q" here, but Solaris's grep doesn't support it.
919 if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
922 echo "WARNING: It looks like \"$1\" is GNU make 3.80."
923 echo "This version cannot be used to build GHC."
924 echo "Please use GNU make >= 3.81."
932 ----------------------------------------------------------------------
933 Configure completed successfully.
935 Building GHC version : $ProjectVersion
937 Build platform : $BuildPlatform
938 Host platform : $HostPlatform
939 Target platform : $TargetPlatform
943 Bootstrapping using : $WithGhc
944 which is version : $GhcVersion
947 if test "x$CC_LLVM_BACKEND" = "x1"; then
948 if test "x$CC_CLANG_BACKEND" = "x1"; then
949 CompilerName="clang "
951 CompilerName="llvm-gcc "
958 Using $CompilerName : $WhatGccIsCalled
959 which is version : $GccVersion
960 Building a cross compiler : $CrossCompiling
963 Happy : $HappyCmd ($HappyVersion)
964 Alex : $AlexCmd ($AlexVersion)
966 dblatex : $DblatexCmd
967 xsltproc : $XsltprocCmd
973 if test "$HSCOLOUR" = ""; then
975 HsColour was not found; documentation will not contain source links
984 Building DocBook HTML documentation : $BUILD_DOCBOOK_HTML
985 Building DocBook PS documentation : $BUILD_DOCBOOK_PS
986 Building DocBook PDF documentation : $BUILD_DOCBOOK_PDF"]
988 echo ["----------------------------------------------------------------------
992 For a standard build of GHC (fully optimised with profiling), type (g)make.
994 To make changes to the default build configuration, copy the file
995 mk/build.mk.sample to mk/build.mk, and edit the settings in there.
997 For more information on how to configure your GHC build, see
998 http://hackage.haskell.org/trac/ghc/wiki/Building