[project @ 2002-07-12 01:28:10 by chak]
[ghc-hetmet.git] / configure.in
1 dnl == autoconf source for the Glasgow FP tools ==
2 dnl (run "grep '^dnl \*' configure.in | 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-1998
7 #
8 # Configure script template for the Glasgow functional programming tools
9 #
10 # Process with 'autoconf' 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 # First off, a distrib sanity check..
17 AC_INIT(mk/config.mk.in)
18
19 dnl * Declare subdirectories that have a private configure script
20 dnl
21 dnl After the toplevel configuration is complete, the script will recurse into
22 dnl these subdirectories (the use of cache values makes repeated checks cheap)
23 dnl (We probably have to add hslibs/{OpenGL,GLUT} here later...)
24 AC_CONFIG_SUBDIRS(ghc)
25
26 # -------------------------------------------------------------------------
27 # Prepare to generate the following header files
28 #
29 #
30 AC_CONFIG_HEADER(mk/config.h)
31
32 # No, semi-sadly, we don't do `--srcdir'...
33 if test x"$srcdir" != 'x.' ; then
34     echo "This configuration does not support the \`--srcdir' option.."
35     exit 1
36 fi
37
38 #
39 # Remove common automounter nonsense + convert from UNC to DOS style paths
40 # (UNC awareness isn't quite there yet for cygwin32-beta18 and consituent tools.)
41 #
42 hardtop=`pwd`
43 hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|' | sed 's|^/grasp_tmp|/local/grasp_tmp|' | sed 's|^//\(.\)/|\1:/|' `
44
45 echo ''
46 echo "*** The top of your build tree is: $hardtop"
47 # subst of hardtop is done below after we've computed hardtop_plat.
48
49 dnl--------------------------------------------------------------------
50 dnl * Choose host(/target/build) platform
51 dnl--------------------------------------------------------------------
52
53 dnl Guess host/target/build platform(s) if necessary.
54 AC_CANONICAL_SYSTEM
55
56 # "$host" defaults to "$target"
57 if test "x$host" = xNONE ; then
58     host=$target
59 fi
60
61 dnl ** canonicalize platform names
62 BuildPlatform=`/bin/sh $srcdir/config.sub $build` || exit 1
63 HostPlatform=`/bin/sh $srcdir/config.sub $host` || exit 1
64 TargetPlatform=`/bin/sh $srcdir/config.sub $target` || exit 1
65
66 if test x"$TargetPlatform" != x"$HostPlatform" ; then
67     echo "GHC configuration does not support differing host/target (i.e., cross-compiling)"
68     exit 1
69 fi
70
71 exeext=''
72 #
73 # The following will be more difficult when we *are* cross-compiling.
74 # Suitable names to slam in *_CPP are in platform.h.in.
75 # We also record the architecture, vendor, and operating system (OS)
76 # separately.
77 case $HostPlatform in
78 alpha*-dec-osf[[12]]*)
79         HostPlatform=alpha-dec-osf1   # canonicalise for our purposes
80         TargetPlatform=alpha-dec-osf1 # this will work for now... (hack)
81         BuildPlatform=alpha-dec-osf1  # hack
82         HostPlatform_CPP='alpha_dec_osf1'
83         HostArch_CPP='alpha'
84         HostVendor_CPP='dec'
85         HostOS_CPP='osf1'
86         ;;
87 alpha*-dec-osf[[345]]*)
88         HostPlatform=alpha-dec-osf3   # canonicalise for our purposes
89         TargetPlatform=alpha-dec-osf3 # this will work for now... (hack)
90         BuildPlatform=alpha-dec-osf3  # hack
91         HostPlatform_CPP='alpha_dec_osf3'
92         HostArch_CPP='alpha'
93         HostVendor_CPP='dec'
94         HostOS_CPP='osf3'
95         ;;
96 alpha*-unknown-linux)
97         HostPlatform=alpha-unknown-linux
98         TargetPlatform=alpha-unknown-linux
99         BuildPlatform=alpha-unknown-linux
100         HostPlatform_CPP='alpha_unknown_linux'
101         HostArch_CPP='alpha'
102         HostVendor_CPP='unknown'
103         HostOS_CPP='linux'
104         ;;
105 alpha*-unknown-freebsd*)
106         HostPlatform=alpha-unknown-freebsd
107         TargetPlatform=alpha-unknown-freebsd
108         BuildPlatform=alpha-unknown-freebsd
109         HostPlatform_CPP='alpha_unknown_freebsd'
110         HostArch_CPP='alpha'
111         HostVendor_CPP='unknown'
112         HostOS_CPP='freebsd'
113         ;;
114 hppa1.1-hp-hpux*)
115         HostPlatform=hppa1.1-hp-hpux  # canonicalise for our purposes (hack)
116         TargetPlatform=hppa1.1-hp-hpux
117         BuildPlatform=hppa1.1-hp-hpux
118         HostPlatform_CPP='hppa1_1_hp_hpux'
119         HostArch_CPP='hppa1_1'
120         HostVendor_CPP='hp'
121         HostOS_CPP='hpux'
122         ;;
123 i[[3456]]86-*-linuxaout*)
124         HostPlatform=i386-unknown-linuxaout   # hack again
125         TargetPlatform=i386-unknown-linuxaout
126         BuildPlatform=i386-unknown-linuxaout
127         HostPlatform_CPP='i386_unknown_linuxaout'
128         HostArch_CPP='i386'
129         HostVendor_CPP='unknown'
130         HostOS_CPP='linuxaout'
131         ;;
132 i[[3456]]86-*-linux*)
133         HostPlatform=i386-unknown-linux # hack again
134         TargetPlatform=i386-unknown-linux
135         BuildPlatform=i386-unknown-linux
136         HostPlatform_CPP='i386_unknown_linux'
137         HostArch_CPP='i386'
138         HostVendor_CPP='unknown'
139         HostOS_CPP='linux'
140         ;;
141 i[[3456]]86-*-freebsd[[3-9]]*) # FreeBSD 3.0+ uses ELF
142         HostPlatform=i386-unknown-freebsd # hack again
143         TargetPlatform=i386-unknown-freebsd
144         BuildPlatform=i386-unknown-freebsd
145         HostPlatform_CPP='i386_unknown_freebsd'
146         HostArch_CPP='i386'
147         HostVendor_CPP='unknown'
148         HostOS_CPP='freebsd'
149         ;;
150 i[[3456]]86-*-freebsd2*) # Older FreeBSDs are a.out
151         HostPlatform=i386-unknown-freebsd2 # hack again
152         TargetPlatform=i386-unknown-freebsd2
153         BuildPlatform=i386-unknown-freebsd2
154         HostPlatform_CPP='i386_unknown_freebsd2'
155         HostArch_CPP='i386'
156         HostVendor_CPP='unknown'
157         HostOS_CPP='freebsd2'
158         ;;
159 i[[3456]]86-*-netbsd*)
160         HostPlatform=i386-unknown-netbsd # hack again
161         TargetPlatform=i386-unknown-netbsd
162         BuildPlatform=i386-unknown-netbsd
163         HostPlatform_CPP='i386_unknown_netbsd'
164         HostArch_CPP='i386'
165         HostVendor_CPP='unknown'
166         HostOS_CPP='netbsd'
167         ;;
168 i[[3456]]86-*-openbsd*)
169         HostPlatform=i386-unknown-openbsd # hack again
170         TargetPlatform=i386-unknown-openbsd
171         BuildPlatform=i386-unknown-openbsd
172         HostPlatform_CPP='i386_unknown_openbsd'
173         HostArch_CPP='i386'
174         HostVendor_CPP='unknown'
175         HostOS_CPP='openbsd'
176         ;;
177 i[[3456]]86-*-solaris2*)
178         HostPlatform=i386-unknown-solaris2 # hack again
179         TargetPlatform=i386-unknown-solaris2
180         BuildPlatform=i386-unknown-solaris2
181         HostPlatform_CPP='i386_unknown_solaris2'
182         HostArch_CPP='i386'
183         HostVendor_CPP='unknown'
184         HostOS_CPP='solaris2'
185         ;;
186 i[[3456]]86-*-cygwin*)
187         HostPlatform=i386-unknown-cygwin32 # hack again
188         TargetPlatform=i386-unknown-cygwin32
189         BuildPlatform=i386-unknown-cygwin32
190         HostPlatform_CPP='i386_unknown_cygwin32'
191         HostArch_CPP='i386'
192         HostVendor_CPP='unknown'
193         HostOS_CPP='cygwin32'
194         exeext='.exe'
195         ;;
196 i[[3456]]86-*-mingw32*)
197         HostPlatform=i386-unknown-mingw32 # hack again
198         TargetPlatform=i386-unknown-mingw32
199         BuildPlatform=i386-unknown-mingw32
200         HostPlatform_CPP='i386_unknown_mingw32'
201         HostArch_CPP='i386'
202         HostVendor_CPP='unknown'
203         HostOS_CPP='mingw32'
204         exeext='.exe'
205         ;;
206 ia64-*-linux*)
207         HostPlatform=ia64-unknown-linux # hack again
208         TargetPlatform=ia64-unknown-linux
209         BuildPlatform=ia64-unknown-linux
210         HostPlatform_CPP='ia64_unknown_linux'
211         HostArch_CPP='ia64'
212         HostVendor_CPP='unknown'
213         HostOS_CPP='linux'
214         ;;
215 m68k-next-nextstep2)
216         HostPlatform_CPP='m68k_next_nextstep2'
217         HostArch_CPP='m68k'
218         HostVendor_CPP='next'
219         HostOS_CPP='nextstep2'
220         ;;
221 m68k-next-nextstep3)
222         HostPlatform_CPP='m68k_next_nextstep3'
223         HostArch_CPP='m68k'
224         HostVendor_CPP='next'
225         HostOS_CPP='nextstep3'
226         ;;
227 i[[3456]]86-next-nextstep3)
228         HostPlatform=i386-next-nextstep3 # hack again
229         TargetPlatform=i386-next-nextstep3
230         BuildPlatform=i386-next-nextstep3
231         HostPlatform_CPP='i386_next_nextstep3'
232         HostArch_CPP='i386'
233         HostVendor_CPP='next'
234         HostOS_CPP='nextstep3'
235         ;;
236 m68k-sun-sunos4*)
237         HostPlatform=m68k-sun-sunos4
238         TargetPlatform=m68k-sun-sunos4 #hack
239         BuildPlatform=m68k-sun-sunos4 #hack
240         HostPlatform_CPP='m68k_sun_sunos4'
241         HostArch_CPP='m68k'
242         HostVendor_CPP='sun'
243         HostOS_CPP='sunos4'
244         ;;
245 mips-dec-ultrix*)
246         HostPlatform_CPP='mips_dec_ultrix'
247         HostArch_CPP='mipsel'   # NB a little different
248         HostVendor_CPP='dec'
249         HostOS_CPP='ultrix'
250         ;;
251 mips-sgi-irix*)
252         HostPlatform=mips-sgi-irix
253         TargetPlatform=mips-sgi-irix #hack
254         BuildPlatform=mips-sgi-irix #hack
255         HostPlatform_CPP='mips_sgi_irix'
256         HostArch_CPP='mipseb'   # NB a little different
257         HostVendor_CPP='sgi'
258         HostOS_CPP='irix'
259         ;;
260 rs6000-ibm-aix*)
261         HostPlatform=rs6000-ibm-aix
262         TargetPlatform=rs6000-ibm-aix #hack
263         BuildPlatform=rs6000-ibm-aix #hack
264         HostPlatform_CPP='rs6000_ibm_aix'
265         HostArch_CPP='rs6000'
266         HostVendor_CPP='ibm'
267         HostOS_CPP='aix'
268         ;;
269 powerpc-ibm-aix*)
270         HostPlatform=powerpc-ibm-aix
271         TargetPlatform=powerpc-ibm-aix #hack
272         BuildPlatform=powerpc-ibm-aix #hack
273         HostPlatform_CPP='powerpc_ibm_aix'
274         HostArch_CPP='powerpc'
275         HostVendor_CPP='ibm'
276         HostOS_CPP='aix'
277         ;;
278 powerpc-apple-darwin*)
279         HostPlatform=powerpc-apple-darwin
280         TargetPlatform=powerpc-apple-darwin #hack
281         BuildPlatform=powerpc-apple-darwin #hack
282         HostPlatform_CPP='powerpc_apple_darwin'
283         HostArch_CPP='powerpc'
284         HostVendor_CPP='apple'
285         HostOS_CPP='darwin'
286         ;;
287 sparc-sun-sunos4*)
288         HostPlatform=sparc-sun-sunos4
289         TargetPlatform=sparc-sun-sunos4 #hack
290         BuildPlatform=sparc-sun-sunos4 #hack
291         HostPlatform_CPP='sparc_sun_sunos4'
292         HostArch_CPP='sparc'
293         HostVendor_CPP='sun'
294         HostOS_CPP='sunos4'
295         ;;
296 sparc-sun-solaris2*)
297         HostPlatform=sparc-sun-solaris2
298         TargetPlatform=sparc-sun-solaris2 #hack
299         BuildPlatform=sparc-sun-solaris2 #hack
300         HostPlatform_CPP='sparc_sun_solaris2'
301         HostArch_CPP='sparc'
302         HostVendor_CPP='sun'
303         HostOS_CPP='solaris2'
304         ;;
305 *)
306         echo "Unrecognised platform: $HostPlatform"
307         exit 1
308         ;;
309 esac
310 echo "Canonicalised to: $HostPlatform"
311 test  x"$HostPlatform" != x"$TargetPlatform" && echo "Target platform set to $TargetPlatform"
312 test  x"$BuildPlatform" != x"$HostPlatform"  && echo "Build platform set to $BuildPlatform"
313
314 BuildPlatform_CPP=$HostPlatform_CPP
315 TargetPlatform_CPP=$HostPlatform_CPP
316 BuildArch_CPP=$HostArch_CPP
317 TargetArch_CPP=$HostArch_CPP
318 BuildOS_CPP=$HostOS_CPP
319 HostOS_Full=$host_os
320 TargetOS_CPP=$HostOS_CPP
321 BuildVendor_CPP=$HostVendor_CPP
322 TargetVendor_CPP=$HostVendor_CPP
323
324 dnl Cannot afford all these SUBSTs (because of braindead seds w/ 99 cmd limits)
325 dnl AC_SUBST(BuildPlatform)
326
327 AC_SUBST(HostPlatform)
328 AC_SUBST(TargetPlatform)
329 AC_SUBST(HostPlatform_CPP)
330 dnl AC_SUBST(BuildPlatform_CPP)
331 dnl AC_SUBST(TargetPlatform_CPP)
332
333 AC_SUBST(HostArch_CPP)
334 dnl AC_SUBST(BuildArch_CPP)
335 dnl AC_SUBST(TargetArch_CPP)
336
337 AC_SUBST(HostOS_CPP)
338 AC_SUBST(HostOS_Full)
339 dnl AC_SUBST(BuildOS_CPP)
340 dnl AC_SUBST(TargetOS_CPP)
341
342 AC_SUBST(HostVendor_CPP)
343 dnl AC_SUBST(BuildVendor_CPP)
344 dnl AC_SUBST(TargetVendor_CPP)
345
346 AC_SUBST(exeext)
347
348 #
349 # The native format for 'hardtop' (i.e., right kind of slashes on a Win32 box).
350 # (but with b-slashes being escaped).
351 case $HostPlatform in
352   i386-unknown-mingw32 | i386-unknown-cygwin32)
353         # get rid off /cygdrive/ prefix
354         hardtop=`echo ${hardtop} | sed -e 's%^/cygdrive/\(.\)/%\1:/%' `
355         hardtop_plat=`cygpath -w ${hardtop} | sed -e 's@\\\\@\\\\\\\\@g' `
356         ;;
357   *)
358         hardtop_plat=${hardtop}
359         ;;
360 esac
361 AC_SUBST(hardtop)
362 AC_SUBST(hardtop_plat)
363
364 dnl --------------------------------------------------------------
365 dnl * Project specific configuration options
366 dnl --------------------------------------------------------------
367 dnl What follows is a bunch of options that can either be configured
368 dnl through command line options to the configure script or by
369 dnl supplying defns in the build tree's mk/build.mk. Having the option to
370 dnl use either is considered a Feature.
371
372 dnl ** What command to use to compile compiler sources ?
373 dnl --------------------------------------------------------------
374
375 AC_ARG_WITH(ghc,
376 [  --with-ghc=<haskell compiler>
377         Use a command different from 'ghc' to compile GHC-specific Haskell code
378             (including GHC itself).
379 ],
380 [ WithGhc="$withval" ],
381
382   if test "$GHC" = ""; then
383     AC_PATH_PROG(GHC,ghc)
384   fi
385   WithGhc=$GHC
386 ]
387 )
388 AC_SUBST(WithGhc)
389
390 AC_ARG_WITH(hc,
391 [  --with-hc=<haskell compiler>
392         Use a command different from 'ghc' to compile generic Haskell code.
393 ],
394 [WithHc="$withval"],
395 [WithHc=$WithGhc]
396 )
397 AC_SUBST(WithHc)
398
399 if test "$WithGhc" != ""; then
400   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
401   AC_SUBST(GhcVersion)dnl
402   AC_SUBST(GhcMajVersion)dnl
403   AC_SUBST(GhcMinVersion)dnl
404   AC_SUBST(GhcPatchLevel)dnl
405 fi
406
407 AC_PATH_PROGS(NHC,nhc nhc98)
408 AC_PATH_PROG(HBC,hbc)
409
410 dnl ** Which gcc to use?
411 dnl --------------------------------------------------------------
412 AC_ARG_WITH(gcc,
413 [  --with-gcc=<gcc command>
414         Use a different command instead of 'gcc' for the GNU C compiler.
415 ],
416 [WhatGccIsCalled="$withval"
417  CC="$withval"],
418 [WhatGccIsCalled="gcc"]
419 )
420 AC_SUBST(WhatGccIsCalled)
421
422 dnl ** Booting from .hc files?
423 dnl --------------------------------------------------------------
424 AC_ARG_ENABLE(hc-boot,
425 [  --enable-hc-boot
426         Boot the Glasgow Haskell Compiler from intermediate .hc files.
427         (This option is mostly of interest to porters.)
428 ],
429 [BootingFromHc=YES],
430 [BootingFromHc=NO]
431 )
432 AC_SUBST(BootingFromHc)
433
434 dnl ** Booting from unregisterised .hc files?
435 dnl --------------------------------------------------------------
436 AC_ARG_ENABLE(hc-boot-unregisterised,
437 [  --enable-hc-boot-unregisterised
438         With --enable-hc-boot, treat the intermediate .hc files as
439         unregisterised rather than registerised code.
440         (This option is mostly of interest to porters.)
441 ],
442 [BootingFromUnregisterisedHc=YES],
443 [BootingFromUnregisterisedHc=NO]
444 )
445 AC_SUBST(BootingFromUnregisterisedHc)
446
447 if test "$BootingFromHc" = "NO"; then
448 if test "$BootingFromUnregisterisedHc" = "YES"; then
449 AC_MSG_ERROR([--enable-hc-boot-unregisterised requires --enable-hc-boot.])
450 fi;
451 fi;
452
453
454 dnl ** Enable multi-thread friendly RTS?
455 dnl --------------------------------------------------------------
456 AC_ARG_ENABLE(threaded-rts,
457 [  --enable-threaded-rts
458         Support better interop with OS threads.
459 ],
460 [ThreadedRts=YES],
461 [ThreadedRts=NO]
462 )
463 AC_SUBST(ThreadedRts)
464
465 dnl ** Enable the construction of Win32 DLLs?
466 dnl --------------------------------------------------------------
467 AC_ARG_ENABLE(win32-dlls,
468 [  --enable-win32-dlls
469         If on a Win32 platform running mingw32/cygwin, enable the
470         construction of DLLs containing ghc-compiled code.
471 ],
472 [
473 case $HostOS_CPP in
474 cygwin32) ;;
475 mingw32)  ;;
476 *)    echo "Unrecognised win32 platform: $HostPlatform"
477       exit 1
478       ;;
479 esac
480 EnableWin32DLLs=YES
481 ],
482 [EnableWin32DLLs=NO]
483 )
484 AC_SUBST(EnableWin32DLLs)
485 if test x"$EnableWin32DLLs" = "xYES" ; then
486  AC_DEFINE(HAVE_WIN32_DLL_SUPPORT)
487 fi
488
489 dnl ** Enable the building of the OpenGL/GLUT binding in hslibs?
490 dnl --------------------------------------------------------------
491 AC_ARG_ENABLE(hopengl,
492 [  --enable-hopengl
493         Build HOpenGL, a Haskell binding for OpenGL/GLUT, too.
494         (This option is only relevant when hslibs are built.)
495 ],
496 [GhcLibsWithHOpenGL=YES],
497 [GhcLibsWithHOpenGL=NO]
498 )
499 AC_SUBST(GhcLibsWithHOpenGL)
500
501 dnl ** Use a specific version of the GLUT API
502 dnl --------------------------------------------------------------
503 AC_ARG_WITH(glut-api,
504 [  --with-glut-api=<version>
505         Use a specific version of the GLUT API when building HOpenGL.
506 ])
507 test -n "$with_glut_api"  && CPPFLAGS="$CPPFLAGS -DGLUT_API_VERSION=$with_glut_api"
508
509
510 dnl ** Use a specific version of the GLUT API
511 dnl --------------------------------------------------------------
512 AC_ARG_WITH(glut-xlib,
513 [  --with-glut-xlib=<version>
514         Use a specific version of the GLUT Xlib implementation when building HOpenGL.
515 ])
516 test -n "$with_glut_xlib" && CPPFLAGS="$CPPFLAGS -DGLUT_XLIB_IMPLEMENTATION=$with_glut_xlib"
517
518
519
520
521 dnl --------------------------------------------------------------
522 dnl End of configure script option section
523 dnl --------------------------------------------------------------
524
525
526 dnl --------------------------------------------------------------
527 dnl * General configuration checks
528 dnl --------------------------------------------------------------
529
530 dnl ** does #! work?
531 AC_SYS_INTERPRETER()
532
533 dnl ** look for `perl', but only in /bin on Windows
534 case $HostOS_CPP in
535 cygwin32|mingw32)
536       AC_CHECK_PROG(PerlCmd,perl,/bin/perl,,/bin)
537       if test -z "$PerlCmd"; then
538          echo "You must install the version of Perl shipped with GHC"
539          echo "(or a compatible one) in /bin."
540          exit 1
541       fi
542    ;;
543 *)
544    AC_PATH_PROG(PerlCmd,perl)
545    if test -z "$PerlCmd"; then
546       echo "You must install perl before you can continue"
547       echo "Perhaps it is already installed, but not in your PATH?"
548       exit 1
549    else
550    FPTOOLS_CHECK_PERL_VERSION
551    fi
552    ;;
553 esac
554
555 dnl ** does #! path/to/perl work? (sometimes it's too long...)
556 FPTOOLS_SHEBANG_PERL
557
558 dnl ** look for GCC and find out which version
559 dnl     Figure out which C compiler to use.  Gcc is preferred.
560 dnl     If gcc, make sure it's at least 2.1
561 dnl
562 AC_PROG_CC
563 FPTOOLS_HAVE_GCC
564
565 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
566 AC_PROG_CPP
567
568 dnl ** Without optimization some INLINE trickery fails for GHCi
569 SRC_CC_OPTS="-O"
570
571 dnl ** Try to add -mno-cygwin to the C compiler options for mingw32 targets
572 if test x"$TargetOS_CPP" = x"mingw32"; then
573   FPTOOLS_CC_FLAG(-mno-cygwin,CC_SUPPORTS_MNO_CYGWIN)
574   SRC_CC_OPTS="$CC_SUPPORTS_MNO_CYGWIN $SRC_CC_OPTS"
575   CPPFLAGS="$CC_SUPPORTS_MNO_CYGWIN $CPPFLAGS"
576 fi
577 AC_SUBST(SRC_CC_OPTS)
578
579 dnl ** figure out how to do context diffs
580 FPTOOLS_PROG_DIFF
581
582 dnl ** Find find command (for Win32's benefit)
583 FPTOOLS_FIND_FIND
584
585 dnl ** look for a decent parser generator (bison preferred)
586 dnl (FPTOOLS_PROG_YACCY is AC_PROG_YACC, but with some extra testing 
587 dnl  on the suitability of the 'yacc' returned.)
588 FPTOOLS_PROG_YACCY
589
590 dnl ** Find lex command (lex or flex) - *doesn't* use autoconf's
591 dnl    AC_PROG_LEX, since it doesn't actually check whether 'lex'
592 dnl    exists if 'flex' doesn't.
593 AC_PROG_LEX_STRICT
594
595 dnl ** figure out how to do a BSD-ish install
596 AC_PROG_INSTALL
597
598 dnl If you can run configure, you certainly have /bin/sh
599 AC_DEFINE(HAVE_BIN_SH)
600
601 dnl ** how to invoke `ar' and `ranlib'
602 FPTOOLS_PROG_AR_AND_RANLIB
603
604 dnl ** Check to see whether ln -s works
605 AC_PROG_LN_S
606
607
608 dnl ** Find the path to sed
609 AC_PATH_PROG(SedCmd,sed)
610
611
612 dnl ** check for time command
613 AC_PATH_PROG(TimeCmd,time)
614
615
616 dnl ** check for tar
617 dnl   if GNU tar is named gtar, look for it first.
618 AC_PATH_PROGS(TarCmd,gtar tar,tar)
619
620 dnl ** check for gzip/compress
621 AC_PATH_PROGS(CompressCmd,gzip compress,gzip)
622
623 dnl ** check for jade/openjade & determine a working catalog
624 AC_PATH_PROGS(JadeCmd,openjade jade,jade)
625 FPTOOLS_DOCBOOK_CATALOG(Catalog, $JadeCmd, docs/fptools-both.dsl, 
626                         /etc/sgml/catalog /etc/sgml.catalog /usr/share/sgml/CATALOG.docbkdsl /usr/local/share/sgml/catalog glafp-utils/docbook/CATALOG*)
627 if test -z "$Catalog"; then
628   AC_MSG_RESULT([Warning: You will not be able to build the documentation.])
629 fi
630 case $Catalog in
631    yes) # assume it is provided by other means (e.g., SGML_CATALOG_FILES env var).
632         Catalog=
633         ;;
634    glafp*) 
635         case $HostOS_CPP in
636            mingw32)
637               Catalog=`cygpath -w $hardtop/$Catalog`
638               ;;
639            *) Catalog=$hardtop/$Catalog
640               ;;
641         esac
642    ;;
643 esac   
644 AC_SUBST(Catalog)
645
646 compress_nm=`basename $CompressCmd`
647 if test x"$compress_nm" = xgzip; then
648   CompressCmd="$CompressCmd -d"
649   CompressSuffix="gz"
650 else
651   CompressSuffix="Z"
652 fi
653 AC_SUBST(CompressCmd)
654 AC_SUBST(CompressSuffix)
655
656 AC_ARG_ENABLE(src-tree-happy,
657 [  --enable-src-tree-happy
658         Build and use source tree (fptools/happy) version of happy.
659 ],
660 [UseSrcTreeHappy=YES],
661 [UseSrcTreeHappy=NO]
662 )
663 dnl ** check for installed happy binary + version
664 dnl    (don't do it if we're booting from .hc files though.)
665 if test "$BootingFromHc" = "NO"; then
666 FPTOOLS_HAPPY
667 fi;
668
669 dnl --------------------------------------------------
670 dnl ### program checking section ends here ###
671 dnl --------------------------------------------------
672
673 dnl --------------------------------------------------
674 dnl * Platform header file and syscall feature tests
675 dnl ### checking the state of the local header files and syscalls ###
676
677 dnl ** check for full ANSI header (.h) files
678 AC_HEADER_STDC
679
680 dnl ** check for specific header (.h) files that we are interested in
681 AC_CHECK_HEADERS(Files.h arpa/inet.h assert.h console.h ctype.h dirent.h errno.h fcntl.h float.h ftw.h grp.h ieee754.h inttypes.h limits.h malloc.h memory.h nlist.h pascal.h pwd.h sgtty.h siginfo.h signal.h stat.h stdint.h stdlib.h stddef.h stdarg.h string.h sys/fault.h sys/file.h sys/ioctl.h sys/limits.h sys/mman.h sys/param.h sys/procfs.h sys/resource.h sys/signal.h sys/socket.h netdb.h netinet/in.h netinet/tcp.h sys/stat.h sys/syscall.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/types.h sys/un.h sys/utsname.h sys/vadvise.h sys/wait.h termio.h termios.h time.h types.h unistd.h utime.h values.h vfork.h bfd.h winsock.h pthread.h sys/uio.h)
682
683 AC_CHECK_HEADER(readline/readline.h, HaveReadlineReadlineH=YES, HaveReadlineReadlineH=NO)
684 AC_CHECK_HEADER(readline/history.h, HaveReadlineHistoryH=YES, HaveReadlineHistoryH=NO)
685
686 if test $HaveReadlineReadlineH = YES && test $HaveReadlineHistoryH = YES ; then
687   HaveReadlineHeaders=YES
688   AC_DEFINE(HAVE_READLINE_HEADERS,1)
689 else
690   HaveReadlineHeaders=NO
691   AC_DEFINE(HAVE_READLINE_HEADERS,0)
692 fi
693 AC_SUBST(HaveReadlineHeaders)
694
695 dnl ** check for DOS include files
696 AC_CHECK_HEADERS(dos.h conio.h io.h std.h) 
697
698 dnl ** check for Windows include files
699 AC_CHECK_HEADERS(windows.h)
700
701 dnl ** check for OpenGL include files
702 AC_CHECK_HEADERS(GL/gl.h)
703
704 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
705 AC_HEADER_TIME
706
707 dnl dynamic loading include files
708 AC_CHECK_HEADERS(dlfcn.h dl.h) 
709
710 dnl ** check for farcalloc (in bcc)
711 AC_CHECK_HEADER(alloc.h,AC_CHECK_FUNCS(farcalloc))
712
713 dnl ** check for valloc (in sunos, solaris, mips, amiga, next, minix, ultrix)
714 AC_CHECK_HEADER(malloc.h,AC_CHECK_FUNCS(valloc))
715
716 dnl ** check for POSIX regex
717 HavePosixRegex=NO
718 AC_CHECK_HEADER(regex.h,AC_CHECK_FUNC(regcomp, HavePosixRegex=YES))
719 AC_SUBST(HavePosixRegex)
720
721 dnl ** how do we get a timezone name, and UTC offset ?
722 AC_STRUCT_TIMEZONE
723
724 dnl ** what's the type of timezone?
725 FPTOOLS_HAVE_TIMEZONE
726 FPTOOLS_TYPE_TIMEZONE
727
728 dnl ** do we have altzone?
729 FPTOOLS_ALTZONE
730
731 dnl ** does struct stat contain st_blksize?
732 AC_STRUCT_ST_BLKSIZE
733
734 dnl ** do we have long longs?
735 FPTOOLS_C_LONG_LONG
736
737 dnl ** check what fields struct msghdr contains
738 FPTOOLS_MSGHDR_MSG_ACCRIGHTS
739 FPTOOLS_MSGHDR_MSG_CONTROL
740
741 dnl ** what are the sizes of various types
742 dnl    (these must come before GHC_CHECK_ALIGNMENT)
743 AC_CHECK_SIZEOF(char,               1)
744 AC_CHECK_SIZEOF(double,             8)
745 AC_CHECK_SIZEOF(float,              4)
746 AC_CHECK_SIZEOF(int,                4)
747 AC_CHECK_SIZEOF(long,               4)
748 if test "$fptools_cv_have_long_long" = yes; then
749 AC_CHECK_SIZEOF(long long,          8)
750 fi
751 AC_CHECK_SIZEOF(short,              2)
752 AC_CHECK_SIZEOF(unsigned char,      1)
753 AC_CHECK_SIZEOF(unsigned int,       4)
754 AC_CHECK_SIZEOF(unsigned long,      4)
755 if test "$fptools_cv_have_long_long" = yes; then
756 AC_CHECK_SIZEOF(unsigned long long, 8)
757 fi
758 AC_CHECK_SIZEOF(unsigned short,     2)
759 AC_CHECK_SIZEOF(void *,             4)
760
761 dnl ** what are alignment constraints on various types
762 FPTOOLS_CHECK_ALIGNMENT(char)
763 FPTOOLS_CHECK_ALIGNMENT(double)
764 FPTOOLS_CHECK_ALIGNMENT(float)
765 FPTOOLS_CHECK_ALIGNMENT(int)
766 FPTOOLS_CHECK_ALIGNMENT(long)
767 if test "$fptools_cv_have_long_long" = yes; then
768 FPTOOLS_CHECK_ALIGNMENT(long long)
769 fi
770 FPTOOLS_CHECK_ALIGNMENT(short)
771 FPTOOLS_CHECK_ALIGNMENT(unsigned char)
772 FPTOOLS_CHECK_ALIGNMENT(unsigned int)
773 FPTOOLS_CHECK_ALIGNMENT(unsigned long)
774 if test "$fptools_cv_have_long_long" = yes; then
775 FPTOOLS_CHECK_ALIGNMENT(unsigned long long)
776 fi
777 FPTOOLS_CHECK_ALIGNMENT(unsigned short)
778 FPTOOLS_CHECK_ALIGNMENT(void *)
779
780 dnl ** map standard C types and ISO types to Haskell types
781 FPTOOLS_CHECK_HTYPE(char)
782 FPTOOLS_CHECK_HTYPE(signed char)
783 FPTOOLS_CHECK_HTYPE(unsigned char)
784 FPTOOLS_CHECK_HTYPE(short)
785 FPTOOLS_CHECK_HTYPE(unsigned short)
786 FPTOOLS_CHECK_HTYPE(int)
787 FPTOOLS_CHECK_HTYPE(unsigned int)
788 FPTOOLS_CHECK_HTYPE(long)
789 FPTOOLS_CHECK_HTYPE(unsigned long)
790 if test "$fptools_cv_have_long_long" = yes; then
791 FPTOOLS_CHECK_HTYPE(long long)
792 FPTOOLS_CHECK_HTYPE(unsigned long long)
793 fi
794 FPTOOLS_CHECK_HTYPE(float)
795 FPTOOLS_CHECK_HTYPE(double)
796 FPTOOLS_CHECK_HTYPE(ptrdiff_t)
797 FPTOOLS_CHECK_HTYPE(size_t)
798 FPTOOLS_CHECK_HTYPE(wchar_t)
799 dnl Int32 is a HACK for non-ISO C compilers
800 FPTOOLS_CHECK_HTYPE(sig_atomic_t, Int32)
801 FPTOOLS_CHECK_HTYPE(clock_t)
802 FPTOOLS_CHECK_HTYPE(time_t)
803 FPTOOLS_CHECK_HTYPE(dev_t, Word32)
804 FPTOOLS_CHECK_HTYPE(ino_t)
805 FPTOOLS_CHECK_HTYPE(mode_t)
806 FPTOOLS_CHECK_HTYPE(off_t)
807 FPTOOLS_CHECK_HTYPE(pid_t)
808 FPTOOLS_CHECK_HTYPE(gid_t)
809 FPTOOLS_CHECK_HTYPE(uid_t)
810 FPTOOLS_CHECK_HTYPE(cc_t)
811 FPTOOLS_CHECK_HTYPE(speed_t)
812 FPTOOLS_CHECK_HTYPE(tcflag_t)
813 FPTOOLS_CHECK_HTYPE(nlink_t)
814 FPTOOLS_CHECK_HTYPE(ssize_t)
815
816 dnl ** Map OpenGL data types to Haskell types
817 if test $GhcLibsWithHOpenGL = YES ; then
818 FPTOOLS_CHECK_HTYPE(GLboolean)
819 FPTOOLS_CHECK_HTYPE(GLbyte)
820 FPTOOLS_CHECK_HTYPE(GLubyte)
821 FPTOOLS_CHECK_HTYPE(GLshort)
822 FPTOOLS_CHECK_HTYPE(GLushort)
823 FPTOOLS_CHECK_HTYPE(GLint)
824 FPTOOLS_CHECK_HTYPE(GLuint)
825 FPTOOLS_CHECK_HTYPE(GLsizei)
826 FPTOOLS_CHECK_HTYPE(GLenum)
827 FPTOOLS_CHECK_HTYPE(GLbitfield)
828 FPTOOLS_CHECK_HTYPE(GLfloat)
829 FPTOOLS_CHECK_HTYPE(GLclampf)
830 FPTOOLS_CHECK_HTYPE(GLdouble)
831 FPTOOLS_CHECK_HTYPE(GLclampd)
832 fi
833
834 dnl ** can we open files in binary mode?
835 FPTOOLS_O_BINARY
836
837 dnl ** check for GetModuleFileName and WinExec (windows only)
838 dnl Old: AC_CHECK_FUNCS(WinExec GetModuleFileName)       dnl Windows
839 dnl Doesn't work because the linker can't see the functions if
840 dnl you omit the #include <windows.h>.  (I've no idea why not...)
841
842 FPTOOLS_TRY_LINK_NOWARN(,[
843 #if HAVE_WINDOWS_H
844 #include <windows.h>
845 #endif
846 main() { 
847   WinExec("",0);
848   exit(0);
849 }
850 ],
851 [have_winexec=1],
852 [have_winexec=0])
853 if test "$have_winexec" = "1"; then
854 AC_DEFINE(HAVE_WINEXEC)
855 fi
856
857 FPTOOLS_TRY_LINK_NOWARN(,[
858 #if HAVE_WINDOWS_H
859 #include <windows.h>
860 #endif
861 main() { 
862   char* dir;
863   GetModuleFileName((HMODULE)0,dir,0);
864   exit(0);
865 }
866 ],
867 [have_getmodulefilename=1],
868 [have_getmodulefilename=0])
869 if test "$have_getmodulefilename" = "1"; then
870 AC_DEFINE(HAVE_GETMODULEFILENAME)
871 fi
872
873 dnl ** check return type of signal handlers
874 dnl Foo: assumes we can use prototypes.
875 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
876 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
877 dnl [AC_TRY_COMPILE([#include <sys/types.h>
878 dnl #include <signal.h>
879 dnl #ifdef signal
880 dnl #undef signal
881 dnl #endif
882 dnl void (*signal (int, void (*)(int)))(int);
883 dnl ],
884 dnl [int i;], 
885 dnl ac_cv_type_signal_handler=void_int,
886 dnl ac_cv_type_signal_handler=int_void)])
887 dnl if test "$ac_cv_type_signal_handler" = void_int; then
888 dnl AC_DEFINE(VOID_INT_SIGNALS)
889 dnl fi
890
891 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
892 AC_TYPE_SIGNAL
893 if test "$ac_cv_type_signal" = void; then
894 AC_DEFINE(VOID_INT_SIGNALS)
895 fi
896
897 dnl ** check for more functions
898 AC_CHECK_FUNCS(strcasecmp _stricmp stricmp strcmpi)
899 AC_CHECK_FUNCS(strcmp)
900 AC_CHECK_FUNCS(realpath _fullpath)  
901 AC_CHECK_FUNCS(PBHSetVolSync macsystem)  
902 AC_CHECK_FUNCS(fgetpos fsetpos fseek ftell)
903 AC_CHECK_FUNCS(vsnprintf _vsnprintf)
904 AC_CHECK_FUNCS(snprintf  _snprintf )  
905 AC_CHECK_FUNCS(popen     _popen )  
906 AC_CHECK_FUNCS(pclose    _pclose )  
907
908
909 dnl ** check for specific library functions that we are interested in
910 AC_CHECK_FUNCS(access ftime getclock getpagesize getrusage gettimeofday mktime mprotect readlink setitimer stat lstat symlink sysconf timelocal times vadvise vfork localtime_r gmtime_r readdir_r)
911
912 dnl ** check whether this machine has gmp3 installed
913 AC_CHECK_LIB(gmp,  __gmpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
914   AC_CHECK_LIB(gmp3, __gmpz_fdiv_qr,  HaveLibGmp=YES; LibGmp=gmp3,
915     HaveLibGmp=NO; LibGmp=not-installed))
916 AC_SUBST(HaveLibGmp)
917 AC_SUBST(LibGmp)
918
919 dnl ** check for mingwex library
920 AC_CHECK_LIB(mingwex, closedir, HaveLibMingwEx=YES, HaveLibMingwEx=NO)
921 AC_SUBST(HaveLibMingwEx)
922
923 if test $HaveLibMingwEx = YES ; then
924   AC_DEFINE(HAVE_MINGWEX)
925 fi
926
927 if test "$HaveLibGmp" = "NO"; then
928 if test "$HostArch_CPP" = "ia64"; then
929 AC_MSG_ERROR([You need to install libgmp (the in-tree version does not work on IA64).])
930 fi;
931 fi;
932
933 dnl ** check whether this machine has GNU regex in libc.
934 FPTOOLS_REGEX_IN_LIBC
935
936 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
937 dnl    the order of these tests matters: bfd needs liberty
938 AC_CHECK_LIB(iberty, xmalloc)
939 AC_CHECK_LIB(bfd,    bfd_init)
940
941 dnl ** check for readline, for Hugs and hslibs' Readline
942 dnl ncurses supersedes termcap and curses, but for compatibility,
943 dnl we have to check for all...
944 AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=YES; LibTermcap=ncurses,
945   AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=YES; LibTermcap=termcap,
946     AC_CHECK_LIB(curses, tputs, HaveLibTermcap=YES; LibTermcap=curses,
947       HaveLibTermcap=NO; LibTermcap=not-installed)))
948
949 if test $HaveLibTermcap = YES ; then
950   LIBS="-l$LibTermcap $LIBS"
951   AC_CHECK_LIB(readline, readline, HaveLibReadline=YES, HaveLibReadline=NO)
952 fi
953
954 if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES ; then
955   AC_DEFINE(HAVE_READLINE_LIBS,1)
956   LibsReadline="readline $LibTermcap"
957 else
958   AC_DEFINE(HAVE_READLINE_LIBS,0)
959   LibsReadline=
960 fi
961 AC_SUBST(LibsReadline)
962
963 if test "$HaveLibReadline"; then
964   AC_CHECK_LIB(readline, rl_erase_empty_line,
965     [AC_DEFINE(HAVE_READLINE_4, 1)],
966     [AC_DEFINE(HAVE_READLINE_4, 0)])
967   AC_CHECK_LIB(readline, rl_free_undo_list,
968     [AC_DEFINE(HAVE_READLINE_4_2, 1)],
969     [AC_DEFINE(HAVE_READLINE_4_2, 0)])
970 else
971   AC_DEFINE(HAVE_READLINE_4, 0)
972   AC_DEFINE(HAVE_READLINE_4_2, 0)
973 fi
974
975 dnl ** check for math library
976 FPTOOLS_CHECK_LIBM()
977 AC_SUBST(LIBM)
978
979 case $HostOS_CPP in
980 cygwin32) ;;
981 mingw32)  ;;
982 *) AC_PATH_XTRA() ;;
983 esac
984
985 FPTOOLS_HAVE_OPENGL
986
987 dnl ################################################################
988 dnl Check for libraries
989 dnl ################################################################
990
991 dnl ** check for libdl & RTLD_NEXT
992
993 AC_CHECK_LIB(dl, dlopen, 
994         [HaveLibDL=YES
995          AC_DEFINE(HAVE_LIBDL)
996          LIBS="$LIBS -ldl"], 
997         [HaveLibDL=NO])
998 AC_CHECK_FUNCS(dlopen)
999 AC_SUBST(HaveLibDL)
1000
1001 dnl ** sometimes RTLD_NEXT is hidden in #ifdefs we really don't wan to set
1002 AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h)
1003 AC_EGREP_CPP(yes,
1004 [
1005  #include <dlfcn.h>
1006  #ifdef RTLD_NEXT
1007         yes
1008  #endif
1009 ], [
1010   AC_MSG_RESULT(yes)
1011   AC_DEFINE(HAVE_RTLDNEXT)
1012   HaveRtldNext=YES
1013 ], [
1014   AC_MSG_RESULT(no)
1015   HaveRtldNext=NO
1016   ])    
1017 AC_SUBST(HaveRtldNext)
1018
1019 dnl ** RTLD_LOCAL isn't available on cygwin
1020 AC_MSG_CHECKING(for RTLD_LOCAL from dlfcn.h)
1021 AC_EGREP_CPP(yes,
1022 [
1023  #include <dlfcn.h>
1024  #ifdef RTLD_LOCAL
1025         yes
1026  #endif
1027 ], [
1028   AC_MSG_RESULT(yes)
1029   AC_DEFINE(HAVE_RTLDLOCAL)
1030   HaveRtldLocal=YES
1031 ], [
1032   AC_MSG_RESULT(no)
1033   HaveRtldLocal=NO
1034   ])    
1035 AC_SUBST(HaveRtldLocal)
1036
1037 FPTOOLS_CHECK_LIB_NOWARN(m, atan)
1038
1039 dnl --------------------------------------------------
1040 dnl * test for GTK+
1041 dnl --------------------------------------------------
1042
1043 AC_PATH_PROGS(GTK_CONFIG, gtk-config gtk12-config)
1044 if test "$GTK_CONFIG" != ""; then
1045    AC_CACHE_CHECK([for version of GTK+], fptools_cv_gtk_version, [
1046         fptools_cv_gtk_version=`$GTK_CONFIG --version`
1047     ])
1048     GTK_VERSION=$fptools_cv_gtk_version
1049 else
1050     GTK_VERSION=
1051 fi
1052
1053 case $fptools_cv_gtk_version in
1054   1.[[23]].*) ;;
1055   *) AC_MSG_WARN([GTK+ not usable; need at least version 1.2])
1056      GTK_CONFIG=
1057      ;;
1058 esac
1059
1060 AC_SUBST(GTK_CONFIG)
1061 AC_SUBST(GTK_VERSION)
1062
1063 dnl --------------------------------------------------
1064 dnl * Miscellaneous feature tests
1065 dnl --------------------------------------------------
1066
1067 dnl ** can we get alloca?
1068 AC_FUNC_ALLOCA
1069
1070 dnl ** determine whether or not const works
1071 AC_C_CONST
1072
1073 dnl ** determine whether ANSI-function prototypes work?
1074 AC_C_PROTOTYPES          
1075
1076 dnl ** are we big endian?
1077 AC_C_BIGENDIAN
1078 # Allay users' general fear of warnings of any kind.
1079 errprint(fptools configure script wizard sez: autoconf-2.50 or later should produce no warnings
1080 )
1081 errprint(if you are using 2.13 or earlier, you may get a (harmless) warning message.
1082 )
1083
1084 dnl ** check for leading underscores in symbol names
1085 FPTOOLS_UNDERSCORE
1086
1087 dnl ** how is the end of text section signalled?
1088 FPTOOLS_END_TEXT_SECTION
1089
1090 dnl ** how is the end of data section signalled?
1091 FPTOOLS_END_DATA_SECTION
1092
1093 dnl ** code before data?
1094 FPTOOLS_CODE_BEFORE_DATA
1095
1096 dnl ** check for ld, and whether ld has -x option
1097 AC_PATH_PROG(LdCmdRaw, ld)
1098 case $HostOS_CPP in
1099  mingw32) LdCmd=`cygpath -w ${LdCmdRaw} | sed -e 's@\\\\@/@g' `
1100            ;;
1101  *) LdCmd=${LdCmdRaw}
1102     ;;
1103 esac
1104 AC_SUBST(LdCmd)
1105 FPTOOLS_LD_X
1106
1107 AC_OUTPUT(mk/config.mk, echo timestamp > mk/stamp-h )