Renaming for Windows compatibility.
[jack2.git] / wscript
blobb0a1ef0d69bc7cfd031edecdf01b9b8e65ec6c3a
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.8'
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('--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')
79 def configure(conf):
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.11.0', args='--cflags --libs'):
133 conf.define('HAVE_CELT', 1)
134 conf.define('HAVE_CELT_API_0_11', 1)
135 conf.define('HAVE_CELT_API_0_8', 0)
136 conf.define('HAVE_CELT_API_0_7', 0)
137 conf.define('HAVE_CELT_API_0_5', 0)
138 elif conf.check_cfg(package='celt', atleast_version='0.8.0', args='--cflags --libs'):
139 conf.define('HAVE_CELT', 1)
140 conf.define('HAVE_CELT_API_0_11', 0)
141 conf.define('HAVE_CELT_API_0_8', 1)
142 conf.define('HAVE_CELT_API_0_7', 0)
143 conf.define('HAVE_CELT_API_0_5', 0)
144 elif conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs'):
145 conf.define('HAVE_CELT', 1)
146 conf.define('HAVE_CELT_API_0_11', 0)
147 conf.define('HAVE_CELT_API_0_8', 0)
148 conf.define('HAVE_CELT_API_0_7', 1)
149 conf.define('HAVE_CELT_API_0_5', 0)
150 elif conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', required=True):
151 conf.define('HAVE_CELT', 1)
152 conf.define('HAVE_CELT_API_0_11', 0)
153 conf.define('HAVE_CELT_API_0_8', 0)
154 conf.define('HAVE_CELT_API_0_7', 0)
155 conf.define('HAVE_CELT_API_0_5', 1)
156 else:
157 conf.define('HAVE_CELT', 0)
158 conf.define('HAVE_CELT_API_0_11', 0)
159 conf.define('HAVE_CELT_API_0_8', 0)
160 conf.define('HAVE_CELT_API_0_7', 0)
161 conf.define('HAVE_CELT_API_0_5', 0)
163 conf.env['LIB_PTHREAD'] = ['pthread']
164 conf.env['LIB_DL'] = ['dl']
165 conf.env['LIB_RT'] = ['rt']
166 conf.env['JACK_API_VERSION'] = JACK_API_VERSION
167 conf.env['JACK_VERSION'] = VERSION
169 conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
170 conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
171 conf.env['BUILD_WITH_32_64'] = Options.options.mixed
172 conf.env['BUILD_CLASSIC'] = Options.options.classic
173 conf.env['BUILD_DEBUG'] = Options.options.debug
175 if conf.env['BUILD_JACKDBUS']:
176 conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
177 else:
178 conf.env['BUILD_JACKD'] = True
180 if Options.options.libdir:
181 conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir
182 else:
183 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
185 if Options.options.mandir:
186 conf.env['MANDIR'] = conf.env['PREFIX'] + Options.options.mandir
187 else:
188 conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
190 if conf.env['BUILD_DEBUG']:
191 conf.env.append_unique('CXXFLAGS', '-g')
192 conf.env.append_unique('CCFLAGS', '-g')
193 conf.env.append_unique('LINKFLAGS', '-g')
195 conf.define('CLIENT_NUM', Options.options.clients)
196 conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
198 conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
199 conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
200 conf.define('USE_POSIX_SHM', 1)
201 conf.define('JACKMP', 1)
202 if conf.env['BUILD_JACKDBUS'] == True:
203 conf.define('JACK_DBUS', 1)
204 if conf.env['BUILD_JACKD'] == False:
205 conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
206 if conf.env['BUILD_WITH_PROFILE'] == True:
207 conf.define('JACK_MONITOR', 1)
208 if conf.env['BUILD_WITH_32_64'] == True:
209 conf.define('JACK_32_64', 1)
210 conf.write_config_header('config.h')
212 svnrev = None
213 if os.access('svnversion.h', os.R_OK):
214 data = file('svnversion.h').read()
215 m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
216 if m != None:
217 svnrev = m.group(1)
219 conf.env.append_unique('LINKFLAGS', '-lm -lstdc++')
221 if Options.options.mixed == True:
222 env_variant2 = conf.env.copy()
223 conf.set_env_name('lib32', env_variant2)
224 env_variant2.set_variant('lib32')
225 conf.setenv('lib32')
226 conf.env.append_unique('CXXFLAGS', '-m32')
227 conf.env.append_unique('CCFLAGS', '-m32')
228 conf.env.append_unique('LINKFLAGS', '-m32')
229 if Options.options.libdir32:
230 conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir32
231 else:
232 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
233 conf.write_config_header('config.h')
235 print
236 display_msg("==================")
237 version_msg = "JACK " + VERSION
238 if svnrev:
239 version_msg += " exported from r" + svnrev
240 else:
241 version_msg += " svn revision will checked and eventually updated during build"
242 print version_msg
244 print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
245 print "Build with a maximum of %d ports per application" % conf.env['PORT_NUM_FOR_CLIENT']
247 display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
248 display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
249 display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
250 display_feature('Build debuggable binaries', conf.env['BUILD_DEBUG'])
251 display_msg('C compiler flags', repr(conf.env['CCFLAGS']))
252 display_msg('C++ compiler flags', repr(conf.env['CXXFLAGS']))
253 display_msg('Linker flags', repr(conf.env['LINKFLAGS']))
254 display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
255 display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
256 display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
258 display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
259 display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
261 if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
262 print Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL
263 print Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL
265 if conf.env['IS_LINUX']:
266 display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
267 display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
268 display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
270 if conf.env['BUILD_JACKDBUS'] == True:
271 display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
272 #display_msg('Settings persistence', xxx)
274 if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
275 print
276 print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
277 print Logs.colors.RED + "WARNING:",
278 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
279 print Logs.colors.RED + 'WARNING: but service file will be installed in'
280 print Logs.colors.RED + "WARNING:",
281 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
282 print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
283 print 'WARNING: You can override dbus service install directory'
284 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
285 print Logs.colors.NORMAL,
286 print
288 def build(bld):
289 print ("make[1]: Entering directory `" + os.getcwd() + "/" + blddir + "'" )
290 if not os.access('svnversion.h', os.R_OK):
291 create_svnversion_task(bld)
293 # process subfolders from here
294 bld.add_subdirs('common')
295 if bld.env['IS_LINUX']:
296 bld.add_subdirs('linux')
297 bld.add_subdirs('example-clients')
298 bld.add_subdirs('tests')
299 bld.add_subdirs('man')
300 if bld.env['BUILD_JACKDBUS'] == True:
301 bld.add_subdirs('dbus')
303 if bld.env['IS_MACOSX']:
304 bld.add_subdirs('macosx')
305 bld.add_subdirs('example-clients')
306 bld.add_subdirs('tests')
307 if bld.env['BUILD_JACKDBUS'] == True:
308 bld.add_subdirs('dbus')
310 if bld.env['IS_SUN']:
311 bld.add_subdirs('solaris')
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['BUILD_DOXYGEN_DOCS'] == True:
318 share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
319 html_docs_source_dir = "build/default/html"
320 html_docs_install_dir = share_dir + '/reference/html/'
321 if Options.commands['install']:
322 if os.path.isdir(html_docs_install_dir):
323 Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
324 shutil.rmtree(html_docs_install_dir)
325 Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
326 Utils.pprint('CYAN', "Installing doxygen documentation...")
327 shutil.copytree(html_docs_source_dir, html_docs_install_dir)
328 Utils.pprint('CYAN', "Installing doxygen documentation done.")
329 elif Options.commands['uninstall']:
330 Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
331 if os.path.isdir(share_dir):
332 shutil.rmtree(share_dir)
333 Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
334 elif Options.commands['clean']:
335 if os.access(html_docs_source_dir, os.R_OK):
336 Utils.pprint('CYAN', "Removing doxygen generated documentation...")
337 shutil.rmtree(html_docs_source_dir)
338 Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
339 elif Options.commands['build']:
340 if not os.access(html_docs_source_dir, os.R_OK):
341 os.popen("doxygen").read()
342 else:
343 Utils.pprint('CYAN', "doxygen documentation already built.")
345 def dist_hook():
346 os.remove('svnversion_regenerate.sh')
347 os.system('../svnversion_regenerate.sh svnversion.h')