annotate common/autoconf/boot-jdk.m4 @ 2654:c5e686bd5a48

Back port BSD support from the initial BSD port. Note that generated-configure.sh was auto-generated. This gets the configure step to succeed.
author Greg Lewis <glewis@eyesbeyond.com>
date Sun, 08 Oct 2017 09:41:08 -0700
parents e75618b257d0
children
rev   line source
erikj@457 1 #
ihse@2482 2 # Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
erikj@457 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@457 4 #
erikj@457 5 # This code is free software; you can redistribute it and/or modify it
erikj@457 6 # under the terms of the GNU General Public License version 2 only, as
erikj@457 7 # published by the Free Software Foundation. Oracle designates this
erikj@457 8 # particular file as subject to the "Classpath" exception as provided
erikj@457 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@457 10 #
erikj@457 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@457 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@457 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@457 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@457 15 # accompanied this code).
erikj@457 16 #
erikj@457 17 # You should have received a copy of the GNU General Public License version
erikj@457 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@457 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@457 20 #
erikj@457 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@457 22 # or visit www.oracle.com if you need additional information or have any
erikj@457 23 # questions.
erikj@457 24 #
erikj@457 25
ihse@956 26 ########################################################################
ihse@1236 27 # This file handles detection of the Boot JDK. The Boot JDK detection
ihse@1236 28 # process has been developed as a response to solve a complex real-world
ihse@1236 29 # problem. Initially, it was simple, but it has grown as platform after
ihse@956 30 # platform, idiosyncracy after idiosyncracy has been supported.
ihse@956 31 #
ihse@956 32 # The basic idea is this:
ihse@956 33 # 1) You need an acceptable *) JDK to use as a Boot JDK
ihse@1236 34 # 2) There are several ways to locate a JDK, that are mostly platform
ihse@956 35 # dependent **)
ihse@956 36 # 3) You can have multiple JDKs installed
ihse@1236 37 # 4) If possible, configure should try to dig out an acceptable JDK
ihse@956 38 # automatically, without having to resort to command-line options
ihse@956 39 #
ihse@1236 40 # *) acceptable means e.g. JDK7 for building JDK8, a complete JDK (with
ihse@1236 41 # javac) and not a JRE, etc.
ihse@956 42 #
ihse@1236 43 # **) On Windows we typically use a well-known path.
ihse@956 44 # On MacOSX we typically use the tool java_home.
ihse@1236 45 # On Linux we typically find javac in the $PATH, and then follow a
ihse@1236 46 # chain of symlinks that often ends up in a real JDK.
ihse@956 47 #
ihse@1236 48 # This leads to the code where we check in different ways to locate a
ihse@1236 49 # JDK, and if one is found, check if it is acceptable. If not, we print
ihse@1236 50 # our reasons for rejecting it (useful when debugging non-working
ihse@1236 51 # configure situations) and continue checking the next one.
ihse@956 52 ########################################################################
ihse@956 53
ohair@476 54 # Execute the check given as argument, and verify the result
ohair@476 55 # If the Boot JDK was previously found, do nothing
ohair@476 56 # $1 A command line (typically autoconf macro) to execute
ohair@476 57 AC_DEFUN([BOOTJDK_DO_CHECK],
erikj@457 58 [
ohair@476 59 if test "x$BOOT_JDK_FOUND" = xno; then
ohair@476 60 # Now execute the test
ohair@476 61 $1
ohair@476 62
ohair@476 63 # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
ohair@476 64 if test "x$BOOT_JDK_FOUND" = xmaybe; then
ohair@476 65 # Do we have a bin/java?
ohair@476 66 if test ! -x "$BOOT_JDK/bin/java"; then
ohair@476 67 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring])
ohair@476 68 BOOT_JDK_FOUND=no
ohair@476 69 else
ohair@476 70 # Do we have a bin/javac?
ohair@476 71 if test ! -x "$BOOT_JDK/bin/javac"; then
ohair@476 72 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring])
ohair@476 73 AC_MSG_NOTICE([(This might be an JRE instead of an JDK)])
ohair@476 74 BOOT_JDK_FOUND=no
ihse@837 75 else
erikj@1246 76 # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
erikj@2131 77 BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
erikj@1246 78
erikj@1246 79 # Extra M4 quote needed to protect [] in grep expression.
ihse@1775 80 [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"|(1\.[89]\.)'`]
erikj@1246 81 if test "x$FOUND_CORRECT_VERSION" = x; then
erikj@1246 82 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring])
erikj@1246 83 AC_MSG_NOTICE([(Your Boot JDK must be version 8 or 9)])
ohair@476 84 BOOT_JDK_FOUND=no
ohair@476 85 else
erikj@1246 86 # We're done! :-)
erikj@1246 87 BOOT_JDK_FOUND=yes
erikj@1246 88 BASIC_FIXUP_PATH(BOOT_JDK)
erikj@1246 89 AC_MSG_CHECKING([for Boot JDK])
erikj@1246 90 AC_MSG_RESULT([$BOOT_JDK])
erikj@1246 91 AC_MSG_CHECKING([Boot JDK version])
erikj@1246 92 BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '`
erikj@1246 93 AC_MSG_RESULT([$BOOT_JDK_VERSION])
erikj@1246 94 fi # end check jdk version
ohair@476 95 fi # end check javac
ohair@476 96 fi # end check java
ohair@476 97 fi # end check boot jdk found
ohair@476 98 fi
ohair@476 99 ])
ohair@476 100
ihse@2384 101 # Test: Is bootjdk explicitly set by command line arguments?
ohair@476 102 AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS],
ohair@476 103 [
ihse@837 104 if test "x$with_boot_jdk" != x; then
ohair@476 105 BOOT_JDK=$with_boot_jdk
ohair@476 106 BOOT_JDK_FOUND=maybe
ohair@476 107 AC_MSG_NOTICE([Found potential Boot JDK using configure arguments])
ihse@837 108 fi
ohair@476 109 ])
ohair@476 110
ohair@476 111 # Test: Is $JAVA_HOME set?
ohair@476 112 AC_DEFUN([BOOTJDK_CHECK_JAVA_HOME],
ohair@476 113 [
ihse@837 114 if test "x$JAVA_HOME" != x; then
ihse@837 115 JAVA_HOME_PROCESSED="$JAVA_HOME"
ihse@837 116 BASIC_FIXUP_PATH(JAVA_HOME_PROCESSED)
ihse@837 117 if test ! -d "$JAVA_HOME_PROCESSED"; then
ihse@837 118 AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!])
ihse@837 119 else
ihse@837 120 # Aha, the user has set a JAVA_HOME
ihse@837 121 # let us use that as the Boot JDK.
ihse@837 122 BOOT_JDK="$JAVA_HOME_PROCESSED"
ihse@837 123 BOOT_JDK_FOUND=maybe
ihse@837 124 AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME])
erikj@457 125 fi
ihse@837 126 fi
erikj@457 127 ])
erikj@457 128
ohair@476 129 # Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
ohair@476 130 AC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK],
erikj@457 131 [
ihse@837 132 AC_PATH_PROG(JAVAC_CHECK, javac)
ihse@837 133 AC_PATH_PROG(JAVA_CHECK, java)
ihse@837 134 BINARY="$JAVAC_CHECK"
ihse@837 135 if test "x$JAVAC_CHECK" = x; then
ihse@837 136 BINARY="$JAVA_CHECK"
ihse@837 137 fi
ihse@837 138 if test "x$BINARY" != x; then
ihse@837 139 # So there is a java(c) binary, it might be part of a JDK.
ihse@837 140 # Lets find the JDK/JRE directory by following symbolic links.
ihse@837 141 # Linux/GNU systems often have links from /usr/bin/java to
ihse@837 142 # /etc/alternatives/java to the real JDK binary.
ihse@837 143 BASIC_REMOVE_SYMBOLIC_LINKS(BINARY)
ihse@837 144 BOOT_JDK=`dirname "$BINARY"`
ihse@837 145 BOOT_JDK=`cd "$BOOT_JDK/.."; pwd`
ihse@837 146 if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then
ihse@837 147 # Looks like we found ourselves an JDK
ihse@837 148 BOOT_JDK_FOUND=maybe
ihse@837 149 AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH])
ohair@476 150 fi
ihse@837 151 fi
ohair@476 152 ])
ohair@476 153
ohair@476 154 # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX)
ihse@956 155 # $1: Argument to the java_home binary (optional)
ohair@476 156 AC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME],
ohair@476 157 [
ihse@837 158 if test -x /usr/libexec/java_home; then
ihse@956 159 BOOT_JDK=`/usr/libexec/java_home $1`
ihse@837 160 BOOT_JDK_FOUND=maybe
ihse@956 161 AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home $1])
ihse@956 162 fi
ihse@956 163 ])
ihse@956 164
ihse@956 165 # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home?
ihse@956 166 AC_DEFUN([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR],
ihse@956 167 [
ihse@956 168 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
ihse@956 169 # First check at user selected default
ihse@956 170 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME()])
ihse@956 171 # If that did not work out (e.g. too old), try explicit versions instead
ihse@956 172 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.9])])
ihse@956 173 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.8])])
ihse@956 174 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.7])])
ihse@837 175 fi
ohair@476 176 ])
ohair@476 177
ohair@476 178 # Look for a jdk in the given path. If there are multiple, try to select the newest.
ohair@476 179 # If found, set BOOT_JDK and BOOT_JDK_FOUND.
ohair@476 180 # $1 = Path to directory containing jdk installations.
ohair@476 181 # $2 = String to append to the found JDK directory to get the proper JDK home
ohair@476 182 AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY],
ohair@476 183 [
ohair@476 184 BOOT_JDK_PREFIX="$1"
ohair@476 185 BOOT_JDK_SUFFIX="$2"
ohair@492 186 ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r`
ohair@492 187 if test "x$ALL_JDKS_FOUND" != x; then
ohair@492 188 for JDK_TO_TRY in $ALL_JDKS_FOUND ; do
ohair@492 189 BOOTJDK_DO_CHECK([
ohair@492 190 BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}"
ohair@492 191 if test -d "$BOOT_JDK"; then
ohair@492 192 BOOT_JDK_FOUND=maybe
ohair@492 193 AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)])
ohair@492 194 fi
ohair@492 195 ])
ohair@492 196 done
ohair@476 197 fi
ohair@476 198 ])
ohair@476 199
ohair@476 200 # Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given
ohair@476 201 # environmental variable as base for where to look.
ohair@476 202 # $1 Name of an environmal variable, assumed to point to the Program Files directory.
ohair@476 203 AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY],
ohair@476 204 [
ohair@476 205 if test "x[$]$1" != x; then
ohair@492 206 VIRTUAL_DIR="[$]$1/Java"
ohair@492 207 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VIRTUAL_DIR)
ohair@492 208 BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR)
ohair@476 209 fi
ohair@476 210 ])
ohair@476 211
ohair@476 212 # Test: Is there a JDK installed in default, well-known locations?
ohair@476 213 AC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS],
ohair@476 214 [
ohair@476 215 if test "x$OPENJDK_TARGET_OS" = xwindows; then
ohair@476 216 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])])
ohair@476 217 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])])
ohair@476 218 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])])
ohair@476 219 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])])
ohair@476 220 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])])
ohair@476 221 elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
ohair@476 222 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])])
ohair@476 223 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])])
ohair@492 224 elif test "x$OPENJDK_TARGET_OS" = xlinux; then
ohair@492 225 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])])
glewis@2654 226 elif test "x$OPENJDK_TARGET_OS" = xbsd; then
glewis@2654 227 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/pkg/java])])
glewis@2654 228 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/local])])
ohair@476 229 fi
ohair@476 230 ])
ohair@476 231
ohair@476 232 # Check that a command-line tool in the Boot JDK is correct
ohair@476 233 # $1 = name of variable to assign
ohair@476 234 # $2 = name of binary
ohair@476 235 AC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK],
ohair@476 236 [
ihse@956 237 # Use user overridden value if available, otherwise locate tool in the Boot JDK.
ihse@1236 238 BASIC_SETUP_TOOL($1,
ihse@956 239 [
ihse@956 240 AC_MSG_CHECKING([for $2 in Boot JDK])
ihse@956 241 $1=$BOOT_JDK/bin/$2
ihse@956 242 if test ! -x [$]$1; then
ihse@956 243 AC_MSG_RESULT(not found)
ihse@2384 244 AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk])
ihse@956 245 AC_MSG_ERROR([Could not find $2 in the Boot JDK])
ihse@956 246 fi
ihse@956 247 AC_MSG_RESULT(ok)
ihse@956 248 AC_SUBST($1)
ihse@956 249 ])
erikj@457 250 ])
erikj@457 251
erikj@457 252 ###############################################################################
erikj@457 253 #
ihse@837 254 # We need a Boot JDK to bootstrap the build.
erikj@457 255 #
erikj@457 256
erikj@457 257 AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK],
erikj@457 258 [
ihse@837 259 BOOT_JDK_FOUND=no
ihse@837 260 AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk],
ihse@837 261 [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])])
ohair@476 262
ihse@837 263 # We look for the Boot JDK through various means, going from more certain to
ihse@837 264 # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if
ihse@837 265 # we detected something (if so, the path to the jdk is in BOOT_JDK). But we
ihse@837 266 # must check if this is indeed valid; otherwise we'll continue looking.
ohair@476 267
ihse@2384 268 # Test: Is bootjdk explicitly set by command line arguments?
ihse@837 269 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS])
ihse@837 270 if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then
ihse@837 271 # Having specified an argument which is incorrect will produce an instant failure;
ihse@837 272 # we should not go on looking
ihse@837 273 AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK])
ihse@837 274 fi
erikj@457 275
ihse@956 276 # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home?
ihse@956 277 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR])
ihse@956 278
ihse@837 279 # Test: Is $JAVA_HOME set?
ihse@837 280 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME])
ohair@476 281
ihse@837 282 # Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
ihse@837 283 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK])
ohair@476 284
ihse@837 285 # Test: Is there a JDK installed in default, well-known locations?
ihse@837 286 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS])
ohair@476 287
ihse@837 288 # If we haven't found anything yet, we've truly lost. Give up.
ihse@837 289 if test "x$BOOT_JDK_FOUND" = xno; then
ihse@837 290 HELP_MSG_MISSING_DEPENDENCY([openjdk])
ihse@837 291 AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG])
ihse@2384 292 AC_MSG_NOTICE([This might be fixed by explicitly setting --with-boot-jdk])
ihse@837 293 AC_MSG_ERROR([Cannot continue])
ihse@837 294 fi
ohair@476 295
ihse@837 296 AC_SUBST(BOOT_JDK)
erikj@457 297
ihse@837 298 # Setup tools from the Boot JDK.
ihse@956 299 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java)
ihse@956 300 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac)
ihse@956 301 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH, javah)
ihse@956 302 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar)
ihse@956 303 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JARSIGNER, jarsigner)
erikj@457 304
ihse@837 305 # Finally, set some other options...
erikj@457 306
coffeys@1044 307 # When compiling code to be executed by the Boot JDK, force jdk8 compatibility.
coffeys@1044 308 BOOT_JDK_SOURCETARGET="-source 8 -target 8"
ihse@837 309 AC_SUBST(BOOT_JDK_SOURCETARGET)
alanb@1970 310
alanb@1970 311 AC_MSG_CHECKING([if Boot JDK supports modules])
erikj@2437 312 if "$JAVA" --list-modules > /dev/null 2>&1; then
alanb@1970 313 AC_MSG_RESULT([yes])
alanb@1970 314 BOOT_JDK_MODULAR="true"
alanb@1970 315 else
alanb@1970 316 AC_MSG_RESULT([no])
alanb@1970 317 BOOT_JDK_MODULAR="false"
alanb@1970 318 fi
alanb@1970 319 AC_SUBST(BOOT_JDK_MODULAR)
alanb@1970 320
ihse@837 321 AC_SUBST(JAVAC_FLAGS)
erikj@1682 322
erikj@1682 323 # Check if the boot jdk is 32 or 64 bit
erikj@1682 324 if "$JAVA" -d64 -version > /dev/null 2>&1; then
erikj@1682 325 BOOT_JDK_BITS="64"
erikj@1682 326 else
erikj@1682 327 BOOT_JDK_BITS="32"
erikj@1682 328 fi
erikj@1682 329 AC_MSG_CHECKING([if Boot JDK is 32 or 64 bits])
erikj@1682 330 AC_MSG_RESULT([$BOOT_JDK_BITS])
erikj@457 331 ])
erikj@457 332
erikj@457 333 AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
erikj@457 334 [
ihse@837 335 ##############################################################################
ihse@837 336 #
mduigou@982 337 # Specify jvm options for anything that is run with the Boot JDK.
mduigou@982 338 # Not all JVM:s accept the same arguments on the command line.
ihse@837 339 #
ihse@837 340 AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs],
mduigou@982 341 [specify JVM arguments to be passed to all java invocations of boot JDK, overriding the default values,
ihse@837 342 e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])])
erikj@457 343
mduigou@982 344 AC_MSG_CHECKING([flags for boot jdk java command] )
erikj@457 345
erikj@998 346 # Disable special log output when a debug build is used as Boot JDK...
erikj@998 347 ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA])
erikj@998 348
naoto@2193 349 # Force en-US environment
naoto@2193 350 ADD_JVM_ARG_IF_OK([-Duser.language=en -Duser.country=US],boot_jdk_jvmargs,[$JAVA])
naoto@2193 351
erikj@998 352 # Apply user provided options.
erikj@998 353 ADD_JVM_ARG_IF_OK([$with_boot_jdk_jvmargs],boot_jdk_jvmargs,[$JAVA])
erikj@998 354
erikj@998 355 AC_MSG_RESULT([$boot_jdk_jvmargs])
erikj@998 356
erikj@998 357 # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs
erikj@998 358 JAVA_FLAGS=$boot_jdk_jvmargs
erikj@998 359 AC_SUBST(JAVA_FLAGS)
erikj@998 360
erikj@998 361
erikj@998 362 AC_MSG_CHECKING([flags for boot jdk java command for big workloads])
erikj@998 363
mduigou@982 364 # Starting amount of heap memory.
erikj@998 365 ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs_big,[$JAVA])
erikj@2150 366 BOOTCYCLE_JVM_ARGS_BIG=-Xms64M
mduigou@982 367
erikj@2150 368 # Maximum amount of heap memory and stack size.
erikj@2152 369 JVM_HEAP_LIMIT_32="1024"
erikj@2150 370 # Running a 64 bit JVM allows for and requires a bigger heap
erikj@2150 371 JVM_HEAP_LIMIT_64="1600"
erikj@2150 372 STACK_SIZE_32=768
erikj@2150 373 STACK_SIZE_64=1536
erikj@2150 374 JVM_HEAP_LIMIT_GLOBAL=`expr $MEMORY_SIZE / 2`
erikj@2150 375 if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_32"; then
erikj@2150 376 JVM_HEAP_LIMIT_32=$JVM_HEAP_LIMIT_GLOBAL
erikj@2150 377 fi
erikj@2150 378 if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_64"; then
erikj@2150 379 JVM_HEAP_LIMIT_64=$JVM_HEAP_LIMIT_GLOBAL
erikj@2150 380 fi
erikj@2150 381 if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "512"; then
erikj@2150 382 JVM_HEAP_LIMIT_32=512
erikj@2150 383 JVM_HEAP_LIMIT_64=512
erikj@2150 384 fi
erikj@2150 385
erikj@1682 386 if test "x$BOOT_JDK_BITS" = "x32"; then
erikj@2150 387 STACK_SIZE=$STACK_SIZE_32
erikj@2150 388 JVM_MAX_HEAP=$JVM_HEAP_LIMIT_32
mduigou@982 389 else
erikj@2150 390 STACK_SIZE=$STACK_SIZE_64
erikj@2150 391 JVM_MAX_HEAP=$JVM_HEAP_LIMIT_64
ihse@837 392 fi
erikj@1146 393 ADD_JVM_ARG_IF_OK([-Xmx${JVM_MAX_HEAP}M],boot_jdk_jvmargs_big,[$JAVA])
erikj@998 394 ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs_big,[$JAVA])
mduigou@982 395
erikj@998 396 AC_MSG_RESULT([$boot_jdk_jvmargs_big])
mduigou@982 397
erikj@998 398 JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big
erikj@998 399 AC_SUBST(JAVA_FLAGS_BIG)
mduigou@982 400
erikj@2150 401 if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
erikj@2150 402 BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_32
erikj@2150 403 BOOTCYCLE_STACK_SIZE=$STACK_SIZE_32
erikj@2150 404 else
erikj@2150 405 BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_64
erikj@2150 406 BOOTCYCLE_STACK_SIZE=$STACK_SIZE_64
erikj@2150 407 fi
erikj@2150 408 BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -Xmx${BOOTCYCLE_MAX_HEAP}M"
erikj@2150 409 BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -XX:ThreadStackSize=$BOOTCYCLE_STACK_SIZE"
erikj@2150 410 AC_MSG_CHECKING([flags for bootcycle boot jdk java command for big workloads])
erikj@2150 411 AC_MSG_RESULT([$BOOTCYCLE_JVM_ARGS_BIG])
erikj@2150 412 AC_SUBST(BOOTCYCLE_JVM_ARGS_BIG)
erikj@2150 413
erikj@1789 414 # By default, the main javac compilations use big
erikj@1789 415 JAVA_FLAGS_JAVAC="$JAVA_FLAGS_BIG"
erikj@1789 416 AC_SUBST(JAVA_FLAGS_JAVAC)
mduigou@982 417
erikj@998 418 AC_MSG_CHECKING([flags for boot jdk java command for small workloads])
erikj@457 419
erikj@998 420 # Use serial gc for small short lived tools if possible
erikj@998 421 ADD_JVM_ARG_IF_OK([-XX:+UseSerialGC],boot_jdk_jvmargs_small,[$JAVA])
erikj@998 422 ADD_JVM_ARG_IF_OK([-Xms32M],boot_jdk_jvmargs_small,[$JAVA])
erikj@998 423 ADD_JVM_ARG_IF_OK([-Xmx512M],boot_jdk_jvmargs_small,[$JAVA])
redestad@2064 424 ADD_JVM_ARG_IF_OK([-XX:TieredStopAtLevel=1],boot_jdk_jvmargs_small,[$JAVA])
erikj@998 425
erikj@998 426 AC_MSG_RESULT([$boot_jdk_jvmargs_small])
erikj@998 427
erikj@998 428 JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small
erikj@998 429 AC_SUBST(JAVA_FLAGS_SMALL)
chegar@1120 430
chegar@1120 431 JAVA_TOOL_FLAGS_SMALL=""
chegar@1120 432 for f in $JAVA_FLAGS_SMALL; do
chegar@1120 433 JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f"
chegar@1120 434 done
chegar@1120 435 AC_SUBST(JAVA_TOOL_FLAGS_SMALL)
erikj@457 436 ])
alanb@1970 437
alanb@1970 438 # BUILD_JDK: the location of the latest JDK that can run
alanb@1970 439 # on the host system and supports the target class file version
alanb@1970 440 # generated in this JDK build. This variable should only be
alanb@1970 441 # used after the launchers are built.
alanb@1970 442 #
alanb@1970 443
alanb@1970 444 # Execute the check given as argument, and verify the result.
alanb@1970 445 # If the JDK was previously found, do nothing.
alanb@1970 446 # $1 A command line (typically autoconf macro) to execute
alanb@1970 447 AC_DEFUN([BOOTJDK_CHECK_BUILD_JDK],
alanb@1970 448 [
alanb@1970 449 if test "x$BUILD_JDK_FOUND" = xno; then
alanb@1970 450 # Execute the test
alanb@1970 451 $1
alanb@1970 452
alanb@1970 453 # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
alanb@1970 454 if test "x$BUILD_JDK_FOUND" = xmaybe; then
alanb@1970 455 # Do we have a bin/java?
alanb@1970 456 if test ! -x "$BUILD_JDK/bin/java"; then
alanb@1970 457 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/java; ignoring])
alanb@1970 458 BUILD_JDK_FOUND=no
alanb@1970 459 elif test ! -x "$BUILD_JDK/bin/jlink"; then
alanb@1970 460 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jlink; ignoring])
alanb@1970 461 BUILD_JDK_FOUND=no
erikj@2074 462 elif test ! -x "$BUILD_JDK/bin/jmod"; then
erikj@2074 463 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jmod; ignoring])
erikj@2074 464 BUILD_JDK_FOUND=no
alanb@1970 465 elif test ! -x "$BUILD_JDK/bin/javac"; then
alanb@1970 466 # Do we have a bin/javac?
alanb@1970 467 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/javac; ignoring])
alanb@1970 468 AC_MSG_NOTICE([(This might be a JRE instead of an JDK)])
alanb@1970 469 BUILD_JDK_FOUND=no
alanb@1970 470 else
alanb@1970 471 # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
erikj@2131 472 BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
alanb@1970 473
alanb@1970 474 # Extra M4 quote needed to protect [] in grep expression.
erikj@2011 475 [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"'`]
alanb@1970 476 if test "x$FOUND_CORRECT_VERSION" = x; then
erikj@2011 477 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring])
alanb@1970 478 AC_MSG_NOTICE([(Your Build JDK must be version 9)])
alanb@1970 479 BUILD_JDK_FOUND=no
alanb@1970 480 else
alanb@1970 481 # We're done!
alanb@1970 482 BUILD_JDK_FOUND=yes
alanb@1970 483 BASIC_FIXUP_PATH(BUILD_JDK)
alanb@1970 484 AC_MSG_CHECKING([for Build JDK])
alanb@1970 485 AC_MSG_RESULT([$BUILD_JDK])
alanb@1970 486 AC_MSG_CHECKING([Build JDK version])
alanb@1970 487 BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '`
alanb@1970 488 AC_MSG_RESULT([$BUILD_JDK_VERSION])
alanb@1970 489 fi # end check jdk version
alanb@1970 490 fi # end check java
alanb@1970 491 fi # end check build jdk found
alanb@1970 492 fi
alanb@1970 493 ])
alanb@1970 494
alanb@1970 495 # By default the BUILD_JDK is the JDK_OUTPUTDIR. If the target architecture
alanb@1970 496 # is different than the host system doing the build (e.g. cross-compilation),
alanb@1970 497 # a special BUILD_JDK is built as part of the build process. An external
alanb@1970 498 # prebuilt BUILD_JDK can also be supplied.
alanb@1970 499 AC_DEFUN([BOOTJDK_SETUP_BUILD_JDK],
alanb@1970 500 [
alanb@1970 501 AC_ARG_WITH(build-jdk, [AS_HELP_STRING([--with-build-jdk],
alanb@1970 502 [path to JDK of same version as is being built@<:@the newly built JDK@:>@])])
alanb@1970 503
redestad@2073 504 CREATE_BUILDJDK=false
redestad@2073 505 EXTERNAL_BUILDJDK=false
alanb@1970 506 BUILD_JDK_FOUND="no"
alanb@1970 507 if test "x$with_build_jdk" != "x"; then
alanb@1970 508 BOOTJDK_CHECK_BUILD_JDK([
alanb@1970 509 if test "x$with_build_jdk" != x; then
alanb@1970 510 BUILD_JDK=$with_build_jdk
alanb@1970 511 BUILD_JDK_FOUND=maybe
alanb@1970 512 AC_MSG_NOTICE([Found potential Build JDK using configure arguments])
alanb@1970 513 fi])
redestad@2073 514 EXTERNAL_BUILDJDK=true
alanb@1970 515 else
alanb@1970 516 if test "x$COMPILE_TYPE" = "xcross"; then
alanb@1970 517 BUILD_JDK="\$(BUILDJDK_OUTPUTDIR)/jdk"
alanb@1970 518 BUILD_JDK_FOUND=yes
alanb@1970 519 CREATE_BUILDJDK=true
alanb@1970 520 AC_MSG_CHECKING([for Build JDK])
alanb@1970 521 AC_MSG_RESULT([yes, will build it for the host platform])
alanb@1970 522 else
alanb@1970 523 BUILD_JDK="\$(JDK_OUTPUTDIR)"
alanb@1970 524 BUILD_JDK_FOUND=yes
alanb@1970 525 AC_MSG_CHECKING([for Build JDK])
alanb@1970 526 AC_MSG_RESULT([yes, will use output dir])
alanb@1970 527 fi
alanb@1970 528 fi
alanb@1970 529
erikj@2074 530 JMOD="$BUILD_JDK/bin/jmod"
erikj@2074 531 JLINK="$BUILD_JDK/bin/jlink"
erikj@2074 532 AC_SUBST(JMOD)
erikj@2074 533 AC_SUBST(JLINK)
erikj@2074 534
alanb@1970 535 if test "x$BUILD_JDK_FOUND" != "xyes"; then
alanb@1970 536 AC_MSG_CHECKING([for Build JDK])
alanb@1970 537 AC_MSG_RESULT([no])
alanb@1970 538 AC_MSG_ERROR([Could not find a suitable Build JDK])
alanb@1970 539 fi
alanb@1970 540
alanb@1970 541 AC_SUBST(CREATE_BUILDJDK)
alanb@1970 542 AC_SUBST(BUILD_JDK)
redestad@2073 543 AC_SUBST(EXTERNAL_BUILDJDK)
alanb@1970 544 ])