changeset 1918:da64f4380984

Merge from main OpenJDK repository
author Greg Lewis <glewis@eyesbeyond.com>
date Sat, 28 Jan 2017 19:01:56 -0800
parents f2b5b6ab1f55 5ad0370d06b1
children af5ddef75a84
files
diffstat 12 files changed, 528 insertions(+), 91 deletions(-) [+]
line wrap: on
line diff
--- a/common/autoconf/build-performance.m4	Mon Dec 05 13:09:07 2016 -0800
+++ b/common/autoconf/build-performance.m4	Sat Jan 28 19:01:56 2017 -0800
@@ -41,6 +41,10 @@
     # Looks like a MacOSX system
     NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk  '{print [$]5}'`
     FOUND_CORES=yes
+  elif test "x$OPENJDK_BUILD_OS" = xbsd && test "x$(uname -s | grep -o BSD)" = xBSD; 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,15 @@
     MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk  '{print [$]2}'`
     MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024`
     FOUND_MEM=yes
+  elif test "x$OPENJDK_BUILD_OS" = xbsd && test "x$(uname -s | grep -o OpenBSD)" = xOpenBSD; then
+    # Looks like an OpenBSD system
+    MEMORY_SIZE=`/sbin/sysctl -n hw.physmem | awk '{print int($NF / 1048576); }'`
+    FOUND_MEM=yes
+  elif test "x$OPENJDK_BUILD_OS" = xbsd && test "x$(uname -s | grep -o BSD)" = xBSD; 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-`
@@ -199,8 +212,8 @@
     # Only use ccache if it is 3.1.4 or later, which supports
     # precompiled headers.
     AC_MSG_CHECKING([if ccache supports precompiled headers])
-    HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null`
-    if test "x$HAS_GOOD_CCACHE" = x; then
+    HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | awk '{ split(@S|@3, a, "."); if (a@<:@1@:>@ >= 3 && (a@<:@2@:>@ > 1 || (a@<:@2@:>@ == 1 && a@<:@3@:>@ >= 4))) print "yes"; else print "no"; }') 2> /dev/null`
+    if test "x$HAS_GOOD_CCACHE" = xyes; then
       AC_MSG_RESULT([no, disabling ccache])
       CCACHE=
     else
--- a/common/autoconf/generated-configure.sh	Mon Dec 05 13:09:07 2016 -0800
+++ b/common/autoconf/generated-configure.sh	Sat Jan 28 19:01:56 2017 -0800
@@ -646,6 +646,8 @@
 LIBM
 LIBZIP_CAN_USE_MMAP
 USE_EXTERNAL_LIBZ
+GIFLIB_LDFLAGS
+GIFLIB_CFLAGS
 USE_EXTERNAL_LIBGIF
 USE_EXTERNAL_LIBJPEG
 ALSA_LIBS
@@ -819,6 +821,7 @@
 JDK_MAJOR_VERSION
 USER_RELEASE_SUFFIX
 COMPRESS_JARS
+BSD_STATIC_LIBJLI
 UNLIMITED_CRYPTO
 CACERTS_FILE
 TEST_IN_BUILD
@@ -895,6 +898,7 @@
 OPENJDK_TARGET_CPU_ARCH
 OPENJDK_TARGET_CPU
 OPENJDK_TARGET_OS_API
+OPENJDK_TARGET_OS_VENDOR
 OPENJDK_TARGET_OS
 OPENJDK_BUILD_CPU_ENDIAN
 OPENJDK_BUILD_CPU_BITS
@@ -1027,6 +1031,7 @@
 enable_hotspot_test_in_build
 with_cacerts_file
 enable_unlimited_crypto
+enable_static_libjli
 with_milestone
 with_update_version
 with_user_release_suffix
@@ -1053,6 +1058,7 @@
 with_extra_cflags
 with_extra_cxxflags
 with_extra_ldflags
+with_package_path
 enable_debug_symbols
 enable_zip_debug_info
 enable_macosx_runtime_support
@@ -1729,6 +1735,7 @@
                           run the Queens test after Hotspot build [disabled]
   --enable-unlimited-crypto
                           Enable unlimited crypto policy [disabled]
+  --enable-static-libjli  Enable staticly linking libjli on bsd [disabled]
   --disable-debug-symbols disable generation of debug symbols [enabled]
   --disable-zip-debug-info
                           disable zipping of debug-info files [enabled]
@@ -1825,6 +1832,8 @@
   --with-extra-cflags     extra flags to be used when compiling jdk c-files
   --with-extra-cxxflags   extra flags to be used when compiling jdk c++-files
   --with-extra-ldflags    extra flags to be used when linking jdk
+  --with-package-path     package path to be used for location of third party
+                          packages
   --with-x                use the X Window System
   --with-cups             specify prefix directory for the cups package
                           (expecting the headers under PATH/include)
@@ -3672,7 +3681,7 @@
 
 
 #
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -3880,7 +3889,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1449096260
+DATE_WHEN_GENERATED=1482096439
 
 ###############################################################################
 #
@@ -6808,11 +6817,27 @@
       as_fn_error $? "unsupported operating system $build_os" "$LINENO" 5
       ;;
   esac
