From: Michael Gratton <mike@vee.net>
Date: Mon, 30 Mar 2020 11:01:03 +1100
Subject: Install client library in private lib sub-directory

Use Geary's private lib sub-directory so that the library won't be found
on the global library search path. Version the library name to avoid
clashes. Update the binary's rpath on install so it can find the lib
still.

Fixes #775

cherry-picked from 207c9757d1791fcd832d8862ba4bf44d91cf5c0e
---
 meson.build            |  5 +++--
 src/client/meson.build | 17 +++++++++++++++--
 src/meson.build        |  1 +
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/meson.build b/meson.build
index 4cc951e..1767cec 100644
--- a/meson.build
+++ b/meson.build
@@ -134,8 +134,9 @@ i18n = import('i18n')
 
 # Static install dirs
 dbus_services_dir = join_paths(data_dir, 'dbus-1', 'services')
-plugins_dir = join_paths(lib_dir, 'geary', 'plugins')
-web_extensions_dir = join_paths(lib_dir, 'geary', 'web-extensions')
+client_lib_dir = join_paths(lib_dir, 'geary')
+plugins_dir = join_paths(client_lib_dir, 'plugins')
+web_extensions_dir = join_paths(client_lib_dir, 'web-extensions')
 
 # Ensure SQLite was built correctly
 if not cc.has_header_symbol('sqlite3.h', 'SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER', dependencies: sqlite)
diff --git a/src/client/meson.build b/src/client/meson.build
index a6a5e26..7edd49d 100644
--- a/src/client/meson.build
+++ b/src/client/meson.build
@@ -1,4 +1,15 @@
 # Geary client
+
+geary_client_package_name = 'geary-client'
+geary_client_api_version = '.'.join([
+  geary_version.split('.')[0],
+  geary_version.split('.')[1],
+])
+geary_client_package = '@0@-@1@'.format(
+  geary_client_package_name,
+  geary_client_api_version
+)
+
 geary_client_vala_sources = files(
   'application/application-attachment-manager.vala',
   'application/application-avatar-store.vala',
@@ -153,13 +164,15 @@ if webkit_version[0].to_int() <= 2 and webkit_version[1].to_int() <= 24
 endif
 
 # Main client application library
-geary_client_lib = shared_library('geary-client',
+geary_client_lib = shared_library(
+  geary_client_package,
   geary_client_sources,
   dependencies: geary_client_dependencies,
   include_directories: config_h_dir,
   vala_args: geary_client_vala_args,
   c_args: geary_c_args,
-  install: true
+  install: true,
+  install_dir: client_lib_dir
 )
 
 geary_client_dep = declare_dependency(
diff --git a/src/meson.build b/src/meson.build
index 244c369..ae4cef4 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -108,6 +108,7 @@ geary_bin = executable('geary',
   vala_args: geary_vala_args,
   c_args: geary_c_args,
   install: true,
+  install_rpath: client_lib_dir
 )
 
 if enable_valadoc
