boot-jdk.m4 revision 837:174a54ce39c4
138061Smsmith# 255939Snsouch# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 338061Smsmith# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 438061Smsmith# 538061Smsmith# This code is free software; you can redistribute it and/or modify it 638061Smsmith# under the terms of the GNU General Public License version 2 only, as 738061Smsmith# published by the Free Software Foundation. Oracle designates this 838061Smsmith# particular file as subject to the "Classpath" exception as provided 938061Smsmith# by Oracle in the LICENSE file that accompanied this code. 1038061Smsmith# 1138061Smsmith# This code is distributed in the hope that it will be useful, but WITHOUT 1238061Smsmith# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1338061Smsmith# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1438061Smsmith# version 2 for more details (a copy is included in the LICENSE file that 1538061Smsmith# accompanied this code). 1638061Smsmith# 1738061Smsmith# You should have received a copy of the GNU General Public License version 1838061Smsmith# 2 along with this work; if not, write to the Free Software Foundation, 1938061Smsmith# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2038061Smsmith# 2138061Smsmith# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2238061Smsmith# or visit www.oracle.com if you need additional information or have any 2338061Smsmith# questions. 2438061Smsmith# 2538061Smsmith 2638061Smsmith# Execute the check given as argument, and verify the result 2738061Smsmith# If the Boot JDK was previously found, do nothing 28119418Sobrien# $1 A command line (typically autoconf macro) to execute 29119418SobrienAC_DEFUN([BOOTJDK_DO_CHECK], 30119418Sobrien[ 3138061Smsmith if test "x$BOOT_JDK_FOUND" = xno; then 3238061Smsmith # Now execute the test 3338061Smsmith $1 34187576Sjhb 35187576Sjhb # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 3638061Smsmith if test "x$BOOT_JDK_FOUND" = xmaybe; then 3755939Snsouch # Do we have a bin/java? 3838061Smsmith if test ! -x "$BOOT_JDK/bin/java"; then 3938061Smsmith AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring]) 4038061Smsmith BOOT_JDK_FOUND=no 4138061Smsmith else 4255939Snsouch # Do we have a bin/javac? 4355939Snsouch if test ! -x "$BOOT_JDK/bin/javac"; then 4438061Smsmith AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring]) 4538061Smsmith AC_MSG_NOTICE([(This might be an JRE instead of an JDK)]) 4638061Smsmith BOOT_JDK_FOUND=no 4738061Smsmith else 4838061Smsmith # Do we have an rt.jar? (On MacOSX it is called classes.jar) 4938061Smsmith if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then 5038061Smsmith AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring]) 5138061Smsmith BOOT_JDK_FOUND=no 5238061Smsmith else 5338061Smsmith # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 5438061Smsmith BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` 5538061Smsmith 5638061Smsmith # Extra M4 quote needed to protect [] in grep expression. 5738061Smsmith [FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'`] 5855939Snsouch if test "x$FOUND_VERSION_78" = x; then 5938061Smsmith AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring]) 60184130Sjhb AC_MSG_NOTICE([(Your Boot JDK must be version 7 or 8)]) 6138061Smsmith BOOT_JDK_FOUND=no 6238061Smsmith else 6338061Smsmith # We're done! :-) 6438061Smsmith BOOT_JDK_FOUND=yes 6555939Snsouch BASIC_FIXUP_PATH(BOOT_JDK) 6638061Smsmith AC_MSG_CHECKING([for Boot JDK]) 6738061Smsmith AC_MSG_RESULT([$BOOT_JDK]) 6838061Smsmith AC_MSG_CHECKING([Boot JDK version]) 6955939Snsouch BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` 7038061Smsmith AC_MSG_RESULT([$BOOT_JDK_VERSION]) 7138061Smsmith fi # end check jdk version 7238061Smsmith fi # end check rt.jar 7387599Sobrien fi # end check javac 7438061Smsmith fi # end check java 7538061Smsmith fi # end check boot jdk found 7638061Smsmith fi 77184130Sjhb]) 78184130Sjhb 7938061Smsmith# Test: Is bootjdk explicitely set by command line arguments? 8038061SmsmithAC_DEFUN([BOOTJDK_CHECK_ARGUMENTS], 8138061Smsmith[ 8238061Smsmith if test "x$with_boot_jdk" != x; then 8338061Smsmith BOOT_JDK=$with_boot_jdk 8438061Smsmith BOOT_JDK_FOUND=maybe 8538061Smsmith AC_MSG_NOTICE([Found potential Boot JDK using configure arguments]) 8638061Smsmith fi 8738061Smsmith]) 8838061Smsmith 8955939Snsouch# Test: Is bootjdk available from builddeps? 9038061SmsmithAC_DEFUN([BOOTJDK_CHECK_BUILDDEPS], 9138061Smsmith[ 9238061Smsmith BDEPS_CHECK_MODULE(BOOT_JDK, bootjdk, xxx, [BOOT_JDK_FOUND=maybe], [BOOT_JDK_FOUND=no]) 9338061Smsmith]) 9438061Smsmith 9538061Smsmith# Test: Is $JAVA_HOME set? 9638061SmsmithAC_DEFUN([BOOTJDK_CHECK_JAVA_HOME], 9787599Sobrien[ 9838061Smsmith if test "x$JAVA_HOME" != x; then 9938061Smsmith JAVA_HOME_PROCESSED="$JAVA_HOME" 10038061Smsmith BASIC_FIXUP_PATH(JAVA_HOME_PROCESSED) 10138061Smsmith if test ! -d "$JAVA_HOME_PROCESSED"; then 10238061Smsmith AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!]) 10338061Smsmith else 10438061Smsmith # Aha, the user has set a JAVA_HOME 105184130Sjhb # let us use that as the Boot JDK. 10638061Smsmith BOOT_JDK="$JAVA_HOME_PROCESSED" 10738061Smsmith BOOT_JDK_FOUND=maybe 10838061Smsmith AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME]) 10938061Smsmith fi 11038061Smsmith fi 11138061Smsmith]) 11238061Smsmith 11338061Smsmith# Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 11438061SmsmithAC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK], 11538061Smsmith[ 11638061Smsmith AC_PATH_PROG(JAVAC_CHECK, javac) 11738061Smsmith AC_PATH_PROG(JAVA_CHECK, java) 11855939Snsouch BINARY="$JAVAC_CHECK" 11938061Smsmith if test "x$JAVAC_CHECK" = x; then 12055939Snsouch BINARY="$JAVA_CHECK" 12155939Snsouch fi 12238061Smsmith if test "x$BINARY" != x; then 123230800Sattilio # So there is a java(c) binary, it might be part of a JDK. 12438061Smsmith # Lets find the JDK/JRE directory by following symbolic links. 12538061Smsmith # Linux/GNU systems often have links from /usr/bin/java to 12638061Smsmith # /etc/alternatives/java to the real JDK binary. 12738061Smsmith BASIC_REMOVE_SYMBOLIC_LINKS(BINARY) 12838061Smsmith BOOT_JDK=`dirname "$BINARY"` 12938061Smsmith BOOT_JDK=`cd "$BOOT_JDK/.."; pwd` 13038061Smsmith if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then 13138061Smsmith # Looks like we found ourselves an JDK 13238061Smsmith BOOT_JDK_FOUND=maybe 13338061Smsmith AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH]) 13438061Smsmith fi 13538061Smsmith fi 13655939Snsouch]) 13738061Smsmith 13838061Smsmith# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 13938061SmsmithAC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME], 14043295Sdillon[ 14138061Smsmith if test -x /usr/libexec/java_home; then 14238061Smsmith BOOT_JDK=`/usr/libexec/java_home` 14338061Smsmith BOOT_JDK_FOUND=maybe 14438061Smsmith AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home]) 14538061Smsmith fi 14638061Smsmith]) 14738061Smsmith 14838061Smsmith# Look for a jdk in the given path. If there are multiple, try to select the newest. 14938061Smsmith# If found, set BOOT_JDK and BOOT_JDK_FOUND. 15038061Smsmith# $1 = Path to directory containing jdk installations. 15155939Snsouch# $2 = String to append to the found JDK directory to get the proper JDK home 15238061SmsmithAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY], 15338061Smsmith[ 15438061Smsmith BOOT_JDK_PREFIX="$1" 15538061Smsmith BOOT_JDK_SUFFIX="$2" 15638061Smsmith ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r` 15738061Smsmith if test "x$ALL_JDKS_FOUND" != x; then 15838061Smsmith for JDK_TO_TRY in $ALL_JDKS_FOUND ; do 15938061Smsmith BOOTJDK_DO_CHECK([ 16038061Smsmith BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" 16155939Snsouch if test -d "$BOOT_JDK"; then 16238061Smsmith BOOT_JDK_FOUND=maybe 16338061Smsmith AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)]) 16438061Smsmith fi 16538061Smsmith ]) 16654903Seivind done 16738061Smsmith fi 16838061Smsmith]) 16938061Smsmith 17054903Seivind# Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given 17138061Smsmith# environmental variable as base for where to look. 17238061Smsmith# $1 Name of an environmal variable, assumed to point to the Program Files directory. 17354903SeivindAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY], 17438061Smsmith[ 17538061Smsmith if test "x[$]$1" != x; then 17638061Smsmith VIRTUAL_DIR="[$]$1/Java" 17738061Smsmith BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VIRTUAL_DIR) 17838061Smsmith BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR) 17938061Smsmith fi 18038061Smsmith]) 18138061Smsmith 18238061Smsmith# Test: Is there a JDK installed in default, well-known locations? 18338061SmsmithAC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS], 18455939Snsouch[ 18538061Smsmith if test "x$OPENJDK_TARGET_OS" = xwindows; then 18638061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])]) 18738061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])]) 18838061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])]) 18938061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])]) 19038061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])]) 19138061Smsmith elif test "x$OPENJDK_TARGET_OS" = xmacosx; then 19238061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 19338061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 19438061Smsmith elif test "x$OPENJDK_TARGET_OS" = xlinux; then 19538061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])]) 19638061Smsmith fi 19738061Smsmith]) 19856618Sdfr 19938061Smsmith# Check that a command-line tool in the Boot JDK is correct 20038061Smsmith# $1 = name of variable to assign 20138061Smsmith# $2 = name of binary 20238061SmsmithAC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], 20338061Smsmith[ 20438061Smsmith AC_MSG_CHECKING([for $2 in Boot JDK]) 20538061Smsmith $1=$BOOT_JDK/bin/$2 20638061Smsmith if test ! -x [$]$1; then 20738061Smsmith AC_MSG_RESULT(not found) 20838061Smsmith AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk]) 20938061Smsmith AC_MSG_ERROR([Could not find $2 in the Boot JDK]) 21038061Smsmith fi 21138061Smsmith AC_MSG_RESULT(ok) 21238061Smsmith]) 21387599Sobrien 21438061Smsmith############################################################################### 21538061Smsmith# 216185003Sjhb# We need a Boot JDK to bootstrap the build. 21787599Sobrien# 21838061Smsmith 21938061SmsmithAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], 22038061Smsmith[ 22138061Smsmith BOOT_JDK_FOUND=no 22238061Smsmith AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk], 22338061Smsmith [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])]) 22438061Smsmith 22538061Smsmith # We look for the Boot JDK through various means, going from more certain to 22638061Smsmith # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if 22766933Sdfr # we detected something (if so, the path to the jdk is in BOOT_JDK). But we 22838061Smsmith # must check if this is indeed valid; otherwise we'll continue looking. 22938061Smsmith 23038061Smsmith # Test: Is bootjdk explicitely set by command line arguments? 23138061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS]) 23238061Smsmith if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then 23338061Smsmith # Having specified an argument which is incorrect will produce an instant failure; 23438061Smsmith # we should not go on looking 23538061Smsmith AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK]) 23638061Smsmith fi 23738061Smsmith 23838061Smsmith # Test: Is bootjdk available from builddeps? 23987599Sobrien BOOTJDK_DO_CHECK([BOOTJDK_CHECK_BUILDDEPS]) 24038061Smsmith 24138061Smsmith # Test: Is $JAVA_HOME set? 24238061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME]) 24338061Smsmith 244226385Sbrueffer # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 24538061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME]) 24638061Smsmith 24738061Smsmith # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 24838061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK]) 24938061Smsmith 25038061Smsmith # Test: Is there a JDK installed in default, well-known locations? 25138061Smsmith BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS]) 25238061Smsmith 25338061Smsmith # If we haven't found anything yet, we've truly lost. Give up. 25438061Smsmith if test "x$BOOT_JDK_FOUND" = xno; then 25555939Snsouch HELP_MSG_MISSING_DEPENDENCY([openjdk]) 25638061Smsmith AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG]) 25755939Snsouch AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk]) 25855939Snsouch AC_MSG_ERROR([Cannot continue]) 25955939Snsouch fi 26038061Smsmith 26139520Snsouch # Setup proper paths for what we found 26238061Smsmith BOOT_RTJAR="$BOOT_JDK/jre/lib/rt.jar" 26338061Smsmith if test ! -f "$BOOT_RTJAR"; then 26438061Smsmith # On MacOSX it is called classes.jar 26538061Smsmith BOOT_RTJAR="$BOOT_JDK/../Classes/classes.jar" 26638061Smsmith if test -f "$BOOT_RTJAR"; then 26738061Smsmith # Remove the .. 26838061Smsmith BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}" 26938061Smsmith fi 27038061Smsmith fi 27138061Smsmith BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar" 272187576Sjhb BOOT_JDK="$BOOT_JDK" 27338061Smsmith AC_SUBST(BOOT_RTJAR) 27438061Smsmith AC_SUBST(BOOT_TOOLSJAR) 27538061Smsmith AC_SUBST(BOOT_JDK) 27639520Snsouch 27738061Smsmith # Setup tools from the Boot JDK. 27839520Snsouch BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA,java) 27938061Smsmith BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC,javac) 280185003Sjhb BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH,javah) 28138061Smsmith BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAP,javap) 28238061Smsmith BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR,jar) 28338061Smsmith BOOTJDK_CHECK_TOOL_IN_BOOTJDK(RMIC,rmic) 28438061Smsmith BOOTJDK_CHECK_TOOL_IN_BOOTJDK(NATIVE2ASCII,native2ascii) 28555939Snsouch 28638061Smsmith # Finally, set some other options... 28738061Smsmith 28842475Snsouch # When compiling code to be executed by the Boot JDK, force jdk7 compatibility. 28942475Snsouch BOOT_JDK_SOURCETARGET="-source 7 -target 7" 29055939Snsouch AC_SUBST(BOOT_JDK_SOURCETARGET) 29155939Snsouch AC_SUBST(JAVAC_FLAGS) 29242475Snsouch]) 29342475Snsouch 29442475SnsouchAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], 29538061Smsmith[ 29642475Snsouch ############################################################################## 29742475Snsouch # 29842475Snsouch # Specify options for anything that is run with the Boot JDK. 29987599Sobrien # 30042475Snsouch AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs], 30142475Snsouch [specify JVM arguments to be passed to all invocations of the Boot JDK, overriding the default values, 30238061Smsmith e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])]) 30338061Smsmith 30438061Smsmith if test "x$with_boot_jdk_jvmargs" = x; then 30538061Smsmith # Not all JVM:s accept the same arguments on the command line. 30638061Smsmith # OpenJDK specific increase in thread stack for JDK build, 30755939Snsouch # well more specifically, when running javac. 30838061Smsmith if test "x$BUILD_NUM_BITS" = x32; then 30938061Smsmith STACK_SIZE=768 31038061Smsmith else 31138061Smsmith # Running Javac on a JVM on a 64-bit machine, the stack takes more space 31238061Smsmith # since 64-bit pointers are pushed on the stach. Apparently, we need 31338061Smsmith # to increase the stack space when javacing the JDK.... 31438061Smsmith STACK_SIZE=1536 31555939Snsouch fi 31638061Smsmith 31738061Smsmith # Minimum amount of heap memory. 31838061Smsmith ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs,[$JAVA]) 31938061Smsmith if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then 32038061Smsmith # Why does macosx need more heap? Its the huge JDK batch. 32138061Smsmith ADD_JVM_ARG_IF_OK([-Xmx1600M],boot_jdk_jvmargs,[$JAVA]) 32238061Smsmith else 323185003Sjhb ADD_JVM_ARG_IF_OK([-Xmx1100M],boot_jdk_jvmargs,[$JAVA]) 32439134Snsouch fi 32539134Snsouch # When is adding -client something that speeds up the JVM? 32638061Smsmith # ADD_JVM_ARG_IF_OK([-client],boot_jdk_jvmargs,[$JAVA]) 32738061Smsmith ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],boot_jdk_jvmargs,[$JAVA]) 32838061Smsmith ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],boot_jdk_jvmargs,[$JAVA]) 32938061Smsmith ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs,[$JAVA]) 33038061Smsmith # Disable special log output when a debug build is used as Boot JDK... 33138061Smsmith ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA]) 33238061Smsmith fi 33355939Snsouch 33455939Snsouch AC_SUBST(BOOT_JDK_JVMARGS, $boot_jdk_jvmargs) 33539520Snsouch]) 33638061Smsmith