[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') |
---|
[d41bc4d] | 36 | ctx.add_option('--enable-fftw', action='store_true', default=False, |
---|
[729a3c0] | 37 | help='compile with ooura instead of fftw') |
---|
[d41bc4d] | 38 | ctx.add_option('--enable-fftw3f', action='store_true', default=False, |
---|
[000b090] | 39 | help='compile with fftw3 instead of fftw3f') |
---|
[d41bc4d] | 40 | ctx.add_option('--enable-complex', action='store_true', default=False, |
---|
[62b8ab2] | 41 | help='compile with C99 complex') |
---|
[d41bc4d] | 42 | ctx.add_option('--enable-jack', action='store_true', default=False, |
---|
[2a6e672] | 43 | help='compile with jack support') |
---|
[d41bc4d] | 44 | ctx.add_option('--enable-lash', action='store_true', default=False, |
---|
[2a6e672] | 45 | help='compile with lash support') |
---|
[d41bc4d] | 46 | ctx.add_option('--enable-sndfile', action='store_true', default=False, |
---|
[110ac90] | 47 | help='compile with libsndfile support') |
---|
[d41bc4d] | 48 | ctx.add_option('--enable-samplerate', action='store_true', default=False, |
---|
[2a6e672] | 49 | help='compile with libsamplerate support') |
---|
[d41bc4d] | 50 | ctx.add_option('--enable-swig', action='store_true', default=False, |
---|
[dda6ba6] | 51 | help='compile with swig support (obsolete)') |
---|
[d41bc4d] | 52 | ctx.add_option('--with-target-platform', type='string', |
---|
[5c411dc] | 53 | help='set target platform for cross-compilation', dest='target_platform') |
---|
[d41bc4d] | 54 | ctx.load('compiler_c') |
---|
| 55 | ctx.load('waf_unit_test') |
---|
[000b090] | 56 | |
---|
[d41bc4d] | 57 | def configure(ctx): |
---|
[6ed0f4e] | 58 | from waflib import Options |
---|
| 59 | ctx.load('compiler_c') |
---|
[d41bc4d] | 60 | ctx.load('waf_unit_test') |
---|
[c57ecd9] | 61 | ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra'] |
---|
[000b090] | 62 | |
---|
[5c411dc] | 63 | if Options.options.target_platform: |
---|
| 64 | Options.platform = Options.options.target_platform |
---|
| 65 | |
---|
| 66 | if Options.platform == 'win32': |
---|
[d41bc4d] | 67 | ctx.env['shlib_PATTERN'] = 'lib%s.dll' |
---|
[5c411dc] | 68 | |
---|
[956e113] | 69 | if Options.platform == 'darwin': |
---|
[d6001bf] | 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' |
---|
[551c6c3] | 74 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox'] |
---|
[d6001bf] | 75 | |
---|
[a1da37f] | 76 | if Options.platform == 'ios': |
---|
| 77 | ctx.env.CC = 'clang' |
---|
| 78 | ctx.env.LD = 'clang' |
---|
| 79 | ctx.env.LINK_CC = 'clang' |
---|
| 80 | SDKVER="6.1" |
---|
| 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' % |
---|
| 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 | |
---|
| 96 | # optionally use complex.h |
---|
[62b8ab2] | 97 | if (Options.options.enable_complex == True): |
---|
[d41bc4d] | 98 | ctx.check(header_name='complex.h') |
---|
[000b090] | 99 | |
---|
[2e4fb04] | 100 | # check dependencies |
---|
[110ac90] | 101 | if (Options.options.enable_sndfile == True): |
---|
[d41bc4d] | 102 | ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
[110ac90] | 103 | args = '--cflags --libs') |
---|
[82335b7] | 104 | if (Options.options.enable_samplerate == True): |
---|
[d41bc4d] | 105 | ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
[2e4fb04] | 106 | args = '--cflags --libs') |
---|
[000b090] | 107 | |
---|
[06d30f9] | 108 | # double precision mode |
---|
| 109 | if (Options.options.enable_double == True): |
---|
[d41bc4d] | 110 | ctx.define('HAVE_AUBIO_DOUBLE', 1) |
---|
[06d30f9] | 111 | else: |
---|
[d41bc4d] | 112 | ctx.define('HAVE_AUBIO_DOUBLE', 0) |
---|
[06d30f9] | 113 | |
---|
[110ac90] | 114 | # check if pkg-config is installed, optional |
---|
| 115 | try: |
---|
[d41bc4d] | 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') |
---|
[110ac90] | 120 | |
---|
[36f954a] | 121 | # optional dependancies using pkg-config |
---|
[d41bc4d] | 122 | if ctx.env['PKGCONFIG']: |
---|
[36f954a] | 123 | |
---|
[dda6ba6] | 124 | if (Options.options.enable_fftw == True or Options.options.enable_fftw3f == True): |
---|
[36f954a] | 125 | # one of fftwf or fftw3f |
---|
[dda6ba6] | 126 | if (Options.options.enable_fftw3f == True): |
---|
[d41bc4d] | 127 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
[729a3c0] | 128 | args = '--cflags --libs') |
---|
[dda6ba6] | 129 | if (Options.options.enable_double == True): |
---|
[d41bc4d] | 130 | ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!') |
---|
[729a3c0] | 131 | else: |
---|
[dda6ba6] | 132 | # fftw3f not enabled, take most sensible one according to enable_double |
---|
[36f954a] | 133 | if (Options.options.enable_double == True): |
---|
[d41bc4d] | 134 | ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
[36f954a] | 135 | args = '--cflags --libs') |
---|
| 136 | else: |
---|
[d41bc4d] | 137 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
[36f954a] | 138 | args = '--cflags --libs') |
---|
[d41bc4d] | 139 | ctx.define('HAVE_FFTW3', 1) |
---|
[36f954a] | 140 | else: |
---|
| 141 | # fftw disabled, use ooura |
---|
[c325a11] | 142 | ctx.msg('Checking for FFT implementation', 'ooura') |
---|
[36f954a] | 143 | pass |
---|
| 144 | |
---|
| 145 | if (Options.options.enable_jack == True): |
---|
[d41bc4d] | 146 | ctx.check_cfg(package = 'jack', atleast_version = '0.15.0', |
---|
[36f954a] | 147 | args = '--cflags --libs') |
---|
| 148 | |
---|
| 149 | if (Options.options.enable_lash == True): |
---|
[d41bc4d] | 150 | ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0', |
---|
[36f954a] | 151 | args = '--cflags --libs', uselib_store = 'LASH') |
---|
[000b090] | 152 | |
---|
| 153 | # swig |
---|
[dda6ba6] | 154 | if (Options.options.enable_swig == True): |
---|
| 155 | try: |
---|
[d41bc4d] | 156 | ctx.find_program('swig', var='SWIG') |
---|
| 157 | except ctx.errors.ConfigurationError: |
---|
| 158 | ctx.to_log('swig was not found, not looking for (ignoring)') |
---|
[dda6ba6] | 159 | |
---|
[d41bc4d] | 160 | if ctx.env['SWIG']: |
---|
| 161 | ctx.check_tool('swig') |
---|
| 162 | ctx.check_swig_version() |
---|
[dda6ba6] | 163 | |
---|
| 164 | # python |
---|
[d41bc4d] | 165 | if ctx.find_program('python'): |
---|
| 166 | ctx.check_tool('python') |
---|
| 167 | ctx.check_python_version((2,4,2)) |
---|
| 168 | ctx.check_python_headers() |
---|
[000b090] | 169 | |
---|
| 170 | # check support for C99 __VA_ARGS__ macros |
---|
| 171 | check_c99_varargs = ''' |
---|
| 172 | #include <stdio.h> |
---|
| 173 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
| 174 | ''' |
---|
[d41bc4d] | 175 | if ctx.check_cc(fragment = check_c99_varargs, |
---|
[46378b3] | 176 | type='cstlib', |
---|
[000b090] | 177 | msg = 'Checking for C99 __VA_ARGS__ macro'): |
---|
[d41bc4d] | 178 | ctx.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
[000b090] | 179 | |
---|
| 180 | # write configuration header |
---|
[d41bc4d] | 181 | ctx.write_config_header('src/config.h') |
---|
[000b090] | 182 | |
---|
[110ac90] | 183 | # add some defines used in examples |
---|
[d41bc4d] | 184 | ctx.define('AUBIO_PREFIX', ctx.env['PREFIX']) |
---|
| 185 | ctx.define('PACKAGE', APPNAME) |
---|
[000b090] | 186 | |
---|
| 187 | # check if docbook-to-man is installed, optional |
---|
[110ac90] | 188 | try: |
---|
[d41bc4d] | 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)') |
---|
[000b090] | 192 | |
---|
[6ed0f4e] | 193 | def build(bld): |
---|
| 194 | bld.env['VERSION'] = VERSION |
---|
| 195 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
[000b090] | 196 | |
---|
| 197 | # add sub directories |
---|
[a1da37f] | 198 | bld.recurse('src examples') |
---|
| 199 | from waflib import Options |
---|
| 200 | import sys |
---|
| 201 | if Options.platform == sys.platform: bld.recurse('tests') |
---|
[000b090] | 202 | |
---|
[6ed0f4e] | 203 | """ |
---|
[000b090] | 204 | # create the aubio.pc file for pkg-config |
---|
[d41bc4d] | 205 | if ctx.env['TARGET_PLATFORM'] == 'linux': |
---|
| 206 | aubiopc = ctx.new_task_gen('subst') |
---|
[110ac90] | 207 | aubiopc.source = 'aubio.pc.in' |
---|
| 208 | aubiopc.target = 'aubio.pc' |
---|
| 209 | aubiopc.install_path = '${PREFIX}/lib/pkgconfig' |
---|
[000b090] | 210 | |
---|
| 211 | # build manpages from sgml files |
---|
[d41bc4d] | 212 | if ctx.env['DOCBOOKTOMAN']: |
---|
[000b090] | 213 | import TaskGen |
---|
| 214 | TaskGen.declare_chain( |
---|
| 215 | name = 'docbooktoman', |
---|
| 216 | rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}', |
---|
| 217 | ext_in = '.sgml', |
---|
| 218 | ext_out = '.1', |
---|
| 219 | reentrant = 0, |
---|
| 220 | ) |
---|
[d41bc4d] | 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')) |
---|
[000b090] | 224 | |
---|
| 225 | # install woodblock sound |
---|
[6ed0f4e] | 226 | bld.install_files('${PREFIX}/share/sounds/aubio/', |
---|
[000b090] | 227 | 'sounds/woodblock.aiff') |
---|
[6ed0f4e] | 228 | """ |
---|