[libgweather] Add version information API



commit 7fd8ce84126d66e0c05a8c6ad83e281b70790fd0
Author: Javier Jardón <javier jardon codethink co uk>
Date:   Tue Feb 18 22:31:01 2014 +0000

    Add version information API
    
    Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=724676

 configure.ac                      |   19 ++++++-
 doc/libgweather-docs.sgml         |    1 +
 doc/libgweather-sections.txt      |   15 +++++
 libgweather/Makefile.am           |    5 +-
 libgweather/gweather-version.h.in |  110 +++++++++++++++++++++++++++++++++++++
 5 files changed, 147 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 109810d..323d9aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,10 @@
+m4_define(libgweather_major_version,   3)
+m4_define(libgweather_minor_version,  11)
+m4_define(libgweather_micro_version,  91)
+m4_define(libgweather_version, libgweather_major_version.libgweather_minor_version.libgweather_micro_version)
+
 AC_INIT([libgweather],
-        [3.11.91],
+        [libgweather_version],
         [http://bugzilla.gnome.org/enter_bug.cgi?product=libgweather],
         [libgweather],
         [http://live.gnome.org/LibGWeather])
@@ -12,6 +17,17 @@ AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz tar-ustar])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
+dnl === Versioning ============================================================
+
+LIBGWEATHER_MAJOR_VERSION=libgweather_major_version
+LIBGWEATHER_MINOR_VERSION=libgweather_minor_version
+LIBGWEATHER_MICRO_VERSION=libgweather_micro_version
+LIBGWEATHER_VERSION=libgweather_version
+AC_SUBST(LIBGWEATHER_MAJOR_VERSION)
+AC_SUBST(LIBGWEATHER_MINOR_VERSION)
+AC_SUBST(LIBGWEATHER_MICRO_VERSION)
+AC_SUBST(LIBGWEATHER_VERSION)
+
 # Before making a release, the LT_VERSION string should be modified.
 # The string is of the form C:R:A.
 # - If interfaces have been changed or added, but binary compatibility has
@@ -204,6 +220,7 @@ po-locations/Makefile.in
 libgweather/Makefile
 libgweather/gweather-3.0.pc
 libgweather/gweather-3.0-uninstalled.pc
+libgweather/gweather-version.h
 data/Makefile
 data/glade/Makefile
 icons/Makefile
diff --git a/doc/libgweather-docs.sgml b/doc/libgweather-docs.sgml
index 5838df5..1e36804 100644
--- a/doc/libgweather-docs.sgml
+++ b/doc/libgweather-docs.sgml
@@ -21,6 +21,7 @@
     <xi:include href="xml/gweatherinfo.xml"/>
     <xi:include href="xml/gweatherlocationentry.xml"/>
     <xi:include href="xml/gweathertimezonemenu.xml"/>
+    <xi:include href="xml/gweatherversion.xml"/>
 
   </chapter>
   <chapter id="object-tree">
diff --git a/doc/libgweather-sections.txt b/doc/libgweather-sections.txt
index 1db419b..03a21af 100644
--- a/doc/libgweather-sections.txt
+++ b/doc/libgweather-sections.txt
@@ -185,3 +185,18 @@ gweather_timezone_unref
 gweather_timezone_get_utc
 </SECTION>
 
+<SECTION>
+<FILE>gweatherversion</FILE>
+<TITLE>Versioning information</TITLE>
+GWEATHER_MAJOR_VERSION
+GWEATHER_MINOR_VERSION
+GWEATHER_MICRO_VERSION
+
+<SUBSECTION>
+GWEATHER_VERSION
+GWEATHER_VERSION_S
+GWEATHER_VERSION_HEX
+
+<SUBSECTION>
+GWEATHER_CHECK_VERSION
+</SECTION>
diff --git a/libgweather/Makefile.am b/libgweather/Makefile.am
index 325019a..bce99fe 100644
--- a/libgweather/Makefile.am
+++ b/libgweather/Makefile.am
@@ -20,7 +20,8 @@ gweather_new_headers = \
 libgweatherincdir = $(includedir)/libgweather-3.0/libgweather
 libgweatherinc_HEADERS = \
        $(gweather_new_headers)         \
-       gweather-enum-types.h
+       gweather-enum-types.h           \
+       gweather-version.h
 
 libgweather_internal_3_la_SOURCES = \
        weather.c weather-priv.h \
@@ -87,7 +88,7 @@ pkgconfig_DATA = gweather-3.0.pc
 
 @INTLTOOL_SCHEMAS_RULE@
 
-EXTRA_DIST = gweather-3.0.pc.in gweather-3.0-uninstalled.pc.in $(schema_in_files)
+EXTRA_DIST = gweather-3.0.pc.in gweather-3.0-uninstalled.pc.in $(schema_in_files) gweather-version.h.in
 
 CLEANFILES = $(schema_DATA) $(noinst_PROGRAMS) $(BUILT_SOURCES)
 
diff --git a/libgweather/gweather-version.h.in b/libgweather/gweather-version.h.in
new file mode 100644
index 0000000..bb3ae69
--- /dev/null
+++ b/libgweather/gweather-version.h.in
@@ -0,0 +1,110 @@
+/* gweather-version.h - libgweather versioning information
+ *
+ * This file is part of libgweather
+ * Copyright (C) 2014  Javier Jardón <jjardon gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Based on json-version from json-glib
+ * Authored by Emmanuele Bassi <ebassi gnome org>
+ * Adapted for libgweather by Javier Jardón <jjardon gnome org>
+ */
+
+#ifndef __GWEATHER_VERSION_H__
+#define __GWEATHER_VERSION_H__
+
+/**
+ * SECTION:gweatherversion
+ * @short_description: libgweather version checking
+ *
+ * LibGweather provides macros to check the version of the library
+ * at compile-time
+ */
+
+/**
+ * GWEATHER_MAJOR_VERSION:
+ *
+ * LibGweather major version component (e.g. 1 if %GWEATHER_VERSION is 1.2.3)
+ *
+ * Since: 3.12
+ */
+#define GWEATHER_MAJOR_VERSION              (@LIBGWEATHER_MAJOR_VERSION@)
+
+/**
+ * GWEATHER_MINOR_VERSION:
+ *
+ * LibGweather minor version component (e.g. 2 if %GWEATHER_VERSION is 1.2.3)
+ *
+ * Since: 3.12
+ */
+#define GWEATHER_MINOR_VERSION              (@LIBGWEATHER_MINOR_VERSION@)
+
+/**
+ * GWEATHER_MICRO_VERSION:
+ *
+ * LibGweather micro version component (e.g. 3 if %GWEATHER_VERSION is 1.2.3)
+ *
+ * Since: 3.12
+ */
+#define GWEATHER_MICRO_VERSION              (@LIBGWEATHER_MICRO_VERSION@)
+
+/**
+ * GWEATHER_VERSION
+ *
+ * LibGweather version.
+ *
+ * Since: 3.12
+ */
+#define GWEATHER_VERSION                    (@LIBGWEATHER_VERSION@)
+
+/**
+ * GWEATHER_VERSION_S:
+ *
+ * LibGweather version, encoded as a string, useful for printing and
+ * concatenation.
+ *
+ * Since: 3.12
+ */
+#define GWEATHER_VERSION_S                  "@LIBGWEATHER_VERSION@"
+
+/**
+ * GWEATHER_VERSION_HEX:
+ *
+ * LibGweather version, encoded as an hexadecimal number, useful for
+ * integer comparisons.
+ *
+ * Since: 3.12
+ */
+#define GWEATHER_VERSION_HEX                (GWEATHER_MAJOR_VERSION << 24 | \
+                                             GWEATHER_MINOR_VERSION << 16 | \
+                                             GWEATHER_MICRO_VERSION << 8)
+
+/**
+ * GWEATHER_CHECK_VERSION:
+ * @major: required major version
+ * @minor: required minor version
+ * @micro: required micro version
+ *
+ * Compile-time version checking. Evaluates to %TRUE if the version
+ * of LibGweather is greater than the required one.
+ *
+ * Since: 3.12
+ */
+#define GWEATHER_CHECK_VERSION(major,minor,micro)   \
+        (GWEATHER_MAJOR_VERSION > (major) || \
+         (GWEATHER_MAJOR_VERSION == (major) && GWEATHER_MINOR_VERSION > (minor)) || \
+         (GWEATHER_MAJOR_VERSION == (major) && GWEATHER_MINOR_VERSION == (minor) && \
+          GWEATHER_MICRO_VERSION >= (micro)))
+
+#endif /* __GWEATHER_VERSION_H__ */


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