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