7 # $ ./waf distclean configure build
9 # Note: aubio uses the waf build system, which relies on Python. Provided you
10 # have Python installed, you do *not* need to install anything to build aubio.
11 # For more info about waf, see http://code.google.com/p/waf/ .
16 for l in open('VERSION').readlines(): exec (l.strip())
18 VERSION = '.'.join ([str(x) for x in [
22 ]]) + AUBIO_VERSION_STATUS
24 LIB_VERSION = '.'.join ([str(x) for x in [
32 def add_option_enable_disable(ctx, name, default = None,
33 help_str = None, help_disable_str = None):
35 help_str = 'enable ' + name + ' support'
36 if help_disable_str == None:
37 help_disable_str = 'do not ' + help_str
38 ctx.add_option('--enable-' + name, action = 'store_true',
40 dest = 'enable_' + name.replace('-','_'),
42 ctx.add_option('--disable-' + name, action = 'store_false',
44 dest = 'enable_' + name.replace('-','_'),
45 help = help_disable_str )
48 add_option_enable_disable(ctx, 'fftw3f', default = False,
49 help_str = 'compile with fftw3f instead of ooura (recommended)',
50 help_disable_str = 'do not compile with fftw3f')
51 add_option_enable_disable(ctx, 'fftw3', default = False,
52 help_str = 'compile with fftw3 instead of ooura',
53 help_disable_str = 'do not compile with fftw3')
54 add_option_enable_disable(ctx, 'complex', default = False,
55 help_str ='compile with C99 complex',
56 help_disable_str = 'do not use C99 complex (default)' )
57 add_option_enable_disable(ctx, 'jack', default = None,
58 help_str = 'compile with jack (auto)',
59 help_disable_str = 'disable jack support')
60 add_option_enable_disable(ctx, 'sndfile', default = None,
61 help_str = 'compile with sndfile (auto)',
62 help_disable_str = 'disable sndfile')
63 add_option_enable_disable(ctx, 'avcodec', default = None,
64 help_str = 'compile with libavcodec (auto)',
65 help_disable_str = 'disable libavcodec')
66 add_option_enable_disable(ctx, 'samplerate', default = None,
67 help_str = 'compile with samplerate (auto)',
68 help_disable_str = 'disable samplerate')
69 add_option_enable_disable(ctx, 'memcpy', default = True,
70 help_str = 'use memcpy hacks (default)',
71 help_disable_str = 'do not use memcpy hacks')
72 add_option_enable_disable(ctx, 'double', default = False,
73 help_str = 'compile in double precision mode',
74 help_disable_str = 'compile in single precision mode (default)')
75 add_option_enable_disable(ctx, 'fat', default = False,
76 help_str = 'build fat binaries (darwin only)',
77 help_disable_str = 'do not build fat binaries (default)')
78 add_option_enable_disable(ctx, 'accelerate', default = None,
79 help_str = 'use Accelerate framework (darwin only) (auto)',
80 help_disable_str = 'do not use Accelerate framework')
81 add_option_enable_disable(ctx, 'apple-audio', default = None,
82 help_str = 'use CoreFoundation (darwin only) (auto)',
83 help_disable_str = 'do not use CoreFoundation framework')
84 add_option_enable_disable(ctx, 'atlas', default = None,
85 help_str = 'use Atlas library (auto)',
86 help_disable_str = 'do not use Atlas library')
88 add_option_enable_disable(ctx, 'docs', default = None,
89 help_str = 'build documentation (auto)',
90 help_disable_str = 'do not build documentation')
92 ctx.add_option('--with-target-platform', type='string',
93 help='set target platform for cross-compilation', dest='target_platform')
95 ctx.load('compiler_c')
96 ctx.load('waf_unit_test')
100 from waflib import Options
101 ctx.load('compiler_c')
102 ctx.load('waf_unit_test')
105 target_platform = Options.platform
106 if ctx.options.target_platform:
107 target_platform = ctx.options.target_platform
108 ctx.env['DEST_OS'] = target_platform
110 if 'CL.exe' not in ctx.env.CC[0]:
111 ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
113 ctx.env.CFLAGS += ['-Wall']
115 if target_platform not in ['win32', 'win64']:
116 ctx.env.CFLAGS += ['-fPIC']
118 ctx.define('HAVE_WIN_HACKS', 1)
119 ctx.env['cshlib_PATTERN'] = 'lib%s.dll'
121 if target_platform == 'darwin' and ctx.options.enable_fat:
122 ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
123 ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
125 ctx.env.CFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ]
126 ctx.env.LINKFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ]
128 if target_platform in [ 'darwin', 'ios', 'iosimulator']:
129 if (ctx.options.enable_apple_audio != False):
130 ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
131 ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1)
132 ctx.define('HAVE_SINK_APPLE_AUDIO', 1)
133 if (ctx.options.enable_accelerate != False):
134 ctx.define('HAVE_ACCELERATE', 1)
135 ctx.env.FRAMEWORK += ['Accelerate']
137 if target_platform in [ 'ios', 'iosimulator' ]:
139 ctx.env.CFLAGS += ['-std=c99']
140 if (ctx.options.enable_apple_audio != False):
141 ctx.define('HAVE_AUDIO_UNIT', 1)
142 #ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
143 if target_platform == 'ios':
144 DEVROOT = "/Applications/Xcode.app/Contents"
145 DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer"
146 SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS.sdk" % locals()
147 ctx.env.CFLAGS += [ '-fembed-bitcode' ]
148 ctx.env.CFLAGS += [ '-arch', 'arm64' ]
149 ctx.env.CFLAGS += [ '-arch', 'armv7' ]
150 ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
151 ctx.env.LINKFLAGS += [ '-arch', 'arm64' ]
152 ctx.env.LINKFLAGS += ['-arch', 'armv7']
153 ctx.env.LINKFLAGS += ['-arch', 'armv7s']
154 ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
155 ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
157 DEVROOT = "/Applications/Xcode.app/Contents"
158 DEVROOT += "/Developer/Platforms/iPhoneSimulator.platform/Developer"
159 SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator.sdk" % locals()
160 ctx.env.CFLAGS += [ '-arch', 'i386' ]
161 ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
162 ctx.env.LINKFLAGS += ['-arch', 'i386']
163 ctx.env.LINKFLAGS += ['-arch', 'x86_64']
164 ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
165 ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
166 ctx.env.CFLAGS += [ '-isysroot' , SDKROOT]
167 ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
169 if target_platform == 'emscripten':
171 ctx.env.CFLAGS += [ '-I' + os.path.join(os.environ['EMSCRIPTEN'], 'system', 'include') ]
172 ctx.env.CFLAGS += ['-Oz']
173 ctx.env.cprogram_PATTERN = "%s.js"
174 if (ctx.options.enable_atlas != True):
175 ctx.options.enable_atlas = False
177 # check for required headers
178 ctx.check(header_name='stdlib.h')
179 ctx.check(header_name='stdio.h')
180 ctx.check(header_name='math.h')
181 ctx.check(header_name='string.h')
182 ctx.check(header_name='limits.h')
184 # check support for C99 __VA_ARGS__ macros
185 check_c99_varargs = '''
187 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
190 if ctx.check_cc(fragment = check_c99_varargs,
192 msg = 'Checking for C99 __VA_ARGS__ macro',
194 ctx.define('HAVE_C99_VARARGS_MACROS', 1)
196 # double precision mode
197 if (ctx.options.enable_double == True):
198 ctx.define('HAVE_AUBIO_DOUBLE', 1)
200 ctx.define('HAVE_AUBIO_DOUBLE', 0)
202 # optionally use complex.h
203 if (ctx.options.enable_complex == True):
204 ctx.check(header_name='complex.h')
207 if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False):
208 # one of fftwf or fftw3f
209 if (ctx.options.enable_fftw3f != False):
210 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
211 args = '--cflags --libs',
212 mandatory = ctx.options.enable_fftw3f)
213 if (ctx.options.enable_double == True):
215 'fftw3f enabled, but compiling in double precision!')
217 # fftw3f disabled, take most sensible one according to
219 if (ctx.options.enable_double == True):
220 ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
221 args = '--cflags --libs', mandatory =
222 ctx.options.enable_fftw3)
224 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
225 args = '--cflags --libs',
226 mandatory = ctx.options.enable_fftw3)
227 ctx.define('HAVE_FFTW3', 1)
229 # fftw not enabled, use vDSP or ooura
230 if 'HAVE_FFTW3F' in ctx.env.define_key:
231 ctx.msg('Checking for FFT implementation', 'fftw3f')
232 elif 'HAVE_FFTW3' in ctx.env.define_key:
233 ctx.msg('Checking for FFT implementation', 'fftw3')
234 elif 'HAVE_ACCELERATE' in ctx.env.define_key:
235 ctx.msg('Checking for FFT implementation', 'vDSP')
237 ctx.msg('Checking for FFT implementation', 'ooura')
239 # check for libsndfile
240 if (ctx.options.enable_sndfile != False):
241 ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
242 args = '--cflags --libs',
243 mandatory = ctx.options.enable_sndfile)
245 # check for libsamplerate
246 if (ctx.options.enable_samplerate != False):
247 ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
248 args = '--cflags --libs',
249 mandatory = ctx.options.enable_samplerate)
252 if (ctx.options.enable_jack != False):
253 ctx.check_cfg(package = 'jack',
254 args = '--cflags --libs',
255 mandatory = ctx.options.enable_jack)
258 if (ctx.options.enable_avcodec != False):
259 ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0',
260 args = '--cflags --libs', uselib_store = 'AVCODEC',
261 mandatory = ctx.options.enable_avcodec)
262 ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0',
263 args = '--cflags --libs', uselib_store = 'AVFORMAT',
264 mandatory = ctx.options.enable_avcodec)
265 ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0',
266 args = '--cflags --libs', uselib_store = 'AVUTIL',
267 mandatory = ctx.options.enable_avcodec)
268 ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
269 args = '--cflags --libs', uselib_store = 'AVRESAMPLE',
270 mandatory = ctx.options.enable_avcodec)
271 if all ( 'HAVE_' + i in ctx.env
272 for i in ['AVCODEC', 'AVFORMAT', 'AVUTIL', 'AVRESAMPLE'] ):
273 ctx.define('HAVE_LIBAV', 1)
274 ctx.msg('Checking for all libav libraries', 'yes')
276 ctx.msg('Checking for all libav libraries', 'not found', color = 'YELLOW')
278 ctx.define('HAVE_WAVREAD', 1)
279 ctx.define('HAVE_WAVWRITE', 1)
282 if (ctx.options.enable_atlas != False):
283 ctx.check(header_name = 'atlas/cblas.h', mandatory = ctx.options.enable_atlas)
284 #ctx.check(lib = 'lapack', uselib_store = 'LAPACK', mandatory = ctx.options.enable_atlas)
285 ctx.check(lib = 'cblas', uselib_store = 'BLAS', mandatory = ctx.options.enable_atlas)
288 if (ctx.options.enable_memcpy == True):
289 ctx.define('HAVE_MEMCPY_HACKS', 1)
291 ctx.define('HAVE_MEMCPY_HACKS', 0)
293 # write configuration header
294 ctx.write_config_header('src/config.h')
296 # add some defines used in examples
297 ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
298 ctx.define('PACKAGE', APPNAME)
300 if (ctx.options.enable_docs != False):
301 # check if txt2man is installed, optional
303 ctx.find_program('txt2man', var='TXT2MAN')
304 except ctx.errors.ConfigurationError:
305 ctx.to_log('txt2man was not found (ignoring)')
307 # check if doxygen is installed, optional
309 ctx.find_program('doxygen', var='DOXYGEN')
310 except ctx.errors.ConfigurationError:
311 ctx.to_log('doxygen was not found (ignoring)')
314 bld.env['VERSION'] = VERSION
315 bld.env['LIB_VERSION'] = LIB_VERSION
317 # add sub directories
319 if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
320 bld.recurse('examples')
323 bld( source = 'aubio.pc.in' )
325 # build manpages from txt files using txt2man
326 if bld.env['TXT2MAN']:
327 from waflib import TaskGen
328 if 'MANDIR' not in bld.env:
329 bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man'
330 rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`'
331 rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}'
332 rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual'
333 rule_str += ' -s 1 ${SRC} > ${TGT}'
334 TaskGen.declare_chain(
340 install_path = '${MANDIR}/man1',
342 bld( source = bld.path.ant_glob('doc/*.txt') )
344 # build documentation from source files using doxygen
345 if bld.env['DOXYGEN']:
346 bld( name = 'doxygen', rule = 'doxygen ${SRC} > /dev/null',
347 source = 'doc/web.cfg',
349 bld.install_files( '${PREFIX}' + '/share/doc/libaubio-doc',
350 bld.path.ant_glob('doc/web/html/**'),
351 cwd = bld.path.find_dir ('doc/web'),
352 relative_trick = True)
355 from waflib import Logs
356 if bld.options.target_platform in ['ios', 'iosimulator']:
357 msg ='building for %s, contact the author for a commercial license' % bld.options.target_platform
358 Logs.pprint('RED', msg)
359 msg =' Paul Brossier <piem@aubio.org>'
360 Logs.pprint('RED', msg)
363 ctx.excl = ' **/.waf-1* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git*'
364 ctx.excl += ' **/build/*'
365 ctx.excl += ' **/python/gen **/python/build **/python/dist'
366 ctx.excl += ' **/**.zip **/**.tar.bz2'
367 ctx.excl += ' **/doc/full/* **/doc/web/*'
368 ctx.excl += ' **/python/*.db'
369 ctx.excl += ' **/python.old/*'
370 ctx.excl += ' **/python/tests/sounds'
371 ctx.excl += ' **/**.asc'
372 ctx.excl += ' **/.DS_Store'
373 ctx.excl += ' **/.travis.yml'