summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2014-02-24 15:00:31 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2014-02-24 15:59:41 +0100
commite124a3b2e8d375661aeed9c151866c46985d7afa (patch)
tree1f51c2883e642fed299692cdacad9b97e98f25de
parent603bad139cd4ee0eb6096037956f3af6fec33730 (diff)
Add a SPICE_GTK_CHECK_VERSION macro
-rw-r--r--configure.ac10
-rw-r--r--doc/reference/spice-gtk-sections.txt4
-rw-r--r--gtk/Makefile.am4
-rw-r--r--gtk/spice-client.h1
-rw-r--r--gtk/spice-version.h.in70
5 files changed, 89 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 6e4b29a..192d748 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,15 @@ AC_CONFIG_SUBDIRS([spice-common])
COMMON_CFLAGS='-I ${top_srcdir}/spice-common/ -I ${top_srcdir}/spice-common/spice-protocol/'
AC_SUBST(COMMON_CFLAGS)
+SPICE_GTK_MAJOR_VERSION=`echo $PACKAGE_VERSION | cut -d. -f1`
+SPICE_GTK_MINOR_VERSION=`echo $PACKAGE_VERSION | cut -d. -f2`
+SPICE_GTK_MICRO_VERSION=`echo $PACKAGE_VERSION | cut -d. -f3 | cut -d- -f1`
+[ "x$SPICE_GTK_MICRO_VERSION" = "x" ] && SPICE_GTK_MICRO_VERSION = 0
+
+AC_SUBST(SPICE_GTK_MAJOR_VERSION)
+AC_SUBST(SPICE_GTK_MINOR_VERSION)
+AC_SUBST(SPICE_GTK_MICRO_VERSION)
+
dnl =========================================================================
dnl Chek optional features
@@ -709,6 +718,7 @@ data/spicy.desktop.in
data/spicy.nsis
po/Makefile.in
gtk/Makefile
+gtk/spice-version.h
gtk/controller/Makefile
doc/Makefile
doc/reference/Makefile
diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index 08b1b4e..9232a23 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -402,6 +402,10 @@ SpiceGtkBoxClass
<FILE>spice-util</FILE>
spice_util_set_debug
spice_util_get_version_string
+SPICE_GTK_CHECK_VERSION
+SPICE_GTK_MAJOR_VERSION
+SPICE_GTK_MICRO_VERSION
+SPICE_GTK_MINOR_VERSION
<SUBSECTION Private>
SPICE_DEBUG
spice_util_get_debug
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 61ed88e..8a16120 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -41,8 +41,11 @@ EXTRA_DIST = \
spice-client-gtk-manual.defs \
spice-client-gtk.override \
spice-marshal.txt \
+ spice-version.h.in \
$(NULL)
+DISTCLEANFILES = spice-version.h
+
bin_PROGRAMS = spicy spicy-stats spicy-screenshot
if WITH_POLKIT
acldir = $(ACL_HELPER_DIR)
@@ -290,6 +293,7 @@ libspice_client_glibinclude_HEADERS = \
spice-channel.h \
spice-util.h \
spice-option.h \
+ spice-version.h \
channel-cursor.h \
channel-display.h \
channel-inputs.h \
diff --git a/gtk/spice-client.h b/gtk/spice-client.h
index 975259a..98aaffe 100644
--- a/gtk/spice-client.h
+++ b/gtk/spice-client.h
@@ -32,6 +32,7 @@
#include "spice-channel.h"
#include "spice-option.h"
#include "spice-uri.h"
+#include "spice-version.h"
#include "channel-main.h"
#include "channel-display.h"
diff --git a/gtk/spice-version.h.in b/gtk/spice-version.h.in
new file mode 100644
index 0000000..fbef265
--- /dev/null
+++ b/gtk/spice-version.h.in
@@ -0,0 +1,70 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ Copyright (C) 2014 Red Hat, Inc.
+
+ 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/>.
+*/
+#ifndef __SPICE_VERSION_H__
+#define __SPICE_VERSION_H__
+
+/**
+ * SECTION:spice-version
+ * @short_description: Spice-Gtk version checking
+ *
+ * Spice-Gtk provides macros to check the version of the library
+ * at compile-time
+ */
+
+/**
+ * SPICE_GTK_MAJOR_VERSION:
+ *
+ * Spice-Gtk major version component (e.g. 1 if version is 1.2.3)
+ * Since: 0.24
+ */
+#define SPICE_GTK_MAJOR_VERSION (@SPICE_GTK_MAJOR_VERSION@)
+
+/**
+ * SPICE_GTK_MINOR_VERSION:
+ *
+ * Spice-Gtk minor version component (e.g. 2 if version is 1.2.3)
+ * Since: 0.24
+ */
+#define SPICE_GTK_MINOR_VERSION (@SPICE_GTK_MINOR_VERSION@)
+
+/**
+ * SPICE_GTK_MICRO_VERSION:
+ *
+ * Spice-Gtk micro version component (e.g. 3 if version is 1.2.3)
+ * Since: 0.24
+ */
+#define SPICE_GTK_MICRO_VERSION (@SPICE_GTK_MICRO_VERSION@)
+
+/**
+ * SPICE_GTK_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 Spice-Gtk is greater than the required one.
+ * Since: 0.24
+ */
+#define SPICE_GTK_CHECK_VERSION(major, minor, micro) \
+ (SPICE_GTK_MAJOR_VERSION > (major) || \
+ (SPICE_GTK_MAJOR_VERSION == (major) && SPICE_GTK_MINOR_VERSION >= (minor)) || \
+ (SPICE_GTK_MAJOR_VERSION == (major) && SPICE_GTK_MINOR_VERSION == (minor) && \
+ SPICE_GTK_MICRO_VERSION >= (micro)))
+
+
+#endif /* __SPICE_VERSION_H__ */