3 from __future__
import print_function
17 from waflib
.Build
import BuildContext
, CleanContext
, InstallContext
, UninstallContext
21 JACK_API_VERSION
= '0.1.0'
23 # these variables are mandatory ('/' are converted automatically)
27 # lib32 variant name used when building in mixed mode
30 def display_msg(msg
, status
= None, color
= None):
33 g_maxlen
= max(g_maxlen
, len(msg
))
35 Logs
.pprint('NORMAL', "%s :" % msg
.ljust(g_maxlen
), sep
=' ')
36 Logs
.pprint(color
, status
)
38 print("%s" % msg
.ljust(g_maxlen
))
40 def display_feature(msg
, build
):
42 display_msg(msg
, "yes", 'GREEN')
44 display_msg(msg
, "no", 'YELLOW')
46 def create_svnversion_task(bld
, header
='svnversion.h', define
=None):
47 cmd
= '../svnversion_regenerate.sh ${TGT}'
52 sg
= Utils
.h_file(self
.outputs
[0].abspath(self
.env
))
53 #print sg.encode('hex')
54 Build
.bld
.node_sigs
[self
.env
.variant()][self
.outputs
[0].id] = sg
59 runnable_status
= Task
.RUN_ME
,
63 target
= [bld
.path
.find_or_declare(header
)]
67 # options provided by the modules
68 opt
.tool_options('compiler_cxx')
69 opt
.tool_options('compiler_cc')
71 opt
.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
72 opt
.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
73 opt
.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
74 opt
.add_option('--dbus', action
='store_true', default
=False, help='Enable D-Bus JACK (jackdbus)')
75 opt
.add_option('--dist-target', type='string', default
='auto', help='Specify the target for cross-compiling [auto,mingw]')
76 opt
.add_option('--classic', action
='store_true', default
=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
77 opt
.add_option('--doxygen', action
='store_true', default
=False, help='Enable build of doxygen documentation')
78 opt
.add_option('--profile', action
='store_true', default
=False, help='Build with engine profiling')
79 opt
.add_option('--mixed', action
='store_true', default
=False, help='Build with 32/64 bits mixed mode')
80 opt
.add_option('--clients', default
=64, type="int", dest
="clients", help='Maximum number of JACK clients')
81 opt
.add_option('--ports-per-application', default
=768, type="int", dest
="application_ports", help='Maximum number of ports per application')
82 opt
.add_option('--debug', action
='store_true', default
=False, dest
='debug', help='Build debuggable binaries')
83 opt
.add_option('--firewire', action
='store_true', default
=False, help='Enable FireWire driver (FFADO)')
84 opt
.add_option('--freebob', action
='store_true', default
=False, help='Enable FreeBob driver')
85 opt
.add_option('--alsa', action
='store_true', default
=False, help='Enable ALSA driver')
86 opt
.add_option('--autostart', type='string', default
="default", help='Autostart method. Possible values: "default", "classic", "dbus", "none"')
87 opt
.add_option('--portaudio', action
='store_true', default
=False, help='Enable Portaudio driver')
88 opt
.add_option('--winmme', action
='store_true', default
=False, help='Enable WinMME driver')
89 opt
.sub_options('dbus')
92 conf
.load('compiler_cxx')
93 conf
.load('compiler_cc')
94 if Options
.options
.dist_target
== 'auto':
95 platform
= sys
.platform
96 conf
.env
['IS_MACOSX'] = platform
== 'darwin'
97 conf
.env
['IS_LINUX'] = platform
== 'linux' or platform
== 'linux2' or platform
== 'linux3' or platform
== 'posix'
98 conf
.env
['IS_SUN'] = platform
== 'sunos'
99 # GNU/kFreeBSD and GNU/Hurd are treated as Linux
100 if platform
.startswith('gnu0') or platform
.startswith('gnukfreebsd'):
101 conf
.env
['IS_LINUX'] = True
102 elif Options
.options
.dist_target
== 'mingw':
103 conf
.env
['IS_WINDOWS'] = True
105 if conf
.env
['IS_LINUX']:
106 Logs
.pprint('CYAN', "Linux detected")
108 if conf
.env
['IS_MACOSX']:
109 Logs
.pprint('CYAN', "MacOS X detected")
111 if conf
.env
['IS_SUN']:
112 Logs
.pprint('CYAN', "SunOS detected")
114 if conf
.env
['IS_WINDOWS']:
115 Logs
.pprint('CYAN', "Windows detected")
117 if conf
.env
['IS_LINUX']:
118 conf
.check_tool('compiler_cxx')
119 conf
.check_tool('compiler_cc')
121 if conf
.env
['IS_MACOSX']:
122 conf
.check_tool('compiler_cxx')
123 conf
.check_tool('compiler_cc')
125 # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
126 if conf
.env
['IS_SUN']:
127 conf
.check_tool('g++')
128 conf
.check_tool('gcc')
130 #if conf.env['IS_SUN']:
131 # conf.check_tool('compiler_cxx')
132 # conf.check_tool('compiler_cc')
134 if conf
.env
['IS_WINDOWS']:
135 conf
.check_tool('compiler_cxx')
136 conf
.check_tool('compiler_cc')
137 conf
.env
.append_unique('CCDEFINES', '_POSIX')
138 conf
.env
.append_unique('CXXDEFINES', '_POSIX')
140 conf
.env
.append_unique('CXXFLAGS', '-Wall')
141 conf
.env
.append_unique('CFLAGS', '-Wall')
143 conf
.sub_config('common')
144 if conf
.env
['IS_LINUX']:
145 conf
.sub_config('linux')
146 if Options
.options
.alsa
and not conf
.env
['BUILD_DRIVER_ALSA']:
147 conf
.fatal('ALSA driver was explicitly requested but cannot be built')
148 if Options
.options
.freebob
and not conf
.env
['BUILD_DRIVER_FREEBOB']:
149 conf
.fatal('FreeBob driver was explicitly requested but cannot be built')
150 if Options
.options
.firewire
and not conf
.env
['BUILD_DRIVER_FFADO']:
151 conf
.fatal('FFADO driver was explicitly requested but cannot be built')
152 conf
.env
['BUILD_DRIVER_ALSA'] = Options
.options
.alsa
153 conf
.env
['BUILD_DRIVER_FFADO'] = Options
.options
.firewire
154 conf
.env
['BUILD_DRIVER_FREEBOB'] = Options
.options
.freebob
155 if conf
.env
['IS_WINDOWS']:
156 conf
.sub_config('windows')
157 if Options
.options
.portaudio
and not conf
.env
['BUILD_DRIVER_PORTAUDIO']:
158 conf
.fatal('Portaudio driver was explicitly requested but cannot be built')
159 conf
.env
['BUILD_DRIVER_WINMME'] = Options
.options
.winmme
160 if Options
.options
.dbus
:
161 conf
.sub_config('dbus')
162 if conf
.env
['BUILD_JACKDBUS'] != True:
163 conf
.fatal('jackdbus was explicitly requested but cannot be built')
165 conf
.check_cc(header_name
='samplerate.h', define_name
="HAVE_SAMPLERATE")
167 if conf
.is_defined('HAVE_SAMPLERATE'):
168 conf
.env
['LIB_SAMPLERATE'] = ['samplerate']
170 conf
.sub_config('example-clients')
172 if conf
.check_cfg(package
='celt', atleast_version
='0.11.0', args
='--cflags --libs', mandatory
=False):
173 conf
.define('HAVE_CELT', 1)
174 conf
.define('HAVE_CELT_API_0_11', 1)
175 conf
.define('HAVE_CELT_API_0_8', 0)
176 conf
.define('HAVE_CELT_API_0_7', 0)
177 conf
.define('HAVE_CELT_API_0_5', 0)
178 elif conf
.check_cfg(package
='celt', atleast_version
='0.8.0', args
='--cflags --libs', mandatory
=False):
179 conf
.define('HAVE_CELT', 1)
180 conf
.define('HAVE_CELT_API_0_11', 0)
181 conf
.define('HAVE_CELT_API_0_8', 1)
182 conf
.define('HAVE_CELT_API_0_7', 0)
183 conf
.define('HAVE_CELT_API_0_5', 0)
184 elif conf
.check_cfg(package
='celt', atleast_version
='0.7.0', args
='--cflags --libs', mandatory
=False):
185 conf
.define('HAVE_CELT', 1)
186 conf
.define('HAVE_CELT_API_0_11', 0)
187 conf
.define('HAVE_CELT_API_0_8', 0)
188 conf
.define('HAVE_CELT_API_0_7', 1)
189 conf
.define('HAVE_CELT_API_0_5', 0)
190 elif conf
.check_cfg(package
='celt', atleast_version
='0.5.0', args
='--cflags --libs', mandatory
=False):
191 conf
.define('HAVE_CELT', 1)
192 conf
.define('HAVE_CELT_API_0_11', 0)
193 conf
.define('HAVE_CELT_API_0_8', 0)
194 conf
.define('HAVE_CELT_API_0_7', 0)
195 conf
.define('HAVE_CELT_API_0_5', 1)
197 conf
.define('HAVE_CELT', 0)
198 conf
.define('HAVE_CELT_API_0_11', 0)
199 conf
.define('HAVE_CELT_API_0_8', 0)
200 conf
.define('HAVE_CELT_API_0_7', 0)
201 conf
.define('HAVE_CELT_API_0_5', 0)
203 conf
.env
['WITH_OPUS'] = False
204 if conf
.check_cfg(package
='opus', atleast_version
='0.9.0' , args
='--cflags --libs', mandatory
=False):
205 if conf
.check_cc(header_name
='opus/opus_custom.h', mandatory
=False):
206 conf
.define('HAVE_OPUS', 1)
207 conf
.env
['WITH_OPUS'] = True
209 conf
.define('HAVE_OPUS', 0)
212 conf
.env
['LIB_PTHREAD'] = ['pthread']
213 conf
.env
['LIB_DL'] = ['dl']
214 conf
.env
['LIB_RT'] = ['rt']
215 conf
.env
['LIB_M'] = ['m']
216 conf
.env
['LIB_STDC++'] = ['stdc++']
217 conf
.env
['JACK_API_VERSION'] = JACK_API_VERSION
218 conf
.env
['JACK_VERSION'] = VERSION
220 conf
.env
['BUILD_DOXYGEN_DOCS'] = Options
.options
.doxygen
221 conf
.env
['BUILD_WITH_PROFILE'] = Options
.options
.profile
222 conf
.env
['BUILD_WITH_32_64'] = Options
.options
.mixed
223 conf
.env
['BUILD_CLASSIC'] = Options
.options
.classic
224 conf
.env
['BUILD_DEBUG'] = Options
.options
.debug
226 if conf
.env
['BUILD_JACKDBUS']:
227 conf
.env
['BUILD_JACKD'] = conf
.env
['BUILD_CLASSIC']
229 conf
.env
['BUILD_JACKD'] = True
231 conf
.env
['BINDIR'] = conf
.env
['PREFIX'] + '/bin'
233 if Options
.options
.libdir
:
234 conf
.env
['LIBDIR'] = Options
.options
.libdir
236 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib'
238 if Options
.options
.mandir
:
239 conf
.env
['MANDIR'] = Options
.options
.mandir
241 conf
.env
['MANDIR'] = conf
.env
['PREFIX'] + '/share/man/man1'
243 if conf
.env
['BUILD_DEBUG']:
244 conf
.env
.append_unique('CXXFLAGS', '-g')
245 conf
.env
.append_unique('CFLAGS', '-g')
246 conf
.env
.append_unique('LINKFLAGS', '-g')
248 if not Options
.options
.autostart
in ["default", "classic", "dbus", "none"]:
249 conf
.fatal("Invalid autostart value \"" + Options
.options
.autostart
+ "\"")
251 if Options
.options
.autostart
== "default":
252 if conf
.env
['BUILD_JACKDBUS'] == True and conf
.env
['BUILD_JACKD'] == False:
253 conf
.env
['AUTOSTART_METHOD'] = "dbus"
255 conf
.env
['AUTOSTART_METHOD'] = "classic"
257 conf
.env
['AUTOSTART_METHOD'] = Options
.options
.autostart
259 if conf
.env
['AUTOSTART_METHOD'] == "dbus" and not conf
.env
['BUILD_JACKDBUS']:
260 conf
.fatal("D-Bus autostart mode was specified but jackdbus will not be built")
261 if conf
.env
['AUTOSTART_METHOD'] == "classic" and not conf
.env
['BUILD_JACKD']:
262 conf
.fatal("Classic autostart mode was specified but jackd will not be built")
264 if conf
.env
['AUTOSTART_METHOD'] == "dbus":
265 conf
.define('USE_LIBDBUS_AUTOLAUNCH', 1)
266 elif conf
.env
['AUTOSTART_METHOD'] == "classic":
267 conf
.define('USE_CLASSIC_AUTOLAUNCH', 1)
269 conf
.define('CLIENT_NUM', Options
.options
.clients
)
270 conf
.define('PORT_NUM_FOR_CLIENT', Options
.options
.application_ports
)
272 if conf
.env
['IS_WINDOWS']:
273 # we define this in the environment to maintain compatability with
274 # existing install paths that use ADDON_DIR rather than have to
275 # have special cases for windows each time.
276 conf
.env
['ADDON_DIR'] = conf
.env
['BINDIR'] + '/jack'
277 # don't define ADDON_DIR in config.h, use the default 'jack' defined in
278 # windows/JackPlatformPlug_os.h
280 conf
.env
['ADDON_DIR'] = os
.path
.normpath(os
.path
.join(conf
.env
['LIBDIR'], 'jack'))
281 conf
.define('ADDON_DIR', conf
.env
['ADDON_DIR'])
282 conf
.define('JACK_LOCATION', os
.path
.normpath(os
.path
.join(conf
.env
['PREFIX'], 'bin')))
284 if not conf
.env
['IS_WINDOWS']:
285 conf
.define('USE_POSIX_SHM', 1)
286 conf
.define('JACKMP', 1)
287 if conf
.env
['BUILD_JACKDBUS'] == True:
288 conf
.define('JACK_DBUS', 1)
289 if conf
.env
['BUILD_WITH_PROFILE'] == True:
290 conf
.define('JACK_MONITOR', 1)
291 conf
.write_config_header('config.h', remove
=False)
294 if os
.access('svnversion.h', os
.R_OK
):
295 data
= file('svnversion.h').read()
296 m
= re
.match(r
'^#define SVN_VERSION "([^"]*)"$', data
)
300 if Options
.options
.mixed
== True:
301 conf
.setenv(lib32
, env
=conf
.env
.derive())
302 conf
.env
.append_unique('CXXFLAGS', '-m32')
303 conf
.env
.append_unique('CFLAGS', '-m32')
304 conf
.env
.append_unique('LINKFLAGS', '-m32')
305 if Options
.options
.libdir32
:
306 conf
.env
['LIBDIR'] = Options
.options
.libdir32
308 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib32'
309 conf
.write_config_header('config.h')
312 display_msg("==================")
313 version_msg
= "JACK " + VERSION
315 version_msg
+= " exported from r" + svnrev
317 version_msg
+= " svn revision will checked and eventually updated during build"
320 print("Build with a maximum of %d JACK clients" % Options
.options
.clients
)
321 print("Build with a maximum of %d ports per application" % Options
.options
.application_ports
)
323 display_msg("Install prefix", conf
.env
['PREFIX'], 'CYAN')
324 display_msg("Library directory", conf
.all_envs
[""]['LIBDIR'], 'CYAN')
325 if conf
.env
['BUILD_WITH_32_64'] == True:
326 display_msg("32-bit library directory", conf
.all_envs
[lib32
]['LIBDIR'], 'CYAN')
327 display_msg("Drivers directory", conf
.env
['ADDON_DIR'], 'CYAN')
328 display_feature('Build debuggable binaries', conf
.env
['BUILD_DEBUG'])
329 display_msg('C compiler flags', repr(conf
.all_envs
[""]['CFLAGS']))
330 display_msg('C++ compiler flags', repr(conf
.all_envs
[""]['CXXFLAGS']))
331 display_msg('Linker flags', repr(conf
.all_envs
[""]['LINKFLAGS']))
332 if conf
.env
['BUILD_WITH_32_64'] == True:
333 display_msg('32-bit C compiler flags', repr(conf
.all_envs
[lib32
]['CFLAGS']))
334 display_msg('32-bit C++ compiler flags', repr(conf
.all_envs
[lib32
]['CXXFLAGS']))
335 display_msg('32-bit linker flags', repr(conf
.all_envs
[lib32
]['LINKFLAGS']))
336 display_feature('Build doxygen documentation', conf
.env
['BUILD_DOXYGEN_DOCS'])
337 display_feature('Build Opus netjack2', conf
.env
['WITH_OPUS'])
338 display_feature('Build with engine profiling', conf
.env
['BUILD_WITH_PROFILE'])
339 display_feature('Build with 32/64 bits mixed mode', conf
.env
['BUILD_WITH_32_64'])
341 display_feature('Build standard JACK (jackd)', conf
.env
['BUILD_JACKD'])
342 display_feature('Build D-Bus JACK (jackdbus)', conf
.env
['BUILD_JACKDBUS'])
343 display_msg('Autostart method', conf
.env
['AUTOSTART_METHOD'])
345 if conf
.env
['BUILD_JACKDBUS'] and conf
.env
['BUILD_JACKD']:
346 print(Logs
.colors
.RED
+ 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs
.colors
.NORMAL
)
347 print(Logs
.colors
.RED
+ 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs
.colors
.NORMAL
)
349 if conf
.env
['IS_LINUX']:
350 display_feature('Build with ALSA support', conf
.env
['BUILD_DRIVER_ALSA'] == True)
351 display_feature('Build with FireWire (FreeBob) support', conf
.env
['BUILD_DRIVER_FREEBOB'] == True)
352 display_feature('Build with FireWire (FFADO) support', conf
.env
['BUILD_DRIVER_FFADO'] == True)
354 if conf
.env
['IS_WINDOWS']:
355 display_feature('Build with WinMME support', conf
.env
['BUILD_DRIVER_WINMME'] == True)
356 display_feature('Build with Portaudio support', conf
.env
['BUILD_DRIVER_PORTAUDIO'] == True)
358 if conf
.env
['BUILD_JACKDBUS'] == True:
359 display_msg('D-Bus service install directory', conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
360 #display_msg('Settings persistence', xxx)
362 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS_SERVICES_DIR_REAL']:
364 print(Logs
.colors
.RED
+ "WARNING: D-Bus session services directory as reported by pkg-config is")
365 print(Logs
.colors
.RED
+ "WARNING:", end
=' ')
366 print(Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR_REAL'])
367 print(Logs
.colors
.RED
+ 'WARNING: but service file will be installed in')
368 print(Logs
.colors
.RED
+ "WARNING:", end
=' ')
369 print(Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR'])
370 print(Logs
.colors
.RED
+ 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
371 print('WARNING: You can override dbus service install directory')
372 print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
373 print(Logs
.colors
.NORMAL
, end
=' ')
377 for y
in (BuildContext
, CleanContext
, InstallContext
, UninstallContext
):
378 name
= y
.__name
__.replace('Context','').lower()
380 cmd
= name
+ '_' + lib32
387 out2
= out
+ "/" + bld
.variant
388 print("make[1]: Entering directory `" + os
.getcwd() + "/" + out2
+ "'")
391 if not os
.access('svnversion.h', os
.R_OK
):
392 create_svnversion_task(bld
)
393 if bld
.env
['BUILD_WITH_32_64'] == True:
394 waflib
.Options
.commands
.append(bld
.cmd
+ '_' + lib32
)
396 # process subfolders from here
397 bld
.add_subdirs('common')
400 # only the wscript in common/ knows how to handle variants
403 if bld
.env
['IS_LINUX']:
404 bld
.add_subdirs('linux')
405 bld
.add_subdirs('example-clients')
406 bld
.add_subdirs('tests')
407 bld
.add_subdirs('man')
408 if bld
.env
['BUILD_JACKDBUS'] == True:
409 bld
.add_subdirs('dbus')
411 if bld
.env
['IS_MACOSX']:
412 bld
.add_subdirs('macosx')
413 bld
.add_subdirs('example-clients')
414 bld
.add_subdirs('tests')
415 if bld
.env
['BUILD_JACKDBUS'] == True:
416 bld
.add_subdirs('dbus')
418 if bld
.env
['IS_SUN']:
419 bld
.add_subdirs('solaris')
420 bld
.add_subdirs('example-clients')
421 bld
.add_subdirs('tests')
422 if bld
.env
['BUILD_JACKDBUS'] == True:
423 bld
.add_subdirs('dbus')
425 if bld
.env
['IS_WINDOWS']:
426 bld
.add_subdirs('windows')
427 bld
.add_subdirs('example-clients')
428 #bld.add_subdirs('tests')
430 if bld
.env
['BUILD_DOXYGEN_DOCS'] == True:
431 html_docs_source_dir
= "build/default/html"
432 if bld
.cmd
== 'install':
433 share_dir
= bld
.options
.destdir
+ bld
.env
['PREFIX'] + '/share/jack-audio-connection-kit'
434 html_docs_install_dir
= share_dir
+ '/reference/html/'
435 if os
.path
.isdir(html_docs_install_dir
):
436 Logs
.pprint('CYAN', "Removing old doxygen documentation installation...")
437 shutil
.rmtree(html_docs_install_dir
)
438 Logs
.pprint('CYAN', "Removing old doxygen documentation installation done.")
439 Logs
.pprint('CYAN', "Installing doxygen documentation...")
440 shutil
.copytree(html_docs_source_dir
, html_docs_install_dir
)
441 Logs
.pprint('CYAN', "Installing doxygen documentation done.")
442 elif bld
.cmd
=='uninstall':
443 Logs
.pprint('CYAN', "Uninstalling doxygen documentation...")
444 if os
.path
.isdir(share_dir
):
445 shutil
.rmtree(share_dir
)
446 Logs
.pprint('CYAN', "Uninstalling doxygen documentation done.")
447 elif bld
.cmd
=='clean':
448 if os
.access(html_docs_source_dir
, os
.R_OK
):
449 Logs
.pprint('CYAN', "Removing doxygen generated documentation...")
450 shutil
.rmtree(html_docs_source_dir
)
451 Logs
.pprint('CYAN', "Removing doxygen generated documentation done.")
452 elif bld
.cmd
=='build':
453 if not os
.access(html_docs_source_dir
, os
.R_OK
):
454 os
.popen("doxygen").read()
456 Logs
.pprint('CYAN', "doxygen documentation already built.")
459 os
.remove('svnversion_regenerate.sh')
460 os
.system('../svnversion_regenerate.sh svnversion.h')