On Mon, Feb 24, 2014 at 03:03:56PM +0100, Marc-André Lureau wrote: > --- > configure.ac | 10 ++++++ > doc/reference/spice-gtk-sections.txt | 4 +++ > gtk/Makefile.am | 4 +++ > gtk/spice-client.h | 1 + > gtk/spice-version.h.in | 70 ++++++++++++++++++++++++++++++++++++ > 5 files changed, 89 insertions(+) > create mode 100644 gtk/spice-version.h.in > > 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..8856914 > --- /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) \ Nitpick, perhaps nicer to have a space after each ',' > + (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__ */ ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel