source: wscript @ 4db0752

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

wscript, /wscript_build: use ctx to match latest waf docs

  • Property mode set to 100644
File size: 8.0 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('compiler_cxx')
56  ctx.load('gnu_dirs')
57  ctx.load('waf_unit_test')
[000b090]58
[d41bc4d]59def configure(ctx):
[000b090]60  import Options
[d41bc4d]61  ctx.check_tool('compiler_c')
62  ctx.check_tool('compiler_cxx')
63  ctx.check_tool('gnu_dirs') # helpful for autotools transition and .pc generation
64  #ctx.check_tool('misc') # needed for subst
65  ctx.load('waf_unit_test')
[000b090]66
[5c411dc]67  if Options.options.target_platform:
68    Options.platform = Options.options.target_platform
69
70  if Options.platform == 'win32':
[d41bc4d]71    ctx.env['shlib_PATTERN'] = 'lib%s.dll'
[5c411dc]72
[000b090]73  # check for required headers
[d41bc4d]74  ctx.check(header_name='stdlib.h')
75  ctx.check(header_name='stdio.h')
76  ctx.check(header_name='math.h')
77  ctx.check(header_name='string.h')
78  ctx.check(header_name='limits.h')
[000b090]79
80  # optionally use complex.h
[62b8ab2]81  if (Options.options.enable_complex == True):
[d41bc4d]82    ctx.check(header_name='complex.h')
[000b090]83
[2e4fb04]84  # check dependencies
[110ac90]85  if (Options.options.enable_sndfile == True):
[d41bc4d]86    ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
[110ac90]87      args = '--cflags --libs')
[82335b7]88  if (Options.options.enable_samplerate == True):
[d41bc4d]89      ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
[2e4fb04]90        args = '--cflags --libs')
[000b090]91
[06d30f9]92  # double precision mode
93  if (Options.options.enable_double == True):
[d41bc4d]94    ctx.define('HAVE_AUBIO_DOUBLE', 1)
[06d30f9]95  else:
[d41bc4d]96    ctx.define('HAVE_AUBIO_DOUBLE', 0)
[06d30f9]97
[110ac90]98  # check if pkg-config is installed, optional
99  try:
[d41bc4d]100    ctx.find_program('pkg-config', var='PKGCONFIG')
101  except ctx.errors.ConfigurationError:
102    ctx.msg('Could not find pkg-config', 'disabling fftw, jack, and lash')
103    ctx.msg('Could not find fftw', 'using ooura')
[110ac90]104
[36f954a]105  # optional dependancies using pkg-config
[d41bc4d]106  if ctx.env['PKGCONFIG']:
[36f954a]107
[dda6ba6]108    if (Options.options.enable_fftw == True or Options.options.enable_fftw3f == True):
[36f954a]109      # one of fftwf or fftw3f
[dda6ba6]110      if (Options.options.enable_fftw3f == True):
[d41bc4d]111        ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[729a3c0]112            args = '--cflags --libs')
[dda6ba6]113        if (Options.options.enable_double == True):
[d41bc4d]114          ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!')
[729a3c0]115      else:
[dda6ba6]116        # fftw3f not enabled, take most sensible one according to enable_double
[36f954a]117        if (Options.options.enable_double == True):
[d41bc4d]118          ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
[36f954a]119              args = '--cflags --libs')
120        else:
[d41bc4d]121          ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[36f954a]122              args = '--cflags --libs')
[d41bc4d]123      ctx.define('HAVE_FFTW3', 1)
[36f954a]124    else:
125      # fftw disabled, use ooura
[d41bc4d]126      ctx.msg('Fftw disabled', 'using ooura')
[36f954a]127      pass
128
129    if (Options.options.enable_jack == True):
[d41bc4d]130      ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
[36f954a]131      args = '--cflags --libs')
132
133    if (Options.options.enable_lash == True):
[d41bc4d]134      ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
[36f954a]135      args = '--cflags --libs', uselib_store = 'LASH')
[000b090]136
137  # swig
[dda6ba6]138  if (Options.options.enable_swig == True):
139    try:
[d41bc4d]140      ctx.find_program('swig', var='SWIG')
141    except ctx.errors.ConfigurationError:
142      ctx.to_log('swig was not found, not looking for (ignoring)')
[dda6ba6]143
[d41bc4d]144    if ctx.env['SWIG']:
145      ctx.check_tool('swig')
146      ctx.check_swig_version()
[dda6ba6]147
148      # python
[d41bc4d]149      if ctx.find_program('python'):
150        ctx.check_tool('python')
151        ctx.check_python_version((2,4,2))
152        ctx.check_python_headers()
[000b090]153
154  # check support for C99 __VA_ARGS__ macros
155  check_c99_varargs = '''
156#include <stdio.h>
157#define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
158'''
[d41bc4d]159  if ctx.check_cc(fragment = check_c99_varargs,
[46378b3]160      type='cstlib',
[000b090]161      msg = 'Checking for C99 __VA_ARGS__ macro'):
[d41bc4d]162    ctx.define('HAVE_C99_VARARGS_MACROS', 1)
[000b090]163
164  # write configuration header
[d41bc4d]165  ctx.write_config_header('src/config.h')
[000b090]166
[110ac90]167  # add some defines used in examples
[d41bc4d]168  ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
169  ctx.define('PACKAGE', APPNAME)
[000b090]170
171  # check if docbook-to-man is installed, optional
[110ac90]172  try:
[d41bc4d]173    ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
174  except ctx.errors.ConfigurationError:
175    ctx.to_log('docbook-to-man was not found (ignoring)')
[000b090]176
[d41bc4d]177def build(ctx):
178  ctx.env['VERSION'] = VERSION
179  ctx.env['LIB_VERSION'] = LIB_VERSION
[000b090]180
181  # add sub directories
[d41bc4d]182  ctx.add_subdirs('src examples')
183  if ctx.env['SWIG']:
184    if ctx.env['PYTHON']:
185      ctx.add_subdirs('python')
[000b090]186
187  # create the aubio.pc file for pkg-config
[d41bc4d]188  if ctx.env['TARGET_PLATFORM'] == 'linux':
189    aubiopc = ctx.new_task_gen('subst')
[110ac90]190    aubiopc.source = 'aubio.pc.in'
191    aubiopc.target = 'aubio.pc'
192    aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
[000b090]193
194  # build manpages from sgml files
[d41bc4d]195  if ctx.env['DOCBOOKTOMAN']:
[000b090]196    import TaskGen
197    TaskGen.declare_chain(
198        name    = 'docbooktoman',
199        rule    = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
200        ext_in  = '.sgml',
201        ext_out = '.1',
202        reentrant = 0,
203    )
[d41bc4d]204    manpages = ctx.new_task_gen(name = 'docbooktoman',
205        source=ctx.path.ant_glob('doc/*.sgml'))
206    ctx.install_files('${MANDIR}/man1', ctx.path.ant_glob('doc/*.1'))
[000b090]207
208  # install woodblock sound
[d41bc4d]209  ctx.install_files('${PREFIX}/share/sounds/aubio/',
[000b090]210      'sounds/woodblock.aiff')
211
[f11d78d]212  # build and run the unit tests
[d41bc4d]213  build_tests(ctx)
[f11d78d]214
[d41bc4d]215def shutdown(ctx):
[000b090]216  pass
217
[f11d78d]218# loop over all *.c filenames in tests/src to build them all
219# target name is filename.c without the .c
[d41bc4d]220def build_tests(ctx):
221  for target_name in ctx.path.ant_glob('tests/src/**/*.c'):
[110ac90]222    includes = ['src']
223    uselib = []
224    if not str(target_name).endswith('-jack.c'):
225      includes = []
226      uselib = []
227      extra_source = []
228    else:
229      # phasevoc-jack needs jack
[d41bc4d]230      if ctx.env['JACK']:
[110ac90]231        includes = ['examples']
232        uselib = ['JACK']
233        extra_source = ['examples/jackio.c']
234      else:
235        continue
236
[d41bc4d]237    this_target = ctx.new_task_gen(
[46378b3]238        features = 'c cprogram test',
[110ac90]239        uselib = uselib,
240        source = [target_name] + extra_source,
[46378b3]241        target = str(target_name).split('.')[0],
[110ac90]242        includes = ['src'] + includes,
[740f06b]243        defines = 'AUBIO_UNSTABLE_API=1',
[46378b3]244        use = 'aubio')
Note: See TracBrowser for help on using the repository browser.