source: wscript @ 7436353

feature/autosinkfeature/cnnfeature/crepefix/ffmpeg5
Last change on this file since 7436353 was 1ba359c, checked in by Paul Brossier <piem@piem.org>, 6 years ago

[waf] add flac detection

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