17 JACK_API_VERSION
= '0.1.0'
19 # these variables are mandatory ('/' are converted automatically)
23 def display_msg(msg
, status
= None, color
= None):
26 g_maxlen
= max(g_maxlen
, len(msg
))
28 Logs
.pprint('NORMAL', "%s :" % msg
.ljust(g_maxlen
), sep
=' ')
29 Logs
.pprint(color
, status
)
31 print("%s" % msg
.ljust(g_maxlen
))
33 def display_feature(msg
, build
):
35 display_msg(msg
, "yes", 'GREEN')
37 display_msg(msg
, "no", 'YELLOW')
39 def create_svnversion_task(bld
, header
='svnversion.h', define
=None):
40 import Constants
, Build
42 cmd
= '../svnversion_regenerate.sh ${TGT}'
46 cls
= Task
.simple_task_type('svnversion', cmd
, color
='BLUE', before
='cc')
47 cls
.runnable_status
= lambda self
: Constants
.RUN_ME
50 sg
= Utils
.h_file(self
.outputs
[0].abspath(self
.env
))
51 #print sg.encode('hex')
52 Build
.bld
.node_sigs
[self
.env
.variant()][self
.outputs
[0].id] = sg
53 cls
.post_run
= post_run
55 tsk
= cls(bld
.env
.copy())
57 tsk
.outputs
= [bld
.path
.find_or_declare(header
)]
60 # options provided by the modules
61 opt
.tool_options('compiler_cxx')
62 opt
.tool_options('compiler_cc')
64 opt
.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
65 opt
.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
66 opt
.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
67 opt
.add_option('--dbus', action
='store_true', default
=False, help='Enable D-Bus JACK (jackdbus)')
68 opt
.add_option('--classic', action
='store_true', default
=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
69 opt
.add_option('--doxygen', action
='store_true', default
=False, help='Enable build of doxygen documentation')
70 opt
.add_option('--profile', action
='store_true', default
=False, help='Build with engine profiling')
71 opt
.add_option('--mixed', action
='store_true', default
=False, help='Build with 32/64 bits mixed mode')
72 opt
.add_option('--clients', default
=64, type="int", dest
="clients", help='Maximum number of JACK clients')
73 opt
.add_option('--ports-per-application', default
=768, type="int", dest
="application_ports", help='Maximum number of ports per application')
74 opt
.add_option('--debug', action
='store_true', default
=False, dest
='debug', help='Build debuggable binaries')
75 opt
.add_option('--firewire', action
='store_true', default
=False, help='Enable FireWire driver (FFADO)')
76 opt
.add_option('--freebob', action
='store_true', default
=False, help='Enable FreeBob driver')
77 opt
.add_option('--alsa', action
='store_true', default
=False, help='Enable ALSA driver')
78 opt
.sub_options('dbus')
81 platform
= sys
.platform
82 conf
.env
['IS_MACOSX'] = platform
== 'darwin'
83 conf
.env
['IS_LINUX'] = platform
== 'linux' or platform
== 'linux2' or platform
== 'posix'
84 conf
.env
['IS_SUN'] = platform
== 'sunos'
86 if conf
.env
['IS_LINUX']:
87 Logs
.pprint('CYAN', "Linux detected")
89 if conf
.env
['IS_MACOSX']:
90 Logs
.pprint('CYAN', "MacOS X detected")
92 if conf
.env
['IS_SUN']:
93 Logs
.pprint('CYAN', "SunOS detected")
95 if conf
.env
['IS_LINUX']:
96 conf
.check_tool('compiler_cxx')
97 conf
.check_tool('compiler_cc')
99 if conf
.env
['IS_MACOSX']:
100 conf
.check_tool('compiler_cxx')
101 conf
.check_tool('compiler_cc')
103 # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
104 if conf
.env
['IS_SUN']:
105 conf
.check_tool('g++')
106 conf
.check_tool('gcc')
108 #if conf.env['IS_SUN']:
109 # conf.check_tool('compiler_cxx')
110 # conf.check_tool('compiler_cc')
112 conf
.env
.append_unique('CXXFLAGS', '-Wall')
113 conf
.env
.append_unique('CCFLAGS', '-Wall')
115 conf
.sub_config('common')
116 if conf
.env
['IS_LINUX']:
117 conf
.sub_config('linux')
118 if Options
.options
.alsa
and not conf
.env
['BUILD_DRIVER_ALSA']:
119 conf
.fatal('ALSA driver was explicitly requested but cannot be built')
120 if Options
.options
.freebob
and not conf
.env
['BUILD_DRIVER_FREEBOB']:
121 conf
.fatal('FreeBob driver was explicitly requested but cannot be built')
122 if Options
.options
.firewire
and not conf
.env
['BUILD_DRIVER_FFADO']:
123 conf
.fatal('FFADO driver was explicitly requested but cannot be built')
124 conf
.env
['BUILD_DRIVER_ALSA'] = Options
.options
.alsa
125 conf
.env
['BUILD_DRIVER_FFADO'] = Options
.options
.firewire
126 conf
.env
['BUILD_DRIVER_FREEBOB'] = Options
.options
.freebob
127 if Options
.options
.dbus
:
128 conf
.sub_config('dbus')
129 if conf
.env
['BUILD_JACKDBUS'] != True:
130 conf
.fatal('jackdbus was explicitly requested but cannot be built')
132 conf
.check_cc(header_name
='samplerate.h', define_name
="HAVE_SAMPLERATE")
134 if conf
.is_defined('HAVE_SAMPLERATE'):
135 conf
.env
['LIB_SAMPLERATE'] = ['samplerate']
137 conf
.sub_config('example-clients')
139 if conf
.check_cfg(package
='celt', atleast_version
='0.11.0', args
='--cflags --libs', mandatory
=False):
140 conf
.define('HAVE_CELT', 1)
141 conf
.define('HAVE_CELT_API_0_11', 1)
142 conf
.define('HAVE_CELT_API_0_8', 0)
143 conf
.define('HAVE_CELT_API_0_7', 0)
144 conf
.define('HAVE_CELT_API_0_5', 0)
145 elif conf
.check_cfg(package
='celt', atleast_version
='0.8.0', args
='--cflags --libs', mandatory
=False):
146 conf
.define('HAVE_CELT', 1)
147 conf
.define('HAVE_CELT_API_0_11', 0)
148 conf
.define('HAVE_CELT_API_0_8', 1)
149 conf
.define('HAVE_CELT_API_0_7', 0)
150 conf
.define('HAVE_CELT_API_0_5', 0)
151 elif conf
.check_cfg(package
='celt', atleast_version
='0.7.0', args
='--cflags --libs', mandatory
=False):
152 conf
.define('HAVE_CELT', 1)
153 conf
.define('HAVE_CELT_API_0_11', 0)
154 conf
.define('HAVE_CELT_API_0_8', 0)
155 conf
.define('HAVE_CELT_API_0_7', 1)
156 conf
.define('HAVE_CELT_API_0_5', 0)
157 elif conf
.check_cfg(package
='celt', atleast_version
='0.5.0', args
='--cflags --libs', mandatory
=False):
158 conf
.define('HAVE_CELT', 1)
159 conf
.define('HAVE_CELT_API_0_11', 0)
160 conf
.define('HAVE_CELT_API_0_8', 0)
161 conf
.define('HAVE_CELT_API_0_7', 0)
162 conf
.define('HAVE_CELT_API_0_5', 1)
164 conf
.define('HAVE_CELT', 0)
165 conf
.define('HAVE_CELT_API_0_11', 0)
166 conf
.define('HAVE_CELT_API_0_8', 0)
167 conf
.define('HAVE_CELT_API_0_7', 0)
168 conf
.define('HAVE_CELT_API_0_5', 0)
170 conf
.env
['LIB_PTHREAD'] = ['pthread']
171 conf
.env
['LIB_DL'] = ['dl']
172 conf
.env
['LIB_RT'] = ['rt']
173 conf
.env
['JACK_API_VERSION'] = JACK_API_VERSION
174 conf
.env
['JACK_VERSION'] = VERSION
176 conf
.env
['BUILD_DOXYGEN_DOCS'] = Options
.options
.doxygen
177 conf
.env
['BUILD_WITH_PROFILE'] = Options
.options
.profile
178 conf
.env
['BUILD_WITH_32_64'] = Options
.options
.mixed
179 conf
.env
['BUILD_CLASSIC'] = Options
.options
.classic
180 conf
.env
['BUILD_DEBUG'] = Options
.options
.debug
182 if conf
.env
['BUILD_JACKDBUS']:
183 conf
.env
['BUILD_JACKD'] = conf
.env
['BUILD_CLASSIC']
185 conf
.env
['BUILD_JACKD'] = True
187 if Options
.options
.libdir
:
188 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + Options
.options
.libdir
190 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib'
192 if Options
.options
.mandir
:
193 conf
.env
['MANDIR'] = conf
.env
['PREFIX'] + Options
.options
.mandir
195 conf
.env
['MANDIR'] = conf
.env
['PREFIX'] + '/share/man/man1'
197 if conf
.env
['BUILD_DEBUG']:
198 conf
.env
.append_unique('CXXFLAGS', '-g')
199 conf
.env
.append_unique('CCFLAGS', '-g')
200 conf
.env
.append_unique('LINKFLAGS', '-g')
202 conf
.define('CLIENT_NUM', Options
.options
.clients
)
203 conf
.define('PORT_NUM_FOR_CLIENT', Options
.options
.application_ports
)
205 conf
.define('ADDON_DIR', os
.path
.normpath(os
.path
.join(conf
.env
['LIBDIR'], 'jack')))
206 conf
.define('JACK_LOCATION', os
.path
.normpath(os
.path
.join(conf
.env
['PREFIX'], 'bin')))
207 conf
.define('USE_POSIX_SHM', 1)
208 conf
.define('JACKMP', 1)
209 if conf
.env
['BUILD_JACKDBUS'] == True:
210 conf
.define('JACK_DBUS', 1)
211 if conf
.env
['BUILD_JACKD'] == False:
212 conf
.define('USE_LIBDBUS_AUTOLAUNCH', 1)
213 if conf
.env
['BUILD_WITH_PROFILE'] == True:
214 conf
.define('JACK_MONITOR', 1)
215 if conf
.env
['BUILD_WITH_32_64'] == True:
216 conf
.define('JACK_32_64', 1)
217 conf
.write_config_header('config.h')
220 if os
.access('svnversion.h', os
.R_OK
):
221 data
= file('svnversion.h').read()
222 m
= re
.match(r
'^#define SVN_VERSION "([^"]*)"$', data
)
226 conf
.env
.append_unique('LINKFLAGS', '-lm -lstdc++')
228 if Options
.options
.mixed
== True:
229 env_variant2
= conf
.env
.copy()
230 conf
.set_env_name('lib32', env_variant2
)
231 env_variant2
.set_variant('lib32')
233 conf
.env
.append_unique('CXXFLAGS', '-m32')
234 conf
.env
.append_unique('CCFLAGS', '-m32')
235 conf
.env
.append_unique('LINKFLAGS', '-m32')
236 if Options
.options
.libdir32
:
237 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + Options
.options
.libdir32
239 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib32'
240 conf
.write_config_header('config.h')
243 display_msg("==================")
244 version_msg
= "JACK " + VERSION
246 version_msg
+= " exported from r" + svnrev
248 version_msg
+= " svn revision will checked and eventually updated during build"
251 print("Build with a maximum of %d JACK clients" % Options
.options
.clients
)
252 print("Build with a maximum of %d ports per application" % Options
.options
.application_ports
)
254 display_msg("Install prefix", conf
.env
['PREFIX'], 'CYAN')
255 display_msg("Library directory", conf
.env
['LIBDIR'], 'CYAN')
256 display_msg("Drivers directory", conf
.env
['ADDON_DIR'], 'CYAN')
257 display_feature('Build debuggable binaries', conf
.env
['BUILD_DEBUG'])
258 display_msg('C compiler flags', repr(conf
.env
['CCFLAGS']))
259 display_msg('C++ compiler flags', repr(conf
.env
['CXXFLAGS']))
260 display_msg('Linker flags', repr(conf
.env
['LINKFLAGS']))
261 display_feature('Build doxygen documentation', conf
.env
['BUILD_DOXYGEN_DOCS'])
262 display_feature('Build with engine profiling', conf
.env
['BUILD_WITH_PROFILE'])
263 display_feature('Build with 32/64 bits mixed mode', conf
.env
['BUILD_WITH_32_64'])
265 display_feature('Build standard JACK (jackd)', conf
.env
['BUILD_JACKD'])
266 display_feature('Build D-Bus JACK (jackdbus)', conf
.env
['BUILD_JACKDBUS'])
268 if conf
.env
['BUILD_JACKDBUS'] and conf
.env
['BUILD_JACKD']:
269 print(Logs
.colors
.RED
+ 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs
.colors
.NORMAL
)
270 print(Logs
.colors
.RED
+ 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs
.colors
.NORMAL
)
272 if conf
.env
['IS_LINUX']:
273 display_feature('Build with ALSA support', conf
.env
['BUILD_DRIVER_ALSA'] == True)
274 display_feature('Build with FireWire (FreeBob) support', conf
.env
['BUILD_DRIVER_FREEBOB'] == True)
275 display_feature('Build with FireWire (FFADO) support', conf
.env
['BUILD_DRIVER_FFADO'] == True)
277 if conf
.env
['BUILD_JACKDBUS'] == True:
278 display_msg('D-Bus service install directory', conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
279 #display_msg('Settings persistence', xxx)
281 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS_SERVICES_DIR_REAL']:
283 print(Logs
.colors
.RED
+ "WARNING: D-Bus session services directory as reported by pkg-config is")
284 print(Logs
.colors
.RED
+ "WARNING:", end
=' ')
285 print(Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR_REAL'])
286 print(Logs
.colors
.RED
+ 'WARNING: but service file will be installed in')
287 print(Logs
.colors
.RED
+ "WARNING:", end
=' ')
288 print(Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR'])
289 print(Logs
.colors
.RED
+ 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
290 print('WARNING: You can override dbus service install directory')
291 print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
292 print(Logs
.colors
.NORMAL
, end
=' ')
296 print(("make[1]: Entering directory `" + os
.getcwd() + "/" + blddir
+ "'" ))
297 if not os
.access('svnversion.h', os
.R_OK
):
298 create_svnversion_task(bld
)
300 # process subfolders from here
301 bld
.add_subdirs('common')
302 if bld
.env
['IS_LINUX']:
303 bld
.add_subdirs('linux')
304 bld
.add_subdirs('example-clients')
305 bld
.add_subdirs('tests')
306 bld
.add_subdirs('man')
307 if bld
.env
['BUILD_JACKDBUS'] == True:
308 bld
.add_subdirs('dbus')
310 if bld
.env
['IS_MACOSX']:
311 bld
.add_subdirs('macosx')
312 bld
.add_subdirs('example-clients')
313 bld
.add_subdirs('tests')
314 if bld
.env
['BUILD_JACKDBUS'] == True:
315 bld
.add_subdirs('dbus')
317 if bld
.env
['IS_SUN']:
318 bld
.add_subdirs('solaris')
319 bld
.add_subdirs('example-clients')
320 bld
.add_subdirs('tests')
321 if bld
.env
['BUILD_JACKDBUS'] == True:
322 bld
.add_subdirs('dbus')
324 if bld
.env
['BUILD_DOXYGEN_DOCS'] == True:
325 share_dir
= bld
.env
.get_destdir() + bld
.env
['PREFIX'] + '/share/jack-audio-connection-kit'
326 html_docs_source_dir
= "build/default/html"
327 html_docs_install_dir
= share_dir
+ '/reference/html/'
328 if Options
.commands
['install']:
329 if os
.path
.isdir(html_docs_install_dir
):
330 Logs
.pprint('CYAN', "Removing old doxygen documentation installation...")
331 shutil
.rmtree(html_docs_install_dir
)
332 Logs
.pprint('CYAN', "Removing old doxygen documentation installation done.")
333 Logs
.pprint('CYAN', "Installing doxygen documentation...")
334 shutil
.copytree(html_docs_source_dir
, html_docs_install_dir
)
335 Logs
.pprint('CYAN', "Installing doxygen documentation done.")
336 elif Options
.commands
['uninstall']:
337 Logs
.pprint('CYAN', "Uninstalling doxygen documentation...")
338 if os
.path
.isdir(share_dir
):
339 shutil
.rmtree(share_dir
)
340 Logs
.pprint('CYAN', "Uninstalling doxygen documentation done.")
341 elif Options
.commands
['clean']:
342 if os
.access(html_docs_source_dir
, os
.R_OK
):
343 Logs
.pprint('CYAN', "Removing doxygen generated documentation...")
344 shutil
.rmtree(html_docs_source_dir
)
345 Logs
.pprint('CYAN', "Removing doxygen generated documentation done.")
346 elif Options
.commands
['build']:
347 if not os
.access(html_docs_source_dir
, os
.R_OK
):
348 os
.popen("doxygen").read()
350 Logs
.pprint('CYAN', "doxygen documentation already built.")
353 os
.remove('svnversion_regenerate.sh')
354 os
.system('../svnversion_regenerate.sh svnversion.h')