changeset 2654:c5e686bd5a48 tip

Back port BSD support from the initial BSD port. Note that generated-configure.sh was auto-generated. This gets the configure step to succeed.
author Greg Lewis <glewis@eyesbeyond.com>
date Sun, 08 Oct 2017 09:41:08 -0700
parents 2787ba758a1a
children
files common/autoconf/boot-jdk.m4 common/autoconf/build-performance.m4 common/autoconf/flags.m4 common/autoconf/generated-configure.sh common/autoconf/help.m4 common/autoconf/jdk-options.m4 common/autoconf/libraries.m4 common/autoconf/platform.m4 common/autoconf/toolchain.m4
diffstat 9 files changed, 1078 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/common/autoconf/boot-jdk.m4	Sat Oct 07 16:28:54 2017 -0700
+++ b/common/autoconf/boot-jdk.m4	Sun Oct 08 09:41:08 2017 -0700
@@ -223,6 +223,9 @@
     BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])])
   elif test "x$OPENJDK_TARGET_OS" = xlinux; then
     BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])])
+  elif test "x$OPENJDK_TARGET_OS" = xbsd; then
+    BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/pkg/java])])
+    BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/local])])
   fi
 ])
 
--- a/common/autoconf/build-performance.m4	Sat Oct 07 16:28:54 2017 -0700
+++ b/common/autoconf/build-performance.m4	Sun Oct 08 09:41:08 2017 -0700
@@ -41,6 +41,10 @@
     # Looks like a MacOSX system
     NUM_CORES=`/usr/sbin/sysctl -n hw.ncpu`
     FOUND_CORES=yes
+  elif test -x /sbin/sysctl; then
+    # Looks like a BSD system
+    NUM_CORES=`/sbin/sysctl -n hw.ncpu`
+    FOUND_CORES=yes
   elif test "x$OPENJDK_BUILD_OS" = xaix ; then
     NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | awk '{ print [$]4 }'`
     FOUND_CORES=yes
@@ -79,6 +83,11 @@
     MEMORY_SIZE=`/usr/sbin/sysctl -n hw.memsize`
     MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
     FOUND_MEM=yes
+  elif test -x /sbin/sysctl; then
+    # Looks like a BSD system
+    MEMORY_SIZE=`/sbin/sysctl -n hw.physmem`
+    MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
+    FOUND_MEM=yes
   elif test "x$OPENJDK_BUILD_OS" = xwindows; then
     # Windows, but without cygwin
     MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-`
--- a/common/autoconf/flags.m4	Sat Oct 07 16:28:54 2017 -0700
+++ b/common/autoconf/flags.m4	Sun Oct 08 09:41:08 2017 -0700
@@ -362,8 +362,13 @@
     else
       # Default works for linux, might work on other platforms as well.
       SHARED_LIBRARY_FLAGS='-shared'
-      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
-      SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
+      if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.netbsd; then
+        # -rpath $ORIGIN is broken on NetBSD.
+        SET_EXECUTABLE_ORIGIN=''
+      else
+        SET_EXECUTABLE_ORIGIN='-Wl,-z,origin -Wl,-rpath,\$$$$ORIGIN[$]1'
+      fi
+      SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
     fi
@@ -387,18 +392,23 @@
       # Default works for linux, might work on other platforms as well.
       PICFLAG='-fPIC'
       SHARED_LIBRARY_FLAGS='-shared'
-      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
 
-      # arm specific settings
-      if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
-        # '-Wl,-z,origin' isn't used on arm.
-        SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
+      if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.netbsd; then
+        # -rpath $ORIGIN is broken on NetBSD.
+        SET_EXECUTABLE_ORIGIN=''
+        SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
       else
-        SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
+        SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
+        # arm specific settings
+        if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
+          # '-Wl,-z,origin' isn't used on arm.
+          SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
+        else
+          SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
+        fi
       fi
-
     fi
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     if test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
@@ -1006,6 +1016,10 @@
         -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
   elif test "x$OPENJDK_$1_OS" = xbsd; then
     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
+    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_ALLBSD_SOURCE"
+    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
+        -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fno-strict-aliasing \
+        -fno-omit-frame-pointer -fvisibility=hidden"
   elif test "x$OPENJDK_$1_OS" = xwindows; then
     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -nologo -W3 -MD -MP"
@@ -1136,11 +1150,14 @@
       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -machine:AMD64"
     fi
   elif test "x$TOOLCHAIN_TYPE" = xclang; then
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -mno-omit-leaf-frame-pointer -mstack-alignment=16 -stdlib=libstdc++ -fPIC"
+      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fPIC"
       if test "x$OPENJDK_$1_OS" = xmacosx; then
         # FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead.
-        $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
-    fi
+        $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -stdlib=libstdc++ -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
+      fi
+      if test "x$OPENJDK_$1_OS" = xbsd; then
+        $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Xlinker -z -Xlinker noexecstack"
+      fi
   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
     # If this is a --hash-style=gnu system, use --hash-style=both, why?
     # We have previously set HAS_GNU_HASH if this is the case
