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-2004
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], [6.13], [glasgow-haskell-bugs@haskell.org], [ghc])
18 # Set this to YES for a released version, otherwise NO
23 # The primary version (e.g. 6.7, 6.6.1) is set in the AC_INIT line
24 # above. If this is not a released version, then we will append the
25 # date to the version number (e.g. 6.7.20070204). The date is
26 # constructed by finding the date of the most recent patch in the
27 # darcs repository. If this is a source distribution (not a darcs
28 # checkout), then we ship a file 'VERSION' containing the full version
29 # when the source distribution was created.
31 if test ! -f mk/config.h.in; then
32 echo "mk/config.h.in doesn't exist: perhaps you haven't run 'sh boot'?"
36 AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
38 dnl ----------------------------------------------------------
39 dnl ** Find unixy sort and find commands,
40 dnl ** which are needed by FP_SETUP_PROJECT_VERSION
42 dnl ** Find find command (for Win32's benefit)
45 dnl ** Find sort command (for the benefit of Win32 environs)
48 dnl ----------------------------------------------------------
49 FP_SETUP_PROJECT_VERSION
51 # Hmmm, we fix the RPM release number to 1 here... Is this convenient?
52 AC_SUBST([release], [1])
54 # First off, a distrib sanity check..
55 AC_CONFIG_SRCDIR([mk/config.mk.in])
57 dnl * We require autoconf version 2.52
58 dnl We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE.
59 dnl We need 2.52 due to the use of AS_TR_CPP and AS_TR_SH.
62 # -------------------------------------------------------------------------
63 # Prepare to generate the following header files
66 AC_CONFIG_HEADER(mk/config.h)
68 # No, semi-sadly, we don't do `--srcdir'...
69 if test x"$srcdir" != 'x.' ; then
70 echo "This configuration does not support the \`--srcdir' option.."
74 dnl --------------------------------------------------------------
75 dnl * Project specific configuration options
76 dnl --------------------------------------------------------------
77 dnl What follows is a bunch of options that can either be configured
78 dnl through command line options to the configure script or by
79 dnl supplying defns in the build tree's mk/build.mk. Having the option to
80 dnl use either is considered a Feature.
82 dnl ** What command to use to compile compiler sources ?
83 dnl --------------------------------------------------------------
86 [AC_HELP_STRING([--with-ghc=ARG],
87 [Use ARG as the path to GHC [default=autodetect]])],
89 [if test "$GHC" = ""; then
90 AC_PATH_PROG([GHC], [ghc])
94 dnl ** Booting from .hc files?
95 dnl --------------------------------------------------------------
96 AC_ARG_ENABLE(hc-boot,
97 [AC_HELP_STRING([--enable-hc-boot],
98 [Boot the Glasgow Haskell Compiler from intermediate .hc files.
99 (This option is mostly of interest to porters.) [default=no]])],
100 [ if test x"$enableval" = x"yes"; then
108 AC_SUBST(BootingFromHc)
110 AC_ARG_ENABLE(bootstrap-with-devel-snapshot,
111 [AC_HELP_STRING([--enable-bootstrap-with-devel-snapshot],
112 [Allow bootstrapping using a development snapshot of GHC. This is not guaranteed to work.])],
113 EnableBootstrapWithDevelSnaphost=YES,
114 EnableBootstrapWithDevelSnaphost=NO
117 if test "$WithGhc" != ""; then
118 FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
120 if test "$GhcMajVersion" = "unknown" -o "$GhcMinVersion" = "unknown"; then
121 AC_MSG_ERROR([Cannot determine the version of $WithGhc. Is it really GHC?])
124 AC_SUBST(GhcVersion)dnl
125 AC_SUBST(GhcMajVersion)dnl
126 AC_SUBST(GhcMinVersion)dnl
127 AC_SUBST(GhcPatchLevel)dnl
128 GhcMinVersion2=`echo "$GhcMinVersion" | sed 's/^\\(.\\)$/0\\1/'`
129 GhcCanonVersion="$GhcMajVersion$GhcMinVersion2"
130 if test $GhcCanonVersion -ge 609; then ghc_ge_609=YES; else ghc_ge_609=NO; fi
131 FP_COMPARE_VERSIONS($GhcVersion,[-ge],[6.10.2],
132 [ghc_ge_6102=YES], [ghc_ge_6102=NO])
133 if test $GhcCanonVersion -ge 611; then ghc_ge_611=YES; else ghc_ge_611=NO; fi
134 AC_SUBST(ghc_ge_609)dnl
135 AC_SUBST(ghc_ge_6102)dnl
136 AC_SUBST(ghc_ge_611)dnl
139 dnl ** Must have GHC to build GHC, unless --enable-hc-boot is on
140 if test "$BootingFromHc" = "NO" -a -d "$srcdir/compiler"; then
141 if test "$WithGhc" = ""; then
142 AC_MSG_ERROR([GHC is required unless bootstrapping from .hc files.])
144 FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[6.8],
145 [AC_MSG_ERROR([GHC version 6.8 or later is required to compile GHC.])])dnl
147 if test `expr $GhcMinVersion % 2` = "1"; then
148 if test "$EnableBootstrapWithDevelSnaphost" = "NO"; then
150 $WithGhc is a development snapshot of GHC, version $GhcVersion.
151 Bootstrapping using this version of GHC is not supported, and may not
152 work. Use --enable-bootstrap-with-devel-snapshot to try it anyway,
153 or --with-ghc to specify a different GHC to use.])
158 # GHC is passed to Cabal, so we need a native path
159 if test "${WithGhc}" != ""
161 ghc_host=`${WithGhc} +RTS --info | grep 'Host platform' | sed -e 's/.*, "//' -e 's/")//'`
163 if test "$ghc_host" = "i386-unknown-mingw32"
165 if test "${OSTYPE}" = "msys"
167 WithGhc=`echo "${WithGhc}" | sed "s#^/\([a-zA-Z]\)/#\1:/#"`
169 # Canonicalise to <drive>:/path/to/ghc
170 WithGhc=`cygpath -m ${WithGhc}`
172 echo "GHC path canonicalised to: ${WithGhc}"
177 dnl ** Without optimization some INLINE trickery fails for GHCi
180 dnl Allow to specify iconv options to the toplevel configure script
181 dnl so they can be properly passed to sub-builds.
182 dnl Note: ICONV_LIB_DIRS and ICONV_INCLUDE_DIRS are not predefined
183 dnl to the empty string to allow them to be overridden from the
186 AC_ARG_WITH([iconv-includes],
187 [AC_HELP_STRING([--with-iconv-includes],
188 [directory containing iconv.h])],
189 [ICONV_INCLUDE_DIRS=$withval])
191 AC_ARG_WITH([iconv-libraries],
192 [AC_HELP_STRING([--with-iconv-libraries],
193 [directory containing iconv library])],
194 [ICONV_LIB_DIRS=$withval])
196 AC_SUBST(ICONV_INCLUDE_DIRS)
197 AC_SUBST(ICONV_LIB_DIRS)
199 dnl--------------------------------------------------------------------
200 dnl * Choose host(/target/build) platform
201 dnl--------------------------------------------------------------------
202 dnl We don't use the standard autoconf macros for this, but instead
203 dnl ask the bootstrapping compiler what platform it is for
205 dnl Guess host/target/build platform(s) if necessary.
206 m4_divert_once([HELP_CANON],
209 --build=BUILD configure for building on BUILD [guessed]
210 --host=HOST cross-compile to build programs to run on HOST [guessed]
211 --target=TARGET configure for building compilers for TARGET [guessed]]])dnl
213 if test "$build" = ""
215 if test "${WithGhc}" != ""
217 build=`${WithGhc} +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
218 echo "Build platform inferred as: $build"
220 echo "Can't work out build platform"
227 if test "${WithGhc}" != ""
229 host=`${WithGhc} +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
230 echo "Host platform inferred as: $host"
232 echo "Can't work out host platform"
237 if test "$target" = ""
239 if test "${WithGhc}" != ""
241 target=`${WithGhc} +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
242 echo "Target platform inferred as: $target"
244 echo "Can't work out target platform"
253 AC_MSG_WARN([GHC does not support the Cygwin target at the moment])
254 AC_MSG_WARN([I'm assuming you wanted to build for i386-unknown-mingw32])
261 i386-apple-darwin|powerpc-apple-darwin)
263 CFLAGS="$CFLAGS -m32"
264 LDFLAGS="$LDFLAGS -m32"
265 CONF_CC_OPTS="$CONF_CC_OPTS -m32"
266 CONF_LD_OPTS="$CONF_LD_OPTS -m32"
270 CFLAGS="$CFLAGS -m64"
271 LDFLAGS="$LDFLAGS -m64"
272 CONF_CC_OPTS="$CONF_CC_OPTS -m64"
273 CONF_LD_OPTS="$CONF_LD_OPTS -m64"
279 alpha|arm|hppa|hppa1_1|i386|ia64|m68k|mips|mipseb|mipsel|powerpc|powerpc64|rs6000|s390|sparc|sparc64|vax|x86_64)
282 echo "Unknown arch $1"
290 dec|unknown|hp|apple|next|sun|sgi|ibm)
293 echo "Unknown vendor $1"
301 linux|freebsd|netbsd|openbsd|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|cygwin32|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|aix)
304 echo "Unknown OS '$1'"
311 BuildArch=`echo "$build" | sed 's/-.*//'`
312 BuildVendor=`echo "$build" | sed -e 's/.*-\(.*\)-.*/\1/'`
313 BuildOS=`echo "$build" | sed 's/.*-//'`
314 BuildPlatform_CPP=`echo "$BuildPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
315 BuildArch_CPP=` echo "$BuildArch" | sed -e 's/\./_/g' -e 's/-/_/g'`
316 BuildVendor_CPP=` echo "$BuildVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
317 BuildOS_CPP=` echo "$BuildOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
319 checkArch "$BuildArch"
320 checkVendor "$BuildVendor"
324 HostArch=`echo "$host" | sed 's/-.*//'`
325 HostVendor=`echo "$host" | sed -e 's/.*-\(.*\)-.*/\1/'`
326 HostOS=`echo "$host" | sed 's/.*-//'`
327 HostPlatform_CPP=`echo "$HostPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
328 HostArch_CPP=` echo "$HostArch" | sed -e 's/\./_/g' -e 's/-/_/g'`
329 HostVendor_CPP=` echo "$HostVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
330 HostOS_CPP=` echo "$HostOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
332 checkArch "$HostArch"
333 checkVendor "$HostVendor"
336 TargetPlatform=$target
337 TargetArch=`echo "$target" | sed 's/-.*//'`
338 TargetVendor=`echo "$target" | sed -e 's/.*-\(.*\)-.*/\1/'`
339 TargetOS=`echo "$target" | sed 's/.*-//'`
340 TargetPlatform_CPP=`echo "$TargetPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
341 TargetArch_CPP=` echo "$TargetArch" | sed -e 's/\./_/g' -e 's/-/_/g'`
342 TargetVendor_CPP=` echo "$TargetVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
343 TargetOS_CPP=` echo "$TargetOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
345 checkArch "$TargetArch"
346 checkVendor "$TargetVendor"
349 AC_SUBST(BuildPlatform)
350 AC_SUBST(HostPlatform)
351 AC_SUBST(TargetPlatform)
352 AC_SUBST(HostPlatform_CPP)
353 AC_SUBST(BuildPlatform_CPP)
354 AC_SUBST(TargetPlatform_CPP)
356 AC_SUBST(HostArch_CPP)
357 AC_SUBST(BuildArch_CPP)
358 AC_SUBST(TargetArch_CPP)
361 AC_SUBST(BuildOS_CPP)
362 AC_SUBST(TargetOS_CPP)
364 AC_SUBST(HostVendor_CPP)
365 AC_SUBST(BuildVendor_CPP)
366 AC_SUBST(TargetVendor_CPP)
372 [AC_HELP_STRING([--with-hc=ARG],
373 [Use ARG as the path to the compiler for compiling ordinary
374 Haskell code (default= value of --with-ghc)])],
380 AC_PATH_PROGS(NHC,nhc nhc98)
381 AC_PATH_PROG(HBC,hbc)
383 # This uses GHC, so put it after the "GHC is required" check above:
386 if test "$HostOS" = "mingw32"
388 CC="$hardtop/inplace/mingw/bin/gcc.exe"
389 LD="$hardtop/inplace/mingw/bin/ld.exe"
390 NM="$hardtop/inplace/mingw/bin/nm.exe"
391 if ! test -d inplace/mingw ||
392 test inplace/mingw -ot ghc-tarballs/mingw/binutils*.tar.gz ||
393 test inplace/mingw -ot ghc-tarballs/mingw/gcc-core*.tar.gz ||
394 test inplace/mingw -ot ghc-tarballs/mingw/libcrypt*.tar.bz2 ||
395 test inplace/mingw -ot ghc-tarballs/mingw/mingw-runtime*.tar.gz ||
396 test inplace/mingw -ot ghc-tarballs/mingw/perl*.tar.bz2 ||
397 test inplace/mingw -ot ghc-tarballs/mingw/w32api*.tar.gz
399 AC_MSG_NOTICE([Making in-tree mingw tree])
404 tar -zxf ../../ghc-tarballs/mingw/binutils*.tar.gz
405 tar -zxf ../../ghc-tarballs/mingw/gcc-core*.tar.gz
406 tar -jxf ../../ghc-tarballs/mingw/libcrypt*.tar.bz2
407 tar -zxf ../../ghc-tarballs/mingw/mingw-runtime*.tar.gz
408 tar -jxf ../../ghc-tarballs/mingw/perl*.tar.bz2
409 tar -zxf ../../ghc-tarballs/mingw/w32api*.tar.gz
411 AC_MSG_NOTICE([In-tree mingw tree created])
415 dnl ** Which gcc to use?
416 dnl --------------------------------------------------------------
417 FP_ARG_WITH_PATH_GNU_PROG([CC], [gcc])
419 WhatGccIsCalled="$CC"
420 AC_SUBST(WhatGccIsCalled)
422 dnl ** Which ld to use?
423 dnl --------------------------------------------------------------
424 FP_ARG_WITH_PATH_GNU_PROG([LD], [ld])
428 dnl ** Which nm to use?
429 dnl --------------------------------------------------------------
430 FP_ARG_WITH_PATH_GNU_PROG([NM], [nm])
434 dnl ** Mac OS X: explicit deployment target
435 dnl --------------------------------------------------------------
436 AC_ARG_WITH([macosx-deployment-target],
437 [AC_HELP_STRING([--with-macosx-deployment-target=VERSION],
438 [Build for Mac OS VERSION and higher (default= version of build host)])],
439 [FP_MACOSX_DEPLOYMENT_TARGET="$withval"
440 if test "x$TargetOS_CPP-$TargetVendor_CPP" != "xdarwin-apple"; then
441 # ignore everywhere, but on Mac OS
442 AC_MSG_WARN([--macosx-deployment-target is only available on Mac OS X])
443 FP_MACOSX_DEPLOYMENT_TARGET=none
445 [FP_MACOSX_DEPLOYMENT_TARGET=none]
447 FP_CHECK_MACOSX_DEPLOYMENT_TARGET
448 AC_SUBST(MACOSX_DEPLOYMENT_VERSION)
449 AC_SUBST(MACOSX_DEPLOYMENT_SDK)
451 dnl --------------------------------------------------------------
452 dnl End of configure script option section
453 dnl --------------------------------------------------------------
456 dnl --------------------------------------------------------------
457 dnl * General configuration checks
458 dnl --------------------------------------------------------------
460 dnl ** Can the unix package be built?
461 dnl --------------------------------------------------------------
463 if test x"$TargetPlatform" = x"i386-unknown-mingw32"; then
468 AC_SUBST([GhcLibsWithUnix])
473 dnl ** look for `perl', but only in /bin on Windows
476 AC_CHECK_PROG(PerlCmd,perl,/bin/perl,,/bin)
477 if test -z "$PerlCmd"; then
478 echo "You must install the version of Perl shipped with GHC"
479 echo "(or a compatible one) in /bin."
484 AC_PATH_PROG(PerlCmd,perl)
485 if test -z "$PerlCmd"; then
486 echo "You must install perl before you can continue"
487 echo "Perhaps it is already installed, but not in your PATH?"
490 FPTOOLS_CHECK_PERL_VERSION
495 dnl ** does #! path/to/perl work? (sometimes it's too long...)
498 dnl ** check for Python
499 AC_PATH_PROG(PythonCmd,python)
501 dnl ** look for GCC and find out which version
502 dnl Figure out which C compiler to use. Gcc is preferred.
503 dnl If gcc, make sure it's at least 2.1
508 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
511 AC_SUBST(CONF_CC_OPTS)
512 AC_SUBST(CONF_LD_OPTS)
514 dnl ** figure out how to do context diffs
517 dnl Let's make sure install-sh is executable here. If we got it from
518 dnl a darcs repo, it might not be (see bug #978).
520 dnl ** figure out how to do a BSD-ish install
523 dnl If you can run configure, you certainly have /bin/sh
524 AC_DEFINE([HAVE_BIN_SH], [1], [Define to 1 if you have /bin/sh.])
526 dnl ** how to invoke `ar' and `ranlib'
527 FP_PROG_AR_NEEDS_RANLIB
528 FP_PROG_AR_SUPPORTS_INPUT
530 dnl ** Check to see whether ln -s works
534 dnl ** Find the path to sed
535 AC_PATH_PROG(SedCmd,sed)
538 dnl ** check for time command
539 AC_PATH_PROG(TimeCmd,time)
542 dnl if GNU tar is named gtar, look for it first.
543 AC_PATH_PROGS(TarCmd,gtar tar,tar)
545 dnl ** check for patch
546 dnl if GNU patch is named gpatch, look for it first
547 AC_PATH_PROGS(PatchCmd,gpatch patch, patch)
549 AC_PATH_PROG(HSCOLOUR,HsColour)
550 # HsColour is passed to Cabal, so we need a native path
551 if test "x$HostPlatform" = "xi386-unknown-mingw32" && \
552 test "${OSTYPE}" != "msys" && \
553 test "${HSCOLOUR}" != ""
555 # Canonicalise to <drive>:/path/to/gcc
556 HSCOLOUR=`cygpath -m ${HSCOLOUR}`
559 dnl ** check for DocBook toolchain
566 dnl ** check for ghc-pkg command
569 dnl ** check for installed happy binary + version
570 dnl (don't do it if we're booting from .hc files though.)
571 if test "$BootingFromHc" = "NO"; then
575 dnl ** check for installed alex binary + version
576 dnl (don't do it if we're booting from .hc files though.)
577 if test "$BootingFromHc" = "NO"; then
581 dnl --------------------------------------------------
582 dnl ### program checking section ends here ###
583 dnl --------------------------------------------------
585 dnl --------------------------------------------------
586 dnl * Platform header file and syscall feature tests
587 dnl ### checking the state of the local header files and syscalls ###
589 dnl ** check for full ANSI header (.h) files
592 dnl ** Enable large file support. NB. do this before testing the type of
593 dnl off_t, because it will affect the result of that test.
596 dnl ** check for specific header (.h) files that we are interested in
597 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/mman.h sys/resource.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])
599 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
602 dnl ** do we have long longs?
603 AC_CHECK_TYPES([long long])
605 dnl ** what are the sizes of various types
606 AC_CHECK_SIZEOF(char, 1)
607 AC_CHECK_SIZEOF(double, 8)
608 AC_CHECK_SIZEOF(float, 4)
609 AC_CHECK_SIZEOF(int, 4)
610 AC_CHECK_SIZEOF(long, 4)
611 if test "$ac_cv_type_long_long" = yes; then
612 AC_CHECK_SIZEOF(long long, 8)
614 AC_CHECK_SIZEOF(short, 2)
615 AC_CHECK_SIZEOF(unsigned char, 1)
616 AC_CHECK_SIZEOF(unsigned int, 4)
617 AC_CHECK_SIZEOF(unsigned long, 4)
618 if test "$ac_cv_type_long_long" = yes; then
619 AC_CHECK_SIZEOF(unsigned long long, 8)
621 AC_CHECK_SIZEOF(unsigned short, 2)
622 AC_CHECK_SIZEOF(void *, 4)
624 dnl ** what are alignment constraints on various types
625 FP_CHECK_ALIGNMENT(char)
626 FP_CHECK_ALIGNMENT(double)
627 FP_CHECK_ALIGNMENT(float)
628 FP_CHECK_ALIGNMENT(int)
629 FP_CHECK_ALIGNMENT(long)
630 if test "$ac_cv_type_long_long" = yes; then
631 FP_CHECK_ALIGNMENT(long long)
633 FP_CHECK_ALIGNMENT(short)
634 FP_CHECK_ALIGNMENT(unsigned char)
635 FP_CHECK_ALIGNMENT(unsigned int)
636 FP_CHECK_ALIGNMENT(unsigned long)
637 if test "$ac_cv_type_long_long" = yes; then
638 FP_CHECK_ALIGNMENT(unsigned long long)
640 FP_CHECK_ALIGNMENT(unsigned short)
641 FP_CHECK_ALIGNMENT(void *)
643 FP_CHECK_FUNC([WinExec],
644 [@%:@include <windows.h>], [WinExec("",0)])
646 FP_CHECK_FUNC([GetModuleFileName],
647 [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
649 dnl ** check return type of signal handlers
650 dnl Foo: assumes we can use prototypes.
651 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
652 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
653 dnl [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
654 dnl #include <signal.h>
658 dnl void (*signal (int, void (*)(int)))(int);
661 dnl [ac_cv_type_signal_handler=void_int],
662 dnl [ac_cv_type_signal_handler=int_void])])
663 dnl if test "$ac_cv_type_signal_handler" = void_int; then
664 dnl AC_DEFINE(VOID_INT_SIGNALS)
667 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
669 if test "$ac_cv_type_signal" = void; then
670 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).])
673 dnl ** check for more functions
674 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
675 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity setlocale])
678 #include <sys/types.h>
679 #include <sys/time.h>
681 struct itimerval tval;
682 tval.it_value.tv_sec = 1;
683 tval.it_value.tv_usec = 0;
684 tval.it_interval = tval.it_value;
685 return setitimer(ITIMER_VIRTUAL, &tval, (void*)0) != 0;
687 ],[AC_DEFINE([HAVE_SETITIMER_VIRTUAL], [1], [Define to 1 if setitimer accepts ITIMER_VIRTUAL, 0 else.])])
689 dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
690 dnl ** _POSIX_C_SOURCE is defined
691 AC_CHECK_DECLS([ctime_r], , ,
692 [#define _POSIX_SOURCE 1
693 #define _POSIX_C_SOURCE 199506L
696 dnl ** check for mingwex library
697 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
698 AC_SUBST(HaveLibMingwEx)
700 if test $HaveLibMingwEx = YES ; then
701 AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
704 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
705 dnl the order of these tests matters: bfd needs liberty
706 AC_CHECK_LIB(iberty, xmalloc)
707 AC_CHECK_LIB(bfd, bfd_init)
709 dnl ** check for math library
710 AC_CHECK_FUNC(atan,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
711 if test x"$fp_libm_not_needed" = xdunno; then
712 AC_CHECK_LIB([m], [atan], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
716 dnl ################################################################
717 dnl Check for libraries
718 dnl ################################################################
720 dnl ** check whether we need -ldl to get dlopen()
722 AC_CHECK_LIB(dl, dlopen,
724 AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if you need -ldl to get dlopen().])
729 dnl --------------------------------------------------
730 dnl * Miscellaneous feature tests
731 dnl --------------------------------------------------
733 dnl ** can we get alloca?
736 dnl ** Working vfork?
739 dnl ** determine whether or not const works
742 dnl ** are we big endian?
744 FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
746 dnl ** check for leading underscores in symbol names
747 FP_LEADING_UNDERSCORE
749 dnl ** check for ld, whether it has an -x option, and if it is GNU ld
753 dnl ** check for Apple-style dead-stripping support
754 dnl (.subsections-via-symbols assembler directive)
757 AC_MSG_CHECKING(for .subsections_via_symbols)
759 [AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
761 AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
762 [Define to 1 if Apple-style dead-stripping is supported.])
766 dnl *** check for GNU non-executable stack note support (ELF only)
767 dnl (.section .note.GNU-stack,"",@progbits)
769 AC_MSG_CHECKING(for GNU non-executable stack support)
771 [AC_LANG_PROGRAM([__asm__ (".section .note.GNU-stack,\"\",@progbits");], [0])],
773 AC_DEFINE([HAVE_GNU_NONEXEC_STACK],[1],
774 [Define to 1 if GNU non-executable stack notes are supported.])
778 dnl ** check for librt
779 AC_CHECK_LIB(rt, clock_gettime)
780 AC_CHECK_FUNCS(clock_gettime timer_create timer_settime)
781 FP_CHECK_TIMER_CREATE
783 dnl ** check for Apple's "interesting" long double compatibility scheme
784 AC_MSG_CHECKING(for printf\$LDBLStub)
785 AC_TRY_LINK_FUNC(printf\$LDBLStub,
788 AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
789 [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
793 AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
794 [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
798 AC_PATH_PROGS([GTK_CONFIG], [pkg-config])
799 if test -n "$GTK_CONFIG"; then
800 if $GTK_CONFIG gtk+-2.0 --atleast-version=2.0; then
801 GTK_CONFIG="$GTK_CONFIG gtk+-2.0"
803 AC_MSG_WARN([GTK+ not usable, need at least version 2.0])
807 AC_SUBST([GTK_CONFIG])
810 AC_CHECK_LIB(papi, PAPI_library_init, HavePapiLib=YES, HavePapiLib=NO)
811 AC_CHECK_HEADER([papi.h], [HavePapiHeader=YES], [HavePapiHeader=NO])
812 AC_SUBST(HavePapiLib)
813 AC_SUBST(HavePapiHeader)
815 AC_CHECK_FUNCS(__mingw_vfprintf)
817 if test "$HavePapiLib" = "YES" -a "$HavePapiHeader" = "YES"; then
824 if test "$HAVE_DOCBOOK_XSL" = "NO" ||
825 test "$XsltprocCmd" = ""
827 BUILD_DOCBOOK_HTML=NO
829 BUILD_DOCBOOK_HTML=YES
831 AC_SUBST(BUILD_DOCBOOK_HTML)
833 if test "$DblatexCmd" = ""
839 BUILD_DOCBOOK_PDF=YES
841 AC_SUBST(BUILD_DOCBOOK_PS)
842 AC_SUBST(BUILD_DOCBOOK_PDF)
844 if grep ' ' compiler/ghc.cabal.in 2>&1 >/dev/null; then
845 AC_MSG_ERROR([compiler/ghc.cabal.in contains tab characters; please remove them])
848 AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal ghc.spec extra-gcc-opts docs/users_guide/ug-book.xml distrib/ghc.iss distrib/configure-bin.ac])
849 AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp > mk/stamp-h])
853 # http://savannah.gnu.org/bugs/index.php?1516
854 # $(eval ...) inside conditionals causes errors
855 # with make 3.80, so warn the user if it looks like they're about to
857 # We would use "grep -q" here, but Solaris's grep doesn't support it.
859 if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
862 echo "WARNING: It looks like \"$1\" is GNU make 3.80."
863 echo "This version cannot be used to build GHC."
864 echo "Please use GNU make >= 3.81."
872 ----------------------------------------------------------------------
873 Configure completed successfully.
875 Building GHC version : $ProjectVersion
877 Build platform : $BuildPlatform
878 Host platform : $HostPlatform
879 Target platform : $TargetPlatform
882 if test "$BootingFromHc" = "YES"; then
884 Bootstrapping from HC files.
888 Bootstrapping using : $WithGhc
889 which is version : $GhcVersion
894 Using GCC : $WhatGccIsCalled
895 which is version : $GccVersion
898 Happy : $HappyCmd ($HappyVersion)
899 Alex : $AlexCmd ($AlexVersion)
902 dblatex : $DblatexCmd
903 xsltproc : $XsltprocCmd"]
905 if test "$HSCOLOUR" = ""; then
907 HsColour was not found; documentation will not contain source links
916 Building DocBook HTML documentation : $BUILD_DOCBOOK_HTML
917 Building DocBook PS documentation : $BUILD_DOCBOOK_PS
918 Building DocBook PDF documentation : $BUILD_DOCBOOK_PDF"]
920 echo ["----------------------------------------------------------------------
924 For a standard build of GHC (fully optimised with profiling), type (g)make.
926 To make changes to the default build configuration, copy the file
927 mk/build.mk.sample to mk/build.mk, and edit the settings in there.
929 For more information on how to configure your GHC build, see
930 http://hackage.haskell.org/trac/ghc/wiki/Building