annotate make/autoconf/configure @ 57834:00d9f8de0e3d

Automatic merge with records-and-sealed
author mcimadamore
date Thu, 19 Sep 2019 15:47:00 +0000
parents c25f6c562bf5
children 9d9317fad3fe
rev   line source
ohair@14111 1 #!/bin/bash
ohair@14111 2 #
mbaesken@55236 3 # Copyright (c) 2012, 2019, 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@47456 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@47456 28 exit 1
ohair@14111 29 fi
ohair@12258 30
ihse@47456 31 # The next argument is the absolute top-level directory path.
ihse@47456 32 # The TOPDIR variable is passed on to configure.ac.
ihse@47456 33 TOPDIR="$2"
ihse@47456 34 # Remove these two arguments to get to the user supplied arguments
ihse@47456 35 shift
ihse@47456 36 shift
ihse@47456 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
ihse@47395 46 if test "x$CUSTOM_CONFIG_DIR" != x; then
ihse@49104 47 custom_hook=$CUSTOM_CONFIG_DIR/custom-hook.m4
ihse@49104 48 if test ! -e $custom_hook; then
ihse@47395 49 echo "CUSTOM_CONFIG_DIR not pointing to a proper custom config dir."
ihse@47395 50 echo "Error: Cannot continue" 1>&2
ihse@47395 51 exit 1
ihse@47395 52 fi
ihse@49230 53 fi
ihse@49230 54
ihse@49230 55 CURRENT_DIR=`pwd`
ihse@49230 56 if test "x$CURRENT_DIR" = "x$TOPDIR"; then
ihse@49230 57 # We are running configure from the src root.
ihse@49230 58 # Create '.configure-support' under $TOPDIR/build
ihse@49230 59 build_support_dir="$TOPDIR/build/.configure-support"
ihse@49230 60 elif test "x$CURRENT_DIR" = "x$CUSTOM_ROOT"; then
ihse@49230 61 # We are running configure from the custom root.
ihse@49230 62 # Create '.configure-support' under $CUSTOM_ROOT/build
ihse@49230 63 build_support_dir="$CUSTOM_ROOT/build/.configure-support"
ihse@49104 64 else
ihse@49230 65 # We are running configure from outside of the src dir.
ihse@49230 66 # Create 'build_support_dir' in the current directory.
ihse@49230 67 build_support_dir="$CURRENT_DIR/configure-support"
ohair@13697 68 fi
erikj@13132 69
ihse@49104 70 conf_script_dir="$TOPDIR/make/autoconf"
ihse@49104 71 generated_script="$build_support_dir/generated-configure.sh"
ihse@49104 72
erikj@13132 73 ###
ihse@49104 74 ### Use autoconf to create a runnable configure script, if needed
erikj@13132 75 ###
erikj@13132 76
ihse@49104 77 autoconf_missing_help() {
ihse@49104 78 APT_GET="`which apt-get 2> /dev/null | grep -v '^no apt-get in'`"
ihse@49104 79 YUM="`which yum 2> /dev/null | grep -v '^no yum in'`"
ihse@49104 80 BREW="`which brew 2> /dev/null | grep -v '^no brew in'`"
mbaesken@55236 81 ZYPPER="`which zypper 2> /dev/null | grep -v '^no zypper in'`"
ihse@49104 82 CYGWIN="`which cygpath 2> /dev/null | grep -v '^no cygpath in'`"
ihse@49104 83
mbaesken@55236 84 if test "x$ZYPPER" != x; then
mbaesken@55236 85 PKGHANDLER_COMMAND="sudo zypper install autoconf"
mbaesken@55236 86 elif test "x$APT_GET" != x; then
ihse@49104 87 PKGHANDLER_COMMAND="sudo apt-get install autoconf"
ihse@49104 88 elif test "x$YUM" != x; then
ihse@49104 89 PKGHANDLER_COMMAND="sudo yum install autoconf"
ihse@49104 90 elif test "x$BREW" != x; then
ihse@49104 91 PKGHANDLER_COMMAND="brew install autoconf"
ihse@49104 92 elif test "x$CYGWIN" != x; then
ihse@49104 93 PKGHANDLER_COMMAND="( cd <location of cygwin setup.exe> && cmd /c setup -q -P autoconf )"
ihse@49104 94 fi
ihse@49104 95
ihse@49104 96 if test "x$PKGHANDLER_COMMAND" != x; then
ihse@49104 97 echo "You might be able to fix this by running '$PKGHANDLER_COMMAND'."
ohair@14111 98 fi
erikj@13132 99 }
erikj@13132 100
ihse@49104 101 generate_configure_script() {
ihse@49104 102 if test "x$AUTOCONF" != x; then
ihse@49104 103 if test ! -x "$AUTOCONF"; then
ihse@49104 104 echo
ihse@49104 105 echo "The specified AUTOCONF variable does not point to a valid autoconf executable:"
ihse@49104 106 echo "AUTOCONF=$AUTOCONF"
ihse@49104 107 echo "Error: Cannot continue" 1>&2
ihse@49104 108 exit 1
erikj@13132 109 fi
ihse@49104 110 else
ihse@49104 111 AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`"
ihse@49104 112 if test "x$AUTOCONF" = x; then
ihse@49104 113 echo
ihse@49104 114 echo "Autoconf is not found on the PATH, and AUTOCONF is not set."
ihse@49104 115 echo "You need autoconf to be able to generate a runnable configure script."
ihse@49104 116 autoconf_missing_help
ihse@49104 117 echo "Error: Cannot find autoconf" 1>&2
ihse@49104 118 exit 1
ihse@49104 119 fi
ihse@49104 120 fi
ihse@49104 121
ihse@49104 122 autoconf_version=`$AUTOCONF --version | head -1`
ihse@49104 123 echo "Using autoconf at ${AUTOCONF} [$autoconf_version]"
erikj@13132 124
ihse@47395 125 if test "x$CUSTOM_CONFIG_DIR" != x; then
ihse@49104 126 # Generate configure script with custom hooks compiled in.
ihse@49104 127 custom_patcher='sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
ihse@52328 128 custom_script_dir_include="-I$CUSTOM_CONFIG_DIR"
ihse@49104 129 else
ihse@49104 130 custom_patcher='cat'
ihse@52328 131 custom_script_dir_include=""
ihse@49104 132 fi
ihse@49104 133
ihse@49230 134 mkdir -p $build_support_dir
ihse@49104 135 # Call autoconf but replace the "magic" variable in configure.ac if requested.
ihse@52328 136
ihse@49104 137 cat $conf_script_dir/configure.ac | eval $custom_patcher | \
ihse@52328 138 ${AUTOCONF} -W all $custom_script_dir_include -I$conf_script_dir - \
ihse@52328 139 > $generated_script
ihse@49104 140 rm -rf autom4te.cache
ihse@49104 141
ihse@49104 142 # Sanity check
ihse@49104 143 if test ! -s $generated_script; then
ihse@49104 144 echo "Error: Failed to generate runnable configure script" 1>&2
ihse@49104 145 rm -f $generated_script
ihse@49104 146 exit 1
ohair@14111 147 fi
ohair@14111 148 }
ohair@14111 149
ihse@49104 150 test_generated_up_to_date() {
erikj@49125 151 conf_source_files="$conf_script_dir/configure.ac $conf_script_dir/*.m4"
erikj@49125 152 if test "x$CUSTOM_CONFIG_DIR" != x; then
erikj@49125 153 conf_custom_source_files="$CUSTOM_CONFIG_DIR/*.m4"
erikj@49125 154 else
erikj@49125 155 conf_custom_source_files=""
erikj@49125 156 fi
erikj@49125 157
erikj@49125 158 for file in $conf_source_files $conf_custom_source_files ; do
erikj@49125 159 if test $file -nt $generated_script; then
erikj@49125 160 return 0
ihse@49104 161 fi
erikj@49125 162 done
ihse@49104 163 return 1
ohair@14111 164 }
ohair@14111 165
ihse@49104 166 run_autoconf=false
ihse@49104 167 if test "x$1" = xautogen; then
ihse@49104 168 # User called us as "configure autogen", so force regeneration
ihse@49104 169 run_autoconf=true
ihse@49104 170 shift
ihse@49104 171 fi
ohair@14111 172
ihse@49104 173 if test ! -s $generated_script; then
ihse@49104 174 # Generated script is missing, so we need to create it
ihse@49104 175 echo "Runnable configure script is not present"
ihse@49104 176 run_autoconf=true
ihse@49104 177 else
ihse@49104 178 # File is present, but is it up to date?
ihse@49104 179 if test_generated_up_to_date; then
ihse@49104 180 echo "Runnable configure script is not up to date"
ihse@49104 181 run_autoconf=true
erikj@13132 182 fi
ohair@12258 183 fi
ohair@12258 184
ihse@49104 185 if test "x$run_autoconf" = xtrue; then
ihse@49230 186 echo "Generating runnable configure script at $generated_script"
ihse@49104 187 generate_configure_script
ihse@49104 188 fi
ihse@49104 189
ihse@20363 190 # Autoconf calls the configure script recursively sometimes.
ohair@13697 191 # Don't start logging twice in that case
ohair@14111 192 if test "x$conf_debug_configure" = xtrue; then
ohair@13697 193 conf_debug_configure=recursive
ohair@13697 194 fi
ihse@22716 195
erikj@13132 196 ###
erikj@13132 197 ### Process command-line arguments
erikj@13132 198 ###
ihse@22716 199
ihse@22716 200 # Returns a shell-escaped version of the argument given.
ihse@22716 201 function shell_quote() {
ihse@22716 202 if [[ -n "$1" ]]; then
ihse@22716 203 # Uses only shell-safe characters? No quoting needed.
ihse@22716 204 # '=' is a zsh meta-character, but only in word-initial position.
erikj@22729 205 if echo "$1" | grep '^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\.:,%/+=_-]\{1,\}$' > /dev/null \
erikj@22729 206 && ! echo "$1" | grep '^=' > /dev/null; then
ihse@22716 207 quoted="$1"
ihse@22716 208 else
erikj@22729 209 if echo "$1" | grep "[\'!]" > /dev/null; then
ihse@22716 210 # csh does history expansion within single quotes, but not
ihse@22716 211 # when backslash-escaped!
ihse@22716 212 local quoted_quote="'\\''" quoted_exclam="'\\!'"
ihse@22716 213 word="${1//\'/${quoted_quote}}"
ihse@22716 214 word="${1//\!/${quoted_exclam}}"
ihse@22716 215 fi
ihse@22716 216 quoted="'$1'"
ihse@22716 217 fi
ihse@22716 218 echo "$quoted"
ihse@22716 219 fi
ihse@22716 220 }
ihse@22716 221
ohair@14111 222 conf_processed_arguments=()
ihse@22716 223 conf_quoted_arguments=()
erikj@13132 224 conf_openjdk_target=
ohair@12258 225
erikj@13132 226 for conf_option
ohair@12258 227 do
ihse@22716 228
ihse@22716 229 # Process (and remove) our own extensions that will not be passed to autoconf
erikj@13132 230 case $conf_option in
ihse@20363 231 --openjdk-target=*)
ihse@20363 232 conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
ihse@22475 233 ;;
ihse@20363 234 --debug-configure)
ihse@20363 235 if test "x$conf_debug_configure" != xrecursive; then
ihse@20363 236 conf_debug_configure=true
ihse@20363 237 export conf_debug_configure
ihse@20363 238 fi
ihse@22475 239 ;;
ihse@20363 240 *)
ihse@22475 241 conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option")
ihse@22475 242 ;;
ohair@12258 243 esac
ohair@12258 244
ihse@22716 245 # Store all variables overridden on the command line
ihse@22716 246 case $conf_option in
ihse@22716 247 [^-]*=*)
ihse@22716 248 # Add name of variable to CONFIGURE_OVERRIDDEN_VARIABLES list inside !...!.
ihse@22716 249 conf_env_var=`expr "x$conf_option" : 'x\([^=]*\)='`
ihse@22716 250 CONFIGURE_OVERRIDDEN_VARIABLES="$CONFIGURE_OVERRIDDEN_VARIABLES!$conf_env_var!"
ihse@22716 251 ;;
ihse@22716 252 esac
ihse@22716 253
ihse@22716 254 # Save the arguments, intelligently quoted for CONFIGURE_COMMAND_LINE.
ihse@22716 255 case $conf_option in
ihse@22716 256 *=*)
ihse@22716 257 conf_option_name=`expr "x$conf_option" : 'x\([^=]*\)='`
ihse@22716 258 conf_option_name=$(shell_quote "$conf_option_name")
ihse@22716 259 conf_option_value=`expr "x$conf_option" : 'x[^=]*=\(.*\)'`
ihse@22716 260 conf_option_value=$(shell_quote "$conf_option_value")
ihse@22716 261 conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$conf_option_name=$conf_option_value")
ihse@22716 262 ;;
ihse@22716 263 *)
ihse@22716 264 conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")")
ihse@22716 265 ;;
ihse@22716 266 esac
ihse@22716 267
ihse@22716 268 # Check for certain autoconf options that require extra action
erikj@13132 269 case $conf_option in
ihse@20363 270 -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
ihse@20363 271 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
ihse@20363 272 -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
ihse@20363 273 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
ihse@20363 274 -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*)
ihse@20363 275 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
ihse@20363 276 -help | --help | --hel | --he | -h)
ihse@20363 277 conf_print_help=true ;;
ohair@12258 278 esac
ohair@12258 279 done
ohair@12258 280
ihse@22716 281 # Save the quoted command line
ihse@22716 282 CONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}"
ihse@22716 283
ohair@14111 284 if test "x$conf_legacy_crosscompile" != "x"; then
ohair@14111 285 if test "x$conf_openjdk_target" != "x"; then
erikj@13132 286 echo "Error: Specifying --openjdk-target together with autoconf"
erikj@13132 287 echo "legacy cross-compilation flags is not supported."
erikj@13132 288 echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile."
erikj@13132 289 echo "The recommended use is just --openjdk-target."
erikj@13132 290 exit 1
erikj@13132 291 else
erikj@13132 292 echo "Warning: You are using legacy autoconf cross-compilation flags."
erikj@13132 293 echo "It is recommended that you use --openjdk-target instead."
erikj@13132 294 echo ""
ohair@12258 295 fi
ohair@12258 296 fi
ohair@12258 297
ohair@14111 298 if test "x$conf_openjdk_target" != "x"; then
erikj@13132 299 conf_build_platform=`sh $conf_script_dir/build-aux/config.guess`
ohair@14111 300 conf_processed_arguments=("--build=$conf_build_platform" "--host=$conf_openjdk_target" "--target=$conf_openjdk_target" "${conf_processed_arguments[@]}")
ohair@12258 301 fi
ohair@12258 302
erikj@13132 303 # Make configure exit with error on invalid options as default.
erikj@13132 304 # Can be overridden by --disable-option-checking, since we prepend our argument
erikj@13132 305 # and later options override earlier.
ohair@14111 306 conf_processed_arguments=("--enable-option-checking=fatal" "${conf_processed_arguments[@]}")
ohair@12258 307
erikj@13132 308 ###
erikj@13132 309 ### Call the configure script
erikj@13132 310 ###
ohair@14111 311 if test "x$conf_debug_configure" != x; then
ohair@13697 312 # Turn on shell debug output if requested (initial or recursive)
ohair@13697 313 set -x
ohair@12258 314 fi
ohair@12258 315
ihse@30417 316 # Now transfer control to the script generated by autoconf. This is where the
ihse@30417 317 # main work is done.
erikj@34491 318 RCDIR=`mktemp -dt jdk-build-configure.tmp.XXXXXX` || exit $?
erikj@34491 319 trap "rm -rf \"$RCDIR\"" EXIT
ihse@30417 320 conf_logfile=./configure.log
ihse@49104 321 (exec 3>&1 ; ((. $generated_script "${conf_processed_arguments[@]}" 2>&1 1>&3 ) \
erikj@34491 322 ; echo $? > "$RCDIR/rc" ) \
erikj@34491 323 | tee -a $conf_logfile 1>&2 ; exec 3>&-) | tee -a $conf_logfile
ohair@13697 324
erikj@34491 325 conf_result_code=`cat "$RCDIR/rc"`
erikj@13132 326 ###
erikj@13132 327 ### Post-processing
erikj@13132 328 ###
ohair@12258 329
ohair@14111 330 if test $conf_result_code -eq 0; then
ohair@14111 331 if test "x$conf_print_help" = xtrue; then
ohair@14111 332 cat <<EOT
ohair@14111 333
ohair@14111 334 Additional (non-autoconf) OpenJDK Options:
ohair@14111 335 --openjdk-target=TARGET cross-compile with TARGET as target platform
ohair@14111 336 (i.e. the one you will run the resulting binary on).
ohair@14111 337 Equivalent to --host=TARGET --target=TARGET
ohair@14111 338 --build=<current platform>
ohair@14111 339 --debug-configure Run the configure script with additional debug
ohair@14111 340 logging enabled.
ohair@14111 341
ihse@22721 342 EOT
ihse@22721 343
erikj@37402 344 # Print additional help, e.g. a list of toolchains and JVM features.
ihse@35747 345 # This must be done by the autoconf script.
ihse@49104 346 ( CONFIGURE_PRINT_ADDITIONAL_HELP=true . $generated_script PRINTF=printf )
ihse@22721 347
ihse@22721 348 cat <<EOT
ihse@22721 349
ohair@14111 350 Please be aware that, when cross-compiling, the OpenJDK configure script will
ohair@14111 351 generally use 'target' where autoconf traditionally uses 'host'.
ihse@22475 352
ihse@22475 353 Also note that variables must be passed on the command line. Variables in the
ihse@22475 354 environment will generally be ignored, unlike traditional autoconf scripts.
ohair@14111 355 EOT
ohair@14111 356 fi
ohair@14111 357 else
ohair@14111 358 echo configure exiting with result code $conf_result_code
ohair@14111 359 fi
ohair@14111 360
ohair@13697 361 exit $conf_result_code