changeset 160:d3edae4807f0

Add new macro IT_FIND_OPTIONAL_JAR Introduce a new autoconf macro IT_FIND_OPTIONAL_JAR that find a jar (but does not fail if the jar is not available). Also make RHINO use this new macro. 2011-03-08 Omair Majid <omajid@redhat.com> * acinclude.m4 (IT_FIND_OPTIONAL_JAR): New macro. * configure.ac: Do not call IT_FIND_RHINO. Use IT_FIND_OPTIONAL_JAR instead.
author Omair Majid <omajid@redhat.com>
date Tue, 08 Mar 2011 17:42:53 -0500
parents 67ae546b6605
children 1d1539d38db0
files ChangeLog acinclude.m4 configure.ac
diffstat 3 files changed, 86 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 08 15:02:45 2011 -0500
+++ b/ChangeLog	Tue Mar 08 17:42:53 2011 -0500
@@ -1,3 +1,9 @@
+2011-03-08  Omair Majid  <omajid@redhat.com>
+
+	* acinclude.m4 (IT_FIND_OPTIONAL_JAR): New macro.
+	* configure.ac: Do not call IT_FIND_RHINO. Use IT_FIND_OPTIONAL_JAR
+	instead.
+
 2011-03-08  Denis Lila  <dlila@redhat.com>
 
 	* netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java
--- a/acinclude.m4	Tue Mar 08 15:02:45 2011 -0500
+++ b/acinclude.m4	Tue Mar 08 17:42:53 2011 -0500
@@ -250,6 +250,79 @@
   AC_SUBST(ECJ_JAR)
 ])
 
+#
+# IT_FIND_OPTIONAL_JAR
+# --------------------
+# Find an optional jar required for building and running
+#
+# $1 : jar/feature name
+# $2 : used to set $2_JAR and WITH_$2
+# $3 (optional) : used to specify additional file paths for searching
+#
+# Sets $2_JAR to the jar location (or blank if not found)
+# Defines WITH_$2 if jar is found
+# Sets $2_AVAILABLE to "true" if jar is found (or "false" if not)
+#
+AC_DEFUN([IT_FIND_OPTIONAL_JAR],
+[
+  AC_MSG_CHECKING([for $1 jar])
+  AC_ARG_WITH([$1],
+              [AS_HELP_STRING(--with-$1,specify location of the $1 jar)],
+  [
+    case "${withval}" in
+      yes)
+        $2_JAR=yes
+        ;;
+      no)
+        $2_JAR=no
+        ;;
+      *)
+        if test -f "${withval}"; then
+          $2_JAR="${withval}"
+        elif test -z "${withval}"; then
+          $2_JAR=yes
+        else
+          AC_MSG_RESULT([not found])
+          AC_MSG_ERROR("The $1 jar ${withval} was not found.")
+        fi
+        ;;
+    esac
+  ],
+  [
+    $2_JAR=yes
+  ])
+  it_extra_paths_$1="$3"
+  if test "x${$2_JAR}" = "xyes"; then
+    for path in ${it_extra_paths_$1}; do
+      if test -f ${path}; then
+        $2_JAR=${path}
+        break
+      fi
+    done
+  fi
+  if test x"${$2_JAR}" = "xyes"; then
+    if test -f "/usr/share/java/$1.jar"; then
+      $2_JAR=/usr/share/java/$1.jar
+    fi
+  fi
+  if test x"${$2_JAR}" = "xyes"; then
+    $2_JAR=no
+  fi
+  AC_MSG_RESULT(${$2_JAR})
+  AM_CONDITIONAL(WITH_$2, test x"${$2_JAR}" != "xno")
+  # Clear $2_JAR if it doesn't contain a valid filename
+  if test x"${$2_JAR}" = "xno"; then
+    $2_JAR=
+  fi
+  if test -n "${$2_JAR}" ; then
+    $2_AVAILABLE=true
+  else
+    $2_AVAILABLE=false
+  fi
+  AC_SUBST($2_JAR)
+  AC_SUBST($2_AVAILABLE)
+])
+
 AC_DEFUN([IT_FIND_RHINO_JAR],
 [
   AC_MSG_CHECKING([whether to include Javascript support via Rhino])
--- a/configure.ac	Tue Mar 08 15:02:45 2011 -0500
+++ b/configure.ac	Tue Mar 08 17:42:53 2011 -0500
@@ -33,7 +33,6 @@
 FIND_JAR
 FIND_ECJ_JAR
 IT_FIND_JAVADOC
-IT_FIND_RHINO_JAR
 AC_CONFIG_FILES([javac], [chmod +x javac])
 
 IT_SET_VERSION
@@ -80,6 +79,13 @@
 IT_CHECK_FOR_CLASS(SUN_APPLET_APPLETIMAGEREF, [sun.applet.AppletImageRef])
 IT_CHECK_FOR_APPLETVIEWERPANEL_HOLE
 
+#
+# Find optional depedencies
+#
+
+IT_FIND_OPTIONAL_JAR([rhino], RHINO,
+    [/usr/share/java/js.jar /usr/share/rhino-1.6/lib/js.jar])
+
 AC_CONFIG_FILES([jrunscript], [chmod u+x jrunscript])
 AC_CONFIG_FILES([build.properties])