[5c411dc] | 1 | #! /usr/bin/python |
---|
[110ac90] | 2 | # |
---|
[21ee709] | 3 | # waf build script, see http://code.google.com/p/waf/ |
---|
| 4 | # usage: |
---|
| 5 | # $ waf distclean configure build |
---|
| 6 | # get it: |
---|
| 7 | # $ svn co http://waf.googlecode.com/svn/trunk /path/to/waf |
---|
| 8 | # $ alias waf=/path/to/waf/waf-light |
---|
| 9 | # |
---|
| 10 | # TODO |
---|
[ee36175] | 11 | # - doc: add doxygen |
---|
[110ac90] | 12 | # - tests: move to new unit test system |
---|
[000b090] | 13 | |
---|
| 14 | APPNAME = 'aubio' |
---|
[5820107] | 15 | |
---|
| 16 | # read from VERSION |
---|
| 17 | for l in open('VERSION').readlines(): exec (l.strip()) |
---|
| 18 | |
---|
| 19 | VERSION = '.'.join \ |
---|
| 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]]) |
---|
[e565c649] | 24 | |
---|
| 25 | import os.path, sys |
---|
| 26 | if os.path.exists('src/config.h') or os.path.exists('Makefile'): |
---|
[7684ff2] | 27 | print "Please run 'make distclean' to clean-up autotools files before using waf" |
---|
[e565c649] | 28 | sys.exit(1) |
---|
| 29 | |
---|
[46378b3] | 30 | top = '.' |
---|
| 31 | out = 'build' |
---|
[000b090] | 32 | |
---|
[3819aca] | 33 | def add_option_enable_disable(ctx, name, default = None, help_str = None, help_disable_str = None): |
---|
| 34 | if help_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, |
---|
[74bdc4a] | 39 | dest = 'enable_' + name.replace('-','_'), |
---|
[3819aca] | 40 | help = help_str) |
---|
| 41 | ctx.add_option('--disable-' + name, action = 'store_false', |
---|
| 42 | #default = default, |
---|
[74bdc4a] | 43 | dest = 'enable_' + name.replace('-','_'), |
---|
[3819aca] | 44 | help = help_disable_str ) |
---|
| 45 | |
---|
[d41bc4d] | 46 | def options(ctx): |
---|
[3819aca] | 47 | add_option_enable_disable(ctx, 'fftw3f', default = False, |
---|
| 48 | help_str = 'compile with fftw3f instead of ooura (recommended)', help_disable_str = 'do not compile with fftw3f') |
---|
| 49 | add_option_enable_disable(ctx, 'fftw3', default = False, |
---|
| 50 | help_str = 'compile with fftw3 instead of ooura', help_disable_str = 'do not compile with fftw3') |
---|
| 51 | add_option_enable_disable(ctx, 'complex', default = False, |
---|
| 52 | help_str ='compile with C99 complex', help_disable_str = 'do not use C99 complex (default)' ) |
---|
| 53 | add_option_enable_disable(ctx, 'jack', default = None, |
---|
| 54 | help_str = 'compile with jack (auto)', help_disable_str = 'disable jack support') |
---|
| 55 | add_option_enable_disable(ctx, 'lash', default = None, |
---|
| 56 | help_str = 'compile with LASH (auto)', help_disable_str = 'disable LASH' ) |
---|
| 57 | add_option_enable_disable(ctx, 'sndfile', default = None, |
---|
| 58 | help_str = 'compile with sndfile (auto)', help_disable_str = 'disable sndfile') |
---|
[ba0ba10] | 59 | add_option_enable_disable(ctx, 'avcodec', default = None, |
---|
| 60 | help_str = 'compile with libavcodec (auto)', help_disable_str = 'disable libavcodec') |
---|
[3819aca] | 61 | add_option_enable_disable(ctx, 'samplerate', default = None, |
---|
| 62 | help_str = 'compile with samplerate (auto)', help_disable_str = 'disable samplerate') |
---|
[923a7a8] | 63 | add_option_enable_disable(ctx, 'memcpy', default = True, |
---|
| 64 | help_str = 'use memcpy hacks (default)', |
---|
| 65 | help_disable_str = 'do not use memcpy hacks') |
---|
[d4c0932] | 66 | add_option_enable_disable(ctx, 'double', default = False, |
---|
| 67 | help_str = 'compile aubio in double precision mode', |
---|
| 68 | help_disable_str = 'compile aubio in single precision mode (default)') |
---|
[3819aca] | 69 | |
---|
[d41bc4d] | 70 | ctx.add_option('--with-target-platform', type='string', |
---|
[5c411dc] | 71 | help='set target platform for cross-compilation', dest='target_platform') |
---|
[d41bc4d] | 72 | ctx.load('compiler_c') |
---|
| 73 | ctx.load('waf_unit_test') |
---|
[f4aa258] | 74 | ctx.load('gnu_dirs') |
---|
[000b090] | 75 | |
---|
[d41bc4d] | 76 | def configure(ctx): |
---|
[6ed0f4e] | 77 | from waflib import Options |
---|
| 78 | ctx.load('compiler_c') |
---|
[d41bc4d] | 79 | ctx.load('waf_unit_test') |
---|
[f4aa258] | 80 | ctx.load('gnu_dirs') |
---|
[fda4fd7] | 81 | ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra', '-fPIC'] |
---|
[000b090] | 82 | |
---|
[985a5d1] | 83 | target_platform = Options.platform |
---|
| 84 | if ctx.options.target_platform: |
---|
| 85 | target_platform = ctx.options.target_platform |
---|
| 86 | ctx.env['DEST_OS'] = target_platform |
---|
[5c411dc] | 87 | |
---|
[985a5d1] | 88 | if target_platform == 'win32': |
---|
[d41bc4d] | 89 | ctx.env['shlib_PATTERN'] = 'lib%s.dll' |
---|
[5c411dc] | 90 | |
---|
[985a5d1] | 91 | if target_platform == 'darwin': |
---|
[d6001bf] | 92 | ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
| 93 | ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
[54dd945] | 94 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate'] |
---|
| 95 | ctx.define('HAVE_ACCELERATE', 1) |
---|
[d6001bf] | 96 | |
---|
[985a5d1] | 97 | if target_platform in [ 'ios', 'iosimulator' ]: |
---|
[54dd945] | 98 | ctx.define('HAVE_ACCELERATE', 1) |
---|
[5e1c04f] | 99 | ctx.define('TARGET_OS_IPHONE', 1) |
---|
[4084cd8] | 100 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate'] |
---|
| 101 | SDKVER="7.0" |
---|
| 102 | MINSDKVER="6.1" |
---|
[19ddbf3] | 103 | ctx.env.CFLAGS += ['-std=c99'] |
---|
[985a5d1] | 104 | if target_platform == 'ios': |
---|
[4084cd8] | 105 | DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer" |
---|
| 106 | SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals() |
---|
[917d4c1] | 107 | ctx.env.CFLAGS += [ '-arch', 'arm64' ] |
---|
[4084cd8] | 108 | ctx.env.CFLAGS += [ '-arch', 'armv7' ] |
---|
| 109 | ctx.env.CFLAGS += [ '-arch', 'armv7s' ] |
---|
[917d4c1] | 110 | ctx.env.LINKFLAGS += [ '-arch', 'arm64' ] |
---|
[4084cd8] | 111 | ctx.env.LINKFLAGS += ['-arch', 'armv7'] |
---|
| 112 | ctx.env.LINKFLAGS += ['-arch', 'armv7s'] |
---|
[19ddbf3] | 113 | ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
| 114 | ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
[4084cd8] | 115 | else: |
---|
| 116 | DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer" |
---|
| 117 | SDKROOT="%(DEVROOT)s/SDKs/iPhoneSimulator%(SDKVER)s.sdk" % locals() |
---|
| 118 | ctx.env.CFLAGS += [ '-arch', 'i386' ] |
---|
[0c11dfa] | 119 | ctx.env.CFLAGS += [ '-arch', 'x86_64' ] |
---|
[917d4c1] | 120 | ctx.env.LINKFLAGS += ['-arch', 'i386'] |
---|
[0c11dfa] | 121 | ctx.env.LINKFLAGS += ['-arch', 'x86_64'] |
---|
[19ddbf3] | 122 | ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
| 123 | ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
| 124 | ctx.env.CFLAGS += [ '-isysroot' , SDKROOT] |
---|
| 125 | ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT] |
---|
[a1da37f] | 126 | |
---|
[000b090] | 127 | # check for required headers |
---|
[d41bc4d] | 128 | ctx.check(header_name='stdlib.h') |
---|
| 129 | ctx.check(header_name='stdio.h') |
---|
| 130 | ctx.check(header_name='math.h') |
---|
| 131 | ctx.check(header_name='string.h') |
---|
| 132 | ctx.check(header_name='limits.h') |
---|
[000b090] | 133 | |
---|
[0318cc1] | 134 | # check support for C99 __VA_ARGS__ macros |
---|
| 135 | check_c99_varargs = ''' |
---|
| 136 | #include <stdio.h> |
---|
| 137 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
| 138 | ''' |
---|
| 139 | if ctx.check_cc(fragment = check_c99_varargs, |
---|
| 140 | type='cstlib', |
---|
| 141 | msg = 'Checking for C99 __VA_ARGS__ macro'): |
---|
| 142 | ctx.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
| 143 | |
---|
[000b090] | 144 | # optionally use complex.h |
---|
[985a5d1] | 145 | if (ctx.options.enable_complex == True): |
---|
[d41bc4d] | 146 | ctx.check(header_name='complex.h') |
---|
[000b090] | 147 | |
---|
[2e4fb04] | 148 | # check dependencies |
---|
[985a5d1] | 149 | if (ctx.options.enable_sndfile != False): |
---|
[0318cc1] | 150 | ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
| 151 | args = '--cflags --libs', mandatory = False) |
---|
[985a5d1] | 152 | if (ctx.options.enable_samplerate != False): |
---|
[d41bc4d] | 153 | ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
[0318cc1] | 154 | args = '--cflags --libs', mandatory = False) |
---|
[000b090] | 155 | |
---|
[06d30f9] | 156 | # double precision mode |
---|
[985a5d1] | 157 | if (ctx.options.enable_double == True): |
---|
[d41bc4d] | 158 | ctx.define('HAVE_AUBIO_DOUBLE', 1) |
---|
[06d30f9] | 159 | else: |
---|
[d41bc4d] | 160 | ctx.define('HAVE_AUBIO_DOUBLE', 0) |
---|
[06d30f9] | 161 | |
---|
[36f954a] | 162 | # optional dependancies using pkg-config |
---|
[985a5d1] | 163 | if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False): |
---|
[0318cc1] | 164 | # one of fftwf or fftw3f |
---|
[985a5d1] | 165 | if (ctx.options.enable_fftw3f != False): |
---|
[0318cc1] | 166 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 167 | args = '--cflags --libs', mandatory = False) |
---|
[985a5d1] | 168 | if (ctx.options.enable_double == True): |
---|
[0318cc1] | 169 | ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!') |
---|
[36f954a] | 170 | else: |
---|
[0318cc1] | 171 | # fftw3f not enabled, take most sensible one according to enable_double |
---|
[985a5d1] | 172 | if (ctx.options.enable_double == True): |
---|
[0318cc1] | 173 | ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
| 174 | args = '--cflags --libs', mandatory = False) |
---|
| 175 | else: |
---|
| 176 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 177 | args = '--cflags --libs', mandatory = False) |
---|
| 178 | ctx.define('HAVE_FFTW3', 1) |
---|
[5dc9f33] | 179 | |
---|
| 180 | # fftw disabled, use ooura |
---|
| 181 | if 'HAVE_FFTW3F' in ctx.env.define_key: |
---|
| 182 | ctx.msg('Checking for FFT implementation', 'fftw3f') |
---|
| 183 | elif 'HAVE_FFTW3' in ctx.env.define_key: |
---|
| 184 | ctx.msg('Checking for FFT implementation', 'fftw3') |
---|
| 185 | elif 'HAVE_ACCELERATE' in ctx.env.define_key: |
---|
| 186 | ctx.msg('Checking for FFT implementation', 'vDSP') |
---|
[0318cc1] | 187 | else: |
---|
[5dc9f33] | 188 | ctx.msg('Checking for FFT implementation', 'ooura') |
---|
[000b090] | 189 | |
---|
[923a7a8] | 190 | # use memcpy hacks |
---|
| 191 | if (ctx.options.enable_memcpy == True): |
---|
| 192 | ctx.define('HAVE_MEMCPY_HACKS', 1) |
---|
| 193 | else: |
---|
| 194 | ctx.define('HAVE_MEMCPY_HACKS', 0) |
---|
| 195 | |
---|
[985a5d1] | 196 | if (ctx.options.enable_jack != False): |
---|
[0318cc1] | 197 | ctx.check_cfg(package = 'jack', atleast_version = '0.15.0', |
---|
| 198 | args = '--cflags --libs', mandatory = False) |
---|
| 199 | |
---|
[985a5d1] | 200 | if (ctx.options.enable_lash != False): |
---|
[0318cc1] | 201 | ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0', |
---|
| 202 | args = '--cflags --libs', uselib_store = 'LASH', mandatory = False) |
---|
[000b090] | 203 | |
---|
[ba0ba10] | 204 | if (ctx.options.enable_avcodec != False): |
---|
| 205 | ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0', |
---|
| 206 | args = '--cflags --libs', uselib_store = 'AVCODEC', mandatory = False) |
---|
| 207 | ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0', |
---|
| 208 | args = '--cflags --libs', uselib_store = 'AVFORMAT', mandatory = False) |
---|
| 209 | ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0', |
---|
| 210 | args = '--cflags --libs', uselib_store = 'AVUTIL', mandatory = False) |
---|
| 211 | ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1', |
---|
| 212 | args = '--cflags --libs', uselib_store = 'AVRESAMPLE', mandatory = False) |
---|
| 213 | |
---|
[000b090] | 214 | # write configuration header |
---|
[d41bc4d] | 215 | ctx.write_config_header('src/config.h') |
---|
[000b090] | 216 | |
---|
[110ac90] | 217 | # add some defines used in examples |
---|
[d41bc4d] | 218 | ctx.define('AUBIO_PREFIX', ctx.env['PREFIX']) |
---|
| 219 | ctx.define('PACKAGE', APPNAME) |
---|
[000b090] | 220 | |
---|
| 221 | # check if docbook-to-man is installed, optional |
---|
[110ac90] | 222 | try: |
---|
[d41bc4d] | 223 | ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN') |
---|
| 224 | except ctx.errors.ConfigurationError: |
---|
| 225 | ctx.to_log('docbook-to-man was not found (ignoring)') |
---|
[000b090] | 226 | |
---|
[6ed0f4e] | 227 | def build(bld): |
---|
[985a5d1] | 228 | bld.env['VERSION'] = VERSION |
---|
| 229 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
| 230 | |
---|
| 231 | # add sub directories |
---|
| 232 | bld.recurse('src') |
---|
| 233 | if bld.env['DEST_OS'] not in ['ios', 'iosimulator']: |
---|
| 234 | pass |
---|
| 235 | if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']: |
---|
| 236 | bld.recurse('examples') |
---|
| 237 | bld.recurse('tests') |
---|
| 238 | |
---|
| 239 | bld( source = 'aubio.pc.in' ) |
---|
| 240 | |
---|
| 241 | # build manpages from sgml files |
---|
| 242 | if bld.env['DOCBOOKTOMAN']: |
---|
| 243 | from waflib import TaskGen |
---|
| 244 | if 'MANDIR' not in bld.env: |
---|
| 245 | bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man' |
---|
| 246 | TaskGen.declare_chain( |
---|
| 247 | name = 'docbooktoman', |
---|
| 248 | rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}', |
---|
| 249 | ext_in = '.sgml', |
---|
| 250 | ext_out = '.1', |
---|
| 251 | reentrant = False, |
---|
| 252 | install_path = '${MANDIR}/man1', |
---|
| 253 | ) |
---|
| 254 | bld( source = bld.path.ant_glob('doc/*.sgml') ) |
---|
| 255 | |
---|
| 256 | """ |
---|
| 257 | bld(rule = 'doxygen ${SRC}', source = 'web.cfg') #, target = 'doc/web/index.html') |
---|
| 258 | """ |
---|
[50d56cc] | 259 | |
---|
| 260 | |
---|
[30250de] | 261 | def shutdown(bld): |
---|
[985a5d1] | 262 | from waflib import Logs |
---|
| 263 | if bld.options.target_platform in ['ios', 'iosimulator']: |
---|
| 264 | msg ='building for %s, contact the author for a commercial license' % bld.options.target_platform |
---|
| 265 | Logs.pprint('RED', msg) |
---|
| 266 | msg =' Paul Brossier <piem@aubio.org>' |
---|
| 267 | Logs.pprint('RED', msg) |
---|
[b4d1ba1] | 268 | |
---|
| 269 | def dist(ctx): |
---|
| 270 | ctx.excl = ' **/.waf-1* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git*' |
---|
| 271 | ctx.excl += ' **/build/*' |
---|
[22dd9dc] | 272 | ctx.excl += ' **/python/gen **/python/build **/python/dist' |
---|
| 273 | ctx.excl += ' **/**.zip **/**.tar.bz2' |
---|
[b4d1ba1] | 274 | ctx.excl += ' **/doc/full/*' |
---|
| 275 | ctx.excl += ' **/python/*.db' |
---|
| 276 | ctx.excl += ' **/python.old/*' |
---|