7 # $ ./waf distclean configure build
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/ .
18 from this_version import *
20 VERSION = get_aubio_version()
21 LIB_VERSION = get_libaubio_version()
26 def add_option_enable_disable(ctx, name, default = None,
27 help_str = None, help_disable_str = None):
29 help_str = 'enable ' + name + ' support'
30 if help_disable_str == None:
31 help_disable_str = 'do not ' + help_str
32 ctx.add_option('--enable-' + name, action = 'store_true',
34 dest = 'enable_' + name.replace('-','_'),
36 ctx.add_option('--disable-' + name, action = 'store_false',
38 dest = 'enable_' + name.replace('-','_'),
39 help = help_disable_str )
42 ctx.add_option('--build-type', action = 'store',
44 choices = ('debug', 'release'),
46 help = 'whether to compile with (--build-type=release)' \
47 ' or without (--build-type=debug)' \
48 ' compiler opimizations [default: release]')
49 ctx.add_option('--debug', action = 'store_const',
50 dest = 'build_type', const = 'debug',
51 help = 'build in debug mode (see --build-type)')
52 ctx.add_option('--nodeps', action = 'store_const',
53 dest = 'nodeps', const = 'debug',
54 help = 'build with no external dependencies')
55 add_option_enable_disable(ctx, 'fftw3f', default = False,
56 help_str = 'compile with fftw3f instead of ooura (recommended)',
57 help_disable_str = 'do not compile with fftw3f')
58 add_option_enable_disable(ctx, 'fftw3', default = False,
59 help_str = 'compile with fftw3 instead of ooura',
60 help_disable_str = 'do not compile with fftw3')
61 add_option_enable_disable(ctx, 'intelipp', default = False,
62 help_str = 'use Intel IPP libraries (auto)',
63 help_disable_str = 'do not use Intel IPP libraries')
64 add_option_enable_disable(ctx, 'complex', default = False,
65 help_str ='compile with C99 complex',
66 help_disable_str = 'do not use C99 complex (default)' )
67 add_option_enable_disable(ctx, 'jack', default = None,
68 help_str = 'compile with jack (auto)',
69 help_disable_str = 'disable jack support')
70 add_option_enable_disable(ctx, 'sndfile', default = None,
71 help_str = 'compile with sndfile (auto)',
72 help_disable_str = 'disable sndfile')
73 add_option_enable_disable(ctx, 'avcodec', default = None,
74 help_str = 'compile with libavcodec (auto)',
75 help_disable_str = 'disable libavcodec')
76 add_option_enable_disable(ctx, 'vorbis', default = None,
77 help_str = 'compile with libvorbis (auto)',
78 help_disable_str = 'disable libvorbis')
79 add_option_enable_disable(ctx, 'flac', default = None,
80 help_str = 'compile with libFLAC (auto)',
81 help_disable_str = 'disable libflac')
82 add_option_enable_disable(ctx, 'samplerate', default = None,
83 help_str = 'compile with samplerate (auto)',
84 help_disable_str = 'disable samplerate')
85 add_option_enable_disable(ctx, 'rubberband', default = None,
86 help_str = 'compile with rubberband (auto)',
87 help_disable_str = 'disable rubberband')
88 add_option_enable_disable(ctx, 'memcpy', default = True,
89 help_str = 'use memcpy hacks (default)',
90 help_disable_str = 'do not use memcpy hacks')
91 add_option_enable_disable(ctx, 'double', default = False,
92 help_str = 'compile in double precision mode',
93 help_disable_str = 'compile in single precision mode (default)')
94 add_option_enable_disable(ctx, 'fat', default = False,
95 help_str = 'build fat binaries (darwin only)',
96 help_disable_str = 'do not build fat binaries (default)')
97 add_option_enable_disable(ctx, 'accelerate', default = None,
98 help_str = 'use Accelerate framework (darwin only) (auto)',
99 help_disable_str = 'do not use Accelerate framework')
100 add_option_enable_disable(ctx, 'apple-audio', default = None,
101 help_str = 'use CoreFoundation (darwin only) (auto)',
102 help_disable_str = 'do not use CoreFoundation framework')
103 add_option_enable_disable(ctx, 'blas', default = False,
104 help_str = 'use BLAS acceleration library (no)',
105 help_disable_str = 'do not use BLAS library')
106 add_option_enable_disable(ctx, 'atlas', default = False,
107 help_str = 'use ATLAS acceleration library (no)',
108 help_disable_str = 'do not use ATLAS library')
109 add_option_enable_disable(ctx, 'wavread', default = True,
110 help_str = 'compile with source_wavread (default)',
111 help_disable_str = 'do not compile source_wavread')
112 add_option_enable_disable(ctx, 'wavwrite', default = True,
113 help_str = 'compile with source_wavwrite (default)',
114 help_disable_str = 'do not compile source_wavwrite')
116 add_option_enable_disable(ctx, 'docs', default = None,
117 help_str = 'build documentation (auto)',
118 help_disable_str = 'do not build documentation')
120 add_option_enable_disable(ctx, 'tests', default = True,
121 help_str = 'build tests (true)',
122 help_disable_str = 'do not build or run tests')
124 add_option_enable_disable(ctx, 'examples', default = True,
125 help_str = 'build examples (true)',
126 help_disable_str = 'do not build examples')
128 ctx.add_option('--with-target-platform', type='string',
129 help='set target platform for cross-compilation',
130 dest='target_platform')
132 ctx.load('compiler_c')
133 ctx.load('waf_unit_test')
135 ctx.load('waf_gensyms', tooldir='.')
138 target_platform = sys.platform
139 if ctx.options.target_platform:
140 target_platform = ctx.options.target_platform
142 if ctx.options.nodeps:
155 for d in external_deps:
156 if not hasattr(ctx.options, 'enable_' + d):
157 raise ctx.errors.ConfigurationError ('--enable-%s missing from options' % d)
158 if getattr(ctx.options, 'enable_' + d) == True:
159 msg = 'Option --nodeps can not be used along with --enable-%s' % d
160 raise ctx.errors.ConfigurationError (msg)
161 elif getattr(ctx.options, 'enable_' + d) is None:
162 msg = 'Option --nodeps used but automatic detection with --enable-%s' % d
163 ctx.msg('Warning', msg)
164 setattr(ctx.options, 'enable_' + d, False)
166 from waflib import Options
168 if target_platform=='emscripten':
169 ctx.load('c_emscripten')
171 ctx.load('compiler_c')
173 ctx.load('waf_unit_test')
175 ctx.load('waf_gensyms', tooldir='.')
177 # check for common headers
178 ctx.check(header_name='stdlib.h')
179 ctx.check(header_name='stdio.h')
180 ctx.check(header_name='math.h')
181 ctx.check(header_name='string.h')
182 ctx.check(header_name='errno.h')
183 ctx.check(header_name='limits.h')
184 ctx.check(header_name='stdarg.h')
185 ctx.check(header_name='getopt.h', mandatory = False)
186 ctx.check(header_name='unistd.h', mandatory = False)
188 ctx.env['DEST_OS'] = target_platform
190 if ctx.options.build_type == "debug":
191 ctx.define('DEBUG', 1)
193 ctx.define('NDEBUG', 1)
195 if ctx.env.CC_NAME != 'msvc':
196 if ctx.options.build_type == "debug":
197 # no optimization in debug mode
198 ctx.env.prepend_value('CFLAGS', ['-O0'])
200 if target_platform == 'emscripten':
201 # -Oz for small js file generation
202 ctx.env.prepend_value('CFLAGS', ['-Oz'])
204 # default to -O2 in release mode
205 ctx.env.prepend_value('CFLAGS', ['-O2'])
206 # enable debug symbols and configure warnings
207 ctx.env.prepend_value('CFLAGS', ['-g', '-Wall', '-Wextra'])
209 # enable debug symbols
210 ctx.env.CFLAGS += ['/Z7']
211 # /FS flag available in msvc >= 12 (2013)
212 if 'MSVC_VERSION' in ctx.env and ctx.env.MSVC_VERSION >= 12:
213 ctx.env.CFLAGS += ['/FS']
214 ctx.env.LINKFLAGS += ['/DEBUG', '/INCREMENTAL:NO']
216 ctx.env.CFLAGS += ['/W4', '/D_CRT_SECURE_NO_WARNINGS']
217 # ignore "possible loss of data" warnings
218 ctx.env.CFLAGS += ['/wd4305', '/wd4244', '/wd4245', '/wd4267']
219 # ignore "unreferenced formal parameter" warnings
220 ctx.env.CFLAGS += ['/wd4100']
221 # set optimization level and runtime libs
222 if (ctx.options.build_type == "release"):
223 ctx.env.CFLAGS += ['/Ox']
224 ctx.env.CFLAGS += ['/MD']
226 assert(ctx.options.build_type == "debug")
227 ctx.env.CFLAGS += ['/MDd']
229 ctx.check_cc(lib='m', uselib_store='M', mandatory=False)
231 if target_platform not in ['win32', 'win64']:
232 ctx.env.CFLAGS += ['-fPIC']
234 ctx.define('HAVE_WIN_HACKS', 1)
235 ctx.env['cshlib_PATTERN'] = 'lib%s.dll'
237 if target_platform == 'darwin' and ctx.options.enable_fat:
238 ctx.env.CFLAGS += ['-arch', 'arm64', '-arch', 'x86_64']
239 ctx.env.LINKFLAGS += ['-arch', 'arm64', '-arch', 'x86_64']
241 ctx.env.CFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ]
242 ctx.env.LINKFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ]
244 if target_platform in [ 'darwin', 'ios', 'iosimulator' ]:
245 if (ctx.options.enable_apple_audio != False):
246 ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
247 ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1)
248 ctx.define('HAVE_SINK_APPLE_AUDIO', 1)
249 ctx.msg('Checking for AudioToolbox.framework', 'yes')
251 ctx.msg('Checking for AudioToolbox.framework', 'no (disabled)',
253 if (ctx.options.enable_accelerate != False):
254 ctx.define('HAVE_ACCELERATE', 1)
255 ctx.env.FRAMEWORK += ['Accelerate']
256 ctx.msg('Checking for Accelerate framework', 'yes')
258 ctx.msg('Checking for Accelerate framework', 'no (disabled)',
261 if target_platform in [ 'ios', 'iosimulator', 'watchos', 'watchsimulator',
262 'tvos', 'tvsimulator', 'visionos', 'visionsimulator' ]:
263 if target_platform in ['ios', 'iosimulator']:
265 elif target_platform in ['watchos', 'watchsimulator']:
267 elif target_platform in ['tvos', 'tvsimulator']:
269 elif target_platform in ['visionos', 'visionsimulator']:
271 xcodeslct_output = subprocess.check_output (['xcode-select', '--print-path'])
272 XCODEPATH = xcodeslct_output.decode(sys.stdout.encoding).strip()
273 if target_platform == 'ios':
275 elif target_platform == 'iosimulator':
276 SDKNAME = "iPhoneSimulator"
277 elif target_platform == 'watchos':
279 elif target_platform == 'watchsimulator':
280 SDKNAME = "WatchSimulator"
281 elif target_platform == 'tvos':
282 SDKNAME = "AppleTVOS"
283 elif target_platform == 'tvsimulator':
284 SDKNAME = "AppleTVSimulator"
285 elif target_platform == 'visionos':
287 elif target_platform == 'visionsimulator':
288 SDKNAME = "XRSimulator"
290 raise ctx.errors.ConfigurationError ("Error: unknown target platform '"
291 + target_platform + "'")
292 DEVROOT = "%(XCODEPATH)s/Platforms/%(SDKNAME)s.platform/Developer" % locals()
293 SDKROOT = "%(DEVROOT)s/SDKs/%(SDKNAME)s.sdk" % locals()
294 ctx.env.CFLAGS += ['-std=c99']
295 if ctx.options.enable_apple_audio != False and target_platform.startswith ('ios'):
296 #ctx.define('HAVE_AUDIO_UNIT', 1)
297 #ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
299 if target_platform == 'ios':
300 ctx.env.CFLAGS += [ '-fembed-bitcode' ]
301 ctx.env.CFLAGS += [ '-arch', 'arm64' ]
302 #ctx.env.CFLAGS += [ '-arch', 'armv7' ]
303 #ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
304 ctx.env.LINKFLAGS += [ '-arch', 'arm64' ]
305 #ctx.env.LINKFLAGS += ['-arch', 'armv7']
306 #ctx.env.LINKFLAGS += ['-arch', 'armv7s']
307 ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
308 ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
309 elif target_platform == 'iosimulator':
310 ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
311 ctx.env.CFLAGS += [ '-arch', 'arm64' ]
312 ctx.env.LINKFLAGS += ['-arch', 'x86_64']
313 ctx.env.LINKFLAGS += ['-arch', 'arm64']
314 ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
315 ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
316 elif target_platform == 'watchos':
317 ctx.env.CFLAGS += [ '-arch', 'armv7' ]
318 ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
319 ctx.env.LINKFLAGS += ['-arch', 'armv7']
320 ctx.env.LINKFLAGS += ['-arch', 'armv7s']
321 ctx.env.CFLAGS += [ '-mwatchos-version-min=' + MINSDKVER ]
322 ctx.env.LINKFLAGS += [ '-mwatchos-version-min=' + MINSDKVER ]
323 elif target_platform == 'watchsimulator':
324 ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
325 ctx.env.CFLAGS += [ '-arch', 'arm64' ]
326 ctx.env.LINKFLAGS += ['-arch', 'x86_64']
327 ctx.env.LINKFLAGS += ['-arch', 'arm64']
328 ctx.env.CFLAGS += [ '-mwatchsimulator-version-min=' + MINSDKVER ]
329 ctx.env.LINKFLAGS += [ '-mwatchsimulator-version-min=' + MINSDKVER ]
330 elif target_platform == 'tvos':
331 ctx.env.CFLAGS += [ '-arch', 'arm64' ]
332 ctx.env.CFLAGS += [ '-arch', 'arm64e' ]
333 ctx.env.LINKFLAGS += ['-arch', 'arm64']
334 ctx.env.LINKFLAGS += ['-arch', 'arm64e']
335 ctx.env.CFLAGS += [ '-mtvos-version-min=' + MINSDKVER ]
336 ctx.env.LINKFLAGS += [ '-mtvos-version-min=' + MINSDKVER ]
337 elif target_platform == 'tvsimulator':
338 ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
339 ctx.env.CFLAGS += [ '-arch', 'arm64' ]
340 ctx.env.LINKFLAGS += ['-arch', 'x86_64']
341 ctx.env.LINKFLAGS += ['-arch', 'arm64']
342 ctx.env.CFLAGS += [ '-mtvos-simulator-version-min=' + MINSDKVER ]
343 ctx.env.LINKFLAGS += [ '-mtvos-simulator-version-min=' + MINSDKVER ]
344 elif target_platform == 'visionos':
345 ctx.env.CFLAGS += [ '-arch', 'arm64' ]
346 ctx.env.CFLAGS += [ '-arch', 'arm64e' ]
347 ctx.env.LINKFLAGS += ['-arch', 'arm64']
348 ctx.env.LINKFLAGS += ['-arch', 'arm64e']
349 elif target_platform == 'visionsimulator':
350 ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
351 ctx.env.CFLAGS += [ '-arch', 'arm64' ]
352 ctx.env.LINKFLAGS += ['-arch', 'x86_64']
353 ctx.env.LINKFLAGS += ['-arch', 'arm64']
354 if target_platform not in ['visionos', 'visionsimulator']:
355 ctx.env.CFLAGS += [ '-isysroot' , SDKROOT]
356 ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
358 ctx.env.CFLAGS += [ '--sysroot' , SDKROOT]
359 ctx.env.LINKFLAGS += [ '--sysroot' , SDKROOT]
361 if target_platform == 'emscripten':
362 if ctx.options.build_type == "debug":
363 ctx.env.cshlib_PATTERN = '%s.js'
364 ctx.env.LINKFLAGS += ['-s','ASSERTIONS=2']
365 ctx.env.LINKFLAGS += ['-s','SAFE_HEAP=1']
366 ctx.env.LINKFLAGS += ['-s','ALIASING_FUNCTION_POINTERS=0']
367 ctx.env.LINKFLAGS += ['-O0']
369 ctx.env.LINKFLAGS += ['-Oz']
370 ctx.env.cshlib_PATTERN = '%s.min.js'
372 # doesnt ship file system support in lib
373 ctx.env.LINKFLAGS_cshlib += ['-s', 'NO_FILESYSTEM=1']
374 # put memory file inside generated js files for easier portability
375 ctx.env.LINKFLAGS += ['--memory-init-file', '0']
376 ctx.env.cprogram_PATTERN = "%s.js"
377 ctx.env.cstlib_PATTERN = '%s.a'
379 # tell emscripten functions we want to expose
380 from python.lib.gen_external import get_c_declarations, \
381 get_cpp_objects_from_c_declarations, \
382 get_all_func_names_from_lib, \
383 generate_lib_from_c_declarations
384 # emscripten can't use double
385 c_decls = get_c_declarations(usedouble=False)
386 objects = list(get_cpp_objects_from_c_declarations(c_decls))
387 # ensure that aubio structs are exported
388 objects += ['fvec_t', 'cvec_t', 'fmat_t']
389 lib = generate_lib_from_c_declarations(objects, c_decls)
390 exported_funcnames = get_all_func_names_from_lib(lib)
391 c_mangled_names = ['_' + s for s in exported_funcnames]
392 ctx.env.LINKFLAGS_cshlib += ['-s',
393 'EXPORTED_FUNCTIONS=%s' % c_mangled_names]
395 # check support for C99 __VA_ARGS__ macros
396 check_c99_varargs = '''
398 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
401 if ctx.check_cc(fragment = check_c99_varargs,
403 msg = 'Checking for C99 __VA_ARGS__ macro',
405 ctx.define('HAVE_C99_VARARGS_MACROS', 1)
407 # show a message about enable_double status
408 if (ctx.options.enable_double == True):
409 ctx.msg('Checking for size of smpl_t', 'double')
410 ctx.msg('Checking for size of lsmp_t', 'long double')
412 ctx.msg('Checking for size of smpl_t', 'float')
413 ctx.msg('Checking for size of lsmp_t', 'double')
415 # optionally use complex.h
416 if (ctx.options.enable_complex == True):
417 ctx.check(header_name='complex.h')
419 ctx.msg('Checking if complex.h is enabled', 'no')
421 # check for Intel IPP
422 if (ctx.options.enable_intelipp != False):
423 has_ipp_headers = ctx.check(header_name=['ippcore.h', 'ippvm.h',
424 'ipps.h'], mandatory = False)
425 has_ipp_libs = ctx.check(lib=['ippcore', 'ippvm', 'ipps'],
426 uselib_store='INTEL_IPP', mandatory = False)
427 if (has_ipp_headers and has_ipp_libs):
428 ctx.msg('Checking if Intel IPP is available', 'yes')
429 ctx.define('HAVE_INTEL_IPP', 1)
430 if ctx.env.CC_NAME == 'msvc':
431 # force linking multi-threaded static IPP libraries on Windows
433 ctx.define('_IPP_SEQUENTIAL_STATIC', 1)
435 ctx.msg('Checking if Intel IPP is available', 'no')
438 if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False):
439 # one of fftwf or fftw3f
440 if (ctx.options.enable_fftw3f != False):
441 ctx.check_cfg(package = 'fftw3f',
442 args = '--cflags --libs fftw3f >= 3.0.0',
443 mandatory = ctx.options.enable_fftw3f)
444 if (ctx.options.enable_double == True):
446 'fftw3f enabled, but compiling in double precision!')
448 # fftw3f disabled, take most sensible one according to
450 if (ctx.options.enable_double == True):
451 ctx.check_cfg(package = 'fftw3',
452 args = '--cflags --libs fftw3 >= 3.0.0.',
453 mandatory = ctx.options.enable_fftw3)
455 ctx.check_cfg(package = 'fftw3f',
456 args = '--cflags --libs fftw3f >= 3.0.0',
457 mandatory = ctx.options.enable_fftw3)
458 ctx.define('HAVE_FFTW3', 1)
460 # fftw not enabled, use vDSP, intelIPP or ooura
461 if 'HAVE_FFTW3F' in ctx.env.define_key:
462 ctx.msg('Checking for FFT implementation', 'fftw3f')
463 elif 'HAVE_FFTW3' in ctx.env.define_key:
464 ctx.msg('Checking for FFT implementation', 'fftw3')
465 elif 'HAVE_ACCELERATE' in ctx.env.define_key:
466 ctx.msg('Checking for FFT implementation', 'vDSP')
467 elif 'HAVE_INTEL_IPP' in ctx.env.define_key:
468 ctx.msg('Checking for FFT implementation', 'Intel IPP')
470 ctx.msg('Checking for FFT implementation', 'ooura')
472 # check for libsndfile
473 if (ctx.options.enable_sndfile != False):
474 ctx.check_cfg(package = 'sndfile',
475 args = '--cflags --libs sndfile >= 1.0.4',
476 mandatory = ctx.options.enable_sndfile)
478 # check for libsamplerate
479 if (ctx.options.enable_double):
480 if (ctx.options.enable_samplerate):
481 ctx.fatal("Could not compile aubio in double precision mode' \
482 ' with libsamplerate")
484 ctx.options.enable_samplerate = False
485 ctx.msg('Checking if using samplerate',
486 'no (disabled in double precision mode)', color = 'YELLOW')
487 if (ctx.options.enable_samplerate != False):
488 ctx.check_cfg(package = 'samplerate',
489 args = '--cflags --libs samplerate >= 0.0.15',
490 mandatory = ctx.options.enable_samplerate)
492 # check for librubberband
493 if (ctx.options.enable_rubberband != False):
494 ctx.check_cfg(package = 'rubberband', atleast_version = '1.3',
495 args = '--cflags --libs',
496 mandatory = ctx.options.enable_rubberband)
499 if (ctx.options.enable_jack != False):
500 ctx.check_cfg(package = 'jack',
501 args = '--cflags --libs',
502 mandatory = ctx.options.enable_jack)
505 if (ctx.options.enable_avcodec != False):
506 ctx.check_cfg(package = 'libavcodec',
507 args = '--cflags --libs libavcodec >= 54.35.0',
508 uselib_store = 'AVCODEC',
509 mandatory = ctx.options.enable_avcodec)
510 ctx.check_cfg(package = 'libavformat',
511 args = '--cflags --libs libavformat >= 52.3.0',
512 uselib_store = 'AVFORMAT',
513 mandatory = ctx.options.enable_avcodec)
514 ctx.check_cfg(package = 'libavutil',
515 args = '--cflags --libs libavutil >= 52.3.0',
516 uselib_store = 'AVUTIL',
517 mandatory = ctx.options.enable_avcodec)
518 ctx.check_cfg(package = 'libswresample',
519 args = '--cflags --libs libswresample >= 1.2.0',
520 uselib_store = 'SWRESAMPLE',
523 msg_check = 'Checking for all libav libraries'
524 if 'HAVE_AVCODEC' not in ctx.env:
525 ctx.msg(msg_check, 'not found (missing avcodec)', color = 'YELLOW')
526 elif 'HAVE_AVFORMAT' not in ctx.env:
527 ctx.msg(msg_check, 'not found (missing avformat)', color = 'YELLOW')
528 elif 'HAVE_AVUTIL' not in ctx.env:
529 ctx.msg(msg_check, 'not found (missing avutil)', color = 'YELLOW')
530 elif 'HAVE_SWRESAMPLE' not in ctx.env :
531 resample_missing = 'not found (missing swresample)'
532 ctx.msg(msg_check, resample_missing, color = 'YELLOW')
534 ctx.msg(msg_check, 'yes')
535 ctx.define('HAVE_LIBAV', 1)
537 # check for vorbisenc
538 if (ctx.options.enable_vorbis != False):
539 ctx.check_cfg(package = 'vorbisenc vorbis ogg',
540 args = '--cflags --libs',
541 uselib_store = 'VORBISENC',
542 mandatory = ctx.options.enable_vorbis)
545 if (ctx.options.enable_flac != False):
546 ctx.check_cfg(package = 'flac',
547 args = '--cflags --libs',
548 uselib_store = 'FLAC',
549 mandatory = ctx.options.enable_flac)
551 if (ctx.options.enable_wavread != False):
552 ctx.define('HAVE_WAVREAD', 1)
553 ctx.msg('Checking if using source_wavread',
554 ctx.options.enable_wavread and 'yes' or 'no')
555 if (ctx.options.enable_wavwrite!= False):
556 ctx.define('HAVE_WAVWRITE', 1)
557 ctx.msg('Checking if using sink_wavwrite',
558 ctx.options.enable_wavwrite and 'yes' or 'no')
561 if (ctx.options.enable_blas != False):
562 ctx.check_cfg(package = 'blas',
563 args = '--cflags --libs',
564 uselib_store='BLAS', mandatory = ctx.options.enable_blas)
565 if 'LIB_BLAS' in ctx.env:
567 if ctx.env['LIBPATH_BLAS']:
568 if 'atlas' in ctx.env['LIBPATH_BLAS'][0]:
569 blas_header = 'atlas/cblas.h'
570 elif 'openblas' in ctx.env['LIBPATH_BLAS'][0]:
571 blas_header = 'openblas/cblas.h'
573 blas_header = 'cblas.h'
574 ctx.check(header_name = blas_header, mandatory =
575 ctx.options.enable_atlas)
578 if (ctx.options.enable_memcpy == True):
579 ctx.define('HAVE_MEMCPY_HACKS', 1)
581 # write configuration header
582 ctx.write_config_header('src/config.h')
584 # the following defines will be passed as arguments to the compiler
585 # instead of being written to src/config.h
586 ctx.define('HAVE_CONFIG_H', 1)
588 # add some defines used in examples
589 ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
590 ctx.define('PACKAGE', APPNAME)
592 # double precision mode
593 if (ctx.options.enable_double == True):
594 ctx.define('HAVE_AUBIO_DOUBLE', 1)
596 if (ctx.options.enable_docs != False):
597 # check if txt2man is installed, optional
599 ctx.find_program('txt2man', var='TXT2MAN')
600 except ctx.errors.ConfigurationError:
601 ctx.to_log('txt2man was not found (ignoring)')
603 # check if doxygen is installed, optional
605 ctx.find_program('doxygen', var='DOXYGEN')
606 except ctx.errors.ConfigurationError:
607 ctx.to_log('doxygen was not found (ignoring)')
609 # check if sphinx-build is installed, optional
611 ctx.find_program('sphinx-build', var='SPHINX')
612 except ctx.errors.ConfigurationError:
613 ctx.to_log('sphinx-build was not found (ignoring)')
616 bld.env['VERSION'] = VERSION
617 bld.env['LIB_VERSION'] = LIB_VERSION
622 # add sub directories
623 if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'watchos', 'watchsimulator',
624 'tvos', 'tvsimulator', 'visionos', 'visionsimulator', 'android']:
625 if bld.env['DEST_OS']=='emscripten' and not bld.options.testcmd:
626 bld.options.testcmd = 'node %s'
627 if bld.options.enable_examples:
628 bld.recurse('examples')
629 if bld.options.enable_tests:
632 # pkg-config template
633 bld( source = 'aubio.pc.in' )
640 from waflib.Tools import waf_unit_test
641 bld.add_post_fun(waf_unit_test.summary)
642 bld.add_post_fun(waf_unit_test.set_exit_code)
645 # build manpages from txt files using txt2man
646 if bld.env['TXT2MAN']:
647 from waflib import TaskGen
648 if 'MANDIR' not in bld.env:
649 bld.env['MANDIR'] = bld.env['DATAROOTDIR'] + '/man'
650 bld.env.VERSION = VERSION
651 rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`'
652 rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}'
653 rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual'
654 rule_str += ' -s 1 ${SRC} > ${TGT}'
655 TaskGen.declare_chain(
661 install_path = '${MANDIR}/man1',
663 bld( source = bld.path.ant_glob('doc/*.txt') )
666 # build documentation from source files using doxygen
667 from waflib import Utils
668 if bld.env['DOXYGEN'] and not Utils.is_win32:
669 bld.env.VERSION = VERSION
670 rule = '( cat ${SRC[0]} && echo PROJECT_NUMBER=${VERSION}'
671 rule += ' && echo OUTPUT_DIRECTORY=%s && echo HTML_OUTPUT=%s )'
672 rule += ' | ${DOXYGEN} - > /dev/null'
673 rule %= (os.path.abspath(out), 'api')
674 bld( name = 'doxygen', rule = rule,
675 source = ['doc/web.cfg']
676 + bld.path.find_dir('src').ant_glob('**/*.h'),
677 target = bld.path.find_or_declare('api/index.html'),
678 cwd = bld.path.find_dir('doc'))
679 # evaluate nodes lazily to prevent build directory traversal warnings
680 bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/api',
681 bld.path.find_or_declare('api').ant_glob('**/*',
682 generator=True), cwd=bld.path.find_or_declare('api'),
686 # build documentation from source files using sphinx-build
691 from waflib import Logs
692 Logs.pprint('YELLOW', "Sphinx manual: install aubio first")
694 if bld.env['SPHINX'] and has_aubio:
695 bld.env.VERSION = VERSION
696 rule = '${SPHINX} -b html -D release=${VERSION}' \
697 ' -D version=${VERSION} -W -a -q' \
698 ' -d %s ' % os.path.join(os.path.abspath(out), 'doctrees')
699 rule += ' . %s' % os.path.join(os.path.abspath(out), 'manual')
700 bld( name = 'sphinx', rule = rule,
701 cwd = bld.path.find_dir('doc'),
702 source = bld.path.find_dir('doc').ant_glob('*.rst'),
703 target = bld.path.find_or_declare('manual/index.html'))
704 # evaluate nodes lazily to prevent build directory traversal warnings
705 bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/manual',
706 bld.path.find_or_declare('manual').ant_glob('**/*',
707 generator=True), cwd=bld.path.find_or_declare('manual'),
710 # register the previous rules as build rules
711 from waflib.Build import BuildContext
713 class build_txt2man(BuildContext):
717 class build_manpages(BuildContext):
721 class build_sphinx(BuildContext):
725 class build_doxygen(BuildContext):
730 from waflib import Logs
731 if bld.options.target_platform in ['ios', 'iosimulator']:
732 msg ='building for %s, contact the author for a commercial license' \
733 % bld.options.target_platform
734 Logs.pprint('RED', msg)
735 msg =' Paul Brossier <piem@aubio.org>'
736 Logs.pprint('RED', msg)
739 ctx.excl = ' **/.waf*'
740 ctx.excl += ' **/.git*'
741 ctx.excl += ' **/*~ **/*.pyc **/*.swp **/*.swo **/*.swn **/.lock-w*'
742 ctx.excl += ' **/build/*'
743 ctx.excl += ' doc/_build'
744 ctx.excl += ' python/demos_*'
745 ctx.excl += ' **/python/gen **/python/build **/python/dist'
746 ctx.excl += ' **/python/ext/config.h'
747 ctx.excl += ' **/python/lib/aubio/_aubio.so'
748 ctx.excl += ' **.egg-info'
749 ctx.excl += ' **/.eggs'
750 ctx.excl += ' **/.pytest_cache'
751 ctx.excl += ' **/.cache'
752 ctx.excl += ' **/**.zip **/**.tar.bz2'
753 ctx.excl += ' **.tar.bz2**'
754 ctx.excl += ' **/doc/full/* **/doc/web/*'
755 ctx.excl += ' **/doc/full.cfg'
756 ctx.excl += ' **/python/*.db'
757 ctx.excl += ' **/python.old/*'
758 ctx.excl += ' **/python/*/*.old'
759 ctx.excl += ' **/python/lib/aubio/*.so'
760 ctx.excl += ' **/python/tests/sounds'
761 ctx.excl += ' **/**.asc'
762 ctx.excl += ' **/dist*'
763 ctx.excl += ' **/.DS_Store'
764 ctx.excl += ' **/.travis.yml'
765 ctx.excl += ' **/.appveyor.yml'
766 ctx.excl += ' **/.circleci/*'
767 ctx.excl += ' **/azure-pipelines.yml'
768 ctx.excl += ' **/.coverage*'