Sys.Signals module for a Variant type of signals (and a set_signal function that...
[ocaml.git] / configure
blob92288be07311675cdc073b564a4d1274a75bd763
1 #! /bin/sh
3 #########################################################################
4 # #
5 # Objective Caml #
6 # #
7 # Xavier Leroy, projet Cristal, INRIA Rocquencourt #
8 # #
9 # Copyright 1999 Institut National de Recherche en Informatique et #
10 # en Automatique. All rights reserved. This file is distributed #
11 # under the terms of the GNU Library General Public License, with #
12 # the special exception on linking described in file LICENSE. #
13 # #
14 #########################################################################
16 # $Id$
18 configure_options="$*"
19 prefix=/usr/local
20 bindir=''
21 libdir=''
22 mandir=''
23 manext=1
24 host_type=unknown
25 ccoption=''
26 cclibs=''
27 curseslibs=''
28 mathlib='-lm'
29 dllib=''
30 x11_include_dir=''
31 x11_lib_dir=''
32 tk_wanted=yes
33 pthread_wanted=yes
34 tk_defs=''
35 tk_libs=''
36 tk_x11=yes
37 dl_defs=''
38 verbose=no
39 withcurses=yes
40 withsharedlibs=yes
41 gcc_warnings="-Wall"
42 partialld="ld -r"
44 # Try to turn internationalization off, can cause config.guess to malfunction!
45 unset LANG
46 unset LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
48 # Turn off some MacOS X debugging stuff, same reason
49 unset RC_TRACE_ARCHIVES RC_TRACE_DYLIBS RC_TRACE_PREBINDING_DISABLED
51 # Parse command-line arguments
53 while : ; do
54 case "$1" in
55 "") break;;
56 -prefix|--prefix)
57 prefix=$2; shift;;
58 -bindir|--bindir)
59 bindir=$2; shift;;
60 -libdir|--libdir)
61 libdir=$2; shift;;
62 -mandir|--mandir)
63 case "$2" in
64 */man[1-9ln])
65 mandir=`echo $2 | sed -e 's|^\(.*\)/man.$|\1|'`
66 manext=`echo $2 | sed -e 's/^.*\(.\)$/\1/'`;;
68 mandir=$2
69 manext=1;;
70 esac
71 shift;;
72 -host*|--host*)
73 host_type=$2; shift;;
74 -cc*)
75 ccoption="$2"; shift;;
76 -lib*)
77 cclibs="$2 $cclibs"; shift;;
78 -no-curses)
79 withcurses=no;;
80 -no-shared-libs)
81 withsharedlibs=no;;
82 -x11include*|--x11include*)
83 x11_include_dir=$2; shift;;
84 -x11lib*|--x11lib*)
85 x11_lib_dir=$2; shift;;
86 -with-pthread*|--with-pthread*)
87 ;; # Ignored for backward compatibility
88 -no-pthread*|--no-pthread*)
89 pthread_wanted=no;;
90 -no-tk|--no-tk)
91 tk_wanted=no;;
92 -tkdefs*|--tkdefs*)
93 tk_defs=$2; shift;;
94 -tklibs*|--tklibs*)
95 tk_libs=$2; shift;;
96 -tk-no-x11|--tk-no-x11)
97 tk_x11=no;;
98 -dldefs*|--dldefs*)
99 dl_defs="$2"; shift;;
100 -dllibs*|--dllibs*)
101 dllib="$2"; shift;;
102 -verbose|--verbose)
103 verbose=yes;;
104 *) echo "Unknown option \"$1\"." 1>&2; exit 2;;
105 esac
106 shift
107 done
109 # Sanity checks
111 case "$prefix" in
112 /*) ;;
113 *) echo "The -prefix directory must be absolute." 1>&2; exit 2;;
114 esac
115 case "$bindir" in
116 /*) ;;
117 "") ;;
118 *) echo "The -bindir directory must be absolute." 1>&2; exit 2;;
119 esac
120 case "$libdir" in
121 /*) ;;
122 "") ;;
123 *) echo "The -libdir directory must be absolute." 1>&2; exit 2;;
124 esac
125 case "$mandir" in
126 /*) ;;
127 "") ;;
128 *) echo "The -mandir directory must be absolute." 1>&2; exit 2;;
129 esac
131 # Generate the files
133 cd config/auto-aux
134 rm -f s.h m.h Makefile
135 touch s.h m.h Makefile
137 # Write options to Makefile
139 echo "# generated by ./configure $configure_options" >> Makefile
141 # Where to install
143 echo "PREFIX=$prefix" >> Makefile
144 case "$bindir" in
145 "") echo 'BINDIR=$(PREFIX)/bin' >> Makefile
146 bindir="$prefix/bin";;
147 *) echo "BINDIR=$bindir" >> Makefile;;
148 esac
149 case "$libdir" in
150 "") echo 'LIBDIR=$(PREFIX)/lib/ocaml' >> Makefile
151 libdir="$prefix/lib/ocaml";;
152 *) echo "LIBDIR=$libdir" >> Makefile;;
153 esac
154 echo 'STUBLIBDIR=$(LIBDIR)/stublibs' >> Makefile
155 case "$mandir" in
156 "") echo 'MANDIR=$(PREFIX)/man' >> Makefile
157 mandir="$prefix/man";;
158 *) echo "MANDIR=$mandir" >> Makefile;;
159 esac
160 echo "MANEXT=$manext" >> Makefile
162 # Determine the system type
164 if test "$host_type" = "unknown"; then
165 if host_type=`../gnu/config.guess`; then :; else
166 echo "Cannot guess host type"
167 echo "You must specify one with the -host option"
168 exit 2
171 if host=`../gnu/config.sub $host_type`; then :; else
172 echo "Please specify the correct host type with the -host option"
173 exit 2
175 echo "Configuring for a $host ..."
177 # Do we have gcc?
179 if test -z "$ccoption"; then
180 if sh ./searchpath gcc; then
181 echo "gcc found"
182 cc=gcc
183 else
184 cc=cc
186 else
187 cc="$ccoption"
190 # Check for buggy versions of GCC
192 buggycc="no"
194 case "$host,$cc" in
195 i[3456]86-*-*,gcc*)
196 case `$cc --version` in
197 2.7.2.1) cat <<'EOF'
199 WARNING: you are using gcc version 2.7.2.1 on an Intel x86 processor.
200 This version of gcc is known to generate incorrect code for the
201 Objective Caml runtime system on some Intel x86 machines. (The symptom
202 is a crash of boot/ocamlc when compiling stdlib/pervasives.mli.)
203 In particular, the version of gcc 2.7.2.1 that comes with
204 Linux RedHat 4.x / Intel is affected by this problem.
205 Other Linux distributions might also be affected.
206 If you are using one of these configurations, you are strongly advised
207 to use another version of gcc, such as 2.95, which are
208 known to work well with Objective Caml.
210 Press <enter> to proceed or <interrupt> to stop.
212 read reply;;
213 2.96*) cat <<'EOF'
215 WARNING: you are using gcc version 2.96 on an Intel x86 processor.
216 Certain patched versions of gcc 2.96 are known to generate incorrect
217 code for the Objective Caml runtime system. (The symptom is a segmentation
218 violation on boot/ocamlc.) Those incorrectly patched versions can be found
219 in RedHat 7.2 and Mandrake 8.0 and 8.1; other Linux distributions
220 might also be affected. (See bug #57760 on bugzilla.redhat.com)
222 Auto-configuration will now select gcc compiler flags that work around
223 the problem. Still, if you observe segmentation faults while running
224 ocamlc or ocamlopt, you are advised to try another version of gcc,
225 such as 2.95.3 or 3.2.
228 buggycc="gcc.2.96";;
230 esac;;
231 esac
233 # Configure the bytecode compiler
235 bytecc="$cc"
236 bytecccompopts=""
237 bytecclinkopts=""
238 ostype="Unix"
239 exe=""
241 case "$bytecc,$host" in
242 cc,*-*-nextstep*)
243 # GNU C extensions disabled, but __GNUC__ still defined!
244 bytecccompopts="-fno-defer-pop $gcc_warnings -U__GNUC__ -posix"
245 bytecclinkopts="-posix";;
246 *,*-*-rhapsody*)
247 # Almost the same as NeXTStep
248 bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
249 mathlib="";;
250 *,*-*-darwin*)
251 bytecccompopts="-fno-defer-pop -no-cpp-precomp $gcc_warnings"
252 mathlib=""
253 # Tell gcc that we can use 32-bit code addresses for threaded code
254 # even if we compile in 64-bit mode
255 echo "#define ARCH_CODE32" >> m.h;;
256 *,*-*-beos*)
257 bytecccompopts="-fno-defer-pop $gcc_warnings"
258 # No -lm library
259 mathlib="";;
260 gcc,alpha*-*-osf*)
261 bytecccompopts="-fno-defer-pop $gcc_warnings"
262 if cc="$bytecc" sh ./hasgot -mieee; then
263 bytecccompopts="-mieee $bytecccompopts";
265 # Put code and static data in lower 4GB
266 bytecclinkopts="-Wl,-T,12000000 -Wl,-D,14000000"
267 # Tell gcc that we can use 32-bit code addresses for threaded code
268 echo "#define ARCH_CODE32" >> m.h;;
269 cc,alpha*-*-osf*)
270 bytecccompopts="-std1 -ieee";;
271 gcc,alpha*-*-linux*)
272 if cc="$bytecc" sh ./hasgot -mieee; then
273 bytecccompopts="-mieee $bytecccompopts";
274 fi;;
275 cc,mips-*-irix6*)
276 # Add -n32 flag to ensure compatibility with native-code compiler
277 bytecccompopts="-n32"
278 # Turn off warning "unused library"
279 bytecclinkopts="-n32 -Wl,-woff,84";;
280 cc*,mips-*-irix6*)
281 # (For those who want to force "cc -64")
282 # Turn off warning "unused library"
283 bytecclinkopts="-Wl,-woff,84";;
284 *,alpha*-*-unicos*)
285 # For the Cray T3E
286 bytecccompopts="-DUMK";;
287 gcc*,powerpc-*-aix*)
288 # Avoid name-space pollution by requiring Unix98-conformant includes
289 bytecccompopts="-fno-defer-pop $gcc_warnings -D_XOPEN_SOURCE=500";;
290 *,powerpc-*-aix*)
291 bytecccompopts="-D_XOPEN_SOURCE=500";;
292 gcc*,*-*-cygwin*)
293 bytecccompopts="-fno-defer-pop $gcc_warnings -U_WIN32"
294 exe=".exe"
295 ostype="Cygwin";;
296 gcc*,x86_64-*-linux*)
297 bytecccompopts="-fno-defer-pop $gcc_warnings"
298 # Tell gcc that we can use 32-bit code addresses for threaded code
299 # unless we are compiled for a shared library (-fPIC option)
300 echo "#ifndef __PIC__" >> m.h
301 echo "# define ARCH_CODE32" >> m.h
302 echo "#endif" >> m.h;;
303 gcc*)
304 bytecccompopts="-fno-defer-pop $gcc_warnings";;
305 esac
307 # Configure compiler to use in further tests
309 cc="$bytecc -O $bytecclinkopts"
310 export cc cclibs verbose
312 # Check C compiler
314 sh ./runtest ansi.c
315 case $? in
316 0) echo "The C compiler is ANSI-compliant.";;
317 1) echo "The C compiler $cc is not ANSI-compliant."
318 echo "You need an ANSI C compiler to build Objective Caml."
319 exit 2;;
320 *) echo "Unable to compile the test program."
321 echo "Make sure the C compiler $cc is properly installed."
322 exit 2;;
323 esac
325 # Check the sizes of data types
327 echo "Checking the sizes of integers and pointers..."
328 set `sh ./runtest sizes.c`
329 case "$2,$3" in
330 4,4) echo "OK, this is a regular 32 bit architecture."
331 echo "#undef ARCH_SIXTYFOUR" >> m.h
332 arch64=false;;
333 *,8) echo "Wow! A 64 bit architecture!"
334 echo "#define ARCH_SIXTYFOUR" >> m.h
335 arch64=true;;
336 *,*) echo "This architecture seems to be neither 32 bits nor 64 bits."
337 echo "Objective Caml won't run on this architecture."
338 exit 2;;
339 *) echo "Unable to compile the test program."
340 echo "Make sure the C compiler $cc is properly installed."
341 exit 2;;
342 esac
343 if test $1 != 4 && test $2 != 4 && test $4 != 4; then
344 echo "Sorry, we can't find a 32-bit integer type"
345 echo "(sizeof(short) = $4, sizeof(int) = $1, sizeof(long) = $2)"
346 echo "Objective Caml won't run on this architecture."
347 exit 2
350 echo "#define SIZEOF_INT $1" >> m.h
351 echo "#define SIZEOF_LONG $2" >> m.h
352 echo "#define SIZEOF_PTR $3" >> m.h
353 echo "#define SIZEOF_SHORT $4" >> m.h
355 if test $2 = 8; then
356 echo "#define ARCH_INT64_TYPE long" >> m.h
357 echo "#define ARCH_UINT64_TYPE unsigned long" >> m.h
358 echo '#define ARCH_INT64_PRINTF_FORMAT "l"' >> m.h
359 int64_native=true
360 else
361 sh ./runtest longlong.c
362 case $? in
363 0) echo "64-bit \"long long\" integer type found (printf with \"%ll\")."
364 echo "#define ARCH_INT64_TYPE long long" >> m.h
365 echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
366 echo '#define ARCH_INT64_PRINTF_FORMAT "ll"' >> m.h
367 int64_native=true;;
368 1) echo "64-bit \"long long\" integer type found (printf with \"%q\")."
369 echo "#define ARCH_INT64_TYPE long long" >> m.h
370 echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
371 echo '#define ARCH_INT64_PRINTF_FORMAT "q"' >> m.h
372 int64_native=true;;
373 2) echo "64-bit \"long long\" integer type found (but no printf)."
374 echo "#define ARCH_INT64_TYPE long long" >> m.h
375 echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
376 echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
377 int64_native=true;;
378 *) echo "No suitable 64-bit integer type found, will use software emulation."
379 echo "#undef ARCH_INT64_TYPE" >> m.h
380 echo "#undef ARCH_UINT64_TYPE" >> m.h
381 echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
382 int64_native=false;;
383 esac
386 if test $3 = 8 && test $int64_native = false; then
387 echo "This architecture has 64-bit pointers but no 64-bit integer type."
388 echo "Objective Caml won't run on this architecture."
389 exit 2
392 # Determine endianness
394 sh ./runtest endian.c
395 case $? in
396 0) echo "This is a big-endian architecture."
397 echo "#define ARCH_BIG_ENDIAN" >> m.h;;
398 1) echo "This is a little-endian architecture."
399 echo "#undef ARCH_BIG_ENDIAN" >> m.h;;
400 2) echo "This architecture seems to be neither big endian nor little endian."
401 echo "Objective Caml won't run on this architecture."
402 exit 2;;
403 *) echo "Something went wrong during endianness determination."
404 echo "You'll have to figure out endianness yourself"
405 echo "(option ARCH_BIG_ENDIAN in m.h).";;
406 esac
408 # Determine alignment constraints
410 case "$host" in
411 sparc*-*-*|hppa*-*-*)
412 # On Sparc V9 with certain versions of gcc, determination of double
413 # alignment is not reliable (PR#1521), hence force it.
414 # Same goes for hppa.
415 # But there's a knack (PR#2572):
416 # if we're in 64-bit mode (sizeof(long) == 8),
417 # we must not doubleword-align floats...
418 if test $2 = 8; then
419 echo "Doubles can be word-aligned."
420 echo "#undef ARCH_ALIGN_DOUBLE" >> m.h
421 else
422 echo "Doubles must be doubleword-aligned."
423 echo "#define ARCH_ALIGN_DOUBLE" >> m.h
424 fi;;
426 sh ./runtest dblalign.c
427 case $? in
428 0) echo "Doubles can be word-aligned."
429 echo "#undef ARCH_ALIGN_DOUBLE" >> m.h;;
430 1) echo "Doubles must be doubleword-aligned."
431 echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
432 *) echo "Something went wrong during alignment determination for doubles."
433 echo "I'm going to assume this architecture has alignment constraints over doubles."
434 echo "That's a safe bet: Objective Caml will work even if"
435 echo "this architecture has actually no alignment constraints."
436 echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
437 esac;;
438 esac
440 if $int64_native; then
441 case "$host" in
442 sparc*-*-*|hppa*-*-*)
443 if test $2 = 8; then
444 echo "64-bit integers can be word-aligned."
445 echo "#undef ARCH_ALIGN_INT64" >> m.h
446 else
447 echo "64-bit integers must be doubleword-aligned."
448 echo "#define ARCH_ALIGN_INT64" >> m.h
449 fi;;
451 sh ./runtest int64align.c
452 case $? in
453 0) echo "64-bit integers can be word-aligned."
454 echo "#undef ARCH_ALIGN_INT64" >> m.h;;
455 1) echo "64-bit integers must be doubleword-aligned."
456 echo "#define ARCH_ALIGN_INT64" >> m.h;;
457 *) echo "Something went wrong during alignment determination for 64-bit integers."
458 echo "I'm going to assume this architecture has alignment constraints."
459 echo "That's a safe bet: Objective Caml will work even if"
460 echo "this architecture has actually no alignment constraints."
461 echo "#define ARCH_ALIGN_INT64" >> m.h;;
462 esac
463 esac
464 else
465 echo "#undef ARCH_ALIGN_INT64" >> m.h
468 # Check semantics of division and modulus
470 sh ./runtest divmod.c
471 case $? in
472 0) echo "Native division and modulus have round-towards-zero semantics, will use them."
473 echo "#undef NONSTANDARD_DIV_MOD" >> m.h;;
474 1) echo "Native division and modulus do not have round-towards-zero semantics, will use software emulation."
475 echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
476 *) echo "Something went wrong while checking native division and modulus, please report it."
477 echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
478 esac
480 # Shared library support
482 shared_libraries_supported=false
483 dl_needs_underscore=false
484 sharedcccompopts=''
485 mksharedlib=''
486 byteccrpath=''
487 mksharedlibrpath=''
489 if test $withsharedlibs = "yes"; then
490 case "$host" in
491 *-*-linux-gnu|*-*-linux|*-*-freebsd[3-9]*|*-*-netbsd*|*-*-gnu*)
492 sharedcccompopts="-fPIC"
493 mksharedlib="$bytecc -shared -o"
494 bytecclinkopts="$bytecclinkopts -Wl,-E"
495 byteccrpath="-Wl,-rpath,"
496 mksharedlibrpath="-Wl,-rpath,"
497 shared_libraries_supported=true;;
498 alpha*-*-osf*)
499 case "$bytecc" in
500 gcc*)
501 sharedcccompopts="-fPIC"
502 mksharedlib="$bytecc -shared -o"
503 byteccrpath="-Wl,-rpath,"
504 mksharedlibrpath="-Wl,-rpath,"
505 shared_libraries_supported=true;;
506 cc*)
507 sharedcccompopts=""
508 mksharedlib="ld -shared -expect_unresolved '*' -o"
509 byteccrpath="-Wl,-rpath,"
510 mksharedlibrpath="-rpath "
511 shared_libraries_supported=true;;
512 esac;;
513 *-*-solaris2*)
514 case "$bytecc" in
515 gcc*)
516 sharedcccompopts="-fPIC"
517 if sh ./solaris-ld; then
518 mksharedlib="$bytecc -shared -o"
519 byteccrpath="-R"
520 mksharedlibrpath="-R"
521 else
522 mksharedlib="$bytecc -shared -o"
523 bytecclinkopts="$bytecclinkopts -Wl,-E"
524 byteccrpath="-Wl,-rpath,"
525 mksharedlibrpath="-Wl,-rpath,"
527 shared_libraries_supported=true;;
529 sharedcccompopts="-KPIC"
530 byteccrpath="-R"
531 mksharedlibrpath="-R"
532 mksharedlib="/usr/ccs/bin/ld -G -o"
533 shared_libraries_supported=true;;
534 esac;;
535 mips*-*-irix[56]*)
536 case "$bytecc" in
537 cc*) sharedcccompopts="";;
538 gcc*) sharedcccompopts="-fPIC";;
539 esac
540 mksharedlib="ld -shared -rdata_shared -o"
541 byteccrpath="-Wl,-rpath,"
542 mksharedlibrpath="-rpath "
543 shared_libraries_supported=true;;
544 *-apple-darwin*)
545 mksharedlib="$bytecc -bundle -flat_namespace -undefined suppress -o"
546 bytecccompopts="$dl_defs $bytecccompopts"
547 #sharedcccompopts="-fnocommon"
548 dl_needs_underscore=true
549 shared_libraries_supported=true;;
550 esac
553 # Further machine-specific hacks
555 case "$host" in
556 ia64-*-linux*|alpha*-*-linux*|x86_64-*-linux*|sparc64-*-linux*)
557 echo "Will use mmap() instead of malloc() for allocation of major heap chunks."
558 echo "#define USE_MMAP_INSTEAD_OF_MALLOC" >> s.h;;
559 esac
561 # Configure the native-code compiler
563 arch=none
564 model=default
565 system=unknown
567 case "$host" in
568 alpha*-*-osf*) arch=alpha; system=digital;;
569 alpha*-*-linux*) arch=alpha; system=linux;;
570 alpha*-*-gnu*) arch=alpha; system=gnu;;
571 alpha*-*-freebsd*) arch=alpha; system=freebsd;;
572 alpha*-*-netbsd*) arch=alpha; system=netbsd;;
573 alpha*-*-openbsd*) arch=alpha; system=openbsd;;
574 sparc*-*-sunos4.*) arch=sparc; system=sunos;;
575 sparc*-*-solaris2.*) arch=sparc; system=solaris;;
576 sparc*-*-*bsd*) arch=sparc; system=bsd;;
577 sparc*-*-linux*) arch=sparc; system=linux;;
578 sparc*-*-gnu*) arch=sparc; system=gnu;;
579 i[3456]86-*-linux*) arch=i386; system=linux_`sh ./runtest elf.c`;;
580 i[3456]86-*-*bsd*) arch=i386; system=bsd_`sh ./runtest elf.c`;;
581 i[3456]86-*-nextstep*) arch=i386; system=nextstep;;
582 i[3456]86-*-solaris*) arch=i386; system=solaris;;
583 i[3456]86-*-beos*) arch=i386; system=beos;;
584 i[3456]86-*-cygwin*) arch=i386; system=cygwin;;
585 i[3456]86-*-darwin*) arch=i386; system=macosx;;
586 i[3456]86-*-gnu*) arch=i386; system=gnu;;
587 mips-*-irix6*) arch=mips; system=irix;;
588 hppa1.1-*-hpux*) arch=hppa; system=hpux;;
589 hppa2.0*-*-hpux*) arch=hppa; system=hpux;;
590 hppa*-*-linux*) arch=hppa; system=linux;;
591 hppa*-*-gnu*) arch=hppa; system=gnu;;
592 powerpc*-*-linux*) arch=power; model=ppc; system=elf;;
593 powerpc-*-netbsd*) arch=power; model=ppc; system=elf;;
594 powerpc-*-rhapsody*) arch=power; model=ppc; system=rhapsody;;
595 powerpc-*-darwin*) arch=power; system=rhapsody
596 if $arch64; then model=ppc64; else model=ppc; fi;;
597 arm*-*-linux*) arch=arm; system=linux;;
598 arm*-*-gnu*) arch=arm; system=gnu;;
599 ia64-*-linux*) arch=ia64; system=linux;;
600 ia64-*-gnu*) arch=ia64; system=gnu;;
601 ia64-*-freebsd*) arch=ia64; system=freebsd;;
602 x86_64-*-linux*) arch=amd64; system=linux;;
603 x86_64-*-gnu*) arch=amd64; system=gnu;;
604 x86_64-*-freebsd*) arch=amd64; system=freebsd;;
605 x86_64-*-netbsd*) arch=amd64; system=netbsd;;
606 x86_64-*-openbsd*) arch=amd64; system=openbsd;;
607 esac
609 # Some platforms exist both in 32-bit and 64-bit variants, not distinguished
610 # by $host. Turn off native code compilation on platforms where 64-bit mode
611 # is not supported. (PR#4441)
613 if $arch64; then
614 case "$arch,$model" in
615 sparc,default|mips,default|hppa,default|power,ppc)
616 arch=none; model=default; system=unknown;;
617 esac
620 if test -z "$ccoption"; then
621 case "$arch,$system,$cc" in
622 alpha,digital,gcc*) nativecc=cc;;
623 mips,*,gcc*) nativecc=cc;;
624 *) nativecc="$bytecc";;
625 esac
626 else
627 nativecc="$ccoption"
630 nativecccompopts=''
631 nativecclinkopts=''
632 nativeccrpath="$byteccrpath"
634 case "$arch,$nativecc,$system,$host_type" in
635 alpha,cc*,digital,*) nativecccompopts=-std1;;
636 mips,cc*,irix,*) nativecccompopts=-n32
637 nativecclinkopts="-n32 -Wl,-woff,84";;
638 *,*,nextstep,*) nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
639 nativecclinkopts="-posix";;
640 *,*,rhapsody,*darwin[1-5].*)
641 nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";;
642 *,*,rhapsody,*) nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs"
643 if $arch64; then partialld="ld -r -arch ppc64"; fi;;
644 *,gcc*,cygwin,*) nativecccompopts="$gcc_warnings -U_WIN32";;
645 *,gcc*,*,*) nativecccompopts="$gcc_warnings";;
646 esac
648 asflags=''
649 aspp=''
650 asppflags=''
651 asppprofflags='-DPROFILING'
653 case "$arch,$model,$system" in
654 alpha,*,digital) aspp='as'; asflags='-O2'; asppflags='-O2 -DSYS_$(SYSTEM)';
655 asppprofflags='-pg -DPROFILING';;
656 alpha,*,linux) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
657 alpha,*,gnu) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
658 alpha,*,freebsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
659 alpha,*,netbsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
660 alpha,*,openbsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
661 mips,*,irix) aspp='as'; asflags='-n32 -O2'; asppflags="$asflags";;
662 sparc,*,bsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
663 sparc,*,linux) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
664 sparc,*,gnu) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
665 sparc,*,*) case "$cc" in
666 gcc*) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
667 *) aspp='as'; asppflags='-P -DSYS_$(SYSTEM)';;
668 esac;;
669 i386,*,solaris) aspp='/usr/ccs/bin/as'; asppflags='-P -DSYS_$(SYSTEM)';;
670 i386,*,*) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
671 hppa,*,*) aspp="$cc"; asppflags='-traditional -c -DSYS_$(SYSTEM)';;
672 power,*,elf) aspp='gcc'; asppflags='-c';;
673 power,*,bsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
674 power,*,rhapsody) aspp="$bytecc"; asppflags='-c';;
675 arm,*,linux) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
676 arm,*,gnu) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
677 ia64,*,*) asflags=-xexplicit
678 aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM) -Wa,-xexplicit';;
679 amd64,*,*) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
680 esac
682 cc_profile='-pg'
683 case "$arch,$model,$system" in
684 alpha,*,digital) profiling='prof';;
685 i386,*,linux_elf) profiling='prof';;
686 i386,*,gnu) profiling='prof';;
687 i386,*,bsd_elf) profiling='prof';;
688 i386,*,macosx) profiling='prof';;
689 sparc,*,solaris)
690 profiling='prof'
691 case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
692 amd64,*,linux) profiling='prof';;
693 amd64,*,gnu) profiling='prof';;
694 *) profiling='noprof';;
695 esac
697 # Where is ranlib?
699 if sh ./searchpath ranlib; then
700 echo "ranlib found"
701 echo "RANLIB=ranlib" >> Makefile
702 echo "RANLIBCMD=ranlib" >> Makefile
703 else
704 echo "ranlib not used"
705 echo "RANLIB=ar rs" >> Makefile
706 echo "RANLIBCMD=" >> Makefile
709 # Do #! scripts work?
711 if (SHELL=/bin/sh; export SHELL; (./sharpbang || ./sharpbang2) >/dev/null); then
712 echo "#! appears to work in shell scripts"
713 case "$host" in
714 *-*-sunos*|*-*-unicos*)
715 echo "We won't use it, though, because under SunOS and Unicos it breaks"
716 echo "on pathnames longer than 30 characters"
717 echo "SHARPBANGSCRIPTS=false" >> Makefile;;
718 *-*-cygwin*)
719 echo "We won't use it, though, because of conflicts with .exe extension"
720 echo "under Cygwin"
721 echo "SHARPBANGSCRIPTS=false" >> Makefile;;
723 echo "SHARPBANGSCRIPTS=true" >> Makefile;;
724 esac
725 else
726 echo "No support for #! in shell scripts"
727 echo "SHARPBANGSCRIPTS=false" >> Makefile
730 # Write the OS type (Unix or Cygwin)
732 echo "#define OCAML_OS_TYPE \"$ostype\"" >> s.h
733 echo "#define OCAML_STDLIB_DIR \"$libdir\"" >> s.h
735 # Use 64-bit file offset if possible
737 bytecccompopts="$bytecccompopts -D_FILE_OFFSET_BITS=64"
738 nativecccompopts="$nativecccompopts -D_FILE_OFFSET_BITS=64"
740 # Check the semantics of signal handlers
742 if sh ./hasgot sigaction sigprocmask; then
743 echo "POSIX signal handling found."
744 echo "#define POSIX_SIGNALS" >> s.h
745 else
746 if sh ./runtest signals.c; then
747 echo "Signals have the BSD semantics."
748 echo "#define BSD_SIGNALS" >> s.h
749 else
750 echo "Signals have the System V semantics."
752 if sh ./hasgot sigsetmask; then
753 echo "sigsetmask() found"
754 echo "#define HAS_SIGSETMASK" >> s.h
758 # For the sys module
760 if sh ./hasgot getrusage; then
761 echo "getrusage() found."
762 echo "#define HAS_GETRUSAGE" >> s.h
765 if sh ./hasgot times; then
766 echo "times() found."
767 echo "#define HAS_TIMES" >> s.h
770 # For the terminfo module
772 if test "$withcurses" = "yes"; then
773 for libs in "" "-lcurses" "-ltermcap" "-lcurses -ltermcap" "-lncurses"; do
774 if sh ./hasgot $libs tgetent tgetstr tgetnum tputs; then
775 echo "termcap functions found (with libraries '$libs')"
776 echo "#define HAS_TERMCAP" >> s.h
777 curseslibs="${libs}"
778 break
780 done
783 # Configuration for the libraries
785 otherlibraries="unix str num dynlink bigarray"
787 # For the Unix library
789 has_sockets=no
790 if sh ./hasgot socket socketpair bind listen accept connect; then
791 echo "You have BSD sockets."
792 echo "#define HAS_SOCKETS" >> s.h
793 has_sockets=yes
794 elif sh ./hasgot -lnsl -lsocket socket socketpair bind listen accept connect; then
795 echo "You have BSD sockets (with libraries '-lnsl -lsocket')"
796 cclibs="$cclibs -lnsl -lsocket"
797 echo "#define HAS_SOCKETS" >> s.h
798 has_sockets=yes
801 if sh ./hasgot -i sys/socket.h -t socklen_t; then
802 echo "socklen_t is defined in <sys/socket.h>"
803 echo "#define HAS_SOCKLEN_T" >> s.h
806 if sh ./hasgot inet_aton; then
807 echo "inet_aton() found."
808 echo "#define HAS_INET_ATON" >> s.h
811 if sh ./hasgot -i sys/types.h -i sys/socket.h -i netinet/in.h \
812 -t 'struct sockaddr_in6' \
813 && sh ./hasgot getaddrinfo getnameinfo inet_pton inet_ntop; then
814 echo "IPv6 is supported."
815 echo "#define HAS_IPV6" >> s.h
818 if sh ./hasgot -i unistd.h; then
819 echo "unistd.h found."
820 echo "#define HAS_UNISTD" >> s.h
823 if sh ./hasgot -i sys/types.h -t off_t; then
824 echo "off_t is defined in <sys/types.h>"
825 echo "#define HAS_OFF_T" >> s.h
828 if sh ./hasgot -i sys/types.h -i dirent.h; then
829 echo "dirent.h found."
830 echo "#define HAS_DIRENT" >> s.h
833 if sh ./hasgot rewinddir; then
834 echo "rewinddir() found."
835 echo "#define HAS_REWINDDIR" >> s.h
838 if sh ./hasgot lockf; then
839 echo "lockf() found."
840 echo "#define HAS_LOCKF" >> s.h
843 if sh ./hasgot mkfifo; then
844 echo "mkfifo() found."
845 echo "#define HAS_MKFIFO" >> s.h
848 if sh ./hasgot getcwd; then
849 echo "getcwd() found."
850 echo "#define HAS_GETCWD" >> s.h
853 if sh ./hasgot getwd; then
854 echo "getwd() found."
855 echo "#define HAS_GETWD" >> s.h
858 if sh ./hasgot getpriority setpriority; then
859 echo "getpriority() found."
860 echo "#define HAS_GETPRIORITY" >> s.h
863 if sh ./hasgot -i sys/types.h -i utime.h && sh ./hasgot utime; then
864 echo "utime() found."
865 echo "#define HAS_UTIME" >> s.h
868 if sh ./hasgot utimes; then
869 echo "utimes() found."
870 echo "#define HAS_UTIMES" >> s.h
873 if sh ./hasgot dup2; then
874 echo "dup2() found."
875 echo "#define HAS_DUP2" >> s.h
878 if sh ./hasgot fchmod fchown; then
879 echo "fchmod() found."
880 echo "#define HAS_FCHMOD" >> s.h
883 if sh ./hasgot truncate ftruncate; then
884 echo "truncate() found."
885 echo "#define HAS_TRUNCATE" >> s.h
888 select_include=''
889 if sh ./hasgot -i sys/types.h -i sys/select.h; then
890 echo "sys/select.h found."
891 echo "#define HAS_SYS_SELECT_H" >> s.h
892 select_include='-i sys/select.h'
895 has_select=no
896 if sh ./hasgot select && \
897 sh ./hasgot -i sys/types.h $select_include -t fd_set ; then
898 echo "select() found."
899 echo "#define HAS_SELECT" >> s.h
900 has_select=yes
903 if sh ./hasgot symlink readlink lstat; then
904 echo "symlink() found."
905 echo "#define HAS_SYMLINK" >> s.h
908 has_wait=no
909 if sh ./hasgot waitpid; then
910 echo "waitpid() found."
911 echo "#define HAS_WAITPID" >> s.h
912 has_wait=yes
915 if sh ./hasgot wait4; then
916 echo "wait4() found."
917 echo "#define HAS_WAIT4" >> s.h
918 has_wait=yes
921 if sh ./hasgot -i limits.h && sh ./runtest getgroups.c; then
922 echo "getgroups() found."
923 echo "#define HAS_GETGROUPS" >> s.h
926 if sh ./hasgot -i termios.h &&
927 sh ./hasgot tcgetattr tcsetattr tcsendbreak tcflush tcflow; then
928 echo "POSIX termios found."
929 echo "#define HAS_TERMIOS" >> s.h
932 # Async I/O under OSF1 3.x are so buggy that the test program hangs...
933 testasyncio=true
934 if test -f /usr/bin/uname; then
935 case "`/usr/bin/uname -s -r`" in
936 "OSF1 V3."*) testasyncio=false;;
937 esac
939 if $testasyncio && sh ./runtest async_io.c; then
940 echo "Asynchronous I/O are supported."
941 echo "#define HAS_ASYNC_IO" >> s.h
944 has_setitimer=no
945 if sh ./hasgot setitimer; then
946 echo "setitimer() found."
947 echo "#define HAS_SETITIMER" >> s.h
948 has_setitimer="yes"
951 if sh ./hasgot gethostname; then
952 echo "gethostname() found."
953 echo "#define HAS_GETHOSTNAME" >> s.h
956 if sh ./hasgot -i sys/utsname.h && sh ./hasgot uname; then
957 echo "uname() found."
958 echo "#define HAS_UNAME" >> s.h
961 has_gettimeofday=no
962 if sh ./hasgot gettimeofday; then
963 echo "gettimeofday() found."
964 echo "#define HAS_GETTIMEOFDAY" >> s.h
965 has_gettimeofday="yes"
968 if sh ./hasgot mktime; then
969 echo "mktime() found."
970 echo "#define HAS_MKTIME" >> s.h
973 case "$host" in
974 *-*-cygwin*) ;; # setsid emulation under Cygwin breaks the debugger
975 *) if sh ./hasgot setsid; then
976 echo "setsid() found."
977 echo "#define HAS_SETSID" >> s.h
978 fi;;
979 esac
981 if sh ./hasgot putenv; then
982 echo "putenv() found."
983 echo "#define HAS_PUTENV" >> s.h
986 if sh ./hasgot -i locale.h && sh ./hasgot setlocale; then
987 echo "setlocale() and <locale.h> found."
988 echo "#define HAS_LOCALE" >> s.h
991 if sh ./hasgot -i mach-o/dyld.h && sh ./hasgot NSLinkModule; then
992 echo "NSLinkModule() found. Using darwin dynamic loading."
993 echo "#define HAS_NSLINKMODULE" >> s.h
994 elif sh ./hasgot $dllib dlopen; then
995 echo "dlopen() found."
996 elif sh ./hasgot $dllib -ldl dlopen; then
997 echo "dlopen() found in -ldl."
998 dllib="$dllib -ldl"
999 else
1000 shared_libraries_supported=false
1003 if $shared_libraries_supported; then
1004 echo "Dynamic loading of shared libraries is supported."
1005 echo "#define SUPPORT_DYNAMIC_LINKING" >> s.h
1006 if $dl_needs_underscore; then
1007 echo '#define DL_NEEDS_UNDERSCORE' >>s.h
1011 if sh ./hasgot -i sys/types.h -i sys/mman.h && sh ./hasgot mmap munmap; then
1012 echo "mmap() found."
1013 echo "#define HAS_MMAP" >> s.h
1016 nargs=none
1017 for i in 5 6; do
1018 if sh ./trycompile -DNUM_ARGS=${i} gethostbyname.c; then nargs=$i; break; fi
1019 done
1020 if test $nargs != "none"; then
1021 echo "gethostbyname_r() found (with ${nargs} arguments)."
1022 echo "#define HAS_GETHOSTBYNAME_R $nargs" >> s.h
1025 nargs=none
1026 for i in 7 8; do
1027 if sh ./trycompile -DNUM_ARGS=${i} gethostbyaddr.c; then nargs=$i; break; fi
1028 done
1029 if test $nargs != "none"; then
1030 echo "gethostbyaddr_r() found (with ${nargs} arguments)."
1031 echo "#define HAS_GETHOSTBYADDR_R $nargs" >> s.h
1034 # Determine if the debugger is supported
1036 if test "$has_sockets" = "yes"; then
1037 echo "Replay debugger supported."
1038 debugger="ocamldebugger"
1039 else
1040 echo "No replay debugger (missing system calls)"
1041 debugger=""
1045 # Determine if system stack overflows can be detected
1047 case "$arch,$system" in
1048 i386,linux_elf|amd64,linux|power,rhapsody|i386,macosx)
1049 echo "System stack overflow can be detected."
1050 echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h;;
1052 echo "Cannot detect system stack overflow.";;
1053 esac
1055 # Determine the target architecture for the "num" library
1057 case "$host" in
1058 alpha*-*-*) bng_arch=alpha; bng_asm_level=1;;
1059 i[3456]86-*-*) bng_arch=ia32
1060 if sh ./trycompile ia32sse2.c
1061 then bng_asm_level=2
1062 else bng_asm_level=1
1063 fi;;
1064 mips-*-*) bng_arch=mips; bng_asm_level=1;;
1065 powerpc-*-*) bng_arch=ppc; bng_asm_level=1;;
1066 sparc*-*-*) bng_arch=sparc; bng_asm_level=1;;
1067 x86_64-*-*) bng_arch=amd64; bng_asm_level=1;;
1068 *) bng_arch=generic; bng_asm_level=0;;
1069 esac
1071 echo "BNG_ARCH=$bng_arch" >> Makefile
1072 echo "BNG_ASM_LEVEL=$bng_asm_level" >> Makefile
1074 # Determine if the POSIX threads library is supported
1076 systhread_support=false
1078 if test "$pthread_wanted" = "yes"; then
1079 case "$host" in
1080 *-*-solaris*) pthread_link="-lpthread -lposix4"
1081 pthread_caml_link="-cclib -lpthread -cclib -lposix4";;
1082 *-*-freebsd*) pthread_link="-pthread"
1083 pthread_caml_link="-cclib -pthread";;
1084 *-*-openbsd*) pthread_link="-pthread"
1085 pthread_caml_link="-cclib -pthread";;
1086 *) pthread_link="-lpthread"
1087 pthread_caml_link="-cclib -lpthread";;
1088 esac
1089 if ./hasgot -i pthread.h $pthread_link pthread_self; then
1090 echo "POSIX threads library supported."
1091 systhread_support=true
1092 otherlibraries="$otherlibraries systhreads"
1093 bytecccompopts="$bytecccompopts -D_REENTRANT"
1094 nativecccompopts="$nativecccompopts -D_REENTRANT"
1095 case "$host" in
1096 *-*-freebsd*)
1097 bytecccompopts="$bytecccompopts -D_THREAD_SAFE"
1098 nativecccompopts="$nativecccompopts -D_THREAD_SAFE";;
1099 *-*-openbsd*)
1100 bytecccompopts="$bytecccompopts -pthread"
1101 asppflags="$asppflags -pthread"
1102 nativecccompopts="$nativecccompopts -pthread";;
1103 esac
1104 echo "Options for linking with POSIX threads: $pthread_link"
1105 if sh ./hasgot $pthread_link sigwait; then
1106 echo "sigwait() found"
1107 echo "#define HAS_SIGWAIT" >> s.h
1109 else
1110 echo "POSIX threads not found."
1111 pthread_link=""
1113 else
1114 pthread_link=""
1116 echo "PTHREAD_LINK=$pthread_caml_link" >> Makefile
1118 # Determine if the bytecode thread library is supported
1120 if test "$has_select" = "yes" \
1121 && test "$has_setitimer" = "yes" \
1122 && test "$has_gettimeofday" = "yes" \
1123 && test "$has_wait" = "yes"; then
1124 echo "Bytecode threads library supported."
1125 otherlibraries="$otherlibraries threads"
1126 else
1127 echo "Bytecode threads library not supported (missing system calls)"
1130 # Determine the location of X include files and libraries
1132 x11_include="not found"
1133 x11_link="not found"
1135 for dir in \
1136 $x11_include_dir \
1138 /usr/X11R6/include \
1139 /usr/include/X11R6 \
1140 /usr/local/X11R6/include \
1141 /usr/local/include/X11R6 \
1142 /opt/X11R6/include \
1144 /usr/X11/include \
1145 /usr/include/X11 \
1146 /usr/local/X11/include \
1147 /usr/local/include/X11 \
1148 /opt/X11/include \
1150 /usr/X11R5/include \
1151 /usr/include/X11R5 \
1152 /usr/local/X11R5/include \
1153 /usr/local/include/X11R5 \
1154 /usr/local/x11r5/include \
1155 /opt/X11R5/include \
1157 /usr/X11R4/include \
1158 /usr/include/X11R4 \
1159 /usr/local/X11R4/include \
1160 /usr/local/include/X11R4 \
1162 /usr/X386/include \
1163 /usr/x386/include \
1164 /usr/XFree86/include/X11 \
1166 /usr/include \
1167 /usr/local/include \
1168 /usr/unsupported/include \
1169 /usr/athena/include \
1170 /usr/lpp/Xamples/include \
1172 /usr/openwin/include \
1173 /usr/openwin/share/include \
1176 if test -f $dir/X11/X.h; then
1177 x11_include=$dir
1178 break
1180 done
1182 if test "$x11_include" = "not found"; then
1183 x11_try_lib_dir=''
1184 else
1185 x11_try_lib_dir=`echo $x11_include | sed -e 's|include|lib|'`
1188 for dir in \
1189 $x11_lib_dir \
1190 $x11_try_lib_dir \
1192 /usr/X11R6/lib64 \
1193 /usr/X11R6/lib \
1194 /usr/lib/X11R6 \
1195 /usr/local/X11R6/lib \
1196 /usr/local/lib/X11R6 \
1197 /opt/X11R6/lib \
1199 /usr/X11/lib \
1200 /usr/lib/X11 \
1201 /usr/local/X11/lib \
1202 /usr/local/lib/X11 \
1203 /opt/X11/lib \
1205 /usr/X11R5/lib \
1206 /usr/lib/X11R5 \
1207 /usr/local/X11R5/lib \
1208 /usr/local/lib/X11R5 \
1209 /usr/local/x11r5/lib \
1210 /opt/X11R5/lib \
1212 /usr/X11R4/lib \
1213 /usr/lib/X11R4 \
1214 /usr/local/X11R4/lib \
1215 /usr/local/lib/X11R4 \
1217 /usr/X386/lib \
1218 /usr/x386/lib \
1219 /usr/XFree86/lib/X11 \
1221 /usr/lib64 \
1222 /usr/lib \
1223 /usr/local/lib \
1224 /usr/unsupported/lib \
1225 /usr/athena/lib \
1226 /usr/lpp/Xamples/lib \
1227 /lib/usr/lib/X11 \
1229 /usr/openwin/lib \
1230 /usr/openwin/share/lib \
1233 if test -f $dir/libX11.a || \
1234 test -f $dir/libX11.so || \
1235 test -f $dir/libX11.dll.a || \
1236 test -f $dir/libX11.dylib || \
1237 test -f $dir/libX11.sa; then
1238 if test $dir = /usr/lib; then
1239 x11_link="-lX11"
1240 else
1241 x11_link="-L$dir -lX11"
1242 x11_libs="-L$dir"
1244 break
1246 done
1249 if test "$x11_include" = "not found" || test "$x11_link" = "not found"
1250 then
1251 echo "X11 not found, the \"graph\" library will not be supported."
1252 x11_include=""
1253 else
1254 echo "Location of X11 include files: $x11_include/X11"
1255 echo "Options for linking with X11: $x11_link"
1256 otherlibraries="$otherlibraries graph"
1257 if test "$x11_include" = "/usr/include"; then
1258 x11_include=""
1259 else
1260 x11_include="-I$x11_include"
1263 echo "X11_INCLUDES=$x11_include" >> Makefile
1264 echo "X11_LINK=$x11_link" >> Makefile
1266 # See if we can compile the dbm library
1268 dbm_include="not found"
1269 dbm_link="not found"
1270 use_gdbm_ndbm=no
1272 for dir in /usr/include /usr/include/db1 /usr/include/gdbm; do
1273 if test -f $dir/ndbm.h; then
1274 dbm_include=$dir
1275 if sh ./hasgot dbm_open; then
1276 dbm_link=""
1277 elif sh ./hasgot -lndbm dbm_open; then
1278 dbm_link="-lndbm"
1279 elif sh ./hasgot -ldb1 dbm_open; then
1280 dbm_link="-ldb1"
1281 elif sh ./hasgot -lgdbm dbm_open; then
1282 dbm_link="-lgdbm"
1283 elif sh ./hasgot -lgdbm_compat -lgdbm dbm_open; then
1284 dbm_link="-lgdbm_compat -lgdbm"
1286 break
1288 if test -f $dir/gdbm-ndbm.h; then
1289 dbm_include=$dir
1290 use_gdbm_ndbm=yes
1291 if sh ./hasgot -lgdbm_compat -lgdbm dbm_open; then
1292 dbm_link="-lgdbm_compat -lgdbm"
1294 break
1296 done
1297 if test "$dbm_include" = "not found" || test "$dbm_link" = "not found"; then
1298 echo "NDBM not found, the \"dbm\" library will not be supported."
1299 else
1300 echo "NDBM found (in $dbm_include)"
1301 if test "$dbm_include" = "/usr/include"; then
1302 dbm_include=""
1303 else
1304 dbm_include="-I$dbm_include"
1306 if test "$use_gdbm_ndbm" = "yes"; then
1307 echo "#define DBM_USES_GDBM_NDBM" >> s.h
1309 otherlibraries="$otherlibraries dbm"
1311 echo "DBM_INCLUDES=$dbm_include" >> Makefile
1312 echo "DBM_LINK=$dbm_link" >> Makefile
1314 # Look for tcl/tk
1316 echo "Configuring LablTk..."
1318 if test $tk_wanted = no; then
1319 has_tk=false
1320 elif test $tk_x11 = no; then
1321 has_tk=true
1322 elif test "$x11_include" = "not found" || test "$x11_link" = "not found"; then
1323 echo "X11 not found."
1324 has_tk=false
1325 else
1326 tk_x11_include="$x11_include"
1327 tk_x11_libs="$x11_libs -lX11"
1328 has_tk=true
1331 if test $has_tk = true; then
1332 tcl_version=''
1333 tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
1334 for tk_incs in \
1335 "-I/usr/local/include" \
1336 "-I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4" \
1337 "-I/usr/include/tcl8.4 -I/usr/include/tk8.4" \
1338 "-I/usr/local/include/tcl8.3 -I/usr/local/include/tk8.3" \
1339 "-I/usr/include/tcl8.3 -I/usr/include/tk8.3" \
1340 "-I/usr/local/include/tcl8.2 -I/usr/local/include/tk8.2" \
1341 "-I/usr/include/tcl8.2 -I/usr/include/tk8.2" \
1342 "-I/sw/include" \
1343 "-I/usr/pkg/include"
1344 do if test -z "$tcl_version"; then
1345 tk_defs="$tk_incs"
1346 tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
1347 fi; done
1348 if test -n "$tcl_version" && test "x$tcl_version" != "xnone"; then
1349 echo "tcl.h and tk.h version $tcl_version found with \"$tk_defs\"."
1350 case $tcl_version in
1351 7.5) tclmaj=7 tclmin=5 tkmaj=4 tkmin=1 ;;
1352 7.6) tclmaj=7 tclmin=6 tkmaj=4 tkmin=2 ;;
1353 8.0) tclmaj=8 tclmin=0 tkmaj=8 tkmin=0 ;;
1354 8.1) tclmaj=8 tclmin=1 tkmaj=8 tkmin=1 ;;
1355 8.2) tclmaj=8 tclmin=2 tkmaj=8 tkmin=2 ;;
1356 8.3) tclmaj=8 tclmin=3 tkmaj=8 tkmin=3 ;;
1357 8.4) tclmaj=8 tclmin=4 tkmaj=8 tkmin=4 ;;
1358 *) echo "This version is not known."; has_tk=false ;;
1359 esac
1360 else
1361 echo "tcl.h and/or tk.h not found."
1362 has_tk=false
1366 tkauxlibs="$mathlib $dllib"
1367 tcllib=''
1368 tklib=''
1369 if test $has_tk = true; then
1370 if test -n "$tk_libs" && \
1371 sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tcl_DoOneEvent
1372 then tk_libs="$tk_libs $dllib"
1373 elif sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent
1374 then
1375 tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
1376 elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent
1377 then
1378 tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib"
1379 elif test -z "$tk_libs" && tk_libs=-L/usr/local/lib && \
1380 sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent
1381 then
1382 tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
1383 elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent
1384 then
1385 tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib"
1386 elif sh ./hasgot -L/sw/lib $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs \
1387 Tcl_DoOneEvent
1388 then tk_libs="-L/sw/lib -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
1389 elif sh ./hasgot -L/usr/pkg/lib $tk_libs $tk_x11_libs \
1390 -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin -lpthread $tkauxlibs \
1391 Tcl_DoOneEvent
1392 then
1393 tk_libs="-L/usr/pkg/lib $tk_libs $tk_x11_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin -lpthread $tkauxlibs"
1394 else
1395 echo "Tcl library not found."
1396 has_tk=false
1400 if test $has_tk = true; then
1401 if sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then
1402 echo "Tcl/Tk libraries found."
1403 elif sh ./hasgot -L/sw/lib $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then
1404 tk_libs="-L/sw/lib $tk_libs"
1405 echo "Tcl/Tk libraries found."
1406 elif sh ./hasgot -L/usr/pkg/lib $tk_libs $tk_x11_libs $tkauxlibs \
1407 Tk_SetGrid; then
1408 tk_libs="-L/usr/pkg/lib $tk_libs"
1409 echo "Tcl/Tk libraries found."
1410 else
1411 echo "Tcl library found."
1412 echo "Tk library not found."
1413 has_tk=false
1417 if test $has_tk = true; then
1418 if test $tk_x11 = yes; then
1419 echo "TK_DEFS=$tk_defs "'$(X11_INCLUDES)' >> Makefile
1420 echo "TK_LINK=$tk_libs "'$(X11_LINK)' >> Makefile
1421 else
1422 echo "TK_DEFS=$tk_defs" >> Makefile
1423 echo "TK_LINK=$tk_libs" >> Makefile
1425 otherlibraries="$otherlibraries labltk"
1426 else
1427 echo "Configuration failed, LablTk will not be built."
1428 echo "TK_DEFS=" >> Makefile
1429 echo "TK_LINK=" >> Makefile
1432 # Final twiddling of compiler options to work around known bugs
1434 nativeccprofopts="$nativecccompopts"
1435 case "$buggycc" in
1436 gcc.2.96)
1437 bytecccompopts="$bytecccompopts -fomit-frame-pointer"
1438 nativecccompopts="$nativecccompopts -fomit-frame-pointer";;
1439 esac
1441 # Finish generated files
1443 cclibs="$cclibs $mathlib"
1445 echo "BYTECC=$bytecc" >> Makefile
1446 echo "BYTECCCOMPOPTS=$bytecccompopts" >> Makefile
1447 echo "BYTECCLINKOPTS=$bytecclinkopts" >> Makefile
1448 echo "BYTECCLIBS=$cclibs $dllib $curseslibs $pthread_link" >> Makefile
1449 echo "BYTECCRPATH=$byteccrpath" >> Makefile
1450 echo "EXE=$exe" >> Makefile
1451 echo "SUPPORTS_SHARED_LIBRARIES=$shared_libraries_supported" >> Makefile
1452 echo "SHAREDCCCOMPOPTS=$sharedcccompopts" >> Makefile
1453 echo "MKSHAREDLIBRPATH=$mksharedlibrpath" >> Makefile
1454 cat >> Makefile <<EOF
1455 SYSLIB=-l\$(1)
1456 #ml let syslib x = "-l"^x;;
1458 MKEXE=\$(BYTECC) -o \$(1) \$(2)
1459 #ml let mkexe out files opts = Printf.sprintf "%s -o %s %s %s" bytecc out opts files;;
1461 ### How to build a DLL
1462 MKDLL=$mksharedlib \$(1) \$(3)
1463 #ml let mkdll out _implib files opts = Printf.sprintf "%s %s %s %s" "$mksharedlib" out opts files;;
1465 ### How to build a static library
1466 MKLIB=ar rc \$(1) \$(2); ranlib \$(1)
1467 #ml let mklib out files opts = Printf.sprintf "ar rc %s %s %s; ranlib %s" out opts files out;;
1469 echo "ARCH=$arch" >> Makefile
1470 echo "MODEL=$model" >> Makefile
1471 echo "SYSTEM=$system" >> Makefile
1472 echo "NATIVECC=$nativecc" >> Makefile
1473 echo "NATIVECCCOMPOPTS=$nativecccompopts" >> Makefile
1474 echo "NATIVECCPROFOPTS=$nativeccprofopts" >> Makefile
1475 echo "NATIVECCLINKOPTS=$nativecclinkopts" >> Makefile
1476 echo "NATIVECCRPATH=$nativeccrpath" >> Makefile
1477 echo "NATIVECCLIBS=$cclibs $dllib" >> Makefile
1478 echo "ASFLAGS=$asflags" >> Makefile
1479 echo "ASPP=$aspp" >> Makefile
1480 echo "ASPPFLAGS=$asppflags" >> Makefile
1481 echo "ASPPPROFFLAGS=$asppprofflags" >> Makefile
1482 echo "PROFILING=$profiling" >> Makefile
1483 echo "DYNLINKOPTS=$dllib" >> Makefile
1484 echo "OTHERLIBRARIES=$otherlibraries" >> Makefile
1485 echo "DEBUGGER=$debugger" >> Makefile
1486 echo "CC_PROFILE=$cc_profile" >> Makefile
1487 echo "SYSTHREAD_SUPPORT=$systhread_support" >> Makefile
1488 echo "PARTIALLD=$partialld" >> Makefile
1489 echo "DLLCCCOMPOPTS=" >> Makefile
1490 echo "O=o" >> Makefile
1491 echo "A=a" >> Makefile
1492 echo "EXT_OBJ=.o" >> Makefile
1493 echo "EXT_ASM=.s" >> Makefile
1494 echo "EXT_LIB=.a" >> Makefile
1495 echo "EXT_DLL=.so" >> Makefile
1496 echo "EXTRALIBS=" >> Makefile
1497 echo "CCOMPTYPE=cc" >> Makefile
1498 echo "TOOLCHAIN=cc" >> Makefile
1500 rm -f tst hasgot.c
1501 rm -f ../m.h ../s.h ../Makefile
1502 mv m.h s.h Makefile ..
1504 # Print a summary
1506 echo
1507 echo "** Configuration summary **"
1508 echo
1509 echo "Directories where Objective Caml will be installed:"
1510 echo " binaries.................. $bindir"
1511 echo " standard library.......... $libdir"
1512 echo " manual pages.............. $mandir (with extension .$manext)"
1514 echo "Configuration for the bytecode compiler:"
1515 echo " C compiler used........... $bytecc"
1516 echo " options for compiling..... $bytecccompopts"
1517 echo " options for linking....... $bytecclinkopts $cclibs $dllib $curseslibs $pthread_link"
1518 if $shared_libraries_supported; then
1519 echo " shared libraries are supported"
1520 echo " options for compiling..... $sharedcccompopts $bytecccompopts"
1521 echo " command for building...... $mksharedlib lib.so $mksharedlibrpath/a/path objs"
1522 else
1523 echo " shared libraries not supported"
1526 echo "Configuration for the native-code compiler:"
1527 if test "$arch" = "none"; then
1528 echo " (not supported on this platform)"
1529 else
1530 if test "$model" = "default"; then
1531 echo " hardware architecture..... $arch"
1532 else
1533 echo " hardware architecture..... $arch ($model)"
1535 if test "$system" = "unknown"; then : ; else
1536 echo " OS variant................ $system"
1538 echo " C compiler used........... $nativecc"
1539 echo " options for compiling..... $nativecccompopts"
1540 echo " options for linking....... $nativecclinkopts $cclibs"
1541 echo " assembler ................ \$(AS) $asflags"
1542 echo " preprocessed assembler ... $aspp $asppflags"
1543 if test "$profiling" = "prof"; then
1544 echo " profiling with gprof ..... supported"
1545 else
1546 echo " profiling with gprof ..... not supported"
1550 if test "$debugger" = "ocamldebugger"; then
1551 echo "Source-level replay debugger: supported"
1552 else
1553 echo "Source-level replay debugger: not supported"
1556 echo "Additional libraries supported:"
1557 echo " $otherlibraries"
1559 echo "Configuration for the \"num\" library:"
1560 echo " target architecture ...... $bng_arch (asm level $bng_asm_level)"
1562 if test "$x11_include" != "not found" && test "$x11_lib" != "not found"; then
1563 echo "Configuration for the \"graph\" library:"
1564 echo " options for compiling .... $x11_include"
1565 echo " options for linking ...... $x11_link"
1568 if test $has_tk = true; then
1569 echo "Configuration for the \"labltk\" library:"
1570 echo " use tcl/tk version ....... $tcl_version"
1571 echo " options for compiling .... $tk_defs"
1572 echo " options for linking ...... $tk_libs"
1573 else
1574 echo "The \"labltk\" library: not supported"
1577 echo
1578 echo "** Objective Caml configuration completed successfully **"
1579 echo