+  # The BSD's have slight differences so determine which one we are building on.
+  # For the rest set VAR_OS_VENDOR to VAR_OS
+  case "$build_os" in
+    *openbsd*)
+      VAR_OS_VENDOR=openbsd
+      ;;
+    *netbsd*)
+      VAR_OS_VENDOR=netbsd
+      ;;
+    *freebsd*)
+      VAR_OS_VENDOR=freebsd
+      ;;
+    *)
+      VAR_OS_VENDOR="$VAR_OS"
+      ;;
+  esac
 
 
   # First argument is the cpu name from the trip/quad
   case "$build_cpu" in
-    x86_64)
+    amd64|x86_64)
       VAR_CPU=x86_64
       VAR_CPU_ARCH=x86
       VAR_CPU_BITS=64
@@ -6945,11 +6970,27 @@
       as_fn_error $? "unsupported operating system $host_os" "$LINENO" 5
       ;;
   esac
+  # The BSD's have slight differences so determine which one we are building on.
+  # For the rest set VAR_OS_VENDOR to VAR_OS
+  case "$host_os" in
+    *openbsd*)
+      VAR_OS_VENDOR=openbsd
+      ;;
+    *netbsd*)
+      VAR_OS_VENDOR=netbsd
+      ;;
+    *freebsd*)
+      VAR_OS_VENDOR=freebsd
+      ;;
+    *)
+      VAR_OS_VENDOR="$VAR_OS"
+      ;;
+  esac
 
 
   # First argument is the cpu name from the trip/quad
   case "$host_cpu" in
-    x86_64)
+    amd64|x86_64)
       VAR_CPU=x86_64
       VAR_CPU_ARCH=x86
       VAR_CPU_BITS=64
@@ -7022,6 +7063,7 @@
 
   # ... and setup our own variables. (Do this explicitely to facilitate searching)
   OPENJDK_TARGET_OS="$VAR_OS"
+  OPENJDK_TARGET_OS_VENDOR="$VAR_OS_VENDOR"
   OPENJDK_TARGET_OS_API="$VAR_OS_API"
   OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
   OPENJDK_TARGET_CPU="$VAR_CPU"
@@ -7035,6 +7077,7 @@
 
 
 
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking openjdk-target os-cpu" >&5
 $as_echo_n "checking openjdk-target os-cpu... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" >&5
@@ -7163,8 +7206,8 @@
 
   # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
   OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
-  if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
-    # On linux only, we replace x86 with i386.
+  if test "x$OPENJDK_TARGET_OS" = xbsd -o "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
+    # On Linux and BSD, we replace x86 with i386.
     OPENJDK_TARGET_CPU_OSARCH="i386"
   elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
     # On all platforms except macosx, we replace x86_64 with amd64.
@@ -7985,7 +8028,7 @@
     INCLUDE_SA=false
   fi
   if test "x$VAR_CPU" = xppc64 ; then
-    INCLUDE_SA=false
+    INCLUDE_SA=true
   fi
   if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
     INCLUDE_SA=false
@@ -11174,6 +11217,24 @@
 
   ###############################################################################
   #
+  # Enable or disable static linking of libjli on bsd only
+  #
+  # Check whether --enable-static-libjli was given.
+if test "${enable_static_libjli+set}" = set; then :
+  enableval=$enable_static_libjli;
+else
+  enable_static_libjli=no
+fi
+
+  if test "x$OPENJDK_TARGET_OS" = "xbsd" && test "x$enable_static_libjli" = "xyes"; then
+    BSD_STATIC_LIBJLI=bsd
+  else
+    BSD_STATIC_LIBJLI=
+  fi
+
+
+  ###############################################################################
+  #
   # Enable or disable the elliptic curve crypto implementation
   #
 
@@ -19397,6 +19458,8 @@
   elif test "x$OPENJDK_TARGET_OS" = "xaix"; then
     # Do not probe for cc on AIX.
     COMPILER_CHECK_LIST="xlc_r"
+  elif test "`uname -s`" = "FreeBSD"; then
+    COMPILER_CHECK_LIST="cc gcc"
   else
     COMPILER_CHECK_LIST="gcc cc"
   fi
@@ -20357,7 +20420,7 @@
   else
     COMPILER_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
     # Check that this is likely to be GCC.
-    $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null
+    $COMPILER --version 2>&1 | $GREP -E "(Free Software Foundation|clang)" > /dev/null
     if test $? -ne 0; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&5
 $as_echo "$as_me: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&6;}
@@ -21958,7 +22021,7 @@
   else
     COMPILER_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
     # Check that this is likely to be GCC.
-    $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null
+    $COMPILER --version 2>&1 | $GREP -E "(Free Software Foundation|clang)" > /dev/null
     if test $? -ne 0; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&5
 $as_echo "$as_me: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&6;}
@@ -27965,7 +28028,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
     if test -n "$ac_tool_prefix"; then
   for ac_prog in gobjcopy objcopy
   do
@@ -29322,8 +29385,10 @@
       SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/$1'
       SET_SHARED_LIBRARY_MAPFILE=''
       SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
+      POST_STRIP_CMD="$STRIP -S"
+    fi
+    if test "x$OPENJDK_TARGET_OS" = xbsd || test "x$OPENJDK_TARGET_OS" = xmacosx; then
       SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
-      POST_STRIP_CMD="$STRIP -S"
     fi
   else
     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
@@ -29667,7 +29732,7 @@
   #
   case $COMPILER_NAME in
     gcc )
-      CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
+      CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses -Wno-sign-compare \
       -pipe \
       -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
       case $OPENJDK_TARGET_CPU_ARCH in
