root/configure.ac

Revision 6994ed9daebb24ffb9142305394035f5f1d1ae91, 31.7 KB (checked in by Ian Lynagh <igloo@…>, 6 days ago)

Fix path to ar on Windows

  • Property mode set to 100644
Line 
1dnl == autoconf source for the Glasgow FP tools ==
2dnl (run "grep '^dnl \*' configure.ac | sed -e 's/dnl / /g; s/\*\*/   +/g;'"
3dnl  (or some such) to see the outline of this file)
4dnl
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
16AC_INIT([The Glorious Glasgow Haskell Compilation System], [7.5], [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
29if 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
32fi
33
34AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
35
36dnl ----------------------------------------------------------
37dnl ** Find unixy sort and find commands,
38dnl ** which are needed by FP_SETUP_PROJECT_VERSION
39
40dnl ** Find find command (for Win32's benefit)
41FP_PROG_FIND
42
43dnl ** Find sort command (for the benefit of Win32 environs)
44FP_PROG_SORT
45
46dnl ----------------------------------------------------------
47FP_SETUP_PROJECT_VERSION
48
49# Hmmm, we fix the RPM release number to 1 here... Is this convenient?
50AC_SUBST([release], [1])
51
52# First off, a distrib sanity check..
53AC_CONFIG_SRCDIR([mk/config.mk.in])
54
55dnl * We require autoconf version 2.52
56dnl We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE.
57dnl We need 2.52 due to the use of AS_TR_CPP and AS_TR_SH.
58AC_PREREQ([2.52])
59
60# -------------------------------------------------------------------------
61# Prepare to generate the following header files
62#
63#
64AC_CONFIG_HEADER(mk/config.h)
65
66# No, semi-sadly, we don't do `--srcdir'...
67if test x"$srcdir" != 'x.' ; then
68    echo "This configuration does not support the \`--srcdir' option.."
69    exit 1
70fi
71
72dnl --------------------------------------------------------------
73dnl * Project specific configuration options
74dnl --------------------------------------------------------------
75dnl What follows is a bunch of options that can either be configured
76dnl through command line options to the configure script or by
77dnl supplying defns in the build tree's mk/build.mk. Having the option to
78dnl use either is considered a Feature.
79
80dnl ** What command to use to compile compiler sources ?
81dnl --------------------------------------------------------------
82
83AC_ARG_WITH([ghc],
84[AC_HELP_STRING([--with-ghc=ARG],
85  [Use ARG as the path to GHC  [default=autodetect]])],
86  [WithGhc="$withval"],
87  [if test "$GHC" = ""; then
88    AC_PATH_PROG([GHC], [ghc])
89  fi
90  WithGhc="$GHC"])
91
92
93dnl ** Tell the make system which OS we are using
94dnl $OSTYPE is set by the operating system to "msys" or "cygwin" or something
95AC_SUBST(OSTYPE)
96
97dnl ** Booting from .hc files?
98dnl --------------------------------------------------------------
99AC_ARG_ENABLE(hc-boot,
100[AC_HELP_STRING([--enable-hc-boot],
101[Boot the Glasgow Haskell Compiler from intermediate .hc files.
102 (This option is mostly of interest to porters.) [default=no]])],
103[ if test x"$enableval" = x"yes"; then
104        BootingFromHc=YES
105  else
106        BootingFromHc=NO
107  fi
108],
109[BootingFromHc=NO]
110)
111AC_SUBST(BootingFromHc)
112
113AC_ARG_ENABLE(bootstrap-with-devel-snapshot,
114[AC_HELP_STRING([--enable-bootstrap-with-devel-snapshot],
115                [Allow bootstrapping using a development snapshot of GHC.  This is not guaranteed to work.])],
116        EnableBootstrapWithDevelSnaphost=YES,
117        EnableBootstrapWithDevelSnaphost=NO
118)
119
120if test "$WithGhc" != ""; then
121  FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
122
123  if test "$GhcMajVersion" = "unknown" -o "$GhcMinVersion" = "unknown"; then
124     AC_MSG_ERROR([Cannot determine the version of $WithGhc.  Is it really GHC?])
125  fi
126
127  AC_SUBST(GhcVersion)dnl
128  AC_SUBST(GhcMajVersion)dnl
129  AC_SUBST(GhcMinVersion)dnl
130  AC_SUBST(GhcPatchLevel)dnl
131  GhcMinVersion2=`echo "$GhcMinVersion" | sed 's/^\\(.\\)$/0\\1/'`
132  GhcCanonVersion="$GhcMajVersion$GhcMinVersion2"
133
134  BOOTSTRAPPING_GHC_INFO_FIELD([OS_STAGE0],[target os],['unkown'])
135  BOOTSTRAPPING_GHC_INFO_FIELD([CC_STAGE0],[C compiler command],['$(CC)'])
136  if test "x$OS_STAGE0" != "xOSDarwin"; then
137    BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command],['$(AR)'])
138    BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags],['$(AR_OPTS)'])
139    BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file],['$(ArSupportsAtFile)'])
140  else
141    AR_STAGE0='$(AR)'
142    AR_OPTS_STAGE0='$(AR_OPTS)'
143    ArSupportsAtFile_STAGE0='$(ArSupportsAtFile)'
144  fi
145fi
146
147dnl ** Must have GHC to build GHC, unless --enable-hc-boot is on
148if test "$BootingFromHc" = "NO"; then
149  if test "$WithGhc" = ""; then
150     AC_MSG_ERROR([GHC is required unless bootstrapping from .hc files.])
151  fi
152  FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.0],
153    [AC_MSG_ERROR([GHC version 7.0 or later is required to compile GHC.])])dnl
154
155  if test `expr $GhcMinVersion % 2` = "1"; then
156     if test "$EnableBootstrapWithDevelSnaphost" = "NO"; then
157        AC_MSG_ERROR([
158     $WithGhc is a development snapshot of GHC, version $GhcVersion.
159     Bootstrapping using this version of GHC is not supported, and may not
160     work.  Use --enable-bootstrap-with-devel-snapshot to try it anyway,
161     or --with-ghc to specify a different GHC to use.])
162     fi
163  fi
164
165  GHC_PACKAGE_DB_FLAG=package-db
166  FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.5],GHC_PACKAGE_DB_FLAG=package-conf)
167  AC_SUBST(GHC_PACKAGE_DB_FLAG)
168fi;
169
170# GHC is passed to Cabal, so we need a native path
171if test "${WithGhc}" != ""
172then
173    ghc_host_os=`"${WithGhc}" +RTS --info | grep 'Host OS' | sed -e 's/.*, "//' -e 's/")//'`
174
175    if test "$ghc_host_os" = "mingw32"
176    then
177        if test "${OSTYPE}" = "msys"
178        then
179            WithGhc=`echo "${WithGhc}" | sed "s#^/\([a-zA-Z]\)/#\1:/#"`
180        else
181            # Canonicalise to <drive>:/path/to/ghc
182            WithGhc=`cygpath -m "${WithGhc}"`
183        fi
184        echo "GHC path canonicalised to: ${WithGhc}"
185    fi
186fi
187AC_SUBST([WithGhc])
188
189dnl ** Without optimization some INLINE trickery fails for GHCi
190SRC_CC_OPTS="-O"
191
192FP_ICONV
193FP_GMP
194
195dnl--------------------------------------------------------------------
196dnl * Choose host(/target/build) platform
197dnl--------------------------------------------------------------------
198dnl If we aren't explicitly told what values to use with configure flags,
199dnl we ask the bootstrapping compiler what platform it is for
200
201if test "${WithGhc}" != ""
202then
203        bootstrap_host=`"${WithGhc}" +RTS --info | grep '^ ,("Host platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
204        bootstrap_target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
205        if test "$bootstrap_host" != "$bootstrap_target"
206        then
207                echo "Bootstrapping GHC is a cross compiler. This probably isn't going to work"
208        fi
209fi
210
211# We have to run these unconditionally, but we may discard their
212# results in the following code
213AC_CANONICAL_BUILD
214AC_CANONICAL_HOST
215AC_CANONICAL_TARGET
216
217# Testing ARM ABI
218# required for code generation (LLVM options)
219ARM_ABI=SOFT
220echo HOST: $host
221
222case $host in
223     arm*-*-linux-gnueabihf)
224     ARM_ABI=HARD
225     ;;
226     arm*-*-linux-gnueabi)
227     ARM_ABI=SOFTFP
228     ;;
229esac
230
231FPTOOLS_SET_PLATFORM_VARS
232
233# Verify that the installed (bootstrap) GHC is capable of generating
234# code for the requested build platform.
235if test "$BootingFromHc" = "NO"
236then
237    if test "$BuildPlatform" != "$bootstrap_target"
238    then
239        echo "This GHC (${WithGhc}) does not generate code for the build platform"
240        echo "   GHC target platform    : $bootstrap_target"
241        echo "   Desired build platform : $BuildPlatform"
242        exit 1
243    fi
244fi
245
246# Testing if we shall enable shared libs support on Solaris.
247# Anything older than SunOS 5.11 aka Solaris 11 (Express) is broken.
248
249SOLARIS_BROKEN_SHLD=NO
250
251case $host in
252     i386-*-solaris2)
253     # here we go with the test
254     MINOR=`uname -r|cut -d '.' -f 2-`
255     if test "$MINOR" -lt "11"; then
256        SOLARIS_BROKEN_SHLD=YES
257     fi
258     ;;
259esac
260
261AC_SUBST(SOLARIS_BROKEN_SHLD)
262
263AC_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)
270AC_SUBST(WithHc)
271
272# This uses GHC, so put it after the "GHC is required" check above:
273FP_INTREE_GHC_PWD
274FP_FIND_ROOT
275
276if test "$HostOS" = "mingw32"
277then
278    test -d inplace || mkdir inplace
279
280    if test "$HostArch" = "i386"
281    then
282        # NB. If you update the tarballs to a new version of gcc, don't
283        # forget to tweak the paths in driver/gcc/gcc.c.
284        if ! test -d inplace/mingw ||
285             test inplace/mingw -ot ghc-tarballs/mingw/binutils*.tar.lzma  ||
286             test inplace/mingw -ot ghc-tarballs/mingw/gcc-core*.tar.lzma  ||
287             test inplace/mingw -ot ghc-tarballs/mingw/gcc-c++*.tar.lzma   ||
288             test inplace/mingw -ot ghc-tarballs/mingw/libgcc*.tar.gz      ||
289             test inplace/mingw -ot ghc-tarballs/mingw/libgmp*.tar.gz      ||
290             test inplace/mingw -ot ghc-tarballs/mingw/libmpc*.tar.gz      ||
291             test inplace/mingw -ot ghc-tarballs/mingw/libmpfr*.tar.gz     ||
292             test inplace/mingw -ot ghc-tarballs/mingw/libstdc*.tar.lzma   ||
293             test inplace/mingw -ot ghc-tarballs/mingw/mingwrt*-dev.tar.gz ||
294             test inplace/mingw -ot ghc-tarballs/mingw/mingwrt*-dll.tar.gz ||
295             test inplace/mingw -ot ghc-tarballs/mingw/w32api*.tar.lzma
296        then
297            AC_MSG_NOTICE([Making in-tree mingw tree])
298            rm -rf inplace/mingw
299            mkdir inplace/mingw
300            (
301                cd inplace/mingw &&
302                tar --lzma -xf ../../ghc-tarballs/mingw/binutils*.tar.lzma  &&
303                tar --lzma -xf ../../ghc-tarballs/mingw/gcc-core*.tar.lzma  &&
304                tar --lzma -xf ../../ghc-tarballs/mingw/gcc-c++*.tar.lzma   &&
305                tar --lzma -xf ../../ghc-tarballs/mingw/libgcc*.tar.lzma    &&
306                tar --lzma -xf ../../ghc-tarballs/mingw/libgmp*.tar.lzma    &&
307                tar --lzma -xf ../../ghc-tarballs/mingw/libmpc*.tar.lzma    &&
308                tar --lzma -xf ../../ghc-tarballs/mingw/libmpfr*.tar.lzma   &&
309                tar --lzma -xf ../../ghc-tarballs/mingw/libstdc*.tar.lzma   &&
310                tar -z     -xf ../../ghc-tarballs/mingw/mingwrt*-dev.tar.gz &&
311                tar -z     -xf ../../ghc-tarballs/mingw/mingwrt*-dll.tar.gz &&
312                tar --lzma -xf ../../ghc-tarballs/mingw/w32api*.tar.lzma    &&
313                mv bin/gcc.exe bin/realgcc.exe
314            )
315            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
316            AC_MSG_NOTICE([In-tree mingw tree created])
317        fi
318        mingwbin="$hardtop/inplace/mingw/bin/"
319    else
320        # NB. If you update the tarballs to a new version of gcc, don't
321        # forget to tweak the paths in driver/gcc/gcc.c.
322        if ! test -d inplace/mingw ||
323             test inplace/mingw -ot ghc-tarballs/mingw64/mingw-w64-bin_*.zip
324        then
325            AC_MSG_NOTICE([Making in-tree mingw tree])
326            rm -rf inplace/mingw
327            mkdir inplace/mingw
328            (
329                cd inplace/mingw &&
330                unzip ../../ghc-tarballs/mingw64/mingw-w64-bin_*.zip
331            )
332            AC_MSG_NOTICE([In-tree mingw tree created])
333        fi
334        mingwbin="$hardtop/inplace/mingw/bin/x86_64-w64-mingw32-"
335    fi
336
337    CC="${mingwbin}gcc.exe"
338    LD="${mingwbin}ld.exe"
339    NM="${mingwbin}nm.exe"
340    fp_prog_ar="${mingwbin}ar.exe"
341
342    if ! test -d inplace/perl ||
343         test inplace/perl -ot ghc-tarballs/perl/ghc-perl*.tar.gz
344    then
345        AC_MSG_NOTICE([Making in-tree perl tree])
346        rm -rf inplace/perl
347        mkdir inplace/perl
348        (
349            cd inplace/perl &&
350            tar -zxf ../../ghc-tarballs/perl/ghc-perl*.tar.gz
351        )
352        AC_MSG_NOTICE([In-tree perl tree created])
353    fi
354fi
355
356XCODE_VERSION()
357
358SplitObjsBroken=NO
359if test "$TargetOS_CPP" = "darwin"
360then
361    # Split objects is broken (#4013) with XCode < 3.2
362    if test "$XCodeVersion1" -lt 3
363    then
364        SplitObjsBroken=YES
365    else
366        if test "$XCodeVersion1" -eq 3
367        then
368            if test "$XCodeVersion2" -lt 2
369            then
370                SplitObjsBroken=YES
371            fi
372        fi
373    fi
374fi
375AC_SUBST([SplitObjsBroken])
376
377dnl ** Building a cross compiler?
378dnl --------------------------------------------------------------
379BuildingCrossCompiler=NO
380PortingCompiler=NO
381CrossCompiling=NO
382# If 'host' and 'target' differ, then this means we are building a cross-compiler.
383if test "$host" != "$target" ; then
384    BuildingCrossCompiler=YES
385    CrossCompiling=YES
386    cross_compiling=yes   # This tells configure that it can accept just 'target',
387                          # otherwise you get
388                          #   configure: error: cannot run C compiled programs.
389                          #   If you meant to cross compile, use `--host'.
390fi
391if test "$build" != "$host" ; then
392    CrossCompiling=YES
393    PortingCompiler=YES
394fi
395# Note: cross_compiling is set to 'yes' in both 'port' and 'toolchain' cases
396if ! test "$host" = "$target" -o "$host" = "$build" ; then
397   AC_MSG_ERROR([
398You've selected:
399
400  build:  $build   (the architecture we're building on)
401  host:   $host    (the architecture the compiler we're building will execute on)
402  target: $target  (the architecture the compiler we're building will produce code for)
403
404host must equal build or target. The two allowed cases are:
405
406  --host=<arch> --target=<arch>   to _port_ GHC to run on a foreign architecture
407                                  and produce code for that architecture
408  --target=<arch>                 to build a cross compiler _toolchain_ that runs
409                                  locally but produces code for a foreign
410                                  architecture
411])
412fi
413if test "$CrossCompiling" = "YES"
414then
415  CrossCompilePrefix="${target}-"
416else
417  CrossCompilePrefix=""
418fi
419TargetPlatformFull="${target}"
420AC_SUBST(BuildingCrossCompiler)  # 'toolchain' case
421AC_SUBST(PortingCompiler)        # 'port' case
422AC_SUBST(CrossCompiling)         # BuildingCrossCompiler OR PortingCompiler
423AC_SUBST(CrossCompilePrefix)
424AC_SUBST(TargetPlatformFull)
425AC_ARG_WITH([alien],
426[AC_HELP_STRING([--with-alien=ARG],
427  [Supply script for running target binaries locally when cross-compiling])],
428  [AlienScript="$withval"],
429  [AlienScript=""])
430AC_SUBST(AlienScript)
431
432dnl ** Which gcc to use?
433dnl --------------------------------------------------------------
434FIND_GCC([WhatGccIsCalled], [gcc], [gcc])
435CC="$WhatGccIsCalled"
436export CC
437
438dnl ** Which ld to use?
439dnl --------------------------------------------------------------
440FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
441LdCmd="$LD"
442AC_SUBST([LdCmd])
443
444dnl ** Which nm to use?
445dnl --------------------------------------------------------------
446FP_ARG_WITH_PATH_GNU_PROG([NM], [nm], [nm])
447NmCmd="$NM"
448AC_SUBST([NmCmd])
449
450dnl ** Which LLVM llc to use?
451dnl --------------------------------------------------------------
452FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([LLC], [llc])
453LlcCmd="$LLC"
454AC_SUBST([LlcCmd])
455
456dnl ** Which LLVM opt to use?
457dnl --------------------------------------------------------------
458FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([OPT], [opt])
459OptCmd="$OPT"
460AC_SUBST([OptCmd])
461
462dnl ** Mac OS X: explicit deployment target
463dnl --------------------------------------------------------------
464AC_ARG_WITH([macosx-deployment-target],
465[AC_HELP_STRING([--with-macosx-deployment-target=VERSION],
466        [Build for Mac OS VERSION and higher  (default= version of build host)])],
467[FP_MACOSX_DEPLOYMENT_TARGET="$withval"
468 if test "x$TargetOS_CPP-$TargetVendor_CPP" != "xdarwin-apple"; then
469   # ignore everywhere, but on Mac OS
470   AC_MSG_WARN([--macosx-deployment-target is only available on Mac OS X])
471   FP_MACOSX_DEPLOYMENT_TARGET=none
472 fi],
473[FP_MACOSX_DEPLOYMENT_TARGET=none]
474)
475FP_CHECK_MACOSX_DEPLOYMENT_TARGET
476AC_SUBST(MACOSX_DEPLOYMENT_VERSION)
477AC_SUBST(MACOSX_DEPLOYMENT_SDK)
478
479dnl --------------------------------------------------------------
480dnl End of configure script option section
481dnl --------------------------------------------------------------
482
483
484dnl --------------------------------------------------------------
485dnl * General configuration checks
486dnl --------------------------------------------------------------
487
488dnl ** Can the unix package be built?
489dnl --------------------------------------------------------------
490
491if test "$TargetOS" = "mingw32"
492then
493    GhcLibsWithUnix=NO
494else
495    GhcLibsWithUnix=YES
496fi
497AC_SUBST([GhcLibsWithUnix])
498
499dnl ** does #! work?
500AC_SYS_INTERPRETER()
501
502dnl ** look for `perl'
503case $HostOS_CPP in
504cygwin32|mingw32)
505    PerlCmd=$hardtop/inplace/perl/perl
506    ;;
507*)
508    AC_PATH_PROG(PerlCmd,perl)
509    if test -z "$PerlCmd"
510    then
511        echo "You must install perl before you can continue"
512        echo "Perhaps it is already installed, but not in your PATH?"
513        exit 1
514    else
515        FPTOOLS_CHECK_PERL_VERSION
516    fi
517    ;;
518esac
519
520dnl ** does #! path/to/perl work? (sometimes it's too long...)
521FPTOOLS_SHEBANG_PERL
522
523dnl ** check for Python
524AC_PATH_PROG(PythonCmd,python)
525
526dnl ** look for GCC and find out which version
527dnl     Figure out which C compiler to use.  Gcc is preferred.
528dnl     If gcc, make sure it's at least 3.0
529dnl
530FP_GCC_VERSION
531
532dnl ** look to see if we have a C compiler using an llvm back end.
533dnl
534FP_CC_LLVM_BACKEND
535
536FP_PROG_LD_HashSize31
537FP_PROG_LD_ReduceMemoryOverheads
538
539FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
540FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
541FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
542# Stage 3 won't be supported by cross-compilation
543FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
544
545FP_GCC_EXTRA_FLAGS
546
547dnl ** figure out how to invoke cpp directly (gcc -E is no good)
548AC_PROG_CPP
549
550AC_SUBST(CONF_CC_OPTS_STAGE0)
551AC_SUBST(CONF_CC_OPTS_STAGE1)
552AC_SUBST(CONF_CC_OPTS_STAGE2)
553AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
554AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
555AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
556AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
557AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
558AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
559AC_SUBST(CONF_CPP_OPTS_STAGE0)
560AC_SUBST(CONF_CPP_OPTS_STAGE1)
561AC_SUBST(CONF_CPP_OPTS_STAGE2)
562
563dnl ** Set up the variables for the platform in the settings file.
564dnl May need to use gcc to find platform details.
565dnl --------------------------------------------------------------
566FPTOOLS_SET_HASKELL_PLATFORM_VARS
567
568dnl ** figure out how to do context diffs
569FP_PROG_CONTEXT_DIFF
570
571dnl Let's make sure install-sh is executable here.  If we got it from
572dnl a darcs repo, it might not be (see bug #978).
573chmod +x install-sh
574dnl ** figure out how to do a BSD-ish install
575AC_PROG_INSTALL
576
577dnl If you can run configure, you certainly have /bin/sh
578AC_DEFINE([HAVE_BIN_SH], [1], [Define to 1 if you have /bin/sh.])
579
580dnl ** how to invoke `ar' and `ranlib'
581FP_PROG_AR_SUPPORTS_ATFILE
582FP_PROG_AR_NEEDS_RANLIB
583
584dnl ** Check to see whether ln -s works
585AC_PROG_LN_S
586
587FP_SETTINGS
588
589dnl ** Find the path to sed
590AC_PATH_PROGS(SedCmd,gsed sed,sed)
591
592
593dnl ** check for time command
594AC_PATH_PROG(TimeCmd,time)
595
596dnl ** check for tar
597dnl   if GNU tar is named gtar, look for it first.
598AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar)
599
600dnl ** check for patch
601dnl if GNU patch is named gpatch, look for it first
602AC_PATH_PROGS(PatchCmd,gpatch patch, patch)
603
604dnl ** check for dtrace (currently only implemented for Mac OS X)
605HaveDtrace=NO
606AC_PATH_PROG(DtraceCmd,dtrace)
607if test -n "$DtraceCmd"; then
608  if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then
609    HaveDtrace=YES
610  fi
611fi
612AC_SUBST(HaveDtrace)
613
614AC_PATH_PROG(HSCOLOUR,HsColour)
615# HsColour is passed to Cabal, so we need a native path
616if test "$HostOS"      = "mingw32" && \
617   test "${OSTYPE}"   != "msys"    && \
618   test "${HSCOLOUR}" != ""
619then
620    # Canonicalise to <drive>:/path/to/gcc
621    HSCOLOUR=`cygpath -m ${HSCOLOUR}`
622fi
623
624dnl ** check for DocBook toolchain
625FP_CHECK_DOCBOOK_DTD
626FP_DOCBOOK_XSL
627FP_PROG_DBLATEX
628
629dnl ** check for ghc-pkg command
630FP_PROG_GHC_PKG
631
632dnl ** check for installed happy binary + version
633dnl    (don't do it if we're booting from .hc files though.)
634if test "$BootingFromHc" = "NO"; then
635FPTOOLS_HAPPY
636fi;
637
638dnl ** check for installed alex binary + version
639dnl    (don't do it if we're booting from .hc files though.)
640if test "$BootingFromHc" = "NO"; then
641FPTOOLS_ALEX
642fi;
643
644dnl --------------------------------------------------
645dnl ### program checking section ends here ###
646dnl --------------------------------------------------
647
648dnl --------------------------------------------------
649dnl * Platform header file and syscall feature tests
650dnl ### checking the state of the local header files and syscalls ###
651
652dnl ** check for full ANSI header (.h) files
653AC_HEADER_STDC
654
655dnl ** Enable large file support.  NB. do this before testing the type of
656dnl    off_t, because it will affect the result of that test.
657AC_SYS_LARGEFILE
658
659dnl ** check for specific header (.h) files that we are interested in
660AC_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/cpuset.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])
661
662dnl ** check if it is safe to include both <time.h> and <sys/time.h>
663AC_HEADER_TIME
664
665dnl ** do we have long longs?
666AC_CHECK_TYPES([long long])
667
668dnl ** what are the sizes of various types
669AC_CHECK_SIZEOF(char,               1)
670AC_CHECK_SIZEOF(double,             8)
671AC_CHECK_SIZEOF(float,              4)
672AC_CHECK_SIZEOF(int,                4)
673AC_CHECK_SIZEOF(long,               4)
674if test "$ac_cv_type_long_long" = yes; then
675AC_CHECK_SIZEOF(long long,          8)
676fi
677AC_CHECK_SIZEOF(short,              2)
678AC_CHECK_SIZEOF(unsigned char,      1)
679AC_CHECK_SIZEOF(unsigned int,       4)
680AC_CHECK_SIZEOF(unsigned long,      4)
681if test "$ac_cv_type_long_long" = yes; then
682AC_CHECK_SIZEOF(unsigned long long, 8)
683fi
684AC_CHECK_SIZEOF(unsigned short,     2)
685AC_CHECK_SIZEOF(void *,             4)
686
687dnl for use in settings.in
688WordSize=$ac_cv_sizeof_void_p
689AC_SUBST(WordSize)
690
691dnl ** what are alignment constraints on various types
692FP_CHECK_ALIGNMENT(char)
693FP_CHECK_ALIGNMENT(double)
694FP_CHECK_ALIGNMENT(float)
695FP_CHECK_ALIGNMENT(int)
696FP_CHECK_ALIGNMENT(long)
697if test "$ac_cv_type_long_long" = yes; then
698FP_CHECK_ALIGNMENT(long long)
699fi
700FP_CHECK_ALIGNMENT(short)
701FP_CHECK_ALIGNMENT(unsigned char)
702FP_CHECK_ALIGNMENT(unsigned int)
703FP_CHECK_ALIGNMENT(unsigned long)
704if test "$ac_cv_type_long_long" = yes; then
705FP_CHECK_ALIGNMENT(unsigned long long)
706fi
707FP_CHECK_ALIGNMENT(unsigned short)
708FP_CHECK_ALIGNMENT(void *)
709
710FP_CHECK_FUNC([WinExec],
711  [@%:@include <windows.h>], [WinExec("",0)])
712
713FP_CHECK_FUNC([GetModuleFileName],
714  [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
715
716dnl ** check return type of signal handlers
717dnl Foo: assumes we can use prototypes.
718dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
719dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
720dnl [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
721dnl #include <signal.h>
722dnl #ifdef signal
723dnl #undef signal
724dnl #endif
725dnl void (*signal (int, void (*)(int)))(int);
726dnl ]],
727dnl [[int i;]])],
728dnl [ac_cv_type_signal_handler=void_int],
729dnl [ac_cv_type_signal_handler=int_void])])
730dnl if test "$ac_cv_type_signal_handler" = void_int; then
731dnl AC_DEFINE(VOID_INT_SIGNALS)
732dnl fi
733
734dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
735AC_TYPE_SIGNAL
736if test "$ac_cv_type_signal" = void; then
737  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).])
738fi
739
740dnl ** check for more functions
741dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
742AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity setlocale])
743
744if test "$cross_compiling" = "no" ; then
745    AC_TRY_RUN([
746    #include <sys/types.h>
747    #include <sys/time.h>
748    int main(void) {
749      struct itimerval tval;
750      tval.it_value.tv_sec = 1;
751      tval.it_value.tv_usec = 0;
752      tval.it_interval = tval.it_value;
753      return setitimer(ITIMER_VIRTUAL, &tval, (void*)0) != 0;
754    }
755    ],[AC_DEFINE([HAVE_SETITIMER_VIRTUAL], [1], [Define to 1 if setitimer accepts ITIMER_VIRTUAL, 0 else.])])
756fi
757
758dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
759dnl ** _POSIX_C_SOURCE is defined
760AC_CHECK_DECLS([ctime_r], , ,
761[#define _POSIX_SOURCE 1
762#define _POSIX_C_SOURCE 199506L
763#include <time.h>])
764
765dnl ** check for mingwex library
766AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
767AC_SUBST(HaveLibMingwEx)
768
769if test $HaveLibMingwEx = YES ; then
770  AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
771fi
772
773dnl ** check for math library
774dnl    Keep that check as early as possible.
775dnl    as we need to know whether we need libm
776dnl    for math functions or not
777dnl    (see http://hackage.haskell.org/trac/ghc/ticket/3730)
778AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO)
779if test $HaveLibM = YES
780then
781  AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])
782fi
783
784dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
785dnl    the order of these tests matters: bfd needs libiberty
786AC_CHECK_LIB(iberty, xmalloc)
787AC_CHECK_LIB(bfd,    bfd_uncompress_section_contents)
788
789dnl ################################################################
790dnl Check for libraries
791dnl ################################################################
792
793dnl ** check whether we need -ldl to get dlopen()
794
795AC_CHECK_LIB(dl, dlopen,
796    [HaveLibDL=YES
797     AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if you need -ldl to get dlopen().])
798     LIBS="$LIBS -ldl"],
799    [HaveLibDL=NO])
800AC_SUBST(HaveLibDL)
801
802dnl --------------------------------------------------
803dnl * Miscellaneous feature tests
804dnl --------------------------------------------------
805
806dnl ** can we get alloca?
807AC_FUNC_ALLOCA
808
809dnl ** working vfork?
810AC_FUNC_FORK
811
812dnl ** determine whether or not const works
813AC_C_CONST
814
815dnl ** are we big endian?
816AC_C_BIGENDIAN
817FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
818
819dnl ** check for leading underscores in symbol names
820FP_LEADING_UNDERSCORE
821
822dnl ** check for ld, whether it has an -x option, and if it is GNU ld
823FP_PROG_LD_X
824FP_PROG_LD_IS_GNU
825FP_PROG_LD_BUILD_ID
826FP_PROG_LD_NO_COMPACT_UNWIND
827
828FP_VISIBILITY_HIDDEN
829
830dnl ** check for librt
831AC_CHECK_LIB(rt, clock_gettime)
832AC_CHECK_FUNCS(clock_gettime timer_create timer_settime)
833FP_CHECK_TIMER_CREATE
834
835dnl ** check for Apple's "interesting" long double compatibility scheme
836AC_MSG_CHECKING(for printf\$LDBLStub)
837AC_TRY_LINK_FUNC(printf\$LDBLStub,
838    [
839        AC_MSG_RESULT(yes)
840        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
841            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
842    ],
843    [
844        AC_MSG_RESULT(no)
845        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
846            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
847    ])
848
849dnl ** check for eventfd which is needed by the I/O manager
850AC_CHECK_HEADERS([sys/eventfd.h])
851AC_CHECK_FUNCS([eventfd])
852
853# test for GTK+
854AC_PATH_PROGS([GTK_CONFIG], [pkg-config])
855if test -n "$GTK_CONFIG"; then
856  if $GTK_CONFIG gtk+-2.0 --atleast-version=2.0; then
857    GTK_CONFIG="$GTK_CONFIG gtk+-2.0"
858  else
859    AC_MSG_WARN([GTK+ not usable, need at least version 2.0])
860    GTK_CONFIG=
861  fi
862fi
863AC_SUBST([GTK_CONFIG])
864
865# checking for PAPI
866AC_CHECK_LIB(papi, PAPI_library_init, HavePapiLib=YES, HavePapiLib=NO)
867AC_CHECK_HEADER([papi.h], [HavePapiHeader=YES], [HavePapiHeader=NO])
868AC_SUBST(HavePapiLib)
869AC_SUBST(HavePapiHeader)
870
871AC_CHECK_FUNCS(__mingw_vfprintf)
872
873if test "$HavePapiLib" = "YES" -a "$HavePapiHeader" = "YES"; then
874   HavePapi=YES
875else
876   HavePapi=NO
877fi
878AC_SUBST(HavePapi)
879
880if test "$HAVE_DOCBOOK_XSL" = "NO" ||
881   test "$XsltprocCmd" = ""
882then
883    BUILD_DOCBOOK_HTML=NO
884else
885    BUILD_DOCBOOK_HTML=YES
886fi
887AC_SUBST(BUILD_DOCBOOK_HTML)
888
889if test "$DblatexCmd" = ""
890then
891    BUILD_DOCBOOK_PS=NO
892    BUILD_DOCBOOK_PDF=NO
893else
894    BUILD_DOCBOOK_PS=YES
895    BUILD_DOCBOOK_PDF=YES
896fi
897AC_SUBST(BUILD_DOCBOOK_PS)
898AC_SUBST(BUILD_DOCBOOK_PDF)
899
900LIBRARY_VERSION(base)
901LIBRARY_VERSION(Cabal, Cabal/Cabal)
902LIBRARY_VERSION(ghc-prim)
903LIBRARY_ghc_VERSION="$ProjectVersion"
904AC_SUBST(LIBRARY_ghc_VERSION)
905
906if grep '       ' compiler/ghc.cabal.in 2>&1 >/dev/null; then
907   AC_MSG_ERROR([compiler/ghc.cabal.in contains tab characters; please remove them])
908fi
909
910AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal utils/runghc/runghc.cabal ghc.spec settings docs/users_guide/ug-book.xml docs/users_guide/ug-ent.xml docs/index.html libraries/prologue.txt distrib/ghc.iss distrib/configure.ac])
911AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp > mk/stamp-h])
912AC_OUTPUT
913
914# We got caught by
915#     http://savannah.gnu.org/bugs/index.php?1516
916#     $(eval ...) inside conditionals causes errors
917# with make 3.80, so warn the user if it looks like they're about to
918# try to use it.
919# We would use "grep -q" here, but Solaris's grep doesn't support it.
920checkMake380() {
921    if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
922    then
923        echo
924        echo "WARNING: It looks like \"$1\" is GNU make 3.80."
925        echo "This version cannot be used to build GHC."
926        echo "Please use GNU make >= 3.81."
927    fi
928}
929
930checkMake380 make
931checkMake380 gmake
932
933echo ["
934----------------------------------------------------------------------
935Configure completed successfully.
936
937   Building GHC version  : $ProjectVersion
938
939   Build platform        : $BuildPlatform
940   Host platform         : $HostPlatform
941   Target platform       : $TargetPlatform
942"]
943
944if test "$BootingFromHc" = "YES"; then
945echo ["\
946   Bootstrapping from HC files.
947"]
948else
949echo ["\
950   Bootstrapping using   : $WithGhc
951      which is version   : $GhcVersion
952"]
953fi
954
955echo ["\
956   Using GCC                 : $WhatGccIsCalled
957      which is version       : $GccVersion
958   Building a cross compiler : $BuildingCrossCompiler
959   Porting to foreign arch   : $PortingCompiler
960   Alien script              : $AlienScript
961
962   ld       : $LdCmd
963   Happy    : $HappyCmd ($HappyVersion)
964   Alex     : $AlexCmd ($AlexVersion)
965   Python   : $PythonCmd
966   Perl     : $PerlCmd
967   dblatex  : $DblatexCmd
968   xsltproc : $XsltprocCmd"]
969
970if test "$HSCOLOUR" = ""; then
971echo ["
972   HsColour was not found; documentation will not contain source links
973"]
974else
975echo ["\
976   HsColour : $HSCOLOUR
977"]
978fi
979
980echo ["\
981   Building DocBook HTML documentation : $BUILD_DOCBOOK_HTML
982   Building DocBook PS documentation   : $BUILD_DOCBOOK_PS
983   Building DocBook PDF documentation  : $BUILD_DOCBOOK_PDF"]
984
985echo ["----------------------------------------------------------------------
986"]
987
988echo "\
989For a standard build of GHC (fully optimised with profiling), type (g)make.
990
991To make changes to the default build configuration, copy the file
992mk/build.mk.sample to mk/build.mk, and edit the settings in there.
993
994For more information on how to configure your GHC build, see
995   http://hackage.haskell.org/trac/ghc/wiki/Building
996"
Note: See TracBrowser for help on using the browser.