Merge branch 'master' into port_register_notification_defer
[jack2.git] / wscript
blobf4b90594b23304e1bcd35e96980d72cc496c4393
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.sub_options('dbus')
74 def configure(conf):
75 platform = Utils.detect_platform()
76 conf.env['IS_MACOSX'] = platform == 'darwin'
77 conf.env['IS_LINUX'] = platform == 'linux'
78 conf.env['IS_SUN'] = platform == 'sunos'
80 if conf.env['IS_LINUX']:
81 Utils.pprint('CYAN', "Linux detected")
83 if conf.env['IS_MACOSX']:
84 Utils.pprint('CYAN', "MacOS X detected")
86 if conf.env['IS_SUN']:
87 Utils.pprint('CYAN', "SunOS detected")
89 if conf.env['IS_LINUX']:
90 conf.check_tool('compiler_cxx')
91 conf.check_tool('compiler_cc')
93 if conf.env['IS_MACOSX']:
94 conf.check_tool('compiler_cxx')
95 conf.check_tool('compiler_cc')
97 # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
98 if conf.env['IS_SUN']:
99 conf.check_tool('g++')
100 conf.check_tool('gcc')
102 #if conf.env['IS_SUN']:
103 # conf.check_tool('compiler_cxx')
104 # conf.check_tool('compiler_cc')
106 conf.env.append_unique('CXXFLAGS', '-O3 -Wall')
107 conf.env.append_unique('CCFLAGS', '-O3 -Wall')
109 #conf.env.append_unique('CXXFLAGS', '-g')
110 #conf.env.append_unique('CCFLAGS', '-g')
111 #conf.env.append_unique('LINKFLAGS', '-g')
113 conf.sub_config('common')
114 if conf.env['IS_LINUX']:
115 conf.sub_config('linux')
116 if Options.options.dbus:
117 conf.sub_config('dbus')
118 conf.sub_config('example-clients')
120 if conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs'):
121 conf.define('HAVE_CELT', 1)
122 conf.define('HAVE_CELT_API_0_7', 1)
123 conf.define('HAVE_CELT_API_0_5', 0)
124 elif conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', required=True):
125 conf.define('HAVE_CELT', 1)
126 conf.define('HAVE_CELT_API_0_5', 1)
127 conf.define('HAVE_CELT_API_0_7', 0)
128 else:
129 conf.define('HAVE_CELT', 0)
130 conf.define('HAVE_CELT_API_0_5', 0)
131 conf.define('HAVE_CELT_API_0_7', 0)
133 conf.env['LIB_PTHREAD'] = ['pthread']
134 conf.env['LIB_DL'] = ['dl']
135 conf.env['LIB_RT'] = ['rt']
136 conf.env['JACK_API_VERSION'] = JACK_API_VERSION
137 conf.env['JACK_VERSION'] = VERSION
139 conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
140 conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
141 conf.env['BUILD_WITH_32_64'] = Options.options.mixed
142 conf.env['BUILD_JACKDBUS'] = Options.options.dbus
143 conf.env['BUILD_CLASSIC'] = Options.options.classic
145 if conf.env['BUILD_JACKDBUS']:
146 conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
147 else:
148 conf.env['BUILD_JACKD'] = True
150 if Options.options.libdir:
151 conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir
152 else:
153 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
155 conf.define('CLIENT_NUM', Options.options.clients)
156 conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
158 conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
159 conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
160 conf.define('USE_POSIX_SHM', 1)
161 conf.define('JACKMP', 1)
162 if conf.env['BUILD_JACKDBUS'] == True:
163 conf.define('JACK_DBUS', 1)
164 if conf.env['BUILD_JACKD'] == False:
165 conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
166 if conf.env['BUILD_WITH_PROFILE'] == True:
167 conf.define('JACK_MONITOR', 1)
168 if conf.env['BUILD_WITH_32_64'] == True:
169 conf.define('JACK_32_64', 1)
170 conf.write_config_header('config.h')
172 svnrev = None
173 if os.access('svnversion.h', os.R_OK):
174 data = file('svnversion.h').read()
175 m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
176 if m != None:
177 svnrev = m.group(1)
179 print
180 display_msg("==================")
181 version_msg = "JACK " + VERSION
182 if svnrev:
183 version_msg += " exported from r" + svnrev
184 else:
185 version_msg += " svn revision will checked and eventually updated during build"
186 print version_msg
188 print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
189 print "Build with a maximum of %d ports per application" % conf.env['PORT_NUM_FOR_CLIENT']
191 display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
192 display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
193 display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
194 display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
195 display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
196 display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
198 display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
199 display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
201 if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
202 print Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues!' + Logs.colors.NORMAL
204 if conf.env['IS_LINUX']:
205 display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
206 display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
207 display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
209 if conf.env['BUILD_JACKDBUS'] == True:
210 display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
211 #display_msg('Settings persistence', xxx)
213 if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
214 print
215 print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
216 print Logs.colors.RED + "WARNING:",
217 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
218 print Logs.colors.RED + 'WARNING: but service file will be installed in'
219 print Logs.colors.RED + "WARNING:",
220 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
221 print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
222 print 'WARNING: You can override dbus service install directory'
223 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
224 print Logs.colors.NORMAL,
225 print
227 if Options.options.mixed == True:
228 env_variant2 = conf.env.copy()
229 conf.set_env_name('lib32', env_variant2)
230 env_variant2.set_variant('lib32')
231 conf.setenv('lib32')
232 conf.env.append_unique('CXXFLAGS', '-m32')
233 conf.env.append_unique('CCFLAGS', '-m32')
234 conf.env.append_unique('LINKFLAGS', '-m32')
235 if Options.options.libdir32:
236 conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir32
237 else:
238 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
239 conf.write_config_header('config.h')
241 def build(bld):
242 print ("make[1]: Entering directory `" + os.getcwd() + "/" + blddir + "'" )
243 if not os.access('svnversion.h', os.R_OK):
244 create_svnversion_task(bld)
246 # process subfolders from here
247 bld.add_subdirs('common')
248 if bld.env['IS_LINUX']:
249 bld.add_subdirs('linux')
250 bld.add_subdirs('example-clients')
251 bld.add_subdirs('tests')
252 if bld.env['BUILD_JACKDBUS'] == True:
253 bld.add_subdirs('dbus')
255 if bld.env['IS_MACOSX']:
256 bld.add_subdirs('macosx')
257 bld.add_subdirs('example-clients')
258 bld.add_subdirs('tests')
259 if bld.env['BUILD_JACKDBUS'] == True:
260 bld.add_subdirs('dbus')
262 if bld.env['IS_SUN']:
263 bld.add_subdirs('solaris')
264 bld.add_subdirs('example-clients')
265 bld.add_subdirs('tests')
266 if bld.env['BUILD_JACKDBUS'] == True:
267 bld.add_subdirs('dbus')
269 if bld.env['BUILD_DOXYGEN_DOCS'] == True:
270 share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
271 html_docs_source_dir = "build/default/html"
272 html_docs_install_dir = share_dir + '/reference/html/'
273 if Options.commands['install']:
274 if os.path.isdir(html_docs_install_dir):
275 Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
276 shutil.rmtree(html_docs_install_dir)
277 Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
278 Utils.pprint('CYAN', "Installing doxygen documentation...")
279 shutil.copytree(html_docs_source_dir, html_docs_install_dir)
280 Utils.pprint('CYAN', "Installing doxygen documentation done.")
281 elif Options.commands['uninstall']:
282 Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
283 if os.path.isdir(share_dir):
284 shutil.rmtree(share_dir)
285 Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
286 elif Options.commands['clean']:
287 if os.access(html_docs_source_dir, os.R_OK):
288 Utils.pprint('CYAN', "Removing doxygen generated documentation...")
289 shutil.rmtree(html_docs_source_dir)
290 Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
291 elif Options.commands['build']:
292 if not os.access(html_docs_source_dir, os.R_OK):
293 os.popen("doxygen").read()
294 else:
295 Utils.pprint('CYAN', "doxygen documentation already built.")
297 def dist_hook():
298 os.remove('svnversion_regenerate.sh')
299 os.system('../svnversion_regenerate.sh svnversion.h')