source: wscript @ 0969113

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

wscript: add option to not build with CoreAudio/AudioToolbox?

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