3 from __future__
import print_function
18 JACK_API_VERSION
= '0.1.0'
20 # these variables are mandatory ('/' are converted automatically)
24 def display_msg(msg
, status
= None, color
= None):
27 g_maxlen
= max(g_maxlen
, len(msg
))
29 Logs
.pprint('NORMAL', "%s :" % msg
.ljust(g_maxlen
), sep
=' ')
30 Logs
.pprint(color
, status
)
32 print("%s" % msg
.ljust(g_maxlen
))
34 def display_feature(msg
, build
):
36 display_msg(msg
, "yes", 'GREEN')
38 display_msg(msg
, "no", 'YELLOW')
40 def create_svnversion_task(bld
, header
='svnversion.h', define
=None):
41 cmd
= '../svnversion_regenerate.sh ${TGT}'
46 sg
= Utils
.h_file(self
.outputs
[0].abspath(self
.env
))
47 #print sg.encode('hex')
48 Build
.bld
.node_sigs
[self
.env
.variant()][self
.outputs
[0].id] = sg
53 runnable_status
= Task
.RUN_ME
,
57 target
= [bld
.path
.find_or_declare(header
)]
61 # options provided by the modules
62 opt
.tool_options('compiler_cxx')
63 opt
.tool_options('compiler_cc')
65 opt
.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
66 opt
.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
67 opt
.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
68 opt
.add_option('--dbus', action
='store_true', default
=False, help='Enable D-Bus JACK (jackdbus)')
69 opt
.add_option('--classic', action
='store_true', default
=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
70 opt
.add_option('--doxygen', action
='store_true', default
=False, help='Enable build of doxygen documentation')
71 opt
.add_option('--profile', action
='store_true', default
=False, help='Build with engine profiling')
72 opt
.add_option('--mixed', action
='store_true', default
=False, help='Build with 32/64 bits mixed mode')
73 opt
.add_option('--clients', default
=64, type="int", dest
="clients", help='Maximum number of JACK clients')
74 opt
.add_option('--ports-per-application', default
=768, type="int", dest
="application_ports", help='Maximum number of ports per application')
75 opt
.add_option('--debug', action
='store_true', default
=False, dest
='debug', help='Build debuggable binaries')
76 opt
.add_option('--firewire', action
='store_true', default
=False, help='Enable FireWire driver (FFADO)')
77 opt
.add_option('--freebob', action
='store_true', default
=False, help='Enable FreeBob driver')
78 opt
.add_option('--alsa', action
='store_true', default
=False, help='Enable ALSA driver')
79 opt
.add_option('--autostart', type='string', default
="default", help='Autostart method. Possible values: "default", "classic", "dbus", "none"')
80 opt
.sub_options('dbus')
83 conf
.load('compiler_cxx')
84 conf
.load('compiler_cc')
85 platform
= sys
.platform
86 conf
.env
['IS_MACOSX'] = platform
== 'darwin'
87 conf
.env
['IS_LINUX'] = platform
== 'linux' or platform
== 'linux2' or platform
== 'linux3' or platform
== 'posix'
88 conf
.env
['IS_SUN'] = platform
== 'sunos'
89 # GNU/kFreeBSD and GNU/Hurd are treated as Linux
90 if platform
.startswith('gnu0') or platform
.startswith('gnukfreebsd'):
91 conf
.env
['IS_LINUX'] = True
93 if conf
.env
['IS_LINUX']:
94 Logs
.pprint('CYAN', "Linux detected")
96 if conf
.env
['IS_MACOSX']:
97 Logs
.pprint('CYAN', "MacOS X detected")
99 if conf
.env
['IS_SUN']:
100 Logs
.pprint('CYAN', "SunOS detected")
102 if conf
.env
['IS_LINUX']:
103 conf
.check_tool('compiler_cxx')
104 conf
.check_tool('compiler_cc')
106 if conf
.env
['IS_MACOSX']:
107 conf
.check_tool('compiler_cxx')
108 conf
.check_tool('compiler_cc')
110 # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
111 if conf
.env
['IS_SUN']:
112 conf
.check_tool('g++')
113 conf
.check_tool('gcc')
115 #if conf.env['IS_SUN']:
116 # conf.check_tool('compiler_cxx')
117 # conf.check_tool('compiler_cc')
119 conf
.env
.append_unique('CXXFLAGS', '-Wall')
120 conf
.env
.append_unique('CFLAGS', '-Wall')
122 conf
.sub_config('common')
123 if conf
.env
['IS_LINUX']:
124 conf
.sub_config('linux')
125 if Options
.options
.alsa
and not conf
.env
['BUILD_DRIVER_ALSA']:
126 conf
.fatal('ALSA driver was explicitly requested but cannot be built')
127 if Options
.options
.freebob
and not conf
.env
['BUILD_DRIVER_FREEBOB']:
128 conf
.fatal('FreeBob driver was explicitly requested but cannot be built')
129 if Options
.options
.firewire
and not conf
.env
['BUILD_DRIVER_FFADO']:
130 conf
.fatal('FFADO driver was explicitly requested but cannot be built')
131 conf
.env
['BUILD_DRIVER_ALSA'] = Options
.options
.alsa
132 conf
.env
['BUILD_DRIVER_FFADO'] = Options
.options
.firewire
133 conf
.env
['BUILD_DRIVER_FREEBOB'] = Options
.options
.freebob
134 if Options
.options
.dbus
:
135 conf
.sub_config('dbus')
136 if conf
.env
['BUILD_JACKDBUS'] != True:
137 conf
.fatal('jackdbus was explicitly requested but cannot be built')
139 conf
.check_cc(header_name
='samplerate.h', define_name
="HAVE_SAMPLERATE")
141 if conf
.is_defined('HAVE_SAMPLERATE'):
142 conf
.env
['LIB_SAMPLERATE'] = ['samplerate']
144 conf
.sub_config('example-clients')
146 if conf
.check_cfg(package
='celt', atleast_version
='0.11.0', args
='--cflags --libs', mandatory
=False):
147 conf
.define('HAVE_CELT', 1)
148 conf
.define('HAVE_CELT_API_0_11', 1)
149 conf
.define('HAVE_CELT_API_0_8', 0)
150 conf
.define('HAVE_CELT_API_0_7', 0)
151 conf
.define('HAVE_CELT_API_0_5', 0)
152 elif conf
.check_cfg(package
='celt', atleast_version
='0.8.0', args
='--cflags --libs', mandatory
=False):
153 conf
.define('HAVE_CELT', 1)
154 conf
.define('HAVE_CELT_API_0_11', 0)
155 conf
.define('HAVE_CELT_API_0_8', 1)
156 conf
.define('HAVE_CELT_API_0_7', 0)
157 conf
.define('HAVE_CELT_API_0_5', 0)
158 elif conf
.check_cfg(package
='celt', atleast_version
='0.7.0', args
='--cflags --libs', mandatory
=False):
159 conf
.define('HAVE_CELT', 1)
160 conf
.define('HAVE_CELT_API_0_11', 0)
161 conf
.define('HAVE_CELT_API_0_8', 0)
162 conf
.define('HAVE_CELT_API_0_7', 1)
163 conf
.define('HAVE_CELT_API_0_5', 0)
164 elif conf
.check_cfg(package
='celt', atleast_version
='0.5.0', args
='--cflags --libs', mandatory
=False):
165 conf
.define('HAVE_CELT', 1)
166 conf
.define('HAVE_CELT_API_0_11', 0)
167 conf
.define('HAVE_CELT_API_0_8', 0)
168 conf
.define('HAVE_CELT_API_0_7', 0)
169 conf
.define('HAVE_CELT_API_0_5', 1)
171 conf
.define('HAVE_CELT', 0)
172 conf
.define('HAVE_CELT_API_0_11', 0)
173 conf
.define('HAVE_CELT_API_0_8', 0)
174 conf
.define('HAVE_CELT_API_0_7', 0)
175 conf
.define('HAVE_CELT_API_0_5', 0)
177 conf
.env
['WITH_OPUS'] = False
178 if conf
.check_cfg(package
='opus', atleast_version
='0.9.0' , args
='--cflags --libs', mandatory
=False):
179 if conf
.check_cc(header_name
='opus/opus_custom.h', mandatory
=False):
180 conf
.define('HAVE_OPUS', 1)
181 conf
.env
['WITH_OPUS'] = True
183 conf
.define('HAVE_OPUS', 0)
186 conf
.env
['LIB_PTHREAD'] = ['pthread']
187 conf
.env
['LIB_DL'] = ['dl']
188 conf
.env
['LIB_RT'] = ['rt']
189 conf
.env
['LIB_M'] = ['m']
190 conf
.env
['LIB_STDC++'] = ['stdc++']
191 conf
.env
['JACK_API_VERSION'] = JACK_API_VERSION
192 conf
.env
['JACK_VERSION'] = VERSION
194 conf
.env
['BUILD_DOXYGEN_DOCS'] = Options
.options
.doxygen
195 conf
.env
['BUILD_WITH_PROFILE'] = Options
.options
.profile
196 conf
.env
['BUILD_WITH_32_64'] = Options
.options
.mixed
197 conf
.env
['BUILD_CLASSIC'] = Options
.options
.classic
198 conf
.env
['BUILD_DEBUG'] = Options
.options
.debug
200 if conf
.env
['BUILD_JACKDBUS']:
201 conf
.env
['BUILD_JACKD'] = conf
.env
['BUILD_CLASSIC']
203 conf
.env
['BUILD_JACKD'] = True
205 if Options
.options
.libdir
:
206 conf
.env
['LIBDIR'] = Options
.options
.libdir
208 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib'
210 if Options
.options
.mandir
:
211 conf
.env
['MANDIR'] = Options
.options
.mandir
213 conf
.env
['MANDIR'] = conf
.env
['PREFIX'] + '/share/man/man1'
215 if conf
.env
['BUILD_DEBUG']:
216 conf
.env
.append_unique('CXXFLAGS', '-g')
217 conf
.env
.append_unique('CFLAGS', '-g')
218 conf
.env
.append_unique('LINKFLAGS', '-g')
220 if not Options
.options
.autostart
in ["default", "classic", "dbus", "none"]:
221 conf
.fatal("Invalid autostart value \"" + Options
.options
.autostart
+ "\"")
223 if Options
.options
.autostart
== "default":
224 if conf
.env
['BUILD_JACKDBUS'] == True and conf
.env
['BUILD_JACKD'] == False:
225 conf
.env
['AUTOSTART_METHOD'] = "dbus"
227 conf
.env
['AUTOSTART_METHOD'] = "classic"
229 conf
.env
['AUTOSTART_METHOD'] = Options
.options
.autostart
231 if conf
.env
['AUTOSTART_METHOD'] == "dbus" and not conf
.env
['BUILD_JACKDBUS']:
232 conf
.fatal("D-Bus autostart mode was specified but jackdbus will not be built")
233 if conf
.env
['AUTOSTART_METHOD'] == "classic" and not conf
.env
['BUILD_JACKD']:
234 conf
.fatal("Classic autostart mode was specified but jackd will not be built")
236 if conf
.env
['AUTOSTART_METHOD'] == "dbus":
237 conf
.define('USE_LIBDBUS_AUTOLAUNCH', 1)
238 elif conf
.env
['AUTOSTART_METHOD'] == "classic":
239 conf
.define('USE_CLASSIC_AUTOLAUNCH', 1)
241 conf
.define('CLIENT_NUM', Options
.options
.clients
)
242 conf
.define('PORT_NUM_FOR_CLIENT', Options
.options
.application_ports
)
244 conf
.env
['ADDON_DIR'] = os
.path
.normpath(os
.path
.join(conf
.env
['LIBDIR'], 'jack'))
245 conf
.define('ADDON_DIR', conf
.env
['ADDON_DIR'])
246 conf
.define('JACK_LOCATION', os
.path
.normpath(os
.path
.join(conf
.env
['PREFIX'], 'bin')))
247 conf
.define('USE_POSIX_SHM', 1)
248 conf
.define('JACKMP', 1)
249 if conf
.env
['BUILD_JACKDBUS'] == True:
250 conf
.define('JACK_DBUS', 1)
251 if conf
.env
['BUILD_WITH_PROFILE'] == True:
252 conf
.define('JACK_MONITOR', 1)
253 conf
.write_config_header('config.h', remove
=False)
256 if os
.access('svnversion.h', os
.R_OK
):
257 data
= file('svnversion.h').read()
258 m
= re
.match(r
'^#define SVN_VERSION "([^"]*)"$', data
)
262 if Options
.options
.mixed
== True:
263 env_variant2
= conf
.env
.copy()
264 conf
.set_env_name('lib32', env_variant2
)
265 env_variant2
.set_variant('lib32')
267 conf
.env
.append_unique('CXXFLAGS', '-m32')
268 conf
.env
.append_unique('CFLAGS', '-m32')
269 conf
.env
.append_unique('LINKFLAGS', '-m32')
270 if Options
.options
.libdir32
:
271 conf
.env
['LIBDIR'] = Options
.options
.libdir32
273 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib32'
274 conf
.write_config_header('config.h')
277 display_msg("==================")
278 version_msg
= "JACK " + VERSION
280 version_msg
+= " exported from r" + svnrev
282 version_msg
+= " svn revision will checked and eventually updated during build"
285 print("Build with a maximum of %d JACK clients" % Options
.options
.clients
)
286 print("Build with a maximum of %d ports per application" % Options
.options
.application_ports
)
288 display_msg("Install prefix", conf
.env
['PREFIX'], 'CYAN')
289 display_msg("Library directory", conf
.env
['LIBDIR'], 'CYAN')
290 display_msg("Drivers directory", conf
.env
['ADDON_DIR'], 'CYAN')
291 display_feature('Build debuggable binaries', conf
.env
['BUILD_DEBUG'])
292 display_msg('C compiler flags', repr(conf
.env
['CFLAGS']))
293 display_msg('C++ compiler flags', repr(conf
.env
['CXXFLAGS']))
294 display_msg('Linker flags', repr(conf
.env
['LINKFLAGS']))
295 display_feature('Build doxygen documentation', conf
.env
['BUILD_DOXYGEN_DOCS'])
296 display_feature('Build Opus netjack2', conf
.env
['WITH_OPUS'])
297 display_feature('Build with engine profiling', conf
.env
['BUILD_WITH_PROFILE'])
298 display_feature('Build with 32/64 bits mixed mode', conf
.env
['BUILD_WITH_32_64'])
300 display_feature('Build standard JACK (jackd)', conf
.env
['BUILD_JACKD'])
301 display_feature('Build D-Bus JACK (jackdbus)', conf
.env
['BUILD_JACKDBUS'])
302 display_msg('Autostart method', conf
.env
['AUTOSTART_METHOD'])
304 if conf
.env
['BUILD_JACKDBUS'] and conf
.env
['BUILD_JACKD']:
305 print(Logs
.colors
.RED
+ 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs
.colors
.NORMAL
)
306 print(Logs
.colors
.RED
+ 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs
.colors
.NORMAL
)
308 if conf
.env
['IS_LINUX']:
309 display_feature('Build with ALSA support', conf
.env
['BUILD_DRIVER_ALSA'] == True)
310 display_feature('Build with FireWire (FreeBob) support', conf
.env
['BUILD_DRIVER_FREEBOB'] == True)
311 display_feature('Build with FireWire (FFADO) support', conf
.env
['BUILD_DRIVER_FFADO'] == True)
313 if conf
.env
['BUILD_JACKDBUS'] == True:
314 display_msg('D-Bus service install directory', conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
315 #display_msg('Settings persistence', xxx)
317 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS_SERVICES_DIR_REAL']:
319 print(Logs
.colors
.RED
+ "WARNING: D-Bus session services directory as reported by pkg-config is")
320 print(Logs
.colors
.RED
+ "WARNING:", end
=' ')
321 print(Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR_REAL'])
322 print(Logs
.colors
.RED
+ 'WARNING: but service file will be installed in')
323 print(Logs
.colors
.RED
+ "WARNING:", end
=' ')
324 print(Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR'])
325 print(Logs
.colors
.RED
+ 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
326 print('WARNING: You can override dbus service install directory')
327 print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
328 print(Logs
.colors
.NORMAL
, end
=' ')
332 print("make[1]: Entering directory `" + os
.getcwd() + "/" + out
+ "'")
333 if not os
.access('svnversion.h', os
.R_OK
):
334 create_svnversion_task(bld
)
336 # process subfolders from here
337 bld
.add_subdirs('common')
338 if bld
.env
['IS_LINUX']:
339 bld
.add_subdirs('linux')
340 bld
.add_subdirs('example-clients')
341 bld
.add_subdirs('tests')
342 bld
.add_subdirs('man')
343 if bld
.env
['BUILD_JACKDBUS'] == True:
344 bld
.add_subdirs('dbus')
346 if bld
.env
['IS_MACOSX']:
347 bld
.add_subdirs('macosx')
348 bld
.add_subdirs('example-clients')
349 bld
.add_subdirs('tests')
350 if bld
.env
['BUILD_JACKDBUS'] == True:
351 bld
.add_subdirs('dbus')
353 if bld
.env
['IS_SUN']:
354 bld
.add_subdirs('solaris')
355 bld
.add_subdirs('example-clients')
356 bld
.add_subdirs('tests')
357 if bld
.env
['BUILD_JACKDBUS'] == True:
358 bld
.add_subdirs('dbus')
360 if bld
.env
['BUILD_DOXYGEN_DOCS'] == True:
361 html_docs_source_dir
= "build/default/html"
362 if bld
.cmd
== 'install':
363 share_dir
= bld
.options
.destdir
+ bld
.env
['PREFIX'] + '/share/jack-audio-connection-kit'
364 html_docs_install_dir
= share_dir
+ '/reference/html/'
365 if os
.path
.isdir(html_docs_install_dir
):
366 Logs
.pprint('CYAN', "Removing old doxygen documentation installation...")
367 shutil
.rmtree(html_docs_install_dir
)
368 Logs
.pprint('CYAN', "Removing old doxygen documentation installation done.")
369 Logs
.pprint('CYAN', "Installing doxygen documentation...")
370 shutil
.copytree(html_docs_source_dir
, html_docs_install_dir
)
371 Logs
.pprint('CYAN', "Installing doxygen documentation done.")
372 elif bld
.cmd
=='uninstall':
373 Logs
.pprint('CYAN', "Uninstalling doxygen documentation...")
374 if os
.path
.isdir(share_dir
):
375 shutil
.rmtree(share_dir
)
376 Logs
.pprint('CYAN', "Uninstalling doxygen documentation done.")
377 elif bld
.cmd
=='clean':
378 if os
.access(html_docs_source_dir
, os
.R_OK
):
379 Logs
.pprint('CYAN', "Removing doxygen generated documentation...")
380 shutil
.rmtree(html_docs_source_dir
)
381 Logs
.pprint('CYAN', "Removing doxygen generated documentation done.")
382 elif bld
.cmd
=='build':
383 if not os
.access(html_docs_source_dir
, os
.R_OK
):
384 os
.popen("doxygen").read()
386 Logs
.pprint('CYAN', "doxygen documentation already built.")
389 os
.remove('svnversion_regenerate.sh')
390 os
.system('../svnversion_regenerate.sh svnversion.h')