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('--dbus', action
='store_true', default
=False, help='Enable D-Bus JACK (jackdbus)')
66 opt
.add_option('--classic', action
='store_true', default
=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
67 opt
.add_option('--doxygen', action
='store_true', default
=False, help='Enable build of doxygen documentation')
68 opt
.add_option('--profile', action
='store_true', default
=False, help='Build with engine profiling')
69 opt
.add_option('--mixed', action
='store_true', default
=False, help='Build with 32/64 bits mixed mode')
70 opt
.add_option('--clients', default
=64, type="int", dest
="clients", help='Maximum number of JACK clients')
71 opt
.add_option('--ports-per-application', default
=768, type="int", dest
="application_ports", help='Maximum number of ports per application')
72 opt
.add_option('--debug', action
='store_true', default
=False, dest
='debug', help='Build debuggable binaries')
73 opt
.add_option('--firewire', action
='store_true', default
=False, help='Enable FireWire driver (FFADO)')
74 opt
.add_option('--freebob', action
='store_true', default
=False, help='Enable FreeBob driver')
75 opt
.add_option('--alsa', action
='store_true', default
=False, help='Enable ALSA driver')
76 opt
.sub_options('dbus')
79 platform
= Utils
.detect_platform()
80 conf
.env
['IS_MACOSX'] = platform
== 'darwin'
81 conf
.env
['IS_LINUX'] = platform
== 'linux'
82 conf
.env
['IS_SUN'] = platform
== 'sunos'
84 if conf
.env
['IS_LINUX']:
85 Utils
.pprint('CYAN', "Linux detected")
87 if conf
.env
['IS_MACOSX']:
88 Utils
.pprint('CYAN', "MacOS X detected")
90 if conf
.env
['IS_SUN']:
91 Utils
.pprint('CYAN', "SunOS detected")
93 if conf
.env
['IS_LINUX']:
94 conf
.check_tool('compiler_cxx')
95 conf
.check_tool('compiler_cc')
97 if conf
.env
['IS_MACOSX']:
98 conf
.check_tool('compiler_cxx')
99 conf
.check_tool('compiler_cc')
101 # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
102 if conf
.env
['IS_SUN']:
103 conf
.check_tool('g++')
104 conf
.check_tool('gcc')
106 #if conf.env['IS_SUN']:
107 # conf.check_tool('compiler_cxx')
108 # conf.check_tool('compiler_cc')
110 conf
.env
.append_unique('CXXFLAGS', '-O3 -Wall')
111 conf
.env
.append_unique('CCFLAGS', '-O3 -Wall')
113 conf
.sub_config('common')
114 if conf
.env
['IS_LINUX']:
115 conf
.sub_config('linux')
116 if Options
.options
.alsa
and not conf
.env
['BUILD_DRIVER_ALSA']:
117 conf
.fatal('ALSA driver was explicitly requested but cannot be built')
118 if Options
.options
.freebob
and not conf
.env
['BUILD_DRIVER_FREEBOB']:
119 conf
.fatal('FreeBob driver was explicitly requested but cannot be built')
120 if Options
.options
.firewire
and not conf
.env
['BUILD_DRIVER_FFADO']:
121 conf
.fatal('FFADO driver was explicitly requested but cannot be built')
122 conf
.env
['BUILD_DRIVER_ALSA'] = Options
.options
.alsa
123 conf
.env
['BUILD_DRIVER_FFADO'] = Options
.options
.firewire
124 conf
.env
['BUILD_DRIVER_FREEBOB'] = Options
.options
.freebob
125 if Options
.options
.dbus
:
126 conf
.sub_config('dbus')
127 if conf
.env
['BUILD_JACKDBUS'] != True:
128 conf
.fatal('jackdbus was explicitly requested but cannot be built')
129 conf
.sub_config('example-clients')
131 if conf
.check_cfg(package
='celt', atleast_version
='0.7.0', args
='--cflags --libs'):
132 conf
.define('HAVE_CELT', 1)
133 conf
.define('HAVE_CELT_API_0_7', 1)
134 conf
.define('HAVE_CELT_API_0_5', 0)
135 elif conf
.check_cfg(package
='celt', atleast_version
='0.5.0', args
='--cflags --libs', required
=True):
136 conf
.define('HAVE_CELT', 1)
137 conf
.define('HAVE_CELT_API_0_5', 1)
138 conf
.define('HAVE_CELT_API_0_7', 0)
140 conf
.define('HAVE_CELT', 0)
141 conf
.define('HAVE_CELT_API_0_5', 0)
142 conf
.define('HAVE_CELT_API_0_7', 0)
144 conf
.env
['LIB_PTHREAD'] = ['pthread']
145 conf
.env
['LIB_DL'] = ['dl']
146 conf
.env
['LIB_RT'] = ['rt']
147 conf
.env
['JACK_API_VERSION'] = JACK_API_VERSION
148 conf
.env
['JACK_VERSION'] = VERSION
150 conf
.env
['BUILD_DOXYGEN_DOCS'] = Options
.options
.doxygen
151 conf
.env
['BUILD_WITH_PROFILE'] = Options
.options
.profile
152 conf
.env
['BUILD_WITH_32_64'] = Options
.options
.mixed
153 conf
.env
['BUILD_CLASSIC'] = Options
.options
.classic
154 conf
.env
['BUILD_DEBUG'] = Options
.options
.debug
156 if conf
.env
['BUILD_JACKDBUS']:
157 conf
.env
['BUILD_JACKD'] = conf
.env
['BUILD_CLASSIC']
159 conf
.env
['BUILD_JACKD'] = True
161 if Options
.options
.libdir
:
162 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + Options
.options
.libdir
164 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib'
166 if conf
.env
['BUILD_DEBUG']:
167 conf
.env
.append_unique('CXXFLAGS', '-g')
168 conf
.env
.append_unique('CCFLAGS', '-g')
169 conf
.env
.append_unique('LINKFLAGS', '-g')
171 conf
.define('CLIENT_NUM', Options
.options
.clients
)
172 conf
.define('PORT_NUM_FOR_CLIENT', Options
.options
.application_ports
)
174 conf
.define('ADDON_DIR', os
.path
.normpath(os
.path
.join(conf
.env
['LIBDIR'], 'jack')))
175 conf
.define('JACK_LOCATION', os
.path
.normpath(os
.path
.join(conf
.env
['PREFIX'], 'bin')))
176 conf
.define('USE_POSIX_SHM', 1)
177 conf
.define('JACKMP', 1)
178 if conf
.env
['BUILD_JACKDBUS'] == True:
179 conf
.define('JACK_DBUS', 1)
180 if conf
.env
['BUILD_JACKD'] == False:
181 conf
.define('USE_LIBDBUS_AUTOLAUNCH', 1)
182 if conf
.env
['BUILD_WITH_PROFILE'] == True:
183 conf
.define('JACK_MONITOR', 1)
184 if conf
.env
['BUILD_WITH_32_64'] == True:
185 conf
.define('JACK_32_64', 1)
186 conf
.write_config_header('config.h')
189 if os
.access('svnversion.h', os
.R_OK
):
190 data
= file('svnversion.h').read()
191 m
= re
.match(r
'^#define SVN_VERSION "([^"]*)"$', data
)
196 display_msg("==================")
197 version_msg
= "JACK " + VERSION
199 version_msg
+= " exported from r" + svnrev
201 version_msg
+= " svn revision will checked and eventually updated during build"
204 print "Build with a maximum of %d JACK clients" % conf
.env
['CLIENT_NUM']
205 print "Build with a maximum of %d ports per application" % conf
.env
['PORT_NUM_FOR_CLIENT']
207 display_msg("Install prefix", conf
.env
['PREFIX'], 'CYAN')
208 display_msg("Library directory", conf
.env
['LIBDIR'], 'CYAN')
209 display_msg("Drivers directory", conf
.env
['ADDON_DIR'], 'CYAN')
210 display_feature('Build debuggable binaries', conf
.env
['BUILD_DEBUG'])
211 display_feature('Build doxygen documentation', conf
.env
['BUILD_DOXYGEN_DOCS'])
212 display_feature('Build with engine profiling', conf
.env
['BUILD_WITH_PROFILE'])
213 display_feature('Build with 32/64 bits mixed mode', conf
.env
['BUILD_WITH_32_64'])
215 display_feature('Build standard JACK (jackd)', conf
.env
['BUILD_JACKD'])
216 display_feature('Build D-Bus JACK (jackdbus)', conf
.env
['BUILD_JACKDBUS'])
218 if conf
.env
['BUILD_JACKDBUS'] and conf
.env
['BUILD_JACKD']:
219 print Logs
.colors
.RED
+ 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs
.colors
.NORMAL
220 print Logs
.colors
.RED
+ 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs
.colors
.NORMAL
222 if conf
.env
['IS_LINUX']:
223 display_feature('Build with ALSA support', conf
.env
['BUILD_DRIVER_ALSA'] == True)
224 display_feature('Build with FireWire (FreeBob) support', conf
.env
['BUILD_DRIVER_FREEBOB'] == True)
225 display_feature('Build with FireWire (FFADO) support', conf
.env
['BUILD_DRIVER_FFADO'] == True)
227 if conf
.env
['BUILD_JACKDBUS'] == True:
228 display_msg('D-Bus service install directory', conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
229 #display_msg('Settings persistence', xxx)
231 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS_SERVICES_DIR_REAL']:
233 print Logs
.colors
.RED
+ "WARNING: D-Bus session services directory as reported by pkg-config is"
234 print Logs
.colors
.RED
+ "WARNING:",
235 print Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR_REAL']
236 print Logs
.colors
.RED
+ 'WARNING: but service file will be installed in'
237 print Logs
.colors
.RED
+ "WARNING:",
238 print Logs
.colors
.CYAN
+ conf
.env
['DBUS_SERVICES_DIR']
239 print Logs
.colors
.RED
+ 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
240 print 'WARNING: You can override dbus service install directory'
241 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
242 print Logs
.colors
.NORMAL
,
245 if Options
.options
.mixed
== True:
246 env_variant2
= conf
.env
.copy()
247 conf
.set_env_name('lib32', env_variant2
)
248 env_variant2
.set_variant('lib32')
250 conf
.env
.append_unique('CXXFLAGS', '-m32')
251 conf
.env
.append_unique('CCFLAGS', '-m32')
252 conf
.env
.append_unique('LINKFLAGS', '-m32')
253 if Options
.options
.libdir32
:
254 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + Options
.options
.libdir32
256 conf
.env
['LIBDIR'] = conf
.env
['PREFIX'] + '/lib32'
257 conf
.write_config_header('config.h')
260 print ("make[1]: Entering directory `" + os
.getcwd() + "/" + blddir
+ "'" )
261 if not os
.access('svnversion.h', os
.R_OK
):
262 create_svnversion_task(bld
)
264 # process subfolders from here
265 bld
.add_subdirs('common')
266 if bld
.env
['IS_LINUX']:
267 bld
.add_subdirs('linux')
268 bld
.add_subdirs('example-clients')
269 bld
.add_subdirs('tests')
270 if bld
.env
['BUILD_JACKDBUS'] == True:
271 bld
.add_subdirs('dbus')
273 if bld
.env
['IS_MACOSX']:
274 bld
.add_subdirs('macosx')
275 bld
.add_subdirs('example-clients')
276 bld
.add_subdirs('tests')
277 if bld
.env
['BUILD_JACKDBUS'] == True:
278 bld
.add_subdirs('dbus')
280 if bld
.env
['IS_SUN']:
281 bld
.add_subdirs('solaris')
282 bld
.add_subdirs('example-clients')
283 bld
.add_subdirs('tests')
284 if bld
.env
['BUILD_JACKDBUS'] == True:
285 bld
.add_subdirs('dbus')
287 if bld
.env
['BUILD_DOXYGEN_DOCS'] == True:
288 share_dir
= bld
.env
.get_destdir() + bld
.env
['PREFIX'] + '/share/jack-audio-connection-kit'
289 html_docs_source_dir
= "build/default/html"
290 html_docs_install_dir
= share_dir
+ '/reference/html/'
291 if Options
.commands
['install']:
292 if os
.path
.isdir(html_docs_install_dir
):
293 Utils
.pprint('CYAN', "Removing old doxygen documentation installation...")
294 shutil
.rmtree(html_docs_install_dir
)
295 Utils
.pprint('CYAN', "Removing old doxygen documentation installation done.")
296 Utils
.pprint('CYAN', "Installing doxygen documentation...")
297 shutil
.copytree(html_docs_source_dir
, html_docs_install_dir
)
298 Utils
.pprint('CYAN', "Installing doxygen documentation done.")
299 elif Options
.commands
['uninstall']:
300 Utils
.pprint('CYAN', "Uninstalling doxygen documentation...")
301 if os
.path
.isdir(share_dir
):
302 shutil
.rmtree(share_dir
)
303 Utils
.pprint('CYAN', "Uninstalling doxygen documentation done.")
304 elif Options
.commands
['clean']:
305 if os
.access(html_docs_source_dir
, os
.R_OK
):
306 Utils
.pprint('CYAN', "Removing doxygen generated documentation...")
307 shutil
.rmtree(html_docs_source_dir
)
308 Utils
.pprint('CYAN', "Removing doxygen generated documentation done.")
309 elif Options
.commands
['build']:
310 if not os
.access(html_docs_source_dir
, os
.R_OK
):
311 os
.popen("doxygen").read()
313 Utils
.pprint('CYAN', "doxygen documentation already built.")
316 os
.remove('svnversion_regenerate.sh')
317 os
.system('../svnversion_regenerate.sh svnversion.h')