source: wscript @ c43c459

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

wscript: added -Wall -Wextra flags

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