24 cat > "$TEMP_DIR/test.c" << __EOF__ |
24 cat > "$TEMP_DIR/test.c" << __EOF__ |
25 /* test file */ |
25 /* test file */ |
26 #include <stdio.h> |
26 #include <stdio.h> |
27 int main(int argc, char **argv) { |
27 int main(int argc, char **argv) { |
28 #if defined(_MSC_VER) |
28 #if defined(_MSC_VER) |
29 printf("msc\n"); |
29 printf("toolchain:msc\n"); |
30 #elif defined(__clang__) |
30 #elif defined(__clang__) |
31 printf("clang gnuc\n"); |
31 printf("toolchain:clang gnuc\n"); |
32 #elif defined(__GNUC__) |
32 #elif defined(__GNUC__) |
33 printf("gcc gnuc\n"); |
33 printf("toolchain:gcc gnuc\n"); |
34 #elif defined(__sun) |
34 #elif defined(__sun) |
35 printf("suncc\n"); |
35 printf("toolchain:suncc\n"); |
36 #else |
36 #else |
37 printf("unknown\n"); |
37 printf("toolchain:unknown\n"); |
|
38 #endif |
|
39 printf("wsize:%d\n", (int)sizeof(void*)*8); |
|
40 #ifdef __STDC_VERSION__ |
|
41 printf("stdcversion:%d\n", __STDC_VERSION__); |
38 #endif |
42 #endif |
39 return 0; |
43 return 0; |
40 } |
44 } |
41 __EOF__ |
45 __EOF__ |
42 rm -f "$TEMP_DIR/checkcc" |
46 rm -f "$TEMP_DIR/checkcc" |
52 cat > "$TEMP_DIR/test.cpp" << __EOF__ |
56 cat > "$TEMP_DIR/test.cpp" << __EOF__ |
53 /* test file */ |
57 /* test file */ |
54 #include <iostream> |
58 #include <iostream> |
55 int main(int argc, char **argv) { |
59 int main(int argc, char **argv) { |
56 #if defined(_MSC_VER) |
60 #if defined(_MSC_VER) |
57 std::cout << "msc" << std::endl; |
61 std::cout << "toolchain:msc" << std::endl; |
58 #elif defined(__clang__) |
62 #elif defined(__clang__) |
59 std::cout << "clang gnuc" << std::endl; |
63 std::cout << "toolchain:clang gnuc" << std::endl; |
60 #elif defined(__GNUC__) |
64 #elif defined(__GNUC__) |
61 std::cout << "gcc gnuc" << std::endl; |
65 std::cout << "toolchain:gcc gnuc" << std::endl; |
62 #elif defined(__sun) |
66 #elif defined(__sun) |
63 std::cout << "suncc" << std::endl; |
67 std::cout << "toolchain:suncc" << std::endl; |
64 #else |
68 #else |
65 std::cout << "cc" << std::endl; |
69 std::cout << "toolchain:unknown" << std::endl; |
66 #endif |
70 #endif |
|
71 std:cout << "wsize:" << sizeof(void*)*8 << std::endl; |
67 return 0; |
72 return 0; |
68 } |
73 } |
69 __EOF__ |
74 __EOF__ |
70 rm -f "$TEMP_DIR/checkcc" |
75 rm -f "$TEMP_DIR/checkcc" |
71 $1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null |
76 $1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null |
128 fi |
133 fi |
129 printf "detect C compiler... " |
134 printf "detect C compiler... " |
130 if [ -n "$CC" ]; then |
135 if [ -n "$CC" ]; then |
131 if check_c_compiler "$CC"; then |
136 if check_c_compiler "$CC"; then |
132 TOOLCHAIN_CC=$CC |
137 TOOLCHAIN_CC=$CC |
133 TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
138 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" |
|
139 TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` |
134 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
140 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
|
141 TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7` |
|
142 TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` |
135 echo "$CC" |
143 echo "$CC" |
136 return 0 |
144 return 0 |
137 else |
145 else |
138 echo "$CC is not a working C compiler" |
146 echo "$CC is not a working C compiler" |
139 return 1 |
147 return 1 |
141 else |
149 else |
142 for COMP in $C_COMPILERS |
150 for COMP in $C_COMPILERS |
143 do |
151 do |
144 if check_c_compiler "$COMP"; then |
152 if check_c_compiler "$COMP"; then |
145 TOOLCHAIN_CC=$COMP |
153 TOOLCHAIN_CC=$COMP |
146 TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
154 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" |
|
155 TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` |
147 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
156 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
|
157 TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7` |
|
158 TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` |
148 echo "$COMP" |
159 echo "$COMP" |
149 return 0 |
160 return 0 |
150 fi |
161 fi |
151 done |
162 done |
152 echo "not found" |
163 echo "not found" |
162 printf "detect C++ compiler... " |
173 printf "detect C++ compiler... " |
163 |
174 |
164 if [ -n "$CXX" ]; then |
175 if [ -n "$CXX" ]; then |
165 if check_cpp_compiler "$CXX"; then |
176 if check_cpp_compiler "$CXX"; then |
166 TOOLCHAIN_CXX=$CXX |
177 TOOLCHAIN_CXX=$CXX |
167 TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
178 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" |
|
179 TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` |
168 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
180 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
169 echo "$CXX" |
181 echo "$CXX" |
170 return 0 |
182 return 0 |
171 else |
183 else |
172 echo "$CXX is not a working C++ compiler" |
184 echo "$CXX is not a working C++ compiler" |