source: wscript @ 2359cbd

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

wscript: factorise build of extra source files

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