vala: add action arguments, for when no proper vala compiler is found
authorDaiki Ueno <ueno@unixuser.org>
Tue, 11 Sep 2012 08:55:37 +0000 (17:55 +0900)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 26 Oct 2012 13:09:12 +0000 (15:09 +0200)
* m4/vala.m4 (AM_PROG_VALAC): Add optional action arguments to
control the behavior if specified version of valac is not found.
This emulates the behaviour of AM_PATH_PYTHON.
* t/vala4.sh: Enhance.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Copyright-paperwork-exempt: yes

m4/vala.m4
t/vala4.sh

index 5dad452..cf88bf8 100644 (file)
 # variable VALAC is set. Optionally a minimum release number of the
 # compiler can be requested.
 #
-# 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], [])
  AS_IF([test -z "$VALAC"],
-   [AC_MSG_WARN([No Vala compiler found.  You will not be able to compile .vala source files.])],
+   [m4_default([$3], [AC_MSG_WARN([No Vala compiler found.  You will not be able to compile .vala source files.])])],
    [AS_IF([test -n "$1"],
       [AC_MSG_CHECKING([$VALAC is at least version $1])
        am__vala_version=`$VALAC --version | sed 's/Vala  *//'`
@@ -23,5 +23,9 @@ AC_DEFUN([AM_PROG_VALAC],
          [AC_MSG_RESULT([yes])],
          [AC_MSG_RESULT([yes])],
          [AC_MSG_RESULT([no])
-          AC_MSG_ERROR([Vala $1 not found.], [77])])])])
-])
+          VALAC=:])])
+    if test "$VALAC" = :; then
+      m4_default([$3], [AC_MSG_ERROR([Vala $1 not found.], [77])])
+    else
+      m4_default([$2], [:])
+    fi])])
index a727ec5..60cb79c 100755 (executable)
@@ -58,4 +58,15 @@ $AUTOCONF --force
 # See comments above for why "|| exit 1" is needed.
 ./configure "VALAC=$cwd/valac" || exit 1
 
+sed 's/AM_PROG_VALAC.*/AM_PROG_VALAC([9999.9], , [:])/' < configure.ac >t
+mv -f t configure.ac
+$AUTOCONF --force
+./configure "VALAC=$cwd/valac" || exit 1
+
+sed 's/AM_PROG_VALAC.*/AM_PROG_VALAC([1.2.3], [exit 77])/' < configure.ac >t
+mv -f t configure.ac
+$AUTOCONF --force
+st=0; ./configure "VALAC=$cwd/valac" || st=$?
+test $st -eq 77 || exit 1
+
 :