Permalink
Browse files

Don't require JAVA_HOME if it can be guessed from javac location

  • Loading branch information...
1 parent b007008 commit 2109baac219a16280035e1271892328adc60b572 Andy Grimm committed Oct 7, 2011
Showing with 51 additions and 2 deletions.
  1. +45 −1 configure
  2. +6 −1 configure.ac
View
@@ -4764,7 +4764,51 @@ fi
# we need JAVA_HOME
if test -z "$JAVA_HOME" ; then
- as_fn_error $? "JAVA_HOME is not defined!" "$LINENO" 5
+ # Extract the first word of "javac", so it can be a program name with args.
+set dummy javac; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_JAVAC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $JAVAC in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_JAVAC="$JAVAC" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_JAVAC="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+JAVAC=$ac_cv_path_JAVAC
+if test -n "$JAVAC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVAC" >&5
+$as_echo "$JAVAC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test -z "$JAVAC" ; then
+ as_fn_error $? "JAVA_HOME is not defined and javac was not found in PATH" "$LINENO" 5
+ else
+ JAVA_HOME=$( readlink -f ${JAVAC} | rev | cut -d/ -f3- | rev )
+ fi
fi
# Extract the first word of "ant", so it can be a program name with args.
View
@@ -165,7 +165,12 @@ fi
# we need JAVA_HOME
if test -z "$JAVA_HOME" ; then
- AC_MSG_ERROR([JAVA_HOME is not defined!])
+ AC_PATH_PROG([JAVAC], javac,, $PATH)
+ if test -z "$JAVAC" ; then
+ AC_MSG_ERROR([JAVA_HOME is not defined and javac was not found in PATH])
+ else
+ JAVA_HOME=$( readlink -f ${JAVAC} | rev | cut -d/ -f3- | rev )
+ fi
fi
AC_PATH_PROG([ANT], ant,,$ANT_HOME/bin:$PATH)

0 comments on commit 2109baa

Please sign in to comment.