1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/common/autoconf/boot-jdk.m4 Wed Apr 27 01:39:08 2016 +0800 1.3 @@ -0,0 +1,335 @@ 1.4 +# 1.5 +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 +# 1.8 +# This code is free software; you can redistribute it and/or modify it 1.9 +# under the terms of the GNU General Public License version 2 only, as 1.10 +# published by the Free Software Foundation. Oracle designates this 1.11 +# particular file as subject to the "Classpath" exception as provided 1.12 +# by Oracle in the LICENSE file that accompanied this code. 1.13 +# 1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 +# version 2 for more details (a copy is included in the LICENSE file that 1.18 +# accompanied this code). 1.19 +# 1.20 +# You should have received a copy of the GNU General Public License version 1.21 +# 2 along with this work; if not, write to the Free Software Foundation, 1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 +# 1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 +# or visit www.oracle.com if you need additional information or have any 1.26 +# questions. 1.27 +# 1.28 + 1.29 +# Execute the check given as argument, and verify the result 1.30 +# If the Boot JDK was previously found, do nothing 1.31 +# $1 A command line (typically autoconf macro) to execute 1.32 +AC_DEFUN([BOOTJDK_DO_CHECK], 1.33 +[ 1.34 + if test "x$BOOT_JDK_FOUND" = xno; then 1.35 + # Now execute the test 1.36 + $1 1.37 + 1.38 + # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 1.39 + if test "x$BOOT_JDK_FOUND" = xmaybe; then 1.40 + # Do we have a bin/java? 1.41 + if test ! -x "$BOOT_JDK/bin/java"; then 1.42 + AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring]) 1.43 + BOOT_JDK_FOUND=no 1.44 + else 1.45 + # Do we have a bin/javac? 1.46 + if test ! -x "$BOOT_JDK/bin/javac"; then 1.47 + AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring]) 1.48 + AC_MSG_NOTICE([(This might be an JRE instead of an JDK)]) 1.49 + BOOT_JDK_FOUND=no 1.50 + else 1.51 + # Do we have an rt.jar? (On MacOSX it is called classes.jar) 1.52 + if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then 1.53 + AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring]) 1.54 + BOOT_JDK_FOUND=no 1.55 + else 1.56 + # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 1.57 + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` 1.58 + 1.59 + # Extra M4 quote needed to protect [] in grep expression. 1.60 + [FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'`] 1.61 + if test "x$FOUND_VERSION_78" = x; then 1.62 + AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring]) 1.63 + AC_MSG_NOTICE([(Your Boot JDK must be version 7 or 8)]) 1.64 + BOOT_JDK_FOUND=no 1.65 + else 1.66 + # We're done! :-) 1.67 + BOOT_JDK_FOUND=yes 1.68 + BASIC_FIXUP_PATH(BOOT_JDK) 1.69 + AC_MSG_CHECKING([for Boot JDK]) 1.70 + AC_MSG_RESULT([$BOOT_JDK]) 1.71 + AC_MSG_CHECKING([Boot JDK version]) 1.72 + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` 1.73 + AC_MSG_RESULT([$BOOT_JDK_VERSION]) 1.74 + fi # end check jdk version 1.75 + fi # end check rt.jar 1.76 + fi # end check javac 1.77 + fi # end check java 1.78 + fi # end check boot jdk found 1.79 + fi 1.80 +]) 1.81 + 1.82 +# Test: Is bootjdk explicitely set by command line arguments? 1.83 +AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS], 1.84 +[ 1.85 + if test "x$with_boot_jdk" != x; then 1.86 + BOOT_JDK=$with_boot_jdk 1.87 + BOOT_JDK_FOUND=maybe 1.88 + AC_MSG_NOTICE([Found potential Boot JDK using configure arguments]) 1.89 + fi 1.90 +]) 1.91 + 1.92 +# Test: Is bootjdk available from builddeps? 1.93 +AC_DEFUN([BOOTJDK_CHECK_BUILDDEPS], 1.94 +[ 1.95 + BDEPS_CHECK_MODULE(BOOT_JDK, bootjdk, xxx, [BOOT_JDK_FOUND=maybe], [BOOT_JDK_FOUND=no]) 1.96 +]) 1.97 + 1.98 +# Test: Is $JAVA_HOME set? 1.99 +AC_DEFUN([BOOTJDK_CHECK_JAVA_HOME], 1.100 +[ 1.101 + if test "x$JAVA_HOME" != x; then 1.102 + JAVA_HOME_PROCESSED="$JAVA_HOME" 1.103 + BASIC_FIXUP_PATH(JAVA_HOME_PROCESSED) 1.104 + if test ! -d "$JAVA_HOME_PROCESSED"; then 1.105 + AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!]) 1.106 + else 1.107 + # Aha, the user has set a JAVA_HOME 1.108 + # let us use that as the Boot JDK. 1.109 + BOOT_JDK="$JAVA_HOME_PROCESSED" 1.110 + BOOT_JDK_FOUND=maybe 1.111 + AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME]) 1.112 + fi 1.113 + fi 1.114 +]) 1.115 + 1.116 +# Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 1.117 +AC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK], 1.118 +[ 1.119 + AC_PATH_PROG(JAVAC_CHECK, javac) 1.120 + AC_PATH_PROG(JAVA_CHECK, java) 1.121 + BINARY="$JAVAC_CHECK" 1.122 + if test "x$JAVAC_CHECK" = x; then 1.123 + BINARY="$JAVA_CHECK" 1.124 + fi 1.125 + if test "x$BINARY" != x; then 1.126 + # So there is a java(c) binary, it might be part of a JDK. 1.127 + # Lets find the JDK/JRE directory by following symbolic links. 1.128 + # Linux/GNU systems often have links from /usr/bin/java to 1.129 + # /etc/alternatives/java to the real JDK binary. 1.130 + BASIC_REMOVE_SYMBOLIC_LINKS(BINARY) 1.131 + BOOT_JDK=`dirname "$BINARY"` 1.132 + BOOT_JDK=`cd "$BOOT_JDK/.."; pwd` 1.133 + if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then 1.134 + # Looks like we found ourselves an JDK 1.135 + BOOT_JDK_FOUND=maybe 1.136 + AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH]) 1.137 + fi 1.138 + fi 1.139 +]) 1.140 + 1.141 +# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 1.142 +AC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME], 1.143 +[ 1.144 + if test -x /usr/libexec/java_home; then 1.145 + BOOT_JDK=`/usr/libexec/java_home` 1.146 + BOOT_JDK_FOUND=maybe 1.147 + AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home]) 1.148 + fi 1.149 +]) 1.150 + 1.151 +# Look for a jdk in the given path. If there are multiple, try to select the newest. 1.152 +# If found, set BOOT_JDK and BOOT_JDK_FOUND. 1.153 +# $1 = Path to directory containing jdk installations. 1.154 +# $2 = String to append to the found JDK directory to get the proper JDK home 1.155 +AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY], 1.156 +[ 1.157 + BOOT_JDK_PREFIX="$1" 1.158 + BOOT_JDK_SUFFIX="$2" 1.159 + ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r` 1.160 + if test "x$ALL_JDKS_FOUND" != x; then 1.161 + for JDK_TO_TRY in $ALL_JDKS_FOUND ; do 1.162 + BOOTJDK_DO_CHECK([ 1.163 + BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" 1.164 + if test -d "$BOOT_JDK"; then 1.165 + BOOT_JDK_FOUND=maybe 1.166 + AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)]) 1.167 + fi 1.168 + ]) 1.169 + done 1.170 + fi 1.171 +]) 1.172 + 1.173 +# Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given 1.174 +# environmental variable as base for where to look. 1.175 +# $1 Name of an environmal variable, assumed to point to the Program Files directory. 1.176 +AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY], 1.177 +[ 1.178 + if test "x[$]$1" != x; then 1.179 + VIRTUAL_DIR="[$]$1/Java" 1.180 + BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VIRTUAL_DIR) 1.181 + BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR) 1.182 + fi 1.183 +]) 1.184 + 1.185 +# Test: Is there a JDK installed in default, well-known locations? 1.186 +AC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS], 1.187 +[ 1.188 + if test "x$OPENJDK_TARGET_OS" = xwindows; then 1.189 + BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])]) 1.190 + BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])]) 1.191 + BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])]) 1.192 + BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])]) 1.193 + BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])]) 1.194 + elif test "x$OPENJDK_TARGET_OS" = xmacosx; then 1.195 + BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 1.196 + BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 1.197 + elif test "x$OPENJDK_TARGET_OS" = xlinux; then 1.198 + BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])]) 1.199 + fi 1.200 +]) 1.201 + 1.202 +# Check that a command-line tool in the Boot JDK is correct 1.203 +# $1 = name of variable to assign 1.204 +# $2 = name of binary 1.205 +AC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], 1.206 +[ 1.207 + AC_MSG_CHECKING([for $2 in Boot JDK]) 1.208 + $1=$BOOT_JDK/bin/$2 1.209 + if test ! -x [$]$1; then 1.210 + AC_MSG_RESULT(not found) 1.211 + AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk]) 1.212 + AC_MSG_ERROR([Could not find $2 in the Boot JDK]) 1.213 + fi 1.214 + AC_MSG_RESULT(ok) 1.215 +]) 1.216 + 1.217 +############################################################################### 1.218 +# 1.219 +# We need a Boot JDK to bootstrap the build. 1.220 +# 1.221 + 1.222 +AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], 1.223 +[ 1.224 + BOOT_JDK_FOUND=no 1.225 + AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk], 1.226 + [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])]) 1.227 + 1.228 + # We look for the Boot JDK through various means, going from more certain to 1.229 + # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if 1.230 + # we detected something (if so, the path to the jdk is in BOOT_JDK). But we 1.231 + # must check if this is indeed valid; otherwise we'll continue looking. 1.232 + 1.233 + # Test: Is bootjdk explicitely set by command line arguments? 1.234 + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS]) 1.235 + if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then 1.236 + # Having specified an argument which is incorrect will produce an instant failure; 1.237 + # we should not go on looking 1.238 + AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK]) 1.239 + fi 1.240 + 1.241 + # Test: Is bootjdk available from builddeps? 1.242 + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_BUILDDEPS]) 1.243 + 1.244 + # Test: Is $JAVA_HOME set? 1.245 + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME]) 1.246 + 1.247 + # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 1.248 + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME]) 1.249 + 1.250 + # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 1.251 + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK]) 1.252 + 1.253 + # Test: Is there a JDK installed in default, well-known locations? 1.254 + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS]) 1.255 + 1.256 + # If we haven't found anything yet, we've truly lost. Give up. 1.257 + if test "x$BOOT_JDK_FOUND" = xno; then 1.258 + HELP_MSG_MISSING_DEPENDENCY([openjdk]) 1.259 + AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG]) 1.260 + AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk]) 1.261 + AC_MSG_ERROR([Cannot continue]) 1.262 + fi 1.263 + 1.264 + # Setup proper paths for what we found 1.265 + BOOT_RTJAR="$BOOT_JDK/jre/lib/rt.jar" 1.266 + if test ! -f "$BOOT_RTJAR"; then 1.267 + # On MacOSX it is called classes.jar 1.268 + BOOT_RTJAR="$BOOT_JDK/../Classes/classes.jar" 1.269 + if test -f "$BOOT_RTJAR"; then 1.270 + # Remove the .. 1.271 + BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}" 1.272 + fi 1.273 + fi 1.274 + BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar" 1.275 + BOOT_JDK="$BOOT_JDK" 1.276 + AC_SUBST(BOOT_RTJAR) 1.277 + AC_SUBST(BOOT_TOOLSJAR) 1.278 + AC_SUBST(BOOT_JDK) 1.279 + 1.280 + # Setup tools from the Boot JDK. 1.281 + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA,java) 1.282 + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC,javac) 1.283 + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH,javah) 1.284 + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAP,javap) 1.285 + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR,jar) 1.286 + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(RMIC,rmic) 1.287 + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(NATIVE2ASCII,native2ascii) 1.288 + 1.289 + # Finally, set some other options... 1.290 + 1.291 + # When compiling code to be executed by the Boot JDK, force jdk7 compatibility. 1.292 + BOOT_JDK_SOURCETARGET="-source 7 -target 7" 1.293 + AC_SUBST(BOOT_JDK_SOURCETARGET) 1.294 + AC_SUBST(JAVAC_FLAGS) 1.295 +]) 1.296 + 1.297 +AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], 1.298 +[ 1.299 + ############################################################################## 1.300 + # 1.301 + # Specify options for anything that is run with the Boot JDK. 1.302 + # 1.303 + AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs], 1.304 + [specify JVM arguments to be passed to all invocations of the Boot JDK, overriding the default values, 1.305 + e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])]) 1.306 + 1.307 + if test "x$with_boot_jdk_jvmargs" = x; then 1.308 + # Not all JVM:s accept the same arguments on the command line. 1.309 + # OpenJDK specific increase in thread stack for JDK build, 1.310 + # well more specifically, when running javac. 1.311 + if test "x$BUILD_NUM_BITS" = x32; then 1.312 + STACK_SIZE=768 1.313 + else 1.314 + # Running Javac on a JVM on a 64-bit machine, the stack takes more space 1.315 + # since 64-bit pointers are pushed on the stach. Apparently, we need 1.316 + # to increase the stack space when javacing the JDK.... 1.317 + STACK_SIZE=1536 1.318 + fi 1.319 + 1.320 + # Minimum amount of heap memory. 1.321 + ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs,[$JAVA]) 1.322 + if test "x$OPENJDK_TARGET_OS" = "xmacosx" || test "x$OPENJDK_TARGET_CPU" = "xppc64" ; then 1.323 + # Why does macosx need more heap? Its the huge JDK batch. 1.324 + ADD_JVM_ARG_IF_OK([-Xmx1600M],boot_jdk_jvmargs,[$JAVA]) 1.325 + else 1.326 + ADD_JVM_ARG_IF_OK([-Xmx1100M],boot_jdk_jvmargs,[$JAVA]) 1.327 + fi 1.328 + # When is adding -client something that speeds up the JVM? 1.329 + # ADD_JVM_ARG_IF_OK([-client],boot_jdk_jvmargs,[$JAVA]) 1.330 + ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],boot_jdk_jvmargs,[$JAVA]) 1.331 + ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],boot_jdk_jvmargs,[$JAVA]) 1.332 + ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs,[$JAVA]) 1.333 + # Disable special log output when a debug build is used as Boot JDK... 1.334 + ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA]) 1.335 + fi 1.336 + 1.337 + AC_SUBST(BOOT_JDK_JVMARGS, $boot_jdk_jvmargs) 1.338 +])