jdk

Форк
0
/
configure 
382 строки · 12.9 Кб
1
#!/bin/bash
2
#
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.
5
#
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.
9
#
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).
15
#
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.
19
#
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
22
# questions.
23
#
24

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."
28
  exit 1
29
fi
30

31
# The next argument is the absolute top-level directory path.
32
# The TOPDIR variable is passed on to configure.ac.
33
TOPDIR="$2"
34
# Remove these two arguments to get to the user supplied arguments
35
shift
36
shift
37

38
if test "x$BASH" = x; then
39
  echo "Error: This script must be run using bash." 1>&2
40
  exit 1
41
fi
42

43
if [[ "$TOPDIR" =~ .*[[:space:]]+.* ]]; then
44
  echo "Error: Build path containing space character is not supported" 1>&2
45
  exit 1
46
fi
47

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
51

52
# Make sure all shell commands are executed with the C locale
53
export LC_ALL=C
54

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
60
    exit 1
61
  fi
62
fi
63

64
CURRENT_DIR=`pwd`
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"
73
else
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"
77
fi
78

79
conf_script_dir="$TOPDIR/make/autoconf"
80
generated_script="$build_support_dir/generated-configure.sh"
81

82
###
83
### Use autoconf to create a runnable configure script, if needed
84
###
85

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`"
93

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 )"
106
  fi
107

108
  if test "x$PKGHANDLER_COMMAND" != x; then
109
    echo "You might be able to fix this by running '$PKGHANDLER_COMMAND'."
110
  fi
111
}
112

113
generate_configure_script() {
114
  if test "x$AUTOCONF" != x; then
115
    if test ! -x "$AUTOCONF"; then
116
      echo
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
120
      exit 1
121
    fi
122
  else
123
    AUTOCONF="`type -p autoconf 2> /dev/null`"
124
    if test "x$AUTOCONF" = x; then
125
      echo
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
130
      exit 1
131
    fi
132
  fi
133

134
  autoconf_version=`$AUTOCONF --version | head -1`
135
  echo "Using autoconf at ${AUTOCONF} [$autoconf_version]"
136

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"
141
  else
142
    custom_patcher='cat'
143
    custom_script_dir_include=""
144
  fi
145

146
  mkdir -p $build_support_dir
147
  # Call autoconf but replace the "magic" variable in configure.ac if requested.
148

149
  cat $conf_script_dir/configure.ac | eval $custom_patcher | \
150
      ${AUTOCONF} -W all $custom_script_dir_include -I$conf_script_dir - \
151
      > $generated_script
152
  rm -rf autom4te.cache
153

154
  # Sanity check
155
  if test ! -s $generated_script; then
156
    echo "Error: Failed to generate runnable configure script" 1>&2
157
    rm -f $generated_script
158
    exit 1
159
  fi
160
}
161

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"
166
  else
167
    conf_custom_source_files=""
168
  fi
169

170
  for file in $conf_source_files $conf_custom_source_files ; do
171
    if test $file -nt $generated_script; then
172
      return 0
173
    fi
174
  done
175
  return 1
176
}
177

178
run_autoconf=false
179
if test "x$1" = xautogen; then
180
  # User called us as "configure autogen", so force regeneration
181
  run_autoconf=true
182
  shift
183
fi
184

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"
188
  run_autoconf=true
189
else
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"
193
    run_autoconf=true
194
  fi
195
fi
196

197
if test "x$run_autoconf" = xtrue; then
198
  echo "Generating runnable configure script at $generated_script"
199
  generate_configure_script
200
fi
201

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
206
fi
207

208
###
209
### Process command-line arguments
210
###
211

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
219
      quoted="$1"
220
    else
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}}"
227
      fi
228
      quoted="'$1'"
229
    fi
230
    echo "$quoted"
231
  fi
232
}
233

234
conf_processed_arguments=()
235
conf_quoted_arguments=()
236
conf_openjdk_target=
237

238
for conf_option
239
do
240

241
  # Process (and remove) our own extensions that will not be passed to autoconf
242
  case $conf_option in
243
    --openjdk-target=*)
244
      conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
245
      ;;
246
    --debug-configure)
247
      if test "x$conf_debug_configure" != xrecursive; then
248
        conf_debug_configure=true
249
        export conf_debug_configure
250
      fi
251
      ;;
252
    *)
253
      conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option")
254
      ;;
255
  esac
256

257
  # Store all variables overridden on the command line
258
  case $conf_option in
259
    [^-]*=*)
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!"
263
      ;;
264
  esac
265

266
  # Save the arguments, intelligently quoted for CONFIGURE_COMMAND_LINE.
267
  case $conf_option in
268
    *=*)
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")
274
      ;;
275
    *)
276
      conf_quoted_arguments=("${conf_quoted_arguments[@]}" "$(shell_quote "$conf_option")")
277
      ;;
278
  esac
279

280
  # Check for certain autoconf options that require extra action
281
  case $conf_option in
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 ;;
290
  esac
291
done
292

293
# Save the quoted command line
294
CONFIGURE_COMMAND_LINE="${conf_quoted_arguments[@]}"
295

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."
302
    exit 1
303
  else
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."
308
    echo ""
309
  fi
310
fi
311

312
if test "x$conf_openjdk_target" != "x"; then
313
  conf_processed_arguments=("--host=$conf_openjdk_target" "--target=$conf_openjdk_target" "${conf_processed_arguments[@]}")
314

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[@]}")
319
  fi
320
fi
321

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[@]}")
326

327
###
328
### Call the configure script
329
###
330
if test "x$conf_debug_configure" != x; then
331
  # Turn on shell debug output if requested (initial or recursive)
332
  set -x
333
fi
334

335
# Now transfer control to the script generated by autoconf. This is where the
336
# main work is done.
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
343

344
conf_result_code=`cat "$RCDIR/rc"`
345
###
346
### Post-processing
347
###
348

349
if test $conf_result_code -eq 0; then
350
  if test "x$conf_print_help" = xtrue; then
351
    cat <<EOT
352

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
359
                          --build to configure
360
  --debug-configure       Run the configure script with additional debug
361
                          logging enabled.
362

363
EOT
364

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 )
368

369
    cat <<EOT
370

371
Please be aware that, when cross-compiling, the OpenJDK configure script will
372
generally use 'target' where autoconf traditionally uses 'host'.
373

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.
376
EOT
377
  fi
378
else
379
  echo configure exiting with result code $conf_result_code
380
fi
381

382
exit $conf_result_code
383

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.