]>
Commit | Line | Data |
---|---|---|
2038f8c8 PB |
1 | #! /bin/sh |
2 | ||
3 | if test -z "$source_path"; then | |
4 | echo Do not invoke this script directly. It is called | |
5 | echo automatically by configure. | |
6 | exit 1 | |
7 | fi | |
8 | ||
9 | write_c_skeleton() { | |
10 | cat > $TMPC <<EOF | |
11 | int main(void) { return 0; } | |
12 | EOF | |
13 | } | |
14 | ||
15 | has() { | |
16 | command -v "$1" >/dev/null 2>&1 | |
17 | } | |
18 | ||
19 | do_compiler() { | |
20 | # Run the compiler, capturing its output to the log. First argument | |
21 | # is compiler binary to execute. | |
22 | local compiler="$1" | |
23 | shift | |
24 | if test -n "$BASH_VERSION"; then eval ' | |
25 | echo >>config.log " | |
26 | funcs: ${FUNCNAME[*]} | |
27 | lines: ${BASH_LINENO[*]}" | |
28 | '; fi | |
29 | echo $compiler "$@" >> config.log | |
30 | $compiler "$@" >> config.log 2>&1 || return $? | |
31 | } | |
32 | ||
33 | ||
34 | TMPDIR1="config-temp" | |
35 | TMPC="${TMPDIR1}/qemu-conf.c" | |
36 | TMPE="${TMPDIR1}/qemu-conf.exe" | |
37 | ||
38 | container="no" | |
afc3a8f9 AB |
39 | if test $use_containers = "yes"; then |
40 | if has "docker" || has "podman"; then | |
41 | container=$($python $source_path/tests/docker/docker.py probe) | |
42 | fi | |
2038f8c8 PB |
43 | fi |
44 | ||
45 | # cross compilers defaults, can be overridden with --cross-cc-ARCH | |
46 | : ${cross_cc_aarch64="aarch64-linux-gnu-gcc"} | |
47 | : ${cross_cc_aarch64_be="$cross_cc_aarch64"} | |
48 | : ${cross_cc_cflags_aarch64_be="-mbig-endian"} | |
49 | : ${cross_cc_arm="arm-linux-gnueabihf-gcc"} | |
50 | : ${cross_cc_cflags_armeb="-mbig-endian"} | |
51 | : ${cross_cc_i386="i386-pc-linux-gnu-gcc"} | |
52 | : ${cross_cc_cflags_i386="-m32"} | |
53 | : ${cross_cc_x86_64="x86_64-pc-linux-gnu-gcc"} | |
54 | : ${cross_cc_cflags_x86_64="-m64"} | |
55 | : ${cross_cc_ppc="powerpc-linux-gnu-gcc"} | |
56 | : ${cross_cc_cflags_ppc="-m32"} | |
57 | : ${cross_cc_ppc64="powerpc-linux-gnu-gcc"} | |
58 | : ${cross_cc_cflags_ppc64="-m64"} | |
59 | : ${cross_cc_ppc64le="powerpc64le-linux-gnu-gcc"} | |
60 | : ${cross_cc_cflags_s390x="-m64"} | |
61 | : ${cross_cc_cflags_sparc="-m32 -mv8plus -mcpu=ultrasparc"} | |
62 | : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"} | |
63 | ||
64 | for target in $target_list; do | |
65 | arch=${target%%-*} | |
66 | case $arch in | |
67 | arm|armeb) | |
68 | arches=arm | |
69 | ;; | |
70 | aarch64|aarch64_be) | |
71 | arches="aarch64 arm" | |
72 | ;; | |
73 | mips*) | |
74 | arches=mips | |
75 | ;; | |
76 | ppc*) | |
77 | arches=ppc | |
78 | ;; | |
79 | sh4|sh4eb) | |
80 | arches=sh4 | |
81 | ;; | |
82 | x86_64) | |
83 | arches="x86_64 i386" | |
84 | ;; | |
85 | xtensa|xtensaeb) | |
86 | arches=xtensa | |
87 | ;; | |
88 | alpha|cris|hppa|i386|lm32|m68k|openrisc|riscv64|s390x|sh4|sparc64) | |
89 | arches=$target | |
90 | ;; | |
91 | *) | |
92 | continue | |
93 | ;; | |
94 | esac | |
95 | ||
96 | container_image= | |
97 | case $target in | |
98 | aarch64-*) | |
99 | # We don't have any bigendian build tools so we only use this for AArch64 | |
18b6be43 | 100 | container_image=debian-arm64-cross |
2038f8c8 PB |
101 | container_cross_cc=aarch64-linux-gnu-gcc |
102 | ;; | |
103 | alpha-*) | |
104 | container_image=debian-alpha-cross | |
105 | container_cross_cc=alpha-linux-gnu-gcc | |
106 | ;; | |
107 | arm-*) | |
108 | # We don't have any bigendian build tools so we only use this for ARM | |
109 | container_image=debian-armhf-cross | |
110 | container_cross_cc=arm-linux-gnueabihf-gcc | |
111 | ;; | |
112 | cris-*) | |
113 | container_image=fedora-cris-cross | |
114 | container_cross_cc=cris-linux-gnu-gcc | |
115 | ;; | |
116 | hppa-*) | |
117 | container_image=debian-hppa-cross | |
118 | container_cross_cc=hppa-linux-gnu-gcc | |
119 | ;; | |
120 | i386-*) | |
121 | container_image=fedora-i386-cross | |
122 | container_cross_cc=gcc | |
123 | ;; | |
124 | m68k-*) | |
125 | container_image=debian-m68k-cross | |
126 | container_cross_cc=m68k-linux-gnu-gcc | |
127 | ;; | |
128 | mips64el-*) | |
129 | container_image=debian-mips64el-cross | |
130 | container_cross_cc=mips64el-linux-gnuabi64-gcc | |
131 | ;; | |
132 | mips64-*) | |
133 | container_image=debian-mips64-cross | |
134 | container_cross_cc=mips64-linux-gnuabi64-gcc | |
135 | ;; | |
136 | mipsel-*) | |
137 | container_image=debian-mipsel-cross | |
138 | container_cross_cc=mipsel-linux-gnu-gcc | |
139 | ;; | |
140 | mips-*) | |
141 | container_image=debian-mips-cross | |
142 | container_cross_cc=mips-linux-gnu-gcc | |
143 | ;; | |
144 | ppc-*|ppc64abi32-*) | |
145 | container_image=debian-powerpc-cross | |
146 | container_cross_cc=powerpc-linux-gnu-gcc | |
147 | ;; | |
148 | ppc64-*) | |
149 | container_image=debian-ppc64-cross | |
150 | container_cross_cc=powerpc64-linux-gnu-gcc | |
151 | ;; | |
152 | ppc64le-*) | |
153 | container_image=debian-ppc64el-cross | |
154 | container_cross_cc=powerpc64le-linux-gnu-gcc | |
155 | ;; | |
156 | riscv64-*) | |
157 | container_image=debian-riscv64-cross | |
158 | container_cross_cc=riscv64-linux-gnu-gcc | |
159 | ;; | |
160 | s390x-*) | |
161 | container_image=debian-s390x-cross | |
162 | container_cross_cc=s390x-linux-gnu-gcc | |
163 | ;; | |
164 | sh4-*) | |
165 | container_image=debian-sh4-cross | |
166 | container_cross_cc=sh4-linux-gnu-gcc | |
167 | ;; | |
168 | sparc64-*) | |
169 | container_image=debian-sparc64-cross | |
170 | container_cross_cc=sparc64-linux-gnu-gcc | |
171 | ;; | |
172 | xtensa*-softmmu) | |
173 | container_image=debian-xtensa-cross | |
174 | ||
175 | # default to the dc232b cpu | |
176 | container_cross_cc=/opt/2018.02/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-gcc | |
177 | ;; | |
178 | esac | |
179 | ||
180 | config_target_mak=tests/tcg/config-$target.mak | |
181 | ||
182 | echo "# Automatically generated by configure - do not modify" > $config_target_mak | |
183 | echo "TARGET_NAME=$arch" >> $config_target_mak | |
184 | case $target in | |
185 | *-linux-user | *-bsd-user) | |
186 | echo "CONFIG_USER_ONLY=y" >> $config_target_mak | |
187 | echo "QEMU=\$(BUILD_DIR)/$target/qemu-$arch" >> $config_target_mak | |
188 | ;; | |
189 | *-softmmu) | |
190 | echo "CONFIG_SOFTMMU=y" >> $config_target_mak | |
191 | echo "QEMU=\$(BUILD_DIR)/$target/qemu-system-$arch" >> $config_target_mak | |
192 | ;; | |
193 | esac | |
194 | ||
195 | eval "target_compiler_cflags=\${cross_cc_cflags_$arch}" | |
196 | echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak | |
197 | ||
198 | got_cross_cc=no | |
199 | for i in $arch $arches; do | |
200 | if eval test "x\${cross_cc_$i+yes}" != xyes; then | |
201 | continue | |
202 | fi | |
203 | ||
204 | eval "target_compiler=\${cross_cc_$i}" | |
205 | if ! has $target_compiler; then | |
206 | continue | |
207 | fi | |
208 | write_c_skeleton | |
209 | if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then | |
210 | # For host systems we might get away with building without -static | |
211 | if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then | |
212 | continue | |
213 | fi | |
214 | echo "CROSS_CC_GUEST_STATIC=y" >> $config_target_mak | |
215 | else | |
216 | echo "CROSS_CC_GUEST_STATIC=y" >> $config_target_mak | |
217 | fi | |
218 | echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak | |
ded663a2 AB |
219 | |
220 | # Test for compiler features for optional tests. We only do this | |
221 | # for cross compilers because ensuring the docker containers based | |
222 | # compilers is a requirememt for adding a new test that needs a | |
223 | # compiler feature. | |
224 | case $target in | |
225 | aarch64-*) | |
226 | if do_compiler "$target_compiler" $target_compiler_cflags \ | |
227 | -march=armv8.1-a+sve -o $TMPE $TMPC; then | |
228 | echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak | |
229 | fi | |
230 | ;; | |
231 | esac | |
232 | ||
2038f8c8 PB |
233 | enabled_cross_compilers="$enabled_cross_compilers $target_compiler" |
234 | got_cross_cc=yes | |
235 | break | |
236 | done | |
237 | ||
238 | if test $got_cross_cc = no && test "$container" != no && test -n "$container_image"; then | |
239 | echo "DOCKER_IMAGE=$container_image" >> $config_target_mak | |
240 | echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak | |
241 | fi | |
242 | done | |
243 | ||
244 | # report container support state | |
245 | echo "cross containers $container" | |
246 | ||
247 | if test -n "$enabled_cross_compilers"; then | |
248 | echo | |
249 | echo "NOTE: guest cross-compilers enabled:$enabled_cross_compilers" | |
250 | fi |