1 | #! /usr/bin/python |
---|
2 | # |
---|
3 | # usage: |
---|
4 | # $ python waf --help |
---|
5 | # |
---|
6 | # example: |
---|
7 | # $ ./waf distclean configure build |
---|
8 | # |
---|
9 | # Note: aubio uses the waf build system, which relies on Python. Provided you |
---|
10 | # have Python installed, you do *not* need to install anything to build aubio. |
---|
11 | # For more info about waf, see http://code.google.com/p/waf/ . |
---|
12 | |
---|
13 | import sys |
---|
14 | |
---|
15 | APPNAME = 'aubio' |
---|
16 | |
---|
17 | from this_version import * |
---|
18 | |
---|
19 | VERSION = get_aubio_version() |
---|
20 | LIB_VERSION = get_libaubio_version() |
---|
21 | |
---|
22 | top = '.' |
---|
23 | out = 'build' |
---|
24 | |
---|
25 | def add_option_enable_disable(ctx, name, default = None, |
---|
26 | help_str = None, help_disable_str = None): |
---|
27 | if help_str == None: |
---|
28 | help_str = 'enable ' + name + ' support' |
---|
29 | if help_disable_str == None: |
---|
30 | help_disable_str = 'do not ' + help_str |
---|
31 | ctx.add_option('--enable-' + name, action = 'store_true', |
---|
32 | default = default, |
---|
33 | dest = 'enable_' + name.replace('-','_'), |
---|
34 | help = help_str) |
---|
35 | ctx.add_option('--disable-' + name, action = 'store_false', |
---|
36 | #default = default, |
---|
37 | dest = 'enable_' + name.replace('-','_'), |
---|
38 | help = help_disable_str ) |
---|
39 | |
---|
40 | def options(ctx): |
---|
41 | ctx.add_option('--build-type', action = 'store', |
---|
42 | default = "release", |
---|
43 | choices = ('debug', 'release'), |
---|
44 | dest = 'build_type', |
---|
45 | help = 'whether to compile with (--build-type=release)' \ |
---|
46 | ' or without (--build-type=debug)' \ |
---|
47 | ' compiler opimizations [default: release]') |
---|
48 | ctx.add_option('--debug', action = 'store_const', |
---|
49 | dest = 'build_type', const = 'debug', |
---|
50 | help = 'build in debug mode (see --build-type)') |
---|
51 | ctx.add_option('--nodeps', action = 'store_const', |
---|
52 | dest = 'nodeps', const = 'debug', |
---|
53 | help = 'build with no external dependencies') |
---|
54 | add_option_enable_disable(ctx, 'fftw3f', default = False, |
---|
55 | help_str = 'compile with fftw3f instead of ooura (recommended)', |
---|
56 | help_disable_str = 'do not compile with fftw3f') |
---|
57 | add_option_enable_disable(ctx, 'fftw3', default = False, |
---|
58 | help_str = 'compile with fftw3 instead of ooura', |
---|
59 | help_disable_str = 'do not compile with fftw3') |
---|
60 | add_option_enable_disable(ctx, 'intelipp', default = False, |
---|
61 | help_str = 'use Intel IPP libraries (auto)', |
---|
62 | help_disable_str = 'do not use Intel IPP libraries') |
---|
63 | add_option_enable_disable(ctx, 'complex', default = False, |
---|
64 | help_str ='compile with C99 complex', |
---|
65 | help_disable_str = 'do not use C99 complex (default)' ) |
---|
66 | add_option_enable_disable(ctx, 'jack', default = None, |
---|
67 | help_str = 'compile with jack (auto)', |
---|
68 | help_disable_str = 'disable jack support') |
---|
69 | add_option_enable_disable(ctx, 'sndfile', default = None, |
---|
70 | help_str = 'compile with sndfile (auto)', |
---|
71 | help_disable_str = 'disable sndfile') |
---|
72 | add_option_enable_disable(ctx, 'avcodec', default = None, |
---|
73 | help_str = 'compile with libavcodec (auto)', |
---|
74 | help_disable_str = 'disable libavcodec') |
---|
75 | add_option_enable_disable(ctx, 'vorbis', default = None, |
---|
76 | help_str = 'compile with libvorbis (auto)', |
---|
77 | help_disable_str = 'disable libvorbis') |
---|
78 | add_option_enable_disable(ctx, 'flac', default = None, |
---|
79 | help_str = 'compile with libFLAC (auto)', |
---|
80 | help_disable_str = 'disable libflac') |
---|
81 | add_option_enable_disable(ctx, 'samplerate', default = None, |
---|
82 | help_str = 'compile with samplerate (auto)', |
---|
83 | help_disable_str = 'disable samplerate') |
---|
84 | add_option_enable_disable(ctx, 'rubberband', default = None, |
---|
85 | help_str = 'compile with rubberband (auto)', |
---|
86 | help_disable_str = 'disable rubberband') |
---|
87 | add_option_enable_disable(ctx, 'memcpy', default = True, |
---|
88 | help_str = 'use memcpy hacks (default)', |
---|
89 | help_disable_str = 'do not use memcpy hacks') |
---|
90 | add_option_enable_disable(ctx, 'double', default = False, |
---|
91 | help_str = 'compile in double precision mode', |
---|
92 | help_disable_str = 'compile in single precision mode (default)') |
---|
93 | add_option_enable_disable(ctx, 'fat', default = False, |
---|
94 | help_str = 'build fat binaries (darwin only)', |
---|
95 | help_disable_str = 'do not build fat binaries (default)') |
---|
96 | add_option_enable_disable(ctx, 'accelerate', default = None, |
---|
97 | help_str = 'use Accelerate framework (darwin only) (auto)', |
---|
98 | help_disable_str = 'do not use Accelerate framework') |
---|
99 | add_option_enable_disable(ctx, 'apple-audio', default = None, |
---|
100 | help_str = 'use CoreFoundation (darwin only) (auto)', |
---|
101 | help_disable_str = 'do not use CoreFoundation framework') |
---|
102 | add_option_enable_disable(ctx, 'blas', default = None, |
---|
103 | help_str = 'use BLAS acceleration library (no)', |
---|
104 | help_disable_str = 'do not use BLAS library') |
---|
105 | add_option_enable_disable(ctx, 'atlas', default = None, |
---|
106 | help_str = 'use ATLAS acceleration library (no)', |
---|
107 | help_disable_str = 'do not use ATLAS library') |
---|
108 | add_option_enable_disable(ctx, 'wavread', default = True, |
---|
109 | help_str = 'compile with source_wavread (default)', |
---|
110 | help_disable_str = 'do not compile source_wavread') |
---|
111 | add_option_enable_disable(ctx, 'wavwrite', default = True, |
---|
112 | help_str = 'compile with source_wavwrite (default)', |
---|
113 | help_disable_str = 'do not compile source_wavwrite') |
---|
114 | |
---|
115 | add_option_enable_disable(ctx, 'hdf5', default = None, |
---|
116 | help_str = 'use libhdf5 (default)', |
---|
117 | help_disable_str = 'do not use libhdf5') |
---|
118 | |
---|
119 | add_option_enable_disable(ctx, 'docs', default = None, |
---|
120 | help_str = 'build documentation (auto)', |
---|
121 | help_disable_str = 'do not build documentation') |
---|
122 | |
---|
123 | add_option_enable_disable(ctx, 'tests', default = True, |
---|
124 | help_str = 'build tests (true)', |
---|
125 | help_disable_str = 'do not build or run tests') |
---|
126 | |
---|
127 | add_option_enable_disable(ctx, 'examples', default = True, |
---|
128 | help_str = 'build examples (true)', |
---|
129 | help_disable_str = 'do not build examples') |
---|
130 | |
---|
131 | ctx.add_option('--with-target-platform', type='string', |
---|
132 | help='set target platform for cross-compilation', |
---|
133 | dest='target_platform') |
---|
134 | |
---|
135 | ctx.load('compiler_c') |
---|
136 | ctx.load('waf_unit_test') |
---|
137 | ctx.load('gnu_dirs') |
---|
138 | ctx.load('waf_gensyms', tooldir='.') |
---|
139 | |
---|
140 | def configure(ctx): |
---|
141 | target_platform = sys.platform |
---|
142 | if ctx.options.target_platform: |
---|
143 | target_platform = ctx.options.target_platform |
---|
144 | |
---|
145 | if ctx.options.nodeps: |
---|
146 | external_deps = [ |
---|
147 | 'sndfile', |
---|
148 | 'samplerate', |
---|
149 | 'jack', |
---|
150 | 'rubberband', |
---|
151 | 'avcodec', |
---|
152 | 'blas', |
---|
153 | 'fftw3', |
---|
154 | 'fftw3f', |
---|
155 | 'flac', |
---|
156 | 'vorbis', |
---|
157 | ] |
---|
158 | for d in external_deps: |
---|
159 | if not hasattr(ctx.options, 'enable_' + d): |
---|
160 | raise ctx.errors.ConfigurationError ('--enable-%s missing from options' % d) |
---|
161 | if getattr(ctx.options, 'enable_' + d) == True: |
---|
162 | msg = 'Option --nodeps can not be used along with --enable-%s' % d |
---|
163 | raise ctx.errors.ConfigurationError (msg) |
---|
164 | elif getattr(ctx.options, 'enable_' + d) is None: |
---|
165 | msg = 'Option --nodeps used but automatic detection with --enable-%s' % d |
---|
166 | ctx.msg('Warning', msg) |
---|
167 | setattr(ctx.options, 'enable_' + d, False) |
---|
168 | |
---|
169 | from waflib import Options |
---|
170 | |
---|
171 | if target_platform=='emscripten': |
---|
172 | ctx.load('c_emscripten') |
---|
173 | else: |
---|
174 | ctx.load('compiler_c') |
---|
175 | |
---|
176 | ctx.load('waf_unit_test') |
---|
177 | ctx.load('gnu_dirs') |
---|
178 | ctx.load('waf_gensyms', tooldir='.') |
---|
179 | |
---|
180 | # check for common headers |
---|
181 | ctx.check(header_name='stdlib.h') |
---|
182 | ctx.check(header_name='stdio.h') |
---|
183 | ctx.check(header_name='math.h') |
---|
184 | ctx.check(header_name='string.h') |
---|
185 | ctx.check(header_name='errno.h') |
---|
186 | ctx.check(header_name='limits.h') |
---|
187 | ctx.check(header_name='stdarg.h') |
---|
188 | ctx.check(header_name='getopt.h', mandatory = False) |
---|
189 | ctx.check(header_name='unistd.h', mandatory = False) |
---|
190 | |
---|
191 | ctx.env['DEST_OS'] = target_platform |
---|
192 | |
---|
193 | if ctx.options.build_type == "debug": |
---|
194 | ctx.define('DEBUG', 1) |
---|
195 | else: |
---|
196 | ctx.define('NDEBUG', 1) |
---|
197 | |
---|
198 | if ctx.env.CC_NAME != 'msvc': |
---|
199 | if ctx.options.build_type == "debug": |
---|
200 | # no optimization in debug mode |
---|
201 | ctx.env.prepend_value('CFLAGS', ['-O0']) |
---|
202 | else: |
---|
203 | if target_platform == 'emscripten': |
---|
204 | # -Oz for small js file generation |
---|
205 | ctx.env.prepend_value('CFLAGS', ['-Oz']) |
---|
206 | else: |
---|
207 | # default to -O2 in release mode |
---|
208 | ctx.env.prepend_value('CFLAGS', ['-O2']) |
---|
209 | # enable debug symbols and configure warnings |
---|
210 | ctx.env.prepend_value('CFLAGS', ['-g', '-Wall', '-Wextra']) |
---|
211 | else: |
---|
212 | # enable debug symbols |
---|
213 | ctx.env.CFLAGS += ['/Z7'] |
---|
214 | # /FS flag available in msvc >= 12 (2013) |
---|
215 | if 'MSVC_VERSION' in ctx.env and ctx.env.MSVC_VERSION >= 12: |
---|
216 | ctx.env.CFLAGS += ['/FS'] |
---|
217 | ctx.env.LINKFLAGS += ['/DEBUG', '/INCREMENTAL:NO'] |
---|
218 | # configure warnings |
---|
219 | ctx.env.CFLAGS += ['/W4', '/D_CRT_SECURE_NO_WARNINGS'] |
---|
220 | # ignore "possible loss of data" warnings |
---|
221 | ctx.env.CFLAGS += ['/wd4305', '/wd4244', '/wd4245', '/wd4267'] |
---|
222 | # ignore "unreferenced formal parameter" warnings |
---|
223 | ctx.env.CFLAGS += ['/wd4100'] |
---|
224 | # set optimization level and runtime libs |
---|
225 | if (ctx.options.build_type == "release"): |
---|
226 | ctx.env.CFLAGS += ['/Ox'] |
---|
227 | ctx.env.CFLAGS += ['/MD'] |
---|
228 | else: |
---|
229 | assert(ctx.options.build_type == "debug") |
---|
230 | ctx.env.CFLAGS += ['/MDd'] |
---|
231 | |
---|
232 | ctx.check_cc(lib='m', uselib_store='M', mandatory=False) |
---|
233 | |
---|
234 | if target_platform not in ['win32', 'win64']: |
---|
235 | ctx.env.CFLAGS += ['-fPIC'] |
---|
236 | else: |
---|
237 | ctx.define('HAVE_WIN_HACKS', 1) |
---|
238 | ctx.env['cshlib_PATTERN'] = 'lib%s.dll' |
---|
239 | |
---|
240 | if target_platform == 'darwin' and ctx.options.enable_fat: |
---|
241 | ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
242 | ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
243 | MINSDKVER="10.4" |
---|
244 | ctx.env.CFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ] |
---|
245 | ctx.env.LINKFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ] |
---|
246 | |
---|
247 | if target_platform in [ 'darwin', 'ios', 'iosimulator']: |
---|
248 | if (ctx.options.enable_apple_audio != False): |
---|
249 | ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox'] |
---|
250 | ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1) |
---|
251 | ctx.define('HAVE_SINK_APPLE_AUDIO', 1) |
---|
252 | ctx.msg('Checking for AudioToolbox.framework', 'yes') |
---|
253 | else: |
---|
254 | ctx.msg('Checking for AudioToolbox.framework', 'no (disabled)', |
---|
255 | color = 'YELLOW') |
---|
256 | if (ctx.options.enable_accelerate != False): |
---|
257 | ctx.define('HAVE_ACCELERATE', 1) |
---|
258 | ctx.env.FRAMEWORK += ['Accelerate'] |
---|
259 | ctx.msg('Checking for Accelerate framework', 'yes') |
---|
260 | else: |
---|
261 | ctx.msg('Checking for Accelerate framework', 'no (disabled)', |
---|
262 | color = 'YELLOW') |
---|
263 | |
---|
264 | if target_platform in [ 'ios', 'iosimulator' ]: |
---|
265 | MINSDKVER="6.1" |
---|
266 | ctx.env.CFLAGS += ['-std=c99'] |
---|
267 | if (ctx.options.enable_apple_audio != False): |
---|
268 | ctx.define('HAVE_AUDIO_UNIT', 1) |
---|
269 | #ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox'] |
---|
270 | if target_platform == 'ios': |
---|
271 | DEVROOT = "/Applications/Xcode.app/Contents" |
---|
272 | DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer" |
---|
273 | SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS.sdk" % locals() |
---|
274 | ctx.env.CFLAGS += [ '-fembed-bitcode' ] |
---|
275 | ctx.env.CFLAGS += [ '-arch', 'arm64' ] |
---|
276 | ctx.env.CFLAGS += [ '-arch', 'armv7' ] |
---|
277 | ctx.env.CFLAGS += [ '-arch', 'armv7s' ] |
---|
278 | ctx.env.LINKFLAGS += [ '-arch', 'arm64' ] |
---|
279 | ctx.env.LINKFLAGS += ['-arch', 'armv7'] |
---|
280 | ctx.env.LINKFLAGS += ['-arch', 'armv7s'] |
---|
281 | ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
282 | ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
283 | else: |
---|
284 | DEVROOT = "/Applications/Xcode.app/Contents" |
---|
285 | DEVROOT += "/Developer/Platforms/iPhoneSimulator.platform/Developer" |
---|
286 | SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator.sdk" % locals() |
---|
287 | ctx.env.CFLAGS += [ '-arch', 'i386' ] |
---|
288 | ctx.env.CFLAGS += [ '-arch', 'x86_64' ] |
---|
289 | ctx.env.LINKFLAGS += ['-arch', 'i386'] |
---|
290 | ctx.env.LINKFLAGS += ['-arch', 'x86_64'] |
---|
291 | ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
292 | ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
293 | ctx.env.CFLAGS += [ '-isysroot' , SDKROOT] |
---|
294 | ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT] |
---|
295 | |
---|
296 | if target_platform == 'emscripten': |
---|
297 | if ctx.options.build_type == "debug": |
---|
298 | ctx.env.cshlib_PATTERN = '%s.js' |
---|
299 | ctx.env.LINKFLAGS += ['-s','ASSERTIONS=2'] |
---|
300 | ctx.env.LINKFLAGS += ['-s','SAFE_HEAP=1'] |
---|
301 | ctx.env.LINKFLAGS += ['-s','ALIASING_FUNCTION_POINTERS=0'] |
---|
302 | ctx.env.LINKFLAGS += ['-O0'] |
---|
303 | else: |
---|
304 | ctx.env.LINKFLAGS += ['-Oz'] |
---|
305 | ctx.env.cshlib_PATTERN = '%s.min.js' |
---|
306 | |
---|
307 | # doesnt ship file system support in lib |
---|
308 | ctx.env.LINKFLAGS_cshlib += ['-s', 'NO_FILESYSTEM=1'] |
---|
309 | # put memory file inside generated js files for easier portability |
---|
310 | ctx.env.LINKFLAGS += ['--memory-init-file', '0'] |
---|
311 | ctx.env.cprogram_PATTERN = "%s.js" |
---|
312 | ctx.env.cstlib_PATTERN = '%s.a' |
---|
313 | |
---|
314 | # tell emscripten functions we want to expose |
---|
315 | from python.lib.gen_external import get_c_declarations, \ |
---|
316 | get_cpp_objects_from_c_declarations, \ |
---|
317 | get_all_func_names_from_lib, \ |
---|
318 | generate_lib_from_c_declarations |
---|
319 | # emscripten can't use double |
---|
320 | c_decls = get_c_declarations(usedouble=False) |
---|
321 | objects = list(get_cpp_objects_from_c_declarations(c_decls)) |
---|
322 | # ensure that aubio structs are exported |
---|
323 | objects += ['fvec_t', 'cvec_t', 'fmat_t'] |
---|
324 | lib = generate_lib_from_c_declarations(objects, c_decls) |
---|
325 | exported_funcnames = get_all_func_names_from_lib(lib) |
---|
326 | c_mangled_names = ['_' + s for s in exported_funcnames] |
---|
327 | ctx.env.LINKFLAGS_cshlib += ['-s', |
---|
328 | 'EXPORTED_FUNCTIONS=%s' % c_mangled_names] |
---|
329 | |
---|
330 | # check support for C99 __VA_ARGS__ macros |
---|
331 | check_c99_varargs = ''' |
---|
332 | #include <stdio.h> |
---|
333 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
334 | ''' |
---|
335 | |
---|
336 | if ctx.check_cc(fragment = check_c99_varargs, |
---|
337 | type='cstlib', |
---|
338 | msg = 'Checking for C99 __VA_ARGS__ macro', |
---|
339 | mandatory = False): |
---|
340 | ctx.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
341 | |
---|
342 | # show a message about enable_double status |
---|
343 | if (ctx.options.enable_double == True): |
---|
344 | ctx.msg('Checking for size of smpl_t', 'double') |
---|
345 | ctx.msg('Checking for size of lsmp_t', 'long double') |
---|
346 | else: |
---|
347 | ctx.msg('Checking for size of smpl_t', 'float') |
---|
348 | ctx.msg('Checking for size of lsmp_t', 'double') |
---|
349 | |
---|
350 | # optionally use complex.h |
---|
351 | if (ctx.options.enable_complex == True): |
---|
352 | ctx.check(header_name='complex.h') |
---|
353 | else: |
---|
354 | ctx.msg('Checking if complex.h is enabled', 'no') |
---|
355 | |
---|
356 | # check for Intel IPP |
---|
357 | if (ctx.options.enable_intelipp != False): |
---|
358 | has_ipp_headers = ctx.check(header_name=['ippcore.h', 'ippvm.h', |
---|
359 | 'ipps.h'], mandatory = False) |
---|
360 | has_ipp_libs = ctx.check(lib=['ippcore', 'ippvm', 'ipps'], |
---|
361 | uselib_store='INTEL_IPP', mandatory = False) |
---|
362 | if (has_ipp_headers and has_ipp_libs): |
---|
363 | ctx.msg('Checking if Intel IPP is available', 'yes') |
---|
364 | ctx.define('HAVE_INTEL_IPP', 1) |
---|
365 | if ctx.env.CC_NAME == 'msvc': |
---|
366 | # force linking multi-threaded static IPP libraries on Windows |
---|
367 | # with msvc |
---|
368 | ctx.define('_IPP_SEQUENTIAL_STATIC', 1) |
---|
369 | else: |
---|
370 | ctx.msg('Checking if Intel IPP is available', 'no') |
---|
371 | |
---|
372 | # check for fftw3 |
---|
373 | if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False): |
---|
374 | # one of fftwf or fftw3f |
---|
375 | if (ctx.options.enable_fftw3f != False): |
---|
376 | ctx.check_cfg(package = 'fftw3f', |
---|
377 | args = '--cflags --libs fftw3f >= 3.0.0', |
---|
378 | mandatory = ctx.options.enable_fftw3f) |
---|
379 | if (ctx.options.enable_double == True): |
---|
380 | ctx.msg('Warning', |
---|
381 | 'fftw3f enabled, but compiling in double precision!') |
---|
382 | else: |
---|
383 | # fftw3f disabled, take most sensible one according to |
---|
384 | # enable_double |
---|
385 | if (ctx.options.enable_double == True): |
---|
386 | ctx.check_cfg(package = 'fftw3', |
---|
387 | args = '--cflags --libs fftw3 >= 3.0.0.', |
---|
388 | mandatory = ctx.options.enable_fftw3) |
---|
389 | else: |
---|
390 | ctx.check_cfg(package = 'fftw3f', |
---|
391 | args = '--cflags --libs fftw3f >= 3.0.0', |
---|
392 | mandatory = ctx.options.enable_fftw3) |
---|
393 | ctx.define('HAVE_FFTW3', 1) |
---|
394 | |
---|
395 | # fftw not enabled, use vDSP, intelIPP or ooura |
---|
396 | if 'HAVE_FFTW3F' in ctx.env.define_key: |
---|
397 | ctx.msg('Checking for FFT implementation', 'fftw3f') |
---|
398 | elif 'HAVE_FFTW3' in ctx.env.define_key: |
---|
399 | ctx.msg('Checking for FFT implementation', 'fftw3') |
---|
400 | elif 'HAVE_ACCELERATE' in ctx.env.define_key: |
---|
401 | ctx.msg('Checking for FFT implementation', 'vDSP') |
---|
402 | elif 'HAVE_INTEL_IPP' in ctx.env.define_key: |
---|
403 | ctx.msg('Checking for FFT implementation', 'Intel IPP') |
---|
404 | else: |
---|
405 | ctx.msg('Checking for FFT implementation', 'ooura') |
---|
406 | |
---|
407 | # check for libsndfile |
---|
408 | if (ctx.options.enable_sndfile != False): |
---|
409 | ctx.check_cfg(package = 'sndfile', |
---|
410 | args = '--cflags --libs sndfile >= 1.0.4', |
---|
411 | mandatory = ctx.options.enable_sndfile) |
---|
412 | |
---|
413 | # check for libsamplerate |
---|
414 | if (ctx.options.enable_double): |
---|
415 | if (ctx.options.enable_samplerate): |
---|
416 | ctx.fatal("Could not compile aubio in double precision mode' \ |
---|
417 | ' with libsamplerate") |
---|
418 | else: |
---|
419 | ctx.options.enable_samplerate = False |
---|
420 | ctx.msg('Checking if using samplerate', |
---|
421 | 'no (disabled in double precision mode)', color = 'YELLOW') |
---|
422 | if (ctx.options.enable_samplerate != False): |
---|
423 | ctx.check_cfg(package = 'samplerate', |
---|
424 | args = '--cflags --libs samplerate >= 0.0.15', |
---|
425 | mandatory = ctx.options.enable_samplerate) |
---|
426 | |
---|
427 | # check for librubberband |
---|
428 | if (ctx.options.enable_rubberband != False): |
---|
429 | ctx.check_cfg(package = 'rubberband', atleast_version = '1.3', |
---|
430 | args = '--cflags --libs', |
---|
431 | mandatory = ctx.options.enable_rubberband) |
---|
432 | |
---|
433 | # check for jack |
---|
434 | if (ctx.options.enable_jack != False): |
---|
435 | ctx.check_cfg(package = 'jack', |
---|
436 | args = '--cflags --libs', |
---|
437 | mandatory = ctx.options.enable_jack) |
---|
438 | |
---|
439 | # check for libav |
---|
440 | if (ctx.options.enable_avcodec != False): |
---|
441 | ctx.check_cfg(package = 'libavcodec', |
---|
442 | args = '--cflags --libs libavcodec >= 54.35.0', |
---|
443 | uselib_store = 'AVCODEC', |
---|
444 | mandatory = ctx.options.enable_avcodec) |
---|
445 | ctx.check_cfg(package = 'libavformat', |
---|
446 | args = '--cflags --libs libavformat >= 52.3.0', |
---|
447 | uselib_store = 'AVFORMAT', |
---|
448 | mandatory = ctx.options.enable_avcodec) |
---|
449 | ctx.check_cfg(package = 'libavutil', |
---|
450 | args = '--cflags --libs libavutil >= 52.3.0', |
---|
451 | uselib_store = 'AVUTIL', |
---|
452 | mandatory = ctx.options.enable_avcodec) |
---|
453 | ctx.check_cfg(package = 'libswresample', |
---|
454 | args = '--cflags --libs libswresample >= 1.2.0', |
---|
455 | uselib_store = 'SWRESAMPLE', |
---|
456 | mandatory = False) |
---|
457 | if 'HAVE_SWRESAMPLE' not in ctx.env: |
---|
458 | ctx.check_cfg(package = 'libavresample', |
---|
459 | args = '--cflags --libs libavresample >= 1.0.1', |
---|
460 | uselib_store = 'AVRESAMPLE', |
---|
461 | mandatory = False) |
---|
462 | |
---|
463 | msg_check = 'Checking for all libav libraries' |
---|
464 | if 'HAVE_AVCODEC' not in ctx.env: |
---|
465 | ctx.msg(msg_check, 'not found (missing avcodec)', color = 'YELLOW') |
---|
466 | elif 'HAVE_AVFORMAT' not in ctx.env: |
---|
467 | ctx.msg(msg_check, 'not found (missing avformat)', color = 'YELLOW') |
---|
468 | elif 'HAVE_AVUTIL' not in ctx.env: |
---|
469 | ctx.msg(msg_check, 'not found (missing avutil)', color = 'YELLOW') |
---|
470 | elif 'HAVE_SWRESAMPLE' not in ctx.env \ |
---|
471 | and 'HAVE_AVRESAMPLE' not in ctx.env: |
---|
472 | resample_missing = 'not found (avresample or swresample required)' |
---|
473 | ctx.msg(msg_check, resample_missing, color = 'YELLOW') |
---|
474 | else: |
---|
475 | ctx.msg(msg_check, 'yes') |
---|
476 | if 'HAVE_SWRESAMPLE' in ctx.env: |
---|
477 | ctx.define('HAVE_SWRESAMPLE', 1) |
---|
478 | elif 'HAVE_AVRESAMPLE' in ctx.env: |
---|
479 | ctx.define('HAVE_AVRESAMPLE', 1) |
---|
480 | ctx.define('HAVE_LIBAV', 1) |
---|
481 | |
---|
482 | # check for vorbisenc |
---|
483 | if (ctx.options.enable_vorbis != False): |
---|
484 | ctx.check_cfg(package = 'vorbisenc vorbis ogg', |
---|
485 | args = '--cflags --libs', |
---|
486 | uselib_store = 'VORBISENC', |
---|
487 | mandatory = ctx.options.enable_vorbis) |
---|
488 | |
---|
489 | # check for flac |
---|
490 | if (ctx.options.enable_flac != False): |
---|
491 | ctx.check_cfg(package = 'flac', |
---|
492 | args = '--cflags --libs', |
---|
493 | uselib_store = 'FLAC', |
---|
494 | mandatory = ctx.options.enable_flac) |
---|
495 | |
---|
496 | if (ctx.options.enable_wavread != False): |
---|
497 | ctx.define('HAVE_WAVREAD', 1) |
---|
498 | ctx.msg('Checking if using source_wavread', |
---|
499 | ctx.options.enable_wavread and 'yes' or 'no') |
---|
500 | if (ctx.options.enable_wavwrite!= False): |
---|
501 | ctx.define('HAVE_WAVWRITE', 1) |
---|
502 | ctx.msg('Checking if using sink_wavwrite', |
---|
503 | ctx.options.enable_wavwrite and 'yes' or 'no') |
---|
504 | |
---|
505 | # use BLAS/ATLAS |
---|
506 | if (ctx.options.enable_blas != False): |
---|
507 | ctx.check_cfg(package = 'blas', |
---|
508 | args = '--cflags --libs', |
---|
509 | uselib_store='BLAS', mandatory = ctx.options.enable_blas) |
---|
510 | if 'LIB_BLAS' in ctx.env: |
---|
511 | blas_header = None |
---|
512 | if ctx.env['LIBPATH_BLAS']: |
---|
513 | if 'atlas' in ctx.env['LIBPATH_BLAS'][0]: |
---|
514 | blas_header = 'atlas/cblas.h' |
---|
515 | elif 'openblas' in ctx.env['LIBPATH_BLAS'][0]: |
---|
516 | blas_header = 'openblas/cblas.h' |
---|
517 | else: |
---|
518 | blas_header = 'cblas.h' |
---|
519 | ctx.check(header_name = blas_header, mandatory = |
---|
520 | ctx.options.enable_atlas) |
---|
521 | |
---|
522 | # use memcpy hacks |
---|
523 | if (ctx.options.enable_memcpy == True): |
---|
524 | ctx.define('HAVE_MEMCPY_HACKS', 1) |
---|
525 | |
---|
526 | if (ctx.options.enable_hdf5 != False): |
---|
527 | ctx.check_cfg(package='hdf5', args='--cflags --libs', |
---|
528 | uselib_store='HDF5', mandatory=ctx.options.enable_hdf5) |
---|
529 | ctx.check(lib=['hdf5_hl'], use = ['HDF5'], |
---|
530 | uselib_store='HDF5_HL', mandatory=ctx.options.enable_hdf5) |
---|
531 | |
---|
532 | # write configuration header |
---|
533 | ctx.write_config_header('src/config.h') |
---|
534 | |
---|
535 | # the following defines will be passed as arguments to the compiler |
---|
536 | # instead of being written to src/config.h |
---|
537 | ctx.define('HAVE_CONFIG_H', 1) |
---|
538 | |
---|
539 | # add some defines used in examples |
---|
540 | ctx.define('AUBIO_PREFIX', ctx.env['PREFIX']) |
---|
541 | ctx.define('PACKAGE', APPNAME) |
---|
542 | |
---|
543 | # double precision mode |
---|
544 | if (ctx.options.enable_double == True): |
---|
545 | ctx.define('HAVE_AUBIO_DOUBLE', 1) |
---|
546 | |
---|
547 | if (ctx.options.enable_docs != False): |
---|
548 | # check if txt2man is installed, optional |
---|
549 | try: |
---|
550 | ctx.find_program('txt2man', var='TXT2MAN') |
---|
551 | except ctx.errors.ConfigurationError: |
---|
552 | ctx.to_log('txt2man was not found (ignoring)') |
---|
553 | |
---|
554 | # check if doxygen is installed, optional |
---|
555 | try: |
---|
556 | ctx.find_program('doxygen', var='DOXYGEN') |
---|
557 | except ctx.errors.ConfigurationError: |
---|
558 | ctx.to_log('doxygen was not found (ignoring)') |
---|
559 | |
---|
560 | # check if sphinx-build is installed, optional |
---|
561 | try: |
---|
562 | ctx.find_program('sphinx-build', var='SPHINX') |
---|
563 | except ctx.errors.ConfigurationError: |
---|
564 | ctx.to_log('sphinx-build was not found (ignoring)') |
---|
565 | |
---|
566 | def build(bld): |
---|
567 | bld.env['VERSION'] = VERSION |
---|
568 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
569 | |
---|
570 | # main source |
---|
571 | bld.recurse('src') |
---|
572 | |
---|
573 | # add sub directories |
---|
574 | if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']: |
---|
575 | if bld.env['DEST_OS']=='emscripten' and not bld.options.testcmd: |
---|
576 | bld.options.testcmd = 'node %s' |
---|
577 | if bld.options.enable_examples: |
---|
578 | bld.recurse('examples') |
---|
579 | if bld.options.enable_tests: |
---|
580 | bld.recurse('tests') |
---|
581 | |
---|
582 | # pkg-config template |
---|
583 | bld( source = 'aubio.pc.in' ) |
---|
584 | |
---|
585 | # documentation |
---|
586 | txt2man(bld) |
---|
587 | doxygen(bld) |
---|
588 | sphinx(bld) |
---|
589 | |
---|
590 | from waflib.Tools import waf_unit_test |
---|
591 | bld.add_post_fun(waf_unit_test.summary) |
---|
592 | bld.add_post_fun(waf_unit_test.set_exit_code) |
---|
593 | |
---|
594 | def txt2man(bld): |
---|
595 | # build manpages from txt files using txt2man |
---|
596 | if bld.env['TXT2MAN']: |
---|
597 | from waflib import TaskGen |
---|
598 | if 'MANDIR' not in bld.env: |
---|
599 | bld.env['MANDIR'] = bld.env['DATAROOTDIR'] + '/man' |
---|
600 | bld.env.VERSION = VERSION |
---|
601 | rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`' |
---|
602 | rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}' |
---|
603 | rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual' |
---|
604 | rule_str += ' -s 1 ${SRC} > ${TGT}' |
---|
605 | TaskGen.declare_chain( |
---|
606 | name = 'txt2man', |
---|
607 | rule = rule_str, |
---|
608 | ext_in = '.txt', |
---|
609 | ext_out = '.1', |
---|
610 | reentrant = False, |
---|
611 | install_path = '${MANDIR}/man1', |
---|
612 | ) |
---|
613 | bld( source = bld.path.ant_glob('doc/*.txt') ) |
---|
614 | |
---|
615 | def doxygen(bld): |
---|
616 | # build documentation from source files using doxygen |
---|
617 | if bld.env['DOXYGEN']: |
---|
618 | bld.env.VERSION = VERSION |
---|
619 | rule = '( cat ${SRC[0]} && echo PROJECT_NUMBER=${VERSION}' |
---|
620 | rule += ' && echo OUTPUT_DIRECTORY=%s && echo HTML_OUTPUT=%s )' |
---|
621 | rule += ' | doxygen - > /dev/null' |
---|
622 | rule %= (os.path.abspath(out), 'api') |
---|
623 | bld( name = 'doxygen', rule = rule, |
---|
624 | source = ['doc/web.cfg'] |
---|
625 | + bld.path.find_dir('src').ant_glob('**/*.h'), |
---|
626 | target = bld.path.find_or_declare('api/index.html'), |
---|
627 | cwd = bld.path.find_dir('doc')) |
---|
628 | # evaluate nodes lazily to prevent build directory traversal warnings |
---|
629 | bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/api', |
---|
630 | bld.path.find_or_declare('api').ant_glob('**/*', |
---|
631 | generator=True), cwd=bld.path.find_or_declare('api'), |
---|
632 | relative_trick=True) |
---|
633 | |
---|
634 | def sphinx(bld): |
---|
635 | # build documentation from source files using sphinx-build |
---|
636 | try: |
---|
637 | import aubio |
---|
638 | has_aubio = True |
---|
639 | except ImportError: |
---|
640 | from waflib import Logs |
---|
641 | Logs.pprint('YELLOW', "Sphinx manual: install aubio first") |
---|
642 | has_aubio = False |
---|
643 | if bld.env['SPHINX'] and has_aubio: |
---|
644 | bld.env.VERSION = VERSION |
---|
645 | rule = '${SPHINX} -b html -D release=${VERSION}' \ |
---|
646 | ' -D version=${VERSION} -W -a -q' \ |
---|
647 | ' -d %s ' % os.path.join(os.path.abspath(out), 'doctrees') |
---|
648 | rule += ' . %s' % os.path.join(os.path.abspath(out), 'manual') |
---|
649 | bld( name = 'sphinx', rule = rule, |
---|
650 | cwd = bld.path.find_dir('doc'), |
---|
651 | source = bld.path.find_dir('doc').ant_glob('*.rst'), |
---|
652 | target = bld.path.find_or_declare('manual/index.html')) |
---|
653 | # evaluate nodes lazily to prevent build directory traversal warnings |
---|
654 | bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/manual', |
---|
655 | bld.path.find_or_declare('manual').ant_glob('**/*', |
---|
656 | generator=True), cwd=bld.path.find_or_declare('manual'), |
---|
657 | relative_trick=True) |
---|
658 | |
---|
659 | # register the previous rules as build rules |
---|
660 | from waflib.Build import BuildContext |
---|
661 | |
---|
662 | class build_txt2man(BuildContext): |
---|
663 | cmd = 'txt2man' |
---|
664 | fun = 'txt2man' |
---|
665 | |
---|
666 | class build_manpages(BuildContext): |
---|
667 | cmd = 'manpages' |
---|
668 | fun = 'txt2man' |
---|
669 | |
---|
670 | class build_sphinx(BuildContext): |
---|
671 | cmd = 'sphinx' |
---|
672 | fun = 'sphinx' |
---|
673 | |
---|
674 | class build_doxygen(BuildContext): |
---|
675 | cmd = 'doxygen' |
---|
676 | fun = 'doxygen' |
---|
677 | |
---|
678 | def shutdown(bld): |
---|
679 | from waflib import Logs |
---|
680 | if bld.options.target_platform in ['ios', 'iosimulator']: |
---|
681 | msg ='building for %s, contact the author for a commercial license' \ |
---|
682 | % bld.options.target_platform |
---|
683 | Logs.pprint('RED', msg) |
---|
684 | msg =' Paul Brossier <piem@aubio.org>' |
---|
685 | Logs.pprint('RED', msg) |
---|
686 | |
---|
687 | def dist(ctx): |
---|
688 | ctx.excl = ' **/.waf*' |
---|
689 | ctx.excl += ' **/.git*' |
---|
690 | ctx.excl += ' **/*~ **/*.pyc **/*.swp **/*.swo **/*.swn **/.lock-w*' |
---|
691 | ctx.excl += ' **/build/*' |
---|
692 | ctx.excl += ' doc/_build' |
---|
693 | ctx.excl += ' python/demos_*' |
---|
694 | ctx.excl += ' **/python/gen **/python/build **/python/dist' |
---|
695 | ctx.excl += ' **/python/ext/config.h' |
---|
696 | ctx.excl += ' **/python/lib/aubio/_aubio.so' |
---|
697 | ctx.excl += ' **.egg-info' |
---|
698 | ctx.excl += ' **/.eggs' |
---|
699 | ctx.excl += ' **/.pytest_cache' |
---|
700 | ctx.excl += ' **/.cache' |
---|
701 | ctx.excl += ' **/**.zip **/**.tar.bz2' |
---|
702 | ctx.excl += ' **.tar.bz2**' |
---|
703 | ctx.excl += ' **/doc/full/* **/doc/web/*' |
---|
704 | ctx.excl += ' **/doc/full.cfg' |
---|
705 | ctx.excl += ' **/python/*.db' |
---|
706 | ctx.excl += ' **/python.old/*' |
---|
707 | ctx.excl += ' **/python/*/*.old' |
---|
708 | ctx.excl += ' **/python/lib/aubio/*.so' |
---|
709 | ctx.excl += ' **/python/tests/sounds' |
---|
710 | ctx.excl += ' **/**.asc' |
---|
711 | ctx.excl += ' **/dist*' |
---|
712 | ctx.excl += ' **/.DS_Store' |
---|
713 | ctx.excl += ' **/.travis.yml' |
---|
714 | ctx.excl += ' **/.appveyor.yml' |
---|
715 | ctx.excl += ' **/.circleci/*' |
---|
716 | ctx.excl += ' **/azure-pipelines.yml' |
---|
717 | ctx.excl += ' **/.coverage*' |
---|