#! /bin/sh #************************************************************************** #* * #* OCaml * #* * #* Xavier Leroy, projet Cristal, INRIA Rocquencourt * #* * #* Copyright 1999 Institut National de Recherche en Informatique et * #* en Automatique. * #* * #* All rights reserved. This file is distributed under the terms of * #* the GNU Lesser General Public License version 2.1, with the * #* special exception on linking described in the file LICENSE. * #* * #************************************************************************** ocamlversion=`head -1 VERSION` echo "Configuring OCaml version $ocamlversion" configure_options="$*" prefix=/usr/local bindir='' target_bindir='' libdir='' mandir='' programs_man_section=1 libraries_man_section=3 host_type=unknown target_type="" ccoption='' cpp='cpp' asoption='' asppoption='' cclibs='' mathlib='-lm' dllib='' x11_include_dir='' x11_lib_dir='' libunwind_include_dir='' libunwind_lib_dir='' libunwind_available=false disable_libunwind=false graph_wanted=yes pthread_wanted=yes dl_defs='' verbose=false debugruntime=true with_sharedlibs=true partialld="ld -r" with_debugger=ocamldebugger with_ocamldoc=ocamldoc with_frame_pointers=false with_spacetime=false enable_call_counts=true with_profinfo=false profinfo_width=0 no_naked_pointers=false native_compiler=true TOOLPREF="" with_cfi=true flambda=false force_safe_string=false default_safe_string=true afl_instrument=false max_testsuite_dir_retries=0 with_cplugins=false with_fpic=false flat_float_array=true # we distinguish '' (not set) from 'true' (explicitly set by the user) with_instrumented_runtime='' # Try to turn internationalization off, can cause config.guess to malfunction! unset LANG unset LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME # Turn off some MacOS X debugging stuff, same reason unset RC_TRACE_ARCHIVES RC_TRACE_DYLIBS RC_TRACE_PREBINDING_DISABLED # The inf(), wrn(), err() functions below can be used to provide a consistent # way to notify the user. The notification is always given to the stdout # descriptor. # # Their output is redirected to a file-descriptor "3" which is then redirected # to fd 1 at the level of the whole configure script. This is done to not # conflict with how values are returned from functions in shell script. # Consider the following where "It works!" would be mixed with "42". # do_foo() { # if some_command; then # inf "It works!" # echo "42" # fi # } inf() { printf "%b\n" "$*" 1>&3 } wrn() { printf "[WARNING] %b\n" "$*" 1>&3 } err() { printf "[ERROR!] %b\n" "$*" 1>&3 exit 2 } exec 3>&1 # Parse command-line arguments while : ; do case "$1" in "") break;; -prefix|--prefix) prefix=$2; shift;; -bindir|--bindir) bindir=$2; shift;; -target-bindir|--target-bindir) target_bindir="$2"; shift;; -libdir|--libdir) libdir=$2; shift;; -mandir|--mandir) case "$2" in */man[1-9ln]) mandir=`echo $2 | sed -e 's|^\(.*\)/man.$|\1|'` programs_man_section=`echo $2 | sed -e 's/^.*\(.\)$/\1/'`;; *) mandir=$2;; esac shift;; -libunwinddir|--libunwinddir) libunwind_include_dir=$2/include; libunwind_lib_dir=$2/lib; shift;; -libunwindlib|--libunwindlib) libunwind_lib_dir=$2; shift;; -libunwindinclude|--libunwindinclude) libunwind_include_dir=$2; shift;; -disable-libunwind|--disable-libunwind) disable_libunwind=true;; -host*|--host*) host_type=$2; shift;; -target*|--target*) target_type=$2; shift;; -cc*) ccoption="$2"; shift;; -as) asoption="$2"; shift;; -aspp) asppoption="$2"; shift;; -lib*) cclibs="$2 $cclibs"; shift;; -no-curses|--no-curses) ;; # Ignored for backward compatibility -no-shared-libs|--no-shared-libs) with_sharedlibs=false;; -x11include*|--x11include*) x11_include_dir=$2; shift;; -x11lib*|--x11lib*) x11_lib_dir=$2; shift;; -no-graph|--no-graph) graph_wanted=no;; -with-pthread*|--with-pthread*) ;; # Ignored for backward compatibility -no-pthread*|--no-pthread*) pthread_wanted=no;; -partialld|--partialld) partialld="$2"; shift;; -dldefs*|--dldefs*) dl_defs="$2"; shift;; -dllibs*|--dllibs*) dllib="$2"; shift;; -verbose|--verbose) verbose=true;; -with-debug-runtime|--with-debug-runtime) debugruntime=true;; # default -no-debug-runtime|--no-debug-runtime) debugruntime=false;; -with-instrumented-runtime|--with-instrumented-runtime) with_instrumented_runtime=true;; -no-instrumented-runtime|--no-instrumented-runtime) with_instrumented_runtime=false;; -no-debugger|--no-debugger) with_debugger="";; -no-ocamldoc|--no-ocamldoc) with_ocamldoc="";; -no-ocamlbuild|--no-ocamlbuild) ;; # ignored for backward compatibility -with-frame-pointers|--with-frame-pointers) with_frame_pointers=true;; -no-naked-pointers|--no-naked-pointers) no_naked_pointers=true;; -spacetime|--spacetime) with_spacetime=true; with_profinfo=true; profinfo_width=26;; -disable-call-counts|--disable-call-counts) enable_call_counts=false;; -reserved-header-bits|--reserved-header-bits) with_spacetime=false; with_profinfo=true; profinfo_width=$2;shift case $profinfo_width in 0) with_profinfo=false;; [0123456789]);; 1?|2?);; 3[012]);; *) err "--reserved-header-bits argument must be less than 32" esac ;; -no-cfi|--no-cfi) with_cfi=false;; -no-native-compiler|--no-native-compiler) native_compiler=false;; -flambda|--flambda) flambda=true;; -with-cplugins|--with-cplugins) with_cplugins=true;; -no-cplugins|--no-cplugins) ;; # Ignored for backward compatibility -fPIC|--fPIC) with_fpic=true;; # There are two configure-time string safety options, # -(no-)force-safe-string and -default-(un)safe-string that # interact with a compile-time (un)safe-string option. # # If -force-safe-string is set at configure time, then the compiler # will always enforce that string and bytes are distinct: the # compile-time -unsafe-string option is disabled. This lets us # assume pervasive string immutability, for code optimizations and # in the C layer. # # If -no-force-safe-string is set at configure-time, the compiler # will use the compile-time (un)safe-string option to decide whether # string and bytes are compatible on a per-file basis. The # configure-time options default-(un)safe-string decide which # setting will be chosen by default, if no compile-time option is # explicitly passed. # # The configure-time behavior of OCaml 4.05 and older was equivalent # to -no-force-safe-string -default-unsafe-string. OCaml 4.06 # uses -no-force-safe-string -default-safe-string. We # expect -force-safe-string to become the default in the future. -force-safe-string|--force-safe-string) force_safe_string=true;; -no-force-safe-string|--no-force-safe-string) force_safe_string=false;; -default-safe-string|--default-safe-string) default_safe_string=true;; -default-unsafe-string|--default-unsafe-string) default_safe_string=false;; -flat-float-array|--flat-float-array) flat_float_array=true;; -no-flat-float-array|--no-flat-float-array) flat_float_array=false;; -afl-instrument) afl_instrument=true;; *) if echo "$1" | grep -q -e '^--\?[a-zA-Z0-9-]\+='; then err "configure expects arguments of the form '-prefix /foo/bar'," \ "not '-prefix=/foo/bar' (note the '=')." else err "Unknown option \"$1\"." fi;; esac shift done # Sanity checks case "$prefix" in /*) ;; *) err "The -prefix directory must be absolute.";; esac case "$bindir" in /*) ;; "") ;; '$(PREFIX)/'*) ;; *) err 'The -bindir directory must be absolute or relative to $(PREFIX).';; esac case "$libdir" in /*) ;; "") ;; '$(PREFIX)/'*) ;; *) err 'The -libdir directory must be absolute or relative to $(PREFIX).';; esac case "$mandir" in /*) ;; "") ;; '$(PREFIX)/'*) ;; *) err 'The -mandir directory must be absolute or relative to $(PREFIX).';; esac # Generate the files cd config/auto-aux rm -f s.h m.h Makefile touch s.h m.h Makefile # Write options to Makefile config() { # This function hardens the generated Makefile against '#' symbols # present in a source path (opam-compiler-conf may pick such directory # names if working from a branch named 'PR#4242-answer-all-questions') # by escaping them into '\#'. # When injecting data in Makefiles, it is customary to also escape # '$', which get turned into '$$'. However, this transformation is # invalid here as some of the variables are meant to be code # interpreted by make: for example, passing # --bindir "$(PREFIX)/bin2" # is explicitly supported (see "or relative to $(PREFIX)" messages above). # Finally, it is also impossible for the user to escape the '#' signs # before calling this configure script, given that # $(PREFIX) is also injected in C code where this escape is invalid # -- see the definition of the OCAML_STDLIB_DIR macro below. echo "$1=$2" | sed 's/#/\\#/g' >> Makefile } echo "# generated by ./configure $configure_options" >> Makefile config CONFIGURE_ARGS "$configure_options" # Where to install config PREFIX "$prefix" case "$bindir" in "") config BINDIR '$(PREFIX)/bin' bindir="$prefix/bin";; *) config BINDIR "$bindir";; esac config BYTERUN '$(BINDIR)/ocamlrun' case "$libdir" in "") config LIBDIR '$(PREFIX)/lib/ocaml' libdir="$prefix/lib/ocaml";; *) config LIBDIR "$libdir";; esac config STUBLIBDIR '$(LIBDIR)/stublibs' case "$mandir" in "") config MANDIR '$(PREFIX)/man' mandir="$prefix/man";; *) config MANDIR "$mandir";; esac config PROGRAMS_MAN_SECTION "$programs_man_section" config LIBRARIES_MAN_SECTION "$libraries_man_section" # Determine the system type if test "$host_type" = "unknown"; then if host_type=`sh ../gnu/config.guess`; then :; else err "Cannot guess host type. You must specify one with the -host option." fi fi if host=`sh ../gnu/config.sub $host_type`; then :; else err "Please specify the correct host type with the -host option" fi inf "Configuring for host $host ..." if test -n "$target_type"; then target="$target_type" TOOLPREF="${target}-" else target="$host" fi inf "Configuring for target $target ..." if [ x"$host" = x"$target" ]; then cross_compiler=false else cross_compiler=true fi # Do we have gcc? if test -z "$ccoption"; then if sh ./searchpath "${TOOLPREF}gcc"; then cc="${TOOLPREF}gcc" else if $cross_compiler; then err "No cross-compiler found for ${target}.\n" \ "It should be named ${TOOLPREF}gcc and be in the PATH." else cc="cc" fi fi else cc="$ccoption" fi inf "Using compiler $cc." # Configure compiler to use in further tests. export cc verbose # Determine the C compiler family (GCC, Clang, etc) ccfamily=`$cc -E cckind.c | grep '^[a-z]' | tr -s ' ' '-'` case $? in 0) inf "Compiler family and version: $ccfamily.";; *) err "Unable to preprocess the test program.\n" \ "Make sure the C compiler $cc is properly installed.";; esac # The BYTECODE_C_COMPILER make variable says how the C compiler should be # invoked to process a third-party C source file passed to ocamlc # when no -cc command-line option has been specified. # The BYTECCCOMPOPTS make variable contains options to pass to the C # compiler but only when compiling C files that belong to the OCaml # distribution. # In other words, when ocamlc is called to compile a third-party C # source file, it will _not_ pass these options to the C compiler. # The SHAREDCCCOMPOPTS make variable contains options to use to compile C # source files so that the resulting object files can then be integrated # into shared libraries. It is passed to BYTECC for both C source files # in the OCaml distribution and third-party C source files compiled # with ocamlc. mkexe="\$(CC) \$(CFLAGS) \$(CPPFLAGS) \$(LDFLAGS)" mkexedebugflag="-g" common_cflags="" common_cppflags="" internal_cflags="" internal_cppflags="" ocamlc_cflags="" ocamlc_cppflags="" ocamlopt_cflags="" ocamlopt_cppflags="" ldflags="" ostype="Unix" exe="" iflexdir="" SO="so" TOOLCHAIN="cc" # Choose reasonable options based on compiler kind # We select high optimization levels, provided we can turn off: # - strict type-based aliasing analysis (too risky for the OCaml runtime) # - strict no-overflow conditions on signed integer arithmetic # (the OCaml runtime assumes Java-style behavior of signed integer arith.) # Concerning optimization level, -O3 is somewhat risky, so take -O2. # Concerning language version, gnu99 is ISO C99 plus GNU extensions # that are often used in standard headers. Older GCC versions # defaults to gnu89, which is not C99. Clang defaults to gnu99 or # gnu11, which is fine. case "$ocamlversion" in *+dev*) gcc_warnings="-Wall -Werror";; *) gcc_warnings="-Wall";; esac case "$ccfamily" in clang-*) common_cflags="-O2 -fno-strict-aliasing -fwrapv"; internal_cflags="$gcc_warnings";; gcc-[012]-*) # Some versions known to miscompile OCaml, e,g, 2.7.2.1, some 2.96. # Plus: C99 support unknown. err "This version of GCC is too old. Please use GCC version 4.2 or above.";; gcc-3-*|gcc-4-[01]) # No -fwrapv option before GCC 3.4. # Known problems with -fwrapv fixed in 4.2 only. wrn "This version of GCC is rather old. Reducing optimization level." wrn "Consider using GCC version 4.2 or above." common_cflags="-std=gnu99 -O"; internal_cflags="$gcc_warnings";; gcc-4-*) common_cflags="-std=gnu99 -O2 -fno-strict-aliasing -fwrapv \ -fno-builtin-memcmp"; internal_cflags="$gcc_warnings";; gcc-*) common_cflags="-O2 -fno-strict-aliasing -fwrapv"; internal_cflags="$gcc_warnings";; *) common_cflags="-O";; esac internal_cppflags="-DCAML_NAME_SPACE $internal_cppflags" # Adjust according to target case "$cc,$target" in *,*-*-rhapsody*) common_cppflags="-DSHRINKED_GNUC $common_cppflags" mathlib="";; *,*-*-darwin*) mathlib="" mkexe="$mkexe -Wl,-no_compact_unwind" # Tell gcc that we can use 32-bit code addresses for threaded code # unless we are compiled for a shared library (-fPIC option) echo "#ifndef __PIC__" >> m.h echo "# define ARCH_CODE32" >> m.h echo "#endif" >> m.h;; *,*-*-haiku*) # No -lm library mathlib="";; *,*-*-beos*) # No -lm library mathlib="";; *gcc,alpha*-*-osf*) if sh ./hasgot -mieee; then common_cflags="-mieee $common_cflags"; fi # Put code and static data in lower 4GB ldflags="-Wl,-T,12000000 -Wl,-D,14000000" # Tell gcc that we can use 32-bit code addresses for threaded code echo "#define ARCH_CODE32" >> m.h;; cc,alpha*-*-osf*) common_cflags="-std1 -ieee";; *gcc*,alpha*-*-linux*) if sh ./hasgot -mieee; then common_cflags="-mieee $common_cflags"; fi;; *,mips-*-irix6*) # Turn off warning "unused library" ldflags="-n32 -Wl,-woff,84";; *,alpha*-*-unicos*) # For the Cray T3E common_cppflags="$common_cppflags -DUMK";; *,powerpc-*-aix*) # Avoid name-space pollution by requiring Unix98-conformant includes common_cppflags="$common_cppflags -D_XOPEN_SOURCE=500 -D_ALL_SOURCE";; *,*-*-cygwin*) case $target in i686-*) flavor=cygwin;; x86_64-*) flavor=cygwin64;; *) err "unknown cygwin variant";; esac common_cppflags="$common_cppflags -U_WIN32" if $with_sharedlibs; then flexlink="flexlink -chain $flavor -merge-manifest -stack 16777216" flexdir=`$flexlink -where | tr -d '\015'` if test -z "$flexdir"; then wrn "flexlink not found: native shared libraries won't be available." with_sharedlibs=false else iflexdir="-I\"$flexdir\"" mkexe="$flexlink -exe" mkexedebugflag="-link -g" fi fi if ! $with_sharedlibs; then mkexe="$mkexe -Wl,--stack,16777216" ldflags="-Wl,--stack,16777216" fi exe=".exe" ostype="Cygwin";; *,*-*-mingw*) if $with_sharedlibs; then case "$target" in i686-*-*) flexlink_chain="mingw";; x86_64-*-*) flexlink_chain="mingw64";; esac flexlink="flexlink -chain $flexlink_chain -merge-manifest -stack 16777216" flexdir=`$flexlink -where` if test -z "$flexdir"; then wrn "flexlink not found: native shared libraries won't be available." with_sharedlibs=false else iflexdir="-I\"$flexdir\"" mkexe="$flexlink -exe" mkexedebugflag="-link -g" fi fi exe=".exe" ostype="Win32" TOOLCHAIN="mingw" SO="dll" ;; *,x86_64-*-linux*) # Tell gcc that we can use 32-bit code addresses for threaded code # unless we are compiled for a shared library (-fPIC option) echo "#ifndef __PIC__" >> m.h echo "# define ARCH_CODE32" >> m.h echo "#endif" >> m.h;; esac # Configure compiler options to use in further tests. export cclibs ldflags # Check C compiler. cflags="$common_cflags $internal_cflags" sh ./runtest ansi.c case $? in 0) inf "The C compiler is ISO C99 compliant." ;; 1) wrn "The C compiler is ANSI / ISO C90 compliant, but not ISO C99" \ "compliant.";; 2) err "The C compiler $cc is not ISO C compliant.\n" \ "You need an ISO C99 compiler to build OCaml.";; *) if $cross_compiler; then wrn "Unable to compile the test program.\n" \ "This failure is expected for cross-compilation:\n" \ "we will assume the C compiler is ISO C99-compliant." else err "Unable to compile the test program.\n" \ "Make sure the C compiler $cc is properly installed." fi;; esac # For cross-compilation, we need a host-based ocamlrun and ocamlyacc, # and the user must specify the target BINDIR if $cross_compiler; then if ! sh ./searchpath ocamlrun; then err "Cross-compilation requires an ocaml runtime environment\n" \ "(the ocamlrun binary). Moreover, its version must be the same\n" \ "as the one you're trying to build (`cut -f1 -d+ < ../../VERSION`)." else ocaml_system_version=`ocamlrun -version | sed 's/[^0-9]*\([0-9.]*\).*/\1/'` ocaml_source_version=`sed -n '1 s/\([0-9\.]*\).*/\1/ p' < ../../VERSION` if test x"$ocaml_system_version" != x"$ocaml_source_version"; then err "While you have an ocaml runtime environment, its version\n" \ "($ocaml_system_version) doesn't match the version of these\n" \ "sources ($ocaml_source_version)." else config CAMLRUN "`./searchpath -p ocamlrun`" fi fi if ! sh ./searchpath ocamlyacc; then err "Cross-compilation requires an ocamlyacc binary." else ocamlyacc 2>/dev/null if test "$?" -ne 1; then err "While you have an ocamlyacc binary, it cannot be executed" \ "successfully." else config CAMLYACC "`./searchpath -p ocamlyacc`" fi fi if [ -z "$target_bindir" ]; then err "Cross-compilation requires -target-bindir." else config TARGET_BINDIR "$target_bindir" fi fi # cross-compiler # Check the sizes of data types # OCaml needs a 32 or 64 bit architecture, a 32-bit integer type and # a 64-bit integer type inf "Checking the sizes of integers and pointers..." ret=`sh ./runtest sizes.c` # $1 = sizeof(int) # $2 = sizeof(long) # $3 = sizeof(pointers) # $4 = sizeof(short) # $5 = sizeof(long long) if test "$?" -eq 0; then set $ret case "$3" in 4) inf "OK, this is a regular 32 bit architecture." echo "#undef ARCH_SIXTYFOUR" >> m.h arch64=false;; 8) inf "Wow! A 64 bit architecture!" echo "#define ARCH_SIXTYFOUR" >> m.h arch64=true;; *) err "This architecture seems to be neither 32 bits nor 64 bits.\n" \ "OCaml won't run on this architecture.";; esac else # For cross-compilation, runtest always fails: add special handling. case "$target" in i686-*-mingw*) inf "OK, this is a regular 32 bit architecture." echo "#undef ARCH_SIXTYFOUR" >> m.h set 4 4 4 2 8 arch64=false;; x86_64-*-mingw*) inf "Wow! A 64 bit architecture!" echo "#define ARCH_SIXTYFOUR" >> m.h set 4 4 8 2 8 arch64=true;; *) err "Since datatype sizes cannot be guessed when cross-compiling,\n" \ "a hardcoded list is used but your architecture isn't known yet.\n" \ "You need to determine the sizes yourself.\n" \ "Please submit a bug report in order to expand the list." ;; esac fi if test $1 != 4 && test $2 != 4 && test $4 != 4; then err "Sorry, we can't find a 32-bit integer type\n" \ "(sizeof(short) = $4, sizeof(int) = $1, sizeof(long) = $2)\n" \ "OCaml won't run on this architecture." fi if test $2 != 8 && test $5 != 8; then err "Sorry, we can't find a 64-bit integer type\n" \ "(sizeof(long) = $2, sizeof(long long) = $5)\n" \ "OCaml won't run on this architecture." fi echo "#define SIZEOF_INT $1" >> m.h echo "#define SIZEOF_LONG $2" >> m.h echo "#define SIZEOF_PTR $3" >> m.h echo "#define SIZEOF_SHORT $4" >> m.h echo "#define SIZEOF_LONGLONG $5" >> m.h echo "#define INT64_LITERAL(s) s ## LL" >> m.h # Determine endianness sh ./runtest endian.c case $? in 0) inf "This is a big-endian architecture." echo "#define ARCH_BIG_ENDIAN" >> m.h;; 1) inf "This is a little-endian architecture." echo "#undef ARCH_BIG_ENDIAN" >> m.h;; 2) err "This architecture seems to be neither big endian nor little" \ "endian.\n OCaml won't run on this architecture.";; *) case $target in *-*-mingw*) inf "This is a little-endian architecture." echo "#undef ARCH_BIG_ENDIAN" >> m.h;; *) wrn "Something went wrong during endianness determination.\n" \ "You will have to figure out endianness yourself\n" \ "(option ARCH_BIG_ENDIAN in m.h).";; esac;; esac # Determine alignment constraints case "$target" in sparc*-*-*|hppa*-*-*|arm*-*-*|mips*-*-*) # On Sparc V9 with certain versions of gcc, determination of double # alignment is not reliable (PR#1521), hence force it. # Same goes for hppa. # PR#5088 suggests same problem on ARM. # PR#5280 reports same problem on MIPS. # But there's a knack (PR#2572): # if we're in 64-bit mode (sizeof(long) == 8), # we must not doubleword-align floats... if test $2 = 8; then inf "Doubles can be word-aligned." echo "#undef ARCH_ALIGN_DOUBLE" >> m.h else inf "Doubles must be doubleword-aligned." echo "#define ARCH_ALIGN_DOUBLE" >> m.h fi;; *) sh ./runtest dblalign.c case $? in 0) inf "Doubles can be word-aligned." echo "#undef ARCH_ALIGN_DOUBLE" >> m.h;; 1) inf "Doubles must be doubleword-aligned." echo "#define ARCH_ALIGN_DOUBLE" >> m.h;; *) case "$target" in *-*-mingw*) inf "Doubles can be word-aligned." echo "#undef ARCH_ALIGN_DOUBLE" >> m.h;; *) wrn "Something went wrong during alignment determination for" \ "doubles.\n" \ "We will assume alignment constraints over doubles.\n" \ "That's a safe bet: OCaml will work even if\n" \ "this architecture actually has no alignment constraints." echo "#define ARCH_ALIGN_DOUBLE" >> m.h;; esac;; esac;; esac case "$target" in # PR#5088: autodetection is unreliable on ARM. PR#5280: also on MIPS. sparc*-*-*|hppa*-*-*|arm*-*-*|mips*-*-*) if test $2 = 8; then inf "64-bit integers can be word-aligned." echo "#undef ARCH_ALIGN_INT64" >> m.h else inf "64-bit integers must be doubleword-aligned." echo "#define ARCH_ALIGN_INT64" >> m.h fi;; *-*-mingw*) true;; # Nothing is in config/m-nt.h so don't add anything. *) sh ./runtest int64align.c case $? in 0) inf "64-bit integers can be word-aligned." echo "#undef ARCH_ALIGN_INT64" >> m.h;; 1) inf "64-bit integers must be doubleword-aligned." echo "#define ARCH_ALIGN_INT64" >> m.h;; *) wrn "Something went wrong during alignment determination for\n" \ "64-bit integers. I'm going to assume this architecture has\n" \ "alignment constraints. That's a safe bet: OCaml will work\n" \ "even if this architecture has actually no alignment\n" \ "constraints." echo "#define ARCH_ALIGN_INT64" >> m.h;; esac esac # Shared library support shared_libraries_supported=false dl_needs_underscore=false sharedcccompopts='' mksharedlib='shared-libs-not-available' rpath='' mksharedlibrpath='' natdynlinkopts="" if $with_sharedlibs; then case "$target" in *-*-cygwin*) mksharedlib="$flexlink" mkmaindll="$flexlink -maindll" shared_libraries_supported=true;; *-*-mingw*) mksharedlib="$flexlink" mkmaindll="$flexlink -maindll" shared_libraries_supported=true;; alpha*-*-osf*) case "$cc" in *gcc*) sharedcccompopts="-fPIC" mksharedlib="$cc -shared" rpath="-Wl,-rpath," mksharedlibrpath="-Wl,-rpath," shared_libraries_supported=true;; cc*) sharedcccompopts="" mksharedlib="ld -shared -expect_unresolved '*'" rpath="-Wl,-rpath," mksharedlibrpath="-rpath " shared_libraries_supported=true;; esac;; *-*-solaris2*) case "$cc" in *gcc*) sharedcccompopts="-fPIC" if sh ./solaris-ld; then mksharedlib="ld -G" rpath="-R" mksharedlibrpath="-R" else mksharedlib="$cc -shared" ldflags="$ldflags -Wl,-E" natdynlinkopts="-Wl,-E" rpath="-Wl,-rpath," mksharedlibrpath="-Wl,-rpath," fi shared_libraries_supported=true;; *) sharedcccompopts="-KPIC" rpath="-R" mksharedlibrpath="-R" mksharedlib="/usr/ccs/bin/ld -G" shared_libraries_supported=true;; esac;; mips*-*-irix[56]*) case "$cc" in cc*) sharedcccompopts="";; *gcc*) sharedcccompopts="-fPIC";; esac mksharedlib="ld -shared -rdata_shared" rpath="-Wl,-rpath," mksharedlibrpath="-rpath " shared_libraries_supported=true;; i[3456]86-*-darwin[89].*) mksharedlib="$cc -shared -flat_namespace -undefined suppress \ -read_only_relocs suppress" common_cflags="$dl_defs $common_cflags" dl_needs_underscore=false shared_libraries_supported=true;; *-apple-darwin*) mksharedlib="$cc -shared -flat_namespace -undefined suppress \ -Wl,-no_compact_unwind" common_cflags="$dl_defs $common_cflags" dl_needs_underscore=false shared_libraries_supported=true;; *-*-linux*|*-*-freebsd[3-9]*|*-*-freebsd[1-9][0-9]*\ |*-*-openbsd*|*-*-netbsd*|*-*-dragonfly*|*-*-gnu*|*-*-haiku*) sharedcccompopts="-fPIC" mksharedlib="$cc -shared" ldflags="$ldflags -Wl,-E" rpath="-Wl,-rpath," mksharedlibrpath="-Wl,-rpath," natdynlinkopts="-Wl,-E" shared_libraries_supported=true;; powerpc-*-aix*) case "$ccfamily" in xlc-*)sharedcccompopts="-qpic" mksharedlib="$cc -qmkshrobj -G" mksharedlibrpath="-Wl,-blibpath," ldflags="$ldflags -brtl -bexpfull" dl_needs_underscore=false rpath="-Wl,-blibpath," shared_libraries_supported=true;; esac esac fi if test -z "$mkmaindll"; then mkmaindll=$mksharedlib fi # Configure native dynlink natdynlink=false if $with_sharedlibs; then case "$target" in *-*-cygwin*) natdynlink=true;; *-*-mingw*) natdynlink=true;; i[3456]86-*-linux*) natdynlink=true;; i[3456]86-*-gnu*) natdynlink=true;; x86_64-*-linux*) natdynlink=true;; i[3456]86-*-darwin[89].*) natdynlink=true;; i[3456]86-*-darwin*) if test $arch64 == true; then natdynlink=true fi;; x86_64-*-darwin*) natdynlink=true;; s390x*-*-linux*) natdynlink=true;; powerpc*-*-linux*) natdynlink=true;; i686-*-kfreebsd*) natdynlink=true;; x86_64-*-kfreebsd*) natdynlink=true;; x86_64-*-dragonfly*) natdynlink=true;; i[3456]86-*-freebsd*) natdynlink=true;; x86_64-*-freebsd*) natdynlink=true;; i[3456]86-*-openbsd*) natdynlink=true;; x86_64-*-openbsd*) natdynlink=true;; i[3456]86-*-netbsd*) natdynlink=true;; x86_64-*-netbsd*) natdynlink=true;; i386-*-gnu0.3) natdynlink=true;; i[3456]86-*-haiku*) natdynlink=true;; arm*-*-linux*) natdynlink=true;; arm*-*-freebsd*) natdynlink=true;; earm*-*-netbsd*) natdynlink=true;; aarch64-*-linux*) natdynlink=true;; esac fi if test $natdynlink = "true"; then cmxs="cmxs" else cmxs="cmxa" fi # Try to work around the Skylake/Kaby Lake processor bug. case "$cc,$target" in *gcc*,x86_64-*|*gcc*,i686-*) if sh ./hasgot -Werror -fno-tree-vrp; then internal_cflags="$internal_cflags -fno-tree-vrp" inf "Adding -fno-tree-vrp option to work around PR#7452" fi;; esac # Configure the native-code compiler arch=none model=default system=unknown case "$target" in i[3456]86-*-linux*) arch=i386; system=linux_`sh ./runtest elf.c`;; i[3456]86-*-*bsd*) arch=i386; system=bsd_`sh ./runtest elf.c`;; i[3456]86-*-solaris*) if $arch64; then arch=amd64; system=solaris else arch=i386; system=solaris fi;; i[3456]86-*-haiku*) arch=i386; system=beos;; i[3456]86-*-beos*) arch=i386; system=beos;; i[3456]86-*-cygwin*) arch=i386; system=cygwin;; i[3456]86-*-darwin*) if $arch64; then arch=amd64; system=macosx else arch=i386; system=macosx fi;; i[3456]86-*-gnu*) arch=i386; system=gnu;; i[3456]86-*-mingw*) arch=i386; system=mingw;; powerpc64le*-*-linux*) arch=power; model=ppc64le; system=elf;; powerpc*-*-linux*) arch=power; if $arch64; then model=ppc64; else model=ppc; fi system=elf;; powerpc-*-netbsd*) arch=power; model=ppc; system=netbsd;; powerpc-*-openbsd*) arch=power; model=ppc; system=bsd_elf;; s390x*-*-linux*) arch=s390x; model=z10; system=elf;; armv6*-*-linux-gnueabihf) arch=arm; model=armv6; system=linux_eabihf;; armv7*-*-linux-gnueabihf) arch=arm; model=armv7; system=linux_eabihf;; armv8*-*-linux-gnueabihf) arch=arm; model=armv8; system=linux_eabihf;; armv8*-*-linux-gnueabi) arch=arm; model=armv8; system=linux_eabi;; armv7*-*-linux-gnueabi) arch=arm; model=armv7; system=linux_eabi;; armv6t2*-*-linux-gnueabi) arch=arm; model=armv6t2; system=linux_eabi;; armv6*-*-linux-gnueabi) arch=arm; model=armv6; system=linux_eabi;; armv6*-*-freebsd*) arch=arm; model=armv6; system=freebsd;; earmv6*-*-netbsd*) arch=arm; model=armv6; system=netbsd;; earmv7*-*-netbsd*) arch=arm; model=armv7; system=netbsd;; armv5te*-*-linux-gnueabi) arch=arm; model=armv5te; system=linux_eabi;; armv5*-*-linux-gnueabi) arch=arm; model=armv5; system=linux_eabi;; arm*-*-linux-gnueabi) arch=arm; system=linux_eabi;; arm*-*-openbsd*) arch=arm; system=bsd;; zaurus*-*-openbsd*) arch=arm; system=bsd;; x86_64-*-linux*) arch=amd64; system=linux;; x86_64-*-gnu*) arch=amd64; system=gnu;; x86_64-*-dragonfly*) arch=amd64; system=dragonfly;; x86_64-*-freebsd*) arch=amd64; system=freebsd;; x86_64-*-netbsd*) arch=amd64; system=netbsd;; x86_64-*-openbsd*) arch=amd64; system=openbsd;; x86_64-*-darwin*) arch=amd64; system=macosx;; x86_64-*-mingw*) arch=amd64; system=mingw;; aarch64-*-linux*) arch=arm64; system=linux;; x86_64-*-cygwin*) arch=amd64; system=cygwin;; esac # Some platforms exist both in 32-bit and 64-bit variants, not distinguished # by $target. Turn off native code compilation on platforms where 64-bit mode # is not supported (PR#4441). # Sometimes, it's 32-bit mode that is not supported (PR#6722). case "$arch64,$arch,$model" in true,power,ppc|false,amd64,*) arch=none; model=default; system=unknown;; esac case "$native_compiler" in true) ;; false) arch=none; model=default; system=unknown; natdynlink=false;; esac nativeccprofopts='' case "$arch,$cc,$system,$model" in *,*,rhapsody,*) if $arch64; then partialld="ld -r -arch ppc64"; fi;; amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";; amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";; power,gcc*,elf,ppc) partialld="ld -r -m elf32ppclinux";; power,gcc*,elf,ppc64) partialld="ld -r -m elf64ppc";; power,gcc*,elf,ppc64le) partialld="ld -r -m elf64lppc";; esac asppprofflags='-DPROFILING' case "$arch,$system" in amd64,macosx) if sh ./searchpath clang; then as='clang -arch x86_64 -Wno-trigraphs -c' aspp='clang -arch x86_64 -Wno-trigraphs -c' else as="${TOOLPREF}as -arch x86_64" aspp="${TOOLPREF}gcc -arch x86_64 -c" fi;; amd64,solaris) as="${TOOLPREF}as --64" aspp="${TOOLPREF}gcc -m64 -c";; i386,solaris) as="${TOOLPREF}as" aspp="${TOOLPREF}gcc -c";; power,elf) if $arch64; then as="${TOOLPREF}as -a64 -mppc64" aspp="${TOOLPREF}gcc -m64 -c" else as="${TOOLPREF}as -mppc" aspp="${TOOLPREF}gcc -m32 -c" fi;; s390x,elf) as="${TOOLPREF}as -m 64 -march=$model" aspp="${TOOLPREF}gcc -c -Wa,-march=$model";; arm,freebsd) as="${TOOLPREF}cc -c" aspp="${TOOLPREF}cc -c";; *,dragonfly) as="${TOOLPREF}as" aspp="${TOOLPREF}cc -c";; *,freebsd) as="${TOOLPREF}as" aspp="${TOOLPREF}cc -c";; amd64,*|arm,*|arm64,*|i386,*|power,bsd*|power,netbsd) as="${TOOLPREF}as" case "$ccfamily" in clang-*) aspp="${TOOLPREF}clang -c -Wno-trigraphs" ;; *) aspp="${TOOLPREF}gcc -c" ;; esac;; esac if test -n "$asoption"; then as="$asoption"; fi if test -n "$asppoption"; then aspp="$asppoption"; fi cc_profile='-pg' case "$arch,$system" in i386,linux_elf) profiling='true';; i386,gnu) profiling='true';; i386,bsd_elf) profiling='true';; amd64,macosx) profiling='true';; i386,macosx) profiling='true';; amd64,linux) profiling='true';; amd64,openbsd) profiling='true';; amd64,freebsd) profiling='true';; amd64,netbsd) profiling='true';; arm,netbsd) profiling='true';; amd64,gnu) profiling='true';; arm,linux*) profiling='true';; power,elf) profiling='true';; power,bsd*) profiling='true';; power,netbsd) profiling='true';; *) profiling='false';; esac # Where is ranlib? if sh ./searchpath ${TOOLPREF}ranlib; then inf "ranlib found" config RANLIB "${TOOLPREF}ranlib" config RANLIBCMD "${TOOLPREF}ranlib" else inf "ranlib not used" config RANLIB "${TOOLPREF}ar rs" config RANLIBCMD "" fi config ARCMD "${TOOLPREF}ar" # Write the OS type (Unix or Cygwin) echo "#define OCAML_OS_TYPE \"$ostype\"" >> s.h echo "#define OCAML_STDLIB_DIR \"$libdir\"" >> s.h # Do #! scripts work? printf "#!%s\nexit 1\n" `command -v cat` > hashbang4 chmod +x hashbang4 if ( (./hashbang || ./hashbang2 || ./hashbang3 || ./hashbang4) >/dev/null); then inf "#! appears to work in shell scripts." case "$target" in *-*-sunos*|*-*-unicos*) wrn "We won't use it, though, because under SunOS and Unicos it breaks " \ "on pathnames longer than 30 characters" config HASHBANGSCRIPTS "false";; *-*-cygwin*) wrn "We won't use it, though, because of conflicts with .exe extension " \ "under Cygwin" config HASHBANGSCRIPTS "false";; *-*-mingw*) inf "We won't use it, though, because it's on the target platform " \ "it would be used and windows doesn't support it." config HASHBANGSCRIPTS "false";; *) config HASHBANGSCRIPTS "true";; esac else inf "No support for #! in shell scripts" config HASHBANGSCRIPTS "false" fi # Use 64-bit file offset if possible common_cppflags="$common_cppflags -D_FILE_OFFSET_BITS=64" # Check the semantics of signal handlers if sh ./hasgot sigaction sigprocmask; then inf "POSIX signal handling found." echo "#define POSIX_SIGNALS" >> s.h else if sh ./runtest signals.c; then inf "Signals have the BSD semantics." echo "#define BSD_SIGNALS" >> s.h else inf "Signals have the System V semantics." fi if sh ./hasgot sigsetmask; then inf "sigsetmask() found" echo "#define HAS_SIGSETMASK" >> s.h fi fi # For the Pervasives module if sh ./hasgot2 -i math.h $mathlib expm1 log1p hypot copysign; then inf "expm1(), log1p(), hypot(), copysign() found." echo "#define HAS_C99_FLOAT_OPS" >> s.h fi # For the Sys module if sh ./hasgot getrusage; then inf "getrusage() found." echo "#define HAS_GETRUSAGE" >> s.h fi if sh ./hasgot times; then inf "times() found." echo "#define HAS_TIMES" >> s.h fi if sh ./hasgot2 -D_GNU_SOURCE -i stdlib.h secure_getenv; then inf "secure_getenv() found." echo "#define HAS_SECURE_GETENV" >> s.h elif sh ./hasgot2 -D_GNU_SOURCE -i stdlib.h __secure_getenv; then inf "__secure_getenv() found." echo "#define HAS___SECURE_GETENV" >> s.h fi if sh ./hasgot -i unistd.h issetugid; then inf "issetugid() found." echo "#define HAS_ISSETUGID" >> s.h fi # For instrumented runtime # (clock_gettime needs -lrt for glibc before 2.17) if test "$with_instrumented_runtime" != "false"; then instrumented_runtime_support="nonsupported" for libs in "" "-lrt"; do if sh ./hasgot $libs clock_gettime; then inf "clock_gettime functions found (with libraries '$libs')" instrumented_runtime_libs="${libs}" instrumented_runtime_support="supported"; break fi done case "$with_instrumented_runtime,$instrumented_runtime_support" in *,supported) with_instrumented_runtime=true;; true,nonsupported) with_instrumented_runtime=false; err "clock_gettime functions not found. " \ "Instrumented runtime can't be built.";; ,nonsupported) with_instrumented_runtime=false; inf "clock_gettime functions not found. " \ "Instrumented runtime can't be built.";; esac fi # Configuration for the libraries case "$system" in mingw) unix_or_win32="win32"; unixlib="win32unix"; graphlib="win32graph";; *) unix_or_win32="unix"; unixlib="unix"; graphlib="graph";; esac config UNIX_OR_WIN32 "$unix_or_win32" config UNIXLIB "$unixlib" config GRAPHLIB "$graphlib" otherlibraries="$unixlib str dynlink bigarray" # Spacetime profiling is only available for native code on 64-bit targets. case "$arch" in none) ;; *) if $arch64; then otherlibraries="$otherlibraries raw_spacetime_lib" fi ;; esac # For the Unix library has_sockets=no if sh ./hasgot socket socketpair bind listen accept connect; then inf "You have BSD sockets." echo "#define HAS_SOCKETS" >> s.h has_sockets=yes elif sh ./hasgot -lnsl -lsocket socket socketpair bind listen accept connect then inf "You have BSD sockets (with libraries '-lnsl -lsocket')" cclibs="$cclibs -lnsl -lsocket" echo "#define HAS_SOCKETS" >> s.h has_sockets=yes elif sh ./hasgot -lnetwork socket socketpair bind listen accept connect; then echo "You have BSD sockets (with library '-lnetwork')" cclibs="$cclibs -lnetwork" echo "#define HAS_SOCKETS" >> s.h has_sockets=yes else case "$target" in *-*-mingw*) inf "You have BSD sockets (with libraries '-lws2_32')" cclibs="$cclibs -lws2_32" echo "#define HAS_SOCKETS" >> s.h has_sockets=yes ;; *) ;; esac fi if sh ./hasgot -i sys/socket.h -t socklen_t; then inf "socklen_t is defined in " echo "#define HAS_SOCKLEN_T" >> s.h fi if sh ./hasgot inet_aton; then inf "inet_aton() found." echo "#define HAS_INET_ATON" >> s.h fi if sh ./hasgot -i sys/types.h -i sys/socket.h -i netinet/in.h \ -t 'struct sockaddr_in6' \ && sh ./hasgot getaddrinfo getnameinfo inet_pton inet_ntop; then inf "IPv6 is supported." echo "#define HAS_IPV6" >> s.h fi if sh ./hasgot -i stdint.h; then inf "stdint.h found." echo "#define HAS_STDINT_H" >> s.h fi if sh ./hasgot -i unistd.h; then inf "unistd.h found." echo "#define HAS_UNISTD" >> s.h fi if sh ./hasgot -i sys/types.h -t off_t; then inf "off_t is defined in " echo "#define HAS_OFF_T" >> s.h fi if sh ./hasgot -i sys/types.h -i dirent.h; then inf "dirent.h found." echo "#define HAS_DIRENT" >> s.h fi if sh ./hasgot rewinddir; then inf "rewinddir() found." echo "#define HAS_REWINDDIR" >> s.h fi if sh ./hasgot lockf; then inf "lockf() found." echo "#define HAS_LOCKF" >> s.h fi if sh ./hasgot mkfifo; then inf "mkfifo() found." echo "#define HAS_MKFIFO" >> s.h fi if sh ./hasgot getcwd; then inf "getcwd() found." echo "#define HAS_GETCWD" >> s.h fi if sh ./hasgot getpriority setpriority; then inf "getpriority() found." echo "#define HAS_GETPRIORITY" >> s.h fi if sh ./hasgot -i sys/types.h -i utime.h && sh ./hasgot utime; then inf "utime() found." echo "#define HAS_UTIME" >> s.h fi if sh ./hasgot utimes; then inf "utimes() found." echo "#define HAS_UTIMES" >> s.h fi if sh ./hasgot dup2; then inf "dup2() found." echo "#define HAS_DUP2" >> s.h fi if sh ./hasgot fchmod fchown; then inf "fchmod() found." echo "#define HAS_FCHMOD" >> s.h fi if sh ./hasgot truncate ftruncate; then inf "truncate() found." echo "#define HAS_TRUNCATE" >> s.h fi select_include='' if sh ./hasgot -i sys/types.h -i sys/select.h; then inf "sys/select.h found." echo "#define HAS_SYS_SELECT_H" >> s.h select_include='-i sys/select.h' fi has_select=no if sh ./hasgot select && \ sh ./hasgot -i sys/types.h $select_include -t fd_set ; then inf "select() found." echo "#define HAS_SELECT" >> s.h has_select=yes fi if sh ./hasgot nanosleep ; then inf "nanosleep() found." echo "#define HAS_NANOSLEEP" >> s.h fi if sh ./hasgot symlink readlink lstat; then inf "symlink() found." echo "#define HAS_SYMLINK" >> s.h fi has_wait=no if sh ./hasgot waitpid; then inf "waitpid() found." echo "#define HAS_WAITPID" >> s.h has_wait=yes fi if sh ./hasgot wait4; then inf "wait4() found." echo "#define HAS_WAIT4" >> s.h has_wait=yes fi if sh ./hasgot -i limits.h && sh ./runtest getgroups.c; then inf "getgroups() found." echo "#define HAS_GETGROUPS" >> s.h fi if sh ./hasgot -i limits.h -i grp.h && sh ./runtest setgroups.c; then inf "setgroups() found." echo "#define HAS_SETGROUPS" >> s.h fi if sh ./hasgot -i limits.h -i grp.h && sh ./runtest initgroups.c; then inf "initgroups() found." echo "#define HAS_INITGROUPS" >> s.h fi if sh ./hasgot -i termios.h && sh ./hasgot tcgetattr tcsetattr tcsendbreak tcflush tcflow; then inf "POSIX termios found." echo "#define HAS_TERMIOS" >> s.h fi if sh ./runtest async_io.c; then inf "Asynchronous I/O are supported." echo "#define HAS_ASYNC_IO" >> s.h fi has_setitimer=no if sh ./hasgot setitimer; then inf "setitimer() found." echo "#define HAS_SETITIMER" >> s.h has_setitimer="yes" fi if sh ./hasgot gethostname; then inf "gethostname() found." echo "#define HAS_GETHOSTNAME" >> s.h fi if sh ./hasgot -i sys/utsname.h && sh ./hasgot uname; then inf "uname() found." echo "#define HAS_UNAME" >> s.h fi has_gettimeofday=no if sh ./hasgot gettimeofday; then inf "gettimeofday() found." echo "#define HAS_GETTIMEOFDAY" >> s.h has_gettimeofday="yes" fi if sh ./hasgot mktime; then inf "mktime() found." echo "#define HAS_MKTIME" >> s.h fi case "$target" in *-*-cygwin*) ;; # setsid emulation under Cygwin breaks the debugger *) if sh ./hasgot setsid; then inf "setsid() found." echo "#define HAS_SETSID" >> s.h fi;; esac if sh ./hasgot putenv; then inf "putenv() found." echo "#define HAS_PUTENV" >> s.h fi if sh ./hasgot -i locale.h && sh ./hasgot setlocale; then inf "setlocale() and found." echo "#define HAS_LOCALE" >> s.h fi if sh ./hasgot $dllib dlopen; then inf "dlopen() found." elif sh ./hasgot $dllib -ldl dlopen; then inf "dlopen() found in -ldl." dllib="$dllib -ldl" else case "$target" in *-*-mingw*) ;; *) shared_libraries_supported=false esac fi if $shared_libraries_supported; then inf "Dynamic loading of shared libraries is supported." echo "#define SUPPORT_DYNAMIC_LINKING" >> s.h if $dl_needs_underscore; then echo '#define DL_NEEDS_UNDERSCORE' >>s.h fi fi if sh ./hasgot -i sys/types.h -i sys/mman.h && sh ./hasgot mmap munmap; then inf "mmap() found." echo "#define HAS_MMAP" >> s.h fi if sh ./hasgot pwrite; then inf "pwrite() found" echo "#define HAS_PWRITE" >> s.h fi nanosecond_stat=none for i in 1 2 3; do if sh ./trycompile -DHAS_NANOSECOND_STAT=$i nanosecond_stat.c; then nanosecond_stat=$i; break fi done if test $nanosecond_stat != "none"; then inf "stat() supports nanosecond precision." echo "#define HAS_NANOSECOND_STAT $nanosecond_stat" >> s.h fi nargs=none for i in 5 6; do if sh ./trycompile -DSYS_${system} -DNUM_ARGS=${i} gethostbyname.c; then nargs=$i; break; fi done if test $nargs != "none"; then inf "gethostbyname_r() found (with ${nargs} arguments)." echo "#define HAS_GETHOSTBYNAME_R $nargs" >> s.h fi nargs=none for i in 7 8; do if sh ./trycompile -DSYS_${system} -DNUM_ARGS=${i} gethostbyaddr.c; then nargs=$i; break; fi done if test $nargs != "none"; then inf "gethostbyaddr_r() found (with ${nargs} arguments)." echo "#define HAS_GETHOSTBYADDR_R $nargs" >> s.h fi if sh ./hasgot mkstemp; then inf "mkstemp() found" echo "#define HAS_MKSTEMP" >> s.h fi if sh ./hasgot nice; then inf "nice() found" echo "#define HAS_NICE" >> s.h fi if sh ./hasgot dup3; then inf "dup3() found" echo "#define HAS_DUP3" >> s.h fi if sh ./hasgot pipe2; then inf "pipe2() found" echo "#define HAS_PIPE2" >> s.h fi if sh ./hasgot accept4; then inf "accept4() found" echo "#define HAS_ACCEPT4" >> s.h fi if sh ./hasgot getauxval; then inf "getauxval() found." echo "#define HAS_GETAUXVAL" >> s.h fi if sh ./hasgot -i sys/shm.h; then inf "sys/shm.h found." echo "#define HAS_SYS_SHM_H" >> s.h fi if sh ./hasgot execvpe; then inf "execvpe() found." echo "#define HAS_EXECVPE" >> s.h fi # Determine if the debugger is supported if test -n "$with_debugger"; then if test "$has_sockets" = "yes"; then inf "Replay debugger supported." with_debugger="ocamldebugger" else inf "No replay debugger (missing system calls)" with_debugger="" fi fi # Determine if system stack overflows can be detected case "$arch,$system" in i386,linux_elf|amd64,linux|power,rhapsody|amd64,macosx|i386,macosx \ |amd64,openbsd|i386,bsd_elf) inf "System stack overflow can be detected." echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h;; *) inf "Cannot detect system stack overflow.";; esac # Determine if the POSIX threads library is supported systhread_support=false if test "$pthread_wanted" = "yes"; then case "$target" in *-*-solaris*) pthread_link="-lpthread -lposix4" pthread_caml_link="-cclib -lpthread -cclib -lposix4";; *-*-dragon*) pthread_link="-pthread" pthread_caml_link="-cclib -pthread";; *-*-freebsd*) pthread_link="-pthread" pthread_caml_link="-cclib -pthread";; *-*-openbsd*) pthread_link="-pthread" pthread_caml_link="-cclib -pthread";; *-*-haiku*) pthread_link="" pthread_caml_link="";; *) pthread_link="-lpthread" pthread_caml_link="-cclib -lpthread";; esac if sh ./hasgot -i pthread.h $pthread_link pthread_self; then inf "POSIX threads library supported." systhread_support=true otherlibraries="$otherlibraries systhreads" common_cppflags="$common_cppflags -D_REENTRANT" case "$target" in *-*-freebsd*|*-*-dragonfly*) common_cppflags="$common_cppflags -D_THREAD_SAFE";; *-*-openbsd*) common_cflags="$common_cflags -pthread"; asppflags="$asppflags -pthread";; esac inf "Options for linking with POSIX threads: $pthread_link" if sh ./hasgot $pthread_link sigwait; then inf "sigwait() found" echo "#define HAS_SIGWAIT" >> s.h fi else inf "POSIX threads not found." pthread_link="" fi else pthread_link="" fi config PTHREAD_LINK "$pthread_link" config PTHREAD_CAML_LINK "$pthread_caml_link" # Determine if the bytecode thread library is supported if test "$has_select" = "yes" \ && test "$has_setitimer" = "yes" \ && test "$has_gettimeofday" = "yes" \ && test "$has_wait" = "yes"; then inf "Bytecode threads library supported." otherlibraries="$otherlibraries threads" else inf "Bytecode threads library not supported (missing system calls)" fi # Determine the location of X include files and libraries # If the user specified -x11include and/or -x11lib, these settings # are used. Otherwise, we check whether there is pkg-config, and take # the flags from there. Otherwise, we search the location. x11_include="not found" x11_link="not found" if test -z "$x11_include_dir" -a -z "$x11_lib_dir"; then if pkg-config --exists x11 2>/dev/null; then x11_include=`pkg-config --cflags x11` x11_link=`pkg-config --libs x11` fi fi if test "$x11_include" = "not found"; then for dir in \ $x11_include_dir \ \ /usr/X11R7/include \ /usr/include/X11R7 \ /usr/local/X11R7/include \ /usr/local/include/X11R7 \ /opt/X11R7/include \ \ /usr/X11R6/include \ /usr/include/X11R6 \ /usr/local/X11R6/include \ /usr/local/include/X11R6 \ /opt/X11R6/include \ \ /usr/X11/include \ /usr/include/X11 \ /usr/local/X11/include \ /usr/local/include/X11 \ /opt/X11/include \ \ /usr/X11R5/include \ /usr/include/X11R5 \ /usr/local/X11R5/include \ /usr/local/include/X11R5 \ /usr/local/x11r5/include \ /opt/X11R5/include \ \ /usr/X11R4/include \ /usr/include/X11R4 \ /usr/local/X11R4/include \ /usr/local/include/X11R4 \ \ /usr/X386/include \ /usr/x386/include \ /usr/XFree86/include/X11 \ \ /usr/include \ /usr/local/include \ /usr/unsupported/include \ /usr/athena/include \ /usr/lpp/Xamples/include \ \ /usr/openwin/include \ /usr/openwin/share/include \ ; \ do if test -f $dir/X11/X.h; then x11_include_dir=$dir x11_include="-I$dir" break fi done if test "$x11_include" = "not found"; then x11_try_lib_dir='' else x11_try_lib_dir=`echo $x11_include_dir | sed -e 's|include|lib|'` fi for dir in \ $x11_lib_dir \ $x11_try_lib_dir \ \ /usr/X11R6/lib64 \ /usr/X11R6/lib \ /usr/lib/X11R6 \ /usr/local/X11R6/lib \ /usr/local/lib/X11R6 \ /opt/X11R6/lib \ \ /usr/X11/lib \ /usr/lib/X11 \ /usr/local/X11/lib \ /usr/local/lib/X11 \ /opt/X11/lib \ \ /usr/X11R5/lib \ /usr/lib/X11R5 \ /usr/local/X11R5/lib \ /usr/local/lib/X11R5 \ /usr/local/x11r5/lib \ /opt/X11R5/lib \ \ /usr/X11R4/lib \ /usr/lib/X11R4 \ /usr/local/X11R4/lib \ /usr/local/lib/X11R4 \ \ /usr/X386/lib \ /usr/x386/lib \ /usr/XFree86/lib/X11 \ \ /usr/lib64 \ /usr/lib \ /usr/local/lib \ /usr/unsupported/lib \ /usr/athena/lib \ /usr/lpp/Xamples/lib \ /lib/usr/lib/X11 \ \ /usr/openwin/lib \ /usr/openwin/share/lib \ \ /usr/lib/i386-linux-gnu \ /usr/lib/x86_64-linux-gnu \ \ /usr/lib/`echo $target | sed -e "s/-[^-]*//"` \ ; \ do if test -f $dir/libX11.a || \ test -f $dir/libX11.so || \ test -f $dir/libX11.dll.a || \ test -f $dir/libX11.dylib || \ test -f $dir/libX11.sa; then if test $dir = /usr/lib; then x11_link="-lX11" else case "$target" in *-*-freebsd*|*-*-dragonfly*) x11_link="-L$dir -lX11";; *-kfreebsd*-gnu) x11_link="-L$dir -lX11";; *-*-*bsd*) x11_link="-R$dir -L$dir -lX11";; *) x11_link="-L$dir -lX11";; esac fi break fi done fi if test "$x11_include" != "not found"; then if test "$x11_include" = "-I/usr/include"; then x11_include="" fi if sh ./hasgot $x11_include $x11_link -i X11/Xlib.h XrmInitialize; then inf "X11 works" else wrn "Cannot compile X11 program." x11_include="not found" fi fi has_graph=false if test "$x11_include" = "not found" || test "$x11_link" = "not found" then wrn 'X11 not found, the "graph" library will not be supported.' x11_include="not found" x11_link="not found" else inf "Options for compiling for X11: $x11_include" inf "Options for linking with X11: $x11_link" if test "$graph_wanted" = yes then has_graph=true otherlibraries="$otherlibraries graph" fi fi echo "X11_INCLUDES=$x11_include" >> Makefile echo "X11_LINK=$x11_link" >> Makefile # Look for BFD library if $shared_libraries_supported && ./hasgot -DPACKAGE=ocaml -i bfd.h ; then inf "BFD library found." if sh ./hasgot -DPACKAGE=ocaml -lbfd bfd_openr; then LIBBFD_LINK="-lbfd" inf "BFD links with $LIBBFD_LINK" echo "#define HAS_LIBBFD" >> s.h elif sh ./hasgot -DPACKAGE=ocaml -lbfd -ldl bfd_openr; then LIBBFD_LINK="-lbfd -ldl" inf "BFD links with $LIBBFD_LINK" echo "#define HAS_LIBBFD" >> s.h elif sh ./hasgot -DPACKAGE=ocaml -lbfd -ldl -liberty bfd_openr; then LIBBFD_LINK="-lbfd -ldl -liberty" inf "BFD links with $LIBBFD_LINK" echo "#define HAS_LIBBFD" >> s.h elif sh ./hasgot -DPACKAGE=ocaml -lbfd -ldl -liberty -lz bfd_openr; then LIBBFD_LINK="-lbfd -ldl -liberty -lz" inf "BFD links with $LIBBFD_LINK" echo "#define HAS_LIBBFD" >> s.h else wrn "Could not determine link options for the BFD library" LIBBFD_LINK= fi echo "LIBBFD_LINK=$LIBBFD_LINK" >> Makefile echo LIBBFD_INCLUDE= >>Makefile elif sh ./hasgot -DPACKAGE=ocaml -I/opt/local/include -i bfd.h && \ sh ./hasgot -DPACKAGE=ocaml -L/opt/local/lib -lbfd -ldl \ -liberty -lz -lintl bfd_openr then # MacOSX with binutils from MacPorts inf "BFD library found." echo "#define HAS_LIBBFD" >> s.h echo "LIBBFD_LINK=-L/opt/local/lib -lbfd -ldl -liberty -lz -lintl" >> Makefile echo LIBBFD_INCLUDE=-I/opt/local/include >>Makefile else wrn "BFD library not found, 'objinfo' will be unable to display info" \ " on .cmxs files." echo "LIBBFD_LINK=" >> Makefile echo "LIBBFD_INCLUDE=" >> Makefile fi # Check whether assembler supports CFI directives asm_cfi_supported=false export as aspp if ! $with_cfi; then echo "CFI support: disabled by command-line option -no-cfi" elif sh ./tryassemble cfi.S; then echo "#define ASM_CFI_SUPPORTED" >> m.h asm_cfi_supported=true inf "Assembler supports CFI" else inf "Assembler does not support CFI" fi if test "$with_frame_pointers" = "true"; then case "$target,$cc" in x86_64-*-linux*,gcc*|x86_64-*-linux*,clang*) common_cflags="$common_cflags -g -fno-omit-frame-pointer" echo "#define WITH_FRAME_POINTERS" >> m.h ;; *) err "Unsupported architecture with frame pointers";; esac fi if $no_naked_pointers; then echo "#define NO_NAKED_POINTERS" >> m.h fi # Check for mmap support for huge pages and contiguous heap if sh ./runtest mmap-huge.c; then has_huge_pages=true echo "#define HAS_HUGE_PAGES" >>s.h echo "#define HUGE_PAGE_SIZE (4 * 1024 * 1024)" >>s.h inf "mmap supports huge pages" else has_huge_pages=false fi # Spacetime profiling, including libunwind detection # The number of bits used for profiling information is configurable here. # The more bits used for profiling, the smaller will be Max_wosize. # Note that PROFINFO_WIDTH must still be defined even if not configuring # for Spacetime (see comment in byterun/caml/mlvalues.h on [Profinfo_hd]). echo "#define PROFINFO_WIDTH $profinfo_width" >> m.h if $with_profinfo; then echo "#define WITH_PROFINFO" >> m.h fi if $with_spacetime; then case "$arch,$system" in amd64,*) spacetime_supported=true ;; *) spacetime_supported=false ;; esac libunwind_warning=false if $spacetime_supported; then echo "Spacetime profiling will be available." echo "#define WITH_SPACETIME" >> m.h if $enable_call_counts; then echo "#define ENABLE_CALL_COUNTS" >> m.h fi if $disable_libunwind; then has_libunwind=no libunwind_available=false echo "libunwind support for Spacetime profiling was explicitly disabled." else # On Mac OS X, we always use the system libunwind. if test "$libunwind_lib_dir" != ""; then case "$arch,$system" in amd64,macosx) inf "[WARNING] -libunwind* options are ignored on Mac OS X" libunwind_warning=true libunwind_lib="-framework System" libunwind_lib_temp="$libunwind_lib" # We need unwinding information at runtime, but since we use # -no_compact_unwind, we also need -keep_dwarf_unwind otherwise # the OS X linker will chuck away the DWARF-like (.eh_frame) # information. (Older versions of OS X don't provide this.) mkexe="$mkexe -Wl,-keep_dwarf_unwind" mksharedlib="$mksharedlib -Wl,-keep_dwarf_unwind" ;; *) libunwind_lib="-L$libunwind_lib_dir -lunwind -lunwind-x86_64" libunwind_lib_temp="-Xl $libunwind_lib" ;; esac else case "$arch,$system" in amd64,macosx) libunwind_lib="-framework System" libunwind_lib_temp="$libunwind_lib" mkexe="$mkexe -Wl,-keep_dwarf_unwind" mksharedlib="$mksharedlib -Wl,-keep_dwarf_unwind" ;; *) libunwind_lib="-lunwind -lunwind-x86_64" libunwind_lib_temp="$libunwind_lib" ;; esac fi if test "$libunwind_include_dir" != ""; then case "$arch,$system" in amd64,macosx) if ! $libunwind_warning; then inf "[WARNING] -libunwind* options are ignored on Mac OS X" fi libunwind_include="" ;; *) libunwind_include="-I$libunwind_include_dir" ;; esac else libunwind_include="" fi if sh ./hasgot -i libunwind.h $libunwind_lib_temp $libunwind_include; \ then echo "#define HAS_LIBUNWIND" >> s.h has_libunwind=yes libunwind_available=true echo "libunwind support for Spacetime profiling will be available." else has_libunwind=no libunwind_available=false echo "libunwind support for Spacetime profiling will not be available." fi fi else echo "Spacetime profiling unavailable: it needs a 64-bit platform with" echo " support for the native code OCaml compiler." with_spacetime=false libunwind_available=false has_libunwind=no fi fi if ! $shared_libraries_supported; then with_cplugins=false fi if $with_fpic; then common_cflags="$common_cflags $sharedcccompopts" aspp="$aspp $sharedcccompopts" fi if $with_cplugins; then echo "#define CAML_WITH_CPLUGINS" >> m.h fi if $with_fpic; then echo "#define CAML_WITH_FPIC" >> m.h fi if $force_safe_string; then echo "#define CAML_SAFE_STRING" >> m.h fi if $flat_float_array; then echo "#define FLAT_FLOAT_ARRAY" >> m.h fi # Finish generated files cclibs="$cclibs $mathlib" config CC "$cc" config CPP "$cpp" config CFLAGS "$common_cflags $internal_cflags" config CPPFLAGS "$common_cppflags $internal_cppflags" config OCAMLC_CFLAGS "$common_cflags $sharedcccompopts" config OCAMLC_CPPFLAGS "$common_cppflags" config LDFLAGS "$ldflags" config BYTECCLIBS "$cclibs $dllib $pthread_link $instrumented_runtime_libs" config RPATH "$rpath" config EXE "$exe" config EMPTY "" config OUTPUTEXE "-o \$(EMPTY)" config SUPPORTS_SHARED_LIBRARIES "$shared_libraries_supported" config SHAREDCCCOMPOPTS "$sharedcccompopts" config MKSHAREDLIBRPATH "$mksharedlibrpath" config NATDYNLINKOPTS "$natdynlinkopts" cat >> Makefile <