Skip to content

Commit 31beff6

Browse files
author
Ralph Castain
committed
Oops - if we don't want the Java bindings, then we really shouldn't be building them :-/
Also ensure we don't try to build them if no Java support was found, and error out if the user requests the bindings and we didn't find Java support. Add a configure flag to skip the Java tests and just force-set the Java support to "disabled" This commit was SVN r26484.
1 parent 88d5e6f commit 31beff6

File tree

3 files changed

+154
-132
lines changed

3 files changed

+154
-132
lines changed

ompi/Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,14 @@ SUBDIRS = \
9191
$(OMPI_MPIEXT_USEMPIF08_DIRS) \
9292
$(OMPI_FORTRAN_USEMPIF08_DIR) \
9393
mpi/fortran/mpiext \
94-
mpi/java \
9594
$(MCA_ompi_FRAMEWORK_COMPONENT_DSO_SUBDIRS) \
9695
$(OMPI_CONTRIB_SUBDIRS)
9796

97+
if OMPI_WANT_JAVA_BINDINGS
98+
SUBDIRS += \
99+
mpi/java
100+
endif
101+
98102
# The ordering of the DIST_SUBDIRS isn't as important, but note that
99103
# its contents *are* different than SUBDIRS. In particular, the
100104
# MPIEXT subdirs has a different value that is *not* equivalent to the

