< prev index next >

make/autoconf/boot-jdk.m4

Print this page


   1 #
   2 # Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any


  46 #     chain of symlinks that often ends up in a real JDK.
  47 #
  48 # This leads to the code where we check in different ways to locate a
  49 # JDK, and if one is found, check if it is acceptable. If not, we print
  50 # our reasons for rejecting it (useful when debugging non-working
  51 # configure situations) and continue checking the next one.
  52 ########################################################################
  53 
  54 # Execute the check given as argument, and verify the result
  55 # If the Boot JDK was previously found, do nothing
  56 # $1 A command line (typically autoconf macro) to execute
  57 AC_DEFUN([BOOTJDK_DO_CHECK],
  58 [
  59   if test "x$BOOT_JDK_FOUND" = xno; then
  60     # Now execute the test
  61     $1
  62 
  63     # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
  64     if test "x$BOOT_JDK_FOUND" = xmaybe; then
  65       # Do we have a bin/java?
  66       if test ! -x "$BOOT_JDK/bin/java$EXE_SUFFIX"; then
  67         AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring])
  68         BOOT_JDK_FOUND=no
  69       else
  70         # Do we have a bin/javac?
  71         if test ! -x "$BOOT_JDK/bin/javac$EXE_SUFFIX"; then
  72           AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring])
  73           AC_MSG_NOTICE([(This might be an JRE instead of an JDK)])
  74           BOOT_JDK_FOUND=no
  75         else
  76           # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
  77           BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java$EXE_SUFFIX" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $HEAD -n 1`
  78           if [ [[ "$BOOT_JDK_VERSION" =~ "Picked up" ]] ]; then
  79             AC_MSG_NOTICE([You have _JAVA_OPTIONS or JAVA_TOOL_OPTIONS set. This can mess up the build. Please use --with-boot-jdk-jvmargs instead.])
  80             AC_MSG_NOTICE([Java reports: "$BOOT_JDK_VERSION".])
  81             AC_MSG_ERROR([Cannot continue])
  82           fi
  83           if [ [[ "$BOOT_JDK_VERSION" =~ "Unrecognized option" ]] ]; then
  84             AC_MSG_NOTICE([The specified --with-boot-jdk-jvmargs is invalid for the tested java])
  85             AC_MSG_NOTICE([Error message: "$BOOT_JDK_VERSION".])
  86             AC_MSG_NOTICE([Please fix arguments, or point to an explicit boot JDK which accept these arguments])
  87             AC_MSG_ERROR([Cannot continue])
  88           fi
  89 
  90           # Extra M4 quote needed to protect [] in grep expression.
  91           [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \
  92               | $EGREP "\"(${DEFAULT_ACCEPTABLE_BOOT_VERSIONS// /|})([\.+-].*)?\""`]
  93           if test "x$FOUND_CORRECT_VERSION" = x; then
  94             AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring])
  95             AC_MSG_NOTICE([(Your Boot JDK version must be one of: $DEFAULT_ACCEPTABLE_BOOT_VERSIONS)])
  96             BOOT_JDK_FOUND=no
  97           else
  98             # We're done! :-)
  99             BOOT_JDK_FOUND=yes
 100             BASIC_FIXUP_PATH(BOOT_JDK)
 101             AC_MSG_CHECKING([for Boot JDK])
 102             AC_MSG_RESULT([$BOOT_JDK])
 103             AC_MSG_CHECKING([Boot JDK version])
 104             BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java$EXE_SUFFIX" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $TR '\n\r' '  '`
 105             AC_MSG_RESULT([$BOOT_JDK_VERSION])
 106           fi # end check jdk version
 107         fi # end check javac
 108       fi # end check java
 109     fi # end check boot jdk found
 110   fi
 111 ])
 112 
 113 # Test: Is bootjdk explicitly set by command line arguments?
 114 AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS],
 115 [
 116   if test "x$with_boot_jdk" != x; then
 117     if test -d "$with_boot_jdk"; then
 118       BOOT_JDK=$with_boot_jdk
 119       BOOT_JDK_FOUND=maybe
 120     elif test -f "$with_boot_jdk"; then
 121       case "$with_boot_jdk" in
 122         *.tar.gz )
 123             BOOT_JDK_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/boot-jdk
 124             $RM -rf $BOOT_JDK_SUPPORT_DIR


 318   # Test: Is $JAVA_HOME set?
 319   BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME])
 320 
 321   # Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
 322   BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK])
 323 
 324   # Test: Is there a JDK installed in default, well-known locations?
 325   BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS])
 326 
 327   # If we haven't found anything yet, we've truly lost. Give up.
 328   if test "x$BOOT_JDK_FOUND" = xno; then
 329     HELP_MSG_MISSING_DEPENDENCY([openjdk])
 330     AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG])
 331     AC_MSG_NOTICE([This might be fixed by explicitly setting --with-boot-jdk])
 332     AC_MSG_ERROR([Cannot continue])
 333   fi
 334 
 335   AC_SUBST(BOOT_JDK)
 336 
 337   # Setup tools from the Boot JDK.
 338   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java$EXE_SUFFIX)
 339   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac$EXE_SUFFIX)
 340   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVADOC, javadoc$EXE_SUFFIX)
 341   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar$EXE_SUFFIX)
 342   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JARSIGNER, jarsigner$EXE_SUFFIX)
 343 
 344   # Finally, set some other options...
 345 
 346   # When compiling code to be executed by the Boot JDK, force compatibility with the
 347   # oldest supported bootjdk.
 348   BOOT_JDK_SOURCETARGET="-source 9 -target 9"
 349   AC_SUBST(BOOT_JDK_SOURCETARGET)
 350 
 351   AC_SUBST(JAVAC_FLAGS)
 352 
 353   # Check if the boot jdk is 32 or 64 bit
 354   if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
 355     BOOT_JDK_BITS="64"
 356   else
 357     BOOT_JDK_BITS="32"
 358   fi
 359   AC_MSG_CHECKING([if Boot JDK is 32 or 64 bits])
 360   AC_MSG_RESULT([$BOOT_JDK_BITS])
 361 
 362   # Try to enable CDS


   1 #
   2 # Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any


  46 #     chain of symlinks that often ends up in a real JDK.
  47 #
  48 # This leads to the code where we check in different ways to locate a
  49 # JDK, and if one is found, check if it is acceptable. If not, we print
  50 # our reasons for rejecting it (useful when debugging non-working
  51 # configure situations) and continue checking the next one.
  52 ########################################################################
  53 
  54 # Execute the check given as argument, and verify the result
  55 # If the Boot JDK was previously found, do nothing
  56 # $1 A command line (typically autoconf macro) to execute
  57 AC_DEFUN([BOOTJDK_DO_CHECK],
  58 [
  59   if test "x$BOOT_JDK_FOUND" = xno; then
  60     # Now execute the test
  61     $1
  62 
  63     # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
  64     if test "x$BOOT_JDK_FOUND" = xmaybe; then
  65       # Do we have a bin/java?
  66       if test ! -x "$BOOT_JDK/bin/java"; then
  67         AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring])
  68         BOOT_JDK_FOUND=no
  69       else
  70         # Do we have a bin/javac?
  71         if test ! -x "$BOOT_JDK/bin/javac"; then
  72           AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring])
  73           AC_MSG_NOTICE([(This might be an JRE instead of an JDK)])
  74           BOOT_JDK_FOUND=no
  75         else
  76           # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
  77           BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $HEAD -n 1`
  78           if [ [[ "$BOOT_JDK_VERSION" =~ "Picked up" ]] ]; then
  79             AC_MSG_NOTICE([You have _JAVA_OPTIONS or JAVA_TOOL_OPTIONS set. This can mess up the build. Please use --with-boot-jdk-jvmargs instead.])
  80             AC_MSG_NOTICE([Java reports: "$BOOT_JDK_VERSION".])
  81             AC_MSG_ERROR([Cannot continue])
  82           fi
  83           if [ [[ "$BOOT_JDK_VERSION" =~ "Unrecognized option" ]] ]; then
  84             AC_MSG_NOTICE([The specified --with-boot-jdk-jvmargs is invalid for the tested java])
  85             AC_MSG_NOTICE([Error message: "$BOOT_JDK_VERSION".])
  86             AC_MSG_NOTICE([Please fix arguments, or point to an explicit boot JDK which accept these arguments])
  87             AC_MSG_ERROR([Cannot continue])
  88           fi
  89 
  90           # Extra M4 quote needed to protect [] in grep expression.
  91           [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \
  92               | $EGREP "\"(${DEFAULT_ACCEPTABLE_BOOT_VERSIONS// /|})([\.+-].*)?\""`]
  93           if test "x$FOUND_CORRECT_VERSION" = x; then
  94             AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring])
  95             AC_MSG_NOTICE([(Your Boot JDK version must be one of: $DEFAULT_ACCEPTABLE_BOOT_VERSIONS)])
  96             BOOT_JDK_FOUND=no
  97           else
  98             # We're done! :-)
  99             BOOT_JDK_FOUND=yes
 100             BASIC_FIXUP_PATH(BOOT_JDK)
 101             AC_MSG_CHECKING([for Boot JDK])
 102             AC_MSG_RESULT([$BOOT_JDK])
 103             AC_MSG_CHECKING([Boot JDK version])
 104             BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $TR '\n\r' '  '`
 105             AC_MSG_RESULT([$BOOT_JDK_VERSION])
 106           fi # end check jdk version
 107         fi # end check javac
 108       fi # end check java
 109     fi # end check boot jdk found
 110   fi
 111 ])
 112 
 113 # Test: Is bootjdk explicitly set by command line arguments?
 114 AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS],
 115 [
 116   if test "x$with_boot_jdk" != x; then
 117     if test -d "$with_boot_jdk"; then
 118       BOOT_JDK=$with_boot_jdk
 119       BOOT_JDK_FOUND=maybe
 120     elif test -f "$with_boot_jdk"; then
 121       case "$with_boot_jdk" in
 122         *.tar.gz )
 123             BOOT_JDK_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/boot-jdk
 124             $RM -rf $BOOT_JDK_SUPPORT_DIR


 318   # Test: Is $JAVA_HOME set?
 319   BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME])
 320 
 321   # Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
 322   BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK])
 323 
 324   # Test: Is there a JDK installed in default, well-known locations?
 325   BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS])
 326 
 327   # If we haven't found anything yet, we've truly lost. Give up.
 328   if test "x$BOOT_JDK_FOUND" = xno; then
 329     HELP_MSG_MISSING_DEPENDENCY([openjdk])
 330     AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG])
 331     AC_MSG_NOTICE([This might be fixed by explicitly setting --with-boot-jdk])
 332     AC_MSG_ERROR([Cannot continue])
 333   fi
 334 
 335   AC_SUBST(BOOT_JDK)
 336 
 337   # Setup tools from the Boot JDK.
 338   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java)
 339   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac)
 340   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVADOC, javadoc)
 341   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar)
 342   BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JARSIGNER, jarsigner)
 343 
 344   # Finally, set some other options...
 345 
 346   # When compiling code to be executed by the Boot JDK, force compatibility with the
 347   # oldest supported bootjdk.
 348   BOOT_JDK_SOURCETARGET="-source 9 -target 9"
 349   AC_SUBST(BOOT_JDK_SOURCETARGET)
 350 
 351   AC_SUBST(JAVAC_FLAGS)
 352 
 353   # Check if the boot jdk is 32 or 64 bit
 354   if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
 355     BOOT_JDK_BITS="64"
 356   else
 357     BOOT_JDK_BITS="32"
 358   fi
 359   AC_MSG_CHECKING([if Boot JDK is 32 or 64 bits])
 360   AC_MSG_RESULT([$BOOT_JDK_BITS])
 361 
 362   # Try to enable CDS


< prev index next >