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