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