[5c411dc] | 1 | #! /usr/bin/python |
---|
[110ac90] | 2 | # |
---|
[21ee709] | 3 | # usage: |
---|
[46b00690] | 4 | # $ python waf --help |
---|
| 5 | # |
---|
| 6 | # example: |
---|
| 7 | # $ ./waf distclean configure build |
---|
[21ee709] | 8 | # |
---|
[46b00690] | 9 | # Note: aubio uses the waf build system, which relies on Python. Provided you |
---|
| 10 | # have Python installed, you do *not* need to install anything to build aubio. |
---|
| 11 | # For more info about waf, see http://code.google.com/p/waf/ . |
---|
[000b090] | 12 | |
---|
| 13 | APPNAME = 'aubio' |
---|
[5820107] | 14 | |
---|
[6b14351] | 15 | # source VERSION |
---|
[5820107] | 16 | for l in open('VERSION').readlines(): exec (l.strip()) |
---|
| 17 | |
---|
[6b14351] | 18 | VERSION = '.'.join ([str(x) for x in [ |
---|
| 19 | AUBIO_MAJOR_VERSION, |
---|
| 20 | AUBIO_MINOR_VERSION, |
---|
| 21 | AUBIO_PATCH_VERSION |
---|
| 22 | ]]) + AUBIO_VERSION_STATUS |
---|
[e565c649] | 23 | |
---|
[6b14351] | 24 | LIB_VERSION = '.'.join ([str(x) for x in [ |
---|
| 25 | LIBAUBIO_LT_CUR, |
---|
| 26 | LIBAUBIO_LT_REV, |
---|
| 27 | LIBAUBIO_LT_AGE]]) |
---|
[e565c649] | 28 | |
---|
[46378b3] | 29 | top = '.' |
---|
| 30 | out = 'build' |
---|
[000b090] | 31 | |
---|
[6b14351] | 32 | def add_option_enable_disable(ctx, name, default = None, |
---|
| 33 | help_str = None, help_disable_str = None): |
---|
[a93dab3] | 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', |
---|
| 39 | default = default, |
---|
| 40 | dest = 'enable_' + name.replace('-','_'), |
---|
| 41 | help = help_str) |
---|
| 42 | ctx.add_option('--disable-' + name, action = 'store_false', |
---|
| 43 | #default = default, |
---|
| 44 | dest = 'enable_' + name.replace('-','_'), |
---|
| 45 | help = help_disable_str ) |
---|
[3819aca] | 46 | |
---|
[d41bc4d] | 47 | def options(ctx): |
---|
[a93dab3] | 48 | add_option_enable_disable(ctx, 'fftw3f', default = False, |
---|
| 49 | help_str = 'compile with fftw3f instead of ooura (recommended)', |
---|
| 50 | 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', |
---|
| 53 | help_disable_str = 'do not compile with fftw3') |
---|
| 54 | add_option_enable_disable(ctx, 'complex', default = False, |
---|
| 55 | help_str ='compile with C99 complex', |
---|
| 56 | help_disable_str = 'do not use C99 complex (default)' ) |
---|
| 57 | add_option_enable_disable(ctx, 'jack', default = None, |
---|
| 58 | help_str = 'compile with jack (auto)', |
---|
| 59 | help_disable_str = 'disable jack support') |
---|
| 60 | add_option_enable_disable(ctx, 'sndfile', default = None, |
---|
| 61 | help_str = 'compile with sndfile (auto)', |
---|
| 62 | help_disable_str = 'disable sndfile') |
---|
| 63 | add_option_enable_disable(ctx, 'avcodec', default = None, |
---|
| 64 | help_str = 'compile with libavcodec (auto)', |
---|
| 65 | help_disable_str = 'disable libavcodec') |
---|
| 66 | add_option_enable_disable(ctx, 'samplerate', default = None, |
---|
| 67 | help_str = 'compile with samplerate (auto)', |
---|
| 68 | help_disable_str = 'disable samplerate') |
---|
| 69 | add_option_enable_disable(ctx, 'memcpy', default = True, |
---|
| 70 | help_str = 'use memcpy hacks (default)', |
---|
| 71 | help_disable_str = 'do not use memcpy hacks') |
---|
| 72 | add_option_enable_disable(ctx, 'double', default = False, |
---|
| 73 | help_str = 'compile in double precision mode', |
---|
| 74 | help_disable_str = 'compile in single precision mode (default)') |
---|
[a3de4be] | 75 | add_option_enable_disable(ctx, 'fat', default = False, |
---|
| 76 | help_str = 'build fat binaries (darwin only)', |
---|
| 77 | help_disable_str = 'do not build fat binaries (default)') |
---|
[a93dab3] | 78 | |
---|
| 79 | ctx.add_option('--with-target-platform', type='string', |
---|
| 80 | help='set target platform for cross-compilation', dest='target_platform') |
---|
| 81 | |
---|
| 82 | ctx.load('compiler_c') |
---|
| 83 | ctx.load('waf_unit_test') |
---|
| 84 | ctx.load('gnu_dirs') |
---|
[000b090] | 85 | |
---|
[d41bc4d] | 86 | def configure(ctx): |
---|
[a93dab3] | 87 | from waflib import Options |
---|
| 88 | ctx.load('compiler_c') |
---|
| 89 | ctx.load('waf_unit_test') |
---|
| 90 | ctx.load('gnu_dirs') |
---|
[06dba46] | 91 | |
---|
[a93dab3] | 92 | target_platform = Options.platform |
---|
| 93 | if ctx.options.target_platform: |
---|
| 94 | target_platform = ctx.options.target_platform |
---|
| 95 | ctx.env['DEST_OS'] = target_platform |
---|
| 96 | |
---|
[a341685] | 97 | if 'CL.exe' not in ctx.env.CC[0]: |
---|
| 98 | ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra'] |
---|
| 99 | else: |
---|
| 100 | ctx.env.CFLAGS += ['-Wall'] |
---|
| 101 | |
---|
[06dba46] | 102 | if target_platform not in ['win32', 'win64']: |
---|
| 103 | ctx.env.CFLAGS += ['-fPIC'] |
---|
| 104 | else: |
---|
| 105 | ctx.define('HAVE_WIN_HACKS', 1) |
---|
| 106 | ctx.env['cshlib_PATTERN'] = 'lib%s.dll' |
---|
[a93dab3] | 107 | |
---|
[a3de4be] | 108 | if target_platform == 'darwin' and ctx.options.enable_fat: |
---|
[a93dab3] | 109 | ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
| 110 | ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
[9209c79] | 111 | |
---|
| 112 | if target_platform in [ 'darwin', 'ios', 'iosimulator']: |
---|
[a93dab3] | 113 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate'] |
---|
[9209c79] | 114 | ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1) |
---|
| 115 | ctx.define('HAVE_SINK_APPLE_AUDIO', 1) |
---|
[a93dab3] | 116 | ctx.define('HAVE_ACCELERATE', 1) |
---|
| 117 | |
---|
| 118 | if target_platform in [ 'ios', 'iosimulator' ]: |
---|
| 119 | ctx.define('TARGET_OS_IPHONE', 1) |
---|
| 120 | MINSDKVER="6.1" |
---|
| 121 | ctx.env.CFLAGS += ['-std=c99'] |
---|
| 122 | if target_platform == 'ios': |
---|
| 123 | DEVROOT = "/Applications/Xcode.app/Contents" |
---|
| 124 | DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer" |
---|
[e11ce489] | 125 | SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS.sdk" % locals() |
---|
[7aa4aaa] | 126 | ctx.env.CFLAGS += [ '-arch', 'arm64' ] |
---|
[a93dab3] | 127 | ctx.env.CFLAGS += [ '-arch', 'armv7' ] |
---|
| 128 | ctx.env.CFLAGS += [ '-arch', 'armv7s' ] |
---|
[7aa4aaa] | 129 | ctx.env.LINKFLAGS += [ '-arch', 'arm64' ] |
---|
[a93dab3] | 130 | ctx.env.LINKFLAGS += ['-arch', 'armv7'] |
---|
| 131 | ctx.env.LINKFLAGS += ['-arch', 'armv7s'] |
---|
| 132 | ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
| 133 | ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
| 134 | else: |
---|
| 135 | DEVROOT = "/Applications/Xcode.app/Contents" |
---|
| 136 | DEVROOT += "/Developer/Platforms/iPhoneSimulator.platform/Developer" |
---|
[e11ce489] | 137 | SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator.sdk" % locals() |
---|
[a93dab3] | 138 | ctx.env.CFLAGS += [ '-arch', 'i386' ] |
---|
| 139 | ctx.env.CFLAGS += [ '-arch', 'x86_64' ] |
---|
| 140 | ctx.env.LINKFLAGS += ['-arch', 'i386'] |
---|
| 141 | ctx.env.LINKFLAGS += ['-arch', 'x86_64'] |
---|
| 142 | ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
| 143 | ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
| 144 | ctx.env.CFLAGS += [ '-isysroot' , SDKROOT] |
---|
| 145 | ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT] |
---|
| 146 | |
---|
| 147 | # check for required headers |
---|
| 148 | ctx.check(header_name='stdlib.h') |
---|
| 149 | ctx.check(header_name='stdio.h') |
---|
| 150 | ctx.check(header_name='math.h') |
---|
| 151 | ctx.check(header_name='string.h') |
---|
| 152 | ctx.check(header_name='limits.h') |
---|
| 153 | |
---|
| 154 | # check support for C99 __VA_ARGS__ macros |
---|
| 155 | check_c99_varargs = ''' |
---|
[0318cc1] | 156 | #include <stdio.h> |
---|
| 157 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
| 158 | ''' |
---|
[a93dab3] | 159 | |
---|
| 160 | if ctx.check_cc(fragment = check_c99_varargs, |
---|
| 161 | type='cstlib', |
---|
[413d4bf] | 162 | msg = 'Checking for C99 __VA_ARGS__ macro', |
---|
| 163 | mandatory = False): |
---|
[a93dab3] | 164 | ctx.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
| 165 | |
---|
| 166 | # double precision mode |
---|
| 167 | if (ctx.options.enable_double == True): |
---|
| 168 | ctx.define('HAVE_AUBIO_DOUBLE', 1) |
---|
| 169 | else: |
---|
| 170 | ctx.define('HAVE_AUBIO_DOUBLE', 0) |
---|
| 171 | |
---|
| 172 | # optionally use complex.h |
---|
| 173 | if (ctx.options.enable_complex == True): |
---|
| 174 | ctx.check(header_name='complex.h') |
---|
| 175 | |
---|
| 176 | # check for fftw3 |
---|
| 177 | if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False): |
---|
| 178 | # one of fftwf or fftw3f |
---|
| 179 | if (ctx.options.enable_fftw3f != False): |
---|
| 180 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 181 | args = '--cflags --libs', mandatory = False) |
---|
| 182 | if (ctx.options.enable_double == True): |
---|
| 183 | ctx.msg('Warning', 'fftw3f enabled, but compiling in double precision!') |
---|
| 184 | else: |
---|
| 185 | # fftw3f not enabled, take most sensible one according to enable_double |
---|
| 186 | if (ctx.options.enable_double == True): |
---|
| 187 | ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
| 188 | args = '--cflags --libs', mandatory = False) |
---|
| 189 | else: |
---|
| 190 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 191 | args = '--cflags --libs', mandatory = False) |
---|
| 192 | ctx.define('HAVE_FFTW3', 1) |
---|
| 193 | |
---|
| 194 | # fftw not enabled, use vDSP or ooura |
---|
| 195 | if 'HAVE_FFTW3F' in ctx.env.define_key: |
---|
| 196 | ctx.msg('Checking for FFT implementation', 'fftw3f') |
---|
| 197 | elif 'HAVE_FFTW3' in ctx.env.define_key: |
---|
| 198 | ctx.msg('Checking for FFT implementation', 'fftw3') |
---|
| 199 | elif 'HAVE_ACCELERATE' in ctx.env.define_key: |
---|
| 200 | ctx.msg('Checking for FFT implementation', 'vDSP') |
---|
[36f954a] | 201 | else: |
---|
[a93dab3] | 202 | ctx.msg('Checking for FFT implementation', 'ooura') |
---|
| 203 | |
---|
| 204 | # check for libsndfile |
---|
| 205 | if (ctx.options.enable_sndfile != False): |
---|
| 206 | ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
| 207 | args = '--cflags --libs', mandatory = False) |
---|
| 208 | |
---|
| 209 | # check for libsamplerate |
---|
| 210 | if (ctx.options.enable_samplerate != False): |
---|
| 211 | ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
| 212 | args = '--cflags --libs', mandatory = False) |
---|
| 213 | |
---|
| 214 | # check for jack |
---|
| 215 | if (ctx.options.enable_jack != False): |
---|
[eb99982] | 216 | ctx.check_cfg(package = 'jack', |
---|
[a93dab3] | 217 | args = '--cflags --libs', mandatory = False) |
---|
| 218 | |
---|
| 219 | # check for libav |
---|
| 220 | if (ctx.options.enable_avcodec != False): |
---|
| 221 | ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0', |
---|
| 222 | args = '--cflags --libs', uselib_store = 'AVCODEC', mandatory = False) |
---|
| 223 | ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0', |
---|
| 224 | args = '--cflags --libs', uselib_store = 'AVFORMAT', mandatory = False) |
---|
| 225 | ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0', |
---|
| 226 | args = '--cflags --libs', uselib_store = 'AVUTIL', mandatory = False) |
---|
| 227 | ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1', |
---|
| 228 | args = '--cflags --libs', uselib_store = 'AVRESAMPLE', mandatory = False) |
---|
[549928e] | 229 | if all ( 'HAVE_' + i in ctx.env.define_key |
---|
| 230 | for i in ['AVCODEC', 'AVFORMAT', 'AVUTIL', 'AVRESAMPLE'] ): |
---|
| 231 | ctx.define('HAVE_LIBAV', 1) |
---|
| 232 | ctx.msg('Checking for all libav libraries', 'yes') |
---|
| 233 | else: |
---|
| 234 | ctx.msg('Checking for all libav libraries', 'not found', color = 'YELLOW') |
---|
[a93dab3] | 235 | |
---|
[5158c22] | 236 | ctx.define('HAVE_WAVREAD', 1) |
---|
[52ca8a3] | 237 | ctx.define('HAVE_WAVWRITE', 1) |
---|
[5158c22] | 238 | |
---|
[a93dab3] | 239 | # use memcpy hacks |
---|
| 240 | if (ctx.options.enable_memcpy == True): |
---|
| 241 | ctx.define('HAVE_MEMCPY_HACKS', 1) |
---|
| 242 | else: |
---|
| 243 | ctx.define('HAVE_MEMCPY_HACKS', 0) |
---|
| 244 | |
---|
| 245 | # write configuration header |
---|
| 246 | ctx.write_config_header('src/config.h') |
---|
| 247 | |
---|
| 248 | # add some defines used in examples |
---|
| 249 | ctx.define('AUBIO_PREFIX', ctx.env['PREFIX']) |
---|
| 250 | ctx.define('PACKAGE', APPNAME) |
---|
| 251 | |
---|
| 252 | # check if txt2man is installed, optional |
---|
| 253 | try: |
---|
| 254 | ctx.find_program('txt2man', var='TXT2MAN') |
---|
| 255 | except ctx.errors.ConfigurationError: |
---|
| 256 | ctx.to_log('txt2man was not found (ignoring)') |
---|
[000b090] | 257 | |
---|
[52a25e5] | 258 | # check if doxygen is installed, optional |
---|
| 259 | try: |
---|
| 260 | ctx.find_program('doxygen', var='DOXYGEN') |
---|
| 261 | except ctx.errors.ConfigurationError: |
---|
| 262 | ctx.to_log('doxygen was not found (ignoring)') |
---|
| 263 | |
---|
[6ed0f4e] | 264 | def build(bld): |
---|
[985a5d1] | 265 | bld.env['VERSION'] = VERSION |
---|
| 266 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
| 267 | |
---|
| 268 | # add sub directories |
---|
| 269 | bld.recurse('src') |
---|
| 270 | if bld.env['DEST_OS'] not in ['ios', 'iosimulator']: |
---|
| 271 | pass |
---|
| 272 | if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']: |
---|
| 273 | bld.recurse('examples') |
---|
| 274 | bld.recurse('tests') |
---|
| 275 | |
---|
| 276 | bld( source = 'aubio.pc.in' ) |
---|
| 277 | |
---|
[52a25e5] | 278 | # build manpages from txt files using txt2man |
---|
[403e9dd] | 279 | if bld.env['TXT2MAN']: |
---|
[985a5d1] | 280 | from waflib import TaskGen |
---|
| 281 | if 'MANDIR' not in bld.env: |
---|
| 282 | bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man' |
---|
[403e9dd] | 283 | rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`' |
---|
| 284 | rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}' |
---|
| 285 | rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual' |
---|
| 286 | rule_str += ' -s 1 ${SRC} > ${TGT}' |
---|
[985a5d1] | 287 | TaskGen.declare_chain( |
---|
[403e9dd] | 288 | name = 'txt2man', |
---|
| 289 | rule = rule_str, |
---|
| 290 | ext_in = '.txt', |
---|
[985a5d1] | 291 | ext_out = '.1', |
---|
| 292 | reentrant = False, |
---|
| 293 | install_path = '${MANDIR}/man1', |
---|
| 294 | ) |
---|
[403e9dd] | 295 | bld( source = bld.path.ant_glob('doc/*.txt') ) |
---|
[985a5d1] | 296 | |
---|
[52a25e5] | 297 | # build documentation from source files using doxygen |
---|
| 298 | if bld.env['DOXYGEN']: |
---|
| 299 | bld( name = 'doxygen', rule = 'doxygen ${SRC} > /dev/null', |
---|
| 300 | source = 'doc/web.cfg', |
---|
[b0ab6ef] | 301 | cwd = 'doc') |
---|
[52a25e5] | 302 | bld.install_files( '${PREFIX}' + '/share/doc/libaubio-doc', |
---|
| 303 | bld.path.ant_glob('doc/web/html/**'), |
---|
| 304 | cwd = bld.path.find_dir ('doc/web'), |
---|
| 305 | relative_trick = True) |
---|
[50d56cc] | 306 | |
---|
[30250de] | 307 | def shutdown(bld): |
---|
[985a5d1] | 308 | from waflib import Logs |
---|
| 309 | if bld.options.target_platform in ['ios', 'iosimulator']: |
---|
| 310 | msg ='building for %s, contact the author for a commercial license' % bld.options.target_platform |
---|
| 311 | Logs.pprint('RED', msg) |
---|
| 312 | msg =' Paul Brossier <piem@aubio.org>' |
---|
| 313 | Logs.pprint('RED', msg) |
---|
[b4d1ba1] | 314 | |
---|
| 315 | def dist(ctx): |
---|
| 316 | ctx.excl = ' **/.waf-1* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git*' |
---|
| 317 | ctx.excl += ' **/build/*' |
---|
[22dd9dc] | 318 | ctx.excl += ' **/python/gen **/python/build **/python/dist' |
---|
| 319 | ctx.excl += ' **/**.zip **/**.tar.bz2' |
---|
[a93dab3] | 320 | ctx.excl += ' **/doc/full/* **/doc/web/*' |
---|
[b4d1ba1] | 321 | ctx.excl += ' **/python/*.db' |
---|
| 322 | ctx.excl += ' **/python.old/*' |
---|
[172b1fe] | 323 | ctx.excl += ' **/python/tests/sounds' |
---|