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