source: wscript @ d1decd5

feature/cnnfeature/crepefix/ffmpeg5
Last change on this file since d1decd5 was d1decd5, checked in by Paul Brossier <piem@piem.org>, 4 years ago

Merge branch 'master' into feature/timestretch

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