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)
6 # (c) The AQUA Project, Glasgow University, 1994-1998
8 # Configure script template for the Glasgow functional programming tools
10 # Process with 'autoconf' to get a working configure script.
12 # For the generated configure script, do "./configure --help" to
13 # see what flags are available. (Better yet, read the documentation!)
16 # First off, a distrib sanity check..
17 AC_INIT(mk/config.mk.in)
19 # -------------------------------------------------------------------------
20 # Prepare to generate the following header files
23 AC_CONFIG_HEADER(mk/config.h)
25 # No, semi-sadly, we don't do `--srcdir'...
26 if test x"$srcdir" != 'x.' ; then
27 echo "This configuration does not support the \`--srcdir' option.."
32 # Remove common automounter nonsense + convert from UNC to DOS style paths
33 # (UNC awareness isn't quite there yet for cygwin32-beta18 and consituent tools.)
36 hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|' | sed 's|^/grasp_tmp|/local/grasp_tmp|' | sed 's|^//\(.\)/|\1:/|' `
39 echo "*** The top of your build tree is: $hardtop"
42 dnl--------------------------------------------------------------------
43 dnl * Choose host(/target/build) platform
44 dnl--------------------------------------------------------------------
46 dnl Guess host/target/build platform(s) if necessary.
49 # "$host" defaults to "$target"
50 if test "x$host" = xNONE ; then
54 dnl ** canonicalize platform names
55 BuildPlatform=`/bin/sh $srcdir/config.sub $build` || exit 1
56 HostPlatform=`/bin/sh $srcdir/config.sub $host` || exit 1
57 TargetPlatform=`/bin/sh $srcdir/config.sub $target` || exit 1
59 if test x"$TargetPlatform" != x"$HostPlatform" ; then
60 echo "GHC configuration does not support differing host/target (i.e., cross-compiling)"
66 # The following will be more difficult when we *are* cross-compiling.
67 # Suitable names to slam in *_CPP are in platform.h.in.
68 # We also record the architecture, vendor, and operating system (OS)
72 HostPlatform=alpha-dec-osf1 # canonicalise for our purposes
73 TargetPlatform=alpha-dec-osf1 # this will work for now... (hack)
74 BuildPlatform=alpha-dec-osf1 # hack
75 HostPlatform_CPP='alpha_dec_osf1'
81 HostPlatform=alpha-dec-osf3 # canonicalise for our purposes
82 TargetPlatform=alpha-dec-osf3 # this will work for now... (hack)
83 BuildPlatform=alpha-dec-osf3 # hack
84 HostPlatform_CPP='alpha_dec_osf3'
90 HostPlatform=hppa1.1-hp-hpux # canonicalise for our purposes (hack)
91 TargetPlatform=hppa1.1-hp-hpux
92 BuildPlatform=hppa1.1-hp-hpux
93 HostPlatform_CPP='hppa1_1_hp_hpux'
94 HostArch_CPP='hppa1_1'
98 i[[3456]]86-*-linuxaout*)
99 HostPlatform=i386-unknown-linuxaout # hack again
100 TargetPlatform=i386-unknown-linuxaout
101 BuildPlatform=i386-unknown-linuxaout
102 HostPlatform_CPP='i386_unknown_linuxaout'
104 HostVendor_CPP='unknown'
105 HostOS_CPP='linuxaout'
107 i[[3456]]86-*-linux*)
108 HostPlatform=i386-unknown-linux # hack again
109 TargetPlatform=i386-unknown-linux
110 BuildPlatform=i386-unknown-linux
111 HostPlatform_CPP='i386_unknown_linux'
113 HostVendor_CPP='unknown'
116 i[[3456]]86-*-freebsd3*) # FreeBSD 3.0+ uses ELF
117 HostPlatform=i386-unknown-freebsd3 # hack again
118 TargetPlatform=i386-unknown-freebsd3
119 BuildPlatform=i386-unknown-freebsd3
120 HostPlatform_CPP='i386_unknown_freebsd3'
122 HostVendor_CPP='unknown'
123 HostOS_CPP='freebsd3'
125 i[[3456]]86-*-freebsd2*) # Older FreeBSDs are a.out
126 HostPlatform=i386-unknown-freebsd2 # hack again
127 TargetPlatform=i386-unknown-freebsd2
128 BuildPlatform=i386-unknown-freebsd2
129 HostPlatform_CPP='i386_unknown_freebsd2'
131 HostVendor_CPP='unknown'
132 HostOS_CPP='freebsd2'
134 i[[3456]]86-*-netbsd*)
135 HostPlatform=i386-unknown-netbsd # hack again
136 TargetPlatform=i386-unknown-netbsd
137 BuildPlatform=i386-unknown-netbsd
138 HostPlatform_CPP='i386_unknown_netbsd'
140 HostVendor_CPP='unknown'
143 i[[3456]]86-*-solaris2*)
144 HostPlatform=i386-unknown-solaris2 # hack again
145 TargetPlatform=i386-unknown-solaris2
146 BuildPlatform=i386-unknown-solaris2
147 HostPlatform_CPP='i386_unknown_solaris2'
149 HostVendor_CPP='unknown'
150 HostOS_CPP='solaris2'
152 i[[3456]]86-*-cygwin32*)
153 HostPlatform=i386-unknown-cygwin32 # hack again
154 TargetPlatform=i386-unknown-cygwin32
155 BuildPlatform=i386-unknown-cygwin32
156 HostPlatform_CPP='i386_unknown_cygwin32'
158 HostVendor_CPP='unknown'
159 HostOS_CPP='cygwin32'
163 HostPlatform_CPP='m68k_next_nextstep2'
165 HostVendor_CPP='next'
166 HostOS_CPP='nextstep2'
169 HostPlatform_CPP='m68k_next_nextstep3'
171 HostVendor_CPP='next'
172 HostOS_CPP='nextstep3'
174 i[[3456]]86-next-nextstep3)
175 HostPlatform=i386-next-nextstep3 # hack again
176 TargetPlatform=i386-next-nextstep3
177 BuildPlatform=i386-next-nextstep3
178 HostPlatform_CPP='i386_next_nextstep3'
180 HostVendor_CPP='next'
181 HostOS_CPP='nextstep3'
184 HostPlatform=m68k-sun-sunos4
185 TargetPlatform=m68k-sun-sunos4 #hack
186 BuildPlatform=m68k-sun-sunos4 #hack
187 HostPlatform_CPP='m68k_sun_sunos4'
193 HostPlatform_CPP='mips_dec_ultrix'
194 HostArch_CPP='mipsel' # NB a little different
199 HostPlatform=mips-sgi-irix
200 TargetPlatform=mips-sgi-irix #hack
201 BuildPlatform=mips-sgi-irix #hack
202 HostPlatform_CPP='mips_sgi_irix'
203 HostArch_CPP='mipseb' # NB a little different
208 HostPlatform=rs6000-ibm-aix
209 TargetPlatform=rs6000-ibm-aix #hack
210 BuildPlatform=rs6000-ibm-aix #hack
211 HostPlatform_CPP='rs6000_ibm_aix'
212 HostArch_CPP='rs6000'
217 HostPlatform=powerpc-ibm-aix
218 TargetPlatform=powerpc-ibm-aix #hack
219 BuildPlatform=powerpc-ibm-aix #hack
220 HostPlatform_CPP='powerpc_ibm_aix'
221 HostArch_CPP='powerpc'
226 HostPlatform=sparc-sun-sunos4
227 TargetPlatform=sparc-sun-sunos4 #hack
228 BuildPlatform=sparc-sun-sunos4 #hack
229 HostPlatform_CPP='sparc_sun_sunos4'
235 HostPlatform=sparc-sun-solaris2
236 TargetPlatform=sparc-sun-solaris2 #hack
237 BuildPlatform=sparc-sun-solaris2 #hack
238 HostPlatform_CPP='sparc_sun_solaris2'
241 HostOS_CPP='solaris2'
244 echo "Unrecognised platform: $HostPlatform"
248 echo "Canonicalised to: $HostPlatform"
249 test x"$HostPlatform" != x"$TargetPlatform" && echo "Target platform set to $TargetPlatform"
250 test x"$BuildPlatform" != x"$HostPlatform" && echo "Build platform set to $BuildPlatform"
252 BuildPlatform_CPP=$HostPlatform_CPP
253 TargetPlatform_CPP=$HostPlatform_CPP
254 BuildArch_CPP=$HostArch_CPP
255 TargetArch_CPP=$HostArch_CPP
256 BuildOS_CPP=$HostOS_CPP
258 TargetOS_CPP=$HostOS_CPP
259 BuildVendor_CPP=$HostVendor_CPP
260 TargetVendor_CPP=$HostVendor_CPP
262 dnl Cannot afford all these SUBSTs (because of braindead seds w/ 99 cmd limits)
263 dnl AC_SUBST(BuildPlatform)
265 AC_SUBST(HostPlatform)
266 AC_SUBST(TargetPlatform)
267 AC_SUBST(HostPlatform_CPP)
268 dnl AC_SUBST(BuildPlatform_CPP)
269 dnl AC_SUBST(TargetPlatform_CPP)
271 AC_SUBST(HostArch_CPP)
272 dnl AC_SUBST(BuildArch_CPP)
273 dnl AC_SUBST(TargetArch_CPP)
276 AC_SUBST(HostOS_Full)
277 dnl AC_SUBST(BuildOS_CPP)
278 dnl AC_SUBST(TargetOS_CPP)
280 AC_SUBST(HostVendor_CPP)
281 dnl AC_SUBST(BuildVendor_CPP)
282 dnl AC_SUBST(TargetVendor_CPP)
286 dnl --------------------------------------------------------------
287 dnl * Project specific configuration options
288 dnl --------------------------------------------------------------
289 dnl What follows is a bunch of options that can either be configured
290 dnl through command line options to the configure script or by
291 dnl supplying defns in the build tree's mk/build.mk. Having the option to
292 dnl use either is considered a Feature.
294 dnl ** What command to use to compile compiler sources ?
295 dnl --------------------------------------------------------------
297 [ --with-ghc-hc=<haskell compiler>
298 Use a command different from 'ghc-2.10' to compile up the GHC compiler sources.
299 (no claims currently made that this will work with a compiler other than a
300 recent version of GHC, but you could always try...)
302 [WithGhcHc="$withval"],
307 dnl ** Which gcc to use?
308 dnl --------------------------------------------------------------
310 [ --with-gcc=<gcc command>
311 Use a different command instead of 'gcc' for the GNU C compiler.
313 [WhatGccIsCalled="$withval"],
314 [WhatGccIsCalled="gcc"]
316 AC_SUBST(WhatGccIsCalled)
318 dnl ** Booting from .hc files?
319 dnl --------------------------------------------------------------
320 AC_ARG_ENABLE(hc-boot,
322 Boot the Glasgow Haskell Compiler from intermediate .hc files.
323 (This option is mostly of interest to porters.)
328 AC_SUBST(BootingFromHc)
331 dnl --------------------------------------------------------------
332 dnl End of configure script option section
333 dnl --------------------------------------------------------------
336 dnl --------------------------------------------------------------
337 dnl * General configuration checks
338 dnl --------------------------------------------------------------
343 dnl ** look for `perl', but watch out for version 4.035
344 AC_PATH_PROG(PerlCmd,perl)
345 if test -z "$PerlCmd"; then
346 echo "You must install perl before you can continue"
347 echo "Perhaps it is already installed, but not in your PATH?"
350 FPTOOLS_CHECK_PERL_VERSION
353 dnl ** does #! path/to/perl work? (sometimes it's too long...)
357 dnl ** look for GCC and find out which version
358 dnl Figure out which C compiler to use. Gcc is preferred.
359 dnl If gcc, make sure it's at least 2.1
364 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
368 dnl ** figure out how to do context diffs
372 dnl ** look for a decent parser generator (bison preferred)
373 dnl (FPTOOLS_PROG_YACCY is AC_PROG_YACC, but with some extra testing
374 dnl on the suitability of the 'yacc' returned.)
377 dnl ** Find lex command (lex or flex) and library (-ll or -lfl)
378 dnl ( not that we care about the latter, see mk/config.mk.in )
382 dnl ** figure out how to do a BSD-ish install
385 dnl If you can run configure, you certainly have /bin/sh
386 AC_DEFINE(HAVE_BIN_SH)
388 dnl ** how to invoke `ar' and `ranlib'
389 FPTOOLS_PROG_AR_AND_RANLIB
392 dnl ** Check to see whether ln -s works
396 dnl ** Find the path to sed
397 AC_PATH_PROG(SedCmd,sed)
400 dnl ** check for time command
401 AC_PATH_PROG(TimeCmd,time)
405 dnl if GNU tar is named gtar, look for it first.
406 AC_PATH_PROGS(TarCmd,gtar tar,tar)
408 dnl ** check for gzip/compress
409 AC_PATH_PROGS(CompressCmd,gzip compress,gzip)
411 compress_nm=`basename $CompressCmd`
412 if test x"$compress_nm" = xgzip; then
413 CompressCmd="$CompressCmd -d"
418 AC_SUBST(CompressCmd)
419 AC_SUBST(CompressSuffix)
421 dnl ** check for installed happy binary + version
422 dnl (don't do it if we're booting from .hc files though.)
423 if (test "$BootingFromHc" = "NO"); then
427 dnl --------------------------------------------------
428 dnl ### program checking section ends here ###
429 dnl --------------------------------------------------
431 dnl --------------------------------------------------
432 dnl * Platform header file and syscall feature tests
433 dnl ### checking the state of the local header files and syscalls ###
435 dnl ** check for full ANSI header (.h) files
438 dnl ** check for specific header (.h) files that we are interested in
439 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 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 readline/readline.h bfd.h)
441 dnl ** check for DOS include files
442 AC_CHECK_HEADERS(dos.h conio.h io.h std.h)
444 dnl ** check for Windows include files
445 AC_CHECK_HEADERS(windows.h)
447 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
450 dnl dynamic loading include files
451 AC_CHECK_HEADERS(dlfcn.h dl.h)
453 dnl ** check for farcalloc (in bcc)
454 AC_CHECK_HEADER(alloc.h,AC_CHECK_FUNCS(farcalloc))
456 dnl ** check for valloc (in sunos, solaris, mips, amiga, next, minix, ultrix)
457 AC_CHECK_HEADER(malloc.h,AC_CHECK_FUNCS(valloc))
459 dnl ** how do we get a timezone name, and UTC offset ?
462 dnl ** what's the type of timezone?
463 FPTOOLS_TYPE_TIMEZONE
465 dnl ** do we have altzone?
468 dnl ** does struct stat contain st_blksize?
471 dnl ** what are the sizes of various types
472 dnl (these must come before GHC_CHECK_ALIGNMENT)
473 AC_CHECK_SIZEOF(unsigned int,4)
474 AC_CHECK_SIZEOF(float, 4)
475 AC_CHECK_SIZEOF(double, 8)
476 AC_CHECK_SIZEOF(long, 4)
477 AC_CHECK_SIZEOF(void *, 4)
479 dnl ** what are alignment constraints on various types
480 FPTOOLS_CHECK_ALIGNMENT(unsigned int) dnl redundant but harmless
481 FPTOOLS_CHECK_ALIGNMENT(long)
482 FPTOOLS_CHECK_ALIGNMENT(float)
483 FPTOOLS_CHECK_ALIGNMENT(double)
485 dnl ** do we have long longs?
488 dnl ** can we open files in binary mode?
491 dnl ** check for GetModuleFileName and WinExec (windows only)
492 dnl Old: AC_CHECK_FUNCS(WinExec GetModuleFileName) dnl Windows
493 dnl Doesn't work because the linker can't see the functions if
494 dnl you omit the #include <windows.h>. (I've no idea why not...)
496 FPTOOLS_TRY_LINK_NOWARN(,[
507 if test "$have_winexec" = "1"; then
508 AC_DEFINE(HAVE_WINEXEC)
511 FPTOOLS_TRY_LINK_NOWARN(,[
517 GetModuleFileName((HMODULE)0,dir,0);
521 [have_getmodulefilename=1],
522 [have_getmodulefilename=0])
523 if test "$have_getmodulefilename" = "1"; then
524 AC_DEFINE(HAVE_GETMODULEFILENAME)
527 dnl ** check return type of signal handlers
528 dnl Foo: assumes we can use prototypes.
529 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
530 dnl AC_CACHE_CHECK([type of signal handlers], ac_cv_type_signal_handler,
531 dnl [AC_TRY_COMPILE([#include <sys/types.h>
532 dnl #include <signal.h>
536 dnl void (*signal (int, void (*)(int)))(int);
539 dnl ac_cv_type_signal_handler=void_int,
540 dnl ac_cv_type_signal_handler=int_void)])
541 dnl if test "$ac_cv_type_signal_handler" = void_int; then
542 dnl AC_DEFINE(VOID_INT_SIGNALS)
545 dnl On BCC, signal handlers have type "int(void)", elsewhere its "void(int)".
547 if test "$ac_cv_type_signal" = void; then
548 AC_DEFINE(VOID_INT_SIGNALS)
551 dnl ** check for more functions
552 AC_CHECK_FUNCS(strcasecmp _stricmp stricmp strcmpi)
553 AC_CHECK_FUNCS(strcmp)
554 AC_CHECK_FUNCS(realpath _fullpath)
555 AC_CHECK_FUNCS(PBHSetVolSync macsystem)
556 AC_CHECK_FUNCS(fgetpos fsetpos fseek ftell)
557 AC_CHECK_FUNCS(vsnprintf _vsnprintf)
558 AC_CHECK_FUNCS(snprintf _snprintf )
559 AC_CHECK_FUNCS(popen _popen )
560 AC_CHECK_FUNCS(pclose _pclose )
563 dnl ** check for specific library functions that we are interested in
564 AC_CHECK_FUNCS(access ftime getclock getpagesize getrusage gettimeofday mktime mprotect readlink setitimer stat symlink sysconf timelocal times vadvise vfork)
566 dnl ** check whether this machine has gmp2 installed
567 AC_CHECK_LIB(gmp, mpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
568 AC_CHECK_LIB(gmp2, mpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp2,
569 HaveLibGmp=No; LibGmp=not-installed))
573 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
574 dnl the order of these tests matters: bfd needs liberty
575 AC_CHECK_LIB(iberty, xmalloc)
576 AC_CHECK_LIB(bfd, bfd_init)
578 dnl ################################################################
579 dnl Check for libraries
580 dnl ################################################################
582 FPTOOLS_CHECK_LIB_NOWARN(dl, dlopen)
583 FPTOOLS_CHECK_LIB_NOWARN(dld, shl_load)
584 FPTOOLS_CHECK_LIB_NOWARN(m, atan)
586 dnl --------------------------------------------------
587 dnl * Miscellaneous feature tests
588 dnl --------------------------------------------------
590 dnl ** can we get alloca?
593 dnl ** determine whether or not const works
596 dnl ** determine whether ANSI-function prototypes work?
599 dnl ** are we big endian?
601 # Allay users' general fear of warnings of any kind.
602 errprint((fptools configure script wizard sez: "don't worry, the above warning is harmless (to us.)")
605 dnl ** determine the return type of signal()
608 dnl ** check for leading underscores in symbol names
611 dnl ** how is the end of text section signalled?
612 FPTOOLS_END_TEXT_SECTION
614 dnl ** how is the end of data section signalled?
615 FPTOOLS_END_DATA_SECTION
617 dnl ** code before data?
618 FPTOOLS_CODE_BEFORE_DATA
620 AC_OUTPUT(mk/config.mk, echo timestamp > mk/stamp-h )
623 echo '************************************************'
624 echo '*** NOW DO: gmake boot followed by gmake all'
625 echo '*** (where gmake == GNU make)'
626 echo '************************************************'