boot-jdk.m4 revision 457:3156dff953b1
1110614Skan# 2110614Skan# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 3169691Skan# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4110614Skan# 5110614Skan# This code is free software; you can redistribute it and/or modify it 6110614Skan# under the terms of the GNU General Public License version 2 only, as 7110614Skan# published by the Free Software Foundation. Oracle designates this 8110614Skan# particular file as subject to the "Classpath" exception as provided 9110614Skan# by Oracle in the LICENSE file that accompanied this code. 10110614Skan# 11110614Skan# This code is distributed in the hope that it will be useful, but WITHOUT 12110614Skan# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13110614Skan# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14110614Skan# version 2 for more details (a copy is included in the LICENSE file that 15110614Skan# accompanied this code). 16110614Skan# 17110614Skan# You should have received a copy of the GNU General Public License version 18169691Skan# 2 along with this work; if not, write to the Free Software Foundation, 19110614Skan# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20110614Skan# 21110614Skan# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22110614Skan# or visit www.oracle.com if you need additional information or have any 23110614Skan# questions. 24110614Skan# 25110614Skan 26110614Skan# Fixes paths on windows to be mixed mode short. 27110614SkanAC_DEFUN([BOOTJDK_WIN_FIX_PATH], 28110614Skan[ 29110614Skan if test "x$OPENJDK_BUILD_OS" = "xwindows"; then 30169691Skan AC_PATH_PROG(CYGPATH, cygpath) 31169691Skan tmp="[$]$1" 32169691Skan # Convert to C:/ mixed style path without spaces. 33169691Skan tmp=`$CYGPATH -s -m "$tmp"` 34169691Skan $1="$tmp" 35110614Skan fi 36110614Skan]) 37110614Skan 38110614SkanAC_DEFUN([BOOTJDK_MISSING_ERROR], 39110614Skan[ 40110614Skan AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk]) 41110614Skan AC_MSG_ERROR([Cannot continue]) 42169691Skan]) 43169691Skan 44110614Skan############################################################################### 45110614Skan# 46132720Skan# We need a Boot JDK to bootstrap the build. 47169691Skan# 48132720Skan 49110614SkanAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], 50110614Skan[ 51132720SkanBOOT_JDK_FOUND=no 52132720SkanAC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk], 53169691Skan [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])]) 54132720Skan 55132720Skanif test "x$with_boot_jdk" != x; then 56132720Skan BOOT_JDK=$with_boot_jdk 57132720Skan BOOT_JDK_FOUND=yes 58117397Skanfi 59132720Skanif test "x$BOOT_JDK_FOUND" = xno; then 60169691Skan BDEPS_CHECK_MODULE(BOOT_JDK, boot-jdk, xxx, [BOOT_JDK_FOUND=yes], [BOOT_JDK_FOUND=no]) 61110614Skanfi 62169691Skan 63169691Skanif test "x$BOOT_JDK_FOUND" = xno; then 64169691Skan if test "x$JAVA_HOME" != x; then 65132720Skan if test ! -d "$JAVA_HOME"; then 66169691Skan AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!]) 67169691Skan BOOTJDK_MISSING_ERROR 68169691Skan fi 69169691Skan # Aha, the user has set a JAVA_HOME 70169691Skan # let us use that as the Boot JDK. 71169691Skan BOOT_JDK="$JAVA_HOME" 72169691Skan BOOT_JDK_FOUND=yes 73169691Skan # To be on the safe side, lets check that it is a JDK. 74110614Skan if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then 75110614Skan JAVAC="$BOOT_JDK/bin/javac" 76110614Skan JAVA="$BOOT_JDK/bin/java" 77110614Skan BOOT_JDK_FOUND=yes 78110614Skan else 79132720Skan AC_MSG_NOTICE([Your JAVA_HOME points to a JRE! The build needs a JDK! Please point JAVA_HOME to a JDK. JAVA_HOME=[$]JAVA_HOME]) 80110614Skan BOOTJDK_MISSING_ERROR 81132720Skan fi 82110614Skan fi 83110614Skanfi 84169691Skan 85169691Skanif test "x$BOOT_JDK_FOUND" = xno; then 86 AC_PATH_PROG(JAVAC_CHECK, javac) 87 AC_PATH_PROG(JAVA_CHECK, java) 88 BINARY="$JAVAC_CHECK" 89 if test "x$JAVAC_CHECK" = x; then 90 BINARY="$JAVA_CHECK" 91 fi 92 if test "x$BINARY" != x; then 93 # So there is a java(c) binary, it might be part of a JDK. 94 # Lets find the JDK/JRE directory by following symbolic links. 95 # Linux/GNU systems often have links from /usr/bin/java to 96 # /etc/alternatives/java to the real JDK binary. 97 WHICHCMD_SPACESAFE(BINARY,[path to javac]) 98 REMOVE_SYMBOLIC_LINKS(BINARY) 99 BOOT_JDK=`dirname $BINARY` 100 BOOT_JDK=`cd $BOOT_JDK/..; pwd` 101 if test -x $BOOT_JDK/bin/javac && test -x $BOOT_JDK/bin/java; then 102 JAVAC=$BOOT_JDK/bin/javac 103 JAVA=$BOOT_JDK/bin/java 104 BOOT_JDK_FOUND=yes 105 fi 106 fi 107fi 108 109if test "x$BOOT_JDK_FOUND" = xno; then 110 # Try the MacOSX way. 111 if test -x /usr/libexec/java_home; then 112 BOOT_JDK=`/usr/libexec/java_home` 113 if test -x $BOOT_JDK/bin/javac && test -x $BOOT_JDK/bin/java; then 114 JAVAC=$BOOT_JDK/bin/javac 115 JAVA=$BOOT_JDK/bin/java 116 BOOT_JDK_FOUND=yes 117 fi 118 fi 119fi 120 121if test "x$BOOT_JDK_FOUND" = xno; then 122 AC_PATH_PROG(JAVA_CHECK, java) 123 if test "x$JAVA_CHECK" != x; then 124 # There is a java in the path. But apparently we have not found a javac 125 # in the path, since that would have been tested earlier. 126 if test "x$OPENJDK_TARGET_OS" = xwindows; then 127 # Now if this is a windows platform. The default installation of a JDK 128 # actually puts the JRE in the path and keeps the JDK out of the path! 129 # Go look in the default installation location. 130 BOOT_JDK=/cygdrive/c/Program\ Files/Java/`ls /cygdrive/c/Program\ Files/Java | grep jdk | sort -r | head --lines 1` 131 if test -d "$BOOT_JDK"; then 132 BOOT_JDK_FOUND=yes 133 fi 134 fi 135 if test "x$BOOT_JDK_FOUND" = xno; then 136 HELP_MSG_MISSING_DEPENDENCY([openjdk]) 137 AC_MSG_NOTICE([Found a JRE, not not a JDK! Please remove the JRE from your path and put a JDK there instead. $HELP_MSG]) 138 BOOTJDK_MISSING_ERROR 139 fi 140 else 141 HELP_MSG_MISSING_DEPENDENCY([openjdk]) 142 AC_MSG_NOTICE([Could not find a JDK. $HELP_MSG]) 143 BOOTJDK_MISSING_ERROR 144 fi 145fi 146 147BOOTJDK_WIN_FIX_PATH(BOOT_JDK) 148 149# Now see if we can find the rt.jar, or its nearest equivalent. 150BOOT_RTJAR="$BOOT_JDK/jre/lib/rt.jar" 151SPACESAFE(BOOT_RTJAR,[the path to the Boot JDK rt.jar (or nearest equivalent)]) 152 153BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar" 154SPACESAFE(BOOT_TOOLSJAR,[the path to the Boot JDK tools.jar (or nearest equivalent)]) 155 156if test ! -f $BOOT_RTJAR; then 157 # On MacOSX it is called classes.jar 158 BOOT_RTJAR=$BOOT_JDK/../Classes/classes.jar 159 if test ! -f $BOOT_RTJAR; then 160 AC_MSG_NOTICE([Cannot find the rt.jar or its equivalent!]) 161 AC_MSG_NOTICE([This typically means that configure failed to automatically find a suitable Boot JDK]) 162 BOOTJDK_MISSING_ERROR 163 fi 164 # Remove the .. 165 BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}" 166 # The tools.jar is part of classes.jar 167 BOOT_TOOLSJAR="$BOOT_RTJAR" 168fi 169 170AC_SUBST(BOOT_JDK) 171AC_SUBST(BOOT_RTJAR) 172AC_SUBST(BOOT_TOOLSJAR) 173AC_MSG_CHECKING([for Boot JDK]) 174AC_MSG_RESULT([$BOOT_JDK]) 175AC_MSG_CHECKING([for Boot rt.jar]) 176AC_MSG_RESULT([$BOOT_RTJAR]) 177AC_MSG_CHECKING([for Boot tools.jar]) 178AC_MSG_RESULT([$BOOT_TOOLSJAR]) 179 180# Use the java tool from the Boot JDK. 181AC_MSG_CHECKING([for java in Boot JDK]) 182JAVA=$BOOT_JDK/bin/java 183if test ! -x $JAVA; then 184 AC_MSG_NOTICE([Could not find a working java]) 185 BOOTJDK_MISSING_ERROR 186fi 187BOOT_JDK_VERSION=`$JAVA -version 2>&1 | head -n 1` 188AC_MSG_RESULT([yes $BOOT_JDK_VERSION]) 189AC_SUBST(JAVA) 190 191# Extra M4 quote needed to protect [] in grep expression. 192[FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'`] 193if test "x$FOUND_VERSION_78" = x; then 194 HELP_MSG_MISSING_DEPENDENCY([openjdk]) 195 AC_MSG_NOTICE([Your boot-jdk must be version 7 or 8. $HELP_MSG]) 196 BOOTJDK_MISSING_ERROR 197fi 198 199# When compiling code to be executed by the Boot JDK, force jdk7 compatibility. 200BOOT_JDK_SOURCETARGET="-source 7 -target 7" 201AC_SUBST(BOOT_JDK_SOURCETARGET) 202 203# Use the javac tool from the Boot JDK. 204AC_MSG_CHECKING([for javac in Boot JDK]) 205JAVAC=$BOOT_JDK/bin/javac 206if test ! -x $JAVAC; then 207 AC_MSG_ERROR([Could not find a working javac]) 208fi 209AC_MSG_RESULT(yes) 210AC_SUBST(JAVAC) 211AC_SUBST(JAVAC_FLAGS) 212 213# Use the javah tool from the Boot JDK. 214AC_MSG_CHECKING([for javah in Boot JDK]) 215JAVAH=$BOOT_JDK/bin/javah 216if test ! -x $JAVAH; then 217 AC_MSG_NOTICE([Could not find a working javah]) 218 BOOTJDK_MISSING_ERROR 219fi 220AC_MSG_RESULT(yes) 221AC_SUBST(JAVAH) 222 223# Use the jar tool from the Boot JDK. 224AC_MSG_CHECKING([for jar in Boot JDK]) 225JAR=$BOOT_JDK/bin/jar 226if test ! -x $JAR; then 227 AC_MSG_NOTICE([Could not find a working jar]) 228 BOOTJDK_MISSING_ERROR 229fi 230AC_SUBST(JAR) 231AC_MSG_RESULT(yes) 232 233# Use the rmic tool from the Boot JDK. 234AC_MSG_CHECKING([for rmic in Boot JDK]) 235RMIC=$BOOT_JDK/bin/rmic 236if test ! -x $RMIC; then 237 AC_MSG_NOTICE([Could not find a working rmic]) 238 BOOTJDK_MISSING_ERROR 239fi 240AC_SUBST(RMIC) 241AC_MSG_RESULT(yes) 242 243# Use the native2ascii tool from the Boot JDK. 244AC_MSG_CHECKING([for native2ascii in Boot JDK]) 245NATIVE2ASCII=$BOOT_JDK/bin/native2ascii 246if test ! -x $NATIVE2ASCII; then 247 AC_MSG_NOTICE([Could not find a working native2ascii]) 248 BOOTJDK_MISSING_ERROR 249fi 250AC_MSG_RESULT(yes) 251AC_SUBST(NATIVE2ASCII) 252]) 253 254AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], 255[ 256############################################################################## 257# 258# Specify options for anything that is run with the Boot JDK. 259# 260AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs], 261 [specify JVM arguments to be passed to all invocations of the Boot JDK, overriding the default values, 262 e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])]) 263 264if test "x$with_boot_jdk_jvmargs" = x; then 265 # Not all JVM:s accept the same arguments on the command line. 266 # OpenJDK specific increase in thread stack for JDK build, 267 # well more specifically, when running javac. 268 if test "x$BUILD_NUM_BITS" = x32; then 269 STACK_SIZE=768 270 else 271 # Running Javac on a JVM on a 64-bit machine, the stack takes more space 272 # since 64-bit pointers are pushed on the stach. Apparently, we need 273 # to increase the stack space when javacing the JDK.... 274 STACK_SIZE=1536 275 fi 276 277 # Minimum amount of heap memory. 278 ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs,[$JAVA]) 279 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then 280 # Why does macosx need more heap? Its the huge JDK batch. 281 ADD_JVM_ARG_IF_OK([-Xmx1600M],boot_jdk_jvmargs,[$JAVA]) 282 else 283 ADD_JVM_ARG_IF_OK([-Xmx1100M],boot_jdk_jvmargs,[$JAVA]) 284 fi 285 # When is adding -client something that speeds up the JVM? 286 # ADD_JVM_ARG_IF_OK([-client],boot_jdk_jvmargs,[$JAVA]) 287 ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],boot_jdk_jvmargs,[$JAVA]) 288 ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],boot_jdk_jvmargs,[$JAVA]) 289 ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs,[$JAVA]) 290 # Disable special log output when a debug build is used as Boot JDK... 291 ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA]) 292fi 293 294AC_SUBST(BOOT_JDK_JVMARGS, $boot_jdk_jvmargs) 295]) 296