forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
2790 lines (2421 loc) · 91.3 KB
/
configure.ac
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
#**************************************************************************
#* *
#* OCaml *
#* *
#* Sebastien Hinderer, projet Gallium, INRIA Paris *
#* *
#* Copyright 2018 Institut National de Recherche en Informatique et *
#* en Automatique. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************
# Process this file with autoconf to produce a configure script.
# Require Autoconf 2.71 for repeatability in CI
AC_PREREQ([2.71])
AC_INIT([OCaml],
[OCAML__VERSION],
[caml-list@inria.fr],
[ocaml],
[http://www.ocaml.org])
AC_MSG_NOTICE([Configuring OCaml version AC_PACKAGE_VERSION])
# Configuration variables
## Command-line arguments passed to configure
CONFIGURE_ARGS="$*"
# Command to build executables
# Ultimately, MKEXE may build an executable using the C compiler or it may use
# a wrapper for a linker (i.e. flexlink). The build system must therefore not
# rely on $CFLAGS because these cannot be processed by flexlink (and are not
# passed)
mkexe_cmd='$(CC)'
mkexe_extra_flags=''
mkexe_via_cc_extra_cmd=''
mkexe_ldflags_prefix=''
mkexe_via_cc_ldflags_prefix=''
# Flags for building executable files with debugging symbols
mkexedebugflag="-g"
common_cflags=""
common_cppflags=""
internal_cflags=""
internal_cppflags=""
bytecode_cflags=""
bytecode_cppflags=""
oc_ldflags=""
oc_dll_ldflags=""
oc_exe_ldflags=""
tsan=false
# TSan flags for each compilation stage
tsan_cppflags="-DWITH_THREAD_SANITIZER"
tsan_cflags="-fsanitize=thread"
tsan_distinguish_volatile_cflags=""
tsan_ldflags="-fsanitize=thread"
# The C# compiler and its flags
CSC=""
CSCFLAGS=""
ostype="Unix"
SO="so"
toolchain="cc"
reserved_header_bits=0
instrumented_runtime=false
instrumented_runtime_libs=""
bootstrapping_flexdll=false
flexdll_dir=
lib_dynlink=false
lib_str=false
lib_systhreads=false
lib_unix=false
optional_libraries=''
optional_bytecode_tools=''
optional_native_tools=''
ocamltest_libunix=None
ocamltest_unix_impl="dummy"
unix_library=""
unix_directory=""
# Information about the package
## Source directory
AC_CONFIG_SRCDIR([runtime/interp.c])
## Directory containing auxiliary scripts used during build
AC_CONFIG_AUX_DIR([build-aux])
## Output variables
AC_SUBST([CONFIGURE_ARGS])
AC_SUBST([native_compiler])
AC_SUBST([default_build_target])
AC_SUBST([VERSION], [AC_PACKAGE_VERSION])
AC_SUBST([OCAML_DEVELOPMENT_VERSION], [OCAML__DEVELOPMENT_VERSION])
AC_SUBST([OCAML_RELEASE_EXTRA], [OCAML__RELEASE_EXTRA])
AC_SUBST([OCAML_VERSION_MAJOR], [OCAML__VERSION_MAJOR])
AC_SUBST([OCAML_VERSION_MINOR], [OCAML__VERSION_MINOR])
AC_SUBST([OCAML_VERSION_PATCHLEVEL], [OCAML__VERSION_PATCHLEVEL])
AC_SUBST([OCAML_VERSION_EXTRA], [OCAML__VERSION_EXTRA])
AC_SUBST([OCAML_VERSION_SHORT], [OCAML__VERSION_SHORT])
AC_DEFINE([MAGIC_NUMBER_PREFIX], ["][MAGIC_NUMBER__PREFIX]["])
AC_DEFINE([MAGIC_NUMBER_VERSION], ["][MAGIC_NUMBER__VERSION]["])
AC_DEFINE([EXEC_MAGIC_LENGTH], [MAGIC_NUMBER__LENGTH])
AC_SUBST([MAGIC_LENGTH], [MAGIC_NUMBER__LENGTH])
AC_DEFINE([EXEC_FORMAT], ["][EXEC__FORMAT]["])
AC_SUBST([EXEC_MAGIC_NUMBER], [EXEC__MAGIC_NUMBER])
AC_SUBST([CMI_MAGIC_NUMBER], [CMI__MAGIC_NUMBER])
AC_SUBST([CMO_MAGIC_NUMBER], [CMO__MAGIC_NUMBER])
AC_SUBST([CMA_MAGIC_NUMBER], [CMA__MAGIC_NUMBER])
AC_SUBST([CMX_MAGIC_NUMBER])
AC_SUBST([CMXA_MAGIC_NUMBER])
AC_SUBST([AST_IMPL_MAGIC_NUMBER], [AST_IMPL__MAGIC_NUMBER])
AC_SUBST([AST_INTF_MAGIC_NUMBER], [AST_INTF__MAGIC_NUMBER])
AC_SUBST([CMXS_MAGIC_NUMBER], [CMXS__MAGIC_NUMBER])
AC_SUBST([CMT_MAGIC_NUMBER], [CMT__MAGIC_NUMBER])
AC_SUBST([LINEAR_MAGIC_NUMBER], [LINEAR__MAGIC_NUMBER])
AC_SUBST([CC])
AC_SUBST([DIFF_FLAGS])
AC_SUBST([CSC])
AC_SUBST([CSCFLAGS])
# Note: This is present for the flexdll bootstrap where it exposed as the old
# TOOLPREF variable. It would be better if flexdll where updated to require
# WINDRES instead.
AC_SUBST([ac_tool_prefix])
AC_SUBST([exeext])
AC_SUBST([OBJEXT])
AC_SUBST([libext])
AC_SUBST([S])
AC_SUBST([runtime_asm_objects])
AC_SUBST([SO])
AC_SUBST([arch])
AC_SUBST([arch_specific_SOURCES])
AC_SUBST([arch64])
AC_SUBST([model])
AC_SUBST([system])
AC_SUBST([bytecode_cflags])
AC_SUBST([bytecode_cppflags])
AC_SUBST([native_cflags])
AC_SUBST([native_cppflags])
AC_SUBST([oc_bytecode_cflags])
AC_SUBST([oc_bytecode_cppflags])
AC_SUBST([oc_native_cflags])
AC_SUBST([oc_native_cppflags])
AC_SUBST([systhread_support])
AC_SUBST([ocamlsrcdir])
AC_SUBST([unix_or_win32])
AC_SUBST([ln])
AC_SUBST([ocamlyacc_wstr_module])
AC_SUBST([outputexe])
AC_SUBST([outputobj])
AC_SUBST([syslib])
AC_SUBST([fpic])
AC_SUBST([mkexe])
AC_SUBST([mkexe_exp])
AC_SUBST([mkexedebugflag])
AC_SUBST([mkexe_via_cc_ldflags])
AC_SUBST([mkexe_via_cc_extra_cmd])
AC_SUBST([ccomptype])
AC_SUBST([toolchain])
AC_SUBST([common_cflags])
AC_SUBST([oc_cflags])
AC_SUBST([tsan])
AC_SUBST([tsan_native_runtime_c_sources])
AC_SUBST([common_cppflags])
AC_SUBST([oc_cppflags])
AC_SUBST([oc_ldflags])
AC_SUBST([oc_dll_ldflags])
AC_SUBST([cclibs])
AC_SUBST([native_ldflags])
AC_SUBST([zstd_libs])
AC_SUBST([bytecode_cflags])
AC_SUBST([bytecode_cppflags])
AC_SUBST([flexdll_source_dir])
AC_SUBST([bootstrapping_flexdll])
AC_SUBST([flexdll_dir])
AC_SUBST([winpthreads_source_dir])
AC_SUBST([winpthreads_source_include_dir])
AC_SUBST([shebangscripts])
AC_SUBST([AR])
AC_SUBST([mklib])
AC_SUBST([supports_shared_libraries])
AC_SUBST([natdynlink])
AC_SUBST([natdynlinkopts])
AC_SUBST([natdynlink_archive])
AC_SUBST([cmxs])
AC_SUBST([debug_runtime])
AC_SUBST([instrumented_runtime])
AC_SUBST([instrumented_runtime_libs])
AC_SUBST([otherlibraries])
AC_SUBST([otherlibs])
AC_SUBST([lib_dynlink])
AC_SUBST([lib_runtime_events])
AC_SUBST([lib_str])
AC_SUBST([lib_systhreads])
AC_SUBST([lib_unix])
AC_SUBST([optional_libraries])
AC_SUBST([optional_bytecode_tools])
AC_SUBST([optional_native_tools])
AC_SUBST([ocamltest_CPP])
AC_SUBST([ocamltest_libunix])
AC_SUBST([unix_library])
AC_SUBST([unix_directory])
AC_SUBST([cc_has_debug_prefix_map])
AC_SUBST([as_has_debug_prefix_map])
AC_SUBST([with_debugger]) # TODO: rename this variable
AC_SUBST([build_ocamldebug])
AC_SUBST([build_ocamltex])
AC_SUBST([build_ocamldoc])
AC_SUBST([ocamldoc_target])
AC_SUBST([ocamldoc_opt_target])
AC_SUBST([with_ocamldoc])
AC_SUBST([documentation_tool])
AC_SUBST([documentation_tool_cmd])
AC_SUBST([build_ocamlobjinfo])
AC_SUBST([build_ocamltest])
AC_SUBST([ocamltest])
AC_SUBST([ocamltest_target])
AC_SUBST([ocamltest_opt_target])
AC_SUBST([ASPP])
AC_SUBST([endianness])
AC_SUBST([AS])
AC_SUBST([asm_cfi_supported])
AC_SUBST([sharedlib_cflags])
AC_SUBST([rpath])
AC_SUBST([mkdll])
AC_SUBST([mkdll_exp])
AC_SUBST([mkmaindll])
AC_SUBST([mkmaindll_exp])
AC_SUBST([mksharedlibrpath])
AC_SUBST([install_bytecode_programs])
AC_SUBST([install_source_artifacts])
AC_SUBST([install_ocamlnat])
AC_SUBST([reserved_header_bits])
AC_SUBST([frame_pointers])
AC_SUBST([flambda])
AC_SUBST([flambda_invariants])
AC_SUBST([cmm_invariants])
AC_SUBST([windows_unicode])
AC_SUBST([align_double])
AC_SUBST([align_int64])
AC_SUBST([flat_float_array])
AC_SUBST([function_sections])
AC_SUBST([oc_native_compflags])
AC_SUBST([afl])
AC_SUBST([flexdll_chain])
AC_SUBST([PACKLD])
AC_SUBST([build_libraries_manpages])
AC_SUBST([compute_deps])
AC_SUBST([ocaml_bindir])
AC_SUBST([ocaml_libdir])
AC_SUBST([QS])
AC_SUBST([ar_supports_response_files])
## Generated files
AC_CONFIG_FILES([Makefile.build_config])
AC_CONFIG_FILES([Makefile.config])
AC_CONFIG_FILES([stdlib/sys.ml])
AC_CONFIG_FILES([manual/src/version.tex])
AC_CONFIG_FILES([manual/src/html_processing/src/common.ml])
AC_CONFIG_FILES([ocamltest/ocamltest_config.ml])
AC_CONFIG_FILES([otherlibs/dynlink/dynlink_config.ml])
AC_CONFIG_FILES([utils/config.common.ml])
AC_CONFIG_FILES([utils/config.generated.ml])
AC_CONFIG_HEADERS([runtime/caml/exec.h])
AC_CONFIG_HEADERS([runtime/caml/m.h])
AC_CONFIG_HEADERS([runtime/caml/s.h])
AC_CONFIG_HEADERS([runtime/caml/version.h])
AC_CONFIG_FILES([compilerlibs/META])
AC_CONFIG_FILES([otherlibs/dynlink/META])
AC_CONFIG_FILES([otherlibs/runtime_events/META])
AC_CONFIG_FILES([stdlib/META])
# Definitions related to the version of OCaml
AC_DEFINE([OCAML_VERSION_MAJOR], [OCAML__VERSION_MAJOR])
AC_DEFINE([OCAML_VERSION_MINOR], [OCAML__VERSION_MINOR])
AC_DEFINE([OCAML_VERSION_PATCHLEVEL], [OCAML__VERSION_PATCHLEVEL])
m4_if([OCAML__VERSION_EXTRA],[], [],
[AC_DEFINE([OCAML_VERSION_ADDITIONAL], ["][OCAML__VERSION_EXTRA]["])
AC_DEFINE([OCAML_VERSION_EXTRA], ["][OCAML__VERSION_EXTRA]["])])
AC_DEFINE([OCAML_VERSION], [OCAML__VERSION_NUMBER])
AC_DEFINE([OCAML_VERSION_STRING], ["][OCAML__VERSION]["])
# Works out how many "o"s are needed in quoted strings
AC_CONFIG_COMMANDS_PRE(OCAML_QUOTED_STRING_ID)
# Checks for system types
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
# Ensure that AC_CONFIG_LINKS will either create symlinks which are compatible
# with native Windows (i.e. NTFS symlinks, not WSL or Cygwin-emulated ones) or
# use its fallback mechanisms. Native Windows versions of ocamlc/ocamlopt cannot
# interpret either WSL or Cygwin-emulated symlinks.
AS_CASE([$host],
[*-pc-windows|*-w64-mingw32*],
[AC_CONFIG_COMMANDS([native-symlinks], [],
[export CYGWIN="\$CYGWIN\${CYGWIN:+ }winsymlinks:nativestrict"
export MSYS="\$MSYS\${MSYS:+ }winsymlinks:nativestrict"])])
# Systems that are known not to work, even in bytecode only.
AS_CASE([$host],
[i386-*-solaris*],
[AC_MSG_ERROR([Building for 32 bits target is not supported. \
If your host is 64 bits, you can try with './configure CC="gcc -m64"' \
(or "cc -m64" if you don't have GCC).])])
# MSVC special case
AS_CASE([$host],
[*-pc-windows],
[AS_IF([test -z "$CC"], [CC=cl])
ccomptype=msvc
S=asm
SO=dll
outputexe=-Fe
syslib='$(1).lib'],
[ccomptype=cc
S=s
SO=so
outputexe='-o '
syslib='-l$(1)'])
AC_CHECK_PROG([csc],[csc],[csc])
AS_IF([test -n "$csc"],
[AS_CASE([$host],
[*-*-mingw32*|*-pc-windows],
[CSC=csc
CSCFLAGS="/nologo /nowarn:1668"
AS_CASE([$host_cpu], [i*86], [CSCFLAGS="$CSCFLAGS /platform:x86"])],
[AC_MSG_WARN([Mono is not yet supported - C sharp tests disabled])])])
# Environment variables that are taken into account
AC_ARG_VAR([AS], [which assembler to use])
AC_ARG_VAR([ASPP], [which assembler (with preprocessor) to use])
AC_ARG_VAR([PARTIALLD], [how to build partial (relocatable) object files])
AC_ARG_VAR([COMPILER_BYTECODE_CFLAGS],
[CFLAGS for compiling C files to be linked with bytecode])
AC_ARG_VAR([COMPILER_BYTECODE_CPPFLAGS],
[CPPFLAGS for compiling C files to be linked with bytecode])
AC_ARG_VAR([COMPILER_NATIVE_CFLAGS],
[CFLAGS for compiling C files to be linked with native code])
AC_ARG_VAR([COMPILER_NATIVE_CPPFLAGS],
[CPPFLAGS for compiling C files to be linked with native code])
# Command-line arguments to configure
AC_ARG_ENABLE([debug-runtime],
[AS_HELP_STRING([--disable-debug-runtime],
[do not build runtime with debugging support])])
AC_ARG_ENABLE([ocamldebug],
[AS_HELP_STRING([--enable-ocamldebug],
[build ocamldebug @<:@default=auto@:>@])],
[],
[enable_ocamldebug=auto])
AC_ARG_ENABLE([debugger],
[AS_HELP_STRING([--enable-debugger],
[alias for --enable-ocamldebug])],
[enable_ocamldebug=$enableval],
[])
AC_ARG_ENABLE([dependency-generation],
[AS_HELP_STRING([--disable-dependency-generation],
[do not compute dependency information for C sources])],
[],
[enable_dependency_generation=auto])
AC_ARG_VAR([DLLIBS],
[which libraries to use (in addition to -ldl) to load dynamic libs])
AC_ARG_ENABLE([instrumented-runtime],
[AS_HELP_STRING([--enable-instrumented-runtime],
[build the instrumented runtime @<:@default=auto@:>@])],
[],
[enable_instrumented_runtime=auto])
AC_ARG_ENABLE([vmthreads], [],
[AS_IF([test "x$enableval" != 'xno'],
[AC_MSG_ERROR(m4_normalize([The vmthreads library is no longer available.
It was deleted in OCaml 4.09.]))])],
[])
AC_ARG_ENABLE([systhreads],
[AS_HELP_STRING([--disable-systhreads],
[disable the Win32/POSIX threads library])])
AC_ARG_ENABLE([tsan],
[AS_HELP_STRING([--enable-tsan],
[enable ThreadSanitizer support @<:@default=no@:>@])],
[],
[enable_tsan=no])
# Preprocessor and linker flags for libunwind (currently only used when TSan is
# enabled)
AC_ARG_VAR([LIBUNWIND_CPPFLAGS],
[C preprocessor flags for libunwind (e.g. -I<location of libunwind headers>)])
AC_ARG_VAR([LIBUNWIND_LDFLAGS],
[linker flags for libunwind (e.g. -L<location of libunwind>])
AC_ARG_ENABLE([graph-lib], [],
[AS_IF([test "x$enableval" != 'xno'],
[AC_MSG_ERROR(m4_normalize([The graphics library is no longer distributed
with OCaml since version 4.09. It is now distributed as a separate
"graphics" package: https://github.com/ocaml/graphics]))])],
[])
AC_ARG_ENABLE([str-lib],
[AS_HELP_STRING([--disable-str-lib],
[do not build the str library])])
AC_ARG_ENABLE([unix-lib],
[AS_HELP_STRING([--disable-unix-lib],
[do not build the unix library])])
AC_ARG_ENABLE([bigarray-lib], [],
[AS_IF([test "x$enableval" != 'xno'],
[AC_MSG_ERROR(m4_normalize([The bigarray-lib option was deleted in OCaml
5.0, as the Bigarray module is now part of the standard library.]))])],
[])
AC_ARG_ENABLE([ocamldoc],
[AS_HELP_STRING([--disable-ocamldoc],
[do not build the ocamldoc documentation system])],
[],
[enable_ocamldoc='auto'])
AC_ARG_WITH([odoc],
[AS_HELP_STRING([--with-odoc],
[build documentation with odoc])])
AC_ARG_ENABLE([ocamlobjinfo],
[AS_HELP_STRING([--disable-ocamlobjinfo],
[do not build ocamlobjinfo])])
AC_ARG_ENABLE([ocamltest],
[AS_HELP_STRING([--disable-ocamltest],
[do not build ocamltest])])
AC_ARG_ENABLE([native-toplevel],
[AS_HELP_STRING([--enable-native-toplevel],
[build the native toplevel])])
AC_ARG_ENABLE([frame-pointers],
[AS_HELP_STRING([--enable-frame-pointers],
[use frame pointers in runtime and generated code])])
AC_ARG_ENABLE([naked-pointers], [],
[AS_IF([test "x$enableval" != 'xno'],
[AC_MSG_ERROR([Naked pointers were prohibited in OCaml 5.0.])])],
[])
AC_ARG_ENABLE([naked-pointers-checker], [],
[AS_IF([test "x$enableval" != 'xno'],
[AC_MSG_ERROR([The naked pointers checker was removed in OCaml 5.0.])])],
[])
AC_ARG_ENABLE([spacetime], [],
[AS_IF([test "x$enableval" != 'xno'],
[AC_MSG_ERROR([spacetime profiling was deleted in OCaml 4.12.])])],
[])
AC_ARG_ENABLE([cfi],
[AS_HELP_STRING([--disable-cfi],
[disable the CFI directives in assembly files])])
AC_ARG_ENABLE([imprecise-c99-float-ops],
[AS_HELP_STRING([--enable-imprecise-c99-float-ops],
[enables potentially imprecise replacement implementations
of C99 float ops if unavailable on this platform])])
AC_ARG_ENABLE([installing-source-artifacts],
[AS_HELP_STRING([--enable-installing-source-artifacts],
[install *.cmt* and *.mli files])])
AC_ARG_ENABLE([installing-bytecode-programs],
[AS_HELP_STRING([--enable-installing-bytecode-programs],
[also install the bytecode versions of programs])])
AC_ARG_ENABLE([native-compiler],
[AS_HELP_STRING([--disable-native-compiler],
[do not build the native compiler])])
AC_ARG_ENABLE([flambda],
[AS_HELP_STRING([--enable-flambda],
[enable flambda optimizations])])
AC_ARG_ENABLE([flambda-invariants],
[AS_HELP_STRING([--enable-flambda-invariants],
[enable invariants checks in flambda])])
AC_ARG_ENABLE([cmm-invariants],
[AS_HELP_STRING([--enable-cmm-invariants],
[enable invariants checks in Cmm])])
AC_ARG_WITH([target-bindir],
[AS_HELP_STRING([--with-target-bindir],
[location of the runtime binaries on the target system])],
[target_bindir=$withval],
[target_bindir=''])
AC_ARG_WITH([target-sh],
[AS_HELP_STRING([--with-target-sh],
[location of Posix sh on the target system])],
[AS_IF([test x"$withval" = 'xno'],
[target_launch_method='exe'],
[target_launch_method="$withval"])],
[target_launch_method=''])
AC_ARG_ENABLE([reserved-header-bits],
[AS_HELP_STRING([--enable-reserved-header-bits=BITS],
[reserve BITS (between 0 and 31) bits in block headers])],
[AS_CASE([$enable_reserved_header_bits],
[[[0-9]]|[[1-2]][[0-9]]|3[[0-1]]],
[reserved_header_bits=$enable_reserved_header_bits],
[AC_MSG_ERROR([invalid argument to --enable-reserved-header-bits])])])
AC_ARG_ENABLE([stdlib-manpages],
[AS_HELP_STRING([--disable-stdlib-manpages],
[do not build or install the library man pages])],
[],
[enable_stdlib_manpages='auto'])
AC_ARG_ENABLE([warn-error],
[AS_HELP_STRING([--enable-warn-error],
[treat C compiler warnings as errors])])
AC_ARG_VAR([WINDOWS_UNICODE_MODE],
[how to handle Unicode under Windows: ansi, compatible])
AC_ARG_ENABLE([force-safe-string], [],
[AS_IF([test "x$enableval" = 'xno'],
[AC_MSG_ERROR([Support for mutable strings was removed in OCaml 5.0.])])],
[])
AC_ARG_VAR([DEFAULT_STRING], [])
AS_IF([test x"$DEFAULT_STRING" = "xunsafe"],
[AC_MSG_ERROR([Support for mutable strings was removed in OCaml 5.0.])])
AC_ARG_ENABLE([flat-float-array],
[AS_HELP_STRING([--disable-flat-float-array],
[do not use flat float arrays])])
AC_ARG_ENABLE([function-sections],
[AS_HELP_STRING([--disable-function-sections],
[do not emit each function in a separate section])],
[],
[enable_function_sections=auto])
AC_ARG_ENABLE([mmap-map-stack],
[AS_HELP_STRING([--enable-mmap-map-stack],
[use mmap to allocate stacks instead of malloc])])
AC_ARG_WITH([afl],
[AS_HELP_STRING([--with-afl],
[use the AFL fuzzer])])
AC_ARG_WITH([flexdll],
[AS_HELP_STRING([--with-flexdll],
[bootstrap FlexDLL from the given sources])],
[AS_IF([test x"$withval" = 'xyes'],[with_flexdll=flexdll])])
AC_ARG_WITH([winpthreads-msvc],
[AS_HELP_STRING([--with-winpthreads-msvc],
[build winpthreads (only for the MSVC port) from the given sources])],
[AS_IF([test x"$withval" = 'xyes'], [with_winpthreads_msvc=winpthreads])])
AC_ARG_WITH([zstd],
[AS_HELP_STRING([--without-zstd],
[disable compression of compilation artefacts])])
AS_IF([test x"$enable_unix_lib" = "xno"],
[AS_IF([test x"$enable_ocamldebug" = "xyes"],
[AC_MSG_ERROR([ocamldebug requires the unix library])],
[enable_ocamldebug="no"])])
AS_IF([test x"$enable_unix_lib" = "xno" || test x"$enable_str_lib" = "xno"],
[AS_IF([test x"$enable_ocamldoc" = "xyes"],
[AC_MSG_ERROR([ocamldoc requires the unix and str libraries])],
[enable_ocamldoc="no"
build_ocamltex=false])],
[build_ocamltex=true])
AS_IF([test x"$enable_ocamldoc" = "xno"],
[AS_IF([test x"$enable_stdlib_manpages" = "xyes"],
[AC_MSG_ERROR([--enable-stdlib-manpages requires ocamldoc])])
ocamldoc_target=""
ocamldoc_opt_target=""
with_ocamldoc=""
enable_stdlib_manpages=no
build_ocamldoc=false],
[ocamldoc_target=ocamldoc
ocamldoc_opt_target=ocamldoc.opt
with_ocamldoc=ocamldoc
build_ocamldoc=true
optional_libraries="$optional_libraries ocamldoc/odoc_info"
AC_CONFIG_FILES([ocamldoc/META])])
# Initialization of libtool
# Allow the MSVC linker to be found even if ld isn't installed.
# User-specified LD still takes precedence.
AC_CHECK_TOOLS([LD],[ld link])
# libtool expects host_os=mingw for native Windows
# Also, it has been observed that, on some platforms (e.g. msvc) LT_INIT
# alters the CFLAGS variable, so we save its value before calling the macro
# and restore it after the call
old_host_os=$host_os
AS_IF([test x"$host_os" = "xwindows"],[host_os=mingw])
saved_CFLAGS="$CFLAGS"
LT_INIT
CFLAGS="$saved_CFLAGS"
host_os=$old_host_os
AS_CASE([$host],
[sparc-sun-solaris*],
[DEP_CC="false"],
[*-pc-windows],
[AC_CHECK_TOOLS(
[DEP_CC],
[$DEP_CC gcc cc x86_64-w64-mingw32-gcc i686-w64-mingw32-gcc],
[false])],
[DEP_CC="$CC"])
AS_CASE([$enable_dependency_generation],
[yes],
[AS_IF([test "$DEP_CC" = "false"],
[AC_MSG_ERROR(m4_normalize([The MSVC ports cannot generate dependency
information. Install gcc (or another CC-like compiler)]))],
[compute_deps=true])],
[no], [compute_deps=false],
[AS_IF([test -e .git],
[AS_IF([test "$DEP_CC" = "false"],
[compute_deps=false],
[compute_deps=true])],
[compute_deps=false])])
AS_CASE([$host],
# In config/Makefile.mingw*, we had:
# TARGET=i686-w64-mingw32 and x86_64-w64-mingw32
# TOOLPREF=$(TARGET)-
# ARCMD=$(TOOLPREF)ar
# However autoconf and libtool seem to use ar
# So we let them do, at the moment
[*-pc-windows],
[
mkexe_via_cc_extra_cmd=' && $(call MERGEMANIFESTEXE,$(1))'
libext=lib
AR=""
AS_IF([test "$host_cpu" = "x86_64" ],
[machine="-machine:AMD64 "],
[machine=""])
mklib="link -lib -nologo $machine /out:\$(1) \$(2)"
],
[
mklib="rm -f \$(1) && ${AR} rc \$(1) \$(2)"
])
## Find vendor of the C compiler
OCAML_CC_VENDOR
## In cross-compilation mode, can we run executables produced?
# At the moment, it's required, but the fact is used in C99 function detection
OCAML_HOST_IS_EXECUTABLE
# Determine how to call the C preprocessor directly.
# Most of the time, calling the C preprocessor through the C compiler is
# desirable and even important.
# In some cases, though, we want to use the C preprocessor only to
# expand macros. In such cases, it is much more convenient to be able
# to invoke it directly rather than through the C compiler, for instance
# because, when invoked directly, the C preprocessor does not require
# to be invoked on a file with a '.c' extension
# We thus figure out how to invoke the C preprocessor directly but
# let the CPP variable untouched, except for the MSVC port where we set it
# manually to make sure the backward compatibility is preserved
AS_CASE([$ocaml_cc_vendor],
[xlc-*],
[CPP="$CC -E -qnoppline" # suppress incompatible XLC line directives
ocamltest_CPP="$CPP"],
[sunc-*],
[CPP="$CC -E -Qn" # suppress generation of Sun PRO ident string
ocamltest_CPP="$CPP"],
[msvc-*],
[CPP="$CC -nologo -EP -TC"
ocamltest_CPP="$CPP 2> nul"],
[CPP="$CC -E -P"
ocamltest_CPP="$CPP"])
# Absolute path to the toplevel source directory
# A sentinel character (X) is added at the end of the directory name
# and then removed, in case the directory name finishes with an odd character.
# (The $(...) construct strips trailing \n characters.)
# Also, it is important to use `printf` rather than `echo` because the
# behaviour of `echo` is indeterminate and uncontrollable if the
# absolute path contains backslashes, which will definitely be the case
# on Windows
# See https://lists.gnu.org/archive/html/autoconf/2019-07/msg00002.html
# for the detailed explanation.
ocamlsrcdir=$(unset CDPATH; cd -- "$srcdir" && printf %sX "$PWD") || fail
ocamlsrcdir=${ocamlsrcdir%X}
# Whether ar supports @FILE arguments
AS_CASE([$lt_cv_ar_at_file],
[no], [ar_supports_response_files=false],
[ar_supports_response_files=true])
# Libraries to build depending on the host
AS_CASE([$host],
[*-*-mingw32*|*-pc-windows],
[unix_or_win32="win32"
ln='cp -pf'
ocamltest_libunix="Some false"
ocamlsrcdir="$(LC_ALL=C.UTF-8 cygpath -w -- "$ocamlsrcdir")"
ocamlyacc_wstr_module="yacc/wstr"],
[unix_or_win32="unix"
ln='ln -sf'
ocamltest_libunix="Some true"
ocamlyacc_wstr_module=""])
AS_CASE([$host],
[*-*-cygwin*|*-*-mingw32*|*-pc-windows],
[exeext=".exe"],
[exeext=''])
otherlibraries="dynlink runtime_events"
otherlibs="runtime_events"
optional_libraries="$optional_libraries otherlibs/dynlink/dynlink"
lib_dynlink=true
dldir=otherlibs/dynlink
AC_CONFIG_LINKS([
$dldir/dynlink_cmo_format.mli:file_formats/cmo_format.mli
$dldir/dynlink_cmxs_format.mli:file_formats/cmxs_format.mli
$dldir/dynlink_platform_intf.mli:$dldir/dynlink_platform_intf.ml
])
lib_runtime_events=true
AS_IF([test x"$enable_unix_lib" != "xno"],
[enable_unix_lib=yes
AC_CONFIG_FILES([otherlibs/unix/META])
otherlibraries="$otherlibraries unix"
otherlibs="$otherlibs unix"
lib_unix=true
AC_CONFIG_LINKS([
otherlibs/unix/unix.ml:otherlibs/unix/unix_${unix_or_win32}.ml
])
ocamltest_unix_impl="real"
unix_directory="otherlibs/unix"
unix_library="${unix_directory}/unix"],
[ocamltest_libunix="None"])
AS_IF([test x"$enable_str_lib" != "xno"],
[otherlibraries="$otherlibraries str"
otherlibs="$otherlibs str"
lib_str=true
AC_CONFIG_FILES([otherlibs/str/META])])
# Checks for system services
## Test whether #! scripts are supported
## TODO: have two values, one for host and one for target
AC_SYS_INTERPRETER
shebangscripts=false
launch_method='exe'
AS_IF([test "x$interpval" = "xyes"],
[AS_CASE([$host],
[*-cygwin],
[# Cygwin supports shebangs, which we use for the compiler itself, but
# partially for legacy, and partially so that executables can be easily
# run from outside Cygwin, the executables ocamlc and ocamlopt produce do
# not use shebang scripts
shebangscripts=true
launch_method='sh'
AS_IF([test x"$target_launch_method" = 'x'],
[target_launch_method='exe'])],
[*-*-mingw32*|*-pc-windows], [],
[shebangscripts=true
launch_method='sh']
)]
)
# stdlib/runtime.info and stdlib/target_runtime.info are generated by commands
# in config.status, rather than by the .in mechanism, since the latter cannot
# reliably process binary files.
AC_CONFIG_COMMANDS([shebang],
[printf '%s\n%s\000\n' "$launch_method" "$ocaml_bindir" \
> stdlib/runtime.info
printf '%s\n%s\000\n' "$target_launch_method" "$target_bindir" \
> stdlib/target_runtime.info],
dnl These declarations are put in a here-document in configure, so the command
dnl in '$(...)' _is_ evaluated as the content is written to config.status (by
dnl standard interpretation of a here-document). The sed commands quote any
dnl nefarious single quotes which may appear in any of the strings.
[launch_method='$(echo "$launch_method" | sed -e "s/'/'\"'\"'/g")'
target_launch_method=\
'$(echo "$target_launch_method" | sed -e "s/'/'\"'\"'/g")'
ocaml_bindir='$(echo "$ocaml_bindir" | sed -e "s/'/'\"'\"'/g")'
target_bindir='$(echo "$target_bindir" | sed -e "s/'/'\"'\"'/g")'])
# Are we building a cross-compiler
AS_IF(
[test x"$host" = x"$target"],
[cross_compiler=false],
[cross_compiler=true])
# Checks for programs
## Check for the C compiler: done by libtool
## AC_PROG_CC
## Check for C99 support: done by libtool
## AC_PROG_CC_C99
## Determine which flags to use for the C compiler
AS_CASE([$ocaml_cc_vendor],
[xlc-*],
[outputobj='-o '
warn_error_flag=''
cc_warnings='-qflag=i:i'], # all warnings enabled
[sunc-*],
[outputobj='-o '; cc_warnings=""],
[msvc-*],
[outputobj='-Fo'
AS_CASE([$ocaml_cc_vendor],
[msvc-*-clang-*],
[cc_warnings='-W4 -Wno-unused-parameter -Wno-sign-compare -Wundef'
warn_error_flag='-WX'],
[cc_warnings='-W2'
warn_error_flag='-WX -options:strict'])],
[outputobj='-o '
warn_error_flag='-Werror'
cc_warnings="-Wall -Wint-conversion -Wstrict-prototypes \
-Wold-style-definition -Wundef"])
# Use -Wold-style-declaration if supported
AX_CHECK_COMPILE_FLAG([-Wold-style-declaration],
[cc_warnings="$cc_warnings -Wold-style-declaration"], [],
[$warn_error_flag])
# Use -Wimplicit-fallthrough if supported
for flag in '-Wimplicit-fallthrough=5' '-Wimplicit-fallthrough'; do
AX_CHECK_COMPILE_FLAG([$flag],
[cc_warnings="$cc_warnings $flag"; break], [], [$warn_error_flag])
done
AS_CASE([$enable_warn_error,OCAML__DEVELOPMENT_VERSION],
[yes,*|,true],
[cc_warnings="$cc_warnings $warn_error_flag"])
AS_CASE([$host],
[*-*-mingw32*|*-pc-windows],
[AS_CASE([$WINDOWS_UNICODE_MODE],
[ansi],
[windows_unicode=0],
[compatible|""],
[windows_unicode=1],
[AC_MSG_ERROR([unexpected windows unicode mode])])],
[windows_unicode=0])
# 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, recent enough versions of GCC and Clang
# default to gnu11 (C11 + GNU extensions) or gnu17, which is fine.
AS_CASE([$ocaml_cc_vendor],
[clang-*],
[common_cflags="-O2 -fno-strict-aliasing -fwrapv";
internal_cflags="$cc_warnings -fno-common"],
[*gcc-[[0123]]-*|*gcc-4-[[0-8]]],
# No C11 support
[AC_MSG_ERROR(m4_normalize([This version of GCC is too old.
Please use GCC version 4.9 or above.]), 69)],
[gcc-*],
[common_cflags="-O2 -fno-strict-aliasing -fwrapv";
internal_cflags="$cc_warnings -fno-common -fexcess-precision=standard \
-Wvla"],
[mingw-*-*-gcc-*],
[internal_cflags="-Wno-unused $cc_warnings \
-fexcess-precision=standard"
# TODO: see whether the code can be fixed to avoid -Wno-unused
common_cflags="-O2 -fno-strict-aliasing -fwrapv -mms-bitfields"
internal_cppflags='-D__USE_MINGW_ANSI_STDIO=0 -DUNICODE -D_UNICODE'
internal_cppflags="$internal_cppflags -DWINDOWS_UNICODE=$windows_unicode"],
[mingw-*],
[AC_MSG_ERROR([Unsupported C compiler for a MinGW-w64 build])],
[msvc-0*|msvc-1[[0-8]]*|msvc-19[[012]]*|msvc-193[[0-7]]],
# No C11 atomics support
[AC_MSG_ERROR(m4_normalize([This version of MSVC is too old.
Please use Visual Studio version 17.8 or above.]), 69)],
[msvc-*],
[common_cflags='-nologo -O2 -Gy- -MD'
common_cppflags="-D_CRT_SECURE_NO_DEPRECATE"
internal_cflags="$cc_warnings"
internal_cppflags='-DUNICODE -D_UNICODE -D_CRT_NONSTDC_NO_WARNINGS'
AX_CHECK_COMPILE_FLAG([-volatileMetadata-],
[internal_cflags="$internal_cflags -volatileMetadata-"], [],
[$warn_error_flag])
internal_cppflags="$internal_cppflags -DWINDOWS_UNICODE=$windows_unicode"],
[xlc-*],
[common_cflags="-O5 -qtune=balanced -qnoipa -qinline";
internal_cflags="$cc_warnings"],
[sunc-*], # Optimization should be >= O4 to inline functions
# and prevent unresolved externals
[common_cflags="-O4 -xc99=all"
common_cppflags="-D_XPG6"
internal_cflags="$cc_warnings"],
[common_cflags="-O"])
# Enable SSE2 on x86 mingw to avoid using 80-bit registers.
AS_CASE([$host],
[i686-*-mingw32*],
[internal_cflags="$internal_cflags -mfpmath=sse -msse2"])
# Use 64-bit file offset if possible
# See also AC_SYS_LARGEFILE
# Problem: flags are added to CC rather than CPPFLAGS
AS_CASE([$host],
[*-*-mingw32*|*-pc-windows], [],
[common_cppflags="$common_cppflags -D_FILE_OFFSET_BITS=64"])
# Adjust according to target
# On Windows we do not take $enable_shared because it does not seem
# to work. This should be better understood later
#AS_CASE([$target],
# [*-pc-windows],
# [enable_shared=yes])
AS_IF([test x"$enable_shared" = "xno"],
[supports_shared_libraries=false
AS_CASE([$host],
[*-pc-windows|*-w64-mingw32*],
[AC_MSG_ERROR([Cannot build native Win32 with --disable-shared])])],
[supports_shared_libraries=true])
# Define flexlink chain and flags correctly for the different Windows ports
flexlink_flags=''
AS_CASE([$host],
[i686-*-cygwin],
[flexdll_chain='cygwin'
flexlink_flags='-merge-manifest -stack 16777216'],
[x86_64-*-cygwin],
[flexdll_chain='cygwin64'
flexlink_flags='-merge-manifest -stack 16777216'],
[*-*-cygwin*],
[AC_MSG_ERROR([unknown cygwin variant])],
[i686-w64-mingw32*],
[flexdll_chain='mingw'
flexlink_flags='-stack 16777216'],
[x86_64-w64-mingw32*],
[flexdll_chain='mingw64'
flexlink_flags='-stack 33554432'],
[i686-pc-windows],
[flexdll_chain='msvc'
flexlink_flags='-merge-manifest -stack 16777216'],
[x86_64-pc-windows],
[flexdll_chain='msvc64'
flexlink_flags='-merge-manifest -stack 33554432'],
[flexdll_chain=''])
AS_IF([test x"$supports_shared_libraries" != 'xfalse'], [
AC_MSG_CHECKING([for flexdll sources])
AS_IF([test x"$with_flexdll" = "xno"],
[flexdll_source_dir=''
AC_MSG_RESULT([disabled])],
[flexmsg=''
AS_CASE([$target],
[*-*-cygwin*|*-w64-mingw32*|*-pc-windows],
[dnl When bootstrapping from the git submodule (flexdll directory), just
dnl use that, however if another directory has been specified with
dnl --with-flexdll=<path> then copy the contents of <path> to
dnl flexdll-sources. This allows us to guarantee that flexdll is always
dnl built at one directory level below the root, so we can specify
dnl ROOTDIR=..
AS_IF([m4_normalize([test x"$with_flexdll" = 'x'
|| test x"$with_flexdll" = 'xflexdll'])],
[AS_IF([test -f 'flexdll/flexdll.h'],
[flexdll_source_dir=flexdll],
[AS_IF([test x"$with_flexdll" != 'x'],