74 return 0; |
66 return 0; |
75 } |
67 } |
76 __EOF__ |
68 __EOF__ |
77 rm -f "$TEMP_DIR/checklib" |
69 rm -f "$TEMP_DIR/checklib" |
78 $TOOLCHAIN_LD -o "$TEMP_DIR/checklib" $CFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.c" 2> /dev/null |
70 $TOOLCHAIN_LD -o "$TEMP_DIR/checklib" $CFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.c" 2> /dev/null |
79 |
|
80 if [ $? -ne 0 ]; then |
|
81 return 1 |
|
82 fi |
|
83 return 0 |
|
84 } |
71 } |
85 |
72 |
86 printf "detect C compiler... " |
73 printf "detect C compiler... " |
87 |
74 |
88 for COMP in $C_COMPILERS |
75 if [ -n "$CC" ]; then |
89 do |
76 if check_c_compiler "$CC"; then |
90 check_c_compiler "$COMP" |
77 TOOLCHAIN_CC=$CC |
91 if [ $? -ne 0 ]; then |
78 TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"` |
92 if [ -n "$CC" ]; then |
79 echo $CC |
93 if [ "$COMP" = "$CC" ]; then |
80 else |
94 echo "$CC is not a working C compiler" |
81 echo "$CC is not a working C compiler" |
95 TOOLCHAIN_DETECTION_ERROR="error" |
82 TOOLCHAIN_ERROR="required C compiler not found" |
96 break |
83 fi |
97 fi |
84 else |
98 fi |
85 for COMP in $C_COMPILERS |
99 else |
86 do |
100 TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` |
87 if check_c_compiler "$COMP"; then |
101 USE_TOOLCHAIN=$TOOLCHAIN_NAME |
88 TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"` |
102 if [ "$COMP" = "cc" ]; then |
89 TOOLCHAIN_CC=$COMP |
103 # we have found a working compiler, but in case |
90 break |
104 # the compiler is gcc or clang, we try to use |
91 fi |
105 # these commands and not 'cc' |
92 done |
106 TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` |
93 echo ${TOOLCHAIN_CC:-"not found"} |
107 if [ "$TOOLCHAIN_NAME" = "gcc" ]; then |
|
108 check_c_compiler "gcc" |
|
109 if [ $? -eq 0 ]; then |
|
110 COMP=gcc |
|
111 USE_TOOLCHAIN="gcc" |
|
112 fi |
|
113 fi |
|
114 if [ "$TOOLCHAIN_NAME" = "clang" ]; then |
|
115 check_c_compiler "clang" |
|
116 if [ $? -eq 0 ]; then |
|
117 COMP=clang |
|
118 USE_TOOLCHAIN="clang" |
|
119 fi |
|
120 fi |
|
121 fi |
|
122 |
|
123 TOOLCHAIN_NAME=$USE_TOOLCHAIN |
|
124 TOOLCHAIN_CC=$COMP |
|
125 echo $COMP |
|
126 break |
|
127 fi |
|
128 done |
|
129 if [ -z "$TOOLCHAIN_CC" ]; then |
|
130 echo "not found" |
|
131 fi |
94 fi |
132 |
95 |
133 printf "detect C++ compiler... " |
96 printf "detect C++ compiler... " |
134 |
97 |
135 for COMP in $CPP_COMPILERS |
98 if [ -n "$CXX" ]; then |
136 do |
99 if check_cpp_compiler "$CXX"; then |
137 check_cpp_compiler "$COMP" |
100 TOOLCHAIN_CXX=$CXX |
138 if [ $? -ne 0 ]; then |
101 TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"` |
139 if [ -n "$CXX" ]; then |
102 echo $CXX |
140 if [ "$COMP" = "$CXX" ]; then |
103 else |
141 echo "$CXX is not a working C++ compiler" |
104 echo "$CXX is not a working C++ compiler" |
142 TOOLCHAIN_DETECTION_ERROR="error" |
105 TOOLCHAIN_ERROR="required C++ compiler not found" |
143 break |
106 fi |
144 fi |
107 else |
145 fi |
108 for COMP in $CPP_COMPILERS |
146 else |
109 do |
147 if [ $COMP = "CC" ]; then |
110 if check_cpp_compiler "$COMP"; then |
148 # we have found a working compiler, but in case |
111 TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"` |
149 # the compiler is gcc or clang, we try to use |
112 TOOLCHAIN_CXX=$COMP |
150 # these commands and not 'CC' |
113 break |
151 TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` |
114 fi |
152 USE_TOOLCHAIN=$TOOLCHAIN_NAME |
115 done |
153 if [ "$TOOLCHAIN_NAME" = "gcc" ]; then |
116 echo ${TOOLCHAIN_CXX:-"not found"} |
154 check_cpp_compiler "g++" |
|
155 if [ $? -eq 0 ]; then |
|
156 COMP=g++ |
|
157 USE_TOOLCHAIN="gcc" |
|
158 fi |
|
159 fi |
|
160 if [ "$TOOLCHAIN_NAME" = "clang" ]; then |
|
161 check_cpp_compiler "clang++" |
|
162 if [ $? -eq 0 ]; then |
|
163 COMP=clang++ |
|
164 USE_TOOLCHAIN="clang" |
|
165 fi |
|
166 fi |
|
167 fi |
|
168 |
|
169 TOOLCHAIN_NAME=$USE_TOOLCHAIN |
|
170 TOOLCHAIN_CXX=$COMP |
|
171 echo $COMP |
|
172 break |
|
173 fi |
|
174 done |
|
175 if [ -z "$TOOLCHAIN_CXX" ]; then |
|
176 echo "not found" |
|
177 fi |
117 fi |
178 |
118 |
|
119 printf "detect linker... " |
179 TOOLCHAIN_LD=$TOOLCHAIN_CC |
120 TOOLCHAIN_LD=$TOOLCHAIN_CC |
|
121 echo "$TOOLCHAIN_LD" |
180 |
122 |
181 if [ -z "$TOOLCHAIN_NAME" ]; then |
123 if [ -z "$TOOLCHAIN_NAME" ]; then |
182 TOOLCHAIN_DETECTION_ERROR="error" |
124 TOOLCHAIN_ERROR="no build tools detected" |
183 else |
125 else |
184 cat >> "$TEMP_DIR/config.mk" << __EOF__ |
126 cat >> "$TEMP_DIR/config.mk" << __EOF__ |
|
127 |
185 # toolchain |
128 # toolchain |
186 __EOF__ |
129 __EOF__ |
187 echo "CC = ${TOOLCHAIN_CC}" >> "$TEMP_DIR/config.mk" |
130 echo "CC = ${TOOLCHAIN_CC}" >> "$TEMP_DIR/config.mk" |
188 if [ -n "$TOOLCHAIN_CXX" ]; then |
131 if [ -n "$TOOLCHAIN_CXX" ]; then |
189 echo "CXX = ${TOOLCHAIN_CXX}" >> "$TEMP_DIR/config.mk" |
132 echo "CXX = ${TOOLCHAIN_CXX}" >> "$TEMP_DIR/config.mk" |