From 07a0c7ce6eca3dbb9cc7ac371c3147f331343ff7 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Sun, 7 Jan 2018 11:35:05 +0000
Subject: [PATCH 12/13] javareconf (macOS): Continue to allow system Java lt 9
 to be detected as such

Java 9 is for macOS 10.10 and above, we still support 10.9

Without this change:
JAVA_HOME        : /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Java library path: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries
JNI cpp flags    :
JNI linker flags : -L/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries -ljvm

With this change:
JAVA_HOME        : /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Java library path:
JNI cpp flags    : -I/System/Library/Frameworks/JavaVM.framework/Headers
JNI linker flags : -framework JavaVM

The problems without this change are that libjvm.so on Apple's Java 1.6.0 JDK (2015 and 2017)
is 32-bit only and jni.h does not get found without JNI cpp flags being set.
---
 src/scripts/javareconf.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/R/bin/javareconf b/lib/R/bin/javareconf
index ca72145269..b6dfc3e63e 100644
--- a/lib/R/bin/javareconf
+++ b/lib/R/bin/javareconf
@@ -204,7 +204,7 @@ hostos=`uname 2>/dev/null`
 if test "${hostos}" = "Darwin"; then
      ## This changed for Java 9.
      ## pref=`echo "${JAVA_HOME}" | grep "/Home$"`
-     pref=`echo "${JAVA_HOME}" | grep "^/System/Library"`
+     pref=`echo "${JAVA_HOME}" | grep "^/System/Library\|/Home$"`
      if test "${pref}" = "${JAVA_HOME}"; then
        echo "System Java on macOS"
        JAVA_CPPFLAGS="-I/System/Library/Frameworks/JavaVM.framework/Headers"
-- 
2.17.0

