source: wscript @ f50c9503

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

wscript: add stdarg.h

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