Fix: Stop opteesp environment using default libc

The opteesp environment uses the libc implementation part of the
SPDEV-KIT. Projects targeting the opteesp environment shall be
configured to stop using the standard library and its header files
part of the compiler package.
This patch:
  - adds the missing compiler and linker options
  - adds header files missing from SPDEV-KITs libc implementation
  - extends the external component cmake files to align build options
    with the main project
  - moves environment specific mandatory flags to a common file
  - fixes the supported C standard from gnuc99 to c99

The following files where forked from TF-A
 (https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git; SHA: 7737fdf0ed):
- stdarg.h
- stdbool.h
- stddef.h
- stddef_.h

Signed-off-by: Andrew Beggs <andrew.beggs@arm.com>
Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
Change-Id: I3890453a29b003c60c8f44dfd19d553e96b1796c
diff --git a/environments/opteesp/default_toolchain_file.cmake b/environments/opteesp/default_toolchain_file.cmake
index 7cec0e4..c73345f 100644
--- a/environments/opteesp/default_toolchain_file.cmake
+++ b/environments/opteesp/default_toolchain_file.cmake
@@ -20,3 +20,19 @@
 #set(CMAKE_EXE_LINKER_FLAGS_INIT --specs=nosys.specs)
 
 include($ENV{TS_ROOT}/tools/cmake/compiler/GCC.cmake REQUIRED)
+
+# Set mandatory compiler and linker flags for this environment:
+#   - This environment uses a libc implementation from SPDEV-KIT. Disable standard
+#     include search paths, startup files and default libraries.
+string(APPEND CMAKE_C_FLAGS_INIT " -nostartfiles -nodefaultlibs -nostdinc -I ${CMAKE_CURRENT_LIST_DIR}/include")
+#   - Compile position independent code
+string(APPEND CMAKE_C_FLAGS_INIT " -fpic")
+#   -set entry point
+#   -disable link time optimization
+#   -link position independent executable
+string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -e __sp_entry -fno-lto -pie")
+
+#   -link libgcc with full PATH to work around disabled linker search paths.
+gcc_get_lib_location("libgcc.a" _TMP_VAR)
+string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${_TMP_VAR} ")
+unset(_TMP_VAR)