[PATCH] Add a public header for the version number

Neil Roberts neil at linux.intel.com
Wed Apr 11 08:59:05 PDT 2012


This adds a public header so that applications can get the Wayland
version number at compile time. This can be used to make applications
that support compiling against multiple versions of Wayland.

There is a separate installed header called cogl-version.h which gets
included by both wayland-client.h and wayland-server.h

The canonical place for the version number is the configure.ac script
which splits it into three separate m4 defines for the major, minor
and micro version. These are copied into the generated
wayland-version.h header using AC_SUBST. There is also a string form
of the complete version number.

The version number is now also automatically copied into the two .pc
files.

Because the major, minor and micro parts are required it is no longer
possible to leave the version number as 'master' when building from
git. Most projects seem to immediately bump the git repo to a fake
version number (usually odd) after making a release so that there is
always a relative number that can be used for comparison. This patch
sets the git version to 0.99.0 under the assumption that the next
release will be 1.0.0.
---
 configure.ac             |   15 ++++++++++++++-
 src/.gitignore           |    1 +
 src/Makefile.am          |    5 ++++-
 src/wayland-client.h     |    1 +
 src/wayland-client.pc.in |    2 +-
 src/wayland-server.h     |    1 +
 src/wayland-server.pc.in |    2 +-
 src/wayland-version.h.in |   31 +++++++++++++++++++++++++++++++
 8 files changed, 54 insertions(+), 4 deletions(-)
 create mode 100644 src/wayland-version.h.in

diff --git a/configure.ac b/configure.ac
index 194850c..6c1323e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,22 @@
 AC_PREREQ([2.64])
+
+m4_define([wayland_major_version], [0])
+m4_define([wayland_minor_version], [99])
+m4_define([wayland_micro_version], [0])
+m4_define([wayland_version],
+          [wayland_major_version.wayland_minor_version.wayland_micro_version])
+
 AC_INIT([wayland],
-        [master],
+        [wayland_version],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=wayland],
         [wayland],
         [http://wayland.freedesktop.org/])
 
+AC_SUBST([WAYLAND_VERSION_MAJOR], [wayland_major_version])
+AC_SUBST([WAYLAND_VERSION_MINOR], [wayland_minor_version])
+AC_SUBST([WAYLAND_VERSION_MICRO], [wayland_micro_version])
+AC_SUBST([WAYLAND_VERSION], [wayland_version])
+
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 
@@ -69,6 +81,7 @@ AC_CONFIG_FILES([Makefile
 		 src/Makefile
 		 src/wayland-server.pc
 		 src/wayland-client.pc
+		 src/wayland-version.h
 		 protocol/Makefile
 		 tests/Makefile])
 AC_OUTPUT
diff --git a/src/.gitignore b/src/.gitignore
index 1813f89..1438b74 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -2,3 +2,4 @@ wayland-scanner
 wayland-client-protocol.h
 wayland-protocol.c
 wayland-server-protocol.h
+/wayland-version.h
diff --git a/src/Makefile.am b/src/Makefile.am
index f356b54..7217236 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,8 @@ include_HEADERS =				\
 	wayland-server.h			\
 	wayland-client-protocol.h		\
 	wayland-client.h			\
-	wayland-egl.h
+	wayland-egl.h				\
+	wayland-version.h
 
 libwayland_util_la_SOURCES =			\
 	connection.c				\
@@ -61,3 +62,5 @@ BUILT_SOURCES =					\
 	wayland-protocol.c
 
 CLEANFILES = $(BUILT_SOURCES)
+DISTCLEANFILES = wayland-version.h
+EXTRA_DIST = wayland-version.h.in
diff --git a/src/wayland-client.h b/src/wayland-client.h
index b04a7ef..5746e85 100644
--- a/src/wayland-client.h
+++ b/src/wayland-client.h
@@ -24,6 +24,7 @@
 #define _WAYLAND_CLIENT_H
 
 #include "wayland-util.h"
+#include "wayland-version.h"
 
 #ifdef  __cplusplus
 extern "C" {
diff --git a/src/wayland-client.pc.in b/src/wayland-client.pc.in
index 59a925d..b3df950 100644
--- a/src/wayland-client.pc.in
+++ b/src/wayland-client.pc.in
@@ -5,6 +5,6 @@ includedir=${prefix}/include
  
 Name: Wayland Client
 Description: Wayland client side library
-Version: 0.1
+Version: @WAYLAND_VERSION@
 Cflags: -I${includedir}
 Libs: -L${libdir} -lwayland-client
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 6d2ab7c..52f25ea 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -30,6 +30,7 @@ extern "C" {
 #include <sys/types.h>
 #include <stdint.h>
 #include "wayland-util.h"
+#include "wayland-version.h"
 
 enum {
 	WL_EVENT_READABLE = 0x01,
diff --git a/src/wayland-server.pc.in b/src/wayland-server.pc.in
index b317461..8e3214e 100644
--- a/src/wayland-server.pc.in
+++ b/src/wayland-server.pc.in
@@ -5,6 +5,6 @@ includedir=${prefix}/include
  
 Name: Wayland Server
 Description: Server side implementation of the Wayland protocol
-Version: 0.1
+Version: @WAYLAND_VERSION@
 Cflags: -I${includedir}
 Libs: -L${libdir} -lwayland-server
diff --git a/src/wayland-version.h.in b/src/wayland-version.h.in
new file mode 100644
index 0000000..9a746ca
--- /dev/null
+++ b/src/wayland-version.h.in
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef WAYLAND_VERSION_H
+#define WAYLAND_VERSION_H
+
+#define WAYLAND_VERSION_MAJOR @WAYLAND_VERSION_MAJOR@
+#define WAYLAND_VERSION_MINOR @WAYLAND_VERSION_MINOR@
+#define WAYLAND_VERSION_MICRO @WAYLAND_VERSION_MICRO@
+#define WAYLAND_VERSION "@WAYLAND_VERSION@"
+
+#endif
-- 
1.7.3.16.g9464b



More information about the wayland-devel mailing list