$OpenBSD: patch-Modules_FindJNI_cmake,v 1.20 2017/04/21 18:37:43 kurt Exp $
--- Modules/FindJNI.cmake.orig	Fri Jan 13 09:05:41 2017
+++ Modules/FindJNI.cmake	Fri Apr 21 09:54:40 2017
@@ -25,6 +25,8 @@
 #   JAVA_INCLUDE_PATH2    = the include path to jni_md.h
 #   JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
 
+set(MODJAVA_VER $ENV{MODJAVA_VER})
+
 # Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var}
 macro(java_append_library_directories _var)
     # Determine java arch-specific library subdir
@@ -70,8 +72,10 @@ macro(java_append_library_directories _var)
 
     # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or
     # system is non-Linux (where the code above has not been well tested)
-    if(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux"))
-        list(APPEND _java_libarch "i386" "amd64" "ppc")
+    if(NOT MODJAVA_VER)
+      if(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux"))
+          list(APPEND _java_libarch "i386" "amd64" "ppc")
+      endif()
     endif()
 
     # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer
@@ -107,57 +111,63 @@ if(_JAVA_HOME_EXPLICIT)
   set(CMAKE_FIND_FRAMEWORK NEVER)
 endif()
 
-set(JAVA_AWT_LIBRARY_DIRECTORIES)
-if(_JAVA_HOME)
+if(MODJAVA_VER)
+  set(JAVA_AWT_LIBRARY_DIRECTORIES)
   JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
-    ${_JAVA_HOME}/jre/lib/{libarch}
-    ${_JAVA_HOME}/jre/lib
-    ${_JAVA_HOME}/lib/{libarch}
-    ${_JAVA_HOME}/lib
-    ${_JAVA_HOME}
+    ${LOCALBASE}/jdk-1.8.0/jre/lib/{libarch}
+    ${LOCALBASE}/jre-1.8.0/lib/{libarch}
     )
-endif()
-get_filename_component(java_install_version
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
+else(MODJAVA_VER)
+  set(JAVA_AWT_LIBRARY_DIRECTORIES)
+  if(_JAVA_HOME)
+    JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
+      ${_JAVA_HOME}/jre/lib/{libarch}
+      ${_JAVA_HOME}/jre/lib
+      ${_JAVA_HOME}/lib/{libarch}
+      ${_JAVA_HOME}/lib
+      ${_JAVA_HOME}
+      )
+  endif()
+  get_filename_component(java_install_version
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
 
-list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
-  )
-JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
-  /usr/lib
-  /usr/local/lib
-  /usr/lib/jvm/java/lib
-  /usr/lib/java/jre/lib/{libarch}
-  /usr/lib/jvm/jre/lib/{libarch}
-  /usr/local/lib/java/jre/lib/{libarch}
-  /usr/local/share/java/jre/lib/{libarch}
-  /usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
-  /usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
-  /opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
-  /usr/lib/jvm/java-6-sun/jre/lib/{libarch}
-  /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
-  /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch}       # can this one be removed according to #8821 ? Alex
-  /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
-  /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/{libarch}        # fedora
-  # Debian specific paths for default JVM
-  /usr/lib/jvm/default-java/jre/lib/{libarch}
-  /usr/lib/jvm/default-java/jre/lib
-  /usr/lib/jvm/default-java/lib
-  # Ubuntu specific paths for default JVM
-  /usr/lib/jvm/java-8-openjdk-{libarch}/jre/lib/{libarch}     # Ubuntu 15.10
-  /usr/lib/jvm/java-7-openjdk-{libarch}/jre/lib/{libarch}     # Ubuntu 15.10
-  /usr/lib/jvm/java-6-openjdk-{libarch}/jre/lib/{libarch}     # Ubuntu 15.10
-  # OpenBSD specific paths for default JVM
-  /usr/local/jdk-1.7.0/jre/lib/{libarch}
-  /usr/local/jre-1.7.0/lib/{libarch}
-  /usr/local/jdk-1.6.0/jre/lib/{libarch}
-  /usr/local/jre-1.6.0/lib/{libarch}
-  # SuSE specific paths for default JVM
-  /usr/lib64/jvm/java/jre/lib/{libarch}
-  /usr/lib64/jvm/jre/lib/{libarch}
-  )
+  list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
+    )
+  JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
+    /usr/lib
+    /usr/local/lib
+    /usr/lib/jvm/java/lib
+    /usr/lib/java/jre/lib/{libarch}
+    /usr/lib/jvm/jre/lib/{libarch}
+    /usr/local/lib/java/jre/lib/{libarch}
+    /usr/local/share/java/jre/lib/{libarch}
+    /usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
+    /usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
+    /opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
+    /usr/lib/jvm/java-6-sun/jre/lib/{libarch}
+    /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
+    /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch}       # can this one be removed according to #8821 ? Alex
+    /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
+    /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/{libarch}        # fedora
+    # Debian specific paths for default JVM
+    /usr/lib/jvm/default-java/jre/lib/{libarch}
+    /usr/lib/jvm/default-java/jre/lib
+    /usr/lib/jvm/default-java/lib
+    # Ubuntu specific paths for default JVM
+    /usr/lib/jvm/java-8-openjdk-{libarch}/jre/lib/{libarch}     # Ubuntu 15.10
+    /usr/lib/jvm/java-7-openjdk-{libarch}/jre/lib/{libarch}     # Ubuntu 15.10
+    /usr/lib/jvm/java-6-openjdk-{libarch}/jre/lib/{libarch}     # Ubuntu 15.10
+    # OpenBSD specific paths for default JVM
+    ${LOCALBASE}/jdk-1.8.0/jre/lib/{libarch}
+    ${LOCALBASE}/jre-1.8.0/lib/{libarch}
+    # SuSE specific paths for default JVM
+    /usr/lib64/jvm/java/jre/lib/{libarch}
+    /usr/lib64/jvm/jre/lib/{libarch}
+    )
+endif(MODJAVA_VER)
 
 set(JAVA_JVM_LIBRARY_DIRECTORIES)
 foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
