forked from whitequark/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·1857 lines (1664 loc) · 55.5 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. #
# #
#########################################################################
ocamlversion=`head -1 VERSION`
echo "Configuring OCaml version $ocamlversion"
configure_options="$*"
prefix=/usr/local
bindir=''
target_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
partialld="ld -r"
with_debugger=ocamldebugger
with_ocamldoc=ocamldoc
with_ocamlbuild=ocamlbuild
with_frame_pointers=false
no_naked_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
while : ; do
case "$1" in
"") break;;
-prefix|--prefix)
prefix=$2; shift;;
-bindir|--bindir)
bindir=$2; shift;;
-target-bindir|--target-bindir)
target_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-naked-pointers|--no-naked-pointers)
no_naked_pointers=true;;
-no-cfi|--no-cfi)
with_cfi=false;;
*) if echo "$1" | grep -q -e '^--\?[a-zA-Z0-9-]\+='; then
err "configure expects arguments of the form '-prefix /foo/bar'," \
"not '-prefix=/foo/bar' (note the '=')."
else
err "Unknown option \"$1\"."
fi;;
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 ..."
if [ x"$host" = x"$target" ]; then
cross_compiler=false
else
cross_compiler=true
fi
# Do we have gcc?
if test -z "$ccoption"; then
if sh ./searchpath "${TOOLPREF}gcc"; then
cc="${TOOLPREF}gcc"
else
if $cross_compiler; then
err "No cross-compiler found for ${target}.\n" \
"It should be named ${TOOLPREF}gcc and be in the PATH."
else
cc="cc"
fi
fi
else
cc="$ccoption"
fi
inf "Using compiler $cc."
# Determine the C compiler family (GCC, Clang, etc)
ccfamily=`$cc -E cckind.c | grep '^[a-z]' | tr -s ' ' '-'`
case $? in
0) inf "Compiler family and version: $ccfamily.";;
*) err "Unable to preprocess the test program.\n" \
"Make sure the C compiler $cc is properly installed.";;
esac
# Configure the bytecode compiler
bytecc="$cc"
mkexe="\$(BYTECC)"
mkexedebugflag="-g"
bytecccompopts=""
bytecclinkopts=""
dllccompopts=""
ostype="Unix"
exe=""
iflexdir=""
SO="so"
TOOLCHAIN="cc"
# Choose reasonable options based on compiler kind
# We select high optimization levels, provided we can turn off:
# - strict type-based aliasing analysis (too risky for the OCaml runtime)
# - strict no-overflow conditions on signed integer arithmetic
# (the OCaml runtime assumes Java-style behavior of signed integer arith.)
# Concerning optimization level, -O3 is somewhat risky, so take -O2
# Concerning language version, gnu99 is ISO C99 plus GNU extensions
# that are often used in standard headers. GCC defaults to gnu89,
# which is not C99. Clang defaults to gnu99 or gnu11, which is fine.
case "$ocamlversion" in
*+dev*) gcc_warnings="-Wall -Werror";;
*) gcc_warnings="-Wall";;
esac
case "$ccfamily" in
clang-*)
bytecccompopts="-O2 -fno-strict-aliasing -fwrapv $gcc_warnings";;
gcc-[012]-*)
# Some versions known to miscompile OCaml, e,g, 2.7,2.1, some 2.96.
# Plus: C99 support unknown.
err "This version of GCC is too old. Please use GCC version 3 or above.";;
gcc-3-[0123])
# No -fwrapv option yet
bytecccompopts="-std=gnu99 -O $gcc_warnings";;
gcc-*)
bytecccompopts="-std=gnu99 -O2 -fno-strict-aliasing -fwrapv $gcc_warnings";;
*)
bytecccompopts="-O";;
esac
# Adjust according to target
case "$bytecc,$target" in
cc,*-*-nextstep*)
# GNU C extensions disabled, but __GNUC__ still defined!
bytecccompopts="$bytecccompopts -U__GNUC__ -posix"
bytecclinkopts="-posix";;
*,*-*-rhapsody*)
# Almost the same as NeXTStep
bytecccompopts="$bytecccompopts -DSHRINKED_GNUC"
mathlib="";;
*,*-*-darwin*)
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;;
*,*-*-haiku*)
# No -lm library
mathlib="";;
*,*-*-beos*)
# No -lm library
mathlib="";;
*gcc,alpha*-*-osf*)
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;;
*,mips-*-irix6*)
# Turn off warning "unused library"
bytecclinkopts="-n32 -Wl,-woff,84";;
*,alpha*-*-unicos*)
# For the Cray T3E
bytecccompopts="$bytecccompopts -DUMK";;
*,powerpc-*-aix*)
# Avoid name-space pollution by requiring Unix98-conformant includes
bytecccompopts="$bytecccompopts -D_XOPEN_SOURCE=500";;
*,*-*-cygwin*)
case $target in
i686-*) flavor=cygwin;;
x86_64-*) flavor=cygwin64;;
*) err "unknown cygwin variant";;
esac
bytecccompopts="$bytecccompopts -U_WIN32"
dllccompopts="-U_WIN32 -DCAML_DLL"
if test $with_sharedlibs = yes; then
flexlink="flexlink -chain $flavor -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";;
*,*-*-mingw*)
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"
;;
*,x86_64-*-linux*)
# 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;;
esac
# Configure compiler to use in further tests.
cc="$bytecc $bytecclinkopts"
export cc cclibs verbose
# Check C compiler.
cc="$bytecc $bytecccompopts $bytecclinkopts" sh ./runtest ansi.c
case $? in
0) inf "The C compiler is ISO C99 compliant." ;;
1) wrn "The C compiler is ANSI / ISO C90 compliant, but not ISO C99" \
"compliant.";;
2) err "The C compiler $cc is not ISO C compliant.\n" \
"You need an ISO C99 compiler to build OCaml.";;
*)
if $cross_compiler; then
wrn "Unable to compile the test program.\n" \
"This failure is expected for cross-compilation:\n" \
"we will assume the C compiler is ISO C99-compliant."
else
err "Unable to compile the test program.\n" \
"Make sure the C compiler $cc is properly installed."
fi;;
esac
# For cross-compilation, we need a host-based ocamlrun and ocamlyacc,
# and the user must specify the target BINDIR
if $cross_compiler; 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\n" \
"sources ($ocaml_source_version)."
else
echo "CAMLRUN=`./searchpath -p ocamlrun`" >> Makefile
fi
fi
if ! sh ./searchpath ocamlyacc; then
err "Cross-compilation requires an ocamlyacc binary."
else
ocamlyacc 2>/dev/null
if test "$?" -ne 1; then
err "While you have an ocamlyacc binary, it cannot be executed" \
"successfully."
else
echo "CAMLYACC=`./searchpath -p ocamlyacc`" >> Makefile
fi
fi
if [ -z "$target_bindir" ]; then
err "Cross-compilation requires -target-bindir."
else
echo "TARGET_BINDIR=$target_bindir" >> Makefile
fi
fi # cross-compiler
# Check the sizes of data types
# OCaml needs a 32 or 64 bit architecture, a 32-bit integer type and
# a 64-bit integer type
inf "Checking the sizes of integers and pointers..."
ret=`sh ./runtest sizes.c`
# $1 = sizeof(int)
# $2 = sizeof(long)
# $3 = sizeof(pointers)
# $4 = sizeof(short)
# $5 = sizeof(long long)
if test "$?" -eq 0; then
set $ret
case "$3" in
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;;
*) 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 8
arch64=false;;
x86_64-*-mingw*) inf "Wow! A 64 bit architecture!"
echo "#define ARCH_SIXTYFOUR" >> m.h
set 4 4 8 2 8
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
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
if test $2 != 8 && test $5 != 8; then
err "Sorry, we can't find a 64-bit integer type\n" \
"(sizeof(long) = $2, sizeof(long long) = $5)\n" \
"OCaml won't run on this architecture."
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
echo "#define SIZEOF_LONGLONG $5" >> m.h
# 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\n" \
"(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
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
# 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*|*-*-haiku*)
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[3456]86-*-freebsd*) natdynlink=true;;
x86_64-*-freebsd*) natdynlink=true;;
i[3456]86-*-openbsd*) natdynlink=true;;
x86_64-*-openbsd*) natdynlink=true;;
i[3456]86-*-netbsd*) natdynlink=true;;
x86_64-*-netbsd*) natdynlink=true;;
i386-*-gnu0.3) natdynlink=true;;
i[3456]86-*-haiku*) natdynlink=true;;
arm*-*-linux*) natdynlink=true;;
arm*-*-freebsd*) 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-*-haiku*) arch=i386; system=beos;;
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;;
powerpc64le*-*-linux*) arch=power; model=ppc64le; system=elf;;
powerpc*-*-linux*) arch=power;
if $arch64; then model=ppc64; else model=ppc; fi
system=elf;;
powerpc-*-netbsd*) arch=power; model=ppc; system=elf;;
powerpc-*-openbsd*) arch=power; model=ppc; system=bsd_elf;;
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;;
armv6*-*-freebsd*) arch=arm; model=armv6; system=freebsd;;
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;;
arm*-*-openbsd*) arch=arm; system=bsd;;
zaurus*-*-openbsd*) arch=arm; system=bsd;;
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).
# Sometimes, it's 32-bit mode that is not supported (PR#6722).
case "$arch64,$arch,$model" in
true,sparc,*|true,power,ppc|false,amd64,*)
arch=none; model=default; system=unknown;;
esac
if test -z "$ccoption"; then
nativecc="$bytecc"
else
nativecc="$ccoption"
fi
nativecccompopts="$bytecccompopts"
nativeccprofopts=''
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,$model" in
*,*,nextstep,*) nativecclinkopts="-posix";;
*,*,rhapsody,*) if $arch64; then partialld="ld -r -arch ppc64"; fi;;
amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
power,gcc*,elf,ppc) partialld="ld -r -m elf32ppclinux";;
power,gcc*,elf,ppc64) partialld="ld -r -m elf64ppc";;
power,gcc*,elf,ppc64le) partialld="ld -r -m elf64lppc";;
esac
asppprofflags='-DPROFILING'
case "$arch,$system" in
amd64,macosx) if sh ./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) if $arch64; then
as="${TOOLPREF}as -a64 -mppc64"
aspp="${TOOLPREF}gcc -m64 -c"
else
as="${TOOLPREF}as -mppc"
aspp="${TOOLPREF}gcc -m32 -c"
fi;;
sparc,solaris) as="${TOOLPREF}as"
case "$cc" in
*gcc*) aspp="${TOOLPREF}gcc -c";;
*) aspp="${TOOLPREF}as -P";;
esac;;
arm,freebsd) as="${TOOLPREF}cc -c"
aspp="${TOOLPREF}cc -c";;
*,freebsd) as="${TOOLPREF}as"
aspp="${TOOLPREF}cc -c";;
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,bsd) profiling='prof';;
sparc,solaris)
profiling='prof'
case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
amd64,linux) profiling='prof';;
amd64,openbsd) profiling='prof';;
amd64,freebsd) profiling='prof';;
amd64,netbsd) profiling='prof';;
amd64,gnu) profiling='prof';;
arm,linux*) profiling='prof';;
power,elf) profiling='prof';;
power,bsd*) 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
if sh ./hasgot sigaction sigprocmask; then
inf "POSIX signal handling found."
echo "#define POSIX_SIGNALS" >> s.h
else
if sh ./runtest signals.c; then
inf "Signals have the BSD semantics."
echo "#define BSD_SIGNALS" >> s.h
else
inf "Signals have the System V semantics."
fi
if sh ./hasgot sigsetmask; then
inf "sigsetmask() found"