Add configure option --with-macos-deployment-target
[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.9], [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     echo "GHC configuration does not support differing host/target (i.e., cross-compiling)"
99     exit 1
100 fi
101
102 exeext=''
103 soext='.so'
104 #
105 # The following will be more difficult when we *are* cross-compiling.
106 # Suitable names to slam in *_CPP are in platform.h.in.
107 # We also record the architecture, vendor, and operating system (OS)
108 # separately.
109 case $HostPlatform in
110 alpha*-dec-osf[[12]]*)
111         HostPlatform=alpha-dec-osf1   # canonicalise for our purposes
112         TargetPlatform=alpha-dec-osf1 # this will work for now... (hack)
113         BuildPlatform=alpha-dec-osf1  # hack
114         HostPlatform_CPP='alpha_dec_osf1'
115         HostArch_CPP='alpha'
116         HostVendor_CPP='dec'
117         HostOS_CPP='osf1'
118         ;;
119 alpha*-dec-osf[[345]]*)
120         HostPlatform=alpha-dec-osf3   # canonicalise for our purposes
121         TargetPlatform=alpha-dec-osf3 # this will work for now... (hack)
122         BuildPlatform=alpha-dec-osf3  # hack
123         HostPlatform_CPP='alpha_dec_osf3'
124         HostArch_CPP='alpha'
125         HostVendor_CPP='dec'
126         HostOS_CPP='osf3'
127         ;;
128 alpha*-unknown-linux*)
129         HostPlatform=alpha-unknown-linux
130         TargetPlatform=alpha-unknown-linux
131         BuildPlatform=alpha-unknown-linux
132         HostPlatform_CPP='alpha_unknown_linux'
133         HostArch_CPP='alpha'
134         HostVendor_CPP='unknown'
135         HostOS_CPP='linux'
136         ;;
137 alpha*-unknown-freebsd*)
138         HostPlatform=alpha-unknown-freebsd
139         TargetPlatform=alpha-unknown-freebsd
140         BuildPlatform=alpha-unknown-freebsd
141         HostPlatform_CPP='alpha_unknown_freebsd'
142         HostArch_CPP='alpha'
143         HostVendor_CPP='unknown'
144         HostOS_CPP='freebsd'
145         ;;
146 alpha*-unknown-openbsd*)
147         HostPlatform=alpha-unknown-openbsd
148         TargetPlatform=alpha-unknown-openbsd
149         BuildPlatform=alpha-unknown-openbsd
150         HostPlatform_CPP='alpha_unknown_openbsd'
151         HostArch_CPP='alpha'
152         HostVendor_CPP='unknown'
153         HostOS_CPP='openbsd'
154         ;;
155 amd64-*-openbsd*|x86_64-*-openbsd*)
156         HostPlatform=x86_64-unknown-openbsd
157         TargetPlatform=x86_64-unknown-openbsd
158         BuildPlatform=x86_64-unknown-openbsd
159         HostPlatform_CPP='x86_64_unknown_openbsd'
160         HostArch_CPP='x86_64'
161         HostVendor_CPP='unknown'
162         HostOS_CPP='openbsd'
163         ;;
164 amd64-*-freebsd*|x86_64-*-freebsd*)
165         HostPlatform=x86_64-unknown-freebsd
166         TargetPlatform=x86_64-unknown-freebsd
167         BuildPlatform=x86_64-unknown-freebsd
168         HostPlatform_CPP='x86_64_unknown_freebsd'
169         HostArch_CPP='x86_64'
170         HostVendor_CPP='unknown'
171         HostOS_CPP='freebsd'
172         ;;
173 arm*-linux*)
174         HostPlatform=arm-unknown-linux # hack again
175         TargetPlatform=arm-unknown-linux
176         BuildPlatform=arm-unknown-linux
177         HostPlatform_CPP='arm_unknown_linux'
178         HostArch_CPP='arm'
179         HostVendor_CPP='unknown'
180         HostOS_CPP='linux'
181         ;;
182 arm*-openbsd*)
183         HostPlatform=arm-unknown-openbsd
184         TargetPlatform=arm-unknown-openbsd
185         BuildPlatform=arm-unknown-openbsd
186         HostPlatform_CPP='arm_unknown_openbsd'
187         HostArch_CPP='arm'
188         HostVendor_CPP='unknown'
189         HostOS_CPP='openbsd'
190         ;;
191 hppa*-*-linux*)
192         HostPlatform=hppa-unknown-linux # hack again
193         TargetPlatform=hppa-unknown-linux
194         BuildPlatform=hppa-unknown-linux
195         HostPlatform_CPP='hppa_unknown_linux'
196         HostArch_CPP='hppa'
197         HostVendor_CPP='unknown'
198         HostOS_CPP='linux'
199         ;;
200 hppa*-*-openbsd*)
201         HostPlatform=hppa-unknown-openbsd # hack again
202         TargetPlatform=hppa-unknown-openbsd
203         BuildPlatform=hppa-unknown-openbsd
204         HostPlatform_CPP='hppa_unknown_openbsd'
205         HostArch_CPP='hppa'
206         HostVendor_CPP='unknown'
207         HostOS_CPP='openbsd'
208         ;;
209 hppa1.1-hp-hpux*)
210         HostPlatform=hppa1.1-hp-hpux  # canonicalise for our purposes (hack)
211         TargetPlatform=hppa1.1-hp-hpux
212         BuildPlatform=hppa1.1-hp-hpux
213         HostPlatform_CPP='hppa1_1_hp_hpux'
214         HostArch_CPP='hppa1_1'
215         HostVendor_CPP='hp'
216         HostOS_CPP='hpux'
217         ;;
218 i[[3456]]86-*-linuxaout*)
219         HostPlatform=i386-unknown-linuxaout   # hack again
220         TargetPlatform=i386-unknown-linuxaout
221         BuildPlatform=i386-unknown-linuxaout
222         HostPlatform_CPP='i386_unknown_linuxaout'
223         HostArch_CPP='i386'
224         HostVendor_CPP='unknown'
225         HostOS_CPP='linuxaout'
226         ;;
227 i[[3456]]86-*-linux*)
228         HostPlatform=i386-unknown-linux # hack again
229         TargetPlatform=i386-unknown-linux
230         BuildPlatform=i386-unknown-linux
231         HostPlatform_CPP='i386_unknown_linux'
232         HostArch_CPP='i386'
233         HostVendor_CPP='unknown'
234         HostOS_CPP='linux'
235         ;;
236 i[[3456]]86-*-kfreebsd*-gnu)
237         HostPlatform=i386-unknown-kfreebsdgnu # hack again
238         TargetPlatform=i386-unknown-kfreebsdgnu
239         BuildPlatform=i386-unknown-kfreebsdgnu
240         HostPlatform_CPP='i386_unknown_kfreebsdgnu'
241         HostArch_CPP='i386'
242         HostVendor_CPP='unknown'
243         HostOS_CPP='kfreebsdgnu'
244         ;;
245 i[[3456]]86-*-freebsd[[3-9]]*) # FreeBSD 3.0+ uses ELF
246         HostPlatform=i386-unknown-freebsd # hack again
247         TargetPlatform=i386-unknown-freebsd
248         BuildPlatform=i386-unknown-freebsd
249         HostPlatform_CPP='i386_unknown_freebsd'
250         HostArch_CPP='i386'
251         HostVendor_CPP='unknown'
252         HostOS_CPP='freebsd'
253         ;;
254 i[[3456]]86-*-freebsd2*) # Older FreeBSDs are a.out
255         HostPlatform=i386-unknown-freebsd2 # hack again
256         TargetPlatform=i386-unknown-freebsd2
257         BuildPlatform=i386-unknown-freebsd2
258         HostPlatform_CPP='i386_unknown_freebsd2'
259         HostArch_CPP='i386'
260         HostVendor_CPP='unknown'
261         HostOS_CPP='freebsd2'
262         ;;
263 i[[3456]]86-*-netbsd*)
264         HostPlatform=i386-unknown-netbsd # hack again
265         TargetPlatform=i386-unknown-netbsd
266         BuildPlatform=i386-unknown-netbsd
267         HostPlatform_CPP='i386_unknown_netbsd'
268         HostArch_CPP='i386'
269         HostVendor_CPP='unknown'
270         HostOS_CPP='netbsd'
271         ;;
272 i[[3456]]86-*-openbsd*)
273         HostPlatform=i386-unknown-openbsd # hack again
274         TargetPlatform=i386-unknown-openbsd
275         BuildPlatform=i386-unknown-openbsd
276         HostPlatform_CPP='i386_unknown_openbsd'
277         HostArch_CPP='i386'
278         HostVendor_CPP='unknown'
279         HostOS_CPP='openbsd'
280         ;;
281 i[[3456]]86-*-solaris2*)
282         HostPlatform=i386-unknown-solaris2 # hack again
283         TargetPlatform=i386-unknown-solaris2
284         BuildPlatform=i386-unknown-solaris2
285         HostPlatform_CPP='i386_unknown_solaris2'
286         HostArch_CPP='i386'
287         HostVendor_CPP='unknown'
288         HostOS_CPP='solaris2'
289         ;;
290 i[[3456]]86-*-cygwin*)
291         HostPlatform=i386-unknown-cygwin32 # hack again
292         TargetPlatform=i386-unknown-cygwin32
293         BuildPlatform=i386-unknown-cygwin32
294         HostPlatform_CPP='i386_unknown_cygwin32'
295         HostArch_CPP='i386'
296         HostVendor_CPP='unknown'
297         HostOS_CPP='cygwin32'
298         exeext='.exe'
299         soext='.dll'
300         ;;
301 i[[3456]]86-*-mingw32*)
302         HostPlatform=i386-unknown-mingw32 # hack again
303         TargetPlatform=i386-unknown-mingw32
304         BuildPlatform=i386-unknown-mingw32
305         HostPlatform_CPP='i386_unknown_mingw32'
306         HostArch_CPP='i386'
307         HostVendor_CPP='unknown'
308         HostOS_CPP='mingw32'
309         exeext='.exe'
310         soext='.dll'
311         ;;
312 i[[3456]]86-apple-darwin*)
313         HostPlatform=i386-apple-darwin
314         TargetPlatform=i386-apple-darwin #hack
315         BuildPlatform=i386-apple-darwin #hack
316         HostPlatform_CPP='i386_apple_darwin'
317         HostArch_CPP='i386'
318         HostVendor_CPP='apple'
319         HostOS_CPP='darwin'
320         soext='.dylib'
321         ;;
322 i[[3456]]86-*-gnu*)
323         HostPlatform=i386-unknown-gnu
324         TargetPlatform=i386-unknown-gnu
325         BuildPlatform=i386-unknown-gnu
326         HostPlatform_CPP=i386_unknown_gnu
327         HostArch_CPP=i386
328         HostVendor_CPP=unknown
329         HostOS_CPP=gnu
330         ;;
331 ia64-*-linux*)
332         HostPlatform=ia64-unknown-linux # hack again
333         TargetPlatform=ia64-unknown-linux
334         BuildPlatform=ia64-unknown-linux
335         HostPlatform_CPP='ia64_unknown_linux'
336         HostArch_CPP='ia64'
337         HostVendor_CPP='unknown'
338         HostOS_CPP='linux'
339         ;;
340 x86_64-*-linux*)
341         HostPlatform=x86_64-unknown-linux
342         TargetPlatform=x86_64-unknown-linux
343         BuildPlatform=x86_64-unknown-linux
344         HostPlatform_CPP='x86_64_unknown_linux'
345         HostArch_CPP='x86_64'
346         HostVendor_CPP='unknown'
347         HostOS_CPP='linux'
348         ;;
349 x86_64-apple-darwin*)
350         HostPlatform=x86_64-apple-darwin
351         TargetPlatform=x86_64-apple-darwin
352         BuildPlatform=x86_64-apple-darwin
353         HostPlatform_CPP='x86_64_apple_darwin'
354         HostArch_CPP='x86_64'
355         HostVendor_CPP='apple'
356         HostOS_CPP='darwin'
357         soext='.dylib'
358         ;;
359 m68k-*-linux*)
360         HostPlatform=m68k-unknown-linux # hack again
361         TargetPlatform=m68k-unknown-linux
362         BuildPlatform=m68k-unknown-linux
363         HostPlatform_CPP='m68k_unknown_linux'
364         HostArch_CPP='m68k'
365         HostVendor_CPP='unknown'
366         HostOS_CPP='linux'
367         ;;
368 m68k-next-nextstep2)
369         HostPlatform_CPP='m68k_next_nextstep2'
370         HostArch_CPP='m68k'
371         HostVendor_CPP='next'
372         HostOS_CPP='nextstep2'
373         ;;
374 m68k-next-nextstep3)
375         HostPlatform_CPP='m68k_next_nextstep3'
376         HostArch_CPP='m68k'
377         HostVendor_CPP='next'
378         HostOS_CPP='nextstep3'
379         ;;
380 i[[3456]]86-next-nextstep3)
381         HostPlatform=i386-next-nextstep3 # hack again
382         TargetPlatform=i386-next-nextstep3
383         BuildPlatform=i386-next-nextstep3
384         HostPlatform_CPP='i386_next_nextstep3'
385         HostArch_CPP='i386'
386         HostVendor_CPP='next'
387         HostOS_CPP='nextstep3'
388         ;;
389 m68k-*-openbsd*)
390         HostPlatform=m68k-unknown-openbsd
391         TargetPlatform=m68k-unknown-openbsd
392         BuildPlatform=m68k-unknown-openbsd
393         HostPlatform_CPP='m68k_unknown_openbsd'
394         HostArch_CPP='m68k'
395         HostVendor_CPP='unknown'
396         HostOS_CPP='openbsd'
397         ;;
398 m68k-*-netbsd*)
399         HostPlatform=m68k-unknown-netbsd
400         TargetPlatform=m68k-unknown-netbsd
401         BuildPlatform=m68k-unknown-netbsd
402         HostPlatform_CPP='m68k_unknown_netbsd'
403         HostArch_CPP='m68k'
404         HostVendor_CPP='unknown'
405         HostOS_CPP='netbsd'
406         ;;
407 m68k-sun-sunos4*)
408         HostPlatform=m68k-sun-sunos4
409         TargetPlatform=m68k-sun-sunos4 #hack
410         BuildPlatform=m68k-sun-sunos4 #hack
411         HostPlatform_CPP='m68k_sun_sunos4'
412         HostArch_CPP='m68k'
413         HostVendor_CPP='sun'
414         HostOS_CPP='sunos4'
415         ;;
416 m88k-*-openbsd*)
417         HostPlatform=m88k-unknown-openbsd
418         TargetPlatform=m88k-unknown-openbsd
419         BuildPlatform=m88k-unknown-openbsd
420         HostPlatform_CPP='m88k_unknown_openbsd'
421         HostArch_CPP='m88k'
422         HostVendor_CPP='unknown'
423         HostOS_CPP='openbsd'
424         ;;
425 mips-*-linux*)
426         HostPlatform=mips-unknown-linux # hack again
427         TargetPlatform=mips-unknown-linux
428         BuildPlatform=mips-unknown-linux
429         HostPlatform_CPP='mips_unknown_linux'
430         HostArch_CPP='mips'
431         HostVendor_CPP='unknown'
432         HostOS_CPP='linux'
433         ;;
434 mipsel-*-linux*)
435         HostPlatform=mipsel-unknown-linux # hack again
436         TargetPlatform=mipsel-unknown-linux
437         BuildPlatform=mipsel-unknown-linux
438         HostPlatform_CPP='mipsel_unknown_linux'
439         HostArch_CPP='mipsel'
440         HostVendor_CPP='unknown'
441         HostOS_CPP='linux'
442         ;;
443 mips-dec-ultrix*)
444         HostPlatform_CPP='mips_dec_ultrix'
445         HostArch_CPP='mipsel'   # NB a little different
446         HostVendor_CPP='dec'
447         HostOS_CPP='ultrix'
448         ;;
449 mips-sgi-irix*)
450         HostPlatform=mips-sgi-irix
451         TargetPlatform=mips-sgi-irix #hack
452         BuildPlatform=mips-sgi-irix #hack
453         HostPlatform_CPP='mips_sgi_irix'
454         HostArch_CPP='mipseb'   # NB a little different
455         HostVendor_CPP='sgi'
456         HostOS_CPP='irix'
457         ;;
458 rs6000-ibm-aix*)
459         HostPlatform=rs6000-ibm-aix
460         TargetPlatform=rs6000-ibm-aix #hack
461         BuildPlatform=rs6000-ibm-aix #hack
462         HostPlatform_CPP='rs6000_ibm_aix'
463         HostArch_CPP='rs6000'
464         HostVendor_CPP='ibm'
465         HostOS_CPP='aix'
466         ;;
467 powerpc-ibm-aix*)
468         HostPlatform=powerpc-ibm-aix
469         TargetPlatform=powerpc-ibm-aix #hack
470         BuildPlatform=powerpc-ibm-aix #hack
471         HostPlatform_CPP='powerpc_ibm_aix'
472         HostArch_CPP='powerpc'
473         HostVendor_CPP='ibm'
474         HostOS_CPP='aix'
475         ;;
476 powerpc-apple-darwin*)
477         HostPlatform=powerpc-apple-darwin
478         TargetPlatform=powerpc-apple-darwin #hack
479         BuildPlatform=powerpc-apple-darwin #hack
480         HostPlatform_CPP='powerpc_apple_darwin'
481         HostArch_CPP='powerpc'
482         HostVendor_CPP='apple'
483         HostOS_CPP='darwin'
484         soext='.dylib'
485         ;;
486 powerpc-unknown-linux*)
487         HostPlatform=powerpc-unknown-linux
488         TargetPlatform=powerpc-unknown-linux
489         BuildPlatform=powerpc-unknown-linux
490         HostPlatform_CPP='powerpc_unknown_linux'
491         HostArch_CPP='powerpc'
492         HostVendor_CPP='unknown'
493         HostOS_CPP='linux'
494         ;;
495 powerpc-unknown-openbsd*)
496         HostPlatform=powerpc-unknown-openbsd
497         TargetPlatform=powerpc-unknown-openbsd
498         BuildPlatform=powerpc-unknown-openbsd
499         HostPlatform_CPP='powerpc_unknown_openbsd'
500         HostArch_CPP='powerpc'
501         HostVendor_CPP='unknown'
502         HostOS_CPP='openbsd'
503         ;;
504 powerpc64-unknown-linux*)
505         HostPlatform=powerpc64-unknown-linux
506         TargetPlatform=powerpc64-unknown-linux
507         BuildPlatform=powerpc64-unknown-linux
508         HostPlatform_CPP='powerpc64_unknown_linux'
509         HostArch_CPP='powerpc64'
510         HostVendor_CPP='unknown'
511         HostOS_CPP='linux'
512         ;;
513
514 s390-ibm-linux*)
515        HostPlatform=s390-ibm-linux
516        TargetPlatform=s390-ibm-linux #hack
517        BuildPlatform=s390-ibm-linux #hack
518         HostPlatform_CPP='s390_ibm_linux'
519         HostArch_CPP='s390'
520         HostVendor_CPP='ibm'
521         HostOS_CPP='linux'
522         ;;
523 sparc-sun-sunos4*)
524         HostPlatform=sparc-sun-sunos4
525         TargetPlatform=sparc-sun-sunos4 #hack
526         BuildPlatform=sparc-sun-sunos4 #hack
527         HostPlatform_CPP='sparc_sun_sunos4'
528         HostArch_CPP='sparc'
529         HostVendor_CPP='sun'
530         HostOS_CPP='sunos4'
531         ;;
532 sparc-sun-solaris2*)
533         HostPlatform=sparc-sun-solaris2
534         TargetPlatform=sparc-sun-solaris2 #hack
535         BuildPlatform=sparc-sun-solaris2 #hack
536         HostPlatform_CPP='sparc_sun_solaris2'
537         HostArch_CPP='sparc'
538         HostVendor_CPP='sun'
539         HostOS_CPP='solaris2'
540         ;;
541 sparc*-linux*)
542         HostPlatform=sparc-unknown-linux
543         TargetPlatform=sparc-unknown-linux
544         BuildPlatform=sparc-unknown-linux
545         HostPlatform_CPP='sparc_unknown_linux'
546         HostArch_CPP='sparc'
547         HostVendor_CPP='unknown'
548         HostOS_CPP='linux'
549         ;;
550 sparc-*-openbsd*)
551         HostPlatform=sparc-unknown-openbsd
552         TargetPlatform=sparc-unknown-openbsd
553         BuildPlatform=sparc-unknown-openbsd
554         HostPlatform_CPP='sparc_unknown_openbsd'
555         HostArch_CPP='sparc'
556         HostVendor_CPP='unknown'
557         HostOS_CPP='openbsd'
558         ;;
559 sparc64-*-openbsd*)
560         HostPlatform=sparc64-unknown-openbsd
561         TargetPlatform=sparc64-unknown-openbsd
562         BuildPlatform=sparc64-unknown-openbsd
563         HostPlatform_CPP='sparc64_unknown_openbsd'
564         HostArch_CPP='sparc64'
565         HostVendor_CPP='unknown'
566         HostOS_CPP='openbsd'
567         ;;
568 vax-*-openbsd*)
569         HostPlatform=vax-unknown-openbsd
570         TargetPlatform=vax-unknown-openbsd
571         BuildPlatform=vax-unknown-openbsd
572         HostPlatform_CPP='vax_unknown_openbsd'
573         HostArch_CPP='vax'
574         HostVendor_CPP='unknown'
575         HostOS_CPP='openbsd'
576         ;;
577 *)
578         echo "Unrecognised platform: $HostPlatform"
579         exit 1
580         ;;
581 esac
582 echo "Canonicalised to: $HostPlatform"
583 test  x"$HostPlatform" != x"$TargetPlatform" && echo "Target platform set to $TargetPlatform"
584 test  x"$BuildPlatform" != x"$HostPlatform"  && echo "Build platform set to $BuildPlatform"
585
586 BuildPlatform_CPP=$HostPlatform_CPP
587 TargetPlatform_CPP=$HostPlatform_CPP
588 BuildArch_CPP=$HostArch_CPP
589 TargetArch_CPP=$HostArch_CPP
590 BuildOS_CPP=$HostOS_CPP
591 HostOS_Full=$host_os
592 TargetOS_CPP=$HostOS_CPP
593 BuildVendor_CPP=$HostVendor_CPP
594 TargetVendor_CPP=$HostVendor_CPP
595
596 AC_SUBST(BuildPlatform)
597 AC_SUBST(HostPlatform)
598 AC_SUBST(TargetPlatform)
599 AC_SUBST(HostPlatform_CPP)
600 AC_SUBST(BuildPlatform_CPP)
601 AC_SUBST(TargetPlatform_CPP)
602
603 AC_SUBST(HostArch_CPP)
604 AC_SUBST(BuildArch_CPP)
605 AC_SUBST(TargetArch_CPP)
606
607 AC_SUBST(HostOS_CPP)
608 AC_SUBST(HostOS_Full)
609 AC_SUBST(BuildOS_CPP)
610 AC_SUBST(TargetOS_CPP)
611
612 AC_SUBST(HostVendor_CPP)
613 AC_SUBST(BuildVendor_CPP)
614 AC_SUBST(TargetVendor_CPP)
615
616 AC_SUBST(exeext)
617 AC_SUBST(soext)
618
619 dnl --------------------------------------------------------------
620 dnl * Project specific configuration options
621 dnl --------------------------------------------------------------
622 dnl What follows is a bunch of options that can either be configured
623 dnl through command line options to the configure script or by
624 dnl supplying defns in the build tree's mk/build.mk. Having the option to
625 dnl use either is considered a Feature.
626
627 dnl ** What command to use to compile compiler sources ?
628 dnl --------------------------------------------------------------
629
630 AC_ARG_WITH([ghc],
631 [AC_HELP_STRING([--with-ghc=ARG],
632   [Use ARG as the path to GHC  [default=autodetect]])],
633   [WithGhc="$withval"],
634   [if test "$GHC" = ""; then
635     AC_PATH_PROG([GHC], [ghc])
636   fi
637   WithGhc="$GHC"])
638 AC_SUBST([WithGhc])
639
640 AC_ARG_WITH(hc,
641 [AC_HELP_STRING([--with-hc=ARG],
642         [Use ARG as the path to the compiler for compiling ordinary
643          Haskell code  (default= value of --with-ghc)])],
644 [WithHc="$withval"],
645 [WithHc=$WithGhc]
646 )
647 AC_SUBST(WithHc)
648
649 if test "$WithGhc" != ""; then
650   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
651   AC_SUBST(GhcVersion)dnl
652   AC_SUBST(GhcMajVersion)dnl
653   AC_SUBST(GhcMinVersion)dnl
654   AC_SUBST(GhcPatchLevel)dnl
655   GhcMinVersion2=`echo "$GhcMinVersion" | sed 's/^\\(.\\)$/0\\1/'`
656   GhcCanonVersion="$GhcMajVersion$GhcMinVersion2"
657   if test $GhcCanonVersion -ge 605; then ghc_ge_605=YES; else ghc_ge_605=NO; fi
658   if test $GhcCanonVersion -ge 607; then ghc_ge_607=YES; else ghc_ge_607=NO; fi
659   AC_SUBST(ghc_ge_605)dnl
660   AC_SUBST(ghc_ge_607)dnl
661 fi
662
663 # Check whether this GHC has readline installed
664 FP_GHC_HAS_READLINE
665
666 AC_PATH_PROGS(NHC,nhc nhc98)
667 AC_PATH_PROG(HBC,hbc)
668
669 dnl ** Which gcc to use?
670 dnl --------------------------------------------------------------
671 AC_ARG_WITH(gcc,
672 [AC_HELP_STRING([--with-gcc=ARG],
673         [Use ARG as the path to GCC  [default=autodetect]])],
674 [WhatGccIsCalled="$withval"
675  if test "x$HostPlatform" = "xi386-unknown-mingw32"
676     then
677        if test "${OSTYPE}" != "msys"
678          then
679          # Canonicalise to <drive>:/path/to/gcc
680          withval=`cygpath -w ${withval} | sed -e 's@\\\\@/@g' `
681        fi
682  fi;
683  CC="$withval"
684  export CC
685  ],
686 [WhatGccIsCalled="gcc"]
687 )
688 AC_SUBST(WhatGccIsCalled)
689
690 dnl ** Which ld to use?
691 dnl --------------------------------------------------------------
692 AC_ARG_WITH(ld,
693 [AC_HELP_STRING([--with-ld=ARG],
694         [Use ARG as the path to LD  [default=autodetect]])],
695 [if test "x$HostPlatform" = "xi386-unknown-mingw32"
696     then
697        if test "${OSTYPE}" != "msys"
698          then
699          # Canonicalise to <drive>:/path/to/ld
700          withval=`cygpath -w ${withval} | sed -e 's@\\\\@/@g' `
701        fi
702  fi;
703  LD=$withval
704  FP_PROG_LD([$LD])
705  ],
706  [FP_PROG_LD()]
707 )
708
709 dnl ** Booting from .hc files?
710 dnl --------------------------------------------------------------
711 AC_ARG_ENABLE(hc-boot,
712 [AC_HELP_STRING([--enable-hc-boot],
713 [Boot the Glasgow Haskell Compiler from intermediate .hc files.
714  (This option is mostly of interest to porters.) [default=no]])],
715 [ if test x"$enableval" = x"yes"; then
716         BootingFromHc=YES
717   else
718         BootingFromHc=NO
719   fi
720 ],
721 [BootingFromHc=NO]
722 )
723 AC_SUBST(BootingFromHc)
724
725 dnl ** Booting from unregisterised .hc files?
726 dnl --------------------------------------------------------------
727 AC_ARG_ENABLE(hc-boot-unregisterised,
728 [AC_HELP_STRING([--enable-hc-boot-unregisterised],
729 [ With --enable-hc-boot, treat the intermediate .hc files as
730  unregisterised rather than registerised code.
731  (This option is mostly of interest to porters.) [default=no]])],
732 [ if test x"$enableval" = x"yes"; then
733         BootingFromUnregisterisedHc=YES
734   else
735         BootingFromUnregisterisedHc=NO
736   fi
737 ],
738 [BootingFromUnregisterisedHc=NO]
739 )
740 AC_SUBST(BootingFromUnregisterisedHc)
741
742 if test "$BootingFromHc" = "NO"; then
743 if test "$BootingFromUnregisterisedHc" = "YES"; then
744 AC_MSG_ERROR([--enable-hc-boot-unregisterised requires --enable-hc-boot.])
745 fi;
746 fi;
747
748 dnl ** Must have GHC to build GHC, unless --enable-hc-boot is on
749 if test "$BootingFromHc" = "NO" -a -d "$srcdir/compiler"; then
750   if test "$WithGhc" = ""; then
751      AC_MSG_ERROR([GHC is required unless bootstrapping from .hc files.])
752   fi
753   FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[6.4],
754     [AC_MSG_ERROR([GHC version 6.4 or later is required to compile GHC.])])dnl
755 fi;
756
757 # This uses GHC, so put it after the "GHC is required" check above:
758 FP_FIND_ROOT
759
760 dnl ** Enable the construction of Win32 DLLs?
761 dnl --------------------------------------------------------------
762 dnl
763 dnl [ The ability to build the RTS and libraries as separate DLLs used
764 dnl   to be supported, but isn't currently (updates to the RTS, compiler
765 dnl   and build system would be required to bring it back again.)
766 dnl   Hence, exposing it as an option is false advertisement, so better
767 dnl   disable it to avoid confusion (but leave it commented-out rather
768 dnl   than removed in order to remind ourselves to bring back the
769 dnl   feature at some stage.) ]
770 dnl
771 dnl AC_ARG_ENABLE(win32-dlls,
772 dnl [  --enable-win32-dlls
773 dnl         If on a Win32 platform running mingw32/cygwin, enable the
774 dnl         construction of DLLs containing ghc-compiled code.
775 dnl ],
776 dnl [
777 dnl case $HostOS_CPP in
778 dnl cygwin32) ;;
779 dnl mingw32)  ;;
780 dnl *)    echo "Unrecognised win32 platform: $HostPlatform"
781 dnl       exit 1
782 dnl       ;;
783 dnl esac
784 dnl EnableWin32DLLs=YES
785 dnl ],
786 dnl [EnableWin32DLLs=NO]
787 dnl )
788 dnl AC_SUBST(EnableWin32DLLs)
789 dnl if test x"$EnableWin32DLLs" = "xYES" ; then
790 dnl  AC_DEFINE(HAVE_WIN32_DLL_SUPPORT)
791 dnl fi
792
793 dnl ** Enable the building of the ObjectIO?
794 dnl --------------------------------------------------------------
795 AC_ARG_ENABLE(objectio,
796 [AC_HELP_STRING([--enable-objectio],
797 [Build ObjectIO, a portable GUI library for Haskell. [default=no]])],
798 [ if test x"$enableval" = x"yes"; then
799         GhcLibsWithObjectIO=YES
800   else
801         GhcLibsWithObjectIO=NO
802   fi
803 ],
804 [GhcLibsWithObjectIO=NO]
805 )
806 AC_SUBST(GhcLibsWithObjectIO)
807
808 dnl ** .NET interop support?
809 dnl --------------------------------------------------------------
810 AC_ARG_ENABLE(dotnet,
811 [AC_HELP_STRING([--enable-dotnet],
812 [Build .NET interop layer. [default=no]])],
813 [ if test x"$enableval" = x"yes"; then
814         DotnetSupport=YES; AC_DEFINE([WANT_DOTNET_SUPPORT], [1], [Define to 1 if you want to include .NET interop support.])
815   else
816         DotnetSupport=NO
817   fi],
818 [DotnetSupport=NO]
819 )
820 AC_SUBST(DotnetSupport)
821
822 dnl ** Mac OS X: explicit deployment target
823 dnl --------------------------------------------------------------
824 AC_ARG_WITH([macos-deployment-target],
825 [AC_HELP_STRING([--macos-deployment-target=VERSION],
826         [Build for Mac OS VERSION and higher  [default= version of build host]])],
827 [MACOS_DEPLOYMENT_TARGET="$withval"
828  if test "x$TargetOS_CPP-$TargetVendor_CPP" != "xdarwin-apple"; then
829    # ignore everywhere, but on Mac OS
830    AC_MSG_WARN([--macos-deployment-target is only available on Mac OS X])
831    MACOS_DEPLOYMENT_TARGET=none
832  fi],
833 [MACOS_DEPLOYMENT_TARGET=none]
834 )
835 FP_MACOS_DEPLOYMENT_TARGET
836 AC_SUBST(MACOS_DEPLOYMENT_VERSION)
837 AC_SUBST(MACOS_DEPLOYMENT_SDK)
838
839 dnl --------------------------------------------------------------
840 dnl End of configure script option section
841 dnl --------------------------------------------------------------
842
843
844 dnl --------------------------------------------------------------
845 dnl * General configuration checks
846 dnl --------------------------------------------------------------
847
848 dnl ** Can the unix package be built?
849 dnl --------------------------------------------------------------
850
851 if test x"$TargetPlatform" = x"i386-unknown-mingw32"; then
852    GhcLibsWithUnix=NO
853 else
854    GhcLibsWithUnix=YES
855 fi
856 AC_SUBST([GhcLibsWithUnix])
857
858 dnl ** does #! work?
859 AC_SYS_INTERPRETER()
860
861 dnl ** look for `perl', but only in /bin on Windows
862 case $HostOS_CPP in
863 cygwin32|mingw32)
864       AC_CHECK_PROG(PerlCmd,perl,/bin/perl,,/bin)
865       if test -z "$PerlCmd"; then
866          echo "You must install the version of Perl shipped with GHC"
867          echo "(or a compatible one) in /bin."
868          exit 1
869       fi
870    ;;
871 *)
872    AC_PATH_PROG(PerlCmd,perl)
873    if test -z "$PerlCmd"; then
874       echo "You must install perl before you can continue"
875       echo "Perhaps it is already installed, but not in your PATH?"
876       exit 1
877    else
878    FPTOOLS_CHECK_PERL_VERSION
879    fi
880    ;;
881 esac
882
883 dnl ** does #! path/to/perl work? (sometimes it's too long...)
884 FPTOOLS_SHEBANG_PERL
885
886 dnl ** check for Python
887 AC_PATH_PROG(PythonCmd,python)
888
889 dnl ** look for GCC and find out which version
890 dnl     Figure out which C compiler to use.  Gcc is preferred.
891 dnl     If gcc, make sure it's at least 2.1
892 dnl
893 FP_HAVE_GCC
894 FP_MINGW_GCC
895 FP_GCC_EXTRA_FLAGS
896
897 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
898 AC_PROG_CPP
899
900 dnl ** Without optimization some INLINE trickery fails for GHCi
901 SRC_CC_OPTS="-O"
902
903 dnl ** Try to add -mno-cygwin to the C compiler options
904 FP_CHECK_FLAG([-mno-cygwin], [
905 SRC_CC_OPTS="-mno-cygwin $SRC_CC_OPTS"
906 CPPFLAGS="-mno-cygwin $CPPFLAGS"])
907 AC_SUBST(SRC_CC_OPTS)
908
909 dnl ** figure out how to do context diffs
910 FP_PROG_CONTEXT_DIFF
911
912 dnl ** Find find command (for Win32's benefit)
913 FP_PROG_FIND
914
915 dnl ** Find sort command (for the benefit of Win32 environs)
916 FP_PROG_SORT
917
918 dnl Let's make sure install-sh is executable here.  If we got it from
919 dnl a darcs repo, it might not be (see bug #978).
920 chmod +x install-sh
921 dnl ** figure out how to do a BSD-ish install
922 AC_PROG_INSTALL
923
924 dnl If you can run configure, you certainly have /bin/sh
925 AC_DEFINE([HAVE_BIN_SH], [1], [Define to 1 if you have /bin/sh.])
926
927 dnl ** how to invoke `ar' and `ranlib'
928 FP_PROG_AR_NEEDS_RANLIB
929 FP_PROG_AR_SUPPORTS_INPUT
930
931 dnl ** Check to see whether ln -s works
932 AC_PROG_LN_S
933
934
935 dnl ** Find the path to sed
936 AC_PATH_PROG(SedCmd,sed)
937
938
939 dnl ** check for time command
940 AC_PATH_PROG(TimeCmd,time)
941
942 dnl ** check for tar
943 dnl   if GNU tar is named gtar, look for it first.
944 AC_PATH_PROGS(TarCmd,gtar tar,tar)
945
946 AC_PATH_PROG(HSCOLOUR,HsColour)
947 # HsColour is passed to Cabal, so we need a native path
948 if test "x$HostPlatform" = "xi386-unknown-mingw32"
949     then
950        if test "${OSTYPE}" != "msys"
951          then
952          # Canonicalise to <drive>:/path/to/gcc
953          HSCOLOUR=`cygpath -w ${HSCOLOUR} | sed -e 's@\\\\@/@g' `
954        fi
955 fi
956
957 dnl ** check for DocBook toolchain
958 FP_CHECK_DOCBOOK_DTD
959 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])
960 FP_PROG_FO_PROCESSOR
961
962 dnl ** check for ghc-pkg command
963 FP_PROG_GHC_PKG
964
965 AC_ARG_WITH(greencard,
966 [AC_HELP_STRING([--with-greencard=ARG],
967         [Use ARG as the path to greencard  [default=autodetct]])],
968 [
969 GreenCardCmd=$withval;
970 FPTOOLS_GREENCARD(3.00)
971 ]
972 )
973
974 dnl ** check for installed happy binary + version
975 dnl    (don't do it if we're booting from .hc files though.)
976 if test "$BootingFromHc" = "NO"; then
977 FPTOOLS_HAPPY
978 fi;
979
980 dnl ** check for installed haddock
981 FPTOOLS_HADDOCK
982
983 dnl ** check for installed alex binary + version
984 dnl    (don't do it if we're booting from .hc files though.)
985 if test "$BootingFromHc" = "NO"; then
986 FPTOOLS_ALEX
987 fi;
988
989 dnl --------------------------------------------------
990 dnl ### program checking section ends here ###
991 dnl --------------------------------------------------
992
993 dnl --------------------------------------------------
994 dnl * Platform header file and syscall feature tests
995 dnl ### checking the state of the local header files and syscalls ###
996
997 dnl ** check for full ANSI header (.h) files
998 AC_HEADER_STDC
999
1000 dnl ** Enable large file support.  NB. do this before testing the type of
1001 dnl    off_t, because it will affect the result of that test.
1002 AC_SYS_LARGEFILE
1003
1004 dnl ** check for specific header (.h) files that we are interested in
1005 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])
1006
1007 AC_CHECK_HEADER([readline/readline.h], [HaveReadlineReadlineH=YES], [HaveReadlineReadlineH=NO])
1008 AC_CHECK_HEADER([readline/history.h], [HaveReadlineHistoryH=YES], [HaveReadlineHistoryH=NO])
1009
1010 if test $HaveReadlineReadlineH = YES && test $HaveReadlineHistoryH = YES ; then
1011   GhcLibsWithReadline=YES
1012   AC_DEFINE([HAVE_READLINE_HEADERS], [1], [Define to 1 if readline/readline.h and readline/history.h exist.])
1013 else
1014   GhcLibsWithReadline=NO
1015   AC_DEFINE([HAVE_READLINE_HEADERS], [0], [Define to 1 if readline/readline.h and readline/history.h exist.])
1016 fi
1017 AC_SUBST(GhcLibsWithReadline)
1018
1019 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
1020 AC_HEADER_TIME
1021
1022 dnl ** do we have long longs?
1023 AC_CHECK_TYPES([long long])
1024
1025 dnl ** what are the sizes of various types
1026 AC_CHECK_SIZEOF(char,               1)
1027 AC_CHECK_SIZEOF(double,             8)
1028 AC_CHECK_SIZEOF(float,              4)
1029 AC_CHECK_SIZEOF(int,                4)
1030 AC_CHECK_SIZEOF(long,               4)
1031 if test "$ac_cv_type_long_long" = yes; then
1032 AC_CHECK_SIZEOF(long long,          8)
1033 fi
1034 AC_CHECK_SIZEOF(short,              2)
1035 AC_CHECK_SIZEOF(unsigned char,      1)
1036 AC_CHECK_SIZEOF(unsigned int,       4)
1037 AC_CHECK_SIZEOF(unsigned long,      4)
1038 if test "$ac_cv_type_long_long" = yes; then
1039 AC_CHECK_SIZEOF(unsigned long long, 8)
1040 fi
1041 AC_CHECK_SIZEOF(unsigned short,     2)
1042 AC_CHECK_SIZEOF(void *,             4)
1043
1044 dnl ** what are alignment constraints on various types
1045 FP_CHECK_ALIGNMENT(char)
1046 FP_CHECK_ALIGNMENT(double)
1047 FP_CHECK_ALIGNMENT(float)
1048 FP_CHECK_ALIGNMENT(int)
1049 FP_CHECK_ALIGNMENT(long)
1050 if test "$ac_cv_type_long_long" = yes; then
1051 FP_CHECK_ALIGNMENT(long long)
1052 fi
1053 FP_CHECK_ALIGNMENT(short)
1054 FP_CHECK_ALIGNMENT(unsigned char)
1055 FP_CHECK_ALIGNMENT(unsigned int)
1056 FP_CHECK_ALIGNMENT(unsigned long)
1057 if test "$ac_cv_type_long_long" = yes; then
1058 FP_CHECK_ALIGNMENT(unsigned long long)
1059 fi
1060 FP_CHECK_ALIGNMENT(unsigned short)
1061 FP_CHECK_ALIGNMENT(void *)
1062
1063 FP_CHECK_FUNC([WinExec],
1064   [@%:@include <windows.h>], [WinExec("",0)])
1065
1066 FP_CHECK_FUNC([GetModuleFileName],
1067   [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
1068
1069 dnl ** check return type of signal handlers
1070 dnl Foo: assumes we can use prototypes.
1071 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
1072 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
1073 dnl [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1074 dnl #include <signal.h>
1075 dnl #ifdef signal
1076 dnl #undef signal
1077 dnl #endif
1078 dnl void (*signal (int, void (*)(int)))(int);
1079 dnl ]],
1080 dnl [[int i;]])],
1081 dnl [ac_cv_type_signal_handler=void_int],
1082 dnl [ac_cv_type_signal_handler=int_void])])
1083 dnl if test "$ac_cv_type_signal_handler" = void_int; then
1084 dnl AC_DEFINE(VOID_INT_SIGNALS)
1085 dnl fi
1086
1087 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
1088 AC_TYPE_SIGNAL
1089 if test "$ac_cv_type_signal" = void; then
1090   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).])
1091 fi
1092
1093 dnl ** check for more functions
1094 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
1095 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r])
1096 dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
1097 dnl ** _POSIX_C_SOURCE is defined
1098 AC_CHECK_DECLS([ctime_r], , ,
1099 [#define _POSIX_SOURCE 1
1100 #define _POSIX_C_SOURCE 199506L
1101 #include <time.h>])
1102
1103 dnl ** For ghc/rts/gmp:
1104 AC_CHECK_FUNCS([getpagesize])
1105
1106 dnl ** check whether this machine has gmp3 installed
1107 AC_CHECK_LIB(gmp,  __gmpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
1108   AC_CHECK_LIB(gmp3, __gmpz_fdiv_qr,  HaveLibGmp=YES; LibGmp=gmp3,
1109     HaveLibGmp=NO; LibGmp=not-installed))
1110   if test $HaveLibGmp = YES; then
1111     AC_DEFINE([HAVE_LIB_GMP], [1], [Define to 1 if GMP library is installed.])
1112   fi;
1113 AC_SUBST(HaveLibGmp)
1114 AC_SUBST(LibGmp)
1115
1116 dnl ** (Mac OS X only: check for GMP.framework)
1117 HaveFrameworkGMP=NO
1118 case $HostPlatform in
1119 *-apple-darwin)
1120     AC_MSG_CHECKING([for GMP.framework])
1121     save_libs="$LIBS"
1122     LIBS="-framework GMP"
1123     AC_TRY_LINK_FUNC(__gmpz_fdiv_qr, HaveFrameworkGMP=YES,)
1124     if test $HaveFrameworkGMP = YES; then
1125       AC_DEFINE([HAVE_FRAMEWORK_GMP], [1], [Define to 1 if GMP.framework is installed (Mac OS X only).])
1126     fi;
1127     LIBS="$save_libs"
1128     AC_MSG_RESULT([$HaveFrameworkGMP])
1129     ;;
1130 esac
1131 AC_SUBST(HaveFrameworkGMP)
1132
1133 dnl ** check for mingwex library
1134 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
1135 AC_SUBST(HaveLibMingwEx)
1136
1137 if test $HaveLibMingwEx = YES ; then
1138   AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
1139 fi
1140
1141 if test "$HaveLibGmp" = "NO"; then
1142 if test "$HostArch_CPP" = "ia64" -o "$HostArch_CPP" = "mipseb" ; then
1143 AC_MSG_ERROR([You need to install libgmp (the in-tree version does not work on IA64 or mips64).])
1144 fi;
1145 fi;
1146
1147 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
1148 dnl    the order of these tests matters: bfd needs liberty
1149 AC_CHECK_LIB(iberty, xmalloc)
1150 AC_CHECK_LIB(bfd,    bfd_init)
1151
1152 dnl ** check for math library
1153 AC_CHECK_FUNC(atan,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
1154 if test x"$fp_libm_not_needed" = xdunno; then
1155    AC_CHECK_LIB([m], [atan], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
1156 fi
1157 AC_SUBST([LIBM])
1158
1159 dnl ################################################################
1160 dnl Check for libraries
1161 dnl ################################################################
1162
1163 dnl ** check whether we need -ldl to get dlopen()
1164
1165 AC_CHECK_LIB(dl, dlopen,
1166     [HaveLibDL=YES
1167      AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if you need -ldl to get dlopen().])
1168      LIBS="$LIBS -ldl"],
1169     [HaveLibDL=NO])
1170 AC_SUBST(HaveLibDL)
1171
1172 dnl --------------------------------------------------
1173 dnl * Miscellaneous feature tests
1174 dnl --------------------------------------------------
1175
1176 dnl ** can we get alloca?
1177 AC_FUNC_ALLOCA
1178
1179 dnl ** Working vfork?
1180 AC_FUNC_FORK
1181
1182 dnl ** determine whether or not const works
1183 AC_C_CONST
1184
1185 dnl ** are we big endian?
1186 AC_C_BIGENDIAN
1187 FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
1188
1189 dnl ** check for leading underscores in symbol names
1190 FP_LEADING_UNDERSCORE
1191
1192 dnl ** check for ld, whether it has an -x option, and if it is GNU ld
1193 FP_PROG_LD_X
1194 FP_PROG_LD_IS_GNU
1195
1196 dnl ** check for Apple-style dead-stripping support
1197 dnl    (.subsections-via-symbols assembler directive)
1198
1199
1200 AC_MSG_CHECKING(for .subsections_via_symbols)
1201 AC_COMPILE_IFELSE(
1202     [AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
1203     [AC_MSG_RESULT(yes)
1204      AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
1205                [Define to 1 if Apple-style dead-stripping is supported.])
1206     ],
1207     [AC_MSG_RESULT(no)])
1208
1209 dnl *** check for GNU non-executable stack note support (ELF only)
1210 dnl     (.section .note.GNU-stack,"",@progbits)
1211
1212 AC_MSG_CHECKING(for GNU non-executable stack support)
1213 AC_COMPILE_IFELSE(
1214     [AC_LANG_PROGRAM([__asm__ (".section .note.GNU-stack,\"\",@progbits");], [0])],
1215     [AC_MSG_RESULT(yes)
1216      AC_DEFINE([HAVE_GNU_NONEXEC_STACK],[1],
1217                [Define to 1 if GNU non-executable stack notes are supported.])
1218     ],
1219     [AC_MSG_RESULT(no)])
1220
1221 dnl ** check for librt
1222 AC_CHECK_LIB(rt, clock_gettime)
1223 AC_CHECK_FUNCS(clock_gettime timer_create timer_settime)
1224 FP_CHECK_TIMER_CREATE
1225
1226 dnl ** check for Apple's "interesting" long double compatibility scheme
1227 AC_MSG_CHECKING(for printf\$LDBLStub)
1228 AC_TRY_LINK_FUNC(printf\$LDBLStub,
1229     [
1230         AC_MSG_RESULT(yes)
1231         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
1232             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
1233     ],
1234     [
1235         AC_MSG_RESULT(no)
1236         AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
1237             [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
1238     ])
1239
1240 # test for GTK+
1241 AC_PATH_PROGS([GTK_CONFIG], [pkg-config])
1242 if test -n "$GTK_CONFIG"; then
1243   if $GTK_CONFIG gtk+-2.0 --atleast-version=2.0; then
1244     GTK_CONFIG="$GTK_CONFIG gtk+-2.0"
1245   else
1246     AC_MSG_WARN([GTK+ not usable, need at least version 2.0])
1247     GTK_CONFIG=
1248   fi
1249 fi
1250 AC_SUBST([GTK_CONFIG])
1251
1252 #Checking for PAPI
1253 AC_CHECK_LIB(papi, PAPI_library_init, HavePapiLib=YES, HavePapiLib=NO)
1254 AC_CHECK_HEADER([papi.h], [HavePapiHeader=YES], [HavePapiHeader=NO])
1255 AC_SUBST(HavePapiLib)
1256 AC_SUBST(HavePapiHeader)
1257
1258 if test "$HavePapiLib" = "YES" -a "$HavePapiHeader" = "YES"; then
1259    HavePapi=YES
1260 else
1261    HavePapi=NO
1262 fi
1263 AC_SUBST(HavePapi)
1264
1265 AC_CONFIG_FILES([mk/config.mk ghc.spec extra-gcc-opts docs/users_guide/ug-book.xml])
1266 AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp > mk/stamp-h])
1267 AC_OUTPUT