test/make/toolchain.sh

changeset 153
751b3209bdb0
parent 140
f453503e09dc
child 154
121757311440
equal deleted inserted replaced
152:c42810d73d88 153:751b3209bdb0
1 #!/bin/sh 1 #!/bin/sh
2 # 2 #
3 # toolchain detection 3 # toolchain detection
4 # 4 #
5 5
6 TAIL=tail
6 if isplatform "bsd" && notisplatform "openbsd"; then 7 if isplatform "bsd" && notisplatform "openbsd"; then
7 C_COMPILERS="clang gcc cc" 8 C_COMPILERS="clang gcc cc"
8 CPP_COMPILERS="clang++ g++ CC" 9 CPP_COMPILERS="clang++ g++ CC"
10 elif isplatform "solaris"; then
11 C_COMPILERS="cc suncc gcc clang"
12 CPP_COMPILERS="CC sunCC g++ clang++"
13 if [ -f /usr/xpg4/bin/tail ]; then
14 TAIL=/usr/xpg4/bin/tail
15 fi
9 else 16 else
10 C_COMPILERS="gcc clang suncc cc" 17 C_COMPILERS="gcc clang cc"
11 CPP_COMPILERS="g++ clang++ sunCC CC" 18 CPP_COMPILERS="g++ clang++ c++"
12 fi 19 fi
13 unset TOOLCHAIN 20 unset TOOLCHAIN
14 unset TOOLCHAIN_NAME 21 unset TOOLCHAIN_NAME
15 unset TOOLCHAIN_CC 22 unset TOOLCHAIN_CC
16 unset TOOLCHAIN_CXX 23 unset TOOLCHAIN_CXX
127 } 134 }
128 135
129 parse_toolchain_properties() 136 parse_toolchain_properties()
130 { 137 {
131 info_file="$1" 138 info_file="$1"
132 TOOLCHAIN=`grep '^toolchain:' "$info_file" | tail -c +11` 139 TOOLCHAIN=`grep '^toolchain:' "$info_file" | $TAIL -c +11`
133 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` 140 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -`
134 TOOLCHAIN_WSIZE=`grep '^wsize:' "$info_file" | tail -c +7` 141 TOOLCHAIN_WSIZE=`grep '^wsize:' "$info_file" | $TAIL -c +7`
135 } 142 }
136 143
137 detect_c_compiler() 144 detect_c_compiler()
138 { 145 {
139 if [ -n "$TOOLCHAIN_CC" ]; then 146 if [ -n "$TOOLCHAIN_CC" ]; then
143 if [ -n "$CC" ]; then 150 if [ -n "$CC" ]; then
144 if check_c_compiler "$CC"; then 151 if check_c_compiler "$CC"; then
145 TOOLCHAIN_CC=$CC 152 TOOLCHAIN_CC=$CC
146 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" 153 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
147 parse_toolchain_properties "$TEMP_DIR/checkcc_out" 154 parse_toolchain_properties "$TEMP_DIR/checkcc_out"
148 TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` 155 TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | $TAIL -c +13`
149 echo "$CC" 156 echo "$CC"
150 return 0 157 return 0
151 else 158 else
152 echo "$CC is not a working C compiler" 159 echo "$CC is not a working C compiler"
153 return 1 160 return 1
157 do 164 do
158 if check_c_compiler "$COMP"; then 165 if check_c_compiler "$COMP"; then
159 TOOLCHAIN_CC=$COMP 166 TOOLCHAIN_CC=$COMP
160 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" 167 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
161 parse_toolchain_properties "$TEMP_DIR/checkcc_out" 168 parse_toolchain_properties "$TEMP_DIR/checkcc_out"
162 TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` 169 TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | $TAIL -c +13`
163 echo "$COMP" 170 echo "$COMP"
164 return 0 171 return 0
165 fi 172 fi
166 done 173 done
167 echo "not found" 174 echo "not found"

mercurial