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())
19 VERSION = '.'.join ([str(x) for x in [
23 ]]) + AUBIO_VERSION_STATUS
25 LIB_VERSION = '.'.join ([str(x) for x in [
33 def add_option_enable_disable(ctx, name, default = None,
34 help_str = None, help_disable_str = None):
36 help_str = 'enable ' + name + ' support'
37 if help_disable_str == None:
38 help_disable_str = 'do not ' + help_str
39 ctx.add_option('--enable-' + name, action = 'store_true'
41 dest = 'enable_' + name.replace('-','_'),
43 ctx.add_option('--disable-' + name, action = 'store_false',
45 dest = 'enable_' + name.replace('-','_'),
46 help = help_disable_str )
49 add_option_enable_disable(ctx, 'fftw3f', default = False,
50 help_str = 'compile with fftw3f instead of ooura (recommended)',
51 help_disable_str = 'do not compile with fftw3f')
52 add_option_enable_disable(ctx, 'fftw3', default = False,
53 help_str = 'compile with fftw3 instead of ooura',
54 help_disable_str = 'do not compile with fftw3')
55 add_option_enable_disable(ctx, 'complex', default = False,
56 help_str ='compile with C99 complex',
57 help_disable_str = 'do not use C99 complex (default)' )
58 add_option_enable_disable(ctx, 'jack', default = None,
59 help_str = 'compile with jack (auto)',
60 help_disable_str = 'disable jack support')
61 add_option_enable_disable(ctx, 'sndfile', default = None,
62 help_str = 'compile with sndfile (auto)',
63 help_disable_str = 'disable sndfile')
64 add_option_enable_disable(ctx, 'avcodec', default = None,
65 help_str = 'compile with libavcodec (auto)',
66 help_disable_str = 'disable libavcodec')
67 add_option_enable_disable(ctx, 'samplerate', default = None,
68 help_str = 'compile with samplerate (auto)',
69 help_disable_str = 'disable samplerate')
70 add_option_enable_disable(ctx, 'memcpy', default = True,
71 help_str = 'use memcpy hacks (default)',
72 help_disable_str = 'do not use memcpy hacks')
73 add_option_enable_disable(ctx, 'double', default = False,
74 help_str = 'compile aubio in double precision mode',
75 help_disable_str = 'compile aubio in single precision mode (default)')
77 ctx.add_option('--with-target-platform', type='string',
78 help='set target platform for cross-compilation', dest='target_platform')
79 ctx.load('compiler_c')
80 ctx.load('waf_unit_test')
84 from waflib import Options
85 ctx.load('compiler_c')
86 ctx.load('waf_unit_test')
88 ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra', '-fPIC']
90 target_platform = Options.platform
91 if ctx.options.target_platform:
92 target_platform = ctx.options.target_platform
93 ctx.env['DEST_OS'] = target_platform
95 if target_platform == 'win32':
96 ctx.env['shlib_PATTERN'] = 'lib%s.dll'
98 if target_platform == 'darwin':
99 ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
100 ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
101 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
102 ctx.define('HAVE_ACCELERATE', 1)
104 if target_platform in [ 'ios', 'iosimulator' ]:
105 ctx.define('HAVE_ACCELERATE', 1)
106 ctx.define('TARGET_OS_IPHONE', 1)
107 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
110 ctx.env.CFLAGS += ['-std=c99']
111 if target_platform == 'ios':
112 DEVROOT = "/Applications/Xcode.app/Contents"
113 DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer"
114 SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals()
115 ctx.env.CFLAGS += [ '-arch', 'arm64' ]
116 ctx.env.CFLAGS += [ '-arch', 'armv7' ]
117 ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
118 ctx.env.LINKFLAGS += [ '-arch', 'arm64' ]
119 ctx.env.LINKFLAGS += ['-arch', 'armv7']
120 ctx.env.LINKFLAGS += ['-arch', 'armv7s']
121 ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
122 ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
124 DEVROOT = "/Applications/Xcode.app/Contents"
125 DEVROOT += "/Developer/Platforms/iPhoneSimulator.platform/Developer"
126 SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator%(SDKVER)s.sdk" % locals()
127 ctx.env.CFLAGS += [ '-arch', 'i386' ]
128 ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
129 ctx.env.LINKFLAGS += ['-arch', 'i386']
130 ctx.env.LINKFLAGS += ['-arch', 'x86_64']
131 ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
132 ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
133 ctx.env.CFLAGS += [ '-isysroot' , SDKROOT]
134 ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
136 # check for required headers
137 ctx.check(header_name='stdlib.h')
138 ctx.check(header_name='stdio.h')
139 ctx.check(header_name='math.h')
140 ctx.check(header_name='string.h')
141 ctx.check(header_name='limits.h')
143 # check support for C99 __VA_ARGS__ macros
144 check_c99_varargs = '''
146 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
148 if ctx.check_cc(fragment = check_c99_varargs,
150 msg = 'Checking for C99 __VA_ARGS__ macro'):
151 ctx.define('HAVE_C99_VARARGS_MACROS', 1)
153 # optionally use complex.h
154 if (ctx.options.enable_complex == True):
155 ctx.check(header_name='complex.h')
158 if (ctx.options.enable_sndfile != False):
159 ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
160 args = '--cflags --libs', mandatory = False)
161 if (ctx.options.enable_samplerate != False):
162 ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
163 args = '--cflags --libs', mandatory = False)
165 # double precision mode
166 if (ctx.options.enable_double == True):
167 ctx.define('HAVE_AUBIO_DOUBLE', 1)
169 ctx.define('HAVE_AUBIO_DOUBLE', 0)
171 # optional dependancies using pkg-config
172 if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False):
173 # one of fftwf or fftw3f
174 if (ctx.options.enable_fftw3f != False):
175 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
176 args = '--cflags --libs', mandatory = False)
177 if (ctx.options.enable_double == True):
178 ctx.msg('Warning', 'fftw3f enabled, but compiling in double precision!')
180 # fftw3f not enabled, take most sensible one according to enable_double
181 if (ctx.options.enable_double == True):
182 ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
183 args = '--cflags --libs', mandatory = False)
185 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
186 args = '--cflags --libs', mandatory = False)
187 ctx.define('HAVE_FFTW3', 1)
189 # fftw disabled, use ooura
190 if 'HAVE_FFTW3F' in ctx.env.define_key:
191 ctx.msg('Checking for FFT implementation', 'fftw3f')
192 elif 'HAVE_FFTW3' in ctx.env.define_key:
193 ctx.msg('Checking for FFT implementation', 'fftw3')
194 elif 'HAVE_ACCELERATE' in ctx.env.define_key:
195 ctx.msg('Checking for FFT implementation', 'vDSP')
197 ctx.msg('Checking for FFT implementation', 'ooura')
200 if (ctx.options.enable_memcpy == True):
201 ctx.define('HAVE_MEMCPY_HACKS', 1)
203 ctx.define('HAVE_MEMCPY_HACKS', 0)
205 if (ctx.options.enable_jack != False):
206 ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
207 args = '--cflags --libs', mandatory = False)
209 if (ctx.options.enable_avcodec != False):
210 ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0',
211 args = '--cflags --libs', uselib_store = 'AVCODEC', mandatory = False)
212 ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0',
213 args = '--cflags --libs', uselib_store = 'AVFORMAT', mandatory = False)
214 ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0',
215 args = '--cflags --libs', uselib_store = 'AVUTIL', mandatory = False)
216 ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
217 args = '--cflags --libs', uselib_store = 'AVRESAMPLE', mandatory = False)
219 # write configuration header
220 ctx.write_config_header('src/config.h')
222 # add some defines used in examples
223 ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
224 ctx.define('PACKAGE', APPNAME)
226 # check if txt2man is installed, optional
228 ctx.find_program('txt2man', var='TXT2MAN')
229 except ctx.errors.ConfigurationError:
230 ctx.to_log('txt2man was not found (ignoring)')
233 bld.env['VERSION'] = VERSION
234 bld.env['LIB_VERSION'] = LIB_VERSION
236 # add sub directories
238 if bld.env['DEST_OS'] not in ['ios', 'iosimulator']:
240 if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
241 bld.recurse('examples')
244 bld( source = 'aubio.pc.in' )
246 # build manpages from sgml files
247 if bld.env['TXT2MAN']:
248 from waflib import TaskGen
249 if 'MANDIR' not in bld.env:
250 bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man'
251 rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`'
252 rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}'
253 rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual'
254 rule_str += ' -s 1 ${SRC} > ${TGT}'
255 TaskGen.declare_chain(
258 #rule = '${TXT2MAN} -p -P aubio -s 1 -r aubio-0.4.0 ${SRC} > ${TGT}',
262 install_path = '${MANDIR}/man1',
264 bld( source = bld.path.ant_glob('doc/*.txt') )
267 bld(rule = 'doxygen ${SRC}', source = 'web.cfg') #, target = 'doc/web/index.html')
272 from waflib import Logs
273 if bld.options.target_platform in ['ios', 'iosimulator']:
274 msg ='building for %s, contact the author for a commercial license' % bld.options.target_platform
275 Logs.pprint('RED', msg)
276 msg =' Paul Brossier <piem@aubio.org>'
277 Logs.pprint('RED', msg)
280 ctx.excl = ' **/.waf-1* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git*'
281 ctx.excl += ' **/build/*'
282 ctx.excl += ' **/python/gen **/python/build **/python/dist'
283 ctx.excl += ' **/**.zip **/**.tar.bz2'
284 ctx.excl += ' **/doc/full/*'
285 ctx.excl += ' **/python/*.db'
286 ctx.excl += ' **/python.old/*'