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-fftw3', action='store_true', default=None,
40 help='compile with fftw3 instead of ooura (recommended)')
41 ctx.add_option('--disable-fftw3', dest='enable_fftw3',
43 help='compile with ooura instead of fftw3')
44 ctx.add_option('--enable-complex', action='store_true', default=None,
45 help='compile with C99 complex')
46 ctx.add_option('--disable-complex', dest='enable_complex',
48 help='compile without C99 complex')
49 ctx.add_option('--enable-jack', action='store_true', default=None,
50 help='compile with jack support')
51 ctx.add_option('--disable-jack', dest='enable_jack', action='store_false',
52 help='compile without jack support')
53 ctx.add_option('--enable-lash', action='store_true', default=None,
54 help='compile with lash support')
55 ctx.add_option('--disable-lash', dest='enable_lash', action='store_false',
56 help='compile without lash support')
57 ctx.add_option('--enable-sndfile', action='store_true', default=None,
58 help='compile with libsndfile support')
59 ctx.add_option('--disable-sndfile', dest='enable_sndfile',
61 help='compile without libsndfile support')
62 ctx.add_option('--enable-samplerate', action='store_true', default=None,
63 help='compile with libsamplerate support')
64 ctx.add_option('--disable-samplerate', dest='enable_samplerate',
66 help='compile without libsamplerate support')
67 ctx.add_option('--with-target-platform', type='string',
68 help='set target platform for cross-compilation', dest='target_platform')
69 ctx.load('compiler_c')
70 ctx.load('waf_unit_test')
73 from waflib import Options
74 ctx.load('compiler_c')
75 ctx.load('waf_unit_test')
76 ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
78 if Options.options.target_platform:
79 Options.platform = Options.options.target_platform
81 if Options.platform == 'win32':
82 ctx.env['shlib_PATTERN'] = 'lib%s.dll'
84 if Options.platform == 'darwin':
85 ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
86 ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
87 ctx.env.CC = 'llvm-gcc-4.2'
88 ctx.env.LINK_CC = 'llvm-gcc-4.2'
89 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
90 ctx.define('HAVE_ACCELERATE', 1)
92 if Options.platform == 'ios':
95 ctx.env.LINK_CC = 'clang'
97 DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
98 SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals()
99 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
100 ctx.define('HAVE_ACCELERATE', 1)
101 ctx.env.CFLAGS += [ '-miphoneos-version-min=6.1', '-arch', 'armv7',
102 '--sysroot=%s' % SDKROOT]
103 ctx.env.LINKFLAGS += ['-std=c99', '-arch', 'armv7', '--sysroot=%s' %
106 # check for required headers
107 ctx.check(header_name='stdlib.h')
108 ctx.check(header_name='stdio.h')
109 ctx.check(header_name='math.h')
110 ctx.check(header_name='string.h')
111 ctx.check(header_name='limits.h')
113 # check support for C99 __VA_ARGS__ macros
114 check_c99_varargs = '''
116 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
118 if ctx.check_cc(fragment = check_c99_varargs,
120 msg = 'Checking for C99 __VA_ARGS__ macro'):
121 ctx.define('HAVE_C99_VARARGS_MACROS', 1)
123 # optionally use complex.h
124 if (Options.options.enable_complex == True):
125 ctx.check(header_name='complex.h')
128 if (Options.options.enable_sndfile != False):
129 ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
130 args = '--cflags --libs', mandatory = Options.options.enable_sndfile)
131 if (Options.options.enable_samplerate != False):
132 ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
133 args = '--cflags --libs',
134 mandatory = Options.options.enable_samplerate)
136 # double precision mode
137 if (Options.options.enable_double == True):
138 ctx.define('HAVE_AUBIO_DOUBLE', 1)
140 ctx.define('HAVE_AUBIO_DOUBLE', 0)
142 # optional dependancies using pkg-config
143 if (Options.options.enable_fftw3 != False):
144 # fftw3f not enabled, take most sensible one according to enable_double
146 if not Options.options.enable_double:
148 ctx.check_cfg(package = package, atleast_version = '3.0.0',
149 args = '--cflags --libs', mandatory = Options.options.enable_fftw3)
150 ctx.define('HAVE_FFTW3', 1)
152 # fftw disabled, use ooura
153 if 'HAVE_ACCELERATE' in ctx.env.define_key:
154 ctx.msg('Checking for FFT implementation', 'vDSP')
156 ctx.msg('Checking for FFT implementation', 'ooura')
159 if (Options.options.enable_jack != False):
160 ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
161 args = '--cflags --libs', mandatory = Options.options.enable_jack)
163 if (Options.options.enable_lash != False):
164 ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
165 args = '--cflags --libs', uselib_store = 'LASH',
166 mandatory = Options.options.enable_lash)
168 # write configuration header
169 ctx.write_config_header('src/config.h')
171 # add some defines used in examples
172 ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
173 ctx.define('PACKAGE', APPNAME)
175 # check if docbook-to-man is installed, optional
177 ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
178 except ctx.errors.ConfigurationError:
179 ctx.to_log('docbook-to-man was not found (ignoring)')
182 bld.env['VERSION'] = VERSION
183 bld.env['LIB_VERSION'] = LIB_VERSION
185 # add sub directories
187 from waflib import Options
188 if Options.platform != 'ios':
189 bld.recurse('examples')
193 # create the aubio.pc file for pkg-config
194 if ctx.env['TARGET_PLATFORM'] == 'linux':
195 aubiopc = ctx.new_task_gen('subst')
196 aubiopc.source = 'aubio.pc.in'
197 aubiopc.target = 'aubio.pc'
198 aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
200 # build manpages from sgml files
201 if ctx.env['DOCBOOKTOMAN']:
203 TaskGen.declare_chain(
204 name = 'docbooktoman',
205 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
210 manpages = ctx.new_task_gen(name = 'docbooktoman',
211 source=ctx.path.ant_glob('doc/*.sgml'))
212 ctx.install_files('${MANDIR}/man1', ctx.path.ant_glob('doc/*.1'))
214 # install woodblock sound
215 bld.install_files('${PREFIX}/share/sounds/aubio/',
216 'sounds/woodblock.aiff')
220 from waflib import Options, Logs
221 if Options.platform == 'ios':
222 msg ='aubio built for ios, contact the author for a commercial license'
223 Logs.pprint('RED', msg)
224 msg =' Paul Brossier <piem@aubio.org>'
225 Logs.pprint('RED', msg)