source: wscript @ d41bc4d

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since d41bc4d 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
Line 
1#! /usr/bin/python
2#
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
11#  - doc: add doxygen
12#  - tests: move to new unit test system
13
14APPNAME = 'aubio'
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]])
24
25import os.path, sys
26if os.path.exists('src/config.h') or os.path.exists('Makefile'):
27    print "Please run 'make distclean' to clean-up autotools files before using waf"
28    sys.exit(1)
29
30top = '.'
31out = 'build'
32
33def options(ctx):
34  ctx.add_option('--enable-double', action='store_true', default=False,
35      help='compile aubio in double precision mode')
36  ctx.add_option('--enable-fftw', action='store_true', default=False,
37      help='compile with ooura instead of fftw')
38  ctx.add_option('--enable-fftw3f', action='store_true', default=False,
39      help='compile with fftw3 instead of fftw3f')
40  ctx.add_option('--enable-complex', action='store_true', default=False,
41      help='compile with C99 complex')
42  ctx.add_option('--enable-jack', action='store_true', default=False,
43      help='compile with jack support')
44  ctx.add_option('--enable-lash', action='store_true', default=False,
45      help='compile with lash support')
46  ctx.add_option('--enable-sndfile', action='store_true', default=False,
47      help='compile with libsndfile support')
48  ctx.add_option('--enable-samplerate', action='store_true', default=False,
49      help='compile with libsamplerate support')
50  ctx.add_option('--enable-swig', action='store_true', default=False,
51      help='compile with swig support (obsolete)')
52  ctx.add_option('--with-target-platform', type='string',
53      help='set target platform for cross-compilation', dest='target_platform')
54  ctx.load('compiler_c')
55  ctx.load('compiler_cxx')
56  ctx.load('gnu_dirs')
57  ctx.load('waf_unit_test')
58
59def configure(ctx):
60  import Options
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')
66
67  if Options.options.target_platform:
68    Options.platform = Options.options.target_platform
69
70  if Options.platform == 'win32':
71    ctx.env['shlib_PATTERN'] = 'lib%s.dll'
72
73  # check for required headers
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')
79
80  # optionally use complex.h
81  if (Options.options.enable_complex == True):
82    ctx.check(header_name='complex.h')
83
84  # check dependencies
85  if (Options.options.enable_sndfile == True):
86    ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
87      args = '--cflags --libs')
88  if (Options.options.enable_samplerate == True):
89      ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
90        args = '--cflags --libs')
91
92  # double precision mode
93  if (Options.options.enable_double == True):
94    ctx.define('HAVE_AUBIO_DOUBLE', 1)
95  else:
96    ctx.define('HAVE_AUBIO_DOUBLE', 0)
97
98  # check if pkg-config is installed, optional
99  try:
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')
104
105  # optional dependancies using pkg-config
106  if ctx.env['PKGCONFIG']:
107
108    if (Options.options.enable_fftw == True or Options.options.enable_fftw3f == True):
109      # one of fftwf or fftw3f
110      if (Options.options.enable_fftw3f == True):
111        ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
112            args = '--cflags --libs')
113        if (Options.options.enable_double == True):
114          ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!')
115      else:
116        # fftw3f not enabled, take most sensible one according to enable_double
117        if (Options.options.enable_double == True):
118          ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
119              args = '--cflags --libs')
120        else:
121          ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
122              args = '--cflags --libs')
123      ctx.define('HAVE_FFTW3', 1)
124    else:
125      # fftw disabled, use ooura
126      ctx.msg('Fftw disabled', 'using ooura')
127      pass
128
129    if (Options.options.enable_jack == True):
130      ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
131      args = '--cflags --libs')
132
133    if (Options.options.enable_lash == True):
134      ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
135      args = '--cflags --libs', uselib_store = 'LASH')
136
137  # swig
138  if (Options.options.enable_swig == True):
139    try:
140      ctx.find_program('swig', var='SWIG')
141    except ctx.errors.ConfigurationError:
142      ctx.to_log('swig was not found, not looking for (ignoring)')
143
144    if ctx.env['SWIG']:
145      ctx.check_tool('swig')
146      ctx.check_swig_version()
147
148      # python
149      if ctx.find_program('python'):
150        ctx.check_tool('python')
151        ctx.check_python_version((2,4,2))
152        ctx.check_python_headers()
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'''
159  if ctx.check_cc(fragment = check_c99_varargs,
160      type='cstlib',
161      msg = 'Checking for C99 __VA_ARGS__ macro'):
162    ctx.define('HAVE_C99_VARARGS_MACROS', 1)
163
164  # write configuration header
165  ctx.write_config_header('src/config.h')
166
167  # add some defines used in examples
168  ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
169  ctx.define('PACKAGE', APPNAME)
170
171  # check if docbook-to-man is installed, optional
172  try:
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)')
176
177def build(ctx):
178  ctx.env['VERSION'] = VERSION
179  ctx.env['LIB_VERSION'] = LIB_VERSION
180
181  # add sub directories
182  ctx.add_subdirs('src examples')
183  if ctx.env['SWIG']:
184    if ctx.env['PYTHON']:
185      ctx.add_subdirs('python')
186
187  # create the aubio.pc file for pkg-config
188  if ctx.env['TARGET_PLATFORM'] == 'linux':
189    aubiopc = ctx.new_task_gen('subst')
190    aubiopc.source = 'aubio.pc.in'
191    aubiopc.target = 'aubio.pc'
192    aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
193
194  # build manpages from sgml files
195  if ctx.env['DOCBOOKTOMAN']:
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    )
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'))
207
208  # install woodblock sound
209  ctx.install_files('${PREFIX}/share/sounds/aubio/',
210      'sounds/woodblock.aiff')
211
212  # build and run the unit tests
213  build_tests(ctx)
214
215def shutdown(ctx):
216  pass
217
218# loop over all *.c filenames in tests/src to build them all
219# target name is filename.c without the .c
220def build_tests(ctx):
221  for target_name in ctx.path.ant_glob('tests/src/**/*.c'):
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
230      if ctx.env['JACK']:
231        includes = ['examples']
232        uselib = ['JACK']
233        extra_source = ['examples/jackio.c']
234      else:
235        continue
236
237    this_target = ctx.new_task_gen(
238        features = 'c cprogram test',
239        uselib = uselib,
240        source = [target_name] + extra_source,
241        target = str(target_name).split('.')[0],
242        includes = ['src'] + includes,
243        defines = 'AUBIO_UNSTABLE_API=1',
244        use = 'aubio')
Note: See TracBrowser for help on using the repository browser.