~ubuntu-branches/debian/sid/ocaml/sid

« back to all changes in this revision

Viewing changes to .pc/0008-Natdynlink-works-on-powerpc-and-hurd-i386.patch/configure

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu
  • Date: 2011-04-21 21:35:08 UTC
  • mfrom: (1.1.11 upstream) (12.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110421213508-kg34453aqmb0moha
* Fixes related to -output-obj with g++ (in debian/patches):
  - add Declare-primitive-name-table-as-const-char
  - add Avoid-multiple-declarations-in-generated-.c-files-in
  - fix Embed-bytecode-in-C-object-when-using-custom: the closing
    brace for extern "C" { ... } was missing in some cases

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
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
#########################################################################
 
15
 
 
16
# $Id: configure 10636 2010-07-28 13:18:22Z doligez $
 
17
 
 
18
configure_options="$*"
 
19
prefix=/usr/local
 
20
bindir=''
 
21
libdir=''
 
22
mandir=''
 
23
manext=1
 
24
host_type=unknown
 
25
ccoption=''
 
26
asoption=''
 
27
asppoption=''
 
28
cclibs=''
 
29
curseslibs=''
 
30
mathlib='-lm'
 
31
dllib=''
 
32
x11_include_dir=''
 
33
x11_lib_dir=''
 
34
tk_wanted=yes
 
35
pthread_wanted=yes
 
36
tk_defs=''
 
37
tk_libs=''
 
38
tk_x11=yes
 
39
dl_defs=''
 
40
verbose=no
 
41
withcurses=yes
 
42
withsharedlibs=yes
 
43
gcc_warnings="-Wall"
 
44
partialld="ld -r"
 
45
 
 
46
# Try to turn internationalization off, can cause config.guess to malfunction!
 
47
unset LANG
 
48
unset LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
 
49
 
 
50
# Turn off some MacOS X debugging stuff, same reason
 
51
unset RC_TRACE_ARCHIVES RC_TRACE_DYLIBS RC_TRACE_PREBINDING_DISABLED
 
52
 
 
53
# Parse command-line arguments
 
54
 
 
55
while : ; do
 
56
  case "$1" in
 
57
    "") break;;
 
58
    -prefix|--prefix)
 
59
        prefix=$2; shift;;
 
60
    -bindir|--bindir)
 
61
        bindir=$2; shift;;
 
62
    -libdir|--libdir)
 
63
        libdir=$2; shift;;
 
64
    -mandir|--mandir)
 
65
        case "$2" in
 
66
          */man[1-9ln])
 
67
            mandir=`echo $2 | sed -e 's|^\(.*\)/man.$|\1|'`
 
68
            manext=`echo $2 | sed -e 's/^.*\(.\)$/\1/'`;;
 
69
          *)
 
70
            mandir=$2
 
71
            manext=1;;
 
72
        esac
 
73
        shift;;
 
74
    -host*|--host*)
 
75
        host_type=$2; shift;;
 
76
    -cc*)
 
77
        ccoption="$2"; shift;;
 
78
    -as)
 
79
        asoption="$2"; shift;;
 
80
    -aspp)
 
81
        asppoption="$2"; shift;;
 
82
    -lib*)
 
83
        cclibs="$2 $cclibs"; shift;;
 
84
    -no-curses)
 
85
        withcurses=no;;
 
86
    -no-shared-libs)
 
87
        withsharedlibs=no;;
 
88
    -x11include*|--x11include*)
 
89
        x11_include_dir=$2; shift;;
 
90
    -x11lib*|--x11lib*)
 
91
        x11_lib_dir=$2; shift;;
 
92
    -with-pthread*|--with-pthread*)
 
93
        ;; # Ignored for backward compatibility
 
94
    -no-pthread*|--no-pthread*)
 
95
        pthread_wanted=no;;
 
96
    -no-tk|--no-tk)
 
97
        tk_wanted=no;;
 
98
    -partialld|--partialld)
 
99
        partialld="$2"; shift;;
 
100
    -tkdefs*|--tkdefs*)
 
101
        tk_defs=$2; shift;;
 
102
    -tklibs*|--tklibs*)
 
103
        tk_libs=$2; shift;;
 
104
    -tk-no-x11|--tk-no-x11)
 
105
        tk_x11=no;;
 
106
    -dldefs*|--dldefs*)
 
107
        dl_defs="$2"; shift;;
 
108
    -dllibs*|--dllibs*)
 
109
        dllib="$2"; shift;;
 
110
    -verbose|--verbose)
 
111
        verbose=yes;;
 
112
    *) echo "Unknown option \"$1\"." 1>&2; exit 2;;
 
113
  esac
 
114
  shift
 
115
done
 
116
 
 
117
# Sanity checks
 
118
 
 
119
case "$prefix" in
 
