Update XCode project.
[jack2.git] / wscript
blob659a1a26535cacab20dae1e98656968da9f71c49
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('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
65 opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
66 opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
67 opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
68 opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
69 opt.add_option('--ports', default=1024, type="int", dest="ports", help='Maximum number of ports')
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.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.sub_config('common')
110 if conf.env['IS_LINUX']:
111 conf.sub_config('linux')
112 if Options.options.dbus:
113 conf.sub_config('dbus')
114 conf.sub_config('example-clients')
116 conf.env['LIB_PTHREAD'] = ['pthread']
117 conf.env['LIB_DL'] = ['dl']
118 conf.env['LIB_RT'] = ['rt']
119 conf.env['JACK_API_VERSION'] = JACK_API_VERSION
120 conf.env['JACK_VERSION'] = VERSION
122 conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
123 conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
124 conf.env['BUILD_WITH_32_64'] = Options.options.mixed
126 if Options.options.libdir:
127 conf.env['LIBDIR'] = Options.options.libdir
128 else:
129 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib/'
131 conf.define('CLIENT_NUM', Options.options.clients)
132 conf.define('PORT_NUM', Options.options. ports)
134 conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
135 conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
136 conf.define('USE_POSIX_SHM', 1)
137 conf.define('JACKMP', 1)
138 if conf.env['BUILD_JACKDBUS'] == True:
139 conf.define('JACK_DBUS', 1)
140 if conf.env['BUILD_WITH_PROFILE'] == True:
141 conf.define('JACK_MONITOR', 1)
142 if conf.env['BUILD_WITH_32_64'] == True:
143 conf.define('JACK_32_64', 1)
144 conf.write_config_header('config.h')
146 svnrev = None
147 if os.access('svnversion.h', os.R_OK):
148 data = file('svnversion.h').read()
149 m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
150 if m != None:
151 svnrev = m.group(1)
153 print
154 display_msg("==================")
155 version_msg = "JACK " + VERSION
156 if svnrev:
157 version_msg += " exported from r" + svnrev
158 else:
159 version_msg += " svn revision will checked and eventually updated during build"
160 print version_msg
162 print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
163 print "Build with a maximum of %d ports" % conf.env['PORT_NUM']
165 display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
166 display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
167 display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
168 display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
169 display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
170 display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
173 if conf.env['IS_LINUX']:
174 display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
175 display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
176 display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
177 display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'] == True)
178 if conf.env['BUILD_JACKDBUS'] == True:
179 display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
180 #display_msg('Settings persistence', xxx)
182 if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
183 print
184 print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
185 print Logs.colors.RED + "WARNING:",
186 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
187 print Logs.colors.RED + 'WARNING: but service file will be installed in'
188 print Logs.colors.RED + "WARNING:",
189 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
190 print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
191 print 'WARNING: You can override dbus service install directory'
192 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
193 print Logs.colors.NORMAL,
194 print
196 def build(bld):
197 if not os.access('svnversion.h', os.R_OK):
198 create_svnversion_task(bld)
200 # process subfolders from here
201 bld.add_subdirs('common')
202 if bld.env['IS_LINUX']:
203 bld.add_subdirs('linux')
204 bld.add_subdirs('example-clients')
205 bld.add_subdirs('tests')
206 if bld.env['BUILD_JACKDBUS'] == True:
207 bld.add_subdirs('dbus')
209 if bld.env['IS_MACOSX']:
210 bld.add_subdirs('macosx')
211 bld.add_subdirs('example-clients')
212 bld.add_subdirs('tests')
213 if bld.env['BUILD_JACKDBUS'] == True:
214 bld.add_subdirs('dbus')
216 if bld.env['IS_SUN']:
217 bld.add_subdirs('solaris')
218 bld.add_subdirs('example-clients')
219 bld.add_subdirs('tests')
220 if bld.env['BUILD_JACKDBUS'] == True:
221 bld.add_subdirs('dbus')
223 if bld.env['BUILD_DOXYGEN_DOCS'] == True:
224 share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
225 html_docs_source_dir = "build/default/html"
226 html_docs_install_dir = share_dir + '/reference/html/'
227 if Options.commands['install']:
228 if os.path.isdir(html_docs_install_dir):
229 Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
230 shutil.rmtree(html_docs_install_dir)
231 Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
232 Utils.pprint('CYAN', "Installing doxygen documentation...")
233 shutil.copytree(html_docs_source_dir, html_docs_install_dir)
234 Utils.pprint('CYAN', "Installing doxygen documentation done.")
235 elif Options.commands['uninstall']:
236 Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
237 if os.path.isdir(share_dir):
238 shutil.rmtree(share_dir)
239 Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
240 elif Options.commands['clean']:
241 if os.access(html_docs_source_dir, os.R_OK):
242 Utils.pprint('CYAN', "Removing doxygen generated documentation...")
243 shutil.rmtree(html_docs_source_dir)
244 Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
245 elif Options.commands['build']:
246 if not os.access(html_docs_source_dir, os.R_OK):
247 os.popen("doxygen").read()
248 else:
249 Utils.pprint('CYAN', "doxygen documentation already built.")
251 def dist_hook():
252 os.remove('svnversion_regenerate.sh')
253 os.system('../svnversion_regenerate.sh svnversion.h')