Default autostart to "none"
[jackdbus.git] / wscript
blob00041808519a0e2bfb75019d126e4ec02e92ee01
1 #! /usr/bin/python3
2 # encoding: utf-8
3 from __future__ import print_function
5 import os
6 import shutil
7 import sys
9 from waflib import Logs, Options, TaskGen
10 from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
12 # see also common/JackConstants.h
13 VERSION = '2.21'
14 APPNAME = 'jack'
15 JACK_API_VERSION = '0.1.0'
17 # these variables are mandatory ('/' are converted automatically)
18 top = '.'
19 out = 'build'
21 # lib32 variant name used when building in mixed mode
22 lib32 = 'lib32'
25 def display_feature(conf, msg, build):
26     if build:
27         conf.msg(msg, 'yes', color='GREEN')
28     else:
29         conf.msg(msg, 'no', color='YELLOW')
32 def check_for_celt(conf):
33     found = False
34     for version in ['11', '8', '7', '5']:
35         define = 'HAVE_CELT_API_0_' + version
36         if not found:
37             try:
38                 conf.check_cfg(
39                         package='celt >= 0.%s.0' % version,
40                         args='--cflags --libs')
41                 found = True
42                 conf.define(define, 1)
43                 continue
44             except conf.errors.ConfigurationError:
45                 pass
46         conf.define(define, 0)
48     if not found:
49         raise conf.errors.ConfigurationError
52 def options(opt):
53     # options provided by the modules
54     opt.load('compiler_cxx')
55     opt.load('compiler_c')
56     opt.load('autooptions')
58     opt.load('xcode6')
60     opt.recurse('compat')
62     # install directories
63     opt.add_option(
64         '--htmldir',
65         type='string',
66         default=None,
67         help='HTML documentation directory [Default: <prefix>/share/jack-audio-connection-kit/reference/html/',
68     )
69     opt.add_option('--libdir', type='string', help='Library directory [Default: <prefix>/lib]')
70     opt.add_option('--libdir32', type='string', help='32bit Library directory [Default: <prefix>/lib32]')
71     opt.add_option('--pkgconfigdir', type='string', help='pkg-config file directory [Default: <libdir>/pkgconfig]')
72     opt.add_option('--mandir', type='string', help='Manpage directory [Default: <prefix>/share/man/man1]')
74     # options affecting binaries
75     opt.add_option(
76         '--platform',
77         type='string',
78         default=sys.platform,
79         help='Target platform for cross-compiling, e.g. cygwin or win32',
80     )
81     opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
82     opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
83     opt.add_option(
84         '--static',
85         action='store_true',
86         default=False,
87         dest='static',
88         help='Build static binaries (Windows only)',
89     )
91     # options affecting general jack functionality
92     opt.add_option(
93         '--classic',
94         action='store_true',
95         default=False,
96         help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too',
97     )
98     opt.add_option('--dbus', action='store_true', default=True, help='Enable D-Bus JACK (jackdbus)')
99     opt.add_option(
100         '--autostart',
101         type='string',
102         default='default',
103         help='Autostart method. Possible values: "none", "dbus", "classic", "default" (none)',
104     )
105     opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
106     opt.add_option('--clients', default=256, type='int', dest='clients', help='Maximum number of JACK clients')
107     opt.add_option(
108         '--ports-per-application',
109         default=2048,
110         type='int',
111         dest='application_ports',
112         help='Maximum number of ports per application',
113     )
114     opt.add_option('--systemd-unit', action='store_true', default=False, help='Install systemd units.')
116     opt.set_auto_options_define('HAVE_%s')
117     opt.set_auto_options_style('yesno_and_hack')
119     # options with third party dependencies
120     doxygen = opt.add_auto_option(
121             'doxygen',
122             help='Build doxygen documentation',
123             conf_dest='BUILD_DOXYGEN_DOCS',
124             default=False)
125     doxygen.find_program('doxygen')
126     alsa = opt.add_auto_option(
127             'alsa',
128             help='Enable ALSA driver',
129             conf_dest='BUILD_DRIVER_ALSA')
130     alsa.check_cfg(
131             package='alsa >= 1.0.18',
132             args='--cflags --libs')
133     firewire = opt.add_auto_option(
134             'firewire',
135             help='Enable FireWire driver (FFADO)',
136             conf_dest='BUILD_DRIVER_FFADO')
137     firewire.check_cfg(
138             package='libffado >= 1.999.17',
139             args='--cflags --libs')
140     iio = opt.add_auto_option(
141             'iio',
142             help='Enable IIO driver',
143             conf_dest='BUILD_DRIVER_IIO')
144     iio.check_cfg(
145             package='gtkIOStream >= 1.4.0',
146             args='--cflags --libs')
147     iio.check_cfg(
148             package='eigen3 >= 3.1.2',
149             args='--cflags --libs')
150     portaudio = opt.add_auto_option(
151             'portaudio',
152             help='Enable Portaudio driver',
153             conf_dest='BUILD_DRIVER_PORTAUDIO')
154     portaudio.check(header_name='windows.h')  # only build portaudio on windows
155     portaudio.check_cfg(
156             package='portaudio-2.0 >= 19',
157             uselib_store='PORTAUDIO',
158             args='--cflags --libs')
159     winmme = opt.add_auto_option(
160             'winmme',
161             help='Enable WinMME driver',
162             conf_dest='BUILD_DRIVER_WINMME')
163     winmme.check(
164             header_name=['windows.h', 'mmsystem.h'],
165             msg='Checking for header mmsystem.h')
167     celt = opt.add_auto_option(
168             'celt',
169             help='Build with CELT')
170     celt.add_function(check_for_celt)
171     opt.add_auto_option(
172             'example-tools',
173             help='Build with jack-example-tools',
174             conf_dest='BUILD_JACK_EXAMPLE_TOOLS',
175             default=False,
176     )
178     # Suffix _PKG to not collide with HAVE_OPUS defined by the option.
179     opus = opt.add_auto_option(
180             'opus',
181             help='Build Opus netjack2')
182     opus.check(header_name='opus/opus_custom.h')
183     opus.check_cfg(
184             package='opus >= 0.9.0',
185             args='--cflags --libs',
186             define_name='HAVE_OPUS_PKG')
188     samplerate = opt.add_auto_option(
189             'samplerate',
190             help='Build with libsamplerate')
191     samplerate.check_cfg(
192             package='samplerate',
193             args='--cflags --libs')
194     sndfile = opt.add_auto_option(
195             'sndfile',
196             help='Build with libsndfile')
197     sndfile.check_cfg(
198             package='sndfile',
199             args='--cflags --libs')
200     readline = opt.add_auto_option(
201             'readline',
202             help='Build with readline')
203     readline.check(lib='readline')
204     readline.check(
205             header_name=['stdio.h', 'readline/readline.h'],
206             msg='Checking for header readline/readline.h')
207     sd = opt.add_auto_option(
208             'systemd',
209             help='Use systemd notify')
210     sd.check(header_name='systemd/sd-daemon.h')
211     sd.check(lib='systemd')
212     db = opt.add_auto_option(
213             'db',
214             help='Use Berkeley DB (metadata)')
215     db.check(header_name='db.h')
216     db.check(lib='db')
217     zalsa = opt.add_auto_option(
218             'zalsa',
219             help='Build internal zita-a2j/j2a client')
220     zalsa.check(lib='zita-alsa-pcmi')
221     zalsa.check(lib='zita-resampler')
223     # dbus options
224     opt.recurse('dbus')
226     # this must be called before the configure phase
227     opt.apply_auto_options_hack()
230 def detect_platform(conf):
231     # GNU/kFreeBSD and GNU/Hurd are treated as Linux
232     platforms = [
233         # ('KEY, 'Human readable name', ['strings', 'to', 'check', 'for'])
234         ('IS_LINUX',   'Linux',   ['gnu0', 'gnukfreebsd', 'linux', 'posix']),
235         ('IS_FREEBSD', 'FreeBSD', ['freebsd']),
236         ('IS_MACOSX',  'MacOS X', ['darwin']),
237         ('IS_SUN',     'SunOS',   ['sunos']),
238         ('IS_WINDOWS', 'Windows', ['cygwin', 'msys', 'win32'])
239     ]
241     for key, name, strings in platforms:
242         conf.env[key] = False
244     conf.start_msg('Checking platform')
245     platform = Options.options.platform
246     for key, name, strings in platforms:
247         for s in strings:
248             if platform.startswith(s):
249                 conf.env[key] = True
250                 conf.end_msg(name, color='CYAN')
251                 break
254 def configure(conf):
255     conf.load('compiler_cxx')
256     conf.load('compiler_c')
258     detect_platform(conf)
260     if conf.env['IS_WINDOWS']:
261         conf.env.append_unique('CCDEFINES', '_POSIX')
262         conf.env.append_unique('CXXDEFINES', '_POSIX')
263         if Options.options.platform in ('msys', 'win32'):
264             conf.env.append_value('INCLUDES', ['/mingw64/include'])
265             conf.check(
266                 header_name='pa_asio.h',
267                 msg='Checking for PortAudio ASIO support',
268                 define_name='HAVE_ASIO',
269                 mandatory=False)
271     conf.env.append_unique('CFLAGS', '-Wall')
272     conf.env.append_unique('CXXFLAGS', ['-Wall', '-Wno-invalid-offsetof'])
273     conf.env.append_unique('CXXFLAGS', '-std=gnu++11')
275     if conf.env['IS_FREEBSD']:
276         conf.check(lib='execinfo', uselib='EXECINFO', define_name='EXECINFO')
277         conf.check_cfg(package='libsysinfo', args='--cflags --libs')
279     if not conf.env['IS_MACOSX']:
280         conf.env.append_unique('LDFLAGS', '-Wl,--no-undefined')
281     else:
282         conf.check(lib='aften', uselib='AFTEN', define_name='AFTEN')
283         conf.check_cxx(
284             fragment=''
285             + '#include <aften/aften.h>\n'
286             + 'int\n'
287             + 'main(void)\n'
288             + '{\n'
289             + 'AftenContext fAftenContext;\n'
290             + 'aften_set_defaults(&fAftenContext);\n'
291             + 'unsigned char *fb;\n'
292             + 'float *buf=new float[10];\n'
293             + 'int res = aften_encode_frame(&fAftenContext, fb, buf, 1);\n'
294             + '}\n',
295             lib='aften',
296             msg='Checking for aften_encode_frame()',
297             define_name='HAVE_AFTEN_NEW_API',
298             mandatory=False)
300         # TODO
301         conf.env.append_unique('CXXFLAGS', '-Wno-deprecated-register')
303     conf.load('autooptions')
305     conf.recurse('compat')
307     # Check for functions.
308     conf.check(
309             fragment=''
310             + '#define _GNU_SOURCE\n'
311             + '#include <poll.h>\n'
312             + '#include <signal.h>\n'
313             + '#include <stddef.h>\n'
314             + 'int\n'
315             + 'main(void)\n'
316             + '{\n'
317             + '   ppoll(NULL, 0, NULL, NULL);\n'
318             + '}\n',
319             msg='Checking for ppoll',
320             define_name='HAVE_PPOLL',
321             mandatory=False)
323     # Check for backtrace support
324     conf.check(
325         header_name='execinfo.h',
326         define_name='HAVE_EXECINFO_H',
327         mandatory=False)
329     conf.recurse('common')
330     if Options.options.dbus:
331         conf.recurse('dbus')
332         if not conf.env['BUILD_JACKDBUS']:
333             conf.fatal('jackdbus was explicitly requested but cannot be built')
334     if conf.env['IS_LINUX']:
335         if Options.options.systemd_unit:
336             conf.recurse('systemd')
337         else:
338             conf.env['SYSTEMD_USER_UNIT_DIR'] = None
340     if conf.env['BUILD_JACK_EXAMPLE_TOOLS']:
341         conf.recurse('example-clients')
342         conf.recurse('tools')
344     # test for the availability of ucontext, and how it should be used
345     for t in ['gp_regs', 'uc_regs', 'mc_gregs', 'gregs']:
346         fragment = '#include <ucontext.h>\n'
347         fragment += 'int main() { ucontext_t *ucontext; return (int) ucontext->uc_mcontext.%s[0]; }' % t
348         confvar = 'HAVE_UCONTEXT_%s' % t.upper()
349         conf.check_cc(fragment=fragment, define_name=confvar, mandatory=False,
350                       msg='Checking for ucontext->uc_mcontext.%s' % t)
351         if conf.is_defined(confvar):
352             conf.define('HAVE_UCONTEXT', 1)
354     fragment = '#include <ucontext.h>\n'
355     fragment += 'int main() { return NGREG; }'
356     conf.check_cc(fragment=fragment, define_name='HAVE_NGREG', mandatory=False,
357                   msg='Checking for NGREG')
359     conf.env['LIB_PTHREAD'] = ['pthread']
360     conf.env['LIB_DL'] = ['dl']
361     conf.env['LIB_RT'] = ['rt']
362     conf.env['LIB_M'] = ['m']
363     conf.env['LIB_STDC++'] = ['stdc++']
364     conf.env['JACK_API_VERSION'] = JACK_API_VERSION
365     conf.env['JACK_VERSION'] = VERSION
367     conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
368     conf.env['BUILD_WITH_32_64'] = Options.options.mixed
369     conf.env['BUILD_CLASSIC'] = Options.options.classic
370     conf.env['BUILD_DEBUG'] = Options.options.debug
371     conf.env['BUILD_STATIC'] = Options.options.static
373     if conf.env['BUILD_JACKDBUS']:
374         conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
375     else:
376         conf.env['BUILD_JACKD'] = True
378     conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin'
380     if Options.options.htmldir:
381         conf.env['HTMLDIR'] = Options.options.htmldir
382     else:
383         # set to None here so that the doxygen code can find out the highest
384         # directory to remove upon install
385         conf.env['HTMLDIR'] = None
387     if Options.options.libdir:
388         conf.env['LIBDIR'] = Options.options.libdir
389     else:
390         conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
392     if Options.options.pkgconfigdir:
393         conf.env['PKGCONFDIR'] = Options.options.pkgconfigdir
394     else:
395         conf.env['PKGCONFDIR'] = conf.env['LIBDIR'] + '/pkgconfig'
397     if Options.options.mandir:
398         conf.env['MANDIR'] = Options.options.mandir
399     else:
400         conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
402     if conf.env['BUILD_DEBUG']:
403         conf.env.append_unique('CXXFLAGS', '-g')
404         conf.env.append_unique('CFLAGS', '-g')
405         conf.env.append_unique('LINKFLAGS', '-g')
407     if Options.options.autostart not in ['default', 'classic', 'dbus', 'none']:
408         conf.fatal('Invalid autostart value "' + Options.options.autostart + '"')
410     if Options.options.autostart == 'default':
411         conf.env['AUTOSTART_METHOD'] = 'none'
412     else:
413         conf.env['AUTOSTART_METHOD'] = Options.options.autostart
415     if conf.env['AUTOSTART_METHOD'] == 'dbus' and not conf.env['BUILD_JACKDBUS']:
416         conf.fatal('D-Bus autostart mode was specified but jackdbus will not be built')
417     if conf.env['AUTOSTART_METHOD'] == 'classic' and not conf.env['BUILD_JACKD']:
418         conf.fatal('Classic autostart mode was specified but jackd will not be built')
420     if conf.env['AUTOSTART_METHOD'] == 'dbus':
421         conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
422     elif conf.env['AUTOSTART_METHOD'] == 'classic':
423         conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
425     conf.define('CLIENT_NUM', Options.options.clients)
426     conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
428     if conf.env['IS_WINDOWS']:
429         # we define this in the environment to maintain compatibility with
430         # existing install paths that use ADDON_DIR rather than have to
431         # have special cases for windows each time.
432         conf.env['ADDON_DIR'] = conf.env['LIBDIR'] + '/jack'
433         if Options.options.platform in ('msys', 'win32'):
434             conf.define('ADDON_DIR', 'jack')
435             conf.define('__STDC_FORMAT_MACROS', 1)  # for PRIu64
436         else:
437             # don't define ADDON_DIR in config.h, use the default 'jack'
438             # defined in windows/JackPlatformPlug_os.h
439             pass
440     else:
441         conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
442         conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
443         conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
445     if not conf.env['IS_WINDOWS']:
446         conf.define('USE_POSIX_SHM', 1)
447     conf.define('JACKMP', 1)
448     if conf.env['BUILD_JACKDBUS']:
449         conf.define('JACK_DBUS', 1)
450     if conf.env['BUILD_WITH_PROFILE']:
451         conf.define('JACK_MONITOR', 1)
452     conf.write_config_header('config.h', remove=False)
454     if Options.options.mixed:
455         conf.setenv(lib32, env=conf.env.derive())
456         conf.env.append_unique('CFLAGS', '-m32')
457         conf.env.append_unique('CXXFLAGS', '-m32')
458         conf.env.append_unique('CXXFLAGS', '-DBUILD_WITH_32_64')
459         conf.env.append_unique('LINKFLAGS', '-m32')
460         if Options.options.libdir32:
461             conf.env['LIBDIR'] = Options.options.libdir32
462         else:
463             conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
465         if conf.env['IS_WINDOWS'] and conf.env['BUILD_STATIC']:
466             def replaceFor32bit(env):
467                 for e in env:
468                     yield e.replace('x86_64', 'i686', 1)
469             for env in ('AR', 'CC', 'CXX', 'LINK_CC', 'LINK_CXX'):
470                 conf.all_envs[lib32][env] = list(replaceFor32bit(conf.all_envs[lib32][env]))
471             conf.all_envs[lib32]['LIB_REGEX'] = ['tre32']
473         # libdb does not work in mixed mode
474         conf.all_envs[lib32]['HAVE_DB'] = 0
475         conf.all_envs[lib32]['HAVE_DB_H'] = 0
476         conf.all_envs[lib32]['LIB_DB'] = []
477         # no need for opus in 32bit mixed mode clients
478         conf.all_envs[lib32]['LIB_OPUS'] = []
479         # someone tell me where this file gets written please..
480         conf.write_config_header('config.h')
482     print()
483     print('LADI JACK ' + VERSION)
485     conf.msg('Maximum JACK clients', Options.options.clients, color='NORMAL')
486     conf.msg('Maximum ports per application', Options.options.application_ports, color='NORMAL')
488     conf.msg('Install prefix', conf.env['PREFIX'], color='CYAN')
489     conf.msg('Library directory', conf.all_envs['']['LIBDIR'], color='CYAN')
490     if conf.env['BUILD_WITH_32_64']:
491         conf.msg('32-bit library directory', conf.all_envs[lib32]['LIBDIR'], color='CYAN')
492     conf.msg('Drivers directory', conf.env['ADDON_DIR'], color='CYAN')
493     display_feature(conf, 'Build debuggable binaries', conf.env['BUILD_DEBUG'])
495     tool_flags = [
496         ('C compiler flags',   ['CFLAGS', 'CPPFLAGS']),
497         ('C++ compiler flags', ['CXXFLAGS', 'CPPFLAGS']),
498         ('Linker flags',       ['LINKFLAGS', 'LDFLAGS'])
499     ]
500     for name, vars in tool_flags:
501         flags = []
502         for var in vars:
503             flags += conf.all_envs[''][var]
504         conf.msg(name, repr(flags), color='NORMAL')
506     if conf.env['BUILD_WITH_32_64']:
507         conf.msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
508         conf.msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
509         conf.msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
510     display_feature(conf, 'Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
511     display_feature(conf, 'Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
513     display_feature(conf, 'Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
514     display_feature(conf, 'Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
515     conf.msg('Autostart method', conf.env['AUTOSTART_METHOD'])
517     if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
518         print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
519         print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
521     conf.summarize_auto_options()
523     if conf.env['BUILD_JACKDBUS']:
524         conf.msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], color='CYAN')
526         if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
527             print()
528             print(Logs.colors.RED + 'WARNING: D-Bus session services directory as reported by pkg-config is')
529             print(Logs.colors.RED + 'WARNING:', end=' ')
530             print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
531             print(Logs.colors.RED + 'WARNING: but service file will be installed in')
532             print(Logs.colors.RED + 'WARNING:', end=' ')
533             print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
534             print(
535                 Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
536             )
537             print('WARNING: You can override dbus service install directory')
538             print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
539             print(Logs.colors.NORMAL, end=' ')
540     print()
543 def init(ctx):
544     for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
545         name = y.__name__.replace('Context', '').lower()
547         class tmp(y):
548             cmd = name + '_' + lib32
549             variant = lib32
552 def obj_add_includes(bld, obj):
553     if bld.env['BUILD_JACKDBUS']:
554         obj.includes += ['dbus']
556     if bld.env['IS_LINUX']:
557         obj.includes += ['linux', 'posix']
559     if bld.env['IS_FREEBSD']:
560         obj.includes += ['freebsd', 'posix']
562     if bld.env['IS_MACOSX']:
563         obj.includes += ['macosx', 'posix']
565     if bld.env['IS_SUN']:
566         obj.includes += ['posix', 'solaris']
568     if bld.env['IS_WINDOWS']:
569         obj.includes += ['windows']
572 # FIXME: Is SERVER_SIDE needed?
573 def build_jackd(bld):
574     jackd = bld(
575         features=['cxx', 'cxxprogram'],
576         defines=['HAVE_CONFIG_H', 'SERVER_SIDE'],
577         includes=['.', 'common', 'common/jack'],
578         target='jackd',
579         source=['common/Jackdmp.cpp'],
580         use=['serverlib', 'SYSTEMD']
581     )
583     if bld.env['BUILD_JACKDBUS']:
584         jackd.source += ['dbus/audio_reserve.c', 'dbus/reserve.c']
585         jackd.use += ['DBUS-1']
587     if bld.env['IS_LINUX']:
588         jackd.use += ['DL', 'M', 'PTHREAD', 'RT', 'STDC++']
590     if bld.env['IS_FREEBSD']:
591         jackd.use += ['M', 'PTHREAD']
593     if bld.env['IS_MACOSX']:
594         jackd.use += ['DL', 'PTHREAD']
595         jackd.framework = ['CoreFoundation']
597     if bld.env['IS_SUN']:
598         jackd.use += ['DL', 'PTHREAD']
600     obj_add_includes(bld, jackd)
602     return jackd
605 # FIXME: Is SERVER_SIDE needed?
606 def create_driver_obj(bld, **kw):
607     if 'use' in kw:
608         kw['use'] += ['serverlib']
609     else:
610         kw['use'] = ['serverlib']
612     driver = bld(
613         features=['c', 'cxx', 'cshlib', 'cxxshlib'],
614         defines=['HAVE_CONFIG_H', 'SERVER_SIDE'],
615         includes=['.', 'common', 'common/jack'],
616         install_path='${ADDON_DIR}/',
617         **kw)
619     if bld.env['IS_WINDOWS']:
620         driver.env['cxxshlib_PATTERN'] = 'jack_%s.dll'
621     else:
622         driver.env['cxxshlib_PATTERN'] = 'jack_%s.so'
624     obj_add_includes(bld, driver)
626     return driver
629 def build_drivers(bld):
630     # Non-hardware driver sources. Lexically sorted.
631     dummy_src = [
632         'common/JackDummyDriver.cpp'
633     ]
635     loopback_src = [
636         'common/JackLoopbackDriver.cpp'
637     ]
639     net_src = [
640         'common/JackNetDriver.cpp'
641     ]
643     netone_src = [
644         'common/JackNetOneDriver.cpp',
645         'common/netjack.c',
646         'common/netjack_packet.c'
647     ]
649     proxy_src = [
650         'common/JackProxyDriver.cpp'
651     ]
653     # Hardware driver sources. Lexically sorted.
654     alsa_src = [
655         'common/memops.c',
656         'linux/alsa/JackAlsaDriver.cpp',
657         'linux/alsa/alsa_rawmidi.c',
658         'linux/alsa/alsa_seqmidi.c',
659         'linux/alsa/alsa_midi_jackmp.cpp',
660         'linux/alsa/generic_hw.c',
661         'linux/alsa/hdsp.c',
662         'linux/alsa/alsa_driver.c',
663         'linux/alsa/hammerfall.c',
664         'linux/alsa/ice1712.c'
665     ]
667     alsarawmidi_src = [
668         'linux/alsarawmidi/JackALSARawMidiDriver.cpp',
669         'linux/alsarawmidi/JackALSARawMidiInputPort.cpp',
670         'linux/alsarawmidi/JackALSARawMidiOutputPort.cpp',
671         'linux/alsarawmidi/JackALSARawMidiPort.cpp',
672         'linux/alsarawmidi/JackALSARawMidiReceiveQueue.cpp',
673         'linux/alsarawmidi/JackALSARawMidiSendQueue.cpp',
674         'linux/alsarawmidi/JackALSARawMidiUtil.cpp'
675     ]
677     boomer_src = [
678         'common/memops.c',
679         'solaris/oss/JackBoomerDriver.cpp'
680     ]
682     coreaudio_src = [
683         'macosx/coreaudio/JackCoreAudioDriver.mm',
684         'common/JackAC3Encoder.cpp'
685     ]
687     coremidi_src = [
688         'macosx/coremidi/JackCoreMidiInputPort.mm',
689         'macosx/coremidi/JackCoreMidiOutputPort.mm',
690         'macosx/coremidi/JackCoreMidiPhysicalInputPort.mm',
691         'macosx/coremidi/JackCoreMidiPhysicalOutputPort.mm',
692         'macosx/coremidi/JackCoreMidiVirtualInputPort.mm',
693         'macosx/coremidi/JackCoreMidiVirtualOutputPort.mm',
694         'macosx/coremidi/JackCoreMidiPort.mm',
695         'macosx/coremidi/JackCoreMidiUtil.mm',
696         'macosx/coremidi/JackCoreMidiDriver.mm'
697     ]
699     ffado_src = [
700         'linux/firewire/JackFFADODriver.cpp',
701         'linux/firewire/JackFFADOMidiInputPort.cpp',
702         'linux/firewire/JackFFADOMidiOutputPort.cpp',
703         'linux/firewire/JackFFADOMidiReceiveQueue.cpp',
704         'linux/firewire/JackFFADOMidiSendQueue.cpp'
705     ]
707     freebsd_oss_src = [
708         'common/memops.c',
709         'freebsd/oss/JackOSSDriver.cpp'
710     ]
712     iio_driver_src = [
713         'linux/iio/JackIIODriver.cpp'
714     ]
716     oss_src = [
717         'common/memops.c',
718         'solaris/oss/JackOSSDriver.cpp'
719     ]
721     portaudio_src = [
722         'windows/portaudio/JackPortAudioDevices.cpp',
723         'windows/portaudio/JackPortAudioDriver.cpp',
724     ]
726     winmme_src = [
727         'windows/winmme/JackWinMMEDriver.cpp',
728         'windows/winmme/JackWinMMEInputPort.cpp',
729         'windows/winmme/JackWinMMEOutputPort.cpp',
730         'windows/winmme/JackWinMMEPort.cpp',
731     ]
733     # Create non-hardware driver objects. Lexically sorted.
734     create_driver_obj(
735         bld,
736         target='dummy',
737         source=dummy_src)
739     create_driver_obj(
740         bld,
741         target='loopback',
742         source=loopback_src)
744     create_driver_obj(
745         bld,
746         target='net',
747         source=net_src,
748         use=['CELT'])
750     create_driver_obj(
751         bld,
752         target='netone',
753         source=netone_src,
754         use=['SAMPLERATE', 'CELT'])
756     create_driver_obj(
757         bld,
758         target='proxy',
759         source=proxy_src)
761     # Create hardware driver objects. Lexically sorted after the conditional,
762     # e.g. BUILD_DRIVER_ALSA.
763     if bld.env['BUILD_DRIVER_ALSA']:
764         create_driver_obj(
765             bld,
766             target='alsa',
767             source=alsa_src,
768             use=['ALSA'])
769         create_driver_obj(
770             bld,
771             target='alsarawmidi',
772             source=alsarawmidi_src,
773             use=['ALSA'])
775     if bld.env['BUILD_DRIVER_FFADO']:
776         create_driver_obj(
777             bld,
778             target='firewire',
779             source=ffado_src,
780             use=['LIBFFADO'])
782     if bld.env['BUILD_DRIVER_IIO']:
783         create_driver_obj(
784             bld,
785             target='iio',
786             source=iio_driver_src,
787             use=['GTKIOSTREAM', 'EIGEN3'])
789     if bld.env['BUILD_DRIVER_PORTAUDIO']:
790         create_driver_obj(
791             bld,
792             target='portaudio',
793             source=portaudio_src,
794             use=['PORTAUDIO'])
796     if bld.env['BUILD_DRIVER_WINMME']:
797         create_driver_obj(
798             bld,
799             target='winmme',
800             source=winmme_src,
801             use=['WINMME'])
803     if bld.env['IS_MACOSX']:
804         create_driver_obj(
805             bld,
806             target='coreaudio',
807             source=coreaudio_src,
808             use=['AFTEN'],
809             framework=['AudioUnit', 'CoreAudio', 'CoreServices'])
811         create_driver_obj(
812             bld,
813             target='coremidi',
814             source=coremidi_src,
815             use=['serverlib'],  # FIXME: Is this needed?
816             framework=['AudioUnit', 'CoreMIDI', 'CoreServices', 'Foundation'])
818     if bld.env['IS_FREEBSD']:
819         create_driver_obj(
820             bld,
821             target='oss',
822             source=freebsd_oss_src)
824     if bld.env['IS_SUN']:
825         create_driver_obj(
826             bld,
827             target='boomer',
828             source=boomer_src)
829         create_driver_obj(
830             bld,
831             target='oss',
832             source=oss_src)
835 def build(bld):
836     if not bld.variant and bld.env['BUILD_WITH_32_64']:
837         Options.commands.append(bld.cmd + '_' + lib32)
839     # process subfolders from here
840     bld.recurse('common')
842     if bld.variant:
843         # only the wscript in common/ knows how to handle variants
844         return
846     bld.recurse('compat')
848     if bld.env['BUILD_JACKD']:
849         build_jackd(bld)
851     build_drivers(bld)
853     if bld.env['BUILD_JACK_EXAMPLE_TOOLS']:
854         bld.recurse('example-clients')
855         bld.recurse('tools')
857     if bld.env['IS_LINUX'] or bld.env['IS_FREEBSD']:
858         bld.recurse('man')
859         bld.recurse('systemd')
860     if not bld.env['IS_WINDOWS'] and bld.env['BUILD_JACK_EXAMPLE_TOOLS']:
861         bld.recurse('tests')
862     if bld.env['BUILD_JACKDBUS']:
863         bld.recurse('dbus')
865     if bld.env['BUILD_DOXYGEN_DOCS']:
866         html_build_dir = bld.path.find_or_declare('html').abspath()
868         bld(
869             features='subst',
870             source='doxyfile.in',
871             target='doxyfile',
872             HTML_BUILD_DIR=html_build_dir,
873             SRCDIR=bld.srcnode.abspath(),
874             VERSION=VERSION
875         )
877         # There are two reasons for logging to doxygen.log and using it as
878         # target in the build rule (rather than html_build_dir):
879         # (1) reduce the noise when running the build
880         # (2) waf has a regular file to check for a timestamp. If the directory
881         #     is used instead waf will rebuild the doxygen target (even upon
882         #     install).
883         def doxygen(task):
884             doxyfile = task.inputs[0].abspath()
885             logfile = task.outputs[0].abspath()
886             cmd = '%s %s &> %s' % (task.env['DOXYGEN'][0], doxyfile, logfile)
887             return task.exec_command(cmd)
889         bld(
890             rule=doxygen,
891             source='doxyfile',
892             target='doxygen.log'
893         )
895         # Determine where to install HTML documentation. Since share_dir is the
896         # highest directory the uninstall routine should remove, there is no
897         # better candidate for share_dir, but the requested HTML directory if
898         # --htmldir is given.
899         if bld.env['HTMLDIR']:
900             html_install_dir = bld.options.destdir + bld.env['HTMLDIR']
901             share_dir = html_install_dir
902         else:
903             share_dir = bld.options.destdir + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
904             html_install_dir = share_dir + '/reference/html/'
906         if bld.cmd == 'install':
907             if os.path.isdir(html_install_dir):
908                 Logs.pprint('CYAN', 'Removing old doxygen documentation installation...')
909                 shutil.rmtree(html_install_dir)
910                 Logs.pprint('CYAN', 'Removing old doxygen documentation installation done.')
911             Logs.pprint('CYAN', 'Installing doxygen documentation...')
912             shutil.copytree(html_build_dir, html_install_dir)
913             Logs.pprint('CYAN', 'Installing doxygen documentation done.')
914         elif bld.cmd == 'uninstall':
915             Logs.pprint('CYAN', 'Uninstalling doxygen documentation...')
916             if os.path.isdir(share_dir):
917                 shutil.rmtree(share_dir)
918             Logs.pprint('CYAN', 'Uninstalling doxygen documentation done.')
919         elif bld.cmd == 'clean':
920             if os.access(html_build_dir, os.R_OK):
921                 Logs.pprint('CYAN', 'Removing doxygen generated documentation...')
922                 shutil.rmtree(html_build_dir)
923                 Logs.pprint('CYAN', 'Removing doxygen generated documentation done.')
926 @TaskGen.extension('.mm')
927 def mm_hook(self, node):
928     """Alias .mm files to be compiled the same as .cpp files, gcc will do the right thing."""
929     return self.create_compiled_task('cxx', node)