boot-jdk.m4 revision 2126:31261e7238af
1296465Sdelphij# 2296465Sdelphij# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. 3296465Sdelphij# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4296465Sdelphij# 5296465Sdelphij# This code is free software; you can redistribute it and/or modify it 6296465Sdelphij# under the terms of the GNU General Public License version 2 only, as 7296465Sdelphij# published by the Free Software Foundation. Oracle designates this 8296465Sdelphij# particular file as subject to the "Classpath" exception as provided 9296465Sdelphij# by Oracle in the LICENSE file that accompanied this code. 10296465Sdelphij# 11296465Sdelphij# This code is distributed in the hope that it will be useful, but WITHOUT 12296465Sdelphij# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13296465Sdelphij# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14296465Sdelphij# version 2 for more details (a copy is included in the LICENSE file that 15296465Sdelphij# accompanied this code). 16296465Sdelphij# 17296465Sdelphij# You should have received a copy of the GNU General Public License version 18296465Sdelphij# 2 along with this work; if not, write to the Free Software Foundation, 19296465Sdelphij# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20296465Sdelphij# 21296465Sdelphij# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22296465Sdelphij# or visit www.oracle.com if you need additional information or have any 23296465Sdelphij# questions. 24296465Sdelphij# 25296465Sdelphij 26296465Sdelphij######################################################################## 27296465Sdelphij# This file handles detection of the Boot JDK. The Boot JDK detection 28296465Sdelphij# process has been developed as a response to solve a complex real-world 29296465Sdelphij# problem. Initially, it was simple, but it has grown as platform after 30296465Sdelphij# platform, idiosyncracy after idiosyncracy has been supported. 31296465Sdelphij# 32296465Sdelphij# The basic idea is this: 33296465Sdelphij# 1) You need an acceptable *) JDK to use as a Boot JDK 34296465Sdelphij# 2) There are several ways to locate a JDK, that are mostly platform 35296465Sdelphij# dependent **) 36296465Sdelphij# 3) You can have multiple JDKs installed 37296465Sdelphij# 4) If possible, configure should try to dig out an acceptable JDK 38296465Sdelphij# automatically, without having to resort to command-line options 39296465Sdelphij# 40296465Sdelphij# *) acceptable means e.g. JDK7 for building JDK8, a complete JDK (with 41296465Sdelphij# javac) and not a JRE, etc. 42296465Sdelphij# 43296465Sdelphij# **) On Windows we typically use a well-known path. 44296465Sdelphij# On MacOSX we typically use the tool java_home. 45296465Sdelphij# On Linux we typically find javac in the $PATH, and then follow a 46296465Sdelphij# chain of symlinks that often ends up in a real JDK. 47296465Sdelphij# 48296465Sdelphij# This leads to the code where we check in different ways to locate a 49296465Sdelphij# JDK, and if one is found, check if it is acceptable. If not, we print 50296465Sdelphij# our reasons for rejecting it (useful when debugging non-working 51296465Sdelphij# configure situations) and continue checking the next one. 52296465Sdelphij######################################################################## 53296465Sdelphij 54296465Sdelphij# Execute the check given as argument, and verify the result 55296465Sdelphij# If the Boot JDK was previously found, do nothing 56296465Sdelphij# $1 A command line (typically autoconf macro) to execute 57296465SdelphijAC_DEFUN([BOOTJDK_DO_CHECK], 58296465Sdelphij[ 59296465Sdelphij if test "x$BOOT_JDK_FOUND" = xno; then 60296465Sdelphij # Now execute the test 61296465Sdelphij $1 62296465Sdelphij 63296465Sdelphij # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 64296465Sdelphij if test "x$BOOT_JDK_FOUND" = xmaybe; then 65296465Sdelphij # Do we have a bin/java? 66296465Sdelphij if test ! -x "$BOOT_JDK/bin/java"; then 67296465Sdelphij AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring]) 68296465Sdelphij BOOT_JDK_FOUND=no 69296465Sdelphij else 70296465Sdelphij # Do we have a bin/javac? 71296465Sdelphij if test ! -x "$BOOT_JDK/bin/javac"; then 72296465Sdelphij AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring]) 73296465Sdelphij AC_MSG_NOTICE([(This might be an JRE instead of an JDK)]) 74296465Sdelphij BOOT_JDK_FOUND=no 75296465Sdelphij else 76296465Sdelphij # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 77296465Sdelphij BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1` 78296465Sdelphij 79296465Sdelphij # Extra M4 quote needed to protect [] in grep expression. 80296465Sdelphij [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"|(1\.[89]\.)'`] 81296465Sdelphij if test "x$FOUND_CORRECT_VERSION" = x; then 82296465Sdelphij AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring]) 83296465Sdelphij AC_MSG_NOTICE([(Your Boot JDK must be version 8 or 9)]) 84296465Sdelphij BOOT_JDK_FOUND=no 85296465Sdelphij else 86296465Sdelphij # We're done! :-) 87296465Sdelphij BOOT_JDK_FOUND=yes 88296465Sdelphij BASIC_FIXUP_PATH(BOOT_JDK) 89296465Sdelphij AC_MSG_CHECKING([for Boot JDK]) 90296465Sdelphij AC_MSG_RESULT([$BOOT_JDK]) 91296465Sdelphij AC_MSG_CHECKING([Boot JDK version]) 92296465Sdelphij BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` 93296465Sdelphij AC_MSG_RESULT([$BOOT_JDK_VERSION]) 94296465Sdelphij fi # end check jdk version 95296465Sdelphij fi # end check javac 96296465Sdelphij fi # end check java 97296465Sdelphij fi # end check boot jdk found 98296465Sdelphij fi 99296465Sdelphij]) 100296465Sdelphij 101296465Sdelphij# Test: Is bootjdk explicitely set by command line arguments? 102296465SdelphijAC_DEFUN([BOOTJDK_CHECK_ARGUMENTS], 103296465Sdelphij[ 104296465Sdelphij if test "x$with_boot_jdk" != x; then 105296465Sdelphij BOOT_JDK=$with_boot_jdk 106296465Sdelphij BOOT_JDK_FOUND=maybe 107296465Sdelphij AC_MSG_NOTICE([Found potential Boot JDK using configure arguments]) 108296465Sdelphij fi 109296465Sdelphij]) 110296465Sdelphij 111296465Sdelphij# Test: Is $JAVA_HOME set? 112296465SdelphijAC_DEFUN([BOOTJDK_CHECK_JAVA_HOME], 113296465Sdelphij[ 114296465Sdelphij if test "x$JAVA_HOME" != x; then 115296465Sdelphij JAVA_HOME_PROCESSED="$JAVA_HOME" 116296465Sdelphij BASIC_FIXUP_PATH(JAVA_HOME_PROCESSED) 117296465Sdelphij if test ! -d "$JAVA_HOME_PROCESSED"; then 118296465Sdelphij AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!]) 119296465Sdelphij else 120296465Sdelphij # Aha, the user has set a JAVA_HOME 121296465Sdelphij # let us use that as the Boot JDK. 122296465Sdelphij BOOT_JDK="$JAVA_HOME_PROCESSED" 123296465Sdelphij BOOT_JDK_FOUND=maybe 124296465Sdelphij AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME]) 125296465Sdelphij fi 126296465Sdelphij fi 127296465Sdelphij]) 128296465Sdelphij 129296465Sdelphij# Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 130296465SdelphijAC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK], 131296465Sdelphij[ 132296465Sdelphij AC_PATH_PROG(JAVAC_CHECK, javac) 133296465Sdelphij AC_PATH_PROG(JAVA_CHECK, java) 134296465Sdelphij BINARY="$JAVAC_CHECK" 135296465Sdelphij if test "x$JAVAC_CHECK" = x; then 136296465Sdelphij BINARY="$JAVA_CHECK" 137296465Sdelphij fi 138296465Sdelphij if test "x$BINARY" != x; then 139296465Sdelphij # So there is a java(c) binary, it might be part of a JDK. 140296465Sdelphij # Lets find the JDK/JRE directory by following symbolic links. 141296465Sdelphij # Linux/GNU systems often have links from /usr/bin/java to 142296465Sdelphij # /etc/alternatives/java to the real JDK binary. 143296465Sdelphij BASIC_REMOVE_SYMBOLIC_LINKS(BINARY) 144296465Sdelphij BOOT_JDK=`dirname "$BINARY"` 145296465Sdelphij BOOT_JDK=`cd "$BOOT_JDK/.."; pwd` 146296465Sdelphij if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then 147296465Sdelphij # Looks like we found ourselves an JDK 148296465Sdelphij BOOT_JDK_FOUND=maybe 149296465Sdelphij AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH]) 150296465Sdelphij fi 151296465Sdelphij fi 152296465Sdelphij]) 153296465Sdelphij 154296465Sdelphij# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 155296465Sdelphij# $1: Argument to the java_home binary (optional) 156296465SdelphijAC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME], 157296465Sdelphij[ 158296465Sdelphij if test -x /usr/libexec/java_home; then 159296465Sdelphij BOOT_JDK=`/usr/libexec/java_home $1` 160296465Sdelphij BOOT_JDK_FOUND=maybe 161296465Sdelphij AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home $1]) 162296465Sdelphij fi 163296465Sdelphij]) 164296465Sdelphij 165296465Sdelphij# Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? 166296465SdelphijAC_DEFUN([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR], 167296465Sdelphij[ 168296465Sdelphij if test "x$OPENJDK_TARGET_OS" = xmacosx; then 169296465Sdelphij # First check at user selected default 170296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME()]) 171296465Sdelphij # If that did not work out (e.g. too old), try explicit versions instead 172296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.9])]) 173296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.8])]) 174296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.7])]) 175296465Sdelphij fi 176296465Sdelphij]) 177296465Sdelphij 178296465Sdelphij# Look for a jdk in the given path. If there are multiple, try to select the newest. 179296465Sdelphij# If found, set BOOT_JDK and BOOT_JDK_FOUND. 180296465Sdelphij# $1 = Path to directory containing jdk installations. 181296465Sdelphij# $2 = String to append to the found JDK directory to get the proper JDK home 182296465SdelphijAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY], 183296465Sdelphij[ 184296465Sdelphij BOOT_JDK_PREFIX="$1" 185296465Sdelphij BOOT_JDK_SUFFIX="$2" 186296465Sdelphij ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r` 187296465Sdelphij if test "x$ALL_JDKS_FOUND" != x; then 188296465Sdelphij for JDK_TO_TRY in $ALL_JDKS_FOUND ; do 189296465Sdelphij BOOTJDK_DO_CHECK([ 190296465Sdelphij BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" 191296465Sdelphij if test -d "$BOOT_JDK"; then 192296465Sdelphij BOOT_JDK_FOUND=maybe 193296465Sdelphij AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)]) 194296465Sdelphij fi 195296465Sdelphij ]) 196296465Sdelphij done 197296465Sdelphij fi 198296465Sdelphij]) 199296465Sdelphij 200296465Sdelphij# Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given 201296465Sdelphij# environmental variable as base for where to look. 202296465Sdelphij# $1 Name of an environmal variable, assumed to point to the Program Files directory. 203296465SdelphijAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY], 204296465Sdelphij[ 205296465Sdelphij if test "x[$]$1" != x; then 206296465Sdelphij VIRTUAL_DIR="[$]$1/Java" 207296465Sdelphij BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VIRTUAL_DIR) 208296465Sdelphij BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR) 209296465Sdelphij fi 210296465Sdelphij]) 211296465Sdelphij 212296465Sdelphij# Test: Is there a JDK installed in default, well-known locations? 213296465SdelphijAC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS], 214296465Sdelphij[ 215296465Sdelphij if test "x$OPENJDK_TARGET_OS" = xwindows; then 216296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])]) 217296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])]) 218296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])]) 219296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])]) 220296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])]) 221296465Sdelphij elif test "x$OPENJDK_TARGET_OS" = xmacosx; then 222296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 223296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 224296465Sdelphij elif test "x$OPENJDK_TARGET_OS" = xlinux; then 225296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])]) 226296465Sdelphij fi 227296465Sdelphij]) 228296465Sdelphij 229296465Sdelphij# Check that a command-line tool in the Boot JDK is correct 230296465Sdelphij# $1 = name of variable to assign 231296465Sdelphij# $2 = name of binary 232296465SdelphijAC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], 233296465Sdelphij[ 234296465Sdelphij # Use user overridden value if available, otherwise locate tool in the Boot JDK. 235296465Sdelphij BASIC_SETUP_TOOL($1, 236296465Sdelphij [ 237296465Sdelphij AC_MSG_CHECKING([for $2 in Boot JDK]) 238296465Sdelphij $1=$BOOT_JDK/bin/$2 239296465Sdelphij if test ! -x [$]$1; then 240296465Sdelphij AC_MSG_RESULT(not found) 241296465Sdelphij AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk]) 242296465Sdelphij AC_MSG_ERROR([Could not find $2 in the Boot JDK]) 243296465Sdelphij fi 244296465Sdelphij AC_MSG_RESULT(ok) 245296465Sdelphij AC_SUBST($1) 246296465Sdelphij ]) 247296465Sdelphij]) 248296465Sdelphij 249296465Sdelphij############################################################################### 250296465Sdelphij# 251296465Sdelphij# We need a Boot JDK to bootstrap the build. 252296465Sdelphij# 253296465Sdelphij 254296465SdelphijAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], 255296465Sdelphij[ 256296465Sdelphij BOOT_JDK_FOUND=no 257296465Sdelphij AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk], 258296465Sdelphij [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])]) 259296465Sdelphij 260296465Sdelphij # We look for the Boot JDK through various means, going from more certain to 261296465Sdelphij # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if 262296465Sdelphij # we detected something (if so, the path to the jdk is in BOOT_JDK). But we 263296465Sdelphij # must check if this is indeed valid; otherwise we'll continue looking. 264296465Sdelphij 265296465Sdelphij # Test: Is bootjdk explicitely set by command line arguments? 266296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS]) 267296465Sdelphij if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then 268296465Sdelphij # Having specified an argument which is incorrect will produce an instant failure; 269296465Sdelphij # we should not go on looking 270296465Sdelphij AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK]) 271296465Sdelphij fi 272296465Sdelphij 273296465Sdelphij # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? 274296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR]) 275296465Sdelphij 276296465Sdelphij # Test: Is $JAVA_HOME set? 277296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME]) 278296465Sdelphij 279296465Sdelphij # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 280296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK]) 281296465Sdelphij 282296465Sdelphij # Test: Is there a JDK installed in default, well-known locations? 283296465Sdelphij BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS]) 284296465Sdelphij 285296465Sdelphij # If we haven't found anything yet, we've truly lost. Give up. 286296465Sdelphij if test "x$BOOT_JDK_FOUND" = xno; then 287296465Sdelphij HELP_MSG_MISSING_DEPENDENCY([openjdk]) 288296465Sdelphij AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG]) 289296465Sdelphij AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk]) 290296465Sdelphij AC_MSG_ERROR([Cannot continue]) 291296465Sdelphij fi 292296465Sdelphij 293296465Sdelphij AC_SUBST(BOOT_JDK) 294296465Sdelphij 295296465Sdelphij # Setup tools from the Boot JDK. 296296465Sdelphij BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java) 297296465Sdelphij BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac) 298296465Sdelphij BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH, javah) 299296465Sdelphij BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar) 300296465Sdelphij BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JARSIGNER, jarsigner) 301296465Sdelphij 302296465Sdelphij # Finally, set some other options... 303296465Sdelphij 304296465Sdelphij # When compiling code to be executed by the Boot JDK, force jdk8 compatibility. 305296465Sdelphij BOOT_JDK_SOURCETARGET="-source 8 -target 8" 306296465Sdelphij AC_SUBST(BOOT_JDK_SOURCETARGET) 307296465Sdelphij 308296465Sdelphij ADD_JVM_ARG_IF_OK([-Xpatch:foo=bar], dummy, [$JAVA]) 309296465Sdelphij AC_MSG_CHECKING([if Boot JDK supports modules]) 310296465Sdelphij if test "x$JVM_ARG_OK" = "xtrue"; then 311296465Sdelphij AC_MSG_RESULT([yes]) 312296465Sdelphij BOOT_JDK_MODULAR="true" 313296465Sdelphij else 314296465Sdelphij AC_MSG_RESULT([no]) 315296465Sdelphij BOOT_JDK_MODULAR="false" 316296465Sdelphij fi 317296465Sdelphij AC_SUBST(BOOT_JDK_MODULAR) 318296465Sdelphij 319296465Sdelphij AC_SUBST(JAVAC_FLAGS) 320296465Sdelphij 321296465Sdelphij # Check if the boot jdk is 32 or 64 bit 322296465Sdelphij if "$JAVA" -d64 -version > /dev/null 2>&1; then 323296465Sdelphij BOOT_JDK_BITS="64" 324296465Sdelphij else 325296465Sdelphij BOOT_JDK_BITS="32" 326296465Sdelphij fi 327296465Sdelphij AC_MSG_CHECKING([if Boot JDK is 32 or 64 bits]) 328296465Sdelphij AC_MSG_RESULT([$BOOT_JDK_BITS]) 329296465Sdelphij AC_SUBST(BOOT_JDK_BITS) 330296465Sdelphij]) 331296465Sdelphij 332296465SdelphijAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], 333296465Sdelphij[ 334296465Sdelphij ############################################################################## 335296465Sdelphij # 336296465Sdelphij # Specify jvm options for anything that is run with the Boot JDK. 337296465Sdelphij # Not all JVM:s accept the same arguments on the command line. 338296465Sdelphij # 339296465Sdelphij AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs], 340296465Sdelphij [specify JVM arguments to be passed to all java invocations of boot JDK, overriding the default values, 341296465Sdelphij e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])]) 342296465Sdelphij 343296465Sdelphij AC_MSG_CHECKING([flags for boot jdk java command] ) 344296465Sdelphij 345296465Sdelphij # Disable special log output when a debug build is used as Boot JDK... 346296465Sdelphij ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA]) 347296465Sdelphij 348296465Sdelphij # Apply user provided options. 349296465Sdelphij ADD_JVM_ARG_IF_OK([$with_boot_jdk_jvmargs],boot_jdk_jvmargs,[$JAVA]) 350296465Sdelphij 351296465Sdelphij AC_MSG_RESULT([$boot_jdk_jvmargs]) 352296465Sdelphij 353296465Sdelphij # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs 354296465Sdelphij JAVA_FLAGS=$boot_jdk_jvmargs 355296465Sdelphij AC_SUBST(JAVA_FLAGS) 356296465Sdelphij 357296465Sdelphij 358296465Sdelphij AC_MSG_CHECKING([flags for boot jdk java command for big workloads]) 359296465Sdelphij 360296465Sdelphij # Starting amount of heap memory. 361296465Sdelphij ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs_big,[$JAVA]) 362296465Sdelphij BOOTCYCLE_JVM_ARGS_BIG=-Xms64M 363296465Sdelphij 364296465Sdelphij # Maximum amount of heap memory and stack size. 365296465Sdelphij JVM_HEAP_LIMIT_32="1100" 366296465Sdelphij # Running a 64 bit JVM allows for and requires a bigger heap 367296465Sdelphij JVM_HEAP_LIMIT_64="1600" 368296465Sdelphij STACK_SIZE_32=768 369296465Sdelphij STACK_SIZE_64=1536 370296465Sdelphij JVM_HEAP_LIMIT_GLOBAL=`expr $MEMORY_SIZE / 2` 371296465Sdelphij if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_32"; then 372296465Sdelphij JVM_HEAP_LIMIT_32=$JVM_HEAP_LIMIT_GLOBAL 373296465Sdelphij fi 374296465Sdelphij if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_64"; then 375296465Sdelphij JVM_HEAP_LIMIT_64=$JVM_HEAP_LIMIT_GLOBAL 376296465Sdelphij fi 377296465Sdelphij if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "512"; then 378296465Sdelphij JVM_HEAP_LIMIT_32=512 379296465Sdelphij JVM_HEAP_LIMIT_64=512 380296465Sdelphij fi 381296465Sdelphij 382296465Sdelphij if test "x$BOOT_JDK_BITS" = "x32"; then 383296465Sdelphij STACK_SIZE=$STACK_SIZE_32 384296465Sdelphij JVM_MAX_HEAP=$JVM_HEAP_LIMIT_32 385296465Sdelphij else 386296465Sdelphij STACK_SIZE=$STACK_SIZE_64 387296465Sdelphij JVM_MAX_HEAP=$JVM_HEAP_LIMIT_64 388296465Sdelphij fi 389296465Sdelphij ADD_JVM_ARG_IF_OK([-Xmx${JVM_MAX_HEAP}M],boot_jdk_jvmargs_big,[$JAVA]) 390296465Sdelphij ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs_big,[$JAVA]) 391296465Sdelphij 392296465Sdelphij AC_MSG_RESULT([$boot_jdk_jvmargs_big]) 393296465Sdelphij 394296465Sdelphij JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big 395296465Sdelphij AC_SUBST(JAVA_FLAGS_BIG) 396296465Sdelphij 397296465Sdelphij if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then 398296465Sdelphij BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_32 399296465Sdelphij BOOTCYCLE_STACK_SIZE=$STACK_SIZE_32 400296465Sdelphij else 401296465Sdelphij BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_64 402296465Sdelphij BOOTCYCLE_STACK_SIZE=$STACK_SIZE_64 403296465Sdelphij fi 404296465Sdelphij BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -Xmx${BOOTCYCLE_MAX_HEAP}M" 405296465Sdelphij BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -XX:ThreadStackSize=$BOOTCYCLE_STACK_SIZE" 406296465Sdelphij AC_MSG_CHECKING([flags for bootcycle boot jdk java command for big workloads]) 407296465Sdelphij AC_MSG_RESULT([$BOOTCYCLE_JVM_ARGS_BIG]) 408296465Sdelphij AC_SUBST(BOOTCYCLE_JVM_ARGS_BIG) 409296465Sdelphij 410296465Sdelphij # By default, the main javac compilations use big 411296465Sdelphij JAVA_FLAGS_JAVAC="$JAVA_FLAGS_BIG" 412296465Sdelphij AC_SUBST(JAVA_FLAGS_JAVAC) 413296465Sdelphij 414296465Sdelphij AC_MSG_CHECKING([flags for boot jdk java command for small workloads]) 415296465Sdelphij 416296465Sdelphij # Use serial gc for small short lived tools if possible 417296465Sdelphij ADD_JVM_ARG_IF_OK([-XX:+UseSerialGC],boot_jdk_jvmargs_small,[$JAVA]) 418296465Sdelphij ADD_JVM_ARG_IF_OK([-Xms32M],boot_jdk_jvmargs_small,[$JAVA]) 419296465Sdelphij ADD_JVM_ARG_IF_OK([-Xmx512M],boot_jdk_jvmargs_small,[$JAVA]) 420296465Sdelphij ADD_JVM_ARG_IF_OK([-XX:TieredStopAtLevel=1],boot_jdk_jvmargs_small,[$JAVA]) 421296465Sdelphij 422296465Sdelphij AC_MSG_RESULT([$boot_jdk_jvmargs_small]) 423296465Sdelphij 424296465Sdelphij JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small 425296465Sdelphij AC_SUBST(JAVA_FLAGS_SMALL) 426296465Sdelphij 427296465Sdelphij JAVA_TOOL_FLAGS_SMALL="" 428296465Sdelphij for f in $JAVA_FLAGS_SMALL; do 429296465Sdelphij JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f" 430296465Sdelphij done 431296465Sdelphij AC_SUBST(JAVA_TOOL_FLAGS_SMALL) 432296465Sdelphij]) 433296465Sdelphij 434296465Sdelphij# BUILD_JDK: the location of the latest JDK that can run 435296465Sdelphij# on the host system and supports the target class file version 436296465Sdelphij# generated in this JDK build. This variable should only be 437296465Sdelphij# used after the launchers are built. 438296465Sdelphij# 439296465Sdelphij 440296465Sdelphij# Execute the check given as argument, and verify the result. 441296465Sdelphij# If the JDK was previously found, do nothing. 442296465Sdelphij# $1 A command line (typically autoconf macro) to execute 443296465SdelphijAC_DEFUN([BOOTJDK_CHECK_BUILD_JDK], 444296465Sdelphij[ 445296465Sdelphij if test "x$BUILD_JDK_FOUND" = xno; then 446296465Sdelphij # Execute the test 447296465Sdelphij $1 448296465Sdelphij 449296465Sdelphij # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 450296465Sdelphij if test "x$BUILD_JDK_FOUND" = xmaybe; then 451296465Sdelphij # Do we have a bin/java? 452296465Sdelphij if test ! -x "$BUILD_JDK/bin/java"; then 453296465Sdelphij AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/java; ignoring]) 454296465Sdelphij BUILD_JDK_FOUND=no 455296465Sdelphij elif test ! -x "$BUILD_JDK/bin/jlink"; then 456296465Sdelphij AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jlink; ignoring]) 457296465Sdelphij BUILD_JDK_FOUND=no 458296465Sdelphij elif test ! -x "$BUILD_JDK/bin/jmod"; then 459296465Sdelphij AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jmod; ignoring]) 460296465Sdelphij BUILD_JDK_FOUND=no 461296465Sdelphij elif test ! -x "$BUILD_JDK/bin/javac"; then 462296465Sdelphij # Do we have a bin/javac? 463296465Sdelphij AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/javac; ignoring]) 464296465Sdelphij AC_MSG_NOTICE([(This might be a JRE instead of an JDK)]) 465296465Sdelphij BUILD_JDK_FOUND=no 466296465Sdelphij else 467296465Sdelphij # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 468296465Sdelphij BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $HEAD -n 1` 469296465Sdelphij 470296465Sdelphij # Extra M4 quote needed to protect [] in grep expression. 471296465Sdelphij [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"'`] 472296465Sdelphij if test "x$FOUND_CORRECT_VERSION" = x; then 473296465Sdelphij AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring]) 474296465Sdelphij AC_MSG_NOTICE([(Your Build JDK must be version 9)]) 475296465Sdelphij BUILD_JDK_FOUND=no 476296465Sdelphij else 477296465Sdelphij # We're done! 478296465Sdelphij BUILD_JDK_FOUND=yes 479296465Sdelphij BASIC_FIXUP_PATH(BUILD_JDK) 480296465Sdelphij AC_MSG_CHECKING([for Build JDK]) 481296465Sdelphij AC_MSG_RESULT([$BUILD_JDK]) 482296465Sdelphij AC_MSG_CHECKING([Build JDK version]) 483296465Sdelphij BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` 484296465Sdelphij AC_MSG_RESULT([$BUILD_JDK_VERSION]) 485296465Sdelphij fi # end check jdk version 486296465Sdelphij fi # end check java 487296465Sdelphij fi # end check build jdk found 488296465Sdelphij fi 489296465Sdelphij]) 490296465Sdelphij 491296465Sdelphij# By default the BUILD_JDK is the JDK_OUTPUTDIR. If the target architecture 492296465Sdelphij# is different than the host system doing the build (e.g. cross-compilation), 493296465Sdelphij# a special BUILD_JDK is built as part of the build process. An external 494296465Sdelphij# prebuilt BUILD_JDK can also be supplied. 495296465SdelphijAC_DEFUN([BOOTJDK_SETUP_BUILD_JDK], 496296465Sdelphij[ 497296465Sdelphij AC_ARG_WITH(build-jdk, [AS_HELP_STRING([--with-build-jdk], 498296465Sdelphij [path to JDK of same version as is being built@<:@the newly built JDK@:>@])]) 499296465Sdelphij 500296465Sdelphij CREATE_BUILDJDK=false 501296465Sdelphij EXTERNAL_BUILDJDK=false 502296465Sdelphij BUILD_JDK_FOUND="no" 503296465Sdelphij if test "x$with_build_jdk" != "x"; then 504296465Sdelphij BOOTJDK_CHECK_BUILD_JDK([ 505296465Sdelphij if test "x$with_build_jdk" != x; then 506296465Sdelphij BUILD_JDK=$with_build_jdk 507296465Sdelphij BUILD_JDK_FOUND=maybe 508296465Sdelphij AC_MSG_NOTICE([Found potential Build JDK using configure arguments]) 509296465Sdelphij fi]) 510296465Sdelphij EXTERNAL_BUILDJDK=true 511296465Sdelphij else 512296465Sdelphij if test "x$COMPILE_TYPE" = "xcross"; then 513296465Sdelphij BUILD_JDK="\$(BUILDJDK_OUTPUTDIR)/jdk" 514296465Sdelphij BUILD_JDK_FOUND=yes 515296465Sdelphij CREATE_BUILDJDK=true 516296465Sdelphij AC_MSG_CHECKING([for Build JDK]) 517296465Sdelphij AC_MSG_RESULT([yes, will build it for the host platform]) 518296465Sdelphij else 519296465Sdelphij BUILD_JDK="\$(JDK_OUTPUTDIR)" 520296465Sdelphij BUILD_JDK_FOUND=yes 521296465Sdelphij AC_MSG_CHECKING([for Build JDK]) 522296465Sdelphij AC_MSG_RESULT([yes, will use output dir]) 523296465Sdelphij fi 524296465Sdelphij fi 525296465Sdelphij 526296465Sdelphij JMOD="$BUILD_JDK/bin/jmod" 527296465Sdelphij JLINK="$BUILD_JDK/bin/jlink" 528296465Sdelphij AC_SUBST(JMOD) 529296465Sdelphij AC_SUBST(JLINK) 530296465Sdelphij 531296465Sdelphij if test "x$BUILD_JDK_FOUND" != "xyes"; then 532296465Sdelphij AC_MSG_CHECKING([for Build JDK]) 533296465Sdelphij AC_MSG_RESULT([no]) 534296465Sdelphij AC_MSG_ERROR([Could not find a suitable Build JDK]) 535296465Sdelphij fi 536296465Sdelphij 537296465Sdelphij AC_SUBST(CREATE_BUILDJDK) 538296465Sdelphij AC_SUBST(BUILD_JDK) 539296465Sdelphij AC_SUBST(EXTERNAL_BUILDJDK) 540296465Sdelphij]) 541296465Sdelphij