changeset 2396:2209644bcac4

8034199: Add 'reconfigure' target for re-creating a configuration Reviewed-by: ihse, erikj, tbell
author kevinw
date Tue, 10 Apr 2018 07:46:25 -0700
parents a05ed58d5ae0
children dd97daafa80b
files common/autoconf/basics.m4 common/autoconf/configure common/autoconf/generated-configure.sh common/autoconf/spec.gmk.in make/Main.gmk
diffstat 5 files changed, 68 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/common/autoconf/basics.m4	Sat Apr 07 03:28:39 2018 -0700
+++ b/common/autoconf/basics.m4	Tue Apr 10 07:46:25 2018 -0700
@@ -564,9 +564,6 @@
   # You can run make from the OUTPUT_ROOT, or from the top-level Makefile
   # which will look for generated configurations
   AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in])
-
-  # Save the arguments given to us
-  echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments
 ])
 
 AC_DEFUN_ONCE([BASIC_SETUP_LOGGING],
--- a/common/autoconf/configure	Sat Apr 07 03:28:39 2018 -0700
+++ b/common/autoconf/configure	Tue Apr 10 07:46:25 2018 -0700
@@ -32,7 +32,6 @@
 export CONFIG_SHELL=$BASH
 export _as_can_reexec=no
 
-CONFIGURE_COMMAND_LINE="$@"
 conf_script_dir=`dirname $0`
 
 if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
@@ -114,14 +113,40 @@
 if test "x$conf_debug_configure" = xtrue; then
   conf_debug_configure=recursive
 fi
+
 ###
 ### Process command-line arguments
 ###
+
+# Returns a shell-escaped version of the argument given.
+function shell_quote() {
+  if [[ -n "$1" ]]; then
+    # Uses only shell-safe characters?  No quoting needed.
+    # '=' is a zsh meta-character, but only in word-initial position.
+    if [[ "$1" =~ ^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.:,%/+=_-]+$ && ! "$1" =~ ^= ]]; then
+      quoted="$1"
+    else
+      if [[ "$1" =~ [\'!] ]]; then
+        # csh does history expansion within single quotes, but not
+        # when backslash-escaped!
+        local quoted_quote="'\\''" quoted_exclam="'\\!'"
+        word="${1//\'/${quoted_quote}}"
+        word="${1//\!/${quoted_exclam}}"
+      fi
+      quoted="'$1'"
+    fi
+    echo "$quoted"
+  fi
+}
+
 conf_processed_arguments=()
+conf_quoted_arguments=()
 conf_openjdk_target=
 
 for conf_option
 do
+
+  # Process (and remove) our own extensions that will not be passed to autoconf
   case $conf_option in
     --openjdk-target=*)
       conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
@@ -132,18 +157,35 @@
         export conf_debug_configure
       fi
       ;;
-    [^-]*=*)
-      # Add name of variable to CONFIGURE_OVERRIDDEN_VARIABLES list inside !...!.
-      conf_env_var=`expr "x$conf_option" : 'x\([^=]*\)='`
-      CONFIGURE_OVERRIDDEN_VARIABLES="$CONFIGURE_OVERRIDDEN_VARIABLES!$conf_env_var!"
-      # ... and then process argument as usual
-      conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option")
-      ;;
     *)
       conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option")
       ;;
   esac
 
+  # Store all variables overridden on the command line
+  case $conf_option in
+    [^-]*=*)
+      # Add name of variable to CONFIGURE_OVERRIDDEN_VARIABLES list inside !...!.
+      conf_env_var=`expr "x$conf_option" : 'x\([^=]*\)='`
+      CONFIGURE_OVERRIDDEN_VARIABLES="$CONFIGURE_OVERRIDDEN_VARIABLES!$conf_env_var!"
+      ;;
+  esac
+
+  # Save the arguments, intelligently quoted for CONFIGURE_COMMAND_LINE.
+  case $conf_option in
+    *=*)
+      conf_option_name=`expr "x$conf_option" : 'x\([^=]*\)='`
+      conf_option_name=$(shell_quote "$conf_option_name")
+      conf_option_value=`expr "x$conf_option" : 'x[^=]*=\(.*\)'`
+      conf_option_value=$(shell_quote "$conf_option_value")
+      conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$conf_option_name=$conf_option_value")
+      ;;
+    *)
+      conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")")
+      ;;
+  esac
+
+  # Check for certain autoconf options that require extra action
   case $conf_option in
     -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
       conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
@@ -156,6 +198,9 @@
   esac
 done
 
+# Save the quoted command line
+CONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}"
+
 if test "x$conf_legacy_crosscompile" != "x"; then
   if test "x$conf_openjdk_target" != "x"; then
     echo "Error: Specifying --openjdk-target together with autoconf"
--- a/common/autoconf/generated-configure.sh	Sat Apr 07 03:28:39 2018 -0700
+++ b/common/autoconf/generated-configure.sh	Tue Apr 10 07:46:25 2018 -0700
@@ -4219,7 +4219,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1523096909
+DATE_WHEN_GENERATED=1523371497
 
 ###############################################################################
 #
@@ -15007,9 +15007,6 @@
   ac_config_files="$ac_config_files $OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in"
 
 
-  # Save the arguments given to us
-  echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments
-
 
 # Must be done before we can call HELP_MSG_MISSING_DEPENDENCY.
 
--- a/common/autoconf/spec.gmk.in	Sat Apr 07 03:28:39 2018 -0700
+++ b/common/autoconf/spec.gmk.in	Tue Apr 10 07:46:25 2018 -0700
@@ -46,6 +46,9 @@
 
 endef
 
+# The command line given to configure.
+CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@
+
 # A self-referential reference to this file.
 SPEC:=@SPEC@
 
--- a/make/Main.gmk	Sat Apr 07 03:28:39 2018 -0700
+++ b/make/Main.gmk	Tue Apr 10 07:46:25 2018 -0700
@@ -71,8 +71,9 @@
 # Setup a rule for SPEC file that fails if executed. This check makes sure the configuration
 # is up to date after changes to configure
 $(SPEC): $(wildcard $(SRC_ROOT)/common/autoconf/*)
-	@$(ECHO) ERROR: $(SPEC) is not up to date
-	@$(ECHO) Please rerun configure!
+	@$(ECHO) "ERROR: $(SPEC) is not up to date."
+	@$(ECHO) "Please rerun configure! Easiest way to do this is by running"
+	@$(ECHO) "'make reconfigure'."
 	@if test "x$(IGNORE_OLD_CONFIG)" != "xtrue"; then exit 1; fi
 
 start-make: $(SPEC)
@@ -230,6 +231,14 @@
 	$(call CleanComponent,docstemp)
 clean-test:
 	$(call CleanComponent,testoutput)
+	
+reconfigure:
+        ifneq ($(CONFIGURE_COMMAND_LINE), )
+	  @$(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'"
+        else
+	  @$(ECHO) "Re-running configure using default settings"
+        endif
+	@( cd $(OUTPUT_ROOT) && $(BASH) $(TOPDIR)/configure "$(CONFIGURE_COMMAND_LINE)" )
 
 .PHONY: langtools corba jaxp jaxws hotspot jdk nashorn images overlay-images install test docs
 .PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only nashorn-only images-only overlay-images-only install-only test-only docs-only