jack: remove unnecessary GPL include from LGPL code
[jack2.git] / wscript
blobba7ba9fa3e5639ed5247c6c2ee7befb02a7955c5
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')
216     conf.env.append_unique('CFLAGS', '-Wall')
217     conf.env.append_unique('CXXFLAGS', '-Wall')
218     conf.env.append_unique('CXXFLAGS', '-std=gnu++11')
220     if not conf.env['IS_MACOSX']:
221         conf.env.append_unique('LDFLAGS', '-Wl,--no-undefined')
222     else:
223         conf.check(lib='aften', uselib='AFTEN', define_name='AFTEN')
224         conf.check_cxx(
225             fragment=''
226                 + '#include <aften/aften.h>\n'
227                 + 'int\n'
228                 + 'main(void)\n'
229                 + '{\n'
230                 + 'AftenContext fAftenContext;\n'
231                 + 'aften_set_defaults(&fAftenContext);\n'
232                 + 'unsigned char *fb;\n'
233                 + 'float *buf=new float[10];\n'
234                 + 'int res = aften_encode_frame(&fAftenContext, fb, buf, 1);\n'
235                 + '}\n',
236             lib='aften',
237             msg='Checking for aften_encode_frame()',
238             define_name='HAVE_AFTEN_NEW_API',
239             mandatory=False)
241     conf.load('autooptions')
243     conf.recurse('compat')
245     # Check for functions.
246     conf.check(
247             fragment=''
248                 + '#define _GNU_SOURCE\n'
249                 + '#include <poll.h>\n'
250                 + '#include <signal.h>\n'
251                 + '#include <stddef.h>\n'
252                 + 'int\n'
253                 + 'main(void)\n'
254                 + '{\n'
255                 + '   ppoll(NULL, 0, NULL, NULL);\n'
256                 + '}\n',
257             msg='Checking for ppoll',
258             define_name='HAVE_PPOLL',
259             mandatory=False)
261     # Check for backtrace support
262     conf.check(
263         header_name='execinfo.h',
264         define_name='HAVE_EXECINFO_H',
265         mandatory=False)
267     conf.recurse('common')
268     if Options.options.dbus:
269         conf.recurse('dbus')
270         if conf.env['BUILD_JACKDBUS'] != True:
271             conf.fatal('jackdbus was explicitly requested but cannot be built')
272     if conf.env['IS_LINUX']:
273         if Options.options.systemd_unit:
274             conf.recurse('systemd')
275         else:
276             conf.env['SYSTEMD_USER_UNIT_DIR'] = None
279     conf.recurse('example-clients')
281     # test for the availability of ucontext, and how it should be used
282     for t in ['gp_regs', 'uc_regs', 'mc_gregs', 'gregs']:
283         fragment = '#include <ucontext.h>\n'
284         fragment += 'int main() { ucontext_t *ucontext; return (int) ucontext->uc_mcontext.%s[0]; }' % t
285         confvar = 'HAVE_UCONTEXT_%s' % t.upper()
286         conf.check_cc(fragment=fragment, define_name=confvar, mandatory=False,
287                       msg='Checking for ucontext->uc_mcontext.%s' % t)
288         if conf.is_defined(confvar):
289             conf.define('HAVE_UCONTEXT', 1)
291     fragment = '#include <ucontext.h>\n'
292     fragment += 'int main() { return NGREG; }'
293     conf.check_cc(fragment=fragment, define_name='HAVE_NGREG', mandatory=False,
294                   msg='Checking for NGREG')
296     conf.env['LIB_PTHREAD'] = ['pthread']
297     conf.env['LIB_DL'] = ['dl']
298     conf.env['LIB_RT'] = ['rt']
299     conf.env['LIB_M'] = ['m']
300     conf.env['LIB_STDC++'] = ['stdc++']
301     conf.env['JACK_API_VERSION'] = JACK_API_VERSION
302     conf.env['JACK_VERSION'] = VERSION
304     conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
305     conf.env['BUILD_WITH_32_64'] = Options.options.mixed
306     conf.env['BUILD_CLASSIC'] = Options.options.classic
307     conf.env['BUILD_DEBUG'] = Options.options.debug
309     if conf.env['BUILD_JACKDBUS']:
310         conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
311     else:
312         conf.env['BUILD_JACKD'] = True
314     conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin'
316     if Options.options.htmldir:
317         conf.env['HTMLDIR'] = Options.options.htmldir
318     else:
319         # set to None here so that the doxygen code can find out the highest
320         # directory to remove upon install
321         conf.env['HTMLDIR'] = None
323     if Options.options.libdir:
324         conf.env['LIBDIR'] = Options.options.libdir
325     else:
326         conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
328     if Options.options.pkgconfigdir:
329         conf.env['PKGCONFDIR'] = Options.options.pkgconfigdir
330     else:
331         conf.env['PKGCONFDIR'] = conf.env['LIBDIR'] + '/pkgconfig'
333     if Options.options.mandir:
334         conf.env['MANDIR'] = Options.options.mandir
335     else:
336         conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
338     if conf.env['BUILD_DEBUG']:
339         conf.env.append_unique('CXXFLAGS', '-g')
340         conf.env.append_unique('CFLAGS', '-g')
341         conf.env.append_unique('LINKFLAGS', '-g')
343     if not Options.options.autostart in ['default', 'classic', 'dbus', 'none']:
344         conf.fatal('Invalid autostart value "' + Options.options.autostart + '"')
346     if Options.options.autostart == 'default':
347         if conf.env['BUILD_JACKD']:
348             conf.env['AUTOSTART_METHOD'] = 'classic'
349         else:
350             conf.env['AUTOSTART_METHOD'] = 'dbus'
351     else:
352         conf.env['AUTOSTART_METHOD'] = Options.options.autostart
354     if conf.env['AUTOSTART_METHOD'] == 'dbus' and not conf.env['BUILD_JACKDBUS']:
355         conf.fatal('D-Bus autostart mode was specified but jackdbus will not be built')
356     if conf.env['AUTOSTART_METHOD'] == 'classic' and not conf.env['BUILD_JACKD']:
357         conf.fatal('Classic autostart mode was specified but jackd will not be built')
359     if conf.env['AUTOSTART_METHOD'] == 'dbus':
360         conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
361     elif conf.env['AUTOSTART_METHOD'] == 'classic':
362         conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
364     conf.define('CLIENT_NUM', Options.options.clients)
365     conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
367     if conf.env['IS_WINDOWS']:
368         # we define this in the environment to maintain compatibility with
369         # existing install paths that use ADDON_DIR rather than have to
370         # have special cases for windows each time.
371         conf.env['ADDON_DIR'] = conf.env['BINDIR'] + '/jack'
372         # don't define ADDON_DIR in config.h, use the default 'jack' defined in
373         # windows/JackPlatformPlug_os.h
374     else:
375         conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
376         conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
377         conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
379     if not conf.env['IS_WINDOWS']:
380         conf.define('USE_POSIX_SHM', 1)
381     conf.define('JACKMP', 1)
382     if conf.env['BUILD_JACKDBUS']:
383         conf.define('JACK_DBUS', 1)
384     if conf.env['BUILD_WITH_PROFILE']:
385         conf.define('JACK_MONITOR', 1)
386     conf.write_config_header('config.h', remove=False)
388     svnrev = None
389     try:
390         f = open('svnversion.h')
391         data = f.read()
392         m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
393         if m != None:
394             svnrev = m.group(1)
395         f.close()
396     except IOError:
397         pass
399     if Options.options.mixed:
400         conf.setenv(lib32, env=conf.env.derive())
401         conf.env.append_unique('CFLAGS', '-m32')
402         conf.env.append_unique('CXXFLAGS', '-m32')
403         conf.env.append_unique('CXXFLAGS', '-DBUILD_WITH_32_64')
404         conf.env.append_unique('LINKFLAGS', '-m32')
405         if Options.options.libdir32:
406             conf.env['LIBDIR'] = Options.options.libdir32
407         else:
408             conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
409         # libdb does not work in mixed mode
410         conf.all_envs[lib32]['HAVE_DB'] = 0
411         conf.all_envs[lib32]['HAVE_DB_H'] = 0
412         conf.all_envs[lib32]['LIB_DB'] = []
413         # no need for opus in 32bit mixed mode clients
414         conf.all_envs[lib32]['LIB_OPUS'] = []
415         # someone tell me where this file gets written please..
416         conf.write_config_header('config.h')
418     print()
419     print('==================')
420     version_msg = 'JACK ' + VERSION
421     if svnrev:
422         version_msg += ' exported from r' + svnrev
423     else:
424         version_msg += ' svn revision will checked and eventually updated during build'
425     print(version_msg)
427     conf.msg('Maximum JACK clients', Options.options.clients, color='NORMAL')
428     conf.msg('Maximum ports per application', Options.options.application_ports, color='NORMAL')
430     conf.msg('Install prefix', conf.env['PREFIX'], color='CYAN')
431     conf.msg('Library directory', conf.all_envs['']['LIBDIR'], color='CYAN')
432     if conf.env['BUILD_WITH_32_64']:
433         conf.msg('32-bit library directory', conf.all_envs[lib32]['LIBDIR'], color='CYAN')
434     conf.msg('Drivers directory', conf.env['ADDON_DIR'], color='CYAN')
435     display_feature(conf, 'Build debuggable binaries', conf.env['BUILD_DEBUG'])
437     tool_flags = [
438         ('C compiler flags',   ['CFLAGS', 'CPPFLAGS']),
439         ('C++ compiler flags', ['CXXFLAGS', 'CPPFLAGS']),
440         ('Linker flags',       ['LINKFLAGS', 'LDFLAGS'])
441     ]
442     for name,vars in tool_flags:
443         flags = []
444         for var in vars:
445             flags += conf.all_envs[''][var]
446         conf.msg(name, repr(flags), color='NORMAL')
448     if conf.env['BUILD_WITH_32_64']:
449         conf.msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
450         conf.msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
451         conf.msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
452     display_feature(conf, 'Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
453     display_feature(conf, 'Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
455     display_feature(conf, 'Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
456     display_feature(conf, 'Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
457     conf.msg('Autostart method', conf.env['AUTOSTART_METHOD'])
459     if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
460         print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
461         print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
463     conf.summarize_auto_options()
465     if conf.env['BUILD_JACKDBUS']:
466         conf.msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], color='CYAN')
468         if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
469             print()
470             print(Logs.colors.RED + 'WARNING: D-Bus session services directory as reported by pkg-config is')
471             print(Logs.colors.RED + 'WARNING:', end=' ')
472             print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
473             print(Logs.colors.RED + 'WARNING: but service file will be installed in')
474             print(Logs.colors.RED + 'WARNING:', end=' ')
475             print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
476             print(Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
477             print('WARNING: You can override dbus service install directory')
478             print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
479             print(Logs.colors.NORMAL, end=' ')
480     print()
482 def init(ctx):
483     for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
484         name = y.__name__.replace('Context','').lower()
485         class tmp(y):
486             cmd = name + '_' + lib32
487             variant = lib32
489 def obj_add_includes(bld, obj):
490     if bld.env['BUILD_JACKDBUS']:
491         obj.includes += ['dbus']
493     if bld.env['IS_LINUX']:
494         obj.includes += ['linux', 'posix']
496     if bld.env['IS_MACOSX']:
497         obj.includes += ['macosx', 'posix']
499     if bld.env['IS_SUN']:
500         obj.includes += ['posix', 'solaris']
502     if bld.env['IS_WINDOWS']:
503         obj.includes += ['windows']
505 # FIXME: Is SERVER_SIDE needed?
506 def build_jackd(bld):
507     jackd = bld(
508         features = ['cxx', 'cxxprogram'],
509         defines = ['HAVE_CONFIG_H','SERVER_SIDE'],
510         includes = ['.', 'common', 'common/jack'],
511         target = 'jackd',
512         source = ['common/Jackdmp.cpp'],
513         use = ['serverlib', 'SYSTEMD']
514     )
516     if bld.env['BUILD_JACKDBUS']:
517         jackd.source += ['dbus/audio_reserve.c', 'dbus/reserve.c']
518         jackd.use += ['DBUS-1']
520     if bld.env['IS_LINUX']:
521         jackd.use += ['DL', 'M', 'PTHREAD', 'RT', 'STDC++']
523     if bld.env['IS_MACOSX']:
524         jackd.use += ['DL', 'PTHREAD']
525         jackd.framework = ['CoreFoundation']
527     if bld.env['IS_SUN']:
528         jackd.use += ['DL', 'PTHREAD']
530     obj_add_includes(bld, jackd)
532     return jackd
534 # FIXME: Is SERVER_SIDE needed?
535 def create_driver_obj(bld, **kw):
536     if 'use' in kw:
537         kw['use'] += ['serverlib']
538     else:
539         kw['use'] = ['serverlib']
541     driver = bld(
542         features = ['c', 'cxx', 'cshlib', 'cxxshlib'],
543         defines = ['HAVE_CONFIG_H', 'SERVER_SIDE'],
544         includes = ['.', 'common', 'common/jack'],
545         install_path = '${ADDON_DIR}/',
546         **kw)
548     if bld.env['IS_WINDOWS']:
549         driver.env['cxxshlib_PATTERN'] = 'jack_%s.dll'
550     else:
551         driver.env['cxxshlib_PATTERN'] = 'jack_%s.so'
553     obj_add_includes(bld, driver)
555     return driver
557 def build_drivers(bld):
558     # Non-hardware driver sources. Lexically sorted.
559     dummy_src = [
560         'common/JackDummyDriver.cpp'
561     ]
563     loopback_src = [
564         'common/JackLoopbackDriver.cpp'
565     ]
567     net_src = [
568         'common/JackNetDriver.cpp'
569     ]
571     netone_src = [
572         'common/JackNetOneDriver.cpp',
573         'common/netjack.c',
574         'common/netjack_packet.c'
575     ]
577     proxy_src = [
578         'common/JackProxyDriver.cpp'
579     ]
581     # Hardware driver sources. Lexically sorted.
582     alsa_src = [
583         'common/memops.c',
584         'linux/alsa/JackAlsaDriver.cpp',
585         'linux/alsa/alsa_rawmidi.c',
586         'linux/alsa/alsa_seqmidi.c',
587         'linux/alsa/alsa_midi_jackmp.cpp',
588         'linux/alsa/generic_hw.c',
589         'linux/alsa/hdsp.c',
590         'linux/alsa/alsa_driver.c',
591         'linux/alsa/hammerfall.c',
592         'linux/alsa/ice1712.c'
593     ]
595     alsarawmidi_src = [
596         'linux/alsarawmidi/JackALSARawMidiDriver.cpp',
597         'linux/alsarawmidi/JackALSARawMidiInputPort.cpp',
598         'linux/alsarawmidi/JackALSARawMidiOutputPort.cpp',
599         'linux/alsarawmidi/JackALSARawMidiPort.cpp',
600         'linux/alsarawmidi/JackALSARawMidiReceiveQueue.cpp',
601         'linux/alsarawmidi/JackALSARawMidiSendQueue.cpp',
602         'linux/alsarawmidi/JackALSARawMidiUtil.cpp'
603     ]
605     boomer_src = [
606         'common/memops.c',
607         'solaris/oss/JackBoomerDriver.cpp'
608     ]
610     coreaudio_src = [
611         'macosx/coreaudio/JackCoreAudioDriver.mm',
612         'common/JackAC3Encoder.cpp'
613     ]
615     coremidi_src = [
616         'macosx/coremidi/JackCoreMidiInputPort.mm',
617         'macosx/coremidi/JackCoreMidiOutputPort.mm',
618         'macosx/coremidi/JackCoreMidiPhysicalInputPort.mm',
619         'macosx/coremidi/JackCoreMidiPhysicalOutputPort.mm',
620         'macosx/coremidi/JackCoreMidiVirtualInputPort.mm',
621         'macosx/coremidi/JackCoreMidiVirtualOutputPort.mm',
622         'macosx/coremidi/JackCoreMidiPort.mm',
623         'macosx/coremidi/JackCoreMidiUtil.mm',
624         'macosx/coremidi/JackCoreMidiDriver.mm'
625     ]
627     ffado_src = [
628         'linux/firewire/JackFFADODriver.cpp',
629         'linux/firewire/JackFFADOMidiInputPort.cpp',
630         'linux/firewire/JackFFADOMidiOutputPort.cpp',
631         'linux/firewire/JackFFADOMidiReceiveQueue.cpp',
632         'linux/firewire/JackFFADOMidiSendQueue.cpp'
633     ]
635     iio_driver_src = [
636         'linux/iio/JackIIODriver.cpp'
637     ]
639     oss_src = [
640         'common/memops.c',
641         'solaris/oss/JackOSSDriver.cpp'
642     ]
644     portaudio_src = [
645         'windows/portaudio/JackPortAudioDevices.cpp',
646         'windows/portaudio/JackPortAudioDriver.cpp',
647     ]
649     winmme_src = [
650         'windows/winmme/JackWinMMEDriver.cpp',
651         'windows/winmme/JackWinMMEInputPort.cpp',
652         'windows/winmme/JackWinMMEOutputPort.cpp',
653         'windows/winmme/JackWinMMEPort.cpp',
654     ]
656     # Create non-hardware driver objects. Lexically sorted.
657     create_driver_obj(
658         bld,
659         target = 'dummy',
660         source = dummy_src)
662     create_driver_obj(
663         bld,
664         target = 'loopback',
665         source = loopback_src)
667     create_driver_obj(
668         bld,
669         target = 'net',
670         source = net_src)
672     create_driver_obj(
673         bld,
674         target = 'netone',
675         source = netone_src,
676         use = ['SAMPLERATE', 'CELT'])
678     create_driver_obj(
679         bld,
680         target = 'proxy',
681         source = proxy_src)
683     # Create hardware driver objects. Lexically sorted after the conditional,
684     # e.g. BUILD_DRIVER_ALSA.
685     if bld.env['BUILD_DRIVER_ALSA']:
686         create_driver_obj(
687             bld,
688             target = 'alsa',
689             source = alsa_src,
690             use = ['ALSA'])
691         create_driver_obj(
692             bld,
693             target = 'alsarawmidi',
694             source = alsarawmidi_src,
695             use = ['ALSA'])
697     if bld.env['BUILD_DRIVER_FFADO']:
698         create_driver_obj(
699             bld,
700             target = 'firewire',
701             source = ffado_src,
702             use = ['LIBFFADO'])
704     if bld.env['BUILD_DRIVER_IIO']:
705         create_driver_obj(
706             bld,
707             target = 'iio',
708             source = iio_src,
709             use = ['GTKIOSTREAM', 'EIGEN3'])
711     if bld.env['BUILD_DRIVER_PORTAUDIO']:
712         create_driver_obj(
713             bld,
714             target = 'portaudio',
715             source = portaudio_src,
716             use = ['PORTAUDIO'])
718     if bld.env['BUILD_DRIVER_WINMME']:
719         create_driver_obj(
720             bld,
721             target = 'winmme',
722             source = winmme_src,
723             use = ['WINMME'])
725     if bld.env['IS_MACOSX']:
726         create_driver_obj(
727             bld,
728             target = 'coreaudio',
729             source = coreaudio_src,
730             use = ['AFTEN'],
731             framework = ['AudioUnit', 'CoreAudio', 'CoreServices'])
733         create_driver_obj(
734             bld,
735             target = 'coremidi',
736             source = coremidi_src,
737             use = ['serverlib'], # FIXME: Is this needed?
738             framework = ['AudioUnit', 'CoreMIDI', 'CoreServices', 'Foundation'])
740     if bld.env['IS_SUN']:
741         create_driver_obj(
742             bld,
743             target = 'boomer',
744             source = boomer_src)
745         create_driver_obj(
746             bld,
747             target = 'oss',
748             source = oss_src)
750 def build(bld):
751     if not bld.variant and bld.env['BUILD_WITH_32_64']:
752         Options.commands.append(bld.cmd + '_' + lib32)
754     # process subfolders from here
755     bld.recurse('common')
757     if bld.variant:
758         # only the wscript in common/ knows how to handle variants
759         return
761     bld.recurse('compat')
763     if not os.access('svnversion.h', os.R_OK):
764         def post_run(self):
765             sg = Utils.h_file(self.outputs[0].abspath(self.env))
766             #print sg.encode('hex')
767             Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
769         script = bld.path.find_resource('svnversion_regenerate.sh')
770         script = script.abspath()
772         bld(
773                 rule = '%s ${TGT}' % script,
774                 name = 'svnversion',
775                 runnable_status = Task.RUN_ME,
776                 before = 'c cxx',
777                 color = 'BLUE',
778                 post_run = post_run,
779                 source = ['svnversion_regenerate.sh'],
780                 target = [bld.path.find_or_declare('svnversion.h')]
781         )
783     if bld.env['BUILD_JACKD']:
784         build_jackd(bld)
786     build_drivers(bld)
788     bld.recurse('example-clients')
789     if bld.env['IS_LINUX']:
790         bld.recurse('man')
791         bld.recurse('systemd')
792     if not bld.env['IS_WINDOWS']:
793         bld.recurse('tests')
794     if bld.env['BUILD_JACKDBUS']:
795         bld.recurse('dbus')
797     if bld.env['BUILD_DOXYGEN_DOCS']:
798         html_build_dir = bld.path.find_or_declare('html').abspath()
800         bld(
801             features = 'subst',
802             source = 'doxyfile.in',
803             target = 'doxyfile',
804             HTML_BUILD_DIR = html_build_dir,
805             SRCDIR = bld.srcnode.abspath(),
806             VERSION = VERSION
807         )
809         # There are two reasons for logging to doxygen.log and using it as
810         # target in the build rule (rather than html_build_dir):
811         # (1) reduce the noise when running the build
812         # (2) waf has a regular file to check for a timestamp. If the directory
813         #     is used instead waf will rebuild the doxygen target (even upon
814         #     install).
815         def doxygen(task):
816             doxyfile = task.inputs[0].abspath()
817             logfile = task.outputs[0].abspath()
818             cmd = '%s %s &> %s' % (task.env['DOXYGEN'][0], doxyfile, logfile)
819             return task.exec_command(cmd)
821         bld(
822             rule = doxygen,
823             source = 'doxyfile',
824             target = 'doxygen.log'
825         )
827         # Determine where to install HTML documentation. Since share_dir is the
828         # highest directory the uninstall routine should remove, there is no
829         # better candidate for share_dir, but the requested HTML directory if
830         # --htmldir is given.
831         if bld.env['HTMLDIR']:
832             html_install_dir = bld.options.destdir + bld.env['HTMLDIR']
833             share_dir = html_install_dir
834         else:
835             share_dir = bld.options.destdir + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
836             html_install_dir = share_dir + '/reference/html/'
838         if bld.cmd == 'install':
839             if os.path.isdir(html_install_dir):
840                 Logs.pprint('CYAN', 'Removing old doxygen documentation installation...')
841                 shutil.rmtree(html_install_dir)
842                 Logs.pprint('CYAN', 'Removing old doxygen documentation installation done.')
843             Logs.pprint('CYAN', 'Installing doxygen documentation...')
844             shutil.copytree(html_build_dir, html_install_dir)
845             Logs.pprint('CYAN', 'Installing doxygen documentation done.')
846         elif bld.cmd =='uninstall':
847             Logs.pprint('CYAN', 'Uninstalling doxygen documentation...')
848             if os.path.isdir(share_dir):
849                 shutil.rmtree(share_dir)
850             Logs.pprint('CYAN', 'Uninstalling doxygen documentation done.')
851         elif bld.cmd =='clean':
852             if os.access(html_build_dir, os.R_OK):
853                 Logs.pprint('CYAN', 'Removing doxygen generated documentation...')
854                 shutil.rmtree(html_build_dir)
855                 Logs.pprint('CYAN', 'Removing doxygen generated documentation done.')
857 def dist(ctx):
858     # This code blindly assumes it is working in the toplevel source directory.
859     if not os.path.exists('svnversion.h'):
860         os.system('./svnversion_regenerate.sh svnversion.h')
862 from waflib import TaskGen
863 @TaskGen.extension('.mm')
864 def mm_hook(self, node):
865     """Alias .mm files to be compiled the same as .cpp files, gcc will do the right thing."""
866     return self.create_compiled_task('cxx', node)