target/mips/rel6_translate: Change license to GNU LGPL v2.1 (or later)
[qemu/ar7.git] / tests / tcg / configure.sh
blobfa1a4261a44f8be80a0edd50b799f77499e281ef
1 #! /bin/sh
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
9 write_c_skeleton() {
10 cat > $TMPC <<EOF
11 int main(void) { return 0; }
12 EOF
15 has() {
16 command -v "$1" >/dev/null 2>&1
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 $?
34 TMPDIR1="config-temp"
35 TMPC="${TMPDIR1}/qemu-conf.c"
36 TMPE="${TMPDIR1}/qemu-conf.exe"
38 container="no"
39 if test $use_containers = "yes"; then
40 if has "docker" || has "podman"; then
41 container=$($python $source_path/tests/docker/docker.py probe)
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_alpha="alpha-linux-gnu-gcc")
50 : ${cross_cc_arm="arm-linux-gnueabihf-gcc"}
51 : ${cross_cc_cflags_armeb="-mbig-endian"}
52 : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
53 : ${cross_cc_cflags_hexagon="-mv67 -O2 -static"}
54 : ${cross_cc_hppa="hppa-linux-gnu-gcc"}
55 : ${cross_cc_i386="i686-linux-gnu-gcc"}
56 : ${cross_cc_cflags_i386="-m32"}
57 : ${cross_cc_m68k="m68k-linux-gnu-gcc"}
58 : $(cross_cc_mips64el="mips64el-linux-gnuabi64-gcc")
59 : $(cross_cc_mips64="mips64-linux-gnuabi64-gcc")
60 : $(cross_cc_mipsel="mipsel-linux-gnu-gcc")
61 : $(cross_cc_mips="mips-linux-gnu-gcc")
62 : ${cross_cc_ppc="powerpc-linux-gnu-gcc"}
63 : ${cross_cc_cflags_ppc="-m32"}
64 : ${cross_cc_ppc64="powerpc64-linux-gnu-gcc"}
65 : ${cross_cc_ppc64le="powerpc64le-linux-gnu-gcc"}
66 : $(cross_cc_riscv64="riscv64-linux-gnu-gcc")
67 : ${cross_cc_s390x="s390x-linux-gnu-gcc"}
68 : $(cross_cc_sh4="sh4-linux-gnu-gcc")
69 : ${cross_cc_cflags_sparc="-m32 -mv8plus -mcpu=ultrasparc"}
70 : ${cross_cc_sparc64="sparc64-linux-gnu-gcc"}
71 : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
72 : ${cross_cc_x86_64="x86_64-linux-gnu-gcc"}
73 : ${cross_cc_cflags_x86_64="-m64"}
75 for target in $target_list; do
76 arch=${target%%-*}
77 case $arch in
78 arm|armeb)
79 arches=arm
81 aarch64|aarch64_be)
82 arches="aarch64 arm"
84 mips*)
85 arches=mips
87 ppc*)
88 arches=ppc
90 sh4|sh4eb)
91 arches=sh4
93 x86_64)
94 arches="x86_64 i386"
96 xtensa|xtensaeb)
97 arches=xtensa
99 alpha|cris|hexagon|hppa|i386|lm32|microblaze|microblazeel|m68k|openrisc|riscv64|s390x|sh4|sparc64)
100 arches=$target
103 continue
105 esac
107 container_image=
108 case $target in
109 aarch64-*)
110 # We don't have any bigendian build tools so we only use this for AArch64
111 container_hosts="x86_64 aarch64"
112 container_image=debian-arm64-test-cross
113 container_cross_cc=aarch64-linux-gnu-gcc-10
115 alpha-*)
116 container_hosts=x86_64
117 container_image=debian-alpha-cross
118 container_cross_cc=alpha-linux-gnu-gcc
120 arm-*)
121 # We don't have any bigendian build tools so we only use this for ARM
122 container_hosts="x86_64 aarch64"
123 container_image=debian-armhf-cross
124 container_cross_cc=arm-linux-gnueabihf-gcc
126 cris-*)
127 container_hosts=x86_64
128 container_image=fedora-cris-cross
129 container_cross_cc=cris-linux-gnu-gcc
131 hppa-*)
132 container_hosts=x86_64
133 container_image=debian-hppa-cross
134 container_cross_cc=hppa-linux-gnu-gcc
136 i386-*)
137 container_hosts=x86_64
138 container_image=fedora-i386-cross
139 container_cross_cc=gcc
141 m68k-*)
142 container_hosts=x86_64
143 container_image=debian-m68k-cross
144 container_cross_cc=m68k-linux-gnu-gcc
146 mips64el-*)
147 container_hosts=x86_64
148 container_image=debian-mips64el-cross
149 container_cross_cc=mips64el-linux-gnuabi64-gcc
151 mips64-*)
152 container_hosts=x86_64
153 container_image=debian-mips64-cross
154 container_cross_cc=mips64-linux-gnuabi64-gcc
156 mipsel-*)
157 container_hosts=x86_64
158 container_image=debian-mipsel-cross
159 container_cross_cc=mipsel-linux-gnu-gcc
161 mips-*)
162 container_hosts=x86_64
163 container_image=debian-mips-cross
164 container_cross_cc=mips-linux-gnu-gcc
166 ppc-*|ppc64abi32-*)
167 container_hosts=x86_64
168 container_image=debian-powerpc-cross
169 container_cross_cc=powerpc-linux-gnu-gcc
171 ppc64-*)
172 container_hosts=x86_64
173 container_image=debian-ppc64-cross
174 container_cross_cc=powerpc64-linux-gnu-gcc
176 ppc64le-*)
177 container_hosts=x86_64
178 container_image=debian-ppc64el-cross
179 container_cross_cc=powerpc64le-linux-gnu-gcc
181 riscv64-*)
182 container_hosts=x86_64
183 container_image=debian-riscv64-cross
184 container_cross_cc=riscv64-linux-gnu-gcc
186 s390x-*)
187 container_hosts=x86_64
188 container_image=debian-s390x-cross
189 container_cross_cc=s390x-linux-gnu-gcc
191 sh4-*)
192 container_hosts=x86_64
193 container_image=debian-sh4-cross
194 container_cross_cc=sh4-linux-gnu-gcc
196 sparc64-*)
197 container_hosts=x86_64
198 container_image=debian-sparc64-cross
199 container_cross_cc=sparc64-linux-gnu-gcc
201 x86_64-*)
202 container_hosts="aarch64 ppc64el x86_64"
203 container_image=debian-amd64-cross
204 container_cross_cc=x86_64-linux-gnu-gcc
206 xtensa*-softmmu)
207 container_hosts=x86_64
208 container_image=debian-xtensa-cross
210 # default to the dc232b cpu
211 container_cross_cc=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-gcc
213 esac
215 config_target_mak=tests/tcg/config-$target.mak
217 echo "# Automatically generated by configure - do not modify" > $config_target_mak
218 echo "TARGET_NAME=$arch" >> $config_target_mak
219 case $target in
220 *-linux-user | *-bsd-user)
221 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
222 echo "QEMU=$PWD/qemu-$arch" >> $config_target_mak
224 *-softmmu)
225 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
226 echo "QEMU=$PWD/qemu-system-$arch" >> $config_target_mak
228 esac
230 eval "target_compiler_cflags=\${cross_cc_cflags_$arch}"
231 echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
233 got_cross_cc=no
234 for i in $arch $arches; do
235 if eval test "x\${cross_cc_$i+yes}" != xyes; then
236 continue
239 eval "target_compiler=\${cross_cc_$i}"
240 if ! has $target_compiler; then
241 continue
243 write_c_skeleton
244 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
245 # For host systems we might get away with building without -static
246 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
247 continue
249 echo "CROSS_CC_GUEST_STATIC=y" >> $config_target_mak
250 else
251 echo "CROSS_CC_GUEST_STATIC=y" >> $config_target_mak
253 echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak
255 # Test for compiler features for optional tests. We only do this
256 # for cross compilers because ensuring the docker containers based
257 # compilers is a requirememt for adding a new test that needs a
258 # compiler feature.
259 case $target in
260 aarch64-*)
261 if do_compiler "$target_compiler" $target_compiler_cflags \
262 -march=armv8.1-a+sve -o $TMPE $TMPC; then
263 echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak
265 if do_compiler "$target_compiler" $target_compiler_cflags \
266 -march=armv8.3-a -o $TMPE $TMPC; then
267 echo "CROSS_CC_HAS_ARMV8_3=y" >> $config_target_mak
269 if do_compiler "$target_compiler" $target_compiler_cflags \
270 -mbranch-protection=standard -o $TMPE $TMPC; then
271 echo "CROSS_CC_HAS_ARMV8_BTI=y" >> $config_target_mak
273 if do_compiler "$target_compiler" $target_compiler_cflags \
274 -march=armv8.5-a+memtag -o $TMPE $TMPC; then
275 echo "CROSS_CC_HAS_ARMV8_MTE=y" >> $config_target_mak
278 ppc*)
279 if do_compiler "$target_compiler" $target_compiler_cflags \
280 -mpower8-vector -o $TMPE $TMPC; then
281 echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak
284 i386-linux-user)
285 if do_compiler "$target_compiler" $target_compiler_cflags \
286 -Werror -fno-pie -o $TMPE $TMPC; then
287 echo "CROSS_CC_HAS_I386_NOPIE=y" >> $config_target_mak
290 esac
292 enabled_cross_compilers="$enabled_cross_compilers $target_compiler"
293 got_cross_cc=yes
294 break
295 done
297 if test $got_cross_cc = no && test "$container" != no && test -n "$container_image"; then
298 for host in $container_hosts; do
299 if test "$host" = "$ARCH"; then
300 echo "DOCKER_IMAGE=$container_image" >> $config_target_mak
301 echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak
303 done
305 done