Skip to content

Commit

Permalink
8295192: Use original configure command line when called from a script
Browse files Browse the repository at this point in the history
Reviewed-by: erikj
  • Loading branch information
magicus committed Oct 17, 2022
1 parent cf07eae commit 552d8a2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
36 changes: 35 additions & 1 deletion bin/jib.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 2022, 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
Expand Down Expand Up @@ -135,6 +135,28 @@ install_jib() {
echo "${data_string}" > "${install_data}"
}

# Returns a shell-escaped version of the argument given.
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 echo "$1" | grep '^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\.:,%/+=_-]\{1,\}$' > /dev/null \
&& ! echo "$1" | grep '^=' > /dev/null; then
quoted="$1"
else
if echo "$1" | grep "[\'!]" > /dev/null; 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
}

# Main body starts here

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


# Save the original command line
conf_quoted_arguments=()
for conf_option; do
conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")")
done
export REAL_CONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}"

myfulldir="$(cd "${mydir}" > /dev/null && pwd)"
export REAL_CONFIGURE_COMMAND_EXEC_FULL="$BASH $myfulldir/$myname"
export REAL_CONFIGURE_COMMAND_EXEC_SHORT="$myname"

${installed_jib_script} "$@"
9 changes: 7 additions & 2 deletions make/Init.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,20 @@ else # HAS_SPEC=true
$(ECHO) $(CONFIGURE_COMMAND_LINE)

reconfigure:
ifneq ($(CONFIGURE_COMMAND_LINE), )
ifneq ($(REAL_CONFIGURE_COMMAND_EXEC_FULL), )
$(ECHO) "Re-running configure using original command line '$(REAL_CONFIGURE_COMMAND_EXEC_SHORT) $(REAL_CONFIGURE_COMMAND_LINE)'"
$(eval RECONFIGURE_COMMAND := $(REAL_CONFIGURE_COMMAND_EXEC_FULL) $(REAL_CONFIGURE_COMMAND_LINE))
else ifneq ($(CONFIGURE_COMMAND_LINE), )
$(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'"
$(eval RECONFIGURE_COMMAND := $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE))
else
$(ECHO) "Re-running configure using default settings"
$(eval RECONFIGURE_COMMAND := $(BASH) $(TOPDIR)/configure)
endif
( cd $(CONFIGURE_START_DIR) && PATH="$(ORIGINAL_PATH)" AUTOCONF="$(AUTOCONF)" \
CUSTOM_ROOT="$(CUSTOM_ROOT)" \
CUSTOM_CONFIG_DIR="$(CUSTOM_CONFIG_DIR)" \
$(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) )
$(RECONFIGURE_COMMAND) )

##############################################################################
# The main target, for delegating into Main.gmk
Expand Down
5 changes: 5 additions & 0 deletions make/autoconf/basic.m4
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ AC_DEFUN_ONCE([BASIC_INIT],
[
# Save the original command line. This is passed to us by the wrapper configure script.
AC_SUBST(CONFIGURE_COMMAND_LINE)
# We might have the original command line if the wrapper was called by some
# other script.
AC_SUBST(REAL_CONFIGURE_COMMAND_EXEC_SHORT)
AC_SUBST(REAL_CONFIGURE_COMMAND_EXEC_FULL)
AC_SUBST(REAL_CONFIGURE_COMMAND_LINE)
# AUTOCONF might be set in the environment by the user. Preserve for "make reconfigure".
AC_SUBST(AUTOCONF)
# Save the path variable before it gets changed
Expand Down
5 changes: 5 additions & 0 deletions make/autoconf/help.m4
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ AC_DEFUN_ONCE([HELP_PRINT_SUMMARY_AND_WARNINGS],
printf "using default settings.\n"
fi
if test "x$REAL_CONFIGURE_COMMAND_EXEC_FULL" != x; then
printf "\n"
printf "The original configure invocation was '$REAL_CONFIGURE_COMMAND_EXEC_SHORT $REAL_CONFIGURE_COMMAND_LINE'.\n"
fi
printf "\n"
printf "Configuration summary:\n"
printf "* Name: $CONF_NAME\n"
Expand Down
5 changes: 5 additions & 0 deletions make/autoconf/spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@
# The current directory when configure was run
CONFIGURE_START_DIR:=@CONFIGURE_START_DIR@

# How configure was originally called, if not called directly
REAL_CONFIGURE_COMMAND_EXEC_SHORT := @REAL_CONFIGURE_COMMAND_EXEC_SHORT@
REAL_CONFIGURE_COMMAND_EXEC_FULL := @REAL_CONFIGURE_COMMAND_EXEC_FULL@
REAL_CONFIGURE_COMMAND_LINE := @REAL_CONFIGURE_COMMAND_LINE@

# A self-referential reference to this file.
SPEC:=@SPEC@

Expand Down

1 comment on commit 552d8a2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.