+if env['build'] == "embed_only":
+ SConscript('./SConscript', variant_dir='#build/%s' % env['build_dir'], duplicate=0)
+ Return()
+
+if env['neon'] and 'x86' in env['arch']:
+ print "Cannot compile NEON for x86"
+ Exit(1)
+
+if env['set_soname'] and not version_at_least(SCons.__version__, "2.4"):
+ print "Setting the library's SONAME / SHLIBVERSION requires SCons 2.4 or above"
+ print "Update your version of SCons or use set_soname=0"
+ Exit(1)
+
+if env['os'] == 'bare_metal':
+ if env['cppthreads'] or env['openmp']:
+ print("ERROR: OpenMP and C++11 threads not supported in bare_metal. Use cppthreads=0 openmp=0")
+ Exit(1)
+
+env.Append(CXXFLAGS = ['-Wno-deprecated-declarations','-Wall','-DARCH_ARM',
+ '-Wextra','-Wno-unused-parameter','-pedantic','-Wdisabled-optimization','-Wformat=2',
+ '-Winit-self','-Wstrict-overflow=2','-Wswitch-default',
+ '-fpermissive','-std=gnu++11','-Wno-vla','-Woverloaded-virtual',
+ '-Wctor-dtor-privacy','-Wsign-promo','-Weffc++','-Wno-format-nonliteral','-Wno-overlength-strings','-Wno-strict-overflow','-Wno-implicit-fallthrough'])
+
+env.Append(CPPDEFINES = ['_GLIBCXX_USE_NANOSLEEP'])
+
+default_cpp_compiler = 'g++' if env['os'] != 'android' else 'clang++'
+default_c_compiler = 'gcc' if env['os'] != 'android' else 'clang'
+cpp_compiler = os.environ.get('CXX', default_cpp_compiler)
+c_compiler = os.environ.get('CC', default_c_compiler)
+
+if env['os'] == 'android' and ( 'clang++' not in cpp_compiler or 'clang' not in c_compiler ):
+ print "WARNING: Only clang is officially supported to build the Compute Library for Android"
+
+if 'clang++' in cpp_compiler:
+ env.Append(CXXFLAGS = ['-Wno-format-nonliteral','-Wno-deprecated-increment-bool','-Wno-vla-extension','-Wno-mismatched-tags'])
+else:
+ env.Append(CXXFLAGS = ['-Wlogical-op','-Wnoexcept','-Wstrict-null-sentinel'])
+
+if env['cppthreads']:
+ env.Append(CPPDEFINES = [('ARM_COMPUTE_CPP_SCHEDULER', 1)])
+
+if env['openmp']:
+ if 'clang++' in cpp_compiler:
+ print "Clang does not support OpenMP. Use scheduler=cpp."
+ Exit(1)
+
+ env.Append(CPPDEFINES = [('ARM_COMPUTE_OPENMP_SCHEDULER', 1)])
+ env.Append(CXXFLAGS = ['-fopenmp'])
+ env.Append(LINKFLAGS = ['-fopenmp'])
+
+prefix = ""
+if env['arch'] == 'armv7a':
+ env.Append(CXXFLAGS = ['-march=armv7-a', '-mthumb', '-mfpu=neon'])
+
+ if env['os'] == 'linux':
+ prefix = "arm-linux-gnueabihf-"
+ env.Append(CXXFLAGS = ['-mfloat-abi=hard'])
+ elif env['os'] == 'bare_metal':
+ prefix = "arm-eabi-"
+ env.Append(CXXFLAGS = ['-mfloat-abi=hard'])
+ elif env['os'] == 'android':
+ prefix = "arm-linux-androideabi-"
+ env.Append(CXXFLAGS = ['-mfloat-abi=softfp'])
+elif env['arch'] == 'arm64-v8a':
+ env.Append(CXXFLAGS = ['-march=armv8-a'])
+ env.Append(CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8A','NO_DOT_IN_TOOLCHAIN'])
+ if env['os'] == 'linux':
+ prefix = "aarch64-linux-gnu-"
+ elif env['os'] == 'bare_metal':
+ prefix = "aarch64-elf-"
+ elif env['os'] == 'android':
+ prefix = "aarch64-linux-android-"
+ if 'clang++' in cpp_compiler:
+ env.Append(CXXFLAGS = ['-no-integrated-as'])
+elif env['arch'] == 'arm64-v8.2-a':
+ env.Append(CXXFLAGS = ['-march=armv8.2-a+fp16']) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined
+ env.Append(CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8_2','NO_DOT_IN_TOOLCHAIN'])
+ if 'clang++' in cpp_compiler:
+ env.Append(CXXFLAGS = ['-no-integrated-as'])
+ if env['os'] == 'linux':
+ prefix = "aarch64-linux-gnu-"
+ elif env['os'] == 'bare_metal':
+ prefix = "aarch64-elf-"
+ elif env['os'] == 'android':
+ prefix = "aarch64-linux-android-"
+elif env['arch'] == 'x86_32':
+ env.Append(CCFLAGS = ['-m32'])
+ env.Append(LINKFLAGS = ['-m32'])
+elif env['arch'] == 'x86_64':
+ env.Append(CCFLAGS = ['-m64'])
+ env.Append(LINKFLAGS = ['-m64'])
+
+if env['build'] == 'native':
+ prefix = ""
+
+env['CC'] = env['compiler_cache']+" "+prefix + c_compiler
+env['CXX'] = env['compiler_cache']+" "+prefix + cpp_compiler
+env['LD'] = prefix + "ld"
+env['AS'] = prefix + "as"
+env['AR'] = prefix + "ar"
+env['RANLIB'] = prefix + "ranlib"