boot-jdk.m4 revision 1775:e1ef7db1e02d
1114472Sru# 2146515Sru# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. 321495Sjmacd# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4114472Sru# 5146515Sru# This code is free software; you can redistribute it and/or modify it 621495Sjmacd# under the terms of the GNU General Public License version 2 only, as 721495Sjmacd# published by the Free Software Foundation. Oracle designates this 821495Sjmacd# particular file as subject to the "Classpath" exception as provided 921495Sjmacd# by Oracle in the LICENSE file that accompanied this code. 1021495Sjmacd# 1121495Sjmacd# This code is distributed in the hope that it will be useful, but WITHOUT 1221495Sjmacd# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1321495Sjmacd# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1421495Sjmacd# version 2 for more details (a copy is included in the LICENSE file that 1521495Sjmacd# accompanied this code). 1621495Sjmacd# 1721495Sjmacd# You should have received a copy of the GNU General Public License version 1821495Sjmacd# 2 along with this work; if not, write to the Free Software Foundation, 1921495Sjmacd# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2021495Sjmacd# 2142660Smarkm# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2242660Smarkm# or visit www.oracle.com if you need additional information or have any 2321495Sjmacd# questions. 2456160Sru# 2556160Sru 2621495Sjmacd######################################################################## 2721495Sjmacd# This file handles detection of the Boot JDK. The Boot JDK detection 2821495Sjmacd# process has been developed as a response to solve a complex real-world 2921495Sjmacd# problem. Initially, it was simple, but it has grown as platform after 3021495Sjmacd# platform, idiosyncracy after idiosyncracy has been supported. 3121495Sjmacd# 3221495Sjmacd# The basic idea is this: 3321495Sjmacd# 1) You need an acceptable *) JDK to use as a Boot JDK 3421495Sjmacd# 2) There are several ways to locate a JDK, that are mostly platform 3521495Sjmacd# dependent **) 3621495Sjmacd# 3) You can have multiple JDKs installed 3721495Sjmacd# 4) If possible, configure should try to dig out an acceptable JDK 3821495Sjmacd# automatically, without having to resort to command-line options 3921495Sjmacd# 40146515Sru# *) acceptable means e.g. JDK7 for building JDK8, a complete JDK (with 4121495Sjmacd# javac) and not a JRE, etc. 4221495Sjmacd# 4321495Sjmacd# **) On Windows we typically use a well-known path. 4421495Sjmacd# On MacOSX we typically use the tool java_home. 4521495Sjmacd# On Linux we typically find javac in the $PATH, and then follow a 4621495Sjmacd# chain of symlinks that often ends up in a real JDK. 4721495Sjmacd# 48146515Sru# This leads to the code where we check in different ways to locate a 49146515Sru# JDK, and if one is found, check if it is acceptable. If not, we print 5021495Sjmacd# our reasons for rejecting it (useful when debugging non-working 5121495Sjmacd# configure situations) and continue checking the next one. 5221495Sjmacd######################################################################## 5321495Sjmacd 5442660Smarkm# Execute the check given as argument, and verify the result 5521495Sjmacd# If the Boot JDK was previously found, do nothing 5642660Smarkm# $1 A command line (typically autoconf macro) to execute 5742660SmarkmAC_DEFUN([BOOTJDK_DO_CHECK], 5821495Sjmacd[ 5942660Smarkm if test "x$BOOT_JDK_FOUND" = xno; then 6021495Sjmacd # Now execute the test 6121495Sjmacd $1 6221495Sjmacd 6321495Sjmacd # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 6421495Sjmacd if test "x$BOOT_JDK_FOUND" = xmaybe; then 6542660Smarkm # Do we have a bin/java? 6642660Smarkm if test ! -x "$BOOT_JDK/bin/java"; then 6742660Smarkm AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring]) 6842660Smarkm BOOT_JDK_FOUND=no 6942660Smarkm else 7042660Smarkm # Do we have a bin/javac? 7142660Smarkm if test ! -x "$BOOT_JDK/bin/javac"; then 7242660Smarkm AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring]) 7342660Smarkm AC_MSG_NOTICE([(This might be an JRE instead of an JDK)]) 7442660Smarkm BOOT_JDK_FOUND=no 7521495Sjmacd else 7621495Sjmacd # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 7721495Sjmacd BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` 7821495Sjmacd 7921495Sjmacd # Extra M4 quote needed to protect [] in grep expression. 8021495Sjmacd [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"|(1\.[89]\.)'`] 8121495Sjmacd if test "x$FOUND_CORRECT_VERSION" = x; then 8221495Sjmacd AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring]) 8321495Sjmacd AC_MSG_NOTICE([(Your Boot JDK must be version 8 or 9)]) 8421495Sjmacd BOOT_JDK_FOUND=no 8521495Sjmacd else 8621495Sjmacd # We're done! :-) 8721495Sjmacd BOOT_JDK_FOUND=yes 8821495Sjmacd BASIC_FIXUP_PATH(BOOT_JDK) 8921495Sjmacd AC_MSG_CHECKING([for Boot JDK]) 9021495Sjmacd AC_MSG_RESULT([$BOOT_JDK]) 9121495Sjmacd AC_MSG_CHECKING([Boot JDK version]) 9221495Sjmacd BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` 9321495Sjmacd AC_MSG_RESULT([$BOOT_JDK_VERSION]) 9421495Sjmacd fi # end check jdk version 9521495Sjmacd fi # end check javac 9621495Sjmacd fi # end check java 9721495Sjmacd fi # end check boot jdk found 9821495Sjmacd fi 9921495Sjmacd]) 10021495Sjmacd 10121495Sjmacd# Test: Is bootjdk explicitely set by command line arguments? 10221495SjmacdAC_DEFUN([BOOTJDK_CHECK_ARGUMENTS], 10321495Sjmacd[ 10421495Sjmacd if test "x$with_boot_jdk" != x; then 10521495Sjmacd BOOT_JDK=$with_boot_jdk 10621495Sjmacd BOOT_JDK_FOUND=maybe 10721495Sjmacd AC_MSG_NOTICE([Found potential Boot JDK using configure arguments]) 10821495Sjmacd fi 10921495Sjmacd]) 11021495Sjmacd 11121495Sjmacd# Test: Is bootjdk available from builddeps? 11221495SjmacdAC_DEFUN([BOOTJDK_CHECK_BUILDDEPS], 113114472Sru[ 114114472Sru BDEPS_CHECK_MODULE(BOOT_JDK, bootjdk, xxx, [BOOT_JDK_FOUND=maybe], [BOOT_JDK_FOUND=no]) 115114472Sru]) 116114472Sru 117114472Sru# Test: Is $JAVA_HOME set? 118114472SruAC_DEFUN([BOOTJDK_CHECK_JAVA_HOME], 119114472Sru[ 12021495Sjmacd if test "x$JAVA_HOME" != x; then 12121495Sjmacd JAVA_HOME_PROCESSED="$JAVA_HOME" 12221495Sjmacd BASIC_FIXUP_PATH(JAVA_HOME_PROCESSED) 12321495Sjmacd if test ! -d "$JAVA_HOME_PROCESSED"; then 12421495Sjmacd AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!]) 12521495Sjmacd else 126146515Sru # Aha, the user has set a JAVA_HOME 127146515Sru # let us use that as the Boot JDK. 128146515Sru BOOT_JDK="$JAVA_HOME_PROCESSED" 129146515Sru BOOT_JDK_FOUND=maybe 130146515Sru AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME]) 131146515Sru fi 132146515Sru fi 133146515Sru]) 134146515Sru 135146515Sru# Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 136146515SruAC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK], 137146515Sru[ 138146515Sru AC_PATH_PROG(JAVAC_CHECK, javac) 139146515Sru AC_PATH_PROG(JAVA_CHECK, java) 140146515Sru BINARY="$JAVAC_CHECK" 141146515Sru if test "x$JAVAC_CHECK" = x; then 142146515Sru BINARY="$JAVA_CHECK" 143146515Sru fi 144146515Sru if test "x$BINARY" != x; then 145146515Sru # So there is a java(c) binary, it might be part of a JDK. 14621495Sjmacd # Lets find the JDK/JRE directory by following symbolic links. 147146515Sru # Linux/GNU systems often have links from /usr/bin/java to 148146515Sru # /etc/alternatives/java to the real JDK binary. 14921495Sjmacd BASIC_REMOVE_SYMBOLIC_LINKS(BINARY) 15021495Sjmacd BOOT_JDK=`dirname "$BINARY"` 15121495Sjmacd BOOT_JDK=`cd "$BOOT_JDK/.."; pwd` 15242660Smarkm if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then 153146515Sru # Looks like we found ourselves an JDK 15421495Sjmacd BOOT_JDK_FOUND=maybe 15521495Sjmacd AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH]) 15621495Sjmacd fi 15721495Sjmacd fi 15821495Sjmacd]) 15921495Sjmacd 16042660Smarkm# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 16142660Smarkm# $1: Argument to the java_home binary (optional) 16242660SmarkmAC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME], 16342660Smarkm[ 16442660Smarkm if test -x /usr/libexec/java_home; then 16542660Smarkm BOOT_JDK=`/usr/libexec/java_home $1` 16642660Smarkm BOOT_JDK_FOUND=maybe 16742660Smarkm AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home $1]) 16842660Smarkm fi 169114472Sru]) 170114472Sru 171116525Sru# Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? 17221495SjmacdAC_DEFUN([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR], 17321495Sjmacd[ 17421495Sjmacd if test "x$OPENJDK_TARGET_OS" = xmacosx; then 17521495Sjmacd # First check at user selected default 17621495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME()]) 17721495Sjmacd # If that did not work out (e.g. too old), try explicit versions instead 17821495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.9])]) 17921495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.8])]) 18021495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.7])]) 18121495Sjmacd fi 18221495Sjmacd]) 18321495Sjmacd 18421495Sjmacd# Look for a jdk in the given path. If there are multiple, try to select the newest. 18521495Sjmacd# If found, set BOOT_JDK and BOOT_JDK_FOUND. 18621495Sjmacd# $1 = Path to directory containing jdk installations. 18721495Sjmacd# $2 = String to append to the found JDK directory to get the proper JDK home 18821495SjmacdAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY], 18921495Sjmacd[ 19021495Sjmacd BOOT_JDK_PREFIX="$1" 19121495Sjmacd BOOT_JDK_SUFFIX="$2" 19221495Sjmacd ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r` 19321495Sjmacd if test "x$ALL_JDKS_FOUND" != x; then 19421495Sjmacd for JDK_TO_TRY in $ALL_JDKS_FOUND ; do 19521495Sjmacd BOOTJDK_DO_CHECK([ 19621495Sjmacd BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" 19721495Sjmacd if test -d "$BOOT_JDK"; then 19856160Sru BOOT_JDK_FOUND=maybe 19921495Sjmacd AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)]) 20056160Sru fi 20121495Sjmacd ]) 20221495Sjmacd done 20321495Sjmacd fi 20442660Smarkm]) 20556160Sru 20656160Sru# Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given 20756160Sru# environmental variable as base for where to look. 20856160Sru# $1 Name of an environmal variable, assumed to point to the Program Files directory. 20956160SruAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY], 21056160Sru[ 21156160Sru if test "x[$]$1" != x; then 21256160Sru VIRTUAL_DIR="[$]$1/Java" 21356160Sru BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VIRTUAL_DIR) 21456160Sru BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR) 21556160Sru fi 21621495Sjmacd]) 21756160Sru 21821495Sjmacd# Test: Is there a JDK installed in default, well-known locations? 21921495SjmacdAC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS], 22021495Sjmacd[ 22121495Sjmacd if test "x$OPENJDK_TARGET_OS" = xwindows; then 22221495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])]) 223116525Sru BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])]) 22421495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])]) 225114472Sru BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])]) 226114472Sru BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])]) 227114472Sru elif test "x$OPENJDK_TARGET_OS" = xmacosx; then 22821495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 22942660Smarkm BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 230114472Sru elif test "x$OPENJDK_TARGET_OS" = xlinux; then 23121495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])]) 23242660Smarkm fi 23321495Sjmacd]) 23421495Sjmacd 23521495Sjmacd# Check that a command-line tool in the Boot JDK is correct 23656160Sru# $1 = name of variable to assign 23742660Smarkm# $2 = name of binary 23821495SjmacdAC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], 23921495Sjmacd[ 24021495Sjmacd # Use user overridden value if available, otherwise locate tool in the Boot JDK. 24121495Sjmacd BASIC_SETUP_TOOL($1, 24221495Sjmacd [ 24321495Sjmacd AC_MSG_CHECKING([for $2 in Boot JDK]) 24421495Sjmacd $1=$BOOT_JDK/bin/$2 24521495Sjmacd if test ! -x [$]$1; then 24621495Sjmacd AC_MSG_RESULT(not found) 24721495Sjmacd AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk]) 24821495Sjmacd AC_MSG_ERROR([Could not find $2 in the Boot JDK]) 24921495Sjmacd fi 25021495Sjmacd AC_MSG_RESULT(ok) 25156160Sru AC_SUBST($1) 25256160Sru ]) 25321495Sjmacd]) 25442660Smarkm 25521495Sjmacd############################################################################### 25642660Smarkm# 25721495Sjmacd# We need a Boot JDK to bootstrap the build. 25842660Smarkm# 25921495Sjmacd 26042660SmarkmAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], 26121495Sjmacd[ 26221495Sjmacd BOOT_JDK_FOUND=no 26321495Sjmacd AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk], 26421495Sjmacd [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])]) 265146515Sru 26621495Sjmacd # We look for the Boot JDK through various means, going from more certain to 26721495Sjmacd # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if 26821495Sjmacd # we detected something (if so, the path to the jdk is in BOOT_JDK). But we 26921495Sjmacd # must check if this is indeed valid; otherwise we'll continue looking. 27042660Smarkm 27142660Smarkm # Test: Is bootjdk explicitely set by command line arguments? 27221495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS]) 27356160Sru if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then 27456160Sru # Having specified an argument which is incorrect will produce an instant failure; 27556160Sru # we should not go on looking 27642660Smarkm AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK]) 27721495Sjmacd fi 27821495Sjmacd 27921495Sjmacd # Test: Is bootjdk available from builddeps? 28056160Sru BOOTJDK_DO_CHECK([BOOTJDK_CHECK_BUILDDEPS]) 28156160Sru 28221495Sjmacd # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? 28342660Smarkm BOOTJDK_DO_CHECK([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR]) 28421495Sjmacd 28521495Sjmacd # Test: Is $JAVA_HOME set? 28642660Smarkm BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME]) 28742660Smarkm 28821495Sjmacd # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 28921495Sjmacd BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK]) 29042660Smarkm 29121495Sjmacd # Test: Is there a JDK installed in default, well-known locations? 29256160Sru BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS]) 29356160Sru 29456160Sru # If we haven't found anything yet, we've truly lost. Give up. 295100513Sru if test "x$BOOT_JDK_FOUND" = xno; then 296100513Sru HELP_MSG_MISSING_DEPENDENCY([openjdk]) 29721495Sjmacd AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG]) 29856160Sru AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk]) 29921495Sjmacd AC_MSG_ERROR([Cannot continue]) 30021495Sjmacd fi 30121495Sjmacd 30221495Sjmacd AC_SUBST(BOOT_JDK) 30321495Sjmacd 30421495Sjmacd # Setup tools from the Boot JDK. 305146515Sru BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java) 30621495Sjmacd BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac) 30721495Sjmacd BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH, javah) 30821495Sjmacd BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar) 30921495Sjmacd BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JARSIGNER, jarsigner) 31021495Sjmacd 31121495Sjmacd # Finally, set some other options... 31221495Sjmacd 31321495Sjmacd # When compiling code to be executed by the Boot JDK, force jdk8 compatibility. 31421495Sjmacd BOOT_JDK_SOURCETARGET="-source 8 -target 8" 31556160Sru AC_SUBST(BOOT_JDK_SOURCETARGET) 31621495Sjmacd AC_SUBST(JAVAC_FLAGS) 31756160Sru]) 31856160Sru 31956160SruAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], 32021495Sjmacd[ 321116525Sru ############################################################################## 32221495Sjmacd # 32321495Sjmacd # Specify jvm options for anything that is run with the Boot JDK. 32421495Sjmacd # Not all JVM:s accept the same arguments on the command line. 32521495Sjmacd # 32621495Sjmacd AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs], 32721495Sjmacd [specify JVM arguments to be passed to all java invocations of boot JDK, overriding the default values, 32821495Sjmacd e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])]) 32921495Sjmacd 33021495Sjmacd AC_MSG_CHECKING([flags for boot jdk java command] ) 33121495Sjmacd 33221495Sjmacd # Disable special log output when a debug build is used as Boot JDK... 33321495Sjmacd ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA]) 33421495Sjmacd 33521495Sjmacd # Apply user provided options. 33621495Sjmacd ADD_JVM_ARG_IF_OK([$with_boot_jdk_jvmargs],boot_jdk_jvmargs,[$JAVA]) 33742660Smarkm 33842660Smarkm AC_MSG_RESULT([$boot_jdk_jvmargs]) 33942660Smarkm 34042660Smarkm # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs 34156160Sru JAVA_FLAGS=$boot_jdk_jvmargs 342146515Sru AC_SUBST(JAVA_FLAGS) 343146515Sru 34421495Sjmacd 345146515Sru AC_MSG_CHECKING([flags for boot jdk java command for big workloads]) 34656160Sru 34742660Smarkm # Starting amount of heap memory. 34842660Smarkm ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs_big,[$JAVA]) 34942660Smarkm 35042660Smarkm # Maximum amount of heap memory. 35142660Smarkm # Maximum stack size. 35242660Smarkm JVM_MAX_HEAP=`expr $MEMORY_SIZE / 2` 35342660Smarkm if test "x$BUILD_NUM_BITS" = x32; then 35442660Smarkm if test "$JVM_MAX_HEAP" -gt "1100"; then 35542660Smarkm JVM_MAX_HEAP=1100 35642660Smarkm elif test "$JVM_MAX_HEAP" -lt "512"; then 35742660Smarkm JVM_MAX_HEAP=512 35842660Smarkm fi 35942660Smarkm STACK_SIZE=768 36042660Smarkm else 36142660Smarkm # Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit 36242660Smarkm # pointers are used. Apparently, we need to increase the heap and stack 36342660Smarkm # space for the jvm. More specifically, when running javac to build huge 36442660Smarkm # jdk batch 36542660Smarkm if test "$JVM_MAX_HEAP" -gt "1600"; then 36642660Smarkm JVM_MAX_HEAP=1600 36742660Smarkm elif test "$JVM_MAX_HEAP" -lt "512"; then 36842660Smarkm JVM_MAX_HEAP=512 36942660Smarkm fi 37042660Smarkm STACK_SIZE=1536 37142660Smarkm fi 37242660Smarkm ADD_JVM_ARG_IF_OK([-Xmx${JVM_MAX_HEAP}M],boot_jdk_jvmargs_big,[$JAVA]) 37321495Sjmacd ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs_big,[$JAVA]) 37442660Smarkm 37542660Smarkm AC_MSG_RESULT([$boot_jdk_jvmargs_big]) 37642660Smarkm 37742660Smarkm JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big 37821495Sjmacd AC_SUBST(JAVA_FLAGS_BIG) 37921495Sjmacd 38021495Sjmacd 38121495Sjmacd AC_MSG_CHECKING([flags for boot jdk java command for small workloads]) 38221495Sjmacd 38321495Sjmacd # Use serial gc for small short lived tools if possible 38421495Sjmacd ADD_JVM_ARG_IF_OK([-XX:+UseSerialGC],boot_jdk_jvmargs_small,[$JAVA]) 38521495Sjmacd ADD_JVM_ARG_IF_OK([-Xms32M],boot_jdk_jvmargs_small,[$JAVA]) 38621495Sjmacd ADD_JVM_ARG_IF_OK([-Xmx512M],boot_jdk_jvmargs_small,[$JAVA]) 387154216Scperciva 388154216Scperciva AC_MSG_RESULT([$boot_jdk_jvmargs_small]) 389154216Scperciva 390154216Scperciva JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small 391154216Scperciva AC_SUBST(JAVA_FLAGS_SMALL) 392154216Scperciva 393154216Scperciva JAVA_TOOL_FLAGS_SMALL="" 394154216Scperciva for f in $JAVA_FLAGS_SMALL; do 395154216Scperciva JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f" 396154216Scperciva done 397154216Scperciva AC_SUBST(JAVA_TOOL_FLAGS_SMALL) 398154216Scperciva]) 399154216Scperciva