From e91ea5d802b794947b21d438f3defdfd9309d860 Mon Sep 17 00:00:00 2001
From: Rasmus Thomsen <oss@cogitri.dev>
Date: Fri, 17 Apr 2020 14:45:59 +0200
Subject: [PATCH 1/2] build: use meson functionality to generate .pc file

This should be sufficiently stable now and also fixes a few things
in the pkgconfig file, like minimum required versions of dependants
and also fixes linking against gnome-software with pkgconfig, previously
only -L/usr/lib was passed to the linker and not -lgnome-software
---
 lib/meson.build | 45 +++++++++++----------------------------------
 1 file changed, 11 insertions(+), 34 deletions(-)

diff --git a/lib/meson.build b/lib/meson.build
index 376beebd..a41f63bb 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -1,40 +1,6 @@
 cargs = ['-DG_LOG_DOMAIN="Gs"']
 cargs += ['-DLOCALPLUGINDIR=""']
 
-# we can't use conf as this is set_quoted()
-
-pkconf = configuration_data()
-pkconf.set('prefix', get_option('prefix'))
-pkconf.set('libdir',
-           join_paths(get_option('prefix'),
-                      get_option('libdir')))
-pkconf.set('includedir',
-           join_paths(get_option('prefix'),
-                      get_option('includedir')))
-pkconf.set('GS_PLUGIN_API_VERSION', gs_plugin_api_version)
-pkconf.set('VERSION', meson.project_version())
-configure_file(
-  input : 'gnome-software.pc.in',
-  output : 'gnome-software.pc',
-  install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
-  configuration : pkconf
-)
-
-# XXX: This can probably be used (after testing), once
-# https://github.com/mesonbuild/meson/pull/1688 is merged
-#pkg = import('pkgconfig')
-#
-#pkg.generate(
-#    description : 'GNOME Software is a software center for GNOME',
-#    filebase : 'gnome-software',
-#    name : 'gnome-software',
-#    requires: [ 'gobject-2.0', 'gdk-3.0', 'appstream-glib', 'libsoup-2.4', 'gio-unix-2.0'],
-#    requires_private : [ 'gthread-2.0', 'atk' ],
-#    subdirs : [ 'gnome-software' ],
-#    variables : [ 'plugindir=${libdir}/lib/gs-plugins-' + gs_plugin_api_version ]
-#    version : meson.project_version()
-#)
-
 install_headers([
     'gnome-software.h',
     'gs-app.h',
@@ -98,6 +64,17 @@ libgnomesoftware = static_library(
   c_args : cargs,
 )
 
+pkg = import('pkgconfig')
+
+pkg.generate(
+    libgnomesoftware,
+    description : 'GNOME Software is a software center for GNOME',
+    filebase : 'gnome-software',
+    name : 'gnome-software',
+    subdirs : 'gnome-software',
+    variables : 'plugindir=${libdir}/gs-plugins-' + gs_plugin_api_version,
+)
+
 executable(
   'gnome-software-cmd',
   sources : [
-- 
2.24.1


From d3fae3b356edc59b53e476de19549c118a6bdc78 Mon Sep 17 00:00:00 2001
From: Rasmus Thomsen <oss@cogitri.dev>
Date: Fri, 17 Apr 2020 15:21:25 +0200
Subject: [PATCH 2/2] build: install libgnomesoftware

This is useful for e.g. out-of-tree plugins
---
 lib/meson.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/meson.build b/lib/meson.build
index a41f63bb..1c00d4f3 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -62,6 +62,7 @@ libgnomesoftware = static_library(
   ],
   dependencies : librarydeps,
   c_args : cargs,
+  install: true,
 )
 
 pkg = import('pkgconfig')
-- 
2.24.1

