forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·1815 lines (1622 loc) · 55.3 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /bin/sh
#########################################################################
# #
# OCaml #
# #
# Xavier Leroy, projet Cristal, INRIA Rocquencourt #
# #
# Copyright 1999 Institut National de Recherche en Informatique et #
# en Automatique. All rights reserved. This file is distributed #
# under the terms of the GNU Library General Public License, with #
# the special exception on linking described in file LICENSE. #
# #
#########################################################################
configure_options="$*"
prefix=/usr/local
bindir=''
libdir=''
mandir=''
manext=1
host_type=unknown
target_type=""
ccoption=''
asoption=''
asppoption=''
cclibs=''
curseslibs=''
mathlib='-lm'
dllib=''
x11_include_dir=''
x11_lib_dir=''
graph_wanted=yes
pthread_wanted=yes
dl_defs=''
verbose=no
with_curses=yes
debugruntime=noruntimed
with_sharedlibs=yes
gcc_warnings="-Wall"
partialld="ld -r"
with_debugger=ocamldebugger
with_ocamldoc=ocamldoc
with_ocamlbuild=ocamlbuild
with_frame_pointers=false
TOOLPREF=""
with_cfi=true
# Try to turn internationalization off, can cause config.guess to malfunction!
unset LANG
unset LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
# Turn off some MacOS X debugging stuff, same reason
unset RC_TRACE_ARCHIVES RC_TRACE_DYLIBS RC_TRACE_PREBINDING_DISABLED
# The inf(), wrn(), err() functions below can be used to provide a consistent
# way to notify the user. The notification is always given to the stdout
# descriptor.
#
# Their output is redirected to a file-descriptor "3" which is then redirected
# to fd 1 at the level of the whole configure script. This is done to not
# conflict with how values are returned from functions in shell script.
# Consider the following where "It works!" would be mixed with "42".
# do_foo() {
# if some_command; then
# inf "It works!"
# echo "42"
# fi
# }
inf() {
printf "%b\n" "$*" 1>&3
}
wrn() {
printf "[WARNING] %b\n" "$*" 1>&3
}
err() {
printf "[ERROR!]%b\n" "$*" 1>&3
exit 2
}
exec 3>&1
# Parse command-line arguments
if echo "$configure_options" | grep -q -e '--\?[a-zA-Z0-9-]\+='; then
err "Arguments to this script look like '-prefix /foo/bar', not '-prefix=/foo/bar' (note the '=')."
fi
while : ; do
case "$1" in
"") break;;
-prefix|--prefix)
prefix=$2; shift;;
-bindir|--bindir)
bindir=$2; shift;;
-libdir|--libdir)
libdir=$2; shift;;
-mandir|--mandir)
case "$2" in
*/man[1-9ln])
mandir=`echo $2 | sed -e 's|^\(.*\)/man.$|\1|'`
manext=`echo $2 | sed -e 's/^.*\(.\)$/\1/'`;;
*)
mandir=$2
manext=1;;
esac
shift;;
-host*|--host*)
host_type=$2; shift;;
-target*|--target*)
target_type=$2; shift;;
-cc*)
ccoption="$2"; shift;;
-as)
asoption="$2"; shift;;
-aspp)
asppoption="$2"; shift;;
-lib*)
cclibs="$2 $cclibs"; shift;;
-no-curses|--no-curses)
with_curses=no;;
-no-shared-libs|--no-shared-libs)
with_sharedlibs=no;;
-x11include*|--x11include*)
x11_include_dir=$2; shift;;
-x11lib*|--x11lib*)
x11_lib_dir=$2; shift;;
-no-graph|--no-graph) graph_wanted=no;;
-with-pthread*|--with-pthread*)
;; # Ignored for backward compatibility
-no-pthread*|--no-pthread*)
pthread_wanted=no;;
-partialld|--partialld)
partialld="$2"; shift;;
-dldefs*|--dldefs*)
dl_defs="$2"; shift;;
-dllibs*|--dllibs*)
dllib="$2"; shift;;
-verbose|--verbose)
verbose=yes;;
-with-debug-runtime|--with-debug-runtime)
debugruntime=runtimed;;
-no-debugger|--no-debugger)
with_debugger="";;
-no-ocamldoc|--no-ocamldoc)
with_ocamldoc="";;
-no-ocamlbuild|--no-ocamlbuild)
with_ocamlbuild="";;
-with-frame-pointers|--with-frame-pointers)
with_frame_pointers=true;;
-no-cfi|--no-cfi)
with_cfi=false;;
*) err "Unknown option \"$1\".";;
esac
shift
done
# Sanity checks
case "$prefix" in
/*) ;;
*) err "The -prefix directory must be absolute.";;
esac
case "$bindir" in
/*) ;;
"") ;;
'$(PREFIX)/'*) ;;
*) err 'The -bindir directory must be absolute or relative to $(PREFIX).';;
esac
case "$libdir" in
/*) ;;
"") ;;
'$(PREFIX)/'*) ;;
*) err 'The -libdir directory must be absolute or relative to $(PREFIX).';;
esac
case "$mandir" in
/*) ;;
"") ;;
'$(PREFIX)/'*) ;;
*) err 'The -mandir directory must be absolute or relative to $(PREFIX).';;
esac
# Generate the files
cd config/auto-aux
rm -f s.h m.h Makefile
touch s.h m.h Makefile
# Write options to Makefile
echo "# generated by ./configure $configure_options" >> Makefile
# Where to install
echo "PREFIX=$prefix" >> Makefile
case "$bindir" in
"") echo 'BINDIR=$(PREFIX)/bin' >> Makefile
bindir="$prefix/bin";;
*) echo "BINDIR=$bindir" >> Makefile;;
esac
case "$libdir" in
"") echo 'LIBDIR=$(PREFIX)/lib/ocaml' >> Makefile
libdir="$prefix/lib/ocaml";;
*) echo "LIBDIR=$libdir" >> Makefile;;
esac
echo 'STUBLIBDIR=$(LIBDIR)/stublibs' >> Makefile
case "$mandir" in
"") echo 'MANDIR=$(PREFIX)/man' >> Makefile
mandir="$prefix/man";;
*) echo "MANDIR=$mandir" >> Makefile;;
esac
echo "MANEXT=$manext" >> Makefile
# Determine the system type
if test "$host_type" = "unknown"; then
if host_type=`../gnu/config.guess`; then :; else
err "Cannot guess host type. You must specify one with the -host option."
fi
fi
if host=`../gnu/config.sub $host_type`; then :; else
err "Please specify the correct host type with the -host option"
fi
inf "Configuring for host $host ..."
if test -n "$target_type"; then
target="$target_type"
TOOLPREF="${target}-"
else
target="$host"
fi
inf "Configuring for target $target ..."
# Do we have gcc?
if test -z "$ccoption"; then
if sh ./searchpath "${TOOLPREF}gcc"; then
cc="${TOOLPREF}gcc"
else
if test x"$host" = x"$target"; then
cc="cc"
else
err "No cross-compiler found for ${target}.\n" \
"It should be named ${TOOLPREF}gcc and be in the PATH."
fi
fi
else
cc="$ccoption"
fi
inf "Using compiler $cc."
# Check for buggy versions of GCC
# These checks are not done for cross-compilation (yet at least) because after
# 15 years, I doubt someone will try to use an experimental (2.96) or
# known-unstable (2.7.2.1) version for cross-compilation.
buggycc="no"
case "$target,$cc" in
i[3456]86-*-*,gcc*)
case `$cc --version` in
2.7.2.1) cat <<'EOF'
WARNING: you are using gcc version 2.7.2.1 on an Intel x86 processor.
This version of gcc is known to generate incorrect code for the
OCaml runtime system on some Intel x86 machines. (The symptom
is a crash of boot/ocamlc when compiling stdlib/pervasives.mli.)
In particular, the version of gcc 2.7.2.1 that comes with
Linux RedHat 4.x / Intel is affected by this problem.
Other Linux distributions might also be affected.
If you are using one of these configurations, you are strongly advised
to use another version of gcc, such as 2.95, which are
known to work well with OCaml.
Press <enter> to proceed or <interrupt> to stop.
EOF
read reply;;
2.96*) cat <<'EOF'
WARNING: you are using gcc version 2.96 on an Intel x86 processor.
Certain patched versions of gcc 2.96 are known to generate incorrect
code for the OCaml runtime system. (The symptom is a segmentation
violation on boot/ocamlc.) Those incorrectly patched versions can be found
in RedHat 7.2 and Mandrake 8.0 and 8.1; other Linux distributions
might also be affected. (See bug #57760 on bugzilla.redhat.com)
Auto-configuration will now select gcc compiler flags that work around
the problem. Still, if you observe segmentation faults while running
ocamlc or ocamlopt, you are advised to try another version of gcc,
such as 2.95.3 or 3.2.
EOF
buggycc="gcc.2.96";;
esac;;
esac
# Configure the bytecode compiler
bytecc="$cc"
mkexe="\$(BYTECC)"
mkexedebugflag="-g"
bytecccompopts=""
bytecclinkopts=""
dllccompopts=""
ostype="Unix"
exe=""
iflexdir=""
SO="so"
TOOLCHAIN="cc"
case "$bytecc,$target" in
cc,*-*-nextstep*)
# GNU C extensions disabled, but __GNUC__ still defined!
bytecccompopts="-fno-defer-pop $gcc_warnings -U__GNUC__ -posix"
bytecclinkopts="-posix";;
*,*-*-rhapsody*)
# Almost the same as NeXTStep
bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
mathlib="";;
*,*-*-darwin*)
bytecccompopts="-fno-defer-pop $gcc_warnings"
mathlib=""
mkexe="$mkexe -Wl,-no_compact_unwind"
# Tell gcc that we can use 32-bit code addresses for threaded code
# unless we are compiled for a shared library (-fPIC option)
echo "#ifndef __PIC__" >> m.h
echo "# define ARCH_CODE32" >> m.h
echo "#endif" >> m.h;;
*,*-*-beos*)
bytecccompopts="-fno-defer-pop $gcc_warnings"
# No -lm library
mathlib="";;
*gcc,alpha*-*-osf*)
bytecccompopts="-fno-defer-pop $gcc_warnings"
if cc="$bytecc" sh ./hasgot -mieee; then
bytecccompopts="-mieee $bytecccompopts";
fi
# Put code and static data in lower 4GB
bytecclinkopts="-Wl,-T,12000000 -Wl,-D,14000000"
# Tell gcc that we can use 32-bit code addresses for threaded code
echo "#define ARCH_CODE32" >> m.h;;
cc,alpha*-*-osf*)
bytecccompopts="-std1 -ieee";;
*gcc*,alpha*-*-linux*)
if cc="$bytecc" sh ./hasgot -mieee; then
bytecccompopts="-mieee $bytecccompopts";
fi;;
cc,mips-*-irix6*)
# Add -n32 flag to ensure compatibility with native-code compiler
bytecccompopts="-n32"
# Turn off warning "unused library"
bytecclinkopts="-n32 -Wl,-woff,84";;
cc*,mips-*-irix6*)
# (For those who want to force "cc -64")
# Turn off warning "unused library"
bytecclinkopts="-Wl,-woff,84";;
*,alpha*-*-unicos*)
# For the Cray T3E
bytecccompopts="-DUMK";;
*gcc*,powerpc-*-aix*)
# Avoid name-space pollution by requiring Unix98-conformant includes
bytecccompopts="-fno-defer-pop $gcc_warnings -D_XOPEN_SOURCE=500";;
*,powerpc-*-aix*)
bytecccompopts="-D_XOPEN_SOURCE=500";;
*gcc*,*-*-cygwin*)
bytecccompopts="-fno-defer-pop $gcc_warnings -U_WIN32"
dllccompopts="-U_WIN32 -DCAML_DLL"
if test $with_sharedlibs = yes; then
flexlink="flexlink -chain cygwin -merge-manifest -stack 16777216"
flexdir=`$flexlink -where | dos2unix`
if test -z "$flexdir"; then
wrn "flexlink not found: native shared libraries won't be available."
with_sharedlibs=no
else
iflexdir="-I\"$flexdir\""
mkexe="$flexlink -exe"
mkexedebugflag="-link -g"
fi
fi
if test $with_sharedlibs = no; then
mkexe="$mkexe -Wl,--stack,16777216"
bytecclinkopts="-Wl,--stack,16777216"
fi
exe=".exe"
ostype="Cygwin";;
*gcc*,*-*-mingw*)
bytecccompopts="-fno-defer-pop $gcc_warnings"
dllccompopt="-DCAML_DLL"
if test $with_sharedlibs = yes; then
case "$target" in
i686-*-*) flexlink_chain="mingw";;
x86_64-*-*) flexlink_chain="mingw64";;
esac
flexlink="flexlink -chain $flexlink_chain -merge-manifest -stack 16777216"
flexdir=`$flexlink -where`
if test -z "$flexdir"; then
wrn "flexlink not found: native shared libraries won't be available."
with_sharedlibs=no
else
iflexdir="-I\"$flexdir\""
mkexe="$flexlink -exe"
mkexedebugflag="-link -g"
fi
fi
exe=".exe"
ostype="Win32"
TOOLCHAIN="mingw"
SO="dll"
;;
*gcc*,x86_64-*-linux*)
bytecccompopts="-fno-defer-pop $gcc_warnings"
# Tell gcc that we can use 32-bit code addresses for threaded code
# unless we are compiled for a shared library (-fPIC option)
echo "#ifndef __PIC__" >> m.h
echo "# define ARCH_CODE32" >> m.h
echo "#endif" >> m.h;;
*gcc*)
bytecccompopts="-fno-defer-pop $gcc_warnings";;
esac
# Configure compiler to use in further tests
cc="$bytecc -O $bytecclinkopts"
export cc cclibs verbose
# Check C compiler
sh ./runtest ansi.c
case $? in
0) inf "The C compiler is ANSI-compliant." ;;
1) err "The C compiler $cc is not ANSI-compliant.\n" \
"You need an ANSI C compiler to build OCaml.";;
*)
if test x"$host" != x"$target"; then
wrn "Unable to compile the test program.\n" \
"This failure is expected for cross-compilation:\n" \
"we will assume the C compiler is ANSI-compliant."
else
err "Unable to compile the test program.\n" \
"Make sure the C compiler $cc is properly installed."
fi;;
esac
# Determine which ocamlrun executable to use; for cross-compilation, a native
# "ocamlrun" executable must be available on the system.
if test x"$target" != x"$host"; then
if ! sh ./searchpath ocamlrun; then
err "Cross-compilation requires an ocaml runtime environment\n" \
"(the ocamlrun binary). Moreover, its version must be the same\n" \
"as the one you're trying to build (`cut -f1 -d+ < ../../VERSION`)."
else
ocaml_system_version=`ocamlrun -version | sed 's/[^0-9]*\([0-9.]\+\).*/\1/'`
ocaml_source_version=`sed -n '1 s/\([0-9\.]\+\).*/\1/ p' < ../../VERSION`
if test x"$ocaml_system_version" != x"$ocaml_source_version"; then
err "While you have an ocaml runtime environment, its version\n" \
"($ocaml_system_version) doesn't match the version of these sources\n" \
"($ocaml_source_version)."
else
CAMLRUN="ocamlrun"
fi
fi
else
CAMLRUN=`cd ../.. && pwd`/boot/ocamlrun
fi
echo "CAMLRUN=$CAMLRUN" >> Makefile
# Check the sizes of data types
# OCaml needs a 32 or 64bit architectue and a 32-bit integer type.
inf "Checking the sizes of integers and pointers..."
ret=`sh ./runtest sizes.c`
if test "$?" -eq 0; then
set $ret
case "$2,$3" in
4,4) inf "OK, this is a regular 32 bit architecture."
echo "#undef ARCH_SIXTYFOUR" >> m.h
arch64=false;;
*,8) inf "Wow! A 64 bit architecture!"
echo "#define ARCH_SIXTYFOUR" >> m.h
arch64=true
if test $1 != 4 && test $2 != 4 && test $4 != 4; then
err "Sorry, we can't find a 32-bit integer type\n" \
"(sizeof(short) = $4, sizeof(int) = $1, sizeof(long) = $2)\n" \
"OCaml won't run on this architecture."
fi;;
*,*) err "This architecture seems to be neither 32 bits nor 64 bits.\n" \
"OCaml won't run on this architecture.";;
esac
else
# For cross-compilation, runtest always fails: add special handling.
case "$target" in
i686-*-mingw*) inf "OK, this is a regular 32 bit architecture."
echo "#undef ARCH_SIXTYFOUR" >> m.h
set 4 4 4 2
arch64=false;;
x86_64-*-mingw*) inf "Wow! A 64 bit architecture!"
echo "#define ARCH_SIXTYFOUR" >> m.h
set 4 4 8 2
arch64=true;;
*) err "Since datatype sizes cannot be guessed when cross-compiling,\n" \
"a hardcoded list is used but your architecture isn't known yet.\n" \
"You need to determine the sizes yourself.\n" \
"Please submit a bug report in order to expand the list." ;;
esac
fi
echo "#define SIZEOF_INT $1" >> m.h
echo "#define SIZEOF_LONG $2" >> m.h
echo "#define SIZEOF_PTR $3" >> m.h
echo "#define SIZEOF_SHORT $4" >> m.h
if test $2 = 8; then
echo "#define ARCH_INT64_TYPE long" >> m.h
echo "#define ARCH_UINT64_TYPE unsigned long" >> m.h
echo '#define ARCH_INT64_PRINTF_FORMAT "l"' >> m.h
int64_native=true
else
sh ./runtest longlong.c
case $? in
0) inf "64-bit \"long long\" integer type found (printf with \"%ll\")."
echo "#define ARCH_INT64_TYPE long long" >> m.h
echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
echo '#define ARCH_INT64_PRINTF_FORMAT "ll"' >> m.h
int64_native=true;;
1) inf "64-bit \"long long\" integer type found (printf with \"%q\")."
echo "#define ARCH_INT64_TYPE long long" >> m.h
echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
echo '#define ARCH_INT64_PRINTF_FORMAT "q"' >> m.h
int64_native=true;;
2) inf "64-bit \"long long\" integer type found (but no printf)."
echo "#define ARCH_INT64_TYPE long long" >> m.h
echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
int64_native=true;;
*)
case "$target" in
*-*-mingw*)
inf "No suitable 64-bit integer type found, will use software emulation."
echo "#define ARCH_INT64_TYPE long long" >> m.h
echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
echo '#define ARCH_INT64_PRINTF_FORMAT "I64"' >> m.h
int64_native=true;;
*)
wrn "No suitable 64-bit integer type found, will use software emulation."
echo "#undef ARCH_INT64_TYPE" >> m.h
echo "#undef ARCH_UINT64_TYPE" >> m.h
echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
int64_native=false;;
esac;;
esac
fi
if test $3 = 8 && test $int64_native = false; then
err "This architecture has 64-bit pointers but no 64-bit integer type.\n" \
"OCaml won't run on this architecture."
fi
# Determine endianness
sh ./runtest endian.c
case $? in
0) inf "This is a big-endian architecture."
echo "#define ARCH_BIG_ENDIAN" >> m.h;;
1) inf "This is a little-endian architecture."
echo "#undef ARCH_BIG_ENDIAN" >> m.h;;
2) err "This architecture seems to be neither big endian nor little endian.\n" \
"OCaml won't run on this architecture.";;
*) case $target in
*-*-mingw*) inf "This is a little-endian architecture."
echo "#undef ARCH_BIG_ENDIAN" >> m.h;;
*) wrn "Something went wrong during endianness determination.\n" \
"You will have to figure out endianness yourself (option ARCH_BIG_ENDIAN in m.h).";;
esac;;
esac
# Determine alignment constraints
case "$target" in
sparc*-*-*|hppa*-*-*|arm*-*-*|mips*-*-*)
# On Sparc V9 with certain versions of gcc, determination of double
# alignment is not reliable (PR#1521), hence force it.
# Same goes for hppa.
# PR#5088 suggests same problem on ARM.
# PR#5280 reports same problem on MIPS.
# But there's a knack (PR#2572):
# if we're in 64-bit mode (sizeof(long) == 8),
# we must not doubleword-align floats...
if test $2 = 8; then
inf "Doubles can be word-aligned."
echo "#undef ARCH_ALIGN_DOUBLE" >> m.h
else
inf "Doubles must be doubleword-aligned."
echo "#define ARCH_ALIGN_DOUBLE" >> m.h
fi;;
*)
sh ./runtest dblalign.c
case $? in
0) inf "Doubles can be word-aligned."
echo "#undef ARCH_ALIGN_DOUBLE" >> m.h;;
1) inf "Doubles must be doubleword-aligned."
echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
*) case "$target" in
*-*-mingw*) inf "Doubles can be word-aligned."
echo "#undef ARCH_ALIGN_DOUBLE" >> m.h;;
*) wrn "Something went wrong during alignment determination for doubles.\n" \
"We will assume alignment constraints over doubles.\n" \
"That's a safe bet: OCaml will work even if\n" \
"this architecture actually has no alignment constraints."
echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
esac;;
esac;;
esac
if $int64_native; then
case "$target" in
# PR#5088: autodetection is unreliable on ARM. PR#5280: also on MIPS.
sparc*-*-*|hppa*-*-*|arm*-*-*|mips*-*-*)
if test $2 = 8; then
inf "64-bit integers can be word-aligned."
echo "#undef ARCH_ALIGN_INT64" >> m.h
else
inf "64-bit integers must be doubleword-aligned."
echo "#define ARCH_ALIGN_INT64" >> m.h
fi;;
*-*-mingw*) true;; # Nothing is in config/m-nt.h so don't add anything.
*)
sh ./runtest int64align.c
case $? in
0) inf "64-bit integers can be word-aligned."
echo "#undef ARCH_ALIGN_INT64" >> m.h;;
1) inf "64-bit integers must be doubleword-aligned."
echo "#define ARCH_ALIGN_INT64" >> m.h;;
*) wrn "Something went wrong during alignment determination for\n" \
"64-bit integers. I'm going to assume this architecture has\n" \
"alignment constraints. That's a safe bet: OCaml will work\n" \
"even if this architecture has actually no alignment\n" \
"constraints." \
echo "#define ARCH_ALIGN_INT64" >> m.h;;
esac
esac
else
echo "#undef ARCH_ALIGN_INT64" >> m.h
fi
# Check semantics of division and modulus
sh ./runtest divmod.c
case $? in
0) inf "Native division and modulus have round-towards-zero semantics," \
"will use them."
echo "#undef NONSTANDARD_DIV_MOD" >> m.h;;
1) inf "Native division and modulus do not have round-towards-zero"
"semantics, will use software emulation."
echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
*) case $target in
*-*-mingw*) inf "Native division and modulus have round-towards-zero" \
"semantics, will use them."
echo "#undef NONSTANDARD_DIV_MOD" >> m.h;;
*) wrn "Something went wrong while checking native division and modulus"\
"please report it at http://http://caml.inria.fr/mantis/"
echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
esac;;
esac
# Shared library support
shared_libraries_supported=false
dl_needs_underscore=false
sharedcccompopts=''
mksharedlib=''
byteccrpath=''
mksharedlibrpath=''
natdynlinkopts=""
if test $with_sharedlibs = "yes"; then
case "$target" in
*-*-cygwin*)
mksharedlib="$flexlink"
mkmaindll="$flexlink -maindll"
shared_libraries_supported=true;;
*-*-mingw*)
mksharedlib="$flexlink"
mkmaindll="$flexlink -maindll"
shared_libraries_supported=true;;
*-*-linux-gnu|*-*-linux|*-*-freebsd[3-9]*|*-*-freebsd[1-9][0-9]*|*-*-openbsd*|*-*-netbsd*|*-*-gnu*)
sharedcccompopts="-fPIC"
mksharedlib="$bytecc -shared"
bytecclinkopts="$bytecclinkopts -Wl,-E"
byteccrpath="-Wl,-rpath,"
mksharedlibrpath="-Wl,-rpath,"
natdynlinkopts="-Wl,-E"
shared_libraries_supported=true;;
alpha*-*-osf*)
case "$bytecc" in
*gcc*)
sharedcccompopts="-fPIC"
mksharedlib="$bytecc -shared"
byteccrpath="-Wl,-rpath,"
mksharedlibrpath="-Wl,-rpath,"
shared_libraries_supported=true;;
cc*)
sharedcccompopts=""
mksharedlib="ld -shared -expect_unresolved '*'"
byteccrpath="-Wl,-rpath,"
mksharedlibrpath="-rpath "
shared_libraries_supported=true;;
esac;;
*-*-solaris2*)
case "$bytecc" in
*gcc*)
sharedcccompopts="-fPIC"
if sh ./solaris-ld; then
mksharedlib="$bytecc -shared"
byteccrpath="-R"
mksharedlibrpath="-R"
else
mksharedlib="$bytecc -shared"
bytecclinkopts="$bytecclinkopts -Wl,-E"
natdynlinkopts="-Wl,-E"
byteccrpath="-Wl,-rpath,"
mksharedlibrpath="-Wl,-rpath,"
fi
shared_libraries_supported=true;;
*)
sharedcccompopts="-KPIC"
byteccrpath="-R"
mksharedlibrpath="-R"
mksharedlib="/usr/ccs/bin/ld -G"
shared_libraries_supported=true;;
esac;;
mips*-*-irix[56]*)
case "$bytecc" in
cc*) sharedcccompopts="";;
*gcc*) sharedcccompopts="-fPIC";;
esac
mksharedlib="ld -shared -rdata_shared"
byteccrpath="-Wl,-rpath,"
mksharedlibrpath="-rpath "
shared_libraries_supported=true;;
i[3456]86-*-darwin[89].*)
mksharedlib="$bytecc -bundle -flat_namespace -undefined suppress -read_only_relocs suppress"
bytecccompopts="$dl_defs $bytecccompopts"
dl_needs_underscore=false
shared_libraries_supported=true;;
*-apple-darwin*)
mksharedlib="$bytecc -bundle -flat_namespace -undefined suppress -Wl,-no_compact_unwind"
bytecccompopts="$dl_defs $bytecccompopts"
dl_needs_underscore=false
shared_libraries_supported=true;;
m88k-*-openbsd*)
shared_libraries_supported=false;;
vax-*-openbsd*)
shared_libraries_supported=false;;
*-*-openbsd*)
sharedcccompopts="-fPIC"
mksharedlib="$bytecc -shared"
bytecclinkopts="$bytecclinkopts -Wl,-E"
natdynlinkopts="-Wl,-E"
byteccrpath="-Wl,-rpath,"
mksharedlibrpath="-Wl,-rpath,"
shared_libraries_supported=true;;
esac
fi
if test -z "$mkmaindll"; then
mkmaindll=$mksharedlib
fi
# Configure native dynlink
natdynlink=false
if test $with_sharedlibs = "yes"; then
case "$target" in
*-*-cygwin*) natdynlink=true;;
*-*-mingw*) natdynlink=true;;
i[3456]86-*-linux*) natdynlink=true;;
i[3456]86-*-gnu*) natdynlink=true;;
x86_64-*-linux*) natdynlink=true;;
i[3456]86-*-darwin[89].*) natdynlink=true;;
i[3456]86-*-darwin*)
if test $arch64 == true; then
natdynlink=true
fi;;
x86_64-*-darwin*) natdynlink=true;;
powerpc*-*-linux*) natdynlink=true;;
sparc*-*-linux*) natdynlink=true;;
i686-*-kfreebsd*) natdynlink=true;;
x86_64-*-kfreebsd*) natdynlink=true;;
i[345]86-*-freebsd*) natdynlink=true;;
x86_64-*-freebsd*) natdynlink=true;;
i[345]86-*-openbsd*) natdynlink=true;;
x86_64-*-openbsd*) natdynlink=true;;
i[345]86-*-netbsd*) natdynlink=true;;
x86_64-*-netbsd*) natdynlink=true;;
i386-*-gnu0.3) natdynlink=true;;
arm*-*-linux*) natdynlink=true;;
aarch64-*-linux*) natdynlink=true;;
esac
fi
if test $natdynlink = "true"; then
cmxs="cmxs"
else
cmxs="cmxa"
fi
# Configure the native-code compiler
arch=none
model=default
system=unknown
case "$target" in
sparc*-*-solaris2.*) arch=sparc; system=solaris;;
sparc*-*-*bsd*) arch=sparc; system=bsd;;
sparc*-*-linux*) arch=sparc; system=linux;;
sparc*-*-gnu*) arch=sparc; system=gnu;;
i[3456]86-*-linux*) arch=i386; system=linux_`sh ./runtest elf.c`;;
i[3456]86-*-*bsd*) arch=i386; system=bsd_`sh ./runtest elf.c`;;
i[3456]86-*-nextstep*) arch=i386; system=nextstep;;
i[3456]86-*-solaris*) if $arch64; then
arch=amd64; system=solaris
else
arch=i386; system=solaris
fi;;
i[3456]86-*-beos*) arch=i386; system=beos;;
i[3456]86-*-cygwin*) arch=i386; system=cygwin;;
i[3456]86-*-darwin*) if $arch64; then
arch=amd64; system=macosx
else
arch=i386; system=macosx
fi;;
i[3456]86-*-gnu*) arch=i386; system=gnu;;
i[3456]86-*-mingw*) arch=i386; system=mingw;;
powerpc*-*-linux*) arch=power; model=ppc; system=elf;;
powerpc-*-netbsd*) arch=power; model=ppc; system=elf;;
powerpc-*-openbsd*) arch=power; model=ppc; system=bsd_elf;;
powerpc-*-rhapsody*) arch=power; model=ppc; system=rhapsody;;
powerpc-*-darwin*) arch=power; system=rhapsody
if $arch64;then model=ppc64;else model=ppc;fi;;
armv6*-*-linux-gnueabihf) arch=arm; model=armv6; system=linux_eabihf;;
arm*-*-linux-gnueabihf) arch=arm; system=linux_eabihf;;
armv7*-*-linux-gnueabi) arch=arm; model=armv7; system=linux_eabi;;
armv6t2*-*-linux-gnueabi) arch=arm; model=armv6t2; system=linux_eabi;;
armv6*-*-linux-gnueabi) arch=arm; model=armv6; system=linux_eabi;;
armv5te*-*-linux-gnueabi) arch=arm; model=armv5te; system=linux_eabi;;
armv5*-*-linux-gnueabi) arch=arm; model=armv5; system=linux_eabi;;
arm*-*-linux-gnueabi) arch=arm; system=linux_eabi;;
x86_64-*-linux*) arch=amd64; system=linux;;
x86_64-*-gnu*) arch=amd64; system=gnu;;
x86_64-*-freebsd*) arch=amd64; system=freebsd;;
x86_64-*-netbsd*) arch=amd64; system=netbsd;;
x86_64-*-openbsd*) arch=amd64; system=openbsd;;
x86_64-*-darwin*) arch=amd64; system=macosx;;
x86_64-*-mingw*) arch=amd64; system=mingw;;
aarch64-*-linux*) arch=arm64; system=linux;;
x86_64-*-cygwin*) arch=amd64; system=cygwin;;
esac
# Some platforms exist both in 32-bit and 64-bit variants, not distinguished
# by $target. Turn off native code compilation on platforms where 64-bit mode
# is not supported. (PR#4441)
if $arch64; then
case "$arch,$model" in
sparc,default|power,ppc)
arch=none; model=default; system=unknown;;
esac
fi
if test -z "$ccoption"; then
nativecc="$bytecc"
else
nativecc="$ccoption"
fi
nativecccompopts=''
nativecclinkopts=''
# FIXME the naming of nativecclinkopts is broken: these are options for
# ld (for shared libs), not for cc
nativeccrpath="$byteccrpath"
case "$arch,$nativecc,$system,$target" in
*,*,nextstep,*) nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
nativecclinkopts="-posix";;
*,*,rhapsody,*darwin[1-5].*)
nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";;
*,*,rhapsody,*) nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs"
if $arch64; then partialld="ld -r -arch ppc64"; fi;;
*,gcc*,cygwin,*) nativecccompopts="$gcc_warnings -U_WIN32";;
amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
*,gcc*,*,*) nativecccompopts="$gcc_warnings";;
esac
asppprofflags='-DPROFILING'
case "$arch,$system" in
amd64,macosx) if ./searchpath clang; then
as='clang -arch x86_64 -c'
aspp='clang -arch x86_64 -c'
else
as="${TOOLPREF}as -arch x86_64"
aspp="${TOOLPREF}gcc -arch x86_64 -c"
fi;;
amd64,solaris) as="${TOOLPREF}as --64"
aspp="${TOOLPREF}gcc -m64 -c";;
i386,solaris) as="${TOOLPREF}as"
aspp="/usr/ccs/bin/${TOOLPREF}as -P";;
power,elf) as="${TOOLPREF}as -u -m ppc"
aspp="${TOOLPREF}gcc -c";;
power,rhapsody) as="${TOOLPREF}as -arch $model"
aspp="$bytecc -c";;
sparc,solaris) as="${TOOLPREF}as"
case "$cc" in
*gcc*) aspp="${TOOLPREF}gcc -c";;
*) aspp="${TOOLPREF}as -P";;
esac;;
amd64,*|arm,*|arm64,*|i386,*|power,bsd*|sparc,*)
as="${TOOLPREF}as"
aspp="${TOOLPREF}gcc -c";;
esac
if test -n "$asoption"; then as="$asoption"; fi
if test -n "$asppoption"; then aspp="$asppoption"; fi
cc_profile='-pg'
case "$arch,$system" in
i386,linux_elf) profiling='prof';;
i386,gnu) profiling='prof';;
i386,bsd_elf) profiling='prof';;
amd64,macosx) profiling='prof';;
i386,macosx) profiling='prof';;
sparc,solaris)
profiling='prof'
case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
amd64,linux) profiling='prof';;
amd64,gnu) profiling='prof';;
arm,linux*) profiling='prof';;
*) profiling='noprof';;
esac
# Where is ranlib?
if sh ./searchpath ${TOOLPREF}ranlib; then
inf "ranlib found"
echo "RANLIB=${TOOLPREF}ranlib" >> Makefile
echo "RANLIBCMD=${TOOLPREF}ranlib" >> Makefile
else
inf "ranlib not used"
echo "RANLIB=${TOOLPREF}ar rs" >> Makefile
echo "RANLIBCMD=" >> Makefile
fi
echo "ARCMD=${TOOLPREF}ar" >> Makefile
# Write the OS type (Unix or Cygwin)
echo "#define OCAML_OS_TYPE \"$ostype\"" >> s.h
echo "#define OCAML_STDLIB_DIR \"$libdir\"" >> s.h
# Do #! scripts work?
if (SHELL=/bin/sh; export SHELL; (./sharpbang || ./sharpbang2) >/dev/null); then
inf "#! appears to work in shell scripts."
case "$target" in
*-*-sunos*|*-*-unicos*)
wrn "We won't use it, though, because under SunOS and Unicos it breaks " \
"on pathnames longer than 30 characters"
echo "SHARPBANGSCRIPTS=false" >> Makefile;;
*-*-cygwin*)
wrn "We won't use it, though, because of conflicts with .exe extension " \
"under Cygwin"
echo "SHARPBANGSCRIPTS=false" >> Makefile;;
*-*-mingw*)
inf "We won't use it, though, because it's on the target platform it would be used and windows doesn't support it."
echo "SHARPBANGSCRIPTS=false" >> Makefile;;
*)
echo "SHARPBANGSCRIPTS=true" >> Makefile;;
esac
else
inf "No support for #! in shell scripts"
echo "SHARPBANGSCRIPTS=false" >> Makefile
fi
# Use 64-bit file offset if possible
bytecccompopts="$bytecccompopts -D_FILE_OFFSET_BITS=64"
nativecccompopts="$nativecccompopts -D_FILE_OFFSET_BITS=64"
# Check the semantics of signal handlers