@@ -1149,8 +1166,8 @@
       $2LDFLAGS_JDK="${$2LDFLAGS_JDK} [$]$2LDFLAGS_HASH_STYLE"
       $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS [$]$2LDFLAGS_HASH_STYLE"
     fi
-      if test "x$OPENJDK_$1_OS" = xmacosx; then
-        $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
+    if test "x$OPENJDK_$1_OS" = xmacosx; then
+      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
     fi
     if test "x$OPENJDK_$1_OS" = xlinux; then
       # And since we now know that the linker is gnu, then add -z defs, to forbid
@@ -1308,6 +1325,8 @@
     fi
   elif test "x$OPENJDK_$1_OS" = xmacosx; then
     $2JVM_ASFLAGS="[$]$2JVM_ASFLAGS -x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
+  elif test "x$OPENJDK_$1_OS" = xbsd; then
+    $2JVM_ASFLAGS="[$]$2JVM_ASFLAGS -x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
   fi
 
   $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${$2EXTRA_LDFLAGS_JDK}"
--- a/common/autoconf/generated-configure.sh	Sat Oct 07 16:28:54 2017 -0700
+++ b/common/autoconf/generated-configure.sh	Sun Oct 08 09:41:08 2017 -0700
@@ -667,6 +667,8 @@
 ELF_CFLAGS
 STLPORT_LIB
 LIBZIP_CAN_USE_MMAP
+ICONV_CFLAGS
+ICONV_LIBS
 LIBDL
 LIBM
 USE_EXTERNAL_LCMS
@@ -4254,6 +4256,29 @@
   esac
 }
 
+pkg_help() {
+  case $1 in
+    openjdk)
+      PKGHANDLER_COMMAND="sudo pkg install openjdk8" ;;
+    cups)
+      PKGHANDLER_COMMAND="sudo pkg install cups-client" ;;
+    freetype)
+      PKGHANDLER_COMMAND="sudo pkg install freetype2" ;;
+    ffi)
+      PKGHANDLER_COMMAND="sudo pkg install libffi" ;;
+    x11)
+      PKGHANDLER_COMMAND="sudo pkg install libX11 libXrender libXext libXtst libXt" ;;
+    ccache)
+      PKGHANDLER_COMMAND="sudo pkg install ccache" ;;
+    unzip)
+      PKGHANDLER_COMMAND="sudo pkg install unzip" ;;
+    zip)
+      PKGHANDLER_COMMAND="sudo pkg install zip" ;;
+    make)
+      PKGHANDLER_COMMAND="sudo pkg install gmake" ;;
+  esac
+}
+
 port_help() {
   PKGHANDLER_COMMAND=""
 }
@@ -4995,6 +5020,7 @@
 VALID_TOOLCHAINS_linux="gcc clang"
 VALID_TOOLCHAINS_solaris="solstudio"
 VALID_TOOLCHAINS_macosx="gcc clang"
+VALID_TOOLCHAINS_bsd="clang gcc"
 VALID_TOOLCHAINS_aix="xlc"
 VALID_TOOLCHAINS_windows="microsoft"
 
@@ -5186,7 +5212,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1496926402
+DATE_WHEN_GENERATED=1507480762
 
 ###############################################################################
 #
@@ -15721,6 +15747,14 @@
     *bsd*)
       VAR_OS=bsd
       VAR_OS_TYPE=unix
+      case "$build_os" in
+        *freebsd*)
+          VAR_OS_ENV=bsd.freebsd ;;
+        *openbsd*)
+          VAR_OS_ENV=bsd.openbsd ;;
+        *netbsd*)
+          VAR_OS_ENV=bsd.netbsd ;;
+      esac
       ;;
     *cygwin*)
       VAR_OS=windows
@@ -15860,6 +15894,14 @@
     *bsd*)
       VAR_OS=bsd
       VAR_OS_TYPE=unix
+      case "$host_os" in
+        *freebsd*)
+          VAR_OS_ENV=bsd.freebsd ;;
+        *openbsd*)
+          VAR_OS_ENV=bsd.openbsd ;;
+        *netbsd*)
+          VAR_OS_ENV=bsd.netbsd ;;
+      esac
       ;;
     *cygwin*)
       VAR_OS=windows
@@ -15981,6 +16023,13 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" >&5
 $as_echo "$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" >&6; }
 
+  if test "x$OPENJDK_TARGET_OS_ENV" != "x$OPENJDK_TARGET_OS"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking openjdk-target os-env" >&5
+$as_echo_n "checking openjdk-target os-env... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENJDK_TARGET_OS_ENV" >&5
+$as_echo "$OPENJDK_TARGET_OS_ENV" >&6; }
+  fi
+
 
 
 # Check whether --with-target-bits was given.
@@ -16045,6 +16094,26 @@
   else
     OPENJDK_MODULE_TARGET_OS_ARCH="$OPENJDK_TARGET_CPU"
   fi
