summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/CMakeLists.txt3
-rw-r--r--cmake/ConfigureChecks.cmake17
-rw-r--r--cmake/config.h.cmake18
-rw-r--r--cmake/modules/CheckForAbstractSockets.c33
4 files changed, 71 insertions, 0 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 8f73d559..d63c40b1 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -49,6 +49,9 @@ find_package(LibXml2)
find_package(LibExpat)
find_package(X11)
+
+OPTION(DBUS_ENABLE_ABSTRACT_SOCKETS "enable support for abstract sockets" ON)
+
# do config checks
INCLUDE(ConfigureChecks.cmake)
diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake
index c44ea7ae..f42ce767 100644
--- a/cmake/ConfigureChecks.cmake
+++ b/cmake/ConfigureChecks.cmake
@@ -130,3 +130,20 @@ else(DBUS_HAVE_VA_COPY)
SET(DBUS_VA_COPY_AS_ARRAY "1" CACHE STRING "'va_lists' cannot be copies as values")
endif(DBUS_HAVE___VA_COPY)
endif(DBUS_HAVE_VA_COPY)
+
+#### Abstract sockets
+
+if (DBUS_ENABLE_ABSTRACT_SOCKETS)
+
+ try_compile(HAVE_ABSTRACT_SOCKETS
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/modules/CheckForAbstractSockets.c)
+
+endif(DBUS_ENABLE_ABSTRACT_SOCKETS)
+
+if(HAVE_ABSTRACT_SOCKETS)
+ set(DBUS_PATH_OR_ABSTRACT_VALUE abstract)
+else(HAVE_ABSTRACT_SOCKETS)
+ set(DBUS_PATH_OR_ABSTRACT_VALUE path)
+endif(HAVE_ABSTRACT_SOCKETS)
+
diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake
index 047135b2..3461338d 100644
--- a/cmake/config.h.cmake
+++ b/cmake/config.h.cmake
@@ -48,7 +48,21 @@
/* xmldocs */
/* doxygen */
#cmakedefine DBUS_GCOV_ENABLED 1
+
/* abstract-sockets */
+
+#cmakedefine HAVE_ABSTRACT_SOCKETS 1
+
+#cmakedefine DBUS_PATH_OR_ABSTRACT_VALUE 1
+
+#if (defined DBUS_PATH_OR_ABSTRACT_VALUE)
+#define DBUS_PATH_OR_ABSTRACT @DBUS_PATH_OR_ABSTRACT_VALUE@
+#endif
+
+#ifdef DBUS_PATH_OR_ABSTRACT_VALUE
+#undef DBUS_PATH_OR_ABSTRACT_VALUE
+#endif
+
/* selinux */
#cmakedefine DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX 1
/* kqueue */
@@ -69,6 +83,10 @@
# define DBUS_VA_COPY @DBUS_VA_COPY_FUNC@
#endif
+#ifdef DBUS_VA_COPY_FUNC
+#undef DBUS_VA_COPY_FUNC
+#endif
+
#cmakedefine DBUS_VA_COPY_AS_ARRAY 1
// headers
diff --git a/cmake/modules/CheckForAbstractSockets.c b/cmake/modules/CheckForAbstractSockets.c
new file mode 100644
index 00000000..062b846c
--- /dev/null
+++ b/cmake/modules/CheckForAbstractSockets.c
@@ -0,0 +1,33 @@
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <errno.h>
+
+int main() {
+ int listen_fd;
+ struct sockaddr_un addr;
+
+ listen_fd = socket (PF_UNIX, SOCK_STREAM, 0);
+
+ if (listen_fd < 0)
+ {
+ fprintf (stderr, "socket() failed: %s\n", strerror (errno));
+ exit (1);
+ }
+
+ memset (&addr, '\0', sizeof (addr));
+ addr.sun_family = AF_UNIX;
+ strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test");
+ addr.sun_path[0] = '\0'; /* this is what makes it abstract */
+
+ if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0)
+ {
+ fprintf (stderr, "Abstract socket namespace bind() failed: %s\n",
+ strerror (errno));
+ exit (1);
+ }
+ else
+ exit (0);
+} \ No newline at end of file