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"
33 def add_option_enable_disable(ctx, name, default = None, help_str = None, help_disable_str = None):
35 help_str = 'enable ' + name + ' support'
36 if help_disable_str == None:
37 help_disable_str = 'do not ' + help_str
38 ctx.add_option('--enable-' + name, action = 'store_true', default = default,
39 dest = 'enable_' + name,
41 ctx.add_option('--disable-' + name, action = 'store_false',
43 dest = 'enable_' + name,
44 help = help_disable_str )
47 add_option_enable_disable(ctx, 'double', default = False,
48 help_str = 'compile aubio in double precision mode')
49 add_option_enable_disable(ctx, 'fftw3f', default = False,
50 help_str = 'compile with fftw3f instead of ooura (recommended)', help_disable_str = 'do not compile with fftw3f')
51 add_option_enable_disable(ctx, 'fftw3', default = False,
52 help_str = 'compile with fftw3 instead of ooura', help_disable_str = 'do not compile with fftw3')
53 add_option_enable_disable(ctx, 'complex', default = False,
54 help_str ='compile with C99 complex', help_disable_str = 'do not use C99 complex (default)' )
55 add_option_enable_disable(ctx, 'jack', default = None,
56 help_str = 'compile with jack (auto)', help_disable_str = 'disable jack support')
57 add_option_enable_disable(ctx, 'lash', default = None,
58 help_str = 'compile with LASH (auto)', help_disable_str = 'disable LASH' )
59 add_option_enable_disable(ctx, 'sndfile', default = None,
60 help_str = 'compile with sndfile (auto)', help_disable_str = 'disable sndfile')
61 add_option_enable_disable(ctx, 'samplerate', default = None,
62 help_str = 'compile with samplerate (auto)', help_disable_str = 'disable samplerate')
64 ctx.add_option('--with-target-platform', type='string',
65 help='set target platform for cross-compilation', dest='target_platform')
66 ctx.load('compiler_c')
67 ctx.load('waf_unit_test')
70 from waflib import Options
71 ctx.load('compiler_c')
72 ctx.load('waf_unit_test')
73 ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
75 if Options.options.target_platform:
76 Options.platform = Options.options.target_platform
78 if Options.platform == 'win32':
79 ctx.env['shlib_PATTERN'] = 'lib%s.dll'
81 if Options.platform == 'darwin':
82 ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
83 ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
84 ctx.env.CC = 'llvm-gcc-4.2'
85 ctx.env.LINK_CC = 'llvm-gcc-4.2'
86 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
87 ctx.define('HAVE_ACCELERATE', 1)
89 if Options.platform in [ 'ios', 'iosimulator' ]:
92 ctx.env.LINK_CC = 'clang'
93 ctx.define('HAVE_ACCELERATE', 1)
94 ctx.define('TARGET_OS_IPHONE', 1)
95 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
98 if Options.platform == 'ios':
99 DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
100 SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals()
101 ctx.env.CFLAGS += [ '-arch', 'armv7' ]
102 ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
103 ctx.env.LINKFLAGS += ['-arch', 'armv7']
104 ctx.env.LINKFLAGS += ['-arch', 'armv7s']
106 DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer"
107 SDKROOT="%(DEVROOT)s/SDKs/iPhoneSimulator%(SDKVER)s.sdk" % locals()
108 ctx.env.CFLAGS += [ '-arch', 'i386' ]
109 ctx.env.LINKFLAGS += ['-arch', 'i386']
110 ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
111 ctx.env.LINKFLAGS += ['-arch', 'x86_64']
112 ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
113 ctx.env.CFLAGS += [ '--sysroot=%s' % SDKROOT]
114 ctx.env.CFLAGS += ['-std=c99']
115 ctx.env.LINKFLAGS += ['-std=c99']
116 ctx.env.LINKFLAGS += ['--sysroot=%s' % SDKROOT]
118 # check for required headers
119 ctx.check(header_name='stdlib.h')
120 ctx.check(header_name='stdio.h')
121 ctx.check(header_name='math.h')
122 ctx.check(header_name='string.h')
123 ctx.check(header_name='limits.h')
125 # check support for C99 __VA_ARGS__ macros
126 check_c99_varargs = '''
128 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
130 if ctx.check_cc(fragment = check_c99_varargs,
132 msg = 'Checking for C99 __VA_ARGS__ macro'):
133 ctx.define('HAVE_C99_VARARGS_MACROS', 1)
135 # optionally use complex.h
136 if (Options.options.enable_complex == True):
137 ctx.check(header_name='complex.h')
140 if (Options.options.enable_sndfile != False):
141 ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
142 args = '--cflags --libs', mandatory = False)
143 if (Options.options.enable_samplerate != False):
144 ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
145 args = '--cflags --libs', mandatory = False)
147 # double precision mode
148 if (Options.options.enable_double == True):
149 ctx.define('HAVE_AUBIO_DOUBLE', 1)
151 ctx.define('HAVE_AUBIO_DOUBLE', 0)
153 # optional dependancies using pkg-config
154 if (Options.options.enable_fftw3 != False or Options.options.enable_fftw3f != False):
155 # one of fftwf or fftw3f
156 if (Options.options.enable_fftw3f != False):
157 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
158 args = '--cflags --libs', mandatory = False)
159 if (Options.options.enable_double == True):
160 ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!')
162 # fftw3f not enabled, take most sensible one according to enable_double
163 if (Options.options.enable_double == True):
164 ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
165 args = '--cflags --libs', mandatory = False)
167 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
168 args = '--cflags --libs', mandatory = False)
169 ctx.define('HAVE_FFTW3', 1)
171 # fftw disabled, use ooura
172 if 'HAVE_FFTW3F' in ctx.env.define_key:
173 ctx.msg('Checking for FFT implementation', 'fftw3f')
174 elif 'HAVE_FFTW3' in ctx.env.define_key:
175 ctx.msg('Checking for FFT implementation', 'fftw3')
176 elif 'HAVE_ACCELERATE' in ctx.env.define_key:
177 ctx.msg('Checking for FFT implementation', 'vDSP')
179 ctx.msg('Checking for FFT implementation', 'ooura')
181 if (Options.options.enable_jack != False):
182 ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
183 args = '--cflags --libs', mandatory = False)
185 if (Options.options.enable_lash != False):
186 ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
187 args = '--cflags --libs', uselib_store = 'LASH', mandatory = False)
189 # write configuration header
190 ctx.write_config_header('src/config.h')
192 # add some defines used in examples
193 ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
194 ctx.define('PACKAGE', APPNAME)
196 # check if docbook-to-man is installed, optional
198 ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
199 except ctx.errors.ConfigurationError:
200 ctx.to_log('docbook-to-man was not found (ignoring)')
203 bld.env['VERSION'] = VERSION
204 bld.env['LIB_VERSION'] = LIB_VERSION
206 # add sub directories
208 from waflib import Options
209 if Options.platform not in ['ios', 'iosimulator']:
210 bld.recurse('examples')
214 # install woodblock sound
215 bld.install_files('${PREFIX}/share/sounds/aubio/',
216 'sounds/woodblock.aiff')
219 bld( source = 'aubio.pc.in' )
221 # build manpages from sgml files
222 if bld.env['DOCBOOKTOMAN']:
223 from waflib import TaskGen
224 if 'MANDIR' not in bld.env:
225 bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man'
226 TaskGen.declare_chain(
227 name = 'docbooktoman',
228 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
232 install_path = '${MANDIR}/man1',
234 bld( source = bld.path.ant_glob('doc/*.sgml') )
237 bld(rule = 'doxygen ${SRC}', source = 'web.cfg') #, target = 'doc/web/index.html')
242 from waflib import Options, Logs
243 if Options.platform in ['ios', 'iosimulator']:
244 msg ='aubio built for ios, contact the author for a commercial license'
245 Logs.pprint('RED', msg)
246 msg =' Paul Brossier <piem@aubio.org>'
247 Logs.pprint('RED', msg)