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]])
26 if os.path.exists('src/config.h') or os.path.exists('Makefile'):
27 print "Please run 'make distclean' to clean-up autotools files before using waf"
34 ctx.add_option('--enable-double', action='store_true', default=False,
35 help='compile aubio in double precision mode')
36 ctx.add_option('--enable-fftw3f', action='store_true', default=False,
37 help='compile with fftw3f instead of ooura (recommended)')
38 ctx.add_option('--enable-fftw3', action='store_true', default=False,
39 help='compile with fftw3 instead of ooura (recommended in double precision)')
40 ctx.add_option('--enable-complex', action='store_true', default=False,
41 help='compile with C99 complex')
42 ctx.add_option('--enable-jack', action='store_true', default=None,
43 help='compile with jack support')
44 ctx.add_option('--enable-lash', action='store_true', default=None,
45 help='compile with lash support')
46 ctx.add_option('--enable-sndfile', action='store_true', default=None,
47 help='compile with libsndfile support')
48 ctx.add_option('--enable-samplerate', action='store_true', default=None,
49 help='compile with libsamplerate support')
50 ctx.add_option('--with-target-platform', type='string',
51 help='set target platform for cross-compilation', dest='target_platform')
52 ctx.load('compiler_c')
53 ctx.load('waf_unit_test')
56 from waflib import Options
57 ctx.load('compiler_c')
58 ctx.load('waf_unit_test')
59 ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
61 if Options.options.target_platform:
62 Options.platform = Options.options.target_platform
64 if Options.platform == 'win32':
65 ctx.env['shlib_PATTERN'] = 'lib%s.dll'
67 if Options.platform == 'darwin':
68 ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
69 ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
70 ctx.env.CC = 'llvm-gcc-4.2'
71 ctx.env.LINK_CC = 'llvm-gcc-4.2'
72 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
73 ctx.define('HAVE_ACCELERATE', 1)
75 if Options.platform in [ 'ios', 'iosimulator' ]:
78 ctx.env.LINK_CC = 'clang'
79 ctx.define('HAVE_ACCELERATE', 1)
80 ctx.define('TARGET_OS_IPHONE', 1)
81 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
84 if Options.platform == 'ios':
85 DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
86 SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals()
87 ctx.env.CFLAGS += [ '-arch', 'armv7' ]
88 ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
89 ctx.env.LINKFLAGS += ['-arch', 'armv7']
90 ctx.env.LINKFLAGS += ['-arch', 'armv7s']
92 DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer"
93 SDKROOT="%(DEVROOT)s/SDKs/iPhoneSimulator%(SDKVER)s.sdk" % locals()
94 ctx.env.CFLAGS += [ '-arch', 'i386' ]
95 ctx.env.LINKFLAGS += ['-arch', 'i386']
96 ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
97 ctx.env.LINKFLAGS += ['-arch', 'x86_64']
98 ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
99 ctx.env.CFLAGS += [ '--sysroot=%s' % SDKROOT]
100 ctx.env.CFLAGS += ['-std=c99']
101 ctx.env.LINKFLAGS += ['-std=c99']
102 ctx.env.LINKFLAGS += ['--sysroot=%s' % SDKROOT]
104 # check for required headers
105 ctx.check(header_name='stdlib.h')
106 ctx.check(header_name='stdio.h')
107 ctx.check(header_name='math.h')
108 ctx.check(header_name='string.h')
109 ctx.check(header_name='limits.h')
111 # check support for C99 __VA_ARGS__ macros
112 check_c99_varargs = '''
114 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
116 if ctx.check_cc(fragment = check_c99_varargs,
118 msg = 'Checking for C99 __VA_ARGS__ macro'):
119 ctx.define('HAVE_C99_VARARGS_MACROS', 1)
121 # optionally use complex.h
122 if (Options.options.enable_complex == True):
123 ctx.check(header_name='complex.h')
126 if (Options.options.enable_sndfile != False):
127 ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
128 args = '--cflags --libs', mandatory = False)
129 if (Options.options.enable_samplerate != False):
130 ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
131 args = '--cflags --libs', mandatory = False)
133 # double precision mode
134 if (Options.options.enable_double == True):
135 ctx.define('HAVE_AUBIO_DOUBLE', 1)
137 ctx.define('HAVE_AUBIO_DOUBLE', 0)
139 # optional dependancies using pkg-config
140 if (Options.options.enable_fftw3 != False or Options.options.enable_fftw3f != False):
141 # one of fftwf or fftw3f
142 if (Options.options.enable_fftw3f != False):
143 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
144 args = '--cflags --libs', mandatory = False)
145 if (Options.options.enable_double == True):
146 ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!')
148 # fftw3f not enabled, take most sensible one according to enable_double
149 if (Options.options.enable_double == True):
150 ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
151 args = '--cflags --libs', mandatory = False)
153 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
154 args = '--cflags --libs', mandatory = False)
155 ctx.define('HAVE_FFTW3', 1)
157 # fftw disabled, use ooura
158 if 'HAVE_FFTW3F' in ctx.env.define_key:
159 ctx.msg('Checking for FFT implementation', 'fftw3f')
160 elif 'HAVE_FFTW3' in ctx.env.define_key:
161 ctx.msg('Checking for FFT implementation', 'fftw3')
162 elif 'HAVE_ACCELERATE' in ctx.env.define_key:
163 ctx.msg('Checking for FFT implementation', 'vDSP')
165 ctx.msg('Checking for FFT implementation', 'ooura')
167 if (Options.options.enable_jack != False):
168 ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
169 args = '--cflags --libs', mandatory = False)
171 if (Options.options.enable_lash != False):
172 ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
173 args = '--cflags --libs', uselib_store = 'LASH', mandatory = False)
175 # write configuration header
176 ctx.write_config_header('src/config.h')
178 # add some defines used in examples
179 ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
180 ctx.define('PACKAGE', APPNAME)
182 # check if docbook-to-man is installed, optional
184 ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
185 except ctx.errors.ConfigurationError:
186 ctx.to_log('docbook-to-man was not found (ignoring)')
189 bld.env['VERSION'] = VERSION
190 bld.env['LIB_VERSION'] = LIB_VERSION
192 # add sub directories
194 from waflib import Options
195 if Options.platform not in ['ios', 'iosimulator']:
196 bld.recurse('examples')
200 # install woodblock sound
201 bld.install_files('${PREFIX}/share/sounds/aubio/',
202 'sounds/woodblock.aiff')
205 bld( source = 'aubio.pc.in' )
207 # build manpages from sgml files
208 if bld.env['DOCBOOKTOMAN']:
209 from waflib import TaskGen
210 if 'MANDIR' not in bld.env:
211 bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man'
212 TaskGen.declare_chain(
213 name = 'docbooktoman',
214 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
218 install_path = '${MANDIR}/man1',
220 bld( source = bld.path.ant_glob('doc/*.sgml') )
223 bld(rule = 'doxygen ${SRC}', source = 'web.cfg') #, target = 'doc/web/index.html')
228 from waflib import Options, Logs
229 if Options.platform in ['ios', 'iosimulator']:
230 msg ='aubio built for ios, contact the author for a commercial license'
231 Logs.pprint('RED', msg)
232 msg =' Paul Brossier <piem@aubio.org>'
233 Logs.pprint('RED', msg)