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