@@ -29749,22 +29814,37 @@
   CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
 
   # The package path is used only on macosx?
-  PACKAGE_PATH=/opt/local
+
+# Check whether --with-package-path was given.
+if test "${with_package_path+set}" = set; then :
+  withval=$with_package_path;
+fi
+
+  PACKAGE_PATH="$with_package_path"
+  if test "x$PACKAGE_PATH" = x; then
+    if test "`uname -s`" = "Darwin"; then
+      PACKAGE_PATH=/opt/local
+    fi
+
+    if test "`uname -s`" = "FreeBSD"; then
+      PACKAGE_PATH=/usr/local
+    fi
+
+    if test "`uname -s`" = "NetBSD"; then
+      PACKAGE_PATH=/usr/pkg
+    fi
+
+    if test "`uname -s`" = "OpenBSD"; then
+      PACKAGE_PATH=/usr/local
+    fi
+  fi
+
 
 
   if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
-    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
-    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
-    #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
-    #   Note: -Dmacro         is the same as    #define macro 1
-    #         -Dmacro=        is the same as    #define macro
-    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
-    else
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
-    fi
-  else
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
+    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DVM_LITTLE_ENDIAN"
+  else
+    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DVM_BIG_ENDIAN"
   fi
   if test "x$OPENJDK_TARGET_OS" = xlinux; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
@@ -29794,6 +29874,38 @@
   fi
   if test "x$OPENJDK_TARGET_OS" = xbsd; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
+    if test "`uname -s`" = "OpenBSD"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld requires -z wxneeded" >&5
+$as_echo_n "checking if ld requires -z wxneeded... " >&6; }
+        if test "$cross_compiling" = yes; then :
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/mman.h>
+int main() { return mmap(0, 4096, PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0) != MAP_FAILED; }
+_ACEOF
+if ac_fn_cxx_try_run "$LINENO"; then :
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+              LDFLAGS_JDK="$LDFLAGS_JDK -Wl,-z,wxneeded"
+
+else
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+    fi
   fi
   if test "x$DEBUG_LEVEL" = xrelease; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
@@ -30261,11 +30373,18 @@
   fi
 
   if test "x$OPENJDK_TARGET_OS" = xbsd; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking what is not needed on bsd?" >&5
-$as_echo_n "checking what is not needed on bsd?... " >&6; }
-    ALSA_NOT_NEEDED=yes
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa" >&5
-$as_echo "alsa" >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking what is not needed on BSD?" >&5
+$as_echo_n "checking what is not needed on BSD?... " >&6; }
+    if test "x$OPENJDK_TARGET_OS_VENDOR" = xopenbsd; then
+      ALSA_NOT_NEEDED=yes
+      PULSE_NOT_NEEDED=yes
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa pulse" >&5
+$as_echo "alsa pulse" >&6; }
+    else
+      PULSE_NOT_NEEDED=yes
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: pulse" >&5
+$as_echo "pulse" >&6; }
+    fi
   fi
 
   if test "x$OPENJDK" = "xfalse"; then
@@ -30301,14 +30420,18 @@
   # --x-libraries for the sysroot, if that seems to be correct.
   if test "x$SYS_ROOT" != "x/"; then
     if test "x$x_includes" = xNONE; then
-      if test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then
+      if test -f "$SYS_ROOT/usr/X11R7/include/X11/Xlib.h"; then
+        x_includes="$SYS_ROOT/usr/X11R7/include"
+      elif test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then
         x_includes="$SYS_ROOT/usr/X11R6/include"
       elif test -f "$SYS_ROOT/usr/include/X11/Xlib.h"; then
         x_includes="$SYS_ROOT/usr/include"
       fi
     fi
     if test "x$x_libraries" = xNONE; then
-      if test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
+      if test -f "$SYS_ROOT/usr/X11R7/lib/libX11.so"; then
+        x_libraries="$SYS_ROOT/usr/X11R7/lib"
+      elif test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
         x_libraries="$SYS_ROOT/usr/X11R6/lib"
       elif test "$SYS_ROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
         x_libraries="$SYS_ROOT/usr/lib64"
@@ -31355,6 +31478,10 @@
         # A CSW package seems to be installed!
         CUPS_FOUND=yes
         CUPS_CFLAGS="-I/opt/csw/include"
+      elif test -s ${PACKAGE_PATH}/include/cups/cups.h; then
+        # Standard package location for BSD
+        CUPS_FOUND=yes
+        CUPS_CFLAGS="-I${PACKAGE_PATH}/include"
       fi
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_FOUND" >&5
 $as_echo "$CUPS_FOUND" >&6; }
@@ -34520,7 +34647,7 @@
 
   ###############################################################################
   #
-  # Check for alsa headers and libraries. Used on Linux/GNU systems.
+  # Check for alsa headers and libraries. Used on Linux/GNU and BSD systems.
   #
 
 # Check whether --with-alsa was given.
@@ -34928,15 +35055,66 @@
 
   if test "x${with_giflib}" = "xbundled"; then
     USE_EXTERNAL_LIBGIF=false
+    GIFLIB_CFLAGS=
+    GIFLIB_LDFLAGS=
   elif test "x${with_giflib}" = "xsystem"; then
+    GIFLIB_H_FOUND=no
     ac_fn_cxx_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default"
 if test "x$ac_cv_header_gif_lib_h" = xyes; then :
 
