Skip to content

Commit 552d8a2

Browse files
committed
8295192: Use original configure command line when called from a script
Reviewed-by: erikj
1 parent cf07eae commit 552d8a2

File tree

5 files changed

+57
-3
lines changed

5 files changed

+57
-3
lines changed

bin/jib.sh

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
44
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
#
66
# This code is free software; you can redistribute it and/or modify it
@@ -135,6 +135,28 @@ install_jib() {
135135
echo "${data_string}" > "${install_data}"
136136
}
137137

138+
# Returns a shell-escaped version of the argument given.
139+
shell_quote() {
140+
if [[ -n "$1" ]]; then
141+
# Uses only shell-safe characters? No quoting needed.
142+
# '=' is a zsh meta-character, but only in word-initial position.
143+
if echo "$1" | grep '^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\.:,%/+=_-]\{1,\}$' > /dev/null \
144+
&& ! echo "$1" | grep '^=' > /dev/null; then
145+
quoted="$1"
146+
else
147+
if echo "$1" | grep "[\'!]" > /dev/null; then
148+
# csh does history expansion within single quotes, but not
149+
# when backslash-escaped!
150+
local quoted_quote="'\\''" quoted_exclam="'\\!'"
151+
word="${1//\'/${quoted_quote}}"
152+
word="${1//\!/${quoted_exclam}}"
153+
fi
154+
quoted="'$1'"
155+
fi
156+
echo "$quoted"
157+
fi
158+
}
159+
138160
# Main body starts here
139161

140162
setup_url
@@ -151,4 +173,16 @@ if [ -z "${JIB_SRC_DIR}" ]; then
151173
export JIB_SRC_DIR="${mydir}/../"
152174
fi
153175

176+
177+
# Save the original command line
178+
conf_quoted_arguments=()
179+
for conf_option; do
180+
conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")")
181+
done
182+
export REAL_CONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}"
183+
184+
myfulldir="$(cd "${mydir}" > /dev/null && pwd)"
185+
export REAL_CONFIGURE_COMMAND_EXEC_FULL="$BASH $myfulldir/$myname"
186+
export REAL_CONFIGURE_COMMAND_EXEC_SHORT="$myname"
187+
154188
${installed_jib_script} "$@"

make/Init.gmk

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,20 @@ else # HAS_SPEC=true
277277
$(ECHO) $(CONFIGURE_COMMAND_LINE)
278278

279279
reconfigure:
280-
ifneq ($(CONFIGURE_COMMAND_LINE), )
280+
ifneq ($(REAL_CONFIGURE_COMMAND_EXEC_FULL), )
281+
$(ECHO) "Re-running configure using original command line '$(REAL_CONFIGURE_COMMAND_EXEC_SHORT) $(REAL_CONFIGURE_COMMAND_LINE)'"
282+
$(eval RECONFIGURE_COMMAND := $(REAL_CONFIGURE_COMMAND_EXEC_FULL) $(REAL_CONFIGURE_COMMAND_LINE))
283+
else ifneq ($(CONFIGURE_COMMAND_LINE), )
281284
$(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'"
285+
$(eval RECONFIGURE_COMMAND := $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE))
282286
else
283287
$(ECHO) "Re-running configure using default settings"
288+
$(eval RECONFIGURE_COMMAND := $(BASH) $(TOPDIR)/configure)
284289
endif
285290
( cd $(CONFIGURE_START_DIR) && PATH="$(ORIGINAL_PATH)" AUTOCONF="$(AUTOCONF)" \
286291
CUSTOM_ROOT="$(CUSTOM_ROOT)" \
287292
CUSTOM_CONFIG_DIR="$(CUSTOM_CONFIG_DIR)" \
288-
$(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) )
293+
$(RECONFIGURE_COMMAND) )
289294

290295
##############################################################################
291296
# The main target, for delegating into Main.gmk

make/autoconf/basic.m4

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ AC_DEFUN_ONCE([BASIC_INIT],
3131
[
3232
# Save the original command line. This is passed to us by the wrapper configure script.
3333
AC_SUBST(CONFIGURE_COMMAND_LINE)
34+
# We might have the original command line if the wrapper was called by some
35+
# other script.
36+
AC_SUBST(REAL_CONFIGURE_COMMAND_EXEC_SHORT)
37+
AC_SUBST(REAL_CONFIGURE_COMMAND_EXEC_FULL)
38+
AC_SUBST(REAL_CONFIGURE_COMMAND_LINE)
3439
# AUTOCONF might be set in the environment by the user. Preserve for "make reconfigure".
3540
AC_SUBST(AUTOCONF)
3641
# Save the path variable before it gets changed

make/autoconf/help.m4

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ AC_DEFUN_ONCE([HELP_PRINT_SUMMARY_AND_WARNINGS],
278278
printf "using default settings.\n"
279279
fi
280280
281+
if test "x$REAL_CONFIGURE_COMMAND_EXEC_FULL" != x; then
282+
printf "\n"
283+
printf "The original configure invocation was '$REAL_CONFIGURE_COMMAND_EXEC_SHORT $REAL_CONFIGURE_COMMAND_LINE'.\n"
284+
fi
285+
281286
printf "\n"
282287
printf "Configuration summary:\n"
283288
printf "* Name: $CONF_NAME\n"

make/autoconf/spec.gmk.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@
3535
# The current directory when configure was run
3636
CONFIGURE_START_DIR:=@CONFIGURE_START_DIR@
3737

38+
# How configure was originally called, if not called directly
39+
REAL_CONFIGURE_COMMAND_EXEC_SHORT := @REAL_CONFIGURE_COMMAND_EXEC_SHORT@
40+
REAL_CONFIGURE_COMMAND_EXEC_FULL := @REAL_CONFIGURE_COMMAND_EXEC_FULL@
41+
REAL_CONFIGURE_COMMAND_LINE := @REAL_CONFIGURE_COMMAND_LINE@
42+
3843
# A self-referential reference to this file.
3944
SPEC:=@SPEC@
4045

0 commit comments

Comments
 (0)