COMPMID-345: Updated scons scripts to link computer_vision statically against libgcc, libstdc++ and computer_vision.

This is needed to run 'computer_vision' on the ARM 8.2-a + FP16 Fast model.

Change-Id: I66d6427e4d4117b7995c35ec9df1dea5b3f22205
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/78429
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
diff --git a/SConscript b/SConscript
index 970466e..a53501d 100644
--- a/SConscript
+++ b/SConscript
@@ -178,7 +178,7 @@
 arm_compute_core_a = build_library('arm_compute_core-static', static_core_objects, static=True)
 Export('arm_compute_core_a')
 
-if env['os'] != 'bare_metal':
+if env['os'] != 'bare_metal' and not env['standalone']:
     arm_compute_core_so = build_library('arm_compute_core', shared_core_objects, static=False)
     Export('arm_compute_core_so')
 
@@ -188,12 +188,20 @@
 arm_compute_a = build_library('arm_compute-static', static_core_objects + static_objects, static=True)
 Export('arm_compute_a')
 
-if env['os'] != 'bare_metal':
+if env['os'] != 'bare_metal' and not env['standalone']:
     arm_compute_so = build_library('arm_compute', shared_core_objects + shared_objects, static=False)
     Export('arm_compute_so')
 
-alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so])
+if env['standalone']:
+    alias = arm_compute_env.Alias("arm_compute", [arm_compute_a])
+else:
+    alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so])
+
 Default(alias)
 
 Default(generate_embed)
-Depends([alias,arm_compute_core_so, arm_compute_core_a], generate_embed)
+
+if env['standalone']:
+    Depends([alias,arm_compute_core_a], generate_embed)
+else:
+    Depends([alias,arm_compute_core_so, arm_compute_core_a], generate_embed)
diff --git a/SConstruct b/SConstruct
index 3927e3a..e23b2d2 100644
--- a/SConstruct
+++ b/SConstruct
@@ -44,6 +44,7 @@
     EnumVariable("build", "Build type", "cross_compile", allowed_values=("native", "cross_compile")),
     BoolVariable("examples", "Build example programs", True),
     BoolVariable("Werror", "Enable/disable the -Werror compilation flag", True),
+    BoolVariable("standalone", "Builds the tests as standalone executables, links statically with libgcc, libstdc++ and libarm_compute", False),
     BoolVariable("opencl", "Enable OpenCL support", True),
     BoolVariable("neon", "Enable Neon support", False),
     BoolVariable("embed_kernels", "Embed OpenCL kernels in library binary", False),
@@ -161,6 +162,10 @@
         if compiler_ver == '4.8.3':
             env.Append(CXXFLAGS = ['-Wno-array-bounds'])
 
+if env['standalone']:
+    env.Append(CXXFLAGS = ['-fPIC'])
+    env.Append(LINKFLAGS = ['-static-libgcc','-static-libstdc++'])
+
 if env['Werror']:
     env.Append(CXXFLAGS = ['-Werror'])
 
diff --git a/examples/SConscript b/examples/SConscript
index 748f771..04569c6 100644
--- a/examples/SConscript
+++ b/examples/SConscript
@@ -23,8 +23,6 @@
 import os.path
 
 Import('env')
-Import('arm_compute_a')
-Import('arm_compute_so')
 
 if env['opencl']:
     Import('opencl')
@@ -38,10 +36,12 @@
 # Build examples
 utils = examples_env.Object("../utils/Utils.cpp")
 
-if env['os'] in ['android', 'bare_metal']:
+if env['os'] in ['android', 'bare_metal'] or env['standalone']:
+    Import('arm_compute_a')
     arm_compute_lib = arm_compute_a
     arm_compute_dependency = arm_compute_a
 else:
+    Import('arm_compute_so')
     arm_compute_lib = "arm_compute"
     arm_compute_dependency = arm_compute_so
 
diff --git a/tests/SConscript b/tests/SConscript
index 6be4ddb..8da1d2f 100644
--- a/tests/SConscript
+++ b/tests/SConscript
@@ -24,8 +24,6 @@
 
 Import('env')
 Import('vars')
-Import('arm_compute_a')
-Import('arm_compute_so')
 
 # vars is imported from arm_compute:
 variables = [
@@ -49,10 +47,12 @@
 
 Help(new_options.GenerateHelpText(common_env))
 
-if env['os'] in ['android', 'bare_metal']:
+if env['os'] in ['android', 'bare_metal'] or env['standalone']:
+    Import('arm_compute_a')
     common_env.Append(LIBS = [arm_compute_a])
     arm_compute_lib = arm_compute_a
 else:
+    Import('arm_compute_so')
     common_env.Append(LIBS = ["arm_compute"])
     arm_compute_lib = arm_compute_so