[project @ 2000-08-04 23:31:43 by lewie]
[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 AC_CONFIG_SUBDIRS(ghc)
24
25 # -------------------------------------------------------------------------
26 # Prepare to generate the following header files
27 #
28 #
29 AC_CONFIG_HEADER(mk/config.h)
30
31 # No, semi-sadly, we don't do `--srcdir'...
32 if test x"$srcdir" != 'x.' ; then
33     echo "This configuration does not support the \`--srcdir' option.."
34     exit 1
35 fi
36
37 #
38 # Remove common automounter nonsense + convert from UNC to DOS style paths
39 # (UNC awareness isn't quite there yet for cygwin32-beta18 and consituent tools.)
40 #
41 hardtop=`pwd`
42 hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|' | sed 's|^/grasp_tmp|/local/grasp_tmp|' | sed 's|^//\(.\)/|\1:/|' `
43
44 echo ''
45 echo "*** The top of your build tree is: $hardtop"
46 AC_SUBST(hardtop)
47
48 dnl--------------------------------------------------------------------
49 dnl * Choose host(/target/build) platform
50 dnl--------------------------------------------------------------------
51
52 dnl Guess host/target/build platform(s) if necessary.
53 AC_CANONICAL_SYSTEM
54
55 # "$host" defaults to "$target"
56 if test "x$host" = xNONE ; then
57     host=$target
58 fi
59
60 dnl ** canonicalize platform names
61 BuildPlatform=`/bin/sh $srcdir/config.sub $build` || exit 1
62 HostPlatform=`/bin/sh $srcdir/config.sub $host` || exit 1
63 TargetPlatform=`/bin/sh $srcdir/config.sub $target` || exit 1
64
65 if test x"$TargetPlatform" != x"$HostPlatform" ; then
66     echo "GHC configuration does not support differing host/target (i.e., cross-compiling)"
67     exit 1
68 fi
69
70 exeext=''
71 #
72 # The following will be more difficult when we *are* cross-compiling.
73 # Suitable names to slam in *_CPP are in platform.h.in.
74 # We also record the architecture, vendor, and operating system (OS)
75 # separately.
76 case $HostPlatform in
77 alpha-dec-osf[[12]]*)
78         HostPlatform=alpha-dec-osf1   # canonicalise for our purposes
79         TargetPlatform=alpha-dec-osf1 # this will work for now... (hack)
80         BuildPlatform=alpha-dec-osf1  # hack
81         HostPlatform_CPP='alpha_dec_osf1'
82         HostArch_CPP='alpha'
83         HostVendor_CPP='dec'
84         HostOS_CPP='osf1'
85         ;;
86 alpha-dec-osf[[34]]*)
87         HostPlatform=alpha-dec-osf3   # canonicalise for our purposes
88         TargetPlatform=alpha-dec-osf3 # this will work for now... (hack)
89         BuildPlatform=alpha-dec-osf3  # hack
90         HostPlatform_CPP='alpha_dec_osf3'
91         HostArch_CPP='alpha'
92         HostVendor_CPP='dec'
93         HostOS_CPP='osf3'
94         ;;
95 alpha-unknown-linux)
96         HostPlatform=alpha-unknown-linux
97         TargetPlatform=alpha-unknown-linux
98         BuildPlatform=alpha-unknown-linux
99         HostPlatform_CPP='alpha_unknown_linux'
100         HostArch_CPP='alpha'
101         HostVendor_CPP='unknown'
102         HostOS_CPP='linux'
103         ;;
104 alpha-unknown-freebsd*)
105         HostPlatform=alpha-unknown-freebsd
106         TargetPlatform=alpha-unknown-freebsd
107         BuildPlatform=alpha-unknown-freebsd
108         HostPlatform_CPP='alpha_unknown_freebsd'
109         HostArch_CPP='alpha'
110         HostVendor_CPP='unknown'
111         HostOS_CPP='freebsd'
112         ;;
113 hppa1.1-hp-hpux*)
114         HostPlatform=hppa1.1-hp-hpux  # canonicalise for our purposes (hack)
115         TargetPlatform=hppa1.1-hp-hpux
116         BuildPlatform=hppa1.1-hp-hpux
117         HostPlatform_CPP='hppa1_1_hp_hpux'
118         HostArch_CPP='hppa1_1'
119         HostVendor_CPP='hp'
120         HostOS_CPP='hpux'
121         ;;
122 i[[3456]]86-*-linuxaout*)
123         HostPlatform=i386-unknown-linuxaout   # hack again
124         TargetPlatform=i386-unknown-linuxaout
125         BuildPlatform=i386-unknown-linuxaout
126         HostPlatform_CPP='i386_unknown_linuxaout'
127         HostArch_CPP='i386'
128         HostVendor_CPP='unknown'
129         HostOS_CPP='linuxaout'
130         ;;
131 i[[3456]]86-*-linux*)
132         HostPlatform=i386-unknown-linux # hack again
133         TargetPlatform=i386-unknown-linux
134         BuildPlatform=i386-unknown-linux
135         HostPlatform_CPP='i386_unknown_linux'
136         HostArch_CPP='i386'
137         HostVendor_CPP='unknown'
138         HostOS_CPP='linux'
139         ;;
140 i[[3456]]86-*-freebsd[[3-9]]*) # FreeBSD 3.0+ uses ELF
141         HostPlatform=i386-unknown-freebsd # hack again
142         TargetPlatform=i386-unknown-freebsd
143         BuildPlatform=i386-unknown-freebsd
144         HostPlatform_CPP='i386_unknown_freebsd'
145         HostArch_CPP='i386'
146         HostVendor_CPP='unknown'
147         HostOS_CPP='freebsd'
148         ;;
149 i[[3456]]86-*-freebsd2*) # Older FreeBSDs are a.out
150         HostPlatform=i386-unknown-freebsd2 # hack again
151         TargetPlatform=i386-unknown-freebsd2
152         BuildPlatform=i386-unknown-freebsd2
153         HostPlatform_CPP='i386_unknown_freebsd2'
154         HostArch_CPP='i386'
155         HostVendor_CPP='unknown'
156         HostOS_CPP='freebsd2'
157         ;;
158 i[[3456]]86-*-netbsd*)
159         HostPlatform=i386-unknown-netbsd # hack again
160         TargetPlatform=i386-unknown-netbsd
161         BuildPlatform=i386-unknown-netbsd
162         HostPlatform_CPP='i386_unknown_netbsd'
163         HostArch_CPP='i386'
164         HostVendor_CPP='unknown'
165         HostOS_CPP='netbsd'
166         ;;
167 i[[3456]]86-*-openbsd*)
168         HostPlatform=i386-unknown-openbsd # hack again
169         TargetPlatform=i386-unknown-openbsd
170         BuildPlatform=i386-unknown-openbsd
171         HostPlatform_CPP='i386_unknown_openbsd'
172         HostArch_CPP='i386'
173         HostVendor_CPP='unknown'
174         HostOS_CPP='openbsd'
175         ;;
176 i[[3456]]86-*-solaris2*)
177         HostPlatform=i386-unknown-solaris2 # hack again
178         TargetPlatform=i386-unknown-solaris2
179         BuildPlatform=i386-unknown-solaris2
180         HostPlatform_CPP='i386_unknown_solaris2'
181         HostArch_CPP='i386'
182         HostVendor_CPP='unknown'
183         HostOS_CPP='solaris2'
184         ;;
185 i[[3456]]86-*-cygwin32*)
186         HostPlatform=i386-unknown-cygwin32 # hack again
187         TargetPlatform=i386-unknown-cygwin32
188         BuildPlatform=i386-unknown-cygwin32
189         HostPlatform_CPP='i386_unknown_cygwin32'
190         HostArch_CPP='i386'
191         HostVendor_CPP='unknown'
192         HostOS_CPP='cygwin32'
193         exeext='.exe'
194         ;;
195 i[[3456]]86-*-mingw32*)
196         HostPlatform=i386-unknown-mingw32 # hack again
197         TargetPlatform=i386-unknown-mingw32
198         BuildPlatform=i386-unknown-mingw32
199         HostPlatform_CPP='i386_unknown_mingw32'
200         HostArch_CPP='i386'
201         HostVendor_CPP='unknown'
202         HostOS_CPP='mingw32'
203         exeext='.exe'
204         # We assume you're using mingw32 via the gcc that comes
205         # with cygwin, and not the native port, so let's augment
206         # the gcc command-line used here with -mno-cygwin to
207         # arrange for good things to happen.
208         CFLAGS="-mno-cygwin $CFLAGS"
209         ;;
210 m68k-next-nextstep2)
211         HostPlatform_CPP='m68k_next_nextstep2'
212         HostArch_CPP='m68k'
213         HostVendor_CPP='next'
214         HostOS_CPP='nextstep2'
215         ;;
216 m68k-next-nextstep3)
217         HostPlatform_CPP='m68k_next_nextstep3'
218         HostArch_CPP='m68k'
219         HostVendor_CPP='next'
220         HostOS_CPP='nextstep3'
221         ;;
222 i[[3456]]86-next-nextstep3)
223         HostPlatform=i386-next-nextstep3 # hack again
224         TargetPlatform=i386-next-nextstep3
225         BuildPlatform=i386-next-nextstep3
226         HostPlatform_CPP='i386_next_nextstep3'
227         HostArch_CPP='i386'
228         HostVendor_CPP='next'
229         HostOS_CPP='nextstep3'
230         ;;
231 m68k-sun-sunos4*)
232         HostPlatform=m68k-sun-sunos4
233         TargetPlatform=m68k-sun-sunos4 #hack
234         BuildPlatform=m68k-sun-sunos4 #hack
235         HostPlatform_CPP='m68k_sun_sunos4'
236         HostArch_CPP='m68k'
237         HostVendor_CPP='sun'
238         HostOS_CPP='sunos4'
239         ;;
240 mips-dec-ultrix*)
241         HostPlatform_CPP='mips_dec_ultrix'
242         HostArch_CPP='mipsel'   # NB a little different
243         HostVendor_CPP='dec'
244         HostOS_CPP='ultrix'
245         ;;
246 mips-sgi-irix*)
247         HostPlatform=mips-sgi-irix
248         TargetPlatform=mips-sgi-irix #hack
249         BuildPlatform=mips-sgi-irix #hack
250         HostPlatform_CPP='mips_sgi_irix'
251         HostArch_CPP='mipseb'   # NB a little different
252         HostVendor_CPP='sgi'
253         HostOS_CPP='irix'
254         ;;
255 rs6000-ibm-aix*)
256         HostPlatform=rs6000-ibm-aix
257         TargetPlatform=rs6000-ibm-aix #hack
258         BuildPlatform=rs6000-ibm-aix #hack
259         HostPlatform_CPP='rs6000_ibm_aix'
260         HostArch_CPP='rs6000'
261         HostVendor_CPP='ibm'
262         HostOS_CPP='aix'
263         ;;
264 powerpc-ibm-aix*)
265         HostPlatform=powerpc-ibm-aix
266         TargetPlatform=powerpc-ibm-aix #hack
267         BuildPlatform=powerpc-ibm-aix #hack
268         HostPlatform_CPP='powerpc_ibm_aix'
269         HostArch_CPP='powerpc'
270         HostVendor_CPP='ibm'
271         HostOS_CPP='aix'
272         ;;
273 sparc-sun-sunos4*)
274         HostPlatform=sparc-sun-sunos4
275         TargetPlatform=sparc-sun-sunos4 #hack
276         BuildPlatform=sparc-sun-sunos4 #hack
277         HostPlatform_CPP='sparc_sun_sunos4'
278         HostArch_CPP='sparc'
279         HostVendor_CPP='sun'
280         HostOS_CPP='sunos4'
281         ;;
282 sparc-sun-solaris2*)
283         HostPlatform=sparc-sun-solaris2
284         TargetPlatform=sparc-sun-solaris2 #hack
285         BuildPlatform=sparc-sun-solaris2 #hack
286         HostPlatform_CPP='sparc_sun_solaris2'
287         HostArch_CPP='sparc'
288         HostVendor_CPP='sun'
289         HostOS_CPP='solaris2'
290         ;;
291 *)
292         echo "Unrecognised platform: $HostPlatform"
293         exit 1
294         ;;
295 esac
296 echo "Canonicalised to: $HostPlatform"
297 test  x"$HostPlatform" != x"$TargetPlatform" && echo "Target platform set to $TargetPlatform"
298 test  x"$BuildPlatform" != x"$HostPlatform"  && echo "Build platform set to $BuildPlatform"
299
300 BuildPlatform_CPP=$HostPlatform_CPP
301 TargetPlatform_CPP=$HostPlatform_CPP
302 BuildArch_CPP=$HostArch_CPP
303 TargetArch_CPP=$HostArch_CPP
304 BuildOS_CPP=$HostOS_CPP
305 HostOS_Full=$host_os
306 TargetOS_CPP=$HostOS_CPP
307 BuildVendor_CPP=$HostVendor_CPP
308 TargetVendor_CPP=$HostVendor_CPP
309
310 dnl Cannot afford all these SUBSTs (because of braindead seds w/ 99 cmd limits)
311 dnl AC_SUBST(BuildPlatform)
312
313 AC_SUBST(HostPlatform)
314 AC_SUBST(TargetPlatform)
315 AC_SUBST(HostPlatform_CPP)
316 dnl AC_SUBST(BuildPlatform_CPP)
317 dnl AC_SUBST(TargetPlatform_CPP)
318
319 AC_SUBST(HostArch_CPP)
320 dnl AC_SUBST(BuildArch_CPP)
321 dnl AC_SUBST(TargetArch_CPP)
322
323 AC_SUBST(HostOS_CPP)
324 AC_SUBST(HostOS_Full)
325 dnl AC_SUBST(BuildOS_CPP)
326 dnl AC_SUBST(TargetOS_CPP)
327
328 AC_SUBST(HostVendor_CPP)
329 dnl AC_SUBST(BuildVendor_CPP)
330 dnl AC_SUBST(TargetVendor_CPP)
331
332 AC_SUBST(exeext)
333
334 if test "$GHC" = ""; then
335   AC_PATH_PROG(GHC,ghc)
336 fi
337 if test "$GHC" != ""; then
338   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
339   AC_SUBST(GhcVersion)dnl
340   AC_SUBST(GhcMajVersion)dnl
341   AC_SUBST(GhcMinVersion)dnl
342   AC_SUBST(GhcPatchLevel)dnl
343 fi
344
345 AC_PATH_PROGS(NHC,nhc nhc98)
346 AC_PATH_PROG(HBC,hbc)
347
348 dnl --------------------------------------------------------------
349 dnl * Project specific configuration options
350 dnl --------------------------------------------------------------
351 dnl What follows is a bunch of options that can either be configured
352 dnl through command line options to the configure script or by
353 dnl supplying defns in the build tree's mk/build.mk. Having the option to
354 dnl use either is considered a Feature.
355
356 dnl ** What command to use to compile compiler sources ?
357 dnl --------------------------------------------------------------
358 AC_ARG_WITH(hc,
359 [  --with-hc=<haskell compiler>
360         Use a command different from 'ghc' to compile up Haskell code.
361         (no claims currently made that this will work with a compiler other than a
362          recent version of GHC, but you could always try...)
363 ],
364 [WithHc="$withval"],
365 [WithHc=$GHC]
366 )
367 AC_SUBST(WithHc)
368
369 dnl ** Which gcc to use?
370 dnl --------------------------------------------------------------
371 AC_ARG_WITH(gcc,
372 [  --with-gcc=<gcc command>
373         Use a different command instead of 'gcc' for the GNU C compiler.
374 ],
375 [WhatGccIsCalled="$withval"],
376 [WhatGccIsCalled="gcc"]
377 )
378 AC_SUBST(WhatGccIsCalled)
379
380 dnl ** Booting from .hc files?
381 dnl --------------------------------------------------------------
382 AC_ARG_ENABLE(hc-boot,
383 [  --enable-hc-boot
384         Boot the Glasgow Haskell Compiler from intermediate .hc files.
385         (This option is mostly of interest to porters.)
386 ],
387 [BootingFromHc=YES],
388 [BootingFromHc=NO]
389 )
390 AC_SUBST(BootingFromHc)
391
392
393 dnl ** Enable the construction of Win32 DLLs?
394 dnl --------------------------------------------------------------
395 AC_ARG_ENABLE(win32-dlls,
396 [  --enable-win32-dlls
397         If on a Win32 platform running mingw32/cygwin, enable the
398         construction of DLLs containing ghc-compiled code.
399 ],
400 [
401 case $HostOS_CPP in
402 cygwin32) ;;
403 mingw32)  ;;
404 *)    echo "Unrecognised win32 platform: $HostPlatform"
405       exit 1
406       ;;
407 esac
408 EnableWin32DLLs=YES
409 ],
410 [EnableWin32DLLs=NO]
411 )
412 AC_SUBST(EnableWin32DLLs)
413 if test x"$EnableWin32DLLs" = "xYES" ; then
414  AC_DEFINE(HAVE_WIN32_DLL_SUPPORT)
415 fi
416
417 dnl --------------------------------------------------------------
418 dnl End of configure script option section
419 dnl --------------------------------------------------------------
420
421
422 dnl --------------------------------------------------------------
423 dnl * General configuration checks
424 dnl --------------------------------------------------------------
425
426 dnl ** does #! work?
427 AC_SYS_INTERPRETER()
428
429 dnl ** look for `perl', but only in /bin on Windows
430 case $HostOS_CPP in
431 cygwin32|mingw32)
432    AC_CHECK_PROG(PerlCmd,perl,/bin/perl,,/bin)
433    if test -z "$PerlCmd"; then
434       echo "You must install the version of Perl shipped with GHC"
435       echo "(or a compatible one) in /bin."
436       exit 1
437    fi
438    ;;
439 *)
440    AC_PATH_PROG(PerlCmd,perl)
441    if test -z "$PerlCmd"; then
442       echo "You must install perl before you can continue"
443       echo "Perhaps it is already installed, but not in your PATH?"
444       exit 1
445    else
446    FPTOOLS_CHECK_PERL_VERSION
447    fi
448    ;;
449 esac
450
451 dnl ** does #! path/to/perl work? (sometimes it's too long...)
452 FPTOOLS_SHEBANG_PERL
453
454
455 dnl ** look for GCC and find out which version
456 dnl     Figure out which C compiler to use.  Gcc is preferred.
457 dnl     If gcc, make sure it's at least 2.1
458 dnl
459 AC_PROG_CC
460 FPTOOLS_HAVE_GCC
461
462 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
463 AC_PROG_CPP
464
465 dnl ** figure out how to do context diffs
466 FPTOOLS_PROG_DIFF
467
468 dnl ** Find find command (for Win32's benefit)
469 AC_PATH_PROG(FindCmd, find)
470
471 dnl ** look for a decent parser generator (bison preferred)
472 dnl (FPTOOLS_PROG_YACCY is AC_PROG_YACC, but with some extra testing 
473 dnl  on the suitability of the 'yacc' returned.)
474 FPTOOLS_PROG_YACCY
475
476 dnl ** Find lex command (lex or flex) and library (-ll or -lfl)
477 dnl     ( not that we care about the latter, see mk/config.mk.in )
478 AC_PROG_LEX
479
480
481 dnl ** figure out how to do a BSD-ish install
482 AC_PROG_INSTALL
483
484 dnl If you can run configure, you certainly have /bin/sh
485 AC_DEFINE(HAVE_BIN_SH)
486
487 dnl ** how to invoke `ar' and `ranlib'
488 FPTOOLS_PROG_AR_AND_RANLIB
489
490
491 dnl ** Check to see whether ln -s works
492 AC_PROG_LN_S
493
494
495 dnl ** Find the path to sed
496 AC_PATH_PROG(SedCmd,sed)
497
498
499 dnl ** check for time command
500 AC_PATH_PROG(TimeCmd,time)
501
502
503 dnl ** check for tar
504 dnl   if GNU tar is named gtar, look for it first.
505 AC_PATH_PROGS(TarCmd,gtar tar,tar)
506
507 dnl ** check for gzip/compress
508 AC_PATH_PROGS(CompressCmd,gzip compress,gzip)
509
510 dnl ** check for jade/openjade & determine a working catalog
511 AC_PATH_PROGS(JadeCmd,openjade jade,jade)
512 FPTOOLS_DOCBOOK_CATALOG(Catalog, $JadeCmd, docs/fptools-both.dsl, 
513                         /etc/sgml.catalog /usr/share/sgml/CATALOG.docbkdsl $hardtop/glafp-utils/docbook/CATALOG*)
514 if test -z "$Catalog"; then
515   AC_MSG_RESULT([Warning: You will not be able to build the documentation.])
516 fi
517 AC_SUBST(Catalog)
518
519 compress_nm=`basename $CompressCmd`
520 if test x"$compress_nm" = xgzip; then
521   CompressCmd="$CompressCmd -d"
522   CompressSuffix="gz"
523 else
524   CompressSuffix="Z"
525 fi
526 AC_SUBST(CompressCmd)
527 AC_SUBST(CompressSuffix)
528
529 dnl ** check for installed happy binary + version
530 dnl    (don't do it if we're booting from .hc files though.)
531 if (test "$BootingFromHc" = "NO"); then
532 FPTOOLS_HAPPY
533 fi;
534
535 dnl --------------------------------------------------
536 dnl ### program checking section ends here ###
537 dnl --------------------------------------------------
538
539 dnl --------------------------------------------------
540 dnl * Platform header file and syscall feature tests
541 dnl ### checking the state of the local header files and syscalls ###
542
543 dnl ** check for full ANSI header (.h) files
544 AC_HEADER_STDC
545
546 dnl ** check for specific header (.h) files that we are interested in
547 AC_CHECK_HEADERS(Files.h assert.h console.h ctype.h dirent.h errno.h fcntl.h float.h ftw.h grp.h ieee754.h malloc.h memory.h nlist.h pascal.h pwd.h sgtty.h siginfo.h signal.h stat.h stdint.h stdlib.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 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/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)
548
549 AC_CHECK_HEADER(readline/readline.h, HaveReadlineReadlineH=YES, HaveReadlineReadlineH=NO)
550 AC_CHECK_HEADER(readline/history.h, HaveReadlineHistoryH=YES, HaveReadlineHistoryH=NO)
551
552 if test $HaveReadlineReadlineH = YES && test $HaveReadlineHistoryH = YES ; then
553   HaveReadlineHeaders=YES
554   AC_DEFINE(HAVE_READLINE_HEADERS,1)
555 else
556   HaveReadlineHeaders=NO
557   AC_DEFINE(HAVE_READLINE_HEADERS,0)
558 fi
559 AC_SUBST(HaveReadlineHeaders)
560
561 dnl ** check for DOS include files
562 AC_CHECK_HEADERS(dos.h conio.h io.h std.h) 
563
564 dnl ** check for Windows include files
565 AC_CHECK_HEADERS(windows.h)
566
567 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
568 AC_HEADER_TIME
569
570 dnl dynamic loading include files
571 AC_CHECK_HEADERS(dlfcn.h dl.h) 
572
573 dnl ** check for farcalloc (in bcc)
574 AC_CHECK_HEADER(alloc.h,AC_CHECK_FUNCS(farcalloc))
575
576 dnl ** check for valloc (in sunos, solaris, mips, amiga, next, minix, ultrix)
577 AC_CHECK_HEADER(malloc.h,AC_CHECK_FUNCS(valloc))
578
579 dnl ** how do we get a timezone name, and UTC offset ?
580 AC_STRUCT_TIMEZONE
581
582 dnl ** what's the type of timezone?
583 FPTOOLS_HAVE_TIMEZONE
584 FPTOOLS_TYPE_TIMEZONE
585
586 dnl ** do we have altzone?
587 FPTOOLS_ALTZONE
588
589 dnl ** does struct stat contain st_blksize?
590 AC_STRUCT_ST_BLKSIZE
591
592 dnl ** do we have long longs?
593 FPTOOLS_C_LONG_LONG
594
595 dnl ** what are the sizes of various types
596 dnl    (these must come before GHC_CHECK_ALIGNMENT)
597 AC_CHECK_SIZEOF(char,               1)
598 AC_CHECK_SIZEOF(double,             8)
599 AC_CHECK_SIZEOF(float,              4)
600 AC_CHECK_SIZEOF(int,                4)
601 AC_CHECK_SIZEOF(long,               4)
602 if test "$fptools_cv_have_long_long" = yes; then
603 AC_CHECK_SIZEOF(long long,          8)
604 fi
605 AC_CHECK_SIZEOF(short,              2)
606 AC_CHECK_SIZEOF(unsigned char,      1)
607 AC_CHECK_SIZEOF(unsigned int,       4)
608 AC_CHECK_SIZEOF(unsigned long,      4)
609 if test "$fptools_cv_have_long_long" = yes; then
610 AC_CHECK_SIZEOF(unsigned long long, 8)
611 fi
612 AC_CHECK_SIZEOF(unsigned short,     2)
613 AC_CHECK_SIZEOF(void *,             4)
614
615 dnl ** what are alignment constraints on various types
616 FPTOOLS_CHECK_ALIGNMENT(char)
617 FPTOOLS_CHECK_ALIGNMENT(double)
618 FPTOOLS_CHECK_ALIGNMENT(float)
619 FPTOOLS_CHECK_ALIGNMENT(int)
620 FPTOOLS_CHECK_ALIGNMENT(long)
621 if test "$fptools_cv_have_long_long" = yes; then
622 FPTOOLS_CHECK_ALIGNMENT(long long)
623 fi
624 FPTOOLS_CHECK_ALIGNMENT(short)
625 FPTOOLS_CHECK_ALIGNMENT(unsigned char)
626 FPTOOLS_CHECK_ALIGNMENT(unsigned int)
627 FPTOOLS_CHECK_ALIGNMENT(unsigned long)
628 if test "$fptools_cv_have_long_long" = yes; then
629 FPTOOLS_CHECK_ALIGNMENT(unsigned long long)
630 fi
631 FPTOOLS_CHECK_ALIGNMENT(unsigned short)
632 FPTOOLS_CHECK_ALIGNMENT(void *)
633
634 dnl ** map standard C types and ISO types to Haskell types
635 FPTOOLS_CHECK_HTYPE(char)
636 FPTOOLS_CHECK_HTYPE(signed char)
637 FPTOOLS_CHECK_HTYPE(unsigned char)
638 FPTOOLS_CHECK_HTYPE(short)
639 FPTOOLS_CHECK_HTYPE(unsigned short)
640 FPTOOLS_CHECK_HTYPE(int)
641 FPTOOLS_CHECK_HTYPE(unsigned int)
642 FPTOOLS_CHECK_HTYPE(long)
643 FPTOOLS_CHECK_HTYPE(unsigned long)
644 if test "$fptools_cv_have_long_long" = yes; then
645 FPTOOLS_CHECK_HTYPE(long long)
646 FPTOOLS_CHECK_HTYPE(unsigned long long)
647 fi
648 FPTOOLS_CHECK_HTYPE(float)
649 FPTOOLS_CHECK_HTYPE(double)
650 FPTOOLS_CHECK_HTYPE(ptrdiff_t)
651 FPTOOLS_CHECK_HTYPE(size_t)
652 FPTOOLS_CHECK_HTYPE(wchar_t)
653 dnl Int32 is a HACK for non-ISO C compilers
654 FPTOOLS_CHECK_HTYPE(sig_atomic_t, Int32)
655 FPTOOLS_CHECK_HTYPE(clock_t)
656 FPTOOLS_CHECK_HTYPE(time_t)
657
658 dnl ** can we open files in binary mode?
659 FPTOOLS_O_BINARY
660
661 dnl ** check for GetModuleFileName and WinExec (windows only)
662 dnl Old: AC_CHECK_FUNCS(WinExec GetModuleFileName)       dnl Windows
663 dnl Doesn't work because the linker can't see the functions if
664 dnl you omit the #include <windows.h>.  (I've no idea why not...)
665
666 FPTOOLS_TRY_LINK_NOWARN(,[
667 #if HAVE_WINDOWS_H
668 #include <windows.h>
669 #endif
670 main() { 
671   WinExec("",0);
672   exit(0);
673 }
674 ],
675 [have_winexec=1],
676 [have_winexec=0])
677 if test "$have_winexec" = "1"; then
678 AC_DEFINE(HAVE_WINEXEC)
679 fi
680
681 FPTOOLS_TRY_LINK_NOWARN(,[
682 #if HAVE_WINDOWS_H
683 #include <windows.h>
684 #endif
685 main() { 
686   char* dir;
687   GetModuleFileName((HMODULE)0,dir,0);
688   exit(0);
689 }
690 ],
691 [have_getmodulefilename=1],
692 [have_getmodulefilename=0])
693 if test "$have_getmodulefilename" = "1"; then
694 AC_DEFINE(HAVE_GETMODULEFILENAME)
695 fi
696
697 dnl ** check return type of signal handlers
698 dnl Foo: assumes we can use prototypes.
699 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
700 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
701 dnl [AC_TRY_COMPILE([#include <sys/types.h>
702 dnl #include <signal.h>
703 dnl #ifdef signal
704 dnl #undef signal
705 dnl #endif
706 dnl void (*signal (int, void (*)(int)))(int);
707 dnl ],
708 dnl [int i;], 
709 dnl ac_cv_type_signal_handler=void_int,
710 dnl ac_cv_type_signal_handler=int_void)])
711 dnl if test "$ac_cv_type_signal_handler" = void_int; then
712 dnl AC_DEFINE(VOID_INT_SIGNALS)
713 dnl fi
714
715 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
716 AC_TYPE_SIGNAL
717 if test "$ac_cv_type_signal" = void; then
718 AC_DEFINE(VOID_INT_SIGNALS)
719 fi
720
721 dnl ** check for more functions
722 AC_CHECK_FUNCS(strcasecmp _stricmp stricmp strcmpi)
723 AC_CHECK_FUNCS(strcmp)
724 AC_CHECK_FUNCS(realpath _fullpath)  
725 AC_CHECK_FUNCS(PBHSetVolSync macsystem)  
726 AC_CHECK_FUNCS(fgetpos fsetpos fseek ftell)
727 AC_CHECK_FUNCS(vsnprintf _vsnprintf)
728 AC_CHECK_FUNCS(snprintf  _snprintf )  
729 AC_CHECK_FUNCS(popen     _popen )  
730 AC_CHECK_FUNCS(pclose    _pclose )  
731
732
733 dnl ** check for specific library functions that we are interested in
734 AC_CHECK_FUNCS(access ftime getclock getpagesize getrusage gettimeofday mktime mprotect readlink setitimer stat symlink sysconf timelocal times vadvise vfork)
735
736 dnl ** check whether this machine has gmp2 installed
737 AC_CHECK_LIB(gmp,  mpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
738   AC_CHECK_LIB(gmp2, mpz_fdiv_qr,  HaveLibGmp=YES; LibGmp=gmp2,
739     HaveLibGmp=No; LibGmp=not-installed))
740 AC_SUBST(HaveLibGmp)
741 AC_SUBST(LibGmp)
742
743 dnl ** check whether this machine has GNU regex in libc.
744 FPTOOLS_REGEX_IN_LIBC
745
746 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
747 dnl    the order of these tests matters: bfd needs liberty
748 AC_CHECK_LIB(iberty, xmalloc)
749 AC_CHECK_LIB(bfd,    bfd_init)
750
751 dnl ** check for readline, for Hugs and hslibs' Readline
752 dnl ncurses supersedes termcap and curses, but for compatibility,
753 dnl we have to check for all...
754 AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=YES; LibTermcap=ncurses,
755   AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=YES; LibTermcap=termcap,
756     AC_CHECK_LIB(curses, tputs, HaveLibTermcap=YES; LibTermcap=curses,
757       HaveLibTermcap=NO; LibTermcap=not-installed)))
758
759 if test $HaveLibTermcap = YES ; then
760   LIBS="-l$LibTermcap $LIBS"
761   AC_CHECK_LIB(readline, readline, HaveLibReadline=YES, HaveLibReadline=NO)
762 fi
763
764 if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES ; then
765   AC_DEFINE(HAVE_READLINE_LIBS,1)
766   LibsReadline="-lreadline -l$LibTermcap"
767 else
768   AC_DEFINE(HAVE_READLINE_LIBS,0)
769   LibsReadline=
770 fi
771 AC_SUBST(LibsReadline)
772
773 dnl ################################################################
774 dnl Check for libraries
775 dnl ################################################################
776
777 FPTOOLS_CHECK_LIB_NOWARN(dl, dlopen)
778 FPTOOLS_CHECK_LIB_NOWARN(dld, shl_load)
779 FPTOOLS_CHECK_LIB_NOWARN(m, atan)
780
781 dnl --------------------------------------------------
782 dnl * Miscellaneous feature tests
783 dnl --------------------------------------------------
784
785 dnl ** can we get alloca?
786 AC_FUNC_ALLOCA
787
788 dnl ** determine whether or not const works
789 AC_C_CONST
790
791 dnl ** determine whether ANSI-function prototypes work?
792 AC_C_PROTOTYPES          
793
794 dnl ** are we big endian?
795 AC_C_BIGENDIAN
796 # Allay users' general fear of warnings of any kind.
797 errprint((fptools configure script wizard sez: "don't worry, the above warning is harmless (to us.)")
798 )
799
800 dnl ** check for leading underscores in symbol names
801 FPTOOLS_UNDERSCORE
802
803 dnl ** how is the end of text section signalled?
804 FPTOOLS_END_TEXT_SECTION
805
806 dnl ** how is the end of data section signalled?
807 FPTOOLS_END_DATA_SECTION
808
809 dnl ** code before data?
810 FPTOOLS_CODE_BEFORE_DATA
811
812 AC_OUTPUT(mk/config.mk, echo timestamp > mk/stamp-h )
813
814 echo ''
815 echo '************************************************'
816 echo '*** NOW DO: gmake boot followed by gmake all'
817 echo '***         (where gmake == GNU make)'
818 echo '************************************************'
819 exit 0