Update changelog
[jack2.git] / wscript
blob2701f9abb23b9dc45748f3f4afa68f8b41e6237b
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 = '1.9.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=False, help='Enable D-Bus JACK (jackdbus)')
99     opt.add_option(
100         '--autostart',
101         type='string',
102         default='default',
103         help='Autostart method. Possible values: "default", "classic", "dbus", "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         if conf.env['BUILD_JACKD']:
412             conf.env['AUTOSTART_METHOD'] = 'classic'
413         else:
414             conf.env['AUTOSTART_METHOD'] = 'dbus'
415     else:
416         conf.env['AUTOSTART_METHOD'] = Options.options.autostart
418     if conf.env['AUTOSTART_METHOD'] == 'dbus' and not conf.env['BUILD_JACKDBUS']:
419         conf.fatal('D-Bus autostart mode was specified but jackdbus will not be built')
420     if conf.env['AUTOSTART_METHOD'] == 'classic' and not conf.env['BUILD_JACKD']:
421         conf.fatal('Classic autostart mode was specified but jackd will not be built')
423     if conf.env['AUTOSTART_METHOD'] == 'dbus':
424         conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
425     elif conf.env['AUTOSTART_METHOD'] == 'classic':
426         conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
428     conf.define('CLIENT_NUM', Options.options.clients)
429     conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
431     if conf.env['IS_WINDOWS']:
432         # we define this in the environment to maintain compatibility with
433         # existing install paths that use ADDON_DIR rather than have to
434         # have special cases for windows each time.
435         conf.env['ADDON_DIR'] = conf.env['LIBDIR'] + '/jack'
436         if Options.options.platform in ('msys', 'win32'):
437             conf.define('ADDON_DIR', 'jack')
438             conf.define('__STDC_FORMAT_MACROS', 1)  # for PRIu64
439         else:
440             # don't define ADDON_DIR in config.h, use the default 'jack'
441             # defined in windows/JackPlatformPlug_os.h
442             pass
443     else:
444         conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
445         conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
446         conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
448     if not conf.env['IS_WINDOWS']:
449         conf.define('USE_POSIX_SHM', 1)
450     conf.define('JACKMP', 1)
451     if conf.env['BUILD_JACKDBUS']:
452         conf.define('JACK_DBUS', 1)
453     if conf.env['BUILD_WITH_PROFILE']:
454         conf.define('JACK_MONITOR', 1)
455     conf.write_config_header('config.h', remove=False)
457     if Options.options.mixed:
458         conf.setenv(lib32, env=conf.env.derive())
459         conf.env.append_unique('CFLAGS', '-m32')
460         conf.env.append_unique('CXXFLAGS', '-m32')
461         conf.env.append_unique('CXXFLAGS', '-DBUILD_WITH_32_64')
462         conf.env.append_unique('LINKFLAGS', '-m32')
463         if Options.options.libdir32:
464             conf.env['LIBDIR'] = Options.options.libdir32
465         else:
466             conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
468         if conf.env['IS_WINDOWS'] and conf.env['BUILD_STATIC']:
469             def replaceFor32bit(env):
470                 for e in env:
471                     yield e.replace('x86_64', 'i686', 1)
472             for env in ('AR', 'CC', 'CXX', 'LINK_CC', 'LINK_CXX'):
473                 conf.all_envs[lib32][env] = list(replaceFor32bit(conf.all_envs[lib32][env]))
474             conf.all_envs[lib32]['LIB_REGEX'] = ['tre32']
476         # libdb does not work in mixed mode
477         conf.all_envs[lib32]['HAVE_DB'] = 0
478         conf.all_envs[lib32]['HAVE_DB_H'] = 0
479         conf.all_envs[lib32]['LIB_DB'] = []
480         # no need for opus in 32bit mixed mode clients
481         conf.all_envs[lib32]['LIB_OPUS'] = []
482         # someone tell me where this file gets written please..
483         conf.write_config_header('config.h')
485     print()
486     print('JACK ' + VERSION)
488     conf.msg('Maximum JACK clients', Options.options.clients, color='NORMAL')
489     conf.msg('Maximum ports per application', Options.options.application_ports, color='NORMAL')
491     conf.msg('Install prefix', conf.env['PREFIX'], color='CYAN')
492     conf.msg('Library directory', conf.all_envs['']['LIBDIR'], color='CYAN')
493     if conf.env['BUILD_WITH_32_64']:
494         conf.msg('32-bit library directory', conf.all_envs[lib32]['LIBDIR'], color='CYAN')
495     conf.msg('Drivers directory', conf.env['ADDON_DIR'], color='CYAN')
496     display_feature(conf, 'Build debuggable binaries', conf.env['BUILD_DEBUG'])
498     tool_flags = [
499         ('C compiler flags',   ['CFLAGS', 'CPPFLAGS']),
500         ('C++ compiler flags', ['CXXFLAGS', 'CPPFLAGS']),
501         ('Linker flags',       ['LINKFLAGS', 'LDFLAGS'])
502     ]
503     for name, vars in tool_flags:
504         flags = []
505         for var in vars:
506             flags += conf.all_envs[''][var]
507         conf.msg(name, repr(flags), color='NORMAL')
509     if conf.env['BUILD_WITH_32_64']:
510         conf.msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
511         conf.msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
512         conf.msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
513     display_feature(conf, 'Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
514     display_feature(conf, 'Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
516     display_feature(conf, 'Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
517     display_feature(conf, 'Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
518     conf.msg('Autostart method', conf.env['AUTOSTART_METHOD'])
520     if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
521         print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
522         print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
524     conf.summarize_auto_options()
526     if conf.env['BUILD_JACKDBUS']:
527         conf.msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], color='CYAN')
529         if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
530             print()
531             print(Logs.colors.RED + 'WARNING: D-Bus session services directory as reported by pkg-config is')
532             print(Logs.colors.RED + 'WARNING:', end=' ')
533             print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
534             print(Logs.colors.RED + 'WARNING: but service file will be installed in')
535             print(Logs.colors.RED + 'WARNING:', end=' ')
536             print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
537             print(
538                 Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
539             )
540             print('WARNING: You can override dbus service install directory')
541             print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
542             print(Logs.colors.NORMAL, end=' ')
543     print()
546 def init(ctx):
547     for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
548         name = y.__name__.replace('Context', '').lower()
550         class tmp(y):
551             cmd = name + '_' + lib32
552             variant = lib32
555 def obj_add_includes(bld, obj):
556     if bld.env['BUILD_JACKDBUS']:
557         obj.includes += ['dbus']
559     if bld.env['IS_LINUX']:
560         obj.includes += ['linux', 'posix']
562     if bld.env['IS_FREEBSD']:
563         obj.includes += ['freebsd', 'posix']
565     if bld.env['IS_MACOSX']:
566         obj.includes += ['macosx', 'posix']
568     if bld.env['IS_SUN']:
569         obj.includes += ['posix', 'solaris']
571     if bld.env['IS_WINDOWS']:
572         obj.includes += ['windows']
575 # FIXME: Is SERVER_SIDE needed?
576 def build_jackd(bld):
577     jackd = bld(
578         features=['cxx', 'cxxprogram'],
579         defines=['HAVE_CONFIG_H', 'SERVER_SIDE'],
580         includes=['.', 'common', 'common/jack'],
581         target='jackd',
582         source=['common/Jackdmp.cpp'],
583         use=['serverlib', 'SYSTEMD']
584     )
586     if bld.env['BUILD_JACKDBUS']:
587         jackd.source += ['dbus/audio_reserve.c', 'dbus/reserve.c']
588         jackd.use += ['DBUS-1']
590     if bld.env['IS_LINUX']:
591         jackd.use += ['DL', 'M', 'PTHREAD', 'RT', 'STDC++']
593     if bld.env['IS_FREEBSD']:
594         jackd.use += ['M', 'PTHREAD']
596     if bld.env['IS_MACOSX']:
597         jackd.use += ['DL', 'PTHREAD']
598         jackd.framework = ['CoreFoundation']
600     if bld.env['IS_SUN']:
601         jackd.use += ['DL', 'PTHREAD']
603     obj_add_includes(bld, jackd)
605     return jackd
608 # FIXME: Is SERVER_SIDE needed?
609 def create_driver_obj(bld, **kw):
610     if 'use' in kw:
611         kw['use'] += ['serverlib']
612     else:
613         kw['use'] = ['serverlib']
615     driver = bld(
616         features=['c', 'cxx', 'cshlib', 'cxxshlib'],
617         defines=['HAVE_CONFIG_H', 'SERVER_SIDE'],
618         includes=['.', 'common', 'common/jack'],
619         install_path='${ADDON_DIR}/',
620         **kw)
622     if bld.env['IS_WINDOWS']:
623         driver.env['cxxshlib_PATTERN'] = 'jack_%s.dll'
624     else:
625         driver.env['cxxshlib_PATTERN'] = 'jack_%s.so'
627     obj_add_includes(bld, driver)
629     return driver
632 def build_drivers(bld):
633     # Non-hardware driver sources. Lexically sorted.
634     dummy_src = [
635         'common/JackDummyDriver.cpp'
636     ]
638     loopback_src = [
639         'common/JackLoopbackDriver.cpp'
640     ]
642     net_src = [
643         'common/JackNetDriver.cpp'
644     ]
646     netone_src = [
647         'common/JackNetOneDriver.cpp',
648         'common/netjack.c',
649         'common/netjack_packet.c'
650     ]
652     proxy_src = [
653         'common/JackProxyDriver.cpp'
654     ]
656     # Hardware driver sources. Lexically sorted.
657     alsa_src = [
658         'common/memops.c',
659         'linux/alsa/JackAlsaDriver.cpp',
660         'linux/alsa/alsa_rawmidi.c',
661         'linux/alsa/alsa_seqmidi.c',
662         'linux/alsa/alsa_midi_jackmp.cpp',
663         'linux/alsa/generic_hw.c',
664         'linux/alsa/hdsp.c',
665         'linux/alsa/alsa_driver.c',
666         'linux/alsa/hammerfall.c',
667         'linux/alsa/ice1712.c'
668     ]
670     alsarawmidi_src = [
671         'linux/alsarawmidi/JackALSARawMidiDriver.cpp',
672         'linux/alsarawmidi/JackALSARawMidiInputPort.cpp',
673         'linux/alsarawmidi/JackALSARawMidiOutputPort.cpp',
674         'linux/alsarawmidi/JackALSARawMidiPort.cpp',
675         'linux/alsarawmidi/JackALSARawMidiReceiveQueue.cpp',
676         'linux/alsarawmidi/JackALSARawMidiSendQueue.cpp',
677         'linux/alsarawmidi/JackALSARawMidiUtil.cpp'
678     ]
680     boomer_src = [
681         'common/memops.c',
682         'solaris/oss/JackBoomerDriver.cpp'
683     ]
685     coreaudio_src = [
686         'macosx/coreaudio/JackCoreAudioDriver.mm',
687         'common/JackAC3Encoder.cpp'
688     ]
690     coremidi_src = [
691         'macosx/coremidi/JackCoreMidiInputPort.mm',
692         'macosx/coremidi/JackCoreMidiOutputPort.mm',
693         'macosx/coremidi/JackCoreMidiPhysicalInputPort.mm',
694         'macosx/coremidi/JackCoreMidiPhysicalOutputPort.mm',
695         'macosx/coremidi/JackCoreMidiVirtualInputPort.mm',
696         'macosx/coremidi/JackCoreMidiVirtualOutputPort.mm',
697         'macosx/coremidi/JackCoreMidiPort.mm',
698         'macosx/coremidi/JackCoreMidiUtil.mm',
699         'macosx/coremidi/JackCoreMidiDriver.mm'
700     ]
702     ffado_src = [
703         'linux/firewire/JackFFADODriver.cpp',
704         'linux/firewire/JackFFADOMidiInputPort.cpp',
705         'linux/firewire/JackFFADOMidiOutputPort.cpp',
706         'linux/firewire/JackFFADOMidiReceiveQueue.cpp',
707         'linux/firewire/JackFFADOMidiSendQueue.cpp'
708     ]
710     freebsd_oss_src = [
711         'common/memops.c',
712         'freebsd/oss/JackOSSDriver.cpp'
713     ]
715     iio_driver_src = [
716         'linux/iio/JackIIODriver.cpp'
717     ]
719     oss_src = [
720         'common/memops.c',
721         'solaris/oss/JackOSSDriver.cpp'
722     ]
724     portaudio_src = [
725         'windows/portaudio/JackPortAudioDevices.cpp',
726         'windows/portaudio/JackPortAudioDriver.cpp',
727     ]
729     winmme_src = [
730         'windows/winmme/JackWinMMEDriver.cpp',
731         'windows/winmme/JackWinMMEInputPort.cpp',
732         'windows/winmme/JackWinMMEOutputPort.cpp',
733         'windows/winmme/JackWinMMEPort.cpp',
734     ]
736     # Create non-hardware driver objects. Lexically sorted.
737     create_driver_obj(
738         bld,
739         target='dummy',
740         source=dummy_src)
742     create_driver_obj(
743         bld,
744         target='loopback',
745         source=loopback_src)
747     create_driver_obj(
748         bld,
749         target='net',
750         source=net_src,
751         use=['CELT'])
753     create_driver_obj(
754         bld,
755         target='netone',
756         source=netone_src,
757         use=['SAMPLERATE', 'CELT'])
759     create_driver_obj(
760         bld,
761         target='proxy',
762         source=proxy_src)
764     # Create hardware driver objects. Lexically sorted after the conditional,
765     # e.g. BUILD_DRIVER_ALSA.
766     if bld.env['BUILD_DRIVER_ALSA']:
767         create_driver_obj(
768             bld,
769             target='alsa',
770             source=alsa_src,
771             use=['ALSA'])
772         create_driver_obj(
773             bld,
774             target='alsarawmidi',
775             source=alsarawmidi_src,
776             use=['ALSA'])
778     if bld.env['BUILD_DRIVER_FFADO']:
779         create_driver_obj(
780             bld,
781             target='firewire',
782             source=ffado_src,
783             use=['LIBFFADO'])
785     if bld.env['BUILD_DRIVER_IIO']:
786         create_driver_obj(
787             bld,
788             target='iio',
789             source=iio_driver_src,
790             use=['GTKIOSTREAM', 'EIGEN3'])
792     if bld.env['BUILD_DRIVER_PORTAUDIO']:
793         create_driver_obj(
794             bld,
795             target='portaudio',
796             source=portaudio_src,
797             use=['PORTAUDIO'])
799     if bld.env['BUILD_DRIVER_WINMME']:
800         create_driver_obj(
801             bld,
802             target='winmme',
803             source=winmme_src,
804             use=['WINMME'])
806     if bld.env['IS_MACOSX']:
807         create_driver_obj(
808             bld,
809             target='coreaudio',
810             source=coreaudio_src,
811             use=['AFTEN'],
812             framework=['AudioUnit', 'CoreAudio', 'CoreServices'])
814         create_driver_obj(
815             bld,
816             target='coremidi',
817             source=coremidi_src,
818             use=['serverlib'],  # FIXME: Is this needed?
819             framework=['AudioUnit', 'CoreMIDI', 'CoreServices', 'Foundation'])
821     if bld.env['IS_FREEBSD']:
822         create_driver_obj(
823             bld,
824             target='oss',
825             source=freebsd_oss_src)
827     if bld.env['IS_SUN']:
828         create_driver_obj(
829             bld,
830             target='boomer',
831             source=boomer_src)
832         create_driver_obj(
833             bld,
834             target='oss',
835             source=oss_src)
838 def build(bld):
839     if not bld.variant and bld.env['BUILD_WITH_32_64']:
840         Options.commands.append(bld.cmd + '_' + lib32)
842     # process subfolders from here
843     bld.recurse('common')
845     if bld.variant:
846         # only the wscript in common/ knows how to handle variants
847         return
849     bld.recurse('compat')
851     if bld.env['BUILD_JACKD']:
852         build_jackd(bld)
854     build_drivers(bld)
856     if bld.env['BUILD_JACK_EXAMPLE_TOOLS']:
857         bld.recurse('example-clients')
858         bld.recurse('tools')
860     if bld.env['IS_LINUX'] or bld.env['IS_FREEBSD']:
861         bld.recurse('man')
862         bld.recurse('systemd')
863     if not bld.env['IS_WINDOWS'] and bld.env['BUILD_JACK_EXAMPLE_TOOLS']:
864         bld.recurse('tests')
865     if bld.env['BUILD_JACKDBUS']:
866         bld.recurse('dbus')
868     if bld.env['BUILD_DOXYGEN_DOCS']:
869         html_build_dir = bld.path.find_or_declare('html').abspath()
871         bld(
872             features='subst',
873             source='doxyfile.in',
874             target='doxyfile',
875             HTML_BUILD_DIR=html_build_dir,
876             SRCDIR=bld.srcnode.abspath(),
877             VERSION=VERSION
878         )
880         # There are two reasons for logging to doxygen.log and using it as
881         # target in the build rule (rather than html_build_dir):
882         # (1) reduce the noise when running the build
883         # (2) waf has a regular file to check for a timestamp. If the directory
884         #     is used instead waf will rebuild the doxygen target (even upon
885         #     install).
886         def doxygen(task):
887             doxyfile = task.inputs[0].abspath()
888             logfile = task.outputs[0].abspath()
889             cmd = '%s %s &> %s' % (task.env['DOXYGEN'][0], doxyfile, logfile)
890             return task.exec_command(cmd)
892         bld(
893             rule=doxygen,
894             source='doxyfile',
895             target='doxygen.log'
896         )
898         # Determine where to install HTML documentation. Since share_dir is the
899         # highest directory the uninstall routine should remove, there is no
900         # better candidate for share_dir, but the requested HTML directory if
901         # --htmldir is given.
902         if bld.env['HTMLDIR']:
903             html_install_dir = bld.options.destdir + bld.env['HTMLDIR']
904             share_dir = html_install_dir
905         else:
906             share_dir = bld.options.destdir + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
907             html_install_dir = share_dir + '/reference/html/'
909         if bld.cmd == 'install':
910             if os.path.isdir(html_install_dir):
911                 Logs.pprint('CYAN', 'Removing old doxygen documentation installation...')
912                 shutil.rmtree(html_install_dir)
913                 Logs.pprint('CYAN', 'Removing old doxygen documentation installation done.')
914             Logs.pprint('CYAN', 'Installing doxygen documentation...')
915             shutil.copytree(html_build_dir, html_install_dir)
916             Logs.pprint('CYAN', 'Installing doxygen documentation done.')
917         elif bld.cmd == 'uninstall':
918             Logs.pprint('CYAN', 'Uninstalling doxygen documentation...')
919             if os.path.isdir(share_dir):
920                 shutil.rmtree(share_dir)
921             Logs.pprint('CYAN', 'Uninstalling doxygen documentation done.')
922         elif bld.cmd == 'clean':
923             if os.access(html_build_dir, os.R_OK):
924                 Logs.pprint('CYAN', 'Removing doxygen generated documentation...')
925                 shutil.rmtree(html_build_dir)
926                 Logs.pprint('CYAN', 'Removing doxygen generated documentation done.')
929 @TaskGen.extension('.mm')
930 def mm_hook(self, node):
931     """Alias .mm files to be compiled the same as .cpp files, gcc will do the right thing."""
932     return self.create_compiled_task('cxx', node)