-else
-   as_fn_error $? "--with-giflib=system specified, but gif_lib.h not found!" "$LINENO" 5
-fi
-
-
+           GIFLIB_H_FOUND=yes
+           GIFLIB_CFLAGS=
+
+
+fi
+
+
+    if test "x$GIFLIB_H_FOUND" = xno; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for giflib headers" >&5
+$as_echo_n "checking for giflib headers... " >&6; }
+      if test -s ${PACKAGE_PATH}/include/gif_lib.h; then
+        # Standard package location for BSD
+        GIFLIB_H_FOUND=yes
+        GIFLIB_CFLAGS="-I${PACKAGE_PATH}/include"
+      fi
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GIFLIB_H_FOUND" >&5
+$as_echo "$GIFLIB_H_FOUND" >&6; }
+    fi
+    if test "x$GIFLIB_H_FOUND" = xno; then
+
+  # Print a helpful message on how to acquire the necessary build dependency.
+  # giflib is the help tag: freetype, cups, pulse, alsa etc
+  MISSING_DEPENDENCY=giflib
+
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    cygwin_help $MISSING_DEPENDENCY
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    msys_help $MISSING_DEPENDENCY
+  else
+    PKGHANDLER_COMMAND=
+
+    case $PKGHANDLER in
+      apt-get)
+        apt_help     $MISSING_DEPENDENCY ;;
+      yum)
+        yum_help     $MISSING_DEPENDENCY ;;
+      port)
+        port_help    $MISSING_DEPENDENCY ;;
+      pkgutil)
+        pkgutil_help $MISSING_DEPENDENCY ;;
+      pkgadd)
+        pkgadd_help  $MISSING_DEPENDENCY ;;
+    esac
+
+    if test "x$PKGHANDLER_COMMAND" != x; then
+      HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
+    fi
+  fi
+
+      as_fn_error $? "Could not find giflib headers! $HELP_MSG " "$LINENO" 5
+    fi
+
+    GIFLIB_LIB_FOUND=no
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DGifGetCode in -lgif" >&5
 $as_echo_n "checking for DGifGetCode in -lgif... " >&6; }
 if ${ac_cv_lib_gif_DGifGetCode+:} false; then :
@@ -34974,16 +35152,96 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_DGifGetCode" >&5
 $as_echo "$ac_cv_lib_gif_DGifGetCode" >&6; }
 if test "x$ac_cv_lib_gif_DGifGetCode" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBGIF 1
-_ACEOF
-
-  LIBS="-lgif $LIBS"
-
-else
-   as_fn_error $? "--with-giflib=system specified, but no giflib found!" "$LINENO" 5
-fi
-
+
+           GIFLIB_LIB_FOUND=yes
+           GIFLIB_LDFLAGS=
+
+
+fi
+
+    if test "x$GIFLIB_LIB_FOUND" = xno; then
+      save_LDFLAGS="$LDFLAGS"
+      LDFLAGS="$LDFLAGS -L${PACKAGE_PATH}/lib"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DGifOpen in -lgif" >&5
+$as_echo_n "checking for DGifOpen in -lgif... " >&6; }
+if ${ac_cv_lib_gif_DGifOpen+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgif  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char DGifOpen ();
+int
+main ()
+{
+return DGifOpen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_gif_DGifOpen=yes
+else
+  ac_cv_lib_gif_DGifOpen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_DGifOpen" >&5
+$as_echo "$ac_cv_lib_gif_DGifOpen" >&6; }
+if test "x$ac_cv_lib_gif_DGifOpen" = xyes; then :
+
+             GIFLIB_LIB_FOUND=yes
+             GIFLIB_LDFLAGS="-L${PACKAGE_PATH}/lib"
+
+
+fi
+
+      LDFLAGS="$save_LDFLAGS"
+    fi
+
+    if test "x$GIFLIB_LIB_FOUND" = xno; then
+
+  # Print a helpful message on how to acquire the necessary build dependency.
+  # giflib is the help tag: freetype, cups, pulse, alsa etc
+  MISSING_DEPENDENCY=giflib
+
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    cygwin_help $MISSING_DEPENDENCY
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    msys_help $MISSING_DEPENDENCY
+  else
+    PKGHANDLER_COMMAND=
+
+    case $PKGHANDLER in
+      apt-get)
+        apt_help     $MISSING_DEPENDENCY ;;
+      yum)
+        yum_help     $MISSING_DEPENDENCY ;;
+      port)
+        port_help    $MISSING_DEPENDENCY ;;
+      pkgutil)
+        pkgutil_help $MISSING_DEPENDENCY ;;
+      pkgadd)
+        pkgadd_help  $MISSING_DEPENDENCY ;;
+    esac
+
+    if test "x$PKGHANDLER_COMMAND" != x; then
+      HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
+    fi
+  fi
+
+      as_fn_error $? "Could not find giflib library! $HELP_MSG " "$LINENO" 5
+    fi
 
     USE_EXTERNAL_LIBGIF=true
   else
@@ -34991,6 +35249,8 @@
   fi
 
 
+
+
   ###############################################################################
   #
   # Check for the zlib library
@@ -35558,6 +35818,11 @@
     LIBCXX="-lstdc++"
   fi
 
+  # TODO better (platform agnostic) test
+  if test "x$OPENJDK_TARGET_OS" = xbsd && test "x$LIBCXX" = x && test "x$GCC" = xyes; then
+    LIBCXX="-lstdc++"
+  fi
+
 
 
 
