--- a/make/toolchain.sh Tue Feb 25 18:46:17 2025 +0100 +++ b/make/toolchain.sh Mon May 19 13:30:18 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__ @@ -113,6 +126,14 @@ fi } +parse_toolchain_properties() +{ + info_file="$1" + TOOLCHAIN=`grep '^toolchain:' "$info_file" | tail -c +11` + TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` + TOOLCHAIN_WSIZE=`grep '^wsize:' "$info_file" | tail -c +7` +} + detect_c_compiler() { if [ -n "$TOOLCHAIN_CC" ]; then @@ -122,8 +143,9 @@ if [ -n "$CC" ]; then if check_c_compiler "$CC"; then TOOLCHAIN_CC=$CC - TOOLCHAIN=`"$TEMP_DIR/checkcc"` - TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + parse_toolchain_properties "$TEMP_DIR/checkcc_out" + TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` echo "$CC" return 0 else @@ -135,8 +157,9 @@ do if check_c_compiler "$COMP"; then TOOLCHAIN_CC=$COMP - TOOLCHAIN=`"$TEMP_DIR/checkcc"` - TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + parse_toolchain_properties "$TEMP_DIR/checkcc_out" + TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` echo "$COMP" return 0 fi @@ -156,8 +179,8 @@ if [ -n "$CXX" ]; then if check_cpp_compiler "$CXX"; then TOOLCHAIN_CXX=$CXX - TOOLCHAIN=`"$TEMP_DIR/checkcc"` - TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + parse_toolchain_properties "$TEMP_DIR/checkcc_out" echo "$CXX" return 0 else @@ -169,8 +192,8 @@ do if check_cpp_compiler "$COMP"; then TOOLCHAIN_CXX=$COMP - TOOLCHAIN=`"$TEMP_DIR/checkcc"` - TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + parse_toolchain_properties "$TEMP_DIR/checkcc_out" echo "$COMP" return 0 fi