source: wscript @ 4fe62ba

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

wscript: do not pass -Wextra to msvc

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