Backport of latest Paul alsa_seqmidi changes.
[jack2.git] / wscript
blob351f126fe616f53abb748bf530cc80c9e447308b
1 #! /usr/bin/env python
2 # encoding: utf-8
4 import os
5 import Params
6 import commands
7 from Configure import g_maxlen
8 #g_maxlen = 40
9 import shutil
10 import Task
11 import re
13 VERSION='1.9.0'
14 APPNAME='jack'
15 JACK_API_VERSION = '0.1.0'
17 # these variables are mandatory ('/' are converted automatically)
18 srcdir = '.'
19 blddir = 'build'
21 def display_msg(msg, status = None, color = None):
22 sr = msg
23 global g_maxlen
24 g_maxlen = max(g_maxlen, len(msg))
25 if status:
26 print "%s :" % msg.ljust(g_maxlen),
27 Params.pprint(color, status)
28 else:
29 print "%s" % msg.ljust(g_maxlen)
31 def display_feature(msg, build):
32 if build:
33 display_msg(msg, "yes", 'GREEN')
34 else:
35 display_msg(msg, "no", 'YELLOW')
37 def create_svnversion_gen(bld, header='svnversion.h', define=None):
38 cmd = '../svnversion_regenerate.sh ${TGT}'
39 if define:
40 cmd += " " + define
41 cls = Task.simple_task_type('svnversion', cmd, color='BLUE')
42 cls.must_run = lambda self: True
43 #cls.before = 'cxx'
45 def sg(self):
46 rt = Params.h_file(self.m_outputs[0].abspath(self.env()))
47 return rt
48 cls.signature = sg
50 #def se(self):
51 # r = sg(self)
52 # return (r, r, r, r, r)
53 #cls.cache_sig = property(sg, None)
54 cls.cache_sig = None
56 tsk = cls('svnversion', bld.env().copy())
57 tsk.m_inputs = []
58 tsk.m_outputs = [bld.path.find_or_declare(header)]
59 tsk.prio = 1 # execute this task first
61 def set_options(opt):
62 # options provided by the modules
63 opt.tool_options('compiler_cxx')
64 opt.tool_options('compiler_cc')
66 opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
67 opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
68 opt.add_option('--monitor', action='store_true', default=False, help='Build with monitoring records')
69 opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
70 opt.add_option('--ports', default=512, type="int", dest="ports", help='Maximum number of ports')
71 opt.sub_options('dbus')
73 def configure(conf):
74 platform = conf.detect_platform()
75 conf.env['IS_MACOSX'] = platform == 'darwin'
76 conf.env['IS_LINUX'] = platform == 'linux'
78 if conf.env['IS_LINUX']:
79 Params.pprint('CYAN', "Linux detected")
81 if conf.env['IS_MACOSX']:
82 Params.pprint('CYAN', "MacOS X detected")
84 conf.check_tool('compiler_cxx')
85 conf.check_tool('compiler_cc')
87 conf.sub_config('common')
88 if conf.env['IS_LINUX']:
89 conf.sub_config('linux')
90 if Params.g_options.dbus:
91 conf.sub_config('dbus')
92 conf.sub_config('example-clients')
94 conf.env['LIB_PTHREAD'] = ['pthread']
95 conf.env['LIB_DL'] = ['dl']
96 conf.env['LIB_RT'] = ['rt']
97 conf.env['JACK_API_VERSION'] = JACK_API_VERSION
98 conf.env['JACK_VERSION'] = VERSION
100 conf.env['BUILD_DOXYGEN_DOCS'] = Params.g_options.doxygen
101 conf.env['BUILD_WITH_MONITOR'] = Params.g_options.monitor
103 conf.define('CLIENT_NUM', Params.g_options.clients)
104 conf.define('PORT_NUM', Params.g_options. ports)
106 conf.define('ADDON_DIR', os.path.normpath(conf.env['PREFIX'] + '/lib/jack'))
107 conf.define('JACK_LOCATION', os.path.normpath(conf.env['PREFIX'] + '/bin'))
108 conf.define('USE_POSIX_SHM', 1)
109 conf.define('JACKMP', 1)
110 if conf.env['BUILD_JACKDBUS'] == True:
111 conf.define('JACK_DBUS', 1)
112 if conf.env['BUILD_WITH_MONITOR'] == True:
113 conf.define('JACK_MONITOR', 1)
114 conf.write_config_header('config.h')
116 svnrev = None
117 if os.access('svnversion.h', os.R_OK):
118 data = file('svnversion.h').read()
119 m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
120 if m != None:
121 svnrev = m.group(1)
123 print
124 display_msg("==================")
125 version_msg = "JACK " + VERSION
126 if svnrev:
127 version_msg += " exported from r" + svnrev
128 else:
129 version_msg += " svn revision will checked and eventually updated during build"
130 print version_msg
132 print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
133 print "Build with a maximum of %d ports" % conf.env['PORT_NUM']
135 display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
136 display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
137 display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
138 display_feature('Build with monitoring records', conf.env['BUILD_WITH_MONITOR'])
140 if conf.env['IS_LINUX']:
141 display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
142 display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
143 display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
144 display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'] == True)
145 if conf.env['BUILD_JACKDBUS'] == True:
146 display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
147 #display_msg('Settings persistence', xxx)
149 if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]:
150 print
151 print Params.g_colors['RED'] + "WARNING: D-Bus session services directory as reported by pkg-config is"
152 print Params.g_colors['RED'] + "WARNING:",
153 print Params.g_colors['CYAN'] + conf.env['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]
154 print Params.g_colors['RED'] + 'WARNING: but service file will be installed in'
155 print Params.g_colors['RED'] + "WARNING:",
156 print Params.g_colors['CYAN'] + conf.env['DBUS_SERVICES_DIR']
157 print Params.g_colors['RED'] + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
158 print 'WARNING: You can override dbus service install directory'
159 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
160 print Params.g_colors['NORMAL'],
161 print
163 def build(bld):
164 if not os.access('svnversion.h', os.R_OK):
165 create_svnversion_gen(bld)
167 # process subfolders from here
168 bld.add_subdirs('common')
169 if bld.env()['IS_LINUX']:
170 bld.add_subdirs('linux')
171 if bld.env()['BUILD_JACKDBUS'] == True:
172 bld.add_subdirs('dbus')
173 bld.add_subdirs('example-clients')
174 bld.add_subdirs('tests')
175 if bld.env()['IS_MACOSX']:
176 bld.add_subdirs('macosx')
177 bld.add_subdirs('example-clients')
178 bld.add_subdirs('tests')
179 if bld.env()['BUILD_JACKDBUS'] == True:
180 bld.add_subdirs('dbus')
182 if bld.env()['BUILD_DOXYGEN_DOCS'] == True:
183 share_dir = bld.env().get_destdir() + Params.g_build.env()['PREFIX'] + '/share/jack-audio-connection-kit'
184 html_docs_source_dir = "build/default/html"
185 html_docs_install_dir = share_dir + '/reference/html/'
186 if Params.g_commands['install']:
187 if os.path.isdir(html_docs_install_dir):
188 Params.pprint('CYAN', "Removing old doxygen documentation installation...")
189 shutil.rmtree(html_docs_install_dir)
190 Params.pprint('CYAN', "Removing old doxygen documentation installation done.")
191 Params.pprint('CYAN', "Installing doxygen documentation...")
192 shutil.copytree(html_docs_source_dir, html_docs_install_dir)
193 Params.pprint('CYAN', "Installing doxygen documentation done.")
194 elif Params.g_commands['uninstall']:
195 Params.pprint('CYAN', "Uninstalling doxygen documentation...")
196 if os.path.isdir(share_dir):
197 shutil.rmtree(share_dir)
198 Params.pprint('CYAN', "Uninstalling doxygen documentation done.")
199 elif Params.g_commands['clean']:
200 if os.access(html_docs_source_dir, os.R_OK):
201 Params.pprint('CYAN', "Removing doxygen generated documentation...")
202 shutil.rmtree(html_docs_source_dir)
203 Params.pprint('CYAN', "Removing doxygen generated documentation done.")
204 elif Params.g_commands['build']:
205 if not os.access(html_docs_source_dir, os.R_OK):
206 os.popen("doxygen").read()
207 else:
208 Params.pprint('CYAN', "doxygen documentation already built.")
210 def dist_hook():
211 os.remove('svnversion_regenerate.sh')
212 os.system('../svnversion_regenerate.sh svnversion.h')