@@ -35631,6 +35896,10 @@
     # Looks like a MacOSX system
     NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk  '{print $5}'`
     FOUND_CORES=yes
+  elif test "x$OPENJDK_BUILD_OS" = xbsd && test "x$(uname -s | grep -o BSD)" = xBSD; 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
@@ -35686,6 +35955,15 @@
     MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk  '{print $2}'`
     MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024`
     FOUND_MEM=yes
+  elif test "x$OPENJDK_BUILD_OS" = xbsd && test "x$(uname -s | grep -o OpenBSD)" = xOpenBSD; then
+    # Looks like an OpenBSD system
+    MEMORY_SIZE=`/sbin/sysctl -n hw.physmem | awk '{print int($NF / 1048576); }'`
+    FOUND_MEM=yes
+  elif test "x$OPENJDK_BUILD_OS" = xbsd && test "x$(uname -s | grep -o BSD)" = xBSD; 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-`
@@ -36093,8 +36371,8 @@
     # precompiled headers.
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ccache supports precompiled headers" >&5
 $as_echo_n "checking if ccache supports precompiled headers... " >&6; }
-    HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.[456789]) 2> /dev/null`
-    if test "x$HAS_GOOD_CCACHE" = x; then
+    HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | awk '{ split($3, a, "."); if (a[1] >= 3 && (a[2] > 1 || (a[2] == 1 && a[3] >= 4))) print "yes"; else print "no"; }') 2> /dev/null`
+    if test "x$HAS_GOOD_CCACHE" = xyes; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, disabling ccache" >&5
 $as_echo "no, disabling ccache" >&6; }
       CCACHE=
--- a/common/autoconf/jdk-options.m4	Mon Dec 05 13:09:07 2016 -0800
+++ b/common/autoconf/jdk-options.m4	Sat Jan 28 19:01:56 2017 -0800
@@ -159,7 +159,7 @@
     INCLUDE_SA=false
   fi
   if test "x$VAR_CPU" = xppc64 ; then
-    INCLUDE_SA=false
+    INCLUDE_SA=true
   fi
   if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
     INCLUDE_SA=false
@@ -410,6 +410,20 @@
 
   ###############################################################################
   #
