[tracker/tracker-0.10] libtracker-sparql: Dirty 'sed' only when really needed



commit fa46d2fd80a6ab9736403dca2a1038cfee190ee8
Author: Ivan Frade <ivan frade nokia com>
Date:   Fri Mar 25 10:55:35 2011 +0200

    libtracker-sparql: Dirty 'sed' only when really needed
    
    If vala is recent enough, the "sed" operation is not needed.
    Also, run the sed trick only once on the file.
    
    Vala version is checked via new m4 function.
    
    Removed the .gir from the CLEANFILES. It must be cleaned only when
    the library it comes from is cleaned.

 configure.ac                      |    3 +++
 m4/vala-extra.m4                  |   26 ++++++++++++++++++++++++++
 src/libtracker-sparql/Makefile.am |   15 +++++++++++----
 3 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8e3edfa..c845762 100644
--- a/configure.ac
+++ b/configure.ac
@@ -481,6 +481,9 @@ fi
 
 AC_SUBST(VALAC)
 
+AX_VALA_CHECK_VERSION([0.11.8], vala_good_gir=true, vala_good_gir=false)
+AM_CONDITIONAL(VALA_GOOD_GIR, test "x$vala_good_gir" == "xtrue")
+
 ####################################################################
 # Check gettext/intltool support
 ####################################################################
diff --git a/m4/vala-extra.m4 b/m4/vala-extra.m4
new file mode 100644
index 0000000..0851ebc
--- /dev/null
+++ b/m4/vala-extra.m4
@@ -0,0 +1,26 @@
+dnl Copyright (C) 2011 Nokia <ivan frade nokia com>
+dnl This file is free software; unlimited permission to copy and/or distribute
+dnl  it is given, with or without modifications, as long as this notice is
+dnl  preserved.
+
+dnl AX_VALA_CHECK_VERSION([MIN_VERSION], [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+dnl ---------------------------------------------------------------------------
+dnl Run ACTION-IF-TRUE if the vala compiler is installed AND has version >= VERSION.
+dnl Run ACTION-IF-FALSE otherwise.
+
+dnl This macro doesn't check if valac is installed (use AM_PROG_VALAC or your
+dnl own AC_PATH_PROG to check that)
+
+AC_DEFUN([AX_VALA_CHECK_VERSION],
+[
+  AC_MSG_CHECKING([valac generates proper GIR])
+  AS_IF([test "x$VALAC" != "x"], [], [AC_PATH_PROG([VALAC], [valac], [])])
+  am__vala_version=`$VALAC --version | sed 's/Vala  *//'`
+  AS_VERSION_COMPARE([$1], ["$am__vala_version"], 
+       [AC_MSG_RESULT([yes]) 
+        $2], 
+       [AC_MSG_RESULT([yes]) 
+        $2], 
+       [AC_MSG_RESULT([no]) 
+        $3])
+])
diff --git a/src/libtracker-sparql/Makefile.am b/src/libtracker-sparql/Makefile.am
index f95a650..fdce74e 100644
--- a/src/libtracker-sparql/Makefile.am
+++ b/src/libtracker-sparql/Makefile.am
@@ -60,9 +60,16 @@ EXTRA_DIST =                                           \
 -include $(INTROSPECTION_MAKEFILE)
 
 if HAVE_INTROSPECTION
-#  set introspectable=0 to the function that uses va_list. This is not needed with a modern vala ( > 23/03/2011)
-Tracker- TRACKER_API_VERSION@.gir: $(lib_LTLIBRARIES)
-	sed -i $@ -e "s/c\:identifier\=\"tracker_sparql_escape_uri_vprintf\"/c\:identifier\=\"tracker_sparql_escape_uri_vprintf\"\ introspectable=\"0\"/g"
+
+#  set introspectable=0 to the function that uses va_list. This is not needed with a modern vala ( >= 0.11.8)
+if VALA_GOOD_GIR
+Tracker- TRACKER_API_VERSION@.gir: $(lib_LTLIBRARIES) Makefile
+else
+Tracker- TRACKER_API_VERSION@.gir: $(lib_LTLIBRARIES) Makefile
+	if [[ -z `grep tracker_sparql_escape_uri_vprintf $@ |grep introspectable` ]] ; then \
+	  sed -i $@ -e "s/c\:identifier\=\"tracker_sparql_escape_uri_vprintf\"/c\:identifier\=\"tracker_sparql_escape_uri_vprintf\"\ introspectable=\"0\"/g" ; \
+        fi
+endif
 
 Tracker- TRACKER_API_VERSION@.typelib: Tracker-$(TRACKER_API_VERSION).gir
 	@INTROSPECTION_COMPILER@ --shared-library=libtracker-sparql- TRACKER_API_VERSION@.so -o $@ $^
@@ -73,5 +80,5 @@ dist_gir_DATA = Tracker-$(TRACKER_API_VERSION).gir
 typelibdir = $(libdir)/girepository-1.0
 typelib_DATA = Tracker-$(TRACKER_API_VERSION).typelib
 
-CLEANFILES = $(dist_gir_DATA) $(typelib_DATA)
+CLEANFILES = $(typelib_DATA)
 endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]