+  if test "x$OPENJDK_TARGET_OS" = "xbsd"; then
+    case "${OPENJDK_TARGET_OS_ENV}" in
+      bsd.freebsd)
+        REQUIRED_OS_NAME=FreeBSD
+        REQUIRED_OS_VERSION=9.0
+        ;;
+      bsd.openbsd)
+        REQUIRED_OS_NAME=OpenBSD
+        REQUIRED_OS_VERSION=5.0
+        ;;
+      bsd.netbsd)
+        REQUIRED_OS_NAME=NetBSD
+        REQUIRED_OS_VERSION=6.0
+        ;;
+      *)
+        REQUIRED_OS_NAME=BSD
+        REQUIRED_OS_VERSION=1.0
+        ;;
+    esac
+  fi
 
   OPENJDK_MODULE_TARGET_PLATFORM="${OPENJDK_MODULE_TARGET_OS_NAME}-${OPENJDK_MODULE_TARGET_OS_ARCH}"
 
@@ -17752,7 +17821,7 @@
 
 # Must be done before we can call HELP_MSG_MISSING_DEPENDENCY.
 
-  for ac_prog in apt-get yum brew port pkgutil pkgadd
+  for ac_prog in apt-get yum brew port pkg pkgutil pkgadd
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -24795,6 +24864,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -24868,6 +24939,9 @@
   if test "x$OPENJDK_TARGET_OS" = xaix ; then
     INCLUDE_SA=false
   fi
+  if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.openbsd || test "x$OPENJDK_TARGET_OS_ENV" = xbsd.netbsd; then
+    INCLUDE_SA=false
+  fi
 
 
   # Compress jars
@@ -30281,7 +30355,26 @@
     fi # end check boot jdk found
   fi
 