+  # Enable or disable static linking of libjli on bsd only
+  #
+  AC_ARG_ENABLE(static-libjli, [AS_HELP_STRING([--enable-static-libjli],
+      [Enable staticly linking libjli on bsd @<:@disabled@:>@])],,
+      [enable_static_libjli=no])
+  if test "x$OPENJDK_TARGET_OS" = "xbsd" && test "x$enable_static_libjli" = "xyes"; then
+    BSD_STATIC_LIBJLI=bsd
+  else
+    BSD_STATIC_LIBJLI=
+  fi
+  AC_SUBST(BSD_STATIC_LIBJLI)
+
+  ###############################################################################
+  #
   # Enable or disable the elliptic curve crypto implementation
   #
   AC_DEFUN_ONCE([JDKOPT_DETECT_INTREE_EC],
--- a/common/autoconf/libraries.m4	Mon Dec 05 13:09:07 2016 -0800
+++ b/common/autoconf/libraries.m4	Sat Jan 28 19:01:56 2017 -0800
@@ -69,9 +69,15 @@
   fi
 
   if test "x$OPENJDK_TARGET_OS" = xbsd; then
-    AC_MSG_CHECKING([what is not needed on bsd?])
-    ALSA_NOT_NEEDED=yes
-    AC_MSG_RESULT([alsa])
+    AC_MSG_CHECKING([what is not needed on BSD?])
+    if test "x$OPENJDK_TARGET_OS_VENDOR" = xopenbsd; then
+      ALSA_NOT_NEEDED=yes
+      PULSE_NOT_NEEDED=yes
+      AC_MSG_RESULT([alsa pulse])
+    else
+      PULSE_NOT_NEEDED=yes
+      AC_MSG_RESULT([pulse])
+    fi
   fi
 
   if test "x$OPENJDK" = "xfalse"; then
@@ -99,14 +105,18 @@
   # --x-libraries for the sysroot, if that seems to be correct.
   if test "x$SYS_ROOT" != "x/"; then
     if test "x$x_includes" = xNONE; then
-      if test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then
+      if test -f "$SYS_ROOT/usr/X11R7/include/X11/Xlib.h"; then
+        x_includes="$SYS_ROOT/usr/X11R7/include"
+      elif test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then
         x_includes="$SYS_ROOT/usr/X11R6/include"
       elif test -f "$SYS_ROOT/usr/include/X11/Xlib.h"; then
         x_includes="$SYS_ROOT/usr/include"
       fi
     fi
     if test "x$x_libraries" = xNONE; then
-      if test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
+      if test -f "$SYS_ROOT/usr/X11R7/lib/libX11.so"; then
+        x_libraries="$SYS_ROOT/usr/X11R7/lib"
+      elif test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
         x_libraries="$SYS_ROOT/usr/X11R6/lib"
       elif test "$SYS_ROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
         x_libraries="$SYS_ROOT/usr/lib64"
@@ -232,6 +242,10 @@
         # A CSW package seems to be installed!
         CUPS_FOUND=yes
         CUPS_CFLAGS="-I/opt/csw/include"
+      elif test -s ${PACKAGE_PATH}/include/cups/cups.h; then
+        # Standard package location for BSD
+        CUPS_FOUND=yes
+        CUPS_CFLAGS="-I${PACKAGE_PATH}/include"
       fi
       AC_MSG_RESULT([$CUPS_FOUND])
     fi
@@ -525,7 +539,7 @@
 
   ###############################################################################
   #
-  # Check for alsa headers and libraries. Used on Linux/GNU systems.
+  # Check for alsa headers and libraries. Used on Linux/GNU and BSD systems.
   #
   AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
       [specify prefix directory for the alsa package
@@ -627,17 +641,61 @@
 
   if test "x${with_giflib}" = "xbundled"; then
     USE_EXTERNAL_LIBGIF=false
+    GIFLIB_CFLAGS=
+    GIFLIB_LDFLAGS=
   elif test "x${with_giflib}" = "xsystem"; then
-    AC_CHECK_HEADER(gif_lib.h, [],
-        [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
-    AC_CHECK_LIB(gif, DGifGetCode, [],
-        [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
+    GIFLIB_H_FOUND=no
+    AC_CHECK_HEADER(gif_lib.h,
+        [
+           GIFLIB_H_FOUND=yes
+           GIFLIB_CFLAGS=
+        ]
+    )
+    if test "x$GIFLIB_H_FOUND" = xno; then
+      AC_MSG_CHECKING([for giflib headers])
+      if test -s ${PACKAGE_PATH}/include/gif_lib.h; then
+        # Standard package location for BSD
+        GIFLIB_H_FOUND=yes
+        GIFLIB_CFLAGS="-I${PACKAGE_PATH}/include"
+      fi
+      AC_MSG_RESULT([$GIFLIB_H_FOUND])
+    fi
+    if test "x$GIFLIB_H_FOUND" = xno; then
+      HELP_MSG_MISSING_DEPENDENCY([giflib])
+      AC_MSG_ERROR([Could not find giflib headers! $HELP_MSG ])
+    fi
+
+    GIFLIB_LIB_FOUND=no
+    AC_CHECK_LIB(gif, DGifGetCode,
+        [
+           GIFLIB_LIB_FOUND=yes
+           GIFLIB_LDFLAGS=
+        ]
+    )
+    if test "x$GIFLIB_LIB_FOUND" = xno; then
+      save_LDFLAGS="$LDFLAGS"
+      LDFLAGS="$LDFLAGS -L${PACKAGE_PATH}/lib"
+      AC_CHECK_LIB(gif, DGifOpen,
+          [
+             GIFLIB_LIB_FOUND=yes
+             GIFLIB_LDFLAGS="-L${PACKAGE_PATH}/lib"
+          ]
+      )
+      LDFLAGS="$save_LDFLAGS"
+    fi
+
+    if test "x$GIFLIB_LIB_FOUND" = xno; then
+      HELP_MSG_MISSING_DEPENDENCY([giflib])
+      AC_MSG_ERROR([Could not find giflib library! $HELP_MSG ])
+    fi
 
     USE_EXTERNAL_LIBGIF=true
   else
     AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
   fi
   AC_SUBST(USE_EXTERNAL_LIBGIF)
+  AC_SUBST(GIFLIB_CFLAGS)
+  AC_SUBST(GIFLIB_LDFLAGS)
 
   ###############################################################################
   #
@@ -872,5 +930,10 @@
     LIBCXX="-lstdc++"
   fi
 
+  # TODO better (platform agnostic) test
+  if test "x$OPENJDK_TARGET_OS" = xbsd && test "x$LIBCXX" = x && test "x$GCC" = xyes; then
+    LIBCXX="-lstdc++"
+  fi
+
   AC_SUBST(LIBCXX)
 ])
--- a/common/autoconf/platform.m4	Mon Dec 05 13:09:07 2016 -0800
+++ b/common/autoconf/platform.m4	Sat Jan 28 19:01:56 2017 -0800
@@ -30,7 +30,7 @@
 [
   # First argument is the cpu name from the trip/quad
   case "$1" in
-    x86_64)
+    amd64|x86_64)
       VAR_CPU=x86_64
       VAR_CPU_ARCH=x86
       VAR_CPU_BITS=64
@@ -147,6 +147,22 @@
       AC_MSG_ERROR([unsupported operating system $1])
       ;;
   esac
+  # The BSD's have slight differences so determine which one we are building on.
+  # For the rest set VAR_OS_VENDOR to VAR_OS
+  case "$1" in
+    *openbsd*)
+      VAR_OS_VENDOR=openbsd
+      ;;
+    *netbsd*)
+      VAR_OS_VENDOR=netbsd
+      ;;
+    *freebsd*)
+      VAR_OS_VENDOR=freebsd
+      ;;
+    *)
+      VAR_OS_VENDOR="$VAR_OS"
+      ;;
+  esac
 ])
 
 # Expects $host_os $host_cpu $build_os and $build_cpu
@@ -192,6 +208,7 @@
   PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
   # ... and setup our own variables. (Do this explicitely to facilitate searching)
   OPENJDK_TARGET_OS="$VAR_OS"
+  OPENJDK_TARGET_OS_VENDOR="$VAR_OS_VENDOR"
   OPENJDK_TARGET_OS_API="$VAR_OS_API"
   OPENJDK_TARGET_OS_ENV="$VAR_OS_ENV"
   OPENJDK_TARGET_CPU="$VAR_CPU"
