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