Use jack_client_open instead of old jack_client_new.
[jack2.git] / wscript
blobeaf40fca9a4f7a44089a47d59d1a86453fdcdcfc
1 #! /usr/bin/env python
2 # encoding: utf-8
4 import os
5 import Utils
6 import Options
7 import commands
8 g_maxlen = 40
9 import shutil
10 import Task
11 import re
12 import Logs
14 VERSION='1.9.4'
15 APPNAME='jack'
16 JACK_API_VERSION = '0.1.0'
18 # these variables are mandatory ('/' are converted automatically)
19 srcdir = '.'
20 blddir = 'build'
22 def display_msg(msg, status = None, color = None):
23 sr = msg
24 global g_maxlen
25 g_maxlen = max(g_maxlen, len(msg))
26 if status:
27 print "%s :" % msg.ljust(g_maxlen),
28 Utils.pprint(color, status)
29 else:
30 print "%s" % msg.ljust(g_maxlen)
32 def display_feature(msg, build):
33 if build:
34 display_msg(msg, "yes", 'GREEN')
35 else:
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}'
42 if define:
43 cmd += " " + define
45 cls = Task.simple_task_type('svnversion', cmd, color='BLUE', before='cc')
46 cls.runnable_status = lambda self: Constants.RUN_ME
48 def post_run(self):
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())
55 tsk.inputs = []
56 tsk.outputs = [bld.path.find_or_declare(header)]
58 def set_options(opt):
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', default=2048, type="int", dest="ports", help='Maximum number of ports')
72 opt.add_option('--ports-per-application', default=512, type="int", dest="application_ports", help='Maximum number of ports per application')
73 opt.sub_options('dbus')
75 def configure(conf):
76 platform = Utils.detect_platform()
77 conf.env['IS_MACOSX'] = platform == 'darwin'
78 conf.env['IS_LINUX'] = platform == 'linux'
79 conf.env['IS_SUN'] = platform == 'sunos'
81 if conf.env['IS_LINUX']:
82 Utils.pprint('CYAN', "Linux detected")
84 if conf.env['IS_MACOSX']:
85 Utils.pprint('CYAN', "MacOS X detected")
87 if conf.env['IS_SUN']:
88 Utils.pprint('CYAN', "SunOS detected")
90 if conf.env['IS_LINUX']:
91 conf.check_tool('compiler_cxx')
92 conf.check_tool('compiler_cc')
94 if conf.env['IS_MACOSX']:
95 conf.check_tool('compiler_cxx')
96 conf.check_tool('compiler_cc')
98 # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
99 if conf.env['IS_SUN']:
100 conf.check_tool('g++')
101 conf.check_tool('gcc')
103 #if conf.env['IS_SUN']:
104 # conf.check_tool('compiler_cxx')
105 # conf.check_tool('compiler_cc')
107 conf.env.append_unique('CXXFLAGS', '-O3 -Wall')
108 conf.env.append_unique('CCFLAGS', '-O3 -Wall')
110 conf.sub_config('common')
111 if conf.env['IS_LINUX']:
112 conf.sub_config('linux')
113 if Options.options.dbus:
114 conf.sub_config('dbus')
115 conf.sub_config('example-clients')
117 if conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs'):
118 conf.define('HAVE_CELT', 1)
119 conf.define('HAVE_CELT_API_0_7', 1)
120 conf.define('HAVE_CELT_API_0_5', 0)
121 elif conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', required=True):
122 conf.define('HAVE_CELT', 1)
123 conf.define('HAVE_CELT_API_0_5', 1)
124 conf.define('HAVE_CELT_API_0_7', 0)
125 else:
126 conf.define('HAVE_CELT', 0)
127 conf.define('HAVE_CELT_API_0_5', 0)
128 conf.define('HAVE_CELT_API_0_7', 0)
130 conf.env['LIB_PTHREAD'] = ['pthread']
131 conf.env['LIB_DL'] = ['dl']
132 conf.env['LIB_RT'] = ['rt']
133 conf.env['JACK_API_VERSION'] = JACK_API_VERSION
134 conf.env['JACK_VERSION'] = VERSION
136 conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
137 conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
138 conf.env['BUILD_WITH_32_64'] = Options.options.mixed
139 conf.env['BUILD_JACKDBUS'] = Options.options.dbus
140 conf.env['BUILD_CLASSIC'] = Options.options.classic
142 if conf.env['BUILD_JACKDBUS']:
143 conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
144 else:
145 conf.env['BUILD_JACKD'] = True
147 if Options.options.libdir:
148 conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir
149 else:
150 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
152 conf.define('CLIENT_NUM', Options.options.clients)
153 conf.define('PORT_NUM', Options.options.ports)
154 conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
156 conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
157 conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
158 conf.define('USE_POSIX_SHM', 1)
159 conf.define('JACKMP', 1)
160 if conf.env['BUILD_JACKDBUS'] == True:
161 conf.define('JACK_DBUS', 1)
162 if conf.env['BUILD_JACKD'] == False:
163 conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
164 if conf.env['BUILD_WITH_PROFILE'] == True:
165 conf.define('JACK_MONITOR', 1)
166 if conf.env['BUILD_WITH_32_64'] == True:
167 conf.define('JACK_32_64', 1)
168 conf.write_config_header('config.h')
170 svnrev = None
171 if os.access('svnversion.h', os.R_OK):
172 data = file('svnversion.h').read()
173 m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
174 if m != None:
175 svnrev = m.group(1)
177 print
178 display_msg("==================")
179 version_msg = "JACK " + VERSION
180 if svnrev:
181 version_msg += " exported from r" + svnrev
182 else:
183 version_msg += " svn revision will checked and eventually updated during build"
184 print version_msg
186 print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
187 print "Build with a maximum of %d ports" % conf.env['PORT_NUM']
188 print "Build with a maximum of %d ports per application" % conf.env['PORT_NUM_FOR_CLIENT']
190 display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
191 display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
192 display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
193 display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
194 display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
195 display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
197 display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
198 display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
200 if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
201 print Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues!' + Logs.colors.NORMAL
203 if conf.env['IS_LINUX']:
204 display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
205 display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
206 display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
208 if conf.env['BUILD_JACKDBUS'] == True:
209 display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
210 #display_msg('Settings persistence', xxx)
212 if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
213 print
214 print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
215 print Logs.colors.RED + "WARNING:",
216 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
217 print Logs.colors.RED + 'WARNING: but service file will be installed in'
218 print Logs.colors.RED + "WARNING:",
219 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
220 print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
221 print 'WARNING: You can override dbus service install directory'
222 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
223 print Logs.colors.NORMAL,
224 print
226 if Options.options.mixed == True:
227 env_variant2 = conf.env.copy()
228 conf.set_env_name('lib32', env_variant2)
229 env_variant2.set_variant('lib32')
230 conf.setenv('lib32')
231 conf.env.append_unique('CXXFLAGS', '-m32')
232 conf.env.append_unique('CCFLAGS', '-m32')
233 conf.env.append_unique('LINKFLAGS', '-m32')
234 if Options.options.libdir32:
235 conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir32
236 else:
237 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
238 conf.write_config_header('config.h')
240 def build(bld):
241 print ("make[1]: Entering directory `" + os.getcwd() + "/" + blddir + "'" )
242 if not os.access('svnversion.h', os.R_OK):
243 create_svnversion_task(bld)
245 # process subfolders from here
246 bld.add_subdirs('common')
247 if bld.env['IS_LINUX']:
248 bld.add_subdirs('linux')
249 bld.add_subdirs('example-clients')
250 bld.add_subdirs('tests')
251 if bld.env['BUILD_JACKDBUS'] == True:
252 bld.add_subdirs('dbus')
254 if bld.env['IS_MACOSX']:
255 bld.add_subdirs('macosx')
256 bld.add_subdirs('example-clients')
257 bld.add_subdirs('tests')
258 if bld.env['BUILD_JACKDBUS'] == True:
259 bld.add_subdirs('dbus')
261 if bld.env['IS_SUN']:
262 bld.add_subdirs('solaris')
263 bld.add_subdirs('example-clients')
264 bld.add_subdirs('tests')
265 if bld.env['BUILD_JACKDBUS'] == True:
266 bld.add_subdirs('dbus')
268 if bld.env['BUILD_DOXYGEN_DOCS'] == True:
269 share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
270 html_docs_source_dir = "build/default/html"
271 html_docs_install_dir = share_dir + '/reference/html/'
272 if Options.commands['install']:
273 if os.path.isdir(html_docs_install_dir):
274 Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
275 shutil.rmtree(html_docs_install_dir)
276 Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
277 Utils.pprint('CYAN', "Installing doxygen documentation...")
278 shutil.copytree(html_docs_source_dir, html_docs_install_dir)
279 Utils.pprint('CYAN', "Installing doxygen documentation done.")
280 elif Options.commands['uninstall']:
281 Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
282 if os.path.isdir(share_dir):
283 shutil.rmtree(share_dir)
284 Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
285 elif Options.commands['clean']:
286 if os.access(html_docs_source_dir, os.R_OK):
287 Utils.pprint('CYAN', "Removing doxygen generated documentation...")
288 shutil.rmtree(html_docs_source_dir)
289 Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
290 elif Options.commands['build']:
291 if not os.access(html_docs_source_dir, os.R_OK):
292 os.popen("doxygen").read()
293 else:
294 Utils.pprint('CYAN', "doxygen documentation already built.")
296 def dist_hook():
297 os.remove('svnversion_regenerate.sh')
298 os.system('../svnversion_regenerate.sh svnversion.h')