make/toolchain.sh

changeset 87
84f94d476934
parent 86
db21aab20169
equal deleted inserted replaced
86:db21aab20169 87:84f94d476934
1 #!/bin/sh 1 #!/bin/sh
2 # 2 #
3 # toolchain detection 3 # toolchain detection
4 # 4 #
5 5
6 TAIL=tail 6 TAIL="tail"
7 if isplatform "bsd" && notisplatform "openbsd"; then 7 if isplatform "bsd" && notisplatform "openbsd"; then
8 C_COMPILERS="clang gcc cc" 8 C_COMPILERS="clang gcc cc"
9 CPP_COMPILERS="clang++ g++ CC" 9 CPP_COMPILERS="clang++ g++ CC"
10 elif isplatform "solaris"; then 10 elif isplatform "solaris"; then
11 C_COMPILERS="cc suncc gcc clang" 11 C_COMPILERS="cc suncc gcc clang"
22 unset TOOLCHAIN_CC 22 unset TOOLCHAIN_CC
23 unset TOOLCHAIN_CXX 23 unset TOOLCHAIN_CXX
24 24
25 check_c_compiler() 25 check_c_compiler()
26 { 26 {
27 command -v $1 2>&1 >/dev/null 27 if command -v "$1" >/dev/null 2>&1 ; then
28 if [ $? -ne 0 ]; then 28 :
29 else
29 return 1 30 return 1
30 fi 31 fi
31 cat > "$TEMP_DIR/test.c" << __EOF__ 32 cat > "$TEMP_DIR/test.c" << __EOF__
32 /* test file */ 33 /* test file */
33 #include <stdio.h> 34 #include <stdio.h>
34 int main(int argc, char **argv) { 35 int main(void) {
35 #if defined(_MSC_VER) 36 #if defined(_MSC_VER)
36 printf("toolchain:msc\n"); 37 printf("toolchain:msc\n");
37 #elif defined(__clang__) 38 #elif defined(__clang__)
38 printf("toolchain:clang gnuc\n"); 39 printf("toolchain:clang gnuc\n");
39 #elif defined(__GNUC__) 40 #elif defined(__GNUC__)
43 #else 44 #else
44 printf("toolchain:unknown\n"); 45 printf("toolchain:unknown\n");
45 #endif 46 #endif
46 printf("wsize:%d\n", (int)sizeof(void*)*8); 47 printf("wsize:%d\n", (int)sizeof(void*)*8);
47 #ifdef __STDC_VERSION__ 48 #ifdef __STDC_VERSION__
48 printf("stdcversion:%d\n", __STDC_VERSION__); 49 printf("stdcversion:%ld\n", (long int)__STDC_VERSION__);
49 #endif 50 #endif
50 return 0; 51 return 0;
51 } 52 }
52 __EOF__ 53 __EOF__
53 rm -f "$TEMP_DIR/checkcc" 54 rm -f "$TEMP_DIR/checkcc"
54 $1 -o "$TEMP_DIR/checkcc" $CFLAGS $LDFLAGS "$TEMP_DIR/test.c" 2> /dev/null 55 $1 -o "$TEMP_DIR/checkcc" $CFLAGS $LDFLAGS "$TEMP_DIR/test.c" 2> /dev/null
55 } 56 }
56 57
57 check_cpp_compiler() 58 check_cpp_compiler()
58 { 59 {
59 command -v $1 2>&1 >/dev/null 60 if command -v "$1" >/dev/null 2>&1 ; then
60 if [ $? -ne 0 ]; then 61 :
62 else
61 return 1 63 return 1
62 fi 64 fi
63 cat > "$TEMP_DIR/test.cpp" << __EOF__ 65 cat > "$TEMP_DIR/test.cpp" << __EOF__
64 /* test file */ 66 /* test file */
65 #include <iostream> 67 #include <iostream>
66 int main(int argc, char **argv) { 68 int main(void) {
67 #if defined(_MSC_VER) 69 #if defined(_MSC_VER)
68 std::cout << "toolchain:msc" << std::endl; 70 std::cout << "toolchain:msc" << std::endl;
69 #elif defined(__clang__) 71 #elif defined(__clang__)
70 std::cout << "toolchain:clang gnuc" << std::endl; 72 std::cout << "toolchain:clang gnuc" << std::endl;
71 #elif defined(__GNUC__) 73 #elif defined(__GNUC__)
79 return 0; 81 return 0;
80 } 82 }
81 __EOF__ 83 __EOF__
82 rm -f "$TEMP_DIR/checkcc" 84 rm -f "$TEMP_DIR/checkcc"
83 $1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null 85 $1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null
84 }
85
86 create_libtest_source()
87 {
88 # $1: filename
89 # $2: optional include
90 cat > "$TEMP_DIR/$1" << __EOF__
91 /* libtest file */
92 int main(int argc, char **argv) {
93 return 0;
94 }
95 __EOF__
96 if [ -n "$2" ]; then
97 echo "#include <$2>" >> "$TEMP_DIR/$1"
98 fi
99 } 86 }
100 87
101 parse_toolchain_properties() 88 parse_toolchain_properties()
102 { 89 {
103 info_file="$1" 90 info_file="$1"

mercurial