Compiles again on Windows.
[jack2.git] / wscript
blobd9cad014bced98e106ec20c6ca0f0c694a87e51a
1 #! /usr/bin/env python
2 # encoding: utf-8
3 from __future__ import print_function
5 import os
6 import Utils
7 import Options
8 import subprocess
9 g_maxlen = 40
10 import shutil
11 import Task
12 import re
13 import Logs
14 import sys
16 VERSION='1.9.9'
17 APPNAME='jack'
18 JACK_API_VERSION = '0.1.0'
20 # these variables are mandatory ('/' are converted automatically)
21 top = '.'
22 out = 'build'
24 def display_msg(msg, status = None, color = None):
25 sr = msg
26 global g_maxlen
27 g_maxlen = max(g_maxlen, len(msg))
28 if status:
29 Logs.pprint('NORMAL', "%s :" % msg.ljust(g_maxlen), sep=' ')
30 Logs.pprint(color, status)
31 else:
32 print("%s" % msg.ljust(g_maxlen))
34 def display_feature(msg, build):
35 if build:
36 display_msg(msg, "yes", 'GREEN')
37 else:
38 display_msg(msg, "no", 'YELLOW')
40 def create_svnversion_task(bld, header='svnversion.h', define=None):
41 cmd = '../svnversion_regenerate.sh ${TGT}'
42 if define:
43 cmd += " " + define
45 def post_run(self):
46 sg = Utils.h_file(self.outputs[0].abspath(self.env))
47 #print sg.encode('hex')
48 Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
50 bld(
51 rule = cmd,
52 name = 'svnversion',
53 runnable_status = Task.RUN_ME,
54 before = 'c',
55 color = 'BLUE',
56 post_run = post_run,
57 target = [bld.path.find_or_declare(header)]
60 def options(opt):
61 # options provided by the modules
62 opt.tool_options('compiler_cxx')
63 opt.tool_options('compiler_cc')
65 opt.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
66 opt.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
67 opt.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
68 opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
69 opt.add_option('--classic', action='store_true', default=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
70 opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
71 opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
72 opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
73 opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
74 opt.add_option('--ports-per-application', default=768, type="int", dest="application_ports", help='Maximum number of ports per application')
75 opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
76 opt.add_option('--firewire', action='store_true', default=False, help='Enable FireWire driver (FFADO)')
77 opt.add_option('--freebob', action='store_true', default=False, help='Enable FreeBob driver')
78 opt.add_option('--alsa', action='store_true', default=False, help='Enable ALSA driver')
79 opt.sub_options('dbus')
81 def configure(conf):
82 platform = sys.platform
83 conf.env['IS_MACOSX'] = platform == 'darwin'
84 conf.env['IS_LINUX'] = platform == 'linux' or platform == 'linux2' or platform == 'posix'
85 conf.env['IS_SUN'] = platform == 'sunos'
87 if conf.env['IS_LINUX']:
88 Logs.pprint('CYAN', "Linux detected")
90 if conf.env['IS_MACOSX']:
91 Logs.pprint('CYAN', "MacOS X detected")
93 if conf.env['IS_SUN']:
94 Logs.pprint('CYAN', "SunOS detected")
96 if conf.env['IS_LINUX']:
97 conf.check_tool('compiler_cxx')
98 conf.check_tool('compiler_cc')
100 if conf.env['IS_MACOSX']:
101 conf.check_tool('compiler_cxx')
102 conf.check_tool('compiler_cc')
104 # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
105 if conf.env['IS_SUN']:
106 conf.check_tool('g++')
107 conf.check_tool('gcc')
109 #if conf.env['IS_SUN']:
110 # conf.check_tool('compiler_cxx')
111 # conf.check_tool('compiler_cc')
113 conf.env.append_unique('CXXFLAGS', '-Wall')
114 conf.env.append_unique('CCFLAGS', '-Wall')
116 conf.sub_config('common')
117 if conf.env['IS_LINUX']:
118 conf.sub_config('linux')
119 if Options.options.alsa and not conf.env['BUILD_DRIVER_ALSA']:
120 conf.fatal('ALSA driver was explicitly requested but cannot be built')
121 if Options.options.freebob and not conf.env['BUILD_DRIVER_FREEBOB']:
122 conf.fatal('FreeBob driver was explicitly requested but cannot be built')
123 if Options.options.firewire and not conf.env['BUILD_DRIVER_FFADO']:
124 conf.fatal('FFADO driver was explicitly requested but cannot be built')
125 conf.env['BUILD_DRIVER_ALSA'] = Options.options.alsa
126 conf.env['BUILD_DRIVER_FFADO'] = Options.options.firewire
127 conf.env['BUILD_DRIVER_FREEBOB'] = Options.options.freebob
128 if Options.options.dbus:
129 conf.sub_config('dbus')
130 if conf.env['BUILD_JACKDBUS'] != True:
131 conf.fatal('jackdbus was explicitly requested but cannot be built')
133 conf.check_cc(header_name='samplerate.h', define_name="HAVE_SAMPLERATE")
135 if conf.is_defined('HAVE_SAMPLERATE'):
136 conf.env['LIB_SAMPLERATE'] = ['samplerate']
138 conf.sub_config('example-clients')
140 if conf.check_cfg(package='celt', atleast_version='0.11.0', args='--cflags --libs', mandatory=False):
141 conf.define('HAVE_CELT', 1)
142 conf.define('HAVE_CELT_API_0_11', 1)
143 conf.define('HAVE_CELT_API_0_8', 0)
144 conf.define('HAVE_CELT_API_0_7', 0)
145 conf.define('HAVE_CELT_API_0_5', 0)
146 elif conf.check_cfg(package='celt', atleast_version='0.8.0', args='--cflags --libs', mandatory=False):
147 conf.define('HAVE_CELT', 1)
148 conf.define('HAVE_CELT_API_0_11', 0)
149 conf.define('HAVE_CELT_API_0_8', 1)
150 conf.define('HAVE_CELT_API_0_7', 0)
151 conf.define('HAVE_CELT_API_0_5', 0)
152 elif conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs', mandatory=False):
153 conf.define('HAVE_CELT', 1)
154 conf.define('HAVE_CELT_API_0_11', 0)
155 conf.define('HAVE_CELT_API_0_8', 0)
156 conf.define('HAVE_CELT_API_0_7', 1)
157 conf.define('HAVE_CELT_API_0_5', 0)
158 elif conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', mandatory=False):
159 conf.define('HAVE_CELT', 1)
160 conf.define('HAVE_CELT_API_0_11', 0)
161 conf.define('HAVE_CELT_API_0_8', 0)
162 conf.define('HAVE_CELT_API_0_7', 0)
163 conf.define('HAVE_CELT_API_0_5', 1)
164 else:
165 conf.define('HAVE_CELT', 0)
166 conf.define('HAVE_CELT_API_0_11', 0)
167 conf.define('HAVE_CELT_API_0_8', 0)
168 conf.define('HAVE_CELT_API_0_7', 0)
169 conf.define('HAVE_CELT_API_0_5', 0)
171 conf.env['LIB_PTHREAD'] = ['pthread']
172 conf.env['LIB_DL'] = ['dl']
173 conf.env['LIB_RT'] = ['rt']
174 conf.env['JACK_API_VERSION'] = JACK_API_VERSION
175 conf.env['JACK_VERSION'] = VERSION
177 conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
178 conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
179 conf.env['BUILD_WITH_32_64'] = Options.options.mixed
180 conf.env['BUILD_CLASSIC'] = Options.options.classic
181 conf.env['BUILD_DEBUG'] = Options.options.debug
183 if conf.env['BUILD_JACKDBUS']:
184 conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
185 else:
186 conf.env['BUILD_JACKD'] = True
188 if Options.options.libdir:
189 conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir
190 else:
191 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
193 if Options.options.mandir:
194 conf.env['MANDIR'] = conf.env['PREFIX'] + Options.options.mandir
195 else:
196 conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
198 if conf.env['BUILD_DEBUG']:
199 conf.env.append_unique('CXXFLAGS', '-g')
200 conf.env.append_unique('CCFLAGS', '-g')
201 conf.env.append_unique('LINKFLAGS', '-g')
203 conf.define('CLIENT_NUM', Options.options.clients)
204 conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
206 conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
207 conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
208 conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
209 conf.define('USE_POSIX_SHM', 1)
210 conf.define('JACKMP', 1)
211 if conf.env['BUILD_JACKDBUS'] == True:
212 conf.define('JACK_DBUS', 1)
213 if conf.env['BUILD_JACKD'] == False:
214 conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
215 if conf.env['BUILD_WITH_PROFILE'] == True:
216 conf.define('JACK_MONITOR', 1)
217 conf.write_config_header('config.h')
219 svnrev = None
220 if os.access('svnversion.h', os.R_OK):
221 data = file('svnversion.h').read()
222 m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
223 if m != None:
224 svnrev = m.group(1)
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')
232 conf.setenv('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
238 else:
239 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
240 conf.write_config_header('config.h')
242 print()
243 display_msg("==================")
244 version_msg = "JACK " + VERSION
245 if svnrev:
246 version_msg += " exported from r" + svnrev
247 else:
248 version_msg += " svn revision will checked and eventually updated during build"
249 print(version_msg)
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']:
282 print()
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=' ')
293 print()
295 def build(bld):
296 print("make[1]: Entering directory `" + os.getcwd() + "/" + out + "'")
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()
349 else:
350 Logs.pprint('CYAN', "doxygen documentation already built.")
352 def dist_hook():
353 os.remove('svnversion_regenerate.sh')
354 os.system('../svnversion_regenerate.sh svnversion.h')