configure revision 975:b18872ff5379
1132718Skan#!/bin/bash 2132718Skan# 3132718Skan# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 4132718Skan# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5132718Skan# 6132718Skan# This code is free software; you can redistribute it and/or modify it 7132718Skan# under the terms of the GNU General Public License version 2 only, as 8132718Skan# published by the Free Software Foundation. 9132718Skan# 10132718Skan# This code is distributed in the hope that it will be useful, but WITHOUT 11132718Skan# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12132718Skan# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13132718Skan# version 2 for more details (a copy is included in the LICENSE file that 14132718Skan# accompanied this code). 15132718Skan# 16132718Skan# You should have received a copy of the GNU General Public License version 17132718Skan# 2 along with this work; if not, write to the Free Software Foundation, 18169689Skan# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19132718Skan# 20132718Skan# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21132718Skan# or visit www.oracle.com if you need additional information or have any 22132718Skan# questions. 23132718Skan# 24132718Skan 25169689Skanif test "x$BASH_VERSION" = x; then 26132718Skan echo This script needs bash to run. 27132718Skan echo It is recommended to use the configure script in the source tree root instead. 28132718Skan exit 1 29132718Skanfi 30132718Skan 31132718Skanconf_script_dir=`dirname $0` 32132718Skan 33132718Skanif [ "$CUSTOM_CONFIG_DIR" = "" ]; then 34132718Skan conf_custom_script_dir="$conf_script_dir/../../closed/autoconf" 35132718Skanelse 36132718Skan conf_custom_script_dir=$CUSTOM_CONFIG_DIR 37169689Skanfi 38132718Skan 39169689Skan### 40132718Skan### Test that the generated configure is up-to-date 41132718Skan### 42132718Skan 43132718Skanrun_autogen_or_fail() { 44259405Spfg if test "x`which autoconf 2> /dev/null`" = x; then 45259405Spfg echo "Cannot locate autoconf, unable to correct situation." 46132718Skan echo "Please install autoconf and run 'bash autogen.sh' to update the generated files." 47132718Skan echo "Error: Cannot continue" 1>&2 48132718Skan exit 1 49132718Skan else 50169689Skan echo "Running autogen.sh to correct the situation" 51169689Skan bash $conf_script_dir/autogen.sh 52132718Skan fi 53132718Skan} 54132718Skan 55132718Skancheck_autoconf_timestamps() { 56169689Skan for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 ; do 57169689Skan if test $file -nt $conf_script_dir/generated-configure.sh; then 58169689Skan echo "Warning: The configure source files is newer than the generated files." 59169689Skan run_autogen_or_fail 60169689Skan fi 61169689Skan done 62169689Skan 63169689Skan if test -e $conf_custom_script_dir/generated-configure.sh; then 64132718Skan # If custom source configure is available, make sure it is up-to-date as well. 65132718Skan for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $conf_custom_script_dir/*.m4; do 66132718Skan if test $file -nt $conf_custom_script_dir/generated-configure.sh; then 67132718Skan echo "Warning: The configure source files is newer than the custom generated files." 68132718Skan run_autogen_or_fail 69132718Skan fi 70132718Skan done 71132718Skan fi 72132718Skan} 73132718Skan 74132718Skancheck_hg_updates() { 75132718Skan if test "x`which hg 2> /dev/null`" != x; then 76132718Skan conf_updated_autoconf_files=`cd $conf_script_dir && hg status -mard 2> /dev/null | grep autoconf` 77132718Skan if test "x$conf_updated_autoconf_files" != x; then 78132718Skan echo "Configure source code has been updated, checking time stamps" 79132718Skan check_autoconf_timestamps 80259405Spfg fi 81259405Spfg 82259405Spfg if test -e $conf_custom_script_dir; then 83132718Skan # If custom source configure is available, make sure it is up-to-date as well. 84132718Skan conf_custom_updated_autoconf_files=`cd $conf_custom_script_dir && hg status -mard 2> /dev/null | grep autoconf` 85132718Skan if test "x$conf_custom_updated_autoconf_files" != x; then 86132718Skan echo "Configure custom source code has been updated, checking time stamps" 87132718Skan check_autoconf_timestamps 88132718Skan fi 89132718Skan fi 90132718Skan fi 91132718Skan} 92132718Skan 93132718Skan# Check for local changes 94132718Skancheck_hg_updates 95132718Skan 96132718Skanif test -e $conf_custom_script_dir/generated-configure.sh; then 97132718Skan # Test if open configure is newer than custom configure, if so, custom needs to 98132718Skan # be regenerated. This test is required to ensure consistency with custom source. 99132718Skan conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_script_dir/generated-configure.sh | cut -d"=" -f 2` 100132718Skan conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_custom_script_dir/generated-configure.sh | cut -d"=" -f 2` 101132718Skan if test $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then 102132718Skan echo "Warning: The generated configure file contains changes not present in the custom generated file." 103132718Skan run_autogen_or_fail 104132718Skan fi 105132718Skanfi 106132718Skan 107132718Skan# Autoconf calls the configure script recursively sometimes. 108132718Skan# Don't start logging twice in that case 109132718Skanif test "x$conf_debug_configure" = xtrue; then 110132718Skan conf_debug_configure=recursive 111132718Skanfi 112132718Skan 113132718Skan### 114132718Skan### Process command-line arguments 115132718Skan### 116169689Skan 117169689Skan# Returns a shell-escaped version of the argument given. 118169689Skanfunction shell_quote() { 119169689Skan if [[ -n "$1" ]]; then 120169689Skan # Uses only shell-safe characters? No quoting needed. 121169689Skan # '=' is a zsh meta-character, but only in word-initial position. 122132718Skan if [[ "$1" =~ ^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.:,%/+=_-]+$ && ! "$1" =~ ^= ]]; then 123132718Skan quoted="$1" 124132718Skan else 125132718Skan if [[ "$1" =~ [\'!] ]]; then 126132718Skan # csh does history expansion within single quotes, but not 127132718Skan # when backslash-escaped! 128169689Skan local quoted_quote="'\\''" quoted_exclam="'\\!'" 129132718Skan word="${1//\'/${quoted_quote}}" 130132718Skan word="${1//\!/${quoted_exclam}}" 131169689Skan fi 132132718Skan quoted="'$1'" 133132718Skan fi 134132718Skan echo "$quoted" 135169689Skan fi 136132718Skan} 137132718Skan 138132718Skanconf_processed_arguments=() 139132718Skanconf_quoted_arguments=() 140132718Skanconf_openjdk_target= 141132718Skan 142132718Skanfor conf_option 143132718Skando 144132718Skan 145132718Skan # Process (and remove) our own extensions that will not be passed to autoconf 146132718Skan case $conf_option in 147132718Skan --openjdk-target=*) 148132718Skan conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'` 149132718Skan ;; 150132718Skan --debug-configure) 151132718Skan if test "x$conf_debug_configure" != xrecursive; then 152132718Skan conf_debug_configure=true 153132718Skan export conf_debug_configure 154132718Skan fi 155132718Skan ;; 156132718Skan *) 157132718Skan conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option") 158132718Skan ;; 159132718Skan esac 160132718Skan 161132718Skan # Store all variables overridden on the command line 162132718Skan case $conf_option in 163132718Skan [^-]*=*) 164132718Skan # Add name of variable to CONFIGURE_OVERRIDDEN_VARIABLES list inside !...!. 165132718Skan conf_env_var=`expr "x$conf_option" : 'x\([^=]*\)='` 166132718Skan CONFIGURE_OVERRIDDEN_VARIABLES="$CONFIGURE_OVERRIDDEN_VARIABLES!$conf_env_var!" 167132718Skan ;; 168132718Skan esac 169132718Skan 170132718Skan # Save the arguments, intelligently quoted for CONFIGURE_COMMAND_LINE. 171132718Skan case $conf_option in 172132718Skan *=*) 173132718Skan conf_option_name=`expr "x$conf_option" : 'x\([^=]*\)='` 174132718Skan conf_option_name=$(shell_quote "$conf_option_name") 175132718Skan conf_option_value=`expr "x$conf_option" : 'x[^=]*=\(.*\)'` 176132718Skan conf_option_value=$(shell_quote "$conf_option_value") 177132718Skan conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$conf_option_name=$conf_option_value") 178132718Skan ;; 179132718Skan *) 180132718Skan conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")") 181132718Skan ;; 182132718Skan esac 183132718Skan 184132718Skan # Check for certain autoconf options that require extra action 185132718Skan case $conf_option in 186132718Skan -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*) 187259405Spfg conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;; 188259405Spfg -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) 189259405Spfg conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;; 190259405Spfg -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*) 191259405Spfg conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;; 192259405Spfg -help | --help | --hel | --he | -h) 193259405Spfg conf_print_help=true ;; 194259405Spfg esac 195259405Spfgdone 196259405Spfg 197259405Spfg# Save the quoted command line 198259405SpfgCONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}" 199259405Spfg 200259405Spfgif test "x$conf_legacy_crosscompile" != "x"; then 201259405Spfg if test "x$conf_openjdk_target" != "x"; then 202259405Spfg echo "Error: Specifying --openjdk-target together with autoconf" 203259405Spfg echo "legacy cross-compilation flags is not supported." 204259405Spfg echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile." 205259405Spfg echo "The recommended use is just --openjdk-target." 206259405Spfg exit 1 207169689Skan else 208132718Skan echo "Warning: You are using legacy autoconf cross-compilation flags." 209132718Skan echo "It is recommended that you use --openjdk-target instead." 210132718Skan echo "" 211132718Skan fi 212132718Skanfi 213169689Skan 214132718Skanif test "x$conf_openjdk_target" != "x"; then 215132718Skan conf_build_platform=`sh $conf_script_dir/build-aux/config.guess` 216132718Skan conf_processed_arguments=("--build=$conf_build_platform" "--host=$conf_openjdk_target" "--target=$conf_openjdk_target" "${conf_processed_arguments[@]}") 217132718Skanfi 218132718Skan 219132718Skan# Make configure exit with error on invalid options as default. 220132718Skan# Can be overridden by --disable-option-checking, since we prepend our argument 221132718Skan# and later options override earlier. 222132718Skanconf_processed_arguments=("--enable-option-checking=fatal" "${conf_processed_arguments[@]}") 223169689Skan 224132718Skan### 225132718Skan### Call the configure script 226132718Skan### 227132718Skanif test -e $conf_custom_script_dir/generated-configure.sh; then 228132718Skan # Custom source configure available; run that instead 229132718Skan echo Running custom generated-configure.sh 230132718Skan conf_script_to_run=$conf_custom_script_dir/generated-configure.sh 231132718Skanelse 232132718Skan echo Running generated-configure.sh 233132718Skan conf_script_to_run=$conf_script_dir/generated-configure.sh 234132718Skanfi 235169689Skan 236132718Skanif test "x$conf_debug_configure" != x; then 237169689Skan # Turn on shell debug output if requested (initial or recursive) 238169689Skan set -x 239132718Skanfi 240132718Skan 241132718Skanif test "x$conf_debug_configure" = xtrue; then 242132718Skan # Turn on logging, but don't turn on twice when called recursive 243169689Skan conf_debug_logfile=./debug-configure.log 244132718Skan (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 245132718Skanelse 246132718Skan ( . $conf_script_to_run "${conf_processed_arguments[@]}" ) 247169689Skanfi 248132718Skan 249169689Skanconf_result_code=$? 250132718Skan### 251132718Skan### Post-processing 252169689Skan### 253132718Skan 254132718Skanif test $conf_result_code -eq 0; then 255132718Skan if test "x$conf_print_help" = xtrue; then 256169689Skan cat <<EOT 257132718Skan 258132718SkanAdditional (non-autoconf) OpenJDK Options: 259132718Skan --openjdk-target=TARGET cross-compile with TARGET as target platform 260132718Skan (i.e. the one you will run the resulting binary on). 261132718Skan Equivalent to --host=TARGET --target=TARGET 262169689Skan --build=<current platform> 263132718Skan --debug-configure Run the configure script with additional debug 264132718Skan logging enabled. 265132718Skan 266132718SkanEOT 267132718Skan 268132718Skan # Print list of toolchains. This must be done by the autoconf script. 269132718Skan ( CONFIGURE_PRINT_TOOLCHAIN_LIST=true . $conf_script_to_run PRINTF=printf ) 270132718Skan 271169689Skan cat <<EOT 272169689Skan 273132718SkanPlease be aware that, when cross-compiling, the OpenJDK configure script will 274169689Skangenerally use 'target' where autoconf traditionally uses 'host'. 275169689Skan 276132718SkanAlso note that variables must be passed on the command line. Variables in the 277132718Skanenvironment will generally be ignored, unlike traditional autoconf scripts. 278169689SkanEOT 279169689Skan fi 280132718Skanelse 281132718Skan echo configure exiting with result code $conf_result_code 282132718Skanfi 283169689Skan 284132718Skanexit $conf_result_code 285132718Skan