Merge branch 'branch-1.13.2' into maint
[platform/upstream/automake.git] / m4 / vala.m4
index 57aae60..c0104f1 100644 (file)
@@ -1,36 +1,37 @@
 # Autoconf support for the Vala compiler
 
-# Copyright (C) 2007 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 2
-
-# Check whether the Vala compiler exists in `PATH'. If it is found the
-# variable VALAC is set. Optionally a minimum release number of the compiler
-# can be requested.
-#
-# Author: Mathias Hasselmann <mathias.hasselmann@gmx.de>
+# Check whether the Vala compiler exists in $PATH.  If it is found, the
+# variable VALAC is set pointing to its absolute path.  Otherwise, it is
+# simply set to 'valac'.
+# Optionally a minimum release number of the compiler can be requested.
+# If the ACTION-IF-FOUND parameter is given, it will be run if a proper
+# Vala compiler is found.
+# Similarly, if the ACTION-IF-FOUND is given, it will be run if no proper
+# Vala compiler is found.  It defaults to simply print a warning about the
+# situation, but otherwise proceeding with the configuration.
 #
-# AM_PROG_VALAC([MINIMUM-VERSION])
+# AM_PROG_VALAC([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # --------------------------------------------------------------------------
-AC_DEFUN([AM_PROG_VALAC],[
-  AC_PATH_PROG([VALAC], [valac], [])
-  AC_SUBST(VALAC)
-
-  if test -z "${VALAC}"; then
-    AC_MSG_WARN([No Vala compiler found. You will not be able to recompile .vala source files.])
-  elif test -n "$1"; then
-    AC_REQUIRE([AC_PROG_AWK])
-    AC_MSG_CHECKING([valac is at least version $1])
-
-    if "${VALAC}" --version | "${AWK}" -v r='$1' 'function vn(s) { if (3 == split(s,v,".")) return (v[1]*1000+v[2])*1000+v[3]; else exit 2; } /^Vala / { exit vn(r) > vn($[2]) }'; then
-      AC_MSG_RESULT([yes])
+AC_DEFUN([AM_PROG_VALAC],
+  [AC_PATH_PROG([VALAC], [valac], [valac])
+   AS_IF([test "$VALAC" != valac && test -n "$1"],
+      [AC_MSG_CHECKING([whether $VALAC is at least version $1])
+       am__vala_version=`$VALAC --version | sed 's/Vala  *//'`
+       AS_VERSION_COMPARE([$1], ["$am__vala_version"],
+         [AC_MSG_RESULT([yes])],
+         [AC_MSG_RESULT([yes])],
+         [AC_MSG_RESULT([no])
+          VALAC=valac])])
+    if test "$VALAC" = valac; then
+      m4_default([$3],
+        [AC_MSG_WARN([no proper vala compiler found])
+         AC_MSG_WARN([you will not be able to compile vala source files])])
     else
-      AC_MSG_RESULT([no])
-      AC_MSG_ERROR([Vala $1 not found.])
-    fi
-  fi
-])
+      m4_default([$2], [:])
+    fi])