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