[Vala] Vala autoconf macro
- From: "Michael Terry" <mike mterry name>
- To: vala-list gnome org
- Subject: [Vala] Vala autoconf macro
- Date: Tue, 19 Aug 2008 13:53:06 -0400
Hello, all!
I recently rewrote a little puzzle game [1] I maintain into Vala from
C++. I'm a big fan of Vala, so thanks! The app is called gmult, and
emulates the mpuz game found in emacs.
I'm writing this list because I thought I'd share one of the packaging
tricks I used. I copied most of the Makefile.am magic from other Vala
apps, but I did write a useful autoconf macro that tests for valac and
its version.
If you stick the following in acinclude.m4, you can use it in
configure.ac (inspired by intltool.m4):
dnl AC_PROG_VALAC([MINIMUM-VERSION])
AC_DEFUN([AC_PROG_VALAC], [
AC_PATH_PROG([VALAC], [valac], [])
USE_VALAC=true
if test -z "$VALAC"; then
AC_MSG_WARN([Vala compilation is disabled.])
USE_VALAC=false
elif test -n "$1"; then
AC_MSG_CHECKING([valac version >= $1])
VALAC_REQUIRED_VERSION_AS_INT=`echo $1 | awk -F. '{ print $ 1 *
1000 + $ 2 * 100 + $ 3; }'`
VALAC_APPLIED_VERSION=`$VALAC --version | head -1 | cut -d" " -f2`
[VALAC_APPLIED_VERSION_AS_INT=`echo $VALAC_APPLIED_VERSION | awk
-F. '{ print $ 1 * 1000 + $ 2 * 100 + $ 3; }'`
]
AC_MSG_RESULT([$VALAC_APPLIED_VERSION found])
if test "$VALAC_APPLIED_VERSION_AS_INT" -lt
"$VALAC_REQUIRED_VERSION_AS_INT"; then
AC_MSG_WARN([Your valac is too old. You need valac $1 or later.])
AC_MSG_WARN([Vala compilation is disabled.])
USE_VALAC=false
fi
fi
AM_CONDITIONAL([USE_VALAC], [test x$USE_VALAC = xtrue])
])
Then, in your configure.ac, something like:
AC_PROG_VALAC([0.3.5])
And in your source directory's Makefile.am:
program.stamp: $(program_VALASOURCES)
if USE_VALAC
$(VALAC) -C $(VALA_CFLAGS) $^
touch $@
else
@echo "ERROR: Valac compilation is disabled, but the C sources
are out-of-date."
@exit 1
endif
EXTRA_DIST = program.stamp
This way, you can distribute a source tarball that does not depend
upon valac, but can use it if it is available and recent enough. If
this has already been done elsewhere better, please let me know! :)
-mt
[1] http://mterry.name/gmult/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]