meson: Make bluez optional
authorArnaud Rebillout <arnaud.rebillout@collabora.com>
Fri, 19 Oct 2018 10:40:06 +0000 (17:40 +0700)
committerArun Raghavan <arun@arunraghavan.net>
Thu, 27 Dec 2018 11:55:55 +0000 (17:25 +0530)
I can't promise that the logic is *exactly* the same as the logic
currently in use with the autotools, but it seems correct to me.

Signed-off-by: Arnaud Rebillout <arnaud.rebillout@collabora.com>
meson.build
meson_options.txt
src/modules/bluetooth/meson.build
src/modules/meson.build

index 03f872a..34c6775 100644 (file)
@@ -266,10 +266,21 @@ if avahi_dep.found()
   cdata.set('HAVE_AVAHI', 1)
 endif
 
-bluez_dep = dependency('bluez', version : '>= 4.101', required : false)
+# TODO fix bluez version, it seems wrong
+bluez_dep = dependency('bluez', version : '>= 4.101', required : get_option('bluez5'))
+sbc_dep = dependency('sbc', version : '>= 1.0', required : false)
 if bluez_dep.found()
-  cdata.set('HAVE_BLUEZ_5_NATIVE_HEADSET', 1)
-  cdata.set('HAVE_BLUEZ_5_OFONO_HEADSET', 1) # TODO This should be optional
+  assert(dbus_dep.found(), 'BlueZ requires D-Bus support')
+  assert(sbc_dep.found(), 'BlueZ requires SBC support')
+  cdata.set('HAVE_SBC', 1)
+  cdata.set('HAVE_BLUEZ', 1)
+  cdata.set('HAVE_BLUEZ_5', 1)
+  if get_option('bluez5-native-headset')
+    cdata.set('HAVE_BLUEZ_5_NATIVE_HEADSET', 1)
+  endif
+  if get_option('bluez5-ofono-headset')
+    cdata.set('HAVE_BLUEZ_5_OFONO_HEADSET', 1)
+  endif
 endif
 
 jack_dep = dependency('jack', version : '>= 0.117.0', required : false)
@@ -292,15 +303,6 @@ if openssl_dep.found()
   cdata.set('HAVE_OPENSSL', 1)
 endif
 
-sbc_dep = dependency('sbc', version : '>= 1.0', required : false)
-if sbc_dep.found()
-  cdata.set('HAVE_SBC', 1)
-endif
-if sbc_dep.found() and dbus_dep.found()
-  cdata.set('HAVE_BLUEZ', 1)
-  cdata.set('HAVE_BLUEZ_5', 1)
-endif
-
 speex_dep = dependency('speexdsp', version : '>= 1.2', required : false)
 if speex_dep.found()
   cdata.set('HAVE_SPEEX', 1)
index 3bd4b94..181c9d4 100644 (file)
@@ -23,6 +23,15 @@ option('alsa',
 option('avahi',
        type : 'feature', value : 'auto',
        description : 'Optional Avahi support')
+option('bluez5',
+       type : 'feature', value : 'auto',
+       description : 'Optional BlueZ 5 support')
+option('bluez5-native-headset',
+       type : 'boolean',
+       description : 'Optional native headset backend support (BlueZ 5)')
+option('bluez5-ofono-headset',
+       type : 'boolean',
+       description : 'Optional oFono headset backend support (BlueZ 5)')
 option('dbus',
        type : 'feature', value : 'auto',
        description : 'Optional D-Bus support')
index 2afcd49..dce743a 100644 (file)
@@ -8,12 +8,13 @@ libbluez5_util_headers = [
   'rtp.h',
 ]
 
-if bluez_dep.found()
+if get_option('bluez5-native-headset')
   libbluez5_util_sources += [ 'backend-native.c' ]
 endif
 
-# TODO This should be optional
-libbluez5_util_sources += [ 'backend-ofono.c' ]
+if get_option('bluez5-ofono-headset')
+  libbluez5_util_sources += [ 'backend-ofono.c' ]
+endif
 
 libbluez5_util = shared_library('libbluez5_util',
   libbluez5_util_sources,
index 43f6e19..6312998 100644 (file)
@@ -103,6 +103,16 @@ if avahi_dep.found()
   ]
 endif
 
+if bluez_dep.found()
+  subdir('bluetooth')
+  all_modules += [
+    [ 'module-bluetooth-discover', 'bluetooth/module-bluetooth-discover.c' ],
+    [ 'module-bluetooth-policy', 'bluetooth/module-bluetooth-policy.c', [], [], [dbus_dep] ],
+    [ 'module-bluez5-device', 'bluetooth/module-bluez5-device.c', [], [], [sbc_dep], libbluez5_util ],
+    [ 'module-bluez5-discover', 'bluetooth/module-bluez5-discover.c', [], [], [dbus_dep], libbluez5_util ],
+  ]
+endif
+
 if dbus_dep.found()
   all_modules += [
     [ 'module-console-kit', 'module-console-kit.c', [], [], [dbus_dep] ],
@@ -130,20 +140,6 @@ if dbus_dep.found() and fftw_dep.found()
   ]
 endif
 
-if dbus_dep.found() and sbc_dep.found()
-  all_modules += [
-    [ 'module-bluetooth-discover', 'bluetooth/module-bluetooth-discover.c' ],
-    [ 'module-bluetooth-policy', 'bluetooth/module-bluetooth-policy.c', [], [], [dbus_dep] ]
-  ]
-  if bluez_dep.found()
-    subdir('bluetooth')
-    all_modules += [
-      [ 'module-bluez5-device', 'bluetooth/module-bluez5-device.c', [], [], [sbc_dep], libbluez5_util ],
-      [ 'module-bluez5-discover', 'bluetooth/module-bluez5-discover.c', [], [], [dbus_dep], libbluez5_util ],
-    ]
-  endif
-endif
-
 if jack_dep.found()
   all_modules += [
     [ 'module-jack-sink', 'jack/module-jack-sink.c', [], [], [jack_dep] ],