3 # waf build script, see http://code.google.com/p/waf/
5 # $ waf distclean configure build
7 # $ svn co http://waf.googlecode.com/svn/trunk /path/to/waf
8 # $ alias waf=/path/to/waf/waf-light
12 # - tests: move to new unit test system
17 for l in open('VERSION').readlines(): exec (l.strip())
20 ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \
21 + AUBIO_VERSION_STATUS
22 LIB_VERSION = '.'.join \
23 ([str(x) for x in [LIBAUBIO_LT_CUR, LIBAUBIO_LT_REV, LIBAUBIO_LT_AGE]])
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-samplerate', 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')
48 opt.load('waf_unit_test')
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')
58 if Options.options.target_platform:
59 Options.platform = Options.options.target_platform
61 if Options.platform == 'win32':
62 conf.env['shlib_PATTERN'] = 'lib%s.dll'
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')
71 # optionally use complex.h
72 if (Options.options.enable_complex == True):
73 conf.check(header_name='complex.h')
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')
82 # double precision mode
83 if (Options.options.enable_double == True):
84 conf.define('HAVE_AUBIO_DOUBLE', 1)
86 conf.define('HAVE_AUBIO_DOUBLE', 0)
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')
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')
98 conf.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
99 args = '--cflags --libs')
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')
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')
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()
120 # check support for C99 __VA_ARGS__ macros
121 check_c99_varargs = '''
123 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
125 if conf.check_cc(fragment = check_c99_varargs,
127 msg = 'Checking for C99 __VA_ARGS__ macro'):
128 conf.define('HAVE_C99_VARARGS_MACROS', 1)
130 # write configuration header
131 conf.write_config_header('src/config.h')
133 # add some defines used in examples
134 conf.define('AUBIO_PREFIX', conf.env['PREFIX'])
135 conf.define('PACKAGE', APPNAME)
137 # check if docbook-to-man is installed, optional
138 conf.find_program('docbook-to-man', var='DOCBOOKTOMAN', mandatory=False)
141 bld.env['VERSION'] = VERSION
142 bld.env['LIB_VERSION'] = LIB_VERSION
144 # add sub directories
145 bld.add_subdirs('src examples')
147 if bld.env['PYTHON']:
148 bld.add_subdirs('python/aubio python')
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'
156 # build manpages from sgml files
157 if bld.env['DOCBOOKTOMAN']:
159 TaskGen.declare_chain(
160 name = 'docbooktoman',
161 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
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'))
170 # install woodblock sound
171 bld.install_files('${PREFIX}/share/sounds/aubio/',
172 'sounds/woodblock.aiff')
174 # build and run the unit tests
180 # loop over all *.c filenames in tests/src to build them all
181 # target name is filename.c without the .c
182 def 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],
189 defines = 'AUBIO_UNSTABLE_API=1',
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'