Skip to content

Commit cd329db

Browse files
committed
Merge bitcoin#460: [build] Update ax_jni_include_dir.m4 macro
e7daa9b [build] Tweak JNI macro to warn instead of error for JNI not found. (Karl-Johan Alm) 5b22977 [build] Update ax_jni_include_dir.m4 macro to deal with recent versions of macOS (Karl-Johan Alm) Pull request description: Prior to this patch, this macro fails to find a working directory for the JNI headers, and results in compile failure when doing ``` ./configure --enable-experimental --enable-module-ecdh --enable-jni ``` on more recent macOS versions. The relevant commit upstream is [here](http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=commit;h=ab23d25b1f1ae544fffdaa0a94a794798695c672) from the [GNU.org page for the macro](https://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html). The original (identical to the version in this commit) is [here](http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_jni_include_dir.m4). The compile failure: ```Bash $ make gcc -I. -g -O2 -Wall -Wextra -Wno-unused-function -c src/gen_context.c -o gen_context.o gcc gen_context.o -o gen_context ./gen_context CC src/libsecp256k1_la-secp256k1.lo CC src/java/libsecp256k1_jni_la-org_bitcoin_NativeSecp256k1.lo In file included from src/java/org_bitcoin_NativeSecp256k1.c:4: In file included from src/java/org_bitcoin_NativeSecp256k1.h:2: /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Headers/jni.h:45:10: fatal error: 'jni_md.h' file not found #include "jni_md.h" ^ 1 error generated. make: *** [src/java/libsecp256k1_jni_la-org_bitcoin_NativeSecp256k1.lo] Error 1 ``` Tree-SHA512: 9a8305b3ed67eba0de728f91cf435857a676ba10507ab8481a3c03b50e1ce0469a3d79e751d0a697018789f21e2aa48b7eccca4d225520a3863fcf23f1fd487a
2 parents 7f9c1a1 + e7daa9b commit cd329db

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

build-aux/m4/ax_jni_include_dir.m4

Lines changed: 26 additions & 21 deletions
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],[
@@ -66,40 +66,45 @@ else
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)