-  fi
+  elif test "x$OPENJDK_TARGET_OS" = xbsd; then
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  BOOT_JDK_PREFIX="/usr/pkg/java"
+  BOOT_JDK_SUFFIX=""
+  ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r`
+  if test "x$ALL_JDKS_FOUND" != x; then
+    for JDK_TO_TRY in $ALL_JDKS_FOUND ; do
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+        BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}"
+        if test -d "$BOOT_JDK"; then
+          BOOT_JDK_FOUND=maybe
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5
+$as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;}
+        fi
 
 
     # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
@@ -30461,6 +30554,746 @@
     fi # end check boot jdk found
   fi
 
+    done
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+          BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
+
+          # Extra M4 quote needed to protect [] in grep expression.
+          FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"|(1\.[89]\.)'`
+          if test "x$FOUND_CORRECT_VERSION" = x; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+            { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # We're done! :-)
+            BOOT_JDK_FOUND=yes
+
+  # Only process if variable expands to non-empty
+
+  if test "x$BOOT_JDK" != x; then
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$BOOT_JDK"
+  new_path=`$CYGPATH -u "$path"`
+
+  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+  # "foo.exe" is OK but "foo" is an error.
+  #
+  # This test is therefore slightly more accurate than "test -f" to check for file precense.
+  # It is also a way to make sure we got the proper file name for the real test later on.
+  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+  if test "x$test_shortpath" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-style (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    BOOT_JDK="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;}
+  fi
+
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$BOOT_JDK"
+  has_colon=`$ECHO $path | $GREP ^.:`
+  new_path="$path"
+  if test "x$has_colon" = x; then
+    # Not in mixed or Windows style, start by that.
+    new_path=`cmd //c echo $path`
+  fi
+
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  fi
+
+
+  windows_path="$new_path"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    new_path="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    new_path="$unix_path"
+  fi
+
+  if test "x$path" != "x$new_path"; then
+    BOOT_JDK="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;}
+  fi
+
+  # Save the first 10 bytes of this path to the storage, so fixpath can work.
+  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+    else
+      # We're on a unix platform. Hooray! :)
+      path="$BOOT_JDK"
+      has_space=`$ECHO "$path" | $GREP " "`
+      if test "x$has_space" != x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;}
+        as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+      fi
+
+      # Use eval to expand a potential ~
+      eval path="$path"
+      if test ! -f "$path" && test ! -d "$path"; then
+        as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+      fi
+
+      if test -d "$path"; then
+        BOOT_JDK="`cd "$path"; $THEPWDCMD -L`"
+      else
+        dir="`$DIRNAME "$path"`"
+        base="`$BASENAME "$path"`"
+        BOOT_JDK="`cd "$dir"; $THEPWDCMD -L`/$base"
+      fi
+    fi
+  fi
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5
+$as_echo "$BOOT_JDK" >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5
+$as_echo_n "checking Boot JDK version... " >&6; }
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' '  '`
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5
+$as_echo "$BOOT_JDK_VERSION" >&6; }
+          fi # end check jdk version
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  BOOT_JDK_PREFIX="/usr/local"
+  BOOT_JDK_SUFFIX=""
+  ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r`
+  if test "x$ALL_JDKS_FOUND" != x; then
+    for JDK_TO_TRY in $ALL_JDKS_FOUND ; do
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+        BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}"
+        if test -d "$BOOT_JDK"; then
+          BOOT_JDK_FOUND=maybe
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5
+$as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;}
+        fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+          BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
+
+          # Extra M4 quote needed to protect [] in grep expression.
+          FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"|(1\.[89]\.)'`
+          if test "x$FOUND_CORRECT_VERSION" = x; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+            { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # We're done! :-)
+            BOOT_JDK_FOUND=yes
+
+  # Only process if variable expands to non-empty
+
+  if test "x$BOOT_JDK" != x; then
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$BOOT_JDK"
+  new_path=`$CYGPATH -u "$path"`
+
+  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+  # "foo.exe" is OK but "foo" is an error.
+  #
+  # This test is therefore slightly more accurate than "test -f" to check for file precense.
+  # It is also a way to make sure we got the proper file name for the real test later on.
+  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+  if test "x$test_shortpath" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-style (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    BOOT_JDK="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;}
+  fi
+
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$BOOT_JDK"
+  has_colon=`$ECHO $path | $GREP ^.:`
+  new_path="$path"
+  if test "x$has_colon" = x; then
+    # Not in mixed or Windows style, start by that.
+    new_path=`cmd //c echo $path`
+  fi
+
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  fi
+
+
+  windows_path="$new_path"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    new_path="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    new_path="$unix_path"
+  fi
+
+  if test "x$path" != "x$new_path"; then
+    BOOT_JDK="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;}
+  fi
+
+  # Save the first 10 bytes of this path to the storage, so fixpath can work.
+  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+    else
+      # We're on a unix platform. Hooray! :)
+      path="$BOOT_JDK"
+      has_space=`$ECHO "$path" | $GREP " "`
+      if test "x$has_space" != x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;}
+        as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+      fi
+
+      # Use eval to expand a potential ~
+      eval path="$path"
+      if test ! -f "$path" && test ! -d "$path"; then
+        as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+      fi
+
+      if test -d "$path"; then
+        BOOT_JDK="`cd "$path"; $THEPWDCMD -L`"
+      else
+        dir="`$DIRNAME "$path"`"
+        base="`$BASENAME "$path"`"
+        BOOT_JDK="`cd "$dir"; $THEPWDCMD -L`/$base"
+      fi
+    fi
+  fi
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5
+$as_echo "$BOOT_JDK" >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5
+$as_echo_n "checking Boot JDK version... " >&6; }
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' '  '`
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5
+$as_echo "$BOOT_JDK_VERSION" >&6; }
+          fi # end check jdk version
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+    done
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+          BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
+
+          # Extra M4 quote needed to protect [] in grep expression.
+          FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"|(1\.[89]\.)'`
+          if test "x$FOUND_CORRECT_VERSION" = x; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+            { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # We're done! :-)
+            BOOT_JDK_FOUND=yes
+
+  # Only process if variable expands to non-empty
+
+  if test "x$BOOT_JDK" != x; then
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$BOOT_JDK"
+  new_path=`$CYGPATH -u "$path"`
+
+  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+  # "foo.exe" is OK but "foo" is an error.
+  #
+  # This test is therefore slightly more accurate than "test -f" to check for file precense.
+  # It is also a way to make sure we got the proper file name for the real test later on.
+  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+  if test "x$test_shortpath" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-style (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    BOOT_JDK="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;}
+  fi
+
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$BOOT_JDK"
+  has_colon=`$ECHO $path | $GREP ^.:`
+  new_path="$path"
+  if test "x$has_colon" = x; then
+    # Not in mixed or Windows style, start by that.
+    new_path=`cmd //c echo $path`
+  fi
+
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  fi
+
+
+  windows_path="$new_path"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    new_path="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    new_path="$unix_path"
+  fi
+
+  if test "x$path" != "x$new_path"; then
+    BOOT_JDK="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;}
+  fi
+
+  # Save the first 10 bytes of this path to the storage, so fixpath can work.
+  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+    else
+      # We're on a unix platform. Hooray! :)
+      path="$BOOT_JDK"
+      has_space=`$ECHO "$path" | $GREP " "`
+      if test "x$has_space" != x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;}
+        as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+      fi
+
+      # Use eval to expand a potential ~
+      eval path="$path"
+      if test ! -f "$path" && test ! -d "$path"; then
+        as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+      fi
+
+      if test -d "$path"; then
+        BOOT_JDK="`cd "$path"; $THEPWDCMD -L`"
+      else
+        dir="`$DIRNAME "$path"`"
+        base="`$BASENAME "$path"`"
+        BOOT_JDK="`cd "$dir"; $THEPWDCMD -L`/$base"
+      fi
+    fi
+  fi
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5
+$as_echo "$BOOT_JDK" >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5
+$as_echo_n "checking Boot JDK version... " >&6; }
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' '  '`
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5
+$as_echo "$BOOT_JDK_VERSION" >&6; }
+          fi # end check jdk version
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+          BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
+
+          # Extra M4 quote needed to protect [] in grep expression.
+          FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"|(1\.[89]\.)'`
+          if test "x$FOUND_CORRECT_VERSION" = x; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+            { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # We're done! :-)
+            BOOT_JDK_FOUND=yes
+
+  # Only process if variable expands to non-empty
+
+  if test "x$BOOT_JDK" != x; then
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$BOOT_JDK"
+  new_path=`$CYGPATH -u "$path"`
+
+  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+  # "foo.exe" is OK but "foo" is an error.
+  #
+  # This test is therefore slightly more accurate than "test -f" to check for file precense.
+  # It is also a way to make sure we got the proper file name for the real test later on.
+  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+  if test "x$test_shortpath" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-style (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    BOOT_JDK="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;}
+  fi
+
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$BOOT_JDK"
+  has_colon=`$ECHO $path | $GREP ^.:`
+  new_path="$path"
+  if test "x$has_colon" = x; then
+    # Not in mixed or Windows style, start by that.
+    new_path=`cmd //c echo $path`
+  fi
+
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  fi
+
+
+  windows_path="$new_path"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    new_path="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    new_path="$unix_path"
+  fi
+
+  if test "x$path" != "x$new_path"; then
+    BOOT_JDK="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;}
+  fi
+
+  # Save the first 10 bytes of this path to the storage, so fixpath can work.
+  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+    else
+      # We're on a unix platform. Hooray! :)
+      path="$BOOT_JDK"
+      has_space=`$ECHO "$path" | $GREP " "`
+      if test "x$has_space" != x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;}
+        as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+      fi
+
+      # Use eval to expand a potential ~
+      eval path="$path"
+      if test ! -f "$path" && test ! -d "$path"; then
+        as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+      fi
+
+      if test -d "$path"; then
+        BOOT_JDK="`cd "$path"; $THEPWDCMD -L`"
+      else
+        dir="`$DIRNAME "$path"`"
+        base="`$BASENAME "$path"`"
+        BOOT_JDK="`cd "$dir"; $THEPWDCMD -L`/$base"
+      fi
+    fi
+  fi
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5
+$as_echo "$BOOT_JDK" >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5
+$as_echo_n "checking Boot JDK version... " >&6; }
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' '  '`
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5
+$as_echo "$BOOT_JDK_VERSION" >&6; }
+          fi # end check jdk version
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
 
   # If we haven't found anything yet, we've truly lost. Give up.
   if test "x$BOOT_JDK_FOUND" = xno; then
