source: wscript @ c57ecd9

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

wscript: do not overwrite user flags

  • Property mode set to 100644
File size: 7.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('waf_unit_test')
[000b090]56
[d41bc4d]57def configure(ctx):
[6ed0f4e]58  from waflib import Options
59  ctx.load('compiler_c')
[d41bc4d]60  ctx.load('waf_unit_test')
[c57ecd9]61  ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
[000b090]62
[5c411dc]63  if Options.options.target_platform:
64    Options.platform = Options.options.target_platform
65
66  if Options.platform == 'win32':
[d41bc4d]67    ctx.env['shlib_PATTERN'] = 'lib%s.dll'
[5c411dc]68
[956e113]69  if Options.platform == 'darwin':
[d6001bf]70    ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
71    ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
72    ctx.env.CC = 'llvm-gcc-4.2'
73    ctx.env.LINK_CC = 'llvm-gcc-4.2'
[551c6c3]74    ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox']
[d6001bf]75
[000b090]76  # check for required headers
[d41bc4d]77  ctx.check(header_name='stdlib.h')
78  ctx.check(header_name='stdio.h')
79  ctx.check(header_name='math.h')
80  ctx.check(header_name='string.h')
81  ctx.check(header_name='limits.h')
[000b090]82
83  # optionally use complex.h
[62b8ab2]84  if (Options.options.enable_complex == True):
[d41bc4d]85    ctx.check(header_name='complex.h')
[000b090]86
[2e4fb04]87  # check dependencies
[110ac90]88  if (Options.options.enable_sndfile == True):
[d41bc4d]89    ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
[110ac90]90      args = '--cflags --libs')
[82335b7]91  if (Options.options.enable_samplerate == True):
[d41bc4d]92      ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
[2e4fb04]93        args = '--cflags --libs')
[000b090]94
[06d30f9]95  # double precision mode
96  if (Options.options.enable_double == True):
[d41bc4d]97    ctx.define('HAVE_AUBIO_DOUBLE', 1)
[06d30f9]98  else:
[d41bc4d]99    ctx.define('HAVE_AUBIO_DOUBLE', 0)
[06d30f9]100
[110ac90]101  # check if pkg-config is installed, optional
102  try:
[d41bc4d]103    ctx.find_program('pkg-config', var='PKGCONFIG')
104  except ctx.errors.ConfigurationError:
105    ctx.msg('Could not find pkg-config', 'disabling fftw, jack, and lash')
106    ctx.msg('Could not find fftw', 'using ooura')
[110ac90]107
[36f954a]108  # optional dependancies using pkg-config
[d41bc4d]109  if ctx.env['PKGCONFIG']:
[36f954a]110
[dda6ba6]111    if (Options.options.enable_fftw == True or Options.options.enable_fftw3f == True):
[36f954a]112      # one of fftwf or fftw3f
[dda6ba6]113      if (Options.options.enable_fftw3f == True):
[d41bc4d]114        ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[729a3c0]115            args = '--cflags --libs')
[dda6ba6]116        if (Options.options.enable_double == True):
[d41bc4d]117          ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!')
[729a3c0]118      else:
[dda6ba6]119        # fftw3f not enabled, take most sensible one according to enable_double
[36f954a]120        if (Options.options.enable_double == True):
[d41bc4d]121          ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
[36f954a]122              args = '--cflags --libs')
123        else:
[d41bc4d]124          ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
[36f954a]125              args = '--cflags --libs')
[d41bc4d]126      ctx.define('HAVE_FFTW3', 1)
[36f954a]127    else:
128      # fftw disabled, use ooura
[c325a11]129      ctx.msg('Checking for FFT implementation', 'ooura')
[36f954a]130      pass
131
132    if (Options.options.enable_jack == True):
[d41bc4d]133      ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
[36f954a]134      args = '--cflags --libs')
135
136    if (Options.options.enable_lash == True):
[d41bc4d]137      ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
[36f954a]138      args = '--cflags --libs', uselib_store = 'LASH')
[000b090]139
140  # swig
[dda6ba6]141  if (Options.options.enable_swig == True):
142    try:
[d41bc4d]143      ctx.find_program('swig', var='SWIG')
144    except ctx.errors.ConfigurationError:
145      ctx.to_log('swig was not found, not looking for (ignoring)')
[dda6ba6]146
[d41bc4d]147    if ctx.env['SWIG']:
148      ctx.check_tool('swig')
149      ctx.check_swig_version()
[dda6ba6]150
151      # python
[d41bc4d]152      if ctx.find_program('python'):
153        ctx.check_tool('python')
154        ctx.check_python_version((2,4,2))
155        ctx.check_python_headers()
[000b090]156
157  # check support for C99 __VA_ARGS__ macros
158  check_c99_varargs = '''
159#include <stdio.h>
160#define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
161'''
[d41bc4d]162  if ctx.check_cc(fragment = check_c99_varargs,
[46378b3]163      type='cstlib',
[000b090]164      msg = 'Checking for C99 __VA_ARGS__ macro'):
[d41bc4d]165    ctx.define('HAVE_C99_VARARGS_MACROS', 1)
[000b090]166
167  # write configuration header
[d41bc4d]168  ctx.write_config_header('src/config.h')
[000b090]169
[110ac90]170  # add some defines used in examples
[d41bc4d]171  ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
172  ctx.define('PACKAGE', APPNAME)
[000b090]173
174  # check if docbook-to-man is installed, optional
[110ac90]175  try:
[d41bc4d]176    ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
177  except ctx.errors.ConfigurationError:
178    ctx.to_log('docbook-to-man was not found (ignoring)')
[000b090]179
[6ed0f4e]180def build(bld):
181  bld.env['VERSION'] = VERSION
182  bld.env['LIB_VERSION'] = LIB_VERSION
[000b090]183
184  # add sub directories
[6ed0f4e]185  bld.recurse('src examples tests')
[000b090]186
[6ed0f4e]187  """
[000b090]188  # create the aubio.pc file for pkg-config
[d41bc4d]189  if ctx.env['TARGET_PLATFORM'] == 'linux':
190    aubiopc = ctx.new_task_gen('subst')
[110ac90]191    aubiopc.source = 'aubio.pc.in'
192    aubiopc.target = 'aubio.pc'
193    aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
[000b090]194
195  # build manpages from sgml files
[d41bc4d]196  if ctx.env['DOCBOOKTOMAN']:
[000b090]197    import TaskGen
198    TaskGen.declare_chain(
199        name    = 'docbooktoman',
200        rule    = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
201        ext_in  = '.sgml',
202        ext_out = '.1',
203        reentrant = 0,
204    )
[d41bc4d]205    manpages = ctx.new_task_gen(name = 'docbooktoman',
206        source=ctx.path.ant_glob('doc/*.sgml'))
207    ctx.install_files('${MANDIR}/man1', ctx.path.ant_glob('doc/*.1'))
[000b090]208
209  # install woodblock sound
[6ed0f4e]210  bld.install_files('${PREFIX}/share/sounds/aubio/',
[000b090]211      'sounds/woodblock.aiff')
[6ed0f4e]212  """
Note: See TracBrowser for help on using the repository browser.