[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' |
---|
[551c6c3] | 72 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox'] |
---|
[d6001bf] | 73 | |
---|
[a1da37f] | 74 | if Options.platform == 'ios': |
---|
| 75 | ctx.env.CC = 'clang' |
---|
| 76 | ctx.env.LD = 'clang' |
---|
| 77 | ctx.env.LINK_CC = 'clang' |
---|
| 78 | SDKVER="6.1" |
---|
| 79 | DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer" |
---|
| 80 | SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals() |
---|
| 81 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox'] |
---|
| 82 | ctx.env.CFLAGS += [ '-miphoneos-version-min=6.1', '-arch', 'armv7', |
---|
| 83 | '--sysroot=%s' % SDKROOT] |
---|
| 84 | ctx.env.LINKFLAGS += ['-std=c99', '-arch', 'armv7', '--sysroot=%s' % |
---|
| 85 | SDKROOT] |
---|
| 86 | |
---|
[000b090] | 87 | # check for required headers |
---|
[d41bc4d] | 88 | ctx.check(header_name='stdlib.h') |
---|
| 89 | ctx.check(header_name='stdio.h') |
---|
| 90 | ctx.check(header_name='math.h') |
---|
| 91 | ctx.check(header_name='string.h') |
---|
| 92 | ctx.check(header_name='limits.h') |
---|
[000b090] | 93 | |
---|
[0318cc1] | 94 | # check support for C99 __VA_ARGS__ macros |
---|
| 95 | check_c99_varargs = ''' |
---|
| 96 | #include <stdio.h> |
---|
| 97 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
| 98 | ''' |
---|
| 99 | if ctx.check_cc(fragment = check_c99_varargs, |
---|
| 100 | type='cstlib', |
---|
| 101 | msg = 'Checking for C99 __VA_ARGS__ macro'): |
---|
| 102 | ctx.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
| 103 | |
---|
[000b090] | 104 | # optionally use complex.h |
---|
[62b8ab2] | 105 | if (Options.options.enable_complex == True): |
---|
[d41bc4d] | 106 | ctx.check(header_name='complex.h') |
---|
[000b090] | 107 | |
---|
[2e4fb04] | 108 | # check dependencies |
---|
[0318cc1] | 109 | if (Options.options.enable_sndfile != False): |
---|
| 110 | ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
| 111 | args = '--cflags --libs', mandatory = False) |
---|
| 112 | if (Options.options.enable_samplerate != False): |
---|
[d41bc4d] | 113 | ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
[0318cc1] | 114 | args = '--cflags --libs', mandatory = False) |
---|
[000b090] | 115 | |
---|
[06d30f9] | 116 | # double precision mode |
---|
| 117 | if (Options.options.enable_double == True): |
---|
[d41bc4d] | 118 | ctx.define('HAVE_AUBIO_DOUBLE', 1) |
---|
[06d30f9] | 119 | else: |
---|
[d41bc4d] | 120 | ctx.define('HAVE_AUBIO_DOUBLE', 0) |
---|
[06d30f9] | 121 | |
---|
[36f954a] | 122 | # optional dependancies using pkg-config |
---|
[002563f] | 123 | if (Options.options.enable_fftw3 != False or Options.options.enable_fftw3f != False): |
---|
[0318cc1] | 124 | # one of fftwf or fftw3f |
---|
| 125 | if (Options.options.enable_fftw3f != False): |
---|
| 126 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 127 | args = '--cflags --libs', mandatory = False) |
---|
| 128 | if (Options.options.enable_double == True): |
---|
| 129 | ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!') |
---|
[36f954a] | 130 | else: |
---|
[0318cc1] | 131 | # fftw3f not enabled, take most sensible one according to enable_double |
---|
| 132 | if (Options.options.enable_double == True): |
---|
| 133 | ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
| 134 | args = '--cflags --libs', mandatory = False) |
---|
| 135 | else: |
---|
| 136 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 137 | args = '--cflags --libs', mandatory = False) |
---|
| 138 | ctx.define('HAVE_FFTW3', 1) |
---|
| 139 | else: |
---|
| 140 | # fftw disabled, use ooura |
---|
| 141 | ctx.msg('Checking for FFT implementation', 'ooura') |
---|
| 142 | pass |
---|
[000b090] | 143 | |
---|
[0318cc1] | 144 | if (Options.options.enable_jack != False): |
---|
| 145 | ctx.check_cfg(package = 'jack', atleast_version = '0.15.0', |
---|
| 146 | args = '--cflags --libs', mandatory = False) |
---|
| 147 | |
---|
| 148 | if (Options.options.enable_lash != False): |
---|
| 149 | ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0', |
---|
| 150 | args = '--cflags --libs', uselib_store = 'LASH', mandatory = False) |
---|
[000b090] | 151 | |
---|
| 152 | # write configuration header |
---|
[d41bc4d] | 153 | ctx.write_config_header('src/config.h') |
---|
[000b090] | 154 | |
---|
[110ac90] | 155 | # add some defines used in examples |
---|
[d41bc4d] | 156 | ctx.define('AUBIO_PREFIX', ctx.env['PREFIX']) |
---|
| 157 | ctx.define('PACKAGE', APPNAME) |
---|
[000b090] | 158 | |
---|
| 159 | # check if docbook-to-man is installed, optional |
---|
[110ac90] | 160 | try: |
---|
[d41bc4d] | 161 | ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN') |
---|
| 162 | except ctx.errors.ConfigurationError: |
---|
| 163 | ctx.to_log('docbook-to-man was not found (ignoring)') |
---|
[000b090] | 164 | |
---|
[6ed0f4e] | 165 | def build(bld): |
---|
| 166 | bld.env['VERSION'] = VERSION |
---|
| 167 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
[000b090] | 168 | |
---|
| 169 | # add sub directories |
---|
[81fe3273] | 170 | bld.recurse('src') |
---|
[a1da37f] | 171 | from waflib import Options |
---|
[81fe3273] | 172 | if Options.platform != 'ios': |
---|
| 173 | bld.recurse('examples') |
---|
| 174 | bld.recurse('tests') |
---|
[000b090] | 175 | |
---|
[6ed0f4e] | 176 | """ |
---|
[000b090] | 177 | # create the aubio.pc file for pkg-config |
---|
[d41bc4d] | 178 | if ctx.env['TARGET_PLATFORM'] == 'linux': |
---|
| 179 | aubiopc = ctx.new_task_gen('subst') |
---|
[110ac90] | 180 | aubiopc.source = 'aubio.pc.in' |
---|
| 181 | aubiopc.target = 'aubio.pc' |
---|
| 182 | aubiopc.install_path = '${PREFIX}/lib/pkgconfig' |
---|
[000b090] | 183 | |
---|
| 184 | # build manpages from sgml files |
---|
[d41bc4d] | 185 | if ctx.env['DOCBOOKTOMAN']: |
---|
[000b090] | 186 | import TaskGen |
---|
| 187 | TaskGen.declare_chain( |
---|
| 188 | name = 'docbooktoman', |
---|
| 189 | rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}', |
---|
| 190 | ext_in = '.sgml', |
---|
| 191 | ext_out = '.1', |
---|
| 192 | reentrant = 0, |
---|
| 193 | ) |
---|
[d41bc4d] | 194 | manpages = ctx.new_task_gen(name = 'docbooktoman', |
---|
| 195 | source=ctx.path.ant_glob('doc/*.sgml')) |
---|
| 196 | ctx.install_files('${MANDIR}/man1', ctx.path.ant_glob('doc/*.1')) |
---|
[000b090] | 197 | |
---|
| 198 | # install woodblock sound |
---|
[6ed0f4e] | 199 | bld.install_files('${PREFIX}/share/sounds/aubio/', |
---|
[000b090] | 200 | 'sounds/woodblock.aiff') |
---|
[6ed0f4e] | 201 | """ |
---|
[30250de] | 202 | |
---|
| 203 | def shutdown(bld): |
---|
| 204 | from waflib import Options, Logs |
---|
| 205 | if Options.platform == 'ios': |
---|
| 206 | msg ='aubio built for ios, contact the author for a commercial license' |
---|
| 207 | Logs.pprint('RED', msg) |
---|
| 208 | msg =' Paul Brossier <piem@aubio.org>' |
---|
| 209 | Logs.pprint('RED', msg) |
---|