toolchain: abstract setting -nostdinc

- newlib needs c standard includes (so no -nostdinc)
- xcc needs toolchain headers (so no -nostdinc)
- with host gcc:
  - x86_64 should not build with standard includes (-nostdinc needed)
  - native_posix should build with standard include (no -nostdinc)
..
..

To simplify, abstract this and move it to compilers/toolchains and still
depend on what the application wants.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d556688..be9f2ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -187,9 +187,8 @@
   )
 endif()
 
-if(NOT CONFIG_NATIVE_APPLICATION)
-  set(NOSTDINC_F -nostdinc)
-endif()
+# @Intent: Obtain compiler specific flags for standard C includes
+toolchain_cc_nostdinc()
 
 zephyr_compile_options(
   -g # TODO: build configuration enough?
@@ -201,7 +200,6 @@
   -ffreestanding
   -Wno-main
   -fno-common
-  ${NOSTDINC_F}
   ${TOOLCHAIN_C_FLAGS}
 )
 
@@ -478,7 +476,6 @@
     ${linker_script_dep}
     COMMAND ${CMAKE_C_COMPILER}
     -x assembler-with-cpp
-    ${NOSTDINC_F}
     ${NOSYSDEF_CFLAG}
     -MD -MF ${linker_cmd_file_name}.dep -MT ${base_name}/${linker_cmd_file_name}
     ${current_includes}
diff --git a/cmake/compiler/gcc/target.cmake b/cmake/compiler/gcc/target.cmake
index ef10d39..4c1d2e5 100644
--- a/cmake/compiler/gcc/target.cmake
+++ b/cmake/compiler/gcc/target.cmake
@@ -135,3 +135,4 @@
 include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_optimizations.cmake)
 include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_cpp.cmake)
 include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_asm.cmake)
+include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_baremetal.cmake)
diff --git a/cmake/compiler/gcc/target_baremetal.cmake b/cmake/compiler/gcc/target_baremetal.cmake
new file mode 100644
index 0000000..dcd8c85
--- /dev/null
+++ b/cmake/compiler/gcc/target_baremetal.cmake
@@ -0,0 +1,10 @@
+
+macro(toolchain_cc_nostdinc)
+
+  if (NOT CONFIG_NEWLIB_LIBC AND
+    NOT COMPILER STREQUAL "xcc" AND
+    NOT CONFIG_NATIVE_APPLICATION)
+    zephyr_compile_options( -nostdinc)
+  endif()
+
+endmacro()
diff --git a/cmake/compiler/host-gcc/target.cmake b/cmake/compiler/host-gcc/target.cmake
index 004fd5c..e75f28d 100644
--- a/cmake/compiler/host-gcc/target.cmake
+++ b/cmake/compiler/host-gcc/target.cmake
@@ -82,3 +82,4 @@
 include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_optimizations.cmake)
 include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_cpp.cmake)
 include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_asm.cmake)
+include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake)
diff --git a/cmake/compiler/host-gcc/target_nostdinc.cmake b/cmake/compiler/host-gcc/target_nostdinc.cmake
deleted file mode 100644
index 336e168..0000000
--- a/cmake/compiler/host-gcc/target_nostdinc.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-
-macro(toolchain_cc_nostdinc)
-
-  zephyr_compile_options_ifndef(CONFIG_NATIVE_APPLICATION
-    -nostdinc
-  )
-
-endmacro()