16 JACK_API_VERSION
= '0.1.0'
18 # these variables are mandatory ('/' are converted automatically)
22 def display_msg(msg
, status
= None, color
= None):
25 g_maxlen
= max(g_maxlen
, len(msg
))
27 print "%s :" % msg
.ljust(g_maxlen
),
28 Utils
.pprint(color
, status
)
30 print "%s" % msg
.ljust(g_maxlen
)
32 def display_feature(msg
, build
):
34 display_msg(msg
, "yes", 'GREEN')
36 display_msg(msg
, "no", 'YELLOW')
38 def create_svnversion_task(bld
, header
='svnversion.h', define
=None):
39 import Constants
, Build
41 cmd
= '../svnversion_regenerate.sh ${TGT}'
45 cls
= Task
.simple_task_type('svnversion', cmd
, color
='BLUE', before
='cc')
46 cls
.runnable_status
= lambda self
: Constants
.RUN_ME
49 sg
= Utils
.h_file(self
.outputs
[0].abspath(self
.env
))
50 #print sg.encode('hex')
51 Build
.bld
.node_sigs
[self
.env
.variant()][self
.outputs
[0].id] = sg
52 cls
.post_run
= post_run
54 tsk
= cls(bld
.env
.copy())
56 tsk
.outputs
= [bld
.path
.find_or_declare(header
)]
59 # options provided by the modules
60 opt
.tool_options('compiler_cxx')
61 opt
.tool_options('compiler_cc')
63 opt
.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
64 opt
.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
65 opt
.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
66 opt
.add_option('--dbus', action
='store_true', default
=False, help='Enable D-Bus JACK (jackdbus)')
67 opt
.add_option('--classic', action
='store_true', default
=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
68 opt
.add_option('--doxygen', action
='store_true', default
=False, help='Enable build of doxygen documentation')
69 opt
.add_option('--profile', action
='store_true', default
=False, help='Build with engine profiling')
70 opt
.add_option('--mixed', action
='store_true', default
=False, help='Build with 32/64 bits mixed mode')
71 opt
.add_option('--clients', default
=64, type="int", dest
="clients", help='Maximum number of JACK clients')
72 opt
.add_option('--ports-per-application', default
=768, type="int", dest
="application_ports", help='Maximum number of ports per application')
73 opt
.add_option('--debug', action
='store_true', default
=False, dest
='debug', help='Build debuggable binaries')
74 opt
.add_option('--firewire', action
='store_true', default
=False, help='Enable FireWire driver (FFADO)')
75 opt
.add_option('--freebob', action
='store_true', default
=False, help='Enable FreeBob driver')
76 opt
.add_option('--alsa', action
='store_true', default
=False, help='Enable ALSA driver')
77 opt
.sub_options('dbus')
80 platform
= Utils
.detect_platform()
81 conf
.env
['IS_MACOSX'] = platform
== 'darwin'
82 conf
.env
['IS_LINUX'] = platform
== 'linux' or platform
== 'posix'
83 conf
.env
['IS_SUN'] = platform
== 'sunos'
85 if conf
.env
['IS_LINUX']:
86 Utils
.pprint('CYAN', "Linux detected")
88 if conf
.env
['IS_MACOSX']:
89 Utils
.pprint('CYAN', "MacOS X detected")
91 if conf
.env
['IS_SUN']:
92 Utils
.pprint('CYAN', "SunOS detected")
94 if conf
.env
['IS_LINUX']:
95 conf
.check_tool('compiler_cxx')
96 conf
.check_tool('compiler_cc')
98 if conf
.env
['IS_MACOSX']:
99 conf
.check_tool('compiler_cxx')
100 conf
.check_tool('compiler_cc')
102 # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
103 if conf
.env
['IS_SUN']:
104 conf
.check_tool('g++')
105 conf
.check_tool('gcc')
107 #if conf.env['IS_SUN']:
108 # conf.check_tool('compiler_cxx')
109 # conf.check_tool('compiler_cc')
111 conf
.env
.append_unique('CXXFLAGS', '-Wall')
112 conf
.env
.append_unique('CCFLAGS', '-Wall')
114 conf
.sub_config('common')
115 if conf
.env
['IS_LINUX']:
116 conf
.sub_config('linux')
117 if Options
.options
.alsa
and not conf
.env
['BUILD_DRIVER_ALSA']:
118 conf
.fatal('ALSA driver was explicitly requested but cannot be built')
119 if Options
.options
.freebob
and not conf
.env
['BUILD_DRIVER_FREEBOB']:
120 conf
.fatal('FreeBob driver was explicitly requested but cannot be built')
121 if Options
.options
.firewire
and not conf
.env
['BUILD_DRIVER_FFADO']:
122 conf
.fatal('FFADO driver was explicitly requested but cannot be built')
123 conf
.env
['BUILD_DRIVER_ALSA'] = Options
.options
.alsa
124 conf
.env
['BUILD_DRIVER_FFADO'] = Options
.options
.firewire
125 conf
.env
['BUILD_DRIVER_FREEBOB'] = Options
.options
.freebob
126 if Options
.options
.dbus
:
127 conf
.sub_config('dbus')
128 if conf
.env
['BUILD_JACKDBUS'] != True:
129 conf
.fatal('jackdbus was explicitly requested but cannot be built')
130 conf
.sub_config('example-clients')
132 if conf
.check_cfg(package
='celt', atleast_version
='0.8.0', args
='--cflags --libs'):
133 conf
.define('HAVE_CELT', 1)
134 conf
.define('HAVE_CELT_API_0_8', 1)
135 conf
.define('HAVE_CELT_API_0_7', 0)
136 conf
.define('HAVE_CELT_API_0_5', 0)
137 elif conf
.check_cfg(package
='celt', atleast_version
='0.7.0', args
='--cflags --libs'):
138 conf
.define('HAVE_CELT', 1)
139 conf
.define('HAVE_CELT_API_0_8', 0)
140 conf
.define('HAVE_CELT_API_0_7', 1)
141 conf
.define('HAVE_CELT_API_0_5', 0)
142 elif conf
.check_cfg(package
='celt', atleast_version
='0.5.0', args
='--cflags --libs', required
=True):
143 conf
.define('HAVE_CELT', 1)
144 conf
.define('HAVE_CELT_API_0_8', 0)
145 conf
.define('HAVE_CELT_API_0_7', 0)
146 conf
.define('HAVE_CELT_API_0_5', 1)
148 conf
.define('HAVE_CELT', 0)
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)
153 conf
.env
['LIB_PTHREAD'] = ['pthread']
154 conf
.env
['LIB_DL'] = ['dl']
155 conf
.env
['LIB_RT'] = ['rt']
156 conf
.env
['JACK_API_VERSION'] = JACK_API_VERSION
157 conf
.env
['JACK_VERSION'] = VERSION
159 conf
.env
['BUILD_DOXYGEN_DOCS'] = Options
.options
.doxygen
160 conf
.env
['BUILD_WITH_PROFILE'] = Options
.options
.profile
161 conf
.env
['BUILD_WITH_32_64'] = Options
.options
.mixed
162 conf
.env
['BUILD_CLASSIC'] = Options
.options
.classic
163 conf
.env
['BUILD_DEBUG'] = Options
.options
.debug
165 if conf
.env
['BUILD_JACKDBUS']:
166 conf
.env
['BUILD_JACKD'] = conf
.env
['BUILD_CLASSIC']
168 conf
.env
['BUILD_JACKD'] = True
170 if Options
.options
.libdir
:
171 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + Options
.options
.libdir
173 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib'
175 if Options
.options
.mandir
:
176 conf
.env
['MANDIR'] = conf
.env
['PREFIX'] + Options
.options
.mandir
178 conf
.env
['MANDIR'] = conf
.env
['PREFIX'] + '/share/man/man1'
180 if conf
.env
['BUILD_DEBUG']:
181 conf
.env
.append_unique('CXXFLAGS', '-g')
182 conf
.env
.append_unique('CCFLAGS', '-g')
183 conf
.env
.append_unique('LINKFLAGS', '-g')
185 conf
.define('CLIENT_NUM', Options
.options
.clients
)
186 conf
.define('PORT_NUM_FOR_CLIENT', Options
.options
.application_ports
)
188 conf
.define('ADDON_DIR', os
.path
.normpath(os
.path
.join(conf
.env
['LIBDIR'], 'jack')))
189 conf
.define('JACK_LOCATION', os
.path
.normpath(os
.path
.join(conf
.env
['PREFIX'], 'bin')))
190 conf
.define('USE_POSIX_SHM', 1)
191 conf
.define('JACKMP', 1)
192 if conf
.env
['BUILD_JACKDBUS'] == True:
193 conf
.define('JACK_DBUS', 1)
194 if conf
.env
['BUILD_JACKD'] == False:
195 conf
.define('USE_LIBDBUS_AUTOLAUNCH', 1)
196 if conf
.env
['BUILD_WITH_PROFILE'] == True:
197 conf
.define('JACK_MONITOR', 1)
198 if conf
.env
['BUILD_WITH_32_64'] == True:
199 conf
.define('JACK_32_64', 1)
200 conf
.write_config_header('config.h')
203 if os
.access('svnversion.h', os
.R_OK
):
204 data
= file('svnversion.h').read()
205 m
= re
.match(r
'^#define SVN_VERSION "([^"]*)"$', data
)
209 conf
.env
.append_unique('LINKFLAGS', '-lm -lstdc++')
211 if Options
.options
.mixed
== True:
212 env_variant2
= conf
.env
.copy()
213 conf
.set_env_name('lib32', env_variant2
)
214 env_variant2
.set_variant('lib32')
216 conf
.env
.append_unique('CXXFLAGS', '-m32')
217 conf
.env
.append_unique('CCFLAGS', '-m32')
218 conf
.env
.append_unique('LINKFLAGS', '-m32')
219 if Options
.options
.libdir32
:
220 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + Options
.options
.libdir32
222 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib32'
223 conf
.write_config_header('config.h')
226 display_msg("==================")
227 version_msg
= "JACK " + VERSION
229 version_msg
+= " exported from r" + svnrev
231 version_msg
+= " svn revision will checked and eventually updated during build"
234 print "Build with a maximum of %d JACK clients" % conf
.env
['CLIENT_NUM']
235 print "Build with a maximum of %d ports per application" % conf
.env
['PORT_NUM_FOR_CLIENT']
237 display_msg("Install prefix", conf
.env
['PREFIX'], 'CYAN')
238 display_msg("Library directory", conf
.env
['LIBDIR'], 'CYAN')
239 display_msg("Drivers directory", conf
.env
['ADDON_DIR'], 'CYAN')
240 display_feature('Build debuggable binaries', conf
.env
['BUILD_DEBUG'])
241 display_msg('C compiler flags', repr(conf
.env
['CCFLAGS']))
242 display_msg('C++ compiler flags', repr(conf
.env
['CXXFLAGS']))
243 display_msg('Linker flags', repr(conf
.env
['LINKFLAGS']))
244 display_feature('Build doxygen documentation', conf
.env
['BUILD_DOXYGEN_DOCS'])
245 display_feature('Build with engine profiling', conf
.env
['BUILD_WITH_PROFILE'])
246 display_feature('Build with 32/64 bits mixed mode', conf
.env
['BUILD_WITH_32_64'])
248 display_feature('Build standard JACK (jackd)', conf
.env
['BUILD_JACKD'])
249 display_feature('Build D-Bus JACK (jackdbus)', conf
.env
['BUILD_JACKDBUS'])
251 if conf
.env
['BUILD_JACKDBUS'] and conf
.env
['BUILD_JACKD']:
252 print Logs
.colors
.RED
+ 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs
.colors
.NORMAL
253 print Logs
.colors
.RED
+ 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs
.colors
.NORMAL
255 if conf
.env
['IS_LINUX']:
256 display_feature('Build with ALSA support', conf
.env
['BUILD_DRIVER_ALSA'] == True)
257 display_feature('Build with FireWire (FreeBob) support', conf
.env
['BUILD_DRIVER_FREEBOB'] == True)
258 display_feature('Build with FireWire (FFADO) support', conf
.env
['BUILD_DRIVER_FFADO'] == True)
260 if conf
.env
['BUILD_JACKDBUS'] == True:
261 display_msg('D-Bus service install directory', conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
262 #display_msg('Settings persistence', xxx)
264 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS_SERVICES_DIR_REAL']:
266 print Logs
.colors
.RED
+ "WARNING: D-Bus session services directory as reported by pkg-config is"
267 print Logs
.colors
.RED
+ "WARNING:",
268 print Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR_REAL']
269 print Logs
.colors
.RED
+ 'WARNING: but service file will be installed in'
270 print Logs
.colors
.RED
+ "WARNING:",
271 print Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR']
272 print Logs
.colors
.RED
+ 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
273 print 'WARNING: You can override dbus service install directory'
274 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
275 print Logs
.colors
.NORMAL
,
279 print ("make[1]: Entering directory `" + os
.getcwd() + "/" + blddir
+ "'" )
280 if not os
.access('svnversion.h', os
.R_OK
):
281 create_svnversion_task(bld
)
283 # process subfolders from here
284 bld
.add_subdirs('common')
285 if bld
.env
['IS_LINUX']:
286 bld
.add_subdirs('linux')
287 bld
.add_subdirs('example-clients')
288 bld
.add_subdirs('tests')
289 bld
.add_subdirs('man')
290 if bld
.env
['BUILD_JACKDBUS'] == True:
291 bld
.add_subdirs('dbus')
293 if bld
.env
['IS_MACOSX']:
294 bld
.add_subdirs('macosx')
295 bld
.add_subdirs('example-clients')
296 bld
.add_subdirs('tests')
297 if bld
.env
['BUILD_JACKDBUS'] == True:
298 bld
.add_subdirs('dbus')
300 if bld
.env
['IS_SUN']:
301 bld
.add_subdirs('solaris')
302 bld
.add_subdirs('example-clients')
303 bld
.add_subdirs('tests')
304 if bld
.env
['BUILD_JACKDBUS'] == True:
305 bld
.add_subdirs('dbus')
307 if bld
.env
['BUILD_DOXYGEN_DOCS'] == True:
308 share_dir
= bld
.env
.get_destdir() + bld
.env
['PREFIX'] + '/share/jack-audio-connection-kit'
309 html_docs_source_dir
= "build/default/html"
310 html_docs_install_dir
= share_dir
+ '/reference/html/'
311 if Options
.commands
['install']:
312 if os
.path
.isdir(html_docs_install_dir
):
313 Utils
.pprint('CYAN', "Removing old doxygen documentation installation...")
314 shutil
.rmtree(html_docs_install_dir
)
315 Utils
.pprint('CYAN', "Removing old doxygen documentation installation done.")
316 Utils
.pprint('CYAN', "Installing doxygen documentation...")
317 shutil
.copytree(html_docs_source_dir
, html_docs_install_dir
)
318 Utils
.pprint('CYAN', "Installing doxygen documentation done.")
319 elif Options
.commands
['uninstall']:
320 Utils
.pprint('CYAN', "Uninstalling doxygen documentation...")
321 if os
.path
.isdir(share_dir
):
322 shutil
.rmtree(share_dir
)
323 Utils
.pprint('CYAN', "Uninstalling doxygen documentation done.")
324 elif Options
.commands
['clean']:
325 if os
.access(html_docs_source_dir
, os
.R_OK
):
326 Utils
.pprint('CYAN', "Removing doxygen generated documentation...")
327 shutil
.rmtree(html_docs_source_dir
)
328 Utils
.pprint('CYAN', "Removing doxygen generated documentation done.")
329 elif Options
.commands
['build']:
330 if not os
.access(html_docs_source_dir
, os
.R_OK
):
331 os
.popen("doxygen").read()
333 Utils
.pprint('CYAN', "doxygen documentation already built.")
336 os
.remove('svnversion_regenerate.sh')
337 os
.system('../svnversion_regenerate.sh svnversion.h')