1 #
2 # Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle in the LICENSE file that accompanied this code.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26 ################################################################################
27 # This file handles detection of the Boot JDK. The Boot JDK detection
28 # process has been developed as a response to solve a complex real-world
29 # problem. Initially, it was simple, but it has grown as platform after
30 # platform, idiosyncrasy after idiosyncrasy has been supported.
31 #
32 # The basic idea is this:
33 # 1) You need an acceptable *) JDK to use as a Boot JDK
34 # 2) There are several ways to locate a JDK, that are mostly platform
35 # dependent **)
36 # 3) You can have multiple JDKs installed
37 # 4) If possible, configure should try to dig out an acceptable JDK
38 # automatically, without having to resort to command-line options
39 #
40 # *) acceptable means e.g. JDK7 for building JDK8, a complete JDK (with
41 # javac) and not a JRE, etc.
42 #
43 # **) On Windows we typically use a well-known path.
44 # On MacOSX we typically use the tool java_home.
45 # On Linux we typically find javac in the $PATH, and then follow a
46 # chain of symlinks that often ends up in a real JDK.
47 #
48 # This leads to the code where we check in different ways to locate a
49 # JDK, and if one is found, check if it is acceptable. If not, we print
50 # our reasons for rejecting it (useful when debugging non-working
51 # configure situations) and continue checking the next one.
52 ################################################################################
53
54 # Execute the check given as argument, and verify the result
55 # If the Boot JDK was previously found, do nothing
56 # $1 A command line (typically autoconf macro) to execute
57 AC_DEFUN([BOOTJDK_DO_CHECK],
58 [
59 if test "x$BOOT_JDK_FOUND" = xno; then
60 # Now execute the test
61 $1
62
63 # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
64 if test "x$BOOT_JDK_FOUND" = xmaybe; then
65 # Do we have a bin/java?
66 if test ! -x "$BOOT_JDK/bin/java" && test ! -x "$BOOT_JDK/bin/java.exe"; then
67 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring])
68 BOOT_JDK_FOUND=no
69 else
70 # Do we have a bin/javac?
71 if test ! -x "$BOOT_JDK/bin/javac" && test ! -x "$BOOT_JDK/bin/javac.exe"; then
72 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring])
73 AC_MSG_NOTICE([(This might be an JRE instead of an JDK)])
74 BOOT_JDK_FOUND=no
75 else
76 # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
77 java_to_test="$BOOT_JDK/bin/java"
78 UTIL_FIXUP_EXECUTABLE(java_to_test)
79 BOOT_JDK_VERSION_OUTPUT=`$java_to_test $USER_BOOT_JDK_OPTIONS -version 2>&1`
80 # Additional [] needed to keep m4 from mangling shell constructs.
81 [ BOOT_JDK_VERSION=`echo $BOOT_JDK_VERSION_OUTPUT | $AWK '/version "[0-9a-zA-Z\._\-]+"/ {print $ 0; exit;}'` ]
82
83 if [ [[ "$BOOT_JDK_VERSION" =~ "Picked up" ]] ]; then
84 AC_MSG_NOTICE([You have _JAVA_OPTIONS or JAVA_TOOL_OPTIONS set. This can mess up the build. Please use --with-boot-jdk-jvmargs instead.])
85 AC_MSG_NOTICE([Java reports: "$BOOT_JDK_VERSION".])
86 AC_MSG_ERROR([Cannot continue])
87 fi
88 if [ [[ "$BOOT_JDK_VERSION" =~ "Unrecognized option" ]] ]; then
89 AC_MSG_NOTICE([The specified --with-boot-jdk-jvmargs is invalid for the tested java])
90 AC_MSG_NOTICE([Error message: "$BOOT_JDK_VERSION".])
91 AC_MSG_NOTICE([Please fix arguments, or point to an explicit boot JDK which accept these arguments])
92 AC_MSG_ERROR([Cannot continue])
93 fi
94
95 # Extra M4 quote needed to protect [] in grep expression.
96 [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \
97 | $EGREP "\"(${DEFAULT_ACCEPTABLE_BOOT_VERSIONS// /|})([\.+-].*)?\""`]
98
99 if test "x$BOOT_JDK_VERSION" = x; then
100 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is not a working JDK; ignoring])
101 AC_MSG_NOTICE([Output from java -version was: $BOOT_JDK_VERSION_OUTPUT])
102 BOOT_JDK_FOUND=no
103 elif test "x$FOUND_CORRECT_VERSION" = x; then
104 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring])
105 AC_MSG_NOTICE([(Your Boot JDK version must be one of: $DEFAULT_ACCEPTABLE_BOOT_VERSIONS)])
106 BOOT_JDK_FOUND=no
107 else
108 # We're done! :-)
109 BOOT_JDK_FOUND=yes
110 UTIL_FIXUP_PATH(BOOT_JDK)
111 AC_MSG_CHECKING([for Boot JDK])
112 AC_MSG_RESULT([$BOOT_JDK])
113 AC_MSG_CHECKING([Boot JDK version])
114 BOOT_JDK_VERSION=`$java_to_test $USER_BOOT_JDK_OPTIONS -version 2>&1 | $TR -d '\r'`
115 # This is not a no-op; it will portably convert newline to space
116 BOOT_JDK_VERSION=`$ECHO $BOOT_JDK_VERSION`
117 AC_MSG_RESULT([$BOOT_JDK_VERSION])
118 fi # end check jdk version
119 fi # end check javac
120 fi # end check java
121 fi # end check boot jdk found
122 fi
123 ])
124
125 # Test: Is bootjdk explicitly set by command line arguments?
126 AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS],
127 [
128 if test "x$with_boot_jdk" != x; then
129 BOOT_JDK_ARG="$with_boot_jdk"
130 UTIL_FIXUP_PATH(BOOT_JDK_ARG)
131 if test -d "$BOOT_JDK_ARG"; then
132 BOOT_JDK=$BOOT_JDK_ARG
133 BOOT_JDK_FOUND=maybe
134 elif test -f "$BOOT_JDK_ARG"; then
135 case "$BOOT_JDK_ARG" in
136 *.tar.gz )
137 BOOT_JDK_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/boot-jdk
138 $RM -rf $BOOT_JDK_SUPPORT_DIR
139 $MKDIR -p $BOOT_JDK_SUPPORT_DIR
140 $GUNZIP -c $BOOT_JDK_ARG | $TAR xf - -C $BOOT_JDK_SUPPORT_DIR
141
142 # Try to find javac to determine BOOT_JDK path
143 BOOT_JDK_JAVAC_PATH=`$FIND $BOOT_JDK_SUPPORT_DIR | $GREP "/bin/javac"`
144 if test "x$BOOT_JDK_JAVAC_PATH" != x; then
145 BOOT_JDK_FOUND=maybe
146 BOOT_JDK=$($DIRNAME $($DIRNAME $BOOT_JDK_JAVAC_PATH))
147 else
148 BOOT_JDK_FOUND=no
149 fi
150 ;;
151 * )
152 BOOT_JDK_FOUND=no
153 ;;
154 esac
155 else
156 BOOT_JDK_FOUND=no
157 fi
158 AC_MSG_NOTICE([Found potential Boot JDK using configure arguments])
159 fi
160 ])
161
162 # Test: Is $JAVA_HOME set?
163 AC_DEFUN([BOOTJDK_CHECK_JAVA_HOME],
164 [
165 if test "x$JAVA_HOME" != x; then
166 JAVA_HOME_PROCESSED="$JAVA_HOME"
167 UTIL_FIXUP_PATH(JAVA_HOME_PROCESSED, NOFAIL)
168 if test "x$JAVA_HOME_PROCESSED" = x || test ! -d "$JAVA_HOME_PROCESSED"; then
169 AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!])
170 else
171 # Aha, the user has set a JAVA_HOME
172 # let us use that as the Boot JDK.
173 BOOT_JDK="$JAVA_HOME_PROCESSED"
174 BOOT_JDK_FOUND=maybe
175 AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME])
176 fi
177 fi
178 ])
179
180 # Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
181 AC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK],
182 [
183 UTIL_LOOKUP_PROGS(JAVAC_CHECK, javac)
184 UTIL_GET_EXECUTABLE(JAVAC_CHECK) # Will setup JAVAC_CHECK_EXECUTABLE
185 UTIL_LOOKUP_PROGS(JAVA_CHECK, java)
186 UTIL_GET_EXECUTABLE(JAVA_CHECK) # Will setup JAVA_CHECK_EXECUTABLE
187 BINARY="$JAVAC_CHECK_EXECUTABLE"
188 if test "x$JAVAC_CHECK_EXECUTABLE" = x; then
189 BINARY="$JAVA_CHECK_EXECUTABLE"
190 fi
191 if test "x$BINARY" != x; then
192 # So there is a java(c) binary, it might be part of a JDK.
193 # Lets find the JDK/JRE directory by following symbolic links.
194 # Linux/GNU systems often have links from /usr/bin/java to
195 # /etc/alternatives/java to the real JDK binary.
196 UTIL_REMOVE_SYMBOLIC_LINKS(BINARY)
197 BOOT_JDK=`dirname "$BINARY"`
198 BOOT_JDK=`cd "$BOOT_JDK/.."; pwd`
199 if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then
200 # Looks like we found ourselves an JDK
201 BOOT_JDK_FOUND=maybe
202 AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH])
203 fi
204 fi
205 ])
206
207 # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX)
208 # $1: Argument to the java_home binary (optional)
209 AC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME],
210 [
211 if test -x /usr/libexec/java_home; then
212 BOOT_JDK=`/usr/libexec/java_home $1`
213 BOOT_JDK_FOUND=maybe
214 AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home $1])
215 fi
216 ])
217
218 # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home?
219 AC_DEFUN([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR],
220 [
221 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
222 # First check at user selected default
223 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME()])
224 # If that did not work out (e.g. too old), try explicit versions instead
225 for ver in $DEFAULT_ACCEPTABLE_BOOT_VERSIONS ; do
226 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v $ver])])
227 done
228 fi
229 ])
230
231 # Look for a jdk in the given path. If there are multiple, try to select the newest.
232 # If found, set BOOT_JDK and BOOT_JDK_FOUND.
233 # $1 = Path to directory containing jdk installations.
234 # $2 = String to append to the found JDK directory to get the proper JDK home
235 AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY],
236 [
237 BOOT_JDK_PREFIX="$1"
238 BOOT_JDK_SUFFIX="$2"
239 ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r`
240 if test "x$ALL_JDKS_FOUND" != x; then
241 for JDK_TO_TRY in $ALL_JDKS_FOUND ; do
242 BOOTJDK_DO_CHECK([
243 BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}"
244 if test -d "$BOOT_JDK"; then
245 BOOT_JDK_FOUND=maybe
246 AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)])
247 fi
248 ])
249 done
250 fi
251 ])
252
253 # Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given
254 # environmental variable as base for where to look.
255 # $1 Name of an environmal variable, assumed to point to the Program Files directory.
256 AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY],
257 [
258 if test "x[$]$1" != x; then
259 VIRTUAL_DIR="[$]$1/Java"
260 UTIL_FIXUP_PATH(VIRTUAL_DIR, NOFAIL)
261 if test "x$VIRTUAL_DIR" != x; then
262 BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR)
263 fi
264 fi
265 ])
266
267 # Test: Is there a JDK installed in default, well-known locations?
268 AC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS],
269 [
270 if test "x$OPENJDK_TARGET_OS" = xwindows; then
271 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])])
272 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])])
273 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])])
274 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])])
275 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])])
276 elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
277 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])])
278 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])])
279 elif test "x$OPENJDK_TARGET_OS" = xlinux; then
280 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])])
281 fi
282 ])
283
284 # Check that a command-line tool in the Boot JDK is correct
285 # $1 = name of variable to assign
286 # $2 = name of binary
287 AC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK],
288 [
289 # Use user overridden value if available, otherwise locate tool in the Boot JDK.
290 UTIL_REQUIRE_SPECIAL($1,
291 [
292 AC_MSG_CHECKING([for $2 [[Boot JDK]]])
293 $1=$BOOT_JDK/bin/$2
294 if test ! -x [$]$1 && test ! -x [$]$1.exe; then
295 AC_MSG_RESULT(not found)
296 AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk])
297 AC_MSG_ERROR([Could not find $2 in the Boot JDK])
298 fi
299 AC_MSG_RESULT(\[$]BOOT_JDK/bin/$2)
300 UTIL_FIXUP_EXECUTABLE($1)
301 AC_SUBST($1)
302 ])
303 ])
304
305 # Setup CLASSPATH environment variable
306 AC_DEFUN([BOOTJDK_SETUP_CLASSPATH],
307 [
308 AC_ARG_WITH([classpath], [AS_HELP_STRING([--with-classpath],
309 [Optional classpath to set as CLASSPATH to all Java invocations @<:@none@:>@])])
310
311 if test "x$CLASSPATH" != x; then
312 AC_MSG_WARN([CLASSPATH is set in the environment. This will be ignored. Use --with-classpath instead.])
313 fi
314
315 CLASSPATH=
316
317 if test "x$with_classpath" != x && test "x$with_classpath" != xyes &&
318 test "x$with_classpath" != xno ; then
319 CLASSPATH="$with_classpath"
320 AC_MSG_CHECKING([for classpath to use for all Java invocations])
321 AC_MSG_RESULT([$CLASSPATH])
322 fi
323
324 AC_SUBST(CLASSPATH)
325 ])
326
327 ################################################################################
328 #
329 # We need a Boot JDK to bootstrap the build.
330 #
331
332 AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK],
333 [
334 BOOT_JDK_FOUND=no
335 AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk],
336 [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])])
337
338 AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs],
339 [specify additional arguments to be passed to Boot JDK tools @<:@none@:>@])])
340
341 USER_BOOT_JDK_OPTIONS="$with_boot_jdk_jvmargs"
342
343 # We look for the Boot JDK through various means, going from more certain to
344 # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if
345 # we detected something (if so, the path to the jdk is in BOOT_JDK). But we
346 # must check if this is indeed valid; otherwise we'll continue looking.
347
348 # Test: Is bootjdk explicitly set by command line arguments?
349 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS])
350 if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then
351 # Having specified an argument which is incorrect will produce an instant failure;
352 # we should not go on looking
353 AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK])
354 fi
355
356 # Test: Is $JAVA_HOME set?
357 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME])
358
359 # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home?
360 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR])
361
362 # Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
363 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK])
364
365 # Test: Is there a JDK installed in default, well-known locations?
366 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS])
367
368 # If we haven't found anything yet, we've truly lost. Give up.
369 if test "x$BOOT_JDK_FOUND" = xno; then
370 HELP_MSG_MISSING_DEPENDENCY([openjdk])
371 AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG])
372 AC_MSG_NOTICE([This might be fixed by explicitly setting --with-boot-jdk])
373 AC_MSG_ERROR([Cannot continue])
374 fi
375
376 AC_SUBST(BOOT_JDK)
377
378 # Setup tools from the Boot JDK.
379 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java)
380 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac)
381 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVADOC, javadoc)
382 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar)
383
384 # Finally, set some other options...
385
386 # Determine if the boot jdk jar supports the --date option
387 if $JAR --help 2>&1 | $GREP -q -e "--date=TIMESTAMP"; then
388 BOOT_JDK_JAR_SUPPORTS_DATE=true
389 else
390 BOOT_JDK_JAR_SUPPORTS_DATE=false
391 fi
392 AC_MSG_CHECKING([if Boot JDK jar supports --date=TIMESTAMP])
393 AC_MSG_RESULT([$BOOT_JDK_JAR_SUPPORTS_DATE])
394 AC_SUBST(BOOT_JDK_JAR_SUPPORTS_DATE)
395
396 # When compiling code to be executed by the Boot JDK, force compatibility with the
397 # oldest supported bootjdk.
398 OLDEST_BOOT_JDK_VERSION=`$ECHO $DEFAULT_ACCEPTABLE_BOOT_VERSIONS \
399 | $TR " " "\n" | $SORT -n | $HEAD -n1`
400 AC_SUBST(OLDEST_BOOT_JDK_VERSION)
401
402 # Check if the boot jdk is 32 or 64 bit
403 if $JAVA -version 2>&1 | $GREP -q "64-Bit"; then
404 BOOT_JDK_BITS="64"
405 else
406 BOOT_JDK_BITS="32"
407 fi
408 AC_MSG_CHECKING([if Boot JDK is 32 or 64 bits])
409 AC_MSG_RESULT([$BOOT_JDK_BITS])
410
411 # Try to enable CDS
412 AC_MSG_CHECKING([for local Boot JDK Class Data Sharing (CDS)])
413 BOOT_JDK_CDS_ARCHIVE=$CONFIGURESUPPORT_OUTPUTDIR/classes.jsa
414 UTIL_ADD_JVM_ARG_IF_OK([-XX:+UnlockDiagnosticVMOptions -XX:-VerifySharedSpaces -XX:SharedArchiveFile=$BOOT_JDK_CDS_ARCHIVE],boot_jdk_cds_args,[$JAVA])
415
416 if test "x$boot_jdk_cds_args" != x; then
417 # Try creating a CDS archive
418 $JAVA $boot_jdk_cds_args -Xshare:dump > /dev/null 2>&1
419 if test $? -eq 0; then
420 BOOTJDK_USE_LOCAL_CDS=true
421 AC_MSG_RESULT([yes, created])
422 else
423 # Generation failed, don't use CDS.
424 BOOTJDK_USE_LOCAL_CDS=false
425 AC_MSG_RESULT([no, creation failed])
426 fi
427 else
428 BOOTJDK_USE_LOCAL_CDS=false
429 AC_MSG_RESULT([no, -XX:SharedArchiveFile not supported])
430 fi
431
432 BOOTJDK_SETUP_CLASSPATH
433 ])
434
435 AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
436 [
437 ##############################################################################
438 #
439 # Specify jvm options for anything that is run with the Boot JDK.
440 # Not all JVM:s accept the same arguments on the command line.
441 #
442 AC_MSG_CHECKING([flags for boot jdk java command] )
443
444 # Force en-US environment
445 UTIL_ADD_JVM_ARG_IF_OK([-Duser.language=en -Duser.country=US],boot_jdk_jvmargs,[$JAVA])
446
447 UTIL_ADD_JVM_ARG_IF_OK([-Xlog:all=off:stdout],boot_jdk_jvmargs,[$JAVA])
448 UTIL_ADD_JVM_ARG_IF_OK([-Xlog:all=warning:stderr],boot_jdk_jvmargs,[$JAVA])
449
450 if test "x$BOOTJDK_USE_LOCAL_CDS" = xtrue; then
451 # Use our own CDS archive
452 UTIL_ADD_JVM_ARG_IF_OK([$boot_jdk_cds_args -Xshare:auto],boot_jdk_jvmargs,[$JAVA])
453 else
454 # Otherwise optimistically use the system-wide one, if one is present
455 UTIL_ADD_JVM_ARG_IF_OK([-Xshare:auto],boot_jdk_jvmargs,[$JAVA])
456 fi
457
458 # Finally append user provided options to allow them to override.
459 UTIL_ADD_JVM_ARG_IF_OK([$USER_BOOT_JDK_OPTIONS],boot_jdk_jvmargs,[$JAVA])
460
461 AC_MSG_RESULT([$boot_jdk_jvmargs])
462
463 # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs
464 JAVA_FLAGS=$boot_jdk_jvmargs
465 AC_SUBST(JAVA_FLAGS)
466
467 AC_MSG_CHECKING([flags for boot jdk java command for big workloads])
468
469 # Starting amount of heap memory.
470 UTIL_ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs_big,[$JAVA])
471 BOOTCYCLE_JVM_ARGS_BIG=-Xms64M
472
473 # Maximum amount of heap memory.
474 JVM_HEAP_LIMIT_32="768"
475 # Running a 64 bit JVM allows for and requires a bigger heap
476 JVM_HEAP_LIMIT_64="2048"
477 JVM_HEAP_LIMIT_GLOBAL=`expr $MEMORY_SIZE / 2`
478 if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_32"; then
479 JVM_HEAP_LIMIT_32=$JVM_HEAP_LIMIT_GLOBAL
480 fi
481 if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_64"; then
482 JVM_HEAP_LIMIT_64=$JVM_HEAP_LIMIT_GLOBAL
483 fi
484 if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "512"; then
485 JVM_HEAP_LIMIT_32=512
486 JVM_HEAP_LIMIT_64=512
487 fi
488
489 if test "x$BOOT_JDK_BITS" = "x32"; then
490 JVM_MAX_HEAP=$JVM_HEAP_LIMIT_32
491 else
492 JVM_MAX_HEAP=$JVM_HEAP_LIMIT_64
493 fi
494 UTIL_ADD_JVM_ARG_IF_OK([-Xmx${JVM_MAX_HEAP}M],boot_jdk_jvmargs_big,[$JAVA])
495
496 AC_MSG_RESULT([$boot_jdk_jvmargs_big])
497
498 JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big
499 AC_SUBST(JAVA_FLAGS_BIG)
500
501 if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
502 BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_32
503 else
504 BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_64
505 fi
506 BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -Xmx${BOOTCYCLE_MAX_HEAP}M"
507 AC_MSG_CHECKING([flags for bootcycle boot jdk java command for big workloads])
508 AC_MSG_RESULT([$BOOTCYCLE_JVM_ARGS_BIG])
509 AC_SUBST(BOOTCYCLE_JVM_ARGS_BIG)
510
511 AC_MSG_CHECKING([flags for boot jdk java command for small workloads])
512
513 # Use serial gc for small short lived tools if possible
514 UTIL_ADD_JVM_ARG_IF_OK([-XX:+UseSerialGC],boot_jdk_jvmargs_small,[$JAVA])
515 UTIL_ADD_JVM_ARG_IF_OK([-Xms32M],boot_jdk_jvmargs_small,[$JAVA])
516 UTIL_ADD_JVM_ARG_IF_OK([-Xmx512M],boot_jdk_jvmargs_small,[$JAVA])
517 UTIL_ADD_JVM_ARG_IF_OK([-XX:TieredStopAtLevel=1],boot_jdk_jvmargs_small,[$JAVA])
518
519 AC_MSG_RESULT([$boot_jdk_jvmargs_small])
520
521 JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small
522 AC_SUBST(JAVA_FLAGS_SMALL)
523
524 # Don't presuppose SerialGC is present in the buildjdk. Also, we cannot test
525 # the buildjdk, but on the other hand we know what it will support.
526 BUILD_JAVA_FLAGS_SMALL="-Xms32M -Xmx512M -XX:TieredStopAtLevel=1"
527 AC_SUBST(BUILD_JAVA_FLAGS_SMALL)
528
529 JAVA_TOOL_FLAGS_SMALL=""
530 for f in $JAVA_FLAGS_SMALL; do
531 JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f"
532 done
533 AC_SUBST(JAVA_TOOL_FLAGS_SMALL)
534 ])
535
536 # BUILD_JDK: the location of the latest JDK that can run
537 # on the host system and supports the target class file version
538 # generated in this JDK build. This variable should only be
539 # used after the launchers are built.
540 #
541
542 # Execute the check given as argument, and verify the result.
543 # If the JDK was previously found, do nothing.
544 # $1 A command line (typically autoconf macro) to execute
545 AC_DEFUN([BOOTJDK_CHECK_BUILD_JDK],
546 [
547 if test "x$BUILD_JDK_FOUND" = xno; then
548 # Execute the test
549 $1
550
551 # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
552 if test "x$BUILD_JDK_FOUND" = xmaybe; then
553 # Do we have a bin/java?
554 if test ! -x "$BUILD_JDK/bin/java"; then
555 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/java; ignoring])
556 BUILD_JDK_FOUND=no
557 elif test ! -x "$BUILD_JDK/bin/jlink"; then
558 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jlink; ignoring])
559 BUILD_JDK_FOUND=no
560 elif test ! -x "$BUILD_JDK/bin/jmod"; then
561 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jmod; ignoring])
562 BUILD_JDK_FOUND=no
563 elif test ! -x "$BUILD_JDK/bin/javac"; then
564 # Do we have a bin/javac?
565 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/javac; ignoring])
566 AC_MSG_NOTICE([(This might be a JRE instead of an JDK)])
567 BUILD_JDK_FOUND=no
568 else
569 # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
570 # Additional [] needed to keep m4 from mangling shell constructs.
571 [ BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $AWK '/version "[0-9a-zA-Z\._\-]+"/ {print $ 0; exit;}'` ]
572
573 # Extra M4 quote needed to protect [] in grep expression.
574 [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP "\"$VERSION_FEATURE([\.+-].*)?\""`]
575 if test "x$FOUND_CORRECT_VERSION" = x; then
576 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring])
577 AC_MSG_NOTICE([(Your Build JDK must be version $VERSION_FEATURE)])
578 BUILD_JDK_FOUND=no
579 else
580 # We're done!
581 BUILD_JDK_FOUND=yes
582 UTIL_FIXUP_PATH(BUILD_JDK)
583 AC_MSG_CHECKING([for Build JDK])
584 AC_MSG_RESULT([$BUILD_JDK])
585 AC_MSG_CHECKING([Build JDK version])
586 BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '`
587 AC_MSG_RESULT([$BUILD_JDK_VERSION])
588 fi # end check jdk version
589 fi # end check java
590 fi # end check build jdk found
591 fi
592 ])
593
594 # By default the BUILD_JDK is the JDK_OUTPUTDIR. If the target architecture
595 # is different than the host system doing the build (e.g. cross-compilation),
596 # a special BUILD_JDK is built as part of the build process. An external
597 # prebuilt BUILD_JDK can also be supplied.
598 AC_DEFUN([BOOTJDK_SETUP_BUILD_JDK],
599 [
600 AC_ARG_WITH(build-jdk, [AS_HELP_STRING([--with-build-jdk],
601 [path to JDK of same version as is being built@<:@the newly built JDK@:>@])])
602
603 EXTERNAL_BUILDJDK_PATH=""
604 if test "x$with_build_jdk" != "x"; then
605 BUILD_JDK_FOUND=no
606 BOOTJDK_CHECK_BUILD_JDK([
607 if test "x$with_build_jdk" != x; then
608 BUILD_JDK=$with_build_jdk
609 BUILD_JDK_FOUND=maybe
610 AC_MSG_NOTICE([Found potential Build JDK using configure arguments])
611 fi
612 ])
613 if test "x$BUILD_JDK_FOUND" != "xyes"; then
614 AC_MSG_CHECKING([for Build JDK])
615 AC_MSG_RESULT([no])
616 AC_MSG_ERROR([Could not find a suitable Build JDK])
617 fi
618 EXTERNAL_BUILDJDK_PATH="$BUILD_JDK"
619 fi
620
621 AC_SUBST(EXTERNAL_BUILDJDK_PATH)
622 ])
623
624 # The docs-reference JDK is used to run javadoc for the docs-reference targets.
625 # If not set, the reference docs will be built using the interim javadoc.
626 AC_DEFUN([BOOTJDK_SETUP_DOCS_REFERENCE_JDK],
627 [
628 AC_ARG_WITH(docs-reference-jdk, [AS_HELP_STRING([--with-docs-reference-jdk],
629 [path to JDK to use for building the reference documentation])])
630
631 AC_MSG_CHECKING([for docs-reference JDK])
632 if test "x$with_docs_reference_jdk" != "x"; then
633 DOCS_REFERENCE_JDK="$with_docs_reference_jdk"
634 AC_MSG_RESULT([$DOCS_REFERENCE_JDK])
635 DOCS_REFERENCE_JAVADOC="$DOCS_REFERENCE_JDK/bin/javadoc"
636 if test ! -x "$DOCS_REFERENCE_JAVADOC"; then
637 AC_MSG_ERROR([docs-reference JDK found at $DOCS_REFERENCE_JDK did not contain bin/javadoc])
638 fi
639 UTIL_FIXUP_EXECUTABLE(DOCS_REFERENCE_JAVADOC)
640 else
641 AC_MSG_RESULT([no, using interim javadoc for the docs-reference targets])
642 # By leaving this empty, Docs.gmk will revert to the default interim javadoc
643 DOCS_REFERENCE_JAVADOC=
644 fi
645
646 AC_SUBST(DOCS_REFERENCE_JAVADOC)
647 ])