Permalink
Browse files

Closes #48? Check JAVA_HOME at configure time, and carry it over as a

fallback into the init script.
  • Loading branch information...
1 parent 4b50b89 commit 3bb2cd560f64f734a5b3cfd2f8cb75c6f691d31e graziano obertelli committed Feb 3, 2009
Showing with 49 additions and 7 deletions.
  1. +11 −2 configure
  2. +9 −1 configure.ac
  3. +29 −4 tools/eucalyptus.in
View
@@ -4470,6 +4470,14 @@ echo "${ECHO_T}no" >&6; }
SET_MAKE="MAKE=${MAKE-make}"
fi
+
+# we need JAVA_HOME
+if test -z "$JAVA_HOME" ; then
+ { { echo "$as_me:$LINENO: error: JAVA_HOME is not defined!" >&5
+echo "$as_me: error: JAVA_HOME is not defined!" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
# Extract the first word of "ant", so it can be a program name with args.
set dummy ant; ac_word=$2
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
@@ -4524,8 +4532,7 @@ else
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_dummy="$JAVA_HOME/bin:$PATH"
-for as_dir in $as_dummy
+for as_dir in $JAVA_HOME/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
@@ -4572,6 +4579,7 @@ if test $goodversion -eq 0; then
echo "$as_me: error: Eucalyptus needs at least JDK version $java_min_version" >&2;}
{ (exit 1); exit 1; }; }
fi
+export JAVA_HOME
ant_version=`$ANT -version 2>&1 | grep "Ant version" | \
sed -e 's/.*Ant version \([0-9.]*\).*/\1/'`
goodversion=`expr $ant_version ">=" $ant_min_version`
@@ -4590,6 +4598,7 @@ echo "$as_me: error: ANT is using the wrong java (version less than $java_min_ve
{ (exit 1); exit 1; }; }
fi
+
# Checks for libraries.
# FIXME: Replace `main' with a function in the library
View
@@ -82,8 +82,14 @@ AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
+
+# we need JAVA_HOME
+if test -z "$JAVA_HOME" ; then
+ AC_MSG_ERROR([JAVA_HOME is not defined!])
+fi
+
AC_PATH_PROG([ANT], ant,,$ANT_HOME/bin:$PATH)
-AC_PATH_PROG([JAVA], java,,$JAVA_HOME/bin:$PATH)
+AC_PATH_PROG([JAVA], java,,$JAVA_HOME/bin)
# Check the version of java and ant
if test -z "$ANT" ; then
@@ -98,6 +104,7 @@ goodversion=`expr $java_version ">=" $java_min_version`
if test $goodversion -eq 0; then
AC_MSG_ERROR([Eucalyptus needs at least JDK version $java_min_version])
fi
+export JAVA_HOME
ant_version=`$ANT -version 2>&1 | grep "Ant version" | \
sed -e 's/.*Ant version \([[0-9.]]*\).*/\1/'`
goodversion=`expr $ant_version ">=" $ant_min_version`
@@ -112,6 +119,7 @@ if test $goodversion -eq 0; then
AC_MSG_ERROR([ANT is using the wrong java (version less than $java_min_version)])
fi
+
# Checks for libraries.
# FIXME: Replace `main' with a function in the library
AC_CHECK_LIB([axis2_axiom],[main],,AC_MSG_ERROR([Cannot find axis2 libs!]))
View
@@ -24,20 +24,45 @@ START_CLOUD="N"
NAME=eucalyptus
BRCTL="`which brctl 2> /dev/null`"
ANT="`which ant 2> /dev/null`"
+JAVA="`which java 2> /dev/null`"
# honor the ENV variable if found otherwise look in root
if [ -z "$EUCALYPTUS" ] ; then
EUCALYPTUS="@prefix@"
fi
export EUCALYPTUS
+
check_java() {
java_min_version="1.6.0"
- java_version=`java -version 2>&1 | grep "java version" | sed -e 's/.*java version "\(.*\)".*/\1/'`
- if [ `expr $java_version ">=" $java_min_version` -eq 0 ]; then
- echo "Eucalyptus needs java version >= $java_min_version"
- exit 1
+
+
+ # let's check the default java
+ if [ -n "$JAVA" ]; then
+ java_version=`java -version 2>&1 | grep "java version" | sed -e 's/.*java version "\(.*\)".*/\1/'`
+ if [ `expr $java_version "<" $java_min_version` -eq 0 ]; then
+ return
+ fi
+ fi
+
+ # we don't have a good java, let's look at JAVA_HOME (defined one
+ # or the one which was defined at compile time)
+ if [ -z "$JAVA_HOME" ]; then
+ JAVA_HOME="@JAVA_HOME@"
+ fi
+ JAVA="$JAVA_HOME/bin/java"
+
+ # let's see if we can find a decent java
+ if [ -x "$JAVA" ]; then
+ java_version=`$JAVA -version 2>&1 | grep "java version" | sed -e 's/.*java version "\(.*\)".*/\1/'`
+ if [ `expr $java_version "<" $java_min_version` -eq 0 ]; then
+ export JAVA_HOME
+ return
+ fi
fi
+
+ echo "Eucalyptus needs java version >= $java_min_version"
+ exit 1
}
enable_service() {
for x in ${1}; do

0 comments on commit 3bb2cd5

Please sign in to comment.