erikj@459: # erikj@459: # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. erikj@459: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. erikj@459: # erikj@459: # This code is free software; you can redistribute it and/or modify it erikj@459: # under the terms of the GNU General Public License version 2 only, as erikj@459: # published by the Free Software Foundation. Oracle designates this erikj@459: # particular file as subject to the "Classpath" exception as provided erikj@459: # by Oracle in the LICENSE file that accompanied this code. erikj@459: # erikj@459: # This code is distributed in the hope that it will be useful, but WITHOUT erikj@459: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or erikj@459: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License erikj@459: # version 2 for more details (a copy is included in the LICENSE file that erikj@459: # accompanied this code). erikj@459: # erikj@459: # You should have received a copy of the GNU General Public License version erikj@459: # 2 along with this work; if not, write to the Free Software Foundation, erikj@459: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. erikj@459: # erikj@459: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA erikj@459: # or visit www.oracle.com if you need additional information or have any erikj@459: # questions. erikj@459: # erikj@459: ohair@478: # Execute the check given as argument, and verify the result ohair@478: # If the Boot JDK was previously found, do nothing ohair@478: # $1 A command line (typically autoconf macro) to execute ohair@478: AC_DEFUN([BOOTJDK_DO_CHECK], erikj@459: [ ohair@478: if test "x$BOOT_JDK_FOUND" = xno; then ohair@478: # Now execute the test ohair@478: $1 ohair@478: ohair@478: # If previous step claimed to have found a JDK, check it to see if it seems to be valid. ohair@478: if test "x$BOOT_JDK_FOUND" = xmaybe; then ohair@478: # Do we have a bin/java? ohair@478: if test ! -x "$BOOT_JDK/bin/java"; then ohair@478: AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring]) ohair@478: BOOT_JDK_FOUND=no ohair@478: else ohair@478: # Do we have a bin/javac? ohair@478: if test ! -x "$BOOT_JDK/bin/javac"; then ohair@478: AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring]) ohair@478: AC_MSG_NOTICE([(This might be an JRE instead of an JDK)]) ohair@478: BOOT_JDK_FOUND=no ihse@839: else ohair@478: # Do we have an rt.jar? (On MacOSX it is called classes.jar) ohair@478: if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then ohair@478: AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring]) ohair@478: BOOT_JDK_FOUND=no ohair@478: else ohair@478: # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? ohair@478: BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` ohair@478: ohair@478: # Extra M4 quote needed to protect [] in grep expression. ohair@478: [FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'`] ohair@478: if test "x$FOUND_VERSION_78" = x; then ohair@478: AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring]) ohair@478: AC_MSG_NOTICE([(Your Boot JDK must be version 7 or 8)]) ohair@478: BOOT_JDK_FOUND=no ohair@478: else ohair@478: # We're done! :-) ohair@478: BOOT_JDK_FOUND=yes ohair@494: BASIC_FIXUP_PATH(BOOT_JDK) ohair@478: AC_MSG_CHECKING([for Boot JDK]) ohair@494: AC_MSG_RESULT([$BOOT_JDK]) ohair@494: AC_MSG_CHECKING([Boot JDK version]) ohair@494: BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` ohair@494: AC_MSG_RESULT([$BOOT_JDK_VERSION]) ohair@478: fi # end check jdk version ohair@478: fi # end check rt.jar ohair@478: fi # end check javac ohair@478: fi # end check java ohair@478: fi # end check boot jdk found ohair@478: fi ohair@478: ]) ohair@478: ohair@478: # Test: Is bootjdk explicitely set by command line arguments? ohair@478: AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS], ohair@478: [ ihse@839: if test "x$with_boot_jdk" != x; then ohair@478: BOOT_JDK=$with_boot_jdk ohair@478: BOOT_JDK_FOUND=maybe ohair@478: AC_MSG_NOTICE([Found potential Boot JDK using configure arguments]) ihse@839: fi ohair@478: ]) ohair@478: ohair@478: # Test: Is bootjdk available from builddeps? ohair@478: AC_DEFUN([BOOTJDK_CHECK_BUILDDEPS], ohair@478: [ ihse@839: BDEPS_CHECK_MODULE(BOOT_JDK, bootjdk, xxx, [BOOT_JDK_FOUND=maybe], [BOOT_JDK_FOUND=no]) ohair@478: ]) ohair@478: ohair@478: # Test: Is $JAVA_HOME set? ohair@478: AC_DEFUN([BOOTJDK_CHECK_JAVA_HOME], ohair@478: [ ihse@839: if test "x$JAVA_HOME" != x; then ihse@839: JAVA_HOME_PROCESSED="$JAVA_HOME" ihse@839: BASIC_FIXUP_PATH(JAVA_HOME_PROCESSED) ihse@839: if test ! -d "$JAVA_HOME_PROCESSED"; then ihse@839: AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!]) ihse@839: else ihse@839: # Aha, the user has set a JAVA_HOME ihse@839: # let us use that as the Boot JDK. ihse@839: BOOT_JDK="$JAVA_HOME_PROCESSED" ihse@839: BOOT_JDK_FOUND=maybe ihse@839: AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME]) erikj@459: fi ihse@839: fi erikj@459: ]) erikj@459: ohair@478: # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? ohair@478: AC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK], erikj@459: [ ihse@839: AC_PATH_PROG(JAVAC_CHECK, javac) ihse@839: AC_PATH_PROG(JAVA_CHECK, java) ihse@839: BINARY="$JAVAC_CHECK" ihse@839: if test "x$JAVAC_CHECK" = x; then ihse@839: BINARY="$JAVA_CHECK" ihse@839: fi ihse@839: if test "x$BINARY" != x; then ihse@839: # So there is a java(c) binary, it might be part of a JDK. ihse@839: # Lets find the JDK/JRE directory by following symbolic links. ihse@839: # Linux/GNU systems often have links from /usr/bin/java to ihse@839: # /etc/alternatives/java to the real JDK binary. ihse@839: BASIC_REMOVE_SYMBOLIC_LINKS(BINARY) ihse@839: BOOT_JDK=`dirname "$BINARY"` ihse@839: BOOT_JDK=`cd "$BOOT_JDK/.."; pwd` ihse@839: if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then ihse@839: # Looks like we found ourselves an JDK ihse@839: BOOT_JDK_FOUND=maybe ihse@839: AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH]) ohair@478: fi ihse@839: fi ohair@478: ]) ohair@478: ohair@478: # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) ohair@478: AC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME], ohair@478: [ ihse@839: if test -x /usr/libexec/java_home; then ihse@839: BOOT_JDK=`/usr/libexec/java_home` ihse@839: BOOT_JDK_FOUND=maybe ihse@839: AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home]) ihse@839: fi ohair@478: ]) ohair@478: ohair@478: # Look for a jdk in the given path. If there are multiple, try to select the newest. ohair@478: # If found, set BOOT_JDK and BOOT_JDK_FOUND. ohair@478: # $1 = Path to directory containing jdk installations. ohair@478: # $2 = String to append to the found JDK directory to get the proper JDK home ohair@478: AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY], ohair@478: [ ohair@478: BOOT_JDK_PREFIX="$1" ohair@478: BOOT_JDK_SUFFIX="$2" ohair@494: ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r` ohair@494: if test "x$ALL_JDKS_FOUND" != x; then ohair@494: for JDK_TO_TRY in $ALL_JDKS_FOUND ; do ohair@494: BOOTJDK_DO_CHECK([ ohair@494: BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" ohair@494: if test -d "$BOOT_JDK"; then ohair@494: BOOT_JDK_FOUND=maybe ohair@494: AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)]) ohair@494: fi ohair@494: ]) ohair@494: done ohair@478: fi ohair@478: ]) ohair@478: ohair@478: # Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given ohair@478: # environmental variable as base for where to look. ohair@478: # $1 Name of an environmal variable, assumed to point to the Program Files directory. ohair@478: AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY], ohair@478: [ ohair@478: if test "x[$]$1" != x; then ohair@494: VIRTUAL_DIR="[$]$1/Java" ohair@494: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VIRTUAL_DIR) ohair@494: BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR) ohair@478: fi ohair@478: ]) ohair@478: ohair@478: # Test: Is there a JDK installed in default, well-known locations? ohair@478: AC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS], ohair@478: [ ohair@478: if test "x$OPENJDK_TARGET_OS" = xwindows; then ohair@478: BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])]) ohair@478: BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])]) ohair@478: BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])]) ohair@478: BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])]) ohair@478: BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])]) ohair@478: elif test "x$OPENJDK_TARGET_OS" = xmacosx; then ohair@478: BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])]) ohair@478: BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])]) ohair@494: elif test "x$OPENJDK_TARGET_OS" = xlinux; then ohair@494: BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])]) ohair@478: fi ohair@478: ]) ohair@478: ohair@478: # Check that a command-line tool in the Boot JDK is correct ohair@478: # $1 = name of variable to assign ohair@478: # $2 = name of binary ohair@478: AC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], ohair@478: [ ohair@478: AC_MSG_CHECKING([for $2 in Boot JDK]) ohair@478: $1=$BOOT_JDK/bin/$2 ohair@478: if test ! -x [$]$1; then ihse@839: AC_MSG_RESULT(not found) ihse@839: AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk]) ihse@839: AC_MSG_ERROR([Could not find $2 in the Boot JDK]) ohair@478: fi ohair@478: AC_MSG_RESULT(ok) erikj@459: ]) erikj@459: erikj@459: ############################################################################### erikj@459: # ihse@839: # We need a Boot JDK to bootstrap the build. erikj@459: # erikj@459: erikj@459: AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], erikj@459: [ ihse@839: BOOT_JDK_FOUND=no ihse@839: AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk], ihse@839: [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])]) ohair@478: ihse@839: # We look for the Boot JDK through various means, going from more certain to ihse@839: # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if ihse@839: # we detected something (if so, the path to the jdk is in BOOT_JDK). But we ihse@839: # must check if this is indeed valid; otherwise we'll continue looking. ohair@478: ihse@839: # Test: Is bootjdk explicitely set by command line arguments? ihse@839: BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS]) ihse@839: if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then ihse@839: # Having specified an argument which is incorrect will produce an instant failure; ihse@839: # we should not go on looking ihse@839: AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK]) ihse@839: fi erikj@459: ihse@839: # Test: Is bootjdk available from builddeps? ihse@839: BOOTJDK_DO_CHECK([BOOTJDK_CHECK_BUILDDEPS]) ohair@478: ihse@839: # Test: Is $JAVA_HOME set? ihse@839: BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME]) ohair@478: ihse@839: # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) ihse@839: BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME]) ohair@478: ihse@839: # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? ihse@839: BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK]) ohair@478: ihse@839: # Test: Is there a JDK installed in default, well-known locations? ihse@839: BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS]) ohair@478: ihse@839: # If we haven't found anything yet, we've truly lost. Give up. ihse@839: if test "x$BOOT_JDK_FOUND" = xno; then ihse@839: HELP_MSG_MISSING_DEPENDENCY([openjdk]) ihse@839: AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG]) ihse@839: AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk]) ihse@839: AC_MSG_ERROR([Cannot continue]) ihse@839: fi ohair@478: ihse@839: # Setup proper paths for what we found ihse@839: BOOT_RTJAR="$BOOT_JDK/jre/lib/rt.jar" ihse@839: if test ! -f "$BOOT_RTJAR"; then ohair@478: # On MacOSX it is called classes.jar ohair@478: BOOT_RTJAR="$BOOT_JDK/../Classes/classes.jar" ohair@478: if test -f "$BOOT_RTJAR"; then ihse@839: # Remove the .. ohair@478: BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}" erikj@459: fi ihse@839: fi ihse@839: BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar" ihse@839: BOOT_JDK="$BOOT_JDK" ihse@839: AC_SUBST(BOOT_RTJAR) ihse@839: AC_SUBST(BOOT_TOOLSJAR) ihse@839: AC_SUBST(BOOT_JDK) erikj@459: ihse@839: # Setup tools from the Boot JDK. ihse@839: BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA,java) ihse@839: BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC,javac) ihse@839: BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH,javah) ihse@839: BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAP,javap) ihse@839: BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR,jar) ihse@839: BOOTJDK_CHECK_TOOL_IN_BOOTJDK(RMIC,rmic) ihse@839: BOOTJDK_CHECK_TOOL_IN_BOOTJDK(NATIVE2ASCII,native2ascii) erikj@459: ihse@839: # Finally, set some other options... erikj@459: ihse@839: # When compiling code to be executed by the Boot JDK, force jdk7 compatibility. ihse@839: BOOT_JDK_SOURCETARGET="-source 7 -target 7" ihse@839: AC_SUBST(BOOT_JDK_SOURCETARGET) ihse@839: AC_SUBST(JAVAC_FLAGS) erikj@1580: erikj@1580: # Check if the boot jdk is 32 or 64 bit erikj@1580: if "$JAVA" -d64 -version > /dev/null 2>&1; then erikj@1580: BOOT_JDK_BITS="64" erikj@1580: else erikj@1580: BOOT_JDK_BITS="32" erikj@1580: fi erikj@1580: AC_MSG_CHECKING([if Boot JDK is 32 or 64 bits]) erikj@1580: AC_MSG_RESULT([$BOOT_JDK_BITS]) erikj@1580: AC_SUBST(BOOT_JDK_BITS) erikj@459: ]) erikj@459: erikj@459: AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], erikj@459: [ ihse@839: ############################################################################## ihse@839: # ihse@839: # Specify options for anything that is run with the Boot JDK. ihse@839: # ihse@839: AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs], ihse@839: [specify JVM arguments to be passed to all invocations of the Boot JDK, overriding the default values, ihse@839: e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])]) erikj@459: erikj@1187: AC_MSG_CHECKING([flags for boot jdk java command] ) erikj@459: erikj@1187: # Disable special log output when a debug build is used as Boot JDK... erikj@1187: ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA]) erikj@1187: erikj@1187: # Apply user provided options. erikj@1187: ADD_JVM_ARG_IF_OK([$with_boot_jdk_jvmargs],boot_jdk_jvmargs,[$JAVA]) erikj@1187: erikj@1187: AC_MSG_RESULT([$boot_jdk_jvmargs]) erikj@1187: erikj@1187: # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs erikj@1187: JAVA_FLAGS=$boot_jdk_jvmargs erikj@1187: AC_SUBST(JAVA_FLAGS) erikj@1187: erikj@1187: erikj@1187: AC_MSG_CHECKING([flags for boot jdk java command for big workloads]) erikj@1187: erikj@1187: # Starting amount of heap memory. erikj@1187: ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs_big,[$JAVA]) erikj@1187: erikj@1187: # Maximum amount of heap memory. erikj@1187: # Maximum stack size. erikj@1580: if test "x$BOOT_JDK_BITS" = x32; then sgehwolf@2222: JVM_MAX_HEAP=768M erikj@1187: STACK_SIZE=768 erikj@1187: else erikj@1187: # Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit erikj@1187: # pointers are used. Apparently, we need to increase the heap and stack erikj@1187: # space for the jvm. More specifically, when running javac to build huge erikj@1187: # jdk batch erikj@1187: JVM_MAX_HEAP=1600M erikj@1187: STACK_SIZE=1536 ihse@839: fi erikj@1187: ADD_JVM_ARG_IF_OK([-Xmx$JVM_MAX_HEAP],boot_jdk_jvmargs_big,[$JAVA]) erikj@1187: ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs_big,[$JAVA]) erikj@1187: ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],boot_jdk_jvmargs_big,[$JAVA]) erikj@1187: ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],boot_jdk_jvmargs_big,[$JAVA]) erikj@459: erikj@1187: AC_MSG_RESULT([$boot_jdk_jvmargs_big]) erikj@1187: erikj@1187: JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big erikj@1187: AC_SUBST(JAVA_FLAGS_BIG) erikj@1187: erikj@1187: erikj@1187: AC_MSG_CHECKING([flags for boot jdk java command for small workloads]) erikj@1187: erikj@1187: # Use serial gc for small short lived tools if possible erikj@1187: ADD_JVM_ARG_IF_OK([-XX:+UseSerialGC],boot_jdk_jvmargs_small,[$JAVA]) erikj@1187: ADD_JVM_ARG_IF_OK([-Xms32M],boot_jdk_jvmargs_small,[$JAVA]) erikj@1187: ADD_JVM_ARG_IF_OK([-Xmx512M],boot_jdk_jvmargs_small,[$JAVA]) erikj@1187: erikj@1187: AC_MSG_RESULT([$boot_jdk_jvmargs_small]) erikj@1187: erikj@1187: JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small erikj@1187: AC_SUBST(JAVA_FLAGS_SMALL) erikj@459: ])