Update XCode project for Universal Binary compilation of netjack components.
[jack2.git] / wscript
blobf3d5a9243303c3c2d6b0706bb2b891ae84e73a14
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.1'
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('--monitor', action='store_true', default=False, help='Build with monitoring records')
67 opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
68 opt.add_option('--ports', default=512, type="int", dest="ports", help='Maximum number of ports')
69 opt.sub_options('dbus')
71 def configure(conf):
72 platform = Utils.detect_platform()
73 conf.env['IS_MACOSX'] = platform == 'darwin'
74 conf.env['IS_LINUX'] = platform == 'linux'
76 if conf.env['IS_LINUX']:
77 Utils.pprint('CYAN', "Linux detected")
79 if conf.env['IS_MACOSX']:
80 Utils.pprint('CYAN', "MacOS X detected")
82 conf.check_tool('compiler_cxx')
83 conf.check_tool('compiler_cc')
85 conf.env.append_unique('CXXFLAGS', '-O3 -Wall')
86 conf.env.append_unique('CCFLAGS', '-O3 -Wall')
88 conf.sub_config('common')
89 if conf.env['IS_LINUX']:
90 conf.sub_config('linux')
91 if Options.options.dbus:
92 conf.sub_config('dbus')
93 conf.sub_config('example-clients')
95 conf.env['LIB_PTHREAD'] = ['pthread']
96 conf.env['LIB_DL'] = ['dl']
97 conf.env['LIB_RT'] = ['rt']
98 conf.env['JACK_API_VERSION'] = JACK_API_VERSION
99 conf.env['JACK_VERSION'] = VERSION
101 conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
102 conf.env['BUILD_WITH_MONITOR'] = Options.options.monitor
104 if Options.options.libdir:
105 conf.env['LIBDIR'] = Options.options.libdir
106 else:
107 conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib/'
109 conf.define('CLIENT_NUM', Options.options.clients)
110 conf.define('PORT_NUM', Options.options. ports)
112 conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
113 conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
114 conf.define('USE_POSIX_SHM', 1)
115 conf.define('JACKMP', 1)
116 if conf.env['BUILD_JACKDBUS'] == True:
117 conf.define('JACK_DBUS', 1)
118 if conf.env['BUILD_WITH_MONITOR'] == True:
119 conf.define('JACK_MONITOR', 1)
120 conf.write_config_header('config.h')
122 svnrev = None
123 if os.access('svnversion.h', os.R_OK):
124 data = file('svnversion.h').read()
125 m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
126 if m != None:
127 svnrev = m.group(1)
129 print
130 display_msg("==================")
131 version_msg = "JACK " + VERSION
132 if svnrev:
133 version_msg += " exported from r" + svnrev
134 else:
135 version_msg += " svn revision will checked and eventually updated during build"
136 print version_msg
138 print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
139 print "Build with a maximum of %d ports" % conf.env['PORT_NUM']
141 display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
142 display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
143 display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
144 display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
145 display_feature('Build with monitoring records', conf.env['BUILD_WITH_MONITOR'])
147 if conf.env['IS_LINUX']:
148 display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
149 display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
150 display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
151 display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'] == True)
152 if conf.env['BUILD_JACKDBUS'] == True:
153 display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
154 #display_msg('Settings persistence', xxx)
156 if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
157 print
158 print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
159 print Logs.colors.RED + "WARNING:",
160 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
161 print Logs.colors.RED + 'WARNING: but service file will be installed in'
162 print Logs.colors.RED + "WARNING:",
163 print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
164 print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
165 print 'WARNING: You can override dbus service install directory'
166 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
167 print Logs.colors.NORMAL,
168 print
170 def build(bld):
171 if not os.access('svnversion.h', os.R_OK):
172 create_svnversion_task(bld)
174 # process subfolders from here
175 bld.add_subdirs('common')
176 if bld.env['IS_LINUX']:
177 bld.add_subdirs('linux')
178 if bld.env['BUILD_JACKDBUS'] == True:
179 bld.add_subdirs('dbus')
180 bld.add_subdirs('example-clients')
181 bld.add_subdirs('tests')
182 if bld.env['IS_MACOSX']:
183 bld.add_subdirs('macosx')
184 bld.add_subdirs('example-clients')
185 bld.add_subdirs('tests')
186 if bld.env['BUILD_JACKDBUS'] == True:
187 bld.add_subdirs('dbus')
189 if bld.env['BUILD_DOXYGEN_DOCS'] == True:
190 share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
191 html_docs_source_dir = "build/default/html"
192 html_docs_install_dir = share_dir + '/reference/html/'
193 if Options.commands['install']:
194 if os.path.isdir(html_docs_install_dir):
195 Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
196 shutil.rmtree(html_docs_install_dir)
197 Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
198 Utils.pprint('CYAN', "Installing doxygen documentation...")
199 shutil.copytree(html_docs_source_dir, html_docs_install_dir)
200 Utils.pprint('CYAN', "Installing doxygen documentation done.")
201 elif Options.commands['uninstall']:
202 Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
203 if os.path.isdir(share_dir):
204 shutil.rmtree(share_dir)
205 Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
206 elif Options.commands['clean']:
207 if os.access(html_docs_source_dir, os.R_OK):
208 Utils.pprint('CYAN', "Removing doxygen generated documentation...")
209 shutil.rmtree(html_docs_source_dir)
210 Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
211 elif Options.commands['build']:
212 if not os.access(html_docs_source_dir, os.R_OK):
213 os.popen("doxygen").read()
214 else:
215 Utils.pprint('CYAN', "doxygen documentation already built.")
217 def dist_hook():
218 os.remove('svnversion_regenerate.sh')
219 os.system('../svnversion_regenerate.sh svnversion.h')