Merge tag 'v1.9.22' into LADI/main
[jack2.git] / dbus / wscript
blobef1db0738bc5d671f7a6c3ec22c2178626412555
1 #! /usr/bin/python3
2 # encoding: utf-8
4 # Copyright (C) 2015, 2018 Karl Linden <karl.j.linden@gmail.com>
5 # Copyleft (C) 2008-2022 Nedko Arnaudov
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 import os.path
23 from waflib import Logs, Options
26 def options(opt):
27     opt.add_option(
28         '--enable-pkg-config-dbus-service-dir',
29         action='store_true',
30         default=False,
31         help='force D-Bus service install dir to be one returned by pkg-config',
32     )
35 def configure(conf):
36     conf.env['BUILD_JACKDBUS'] = False
37     conf.define('JACK_VERSION', conf.env['JACK_VERSION'])
39     if not conf.check_cfg(package='dbus-1 >= 1.0.0', args='--cflags --libs', mandatory=False):
40         print(
41             Logs.colors.RED + 'ERROR !! jackdbus will not be built because libdbus-dev is missing' + Logs.colors.NORMAL
42         )
43         return
45     dbus_dir = conf.check_cfg(package='dbus-1', args='--variable=session_bus_services_dir')
46     if not dbus_dir:
47         print(
48             Logs.colors.RED + 'ERROR !! jackdbus will not be built because service dir is unknown' + Logs.colors.NORMAL
49         )
50         return
52     dbus_dir = dbus_dir.strip()
53     conf.env['DBUS_SERVICES_DIR_REAL'] = dbus_dir
55     if Options.options.enable_pkg_config_dbus_service_dir:
56         conf.env['DBUS_SERVICES_DIR'] = dbus_dir
57     else:
58         conf.env['DBUS_SERVICES_DIR'] = os.path.normpath(conf.env['PREFIX'] + '/share/dbus-1/services')
60     if not conf.check_cfg(package='expat', args='--cflags --libs', mandatory=False):
61         print(Logs.colors.RED + 'ERROR !! jackdbus will not be built because of expat is missing' + Logs.colors.NORMAL)
62         return
64     conf.env['BUILD_JACKDBUS'] = True
67 def build(bld):
68     obj = bld(features=['c', 'cprogram'], idx=17)
69     if bld.env['IS_LINUX']:
70         sysdeps_dbus_include = ['../linux', '../posix']
71     if bld.env['IS_FREEBSD']:
72         sysdeps_dbus_include = ['../freebsd', '../posix']
73     if bld.env['IS_MACOSX']:
74         sysdeps_dbus_include = ['../macosx', '../posix']
76     obj.includes = sysdeps_dbus_include + ['.', '../', '../common', '../common/jack']
77     obj.defines = ['HAVE_CONFIG_H', 'SERVER_SIDE']
78     obj.source = [
79         'jackdbus.c',
80         'controller.c',
81         'params.c',
82         'controller_iface_configure.c',
83         'controller_iface_control.c',
84         'controller_iface_introspectable.c',
85         'controller_iface_patchbay.c',
86         'controller_iface_session_manager.c',
87         'controller_iface_transport.c',
88         'xml.c',
89         'xml_expat.c',
90         'xml_write_raw.c',
91         'sigsegv.c',
92         'reserve.c',
93         ]
94     obj.use = ['serverlib']
95     if bld.env['IS_LINUX']:
96         obj.source += [
97             '../linux/uptime.c',
98         ]
99         obj.use += ['PTHREAD', 'DL', 'RT', 'DBUS-1', 'EXPAT', 'STDC++']
100     if bld.env['IS_FREEBSD']:
101         obj.source += [
102             '../linux/uptime.c',
103         ]
104         obj.use += ['PTHREAD', 'EXECINFO', 'LIBSYSINFO', 'DBUS-1', 'EXPAT']
105     if bld.env['IS_MACOSX']:
106         obj.source += [
107             '../macosx/uptime.c',
108         ]
109         obj.use += ['PTHREAD', 'DL', 'DBUS-1', 'EXPAT']
110     obj.target = 'jackdbus'
112     # process org.jackaudio.service.in -> org.jackaudio.service
113     obj = bld(
114             features='subst',
115             source='org.jackaudio.service.in',
116             target='org.jackaudio.service',
117             install_path='${DBUS_SERVICES_DIR}/',
118             BINDIR=bld.env['PREFIX'] + '/bin')
120     if not bld.env['IS_WINDOWS']:
121         bld.install_files('${PREFIX}/bin', 'jack_control', chmod=0o755)