--- a/make/autoconf/configure Mon Feb 05 11:12:09 2018 +0800
+++ b/make/autoconf/configure Mon Feb 05 09:15:32 2018 +0100
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -43,82 +43,138 @@
export CONFIG_SHELL=$BASH
export _as_can_reexec=no
-conf_script_dir="$TOPDIR/make/autoconf"
-
if test "x$CUSTOM_CONFIG_DIR" != x; then
- if test ! -e $CUSTOM_CONFIG_DIR/generated-configure.sh; then
+ custom_hook=$CUSTOM_CONFIG_DIR/custom-hook.m4
+ if test ! -e $custom_hook; then
echo "CUSTOM_CONFIG_DIR not pointing to a proper custom config dir."
echo "Error: Cannot continue" 1>&2
exit 1
fi
+ build_support_dir="$CUSTOM_ROOT/.build"
+else
+ build_support_dir="$TOPDIR/.build"
fi
+conf_script_dir="$TOPDIR/make/autoconf"
+generated_script="$build_support_dir/generated-configure.sh"
+
###
-### Test that the generated configure is up-to-date
+### Use autoconf to create a runnable configure script, if needed
###
-run_autogen_or_fail() {
- if test "x`which autoconf 2> /dev/null | grep -v '^no autoconf in'`" = x; then
- echo "Cannot locate autoconf, unable to correct situation."
- echo "Please install autoconf and run 'bash autogen.sh' to update the generated files."
- echo "Error: Cannot continue" 1>&2
- exit 1
- else
- echo "Running autogen.sh to correct the situation"
- bash $conf_script_dir/autogen.sh
+autoconf_missing_help() {
+ APT_GET="`which apt-get 2> /dev/null | grep -v '^no apt-get in'`"
+ YUM="`which yum 2> /dev/null | grep -v '^no yum in'`"
+ BREW="`which brew 2> /dev/null | grep -v '^no brew in'`"
+ CYGWIN="`which cygpath 2> /dev/null | grep -v '^no cygpath in'`"
+
+ if test "x$APT_GET" != x; then
+ PKGHANDLER_COMMAND="sudo apt-get install autoconf"
+ elif test "x$YUM" != x; then
+ PKGHANDLER_COMMAND="sudo yum install autoconf"
+ elif test "x$BREW" != x; then
+ PKGHANDLER_COMMAND="brew install autoconf"
+ elif test "x$CYGWIN" != x; then
+ PKGHANDLER_COMMAND="( cd <location of cygwin setup.exe> && cmd /c setup -q -P autoconf )"
+ fi
+
+ if test "x$PKGHANDLER_COMMAND" != x; then
+ echo "You might be able to fix this by running '$PKGHANDLER_COMMAND'."
fi
}
-check_autoconf_timestamps() {
- for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 ; do
- if test $file -nt $conf_script_dir/generated-configure.sh; then
- echo "Warning: The configure source files is newer than the generated files."
- run_autogen_or_fail
+generate_configure_script() {
+ if test "x$AUTOCONF" != x; then
+ if test ! -x "$AUTOCONF"; then
+ echo
+ echo "The specified AUTOCONF variable does not point to a valid autoconf executable:"
+ echo "AUTOCONF=$AUTOCONF"
+ echo "Error: Cannot continue" 1>&2
+ exit 1
fi
- done
+ else
+ AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`"
+ if test "x$AUTOCONF" = x; then
+ echo
+ echo "Autoconf is not found on the PATH, and AUTOCONF is not set."
+ echo "You need autoconf to be able to generate a runnable configure script."
+ autoconf_missing_help
+ echo "Error: Cannot find autoconf" 1>&2
+ exit 1
+ fi
+ fi
+
+ autoconf_version=`$AUTOCONF --version | head -1`
+ echo "Using autoconf at ${AUTOCONF} [$autoconf_version]"
if test "x$CUSTOM_CONFIG_DIR" != x; then
- # If custom source configure is available, make sure it is up-to-date as well.
- for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $CUSTOM_CONFIG_DIR/*.m4; do
- if test $file -nt $CUSTOM_CONFIG_DIR/generated-configure.sh; then
- echo "Warning: The configure source files is newer than the custom generated files."
- run_autogen_or_fail
- fi
- done
+ # Generate configure script with custom hooks compiled in.
+ custom_patcher='sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
+ else
+ custom_patcher='cat'
+ fi
+
+ mkdir -p `dirname $generated_script`
+ # Call autoconf but replace the "magic" variable in configure.ac if requested.
+ cat $conf_script_dir/configure.ac | eval $custom_patcher | \
+ ${AUTOCONF} -W all -I$conf_script_dir - > $generated_script
+ rm -rf autom4te.cache
+
+ # Sanity check
+ if test ! -s $generated_script; then
+ echo "Error: Failed to generate runnable configure script" 1>&2
+ rm -f $generated_script
+ exit 1
fi
}
-check_hg_updates() {
+test_generated_up_to_date() {
if test "x`which hg 2> /dev/null | grep -v '^no hg in'`" != x; then
conf_updated_autoconf_files=`cd $conf_script_dir && hg status -mard . 2> /dev/null`
- if test "x$conf_updated_autoconf_files" != x; then
- echo "Configure source code has been updated, checking time stamps"
- check_autoconf_timestamps
- elif test "x$CUSTOM_CONFIG_DIR" != x; then
- # If custom source configure is available, make sure it is up-to-date as well.
+ conf_source_files="$conf_script_dir/configure.ac $conf_script_dir/*.m4"
+ if test "x$CUSTOM_CONFIG_DIR" != x; then
conf_custom_updated_autoconf_files=`cd $CUSTOM_CONFIG_DIR && hg status -mard . 2> /dev/null`
- if test "x$conf_custom_updated_autoconf_files" != x; then
- echo "Configure custom source code has been updated, checking time stamps"
- check_autoconf_timestamps
- fi
+ conf_custom_source_files="$CUSTOM_CONFIG_DIR/*.m4"
+ else
+ conf_custom_updated_autoconf_files=""
+ conf_custom_source_files=""
+ fi
+
+ if test "x${conf_updated_autoconf_files}${conf_custom_updated_autoconf_files}" != x; then
+ for file in $conf_source_files $conf_custom_source_files ; do
+ if test $file -nt $generated_script; then
+ return 0
+ fi
+ done
fi
fi
+ return 1
}
-# Check for local changes
-check_hg_updates
+run_autoconf=false
+if test "x$1" = xautogen; then
+ # User called us as "configure autogen", so force regeneration
+ run_autoconf=true
+ shift
+fi
-if test "x$CUSTOM_CONFIG_DIR" != x; then
- # Test if open configure is newer than custom configure, if so, custom needs to
- # be regenerated. This test is required to ensure consistency with custom source.
- conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_script_dir/generated-configure.sh | cut -d"=" -f 2`
- conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $CUSTOM_CONFIG_DIR/generated-configure.sh | cut -d"=" -f 2`
- if test $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
- echo "Warning: The generated configure file contains changes not present in the custom generated file."
- run_autogen_or_fail
+if test ! -s $generated_script; then
+ # Generated script is missing, so we need to create it
+ echo "Runnable configure script is not present"
+ run_autoconf=true
+else
+ # File is present, but is it up to date?
+ if test_generated_up_to_date; then
+ echo "Runnable configure script is not up to date"
+ run_autoconf=true
fi
fi
+if test "x$run_autoconf" = xtrue; then
+ echo "Generating runnable configure script"
+ generate_configure_script
+fi
+
# Autoconf calls the configure script recursively sometimes.
# Don't start logging twice in that case
if test "x$conf_debug_configure" = xtrue; then
@@ -240,15 +296,6 @@
###
### Call the configure script
###
-if test "x$CUSTOM_CONFIG_DIR" != x; then
- # Custom source configure available; run that instead
- echo "Running custom generated-configure.sh"
- conf_script_to_run=$CUSTOM_CONFIG_DIR/generated-configure.sh
-else
- echo "Running generated-configure.sh"
- conf_script_to_run=$conf_script_dir/generated-configure.sh
-fi
-
if test "x$conf_debug_configure" != x; then
# Turn on shell debug output if requested (initial or recursive)
set -x
@@ -259,7 +306,7 @@
RCDIR=`mktemp -dt jdk-build-configure.tmp.XXXXXX` || exit $?
trap "rm -rf \"$RCDIR\"" EXIT
conf_logfile=./configure.log
-(exec 3>&1 ; ((. $conf_script_to_run "${conf_processed_arguments[@]}" 2>&1 1>&3 ) \
+(exec 3>&1 ; ((. $generated_script "${conf_processed_arguments[@]}" 2>&1 1>&3 ) \
; echo $? > "$RCDIR/rc" ) \
| tee -a $conf_logfile 1>&2 ; exec 3>&-) | tee -a $conf_logfile
@@ -284,7 +331,7 @@
# Print additional help, e.g. a list of toolchains and JVM features.
# This must be done by the autoconf script.
- ( CONFIGURE_PRINT_ADDITIONAL_HELP=true . $conf_script_to_run PRINTF=printf )
+ ( CONFIGURE_PRINT_ADDITIONAL_HELP=true . $generated_script PRINTF=printf )
cat <<EOT