source: wscript @ 79ef3b3

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampler
Last change on this file since 79ef3b3 was 79ef3b3, checked in by Martin Hermant <martin.hermant@gmail.com>, 7 years ago

hide AUBIO_GIT_SHA in release
fix py3 syntax error

  • Property mode set to 100644
File size: 21.8 KB
RevLine 
[5c411dc]1#! /usr/bin/python
[110ac90]2#
[21ee709]3# usage:
[46b00690]4#   $ python waf --help
5#
6# example:
7#   $ ./waf distclean configure build
[21ee709]8#
[46b00690]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/ .
[000b090]12
[004b431]13import sys
14
[000b090]15APPNAME = 'aubio'
[5820107]16
[6b14351]17# source VERSION
[5820107]18for l in open('VERSION').readlines(): exec (l.strip())
19
[1eb8c0e]20def get_git_revision_hash( short=True):
21    import os
22    def which(program):
23        def is_exe(fpath):
24            return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
25
26        fpath, fname = os.path.split(program)
27        if fpath:
28            if is_exe(program):
29                return program
30        else:
31            for path in os.environ["PATH"].split(os.pathsep):
32                path = path.strip('"')
33                exe_file = os.path.join(path, program)
34                if is_exe(exe_file):
35                    return exe_file
36        return None
[79ef3b3]37
[1eb8c0e]38    if not which('git'):
[dd3b1d5]39        print('no git found on this system : can\'t get sha')
[1eb8c0e]40        return ""
41
42    import subprocess
43    aubio_dir = os.path.abspath(os.curdir)
44    if not os.path.exists(aubio_dir):
45        raise SystemError("git / root folder not found")
46    gitcmd = ['git','-C',aubio_dir ,'rev-parse']
47    if short:
48      gitcmd.append('--short')
49    gitcmd.append('HEAD')
[79ef3b3]50    return str(subprocess.check_output(gitcmd).strip())
51
[1eb8c0e]52
[79ef3b3]53# append sha to version in alpha release
54if AUBIO_VERSION_STATUS and '~alpha' in AUBIO_VERSION_STATUS :
55    AUBIO_GIT_SHA = get_git_revision_hash()
[1eb8c0e]56    if AUBIO_GIT_SHA:
57        AUBIO_VERSION_STATUS = '~git'+AUBIO_GIT_SHA
58
59
60
61
[6b14351]62VERSION = '.'.join ([str(x) for x in [
63    AUBIO_MAJOR_VERSION,
64    AUBIO_MINOR_VERSION,
65    AUBIO_PATCH_VERSION
66    ]]) + AUBIO_VERSION_STATUS
[e565c649]67
[6b14351]68LIB_VERSION = '.'.join ([str(x) for x in [
69    LIBAUBIO_LT_CUR,
70    LIBAUBIO_LT_REV,
71    LIBAUBIO_LT_AGE]])
[e565c649]72
[46378b3]73top = '.'
74out = 'build'
[000b090]75
[6b14351]76def add_option_enable_disable(ctx, name, default = None,
77        help_str = None, help_disable_str = None):
[a93dab3]78    if help_str == None:
79        help_str = 'enable ' + name + ' support'
80    if help_disable_str == None:
81        help_disable_str = 'do not ' + help_str
82    ctx.add_option('--enable-' + name, action = 'store_true',
83            default = default,
84            dest = 'enable_' + name.replace('-','_'),
85            help = help_str)
86    ctx.add_option('--disable-' + name, action = 'store_false',
87            #default = default,
88            dest = 'enable_' + name.replace('-','_'),
89            help = help_disable_str )
[3819aca]90
[d41bc4d]91def options(ctx):
[b4ce693]92    ctx.add_option('--build-type', action = 'store',
93            default = "release",
94            choices = ('debug', 'release'),
95            dest = 'build_type',
[fb6a0ff]96            help = 'whether to compile with (--build-type=release) or without (--build-type=debug) '\
[b4ce693]97              ' compiler opimizations [default: release]')
[a93dab3]98    add_option_enable_disable(ctx, 'fftw3f', default = False,
99            help_str = 'compile with fftw3f instead of ooura (recommended)',
100            help_disable_str = 'do not compile with fftw3f')
101    add_option_enable_disable(ctx, 'fftw3', default = False,
102            help_str = 'compile with fftw3 instead of ooura',
103            help_disable_str = 'do not compile with fftw3')
104    add_option_enable_disable(ctx, 'complex', default = False,
105            help_str ='compile with C99 complex',
106            help_disable_str = 'do not use C99 complex (default)' )
107    add_option_enable_disable(ctx, 'jack', default = None,
108            help_str = 'compile with jack (auto)',
109            help_disable_str = 'disable jack support')
110    add_option_enable_disable(ctx, 'sndfile', default = None,
111            help_str = 'compile with sndfile (auto)',
112            help_disable_str = 'disable sndfile')
113    add_option_enable_disable(ctx, 'avcodec', default = None,
114            help_str = 'compile with libavcodec (auto)',
115            help_disable_str = 'disable libavcodec')
116    add_option_enable_disable(ctx, 'samplerate', default = None,
117            help_str = 'compile with samplerate (auto)',
118            help_disable_str = 'disable samplerate')
119    add_option_enable_disable(ctx, 'memcpy', default = True,
120            help_str = 'use memcpy hacks (default)',
121            help_disable_str = 'do not use memcpy hacks')
122    add_option_enable_disable(ctx, 'double', default = False,
123            help_str = 'compile in double precision mode',
124            help_disable_str = 'compile in single precision mode (default)')
[a3de4be]125    add_option_enable_disable(ctx, 'fat', default = False,
126            help_str = 'build fat binaries (darwin only)',
127            help_disable_str = 'do not build fat binaries (default)')
[0309a22]128    add_option_enable_disable(ctx, 'accelerate', default = None,
129            help_str = 'use Accelerate framework (darwin only) (auto)',
130            help_disable_str = 'do not use Accelerate framework')
[cc81763]131    add_option_enable_disable(ctx, 'apple-audio', default = None,
132            help_str = 'use CoreFoundation (darwin only) (auto)',
133            help_disable_str = 'do not use CoreFoundation framework')
[f61ffb9]134    add_option_enable_disable(ctx, 'atlas', default = False,
135            help_str = 'use Atlas library (no)',
[f0ce36a1]136            help_disable_str = 'do not use Atlas library')
[f9a543e]137    add_option_enable_disable(ctx, 'wavread', default = True,
138            help_str = 'compile with source_wavread (default)',
139            help_disable_str = 'do not compile source_wavread')
140    add_option_enable_disable(ctx, 'wavwrite', default = True,
141            help_str = 'compile with source_wavwrite (default)',
142            help_disable_str = 'do not compile source_wavwrite')
[a93dab3]143
[a33d406]144    add_option_enable_disable(ctx, 'docs', default = None,
145            help_str = 'build documentation (auto)',
146            help_disable_str = 'do not build documentation')
147
[a93dab3]148    ctx.add_option('--with-target-platform', type='string',
149            help='set target platform for cross-compilation', dest='target_platform')
150
151    ctx.load('compiler_c')
152    ctx.load('waf_unit_test')
153    ctx.load('gnu_dirs')
[000b090]154
[d41bc4d]155def configure(ctx):
[a93dab3]156    from waflib import Options
157    ctx.load('compiler_c')
158    ctx.load('waf_unit_test')
159    ctx.load('gnu_dirs')
[06dba46]160
[bef979a]161    # check for common headers
162    ctx.check(header_name='stdlib.h')
163    ctx.check(header_name='stdio.h')
164    ctx.check(header_name='math.h')
165    ctx.check(header_name='string.h')
166    ctx.check(header_name='limits.h')
[f334300]167    ctx.check(header_name='stdarg.h')
[d746ef8]168    ctx.check(header_name='getopt.h', mandatory = False)
[06cf47d]169    ctx.check(header_name='unistd.h', mandatory = False)
[bef979a]170
[004b431]171    target_platform = sys.platform
[a93dab3]172    if ctx.options.target_platform:
173        target_platform = ctx.options.target_platform
174    ctx.env['DEST_OS'] = target_platform
175
[1eb8c0e]176    ctx.define('AUBIO_VERSION',VERSION)
177    ctx.define('AUBIO_MAJOR_VERSION',AUBIO_MAJOR_VERSION)
178    ctx.define('AUBIO_MINOR_VERSION',AUBIO_MINOR_VERSION)
179    ctx.define('AUBIO_PATCH_VERSION',AUBIO_PATCH_VERSION)
180    ctx.define('AUBIO_VERSION_STATUS',AUBIO_VERSION_STATUS)
[79ef3b3]181    # ctx.define('AUBIO_GIT_SHA',AUBIO_GIT_SHA)
[b4ce693]182    if ctx.options.build_type == "debug":
183        ctx.define('DEBUG', 1)
184    else:
185        ctx.define('NDEBUG', 1)
[578d3a2]186
[ae36035]187    if ctx.env.CC_NAME != 'msvc':
[c04346d]188        if ctx.options.build_type == "debug":
189            # no optimization in debug mode
[a6ba5d9f]190            ctx.env.prepend_value('CFLAGS', ['-O0'])
191        else:
192            # default to -O2 in release mode
193            ctx.env.prepend_value('CFLAGS', ['-O2'])
194        # enable debug symbols and configure warnings
195        ctx.env.prepend_value('CFLAGS', ['-g', '-Wall', '-Wextra'])
[a341685]196    else:
[b4ce693]197        # enable debug symbols
198        ctx.env.CFLAGS += ['/Z7', '/FS']
199        ctx.env.LINKFLAGS += ['/DEBUG', '/INCREMENTAL:NO']
200        # configure warnings
201        ctx.env.CFLAGS += ['/W4', '/D_CRT_SECURE_NO_WARNINGS']
[578d3a2]202        # set optimization level and runtime libs
[b4ce693]203        if (ctx.options.build_type == "release"):
204            ctx.env.CFLAGS += ['/Ox']
205            ctx.env.CFLAGS += ['/MD']
206        else:
207            assert(ctx.options.build_type == "debug")
208            ctx.env.CFLAGS += ['/MDd']
[578d3a2]209
[70a304e]210    ctx.check_cc(lib='m', uselib_store='M', mandatory=False)
211
[06dba46]212    if target_platform not in ['win32', 'win64']:
213        ctx.env.CFLAGS += ['-fPIC']
214    else:
215        ctx.define('HAVE_WIN_HACKS', 1)
216        ctx.env['cshlib_PATTERN'] = 'lib%s.dll'
[a93dab3]217
[a3de4be]218    if target_platform == 'darwin' and ctx.options.enable_fat:
[a93dab3]219        ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
220        ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
[da1709f]221        MINSDKVER="10.4"
222        ctx.env.CFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ]
223        ctx.env.LINKFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ]
[9209c79]224
225    if target_platform in [ 'darwin', 'ios', 'iosimulator']:
[cc81763]226        if (ctx.options.enable_apple_audio != False):
227            ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
228            ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1)
229            ctx.define('HAVE_SINK_APPLE_AUDIO', 1)
[f61ffb9]230            ctx.msg('Checking for AudioToolbox.framework', 'yes')
231        else:
232            ctx.msg('Checking for AudioToolbox.framework', 'no (disabled)', color = 'YELLOW')
[0309a22]233        if (ctx.options.enable_accelerate != False):
234            ctx.define('HAVE_ACCELERATE', 1)
235            ctx.env.FRAMEWORK += ['Accelerate']
[f61ffb9]236            ctx.msg('Checking for Accelerate framework', 'yes')
237        else:
[488381e]238            ctx.msg('Checking for Accelerate framework', 'no (disabled)', color = 'YELLOW')
[a93dab3]239
240    if target_platform in [ 'ios', 'iosimulator' ]:
241        MINSDKVER="6.1"
242        ctx.env.CFLAGS += ['-std=c99']
[536bf70]243        if (ctx.options.enable_apple_audio != False):
[cc81763]244            ctx.define('HAVE_AUDIO_UNIT', 1)
245            #ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
[a93dab3]246        if target_platform == 'ios':
247            DEVROOT = "/Applications/Xcode.app/Contents"
248            DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer"
[e11ce489]249            SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS.sdk" % locals()
[94b16497]250            ctx.env.CFLAGS += [ '-fembed-bitcode' ]
[7aa4aaa]251            ctx.env.CFLAGS += [ '-arch', 'arm64' ]
[a93dab3]252            ctx.env.CFLAGS += [ '-arch', 'armv7' ]
253            ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
[7aa4aaa]254            ctx.env.LINKFLAGS += [ '-arch', 'arm64' ]
[a93dab3]255            ctx.env.LINKFLAGS += ['-arch', 'armv7']
256            ctx.env.LINKFLAGS += ['-arch', 'armv7s']
257            ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
258            ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
259        else:
260            DEVROOT = "/Applications/Xcode.app/Contents"
261            DEVROOT += "/Developer/Platforms/iPhoneSimulator.platform/Developer"
[e11ce489]262            SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator.sdk" % locals()
[a93dab3]263            ctx.env.CFLAGS += [ '-arch', 'i386' ]
264            ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
265            ctx.env.LINKFLAGS += ['-arch', 'i386']
266            ctx.env.LINKFLAGS += ['-arch', 'x86_64']
267            ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
268            ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
269        ctx.env.CFLAGS += [ '-isysroot' , SDKROOT]
270        ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
271
[fb5838a]272    if target_platform == 'emscripten':
273        import os.path
274        ctx.env.CFLAGS += [ '-I' + os.path.join(os.environ['EMSCRIPTEN'], 'system', 'include') ]
275        ctx.env.CFLAGS += ['-Oz']
276        ctx.env.cprogram_PATTERN = "%s.js"
277        if (ctx.options.enable_atlas != True):
278            ctx.options.enable_atlas = False
279
[a93dab3]280    # check support for C99 __VA_ARGS__ macros
281    check_c99_varargs = '''
[0318cc1]282#include <stdio.h>
283#define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
284'''
[a93dab3]285
286    if ctx.check_cc(fragment = check_c99_varargs,
287            type='cstlib',
[413d4bf]288            msg = 'Checking for C99 __VA_ARGS__ macro',
289            mandatory = False):
[a93dab3]290        ctx.define('HAVE_C99_VARARGS_MACROS', 1)
291
[06c6d7d]292    # show a message about enable_double status
[a93dab3]293    if (ctx.options.enable_double == True):
[06c6d7d]294        ctx.msg('Checking for size of smpl_t', 'double')
295        ctx.msg('Checking for size of lsmp_t', 'long double')
[a93dab3]296    else:
[06c6d7d]297        ctx.msg('Checking for size of smpl_t', 'float')
298        ctx.msg('Checking for size of lsmp_t', 'double')
[a93dab3]299
300    # optionally use complex.h
301    if (ctx.options.enable_complex == True):
302        ctx.check(header_name='complex.h')
[06c6d7d]303    else:
304        ctx.msg('Checking if complex.h is enabled', 'no')
[a93dab3]305
306    # check for fftw3
307    if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False):
308        # one of fftwf or fftw3f
309        if (ctx.options.enable_fftw3f != False):
310            ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[795fcd9]311                    args = '--cflags --libs',
312                    mandatory = ctx.options.enable_fftw3f)
[a93dab3]313            if (ctx.options.enable_double == True):
[795fcd9]314                ctx.msg('Warning',
315                        'fftw3f enabled, but compiling in double precision!')
[a93dab3]316        else:
[795fcd9]317            # fftw3f disabled, take most sensible one according to
318            # enable_double
[a93dab3]319            if (ctx.options.enable_double == True):
320                ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
[795fcd9]321                        args = '--cflags --libs', mandatory =
322                        ctx.options.enable_fftw3)
[a93dab3]323            else:
324                ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[795fcd9]325                        args = '--cflags --libs',
326                        mandatory = ctx.options.enable_fftw3)
[a93dab3]327        ctx.define('HAVE_FFTW3', 1)
328
329    # fftw not enabled, use vDSP or ooura
330    if 'HAVE_FFTW3F' in ctx.env.define_key:
331        ctx.msg('Checking for FFT implementation', 'fftw3f')
332    elif 'HAVE_FFTW3' in ctx.env.define_key:
333        ctx.msg('Checking for FFT implementation', 'fftw3')
334    elif 'HAVE_ACCELERATE' in ctx.env.define_key:
335        ctx.msg('Checking for FFT implementation', 'vDSP')
[36f954a]336    else:
[a93dab3]337        ctx.msg('Checking for FFT implementation', 'ooura')
338
339    # check for libsndfile
340    if (ctx.options.enable_sndfile != False):
341        ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
[795fcd9]342                args = '--cflags --libs',
343                mandatory = ctx.options.enable_sndfile)
[a93dab3]344
345    # check for libsamplerate
[8be88e7]346    if (ctx.options.enable_double):
347        if (ctx.options.enable_samplerate):
348            ctx.fatal("Could not compile aubio in double precision mode with libsamplerate")
349        else:
350            ctx.options.enable_samplerate = False
351            ctx.msg('Checking if using samplerate', 'no (disabled in double precision mode)',
352                    color = 'YELLOW')
[a93dab3]353    if (ctx.options.enable_samplerate != False):
354        ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
[795fcd9]355                args = '--cflags --libs',
356                mandatory = ctx.options.enable_samplerate)
[a93dab3]357
358    # check for jack
359    if (ctx.options.enable_jack != False):
[eb99982]360        ctx.check_cfg(package = 'jack',
[795fcd9]361                args = '--cflags --libs',
362                mandatory = ctx.options.enable_jack)
[a93dab3]363
364    # check for libav
365    if (ctx.options.enable_avcodec != False):
366        ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0',
[795fcd9]367                args = '--cflags --libs', uselib_store = 'AVCODEC',
368                mandatory = ctx.options.enable_avcodec)
[a93dab3]369        ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0',
[795fcd9]370                args = '--cflags --libs', uselib_store = 'AVFORMAT',
371                mandatory = ctx.options.enable_avcodec)
[a93dab3]372        ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0',
[795fcd9]373                args = '--cflags --libs', uselib_store = 'AVUTIL',
374                mandatory = ctx.options.enable_avcodec)
[a93dab3]375        ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
[795fcd9]376                args = '--cflags --libs', uselib_store = 'AVRESAMPLE',
377                mandatory = ctx.options.enable_avcodec)
[eb68991]378        if all ( 'HAVE_' + i in ctx.env
[549928e]379                for i in ['AVCODEC', 'AVFORMAT', 'AVUTIL', 'AVRESAMPLE'] ):
380            ctx.define('HAVE_LIBAV', 1)
381            ctx.msg('Checking for all libav libraries', 'yes')
382        else:
383            ctx.msg('Checking for all libav libraries', 'not found', color = 'YELLOW')
[a93dab3]384
[f9a543e]385    if (ctx.options.enable_wavread != False):
386        ctx.define('HAVE_WAVREAD', 1)
387    ctx.msg('Checking if using source_wavread', ctx.options.enable_wavread and 'yes' or 'no')
388    if (ctx.options.enable_wavwrite!= False):
389        ctx.define('HAVE_WAVWRITE', 1)
390    ctx.msg('Checking if using sink_wavwrite', ctx.options.enable_wavwrite and 'yes' or 'no')
[5158c22]391
[f0ce36a1]392    # use ATLAS
393    if (ctx.options.enable_atlas != False):
394        ctx.check(header_name = 'atlas/cblas.h', mandatory = ctx.options.enable_atlas)
395        #ctx.check(lib = 'lapack', uselib_store = 'LAPACK', mandatory = ctx.options.enable_atlas)
396        ctx.check(lib = 'cblas', uselib_store = 'BLAS', mandatory = ctx.options.enable_atlas)
397
[a93dab3]398    # use memcpy hacks
399    if (ctx.options.enable_memcpy == True):
400        ctx.define('HAVE_MEMCPY_HACKS', 1)
401
402    # write configuration header
403    ctx.write_config_header('src/config.h')
404
[06c6d7d]405    # the following defines will be passed as arguments to the compiler
406    # instead of being written to src/config.h
[1910fed]407    ctx.define('HAVE_CONFIG_H', 1)
[06c6d7d]408
[a93dab3]409    # add some defines used in examples
410    ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
411    ctx.define('PACKAGE', APPNAME)
412
[06c6d7d]413    # double precision mode
414    if (ctx.options.enable_double == True):
415        ctx.define('HAVE_AUBIO_DOUBLE', 1)
416
[a33d406]417    if (ctx.options.enable_docs != False):
418        # check if txt2man is installed, optional
419        try:
420          ctx.find_program('txt2man', var='TXT2MAN')
421        except ctx.errors.ConfigurationError:
422          ctx.to_log('txt2man was not found (ignoring)')
[000b090]423
[a33d406]424        # check if doxygen is installed, optional
425        try:
426          ctx.find_program('doxygen', var='DOXYGEN')
427        except ctx.errors.ConfigurationError:
428          ctx.to_log('doxygen was not found (ignoring)')
[52a25e5]429
[7800335]430        # check if sphinx-build is installed, optional
431        try:
432          ctx.find_program('sphinx-build', var='SPHINX')
433        except ctx.errors.ConfigurationError:
434          ctx.to_log('sphinx-build was not found (ignoring)')
435
[6ed0f4e]436def build(bld):
[985a5d1]437    bld.env['VERSION'] = VERSION
438    bld.env['LIB_VERSION'] = LIB_VERSION
439
[7b38f3f]440    # main source
[985a5d1]441    bld.recurse('src')
[7b38f3f]442
443    # add sub directories
[985a5d1]444    if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
445        bld.recurse('examples')
446        bld.recurse('tests')
447
[7b38f3f]448    # pkg-config template
[985a5d1]449    bld( source = 'aubio.pc.in' )
450
[7b38f3f]451    # documentation
452    txt2man(bld)
453    doxygen(bld)
454    sphinx(bld)
455
456def txt2man(bld):
[52a25e5]457    # build manpages from txt files using txt2man
[403e9dd]458    if bld.env['TXT2MAN']:
[985a5d1]459        from waflib import TaskGen
460        if 'MANDIR' not in bld.env:
[641e533]461            bld.env['MANDIR'] = bld.env['DATAROOTDIR'] + '/man'
[e3b77e8]462        bld.env.VERSION = VERSION
[403e9dd]463        rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`'
464        rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}'
465        rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual'
466        rule_str += ' -s 1 ${SRC} > ${TGT}'
[985a5d1]467        TaskGen.declare_chain(
[403e9dd]468                name      = 'txt2man',
469                rule      = rule_str,
470                ext_in    = '.txt',
[985a5d1]471                ext_out   = '.1',
472                reentrant = False,
473                install_path =  '${MANDIR}/man1',
474                )
[403e9dd]475        bld( source = bld.path.ant_glob('doc/*.txt') )
[985a5d1]476
[7b38f3f]477def doxygen(bld):
[52a25e5]478    # build documentation from source files using doxygen
479    if bld.env['DOXYGEN']:
480        bld( name = 'doxygen', rule = 'doxygen ${SRC} > /dev/null',
481                source = 'doc/web.cfg',
[41dd34e]482                target = '../doc/web/html/index.html',
[7f35041]483                cwd = 'doc')
[641e533]484        bld.install_files( '${DATAROOTDIR}' + '/doc/libaubio-doc',
[52a25e5]485                bld.path.ant_glob('doc/web/html/**'),
486                cwd = bld.path.find_dir ('doc/web'),
487                relative_trick = True)
[7800335]488
[7b38f3f]489def sphinx(bld):
[7800335]490    # build documentation from source files using sphinx-build
[5a19f33]491    # note: build in ../doc/_build/html, otherwise waf wont install unsigned files
[7800335]492    if bld.env['SPHINX']:
[e3b77e8]493        bld.env.VERSION = VERSION
[5a19f33]494        bld( name = 'sphinx',
[e3b77e8]495                rule = '${SPHINX} -b html -D release=${VERSION} -D version=${VERSION} -a -q `dirname ${SRC}` `dirname ${TGT}`',
[7b38f3f]496                source = 'doc/conf.py',
[5a19f33]497                target = '../doc/_build/html/index.html')
[641e533]498        bld.install_files( '${DATAROOTDIR}' + '/doc/libaubio-doc/sphinx',
[7800335]499                bld.path.ant_glob('doc/_build/html/**'),
[5a19f33]500                cwd = bld.path.find_dir('doc/_build/html'),
[7800335]501                relative_trick = True)
[50d56cc]502
[7b38f3f]503# register the previous rules as build rules
504from waflib.Build import BuildContext
505
506class build_txt2man(BuildContext):
507    cmd = 'txt2man'
508    fun = 'txt2man'
509
510class build_manpages(BuildContext):
511    cmd = 'manpages'
512    fun = 'txt2man'
513
514class build_sphinx(BuildContext):
515    cmd = 'sphinx'
516    fun = 'sphinx'
517
518class build_doxygen(BuildContext):
519    cmd = 'doxygen'
520    fun = 'doxygen'
521
[30250de]522def shutdown(bld):
[985a5d1]523    from waflib import Logs
524    if bld.options.target_platform in ['ios', 'iosimulator']:
525        msg ='building for %s, contact the author for a commercial license' % bld.options.target_platform
526        Logs.pprint('RED', msg)
527        msg ='   Paul Brossier <piem@aubio.org>'
528        Logs.pprint('RED', msg)
[b4d1ba1]529
530def dist(ctx):
[3388e1a]531    ctx.excl  = ' **/.waf* **/*~ **/*.pyc **/*.swp **/*.swo **/*.swn **/.lock-w* **/.git*'
[b4d1ba1]532    ctx.excl += ' **/build/*'
[99d8cbb]533    ctx.excl += ' doc/_build'
534    ctx.excl += ' python/demos_*'
[22dd9dc]535    ctx.excl += ' **/python/gen **/python/build **/python/dist'
[981e7082]536    ctx.excl += ' **/python/ext/config.h'
[99d8cbb]537    ctx.excl += ' **/python/lib/aubio/_aubio.so'
538    ctx.excl += ' **.egg-info'
[22dd9dc]539    ctx.excl += ' **/**.zip **/**.tar.bz2'
[7b38f3f]540    ctx.excl += ' **.tar.bz2'
[a93dab3]541    ctx.excl += ' **/doc/full/* **/doc/web/*'
[e57a7d4]542    ctx.excl += ' **/doc/full.cfg'
[b4d1ba1]543    ctx.excl += ' **/python/*.db'
544    ctx.excl += ' **/python.old/*'
[981e7082]545    ctx.excl += ' **/python/*/*.old'
[172b1fe]546    ctx.excl += ' **/python/tests/sounds'
[7b2d740]547    ctx.excl += ' **/**.asc'
[5e544f1]548    ctx.excl += ' **/dist*'
[73aac2a]549    ctx.excl += ' **/.DS_Store'
550    ctx.excl += ' **/.travis.yml'
[5e544f1]551    ctx.excl += ' **/.landscape.yml'
552    ctx.excl += ' **/.appveyor.yml'
Note: See TracBrowser for help on using the repository browser.