Skip to content

Commit c840721

Browse files
authored
Merge pull request #5028 from ggouaillardet/topic/v3.1.x/javah
configury: use javac vs javah whenever possible
2 parents 1d8e717 + 0d04124 commit c840721

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

config/opal_setup_java.m4

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dnl reserved.
1515
dnl Copyright (c) 2007-2012 Oracle and/or its affiliates. All rights reserved.
1616
dnl Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
1717
dnl Copyright (c) 2013 Intel, Inc. All rights reserved.
18-
dnl Copyright (c) 2015 Research Organization for Information Science
18+
dnl Copyright (c) 2015-2018 Research Organization for Information Science
1919
dnl and Technology (RIST). All rights reserved.
2020
dnl Copyright (c) 2017 FUJITSU LIMITED. All rights reserved.
2121
dnl $COPYRIGHT$
@@ -37,7 +37,7 @@ AC_DEFUN([OPAL_SETUP_JAVA_BANNER],[
3737
AC_DEFUN([OPAL_SETUP_JAVA],[
3838
AC_REQUIRE([OPAL_SETUP_JAVA_BANNER])
3939

40-
OPAL_VAR_SCOPE_PUSH([opal_java_bad opal_java_found opal_java_dir opal_java_jnih opal_java_PATH_save opal_java_CPPFLAGS_save])
40+
OPAL_VAR_SCOPE_PUSH([opal_java_bad opal_javah_happy opal_java_found opal_java_dir opal_java_jnih opal_java_PATH_save opal_java_CPPFLAGS_save])
4141
AC_ARG_ENABLE(java,
4242
AC_HELP_STRING([--enable-java],
4343
[Enable Java-based support in the system - use this option to disable all Java-based compiler tests (default: enabled)]))
@@ -161,13 +161,13 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
161161
AS_IF([test -n "$with_jdk_bindir" && test "$with_jdk_bindir" != "yes" && test "$with_jdk_bindir" != "no"],
162162
[PATH="$with_jdk_bindir:$PATH"])
163163
AC_PATH_PROG(JAVAC, javac)
164-
AC_PATH_PROG(JAVAH, javah)
165164
AC_PATH_PROG(JAR, jar)
166165
AC_PATH_PROG(JAVADOC, javadoc)
166+
AC_PATH_PROG(JAVAH, javah)
167167
PATH=$opal_java_PATH_save
168168

169-
# Check to see if we have all 4 programs.
170-
AS_IF([test -z "$JAVAC" || test -z "$JAVAH" || test -z "$JAR" || test -z "$JAVADOC"],
169+
# Check to see if we have all 3 programs.
170+
AS_IF([test -z "$JAVAC" || test -z "$JAR" || test -z "$JAVADOC"],
171171
[opal_java_happy=no
172172
HAVE_JAVA_SUPPORT=0],
173173
[opal_java_happy=yes
@@ -178,6 +178,21 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
178178
[opal_java_CPPFLAGS_save=$CPPFLAGS
179179
# silence a stupid Mac warning
180180
CPPFLAGS="$CPPFLAGS -DTARGET_RT_MAC_CFM=0"
181+
AC_MSG_CHECKING([javac -h])
182+
cat > Conftest.java << EOF
183+
public final class Conftest {
184+
public native void conftest();
185+
}
186+
EOF
187+
AS_IF([$JAVAC -d . -h . Conftest.java > /dev/null 2>&1],
188+
[AC_MSG_RESULT([yes])],
189+
[AC_MSG_RESULT([no])
190+
AS_IF([test -n "$JAVAH"],
191+
[opal_javah_happy=yes],
192+
[opal_java_happy=no])])
193+
rm -f Conftest.java Conftest.class Conftest.h
194+
195+
181196
AS_IF([test -n "$with_jdk_headers" && test "$with_jdk_headers" != "yes" && test "$with_jdk_headers" != "no"],
182197
[OPAL_JDK_CPPFLAGS="-I$with_jdk_headers"
183198
# Some flavors of JDK also require -I<blah>/linux.
@@ -216,5 +231,6 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
216231

217232
AC_DEFINE_UNQUOTED([OPAL_HAVE_JAVA_SUPPORT], [$HAVE_JAVA_SUPPORT], [do we have Java support])
218233
AM_CONDITIONAL(OPAL_HAVE_JAVA_SUPPORT, test "$opal_java_happy" = "yes")
234+
AM_CONDITIONAL(OPAL_HAVE_JAVAH_SUPPORT, test "$opal_javah_happy" = "yes")
219235
OPAL_VAR_SCOPE_POP
220236
])

ompi/mpi/java/java/Makefile.am

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ ompi__v_JAVADOC_QUIET_0 = -quiet
140140
# in. This, along with the fact that the .java files seem to have
141141
# circular references, prevents us from using a .foo.bar: generic
142142
# Makefile rule. :-(
143+
if OPAL_HAVE_JAVAH_SUPPORT
143144
mpi/MPI.class: $(JAVA_SRC_FILES)
144145
$(OMPI_V_JAVAC) CLASSPATH=. ; \
145146
export CLASSPATH ; \
@@ -148,11 +149,18 @@ mpi/MPI.class: $(JAVA_SRC_FILES)
148149
# Similar to above, all the generated .h files are dependent upon the
149150
# token mpi/MPI.class file. Hence, all the classes will be generated
150151
# first, then we'll individually generate each of the .h files.
152+
151153
$(JAVA_H): mpi/MPI.class
152154
$(OMPI_V_JAVAH) sourcename=mpi.`echo $@ | sed -e s/^mpi_// -e s/.h$$//`; \
153155
CLASSPATH=. ; \
154156
export CLASSPATH ; \
155157
$(JAVAH) -d . -jni $$sourcename
158+
else
159+
mpi/MPI.class: $(JAVA_SRC_FILES)
160+
$(OMPI_V_JAVAC) CLASSPATH=. ; \
161+
export CLASSPATH ; \
162+
$(JAVAC) -h . -d . $(top_srcdir)/ompi/mpi/java/java/*.java
163+
endif # OPAL_HAVE_JAVAH_SUPPORT
156164

157165
# Generate the .jar file from all the class files. List mpi/MPI.class
158166
# as a dependency so that it fires the rule above that will generate
@@ -171,7 +179,11 @@ java_DATA = mpi.jar
171179
# List all the header files in BUILT_SOURCES so that Automake's "all"
172180
# target will build them. This will also force the building of the
173181
# mpi/*.class files (for the jar file).
182+
if OPAL_HAVE_JAVAH_SUPPORT
174183
BUILT_SOURCES = $(JAVA_H) doc
184+
else
185+
BUILT_SOURCES = mpi/MPI.class doc
186+
endif
175187

176188
# Convenience for building Javadoc docs
177189
jdoc: doc

0 commit comments

Comments
 (0)