weakjack.h stuff backported from jack1.
[jack2.git] / wscript
blob334693977d07f98f103036e403063a7ba153f26c
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-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.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 if conf.env['BUILD_JACKDBUS'] != True:
116 conf.fatal('jackdbus was explicitly requested but cannot be built')
117 conf.sub_config('example-clients')
119 if conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs'):
120 conf.define('HAVE_CELT', 1)
121 conf.define('HAVE_CELT_API_0_7', 1)
122 conf.define('HAVE_CELT_API_0_5', 0)
123 elif conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', required=True):
124 conf.define('HAVE_CELT', 1)
125 conf.define('HAVE_CELT_API_0_5', 1)
126 conf.define('HAVE_CELT_API_0_7', 0)
127 else:
128 conf.define('HAVE_CELT', 0)
129 conf.define('HAVE_CELT_API_0_5', 0)
130 conf.define('HAVE_CELT_API_0_7', 0)
132 conf.env['LIB_PTHREAD'] = ['pthread']
133 conf.env['LIB_DL'] = ['dl']
134 conf.env['LIB_RT'] = ['rt']
135 conf.env['JACK_API_VERSION'] = JACK_API_VERSION
136 conf.env['JACK_VERSION'] = VERSION
138 conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
139 conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
140 conf.env['BUILD_WITH_32_64'] = Options.options.mixed
141 conf.env['BUILD_CLASSIC'] = Options.options.classic
142 conf.env['BUILD_DEBUG'] = Options.options.debug
144 if conf.env['BUILD_JACKDBUS']:
145 conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
146 else:
147 conf.env['BUILD_JACKD'] = True
149 if Options.options.libdir:
150 conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir
151 else:
152 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
154 if conf.env['BUILD_DEBUG']:
155 conf.env.append_unique('CXXFLAGS', '-g')
156 conf.env.append_unique('CCFLAGS', '-g')
157 conf.env.append_unique('LINKFLAGS', '-g')
159 conf.define('CLIENT_NUM', Options.options.clients)
160 conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
162 conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
163 conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
164 conf.define('USE_POSIX_SHM', 1)
165 conf.define('JACKMP', 1)
166 if conf.env['BUILD_JACKDBUS'] == True:
167 conf.define('JACK_DBUS', 1)
168 if conf.env['BUILD_JACKD'] == False:
169 conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
170 if conf.env['BUILD_WITH_PROFILE'] == True:
171 conf.define('JACK_MONITOR', 1)
172 if conf.env['BUILD_WITH_32_64'] == True:
173 conf.define('JACK_32_64', 1)
174 conf.write_config_header('config.h')
176 svnrev = None
177 if os.access('svnversion.h', os.R_OK):
178 data = file('svnversion.h').read()
179 m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
180 if m != None:
181 svnrev = m.group(1)
183 print
184 display_msg("==================")
185 version_msg = "JACK " + VERSION
186 if svnrev:
187 version_msg += " exported from r" + svnrev
188 else:
189 version_msg += " svn revision will checked and eventually updated during build"
190 print version_msg
192 print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
193 print "Build with a maximum of %d ports per application" % conf.env['PORT_NUM_FOR_CLIENT']
195 display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
196 display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
197 display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
198 display_feature('Build debuggable binaries', conf.env['BUILD_DEBUG'])
199 display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
200 display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
201 display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
203 display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
204 display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
206 if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
207 print Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL
208 print Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL
210 if conf.env['IS_LINUX']:
211 display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
212 display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
213 display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
215 if conf.env['BUILD_JACKDBUS'] == True:
216 display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
217 #display_msg('Settings persistence', xxx)
219 if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
220 print
221 print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
222 print Logs.colors.RED + "WARNING:",
223 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
224 print Logs.colors.RED + 'WARNING: but service file will be installed in'
225 print Logs.colors.RED + "WARNING:",
226 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
227 print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
228 print 'WARNING: You can override dbus service install directory'
229 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
230 print Logs.colors.NORMAL,
231 print
233 if Options.options.mixed == True:
234 env_variant2 = conf.env.copy()
235 conf.set_env_name('lib32', env_variant2)
236 env_variant2.set_variant('lib32')
237 conf.setenv('lib32')
238 conf.env.append_unique('CXXFLAGS', '-m32')
239 conf.env.append_unique('CCFLAGS', '-m32')
240 conf.env.append_unique('LINKFLAGS', '-m32')
241 if Options.options.libdir32:
242 conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir32
243 else:
244 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
245 conf.write_config_header('config.h')
247 def build(bld):
248 print ("make[1]: Entering directory `" + os.getcwd() + "/" + blddir + "'" )
249 if not os.access('svnversion.h', os.R_OK):
250 create_svnversion_task(bld)
252 # process subfolders from here
253 bld.add_subdirs('common')
254 if bld.env['IS_LINUX']:
255 bld.add_subdirs('linux')
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_MACOSX']:
262 bld.add_subdirs('macosx')
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['IS_SUN']:
269 bld.add_subdirs('solaris')
270 bld.add_subdirs('example-clients')
271 bld.add_subdirs('tests')
272 if bld.env['BUILD_JACKDBUS'] == True:
273 bld.add_subdirs('dbus')
275 if bld.env['BUILD_DOXYGEN_DOCS'] == True:
276 share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
277 html_docs_source_dir = "build/default/html"
278 html_docs_install_dir = share_dir + '/reference/html/'
279 if Options.commands['install']:
280 if os.path.isdir(html_docs_install_dir):
281 Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
282 shutil.rmtree(html_docs_install_dir)
283 Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
284 Utils.pprint('CYAN', "Installing doxygen documentation...")
285 shutil.copytree(html_docs_source_dir, html_docs_install_dir)
286 Utils.pprint('CYAN', "Installing doxygen documentation done.")
287 elif Options.commands['uninstall']:
288 Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
289 if os.path.isdir(share_dir):
290 shutil.rmtree(share_dir)
291 Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
292 elif Options.commands['clean']:
293 if os.access(html_docs_source_dir, os.R_OK):
294 Utils.pprint('CYAN', "Removing doxygen generated documentation...")
295 shutil.rmtree(html_docs_source_dir)
296 Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
297 elif Options.commands['build']:
298 if not os.access(html_docs_source_dir, os.R_OK):
299 os.popen("doxygen").read()
300 else:
301 Utils.pprint('CYAN', "doxygen documentation already built.")
303 def dist_hook():
304 os.remove('svnversion_regenerate.sh')
305 os.system('../svnversion_regenerate.sh svnversion.h')