From 8734477d526b5a5d9ac08685b5fc02f204fc55e3 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Thu, 5 Jun 2014 14:05:16 +0200 Subject: [PATCH] meta: Add generated meta-version.h Avoid populating *_VERSION constants through cflags in pkg-config-file which could be overridden by the project using it. Properly prefix the defines with META_ to make gi-scanner happy. --- .gitignore | 1 + configure.ac | 1 + src/Makefile.am | 21 +++++++++++++++------ src/compositor/meta-module.c | 3 ++- src/compositor/plugins/Makefile.am | 5 +---- src/libmutter.pc.in | 7 +------ src/meta/meta-plugin.h | 9 +++++---- src/meta/meta-version.h.in | 28 ++++++++++++++++++++++++++++ 8 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 src/meta/meta-version.h.in diff --git a/.gitignore b/.gitignore index c2b89a4aa..eaec1131e 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,7 @@ src/xdg-shell-protocol.c src/xdg-shell-server-protocol.h src/xserver-protocol.c src/xserver-server-protocol.h +src/meta/meta-version.h doc/reference/*.args doc/reference/*.bak doc/reference/*.hierarchy diff --git a/configure.ac b/configure.ac index ead3257c8..35a8c3ff6 100644 --- a/configure.ac +++ b/configure.ac @@ -387,6 +387,7 @@ doc/reference/meta-docs.sgml src/Makefile src/libmutter.pc src/compositor/plugins/Makefile +src/meta/meta-version.h po/Makefile.in ]) diff --git a/src/Makefile.am b/src/Makefile.am index fdd0334e9..7bebe0434 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,6 +12,7 @@ AM_CPPFLAGS = \ -DCOGL_ENABLE_EXPERIMENTAL_2_0_API \ $(MUTTER_CFLAGS) \ $(MUTTER_NATIVE_BACKEND_CFLAGS) \ + -I$(builddir) \ -I$(srcdir) \ -I$(srcdir)/backends \ -I$(srcdir)/core \ @@ -23,10 +24,6 @@ AM_CPPFLAGS = \ -DMUTTER_DATADIR=\"$(datadir)\" \ -DG_LOG_DOMAIN=\"mutter\" \ -DSN_API_NOT_YET_FROZEN=1 \ - -DMUTTER_MAJOR_VERSION=$(MUTTER_MAJOR_VERSION) \ - -DMUTTER_MINOR_VERSION=$(MUTTER_MINOR_VERSION) \ - -DMUTTER_MICRO_VERSION=$(MUTTER_MICRO_VERSION) \ - -DMUTTER_PLUGIN_API_VERSION=$(MUTTER_PLUGIN_API_VERSION) \ -DMUTTER_PKGLIBDIR=\"$(pkglibdir)\" \ -DMUTTER_PLUGIN_DIR=\"$(MUTTER_PLUGIN_DIR)\" \ -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ @@ -36,6 +33,7 @@ mutter_built_sources = \ $(dbus_idle_built_sources) \ $(dbus_display_config_built_sources) \ $(dbus_login1_built_sources) \ + meta/meta-version.h \ mutter-enum-types.h \ mutter-enum-types.c \ gtk-shell-protocol.c \ @@ -257,7 +255,7 @@ libmutter_la_LIBADD = $(MUTTER_LIBS) $(MUTTER_NATIVE_BACKEND_LIBS) # Headers installed for plugins; introspected information will # be extracted into Mutter-.gir -libmutterinclude_base_headers = \ +libmutterinclude_headers = \ meta/barrier.h \ meta/boxes.h \ meta/common.h \ @@ -286,6 +284,13 @@ libmutterinclude_base_headers = \ meta/window.h \ meta/workspace.h +libmutterinclude_built_headers = \ + meta/meta-version.h + +libmutterinclude_base_headers = \ + $(libmutterinclude_headers) \ + $(libmutterinclude_built_headers) + # Excluded from scanning for introspection but installed # atomnames.h: macros cause problems for scanning process libmutterinclude_extra_headers = \ @@ -294,9 +299,12 @@ libmutterinclude_extra_headers = \ libmutterincludedir = $(includedir)/mutter/meta libmutterinclude_HEADERS = \ - $(libmutterinclude_base_headers) \ + $(libmutterinclude_headers) \ $(libmutterinclude_extra_headers) +nodist_libmutterinclude_HEADERS = \ + $(libmutterinclude_built_headers) + bin_PROGRAMS=mutter mutter_SOURCES = core/mutter.c @@ -349,6 +357,7 @@ dbus_idle_built_sources = meta-dbus-idle-monitor.c meta-dbus-idle-monitor.h CLEANFILES = \ $(mutter_built_sources) \ + $(libmutterinclude_built_headers) \ $(typelib_DATA) \ $(gir_DATA) diff --git a/src/compositor/meta-module.c b/src/compositor/meta-module.c index 1369b8086..c78bef785 100644 --- a/src/compositor/meta-module.c +++ b/src/compositor/meta-module.c @@ -20,6 +20,7 @@ */ #include +#include #include "meta-module.h" #include @@ -68,7 +69,7 @@ meta_module_load (GTypeModule *gmodule) (gpointer *)(void *)®ister_type) && info && register_type) { - if (info->version_api != MUTTER_PLUGIN_API_VERSION) + if (info->version_api != META_PLUGIN_API_VERSION) g_warning ("Plugin API mismatch for [%s]", priv->path); else { diff --git a/src/compositor/plugins/Makefile.am b/src/compositor/plugins/Makefile.am index 365824561..072599192 100644 --- a/src/compositor/plugins/Makefile.am +++ b/src/compositor/plugins/Makefile.am @@ -3,6 +3,7 @@ pkglibdir = $(MUTTER_PLUGIN_DIR) AM_CPPFLAGS = \ $(MUTTER_CFLAGS) \ + -I$(top_builddir)/src \ -I$(top_srcdir)/src \ -DMUTTER_LIBEXECDIR=\"$(libexecdir)\" \ -DMUTTER_LOCALEDIR=\"$(localedir)\" \ @@ -10,10 +11,6 @@ AM_CPPFLAGS = \ -DMUTTER_DATADIR=\"$(datadir)\" \ -DG_LOG_DOMAIN=\"mutter\" \ -DSN_API_NOT_YET_FROZEN=1 \ - -DMUTTER_MAJOR_VERSION=$(MUTTER_MAJOR_VERSION) \ - -DMUTTER_MINOR_VERSION=$(MUTTER_MINOR_VERSION) \ - -DMUTTER_MICRO_VERSION=$(MUTTER_MICRO_VERSION) \ - -DMUTTER_PLUGIN_API_VERSION=$(MUTTER_PLUGIN_API_VERSION) \ -DMUTTER_PLUGIN_DIR=\"$(MUTTER_PLUGIN_DIR)\" default_la_CFLAGS = -fPIC diff --git a/src/libmutter.pc.in b/src/libmutter.pc.in index 1f819af80..3fea36d51 100644 --- a/src/libmutter.pc.in +++ b/src/libmutter.pc.in @@ -5,14 +5,9 @@ includedir=@includedir@ girdir=@libdir@/mutter typelibdir=@libdir@/mutter -mutter_major_version=@MUTTER_MAJOR_VERSION@ -mutter_minor_version=@MUTTER_MINOR_VERSION@ -mutter_micro_version=@MUTTER_MICRO_VERSION@ -mutter_plugin_api_version=@MUTTER_PLUGIN_API_VERSION@ - Name: libmutter Description: Mutter window manager library Requires: gsettings-desktop-schemas gtk+-3.0 @CLUTTER_PACKAGE@ x11 Version: @VERSION@ Libs: -L${libdir} -lmutter -Cflags: -I${includedir}/mutter -DMUTTER_MAJOR_VERSION=${mutter_major_version} -DMUTTER_MINOR_VERSION=${mutter_minor_version} -DMUTTER_MICRO_VERSION=${mutter_micro_version} -DMUTTER_PLUGIN_API_VERSION=${mutter_plugin_api_version} +Cflags: -I${includedir}/mutter diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h index d1089e5be..55887b463 100644 --- a/src/meta/meta-plugin.h +++ b/src/meta/meta-plugin.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -299,10 +300,10 @@ struct _MetaPluginVersion #define META_PLUGIN_DECLARE(ObjectName, object_name) \ G_MODULE_EXPORT MetaPluginVersion meta_plugin_version = \ { \ - MUTTER_MAJOR_VERSION, \ - MUTTER_MINOR_VERSION, \ - MUTTER_MICRO_VERSION, \ - MUTTER_PLUGIN_API_VERSION \ + META_MAJOR_VERSION, \ + META_MINOR_VERSION, \ + META_MICRO_VERSION, \ + META_PLUGIN_API_VERSION \ }; \ \ static GType g_define_type_id = 0; \ diff --git a/src/meta/meta-version.h.in b/src/meta/meta-version.h.in new file mode 100644 index 000000000..bf977cf41 --- /dev/null +++ b/src/meta/meta-version.h.in @@ -0,0 +1,28 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2014 Rico Tzschichholz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef META_VERSION_H +#define META_VERSION_H + +#define META_MAJOR_VERSION @MUTTER_MAJOR_VERSION@ +#define META_MINOR_VERSION @MUTTER_MINOR_VERSION@ +#define META_MICRO_VERSION @MUTTER_MICRO_VERSION@ +#define META_PLUGIN_API_VERSION @MUTTER_PLUGIN_API_VERSION@ + +#endif