Merge tag 'v1.9.22' into LADI/main
[jack2.git] / wscript
blobc5d2ee24cd4c368a70b5b486ccf6c04c6859e591
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.22'
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             'tests',
195             help='Build tests',
196             conf_dest='BUILD_TESTS',
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     sd = opt.add_auto_option(
217             'systemd',
218             help='Use systemd notify')
219     sd.check(header_name='systemd/sd-daemon.h')
220     sd.check(lib='systemd')
221     db = opt.add_auto_option(
222             'db',
223             help='Use Berkeley DB (metadata)')
224     db.check(header_name='db.h')
225     db.check(lib='db')
227     # this must be called before the configure phase
228     opt.apply_auto_options_hack()
231 def detect_platform(conf):
232     # GNU/kFreeBSD and GNU/Hurd are treated as Linux
233     platforms = [
234         # ('KEY, 'Human readable name', ['strings', 'to', 'check', 'for'])
235         ('IS_LINUX',   'Linux',   ['gnu0', 'gnukfreebsd', 'linux', 'posix']),
236         ('IS_FREEBSD', 'FreeBSD', ['freebsd']),
237         ('IS_MACOSX',  'MacOS X', ['darwin']),
238         ('IS_SUN',     'SunOS',   ['sunos']),
239         ('IS_WINDOWS', 'Windows', ['cygwin', 'msys', 'win32'])
240     ]
242     for key, name, strings in platforms:
243         conf.env[key] = False
245     conf.start_msg('Checking platform')
246     platform = Options.options.platform
247     for key, name, strings in platforms:
248         for s in strings:
249             if platform.startswith(s):
250                 conf.env[key] = True
251                 conf.end_msg(name, color='CYAN')
252                 break
255 def configure(conf):
256     conf.load('compiler_cxx')
257     conf.load('compiler_c')
259     detect_platform(conf)
261     if conf.env['IS_WINDOWS']:
262         conf.env.append_unique('CCDEFINES', '_POSIX')
263         conf.env.append_unique('CXXDEFINES', '_POSIX')
264         if Options.options.platform in ('msys', 'win32'):
265             conf.env.append_value('INCLUDES', ['/mingw64/include'])
266             conf.check(
267                 header_name='pa_asio.h',
268                 msg='Checking for PortAudio ASIO support',
269                 define_name='HAVE_ASIO',
270                 mandatory=False)
272     conf.env.append_unique('CFLAGS', '-Wall')
273     conf.env.append_unique('CXXFLAGS', ['-Wall', '-Wno-invalid-offsetof'])
274     conf.env.append_unique('CXXFLAGS', '-std=gnu++11')
276     if conf.env['IS_FREEBSD']:
277         conf.check(lib='execinfo', uselib='EXECINFO', define_name='EXECINFO')
278         conf.check_cfg(package='libsysinfo', args='--cflags --libs')
280     if not conf.env['IS_MACOSX']:
281         conf.env.append_unique('LDFLAGS', '-Wl,--no-undefined')
282     else:
283         conf.check(lib='aften', uselib='AFTEN', define_name='AFTEN')
284         conf.check_cxx(
285             fragment=''
286             + '#include <aften/aften.h>\n'
287             + 'int\n'
288             + 'main(void)\n'
289             + '{\n'
290             + 'AftenContext fAftenContext;\n'
291             + 'aften_set_defaults(&fAftenContext);\n'
292             + 'unsigned char *fb;\n'
293             + 'float *buf=new float[10];\n'
294             + 'int res = aften_encode_frame(&fAftenContext, fb, buf, 1);\n'
295             + '}\n',
296             lib='aften',
297             msg='Checking for aften_encode_frame()',
298             define_name='HAVE_AFTEN_NEW_API',
299             mandatory=False)
301         # TODO
302         conf.env.append_unique('CXXFLAGS', '-Wno-deprecated-register')
304     conf.load('autooptions')
306     conf.recurse('compat')
308     # Check for functions.
309     conf.check(
310             fragment=''
311             + '#define _GNU_SOURCE\n'
312             + '#include <poll.h>\n'
313             + '#include <signal.h>\n'
314             + '#include <stddef.h>\n'
315             + 'int\n'
316             + 'main(void)\n'
317             + '{\n'
318             + '   ppoll(NULL, 0, NULL, NULL);\n'
319             + '}\n',
320             msg='Checking for ppoll',
321             define_name='HAVE_PPOLL',
322             mandatory=False)
324     # Check for backtrace support
325     conf.check(
326         header_name='execinfo.h',
327         define_name='HAVE_EXECINFO_H',
328         mandatory=False)
330     conf.recurse('common')
331     if conf.env['IS_LINUX']:
332         if Options.options.systemd_unit:
333             conf.recurse('systemd')
334         else:
335             conf.env['SYSTEMD_USER_UNIT_DIR'] = None
337     # test for the availability of ucontext, and how it should be used
338     for t in ['gp_regs', 'uc_regs', 'mc_gregs', 'gregs']:
339         fragment = '#include <ucontext.h>\n'
340         fragment += 'int main() { ucontext_t *ucontext; return (int) ucontext->uc_mcontext.%s[0]; }' % t
341         confvar = 'HAVE_UCONTEXT_%s' % t.upper()
342         conf.check_cc(fragment=fragment, define_name=confvar, mandatory=False,
343                       msg='Checking for ucontext->uc_mcontext.%s' % t)
344         if conf.is_defined(confvar):
345             conf.define('HAVE_UCONTEXT', 1)
347     fragment = '#include <ucontext.h>\n'
348     fragment += 'int main() { return NGREG; }'
349     conf.check_cc(fragment=fragment, define_name='HAVE_NGREG', mandatory=False,
350                   msg='Checking for NGREG')
352     conf.env['LIB_PTHREAD'] = ['pthread']
353     conf.env['LIB_DL'] = ['dl']
354     conf.env['LIB_RT'] = ['rt']
355     conf.env['LIB_M'] = ['m']
356     conf.env['LIB_STDC++'] = ['stdc++']
357     conf.env['JACK_API_VERSION'] = JACK_API_VERSION
358     conf.env['JACK_VERSION'] = VERSION
360     conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
361     conf.env['BUILD_WITH_32_64'] = Options.options.mixed
362     conf.env['BUILD_CLASSIC'] = Options.options.classic
363     conf.env['BUILD_DEBUG'] = Options.options.debug
364     conf.env['BUILD_STATIC'] = Options.options.static
366     conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
368     if conf.env['BUILD_JACKD'] and conf.env['BUILD_DBUS_RESERVATION']:
369         if not conf.check_cfg(package='dbus-1 >= 1.0.0', args='--cflags --libs', mandatory=False):
370             print(Logs.colors.RED + 'ERROR !! jackd cannot be built with D-Bus device reservation feature because libdbus-dev is missing' + Logs.colors.NORMAL)
371             return
373     conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin'
375     if Options.options.htmldir:
376         conf.env['HTMLDIR'] = Options.options.htmldir
377     else:
378         # set to None here so that the doxygen code can find out the highest
379         # directory to remove upon install
380         conf.env['HTMLDIR'] = None
382     if Options.options.libdir:
383         conf.env['LIBDIR'] = Options.options.libdir
384     else:
385         conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
387     if Options.options.pkgconfigdir:
388         conf.env['PKGCONFDIR'] = Options.options.pkgconfigdir
389     else:
390         conf.env['PKGCONFDIR'] = conf.env['LIBDIR'] + '/pkgconfig'
392     if Options.options.mandir:
393         conf.env['MANDIR'] = Options.options.mandir
394     else:
395         conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
397     if conf.env['BUILD_DEBUG']:
398         conf.env.append_unique('CXXFLAGS', '-g')
399         conf.env.append_unique('CFLAGS', '-g')
400         conf.env.append_unique('LINKFLAGS', '-g')
402     if Options.options.autostart not in ['default', 'classic', 'dbus', 'none']:
403         conf.fatal('Invalid autostart value "' + Options.options.autostart + '"')
405     if Options.options.autostart == 'default':
406         conf.env['AUTOSTART_METHOD'] = 'none'
407     else:
408         conf.env['AUTOSTART_METHOD'] = Options.options.autostart
410     if conf.env['AUTOSTART_METHOD'] == 'dbus' and not conf.env['BUILD_JACKDBUS']:
411         conf.fatal('D-Bus autostart mode was specified but jackdbus will not be built')
412     if conf.env['AUTOSTART_METHOD'] == 'classic' and not conf.env['BUILD_JACKD']:
413         conf.fatal('Classic autostart mode was specified but jackd will not be built')
415     if conf.env['AUTOSTART_METHOD'] == 'dbus':
416         conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
417     elif conf.env['AUTOSTART_METHOD'] == 'classic':
418         conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
420     conf.define('CLIENT_NUM', Options.options.clients)
421     conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
423     if conf.env['IS_WINDOWS']:
424         # we define this in the environment to maintain compatibility with
425         # existing install paths that use ADDON_DIR rather than have to
426         # have special cases for windows each time.
427         conf.env['ADDON_DIR'] = conf.env['LIBDIR'] + '/jack'
428         if Options.options.platform in ('msys', 'win32'):
429             conf.define('ADDON_DIR', 'jack')
430             conf.define('__STDC_FORMAT_MACROS', 1)  # for PRIu64
431         else:
432             # don't define ADDON_DIR in config.h, use the default 'jack'
433             # defined in windows/JackPlatformPlug_os.h
434             pass
435     else:
436         conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
437         conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
438         conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
440     if not conf.env['IS_WINDOWS']:
441         conf.define('USE_POSIX_SHM', 1)
442     conf.define('JACKMP', 1)
443     if conf.env['BUILD_WITH_PROFILE']:
444         conf.define('JACK_MONITOR', 1)
445     conf.write_config_header('config.h', remove=False)
447     if Options.options.mixed:
448         conf.setenv(lib32, env=conf.env.derive())
449         conf.env.append_unique('CFLAGS', '-m32')
450         conf.env.append_unique('CXXFLAGS', '-m32')
451         conf.env.append_unique('CXXFLAGS', '-DBUILD_WITH_32_64')
452         conf.env.append_unique('LINKFLAGS', '-m32')
453         if Options.options.libdir32:
454             conf.env['LIBDIR'] = Options.options.libdir32
455         else:
456             conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
458         if conf.env['IS_WINDOWS'] and conf.env['BUILD_STATIC']:
459             def replaceFor32bit(env):
460                 for e in env:
461                     yield e.replace('x86_64', 'i686', 1)
462             for env in ('AR', 'CC', 'CXX', 'LINK_CC', 'LINK_CXX'):
463                 conf.all_envs[lib32][env] = list(replaceFor32bit(conf.all_envs[lib32][env]))
464             conf.all_envs[lib32]['LIB_REGEX'] = ['tre32']
466         # libdb does not work in mixed mode
467         conf.all_envs[lib32]['HAVE_DB'] = 0
468         conf.all_envs[lib32]['HAVE_DB_H'] = 0
469         conf.all_envs[lib32]['LIB_DB'] = []
470         # no need for opus in 32bit mixed mode clients
471         conf.all_envs[lib32]['LIB_OPUS'] = []
472         # someone tell me where this file gets written please..
473         conf.write_config_header('config.h')
475     print()
476     print('LADI JACK ' + VERSION)
478     conf.msg('Maximum JACK clients', Options.options.clients, color='NORMAL')
479     conf.msg('Maximum ports per application', Options.options.application_ports, color='NORMAL')
481     conf.msg('Install prefix', conf.env['PREFIX'], color='CYAN')
482     conf.msg('Library directory', conf.all_envs['']['LIBDIR'], color='CYAN')
483     if conf.env['BUILD_WITH_32_64']:
484         conf.msg('32-bit library directory', conf.all_envs[lib32]['LIBDIR'], color='CYAN')
485     conf.msg('Drivers directory', conf.env['ADDON_DIR'], color='CYAN')
486     display_feature(conf, 'Build debuggable binaries', conf.env['BUILD_DEBUG'])
488     tool_flags = [
489         ('C compiler flags',   ['CFLAGS', 'CPPFLAGS']),
490         ('C++ compiler flags', ['CXXFLAGS', 'CPPFLAGS']),
491         ('Linker flags',       ['LINKFLAGS', 'LDFLAGS'])
492     ]
493     for name, vars in tool_flags:
494         flags = []
495         for var in vars:
496             flags += conf.all_envs[''][var]
497         conf.msg(name, repr(flags), color='NORMAL')
499     if conf.env['BUILD_WITH_32_64']:
500         conf.msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
501         conf.msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
502         conf.msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
503     display_feature(conf, 'Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
504     display_feature(conf, 'Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
506     display_feature(conf, 'Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
507     if conf.env['BUILD_JACKD']:
508         display_feature(conf, 'D-Bus device reservation for jackd', conf.env['BUILD_DBUS_RESERVATION'])
509     conf.msg('Autostart method', conf.env['AUTOSTART_METHOD'])
511     conf.summarize_auto_options()
513     print()
516 def init(ctx):
517     for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
518         name = y.__name__.replace('Context', '').lower()
520         class tmp(y):
521             cmd = name + '_' + lib32
522             variant = lib32
525 def obj_add_includes(bld, obj):
526     if bld.env['IS_LINUX']:
527         obj.includes += ['linux', 'posix']
529     if bld.env['IS_FREEBSD']:
530         obj.includes += ['freebsd', 'posix']
532     if bld.env['IS_MACOSX']:
533         obj.includes += ['macosx', 'posix']
535     if bld.env['IS_SUN']:
536         obj.includes += ['posix', 'solaris']
538     if bld.env['IS_WINDOWS']:
539         obj.includes += ['windows']
542 # FIXME: Is SERVER_SIDE needed?
543 def build_jackd(bld):
544     jackd = bld(
545         features=['cxx', 'cxxprogram'],
546         defines=['HAVE_CONFIG_H', 'SERVER_SIDE'],
547         includes=['.', 'common', 'common/jack'],
548         target='jackd',
549         source=['common/Jackdmp.cpp'],
550         use=['serverlib', 'SYSTEMD']
551     )
553     if bld.env['BUILD_DBUS_RESERVATION']:
554         jackd.source += ['dbus/audio_reserve.c', 'dbus/reserve.c']
555         jackd.use += ['DBUS-1']
557     if bld.env['IS_LINUX']:
558         jackd.use += ['DL', 'M', 'PTHREAD', 'RT', 'STDC++']
560     if bld.env['IS_FREEBSD']:
561         jackd.use += ['M', 'PTHREAD']
563     if bld.env['IS_MACOSX']:
564         jackd.use += ['DL', 'PTHREAD']
565         jackd.framework = ['CoreFoundation']
567     if bld.env['IS_SUN']:
568         jackd.use += ['DL', 'PTHREAD']
570     obj_add_includes(bld, jackd)
572     return jackd
575 # FIXME: Is SERVER_SIDE needed?
576 def create_driver_obj(bld, **kw):
577     if 'use' in kw:
578         kw['use'] += ['serverlib']
579     else:
580         kw['use'] = ['serverlib']
582     driver = bld(
583         features=['c', 'cxx', 'cshlib', 'cxxshlib'],
584         defines=['HAVE_CONFIG_H', 'SERVER_SIDE'],
585         includes=['.', 'common', 'common/jack'],
586         install_path='${ADDON_DIR}/',
587         **kw)
589     if bld.env['IS_WINDOWS']:
590         driver.env['cxxshlib_PATTERN'] = 'jack_%s.dll'
591     else:
592         driver.env['cxxshlib_PATTERN'] = 'jack_%s.so'
594     obj_add_includes(bld, driver)
596     return driver
599 def build_drivers(bld):
600     # Non-hardware driver sources. Lexically sorted.
601     dummy_src = [
602         'common/JackDummyDriver.cpp'
603     ]
605     loopback_src = [
606         'common/JackLoopbackDriver.cpp'
607     ]
609     net_src = [
610         'common/JackNetDriver.cpp'
611     ]
613     netone_src = [
614         'common/JackNetOneDriver.cpp',
615         'common/netjack.c',
616         'common/netjack_packet.c'
617     ]
619     proxy_src = [
620         'common/JackProxyDriver.cpp'
621     ]
623     # Hardware driver sources. Lexically sorted.
624     alsa_src = [
625         'common/memops.c',
626         'linux/alsa/JackAlsaDriver.cpp',
627         'linux/alsa/alsa_rawmidi.c',
628         'linux/alsa/alsa_seqmidi.c',
629         'linux/alsa/alsa_midi_jackmp.cpp',
630         'linux/alsa/generic_hw.c',
631         'linux/alsa/hdsp.c',
632         'linux/alsa/alsa_driver.c',
633         'linux/alsa/hammerfall.c',
634         'linux/alsa/ice1712.c'
635     ]
637     alsarawmidi_src = [
638         'linux/alsarawmidi/JackALSARawMidiDriver.cpp',
639         'linux/alsarawmidi/JackALSARawMidiInputPort.cpp',
640         'linux/alsarawmidi/JackALSARawMidiOutputPort.cpp',
641         'linux/alsarawmidi/JackALSARawMidiPort.cpp',
642         'linux/alsarawmidi/JackALSARawMidiReceiveQueue.cpp',
643         'linux/alsarawmidi/JackALSARawMidiSendQueue.cpp',
644         'linux/alsarawmidi/JackALSARawMidiUtil.cpp'
645     ]
647     boomer_src = [
648         'common/memops.c',
649         'solaris/oss/JackBoomerDriver.cpp'
650     ]
652     coreaudio_src = [
653         'macosx/coreaudio/JackCoreAudioDriver.mm',
654         'common/JackAC3Encoder.cpp'
655     ]
657     coremidi_src = [
658         'macosx/coremidi/JackCoreMidiInputPort.mm',
659         'macosx/coremidi/JackCoreMidiOutputPort.mm',
660         'macosx/coremidi/JackCoreMidiPhysicalInputPort.mm',
661         'macosx/coremidi/JackCoreMidiPhysicalOutputPort.mm',
662         'macosx/coremidi/JackCoreMidiVirtualInputPort.mm',
663         'macosx/coremidi/JackCoreMidiVirtualOutputPort.mm',
664         'macosx/coremidi/JackCoreMidiPort.mm',
665         'macosx/coremidi/JackCoreMidiUtil.mm',
666         'macosx/coremidi/JackCoreMidiDriver.mm'
667     ]
669     ffado_src = [
670         'linux/firewire/JackFFADODriver.cpp',
671         'linux/firewire/JackFFADOMidiInputPort.cpp',
672         'linux/firewire/JackFFADOMidiOutputPort.cpp',
673         'linux/firewire/JackFFADOMidiReceiveQueue.cpp',
674         'linux/firewire/JackFFADOMidiSendQueue.cpp'
675     ]
677     freebsd_oss_src = [
678         'common/memops.c',
679         'freebsd/oss/JackOSSDriver.cpp'
680     ]
682     iio_driver_src = [
683         'linux/iio/JackIIODriver.cpp'
684     ]
686     oss_src = [
687         'common/memops.c',
688         'solaris/oss/JackOSSDriver.cpp'
689     ]
691     portaudio_src = [
692         'windows/portaudio/JackPortAudioDevices.cpp',
693         'windows/portaudio/JackPortAudioDriver.cpp',
694     ]
696     winmme_src = [
697         'windows/winmme/JackWinMMEDriver.cpp',
698         'windows/winmme/JackWinMMEInputPort.cpp',
699         'windows/winmme/JackWinMMEOutputPort.cpp',
700         'windows/winmme/JackWinMMEPort.cpp',
701     ]
703     # Create non-hardware driver objects. Lexically sorted.
704     create_driver_obj(
705         bld,
706         target='dummy',
707         source=dummy_src)
709     create_driver_obj(
710         bld,
711         target='loopback',
712         source=loopback_src)
714     create_driver_obj(
715         bld,
716         target='net',
717         source=net_src,
718         use=['CELT'])
720     create_driver_obj(
721         bld,
722         target='netone',
723         source=netone_src,
724         use=['SAMPLERATE', 'CELT'])
726     create_driver_obj(
727         bld,
728         target='proxy',
729         source=proxy_src)
731     # Create hardware driver objects. Lexically sorted after the conditional,
732     # e.g. BUILD_DRIVER_ALSA.
733     if bld.env['BUILD_DRIVER_ALSA']:
734         create_driver_obj(
735             bld,
736             target='alsa',
737             source=alsa_src,
738             use=['ALSA'])
739         create_driver_obj(
740             bld,
741             target='alsarawmidi',
742             source=alsarawmidi_src,
743             use=['ALSA'])
745     if bld.env['BUILD_DRIVER_FFADO']:
746         create_driver_obj(
747             bld,
748             target='firewire',
749             source=ffado_src,
750             use=['LIBFFADO'])
752     if bld.env['BUILD_DRIVER_IIO']:
753         create_driver_obj(
754             bld,
755             target='iio',
756             source=iio_driver_src,
757             use=['GTKIOSTREAM', 'EIGEN3'])
759     if bld.env['BUILD_DRIVER_PORTAUDIO']:
760         create_driver_obj(
761             bld,
762             target='portaudio',
763             source=portaudio_src,
764             use=['PORTAUDIO'])
766     if bld.env['BUILD_DRIVER_WINMME']:
767         create_driver_obj(
768             bld,
769             target='winmme',
770             source=winmme_src,
771             use=['WINMME'])
773     if bld.env['IS_MACOSX']:
774         create_driver_obj(
775             bld,
776             target='coreaudio',
777             source=coreaudio_src,
778             use=['AFTEN'],
779             framework=['AudioUnit', 'CoreAudio', 'CoreServices'])
781         create_driver_obj(
782             bld,
783             target='coremidi',
784             source=coremidi_src,
785             use=['serverlib'],  # FIXME: Is this needed?
786             framework=['AudioUnit', 'CoreMIDI', 'CoreServices', 'Foundation'])
788     if bld.env['IS_FREEBSD']:
789         create_driver_obj(
790             bld,
791             target='oss',
792             source=freebsd_oss_src)
794     if bld.env['IS_SUN']:
795         create_driver_obj(
796             bld,
797             target='boomer',
798             source=boomer_src)
799         create_driver_obj(
800             bld,
801             target='oss',
802             source=oss_src)
805 def build(bld):
806     if not bld.variant and bld.env['BUILD_WITH_32_64']:
807         Options.commands.append(bld.cmd + '_' + lib32)
809     # process subfolders from here
810     bld.recurse('common')
812     if bld.variant:
813         # only the wscript in common/ knows how to handle variants
814         return
816     bld.recurse('compat')
818     if bld.env['BUILD_JACKD']:
819         build_jackd(bld)
821     build_drivers(bld)
823     if bld.env['IS_LINUX'] or bld.env['IS_FREEBSD']:
824         bld.recurse('man')
825         bld.recurse('systemd')
826     if not bld.env['IS_WINDOWS'] and bld.env['BUILD_TESTS']:
827         bld.recurse('tests')
829     if bld.env['BUILD_DOXYGEN_DOCS']:
830         html_build_dir = bld.path.find_or_declare('html').abspath()
832         bld(
833             features='subst',
834             source='doxyfile.in',
835             target='doxyfile',
836             HTML_BUILD_DIR=html_build_dir,
837             SRCDIR=bld.srcnode.abspath(),
838             VERSION=VERSION
839         )
841         # There are two reasons for logging to doxygen.log and using it as
842         # target in the build rule (rather than html_build_dir):
843         # (1) reduce the noise when running the build
844         # (2) waf has a regular file to check for a timestamp. If the directory
845         #     is used instead waf will rebuild the doxygen target (even upon
846         #     install).
847         def doxygen(task):
848             doxyfile = task.inputs[0].abspath()
849             logfile = task.outputs[0].abspath()
850             cmd = '%s %s &> %s' % (task.env['DOXYGEN'][0], doxyfile, logfile)
851             return task.exec_command(cmd)
853         bld(
854             rule=doxygen,
855             source='doxyfile',
856             target='doxygen.log'
857         )
859         # Determine where to install HTML documentation. Since share_dir is the
860         # highest directory the uninstall routine should remove, there is no
861         # better candidate for share_dir, but the requested HTML directory if
862         # --htmldir is given.
863         if bld.env['HTMLDIR']:
864             html_install_dir = bld.options.destdir + bld.env['HTMLDIR']
865             share_dir = html_install_dir
866         else:
867             share_dir = bld.options.destdir + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
868             html_install_dir = share_dir + '/reference/html/'
870         if bld.cmd == 'install':
871             if os.path.isdir(html_install_dir):
872                 Logs.pprint('CYAN', 'Removing old doxygen documentation installation...')
873                 shutil.rmtree(html_install_dir)
874                 Logs.pprint('CYAN', 'Removing old doxygen documentation installation done.')
875             Logs.pprint('CYAN', 'Installing doxygen documentation...')
876             shutil.copytree(html_build_dir, html_install_dir)
877             Logs.pprint('CYAN', 'Installing doxygen documentation done.')
878         elif bld.cmd == 'uninstall':
879             Logs.pprint('CYAN', 'Uninstalling doxygen documentation...')
880             if os.path.isdir(share_dir):
881                 shutil.rmtree(share_dir)
882             Logs.pprint('CYAN', 'Uninstalling doxygen documentation done.')
883         elif bld.cmd == 'clean':
884             if os.access(html_build_dir, os.R_OK):
885                 Logs.pprint('CYAN', 'Removing doxygen generated documentation...')
886                 shutil.rmtree(html_build_dir)
887                 Logs.pprint('CYAN', 'Removing doxygen generated documentation done.')
890 @TaskGen.extension('.mm')
891 def mm_hook(self, node):
892     """Alias .mm files to be compiled the same as .cpp files, gcc will do the right thing."""
893     return self.create_compiled_task('cxx', node)