common/autoconf/configure

Mon, 16 Oct 2017 15:57:35 +0800

author
aoqi
date
Mon, 16 Oct 2017 15:57:35 +0800
changeset 1482
8fb429038513
parent 1323
d22ee7172ab2
parent 1133
50aaf272884f
child 2316
64a3eeabf6e5
permissions
-rw-r--r--

merge

aoqi@0 1 #!/bin/bash
aoqi@0 2 #
aoqi@0 3 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 5 #
aoqi@0 6 # This code is free software; you can redistribute it and/or modify it
aoqi@0 7 # under the terms of the GNU General Public License version 2 only, as
aoqi@0 8 # published by the Free Software Foundation.
aoqi@0 9 #
aoqi@0 10 # This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 13 # version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 14 # accompanied this code).
aoqi@0 15 #
aoqi@0 16 # You should have received a copy of the GNU General Public License version
aoqi@0 17 # 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 19 #
aoqi@0 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 21 # or visit www.oracle.com if you need additional information or have any
aoqi@0 22 # questions.
aoqi@0 23 #
aoqi@0 24
aoqi@0 25 if test "x$BASH_VERSION" = x; then
aoqi@0 26 echo This script needs bash to run.
aoqi@0 27 echo It is recommended to use the configure script in the source tree root instead.
aoqi@0 28 exit 1
aoqi@0 29 fi
aoqi@0 30
ihse@1323 31 # Force autoconf to use bash. This also means we must disable autoconf re-exec.
ihse@1322 32 export CONFIG_SHELL=$BASH
ihse@1323 33 export _as_can_reexec=no
ihse@1322 34
aoqi@0 35 CONFIGURE_COMMAND_LINE="$@"
aoqi@0 36 conf_script_dir=`dirname $0`
aoqi@0 37
aoqi@0 38 if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
aoqi@0 39 conf_custom_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
aoqi@0 40 else
aoqi@0 41 conf_custom_script_dir=$CUSTOM_CONFIG_DIR
aoqi@0 42 fi
aoqi@0 43
aoqi@0 44 ###
aoqi@0 45 ### Test that the generated configure is up-to-date
aoqi@0 46 ###
aoqi@0 47
aoqi@0 48 run_autogen_or_fail() {
aoqi@0 49 if test "x`which autoconf 2> /dev/null`" = x; then
aoqi@0 50 echo "Cannot locate autoconf, unable to correct situation."
aoqi@0 51 echo "Please install autoconf and run 'bash autogen.sh' to update the generated files."
aoqi@0 52 echo "Error: Cannot continue" 1>&2
aoqi@0 53 exit 1
aoqi@0 54 else
aoqi@0 55 echo "Running autogen.sh to correct the situation"
aoqi@0 56 bash $conf_script_dir/autogen.sh
aoqi@0 57 fi
aoqi@0 58 }
aoqi@0 59
aoqi@0 60 check_autoconf_timestamps() {
aoqi@0 61 for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 ; do
aoqi@0 62 if test $file -nt $conf_script_dir/generated-configure.sh; then
aoqi@0 63 echo "Warning: The configure source files is newer than the generated files."
aoqi@0 64 run_autogen_or_fail
aoqi@0 65 fi
aoqi@0 66 done
aoqi@0 67
aoqi@0 68 if test -e $conf_custom_script_dir/generated-configure.sh; then
aoqi@0 69 # If custom source configure is available, make sure it is up-to-date as well.
aoqi@0 70 for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $conf_custom_script_dir/*.m4; do
aoqi@0 71 if test $file -nt $conf_custom_script_dir/generated-configure.sh; then
aoqi@0 72 echo "Warning: The configure source files is newer than the custom generated files."
aoqi@0 73 run_autogen_or_fail
aoqi@0 74 fi
aoqi@0 75 done
aoqi@0 76 fi
aoqi@0 77 }
aoqi@0 78
aoqi@0 79 check_hg_updates() {
aoqi@0 80 if test "x`which hg 2> /dev/null`" != x; then
aoqi@0 81 conf_updated_autoconf_files=`cd $conf_script_dir && hg status -mard 2> /dev/null | grep autoconf`
aoqi@0 82 if test "x$conf_updated_autoconf_files" != x; then
aoqi@0 83 echo "Configure source code has been updated, checking time stamps"
aoqi@0 84 check_autoconf_timestamps
aoqi@0 85 fi
aoqi@0 86
aoqi@0 87 if test -e $conf_custom_script_dir; then
aoqi@0 88 # If custom source configure is available, make sure it is up-to-date as well.
aoqi@0 89 conf_custom_updated_autoconf_files=`cd $conf_custom_script_dir && hg status -mard 2> /dev/null | grep autoconf`
aoqi@0 90 if test "x$conf_custom_updated_autoconf_files" != x; then
aoqi@0 91 echo "Configure custom source code has been updated, checking time stamps"
aoqi@0 92 check_autoconf_timestamps
aoqi@0 93 fi
aoqi@0 94 fi
aoqi@0 95 fi
aoqi@0 96 }
aoqi@0 97
aoqi@0 98 # Check for local changes
aoqi@0 99 check_hg_updates
aoqi@0 100
aoqi@0 101 if test -e $conf_custom_script_dir/generated-configure.sh; then
aoqi@0 102 # Test if open configure is newer than custom configure, if so, custom needs to
aoqi@0 103 # be regenerated. This test is required to ensure consistency with custom source.
aoqi@0 104 conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_script_dir/generated-configure.sh | cut -d"=" -f 2`
aoqi@0 105 conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_custom_script_dir/generated-configure.sh | cut -d"=" -f 2`
aoqi@0 106 if test $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
aoqi@0 107 echo "Warning: The generated configure file contains changes not present in the custom generated file."
aoqi@0 108 run_autogen_or_fail
aoqi@0 109 fi
aoqi@0 110 fi
aoqi@0 111
aoqi@0 112 # Autoconf calls the configure script recursively sometimes.
aoqi@0 113 # Don't start logging twice in that case
aoqi@0 114 if test "x$conf_debug_configure" = xtrue; then
aoqi@0 115 conf_debug_configure=recursive
aoqi@0 116 fi
aoqi@0 117 ###
aoqi@0 118 ### Process command-line arguments
aoqi@0 119 ###
aoqi@0 120 conf_processed_arguments=()
aoqi@0 121 conf_openjdk_target=
aoqi@0 122
aoqi@0 123 for conf_option
aoqi@0 124 do
aoqi@0 125 case $conf_option in
aoqi@0 126 --openjdk-target=*)
aoqi@0 127 conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
aoqi@0 128 continue ;;
aoqi@0 129 --debug-configure)
aoqi@0 130 if test "x$conf_debug_configure" != xrecursive; then
aoqi@0 131 conf_debug_configure=true
aoqi@0 132 export conf_debug_configure
aoqi@0 133 fi
aoqi@0 134 continue ;;
aoqi@0 135 *)
aoqi@0 136 conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option") ;;
aoqi@0 137 esac
aoqi@0 138
aoqi@0 139 case $conf_option in
aoqi@0 140 -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
aoqi@0 141 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
aoqi@0 142 -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
aoqi@0 143 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
aoqi@0 144 -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*)
aoqi@0 145 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
aoqi@0 146 -help | --help | --hel | --he | -h)
aoqi@0 147 conf_print_help=true ;;
aoqi@0 148 esac
aoqi@0 149 done
aoqi@0 150
aoqi@0 151 if test "x$conf_legacy_crosscompile" != "x"; then
aoqi@0 152 if test "x$conf_openjdk_target" != "x"; then
aoqi@0 153 echo "Error: Specifying --openjdk-target together with autoconf"
aoqi@0 154 echo "legacy cross-compilation flags is not supported."
aoqi@0 155 echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile."
aoqi@0 156 echo "The recommended use is just --openjdk-target."
aoqi@0 157 exit 1
aoqi@0 158 else
aoqi@0 159 echo "Warning: You are using legacy autoconf cross-compilation flags."
aoqi@0 160 echo "It is recommended that you use --openjdk-target instead."
aoqi@0 161 echo ""
aoqi@0 162 fi
aoqi@0 163 fi
aoqi@0 164
aoqi@0 165 if test "x$conf_openjdk_target" != "x"; then
aoqi@0 166 conf_build_platform=`sh $conf_script_dir/build-aux/config.guess`
aoqi@0 167 conf_processed_arguments=("--build=$conf_build_platform" "--host=$conf_openjdk_target" "--target=$conf_openjdk_target" "${conf_processed_arguments[@]}")
aoqi@0 168 fi
aoqi@0 169
aoqi@0 170 # Make configure exit with error on invalid options as default.
aoqi@0 171 # Can be overridden by --disable-option-checking, since we prepend our argument
aoqi@0 172 # and later options override earlier.
aoqi@0 173 conf_processed_arguments=("--enable-option-checking=fatal" "${conf_processed_arguments[@]}")
aoqi@0 174
aoqi@0 175 ###
aoqi@0 176 ### Call the configure script
aoqi@0 177 ###
aoqi@0 178 if test -e $conf_custom_script_dir/generated-configure.sh; then
aoqi@0 179 # Custom source configure available; run that instead
aoqi@0 180 echo Running custom generated-configure.sh
aoqi@0 181 conf_script_to_run=$conf_custom_script_dir/generated-configure.sh
aoqi@0 182 else
aoqi@0 183 echo Running generated-configure.sh
aoqi@0 184 conf_script_to_run=$conf_script_dir/generated-configure.sh
aoqi@0 185 fi
aoqi@0 186
aoqi@0 187 if test "x$conf_debug_configure" != x; then
aoqi@0 188 # Turn on shell debug output if requested (initial or recursive)
aoqi@0 189 set -x
aoqi@0 190 fi
aoqi@0 191
aoqi@0 192 if test "x$conf_debug_configure" = xtrue; then
aoqi@0 193 # Turn on logging, but don't turn on twice when called recursive
aoqi@0 194 conf_debug_logfile=./debug-configure.log
aoqi@0 195 (exec 3>&1 ; (. $conf_script_to_run "${conf_processed_arguments[@]}" 2>&1 1>&3 ) | tee -a $conf_debug_logfile 1>&2 ; exec 3>&-) | tee -a $conf_debug_logfile
aoqi@0 196 else
aoqi@0 197 ( . $conf_script_to_run "${conf_processed_arguments[@]}" )
aoqi@0 198 fi
aoqi@0 199
aoqi@0 200 conf_result_code=$?
aoqi@0 201 ###
aoqi@0 202 ### Post-processing
aoqi@0 203 ###
aoqi@0 204
aoqi@0 205 if test $conf_result_code -eq 0; then
aoqi@0 206 if test "x$conf_print_help" = xtrue; then
aoqi@0 207 cat <<EOT
aoqi@0 208
aoqi@0 209 Additional (non-autoconf) OpenJDK Options:
aoqi@0 210 --openjdk-target=TARGET cross-compile with TARGET as target platform
aoqi@0 211 (i.e. the one you will run the resulting binary on).
aoqi@0 212 Equivalent to --host=TARGET --target=TARGET
aoqi@0 213 --build=<current platform>
aoqi@0 214 --debug-configure Run the configure script with additional debug
aoqi@0 215 logging enabled.
aoqi@0 216
aoqi@0 217 Please be aware that, when cross-compiling, the OpenJDK configure script will
aoqi@0 218 generally use 'target' where autoconf traditionally uses 'host'.
aoqi@0 219 EOT
aoqi@0 220 fi
aoqi@0 221 else
aoqi@0 222 echo configure exiting with result code $conf_result_code
aoqi@0 223 fi
aoqi@0 224
aoqi@0 225 exit $conf_result_code

mercurial