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