source: wscript @ 860ef4b

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

wscript: added some pointers about waf

  • Property mode set to 100644
File size: 6.8 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'
15VERSION = '0.3.3'
16LIB_VERSION = '2.1.1'
17srcdir = '.'
18blddir = 'build'
19
20def init(opt):
21  pass
22
23def set_options(opt):
24  opt.add_option('--enable-double', action='store_true', default=False,
25      help='compile aubio in double precision mode')
26  opt.add_option('--disable-fftw3f', action='store_true', default=False,
27      help='compile with fftw3 instead of fftw3f')
28  opt.add_option('--enable-complex', action='store_true', default=False,
29      help='compile with C99 complex')
30  opt.add_option('--disable-jack', action='store_true', default=False,
31      help='compile without jack support')
32  opt.add_option('--disable-lash', action='store_true', default=False,
33      help='compile without lash support')
34  opt.add_option('--disable-libsamplerate', action='store_true', default=False,
35      help='compile without libsamplerate support')
36  opt.add_option('--with-target-platform', type='string',
37      help='set target platform for cross-compilation', dest='target_platform')
38  opt.tool_options('compiler_cc')
39  opt.tool_options('compiler_cxx')
40  opt.tool_options('gnu_dirs')
41  opt.tool_options('UnitTest')
42
43def configure(conf):
44  import Options
45  conf.check_tool('compiler_cc')
46  conf.check_tool('compiler_cxx')
47  conf.check_tool('gnu_dirs') # helpful for autotools transition and .pc generation
48  conf.check_tool('misc') # needed for subst
49
50  if Options.options.target_platform:
51    Options.platform = Options.options.target_platform
52
53  if Options.platform == 'win32':
54    conf.env['shlib_PATTERN'] = 'lib%s.dll'
55
56  # check for required headers
57  conf.check(header_name='stdlib.h')
58  conf.check(header_name='stdio.h')
59  conf.check(header_name='math.h')
60  conf.check(header_name='string.h')
61  conf.check(header_name='limits.h')
62
63  # optionally use complex.h
64  if (Options.options.enable_complex == True):
65    conf.check(header_name='complex.h')
66
67  # check dependencies
68  conf.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
69    args = '--cflags --libs')
70  if (Options.options.disable_libsamplerate == False):
71      conf.check_cfg(package = 'libsamplerate', atleast_version = '0.0.15',
72        args = '--cflags --libs')
73
74  # double precision mode
75  if (Options.options.enable_double == True):
76    conf.define('HAVE_AUBIO_DOUBLE', 1)
77  else:
78    conf.define('HAVE_AUBIO_DOUBLE', 0)
79
80  # one of fftwf or fftw3f
81  if (Options.options.disable_fftw3f == True):
82    conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
83        args = '--cflags --libs')
84  else:
85    # fftw3f not disabled, take most sensible one according to enable_double
86    if (Options.options.enable_double == True):
87      conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
88          args = '--cflags --libs')
89    else:
90      conf.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
91          args = '--cflags --libs')
92
93  # optional dependancies
94  if (Options.options.disable_jack == False):
95    conf.check_cfg(package = 'jack', atleast_version = '0.15.0',
96    args = '--cflags --libs')
97  if (Options.options.disable_lash == False):
98    conf.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
99    args = '--cflags --libs', uselib_store = 'LASH')
100
101  # swig
102  if conf.find_program('swig', var='SWIG', mandatory = False):
103    conf.check_tool('swig', tooldir='swig')
104    conf.check_swig_version('1.3.27')
105
106    # python
107    if conf.find_program('python', mandatory = False):
108      conf.check_tool('python')
109      conf.check_python_version((2,4,2))
110      conf.check_python_headers()
111
112  # check support for C99 __VA_ARGS__ macros
113  check_c99_varargs = '''
114#include <stdio.h>
115#define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
116'''
117  if conf.check_cc(fragment = check_c99_varargs,
118      type='cstaticlib',
119      msg = 'Checking for C99 __VA_ARGS__ macro'):
120    conf.define('HAVE_C99_VARARGS_MACROS', 1)
121
122  # write configuration header
123  conf.write_config_header('src/config.h')
124
125  # add some defines used in examples
126  conf.define('AUBIO_PREFIX', conf.env['PREFIX'])
127  conf.define('PACKAGE', APPNAME)
128
129  # check if docbook-to-man is installed, optional
130  conf.find_program('docbook-to-man', var='DOCBOOKTOMAN', mandatory=False)
131
132def build(bld):
133  bld.env['VERSION'] = VERSION
134  bld.env['LIB_VERSION'] = LIB_VERSION
135
136  build_extras(bld)
137
138  # add sub directories
139  bld.add_subdirs('src examples')
140  if bld.env['SWIG']:
141    if bld.env['PYTHON']:
142      bld.add_subdirs('python/aubio python')
143
144  # create the aubio.pc file for pkg-config
145  aubiopc = bld.new_task_gen('subst')
146  aubiopc.source = 'aubio.pc.in'
147  aubiopc.target = 'aubio.pc'
148  aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
149
150  # build manpages from sgml files
151  if bld.env['DOCBOOKTOMAN']:
152    import TaskGen
153    TaskGen.declare_chain(
154        name    = 'docbooktoman',
155        rule    = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
156        ext_in  = '.sgml',
157        ext_out = '.1',
158        reentrant = 0,
159    )
160    manpages = bld.new_task_gen(name = 'docbooktoman',
161        source=bld.path.ant_glob('doc/*.sgml'))
162    bld.install_files('${MANDIR}/man1', bld.path.ant_glob('doc/*.1'))
163
164  # install woodblock sound
165  bld.install_files('${PREFIX}/share/sounds/aubio/',
166      'sounds/woodblock.aiff')
167
168  # build and run the unit tests
169  build_tests(bld)
170  import UnitTest
171  bld.add_post_fun(UnitTest.summary)
172
173def shutdown(bld):
174  pass
175
176# loop over all *.c filenames in tests/src to build them all
177# target name is filename.c without the .c
178def build_tests(bld):
179  for target_name in bld.path.ant_glob('tests/src/**/*.c').split():
180    this_target = bld.new_task_gen(
181        features = 'cc cprogram test',
182        source = target_name,
183        target = target_name.split('.')[0],
184        includes = 'src',
185        defines = 'AUBIO_UNSTABLE_API=1',
186        uselib_local = 'aubio')
187    # phasevoc-jack also needs jack
188    if target_name.endswith('test-phasevoc-jack.c'):
189      this_target.includes = ['src', 'examples']
190      this_target.uselib_local = ['aubio']
191      this_target.uselib = ['JACK']
192      this_target.source += ' examples/jackio.c'
193
194def build_extras(bld):
195    # corner cases to build these ones only once
196    sndfileio = bld.new_task_gen(features = 'cc',
197        includes = 'examples src',
198        source = ['examples/sndfileio.c'],
199        target = 'sndfileio')
200
201    defines = ['AUBIO_PREFIX="' + bld.env['AUBIO_PREFIX'] + '"']
202    defines += ['PACKAGE="' + bld.env['PACKAGE'] + '"']
203
204    utilsio = bld.new_task_gen(features = 'cc',
205          includes = 'examples src',
206          add_objects = 'sndfileio',
207          source = ['examples/utils.c', 'examples/jackio.c'],
208          uselib = ['LASH', 'JACK', 'SNDFILE'],
209          defines = defines,
210          target = 'utilsio')
Note: See TracBrowser for help on using the repository browser.