120
  /*) ;;
 
121
   *) echo "The -prefix directory must be absolute." 1>&2; exit 2;;
 
122
esac
 
123
case "$bindir" in
 
124
  /*) ;;
 
125
  "") ;;
 
126
   *) echo "The -bindir directory must be absolute." 1>&2; exit 2;;
 
127
esac
 
128
case "$libdir" in
 
129
  /*) ;;
 
130
  "") ;;
 
131
   *) echo "The -libdir directory must be absolute." 1>&2; exit 2;;
 
132
esac
 
133
case "$mandir" in
 
134
  /*) ;;
 
135
  "") ;;
 
136
   *) echo "The -mandir directory must be absolute." 1>&2; exit 2;;
 
137
esac
 
138
 
 
139
# Generate the files
 
140
 
 
141
cd config/auto-aux
 
142
rm -f s.h m.h Makefile
 
143
touch s.h m.h Makefile
 
144
 
 
145
# Write options to Makefile
 
146
 
 
147
echo "# generated by ./configure $configure_options" >> Makefile
 
148
 
 
149
# Where to install
 
150
 
 
151
echo "PREFIX=$prefix" >> Makefile
 
152
case "$bindir" in
 
153
  "") echo 'BINDIR=$(PREFIX)/bin' >> Makefile
 
154
      bindir="$prefix/bin";;
 
155
   *) echo "BINDIR=$bindir" >> Makefile;;
 
156
esac
 
157
case "$libdir" in
 
158
  "") echo 'LIBDIR=$(PREFIX)/lib/ocaml' >> Makefile
 
159
      libdir="$prefix/lib/ocaml";;
 
160
   *) echo "LIBDIR=$libdir" >> Makefile;;
 
161
esac
 
162
echo 'STUBLIBDIR=$(LIBDIR)/stublibs' >> Makefile
 
163
case "$mandir" in
 
164
  "") echo 'MANDIR=$(PREFIX)/man' >> Makefile
 
165
      mandir="$prefix/man";;
 
166
   *) echo "MANDIR=$mandir" >> Makefile;;
 
167
esac
 
168
echo "MANEXT=$manext" >> Makefile
 
169
 
 
170
# Determine the system type
 
171
 
 
172
if test "$host_type" = "unknown"; then
 
173
  if host_type=`../gnu/config.guess`; then :; else
 
174
    echo "Cannot guess host type"
 
175
    echo "You must specify one with the -host option"
 
176
    exit 2
 
177
  fi
 
178
fi
 
179
if host=`../gnu/config.sub $host_type`; then :; else
 
180
  echo "Please specify the correct host type with the -host option"
 
181
  exit 2
 
182
fi
 
183
echo "Configuring for a $host ..."
 
184
 
 
185
# Do we have gcc?
 
186
 
 
187
if test -z "$ccoption"; then
 
188
  if sh ./searchpath gcc; then
 
189
    echo "gcc found"
 
190
    cc=gcc
 
191
  else
 
192
    cc=cc
 
193
  fi
 
194
else
 
195
  cc="$ccoption"
 
196
fi
 
197
 
 
198
# Check for buggy versions of GCC
 
199
 
 
200
buggycc="no"
 
201
 
 
202
case "$host,$cc" in
 
203
  i[3456]86-*-*,gcc*)
 
204
    case `$cc --version` in
 
205
      2.7.2.1) cat <<'EOF'
 
206
 
 
207
WARNING: you are using gcc version 2.7.2.1 on an Intel x86 processor.
 
208
This version of gcc is known to generate incorrect code for the
 
209
Objective Caml runtime system on some Intel x86 machines. (The symptom
 
210
is a crash of boot/ocamlc when compiling stdlib/pervasives.mli.)
 
211
In particular, the version of gcc 2.7.2.1 that comes with
 
212
Linux RedHat 4.x / Intel is affected by this problem.
 
213
Other Linux distributions might also be affected.
 
214
If you are using one of these configurations, you are strongly advised
 
215
to use another version of gcc, such as 2.95, which are
 
216
known to work well with Objective Caml.
 
217
 
 
218
Press <enter> to proceed or <interrupt> to stop.
 
219
EOF
 
220
        read reply;;
 
221
      2.96*) cat <<'EOF'
 
222
 
 
223
WARNING: you are using gcc version 2.96 on an Intel x86 processor.
 
224
Certain patched versions of gcc 2.96 are known to generate incorrect
 
225
code for the Objective Caml runtime system.  (The symptom is a segmentation
 
226
violation on boot/ocamlc.)  Those incorrectly patched versions can be found
 
227
in RedHat 7.2 and Mandrake 8.0 and 8.1; other Linux distributions
 
228
might also be affected.  (See bug #57760 on bugzilla.redhat.com)
 
229
 
 
230
Auto-configuration will now select gcc compiler flags that work around
 
231
the problem.  Still, if you observe segmentation faults while running
 
232
ocamlc or ocamlopt, you are advised to try another version of gcc,
 
233
such as 2.95.3 or 3.2.
 
234
 
 
235
EOF
 
236
        buggycc="gcc.2.96";;
 
237
 
 
238
            esac;;
 
239
esac
 
240
 
 
241
# Configure the bytecode compiler
 
242
 
 
243
bytecc="$cc"
 
244
mkexe="\$(BYTECC)"
 
245
bytecccompopts=""
 
246
bytecclinkopts=""
 
247
dllccompopts=""
 
248
ostype="Unix"
 
249
exe=""
 
250
iflexdir=""
 
251
 
 
252
case "$bytecc,$host" in
 
253
  cc,*-*-nextstep*)
 
254
    # GNU C extensions disabled, but __GNUC__ still defined!
 
255
    bytecccompopts="-fno-defer-pop $gcc_warnings -U__GNUC__ -posix"
 
256
    bytecclinkopts="-posix";;
 
257
  *,*-*-rhapsody*)
 
258
    # Almost the same as NeXTStep
 
259
    bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
 
260
    mathlib="";;
 
261
  *,*-*-darwin*)
 
262
    bytecccompopts="-fno-defer-pop -no-cpp-precomp $gcc_warnings"
 
263
    mathlib=""
 
264
    # Tell gcc that we can use 32-bit code addresses for threaded code
 
265
    # unless we are compiled for a shared library (-fPIC option)
 
266
    echo "#ifndef __PIC__" >> m.h
 
267
    echo "#  define ARCH_CODE32" >> m.h
 
268
    echo "#endif" >> m.h;;
 
269
  *,*-*-beos*)
 
270
    bytecccompopts="-fno-defer-pop $gcc_warnings"
 
271
    # No -lm library
 
272
    mathlib="";;
 
273
  gcc,alpha*-*-osf*)
 
274
    bytecccompopts="-fno-defer-pop $gcc_warnings"
 
275
    if cc="$bytecc" sh ./hasgot -mieee; then
 
276
      bytecccompopts="-mieee $bytecccompopts";
 
277
    fi
 
278
    # Put code and static data in lower 4GB
 
279
    bytecclinkopts="-Wl,-T,12000000 -Wl,-D,14000000"
 
280
    # Tell gcc that we can use 32-bit code addresses for threaded code
 
281
    echo "#define ARCH_CODE32" >> m.h;;
 
282
  cc,alpha*-*-osf*)
 
283
    bytecccompopts="-std1 -ieee";;
 
284
  gcc,alpha*-*-linux*)
 
285
    if cc="$bytecc" sh ./hasgot -mieee; then
 
286
      bytecccompopts="-mieee $bytecccompopts";
 
287
    fi
 
288
    bytecclinkopts="-Wl,--no-relax";;
 
289
  cc,mips-*-irix6*)
 
290
    # Add -n32 flag to ensure compatibility with native-code compiler
 
291
    bytecccompopts="-n32"
 
292
    # Turn off warning "unused library"
 
293
    bytecclinkopts="-n32 -Wl,-woff,84";;
 
294
  cc*,mips-*-irix6*)
 
295
    # (For those who want to force "cc -64")
 
296
    # Turn off warning "unused library"
 
297
    bytecclinkopts="-Wl,-woff,84";;
 
298
  *,alpha*-*-unicos*)
 
299
    # For the Cray T3E
 
300
    bytecccompopts="-DUMK";;
 
301
  gcc*,powerpc-*-aix*)
 
302
    # Avoid name-space pollution by requiring Unix98-conformant includes
 
303
    bytecccompopts="-fno-defer-pop $gcc_warnings -D_XOPEN_SOURCE=500";;
 
304
  *,powerpc-*-aix*)
 
305
    bytecccompopts="-D_XOPEN_SOURCE=500";;
 
306
  gcc*,*-*-cygwin*)
 
307
    bytecccompopts="-fno-defer-pop $gcc_warnings -U_WIN32"
 
308
    dllccompopts="-D_WIN32 -DCAML_DLL"
 
309
    if test $withsharedlibs = yes; then
 
310
      flexlink="flexlink -chain cygwin -merge-manifest"
 
311
      flexdir=`$flexlink -where | dos2unix`
 
312
      if test -z "$flexdir"; then
 
313
        echo "flexlink not found: native shared libraries won't be available"
 
314
        withsharedlibs=no
 
315
      else
 
316
        iflexdir="-I\"$flexdir\""
 
317
        mkexe="$flexlink -exe"
 
318
      fi
 
319
    fi
 
320
    exe=".exe"
 
321
    ostype="Cygwin";;
 
322
  gcc*,x86_64-*-linux*)
 
323
    bytecccompopts="-fno-defer-pop $gcc_warnings"
 
324
    # Tell gcc that we can use 32-bit code addresses for threaded code
 
325
    # unless we are compiled for a shared library (-fPIC option)
 
326
    echo "#ifndef __PIC__" >> m.h
 
327
    echo "#  define ARCH_CODE32" >> m.h
 
328
    echo "#endif" >> m.h;;
 
329
  gcc*)
 
330
    bytecccompopts="-fno-defer-pop $gcc_warnings";;
 
331
esac
 
332
 
 
333
# Configure compiler to use in further tests
 
334
 
 
335
cc="$bytecc -O $bytecclinkopts"
 
336
export cc cclibs verbose
 
337
 
 
338
# Check C compiler
 
339
 
 
340
sh ./runtest ansi.c
 
341
case $? in
 
342
  0) echo "The C compiler is ANSI-compliant.";;
 
343
  1) echo "The C compiler $cc is not ANSI-compliant."
 
344
     echo "You need an ANSI C compiler to build Objective Caml."
 
345
     exit 2;;
 
346
  *) echo "Unable to compile the test program."
 
347
     echo "Make sure the C compiler $cc is properly installed."
 
348
     exit 2;;
 
349
esac
 
350
 
 
351
# Check the sizes of data types
 
352
 
 
353
echo "Checking the sizes of integers and pointers..."
 
354
set `sh ./runtest sizes.c`
 
355
case "$2,$3" in
 
356
  4,4) echo "OK, this is a regular 32 bit architecture."
 
357
       echo "#undef ARCH_SIXTYFOUR" >> m.h
 
358
       arch64=false;;
 
359
  *,8) echo "Wow! A 64 bit architecture!"
 
360
       echo "#define ARCH_SIXTYFOUR" >> m.h
 
361
       arch64=true;;
 
362
  *,*) echo "This architecture seems to be neither 32 bits nor 64 bits."
 
363
       echo "Objective Caml won't run on this architecture."
 
364
       exit 2;;
 
365
    *) echo "Unable to compile the test program."
 
366
       echo "Make sure the C compiler $cc is properly installed."
 
367
       exit 2;;
 
368
esac
 
369
if test $1 != 4 && test $2 != 4 && test $4 != 4; then
 
370
  echo "Sorry, we can't find a 32-bit integer type"
 
371
  echo "(sizeof(short) = $4, sizeof(int) = $1, sizeof(long) = $2)"
 
372
  echo "Objective Caml won't run on this architecture."
 
373
  exit 2
 
374
fi
 
375
 
 
376
echo "#define SIZEOF_INT $1" >> m.h
 
377
echo "#define SIZEOF_LONG $2" >> m.h
 
378
echo "#define SIZEOF_PTR $3" >> m.h
 
379
echo "#define SIZEOF_SHORT $4" >> m.h
 
380
 
 
381
if test $2 = 8; then
 
382
     echo "#define ARCH_INT64_TYPE long" >> m.h
 
383
     echo "#define ARCH_UINT64_TYPE unsigned long" >> m.h
 
384
     echo '#define ARCH_INT64_PRINTF_FORMAT "l"' >> m.h
 
385
     int64_native=true
 
386
else
 
387
  sh ./runtest longlong.c
 
388
  case $? in
 
389
  0) echo "64-bit \"long long\" integer type found (printf with \"%ll\")."
 
390
     echo "#define ARCH_INT64_TYPE long long" >> m.h
 
391
     echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
 
392
     echo '#define ARCH_INT64_PRINTF_FORMAT "ll"' >> m.h
 
393
     int64_native=true;;
 
394
  1) echo "64-bit \"long long\" integer type found (printf with \"%q\")."
 
395
     echo "#define ARCH_INT64_TYPE long long" >> m.h
 
396
     echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
 
397
     echo '#define ARCH_INT64_PRINTF_FORMAT "q"' >> m.h
 
398
     int64_native=true;;
 
399
  2) echo "64-bit \"long long\" integer type found (but no printf)."
 
400
     echo "#define ARCH_INT64_TYPE long long" >> m.h
 
401
     echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
 
402
     echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
 
403
     int64_native=true;;
 
404
  *) echo "No suitable 64-bit integer type found, will use software emulation."
 
405
     echo "#undef ARCH_INT64_TYPE" >> m.h
 
406
     echo "#undef ARCH_UINT64_TYPE" >> m.h
 
407
     echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
 
408
     int64_native=false;;
 
409
  esac
 
410
fi
 
411
 
 
412
if test $3 = 8 && test $int64_native = false; then
 
413
  echo "This architecture has 64-bit pointers but no 64-bit integer type."
 
414
  echo "Objective Caml won't run on this architecture."
 
415
  exit 2
 
416
fi
 
417
 
 
418
# Determine endianness
 
419
 
 
420
sh ./runtest endian.c
 
421
case $? in
 
422
  0) echo "This is a big-endian architecture."
 
423
     echo "#define ARCH_BIG_ENDIAN" >> m.h;;
 
424
  1) echo "This is a little-endian architecture."
 
425
     echo "#undef ARCH_BIG_ENDIAN" >> m.h;;
 
426
  2) echo "This architecture seems to be neither big endian nor little endian."
 
427
     echo "Objective Caml won't run on this architecture."
 
428
     exit 2;;
 
429
  *) echo "Something went wrong during endianness determination."
 
430
     echo "You'll have to figure out endianness yourself"
 
431
     echo "(option ARCH_BIG_ENDIAN in m.h).";;
 
432
esac
 
433
 
 
434
# Determine alignment constraints
 
435
 
 
436
case "$host" in
 
437
  sparc*-*-*|hppa*-*-*|arm*-*-*)
 
438
    # On Sparc V9 with certain versions of gcc, determination of double
 
439
    # alignment is not reliable (PR#1521), hence force it.
 
440
    # Same goes for hppa.
 
441
    # PR#5088 suggests same problem on ARM.
 
442
    # But there's a knack (PR#2572):
 
443
    # if we're in 64-bit mode (sizeof(long) == 8),
 
444
    # we must not doubleword-align floats...
 
445
    if test $2 = 8; then
 
446
      echo "Doubles can be word-aligned."
 
447
      echo "#undef ARCH_ALIGN_DOUBLE" >> m.h
 
448
    else
 
449
      echo "Doubles must be doubleword-aligned."
 
450
      echo "#define ARCH_ALIGN_DOUBLE" >> m.h
 
451
    fi;;
 
452
  *)
 
453
    sh ./runtest dblalign.c
 
454
    case $? in
 
455
      0) echo "Doubles can be word-aligned."
 
456
         echo "#undef ARCH_ALIGN_DOUBLE" >> m.h;;
 
457
      1) echo "Doubles must be doubleword-aligned."
 
458
         echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
 
459
      *) echo "Something went wrong during alignment determination for doubles."
 
460
         echo "I'm going to assume this architecture has alignment constraints over doubles."
 
461
         echo "That's a safe bet: Objective Caml will work even if"
 
462
         echo "this architecture has actually no alignment constraints."
 
463
         echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
 
464
    esac;;
 
465
esac
 
466
 
 
467
if $int64_native; then
 
468
  case "$host" in
 
469
    # PR#5088: autodetection is unreliable on ARM
 
470
    sparc*-*-*|hppa*-*-*|arm*-*-*)
 
471
      if test $2 = 8; then
 
472
        echo "64-bit integers can be word-aligned."
 
473
        echo "#undef ARCH_ALIGN_INT64" >> m.h
 
474
      else
 
475
        echo "64-bit integers must be doubleword-aligned."
 
476
        echo "#define ARCH_ALIGN_INT64" >> m.h
 
477
      fi;;
 
478
    *)
 
479
      sh ./runtest int64align.c
 
480
      case $? in
 
481
        0) echo "64-bit integers can be word-aligned."
 
482
           echo "#undef ARCH_ALIGN_INT64" >> m.h;;
 
483
        1) echo "64-bit integers must be doubleword-aligned."
 
484
           echo "#define ARCH_ALIGN_INT64" >> m.h;;
 
485
        *) echo "Something went wrong during alignment determination for 64-bit integers."
 
486
           echo "I'm going to assume this architecture has alignment constraints."
 
487
           echo "That's a safe bet: Objective Caml will work even if"
 
488
           echo "this architecture has actually no alignment constraints."
 
489
           echo "#define ARCH_ALIGN_INT64" >> m.h;;
 
490
      esac
 
491
  esac
 
492
else
 
493
  echo "#undef ARCH_ALIGN_INT64" >> m.h
 
494
fi
 
495
 
 
496
# Check semantics of division and modulus
 
497
 
 
498
sh ./runtest divmod.c
 
499
case $? in
 
500
  0) echo "Native division and modulus have round-towards-zero semantics, will use them."
 
501
     echo "#undef NONSTANDARD_DIV_MOD" >> m.h;;
 
502
  1) echo "Native division and modulus do not have round-towards-zero semantics, will use software emulation."
 
503
     echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
 
504
  *) echo "Something went wrong while checking native division and modulus, please report it."
 
505
     echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
 
506
esac
 
507
 
 
508
# Shared library support
 
509
 
 
510
shared_libraries_supported=false
 
511
dl_needs_underscore=false
 
512
sharedcccompopts=''
 
513
mksharedlib=''
 
514
byteccrpath=''
 
515
mksharedlibrpath=''
 
516
natdynlinkopts=""
 
517
 
 
518
if test $withsharedlibs = "yes"; then
 
519
  case "$host" in
 
520
    *-*-cygwin*)
 
521
      mksharedlib="$flexlink"
 
522
      mkmaindll="$flexlink -maindll"
 
523
      shared_libraries_supported=true;;
 
524
    *-*-linux-gnu|*-*-linux|*-*-freebsd[3-9]*|*-*-openbsd*|*-*-netbsd*|*-*-gnu*)
 
525
      sharedcccompopts="-fPIC"
 
526
      mksharedlib="$bytecc -shared"
 
527
      bytecclinkopts="$bytecclinkopts -Wl,-E"
 
528
      byteccrpath="-Wl,-rpath,"
 
529
      mksharedlibrpath="-Wl,-rpath,"
 
530
      natdynlinkopts="-Wl,-E"
 
531
      shared_libraries_supported=true;;
 
532
    alpha*-*-osf*)
 
533
      case "$bytecc" in
 
534
        gcc*)
 
535
          sharedcccompopts="-fPIC"
 
536
          mksharedlib="$bytecc -shared"
 
537
          byteccrpath="-Wl,-rpath,"
 
538
          mksharedlibrpath="-Wl,-rpath,"
 
539
          shared_libraries_supported=true;;
 
540
        cc*)
 
541
          sharedcccompopts=""
 
542
          mksharedlib="ld -shared -expect_unresolved '*'"
 
543
          byteccrpath="-Wl,-rpath,"
 
544
          mksharedlibrpath="-rpath "
 
545
          shared_libraries_supported=true;;
 
546
      esac;;
 
547
    *-*-solaris2*)
 
548
      case "$bytecc" in
 
549
        gcc*)
 
550
          sharedcccompopts="-fPIC"
 
551
          if sh ./solaris-ld; then
 
552
            mksharedlib="$bytecc -shared"
 
553
            byteccrpath="-R"
 
554
            mksharedlibrpath="-R"
 
555
          else
 
556
            mksharedlib="$bytecc -shared"
 
557
            bytecclinkopts="$bytecclinkopts -Wl,-E"
 
558
            natdynlinkopts="-Wl,-E"
 
559
            byteccrpath="-Wl,-rpath,"
 
560
            mksharedlibrpath="-Wl,-rpath,"
 
561
          fi
 
562
          shared_libraries_supported=true;;
 
563
        *)
 
564
          sharedcccompopts="-KPIC"
 
565
          byteccrpath="-R"
 
566
          mksharedlibrpath="-R"
 
567
          mksharedlib="/usr/ccs/bin/ld -G"
 
568
          shared_libraries_supported=true;;
 
569
      esac;;
 
570
    mips*-*-irix[56]*)
 
571
      case "$bytecc" in
 
572
        cc*) sharedcccompopts="";;
 
573
        gcc*) sharedcccompopts="-fPIC";;
 
574
      esac
 
575
      mksharedlib="ld -shared -rdata_shared"
 
576
      byteccrpath="-Wl,-rpath,"
 
577
      mksharedlibrpath="-rpath "
 
578
      shared_libraries_supported=true;;
 
579
    i[3456]86-*-darwin10.*)
 
580
       mksharedlib="$bytecc -bundle -flat_namespace -undefined suppress"
 
581
       bytecccompopts="$dl_defs $bytecccompopts"
 
582
       dl_needs_underscore=false
 
583
       shared_libraries_supported=true
 
584
       ;;
 
585
    i[3456]86-*-darwin*)
 
586
      mksharedlib="$bytecc -bundle -flat_namespace -undefined suppress -read_only_relocs suppress"
 
587
      bytecccompopts="$dl_defs $bytecccompopts"
 
588
      dl_needs_underscore=false
 
589
      shared_libraries_supported=true;;
 
590
    *-apple-darwin*)
 
591
      mksharedlib="$bytecc -bundle -flat_namespace -undefined suppress"
 
592
      bytecccompopts="$dl_defs $bytecccompopts"
 
593
      dl_needs_underscore=false
 
594
      shared_libraries_supported=true;;
 
595
    m88k-*-openbsd*)
 
596
      shared_libraries_supported=false;;
 
597
    vax-*-openbsd*)
 
598
      shared_libraries_supported=false;;
 
599
    *-*-openbsd*)
 
600
      sharedcccompopts="-fPIC"
 
601
      mksharedlib="$bytecc -shared"
 
602
      bytecclinkopts="$bytecclinkopts -Wl,-E"
 
603
      natdynlinkopts="-Wl,-E"
 
604
      byteccrpath="-Wl,-rpath,"
 
605
      mksharedlibrpath="-Wl,-rpath,"
 
606
      shared_libraries_supported=true;;
 
607
  esac
 
608
fi
 
609
 
 
610
if test -z "$mkmaindll"; then
 
611
  mkmaindll=$mksharedlib
 
612
fi
 
613
 
 
614
# Configure native dynlink
 
615
 
 
616
natdynlink=false
 
617
 
 
618
if test $withsharedlibs = "yes"; then
 
619
  case "$host" in
 
620
    *-*-cygwin*)                  natdynlink=true;;
 
621
    i[3456]86-*-linux*)           natdynlink=true;;
 
622
    x86_64-*-linux*)              natdynlink=true;;
 
623
    i[3456]86-*-darwin10.*)
 
624
      if test $arch64 == true; then
 
625
        natdynlink=true
 
626
      fi;;
 
627
    i[3456]86-*-darwin[89]*)      natdynlink=true;;
 
628
    powerpc64-*-linux*)           natdynlink=true;;
 
629
    sparc-*-linux*)               natdynlink=true;;
 
630
    i686-*-kfreebsd*)             natdynlink=true;;
 
631
    x86_64-*-kfreebsd*)           natdynlink=true;;
 
632
    i386-*-gnu0.3)                natdynlink=true;;
 
633
  esac
 
634
fi
 
635
 
 
636
if test $natdynlink = "true"; then
 
637
  cmxs="cmxs"
 
638
else
 
639
  cmxs="cmxa"
 
640
fi
 
641
 
 
642
 
 
643
# Configure the native-code compiler
 
644
 
 
645
arch=none
 
646
model=default
 
647
system=unknown
 
648
 
 
649
case "$host" in
 
650
  alpha*-*-osf*)                arch=alpha; system=digital;;
 
651
  alpha*-*-linux*)              arch=alpha; system=linux;;
 
652
  alpha*-*-gnu*)                arch=alpha; system=gnu;;
 
653
  alpha*-*-freebsd*)            arch=alpha; system=freebsd;;
 
654
  alpha*-*-netbsd*)             arch=alpha; system=netbsd;;
 
655
  alpha*-*-openbsd*)            arch=alpha; system=openbsd;;
 
656
  sparc*-*-sunos4.*)            arch=sparc; system=sunos;;
 
657
  sparc*-*-solaris2.*)          arch=sparc; system=solaris;;
 
658
  sparc*-*-*bsd*)               arch=sparc; system=bsd;;
 
659
  sparc*-*-linux*)              arch=sparc; system=linux;;
 
660
  sparc*-*-gnu*)                arch=sparc; system=gnu;;
 
661
  i[3456]86-*-linux*)           arch=i386; system=linux_`sh ./runtest elf.c`;;
 
662
  i[3456]86-*-*bsd*)            arch=i386; system=bsd_`sh ./runtest elf.c`;;
 
663
  i[3456]86-*-nextstep*)        arch=i386; system=nextstep;;
 
664
  i[3456]86-*-solaris*)         if $arch64; then
 
665
                                  arch=amd64; system=solaris
 
666
                                else
 
667
                                  arch=i386; system=solaris
 
668
                                fi;;
 
669
  i[3456]86-*-beos*)            arch=i386; system=beos;;
 
670
  i[3456]86-*-cygwin*)          arch=i386; system=cygwin;;
 
671
  i[3456]86-*-darwin*)          if $arch64; then
 
672
                                  arch=amd64; system=macosx
 
673
                                else
 
674
                                  arch=i386; system=macosx
 
675
                                fi;;
 
676
  i[3456]86-*-gnu*)             arch=i386; system=gnu;;
 
677
  mips-*-irix6*)                arch=mips; system=irix;;
 
678
  hppa1.1-*-hpux*)              arch=hppa; system=hpux;;
 
679
  hppa2.0*-*-hpux*)             arch=hppa; system=hpux;;
 
680
  hppa*-*-linux*)               arch=hppa; system=linux;;
 
681
  hppa*-*-gnu*)                 arch=hppa; system=gnu;;
 
682
  powerpc*-*-linux*)            arch=power; model=ppc; system=elf;;
 
683
  powerpc-*-netbsd*)            arch=power; model=ppc; system=elf;;
 
684
  powerpc-*-rhapsody*)          arch=power; model=ppc; system=rhapsody;;
 
685
  powerpc-*-darwin*)            arch=power; system=rhapsody
 
686
                                if $arch64; then model=ppc64; else model=ppc; fi;;
 
687
  arm*-*-linux*)                arch=arm; system=linux;;
 
688
  arm*-*-gnu*)                  arch=arm; system=gnu;;
 
689
  ia64-*-linux*)                arch=ia64; system=linux;;
 
690
  ia64-*-gnu*)                  arch=ia64; system=gnu;;
 
691
  ia64-*-freebsd*)              arch=ia64; system=freebsd;;
 
692
  x86_64-*-linux*)              arch=amd64; system=linux;;
 
693
  x86_64-*-gnu*)                arch=amd64; system=gnu;;
 
694
  x86_64-*-freebsd*)            arch=amd64; system=freebsd;;
 
695
  x86_64-*-netbsd*)             arch=amd64; system=netbsd;;
 
696
  x86_64-*-openbsd*)            arch=amd64; system=openbsd;;
 
697
  x86_64-*-darwin9.5)           arch=amd64; system=macosx;;
 
698
esac
 
699
 
 
700
# Some platforms exist both in 32-bit and 64-bit variants, not distinguished
 
701
# by $host.  Turn off native code compilation on platforms where 64-bit mode
 
702
# is not supported.  (PR#4441)
 
703
 
 
704
if $arch64; then
 
705
  case "$arch,$model" in
 
706
    sparc,default|mips,default|hppa,default|power,ppc)
 
707
      arch=none; model=default; system=unknown;;
 
708
  esac
 
709
fi
 
710
 
 
711
if test -z "$ccoption"; then
 
712
  case "$arch,$system,$cc" in
 
713
    alpha,digital,gcc*) nativecc=cc;;
 
714
    mips,*,gcc*) nativecc=cc;;
 
715
    *) nativecc="$bytecc";;
 
716
  esac
 
717
else
 
718
  nativecc="$ccoption"
 
719
fi
 
720
 
 
721
nativecccompopts=''
 
722
nativecclinkopts=''
 
723
nativeccrpath="$byteccrpath"
 
724
 
 
725
case "$arch,$nativecc,$system,$host_type" in
 
726
  alpha,cc*,digital,*) nativecccompopts=-std1;;
 
727
  mips,cc*,irix,*)     nativecccompopts=-n32
 
728
                       nativecclinkopts="-n32 -Wl,-woff,84";;
 
729
  *,*,nextstep,*)      nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
 
730
                       nativecclinkopts="-posix";;
 
731
  *,*,rhapsody,*darwin[1-5].*)
 
732
                       nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";;
 
733
  *,*,rhapsody,*)      nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs"
 
734
                       if $arch64; then partialld="ld -r -arch ppc64"; fi;;
 
735
  alpha,gcc*,linux*,*) nativecclinkopts="-Wl,--no-relax";;
 
736
  *,gcc*,cygwin,*)     nativecccompopts="$gcc_warnings -U_WIN32";;
 
737
  amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
 
738
  amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
 
739
  *,gcc*,*,*)          nativecccompopts="$gcc_warnings";;
 
740
esac
 
741
 
 
742
asppprofflags='-DPROFILING'
 
743
 
 
744
case "$arch,$model,$system" in
 
745
  alpha,*,digital)  as='as -O2 -nocpp'
 
746
                    aspp='as -O2'
 
747
                    asppprofflags='-pg -DPROFILING';;
 
748
  alpha,*,*)        as='as'
 
749
                    aspp='gcc -c';;
 
750
  amd64,*,macosx)   as='as -arch x86_64'
 
751
                    aspp='gcc -arch x86_64 -c';;
 
752
  amd64,*,solaris)  as='as --64'
 
753
                    aspp='gcc -m64 -c';;
 
754
  amd64,*,*)        as='as'
 
755
                    aspp='gcc -c';;
 
756
  arm,*,*)          as='as';
 
757
                    aspp='gcc -c';;
 
758
  hppa,*,*)         as='as';
 
759
                    aspp='gcc -traditional -c';;
 
760
  i386,*,solaris)   as='as'
 
761
                    aspp='/usr/ccs/bin/as -P';;
 
762
  i386,*,*)         as='as'
 
763
                    aspp='gcc -c';;
 
764
  ia64,*,*)         as='as -xexplicit'
 
765
                    aspp='gcc -c -Wa,-xexplicit';;
 
766
  mips,*,irix)      as='as -n32 -O2 -nocpp -g0'
 
767
                    aspp='as -n32 -O2';;
 
768
  power,*,elf)      as='as -u -m ppc'
 
769
                    aspp='gcc -c';;
 
770
  power,*,bsd)      as='as'
 
771
                    aspp='gcc -c';;
 
772
  power,*,rhapsody) as="as -arch $model"
 
773
                    aspp="$bytecc -c";;
 
774
  sparc,*,solaris)  as='as'
 
775
                    case "$cc" in
 
776
                      gcc*) aspp='gcc -c';;
 
777
                         *) aspp='as -P';;
 
778
                    esac;;
 
779
  sparc,*,*)        as='as'
 
780
                    aspp='gcc -c';;
 
781
esac
 
782
 
 
783
if test -n "$asoption"; then as="$asoption"; fi
 
784
if test -n "$asppoption"; then aspp="$asppoption"; fi
 
785
 
 
786
cc_profile='-pg'
 
787
case "$arch,$model,$system" in
 
788
  alpha,*,digital) profiling='prof';;
 
789
  i386,*,linux_elf) profiling='prof';;
 
790
  i386,*,gnu) profiling='prof';;
 
791
  i386,*,bsd_elf) profiling='prof';;
 
792
  amd64,*,macosx) profiling='prof';;
 
793
  i386,*,macosx) profiling='prof';;
 
794
  sparc,*,solaris)
 
795
    profiling='prof'
 
796
    case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
 
797
  amd64,*,linux) profiling='prof';;
 
798
  amd64,*,gnu) profiling='prof';;
 
799
  *) profiling='noprof';;
 
800
esac
 
801
 
 
802
# Where is ranlib?
 
803
 
 
804
if sh ./searchpath ranlib; then
 
805
  echo "ranlib found"
 
806
  echo "RANLIB=ranlib" >> Makefile
 
807
  echo "RANLIBCMD=ranlib" >> Makefile
 
808
else
 
809
  echo "ranlib not used"
 
810
  echo "RANLIB=ar rs" >> Makefile
 
811
  echo "RANLIBCMD=" >> Makefile
 
812
fi
 
813
 
 
814
# Do #! scripts work?
 
815
 
 
816
if (SHELL=/bin/sh; export SHELL; (./sharpbang || ./sharpbang2) >/dev/null); then
 
817
  echo "#! appears to work in shell scripts"
 
818
  case "$host" in
 
819
    *-*-sunos*|*-*-unicos*)
 
820
      echo "We won't use it, though, because under SunOS and Unicos it breaks"
 
821
      echo "on pathnames longer than 30 characters"
 
822
      echo "SHARPBANGSCRIPTS=false" >> Makefile;;
 
823
    *-*-cygwin*)
 
824
      echo "We won't use it, though, because of conflicts with .exe extension"
 
825
      echo "under Cygwin"
 
826
      echo "SHARPBANGSCRIPTS=false" >> Makefile;;
 
827
    *)
 
828
      echo "SHARPBANGSCRIPTS=true" >> Makefile;;
 
829
  esac
 
830
else
 
831
  echo "No support for #! in shell scripts"
 
832
  echo "SHARPBANGSCRIPTS=false" >> Makefile
 
833
fi
 
834
 
 
835
# Write the OS type (Unix or Cygwin)
 
836
 
 
837
echo "#define OCAML_OS_TYPE \"$ostype\"" >> s.h
 
838
echo "#define OCAML_STDLIB_DIR \"$libdir\"" >> s.h
 
839
 
 
840
# Use 64-bit file offset if possible
 
841
 
 
842
bytecccompopts="$bytecccompopts -D_FILE_OFFSET_BITS=64"
 
843
nativecccompopts="$nativecccompopts -D_FILE_OFFSET_BITS=64"
 
844
 
 
845
# Check the semantics of signal handlers
 
846
 
 
847
if sh ./hasgot sigaction sigprocmask; then
 
848
  echo "POSIX signal handling found."
 
849
  echo "#define POSIX_SIGNALS" >> s.h
 
850
else
 
851
  if sh ./runtest signals.c; then
 
852
    echo "Signals have the BSD semantics."
 
853
    echo "#define BSD_SIGNALS" >> s.h
 
854
  else
 
855
    echo "Signals have the System V semantics."
 
856
  fi
 
857
  if sh ./hasgot sigsetmask; then
 
858
    echo "sigsetmask() found"
 
859
    echo "#define HAS_SIGSETMASK" >> s.h
 
860
  fi
 
861
fi
 
862
 
 
863
# For the Pervasives module
 
864
 
 
865
if sh ./trycompile expm1.c $mathlib; then
 
866
  echo "expm1() and log1p() found."
 
867
  echo "#define HAS_EXPM1_LOG1P" >> s.h
 
868
fi
 
869
 
 
870
# For the Sys module
 
871
 
 
872
if sh ./hasgot getrusage; then
 
873
  echo "getrusage() found."
 
874
  echo "#define HAS_GETRUSAGE" >> s.h
 
875
fi
 
876
 
 
877
if sh ./hasgot times; then
 
878
  echo "times() found."
 
879
  echo "#define HAS_TIMES" >> s.h
 
880
fi
 
881
 
 
882
# For the terminfo module
 
883
 
 
884
if test "$withcurses" = "yes"; then
 
885
  for libs in "" "-lcurses" "-ltermcap" "-lcurses -ltermcap" "-lncurses"; do
 
886
    if sh ./hasgot $libs tgetent tgetstr tgetnum tputs; then
 
887
      echo "termcap functions found (with libraries '$libs')"
 
888
      echo "#define HAS_TERMCAP" >> s.h
 
889
      curseslibs="${libs}"
 
890
      break
 
891
    fi
 
892
  done
 
893
fi
 
894
 
 
895
# Configuration for the libraries
 
896
 
 
897
otherlibraries="unix str num dynlink bigarray"
 
898
 
 
899
# For the Unix library
 
900
 
 
901
has_sockets=no
 
902
if sh ./hasgot socket socketpair bind listen accept connect; then
 
903
  echo "You have BSD sockets."
 
904
  echo "#define HAS_SOCKETS" >> s.h
 
905
  has_sockets=yes
 
906
elif sh ./hasgot -lnsl -lsocket socket socketpair bind listen accept connect; then
 
907
  echo "You have BSD sockets (with libraries '-lnsl -lsocket')"
 
908
  cclibs="$cclibs -lnsl -lsocket"
 
909
  echo "#define HAS_SOCKETS" >> s.h
 
910
  has_sockets=yes
 
911
fi
 
912
 
 
913
if sh ./hasgot -i sys/socket.h -t socklen_t; then
 
914
  echo "socklen_t is defined in <sys/socket.h>"
 
915
  echo "#define HAS_SOCKLEN_T" >> s.h
 
916
fi
 
917
 
 
918
if sh ./hasgot inet_aton; then
 
919
  echo "inet_aton() found."
 
920
  echo "#define HAS_INET_ATON" >> s.h
 
921
fi
 
922
 
 
923
if sh ./hasgot -i sys/types.h -i sys/socket.h -i netinet/in.h \
 
924
               -t 'struct sockaddr_in6' \
 
925
&& sh ./hasgot getaddrinfo getnameinfo inet_pton inet_ntop; then
 
926
  echo "IPv6 is supported."
 
927
  echo "#define HAS_IPV6" >> s.h
 
928
fi
 
929
 
 
930
if sh ./hasgot -i unistd.h; then
 
931
  echo "unistd.h found."
 
932
  echo "#define HAS_UNISTD" >> s.h
 
933
fi
 
934
 
 
935
if sh ./hasgot -i sys/types.h -t off_t; then
 
936
  echo "off_t is defined in <sys/types.h>"
 
937
  echo "#define HAS_OFF_T" >> s.h
 
938
fi
 
939
 
 
940
if sh ./hasgot -i sys/types.h -i dirent.h; then
 
941
  echo "dirent.h found."
 
942
  echo "#define HAS_DIRENT" >> s.h
 
943
fi
 
944
 
 
945
if sh ./hasgot rewinddir; then
 
946
  echo "rewinddir() found."
 
947
  echo "#define HAS_REWINDDIR" >> s.h
 
948
fi
 
949
 
 
950
if sh ./hasgot lockf; then
 
951
  echo "lockf() found."
 
952
  echo "#define HAS_LOCKF" >> s.h
 
953
fi
 
954
 
 
955
if sh ./hasgot mkfifo; then
 
956
  echo "mkfifo() found."
 
957
  echo "#define HAS_MKFIFO" >> s.h
 
958
fi
 
959
 
 
960
if sh ./hasgot getcwd; then
 
961
  echo "getcwd() found."
 
962
  echo "#define HAS_GETCWD" >> s.h
 
963
fi
 
964
 
 
965
if sh ./hasgot getwd; then
 
966
  echo "getwd() found."
 
967
  echo "#define HAS_GETWD" >> s.h
 
968
fi
 
969
 
 
970
if sh ./hasgot getpriority setpriority; then
 
971
  echo "getpriority() found."
 
972
  echo "#define HAS_GETPRIORITY" >> s.h
 
973
fi
 
974
 
 
975
if sh ./hasgot -i sys/types.h -i utime.h && sh ./hasgot utime; then
 
976
  echo "utime() found."
 
977
  echo "#define HAS_UTIME" >> s.h
 
978
fi
 
979
 
 
980
if sh ./hasgot utimes; then
 
981
  echo "utimes() found."
 
982
  echo "#define HAS_UTIMES" >> s.h
 
983
fi
 
984
 
 
985
if sh ./hasgot dup2; then
 
986
  echo "dup2() found."
 
987
  echo "#define HAS_DUP2" >> s.h
 
988
fi
 
989
 
 
990
if sh ./hasgot fchmod fchown; then
 
991
  echo "fchmod() found."
 
992
  echo "#define HAS_FCHMOD" >> s.h
 
993
fi
 
994
 
 
995
if sh ./hasgot truncate ftruncate; then
 
996
  echo "truncate() found."
 
997
  echo "#define HAS_TRUNCATE" >> s.h
 
998
fi
 
999
 
 
1000
select_include=''
 
1001
if sh ./hasgot -i sys/types.h -i sys/select.h; then
 
1002
  echo "sys/select.h found."
 
1003
  echo "#define HAS_SYS_SELECT_H" >> s.h
 
1004
  select_include='-i sys/select.h'
 
1005
fi
 
1006
 
 
1007
has_select=no
 
1008
if sh ./hasgot select && \
 
1009
   sh ./hasgot -i sys/types.h $select_include -t fd_set ; then
 
1010
  echo "select() found."
 
1011
  echo "#define HAS_SELECT" >> s.h
 
1012
  has_select=yes
 
1013
fi
 
1014
 
 
1015
if sh ./hasgot symlink readlink lstat;  then
 
1016
  echo "symlink() found."
 
1017
  echo "#define HAS_SYMLINK" >> s.h
 
1018
fi
 
1019
 
 
1020
has_wait=no
 
1021
if sh ./hasgot waitpid;  then
 
1022
  echo "waitpid() found."
 
1023
  echo "#define HAS_WAITPID" >> s.h
 
1024
  has_wait=yes
 
1025
fi
 
1026
 
 
1027
if sh ./hasgot wait4;  then
 
1028
  echo "wait4() found."
 
1029
  echo "#define HAS_WAIT4" >> s.h
 
1030
  has_wait=yes
 
1031
fi
 
1032
 
 
1033
if sh ./hasgot -i limits.h && sh ./runtest getgroups.c; then
 
1034
  echo "getgroups() found."
 
1035
  echo "#define HAS_GETGROUPS" >> s.h
 
1036
fi
 
1037
 
 
1038
if sh ./hasgot -i limits.h -i grp.h && sh ./runtest setgroups.c; then
 
1039
  echo "setgroups() found."
 
1040
  echo "#define HAS_SETGROUPS" >> s.h
 
1041
fi
 
1042
 
 
1043
if sh ./hasgot -i limits.h -i grp.h && sh ./runtest initgroups.c; then
 
1044
  echo "initgroups() found."
 
1045
  echo "#define HAS_INITGROUPS" >> s.h
 
1046
fi
 
1047
 
 
1048
if sh ./hasgot -i termios.h &&
 
1049
   sh ./hasgot tcgetattr tcsetattr tcsendbreak tcflush tcflow; then
 
1050
  echo "POSIX termios found."
 
1051
  echo "#define HAS_TERMIOS" >> s.h
 
1052
fi
 
1053
 
 
1054
# Async I/O under OSF1 3.x are so buggy that the test program hangs...
 
1055
testasyncio=true
 
1056
if test -f /usr/bin/uname; then
 
1057
  case "`/usr/bin/uname -s -r`" in
 
1058
    "OSF1 V3."*) testasyncio=false;;
 
1059
  esac
 
1060
fi
 
1061
if $testasyncio && sh ./runtest async_io.c; then
 
1062
  echo "Asynchronous I/O are supported."
 
1063
  echo "#define HAS_ASYNC_IO" >> s.h
 
1064
fi
 
1065
 
 
1066
has_setitimer=no
 
1067
if sh ./hasgot setitimer; then
 
1068
  echo "setitimer() found."
 
1069
  echo "#define HAS_SETITIMER" >> s.h
 
1070
  has_setitimer="yes"
 
1071
fi
 
1072
 
 
1073
if sh ./hasgot gethostname; then
 
1074
  echo "gethostname() found."
 
1075
  echo "#define HAS_GETHOSTNAME" >> s.h
 
1076
fi
 
1077
 
 
1078
if sh ./hasgot -i sys/utsname.h && sh ./hasgot uname; then
 
1079
  echo "uname() found."
 
1080
  echo "#define HAS_UNAME" >> s.h
 
1081
fi
 
1082
 
 
1083
has_gettimeofday=no
 
1084
if sh ./hasgot gettimeofday; then
 
1085
  echo "gettimeofday() found."
 
1086
  echo "#define HAS_GETTIMEOFDAY" >> s.h
 
1087
  has_gettimeofday="yes"
 
1088
fi
 
1089
 
 
1090
if sh ./hasgot mktime; then
 
1091
  echo "mktime() found."
 
1092
  echo "#define HAS_MKTIME" >> s.h
 
1093
fi
 
1094
 
 
1095
case "$host" in
 
1096
  *-*-cygwin*) ;;  # setsid emulation under Cygwin breaks the debugger
 
1097
  *) if sh ./hasgot setsid; then
 
1098
       echo "setsid() found."
 
1099
       echo "#define HAS_SETSID" >> s.h
 
1100
     fi;;
 
1101
esac
 
1102
 
 
1103
if sh ./hasgot putenv; then
 
1104
  echo "putenv() found."
 
1105
  echo "#define HAS_PUTENV" >> s.h
 
1106
fi
 
1107
 
 
1108
if sh ./hasgot -i locale.h && sh ./hasgot setlocale; then
 
1109
  echo "setlocale() and <locale.h> found."
 
1110
  echo "#define HAS_LOCALE" >> s.h
 
1111
fi
 
1112
 
 
1113
 
 
1114
if sh ./hasgot $dllib dlopen; then
 
1115
  echo "dlopen() found."
 
1116
elif sh ./hasgot $dllib -ldl dlopen; then
 
1117
  echo "dlopen() found in -ldl."
 
1118
  dllib="$dllib -ldl"
 
1119
else
 
1120
  shared_libraries_supported=false
 
1121
fi
 
1122
 
 
1123
if $shared_libraries_supported; then
 
1124
  echo "Dynamic loading of shared libraries is supported."
 
1125
  echo "#define SUPPORT_DYNAMIC_LINKING" >> s.h
 
1126
  if $dl_needs_underscore; then
 
1127
    echo '#define DL_NEEDS_UNDERSCORE' >>s.h
 
1128
  fi
 
1129
fi
 
1130
 
 
1131
if sh ./hasgot -i sys/types.h -i sys/mman.h && sh ./hasgot mmap munmap; then
 
1132
  echo "mmap() found."
 
1133
  echo "#define HAS_MMAP" >> s.h
 
1134
fi
 
1135
 
 
1136
nargs=none
 
1137
for i in 5 6; do
 
1138
  if sh ./trycompile -DNUM_ARGS=${i} gethostbyname.c; then nargs=$i; break; fi
 
1139
done
 
1140
if test $nargs != "none"; then
 
1141
  echo "gethostbyname_r() found (with ${nargs} arguments)."
 
1142
  echo "#define HAS_GETHOSTBYNAME_R $nargs" >> s.h
 
1143
fi
 
1144
 
 
1145
nargs=none
 
1146
for i in 7 8; do
 
1147
  if sh ./trycompile -DNUM_ARGS=${i} gethostbyaddr.c; then nargs=$i; break; fi
 
1148
done
 
1149
if test $nargs != "none"; then
 
1150
  echo "gethostbyaddr_r() found (with ${nargs} arguments)."
 
1151
  echo "#define HAS_GETHOSTBYADDR_R $nargs" >> s.h
 
1152
fi
 
1153
 
 
1154
# Determine if the debugger is supported
 
1155
 
 
1156
if test "$has_sockets" = "yes"; then
 
1157
  echo "Replay debugger supported."
 
1158
  debugger="ocamldebugger"
 
1159
else
 
1160
  echo "No replay debugger (missing system calls)"
 
1161
  debugger=""
 
1162
fi
 
1163
 
 
1164
 
 
1165
# Determine if system stack overflows can be detected
 
1166
 
 
1167
case "$arch,$system" in
 
1168
  i386,linux_elf|amd64,linux|power,rhapsody|amd64,macosx|i386,macosx|amd64,macosx)
 
1169
    echo "System stack overflow can be detected."
 
1170
    echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h;;
 
1171
  *)
 
1172
    echo "Cannot detect system stack overflow.";;
 
1173
esac
 
1174
 
 
1175
# Determine the target architecture for the "num" library
 
1176
 
 
1177
case "$arch" in
 
1178
  alpha)    bng_arch=alpha; bng_asm_level=1;;
 
1179
  i386)     bng_arch=ia32
 
1180
            if sh ./trycompile ia32sse2.c
 
1181
            then bng_asm_level=2
 
1182
            else bng_asm_level=1
 
1183
            fi;;
 
1184
  mips)     bng_arch=mips; bng_asm_level=1;;
 
1185
  power)    bng_arch=ppc; bng_asm_level=1;;
 
1186
  amd64)    bng_arch=amd64; bng_asm_level=1;;
 
1187
  *)        bng_arch=generic; bng_asm_level=0;;
 
1188
esac
 
1189
 
 
1190
echo "BNG_ARCH=$bng_arch" >> Makefile
 
1191
echo "BNG_ASM_LEVEL=$bng_asm_level" >> Makefile
 
1192
 
 
1193
# Determine if the POSIX threads library is supported
 
1194
 
 
1195
systhread_support=false
 
1196
 
 
1197
if test "$pthread_wanted" = "yes"; then
 
1198
  case "$host" in
 
1199
    *-*-solaris*)  pthread_link="-lpthread -lposix4"
 
1200
                   pthread_caml_link="-cclib -lpthread -cclib -lposix4";;
 
1201
    *-*-freebsd*)  pthread_link="-pthread"
 
1202
                   pthread_caml_link="-cclib -pthread";;
 
1203
    *-*-openbsd*)  pthread_link="-pthread"
 
1204
                   pthread_caml_link="-cclib -pthread";;
 
1205
    *)             pthread_link="-lpthread"
 
1206
                   pthread_caml_link="-cclib -lpthread";;
 
1207
  esac
 
1208
  if ./hasgot -i pthread.h $pthread_link pthread_self; then
 
1209
    echo "POSIX threads library supported."
 
1210
    systhread_support=true
 
1211
    otherlibraries="$otherlibraries systhreads"
 
1212
    bytecccompopts="$bytecccompopts -D_REENTRANT"
 
1213
    nativecccompopts="$nativecccompopts -D_REENTRANT"
 
1214
    case "$host" in
 
1215
      *-*-freebsd*)
 
1216
          bytecccompopts="$bytecccompopts -D_THREAD_SAFE"
 
1217
          nativecccompopts="$nativecccompopts -D_THREAD_SAFE";;
 
1218
      *-*-openbsd*)
 
1219
          bytecccompopts="$bytecccompopts -pthread"
 
1220
          asppflags="$asppflags -pthread"
 
1221
          nativecccompopts="$nativecccompopts -pthread";;
 
1222
    esac
 
1223
    echo "Options for linking with POSIX threads: $pthread_link"
 
1224
    if sh ./hasgot $pthread_link sigwait; then
 
1225
      echo "sigwait() found"
 
1226
      echo "#define HAS_SIGWAIT" >> s.h
 
1227
    fi
 
1228
  else
 
1229
    echo "POSIX threads not found."
 
1230
    pthread_link=""
 
1231
  fi
 
1232
else
 
1233
  pthread_link=""
 
1234
fi
 
1235
echo "PTHREAD_LINK=$pthread_caml_link" >> Makefile
 
1236
 
 
1237
# Determine if the bytecode thread library is supported
 
1238
 
 
1239
if test "$has_select" = "yes" \
 
1240
&& test "$has_setitimer" = "yes" \
 
1241
&& test "$has_gettimeofday" = "yes" \
 
1242
&& test "$has_wait" = "yes"; then
 
1243
  echo "Bytecode threads library supported."
 
1244
  otherlibraries="$otherlibraries threads"
 
1245
else
 
1246
  echo "Bytecode threads library not supported (missing system calls)"
 
1247
fi
 
1248
 
 
1249
# Determine the location of X include files and libraries
 
1250
 
 
1251
x11_include="not found"
 
1252
x11_link="not found"
 
1253
 
 
1254
for dir in \
 
1255
    $x11_include_dir          \
 
1256
                              \
 
1257
    /usr/X11R7/include        \
 
1258
    /usr/include/X11R7        \
 
1259
    /usr/local/X11R7/include  \
 
1260
    /usr/local/include/X11R7  \
 
1261
    /opt/X11R7/include        \
 
1262
                              \
 
1263
    /usr/X11R6/include        \
 
1264
    /usr/include/X11R6        \
 
1265
    /usr/local/X11R6/include  \
 
1266
    /usr/local/include/X11R6  \
 
1267
    /opt/X11R6/include        \
 
1268
                              \
 
1269
    /usr/X11/include          \
 
1270
    /usr/include/X11          \
 
1271
    /usr/local/X11/include    \
 
1272
    /usr/local/include/X11    \
 
1273
    /opt/X11/include          \
 
1274
                              \
 
1275
    /usr/X11R5/include        \
 
1276
    /usr/include/X11R5        \
 
1277
    /usr/local/X11R5/include  \
 
1278
    /usr/local/include/X11R5  \
 
1279
    /usr/local/x11r5/include  \
 
1280
    /opt/X11R5/include        \
 
1281
                              \
 
1282
    /usr/X11R4/include        \
 
1283
    /usr/include/X11R4        \
 
1284
    /usr/local/X11R4/include  \
 
1285
    /usr/local/include/X11R4  \
 
1286
                              \
 
1287
    /usr/X386/include         \
 
1288
    /usr/x386/include         \
 
1289
    /usr/XFree86/include/X11  \
 
1290
                              \
 
1291
    /usr/include              \
 
1292
    /usr/local/include        \
 
1293
    /usr/unsupported/include  \
 
1294
    /usr/athena/include       \
 
1295
    /usr/lpp/Xamples/include  \
 
1296
                              \
 
1297
    /usr/openwin/include      \
 
1298
    /usr/openwin/share/include \
 
1299
    ; \
 
1300
do
 
1301
  if test -f $dir/X11/X.h; then
 
1302
    x11_include=$dir
 
1303
    break
 
1304
  fi
 
1305
done
 
1306
 
 
1307
if test "$x11_include" = "not found"; then
 
1308
  x11_try_lib_dir=''
 
1309
else
 
1310
  x11_try_lib_dir=`echo $x11_include | sed -e 's|include|lib|'`
 
1311
fi
 
1312
 
 
1313
for dir in \
 
1314
    $x11_lib_dir          \
 
1315
    $x11_try_lib_dir      \
 
1316
                          \
 
1317
    /usr/X11R6/lib64      \
 
1318
    /usr/X11R6/lib        \
 
1319
    /usr/lib/X11R6        \
 
1320
    /usr/local/X11R6/lib  \
 
1321
    /usr/local/lib/X11R6  \
 
1322
    /opt/X11R6/lib        \
 
1323
                          \
 
1324
    /usr/X11/lib          \
 
1325
    /usr/lib/X11          \
 
1326
    /usr/local/X11/lib    \
 
1327
    /usr/local/lib/X11    \
 
1328
    /opt/X11/lib          \
 
1329
                          \
 
1330
    /usr/X11R5/lib        \
 
1331
    /usr/lib/X11R5        \
 
1332
    /usr/local/X11R5/lib  \
 
1333
    /usr/local/lib/X11R5  \
 
1334
    /usr/local/x11r5/lib  \
 
1335
    /opt/X11R5/lib        \
 
1336
                          \
 
1337
    /usr/X11R4/lib        \
 
1338
    /usr/lib/X11R4        \
 
1339
    /usr/local/X11R4/lib  \
 
1340
    /usr/local/lib/X11R4  \
 
1341
                          \
 
1342
    /usr/X386/lib         \
 
1343
    /usr/x386/lib         \
 
1344
    /usr/XFree86/lib/X11  \
 
1345
                          \
 
1346
    /usr/lib64            \
 
1347
    /usr/lib              \
 
1348
    /usr/local/lib        \
 
1349
    /usr/unsupported/lib  \
 
1350
    /usr/athena/lib       \
 
1351
    /usr/lpp/Xamples/lib  \
 
1352
    /lib/usr/lib/X11      \
 
1353
                          \
 
1354
    /usr/openwin/lib      \
 
1355
    /usr/openwin/share/lib \
 
1356
    ; \
 
1357
do
 
1358
  if test -f $dir/libX11.a || \
 
1359
     test -f $dir/libX11.so || \
 
1360
     test -f $dir/libX11.dll.a || \
 
1361
     test -f $dir/libX11.dylib || \
 
1362
     test -f $dir/libX11.sa; then
 
1363
    if test $dir = /usr/lib; then
 
1364
      x11_link="-lX11"
 
1365
    else
 
1366
      x11_libs="-L$dir"
 
1367
      case "$host" in
 
1368
        *-*-*bsd*) x11_link="-R$dir -L$dir -lX11";;
 
1369
        *) x11_link="-L$dir -lX11";;
 
1370
      esac
 
1371
    fi
 
1372
    break
 
1373
  fi
 
1374
done
 
1375
 
 
1376
 
 
1377
if test "$x11_include" = "not found" || test "$x11_link" = "not found"
 
1378
then
 
1379
  echo "X11 not found, the \"graph\" library will not be supported."
 
1380
  x11_include=""
 
1381
else
 
1382
  echo "Location of X11 include files: $x11_include/X11"
 
1383
  echo "Options for linking with X11: $x11_link"
 
1384
  otherlibraries="$otherlibraries graph"
 
1385
  if test "$x11_include" = "/usr/include"; then
 
1386
    x11_include=""
 
1387
  else
 
1388
    x11_include="-I$x11_include"
 
1389
  fi
 
1390
fi
 
1391
echo "X11_INCLUDES=$x11_include" >> Makefile
 
1392
echo "X11_LINK=$x11_link" >> Makefile
 
1393
 
 
1394
# See if we can compile the dbm library
 
1395
 
 
1396
dbm_include="not found"
 
1397
dbm_link="not found"
 
1398
use_gdbm_ndbm=no
 
1399
 
 
1400
for dir in /usr/include /usr/include/db1 /usr/include/gdbm; do
 
1401
  if test -f $dir/ndbm.h; then
 
1402
    dbm_include=$dir
 
1403
    if sh ./hasgot dbm_open; then
 
1404
      dbm_link=""
 
1405
    elif sh ./hasgot -lndbm dbm_open; then
 
1406
      dbm_link="-lndbm"
 
1407
    elif sh ./hasgot -ldb1 dbm_open; then
 
1408
      dbm_link="-ldb1"
 
1409
    elif sh ./hasgot -lgdbm dbm_open; then
 
1410
      dbm_link="-lgdbm"
 
1411
    elif sh ./hasgot -lgdbm_compat -lgdbm dbm_open; then
 
1412
      dbm_link="-lgdbm_compat -lgdbm"
 
1413
    fi
 
1414
    break
 
1415
  fi
 
1416
  if test -f $dir/gdbm-ndbm.h; then
 
1417
    dbm_include=$dir
 
1418
    use_gdbm_ndbm=yes
 
1419
    if sh ./hasgot -lgdbm_compat -lgdbm dbm_open; then
 
1420
      dbm_link="-lgdbm_compat -lgdbm"
 
1421
    fi
 
1422
    break
 
1423
  fi
 
1424
done
 
1425
if test "$dbm_include" = "not found" || test "$dbm_link" = "not found"; then
 
1426
  echo "NDBM not found, the \"dbm\" library will not be supported."
 
1427
else
 
1428
  echo "NDBM found (in $dbm_include)"
 
1429
  if test "$dbm_include" = "/usr/include"; then
 
1430
    dbm_include=""
 
1431
  else
 
1432
    dbm_include="-I$dbm_include"
 
1433
  fi
 
1434
  if test "$use_gdbm_ndbm" = "yes"; then
 
1435
    echo "#define DBM_USES_GDBM_NDBM" >> s.h
 
1436
  fi
 
1437
  otherlibraries="$otherlibraries dbm"
 
1438
fi
 
1439
echo "DBM_INCLUDES=$dbm_include" >> Makefile
 
1440
echo "DBM_LINK=$dbm_link" >> Makefile
 
1441
 
 
1442
# Look for tcl/tk
 
1443
 
 
1444
echo "Configuring LablTk..."
 
1445
 
 
1446
if test $tk_wanted = no; then
 
1447
  has_tk=false
 
1448
elif test $tk_x11 = no; then
 
1449
  has_tk=true
 
1450
elif test "$x11_include" = "not found" || test "$x11_link" = "not found"; then
 
1451
  echo "X11 not found."
 
1452
  has_tk=false
 
1453
else
 
1454
  tk_x11_include="$x11_include"
 
1455
  tk_x11_libs="$x11_libs -lX11"
 
1456
  has_tk=true
 
1457
fi
 
1458
 
 
1459
if test $has_tk = true; then
 
1460
  tcl_version=''
 
1461
  tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
 
1462
  for tk_incs in \
 
1463
    "-I/usr/local/include" \
 
1464
    "-I/usr/include" \
 
1465
    "-I/usr/local/include/tcl8.5 -I/usr/local/include/tk8.5" \
 
1466
    "-I/usr/include/tcl8.5 -I/usr/include/tk8.5" \
 
1467
    "-I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4" \
 
1468
    "-I/usr/include/tcl8.4 -I/usr/include/tk8.4" \
 
1469
    "-I/usr/local/include/tcl8.3 -I/usr/local/include/tk8.3" \
 
1470
    "-I/usr/include/tcl8.3 -I/usr/include/tk8.3" \
 
1471
    "-I/usr/local/include/tcl8.2 -I/usr/local/include/tk8.2" \
 
1472
    "-I/usr/include/tcl8.2 -I/usr/include/tk8.2" \
 
1473
    "-I/sw/include" \
 
1474
    "-I/usr/pkg/include"
 
1475
  do if test -z "$tcl_version"; then
 
1476
    tk_defs="$tk_incs"
 
1477
    tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
 
1478
  fi; done
 
1479
  if test -n "$tcl_version" && test "x$tcl_version" != "xnone"; then
 
1480
    echo "tcl.h and tk.h version $tcl_version found with \"$tk_defs\"."
 
1481
    case $tcl_version in
 
1482
    7.5) tclmaj=7 tclmin=5 tkmaj=4 tkmin=1 ;;
 
1483
    7.6) tclmaj=7 tclmin=6 tkmaj=4 tkmin=2 ;;
 
1484
    8.0) tclmaj=8 tclmin=0 tkmaj=8 tkmin=0 ;;
 
1485
    8.1) tclmaj=8 tclmin=1 tkmaj=8 tkmin=1 ;;
 
1486
    8.2) tclmaj=8 tclmin=2 tkmaj=8 tkmin=2 ;;
 
1487
    8.3) tclmaj=8 tclmin=3 tkmaj=8 tkmin=3 ;;
 
1488
    8.4) tclmaj=8 tclmin=4 tkmaj=8 tkmin=4 ;;
 
1489
    8.5) tclmaj=8 tclmin=5 tkmaj=8 tkmin=5 ;;
 
1490
    *) echo "This version is not known."; has_tk=false ;;
 
1491
    esac
 
1492
  else
 
1493
    echo "tcl.h and/or tk.h not found."
 
1494
    has_tk=false
 
1495
  fi
 
1496
fi
 
1497
 
 
1498
tkauxlibs="$mathlib $dllib"
 
1499
tcllib=''
 
1500
tklib=''
 
1501
if test $has_tk = true; then
 
1502
  if test -n "$tk_libs" && \
 
1503
     sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tcl_DoOneEvent
 
1504
  then tk_libs="$tk_libs $dllib"
 
1505
  elif sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent
 
1506
  then
 
1507
    tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
 
1508
  elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent
 
1509
  then
 
1510
    tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib"
 
1511
  elif test -z "$tk_libs" && tk_libs=-L/usr/local/lib && \
 
1512
    sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent
 
1513
  then
 
1514
    tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
 
1515
  elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent
 
1516
  then
 
1517
    tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib"
 
1518
  elif sh ./hasgot -L/sw/lib $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs \
 
1519
                   Tcl_DoOneEvent
 
1520
  then tk_libs="-L/sw/lib -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
 
1521
  elif sh ./hasgot -L/usr/pkg/lib $tk_libs $tk_x11_libs \
 
1522
        -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin -lpthread $tkauxlibs \
 
1523
                   Tcl_DoOneEvent
 
1524
  then
 
1525
    case "$host" in
 
1526
      *-*-*bsd*) tk_libs="-R/usr/pkg/lib -L/usr/pkg/lib $tk_libs $tk_x11_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin -lpthread $tkauxlibs";;
 
1527
      *) tk_libs="-L/usr/pkg/lib $tk_libs $tk_x11_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin -lpthread $tkauxlibs";;
 
1528
    esac
 
1529
  else
 
1530
    echo "Tcl library not found."
 
1531
    has_tk=false
 
1532
  fi
 
1533
fi
 
1534
 
 
1535
if test $has_tk = true; then
 
1536
  if sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then
 
1537
    echo "Tcl/Tk libraries found."
 
1538
  elif sh ./hasgot -L/sw/lib $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then
 
1539
    case "$host" in
 
1540
      *-*-*bsd*) tk_libs="-R/sw/lib -L/sw/lib $tk_libs";;
 
1541
      *) tk_libs="-L/sw/lib $tk_libs";;
 
1542
    esac
 
1543
    echo "Tcl/Tk libraries found."
 
1544
  elif sh ./hasgot -L/usr/pkg/lib $tk_libs $tk_x11_libs $tkauxlibs \
 
1545
                   Tk_SetGrid; then
 
1546
    case "$host" in
 
1547
      *-*-*bsd*) tk_libs="-R/usr/pkg/lib -L/usr/pkg/lib $tk_libs";;
 
1548
      *) tk_libs="-L/usr/pkg/lib $tk_libs";;
 
1549
    esac
 
1550
    echo "Tcl/Tk libraries found."
 
1551
  else
 
1552
    echo "Tcl library found."
 
1553
    echo "Tk library not found."
 
1554
    has_tk=false
 
1555
  fi
 
1556
fi
 
1557
 
 
1558
if test $has_tk = true; then
 
1559
  if test $tk_x11 = yes; then
 
1560
    echo "TK_DEFS=$tk_defs "'$(X11_INCLUDES)' >> Makefile
 
1561
    echo "TK_LINK=$tk_libs "'$(X11_LINK)' >> Makefile
 
1562
  else
 
1563
    echo "TK_DEFS=$tk_defs" >> Makefile
 
1564
    echo "TK_LINK=$tk_libs" >> Makefile
 
1565
  fi
 
1566
  otherlibraries="$otherlibraries labltk"
 
1567
else
 
1568
  echo "Configuration failed, LablTk will not be built."
 
1569
  echo "TK_DEFS=" >> Makefile
 
1570
  echo "TK_LINK=" >> Makefile
 
1571
fi
 
1572
 
 
1573
# Look for BFD library
 
1574
 
 
1575
if ./hasgot -i bfd.h && \
 
1576
   ./hasgot -lbfd -ldl -liberty -lz bfd_openr; then
 
1577
  echo "BFD library found."
 
1578
  echo "#define HAS_LIBBFD" >> s.h
 
1579
  echo "LIBBFD_LINK=-lbfd -ldl -liberty -lz" >> Makefile
 
1580
else
 
1581
  echo "BFD library not found, 'objinfo' will be unable to display info on .cmxs files"
 
1582
  echo "LIBBFD_LINK=" >> Makefile
 
1583
fi
 
1584
 
 
1585
# Final twiddling of compiler options to work around known bugs
 
1586
 
 
1587
nativeccprofopts="$nativecccompopts"
 
1588
case "$buggycc" in
 
1589
  gcc.2.96)
 
1590
    bytecccompopts="$bytecccompopts -fomit-frame-pointer"
 
1591
    nativecccompopts="$nativecccompopts -fomit-frame-pointer";;
 
1592
esac
 
1593
 
 
1594
# Finish generated files
 
1595
 
 
1596
cclibs="$cclibs $mathlib"
 
1597
 
 
1598
echo "BYTECC=$bytecc" >> Makefile
 
1599
echo "BYTECCCOMPOPTS=$bytecccompopts" >> Makefile
 
1600
echo "BYTECCLINKOPTS=$bytecclinkopts" >> Makefile
 
1601
echo "BYTECCLIBS=$cclibs $dllib $curseslibs $pthread_link" >> Makefile
 
1602
echo "BYTECCRPATH=$byteccrpath" >> Makefile
 
1603
echo "EXE=$exe" >> Makefile
 
1604
echo "SUPPORTS_SHARED_LIBRARIES=$shared_libraries_supported" >> Makefile
 
1605
echo "SHAREDCCCOMPOPTS=$sharedcccompopts" >> Makefile
 
1606
echo "MKSHAREDLIBRPATH=$mksharedlibrpath" >> Makefile
 
1607
echo "NATDYNLINKOPTS=$natdynlinkopts" >> Makefile
 
1608
cat >> Makefile <<EOF
 
1609
SYSLIB=-l\$(1)
 
1610
#ml let syslib x = "-l"^x;;
 
1611
 
 
1612
### How to build a static library
 
1613
MKLIB=ar rc \$(1) \$(2); ranlib \$(1)
 
1614
#ml let mklib out files opts = Printf.sprintf "ar rc %s %s %s; ranlib %s" out opts files out;;
 
1615
EOF
 
1616
echo "ARCH=$arch" >> Makefile
 
1617
echo "MODEL=$model" >> Makefile
 
1618
echo "SYSTEM=$system" >> Makefile
 
1619
echo "NATIVECC=$nativecc" >> Makefile
 
1620
echo "NATIVECCCOMPOPTS=$nativecccompopts" >> Makefile
 
1621
echo "NATIVECCPROFOPTS=$nativeccprofopts" >> Makefile
 
1622
echo "NATIVECCLINKOPTS=$nativecclinkopts" >> Makefile
 
1623
echo "NATIVECCRPATH=$nativeccrpath" >> Makefile
 
1624
echo "NATIVECCLIBS=$cclibs $dllib" >> Makefile
 
1625
echo "ASM=$as" >> Makefile
 
1626
echo "ASPP=$aspp" >> Makefile
 
1627
echo "ASPPPROFFLAGS=$asppprofflags" >> Makefile
 
1628
echo "PROFILING=$profiling" >> Makefile
 
1629
echo "DYNLINKOPTS=$dllib" >> Makefile
 
1630
echo "OTHERLIBRARIES=$otherlibraries" >> Makefile
 
1631
echo "DEBUGGER=$debugger" >> Makefile
 
1632
echo "CC_PROFILE=$cc_profile" >> Makefile
 
1633
echo "SYSTHREAD_SUPPORT=$systhread_support" >> Makefile
 
1634
echo "PARTIALLD=$partialld" >> Makefile
 
1635
echo "PACKLD=\$(PARTIALLD) $(echo $nativecclinkopts|sed s/-Wl,//g) -o " \
 
1636
  | sed -e 's/ $/\\ /' >> Makefile
 
1637
echo "DLLCCCOMPOPTS=$dllccompopts" >> Makefile
 
1638
echo "IFLEXDIR=$iflexdir" >> Makefile
 
1639
echo "O=o" >> Makefile
 
1640
echo "A=a" >> Makefile
 
1641
echo "SO=so" >> Makefile
 
1642
echo "EXT_OBJ=.o" >> Makefile
 
1643
echo "EXT_ASM=.s" >> Makefile
 
1644
echo "EXT_LIB=.a" >> Makefile
 
1645
echo "EXT_DLL=.so" >> Makefile
 
1646
echo "EXTRALIBS=" >> Makefile
 
1647
echo "CCOMPTYPE=cc" >> Makefile
 
1648
echo "TOOLCHAIN=cc" >> Makefile
 
1649
echo "NATDYNLINK=$natdynlink" >> Makefile
 
1650
echo "CMXS=$cmxs" >> Makefile
 
1651
echo "MKEXE=$mkexe" >> Makefile
 
1652
echo "MKDLL=$mksharedlib" >> Makefile
 
1653
echo "MKMAINDLL=$mkmaindll" >> Makefile
 
1654
 
 
1655
rm -f tst hasgot.c
 
1656
rm -f ../m.h ../s.h ../Makefile
 
1657
mv m.h s.h Makefile ..
 
1658
 
 
1659
# Print a summary
 
1660
 
 
1661
echo
 
1662
echo "** Configuration summary **"
 
1663
echo
 
1664
echo "Directories where Objective Caml will be installed:"
 
1665
echo "        binaries.................. $bindir"
 
1666
echo "        standard library.......... $libdir"
 
1667
echo "        manual pages.............. $mandir (with extension .$manext)"
 
1668
 
 
1669
echo "Configuration for the bytecode compiler:"
 
1670
echo "        C compiler used........... $bytecc"
 
1671
echo "        options for compiling..... $bytecccompopts"
 
1672
echo "        options for linking....... $bytecclinkopts $cclibs $dllib $curseslibs $pthread_link"
 
1673
if $shared_libraries_supported; then
 
1674
echo "        shared libraries are supported"
 
1675
echo "        options for compiling..... $sharedcccompopts $bytecccompopts"
 
1676
echo "        command for building...... $mksharedlib -o lib.so $mksharedlibrpath/a/path objs"
 
1677
else
 
1678
echo "        shared libraries not supported"
 
1679
fi
 
1680
 
 
1681
echo "Configuration for the native-code compiler:"
 
1682
if test "$arch" = "none"; then
 
1683
  echo "        (not supported on this platform)"
 
1684
else
 
1685
  if test "$model" = "default"; then
 
1686
    echo "        hardware architecture..... $arch"
 
1687
  else
 
1688
    echo "        hardware architecture..... $arch ($model)"
 
1689
  fi
 
1690
  if test "$system" = "unknown"; then : ; else
 
1691
  echo "        OS variant................ $system"
 
1692
  fi
 
1693
  echo "        C compiler used........... $nativecc"
 
1694
  echo "        options for compiling..... $nativecccompopts"
 
1695
  echo "        options for linking....... $nativecclinkopts $cclibs"
 
1696
  echo "        assembler ................ $as"
 
1697
  echo "        preprocessed assembler ... $aspp"
 
1698
  echo "        native dynlink ........... $natdynlink"
 
1699
  if test "$profiling" = "prof"; then
 
1700
  echo "        profiling with gprof ..... supported"
 
1701
  else
 
1702
  echo "        profiling with gprof ..... not supported"
 
1703
  fi
 
1704
fi
 
1705
 
 
1706
if test "$debugger" = "ocamldebugger"; then
 
1707
  echo "Source-level replay debugger: supported"
 
1708
else
 
1709
  echo "Source-level replay debugger: not supported"
 
1710
fi
 
1711
 
 
1712
echo "Additional libraries supported:"
 
1713
echo "        $otherlibraries"
 
1714
 
 
1715
echo "Configuration for the \"num\" library:"
 
1716
echo "        target architecture ...... $bng_arch (asm level $bng_asm_level)"
 
1717
 
 
1718
if test "$x11_include" != "not found" && test "$x11_lib" != "not found"; then
 
1719
echo "Configuration for the \"graph\" library:"
 
1720
echo "        options for compiling .... $x11_include"
 
1721
echo "        options for linking ...... $x11_link"
 
1722
fi
 
1723
 
 
1724
if test $has_tk = true; then
 
1725
echo "Configuration for the \"labltk\" library:"
 
1726
echo "        use tcl/tk version ....... $tcl_version"
 
1727
echo "        options for compiling .... $tk_defs"
 
1728
echo "        options for linking ...... $tk_libs"
 
1729
else
 
1730
echo "The \"labltk\" library: not supported"
 
1731
fi
 
1732
 
 
1733
echo
 
1734
echo "** Objective Caml configuration completed successfully **"
 
1735
echo