source: wscript @ 0015a54

feature/cnnfeature/crepefeature/pitchshiftfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretch
Last change on this file since 0015a54 was d9d1010, checked in by Paul Brossier <piem@piem.org>, 8 years ago

wscript: check if rubberband can be foud

  • Property mode set to 100644
File size: 17.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
17# source VERSION
18for l in open('VERSION').readlines(): exec (l.strip())
19
20VERSION = '.'.join ([str(x) for x in [
21    AUBIO_MAJOR_VERSION,
22    AUBIO_MINOR_VERSION,
23    AUBIO_PATCH_VERSION
24    ]]) + AUBIO_VERSION_STATUS
25
26LIB_VERSION = '.'.join ([str(x) for x in [
27    LIBAUBIO_LT_CUR,
28    LIBAUBIO_LT_REV,
29    LIBAUBIO_LT_AGE]])
30
31top = '.'
32out = 'build'
33
34def add_option_enable_disable(ctx, name, default = None,
35        help_str = None, help_disable_str = None):
36    if help_str == None:
37        help_str = 'enable ' + name + ' support'
38    if help_disable_str == None:
39        help_disable_str = 'do not ' + help_str
40    ctx.add_option('--enable-' + name, action = 'store_true',
41            default = default,
42            dest = 'enable_' + name.replace('-','_'),
43            help = help_str)
44    ctx.add_option('--disable-' + name, action = 'store_false',
45            #default = default,
46            dest = 'enable_' + name.replace('-','_'),
47            help = help_disable_str )
48
49def options(ctx):
50    add_option_enable_disable(ctx, 'fftw3f', default = False,
51            help_str = 'compile with fftw3f instead of ooura (recommended)',
52            help_disable_str = 'do not compile with fftw3f')
53    add_option_enable_disable(ctx, 'fftw3', default = False,
54            help_str = 'compile with fftw3 instead of ooura',
55            help_disable_str = 'do not compile with fftw3')
56    add_option_enable_disable(ctx, 'complex', default = False,
57            help_str ='compile with C99 complex',
58            help_disable_str = 'do not use C99 complex (default)' )
59    add_option_enable_disable(ctx, 'jack', default = None,
60            help_str = 'compile with jack (auto)',
61            help_disable_str = 'disable jack support')
62    add_option_enable_disable(ctx, 'sndfile', default = None,
63            help_str = 'compile with sndfile (auto)',
64            help_disable_str = 'disable sndfile')
65    add_option_enable_disable(ctx, 'avcodec', default = None,
66            help_str = 'compile with libavcodec (auto)',
67            help_disable_str = 'disable libavcodec')
68    add_option_enable_disable(ctx, 'samplerate', default = None,
69            help_str = 'compile with samplerate (auto)',
70            help_disable_str = 'disable samplerate')
71    add_option_enable_disable(ctx, 'rubberband', default = None,
72            help_str = 'compile with rubberband (auto)',
73            help_disable_str = 'disable rubberband')
74    add_option_enable_disable(ctx, 'memcpy', default = True,
75            help_str = 'use memcpy hacks (default)',
76            help_disable_str = 'do not use memcpy hacks')
77    add_option_enable_disable(ctx, 'double', default = False,
78            help_str = 'compile in double precision mode',
79            help_disable_str = 'compile in single precision mode (default)')
80    add_option_enable_disable(ctx, 'fat', default = False,
81            help_str = 'build fat binaries (darwin only)',
82            help_disable_str = 'do not build fat binaries (default)')
83    add_option_enable_disable(ctx, 'accelerate', default = None,
84            help_str = 'use Accelerate framework (darwin only) (auto)',
85            help_disable_str = 'do not use Accelerate framework')
86    add_option_enable_disable(ctx, 'apple-audio', default = None,
87            help_str = 'use CoreFoundation (darwin only) (auto)',
88            help_disable_str = 'do not use CoreFoundation framework')
89    add_option_enable_disable(ctx, 'atlas', default = None,
90            help_str = 'use Atlas library (auto)',
91            help_disable_str = 'do not use Atlas library')
92
93    add_option_enable_disable(ctx, 'docs', default = None,
94            help_str = 'build documentation (auto)',
95            help_disable_str = 'do not build documentation')
96
97    ctx.add_option('--with-target-platform', type='string',
98            help='set target platform for cross-compilation', dest='target_platform')
99
100    ctx.load('compiler_c')
101    ctx.load('waf_unit_test')
102    ctx.load('gnu_dirs')
103
104def configure(ctx):
105    from waflib import Options
106    ctx.load('compiler_c')
107    ctx.load('waf_unit_test')
108    ctx.load('gnu_dirs')
109
110    # check for common headers
111    ctx.check(header_name='stdlib.h')
112    ctx.check(header_name='stdio.h')
113    ctx.check(header_name='math.h')
114    ctx.check(header_name='string.h')
115    ctx.check(header_name='limits.h')
116    ctx.check(header_name='getopt.h', mandatory = False)
117    ctx.check(header_name='unistd.h', mandatory = False)
118
119    target_platform = sys.platform
120    if ctx.options.target_platform:
121        target_platform = ctx.options.target_platform
122    ctx.env['DEST_OS'] = target_platform
123
124    if ctx.env.CC_NAME != 'msvc':
125        ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
126    else:
127        ctx.env.CFLAGS += ['/W4', '/MD']
128        ctx.env.CFLAGS += ['/D_CRT_SECURE_NO_WARNINGS']
129
130    ctx.check_cc(lib='m', uselib_store='M', mandatory=False)
131
132    if target_platform not in ['win32', 'win64']:
133        ctx.env.CFLAGS += ['-fPIC']
134    else:
135        ctx.define('HAVE_WIN_HACKS', 1)
136        ctx.env['cshlib_PATTERN'] = 'lib%s.dll'
137
138    if target_platform == 'darwin' and ctx.options.enable_fat:
139        ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
140        ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
141        MINSDKVER="10.4"
142        ctx.env.CFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ]
143        ctx.env.LINKFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ]
144
145    if target_platform in [ 'darwin', 'ios', 'iosimulator']:
146        if (ctx.options.enable_apple_audio != False):
147            ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
148            ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1)
149            ctx.define('HAVE_SINK_APPLE_AUDIO', 1)
150        if (ctx.options.enable_accelerate != False):
151            ctx.define('HAVE_ACCELERATE', 1)
152            ctx.env.FRAMEWORK += ['Accelerate']
153
154    if target_platform in [ 'ios', 'iosimulator' ]:
155        MINSDKVER="6.1"
156        ctx.env.CFLAGS += ['-std=c99']
157        if (ctx.options.enable_apple_audio != False):
158            ctx.define('HAVE_AUDIO_UNIT', 1)
159            #ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
160        if target_platform == 'ios':
161            DEVROOT = "/Applications/Xcode.app/Contents"
162            DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer"
163            SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS.sdk" % locals()
164            ctx.env.CFLAGS += [ '-fembed-bitcode' ]
165            ctx.env.CFLAGS += [ '-arch', 'arm64' ]
166            ctx.env.CFLAGS += [ '-arch', 'armv7' ]
167            ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
168            ctx.env.LINKFLAGS += [ '-arch', 'arm64' ]
169            ctx.env.LINKFLAGS += ['-arch', 'armv7']
170            ctx.env.LINKFLAGS += ['-arch', 'armv7s']
171            ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
172            ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
173        else:
174            DEVROOT = "/Applications/Xcode.app/Contents"
175            DEVROOT += "/Developer/Platforms/iPhoneSimulator.platform/Developer"
176            SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator.sdk" % locals()
177            ctx.env.CFLAGS += [ '-arch', 'i386' ]
178            ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
179            ctx.env.LINKFLAGS += ['-arch', 'i386']
180            ctx.env.LINKFLAGS += ['-arch', 'x86_64']
181            ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
182            ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
183        ctx.env.CFLAGS += [ '-isysroot' , SDKROOT]
184        ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
185
186    if target_platform == 'emscripten':
187        import os.path
188        ctx.env.CFLAGS += [ '-I' + os.path.join(os.environ['EMSCRIPTEN'], 'system', 'include') ]
189        ctx.env.CFLAGS += ['-Oz']
190        ctx.env.cprogram_PATTERN = "%s.js"
191        if (ctx.options.enable_atlas != True):
192            ctx.options.enable_atlas = False
193
194    # check support for C99 __VA_ARGS__ macros
195    check_c99_varargs = '''
196#include <stdio.h>
197#define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
198'''
199
200    if ctx.check_cc(fragment = check_c99_varargs,
201            type='cstlib',
202            msg = 'Checking for C99 __VA_ARGS__ macro',
203            mandatory = False):
204        ctx.define('HAVE_C99_VARARGS_MACROS', 1)
205
206    # show a message about enable_double status
207    if (ctx.options.enable_double == True):
208        ctx.msg('Checking for size of smpl_t', 'double')
209        ctx.msg('Checking for size of lsmp_t', 'long double')
210    else:
211        ctx.msg('Checking for size of smpl_t', 'float')
212        ctx.msg('Checking for size of lsmp_t', 'double')
213
214    # optionally use complex.h
215    if (ctx.options.enable_complex == True):
216        ctx.check(header_name='complex.h')
217    else:
218        ctx.msg('Checking if complex.h is enabled', 'no')
219
220    # check for fftw3
221    if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False):
222        # one of fftwf or fftw3f
223        if (ctx.options.enable_fftw3f != False):
224            ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
225                    args = '--cflags --libs',
226                    mandatory = ctx.options.enable_fftw3f)
227            if (ctx.options.enable_double == True):
228                ctx.msg('Warning',
229                        'fftw3f enabled, but compiling in double precision!')
230        else:
231            # fftw3f disabled, take most sensible one according to
232            # enable_double
233            if (ctx.options.enable_double == True):
234                ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
235                        args = '--cflags --libs', mandatory =
236                        ctx.options.enable_fftw3)
237            else:
238                ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
239                        args = '--cflags --libs',
240                        mandatory = ctx.options.enable_fftw3)
241        ctx.define('HAVE_FFTW3', 1)
242
243    # fftw not enabled, use vDSP or ooura
244    if 'HAVE_FFTW3F' in ctx.env.define_key:
245        ctx.msg('Checking for FFT implementation', 'fftw3f')
246    elif 'HAVE_FFTW3' in ctx.env.define_key:
247        ctx.msg('Checking for FFT implementation', 'fftw3')
248    elif 'HAVE_ACCELERATE' in ctx.env.define_key:
249        ctx.msg('Checking for FFT implementation', 'vDSP')
250    else:
251        ctx.msg('Checking for FFT implementation', 'ooura')
252
253    # check for libsndfile
254    if (ctx.options.enable_sndfile != False):
255        ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
256                args = '--cflags --libs',
257                mandatory = ctx.options.enable_sndfile)
258
259    # check for libsamplerate
260    if (ctx.options.enable_samplerate != False):
261        ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
262                args = '--cflags --libs',
263                mandatory = ctx.options.enable_samplerate)
264
265    # check for librubberband
266    if (ctx.options.enable_rubberband != False):
267        ctx.check_cfg(package = 'rubberband', atleast_version = '1.8.1',
268                args = '--cflags --libs',
269                mandatory = ctx.options.enable_rubberband)
270
271    # check for jack
272    if (ctx.options.enable_jack != False):
273        ctx.check_cfg(package = 'jack',
274                args = '--cflags --libs',
275                mandatory = ctx.options.enable_jack)
276
277    # check for libav
278    if (ctx.options.enable_avcodec != False):
279        ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0',
280                args = '--cflags --libs', uselib_store = 'AVCODEC',
281                mandatory = ctx.options.enable_avcodec)
282        ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0',
283                args = '--cflags --libs', uselib_store = 'AVFORMAT',
284                mandatory = ctx.options.enable_avcodec)
285        ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0',
286                args = '--cflags --libs', uselib_store = 'AVUTIL',
287                mandatory = ctx.options.enable_avcodec)
288        ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
289                args = '--cflags --libs', uselib_store = 'AVRESAMPLE',
290                mandatory = ctx.options.enable_avcodec)
291        if all ( 'HAVE_' + i in ctx.env
292                for i in ['AVCODEC', 'AVFORMAT', 'AVUTIL', 'AVRESAMPLE'] ):
293            ctx.define('HAVE_LIBAV', 1)
294            ctx.msg('Checking for all libav libraries', 'yes')
295        else:
296            ctx.msg('Checking for all libav libraries', 'not found', color = 'YELLOW')
297
298    ctx.define('HAVE_WAVREAD', 1)
299    ctx.define('HAVE_WAVWRITE', 1)
300
301    # use ATLAS
302    if (ctx.options.enable_atlas != False):
303        ctx.check(header_name = 'atlas/cblas.h', mandatory = ctx.options.enable_atlas)
304        #ctx.check(lib = 'lapack', uselib_store = 'LAPACK', mandatory = ctx.options.enable_atlas)
305        ctx.check(lib = 'cblas', uselib_store = 'BLAS', mandatory = ctx.options.enable_atlas)
306
307    # use memcpy hacks
308    if (ctx.options.enable_memcpy == True):
309        ctx.define('HAVE_MEMCPY_HACKS', 1)
310
311    # write configuration header
312    ctx.write_config_header('src/config.h')
313
314    # the following defines will be passed as arguments to the compiler
315    # instead of being written to src/config.h
316
317    # add some defines used in examples
318    ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
319    ctx.define('PACKAGE', APPNAME)
320
321    # double precision mode
322    if (ctx.options.enable_double == True):
323        ctx.define('HAVE_AUBIO_DOUBLE', 1)
324
325    if (ctx.options.enable_docs != False):
326        # check if txt2man is installed, optional
327        try:
328          ctx.find_program('txt2man', var='TXT2MAN')
329        except ctx.errors.ConfigurationError:
330          ctx.to_log('txt2man was not found (ignoring)')
331
332        # check if doxygen is installed, optional
333        try:
334          ctx.find_program('doxygen', var='DOXYGEN')
335        except ctx.errors.ConfigurationError:
336          ctx.to_log('doxygen was not found (ignoring)')
337
338        # check if sphinx-build is installed, optional
339        try:
340          ctx.find_program('sphinx-build', var='SPHINX')
341        except ctx.errors.ConfigurationError:
342          ctx.to_log('sphinx-build was not found (ignoring)')
343
344def build(bld):
345    bld.env['VERSION'] = VERSION
346    bld.env['LIB_VERSION'] = LIB_VERSION
347
348    # add sub directories
349    bld.recurse('src')
350    if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
351        bld.recurse('examples')
352        bld.recurse('tests')
353
354    bld( source = 'aubio.pc.in' )
355
356    # build manpages from txt files using txt2man
357    if bld.env['TXT2MAN']:
358        from waflib import TaskGen
359        if 'MANDIR' not in bld.env:
360            bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man'
361        rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`'
362        rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}'
363        rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual'
364        rule_str += ' -s 1 ${SRC} > ${TGT}'
365        TaskGen.declare_chain(
366                name      = 'txt2man',
367                rule      = rule_str,
368                ext_in    = '.txt',
369                ext_out   = '.1',
370                reentrant = False,
371                install_path =  '${MANDIR}/man1',
372                )
373        bld( source = bld.path.ant_glob('doc/*.txt') )
374
375    # build documentation from source files using doxygen
376    if bld.env['DOXYGEN']:
377        bld( name = 'doxygen', rule = 'doxygen ${SRC} > /dev/null',
378                source = 'doc/web.cfg',
379                cwd = 'doc')
380        bld.install_files( '${PREFIX}' + '/share/doc/libaubio-doc',
381                bld.path.ant_glob('doc/web/html/**'),
382                cwd = bld.path.find_dir ('doc/web'),
383                relative_trick = True)
384
385    # build documentation from source files using sphinx-build
386    if bld.env['SPHINX']:
387        bld( name = 'sphinx', rule = 'make html',
388                source = ['doc/conf.py'] + bld.path.ant_glob('doc/**.rst'),
389                cwd = 'doc')
390        bld.install_files( '${PREFIX}' + '/share/doc/libaubio-doc/sphinx',
391                bld.path.ant_glob('doc/_build/html/**'),
392                cwd = bld.path.find_dir ('doc/_build/html'),
393                relative_trick = True)
394
395def shutdown(bld):
396    from waflib import Logs
397    if bld.options.target_platform in ['ios', 'iosimulator']:
398        msg ='building for %s, contact the author for a commercial license' % bld.options.target_platform
399        Logs.pprint('RED', msg)
400        msg ='   Paul Brossier <piem@aubio.org>'
401        Logs.pprint('RED', msg)
402
403def dist(ctx):
404    ctx.excl  = ' **/.waf-1* **/*~ **/*.pyc **/*.swp **/*.swo **/*.swn **/.lock-w* **/.git*'
405    ctx.excl += ' **/build/*'
406    ctx.excl += ' doc/_build'
407    ctx.excl += ' python/demos_*'
408    ctx.excl += ' **/python/gen **/python/build **/python/dist'
409    ctx.excl += ' **/python/ext/config.h'
410    ctx.excl += ' **/python/lib/aubio/_aubio.so'
411    ctx.excl += ' **.egg-info'
412    ctx.excl += ' **/**.zip **/**.tar.bz2'
413    ctx.excl += ' **/doc/full/* **/doc/web/*'
414    ctx.excl += ' **/python/*.db'
415    ctx.excl += ' **/python.old/*'
416    ctx.excl += ' **/python/*/*.old'
417    ctx.excl += ' **/python/tests/sounds'
418    ctx.excl += ' **/**.asc'
419    ctx.excl += ' **/dist*'
420    ctx.excl += ' **/.DS_Store'
421    ctx.excl += ' **/.travis.yml'
422    ctx.excl += ' **/.landscape.yml'
423    ctx.excl += ' **/.appveyor.yml'
Note: See TracBrowser for help on using the repository browser.