source: wscript @ 614963a

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

Merge branch 'develop' into io

  • Property mode set to 100644
File size: 8.1 KB
RevLine 
[5c411dc]1#! /usr/bin/python
[110ac90]2#
[21ee709]3# waf build script, see http://code.google.com/p/waf/
4# usage:
5#     $ waf distclean configure build
6# get it:
7#     $ svn co http://waf.googlecode.com/svn/trunk /path/to/waf
8#     $ alias waf=/path/to/waf/waf-light
9#
10# TODO
[ee36175]11#  - doc: add doxygen
[110ac90]12#  - tests: move to new unit test system
[000b090]13
14APPNAME = 'aubio'
[5820107]15
16# read from VERSION
17for l in open('VERSION').readlines(): exec (l.strip())
18
19VERSION = '.'.join \
20        ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \
21        + AUBIO_VERSION_STATUS
22LIB_VERSION = '.'.join \
23        ([str(x) for x in [LIBAUBIO_LT_CUR, LIBAUBIO_LT_REV, LIBAUBIO_LT_AGE]])
[e565c649]24
25import os.path, sys
26if os.path.exists('src/config.h') or os.path.exists('Makefile'):
[7684ff2]27    print "Please run 'make distclean' to clean-up autotools files before using waf"
[e565c649]28    sys.exit(1)
29
[46378b3]30top = '.'
31out = 'build'
[000b090]32
[d41bc4d]33def options(ctx):
34  ctx.add_option('--enable-double', action='store_true', default=False,
[06d30f9]35      help='compile aubio in double precision mode')
[d41bc4d]36  ctx.add_option('--enable-fftw', action='store_true', default=False,
[729a3c0]37      help='compile with ooura instead of fftw')
[d41bc4d]38  ctx.add_option('--enable-fftw3f', action='store_true', default=False,
[000b090]39      help='compile with fftw3 instead of fftw3f')
[d41bc4d]40  ctx.add_option('--enable-complex', action='store_true', default=False,
[62b8ab2]41      help='compile with C99 complex')
[d41bc4d]42  ctx.add_option('--enable-jack', action='store_true', default=False,
[2a6e672]43      help='compile with jack support')
[d41bc4d]44  ctx.add_option('--enable-lash', action='store_true', default=False,
[2a6e672]45      help='compile with lash support')
[d41bc4d]46  ctx.add_option('--enable-sndfile', action='store_true', default=False,
[110ac90]47      help='compile with libsndfile support')
[d41bc4d]48  ctx.add_option('--enable-samplerate', action='store_true', default=False,
[2a6e672]49      help='compile with libsamplerate support')
[d41bc4d]50  ctx.add_option('--enable-swig', action='store_true', default=False,
[dda6ba6]51      help='compile with swig support (obsolete)')
[d41bc4d]52  ctx.add_option('--with-target-platform', type='string',
[5c411dc]53      help='set target platform for cross-compilation', dest='target_platform')
[d41bc4d]54  ctx.load('compiler_c')
55  ctx.load('gnu_dirs')
56  ctx.load('waf_unit_test')
[000b090]57
[d41bc4d]58def configure(ctx):
[000b090]59  import Options
[d41bc4d]60  ctx.check_tool('compiler_c')
61  ctx.check_tool('gnu_dirs') # helpful for autotools transition and .pc generation
62  ctx.load('waf_unit_test')
[fd70e5e]63  ctx.env.CFLAGS = ['-g', '-Wall', '-Wextra']
[000b090]64
[5c411dc]65  if Options.options.target_platform:
66    Options.platform = Options.options.target_platform
67
68  if Options.platform == 'win32':
[d41bc4d]69    ctx.env['shlib_PATTERN'] = 'lib%s.dll'
[5c411dc]70
[d6001bf]71  if Options.platform == 'macfat':
72    ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
73    ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
74    ctx.env.CC = 'llvm-gcc-4.2'
75    ctx.env.LINK_CC = 'llvm-gcc-4.2'
[551c6c3]76    ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox']
[d6001bf]77
[000b090]78  # check for required headers
[d41bc4d]79  ctx.check(header_name='stdlib.h')
80  ctx.check(header_name='stdio.h')
81  ctx.check(header_name='math.h')
82  ctx.check(header_name='string.h')
83  ctx.check(header_name='limits.h')
[000b090]84
85  # optionally use complex.h
[62b8ab2]86  if (Options.options.enable_complex == True):
[d41bc4d]87    ctx.check(header_name='complex.h')
[000b090]88
[2e4fb04]89  # check dependencies
[110ac90]90  if (Options.options.enable_sndfile == True):
[d41bc4d]91    ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
[110ac90]92      args = '--cflags --libs')
[82335b7]93  if (Options.options.enable_samplerate == True):
[d41bc4d]94      ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
[2e4fb04]95        args = '--cflags --libs')
[000b090]96
[06d30f9]97  # double precision mode
98  if (Options.options.enable_double == True):
[d41bc4d]99    ctx.define('HAVE_AUBIO_DOUBLE', 1)
[06d30f9]100  else:
[d41bc4d]101    ctx.define('HAVE_AUBIO_DOUBLE', 0)
[06d30f9]102
[110ac90]103  # check if pkg-config is installed, optional
104  try:
[d41bc4d]105    ctx.find_program('pkg-config', var='PKGCONFIG')
106  except ctx.errors.ConfigurationError:
107    ctx.msg('Could not find pkg-config', 'disabling fftw, jack, and lash')
108    ctx.msg('Could not find fftw', 'using ooura')
[110ac90]109
[36f954a]110  # optional dependancies using pkg-config
[d41bc4d]111  if ctx.env['PKGCONFIG']:
[36f954a]112
[dda6ba6]113    if (Options.options.enable_fftw == True or Options.options.enable_fftw3f == True):
[36f954a]114      # one of fftwf or fftw3f
[dda6ba6]115      if (Options.options.enable_fftw3f == True):
[d41bc4d]116        ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[729a3c0]117            args = '--cflags --libs')
[dda6ba6]118        if (Options.options.enable_double == True):
[d41bc4d]119          ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!')
[729a3c0]120      else:
[dda6ba6]121        # fftw3f not enabled, take most sensible one according to enable_double
[36f954a]122        if (Options.options.enable_double == True):
[d41bc4d]123          ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
[36f954a]124              args = '--cflags --libs')
125        else:
[d41bc4d]126          ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[36f954a]127              args = '--cflags --libs')
[d41bc4d]128      ctx.define('HAVE_FFTW3', 1)
[36f954a]129    else:
130      # fftw disabled, use ooura
[c325a11]131      ctx.msg('Checking for FFT implementation', 'ooura')
[36f954a]132      pass
133
134    if (Options.options.enable_jack == True):
[d41bc4d]135      ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
[36f954a]136      args = '--cflags --libs')
137
138    if (Options.options.enable_lash == True):
[d41bc4d]139      ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
[36f954a]140      args = '--cflags --libs', uselib_store = 'LASH')
[000b090]141
142  # swig
[dda6ba6]143  if (Options.options.enable_swig == True):
144    try:
[d41bc4d]145      ctx.find_program('swig', var='SWIG')
146    except ctx.errors.ConfigurationError:
147      ctx.to_log('swig was not found, not looking for (ignoring)')
[dda6ba6]148
[d41bc4d]149    if ctx.env['SWIG']:
150      ctx.check_tool('swig')
151      ctx.check_swig_version()
[dda6ba6]152
153      # python
[d41bc4d]154      if ctx.find_program('python'):
155        ctx.check_tool('python')
156        ctx.check_python_version((2,4,2))
157        ctx.check_python_headers()
[000b090]158
159  # check support for C99 __VA_ARGS__ macros
160  check_c99_varargs = '''
161#include <stdio.h>
162#define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
163'''
[d41bc4d]164  if ctx.check_cc(fragment = check_c99_varargs,
[46378b3]165      type='cstlib',
[000b090]166      msg = 'Checking for C99 __VA_ARGS__ macro'):
[d41bc4d]167    ctx.define('HAVE_C99_VARARGS_MACROS', 1)
[000b090]168
169  # write configuration header
[d41bc4d]170  ctx.write_config_header('src/config.h')
[000b090]171
[110ac90]172  # add some defines used in examples
[d41bc4d]173  ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
174  ctx.define('PACKAGE', APPNAME)
[000b090]175
176  # check if docbook-to-man is installed, optional
[110ac90]177  try:
[d41bc4d]178    ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
179  except ctx.errors.ConfigurationError:
180    ctx.to_log('docbook-to-man was not found (ignoring)')
[000b090]181
[d41bc4d]182def build(ctx):
183  ctx.env['VERSION'] = VERSION
184  ctx.env['LIB_VERSION'] = LIB_VERSION
[000b090]185
186  # add sub directories
[c325a11]187  ctx.add_subdirs(['src','examples'])
[d41bc4d]188  if ctx.env['SWIG']:
189    if ctx.env['PYTHON']:
190      ctx.add_subdirs('python')
[000b090]191
192  # create the aubio.pc file for pkg-config
[d41bc4d]193  if ctx.env['TARGET_PLATFORM'] == 'linux':
194    aubiopc = ctx.new_task_gen('subst')
[110ac90]195    aubiopc.source = 'aubio.pc.in'
196    aubiopc.target = 'aubio.pc'
197    aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
[000b090]198
199  # build manpages from sgml files
[d41bc4d]200  if ctx.env['DOCBOOKTOMAN']:
[000b090]201    import TaskGen
202    TaskGen.declare_chain(
203        name    = 'docbooktoman',
204        rule    = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
205        ext_in  = '.sgml',
206        ext_out = '.1',
207        reentrant = 0,
208    )
[d41bc4d]209    manpages = ctx.new_task_gen(name = 'docbooktoman',
210        source=ctx.path.ant_glob('doc/*.sgml'))
211    ctx.install_files('${MANDIR}/man1', ctx.path.ant_glob('doc/*.1'))
[000b090]212
213  # install woodblock sound
[d41bc4d]214  ctx.install_files('${PREFIX}/share/sounds/aubio/',
[000b090]215      'sounds/woodblock.aiff')
216
[f11d78d]217  # build and run the unit tests
[d41bc4d]218  build_tests(ctx)
[f11d78d]219
[d41bc4d]220def shutdown(ctx):
[000b090]221  pass
222
[f11d78d]223# loop over all *.c filenames in tests/src to build them all
224# target name is filename.c without the .c
[d41bc4d]225def build_tests(ctx):
226  for target_name in ctx.path.ant_glob('tests/src/**/*.c'):
[110ac90]227    uselib = []
[c325a11]228    includes = ['src']
229    extra_source = []
230    if str(target_name).endswith('-jack.c') and ctx.env['JACK']:
231      uselib += ['JACK']
232      includes += ['examples']
233      extra_source += ['examples/jackio.c']
[110ac90]234
[d41bc4d]235    this_target = ctx.new_task_gen(
[46378b3]236        features = 'c cprogram test',
[110ac90]237        uselib = uselib,
238        source = [target_name] + extra_source,
[46378b3]239        target = str(target_name).split('.')[0],
[c325a11]240        includes = includes,
[740f06b]241        defines = 'AUBIO_UNSTABLE_API=1',
[c325a11]242        cflags = ['-g'],
[46378b3]243        use = 'aubio')
Note: See TracBrowser for help on using the repository browser.