Skip to content

Commit ec2367e

Browse files
authored
Merge pull request #5153 from kawashima-fj/pr/v2.x/apple_java_path
v2.x: Improve JDK tool path resolution on OS X/macOS
2 parents deb66bf + 5e07252 commit ec2367e

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

config/opal_setup_java.m4

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,29 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
9292
# hard-code a few of the common ones so that users don't have to
9393
# specify --with-java-<foo>=LONG_ANNOYING_DIRECTORY.
9494
AS_IF([test -z "$with_jdk_bindir"],
95-
[ # OS X Snow Leopard and Lion (10.6 and 10.7 -- did not
96-
# check prior versions)
95+
[ # OS X/macOS
9796
opal_java_found=0
98-
opal_java_dir=/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
99-
AC_MSG_CHECKING([OSX locations])
97+
# The following logic was deliberately decided upon in https://github.com/open-mpi/ompi/pull/5015 specifically to prevent this script and the
98+
# rest of Open MPI's build system from getting confused by the somewhat unorthodox Java toolchain layout present on OS X/macOS systems, described
99+
# in depth by https://github.com/open-mpi/ompi/pull/5015#issuecomment-379324639, and mishandling OS X/macOS Java toolchain path
100+
# detection as a result.
101+
AS_IF([test -x /usr/libexec/java_home],
102+
[opal_java_dir=`/usr/libexec/java_home`],
103+
[opal_java_dir=/System/Library/Frameworks/JavaVM.framework/Versions/Current])
104+
AC_MSG_CHECKING([OS X/macOS locations])
100105
AS_IF([test -d $opal_java_dir],
101106
[AC_MSG_RESULT([found ($opal_java_dir)])
102107
opal_java_found=1
103-
with_jdk_headers=$opal_java_dir
104-
with_jdk_bindir=/usr/bin],
108+
if test -d "$opal_java_dir/Headers" && test -d "$opal_java_dir/Commands"; then
109+
with_jdk_headers=$opal_java_dir/Headers
110+
with_jdk_bindir=$opal_java_dir/Commands
111+
elif test -d "$opal_java_dir/include" && test -d "$opal_java_dir/bin"; then
112+
with_jdk_headers=$opal_java_dir/include
113+
with_jdk_bindir=$opal_java_dir/bin
114+
else
115+
AC_MSG_WARN([No recognized OS X/macOS JDK directory structure found under $opal_java_dir])
116+
opal_java_found=0
117+
fi],
105118
[AC_MSG_RESULT([not found])])
106119

107120
if test "$opal_java_found" = "0"; then

0 commit comments

Comments
 (0)