3
# Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
4
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
# This code is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License version 2 only, as
8
# published by the Free Software Foundation.
10
# This code is distributed in the hope that it will be useful, but WITHOUT
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
# version 2 for more details (a copy is included in the LICENSE file that
14
# accompanied this code).
16
# You should have received a copy of the GNU General Public License version
17
# 2 along with this work; if not, write to the Free Software Foundation,
18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
# or visit www.oracle.com if you need additional information or have any
25
if test "x$1" != xCHECKME; then
26
echo "ERROR: Calling this wrapper script directly is not supported."
27
echo "Use the 'configure' script in the top-level directory instead."
31
# The next argument is the absolute top-level directory path.
32
# The TOPDIR variable is passed on to configure.ac.
34
# Remove these two arguments to get to the user supplied arguments
38
if test "x$BASH" = x; then
39
echo "Error: This script must be run using bash." 1>&2
43
if [[ "$TOPDIR" =~ .*[[:space:]]+.* ]]; then
44
echo "Error: Build path containing space character is not supported" 1>&2
48
# Force autoconf to use bash. This also means we must disable autoconf re-exec.
49
export CONFIG_SHELL=$BASH
50
export _as_can_reexec=no
52
# Make sure all shell commands are executed with the C locale
55
if test "x$CUSTOM_CONFIG_DIR" != x; then
56
custom_hook=$CUSTOM_CONFIG_DIR/custom-hook.m4
57
if test ! -e $custom_hook; then
58
echo "CUSTOM_CONFIG_DIR ($CUSTOM_CONFIG_DIR) not pointing to a proper custom config dir."
59
echo "Error: Cannot continue" 1>&2
65
if test "x$CURRENT_DIR" = "x$TOPDIR"; then
66
# We are running configure from the src root.
67
# Create '.configure-support' under $TOPDIR/build
68
build_support_dir="$TOPDIR/build/.configure-support"
69
elif test "x$CURRENT_DIR" = "x$CUSTOM_ROOT"; then
70
# We are running configure from the custom root.
71
# Create '.configure-support' under $CUSTOM_ROOT/build
72
build_support_dir="$CUSTOM_ROOT/build/.configure-support"
74
# We are running configure from outside of the src dir.
75
# Create 'build_support_dir' in the current directory.
76
build_support_dir="$CURRENT_DIR/configure-support"
79
conf_script_dir="$TOPDIR/make/autoconf"
80
generated_script="$build_support_dir/generated-configure.sh"
83
### Use autoconf to create a runnable configure script, if needed
86
autoconf_missing_help() {
87
APT_GET="`type -p apt-get 2> /dev/null`"
88
YUM="`type -p yum 2> /dev/null`"
89
BREW="`type -p brew 2> /dev/null`"
90
ZYPPER="`type -p zypper 2> /dev/null`"
91
CYGWIN="`type -p cygpath 2> /dev/null`"
92
UNAMEOUT="`uname 2> /dev/null`"
94
if test "x$ZYPPER" != x; then
95
PKGHANDLER_COMMAND="sudo zypper install autoconf"
96
elif test "x$APT_GET" != x; then
97
PKGHANDLER_COMMAND="sudo apt-get install autoconf"
98
elif test "x$YUM" != x; then
99
PKGHANDLER_COMMAND="sudo yum install autoconf"
100
elif test "x$BREW" != x; then
101
PKGHANDLER_COMMAND="brew install autoconf"
102
elif test "x$UNAMEOUT" == xAIX; then
103
echo "You might be able to fix this by installing autoconf from the 'AIX Toolbox for Linux Applications' (or compile it from the sources)."
104
elif test "x$CYGWIN" != x; then
105
PKGHANDLER_COMMAND="( cd <location of cygwin setup.exe> && cmd /c setup -q -P autoconf )"
108
if test "x$PKGHANDLER_COMMAND" != x; then
109
echo "You might be able to fix this by running '$PKGHANDLER_COMMAND'."
113
generate_configure_script() {
114
if test "x$AUTOCONF" != x; then
115
if test ! -x "$AUTOCONF"; then
117
echo "The specified AUTOCONF variable does not point to a valid autoconf executable:"
118
echo "AUTOCONF=$AUTOCONF"
119
echo "Error: Cannot continue" 1>&2
123
AUTOCONF="`type -p autoconf 2> /dev/null`"
124
if test "x$AUTOCONF" = x; then
126
echo "Autoconf is not found on the PATH ($PATH), and AUTOCONF is not set."
127
echo "You need autoconf to be able to generate a runnable configure script."
128
autoconf_missing_help
129
echo "Error: Cannot find autoconf" 1>&2
134
autoconf_version=`$AUTOCONF --version | head -1`
135
echo "Using autoconf at ${AUTOCONF} [$autoconf_version]"
137
if test "x$CUSTOM_CONFIG_DIR" != x; then
138
# Generate configure script with custom hooks compiled in.
139
custom_patcher='sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
140
custom_script_dir_include="-I$CUSTOM_CONFIG_DIR"
143
custom_script_dir_include=""
146
mkdir -p $build_support_dir
147
# Call autoconf but replace the "magic" variable in configure.ac if requested.
149
cat $conf_script_dir/configure.ac | eval $custom_patcher | \
150
${AUTOCONF} -W all $custom_script_dir_include -I$conf_script_dir - \
152
rm -rf autom4te.cache
155
if test ! -s $generated_script; then
156
echo "Error: Failed to generate runnable configure script" 1>&2
157
rm -f $generated_script
162
test_generated_up_to_date() {
163
conf_source_files="$conf_script_dir/configure.ac $conf_script_dir/*.m4"
164
if test "x$CUSTOM_CONFIG_DIR" != x; then
165
conf_custom_source_files="$CUSTOM_CONFIG_DIR/*.m4"
167
conf_custom_source_files=""
170
for file in $conf_source_files $conf_custom_source_files ; do
171
if test $file -nt $generated_script; then
179
if test "x$1" = xautogen; then
180
# User called us as "configure autogen", so force regeneration
185
if test ! -s $generated_script; then
186
# Generated script is missing, so we need to create it
187
echo "Runnable configure script is not present"
190
# File is present, but is it up to date?
191
if test_generated_up_to_date; then
192
echo "Runnable configure script is not up to date"
197
if test "x$run_autoconf" = xtrue; then
198
echo "Generating runnable configure script at $generated_script"
199
generate_configure_script
202
# Autoconf calls the configure script recursively sometimes.
203
# Don't start logging twice in that case
204
if test "x$conf_debug_configure" = xtrue; then
205
conf_debug_configure=recursive
209
### Process command-line arguments
212
# Returns a shell-escaped version of the argument given.
213
function shell_quote() {
214
if [[ -n "$1" ]]; then
215
# Uses only shell-safe characters? No quoting needed.
216
# '=' is a zsh meta-character, but only in word-initial position.
217
if echo "$1" | grep '^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\.:,%/+=_-]\{1,\}$' > /dev/null \
218
&& ! echo "$1" | grep '^=' > /dev/null; then
221
if echo "$1" | grep "[\'!]" > /dev/null; then
222
# csh does history expansion within single quotes, but not
223
# when backslash-escaped!
224
local quoted_quote="'\\''" quoted_exclam="'\\!'"
225
word="${1//\'/${quoted_quote}}"
226
word="${1//\!/${quoted_exclam}}"
234
conf_processed_arguments=()
235
conf_quoted_arguments=()
241
# Process (and remove) our own extensions that will not be passed to autoconf
244
conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
247
if test "x$conf_debug_configure" != xrecursive; then
248
conf_debug_configure=true
249
export conf_debug_configure
253
conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option")
257
# Store all variables overridden on the command line
260
# Add name of variable to CONFIGURE_OVERRIDDEN_VARIABLES list inside !...!.
261
conf_env_var=`expr "x$conf_option" : 'x\([^=]*\)='`
262
CONFIGURE_OVERRIDDEN_VARIABLES="$CONFIGURE_OVERRIDDEN_VARIABLES!$conf_env_var!"
266
# Save the arguments, intelligently quoted for CONFIGURE_COMMAND_LINE.
269
conf_option_name=`expr "x$conf_option" : 'x\([^=]*\)='`
270
conf_option_name=$(shell_quote "$conf_option_name")
271
conf_option_value=`expr "x$conf_option" : 'x[^=]*=\(.*\)'`
272
conf_option_value=$(shell_quote "$conf_option_value")
273
conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$conf_option_name=$conf_option_value")
276
conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")")
280
# Check for certain autoconf options that require extra action
282
-build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
283
conf_build_set=true ;;
284
-target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
285
conf_incompatible_crosscompile="$conf_incompatible_crosscompile $conf_option" ;;
286
-host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*)
287
conf_incompatible_crosscompile="$conf_incompatible_crosscompile $conf_option" ;;
288
-help | --help | --hel | --he | -h)
289
conf_print_help=true ;;
293
# Save the quoted command line
294
CONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}"
296
if test "x$conf_incompatible_crosscompile" != "x"; then
297
if test "x$conf_openjdk_target" != "x"; then
298
echo "Error: --openjdk-target was specified together with"
299
echo "incompatible autoconf cross-compilation flags."
300
echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_incompatible_crosscompile."
301
echo "It is recommended that you only use --openjdk-target."
304
echo "Warning: You are using misleading autoconf cross-compilation flag(s)."
305
echo "This is not encouraged as use of such flags during building can"
306
echo "quickly become confusing."
307
echo "It is highly recommended that you use --openjdk-target instead."
312
if test "x$conf_openjdk_target" != "x"; then
313
conf_processed_arguments=("--host=$conf_openjdk_target" "--target=$conf_openjdk_target" "${conf_processed_arguments[@]}")
315
# If --build has been explicitly set don't override that flag with our own
316
if test "x$conf_build_set" != xtrue; then
317
conf_build_platform=`sh $conf_script_dir/build-aux/config.guess`
318
conf_processed_arguments=("--build=$conf_build_platform" "${conf_processed_arguments[@]}")
322
# Make configure exit with error on invalid options as default.
323
# Can be overridden by --disable-option-checking, since we prepend our argument
324
# and later options override earlier.
325
conf_processed_arguments=("--enable-option-checking=fatal" "${conf_processed_arguments[@]}")
328
### Call the configure script
330
if test "x$conf_debug_configure" != x; then
331
# Turn on shell debug output if requested (initial or recursive)
335
# Now transfer control to the script generated by autoconf. This is where the
337
RCDIR=`mktemp -dt jdk-build-configure.tmp.XXXXXX` || exit $?
338
trap "rm -rf \"$RCDIR\"" EXIT
339
conf_logfile=./configure.log
340
(exec 3>&1 ; ((. $generated_script "${conf_processed_arguments[@]}" 2>&1 1>&3 ) \
341
; echo $? > "$RCDIR/rc" ) \
342
| tee -a $conf_logfile 1>&2 ; exec 3>&-) | tee -a $conf_logfile
344
conf_result_code=`cat "$RCDIR/rc"`
349
if test $conf_result_code -eq 0; then
350
if test "x$conf_print_help" = xtrue; then
353
Additional (non-autoconf) OpenJDK Options:
354
--openjdk-target=TARGET cross-compile with TARGET as target platform
355
(i.e. the one you will run the resulting binary on).
356
Equivalent to --host=TARGET --target=TARGET
357
--build=<current platform>, or the platform you
358
have provided if you have explicitly passed
360
--debug-configure Run the configure script with additional debug
365
# Print additional help, e.g. a list of toolchains and JVM features.
366
# This must be done by the autoconf script.
367
( CONFIGURE_PRINT_ADDITIONAL_HELP=true . $generated_script PRINTF=printf )
371
Please be aware that, when cross-compiling, the OpenJDK configure script will
372
generally use 'target' where autoconf traditionally uses 'host'.
374
Also note that variables must be passed on the command line. Variables in the
375
environment will generally be ignored, unlike traditional autoconf scripts.
379
echo configure exiting with result code $conf_result_code
382
exit $conf_result_code