Set C compiler and linker flags correctly for OS X 64
[ghc.git] / configure.ac
1 dnl == autoconf source for the Glasgow FP tools ==
2 dnl (run "grep '^dnl \*' configure.ac | sed -e 's/dnl / /g; s/\*\*/   +/g;'"
3 dnl  (or some such) to see the outline of this file)
4 dnl
5 #
6 # (c) The University of Glasgow 1994-2004
7 #
8 # Configure script template for GHC
9 #
10 # Process with 'autoreconf' to get a working configure script.
11 #
12 # For the generated configure script, do "./configure --help" to
13 # see what flags are available. (Better yet, read the documentation!)
14 #
15
16 AC_INIT([The Glorious Glasgow Haskell Compilation System], [6.11], [glasgow-haskell-bugs@haskell.org], [ghc])
17
18 # Set this to YES for a released version, otherwise NO
19 : ${RELEASE=NO}
20
21 # The primary version (e.g. 6.7, 6.6.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. 6.7.20070204).  The date is
24 # constructed by finding the date of the most recent patch in the
25 # darcs repository.  If this is a source distribution (not a darcs
26 # checkout), then we ship a file 'VERSION' containing the full version
27 # when the source distribution was created.
28
29 if test ! -f mk/config.h.in; then
30    echo "mk/config.h.in doesn't exist: perhaps you haven't run 'sh boot'?"
31    exit 1
32 fi
33
34 AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
35
36 FP_SETUP_PROJECT_VERSION
37
38 # Hmmm, we fix the RPM release number to 1 here... Is this convenient?
39 AC_SUBST([release], [1])
40
41 # First off, a distrib sanity check..
42 AC_CONFIG_SRCDIR([mk/config.mk.in])
43
44 dnl * We require autoconf version 2.52
45 dnl We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE.
46 dnl We need 2.52 due to the use of AS_TR_CPP and AS_TR_SH.
47 AC_PREREQ([2.52])
48
49 # -------------------------------------------------------------------------
50 # Prepare to generate the following header files
51 #
52 #
53 AC_CONFIG_HEADER(mk/config.h)
54
55 # No, semi-sadly, we don't do `--srcdir'...
56 if test x"$srcdir" != 'x.' ; then
57     echo "This configuration does not support the \`--srcdir' option.."
58     exit 1
59 fi
60
61 dnl--------------------------------------------------------------------
62 dnl * Deal with arguments telling us gmp is somewhere odd
63 dnl--------------------------------------------------------------------
64
65 FP_ARG_GMP
66
67 GMP_INCLUDE_DIRS=
68 GMP_LIB_DIRS=
69 if test "x$gmp_libraries" != "xNONE"; then
70   LDFLAGS="-L$gmp_libraries $LDFLAGS"
71   GMP_LIB_DIRS=$gmp_libraries
72 fi
73 if test "x$gmp_includes" != "xNONE"; then
74   CPPFLAGS="-I$gmp_includes $CPPFLAGS"
75   GMP_INCLUDE_DIRS=$gmp_includes
76 fi
77 AC_SUBST(GMP_INCLUDE_DIRS)
78 AC_SUBST(GMP_LIB_DIRS)
79
80 dnl--------------------------------------------------------------------
81 dnl * Choose host(/target/build) platform
82 dnl--------------------------------------------------------------------
83
84 dnl Guess host/target/build platform(s) if necessary.
85 AC_CANONICAL_TARGET
86
87 # "$host" defaults to "$target"
88 if test "x$host" = xNONE ; then
89     host=$target
90 fi
91
92 dnl ** canonicalize platform names
93 BuildPlatform=`/bin/sh $srcdir/config.sub $build` || exit 1
94 HostPlatform=`/bin/sh $srcdir/config.sub $host` || exit 1
95 TargetPlatform=`/bin/sh $srcdir/config.sub $target` || exit 1
96
97 if test x"$TargetPlatform" != x"$HostPlatform" ; then
98     AC_MSG_ERROR([
99       GHC configuration does not support differing host/target (i.e., cross-compiling)])
100 fi
101
102 case $HostPlatform in
103 *-cygwin*)
104     AC_MSG_WARN([GHC does not support the Cygwin target at the moment])
105     AC_MSG_WARN([I'm assuming you wanted to build for i386-unknown-mingw32])
106     HostPlatform=i386-unknown-mingw32  
107     ;;
108 esac
109
110 exeext=''
111 soext='.so'
112 #
113 # The following will be more difficult when we *are* cross-compiling.
114 # Suitable names to slam in *_CPP are in platform.h.in.
115 # We also record the architecture, vendor, and operating system (OS)
116 # separately.
117 case $HostPlatform in
118 alpha*-dec-osf[[12]]*)
119         HostPlatform=alpha-dec-osf1   # canonicalise for our purposes
120         TargetPlatform=alpha-dec-osf1 # this will work for now... (hack)
121         BuildPlatform=alpha-dec-osf1  # hack
122         HostPlatform_CPP='alpha_dec_osf1'
123         HostArch_CPP='alpha'
124         HostVendor_CPP='dec'
125         HostOS_CPP='osf1'
126         ;;
127 alpha*-dec-osf[[345]]*)
128         HostPlatform=alpha-dec-osf3   # canonicalise for our purposes
129         TargetPlatform=alpha-dec-osf3 # this will work for now... (hack)
130         BuildPlatform=alpha-dec-osf3  # hack
131         HostPlatform_CPP='alpha_dec_osf3'
132         HostArch_CPP='alpha'
133         HostVendor_CPP='dec'
134         HostOS_CPP='osf3'
135         ;;
136 alpha*-unknown-linux*)
137         HostPlatform=alpha-unknown-linux
138         TargetPlatform=alpha-unknown-linux
139         BuildPlatform=alpha-unknown-linux
140         HostPlatform_CPP='alpha_unknown_linux'
141         HostArch_CPP='alpha'
142         HostVendor_CPP='unknown'
143         HostOS_CPP='linux'
144         ;;
145 alpha*-unknown-freebsd*)
146         HostPlatform=alpha-unknown-freebsd
147         TargetPlatform=alpha-unknown-freebsd
148         BuildPlatform=alpha-unknown-freebsd
149         HostPlatform_CPP='alpha_unknown_freebsd'
150         HostArch_CPP='alpha'
151         HostVendor_CPP='unknown'
152         HostOS_CPP='freebsd'
153         ;;
154 alpha*-unknown-openbsd*)
155         HostPlatform=alpha-unknown-openbsd
156         TargetPlatform=alpha-unknown-openbsd
157         BuildPlatform=alpha-unknown-openbsd
158         HostPlatform_CPP='alpha_unknown_openbsd'
159         HostArch_CPP='alpha'
160         HostVendor_CPP='unknown'
161         HostOS_CPP='openbsd'
162         ;;
163 amd64-*-openbsd*|x86_64-*-openbsd*)
164         HostPlatform=x86_64-unknown-openbsd
165         TargetPlatform=x86_64-unknown-openbsd
166         BuildPlatform=x86_64-unknown-openbsd
167         HostPlatform_CPP='x86_64_unknown_openbsd'
168         HostArch_CPP='x86_64'
169         HostVendor_CPP='unknown'
170         HostOS_CPP='openbsd'
171         ;;
172 amd64-*-freebsd*|x86_64-*-freebsd*)
173         HostPlatform=x86_64-unknown-freebsd
174         TargetPlatform=x86_64-unknown-freebsd
175         BuildPlatform=x86_64-unknown-freebsd
176         HostPlatform_CPP='x86_64_unknown_freebsd'
177         HostArch_CPP='x86_64'
178         HostVendor_CPP='unknown'
179         HostOS_CPP='freebsd'
180         ;;
181 amd64-*-netbsd*|x86_64-*-netbsd*)
182         HostPlatform=x86_64-unknown-netbsd
183         TargetPlatform=x86_64-unknown-netbsd
184         BuildPlatform=x86_64-unknown-netbsd
185         HostPlatform_CPP='x86_64_unknown_netbsd'
186         HostArch_CPP='x86_64'
187         HostVendor_CPP='unknown'
188         HostOS_CPP='netbsd'
189         ;;
190 arm*-linux*)
191         HostPlatform=arm-unknown-linux # hack again
192         TargetPlatform=arm-unknown-linux
193         BuildPlatform=arm-unknown-linux
194         HostPlatform_CPP='arm_unknown_linux'
195         HostArch_CPP='arm'
196         HostVendor_CPP='unknown'
197         HostOS_CPP='linux'
198         ;;
199 arm*-openbsd*)
200         HostPlatform=arm-unknown-openbsd
201         TargetPlatform=arm-unknown-openbsd
202         BuildPlatform=arm-unknown-openbsd
203         HostPlatform_CPP='arm_unknown_openbsd'
204         HostArch_CPP='arm'
205         HostVendor_CPP='unknown'
206         HostOS_CPP='openbsd'
207         ;;
208 hppa*-*-linux*)
209         HostPlatform=hppa-unknown-linux # hack again
210         TargetPlatform=hppa-unknown-linux
211         BuildPlatform=hppa-unknown-linux
212         HostPlatform_CPP='hppa_unknown_linux'
213         HostArch_CPP='hppa'
214         HostVendor_CPP='unknown'
215         HostOS_CPP='linux'
216         ;;
217 hppa*-*-openbsd*)
218         HostPlatform=hppa-unknown-openbsd # hack again
219         TargetPlatform=hppa-unknown-openbsd
220         BuildPlatform=hppa-unknown-openbsd
221         HostPlatform_CPP='hppa_unknown_openbsd'
222         HostArch_CPP='hppa'
223         HostVendor_CPP='unknown'
224         HostOS_CPP='openbsd'
225         ;;
226 hppa1.1-hp-hpux*)
227         HostPlatform=hppa1.1-hp-hpux  # canonicalise for our purposes (hack)
228         TargetPlatform=hppa1.1-hp-hpux
229         BuildPlatform=hppa1.1-hp-hpux
230         HostPlatform_CPP='hppa1_1_hp_hpux'
231         HostArch_CPP='hppa1_1'
232         HostVendor_CPP='hp'
233         HostOS_CPP='hpux'
234         ;;
235 i[[3456]]86-*-linuxaout*)
236         HostPlatform=i386-unknown-linuxaout   # hack again
237         TargetPlatform=i386-unknown-linuxaout
238         BuildPlatform=i386-unknown-linuxaout
239         HostPlatform_CPP='i386_unknown_linuxaout'
240         HostArch_CPP='i386'
241         HostVendor_CPP='unknown'
242         HostOS_CPP='linuxaout'
243         ;;
244 i[[3456]]86-*-linux*)
245         HostPlatform=i386-unknown-linux # hack again
246         TargetPlatform=i386-unknown-linux
247         BuildPlatform=i386-unknown-linux
248         HostPlatform_CPP='i386_unknown_linux'
249         HostArch_CPP='i386'
250         HostVendor_CPP='unknown'
251         HostOS_CPP='linux'
252         ;;
253 i[[3456]]86-*-kfreebsd*-gnu)
254         HostPlatform=i386-unknown-kfreebsdgnu # hack again
255         TargetPlatform=i386-unknown-kfreebsdgnu
256         BuildPlatform=i386-unknown-kfreebsdgnu
257         HostPlatform_CPP='i386_unknown_kfreebsdgnu'
258         HostArch_CPP='i386'
259         HostVendor_CPP='unknown'
260         HostOS_CPP='kfreebsdgnu'
261         ;;
262 i[[3456]]86-*-freebsd[[3-9]]*) # FreeBSD 3.0+ uses ELF
263         HostPlatform=i386-unknown-freebsd # hack again
264         TargetPlatform=i386-unknown-freebsd
265         BuildPlatform=i386-unknown-freebsd
266         HostPlatform_CPP='i386_unknown_freebsd'
267         HostArch_CPP='i386'
268         HostVendor_CPP='unknown'
269         HostOS_CPP='freebsd'
270         ;;
271 i[[3456]]86-*-freebsd2*) # Older FreeBSDs are a.out
272         HostPlatform=i386-unknown-freebsd2 # hack again
273         TargetPlatform=i386-unknown-freebsd2
274         BuildPlatform=i386-unknown-freebsd2
275         HostPlatform_CPP='i386_unknown_freebsd2'
276         HostArch_CPP='i386'
277         HostVendor_CPP='unknown'
278         HostOS_CPP='freebsd2'
279         ;;
280 i[[3456]]86-*-netbsd*)
281         HostPlatform=i386-unknown-netbsd # hack again
282         TargetPlatform=i386-unknown-netbsd
283         BuildPlatform=i386-unknown-netbsd
284         HostPlatform_CPP='i386_unknown_netbsd'
285         HostArch_CPP='i386'
286         HostVendor_CPP='unknown'
287         HostOS_CPP='netbsd'
288         ;;
289 i[[3456]]86-*-openbsd*)
290         HostPlatform=i386-unknown-openbsd # hack again
291         TargetPlatform=i386-unknown-openbsd
292         BuildPlatform=i386-unknown-openbsd
293         HostPlatform_CPP='i386_unknown_openbsd'
294         HostArch_CPP='i386'
295         HostVendor_CPP='unknown'
296         HostOS_CPP='openbsd'
297         ;;
298 i[[3456]]86-*-solaris2*)
299         HostPlatform=i386-unknown-solaris2 # hack again
300         TargetPlatform=i386-unknown-solaris2
301         BuildPlatform=i386-unknown-solaris2
302         HostPlatform_CPP='i386_unknown_solaris2'
303         HostArch_CPP='i386'
304         HostVendor_CPP='unknown'
305         HostOS_CPP='solaris2'
306         ;;
307 i[[3456]]86-*-cygwin*)
308         HostPlatform=i386-unknown-cygwin32 # hack again
309         TargetPlatform=i386-unknown-cygwin32
310         BuildPlatform=i386-unknown-cygwin32
311         HostPlatform_CPP='i386_unknown_cygwin32'
312         HostArch_CPP='i386'
313         HostVendor_CPP='unknown'
314         HostOS_CPP='cygwin32'
315         exeext='.exe'
316         soext='.dll'
317         ;;
318 i[[3456]]86-*-mingw32*)
319         HostPlatform=i386-unknown-mingw32 # hack again
320         TargetPlatform=i386-unknown-mingw32
321         BuildPlatform=i386-unknown-mingw32
322         HostPlatform_CPP='i386_unknown_mingw32'
323         HostArch_CPP='i386'
324         HostVendor_CPP='unknown'
325         HostOS_CPP='mingw32'
326         exeext='.exe'
327         soext='.dll'
328         ;;
329 i[[3456]]86-apple-darwin*)
330         HostPlatform=i386-apple-darwin
331         TargetPlatform=i386-apple-darwin #hack
332         BuildPlatform=i386-apple-darwin #hack
333         HostPlatform_CPP='i386_apple_darwin'
334         HostArch_CPP='i386'
335         HostVendor_CPP='apple'
336         HostOS_CPP='darwin'
337         soext='.dylib'
338         ;;
339 i[[3456]]86-*-gnu*)
340         HostPlatform=i386-unknown-gnu
341         TargetPlatform=i386-unknown-gnu
342         BuildPlatform=i386-unknown-gnu
343         HostPlatform_CPP=i386_unknown_gnu
344         HostArch_CPP=i386
345         HostVendor_CPP=unknown
346         HostOS_CPP=gnu
347         ;;
348 ia64-*-linux*)
349         HostPlatform=ia64-unknown-linux # hack again
350         TargetPlatform=ia64-unknown-linux
351         BuildPlatform=ia64-unknown-linux
352         HostPlatform_CPP='ia64_unknown_linux'
353         HostArch_CPP='ia64'
354         HostVendor_CPP='unknown'
355         HostOS_CPP='linux'
356         ;;
357 x86_64-*-linux*)
358         HostPlatform=x86_64-unknown-linux
359         TargetPlatform=x86_64-unknown-linux
360         BuildPlatform=x86_64-unknown-linux
361         HostPlatform_CPP='x86_64_unknown_linux'
362         HostArch_CPP='x86_64'
363         HostVendor_CPP='unknown'
364         HostOS_CPP='linux'
365         ;;
366 x86_64-apple-darwin*)
367         HostPlatform=x86_64-apple-darwin
368         TargetPlatform=x86_64-apple-darwin
369         BuildPlatform=x86_64-apple-darwin
370         HostPlatform_CPP='x86_64_apple_darwin'
371         HostArch_CPP='x86_64'
372         HostVendor_CPP='apple'
373         HostOS_CPP='darwin'
374         soext='.dylib'
375         # By default, gcc makes 32bit executables on OS X
376         CFLAGS="$CFLAGS -m64"
377         LDFLAGS="$LDFLAGS -m64"
378         ;;
379 m68k-*-linux*)
380         HostPlatform=m68k-unknown-linux # hack again
381         TargetPlatform=m68k-unknown-linux
382         BuildPlatform=m68k-unknown-linux
383         HostPlatform_CPP='m68k_unknown_linux'
384         HostArch_CPP='m68k'
385         HostVendor_CPP='unknown'
386         HostOS_CPP='linux'
387         ;;
388 m68k-next-nextstep2)
389         HostPlatform_CPP='m68k_next_nextstep2'
390         HostArch_CPP='m68k'
391         HostVendor_CPP='next'
392         HostOS_CPP='nextstep2'
393         ;;
394 m68k-next-nextstep3)
395         HostPlatform_CPP='m68k_next_nextstep3'
396         HostArch_CPP='m68k'
397         HostVendor_CPP='next'
398         HostOS_CPP='nextstep3'
399         ;;
400 i[[3456]]86-next-nextstep3)
401         HostPlatform=i386-next-nextstep3 # hack again
402         TargetPlatform=i386-next-nextstep3
403         BuildPlatform=i386-next-nextstep3
404         HostPlatform_CPP='i386_next_nextstep3'
405         HostArch_CPP='i386'
406         HostVendor_CPP='next'
407         HostOS_CPP='nextstep3'
408         ;;
409 m68k-*-openbsd*)
410         HostPlatform=m68k-unknown-openbsd
411         TargetPlatform=m68k-unknown-openbsd
412         BuildPlatform=m68k-unknown-openbsd
413         HostPlatform_CPP='m68k_unknown_openbsd'
414         HostArch_CPP='m68k'
415         HostVendor_CPP='unknown'
416         HostOS_CPP='openbsd'
417         ;;
418 m68k-*-netbsd*)
419         HostPlatform=m68k-unknown-netbsd
420         TargetPlatform=m68k-unknown-netbsd
421         BuildPlatform=m68k-unknown-netbsd
422         HostPlatform_CPP='m68k_unknown_netbsd'
423         HostArch_CPP='m68k'
424         HostVendor_CPP='unknown'
425         HostOS_CPP='netbsd'
426         ;;
427 m68k-sun-sunos4*)
428         HostPlatform=m68k-sun-sunos4
429         TargetPlatform=m68k-sun-sunos4 #hack
430         BuildPlatform=m68k-sun-sunos4 #hack
431         HostPlatform_CPP='m68k_sun_sunos4'
432         HostArch_CPP='m68k'
433         HostVendor_CPP='sun'
434         HostOS_CPP='sunos4'
435         ;;
436 m88k-*-openbsd*)
437         HostPlatform=m88k-unknown-openbsd
438         TargetPlatform=m88k-unknown-openbsd
439         BuildPlatform=m88k-unknown-openbsd
440         HostPlatform_CPP='m88k_unknown_openbsd'
441         HostArch_CPP='m88k'
442         HostVendor_CPP='unknown'
443         HostOS_CPP='openbsd'
444         ;;
445 mips-*-linux*)
446         HostPlatform=mips-unknown-linux # hack again
447         TargetPlatform=mips-unknown-linux
448         BuildPlatform=mips-unknown-linux
449         HostPlatform_CPP='mips_unknown_linux'
450         HostArch_CPP='mips'
451         HostVendor_CPP='unknown'
452         HostOS_CPP='linux'
453         ;;
454 mipsel-*-linux*)
455         HostPlatform=mipsel-unknown-linux # hack again
456         TargetPlatform=mipsel-unknown-linux
457         BuildPlatform=mipsel-unknown-linux
458         HostPlatform_CPP='mipsel_unknown_linux'
459         HostArch_CPP='mipsel'
460         HostVendor_CPP='unknown'
461         HostOS_CPP='linux'
462         ;;
463 mips-dec-ultrix*)
464         HostPlatform_CPP='mips_dec_ultrix'
465         HostArch_CPP='mipsel'   # NB a little different
466         HostVendor_CPP='dec'
467         HostOS_CPP='ultrix'
468         ;;
469 mips-sgi-irix*)
470         HostPlatform=mips-sgi-irix
471         TargetPlatform=mips-sgi-irix #hack
472         BuildPlatform=mips-sgi-irix #hack
473         HostPlatform_CPP='mips_sgi_irix'
474         HostArch_CPP='mipseb'   # NB a little different
475         HostVendor_CPP='sgi'
476         HostOS_CPP='irix'
477         ;;
478 rs6000-ibm-aix*)
479         HostPlatform=rs6000-ibm-aix
480         TargetPlatform=rs6000-ibm-aix #hack
481         BuildPlatform=rs6000-ibm-aix #hack
482         HostPlatform_CPP='rs6000_ibm_aix'
483         HostArch_CPP='rs6000'
484         HostVendor_CPP='ibm'
485         HostOS_CPP='aix'
486         ;;
487 powerpc-ibm-aix*)
488         HostPlatform=powerpc-ibm-aix
489         TargetPlatform=powerpc-ibm-aix #hack
490         BuildPlatform=powerpc-ibm-aix #hack
491         HostPlatform_CPP='powerpc_ibm_aix'
492         HostArch_CPP='powerpc'
493         HostVendor_CPP='ibm'
494         HostOS_CPP='aix'
495         ;;
496 powerpc-apple-darwin*)
497         HostPlatform=powerpc-apple-darwin
498         TargetPlatform=powerpc-apple-darwin #hack
499         BuildPlatform=powerpc-apple-darwin #hack
500         HostPlatform_CPP='powerpc_apple_darwin'
501         HostArch_CPP='powerpc'
502         HostVendor_CPP='apple'
503         HostOS_CPP='darwin'
504         soext='.dylib'
505         ;;
506 powerpc-unknown-linux*)
507         HostPlatform=powerpc-unknown-linux
508         TargetPlatform=powerpc-unknown-linux
509         BuildPlatform=powerpc-unknown-linux
510         HostPlatform_CPP='powerpc_unknown_linux'
511         HostArch_CPP='powerpc'
512         HostVendor_CPP='unknown'
513         HostOS_CPP='linux'
514         ;;
515 powerpc-unknown-openbsd*)
516         HostPlatform=powerpc-unknown-openbsd
517         TargetPlatform=powerpc-unknown-openbsd
518         BuildPlatform=powerpc-unknown-openbsd
519         HostPlatform_CPP='powerpc_unknown_openbsd'
520         HostArch_CPP='powerpc'
521         HostVendor_CPP='unknown'
522         HostOS_CPP='openbsd'
523         ;;
524 powerpc64-unknown-linux*)
525         HostPlatform=powerpc64-unknown-linux
526         TargetPlatform=powerpc64-unknown-linux
527         BuildPlatform=powerpc64-unknown-linux
528         HostPlatform_CPP='powerpc64_unknown_linux'
529         HostArch_CPP='powerpc64'
530         HostVendor_CPP='unknown'
531         HostOS_CPP='linux'
532         ;;
533
534 s390-ibm-linux*)
535        HostPlatform=s390-ibm-linux
536        TargetPlatform=s390-ibm-linux #hack
537        BuildPlatform=s390-ibm-linux #hack
538         HostPlatform_CPP='s390_ibm_linux'
539         HostArch_CPP='s390'
540         HostVendor_CPP='ibm'
541         HostOS_CPP='linux'
542         ;;
543 sparc-sun-sunos4*)
544         HostPlatform=sparc-sun-sunos4
545         TargetPlatform=sparc-sun-sunos4 #hack
546         BuildPlatform=sparc-sun-sunos4 #hack
547         HostPlatform_CPP='sparc_sun_sunos4'
548         HostArch_CPP='sparc'
549         HostVendor_CPP='sun'
550         HostOS_CPP='sunos4'
551         ;;
552 sparc-sun-solaris2*)
553         HostPlatform=sparc-sun-solaris2
554         TargetPlatform=sparc-sun-solaris2 #hack
555         BuildPlatform=sparc-sun-solaris2 #hack
556         HostPlatform_CPP='sparc_sun_solaris2'
557         HostArch_CPP='sparc'
558         HostVendor_CPP='sun'
559         HostOS_CPP='solaris2'
560         ;;
561 sparc*-linux*)
562         HostPlatform=sparc-unknown-linux
563         TargetPlatform=sparc-unknown-linux
564         BuildPlatform=sparc-unknown-linux
565         HostPlatform_CPP='sparc_unknown_linux'
566         HostArch_CPP='sparc'
567         HostVendor_CPP='unknown'
568         HostOS_CPP='linux'
569         ;;
570 sparc-*-openbsd*)
571         HostPlatform=sparc-unknown-openbsd
572         TargetPlatform=sparc-unknown-openbsd
573         BuildPlatform=sparc-unknown-openbsd
574         HostPlatform_CPP='sparc_unknown_openbsd'
575         HostArch_CPP='sparc'
576         HostVendor_CPP='unknown'
577         HostOS_CPP='openbsd'
578         ;;
579 sparc64-*-openbsd*)
580         HostPlatform=sparc64-unknown-openbsd
581         TargetPlatform=sparc64-unknown-openbsd
582         BuildPlatform=sparc64-unknown-openbsd
583         HostPlatform_CPP='sparc64_unknown_openbsd'
584         HostArch_CPP='sparc64'
585         HostVendor_CPP='unknown'
586         HostOS_CPP='openbsd'
587         ;;
588 vax-*-openbsd*)
589         HostPlatform=vax-unknown-openbsd
590         TargetPlatform=vax-unknown-openbsd
591         BuildPlatform=vax-unknown-openbsd
592         HostPlatform_CPP='vax_unknown_openbsd'
593         HostArch_CPP='vax'
594         HostVendor_CPP='unknown'
595         HostOS_CPP='openbsd'
596         ;;
597 *)
598         echo "Unrecognised platform: $HostPlatform"
599         exit 1
600         ;;
601 esac
602 echo "Canonicalised to: $HostPlatform"
603 test  x"$HostPlatform" != x"$TargetPlatform" && echo "Target platform set to $TargetPlatform"
604 test  x"$BuildPlatform" != x"$HostPlatform"  && echo "Build platform set to $BuildPlatform"
605
606 BuildPlatform_CPP=$HostPlatform_CPP
607 TargetPlatform_CPP=$HostPlatform_CPP
608 BuildArch_CPP=$HostArch_CPP
609 TargetArch_CPP=$HostArch_CPP
610 BuildOS_CPP=$HostOS_CPP
611 HostOS_Full=$host_os
612 TargetOS_CPP=$HostOS_CPP
613 BuildVendor_CPP=$HostVendor_CPP
614 TargetVendor_CPP=$HostVendor_CPP
615
616 AC_SUBST(BuildPlatform)
617 AC_SUBST(HostPlatform)
618 AC_SUBST(TargetPlatform)
619 AC_SUBST(HostPlatform_CPP)
620 AC_SUBST(BuildPlatform_CPP)
621 AC_SUBST(TargetPlatform_CPP)
622
623 AC_SUBST(HostArch_CPP)
624 AC_SUBST(BuildArch_CPP)
625 AC_SUBST(TargetArch_CPP)
626
627 AC_SUBST(HostOS_CPP)
628 AC_SUBST(HostOS_Full)
629 AC_SUBST(BuildOS_CPP)
630 AC_SUBST(TargetOS_CPP)
631
632 AC_SUBST(HostVendor_CPP)
633 AC_SUBST(BuildVendor_CPP)
634 AC_SUBST(TargetVendor_CPP)
635
636 AC_SUBST(exeext)
637 AC_SUBST(soext)
638
639 dnl --------------------------------------------------------------
640 dnl * Project specific configuration options
641 dnl --------------------------------------------------------------
642 dnl What follows is a bunch of options that can either be configured
643 dnl through command line options to the configure script or by
644 dnl supplying defns in the build tree's mk/build.mk. Having the option to
645 dnl use either is considered a Feature.
646
647 dnl ** What command to use to compile compiler sources ?
648 dnl --------------------------------------------------------------
649
650 AC_ARG_WITH([ghc],
651 [AC_HELP_STRING([--with-ghc=ARG],
652   [Use ARG as the path to GHC  [default=autodetect]])],
653   [WithGhc="$withval"],
654   [if test "$GHC" = ""; then
655     AC_PATH_PROG([GHC], [ghc])
656   fi
657   WithGhc="$GHC"])
658 # GHC is passed to Cabal, so we need a native path
659 if test "${WithGhc}" != "" && test "$HostPlatform" = "i386-unknown-mingw32"
660 then
661     if test "${OSTYPE}" = "msys"
662     then
663         WithGhc=`echo "${WithGhc}" | sed "s#^/\([a-zA-Z]\)/#\1:/#"`
664     else
665         # Canonicalise to <drive>:/path/to/ghc
666         WithGhc=`cygpath -m ${WithGhc}`
667     fi
668     echo "Canonicalised to: ${WithGhc}"
669 fi
670 AC_SUBST([WithGhc])
671
672 AC_ARG_WITH(hc,
673 [AC_HELP_STRING([--with-hc=ARG],
674         [Use ARG as the path to the compiler for compiling ordinary
675          Haskell code  (default= value of --with-ghc)])],
676 [WithHc="$withval"],
677 [WithHc=$WithGhc]
678 )
679 AC_SUBST(WithHc)
680
681 AC_ARG_ENABLE(bootstrap-with-devel-snapshot,
682 [AC_HELP_STRING([--enable-bootstrap-with-devel-snapshot],
683                 [Allow bootstrapping using a development snapshot of GHC.  This is not guaranteed to work.])],
684         EnableBootstrapWithDevelSnaphost=YES,
685         EnableBootstrapWithDevelSnaphost=NO
686 )
687
688 if test "$WithGhc" != ""; then
689   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
690
691   if test "$GhcMajVersion" = "unknown" -o "$GhcMinVersion" = "unknown"; then
692      AC_MSG_ERROR([Cannot determine the version of $WithGhc.  Is it really GHC?])
693   fi
694
695   AC_SUBST(GhcVersion)dnl
696   AC_SUBST(GhcMajVersion)dnl
697   AC_SUBST(GhcMinVersion)dnl
698   AC_SUBST(GhcPatchLevel)dnl
699   GhcMinVersion2=`echo "$GhcMinVersion" | sed 's/^\\(.\\)$/0\\1/'`
700   GhcCanonVersion="$GhcMajVersion$GhcMinVersion2"
701   if test $GhcCanonVersion -ge 607; then ghc_ge_607=YES; else ghc_ge_607=NO; fi
702   if test $GhcCanonVersion -ge 609; then ghc_ge_609=YES; else ghc_ge_609=NO; fi
703   AC_SUBST(ghc_ge_607)dnl
704   AC_SUBST(ghc_ge_609)dnl
705 fi
706
707 AC_PATH_PROGS(NHC,nhc nhc98)
708 AC_PATH_PROG(HBC,hbc)
709
710 dnl ** Which gcc to use?
711 dnl --------------------------------------------------------------
712 AC_ARG_WITH(gcc,
713 [AC_HELP_STRING([--with-gcc=ARG],
714         [Use ARG as the path to GCC  [default=autodetect]])],
715 [WhatGccIsCalled="$withval"
716  if test "x$HostPlatform"  = "xi386-unknown-mingw32" && \
717     test "${OSTYPE}"      != "msys"                  && \
718     test "${withval}"     != ""
719  then
720      # Canonicalise to <drive>:/path/to/gcc
721      withval=`cygpath -m ${withval}`
722  fi;
723  CC="$withval"
724  export CC
725  ],
726 [WhatGccIsCalled="gcc"]
727 )
728 AC_SUBST(WhatGccIsCalled)
729
730 dnl ** Which ld to use?
731 dnl --------------------------------------------------------------
732 AC_ARG_WITH(ld,
733 [AC_HELP_STRING([--with-ld=ARG],
734         [Use ARG as the path to LD  [default=autodetect]])],
735 [if test "x$HostPlatform"  = "xi386-unknown-mingw32" && \
736     test "${OSTYPE}"      != "msys"                  && \
737     test "${withval}"     != ""
738  then
739      # Canonicalise to <drive>:/path/to/ld
740      withval=`cygpath -m ${withval}`
741  fi;
742  LD=$withval
743  FP_PROG_LD([$LD])
744  ],
745  [FP_PROG_LD()]
746 )
747
748 dnl ** Build shared and/or static libs?
749 dnl --------------------------------------------------------------
750 AC_ARG_ENABLE(shared,
751 [AC_HELP_STRING([--enable-shared],
752 [Build shared libraries, if available (EXPERIMENTAL, non-working). [default=no]])],
753 [ if test x"$enableval" = x"yes"; then
754         AC_MSG_WARN([--enable-shared is experimental and not fully supported at this time])
755         BuildSharedLibs=YES
756   else
757         BuildSharedLibs=NO
758   fi
759 ],
760 [BuildSharedLibs=NO]
761 )
762 AC_SUBST(BuildSharedLibs)
763
764 # ToDo later:
765 # AC_ARG_ENABLE(static,
766 # [AC_HELP_STRING([--enable-static],
767 # [Build static libraries. [default=yes]])],
768 # [ if test x"$enableval" = x"yes"; then
769 #         BuildStaticLibs=YES
770 #   else
771 #         BuildStaticLibs=NO
772 #   fi
773 # ],
774 # [BuildStaticLibs=YES]
775 # )
776 # AC_SUBST(BuildStaticLibs)
777
778 dnl ** Booting from .hc files?
779 dnl --------------------------------------------------------------
780 AC_ARG_ENABLE(hc-boot,
781 [AC_HELP_STRING([--enable-hc-boot],
782 [Boot the Glasgow Haskell Compiler from intermediate .hc files.
783  (This option is mostly of interest to porters.) [default=no]])],
784 [ if test x"$enableval" = x"yes"; then
785         BootingFromHc=YES
786   else
787         BootingFromHc=NO
788   fi
789 ],
790 [BootingFromHc=NO]
791 )
792 AC_SUBST(BootingFromHc)
793
794 dnl ** Booting from unregisterised .hc files?
795 dnl --------------------------------------------------------------
796 AC_ARG_ENABLE(hc-boot-unregisterised,
797 [AC_HELP_STRING([--enable-hc-boot-unregisterised],
798 [ With --enable-hc-boot, treat the intermediate .hc files as
799  unregisterised rather than registerised code.
800  (This option is mostly of interest to porters.) [default=no]])],
801 [ if test x"$enableval" = x"yes"; then
802         BootingFromUnregisterisedHc=YES
803   else
804         BootingFromUnregisterisedHc=NO
805   fi
806 ],
807 [BootingFromUnregisterisedHc=NO]
808 )
809 AC_SUBST(BootingFromUnregisterisedHc)
810
811 if test "$BootingFromHc" = "NO"; then
812 if test "$BootingFromUnregisterisedHc" = "YES"; then
813 AC_MSG_ERROR([--enable-hc-boot-unregisterised requires --enable-hc-boot.])
814 fi;
815 fi;
816
817 dnl ** Must have GHC to build GHC, unless --enable-hc-boot is on
818 if test "$BootingFromHc" = "NO" -a -d "$srcdir/compiler"; then
819   if test "$WithGhc" = ""; then
820      AC_MSG_ERROR([GHC is required unless bootstrapping from .hc files.])
821   fi
822   FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[6.6],
823     [AC_MSG_ERROR([GHC version 6.6 or later is required to compile GHC.])])dnl
824
825   if test `expr $GhcMinVersion % 2` = "1"; then
826      echo $EnableBootstrapWithDevelSnaphost
827      if test "$EnableBootstrapWithDevelSnaphost" = "NO"; then
828         AC_MSG_ERROR([
829      $WithGhc is a development snapshot of GHC, version $GhcVersion.
830      Bootstrapping using this version of GHC is not supported, and may not
831      work.  Use --enable-bootstrap-with-devel-snapshot to try it anyway,
832      or --with-ghc to specify a different GHC to use.])
833      fi
834   fi
835 fi;
836
837 # This uses GHC, so put it after the "GHC is required" check above:
838 FP_FIND_ROOT
839
840 dnl ** Enable the construction of Win32 DLLs?
841 dnl --------------------------------------------------------------
842 dnl
843 dnl [ The ability to build the RTS and libraries as separate DLLs used
844 dnl   to be supported, but isn't currently (updates to the RTS, compiler
845 dnl   and build system would be required to bring it back again.)
846 dnl   Hence, exposing it as an option is false advertisement, so better
847 dnl   disable it to avoid confusion (but leave it commented-out rather
848 dnl   than removed in order to remind ourselves to bring back the
849 dnl   feature at some stage.) ]
850 dnl
851 dnl AC_ARG_ENABLE(win32-dlls,
852 dnl [  --enable-win32-dlls
853 dnl         If on a Win32 platform running mingw32/cygwin, enable the
854 dnl         construction of DLLs containing ghc-compiled code.
855 dnl ],
856 dnl [
857 dnl case $HostOS_CPP in
858 dnl cygwin32) ;;
859 dnl mingw32)  ;;
860 dnl *)    echo "Unrecognised win32 platform: $HostPlatform"
861 dnl       exit 1
862 dnl       ;;
863 dnl esac
864 dnl EnableWin32DLLs=YES
865 dnl ],
866 dnl [EnableWin32DLLs=NO]
867 dnl )
868 dnl AC_SUBST(EnableWin32DLLs)
869 dnl if test x"$EnableWin32DLLs" = "xYES" ; then
870 dnl  AC_DEFINE(HAVE_WIN32_DLL_SUPPORT)
871 dnl fi
872
873 dnl ** Mac OS X: explicit deployment target
874 dnl --------------------------------------------------------------
875 AC_ARG_WITH([macosx-deployment-target],
876 [AC_HELP_STRING([--with-macosx-deployment-target=VERSION],
877         [Build for Mac OS VERSION and higher  (default= version of build host)])],
878 [FP_MACOSX_DEPLOYMENT_TARGET="$withval"
879  if test "x$TargetOS_CPP-$TargetVendor_CPP" != "xdarwin-apple"; then
880    # ignore everywhere, but on Mac OS
881    AC_MSG_WARN([--macosx-deployment-target is only available on Mac OS X])
882    FP_MACOSX_DEPLOYMENT_TARGET=none
883  fi],
884 [FP_MACOSX_DEPLOYMENT_TARGET=none]
885 )
886 FP_CHECK_MACOSX_DEPLOYMENT_TARGET
887 AC_SUBST(MACOSX_DEPLOYMENT_VERSION)
888 AC_SUBST(MACOSX_DEPLOYMENT_SDK)
889
890 dnl --------------------------------------------------------------
891 dnl End of configure script option section
892 dnl --------------------------------------------------------------
893
894
895 dnl --------------------------------------------------------------
896 dnl * General configuration checks
897 dnl --------------------------------------------------------------
898
899 dnl ** Can the unix package be built?
900 dnl --------------------------------------------------------------
901
902 if test x"$TargetPlatform" = x"i386-unknown-mingw32"; then
903    GhcLibsWithUnix=NO
904 else
905    GhcLibsWithUnix=YES
906 fi
907 AC_SUBST([GhcLibsWithUnix])
908
909 dnl ** does #! work?
910 AC_SYS_INTERPRETER()
911
912 dnl ** look for `perl', but only in /bin on Windows
913 case $HostOS_CPP in
914 cygwin32|mingw32)
915       AC_CHECK_PROG(PerlCmd,perl,/bin/perl,,/bin)
916       if test -z "$PerlCmd"; then
917          echo "You must install the version of Perl shipped with GHC"
918          echo "(or a compatible one) in /bin."
919          exit 1
920       fi
921    ;;
922 *)
923    AC_PATH_PROG(PerlCmd,perl)
924    if test -z "$PerlCmd"; then
925       echo "You must install perl before you can continue"
926       echo "Perhaps it is already installed, but not in your PATH?"
927       exit 1
928    else
929    FPTOOLS_CHECK_PERL_VERSION
930    fi
931    ;;
932 esac
933
934 dnl ** does #! path/to/perl work? (sometimes it's too long...)
935 FPTOOLS_SHEBANG_PERL
936
937 dnl ** check for Python
938 AC_PATH_PROG(PythonCmd,python)
939
940 dnl ** look for GCC and find out which version
941 dnl     Figure out which C compiler to use.  Gcc is preferred.
942 dnl     If gcc, make sure it's at least 2.1
943 dnl
944 FP_HAVE_GCC
945 FP_MINGW_GCC
946 FP_GCC_EXTRA_FLAGS
947
948 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
949 AC_PROG_CPP
950
951 dnl ** Without optimization some INLINE trickery fails for GHCi
952 SRC_CC_OPTS="-O"
953
954 SRC_CC_OPTS="$SRC_CC_OPTS $CFLAGS"
955 SRC_LD_OPTS="$SRC_LD_OPTS $LDFLAGS"
956
957 AC_SUBST(SRC_CC_OPTS)
958 AC_SUBST(SRC_LD_OPTS)
959
960 dnl ** figure out how to do context diffs
961 FP_PROG_CONTEXT_DIFF
962
963 dnl ** Find find command (for Win32's benefit)
964 FP_PROG_FIND
965
966 dnl ** Find sort command (for the benefit of Win32 environs)
967 FP_PROG_SORT
968
969 dnl Let's make sure install-sh is executable here.  If we got it from
970 dnl a darcs repo, it might not be (see bug #978).
971 chmod +x install-sh
972 dnl ** figure out how to do a BSD-ish install
973 AC_PROG_INSTALL
974
975 dnl If you can run configure, you certainly have /bin/sh
976 AC_DEFINE([HAVE_BIN_SH], [1], [Define to 1 if you have /bin/sh.])
977
978 dnl ** how to invoke `ar' and `ranlib'
979 FP_PROG_AR_NEEDS_RANLIB
980 FP_PROG_AR_SUPPORTS_INPUT
981
982 dnl ** Check to see whether ln -s works
983 AC_PROG_LN_S
984
985
986 dnl ** Find the path to sed
987 AC_PATH_PROG(SedCmd,sed)
988
989
990 dnl ** check for time command
991 AC_PATH_PROG(TimeCmd,time)
992
993 dnl ** check for tar
994 dnl   if GNU tar is named gtar, look for it first.
995 AC_PATH_PROGS(TarCmd,gtar tar,tar)
996
997 dnl ** check for patch
998 dnl if GNU patch is named gpatch, look for it first
999 AC_PATH_PROGS(PatchCmd,gpatch patch, patch)
1000
1001 AC_PATH_PROG(HSCOLOUR,HsColour)
1002 # HsColour is passed to Cabal, so we need a native path
1003 if test "x$HostPlatform"  = "xi386-unknown-mingw32" && \
1004    test "${OSTYPE}"      != "msys"                  && \
1005    test "${HSCOLOUR}"    != ""
1006 then
1007     # Canonicalise to <drive>:/path/to/gcc
1008     HSCOLOUR=`cygpath -m ${HSCOLOUR}`
1009 fi
1010
1011 dnl ** check for DocBook toolchain
1012 FP_CHECK_DOCBOOK_DTD
1013 FP_DIR_DOCBOOK_XSL([/usr/share/xml/docbook/stylesheet/nwalsh/current /usr/share/xml/docbook/stylesheet/nwalsh /usr/share/xml/docbook/xsl-stylesheets* /usr/share/sgml/docbook/docbook-xsl-stylesheets* /usr/share/sgml/docbook/xsl-stylesheets* /opt/kde?/share/apps/ksgmltools2/docbook/xsl /usr/share/docbook-xsl /usr/share/sgml/docbkxsl /usr/local/share/xsl/docbook /sw/share/xml/xsl/docbook-xsl /opt/local/share/xsl/docbook-xsl])
1014
1015 FP_PROG_DBLATEX
1016
1017 FP_PROG_HSTAGS
1018
1019 dnl ** check for ghc-pkg command
1020 FP_PROG_GHC_PKG
1021
1022 dnl ** check for installed happy binary + version
1023 dnl    (don't do it if we're booting from .hc files though.)
1024 if test "$BootingFromHc" = "NO"; then
1025 FPTOOLS_HAPPY
1026 fi;
1027
1028 dnl ** check for installed alex binary + version
1029 dnl    (don't do it if we're booting from .hc files though.)
1030 if test "$BootingFromHc" = "NO"; then
1031 FPTOOLS_ALEX
1032 fi;
1033
1034 dnl Check we have an acceptable version of windres
1035 FPTOOLS_WINDRES
1036
1037 dnl --------------------------------------------------
1038 dnl ### program checking section ends here ###
1039 dnl --------------------------------------------------
1040
1041 dnl --------------------------------------------------
1042 dnl * Platform header file and syscall feature tests
1043 dnl ### checking the state of the local header files and syscalls ###
1044
1045 dnl ** check for full ANSI header (.h) files
1046 AC_HEADER_STDC
1047
1048 dnl ** Enable large file support.  NB. do this before testing the type of
1049 dnl    off_t, because it will affect the result of that test.
1050 AC_SYS_LARGEFILE
1051
1052 dnl ** check for specific header (.h) files that we are interested in
1053 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])
1054
1055 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
1056 AC_HEADER_TIME
1057
1058 dnl ** do we have long longs?
1059 AC_CHECK_TYPES([long long])
1060
1061 dnl ** what are the sizes of various types
1062 AC_CHECK_SIZEOF(char,               1)
1063 AC_CHECK_SIZEOF(double,             8)
1064 AC_CHECK_SIZEOF(float,              4)
1065 AC_CHECK_SIZEOF(int,                4)
1066 AC_CHECK_SIZEOF(long,               4)
1067 if test "$ac_cv_type_long_long" = yes; then
1068 AC_CHECK_SIZEOF(long long,          8)
1069 fi
1070 AC_CHECK_SIZEOF(short,              2)
1071 AC_CHECK_SIZEOF(unsigned char,      1)
1072 AC_CHECK_SIZEOF(unsigned int,       4)
1073 AC_CHECK_SIZEOF(unsigned long,      4)
1074 if test "$ac_cv_type_long_long" = yes; then
1075 AC_CHECK_SIZEOF(unsigned long long, 8)
1076 fi
1077 AC_CHECK_SIZEOF(unsigned short,     2)
1078 AC_CHECK_SIZEOF(void *,             4)
1079
1080 dnl ** what are alignment constraints on various types
1081 FP_CHECK_ALIGNMENT(char)
1082 FP_CHECK_ALIGNMENT(double)
1083 FP_CHECK_ALIGNMENT(float)
1084 FP_CHECK_ALIGNMENT(int)
1085 FP_CHECK_ALIGNMENT(long)
1086 if test "$ac_cv_type_long_long" = yes; then
1087 FP_CHECK_ALIGNMENT(long long)
1088 fi
1089 FP_CHECK_ALIGNMENT(short)
1090 FP_CHECK_ALIGNMENT(unsigned char)
1091 FP_CHECK_ALIGNMENT(unsigned int)
1092 FP_CHECK_ALIGNMENT(unsigned long)
1093 if test "$ac_cv_type_long_long" = yes; then
1094 FP_CHECK_ALIGNMENT(unsigned long long)
1095 fi
1096 FP_CHECK_ALIGNMENT(unsigned short)
1097 FP_CHECK_ALIGNMENT(void *)
1098
1099 FP_CHECK_FUNC([WinExec],
1100   [@%:@include <windows.h>], [WinExec("",0)])
1101
1102 FP_CHECK_FUNC([GetModuleFileName],
1103   [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
1104
1105 dnl ** check return type of signal handlers
1106 dnl Foo: assumes we can use prototypes.
1107 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
1108 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
1109 dnl [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1110 dnl #include <signal.h>
1111 dnl #ifdef signal
1112 dnl #undef signal
1113 dnl #endif
1114 dnl void (*signal (int, void (*)(int)))(int);
1115 dnl ]],
1116 dnl [[int i;]])],
1117 dnl [ac_cv_type_signal_handler=void_int],
1118 dnl [ac_cv_type_signal_handler=int_void])])
1119 dnl if test "$ac_cv_type_signal_handler" = void_int; then
1120 dnl AC_DEFINE(VOID_INT_SIGNALS)
1121 dnl fi
1122
1123 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
1124 AC_TYPE_SIGNAL
1125 if test "$ac_cv_type_signal" = void; then
1126   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).])
1127 fi
1128
1129 dnl ** check for more functions
1130 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
1131 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r, sched_setaffinity])
1132
1133 AC_TRY_RUN([
1134 #include <sys/types.h>
1135 #include <sys/time.h>
1136 int main(void) {
1137   struct itimerval tval;
1138   tval.it_value.tv_sec = 1;
1139   tval.it_value.tv_usec = 0;
1140   tval.it_interval = tval.it_value;
1141   return setitimer(ITIMER_VIRTUAL, &tval, (void*)0) != 0;
1142 }
1143 ],[AC_DEFINE([HAVE_SETITIMER_VIRTUAL], [1], [Define to 1 if setitimer accepts ITIMER_VIRTUAL, 0 else.])])
1144
1145 dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
1146 dnl ** _POSIX_C_SOURCE is defined
1147 AC_CHECK_DECLS([ctime_r], , ,
1148 [#define _POSIX_SOURCE 1
1149 #define _POSIX_C_SOURCE 199506L
1150 #include <time.h>])
1151
1152 dnl ** For ghc/rts/gmp:
1153 AC_CHECK_FUNCS([getpagesize])
1154
1155 dnl ** check whether this machine has gmp3 installed
1156 AC_CHECK_LIB(gmp,  __gmpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
1157   AC_CHECK_LIB(gmp3, __gmpz_fdiv_qr,  HaveLibGmp=YES; LibGmp=gmp3,
1158     HaveLibGmp=NO; LibGmp=not-installed))
1159   if test $HaveLibGmp = YES; then
1160     AC_DEFINE([HAVE_LIB_GMP], [1], [Define to 1 if GMP library is installed.])
1161   fi;
1162 AC_SUBST(HaveLibGmp)
1163 AC_SUBST(LibGmp)
1164
1165 dnl ** (Mac OS X only: check for GMP.framework)
1166 HaveFrameworkGMP=NO
1167 case $HostPlatform in
1168 *-apple-darwin)
1169     AC_MSG_CHECKING([for GMP.framework])
1170     save_libs="$LIBS"
1171     LIBS="-framework GMP"
1172     AC_TRY_LINK_FUNC(__gmpz_fdiv_qr, HaveFrameworkGMP=YES,)
1173     if test $HaveFrameworkGMP = YES; then
1174       AC_DEFINE([HAVE_FRAMEWORK_GMP], [1], [Define to 1 if GMP.framework is installed (Mac OS X only).])
1175     fi;
1176     LIBS="$save_libs"
1177     AC_MSG_RESULT([$HaveFrameworkGMP])
1178     ;;
1179 esac
1180 AC_SUBST(HaveFrameworkGMP)
1181
1182 dnl ** check for mingwex library
1183 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
1184 AC_SUBST(HaveLibMingwEx)
1185
1186 if test $HaveLibMingwEx = YES ; then
1187   AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
1188 fi
1189
1190 if test "$HaveLibGmp" = "NO"; then
1191 if test "$HostArch_CPP" = "ia64" -o "$HostArch_CPP" = "mipseb" ; then
1192 AC_MSG_ERROR([You need to install libgmp (the in-tree version does not work on IA64 or mips64).])
1193 fi;
1194 fi;
1195
1196 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
1197 dnl    the order of these tests matters: bfd needs liberty
1198 AC_CHECK_LIB(iberty, xmalloc)
1199 AC_CHECK_LIB(bfd,    bfd_init)
1200
1201 dnl ** check for math library
1202 AC_CHECK_FUNC(atan,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
1203 if test x"$fp_libm_not_needed" = xdunno; then
1204    AC_CHECK_LIB([m], [atan], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
1205 fi
1206 AC_SUBST([LIBM])
1207
1208 dnl ################################################################
1209 dnl Check for libraries
1210 dnl ################################################################
1211
1212 dnl ** check whether we need -ldl to get dlopen()
1213
1214 AC_CHECK_LIB(dl, dlopen,
1215     [HaveLibDL=YES
1216      AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if you need -ldl to get dlopen().])
1217      LIBS="$LIBS -ldl"],
1218     [HaveLibDL=NO])
1219 AC_SUBST(HaveLibDL)
1220
1221 dnl --------------------------------------------------
1222 dnl * Miscellaneous feature tests
1223 dnl --------------------------------------------------
1224
1225 dnl ** can we get alloca?
1226 AC_FUNC_ALLOCA
1227
1228 dnl ** Working vfork?
1229 AC_FUNC_FORK
1230
1231 dnl ** determine whether or not const works
1232 AC_C_CONST
1233
1234 dnl ** are we big endian?
1235 AC_C_BIGENDIAN
1236 FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
1237
1238 dnl ** check for leading underscores in symbol names
1239 FP_LEADING_UNDERSCORE
1240
1241 dnl ** check for ld, whether it has an -x option, and if it is GNU ld
1242 FP_PROG_LD_X
1243 FP_PROG_LD_IS_GNU
1244
1245 dnl ** check for Apple-style dead-stripping support
1246 dnl    (.subsections-via-symbols assembler directive)
1247
1248
1249 AC_MSG_CHECKING(for .subsections_via_symbols)
1250 AC_COMPILE_IFELSE(
1251     [AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
1252     [AC_MSG_RESULT(yes)
1253      AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
1254                [Define to 1 if Apple-style dead-stripping is supported.])
1255     ],
1256     [AC_MSG_RESULT(no)])
1257
1258 dnl *** check for GNU non-executable stack note support (ELF only)
1259 dnl     (.section .note.GNU-stack,"",@progbits)
1260
1261 AC_MSG_CHECKING(for GNU non-executable stack support)
1262 AC_COMPILE_IFELSE(
1263     [AC_LANG_PROGRAM([__asm__ (".section .note.GNU-stack,\"\",@progbits");], [0])],
1264     [AC_MSG_RESULT(yes)
1265      AC_DEFINE([HAVE_GNU_NONEXEC_STACK],[1],
1266                [Define to 1 if GNU non-executable stack notes are supported.])
1267     ],
1268     [AC_MSG_RESULT(no)])
1269
1270 dnl ** check for librt
1271 AC_CHECK_LIB(rt, clock_gettime)
1272 AC_CHECK_FUNCS(clock_gettime timer_create timer_settime)
1273 FP_CHECK_TIMER_CREATE
1274
1275 dnl ** check for Apple's "interesting" long double compatibility scheme
1276 AC_MSG_CHECKING(for printf\$LDBLStub)
1277 AC_TRY_LINK_FUNC(printf\$LDBLStub,
1278     [
1279         AC_MSG_RESULT(yes)
1280         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
1281             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
1282     ],
1283     [
1284         AC_MSG_RESULT(no)
1285         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
1286             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
1287     ])
1288
1289 # test for GTK+
1290 AC_PATH_PROGS([GTK_CONFIG], [pkg-config])
1291 if test -n "$GTK_CONFIG"; then
1292   if $GTK_CONFIG gtk+-2.0 --atleast-version=2.0; then
1293     GTK_CONFIG="$GTK_CONFIG gtk+-2.0"
1294   else
1295     AC_MSG_WARN([GTK+ not usable, need at least version 2.0])
1296     GTK_CONFIG=
1297   fi
1298 fi
1299 AC_SUBST([GTK_CONFIG])
1300
1301 #Checking for PAPI
1302 AC_CHECK_LIB(papi, PAPI_library_init, HavePapiLib=YES, HavePapiLib=NO)
1303 AC_CHECK_HEADER([papi.h], [HavePapiHeader=YES], [HavePapiHeader=NO])
1304 AC_SUBST(HavePapiLib)
1305 AC_SUBST(HavePapiHeader)
1306
1307 if test "$HavePapiLib" = "YES" -a "$HavePapiHeader" = "YES"; then
1308    HavePapi=YES
1309 else
1310    HavePapi=NO
1311 fi
1312 AC_SUBST(HavePapi)
1313
1314 if test "$DIR_DOCBOOK_XSL" = "" ||
1315    test "$XsltprocCmd" = ""
1316 then
1317     BUILD_DOCBOOK_HTML=NO
1318 else
1319     BUILD_DOCBOOK_HTML=YES
1320 fi
1321 AC_SUBST(BUILD_DOCBOOK_HTML)
1322
1323 if test "$DblatexCmd" = ""
1324 then
1325     BUILD_DOCBOOK_PS=NO
1326     BUILD_DOCBOOK_PDF=NO
1327 else
1328     BUILD_DOCBOOK_PS=YES
1329     BUILD_DOCBOOK_PDF=YES
1330 fi
1331 AC_SUBST(BUILD_DOCBOOK_PS)
1332 AC_SUBST(BUILD_DOCBOOK_PDF)
1333
1334 AC_CONFIG_FILES([mk/config.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal ghc.spec extra-gcc-opts docs/users_guide/ug-book.xml])
1335 AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp > mk/stamp-h])
1336 AC_OUTPUT
1337
1338 # We get caught by
1339 #     http://savannah.gnu.org/bugs/index.php?1516
1340 #     $(eval ...) inside conditionals causes errors
1341 # with make 3.80, so warn the user if it looks like they're about to
1342 # try to use it.
1343 # We would use "grep -q" here, but Solaris's grep doesn't support it.
1344 checkMake380() {
1345     if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
1346     then
1347         echo
1348         echo "WARNING: It looks like \"$1\" is GNU make 3.80."
1349         echo "This version cannot be used to build GHC."
1350         echo "Please use GNU make >= 3.81."
1351     fi
1352 }
1353
1354 checkMake380 make
1355 checkMake380 gmake
1356
1357 echo ["
1358 ----------------------------------------------------------------------
1359 Configure completed successfully.
1360
1361    Building GHC version  : $ProjectVersion
1362
1363    Build platform        : $BuildPlatform
1364    Host platform         : $HostPlatform
1365    Target platform       : $TargetPlatform
1366 "]
1367
1368 if test "$BootingFromHc" = "YES"; then
1369 echo ["\
1370    Bootstrapping from HC files.
1371 "]
1372 else
1373 echo ["\
1374    Bootstrapping using   : $WithGhc
1375       which is version   : $GhcVersion
1376 "]
1377 fi
1378
1379 echo ["\
1380    Using GCC             : $WhatGccIsCalled
1381       which is version   : $GccVersion
1382
1383    ld       : $LdCmd
1384    Happy    : $HappyCmd
1385    Alex     : $AlexCmd
1386    Python   : $PythonCmd
1387    Perl     : $PerlCmd"]
1388
1389 if test "$HSCOLOUR" = ""; then
1390 echo ["
1391    HsColour was not found; documentation will not contain source links
1392 "]
1393 else
1394 echo ["\
1395    HsColour : $HSCOLOUR
1396 "]
1397 fi
1398
1399 echo "Building DocBook HTML documentation: $BUILD_DOCBOOK_HTML"
1400 echo "Building DocBook PS documentation:   $BUILD_DOCBOOK_PS"
1401 echo "Building DocBook PDF documentation:  $BUILD_DOCBOOK_PDF"
1402
1403 echo ["Building shared libraries      : $BuildSharedLibs"]
1404
1405 echo ["----------------------------------------------------------------------
1406 "]
1407
1408 echo "\
1409 For a standard build of GHC (fully optimised with profiling), type (g)make.
1410
1411 To make changes to the default build configuration, copy the file
1412 mk/build.mk.sample to mk/build.mk, and edit the settings in there.
1413
1414 For more information on how to configure your GHC build, see
1415    http://hackage.haskell.org/trac/ghc/wiki/Building
1416 "