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