@@ -199,6 +216,7 @@
   OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
   OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
   AC_SUBST(OPENJDK_TARGET_OS)
+  AC_SUBST(OPENJDK_TARGET_OS_VENDOR)
   AC_SUBST(OPENJDK_TARGET_OS_API)
   AC_SUBST(OPENJDK_TARGET_CPU)
   AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
@@ -308,8 +326,8 @@
 
   # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
   OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
-  if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
-    # On linux only, we replace x86 with i386.
+  if test "x$OPENJDK_TARGET_OS" = xbsd -o "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
+    # On Linux and BSD, we replace x86 with i386.
     OPENJDK_TARGET_CPU_OSARCH="i386"
   elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
     # On all platforms except macosx, we replace x86_64 with amd64.
--- a/common/autoconf/spec.gmk.in	Mon Dec 05 13:09:07 2016 -0800
+++ b/common/autoconf/spec.gmk.in	Sat Jan 28 19:01:56 2017 -0800
@@ -76,6 +76,7 @@
 OPENJDK_TARGET_OS:=@OPENJDK_TARGET_OS@
 OPENJDK_TARGET_OS_API:=@OPENJDK_TARGET_OS_API@
 OPENJDK_TARGET_OS_ENV:=@OPENJDK_TARGET_OS_ENV@
+OPENJDK_TARGET_OS_VENDOR:=@OPENJDK_TARGET_OS_VENDOR@
 
 OPENJDK_TARGET_CPU:=@OPENJDK_TARGET_CPU@
 OPENJDK_TARGET_CPU_ARCH:=@OPENJDK_TARGET_CPU_ARCH@
@@ -276,7 +277,7 @@
 ALSA_LIBS:=@ALSA_LIBS@
 ALSA_CFLAGS:=@ALSA_CFLAGS@
 
-PACKAGE_PATH=@PACKAGE_PATH@
+PACKAGE_PATH:=@PACKAGE_PATH@
 
 # Source file for cacerts
 CACERTS_FILE=@CACERTS_FILE@
@@ -284,6 +285,9 @@
 # Enable unlimited crypto policy
 UNLIMITED_CRYPTO=@UNLIMITED_CRYPTO@
 
+# Build static libjli on bsd
+BSD_STATIC_LIBJLI=@BSD_STATIC_LIBJLI@
+
 # Necessary additional compiler flags to compile X11
 X_CFLAGS:=@X_CFLAGS@
 X_LIBS:=@X_LIBS@
@@ -564,6 +568,8 @@
 ENABLE_INTREE_EC=@ENABLE_INTREE_EC@
 USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@
 USE_EXTERNAL_LIBGIF:=@USE_EXTERNAL_LIBGIF@
+GIFLIB_CFLAGS:=@GIFLIB_CFLAGS@
+GIFLIB_LDFLAGS:=@GIFLIB_LDFLAGS@
 USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@
 LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@
 MSVCR_DLL:=@MSVCR_DLL@
--- a/common/autoconf/toolchain.m4	Mon Dec 05 13:09:07 2016 -0800
+++ b/common/autoconf/toolchain.m4	Sat Jan 28 19:01:56 2017 -0800
@@ -72,7 +72,7 @@
   else
     COMPILER_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
     # Check that this is likely to be GCC.
-    $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null
+    $COMPILER --version 2>&1 | $GREP -E "(Free Software Foundation|clang)" > /dev/null
     if test $? -ne 0; then
       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler.])
       AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_TEST"])
@@ -350,6 +350,8 @@
   elif test "x$OPENJDK_TARGET_OS" = "xaix"; then
     # Do not probe for cc on AIX.
     COMPILER_CHECK_LIST="xlc_r"
+  elif test "`uname -s`" = "FreeBSD"; then
+    COMPILER_CHECK_LIST="cc gcc"
   else
     COMPILER_CHECK_LIST="gcc cc"
   fi
@@ -571,7 +573,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
     AC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
     # Only call fixup if objcopy was found.
     if test -n "$OBJCOPY"; then
@@ -634,8 +636,10 @@
       SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
       SET_SHARED_LIBRARY_MAPFILE=''
       SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
+      POST_STRIP_CMD="$STRIP -S"
+    fi
+    if test "x$OPENJDK_TARGET_OS" = xbsd || test "x$OPENJDK_TARGET_OS" = xmacosx; then
       SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
-      POST_STRIP_CMD="$STRIP -S"
     fi
   else
     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
@@ -957,7 +961,7 @@
   #
   case $COMPILER_NAME in
     gcc )
-      CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
+      CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses -Wno-sign-compare \
       -pipe \
       -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
       case $OPENJDK_TARGET_CPU_ARCH in
@@ -1039,22 +1043,33 @@
   CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
 
   # The package path is used only on macosx?
-  PACKAGE_PATH=/opt/local
+  AC_ARG_WITH(package-path, [AS_HELP_STRING([--with-package-path],
+      [package path to be used for location of third party packages])])
+  PACKAGE_PATH="$with_package_path"
+  if test "x$PACKAGE_PATH" = x; then
+    if test "`uname -s`" = "Darwin"; then
+      PACKAGE_PATH=/opt/local
+    fi
+
+    if test "`uname -s`" = "FreeBSD"; then
+      PACKAGE_PATH=/usr/local
+    fi
+
+    if test "`uname -s`" = "NetBSD"; then
+      PACKAGE_PATH=/usr/pkg
+    fi
+
+    if test "`uname -s`" = "OpenBSD"; then
+      PACKAGE_PATH=/usr/local
+    fi
+  fi
+
   AC_SUBST(PACKAGE_PATH)
 
   if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