@@ -30485,6 +31318,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -31848,6 +32683,10 @@
   # Use indirect variable referencing
   toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
   VALID_TOOLCHAINS=${!toolchain_var_name}
+  if test "x$VALID_TOOLCHAINS" = x; then
+    # For portability, assume gcc and clang for unknown platforms
+    VALID_TOOLCHAINS="gcc clang"
+  fi
 
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
     if test -n "$XCODEBUILD"; then
@@ -33879,6 +34718,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -35286,6 +36127,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -43308,7 +44151,7 @@
 
   # objcopy is used for moving debug symbols to separate files when
   # full debug symbols are enabled.
-  if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
+  if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
 
 
   # Publish this variable in the help.
@@ -49647,6 +50490,11 @@
     JVM_LDFLAGS="$JVM_LDFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
     JVM_ASFLAGS="$JVM_ASFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   fi
+  if test "x$OPENJDK_TARGET_OS" = xbsd; then
+    JVM_CFLAGS="$JVM_CFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
+    JVM_LDFLAGS="$JVM_LDFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
+    JVM_ASFLAGS="$JVM_ASFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
+  fi
 
   # Make compilation sanity check
   for ac_header in stdio.h
@@ -49683,6 +50531,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -49846,6 +50696,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -50134,8 +50986,13 @@
     else
       # Default works for linux, might work on other platforms as well.
       SHARED_LIBRARY_FLAGS='-shared'
-      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN$1'
-      SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
+      if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.netbsd; then
+        # -rpath $ORIGIN is broken on NetBSD.
+        SET_EXECUTABLE_ORIGIN=''
+      else
+        SET_EXECUTABLE_ORIGIN='-Wl,-z,origin -Wl,-rpath,\$$$$ORIGIN$1'
+      fi
+      SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
       SET_SHARED_LIBRARY_NAME='-Wl,-soname=$1'
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1'
     fi
@@ -50159,18 +51016,23 @@
       # Default works for linux, might work on other platforms as well.
       PICFLAG='-fPIC'
       SHARED_LIBRARY_FLAGS='-shared'
-      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN$1'
       SET_SHARED_LIBRARY_NAME='-Wl,-soname=$1'
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1'
 
-      # arm specific settings
-      if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
-        # '-Wl,-z,origin' isn't used on arm.
-        SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN$1'
-      else
-        SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
-      fi
-
+      if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.netbsd; then
+        # -rpath $ORIGIN is broken on NetBSD.
+        SET_EXECUTABLE_ORIGIN=''
+        SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
+      else
+        SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN$1'
+        # arm specific settings
+        if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
+          # '-Wl,-z,origin' isn't used on arm.
+          SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN$1'
+        else
+          SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
+        fi
+      fi
     fi
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     if test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
@@ -51271,6 +52133,10 @@
         -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
+    JVM_CFLAGS="$JVM_CFLAGS -D_ALLBSD_SOURCE"
+    JVM_CFLAGS="$JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
+        -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fno-strict-aliasing \
+        -fno-omit-frame-pointer -fvisibility=hidden"
   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
     JVM_CFLAGS="$JVM_CFLAGS -D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
     JVM_CFLAGS="$JVM_CFLAGS -nologo -W3 -MD -MP"
