source: wscript @ 36ab428

feature/crepe_org
Last change on this file since 36ab428 was 36ab428, checked in by Paul Brossier <piem@piem.org>, 6 years ago

Merge branch 'master' into feature/crepe

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