-    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
-    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
-    #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
-    #   Note: -Dmacro         is the same as    #define macro 1
-    #         -Dmacro=        is the same as    #define macro
-    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
-    else
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
-    fi
+    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DVM_LITTLE_ENDIAN"
   else
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
+    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DVM_BIG_ENDIAN"
   fi
   if test "x$OPENJDK_TARGET_OS" = xlinux; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
@@ -1084,6 +1099,22 @@
   fi
   if test "x$OPENJDK_TARGET_OS" = xbsd; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
+    if test "`uname -s`" = "OpenBSD"; then
+        AC_MSG_CHECKING([if ld requires -z wxneeded])
+        AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/mman.h>
+int main() { return mmap(0, 4096, PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0) != MAP_FAILED; }]])],
+            [
+              AC_MSG_RESULT([yes])
+              LDFLAGS_JDK="$LDFLAGS_JDK -Wl,-z,wxneeded"
+            ],
+            [
+              AC_MSG_RESULT([no])
+            ],
+            [
+              AC_MSG_RESULT([no])
+            ]
+        )
+    fi
   fi
   if test "x$DEBUG_LEVEL" = xrelease; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
--- a/configure	Mon Dec 05 13:09:07 2016 -0800
+++ b/configure	Sat Jan 28 19:01:56 2017 -0800
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
--- a/make/Javadoc.gmk	Mon Dec 05 13:09:07 2016 -0800
+++ b/make/Javadoc.gmk	Sat Jan 28 19:01:56 2017 -0800
@@ -46,8 +46,18 @@
 
 BUILD_NUMBER=$(JDK_BUILD_NUMBER)
 
+ifeq ($(OPENJDK_TARGET_OS_VENDOR), openbsd)
+  ifeq ($(OPENJDK_TARGET_CPU_BITS), 32)
+    JAVADOC_CMD_MEM = "-Xmx768m"
+  else
+    JAVADOC_CMD_MEM = "-Xmx1024m"
+  endif
+else
+  JAVADOC_CMD_MEM = "-Xmx1024m"
+endif
+
 JAVADOC_CMD = $(JAVA) \
-    -Xmx1024m \
+    $(JAVADOC_CMD_MEM) \
     -Djava.awt.headless=true \
     $(NEW_JAVADOC) \
     -bootclasspath $(JDK_OUTPUTDIR)/classes
--- a/make/Main.gmk	Mon Dec 05 13:09:07 2016 -0800
+++ b/make/Main.gmk	Sat Jan 28 19:01:56 2017 -0800
@@ -58,7 +58,11 @@
 
 # Setup number of jobs to use. -jN is unfortunately not available for us to parse from the command line,
 # hence this workaround.
+ifdef JOBS
+ifneq ($(JOBS),0)
 MAKE_ARGS:=$(MAKE_ARGS) -j$(JOBS)
+endif
+endif
 
 ### Main targets
 
--- a/make/common/MakeBase.gmk	Mon Dec 05 13:09:07 2016 -0800
+++ b/make/common/MakeBase.gmk	Sat Jan 28 19:01:56 2017 -0800
@@ -338,7 +338,7 @@
     # (and causing a crash on Cygwin).
     # Default shell seems to always be /bin/sh. Must override with bash to get this to work on Solaris.
     # Only use time if it's GNU time which supports format and output file.
-    WRAPPER_SHELL:=/bin/bash $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log /bin/bash
+    WRAPPER_SHELL:=bash $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log bash
     SHELL=$$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL)
   endif
   # Never remove warning messages; this is just for completeness
@@ -365,8 +365,8 @@
 
 # This is to be called by all SetupFoo macros
 define LogSetupMacroEntry
-  $(if $(27),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk))
-  $(if $(findstring $(LOG_LEVEL),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26,$(if $($i),$(NEWLINE) $(strip [$i] $($i))))))
+  $(if $(30),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk))
+  $(if $(findstring $(LOG_LEVEL),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29,$(if $($i),$(NEWLINE) $(strip [$i] $($i))))))
 endef
 
 # Make directory without forking mkdir if not needed
--- a/make/common/NativeCompilation.gmk	Mon Dec 05 13:09:07 2016 -0800
+++ b/make/common/NativeCompilation.gmk	Sat Jan 28 19:01:56 2017 -0800
@@ -151,9 +151,9 @@
   #   CC the compiler to use, default is $(CC)
   #   LDEXE the linker to use for linking executables, default is $(LDEXE)
   #   OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST
-  $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
-  $(call LogSetupMacroEntry,SetupNativeCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15),$(16),$(17),$(18),$(19),$(20),$(21),$(22),$(23),$(24),$(25),$(26))
-  $(if $(27),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk))
+  $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
+  $(call LogSetupMacroEntry,SetupNativeCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15),$(16),$(17),$(18),$(19),$(20),$(21),$(22),$(23),$(24),$(25),$(26),$(27),$(28),$(29))
+  $(if $(30),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk))
 
   ifneq (,$$($1_BIN))
     $$(error BIN has been replaced with OBJECT_DIR)