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