source: wscript @ 9590e81

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

wscript: add --disable-docs option

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