source: wscript @ c34336e

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

wscript: doxygen has no target for now

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