1 #**************************************************************************
2 #* *
3 #* OCaml *
4 #* *
5 #* Sebastien Hinderer, projet Gallium, INRIA Paris *
6 #* *
7 #* Copyright 2018 Institut National de Recherche en Informatique et *
8 #* en Automatique. *
9 #* *
10 #* All rights reserved. This file is distributed under the terms of *
11 #* the GNU Lesser General Public License version 2.1, with the *
12 #* special exception on linking described in the file LICENSE. *
13 #* *
14 #**************************************************************************
15
16 # Process this file with autoconf to produce a configure script.
17
18 # Require Autoconf 2.69 for repeatability in CI
19 AC_PREREQ([2.69])
20 AC_INIT([OCaml],
21 m4_esyscmd([head -n1 VERSION | tr -d '\r\n']),
22 [caml-list@inria.fr],
23 [ocaml],
24 [http://www.ocaml.org])
25
26 AC_MSG_NOTICE([Configuring OCaml version AC_PACKAGE_VERSION])
27
28 # Configuration variables
29
30 ## Command-line arguments passed to configure
31 CONFIGURE_ARGS="$*"
32
33 # Command-line tools section of the Unix manual
34 programs_man_section=1
35
36 # Library section of the Unix manual
37 libraries_man_section=3
38
39 # Command to build executalbes
40 mkexe="\$(CC) \$(OC_CFLAGS) \$(OC_CPPFLAGS) \$(OC_LDFLAGS)"
41
42 # Flags for building executable files with debugging symbols
43 mkexedebugflag="-g"
44 common_cflags=""
45 common_cppflags=""
46 internal_cflags=""
47 internal_cppflags=""
48 ocamlc_cflags=""
49 ocamlc_cppflags=""
50 ocamlopt_cflags=""
51 ocamlopt_cppflags=""
52 oc_ldflags=""
53 with_sharedlibs=true
54 ostype="Unix"
55 iflexdir=""
56 SO="so"
57 toolchain="cc"
58 profinfo=false
59 profinfo_width=0
60 extralibs=
61
62 # Information about the package
63
64 ## Source directory
65 AC_CONFIG_SRCDIR([runtime/interp.c])
66
67 ## Directory containing auxiliary scripts used dugring build
68 AC_CONFIG_AUX_DIR([build-aux])
69
70 ## Output variables
71
72 AC_SUBST([CONFIGURE_ARGS])
73 AC_SUBST([native_compiler])
74 AC_SUBST([VERSION], [AC_PACKAGE_VERSION])
75 AC_SUBST([CC])
76 # Note: This is present for the flexdll bootstrap where it exposed as the old
77 # TOOLPREF variable. It would be better if flexdll where updated to require
78 # WINDRES instead.
79 AC_SUBST([DIRECT_CPP])
80 AC_SUBST([ac_tool_prefix])
81 AC_SUBST([exeext])
82 AC_SUBST([OBJEXT])
83 AC_SUBST([libext])
84 AC_SUBST([S])
85 AC_SUBST([SO])
86 AC_SUBST([arch])
87 AC_SUBST([arch64])
88 AC_SUBST([model])
89 AC_SUBST([system])
90 AC_SUBST([systhread_support])
91 AC_SUBST([unix_or_win32])
92 AC_SUBST([unixlib])
93 AC_SUBST([outputexe])
94 AC_SUBST([outputobj])
95 AC_SUBST([syslib])
96 AC_SUBST([extralibs])
97 AC_SUBST([programs_man_section])
98 AC_SUBST([libraries_man_section])
99 AC_SUBST([fpic])
100 AC_SUBST([mkexe])
101 AC_SUBST([mkexedebugflag])
102 AC_SUBST([ccomptype])
103 AC_SUBST([toolchain])
104 AC_SUBST([oc_cflags])
105 AC_SUBST([oc_cppflags])
106 AC_SUBST([oc_ldflags])
107 AC_SUBST([bytecclibs])
108 AC_SUBST([nativecclibs])
109 AC_SUBST([ocamlc_cflags])
110 AC_SUBST([ocamlc_cppflags])
111 AC_SUBST([ocamlopt_cflags])
112 AC_SUBST([ocamlopt_cppflags])
113 AC_SUBST([iflexdir])
114 AC_SUBST([long_shebang])
115 AC_SUBST([shebangscripts])
116 AC_SUBST([AR])
117 AC_SUBST([RANLIB])
118 AC_SUBST([RANLIBCMD])
119 AC_SUBST([mklib])
120 AC_SUBST([supports_shared_libraries])
121 AC_SUBST([natdynlink])
122 AC_SUBST([natdynlinkopts])
123 AC_SUBST([cmxs])
124 AC_SUBST([debug_runtime])
125 AC_SUBST([instrumented_runtime])
126 AC_SUBST([otherlibraries])
127 AC_SUBST([cc_has_debug_prefix_map])
128 AC_SUBST([as_has_debug_prefix_map])
129 AC_SUBST([with_debugger]) # TODO: rename this variable
130 AC_SUBST([with_camltex])
131 AC_SUBST([ocamldoc])
132 AC_SUBST([pthread_link])
133 AC_SUBST([x_includes])
134 AC_SUBST([x_libraries])
135 AC_SUBST([bfd_cppflags])
136 AC_SUBST([bfd_ldflags])
137 AC_SUBST([bfd_ldlibs])
138 AC_SUBST([ASPP])
139 AC_SUBST([AS])
140 AC_SUBST([asm_cfi_supported])
141 AC_SUBST([sharedlib_cflags])
142 AC_SUBST([rpath])
143 AC_SUBST([mksharedlib])
144 AC_SUBST([mkmaindll])
145 AC_SUBST([mksharedlibrpath])
146 AC_SUBST([install_bytecode_programs])
147 AC_SUBST([install_source_artifacts])
148 AC_SUBST([profinfo])
149 AC_SUBST([profinfo_width])
150 AC_SUBST([frame_pointers])
151 AC_SUBST([spacetime])
152 AC_SUBST([call_counts])
153 AC_SUBST([libunwind_available])
154 AC_SUBST([libunwind_include_flags])
155 AC_SUBST([libunwind_link_flags])
156 AC_SUBST([flambda])
157 AC_SUBST([flambda_invariants])
158 AC_SUBST([max_testsuite_dir_retries])
159 AC_SUBST([windows_unicode])
160 AC_SUBST([flat_float_array])
161 AC_SUBST([function_sections])
162 AC_SUBST([afl])
163 AC_SUBST([force_safe_string])
164 AC_SUBST([default_safe_string])
165 AC_SUBST([flexdll_chain])
166 AC_SUBST([flexlink_flags])
167 AC_SUBST([PACKLD])
168 AC_SUBST([stdlib_manpages])
169
170 ## Generated files
171
172 AC_CONFIG_FILES([Makefile.common])
173 AC_CONFIG_FILES([Makefile.config])
174 AC_CONFIG_HEADERS([runtime/caml/m.h])
175 AC_CONFIG_HEADERS([runtime/caml/s.h])
176
177 # Checks for system types
178
179 AC_CANONICAL_BUILD
180 AC_CANONICAL_HOST
181 AC_CANONICAL_TARGET
182
183 AS_CASE([$host],
184 [*-pc-windows],
185 [CC=cl
186 ccomptype=msvc
187 S=asm
188 SO=dll
189 outputexe=-Fe
190 syslib='$(1).lib'],
191 [ccomptype=cc
192 S=s
193 SO=so
194 outputexe='-o $(EMPTY)'
195 syslib='-l$(1)'])
196
197 # Environment variables that are taken into account
198
199 AC_ARG_VAR([AS], [which assembler to use])
200 AC_ARG_VAR([ASPP], [which assembler (with preprocessor) to use])
201 AC_ARG_VAR([PARTIALLD], [how to build partial (relocatable) object files])
202
203 # Command-line arguments to configure
204
205 AC_ARG_ENABLE([debug-runtime],
206 [AS_HELP_STRING([--disable-debug-runtime],
207 [do not build runtime with debugging support])])
208
209 AC_ARG_ENABLE([debugger],
210 [AS_HELP_STRING([--enable-debugger],
211 [build the debugger @<:@default=auto@:>@])],
212 [],
213 [enable_debugger=auto])
214
215 AC_ARG_VAR([DLLIBS],
216 [which libraries to use (in addition to -ldl) to load dynamic libs])
217
218 AC_ARG_ENABLE([instrumented-runtime],
219 [AS_HELP_STRING([--enable-instrumented-runtime],
220 [build the instrumented runtime @<:@default=auto@:>@])],
221 [],
222 [enable_instrumented_runtime=auto])
223
224 AC_ARG_ENABLE([vmthreads], [],
225 [AC_MSG_ERROR([The vmthreads library is no longer available. \
226 It was deleted in OCaml 4.09.])],
227 [])
228
229 AC_ARG_ENABLE([systhreads],
230 [AS_HELP_STRING([--disable-systhreads],
231 [disable the Win32/POSIX threads library])])
232
233 AC_ARG_WITH([libunwind],
234 [AS_HELP_STRING([--without-libunwind],
235 [disable libunwind support for Spacetime profiling])])
236
237 AC_ARG_VAR([LIBUNWIND_INCLUDE_DIR],
238 [location of header files for libunwind])
239
240 AC_ARG_VAR([LIBUNWIND_LIB_DIR],
241 [location of library files for libunwind])
242
243 AC_ARG_WITH([bfd],
244 [AS_HELP_STRING([--without-bfd],
245 [disable BFD (Binary File Description) library support])],
246 [],
247 [with_bfd=auto])
248
249 AC_ARG_VAR([BFD_INCLUDE_DIR],
250 [location of header files for the BFD library])
251
252 AC_ARG_VAR([BFD_LIB_DIR],
253 [location of library files for the BFD library])
254
255 AC_ARG_ENABLE([graph-lib], [],
256 [AC_MSG_ERROR([The graphics library is no longer distributed with OCaml \
257 since version 4.09. It is now distributed as a separate "graphics" package: \
258 https://github.com/ocaml/graphics])],
259 [])
260
261 AC_ARG_ENABLE([str-lib],
262 [AS_HELP_STRING([--disable-str-lib],
263 [do not build the str library])])
264
265 AC_ARG_ENABLE([unix-lib],
266 [AS_HELP_STRING([--disable-unix-lib],
267 [do not build the unix library])])
268
269 AC_ARG_ENABLE([bigarray-lib],
270 [AS_HELP_STRING([--disable-bigarray-lib],
271 [do not build the legacy separate bigarray library])])
272
273 AC_ARG_ENABLE([ocamldoc],
274 [AS_HELP_STRING([--disable-ocamldoc],
275 [do not build the ocamldoc documentation system])],
276 [],
277 [ocamldoc=auto])
278
279 AC_ARG_ENABLE([frame-pointers],
280 [AS_HELP_STRING([--enable-frame-pointers],
281 [use frame pointers in runtime and generated code])])
282
283 AC_ARG_ENABLE([naked-pointers],
284 [AS_HELP_STRING([--disable-naked-pointers],
285 [do not allow naked pointers])])
286
287 AC_ARG_ENABLE([spacetime],
288 [AS_HELP_STRING([--enable-spacetime],
289 [build the spacetime profiler])])
290
291 AC_ARG_ENABLE([call-counts],
292 [AS_HELP_STRING([--disable-call-counts],
293 [disable the call counts in spacetime])])
294
295 AC_ARG_ENABLE([cfi],
296 [AS_HELP_STRING([--disable-cfi],
297 [disable the CFI directives in assembly files])])
298
299 AC_ARG_ENABLE([installing-source-artifacts],
300 [AS_HELP_STRING([--enable-installing-source-artifacts],
301 [install *.cmt* and *.mli files])])
302 AC_ARG_ENABLE([installing-bytecode-programs],
303 [AS_HELP_STRING([--enable-installing-bytecode-programs],
304 [also install the bytecode versions of programs])])
305
306 AC_ARG_ENABLE([native-compiler],
307 [AS_HELP_STRING([--disable-native-compiler],
308 [do not build the native compiler])])
309
310 AC_ARG_ENABLE([flambda],
311 [AS_HELP_STRING([--enable-flambda],
312 [enable flambda optimizations])])
313
314 AC_ARG_ENABLE([flambda-invariants],
315 [AS_HELP_STRING([--enable-flambda-invariants],
316 [enable invariants checks in flambda])])
317
318 AC_ARG_WITH([target-bindir],
319 [AS_HELP_STRING([--with-target-bindir],
320 [location of binary programs on target system])])
321
322 AC_ARG_ENABLE([reserved-header-bits],
323 [AS_HELP_STRING([--enable-reserved-header-bits=BITS],
324 [reserve BITS (between 0 and 31) bits in block headers for profiling info])],
325 [AS_CASE([$enable_reserved_header_bits],
326 [0],
327 [with_profinfo=false
328 profinfo_width=0],
329 [[[1-9]]|1[[0-9]]|2[[0-1]]],
330 [with_profinfo=true
331 profinfo_width="$enable_reserved_header_bits"],
332 [AC_MSG_ERROR([invalid argument to --enable-reserved-header-bits])])])
333
334 AC_ARG_ENABLE([stdlib-manpages],
335 [AS_HELP_STRING([--disable-stdlib-manpages],
336 [do not build or install the library man pages])])
337
338 AC_ARG_VAR([WINDOWS_UNICODE_MODE],
339 [how to handle Unicode under Windows: ansi, compatible])
340
341 # There are two configure-time string safety options,
342 # --(enable|disable)-force-safe-string and
343 # DEFAULT_STRING=safe|unsafe that
344 # interact with a compile-time (un)safe-string option.
345 #
346 # If --enable-force-safe-string is set at configure time, then the compiler
347 # will always enforce that string and bytes are distinct: the
348 # compile-time -unsafe-string option is disabled. This lets us
349 # assume pervasive string immutability, for code optimizations and
350 # in the C layer.
351 #
352 # If --disable-force-safe-string is set at configure-time, the compiler
353 # will use the compile-time (un)safe-string option to decide whether
354 # string and bytes are compatible on a per-file basis. The
355 # configuration variable DEFAULT_STRING=safe|unsafe decides which
356 # setting will be chosen by default, if no compile-time option is
357 # explicitly passed.
358 #
359 # The configure-time behavior of OCaml 4.05 and older was equivalent
360 # to --disable-force-safe-string DEFAULT_STRING=unsafe. With OCaml 4.06
361 # and older was equivalent to --disable-force-safe-string DEFAULT_STRING=safe.
362 # With OCaml 4.10 and later use --enable-force-safe-string DEFAULT_STRING=safe.
363 # We expect the --disable-force-safe-string and DEFAULT_STRING=unsafe options
364 # to be removed in the future.
365
366 AC_ARG_ENABLE([force-safe-string],
367 [AS_HELP_STRING([--disable-force-safe-string],
368 [do not force strings to be safe])])
369
370 AC_ARG_VAR([DEFAULT_STRING],
371 [whether strings should be safe (default) or unsafe])
372
373 AC_ARG_ENABLE([flat-float-array],
374 [AS_HELP_STRING([--disable-flat-float-array],
375 [do not use flat float arrays])])
376
377 AC_ARG_ENABLE([function-sections],
378 [AS_HELP_STRING([--disable-function-sections],
379 [do not emit each function in a separate section])],
380 [],
381 [enable_function_sections=auto])
382
383 AC_ARG_WITH([afl],
384 [AS_HELP_STRING([--with-afl],
385 [use the AFL fuzzer])])
386
387 AS_IF([test x"$enable_unix_lib" = "xno"],
388 [AS_IF([test x"$enable_debugger" = "xyes"],
389 [AC_MSG_ERROR([replay debugger requires the unix library])],
390 [enable_debugger="no"])
391 AS_IF([test x"$enable_bigarray_lib" = "xyes"],
392 [AC_MSG_ERROR([legacy bigarray library requires the unix library])])])
393
394 AS_IF([test x"$enable_unix_lib" = "xno" -o x"$enable_str_lib" = "xno"],
395 [AS_IF([test x"$enable_ocamldoc" = "xyes"],
396 [AC_MSG_ERROR([ocamldoc requires the unix and str libraries])],
397 [enable_ocamldoc="no"
398 with_camltex=""])],
399 [with_camltex="true"])
400
401 # Initialization of libtool
402 # Allow the MSVC linker to be found even if ld isn't installed.
403 # User-specified LD still takes precedence.
404 AC_CHECK_TOOLS([LD],[ld link])
405 # libtool expects host_os=mingw for native Windows
406 old_host_os=$host_os
407 AS_IF([test x"$host_os" = "xwindows"],[host_os=mingw])
408 LT_INIT
409 host_os=$old_host_os
410
411 # Extracting information from libtool's configuration
412 AS_IF([test -n "$RANLIB" ],
413 [RANLIBCMD="$RANLIB"],
414 [RANLIB="$AR rs"; RANLIBCMD=""]
415 )
416
417 AS_CASE([$host],
418 # In config/Makefile.mingw*, we had:
419 # TARGET=i686-w64-mingw32 and x86_64-w64-mingw32
420 # TOOLPREF=$(TARGET)-
421 # ARCMD=$(TOOLPREF)ar
422 # RANLIB=$(TOOLPREF)ranlib
423 # RANLIBCMD=$(TOOLPREF)ranlib
424 # However autoconf and libtool seem to use ar and ranlib
425 # So we let them do, at the moment
426 [*-pc-windows],
427 [
428 libext=lib
429 AR=""; RANLIB=echo; RANLIBCMD=""
430 AS_IF([test "$host_cpu" = "x86_64" ],
431 [machine="-machine:AMD64 "],
432 [machine=""])
433 mklib="link -lib -nologo $machine /out:\$(1) \$(2)"
434 ],
435 [
436 mklib="rm -f \$(1) && ${AR} rc \$(1) \$(2) && ${RANLIB} \$(1)"
437 ])
438
439 ## Find vendor of the C compiler
440 OCAML_CC_VENDOR
441
442 # Determine how to call the C preprocessor directly.
443 # Most of the time, calling the C preprocessor through the C compiler is
444 # desirable and even important.
445 # In some cases, though, we want to use the C preprocessor only to
446 # expand macros. In such cases, it is much more convenient to be able
447 # to invoke it directly rather than through the C compiler, for instance
448 # because, when invoked directly, the C preprocessor does not require
449 # to be invoked on a file with a '.c' extension
450 # We thus figure out how to invoke the C preprocessor directly but
451 # let the CPP variable untouched, except for the MSVC port where we set it
452 # manually to make sure the backward compatibility is preserved
453 AS_CASE([$ocaml_cv_cc_vendor],
454 [xlc-*],
455 [CPP="$CC -E -qnoppline"], # suppress incompatible XLC line directives
456 [msvc-*],
457 [CPP="$CC -nologo -EP"])
458
459 # Libraries to build depending on the host
460
461 AS_CASE([$host],
462 [*-*-mingw32|*-pc-windows],
463 [unix_or_win32="win32"
464 unixlib="win32unix"
465 ],
466 [unix_or_win32="unix"
467 unixlib="unix"])
468 AS_CASE([$host],
469 [*-*-cygwin*|*-*-mingw32|*-pc-windows],
470 [exeext=".exe"],
471 [exeext=''])
472
473 otherlibraries="dynlink"
474 AS_IF([test x"$enable_unix_lib" != "xno"],
475 [AS_IF([test x"$enable_bigarray_lib" != "xno"],
476 [otherlibraries="$otherlibraries $unixlib bigarray"],
477 [otherlibraries="$otherlibraries $unixlib"])])
478 AS_IF([test x"$enable_str_lib" != "xno"],
479 [otherlibraries="$otherlibraries str"])
480
481 # Checks for system services
482
483 ## Test whether #! scripts are supported
484 ## TODO: have two values, one for host and one for target
485 AC_SYS_INTERPRETER
486
487 long_shebang=false
488 AS_IF(
489 [test "x$interpval" = "xyes"],
490 [AS_CASE([$host],
491 [*-cygwin|*-*-mingw32|*-pc-windows],
492 [shebangscripts=false],
493 [shebangscripts=true
494 prev_exec_prefix="$exec_prefix"
495 AS_IF([test "x$exec_prefix" = "xNONE"],[exec_prefix="$prefix"])
496 eval "expanded_bindir=\"$bindir\""
497 exec_prefix="$prev_exec_prefix"
498 # Assume maximum shebang is 128 chars; less #!, /ocamlrun, an optional
499 # 1 char suffix and the \0 leaving 115 characters
500 AS_IF([test "${#expanded_bindir}" -gt 115],[long_shebang=true])
501 ]
502 )],
503 [shebangscripts=false]
504 )
505
506 # Are we building a cross-compiler
507
508 AS_IF(
509 [test x"$host" = x"$target"],
510 [cross_compiler=false],
511 [cross_compiler=true])
512
513 # Checks for programs
514
515 ## Check for the C compiler: done by libtool
516 ## AC_PROG_CC
517
518 ## Check for C99 support: done by libtool
519 ## AC_PROG_CC_C99
520
521 ## Determine which flags to use for the C compiler
522
523 AS_CASE([$ocaml_cv_cc_vendor],
524 [xlc-*],
525 [outputobj='-o $(EMPTY)'; gcc_warnings="-qflag=i:i"], # all warnings enabled
526 [msvc-*],
527 [outputobj=-Fo; gcc_warnings=""],
528 [outputobj='-o $(EMPTY)'; AS_CASE([AC_PACKAGE_VERSION],
529 [*+dev*],
530 [gcc_warnings="-Wall -Werror"],
531 [gcc_warnings="-Wall"]
532 )]
533 )
534
535 # We select high optimization levels, provided we can turn off:
536 # - strict type-based aliasing analysis (too risky for the OCaml runtime)
537 # - strict no-overflow conditions on signed integer arithmetic
538 # (the OCaml runtime assumes Java-style behavior of signed integer arith.)
539 # Concerning optimization level, -O3 is somewhat risky, so take -O2.
540 # Concerning language version, gnu99 is ISO C99 plus GNU extensions
541 # that are often used in standard headers. Older GCC versions
542 # defaults to gnu89, which is not C99. Clang defaults to gnu99 or
543 # gnu11, which is fine.
544
545 # Note: the vendor macro can not recognize MinGW because it calls the
546 # C preprocessor directly so no compiler specific macro like __MING32__
547 # is defined. We thus catch MinGW first by looking at host and examine
548 # the vendor only as a fall-back. We could put tis part of the logic
549 # in the macro itself, too
550 AS_CASE([$host],
551 [*-*-mingw32],
552 [internal_cflags="-Wno-unused $gcc_warnings"
553 # TODO: see whether the code can be fixed to avoid -Wno-unused
554 common_cflags="-O -mms-bitfields"
555 internal_cppflags='-DUNICODE -D_UNICODE'
556 internal_cppflags="$internal_cppflags -DWINDOWS_UNICODE="
557 internal_cppflags="${internal_cppflags}\$(WINDOWS_UNICODE)"],
558 [AS_CASE([$ocaml_cv_cc_vendor],
559 [clang-*],
560 [common_cflags="-O2 -fno-strict-aliasing -fwrapv";
561 internal_cflags="$gcc_warnings -fno-common"],
562 [gcc-[012]-*],
563 # Some versions known to miscompile OCaml, e,g, 2.7.2.1, some 2.96.
564 # Plus: C99 support unknown.
565 [AC_MSG_ERROR([This version of GCC is too old.
566 Please use GCC version 4.2 or above.])],
567 [gcc-3-*|gcc-4-[01]],
568 # No -fwrapv option before GCC 3.4.
569 # Known problems with -fwrapv fixed in 4.2 only.
570 [AC_MSG_WARN([This version of GCC is rather old.
571 Reducing optimization level."]);
572 AC_MSG_WARN([Consider using GCC version 4.2 or above.]);
573 common_cflags="-std=gnu99 -O";
574 internal_cflags="$gcc_warnings"],
575 [gcc-4-*],
576 [common_cflags="-std=gnu99 -O2 -fno-strict-aliasing -fwrapv \
577 -fno-builtin-memcmp";
578 internal_cflags="$gcc_warnings"],
579 [gcc-*],
580 [common_cflags="-O2 -fno-strict-aliasing -fwrapv";
581 internal_cflags="$gcc_warnings -fno-common"],
582 [msvc-*],
583 [common_cflags="-nologo -O2 -Gy- -MD"
584 common_cppflags="-D_CRT_SECURE_NO_DEPRECATE"
585 internal_cppflags='-DUNICODE -D_UNICODE'
586 internal_cppflags="$internal_cppflags -DWINDOWS_UNICODE="
587 internal_cppflags="${internal_cppflags}\$(WINDOWS_UNICODE)"],
588 [xlc-*],
589 [common_cflags="-O5 -qtune=balanced -qnoipa -qinline $CFLAGS";
590 internal_cflags="$gcc_warnings"],
591 [common_cflags="-O"])])
592
593 internal_cppflags="-DCAML_NAME_SPACE $internal_cppflags"
594
595 # Enable SSE2 on x86 mingw to avoid using 80-bit registers.
596 AS_CASE([$host],
597 [i686-*-mingw32],
598 [internal_cflags="$internal_cflags -mfpmath=sse -msse2"])
599
600 # Use 64-bit file offset if possible
601 # See also AC_SYS_LARGEFILE
602 # Problem: flags are added to CC rather than CPPFLAGS
603 AS_CASE([$host],
604 [*-*-mingw32|*-pc-windows], [],
605 [common_cppflags="$common_cppflags -D_FILE_OFFSET_BITS=64"])
606
607 # Adjust according to target
608
609 # On Windows we do not take $enable_shared because it does not seem
610 # to work. This should be better understood later
611 #AS_CASE([$target],
612 # [*-pc-windows],
613 # [enable_shared=yes])
614
615 AS_IF([test x"$enable_shared" = "xno"],[with_sharedlibs=false])
616
617 AS_CASE([$CC,$host],
618 [*,*-*-darwin*],
619 [mkexe="$mkexe -Wl,-no_compact_unwind";
620 AC_DEFINE([HAS_ARCH_CODE32], [1])],
621 [*,*-*-haiku*], [mathlib=""],
622 [*,*-*-cygwin*],
623 [AS_CASE([$target],
624 [i686-*], [flavor=cygwin],
625 [x86_64-*], [flavor=cygwin64],
626 [AC_MSG_ERROR([unknown cygwin variant])])
627 common_cppflags="$common_cppflags -U_WIN32"
628 AS_IF([$with_sharedlibs],
629 [flexlink="flexlink -chain $flavor -merge-manifest -stack 16777216"
630 flexdir=`$flexlink -where | tr -d '\015'`
631 AS_IF([test -z "$flexdir"],
632 [AC_MSG_WARN(
633 [flexlink not found: native shared libraries won't be available.]
634 )
635 with_sharedlibs=false],
636 [iflexdir="-I\"$flexdir\""
637 mkexe="$flexlink -exe"
638 mkexedebugflag="-link -g"]
639 )]
640 )
641 AS_IF([! $with_sharedlibs],
642 [mkexe="$mkexe -Wl,--stack,16777216"
643 oc_ldflags="-Wl,--stack,16777216"]
644 )
645 ostype="Cygwin"],
646 [*,*-*-mingw32],
647 [AS_IF([$with_sharedlibs],
648 [AS_CASE([$host],
649 [i686-*-*], [flexdll_chain="mingw"],
650 [x86_64-*-*], [flexdll_chain="mingw64"])
651 flexlink="flexlink -chain $flexdll_chain -merge-manifest -stack 16777216"
652 flexdir=`$flexlink -where | tr -d '\015'`
653 AS_IF([test -z "$flexdir"], [flexdir='$(ROOTDIR)/flexdll'])
654 iflexdir="-I\"$flexdir\""
655 mkexedebugflag="-link -g"])
656 ostype="Win32"
657 toolchain="mingw"
658 mkexe='$(MKEXE_ANSI) $(if $(OC_LDFLAGS),-link "$(OC_LDFLAGS)")'
659 oc_ldflags='-municode'
660 SO="dll"],
661 [*,*-pc-windows],
662 [toolchain=msvc
663 ostype="Win32"
664 mkexe='$(MKEXE_ANSI) $(if $(OC_LDFLAGS),-link "$(OC_LDFLAGS)")'
665 oc_ldflags='/ENTRY:wmainCRTStartup'
666 AS_CASE([$host],
667 [i686-pc-windows], [flexdll_chain=msvc],
668 [x86_64-pc-windows], [flexdll_chain=msvc64])
669 AS_IF([$with_sharedlibs],
670 [flexlink="flexlink -chain $flexdll_chain -merge-manifest -stack 16777216"
671 flexdir=`$flexlink -where | tr -d '\015'`
672 AS_IF([test -z "$flexdir"], [flexdir='$(ROOTDIR)/flexdll'])
673 iflexdir="-I\"$flexdir\""
674 mkexedebugflag=''])],
675 [*,x86_64-*-linux*],
676 AC_DEFINE([HAS_ARCH_CODE32], [1]),
677 [xlc*,powerpc-ibm-aix*],
678 [mkexe="$mkexe "
679 oc_ldflags="-brtl -bexpfull"
680 AC_DEFINE([HAS_ARCH_CODE32], [1])],
681 )
682
683
684 ## Program to use to install files
685 AC_PROG_INSTALL
686
687 # Checks for libraries
688
689 ## Mathematical library
690 AC_CHECK_LIB([m],[cos])
691
692 AS_IF([test "x$ac_cv_lib_m_cos" = xyes ], [mathlib="-lm"], [mathlib=""])
693
694 # Checks for header files
695
696 AC_CHECK_HEADER([math.h])
697 AC_CHECK_HEADERS([unistd.h],[AC_DEFINE([HAS_UNISTD])])
698 AC_CHECK_HEADER([stdint.h],[AC_DEFINE([HAS_STDINT_H])])
699 AC_CHECK_HEADER([sys/shm.h],[AC_DEFINE([HAS_SYS_SHM_H])])
700 AC_CHECK_HEADER([dirent.h], [AC_DEFINE([HAS_DIRENT])], [],
701 [#include <sys/types.h>])
702
703 AC_CHECK_HEADER([sys/select.h], [AC_DEFINE([HAS_SYS_SELECT_H])], [],
704 [#include <sys/types.h>])
705
706 # Checks for types
707
708 ## off_t
709 AC_TYPE_OFF_T
710
711 # Checks for structures
712
713 # Checks for compiler characteristics
714
715 AC_CHECK_SIZEOF(int)
716 AC_CHECK_SIZEOF(long)
717 AC_CHECK_SIZEOF(long *)
718 AC_CHECK_SIZEOF(short)
719 AC_CHECK_SIZEOF(long long)
720
721 AS_IF(
722 [test "x$ac_cv_sizeof_long_p" = "x4" ],
723 [bits=32; arch64=false],
724 [test "x$ac_cv_sizeof_long_p" = "x8" ],
725 [bits=64; arch64=true
726 AC_DEFINE([ARCH_SIXTYFOUR], [1])],
727 [AC_MSG_ERROR([Neither 32 nor 64 bits architecture.])]
728 )
729
730 AS_IF([test "x$ac_cv_sizeof_int" != "x4" && test "x$ac_cv_sizeof_long" != "x4" \
731 && test "x$ac_cv_sizeof_short" != "x4"],
732 [AC_MSG_ERROR([Sorry, we can't find a 32-bit integer type.])]
733 )
734
735 AS_IF(
736 [test "x$ac_cv_sizeof_long" != "x8" &&
737 test "x$ac_cv_sizeof_long_long" != "x8"],
738 [AC_MSG_ERROR([Sorry, we can't find a 64-bit integer type.])]
739 )
740
741 AC_DEFINE_UNQUOTED([SIZEOF_PTR], [$ac_cv_sizeof_long_p])
742 AC_DEFINE_UNQUOTED([SIZEOF_LONGLONG], [$ac_cv_sizeof_long_long])
743
744 AC_MSG_NOTICE([Target is a $bits bits architecture])
745
746 AC_C_BIGENDIAN(
747 [AC_DEFINE([ARCH_BIG_ENDIAN], [1])],
748 [],
749 [AC_MSG_ERROR([could not determine endianness.])],
750 [AC_MSG_ERROR([unable to handle universal endianness])]
751 )
752
753 AC_CHECK_ALIGNOF([double])
754 AC_CHECK_ALIGNOF([long])
755
756 AS_IF([! $arch64],
757 [AS_CASE([$target_cpu],
758 [i686], [],
759 [AS_IF([test "$ac_cv_alignof_double" -gt 4],
760 [AC_DEFINE([ARCH_ALIGN_DOUBLE], [1])])
761 AS_IF([test "$ac_cv_alignof_long" -gt 4],
762 [AC_DEFINE([ARCH_ALIGN_LONG], [1])])
763 ])])
764
765 # Shared library support
766
767 shared_libraries_supported=false
768 sharedlib_cflags=''
769 mksharedlib='shared-libs-not-available'
770 rpath=''
771 mksharedlibrpath=''
772 natdynlinkopts=""
773
774 AS_IF([test x"$enable_shared" != "xno"],
775 [AS_CASE([$host],
776 [*-apple-darwin*],
777 [mksharedlib="$CC -shared -flat_namespace -undefined suppress \
778 -Wl,-no_compact_unwind"
779 shared_libraries_supported=true],
780 [*-*-mingw32],
781 [mksharedlib='$(FLEXLINK)'
782 mkmaindll='$(FLEXLINK) -maindll'
783 shared_libraries_supported=$with_sharedlibs],
784 [*-pc-windows],
785 [mksharedlib='$(FLEXLINK)'
786 mkmaindll='$(FLEXLINK) -maindll'
787 shared_libraries_supported=$with_sharedlibs],
788 [*-*-cygwin*],
789 [mksharedlib="$flexlink"
790 mkmaindll="$flexlink -maindll"
791 shared_libraries_supported=true],
792 [powerpc-ibm-aix*],
793 [AS_CASE([$CC],
794 [xlc*],
795 [mksharedlib="$CC -qmkshrobj -G"
796 shared_libraries_supported=true])],
797 [[*-*-linux*|*-*-freebsd[3-9]*|*-*-freebsd[1-9][0-9]*\
798 |*-*-openbsd*|*-*-netbsd*|*-*-dragonfly*|*-*-gnu*|*-*-haiku*]],
799 [sharedlib_cflags="-fPIC"
800 mksharedlib="$CC -shared"
801 oc_ldflags="$oc_ldflags -Wl,-E"
802 rpath="-Wl,-rpath,"
803 mksharedlibrpath="-Wl,-rpath,"
804 natdynlinkopts="-Wl,-E"
805 shared_libraries_supported=true])])
806
807 AS_IF([test -z "$mkmaindll"], [mkmaindll=$mksharedlib])
808
809 # Configure native dynlink
810
811 natdynlink=false
812
813 AS_IF([test x"$enable_shared" != "xno"],
814 [AS_CASE(["$host"],
815 [*-*-cygwin*], [natdynlink=true],
816 [*-*-mingw32], [natdynlink=true],
817 [*-pc-windows], [natdynlink=true],
818 [[i[3456]86-*-linux*]], [natdynlink=true],
819 [[i[3456]86-*-gnu*]], [natdynlink=true],
820 [[x86_64-*-linux*]], [natdynlink=true],
821 [x86_64-*-darwin*], [natdynlink=true],
822 [s390x*-*-linux*], [natdynlink=true],
823 [powerpc*-*-linux*], [natdynlink=true],
824 [i686-*-kfreebsd*], [natdynlink=true],
825 [x86_64-*-kfreebsd*], [natdynlink=true],
826 [x86_64-*-dragonfly*], [natdynlink=true],
827 [[i[3456]86-*-freebsd*]], [natdynlink=true],
828 [x86_64-*-freebsd*], [natdynlink=true],
829 [[i[3456]86-*-openbsd*]], [natdynlink=true],
830 [x86_64-*-openbsd*], [natdynlink=true],
831 [[i[3456]86-*-netbsd*]], [natdynlink=true],
832 [x86_64-*-netbsd*], [natdynlink=true],
833 [i386-*-gnu0.3], [natdynlink=true],
834 [[i[3456]86-*-haiku*]], [natdynlink=true],
835 [arm*-*-linux*], [natdynlink=true],
836 [arm*-*-freebsd*], [natdynlink=true],
837 [earm*-*-netbsd*], [natdynlink=true],
838 [aarch64-*-linux*], [natdynlink=true],
839 [aarch64-*-freebsd*], [natdynlink=true])])
840
841 # Try to work around the Skylake/Kaby Lake processor bug.
842 AS_CASE(["$CC,$host"],
843 [*gcc*,x86_64-*|*gcc*,i686-*],
844 [OCAML_CC_HAS_FNO_TREE_VRP
845 AS_IF([$cc_has_fno_tree_vrp],
846 [internal_cflags="$internal_cflags -fno-tree-vrp"])])
847
848 OCAML_CC_SUPPORTS_ALIGNED
849
850 # Configure the native-code compiler
851
852 arch=none
853 model=default
854 system=unknown
855
856 AS_CASE([$host],
857 [[i[3456]86-*-linux*]],
858 [arch=i386; system=linux_elf],
859 [[i[3456]86-*-*bsd*]],
860 [arch=i386; system=bsd_elf],
861 [[i[3456]86-*-haiku*]],
862 [arch=i386; system=beos],
863 [[i[3456]86-*-cygwin]],
864 [arch=i386; system=cygwin],
865 [[i[3456]86-*-gnu*]],
866 [arch=i386; system=gnu],
867 [[i[3456]86-*-mingw32]],
868 [arch=i386; system=mingw],
869 [i686-pc-windows],
870 [arch=i386; system=win32],
871 [x86_64-pc-windows],
872 [arch=amd64; system=win64],
873 [[powerpc64le*-*-linux*]],
874 [arch=power; model=ppc64le; system=elf],
875 [[powerpc*-*-linux*]],
876 [arch=power; AS_IF([$arch64],[model=ppc64],[model=ppc]); system=elf],
877 [[s390x*-*-linux*]],
878 [arch=s390x; model=z10; system=elf],
879 [armv6*-*-linux-gnueabihf],
880 [arch=arm; model=armv6; system=linux_eabihf],
881 [armv7*-*-linux-gnueabihf],
882 [arch=arm; model=armv7; system=linux_eabihf],
883 [armv8*-*-linux-gnueabihf],
884 [arch=arm; model=armv8; system=linux_eabihf],
885 [armv8*-*-linux-gnueabi],
886 [arch=arm; model=armv8; system=linux_eabi],
887 [armv7*-*-linux-gnueabi],
888 [arch=arm; model=armv7; system=linux_eabi],
889 [armv6t2*-*-linux-gnueabi],
890 [arch=arm; model=armv6t2; system=linux_eabi],
891 [armv6*-*-linux-gnueabi],
892 [arch=arm; model=armv6; system=linux_eabi],
893 [armv6*-*-freebsd*],
894 [arch=arm; model=armv6; system=freebsd],
895 [earmv6*-*-netbsd*],
896 [arch=arm; model=armv6; system=netbsd],
897 [earmv7*-*-netbsd*],
898 [arch=arm; model=armv7; system=netbsd],
899 [armv5te*-*-linux-gnueabi],
900 [arch=arm; model=armv5te; system=linux_eabi],
901 [armv5*-*-linux-gnueabi],
902 [arch=arm; model=armv5; system=linux_eabi],
903 [arm*-*-linux-gnueabihf],
904 [arch=arm; system=linux_eabihf],
905 [arm*-*-linux-gnueabi],
906 [arch=arm; system=linux_eabi],
907 [arm*-*-openbsd*],
908 [arch=arm; system=bsd],
909 [zaurus*-*-openbsd*],
910 [arch=arm; system=bsd],
911 [x86_64-*-linux*],
912 [arch=amd64; system=linux],
913 [x86_64-*-gnu*],
914 [arch=amd64; system=gnu],
915 [x86_64-*-dragonfly*],
916 [arch=amd64; system=dragonfly],
917 [x86_64-*-freebsd*],
918 [arch=amd64; system=freebsd],
919 [x86_64-*-netbsd*],
920 [arch=amd64; system=netbsd],
921 [x86_64-*-openbsd*],
922 [arch=amd64; system=openbsd],
923 [x86_64-*-darwin*],
924 [arch=amd64; system=macosx],
925 [x86_64-*-mingw32],
926 [arch=amd64; system=mingw64],
927 [aarch64-*-linux*],
928 [arch=arm64; system=linux],
929 [aarch64-*-freebsd*],
930 [arch=arm64; system=freebsd],
931 [x86_64-*-cygwin*],
932 [arch=amd64; system=cygwin]
933 )
934
935 AS_IF([test x"$enable_native_compiler" = "xno"],
936 [arch=none; model=default; system=unknown; native_compiler=false
937 AC_MSG_NOTICE([the native compiler is disabled])],
938 [native_compiler=true])
939
940 AS_IF([! $native_compiler], [natdynlink=false])
941
942 AS_IF([$natdynlink], [cmxs="cmxs"], [cmxs="cmx"])
943
944 AC_DEFINE_UNQUOTED([OCAML_OS_TYPE], ["$ostype"])
945
946 AC_CHECK_TOOL([DIRECT_LD],[ld])
947 AS_IF([test -z "$PARTIALLD"],
948 # The string for PACKLD must be capable of being concatenated with the
949 # output filename. Don't assume that all C compilers understand GNU -ofoo
950 # form, so ensure that the definition includes a space at the end (which is
951 # achieved using the $(EMPTY) expansion trick).
952 [AS_CASE(["$arch,$CC,$system,$model"],
953 [amd64,gcc*,macosx,*], [PACKLD='ld -r -arch x86_64 -o $(EMPTY)'],
954 [amd64,gcc*,solaris,*], [PACKLD='ld -r -m elf_x86_64 -o $(EMPTY)'],
955 [power,gcc*,elf,ppc], [PACKLD='ld -r -m elf32ppclinux -o $(EMPTY)'],
956 [power,gcc*,elf,ppc64], [PACKLD='ld -r -m elf64ppc -o $(EMPTY)'],
957 [power,gcc*,elf,ppc64le], [PACKLD='ld -r -m elf64lppc -o $(EMPTY)'],
958 # For the Microsoft C compiler there must be no space at the end of the
959 # string.
960 [*,cl,*,*], [PACKLD="link -lib -nologo $machine -out:"],
961 [PACKLD="$DIRECT_LD -r -o \$(EMPTY)"])],
962 [PACKLD="$PARTIALLD -o \$(EMPTY)"])
963
964 AS_IF([test $arch != "none" && $arch64 ],
965 [otherlibraries="$otherlibraries raw_spacetime_lib"])
966
967 # Assembler
968
969 AS_IF([test -n "$host_alias"], [toolpref="${host_alias}-"], [toolpref=""])
970
971 # We first compute default values for as and aspp
972 # If values have been given by the user then they take precedence over
973 # those just computed
974 # One may want to check whether the user provided values first
975 # and only compute values if none has been provided
976
977 AS_CASE(["$arch,$system"],
978 [i386,win32],
979 [default_as="ml -nologo -coff -Cp -c -Fo"],
980 [amd64,win64],
981 [default_as="ml64 -nologo -Cp -c -Fo"],
982 [amd64,macosx],
983 [AS_CASE([$ocaml_cv_cc_vendor],
984 [clang-*],
985 [default_as='clang -arch x86_64 -Wno-trigraphs -c'
986 default_aspp='clang -arch x86_64 -Wno-trigraphs -c'],
987 [default_as="${toolpref}as -arch x86_64"
988 default_aspp="${toolpref}gcc -arch x86_64 -c"])],
989 [amd64,solaris],
990 [default_as="${toolpref}as --64"
991 default_aspp="${toolpref}gcc -m64 -c"],
992 [i386,solaris],
993 [default_as="${toolpref}as"
994 default_aspp="${toolpref}gcc -c"],
995 [power,elf],
996 [AS_CASE([$model],
997 [ppc64le],
998 [default_as="${toolpref}as -a64 -mpower8"
999 default_aspp="${toolpref}gcc -m64 -mcpu=powerpc64le -c"],
1000 [ppc64],
1001 [default_as="${toolpref}as -a64 -mppc64"
1002 default_aspp="${toolpref}gcc -m64 -c"],
1003 [ppc],
1004 [default_as="${toolpref}as -mppc"
1005 default_aspp="${toolpref}gcc -m32 -c"])],
1006 [s390x,elf],
1007 [default_as="${toolpref}as -m 64 -march=$model"
1008 default_aspp="${toolpref}gcc -c -Wa,-march=$model"],
1009 [arm,freebsd|arm64,freebsd],
1010 [default_as="${toolpref}cc -c"
1011 default_aspp="${toolpref}cc -c"],
1012 [*,dragonfly],
1013 [default_as="${toolpref}as"
1014 default_aspp="${toolpref}cc -c"],
1015 [*,freebsd],
1016 [default_as="${toolpref}as"
1017 default_aspp="${toolpref}cc -c"],
1018 [amd64,*|arm,*|arm64,*|i386,*],
1019 [default_as="${toolpref}as"
1020 AS_CASE([$ocaml_cv_cc_vendor],
1021 [clang-*], [default_aspp="${toolpref}clang -c -Wno-trigraphs"],
1022 [default_aspp="${toolpref}gcc -c"])])
1023
1024 AS_IF([test "$with_pic"],
1025 [fpic=true
1026 AC_DEFINE([CAML_WITH_FPIC])
1027 internal_cflags="$internal_cflags $sharedlib_cflags"
1028 default_aspp="$default_aspp $sharedlib_cflags"],
1029 [fpic=false])
1030
1031 AS_IF([test -z "$AS"], [AS="$default_as"])
1032
1033 AS_IF([test -z "$ASPP"], [ASPP="$default_aspp"])
1034
1035 # Checks for library functions
1036
1037 ## Check the semantics of signal handlers
1038 OCAML_SIGNAL_HANDLERS_SEMANTICS
1039
1040 ## Check for C99 float ops
1041
1042 # Note: this was disabled on Windows but the autoconf-generated script
1043 # does find the function it is looking for.
1044 # however the fma test does not pass so we disable the feature
1045 # for the moment, to be backward-compatible
1046
1047 AS_CASE([$host],
1048 [*-*-mingw32|*-pc-windows], [],
1049 [has_c99_float_ops=true
1050 AC_CHECK_FUNC([expm1], [], [has_c99_float_ops=false])
1051 AS_IF([$has_c99_float_ops],
1052 [AC_CHECK_FUNC([log1p], [], [has_c99_float_ops=false])])
1053 AS_IF([$has_c99_float_ops],
1054 [AC_CHECK_FUNC([hypot], [], [has_c99_float_ops=false])])
1055 AS_IF([$has_c99_float_ops],
1056 [AC_CHECK_FUNC([fma], [
1057 AS_CASE([$target],[x86_64-*-cygwin],[],[AC_DEFINE([HAS_WORKING_FMA])])],
1058 [has_c99_float_ops=false])])
1059 AS_IF([$has_c99_float_ops],
1060 [AC_CHECK_FUNC([copysign], [AC_DEFINE([HAS_C99_FLOAT_OPS])])])])
1061
1062 ## getrusage
1063 AC_CHECK_FUNC([getrusage], [AC_DEFINE([HAS_GETRUSAGE])])
1064
1065 ## times
1066 AC_CHECK_FUNC([times], [AC_DEFINE([HAS_TIMES])])
1067
1068 ## secure_getenv and __secure_getenv
1069
1070 saved_CPPFLAGS="$CPPFLAGS"
1071 CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
1072
1073 AC_CHECK_FUNC([secure_getenv],
1074 [AC_DEFINE([HAS_SECURE_GETENV])],
1075 [AC_CHECK_FUNC([__secure_getenv], [AC_DEFINE([HAS___SECURE_GETENV])])])
1076
1077 CPPFLAGS="$saved_CPPFLAGS"
1078
1079 ## issetugid
1080
1081 AC_CHECK_FUNC([issetugid], [AC_DEFINE([HAS_ISSETUGID])])
1082
1083 ## clock_gettime, for the instrumented runtime
1084
1085 ## Note: on MinGW, configure finds a clock_gettime and thus the build
1086 # system tries to build the instrumented runtime, which causes
1087 # warnings. For the moment we simply disable it on MinGW
1088 # but this would need to be further investigated
1089 AS_CASE([$host],
1090 [*-*-mingw32], [instrumented_runtime=false],
1091 [AS_IF([test "x$enable_instrumented_runtime" = "xno" ],
1092 [instrumented_runtime=false; instrumented_runtime_libs=""],
1093 [
1094 AC_SEARCH_LIBS([clock_gettime], [rt],
1095 [has_clock_gettime=true],
1096 [has_clock_gettime=false])
1097 AS_CASE([$enable_instrumented_runtime,$has_clock_gettime],
1098 [*,true],
1099 [instrumented_runtime=true
1100 AS_IF([test "x$ac_cv_search_clock_gettime" = "xnone required"],
1101 [instrumented_runtime_libs=""],
1102 [instrumented_runtime_libs=$ac_cv_search_clock_gettime])],
1103 [auto,*],
1104 [instrumented_runtime=false],
1105 [yes,*],
1106 [AC_MSG_ERROR([the instrumented runtime can not be built])])])])
1107
1108 ## Sockets
1109
1110 ## TODO: check whether the different libraries are really useful
1111
1112 sockets=false
1113
1114 AS_CASE([$host],
1115 [*-*-mingw32|*-pc-windows],
1116 [cclibs="$cclibs -lws2_32"
1117 sockets=true],
1118 [
1119 AC_CHECK_FUNC([socket])
1120 AC_CHECK_FUNC([socketpair])
1121 AC_CHECK_FUNC([bind])
1122 AC_CHECK_FUNC([listen])
1123 AC_CHECK_FUNC([accept])
1124 AC_CHECK_FUNC([connect])
1125 sockets=true
1126 ]
1127 )
1128
1129 AS_IF([$sockets], [AC_DEFINE([HAS_SOCKETS])])
1130
1131 ## socklen_t in sys/socket.h
1132
1133 AC_CHECK_TYPE(
1134 [socklen_t],
1135 [AC_DEFINE([HAS_SOCKLEN_T])], [],
1136 [#include <sys/socket.h>])
1137
1138 AC_CHECK_FUNC([inet_aton], [AC_DEFINE([HAS_INET_ATON])])
1139
1140 ## IPv6 support
1141
1142 ipv6=true
1143
1144 AC_CHECK_TYPE(
1145 [struct sockaddr_in6], [], [ipv6=false],
1146 [
1147 #include <sys/types.h>
1148 #include <sys/socket.h>
1149 #include <netinet/in.h>
1150 ]
1151 )
1152
1153 AS_IF([$ipv6],
1154 [AC_CHECK_FUNC([getaddrinfo], [], [ipv6=false])])
1155
1156 AS_IF([$ipv6],
1157 [AC_CHECK_FUNC([getnameinfo], [], [ipv6=false])])
1158
1159 AS_IF([$ipv6],
1160 [AC_CHECK_FUNC([inet_pton], [], [ipv6=false])])
1161
1162 AS_IF([$ipv6],
1163 [AC_CHECK_FUNC([inet_ntop], [AC_DEFINE([HAS_IPV6])])])
1164
1165 AC_CHECK_FUNC([rewinddir], [AC_DEFINE([HAS_REWINDDIR])])
1166
1167 AC_CHECK_FUNC([lockf], [AC_DEFINE([HAS_LOCKF])])
1168
1169 AC_CHECK_FUNC([mkfifo], [AC_DEFINE([HAS_MKFIFO])])
1170
1171 AC_CHECK_FUNC([getcwd], [AC_DEFINE([HAS_GETCWD])])
1172
1173 ## utime
1174 ## Note: this was defined in config/s-nt.h but the autoconf macros do not
1175 # seem to detect it properly on Windows so we hardcode the definition
1176 # of HAS_UTIME on Windows but this will probably need to be clarified
1177 AS_CASE([$host],
1178 [*-*-mingw32|*-pc-windows], [AC_DEFINE([HAS_UTIME])],
1179 [AC_CHECK_HEADER([sys/types.h],
1180 [AC_CHECK_HEADER([utime.h],
1181 [AC_CHECK_FUNC([utime], [AC_DEFINE([HAS_UTIME])])])])])
1182
1183 AC_CHECK_FUNC([utimes], [AC_DEFINE([HAS_UTIMES])])
1184
1185 AC_CHECK_FUNC([fchmod],
1186 [AC_CHECK_FUNC([fchown], [AC_DEFINE([HAS_FCHMOD])])])
1187
1188 AC_CHECK_FUNC([truncate],
1189 [AC_CHECK_FUNC([ftruncate], [AC_DEFINE([HAS_TRUNCATE])])])
1190
1191 ## select
1192 AC_CHECK_FUNC([select],
1193 [AC_CHECK_TYPE([fd_set],
1194 [AC_DEFINE([HAS_SELECT])
1195 select=true], [select=false], [
1196 #include <sys/types.h>
1197 #include <sys/select.h>
1198 ])])
1199
1200 AC_CHECK_FUNC([nanosleep], [AC_DEFINE([HAS_NANOSLEEP])])
1201
1202 AC_CHECK_FUNC([symlink],
1203 [AC_CHECK_FUNC([readlink],
1204 [AC_CHECK_FUNC([lstat], [AC_DEFINE([HAS_SYMLINK])])])])
1205
1206 # wait
1207 AC_CHECK_FUNC(
1208 [waitpid],
1209 [
1210 wait=true
1211 AC_DEFINE([HAS_WAITPID])
1212 ],
1213 [wait=false])
1214
1215 AC_CHECK_FUNC(
1216 [wait4],
1217 [
1218 has_wait=true
1219 AC_DEFINE([HAS_WAIT4])
1220 ])
1221
1222 ## getgroups
1223 AC_CHECK_FUNC([getgroups], [AC_DEFINE([HAS_GETGROUPS])])
1224
1225 ## setgroups
1226 AC_CHECK_FUNC([setgroups], [AC_DEFINE([HAS_SETGROUPS])])
1227
1228 ## initgroups
1229 AC_CHECK_FUNC([initgroups], [AC_DEFINE([HAS_INITGROUPS])])
1230
1231 ## termios
1232
1233 AC_CHECK_HEADER([termios.h],
1234 [AC_CHECK_FUNC([tcgetattr],
1235 [AC_CHECK_FUNC([tcsetattr],
1236 [AC_CHECK_FUNC([tcsendbreak],
1237 [AC_CHECK_FUNC([tcflush],
1238 [AC_CHECK_FUNC([tcflow], [AC_DEFINE([HAS_TERMIOS])])])])])])])
1239
1240 ## setitimer
1241
1242 AC_CHECK_FUNC([setitimer],
1243 [
1244 setitimer=true
1245 AC_DEFINE([HAS_SETITIMER])
1246 ],
1247 [setitimer=false])
1248
1249 ## gethostname
1250 # Note: detection fails on Windows so hardcoding the result
1251 # (should be debugged later)
1252 AS_CASE([$host],
1253 [*-*-mingw32|*-pc-windows], [AC_DEFINE([HAS_GETHOSTNAME])],
1254 [AC_CHECK_FUNC([gethostname], [AC_DEFINE([HAS_GETHOSTNAME])])])
1255
1256 ## uname
1257
1258 AC_CHECK_HEADER([sys/utsname.h],
1259 [AC_CHECK_FUNC([uname], [AC_DEFINE([HAS_UNAME])])])
1260
1261 ## gettimeofday
1262
1263 AC_CHECK_FUNC([gettimeofday],
1264 [
1265 gettimeofday=true
1266 AC_DEFINE([HAS_GETTIMEOFDAY])
1267 ],
1268 [gettimeofday=false])
1269
1270 ## mktime
1271
1272 AC_CHECK_FUNC([mktime], [AC_DEFINE([HAS_MKTIME])])
1273
1274 ## setsid
1275
1276 AS_CASE([$host],
1277 [*-cygwin|*-*-mingw32|*-pc-windows], [],
1278 [AC_CHECK_FUNC([setsid], [AC_DEFINE([HAS_SETSID])])])
1279
1280 ## putenv
1281
1282 AC_CHECK_FUNC([putenv], [AC_DEFINE([HAS_PUTENV])])
1283
1284 ## newlocale() and <locale.h>
1285 # Note: the detection fails on msvc so we hardcode the result
1286 # (should be debugged later)
1287 AS_CASE([$host],
1288 [*-pc-windows], [AC_DEFINE([HAS_LOCALE_H])],
1289 [AC_CHECK_HEADER([locale.h],
1290 [AC_CHECK_FUNC([newlocale],
1291 [AC_CHECK_FUNC([freelocale],
1292 [AC_CHECK_FUNC([uselocale], [AC_DEFINE([HAS_LOCALE_H])])])])])])
1293
1294 AC_CHECK_HEADER([xlocale.h],
1295 [AC_CHECK_FUNC([newlocale],
1296 [AC_CHECK_FUNC([freelocale],
1297 [AC_CHECK_FUNC([uselocale], [AC_DEFINE([HAS_XLOCALE_H])])])])])
1298
1299 ## strtod_l
1300 # Note: not detected on MSVC so hardcoding the result
1301 # (should be debugged later)
1302 AS_CASE([$host],
1303 [*-pc-windows], [AC_DEFINE([HAS_STRTOD_L])],
1304 [AC_CHECK_FUNC([strtod_l], [AC_DEFINE([HAS_STRTOD_L])])])
1305
1306 ## shared library support
1307 AS_IF([$shared_libraries_supported],
1308 [AS_CASE([$host],
1309 [*-*-mingw32|*-pc-windows],
1310 [supports_shared_libraries=$shared_libraries_supported; DLLIBS=""],
1311 [AC_CHECK_FUNC([dlopen],
1312 [supports_shared_libraries=true DLLIBS=""],
1313 [AC_CHECK_LIB([dl], [dlopen],
1314 [supports_shared_libraries=true DLLIBS="-ldl $DLLIBS"],
1315 [supports_shared_libraries=false])])])],
1316 [supports_shared_libraries=false])
1317
1318 AS_IF([$supports_shared_libraries],
1319 [AC_MSG_NOTICE([Dynamic loading of shared libraries is supported.])
1320 AC_DEFINE([SUPPORT_DYNAMIC_LINKING])],
1321 [AC_MSG_NOTICE([Dynamic loading of shared libraries is not supported.])])
1322
1323 ## mmap
1324
1325 AC_CHECK_HEADER([sys/mman.h],
1326 [AC_CHECK_FUNC([mmap],
1327 [AC_CHECK_FUNC([munmap], [AC_DEFINE([HAS_MMAP])])])])
1328
1329 ## pwrite
1330
1331 AC_CHECK_FUNC([pwrite], [AC_DEFINE([HAS_PWRITE])])
1332
1333 ## -fdebug-prefix-map support by the C compiler
1334 AS_CASE([$CC,$host],
1335 [*,*-*-mingw32], [cc_has_debug_prefix_map=false],
1336 [*,*-pc-windows], [cc_has_debug_prefix_map=false],
1337 [xlc*,powerpc-ibm-aix*], [cc_has_debug_prefix_map=false],
1338 [OCAML_CC_HAS_DEBUG_PREFIX_MAP])
1339
1340 ## Does stat support nanosecond precision
1341
1342 AC_CHECK_MEMBER([struct stat.st_atim.tv_nsec],
1343 [stat_has_ns_precision=true
1344 AC_DEFINE([HAS_NANOSECOND_STAT], [1])],
1345 [],
1346 [
1347 AC_INCLUDES_DEFAULT
1348 #include <sys/stat.h>
1349 ])
1350
1351
1352 AS_IF([! $stat_has_ns_precision],
1353 [AC_CHECK_MEMBER([struct stat.st_atimespec.tv_nsec],
1354 [stat_has_ns_precision=true
1355 AC_DEFINE([HAS_NANOSECOND_STAT], [2])],
1356 [],
1357 [
1358 AC_INCLUDES_DEFAULT
1359 #include <sys/stat.h>
1360 ])])
1361
1362 AS_IF([! $stat_has_ns_precision],
1363 [AC_CHECK_MEMBER([struct stat.st_atimensec],
1364 [stat_has_ns_precision=true
1365 AC_DEFINE([HAS_NANOSECOND_STAT], [3])],
1366 [],
1367 [
1368 AC_INCLUDES_DEFAULT
1369 #include <sys/stat.h>
1370 ])])
1371
1372 AS_IF([$stat_has_ns_precision],
1373 [AC_MSG_NOTICE([stat supports nanosecond precision])],
1374 [AC_MSG_NOTICE([stat does not support nanosecond precision])])
1375
1376 # Number of arguments of gethostbyname_r
1377
1378 AX_FUNC_WHICH_GETHOSTBYNAME_R
1379
1380 AS_CASE([$ac_cv_func_which_gethostbyname_r],
1381 [six], [AC_DEFINE([HAS_GETHOSTBYNAME_R],[6])],
1382 [five], [AC_DEFINE([HAS_GETHOSTBYNAME_R],[5])],
1383 [three], [AC_MSG_WARN([OCaml does not support this variant])])
1384
1385 # Number of arguments of gethostbyaddr_r
1386
1387 AX_FUNC_WHICH_GETHOSTBYADDR_R
1388
1389 AS_CASE([$ac_cv_func_which_gethostbyaddr_r],
1390 [eight], [AC_DEFINE([HAS_GETHOSTBYADDR_R],[8])],
1391 [seven], [AC_DEFINE([HAS_GETHOSTBYADDR_R],[7])])
1392
1393 ## mkstemp
1394
1395 AC_CHECK_FUNC([mkstemp], [AC_DEFINE([HAS_MKSTEMP])])
1396
1397 ## nice
1398
1399 AC_CHECK_FUNC([nice], [AC_DEFINE([HAS_NICE])])
1400
1401 ## dup3
1402
1403 AC_CHECK_FUNC([dup3], [AC_DEFINE([HAS_DUP3])])
1404
1405 ## pipe2
1406
1407 AC_CHECK_FUNC([pipe2], [AC_DEFINE([HAS_PIPE2])])
1408
1409 ## accept4
1410
1411 AC_CHECK_FUNC([accept4], [AC_DEFINE([HAS_ACCEPT4])])
1412
1413 ## getauxval
1414
1415 AC_CHECK_FUNC([getauxval], [AC_DEFINE([HAS_GETAUXVAL])])
1416
1417 ## execvpe
1418
1419 AC_CHECK_FUNC([execvpe], [AC_DEFINE([HAS_EXECVPE])])
1420
1421 ## ffs or _BitScanForward
1422
1423 AC_CHECK_FUNC([ffs], [AC_DEFINE([HAS_FFS])])
1424 AC_CHECK_FUNC([_BitScanForward], [AC_DEFINE([HAS_BITSCANFORWARD])])
1425
1426 ## Determine whether the debugger should/can be built
1427
1428 AS_CASE([$enable_debugger],
1429 [no],
1430 [with_debugger=""
1431 AC_MSG_NOTICE([replay debugger disabled])],
1432 [AS_IF([$sockets],
1433 [with_debugger="ocamldebugger"
1434 AC_MSG_NOTICE([replay debugger supported])],
1435 [with_debugger=""
1436 AC_MSG_NOTICE([replay debugger not supported])])
1437 ])
1438
1439 ## Should the runtime with debugging support be built
1440 AS_CASE([$enable_debug_runtime],
1441 [no], [debug_runtime=false],
1442 [debug_runtime=true])
1443
1444 ## Determine if system stack overflows can be detected
1445
1446 AC_MSG_CHECKING([whether stack overflows can be detected])
1447
1448 AS_CASE([$arch,$system],
1449 [i386,linux_elf|amd64,linux|amd64,macosx \
1450 |amd64,openbsd|i386,bsd_elf],
1451 [AC_DEFINE([HAS_STACK_OVERFLOW_DETECTION])
1452 AC_MSG_RESULT([yes])],
1453 [AC_MSG_RESULT([no])])
1454
1455 ## Determine if the POSIX threads library is supported
1456
1457 AS_IF([test x"$enable_systhreads" = "xno"],
1458 [systhread_support=false
1459 AC_MSG_NOTICE([the Win32/POSIX threads library is disabled])],
1460 [AS_CASE([$host],
1461 [*-*-mingw32|*-pc-windows],
1462 [systhread_support=true
1463 otherlibraries="$otherlibraries systhreads"
1464 AC_MSG_NOTICE([the Win32 threads library is supported])],
1465 [AX_PTHREAD(
1466 [systhread_support=true
1467 otherlibraries="$otherlibraries systhreads"
1468 AS_CASE([$host],
1469 [*-*-solaris*], [pthread_link="-lpthread -lposix4"],
1470 [*-*-haiku*], [pthread_link=""],
1471 [pthread_link="-lpthread"])
1472 common_cppflags="$common_cppflags -D_REENTRANT"
1473 AC_MSG_NOTICE([the POSIX threads library is supported])
1474 saved_CFLAGS="$CFLAGS"
1475 saved_LIBS="$LIBS"
1476 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1477 LIBS="$LIBS $pthread_link"
1478 AC_CHECK_FUNC([sigwait], [AC_DEFINE([HAS_SIGWAIT])])
1479 LIBS="$saved_LIBS"
1480 CFLAGS="$saved_CFLAGS"],
1481 [AS_IF([test x"$enable_systhreads" = "xyes"],
1482 [AC_MSG_ERROR([the POSIX thread library is not available])],
1483 [systhread_support=false
1484 AC_MSG_NOTICE([the POSIX threads library is not supported])])])])])
1485
1486 ## BFD (Binary File Description) library
1487
1488 bfd_cppflags=""
1489 bfd_ldflags=""
1490 bfd_ldlibs=""
1491
1492 AS_IF([test x"$with_bfd" != "xno"],
1493 [bfd_available=false
1494 AS_CASE([$host],
1495 [x86_64-*-darwin*],
1496 [AS_IF([test -z "$BFD_INCLUDE_DIR"],
1497 [BFD_INCLUDE_DIR="/opt/local/include"])
1498 AS_IF([test -z "$BFD_LIB_DIR"],
1499 [BFD_LIB_DIR="/opt/local/lib"])],
1500 [*-*openbsd*],
1501 [AS_IF([test -z "$BFD_INCLUDE_DIR"],
1502 [BFD_INCLUDE_DIR="/usr/local/include"])
1503 AS_IF([test -z "$BFD_LIB_DIR"],
1504 [BFD_LIB_DIR="/usr/local/lib"])])
1505 AS_IF([test -n "$BFD_INCLUDE_DIR"],
1506 [bfd_cppflags="-I$BFD_INCLUDE_DIR"])
1507 AS_IF([test -n "$BFD_LIB_DIR"],
1508 [bfd_ldflags="-L$BFD_LIB_DIR"])
1509 SAVED_CPPFLAGS="$CPPFLAGS"
1510 SAVED_LDFLAGS="$LDFLAGS"
1511 CPPFLAGS="$CPPFLAGS $bfd_cppflags"
1512 LDFLAGS="$LDFLAGS $bfd_ldflags"
1513 AC_CHECK_HEADER([bfd.h],
1514 [bfd_ldlibs=""
1515 AC_CHECK_LIB([bfd], [bfd_openr], [bfd_ldlibs="-lbfd"])
1516 AS_IF([test -z "$bfd_ldlibs"],
1517 [unset ac_cv_lib_bfd_bfd_openr
1518 AC_CHECK_LIB([bfd], [bfd_openr],
1519 [bfd_ldlibs="-lbfd $DLLIBS"], [], [$DLLIBS])])
1520 AS_IF([test -z "$bfd_ldlibs"],
1521 [unset ac_cv_lib_bfd_bfd_openr
1522 AC_CHECK_LIB([bfd], [bfd_openr],
1523 [bfd_ldlibs="-lbfd $DLLIBS -liberty"], [], [$DLLIBS -liberty])])
1524 AS_IF([test -z "$bfd_ldlibs"],
1525 [unset ac_cv_lib_bfd_bfd_openr
1526 AC_CHECK_LIB([bfd], [bfd_openr],
1527 [bfd_ldlibs="-lbfd $DLLIBS -liberty -lz"], [], [$DLLIBS -liberty -lz])])
1528 AS_IF([test -z "$bfd_ldlibs"],
1529 [unset ac_cv_lib_bfd_bfd_openr
1530 AC_CHECK_LIB([bfd], [bfd_openr],
1531 [bfd_ldlibs="-lbfd $DLLIBS -liberty -lz -lintl"], [],
1532 [$DLLIBS -liberty -lz -lintl])])
1533 AS_IF([test -n "$bfd_ldlibs"],
1534 [bfd_available=true
1535 AC_DEFINE([HAS_LIBBFD])])])
1536 AS_IF([! $bfd_available],
1537 [AS_IF([test x"$with_bfd" = "xyes"],
1538 [AC_MSG_ERROR([BFD library support requested but not available])],
1539 [bfd_cppflags=""
1540 bfd_ldflags=""
1541 AC_MSG_NOTICE(m4_normalize([
1542 BFD library not found, 'ocamlobjinfo' will be unable to display
1543 info on .cmxs files.
1544 ]))])])
1545 LDFLAGS="$SAVED_LDFLAGS"
1546 CPP_FLAGS="$SAVED_CPPFLAGS"],
1547 [AC_MSG_NOTICE(m4_normalize([
1548 Support for the BFD (Binary File Description) library disabled,
1549 'ocamlobjinfo' will be unable to display info on .cmxs files.
1550 ]))])
1551
1552 ## Does the assembler support debug prefix map and CFI directives
1553 as_has_debug_prefix_map=false
1554 asm_cfi_supported=false
1555 AS_IF([$native_compiler],
1556 [AS_CASE([$host],
1557 [*-*-mingw32|*-pc-windows], [],
1558 [OCAML_AS_HAS_DEBUG_PREFIX_MAP
1559 OCAML_AS_HAS_CFI_DIRECTIVES])])
1560
1561 ## Frame pointers
1562
1563 AS_IF([test x"$enable_frame_pointers" = "xyes"],
1564 [AS_CASE(["$host,$CC"],
1565 [x86_64-*-linux*,gcc*|x86_64-*-linux*,clang*],
1566 [common_cflags="$common_cflags -g -fno-omit-frame-pointer"
1567 frame_pointers=true
1568 AC_DEFINE([WITH_FRAME_POINTERS])
1569 AC_MSG_NOTICE([using frame pointers])],
1570 [AC_MSG_ERROR([frame pointers not supported on this platform])]
1571 )],
1572 [AC_MSG_NOTICE([not using frame pointers])
1573 frame_pointers=false])
1574
1575 ## No naked pointers
1576
1577 AS_IF([test x"$enable_naked_pointers" = "xno" ],
1578 [AC_DEFINE([NO_NAKED_POINTERS])])
1579
1580 ## Check for mmap support for huge pages and contiguous heap
1581 OCAML_MMAP_SUPPORTS_HUGE_PAGES
1582
1583 # Spacetime profiling, including libunwind detection
1584
1585 # The number of bits used for profiling information is configurable here.
1586 # The more bits used for profiling, the smaller will be Max_wosize.
1587 # Note that PROFINFO_WIDTH must still be defined even if not configuring
1588 # for Spacetime (see comment in runtime/caml/mlvalues.h on [Profinfo_hd]).
1589 AC_MSG_CHECKING([whether to build spacetime])
1590 AS_IF([test x"$enable_spacetime" != "xyes" ],
1591 [spacetime=false
1592 call_counts=true # as in original script but should probably be false
1593 libunwind_available=false
1594 libunwind_include_flags=
1595 libunwind_link_flags=
1596 AC_MSG_RESULT([no])],
1597 [AS_CASE([$arch],
1598 [amd64], [spacetime_supported=true],
1599 [spacetime_supported=false])
1600 AS_IF([$spacetime_supported],
1601 [AC_MSG_RESULT([yes])
1602 spacetime=true
1603 profinfo=true
1604 profinfo_width=26
1605 AC_DEFINE([WITH_SPACETIME])
1606 AS_IF([test x"$enable_call_counts" != "xno"],
1607 [call_counts=true
1608 AC_DEFINE([ENABLE_CALL_COUNTS])],
1609 [call_counts=false])
1610 AC_MSG_CHECKING([whether to use libunwind])
1611 AS_IF([test x"$with_libunwind" = "xno"],
1612 [AC_MSG_RESULT([disabled])],
1613 [AS_IF([test x"$with_libunwind" = "x"],
1614 [libunwind_requested=false
1615 AC_MSG_RESULT([if available])],
1616 [libunwind_requested=true
1617 AC_MSG_RESULT([requested])
1618 AS_IF([test x"$with_libunwind" != "xyes"],
1619 [AS_IF([test x"$LIBUNWIND_INCLUDE_DIR" = "x"],
1620 [LIBUNWIND_INCLUDE_DIR="$with_libunwind/include"])
1621 AS_IF([test x"$LIBUNWIND_LIB_DIR" = "x"],
1622 [LIBUNWIND_LIB_DIR="$with_libunwind/lib"])
1623 ])
1624 ])
1625 AS_IF([test "$system" = "macosx"],
1626 [AS_IF([test x"$LIBUNWIND_INCLUDE_DIR" != x -o \
1627 x"$LIBUNWIND_LIB_DIR" != x],
1628 [AC_MSG_WARN(m4_normalize([
1629 On MacOSX, specifying paths for libunwind headers or libraries
1630 is strongly discouraged. It is recommended to rely on the
1631 defaults provided by the configure script
1632 ]))])])
1633
1634 AS_IF([test x"$LIBUNWIND_INCLUDE_DIR" != x],
1635 [libunwind_include_flags="-I$LIBUNWIND_INCLUDE_DIR"],
1636 [libunwind_include_flags=""])
1637
1638 AS_CASE(["$system"],
1639 ["macosx"], [libunwind_link_flags="-framework System"],
1640 [libunwind_link_flags="-lunwind -lunwind-x86_64"])
1641
1642 AS_IF([test x"$LIBUNWIND_LIB_DIR" != x],
1643 [libunwind_link_flags="-L$LIBUNWIND_LIB_DIR $libunwind_link_flags"])
1644
1645 OCAML_CHECK_LIBUNWIND
1646
1647 AS_IF([$libunwind_requested && ! $libunwind_available],
1648 [AC_MSG_ERROR([libunwind was requested but can not be found])])
1649
1650 # We need unwinding information at runtime, but since we use
1651 # -no_compact_unwind, we also need -keep_dwarf_unwind otherwise
1652 # the OS X linker will chuck away the DWARF-like (.eh_frame)
1653 # information. (Older versions of OS X don't provide this.)
1654
1655 AS_IF([$libunwind_available && test x"$system" = "xmacosx"],
1656 [extra_flags="-Wl,-keep_dwarf_unwind"
1657 mkexe="$mkexe $extra_flags"
1658 mksharedlib="$mksharedlib $extra_flags"])])
1659 ],
1660 [AS_IF([test x"$enable_spacetime" = "xyes"],
1661 [AC_MSG_RESULT([requested but not supported])
1662 AC_MSG_ERROR([exiting])],
1663 [AC_MSG_RESULT([no])])
1664 ])
1665 ])
1666
1667 AC_DEFINE_UNQUOTED([PROFINFO_WIDTH], [$profinfo_width])
1668 AS_IF([$profinfo], [AC_DEFINE([WITH_PROFINFO])])
1669
1670 AS_IF([test x"$enable_installing_bytecode_programs" = "xno"],
1671 [install_bytecode_programs=false],
1672 [install_bytecode_programs=true])
1673
1674 AS_IF([test x"$enable_installing_source_artifacts" = "xno"],
1675 [install_source_artifacts=false],
1676 [install_source_artifacts=true])
1677
1678 AS_IF([test x"$enable_ocamldoc" = "xno"],
1679 [ocamldoc=""],
1680 [ocamldoc=ocamldoc])
1681
1682 AS_IF([test x"$enable_flambda" = "xyes"],
1683 [flambda=true
1684 AS_IF([test x"$enable_flambda_invariants" = "xyes"],
1685 [flambda_invariants=true],
1686 [flambda_invariants=false])],
1687 [flambda=false
1688 flambda_invariants=false])
1689
1690 AS_IF([test x"$enable_flat_float_array" = "xno"],
1691 [flat_float_array=false],
1692 [AC_DEFINE([FLAT_FLOAT_ARRAY])
1693 flat_float_array=true])
1694
1695 AS_IF([test x"$enable_function_sections" = "xno"],
1696 [function_sections=false],
1697 [AS_CASE([$arch],
1698 [amd64|i386|arm64], # not supported on arm32, see issue #9124.
1699 [AS_CASE([$target],
1700 [*-cygwin*|*-mingw*|*-windows|*-apple-darwin*],
1701 [function_sections=false;
1702 AC_MSG_NOTICE([No support for function sections on $target.])],
1703 [*],
1704 [AS_CASE([$ocaml_cv_cc_vendor],
1705 [gcc-[0123]-*|gcc-4-[01234567]],
1706 [function_sections=false;
1707 AC_MSG_NOTICE([Function sections are not
1708 supported in GCC prior to version 4.8.])],
1709 [clang-[012]-*|clang-3-[01234]],
1710 [function_sections=false;
1711 AC_MSG_NOTICE([Function sections are not supported
1712 in Clang prior to version 3.5.])],
1713 [gcc-*|clang-*],
1714 [function_sections=true;
1715 internal_cflags="$internal_cflags -ffunction-sections";
1716 AC_DEFINE([FUNCTION_SECTIONS])],
1717 [*],
1718 [function_sections=false;
1719 AC_MSG_NOTICE([Function sections are not supported by
1720 $ocaml_cv_cc_vendor.])])])],
1721 [function_sections=false]);
1722 AS_IF([test x"$function_sections" = "xfalse"],
1723 [AS_IF([test x"$enable_function_sections" = "xyes"],
1724 [AC_MSG_ERROR([Function sections are not supported.])],
1725 [AC_MSG_NOTICE([Disabling function sections.])])],
1726 [])])
1727
1728 AS_IF([test x"$with_afl" = "xyes"],
1729 [afl=true],
1730 [afl=false])
1731
1732 AS_IF([test x"$enable_force_safe_string" = "xno"],
1733 [force_safe_string=false],
1734 [AC_DEFINE([CAML_SAFE_STRING])
1735 force_safe_string=true])
1736
1737 AS_IF([test x"$DEFAULT_STRING" = "xunsafe"],
1738 [default_safe_string=false],
1739 [default_safe_string=true])
1740
1741 oc_cflags="$common_cflags $internal_cflags"
1742 oc_cppflags="$common_cppflags $internal_cppflags"
1743 ocamlc_cflags="$common_cflags $sharedlib_cflags"
1744 ocamlc_cppflags="$common_cppflags"
1745 ocamlopt_cflags="$common_cflags"
1746 ocamlopt_cppflags="$common_cppflags"
1747 cclibs="$cclibs $mathlib"
1748
1749 AS_CASE([$host],
1750 [*-*-mingw32],
1751 [bytecclibs="-lws2_32 -lversion"
1752 nativecclibs="-lws2_32 -lversion"],
1753 [*-pc-windows],
1754 [bytecclibs="advapi32.lib ws2_32.lib version.lib"
1755 nativecclibs="advapi32.lib ws2_32.lib version.lib"],
1756 [bytecclibs="$cclibs $DLLIBS $pthread_link $instrumented_runtime_libs"
1757 nativecclibs="$cclibs $DLLIBS"])
1758
1759 AS_IF([test x"$libdir" = x'${exec_prefix}/lib'],
1760 [libdir="$libdir"/ocaml])
1761
1762 AS_IF([test x"$mandir" = x'${datarootdir}/man'],
1763 [mandir='${prefix}/man'])
1764
1765 AS_CASE([$host],
1766 [*-*-mingw32|*-pc-windows],
1767 [max_testsuite_dir_retries=1
1768 AS_CASE([$WINDOWS_UNICODE_MODE],
1769 [ansi],
1770 [windows_unicode=0],
1771 [compatible|""],
1772 [windows_unicode=1],
1773 [AC_MSG_ERROR([unexpected windows unicode mode])])],
1774 [max_testsuite_dir_retries=0
1775 windows_unicode=0])
1776
1777 # Define flexlink chain and flags correctly for the different Windows ports
1778 AS_CASE([$host],
1779 [i686-w64-mingw32],
1780 [flexdll_chain='mingw'
1781 flexlink_flags="-chain $flexdll_chain -stack 16777216"],
1782 [x86_64-w64-mingw32],
1783 [flexdll_chain='mingw64'
1784 flexlink_flags="-chain $flexdll_chain -stack 33554432"],
1785 [i686-pc-windows],
1786 [flexdll_chain='msvc'
1787 flexlink_flags="-merge-manifest -stack 16777216"],
1788 [x86_64-pc-windows],
1789 [flexdll_chain='msvc64'
1790 flexlink_flags="-x64 -merge-manifest -stack 33554432"])
1791
1792 # Define default prefix correctly for the different Windows ports
1793 AS_IF([test x"$prefix" = "xNONE"],
1794 [AS_CASE([$host],
1795 [i686-w64-mingw32], [prefix='C:/ocamlmgw'],
1796 [x86_64-w64-mingw32], [prefix='C:/ocamlmgw64'],
1797 [i686-pc-windows], [prefix='C:/ocamlms'],
1798 [x86_64-pc-windows], [prefix='C:/ocamlms64'])],
1799 [AS_IF([test x"$unix_or_win32" = "xwin32" \
1800 && test "$host_vendor-$host_os" != "$build_vendor-$build_os" ],
1801 [AS_CASE([$build],
1802 [*-pc-cygwin], [prefix=`cygpath -m "$prefix"`])])])
1803
1804 # Define a few macros that were defined in config/m-nt.h
1805 # but whose value is not guessed properly by configure
1806 # (all this should be understood and fixed)
1807 AS_CASE([$host],
1808 [*-*-mingw32|*-pc-windows],
1809 [AC_DEFINE([HAS_BROKEN_PRINTF])
1810 AC_DEFINE([HAS_STRERROR])
1811 AC_DEFINE([HAS_IPV6])
1812 AC_DEFINE([HAS_NICE])])
1813
1814 AS_IF([test x"$enable_stdlib_manpages" != "xno"],
1815 [stdlib_manpages=true],[stdlib_manpages=false])
1816
1817 AC_OUTPUT
1818