ompi/config/ompi_setup_java.m4

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@ AC_DEFUN([OMPI_SETUP_JAVA_BINDINGS],[
4141
AC_HELP_STRING([--enable-mpi-java],
4242
[enable Java MPI bindings (default: disabled)]))
4343

44+
# check for required support
45+
if test "$orte_java_happy" = "no" -a "$enable_mpi_java" = "yes"; then
46+
AC_MSG_RESULT([yes])
47+
AC_MSG_WARN([Java bindings requested but no Java support found])
48+
AC_MSG_ERROR([cannot continue])
49+
fi
50+
4451
# Only build the Java bindings if requested
45-
if test "$enable_mpi_java" = "yes"; then
52+
if test "$orte_java_happy" = "yes" -a "$enable_mpi_java" = "yes"; then
4653
AC_MSG_RESULT([yes])
4754
WANT_MPI_JAVA_SUPPORT=1
4855
AC_MSG_CHECKING([if shared libraries are enabled])

orte/config/orte_setup_java.m4

Lines changed: 141 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ AC_DEFUN([ORTE_SETUP_JAVA_BANNER],[
3333
AC_DEFUN([ORTE_SETUP_JAVA],[
3434
AC_REQUIRE([ORTE_SETUP_JAVA_BANNER])
3535

36+
AC_ARG_ENABLE(java,
37+
AC_HELP_STRING([--enable-java],
38+
[Enable Java-based support in the system - use this option to disable all Java-based compiler tests (default: enabled)]))
39+
3640
AC_ARG_WITH(jdk-dir,
3741
AC_HELP_STRING([--with-jdk-dir(=DIR)],
3842
[Location of the JDK header directory. If you use this option, do not specify --with-jdk-bindir or --with-jdk-headers.]))
@@ -43,140 +47,147 @@ AC_DEFUN([ORTE_SETUP_JAVA],[
4347
AC_HELP_STRING([--with-jdk-headers(=DIR)],
4448
[Location of the JDK header directory. If you use this option, you must also use --with-jdk-bindir (and you must NOT use --with-jdk-dir)]))
4549

46-
# Check for bozo case: ensure a directory was specified
47-
AS_IF([test "$with_jdk_dir" = "yes" -o "$with_jdk_dir" = "no"],
48-
[AC_MSG_WARN([Must specify a directory name for --with-jdk-dir])
49-
AC_MSG_ERROR([Cannot continue])])
50-
AS_IF([test "$with_jdk_bindir" = "yes" -o "$with_jdk_bindir" = "no"],
51-
[AC_MSG_WARN([Must specify a directory name for --with-jdk-bindir])
52-
AC_MSG_ERROR([Cannot continue])])
53-
AS_IF([test "$with_jdk_headers" = "yes" -o "$with_jdk_headers" = "no"],
54-
[AC_MSG_WARN([Must specify a directory name for --with-jdk-headers])
55-
AC_MSG_ERROR([Cannot continue])])
56-
57-
# Check for bozo case: either specify --with-jdk-dir or
58-
# (--with-jdk-bindir, --with-jdk-headers) -- not both.
59-
bad=0
60-
AS_IF([test -n "$with_jdk_dir" -a -n "$with_jdk_bindir" -o \
61-
-n "$with_jdk_dir" -a -n "$with_jdk_headers"],[bad=1])
62-
AS_IF([test -z "$with_jdk_bindir" -a -n "$with_jdk_headers" -o \
63-
-n "$with_jdk_bindir" -a -z "$with_jdk_headers"],[bad=1])
64-
AS_IF([test "$bad" = "1"],
65-
[AC_MSG_WARN([Either specify --with-jdk-dir or both of (--with-jdk_bindir, --with-jdk-headers) -- not both.])
66-
AC_MSG_ERROR([Cannot continue])])
67-
68-
AS_IF([test -n "$with_jdk_dir"],
69-
[with_jdk_bindir=$with_jdk_dir/bin
70-
with_jdk_headers=$with_jdk_dir/include])
71-
72-
##################################################################
73-
# with_jdk_dir can now be ignored; with_jdk_bindir and
74-
# with_jdk_headers will be either empty or have valid values.
75-
##################################################################
76-
77-
# Some java installations are in obscure places. So let's
78-
# hard-code a few of the common ones so that users don't have to
79-
# specify --with-java-<foo>=LONG_ANNOYING_DIRECTORY.
80-
AS_IF([test -z "$with_jdk_bindir"],
81-
[ # OS X Snow Leopard and Lion (10.6 and 10.7 -- did not
82-
# check prior versions)
83-
found=0
84-
dir=/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
85-
AC_MSG_CHECKING([OSX locations])
86-
AS_IF([test -d $dir],
87-
[AC_MSG_RESULT([found])
88-
found=1
89-
with_jdk_headers=$dir
90-
with_jdk_bindir=/usr/bin],
91-
[AC_MSG_RESULT([not found])])
92-
93-
if test "$found" = "0"; then
94-
# Various Linux
95-
dir='/usr/lib/jvm/java-*-openjdk-*/include/'
96-
jnih=`ls $dir/jni.h 2>/dev/null | head -n 1`
97-
AC_MSG_CHECKING([Linux locations])
98-
AS_IF([test -r "$jnih"],
99-
[with_jdk_headers=`dirname $jnih`
100-
OPAL_WHICH([javac], [with_jdk_bindir])
101-
AS_IF([test -n "$with_jdk_bindir"],
102-
[AC_MSG_RESULT([found])
103-
found=1
104-
with_jdk_bindir=`dirname $with_jdk_bindir`],
105-
[with_jdk_headers=])],
106-
[dir='/usr/lib/jvm/default-java/include/'
107-
jnih=`ls $dir/jni.h 2>/dev/null | head -n 1`
108-
AS_IF([test -r "$jnih"],
109-
[with_jdk_headers=`dirname $jnih`
110-
OPAL_WHICH([javac], [with_jdk_bindir])
111-
AS_IF([test -n "$with_jdk_bindir"],
112-
[AC_MSG_RESULT([found])
113-
found=1
114-
with_jdk_bindir=`dirname $with_jdk_bindir`],
115-
[with_jdk_headers=])],
116-
[AC_MSG_RESULT([not found])])])
117-
fi
118-
119-
if test "$found" = "0"; then
120-
# Solaris
121-
dir=/usr/java
122-
AC_MSG_CHECKING([Solaris locations])
123-
AS_IF([test -d $dir -a -r "$dir/include/jni.h"],
50+
if test "$enable_java" = "no"; then
51+
HAVE_JAVA_SUPPORT=0
52+
orte_java_happy=no
53+
else
54+
# Check for bozo case: ensure a directory was specified
55+
AS_IF([test "$with_jdk_dir" = "yes" -o "$with_jdk_dir" = "no"],
56+
[AC_MSG_WARN([Must specify a directory name for --with-jdk-dir])
57+
AC_MSG_ERROR([Cannot continue])])
58+
AS_IF([test "$with_jdk_bindir" = "yes" -o "$with_jdk_bindir" = "no"],
59+
[AC_MSG_WARN([Must specify a directory name for --with-jdk-bindir])
60+
AC_MSG_ERROR([Cannot continue])])
61+
AS_IF([test "$with_jdk_headers" = "yes" -o "$with_jdk_headers" = "no"],
62+
[AC_MSG_WARN([Must specify a directory name for --with-jdk-headers])
63+
AC_MSG_ERROR([Cannot continue])])
64+
65+
# Check for bozo case: either specify --with-jdk-dir or
66+
# (--with-jdk-bindir, --with-jdk-headers) -- not both.
67+
bad=0
68+
AS_IF([test -n "$with_jdk_dir" -a -n "$with_jdk_bindir" -o \
69+
-n "$with_jdk_dir" -a -n "$with_jdk_headers"],[bad=1])
70+
AS_IF([test -z "$with_jdk_bindir" -a -n "$with_jdk_headers" -o \
71+
-n "$with_jdk_bindir" -a -z "$with_jdk_headers"],[bad=1])
72+
AS_IF([test "$bad" = "1"],
73+
[AC_MSG_WARN([Either specify --with-jdk-dir or both of (--with-jdk_bindir, --with-jdk-headers) -- not both.])
74+
AC_MSG_ERROR([Cannot continue])])
75+
76+
AS_IF([test -n "$with_jdk_dir"],
77+
[with_jdk_bindir=$with_jdk_dir/bin
78+
with_jdk_headers=$with_jdk_dir/include])
79+
80+
##################################################################
81+
# with_jdk_dir can now be ignored; with_jdk_bindir and
82+
# with_jdk_headers will be either empty or have valid values.
83+
##################################################################
84+
85+
# Some java installations are in obscure places. So let's
86+
# hard-code a few of the common ones so that users don't have to
87+
# specify --with-java-<foo>=LONG_ANNOYING_DIRECTORY.
88+
AS_IF([test -z "$with_jdk_bindir"],
89+
[ # OS X Snow Leopard and Lion (10.6 and 10.7 -- did not
90+
# check prior versions)
91+
found=0
92+
dir=/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
93+
AC_MSG_CHECKING([OSX locations])
94+
AS_IF([test -d $dir],
12495
[AC_MSG_RESULT([found])
125-
with_jdk_headers=$dir/include
126-
with_jdk_bindir=$dir/bin
127-
found=1],
96+
found=1
97+
with_jdk_headers=$dir
98+
with_jdk_bindir=/usr/bin],
12899
[AC_MSG_RESULT([not found])])
129-
fi
130-
],
131-
[found=1])
132100

133-
if test "$found" = "1"; then
134-
OMPI_CHECK_WITHDIR([jdk-bindir], [$with_jdk_bindir], [javac])
135-
OMPI_CHECK_WITHDIR([jdk-headers], [$with_jdk_headers], [jni.h])
136-
137-
# Look for various Java-related programs
138-
orte_java_happy=no
139-
PATH_save=$PATH
140-
AS_IF([test -n "$with_jdk_bindir" -a "$with_jdk_bindir" != "yes" -a "$with_jdk_bindir" != "no"],
141-
[PATH="$PATH:$with_jdk_bindir"])
142-
AC_PATH_PROG(JAVAC, javac)
143-
AC_PATH_PROG(JAVAH, javah)
144-
AC_PATH_PROG(JAR, jar)
145-
PATH=$PATH_save
146-
147-
# Check to see if we have all 3 programs.
148-
AS_IF([test -z "$JAVAC" -o -z "$JAVAH" -o -z "$JAR"],
149-
[orte_java_happy=no
150-
HAVE_JAVA_SUPPORT=0],
151-
[orte_java_happy=yes
152-
HAVE_JAVA_SUPPORT=1])
153-
154-
# Look for jni.h
155-
AS_IF([test "$orte_java_happy" = "yes"],
156-
[CPPFLAGS_save=$CPPFLAGS
157-
AS_IF([test -n "$with_jdk_headers" -a "$with_jdk_headers" != "yes" -a "$with_jdk_headers" != "no"],
158-
[ORTE_JDK_CPPFLAGS="-I$with_jdk_headers"
159-
# Some flavors of JDK also require -I<blah>/linux.
160-
# See if that's there, and if so, add a -I for that,
161-
# too. Ugh.
162-
AS_IF([test -d "$with_jdk_headers/linux"],
163-
[ORTE_JDK_CPPFLAGS="$ORTE_JDK_CPPFLAGS -I$with_jdk_headers/linux"])
164-
# Solaris JDK also require -I<blah>/solaris.
165-
# See if that's there, and if so, add a -I for that,
166-
# too. Ugh.
167-
AS_IF([test -d "$with_jdk_headers/solaris"],
168-
[ORTE_JDK_CPPFLAGS="$ORTE_JDK_CPPFLAGS -I$with_jdk_headers/solaris"])
169-
170-
CPPFLAGS="$CPPFLAGS $ORTE_JDK_CPPFLAGS"])
171-
AC_CHECK_HEADER([jni.h], [],
172-
[orte_java_happy=no])
173-
CPPFLAGS=$CPPFLAGS_save
174-
])
175-
else
176-
orte_java_happy=no;
177-
HAVE_JAVA_SUPPORT=no;
101+
if test "$found" = "0"; then
102+
# Various Linux
103+
dir='/usr/lib/jvm/java-*-openjdk-*/include/'
104+
jnih=`ls $dir/jni.h 2>/dev/null | head -n 1`
105+
AC_MSG_CHECKING([Linux locations])
106+
AS_IF([test -r "$jnih"],
107+
[with_jdk_headers=`dirname $jnih`
108+
OPAL_WHICH([javac], [with_jdk_bindir])
109+
AS_IF([test -n "$with_jdk_bindir"],
110+
[AC_MSG_RESULT([found])
111+
found=1
112+
with_jdk_bindir=`dirname $with_jdk_bindir`],
113+
[with_jdk_headers=])],
114+
[dir='/usr/lib/jvm/default-java/include/'
115+
jnih=`ls $dir/jni.h 2>/dev/null | head -n 1`
116+
AS_IF([test -r "$jnih"],
117+
[with_jdk_headers=`dirname $jnih`
118+
OPAL_WHICH([javac], [with_jdk_bindir])
119+
AS_IF([test -n "$with_jdk_bindir"],
120+
[AC_MSG_RESULT([found])
121+
found=1
122+
with_jdk_bindir=`dirname $with_jdk_bindir`],
123+
[with_jdk_headers=])],
124+
[AC_MSG_RESULT([not found])])])
125+
fi
126+
127+
if test "$found" = "0"; then
128+
# Solaris
129+
dir=/usr/java
130+
AC_MSG_CHECKING([Solaris locations])
131+
AS_IF([test -d $dir -a -r "$dir/include/jni.h"],
132+
[AC_MSG_RESULT([found])
133+
with_jdk_headers=$dir/include
134+
with_jdk_bindir=$dir/bin
135+
found=1],
136+
[AC_MSG_RESULT([not found])])
137+
fi
138+
],
139+
[found=1])
140+
141+
if test "$found" = "1"; then
142+
OMPI_CHECK_WITHDIR([jdk-bindir], [$with_jdk_bindir], [javac])
143+
OMPI_CHECK_WITHDIR([jdk-headers], [$with_jdk_headers], [jni.h])
144+
145+
# Look for various Java-related programs
146+
orte_java_happy=no
147+
PATH_save=$PATH
148+
AS_IF([test -n "$with_jdk_bindir" -a "$with_jdk_bindir" != "yes" -a "$with_jdk_bindir" != "no"],
149+
[PATH="$PATH:$with_jdk_bindir"])
150+
AC_PATH_PROG(JAVAC, javac)
151+
AC_PATH_PROG(JAVAH, javah)
152+
AC_PATH_PROG(JAR, jar)
153+
PATH=$PATH_save
154+
155+
# Check to see if we have all 3 programs.
156+
AS_IF([test -z "$JAVAC" -o -z "$JAVAH" -o -z "$JAR"],
157+
[orte_java_happy=no
158+
HAVE_JAVA_SUPPORT=0],
159+
[orte_java_happy=yes
160+
HAVE_JAVA_SUPPORT=1])
161+
162+
# Look for jni.h
163+
AS_IF([test "$orte_java_happy" = "yes"],
164+
[CPPFLAGS_save=$CPPFLAGS
165+
# silence a stupid Mac warning
166+
CPPFLAGS="$CPPFLAGS -DTARGET_RT_MAC_CFM=0"
167+
AS_IF([test -n "$with_jdk_headers" -a "$with_jdk_headers" != "yes" -a "$with_jdk_headers" != "no"],
168+
[ORTE_JDK_CPPFLAGS="-I$with_jdk_headers"
169+
# Some flavors of JDK also require -I<blah>/linux.
170+
# See if that's there, and if so, add a -I for that,
171+
# too. Ugh.
172+
AS_IF([test -d "$with_jdk_headers/linux"],
173+
[ORTE_JDK_CPPFLAGS="$ORTE_JDK_CPPFLAGS -I$with_jdk_headers/linux"])
174+
# Solaris JDK also require -I<blah>/solaris.
175+
# See if that's there, and if so, add a -I for that,
176+
# too. Ugh.
177+
AS_IF([test -d "$with_jdk_headers/solaris"],
178+
[ORTE_JDK_CPPFLAGS="$ORTE_JDK_CPPFLAGS -I$with_jdk_headers/solaris"])
179+
180+
CPPFLAGS="$CPPFLAGS $ORTE_JDK_CPPFLAGS"])
181+
AC_CHECK_HEADER([jni.h], [],
182+
[orte_java_happy=no])
183+
CPPFLAGS=$CPPFLAGS_save
184+
])
185+
else
186+
orte_java_happy=no;
187+
HAVE_JAVA_SUPPORT=no;
188+
fi
189+
AC_SUBST(ORTE_JDK_CPPFLAGS)
178190
fi
179-
AC_SUBST(ORTE_JDK_CPPFLAGS)
180191

181192
# Are we happy?
182193
AC_MSG_CHECKING([Java support available])

0 commit comments

Comments
 (0)