make/toolchain.sh

changeset 1310
ca52ea73a4ca
parent 815
b0c4750cecd8
--- a/make/toolchain.sh	Sun Apr 27 12:56:05 2025 +0200
+++ b/make/toolchain.sh	Fri May 02 19:26:47 2025 +0200
@@ -17,20 +17,28 @@
 
 check_c_compiler()
 {
+  command -v $1 2>&1 >/dev/null
+  if [ $? -ne 0 ]; then
+    return 1
+  fi
   cat > "$TEMP_DIR/test.c" << __EOF__
 /* test file */
 #include <stdio.h>
 int main(int argc, char **argv) {
 #if defined(_MSC_VER)
-  printf("msc\n");
+  printf("toolchain:msc\n");
 #elif defined(__clang__)
-  printf("clang gnuc\n");
+  printf("toolchain:clang gnuc\n");
 #elif defined(__GNUC__)
-  printf("gcc gnuc\n");
+  printf("toolchain:gcc gnuc\n");
 #elif defined(__sun)
-  printf("suncc\n");
+  printf("toolchain:suncc\n");
 #else
-  printf("unknown\n");
+  printf("toolchain:unknown\n");
+#endif
+  printf("wsize:%d\n", (int)sizeof(void*)*8);
+#ifdef __STDC_VERSION__
+  printf("stdcversion:%d\n", __STDC_VERSION__);
 #endif
   return 0;
 }
@@ -41,21 +49,26 @@
 
 check_cpp_compiler()
 {
+  command -v $1 2>&1 >/dev/null
+  if [ $? -ne 0 ]; then
+    return 1
+  fi
   cat > "$TEMP_DIR/test.cpp" << __EOF__
 /* test file */
 #include <iostream>
 int main(int argc, char **argv) {
 #if defined(_MSC_VER)
-  std::cout << "msc" << std::endl;
+  std::cout << "toolchain:msc" << std::endl;
 #elif defined(__clang__)
-  std::cout << "clang gnuc" << std::endl;
+  std::cout << "toolchain:clang gnuc" << std::endl;
 #elif defined(__GNUC__)
-  std::cout << "gcc gnuc" << std::endl;
+  std::cout << "toolchain:gcc gnuc" << std::endl;
 #elif defined(__sun)
-  std::cout << "suncc" << std::endl;
+  std::cout << "toolchain:suncc" << std::endl;
 #else
-  std::cout << "cc" << std::endl;
+  std::cout << "toolchain:unknown" << std::endl;
 #endif
+  std:cout << "wsize:" << sizeof(void*)*8 << std::endl;
   return 0;
 }
 __EOF__
@@ -122,8 +135,11 @@
   if [ -n "$CC" ]; then
     if check_c_compiler "$CC"; then
       TOOLCHAIN_CC=$CC
-      TOOLCHAIN=`"$TEMP_DIR/checkcc"`
+      "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
+      TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11`
       TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -`
+      TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7`
+      TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13`
       echo "$CC"
       return 0
     else
@@ -135,8 +151,11 @@
     do
       if check_c_compiler "$COMP"; then
         TOOLCHAIN_CC=$COMP
-        TOOLCHAIN=`"$TEMP_DIR/checkcc"`
+        "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
+        TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11`
         TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -`
+        TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7`
+        TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13`
         echo "$COMP"
         return 0
       fi
@@ -156,7 +175,8 @@
   if [ -n "$CXX" ]; then
     if check_cpp_compiler "$CXX"; then
       TOOLCHAIN_CXX=$CXX
-      TOOLCHAIN=`"$TEMP_DIR/checkcc"`
+      "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
+      TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11`
       TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -`
       echo "$CXX"
       return 0
@@ -169,7 +189,8 @@
     do
       if check_cpp_compiler "$COMP"; then
         TOOLCHAIN_CXX=$COMP
-        TOOLCHAIN=`"$TEMP_DIR/checkcc"`
+        "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
+        TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11`
         TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -`
         echo "$COMP"
         return 0

mercurial