common/autoconf/boot-jdk.m4

Tue, 18 Sep 2012 11:29:16 -0700

author
ohair
date
Tue, 18 Sep 2012 11:29:16 -0700
changeset 478
2ba6f4da4bf3
parent 459
3156dff953b1
child 494
e64f2cb57d05
permissions
-rw-r--r--

7197849: Update new build-infra makefiles
Reviewed-by: ihse, erikj, ohrstrom, tbell

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

mercurial