[project @ 1998-09-29 17:31:21 by sof]
[ghc-hetmet.git] / configure.in
1 dnl == autoconf source for the Glasgow FP tools ==
2 dnl (run "grep '^dnl \*' configure.in | sed -e 's/dnl / /g; s/\*\*/   +/g;'"
3 dnl  (or some such) to see the outline of this file)
4 dnl
5 #
6 # (c) The AQUA Project, Glasgow University, 1994-1998
7 #
8 # Configure script template for the Glasgow functional programming tools
9 #
10 # Process with 'autoconf' to get a working configure script.
11 #
12 # For the generated configure script, do "./configure --help" to
13 # see what flags are available. (Better yet, read the documentation!)
14 #
15
16 # First off, a distrib sanity check..
17 AC_INIT(mk/config.mk.in)
18
19 # -------------------------------------------------------------------------
20 # Prepare to generate the following header files
21 #
22 #
23 AC_CONFIG_HEADER(mk/config.h)
24
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.."
28     exit 1
29 fi
30
31 #
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.)
34 #
35 hardtop=`pwd`
36 hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|' | sed 's|^/grasp_tmp|/local/grasp_tmp|' | sed 's|^//\(.\)/|\1:/|' `
37
38 echo ''
39 echo "*** The top of your build tree is: $hardtop"
40 AC_SUBST(hardtop)
41
42 dnl--------------------------------------------------------------------
43 dnl * Choose host(/target/build) platform
44 dnl--------------------------------------------------------------------
45
46 dnl Guess host/target/build platform(s) if necessary.
47 AC_CANONICAL_SYSTEM
48
49 # "$host" defaults to "$target"
50 if test "x$host" = xNONE ; then
51     host=$target
52 fi
53
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
58
59 if test x"$TargetPlatform" != x"$HostPlatform" ; then
60     echo "GHC configuration does not support differing host/target (i.e., cross-compiling)"
61     exit 1
62 fi
63
64 exeext=''
65 #
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)
69 # separately.
70 case $HostPlatform in
71 alpha-dec-osf[[12]]*)
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'
76         HostArch_CPP='alpha'
77         HostVendor_CPP='dec'
78         HostOS_CPP='osf1'
79         ;;
80 alpha-dec-osf[[34]]*)
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'
85         HostArch_CPP='alpha'
86         HostVendor_CPP='dec'
87         HostOS_CPP='osf3'
88         ;;
89 hppa1.1-hp-hpux*)
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'
95         HostVendor_CPP='hp'
96         HostOS_CPP='hpux'
97         ;;
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'
103         HostArch_CPP='i386'
104         HostVendor_CPP='unknown'
105         HostOS_CPP='linuxaout'
106         ;;
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'
112         HostArch_CPP='i386'
113         HostVendor_CPP='unknown'
114         HostOS_CPP='linux'
115         ;;
116 i[[3456]]86-*-freebsd*)
117         HostPlatform=i386-unknown-freebsd # hack again
118         TargetPlatform=i386-unknown-freebsd
119         BuildPlatform=i386-unknown-freebsd
120         HostPlatform_CPP='i386_unknown_freebsd'
121         HostArch_CPP='i386'
122         HostVendor_CPP='unknown'
123         HostOS_CPP='freebsd'
124         ;;
125 i[[3456]]86-*-netbsd*)
126         HostPlatform=i386-unknown-netbsd # hack again
127         TargetPlatform=i386-unknown-netbsd
128         BuildPlatform=i386-unknown-netbsd
129         HostPlatform_CPP='i386_unknown_netbsd'
130         HostArch_CPP='i386'
131         HostVendor_CPP='unknown'
132         HostOS_CPP='netbsd'
133         ;;
134 i[[3456]]86-*-solaris2*)
135         HostPlatform=i386-unknown-solaris2 # hack again
136         TargetPlatform=i386-unknown-solaris2
137         BuildPlatform=i386-unknown-solaris2
138         HostPlatform_CPP='i386_unknown_solaris2'
139         HostArch_CPP='i386'
140         HostVendor_CPP='unknown'
141         HostOS_CPP='solaris2'
142         ;;
143 i[[3456]]86-*-cygwin32*)
144         HostPlatform=i386-unknown-cygwin32 # hack again
145         TargetPlatform=i386-unknown-cygwin32
146         BuildPlatform=i386-unknown-cygwin32
147         HostPlatform_CPP='i386_unknown_cygwin32'
148         HostArch_CPP='i386'
149         HostVendor_CPP='unknown'
150         HostOS_CPP='cygwin32'
151         exeext='.exe'
152         ;;
153 m68k-next-nextstep2)
154         HostPlatform_CPP='m68k_next_nextstep2'
155         HostArch_CPP='m68k'
156         HostVendor_CPP='next'
157         HostOS_CPP='nextstep2'
158         ;;
159 m68k-next-nextstep3)
160         HostPlatform_CPP='m68k_next_nextstep3'
161         HostArch_CPP='m68k'
162         HostVendor_CPP='next'
163         HostOS_CPP='nextstep3'
164         ;;
165 i[[3456]]86-next-nextstep3)
166         HostPlatform=i386-next-nextstep3 # hack again
167         TargetPlatform=i386-next-nextstep3
168         BuildPlatform=i386-next-nextstep3
169         HostPlatform_CPP='i386_next_nextstep3'
170         HostArch_CPP='i386'
171         HostVendor_CPP='next'
172         HostOS_CPP='nextstep3'
173         ;;
174 m68k-sun-sunos4*)
175         HostPlatform=m68k-sun-sunos4
176         TargetPlatform=m68k-sun-sunos4 #hack
177         BuildPlatform=m68k-sun-sunos4 #hack
178         HostPlatform_CPP='m68k_sun_sunos4'
179         HostArch_CPP='m68k'
180         HostVendor_CPP='sun'
181         HostOS_CPP='sunos4'
182         ;;
183 mips-dec-ultrix*)
184         HostPlatform_CPP='mips_dec_ultrix'
185         HostArch_CPP='mipsel'   # NB a little different
186         HostVendor_CPP='dec'
187         HostOS_CPP='ultrix'
188         ;;
189 mips-sgi-irix*)
190         HostPlatform=mips-sgi-irix
191         TargetPlatform=mips-sgi-irix #hack
192         BuildPlatform=mips-sgi-irix #hack
193         HostPlatform_CPP='mips_sgi_irix'
194         HostArch_CPP='mipseb'   # NB a little different
195         HostVendor_CPP='sgi'
196         HostOS_CPP='irix'
197         ;;
198 rs6000-ibm-aix*)
199         HostPlatform=rs6000-ibm-aix
200         TargetPlatform=rs6000-ibm-aix #hack
201         BuildPlatform=rs6000-ibm-aix #hack
202         HostPlatform_CPP='rs6000_ibm_aix'
203         HostArch_CPP='rs6000'
204         HostVendor_CPP='ibm'
205         HostOS_CPP='aix'
206         ;;
207 powerpc-ibm-aix*)
208         HostPlatform=powerpc-ibm-aix
209         TargetPlatform=powerpc-ibm-aix #hack
210         BuildPlatform=powerpc-ibm-aix #hack
211         HostPlatform_CPP='powerpc_ibm_aix'
212         HostArch_CPP='powerpc'
213         HostVendor_CPP='ibm'
214         HostOS_CPP='aix'
215         ;;
216 sparc-sun-sunos4*)
217         HostPlatform=sparc-sun-sunos4
218         TargetPlatform=sparc-sun-sunos4 #hack
219         BuildPlatform=sparc-sun-sunos4 #hack
220         HostPlatform_CPP='sparc_sun_sunos4'
221         HostArch_CPP='sparc'
222         HostVendor_CPP='sun'
223         HostOS_CPP='sunos4'
224         ;;
225 sparc-sun-solaris2*)
226         HostPlatform=sparc-sun-solaris2
227         TargetPlatform=sparc-sun-solaris2 #hack
228         BuildPlatform=sparc-sun-solaris2 #hack
229         HostPlatform_CPP='sparc_sun_solaris2'
230         HostArch_CPP='sparc'
231         HostVendor_CPP='sun'
232         HostOS_CPP='solaris2'
233         ;;
234 *)
235         echo "Unrecognised platform: $HostPlatform"
236         exit 1
237         ;;
238 esac
239 echo "Canonicalised to: $HostPlatform"
240 test  x"$HostPlatform" != x"$TargetPlatform" && echo "Target platform set to $TargetPlatform"
241 test  x"$BuildPlatform" != x"$HostPlatform"  && echo "Build platform set to $BuildPlatform"
242
243 BuildPlatform_CPP=$HostPlatform_CPP
244 TargetPlatform_CPP=$HostPlatform_CPP
245 BuildArch_CPP=$HostArch_CPP
246 TargetArch_CPP=$HostArch_CPP
247 BuildOS_CPP=$HostOS_CPP
248 HostOS_Full=$host_os
249 TargetOS_CPP=$HostOS_CPP
250 BuildVendor_CPP=$HostVendor_CPP
251 TargetVendor_CPP=$HostVendor_CPP
252
253 dnl Cannot afford all these SUBSTs (because of braindead seds w/ 99 cmd limits)
254 dnl AC_SUBST(BuildPlatform)
255
256 AC_SUBST(HostPlatform)
257 AC_SUBST(TargetPlatform)
258 AC_SUBST(HostPlatform_CPP)
259 dnl AC_SUBST(BuildPlatform_CPP)
260 dnl AC_SUBST(TargetPlatform_CPP)
261
262 AC_SUBST(HostArch_CPP)
263 dnl AC_SUBST(BuildArch_CPP)
264 dnl AC_SUBST(TargetArch_CPP)
265
266 AC_SUBST(HostOS_CPP)
267 AC_SUBST(HostOS_Full)
268 dnl AC_SUBST(BuildOS_CPP)
269 dnl AC_SUBST(TargetOS_CPP)
270
271 AC_SUBST(HostVendor_CPP)
272 dnl AC_SUBST(BuildVendor_CPP)
273 dnl AC_SUBST(TargetVendor_CPP)
274
275 AC_SUBST(exeext)
276
277 dnl --------------------------------------------------------------
278 dnl * Project specific configuration options
279 dnl --------------------------------------------------------------
280 dnl What follows is a bunch of options that can either be configured
281 dnl through command line options to the configure script or by
282 dnl supplying defns in the build tree's mk/build.mk. Having the option to
283 dnl use either is considered a Feature.
284
285 dnl ** What command to use to compile compiler sources ?
286 dnl --------------------------------------------------------------
287 AC_ARG_WITH(ghc-hc,
288 [  --with-ghc-hc=<haskell compiler>
289         Use a command different from 'ghc-2.10' to compile up the GHC compiler sources.
290          (no claims currently made that this will work with a compiler other than a
291           recent version of GHC, but you could always try...)
292 ],
293 [WithGhcHc="$withval"],
294 [WithGhcHc="ghc-2.10"]
295 )
296 AC_SUBST(WithGhcHc)
297
298 dnl ** Which gcc to use?
299 dnl --------------------------------------------------------------
300 AC_ARG_WITH(gcc,
301 [  --with-gcc=<gcc command>
302         Use a different command instead of 'gcc' for the GNU C compiler.
303 ],
304 [WhatGccIsCalled="$withval"],
305 [WhatGccIsCalled="gcc"]
306 )
307 AC_SUBST(WhatGccIsCalled)
308
309 dnl ** Booting from .hc files?
310 dnl --------------------------------------------------------------
311 AC_ARG_ENABLE(hc-boot,
312 [  --enable-hc-boot
313         Boot the Glasgow Haskell Compiler from intermediate .hc files.
314         (This option is mostly of interest to porters.)
315 ],
316 [BootingFromHc=YES],
317 [BootingFromHc=NO]
318 )
319 AC_SUBST(BootingFromHc)
320
321
322 dnl --------------------------------------------------------------
323 dnl End of configure script option section
324 dnl --------------------------------------------------------------
325
326
327 dnl --------------------------------------------------------------
328 dnl * General configuration checks
329 dnl --------------------------------------------------------------
330
331 dnl ** does #! work?
332 AC_SYS_INTERPRETER()
333
334 dnl ** look for `perl', but watch out for version 4.035
335 AC_PATH_PROG(PerlCmd,perl)
336 if test -z "$PerlCmd"; then
337    echo "You must install perl before you can continue"
338    echo "Perhaps it is already installed, but not in your PATH?"
339    exit 1
340 else
341 FPTOOLS_CHECK_PERL_VERSION
342 fi
343
344 dnl ** does #! path/to/perl work? (sometimes it's too long...)
345 FPTOOLS_SHEBANG_PERL
346
347
348 dnl ** look for GCC and find out which version
349 dnl     Figure out which C compiler to use.  Gcc is preferred.
350 dnl     If gcc, make sure it's at least 2.1
351 dnl
352 AC_PROG_CC
353 FPTOOLS_HAVE_GCC
354
355 dnl ** figure out how to invoke cpp directly (gcc -E is no good)
356 AC_PROG_CPP
357 FPTOOLS_PROG_GNUCPP
358
359 dnl ** figure out how to do context diffs
360 FPTOOLS_PROG_DIFF
361
362
363 dnl ** look for a decent parser generator (bison preferred)
364 dnl (FPTOOLS_PROG_YACCY is AC_PROG_YACC, but with some extra testing 
365 dnl  on the suitability of the 'yacc' returned.)
366 FPTOOLS_PROG_YACCY
367
368 dnl ** Find lex command (lex or flex) and library (-ll or -lfl)
369 dnl     ( not that we care about the latter, see mk/config.mk.in )
370 AC_PROG_LEX
371
372
373 dnl ** figure out how to do a BSD-ish install
374 AC_PROG_INSTALL
375
376 dnl ** how to invoke `ar' and `ranlib'
377 FPTOOLS_PROG_AR_AND_RANLIB
378
379
380 dnl ** Check to see whether ln -s works
381 AC_PROG_LN_S
382
383
384 dnl ** Find the path to sed
385 AC_PATH_PROG(SedCmd,sed)
386
387
388 dnl ** check for time command
389 AC_PATH_PROG(TimeCmd,time)
390
391
392 dnl ** check for tar
393 dnl   if GNU tar is named gtar, look for it first.
394 AC_PATH_PROGS(TarCmd,gtar tar,tar)
395
396 dnl ** check for gzip/compress
397 AC_PATH_PROGS(CompressCmd,gzip compress,gzip)
398
399 compress_nm=`basename $CompressCmd`
400 if test x"$compress_nm" = xgzip; then
401   CompressCmd="$CompressCmd -d"
402   CompressSuffix="gz"
403 else
404   CompressSuffix="Z"
405 fi
406 AC_SUBST(CompressCmd)
407 AC_SUBST(CompressSuffix)
408
409 dnl ** check for installed happy binary + version
410 dnl    (don't do it if we're booting from .hc files though.)
411 if (test "$BootingFromHc" = "NO"); then
412 FPTOOLS_HAPPY
413 fi;
414
415 dnl --------------------------------------------------
416 dnl ### program checking section ends here ###
417 dnl --------------------------------------------------
418
419 dnl --------------------------------------------------
420 dnl * Platform header file and syscall feature tests
421 dnl ### checking the state of the local header files and syscalls ###
422
423 dnl ** check for full ANSI header (.h) files
424 AC_HEADER_STDC
425
426 dnl ** check for specific header (.h) files that we are interested in
427 AC_CHECK_HEADERS(dirent.h fcntl.h grp.h malloc.h memory.h nlist.h pwd.h siginfo.h signal.h stdlib.h string.h sys/fault.h sys/file.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 termios.h time.h types.h unistd.h utime.h vfork.h readline/readline.h bfd.h)
428
429 dnl ** check if it is safe to include both <time.h> and <sys/time.h>
430 AC_HEADER_TIME
431
432 dnl ** how do we get a timezone name, and UTC offset ?
433 AC_STRUCT_TIMEZONE
434
435 dnl ** what's the type of timezone?
436 FPTOOLS_TYPE_TIMEZONE
437
438 dnl ** do we have altzone?
439 FPTOOLS_ALTZONE
440
441 dnl ** does struct stat contain st_blksize?
442 AC_STRUCT_ST_BLKSIZE
443
444 dnl ** what are the sizes of various types
445 dnl    (these must come before GHC_CHECK_ALIGNMENT)
446 AC_CHECK_SIZEOF(unsigned int,4)
447 AC_CHECK_SIZEOF(float,       4)
448 AC_CHECK_SIZEOF(double,      8)
449 AC_CHECK_SIZEOF(long,        4)
450 AC_CHECK_SIZEOF(void *,      4)
451
452 dnl ** what are alignment constraints on various types
453 FPTOOLS_CHECK_ALIGNMENT(unsigned int) dnl redundant but harmless
454 FPTOOLS_CHECK_ALIGNMENT(long)
455 FPTOOLS_CHECK_ALIGNMENT(float)
456 FPTOOLS_CHECK_ALIGNMENT(double)
457
458 dnl ** do we have long longs?
459 FPTOOLS_C_LONG_LONG
460
461 dnl ** can we open files in binary mode?
462 FPTOOLS_O_BINARY
463
464 dnl ** check for specific library functions that we are interested in
465 AC_CHECK_FUNCS(access ftime getclock getpagesize getrusage gettimeofday mktime mprotect setitimer stat sysconf timelocal times vadvise vfork)
466
467 dnl ** check whether this machine has gmp2 installed
468 AC_CHECK_LIB(gmp,  mpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
469   AC_CHECK_LIB(gmp2, mpz_fdiv_qr,  HaveLibGmp=YES; LibGmp=gmp2,
470     HaveLibGmp=No; LibGmp=not-installed))
471 AC_SUBST(HaveLibGmp)
472 AC_SUBST(LibGmp)
473
474 dnl ** check whether this machine has BFD and liberty installed (used for debugging)
475 dnl    the order of these tests matters: bfd needs liberty
476 AC_CHECK_LIB(iberty, xmalloc)
477 AC_CHECK_LIB(bfd,    bfd_init)
478
479
480 dnl --------------------------------------------------
481 dnl * Miscellaneous feature tests
482 dnl --------------------------------------------------
483
484 dnl ** can we get alloca?
485 AC_FUNC_ALLOCA
486
487 dnl ** determine whether or not const works
488 AC_C_CONST
489
490 dnl ** are we big endian?
491 AC_C_BIGENDIAN
492
493 dnl ** determine the return type of signal()
494 AC_TYPE_SIGNAL
495
496 dnl ** check for leading underscores in symbol names
497 FPTOOLS_UNDERSCORE
498
499 dnl ** how is the end of text section signalled?
500 FPTOOLS_END_TEXT_SECTION
501
502 dnl ** how is the end of data section signalled?
503 FPTOOLS_END_DATA_SECTION
504
505 dnl ** code before data?
506 FPTOOLS_CODE_BEFORE_DATA
507
508 AC_OUTPUT(mk/config.mk, echo timestamp > mk/stamp-h )
509
510 echo ''
511 echo '************************************************'
512 echo '*** NOW DO: gmake boot followed by gmake all'
513 echo '***         (where gmake == GNU make)'
514 echo '************************************************'
515 exit 0