From ecd3e19de702979b695c8936f80e376c938e2f22 Mon Sep 17 00:00:00 2001
From: Mart Raudsepp <leio@gentoo.org>
Date: Sun, 12 Jul 2020 12:21:07 +0300
Subject: [PATCH 1/6] build: Restore options for bluetooth, NetworkManager and
 Wacom

---
 meson.build        | 37 ++++++++++++++++++++++---------------
 meson_options.txt  |  3 +++
 panels/meson.build | 19 +++++++++++--------
 shell/meson.build  |  2 +-
 4 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/meson.build b/meson.build
index 1ee69c513..477250baf 100644
--- a/meson.build
+++ b/meson.build
@@ -216,7 +216,8 @@ endif
 config_h.set('HAVE_MALCONTENT', enable_malcontent,
              description: 'Define to 1 if malcontent support is enabled')
 
-if host_is_linux
+enable_network_manager = get_option('network_manager')
+if enable_network_manager
   # network manager
   network_manager_deps = [
     dependency('libnm', version: '>= 1.24.0'),
@@ -224,19 +225,24 @@ if host_is_linux
     dependency('mm-glib', version: '>= 0.7')
   ]
 endif
-config_h.set('BUILD_NETWORK', host_is_linux,
+config_h.set('BUILD_NETWORK', enable_network_manager,
              description: 'Define to 1 to build the Network panel')
-config_h.set('HAVE_NETWORK_MANAGER', host_is_linux,
+config_h.set('HAVE_NETWORK_MANAGER', enable_network_manager,
              description: 'Define to 1 if NetworkManager is available')
-config_h.set('BUILD_WWAN', host_is_linux,
+config_h.set('BUILD_WWAN', enable_network_manager,
              description: 'Define to 1 to build the WWan panel')
-config_h.set('HAVE_WWAN', host_is_linux,
+config_h.set('HAVE_WWAN', enable_network_manager,
              description: 'Define to 1 if WWan is available')
 
-if host_is_linux_not_s390
+enable_bluetooth = get_option('bluetooth')
+if enable_bluetooth
   # gnome-bluetooth
   gnome_bluetooth_dep = dependency('gnome-bluetooth-1.0', version: '>= 3.18.2')
+endif
 
+enable_wacom = get_option('wacom')
+if enable_wacom
+  # Wacom
   libwacom_dep = dependency('libwacom', version: '>= 0.7')
 
   wacom_deps = [
@@ -244,17 +250,18 @@ if host_is_linux_not_s390
   ]
   config_h.set('HAVE_WACOM_3D_STYLUS', libwacom_dep.version().version_compare('>= 0.27'),
                description: 'Define to 1 if libwacom provides definition for 3D styli')
-else
-  message('Bluetooth and Wacom panels will not be built (no USB support on this platform)')
+endif
+
+if not host_is_linux_not_s390
   message('Thunderbolt panel will not be built (not supported on this platform)')
 endif
-config_h.set('BUILD_BLUETOOTH', host_is_linux_not_s390,
+config_h.set('BUILD_BLUETOOTH', enable_bluetooth,
              description: 'Define to 1 to build the Bluetooth panel')
-config_h.set('HAVE_BLUETOOTH', host_is_linux_not_s390,
+config_h.set('HAVE_BLUETOOTH', enable_bluetooth,
              description: 'Define to 1 if bluetooth support is available')
-config_h.set('BUILD_WACOM', host_is_linux_not_s390,
+config_h.set('BUILD_WACOM', enable_wacom,
              description: 'Define to 1 to build the Wacom panel')
-config_h.set('HAVE_WACOM', host_is_linux_not_s390,
+config_h.set('HAVE_WACOM', enable_wacom,
              description: 'Define to 1 if Wacom is supportted')
 config_h.set('BUILD_THUNDERBOLT', host_is_linux_not_s390,
              description: 'Define to 1 to build the Thunderbolt panel')
@@ -305,9 +312,9 @@ summary({
 })
 
 summary({
-  'GNOME Bluetooth': host_is_linux_not_s390,
-  'NetworkManager': host_is_linux,
-  'Wacom': host_is_linux_not_s390,
+  'GNOME Bluetooth': enable_bluetooth,
+  'NetworkManager': enable_network_manager,
+  'Wacom': enable_wacom,
 }, section: 'Dependencies')
 
 summary({
diff --git a/meson_options.txt b/meson_options.txt
index 1b7b54810..2b3da02c0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,9 +2,12 @@
+option('bluetooth', type: 'boolean', value: true, description: 'build with Bluetooth support')
 option('cheese', type: 'boolean', value: true, description: 'build with cheese webcam support')
 option('documentation', type: 'boolean', value: false, description: 'build documentation')
 option('ibus', type: 'boolean', value: true, description: 'build with IBus support')
+option('network_manager', type: 'boolean', value: true, description: 'build with NetworkManager support')
 option('privileged_group', type: 'string', value: 'wheel', description: 'name of group that has elevated permissions')
 option('snap', type: 'boolean', value: false, description: 'build with Snap support')
 option('tracing', type: 'boolean', value: false, description: 'add extra debugging information')
+option('wacom', type: 'boolean', value: true, description: 'build with Wacom support')
 option('wayland', type: 'boolean', value: false, description: 'build with Wayland support')
 option('profile', type: 'combo', choices: ['default','development'], value: 'default')
 option('malcontent', type: 'boolean', value: false, description: 'build with malcontent support')
diff --git a/panels/meson.build b/panels/meson.build
index f603db919..d44ad9de1 100644
--- a/panels/meson.build
+++ b/panels/meson.build
@@ -26,19 +26,22 @@
   'universal-access',
   'usage',
   'user-accounts',
-  'wwan',
 ]
 
-if host_is_linux
-  panels += ['network']
+if enable_network_manager
+  panels += ['network', 'wwan']
+endif
+
+if enable_bluetooth
+  panels += ['bluetooth']
+endif
+
+if enable_wacom
+  panels += ['wacom']
 endif
 
 if host_is_linux_not_s390
-  panels += [
-    'bluetooth',
-    'thunderbolt',
-    'wacom'
-  ]
+  panels += ['thunderbolt']
 endif
 
 panels_list = []
diff --git a/shell/meson.build b/shell/meson.build
index 89b96590e..93e1f8994 100644
--- a/shell/meson.build
+++ b/shell/meson.build
@@ -118,7 +118,7 @@
   shell_deps += cheese_deps
 endif

-if host_is_linux_not_s390
+if enable_wacom
   shell_deps += wacom_deps
 endif
 