@@ -51490,11 +52356,14 @@
       JVM_LDFLAGS="$JVM_LDFLAGS -machine:AMD64"
     fi
   elif test "x$TOOLCHAIN_TYPE" = xclang; then
-      JVM_LDFLAGS="$JVM_LDFLAGS -mno-omit-leaf-frame-pointer -mstack-alignment=16 -stdlib=libstdc++ -fPIC"
+      JVM_LDFLAGS="$JVM_LDFLAGS -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fPIC"
       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
         # FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead.
-        JVM_LDFLAGS="$JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
-    fi
+        JVM_LDFLAGS="$JVM_LDFLAGS -stdlib=libstdc++ -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
+      fi
+      if test "x$OPENJDK_TARGET_OS" = xbsd; then
+        JVM_LDFLAGS="$JVM_LDFLAGS -Xlinker -z -Xlinker noexecstack"
+      fi
   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
     # If this is a --hash-style=gnu system, use --hash-style=both, why?
     # We have previously set HAS_GNU_HASH if this is the case
@@ -51503,8 +52372,8 @@
       LDFLAGS_JDK="${LDFLAGS_JDK} $LDFLAGS_HASH_STYLE"
       JVM_LDFLAGS="$JVM_LDFLAGS $LDFLAGS_HASH_STYLE"
     fi
-      if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-        JVM_LDFLAGS="$JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
+    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+      JVM_LDFLAGS="$JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
     fi
     if test "x$OPENJDK_TARGET_OS" = xlinux; then
       # And since we now know that the linker is gnu, then add -z defs, to forbid
@@ -51662,6 +52531,8 @@
     fi
   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
     JVM_ASFLAGS="$JVM_ASFLAGS -x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
+  elif test "x$OPENJDK_TARGET_OS" = xbsd; then
+    JVM_ASFLAGS="$JVM_ASFLAGS -x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
   fi
 
   LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} ${EXTRA_LDFLAGS_JDK}"
@@ -52089,6 +52960,10 @@
         -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
   elif test "x$OPENJDK_BUILD_OS" = xbsd; then
     OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
+    OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -D_ALLBSD_SOURCE"
+    OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
+        -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fno-strict-aliasing \
+        -fno-omit-frame-pointer -fvisibility=hidden"
   elif test "x$OPENJDK_BUILD_OS" = xwindows; then
     OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
     OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -nologo -W3 -MD -MP"
@@ -52308,11 +53183,14 @@
       OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -machine:AMD64"
     fi
   elif test "x$TOOLCHAIN_TYPE" = xclang; then
-      OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -mno-omit-leaf-frame-pointer -mstack-alignment=16 -stdlib=libstdc++ -fPIC"
+      OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fPIC"
       if test "x$OPENJDK_BUILD_OS" = xmacosx; then
         # FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead.
-        OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
-    fi
+        OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -stdlib=libstdc++ -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
+      fi
+      if test "x$OPENJDK_BUILD_OS" = xbsd; then
+        OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -Xlinker -z -Xlinker noexecstack"
+      fi
   elif test "x$TOOLCHAIN_TYPE" = xgcc; then
     # If this is a --hash-style=gnu system, use --hash-style=both, why?
     # We have previously set HAS_GNU_HASH if this is the case
@@ -52321,8 +53199,8 @@
       OPENJDK_BUILD_LDFLAGS_JDK="${OPENJDK_BUILD_LDFLAGS_JDK} $OPENJDK_BUILD_LDFLAGS_HASH_STYLE"
       OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS $OPENJDK_BUILD_LDFLAGS_HASH_STYLE"
     fi
-      if test "x$OPENJDK_BUILD_OS" = xmacosx; then
-        OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
+    if test "x$OPENJDK_BUILD_OS" = xmacosx; then
+      OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
     fi
     if test "x$OPENJDK_BUILD_OS" = xlinux; then
       # And since we now know that the linker is gnu, then add -z defs, to forbid
@@ -52480,6 +53358,8 @@
     fi
   elif test "x$OPENJDK_BUILD_OS" = xmacosx; then
     OPENJDK_BUILD_JVM_ASFLAGS="$OPENJDK_BUILD_JVM_ASFLAGS -x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
+  elif test "x$OPENJDK_BUILD_OS" = xbsd; then
+    OPENJDK_BUILD_JVM_ASFLAGS="$OPENJDK_BUILD_JVM_ASFLAGS -x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
   fi
 
   OPENJDK_BUILD_LDFLAGS_JDKLIB="${OPENJDK_BUILD_LDFLAGS_JDKLIB} ${OPENJDK_BUILD_EXTRA_LDFLAGS_JDK}"
@@ -53450,7 +54330,7 @@
 
   if test "x$NATIVE_DEBUG_SYMBOLS" = xzipped; then
 
-    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
+    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
       if test "x$OBJCOPY" = x; then
         # enabling of enable-debug-symbols and can't find objcopy
         # this is an error
@@ -53471,7 +54351,7 @@
     ZIP_EXTERNAL_DEBUG_SYMBOLS=false
   elif test "x$NATIVE_DEBUG_SYMBOLS" = xexternal; then
 
