configure revision 1319:507654772146
1139743Simp#!/bin/bash 243412Snewton# 343412Snewton# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 443412Snewton# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 543412Snewton# 643412Snewton# This code is free software; you can redistribute it and/or modify it 743412Snewton# under the terms of the GNU General Public License version 2 only, as 843412Snewton# published by the Free Software Foundation. 943412Snewton# 1043412Snewton# This code is distributed in the hope that it will be useful, but WITHOUT 1143412Snewton# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1243412Snewton# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1343412Snewton# version 2 for more details (a copy is included in the LICENSE file that 1443412Snewton# accompanied this code). 1543412Snewton# 1643412Snewton# You should have received a copy of the GNU General Public License version 1743412Snewton# 2 along with this work; if not, write to the Free Software Foundation, 1843412Snewton# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1943412Snewton# 2043412Snewton# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2143412Snewton# or visit www.oracle.com if you need additional information or have any 2243412Snewton# questions. 2343412Snewton# 2443412Snewton 2543412Snewtonif test "x$1" != xCHECKME; then 2643412Snewton echo "WARNING: Calling the wrapper script directly is deprecated and unsupported." 2743412Snewton echo "Not all features of configure will be available." 2843412Snewton echo "Use the 'configure' script in the top-level directory instead." 29116174Sobrien TOPDIR=$(cd $(dirname $0)/../.. > /dev/null && pwd) 30116174Sobrienelse 31116174Sobrien # Now the next argument is the absolute top-level directory path. 3243412Snewton # The TOPDIR variable is passed on to configure.ac. 3343412Snewton TOPDIR="$2" 3476166Smarkm # Remove these two arguments to get to the user supplied arguments 3576166Smarkm shift 3676166Smarkm shift 3743412Snewtonfi 3843412Snewton 3943412Snewtonif test "x$BASH" = x; then 40113859Sjhb echo "Error: This script must be run using bash." 1>&2 4143412Snewton exit 1 4243412Snewtonfi 4369541Smarcel# Force autoconf to use bash. This also means we must disable autoconf re-exec. 4469541Smarcelexport CONFIG_SHELL=$BASH 4565302Sobrienexport _as_can_reexec=no 4665302Sobrien 4765302Sobrienconf_script_dir="$TOPDIR/common/autoconf" 4865302Sobrien 4965302Sobrienif [ "$CUSTOM_CONFIG_DIR" = "" ]; then 5065302Sobrien conf_custom_script_dir="$TOPDIR/closed/autoconf" 5143412Snewtonelse 5243412Snewton conf_custom_script_dir="$CUSTOM_CONFIG_DIR" 5343412Snewtonfi 5443412Snewton 5543412Snewton### 5643412Snewton### Test that the generated configure is up-to-date 5743412Snewton### 5892761Salfred 5992761Salfredrun_autogen_or_fail() { 6092761Salfred if test "x`which autoconf 2> /dev/null | grep -v '^no autoconf in'`" = x; then 6143412Snewton echo "Cannot locate autoconf, unable to correct situation." 62142500Ssam echo "Please install autoconf and run 'bash autogen.sh' to update the generated files." 63142500Ssam echo "Error: Cannot continue" 1>&2 6443412Snewton exit 1 6543412Snewton else 6643412Snewton echo "Running autogen.sh to correct the situation" 6743412Snewton bash $conf_script_dir/autogen.sh 6843412Snewton fi 6943412Snewton} 7043412Snewton 7143412Snewtoncheck_autoconf_timestamps() { 7243412Snewton for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 ; do 7343412Snewton if test $file -nt $conf_script_dir/generated-configure.sh; then 7443412Snewton echo "Warning: The configure source files is newer than the generated files." 7543412Snewton run_autogen_or_fail 7643412Snewton fi 7743412Snewton done 7843412Snewton 7943412Snewton if test -e $conf_custom_script_dir/generated-configure.sh; then 8043412Snewton # If custom source configure is available, make sure it is up-to-date as well. 8143412Snewton for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $conf_custom_script_dir/*.m4; do 8243412Snewton if test $file -nt $conf_custom_script_dir/generated-configure.sh; then 8343412Snewton echo "Warning: The configure source files is newer than the custom generated files." 8443412Snewton run_autogen_or_fail 8543412Snewton fi 8643412Snewton done 8743412Snewton fi 8843412Snewton} 8943412Snewton 9043412Snewtoncheck_hg_updates() { 9143412Snewton if test "x`which hg 2> /dev/null | grep -v '^no hg in'`" != x; then 9243412Snewton conf_updated_autoconf_files=`cd $conf_script_dir && hg status -mard 2> /dev/null | grep autoconf` 9343412Snewton if test "x$conf_updated_autoconf_files" != x; then 9443412Snewton echo "Configure source code has been updated, checking time stamps" 9543412Snewton check_autoconf_timestamps 9643412Snewton fi 97142500Ssam 98142500Ssam if test -e $conf_custom_script_dir; then 9943412Snewton # If custom source configure is available, make sure it is up-to-date as well. 10043412Snewton conf_custom_updated_autoconf_files=`cd $conf_custom_script_dir && hg status -mard 2> /dev/null | grep autoconf` 10143412Snewton if test "x$conf_custom_updated_autoconf_files" != x; then 10243412Snewton echo "Configure custom source code has been updated, checking time stamps" 10343412Snewton check_autoconf_timestamps 10443412Snewton fi 10543412Snewton fi 10643412Snewton fi 10743412Snewton} 10843412Snewton 10943412Snewton# Check for local changes 11043412Snewtoncheck_hg_updates 11143412Snewton 11243412Snewtonif test -e $conf_custom_script_dir/generated-configure.sh; then 11343412Snewton # Test if open configure is newer than custom configure, if so, custom needs to 11443412Snewton # be regenerated. This test is required to ensure consistency with custom source. 11543412Snewton conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_script_dir/generated-configure.sh | cut -d"=" -f 2` 11643412Snewton conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_custom_script_dir/generated-configure.sh | cut -d"=" -f 2` 11743412Snewton if test $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then 11843412Snewton echo "Warning: The generated configure file contains changes not present in the custom generated file." 11943412Snewton run_autogen_or_fail 12043412Snewton fi 12143412Snewtonfi 12243412Snewton 12343412Snewton# Autoconf calls the configure script recursively sometimes. 12443412Snewton# Don't start logging twice in that case 12543412Snewtonif test "x$conf_debug_configure" = xtrue; then 12643412Snewton conf_debug_configure=recursive 12743412Snewtonfi 12843412Snewton 12943412Snewton### 13043412Snewton### Process command-line arguments 13143412Snewton### 13243412Snewton 13356046Snewton# Returns a shell-escaped version of the argument given. 13456046Snewtonfunction shell_quote() { 13556046Snewton if [[ -n "$1" ]]; then 13656046Snewton # Uses only shell-safe characters? No quoting needed. 13756046Snewton # '=' is a zsh meta-character, but only in word-initial position. 13856046Snewton if echo "$1" | grep '^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\.:,%/+=_-]\{1,\}$' > /dev/null \ 139142500Ssam && ! echo "$1" | grep '^=' > /dev/null; then 14056046Snewton quoted="$1" 14156046Snewton else 14256046Snewton if echo "$1" | grep "[\'!]" > /dev/null; then 14356046Snewton # csh does history expansion within single quotes, but not 14456046Snewton # when backslash-escaped! 14543412Snewton local quoted_quote="'\\''" quoted_exclam="'\\!'" 14643412Snewton word="${1//\'/${quoted_quote}}" 14743412Snewton word="${1//\!/${quoted_exclam}}" 14843412Snewton fi 14943412Snewton quoted="'$1'" 15043412Snewton fi 15151793Smarcel echo "$quoted" 152142500Ssam fi 153142500Ssam} 15456046Snewton 15543412Snewtonconf_processed_arguments=() 15651793Smarcelconf_quoted_arguments=() 15743412Snewtonconf_openjdk_target= 15843412Snewton 15943412Snewtonfor conf_option 16043412Snewtondo 16143412Snewton 16243412Snewton # Process (and remove) our own extensions that will not be passed to autoconf 16343412Snewton case $conf_option in 16443412Snewton --openjdk-target=*) 16543412Snewton conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'` 16643412Snewton ;; 16743412Snewton --debug-configure) 168142500Ssam if test "x$conf_debug_configure" != xrecursive; then 16951793Smarcel conf_debug_configure=true 170142500Ssam export conf_debug_configure 17143412Snewton fi 17243412Snewton ;; 17343412Snewton *) 17443412Snewton conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option") 17543412Snewton ;; 17643412Snewton esac 17743412Snewton 17843412Snewton # Store all variables overridden on the command line 17943412Snewton case $conf_option in 18043412Snewton [^-]*=*) 18143412Snewton # Add name of variable to CONFIGURE_OVERRIDDEN_VARIABLES list inside !...!. 18243412Snewton conf_env_var=`expr "x$conf_option" : 'x\([^=]*\)='` 18343412Snewton CONFIGURE_OVERRIDDEN_VARIABLES="$CONFIGURE_OVERRIDDEN_VARIABLES!$conf_env_var!" 18443412Snewton ;; 18543412Snewton esac 18648620Scracauer 18748620Scracauer # Save the arguments, intelligently quoted for CONFIGURE_COMMAND_LINE. 18843412Snewton case $conf_option in 18948620Scracauer *=*) 19043412Snewton conf_option_name=`expr "x$conf_option" : 'x\([^=]*\)='` 19148620Scracauer conf_option_name=$(shell_quote "$conf_option_name") 19243412Snewton conf_option_value=`expr "x$conf_option" : 'x[^=]*=\(.*\)'` 19348620Scracauer conf_option_value=$(shell_quote "$conf_option_value") 19443412Snewton conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$conf_option_name=$conf_option_value") 19548620Scracauer ;; 19643412Snewton *) 19748620Scracauer conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")") 19843412Snewton ;; 19948620Scracauer esac 20043412Snewton 20148620Scracauer # Check for certain autoconf options that require extra action 20243412Snewton case $conf_option in 20348620Scracauer -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*) 20443412Snewton conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;; 20543412Snewton -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) 20643412Snewton conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;; 20743412Snewton -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*) 20843412Snewton conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;; 20943412Snewton -help | --help | --hel | --he | -h) 21043412Snewton conf_print_help=true ;; 21143412Snewton esac 21243412Snewtondone 21348620Scracauer 21448620Scracauer# Save the quoted command line 21548620ScracauerCONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}" 21643412Snewton 21748620Scracauerif test "x$conf_legacy_crosscompile" != "x"; then 21843412Snewton if test "x$conf_openjdk_target" != "x"; then 21948620Scracauer echo "Error: Specifying --openjdk-target together with autoconf" 22043412Snewton echo "legacy cross-compilation flags is not supported." 22148620Scracauer echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile." 22243412Snewton echo "The recommended use is just --openjdk-target." 22348620Scracauer exit 1 22443412Snewton else 22548620Scracauer echo "Warning: You are using legacy autoconf cross-compilation flags." 22643412Snewton echo "It is recommended that you use --openjdk-target instead." 22743412Snewton echo "" 22843412Snewton fi 22943412Snewtonfi 23043412Snewton 23143412Snewtonif test "x$conf_openjdk_target" != "x"; then 23243412Snewton conf_build_platform=`sh $conf_script_dir/build-aux/config.guess` 23343412Snewton conf_processed_arguments=("--build=$conf_build_platform" "--host=$conf_openjdk_target" "--target=$conf_openjdk_target" "${conf_processed_arguments[@]}") 23443412Snewtonfi 23543412Snewton 23643412Snewton# Make configure exit with error on invalid options as default. 23743412Snewton# Can be overridden by --disable-option-checking, since we prepend our argument 23843412Snewton# and later options override earlier. 23943412Snewtonconf_processed_arguments=("--enable-option-checking=fatal" "${conf_processed_arguments[@]}") 24043412Snewton 241150663Srwatson### 24243412Snewton### Call the configure script 24343412Snewton### 24443412Snewtonif test -e $conf_custom_script_dir/generated-configure.sh; then 24543412Snewton # Custom source configure available; run that instead 24643412Snewton echo "Running custom generated-configure.sh" 24743412Snewton conf_script_to_run=$conf_custom_script_dir/generated-configure.sh 24843412Snewtonelse 24943412Snewton echo "Running generated-configure.sh" 25043412Snewton conf_script_to_run=$conf_script_dir/generated-configure.sh 25143412Snewtonfi 25243412Snewton 25343412Snewtonif test "x$conf_debug_configure" != x; then 25443412Snewton # Turn on shell debug output if requested (initial or recursive) 25543412Snewton set -x 25643412Snewtonfi 25743412Snewton 25843412Snewtonif test "x$conf_debug_configure" = xtrue; then 25943412Snewton # Turn on logging, but don't turn on twice when called recursive 26043412Snewton conf_debug_logfile=./debug-configure.log 26183366Sjulian (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 262193014Sdelphijelse 26343412Snewton ( . $conf_script_to_run "${conf_processed_arguments[@]}" ) 26443412Snewtonfi 265113859Sjhb 266113859Sjhbconf_result_code=$? 267113859Sjhb### 26843412Snewton### Post-processing 26943412Snewton### 270121275Stjr 271121275Stjrif test $conf_result_code -eq 0; then 272121275Stjr if test "x$conf_print_help" = xtrue; then 27383366Sjulian cat <<EOT 274107849Salfred 275107849SalfredAdditional (non-autoconf) OpenJDK Options: 27656046Snewton --openjdk-target=TARGET cross-compile with TARGET as target platform 277113859Sjhb (i.e. the one you will run the resulting binary on). 278113859Sjhb Equivalent to --host=TARGET --target=TARGET 279113859Sjhb --build=<current platform> 280113859Sjhb --debug-configure Run the configure script with additional debug 281113859Sjhb logging enabled. 28243412Snewton 283113859SjhbEOT 28456046Snewton 28556046Snewton # Print list of toolchains. This must be done by the autoconf script. 28656046Snewton ( CONFIGURE_PRINT_TOOLCHAIN_LIST=true . $conf_script_to_run PRINTF=printf ) 28756046Snewton 28856046Snewton cat <<EOT 289113859Sjhb 290113859SjhbPlease be aware that, when cross-compiling, the OpenJDK configure script will 29156046Snewtongenerally use 'target' where autoconf traditionally uses 'host'. 29256046Snewton 293113859SjhbAlso note that variables must be passed on the command line. Variables in the 294113859Sjhbenvironment will generally be ignored, unlike traditional autoconf scripts. 295113859SjhbEOT 296113859Sjhb fi 297113859Sjhbelse 29843412Snewton echo configure exiting with result code $conf_result_code 299113859Sjhbfi 30043412Snewton 30143412Snewtonexit $conf_result_code 30243412Snewton