source: wscript @ 34e505f

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampler
Last change on this file since 34e505f was 536bf70, checked in by Paul Brossier <piem@piem.org>, 9 years ago

wscript: fix variable name

  • Property mode set to 100644
File size: 14.4 KB
RevLine 
[5c411dc]1#! /usr/bin/python
[110ac90]2#
[21ee709]3# usage:
[46b00690]4#   $ python waf --help
5#
6# example:
7#   $ ./waf distclean configure build
[21ee709]8#
[46b00690]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/ .
[000b090]12
13APPNAME = 'aubio'
[5820107]14
[6b14351]15# source VERSION
[5820107]16for l in open('VERSION').readlines(): exec (l.strip())
17
[6b14351]18VERSION = '.'.join ([str(x) for x in [
19    AUBIO_MAJOR_VERSION,
20    AUBIO_MINOR_VERSION,
21    AUBIO_PATCH_VERSION
22    ]]) + AUBIO_VERSION_STATUS
[e565c649]23
[6b14351]24LIB_VERSION = '.'.join ([str(x) for x in [
25    LIBAUBIO_LT_CUR,
26    LIBAUBIO_LT_REV,
27    LIBAUBIO_LT_AGE]])
[e565c649]28
[46378b3]29top = '.'
30out = 'build'
[000b090]31
[6b14351]32def add_option_enable_disable(ctx, name, default = None,
33        help_str = None, help_disable_str = None):
[a93dab3]34    if help_str == None:
35        help_str = 'enable ' + name + ' support'
36    if help_disable_str == None:
37        help_disable_str = 'do not ' + help_str
38    ctx.add_option('--enable-' + name, action = 'store_true',
39            default = default,
40            dest = 'enable_' + name.replace('-','_'),
41            help = help_str)
42    ctx.add_option('--disable-' + name, action = 'store_false',
43            #default = default,
44            dest = 'enable_' + name.replace('-','_'),
45            help = help_disable_str )
[3819aca]46
[d41bc4d]47def options(ctx):
[a93dab3]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, 'complex', default = False,
55            help_str ='compile with C99 complex',
56            help_disable_str = 'do not use C99 complex (default)' )
57    add_option_enable_disable(ctx, 'jack', default = None,
58            help_str = 'compile with jack (auto)',
59            help_disable_str = 'disable jack support')
60    add_option_enable_disable(ctx, 'sndfile', default = None,
61            help_str = 'compile with sndfile (auto)',
62            help_disable_str = 'disable sndfile')
63    add_option_enable_disable(ctx, 'avcodec', default = None,
64            help_str = 'compile with libavcodec (auto)',
65            help_disable_str = 'disable libavcodec')
66    add_option_enable_disable(ctx, 'samplerate', default = None,
67            help_str = 'compile with samplerate (auto)',
68            help_disable_str = 'disable samplerate')
69    add_option_enable_disable(ctx, 'memcpy', default = True,
70            help_str = 'use memcpy hacks (default)',
71            help_disable_str = 'do not use memcpy hacks')
72    add_option_enable_disable(ctx, 'double', default = False,
73            help_str = 'compile in double precision mode',
74            help_disable_str = 'compile in single precision mode (default)')
[a3de4be]75    add_option_enable_disable(ctx, 'fat', default = False,
76            help_str = 'build fat binaries (darwin only)',
77            help_disable_str = 'do not build fat binaries (default)')
[0309a22]78    add_option_enable_disable(ctx, 'accelerate', default = None,
79            help_str = 'use Accelerate framework (darwin only) (auto)',
80            help_disable_str = 'do not use Accelerate framework')
[cc81763]81    add_option_enable_disable(ctx, 'apple-audio', default = None,
82            help_str = 'use CoreFoundation (darwin only) (auto)',
83            help_disable_str = 'do not use CoreFoundation framework')
[f0ce36a1]84    add_option_enable_disable(ctx, 'atlas', default = None,
85            help_str = 'use Atlas library (auto)',
86            help_disable_str = 'do not use Atlas library')
[a93dab3]87
88    ctx.add_option('--with-target-platform', type='string',
89            help='set target platform for cross-compilation', dest='target_platform')
90
91    ctx.load('compiler_c')
92    ctx.load('waf_unit_test')
93    ctx.load('gnu_dirs')
[000b090]94
[d41bc4d]95def configure(ctx):
[a93dab3]96    from waflib import Options
97    ctx.load('compiler_c')
98    ctx.load('waf_unit_test')
99    ctx.load('gnu_dirs')
[06dba46]100
[a93dab3]101    target_platform = Options.platform
102    if ctx.options.target_platform:
103        target_platform = ctx.options.target_platform
104    ctx.env['DEST_OS'] = target_platform
105
[a341685]106    if 'CL.exe' not in ctx.env.CC[0]:
107        ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
108    else:
109        ctx.env.CFLAGS += ['-Wall']
110
[06dba46]111    if target_platform not in ['win32', 'win64']:
112        ctx.env.CFLAGS += ['-fPIC']
113    else:
114        ctx.define('HAVE_WIN_HACKS', 1)
115        ctx.env['cshlib_PATTERN'] = 'lib%s.dll'
[a93dab3]116
[a3de4be]117    if target_platform == 'darwin' and ctx.options.enable_fat:
[a93dab3]118        ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
119        ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
[9209c79]120
121    if target_platform in [ 'darwin', 'ios', 'iosimulator']:
[cc81763]122        if (ctx.options.enable_apple_audio != False):
123            ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
124            ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1)
125            ctx.define('HAVE_SINK_APPLE_AUDIO', 1)
[0309a22]126        if (ctx.options.enable_accelerate != False):
127            ctx.define('HAVE_ACCELERATE', 1)
128            ctx.env.FRAMEWORK += ['Accelerate']
[a93dab3]129
130    if target_platform in [ 'ios', 'iosimulator' ]:
131        MINSDKVER="6.1"
132        ctx.env.CFLAGS += ['-std=c99']
[536bf70]133        if (ctx.options.enable_apple_audio != False):
[cc81763]134            ctx.define('HAVE_AUDIO_UNIT', 1)
135            #ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
[a93dab3]136        if target_platform == 'ios':
137            DEVROOT = "/Applications/Xcode.app/Contents"
138            DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer"
[e11ce489]139            SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS.sdk" % locals()
[7aa4aaa]140            ctx.env.CFLAGS += [ '-arch', 'arm64' ]
[a93dab3]141            ctx.env.CFLAGS += [ '-arch', 'armv7' ]
142            ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
[7aa4aaa]143            ctx.env.LINKFLAGS += [ '-arch', 'arm64' ]
[a93dab3]144            ctx.env.LINKFLAGS += ['-arch', 'armv7']
145            ctx.env.LINKFLAGS += ['-arch', 'armv7s']
146            ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
147            ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
148        else:
149            DEVROOT = "/Applications/Xcode.app/Contents"
150            DEVROOT += "/Developer/Platforms/iPhoneSimulator.platform/Developer"
[e11ce489]151            SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator.sdk" % locals()
[a93dab3]152            ctx.env.CFLAGS += [ '-arch', 'i386' ]
153            ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
154            ctx.env.LINKFLAGS += ['-arch', 'i386']
155            ctx.env.LINKFLAGS += ['-arch', 'x86_64']
156            ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
157            ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
158        ctx.env.CFLAGS += [ '-isysroot' , SDKROOT]
159        ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
160
161    # check for required headers
162    ctx.check(header_name='stdlib.h')
163    ctx.check(header_name='stdio.h')
164    ctx.check(header_name='math.h')
165    ctx.check(header_name='string.h')
166    ctx.check(header_name='limits.h')
167
168    # check support for C99 __VA_ARGS__ macros
169    check_c99_varargs = '''
[0318cc1]170#include <stdio.h>
171#define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
172'''
[a93dab3]173
174    if ctx.check_cc(fragment = check_c99_varargs,
175            type='cstlib',
[413d4bf]176            msg = 'Checking for C99 __VA_ARGS__ macro',
177            mandatory = False):
[a93dab3]178        ctx.define('HAVE_C99_VARARGS_MACROS', 1)
179
180    # double precision mode
181    if (ctx.options.enable_double == True):
182        ctx.define('HAVE_AUBIO_DOUBLE', 1)
183    else:
184        ctx.define('HAVE_AUBIO_DOUBLE', 0)
185
186    # optionally use complex.h
187    if (ctx.options.enable_complex == True):
188        ctx.check(header_name='complex.h')
189
190    # check for fftw3
191    if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False):
192        # one of fftwf or fftw3f
193        if (ctx.options.enable_fftw3f != False):
194            ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[795fcd9]195                    args = '--cflags --libs',
196                    mandatory = ctx.options.enable_fftw3f)
[a93dab3]197            if (ctx.options.enable_double == True):
[795fcd9]198                ctx.msg('Warning',
199                        'fftw3f enabled, but compiling in double precision!')
[a93dab3]200        else:
[795fcd9]201            # fftw3f disabled, take most sensible one according to
202            # enable_double
[a93dab3]203            if (ctx.options.enable_double == True):
204                ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
[795fcd9]205                        args = '--cflags --libs', mandatory =
206                        ctx.options.enable_fftw3)
[a93dab3]207            else:
208                ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[795fcd9]209                        args = '--cflags --libs',
210                        mandatory = ctx.options.enable_fftw3)
[a93dab3]211        ctx.define('HAVE_FFTW3', 1)
212
213    # fftw not enabled, use vDSP or ooura
214    if 'HAVE_FFTW3F' in ctx.env.define_key:
215        ctx.msg('Checking for FFT implementation', 'fftw3f')
216    elif 'HAVE_FFTW3' in ctx.env.define_key:
217        ctx.msg('Checking for FFT implementation', 'fftw3')
218    elif 'HAVE_ACCELERATE' in ctx.env.define_key:
219        ctx.msg('Checking for FFT implementation', 'vDSP')
[36f954a]220    else:
[a93dab3]221        ctx.msg('Checking for FFT implementation', 'ooura')
222
223    # check for libsndfile
224    if (ctx.options.enable_sndfile != False):
225        ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
[795fcd9]226                args = '--cflags --libs',
227                mandatory = ctx.options.enable_sndfile)
[a93dab3]228
229    # check for libsamplerate
230    if (ctx.options.enable_samplerate != False):
231        ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
[795fcd9]232                args = '--cflags --libs',
233                mandatory = ctx.options.enable_samplerate)
[a93dab3]234
235    # check for jack
236    if (ctx.options.enable_jack != False):
[eb99982]237        ctx.check_cfg(package = 'jack',
[795fcd9]238                args = '--cflags --libs',
239                mandatory = ctx.options.enable_jack)
[a93dab3]240
241    # check for libav
242    if (ctx.options.enable_avcodec != False):
243        ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0',
[795fcd9]244                args = '--cflags --libs', uselib_store = 'AVCODEC',
245                mandatory = ctx.options.enable_avcodec)
[a93dab3]246        ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0',
[795fcd9]247                args = '--cflags --libs', uselib_store = 'AVFORMAT',
248                mandatory = ctx.options.enable_avcodec)
[a93dab3]249        ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0',
[795fcd9]250                args = '--cflags --libs', uselib_store = 'AVUTIL',
251                mandatory = ctx.options.enable_avcodec)
[a93dab3]252        ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
[795fcd9]253                args = '--cflags --libs', uselib_store = 'AVRESAMPLE',
254                mandatory = ctx.options.enable_avcodec)
[eb68991]255        if all ( 'HAVE_' + i in ctx.env
[549928e]256                for i in ['AVCODEC', 'AVFORMAT', 'AVUTIL', 'AVRESAMPLE'] ):
257            ctx.define('HAVE_LIBAV', 1)
258            ctx.msg('Checking for all libav libraries', 'yes')
259        else:
260            ctx.msg('Checking for all libav libraries', 'not found', color = 'YELLOW')
[a93dab3]261
[5158c22]262    ctx.define('HAVE_WAVREAD', 1)
[52ca8a3]263    ctx.define('HAVE_WAVWRITE', 1)
[5158c22]264
[f0ce36a1]265    # use ATLAS
266    if (ctx.options.enable_atlas != False):
267        ctx.check(header_name = 'atlas/cblas.h', mandatory = ctx.options.enable_atlas)
268        #ctx.check(lib = 'lapack', uselib_store = 'LAPACK', mandatory = ctx.options.enable_atlas)
269        ctx.check(lib = 'cblas', uselib_store = 'BLAS', mandatory = ctx.options.enable_atlas)
270
[a93dab3]271    # use memcpy hacks
272    if (ctx.options.enable_memcpy == True):
273        ctx.define('HAVE_MEMCPY_HACKS', 1)
274    else:
275        ctx.define('HAVE_MEMCPY_HACKS', 0)
276
277    # write configuration header
278    ctx.write_config_header('src/config.h')
279
280    # add some defines used in examples
281    ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
282    ctx.define('PACKAGE', APPNAME)
283
284    # check if txt2man is installed, optional
285    try:
286      ctx.find_program('txt2man', var='TXT2MAN')
287    except ctx.errors.ConfigurationError:
288      ctx.to_log('txt2man was not found (ignoring)')
[000b090]289
[52a25e5]290    # check if doxygen is installed, optional
291    try:
292      ctx.find_program('doxygen', var='DOXYGEN')
293    except ctx.errors.ConfigurationError:
294      ctx.to_log('doxygen was not found (ignoring)')
295
[6ed0f4e]296def build(bld):
[985a5d1]297    bld.env['VERSION'] = VERSION
298    bld.env['LIB_VERSION'] = LIB_VERSION
299
300    # add sub directories
301    bld.recurse('src')
302    if bld.env['DEST_OS'] not in ['ios', 'iosimulator']:
303        pass
304    if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
305        bld.recurse('examples')
306        bld.recurse('tests')
307
308    bld( source = 'aubio.pc.in' )
309
[52a25e5]310    # build manpages from txt files using txt2man
[403e9dd]311    if bld.env['TXT2MAN']:
[985a5d1]312        from waflib import TaskGen
313        if 'MANDIR' not in bld.env:
314            bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man'
[403e9dd]315        rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`'
316        rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}'
317        rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual'
318        rule_str += ' -s 1 ${SRC} > ${TGT}'
[985a5d1]319        TaskGen.declare_chain(
[403e9dd]320                name      = 'txt2man',
321                rule      = rule_str,
322                ext_in    = '.txt',
[985a5d1]323                ext_out   = '.1',
324                reentrant = False,
325                install_path =  '${MANDIR}/man1',
326                )
[403e9dd]327        bld( source = bld.path.ant_glob('doc/*.txt') )
[985a5d1]328
[52a25e5]329    # build documentation from source files using doxygen
330    if bld.env['DOXYGEN']:
331        bld( name = 'doxygen', rule = 'doxygen ${SRC} > /dev/null',
332                source = 'doc/web.cfg',
[b0ab6ef]333                cwd = 'doc')
[52a25e5]334        bld.install_files( '${PREFIX}' + '/share/doc/libaubio-doc',
335                bld.path.ant_glob('doc/web/html/**'),
336                cwd = bld.path.find_dir ('doc/web'),
337                relative_trick = True)
[50d56cc]338
[30250de]339def shutdown(bld):
[985a5d1]340    from waflib import Logs
341    if bld.options.target_platform in ['ios', 'iosimulator']:
342        msg ='building for %s, contact the author for a commercial license' % bld.options.target_platform
343        Logs.pprint('RED', msg)
344        msg ='   Paul Brossier <piem@aubio.org>'
345        Logs.pprint('RED', msg)
[b4d1ba1]346
347def dist(ctx):
348    ctx.excl  = ' **/.waf-1* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git*'
349    ctx.excl += ' **/build/*'
[22dd9dc]350    ctx.excl += ' **/python/gen **/python/build **/python/dist'
351    ctx.excl += ' **/**.zip **/**.tar.bz2'
[a93dab3]352    ctx.excl += ' **/doc/full/* **/doc/web/*'
[b4d1ba1]353    ctx.excl += ' **/python/*.db'
354    ctx.excl += ' **/python.old/*'
[172b1fe]355    ctx.excl += ' **/python/tests/sounds'
[7b2d740]356    ctx.excl += ' **/**.asc'
Note: See TracBrowser for help on using the repository browser.