[project @ 2004-11-18 16:39:53 by stolz]
[ghc-hetmet.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 AQUA Project, Glasgow University, 1994-2004
7 #
8 # Configure script template for the Glasgow functional programming tools
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([fptools build system], [1.0], [cvs-fptools@haskell.org], [fptools])
17
18 # First off, a distrib sanity check..
19 AC_CONFIG_SRCDIR([mk/config.mk.in])
20
21 dnl * We require autoconf version 2.52
22 dnl We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE.
23 dnl We need 2.52 due to the use of AS_TR_CPP and AS_TR_SH.
24 AC_PREREQ([2.52])
25
26 dnl * Declare subdirectories that have a private configure script
27 dnl
28 dnl After the toplevel configuration is complete, the script will recurse into
29 dnl these subdirectories if they exist. The use of a cache file makes repeated
30 dnl checks cheap.
31 AC_CONFIG_SUBDIRS([ghc libraries])
32
33 # -------------------------------------------------------------------------
34 # Prepare to generate the following header files
35 #
36 #
37 AC_CONFIG_HEADER(mk/config.h)
38
39 # No, semi-sadly, we don't do `--srcdir'...
40 if test x"$srcdir" != 'x.' ; then
41     echo "This configuration does not support the \`--srcdir' option.."
42     exit 1
43 fi
44
45 dnl--------------------------------------------------------------------
46 dnl * Choose host(/target/build) platform
47 dnl--------------------------------------------------------------------
48
49 dnl Guess host/target/build platform(s) if necessary.
50 AC_CANONICAL_TARGET
51
52 # "$host" defaults to "$target"
53 if test "x$host" = xNONE ; then
54     host=$target
55 fi
56
57 dnl ** canonicalize platform names
58 BuildPlatform=`/bin/sh $srcdir/config.sub $build` || exit 1
59 HostPlatform=`/bin/sh $srcdir/config.sub $host` || exit 1
60 TargetPlatform=`/bin/sh $srcdir/config.sub $target` || exit 1
61
62 if test x"$TargetPlatform" != x"$HostPlatform" ; then
63     echo "GHC configuration does not support differing host/target (i.e., cross-compiling)"
64     exit 1
65 fi
66
67 exeext=''
68 #
69 # The following will be more difficult when we *are* cross-compiling.
70 # Suitable names to slam in *_CPP are in platform.h.in.
71 # We also record the architecture, vendor, and operating system (OS)
72 # separately.
73 case $HostPlatform in
74 alpha*-dec-osf[[12]]*)
75         HostPlatform=alpha-dec-osf1   # canonicalise for our purposes
76         TargetPlatform=alpha-dec-osf1 # this will work for now... (hack)
77         BuildPlatform=alpha-dec-osf1  # hack
78         HostPlatform_CPP='alpha_dec_osf1'
79         HostArch_CPP='alpha'
80         HostVendor_CPP='dec'
81         HostOS_CPP='osf1'
82         ;;
83 alpha*-dec-osf[[345]]*)
84         HostPlatform=alpha-dec-osf3   # canonicalise for our purposes
85         TargetPlatform=alpha-dec-osf3 # this will work for now... (hack)
86         BuildPlatform=alpha-dec-osf3  # hack
87         HostPlatform_CPP='alpha_dec_osf3'
88         HostArch_CPP='alpha'
89         HostVendor_CPP='dec'
90         HostOS_CPP='osf3'
91         ;;
92 alpha*-unknown-linux*)
93         HostPlatform=alpha-unknown-linux
94         TargetPlatform=alpha-unknown-linux
95         BuildPlatform=alpha-unknown-linux
96         HostPlatform_CPP='alpha_unknown_linux'
97         HostArch_CPP='alpha'
98         HostVendor_CPP='unknown'
99         HostOS_CPP='linux'
100         ;;
101 alpha*-unknown-freebsd*)
102         HostPlatform=alpha-unknown-freebsd
103         TargetPlatform=alpha-unknown-freebsd
104         BuildPlatform=alpha-unknown-freebsd
105         HostPlatform_CPP='alpha_unknown_freebsd'
106         HostArch_CPP='alpha'
107         HostVendor_CPP='unknown'
108         HostOS_CPP='freebsd'
109         ;;
110 alpha*-unknown-openbsd*)
111         HostPlatform=alpha-unknown-openbsd
112         TargetPlatform=alpha-unknown-openbsd
113         BuildPlatform=alpha-unknown-openbsd
114         HostPlatform_CPP='alpha_unknown_openbsd'
115         HostArch_CPP='alpha'
116         HostVendor_CPP='unknown'
117         HostOS_CPP='openbsd'
118         ;;
119 amd64-*-openbsd*|x86_64-*-openbsd*)
120         HostPlatform=x86_64-unknown-openbsd
121         TargetPlatform=x86_64-unknown-openbsd
122         BuildPlatform=x86_64-unknown-openbsd
123         HostPlatform_CPP='x86_64_unknown_openbsd'
124         HostArch_CPP='x86_64'
125         HostVendor_CPP='unknown'
126         HostOS_CPP='openbsd'
127         ;;
128 arm*-linux*)
129         HostPlatform=arm-unknown-linux # hack again
130         TargetPlatform=arm-unknown-linux
131         BuildPlatform=arm-unknown-linux
132         HostPlatform_CPP='arm_unknown_linux'                 
133         HostArch_CPP='arm'
134         HostVendor_CPP='unknown'
135         HostOS_CPP='linux'
136         ;;
137 arm*-openbsd*)
138         HostPlatform=arm-unknown-openbsd
139         TargetPlatform=arm-unknown-openbsd
140         BuildPlatform=arm-unknown-openbsd
141         HostPlatform_CPP='arm_unknown_openbsd'                 
142         HostArch_CPP='arm'
143         HostVendor_CPP='unknown'
144         HostOS_CPP='openbsd'
145         ;;
146 hppa*-*-linux*)
147         HostPlatform=hppa-unknown-linux # hack again
148         TargetPlatform=hppa-unknown-linux
149         BuildPlatform=hppa-unknown-linux
150         HostPlatform_CPP='hppa_unknown_linux'                
151         HostArch_CPP='hppa'
152         HostVendor_CPP='unknown'                             
153         HostOS_CPP='linux'
154         ;;
155 hppa*-*-openbsd*)
156         HostPlatform=hppa-unknown-openbsd # hack again
157         TargetPlatform=hppa-unknown-openbsd
158         BuildPlatform=hppa-unknown-openbsd
159         HostPlatform_CPP='hppa_unknown_openbsd'                
160         HostArch_CPP='hppa'
161         HostVendor_CPP='unknown'                             
162         HostOS_CPP='openbsd'
163         ;;
164 hppa1.1-hp-hpux*)
165         HostPlatform=hppa1.1-hp-hpux  # canonicalise for our purposes (hack)
166         TargetPlatform=hppa1.1-hp-hpux
167         BuildPlatform=hppa1.1-hp-hpux
168         HostPlatform_CPP='hppa1_1_hp_hpux'
169         HostArch_CPP='hppa1_1'
170         HostVendor_CPP='hp'
171         HostOS_CPP='hpux'
172         ;;
173 i[[3456]]86-*-linuxaout*)
174         HostPlatform=i386-unknown-linuxaout   # hack again
175         TargetPlatform=i386-unknown-linuxaout
176         BuildPlatform=i386-unknown-linuxaout
177         HostPlatform_CPP='i386_unknown_linuxaout'
178         HostArch_CPP='i386'
179         HostVendor_CPP='unknown'
180         HostOS_CPP='linuxaout'
181         ;;
182 i[[3456]]86-*-linux*)
183         HostPlatform=i386-unknown-linux # hack again
184         TargetPlatform=i386-unknown-linux
185         BuildPlatform=i386-unknown-linux
186         HostPlatform_CPP='i386_unknown_linux'
187         HostArch_CPP='i386'
188         HostVendor_CPP='unknown'
189         HostOS_CPP='linux'
190         ;;
191 i[[3456]]86-*-freebsd[[3-9]]*) # FreeBSD 3.0+ uses ELF
192         HostPlatform=i386-unknown-freebsd # hack again
193         TargetPlatform=i386-unknown-freebsd
194         BuildPlatform=i386-unknown-freebsd
195         HostPlatform_CPP='i386_unknown_freebsd'
196         HostArch_CPP='i386'
197         HostVendor_CPP='unknown'
198         HostOS_CPP='freebsd'
199         ;;
200 i[[3456]]86-*-freebsd2*) # Older FreeBSDs are a.out
201         HostPlatform=i386-unknown-freebsd2 # hack again
202         TargetPlatform=i386-unknown-freebsd2
203         BuildPlatform=i386-unknown-freebsd2
204         HostPlatform_CPP='i386_unknown_freebsd2'
205         HostArch_CPP='i386'
206         HostVendor_CPP='unknown'
207         HostOS_CPP='freebsd2'
208         ;;
209 i[[3456]]86-*-netbsd*)
210         HostPlatform=i386-unknown-netbsd # hack again
211         TargetPlatform=i386-unknown-netbsd
212         BuildPlatform=i386-unknown-netbsd
213         HostPlatform_CPP='i386_unknown_netbsd'
214         HostArch_CPP='i386'
215         HostVendor_CPP='unknown'
216         HostOS_CPP='netbsd'
217         ;;
218 i[[3456]]86-*-openbsd*)
219         HostPlatform=i386-unknown-openbsd # hack again
220         TargetPlatform=i386-unknown-openbsd
221         BuildPlatform=i386-unknown-openbsd
222         HostPlatform_CPP='i386_unknown_openbsd'
223         HostArch_CPP='i386'
224         HostVendor_CPP='unknown'
225         HostOS_CPP='openbsd'
226         ;;
227 i[[3456]]86-*-solaris2*)
228         HostPlatform=i386-unknown-solaris2 # hack again
229         TargetPlatform=i386-unknown-solaris2
230         BuildPlatform=i386-unknown-solaris2
231         HostPlatform_CPP='i386_unknown_solaris2'
232         HostArch_CPP='i386'
233         HostVendor_CPP='unknown'
234         HostOS_CPP='solaris2'
235         ;;
236 i[[3456]]86-*-cygwin*)
237         HostPlatform=i386-unknown-cygwin32 # hack again
238         TargetPlatform=i386-unknown-cygwin32
239         BuildPlatform=i386-unknown-cygwin32
240         HostPlatform_CPP='i386_unknown_cygwin32'
241         HostArch_CPP='i386'
242         HostVendor_CPP='unknown'
243         HostOS_CPP='cygwin32'
244         exeext='.exe'
245         ;;
246 i[[3456]]86-*-mingw32*)
247         HostPlatform=i386-unknown-mingw32 # hack again
248         TargetPlatform=i386-unknown-mingw32
249         BuildPlatform=i386-unknown-mingw32
250         HostPlatform_CPP='i386_unknown_mingw32'
251         HostArch_CPP='i386'
252         HostVendor_CPP='unknown'
253         HostOS_CPP='mingw32'
254         exeext='.exe'
255         ;;
256 ia64-*-linux*)
257         HostPlatform=ia64-unknown-linux # hack again
258         TargetPlatform=ia64-unknown-linux
259         BuildPlatform=ia64-unknown-linux
260         HostPlatform_CPP='ia64_unknown_linux'
261         HostArch_CPP='ia64'
262         HostVendor_CPP='unknown'
263         HostOS_CPP='linux'
264         ;;
265 x86_64-*-linux*)
266         HostPlatform=x86_64-unknown-linux
267         TargetPlatform=x86_64-unknown-linux
268         BuildPlatform=x86_64-unknown-linux
269         HostPlatform_CPP='x86_64_unknown_linux'
270         HostArch_CPP='x86_64'
271         HostVendor_CPP='unknown'
272         HostOS_CPP='linux'
273         ;;
274 m68k-*-linux*)
275         HostPlatform=m68k-unknown-linux # hack again
276         TargetPlatform=m68k-unknown-linux                    
277         BuildPlatform=m68k-unknown-linux
278         HostPlatform_CPP='m68k_unknown_linux'
279         HostArch_CPP='m68k'
280         HostVendor_CPP='unknown'
281         HostOS_CPP='linux'
282         ;;
283 m68k-next-nextstep2)
284         HostPlatform_CPP='m68k_next_nextstep2'
285         HostArch_CPP='m68k'
286         HostVendor_CPP='next'
287         HostOS_CPP='nextstep2'
288         ;;
289 m68k-next-nextstep3)
290         HostPlatform_CPP='m68k_next_nextstep3'
291         HostArch_CPP='m68k'
292         HostVendor_CPP='next'
293         HostOS_CPP='nextstep3'
294         ;;
295 i[[3456]]86-next-nextstep3)
296         HostPlatform=i386-next-nextstep3 # hack again
297         TargetPlatform=i386-next-nextstep3
298         BuildPlatform=i386-next-nextstep3
299         HostPlatform_CPP='i386_next_nextstep3'
300         HostArch_CPP='i386'
301         HostVendor_CPP='next'
302         HostOS_CPP='nextstep3'
303         ;;
304 m68k-*-openbsd*)
305         HostPlatform=m68k-unknown-openbsd
306         TargetPlatform=m68k-unknown-openbsd
307         BuildPlatform=m68k-unknown-openbsd
308         HostPlatform_CPP='m68k_unknown_openbsd'
309         HostArch_CPP='m68k'
310         HostVendor_CPP='unknown'
311         HostOS_CPP='openbsd'
312         ;;
313 m68k-*-netbsd*)
314         HostPlatform=m68k-unknown-netbsd
315         TargetPlatform=m68k-unknown-netbsd
316         BuildPlatform=m68k-unknown-netbsd
317         HostPlatform_CPP='m68k_unknown_netbsd'
318         HostArch_CPP='m68k'
319         HostVendor_CPP='unknown'
320         HostOS_CPP='netbsd'
321         ;;
322 m68k-sun-sunos4*)
323         HostPlatform=m68k-sun-sunos4
324         TargetPlatform=m68k-sun-sunos4 #hack
325         BuildPlatform=m68k-sun-sunos4 #hack
326         HostPlatform_CPP='m68k_sun_sunos4'
327         HostArch_CPP='m68k'
328         HostVendor_CPP='sun'
329         HostOS_CPP='sunos4'
330         ;;
331 m88k-*-openbsd*)
332         HostPlatform=m88k-unknown-openbsd
333         TargetPlatform=m88k-unknown-openbsd
334         BuildPlatform=m88k-unknown-openbsd
335         HostPlatform_CPP='m88k_unknown_openbsd'
336         HostArch_CPP='m88k'
337         HostVendor_CPP='unknown'
338         HostOS_CPP='openbsd'
339         ;;
340 mips-*-linux*)
341         HostPlatform=mips-unknown-linux # hack again
342         TargetPlatform=mips-unknown-linux
343         BuildPlatform=mips-unknown-linux
344         HostPlatform_CPP='mips_unknown_linux'
345         HostArch_CPP='mips'
346         HostVendor_CPP='unknown'
347         HostOS_CPP='linux'
348         ;;
349 mips-dec-ultrix*)
350         HostPlatform_CPP='mips_dec_ultrix'
351         HostArch_CPP='mipsel'   # NB a little different
352         HostVendor_CPP='dec'
353         HostOS_CPP='ultrix'
354         ;;
355 mips-sgi-irix*)
356         HostPlatform=mips-sgi-irix
357         TargetPlatform=mips-sgi-irix #hack
358         BuildPlatform=mips-sgi-irix #hack
359         HostPlatform_CPP='mips_sgi_irix'
360         HostArch_CPP='mipseb'   # NB a little different
361         HostVendor_CPP='sgi'
362         HostOS_CPP='irix'
363         ;;
364 rs6000-ibm-aix*)
365         HostPlatform=rs6000-ibm-aix
366         TargetPlatform=rs6000-ibm-aix #hack
367         BuildPlatform=rs6000-ibm-aix #hack
368         HostPlatform_CPP='rs6000_ibm_aix'
369         HostArch_CPP='rs6000'
370         HostVendor_CPP='ibm'
371         HostOS_CPP='aix'
372         ;;
373 powerpc-ibm-aix*)
374         HostPlatform=powerpc-ibm-aix
375         TargetPlatform=powerpc-ibm-aix #hack
376         BuildPlatform=powerpc-ibm-aix #hack
377         HostPlatform_CPP='powerpc_ibm_aix'
378         HostArch_CPP='powerpc'
379         HostVendor_CPP='ibm'
380         HostOS_CPP='aix'
381         ;;
382 powerpc-apple-darwin*)
383         HostPlatform=powerpc-apple-darwin
384         TargetPlatform=powerpc-apple-darwin #hack
385         BuildPlatform=powerpc-apple-darwin #hack
386         HostPlatform_CPP='powerpc_apple_darwin'
387         HostArch_CPP='powerpc'
388         HostVendor_CPP='apple'
389         HostOS_CPP='darwin'
390         ;;
391 powerpc-unknown-linux*)
392         HostPlatform=powerpc-unknown-linux
393         TargetPlatform=powerpc-unknown-linux
394         BuildPlatform=powerpc-unknown-linux
395         HostPlatform_CPP='powerpc_unknown_linux'
396         HostArch_CPP='powerpc'
397         HostVendor_CPP='unknown'
398         HostOS_CPP='linux'
399         ;;
400 powerpc-unknown-openbsd*)
401         HostPlatform=powerpc-unknown-openbsd
402         TargetPlatform=powerpc-unknown-openbsd
403         BuildPlatform=powerpc-unknown-openbsd
404         HostPlatform_CPP='powerpc_unknown_openbsd'
405         HostArch_CPP='powerpc'
406         HostVendor_CPP='unknown'
407         HostOS_CPP='openbsd'
408         ;;
409 powerpc64-unknown-linux*)
410         HostPlatform=powerpc64-unknown-linux
411         TargetPlatform=powerpc64-unknown-linux
412         BuildPlatform=powerpc64-unknown-linux
413         HostPlatform_CPP='powerpc64_unknown_linux'
414         HostArch_CPP='powerpc64'
415         HostVendor_CPP='unknown'
416         HostOS_CPP='linux'
417         ;;
418                                                                 
419 s390-ibm-linux*)
420        HostPlatform=s390-ibm-linux
421        TargetPlatform=s390-ibm-linux #hack
422        BuildPlatform=s390-ibm-linux #hack
423         HostPlatform_CPP='s390_ibm_linux'
424         HostArch_CPP='s390'
425         HostVendor_CPP='ibm'
426         HostOS_CPP='linux'
427         ;;
428 sparc-sun-sunos4*)
429         HostPlatform=sparc-sun-sunos4
430         TargetPlatform=sparc-sun-sunos4 #hack
431         BuildPlatform=sparc-sun-sunos4 #hack
432         HostPlatform_CPP='sparc_sun_sunos4'
433         HostArch_CPP='sparc'
434         HostVendor_CPP='sun'
435         HostOS_CPP='sunos4'
436         ;;
437 sparc-sun-solaris2*)
438         HostPlatform=sparc-sun-solaris2
439         TargetPlatform=sparc-sun-solaris2 #hack
440         BuildPlatform=sparc-sun-solaris2 #hack
441         HostPlatform_CPP='sparc_sun_solaris2'
442         HostArch_CPP='sparc'
443         HostVendor_CPP='sun'
444         HostOS_CPP='solaris2'
445         ;;
446 sparc*-linux*)
447         HostPlatform=sparc-unknown-linux
448         TargetPlatform=sparc-unknown-linux
449         BuildPlatform=sparc-unknown-linux
450         HostPlatform_CPP='sparc_unknown_linux'
451         HostArch_CPP='sparc'
452         HostVendor_CPP='unknown'
453         HostOS_CPP='linux'
454         ;;
455 sparc-*-openbsd*)
456         HostPlatform=sparc-unknown-openbsd
457         TargetPlatform=sparc-unknown-openbsd
458         BuildPlatform=sparc-unknown-openbsd
459         HostPlatform_CPP='sparc_unknown_openbsd'
460         HostArch_CPP='sparc'
461         HostVendor_CPP='unknown'
462         HostOS_CPP='openbsd'
463         ;;
464 sparc64-*-openbsd*)
465         HostPlatform=sparc64-unknown-openbsd
466         TargetPlatform=sparc64-unknown-openbsd
467         BuildPlatform=sparc64-unknown-openbsd
468         HostPlatform_CPP='sparc64_unknown_openbsd'
469         HostArch_CPP='sparc64'
470         HostVendor_CPP='unknown'
471         HostOS_CPP='openbsd'
472         ;;
473 vax-*-openbsd*)
474         HostPlatform=vax-unknown-openbsd
475         TargetPlatform=vax-unknown-openbsd
476         BuildPlatform=vax-unknown-openbsd
477         HostPlatform_CPP='vax_unknown_openbsd'
478         HostArch_CPP='vax'
479         HostVendor_CPP='unknown'
480         HostOS_CPP='openbsd'
481         ;;
482 *)
483         echo "Unrecognised platform: $HostPlatform"
484         exit 1
485         ;;
486 esac
487 echo "Canonicalised to: $HostPlatform"
488 test  x"$HostPlatform" != x"$TargetPlatform" && echo "Target platform set to $TargetPlatform"
489 test  x"$BuildPlatform" != x"$HostPlatform"  && echo "Build platform set to $BuildPlatform"
490
491 BuildPlatform_CPP=$HostPlatform_CPP
492 TargetPlatform_CPP=$HostPlatform_CPP
493 BuildArch_CPP=$HostArch_CPP
494 TargetArch_CPP=$HostArch_CPP
495 BuildOS_CPP=$HostOS_CPP
496 HostOS_Full=$host_os
497 TargetOS_CPP=$HostOS_CPP
498 BuildVendor_CPP=$HostVendor_CPP
499 TargetVendor_CPP=$HostVendor_CPP
500
501 AC_SUBST(BuildPlatform)
502 AC_SUBST(HostPlatform)
503 AC_SUBST(TargetPlatform)
504 AC_SUBST(HostPlatform_CPP)
505 AC_SUBST(BuildPlatform_CPP)
506 AC_SUBST(TargetPlatform_CPP)
507
508 AC_SUBST(HostArch_CPP)
509 AC_SUBST(BuildArch_CPP)
510 AC_SUBST(TargetArch_CPP)
511
512 AC_SUBST(HostOS_CPP)
513 AC_SUBST(HostOS_Full)
514 AC_SUBST(BuildOS_CPP)
515 AC_SUBST(TargetOS_CPP)
516
517 AC_SUBST(HostVendor_CPP)
518 AC_SUBST(BuildVendor_CPP)
519 AC_SUBST(TargetVendor_CPP)
520
521 AC_SUBST(exeext)
522
523 dnl --------------------------------------------------------------
524 dnl * Calculate absolute path to build tree
525 dnl --------------------------------------------------------------
526
527 AC_MSG_CHECKING(for path to top of build tree)
528
529 hardtop=`pwd`
530
531 dnl Remove common automounter nonsense
532 dnl
533 hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|' | sed 's|^//\(.\)/|\1:/|' `
534
535 dnl Find 'hardtop_plat', the native format for 'hardtop' 
536 dnl (i.e., right kind of \dnl slashes on a Win32 box, but with b-slashes being escaped).
537 dnl
538 dnl Note OSTYPE: On Cygwin we need to use 'cygpath' to convert /cygdrive/c/foo to c:/foo
539 dnl              but we must not do that if we aren't building using Cygwin (notably msys), 
540 dnl              because cygpath doesn't exist.  It seems that 'bash' sets OSTYPE to 'cygwin' 
541 dnl              or 'msys' respectively, but cygwin's 'sh' does not.  So we hackily assume
542 dnl              that if the shell hasn't set it to 'msys' then we must be in Cygwin.  Sigh.
543 dnl
544 dnl              The Right Thing is probably to test $BuildPlatform instead, but we are sloppy 
545 dnl              about setting that correctly at the moment, so we just work around for now.
546 dnl
547 dnl              The quotes round "$(OSTYPE)" are essential, for the Cygwin-sh case where OSTYPE
548 dnl              is not set.
549 case $HostPlatform in
550   i386-unknown-mingw32 | i386-unknown-cygwin32)
551         if test "${OSTYPE}" != "msys" 
552           then
553             # convert $hardtop to a path that mingw will understand too
554             cyghardtop=${hardtop}
555             hardtop=`cygpath -w ${cyghardtop} | sed -e 's@\\\\@/@g'`
556             hardtop_plat=`cygpath -w ${cyghardtop} | sed -e 's@\\\\@\\\\\\\\@g'`
557           else
558             hardtop_plat=${hardtop}
559         fi
560         ;;
561   *)
562         hardtop_plat=${hardtop}
563         ;;
564 esac
565 AC_SUBST(hardtop)
566 AC_SUBST(hardtop_plat)
567
568 AC_MSG_RESULT(${hardtop})
569
570 dnl --------------------------------------------------------------
571 dnl * Project specific configuration options
572 dnl --------------------------------------------------------------
573 dnl What follows is a bunch of options that can either be configured
574 dnl through command line options to the configure script or by
575 dnl supplying defns in the build tree's mk/build.mk. Having the option to
576 dnl use either is considered a Feature.
577
578 dnl ** What command to use to compile compiler sources ?
579 dnl --------------------------------------------------------------
580
581 AC_ARG_WITH(ghc,
582 [AC_HELP_STRING([--with-ghc=ARG],
583         [Use ARG as the path to GHC  [default=autodetect]])],
584 [ WithGhc="$withval" ],
585
586   if test "$GHC" = ""; then
587     AC_PATH_PROG(GHC,ghc)
588   fi
589   WithGhc=$GHC
590 ])
591 AC_SUBST(WithGhc)
592
593 AC_ARG_WITH(hc,
594 [AC_HELP_STRING([--with-hc=ARG],
595         [Use ARG as the path to the compiler for compiling ordinary
596          Haskell code  (default= value of --with-ghc)])],
597 [WithHc="$withval"],
598 [WithHc=$WithGhc]
599 )
600 AC_SUBST(WithHc)
601
602 if test "$WithGhc" != ""; then
603   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
604   AC_SUBST(GhcVersion)dnl
605   AC_SUBST(GhcMajVersion)dnl
606   AC_SUBST(GhcMinVersion)dnl
607   AC_SUBST(GhcPatchLevel)dnl
608 fi
609
610 AC_PATH_PROGS(NHC,nhc nhc98)
611 AC_PATH_PROG(HBC,hbc)
612
613 dnl ** Which gcc to use?
614 dnl --------------------------------------------------------------
615 AC_ARG_WITH(gcc,
616 [AC_HELP_STRING([--with-gcc=ARG],
617         [Use ARG as the path to GCC  [default=autodetect]])],
618 [WhatGccIsCalled="$withval"
619  if test "x$HostPlatform" = "xi386-unknown-mingw32"
620     then
621        if test "${OSTYPE}" != "msys"
622          then
623          # Canonicalise to <drive>:/path/to/gcc
624          withval=`cygpath -w ${withval} | sed -e 's@\\\\@/@g' `
625        fi
626  fi;
627  CC="$withval"],
628 [WhatGccIsCalled="gcc"]
629 )
630 AC_SUBST(WhatGccIsCalled)
631
632 dnl ** Booting from .hc files?
633 dnl --------------------------------------------------------------
634 AC_ARG_ENABLE(hc-boot,
635 [AC_HELP_STRING([--enable-hc-boot],
636 [Boot the Glasgow Haskell Compiler from intermediate .hc files.
637  (This option is mostly of interest to porters.) [default=no]])],
638 [ if test x"$enableval" = x"yes"; then
639         BootingFromHc=YES
640   else
641         BootingFromHc=NO
642   fi
643 ],
644 [BootingFromHc=NO]
645 )
646 AC_SUBST(BootingFromHc)
647
648 dnl ** Booting from unregisterised .hc files?
649 dnl --------------------------------------------------------------
650 AC_ARG_ENABLE(hc-boot-unregisterised,
651 [AC_HELP_STRING([--enable-hc-boot-unregisterised],
652 [ With --enable-hc-boot, treat the intermediate .hc files as
653  unregisterised rather than registerised code.
654  (This option is mostly of interest to porters.) [default=no]])],
655 [ if test x"$enableval" = x"yes"; then
656         BootingFromUnregisterisedHc=YES
657   else
658         BootingFromUnregisterisedHc=NO
659   fi
660 ],
661 [BootingFromUnregisterisedHc=NO]
662 )
663 AC_SUBST(BootingFromUnregisterisedHc)
664
665 if test "$BootingFromHc" = "NO"; then
666 if test "$BootingFromUnregisterisedHc" = "YES"; then
667 AC_MSG_ERROR([--enable-hc-boot-unregisterised requires --enable-hc-boot.])
668 fi;
669 fi;
670
671 dnl ** Must have GHC to build GHC, unless --enable-hc-boot is on
672 if test "$BootingFromHc" = "NO" -a "$WithGhc" = "" -a -d "$srcdir/ghc"; then
673 AC_MSG_ERROR([GHC is required unless bootstrapping from .hc files.])
674 fi;
675
676 dnl ** --enable-threaded-rts (not used any more)
677 dnl --------------------------------------------------------------
678 AC_ARG_ENABLE(threaded-rts,
679 [AC_HELP_STRING([--enable-threaded-rts],
680 [DEPRECATED (backwards compatibility only). [default=no]])],
681 [ if test x"$enableval" = x"yes"; then
682         ThreadedRts=YES
683   else
684         ThreadedRts=NO
685   fi
686 ],
687 [ThreadedRts=NO]
688 )
689 AC_SUBST(ThreadedRts)
690
691 dnl ** Enable the construction of Win32 DLLs?
692 dnl --------------------------------------------------------------
693 dnl
694 dnl [ The ability to build the RTS and libraries as separate DLLs used
695 dnl   to be supported, but isn't currently (updates to the RTS, compiler 
696 dnl   and build system would be required to bring it back again.)
697 dnl   Hence, exposing it as an option is false advertisement, so better
698 dnl   disable it to avoid confusion (but leave it commented-out rather
699 dnl   than removed in order to remind ourselves to bring back the 
700 dnl   feature at some stage.) ]
701 dnl
702 dnl AC_ARG_ENABLE(win32-dlls,
703 dnl [  --enable-win32-dlls
704 dnl         If on a Win32 platform running mingw32/cygwin, enable the
705 dnl     construction of DLLs containing ghc-compiled code.
706 dnl ],
707 dnl [
708 dnl case $HostOS_CPP in
709 dnl cygwin32) ;;
710 dnl mingw32)  ;;
711 dnl *)    echo "Unrecognised win32 platform: $HostPlatform"
712 dnl       exit 1
713 dnl       ;;
714 dnl esac
715 dnl EnableWin32DLLs=YES
716 dnl ],
717 dnl [EnableWin32DLLs=NO]
718 dnl )
719 dnl AC_SUBST(EnableWin32DLLs)
720 dnl if test x"$EnableWin32DLLs" = "xYES" ; then
721 dnl  AC_DEFINE(HAVE_WIN32_DLL_SUPPORT)
722 dnl fi
723
724 dnl ** Enable the building of the ObjectIO?
725 dnl --------------------------------------------------------------
726 AC_ARG_ENABLE(objectio,
727 [AC_HELP_STRING([--enable-objectio],
728 [Build ObjectIO, a portable GUI library for Haskell. [default=no]])],
729 [ if test x"$enableval" = x"yes"; then
730         GhcLibsWithObjectIO=YES
731   else
732         GhcLibsWithObjectIO=NO
733   fi
734 ],
735 [GhcLibsWithObjectIO=NO]
736 )
737 AC_SUBST(GhcLibsWithObjectIO)
738
739 dnl ** Enable the building of the OpenAL binding?
740 dnl --------------------------------------------------------------
741 AC_ARG_ENABLE([openal],
742   AC_HELP_STRING([--enable-openal],
743                  [Build OpenAL binding [[default=autodetect]]]),
744   [ if test x"$enableval" = x"yes"; then
745         GhcLibsWithOpenAL=YES
746     else
747         GhcLibsWithOpenAL=NO
748     fi
749   ],
750   [GhcLibsWithOpenAL=YES])
751
752 AC_SUBST([GhcLibsWithOpenAL])
753
754 dnl ** .NET interop support?
755 dnl --------------------------------------------------------------
756 AC_ARG_ENABLE(dotnet,
757 [AC_HELP_STRING([--enable-dotnet],
758 [Build .NET interop layer. [default=no]])],
759 [ if test x"$enableval" = x"yes"; then
760         DotnetSupport=YES; AC_DEFINE([WANT_DOTNET_SUPPORT], [1], [Define to 1 if you want to include .NET interop support.])
761   else 
762         DotnetSupport=NO
763   fi],
764 [DotnetSupport=NO]
765 )
766 AC_SUBST(DotnetSupport)
767
768 dnl --------------------------------------------------------------
769 dnl End of configure script option section
770 dnl --------------------------------------------------------------
771
772
773 dnl --------------------------------------------------------------
774 dnl * General configuration checks
775 dnl --------------------------------------------------------------
776
777 dnl ** Can the unix package be built?
778 dnl --------------------------------------------------------------
779
780 if test x"$TargetPlatform" = x"i386-unknown-mingw32"; then
781    GhcLibsWithUnix=NO
782 else
783    GhcLibsWithUnix=YES
784 fi
785 AC_SUBST([GhcLibsWithUnix])
786
787 dnl ** does #! work?
788 AC_SYS_INTERPRETER()
789
790 dnl ** look for `perl', but only in /bin on Windows
791 case $HostOS_CPP in
792 cygwin32|mingw32)
793       AC_CHECK_PROG(PerlCmd,perl,/bin/perl,,/bin)
794       if test -z "$PerlCmd"; then
795          echo "You must install the version of Perl shipped with GHC"
796          echo "(or a compatible one) in /bin."
797          exit 1
798       fi
799    ;;
800 *)
801    AC_PATH_PROG(PerlCmd,perl)
802    if test -z "$PerlCmd"; then
803       echo "You must install perl before you can continue"
804       echo "Perhaps it is already installed, but not in your PATH?"
805       exit 1
806    else
807    FPTOOLS_CHECK_PERL_VERSION
808    fi
809    ;;
810 esac
811
812 dnl ** does #! path/to/perl work? (sometimes it's too long...)
813 FPTOOLS_SHEBANG_PERL
814
815 dnl ** check for Python
816 AC_PATH_PROG(PythonCmd,python)
817
818 dnl ** look for GCC and find out which version
819 dnl     Figure out which C compiler to use.  Gcc is preferred.
820 dnl     If gcc, make sure it's at least 2.1
821 dnl
822 AC_PROG_CC
823 FPTOOLS_HAVE_GCC
824 FPTOOLS_GCC_NEEDS_NO_OMIT_LFPTR
825
826 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
827 AC_PROG_CPP
828
829 dnl ** Without optimization some INLINE trickery fails for GHCi
830 SRC_CC_OPTS="-O"
831
832 dnl ** Try to add -mno-cygwin to the C compiler options
833 FP_CHECK_FLAG([-mno-cygwin], [
834 SRC_CC_OPTS="-mno-cygwin $SRC_CC_OPTS"
835 CPPFLAGS="-mno-cygwin $CPPFLAGS"])
836 AC_SUBST(SRC_CC_OPTS)
837
838 dnl ** figure out how to do context diffs
839 FP_PROG_CONTEXT_DIFF
840
841 dnl ** Find find command (for Win32's benefit)
842 FP_PROG_FIND
843
844 dnl ** figure out how to do a BSD-ish install
845 AC_PROG_INSTALL
846
847 dnl If you can run configure, you certainly have /bin/sh
848 AC_DEFINE([HAVE_BIN_SH], [1], [Define to 1 if you have /bin/sh.])
849
850 dnl ** how to invoke `ar' and `ranlib'
851 FP_PROG_AR_NEEDS_RANLIB
852 FP_PROG_AR_SUPPORTS_INPUT
853
854 dnl ** Check to see whether ln -s works
855 AC_PROG_LN_S
856
857
858 dnl ** Find the path to sed
859 AC_PATH_PROG(SedCmd,sed)
860
861
862 dnl ** check for time command
863 AC_PATH_PROG(TimeCmd,time)
864
865 dnl ** check for tar
866 dnl   if GNU tar is named gtar, look for it first.
867 AC_PATH_PROGS(TarCmd,gtar tar,tar)
868
869 dnl ** check for DocBook toolchain
870 FP_CHECK_DOCBOOK_DTD
871 FP_DIR_DOCBOOK_XSL([/usr/share/xml/docbook/stylesheet/nwalsh/current /usr/share/xml/docbook/stylesheet/nwalsh /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])
872 FP_PROG_FO_PROCESSOR
873
874 dnl ** check for ghc-pkg command
875 FP_PROG_GHC_PKG
876
877 dnl Check whether this GHC has readline installed
878 FPTOOLS_GHC_HAS_READLINE
879
880 AC_ARG_WITH(greencard,
881 [AC_HELP_STRING([--with-greencard=ARG],
882         [Use ARG as the path to greencard  [default=autodetct]])],
883 [
884 GreenCardCmd=$withval;
885 FPTOOLS_GREENCARD(3.00)
886 ]
887 )
888
889 AC_ARG_ENABLE(src-tree-happy,
890 [AC_HELP_STRING([--enable-src-tree-happy],
891         [Build and use source tree (fptools/happy) version of Happy. 
892          [default=autodetect]])],
893 [ if test x"$enableval" = x"yes"; then
894         UseSrcTreeHappy=YES
895   else
896         UseSrcTreeHappy=NO
897   fi
898 ],
899 [UseSrcTreeHappy=NO]
900 )
901 dnl ** check for installed happy binary + version
902 dnl    (don't do it if we're booting from .hc files though.)
903 if test "$BootingFromHc" = "NO"; then
904 FPTOOLS_HAPPY
905 fi;
906
907 AC_ARG_ENABLE(src-tree-haddock,
908 [AC_HELP_STRING([--enable-src-tree-haddock],
909         [Build and use source tree (fptools/haddock) version of Haddock.
910          [default=autodetect]])],
911 [ if test x"$enableval" = x"yes"; then
912         UseSrcTreeHaddock=YES
913   else
914         UseSrcTreeHaddock=NO
915   fi
916 ],
917 [UseSrcTreeHaddock=NO]
918 )
919 dnl ** check for installed haddock
920 FPTOOLS_HADDOCK
921
922 AC_ARG_ENABLE(src-tree-alex,
923 [AC_HELP_STRING([--enable-src-tree-alex],
924         [Build and use source tree (fptools/alex) version of Alex.
925          [default=autodetect]])],
926 [ if test x"$enableval" = x"yes"; then
927         UseSrcTreeAlex=YES
928   else
929         UseSrcTreeAlex=NO
930   fi
931 ],
932 [UseSrcTreeAlex=NO]
933 )
934 dnl ** check for installed alex binary + version
935 dnl    (don't do it if we're booting from .hc files though.)
936 if test "$BootingFromHc" = "NO"; then
937 FPTOOLS_ALEX
938 fi;
939
940 dnl --------------------------------------------------
941 dnl ### program checking section ends here ###
942 dnl --------------------------------------------------
943
944 dnl --------------------------------------------------
945 dnl * Platform header file and syscall feature tests
946 dnl ### checking the state of the local header files and syscalls ###
947
948 dnl ** check for full ANSI header (.h) files
949 AC_HEADER_STDC
950
951 dnl ** Enable large file support.  NB. do this before testing the type of
952 dnl    off_t, because it will affect the result of that test.
953 AC_SYS_LARGEFILE
954
955 dnl ** check for specific header (.h) files that we are interested in
956 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])
957
958 AC_CHECK_HEADER([readline/readline.h], [HaveReadlineReadlineH=YES], [HaveReadlineReadlineH=NO])
959 AC_CHECK_HEADER([readline/history.h], [HaveReadlineHistoryH=YES], [HaveReadlineHistoryH=NO])
960
961 if test $HaveReadlineReadlineH = YES && test $HaveReadlineHistoryH = YES ; then
962   GhcLibsWithReadline=YES
963   AC_DEFINE([HAVE_READLINE_HEADERS], [1], [Define to 1 if readline/readline.h and readline/history.h exist.])
964 else
965   GhcLibsWithReadline=NO
966   AC_DEFINE([HAVE_READLINE_HEADERS], [0], [Define to 1 if readline/readline.h and readline/history.h exist.])
967 fi
968 AC_SUBST(GhcLibsWithReadline)
969
970 dnl ** check for OpenGL/GLUT include paths and libraries
971 FP_CHECK_GLUT
972
973 if test x"$no_GLU" = xyes; then
974   GhcLibsWithOpenGL=NO
975 else
976   GhcLibsWithOpenGL=YES
977 fi
978 AC_SUBST([GhcLibsWithOpenGL])
979
980 if test x"$no_GLUT" = xyes; then
981   GhcLibsWithGLUT=NO
982 else
983   GhcLibsWithGLUT=YES
984 fi
985 AC_SUBST([GhcLibsWithGLUT])
986
987 dnl ** check for OpenGL include files
988 fp_save_cppflags="$CPPFLAGS"
989 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
990 if test x"$use_quartz_opengl" = xyes; then
991   AC_CHECK_HEADERS([OpenGL/gl.h])
992 else
993   AC_CHECK_HEADERS([GL/gl.h])
994 fi
995 CPPFLAGS="$fp_save_cppflags"
996
997 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
998 AC_HEADER_TIME
999
1000 dnl ** check for POSIX regex
1001 HavePosixRegex=NO
1002 AC_CHECK_HEADERS([regex.h], [AC_CHECK_FUNCS(regcomp, [HavePosixRegex=YES])])
1003 AC_SUBST(HavePosixRegex)
1004
1005 dnl ** how do we get a timezone name, and UTC offset ?
1006 AC_STRUCT_TIMEZONE
1007
1008 dnl ** do we have altzone?
1009 FP_DECL_ALTZONE
1010
1011 dnl ** do we have long longs?
1012 AC_CHECK_TYPES([long long])
1013
1014 dnl ** what are the sizes of various types
1015 AC_CHECK_SIZEOF(char,               1)
1016 AC_CHECK_SIZEOF(double,             8)
1017 AC_CHECK_SIZEOF(float,              4)
1018 AC_CHECK_SIZEOF(int,                4)
1019 AC_CHECK_SIZEOF(long,               4)
1020 if test "$ac_cv_type_long_long" = yes; then
1021 AC_CHECK_SIZEOF(long long,          8)
1022 fi
1023 AC_CHECK_SIZEOF(short,              2)
1024 AC_CHECK_SIZEOF(unsigned char,      1)
1025 AC_CHECK_SIZEOF(unsigned int,       4)
1026 AC_CHECK_SIZEOF(unsigned long,      4)
1027 if test "$ac_cv_type_long_long" = yes; then
1028 AC_CHECK_SIZEOF(unsigned long long, 8)
1029 fi
1030 AC_CHECK_SIZEOF(unsigned short,     2)
1031 AC_CHECK_SIZEOF(void *,             4)
1032
1033 dnl ** what are alignment constraints on various types
1034 FP_CHECK_ALIGNMENT(char)
1035 FP_CHECK_ALIGNMENT(double)
1036 FP_CHECK_ALIGNMENT(float)
1037 FP_CHECK_ALIGNMENT(int)
1038 FP_CHECK_ALIGNMENT(long)
1039 if test "$ac_cv_type_long_long" = yes; then
1040 FP_CHECK_ALIGNMENT(long long)
1041 fi
1042 FP_CHECK_ALIGNMENT(short)
1043 FP_CHECK_ALIGNMENT(unsigned char)
1044 FP_CHECK_ALIGNMENT(unsigned int)
1045 FP_CHECK_ALIGNMENT(unsigned long)
1046 if test "$ac_cv_type_long_long" = yes; then
1047 FP_CHECK_ALIGNMENT(unsigned long long)
1048 fi
1049 FP_CHECK_ALIGNMENT(unsigned short)
1050 FP_CHECK_ALIGNMENT(void *)
1051
1052 dnl ** Map OpenGL data types to Haskell types
1053 if test $GhcLibsWithOpenGL = YES ; then
1054 FPTOOLS_CHECK_HTYPE(GLboolean)
1055 FPTOOLS_CHECK_HTYPE(GLbyte)
1056 FPTOOLS_CHECK_HTYPE(GLubyte)
1057 FPTOOLS_CHECK_HTYPE(GLshort)
1058 FPTOOLS_CHECK_HTYPE(GLushort)
1059 FPTOOLS_CHECK_HTYPE(GLint)
1060 FPTOOLS_CHECK_HTYPE(GLuint)
1061 FPTOOLS_CHECK_HTYPE(GLsizei)
1062 FPTOOLS_CHECK_HTYPE(GLenum)
1063 FPTOOLS_CHECK_HTYPE(GLbitfield)
1064 FPTOOLS_CHECK_HTYPE(GLfloat)
1065 FPTOOLS_CHECK_HTYPE(GLclampf)
1066 FPTOOLS_CHECK_HTYPE(GLdouble)
1067 FPTOOLS_CHECK_HTYPE(GLclampd)
1068 fi
1069
1070 FP_CHECK_FUNC([WinExec],
1071   [@%:@include <windows.h>], [WinExec("",0)])
1072
1073 FP_CHECK_FUNC([GetModuleFileName],
1074   [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
1075
1076 dnl ** check return type of signal handlers
1077 dnl Foo: assumes we can use prototypes.
1078 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
1079 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
1080 dnl [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1081 dnl #include <signal.h>
1082 dnl #ifdef signal
1083 dnl #undef signal
1084 dnl #endif
1085 dnl void (*signal (int, void (*)(int)))(int);
1086 dnl ]],
1087 dnl [[int i;]])],
1088 dnl [ac_cv_type_signal_handler=void_int],
1089 dnl [ac_cv_type_signal_handler=int_void])])
1090 dnl if test "$ac_cv_type_signal_handler" = void_int; then
1091 dnl AC_DEFINE(VOID_INT_SIGNALS)
1092 dnl fi
1093
1094 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
1095 AC_TYPE_SIGNAL
1096 if test "$ac_cv_type_signal" = void; then
1097   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).])
1098 fi
1099
1100 dnl ** check for more functions
1101 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
1102 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times])
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 AC_SUBST(HaveLibGmp)
1111 AC_SUBST(LibGmp)
1112
1113 dnl ** (Mac OS X only: check for HaskellSupport.framework)
1114 HaveFrameworkHaskellSupport=NO
1115 if test $HostPlatform = "powerpc-apple-darwin"; then
1116  AC_MSG_CHECKING([for HaskellSupport.framework])
1117  save_libs="$LIBS"
1118  LIBS="-framework HaskellSupport"
1119  AC_TRY_LINK_FUNC(__gmpz_fdiv_qr, HaveFrameworkHaskellSupport=YES,)
1120  if test $HaveFrameworkHaskellSupport = YES; then
1121   AC_DEFINE([HAVE_FRAMEWORK_HASKELLSUPPORT], [1], [Define to 1 if the HaskellSupport.framework is installed (Mac OS X only).])
1122  fi;
1123  LIBS="$save_libs"
1124  AC_MSG_RESULT([$HaveFrameworkHaskellSupport])
1125 fi;
1126 AC_SUBST(HaveFrameworkHaskellSupport)
1127
1128 dnl ** check for mingwex library
1129 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
1130 AC_SUBST(HaveLibMingwEx)
1131
1132 if test $HaveLibMingwEx = YES ; then
1133   AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
1134 fi
1135
1136 if test "$HaveLibGmp" = "NO"; then
1137 if test "$HostArch_CPP" = "ia64" -o "$HostArch_CPP" = "mipseb" ; then
1138 AC_MSG_ERROR([You need to install libgmp (the in-tree version does not work on IA64 or mips64).])
1139 fi;
1140 fi;
1141
1142 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
1143 dnl    the order of these tests matters: bfd needs liberty
1144 AC_CHECK_LIB(iberty, xmalloc)
1145 AC_CHECK_LIB(bfd,    bfd_init)
1146
1147 dnl ** check for readline, for Hugs and hslibs' Readline
1148 dnl ncurses supersedes termcap and curses, but for compatibility,
1149 dnl we have to check for all...
1150 AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=YES; LibTermcap=ncurses,
1151   AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=YES; LibTermcap=termcap,
1152     AC_CHECK_LIB(curses, tputs, HaveLibTermcap=YES; LibTermcap=curses,
1153       HaveLibTermcap=NO; LibTermcap=not-installed)))
1154
1155 if test $HaveLibTermcap = YES ; then
1156   LIBS="-l$LibTermcap $LIBS"
1157   AC_CHECK_LIB(readline, readline, HaveLibReadline=YES, HaveLibReadline=NO)
1158 fi
1159
1160 if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES ; then
1161   AC_DEFINE([HAVE_READLINE_LIBS], [1], [Define to 1 if readline plus any additional libs needed for it exist.])
1162   LibsReadline="readline $LibTermcap"
1163 else
1164   AC_DEFINE([HAVE_READLINE_LIBS], [0], [Define to 1 if readline plus any additional libs needed for it exist.])
1165   LibsReadline=
1166 fi
1167 AC_SUBST(LibsReadline)
1168
1169 if test "$HaveLibReadline"; then
1170   AC_CHECK_LIB(readline, rl_erase_empty_line,
1171     [AC_DEFINE([HAVE_READLINE_4], [1], [Define to 1 if readline has version >= 4.0.])],
1172     [AC_DEFINE([HAVE_READLINE_4], [0], [Define to 1 if readline has version >= 4.0.])])
1173   AC_CHECK_LIB(readline, rl_free_undo_list,
1174     [AC_DEFINE([HAVE_READLINE_4_2], [1], [Define to 1 if readline has version >= 4.2.])],
1175     [AC_DEFINE([HAVE_READLINE_4_2], [0], [Define to 1 if readline has version >= 4.2.])])
1176 else
1177   AC_DEFINE([HAVE_READLINE_4], [0], [Define to 1 if readline has version >= 4.0.])
1178   AC_DEFINE([HAVE_READLINE_4_2], [0], [Define to 1 if readline has version >= 4.2.])
1179 fi
1180
1181 dnl ** check for math library
1182 AC_CHECK_LIB([m], [atan], [LIBS="-lm $LIBS"; LIBM="-lm"], [LIBM=])
1183 AC_SUBST([LIBM])
1184
1185 dnl ** check for X Window System
1186 AC_PATH_XTRA()
1187
1188 if test "$no_x" = yes; then
1189   GhcLibsWithX11=NO
1190 else
1191   GhcLibsWithX11=YES
1192 fi
1193 AC_SUBST([GhcLibsWithX11])
1194
1195 dnl ################################################################
1196 dnl Check for libraries
1197 dnl ################################################################
1198
1199 dnl ** check for libdl & RTLD_NEXT
1200
1201 dnl (Mac OS X only) ... but don't check if we already have the
1202 dnl HaskellSupport.framework
1203
1204 if test $HaveFrameworkHaskellSupport = YES; then
1205     HaveLibDL=NO
1206     HaveRtldNext=NO
1207     HaveRtldLocal=YES
1208     AC_DEFINE([HAVE_RTLDLOCAL], [1], [Define to 1 if RTLD_LOCAL is available.])
1209     HaveRtldGlobal=YES
1210     AC_DEFINE([HAVE_RTLDGLOBAL], [1], [Define to 1 if RTLD_GLOBAL is available.])
1211     HaveRtldNow=YES
1212     AC_DEFINE([HAVE_RTLDNOW], [1], [Define to 1 if we can see RTLD_NOW in dlfcn.h.])
1213     AC_SUBST(HaveLibDL)
1214     AC_SUBST(HaveRtldNext)
1215     AC_SUBST(HaveRtldLocal)
1216     AC_SUBST(HaveRtldGlobal)
1217     AC_SUBST(HaveRtldNow)
1218 else
1219     AC_CHECK_LIB(dl, dlopen, 
1220         [HaveLibDL=YES
1221          AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if you need -ldl to get dlopen().])
1222          LIBS="$LIBS -ldl"], 
1223         [HaveLibDL=NO])
1224     AC_SUBST(HaveLibDL)
1225
1226     dnl ** sometimes RTLD_NEXT is hidden in #ifdefs we really don't wan to set
1227     AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h)
1228     AC_EGREP_CPP(yes,
1229     [
1230      #include <dlfcn.h>
1231      #ifdef RTLD_NEXT
1232             yes
1233      #endif
1234     ], [
1235       AC_MSG_RESULT(yes)
1236       AC_DEFINE([HAVE_RTLDNEXT], [1], [Define to 1 if we can see RTLD_NEXT in dlfcn.h.])
1237       HaveRtldNext=YES
1238     ], [
1239       AC_MSG_RESULT(no)
1240       HaveRtldNext=NO
1241       ])    
1242     AC_SUBST(HaveRtldNext)
1243
1244     dnl ** RTLD_LOCAL isn't available on cygwin or openbsd
1245     AC_MSG_CHECKING(for RTLD_LOCAL from dlfcn.h)
1246     AC_EGREP_CPP(yes,
1247     [
1248      #include <dlfcn.h>
1249      #ifdef RTLD_LOCAL
1250             yes
1251      #endif
1252     ], [
1253       AC_MSG_RESULT(yes)
1254       AC_DEFINE(HAVE_RTLDLOCAL)
1255       HaveRtldLocal=YES
1256     ], [
1257       AC_MSG_RESULT(no)
1258       HaveRtldLocal=NO
1259       ])    
1260     AC_SUBST(HaveRtldLocal)
1261
1262     dnl ** RTLD_GLOBAL isn't available on openbsd
1263     AC_MSG_CHECKING(for RTLD_GLOBAL from dlfcn.h)
1264     AC_EGREP_CPP(yes,
1265     [
1266      #include <dlfcn.h>
1267      #ifdef RTLD_GLOBAL
1268             yes
1269      #endif
1270     ], [
1271       AC_MSG_RESULT(yes)
1272       AC_DEFINE(HAVE_RTLDGLOBAL)
1273       HaveRtldGlobal=YES
1274     ], [
1275       AC_MSG_RESULT(no)
1276       HaveRtldGlobal=NO
1277       ])    
1278     AC_SUBST(HaveRtldGlobal)
1279
1280     dnl ** RTLD_NOW isn't available on openbsd
1281     AC_MSG_CHECKING(for RTLD_NOW from dlfcn.h)
1282     AC_EGREP_CPP(yes,
1283     [
1284      #include <dlfcn.h>
1285      #ifdef RTLD_NOW
1286             yes
1287      #endif
1288     ], [
1289       AC_MSG_RESULT(yes)
1290       AC_DEFINE(HAVE_RTLDNOW)
1291       HaveRtldNow=YES
1292     ], [
1293       AC_MSG_RESULT(no)
1294       HaveRtldNow=NO
1295       ])    
1296     AC_SUBST(HaveRtldNow)
1297 fi
1298
1299 dnl --------------------------------------------------
1300 dnl * test for GTK+
1301 dnl --------------------------------------------------
1302
1303 AC_PATH_PROGS([GTK_CONFIG], [gtk-config gtk12-config])
1304 if test -n "$GTK_CONFIG"; then
1305   AC_CACHE_CHECK([for version of GTK+], [fp_cv_gtk_version],
1306     [fp_cv_gtk_version=`$GTK_CONFIG --version`])
1307   FP_COMPARE_VERSIONS([$fp_cv_gtk_version], [-lt], [1.2],
1308     [AC_MSG_WARN([GTK+ not usable, need at least version 1.2])
1309      GTK_CONFIG=])
1310 fi
1311 AC_SUBST([GTK_CONFIG])
1312
1313 dnl --------------------------------------------------
1314 dnl * Miscellaneous feature tests
1315 dnl --------------------------------------------------
1316
1317 dnl ** can we get alloca?
1318 AC_FUNC_ALLOCA
1319
1320 dnl ** Working vfork?
1321 AC_FUNC_FORK
1322
1323 dnl ** determine whether or not const works
1324 AC_C_CONST
1325
1326 dnl ** are we big endian?
1327 AC_C_BIGENDIAN
1328
1329 dnl ** check for leading underscores in symbol names
1330 FP_LEADING_UNDERSCORE
1331
1332 dnl ** check for ld, and whether ld has -x option
1333 AC_PATH_PROG(LdCmdRaw, ld)
1334 case $HostOS_CPP in
1335  mingw32) 
1336         if test "${OSTYPE}" == "msys"
1337            then
1338              LdCmd=${LdCmdRaw}
1339            else
1340              LdCmd=`cygpath -w ${LdCmdRaw} | sed -e 's@\\\\@/@g' `
1341         fi
1342            ;;
1343  *) LdCmd=${LdCmdRaw}
1344     ;;
1345 esac
1346 AC_SUBST(LdCmd)
1347 FPTOOLS_LD_X
1348
1349 AC_CONFIG_FILES([mk/config.mk])
1350 AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp > mk/stamp-h])
1351 AC_OUTPUT