boot-jdk.m4 revision 946:f3697e0783e2
1251881Speter# 2251881Speter# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 3251881Speter# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4251881Speter# 5251881Speter# This code is free software; you can redistribute it and/or modify it 6251881Speter# under the terms of the GNU General Public License version 2 only, as 7251881Speter# published by the Free Software Foundation. Oracle designates this 8251881Speter# particular file as subject to the "Classpath" exception as provided 9251881Speter# by Oracle in the LICENSE file that accompanied this code. 10251881Speter# 11251881Speter# This code is distributed in the hope that it will be useful, but WITHOUT 12251881Speter# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13251881Speter# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14251881Speter# version 2 for more details (a copy is included in the LICENSE file that 15251881Speter# accompanied this code). 16251881Speter# 17251881Speter# You should have received a copy of the GNU General Public License version 18251881Speter# 2 along with this work; if not, write to the Free Software Foundation, 19251881Speter# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20251881Speter# 21251881Speter# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22251881Speter# or visit www.oracle.com if you need additional information or have any 23251881Speter# questions. 24251881Speter# 25251881Speter 26251881Speter# Execute the check given as argument, and verify the result 27251881Speter# If the Boot JDK was previously found, do nothing 28251881Speter# $1 A command line (typically autoconf macro) to execute 29251881SpeterAC_DEFUN([BOOTJDK_DO_CHECK], 30251881Speter[ 31251881Speter if test "x$BOOT_JDK_FOUND" = xno; then 32251881Speter # Now execute the test 33251881Speter $1 34251881Speter 35251881Speter # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 36251881Speter if test "x$BOOT_JDK_FOUND" = xmaybe; then 37251881Speter # Do we have a bin/java? 38251881Speter if test ! -x "$BOOT_JDK/bin/java"; then 39251881Speter AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring]) 40251881Speter BOOT_JDK_FOUND=no 41251881Speter else 42251881Speter # Do we have a bin/javac? 43251881Speter if test ! -x "$BOOT_JDK/bin/javac"; then 44251881Speter AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring]) 45251881Speter AC_MSG_NOTICE([(This might be an JRE instead of an JDK)]) 46251881Speter BOOT_JDK_FOUND=no 47251881Speter else 48251881Speter # Do we have an rt.jar? (On MacOSX it is called classes.jar) 49251881Speter if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then 50251881Speter AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring]) 51251881Speter BOOT_JDK_FOUND=no 52251881Speter else 53251881Speter # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 54251881Speter BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` 55251881Speter 56251881Speter # Extra M4 quote needed to protect [] in grep expression. 57251881Speter [FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'`] 58251881Speter if test "x$FOUND_VERSION_78" = x; then 59251881Speter AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring]) 60251881Speter AC_MSG_NOTICE([(Your Boot JDK must be version 7 or 8)]) 61251881Speter BOOT_JDK_FOUND=no 62251881Speter else 63251881Speter # We're done! :-) 64251881Speter BOOT_JDK_FOUND=yes 65251881Speter BASIC_FIXUP_PATH(BOOT_JDK) 66251881Speter AC_MSG_CHECKING([for Boot JDK]) 67251881Speter AC_MSG_RESULT([$BOOT_JDK]) 68251881Speter AC_MSG_CHECKING([Boot JDK version]) 69251881Speter BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` 70251881Speter AC_MSG_RESULT([$BOOT_JDK_VERSION]) 71251881Speter fi # end check jdk version 72251881Speter fi # end check rt.jar 73251881Speter fi # end check javac 74251881Speter fi # end check java 75251881Speter fi # end check boot jdk found 76251881Speter fi 77251881Speter]) 78251881Speter 79251881Speter# Test: Is bootjdk explicitely set by command line arguments? 80251881SpeterAC_DEFUN([BOOTJDK_CHECK_ARGUMENTS], 81251881Speter[ 82251881Speter if test "x$with_boot_jdk" != x; then 83251881Speter BOOT_JDK=$with_boot_jdk 84251881Speter BOOT_JDK_FOUND=maybe 85251881Speter AC_MSG_NOTICE([Found potential Boot JDK using configure arguments]) 86251881Speter fi 87251881Speter]) 88251881Speter 89251881Speter# Test: Is bootjdk available from builddeps? 90251881SpeterAC_DEFUN([BOOTJDK_CHECK_BUILDDEPS], 91251881Speter[ 92251881Speter BDEPS_CHECK_MODULE(BOOT_JDK, bootjdk, xxx, [BOOT_JDK_FOUND=maybe], [BOOT_JDK_FOUND=no]) 93251881Speter]) 94251881Speter 95251881Speter# Test: Is $JAVA_HOME set? 96251881SpeterAC_DEFUN([BOOTJDK_CHECK_JAVA_HOME], 97251881Speter[ 98251881Speter if test "x$JAVA_HOME" != x; then 99251881Speter JAVA_HOME_PROCESSED="$JAVA_HOME" 100251881Speter BASIC_FIXUP_PATH(JAVA_HOME_PROCESSED) 101251881Speter if test ! -d "$JAVA_HOME_PROCESSED"; then 102251881Speter AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!]) 103251881Speter else 104251881Speter # Aha, the user has set a JAVA_HOME 105251881Speter # let us use that as the Boot JDK. 106251881Speter BOOT_JDK="$JAVA_HOME_PROCESSED" 107251881Speter BOOT_JDK_FOUND=maybe 108251881Speter AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME]) 109251881Speter fi 110251881Speter fi 111251881Speter]) 112251881Speter 113251881Speter# Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 114251881SpeterAC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK], 115251881Speter[ 116251881Speter AC_PATH_PROG(JAVAC_CHECK, javac) 117251881Speter AC_PATH_PROG(JAVA_CHECK, java) 118251881Speter BINARY="$JAVAC_CHECK" 119251881Speter if test "x$JAVAC_CHECK" = x; then 120251881Speter BINARY="$JAVA_CHECK" 121251881Speter fi 122251881Speter if test "x$BINARY" != x; then 123251881Speter # So there is a java(c) binary, it might be part of a JDK. 124251881Speter # Lets find the JDK/JRE directory by following symbolic links. 125251881Speter # Linux/GNU systems often have links from /usr/bin/java to 126251881Speter # /etc/alternatives/java to the real JDK binary. 127251881Speter BASIC_REMOVE_SYMBOLIC_LINKS(BINARY) 128251881Speter BOOT_JDK=`dirname "$BINARY"` 129251881Speter BOOT_JDK=`cd "$BOOT_JDK/.."; pwd` 130251881Speter if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then 131251881Speter # Looks like we found ourselves an JDK 132251881Speter BOOT_JDK_FOUND=maybe 133251881Speter AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH]) 134251881Speter fi 135251881Speter fi 136251881Speter]) 137251881Speter 138251881Speter# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 139251881SpeterAC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME], 140251881Speter[ 141251881Speter if test -x /usr/libexec/java_home; then 142251881Speter BOOT_JDK=`/usr/libexec/java_home` 143251881Speter BOOT_JDK_FOUND=maybe 144251881Speter AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home]) 145251881Speter fi 146251881Speter]) 147251881Speter 148251881Speter# Look for a jdk in the given path. If there are multiple, try to select the newest. 149251881Speter# If found, set BOOT_JDK and BOOT_JDK_FOUND. 150251881Speter# $1 = Path to directory containing jdk installations. 151251881Speter# $2 = String to append to the found JDK directory to get the proper JDK home 152251881SpeterAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY], 153251881Speter[ 154251881Speter BOOT_JDK_PREFIX="$1" 155251881Speter BOOT_JDK_SUFFIX="$2" 156251881Speter ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r` 157251881Speter if test "x$ALL_JDKS_FOUND" != x; then 158251881Speter for JDK_TO_TRY in $ALL_JDKS_FOUND ; do 159251881Speter BOOTJDK_DO_CHECK([ 160251881Speter BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" 161251881Speter if test -d "$BOOT_JDK"; then 162251881Speter BOOT_JDK_FOUND=maybe 163251881Speter AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)]) 164251881Speter fi 165251881Speter ]) 166251881Speter done 167251881Speter fi 168251881Speter]) 169251881Speter 170251881Speter# Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given 171251881Speter# environmental variable as base for where to look. 172251881Speter# $1 Name of an environmal variable, assumed to point to the Program Files directory. 173251881SpeterAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY], 174251881Speter[ 175251881Speter if test "x[$]$1" != x; then 176251881Speter VIRTUAL_DIR="[$]$1/Java" 177251881Speter BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VIRTUAL_DIR) 178251881Speter BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR) 179251881Speter fi 180251881Speter]) 181251881Speter 182251881Speter# Test: Is there a JDK installed in default, well-known locations? 183251881SpeterAC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS], 184251881Speter[ 185251881Speter if test "x$OPENJDK_TARGET_OS" = xwindows; then 186251881Speter BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])]) 187251881Speter BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])]) 188251881Speter BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])]) 189251881Speter BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])]) 190251881Speter BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])]) 191251881Speter elif test "x$OPENJDK_TARGET_OS" = xmacosx; then 192251881Speter BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 193251881Speter BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 194251881Speter elif test "x$OPENJDK_TARGET_OS" = xlinux; then 195251881Speter BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])]) 196251881Speter fi 197251881Speter]) 198251881Speter 199251881Speter# Check that a command-line tool in the Boot JDK is correct 200251881Speter# $1 = name of variable to assign 201251881Speter# $2 = name of binary 202251881SpeterAC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], 203251881Speter[ 204251881Speter AC_MSG_CHECKING([for $2 in Boot JDK]) 205251881Speter $1=$BOOT_JDK/bin/$2 206251881Speter if test ! -x [$]$1; then 207251881Speter AC_MSG_RESULT(not found) 208251881Speter AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk]) 209251881Speter AC_MSG_ERROR([Could not find $2 in the Boot JDK]) 210251881Speter fi 211251881Speter AC_MSG_RESULT(ok) 212251881Speter]) 213251881Speter 214251881Speter############################################################################### 215251881Speter# 216251881Speter# We need a Boot JDK to bootstrap the build. 217251881Speter# 218251881Speter 219251881SpeterAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], 220251881Speter[ 221251881Speter BOOT_JDK_FOUND=no 222251881Speter AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk], 223251881Speter [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])]) 224251881Speter 225251881Speter # We look for the Boot JDK through various means, going from more certain to 226251881Speter # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if 227251881Speter # we detected something (if so, the path to the jdk is in BOOT_JDK). But we 228251881Speter # must check if this is indeed valid; otherwise we'll continue looking. 229251881Speter 230251881Speter # Test: Is bootjdk explicitely set by command line arguments? 231251881Speter BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS]) 232251881Speter if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then 233251881Speter # Having specified an argument which is incorrect will produce an instant failure; 234251881Speter # we should not go on looking 235251881Speter AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK]) 236251881Speter fi 237251881Speter 238251881Speter # Test: Is bootjdk available from builddeps? 239251881Speter BOOTJDK_DO_CHECK([BOOTJDK_CHECK_BUILDDEPS]) 240251881Speter 241251881Speter # Test: Is $JAVA_HOME set? 242251881Speter BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME]) 243251881Speter 244251881Speter # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 245251881Speter BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME]) 246251881Speter 247251881Speter # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 248251881Speter BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK]) 249251881Speter 250251881Speter # Test: Is there a JDK installed in default, well-known locations? 251251881Speter BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS]) 252251881Speter 253251881Speter # If we haven't found anything yet, we've truly lost. Give up. 254251881Speter if test "x$BOOT_JDK_FOUND" = xno; then 255251881Speter HELP_MSG_MISSING_DEPENDENCY([openjdk]) 256251881Speter AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG]) 257251881Speter AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk]) 258251881Speter AC_MSG_ERROR([Cannot continue]) 259251881Speter fi 260251881Speter 261251881Speter # Setup proper paths for what we found 262251881Speter BOOT_RTJAR="$BOOT_JDK/jre/lib/rt.jar" 263251881Speter if test ! -f "$BOOT_RTJAR"; then 264251881Speter # On MacOSX it is called classes.jar 265251881Speter BOOT_RTJAR="$BOOT_JDK/../Classes/classes.jar" 266251881Speter if test -f "$BOOT_RTJAR"; then 267251881Speter # Remove the .. 268251881Speter BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}" 269251881Speter fi 270251881Speter fi 271251881Speter BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar" 272251881Speter BOOT_JDK="$BOOT_JDK" 273251881Speter AC_SUBST(BOOT_RTJAR) 274251881Speter AC_SUBST(BOOT_TOOLSJAR) 275251881Speter AC_SUBST(BOOT_JDK) 276251881Speter 277251881Speter # Setup tools from the Boot JDK. 278251881Speter BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA,java) 279251881Speter BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC,javac) 280251881Speter BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH,javah) 281251881Speter BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAP,javap) 282251881Speter BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR,jar) 283251881Speter BOOTJDK_CHECK_TOOL_IN_BOOTJDK(RMIC,rmic) 284251881Speter BOOTJDK_CHECK_TOOL_IN_BOOTJDK(NATIVE2ASCII,native2ascii) 285251881Speter 286251881Speter # Finally, set some other options... 287251881Speter 288251881Speter # When compiling code to be executed by the Boot JDK, force jdk7 compatibility. 289251881Speter BOOT_JDK_SOURCETARGET="-source 7 -target 7" 290251881Speter AC_SUBST(BOOT_JDK_SOURCETARGET) 291251881Speter AC_SUBST(JAVAC_FLAGS) 292251881Speter]) 293251881Speter 294251881SpeterAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], 295251881Speter[ 296251881Speter ############################################################################## 297251881Speter # 298251881Speter # Specify options for anything that is run with the Boot JDK. 299251881Speter # 300251881Speter AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs], 301251881Speter [specify JVM arguments to be passed to all invocations of the Boot JDK, overriding the default values, 302251881Speter e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])]) 303251881Speter 304251881Speter if test "x$with_boot_jdk_jvmargs" = x; then 305251881Speter # Not all JVM:s accept the same arguments on the command line. 306251881Speter # OpenJDK specific increase in thread stack for JDK build, 307251881Speter # well more specifically, when running javac. 308251881Speter if test "x$BUILD_NUM_BITS" = x32; then 309251881Speter STACK_SIZE=768 310251881Speter else 311251881Speter # Running Javac on a JVM on a 64-bit machine, the stack takes more space 312251881Speter # since 64-bit pointers are pushed on the stach. Apparently, we need 313251881Speter # to increase the stack space when javacing the JDK.... 314251881Speter STACK_SIZE=1536 315251881Speter fi 316251881Speter 317251881Speter # Minimum amount of heap memory. 318251881Speter ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs,[$JAVA]) 319251881Speter if test "x$OPENJDK_TARGET_OS" = "xmacosx" || test "x$OPENJDK_TARGET_CPU" = "xppc64" ; then 320251881Speter # Why does macosx need more heap? Its the huge JDK batch. 321251881Speter ADD_JVM_ARG_IF_OK([-Xmx1600M],boot_jdk_jvmargs,[$JAVA]) 322251881Speter else 323251881Speter ADD_JVM_ARG_IF_OK([-Xmx1100M],boot_jdk_jvmargs,[$JAVA]) 324251881Speter fi 325251881Speter # When is adding -client something that speeds up the JVM? 326251881Speter # ADD_JVM_ARG_IF_OK([-client],boot_jdk_jvmargs,[$JAVA]) 327251881Speter ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],boot_jdk_jvmargs,[$JAVA]) 328251881Speter ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],boot_jdk_jvmargs,[$JAVA]) 329251881Speter ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs,[$JAVA]) 330251881Speter # Disable special log output when a debug build is used as Boot JDK... 331251881Speter ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA]) 332251881Speter fi 333251881Speter 334251881Speter AC_SUBST(BOOT_JDK_JVMARGS, $boot_jdk_jvmargs) 335251881Speter]) 336251881Speter