source: wscript @ 5820107

feature/autosinkfeature/constantqfeature/pitchshiftfeature/pydocstringsfeature/timestretchpitchshiftsamplertimestretchyinfft+
Last change on this file since 5820107 was 5820107, checked in by Paul Brossier <piem@piem.org>, 9 years ago

wscript: parse VERSION from file

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