source: wscript @ 1dfe409

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

Merge branch 'master' into feature/autosink

  • Property mode set to 100644
File size: 27.2 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    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, 'vorbis', default = None,
70            help_str = 'compile with libvorbis (auto)',
71            help_disable_str = 'disable libvorbis')
72    add_option_enable_disable(ctx, 'flac', default = None,
73            help_str = 'compile with libFLAC (auto)',
74            help_disable_str = 'disable libflac')
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)')
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)')
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')
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')
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')
96    add_option_enable_disable(ctx, 'atlas', default = False,
97            help_str = 'use ATLAS acceleration library (no)',
98            help_disable_str = 'do not use ATLAS library')
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')
105
106    add_option_enable_disable(ctx, 'docs', default = None,
107            help_str = 'build documentation (auto)',
108            help_disable_str = 'do not build 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    # check for vorbisenc
440    if (ctx.options.enable_vorbis != False):
441        ctx.check_cfg(package = 'vorbisenc vorbis ogg',
442                args = '--cflags --libs',
443                uselib_store = 'VORBISENC',
444                mandatory = ctx.options.enable_vorbis)
445
446    # check for flac
447    if (ctx.options.enable_flac != False):
448        ctx.check_cfg(package = 'flac',
449                args = '--cflags --libs',
450                uselib_store = 'FLAC',
451                mandatory = ctx.options.enable_flac)
452
453    if (ctx.options.enable_wavread != False):
454        ctx.define('HAVE_WAVREAD', 1)
455    ctx.msg('Checking if using source_wavread',
456            ctx.options.enable_wavread and 'yes' or 'no')
457    if (ctx.options.enable_wavwrite!= False):
458        ctx.define('HAVE_WAVWRITE', 1)
459    ctx.msg('Checking if using sink_wavwrite',
460            ctx.options.enable_wavwrite and 'yes' or 'no')
461
462    # use BLAS/ATLAS
463    if (ctx.options.enable_blas != False):
464        ctx.check_cfg(package = 'blas',
465                args = '--cflags --libs',
466                uselib_store='BLAS', mandatory = ctx.options.enable_blas)
467        if 'LIB_BLAS' in ctx.env:
468            blas_header = None
469            if ctx.env['LIBPATH_BLAS']:
470                if 'atlas' in ctx.env['LIBPATH_BLAS'][0]:
471                    blas_header = 'atlas/cblas.h'
472                elif 'openblas' in ctx.env['LIBPATH_BLAS'][0]:
473                    blas_header = 'openblas/cblas.h'
474            else:
475                blas_header = 'cblas.h'
476            ctx.check(header_name = blas_header, mandatory =
477                    ctx.options.enable_atlas)
478
479    # use memcpy hacks
480    if (ctx.options.enable_memcpy == True):
481        ctx.define('HAVE_MEMCPY_HACKS', 1)
482
483    # write configuration header
484    ctx.write_config_header('src/config.h')
485
486    # the following defines will be passed as arguments to the compiler
487    # instead of being written to src/config.h
488    ctx.define('HAVE_CONFIG_H', 1)
489
490    # add some defines used in examples
491    ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
492    ctx.define('PACKAGE', APPNAME)
493
494    # double precision mode
495    if (ctx.options.enable_double == True):
496        ctx.define('HAVE_AUBIO_DOUBLE', 1)
497
498    if (ctx.options.enable_docs != False):
499        # check if txt2man is installed, optional
500        try:
501          ctx.find_program('txt2man', var='TXT2MAN')
502        except ctx.errors.ConfigurationError:
503          ctx.to_log('txt2man was not found (ignoring)')
504
505        # check if doxygen is installed, optional
506        try:
507          ctx.find_program('doxygen', var='DOXYGEN')
508        except ctx.errors.ConfigurationError:
509          ctx.to_log('doxygen was not found (ignoring)')
510
511        # check if sphinx-build is installed, optional
512        try:
513          ctx.find_program('sphinx-build', var='SPHINX')
514        except ctx.errors.ConfigurationError:
515          ctx.to_log('sphinx-build was not found (ignoring)')
516
517def build(bld):
518    bld.env['VERSION'] = VERSION
519    bld.env['LIB_VERSION'] = LIB_VERSION
520
521    # main source
522    bld.recurse('src')
523
524    # add sub directories
525    if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
526        if bld.env['DEST_OS']=='emscripten' and not bld.options.testcmd:
527            bld.options.testcmd = 'node %s'
528        if bld.options.enable_examples:
529            bld.recurse('examples')
530        if bld.options.enable_tests:
531            bld.recurse('tests')
532
533    # pkg-config template
534    bld( source = 'aubio.pc.in' )
535
536    # documentation
537    txt2man(bld)
538    doxygen(bld)
539    sphinx(bld)
540
541    from waflib.Tools import waf_unit_test
542    bld.add_post_fun(waf_unit_test.summary)
543    bld.add_post_fun(waf_unit_test.set_exit_code)
544
545def txt2man(bld):
546    # build manpages from txt files using txt2man
547    if bld.env['TXT2MAN']:
548        from waflib import TaskGen
549        if 'MANDIR' not in bld.env:
550            bld.env['MANDIR'] = bld.env['DATAROOTDIR'] + '/man'
551        bld.env.VERSION = VERSION
552        rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`'
553        rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}'
554        rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual'
555        rule_str += ' -s 1 ${SRC} > ${TGT}'
556        TaskGen.declare_chain(
557                name      = 'txt2man',
558                rule      = rule_str,
559                ext_in    = '.txt',
560                ext_out   = '.1',
561                reentrant = False,
562                install_path =  '${MANDIR}/man1',
563                )
564        bld( source = bld.path.ant_glob('doc/*.txt') )
565
566def doxygen(bld):
567    # build documentation from source files using doxygen
568    if bld.env['DOXYGEN']:
569        bld.env.VERSION = VERSION
570        rule = '( cat ${SRC[0]} && echo PROJECT_NUMBER=${VERSION}'
571        rule += ' && echo OUTPUT_DIRECTORY=%s && echo HTML_OUTPUT=%s )'
572        rule += ' | doxygen - > /dev/null'
573        rule %= (os.path.abspath(out), 'api')
574        bld( name = 'doxygen', rule = rule,
575                source = ['doc/web.cfg']
576                    + bld.path.find_dir('src').ant_glob('**/*.h'),
577                target = bld.path.find_or_declare('api/index.html'),
578                cwd = bld.path.find_dir('doc'))
579        # evaluate nodes lazily to prevent build directory traversal warnings
580        bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/api',
581                bld.path.find_or_declare('api').ant_glob('**/*',
582                    generator=True), cwd=bld.path.find_or_declare('api'),
583                relative_trick=True)
584
585def sphinx(bld):
586    # build documentation from source files using sphinx-build
587    try:
588        import aubio
589        has_aubio = True
590    except ImportError:
591        from waflib import Logs
592        Logs.pprint('YELLOW', "Sphinx manual: install aubio first")
593        has_aubio = False
594    if bld.env['SPHINX'] and has_aubio:
595        bld.env.VERSION = VERSION
596        rule = '${SPHINX} -b html -D release=${VERSION}' \
597                ' -D version=${VERSION} -W -a -q' \
598                ' -d %s ' % os.path.join(os.path.abspath(out), 'doctrees')
599        rule += ' . %s' % os.path.join(os.path.abspath(out), 'manual')
600        bld( name = 'sphinx', rule = rule,
601                cwd = bld.path.find_dir('doc'),
602                source = bld.path.find_dir('doc').ant_glob('*.rst'),
603                target = bld.path.find_or_declare('manual/index.html'))
604        # evaluate nodes lazily to prevent build directory traversal warnings
605        bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/manual',
606                bld.path.find_or_declare('manual').ant_glob('**/*',
607                    generator=True), cwd=bld.path.find_or_declare('manual'),
608                relative_trick=True)
609
610# register the previous rules as build rules
611from waflib.Build import BuildContext
612
613class build_txt2man(BuildContext):
614    cmd = 'txt2man'
615    fun = 'txt2man'
616
617class build_manpages(BuildContext):
618    cmd = 'manpages'
619    fun = 'txt2man'
620
621class build_sphinx(BuildContext):
622    cmd = 'sphinx'
623    fun = 'sphinx'
624
625class build_doxygen(BuildContext):
626    cmd = 'doxygen'
627    fun = 'doxygen'
628
629def shutdown(bld):
630    from waflib import Logs
631    if bld.options.target_platform in ['ios', 'iosimulator']:
632        msg ='building for %s, contact the author for a commercial license' \
633                % bld.options.target_platform
634        Logs.pprint('RED', msg)
635        msg ='   Paul Brossier <piem@aubio.org>'
636        Logs.pprint('RED', msg)
637
638def dist(ctx):
639    ctx.excl  = ' **/.waf*'
640    ctx.excl += ' **/.git*'
641    ctx.excl += ' **/*~ **/*.pyc **/*.swp **/*.swo **/*.swn **/.lock-w*'
642    ctx.excl += ' **/build/*'
643    ctx.excl += ' doc/_build'
644    ctx.excl += ' python/demos_*'
645    ctx.excl += ' **/python/gen **/python/build **/python/dist'
646    ctx.excl += ' **/python/ext/config.h'
647    ctx.excl += ' **/python/lib/aubio/_aubio.so'
648    ctx.excl += ' **.egg-info'
649    ctx.excl += ' **/.eggs'
650    ctx.excl += ' **/.pytest_cache'
651    ctx.excl += ' **/.cache'
652    ctx.excl += ' **/**.zip **/**.tar.bz2'
653    ctx.excl += ' **.tar.bz2**'
654    ctx.excl += ' **/doc/full/* **/doc/web/*'
655    ctx.excl += ' **/doc/full.cfg'
656    ctx.excl += ' **/python/*.db'
657    ctx.excl += ' **/python.old/*'
658    ctx.excl += ' **/python/*/*.old'
659    ctx.excl += ' **/python/lib/aubio/*.so'
660    ctx.excl += ' **/python/tests/sounds'
661    ctx.excl += ' **/**.asc'
662    ctx.excl += ' **/dist*'
663    ctx.excl += ' **/.DS_Store'
664    ctx.excl += ' **/.travis.yml'
665    ctx.excl += ' **/.appveyor.yml'
666    ctx.excl += ' **/.circleci/*'
667    ctx.excl += ' **/azure-pipelines.yml'
668    ctx.excl += ' **/.coverage*'
Note: See TracBrowser for help on using the repository browser.