annotate make/autoconf/configure @ 47944:5ab3961d20dd

8191204: Post-consolidation cleaning up of the build system Reviewed-by: tbell, dholmes
author ihse
date Tue, 21 Nov 2017 09:56:35 +0100
parents ea082b202a23
children ba52fa7bbf14
rev   line source
ohair@14111 1 #!/bin/bash
ohair@14111 2 #
ihse@47405 3 # Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
ohair@14111 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@14111 5 #
ohair@14111 6 # This code is free software; you can redistribute it and/or modify it
ohair@14111 7 # under the terms of the GNU General Public License version 2 only, as
ohair@14111 8 # published by the Free Software Foundation.
ohair@14111 9 #
ohair@14111 10 # This code is distributed in the hope that it will be useful, but WITHOUT
ohair@14111 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@14111 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@14111 13 # version 2 for more details (a copy is included in the LICENSE file that
ohair@14111 14 # accompanied this code).
ohair@14111 15 #
ohair@14111 16 # You should have received a copy of the GNU General Public License version
ohair@14111 17 # 2 along with this work; if not, write to the Free Software Foundation,
ohair@14111 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@14111 19 #
ohair@14111 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@14111 21 # or visit www.oracle.com if you need additional information or have any
ohair@14111 22 # questions.
ohair@14111 23 #
ohair@14111 24
ihse@22722 25 if test "x$1" != xCHECKME; then
ihse@47454 26 echo "ERROR: Calling this wrapper script directly is not supported."
ihse@22722 27 echo "Use the 'configure' script in the top-level directory instead."
ihse@47454 28 exit 1
ohair@14111 29 fi
ohair@12258 30
ihse@47454 31 # The next argument is the absolute top-level directory path.
ihse@47454 32 # The TOPDIR variable is passed on to configure.ac.
ihse@47454 33 TOPDIR="$2"
ihse@47454 34 # Remove these two arguments to get to the user supplied arguments
ihse@47454 35 shift
ihse@47454 36 shift
ihse@47454 37
ihse@28358 38 if test "x$BASH" = x; then
ihse@28358 39 echo "Error: This script must be run using bash." 1>&2
ihse@28358 40 exit 1
ihse@28358 41 fi
ihse@28813 42 # Force autoconf to use bash. This also means we must disable autoconf re-exec.
ihse@28358 43 export CONFIG_SHELL=$BASH
ihse@28813 44 export _as_can_reexec=no
ihse@28358 45
erikj@47217 46 conf_script_dir="$TOPDIR/make/autoconf"
ohair@13697 47
ihse@47405 48 if test "x$CUSTOM_CONFIG_DIR" != x; then
ihse@47405 49 if test ! -e $CUSTOM_CONFIG_DIR/generated-configure.sh; then
ihse@47405 50 echo "CUSTOM_CONFIG_DIR not pointing to a proper custom config dir."
ihse@47405 51 echo "Error: Cannot continue" 1>&2
ihse@47405 52 exit 1
ihse@47405 53 fi
ohair@13697 54 fi
erikj@13132 55
erikj@13132 56 ###
erikj@13132 57 ### Test that the generated configure is up-to-date
erikj@13132 58 ###
erikj@13132 59
ohair@14111 60 run_autogen_or_fail() {
mduigou@24655 61 if test "x`which autoconf 2> /dev/null | grep -v '^no autoconf in'`" = x; then
ohair@14111 62 echo "Cannot locate autoconf, unable to correct situation."
ohair@14111 63 echo "Please install autoconf and run 'bash autogen.sh' to update the generated files."
ohair@14111 64 echo "Error: Cannot continue" 1>&2
ohair@14111 65 exit 1
ohair@14111 66 else
ohair@14111 67 echo "Running autogen.sh to correct the situation"
ohair@14111 68 bash $conf_script_dir/autogen.sh
ohair@14111 69 fi
erikj@13132 70 }
erikj@13132 71
ohair@14111 72 check_autoconf_timestamps() {
ohair@14111 73 for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 ; do
ohair@14111 74 if test $file -nt $conf_script_dir/generated-configure.sh; then
ohair@14111 75 echo "Warning: The configure source files is newer than the generated files."
ohair@14111 76 run_autogen_or_fail
erikj@13132 77 fi
erikj@13132 78 done
erikj@13132 79
ihse@47405 80 if test "x$CUSTOM_CONFIG_DIR" != x; then
ohair@14111 81 # If custom source configure is available, make sure it is up-to-date as well.
ihse@47405 82 for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $CUSTOM_CONFIG_DIR/*.m4; do
ihse@47405 83 if test $file -nt $CUSTOM_CONFIG_DIR/generated-configure.sh; then
ohair@14111 84 echo "Warning: The configure source files is newer than the custom generated files."
ohair@14111 85 run_autogen_or_fail
ohair@14111 86 fi
ohair@14111 87 done
ohair@14111 88 fi
ohair@14111 89 }
ohair@14111 90
ohair@14111 91 check_hg_updates() {
mduigou@24655 92 if test "x`which hg 2> /dev/null | grep -v '^no hg in'`" != x; then
ihse@47944 93 conf_updated_autoconf_files=`cd $conf_script_dir && hg status -mard . 2> /dev/null`
ohair@14111 94 if test "x$conf_updated_autoconf_files" != x; then
ohair@14111 95 echo "Configure source code has been updated, checking time stamps"
ohair@14111 96 check_autoconf_timestamps
ihse@47405 97 elif test "x$CUSTOM_CONFIG_DIR" != x; then
ohair@14111 98 # If custom source configure is available, make sure it is up-to-date as well.
ihse@47944 99 conf_custom_updated_autoconf_files=`cd $CUSTOM_CONFIG_DIR && hg status -mard . 2> /dev/null`
ohair@14111 100 if test "x$conf_custom_updated_autoconf_files" != x; then
ohair@14111 101 echo "Configure custom source code has been updated, checking time stamps"
ohair@14111 102 check_autoconf_timestamps
ohair@14111 103 fi
ohair@14111 104 fi
ohair@14111 105 fi
ohair@14111 106 }
ohair@14111 107
ohair@14111 108 # Check for local changes
ohair@14111 109 check_hg_updates
ohair@14111 110
ihse@47405 111 if test "x$CUSTOM_CONFIG_DIR" != x; then
ohair@13697 112 # Test if open configure is newer than custom configure, if so, custom needs to
ohair@13697 113 # be regenerated. This test is required to ensure consistency with custom source.
ohair@14111 114 conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_script_dir/generated-configure.sh | cut -d"=" -f 2`
ihse@47405 115 conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $CUSTOM_CONFIG_DIR/generated-configure.sh | cut -d"=" -f 2`
ohair@14111 116 if test $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
ohair@14111 117 echo "Warning: The generated configure file contains changes not present in the custom generated file."
ohair@14111 118 run_autogen_or_fail
erikj@13132 119 fi
ohair@12258 120 fi
ohair@12258 121
ihse@20363 122 # Autoconf calls the configure script recursively sometimes.
ohair@13697 123 # Don't start logging twice in that case
ohair@14111 124 if test "x$conf_debug_configure" = xtrue; then
ohair@13697 125 conf_debug_configure=recursive
ohair@13697 126 fi
ihse@22716 127
erikj@13132 128 ###
erikj@13132 129 ### Process command-line arguments
erikj@13132 130 ###
ihse@22716 131
ihse@22716 132 # Returns a shell-escaped version of the argument given.
ihse@22716 133 function shell_quote() {
ihse@22716 134 if [[ -n "$1" ]]; then
ihse@22716 135 # Uses only shell-safe characters? No quoting needed.
ihse@22716 136 # '=' is a zsh meta-character, but only in word-initial position.
erikj@22729 137 if echo "$1" | grep '^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\.:,%/+=_-]\{1,\}$' > /dev/null \
erikj@22729 138 && ! echo "$1" | grep '^=' > /dev/null; then
ihse@22716 139 quoted="$1"
ihse@22716 140 else
erikj@22729 141 if echo "$1" | grep "[\'!]" > /dev/null; then
ihse@22716 142 # csh does history expansion within single quotes, but not
ihse@22716 143 # when backslash-escaped!
ihse@22716 144 local quoted_quote="'\\''" quoted_exclam="'\\!'"
ihse@22716 145 word="${1//\'/${quoted_quote}}"
ihse@22716 146 word="${1//\!/${quoted_exclam}}"
ihse@22716 147 fi
ihse@22716 148 quoted="'$1'"
ihse@22716 149 fi
ihse@22716 150 echo "$quoted"
ihse@22716 151 fi
ihse@22716 152 }
ihse@22716 153
ohair@14111 154 conf_processed_arguments=()
ihse@22716 155 conf_quoted_arguments=()
erikj@13132 156 conf_openjdk_target=
ohair@12258 157
erikj@13132 158 for conf_option
ohair@12258 159 do
ihse@22716 160
ihse@22716 161 # Process (and remove) our own extensions that will not be passed to autoconf
erikj@13132 162 case $conf_option in
ihse@20363 163 --openjdk-target=*)
ihse@20363 164 conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
ihse@22475 165 ;;
ihse@20363 166 --debug-configure)
ihse@20363 167 if test "x$conf_debug_configure" != xrecursive; then
ihse@20363 168 conf_debug_configure=true
ihse@20363 169 export conf_debug_configure
ihse@20363 170 fi
ihse@22475 171 ;;
ihse@20363 172 *)
ihse@22475 173 conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option")
ihse@22475 174 ;;
ohair@12258 175 esac
ohair@12258 176
ihse@22716 177 # Store all variables overridden on the command line
ihse@22716 178 case $conf_option in
ihse@22716 179 [^-]*=*)
ihse@22716 180 # Add name of variable to CONFIGURE_OVERRIDDEN_VARIABLES list inside !...!.
ihse@22716 181 conf_env_var=`expr "x$conf_option" : 'x\([^=]*\)='`
ihse@22716 182 CONFIGURE_OVERRIDDEN_VARIABLES="$CONFIGURE_OVERRIDDEN_VARIABLES!$conf_env_var!"
ihse@22716 183 ;;
ihse@22716 184 esac
ihse@22716 185
ihse@22716 186 # Save the arguments, intelligently quoted for CONFIGURE_COMMAND_LINE.
ihse@22716 187 case $conf_option in
ihse@22716 188 *=*)
ihse@22716 189 conf_option_name=`expr "x$conf_option" : 'x\([^=]*\)='`
ihse@22716 190 conf_option_name=$(shell_quote "$conf_option_name")
ihse@22716 191 conf_option_value=`expr "x$conf_option" : 'x[^=]*=\(.*\)'`
ihse@22716 192 conf_option_value=$(shell_quote "$conf_option_value")
ihse@22716 193 conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$conf_option_name=$conf_option_value")
ihse@22716 194 ;;
ihse@22716 195 *)
ihse@22716 196 conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")")
ihse@22716 197 ;;
ihse@22716 198 esac
ihse@22716 199
ihse@22716 200 # Check for certain autoconf options that require extra action
erikj@13132 201 case $conf_option in
ihse@20363 202 -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
ihse@20363 203 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
ihse@20363 204 -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
ihse@20363 205 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
ihse@20363 206 -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*)
ihse@20363 207 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
ihse@20363 208 -help | --help | --hel | --he | -h)
ihse@20363 209 conf_print_help=true ;;
ohair@12258 210 esac
ohair@12258 211 done
ohair@12258 212
ihse@22716 213 # Save the quoted command line
ihse@22716 214 CONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}"
ihse@22716 215
ohair@14111 216 if test "x$conf_legacy_crosscompile" != "x"; then
ohair@14111 217 if test "x$conf_openjdk_target" != "x"; then
erikj@13132 218 echo "Error: Specifying --openjdk-target together with autoconf"
erikj@13132 219 echo "legacy cross-compilation flags is not supported."
erikj@13132 220 echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile."
erikj@13132 221 echo "The recommended use is just --openjdk-target."
erikj@13132 222 exit 1
erikj@13132 223 else
erikj@13132 224 echo "Warning: You are using legacy autoconf cross-compilation flags."
erikj@13132 225 echo "It is recommended that you use --openjdk-target instead."
erikj@13132 226 echo ""
ohair@12258 227 fi
ohair@12258 228 fi
ohair@12258 229
ohair@14111 230 if test "x$conf_openjdk_target" != "x"; then
erikj@13132 231 conf_build_platform=`sh $conf_script_dir/build-aux/config.guess`
ohair@14111 232 conf_processed_arguments=("--build=$conf_build_platform" "--host=$conf_openjdk_target" "--target=$conf_openjdk_target" "${conf_processed_arguments[@]}")
ohair@12258 233 fi
ohair@12258 234
erikj@13132 235 # Make configure exit with error on invalid options as default.
erikj@13132 236 # Can be overridden by --disable-option-checking, since we prepend our argument
erikj@13132 237 # and later options override earlier.
ohair@14111 238 conf_processed_arguments=("--enable-option-checking=fatal" "${conf_processed_arguments[@]}")
ohair@12258 239
erikj@13132 240 ###
erikj@13132 241 ### Call the configure script
erikj@13132 242 ###
ihse@47405 243 if test "x$CUSTOM_CONFIG_DIR" != x; then
ohair@13697 244 # Custom source configure available; run that instead
ihse@22722 245 echo "Running custom generated-configure.sh"
ihse@47405 246 conf_script_to_run=$CUSTOM_CONFIG_DIR/generated-configure.sh
erikj@13132 247 else
ihse@22722 248 echo "Running generated-configure.sh"
ohair@13697 249 conf_script_to_run=$conf_script_dir/generated-configure.sh
ihse@20363 250 fi
ohair@13697 251
ohair@14111 252 if test "x$conf_debug_configure" != x; then
ohair@13697 253 # Turn on shell debug output if requested (initial or recursive)
ohair@13697 254 set -x
ohair@12258 255 fi
ohair@12258 256
ihse@30417 257 # Now transfer control to the script generated by autoconf. This is where the
ihse@30417 258 # main work is done.
erikj@34491 259 RCDIR=`mktemp -dt jdk-build-configure.tmp.XXXXXX` || exit $?
erikj@34491 260 trap "rm -rf \"$RCDIR\"" EXIT
ihse@30417 261 conf_logfile=./configure.log
erikj@34491 262 (exec 3>&1 ; ((. $conf_script_to_run "${conf_processed_arguments[@]}" 2>&1 1>&3 ) \
erikj@34491 263 ; echo $? > "$RCDIR/rc" ) \
erikj@34491 264 | tee -a $conf_logfile 1>&2 ; exec 3>&-) | tee -a $conf_logfile
ohair@13697 265
erikj@34491 266 conf_result_code=`cat "$RCDIR/rc"`
erikj@13132 267 ###
erikj@13132 268 ### Post-processing
erikj@13132 269 ###
ohair@12258 270
ohair@14111 271 if test $conf_result_code -eq 0; then
ohair@14111 272 if test "x$conf_print_help" = xtrue; then
ohair@14111 273 cat <<EOT
ohair@14111 274
ohair@14111 275 Additional (non-autoconf) OpenJDK Options:
ohair@14111 276 --openjdk-target=TARGET cross-compile with TARGET as target platform
ohair@14111 277 (i.e. the one you will run the resulting binary on).
ohair@14111 278 Equivalent to --host=TARGET --target=TARGET
ohair@14111 279 --build=<current platform>
ohair@14111 280 --debug-configure Run the configure script with additional debug
ohair@14111 281 logging enabled.
ohair@14111 282
ihse@22721 283 EOT
ihse@22721 284
erikj@37402 285 # Print additional help, e.g. a list of toolchains and JVM features.
ihse@35747 286 # This must be done by the autoconf script.
ihse@35747 287 ( CONFIGURE_PRINT_ADDITIONAL_HELP=true . $conf_script_to_run PRINTF=printf )
ihse@22721 288
ihse@22721 289 cat <<EOT
ihse@22721 290
ohair@14111 291 Please be aware that, when cross-compiling, the OpenJDK configure script will
ohair@14111 292 generally use 'target' where autoconf traditionally uses 'host'.
ihse@22475 293
ihse@22475 294 Also note that variables must be passed on the command line. Variables in the
ihse@22475 295 environment will generally be ignored, unlike traditional autoconf scripts.
ohair@14111 296 EOT
ohair@14111 297 fi
ohair@14111 298 else
ohair@14111 299 echo configure exiting with result code $conf_result_code
ohair@14111 300 fi
ohair@14111 301
ohair@13697 302 exit $conf_result_code