[project @ 2001-11-08 18:51:03 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 # (but with b-slashes being escaped).
343 case $HostPlatform in
344   i386-unknown-mingw32 | i386-unknown-cygwin32)
345         hardtop_plat=`cygpath -w ${hardtop} | sed -e 's@\\\\@\\\\\\\\@g' `
346         ;;
347   *)
348         hardtop_plat=${hardtop}
349         ;;
350 esac
351 AC_SUBST(hardtop_plat)
352
353 dnl --------------------------------------------------------------
354 dnl * Project specific configuration options
355 dnl --------------------------------------------------------------
356 dnl What follows is a bunch of options that can either be configured
357 dnl through command line options to the configure script or by
358 dnl supplying defns in the build tree's mk/build.mk. Having the option to
359 dnl use either is considered a Feature.
360
361 dnl ** What command to use to compile compiler sources ?
362 dnl --------------------------------------------------------------
363
364 AC_ARG_WITH(ghc,
365 [  --with-ghc=<haskell compiler>
366         Use a command different from 'ghc' to compile GHC-specific Haskell code
367             (including GHC itself).
368 ],
369 [ WithGhc="$withval" ],
370
371   if test "$GHC" = ""; then
372     AC_PATH_PROG(GHC,ghc)
373   fi
374   WithGhc=$GHC
375 ]
376 )
377 AC_SUBST(WithGhc)
378
379 AC_ARG_WITH(hc,
380 [  --with-hc=<haskell compiler>
381         Use a command different from 'ghc' to compile generic Haskell code.
382 ],
383 [WithHc="$withval"],
384 [WithHc=$WithGhc]
385 )
386 AC_SUBST(WithHc)
387
388 if test "$WithGhc" != ""; then
389   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
390   AC_SUBST(GhcVersion)dnl
391   AC_SUBST(GhcMajVersion)dnl
392   AC_SUBST(GhcMinVersion)dnl
393   AC_SUBST(GhcPatchLevel)dnl
394 fi
395
396 AC_PATH_PROGS(NHC,nhc nhc98)
397 AC_PATH_PROG(HBC,hbc)
398
399 dnl ** Which gcc to use?
400 dnl --------------------------------------------------------------
401 AC_ARG_WITH(gcc,
402 [  --with-gcc=<gcc command>
403         Use a different command instead of 'gcc' for the GNU C compiler.
404 ],
405 [WhatGccIsCalled="$withval"
406  CC="$withval"],
407 [WhatGccIsCalled="gcc"]
408 )
409 AC_SUBST(WhatGccIsCalled)
410
411 dnl ** Booting from .hc files?
412 dnl --------------------------------------------------------------
413 AC_ARG_ENABLE(hc-boot,
414 [  --enable-hc-boot
415         Boot the Glasgow Haskell Compiler from intermediate .hc files.
416         (This option is mostly of interest to porters.)
417 ],
418 [BootingFromHc=YES],
419 [BootingFromHc=NO]
420 )
421 AC_SUBST(BootingFromHc)
422
423 dnl ** Booting from unregisterised .hc files?
424 dnl --------------------------------------------------------------
425 AC_ARG_ENABLE(hc-boot-unregisterised,
426 [  --enable-hc-boot-unregisterised
427         With --enable-hc-boot, treat the intermediate .hc files as
428         unregisterised rather than registerised code.
429         (This option is mostly of interest to porters.)
430 ],
431 [BootingFromUnregisterisedHc=YES],
432 [BootingFromUnregisterisedHc=NO]
433 )
434 AC_SUBST(BootingFromUnregisterisedHc)
435
436 if test "$BootingFromHc" = "NO"; then
437 if test "$BootingFromUnregisterisedHc" = "YES"; then
438 AC_MSG_ERROR([--enable-hc-boot-unregisterised requires --enable-hc-boot.])
439 fi;
440 fi;
441
442
443 dnl ** Enable the construction of Win32 DLLs?
444 dnl --------------------------------------------------------------
445 AC_ARG_ENABLE(win32-dlls,
446 [  --enable-win32-dlls
447         If on a Win32 platform running mingw32/cygwin, enable the
448         construction of DLLs containing ghc-compiled code.
449 ],
450 [
451 case $HostOS_CPP in
452 cygwin32) ;;
453 mingw32)  ;;
454 *)    echo "Unrecognised win32 platform: $HostPlatform"
455       exit 1
456       ;;
457 esac
458 EnableWin32DLLs=YES
459 ],
460 [EnableWin32DLLs=NO]
461 )
462 AC_SUBST(EnableWin32DLLs)
463 if test x"$EnableWin32DLLs" = "xYES" ; then
464  AC_DEFINE(HAVE_WIN32_DLL_SUPPORT)
465 fi
466
467 dnl ** Enable the building of the OpenGL/GLUT binding in hslibs?
468 dnl --------------------------------------------------------------
469 AC_ARG_ENABLE(hopengl,
470 [  --enable-hopengl
471         Build HOpenGL, a Haskell binding for OpenGL/GLUT, too.
472         (This option is only relevant when hslibs are built.)
473 ],
474 [GhcLibsWithHOpenGL=YES],
475 [GhcLibsWithHOpenGL=NO]
476 )
477 AC_SUBST(GhcLibsWithHOpenGL)
478
479 dnl ** Use a specific version of the GLUT API
480 dnl --------------------------------------------------------------
481 AC_ARG_WITH(glut-api,
482 [  --with-glut-api=<version>
483         Use a specific version of the GLUT API when building HOpenGL.
484 ])
485 test -n "$with_glut_api"  && CPPFLAGS="$CPPFLAGS -DGLUT_API_VERSION=$with_glut_api"
486
487
488 dnl ** Use a specific version of the GLUT API
489 dnl --------------------------------------------------------------
490 AC_ARG_WITH(glut-xlib,
491 [  --with-glut-xlib=<version>
492         Use a specific version of the GLUT Xlib implementation when building HOpenGL.
493 ])
494 test -n "$with_glut_xlib" && CPPFLAGS="$CPPFLAGS -DGLUT_XLIB_IMPLEMENTATION=$with_glut_xlib"
495
496
497
498
499 dnl --------------------------------------------------------------
500 dnl End of configure script option section
501 dnl --------------------------------------------------------------
502
503
504 dnl --------------------------------------------------------------
505 dnl * General configuration checks
506 dnl --------------------------------------------------------------
507
508 dnl ** does #! work?
509 AC_SYS_INTERPRETER()
510
511 dnl ** look for `perl', but only in /bin on Windows
512 case $HostOS_CPP in
513 cygwin32|mingw32)
514       AC_CHECK_PROG(PerlCmd,perl,/bin/perl,,/bin)
515       if test -z "$PerlCmd"; then
516          echo "You must install the version of Perl shipped with GHC"
517          echo "(or a compatible one) in /bin."
518          exit 1
519       fi
520    ;;
521 *)
522    AC_PATH_PROG(PerlCmd,perl)
523    if test -z "$PerlCmd"; then
524       echo "You must install perl before you can continue"
525       echo "Perhaps it is already installed, but not in your PATH?"
526       exit 1
527    else
528    FPTOOLS_CHECK_PERL_VERSION
529    fi
530    ;;
531 esac
532
533 dnl ** does #! path/to/perl work? (sometimes it's too long...)
534 FPTOOLS_SHEBANG_PERL
535
536 dnl ** look for GCC and find out which version
537 dnl     Figure out which C compiler to use.  Gcc is preferred.
538 dnl     If gcc, make sure it's at least 2.1
539 dnl
540 AC_PROG_CC
541 FPTOOLS_HAVE_GCC
542
543 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
544 AC_PROG_CPP
545
546 dnl ** does the C compiler support the following options?
547 FPTOOLS_CC_FLAG(-mwin32,CC_SUPPORTS_MWIN32)
548 FPTOOLS_CC_FLAG(-mno-cygwin,CC_SUPPORTS_MNO_CYGWIN)
549
550 EXTRA_CC_OPTS="$CC_SUPPORTS_MNO_CYGWIN $CC_SUPPORTS_MWIN32"
551 SRC_CC_OPTS="-O $EXTRA_CC_OPTS"
552 CPPFLAGS="$EXTRA_CC_OPTS $CPPFLAGS"
553 AC_SUBST(SRC_CC_OPTS)
554
555 dnl ** figure out how to do context diffs
556 FPTOOLS_PROG_DIFF
557
558 dnl ** Find find command (for Win32's benefit)
559 FPTOOLS_FIND_FIND
560
561 dnl ** look for a decent parser generator (bison preferred)
562 dnl (FPTOOLS_PROG_YACCY is AC_PROG_YACC, but with some extra testing 
563 dnl  on the suitability of the 'yacc' returned.)
564 FPTOOLS_PROG_YACCY
565
566 dnl ** Find lex command (lex or flex) - *doesn't* use autoconf's
567 dnl    AC_PROG_LEX, since it doesn't actually check whether 'lex'
568 dnl    exists if 'flex' doesn't.
569 AC_PROG_LEX_STRICT
570
571 dnl ** figure out how to do a BSD-ish install
572 AC_PROG_INSTALL
573
574 dnl If you can run configure, you certainly have /bin/sh
575 AC_DEFINE(HAVE_BIN_SH)
576
577 dnl ** how to invoke `ar' and `ranlib'
578 FPTOOLS_PROG_AR_AND_RANLIB
579
580
581 dnl ** Check to see whether ln -s works
582 AC_PROG_LN_S
583
584
585 dnl ** Find the path to sed
586 AC_PATH_PROG(SedCmd,sed)
587
588
589 dnl ** check for time command
590 AC_PATH_PROG(TimeCmd,time)
591
592
593 dnl ** check for tar
594 dnl   if GNU tar is named gtar, look for it first.
595 AC_PATH_PROGS(TarCmd,gtar tar,tar)
596
597 dnl ** check for gzip/compress
598 AC_PATH_PROGS(CompressCmd,gzip compress,gzip)
599
600 dnl ** check for jade/openjade & determine a working catalog
601 AC_PATH_PROGS(JadeCmd,openjade jade,jade)
602 FPTOOLS_DOCBOOK_CATALOG(Catalog, $JadeCmd, docs/fptools-both.dsl, 
603                         /etc/sgml/catalog /etc/sgml.catalog /usr/share/sgml/CATALOG.docbkdsl glafp-utils/docbook/CATALOG*)
604 if test -z "$Catalog"; then
605   AC_MSG_RESULT([Warning: You will not be able to build the documentation.])
606 fi
607 case $Catalog in
608    glafp*) 
609         case $HostOS_CPP in
610            mingw32)
611               Catalog=`cygpath -w $hardtop/$Catalog`
612               ;;
613            *) Catalog=$hardtop/$Catalog
614               ;;
615         esac
616    ;;
617 esac   
618 AC_SUBST(Catalog)
619
620 compress_nm=`basename $CompressCmd`
621 if test x"$compress_nm" = xgzip; then
622   CompressCmd="$CompressCmd -d"
623   CompressSuffix="gz"
624 else
625   CompressSuffix="Z"
626 fi
627 AC_SUBST(CompressCmd)
628 AC_SUBST(CompressSuffix)
629
630 dnl ** check for installed happy binary + version
631 dnl    (don't do it if we're booting from .hc files though.)
632 if test "$BootingFromHc" = "NO"; then
633 FPTOOLS_HAPPY
634 fi;
635
636 dnl --------------------------------------------------
637 dnl ### program checking section ends here ###
638 dnl --------------------------------------------------
639
640 dnl --------------------------------------------------
641 dnl * Platform header file and syscall feature tests
642 dnl ### checking the state of the local header files and syscalls ###
643
644 dnl ** check for full ANSI header (.h) files
645 AC_HEADER_STDC
646
647 dnl ** check for specific header (.h) files that we are interested in
648 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)
649
650 AC_CHECK_HEADER(readline/readline.h, HaveReadlineReadlineH=YES, HaveReadlineReadlineH=NO)
651 AC_CHECK_HEADER(readline/history.h, HaveReadlineHistoryH=YES, HaveReadlineHistoryH=NO)
652
653 if test $HaveReadlineReadlineH = YES && test $HaveReadlineHistoryH = YES ; then
654   HaveReadlineHeaders=YES
655   AC_DEFINE(HAVE_READLINE_HEADERS,1)
656 else
657   HaveReadlineHeaders=NO
658   AC_DEFINE(HAVE_READLINE_HEADERS,0)
659 fi
660 AC_SUBST(HaveReadlineHeaders)
661
662 dnl ** check for DOS include files
663 AC_CHECK_HEADERS(dos.h conio.h io.h std.h) 
664
665 dnl ** check for Windows include files
666 AC_CHECK_HEADERS(windows.h)
667
668 dnl ** check for OpenGL include files
669 AC_CHECK_HEADERS(GL/gl.h)
670
671 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
672 AC_HEADER_TIME
673
674 dnl dynamic loading include files
675 AC_CHECK_HEADERS(dlfcn.h dl.h) 
676
677 dnl ** check for farcalloc (in bcc)
678 AC_CHECK_HEADER(alloc.h,AC_CHECK_FUNCS(farcalloc))
679
680 dnl ** check for valloc (in sunos, solaris, mips, amiga, next, minix, ultrix)
681 AC_CHECK_HEADER(malloc.h,AC_CHECK_FUNCS(valloc))
682
683 dnl ** how do we get a timezone name, and UTC offset ?
684 AC_STRUCT_TIMEZONE
685
686 dnl ** what's the type of timezone?
687 FPTOOLS_HAVE_TIMEZONE
688 FPTOOLS_TYPE_TIMEZONE
689
690 dnl ** do we have altzone?
691 FPTOOLS_ALTZONE
692
693 dnl ** does struct stat contain st_blksize?
694 AC_STRUCT_ST_BLKSIZE
695
696 dnl ** do we have long longs?
697 FPTOOLS_C_LONG_LONG
698
699 dnl ** what are the sizes of various types
700 dnl    (these must come before GHC_CHECK_ALIGNMENT)
701 AC_CHECK_SIZEOF(char,               1)
702 AC_CHECK_SIZEOF(double,             8)
703 AC_CHECK_SIZEOF(float,              4)
704 AC_CHECK_SIZEOF(int,                4)
705 AC_CHECK_SIZEOF(long,               4)
706 if test "$fptools_cv_have_long_long" = yes; then
707 AC_CHECK_SIZEOF(long long,          8)
708 fi
709 AC_CHECK_SIZEOF(short,              2)
710 AC_CHECK_SIZEOF(unsigned char,      1)
711 AC_CHECK_SIZEOF(unsigned int,       4)
712 AC_CHECK_SIZEOF(unsigned long,      4)
713 if test "$fptools_cv_have_long_long" = yes; then
714 AC_CHECK_SIZEOF(unsigned long long, 8)
715 fi
716 AC_CHECK_SIZEOF(unsigned short,     2)
717 AC_CHECK_SIZEOF(void *,             4)
718
719 dnl ** what are alignment constraints on various types
720 FPTOOLS_CHECK_ALIGNMENT(char)
721 FPTOOLS_CHECK_ALIGNMENT(double)
722 FPTOOLS_CHECK_ALIGNMENT(float)
723 FPTOOLS_CHECK_ALIGNMENT(int)
724 FPTOOLS_CHECK_ALIGNMENT(long)
725 if test "$fptools_cv_have_long_long" = yes; then
726 FPTOOLS_CHECK_ALIGNMENT(long long)
727 fi
728 FPTOOLS_CHECK_ALIGNMENT(short)
729 FPTOOLS_CHECK_ALIGNMENT(unsigned char)
730 FPTOOLS_CHECK_ALIGNMENT(unsigned int)
731 FPTOOLS_CHECK_ALIGNMENT(unsigned long)
732 if test "$fptools_cv_have_long_long" = yes; then
733 FPTOOLS_CHECK_ALIGNMENT(unsigned long long)
734 fi
735 FPTOOLS_CHECK_ALIGNMENT(unsigned short)
736 FPTOOLS_CHECK_ALIGNMENT(void *)
737
738 dnl ** map standard C types and ISO types to Haskell types
739 FPTOOLS_CHECK_HTYPE(char)
740 FPTOOLS_CHECK_HTYPE(signed char)
741 FPTOOLS_CHECK_HTYPE(unsigned char)
742 FPTOOLS_CHECK_HTYPE(short)
743 FPTOOLS_CHECK_HTYPE(unsigned short)
744 FPTOOLS_CHECK_HTYPE(int)
745 FPTOOLS_CHECK_HTYPE(unsigned int)
746 FPTOOLS_CHECK_HTYPE(long)
747 FPTOOLS_CHECK_HTYPE(unsigned long)
748 if test "$fptools_cv_have_long_long" = yes; then
749 FPTOOLS_CHECK_HTYPE(long long)
750 FPTOOLS_CHECK_HTYPE(unsigned long long)
751 fi
752 FPTOOLS_CHECK_HTYPE(float)
753 FPTOOLS_CHECK_HTYPE(double)
754 FPTOOLS_CHECK_HTYPE(ptrdiff_t)
755 FPTOOLS_CHECK_HTYPE(size_t)
756 FPTOOLS_CHECK_HTYPE(wchar_t)
757 dnl Int32 is a HACK for non-ISO C compilers
758 FPTOOLS_CHECK_HTYPE(sig_atomic_t, Int32)
759 FPTOOLS_CHECK_HTYPE(clock_t)
760 FPTOOLS_CHECK_HTYPE(time_t)
761
762 dnl ** Map OpenGL data types to Haskell types
763 if test $GhcLibsWithHOpenGL = YES ; then
764 FPTOOLS_CHECK_HTYPE(GLboolean)
765 FPTOOLS_CHECK_HTYPE(GLbyte)
766 FPTOOLS_CHECK_HTYPE(GLubyte)
767 FPTOOLS_CHECK_HTYPE(GLshort)
768 FPTOOLS_CHECK_HTYPE(GLushort)
769 FPTOOLS_CHECK_HTYPE(GLint)
770 FPTOOLS_CHECK_HTYPE(GLuint)
771 FPTOOLS_CHECK_HTYPE(GLsizei)
772 FPTOOLS_CHECK_HTYPE(GLenum)
773 FPTOOLS_CHECK_HTYPE(GLbitfield)
774 FPTOOLS_CHECK_HTYPE(GLfloat)
775 FPTOOLS_CHECK_HTYPE(GLclampf)
776 FPTOOLS_CHECK_HTYPE(GLdouble)
777 FPTOOLS_CHECK_HTYPE(GLclampd)
778 fi
779
780 dnl ** can we open files in binary mode?
781 FPTOOLS_O_BINARY
782
783 dnl ** check for GetModuleFileName and WinExec (windows only)
784 dnl Old: AC_CHECK_FUNCS(WinExec GetModuleFileName)       dnl Windows
785 dnl Doesn't work because the linker can't see the functions if
786 dnl you omit the #include <windows.h>.  (I've no idea why not...)
787
788 FPTOOLS_TRY_LINK_NOWARN(,[
789 #if HAVE_WINDOWS_H
790 #include <windows.h>
791 #endif
792 main() { 
793   WinExec("",0);
794   exit(0);
795 }
796 ],
797 [have_winexec=1],
798 [have_winexec=0])
799 if test "$have_winexec" = "1"; then
800 AC_DEFINE(HAVE_WINEXEC)
801 fi
802
803 FPTOOLS_TRY_LINK_NOWARN(,[
804 #if HAVE_WINDOWS_H
805 #include <windows.h>
806 #endif
807 main() { 
808   char* dir;
809   GetModuleFileName((HMODULE)0,dir,0);
810   exit(0);
811 }
812 ],
813 [have_getmodulefilename=1],
814 [have_getmodulefilename=0])
815 if test "$have_getmodulefilename" = "1"; then
816 AC_DEFINE(HAVE_GETMODULEFILENAME)
817 fi
818
819 dnl ** check return type of signal handlers
820 dnl Foo: assumes we can use prototypes.
821 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
822 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
823 dnl [AC_TRY_COMPILE([#include <sys/types.h>
824 dnl #include <signal.h>
825 dnl #ifdef signal
826 dnl #undef signal
827 dnl #endif
828 dnl void (*signal (int, void (*)(int)))(int);
829 dnl ],
830 dnl [int i;], 
831 dnl ac_cv_type_signal_handler=void_int,
832 dnl ac_cv_type_signal_handler=int_void)])
833 dnl if test "$ac_cv_type_signal_handler" = void_int; then
834 dnl AC_DEFINE(VOID_INT_SIGNALS)
835 dnl fi
836
837 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
838 AC_TYPE_SIGNAL
839 if test "$ac_cv_type_signal" = void; then
840 AC_DEFINE(VOID_INT_SIGNALS)
841 fi
842
843 dnl ** check for more functions
844 AC_CHECK_FUNCS(strcasecmp _stricmp stricmp strcmpi)
845 AC_CHECK_FUNCS(strcmp)
846 AC_CHECK_FUNCS(realpath _fullpath)  
847 AC_CHECK_FUNCS(PBHSetVolSync macsystem)  
848 AC_CHECK_FUNCS(fgetpos fsetpos fseek ftell)
849 AC_CHECK_FUNCS(vsnprintf _vsnprintf)
850 AC_CHECK_FUNCS(snprintf  _snprintf )  
851 AC_CHECK_FUNCS(popen     _popen )  
852 AC_CHECK_FUNCS(pclose    _pclose )  
853
854
855 dnl ** check for specific library functions that we are interested in
856 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)
857
858 dnl ** check whether this machine has gmp3 installed
859 AC_CHECK_LIB(gmp,  __gmpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
860   AC_CHECK_LIB(gmp3, __gmpz_fdiv_qr,  HaveLibGmp=YES; LibGmp=gmp3,
861     HaveLibGmp=No; LibGmp=not-installed))
862 AC_SUBST(HaveLibGmp)
863 AC_SUBST(LibGmp)
864
865 dnl ** check whether this machine has GNU regex in libc.
866 FPTOOLS_REGEX_IN_LIBC
867
868 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
869 dnl    the order of these tests matters: bfd needs liberty
870 AC_CHECK_LIB(iberty, xmalloc)
871 AC_CHECK_LIB(bfd,    bfd_init)
872
873 dnl ** check for readline, for Hugs and hslibs' Readline
874 dnl ncurses supersedes termcap and curses, but for compatibility,
875 dnl we have to check for all...
876 AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=YES; LibTermcap=ncurses,
877   AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=YES; LibTermcap=termcap,
878     AC_CHECK_LIB(curses, tputs, HaveLibTermcap=YES; LibTermcap=curses,
879       HaveLibTermcap=NO; LibTermcap=not-installed)))
880
881 if test $HaveLibTermcap = YES ; then
882   LIBS="-l$LibTermcap $LIBS"
883   AC_CHECK_LIB(readline, readline, HaveLibReadline=YES, HaveLibReadline=NO)
884 fi
885
886 if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES ; then
887   AC_DEFINE(HAVE_READLINE_LIBS,1)
888   LibsReadline="readline $LibTermcap"
889 else
890   AC_DEFINE(HAVE_READLINE_LIBS,0)
891   LibsReadline=
892 fi
893 AC_SUBST(LibsReadline)
894
895 if test "$HaveLibReadline"; then
896   AC_CHECK_LIB(readline, rl_erase_empty_line,
897     [AC_DEFINE(HAVE_READLINE_4, 1)],
898     [AC_DEFINE(HAVE_READLINE_4, 0)])
899   AC_CHECK_LIB(readline, rl_free_undo_list,
900     [AC_DEFINE(HAVE_READLINE_4_2, 1)],
901     [AC_DEFINE(HAVE_READLINE_4_2, 0)])
902 else
903   AC_DEFINE(HAVE_READLINE_4, 0)
904   AC_DEFINE(HAVE_READLINE_4_2, 0)
905 fi
906
907 dnl ** check for math library
908 FPTOOLS_CHECK_LIBM()
909 AC_SUBST(LIBM)
910
911 case $HostOS_CPP in
912 cygwin32) ;;
913 mingw32)  ;;
914 *) AC_PATH_XTRA() ;;
915 esac
916
917 dnl ################################################################
918 dnl Check for libraries
919 dnl ################################################################
920
921 AC_CHECK_LIB(dl, dlopen, 
922         [HaveLibDL=YES
923          AC_DEFINE(HAVE_LIBDL)
924          LIBS="$LIBS -ldl"], 
925         [HaveLibDL=NO])
926 AC_CHECK_FUNCS(dlopen)
927 AC_SUBST(HaveLibDL)
928
929 FPTOOLS_CHECK_LIB_NOWARN(m, atan)
930
931 dnl --------------------------------------------------
932 dnl * test for GTK+
933 dnl --------------------------------------------------
934
935 AC_PATH_PROGS(GTK_CONFIG, gtk-config gtk12-config)
936 if test "$GTK_CONFIG" != ""; then
937    AC_CACHE_CHECK([for version of GTK+], fptools_cv_gtk_version, [
938         fptools_cv_gtk_version=`$GTK_CONFIG --version`
939     ])
940     GTK_VERSION=$fptools_cv_gtk_version
941 else
942     GTK_VERSION=
943 fi
944
945 case $fptools_cv_gtk_version in
946   1.[[23]].*) ;;
947   *) AC_MSG_WARN([GTK+ not usable; need at least version 1.2])
948      GTK_CONFIG=
949      ;;
950 esac
951
952 AC_SUBST(GTK_CONFIG)
953 AC_SUBST(GTK_VERSION)
954
955 dnl --------------------------------------------------
956 dnl * Miscellaneous feature tests
957 dnl --------------------------------------------------
958
959 dnl ** can we get alloca?
960 AC_FUNC_ALLOCA
961
962 dnl ** determine whether or not const works
963 AC_C_CONST
964
965 dnl ** determine whether ANSI-function prototypes work?
966 AC_C_PROTOTYPES          
967
968 dnl ** are we big endian?
969 AC_C_BIGENDIAN
970 # Allay users' general fear of warnings of any kind.
971 errprint(fptools configure script wizard sez: autoconf-2.50 or later should produce no warnings
972 )
973 errprint(if you are using 2.13 or earlier, you may get a (harmless) warning message.
974 )
975
976 dnl ** check for leading underscores in symbol names
977 FPTOOLS_UNDERSCORE
978
979 dnl ** how is the end of text section signalled?
980 FPTOOLS_END_TEXT_SECTION
981
982 dnl ** how is the end of data section signalled?
983 FPTOOLS_END_DATA_SECTION
984
985 dnl ** code before data?
986 FPTOOLS_CODE_BEFORE_DATA
987
988 dnl ** check for ld, and whether ld has -x option
989 AC_PATH_PROG(LdCmd, ld)
990 FPTOOLS_LD_X
991
992 AC_OUTPUT(mk/config.mk, echo timestamp > mk/stamp-h )