[project @ 2004-10-06 06:14:29 by panne]
[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-1998
7 #
8 # Configure script template for the Glasgow functional programming tools
9 #
10 # Process with 'autoconf' 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 s390-ibm-linux*)
410        HostPlatform=s390-ibm-linux
411        TargetPlatform=s390-ibm-linux #hack
412        BuildPlatform=s390-ibm-linux #hack
413         HostPlatform_CPP='s390_ibm_linux'
414         HostArch_CPP='s390'
415         HostVendor_CPP='ibm'
416         HostOS_CPP='linux'
417         ;;
418 sparc-sun-sunos4*)
419         HostPlatform=sparc-sun-sunos4
420         TargetPlatform=sparc-sun-sunos4 #hack
421         BuildPlatform=sparc-sun-sunos4 #hack
422         HostPlatform_CPP='sparc_sun_sunos4'
423         HostArch_CPP='sparc'
424         HostVendor_CPP='sun'
425         HostOS_CPP='sunos4'
426         ;;
427 sparc-sun-solaris2*)
428         HostPlatform=sparc-sun-solaris2
429         TargetPlatform=sparc-sun-solaris2 #hack
430         BuildPlatform=sparc-sun-solaris2 #hack
431         HostPlatform_CPP='sparc_sun_solaris2'
432         HostArch_CPP='sparc'
433         HostVendor_CPP='sun'
434         HostOS_CPP='solaris2'
435         ;;
436 sparc*-linux*)
437         HostPlatform=sparc-unknown-linux
438         TargetPlatform=sparc-unknown-linux
439         BuildPlatform=sparc-unknown-linux
440         HostPlatform_CPP='sparc_unknown_linux'
441         HostArch_CPP='sparc'
442         HostVendor_CPP='unknown'
443         HostOS_CPP='linux'
444         ;;
445 sparc-*-openbsd*)
446         HostPlatform=sparc-unknown-openbsd
447         TargetPlatform=sparc-unknown-openbsd
448         BuildPlatform=sparc-unknown-openbsd
449         HostPlatform_CPP='sparc_unknown_openbsd'
450         HostArch_CPP='sparc'
451         HostVendor_CPP='unknown'
452         HostOS_CPP='openbsd'
453         ;;
454 sparc64-*-openbsd*)
455         HostPlatform=sparc64-unknown-openbsd
456         TargetPlatform=sparc64-unknown-openbsd
457         BuildPlatform=sparc64-unknown-openbsd
458         HostPlatform_CPP='sparc64_unknown_openbsd'
459         HostArch_CPP='sparc64'
460         HostVendor_CPP='unknown'
461         HostOS_CPP='openbsd'
462         ;;
463 vax-*-openbsd*)
464         HostPlatform=vax-unknown-openbsd
465         TargetPlatform=vax-unknown-openbsd
466         BuildPlatform=vax-unknown-openbsd
467         HostPlatform_CPP='vax_unknown_openbsd'
468         HostArch_CPP='vax'
469         HostVendor_CPP='unknown'
470         HostOS_CPP='openbsd'
471         ;;
472 *)
473         echo "Unrecognised platform: $HostPlatform"
474         exit 1
475         ;;
476 esac
477 echo "Canonicalised to: $HostPlatform"
478 test  x"$HostPlatform" != x"$TargetPlatform" && echo "Target platform set to $TargetPlatform"
479 test  x"$BuildPlatform" != x"$HostPlatform"  && echo "Build platform set to $BuildPlatform"
480
481 BuildPlatform_CPP=$HostPlatform_CPP
482 TargetPlatform_CPP=$HostPlatform_CPP
483 BuildArch_CPP=$HostArch_CPP
484 TargetArch_CPP=$HostArch_CPP
485 BuildOS_CPP=$HostOS_CPP
486 HostOS_Full=$host_os
487 TargetOS_CPP=$HostOS_CPP
488 BuildVendor_CPP=$HostVendor_CPP
489 TargetVendor_CPP=$HostVendor_CPP
490
491 AC_SUBST(BuildPlatform)
492 AC_SUBST(HostPlatform)
493 AC_SUBST(TargetPlatform)
494 AC_SUBST(HostPlatform_CPP)
495 AC_SUBST(BuildPlatform_CPP)
496 AC_SUBST(TargetPlatform_CPP)
497
498 AC_SUBST(HostArch_CPP)
499 AC_SUBST(BuildArch_CPP)
500 AC_SUBST(TargetArch_CPP)
501
502 AC_SUBST(HostOS_CPP)
503 AC_SUBST(HostOS_Full)
504 AC_SUBST(BuildOS_CPP)
505 AC_SUBST(TargetOS_CPP)
506
507 AC_SUBST(HostVendor_CPP)
508 AC_SUBST(BuildVendor_CPP)
509 AC_SUBST(TargetVendor_CPP)
510
511 AC_SUBST(exeext)
512
513 dnl --------------------------------------------------------------
514 dnl * Calculate absolute path to build tree
515 dnl --------------------------------------------------------------
516
517 AC_MSG_CHECKING(for path to top of build tree)
518
519 hardtop=`pwd`
520
521 dnl Remove common automounter nonsense
522 dnl
523 hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|' | sed 's|^//\(.\)/|\1:/|' `
524
525 dnl Find 'hardtop_plat', the native format for 'hardtop' 
526 dnl (i.e., right kind of \dnl slashes on a Win32 box, but with b-slashes being escaped).
527 dnl
528 dnl Note OSTYPE: On Cygwin we need to use 'cygpath' to convert /cygdrive/c/foo to c:/foo
529 dnl              but we must not do that if we aren't building using Cygwin (notably msys), 
530 dnl              because cygpath doesn't exist.  It seems that 'bash' sets OSTYPE to 'cygwin' 
531 dnl              or 'msys' respectively, but cygwin's 'sh' does not.  So we hackily assume
532 dnl              that if the shell hasn't set it to 'msys' then we must be in Cygwin.  Sigh.
533 dnl
534 dnl              The Right Thing is probably to test $BuildPlatform instead, but we are sloppy 
535 dnl              about setting that correctly at the moment, so we just work around for now.
536 dnl
537 dnl              The quotes round "$(OSTYPE)" are essential, for the Cygwin-sh case where OSTYPE
538 dnl              is not set.
539 case $HostPlatform in
540   i386-unknown-mingw32 | i386-unknown-cygwin32)
541         if test "${OSTYPE}" != "msys" 
542           then
543             # convert $hardtop to a path that mingw will understand too
544             cyghardtop=${hardtop}
545             hardtop=`cygpath -w ${cyghardtop} | sed -e 's@\\\\@/@g'`
546             hardtop_plat=`cygpath -w ${cyghardtop} | sed -e 's@\\\\@\\\\\\\\@g'`
547           else
548             hardtop_plat=${hardtop}
549         fi
550         ;;
551   *)
552         hardtop_plat=${hardtop}
553         ;;
554 esac
555 AC_SUBST(hardtop)
556 AC_SUBST(hardtop_plat)
557
558 AC_MSG_RESULT(${hardtop})
559
560 dnl --------------------------------------------------------------
561 dnl * Project specific configuration options
562 dnl --------------------------------------------------------------
563 dnl What follows is a bunch of options that can either be configured
564 dnl through command line options to the configure script or by
565 dnl supplying defns in the build tree's mk/build.mk. Having the option to
566 dnl use either is considered a Feature.
567
568 dnl ** What command to use to compile compiler sources ?
569 dnl --------------------------------------------------------------
570
571 AC_ARG_WITH(ghc,
572 [AC_HELP_STRING([--with-ghc=ARG],
573         [Use ARG as the path to GHC  [default=autodetect]])],
574 [ WithGhc="$withval" ],
575
576   if test "$GHC" = ""; then
577     AC_PATH_PROG(GHC,ghc)
578   fi
579   WithGhc=$GHC
580 ])
581 AC_SUBST(WithGhc)
582
583 AC_ARG_WITH(hc,
584 [AC_HELP_STRING([--with-hc=ARG],
585         [Use ARG as the path to the compiler for compiling ordinary
586          Haskell code  (default= value of --with-ghc)])],
587 [WithHc="$withval"],
588 [WithHc=$WithGhc]
589 )
590 AC_SUBST(WithHc)
591
592 if test "$WithGhc" != ""; then
593   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
594   AC_SUBST(GhcVersion)dnl
595   AC_SUBST(GhcMajVersion)dnl
596   AC_SUBST(GhcMinVersion)dnl
597   AC_SUBST(GhcPatchLevel)dnl
598 fi
599
600 AC_PATH_PROGS(NHC,nhc nhc98)
601 AC_PATH_PROG(HBC,hbc)
602
603 dnl ** Which gcc to use?
604 dnl --------------------------------------------------------------
605 AC_ARG_WITH(gcc,
606 [AC_HELP_STRING([--with-gcc=ARG],
607         [Use ARG as the path to GCC  [default=autodetect]])],
608 [WhatGccIsCalled="$withval"
609  if test "x$HostPlatform" = "xi386-unknown-mingw32"
610     then
611        if test "${OSTYPE}" != "msys"
612          then
613          # Canonicalise to <drive>:/path/to/gcc
614          withval=`cygpath -w ${withval} | sed -e 's@\\\\@/@g' `
615        fi
616  fi;
617  CC="$withval"],
618 [WhatGccIsCalled="gcc"]
619 )
620 AC_SUBST(WhatGccIsCalled)
621
622 dnl ** Booting from .hc files?
623 dnl --------------------------------------------------------------
624 AC_ARG_ENABLE(hc-boot,
625 [AC_HELP_STRING([--enable-hc-boot],
626 [Boot the Glasgow Haskell Compiler from intermediate .hc files.
627  (This option is mostly of interest to porters.) [default=no]])],
628 [ if test x"$enableval" = x"yes"; then
629         BootingFromHc=YES
630   else
631         BootingFromHc=NO
632   fi
633 ],
634 [BootingFromHc=NO]
635 )
636 AC_SUBST(BootingFromHc)
637
638 dnl ** Booting from unregisterised .hc files?
639 dnl --------------------------------------------------------------
640 AC_ARG_ENABLE(hc-boot-unregisterised,
641 [AC_HELP_STRING([--enable-hc-boot-unregisterised],
642 [ With --enable-hc-boot, treat the intermediate .hc files as
643  unregisterised rather than registerised code.
644  (This option is mostly of interest to porters.) [default=no]])],
645 [ if test x"$enableval" = x"yes"; then
646         BootingFromUnregisterisedHc=YES
647   else
648         BootingFromUnregisterisedHc=NO
649   fi
650 ],
651 [BootingFromUnregisterisedHc=NO]
652 )
653 AC_SUBST(BootingFromUnregisterisedHc)
654
655 if test "$BootingFromHc" = "NO"; then
656 if test "$BootingFromUnregisterisedHc" = "YES"; then
657 AC_MSG_ERROR([--enable-hc-boot-unregisterised requires --enable-hc-boot.])
658 fi;
659 fi;
660
661 dnl ** Must have GHC to build GHC, unless --enable-hc-boot is on
662 if test "$BootingFromHc" = "NO" -a "$WithGhc" = "" -a -d "$srcdir/ghc"; then
663 AC_MSG_ERROR([GHC is required unless bootstrapping from .hc files.])
664 fi;
665
666 dnl ** --enable-threaded-rts (not used any more)
667 dnl --------------------------------------------------------------
668 AC_ARG_ENABLE(threaded-rts,
669 [AC_HELP_STRING([--enable-threaded-rts],
670 [DEPRECATED (backwards compatibility only). [default=no]])],
671 [ if test x"$enableval" = x"yes"; then
672         ThreadedRts=YES
673   else
674         ThreadedRts=NO
675   fi
676 ],
677 [ThreadedRts=NO]
678 )
679 AC_SUBST(ThreadedRts)
680
681 dnl ** Enable the construction of Win32 DLLs?
682 dnl --------------------------------------------------------------
683 dnl
684 dnl [ The ability to build the RTS and libraries as separate DLLs used
685 dnl   to be supported, but isn't currently (updates to the RTS, compiler 
686 dnl   and build system would be required to bring it back again.)
687 dnl   Hence, exposing it as an option is false advertisement, so better
688 dnl   disable it to avoid confusion (but leave it commented-out rather
689 dnl   than removed in order to remind ourselves to bring back the 
690 dnl   feature at some stage.) ]
691 dnl
692 dnl AC_ARG_ENABLE(win32-dlls,
693 dnl [  --enable-win32-dlls
694 dnl         If on a Win32 platform running mingw32/cygwin, enable the
695 dnl     construction of DLLs containing ghc-compiled code.
696 dnl ],
697 dnl [
698 dnl case $HostOS_CPP in
699 dnl cygwin32) ;;
700 dnl mingw32)  ;;
701 dnl *)    echo "Unrecognised win32 platform: $HostPlatform"
702 dnl       exit 1
703 dnl       ;;
704 dnl esac
705 dnl EnableWin32DLLs=YES
706 dnl ],
707 dnl [EnableWin32DLLs=NO]
708 dnl )
709 dnl AC_SUBST(EnableWin32DLLs)
710 dnl if test x"$EnableWin32DLLs" = "xYES" ; then
711 dnl  AC_DEFINE(HAVE_WIN32_DLL_SUPPORT)
712 dnl fi
713
714 dnl ** Enable the building of the ObjectIO?
715 dnl --------------------------------------------------------------
716 AC_ARG_ENABLE(objectio,
717 [AC_HELP_STRING([--enable-objectio],
718 [Build ObjectIO, a portable GUI library for Haskell. [default=no]])],
719 [ if test x"$enableval" = x"yes"; then
720         GhcLibsWithObjectIO=YES
721   else
722         GhcLibsWithObjectIO=NO
723   fi
724 ],
725 [GhcLibsWithObjectIO=NO]
726 )
727 AC_SUBST(GhcLibsWithObjectIO)
728
729 dnl ** Enable the building of the OpenAL binding?
730 dnl --------------------------------------------------------------
731 AC_ARG_ENABLE([openal],
732   AC_HELP_STRING([--enable-openal],
733                  [Build OpenAL binding [[default=autodetect]]]),
734   [ if test x"$enableval" = x"yes"; then
735         GhcLibsWithOpenAL=YES
736     else
737         GhcLibsWithOpenAL=NO
738     fi
739   ],
740   [GhcLibsWithOpenAL=YES])
741
742 AC_SUBST([GhcLibsWithOpenAL])
743
744 dnl ** .NET interop support?
745 dnl --------------------------------------------------------------
746 AC_ARG_ENABLE(dotnet,
747 [AC_HELP_STRING([--enable-dotnet],
748 [Build .NET interop layer. [default=no]])],
749 [ if test x"$enableval" = x"yes"; then
750         DotnetSupport=YES; AC_DEFINE([WANT_DOTNET_SUPPORT], [1], [Define to 1 if you want to include .NET interop support.])
751   else 
752         DotnetSupport=NO
753   fi],
754 [DotnetSupport=NO]
755 )
756 AC_SUBST(DotnetSupport)
757
758 dnl --------------------------------------------------------------
759 dnl End of configure script option section
760 dnl --------------------------------------------------------------
761
762
763 dnl --------------------------------------------------------------
764 dnl * General configuration checks
765 dnl --------------------------------------------------------------
766
767 dnl ** Can the unix package be built?
768 dnl --------------------------------------------------------------
769
770 if test x"$TargetPlatform" = x"i386-unknown-mingw32"; then
771    GhcLibsWithUnix=NO
772 else
773    GhcLibsWithUnix=YES
774 fi
775 AC_SUBST([GhcLibsWithUnix])
776
777 dnl ** does #! work?
778 AC_SYS_INTERPRETER()
779
780 dnl ** look for `perl', but only in /bin on Windows
781 case $HostOS_CPP in
782 cygwin32|mingw32)
783       AC_CHECK_PROG(PerlCmd,perl,/bin/perl,,/bin)
784       if test -z "$PerlCmd"; then
785          echo "You must install the version of Perl shipped with GHC"
786          echo "(or a compatible one) in /bin."
787          exit 1
788       fi
789    ;;
790 *)
791    AC_PATH_PROG(PerlCmd,perl)
792    if test -z "$PerlCmd"; then
793       echo "You must install perl before you can continue"
794       echo "Perhaps it is already installed, but not in your PATH?"
795       exit 1
796    else
797    FPTOOLS_CHECK_PERL_VERSION
798    fi
799    ;;
800 esac
801
802 dnl ** does #! path/to/perl work? (sometimes it's too long...)
803 FPTOOLS_SHEBANG_PERL
804
805 dnl ** check for Python
806 AC_PATH_PROG(PythonCmd,python)
807
808 dnl ** look for GCC and find out which version
809 dnl     Figure out which C compiler to use.  Gcc is preferred.
810 dnl     If gcc, make sure it's at least 2.1
811 dnl
812 AC_PROG_CC
813 FPTOOLS_HAVE_GCC
814 FPTOOLS_GCC_NEEDS_NO_OMIT_LFPTR
815
816 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
817 AC_PROG_CPP
818
819 dnl ** Without optimization some INLINE trickery fails for GHCi
820 SRC_CC_OPTS="-O"
821
822 dnl ** Try to add -mno-cygwin to the C compiler options
823 FP_CHECK_FLAG([-mno-cygwin], [
824 SRC_CC_OPTS="-mno-cygwin $SRC_CC_OPTS"
825 CPPFLAGS="-mno-cygwin $CPPFLAGS"])
826 AC_SUBST(SRC_CC_OPTS)
827
828 dnl ** figure out how to do context diffs
829 FP_PROG_CONTEXT_DIFF
830
831 dnl ** Find find command (for Win32's benefit)
832 FP_PROG_FIND
833
834 dnl ** figure out how to do a BSD-ish install
835 AC_PROG_INSTALL
836
837 dnl If you can run configure, you certainly have /bin/sh
838 AC_DEFINE([HAVE_BIN_SH], [1], [Define to 1 if you have /bin/sh.])
839
840 dnl ** how to invoke `ar' and `ranlib'
841 FP_PROG_AR_NEEDS_RANLIB
842 FP_PROG_AR_SUPPORTS_INPUT
843
844 dnl ** Check to see whether ln -s works
845 AC_PROG_LN_S
846
847
848 dnl ** Find the path to sed
849 AC_PATH_PROG(SedCmd,sed)
850
851
852 dnl ** check for time command
853 AC_PATH_PROG(TimeCmd,time)
854
855 dnl ** check for tar
856 dnl   if GNU tar is named gtar, look for it first.
857 AC_PATH_PROGS(TarCmd,gtar tar,tar)
858
859 dnl ** check for DocBook toolchain
860 FP_CHECK_DOCBOOK_DTD
861 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])
862 FP_PROG_FO_PROCESSOR
863
864 dnl ** check for ghc-pkg command
865 FP_PROG_GHC_PKG
866
867 AC_ARG_WITH(greencard,
868 [AC_HELP_STRING([--with-greencard=ARG],
869         [Use ARG as the path to greencard  [default=autodetct]])],
870 [
871 GreenCardCmd=$withval;
872 FPTOOLS_GREENCARD(3.00)
873 ]
874 )
875
876 AC_ARG_ENABLE(src-tree-happy,
877 [AC_HELP_STRING([--enable-src-tree-happy],
878         [Build and use source tree (fptools/happy) version of Happy. 
879          [default=autodetect]])],
880 [ if test x"$enableval" = x"yes"; then
881         UseSrcTreeHappy=YES
882   else
883         UseSrcTreeHappy=NO
884   fi
885 ],
886 [UseSrcTreeHappy=NO]
887 )
888 dnl ** check for installed happy binary + version
889 dnl    (don't do it if we're booting from .hc files though.)
890 if test "$BootingFromHc" = "NO"; then
891 FPTOOLS_HAPPY
892 fi;
893
894 AC_ARG_ENABLE(src-tree-haddock,
895 [AC_HELP_STRING([--enable-src-tree-haddock],
896         [Build and use source tree (fptools/haddock) version of Haddock.
897          [default=autodetect]])],
898 [ if test x"$enableval" = x"yes"; then
899         UseSrcTreeHaddock=YES
900   else
901         UseSrcTreeHaddock=NO
902   fi
903 ],
904 [UseSrcTreeHaddock=NO]
905 )
906 dnl ** check for installed haddock
907 FPTOOLS_HADDOCK
908
909 AC_ARG_ENABLE(src-tree-alex,
910 [AC_HELP_STRING([--enable-src-tree-alex],
911         [Build and use source tree (fptools/alex) version of Alex.
912          [default=autodetect]])],
913 [ if test x"$enableval" = x"yes"; then
914         UseSrcTreeAlex=YES
915   else
916         UseSrcTreeAlex=NO
917   fi
918 ],
919 [UseSrcTreeAlex=NO]
920 )
921 dnl ** check for installed alex binary + version
922 dnl    (don't do it if we're booting from .hc files though.)
923 if test "$BootingFromHc" = "NO"; then
924 FPTOOLS_ALEX
925 fi;
926
927 dnl --------------------------------------------------
928 dnl ### program checking section ends here ###
929 dnl --------------------------------------------------
930
931 dnl --------------------------------------------------
932 dnl * Platform header file and syscall feature tests
933 dnl ### checking the state of the local header files and syscalls ###
934
935 dnl ** check for full ANSI header (.h) files
936 AC_HEADER_STDC
937
938 dnl ** Enable large file support.  NB. do this before testing the type of
939 dnl    off_t, because it will affect the result of that test.
940 AC_SYS_LARGEFILE
941
942 dnl ** check for specific header (.h) files that we are interested in
943 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])
944
945 AC_CHECK_HEADER([unistd.h], [AC_CHECK_FUNCS(lchown)])
946
947 AC_CHECK_HEADER([readline/readline.h], [HaveReadlineReadlineH=YES], [HaveReadlineReadlineH=NO])
948 AC_CHECK_HEADER([readline/history.h], [HaveReadlineHistoryH=YES], [HaveReadlineHistoryH=NO])
949
950 if test $HaveReadlineReadlineH = YES && test $HaveReadlineHistoryH = YES ; then
951   GhcLibsWithReadline=YES
952   AC_DEFINE([HAVE_READLINE_HEADERS], [1], [Define to 1 if readline/readline.h and readline/history.h exist.])
953 else
954   GhcLibsWithReadline=NO
955   AC_DEFINE([HAVE_READLINE_HEADERS], [0], [Define to 1 if readline/readline.h and readline/history.h exist.])
956 fi
957 AC_SUBST(GhcLibsWithReadline)
958
959 dnl ** check for OpenGL/GLUT include paths and libraries
960 FP_CHECK_GLUT
961
962 if test x"$no_GLU" = xyes; then
963   GhcLibsWithOpenGL=NO
964 else
965   GhcLibsWithOpenGL=YES
966 fi
967 AC_SUBST([GhcLibsWithOpenGL])
968
969 if test x"$no_GLUT" = xyes; then
970   GhcLibsWithGLUT=NO
971 else
972   GhcLibsWithGLUT=YES
973 fi
974 AC_SUBST([GhcLibsWithGLUT])
975
976 dnl ** check for OpenGL include files
977 fp_save_cppflags="$CPPFLAGS"
978 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
979 if test x"$use_quartz_opengl" = xyes; then
980   AC_CHECK_HEADERS([OpenGL/gl.h])
981 else
982   AC_CHECK_HEADERS([GL/gl.h])
983 fi
984 CPPFLAGS="$fp_save_cppflags"
985
986 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
987 AC_HEADER_TIME
988
989 dnl ** check for POSIX regex
990 HavePosixRegex=NO
991 AC_CHECK_HEADERS([regex.h], [AC_CHECK_FUNCS(regcomp, [HavePosixRegex=YES])])
992 AC_SUBST(HavePosixRegex)
993
994 dnl ** how do we get a timezone name, and UTC offset ?
995 AC_STRUCT_TIMEZONE
996
997 dnl ** do we have altzone?
998 FP_DECL_ALTZONE
999
1000 dnl ** do we have long longs?
1001 AC_CHECK_TYPES([long long])
1002
1003 dnl ** what are the sizes of various types
1004 AC_CHECK_SIZEOF(char,               1)
1005 AC_CHECK_SIZEOF(double,             8)
1006 AC_CHECK_SIZEOF(float,              4)
1007 AC_CHECK_SIZEOF(int,                4)
1008 AC_CHECK_SIZEOF(long,               4)
1009 if test "$ac_cv_type_long_long" = yes; then
1010 AC_CHECK_SIZEOF(long long,          8)
1011 fi
1012 AC_CHECK_SIZEOF(short,              2)
1013 AC_CHECK_SIZEOF(unsigned char,      1)
1014 AC_CHECK_SIZEOF(unsigned int,       4)
1015 AC_CHECK_SIZEOF(unsigned long,      4)
1016 if test "$ac_cv_type_long_long" = yes; then
1017 AC_CHECK_SIZEOF(unsigned long long, 8)
1018 fi
1019 AC_CHECK_SIZEOF(unsigned short,     2)
1020 AC_CHECK_SIZEOF(void *,             4)
1021
1022 dnl ** what are alignment constraints on various types
1023 FP_CHECK_ALIGNMENT(char)
1024 FP_CHECK_ALIGNMENT(double)
1025 FP_CHECK_ALIGNMENT(float)
1026 FP_CHECK_ALIGNMENT(int)
1027 FP_CHECK_ALIGNMENT(long)
1028 if test "$ac_cv_type_long_long" = yes; then
1029 FP_CHECK_ALIGNMENT(long long)
1030 fi
1031 FP_CHECK_ALIGNMENT(short)
1032 FP_CHECK_ALIGNMENT(unsigned char)
1033 FP_CHECK_ALIGNMENT(unsigned int)
1034 FP_CHECK_ALIGNMENT(unsigned long)
1035 if test "$ac_cv_type_long_long" = yes; then
1036 FP_CHECK_ALIGNMENT(unsigned long long)
1037 fi
1038 FP_CHECK_ALIGNMENT(unsigned short)
1039 FP_CHECK_ALIGNMENT(void *)
1040
1041 dnl ** map standard C types and ISO types to Haskell types
1042 FPTOOLS_CHECK_HTYPE(char)
1043 FPTOOLS_CHECK_HTYPE(signed char)
1044 FPTOOLS_CHECK_HTYPE(unsigned char)
1045 FPTOOLS_CHECK_HTYPE(short)
1046 FPTOOLS_CHECK_HTYPE(unsigned short)
1047 FPTOOLS_CHECK_HTYPE(int)
1048 FPTOOLS_CHECK_HTYPE(unsigned int)
1049 FPTOOLS_CHECK_HTYPE(long)
1050 FPTOOLS_CHECK_HTYPE(unsigned long)
1051 if test "$ac_cv_type_long_long" = yes; then
1052 FPTOOLS_CHECK_HTYPE(long long)
1053 FPTOOLS_CHECK_HTYPE(unsigned long long)
1054 fi
1055 FPTOOLS_CHECK_HTYPE(float)
1056 FPTOOLS_CHECK_HTYPE(double)
1057 FPTOOLS_CHECK_HTYPE(ptrdiff_t)
1058 FPTOOLS_CHECK_HTYPE(size_t)
1059 FPTOOLS_CHECK_HTYPE(wchar_t)
1060 dnl Int32 is a HACK for non-ISO C compilers
1061 FPTOOLS_CHECK_HTYPE(sig_atomic_t, Int32)
1062 FPTOOLS_CHECK_HTYPE(clock_t)
1063 FPTOOLS_CHECK_HTYPE(time_t)
1064 FPTOOLS_CHECK_HTYPE(dev_t, Word32)
1065 FPTOOLS_CHECK_HTYPE(ino_t)
1066 FPTOOLS_CHECK_HTYPE(mode_t)
1067 FPTOOLS_CHECK_HTYPE(off_t)
1068 FPTOOLS_CHECK_HTYPE(pid_t)
1069 FPTOOLS_CHECK_HTYPE(gid_t)
1070 FPTOOLS_CHECK_HTYPE(uid_t)
1071 FPTOOLS_CHECK_HTYPE(cc_t)
1072 FPTOOLS_CHECK_HTYPE(speed_t)
1073 FPTOOLS_CHECK_HTYPE(tcflag_t)
1074 FPTOOLS_CHECK_HTYPE(blkcnt_t)
1075 FPTOOLS_CHECK_HTYPE(nlink_t)
1076 FPTOOLS_CHECK_HTYPE(ssize_t)
1077 FPTOOLS_CHECK_HTYPE(rlim_t)
1078 FPTOOLS_CHECK_HTYPE(wint_t)
1079
1080 dnl ** Map OpenGL data types to Haskell types
1081 if test $GhcLibsWithOpenGL = YES ; then
1082 FPTOOLS_CHECK_HTYPE(GLboolean)
1083 FPTOOLS_CHECK_HTYPE(GLbyte)
1084 FPTOOLS_CHECK_HTYPE(GLubyte)
1085 FPTOOLS_CHECK_HTYPE(GLshort)
1086 FPTOOLS_CHECK_HTYPE(GLushort)
1087 FPTOOLS_CHECK_HTYPE(GLint)
1088 FPTOOLS_CHECK_HTYPE(GLuint)
1089 FPTOOLS_CHECK_HTYPE(GLsizei)
1090 FPTOOLS_CHECK_HTYPE(GLenum)
1091 FPTOOLS_CHECK_HTYPE(GLbitfield)
1092 FPTOOLS_CHECK_HTYPE(GLfloat)
1093 FPTOOLS_CHECK_HTYPE(GLclampf)
1094 FPTOOLS_CHECK_HTYPE(GLdouble)
1095 FPTOOLS_CHECK_HTYPE(GLclampd)
1096 fi
1097
1098 FP_CHECK_CONSTS([E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EADV EAFNOSUPPORT EAGAIN EALREADY EBADF EBADMSG EBADRPC EBUSY ECHILD ECOMM ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ EDIRTY EDOM EDQUOT EEXIST EFAULT EFBIG EFTYPE EHOSTDOWN EHOSTUNREACH EIDRM EILSEQ EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE EMULTIHOP ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODATA ENODEV ENOENT ENOEXEC ENOLCK ENOLINK ENOMEM ENOMSG ENONET ENOPROTOOPT ENOSPC ENOSR ENOSTR ENOSYS ENOTBLK ENOTCONN ENOTDIR ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM EPFNOSUPPORT EPIPE EPROCLIM EPROCUNAVAIL EPROGMISMATCH EPROGUNAVAIL EPROTO EPROTONOSUPPORT EPROTOTYPE ERANGE EREMCHG EREMOTE EROFS ERPCMISMATCH ERREMOTE ESHUTDOWN ESOCKTNOSUPPORT ESPIPE ESRCH ESRMNT ESTALE ETIME ETIMEDOUT ETOOMANYREFS ETXTBSY EUSERS EWOULDBLOCK EXDEV], [#include <stdio.h>
1099 #include <errno.h>])
1100
1101 dnl ** can we open files in binary mode?
1102 FP_CHECK_CONST([O_BINARY], [#include <fcntl.h>], [0])
1103
1104 FP_CHECK_FUNC([WinExec],
1105   [@%:@include <windows.h>], [WinExec("",0)])
1106
1107 FP_CHECK_FUNC([GetModuleFileName],
1108   [@%:@include <windows.h>], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
1109
1110 dnl ** check return type of signal handlers
1111 dnl Foo: assumes we can use prototypes.
1112 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
1113 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
1114 dnl [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1115 dnl #include <signal.h>
1116 dnl #ifdef signal
1117 dnl #undef signal
1118 dnl #endif
1119 dnl void (*signal (int, void (*)(int)))(int);
1120 dnl ]],
1121 dnl [[int i;]])],
1122 dnl [ac_cv_type_signal_handler=void_int],
1123 dnl [ac_cv_type_signal_handler=int_void])])
1124 dnl if test "$ac_cv_type_signal_handler" = void_int; then
1125 dnl AC_DEFINE(VOID_INT_SIGNALS)
1126 dnl fi
1127
1128 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
1129 AC_TYPE_SIGNAL
1130 if test "$ac_cv_type_signal" = void; then
1131   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).])
1132 fi
1133
1134 dnl ** check for more functions
1135 AC_CHECK_FUNCS([ftime getclock getgrgid_r getgrnam_r getpagesize getpwnam_r getpwuid_r getpwnam getpwuid getrusage gettimeofday gmtime_r localtime_r lstat readdir_r readlink setenv setitimer siginterrupt symlink sysconf times unsetenv])
1136
1137 dnl ** Solaris2 needs additionl flag for getpw*_r()
1138 case "$TargetPlatform" in
1139   *-solaris2*)
1140     unix_SRC_HSC2HS_OPTS="-D_POSIX_PTHREAD_SEMANTICS"
1141     AC_SUBST(unix_SRC_HSC2HS_OPTS)
1142   ;;
1143 esac
1144
1145 dnl ** check whether this machine has gmp3 installed
1146 AC_CHECK_LIB(gmp,  __gmpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
1147   AC_CHECK_LIB(gmp3, __gmpz_fdiv_qr,  HaveLibGmp=YES; LibGmp=gmp3,
1148     HaveLibGmp=NO; LibGmp=not-installed))
1149 AC_SUBST(HaveLibGmp)
1150 AC_SUBST(LibGmp)
1151
1152 dnl ** (Mac OS X only: check for HaskellSupport.framework)
1153 HaveFrameworkHaskellSupport=NO
1154 if test $HostPlatform = "powerpc-apple-darwin"; then
1155  AC_MSG_CHECKING([for HaskellSupport.framework])
1156  save_libs="$LIBS"
1157  LIBS="-framework HaskellSupport"
1158  AC_TRY_LINK_FUNC(__gmpz_fdiv_qr, HaveFrameworkHaskellSupport=YES,)
1159  if test $HaveFrameworkHaskellSupport = YES; then
1160   AC_DEFINE([HAVE_FRAMEWORK_HASKELLSUPPORT], [1], [Define to 1 if the HaskellSupport.framework is installed (Mac OS X only).])
1161  fi;
1162  LIBS="$save_libs"
1163  AC_MSG_RESULT([$HaveFrameworkHaskellSupport])
1164 fi;
1165 AC_SUBST(HaveFrameworkHaskellSupport)
1166
1167 dnl ** check for mingwex library
1168 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
1169 AC_SUBST(HaveLibMingwEx)
1170
1171 if test $HaveLibMingwEx = YES ; then
1172   AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.])
1173 fi
1174
1175 if test "$HaveLibGmp" = "NO"; then
1176 if test "$HostArch_CPP" = "ia64" -o "$HostArch_CPP" = "mipseb" ; then
1177 AC_MSG_ERROR([You need to install libgmp (the in-tree version does not work on IA64 or mips64).])
1178 fi;
1179 fi;
1180
1181 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
1182 dnl    the order of these tests matters: bfd needs liberty
1183 AC_CHECK_LIB(iberty, xmalloc)
1184 AC_CHECK_LIB(bfd,    bfd_init)
1185
1186 dnl ** check for wide-char classifications
1187 dnl FreeBSD has an emtpy wctype.h, so test one of the affected
1188 dnl functions if it's really there.
1189 AC_CHECK_HEADERS([wctype.h], [AC_CHECK_FUNCS(iswspace)])
1190
1191 dnl ** check for readline, for Hugs and hslibs' Readline
1192 dnl ncurses supersedes termcap and curses, but for compatibility,
1193 dnl we have to check for all...
1194 AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=YES; LibTermcap=ncurses,
1195   AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=YES; LibTermcap=termcap,
1196     AC_CHECK_LIB(curses, tputs, HaveLibTermcap=YES; LibTermcap=curses,
1197       HaveLibTermcap=NO; LibTermcap=not-installed)))
1198
1199 if test $HaveLibTermcap = YES ; then
1200   LIBS="-l$LibTermcap $LIBS"
1201   AC_CHECK_LIB(readline, readline, HaveLibReadline=YES, HaveLibReadline=NO)
1202 fi
1203
1204 if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES ; then
1205   AC_DEFINE([HAVE_READLINE_LIBS], [1], [Define to 1 if readline plus any additional libs needed for it exist.])
1206   LibsReadline="readline $LibTermcap"
1207 else
1208   AC_DEFINE([HAVE_READLINE_LIBS], [0], [Define to 1 if readline plus any additional libs needed for it exist.])
1209   LibsReadline=
1210 fi
1211 AC_SUBST(LibsReadline)
1212
1213 if test "$HaveLibReadline"; then
1214   AC_CHECK_LIB(readline, rl_erase_empty_line,
1215     [AC_DEFINE([HAVE_READLINE_4], [1], [Define to 1 if readline has version >= 4.0.])],
1216     [AC_DEFINE([HAVE_READLINE_4], [0], [Define to 1 if readline has version >= 4.0.])])
1217   AC_CHECK_LIB(readline, rl_free_undo_list,
1218     [AC_DEFINE([HAVE_READLINE_4_2], [1], [Define to 1 if readline has version >= 4.2.])],
1219     [AC_DEFINE([HAVE_READLINE_4_2], [0], [Define to 1 if readline has version >= 4.2.])])
1220 else
1221   AC_DEFINE([HAVE_READLINE_4], [0], [Define to 1 if readline has version >= 4.0.])
1222   AC_DEFINE([HAVE_READLINE_4_2], [0], [Define to 1 if readline has version >= 4.2.])
1223 fi
1224
1225 dnl ** check for math library
1226 AC_CHECK_LIB([m], [atan], [LIBS="-lm $LIBS"; LIBM="-lm"], [LIBM=])
1227 AC_SUBST([LIBM])
1228
1229 dnl ** check for X Window System
1230 AC_PATH_XTRA()
1231
1232 if test "$no_x" = yes; then
1233   GhcLibsWithX11=NO
1234 else
1235   GhcLibsWithX11=YES
1236 fi
1237 AC_SUBST([GhcLibsWithX11])
1238
1239 dnl ################################################################
1240 dnl Check for libraries
1241 dnl ################################################################
1242
1243 dnl ** check for libdl & RTLD_NEXT
1244
1245 dnl (Mac OS X only) ... but don't check if we already have the
1246 dnl HaskellSupport.framework
1247
1248 if test $HaveFrameworkHaskellSupport = YES; then
1249     HaveLibDL=NO
1250     HaveRtldNext=NO
1251     HaveRtldLocal=YES
1252     AC_DEFINE([HAVE_RTLDLOCAL], [1], [Define to 1 if RTLD_LOCAL is available.])
1253     HaveRtldGlobal=YES
1254     AC_DEFINE([HAVE_RTLDGLOBAL], [1], [Define to 1 if RTLD_GLOBAL is available.])
1255     HaveRtldNow=YES
1256     AC_DEFINE([HAVE_RTLDNOW], [1], [Define to 1 if we can see RTLD_NOW in dlfcn.h.])
1257     AC_SUBST(HaveLibDL)
1258     AC_SUBST(HaveRtldNext)
1259     AC_SUBST(HaveRtldLocal)
1260     AC_SUBST(HaveRtldGlobal)
1261     AC_SUBST(HaveRtldNow)
1262 else
1263     AC_CHECK_LIB(dl, dlopen, 
1264         [HaveLibDL=YES
1265          AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if you need -ldl to get dlopen().])
1266          LIBS="$LIBS -ldl"], 
1267         [HaveLibDL=NO])
1268     AC_SUBST(HaveLibDL)
1269
1270     dnl ** sometimes RTLD_NEXT is hidden in #ifdefs we really don't wan to set
1271     AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h)
1272     AC_EGREP_CPP(yes,
1273     [
1274      #include <dlfcn.h>
1275      #ifdef RTLD_NEXT
1276             yes
1277      #endif
1278     ], [
1279       AC_MSG_RESULT(yes)
1280       AC_DEFINE([HAVE_RTLDNEXT], [1], [Define to 1 if we can see RTLD_NEXT in dlfcn.h.])
1281       HaveRtldNext=YES
1282     ], [
1283       AC_MSG_RESULT(no)
1284       HaveRtldNext=NO
1285       ])    
1286     AC_SUBST(HaveRtldNext)
1287
1288     dnl ** RTLD_LOCAL isn't available on cygwin or openbsd
1289     AC_MSG_CHECKING(for RTLD_LOCAL from dlfcn.h)
1290     AC_EGREP_CPP(yes,
1291     [
1292      #include <dlfcn.h>
1293      #ifdef RTLD_LOCAL
1294             yes
1295      #endif
1296     ], [
1297       AC_MSG_RESULT(yes)
1298       AC_DEFINE(HAVE_RTLDLOCAL)
1299       HaveRtldLocal=YES
1300     ], [
1301       AC_MSG_RESULT(no)
1302       HaveRtldLocal=NO
1303       ])    
1304     AC_SUBST(HaveRtldLocal)
1305
1306     dnl ** RTLD_GLOBAL isn't available on openbsd
1307     AC_MSG_CHECKING(for RTLD_GLOBAL from dlfcn.h)
1308     AC_EGREP_CPP(yes,
1309     [
1310      #include <dlfcn.h>
1311      #ifdef RTLD_GLOBAL
1312             yes
1313      #endif
1314     ], [
1315       AC_MSG_RESULT(yes)
1316       AC_DEFINE(HAVE_RTLDGLOBAL)
1317       HaveRtldGlobal=YES
1318     ], [
1319       AC_MSG_RESULT(no)
1320       HaveRtldGlobal=NO
1321       ])    
1322     AC_SUBST(HaveRtldGlobal)
1323
1324     dnl ** RTLD_NOW isn't available on openbsd
1325     AC_MSG_CHECKING(for RTLD_NOW from dlfcn.h)
1326     AC_EGREP_CPP(yes,
1327     [
1328      #include <dlfcn.h>
1329      #ifdef RTLD_NOW
1330             yes
1331      #endif
1332     ], [
1333       AC_MSG_RESULT(yes)
1334       AC_DEFINE(HAVE_RTLDNOW)
1335       HaveRtldNow=YES
1336     ], [
1337       AC_MSG_RESULT(no)
1338       HaveRtldNow=NO
1339       ])    
1340     AC_SUBST(HaveRtldNow)
1341 fi
1342
1343 dnl ---------- usleep ----------
1344 dnl --- stolen from guile configure ---
1345 dnl --- FIXME: /usr/include/unistd.h can't be right?
1346
1347 ### On some systems usleep has no return value.  If it does have one,
1348 ### we'd like to return it; otherwise, we'll fake it.
1349 AC_CACHE_CHECK([return type of usleep], cv_func_usleep_return_type,
1350   [AC_EGREP_HEADER(changequote(<, >)<void[      ]+usleep>changequote([, ]),
1351                    /usr/include/unistd.h,
1352                    [cv_func_usleep_return_type=void],
1353                    [cv_func_usleep_return_type=int])])
1354 case "$cv_func_usleep_return_type" in
1355   "void" )
1356     AC_DEFINE([USLEEP_RETURNS_VOID], [1], [Define if the system headers declare usleep to return void.])
1357   ;;
1358 esac
1359
1360 dnl --------------------------------------------------
1361 dnl * test for GTK+
1362 dnl --------------------------------------------------
1363
1364 AC_PATH_PROGS([GTK_CONFIG], [gtk-config gtk12-config])
1365 if test -n "$GTK_CONFIG"; then
1366   AC_CACHE_CHECK([for version of GTK+], [fp_cv_gtk_version],
1367     [fp_cv_gtk_version=`$GTK_CONFIG --version`])
1368   FP_COMPARE_VERSIONS([$fp_cv_gtk_version], [-lt], [1.2],
1369     [AC_MSG_WARN([GTK+ not usable, need at least version 1.2])
1370      GTK_CONFIG=])
1371 fi
1372 AC_SUBST([GTK_CONFIG])
1373
1374 dnl --------------------------------------------------
1375 dnl * Miscellaneous feature tests
1376 dnl --------------------------------------------------
1377
1378 dnl ** can we get alloca?
1379 AC_FUNC_ALLOCA
1380
1381 dnl ** Working vfork?
1382 AC_FUNC_FORK
1383
1384 dnl ** determine whether or not const works
1385 AC_C_CONST
1386
1387 dnl ** are we big endian?
1388 AC_C_BIGENDIAN
1389
1390 dnl ** check for leading underscores in symbol names
1391 FP_LEADING_UNDERSCORE
1392
1393 dnl ** check for ld, and whether ld has -x option
1394 AC_PATH_PROG(LdCmdRaw, ld)
1395 case $HostOS_CPP in
1396  mingw32) 
1397         if test "${OSTYPE}" == "msys"
1398            then
1399              LdCmd=${LdCmdRaw}
1400            else
1401              LdCmd=`cygpath -w ${LdCmdRaw} | sed -e 's@\\\\@/@g' `
1402         fi
1403            ;;
1404  *) LdCmd=${LdCmdRaw}
1405     ;;
1406 esac
1407 AC_SUBST(LdCmd)
1408 FPTOOLS_LD_X
1409
1410 FP_EMPTY_STRUCTS
1411
1412 AC_CONFIG_FILES([mk/config.mk])
1413 AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp > mk/stamp-h])
1414 AC_OUTPUT