annotate common/autoconf/boot-jdk.m4 @ 890:13ddc5c3ebfc

Merge
author jlaskey
date Sat, 02 Mar 2013 10:28:16 -0400
parents 2ba6f4da4bf3
children 3ef3f4174c2b 174a54ce39c4
rev   line source
erikj@457 1 #
erikj@457 2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
erikj@457 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@457 4 #
erikj@457 5 # This code is free software; you can redistribute it and/or modify it
erikj@457 6 # under the terms of the GNU General Public License version 2 only, as
erikj@457 7 # published by the Free Software Foundation. Oracle designates this
erikj@457 8 # particular file as subject to the "Classpath" exception as provided
erikj@457 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@457 10 #
erikj@457 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@457 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@457 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@457 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@457 15 # accompanied this code).
erikj@457 16 #
erikj@457 17 # You should have received a copy of the GNU General Public License version
erikj@457 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@457 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@457 20 #
erikj@457 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@457 22 # or visit www.oracle.com if you need additional information or have any
erikj@457 23 # questions.
erikj@457 24 #
erikj@457 25
ohair@476 26 # Execute the check given as argument, and verify the result
ohair@476 27 # If the Boot JDK was previously found, do nothing
ohair@476 28 # $1 A command line (typically autoconf macro) to execute
ohair@476 29 AC_DEFUN([BOOTJDK_DO_CHECK],
erikj@457 30 [
ohair@476 31 if test "x$BOOT_JDK_FOUND" = xno; then
ohair@476 32 # Now execute the test
ohair@476 33 $1
ohair@476 34
ohair@476 35 # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
ohair@476 36 if test "x$BOOT_JDK_FOUND" = xmaybe; then
ohair@476 37 # Do we have a bin/java?
ohair@476 38 if test ! -x "$BOOT_JDK/bin/java"; then
ohair@476 39 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring])
ohair@476 40 BOOT_JDK_FOUND=no
ohair@476 41 else
ohair@476 42 # Do we have a bin/javac?
ohair@476 43 if test ! -x "$BOOT_JDK/bin/javac"; then
ohair@476 44 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring])
ohair@476 45 AC_MSG_NOTICE([(This might be an JRE instead of an JDK)])
ohair@476 46 BOOT_JDK_FOUND=no
ohair@476 47 else
ohair@476 48 # Do we have an rt.jar? (On MacOSX it is called classes.jar)
ohair@476 49 if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
ohair@476 50 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring])
ohair@476 51 BOOT_JDK_FOUND=no
ohair@476 52 else
ohair@476 53 # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
ohair@476 54 BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
ohair@476 55
ohair@476 56 # Extra M4 quote needed to protect [] in grep expression.
ohair@476 57 [FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'`]
ohair@476 58 if test "x$FOUND_VERSION_78" = x; then
ohair@476 59 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring])
ohair@476 60 AC_MSG_NOTICE([(Your Boot JDK must be version 7 or 8)])
ohair@476 61 BOOT_JDK_FOUND=no
ohair@476 62 else
ohair@476 63 # We're done! :-)
ohair@476 64 BOOT_JDK_FOUND=yes
ohair@492 65 BASIC_FIXUP_PATH(BOOT_JDK)
ohair@476 66 AC_MSG_CHECKING([for Boot JDK])
ohair@492 67 AC_MSG_RESULT([$BOOT_JDK])
ohair@492 68 AC_MSG_CHECKING([Boot JDK version])
ohair@492 69 BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '`
ohair@492 70 AC_MSG_RESULT([$BOOT_JDK_VERSION])
ohair@476 71 fi # end check jdk version
ohair@476 72 fi # end check rt.jar
ohair@476 73 fi # end check javac
ohair@476 74 fi # end check java
ohair@476 75 fi # end check boot jdk found
ohair@476 76 fi
ohair@476 77 ])
ohair@476 78
ohair@476 79 # Test: Is bootjdk explicitely set by command line arguments?
ohair@476 80 AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS],
ohair@476 81 [
ohair@476 82 if test "x$with_boot_jdk" != x; then
ohair@476 83 BOOT_JDK=$with_boot_jdk
ohair@476 84 BOOT_JDK_FOUND=maybe
ohair@476 85 AC_MSG_NOTICE([Found potential Boot JDK using configure arguments])
ohair@476 86 fi
ohair@476 87 ])
ohair@476 88
ohair@476 89 # Test: Is bootjdk available from builddeps?
ohair@476 90 AC_DEFUN([BOOTJDK_CHECK_BUILDDEPS],
ohair@476 91 [
ohair@476 92 BDEPS_CHECK_MODULE(BOOT_JDK, bootjdk, xxx, [BOOT_JDK_FOUND=maybe], [BOOT_JDK_FOUND=no])
ohair@476 93 ])
ohair@476 94
ohair@476 95 # Test: Is $JAVA_HOME set?
ohair@476 96 AC_DEFUN([BOOTJDK_CHECK_JAVA_HOME],
ohair@476 97 [
ohair@476 98 if test "x$JAVA_HOME" != x; then
ohair@492 99 JAVA_HOME_PROCESSED="$JAVA_HOME"
ohair@492 100 BASIC_FIXUP_PATH(JAVA_HOME_PROCESSED)
ohair@476 101 if test ! -d "$JAVA_HOME_PROCESSED"; then
ohair@476 102 AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!])
ohair@476 103 else
ohair@476 104 # Aha, the user has set a JAVA_HOME
ohair@476 105 # let us use that as the Boot JDK.
ohair@476 106 BOOT_JDK="$JAVA_HOME_PROCESSED"
ohair@476 107 BOOT_JDK_FOUND=maybe
ohair@476 108 AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME])
ohair@476 109 fi
erikj@457 110 fi
erikj@457 111 ])
erikj@457 112
ohair@476 113 # Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
ohair@476 114 AC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK],
erikj@457 115 [
ohair@476 116 AC_PATH_PROG(JAVAC_CHECK, javac)
ohair@476 117 AC_PATH_PROG(JAVA_CHECK, java)
ohair@476 118 BINARY="$JAVAC_CHECK"
ohair@476 119 if test "x$JAVAC_CHECK" = x; then
ohair@476 120 BINARY="$JAVA_CHECK"
ohair@476 121 fi
ohair@476 122 if test "x$BINARY" != x; then
ohair@476 123 # So there is a java(c) binary, it might be part of a JDK.
ohair@476 124 # Lets find the JDK/JRE directory by following symbolic links.
ohair@476 125 # Linux/GNU systems often have links from /usr/bin/java to
ohair@476 126 # /etc/alternatives/java to the real JDK binary.
ohair@492 127 BASIC_REMOVE_SYMBOLIC_LINKS(BINARY)
ohair@476 128 BOOT_JDK=`dirname "$BINARY"`
ohair@476 129 BOOT_JDK=`cd "$BOOT_JDK/.."; pwd`
ohair@476 130 if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then
ohair@476 131 # Looks like we found ourselves an JDK
ohair@476 132 BOOT_JDK_FOUND=maybe
ohair@476 133 AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH])
ohair@476 134 fi
ohair@476 135 fi
ohair@476 136 ])
ohair@476 137
ohair@476 138 # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX)
ohair@476 139 AC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME],
ohair@476 140 [
ohair@476 141 if test -x /usr/libexec/java_home; then
ohair@476 142 BOOT_JDK=`/usr/libexec/java_home`
ohair@476 143 BOOT_JDK_FOUND=maybe
ohair@476 144 AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home])
ohair@476 145 fi
ohair@476 146 ])
ohair@476 147
ohair@476 148 # Look for a jdk in the given path. If there are multiple, try to select the newest.
ohair@476 149 # If found, set BOOT_JDK and BOOT_JDK_FOUND.
ohair@476 150 # $1 = Path to directory containing jdk installations.
ohair@476 151 # $2 = String to append to the found JDK directory to get the proper JDK home
ohair@476 152 AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY],
ohair@476 153 [
ohair@476 154 BOOT_JDK_PREFIX="$1"
ohair@476 155 BOOT_JDK_SUFFIX="$2"
ohair@492 156 ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r`
ohair@492 157 if test "x$ALL_JDKS_FOUND" != x; then
ohair@492 158 for JDK_TO_TRY in $ALL_JDKS_FOUND ; do
ohair@492 159 BOOTJDK_DO_CHECK([
ohair@492 160 BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}"
ohair@492 161 if test -d "$BOOT_JDK"; then
ohair@492 162 BOOT_JDK_FOUND=maybe
ohair@492 163 AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)])
ohair@492 164 fi
ohair@492 165 ])
ohair@492 166 done
ohair@476 167 fi
ohair@476 168 ])
ohair@476 169
ohair@476 170 # Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given
ohair@476 171 # environmental variable as base for where to look.
ohair@476 172 # $1 Name of an environmal variable, assumed to point to the Program Files directory.
ohair@476 173 AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY],
ohair@476 174 [
ohair@476 175 if test "x[$]$1" != x; then
ohair@492 176 VIRTUAL_DIR="[$]$1/Java"
ohair@492 177 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VIRTUAL_DIR)
ohair@492 178 BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR)
ohair@476 179 fi
ohair@476 180 ])
ohair@476 181
ohair@476 182 # Test: Is there a JDK installed in default, well-known locations?
ohair@476 183 AC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS],
ohair@476 184 [
ohair@476 185 if test "x$OPENJDK_TARGET_OS" = xwindows; then
ohair@476 186 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])])
ohair@476 187 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])])
ohair@476 188 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])])
ohair@476 189 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])])
ohair@476 190 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])])
ohair@476 191 elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
ohair@476 192 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])])
ohair@476 193 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])])
ohair@492 194 elif test "x$OPENJDK_TARGET_OS" = xlinux; then
ohair@492 195 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])])
ohair@476 196 fi
ohair@476 197 ])
ohair@476 198
ohair@476 199 # Check that a command-line tool in the Boot JDK is correct
ohair@476 200 # $1 = name of variable to assign
ohair@476 201 # $2 = name of binary
ohair@476 202 AC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK],
ohair@476 203 [
ohair@476 204 AC_MSG_CHECKING([for $2 in Boot JDK])
ohair@476 205 $1=$BOOT_JDK/bin/$2
ohair@476 206 if test ! -x [$]$1; then
ohair@476 207 AC_MSG_RESULT(not found)
ohair@476 208 AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk])
ohair@476 209 AC_MSG_ERROR([Could not find $2 in the Boot JDK])
ohair@476 210 fi
ohair@476 211 AC_MSG_RESULT(ok)
erikj@457 212 ])
erikj@457 213
erikj@457 214 ###############################################################################
erikj@457 215 #
erikj@457 216 # We need a Boot JDK to bootstrap the build.
erikj@457 217 #
erikj@457 218
erikj@457 219 AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK],
erikj@457 220 [
erikj@457 221 BOOT_JDK_FOUND=no
erikj@457 222 AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk],
erikj@457 223 [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])])
ohair@476 224
ohair@476 225 # We look for the Boot JDK through various means, going from more certain to
ohair@476 226 # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if
ohair@476 227 # we detected something (if so, the path to the jdk is in BOOT_JDK). But we
ohair@476 228 # must check if this is indeed valid; otherwise we'll continue looking.
ohair@476 229
ohair@476 230 # Test: Is bootjdk explicitely set by command line arguments?
ohair@476 231 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS])
ohair@476 232 if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then
ohair@476 233 # Having specified an argument which is incorrect will produce an instant failure;
ohair@476 234 # we should not go on looking
ohair@476 235 AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK])
erikj@457 236 fi
erikj@457 237
ohair@476 238 # Test: Is bootjdk available from builddeps?
ohair@476 239 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_BUILDDEPS])
ohair@476 240
ohair@476 241 # Test: Is $JAVA_HOME set?
ohair@476 242 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME])
ohair@476 243
ohair@476 244 # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX)
ohair@476 245 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME])
ohair@476 246
ohair@476 247 # Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
ohair@476 248 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK])
ohair@476 249
ohair@476 250 # Test: Is there a JDK installed in default, well-known locations?
ohair@476 251 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS])
ohair@476 252
ohair@476 253 # If we haven't found anything yet, we've truly lost. Give up.
erikj@457 254 if test "x$BOOT_JDK_FOUND" = xno; then
ohair@476 255 HELP_MSG_MISSING_DEPENDENCY([openjdk])
ohair@476 256 AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG])
ohair@476 257 AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk])
ohair@476 258 AC_MSG_ERROR([Cannot continue])
ohair@476 259 fi
ohair@476 260
ohair@476 261 # Setup proper paths for what we found
ohair@476 262 BOOT_RTJAR="$BOOT_JDK/jre/lib/rt.jar"
ohair@476 263 if test ! -f "$BOOT_RTJAR"; then
ohair@476 264 # On MacOSX it is called classes.jar
ohair@476 265 BOOT_RTJAR="$BOOT_JDK/../Classes/classes.jar"
ohair@476 266 if test -f "$BOOT_RTJAR"; then
ohair@476 267 # Remove the ..
ohair@476 268 BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}"
erikj@457 269 fi
erikj@457 270 fi
erikj@457 271 BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar"
ohair@476 272 BOOT_JDK="$BOOT_JDK"
erikj@457 273 AC_SUBST(BOOT_RTJAR)
erikj@457 274 AC_SUBST(BOOT_TOOLSJAR)
ohair@476 275 AC_SUBST(BOOT_JDK)
erikj@457 276
ohair@476 277 # Setup tools from the Boot JDK.
ohair@476 278 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA,java)
ohair@476 279 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC,javac)
ohair@476 280 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH,javah)
ohair@476 281 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAP,javap)
ohair@476 282 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR,jar)
ohair@476 283 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(RMIC,rmic)
ohair@476 284 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(NATIVE2ASCII,native2ascii)
erikj@457 285
ohair@476 286 # Finally, set some other options...
erikj@457 287
erikj@457 288 # When compiling code to be executed by the Boot JDK, force jdk7 compatibility.
erikj@457 289 BOOT_JDK_SOURCETARGET="-source 7 -target 7"
erikj@457 290 AC_SUBST(BOOT_JDK_SOURCETARGET)
erikj@457 291 AC_SUBST(JAVAC_FLAGS)
erikj@457 292 ])
erikj@457 293
erikj@457 294 AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
erikj@457 295 [
erikj@457 296 ##############################################################################
erikj@457 297 #
erikj@457 298 # Specify options for anything that is run with the Boot JDK.
erikj@457 299 #
erikj@457 300 AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs],
erikj@457 301 [specify JVM arguments to be passed to all invocations of the Boot JDK, overriding the default values,
erikj@457 302 e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])])
erikj@457 303
erikj@457 304 if test "x$with_boot_jdk_jvmargs" = x; then
erikj@457 305 # Not all JVM:s accept the same arguments on the command line.
erikj@457 306 # OpenJDK specific increase in thread stack for JDK build,
erikj@457 307 # well more specifically, when running javac.
erikj@457 308 if test "x$BUILD_NUM_BITS" = x32; then
erikj@457 309 STACK_SIZE=768
erikj@457 310 else
erikj@457 311 # Running Javac on a JVM on a 64-bit machine, the stack takes more space
erikj@457 312 # since 64-bit pointers are pushed on the stach. Apparently, we need
erikj@457 313 # to increase the stack space when javacing the JDK....
erikj@457 314 STACK_SIZE=1536
erikj@457 315 fi
erikj@457 316
erikj@457 317 # Minimum amount of heap memory.
erikj@457 318 ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs,[$JAVA])
erikj@457 319 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
erikj@457 320 # Why does macosx need more heap? Its the huge JDK batch.
erikj@457 321 ADD_JVM_ARG_IF_OK([-Xmx1600M],boot_jdk_jvmargs,[$JAVA])
erikj@457 322 else
erikj@457 323 ADD_JVM_ARG_IF_OK([-Xmx1100M],boot_jdk_jvmargs,[$JAVA])
erikj@457 324 fi
erikj@457 325 # When is adding -client something that speeds up the JVM?
erikj@457 326 # ADD_JVM_ARG_IF_OK([-client],boot_jdk_jvmargs,[$JAVA])
erikj@457 327 ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],boot_jdk_jvmargs,[$JAVA])
erikj@457 328 ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],boot_jdk_jvmargs,[$JAVA])
erikj@457 329 ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs,[$JAVA])
erikj@457 330 # Disable special log output when a debug build is used as Boot JDK...
erikj@457 331 ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA])
erikj@457 332 fi
erikj@457 333
erikj@457 334 AC_SUBST(BOOT_JDK_JVMARGS, $boot_jdk_jvmargs)
erikj@457 335 ])