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=False,
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=False,
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 = False)
131 if (Options.options.enable_samplerate != False):
132 ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
133 args = '--cflags --libs', mandatory = False)
135 # double precision mode
136 if (Options.options.enable_double == True):
137 ctx.define('HAVE_AUBIO_DOUBLE', 1)
139 ctx.define('HAVE_AUBIO_DOUBLE', 0)
141 # optional dependancies using pkg-config
142 if (Options.options.enable_fftw3 != False):
143 # fftw3f not enabled, take most sensible one according to enable_double
145 if not Options.options.enable_double:
147 ctx.check_cfg(package = package, atleast_version = '3.0.0',
148 args = '--cflags --libs', mandatory = False)
149 ctx.define('HAVE_FFTW3', 1)
151 # fftw disabled, use ooura
152 if 'HAVE_ACCELERATE' in ctx.env.define_key:
153 ctx.msg('Checking for FFT implementation', 'vDSP')
155 ctx.msg('Checking for FFT implementation', 'ooura')
158 if (Options.options.enable_jack != False):
159 ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
160 args = '--cflags --libs', mandatory = False)
162 if (Options.options.enable_lash != False):
163 ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
164 args = '--cflags --libs', uselib_store = 'LASH', mandatory = False)
166 # write configuration header
167 ctx.write_config_header('src/config.h')
169 # add some defines used in examples
170 ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
171 ctx.define('PACKAGE', APPNAME)
173 # check if docbook-to-man is installed, optional
175 ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
176 except ctx.errors.ConfigurationError:
177 ctx.to_log('docbook-to-man was not found (ignoring)')
180 bld.env['VERSION'] = VERSION
181 bld.env['LIB_VERSION'] = LIB_VERSION
183 # add sub directories
185 from waflib import Options
186 if Options.platform != 'ios':
187 bld.recurse('examples')
191 # create the aubio.pc file for pkg-config
192 if ctx.env['TARGET_PLATFORM'] == 'linux':
193 aubiopc = ctx.new_task_gen('subst')
194 aubiopc.source = 'aubio.pc.in'
195 aubiopc.target = 'aubio.pc'
196 aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
198 # build manpages from sgml files
199 if ctx.env['DOCBOOKTOMAN']:
201 TaskGen.declare_chain(
202 name = 'docbooktoman',
203 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
208 manpages = ctx.new_task_gen(name = 'docbooktoman',
209 source=ctx.path.ant_glob('doc/*.sgml'))
210 ctx.install_files('${MANDIR}/man1', ctx.path.ant_glob('doc/*.1'))
212 # install woodblock sound
213 bld.install_files('${PREFIX}/share/sounds/aubio/',
214 'sounds/woodblock.aiff')
218 from waflib import Options, Logs
219 if Options.platform == 'ios':
220 msg ='aubio built for ios, contact the author for a commercial license'
221 Logs.pprint('RED', msg)
222 msg =' Paul Brossier <piem@aubio.org>'
223 Logs.pprint('RED', msg)