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