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('--disable-double', dest='enable_double',
38 help='compile aubio in single precision mode')
39 ctx.add_option('--enable-fftw3f', action='store_true', default=False,
40 help='compile with fftw3f instead of ooura (recommended)')
41 ctx.add_option('--disable-fftw3f', dest='enable_fftw3f',
42 ctx.add_option('--enable-fftw3', action='store_true', default=None,
43 help='compile with fftw3 instead of ooura (recommended)')
44 ctx.add_option('--disable-fftw3', dest='enable_fftw3',
46 help='compile with ooura instead of fftw3f')
47 ctx.add_option('--enable-fftw3', action='store_true', default=False,
48 help='compile with fftw3 instead of ooura (recommended in double precision)')
49 ctx.add_option('--disable-fftw3', dest='enable-fftw3', action='store_false'.
50 help='compile with ooura instead of fftw3')
51 ctx.add_option('--enable-complex', action='store_true', default=False,
52 help='compile with C99 complex')
53 ctx.add_option('--disable-complex', dest='enable_complex',
55 help='compile without C99 complex')
56 ctx.add_option('--enable-jack', action='store_true', default=None,
57 help='compile with jack support')
58 ctx.add_option('--disable-jack', dest='enable_jack', action='store_false',
59 help='compile without jack support')
60 ctx.add_option('--enable-lash', action='store_true', default=None,
61 help='compile with lash support')
62 ctx.add_option('--disable-lash', dest='enable_lash', action='store_false',
63 help='compile without lash support')
64 ctx.add_option('--enable-sndfile', action='store_true', default=None,
65 help='compile with libsndfile support')
66 ctx.add_option('--disable-sndfile', dest='enable_sndfile',
68 help='compile without libsndfile support')
69 ctx.add_option('--enable-samplerate', action='store_true', default=None,
70 help='compile with libsamplerate support')
71 ctx.add_option('--disable-samplerate', dest='enable_samplerate',
73 help='compile without libsamplerate support')
74 ctx.add_option('--with-target-platform', type='string',
75 help='set target platform for cross-compilation', dest='target_platform')
76 ctx.load('compiler_c')
77 ctx.load('waf_unit_test')
80 from waflib import Options
81 ctx.load('compiler_c')
82 ctx.load('waf_unit_test')
83 ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
85 if Options.options.target_platform:
86 Options.platform = Options.options.target_platform
88 if Options.platform == 'win32':
89 ctx.env['shlib_PATTERN'] = 'lib%s.dll'
91 if Options.platform == 'darwin':
92 ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
93 ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
94 ctx.env.CC = 'llvm-gcc-4.2'
95 ctx.env.LINK_CC = 'llvm-gcc-4.2'
96 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
97 ctx.define('HAVE_ACCELERATE', 1)
99 if Options.platform == 'ios':
102 ctx.env.LINK_CC = 'clang'
104 DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
105 SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals()
106 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
107 ctx.define('HAVE_ACCELERATE', 1)
108 ctx.env.CFLAGS += [ '-miphoneos-version-min=6.1', '-arch', 'armv7',
109 '--sysroot=%s' % SDKROOT]
110 ctx.env.LINKFLAGS += ['-std=c99', '-arch', 'armv7', '--sysroot=%s' %
113 # check for required headers
114 ctx.check(header_name='stdlib.h')
115 ctx.check(header_name='stdio.h')
116 ctx.check(header_name='math.h')
117 ctx.check(header_name='string.h')
118 ctx.check(header_name='limits.h')
120 # check support for C99 __VA_ARGS__ macros
121 check_c99_varargs = '''
123 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
125 if ctx.check_cc(fragment = check_c99_varargs,
127 msg = 'Checking for C99 __VA_ARGS__ macro'):
128 ctx.define('HAVE_C99_VARARGS_MACROS', 1)
130 # optionally use complex.h
131 if (Options.options.enable_complex == True):
132 ctx.check(header_name='complex.h')
135 if (Options.options.enable_sndfile != False):
136 ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
137 args = '--cflags --libs', mandatory = False)
138 if (Options.options.enable_samplerate != False):
139 ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
140 args = '--cflags --libs', mandatory = False)
142 # double precision mode
143 if (Options.options.enable_double == True):
144 ctx.define('HAVE_AUBIO_DOUBLE', 1)
146 ctx.define('HAVE_AUBIO_DOUBLE', 0)
148 # optional dependancies using pkg-config
149 if (Options.options.enable_fftw3 != False or Options.options.enable_fftw3f != False):
150 # one of fftwf or fftw3f
151 if (Options.options.enable_fftw3f != False):
152 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
153 args = '--cflags --libs', mandatory = False)
154 if (Options.options.enable_double == True):
155 ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!')
157 # fftw3f not enabled, take most sensible one according to enable_double
158 if (Options.options.enable_double == True):
159 ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
160 args = '--cflags --libs', mandatory = False)
162 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
163 args = '--cflags --libs', mandatory = False)
164 ctx.define('HAVE_FFTW3', 1)
166 # fftw disabled, use ooura
167 if 'HAVE_ACCELERATE' in ctx.env.define_key:
168 ctx.msg('Checking for FFT implementation', 'vDSP')
170 ctx.msg('Checking for FFT implementation', 'ooura')
173 if (Options.options.enable_jack != False):
174 ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
175 args = '--cflags --libs', mandatory = False)
177 if (Options.options.enable_lash != False):
178 ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
179 args = '--cflags --libs', uselib_store = 'LASH', mandatory = False)
181 # write configuration header
182 ctx.write_config_header('src/config.h')
184 # add some defines used in examples
185 ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
186 ctx.define('PACKAGE', APPNAME)
188 # check if docbook-to-man is installed, optional
190 ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
191 except ctx.errors.ConfigurationError:
192 ctx.to_log('docbook-to-man was not found (ignoring)')
195 bld.env['VERSION'] = VERSION
196 bld.env['LIB_VERSION'] = LIB_VERSION
198 # add sub directories
200 from waflib import Options
201 if Options.platform != 'ios':
202 bld.recurse('examples')
206 # create the aubio.pc file for pkg-config
207 if ctx.env['TARGET_PLATFORM'] == 'linux':
208 aubiopc = ctx.new_task_gen('subst')
209 aubiopc.source = 'aubio.pc.in'
210 aubiopc.target = 'aubio.pc'
211 aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
213 # build manpages from sgml files
214 if ctx.env['DOCBOOKTOMAN']:
216 TaskGen.declare_chain(
217 name = 'docbooktoman',
218 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
223 manpages = ctx.new_task_gen(name = 'docbooktoman',
224 source=ctx.path.ant_glob('doc/*.sgml'))
225 ctx.install_files('${MANDIR}/man1', ctx.path.ant_glob('doc/*.1'))
227 # install woodblock sound
228 bld.install_files('${PREFIX}/share/sounds/aubio/',
229 'sounds/woodblock.aiff')
233 from waflib import Options, Logs
234 if Options.platform == 'ios':
235 msg ='aubio built for ios, contact the author for a commercial license'
236 Logs.pprint('RED', msg)
237 msg =' Paul Brossier <piem@aubio.org>'
238 Logs.pprint('RED', msg)