-    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
+    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
       if test "x$OBJCOPY" = x; then
         # enabling of enable-debug-symbols and can't find objcopy
         # this is an error
@@ -53636,6 +54516,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -57442,6 +58324,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -57516,6 +58400,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -57661,6 +58547,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -63266,6 +64154,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -63623,6 +64513,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -63977,6 +64869,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -64167,6 +65061,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -64248,6 +65144,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -65012,6 +65910,16 @@
 
   LIBS="$save_LIBS"
 
+  # The iconv library
+  ICONV_LIBS=-liconv
+  if test "x$OPENJDK_TARGET_OS_ENV" = "xbsd.openbsd"; then
+    ICONV_CFLAGS="-I/usr/local/include"
+  else
+    ICONV_CFLAGS=
+  fi
+
+
+
   # Deprecated libraries, keep the flags for backwards compatibility
   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 
@@ -65369,6 +66277,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -65455,6 +66365,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -65817,6 +66729,10 @@
     # Looks like a MacOSX system
     NUM_CORES=`/usr/sbin/sysctl -n hw.ncpu`
     FOUND_CORES=yes
+  elif test -x /sbin/sysctl; then
+    # Looks like a BSD system
+    NUM_CORES=`/sbin/sysctl -n hw.ncpu`
+    FOUND_CORES=yes
   elif test "x$OPENJDK_BUILD_OS" = xaix ; then
     NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | awk '{ print $4 }'`
     FOUND_CORES=yes
@@ -65872,6 +66788,11 @@
     MEMORY_SIZE=`/usr/sbin/sysctl -n hw.memsize`
     MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
     FOUND_MEM=yes
+  elif test -x /sbin/sysctl; then
+    # Looks like a BSD system
+    MEMORY_SIZE=`/sbin/sysctl -n hw.physmem`
+    MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
+    FOUND_MEM=yes
   elif test "x$OPENJDK_BUILD_OS" = xwindows; then
     # Windows, but without cygwin
     MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-`
--- a/common/autoconf/help.m4	Sat Oct 07 16:28:54 2017 -0700
+++ b/common/autoconf/help.m4	Sun Oct 08 09:41:08 2017 -0700
@@ -25,7 +25,7 @@
 
 AC_DEFUN_ONCE([HELP_SETUP_DEPENDENCY_HELP],
 [
-  AC_CHECK_PROGS(PKGHANDLER, apt-get yum brew port pkgutil pkgadd)
+  AC_CHECK_PROGS(PKGHANDLER, apt-get yum brew port pkg pkgutil pkgadd)
 ])
 
 AC_DEFUN([HELP_MSG_MISSING_DEPENDENCY],
@@ -50,6 +50,8 @@
         brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
+      pkg)
+        pkg_help    $MISSING_DEPENDENCY ;;
       pkgutil)
         pkgutil_help $MISSING_DEPENDENCY ;;
       pkgadd)
@@ -160,6 +162,29 @@
   esac
 }
 
+pkg_help() {
+  case $1 in
+    openjdk)
+      PKGHANDLER_COMMAND="sudo pkg install openjdk8" ;;
+    cups)
+      PKGHANDLER_COMMAND="sudo pkg install cups-client" ;;
+    freetype)
+      PKGHANDLER_COMMAND="sudo pkg install freetype2" ;;
+    ffi)
+      PKGHANDLER_COMMAND="sudo pkg install libffi" ;;
+    x11)
+      PKGHANDLER_COMMAND="sudo pkg install libX11 libXrender libXext libXtst libXt" ;;
+    ccache)
+      PKGHANDLER_COMMAND="sudo pkg install ccache" ;;
+    unzip)
+      PKGHANDLER_COMMAND="sudo pkg install unzip" ;;
+    zip)
+      PKGHANDLER_COMMAND="sudo pkg install zip" ;;
+    make)      
+      PKGHANDLER_COMMAND="sudo pkg install gmake" ;;
+  esac
+}
+
 port_help() {
   PKGHANDLER_COMMAND=""
 }
--- a/common/autoconf/jdk-options.m4	Sat Oct 07 16:28:54 2017 -0700
+++ b/common/autoconf/jdk-options.m4	Sun Oct 08 09:41:08 2017 -0700
@@ -230,6 +230,9 @@
   if test "x$OPENJDK_TARGET_OS" = xaix ; then
     INCLUDE_SA=false
   fi
+  if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.openbsd || test "x$OPENJDK_TARGET_OS_ENV" = xbsd.netbsd; then
+    INCLUDE_SA=false
+  fi
   AC_SUBST(INCLUDE_SA)
 
   # Compress jars
@@ -303,7 +306,7 @@
 
   if test "x$NATIVE_DEBUG_SYMBOLS" = xzipped; then
 
-    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
+    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
       if test "x$OBJCOPY" = x; then
         # enabling of enable-debug-symbols and can't find objcopy
         # this is an error
@@ -324,7 +327,7 @@
     ZIP_EXTERNAL_DEBUG_SYMBOLS=false
   elif test "x$NATIVE_DEBUG_SYMBOLS" = xexternal; then
 
