source: wscript @ 8197dbd

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

Merge branch 'master' into feature/timestretch

  • Property mode set to 100644
File size: 27.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    add_option_enable_disable(ctx, 'fftw3f', default = False,
52            help_str = 'compile with fftw3f instead of ooura (recommended)',
53            help_disable_str = 'do not compile with fftw3f')
54    add_option_enable_disable(ctx, 'fftw3', default = False,
55            help_str = 'compile with fftw3 instead of ooura',
56            help_disable_str = 'do not compile with fftw3')
57    add_option_enable_disable(ctx, 'intelipp', default = False,
58            help_str = 'use Intel IPP libraries (auto)',
59            help_disable_str = 'do not use Intel IPP libraries')
60    add_option_enable_disable(ctx, 'complex', default = False,
61            help_str ='compile with C99 complex',
62            help_disable_str = 'do not use C99 complex (default)' )
63    add_option_enable_disable(ctx, 'jack', default = None,
64            help_str = 'compile with jack (auto)',
65            help_disable_str = 'disable jack support')
66    add_option_enable_disable(ctx, 'sndfile', default = None,
67            help_str = 'compile with sndfile (auto)',
68            help_disable_str = 'disable sndfile')
69    add_option_enable_disable(ctx, 'avcodec', default = None,
70            help_str = 'compile with libavcodec (auto)',
71            help_disable_str = 'disable libavcodec')
72    add_option_enable_disable(ctx, 'samplerate', default = None,
73            help_str = 'compile with samplerate (auto)',
74            help_disable_str = 'disable samplerate')
75    add_option_enable_disable(ctx, 'rubberband', default = None,
76            help_str = 'compile with rubberband (auto)',
77            help_disable_str = 'disable rubberband')
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 librubberband
391    if (ctx.options.enable_rubberband != False):
392        ctx.check_cfg(package = 'rubberband', atleast_version = '1.3',
393                args = '--cflags --libs',
394                mandatory = ctx.options.enable_rubberband)
395
396    # check for jack
397    if (ctx.options.enable_jack != False):
398        ctx.check_cfg(package = 'jack',
399                args = '--cflags --libs',
400                mandatory = ctx.options.enable_jack)
401
402    # check for libav
403    if (ctx.options.enable_avcodec != False):
404        ctx.check_cfg(package = 'libavcodec',
405                args = '--cflags --libs libavcodec >= 54.35.0',
406                uselib_store = 'AVCODEC',
407                mandatory = ctx.options.enable_avcodec)
408        ctx.check_cfg(package = 'libavformat',
409                args = '--cflags --libs libavformat >= 52.3.0',
410                uselib_store = 'AVFORMAT',
411                mandatory = ctx.options.enable_avcodec)
412        ctx.check_cfg(package = 'libavutil',
413                args = '--cflags --libs libavutil >= 52.3.0',
414                uselib_store = 'AVUTIL',
415                mandatory = ctx.options.enable_avcodec)
416        ctx.check_cfg(package = 'libswresample',
417                args = '--cflags --libs libswresample >= 1.2.0',
418                uselib_store = 'SWRESAMPLE',
419                mandatory = False)
420        if 'HAVE_SWRESAMPLE' not in ctx.env:
421            ctx.check_cfg(package = 'libavresample',
422                    args = '--cflags --libs libavresample >= 1.0.1',
423                    uselib_store = 'AVRESAMPLE',
424                    mandatory = False)
425
426        msg_check = 'Checking for all libav libraries'
427        if 'HAVE_AVCODEC' not in ctx.env:
428            ctx.msg(msg_check, 'not found (missing avcodec)', color = 'YELLOW')
429        elif 'HAVE_AVFORMAT' not in ctx.env:
430            ctx.msg(msg_check, 'not found (missing avformat)', color = 'YELLOW')
431        elif 'HAVE_AVUTIL' not in ctx.env:
432            ctx.msg(msg_check, 'not found (missing avutil)', color = 'YELLOW')
433        elif 'HAVE_SWRESAMPLE' not in ctx.env \
434                and 'HAVE_AVRESAMPLE' not in ctx.env:
435            resample_missing = 'not found (avresample or swresample required)'
436            ctx.msg(msg_check, resample_missing, color = 'YELLOW')
437        else:
438            ctx.msg(msg_check, 'yes')
439            if 'HAVE_SWRESAMPLE' in ctx.env:
440                ctx.define('HAVE_SWRESAMPLE', 1)
441            elif 'HAVE_AVRESAMPLE' in ctx.env:
442                ctx.define('HAVE_AVRESAMPLE', 1)
443            ctx.define('HAVE_LIBAV', 1)
444
445    if (ctx.options.enable_wavread != False):
446        ctx.define('HAVE_WAVREAD', 1)
447    ctx.msg('Checking if using source_wavread',
448            ctx.options.enable_wavread and 'yes' or 'no')
449    if (ctx.options.enable_wavwrite!= False):
450        ctx.define('HAVE_WAVWRITE', 1)
451    ctx.msg('Checking if using sink_wavwrite',
452            ctx.options.enable_wavwrite and 'yes' or 'no')
453
454    # use BLAS/ATLAS
455    if (ctx.options.enable_blas != False):
456        ctx.check_cfg(package = 'blas',
457                args = '--cflags --libs',
458                uselib_store='BLAS', mandatory = ctx.options.enable_blas)
459        if 'LIB_BLAS' in ctx.env:
460            blas_header = None
461            if ctx.env['LIBPATH_BLAS']:
462                if 'atlas' in ctx.env['LIBPATH_BLAS'][0]:
463                    blas_header = 'atlas/cblas.h'
464                elif 'openblas' in ctx.env['LIBPATH_BLAS'][0]:
465                    blas_header = 'openblas/cblas.h'
466            else:
467                blas_header = 'cblas.h'
468            ctx.check(header_name = blas_header, mandatory =
469                    ctx.options.enable_atlas)
470
471    # use memcpy hacks
472    if (ctx.options.enable_memcpy == True):
473        ctx.define('HAVE_MEMCPY_HACKS', 1)
474
475    # write configuration header
476    ctx.write_config_header('src/config.h')
477
478    # the following defines will be passed as arguments to the compiler
479    # instead of being written to src/config.h
480    ctx.define('HAVE_CONFIG_H', 1)
481
482    # add some defines used in examples
483    ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
484    ctx.define('PACKAGE', APPNAME)
485
486    # double precision mode
487    if (ctx.options.enable_double == True):
488        ctx.define('HAVE_AUBIO_DOUBLE', 1)
489
490    if (ctx.options.enable_docs != False):
491        # check if txt2man is installed, optional
492        try:
493          ctx.find_program('txt2man', var='TXT2MAN')
494        except ctx.errors.ConfigurationError:
495          ctx.to_log('txt2man was not found (ignoring)')
496
497        # check if doxygen is installed, optional
498        try:
499          ctx.find_program('doxygen', var='DOXYGEN')
500        except ctx.errors.ConfigurationError:
501          ctx.to_log('doxygen was not found (ignoring)')
502
503        # check if sphinx-build is installed, optional
504        try:
505          ctx.find_program('sphinx-build', var='SPHINX')
506        except ctx.errors.ConfigurationError:
507          ctx.to_log('sphinx-build was not found (ignoring)')
508
509def build(bld):
510    bld.env['VERSION'] = VERSION
511    bld.env['LIB_VERSION'] = LIB_VERSION
512
513    # main source
514    bld.recurse('src')
515
516    # add sub directories
517    if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
518        if bld.env['DEST_OS']=='emscripten' and not bld.options.testcmd:
519            bld.options.testcmd = 'node %s'
520        if bld.options.enable_examples:
521            bld.recurse('examples')
522        if bld.options.enable_tests:
523            bld.recurse('tests')
524
525    # pkg-config template
526    bld( source = 'aubio.pc.in' )
527
528    # documentation
529    txt2man(bld)
530    doxygen(bld)
531    sphinx(bld)
532
533    from waflib.Tools import waf_unit_test
534    bld.add_post_fun(waf_unit_test.summary)
535    bld.add_post_fun(waf_unit_test.set_exit_code)
536
537def txt2man(bld):
538    # build manpages from txt files using txt2man
539    if bld.env['TXT2MAN']:
540        from waflib import TaskGen
541        if 'MANDIR' not in bld.env:
542            bld.env['MANDIR'] = bld.env['DATAROOTDIR'] + '/man'
543        bld.env.VERSION = VERSION
544        rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`'
545        rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}'
546        rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual'
547        rule_str += ' -s 1 ${SRC} > ${TGT}'
548        TaskGen.declare_chain(
549                name      = 'txt2man',
550                rule      = rule_str,
551                ext_in    = '.txt',
552                ext_out   = '.1',
553                reentrant = False,
554                install_path =  '${MANDIR}/man1',
555                )
556        bld( source = bld.path.ant_glob('doc/*.txt') )
557
558def doxygen(bld):
559    # build documentation from source files using doxygen
560    if bld.env['DOXYGEN']:
561        bld.env.VERSION = VERSION
562        rule = '( cat ${SRC[0]} && echo PROJECT_NUMBER=${VERSION}'
563        rule += ' && echo OUTPUT_DIRECTORY=%s && echo HTML_OUTPUT=%s )'
564        rule += ' | doxygen - > /dev/null'
565        rule %= (os.path.abspath(out), 'api')
566        bld( name = 'doxygen', rule = rule,
567                source = ['doc/web.cfg']
568                    + bld.path.find_dir('src').ant_glob('**/*.h'),
569                target = bld.path.find_or_declare('api/index.html'),
570                cwd = bld.path.find_dir('doc'))
571        # evaluate nodes lazily to prevent build directory traversal warnings
572        bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/api',
573                bld.path.find_or_declare('api').ant_glob('**/*',
574                    generator=True), cwd=bld.path.find_or_declare('api'),
575                relative_trick=True)
576
577def sphinx(bld):
578    # build documentation from source files using sphinx-build
579    try:
580        import aubio
581        has_aubio = True
582    except ImportError:
583        from waflib import Logs
584        Logs.pprint('YELLOW', "Sphinx manual: install aubio first")
585        has_aubio = False
586    if bld.env['SPHINX'] and has_aubio:
587        bld.env.VERSION = VERSION
588        rule = '${SPHINX} -b html -D release=${VERSION}' \
589                ' -D version=${VERSION} -W -a -q' \
590                ' -d %s ' % os.path.join(os.path.abspath(out), 'doctrees')
591        rule += ' . %s' % os.path.join(os.path.abspath(out), 'manual')
592        bld( name = 'sphinx', rule = rule,
593                cwd = bld.path.find_dir('doc'),
594                source = bld.path.find_dir('doc').ant_glob('*.rst'),
595                target = bld.path.find_or_declare('manual/index.html'))
596        # evaluate nodes lazily to prevent build directory traversal warnings
597        bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/manual',
598                bld.path.find_or_declare('manual').ant_glob('**/*',
599                    generator=True), cwd=bld.path.find_or_declare('manual'),
600                relative_trick=True)
601
602# register the previous rules as build rules
603from waflib.Build import BuildContext
604
605class build_txt2man(BuildContext):
606    cmd = 'txt2man'
607    fun = 'txt2man'
608
609class build_manpages(BuildContext):
610    cmd = 'manpages'
611    fun = 'txt2man'
612
613class build_sphinx(BuildContext):
614    cmd = 'sphinx'
615    fun = 'sphinx'
616
617class build_doxygen(BuildContext):
618    cmd = 'doxygen'
619    fun = 'doxygen'
620
621def shutdown(bld):
622    from waflib import Logs
623    if bld.options.target_platform in ['ios', 'iosimulator']:
624        msg ='building for %s, contact the author for a commercial license' \
625                % bld.options.target_platform
626        Logs.pprint('RED', msg)
627        msg ='   Paul Brossier <piem@aubio.org>'
628        Logs.pprint('RED', msg)
629
630def dist(ctx):
631    ctx.excl  = ' **/.waf*'
632    ctx.excl += ' **/.git*'
633    ctx.excl += ' **/*~ **/*.pyc **/*.swp **/*.swo **/*.swn **/.lock-w*'
634    ctx.excl += ' **/build/*'
635    ctx.excl += ' doc/_build'
636    ctx.excl += ' python/demos_*'
637    ctx.excl += ' **/python/gen **/python/build **/python/dist'
638    ctx.excl += ' **/python/ext/config.h'
639    ctx.excl += ' **/python/lib/aubio/_aubio.so'
640    ctx.excl += ' **.egg-info'
641    ctx.excl += ' **/.eggs'
642    ctx.excl += ' **/.pytest_cache'
643    ctx.excl += ' **/.cache'
644    ctx.excl += ' **/**.zip **/**.tar.bz2'
645    ctx.excl += ' **.tar.bz2**'
646    ctx.excl += ' **/doc/full/* **/doc/web/*'
647    ctx.excl += ' **/doc/full.cfg'
648    ctx.excl += ' **/python/*.db'
649    ctx.excl += ' **/python.old/*'
650    ctx.excl += ' **/python/*/*.old'
651    ctx.excl += ' **/python/lib/aubio/*.so'
652    ctx.excl += ' **/python/tests/sounds'
653    ctx.excl += ' **/**.asc'
654    ctx.excl += ' **/dist*'
655    ctx.excl += ' **/.DS_Store'
656    ctx.excl += ' **/.travis.yml'
657    ctx.excl += ' **/.appveyor.yml'
658    ctx.excl += ' **/.circleci/*'
659    ctx.excl += ' **/azure-pipelines.yml'
660    ctx.excl += ' **/.coverage*'
Note: See TracBrowser for help on using the repository browser.