[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 | |
---|
[004b431] | 13 | import sys |
---|
| 14 | |
---|
[000b090] | 15 | APPNAME = 'aubio' |
---|
[5820107] | 16 | |
---|
[6b14351] | 17 | # source VERSION |
---|
[5820107] | 18 | for l in open('VERSION').readlines(): exec (l.strip()) |
---|
| 19 | |
---|
[6b14351] | 20 | VERSION = '.'.join ([str(x) for x in [ |
---|
| 21 | AUBIO_MAJOR_VERSION, |
---|
| 22 | AUBIO_MINOR_VERSION, |
---|
| 23 | AUBIO_PATCH_VERSION |
---|
| 24 | ]]) + AUBIO_VERSION_STATUS |
---|
[e565c649] | 25 | |
---|
[6b14351] | 26 | LIB_VERSION = '.'.join ([str(x) for x in [ |
---|
| 27 | LIBAUBIO_LT_CUR, |
---|
| 28 | LIBAUBIO_LT_REV, |
---|
| 29 | LIBAUBIO_LT_AGE]]) |
---|
[e565c649] | 30 | |
---|
[46378b3] | 31 | top = '.' |
---|
| 32 | out = 'build' |
---|
[000b090] | 33 | |
---|
[6b14351] | 34 | def add_option_enable_disable(ctx, name, default = None, |
---|
| 35 | help_str = None, help_disable_str = None): |
---|
[a93dab3] | 36 | if help_str == None: |
---|
| 37 | help_str = 'enable ' + name + ' support' |
---|
| 38 | if help_disable_str == None: |
---|
| 39 | help_disable_str = 'do not ' + help_str |
---|
| 40 | ctx.add_option('--enable-' + name, action = 'store_true', |
---|
| 41 | default = default, |
---|
| 42 | dest = 'enable_' + name.replace('-','_'), |
---|
| 43 | help = help_str) |
---|
| 44 | ctx.add_option('--disable-' + name, action = 'store_false', |
---|
| 45 | #default = default, |
---|
| 46 | dest = 'enable_' + name.replace('-','_'), |
---|
| 47 | help = help_disable_str ) |
---|
[3819aca] | 48 | |
---|
[d41bc4d] | 49 | def options(ctx): |
---|
[a93dab3] | 50 | add_option_enable_disable(ctx, 'fftw3f', default = False, |
---|
| 51 | help_str = 'compile with fftw3f instead of ooura (recommended)', |
---|
| 52 | help_disable_str = 'do not compile with fftw3f') |
---|
| 53 | add_option_enable_disable(ctx, 'fftw3', default = False, |
---|
| 54 | help_str = 'compile with fftw3 instead of ooura', |
---|
| 55 | help_disable_str = 'do not compile with fftw3') |
---|
| 56 | add_option_enable_disable(ctx, 'complex', default = False, |
---|
| 57 | help_str ='compile with C99 complex', |
---|
| 58 | help_disable_str = 'do not use C99 complex (default)' ) |
---|
| 59 | add_option_enable_disable(ctx, 'jack', default = None, |
---|
| 60 | help_str = 'compile with jack (auto)', |
---|
| 61 | help_disable_str = 'disable jack support') |
---|
| 62 | add_option_enable_disable(ctx, 'sndfile', default = None, |
---|
| 63 | help_str = 'compile with sndfile (auto)', |
---|
| 64 | help_disable_str = 'disable sndfile') |
---|
| 65 | add_option_enable_disable(ctx, 'avcodec', default = None, |
---|
| 66 | help_str = 'compile with libavcodec (auto)', |
---|
| 67 | help_disable_str = 'disable libavcodec') |
---|
| 68 | add_option_enable_disable(ctx, 'samplerate', default = None, |
---|
| 69 | help_str = 'compile with samplerate (auto)', |
---|
| 70 | help_disable_str = 'disable samplerate') |
---|
| 71 | add_option_enable_disable(ctx, 'memcpy', default = True, |
---|
| 72 | help_str = 'use memcpy hacks (default)', |
---|
| 73 | help_disable_str = 'do not use memcpy hacks') |
---|
| 74 | add_option_enable_disable(ctx, 'double', default = False, |
---|
| 75 | help_str = 'compile in double precision mode', |
---|
| 76 | help_disable_str = 'compile in single precision mode (default)') |
---|
[a3de4be] | 77 | add_option_enable_disable(ctx, 'fat', default = False, |
---|
| 78 | help_str = 'build fat binaries (darwin only)', |
---|
| 79 | help_disable_str = 'do not build fat binaries (default)') |
---|
[0309a22] | 80 | add_option_enable_disable(ctx, 'accelerate', default = None, |
---|
| 81 | help_str = 'use Accelerate framework (darwin only) (auto)', |
---|
| 82 | help_disable_str = 'do not use Accelerate framework') |
---|
[cc81763] | 83 | add_option_enable_disable(ctx, 'apple-audio', default = None, |
---|
| 84 | help_str = 'use CoreFoundation (darwin only) (auto)', |
---|
| 85 | help_disable_str = 'do not use CoreFoundation framework') |
---|
[f61ffb9] | 86 | add_option_enable_disable(ctx, 'atlas', default = False, |
---|
| 87 | help_str = 'use Atlas library (no)', |
---|
[f0ce36a1] | 88 | help_disable_str = 'do not use Atlas library') |
---|
[f9a543e] | 89 | add_option_enable_disable(ctx, 'wavread', default = True, |
---|
| 90 | help_str = 'compile with source_wavread (default)', |
---|
| 91 | help_disable_str = 'do not compile source_wavread') |
---|
| 92 | add_option_enable_disable(ctx, 'wavwrite', default = True, |
---|
| 93 | help_str = 'compile with source_wavwrite (default)', |
---|
| 94 | help_disable_str = 'do not compile source_wavwrite') |
---|
[a93dab3] | 95 | |
---|
[a33d406] | 96 | add_option_enable_disable(ctx, 'docs', default = None, |
---|
| 97 | help_str = 'build documentation (auto)', |
---|
| 98 | help_disable_str = 'do not build documentation') |
---|
| 99 | |
---|
[a93dab3] | 100 | ctx.add_option('--with-target-platform', type='string', |
---|
| 101 | help='set target platform for cross-compilation', dest='target_platform') |
---|
| 102 | |
---|
| 103 | ctx.load('compiler_c') |
---|
| 104 | ctx.load('waf_unit_test') |
---|
| 105 | ctx.load('gnu_dirs') |
---|
[000b090] | 106 | |
---|
[d41bc4d] | 107 | def configure(ctx): |
---|
[a93dab3] | 108 | from waflib import Options |
---|
| 109 | ctx.load('compiler_c') |
---|
| 110 | ctx.load('waf_unit_test') |
---|
| 111 | ctx.load('gnu_dirs') |
---|
[06dba46] | 112 | |
---|
[bef979a] | 113 | # check for common headers |
---|
| 114 | ctx.check(header_name='stdlib.h') |
---|
| 115 | ctx.check(header_name='stdio.h') |
---|
| 116 | ctx.check(header_name='math.h') |
---|
| 117 | ctx.check(header_name='string.h') |
---|
| 118 | ctx.check(header_name='limits.h') |
---|
[f334300] | 119 | ctx.check(header_name='stdarg.h') |
---|
[d746ef8] | 120 | ctx.check(header_name='getopt.h', mandatory = False) |
---|
[06cf47d] | 121 | ctx.check(header_name='unistd.h', mandatory = False) |
---|
[bef979a] | 122 | |
---|
[004b431] | 123 | target_platform = sys.platform |
---|
[a93dab3] | 124 | if ctx.options.target_platform: |
---|
| 125 | target_platform = ctx.options.target_platform |
---|
| 126 | ctx.env['DEST_OS'] = target_platform |
---|
| 127 | |
---|
[ae36035] | 128 | if ctx.env.CC_NAME != 'msvc': |
---|
[a341685] | 129 | ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra'] |
---|
| 130 | else: |
---|
[5bba662] | 131 | ctx.env.CFLAGS += ['/W4', '/MD'] |
---|
| 132 | ctx.env.CFLAGS += ['/D_CRT_SECURE_NO_WARNINGS'] |
---|
[a341685] | 133 | |
---|
[70a304e] | 134 | ctx.check_cc(lib='m', uselib_store='M', mandatory=False) |
---|
| 135 | |
---|
[06dba46] | 136 | if target_platform not in ['win32', 'win64']: |
---|
| 137 | ctx.env.CFLAGS += ['-fPIC'] |
---|
| 138 | else: |
---|
| 139 | ctx.define('HAVE_WIN_HACKS', 1) |
---|
| 140 | ctx.env['cshlib_PATTERN'] = 'lib%s.dll' |
---|
[a93dab3] | 141 | |
---|
[a3de4be] | 142 | if target_platform == 'darwin' and ctx.options.enable_fat: |
---|
[a93dab3] | 143 | ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
| 144 | ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
[da1709f] | 145 | MINSDKVER="10.4" |
---|
| 146 | ctx.env.CFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ] |
---|
| 147 | ctx.env.LINKFLAGS += [ '-mmacosx-version-min=' + MINSDKVER ] |
---|
[9209c79] | 148 | |
---|
| 149 | if target_platform in [ 'darwin', 'ios', 'iosimulator']: |
---|
[cc81763] | 150 | if (ctx.options.enable_apple_audio != False): |
---|
| 151 | ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox'] |
---|
| 152 | ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1) |
---|
| 153 | ctx.define('HAVE_SINK_APPLE_AUDIO', 1) |
---|
[f61ffb9] | 154 | ctx.msg('Checking for AudioToolbox.framework', 'yes') |
---|
| 155 | else: |
---|
| 156 | ctx.msg('Checking for AudioToolbox.framework', 'no (disabled)', color = 'YELLOW') |
---|
[0309a22] | 157 | if (ctx.options.enable_accelerate != False): |
---|
| 158 | ctx.define('HAVE_ACCELERATE', 1) |
---|
| 159 | ctx.env.FRAMEWORK += ['Accelerate'] |
---|
[f61ffb9] | 160 | ctx.msg('Checking for Accelerate framework', 'yes') |
---|
| 161 | else: |
---|
[488381e] | 162 | ctx.msg('Checking for Accelerate framework', 'no (disabled)', color = 'YELLOW') |
---|
[a93dab3] | 163 | |
---|
| 164 | if target_platform in [ 'ios', 'iosimulator' ]: |
---|
| 165 | MINSDKVER="6.1" |
---|
| 166 | ctx.env.CFLAGS += ['-std=c99'] |
---|
[536bf70] | 167 | if (ctx.options.enable_apple_audio != False): |
---|
[cc81763] | 168 | ctx.define('HAVE_AUDIO_UNIT', 1) |
---|
| 169 | #ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox'] |
---|
[a93dab3] | 170 | if target_platform == 'ios': |
---|
| 171 | DEVROOT = "/Applications/Xcode.app/Contents" |
---|
| 172 | DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer" |
---|
[e11ce489] | 173 | SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS.sdk" % locals() |
---|
[94b16497] | 174 | ctx.env.CFLAGS += [ '-fembed-bitcode' ] |
---|
[7aa4aaa] | 175 | ctx.env.CFLAGS += [ '-arch', 'arm64' ] |
---|
[a93dab3] | 176 | ctx.env.CFLAGS += [ '-arch', 'armv7' ] |
---|
| 177 | ctx.env.CFLAGS += [ '-arch', 'armv7s' ] |
---|
[7aa4aaa] | 178 | ctx.env.LINKFLAGS += [ '-arch', 'arm64' ] |
---|
[a93dab3] | 179 | ctx.env.LINKFLAGS += ['-arch', 'armv7'] |
---|
| 180 | ctx.env.LINKFLAGS += ['-arch', 'armv7s'] |
---|
| 181 | ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
| 182 | ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
| 183 | else: |
---|
| 184 | DEVROOT = "/Applications/Xcode.app/Contents" |
---|
| 185 | DEVROOT += "/Developer/Platforms/iPhoneSimulator.platform/Developer" |
---|
[e11ce489] | 186 | SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator.sdk" % locals() |
---|
[a93dab3] | 187 | ctx.env.CFLAGS += [ '-arch', 'i386' ] |
---|
| 188 | ctx.env.CFLAGS += [ '-arch', 'x86_64' ] |
---|
| 189 | ctx.env.LINKFLAGS += ['-arch', 'i386'] |
---|
| 190 | ctx.env.LINKFLAGS += ['-arch', 'x86_64'] |
---|
| 191 | ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
| 192 | ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
| 193 | ctx.env.CFLAGS += [ '-isysroot' , SDKROOT] |
---|
| 194 | ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT] |
---|
| 195 | |
---|
[fb5838a] | 196 | if target_platform == 'emscripten': |
---|
| 197 | import os.path |
---|
| 198 | ctx.env.CFLAGS += [ '-I' + os.path.join(os.environ['EMSCRIPTEN'], 'system', 'include') ] |
---|
| 199 | ctx.env.CFLAGS += ['-Oz'] |
---|
| 200 | ctx.env.cprogram_PATTERN = "%s.js" |
---|
| 201 | if (ctx.options.enable_atlas != True): |
---|
| 202 | ctx.options.enable_atlas = False |
---|
| 203 | |
---|
[a93dab3] | 204 | # check support for C99 __VA_ARGS__ macros |
---|
| 205 | check_c99_varargs = ''' |
---|
[0318cc1] | 206 | #include <stdio.h> |
---|
| 207 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
| 208 | ''' |
---|
[a93dab3] | 209 | |
---|
| 210 | if ctx.check_cc(fragment = check_c99_varargs, |
---|
| 211 | type='cstlib', |
---|
[413d4bf] | 212 | msg = 'Checking for C99 __VA_ARGS__ macro', |
---|
| 213 | mandatory = False): |
---|
[a93dab3] | 214 | ctx.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
| 215 | |
---|
[06c6d7d] | 216 | # show a message about enable_double status |
---|
[a93dab3] | 217 | if (ctx.options.enable_double == True): |
---|
[06c6d7d] | 218 | ctx.msg('Checking for size of smpl_t', 'double') |
---|
| 219 | ctx.msg('Checking for size of lsmp_t', 'long double') |
---|
[a93dab3] | 220 | else: |
---|
[06c6d7d] | 221 | ctx.msg('Checking for size of smpl_t', 'float') |
---|
| 222 | ctx.msg('Checking for size of lsmp_t', 'double') |
---|
[a93dab3] | 223 | |
---|
| 224 | # optionally use complex.h |
---|
| 225 | if (ctx.options.enable_complex == True): |
---|
| 226 | ctx.check(header_name='complex.h') |
---|
[06c6d7d] | 227 | else: |
---|
| 228 | ctx.msg('Checking if complex.h is enabled', 'no') |
---|
[a93dab3] | 229 | |
---|
| 230 | # check for fftw3 |
---|
| 231 | if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False): |
---|
| 232 | # one of fftwf or fftw3f |
---|
| 233 | if (ctx.options.enable_fftw3f != False): |
---|
| 234 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
[795fcd9] | 235 | args = '--cflags --libs', |
---|
| 236 | mandatory = ctx.options.enable_fftw3f) |
---|
[a93dab3] | 237 | if (ctx.options.enable_double == True): |
---|
[795fcd9] | 238 | ctx.msg('Warning', |
---|
| 239 | 'fftw3f enabled, but compiling in double precision!') |
---|
[a93dab3] | 240 | else: |
---|
[795fcd9] | 241 | # fftw3f disabled, take most sensible one according to |
---|
| 242 | # enable_double |
---|
[a93dab3] | 243 | if (ctx.options.enable_double == True): |
---|
| 244 | ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
[795fcd9] | 245 | args = '--cflags --libs', mandatory = |
---|
| 246 | ctx.options.enable_fftw3) |
---|
[a93dab3] | 247 | else: |
---|
| 248 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
[795fcd9] | 249 | args = '--cflags --libs', |
---|
| 250 | mandatory = ctx.options.enable_fftw3) |
---|
[a93dab3] | 251 | ctx.define('HAVE_FFTW3', 1) |
---|
| 252 | |
---|
| 253 | # fftw not enabled, use vDSP or ooura |
---|
| 254 | if 'HAVE_FFTW3F' in ctx.env.define_key: |
---|
| 255 | ctx.msg('Checking for FFT implementation', 'fftw3f') |
---|
| 256 | elif 'HAVE_FFTW3' in ctx.env.define_key: |
---|
| 257 | ctx.msg('Checking for FFT implementation', 'fftw3') |
---|
| 258 | elif 'HAVE_ACCELERATE' in ctx.env.define_key: |
---|
| 259 | ctx.msg('Checking for FFT implementation', 'vDSP') |
---|
[36f954a] | 260 | else: |
---|
[a93dab3] | 261 | ctx.msg('Checking for FFT implementation', 'ooura') |
---|
| 262 | |
---|
| 263 | # check for libsndfile |
---|
| 264 | if (ctx.options.enable_sndfile != False): |
---|
| 265 | ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
[795fcd9] | 266 | args = '--cflags --libs', |
---|
| 267 | mandatory = ctx.options.enable_sndfile) |
---|
[a93dab3] | 268 | |
---|
| 269 | # check for libsamplerate |
---|
[8be88e7] | 270 | if (ctx.options.enable_double): |
---|
| 271 | if (ctx.options.enable_samplerate): |
---|
| 272 | ctx.fatal("Could not compile aubio in double precision mode with libsamplerate") |
---|
| 273 | else: |
---|
| 274 | ctx.options.enable_samplerate = False |
---|
| 275 | ctx.msg('Checking if using samplerate', 'no (disabled in double precision mode)', |
---|
| 276 | color = 'YELLOW') |
---|
[a93dab3] | 277 | if (ctx.options.enable_samplerate != False): |
---|
| 278 | ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
[795fcd9] | 279 | args = '--cflags --libs', |
---|
| 280 | mandatory = ctx.options.enable_samplerate) |
---|
[a93dab3] | 281 | |
---|
| 282 | # check for jack |
---|
| 283 | if (ctx.options.enable_jack != False): |
---|
[eb99982] | 284 | ctx.check_cfg(package = 'jack', |
---|
[795fcd9] | 285 | args = '--cflags --libs', |
---|
| 286 | mandatory = ctx.options.enable_jack) |
---|
[a93dab3] | 287 | |
---|
| 288 | # check for libav |
---|
| 289 | if (ctx.options.enable_avcodec != False): |
---|
| 290 | ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0', |
---|
[795fcd9] | 291 | args = '--cflags --libs', uselib_store = 'AVCODEC', |
---|
| 292 | mandatory = ctx.options.enable_avcodec) |
---|
[a93dab3] | 293 | ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0', |
---|
[795fcd9] | 294 | args = '--cflags --libs', uselib_store = 'AVFORMAT', |
---|
| 295 | mandatory = ctx.options.enable_avcodec) |
---|
[a93dab3] | 296 | ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0', |
---|
[795fcd9] | 297 | args = '--cflags --libs', uselib_store = 'AVUTIL', |
---|
| 298 | mandatory = ctx.options.enable_avcodec) |
---|
[a93dab3] | 299 | ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1', |
---|
[795fcd9] | 300 | args = '--cflags --libs', uselib_store = 'AVRESAMPLE', |
---|
| 301 | mandatory = ctx.options.enable_avcodec) |
---|
[eb68991] | 302 | if all ( 'HAVE_' + i in ctx.env |
---|
[549928e] | 303 | for i in ['AVCODEC', 'AVFORMAT', 'AVUTIL', 'AVRESAMPLE'] ): |
---|
| 304 | ctx.define('HAVE_LIBAV', 1) |
---|
| 305 | ctx.msg('Checking for all libav libraries', 'yes') |
---|
| 306 | else: |
---|
| 307 | ctx.msg('Checking for all libav libraries', 'not found', color = 'YELLOW') |
---|
[a93dab3] | 308 | |
---|
[f9a543e] | 309 | if (ctx.options.enable_wavread != False): |
---|
| 310 | ctx.define('HAVE_WAVREAD', 1) |
---|
| 311 | ctx.msg('Checking if using source_wavread', ctx.options.enable_wavread and 'yes' or 'no') |
---|
| 312 | if (ctx.options.enable_wavwrite!= False): |
---|
| 313 | ctx.define('HAVE_WAVWRITE', 1) |
---|
| 314 | ctx.msg('Checking if using sink_wavwrite', ctx.options.enable_wavwrite and 'yes' or 'no') |
---|
[5158c22] | 315 | |
---|
[f0ce36a1] | 316 | # use ATLAS |
---|
| 317 | if (ctx.options.enable_atlas != False): |
---|
| 318 | ctx.check(header_name = 'atlas/cblas.h', mandatory = ctx.options.enable_atlas) |
---|
| 319 | #ctx.check(lib = 'lapack', uselib_store = 'LAPACK', mandatory = ctx.options.enable_atlas) |
---|
| 320 | ctx.check(lib = 'cblas', uselib_store = 'BLAS', mandatory = ctx.options.enable_atlas) |
---|
| 321 | |
---|
[a93dab3] | 322 | # use memcpy hacks |
---|
| 323 | if (ctx.options.enable_memcpy == True): |
---|
| 324 | ctx.define('HAVE_MEMCPY_HACKS', 1) |
---|
| 325 | |
---|
| 326 | # write configuration header |
---|
| 327 | ctx.write_config_header('src/config.h') |
---|
| 328 | |
---|
[06c6d7d] | 329 | # the following defines will be passed as arguments to the compiler |
---|
| 330 | # instead of being written to src/config.h |
---|
[1910fed] | 331 | ctx.define('HAVE_CONFIG_H', 1) |
---|
[06c6d7d] | 332 | |
---|
[a93dab3] | 333 | # add some defines used in examples |
---|
| 334 | ctx.define('AUBIO_PREFIX', ctx.env['PREFIX']) |
---|
| 335 | ctx.define('PACKAGE', APPNAME) |
---|
| 336 | |
---|
[06c6d7d] | 337 | # double precision mode |
---|
| 338 | if (ctx.options.enable_double == True): |
---|
| 339 | ctx.define('HAVE_AUBIO_DOUBLE', 1) |
---|
| 340 | |
---|
[a33d406] | 341 | if (ctx.options.enable_docs != False): |
---|
| 342 | # check if txt2man is installed, optional |
---|
| 343 | try: |
---|
| 344 | ctx.find_program('txt2man', var='TXT2MAN') |
---|
| 345 | except ctx.errors.ConfigurationError: |
---|
| 346 | ctx.to_log('txt2man was not found (ignoring)') |
---|
[000b090] | 347 | |
---|
[a33d406] | 348 | # check if doxygen is installed, optional |
---|
| 349 | try: |
---|
| 350 | ctx.find_program('doxygen', var='DOXYGEN') |
---|
| 351 | except ctx.errors.ConfigurationError: |
---|
| 352 | ctx.to_log('doxygen was not found (ignoring)') |
---|
[52a25e5] | 353 | |
---|
[7800335] | 354 | # check if sphinx-build is installed, optional |
---|
| 355 | try: |
---|
| 356 | ctx.find_program('sphinx-build', var='SPHINX') |
---|
| 357 | except ctx.errors.ConfigurationError: |
---|
| 358 | ctx.to_log('sphinx-build was not found (ignoring)') |
---|
| 359 | |
---|
[6ed0f4e] | 360 | def build(bld): |
---|
[985a5d1] | 361 | bld.env['VERSION'] = VERSION |
---|
| 362 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
| 363 | |
---|
[7b38f3f] | 364 | # main source |
---|
[985a5d1] | 365 | bld.recurse('src') |
---|
[7b38f3f] | 366 | |
---|
| 367 | # add sub directories |
---|
[985a5d1] | 368 | if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']: |
---|
| 369 | bld.recurse('examples') |
---|
| 370 | bld.recurse('tests') |
---|
| 371 | |
---|
[7b38f3f] | 372 | # pkg-config template |
---|
[985a5d1] | 373 | bld( source = 'aubio.pc.in' ) |
---|
| 374 | |
---|
[7b38f3f] | 375 | # documentation |
---|
| 376 | txt2man(bld) |
---|
| 377 | doxygen(bld) |
---|
| 378 | sphinx(bld) |
---|
| 379 | |
---|
| 380 | def txt2man(bld): |
---|
[52a25e5] | 381 | # build manpages from txt files using txt2man |
---|
[403e9dd] | 382 | if bld.env['TXT2MAN']: |
---|
[985a5d1] | 383 | from waflib import TaskGen |
---|
| 384 | if 'MANDIR' not in bld.env: |
---|
[641e533] | 385 | bld.env['MANDIR'] = bld.env['DATAROOTDIR'] + '/man' |
---|
[403e9dd] | 386 | rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`' |
---|
| 387 | rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}' |
---|
| 388 | rule_str += ' -v ${PACKAGE}\\ User\\\'s\\ manual' |
---|
| 389 | rule_str += ' -s 1 ${SRC} > ${TGT}' |
---|
[985a5d1] | 390 | TaskGen.declare_chain( |
---|
[403e9dd] | 391 | name = 'txt2man', |
---|
| 392 | rule = rule_str, |
---|
| 393 | ext_in = '.txt', |
---|
[985a5d1] | 394 | ext_out = '.1', |
---|
| 395 | reentrant = False, |
---|
| 396 | install_path = '${MANDIR}/man1', |
---|
| 397 | ) |
---|
[403e9dd] | 398 | bld( source = bld.path.ant_glob('doc/*.txt') ) |
---|
[985a5d1] | 399 | |
---|
[7b38f3f] | 400 | def doxygen(bld): |
---|
[52a25e5] | 401 | # build documentation from source files using doxygen |
---|
| 402 | if bld.env['DOXYGEN']: |
---|
| 403 | bld( name = 'doxygen', rule = 'doxygen ${SRC} > /dev/null', |
---|
| 404 | source = 'doc/web.cfg', |
---|
[7f35041] | 405 | cwd = 'doc') |
---|
[641e533] | 406 | bld.install_files( '${DATAROOTDIR}' + '/doc/libaubio-doc', |
---|
[52a25e5] | 407 | bld.path.ant_glob('doc/web/html/**'), |
---|
| 408 | cwd = bld.path.find_dir ('doc/web'), |
---|
| 409 | relative_trick = True) |
---|
[7800335] | 410 | |
---|
[7b38f3f] | 411 | def sphinx(bld): |
---|
[7800335] | 412 | # build documentation from source files using sphinx-build |
---|
[5a19f33] | 413 | # note: build in ../doc/_build/html, otherwise waf wont install unsigned files |
---|
[7800335] | 414 | if bld.env['SPHINX']: |
---|
[5a19f33] | 415 | bld( name = 'sphinx', |
---|
| 416 | rule = '${SPHINX} -b html -a -q `dirname ${SRC}` `dirname ${TGT}`', |
---|
[7b38f3f] | 417 | source = 'doc/conf.py', |
---|
[5a19f33] | 418 | target = '../doc/_build/html/index.html') |
---|
[641e533] | 419 | bld.install_files( '${DATAROOTDIR}' + '/doc/libaubio-doc/sphinx', |
---|
[7800335] | 420 | bld.path.ant_glob('doc/_build/html/**'), |
---|
[5a19f33] | 421 | cwd = bld.path.find_dir('doc/_build/html'), |
---|
[7800335] | 422 | relative_trick = True) |
---|
[50d56cc] | 423 | |
---|
[7b38f3f] | 424 | # register the previous rules as build rules |
---|
| 425 | from waflib.Build import BuildContext |
---|
| 426 | |
---|
| 427 | class build_txt2man(BuildContext): |
---|
| 428 | cmd = 'txt2man' |
---|
| 429 | fun = 'txt2man' |
---|
| 430 | |
---|
| 431 | class build_manpages(BuildContext): |
---|
| 432 | cmd = 'manpages' |
---|
| 433 | fun = 'txt2man' |
---|
| 434 | |
---|
| 435 | class build_sphinx(BuildContext): |
---|
| 436 | cmd = 'sphinx' |
---|
| 437 | fun = 'sphinx' |
---|
| 438 | |
---|
| 439 | class build_doxygen(BuildContext): |
---|
| 440 | cmd = 'doxygen' |
---|
| 441 | fun = 'doxygen' |
---|
| 442 | |
---|
[30250de] | 443 | def shutdown(bld): |
---|
[985a5d1] | 444 | from waflib import Logs |
---|
| 445 | if bld.options.target_platform in ['ios', 'iosimulator']: |
---|
| 446 | msg ='building for %s, contact the author for a commercial license' % bld.options.target_platform |
---|
| 447 | Logs.pprint('RED', msg) |
---|
| 448 | msg =' Paul Brossier <piem@aubio.org>' |
---|
| 449 | Logs.pprint('RED', msg) |
---|
[b4d1ba1] | 450 | |
---|
| 451 | def dist(ctx): |
---|
[3388e1a] | 452 | ctx.excl = ' **/.waf* **/*~ **/*.pyc **/*.swp **/*.swo **/*.swn **/.lock-w* **/.git*' |
---|
[b4d1ba1] | 453 | ctx.excl += ' **/build/*' |
---|
[99d8cbb] | 454 | ctx.excl += ' doc/_build' |
---|
| 455 | ctx.excl += ' python/demos_*' |
---|
[22dd9dc] | 456 | ctx.excl += ' **/python/gen **/python/build **/python/dist' |
---|
[981e7082] | 457 | ctx.excl += ' **/python/ext/config.h' |
---|
[99d8cbb] | 458 | ctx.excl += ' **/python/lib/aubio/_aubio.so' |
---|
| 459 | ctx.excl += ' **.egg-info' |
---|
[22dd9dc] | 460 | ctx.excl += ' **/**.zip **/**.tar.bz2' |
---|
[7b38f3f] | 461 | ctx.excl += ' **.tar.bz2' |
---|
[a93dab3] | 462 | ctx.excl += ' **/doc/full/* **/doc/web/*' |
---|
[e57a7d4] | 463 | ctx.excl += ' **/doc/full.cfg' |
---|
[b4d1ba1] | 464 | ctx.excl += ' **/python/*.db' |
---|
| 465 | ctx.excl += ' **/python.old/*' |
---|
[981e7082] | 466 | ctx.excl += ' **/python/*/*.old' |
---|
[172b1fe] | 467 | ctx.excl += ' **/python/tests/sounds' |
---|
[7b2d740] | 468 | ctx.excl += ' **/**.asc' |
---|
[5e544f1] | 469 | ctx.excl += ' **/dist*' |
---|
[73aac2a] | 470 | ctx.excl += ' **/.DS_Store' |
---|
| 471 | ctx.excl += ' **/.travis.yml' |
---|
[5e544f1] | 472 | ctx.excl += ' **/.landscape.yml' |
---|
| 473 | ctx.excl += ' **/.appveyor.yml' |
---|