1# DBUS Role Support
2
3## DBUS-related distro packages
4
5Fedora: dbus-devel
6Debian / Ubuntu: libdbus-1-dev
7
8## Enabling for build at cmake
9
10Fedora example:
11```
12$ cmake .. -DLWS_ROLE_DBUS=1 -DLWS_DBUS_INCLUDE2="/usr/lib64/dbus-1.0/include"
13```
14
15Ubuntu example:
16```
17$ cmake .. -DLWS_ROLE_DBUS=1 -DLWS_DBUS_INCLUDE2="/usr/lib/x86_64-linux-gnu/dbus-1.0/include"
18```
19
20Dbus requires two include paths, which you can force by setting `LWS_DBUS_INCLUDE1`
21and `LWS_DBUS_INCLUDE2`.  Although INCLUDE1 is usually guessable, both can be
22forced to allow cross-build.
23
24If these are not forced, then lws cmake will try to check some popular places,
25for `LWS_DBUS_INCLUDE1`, on both Fedora and Debian / Ubuntu, this is
26`/usr/include/dbus-1.0`... if the directory exists, it is used.
27
28For `LWS_DBUS_INCLUDE2`, it is the arch-specific dbus header which may be
29packaged separately than the main dbus headers.  On Fedora, this is in
30`/usr/lib[64]/dbus-1.0/include`... if not given externally, lws cmake will
31try `/usr/lib64/dbus-1.0/include`.  On Debian / Ubuntu, the package installs
32it in an arch-specific dir like `/usr/lib/x86_64-linux-gnu/dbus-1.0/include`,
33you should force the path.
34
35The library path is usually \[lib\] "dbus-1", but this can also be forced if
36you want to build cross or use a special build, via `LWS_DBUS_LIB`.
37
38## Building against local dbus build
39
40If you built your own local dbus and installed it in /usr/local, then
41this is the incantation to direct lws to use the local version of dbus:
42
43```
44cmake .. -DLWS_ROLE_DBUS=1 -DLWS_DBUS_INCLUDE1="/usr/local/include/dbus-1.0" -DLWS_DBUS_INCLUDE2="/usr/local/lib/dbus-1.0/include" -DLWS_DBUS_LIB="/usr/local/lib/libdbus-1.so"
45```
46
47You'll also need to give the loader a helping hand to do what you want if
48there's a perfectly good dbus lib already in `/usr/lib[64]` using `LD_PRELOAD`
49like this
50
51```
52LD_PRELOAD=/usr/local/lib/libdbus-1.so.3.24.0 myapp
53```
54
55## Lws dbus api exports
56
57Because of the irregular situation with libdbus includes, if lws exports the
58dbus helpers, which use dbus types, as usual from `#include <libwebsockets.h>`
59then if lws was compiled with dbus role support it forces all users to take
60care about the dbus include path mess whether they use dbus themselves or not.
61
62For that reason, if you need access to the lws dbus apis, you must explicitly
63include them by
64
65```
66#include <libwebsockets/lws-dbus.h>
67```
68
69This includes `<dbus/dbus.h>` and so requires the include paths set up.  But
70otherwise non-dbus users that don't include `libwebsockets/lws-dbus.h` don't
71have to care about it.
72
73## DBUS and valgrind
74
75https://cgit.freedesktop.org/dbus/dbus/tree/README.valgrind
76
771) One-time 6KiB "Still reachable" caused by abstract unix domain socket + libc
78`getgrouplist()` via nss... bug since 2004(!)
79
80https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=273051
81
82
83
84