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