source: wscript @ 288c193

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 288c193 was 5bba662, checked in by Paul Brossier <piem@piem.org>, 8 years ago

wscript: add /MD and /D_CRT_SECURE_NO_WARNINGS on windows

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