[PATCH] Passing a bogus value to 'configure --with-java' should cause error

Maynard Johnson <[email protected]>
Newsgroups gmane.linux.oprofile
Message-ID <[email protected]>
Passing a bogus value to 'configure --with-java' should cause error

The "--with-java" configure option expects either "no", "yes", or a
path to a directory which has an 'include' directory containing either
jvmpi.h or jvmti.h or both. If the user who is running 'configure'
specifies an incorrect pathname, the configure script continues on to
the end and exits normally with no error message. If the user looks
carefully at the output of the configure script, they will see messages
indicating jvmpi.h and jvmti.h were not found, but that's not sufficient
warning to the user that something went wrong.

This patch will detect an invalid Java home pathname and exit immediately
with an error.

Signed-off-by: Maynard Johnson <[email protected]>
---
 configure.ac |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 65b43f2..015d7be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -224,6 +224,8 @@ if test "x$with_java" = "xyes"; then
 	JAVA_HOMEDIR="/usr"
 else if test "x$with_java" = "xno"; then
 	JAVA_HOMEDIR=
+	else
+		JAVA_HOME_SPECIFIED="yes"
 	fi
 fi
 AC_SUBST(JAVA_HOMEDIR)
@@ -232,6 +234,15 @@ if test -n "$JAVA_HOMEDIR"; then
 	AC_CHECK_FILE("$JAVA_HOMEDIR/include/jvmti.h",JVMTI_H_EXISTS="yes",)
 	AC_CHECK_FILE("$JAVA_HOMEDIR/include/jvmpi.h",JVMPI_H_EXISTS="yes",)
 fi
+if test -n "$JAVA_HOME_SPECIFIED"  && test -z "$JVMTI_H_EXISTS" && test -z "$JVMPI_H_EXISTS"; then
+	if test -d "$JAVA_HOMEDIR"; then
+		echo "You specified the "--with-java" option, but neither jvmti.h nor jvmpi.h were found."
+	else
+		echo "You specified the "--with-java" option, but $JAVA_HOMEDIR does not exist."
+	fi
+	exit
+fi
+
 
 AM_CONDITIONAL(BUILD_JVMTI_AGENT, test -n "$JVMTI_H_EXISTS")
 AM_CONDITIONAL(BUILD_JVMPI_AGENT, test -n "$JVMPI_H_EXISTS")
-- 
1.7.1


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.