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-fftw', action='store_true', default=False,
37 help='compile with ooura instead of fftw')
38 ctx.add_option('--enable-fftw3f', action='store_true', default=False,
39 help='compile with fftw3 instead of fftw3f')
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=False,
43 help='compile with jack support')
44 ctx.add_option('--enable-lash', action='store_true', default=False,
45 help='compile with lash support')
46 ctx.add_option('--enable-sndfile', action='store_true', default=False,
47 help='compile with libsndfile support')
48 ctx.add_option('--enable-samplerate', action='store_true', default=False,
49 help='compile with libsamplerate support')
50 ctx.add_option('--enable-swig', action='store_true', default=False,
51 help='compile with swig support (obsolete)')
52 ctx.add_option('--with-target-platform', type='string',
53 help='set target platform for cross-compilation', dest='target_platform')
54 ctx.load('compiler_c')
55 ctx.load('waf_unit_test')
58 from waflib import Options
59 ctx.load('compiler_c')
60 ctx.load('waf_unit_test')
61 ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
63 if Options.options.target_platform:
64 Options.platform = Options.options.target_platform
66 if Options.platform == 'win32':
67 ctx.env['shlib_PATTERN'] = 'lib%s.dll'
69 if Options.platform == 'darwin':
70 ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
71 ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
72 ctx.env.CC = 'llvm-gcc-4.2'
73 ctx.env.LINK_CC = 'llvm-gcc-4.2'
74 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox']
76 if Options.platform == 'ios':
79 ctx.env.LINK_CC = 'clang'
81 DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
82 SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals()
83 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox']
84 ctx.env.CFLAGS += [ '-miphoneos-version-min=6.1', '-arch', 'armv7',
85 '--sysroot=%s' % SDKROOT]
86 ctx.env.LINKFLAGS += ['-std=c99', '-arch', 'armv7', '--sysroot=%s' %
89 # check for required headers
90 ctx.check(header_name='stdlib.h')
91 ctx.check(header_name='stdio.h')
92 ctx.check(header_name='math.h')
93 ctx.check(header_name='string.h')
94 ctx.check(header_name='limits.h')
96 # optionally use complex.h
97 if (Options.options.enable_complex == True):
98 ctx.check(header_name='complex.h')
101 if (Options.options.enable_sndfile == True):
102 ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
103 args = '--cflags --libs')
104 if (Options.options.enable_samplerate == True):
105 ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
106 args = '--cflags --libs')
108 # double precision mode
109 if (Options.options.enable_double == True):
110 ctx.define('HAVE_AUBIO_DOUBLE', 1)
112 ctx.define('HAVE_AUBIO_DOUBLE', 0)
114 # check if pkg-config is installed, optional
116 ctx.find_program('pkg-config', var='PKGCONFIG')
117 except ctx.errors.ConfigurationError:
118 ctx.msg('Could not find pkg-config', 'disabling fftw, jack, and lash')
119 ctx.msg('Could not find fftw', 'using ooura')
121 # optional dependancies using pkg-config
122 if ctx.env['PKGCONFIG']:
124 if (Options.options.enable_fftw == True or Options.options.enable_fftw3f == True):
125 # one of fftwf or fftw3f
126 if (Options.options.enable_fftw3f == True):
127 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
128 args = '--cflags --libs')
129 if (Options.options.enable_double == True):
130 ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!')
132 # fftw3f not enabled, take most sensible one according to enable_double
133 if (Options.options.enable_double == True):
134 ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
135 args = '--cflags --libs')
137 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
138 args = '--cflags --libs')
139 ctx.define('HAVE_FFTW3', 1)
141 # fftw disabled, use ooura
142 ctx.msg('Checking for FFT implementation', 'ooura')
145 if (Options.options.enable_jack == True):
146 ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
147 args = '--cflags --libs')
149 if (Options.options.enable_lash == True):
150 ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
151 args = '--cflags --libs', uselib_store = 'LASH')
154 if (Options.options.enable_swig == True):
156 ctx.find_program('swig', var='SWIG')
157 except ctx.errors.ConfigurationError:
158 ctx.to_log('swig was not found, not looking for (ignoring)')
161 ctx.check_tool('swig')
162 ctx.check_swig_version()
165 if ctx.find_program('python'):
166 ctx.check_tool('python')
167 ctx.check_python_version((2,4,2))
168 ctx.check_python_headers()
170 # check support for C99 __VA_ARGS__ macros
171 check_c99_varargs = '''
173 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
175 if ctx.check_cc(fragment = check_c99_varargs,
177 msg = 'Checking for C99 __VA_ARGS__ macro'):
178 ctx.define('HAVE_C99_VARARGS_MACROS', 1)
180 # write configuration header
181 ctx.write_config_header('src/config.h')
183 # add some defines used in examples
184 ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
185 ctx.define('PACKAGE', APPNAME)
187 # check if docbook-to-man is installed, optional
189 ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
190 except ctx.errors.ConfigurationError:
191 ctx.to_log('docbook-to-man was not found (ignoring)')
194 bld.env['VERSION'] = VERSION
195 bld.env['LIB_VERSION'] = LIB_VERSION
197 # add sub directories
198 bld.recurse('src examples')
199 from waflib import Options
201 if Options.platform == sys.platform: bld.recurse('tests')
204 # create the aubio.pc file for pkg-config
205 if ctx.env['TARGET_PLATFORM'] == 'linux':
206 aubiopc = ctx.new_task_gen('subst')
207 aubiopc.source = 'aubio.pc.in'
208 aubiopc.target = 'aubio.pc'
209 aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
211 # build manpages from sgml files
212 if ctx.env['DOCBOOKTOMAN']:
214 TaskGen.declare_chain(
215 name = 'docbooktoman',
216 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
221 manpages = ctx.new_task_gen(name = 'docbooktoman',
222 source=ctx.path.ant_glob('doc/*.sgml'))
223 ctx.install_files('${MANDIR}/man1', ctx.path.ant_glob('doc/*.1'))
225 # install woodblock sound
226 bld.install_files('${PREFIX}/share/sounds/aubio/',
227 'sounds/woodblock.aiff')