diff options
author | Félix Piédallu <felix@piedallu.me> | 2020-01-23 13:12:15 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-07-13 20:36:13 +0100 |
commit | cd2e38261058f552fc51e14e0ac5af93411b3de5 (patch) | |
tree | 362ca0cbf6ef951f6d5ab3542e4a7bbe9ae2dc32 /meson.build | |
parent | b7a1da122a3cda9cc4c0becd948c6a993be43ef8 (diff) | |
download | dbus-cd2e38261058f552fc51e14e0ac5af93411b3de5.tar.gz |
Add Meson build system
Signed-off-by: Félix Piédallu <felix@piedallu.me>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 1056 |
1 files changed, 1056 insertions, 0 deletions
diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..8b871c44 --- /dev/null +++ b/meson.build @@ -0,0 +1,1056 @@ +# Copyright © 2019-2020 Salamandar <felix@piedallu.me> +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +project('dbus', + 'c', 'cpp', + version: '1.14.99', + meson_version: '>=0.56', +) + +project_url = 'https://gitlab.freedesktop.org/dbus/dbus' + +cc = meson.get_compiler('c') +cpp = meson.get_compiler('cpp') + +windows = import('windows') +pkgconfig = import('pkgconfig') + +config = configuration_data() +# Used for dbus-arch-deps.h, separated from config.h +arch_config = configuration_data() +# Non-quoted variables +data_config = configuration_data() + +# Those will be checked for compiler compatibility and added at the end +compile_args = [] +link_args = [] + +############################################################################### +# Project configuration + +not_found = dependency('', required: false) + +version = meson.project_version() +config.set_quoted('VERSION', version) +data_config.set('VERSION', version) +data_config.set('DBUS_VERSION', version) + +ver_array = version.split('.') +arch_config.set('DBUS_VERSION', version) +arch_config.set('DBUS_MAJOR_VERSION', ver_array[0]) +arch_config.set('DBUS_MINOR_VERSION', ver_array[1]) +arch_config.set('DBUS_MICRO_VERSION', ver_array[2]) + +config.set_quoted('DBUS_DAEMON_NAME', 'dbus-daemon') + +############################################################################### +# libtool versioning - this applies to libdbus +# http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 + +## increment if the interface has additions, changes, removals. +lt_current = 36 +## increment any time the source changes; +## set to 0 if you increment CURRENT +lt_revision = 0 +## increment if any interfaces have been added; +## set to 0 if any interfaces have been changed or removed. +## removal has precedence over adding, so set to 0 if both happened. +lt_age = 33 + +soversion = (lt_current - lt_age) +version_info = '@0@.@1@.@2@'.format(soversion, lt_age, lt_revision) + +data_config.set('SOVERSION', soversion) + +############################################################################### +# System detection + +python = find_program('python3') + +host_os = host_machine.system() + +platform_windows = host_os.contains('windows') + +platform_cygwin = host_os.contains('cygwin') + +# TODO: meson doesn't actually have WinCE support +platform_win32ce = host_os.contains('mingw32ce') + +platform_unix = not platform_windows + +config.set('DBUS_UNIX', platform_unix) +config.set('DBUS_CYGWIN', platform_cygwin) +config.set('DBUS_WIN', platform_windows) +config.set('DBUS_WINCE', platform_win32ce) + +if platform_unix + platform = 'Unix' +elif platform_cygwin + platform = 'cygwin' +elif platform_win32ce + platform = 'win32ce' +elif platform_windows + platform = 'windows' +else + platform = 'unknown' +endif +message('Detected platform : @0@ (@1@)'.format(platform, host_os)) + +if platform_windows + config.set('FD_SETSIZE', 8192, + description: 'The maximum number of connections that can be handled at once' + ) + if platform_win32ce + config.set('_WIN32_WCE', '0x0502', description: 'Get newer W32 CE APIs') + else + config.set('_WIN32_WINNT', '0x0600', + description: 'Define to the minimum supported Windows version (Vista)' + ) + endif + + # TODO: make this respect SOURCE_DATE_EPOCH + build_timestamp = run_command( + find_program('tools/build-timestamp.py'), + check: true, + ).stdout().strip() + + data_config.set('BUILD_TIMESTAMP', build_timestamp) + data_config.set('BUILD_FILEVERSION', ','.join(version.split('.'))) + + data_config.set('DBUS_VER_FILE_TYPE', 'VFT_DLL') + data_config.set('DBUS_VER_INTERNAL_NAME', 'libdbus-1-@0@' .format(soversion)) + data_config.set('DBUS_VER_ORIGINAL_NAME', 'libdbus-1-@0@.dll' .format(soversion)) +endif + +if platform_windows + conf_maybe_external = '<!--<auth>EXTERNAL</auth>-->' +else + conf_maybe_external = '<auth>EXTERNAL</auth>' +endif +data_config.set('DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL', conf_maybe_external) + +if host_os.contains('solaris') + compile_args += [ + # Solaris' C library apparently needs these runes to be threadsafe... + '-D_POSIX_PTHREAD_SEMANTICS', + # ... this opt-in to get sockaddr_in6 and sockaddr_storage... + '-D__EXTENSIONS__', + # ... and this opt-in to get file descriptor passing support + ' -D_XOPEN_SOURCE=500', + ] +endif + +if host_machine.endian() == 'big' + config.set('WORDS_BIGENDIAN', 1) +endif + +# Integer sizes +int_types = [ + { + 'type': 'short', + 'size': cc.sizeof('short'), + }, { + 'type': 'int', + 'size': cc.sizeof('int'), + 'type_c': '(val)', + 'type_u_c': '(val)', + 'type_m': '', + }, { + 'type': 'long', + 'size': cc.sizeof('long'), + 'type_c': '(val##L)', + 'type_u_c': '(val##UL)', + 'type_m': 'l', + }, { + 'type': 'long long', + 'size': cc.sizeof('long long'), + 'type_c': '(val##LL)', + 'type_u_c': '(val##ULL)', + 'type_m': 'll', + }, { + 'type': '__int64', + 'size': cc.sizeof('__int64'), + 'type_c': '(val##i64)', + 'type_u_c': '(val##ui64)', + 'type_m': 'I64', + }, { + 'type': 'err' + }, +] + +foreach type : int_types + if type.get('type') == 'err' + error('Could not find a 64-bit integer type.') + endif + if type.get('size') == 8 + arch_config.set('DBUS_INT64_TYPE', type.get('type')) + arch_config.set('DBUS_INT64_CONSTANT', type.get('type_c')) + arch_config.set('DBUS_UINT64_CONSTANT', type.get('type_u_c')) + if platform_windows + arch_config.set('DBUS_INT64_MODIFIER', 'I64') + else + arch_config.set('DBUS_INT64_MODIFIER', type.get('type_m')) + endif + break + endif +endforeach + +foreach type : int_types + if type.get('type') == 'err' + error('Could not find a 32-bit integer type.') + endif + if type.get('size') == 4 + arch_config.set('DBUS_INT32_TYPE', type.get('type')) + break + endif +endforeach + +foreach type : int_types + if type.get('type') == 'err' + error('Could not find a 16-bit integer type.') + endif + if type.get('size') == 2 + arch_config.set('DBUS_INT16_TYPE', type.get('type')) + break + endif +endforeach + +############################################################################### +# Dependencies + +xsltproc = find_program('xsltproc', required: get_option('xml_docs')) +build_xml_docs = false + +if xsltproc.found() + build_xml_docs = true + foreach fmt: [ 'html', 'manpages' ] + xsl = 'http://docbook.sourceforge.net/release/xsl/current/@0@/docbook.xsl'.format(fmt) + if run_command([xsltproc, '--nonet', xsl], check : false).returncode() == 0 + continue + endif + + build_xml_docs = false + if get_option('xml_docs').enabled() + error('Docbook XSL "@0@" not found'.format(fmt)) + else + message('Docbook XSL "@0@" not found, disabled automatically'.format(fmt)) + endif + endforeach +endif + +# For doxygen +doxygen = find_program('doxygen', required: get_option('doxygen_docs')) +ducktype = find_program('ducktype', required: get_option('ducktype_docs')) +yelpbuild = find_program('yelp-build', required: get_option('doxygen_docs')) + +can_upload_docs = doxygen.found() and xsltproc.found() and ducktype.found() + +qhelpgen = find_program('qhelpgenerator', 'qhelpgenerator-qt5', required: get_option('qt_help')) +qt_help_generate = doxygen.found() and qhelpgen.found() + +data_config.set('DBUS_GENERATE_MAN', platform_windows ? 'NO' : 'YES') +data_config.set('DOXYGEN_QCH_FILE', meson.current_build_dir() + / 'doc' / 'api' / 'qch' / 'dbus-@0@.qch'.format(version)) +if qhelpgen.found() + data_config.set('DOXYGEN_QHG_LOCATION', qhelpgen.full_path()) + data_config.set('DOXYGEN_GENERATE_QHP', 'YES') +else + data_config.set('DOXYGEN_QHG_LOCATION', '') + data_config.set('DOXYGEN_GENERATE_QHP', 'NO') +endif +data_config.set('top_srcdir', meson.project_source_root()) +data_config.set('top_builddir', meson.project_build_root()) + + +threads = dependency('threads') +config.set('HAVE_MONOTONIC_CLOCK', cc.has_header_symbol('pthread.h', 'CLOCK_MONOTONIC')) + +glib = dependency('glib-2.0', version: '>=2.40', required: false) +if platform_windows + gio = dependency('gio-windows-2.0', required: false) +else + gio = dependency('gio-unix-2.0', required: false) +endif +use_glib = glib.found() and gio.found() +config.set('DBUS_WITH_GLIB', use_glib) + +expat = dependency('expat') +config.set('HAVE_XML_SETHASHSALT', cc.has_function('XML_SetHashSalt', dependencies: expat)) + +selinux = dependency('libselinux', version: '>=2.0.86', required: get_option('selinux')) + +# the selinux code creates threads which requires libpthread even on linux +# TODO: smcv: actually we've stopped doing that. We still include <pthread.h> in +# selinux.c (but probably shouldn't), and we don't actually create the thread; +# so this can probably be simplified. +config.set('HAVE_SELINUX', selinux.found() and threads.found()) + +apparmor = dependency('libapparmor', version: '>=2.8.95', required: get_option('apparmor')) +config.set('HAVE_APPARMOR', apparmor.found()) +config.set('HAVE_APPARMOR_2_10', apparmor.version().version_compare('>=2.10')) + +if get_option('inotify').disabled() + use_inotify = false +else + use_inotify = cc.has_header('sys/inotify.h') + if get_option('inotify').enabled() and not use_inotify + error('inotify support requested but not found') + endif +endif + +if get_option('epoll').disabled() + use_linux_epoll = false +else + use_linux_epoll = ( + cc.has_header('sys/epoll.h') and + cc.has_function('epoll_create1', prefix: '#include <sys/epoll.h>') + ) + if get_option('epoll').enabled() and not use_linux_epoll + error('epoll support requested but not found') + endif +endif +config.set('DBUS_HAVE_LINUX_EPOLL', use_linux_epoll) + +if get_option('kqueue').disabled() + use_kqueue = false +else + use_kqueue = ( + cc.has_header('sys/event.h') and + cc.has_function('kqueue', prefix: '#include <sys/event.h>') + ) + if get_option('kqueue').enabled() and not use_kqueue + error('kqueue support requested but not found') + endif +endif +config.set('DBUS_BUS_ENABLE_KQUEUE', use_kqueue) + +if get_option('launchd').disabled() + use_launchd = false +else + launchctl = find_program('launchctl', required: get_option('launchd')) + use_launchd = cc.has_header('launch.h') and launchctl.found() + if get_option('launchd').enabled() and not use_launchd + error('launchd support requested but not found') + endif +endif +config.set('DBUS_BUS_ENABLE_LAUNCHD', use_launchd) + +if use_launchd + launchd_agent_dir = get_option('launchd_agent_dir') + if launchd_agent_dir == '' + launchd_agent_dir = '/Library/LaunchAgents' + endif +endif + +systemd = dependency('libsystemd', version: '>=209', required: get_option('systemd')) +use_systemd = systemd.found() +config.set('HAVE_SYSTEMD', use_systemd) + +if use_systemd + # If not found in $PATH, we might still have systemd and systemctl at runtime + # (perhaps dbus is being compiled in a minimal chroot with no systemd). + # Assume the upstream-recommended location. Distributors with split /usr + # can override this with --native-file (see https://mesonbuild.com/Machine-files.html) + systemctl = find_program('systemctl', required: false) + if systemctl.found() + systemctl = systemctl.full_path() + else + systemctl = '/usr/bin/systemctl' + endif + + systemd_system_unitdir = get_option('systemd_system_unitdir') + systemd_user_unitdir = get_option('systemd_user_unitdir') + + systemd_dirs = dependency('systemd', required: false) + if systemd_system_unitdir == '' + systemd_system_unitdir = (systemd_dirs.found() + ? systemd_dirs.get_variable(pkgconfig: 'systemdsystemunitdir') + : '/lib/systemd/system' + ) + endif + if systemd_user_unitdir == '' + systemd_user_unitdir = (systemd_dirs.found() + ? systemd_dirs.get_variable(pkgconfig: 'systemduserunitdir') + : '/usr/lib/systemd/user' + ) + endif +else + systemctl = '' +endif +data_config.set('SYSTEMCTL', systemctl) + + + +use_traditional_activation = get_option('traditional_activation') +config.set('ENABLE_TRADITIONAL_ACTIVATION', use_traditional_activation) + +if not (use_systemd or use_traditional_activation) + warning('Traditional activation and systemd activation are both disabled, ' + + 'so service activation (automatically starting services that ' + + 'receive messages) will not work') +endif + + +have_console_owner_file = false +console_owner_file = get_option('solaris_console_owner_file') +if console_owner_file != '' + if not host_os.contains('solaris') + error('solaris_console_owner_file is only supported on Solaris)') + endif + have_console_owner_file = true + if console_owner_file == 'auto' + console_owner_file = '/dev/console' + else + endif +endif +config.set('HAVE_CONSOLE_OWNER_FILE', have_console_owner_file) +config.set_quoted('DBUS_CONSOLE_OWNER_FILE', console_owner_file) + +if get_option('libaudit').disabled() + have_libaudit = false +else + libaudit = cc.find_library('audit', required: false) + libaudit_ok = cc.has_function('audit_log_user_avc_message', dependencies: libaudit) + cap_ng = cc.find_library('cap-ng', required: false) + cap_ng_ok = cc.has_function('capng_clear', dependencies: cap_ng) + have_libaudit = libaudit_ok and cap_ng_ok + if get_option('libaudit').enabled() and not have_libaudit + error('libaudit support requested but not found') + endif +endif +config.set('HAVE_LIBAUDIT', have_libaudit) + +if have_libaudit + selinux = [ selinux, libaudit, cap_ng ] +endif + +# Check for ADT API (Solaris Basic Security Mode auditing) +adt_api_check = cc.compiles(''' +#include <bsm/adt.h> +int main() { + adt_user_context = ADT_USER; + return 0; +} +''') +config.set('HAVE_ADT', adt_api_check) +if adt_api_check + adt_libs = cc.find_library('bsm') +else + adt_libs = dependency('', required: false) +endif + +# Check for SCM_RIGHTS +has_scm_rights = cc.compiles(''' +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/un.h> +int main() { + static int x = SCM_RIGHTS; + return 0; +} +''') +config.set('HAVE_UNIX_FD_PASSING', has_scm_rights) + +valgrind = dependency('valgrind', version: '>=3.6', required: false) +config.set('WITH_VALGRIND', valgrind.found()) + +if platform_win32ce + network_libs = [ + cc.find_library('ws2'), + ] +elif platform_windows + network_libs = [ + cc.find_library('ws2_32'), + cc.find_library('iphlpapi'), + cc.find_library('dbghelp'), + ] +else + network_libs = [] +endif + +if get_option('x11_autolaunch').disabled() + use_x11_autolaunch = false +else + if get_option('x11_autolaunch').enabled() and platform_windows + error('X11 autolaunch is not supported on Windows') + endif + + x11 = dependency('x11', required: false) + use_x11_autolaunch = x11.found() + + if get_option('x11_autolaunch').enabled() and not use_x11_autolaunch + error('X11 autolaunch support requested but not found') + endif +endif +config.set('DBUS_BUILD_X11', use_x11_autolaunch) +config.set('DBUS_ENABLE_X11_AUTOLAUNCH', use_x11_autolaunch) + + +check_functions = [ + 'accept4', + 'clearenv', + 'closefrom', + 'close_range', + 'dirfd', + 'fpathconf', + 'getgrouplist', + 'getpeereid', + 'getpeerucred', + 'getpwnam_r', + 'getrandom', + 'getresuid', + 'getrlimit', + 'inotify_init1', + 'issetugid', + 'localeconv', + 'nanosleep', + 'pipe2', + 'poll', + 'prctl', + 'prlimit', + 'raise', + 'setenv', + 'setlocale', + 'setresuid', + 'setrlimit', + 'socketpair', + 'strtoll', + 'strtoull', + 'unsetenv', + 'usleep', +] + +foreach function : check_functions + macro = 'HAVE_' + function.underscorify().to_upper() + config.set(macro, cc.has_function(function) ? 1 : false) +endforeach + +check_headers = [ + 'alloca.h', + 'byteswap.h', + 'crt_externs.h', + 'dirent.h', + 'errno.h', + 'inttypes.h', + 'linux/close_range.h', + 'locale.h', + 'signal.h', + 'stdint.h', + 'syslog.h', + 'sys/prctl.h', + 'sys/random.h', + 'sys/resource.h', + 'sys/syscall.h', + 'sys/syslimits.h', + 'sys/time.h', + 'unistd.h', + 'ws2tcpip.h', +] + +foreach header : check_headers + macro = 'HAVE_' + header.underscorify().to_upper() + config.set(macro, cc.has_header(header) ? 1 : false) +endforeach + +execinfo = cc.find_library('execinfo', required: false) +have_backtrace = (cc.has_header('execinfo.h') + and cc.has_function('backtrace', dependencies: execinfo) +) +config.set('HAVE_BACKTRACE', have_backtrace) + + +# ********************************** +# *** va_copy checks (from GLib) *** +# ********************************** +# we currently check for all three va_copy possibilities, so we get +# all results in config.log for bug reports. + +has_va_copy = cc.has_function('va_copy') +has___va_copy = cc.has_function('__va_copy') +if has_va_copy + va_copy = 'va_copy' +elif has___va_copy + va_copy = '__va_copy' +elif cc.get_id() == 'msvc' + va_copy = '_DBUS_VA_COPY_ASSIGN' + config.set('_DBUS_VA_COPY_ASSIGN(a1,a2)', '{ a1 = a2; }') +else + error('dbus requires an ISO C99-compatible va_copy() macro, ' + + 'or a compatible __va_copy()') +endif +config.set('DBUS_VA_COPY', va_copy) + + +#### Atomic integers +config.set10('DBUS_USE_SYNC', cc.has_function('__sync_sub_and_fetch') ? 1 : false) + +config.set('HAVE_DECL_MSG_NOSIGNAL', + cc.has_header_symbol('sys/socket.h', 'MSG_NOSIGNAL') ? 1 : false +) +config.set('HAVE_SOCKLEN_T', + cc.has_type('socklen_t', prefix: '#include <sys/socket.h>') +) +config.set('HAVE_CMSGCRED', + cc.has_type('struct cmsgcred', prefix: '#include <sys/socket.h>') +) + +config.set('HAVE_WRITEV', + cc.has_header_symbol('sys/uio.h', 'writev') +) + +config.set('HAVE_UNPCBID', + cc.has_member('struct unpcbid', 'unp_pid', prefix: '#include <sys/un.h>') +) + + +############################################################################### +# Project options + +# Verbose mode +verbose_mode = get_option('verbose_mode') +config.set('DBUS_ENABLE_VERBOSE_MODE', verbose_mode) + +# Asserts defaults to developer mode +asserts = get_option('asserts') +config.set('DBUS_ENABLE_ASSERTS', asserts) + +config.set('DBUS_ENABLE_ASSERT', asserts ? 1 : false) +config.set('DBUS_DISABLE_ASSERT', not asserts ? 1 : false) + +# -rdynamic is needed for glibc's backtrace_symbols to work. +# No clue how much overhead this adds, but it's useful +# to do this on any assertion failure, +# so for now it's enabled anytime asserts are (currently not +# in production builds). +# To get -rdynamic you pass -export-dynamic to libtool. +config.set('DBUS_BUILT_R_DYNAMIC', asserts ? 1 : false) +if asserts + link_args += '-export-dynamic' +endif + +if not asserts + compile_args += [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-function', + ] +endif + + +checks = get_option('checks') +config.set('DBUS_ENABLE_CHECKS', checks ? 1 : false) +config.set('DBUS_DISABLE_CHECKS', not checks ? 1 : false) +config.set('G_DISABLE_CHECKS', not checks ? 1 : false) + + +dbus_static_flags = ( get_option('default_library') == 'static' + ? '-DDBUS_STATIC_BUILD' + : [] +) +compile_args += dbus_static_flags + + +# DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files +# and some stuff in the test/ subdir. +embedded_tests = get_option('embedded_tests') +config.set('DBUS_ENABLE_EMBEDDED_TESTS', embedded_tests) + + +# DBUS_ENABLE_MODULAR_TESTS controls tests that work based on public API. +# These use GTest, from GLib, because life's too short. They're enabled by +# default (unless you don't have GLib), because they don't bloat the library +# or binaries. +dbus_enable_modular_tests = ( + get_option('modular_tests') + and glib.version().version_compare('>=2.40') + and gio.found() +) + +############################################################################### +# Paths and directories + +docs_dir = get_option('datadir') / 'doc' / 'dbus' + +data_config.set('EXPANDED_LOCALSTATEDIR', '/' / get_option('localstatedir')) +data_config.set('EXPANDED_SYSCONFDIR', '/' / get_option('sysconfdir')) +data_config.set('EXPANDED_RUNSTATEDIR', '/' / 'run') +data_config.set('EXPANDED_BINDIR', get_option('prefix') / get_option('bindir')) +data_config.set('EXPANDED_DATADIR', get_option('prefix') / get_option('datadir')) + +data_config.set('DBUS_PREFIX', get_option('prefix')) +config.set_quoted('DBUS_PREFIX', get_option('prefix')) +config.set_quoted('DBUS_BINDIR', get_option('prefix') / get_option('bindir')) +config.set_quoted('DBUS_DATADIR',get_option('prefix') / get_option('datadir')) +data_config.set('DBUS_LIBEXECDIR', get_option('prefix') / get_option('libexecdir')) + +config.set_quoted('DBUS_RUNSTATEDIR', + get_option('localstatedir') +) +config.set_quoted('DBUS_MACHINE_UUID_FILE', + get_option('localstatedir') / 'lib'/'dbus'/'machine-id' +) +config.set_quoted('DBUS_SYSTEM_CONFIG_FILE', + get_option('prefix') / get_option('datadir') / 'dbus-1' / 'system.conf' +) +config.set_quoted('DBUS_SESSION_CONFIG_FILE', + get_option('prefix') / get_option('datadir') / 'dbus-1' / 'session.conf' +) + + +system_socket = get_option('system_socket') +if system_socket == '' + # We don't use runstatedir for this (yet?), because /var/run has been the + # interoperable system bus socket for 10+ years. + # See https://bugs.freedesktop.org/show_bug.cgi?id=101628 + system_socket = '/' / get_option('localstatedir')/'run'/'dbus'/'system_bus_socket' +endif +data_config.set('DBUS_SYSTEM_SOCKET', system_socket) + +## System bus only listens on local domain sockets, and never +## on an abstract socket (so only root can create the socket). +## +## This won't work on Windows. It's not meant to - the system bus is +## meaningless on Windows anyway. +## +## This has to be suitable for hard-coding in client libraries as well as +## in the dbus-daemon's configuration, so it has to be valid to listen on +## and also to connect to. If this ever changes, it'll need to be split into +## two variables, one for the listening address and one for the connecting +## address. +system_bus_default_address = 'unix:path=@0@'.format(system_socket) +data_config.set('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS', system_bus_default_address) +config.set_quoted('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS', system_bus_default_address) + + +system_pid_file = get_option('system_pid_file') +if system_pid_file == '' + system_pid_file = '/run'/'dbus'/'pid' +endif +data_config.set('DBUS_SYSTEM_PID_FILE', system_pid_file) + + +dbus_user = get_option('dbus_user') +data_config.set('DBUS_USER', dbus_user) +config.set_quoted('DBUS_USER', dbus_user) + +test_user = get_option('test_user') +config.set_quoted('DBUS_TEST_USER', test_user) + +daemon_dir = get_option('dbus_daemondir') +if daemon_dir == '' + daemon_dir = get_option('prefix') / get_option('bindir') +endif +data_config.set('DBUS_DAEMONDIR', daemon_dir) +config.set_quoted('DBUS_DAEMONDIR', daemon_dir) + + + +# Relocation is disabled by default, let's check if we need to enable it +relocation = false +if get_option('relocation').enabled() + # Manually forced at true + relocation = true +endif +if get_option('relocation').auto() and platform_windows + # By default, on Windows we are relocatable if possible + relocation = true +endif + +# Now check if it's not possible +# Meson does not separate exec_prefix and prefix (hopefully) +if relocation and not (get_option('libdir') in [ 'lib', 'lib64', ]) + message = ( + 'Relocatable pkg-config metadata requires default libdir, ' + + 'not @0@'.format(get_option('libdir')) + ) + if get_option('relocation').enabled() + error(message) + else + warning(message) + endif +endif + +#### Directory to source sysconfdir configuration from + +# On Windows this is relative to where we put the bus setup, in +# ${datadir}/dbus-1. For simplicity, we only do this if +# ${sysconfdir} = ${prefix}/etc and ${datadir} = ${prefix}/share. +# +# On Unix, or on Windows with weird install layouts, it's the absolute path. +if (platform_windows + and data_config.get('EXPANDED_SYSCONFDIR') == get_option('prefix') / 'etc' + and data_config.get('EXPANDED_DATADIR') == get_option('prefix') / 'share' +) + sysconfdir_from_pkgdatadir = '../../etc' + datadir_from_pkgsysconfdir = '../../share' +else + sysconfdir_from_pkgdatadir = data_config.get('EXPANDED_SYSCONFDIR') + datadir_from_pkgsysconfdir = data_config.get('EXPANDED_DATADIR') +endif +data_config.set('SYSCONFDIR_FROM_PKGDATADIR', sysconfdir_from_pkgdatadir) +data_config.set('DATADIR_FROM_PKGSYSCONFDIR', datadir_from_pkgsysconfdir) + +#### Find socket directories +values = run_command(python, '-c', + 'import os; [print(os.getenv(e, "")) for e in ["TMPDIR", "TEMP", "TMP"]]', + check: true, +).stdout() +values += '/tmp' +default_socket_dir = values.strip().split('\n')[0] + +test_socket_dir = get_option('test_socket_dir') +if test_socket_dir == '' + test_socket_dir = default_socket_dir +endif +test_listen = platform_unix ? 'unix:tmpdir=' + test_socket_dir : 'tcp:host=localhost' +config.set_quoted('TEST_LISTEN', test_listen) +data_config.set('TEST_LISTEN', test_listen) + +session_socket_dir = get_option('session_socket_dir') +if session_socket_dir == '' + session_socket_dir = default_socket_dir +endif +config.set_quoted('DBUS_SESSION_SOCKET_DIR', session_socket_dir) + +session_bus_listen_address = get_option('dbus_session_bus_listen_address') +if session_bus_listen_address == '' + if platform_windows + session_bus_listen_address = 'autolaunch:' + elif use_launchd + session_bus_listen_address = 'launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET' + else + session_bus_listen_address = 'unix:tmpdir=@0@'.format(session_socket_dir) + endif +endif +data_config.set('DBUS_SESSION_BUS_LISTEN_ADDRESS', session_bus_listen_address) + + + +session_bus_connect_address = get_option('dbus_session_bus_connect_address') +if session_bus_connect_address == '' + session_bus_connect_address = 'autolaunch:' +endif +config.set_quoted('DBUS_SESSION_BUS_CONNECT_ADDRESS', session_bus_connect_address) + + +config.set('DBUS_ENABLE_STATS', get_option('stats')) +config.set('DBUS_ENABLE_CONTAINERS', get_option('containers')) +enable_user_session = get_option('user_session') + + +# Add this only for the correct targets +config.set('DBUS_COMPILATION', true) + +exe_ext = platform_windows ? '.exe' : '' +config.set_quoted('DBUS_EXEEXT', exe_ext) + +compile_args_c = [] +compile_args += [ + '-D_GNU_SOURCE', +] + +if cc.get_id() == 'msvc' + compile_args += [ + # once + '/wo4018', # 'expression' : signed/unsigned mismatch + # disabled + '/wd4090', # 'operation' : different 'modifier' qualifiers + '/wd4101', # 'identifier' : unreferenced local variable + '/wd4127', # conditional expression is constant + '/wd4244', # 'argument' : conversion from 'type1' to 'type2', possible loss of data + # error + '/we4002', # too many actual parameters for macro 'identifier' + '/we4003', # not enough actual parameters for macro 'identifier' + '/we4013', # 'function' undefined; assuming extern returning int + '/we4028', # formal parameter 'number' different from declaration + '/we4031', # second formal parameter list longer than the first list + '/we4047', # operator' : 'identifier1' differs in levels of indirection from 'identifier2' + '/we4114', # same type qualifier used more than once + '/we4133', # 'type' : incompatible types - from 'type1' to 'type2' + ] +else + compile_args += [ + '-Wno-missing-field-initializers', + '-Wno-unused-parameter', + '-Wchar-subscripts', + '-Wfloat-equal', + '-D__USE_MINGW_ANSI_STDIO=0', + ] + + compile_args_c += [ + '-Wpointer-sign', + ] +endif + +compile_args_c = cc .get_supported_arguments(compile_args + compile_args_c) +compile_args_cpp= cpp.get_supported_arguments(compile_args) +link_args = cc.get_supported_link_arguments(link_args) +add_project_arguments(compile_args_c, language: 'c') +add_project_arguments(compile_args_cpp, language: 'cpp') +add_project_link_arguments(link_args, language: [ 'c', 'cpp' ]) + +root_include = include_directories('.') + +configure_file( + output: 'config.h', + configuration: config, +) + +bonus_files = files( + 'AUTHORS', + 'CONTRIBUTING.md', + 'COPYING', + 'NEWS', + 'README', +) + +subdir('dbus') +subdir('bus') +subdir('tools') +subdir('test') +subdir('doc') +subdir('cmake') + +meson.add_install_script('meson_post_install.py', + '@0@'.format(platform_unix), + '@0@'.format(relocation), + '@0@'.format(use_systemd), +) + +if use_systemd + meson.add_install_script('meson_post_install_systemd.py', + systemd_system_unitdir, + systemd_user_unitdir, + ) +endif + +pkgconfig.generate( + libdbus, + name: 'dbus', + filebase: 'dbus-1', + description: 'Free desktop message bus', + subdirs: [ 'dbus-1.0' ], + extra_cflags: [ + '-I${libdir}/dbus-1.0/include', + ] + dbus_static_flags, + variables: { + 'original_prefix': get_option('prefix'), + + 'exec_prefix': '${prefix}', + 'bindir': '${prefix}' / get_option('bindir'), + 'datadir': '${prefix}' / get_option('datadir'), + 'datarootdir': '${prefix}' / get_option('datadir'), + 'sysconfdir': '/' / get_option('sysconfdir'), + + 'daemondir': '${bindir}', + 'system_bus_default_address': system_bus_default_address, + 'session_bus_services_dir': '${datadir}/dbus-1/services', + 'system_bus_services_dir': '${datadir}/dbus-1/system-services', + 'interfaces_dir': '${datadir}/dbus-1/interfaces', + } +) + +summary_dict = { + 'prefix': get_option('prefix'), + 'exec_prefix': get_option('prefix'), + 'libdir': get_option('prefix') / get_option('libdir'), + 'libexecdir': get_option('prefix') / get_option('libexecdir'), + 'bindir': get_option('prefix') / get_option('bindir'), + 'sysconfdir': data_config.get('EXPANDED_SYSCONFDIR'), + 'localstatedir': data_config.get('EXPANDED_LOCALSTATEDIR'), + 'runstatedir': data_config.get('EXPANDED_RUNSTATEDIR'), + 'datadir': data_config.get('EXPANDED_DATADIR'), + 'source code location': meson.project_source_root(), + 'compiler': cc.get_id(), + 'cflags': compile_args_c, + 'cxxflags': compile_args_cpp, + 'ldflags': (link_args.length() == 0) ? '[]' : link_args, + '64-bit int': arch_config.get('DBUS_INT64_TYPE'), + '32-bit int': arch_config.get('DBUS_INT32_TYPE'), + '16-bit int': arch_config.get('DBUS_INT16_TYPE'), + 'xsltproc': xsltproc.found() ? xsltproc.full_path() : '', + 'Doxygen': doxygen.found() ? doxygen.full_path() : '', + 'ducktype': ducktype.found() ? ducktype.full_path() : '', + 'yelp-build': yelpbuild.found() ? yelpbuild.full_path() : '', + + 'gcc coverage': get_option('b_coverage'), + 'gcc profiling': get_option('b_pgo'), + 'Building embedded tests': embedded_tests, + 'Building modular tests': dbus_enable_modular_tests, + '- with GLib': use_glib, + 'Installing tests': get_option('installed_tests'), + 'Building verbose mode': verbose_mode, + 'Building assertions': asserts, + 'Building checks': checks, + 'Building bus stats API': get_option('stats'), + 'Building container API': get_option('containers'), + 'Building SELinux support': config.get('HAVE_SELINUX'), + 'Building AppArmor support': apparmor.found(), + 'Building inotify support': use_inotify, + 'Building kqueue support': use_kqueue, + 'Building systemd support': use_systemd, + 'Traditional activation': use_traditional_activation, + 'Building X11 code': config.get('DBUS_BUILD_X11'), + 'Building Doxygen docs': doxygen.found(), + 'Building Qt help file': qt_help_generate, + 'Building Ducktype docs': ducktype.found(), + 'Building XML docs': build_xml_docs, + 'Building launchd support': use_launchd, + 'System bus socket': data_config.get('DBUS_SYSTEM_SOCKET'), + 'System bus address': config.get('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS'), + 'System bus PID file': data_config.get('DBUS_SYSTEM_PID_FILE'), + 'Session bus listens on': data_config.get('DBUS_SESSION_BUS_LISTEN_ADDRESS'), + 'Session clients connect to': config.get('DBUS_SESSION_BUS_CONNECT_ADDRESS'), + 'System bus user': dbus_user, + 'Session bus services dir': + get_option('prefix') / get_option('datadir') / 'dbus-1' / 'services', + 'Tests socket dir': test_socket_dir, +} + +if host_os.contains('solaris') + summary_dict += { + 'Console owner file': console_owner_file, + } +endif + +summary(summary_dict, bool_yn: true) + +if embedded_tests + warning('building with unit tests increases the size of the installed library and renders it insecure.') + if not asserts + warning('building with embedded tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)') + endif +endif + +if get_option('b_coverage') + warning('Building with coverage profiling is definitely for developers only.') +endif + +if verbose_mode + warning('building with verbose mode increases library size, may slightly increase security risk, and decreases performance.') +endif + +if asserts + warning('building with assertions increases library size and decreases performance.') +endif + +if not checks + warning('building without checks for arguments passed to public API makes it harder to debug apps using D-Bus, but will slightly decrease D-Bus library size and _very_ slightly improve performance.') +endif |