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