-    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
+    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
       if test "x$OBJCOPY" = x; then
         # enabling of enable-debug-symbols and can't find objcopy
         # this is an error
--- a/common/autoconf/libraries.m4	Sat Oct 07 16:28:54 2017 -0700
+++ b/common/autoconf/libraries.m4	Sun Oct 08 09:41:08 2017 -0700
@@ -174,6 +174,16 @@
   LIBDL="$LIBS"
   AC_SUBST(LIBDL)
   LIBS="$save_LIBS"
+  
+  # The iconv library
+  ICONV_LIBS=-liconv
+  if test "x$OPENJDK_TARGET_OS_ENV" = "xbsd.openbsd"; then
+    ICONV_CFLAGS="-I/usr/local/include"
+  else
+    ICONV_CFLAGS=
+  fi
+  AC_SUBST(ICONV_LIBS)
+  AC_SUBST(ICONV_CFLAGS)
 
   # Deprecated libraries, keep the flags for backwards compatibility
   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
--- a/common/autoconf/platform.m4	Sat Oct 07 16:28:54 2017 -0700
+++ b/common/autoconf/platform.m4	Sun Oct 08 09:41:08 2017 -0700
@@ -123,6 +123,14 @@
     *bsd*)
       VAR_OS=bsd
       VAR_OS_TYPE=unix
+      case "$1" in
+        *freebsd*)
+          VAR_OS_ENV=bsd.freebsd ;;
+        *openbsd*)
+          VAR_OS_ENV=bsd.openbsd ;;
+        *netbsd*)
+          VAR_OS_ENV=bsd.netbsd ;;
+      esac
       ;;
     *cygwin*)
       VAR_OS=windows
@@ -218,6 +226,11 @@
 
   AC_MSG_CHECKING([openjdk-target os-cpu])
   AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
+
+  if test "x$OPENJDK_TARGET_OS_ENV" != "x$OPENJDK_TARGET_OS"; then
+    AC_MSG_CHECKING([openjdk-target os-env])
+    AC_MSG_RESULT([$OPENJDK_TARGET_OS_ENV])
+  fi
 ])
 
 # Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
@@ -469,6 +482,26 @@
   else
     OPENJDK_MODULE_TARGET_OS_ARCH="$OPENJDK_TARGET_CPU"
   fi
+  if test "x$OPENJDK_TARGET_OS" = "xbsd"; then
+    case "${OPENJDK_TARGET_OS_ENV}" in
+      bsd.freebsd)
+        REQUIRED_OS_NAME=FreeBSD
+        REQUIRED_OS_VERSION=9.0
+        ;;
+      bsd.openbsd)
+        REQUIRED_OS_NAME=OpenBSD
+        REQUIRED_OS_VERSION=5.0
+        ;;
+      bsd.netbsd)
+        REQUIRED_OS_NAME=NetBSD
+        REQUIRED_OS_VERSION=6.0
+        ;;
+      *)
+        REQUIRED_OS_NAME=BSD
+        REQUIRED_OS_VERSION=1.0
+        ;;
+    esac
+  fi
 
   OPENJDK_MODULE_TARGET_PLATFORM="${OPENJDK_MODULE_TARGET_OS_NAME}-${OPENJDK_MODULE_TARGET_OS_ARCH}"
   AC_SUBST(OPENJDK_MODULE_TARGET_PLATFORM)
@@ -557,6 +590,11 @@
     JVM_LDFLAGS="$JVM_LDFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
     JVM_ASFLAGS="$JVM_ASFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
   fi
+  if test "x$OPENJDK_TARGET_OS" = xbsd; then
+    JVM_CFLAGS="$JVM_CFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
+    JVM_LDFLAGS="$JVM_LDFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
+    JVM_ASFLAGS="$JVM_ASFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
+  fi
 
   # Make compilation sanity check
   AC_CHECK_HEADERS([stdio.h], , [
--- a/common/autoconf/toolchain.m4	Sat Oct 07 16:28:54 2017 -0700
+++ b/common/autoconf/toolchain.m4	Sun Oct 08 09:41:08 2017 -0700
@@ -40,6 +40,7 @@
 VALID_TOOLCHAINS_linux="gcc clang"
 VALID_TOOLCHAINS_solaris="solstudio"
 VALID_TOOLCHAINS_macosx="gcc clang"
+VALID_TOOLCHAINS_bsd="clang gcc"
 VALID_TOOLCHAINS_aix="xlc"
 VALID_TOOLCHAINS_windows="microsoft"
 
@@ -171,6 +172,10 @@
   # Use indirect variable referencing
   toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
   VALID_TOOLCHAINS=${!toolchain_var_name}
+  if test "x$VALID_TOOLCHAINS" = x; then
+    # For portability, assume gcc and clang for unknown platforms
+    VALID_TOOLCHAINS="gcc clang"
+  fi
 
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
     if test -n "$XCODEBUILD"; then
@@ -671,7 +676,7 @@
 
   # objcopy is used for moving debug symbols to separate files when
   # full debug symbols are enabled.
-  if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
+  if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
     BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
     # Only call fixup if objcopy was found.
     if test -n "$OBJCOPY"; then