[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, |
---|
| 39 | dest = 'enable_' + name, |
---|
| 40 | help = help_str) |
---|
| 41 | ctx.add_option('--disable-' + name, action = 'store_false', |
---|
| 42 | #default = default, |
---|
| 43 | dest = 'enable_' + name, |
---|
| 44 | help = help_disable_str ) |
---|
| 45 | |
---|
[d41bc4d] | 46 | def options(ctx): |
---|
[3819aca] | 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') |
---|
| 63 | |
---|
[d41bc4d] | 64 | ctx.add_option('--with-target-platform', type='string', |
---|
[5c411dc] | 65 | help='set target platform for cross-compilation', dest='target_platform') |
---|
[d41bc4d] | 66 | ctx.load('compiler_c') |
---|
| 67 | ctx.load('waf_unit_test') |
---|
[000b090] | 68 | |
---|
[d41bc4d] | 69 | def configure(ctx): |
---|
[6ed0f4e] | 70 | from waflib import Options |
---|
| 71 | ctx.load('compiler_c') |
---|
[d41bc4d] | 72 | ctx.load('waf_unit_test') |
---|
[c57ecd9] | 73 | ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra'] |
---|
[000b090] | 74 | |
---|
[5c411dc] | 75 | if Options.options.target_platform: |
---|
| 76 | Options.platform = Options.options.target_platform |
---|
| 77 | |
---|
| 78 | if Options.platform == 'win32': |
---|
[d41bc4d] | 79 | ctx.env['shlib_PATTERN'] = 'lib%s.dll' |
---|
[5c411dc] | 80 | |
---|
[956e113] | 81 | if Options.platform == 'darwin': |
---|
[d6001bf] | 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' |
---|
[54dd945] | 86 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate'] |
---|
| 87 | ctx.define('HAVE_ACCELERATE', 1) |
---|
[d6001bf] | 88 | |
---|
[a1da37f] | 89 | if Options.platform == 'ios': |
---|
| 90 | ctx.env.CC = 'clang' |
---|
| 91 | ctx.env.LD = 'clang' |
---|
| 92 | ctx.env.LINK_CC = 'clang' |
---|
[ff75d60] | 93 | SDKVER="7.0" |
---|
[a1da37f] | 94 | DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer" |
---|
| 95 | SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals() |
---|
[54dd945] | 96 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate'] |
---|
| 97 | ctx.define('HAVE_ACCELERATE', 1) |
---|
[a1da37f] | 98 | ctx.env.CFLAGS += [ '-miphoneos-version-min=6.1', '-arch', 'armv7', |
---|
| 99 | '--sysroot=%s' % SDKROOT] |
---|
| 100 | ctx.env.LINKFLAGS += ['-std=c99', '-arch', 'armv7', '--sysroot=%s' % |
---|
| 101 | SDKROOT] |
---|
| 102 | |
---|
[000b090] | 103 | # check for required headers |
---|
[d41bc4d] | 104 | ctx.check(header_name='stdlib.h') |
---|
| 105 | ctx.check(header_name='stdio.h') |
---|
| 106 | ctx.check(header_name='math.h') |
---|
| 107 | ctx.check(header_name='string.h') |
---|
| 108 | ctx.check(header_name='limits.h') |
---|
[000b090] | 109 | |
---|
[0318cc1] | 110 | # check support for C99 __VA_ARGS__ macros |
---|
| 111 | check_c99_varargs = ''' |
---|
| 112 | #include <stdio.h> |
---|
| 113 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
| 114 | ''' |
---|
| 115 | if ctx.check_cc(fragment = check_c99_varargs, |
---|
| 116 | type='cstlib', |
---|
| 117 | msg = 'Checking for C99 __VA_ARGS__ macro'): |
---|
| 118 | ctx.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
| 119 | |
---|
[000b090] | 120 | # optionally use complex.h |
---|
[62b8ab2] | 121 | if (Options.options.enable_complex == True): |
---|
[d41bc4d] | 122 | ctx.check(header_name='complex.h') |
---|
[000b090] | 123 | |
---|
[2e4fb04] | 124 | # check dependencies |
---|
[0318cc1] | 125 | if (Options.options.enable_sndfile != False): |
---|
| 126 | ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
| 127 | args = '--cflags --libs', mandatory = False) |
---|
| 128 | if (Options.options.enable_samplerate != False): |
---|
[d41bc4d] | 129 | ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
[0318cc1] | 130 | args = '--cflags --libs', mandatory = False) |
---|
[000b090] | 131 | |
---|
[06d30f9] | 132 | # double precision mode |
---|
| 133 | if (Options.options.enable_double == True): |
---|
[d41bc4d] | 134 | ctx.define('HAVE_AUBIO_DOUBLE', 1) |
---|
[06d30f9] | 135 | else: |
---|
[d41bc4d] | 136 | ctx.define('HAVE_AUBIO_DOUBLE', 0) |
---|
[06d30f9] | 137 | |
---|
[36f954a] | 138 | # optional dependancies using pkg-config |
---|
[002563f] | 139 | if (Options.options.enable_fftw3 != False or Options.options.enable_fftw3f != False): |
---|
[0318cc1] | 140 | # one of fftwf or fftw3f |
---|
| 141 | if (Options.options.enable_fftw3f != False): |
---|
| 142 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 143 | args = '--cflags --libs', mandatory = False) |
---|
| 144 | if (Options.options.enable_double == True): |
---|
| 145 | ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!') |
---|
[36f954a] | 146 | else: |
---|
[0318cc1] | 147 | # fftw3f not enabled, take most sensible one according to enable_double |
---|
| 148 | if (Options.options.enable_double == True): |
---|
| 149 | ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
| 150 | args = '--cflags --libs', mandatory = False) |
---|
| 151 | else: |
---|
| 152 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 153 | args = '--cflags --libs', mandatory = False) |
---|
| 154 | ctx.define('HAVE_FFTW3', 1) |
---|
[5dc9f33] | 155 | |
---|
| 156 | # fftw disabled, use ooura |
---|
| 157 | if 'HAVE_FFTW3F' in ctx.env.define_key: |
---|
| 158 | ctx.msg('Checking for FFT implementation', 'fftw3f') |
---|
| 159 | elif 'HAVE_FFTW3' in ctx.env.define_key: |
---|
| 160 | ctx.msg('Checking for FFT implementation', 'fftw3') |
---|
| 161 | elif 'HAVE_ACCELERATE' in ctx.env.define_key: |
---|
| 162 | ctx.msg('Checking for FFT implementation', 'vDSP') |
---|
[0318cc1] | 163 | else: |
---|
[5dc9f33] | 164 | ctx.msg('Checking for FFT implementation', 'ooura') |
---|
[000b090] | 165 | |
---|
[0318cc1] | 166 | if (Options.options.enable_jack != False): |
---|
| 167 | ctx.check_cfg(package = 'jack', atleast_version = '0.15.0', |
---|
| 168 | args = '--cflags --libs', mandatory = False) |
---|
| 169 | |
---|
| 170 | if (Options.options.enable_lash != False): |
---|
| 171 | ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0', |
---|
| 172 | args = '--cflags --libs', uselib_store = 'LASH', mandatory = False) |
---|
[000b090] | 173 | |
---|
| 174 | # write configuration header |
---|
[d41bc4d] | 175 | ctx.write_config_header('src/config.h') |
---|
[000b090] | 176 | |
---|
[110ac90] | 177 | # add some defines used in examples |
---|
[d41bc4d] | 178 | ctx.define('AUBIO_PREFIX', ctx.env['PREFIX']) |
---|
| 179 | ctx.define('PACKAGE', APPNAME) |
---|
[000b090] | 180 | |
---|
| 181 | # check if docbook-to-man is installed, optional |
---|
[110ac90] | 182 | try: |
---|
[d41bc4d] | 183 | ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN') |
---|
| 184 | except ctx.errors.ConfigurationError: |
---|
| 185 | ctx.to_log('docbook-to-man was not found (ignoring)') |
---|
[000b090] | 186 | |
---|
[6ed0f4e] | 187 | def build(bld): |
---|
| 188 | bld.env['VERSION'] = VERSION |
---|
| 189 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
[000b090] | 190 | |
---|
| 191 | # add sub directories |
---|
[81fe3273] | 192 | bld.recurse('src') |
---|
[a1da37f] | 193 | from waflib import Options |
---|
[81fe3273] | 194 | if Options.platform != 'ios': |
---|
| 195 | bld.recurse('examples') |
---|
| 196 | bld.recurse('tests') |
---|
[000b090] | 197 | |
---|
[6ed0f4e] | 198 | """ |
---|
[65860ff] | 199 | # install woodblock sound |
---|
| 200 | bld.install_files('${PREFIX}/share/sounds/aubio/', |
---|
| 201 | 'sounds/woodblock.aiff') |
---|
| 202 | """ |
---|
| 203 | |
---|
[e57859f] | 204 | bld( source = 'aubio.pc.in' ) |
---|
| 205 | |
---|
[000b090] | 206 | # build manpages from sgml files |
---|
[65860ff] | 207 | if bld.env['DOCBOOKTOMAN']: |
---|
| 208 | from waflib import TaskGen |
---|
[733aea2] | 209 | if 'MANDIR' not in bld.env: |
---|
| 210 | bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man' |
---|
[000b090] | 211 | TaskGen.declare_chain( |
---|
[733aea2] | 212 | name = 'docbooktoman', |
---|
| 213 | rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}', |
---|
| 214 | ext_in = '.sgml', |
---|
| 215 | ext_out = '.1', |
---|
| 216 | reentrant = False, |
---|
| 217 | install_path = '${MANDIR}/man1', |
---|
[000b090] | 218 | ) |
---|
[733aea2] | 219 | bld( source = bld.path.ant_glob('doc/*.sgml') ) |
---|
[30250de] | 220 | |
---|
[50d56cc] | 221 | """ |
---|
| 222 | bld(rule = 'doxygen ${SRC}', source = 'web.cfg') #, target = 'doc/web/index.html') |
---|
| 223 | """ |
---|
| 224 | |
---|
| 225 | |
---|
[30250de] | 226 | def shutdown(bld): |
---|
| 227 | from waflib import Options, Logs |
---|
| 228 | if Options.platform == 'ios': |
---|
| 229 | msg ='aubio built for ios, contact the author for a commercial license' |
---|
| 230 | Logs.pprint('RED', msg) |
---|
| 231 | msg =' Paul Brossier <piem@aubio.org>' |
---|
| 232 | Logs.pprint('RED', msg) |
---|