Skip to content

Commit 5b22977

Browse files
committed
[build] Update ax_jni_include_dir.m4 macro to deal with recent versions of macOS
1 parent 84973d3 commit 5b22977

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

build-aux/m4/ax_jni_include_dir.m4

+27-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ===========================================================================
2-
# http://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html
2+
# https://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html
33
# ===========================================================================
44
#
55
# SYNOPSIS
@@ -44,7 +44,7 @@
4444
# and this notice are preserved. This file is offered as-is, without any
4545
# warranty.
4646

47-
#serial 10
47+
#serial 14
4848

4949
AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR])
5050
AC_DEFUN([AX_JNI_INCLUDE_DIR],[
@@ -59,47 +59,52 @@ else
5959
fi
6060
AC_PATH_PROG([_ACJNI_JAVAC], [$JAVAC], [no])
6161
if test "x$_ACJNI_JAVAC" = xno; then
62-
AC_MSG_WARN([cannot find JDK; try setting \$JAVAC or \$JAVA_HOME])
62+
AC_MSG_ERROR([cannot find JDK; try setting \$JAVAC or \$JAVA_HOME])
6363
fi
6464
_ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
6565
_JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'`
6666
fi
6767
6868
case "$host_os" in
69-
darwin*) _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
70-
_JINC="$_JTOPDIR/Headers";;
71-
*) _JINC="$_JTOPDIR/include";;
69+
darwin*) # Apple Java headers are inside the Xcode bundle.
70+
macos_version=$(sw_vers -productVersion | sed -n -e 's/^@<:@0-9@:>@*.\(@<:@0-9@:>@*\).@<:@0-9@:>@*/\1/p')
71+
if @<:@ "$macos_version" -gt "7" @:>@; then
72+
_JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework"
73+
_JINC="$_JTOPDIR/Headers"
74+
else
75+
_JTOPDIR="/System/Library/Frameworks/JavaVM.framework"
76+
_JINC="$_JTOPDIR/Headers"
77+
fi
78+
;;
79+
*) _JINC="$_JTOPDIR/include";;
7280
esac
7381
_AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR])
7482
_AS_ECHO_LOG([_JINC=$_JINC])
7583
7684
# On Mac OS X 10.6.4, jni.h is a symlink:
7785
# /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h
7886
# -> ../../CurrentJDK/Headers/jni.h.
79-
8087
AC_CACHE_CHECK(jni headers, ac_cv_jni_header_path,
8188
[
82-
if test -f "$_JINC/jni.h"; then
83-
ac_cv_jni_header_path="$_JINC"
84-
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
85-
else
86-
_JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
87-
if test -f "$_JTOPDIR/include/jni.h"; then
88-
ac_cv_jni_header_path="$_JTOPDIR/include"
89+
if test -f "$_JINC/jni.h"; then
90+
ac_cv_jni_header_path="$_JINC"
8991
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
9092
else
91-
ac_cv_jni_header_path=none
93+
_JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
94+
if test -f "$_JTOPDIR/include/jni.h"; then
95+
ac_cv_jni_header_path="$_JTOPDIR/include"
96+
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
97+
else
98+
ac_cv_jni_header_path=none
99+
fi
92100
fi
93-
fi
94101
])
95102
96-
97-
98103
# get the likely subdirectories for system specific java includes
99104
case "$host_os" in
100105
bsdi*) _JNI_INC_SUBDIRS="bsdos";;
101-
darwin*) _JNI_INC_SUBDIRS="darwin";;
102106
freebsd*) _JNI_INC_SUBDIRS="freebsd";;
107+
darwin*) _JNI_INC_SUBDIRS="darwin";;
103108
linux*) _JNI_INC_SUBDIRS="linux genunix";;
104109
osf*) _JNI_INC_SUBDIRS="alpha";;
105110
solaris*) _JNI_INC_SUBDIRS="solaris";;
@@ -112,9 +117,9 @@ if test "x$ac_cv_jni_header_path" != "xnone"; then
112117
# add any subdirectories that are present
113118
for JINCSUBDIR in $_JNI_INC_SUBDIRS
114119
do
115-
if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
116-
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
117-
fi
120+
if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
121+
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
122+
fi
118123
done
119124
fi
120125
])

0 commit comments

Comments
 (0)