From 6ba2ce016aa04d2b81bf04815aa3a6f2edd7d10b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Fri, 5 Nov 2021 12:19:46 -0400
Subject: [PATCH] build: disable SHM if DBUS is not used

As libwrap is used by default, HAVE_SHM should only be true
if directrenderer is not used to avoid useless work

Change-Id: I9f819a7c06c667ccf08066f70104dcd3667f8546
---
 README       | 4 ++--
 configure.ac | 6 ++++--
 meson.build  | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/README b/README
index 37d99ec462..a89777e8c6 100644
--- a/README
+++ b/README
@@ -79,8 +79,8 @@ ninja install
 
 Done !
 
-More details available here:
-https://git.jami.net/savoirfairelinux/ring-project/wikis/technical/Build-instructions
+Note:
+If you don't want SHM to be used, you can build with `--without-dbus`
 
 How to compile on Linux for Android
 -----------------------------------
diff --git a/configure.ac b/configure.ac
index 0706f2d460..d1707d4cf4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -606,9 +606,11 @@ AC_DEFINE_UNQUOTED([HAVE_LIBNATPMP],
   [Define if you have libnatpmp])
 AM_CONDITIONAL([BUILD_NATPMP], test "x$with_natpmp" = "xyes")
 
+# SHM
+dnl check for shm
+
 AC_DEFINE_UNQUOTED([HAVE_SHM],
-  `if test -z "${HAVE_LINUX_TRUE}" && \
-test -z "${HAVE_ANDROID_FALSE}"; then echo 1; else echo 0; fi`,
+  `if test "x$with_dbus" == xyes; then echo 1; else echo 0; fi`,
   [Define if you have shared memory support])
 
 # DOXYGEN
diff --git a/meson.build b/meson.build
index f59ee3c1ac..c9f688b6fc 100644
--- a/meson.build
+++ b/meson.build
@@ -147,7 +147,7 @@ else
 endif
 
 conf.set10('HAVE_COREAUDIO', host_machine.system() == 'darwin')
-conf.set10('HAVE_SHM', host_machine.system() == 'linux' and meson.get_compiler('cpp').get_define('__ANDROID__') != '1')
+conf.set10('HAVE_SHM', get_option('interfaces').contains('dbus'))
 
 configure_file(
     output: 'config.h',
-- 
GitLab