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