Add compile time option for maximum ports per application.
[jack2.git] / wscript
blob8c01c38430d51d402de28dc1079fb14cc0831da5
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.3'
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', default=1024, type="int", dest="ports", help='Maximum number of ports')
72 opt.add_option('--ports-per-application', default=512, type="int", dest="application_ports", help='Maximum number of ports per application')
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 conf.sub_config('example-clients')
117 conf.env['LIB_PTHREAD'] = ['pthread']
118 conf.env['LIB_DL'] = ['dl']
119 conf.env['LIB_RT'] = ['rt']
120 conf.env['JACK_API_VERSION'] = JACK_API_VERSION
121 conf.env['JACK_VERSION'] = VERSION
123 conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
124 conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
125 conf.env['BUILD_WITH_32_64'] = Options.options.mixed
126 conf.env['BUILD_JACKDBUS'] = Options.options.dbus
127 conf.env['BUILD_CLASSIC'] = Options.options.classic
129 if conf.env['BUILD_JACKDBUS']:
130 conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
131 else:
132 conf.env['BUILD_JACKD'] = True
134 if Options.options.libdir:
135 conf.env['LIBDIR'] = Options.options.libdir
136 else:
137 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib/'
139 conf.define('CLIENT_NUM', Options.options.clients)
140 conf.define('PORT_NUM', Options.options.ports)
141 conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
143 conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
144 conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
145 conf.define('USE_POSIX_SHM', 1)
146 conf.define('JACKMP', 1)
147 if conf.env['BUILD_JACKDBUS'] == True:
148 conf.define('JACK_DBUS', 1)
149 if conf.env['BUILD_JACKD'] == False:
150 conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
151 if conf.env['BUILD_WITH_PROFILE'] == True:
152 conf.define('JACK_MONITOR', 1)
153 if conf.env['BUILD_WITH_32_64'] == True:
154 conf.define('JACK_32_64', 1)
155 conf.write_config_header('config.h')
157 svnrev = None
158 if os.access('svnversion.h', os.R_OK):
159 data = file('svnversion.h').read()
160 m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
161 if m != None:
162 svnrev = m.group(1)
164 print
165 display_msg("==================")
166 version_msg = "JACK " + VERSION
167 if svnrev:
168 version_msg += " exported from r" + svnrev
169 else:
170 version_msg += " svn revision will checked and eventually updated during build"
171 print version_msg
173 print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
174 print "Build with a maximum of %d ports" % conf.env['PORT_NUM']
175 print "Build with a maximum of %d ports per application" % conf.env['PORT_NUM_FOR_CLIENT']
177 display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
178 display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
179 display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
180 display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
181 display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
182 display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
184 display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
185 display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
187 if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
188 print Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues!' + Logs.colors.NORMAL
190 if conf.env['IS_LINUX']:
191 display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
192 display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
193 display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
195 if conf.env['BUILD_JACKDBUS'] == True:
196 display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
197 #display_msg('Settings persistence', xxx)
199 if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
200 print
201 print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
202 print Logs.colors.RED + "WARNING:",
203 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
204 print Logs.colors.RED + 'WARNING: but service file will be installed in'
205 print Logs.colors.RED + "WARNING:",
206 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
207 print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
208 print 'WARNING: You can override dbus service install directory'
209 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
210 print Logs.colors.NORMAL,
211 print
213 if Options.options.mixed == True:
214 env_variant2 = conf.env.copy()
215 conf.set_env_name('lib32', env_variant2)
216 env_variant2.set_variant('lib32')
217 conf.setenv('lib32')
218 conf.env.append_unique('CXXFLAGS', '-m32')
219 conf.env.append_unique('CCFLAGS', '-m32')
220 conf.env.append_unique('LINKFLAGS', '-m32')
221 conf.write_config_header('config.h')
222 if Options.options.libdir32:
223 conf.env['LIBDIR'] = Options.options.libdir32
224 else:
225 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32/'
227 def build(bld):
228 print ("make[1]: Entering directory `" + os.getcwd() + "/" + blddir + "'" )
229 if not os.access('svnversion.h', os.R_OK):
230 create_svnversion_task(bld)
232 # process subfolders from here
233 bld.add_subdirs('common')
234 if bld.env['IS_LINUX']:
235 bld.add_subdirs('linux')
236 bld.add_subdirs('example-clients')
237 bld.add_subdirs('tests')
238 if bld.env['BUILD_JACKDBUS'] == True:
239 bld.add_subdirs('dbus')
241 if bld.env['IS_MACOSX']:
242 bld.add_subdirs('macosx')
243 bld.add_subdirs('example-clients')
244 bld.add_subdirs('tests')
245 if bld.env['BUILD_JACKDBUS'] == True:
246 bld.add_subdirs('dbus')
248 if bld.env['IS_SUN']:
249 bld.add_subdirs('solaris')
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['BUILD_DOXYGEN_DOCS'] == True:
256 share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
257 html_docs_source_dir = "build/default/html"
258 html_docs_install_dir = share_dir + '/reference/html/'
259 if Options.commands['install']:
260 if os.path.isdir(html_docs_install_dir):
261 Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
262 shutil.rmtree(html_docs_install_dir)
263 Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
264 Utils.pprint('CYAN', "Installing doxygen documentation...")
265 shutil.copytree(html_docs_source_dir, html_docs_install_dir)
266 Utils.pprint('CYAN', "Installing doxygen documentation done.")
267 elif Options.commands['uninstall']:
268 Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
269 if os.path.isdir(share_dir):
270 shutil.rmtree(share_dir)
271 Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
272 elif Options.commands['clean']:
273 if os.access(html_docs_source_dir, os.R_OK):
274 Utils.pprint('CYAN', "Removing doxygen generated documentation...")
275 shutil.rmtree(html_docs_source_dir)
276 Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
277 elif Options.commands['build']:
278 if not os.access(html_docs_source_dir, os.R_OK):
279 os.popen("doxygen").read()
280 else:
281 Utils.pprint('CYAN', "doxygen documentation already built.")
283 def dist_hook():
284 os.remove('svnversion_regenerate.sh')
285 os.system('../svnversion_regenerate.sh svnversion.h')