#! /bin/sh # # %CopyrightBegin% # # Copyright Ericsson AB 2002-2014. All Rights Reserved. # # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. # # %CopyrightEnd% # # Expected autoconf version EXPECTED_AUTOCONF_VERSION=2.59 # Global configuration variables # # NOTE: lazy_configure depends on '.' always being last directory if [ -z "$ONLY_ERTS" ]; then AUTOCONF_SUBDIRS="lib lib/* lib/test_server/src" fi AUTOCONF_SUBDIRS="$AUTOCONF_SUBDIRS erts ." # `bootstrap_apps' should include application that are built, or # partly built in one of the bootstrap phases. Applications that # only get some static includes copied into the bootstrap directory # should not be included. bootstrap_apps="erts lib/asn1 lib/compiler lib/hipe lib/ic lib/kernel lib/parsetools lib/sasl lib/snmp lib/stdlib lib/syntax_tools" # We will quote a bit more than needed, but the important thing is that # all that needs quoting will be quoted... DONT_QUOTE="A-Za-z0-9~/=_+-" # Utility functions usage () { echo "Available options (-a switch select all applications):" echo " setup [-a] [] - does autoconf, configure and boot." echo " all [-a] - does autoconf, configure, boot, release" echo " autoconf - (re)build the configure scripts" echo " configure [] - does the actual configuration" echo " boot [-a] - bootstraps and builds the system (after configure)" echo " release - creates a small release to " echo " release [-a] - creates full release to " echo " smp [-a] - build an Erlang system, smp flavor only" echo " tests - Build testsuites to " echo " patch_app ... - build given apps to " echo " If core apps are patched, new start scripts will be created" echo " and 'Install' must be run again." echo "" echo "These are for cleaning up an open source distribution" echo "with prebuilt files, so that it resembles the clean developers" echo "codebase:" echo " remove_prebuilt_files - create a minimal source tree" echo " save_bootstrap - recreate primary bootstrap" echo "" echo "Special targets for Windows(tm) build:" echo " debuginfo_win32 - adds debug emulator and pdb files to " echo " installer_win32 - creates a windows installer from " echo "" echo "Before trying to build on windows, consider the following option" echo " env_win32 [] - echo environment settings for win32 with visual C++, use with eval" echo " The optional can be x64 for 64bit Windows 7" echo " or x86 for 32bit Windows XP+" echo " env_win64 - echo environment settings for win32 with visual C++, use with eval" echo " Note that env_win32 x64 gives the same result, Windows 7 64bit" echo " env_mingw32 - echo environment settings for win32 with MinGW, use with eval" echo " - experimental!" echo " env_msys64 - echo environment settings for win32 with visual C++ running " echo " msys and mingw, use with eval" echo " - experimental!" echo "" echo "Before trying to build for vxworks, consider the following option" echo " env_vxworks - echo environment settings for vxworks, use with eval" echo "" case $version_controller in none) ;; git) echo "" echo "update_primary [--no-commit] - build and maybe commit a new primary bootstrap" ;; esac case $version_controller in none) ;; git) echo "" echo "update_preloaded [--no-commit] - build and maybe commit the preloaded modules" ;; esac } git_required () { echo "This operation must be run in a git repository." exit 1 } hide_vars () { script= for var in "$@"; do if [ "X$var" != "X" ]; then script="$script test \"X\$$var\" = \"X\" || hidden_$var=\$$var; unset $var;" fi done if [ "X$script" != "X" ]; then eval "$script" fi unset script } restore_vars () { script= for var in "$@"; do if [ "X$var" != "X" ]; then script="$script unset $var; test \"X\$hidden_$var\" = \"X\" || { $var=\$hidden_$var; export $var; } ; unset hidden_$var;" fi done if [ "X$script" != "X" ]; then eval "$script" fi unset script } check_erltop () { ERLTOP_FORCED=false if [ "X$ERL_TOP" = "X" ]; then if [ -f ./otp_build -a -f ./erts/autoconf/config.guess ]; then ERLTOP_FORCED=true ERL_TOP=`/bin/pwd` export ERL_TOP else echo "The environment variable ERL_TOP must be set." >&2 exit 1 fi fi } target_contains () { Y=`echo $TARGET | sed "s,$1,,g"` [ X"$Y" != X"$TARGET" ] return $? } determine_version_controller () { version_controller=none # The current directory is now $ERL_TOP. Find out whether # this directory is a git repository. if { git rev-parse --git-dir; } 2>/dev/null >/dev/null; then version_controller=git fi } # Execution of the different options # Special static config flags for certain platforms are set here set_config_flags () { # # NOTE! Do not add special flags here without a *very good* # reason. We normally do not want "./otp_build configure" # and "./configure" to produce different results. # However, in the Windows case this does not matter, since # the only supported way to build on Windows is using # otp_build. # # * Extra flags to pass to configure are placed in `CONFIG_FLAGS'. # * The command line is no longer added to `CONFIG_FLAGS' by # `set_config_flags'. It is instead passed directly to # `run_configure', or added to `CONFIG_FLAGS' at some other # place. # * `CONFIG_FLAGS' may contain flags when `set_config_flags' is # called. These flags should survive the call to `set_config_flags' # (in the cross compilation case the whole command line as well as # the cross configuration have been moved here). if target_contains free_source; then CONFIG_FLAGS="$CONFIG_FLAGS --host=$TARGET" fi # Link SSL static for win32 binary distributions if not overridden if target_contains win32; then XX=`echo $* | grep -v dynamic-ssl-lib` if [ "$*" = "$XX" ]; then CONFIG_FLAGS="--disable-dynamic-ssl-lib $CONFIG_FLAGS" fi CONFIG_FLAGS="--build=$BUILDSYS build_alias=win32 --host=win32 --target=win32 $CONFIG_FLAGS" fi if [ "x$OVERRIDE_CONFIG_CACHE" = "x" ]; then CONFIG_FLAGS="$CONFIG_FLAGS --cache-file=/dev/null" else CONFIG_FLAGS="$CONFIG_FLAGS --cache-file=$OVERRIDE_CONFIG_CACHE" fi env_to_config_flags $erl_build_tool_vars export CONFIG_FLAGS; } NL="\ " create_lib_configure_in() { cd $ERL_TOP # Multiple versions of autoconf generates code that # don't work on all platforms (e.g. SunOS 5.8) if # sub directories are soft links. Internally at Ericsson # some OTP application directories are soft links. # An added "/." solves this problem. sdirs= for lib_app in $bootstrap_apps; do case $lib_app in lib/*) if [ -f "$lib_app/configure.in" ]; then app=`echo "$lib_app" | sed "s|lib/\(.*\)|\1|"` sdirs="${sdirs}test ! -f $app/configure || AC_CONFIG_SUBDIRS($app/.)${NL}" fi;; *) ;; esac done sed_bootstrap="s%@BOOTSTRAP_CONFIGURE_APPS@%$sdirs%g" sdirs= for lib_app in lib/*; do is_bapp=false for bapp in $bootstrap_apps; do test $bapp != $lib_app || { is_bapp=true; break; } done if [ $is_bapp = false ] && [ -f "$lib_app/configure.in" ]; then app=`echo "$lib_app" | sed "s|lib/\(.*\)|\1|"` sdirs="${sdirs} test ! -f $app/configure || AC_CONFIG_SUBDIRS($app/.)${NL}" fi done sed_non_bootstrap="s%@NON_BOOTSTRAP_CONFIGURE_APPS@%$sdirs%g" rm -f lib/configure.in sed "$sed_bootstrap;$sed_non_bootstrap" > lib/configure.in < lib/configure.in.src || { echo "Failed to create lib/configure.in" exit 1 } } find_sum() { candidates="sum cksum md5sum sha1sum" SUM_CMD="wc" for x in $candidates; do if (echo foo | $x > /dev/null 2>&1); then SUM_CMD=$x break fi done } chk_eq() { master=$1 shift slaves="$@" master_sum=`$SUM_CMD $master | awk '{print $1}'` for x in $slaves; do s=`$SUM_CMD $x | awk '{print $1}'` if test "$s" != "$master_sum"; then echo "Error: $master and $x are not equal, make sure they are!" >&2 echo "Maybe you would want to:" >&2 echo "for x in $slaves; do cp $master \$x; done" >&2 echo "? Or something else is wrong." 2>&1 exit 2 fi done } check_config_helpers () { aclocals="./aclocal.m4 ./lib/erl_interface/aclocal.m4 ./lib/odbc/aclocal.m4 ./lib/wx/aclocal.m4 ./lib/megaco/aclocal.m4" install_shs="./lib/common_test/priv/auxdir/install-sh ./lib/erl_interface/src/auxdir/install-sh ./lib/test_server/src/install-sh" config_guesses="./lib/common_test/priv/auxdir/config.guess ./lib/erl_interface/src/auxdir/config.guess ./lib/test_server/src/config.guess" config_subs="./lib/common_test/priv/auxdir/config.sub ./lib/erl_interface/src/auxdir/config.sub ./lib/test_server/src/config.sub" aclocal_master="./erts/aclocal.m4" install_sh_master="./erts/autoconf/install-sh" config_guess_master="./erts/autoconf/config.guess" config_sub_master="./erts/autoconf/config.sub" find_sum chk_eq $aclocal_master $aclocals chk_eq $install_sh_master $install_shs chk_eq $config_guess_master $config_guesses chk_eq $config_sub_master $config_subs } do_autoconf () { create_lib_configure_in check_config_helpers if target_contains win32; then # Select the correct autoconf on cygwin save_want_autoconf_ver=$WANT_AUTOCONF_VER WANT_AUTOCONF_VER=$EXPECTED_AUTOCONF_VERSION export WANT_AUTOCONF_VER fi exp_ac_vsn=$EXPECTED_AUTOCONF_VERSION ac_vsn_blob=`autoconf --version` ac_vsn=`echo x$ac_vsn_blob | sed "s|[^0-9]*\([0-9][^ \t\n]*\).*|\1|"` case "$ac_vsn" in $exp_ac_vsn) ;; *) echo "***************************************************" 1>&2 echo "***************************************************" 1>&2 echo "*** WARNING: System might fail to configure or" 1>&2 echo "*** might be erroneously configured" 1>&2 echo "*** since autoconf version $ac_vsn is used" 1>&2 echo "*** instead of version $exp_ac_vsn!" 1>&2 echo "***************************************************" 1>&2 echo "***************************************************" 1>&2 ;; esac if [ ! -z "$OVERRIDE_CONFIGURE" ]; then echo "Autoconf disabled on target $TARGET, but is performed on host" >&2 # We still use erts configure for erl_interface and VxWorks case "$TARGET" in *vxworks*) AUTOCONF_SUBDIRS=`echo $AUTOCONF_SUBDIRS | \ sed -e 's,lib/erl_interface,,' \ -e 's,lib/gs,,' \ -e 's,lib/megaco,,'` ;; esac fi hide_vars OVERRIDE_TARGET TARGET TARGET=$BUILDSYS export TARGET for d in $AUTOCONF_SUBDIRS; do file="$d/configure.in" [ -f "$file" ] || continue echo "" [ ! -d "$d/autom4te.cache" ] || { echo "=== cleaning $d/autom4te.cache" rm -f "$d"/autom4te.cache/* } echo "=== running autoconf in $d" ( cd "$d" && autoconf ) || exit 1 chdr=`cat "$file" | sed -n "s|.*\(AC_CONFIG_HEADER\).*|\1|p"` [ "$chdr" = "AC_CONFIG_HEADER" ] || continue echo "=== running autoheader in $d" ( cd "$d" && autoheader ) || exit 1 done restore_vars OVERRIDE_TARGET TARGET if target_contains win32; then WANT_AUTOCONF_VER=$save_want_autoconf_ver export WANT_AUTOCONF_VER fi } run_configure () { cdir="$ERL_TOP" [ -z "$ONLY_ERTS" ] || { cdir="$ERL_TOP/erts" CONFIG_FLAGS="$CONFIG_FLAGS --no-recursion" } echo "$cdir/configure $CONFIG_FLAGS" ${1+"$@"} (cd "$cdir" && $config_eval ./configure $CONFIG_FLAGS ${1+"$@"}) || exit 1 } env_to_config_flags () { for env_var in "$@"; do script="echo $env_var=\$$env_var; unset $env_var >/dev/null 2>&1" env_arg=`eval $script` case $env_arg in "$env_var=") ;; *[!$DONT_QUOTE]*) config_eval=eval new_arg=`echo "X$env_arg" | sed "s|^X||;s|\([^$DONT_QUOTE]\)|\\\\\\\\\1|g"` CONFIG_FLAGS="$CONFIG_FLAGS $new_arg";; *) CONFIG_FLAGS="$CONFIG_FLAGS $env_arg";; esac eval unset $env_var done } try_cross_configure () { cross_configure=no host_value= build_value= # Get `erl_xcomp_vars' . "$ERL_TOP/xcomp/erl-xcomp-vars.sh" || exit 1 for arg in ${1+"$@"}; do case "$arg" in --host=*) host_value=`echo $x | sed "s|^--host=\(.*\)|\1|"`;; --build=*) build_value=`echo $x | sed "s|^--build=\(.*\)|\1|"`;; --xcomp-conf=*) cross_configure=yes;; *) ;; esac done test $cross_configure = yes || { test "X$host_value" = "X" || { test "X$build_value" != "X" || build_value="$BUILDSYS" build_sys=`$ERL_TOP/erts/autoconf/config.sub "$build_value"` || exit 1 host_sys=`$ERL_TOP/erts/autoconf/config.sub "$host_value"` || exit 1 test "$host_sys" = "$build_sys" || cross_configure=yes } } test $cross_configure = yes || return 1 # cross configure... CONFIG_FLAGS= env_to_config_flags $erl_build_tool_vars $erl_xcomp_vars for arg in ${1+"$@"}; do case "$arg" in --host=*) host_value=`echo $x | sed "s|^--host=\(.*\)|\1|"`;; --build=*) build_value=`echo $x | sed "s|^--build=\(.*\)|\1|"`;; --xcomp-conf=*) # tilde expansion is not handled by the `configure' script, # but we do it for this argument. This argument is however not # a `configure' argument. xcomp_conf=`echo "X$arg" | sed "s|^X--xcomp-conf=\(.*\)\$|\1|g;s|\([^$DONT_QUOTE]\)|\\\\\\\\\1|g"` eval "xcomp_conf=$xcomp_conf" test "X$xcomp_conf" != "X" || { echo "$0: Missing xcomp-conf file name" exit 1 } test -f "$xcomp_conf" || { echo "$0: Missing xcomp-conf file: $xcomp_conf" exit 1 } . "$xcomp_conf" test $? -eq 0 || { echo "$0: Failed to read xcomp-conf file: $xcomp_conf" exit 1 } test "X$erl_xcomp_build" = "X" || build_value="$erl_xcomp_build" test "X$erl_xcomp_host" = "X" || host_value="$erl_xcomp_host" unset erl_xcomp_build unset erl_xcomp_host CONFIG_FLAGS="$CONFIG_FLAGS $erl_xcomp_configure_flags" unset erl_xcomp_configure_flags env_to_config_flags $erl_build_tool_vars $erl_xcomp_vars;; *[!$DONT_QUOTE]*) config_eval=eval new_arg=`echo "X$arg" | sed "s|^X||;s|\([^$DONT_QUOTE]\)|\\\\\\\\\1|g"` CONFIG_FLAGS="$CONFIG_FLAGS $new_arg";; *) CONFIG_FLAGS="$CONFIG_FLAGS $arg";; esac done CONFIG_FLAGS="--host=$host_value $CONFIG_FLAGS" test "X$build_value" != "Xguess" || build_value="$BUILDSYS" test "X$build_value" = "X" || CONFIG_FLAGS="--build=$build_value $CONFIG_FLAGS" # Configure build system for boot strap cat <