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