Skip to content

Commit 2b3bf09

Browse files
committed
8034199: Add 'reconfigure' target for re-creating a configuration
Reviewed-by: ihse, erikj, tbell
1 parent 4106f1f commit 2b3bf09

File tree

5 files changed

+64
-13
lines changed

5 files changed

+64
-13
lines changed

common/autoconf/basics.m4

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
564564
# You can run make from the OUTPUT_ROOT, or from the top-level Makefile
565565
# which will look for generated configurations
566566
AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in])
567-
568-
# Save the arguments given to us
569-
echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments
570567
])
571568

572569
AC_DEFUN_ONCE([BASIC_SETUP_LOGGING],

common/autoconf/configure

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ fi
3232
export CONFIG_SHELL=$BASH
3333
export _as_can_reexec=no
3434

35-
CONFIGURE_COMMAND_LINE="$@"
3635
conf_script_dir=`dirname $0`
3736

3837
if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
@@ -114,14 +113,40 @@ fi
114113
if test "x$conf_debug_configure" = xtrue; then
115114
conf_debug_configure=recursive
116115
fi
116+
117117
###
118118
### Process command-line arguments
119119
###
120+
121+
# Returns a shell-escaped version of the argument given.
122+
function shell_quote() {
123+
if [[ -n "$1" ]]; then
124+
# Uses only shell-safe characters? No quoting needed.
125+
# '=' is a zsh meta-character, but only in word-initial position.
126+
if [[ "$1" =~ ^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.:,%/+=_-]+$ && ! "$1" =~ ^= ]]; then
127+
quoted="$1"
128+
else
129+
if [[ "$1" =~ [\'!] ]]; then
130+
# csh does history expansion within single quotes, but not
131+
# when backslash-escaped!
132+
local quoted_quote="'\\''" quoted_exclam="'\\!'"
133+
word="${1//\'/${quoted_quote}}"
134+
word="${1//\!/${quoted_exclam}}"
135+
fi
136+
quoted="'$1'"
137+
fi
138+
echo "$quoted"
139+
fi
140+
}
141+
120142
conf_processed_arguments=()
143+
conf_quoted_arguments=()
121144
conf_openjdk_target=
122145

123146
for conf_option
124147
do
148+
149+
# Process (and remove) our own extensions that will not be passed to autoconf
125150
case $conf_option in
126151
--openjdk-target=*)
127152
conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
@@ -132,18 +157,35 @@ do
132157
export conf_debug_configure
133158
fi
134159
;;
160+
*)
161+
conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option")
162+
;;
163+
esac
164+
165+
# Store all variables overridden on the command line
166+
case $conf_option in
135167
[^-]*=*)
136168
# Add name of variable to CONFIGURE_OVERRIDDEN_VARIABLES list inside !...!.
137169
conf_env_var=`expr "x$conf_option" : 'x\([^=]*\)='`
138170
CONFIGURE_OVERRIDDEN_VARIABLES="$CONFIGURE_OVERRIDDEN_VARIABLES!$conf_env_var!"
139-
# ... and then process argument as usual
140-
conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option")
171+
;;
172+
esac
173+
174+
# Save the arguments, intelligently quoted for CONFIGURE_COMMAND_LINE.
175+
case $conf_option in
176+
*=*)
177+
conf_option_name=`expr "x$conf_option" : 'x\([^=]*\)='`
178+
conf_option_name=$(shell_quote "$conf_option_name")
179+
conf_option_value=`expr "x$conf_option" : 'x[^=]*=\(.*\)'`
180+
conf_option_value=$(shell_quote "$conf_option_value")
181+
conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$conf_option_name=$conf_option_value")
141182
;;
142183
*)
143-
conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option")
184+
conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")")
144185
;;
145186
esac
146187

188+
# Check for certain autoconf options that require extra action
147189
case $conf_option in
148190
-build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
149191
conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
@@ -156,6 +198,9 @@ do
156198
esac
157199
done
158200

201+
# Save the quoted command line
202+
CONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}"
203+
159204
if test "x$conf_legacy_crosscompile" != "x"; then
160205
if test "x$conf_openjdk_target" != "x"; then
161206
echo "Error: Specifying --openjdk-target together with autoconf"

common/autoconf/generated-configure.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4219,7 +4219,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++"
42194219
#CUSTOM_AUTOCONF_INCLUDE
42204220

42214221
# Do not change or remove the following line, it is needed for consistency checks:
4222-
DATE_WHEN_GENERATED=1523096909
4222+
DATE_WHEN_GENERATED=1523371497
42234223

42244224
###############################################################################
42254225
#
@@ -15007,9 +15007,6 @@ $as_echo "$as_me: The path of OUTPUT_ROOT, which resolves as \"$path\", is inval
1500715007
ac_config_files="$ac_config_files $OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in"
1500815008

1500915009

15010-
# Save the arguments given to us
15011-
echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments
15012-
1501315010

1501415011
# Must be done before we can call HELP_MSG_MISSING_DEPENDENCY.
1501515012

common/autoconf/spec.gmk.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ define NEWLINE
4646

4747
endef
4848

49+
# The command line given to configure.
50+
CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@
51+
4952
# A self-referential reference to this file.
5053
SPEC:=@SPEC@
5154

make/Main.gmk

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ all: images docs
7171
# Setup a rule for SPEC file that fails if executed. This check makes sure the configuration
7272
# is up to date after changes to configure
7373
$(SPEC): $(wildcard $(SRC_ROOT)/common/autoconf/*)
74-
@$(ECHO) ERROR: $(SPEC) is not up to date
75-
@$(ECHO) Please rerun configure!
74+
@$(ECHO) "ERROR: $(SPEC) is not up to date."
75+
@$(ECHO) "Please rerun configure! Easiest way to do this is by running"
76+
@$(ECHO) "'make reconfigure'."
7677
@if test "x$(IGNORE_OLD_CONFIG)" != "xtrue"; then exit 1; fi
7778

7879
start-make: $(SPEC)
@@ -230,6 +231,14 @@ clean-docs:
230231
$(call CleanComponent,docstemp)
231232
clean-test:
232233
$(call CleanComponent,testoutput)
234+
235+
reconfigure:
236+
ifneq ($(CONFIGURE_COMMAND_LINE), )
237+
@$(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'"
238+
else
239+
@$(ECHO) "Re-running configure using default settings"
240+
endif
241+
@( cd $(OUTPUT_ROOT) && $(BASH) $(TOPDIR)/configure "$(CONFIGURE_COMMAND_LINE)" )
233242

234243
.PHONY: langtools corba jaxp jaxws hotspot jdk nashorn images overlay-images install test docs
235244
.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

0 commit comments

Comments
 (0)