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