@@ -171,41 +181,48 @@ foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
     )
 endforeach()
 
-set(JAVA_AWT_INCLUDE_DIRECTORIES)
-if(_JAVA_HOME)
-  list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES ${_JAVA_HOME}/include)
-endif()
-list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
-)
-
-JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
-  /usr/include
-  /usr/local/include
-  /usr/lib/java/include
-  /usr/local/lib/java/include
-  /usr/lib/jvm/java/include
-  /usr/lib/jvm/java-6-sun/include
-  /usr/lib/jvm/java-1.5.0-sun/include
-  /usr/lib/jvm/java-6-sun-1.6.0.00/include       # can this one be removed according to #8821 ? Alex
-  /usr/lib/jvm/java-6-openjdk/include
-  /usr/lib/jvm/java-8-openjdk-{libarch}/include  # ubuntu 15.10
-  /usr/lib/jvm/java-7-openjdk-{libarch}/include  # ubuntu 15.10
-  /usr/lib/jvm/java-6-openjdk-{libarch}/include  # ubuntu 15.10
-  /usr/local/share/java/include
-  /usr/lib/j2sdk1.4-sun/include
-  /usr/lib/j2sdk1.5-sun/include
-  /opt/sun-jdk-1.5.0.04/include
-  # Debian specific path for default JVM
-  /usr/lib/jvm/default-java/include
-  # OpenBSD specific path for default JVM
-  /usr/local/jdk-1.7.0/include
-  /usr/local/jdk-1.6.0/include
-  # SuSE specific paths for default JVM
-  /usr/lib64/jvm/java/include
+if(MODJAVA_VER)
+  set(JAVA_AWT_INCLUDE_DIRECTORIES)
+  JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
+    ${LOCALBASE}/jdk-1.8.0/include
+    )
+else(MODJAVA_VER)
+  set(JAVA_AWT_INCLUDE_DIRECTORIES)
+  if(_JAVA_HOME)
+    list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES ${_JAVA_HOME}/include)
+  endif()
+  list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
   )
+
+  JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
+    /usr/include
+    /usr/local/include
+    /usr/lib/java/include
+    /usr/local/lib/java/include
+    /usr/lib/jvm/java/include
+    /usr/lib/jvm/java-6-sun/include
+    /usr/lib/jvm/java-1.5.0-sun/include
+    /usr/lib/jvm/java-6-sun-1.6.0.00/include       # can this one be removed according to #8821 ? Alex
+    /usr/lib/jvm/java-6-openjdk/include
+    /usr/lib/jvm/java-8-openjdk-{libarch}/include  # ubuntu 15.10
+    /usr/lib/jvm/java-7-openjdk-{libarch}/include  # ubuntu 15.10
+    /usr/lib/jvm/java-6-openjdk-{libarch}/include  # ubuntu 15.10
+    /usr/local/share/java/include
+    /usr/lib/j2sdk1.4-sun/include
+    /usr/lib/j2sdk1.5-sun/include
+    /opt/sun-jdk-1.5.0.04/include
+    # Debian specific path for default JVM
+    /usr/lib/jvm/default-java/include
+    # OpenBSD specific path for default JVM
+    ${LOCALBASE}/jdk-1.8.0/include
+    # SuSE specific paths for default JVM
+    /usr/lib64/jvm/java/include
+    )
+endif(MODJAVA_VER)
 
 foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
   get_filename_component(jpath "${JAVA_PROG}" PATH)
