diff --git a/3rdparty/opus/wscript b/3rdparty/opus/wscript index 38fa0309..1b343d4d 100644 --- a/3rdparty/opus/wscript +++ b/3rdparty/opus/wscript @@ -3,6 +3,26 @@ import os +FRAGMENT_VLA='''int main (int argc, char **argv) { + char a[argc]; + a[sizeof( a ) - 1] = 0; + int N; + return a[0]; +}''' + +FRAGMENT_ALLOCA_H='''#include +int main (void) { + int foo=10; + int * array = alloca(foo); +}''' + +FRAGMENT_STDLIB_H='''#include +#include +int main (void) { + int foo=10; + int * array = alloca(foo); +}''' + def options(opt): pass @@ -11,6 +31,15 @@ def configure(conf): conf.fatal('Can\'t find opus submodule. Run `git submodule update --init --recursive`.') return + # Check for C99 variable-size arrays, or alloca() as fallback + if conf.check_cc(fragment=FRAGMENT_VLA, msg = 'Checking for C99 VLA support', mandatory = False): + conf.define('VAR_ARRAYS', 1) + elif conf.check_cc(fragment=FRAGMENT_ALLOCA_H, msg = 'Checking for alloca in alloca.h header', mandatory = False): + conf.define('USE_ALLOCA', 1) + conf.define('HAVE_ALLOCA_H', 1) + elif conf.check_cc(fragmenmt=FRAGMENT_STDLIB_H, msg = 'Checking for alloca.h in stdlib.h', mandatory = False): + conf.define('USE_ALLOCA', 1) + # TODO: ARM/x86 intrinsics detection # TODO: maybe call autotools/cmake/meson instead? @@ -27,7 +56,7 @@ def build(bld): 'opus/celt/opus_custom_demo.c' ]) includes = ['opus/include/', 'opus/celt/', 'opus/silk/', 'opus/silk/float/'] - defines = ['USE_ALLOCA', 'OPUS_BUILD', 'FLOAT_APPROX', 'PACKAGE_VERSION="1.4.0"', 'CUSTOM_MODES'] + defines = ['OPUS_BUILD', 'FLOAT_APPROX', 'PACKAGE_VERSION="1.4.0"', 'CUSTOM_MODES'] bld.stlib( source = sources,