common/autoconf/configure

Thu, 31 Aug 2017 15:40:18 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:40:18 +0800
changeset 1133
50aaf272884f
parent 839
174a54ce39c4
parent 0
75a576e87639
child 1482
8fb429038513
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
aoqi@0 31 CONFIGURE_COMMAND_LINE="$@"
aoqi@0 32 conf_script_dir=`dirname $0`
aoqi@0 33
aoqi@0 34 if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
aoqi@0 35 conf_custom_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
aoqi@0 36 else
aoqi@0 37 conf_custom_script_dir=$CUSTOM_CONFIG_DIR
aoqi@0 38 fi
aoqi@0 39
aoqi@0 40 ###
aoqi@0 41 ### Test that the generated configure is up-to-date
aoqi@0 42 ###
aoqi@0 43
aoqi@0 44 run_autogen_or_fail() {
aoqi@0 45 if test "x`which autoconf 2> /dev/null`" = x; then
aoqi@0 46 echo "Cannot locate autoconf, unable to correct situation."
aoqi@0 47 echo "Please install autoconf and run 'bash autogen.sh' to update the generated files."
aoqi@0 48 echo "Error: Cannot continue" 1>&2
aoqi@0 49 exit 1
aoqi@0 50 else
aoqi@0 51 echo "Running autogen.sh to correct the situation"
aoqi@0 52 bash $conf_script_dir/autogen.sh
aoqi@0 53 fi
aoqi@0 54 }
aoqi@0 55
aoqi@0 56 check_autoconf_timestamps() {
aoqi@0 57 for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 ; do
aoqi@0 58 if test $file -nt $conf_script_dir/generated-configure.sh; then
aoqi@0 59 echo "Warning: The configure source files is newer than the generated files."
aoqi@0 60 run_autogen_or_fail
aoqi@0 61 fi
aoqi@0 62 done
aoqi@0 63
aoqi@0 64 if test -e $conf_custom_script_dir/generated-configure.sh; then
aoqi@0 65 # If custom source configure is available, make sure it is up-to-date as well.
aoqi@0 66 for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $conf_custom_script_dir/*.m4; do
aoqi@0 67 if test $file -nt $conf_custom_script_dir/generated-configure.sh; then
aoqi@0 68 echo "Warning: The configure source files is newer than the custom generated files."
aoqi@0 69 run_autogen_or_fail
aoqi@0 70 fi
aoqi@0 71 done
aoqi@0 72 fi
aoqi@0 73 }
aoqi@0 74
aoqi@0 75 check_hg_updates() {
aoqi@0 76 if test "x`which hg 2> /dev/null`" != x; then
aoqi@0 77 conf_updated_autoconf_files=`cd $conf_script_dir && hg status -mard 2> /dev/null | grep autoconf`
aoqi@0 78 if test "x$conf_updated_autoconf_files" != x; then
aoqi@0 79 echo "Configure source code has been updated, checking time stamps"
aoqi@0 80 check_autoconf_timestamps
aoqi@0 81 fi
aoqi@0 82
aoqi@0 83 if test -e $conf_custom_script_dir; then
aoqi@0 84 # If custom source configure is available, make sure it is up-to-date as well.
aoqi@0 85 conf_custom_updated_autoconf_files=`cd $conf_custom_script_dir && hg status -mard 2> /dev/null | grep autoconf`
aoqi@0 86 if test "x$conf_custom_updated_autoconf_files" != x; then
aoqi@0 87 echo "Configure custom source code has been updated, checking time stamps"
aoqi@0 88 check_autoconf_timestamps
aoqi@0 89 fi
aoqi@0 90 fi
aoqi@0 91 fi
aoqi@0 92 }
aoqi@0 93
aoqi@0 94 # Check for local changes
aoqi@0 95 check_hg_updates
aoqi@0 96
aoqi@0 97 if test -e $conf_custom_script_dir/generated-configure.sh; then
aoqi@0 98 # Test if open configure is newer than custom configure, if so, custom needs to
aoqi@0 99 # be regenerated. This test is required to ensure consistency with custom source.
aoqi@0 100 conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_script_dir/generated-configure.sh | cut -d"=" -f 2`
aoqi@0 101 conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_custom_script_dir/generated-configure.sh | cut -d"=" -f 2`
aoqi@0 102 if test $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
aoqi@0 103 echo "Warning: The generated configure file contains changes not present in the custom generated file."
aoqi@0 104 run_autogen_or_fail
aoqi@0 105 fi
aoqi@0 106 fi
aoqi@0 107
aoqi@0 108 # Autoconf calls the configure script recursively sometimes.
aoqi@0 109 # Don't start logging twice in that case
aoqi@0 110 if test "x$conf_debug_configure" = xtrue; then
aoqi@0 111 conf_debug_configure=recursive
aoqi@0 112 fi
aoqi@0 113 ###
aoqi@0 114 ### Process command-line arguments
aoqi@0 115 ###
aoqi@0 116 conf_processed_arguments=()
aoqi@0 117 conf_openjdk_target=
aoqi@0 118
aoqi@0 119 for conf_option
aoqi@0 120 do
aoqi@0 121 case $conf_option in
aoqi@0 122 --openjdk-target=*)
aoqi@0 123 conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
aoqi@0 124 continue ;;
aoqi@0 125 --debug-configure)
aoqi@0 126 if test "x$conf_debug_configure" != xrecursive; then
aoqi@0 127 conf_debug_configure=true
aoqi@0 128 export conf_debug_configure
aoqi@0 129 fi
aoqi@0 130 continue ;;
aoqi@0 131 *)
aoqi@0 132 conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option") ;;
aoqi@0 133 esac
aoqi@0 134
aoqi@0 135 case $conf_option in
aoqi@0 136 -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
aoqi@0 137 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
aoqi@0 138 -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
aoqi@0 139 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
aoqi@0 140 -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*)
aoqi@0 141 conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
aoqi@0 142 -help | --help | --hel | --he | -h)
aoqi@0 143 conf_print_help=true ;;
aoqi@0 144 esac
aoqi@0 145 done
aoqi@0 146
aoqi@0 147 if test "x$conf_legacy_crosscompile" != "x"; then
aoqi@0 148 if test "x$conf_openjdk_target" != "x"; then
aoqi@0 149 echo "Error: Specifying --openjdk-target together with autoconf"
aoqi@0 150 echo "legacy cross-compilation flags is not supported."
aoqi@0 151 echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile."
aoqi@0 152 echo "The recommended use is just --openjdk-target."
aoqi@0 153 exit 1
aoqi@0 154 else
aoqi@0 155 echo "Warning: You are using legacy autoconf cross-compilation flags."
aoqi@0 156 echo "It is recommended that you use --openjdk-target instead."
aoqi@0 157 echo ""
aoqi@0 158 fi
aoqi@0 159 fi
aoqi@0 160
aoqi@0 161 if test "x$conf_openjdk_target" != "x"; then
aoqi@0 162 conf_build_platform=`sh $conf_script_dir/build-aux/config.guess`
aoqi@0 163 conf_processed_arguments=("--build=$conf_build_platform" "--host=$conf_openjdk_target" "--target=$conf_openjdk_target" "${conf_processed_arguments[@]}")
aoqi@0 164 fi
aoqi@0 165
aoqi@0 166 # Make configure exit with error on invalid options as default.
aoqi@0 167 # Can be overridden by --disable-option-checking, since we prepend our argument
aoqi@0 168 # and later options override earlier.
aoqi@0 169 conf_processed_arguments=("--enable-option-checking=fatal" "${conf_processed_arguments[@]}")
aoqi@0 170
aoqi@0 171 ###
aoqi@0 172 ### Call the configure script
aoqi@0 173 ###
aoqi@0 174 if test -e $conf_custom_script_dir/generated-configure.sh; then
aoqi@0 175 # Custom source configure available; run that instead
aoqi@0 176 echo Running custom generated-configure.sh
aoqi@0 177 conf_script_to_run=$conf_custom_script_dir/generated-configure.sh
aoqi@0 178 else
aoqi@0 179 echo Running generated-configure.sh
aoqi@0 180 conf_script_to_run=$conf_script_dir/generated-configure.sh
aoqi@0 181 fi
aoqi@0 182
aoqi@0 183 if test "x$conf_debug_configure" != x; then
aoqi@0 184 # Turn on shell debug output if requested (initial or recursive)
aoqi@0 185 set -x
aoqi@0 186 fi
aoqi@0 187
aoqi@0 188 if test "x$conf_debug_configure" = xtrue; then
aoqi@0 189 # Turn on logging, but don't turn on twice when called recursive
aoqi@0 190 conf_debug_logfile=./debug-configure.log
aoqi@0 191 (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 192 else
aoqi@0 193 ( . $conf_script_to_run "${conf_processed_arguments[@]}" )
aoqi@0 194 fi
aoqi@0 195
aoqi@0 196 conf_result_code=$?
aoqi@0 197 ###
aoqi@0 198 ### Post-processing
aoqi@0 199 ###
aoqi@0 200
aoqi@0 201 if test $conf_result_code -eq 0; then
aoqi@0 202 if test "x$conf_print_help" = xtrue; then
aoqi@0 203 cat <<EOT
aoqi@0 204
aoqi@0 205 Additional (non-autoconf) OpenJDK Options:
aoqi@0 206 --openjdk-target=TARGET cross-compile with TARGET as target platform
aoqi@0 207 (i.e. the one you will run the resulting binary on).
aoqi@0 208 Equivalent to --host=TARGET --target=TARGET
aoqi@0 209 --build=<current platform>
aoqi@0 210 --debug-configure Run the configure script with additional debug
aoqi@0 211 logging enabled.
aoqi@0 212
aoqi@0 213 Please be aware that, when cross-compiling, the OpenJDK configure script will
aoqi@0 214 generally use 'target' where autoconf traditionally uses 'host'.
aoqi@0 215 EOT
aoqi@0 216 fi
aoqi@0 217 else
aoqi@0 218 echo configure exiting with result code $conf_result_code
aoqi@0 219 fi
aoqi@0 220
aoqi@0 221 exit $conf_result_code

mercurial