]> git.proxmox.com Git - mirror_qemu.git/blame - configure
ui: fix dcl unregister
[mirror_qemu.git] / configure
CommitLineData
7d13299d
FB
1#!/bin/sh
2#
3ef693a0 3# qemu configure script (c) 2003 Fabrice Bellard
7d13299d 4#
8cd05ab6 5
99519e67
CH
6# Unset some variables known to interfere with behavior of common tools,
7# just as autoconf does.
8CLICOLOR_FORCE= GREP_OPTIONS=
9unset CLICOLOR_FORCE GREP_OPTIONS
10
5e4dfd3d
JS
11# Don't allow CCACHE, if present, to use cached results of compile tests!
12export CCACHE_RECACHE=yes
13
8cd05ab6
PM
14# Temporary directory used for files created while
15# configure runs. Since it is in the build directory
16# we can safely blow away any previous version of it
17# (and we need not jump through hoops to try to delete
18# it when configure exits.)
19TMPDIR1="config-temp"
20rm -rf "${TMPDIR1}"
21mkdir -p "${TMPDIR1}"
22if [ $? -ne 0 ]; then
23 echo "ERROR: failed to create temporary directory"
24 exit 1
7d13299d
FB
25fi
26
8cd05ab6
PM
27TMPB="qemu-conf"
28TMPC="${TMPDIR1}/${TMPB}.c"
66518bf6 29TMPO="${TMPDIR1}/${TMPB}.o"
9c83ffd8 30TMPCXX="${TMPDIR1}/${TMPB}.cxx"
8cd05ab6 31TMPE="${TMPDIR1}/${TMPB}.exe"
6969ec6c 32TMPMO="${TMPDIR1}/${TMPB}.mo"
7d13299d 33
da1d85e3 34rm -f config.log
9ac81bbb 35
b48e3611
PM
36# Print a helpful header at the top of config.log
37echo "# QEMU configure log $(date)" >> config.log
979ae168
PM
38printf "# Configured with:" >> config.log
39printf " '%s'" "$0" "$@" >> config.log
40echo >> config.log
b48e3611
PM
41echo "#" >> config.log
42
d880a3ba
PB
43print_error() {
44 (echo
76ad07a4
PM
45 echo "ERROR: $1"
46 while test -n "$2"; do
47 echo " $2"
48 shift
49 done
d880a3ba
PB
50 echo) >&2
51}
52
53error_exit() {
54 print_error "$@"
76ad07a4
PM
55 exit 1
56}
57
9c83ffd8
PM
58do_compiler() {
59 # Run the compiler, capturing its output to the log. First argument
60 # is compiler binary to execute.
61 local compiler="$1"
62 shift
63 echo $compiler "$@" >> config.log
64 $compiler "$@" >> config.log 2>&1 || return $?
8dc38a78
PM
65 # Test passed. If this is an --enable-werror build, rerun
66 # the test with -Werror and bail out if it fails. This
67 # makes warning-generating-errors in configure test code
68 # obvious to developers.
69 if test "$werror" != "yes"; then
70 return 0
71 fi
72 # Don't bother rerunning the compile if we were already using -Werror
73 case "$*" in
74 *-Werror*)
75 return 0
76 ;;
77 esac
9c83ffd8
PM
78 echo $compiler -Werror "$@" >> config.log
79 $compiler -Werror "$@" >> config.log 2>&1 && return $?
76ad07a4
PM
80 error_exit "configure test passed without -Werror but failed with -Werror." \
81 "This is probably a bug in the configure script. The failing command" \
82 "will be at the bottom of config.log." \
83 "You can run configure with --disable-werror to bypass this check."
8dc38a78
PM
84}
85
9c83ffd8
PM
86do_cc() {
87 do_compiler "$cc" "$@"
88}
89
90do_cxx() {
91 do_compiler "$cxx" "$@"
92}
93
94update_cxxflags() {
95 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
96 # options which some versions of GCC's C++ compiler complain about
97 # because they only make sense for C programs.
11cde1c8
BD
98 QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
99
9c83ffd8
PM
100 for arg in $QEMU_CFLAGS; do
101 case $arg in
102 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
103 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
104 ;;
105 *)
106 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
107 ;;
108 esac
109 done
110}
111
52166aa0 112compile_object() {
fd0e6053
JS
113 local_cflags="$1"
114 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
52166aa0
JQ
115}
116
117compile_prog() {
118 local_cflags="$1"
119 local_ldflags="$2"
8dc38a78 120 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
52166aa0
JQ
121}
122
11568d6d
PB
123# symbolically link $1 to $2. Portable version of "ln -sf".
124symlink() {
72b8b5a1 125 rm -rf "$2"
ec5b06d7 126 mkdir -p "$(dirname "$2")"
72b8b5a1 127 ln -s "$1" "$2"
11568d6d
PB
128}
129
0dba6195
LM
130# check whether a command is available to this shell (may be either an
131# executable or a builtin)
132has() {
133 type "$1" >/dev/null 2>&1
134}
135
136# search for an executable in PATH
137path_of() {
138 local_command="$1"
139 local_ifs="$IFS"
140 local_dir=""
141
142 # pathname has a dir component?
143 if [ "${local_command#*/}" != "$local_command" ]; then
144 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
145 echo "$local_command"
146 return 0
147 fi
148 fi
149 if [ -z "$local_command" ]; then
150 return 1
151 fi
152
153 IFS=:
154 for local_dir in $PATH; do
155 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
156 echo "$local_dir/$local_command"
157 IFS="${local_ifs:-$(printf ' \t\n')}"
158 return 0
159 fi
160 done
161 # not found
162 IFS="${local_ifs:-$(printf ' \t\n')}"
163 return 1
164}
165
5b808275
LV
166have_backend () {
167 echo "$trace_backends" | grep "$1" >/dev/null
168}
169
3b6b7550
PB
170glob() {
171 eval test -z '"${1#'"$2"'}"'
172}
173
174supported_hax_target() {
175 test "$hax" = "yes" || return 1
176 glob "$1" "*-softmmu" || return 1
177 case "${1%-softmmu}" in
178 i386|x86_64)
179 return 0
180 ;;
181 esac
182 return 1
183}
184
185supported_kvm_target() {
186 test "$kvm" = "yes" || return 1
187 glob "$1" "*-softmmu" || return 1
188 case "${1%-softmmu}:$cpu" in
189 arm:arm | aarch64:aarch64 | \
190 i386:i386 | i386:x86_64 | i386:x32 | \
191 x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
192 mips:mips | mipsel:mips | \
193 ppc:ppc | ppcemb:ppc | ppc64:ppc | \
194 ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
195 s390x:s390x)
196 return 0
197 ;;
198 esac
199 return 1
200}
201
202supported_xen_target() {
203 test "$xen" = "yes" || return 1
204 glob "$1" "*-softmmu" || return 1
b5ed2e11
PB
205 # Only i386 and x86_64 provide the xenpv machine.
206 case "${1%-softmmu}" in
207 i386|x86_64)
3b6b7550
PB
208 return 0
209 ;;
210 esac
211 return 1
212}
213
d880a3ba
PB
214supported_target() {
215 case "$1" in
216 *-softmmu)
217 ;;
218 *-linux-user)
219 if test "$linux" != "yes"; then
220 print_error "Target '$target' is only available on a Linux host"
221 return 1
222 fi
223 ;;
224 *-bsd-user)
225 if test "$bsd" != "yes"; then
226 print_error "Target '$target' is only available on a BSD host"
227 return 1
228 fi
229 ;;
230 *)
231 print_error "Invalid target name '$target'"
232 return 1
233 ;;
234 esac
b3f6ea7e
PB
235 test "$tcg" = "yes" && return 0
236 supported_kvm_target "$1" && return 0
237 supported_xen_target "$1" && return 0
238 supported_hax_target "$1" && return 0
239 print_error "TCG disabled, but hardware accelerator not available for '$target'"
240 return 1
d880a3ba
PB
241}
242
e9a3591f
CB
243
244ld_has() {
245 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
246}
247
7d13299d 248# default parameters
89138857 249source_path=$(dirname "$0")
2ff6b91e 250cpu=""
a31a8642 251iasl="iasl"
1e43adfc 252interp_prefix="/usr/gnemul/qemu-%M"
43ce4dfe 253static="no"
7d13299d 254cross_prefix=""
0c58ac1c 255audio_drv_list=""
b64ec4e4
FZ
256block_drv_rw_whitelist=""
257block_drv_ro_whitelist=""
e49d021e 258host_cc="cc"
73da375e 259libs_softmmu=""
3e2e0e6b 260libs_tools=""
67f86e8e 261audio_pt_int=""
d5631638 262audio_win_int=""
2b2e59e6 263cc_i386=i386-pc-linux-gnu-gcc
957f1f99 264libs_qga=""
5bc62e01 265debug_info="yes"
63678e17 266stack_protector=""
ac0df51d 267
92712822
DB
268if test -e "$source_path/.git"
269then
f62bbee5 270 git_update=yes
92712822
DB
271 git_submodules="ui/keycodemapdb"
272else
f62bbee5 273 git_update=no
92712822
DB
274 git_submodules=""
275fi
cc84d63a 276git="git"
ac0df51d 277
afb63ebd
SW
278# Don't accept a target_list environment variable.
279unset target_list
377529c0
PB
280
281# Default value for a variable defining feature "foo".
282# * foo="no" feature will only be used if --enable-foo arg is given
283# * foo="" feature will be searched for, and if found, will be used
284# unless --disable-foo is given
285# * foo="yes" this value will only be set by --enable-foo flag.
286# feature will searched for,
287# if not found, configure exits with error
288#
289# Always add --enable-foo and --disable-foo command line args.
290# Distributions want to ensure that several features are compiled in, and it
291# is impossible without a --enable-foo that exits if a feature is not found.
292
293bluez=""
294brlapi=""
295curl=""
296curses=""
297docs=""
298fdt=""
58952137 299netmap="no"
377529c0 300sdl=""
ee8466d0 301sdlabi=""
983eef5a 302virtfs=""
fe8fc5ae 303mpath=""
821601ea 304vnc="yes"
377529c0 305sparse="no"
377529c0 306vde=""
377529c0
PB
307vnc_sasl=""
308vnc_jpeg=""
309vnc_png=""
6a021536 310xkbcommon=""
377529c0 311xen=""
d5b93ddf 312xen_ctrl_version=""
64a7ad6f 313xen_pv_domain_build="no"
eb6fda0f 314xen_pci_passthrough=""
377529c0 315linux_aio=""
47e98658 316cap_ng=""
377529c0 317attr=""
4f26f2b6 318libattr=""
377529c0 319xfs=""
b3f6ea7e 320tcg="yes"
377529c0 321
d41a75a2 322vhost_net="no"
5e9be92d 323vhost_scsi="no"
fc0b9b0e 324vhost_vsock="no"
e6a74868 325vhost_user=""
d41a75a2 326kvm="no"
b0cb0a66 327hax="no"
2da776db 328rdma=""
377529c0
PB
329gprof="no"
330debug_tcg="no"
377529c0 331debug="no"
b553a042 332fortify_source=""
377529c0 333strip_opt="yes"
9195b2c2 334tcg_interpreter="no"
377529c0
PB
335bigendian="no"
336mingw32="no"
1d728c39
BS
337gcov="no"
338gcov_tool="gcov"
377529c0 339EXESUF=""
17969268
FZ
340DSOSUF=".so"
341LDFLAGS_SHARED="-shared"
342modules="no"
377529c0
PB
343prefix="/usr/local"
344mandir="\${prefix}/share/man"
528ae5b8 345datadir="\${prefix}/share"
3d5eecab 346firmwarepath="\${prefix}/share/qemu-firmware"
850da188 347qemu_docdir="\${prefix}/share/doc/qemu"
377529c0 348bindir="\${prefix}/bin"
3aa5d2be 349libdir="\${prefix}/lib"
8bf188aa 350libexecdir="\${prefix}/libexec"
0f94d6da 351includedir="\${prefix}/include"
377529c0 352sysconfdir="\${prefix}/etc"
785c23ae 353local_statedir="\${prefix}/var"
377529c0
PB
354confsuffix="/qemu"
355slirp="yes"
377529c0
PB
356oss_lib=""
357bsd="no"
358linux="no"
359solaris="no"
360profiler="no"
361cocoa="no"
362softmmu="yes"
363linux_user="no"
377529c0 364bsd_user="no"
377529c0
PB
365blobs="yes"
366pkgversion=""
40d6444e 367pie=""
3556c233 368qom_cast_debug="yes"
baf86d6b 369trace_backends="log"
377529c0
PB
370trace_file="trace"
371spice=""
372rbd=""
7b02f544 373smartcard=""
2b2325ff 374libusb=""
69354a83 375usb_redir=""
da076ffe 376opengl=""
014cb152 377opengl_dmabuf="no"
5dd89908 378cpuid_h="no"
99f2dbd3 379avx2_opt="no"
1ece9905 380zlib="yes"
8ca80760 381capstone=""
b25c9dff
SW
382lzo=""
383snappy=""
6b383c08 384bzip2=""
e8ef31a3 385guest_agent=""
d9840e25 386guest_agent_with_vss="no"
50cbebb9 387guest_agent_ntddscsi="no"
9dacf32d 388guest_agent_msi=""
d9840e25
TS
389vss_win32_sdk=""
390win_sdk="no"
4b1c11fd 391want_tools="yes"
c589b249 392libiscsi=""
6542aa9c 393libnfs=""
519175a2 394coroutine=""
70c60c08 395coroutine_pool=""
7d992e4d 396debug_stack_usage="no"
f0d92b56 397crypto_afalg="no"
f794573e 398seccomp=""
eb100396 399glusterfs=""
d85fa9eb 400glusterfs_xlator_opt="no"
0c14fb47 401glusterfs_discard="no"
df3a429a 402glusterfs_fallocate="no"
7c815372 403glusterfs_zerofill="no"
a4ccabcf 404gtk=""
9e04c683 405gtkabi=""
925a0400 406gtk_gl="no"
a1c5e949 407tls_priority="NORMAL"
ddbb0d09 408gnutls=""
b917da4c 409gnutls_rnd=""
91bfcdb0 410nettle=""
fff2f982 411nettle_kdf="no"
91bfcdb0 412gcrypt=""
1f923c70 413gcrypt_hmac="no"
37788f25 414gcrypt_kdf="no"
bbbf9bfb 415vte=""
9d9e1521 416virglrenderer=""
e91c793c 417tpm="yes"
0a12ec87 418libssh2=""
ed1701c6 419live_block_migration="yes"
a99d57bb 420numa=""
2847b469 421tcmalloc="no"
7b01cb97 422jemalloc="no"
a6b1d4c0 423replication="yes"
da92c3ff 424vxhs=""
377529c0 425
898be3e0
PM
426supported_cpu="no"
427supported_os="no"
fb59dabd 428bogus_os="no"
898be3e0 429
ac0df51d
AL
430# parse CC options first
431for opt do
89138857 432 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
ac0df51d
AL
433 case "$opt" in
434 --cross-prefix=*) cross_prefix="$optarg"
435 ;;
3d8df640 436 --cc=*) CC="$optarg"
ac0df51d 437 ;;
83f73fce
TS
438 --cxx=*) CXX="$optarg"
439 ;;
ca4deeb1
PB
440 --source-path=*) source_path="$optarg"
441 ;;
2ff6b91e
JQ
442 --cpu=*) cpu="$optarg"
443 ;;
de385287 444 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
f9943cd5 445 EXTRA_CFLAGS="$optarg"
e2a2ed06 446 ;;
11cde1c8
BD
447 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
448 EXTRA_CXXFLAGS="$optarg"
449 ;;
a4969e90 450 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
f9943cd5 451 EXTRA_LDFLAGS="$optarg"
e2a2ed06 452 ;;
5bc62e01
GH
453 --enable-debug-info) debug_info="yes"
454 ;;
455 --disable-debug-info) debug_info="no"
456 ;;
ac0df51d
AL
457 esac
458done
ac0df51d
AL
459# OS specific
460# Using uname is really, really broken. Once we have the right set of checks
93148aa5 461# we can eliminate its usage altogether.
ac0df51d 462
e49d021e
PM
463# Preferred compiler:
464# ${CC} (if set)
465# ${cross_prefix}gcc (if cross-prefix specified)
466# system compiler
467if test -z "${CC}${cross_prefix}"; then
468 cc="$host_cc"
469else
470 cc="${CC-${cross_prefix}gcc}"
471fi
472
83f73fce
TS
473if test -z "${CXX}${cross_prefix}"; then
474 cxx="c++"
475else
476 cxx="${CXX-${cross_prefix}g++}"
477fi
478
b3198cc2 479ar="${AR-${cross_prefix}ar}"
cdbd727c 480as="${AS-${cross_prefix}as}"
5f6f0e27 481ccas="${CCAS-$cc}"
3dd46c78 482cpp="${CPP-$cc -E}"
b3198cc2
SY
483objcopy="${OBJCOPY-${cross_prefix}objcopy}"
484ld="${LD-${cross_prefix}ld}"
4852ee95 485nm="${NM-${cross_prefix}nm}"
b3198cc2
SY
486strip="${STRIP-${cross_prefix}strip}"
487windres="${WINDRES-${cross_prefix}windres}"
17884d7b
ST
488pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
489query_pkg_config() {
490 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
491}
492pkg_config=query_pkg_config
b3198cc2 493sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
47c03744 494sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
ac0df51d 495
45d285ab
PM
496# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
497ARFLAGS="${ARFLAGS-rv}"
498
be17dc90 499# default flags for all hosts
2d31515b
PM
500# We use -fwrapv to tell the compiler that we require a C dialect where
501# left shift of signed integers is well defined and has the expected
502# 2s-complement style results. (Both clang and gcc agree that it
503# provides these semantics.)
504QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
f9188227 505QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
c95e3080 506QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
be17dc90 507QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
244f1441 508QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
5bc62e01
GH
509if test "$debug_info" = "yes"; then
510 CFLAGS="-g $CFLAGS"
511 LDFLAGS="-g $LDFLAGS"
512fi
be17dc90 513
ca4deeb1 514# make source path absolute
89138857 515source_path=$(cd "$source_path"; pwd)
ca4deeb1 516
cab00a5a
MT
517# running configure in the source tree?
518# we know that's the case if configure is there.
519if test -f "./configure"; then
520 pwd_is_source_path="y"
521else
522 pwd_is_source_path="n"
523fi
524
ac0df51d
AL
525check_define() {
526cat > $TMPC <<EOF
527#if !defined($1)
fd786e1a 528#error $1 not defined
ac0df51d
AL
529#endif
530int main(void) { return 0; }
531EOF
52166aa0 532 compile_object
ac0df51d
AL
533}
534
307119e7
GH
535check_include() {
536cat > $TMPC <<EOF
537#include <$1>
538int main(void) { return 0; }
539EOF
540 compile_object
541}
542
93b25869
JS
543write_c_skeleton() {
544 cat > $TMPC <<EOF
545int main(void) { return 0; }
546EOF
547}
548
bbea4050
PM
549if check_define __linux__ ; then
550 targetos="Linux"
551elif check_define _WIN32 ; then
552 targetos='MINGW32'
553elif check_define __OpenBSD__ ; then
554 targetos='OpenBSD'
555elif check_define __sun__ ; then
556 targetos='SunOS'
557elif check_define __HAIKU__ ; then
558 targetos='Haiku'
951fedfc
PM
559elif check_define __FreeBSD__ ; then
560 targetos='FreeBSD'
561elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
562 targetos='GNU/kFreeBSD'
563elif check_define __DragonFly__ ; then
564 targetos='DragonFly'
565elif check_define __NetBSD__; then
566 targetos='NetBSD'
567elif check_define __APPLE__; then
568 targetos='Darwin'
bbea4050 569else
951fedfc
PM
570 # This is a fatal error, but don't report it yet, because we
571 # might be going to just print the --help text, or it might
572 # be the result of a missing compiler.
573 targetos='bogus'
574 bogus_os='yes'
bbea4050
PM
575fi
576
577# Some host OSes need non-standard checks for which CPU to use.
578# Note that these checks are broken for cross-compilation: if you're
579# cross-compiling to one of these OSes then you'll need to specify
580# the correct CPU with the --cpu option.
581case $targetos in
582Darwin)
583 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
584 # run 64-bit userspace code.
585 # If the user didn't specify a CPU explicitly and the kernel says this is
586 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
587 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
588 cpu="x86_64"
589 fi
590 ;;
591SunOS)
89138857 592 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
bbea4050
PM
593 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
594 cpu="x86_64"
595 fi
596esac
597
2ff6b91e
JQ
598if test ! -z "$cpu" ; then
599 # command line argument
600 :
601elif check_define __i386__ ; then
ac0df51d
AL
602 cpu="i386"
603elif check_define __x86_64__ ; then
c72b26ec
RH
604 if check_define __ILP32__ ; then
605 cpu="x32"
606 else
607 cpu="x86_64"
608 fi
3aa9bd6c 609elif check_define __sparc__ ; then
3aa9bd6c
BS
610 if check_define __arch64__ ; then
611 cpu="sparc64"
612 else
613 cpu="sparc"
614 fi
fdf7ed96 615elif check_define _ARCH_PPC ; then
616 if check_define _ARCH_PPC64 ; then
617 cpu="ppc64"
618 else
619 cpu="ppc"
620 fi
afa05235
AJ
621elif check_define __mips__ ; then
622 cpu="mips"
477ba620
AJ
623elif check_define __ia64__ ; then
624 cpu="ia64"
d66ed0ea
AJ
625elif check_define __s390__ ; then
626 if check_define __s390x__ ; then
627 cpu="s390x"
628 else
629 cpu="s390"
630 fi
21d89f84
PM
631elif check_define __arm__ ; then
632 cpu="arm"
1f080313
CF
633elif check_define __aarch64__ ; then
634 cpu="aarch64"
ac0df51d 635else
89138857 636 cpu=$(uname -m)
ac0df51d
AL
637fi
638
359bc95d
PM
639ARCH=
640# Normalise host CPU name and set ARCH.
641# Note that this case should only have supported host CPUs, not guests.
7d13299d 642case "$cpu" in
6499fd15 643 ppc|ppc64|s390|s390x|sparc64|x32)
898be3e0
PM
644 cpu="$cpu"
645 supported_cpu="yes"
646 ;;
7d13299d 647 i386|i486|i586|i686|i86pc|BePC)
97a847bc 648 cpu="i386"
898be3e0 649 supported_cpu="yes"
7d13299d 650 ;;
aaa5fa14
AJ
651 x86_64|amd64)
652 cpu="x86_64"
898be3e0 653 supported_cpu="yes"
aaa5fa14 654 ;;
21d89f84
PM
655 armv*b|armv*l|arm)
656 cpu="arm"
898be3e0 657 supported_cpu="yes"
7d13299d 658 ;;
1f080313
CF
659 aarch64)
660 cpu="aarch64"
898be3e0 661 supported_cpu="yes"
1f080313 662 ;;
afa05235
AJ
663 mips*)
664 cpu="mips"
898be3e0 665 supported_cpu="yes"
afa05235 666 ;;
3142255c 667 sparc|sun4[cdmuv])
ae228531 668 cpu="sparc"
6499fd15 669 supported_cpu="yes"
ae228531 670 ;;
7d13299d 671 *)
359bc95d
PM
672 # This will result in either an error or falling back to TCI later
673 ARCH=unknown
7d13299d
FB
674 ;;
675esac
359bc95d
PM
676if test -z "$ARCH"; then
677 ARCH="$cpu"
678fi
e2d52ad3 679
7d13299d 680# OS specific
0dbfc675 681
adfc3e91
SS
682# host *BSD for user mode
683HOST_VARIANT_DIR=""
684
7d13299d 685case $targetos in
67b915a5 686MINGW32*)
0dbfc675 687 mingw32="yes"
b0cb0a66 688 hax="yes"
3cec7cc2 689 audio_possible_drivers="dsound sdl"
307119e7
GH
690 if check_include dsound.h; then
691 audio_drv_list="dsound"
692 else
693 audio_drv_list=""
694 fi
898be3e0 695 supported_os="yes"
67b915a5 696;;
5c40d2bd 697GNU/kFreeBSD)
a167ba50 698 bsd="yes"
0dbfc675 699 audio_drv_list="oss"
0bac1111 700 audio_possible_drivers="oss sdl pa"
5c40d2bd 701;;
7d3505c5 702FreeBSD)
0dbfc675 703 bsd="yes"
0db4a067 704 make="${MAKE-gmake}"
0dbfc675 705 audio_drv_list="oss"
0bac1111 706 audio_possible_drivers="oss sdl pa"
f01576f1
JL
707 # needed for kinfo_getvmmap(3) in libutil.h
708 LIBS="-lutil $LIBS"
a7764f15
EM
709 # needed for kinfo_getproc
710 libs_qga="-lutil $libs_qga"
58952137 711 netmap="" # enable netmap autodetect
adfc3e91 712 HOST_VARIANT_DIR="freebsd"
898be3e0 713 supported_os="yes"
7d3505c5 714;;
c5e97233 715DragonFly)
0dbfc675 716 bsd="yes"
0db4a067 717 make="${MAKE-gmake}"
0dbfc675 718 audio_drv_list="oss"
0bac1111 719 audio_possible_drivers="oss sdl pa"
adfc3e91 720 HOST_VARIANT_DIR="dragonfly"
c5e97233 721;;
7d3505c5 722NetBSD)
0dbfc675 723 bsd="yes"
0db4a067 724 make="${MAKE-gmake}"
0dbfc675 725 audio_drv_list="oss"
0bac1111 726 audio_possible_drivers="oss sdl"
0dbfc675 727 oss_lib="-lossaudio"
adfc3e91 728 HOST_VARIANT_DIR="netbsd"
3c2bdbc1 729 supported_os="yes"
7d3505c5
FB
730;;
731OpenBSD)
0dbfc675 732 bsd="yes"
0db4a067 733 make="${MAKE-gmake}"
4f6ab397 734 audio_drv_list="sdl"
0bac1111 735 audio_possible_drivers="sdl"
adfc3e91 736 HOST_VARIANT_DIR="openbsd"
7d3505c5 737;;
83fb7adf 738Darwin)
0dbfc675
JQ
739 bsd="yes"
740 darwin="yes"
b0cb0a66 741 hax="yes"
17969268 742 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
0dbfc675 743 if [ "$cpu" = "x86_64" ] ; then
a558ee17 744 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
0c439cbf 745 LDFLAGS="-arch x86_64 $LDFLAGS"
0dbfc675 746 fi
0dbfc675
JQ
747 cocoa="yes"
748 audio_drv_list="coreaudio"
14382605 749 audio_possible_drivers="coreaudio sdl"
0dbfc675 750 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7973f21c 751 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
a0b7cf6b
PM
752 # Disable attempts to use ObjectiveC features in os/object.h since they
753 # won't work when we're compiling with gcc as a C compiler.
754 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
adfc3e91 755 HOST_VARIANT_DIR="darwin"
898be3e0 756 supported_os="yes"
83fb7adf 757;;
ec530c81 758SunOS)
0dbfc675 759 solaris="yes"
0db4a067
PB
760 make="${MAKE-gmake}"
761 install="${INSTALL-ginstall}"
e2d8830e 762 smbd="${SMBD-/usr/sfw/sbin/smbd}"
0dbfc675
JQ
763 if test -f /usr/include/sys/soundcard.h ; then
764 audio_drv_list="oss"
765 fi
766 audio_possible_drivers="oss sdl"
d741429a
BS
767# needed for CMSG_ macros in sys/socket.h
768 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
769# needed for TIOCWIN* defines in termios.h
770 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
a558ee17 771 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
560d375f
AF
772 solarisnetlibs="-lsocket -lnsl -lresolv"
773 LIBS="$solarisnetlibs $LIBS"
774 libs_qga="$solarisnetlibs $libs_qga"
86b2bd93 775;;
179cf400
AF
776Haiku)
777 haiku="yes"
778 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
779 LIBS="-lposix_error_mapper -lnetwork $LIBS"
780;;
898be3e0 781Linux)
0dbfc675 782 audio_drv_list="oss"
0bac1111 783 audio_possible_drivers="oss alsa sdl pa"
0dbfc675
JQ
784 linux="yes"
785 linux_user="yes"
af2be207
JK
786 kvm="yes"
787 vhost_net="yes"
5e9be92d 788 vhost_scsi="yes"
fc0b9b0e 789 vhost_vsock="yes"
a585140d 790 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
898be3e0
PM
791 supported_os="yes"
792;;
7d13299d
FB
793esac
794
7d3505c5 795if [ "$bsd" = "yes" ] ; then
b1a550a0 796 if [ "$darwin" != "yes" ] ; then
08de3949 797 bsd_user="yes"
83fb7adf 798 fi
7d3505c5
FB
799fi
800
0db4a067
PB
801: ${make=${MAKE-make}}
802: ${install=${INSTALL-install}}
52510f8b 803: ${python=${PYTHON-python}}
e2d8830e 804: ${smbd=${SMBD-/usr/sbin/smbd}}
0db4a067 805
3c4a4d0d
PM
806# Default objcc to clang if available, otherwise use CC
807if has clang; then
808 objcc=clang
809else
810 objcc="$cc"
811fi
812
3457a3f8 813if test "$mingw32" = "yes" ; then
3457a3f8 814 EXESUF=".exe"
17969268 815 DSOSUF=".dll"
a558ee17 816 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
e94a7936
SW
817 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
818 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
78e9d4ad
SW
819 # MinGW needs -mthreads for TLS and macro _MT.
820 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
f7cf5d5b 821 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
93b25869 822 write_c_skeleton;
f7cf5d5b
SW
823 if compile_prog "" "-liberty" ; then
824 LIBS="-liberty $LIBS"
825 fi
c5ec15ea 826 prefix="c:/Program Files/QEMU"
683035de 827 mandir="\${prefix}"
528ae5b8 828 datadir="\${prefix}"
850da188 829 qemu_docdir="\${prefix}"
683035de
PB
830 bindir="\${prefix}"
831 sysconfdir="\${prefix}"
5a699bbb 832 local_statedir=
683035de 833 confsuffix=""
105fad6b 834 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
3457a3f8
JQ
835fi
836
487fefdb 837werror=""
85aa5189 838
7d13299d 839for opt do
89138857 840 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
7d13299d 841 case "$opt" in
2efc3265
FB
842 --help|-h) show_help=yes
843 ;;
99123e13
MF
844 --version|-V) exec cat $source_path/VERSION
845 ;;
b1a550a0 846 --prefix=*) prefix="$optarg"
7d13299d 847 ;;
b1a550a0 848 --interp-prefix=*) interp_prefix="$optarg"
32ce6337 849 ;;
ca4deeb1 850 --source-path=*)
7d13299d 851 ;;
ac0df51d 852 --cross-prefix=*)
7d13299d 853 ;;
ac0df51d 854 --cc=*)
7d13299d 855 ;;
b1a550a0 856 --host-cc=*) host_cc="$optarg"
83469015 857 ;;
83f73fce
TS
858 --cxx=*)
859 ;;
e007dbec
MT
860 --iasl=*) iasl="$optarg"
861 ;;
3c4a4d0d
PM
862 --objcc=*) objcc="$optarg"
863 ;;
b1a550a0 864 --make=*) make="$optarg"
7d13299d 865 ;;
6a882643
PB
866 --install=*) install="$optarg"
867 ;;
c886edfb
BS
868 --python=*) python="$optarg"
869 ;;
1d728c39
BS
870 --gcov=*) gcov_tool="$optarg"
871 ;;
e2d8830e
BS
872 --smbd=*) smbd="$optarg"
873 ;;
e2a2ed06 874 --extra-cflags=*)
7d13299d 875 ;;
11cde1c8
BD
876 --extra-cxxflags=*)
877 ;;
e2a2ed06 878 --extra-ldflags=*)
7d13299d 879 ;;
5bc62e01
GH
880 --enable-debug-info)
881 ;;
882 --disable-debug-info)
883 ;;
17969268
FZ
884 --enable-modules)
885 modules="yes"
3aa88b31
SH
886 ;;
887 --disable-modules)
888 modules="no"
17969268 889 ;;
2ff6b91e 890 --cpu=*)
7d13299d 891 ;;
b1a550a0 892 --target-list=*) target_list="$optarg"
de83cd02 893 ;;
5b808275
LV
894 --enable-trace-backends=*) trace_backends="$optarg"
895 ;;
896 # XXX: backwards compatibility
897 --enable-trace-backend=*) trace_backends="$optarg"
94a420b1 898 ;;
74242e0f 899 --with-trace-file=*) trace_file="$optarg"
9410b56c 900 ;;
7d13299d
FB
901 --enable-gprof) gprof="yes"
902 ;;
1d728c39
BS
903 --enable-gcov) gcov="yes"
904 ;;
79427693
LM
905 --static)
906 static="yes"
907 LDFLAGS="-static $LDFLAGS"
17884d7b 908 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
43ce4dfe 909 ;;
0b24e75f
PB
910 --mandir=*) mandir="$optarg"
911 ;;
912 --bindir=*) bindir="$optarg"
913 ;;
3aa5d2be
AL
914 --libdir=*) libdir="$optarg"
915 ;;
8bf188aa
MT
916 --libexecdir=*) libexecdir="$optarg"
917 ;;
0f94d6da
AL
918 --includedir=*) includedir="$optarg"
919 ;;
528ae5b8 920 --datadir=*) datadir="$optarg"
0b24e75f 921 ;;
023d3d67
EH
922 --with-confsuffix=*) confsuffix="$optarg"
923 ;;
850da188 924 --docdir=*) qemu_docdir="$optarg"
0b24e75f 925 ;;
ca2fb938 926 --sysconfdir=*) sysconfdir="$optarg"
07381cc1 927 ;;
785c23ae
LC
928 --localstatedir=*) local_statedir="$optarg"
929 ;;
3d5eecab
GH
930 --firmwarepath=*) firmwarepath="$optarg"
931 ;;
785c23ae 932 --sbindir=*|--sharedstatedir=*|\
023ddd74
MF
933 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
934 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
935 # These switches are silently ignored, for compatibility with
936 # autoconf-generated configure scripts. This allows QEMU's
937 # configure to be used by RPM and similar macros that set
938 # lots of directory switches by default.
939 ;;
97a847bc
FB
940 --disable-sdl) sdl="no"
941 ;;
c4198157
JQ
942 --enable-sdl) sdl="yes"
943 ;;
47c03744
DA
944 --with-sdlabi=*) sdlabi="$optarg"
945 ;;
3556c233
PB
946 --disable-qom-cast-debug) qom_cast_debug="no"
947 ;;
948 --enable-qom-cast-debug) qom_cast_debug="yes"
949 ;;
983eef5a
MI
950 --disable-virtfs) virtfs="no"
951 ;;
952 --enable-virtfs) virtfs="yes"
953 ;;
fe8fc5ae
PB
954 --disable-mpath) mpath="no"
955 ;;
956 --enable-mpath) mpath="yes"
957 ;;
821601ea
JS
958 --disable-vnc) vnc="no"
959 ;;
960 --enable-vnc) vnc="yes"
961 ;;
2f6a1ab0
BS
962 --oss-lib=*) oss_lib="$optarg"
963 ;;
0c58ac1c 964 --audio-drv-list=*) audio_drv_list="$optarg"
102a52e4 965 ;;
89138857 966 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
b64ec4e4 967 ;;
89138857 968 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
eb852011 969 ;;
f8393946
AJ
970 --enable-debug-tcg) debug_tcg="yes"
971 ;;
972 --disable-debug-tcg) debug_tcg="no"
973 ;;
f3d08ee6
PB
974 --enable-debug)
975 # Enable debugging options that aren't excessively noisy
976 debug_tcg="yes"
977 debug="yes"
978 strip_opt="no"
b553a042 979 fortify_source="no"
f3d08ee6 980 ;;
03b4fe7d
AL
981 --enable-sparse) sparse="yes"
982 ;;
983 --disable-sparse) sparse="no"
984 ;;
1625af87
AL
985 --disable-strip) strip_opt="no"
986 ;;
2f9606b3
AL
987 --disable-vnc-sasl) vnc_sasl="no"
988 ;;
ea784e3b
JQ
989 --enable-vnc-sasl) vnc_sasl="yes"
990 ;;
2f6f5c7a
CC
991 --disable-vnc-jpeg) vnc_jpeg="no"
992 ;;
993 --enable-vnc-jpeg) vnc_jpeg="yes"
994 ;;
efe556ad
CC
995 --disable-vnc-png) vnc_png="no"
996 ;;
997 --enable-vnc-png) vnc_png="yes"
998 ;;
443f1376 999 --disable-slirp) slirp="no"
1d14ffa9 1000 ;;
e0e6c8c0 1001 --disable-vde) vde="no"
8a16d273 1002 ;;
dfb278bd
JQ
1003 --enable-vde) vde="yes"
1004 ;;
58952137
VM
1005 --disable-netmap) netmap="no"
1006 ;;
1007 --enable-netmap) netmap="yes"
1008 ;;
e37630ca
AL
1009 --disable-xen) xen="no"
1010 ;;
fc321b4b
JQ
1011 --enable-xen) xen="yes"
1012 ;;
eb6fda0f
AP
1013 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1014 ;;
1015 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1016 ;;
64a7ad6f
IC
1017 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
1018 ;;
1019 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
1020 ;;
2e4d9fb1
AJ
1021 --disable-brlapi) brlapi="no"
1022 ;;
4ffcedb6
JQ
1023 --enable-brlapi) brlapi="yes"
1024 ;;
fb599c9a
AZ
1025 --disable-bluez) bluez="no"
1026 ;;
a20a6f46
JQ
1027 --enable-bluez) bluez="yes"
1028 ;;
7ba1e619
AL
1029 --disable-kvm) kvm="no"
1030 ;;
b31a0277
JQ
1031 --enable-kvm) kvm="yes"
1032 ;;
b0cb0a66 1033 --disable-hax) hax="no"
180fb750 1034 ;;
b0cb0a66 1035 --enable-hax) hax="yes"
180fb750 1036 ;;
9195b2c2
SW
1037 --disable-tcg-interpreter) tcg_interpreter="no"
1038 ;;
1039 --enable-tcg-interpreter) tcg_interpreter="yes"
1040 ;;
47e98658
CB
1041 --disable-cap-ng) cap_ng="no"
1042 ;;
1043 --enable-cap-ng) cap_ng="yes"
1044 ;;
b3f6ea7e
PB
1045 --disable-tcg) tcg="no"
1046 ;;
1047 --enable-tcg) tcg="yes"
1048 ;;
cd4ec0b4
GH
1049 --disable-spice) spice="no"
1050 ;;
1051 --enable-spice) spice="yes"
1052 ;;
c589b249
RS
1053 --disable-libiscsi) libiscsi="no"
1054 ;;
1055 --enable-libiscsi) libiscsi="yes"
1056 ;;
6542aa9c
PL
1057 --disable-libnfs) libnfs="no"
1058 ;;
1059 --enable-libnfs) libnfs="yes"
1060 ;;
05c2a3e7
FB
1061 --enable-profiler) profiler="yes"
1062 ;;
14821030
PB
1063 --disable-cocoa) cocoa="no"
1064 ;;
c2de5c91 1065 --enable-cocoa)
1066 cocoa="yes" ;
89138857 1067 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1d14ffa9 1068 ;;
cad25d69 1069 --disable-system) softmmu="no"
0a8e90f4 1070 ;;
cad25d69 1071 --enable-system) softmmu="yes"
0a8e90f4 1072 ;;
0953a80f
ZA
1073 --disable-user)
1074 linux_user="no" ;
1075 bsd_user="no" ;
0953a80f
ZA
1076 ;;
1077 --enable-user) ;;
831b7825 1078 --disable-linux-user) linux_user="no"
0a8e90f4 1079 ;;
831b7825
TS
1080 --enable-linux-user) linux_user="yes"
1081 ;;
84778508
BS
1082 --disable-bsd-user) bsd_user="no"
1083 ;;
1084 --enable-bsd-user) bsd_user="yes"
1085 ;;
40d6444e 1086 --enable-pie) pie="yes"
34005a00 1087 ;;
40d6444e 1088 --disable-pie) pie="no"
34005a00 1089 ;;
85aa5189
FB
1090 --enable-werror) werror="yes"
1091 ;;
1092 --disable-werror) werror="no"
1093 ;;
63678e17
SN
1094 --enable-stack-protector) stack_protector="yes"
1095 ;;
1096 --disable-stack-protector) stack_protector="no"
1097 ;;
4d3b6f6e
AZ
1098 --disable-curses) curses="no"
1099 ;;
c584a6d0
JQ
1100 --enable-curses) curses="yes"
1101 ;;
769ce76d
AG
1102 --disable-curl) curl="no"
1103 ;;
788c8196
JQ
1104 --enable-curl) curl="yes"
1105 ;;
2df87df7
JQ
1106 --disable-fdt) fdt="no"
1107 ;;
1108 --enable-fdt) fdt="yes"
1109 ;;
5c6c3a6c
CH
1110 --disable-linux-aio) linux_aio="no"
1111 ;;
1112 --enable-linux-aio) linux_aio="yes"
1113 ;;
758e8e38
VJ
1114 --disable-attr) attr="no"
1115 ;;
1116 --enable-attr) attr="yes"
1117 ;;
77755340
TS
1118 --disable-blobs) blobs="no"
1119 ;;
4a19f1ec
PB
1120 --with-pkgversion=*) pkgversion=" ($optarg)"
1121 ;;
519175a2
AB
1122 --with-coroutine=*) coroutine="$optarg"
1123 ;;
70c60c08
SH
1124 --disable-coroutine-pool) coroutine_pool="no"
1125 ;;
1126 --enable-coroutine-pool) coroutine_pool="yes"
1127 ;;
7d992e4d
PL
1128 --enable-debug-stack-usage) debug_stack_usage="yes"
1129 ;;
f0d92b56
LM
1130 --enable-crypto-afalg) crypto_afalg="yes"
1131 ;;
1132 --disable-crypto-afalg) crypto_afalg="no"
1133 ;;
a25dba17 1134 --disable-docs) docs="no"
70ec5dc0 1135 ;;
a25dba17 1136 --enable-docs) docs="yes"
83a3ab8b 1137 ;;
d5970055
MT
1138 --disable-vhost-net) vhost_net="no"
1139 ;;
1140 --enable-vhost-net) vhost_net="yes"
1141 ;;
5e9be92d
NB
1142 --disable-vhost-scsi) vhost_scsi="no"
1143 ;;
1144 --enable-vhost-scsi) vhost_scsi="yes"
1145 ;;
fc0b9b0e
SH
1146 --disable-vhost-vsock) vhost_vsock="no"
1147 ;;
1148 --enable-vhost-vsock) vhost_vsock="yes"
1149 ;;
da076ffe 1150 --disable-opengl) opengl="no"
20ff075b 1151 ;;
da076ffe 1152 --enable-opengl) opengl="yes"
20ff075b 1153 ;;
f27aaf4b
CB
1154 --disable-rbd) rbd="no"
1155 ;;
1156 --enable-rbd) rbd="yes"
1157 ;;
8c84cf11
ST
1158 --disable-xfsctl) xfs="no"
1159 ;;
1160 --enable-xfsctl) xfs="yes"
1161 ;;
7b02f544 1162 --disable-smartcard) smartcard="no"
111a38b0 1163 ;;
7b02f544 1164 --enable-smartcard) smartcard="yes"
111a38b0 1165 ;;
2b2325ff
GH
1166 --disable-libusb) libusb="no"
1167 ;;
1168 --enable-libusb) libusb="yes"
1169 ;;
69354a83
HG
1170 --disable-usb-redir) usb_redir="no"
1171 ;;
1172 --enable-usb-redir) usb_redir="yes"
1173 ;;
1ece9905
AL
1174 --disable-zlib-test) zlib="no"
1175 ;;
b25c9dff
SW
1176 --disable-lzo) lzo="no"
1177 ;;
607dacd0
QN
1178 --enable-lzo) lzo="yes"
1179 ;;
b25c9dff
SW
1180 --disable-snappy) snappy="no"
1181 ;;
607dacd0
QN
1182 --enable-snappy) snappy="yes"
1183 ;;
6b383c08
PW
1184 --disable-bzip2) bzip2="no"
1185 ;;
1186 --enable-bzip2) bzip2="yes"
1187 ;;
d138cee9
MR
1188 --enable-guest-agent) guest_agent="yes"
1189 ;;
1190 --disable-guest-agent) guest_agent="no"
1191 ;;
9dacf32d
YH
1192 --enable-guest-agent-msi) guest_agent_msi="yes"
1193 ;;
1194 --disable-guest-agent-msi) guest_agent_msi="no"
1195 ;;
d9840e25
TS
1196 --with-vss-sdk) vss_win32_sdk=""
1197 ;;
1198 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1199 ;;
1200 --without-vss-sdk) vss_win32_sdk="no"
1201 ;;
1202 --with-win-sdk) win_sdk=""
1203 ;;
1204 --with-win-sdk=*) win_sdk="$optarg"
1205 ;;
1206 --without-win-sdk) win_sdk="no"
1207 ;;
4b1c11fd
DB
1208 --enable-tools) want_tools="yes"
1209 ;;
1210 --disable-tools) want_tools="no"
1211 ;;
f794573e
EO
1212 --enable-seccomp) seccomp="yes"
1213 ;;
1214 --disable-seccomp) seccomp="no"
1215 ;;
eb100396
BR
1216 --disable-glusterfs) glusterfs="no"
1217 ;;
1218 --enable-glusterfs) glusterfs="yes"
1219 ;;
52b53c04
FZ
1220 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1221 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
583f6e7b 1222 ;;
cb6414df
FZ
1223 --enable-vhdx|--disable-vhdx)
1224 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1225 ;;
315d3184
FZ
1226 --enable-uuid|--disable-uuid)
1227 echo "$0: $opt is obsolete, UUID support is always built" >&2
1228 ;;
a4ccabcf
AL
1229 --disable-gtk) gtk="no"
1230 ;;
1231 --enable-gtk) gtk="yes"
1232 ;;
a1c5e949
DB
1233 --tls-priority=*) tls_priority="$optarg"
1234 ;;
ddbb0d09
DB
1235 --disable-gnutls) gnutls="no"
1236 ;;
1237 --enable-gnutls) gnutls="yes"
1238 ;;
91bfcdb0
DB
1239 --disable-nettle) nettle="no"
1240 ;;
1241 --enable-nettle) nettle="yes"
1242 ;;
1243 --disable-gcrypt) gcrypt="no"
1244 ;;
1245 --enable-gcrypt) gcrypt="yes"
1246 ;;
2da776db
MH
1247 --enable-rdma) rdma="yes"
1248 ;;
1249 --disable-rdma) rdma="no"
1250 ;;
528de90a
DB
1251 --with-gtkabi=*) gtkabi="$optarg"
1252 ;;
bbbf9bfb
SW
1253 --disable-vte) vte="no"
1254 ;;
1255 --enable-vte) vte="yes"
1256 ;;
9d9e1521
GH
1257 --disable-virglrenderer) virglrenderer="no"
1258 ;;
1259 --enable-virglrenderer) virglrenderer="yes"
1260 ;;
e91c793c
CR
1261 --disable-tpm) tpm="no"
1262 ;;
ab214c29
SB
1263 --enable-tpm) tpm="yes"
1264 ;;
0a12ec87
RJ
1265 --disable-libssh2) libssh2="no"
1266 ;;
1267 --enable-libssh2) libssh2="yes"
1268 ;;
ed1701c6
DDAG
1269 --disable-live-block-migration) live_block_migration="no"
1270 ;;
1271 --enable-live-block-migration) live_block_migration="yes"
1272 ;;
a99d57bb
WG
1273 --disable-numa) numa="no"
1274 ;;
1275 --enable-numa) numa="yes"
1276 ;;
2847b469
FZ
1277 --disable-tcmalloc) tcmalloc="no"
1278 ;;
1279 --enable-tcmalloc) tcmalloc="yes"
1280 ;;
7b01cb97
AD
1281 --disable-jemalloc) jemalloc="no"
1282 ;;
1283 --enable-jemalloc) jemalloc="yes"
1284 ;;
a6b1d4c0
CX
1285 --disable-replication) replication="no"
1286 ;;
1287 --enable-replication) replication="yes"
1288 ;;
da92c3ff
AM
1289 --disable-vxhs) vxhs="no"
1290 ;;
1291 --enable-vxhs) vxhs="yes"
1292 ;;
e6a74868
MAL
1293 --disable-vhost-user) vhost_user="no"
1294 ;;
1295 --enable-vhost-user)
1296 vhost_user="yes"
1297 if test "$mingw32" = "yes"; then
1298 error_exit "vhost-user isn't available on win32"
1299 fi
1300 ;;
8ca80760
RH
1301 --disable-capstone) capstone="no"
1302 ;;
1303 --enable-capstone) capstone="yes"
1304 ;;
e219c499
RH
1305 --enable-capstone=git) capstone="git"
1306 ;;
1307 --enable-capstone=system) capstone="system"
1308 ;;
cc84d63a
DB
1309 --with-git=*) git="$optarg"
1310 ;;
f62bbee5
DB
1311 --enable-git-update) git_update=yes
1312 ;;
1313 --disable-git-update) git_update=no
1314 ;;
2d2ad6d0
FZ
1315 *)
1316 echo "ERROR: unknown option $opt"
1317 echo "Try '$0 --help' for more information"
1318 exit 1
7f1559c6 1319 ;;
7d13299d
FB
1320 esac
1321done
1322
e6a74868
MAL
1323if test "$vhost_user" = ""; then
1324 if test "$mingw32" = "yes"; then
1325 vhost_user="no"
1326 else
1327 vhost_user="yes"
1328 fi
1329fi
1330
40293e58 1331case "$cpu" in
e3608d66
RH
1332 ppc)
1333 CPU_CFLAGS="-m32"
1334 LDFLAGS="-m32 $LDFLAGS"
1335 ;;
1336 ppc64)
1337 CPU_CFLAGS="-m64"
1338 LDFLAGS="-m64 $LDFLAGS"
1339 ;;
9b9c37c3 1340 sparc)
f1079bb8
RH
1341 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1342 LDFLAGS="-m32 -mv8plus $LDFLAGS"
3142255c 1343 ;;
ed968ff1 1344 sparc64)
79f3b12f 1345 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
f1079bb8 1346 LDFLAGS="-m64 $LDFLAGS"
3142255c 1347 ;;
76d83bde 1348 s390)
061cdd81 1349 CPU_CFLAGS="-m31"
28d7cc49
RH
1350 LDFLAGS="-m31 $LDFLAGS"
1351 ;;
1352 s390x)
061cdd81 1353 CPU_CFLAGS="-m64"
28d7cc49 1354 LDFLAGS="-m64 $LDFLAGS"
76d83bde 1355 ;;
40293e58 1356 i386)
79f3b12f 1357 CPU_CFLAGS="-m32"
0c439cbf 1358 LDFLAGS="-m32 $LDFLAGS"
2b2e59e6 1359 cc_i386='$(CC) -m32'
40293e58
FB
1360 ;;
1361 x86_64)
7ebee43e
RH
1362 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1363 # If we truly care, we should simply detect this case at
1364 # runtime and generate the fallback to serial emulation.
1365 CPU_CFLAGS="-m64 -mcx16"
0c439cbf 1366 LDFLAGS="-m64 $LDFLAGS"
2b2e59e6 1367 cc_i386='$(CC) -m32'
d2fbca94 1368 ;;
c72b26ec
RH
1369 x32)
1370 CPU_CFLAGS="-mx32"
1371 LDFLAGS="-mx32 $LDFLAGS"
1372 cc_i386='$(CC) -m32'
1373 ;;
30163d89 1374 # No special flags required for other host CPUs
3142255c
BS
1375esac
1376
79f3b12f
PC
1377QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1378EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1379
affc88cc
PM
1380# For user-mode emulation the host arch has to be one we explicitly
1381# support, even if we're using TCI.
1382if [ "$ARCH" = "unknown" ]; then
1383 bsd_user="no"
1384 linux_user="no"
1385fi
1386
60e0df25
PM
1387default_target_list=""
1388
6e92f823
PM
1389mak_wilds=""
1390
1391if [ "$softmmu" = "yes" ]; then
1392 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
60e0df25 1393fi
6e92f823
PM
1394if [ "$linux_user" = "yes" ]; then
1395 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
60e0df25 1396fi
6e92f823
PM
1397if [ "$bsd_user" = "yes" ]; then
1398 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
60e0df25
PM
1399fi
1400
6e92f823
PM
1401for config in $mak_wilds; do
1402 default_target_list="${default_target_list} $(basename "$config" .mak)"
1403done
1404
c53eeaf7 1405# Enumerate public trace backends for --help output
64a6047d 1406trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
c53eeaf7 1407
af5db58e
PB
1408if test x"$show_help" = x"yes" ; then
1409cat << EOF
1410
1411Usage: configure [options]
1412Options: [defaults in brackets after descriptions]
1413
08fb77ed
SW
1414Standard options:
1415 --help print this message
1416 --prefix=PREFIX install in PREFIX [$prefix]
1417 --interp-prefix=PREFIX where to find shared libraries, etc.
1418 use %M for cpu name [$interp_prefix]
1419 --target-list=LIST set target list (default: build everything)
1420$(echo Available targets: $default_target_list | \
1421 fold -s -w 53 | sed -e 's/^/ /')
1422
1423Advanced options (experts only):
1424 --source-path=PATH path of source code [$source_path]
1425 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1426 --cc=CC use C compiler CC [$cc]
1427 --iasl=IASL use ACPI compiler IASL [$iasl]
1428 --host-cc=CC use C compiler CC [$host_cc] for code run at
1429 build time
1430 --cxx=CXX use C++ compiler CXX [$cxx]
1431 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1432 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
11cde1c8 1433 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
08fb77ed
SW
1434 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1435 --make=MAKE use specified make [$make]
1436 --install=INSTALL use specified install [$install]
1437 --python=PYTHON use specified python [$python]
1438 --smbd=SMBD use specified smbd [$smbd]
1439 --static enable static build [$static]
1440 --mandir=PATH install man pages in PATH
1441 --datadir=PATH install firmware in PATH$confsuffix
1442 --docdir=PATH install documentation in PATH$confsuffix
1443 --bindir=PATH install binaries in PATH
1444 --libdir=PATH install libraries in PATH
1445 --sysconfdir=PATH install config in PATH$confsuffix
1446 --localstatedir=PATH install local state in PATH (set at runtime on win32)
3d5eecab 1447 --firmwarepath=PATH search PATH for firmware files
e26110cf 1448 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
08fb77ed 1449 --enable-debug enable common debug build options
08fb77ed
SW
1450 --disable-strip disable stripping binaries
1451 --disable-werror disable compilation abort on warning
63678e17 1452 --disable-stack-protector disable compiler-provided stack protection
08fb77ed
SW
1453 --audio-drv-list=LIST set audio drivers list:
1454 Available drivers: $audio_possible_drivers
1455 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1456 --block-drv-rw-whitelist=L
1457 set block driver read-write whitelist
1458 (affects only QEMU, not qemu-img)
1459 --block-drv-ro-whitelist=L
1460 set block driver read-only whitelist
1461 (affects only QEMU, not qemu-img)
5b808275 1462 --enable-trace-backends=B Set trace backend
c53eeaf7 1463 Available backends: $trace_backend_list
08fb77ed
SW
1464 --with-trace-file=NAME Full PATH,NAME of file to store traces
1465 Default:trace-<pid>
c23f23b9
MT
1466 --disable-slirp disable SLIRP userspace network connectivity
1467 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1468 --oss-lib path to OSS library
1469 --cpu=CPU Build for host CPU [$cpu]
08fb77ed 1470 --with-coroutine=BACKEND coroutine backend. Supported options:
33c53c54 1471 ucontext, sigaltstack, windows
08fb77ed
SW
1472 --enable-gcov enable test coverage analysis with gcov
1473 --gcov=GCOV use specified gcov [$gcov_tool]
c23f23b9
MT
1474 --disable-blobs disable installing provided firmware blobs
1475 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1476 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
a1c5e949 1477 --tls-priority default TLS protocol/cipher priority string
c12d66aa
LM
1478 --enable-gprof QEMU profiling with gprof
1479 --enable-profiler profiler support
1480 --enable-xen-pv-domain-build
1481 xen pv domain builder
1482 --enable-debug-stack-usage
1483 track the maximum stack usage of stacks created by qemu_alloc_stack
c23f23b9
MT
1484
1485Optional features, enabled with --enable-FEATURE and
1486disabled with --disable-FEATURE, default is enabled if available:
1487
1488 system all system emulation targets
1489 user supported user emulation targets
1490 linux-user all linux usermode emulation targets
1491 bsd-user all BSD usermode emulation targets
c23f23b9
MT
1492 docs build documentation
1493 guest-agent build the QEMU Guest Agent
1494 guest-agent-msi build guest agent Windows MSI installation package
1495 pie Position Independent Executables
1496 modules modules support
1497 debug-tcg TCG debugging (default is disabled)
1498 debug-info debugging information
1499 sparse sparse checker
1500
ddbb0d09 1501 gnutls GNUTLS cryptography support
91bfcdb0
DB
1502 nettle nettle cryptography support
1503 gcrypt libgcrypt cryptography support
c23f23b9
MT
1504 sdl SDL UI
1505 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1506 gtk gtk UI
1507 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1508 vte vte support for the gtk UI
1509 curses curses UI
1510 vnc VNC UI support
c23f23b9
MT
1511 vnc-sasl SASL encryption for VNC server
1512 vnc-jpeg JPEG lossy compression for VNC server
1513 vnc-png PNG compression for VNC server
c23f23b9
MT
1514 cocoa Cocoa UI (Mac OS X only)
1515 virtfs VirtFS
fe8fc5ae 1516 mpath Multipath persistent reservation passthrough
c23f23b9
MT
1517 xen xen backend driver support
1518 xen-pci-passthrough
1519 brlapi BrlAPI (Braile)
1520 curl curl connectivity
1521 fdt fdt device tree
1522 bluez bluez stack connectivity
1523 kvm KVM acceleration support
b0cb0a66 1524 hax HAX acceleration support
c23f23b9 1525 rdma RDMA-based migration support
c23f23b9
MT
1526 vde support for vde network
1527 netmap support for netmap network
1528 linux-aio Linux AIO support
1529 cap-ng libcap-ng support
1530 attr attr and xattr support
1531 vhost-net vhost-net acceleration support
1532 spice spice
1533 rbd rados block device (rbd)
1534 libiscsi iscsi support
1535 libnfs nfs support
7b02f544 1536 smartcard smartcard support (libcacard)
c23f23b9 1537 libusb libusb (for usb passthrough)
ed1701c6 1538 live-block-migration Block migration in the main migration stream
c23f23b9
MT
1539 usb-redir usb network redirection support
1540 lzo support of lzo compression library
1541 snappy support of snappy compression library
1542 bzip2 support of bzip2 compression library
1543 (for reading bzip2-compressed dmg images)
1544 seccomp seccomp support
1545 coroutine-pool coroutine freelist (better performance)
1546 glusterfs GlusterFS backend
c23f23b9
MT
1547 tpm TPM support
1548 libssh2 ssh block device support
c23f23b9
MT
1549 numa libnuma support
1550 tcmalloc tcmalloc support
7b01cb97 1551 jemalloc jemalloc support
a6b1d4c0 1552 replication replication support
c12d66aa
LM
1553 vhost-vsock virtio sockets device support
1554 opengl opengl support
1555 virglrenderer virgl rendering support
1556 xfsctl xfsctl support
1557 qom-cast-debug cast debugging support
1558 tools build qemu-io, qemu-nbd and qemu-image tools
da92c3ff 1559 vxhs Veritas HyperScale vDisk backend support
f0d92b56 1560 crypto-afalg Linux AF_ALG crypto backend driver
e6a74868 1561 vhost-user vhost-user support
8ca80760 1562 capstone capstone disassembler support
08fb77ed
SW
1563
1564NOTE: The object files are built at the place where configure is launched
af5db58e 1565EOF
2d2ad6d0 1566exit 0
af5db58e
PB
1567fi
1568
c53eeaf7
SH
1569if ! has $python; then
1570 error_exit "Python not found. Use --python=/path/to/python"
1571fi
1572
1573# Note that if the Python conditional here evaluates True we will exit
1574# with status 1 which is a shell 'false' value.
1575if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1576 error_exit "Cannot use '$python', Python 2.6 or later is required." \
1577 "Note that Python 3 or later is not yet supported." \
1578 "Use --python=/path/to/python to specify a supported Python."
1579fi
1580
1581# Suppress writing compiled files
1582python="$python -B"
1583
359bc95d
PM
1584# Now we have handled --enable-tcg-interpreter and know we're not just
1585# printing the help message, bail out if the host CPU isn't supported.
1586if test "$ARCH" = "unknown"; then
1587 if test "$tcg_interpreter" = "yes" ; then
1588 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
359bc95d 1589 else
76ad07a4 1590 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
359bc95d
PM
1591 fi
1592fi
1593
9c83ffd8
PM
1594# Consult white-list to determine whether to enable werror
1595# by default. Only enable by default for git builds
9c83ffd8
PM
1596if test -z "$werror" ; then
1597 if test -d "$source_path/.git" -a \
e4650c81 1598 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
9c83ffd8
PM
1599 werror="yes"
1600 else
1601 werror="no"
1602 fi
1603fi
1604
8d05095c 1605# check that the C compiler works.
93b25869 1606write_c_skeleton;
8d05095c
PB
1607if compile_object ; then
1608 : C compiler works ok
1609else
76ad07a4 1610 error_exit "\"$cc\" either does not exist or does not work"
8d05095c 1611fi
0ef74c74
PM
1612if ! compile_prog ; then
1613 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1614fi
8d05095c 1615
fb59dabd
PM
1616if test "$bogus_os" = "yes"; then
1617 # Now that we know that we're not printing the help and that
1618 # the compiler works (so the results of the check_defines we used
1619 # to identify the OS are reliable), if we didn't recognize the
1620 # host OS we should stop now.
951fedfc 1621 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
fb59dabd
PM
1622fi
1623
8d05095c
PB
1624gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1625gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
ac7568bd 1626gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
435405ac 1627gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
b98fcfd8 1628gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
71429097 1629gcc_flags="-Wno-string-plus-int $gcc_flags"
6ca026cb
PM
1630# Note that we do not add -Werror to gcc_flags here, because that would
1631# enable it for all configure tests. If a configure test failed due
1632# to -Werror this would just silently disable some features,
1633# so it's too error prone.
93b25869
JS
1634
1635cc_has_warning_flag() {
1636 write_c_skeleton;
1637
a1d29d6c
PM
1638 # Use the positive sense of the flag when testing for -Wno-wombat
1639 # support (gcc will happily accept the -Wno- form of unknown
1640 # warning options).
93b25869
JS
1641 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1642 compile_prog "-Werror $optflag" ""
1643}
1644
1645for flag in $gcc_flags; do
1646 if cc_has_warning_flag $flag ; then
1647 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
8d05095c
PB
1648 fi
1649done
1650
3b463a3f 1651if test "$stack_protector" != "no"; then
fccd35a0
RR
1652 cat > $TMPC << EOF
1653int main(int argc, char *argv[])
1654{
1655 char arr[64], *p = arr, *c = argv[0];
1656 while (*c) {
1657 *p++ = *c++;
1658 }
1659 return 0;
1660}
1661EOF
63678e17 1662 gcc_flags="-fstack-protector-strong -fstack-protector-all"
3b463a3f 1663 sp_on=0
63678e17 1664 for flag in $gcc_flags; do
590e5dd9
PM
1665 # We need to check both a compile and a link, since some compiler
1666 # setups fail only on a .c->.o compile and some only at link time
1667 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1668 compile_prog "-Werror $flag" ""; then
63678e17 1669 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
3b463a3f 1670 sp_on=1
63678e17
SN
1671 break
1672 fi
1673 done
3b463a3f
MR
1674 if test "$stack_protector" = yes; then
1675 if test $sp_on = 0; then
1676 error_exit "Stack protector not supported"
1677 fi
1678 fi
37746c5e
MAL
1679fi
1680
20bc94a2
PB
1681# Disable -Wmissing-braces on older compilers that warn even for
1682# the "universal" C zero initializer {0}.
1683cat > $TMPC << EOF
1684struct {
1685 int a[2];
1686} x = {0};
1687EOF
1688if compile_object "-Werror" "" ; then
1689 :
1690else
1691 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1692fi
1693
cbdd1999
PB
1694# Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1695# large functions that use global variables. The bug is in all releases of
1696# GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1697# 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1698cat > $TMPC << EOF
1699#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1700int main(void) { return 0; }
1701#else
1702#error No bug in this compiler.
1703#endif
1704EOF
1705if compile_prog "-Werror -fno-gcse" "" ; then
1706 TRANSLATE_OPT_CFLAGS=-fno-gcse
1707fi
1708
40d6444e 1709if test "$static" = "yes" ; then
aa0d1f44
PB
1710 if test "$modules" = "yes" ; then
1711 error_exit "static and modules are mutually incompatible"
1712 fi
40d6444e 1713 if test "$pie" = "yes" ; then
76ad07a4 1714 error_exit "static and pie are mutually incompatible"
40d6444e
AK
1715 else
1716 pie="no"
1717 fi
1718fi
1719
768b7855
EC
1720# Unconditional check for compiler __thread support
1721 cat > $TMPC << EOF
1722static __thread int tls_var;
1723int main(void) { return tls_var; }
1724EOF
1725
1726if ! compile_prog "-Werror" "" ; then
1727 error_exit "Your compiler does not support the __thread specifier for " \
1728 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1729fi
1730
40d6444e
AK
1731if test "$pie" = ""; then
1732 case "$cpu-$targetos" in
c72b26ec 1733 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
40d6444e
AK
1734 ;;
1735 *)
1736 pie="no"
1737 ;;
1738 esac
1739fi
1740
1741if test "$pie" != "no" ; then
1742 cat > $TMPC << EOF
21d4a791
AK
1743
1744#ifdef __linux__
1745# define THREAD __thread
1746#else
1747# define THREAD
1748#endif
1749
1750static THREAD int tls_var;
1751
1752int main(void) { return tls_var; }
1753
40d6444e
AK
1754EOF
1755 if compile_prog "-fPIE -DPIE" "-pie"; then
1756 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1757 LDFLAGS="-pie $LDFLAGS"
1758 pie="yes"
1759 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1760 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1761 fi
1762 else
1763 if test "$pie" = "yes"; then
76ad07a4 1764 error_exit "PIE not available due to missing toolchain support"
40d6444e
AK
1765 else
1766 echo "Disabling PIE due to missing toolchain support"
1767 pie="no"
1768 fi
1769 fi
46eef33b 1770
e4a7b344 1771 if compile_prog "-Werror -fno-pie" "-nopie"; then
46eef33b
BS
1772 CFLAGS_NOPIE="-fno-pie"
1773 LDFLAGS_NOPIE="-nopie"
1774 fi
40d6444e
AK
1775fi
1776
09dada40
PB
1777##########################################
1778# __sync_fetch_and_and requires at least -march=i486. Many toolchains
1779# use i686 as default anyway, but for those that don't, an explicit
1780# specification is necessary
1781
1782if test "$cpu" = "i386"; then
1783 cat > $TMPC << EOF
1784static int sfaa(int *ptr)
1785{
1786 return __sync_fetch_and_and(ptr, 0);
1787}
1788
1789int main(void)
1790{
1791 int val = 42;
1405b629 1792 val = __sync_val_compare_and_swap(&val, 0, 1);
09dada40
PB
1793 sfaa(&val);
1794 return val;
1795}
1796EOF
1797 if ! compile_prog "" "" ; then
1798 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1799 fi
1800fi
1801
1802#########################################
ec530c81 1803# Solaris specific configure tool chain decisions
09dada40 1804
ec530c81 1805if test "$solaris" = "yes" ; then
6792aa11
LM
1806 if has $install; then
1807 :
1808 else
76ad07a4
PM
1809 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1810 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1811 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
ec530c81 1812 fi
89138857 1813 if test "$(path_of $install)" = "/usr/sbin/install" ; then
76ad07a4
PM
1814 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1815 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1816 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
ec530c81 1817 fi
6792aa11
LM
1818 if has ar; then
1819 :
1820 else
ec530c81 1821 if test -f /usr/ccs/bin/ar ; then
76ad07a4
PM
1822 error_exit "No path includes ar" \
1823 "Add /usr/ccs/bin to your path and rerun configure"
ec530c81 1824 fi
76ad07a4 1825 error_exit "No path includes ar"
ec530c81 1826 fi
5fafdf24 1827fi
ec530c81 1828
afb63ebd 1829if test -z "${target_list+xxx}" ; then
d880a3ba
PB
1830 for target in $default_target_list; do
1831 supported_target $target 2>/dev/null && \
1832 target_list="$target_list $target"
1833 done
1834 target_list="${target_list# }"
121afa9e 1835else
89138857 1836 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
d880a3ba
PB
1837 for target in $target_list; do
1838 # Check that we recognised the target name; this allows a more
1839 # friendly error message than if we let it fall through.
1840 case " $default_target_list " in
1841 *" $target "*)
1842 ;;
1843 *)
1844 error_exit "Unknown target name '$target'"
1845 ;;
1846 esac
1847 supported_target $target || exit 1
1848 done
121afa9e 1849fi
25b48338 1850
f55fe278
PB
1851# see if system emulation was really requested
1852case " $target_list " in
1853 *"-softmmu "*) softmmu=yes
1854 ;;
1855 *) softmmu=no
1856 ;;
1857esac
5327cf48 1858
249247c9
JQ
1859feature_not_found() {
1860 feature=$1
21684af0 1861 remedy=$2
249247c9 1862
76ad07a4 1863 error_exit "User requested feature $feature" \
21684af0
SS
1864 "configure was not able to find it." \
1865 "$remedy"
249247c9
JQ
1866}
1867
7d13299d
FB
1868# ---
1869# big/little endian test
1870cat > $TMPC << EOF
61cc919f
MF
1871short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1872short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1873extern int foo(short *, short *);
1874int main(int argc, char *argv[]) {
1875 return foo(big_endian, little_endian);
7d13299d
FB
1876}
1877EOF
1878
61cc919f
MF
1879if compile_object ; then
1880 if grep -q BiGeNdIaN $TMPO ; then
1881 bigendian="yes"
1882 elif grep -q LiTtLeEnDiAn $TMPO ; then
1883 bigendian="no"
1884 else
1885 echo big/little test failed
21d89f84 1886 fi
61cc919f
MF
1887else
1888 echo big/little test failed
7d13299d
FB
1889fi
1890
a30878e7
PM
1891##########################################
1892# cocoa implies not SDL or GTK
1893# (the cocoa UI code currently assumes it is always the active UI
1894# and doesn't interact well with other UI frontend code)
1895if test "$cocoa" = "yes"; then
1896 if test "$sdl" = "yes"; then
1897 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1898 fi
1899 if test "$gtk" = "yes"; then
1900 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1901 fi
1902 gtk=no
1903 sdl=no
1904fi
1905
6b39b063
EB
1906# Some versions of Mac OS X incorrectly define SIZE_MAX
1907cat > $TMPC << EOF
1908#include <stdint.h>
1909#include <stdio.h>
1910int main(int argc, char *argv[]) {
1911 return printf("%zu", SIZE_MAX);
1912}
1913EOF
1914have_broken_size_max=no
1915if ! compile_object -Werror ; then
1916 have_broken_size_max=yes
1917fi
1918
015a33bd
GA
1919##########################################
1920# L2TPV3 probe
1921
1922cat > $TMPC <<EOF
1923#include <sys/socket.h>
bff6cb72 1924#include <linux/ip.h>
015a33bd
GA
1925int main(void) { return sizeof(struct mmsghdr); }
1926EOF
1927if compile_prog "" "" ; then
1928 l2tpv3=yes
1929else
1930 l2tpv3=no
1931fi
1932
4d9310f4
DB
1933##########################################
1934# MinGW / Mingw-w64 localtime_r/gmtime_r check
1935
1936if test "$mingw32" = "yes"; then
1937 # Some versions of MinGW / Mingw-w64 lack localtime_r
1938 # and gmtime_r entirely.
1939 #
1940 # Some versions of Mingw-w64 define a macro for
1941 # localtime_r/gmtime_r.
1942 #
1943 # Some versions of Mingw-w64 will define functions
1944 # for localtime_r/gmtime_r, but only if you have
1945 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
1946 # though, unistd.h and pthread.h both define
1947 # that for you.
1948 #
1949 # So this #undef localtime_r and #include <unistd.h>
1950 # are not in fact redundant.
1951cat > $TMPC << EOF
1952#include <unistd.h>
1953#include <time.h>
1954#undef localtime_r
1955int main(void) { localtime_r(NULL, NULL); return 0; }
1956EOF
1957 if compile_prog "" "" ; then
1958 localtime_r="yes"
1959 else
1960 localtime_r="no"
1961 fi
1962fi
1963
779ab5e3
SW
1964##########################################
1965# pkg-config probe
1966
1967if ! has "$pkg_config_exe"; then
76ad07a4 1968 error_exit "pkg-config binary '$pkg_config_exe' not found"
779ab5e3
SW
1969fi
1970
b0a47e79
JQ
1971##########################################
1972# NPTL probe
1973
24cb36a6 1974if test "$linux_user" = "yes"; then
b0a47e79 1975 cat > $TMPC <<EOF
bd0c5661 1976#include <sched.h>
30813cea 1977#include <linux/futex.h>
182eacc0 1978int main(void) {
bd0c5661
PB
1979#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1980#error bork
1981#endif
182eacc0 1982 return 0;
bd0c5661
PB
1983}
1984EOF
24cb36a6 1985 if ! compile_object ; then
21684af0 1986 feature_not_found "nptl" "Install glibc and linux kernel headers."
b0a47e79 1987 fi
bd0c5661
PB
1988fi
1989
99f2dbd3 1990#########################################
ac62922e
AZ
1991# zlib check
1992
1ece9905
AL
1993if test "$zlib" != "no" ; then
1994 cat > $TMPC << EOF
ac62922e
AZ
1995#include <zlib.h>
1996int main(void) { zlibVersion(); return 0; }
1997EOF
1ece9905
AL
1998 if compile_prog "" "-lz" ; then
1999 :
2000 else
76ad07a4
PM
2001 error_exit "zlib check failed" \
2002 "Make sure to have the zlib libs and headers installed."
1ece9905 2003 fi
ac62922e 2004fi
eb0ecd5a 2005LIBS="$LIBS -lz"
ac62922e 2006
607dacd0
QN
2007##########################################
2008# lzo check
2009
2010if test "$lzo" != "no" ; then
2011 cat > $TMPC << EOF
2012#include <lzo/lzo1x.h>
2013int main(void) { lzo_version(); return 0; }
2014EOF
2015 if compile_prog "" "-llzo2" ; then
b25c9dff
SW
2016 libs_softmmu="$libs_softmmu -llzo2"
2017 lzo="yes"
607dacd0 2018 else
b25c9dff
SW
2019 if test "$lzo" = "yes"; then
2020 feature_not_found "liblzo2" "Install liblzo2 devel"
2021 fi
2022 lzo="no"
607dacd0 2023 fi
607dacd0
QN
2024fi
2025
2026##########################################
2027# snappy check
2028
2029if test "$snappy" != "no" ; then
2030 cat > $TMPC << EOF
2031#include <snappy-c.h>
2032int main(void) { snappy_max_compressed_length(4096); return 0; }
2033EOF
2034 if compile_prog "" "-lsnappy" ; then
b25c9dff
SW
2035 libs_softmmu="$libs_softmmu -lsnappy"
2036 snappy="yes"
607dacd0 2037 else
b25c9dff
SW
2038 if test "$snappy" = "yes"; then
2039 feature_not_found "libsnappy" "Install libsnappy devel"
2040 fi
2041 snappy="no"
607dacd0 2042 fi
607dacd0
QN
2043fi
2044
6b383c08
PW
2045##########################################
2046# bzip2 check
2047
2048if test "$bzip2" != "no" ; then
2049 cat > $TMPC << EOF
2050#include <bzlib.h>
2051int main(void) { BZ2_bzlibVersion(); return 0; }
2052EOF
2053 if compile_prog "" "-lbz2" ; then
2054 bzip2="yes"
2055 else
2056 if test "$bzip2" = "yes"; then
2057 feature_not_found "libbzip2" "Install libbzip2 devel"
2058 fi
2059 bzip2="no"
2060 fi
2061fi
2062
f794573e
EO
2063##########################################
2064# libseccomp check
2065
2066if test "$seccomp" != "no" ; then
693e5910
AJ
2067 case "$cpu" in
2068 i386|x86_64)
ba060c53 2069 libseccomp_minver="2.1.0"
693e5910 2070 ;;
5ce43972
JH
2071 mips)
2072 libseccomp_minver="2.2.0"
2073 ;;
693e5910
AJ
2074 arm|aarch64)
2075 libseccomp_minver="2.2.3"
2076 ;;
3aa35fcf 2077 ppc|ppc64|s390x)
3e684455
MS
2078 libseccomp_minver="2.3.0"
2079 ;;
693e5910
AJ
2080 *)
2081 libseccomp_minver=""
2082 ;;
2083 esac
2084
2085 if test "$libseccomp_minver" != "" &&
2086 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
c3883e1f
FZ
2087 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2088 seccomp_libs="$($pkg_config --libs libseccomp)"
693e5910 2089 seccomp="yes"
f794573e 2090 else
693e5910
AJ
2091 if test "$seccomp" = "yes" ; then
2092 if test "$libseccomp_minver" != "" ; then
2093 feature_not_found "libseccomp" \
2094 "Install libseccomp devel >= $libseccomp_minver"
2095 else
2096 feature_not_found "libseccomp" \
2097 "libseccomp is not supported for host cpu $cpu"
2098 fi
2099 fi
2100 seccomp="no"
f794573e
EO
2101 fi
2102fi
e37630ca
AL
2103##########################################
2104# xen probe
2105
fc321b4b 2106if test "$xen" != "no" ; then
c1cdd9d5
JG
2107 # Check whether Xen library path is specified via --extra-ldflags to avoid
2108 # overriding this setting with pkg-config output. If not, try pkg-config
2109 # to obtain all needed flags.
2110
2111 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2112 $pkg_config --exists xencontrol ; then
2113 xen_ctrl_version="$(printf '%d%02d%02d' \
2114 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2115 xen=yes
2116 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2117 xen_pc="$xen_pc xenevtchn xendevicemodel"
2118 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2119 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2120 LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2121 else
d5b93ddf 2122
c1cdd9d5 2123 xen_libs="-lxenstore -lxenctrl -lxenguest"
d9506cab 2124 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
50ced5b3 2125
c1cdd9d5
JG
2126 # First we test whether Xen headers and libraries are available.
2127 # If no, we are done and there is no Xen support.
2128 # If yes, more tests are run to detect the Xen version.
2129
2130 # Xen (any)
2131 cat > $TMPC <<EOF
e37630ca 2132#include <xenctrl.h>
50ced5b3
SW
2133int main(void) {
2134 return 0;
2135}
2136EOF
c1cdd9d5
JG
2137 if ! compile_prog "" "$xen_libs" ; then
2138 # Xen not found
2139 if test "$xen" = "yes" ; then
2140 feature_not_found "xen" "Install xen devel"
2141 fi
2142 xen=no
50ced5b3 2143
c1cdd9d5
JG
2144 # Xen unstable
2145 elif
2146 cat > $TMPC <<EOF &&
5ba3d756
ID
2147#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2148#include <xenforeignmemory.h>
2149int main(void) {
2150 xenforeignmemory_handle *xfmem;
2151
2152 xfmem = xenforeignmemory_open(0, 0);
2153 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2154
2155 return 0;
2156}
2157EOF
2158 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2159 then
2160 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2161 xen_ctrl_version=41000
2162 xen=yes
2163 elif
2164 cat > $TMPC <<EOF &&
da8090cc
PD
2165#undef XC_WANT_COMPAT_DEVICEMODEL_API
2166#define __XEN_TOOLS__
2167#include <xendevicemodel.h>
2168int main(void) {
2169 xendevicemodel_handle *xd;
2170
2171 xd = xendevicemodel_open(0, 0);
2172 xendevicemodel_close(xd);
50ced5b3 2173
da8090cc
PD
2174 return 0;
2175}
2176EOF
c1cdd9d5
JG
2177 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2178 then
2179 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2180 xen_ctrl_version=40900
2181 xen=yes
2182 elif
2183 cat > $TMPC <<EOF &&
b6eb9b45
PS
2184/*
2185 * If we have stable libs the we don't want the libxc compat
2186 * layers, regardless of what CFLAGS we may have been given.
2187 *
2188 * Also, check if xengnttab_grant_copy_segment_t is defined and
2189 * grant copy operation is implemented.
2190 */
2191#undef XC_WANT_COMPAT_EVTCHN_API
2192#undef XC_WANT_COMPAT_GNTTAB_API
2193#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2194#include <xenctrl.h>
2195#include <xenstore.h>
2196#include <xenevtchn.h>
2197#include <xengnttab.h>
2198#include <xenforeignmemory.h>
2199#include <stdint.h>
2200#include <xen/hvm/hvm_info_table.h>
2201#if !defined(HVM_MAX_VCPUS)
2202# error HVM_MAX_VCPUS not defined
2203#endif
2204int main(void) {
2205 xc_interface *xc = NULL;
2206 xenforeignmemory_handle *xfmem;
2207 xenevtchn_handle *xe;
2208 xengnttab_handle *xg;
2209 xen_domain_handle_t handle;
2210 xengnttab_grant_copy_segment_t* seg = NULL;
2211
2212 xs_daemon_open();
2213
2214 xc = xc_interface_open(0, 0, 0);
2215 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2216 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2217 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2218 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2219 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2220
2221 xfmem = xenforeignmemory_open(0, 0);
2222 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2223
2224 xe = xenevtchn_open(0, 0);
2225 xenevtchn_fd(xe);
2226
2227 xg = xengnttab_open(0, 0);
2228 xengnttab_grant_copy(xg, 0, seg);
2229
2230 return 0;
2231}
2232EOF
c1cdd9d5
JG
2233 compile_prog "" "$xen_libs $xen_stable_libs"
2234 then
2235 xen_ctrl_version=40800
2236 xen=yes
2237 elif
2238 cat > $TMPC <<EOF &&
5eeb39c2
IC
2239/*
2240 * If we have stable libs the we don't want the libxc compat
2241 * layers, regardless of what CFLAGS we may have been given.
2242 */
2243#undef XC_WANT_COMPAT_EVTCHN_API
2244#undef XC_WANT_COMPAT_GNTTAB_API
2245#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2246#include <xenctrl.h>
2247#include <xenstore.h>
2248#include <xenevtchn.h>
2249#include <xengnttab.h>
2250#include <xenforeignmemory.h>
2251#include <stdint.h>
2252#include <xen/hvm/hvm_info_table.h>
2253#if !defined(HVM_MAX_VCPUS)
2254# error HVM_MAX_VCPUS not defined
2255#endif
2256int main(void) {
2257 xc_interface *xc = NULL;
2258 xenforeignmemory_handle *xfmem;
2259 xenevtchn_handle *xe;
2260 xengnttab_handle *xg;
2261 xen_domain_handle_t handle;
2262
2263 xs_daemon_open();
2264
2265 xc = xc_interface_open(0, 0, 0);
2266 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2267 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2268 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2269 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2270 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2271
2272 xfmem = xenforeignmemory_open(0, 0);
2273 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2274
2275 xe = xenevtchn_open(0, 0);
2276 xenevtchn_fd(xe);
2277
2278 xg = xengnttab_open(0, 0);
2279 xengnttab_map_grant_ref(xg, 0, 0, 0);
2280
2281 return 0;
2282}
2283EOF
c1cdd9d5
JG
2284 compile_prog "" "$xen_libs $xen_stable_libs"
2285 then
2286 xen_ctrl_version=40701
2287 xen=yes
2288 elif
2289 cat > $TMPC <<EOF &&
50ced5b3 2290#include <xenctrl.h>
cdadde39
RPM
2291#include <stdint.h>
2292int main(void) {
2293 xc_interface *xc = NULL;
2294 xen_domain_handle_t handle;
2295 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2296 return 0;
2297}
2298EOF
c1cdd9d5
JG
2299 compile_prog "" "$xen_libs"
2300 then
2301 xen_ctrl_version=40700
2302 xen=yes
2303
2304 # Xen 4.6
2305 elif
2306 cat > $TMPC <<EOF &&
cdadde39 2307#include <xenctrl.h>
e108a3c1 2308#include <xenstore.h>
d5b93ddf
AP
2309#include <stdint.h>
2310#include <xen/hvm/hvm_info_table.h>
2311#if !defined(HVM_MAX_VCPUS)
2312# error HVM_MAX_VCPUS not defined
2313#endif
d8b441a3
JB
2314int main(void) {
2315 xc_interface *xc;
2316 xs_daemon_open();
2317 xc = xc_interface_open(0, 0, 0);
2318 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2319 xc_gnttab_open(NULL, 0);
2320 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2321 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2322 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
20a544c7 2323 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
d8b441a3
JB
2324 return 0;
2325}
2326EOF
c1cdd9d5
JG
2327 compile_prog "" "$xen_libs"
2328 then
2329 xen_ctrl_version=40600
2330 xen=yes
2331
2332 # Xen 4.5
2333 elif
2334 cat > $TMPC <<EOF &&
d8b441a3
JB
2335#include <xenctrl.h>
2336#include <xenstore.h>
2337#include <stdint.h>
2338#include <xen/hvm/hvm_info_table.h>
2339#if !defined(HVM_MAX_VCPUS)
2340# error HVM_MAX_VCPUS not defined
2341#endif
3996e85c
PD
2342int main(void) {
2343 xc_interface *xc;
2344 xs_daemon_open();
2345 xc = xc_interface_open(0, 0, 0);
2346 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2347 xc_gnttab_open(NULL, 0);
2348 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2349 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2350 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2351 return 0;
2352}
2353EOF
c1cdd9d5
JG
2354 compile_prog "" "$xen_libs"
2355 then
2356 xen_ctrl_version=40500
2357 xen=yes
3996e85c 2358
c1cdd9d5
JG
2359 elif
2360 cat > $TMPC <<EOF &&
3996e85c
PD
2361#include <xenctrl.h>
2362#include <xenstore.h>
2363#include <stdint.h>
2364#include <xen/hvm/hvm_info_table.h>
2365#if !defined(HVM_MAX_VCPUS)
2366# error HVM_MAX_VCPUS not defined
2367#endif
8688e065
SS
2368int main(void) {
2369 xc_interface *xc;
2370 xs_daemon_open();
2371 xc = xc_interface_open(0, 0, 0);
2372 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2373 xc_gnttab_open(NULL, 0);
2374 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2375 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2376 return 0;
2377}
2378EOF
c1cdd9d5
JG
2379 compile_prog "" "$xen_libs"
2380 then
2381 xen_ctrl_version=40200
2382 xen=yes
8688e065 2383
c1cdd9d5
JG
2384 else
2385 if test "$xen" = "yes" ; then
2386 feature_not_found "xen (unsupported version)" \
2387 "Install a supported xen (xen 4.2 or newer)"
2388 fi
2389 xen=no
fc321b4b 2390 fi
d5b93ddf 2391
c1cdd9d5
JG
2392 if test "$xen" = yes; then
2393 if test $xen_ctrl_version -ge 40701 ; then
2394 libs_softmmu="$xen_stable_libs $libs_softmmu"
2395 fi
2396 libs_softmmu="$xen_libs $libs_softmmu"
5eeb39c2 2397 fi
d5b93ddf 2398 fi
e37630ca
AL
2399fi
2400
eb6fda0f 2401if test "$xen_pci_passthrough" != "no"; then
edfb07ed 2402 if test "$xen" = "yes" && test "$linux" = "yes"; then
eb6fda0f
AP
2403 xen_pci_passthrough=yes
2404 else
2405 if test "$xen_pci_passthrough" = "yes"; then
76ad07a4
PM
2406 error_exit "User requested feature Xen PCI Passthrough" \
2407 " but this feature requires /sys from Linux"
eb6fda0f
AP
2408 fi
2409 xen_pci_passthrough=no
2410 fi
2411fi
2412
64a7ad6f
IC
2413if test "$xen_pv_domain_build" = "yes" &&
2414 test "$xen" != "yes"; then
2415 error_exit "User requested Xen PV domain builder support" \
2416 "which requires Xen support."
2417fi
2418
dfffc653
JQ
2419##########################################
2420# Sparse probe
2421if test "$sparse" != "no" ; then
0dba6195 2422 if has cgcc; then
dfffc653
JQ
2423 sparse=yes
2424 else
2425 if test "$sparse" = "yes" ; then
21684af0 2426 feature_not_found "sparse" "Install sparse binary"
dfffc653
JQ
2427 fi
2428 sparse=no
2429 fi
2430fi
2431
f676c67e
JW
2432##########################################
2433# X11 probe
2434x11_cflags=
2435x11_libs=-lX11
2436if $pkg_config --exists "x11"; then
89138857
SW
2437 x11_cflags=$($pkg_config --cflags x11)
2438 x11_libs=$($pkg_config --libs x11)
f676c67e
JW
2439fi
2440
a4ccabcf
AL
2441##########################################
2442# GTK probe
2443
9e04c683 2444if test "$gtkabi" = ""; then
5fe309ff
GH
2445 # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
2446 # Use 2.0 as a fallback if that is available.
2447 if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
9e04c683 2448 gtkabi=3.0
5fe309ff 2449 elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
9e04c683 2450 gtkabi=2.0
5fe309ff
GH
2451 else
2452 gtkabi=3.0
9e04c683
SW
2453 fi
2454fi
2455
a4ccabcf 2456if test "$gtk" != "no"; then
528de90a 2457 gtkpackage="gtk+-$gtkabi"
0a337ed0 2458 gtkx11package="gtk+-x11-$gtkabi"
528de90a
DB
2459 if test "$gtkabi" = "3.0" ; then
2460 gtkversion="3.0.0"
bbbf9bfb
SW
2461 else
2462 gtkversion="2.18.0"
2463 fi
2464 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
89138857
SW
2465 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2466 gtk_libs=$($pkg_config --libs $gtkpackage)
2467 gtk_version=$($pkg_config --modversion $gtkpackage)
0a337ed0 2468 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
f676c67e
JW
2469 gtk_cflags="$gtk_cflags $x11_cflags"
2470 gtk_libs="$gtk_libs $x11_libs"
0a337ed0 2471 fi
bbbf9bfb
SW
2472 libs_softmmu="$gtk_libs $libs_softmmu"
2473 gtk="yes"
2474 elif test "$gtk" = "yes"; then
5fe309ff 2475 feature_not_found "gtk" "Install gtk3-devel"
bbbf9bfb
SW
2476 else
2477 gtk="no"
2478 fi
2479fi
2480
ddbb0d09
DB
2481
2482##########################################
2483# GNUTLS probe
2484
37371299
PM
2485gnutls_works() {
2486 # Unfortunately some distros have bad pkg-config information for gnutls
2487 # such that it claims to exist but you get a compiler error if you try
2488 # to use the options returned by --libs. Specifically, Ubuntu for --static
2489 # builds doesn't work:
2490 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2491 #
2492 # So sanity check the cflags/libs before assuming gnutls can be used.
2493 if ! $pkg_config --exists "gnutls"; then
2494 return 1
2495 fi
2496
2497 write_c_skeleton
2498 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2499}
2500
62893b67 2501gnutls_gcrypt=no
ed754746 2502gnutls_nettle=no
ddbb0d09 2503if test "$gnutls" != "no"; then
37371299 2504 if gnutls_works; then
89138857
SW
2505 gnutls_cflags=$($pkg_config --cflags gnutls)
2506 gnutls_libs=$($pkg_config --libs gnutls)
ddbb0d09
DB
2507 libs_softmmu="$gnutls_libs $libs_softmmu"
2508 libs_tools="$gnutls_libs $libs_tools"
2509 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2510 gnutls="yes"
2511
b917da4c
DB
2512 # gnutls_rnd requires >= 2.11.0
2513 if $pkg_config --exists "gnutls >= 2.11.0"; then
2514 gnutls_rnd="yes"
2515 else
2516 gnutls_rnd="no"
2517 fi
2518
62893b67
DB
2519 if $pkg_config --exists 'gnutls >= 3.0'; then
2520 gnutls_gcrypt=no
ed754746 2521 gnutls_nettle=yes
62893b67 2522 elif $pkg_config --exists 'gnutls >= 2.12'; then
89138857 2523 case $($pkg_config --libs --static gnutls) in
ed754746
DB
2524 *gcrypt*)
2525 gnutls_gcrypt=yes
2526 gnutls_nettle=no
2527 ;;
2528 *nettle*)
2529 gnutls_gcrypt=no
2530 gnutls_nettle=yes
2531 ;;
2532 *)
2533 gnutls_gcrypt=yes
2534 gnutls_nettle=no
2535 ;;
62893b67
DB
2536 esac
2537 else
2538 gnutls_gcrypt=yes
ed754746 2539 gnutls_nettle=no
62893b67 2540 fi
ddbb0d09
DB
2541 elif test "$gnutls" = "yes"; then
2542 feature_not_found "gnutls" "Install gnutls devel"
2543 else
2544 gnutls="no"
b917da4c 2545 gnutls_rnd="no"
ddbb0d09
DB
2546 fi
2547else
b917da4c 2548 gnutls_rnd="no"
ddbb0d09
DB
2549fi
2550
91bfcdb0
DB
2551
2552# If user didn't give a --disable/enable-gcrypt flag,
2553# then mark as disabled if user requested nettle
2554# explicitly, or if gnutls links to nettle
2555if test -z "$gcrypt"
2556then
2557 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2558 then
2559 gcrypt="no"
2560 fi
2561fi
2562
2563# If user didn't give a --disable/enable-nettle flag,
2564# then mark as disabled if user requested gcrypt
2565# explicitly, or if gnutls links to gcrypt
2566if test -z "$nettle"
2567then
2568 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2569 then
2570 nettle="no"
2571 fi
2572fi
2573
2574has_libgcrypt_config() {
2575 if ! has "libgcrypt-config"
2576 then
2577 return 1
2578 fi
2579
2580 if test -n "$cross_prefix"
2581 then
89138857 2582 host=$(libgcrypt-config --host)
91bfcdb0
DB
2583 if test "$host-" != $cross_prefix
2584 then
2585 return 1
2586 fi
2587 fi
2588
2589 return 0
2590}
2591
2592if test "$gcrypt" != "no"; then
2593 if has_libgcrypt_config; then
89138857
SW
2594 gcrypt_cflags=$(libgcrypt-config --cflags)
2595 gcrypt_libs=$(libgcrypt-config --libs)
91bfcdb0
DB
2596 # Debian has remove -lgpg-error from libgcrypt-config
2597 # as it "spreads unnecessary dependencies" which in
2598 # turn breaks static builds...
2599 if test "$static" = "yes"
2600 then
2601 gcrypt_libs="$gcrypt_libs -lgpg-error"
2602 fi
62893b67
DB
2603 libs_softmmu="$gcrypt_libs $libs_softmmu"
2604 libs_tools="$gcrypt_libs $libs_tools"
2605 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
91bfcdb0
DB
2606 gcrypt="yes"
2607 if test -z "$nettle"; then
2608 nettle="no"
2609 fi
37788f25
DB
2610
2611 cat > $TMPC << EOF
2612#include <gcrypt.h>
2613int main(void) {
2614 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2615 GCRY_MD_SHA256,
2616 NULL, 0, 0, 0, NULL);
2617 return 0;
2618}
2619EOF
2620 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2621 gcrypt_kdf=yes
2622 fi
1f923c70
LM
2623
2624 cat > $TMPC << EOF
2625#include <gcrypt.h>
2626int main(void) {
2627 gcry_mac_hd_t handle;
2628 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2629 GCRY_MAC_FLAG_SECURE, NULL);
2630 return 0;
2631}
2632EOF
2633 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2634 gcrypt_hmac=yes
2635 fi
62893b67 2636 else
91bfcdb0
DB
2637 if test "$gcrypt" = "yes"; then
2638 feature_not_found "gcrypt" "Install gcrypt devel"
2639 else
2640 gcrypt="no"
2641 fi
62893b67
DB
2642 fi
2643fi
2644
ddbb0d09 2645
91bfcdb0 2646if test "$nettle" != "no"; then
ed754746 2647 if $pkg_config --exists "nettle"; then
89138857
SW
2648 nettle_cflags=$($pkg_config --cflags nettle)
2649 nettle_libs=$($pkg_config --libs nettle)
2650 nettle_version=$($pkg_config --modversion nettle)
ed754746
DB
2651 libs_softmmu="$nettle_libs $libs_softmmu"
2652 libs_tools="$nettle_libs $libs_tools"
2653 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
91bfcdb0 2654 nettle="yes"
fff2f982
DB
2655
2656 cat > $TMPC << EOF
9e87a691 2657#include <stddef.h>
fff2f982
DB
2658#include <nettle/pbkdf2.h>
2659int main(void) {
2660 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2661 return 0;
2662}
2663EOF
2664 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2665 nettle_kdf=yes
2666 fi
ed754746 2667 else
91bfcdb0
DB
2668 if test "$nettle" = "yes"; then
2669 feature_not_found "nettle" "Install nettle devel"
2670 else
2671 nettle="no"
2672 fi
ed754746
DB
2673 fi
2674fi
2675
91bfcdb0
DB
2676if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2677then
2678 error_exit "Only one of gcrypt & nettle can be enabled"
2679fi
2680
9a2fd434
DB
2681##########################################
2682# libtasn1 - only for the TLS creds/session test suite
2683
2684tasn1=yes
90246037
DB
2685tasn1_cflags=""
2686tasn1_libs=""
9a2fd434 2687if $pkg_config --exists "libtasn1"; then
89138857
SW
2688 tasn1_cflags=$($pkg_config --cflags libtasn1)
2689 tasn1_libs=$($pkg_config --libs libtasn1)
9a2fd434
DB
2690else
2691 tasn1=no
2692fi
2693
ed754746 2694
559607ea
DB
2695##########################################
2696# getifaddrs (for tests/test-io-channel-socket )
2697
2698have_ifaddrs_h=yes
2699if ! check_include "ifaddrs.h" ; then
2700 have_ifaddrs_h=no
2701fi
2702
bbbf9bfb
SW
2703##########################################
2704# VTE probe
2705
2706if test "$vte" != "no"; then
2707 if test "$gtkabi" = "3.0"; then
c6feff9e
CR
2708 vteminversion="0.32.0"
2709 if $pkg_config --exists "vte-2.91"; then
2710 vtepackage="vte-2.91"
2711 else
2712 vtepackage="vte-2.90"
2713 fi
528de90a 2714 else
528de90a 2715 vtepackage="vte"
c6feff9e 2716 vteminversion="0.24.0"
528de90a 2717 fi
c6feff9e 2718 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
89138857
SW
2719 vte_cflags=$($pkg_config --cflags $vtepackage)
2720 vte_libs=$($pkg_config --libs $vtepackage)
2721 vteversion=$($pkg_config --modversion $vtepackage)
bbbf9bfb
SW
2722 libs_softmmu="$vte_libs $libs_softmmu"
2723 vte="yes"
2724 elif test "$vte" = "yes"; then
9e04c683 2725 if test "$gtkabi" = "3.0"; then
c6feff9e 2726 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
9e04c683
SW
2727 else
2728 feature_not_found "vte" "Install libvte devel"
2729 fi
0d185e63 2730 else
bbbf9bfb 2731 vte="no"
a4ccabcf
AL
2732 fi
2733fi
2734
11d9f695
FB
2735##########################################
2736# SDL probe
2737
3ec87ffe
PB
2738# Look for sdl configuration program (pkg-config or sdl-config). Try
2739# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
47c03744 2740
ee8466d0 2741if test "$sdlabi" = ""; then
8f4ea9cd 2742 if $pkg_config --exists "sdl2"; then
ee8466d0 2743 sdlabi=2.0
8f4ea9cd 2744 elif $pkg_config --exists "sdl"; then
ee8466d0 2745 sdlabi=1.2
8f4ea9cd
GH
2746 else
2747 sdlabi=2.0
ee8466d0
CR
2748 fi
2749fi
2750
47c03744
DA
2751if test $sdlabi = "2.0"; then
2752 sdl_config=$sdl2_config
2753 sdlname=sdl2
2754 sdlconfigname=sdl2_config
e07047cf 2755elif test $sdlabi = "1.2"; then
47c03744
DA
2756 sdlname=sdl
2757 sdlconfigname=sdl_config
e07047cf
CR
2758else
2759 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
47c03744
DA
2760fi
2761
89138857 2762if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
47c03744 2763 sdl_config=$sdlconfigname
3ec87ffe
PB
2764fi
2765
47c03744
DA
2766if $pkg_config $sdlname --exists; then
2767 sdlconfig="$pkg_config $sdlname"
89138857 2768 sdlversion=$($sdlconfig --modversion 2>/dev/null)
3ec87ffe
PB
2769elif has ${sdl_config}; then
2770 sdlconfig="$sdl_config"
89138857 2771 sdlversion=$($sdlconfig --version)
a0dfd8a4
LM
2772else
2773 if test "$sdl" = "yes" ; then
8f4ea9cd 2774 feature_not_found "sdl" "Install SDL2-devel"
a0dfd8a4
LM
2775 fi
2776 sdl=no
9316f803 2777fi
29e5bada 2778if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
3ec87ffe
PB
2779 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2780fi
11d9f695 2781
9316f803 2782sdl_too_old=no
c4198157 2783if test "$sdl" != "no" ; then
ac119f9d 2784 cat > $TMPC << EOF
11d9f695
FB
2785#include <SDL.h>
2786#undef main /* We don't want SDL to override our main() */
2787int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2788EOF
89138857 2789 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
74f42e18 2790 if test "$static" = "yes" ; then
5f37e6d4
TH
2791 if $pkg_config $sdlname --exists; then
2792 sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
2793 else
2794 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2795 fi
74f42e18 2796 else
89138857 2797 sdl_libs=$($sdlconfig --libs 2>/dev/null)
74f42e18 2798 fi
52166aa0 2799 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
89138857 2800 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
ac119f9d
JQ
2801 sdl_too_old=yes
2802 else
a30878e7 2803 sdl=yes
ac119f9d 2804 fi
cd01b4a3 2805
67c274d3 2806 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
ac119f9d 2807 if test "$sdl" = "yes" -a "$static" = "yes" ; then
67c274d3 2808 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
89138857
SW
2809 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2810 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
ac119f9d 2811 fi
52166aa0 2812 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
2813 :
2814 else
2815 sdl=no
2816 fi
2817 fi # static link
c4198157
JQ
2818 else # sdl not found
2819 if test "$sdl" = "yes" ; then
21684af0 2820 feature_not_found "sdl" "Install SDL devel"
c4198157
JQ
2821 fi
2822 sdl=no
ac119f9d 2823 fi # sdl compile test
a68551bc 2824fi
11d9f695 2825
5368a422 2826if test "$sdl" = "yes" ; then
ac119f9d 2827 cat > $TMPC <<EOF
5368a422
AL
2828#include <SDL.h>
2829#if defined(SDL_VIDEO_DRIVER_X11)
2830#include <X11/XKBlib.h>
2831#else
2832#error No x11 support
2833#endif
2834int main(void) { return 0; }
2835EOF
f676c67e
JW
2836 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2837 sdl_cflags="$sdl_cflags $x11_cflags"
2838 sdl_libs="$sdl_libs $x11_libs"
ac119f9d 2839 fi
5368a422
AL
2840fi
2841
2da776db
MH
2842##########################################
2843# RDMA needs OpenFabrics libraries
2844if test "$rdma" != "no" ; then
2845 cat > $TMPC <<EOF
2846#include <rdma/rdma_cma.h>
2847int main(void) { return 0; }
2848EOF
2849 rdma_libs="-lrdmacm -libverbs"
2850 if compile_prog "" "$rdma_libs" ; then
2851 rdma="yes"
2da776db
MH
2852 else
2853 if test "$rdma" = "yes" ; then
2854 error_exit \
2855 " OpenFabrics librdmacm/libibverbs not present." \
2856 " Your options:" \
2857 " (1) Fast: Install infiniband packages from your distro." \
2858 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2859 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2860 fi
2861 rdma="no"
2862 fi
2863fi
2864
95c6bff3 2865
2f9606b3
AL
2866##########################################
2867# VNC SASL detection
821601ea 2868if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
ea784e3b 2869 cat > $TMPC <<EOF
2f9606b3
AL
2870#include <sasl/sasl.h>
2871#include <stdio.h>
2872int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2873EOF
ea784e3b
JQ
2874 # Assuming Cyrus-SASL installed in /usr prefix
2875 vnc_sasl_cflags=""
2876 vnc_sasl_libs="-lsasl2"
2877 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2878 vnc_sasl=yes
2879 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
ca273d58 2880 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
ea784e3b
JQ
2881 else
2882 if test "$vnc_sasl" = "yes" ; then
21684af0 2883 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2f9606b3 2884 fi
ea784e3b
JQ
2885 vnc_sasl=no
2886 fi
2f9606b3
AL
2887fi
2888
2f6f5c7a
CC
2889##########################################
2890# VNC JPEG detection
821601ea 2891if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2f6f5c7a
CC
2892cat > $TMPC <<EOF
2893#include <stdio.h>
2894#include <jpeglib.h>
2895int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2896EOF
2897 vnc_jpeg_cflags=""
2898 vnc_jpeg_libs="-ljpeg"
2899 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2900 vnc_jpeg=yes
2901 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
ca273d58 2902 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2f6f5c7a
CC
2903 else
2904 if test "$vnc_jpeg" = "yes" ; then
21684af0 2905 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2f6f5c7a
CC
2906 fi
2907 vnc_jpeg=no
2908 fi
2909fi
2910
efe556ad
CC
2911##########################################
2912# VNC PNG detection
821601ea 2913if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
efe556ad
CC
2914cat > $TMPC <<EOF
2915//#include <stdio.h>
2916#include <png.h>
832ce9c2 2917#include <stddef.h>
efe556ad
CC
2918int main(void) {
2919 png_structp png_ptr;
2920 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
7edc3fed 2921 return png_ptr != 0;
efe556ad
CC
2922}
2923EOF
65d5d3f9 2924 if $pkg_config libpng --exists; then
89138857
SW
2925 vnc_png_cflags=$($pkg_config libpng --cflags)
2926 vnc_png_libs=$($pkg_config libpng --libs)
9af8025e 2927 else
efe556ad
CC
2928 vnc_png_cflags=""
2929 vnc_png_libs="-lpng"
9af8025e 2930 fi
efe556ad
CC
2931 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2932 vnc_png=yes
2933 libs_softmmu="$vnc_png_libs $libs_softmmu"
9af8025e 2934 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
efe556ad
CC
2935 else
2936 if test "$vnc_png" = "yes" ; then
21684af0 2937 feature_not_found "vnc-png" "Install libpng devel"
efe556ad
CC
2938 fi
2939 vnc_png=no
2940 fi
2941fi
2942
6a021536
GH
2943##########################################
2944# xkbcommon probe
2945if test "$xkbcommon" != "no" ; then
2946 if $pkg_config xkbcommon --exists; then
2947 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
2948 xkbcommon_libs=$($pkg_config xkbcommon --libs)
2949 xkbcommon=yes
2950 else
2951 if test "$xkbcommon" = "yes" ; then
2952 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
2953 fi
2954 xkbcommon=no
2955 fi
2956fi
2957
76655d6d
AL
2958##########################################
2959# fnmatch() probe, used for ACL routines
2960fnmatch="no"
2961cat > $TMPC << EOF
2962#include <fnmatch.h>
2963int main(void)
2964{
2965 fnmatch("foo", "foo", 0);
2966 return 0;
2967}
2968EOF
52166aa0 2969if compile_prog "" "" ; then
76655d6d
AL
2970 fnmatch="yes"
2971fi
2972
ee682d27 2973##########################################
c1bb86cd 2974# xfsctl() probe, used for file-posix.c
dce512de
CH
2975if test "$xfs" != "no" ; then
2976 cat > $TMPC << EOF
ffc41d10 2977#include <stddef.h> /* NULL */
dce512de
CH
2978#include <xfs/xfs.h>
2979int main(void)
2980{
2981 xfsctl(NULL, 0, 0, NULL);
2982 return 0;
2983}
2984EOF
2985 if compile_prog "" "" ; then
2986 xfs="yes"
2987 else
2988 if test "$xfs" = "yes" ; then
21684af0 2989 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
dce512de
CH
2990 fi
2991 xfs=no
2992 fi
2993fi
2994
8a16d273
TS
2995##########################################
2996# vde libraries probe
dfb278bd 2997if test "$vde" != "no" ; then
4baae0ac 2998 vde_libs="-lvdeplug"
8a16d273
TS
2999 cat > $TMPC << EOF
3000#include <libvdeplug.h>
4a7f0e06
PB
3001int main(void)
3002{
3003 struct vde_open_args a = {0, 0, 0};
fea08e08
PM
3004 char s[] = "";
3005 vde_open(s, s, &a);
4a7f0e06
PB
3006 return 0;
3007}
8a16d273 3008EOF
52166aa0 3009 if compile_prog "" "$vde_libs" ; then
4baae0ac 3010 vde=yes
dfb278bd
JQ
3011 else
3012 if test "$vde" = "yes" ; then
21684af0 3013 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
dfb278bd
JQ
3014 fi
3015 vde=no
4baae0ac 3016 fi
8a16d273
TS
3017fi
3018
58952137 3019##########################################
0a985b37
VM
3020# netmap support probe
3021# Apart from looking for netmap headers, we make sure that the host API version
3022# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3023# a minor/major version number. Minor new features will be marked with values up
3024# to 15, and if something happens that requires a change to the backend we will
3025# move above 15, submit the backend fixes and modify this two bounds.
58952137
VM
3026if test "$netmap" != "no" ; then
3027 cat > $TMPC << EOF
3028#include <inttypes.h>
3029#include <net/if.h>
3030#include <net/netmap.h>
3031#include <net/netmap_user.h>
0a985b37
VM
3032#if (NETMAP_API < 11) || (NETMAP_API > 15)
3033#error
3034#endif
58952137
VM
3035int main(void) { return 0; }
3036EOF
3037 if compile_prog "" "" ; then
3038 netmap=yes
3039 else
3040 if test "$netmap" = "yes" ; then
3041 feature_not_found "netmap"
3042 fi
3043 netmap=no
3044 fi
3045fi
3046
47e98658
CB
3047##########################################
3048# libcap-ng library probe
3049if test "$cap_ng" != "no" ; then
3050 cap_libs="-lcap-ng"
3051 cat > $TMPC << EOF
3052#include <cap-ng.h>
3053int main(void)
3054{
3055 capng_capability_to_name(CAPNG_EFFECTIVE);
3056 return 0;
3057}
3058EOF
3059 if compile_prog "" "$cap_libs" ; then
3060 cap_ng=yes
3061 libs_tools="$cap_libs $libs_tools"
3062 else
3063 if test "$cap_ng" = "yes" ; then
21684af0 3064 feature_not_found "cap_ng" "Install libcap-ng devel"
47e98658
CB
3065 fi
3066 cap_ng=no
3067 fi
3068fi
3069
8f28f3fb 3070##########################################
c2de5c91 3071# Sound support libraries probe
8f28f3fb 3072
c2de5c91 3073audio_drv_probe()
3074{
3075 drv=$1
3076 hdr=$2
3077 lib=$3
3078 exp=$4
3079 cfl=$5
3080 cat > $TMPC << EOF
3081#include <$hdr>
3082int main(void) { $exp }
8f28f3fb 3083EOF
52166aa0 3084 if compile_prog "$cfl" "$lib" ; then
c2de5c91 3085 :
3086 else
76ad07a4
PM
3087 error_exit "$drv check failed" \
3088 "Make sure to have the $drv libs and headers installed."
c2de5c91 3089 fi
3090}
3091
89138857 3092audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
c2de5c91 3093for drv in $audio_drv_list; do
3094 case $drv in
3095 alsa)
3096 audio_drv_probe $drv alsa/asoundlib.h -lasound \
e35bcb0c 3097 "return snd_pcm_close((snd_pcm_t *)0);"
b1149911 3098 alsa_libs="-lasound"
c2de5c91 3099 ;;
3100
b8e59f18 3101 pa)
e58ff62d
PK
3102 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3103 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
b1149911 3104 pulse_libs="-lpulse"
67f86e8e 3105 audio_pt_int="yes"
b8e59f18 3106 ;;
3107
373967b2
GH
3108 sdl)
3109 if test "$sdl" = "no"; then
3110 error_exit "sdl not found or disabled, can not use sdl audio driver"
3111 fi
3112 ;;
3113
997e690a 3114 coreaudio)
b1149911 3115 coreaudio_libs="-framework CoreAudio"
997e690a
JQ
3116 ;;
3117
a4bf6780 3118 dsound)
b1149911 3119 dsound_libs="-lole32 -ldxguid"
d5631638 3120 audio_win_int="yes"
a4bf6780
JQ
3121 ;;
3122
3123 oss)
b1149911 3124 oss_libs="$oss_lib"
a4bf6780
JQ
3125 ;;
3126
373967b2
GH
3127 wav)
3128 # XXX: Probes for CoreAudio, DirectSound
2f6a1ab0
BS
3129 ;;
3130
e4c63a6a 3131 *)
1c9b2a52 3132 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
76ad07a4
PM
3133 error_exit "Unknown driver '$drv' selected" \
3134 "Possible drivers are: $audio_possible_drivers"
e4c63a6a 3135 }
3136 ;;
c2de5c91 3137 esac
3138done
8f28f3fb 3139
2e4d9fb1
AJ
3140##########################################
3141# BrlAPI probe
3142
4ffcedb6 3143if test "$brlapi" != "no" ; then
eb82284f
JQ
3144 brlapi_libs="-lbrlapi"
3145 cat > $TMPC << EOF
2e4d9fb1 3146#include <brlapi.h>
832ce9c2 3147#include <stddef.h>
2e4d9fb1
AJ
3148int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3149EOF
52166aa0 3150 if compile_prog "" "$brlapi_libs" ; then
eb82284f 3151 brlapi=yes
4ffcedb6
JQ
3152 else
3153 if test "$brlapi" = "yes" ; then
21684af0 3154 feature_not_found "brlapi" "Install brlapi devel"
4ffcedb6
JQ
3155 fi
3156 brlapi=no
eb82284f
JQ
3157 fi
3158fi
2e4d9fb1 3159
4d3b6f6e
AZ
3160##########################################
3161# curses probe
a3605bf6
MT
3162if test "$curses" != "no" ; then
3163 if test "$mingw32" = "yes" ; then
8ddc5bf9
ST
3164 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3165 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
a3605bf6 3166 else
7c703002 3167 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
8ddc5bf9 3168 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
a3605bf6 3169 fi
c584a6d0 3170 curses_found=no
4d3b6f6e 3171 cat > $TMPC << EOF
8ddc5bf9 3172#include <locale.h>
4d3b6f6e 3173#include <curses.h>
8ddc5bf9 3174#include <wchar.h>
ef9a2524 3175int main(void) {
8ddc5bf9
ST
3176 wchar_t wch = L'w';
3177 setlocale(LC_ALL, "");
ef9a2524 3178 resize_term(0, 0);
8ddc5bf9
ST
3179 addwstr(L"wide chars\n");
3180 addnwstr(&wch, 1);
7c703002 3181 add_wch(WACS_DEGREE);
271f37ab 3182 return 0;
ef9a2524 3183}
4d3b6f6e 3184EOF
ecbe251f 3185 IFS=:
8ddc5bf9 3186 for curses_inc in $curses_inc_list; do
b01a4fd3
PM
3187 # Make sure we get the wide character prototypes
3188 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
7c703002 3189 IFS=:
8ddc5bf9
ST
3190 for curses_lib in $curses_lib_list; do
3191 unset IFS
3192 if compile_prog "$curses_inc" "$curses_lib" ; then
3193 curses_found=yes
3194 QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
3195 libs_softmmu="$curses_lib $libs_softmmu"
3196 break
3197 fi
3198 done
7c703002
ST
3199 if test "$curses_found" = yes ; then
3200 break
3201 fi
4f78ef9a 3202 done
ecbe251f 3203 unset IFS
c584a6d0
JQ
3204 if test "$curses_found" = "yes" ; then
3205 curses=yes
3206 else
3207 if test "$curses" = "yes" ; then
21684af0 3208 feature_not_found "curses" "Install ncurses devel"
c584a6d0
JQ
3209 fi
3210 curses=no
3211 fi
4f78ef9a 3212fi
4d3b6f6e 3213
769ce76d
AG
3214##########################################
3215# curl probe
788c8196 3216if test "$curl" != "no" ; then
65d5d3f9 3217 if $pkg_config libcurl --exists; then
a3605bf6
MT
3218 curlconfig="$pkg_config libcurl"
3219 else
3220 curlconfig=curl-config
3221 fi
769ce76d
AG
3222 cat > $TMPC << EOF
3223#include <curl/curl.h>
0b862ced 3224int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
769ce76d 3225EOF
89138857
SW
3226 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3227 curl_libs=$($curlconfig --libs 2>/dev/null)
b1d5a277 3228 if compile_prog "$curl_cflags" "$curl_libs" ; then
769ce76d 3229 curl=yes
788c8196
JQ
3230 else
3231 if test "$curl" = "yes" ; then
21684af0 3232 feature_not_found "curl" "Install libcurl devel"
788c8196
JQ
3233 fi
3234 curl=no
769ce76d
AG
3235 fi
3236fi # test "$curl"
3237
fb599c9a
AZ
3238##########################################
3239# bluez support probe
a20a6f46 3240if test "$bluez" != "no" ; then
e820e3f4
AZ
3241 cat > $TMPC << EOF
3242#include <bluetooth/bluetooth.h>
3243int main(void) { return bt_error(0); }
3244EOF
89138857
SW
3245 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3246 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
52166aa0 3247 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
a20a6f46 3248 bluez=yes
e482d56a 3249 libs_softmmu="$bluez_libs $libs_softmmu"
e820e3f4 3250 else
a20a6f46 3251 if test "$bluez" = "yes" ; then
21684af0 3252 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
a20a6f46 3253 fi
e820e3f4
AZ
3254 bluez="no"
3255 fi
fb599c9a
AZ
3256fi
3257
e18df141
AL
3258##########################################
3259# glib support probe
a52d28af 3260
ad04d8cb
PM
3261if test "$mingw32" = yes; then
3262 glib_req_ver=2.30
3263else
3264 glib_req_ver=2.22
3265fi
aa0d1f44
PB
3266glib_modules=gthread-2.0
3267if test "$modules" = yes; then
3268 glib_modules="$glib_modules gmodule-2.0"
3269fi
e26110cf 3270
4eaf7202
SJ
3271# This workaround is required due to a bug in pkg-config file for glib as it
3272# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3273
3274if test "$static" = yes -a "$mingw32" = yes; then
3275 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3276fi
3277
aa0d1f44 3278for i in $glib_modules; do
e26110cf 3279 if $pkg_config --atleast-version=$glib_req_ver $i; then
89138857
SW
3280 glib_cflags=$($pkg_config --cflags $i)
3281 glib_libs=$($pkg_config --libs $i)
4a058899 3282 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
e26110cf
FZ
3283 LIBS="$glib_libs $LIBS"
3284 libs_qga="$glib_libs $libs_qga"
3285 else
3286 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3287 fi
3288done
3289
977a82ab
DB
3290# Sanity check that the current size_t matches the
3291# size that glib thinks it should be. This catches
3292# problems on multi-arch where people try to build
3293# 32-bit QEMU while pointing at 64-bit glib headers
3294cat > $TMPC <<EOF
3295#include <glib.h>
3296#include <unistd.h>
3297
3298#define QEMU_BUILD_BUG_ON(x) \
3299 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3300
3301int main(void) {
3302 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3303 return 0;
3304}
3305EOF
3306
5919e032 3307if ! compile_prog "$CFLAGS" "$LIBS" ; then
977a82ab
DB
3308 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3309 "You probably need to set PKG_CONFIG_LIBDIR"\
3310 "to point to the right pkg-config files for your"\
3311 "build target"
3312fi
3313
9d41401b
MT
3314# g_test_trap_subprocess added in 2.38. Used by some tests.
3315glib_subprocess=yes
a049223a 3316if ! $pkg_config --atleast-version=2.38 glib-2.0; then
9d41401b
MT
3317 glib_subprocess=no
3318fi
3319
bbbf2e04
JS
3320# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3321cat > $TMPC << EOF
3322#include <glib.h>
3323int main(void) { return 0; }
3324EOF
3325if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3326 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3327 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3328 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3329 fi
3330fi
3331
e26110cf
FZ
3332##########################################
3333# SHA command probe for modules
3334if test "$modules" = yes; then
3335 shacmd_probe="sha1sum sha1 shasum"
3336 for c in $shacmd_probe; do
8ccefb91 3337 if has $c; then
e26110cf
FZ
3338 shacmd="$c"
3339 break
3340 fi
3341 done
3342 if test "$shacmd" = ""; then
3343 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3344 fi
e18df141
AL
3345fi
3346
e2134eb9
GH
3347##########################################
3348# pixman support probe
3349
35c4e86c 3350if test "$want_tools" = "no" -a "$softmmu" = "no"; then
74880fe2
RS
3351 pixman_cflags=
3352 pixman_libs=
35c4e86c 3353elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
89138857
SW
3354 pixman_cflags=$($pkg_config --cflags pixman-1)
3355 pixman_libs=$($pkg_config --libs pixman-1)
e2134eb9 3356else
c12b6d70
GH
3357 error_exit "pixman >= 0.21.8 not present." \
3358 "Please install the pixman devel package."
e2134eb9 3359fi
e2134eb9 3360
fe8fc5ae
PB
3361##########################################
3362# libmpathpersist probe
3363
3364if test "$mpath" != "no" ; then
3365 cat > $TMPC <<EOF
3366#include <libudev.h>
3367#include <mpath_persist.h>
3368unsigned mpath_mx_alloc_len = 1024;
3369int logsink;
b3f1c8c4
PB
3370static struct config *multipath_conf;
3371extern struct udev *udev;
3372extern struct config *get_multipath_config(void);
3373extern void put_multipath_config(struct config *conf);
3374struct udev *udev;
3375struct config *get_multipath_config(void) { return multipath_conf; }
3376void put_multipath_config(struct config *conf) { }
3377
fe8fc5ae 3378int main(void) {
b3f1c8c4
PB
3379 udev = udev_new();
3380 multipath_conf = mpath_lib_init();
fe8fc5ae
PB
3381 return 0;
3382}
3383EOF
3384 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3385 mpathpersist=yes
3386 else
3387 mpathpersist=no
3388 fi
3389else
3390 mpathpersist=no
3391fi
3392
17bff52b
MK
3393##########################################
3394# libcap probe
3395
3396if test "$cap" != "no" ; then
3397 cat > $TMPC <<EOF
3398#include <stdio.h>
3399#include <sys/capability.h>
cc939743 3400int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
17bff52b
MK
3401EOF
3402 if compile_prog "" "-lcap" ; then
3403 cap=yes
3404 else
3405 cap=no
3406 fi
3407fi
3408
414f0dab 3409##########################################
e5d355d1 3410# pthread probe
4b29ec41 3411PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3c529d93 3412
4dd75c70 3413pthread=no
e5d355d1 3414cat > $TMPC << EOF
3c529d93 3415#include <pthread.h>
7a42bbe4
SW
3416static void *f(void *p) { return NULL; }
3417int main(void) {
3418 pthread_t thread;
3419 pthread_create(&thread, 0, f, 0);
3420 return 0;
3421}
414f0dab 3422EOF
bd00d539
AF
3423if compile_prog "" "" ; then
3424 pthread=yes
3425else
3426 for pthread_lib in $PTHREADLIBS_LIST; do
3427 if compile_prog "" "$pthread_lib" ; then
3428 pthread=yes
e3c56761
PP
3429 found=no
3430 for lib_entry in $LIBS; do
3431 if test "$lib_entry" = "$pthread_lib"; then
3432 found=yes
3433 break
3434 fi
3435 done
3436 if test "$found" = "no"; then
3437 LIBS="$pthread_lib $LIBS"
3438 fi
409437e1 3439 PTHREAD_LIB="$pthread_lib"
bd00d539
AF
3440 break
3441 fi
3442 done
3443fi
414f0dab 3444
4617e593 3445if test "$mingw32" != yes -a "$pthread" = no; then
76ad07a4
PM
3446 error_exit "pthread check failed" \
3447 "Make sure to have the pthread libs and headers installed."
e5d355d1
AL
3448fi
3449
5c312079
DDAG
3450# check for pthread_setname_np
3451pthread_setname_np=no
3452cat > $TMPC << EOF
3453#include <pthread.h>
3454
3455static void *f(void *p) { return NULL; }
3456int main(void)
3457{
3458 pthread_t thread;
3459 pthread_create(&thread, 0, f, 0);
3460 pthread_setname_np(thread, "QEMU");
3461 return 0;
3462}
3463EOF
3464if compile_prog "" "$pthread_lib" ; then
3465 pthread_setname_np=yes
3466fi
3467
f27aaf4b
CB
3468##########################################
3469# rbd probe
3470if test "$rbd" != "no" ; then
3471 cat > $TMPC <<EOF
3472#include <stdio.h>
ad32e9c0 3473#include <rbd/librbd.h>
f27aaf4b 3474int main(void) {
ad32e9c0
JD
3475 rados_t cluster;
3476 rados_create(&cluster, NULL);
f27aaf4b
CB
3477 return 0;
3478}
3479EOF
ad32e9c0
JD
3480 rbd_libs="-lrbd -lrados"
3481 if compile_prog "" "$rbd_libs" ; then
3482 rbd=yes
f27aaf4b
CB
3483 else
3484 if test "$rbd" = "yes" ; then
21684af0 3485 feature_not_found "rados block device" "Install librbd/ceph devel"
f27aaf4b
CB
3486 fi
3487 rbd=no
3488 fi
f27aaf4b
CB
3489fi
3490
0a12ec87
RJ
3491##########################################
3492# libssh2 probe
4fc16838 3493min_libssh2_version=1.2.8
0a12ec87 3494if test "$libssh2" != "no" ; then
65d5d3f9 3495 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
89138857
SW
3496 libssh2_cflags=$($pkg_config libssh2 --cflags)
3497 libssh2_libs=$($pkg_config libssh2 --libs)
0a12ec87 3498 libssh2=yes
0a12ec87
RJ
3499 else
3500 if test "$libssh2" = "yes" ; then
4fc16838 3501 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
0a12ec87
RJ
3502 fi
3503 libssh2=no
3504 fi
3505fi
3506
9a2d462e
RJ
3507##########################################
3508# libssh2_sftp_fsync probe
3509
3510if test "$libssh2" = "yes"; then
3511 cat > $TMPC <<EOF
3512#include <stdio.h>
3513#include <libssh2.h>
3514#include <libssh2_sftp.h>
3515int main(void) {
3516 LIBSSH2_SESSION *session;
3517 LIBSSH2_SFTP *sftp;
3518 LIBSSH2_SFTP_HANDLE *sftp_handle;
3519 session = libssh2_session_init ();
3520 sftp = libssh2_sftp_init (session);
3521 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3522 libssh2_sftp_fsync (sftp_handle);
3523 return 0;
3524}
3525EOF
3526 # libssh2_cflags/libssh2_libs defined in previous test.
3527 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3528 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3529 fi
3530fi
3531
5c6c3a6c
CH
3532##########################################
3533# linux-aio probe
5c6c3a6c
CH
3534
3535if test "$linux_aio" != "no" ; then
3536 cat > $TMPC <<EOF
3537#include <libaio.h>
3538#include <sys/eventfd.h>
832ce9c2 3539#include <stddef.h>
5c6c3a6c
CH
3540int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3541EOF
3542 if compile_prog "" "-laio" ; then
3543 linux_aio=yes
5c6c3a6c
CH
3544 else
3545 if test "$linux_aio" = "yes" ; then
21684af0 3546 feature_not_found "linux AIO" "Install libaio devel"
5c6c3a6c 3547 fi
3cfcae3c 3548 linux_aio=no
5c6c3a6c
CH
3549 fi
3550fi
3551
3b8acc11
PB
3552##########################################
3553# TPM passthrough is only on x86 Linux
3554
3555if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3556 tpm_passthrough=$tpm
3557else
3558 tpm_passthrough=no
3559fi
3560
f4ede81e
AV
3561# TPM emulator is for all posix systems
3562if test "$mingw32" != "yes"; then
3563 tpm_emulator=$tpm
3564else
3565 tpm_emulator=no
3566fi
758e8e38
VJ
3567##########################################
3568# attr probe
3569
3570if test "$attr" != "no" ; then
3571 cat > $TMPC <<EOF
3572#include <stdio.h>
3573#include <sys/types.h>
f2338fb4
PB
3574#ifdef CONFIG_LIBATTR
3575#include <attr/xattr.h>
3576#else
4f26f2b6 3577#include <sys/xattr.h>
f2338fb4 3578#endif
758e8e38
VJ
3579int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3580EOF
4f26f2b6
AK
3581 if compile_prog "" "" ; then
3582 attr=yes
3583 # Older distros have <attr/xattr.h>, and need -lattr:
f2338fb4 3584 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
758e8e38
VJ
3585 attr=yes
3586 LIBS="-lattr $LIBS"
4f26f2b6 3587 libattr=yes
758e8e38
VJ
3588 else
3589 if test "$attr" = "yes" ; then
21684af0 3590 feature_not_found "ATTR" "Install libc6 or libattr devel"
758e8e38
VJ
3591 fi
3592 attr=no
3593 fi
3594fi
3595
bf9298b9
AL
3596##########################################
3597# iovec probe
3598cat > $TMPC <<EOF
db34f0b3 3599#include <sys/types.h>
bf9298b9 3600#include <sys/uio.h>
db34f0b3 3601#include <unistd.h>
f91f9bee 3602int main(void) { return sizeof(struct iovec); }
bf9298b9
AL
3603EOF
3604iovec=no
52166aa0 3605if compile_prog "" "" ; then
bf9298b9
AL
3606 iovec=yes
3607fi
3608
ceb42de8
AL
3609##########################################
3610# preadv probe
3611cat > $TMPC <<EOF
3612#include <sys/types.h>
3613#include <sys/uio.h>
3614#include <unistd.h>
c075a723 3615int main(void) { return preadv(0, 0, 0, 0); }
ceb42de8
AL
3616EOF
3617preadv=no
52166aa0 3618if compile_prog "" "" ; then
ceb42de8
AL
3619 preadv=yes
3620fi
3621
f652e6af
AJ
3622##########################################
3623# fdt probe
e169e1e1
PM
3624# fdt support is mandatory for at least some target architectures,
3625# so insist on it if we're building those system emulators.
3626fdt_required=no
3627for target in $target_list; do
3628 case $target in
df1d8a1f 3629 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
e169e1e1
PM
3630 fdt_required=yes
3631 ;;
3632 esac
3633done
3634
3635if test "$fdt_required" = "yes"; then
3636 if test "$fdt" = "no"; then
3637 error_exit "fdt disabled but some requested targets require it." \
3638 "You can turn off fdt only if you also disable all the system emulation" \
3639 "targets which need it (by specifying a cut down --target-list)."
3640 fi
3641 fdt=yes
3642fi
3643
2df87df7 3644if test "$fdt" != "no" ; then
b41af4ba 3645 fdt_libs="-lfdt"
96ce6545 3646 # explicitly check for libfdt_env.h as it is missing in some stable installs
6e85fce0 3647 # and test for required functions to make sure we are on a version >= 1.4.2
b41af4ba 3648 cat > $TMPC << EOF
31ce0adb 3649#include <libfdt.h>
96ce6545 3650#include <libfdt_env.h>
6e85fce0 3651int main(void) { fdt_first_subnode(0, 0); return 0; }
f652e6af 3652EOF
52166aa0 3653 if compile_prog "" "$fdt_libs" ; then
a540f158 3654 # system DTC is good - use it
f652e6af 3655 fdt=yes
a540f158 3656 else
aef45d51
DB
3657 # have GIT checkout, so activate dtc submodule
3658 if test -e "${source_path}/.git" ; then
3659 git_submodules="${git_submodules} dtc"
3660 fi
3661 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3662 fdt=yes
3663 dtc_internal="yes"
3664 mkdir -p dtc
3665 if [ "$pwd_is_source_path" != "y" ] ; then
3666 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3667 symlink "$source_path/dtc/scripts" "dtc/scripts"
3668 fi
3669 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3670 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3671 elif test "$fdt" = "yes" ; then
3672 # Not a git build & no libfdt found, prompt for system install
3673 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3674 "Please install the DTC (libfdt) devel package"
3675 else
3676 # don't have and don't want
3677 fdt_libs=
3678 fdt=no
3679 fi
f652e6af
AJ
3680 fi
3681fi
3682
a540f158
PC
3683libs_softmmu="$libs_softmmu $fdt_libs"
3684
20ff075b 3685##########################################
fb719563 3686# opengl probe (for sdl2, gtk, milkymist-tmu2)
b1546f32 3687
da076ffe 3688if test "$opengl" != "no" ; then
014cb152 3689 opengl_pkgs="epoxy libdrm gbm"
fb719563 3690 if $pkg_config $opengl_pkgs x11; then
f676c67e
JW
3691 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3692 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
da076ffe 3693 opengl=yes
925a0400
GH
3694 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3695 gtk_gl="yes"
3696 fi
cc720a5d 3697 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
20ff075b 3698 else
da076ffe 3699 if test "$opengl" = "yes" ; then
dcf30025 3700 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
20ff075b 3701 fi
f676c67e 3702 opengl_cflags=""
da076ffe
GH
3703 opengl_libs=""
3704 opengl=no
20ff075b
MW
3705 fi
3706fi
3707
014cb152
GH
3708if test "$opengl" = "yes"; then
3709 cat > $TMPC << EOF
3710#include <epoxy/egl.h>
3711#ifndef EGL_MESA_image_dma_buf_export
3712# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3713#endif
3714int main(void) { return 0; }
3715EOF
3716 if compile_prog "" "" ; then
3717 opengl_dmabuf=yes
3718 fi
3719fi
c9a12e75 3720
c9a12e75 3721
eb100396
BR
3722##########################################
3723# glusterfs probe
3724if test "$glusterfs" != "no" ; then
65d5d3f9 3725 if $pkg_config --atleast-version=3 glusterfs-api; then
e01bee08 3726 glusterfs="yes"
89138857
SW
3727 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3728 glusterfs_libs=$($pkg_config --libs glusterfs-api)
d85fa9eb
JC
3729 if $pkg_config --atleast-version=4 glusterfs-api; then
3730 glusterfs_xlator_opt="yes"
3731 fi
65d5d3f9 3732 if $pkg_config --atleast-version=5 glusterfs-api; then
0c14fb47
BR
3733 glusterfs_discard="yes"
3734 fi
7c815372 3735 if $pkg_config --atleast-version=6 glusterfs-api; then
df3a429a 3736 glusterfs_fallocate="yes"
7c815372
BR
3737 glusterfs_zerofill="yes"
3738 fi
eb100396
BR
3739 else
3740 if test "$glusterfs" = "yes" ; then
8efc9363
HT
3741 feature_not_found "GlusterFS backend support" \
3742 "Install glusterfs-api devel >= 3"
eb100396 3743 fi
e01bee08 3744 glusterfs="no"
eb100396
BR
3745 fi
3746fi
3747
39386ac7 3748# Check for inotify functions when we are building linux-user
3b3f24ad
AJ
3749# emulator. This is done because older glibc versions don't
3750# have syscall stubs for these implemented. In that case we
3751# don't provide them even if kernel supports them.
3752#
3753inotify=no
67ba57f6 3754cat > $TMPC << EOF
3b3f24ad
AJ
3755#include <sys/inotify.h>
3756
3757int
3758main(void)
3759{
3760 /* try to start inotify */
8690e420 3761 return inotify_init();
3b3f24ad
AJ
3762}
3763EOF
52166aa0 3764if compile_prog "" "" ; then
67ba57f6 3765 inotify=yes
3b3f24ad
AJ
3766fi
3767
c05c7a73
RV
3768inotify1=no
3769cat > $TMPC << EOF
3770#include <sys/inotify.h>
3771
3772int
3773main(void)
3774{
3775 /* try to start inotify */
3776 return inotify_init1(0);
3777}
3778EOF
3779if compile_prog "" "" ; then
3780 inotify1=yes
3781fi
3782
099d6b0f
RV
3783# check if pipe2 is there
3784pipe2=no
3785cat > $TMPC << EOF
099d6b0f
RV
3786#include <unistd.h>
3787#include <fcntl.h>
3788
3789int main(void)
3790{
3791 int pipefd[2];
9bca8162 3792 return pipe2(pipefd, O_CLOEXEC);
099d6b0f
RV
3793}
3794EOF
52166aa0 3795if compile_prog "" "" ; then
099d6b0f
RV
3796 pipe2=yes
3797fi
3798
40ff6d7e
KW
3799# check if accept4 is there
3800accept4=no
3801cat > $TMPC << EOF
40ff6d7e
KW
3802#include <sys/socket.h>
3803#include <stddef.h>
3804
3805int main(void)
3806{
3807 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3808 return 0;
3809}
3810EOF
3811if compile_prog "" "" ; then
3812 accept4=yes
3813fi
3814
3ce34dfb
VS
3815# check if tee/splice is there. vmsplice was added same time.
3816splice=no
3817cat > $TMPC << EOF
3ce34dfb
VS
3818#include <unistd.h>
3819#include <fcntl.h>
3820#include <limits.h>
3821
3822int main(void)
3823{
66ea0f22 3824 int len, fd = 0;
3ce34dfb
VS
3825 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3826 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3827 return 0;
3828}
3829EOF
52166aa0 3830if compile_prog "" "" ; then
3ce34dfb
VS
3831 splice=yes
3832fi
3833
a99d57bb
WG
3834##########################################
3835# libnuma probe
3836
3837if test "$numa" != "no" ; then
3838 cat > $TMPC << EOF
3839#include <numa.h>
3840int main(void) { return numa_available(); }
3841EOF
3842
3843 if compile_prog "" "-lnuma" ; then
3844 numa=yes
3845 libs_softmmu="-lnuma $libs_softmmu"
3846 else
3847 if test "$numa" = "yes" ; then
3848 feature_not_found "numa" "install numactl devel"
3849 fi
3850 numa=no
3851 fi
3852fi
3853
7b01cb97
AD
3854if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3855 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3856 exit 1
3857fi
3858
2847b469
FZ
3859##########################################
3860# tcmalloc probe
3861
3862if test "$tcmalloc" = "yes" ; then
3863 cat > $TMPC << EOF
3864#include <stdlib.h>
3865int main(void) { malloc(1); return 0; }
3866EOF
3867
3868 if compile_prog "" "-ltcmalloc" ; then
3869 LIBS="-ltcmalloc $LIBS"
3870 else
3871 feature_not_found "tcmalloc" "install gperftools devel"
3872 fi
3873fi
3874
7b01cb97
AD
3875##########################################
3876# jemalloc probe
3877
3878if test "$jemalloc" = "yes" ; then
3879 cat > $TMPC << EOF
3880#include <stdlib.h>
3881int main(void) { malloc(1); return 0; }
3882EOF
3883
3884 if compile_prog "" "-ljemalloc" ; then
3885 LIBS="-ljemalloc $LIBS"
3886 else
3887 feature_not_found "jemalloc" "install jemalloc devel"
3888 fi
3889fi
3890
dcc38d1c
MT
3891##########################################
3892# signalfd probe
3893signalfd="no"
3894cat > $TMPC << EOF
dcc38d1c
MT
3895#include <unistd.h>
3896#include <sys/syscall.h>
3897#include <signal.h>
3898int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3899EOF
3900
3901if compile_prog "" "" ; then
3902 signalfd=yes
3903fi
3904
c2882b96
RV
3905# check if eventfd is supported
3906eventfd=no
3907cat > $TMPC << EOF
3908#include <sys/eventfd.h>
3909
3910int main(void)
3911{
55cc7f3e 3912 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
c2882b96
RV
3913}
3914EOF
3915if compile_prog "" "" ; then
3916 eventfd=yes
3917fi
3918
751bcc39
MAL
3919# check if memfd is supported
3920memfd=no
3921cat > $TMPC << EOF
3922#include <sys/memfd.h>
3923
3924int main(void)
3925{
3926 return memfd_create("foo", MFD_ALLOW_SEALING);
3927}
3928EOF
3929if compile_prog "" "" ; then
3930 memfd=yes
3931fi
3932
3933
3934
d0927938
UH
3935# check for fallocate
3936fallocate=no
3937cat > $TMPC << EOF
3938#include <fcntl.h>
3939
3940int main(void)
3941{
3942 fallocate(0, 0, 0, 0);
3943 return 0;
3944}
3945EOF
8fb03151 3946if compile_prog "" "" ; then
d0927938
UH
3947 fallocate=yes
3948fi
3949
3d4fa43e
KK
3950# check for fallocate hole punching
3951fallocate_punch_hole=no
3952cat > $TMPC << EOF
3953#include <fcntl.h>
3954#include <linux/falloc.h>
3955
3956int main(void)
3957{
3958 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
3959 return 0;
3960}
3961EOF
3962if compile_prog "" "" ; then
3963 fallocate_punch_hole=yes
3964fi
3965
b953f075
DL
3966# check that fallocate supports range zeroing inside the file
3967fallocate_zero_range=no
3968cat > $TMPC << EOF
3969#include <fcntl.h>
3970#include <linux/falloc.h>
3971
3972int main(void)
3973{
3974 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3975 return 0;
3976}
3977EOF
3978if compile_prog "" "" ; then
3979 fallocate_zero_range=yes
3980fi
3981
ed911435
KW
3982# check for posix_fallocate
3983posix_fallocate=no
3984cat > $TMPC << EOF
3985#include <fcntl.h>
3986
3987int main(void)
3988{
3989 posix_fallocate(0, 0, 0);
3990 return 0;
3991}
3992EOF
3993if compile_prog "" "" ; then
3994 posix_fallocate=yes
3995fi
3996
c727f47d
PM
3997# check for sync_file_range
3998sync_file_range=no
3999cat > $TMPC << EOF
4000#include <fcntl.h>
4001
4002int main(void)
4003{
4004 sync_file_range(0, 0, 0, 0);
4005 return 0;
4006}
4007EOF
8fb03151 4008if compile_prog "" "" ; then
c727f47d
PM
4009 sync_file_range=yes
4010fi
4011
dace20dc
PM
4012# check for linux/fiemap.h and FS_IOC_FIEMAP
4013fiemap=no
4014cat > $TMPC << EOF
4015#include <sys/ioctl.h>
4016#include <linux/fs.h>
4017#include <linux/fiemap.h>
4018
4019int main(void)
4020{
4021 ioctl(0, FS_IOC_FIEMAP, 0);
4022 return 0;
4023}
4024EOF
8fb03151 4025if compile_prog "" "" ; then
dace20dc
PM
4026 fiemap=yes
4027fi
4028
d0927938
UH
4029# check for dup3
4030dup3=no
4031cat > $TMPC << EOF
4032#include <unistd.h>
4033
4034int main(void)
4035{
4036 dup3(0, 0, 0);
4037 return 0;
4038}
4039EOF
78f5d726 4040if compile_prog "" "" ; then
d0927938
UH
4041 dup3=yes
4042fi
4043
4e0c6529
AB
4044# check for ppoll support
4045ppoll=no
4046cat > $TMPC << EOF
4047#include <poll.h>
4048
4049int main(void)
4050{
4051 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4052 ppoll(&pfd, 1, 0, 0);
4053 return 0;
4054}
4055EOF
4056if compile_prog "" "" ; then
4057 ppoll=yes
4058fi
4059
cd758dd0
AB
4060# check for prctl(PR_SET_TIMERSLACK , ... ) support
4061prctl_pr_set_timerslack=no
4062cat > $TMPC << EOF
4063#include <sys/prctl.h>
4064
4065int main(void)
4066{
4067 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4068 return 0;
4069}
4070EOF
4071if compile_prog "" "" ; then
4072 prctl_pr_set_timerslack=yes
4073fi
4074
3b6edd16
PM
4075# check for epoll support
4076epoll=no
4077cat > $TMPC << EOF
4078#include <sys/epoll.h>
4079
4080int main(void)
4081{
4082 epoll_create(0);
4083 return 0;
4084}
4085EOF
8fb03151 4086if compile_prog "" "" ; then
3b6edd16
PM
4087 epoll=yes
4088fi
4089
227f0214
PM
4090# epoll_create1 is a later addition
4091# so we must check separately for its presence
3b6edd16
PM
4092epoll_create1=no
4093cat > $TMPC << EOF
4094#include <sys/epoll.h>
4095
4096int main(void)
4097{
19e83f6b
PM
4098 /* Note that we use epoll_create1 as a value, not as
4099 * a function being called. This is necessary so that on
4100 * old SPARC glibc versions where the function was present in
4101 * the library but not declared in the header file we will
4102 * fail the configure check. (Otherwise we will get a compiler
4103 * warning but not an error, and will proceed to fail the
4104 * qemu compile where we compile with -Werror.)
4105 */
c075a723 4106 return (int)(uintptr_t)&epoll_create1;
3b6edd16
PM
4107}
4108EOF
8fb03151 4109if compile_prog "" "" ; then
3b6edd16
PM
4110 epoll_create1=yes
4111fi
4112
a8fd1aba
PM
4113# check for sendfile support
4114sendfile=no
4115cat > $TMPC << EOF
4116#include <sys/sendfile.h>
4117
4118int main(void)
4119{
4120 return sendfile(0, 0, 0, 0);
4121}
4122EOF
4123if compile_prog "" "" ; then
4124 sendfile=yes
4125fi
4126
51834341
RV
4127# check for timerfd support (glibc 2.8 and newer)
4128timerfd=no
4129cat > $TMPC << EOF
4130#include <sys/timerfd.h>
4131
4132int main(void)
4133{
4134 return(timerfd_create(CLOCK_REALTIME, 0));
4135}
4136EOF
4137if compile_prog "" "" ; then
4138 timerfd=yes
4139fi
4140
9af5c906
RV
4141# check for setns and unshare support
4142setns=no
4143cat > $TMPC << EOF
4144#include <sched.h>
4145
4146int main(void)
4147{
4148 int ret;
4149 ret = setns(0, 0);
4150 ret = unshare(0);
4151 return ret;
4152}
4153EOF
4154if compile_prog "" "" ; then
4155 setns=yes
4156fi
4157
38860a03
AM
4158# clock_adjtime probe
4159clock_adjtime=no
4160cat > $TMPC <<EOF
4161#include <time.h>
4162
4163int main(void)
4164{
4165 return clock_adjtime(0, 0);
4166}
4167EOF
4168clock_adjtime=no
4169if compile_prog "" "" ; then
4170 clock_adjtime=yes
4171fi
4172
5a03cd00
AM
4173# syncfs probe
4174syncfs=no
4175cat > $TMPC <<EOF
4176#include <unistd.h>
4177
4178int main(void)
4179{
4180 return syncfs(0);
4181}
4182EOF
4183syncfs=no
4184if compile_prog "" "" ; then
4185 syncfs=yes
4186fi
4187
cc8ae6de 4188# Check if tools are available to build documentation.
a25dba17 4189if test "$docs" != "no" ; then
01668d98 4190 if has makeinfo && has pod2man; then
a25dba17 4191 docs=yes
83a3ab8b 4192 else
a25dba17 4193 if test "$docs" = "yes" ; then
21684af0 4194 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
83a3ab8b 4195 fi
a25dba17 4196 docs=no
83a3ab8b 4197 fi
cc8ae6de
PB
4198fi
4199
f514f41c 4200# Search for bswap_32 function
6ae9a1f4
JQ
4201byteswap_h=no
4202cat > $TMPC << EOF
4203#include <byteswap.h>
4204int main(void) { return bswap_32(0); }
4205EOF
52166aa0 4206if compile_prog "" "" ; then
6ae9a1f4
JQ
4207 byteswap_h=yes
4208fi
4209
75f13596 4210# Search for bswap32 function
6ae9a1f4
JQ
4211bswap_h=no
4212cat > $TMPC << EOF
4213#include <sys/endian.h>
4214#include <sys/types.h>
4215#include <machine/bswap.h>
4216int main(void) { return bswap32(0); }
4217EOF
52166aa0 4218if compile_prog "" "" ; then
6ae9a1f4
JQ
4219 bswap_h=yes
4220fi
4221
c589b249 4222##########################################
e49ab19f 4223# Do we have libiscsi >= 1.9.0
c589b249 4224if test "$libiscsi" != "no" ; then
e49ab19f 4225 if $pkg_config --atleast-version=1.9.0 libiscsi; then
3c33ea96 4226 libiscsi="yes"
ca871ec8
SW
4227 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4228 libiscsi_libs=$($pkg_config --libs libiscsi)
c589b249
RS
4229 else
4230 if test "$libiscsi" = "yes" ; then
e49ab19f 4231 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
c589b249
RS
4232 fi
4233 libiscsi="no"
4234 fi
4235fi
4236
8bacde8d
NC
4237##########################################
4238# Do we need libm
4239cat > $TMPC << EOF
4240#include <math.h>
f80ea986 4241int main(int argc, char **argv) { return isnan(sin((double)argc)); }
8bacde8d
NC
4242EOF
4243if compile_prog "" "" ; then
4244 :
4245elif compile_prog "" "-lm" ; then
4246 LIBS="-lm $LIBS"
4247 libs_qga="-lm $libs_qga"
4248else
76ad07a4 4249 error_exit "libm check failed"
8bacde8d
NC
4250fi
4251
da93a1fd
AL
4252##########################################
4253# Do we need librt
8bacde8d
NC
4254# uClibc provides 2 versions of clock_gettime(), one with realtime
4255# support and one without. This means that the clock_gettime() don't
4256# need -lrt. We still need it for timer_create() so we check for this
4257# function in addition.
da93a1fd
AL
4258cat > $TMPC <<EOF
4259#include <signal.h>
4260#include <time.h>
8bacde8d
NC
4261int main(void) {
4262 timer_create(CLOCK_REALTIME, NULL, NULL);
4263 return clock_gettime(CLOCK_REALTIME, NULL);
4264}
da93a1fd
AL
4265EOF
4266
52166aa0 4267if compile_prog "" "" ; then
07ffa4bd 4268 :
8bacde8d 4269# we need pthread for static linking. use previous pthread test result
18e588b1
RL
4270elif compile_prog "" "$pthread_lib -lrt" ; then
4271 LIBS="$LIBS -lrt"
4272 libs_qga="$libs_qga -lrt"
da93a1fd
AL
4273fi
4274
31ff504d 4275if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
78723752 4276 "$haiku" != "yes" ; then
6362a53f
JQ
4277 libs_softmmu="-lutil $libs_softmmu"
4278fi
4279
de5071c5 4280##########################################
cd4ec0b4
GH
4281# spice probe
4282if test "$spice" != "no" ; then
4283 cat > $TMPC << EOF
4284#include <spice.h>
4285int main(void) { spice_server_new(); return 0; }
4286EOF
710fc4f5
JD
4287 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4288 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
65d5d3f9
SW
4289 if $pkg_config --atleast-version=0.12.0 spice-server && \
4290 $pkg_config --atleast-version=0.12.3 spice-protocol && \
cd4ec0b4
GH
4291 compile_prog "$spice_cflags" "$spice_libs" ; then
4292 spice="yes"
4293 libs_softmmu="$libs_softmmu $spice_libs"
4294 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2e0e3c39
AL
4295 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4296 spice_server_version=$($pkg_config --modversion spice-server)
cd4ec0b4
GH
4297 else
4298 if test "$spice" = "yes" ; then
8efc9363
HT
4299 feature_not_found "spice" \
4300 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
cd4ec0b4
GH
4301 fi
4302 spice="no"
4303 fi
4304fi
4305
7b02f544 4306# check for smartcard support
7b02f544
MAL
4307if test "$smartcard" != "no"; then
4308 if $pkg_config libcacard; then
4309 libcacard_cflags=$($pkg_config --cflags libcacard)
4310 libcacard_libs=$($pkg_config --libs libcacard)
7b02f544 4311 smartcard="yes"
afd347ab 4312 else
7b02f544
MAL
4313 if test "$smartcard" = "yes"; then
4314 feature_not_found "smartcard" "Install libcacard devel"
111a38b0 4315 fi
7b02f544 4316 smartcard="no"
111a38b0
RR
4317 fi
4318fi
111a38b0 4319
2b2325ff
GH
4320# check for libusb
4321if test "$libusb" != "no" ; then
65d5d3f9 4322 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
2b2325ff 4323 libusb="yes"
ca871ec8
SW
4324 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4325 libusb_libs=$($pkg_config --libs libusb-1.0)
2b2325ff
GH
4326 else
4327 if test "$libusb" = "yes"; then
8efc9363 4328 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
2b2325ff
GH
4329 fi
4330 libusb="no"
4331 fi
4332fi
4333
69354a83
HG
4334# check for usbredirparser for usb network redirection support
4335if test "$usb_redir" != "no" ; then
65d5d3f9 4336 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
69354a83 4337 usb_redir="yes"
ca871ec8
SW
4338 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4339 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
69354a83
HG
4340 else
4341 if test "$usb_redir" = "yes"; then
21684af0 4342 feature_not_found "usb-redir" "Install usbredir devel"
69354a83
HG
4343 fi
4344 usb_redir="no"
4345 fi
4346fi
4347
d9840e25
TS
4348##########################################
4349# check if we have VSS SDK headers for win
4350
4351if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4352 case "$vss_win32_sdk" in
690604f6 4353 "") vss_win32_include="-isystem $source_path" ;;
d9840e25
TS
4354 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4355 # handle path with spaces. So we symlink the headers into ".sdk/vss".
690604f6 4356 vss_win32_include="-isystem $source_path/.sdk/vss"
d9840e25
TS
4357 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4358 ;;
690604f6 4359 *) vss_win32_include="-isystem $vss_win32_sdk"
d9840e25
TS
4360 esac
4361 cat > $TMPC << EOF
4362#define __MIDL_user_allocate_free_DEFINED__
4363#include <inc/win2003/vss.h>
4364int main(void) { return VSS_CTX_BACKUP; }
4365EOF
4366 if compile_prog "$vss_win32_include" "" ; then
4367 guest_agent_with_vss="yes"
4368 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
315d3184 4369 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
f33ca81f 4370 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
d9840e25
TS
4371 else
4372 if test "$vss_win32_sdk" != "" ; then
4373 echo "ERROR: Please download and install Microsoft VSS SDK:"
4374 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4375 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4376 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4377 echo "ERROR: The headers are extracted in the directory \`inc'."
4378 feature_not_found "VSS support"
4379 fi
4380 guest_agent_with_vss="no"
4381 fi
4382fi
4383
4384##########################################
4385# lookup Windows platform SDK (if not specified)
4386# The SDK is needed only to build .tlb (type library) file of guest agent
4387# VSS provider from the source. It is usually unnecessary because the
4388# pre-compiled .tlb file is included.
4389
4390if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4391 if test -z "$win_sdk"; then
4392 programfiles="$PROGRAMFILES"
4393 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4394 if test -n "$programfiles"; then
4395 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4396 else
4397 feature_not_found "Windows SDK"
4398 fi
4399 elif test "$win_sdk" = "no"; then
4400 win_sdk=""
4401 fi
4402fi
4403
50cbebb9
MR
4404##########################################
4405# check if mingw environment provides a recent ntddscsi.h
4406if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4407 cat > $TMPC << EOF
4408#include <windows.h>
4409#include <ntddscsi.h>
4410int main(void) {
4411#if !defined(IOCTL_SCSI_GET_ADDRESS)
4412#error Missing required ioctl definitions
4413#endif
4414 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4415 return addr.Lun;
4416}
4417EOF
4418 if compile_prog "" "" ; then
4419 guest_agent_ntddscsi=yes
c54e1eb4 4420 libs_qga="-lsetupapi $libs_qga"
50cbebb9
MR
4421 fi
4422fi
4423
9d9e1521
GH
4424##########################################
4425# virgl renderer probe
4426
4427if test "$virglrenderer" != "no" ; then
4428 cat > $TMPC << EOF
4429#include <virglrenderer.h>
4430int main(void) { virgl_renderer_poll(); return 0; }
4431EOF
4432 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4433 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4434 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4435 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4436 virglrenderer="yes"
4437 else
4438 if test "$virglrenderer" = "yes" ; then
4439 feature_not_found "virglrenderer"
4440 fi
4441 virglrenderer="no"
4442 fi
4443fi
4444
8ca80760
RH
4445##########################################
4446# capstone
4447
e219c499
RH
4448case "$capstone" in
4449 "" | yes)
4450 if $pkg_config capstone; then
4451 capstone=system
4452 elif test -e "${source_path}/.git" ; then
4453 capstone=git
4454 elif test -e "${source_path}/capstone/Makefile" ; then
4455 capstone=internal
4456 elif test -z "$capstone" ; then
4457 capstone=no
4458 else
4459 feature_not_found "capstone" "Install capstone devel or git submodule"
4460 fi
4461 ;;
4462
4463 system)
4464 if ! $pkg_config capstone; then
4465 feature_not_found "capstone" "Install capstone devel"
4466 fi
4467 ;;
4468esac
4469
4470case "$capstone" in
4471 git | internal)
4472 if test "$capstone" = git; then
4473 git_submodules="${git_submodules} capstone"
4474 fi
4475 mkdir -p capstone
4476 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4477 if test "$mingw32" = "yes"; then
4478 LIBCAPSTONE=capstone.lib
4479 else
4480 LIBCAPSTONE=libcapstone.a
4481 fi
4482 LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4483 ;;
4484
4485 system)
8ca80760
RH
4486 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
4487 LIBS="$($pkg_config --libs capstone) $LIBS"
e219c499
RH
4488 ;;
4489
4490 no)
4491 ;;
4492 *)
4493 error_exit "Unknown state for capstone: $capstone"
4494 ;;
4495esac
8ca80760 4496
5f6b9e8f
BS
4497##########################################
4498# check if we have fdatasync
4499
4500fdatasync=no
4501cat > $TMPC << EOF
4502#include <unistd.h>
d1722a27
AR
4503int main(void) {
4504#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4505return fdatasync(0);
4506#else
e172fe11 4507#error Not supported
d1722a27
AR
4508#endif
4509}
5f6b9e8f
BS
4510EOF
4511if compile_prog "" "" ; then
4512 fdatasync=yes
4513fi
4514
e78815a5
AF
4515##########################################
4516# check if we have madvise
4517
4518madvise=no
4519cat > $TMPC << EOF
4520#include <sys/types.h>
4521#include <sys/mman.h>
832ce9c2 4522#include <stddef.h>
e78815a5
AF
4523int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4524EOF
4525if compile_prog "" "" ; then
4526 madvise=yes
4527fi
4528
4529##########################################
4530# check if we have posix_madvise
4531
4532posix_madvise=no
4533cat > $TMPC << EOF
4534#include <sys/mman.h>
832ce9c2 4535#include <stddef.h>
e78815a5
AF
4536int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4537EOF
4538if compile_prog "" "" ; then
4539 posix_madvise=yes
4540fi
4541
0a852417
PD
4542##########################################
4543# check if we have posix_syslog
4544
4545posix_syslog=no
4546cat > $TMPC << EOF
4547#include <syslog.h>
4548int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4549EOF
4550if compile_prog "" "" ; then
4551 posix_syslog=yes
4552fi
4553
401bc051
PM
4554##########################################
4555# check if we have sem_timedwait
4556
4557sem_timedwait=no
4558cat > $TMPC << EOF
4559#include <semaphore.h>
4560int main(void) { return sem_timedwait(0, 0); }
4561EOF
4562if compile_prog "" "" ; then
4563 sem_timedwait=yes
4564fi
4565
94a420b1
SH
4566##########################################
4567# check if trace backend exists
4568
5b808275 4569$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
94a420b1 4570if test "$?" -ne 0 ; then
5b808275
LV
4571 error_exit "invalid trace backends" \
4572 "Please choose supported trace backends."
94a420b1
SH
4573fi
4574
7e24e92a
SH
4575##########################################
4576# For 'ust' backend, test if ust headers are present
5b808275 4577if have_backend "ust"; then
7e24e92a 4578 cat > $TMPC << EOF
bf15f63c 4579#include <lttng/tracepoint.h>
7e24e92a
SH
4580int main(void) { return 0; }
4581EOF
c79ed23d 4582 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
bf15f63c 4583 if $pkg_config lttng-ust --exists; then
89138857 4584 lttng_ust_libs=$($pkg_config --libs lttng-ust)
bf15f63c 4585 else
c79ed23d 4586 lttng_ust_libs="-llttng-ust -ldl"
bf15f63c
MG
4587 fi
4588 if $pkg_config liburcu-bp --exists; then
89138857 4589 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
bf15f63c
MG
4590 else
4591 urcu_bp_libs="-lurcu-bp"
4592 fi
4593
4594 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4595 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
7e24e92a 4596 else
bf15f63c 4597 error_exit "Trace backend 'ust' missing lttng-ust header files"
7e24e92a
SH
4598 fi
4599fi
b3d08c02
DB
4600
4601##########################################
4602# For 'dtrace' backend, test if 'dtrace' command is present
5b808275 4603if have_backend "dtrace"; then
b3d08c02 4604 if ! has 'dtrace' ; then
76ad07a4 4605 error_exit "dtrace command is not found in PATH $PATH"
b3d08c02 4606 fi
c276b17d
DB
4607 trace_backend_stap="no"
4608 if has 'stap' ; then
4609 trace_backend_stap="yes"
4610 fi
b3d08c02
DB
4611fi
4612
023367e6 4613##########################################
519175a2 4614# check and set a backend for coroutine
d0e2fce5 4615
7c2acc70 4616# We prefer ucontext, but it's not always possible. The fallback
33c53c54
DB
4617# is sigcontext. On Windows the only valid backend is the Windows
4618# specific one.
7c2acc70
PM
4619
4620ucontext_works=no
4621if test "$darwin" != "yes"; then
4622 cat > $TMPC << EOF
d0e2fce5 4623#include <ucontext.h>
cdf84806
PM
4624#ifdef __stub_makecontext
4625#error Ignoring glibc stub makecontext which will always fail
4626#endif
75cafad7 4627int main(void) { makecontext(0, 0, 0); return 0; }
d0e2fce5 4628EOF
7c2acc70
PM
4629 if compile_prog "" "" ; then
4630 ucontext_works=yes
4631 fi
4632fi
4633
4634if test "$coroutine" = ""; then
4635 if test "$mingw32" = "yes"; then
4636 coroutine=win32
4637 elif test "$ucontext_works" = "yes"; then
4638 coroutine=ucontext
4639 else
4640 coroutine=sigaltstack
d0e2fce5 4641 fi
519175a2 4642else
7c2acc70
PM
4643 case $coroutine in
4644 windows)
4645 if test "$mingw32" != "yes"; then
4646 error_exit "'windows' coroutine backend only valid for Windows"
4647 fi
4648 # Unfortunately the user visible backend name doesn't match the
4649 # coroutine-*.c filename for this case, so we have to adjust it here.
4650 coroutine=win32
4651 ;;
4652 ucontext)
4653 if test "$ucontext_works" != "yes"; then
4654 feature_not_found "ucontext"
4655 fi
4656 ;;
33c53c54 4657 sigaltstack)
7c2acc70
PM
4658 if test "$mingw32" = "yes"; then
4659 error_exit "only the 'windows' coroutine backend is valid for Windows"
4660 fi
4661 ;;
4662 *)
4663 error_exit "unknown coroutine backend $coroutine"
4664 ;;
4665 esac
d0e2fce5
AK
4666fi
4667
70c60c08 4668if test "$coroutine_pool" = ""; then
33c53c54 4669 coroutine_pool=yes
70c60c08
SH
4670fi
4671
7d992e4d
PL
4672if test "$debug_stack_usage" = "yes"; then
4673 if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
4674 error_exit "stack usage debugging is not supported for $cpu"
4675 fi
4676 if test "$coroutine_pool" = "yes"; then
4677 echo "WARN: disabling coroutine pool for stack usage debugging"
4678 coroutine_pool=no
4679 fi
4680fi
4681
4682
d2042378
AK
4683##########################################
4684# check if we have open_by_handle_at
4685
4e1797f9 4686open_by_handle_at=no
d2042378
AK
4687cat > $TMPC << EOF
4688#include <fcntl.h>
acc55ba8
SW
4689#if !defined(AT_EMPTY_PATH)
4690# error missing definition
4691#else
75cafad7 4692int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
acc55ba8 4693#endif
d2042378
AK
4694EOF
4695if compile_prog "" "" ; then
4696 open_by_handle_at=yes
4697fi
4698
e06a765e
HPB
4699########################################
4700# check if we have linux/magic.h
4701
4702linux_magic_h=no
4703cat > $TMPC << EOF
4704#include <linux/magic.h>
4705int main(void) {
75cafad7 4706 return 0;
e06a765e
HPB
4707}
4708EOF
4709if compile_prog "" "" ; then
4710 linux_magic_h=yes
4711fi
4712
06d71fa1 4713########################################
c95e3080
KW
4714# check whether we can disable warning option with a pragma (this is needed
4715# to silence warnings in the headers of some versions of external libraries).
4716# This test has to be compiled with -Werror as otherwise an unknown pragma is
4717# only a warning.
4718#
4719# If we can't selectively disable warning in the code, disable -Werror so that
4720# the build doesn't fail anyway.
4721
06d71fa1
PM
4722pragma_disable_unused_but_set=no
4723cat > $TMPC << EOF
e6f53fd5 4724#pragma GCC diagnostic push
06d71fa1 4725#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
c95e3080 4726#pragma GCC diagnostic ignored "-Wstrict-prototypes"
e6f53fd5 4727#pragma GCC diagnostic pop
c95e3080 4728
06d71fa1
PM
4729int main(void) {
4730 return 0;
4731}
4732EOF
4733if compile_prog "-Werror" "" ; then
cc6e3ca9 4734 pragma_diagnostic_available=yes
c95e3080
KW
4735else
4736 werror=no
06d71fa1
PM
4737fi
4738
3f4349dc 4739########################################
541be927 4740# check if we have valgrind/valgrind.h
3f4349dc
KW
4741
4742valgrind_h=no
4743cat > $TMPC << EOF
4744#include <valgrind/valgrind.h>
3f4349dc 4745int main(void) {
3f4349dc
KW
4746 return 0;
4747}
4748EOF
4749if compile_prog "" "" ; then
4750 valgrind_h=yes
4751fi
4752
8ab1bf12
LC
4753########################################
4754# check if environ is declared
4755
4756has_environ=no
4757cat > $TMPC << EOF
4758#include <unistd.h>
4759int main(void) {
c075a723 4760 environ = 0;
8ab1bf12
LC
4761 return 0;
4762}
4763EOF
4764if compile_prog "" "" ; then
4765 has_environ=yes
4766fi
4767
76a347e1
RH
4768########################################
4769# check if cpuid.h is usable.
4770
76a347e1
RH
4771cat > $TMPC << EOF
4772#include <cpuid.h>
4773int main(void) {
774d566c
PM
4774 unsigned a, b, c, d;
4775 int max = __get_cpuid_max(0, 0);
4776
4777 if (max >= 1) {
4778 __cpuid(1, a, b, c, d);
4779 }
4780
4781 if (max >= 7) {
4782 __cpuid_count(7, 0, a, b, c, d);
4783 }
4784
4785 return 0;
76a347e1
RH
4786}
4787EOF
4788if compile_prog "" "" ; then
4789 cpuid_h=yes
4790fi
4791
5dd89908
RH
4792##########################################
4793# avx2 optimization requirement check
4794#
4795# There is no point enabling this if cpuid.h is not usable,
4796# since we won't be able to select the new routines.
4797
4798if test $cpuid_h = yes; then
4799 cat > $TMPC << EOF
4800#pragma GCC push_options
4801#pragma GCC target("avx2")
4802#include <cpuid.h>
4803#include <immintrin.h>
4804static int bar(void *a) {
4805 __m256i x = *(__m256i *)a;
4806 return _mm256_testz_si256(x, x);
4807}
4808int main(int argc, char *argv[]) { return bar(argv[0]); }
4809EOF
4810 if compile_object "" ; then
4811 avx2_opt="yes"
4812 fi
4813fi
4814
f540166b
RH
4815########################################
4816# check if __[u]int128_t is usable.
4817
4818int128=no
4819cat > $TMPC << EOF
a00f66ab
SW
4820#if defined(__clang_major__) && defined(__clang_minor__)
4821# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4822# error __int128_t does not work in CLANG before 3.2
4823# endif
4824#endif
f540166b
RH
4825__int128_t a;
4826__uint128_t b;
4827int main (void) {
4828 a = a + b;
4829 b = a * b;
464e3671 4830 a = a * a;
f540166b
RH
4831 return 0;
4832}
4833EOF
4834if compile_prog "" "" ; then
4835 int128=yes
4836fi
76a347e1 4837
7ebee43e
RH
4838#########################################
4839# See if 128-bit atomic operations are supported.
4840
4841atomic128=no
4842if test "$int128" = "yes"; then
4843 cat > $TMPC << EOF
4844int main(void)
4845{
4846 unsigned __int128 x = 0, y = 0;
4847 y = __atomic_load_16(&x, 0);
4848 __atomic_store_16(&x, y, 0);
4849 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
4850 return 0;
4851}
4852EOF
4853 if compile_prog "" "" ; then
4854 atomic128=yes
4855 fi
4856fi
4857
df79b996
RH
4858#########################################
4859# See if 64-bit atomic operations are supported.
4860# Note that without __atomic builtins, we can only
4861# assume atomic loads/stores max at pointer size.
4862
4863cat > $TMPC << EOF
4864#include <stdint.h>
4865int main(void)
4866{
4867 uint64_t x = 0, y = 0;
4868#ifdef __ATOMIC_RELAXED
4869 y = __atomic_load_8(&x, 0);
4870 __atomic_store_8(&x, y, 0);
4871 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4872 __atomic_exchange_8(&x, y, 0);
4873 __atomic_fetch_add_8(&x, y, 0);
4874#else
4875 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4876 __sync_lock_test_and_set(&x, y);
4877 __sync_val_compare_and_swap(&x, y, 0);
4878 __sync_fetch_and_add(&x, y);
4879#endif
4880 return 0;
4881}
4882EOF
4883if compile_prog "" "" ; then
4884 atomic64=yes
4885fi
4886
1e6e9aca
RH
4887########################################
4888# check if getauxval is available.
4889
4890getauxval=no
4891cat > $TMPC << EOF
4892#include <sys/auxv.h>
4893int main(void) {
4894 return getauxval(AT_HWCAP) == 0;
4895}
4896EOF
4897if compile_prog "" "" ; then
4898 getauxval=yes
4899fi
4900
fd0e6053
JS
4901########################################
4902# check if ccache is interfering with
4903# semantic analysis of macros
4904
5e4dfd3d 4905unset CCACHE_CPP2
fd0e6053
JS
4906ccache_cpp2=no
4907cat > $TMPC << EOF
4908static const int Z = 1;
4909#define fn() ({ Z; })
4910#define TAUT(X) ((X) == Z)
4911#define PAREN(X, Y) (X == Y)
4912#define ID(X) (X)
4913int main(int argc, char *argv[])
4914{
4915 int x = 0, y = 0;
4916 x = ID(x);
4917 x = fn();
4918 fn();
4919 if (PAREN(x, y)) return 0;
4920 if (TAUT(Z)) return 0;
4921 return 0;
4922}
4923EOF
4924
4925if ! compile_object "-Werror"; then
4926 ccache_cpp2=yes
4927fi
4928
b553a042
JS
4929#################################################
4930# clang does not support glibc + FORTIFY_SOURCE.
4931
4932if test "$fortify_source" != "no"; then
4933 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4934 fortify_source="no";
e189091f 4935 elif test -n "$cxx" && has $cxx &&
cfcc7c14 4936 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
b553a042
JS
4937 fortify_source="no";
4938 else
4939 fortify_source="yes"
4940 fi
4941fi
4942
277abf15
JV
4943##########################################
4944# check if struct fsxattr is available via linux/fs.h
4945
4946have_fsxattr=no
4947cat > $TMPC << EOF
4948#include <linux/fs.h>
4949struct fsxattr foo;
4950int main(void) {
4951 return 0;
4952}
4953EOF
4954if compile_prog "" "" ; then
4955 have_fsxattr=yes
4956fi
4957
b66e10e4
PM
4958##########################################
4959# check if rtnetlink.h exists and is useful
575b22b1
LV
4960have_rtnetlink=no
4961cat > $TMPC << EOF
4962#include <linux/rtnetlink.h>
4963int main(void) {
4964 return IFLA_PROTO_DOWN;
4965}
4966EOF
4967if compile_prog "" "" ; then
4968 have_rtnetlink=yes
4969fi
4970
6a02c806
SH
4971##########################################
4972# check for usable AF_VSOCK environment
4973have_af_vsock=no
4974cat > $TMPC << EOF
4975#include <errno.h>
4976#include <sys/types.h>
4977#include <sys/socket.h>
4978#if !defined(AF_VSOCK)
4979# error missing AF_VSOCK flag
4980#endif
4981#include <linux/vm_sockets.h>
4982int main(void) {
4983 int sock, ret;
4984 struct sockaddr_vm svm;
4985 socklen_t len = sizeof(svm);
4986 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
4987 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
4988 if ((ret == -1) && (errno == ENOTCONN)) {
4989 return 0;
4990 }
4991 return -1;
4992}
4993EOF
4994if compile_prog "" "" ; then
4995 have_af_vsock=yes
4996fi
4997
f0d92b56
LM
4998##########################################
4999# check for usable AF_ALG environment
5000hava_afalg=no
5001cat > $TMPC << EOF
5002#include <errno.h>
5003#include <sys/types.h>
5004#include <sys/socket.h>
5005#include <linux/if_alg.h>
5006int main(void) {
5007 int sock;
5008 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5009 return sock;
5010}
5011EOF
5012if compile_prog "" "" ; then
5013 have_afalg=yes
5014fi
5015if test "$crypto_afalg" = "yes"
5016then
5017 if test "$have_afalg" != "yes"
5018 then
5019 error_exit "AF_ALG requested but could not be detected"
5020 fi
5021fi
5022
5023
6969ec6c
JC
5024#################################################
5025# Sparc implicitly links with --relax, which is
5026# incompatible with -r, so --no-relax should be
5027# given. It does no harm to give it on other
5028# platforms too.
5029
5030# Note: the prototype is needed since QEMU_CFLAGS
5031# contains -Wmissing-prototypes
5032cat > $TMPC << EOF
5033extern int foo(void);
5034int foo(void) { return 0; }
5035EOF
5036if ! compile_object ""; then
5037 error_exit "Failed to compile object file for LD_REL_FLAGS test"
5038fi
7ecf44a5
PB
5039for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
5040 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
5041 LD_REL_FLAGS=$i
5042 break
5043 fi
5044done
5045if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
5046 feature_not_found "modules" "Cannot find how to build relocatable objects"
6969ec6c
JC
5047fi
5048
4d04351f
CC
5049##########################################
5050# check for sysmacros.h
5051
5052have_sysmacros=no
5053cat > $TMPC << EOF
5054#include <sys/sysmacros.h>
5055int main(void) {
5056 return makedev(0, 0);
5057}
5058EOF
5059if compile_prog "" "" ; then
5060 have_sysmacros=yes
5061fi
5062
da92c3ff
AM
5063##########################################
5064# Veritas HyperScale block driver VxHS
5065# Check if libvxhs is installed
5066
5067if test "$vxhs" != "no" ; then
5068 cat > $TMPC <<EOF
5069#include <stdint.h>
5070#include <qnio/qnio_api.h>
5071
5072void *vxhs_callback;
5073
5074int main(void) {
5075 iio_init(QNIO_VERSION, vxhs_callback);
5076 return 0;
5077}
5078EOF
5079 vxhs_libs="-lvxhs -lssl"
5080 if compile_prog "" "$vxhs_libs" ; then
5081 vxhs=yes
5082 else
5083 if test "$vxhs" = "yes" ; then
5084 feature_not_found "vxhs block device" "Install libvxhs See github"
5085 fi
5086 vxhs=no
5087 fi
5088fi
5089
49e00a18
AG
5090##########################################
5091# check for _Static_assert()
5092
5093have_static_assert=no
5094cat > $TMPC << EOF
5095_Static_assert(1, "success");
5096int main(void) {
5097 return 0;
5098}
5099EOF
5100if compile_prog "" "" ; then
5101 have_static_assert=yes
5102fi
5103
e674605f
TG
5104##########################################
5105# check for utmpx.h, it is missing e.g. on OpenBSD
5106
5107have_utmpx=no
5108cat > $TMPC << EOF
5109#include <utmpx.h>
5110struct utmpx user_info;
5111int main(void) {
5112 return 0;
5113}
5114EOF
5115if compile_prog "" "" ; then
5116 have_utmpx=yes
5117fi
5118
7e24e92a 5119##########################################
e86ecd4b
JQ
5120# End of CC checks
5121# After here, no more $cc or $ld runs
5122
1d728c39
BS
5123if test "$gcov" = "yes" ; then
5124 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
5125 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
b553a042 5126elif test "$fortify_source" = "yes" ; then
e600cdf3 5127 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
ce278618
PM
5128elif test "$debug" = "no"; then
5129 CFLAGS="-O2 $CFLAGS"
e86ecd4b 5130fi
a316e378 5131
6542aa9c
PL
5132##########################################
5133# Do we have libnfs
5134if test "$libnfs" != "no" ; then
b7d769c9 5135 if $pkg_config --atleast-version=1.9.3 libnfs; then
6542aa9c
PL
5136 libnfs="yes"
5137 libnfs_libs=$($pkg_config --libs libnfs)
6542aa9c
PL
5138 else
5139 if test "$libnfs" = "yes" ; then
8efc9363 5140 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
6542aa9c
PL
5141 fi
5142 libnfs="no"
5143 fi
5144fi
1d728c39 5145
6ca026cb
PM
5146# Now we've finished running tests it's OK to add -Werror to the compiler flags
5147if test "$werror" = "yes"; then
5148 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
5149fi
5150
e86ecd4b
JQ
5151if test "$solaris" = "no" ; then
5152 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1156c669 5153 LDFLAGS="-Wl,--warn-common $LDFLAGS"
e86ecd4b
JQ
5154 fi
5155fi
5156
94dd53c5
GH
5157# test if pod2man has --utf8 option
5158if pod2man --help | grep -q utf8; then
5159 POD2MAN="pod2man --utf8"
5160else
5161 POD2MAN="pod2man"
5162fi
5163
952afb71
BS
5164# Use ASLR, no-SEH and DEP if available
5165if test "$mingw32" = "yes" ; then
5166 for flag in --dynamicbase --no-seh --nxcompat; do
e9a3591f 5167 if ld_has $flag ; then
952afb71
BS
5168 LDFLAGS="-Wl,$flag $LDFLAGS"
5169 fi
5170 done
5171fi
5172
10ea68b3 5173qemu_confdir=$sysconfdir$confsuffix
e26110cf 5174qemu_moddir=$libdir$confsuffix
528ae5b8 5175qemu_datadir=$datadir$confsuffix
834574ea 5176qemu_localedir="$datadir/locale"
e7b45cc4 5177
e0580342
KR
5178# We can only support ivshmem if we have eventfd
5179if [ "$eventfd" = "yes" ]; then
5180 ivshmem=yes
5181fi
5182
4b1c11fd
DB
5183tools=""
5184if test "$want_tools" = "yes" ; then
ca35f780 5185 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
4b1c11fd
DB
5186 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
5187 tools="qemu-nbd\$(EXESUF) $tools"
b1449edb
KR
5188 fi
5189 if [ "$ivshmem" = "yes" ]; then
a75eb03b 5190 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
4b1c11fd
DB
5191 fi
5192fi
5193if test "$softmmu" = yes ; then
b855f8d1
PB
5194 if test "$linux" = yes; then
5195 if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
aabfd88d
AF
5196 virtfs=yes
5197 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5198 else
5199 if test "$virtfs" = yes; then
b855f8d1 5200 error_exit "VirtFS requires libcap devel and libattr devel"
983eef5a 5201 fi
17500370 5202 virtfs=no
aabfd88d 5203 fi
fe8fc5ae
PB
5204 if test "$mpath" != no && test "$mpathpersist" = yes ; then
5205 mpath=yes
5206 else
5207 if test "$mpath" = yes; then
5208 error_exit "Multipath requires libmpathpersist devel"
5209 fi
5210 mpath=no
5211 fi
b855f8d1
PB
5212 tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5213 else
5214 if test "$virtfs" = yes; then
5215 error_exit "VirtFS is supported only on Linux"
5216 fi
5217 virtfs=no
fe8fc5ae
PB
5218 if test "$mpath" = yes; then
5219 error_exit "Multipath is supported only on Linux"
5220 fi
5221 mpath=no
17bff52b 5222 fi
ff69fd8c
LV
5223 if test "$xkbcommon" = "yes"; then
5224 tools="qemu-keymap\$(EXESUF) $tools"
5225 fi
6a021536 5226fi
9d6bc27b
MR
5227
5228# Probe for guest agent support/options
5229
e8ef31a3 5230if [ "$guest_agent" != "no" ]; then
b39297ae 5231 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
fafcaf1d 5232 tools="qemu-ga $tools"
e8ef31a3
MT
5233 guest_agent=yes
5234 elif [ "$guest_agent" != yes ]; then
5235 guest_agent=no
5236 else
5237 error_exit "Guest agent is not supported on this platform"
ca35f780 5238 fi
00c705fb 5239fi
ca35f780 5240
9d6bc27b
MR
5241# Guest agent Window MSI package
5242
5243if test "$guest_agent" != yes; then
5244 if test "$guest_agent_msi" = yes; then
5245 error_exit "MSI guest agent package requires guest agent enabled"
5246 fi
5247 guest_agent_msi=no
5248elif test "$mingw32" != "yes"; then
5249 if test "$guest_agent_msi" = "yes"; then
5250 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
5251 fi
5252 guest_agent_msi=no
5253elif ! has wixl; then
5254 if test "$guest_agent_msi" = "yes"; then
5255 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
5256 fi
5257 guest_agent_msi=no
1a34904e
MR
5258else
5259 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
5260 # disabled explicitly
5261 if test "$guest_agent_msi" != "no"; then
5262 guest_agent_msi=yes
5263 fi
9d6bc27b
MR
5264fi
5265
1a34904e 5266if test "$guest_agent_msi" = "yes"; then
9d6bc27b
MR
5267 if test "$guest_agent_with_vss" = "yes"; then
5268 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
5269 fi
5270
5271 if test "$QEMU_GA_MANUFACTURER" = ""; then
5272 QEMU_GA_MANUFACTURER=QEMU
5273 fi
5274
5275 if test "$QEMU_GA_DISTRO" = ""; then
5276 QEMU_GA_DISTRO=Linux
5277 fi
5278
5279 if test "$QEMU_GA_VERSION" = ""; then
89138857 5280 QEMU_GA_VERSION=$(cat $source_path/VERSION)
9d6bc27b
MR
5281 fi
5282
89138857 5283 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
9d6bc27b
MR
5284
5285 case "$cpu" in
5286 x86_64)
5287 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
5288 ;;
5289 i386)
5290 QEMU_GA_MSI_ARCH="-D Arch=32"
5291 ;;
5292 *)
5293 error_exit "CPU $cpu not supported for building installation package"
5294 ;;
5295 esac
5296fi
5297
ca35f780
PB
5298# Mac OS X ships with a broken assembler
5299roms=
5300if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5301 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5302 "$softmmu" = yes ; then
e57218b6
PM
5303 # Different host OS linkers have different ideas about the name of the ELF
5304 # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
5305 # variant; and Windows uses i386pe.
5306 for emu in elf_i386 elf_i386_fbsd i386pe; do
5307 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5308 ld_i386_emulation="$emu"
5309 roms="optionrom"
5310 break
5311 fi
5312 done
ca35f780 5313fi
d0384d1d 5314if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
39ac8455
DG
5315 roms="$roms spapr-rtas"
5316fi
ca35f780 5317
9933c305
CB
5318if test "$cpu" = "s390x" ; then
5319 roms="$roms s390-ccw"
5320fi
5321
964c6fa1 5322# Probe for the need for relocating the user-only binary.
92fe2ba8 5323if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
964c6fa1
RH
5324 textseg_addr=
5325 case "$cpu" in
479eb121
RH
5326 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5327 # ??? Rationale for choosing this address
964c6fa1
RH
5328 textseg_addr=0x60000000
5329 ;;
5330 mips)
479eb121
RH
5331 # A 256M aligned address, high in the address space, with enough
5332 # room for the code_gen_buffer above it before the stack.
5333 textseg_addr=0x60000000
964c6fa1
RH
5334 ;;
5335 esac
5336 if [ -n "$textseg_addr" ]; then
5337 cat > $TMPC <<EOF
5338 int main(void) { return 0; }
5339EOF
5340 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5341 if ! compile_prog "" "$textseg_ldflags"; then
5342 # In case ld does not support -Ttext-segment, edit the default linker
5343 # script via sed to set the .text start addr. This is needed on FreeBSD
5344 # at least.
92fe2ba8
PM
5345 if ! $ld --verbose >/dev/null 2>&1; then
5346 error_exit \
5347 "We need to link the QEMU user mode binaries at a" \
5348 "specific text address. Unfortunately your linker" \
5349 "doesn't support either the -Ttext-segment option or" \
5350 "printing the default linker script with --verbose." \
5351 "If you don't want the user mode binaries, pass the" \
5352 "--disable-user option to configure."
5353 fi
5354
964c6fa1
RH
5355 $ld --verbose | sed \
5356 -e '1,/==================================================/d' \
5357 -e '/==================================================/,$d' \
5358 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5359 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5360 textseg_ldflags="-Wl,-T../config-host.ld"
5361 fi
5362 fi
5363fi
5364
11cde1c8
BD
5365# Check that the C++ compiler exists and works with the C compiler.
5366# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
5367if has $cxx; then
5368 cat > $TMPC <<EOF
5369int c_function(void);
5370int main(void) { return c_function(); }
5371EOF
5372
5373 compile_object
5374
5375 cat > $TMPCXX <<EOF
5376extern "C" {
5377 int c_function(void);
5378}
5379int c_function(void) { return 42; }
5380EOF
5381
5382 update_cxxflags
5383
5384 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
5385 # C++ compiler $cxx works ok with C compiler $cc
5386 :
5387 else
5388 echo "C++ compiler $cxx does not work with C compiler $cc"
5389 echo "Disabling C++ specific optional code"
5390 cxx=
5391 fi
5392else
5393 echo "No C++ compiler available; disabling C++ specific optional code"
5394 cxx=
5395fi
5396
02d34f62
CR
5397echo_version() {
5398 if test "$1" = "yes" ; then
5399 echo "($2)"
5400 fi
5401}
5402
50e12060
JK
5403# prepend pixman and ftd flags after all config tests are done
5404QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
5405libs_softmmu="$pixman_libs $libs_softmmu"
5ca9388a 5406
43ce4dfe 5407echo "Install prefix $prefix"
89138857 5408echo "BIOS directory $(eval echo $qemu_datadir)"
3d5eecab 5409echo "firmware path $(eval echo $firmwarepath)"
89138857
SW
5410echo "binary directory $(eval echo $bindir)"
5411echo "library directory $(eval echo $libdir)"
5412echo "module directory $(eval echo $qemu_moddir)"
5413echo "libexec directory $(eval echo $libexecdir)"
5414echo "include directory $(eval echo $includedir)"
5415echo "config directory $(eval echo $sysconfdir)"
11d9f695 5416if test "$mingw32" = "no" ; then
89138857
SW
5417echo "local state directory $(eval echo $local_statedir)"
5418echo "Manual directory $(eval echo $mandir)"
43ce4dfe 5419echo "ELF interp prefix $interp_prefix"
5a699bbb
LE
5420else
5421echo "local state directory queried at runtime"
d9840e25 5422echo "Windows SDK $win_sdk"
11d9f695 5423fi
5a67135a 5424echo "Source path $source_path"
cc84d63a 5425echo "GIT binary $git"
aef45d51 5426echo "GIT submodules $git_submodules"
43ce4dfe 5427echo "C compiler $cc"
83469015 5428echo "Host C compiler $host_cc"
83f73fce 5429echo "C++ compiler $cxx"
3c4a4d0d 5430echo "Objective-C compiler $objcc"
45d285ab 5431echo "ARFLAGS $ARFLAGS"
0c439cbf 5432echo "CFLAGS $CFLAGS"
a558ee17 5433echo "QEMU_CFLAGS $QEMU_CFLAGS"
0c439cbf 5434echo "LDFLAGS $LDFLAGS"
43ce4dfe 5435echo "make $make"
6a882643 5436echo "install $install"
c886edfb 5437echo "python $python"
e2d8830e
BS
5438if test "$slirp" = "yes" ; then
5439 echo "smbd $smbd"
5440fi
17969268 5441echo "module support $modules"
43ce4dfe 5442echo "host CPU $cpu"
de83cd02 5443echo "host big endian $bigendian"
97a847bc 5444echo "target list $target_list"
43ce4dfe 5445echo "gprof enabled $gprof"
03b4fe7d 5446echo "sparse enabled $sparse"
1625af87 5447echo "strip binaries $strip_opt"
05c2a3e7 5448echo "profiler $profiler"
43ce4dfe 5449echo "static build $static"
5b0753e0
FB
5450if test "$darwin" = "yes" ; then
5451 echo "Cocoa support $cocoa"
5452fi
89138857
SW
5453echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5454echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
925a0400 5455echo "GTK GL support $gtk_gl"
89138857 5456echo "VTE support $vte $(echo_version $vte $vteversion)"
a1c5e949 5457echo "TLS priority $tls_priority"
ddbb0d09 5458echo "GNUTLS support $gnutls"
b917da4c 5459echo "GNUTLS rnd $gnutls_rnd"
91bfcdb0 5460echo "libgcrypt $gcrypt"
37788f25 5461echo "libgcrypt kdf $gcrypt_kdf"
89138857 5462echo "nettle $nettle $(echo_version $nettle $nettle_version)"
fff2f982 5463echo "nettle kdf $nettle_kdf"
9a2fd434 5464echo "libtasn1 $tasn1"
4d3b6f6e 5465echo "curses support $curses"
9d9e1521 5466echo "virgl support $virglrenderer"
769ce76d 5467echo "curl support $curl"
67b915a5 5468echo "mingw32 support $mingw32"
0c58ac1c 5469echo "Audio drivers $audio_drv_list"
b64ec4e4
FZ
5470echo "Block whitelist (rw) $block_drv_rw_whitelist"
5471echo "Block whitelist (ro) $block_drv_ro_whitelist"
983eef5a 5472echo "VirtFS support $virtfs"
fe8fc5ae 5473echo "Multipath support $mpath"
821601ea
JS
5474echo "VNC support $vnc"
5475if test "$vnc" = "yes" ; then
821601ea
JS
5476 echo "VNC SASL support $vnc_sasl"
5477 echo "VNC JPEG support $vnc_jpeg"
5478 echo "VNC PNG support $vnc_png"
821601ea 5479fi
3142255c
BS
5480if test -n "$sparc_cpu"; then
5481 echo "Target Sparc Arch $sparc_cpu"
5482fi
e37630ca 5483echo "xen support $xen"
3996e85c
PD
5484if test "$xen" = "yes" ; then
5485 echo "xen ctrl version $xen_ctrl_version"
64a7ad6f 5486 echo "pv dom build $xen_pv_domain_build"
3996e85c 5487fi
2e4d9fb1 5488echo "brlapi support $brlapi"
a20a6f46 5489echo "bluez support $bluez"
a25dba17 5490echo "Documentation $docs"
40d6444e 5491echo "PIE $pie"
8a16d273 5492echo "vde support $vde"
58952137 5493echo "netmap support $netmap"
5c6c3a6c 5494echo "Linux AIO support $linux_aio"
758e8e38 5495echo "ATTR/XATTR support $attr"
77755340 5496echo "Install blobs $blobs"
b31a0277 5497echo "KVM support $kvm"
b0cb0a66 5498echo "HAX support $hax"
b3f6ea7e
PB
5499echo "TCG support $tcg"
5500if test "$tcg" = "yes" ; then
5501 echo "TCG debug enabled $debug_tcg"
5502 echo "TCG interpreter $tcg_interpreter"
5503fi
2da776db 5504echo "RDMA support $rdma"
f652e6af 5505echo "fdt support $fdt"
ceb42de8 5506echo "preadv support $preadv"
5f6b9e8f 5507echo "fdatasync $fdatasync"
e78815a5
AF
5508echo "madvise $madvise"
5509echo "posix_madvise $posix_madvise"
47e98658 5510echo "libcap-ng support $cap_ng"
d5970055 5511echo "vhost-net support $vhost_net"
5e9be92d 5512echo "vhost-scsi support $vhost_scsi"
fc0b9b0e 5513echo "vhost-vsock support $vhost_vsock"
e6a74868 5514echo "vhost-user support $vhost_user"
5b808275 5515echo "Trace backends $trace_backends"
713572a7 5516if have_backend "simple"; then
9410b56c 5517echo "Trace output file $trace_file-<pid>"
e00e36fb 5518fi
89138857 5519echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
f27aaf4b 5520echo "rbd support $rbd"
dce512de 5521echo "xfsctl support $xfs"
7b02f544 5522echo "smartcard support $smartcard"
2b2325ff 5523echo "libusb $libusb"
69354a83 5524echo "usb net redir $usb_redir"
da076ffe 5525echo "OpenGL support $opengl"
014cb152 5526echo "OpenGL dmabufs $opengl_dmabuf"
c589b249 5527echo "libiscsi support $libiscsi"
6542aa9c 5528echo "libnfs support $libnfs"
d138cee9 5529echo "build guest agent $guest_agent"
d9840e25 5530echo "QGA VSS support $guest_agent_with_vss"
50cbebb9 5531echo "QGA w32 disk info $guest_agent_ntddscsi"
4c875d89 5532echo "QGA MSI support $guest_agent_msi"
f794573e 5533echo "seccomp support $seccomp"
7c2acc70 5534echo "coroutine backend $coroutine"
70c60c08 5535echo "coroutine pool $coroutine_pool"
7d992e4d 5536echo "debug stack usage $debug_stack_usage"
f0d92b56 5537echo "crypto afalg $crypto_afalg"
eb100396 5538echo "GlusterFS support $glusterfs"
1d728c39
BS
5539echo "gcov $gcov_tool"
5540echo "gcov enabled $gcov"
ab214c29 5541echo "TPM support $tpm"
0a12ec87 5542echo "libssh2 support $libssh2"
3b8acc11 5543echo "TPM passthrough $tpm_passthrough"
f4ede81e 5544echo "TPM emulator $tpm_emulator"
3556c233 5545echo "QOM debugging $qom_cast_debug"
ed1701c6 5546echo "Live block migration $live_block_migration"
607dacd0
QN
5547echo "lzo support $lzo"
5548echo "snappy support $snappy"
6b383c08 5549echo "bzip2 support $bzip2"
a99d57bb 5550echo "NUMA host support $numa"
2847b469 5551echo "tcmalloc support $tcmalloc"
7b01cb97 5552echo "jemalloc support $jemalloc"
99f2dbd3 5553echo "avx2 optimization $avx2_opt"
a6b1d4c0 5554echo "replication support $replication"
da92c3ff 5555echo "VxHS block device $vxhs"
8ca80760 5556echo "capstone $capstone"
67b915a5 5557
1ba16968 5558if test "$sdl_too_old" = "yes"; then
24b55b96 5559echo "-> Your SDL version is too old - please upgrade to have SDL support"
7c1f25b4 5560fi
7d13299d 5561
898be3e0
PM
5562if test "$supported_cpu" = "no"; then
5563 echo
5564 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5565 echo
5566 echo "CPU host architecture $cpu support is not currently maintained."
5567 echo "The QEMU project intends to remove support for this host CPU in"
5568 echo "a future release if nobody volunteers to maintain it and to"
5569 echo "provide a build host for our continuous integration setup."
5570 echo "configure has succeeded and you can continue to build, but"
5571 echo "if you care about QEMU on this platform you should contact"
5572 echo "us upstream at qemu-devel@nongnu.org."
5573fi
5574
5575if test "$supported_os" = "no"; then
5576 echo
5577 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5578 echo
c50126aa
PM
5579 echo "Host OS $targetos support is not currently maintained."
5580 echo "The QEMU project intends to remove support for this host OS in"
898be3e0
PM
5581 echo "a future release if nobody volunteers to maintain it and to"
5582 echo "provide a build host for our continuous integration setup."
5583 echo "configure has succeeded and you can continue to build, but"
5584 echo "if you care about QEMU on this platform you should contact"
5585 echo "us upstream at qemu-devel@nongnu.org."
5586fi
5587
98ec69ac 5588config_host_mak="config-host.mak"
98ec69ac 5589
dbd99ae3
SW
5590echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
5591
98ec69ac 5592echo "# Automatically generated by configure - do not modify" > $config_host_mak
98ec69ac 5593echo >> $config_host_mak
98ec69ac 5594
e6c3b0f7 5595echo all: >> $config_host_mak
99d7cc75
PB
5596echo "prefix=$prefix" >> $config_host_mak
5597echo "bindir=$bindir" >> $config_host_mak
3aa5d2be 5598echo "libdir=$libdir" >> $config_host_mak
8bf188aa 5599echo "libexecdir=$libexecdir" >> $config_host_mak
0f94d6da 5600echo "includedir=$includedir" >> $config_host_mak
99d7cc75 5601echo "mandir=$mandir" >> $config_host_mak
99d7cc75 5602echo "sysconfdir=$sysconfdir" >> $config_host_mak
22d07038 5603echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
9afa52ce 5604echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
3d5eecab 5605echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
9afa52ce 5606echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
e26110cf 5607echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5a699bbb
LE
5608if test "$mingw32" = "no" ; then
5609 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
5610fi
f354b1a1 5611echo "qemu_helperdir=$libexecdir" >> $config_host_mak
f9943cd5 5612echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
11cde1c8 5613echo "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
f9943cd5 5614echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
834574ea 5615echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
f544a488 5616echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
cc84d63a 5617echo "GIT=$git" >> $config_host_mak
aef45d51 5618echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
f62bbee5 5619echo "GIT_UPDATE=$git_update" >> $config_host_mak
804edf29 5620
98ec69ac 5621echo "ARCH=$ARCH" >> $config_host_mak
727e5283 5622
f8393946 5623if test "$debug_tcg" = "yes" ; then
2358a494 5624 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
f8393946 5625fi
1625af87 5626if test "$strip_opt" = "yes" ; then
52ba784d 5627 echo "STRIP=${strip}" >> $config_host_mak
1625af87 5628fi
7d13299d 5629if test "$bigendian" = "yes" ; then
e2542fe2 5630 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
97a847bc 5631fi
67b915a5 5632if test "$mingw32" = "yes" ; then
98ec69ac 5633 echo "CONFIG_WIN32=y" >> $config_host_mak
89138857 5634 rc_version=$(cat $source_path/VERSION)
9fe6de94
BS
5635 version_major=${rc_version%%.*}
5636 rc_version=${rc_version#*.}
5637 version_minor=${rc_version%%.*}
5638 rc_version=${rc_version#*.}
5639 version_subminor=${rc_version%%.*}
5640 version_micro=0
5641 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5642 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
d9840e25
TS
5643 if test "$guest_agent_with_vss" = "yes" ; then
5644 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
f33ca81f 5645 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
d9840e25
TS
5646 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5647 fi
50cbebb9
MR
5648 if test "$guest_agent_ntddscsi" = "yes" ; then
5649 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
5650 fi
1a34904e 5651 if test "$guest_agent_msi" = "yes"; then
9dacf32d
YH
5652 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
5653 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
5654 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
5655 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
5656 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
5657 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
5658 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5659 fi
210fa556 5660else
35f4df27 5661 echo "CONFIG_POSIX=y" >> $config_host_mak
dffcb71c
MM
5662fi
5663
5664if test "$linux" = "yes" ; then
5665 echo "CONFIG_LINUX=y" >> $config_host_mak
67b915a5 5666fi
128ab2ff 5667
83fb7adf 5668if test "$darwin" = "yes" ; then
98ec69ac 5669 echo "CONFIG_DARWIN=y" >> $config_host_mak
83fb7adf 5670fi
b29fe3ed 5671
ec530c81 5672if test "$solaris" = "yes" ; then
98ec69ac 5673 echo "CONFIG_SOLARIS=y" >> $config_host_mak
ec530c81 5674fi
179cf400
AF
5675if test "$haiku" = "yes" ; then
5676 echo "CONFIG_HAIKU=y" >> $config_host_mak
5677fi
97a847bc 5678if test "$static" = "yes" ; then
98ec69ac 5679 echo "CONFIG_STATIC=y" >> $config_host_mak
7d13299d 5680fi
1ba16968 5681if test "$profiler" = "yes" ; then
2358a494 5682 echo "CONFIG_PROFILER=y" >> $config_host_mak
05c2a3e7 5683fi
c20709aa 5684if test "$slirp" = "yes" ; then
98ec69ac 5685 echo "CONFIG_SLIRP=y" >> $config_host_mak
e2d8830e 5686 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
c20709aa 5687fi
8a16d273 5688if test "$vde" = "yes" ; then
98ec69ac 5689 echo "CONFIG_VDE=y" >> $config_host_mak
e2ad6f16 5690 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
8a16d273 5691fi
58952137
VM
5692if test "$netmap" = "yes" ; then
5693 echo "CONFIG_NETMAP=y" >> $config_host_mak
5694fi
015a33bd
GA
5695if test "$l2tpv3" = "yes" ; then
5696 echo "CONFIG_L2TPV3=y" >> $config_host_mak
5697fi
47e98658
CB
5698if test "$cap_ng" = "yes" ; then
5699 echo "CONFIG_LIBCAP=y" >> $config_host_mak
5700fi
2358a494 5701echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
0c58ac1c 5702for drv in $audio_drv_list; do
89138857 5703 def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
98ec69ac 5704 echo "$def=y" >> $config_host_mak
0c58ac1c 5705done
b1149911
FZ
5706echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5707echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5708echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5709echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5710echo "OSS_LIBS=$oss_libs" >> $config_host_mak
67f86e8e
JQ
5711if test "$audio_pt_int" = "yes" ; then
5712 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
5713fi
d5631638 5714if test "$audio_win_int" = "yes" ; then
5715 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5716fi
b64ec4e4
FZ
5717echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5718echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
821601ea
JS
5719if test "$vnc" = "yes" ; then
5720 echo "CONFIG_VNC=y" >> $config_host_mak
5721fi
2f9606b3 5722if test "$vnc_sasl" = "yes" ; then
98ec69ac 5723 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2f9606b3 5724fi
821601ea 5725if test "$vnc_jpeg" = "yes" ; then
2f6f5c7a 5726 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2f6f5c7a 5727fi
821601ea 5728if test "$vnc_png" = "yes" ; then
efe556ad 5729 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
efe556ad 5730fi
6a021536
GH
5731if test "$xkbcommon" = "yes" ; then
5732 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
5733 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
5734fi
76655d6d 5735if test "$fnmatch" = "yes" ; then
2358a494 5736 echo "CONFIG_FNMATCH=y" >> $config_host_mak
76655d6d 5737fi
dce512de
CH
5738if test "$xfs" = "yes" ; then
5739 echo "CONFIG_XFS=y" >> $config_host_mak
5740fi
89138857 5741qemu_version=$(head $source_path/VERSION)
98ec69ac 5742echo "VERSION=$qemu_version" >>$config_host_mak
2358a494 5743echo "PKGVERSION=$pkgversion" >>$config_host_mak
98ec69ac 5744echo "SRC_PATH=$source_path" >> $config_host_mak
98ec69ac 5745echo "TARGET_DIRS=$target_list" >> $config_host_mak
a25dba17 5746if [ "$docs" = "yes" ] ; then
98ec69ac 5747 echo "BUILD_DOCS=yes" >> $config_host_mak
cc8ae6de 5748fi
17969268 5749if test "$modules" = "yes"; then
e26110cf
FZ
5750 # $shacmd can generate a hash started with digit, which the compiler doesn't
5751 # like as an symbol. So prefix it with an underscore
89138857 5752 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
17969268
FZ
5753 echo "CONFIG_MODULES=y" >> $config_host_mak
5754fi
1ac88f28 5755if test "$sdl" = "yes" ; then
98ec69ac 5756 echo "CONFIG_SDL=y" >> $config_host_mak
a3f4d63d 5757 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
1ac88f28 5758 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
8ecc89f6 5759 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
49ecc3fa
FB
5760fi
5761if test "$cocoa" = "yes" ; then
98ec69ac 5762 echo "CONFIG_COCOA=y" >> $config_host_mak
4d3b6f6e
AZ
5763fi
5764if test "$curses" = "yes" ; then
98ec69ac 5765 echo "CONFIG_CURSES=y" >> $config_host_mak
49ecc3fa 5766fi
099d6b0f 5767if test "$pipe2" = "yes" ; then
2358a494 5768 echo "CONFIG_PIPE2=y" >> $config_host_mak
099d6b0f 5769fi
40ff6d7e
KW
5770if test "$accept4" = "yes" ; then
5771 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5772fi
3ce34dfb 5773if test "$splice" = "yes" ; then
2358a494 5774 echo "CONFIG_SPLICE=y" >> $config_host_mak
3ce34dfb 5775fi
c2882b96
RV
5776if test "$eventfd" = "yes" ; then
5777 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5778fi
751bcc39
MAL
5779if test "$memfd" = "yes" ; then
5780 echo "CONFIG_MEMFD=y" >> $config_host_mak
5781fi
d0927938
UH
5782if test "$fallocate" = "yes" ; then
5783 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5784fi
3d4fa43e
KK
5785if test "$fallocate_punch_hole" = "yes" ; then
5786 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5787fi
b953f075
DL
5788if test "$fallocate_zero_range" = "yes" ; then
5789 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5790fi
ed911435
KW
5791if test "$posix_fallocate" = "yes" ; then
5792 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5793fi
c727f47d
PM
5794if test "$sync_file_range" = "yes" ; then
5795 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5796fi
dace20dc
PM
5797if test "$fiemap" = "yes" ; then
5798 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5799fi
d0927938
UH
5800if test "$dup3" = "yes" ; then
5801 echo "CONFIG_DUP3=y" >> $config_host_mak
5802fi
4e0c6529
AB
5803if test "$ppoll" = "yes" ; then
5804 echo "CONFIG_PPOLL=y" >> $config_host_mak
5805fi
cd758dd0
AB
5806if test "$prctl_pr_set_timerslack" = "yes" ; then
5807 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5808fi
3b6edd16
PM
5809if test "$epoll" = "yes" ; then
5810 echo "CONFIG_EPOLL=y" >> $config_host_mak
5811fi
5812if test "$epoll_create1" = "yes" ; then
5813 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5814fi
a8fd1aba
PM
5815if test "$sendfile" = "yes" ; then
5816 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5817fi
51834341
RV
5818if test "$timerfd" = "yes" ; then
5819 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5820fi
9af5c906
RV
5821if test "$setns" = "yes" ; then
5822 echo "CONFIG_SETNS=y" >> $config_host_mak
5823fi
38860a03
AM
5824if test "$clock_adjtime" = "yes" ; then
5825 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
5826fi
5a03cd00
AM
5827if test "$syncfs" = "yes" ; then
5828 echo "CONFIG_SYNCFS=y" >> $config_host_mak
5829fi
3b3f24ad 5830if test "$inotify" = "yes" ; then
2358a494 5831 echo "CONFIG_INOTIFY=y" >> $config_host_mak
3b3f24ad 5832fi
c05c7a73
RV
5833if test "$inotify1" = "yes" ; then
5834 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5835fi
401bc051
PM
5836if test "$sem_timedwait" = "yes" ; then
5837 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
5838fi
6ae9a1f4
JQ
5839if test "$byteswap_h" = "yes" ; then
5840 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
5841fi
5842if test "$bswap_h" = "yes" ; then
5843 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
5844fi
769ce76d 5845if test "$curl" = "yes" ; then
d3399d7c 5846 echo "CONFIG_CURL=m" >> $config_host_mak
b1d5a277 5847 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
6ebc91e5 5848 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
769ce76d 5849fi
2e4d9fb1 5850if test "$brlapi" = "yes" ; then
98ec69ac 5851 echo "CONFIG_BRLAPI=y" >> $config_host_mak
8eca2889 5852 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
2e4d9fb1 5853fi
fb599c9a 5854if test "$bluez" = "yes" ; then
98ec69ac 5855 echo "CONFIG_BLUEZ=y" >> $config_host_mak
ef7635ec 5856 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
fb599c9a 5857fi
d46f7c9e 5858if test "$glib_subprocess" = "yes" ; then
9d41401b
MT
5859 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
5860fi
a4ccabcf
AL
5861if test "$gtk" = "yes" ; then
5862 echo "CONFIG_GTK=y" >> $config_host_mak
a3f4d63d 5863 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
a4ccabcf 5864 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
014cb152 5865 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
925a0400
GH
5866 if test "$gtk_gl" = "yes" ; then
5867 echo "CONFIG_GTK_GL=y" >> $config_host_mak
5868 fi
bbbf9bfb 5869fi
a1c5e949 5870echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
ddbb0d09
DB
5871if test "$gnutls" = "yes" ; then
5872 echo "CONFIG_GNUTLS=y" >> $config_host_mak
5873fi
b917da4c
DB
5874if test "$gnutls_rnd" = "yes" ; then
5875 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5876fi
91bfcdb0
DB
5877if test "$gcrypt" = "yes" ; then
5878 echo "CONFIG_GCRYPT=y" >> $config_host_mak
1f923c70
LM
5879 if test "$gcrypt_hmac" = "yes" ; then
5880 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
5881 fi
37788f25
DB
5882 if test "$gcrypt_kdf" = "yes" ; then
5883 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
5884 fi
62893b67 5885fi
91bfcdb0
DB
5886if test "$nettle" = "yes" ; then
5887 echo "CONFIG_NETTLE=y" >> $config_host_mak
becaeb72 5888 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
fff2f982
DB
5889 if test "$nettle_kdf" = "yes" ; then
5890 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5891 fi
ed754746 5892fi
9a2fd434
DB
5893if test "$tasn1" = "yes" ; then
5894 echo "CONFIG_TASN1=y" >> $config_host_mak
5895fi
559607ea
DB
5896if test "$have_ifaddrs_h" = "yes" ; then
5897 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5898fi
6b39b063
EB
5899if test "$have_broken_size_max" = "yes" ; then
5900 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
5901fi
277abf15
JV
5902
5903# Work around a system header bug with some kernel/XFS header
5904# versions where they both try to define 'struct fsxattr':
5905# xfs headers will not try to redefine structs from linux headers
5906# if this macro is set.
5907if test "$have_fsxattr" = "yes" ; then
5908 echo "HAVE_FSXATTR=y" >> $config_host_mak
5909fi
bbbf9bfb
SW
5910if test "$vte" = "yes" ; then
5911 echo "CONFIG_VTE=y" >> $config_host_mak
a4ccabcf
AL
5912 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5913fi
9d9e1521
GH
5914if test "$virglrenderer" = "yes" ; then
5915 echo "CONFIG_VIRGL=y" >> $config_host_mak
5916 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
5917 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
5918fi
e37630ca 5919if test "$xen" = "yes" ; then
6dbd588a 5920 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
d5b93ddf 5921 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
64a7ad6f
IC
5922 if test "$xen_pv_domain_build" = "yes" ; then
5923 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
5924 fi
e37630ca 5925fi
5c6c3a6c
CH
5926if test "$linux_aio" = "yes" ; then
5927 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
5928fi
758e8e38
VJ
5929if test "$attr" = "yes" ; then
5930 echo "CONFIG_ATTR=y" >> $config_host_mak
5931fi
4f26f2b6
AK
5932if test "$libattr" = "yes" ; then
5933 echo "CONFIG_LIBATTR=y" >> $config_host_mak
5934fi
983eef5a
MI
5935if test "$virtfs" = "yes" ; then
5936 echo "CONFIG_VIRTFS=y" >> $config_host_mak
758e8e38 5937fi
fe8fc5ae
PB
5938if test "$mpath" = "yes" ; then
5939 echo "CONFIG_MPATH=y" >> $config_host_mak
5940fi
5e9be92d
NB
5941if test "$vhost_scsi" = "yes" ; then
5942 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
5943fi
e6a74868 5944if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
03ce5744
NN
5945 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
5946fi
fc0b9b0e
SH
5947if test "$vhost_vsock" = "yes" ; then
5948 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5949fi
e6a74868
MAL
5950if test "$vhost_user" = "yes" ; then
5951 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
5952fi
77755340 5953if test "$blobs" = "yes" ; then
98ec69ac 5954 echo "INSTALL_BLOBS=yes" >> $config_host_mak
77755340 5955fi
bf9298b9 5956if test "$iovec" = "yes" ; then
2358a494 5957 echo "CONFIG_IOVEC=y" >> $config_host_mak
bf9298b9 5958fi
ceb42de8 5959if test "$preadv" = "yes" ; then
2358a494 5960 echo "CONFIG_PREADV=y" >> $config_host_mak
ceb42de8 5961fi
f652e6af 5962if test "$fdt" = "yes" ; then
3f0855b1 5963 echo "CONFIG_FDT=y" >> $config_host_mak
f652e6af 5964fi
dcc38d1c
MT
5965if test "$signalfd" = "yes" ; then
5966 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5967fi
b3f6ea7e
PB
5968if test "$tcg" = "yes"; then
5969 echo "CONFIG_TCG=y" >> $config_host_mak
5970 if test "$tcg_interpreter" = "yes" ; then
5971 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
5972 fi
9195b2c2 5973fi
5f6b9e8f
BS
5974if test "$fdatasync" = "yes" ; then
5975 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
5976fi
e78815a5
AF
5977if test "$madvise" = "yes" ; then
5978 echo "CONFIG_MADVISE=y" >> $config_host_mak
5979fi
5980if test "$posix_madvise" = "yes" ; then
5981 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5982fi
97a847bc 5983
cd4ec0b4
GH
5984if test "$spice" = "yes" ; then
5985 echo "CONFIG_SPICE=y" >> $config_host_mak
5986fi
36707144 5987
7b02f544
MAL
5988if test "$smartcard" = "yes" ; then
5989 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
7b62bf5a
FZ
5990 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
5991 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
111a38b0
RR
5992fi
5993
2b2325ff
GH
5994if test "$libusb" = "yes" ; then
5995 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
b878b652
FZ
5996 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
5997 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
2b2325ff
GH
5998fi
5999
69354a83
HG
6000if test "$usb_redir" = "yes" ; then
6001 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
cc7923fc
FZ
6002 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6003 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
69354a83
HG
6004fi
6005
da076ffe
GH
6006if test "$opengl" = "yes" ; then
6007 echo "CONFIG_OPENGL=y" >> $config_host_mak
6008 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
014cb152
GH
6009 if test "$opengl_dmabuf" = "yes" ; then
6010 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6011 fi
20ff075b
MW
6012fi
6013
99f2dbd3
LL
6014if test "$avx2_opt" = "yes" ; then
6015 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
6016fi
6017
607dacd0
QN
6018if test "$lzo" = "yes" ; then
6019 echo "CONFIG_LZO=y" >> $config_host_mak
6020fi
6021
6022if test "$snappy" = "yes" ; then
6023 echo "CONFIG_SNAPPY=y" >> $config_host_mak
6024fi
6025
6b383c08
PW
6026if test "$bzip2" = "yes" ; then
6027 echo "CONFIG_BZIP2=y" >> $config_host_mak
6028 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
6029fi
6030
c589b249 6031if test "$libiscsi" = "yes" ; then
d3399d7c 6032 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6ebc91e5
FZ
6033 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
6034 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
c589b249
RS
6035fi
6036
6542aa9c 6037if test "$libnfs" = "yes" ; then
4be4879f
CL
6038 echo "CONFIG_LIBNFS=m" >> $config_host_mak
6039 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
6542aa9c
PL
6040fi
6041
f794573e
EO
6042if test "$seccomp" = "yes"; then
6043 echo "CONFIG_SECCOMP=y" >> $config_host_mak
c3883e1f
FZ
6044 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6045 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
f794573e
EO
6046fi
6047
83fb7adf 6048# XXX: suppress that
7d3505c5 6049if [ "$bsd" = "yes" ] ; then
2358a494 6050 echo "CONFIG_BSD=y" >> $config_host_mak
7d3505c5
FB
6051fi
6052
4d9310f4
DB
6053if test "$localtime_r" = "yes" ; then
6054 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
6055fi
3556c233
PB
6056if test "$qom_cast_debug" = "yes" ; then
6057 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
6058fi
f27aaf4b 6059if test "$rbd" = "yes" ; then
d3399d7c 6060 echo "CONFIG_RBD=m" >> $config_host_mak
6ebc91e5
FZ
6061 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
6062 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
d0e2fce5
AK
6063fi
6064
7c2acc70 6065echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
70c60c08
SH
6066if test "$coroutine_pool" = "yes" ; then
6067 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
6068else
6069 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
6070fi
20ff6c80 6071
7d992e4d
PL
6072if test "$debug_stack_usage" = "yes" ; then
6073 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
6074fi
6075
f0d92b56
LM
6076if test "$crypto_afalg" = "yes" ; then
6077 echo "CONFIG_AF_ALG=y" >> $config_host_mak
6078fi
6079
d2042378
AK
6080if test "$open_by_handle_at" = "yes" ; then
6081 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6082fi
6083
e06a765e
HPB
6084if test "$linux_magic_h" = "yes" ; then
6085 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
8ab1bf12
LC
6086fi
6087
cc6e3ca9
GH
6088if test "$pragma_diagnostic_available" = "yes" ; then
6089 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
06d71fa1
PM
6090fi
6091
3f4349dc
KW
6092if test "$valgrind_h" = "yes" ; then
6093 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
6094fi
6095
8ab1bf12
LC
6096if test "$has_environ" = "yes" ; then
6097 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
e06a765e
HPB
6098fi
6099
76a347e1
RH
6100if test "$cpuid_h" = "yes" ; then
6101 echo "CONFIG_CPUID_H=y" >> $config_host_mak
6102fi
6103
f540166b
RH
6104if test "$int128" = "yes" ; then
6105 echo "CONFIG_INT128=y" >> $config_host_mak
6106fi
6107
7ebee43e
RH
6108if test "$atomic128" = "yes" ; then
6109 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
6110fi
6111
df79b996
RH
6112if test "$atomic64" = "yes" ; then
6113 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6114fi
6115
1e6e9aca
RH
6116if test "$getauxval" = "yes" ; then
6117 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
6118fi
6119
eb100396 6120if test "$glusterfs" = "yes" ; then
d3399d7c 6121 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6ebc91e5
FZ
6122 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
6123 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
0c14fb47
BR
6124fi
6125
d85fa9eb
JC
6126if test "$glusterfs_xlator_opt" = "yes" ; then
6127 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6128fi
6129
0c14fb47
BR
6130if test "$glusterfs_discard" = "yes" ; then
6131 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
eb100396 6132fi
e06a765e 6133
df3a429a
NV
6134if test "$glusterfs_fallocate" = "yes" ; then
6135 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6136fi
6137
7c815372
BR
6138if test "$glusterfs_zerofill" = "yes" ; then
6139 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
6140fi
6141
0a12ec87 6142if test "$libssh2" = "yes" ; then
d3399d7c 6143 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6ebc91e5
FZ
6144 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
6145 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
0a12ec87
RJ
6146fi
6147
ed1701c6
DDAG
6148if test "$live_block_migration" = "yes" ; then
6149 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6150fi
6151
3b8acc11
PB
6152if test "$tpm" = "yes"; then
6153 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
f4ede81e 6154 # TPM passthrough support?
3b8acc11
PB
6155 if test "$tpm_passthrough" = "yes"; then
6156 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
6157 fi
f4ede81e
AV
6158 # TPM emulator support?
6159 if test "$tpm_emulator" = "yes"; then
6160 echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6161 fi
3b8acc11
PB
6162fi
6163
5b808275
LV
6164echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
6165if have_backend "nop"; then
6d8a764e 6166 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
22890ab5 6167fi
5b808275 6168if have_backend "simple"; then
6d8a764e
LV
6169 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
6170 # Set the appropriate trace file.
953ffe0f 6171 trace_file="\"$trace_file-\" FMT_pid"
9410b56c 6172fi
ed7f5f1d
PB
6173if have_backend "log"; then
6174 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6d8a764e 6175fi
5b808275 6176if have_backend "ust"; then
6d8a764e
LV
6177 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
6178fi
5b808275 6179if have_backend "dtrace"; then
6d8a764e
LV
6180 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
6181 if test "$trace_backend_stap" = "yes" ; then
6182 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
6183 fi
c276b17d 6184fi
5b808275 6185if have_backend "ftrace"; then
781e9545
ET
6186 if test "$linux" = "yes" ; then
6187 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
781e9545 6188 else
21684af0 6189 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
781e9545
ET
6190 fi
6191fi
0a852417
PD
6192if have_backend "syslog"; then
6193 if test "$posix_syslog" = "yes" ; then
6194 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
6195 else
6196 feature_not_found "syslog(trace backend)" "syslog not available"
6197 fi
6198fi
9410b56c
PS
6199echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
6200
2da776db
MH
6201if test "$rdma" = "yes" ; then
6202 echo "CONFIG_RDMA=y" >> $config_host_mak
392fb643 6203 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
2da776db
MH
6204fi
6205
575b22b1
LV
6206if test "$have_rtnetlink" = "yes" ; then
6207 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6208fi
6209
a6b1d4c0
CX
6210if test "$replication" = "yes" ; then
6211 echo "CONFIG_REPLICATION=y" >> $config_host_mak
6212fi
6213
6a02c806
SH
6214if test "$have_af_vsock" = "yes" ; then
6215 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
6216fi
6217
4d04351f
CC
6218if test "$have_sysmacros" = "yes" ; then
6219 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
6220fi
6221
49e00a18
AG
6222if test "$have_static_assert" = "yes" ; then
6223 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
6224fi
6225
e674605f
TG
6226if test "$have_utmpx" = "yes" ; then
6227 echo "HAVE_UTMPX=y" >> $config_host_mak
6228fi
6229
e0580342
KR
6230if test "$ivshmem" = "yes" ; then
6231 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
8ca80760 6232fi
e219c499 6233if test "$capstone" != "no" ; then
8ca80760 6234 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
e0580342
KR
6235fi
6236
5c312079
DDAG
6237# Hold two types of flag:
6238# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
6239# a thread we have a handle to
6240# CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
6241# platform
6242if test "$pthread_setname_np" = "yes" ; then
6243 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6244 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
6245fi
6246
da92c3ff
AM
6247if test "$vxhs" = "yes" ; then
6248 echo "CONFIG_VXHS=y" >> $config_host_mak
6249 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6250fi
6251
5b5e3037
PB
6252if test "$tcg_interpreter" = "yes"; then
6253 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
6254elif test "$ARCH" = "sparc64" ; then
6255 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
6256elif test "$ARCH" = "s390x" ; then
6257 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
c72b26ec 6258elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
5b5e3037 6259 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
40d964b5
RH
6260elif test "$ARCH" = "ppc64" ; then
6261 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
5b5e3037
PB
6262else
6263 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
6264fi
6265QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
6266
98ec69ac 6267echo "TOOLS=$tools" >> $config_host_mak
98ec69ac 6268echo "ROMS=$roms" >> $config_host_mak
804edf29
JQ
6269echo "MAKE=$make" >> $config_host_mak
6270echo "INSTALL=$install" >> $config_host_mak
1901cb14
BS
6271echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
6272echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
e999ee44
MT
6273echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
6274echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
c886edfb 6275echo "PYTHON=$python" >> $config_host_mak
804edf29 6276echo "CC=$cc" >> $config_host_mak
a31a8642
MT
6277if $iasl -h > /dev/null 2>&1; then
6278 echo "IASL=$iasl" >> $config_host_mak
6279fi
2b2e59e6 6280echo "CC_I386=$cc_i386" >> $config_host_mak
804edf29 6281echo "HOST_CC=$host_cc" >> $config_host_mak
83f73fce 6282echo "CXX=$cxx" >> $config_host_mak
3c4a4d0d 6283echo "OBJCC=$objcc" >> $config_host_mak
804edf29 6284echo "AR=$ar" >> $config_host_mak
45d285ab 6285echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
cdbd727c 6286echo "AS=$as" >> $config_host_mak
5f6f0e27 6287echo "CCAS=$ccas" >> $config_host_mak
3dd46c78 6288echo "CPP=$cpp" >> $config_host_mak
804edf29
JQ
6289echo "OBJCOPY=$objcopy" >> $config_host_mak
6290echo "LD=$ld" >> $config_host_mak
4852ee95 6291echo "NM=$nm" >> $config_host_mak
9fe6de94 6292echo "WINDRES=$windres" >> $config_host_mak
e2a2ed06 6293echo "CFLAGS=$CFLAGS" >> $config_host_mak
46eef33b 6294echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
a558ee17 6295echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
11cde1c8 6296echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
f9728943 6297echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
e39f0062
PB
6298if test "$sparse" = "yes" ; then
6299 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
80fd48df 6300 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
2944d742 6301 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
e39f0062
PB
6302 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
6303 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6304fi
42da6041
GH
6305if test "$cross_prefix" != ""; then
6306 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
6307else
6308 echo "AUTOCONF_HOST := " >> $config_host_mak
6309fi
e2a2ed06 6310echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
46eef33b 6311echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
6969ec6c 6312echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
e57218b6 6313echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
73da375e 6314echo "LIBS+=$LIBS" >> $config_host_mak
3e2e0e6b 6315echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
409437e1 6316echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
804edf29 6317echo "EXESUF=$EXESUF" >> $config_host_mak
17969268
FZ
6318echo "DSOSUF=$DSOSUF" >> $config_host_mak
6319echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
957f1f99 6320echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
90246037
DB
6321echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
6322echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
94dd53c5 6323echo "POD2MAN=$POD2MAN" >> $config_host_mak
cbdd1999 6324echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
1d728c39
BS
6325if test "$gcov" = "yes" ; then
6326 echo "CONFIG_GCOV=y" >> $config_host_mak
6327 echo "GCOV=$gcov_tool" >> $config_host_mak
6328fi
804edf29 6329
6efd7517
PM
6330# use included Linux headers
6331if test "$linux" = "yes" ; then
a307beb6 6332 mkdir -p linux-headers
6efd7517 6333 case "$cpu" in
c72b26ec 6334 i386|x86_64|x32)
08312a63 6335 linux_arch=x86
6efd7517
PM
6336 ;;
6337 ppcemb|ppc|ppc64)
08312a63 6338 linux_arch=powerpc
6efd7517
PM
6339 ;;
6340 s390x)
08312a63
PM
6341 linux_arch=s390
6342 ;;
1f080313
CF
6343 aarch64)
6344 linux_arch=arm64
6345 ;;
222e7d11
SL
6346 mips64)
6347 linux_arch=mips
6348 ;;
08312a63
PM
6349 *)
6350 # For most CPUs the kernel architecture name and QEMU CPU name match.
6351 linux_arch="$cpu"
6efd7517
PM
6352 ;;
6353 esac
08312a63
PM
6354 # For non-KVM architectures we will not have asm headers
6355 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
6356 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
6357 fi
6efd7517
PM
6358fi
6359
1d14ffa9 6360for target in $target_list; do
97a847bc 6361target_dir="$target"
25be210f 6362config_target_mak=$target_dir/config-target.mak
89138857 6363target_name=$(echo $target | cut -d '-' -f 1)
97a847bc 6364target_bigendian="no"
1f3d3c8f 6365
c1799a84 6366case "$target_name" in
4a09d0bb 6367 armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
ea2d6a39
JQ
6368 target_bigendian=yes
6369 ;;
6370esac
97a847bc 6371target_softmmu="no"
997344f3 6372target_user_only="no"
831b7825 6373target_linux_user="no"
84778508 6374target_bsd_user="no"
9e407a85 6375case "$target" in
c1799a84 6376 ${target_name}-softmmu)
9e407a85
PB
6377 target_softmmu="yes"
6378 ;;
c1799a84 6379 ${target_name}-linux-user)
9e407a85
PB
6380 target_user_only="yes"
6381 target_linux_user="yes"
6382 ;;
c1799a84 6383 ${target_name}-bsd-user)
84778508
BS
6384 target_user_only="yes"
6385 target_bsd_user="yes"
6386 ;;
9e407a85 6387 *)
76ad07a4 6388 error_exit "Target '$target' not recognised"
9e407a85
PB
6389 exit 1
6390 ;;
6391esac
831b7825 6392
97a847bc 6393mkdir -p $target_dir
25be210f 6394echo "# Automatically generated by configure - do not modify" > $config_target_mak
de83cd02 6395
e5fe0c52 6396bflt="no"
ca759f9e 6397mttcg="no"
89138857 6398interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
56aebc89 6399gdb_xml_files=""
7ba1e619 6400
c1799a84 6401TARGET_ARCH="$target_name"
6acff7da 6402TARGET_BASE_ARCH=""
e6e91b9c 6403TARGET_ABI_DIR=""
e73aae67 6404
c1799a84 6405case "$target_name" in
2408a527 6406 i386)
b8158192 6407 gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
2408a527
AJ
6408 ;;
6409 x86_64)
6acff7da 6410 TARGET_BASE_ARCH=i386
b8158192 6411 gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
2408a527
AJ
6412 ;;
6413 alpha)
5ee4f3c2 6414 mttcg="yes"
2408a527
AJ
6415 ;;
6416 arm|armeb)
b498c8a0 6417 TARGET_ARCH=arm
2408a527 6418 bflt="yes"
ca759f9e 6419 mttcg="yes"
56aebc89 6420 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2408a527 6421 ;;
6a49fa95
AG
6422 aarch64)
6423 TARGET_BASE_ARCH=arm
6424 bflt="yes"
ca759f9e 6425 mttcg="yes"
8f95ce2e 6426 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6a49fa95 6427 ;;
2408a527 6428 cris)
2408a527 6429 ;;
61766fe9
RH
6430 hppa)
6431 ;;
613a22c9 6432 lm32)
613a22c9 6433 ;;
2408a527 6434 m68k)
2408a527 6435 bflt="yes"
5a4526b2 6436 gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
2408a527 6437 ;;
877fdc12
EI
6438 microblaze|microblazeel)
6439 TARGET_ARCH=microblaze
72b675ca 6440 bflt="yes"
72b675ca 6441 ;;
0adcffb1 6442 mips|mipsel)
b498c8a0 6443 TARGET_ARCH=mips
25be210f 6444 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2408a527
AJ
6445 ;;
6446 mipsn32|mipsn32el)
597e2cec 6447 TARGET_ARCH=mips64
6acff7da 6448 TARGET_BASE_ARCH=mips
25be210f 6449 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
597e2cec 6450 echo "TARGET_ABI32=y" >> $config_target_mak
2408a527
AJ
6451 ;;
6452 mips64|mips64el)
b498c8a0 6453 TARGET_ARCH=mips64
6acff7da 6454 TARGET_BASE_ARCH=mips
25be210f 6455 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2408a527 6456 ;;
d15a9c23
AG
6457 moxie)
6458 ;;
e671711c
MV
6459 nios2)
6460 ;;
4a09d0bb 6461 or1k)
e67db06e
JL
6462 TARGET_ARCH=openrisc
6463 TARGET_BASE_ARCH=openrisc
e67db06e 6464 ;;
2408a527 6465 ppc)
c8b3532d 6466 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2408a527
AJ
6467 ;;
6468 ppcemb)
6acff7da 6469 TARGET_BASE_ARCH=ppc
e6e91b9c 6470 TARGET_ABI_DIR=ppc
c8b3532d 6471 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2408a527
AJ
6472 ;;
6473 ppc64)
6acff7da 6474 TARGET_BASE_ARCH=ppc
e6e91b9c 6475 TARGET_ABI_DIR=ppc
f0b0685d 6476 mttcg=yes
1438eff3 6477 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
2408a527 6478 ;;
9c35126c
DK
6479 ppc64le)
6480 TARGET_ARCH=ppc64
6481 TARGET_BASE_ARCH=ppc
6482 TARGET_ABI_DIR=ppc
f0b0685d 6483 mttcg=yes
1438eff3 6484 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
9c35126c 6485 ;;
2408a527 6486 ppc64abi32)
b498c8a0 6487 TARGET_ARCH=ppc64
6acff7da 6488 TARGET_BASE_ARCH=ppc
e6e91b9c 6489 TARGET_ABI_DIR=ppc
25be210f 6490 echo "TARGET_ABI32=y" >> $config_target_mak
1438eff3 6491 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
2408a527
AJ
6492 ;;
6493 sh4|sh4eb)
b498c8a0 6494 TARGET_ARCH=sh4
2408a527
AJ
6495 bflt="yes"
6496 ;;
6497 sparc)
2408a527
AJ
6498 ;;
6499 sparc64)
6acff7da 6500 TARGET_BASE_ARCH=sparc
2408a527
AJ
6501 ;;
6502 sparc32plus)
b498c8a0 6503 TARGET_ARCH=sparc64
6acff7da 6504 TARGET_BASE_ARCH=sparc
e6e91b9c 6505 TARGET_ABI_DIR=sparc
25be210f 6506 echo "TARGET_ABI32=y" >> $config_target_mak
2408a527 6507 ;;
24e804ec 6508 s390x)
86158a2a 6509 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
24e804ec 6510 ;;
444e06b1
CG
6511 tilegx)
6512 ;;
5ecaa4ed
PC
6513 tricore)
6514 ;;
d2fbca94 6515 unicore32)
d2fbca94 6516 ;;
cfa550c6
MF
6517 xtensa|xtensaeb)
6518 TARGET_ARCH=xtensa
cfa550c6 6519 ;;
2408a527 6520 *)
76ad07a4 6521 error_exit "Unsupported target CPU"
2408a527
AJ
6522 ;;
6523esac
5e8861a0
PB
6524# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6525if [ "$TARGET_BASE_ARCH" = "" ]; then
6526 TARGET_BASE_ARCH=$TARGET_ARCH
6527fi
6528
5e8861a0
PB
6529symlink "$source_path/Makefile.target" "$target_dir/Makefile"
6530
99afc91d
DB
6531upper() {
6532 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
6533}
6534
89138857 6535target_arch_name="$(upper $TARGET_ARCH)"
25be210f 6536echo "TARGET_$target_arch_name=y" >> $config_target_mak
c1799a84 6537echo "TARGET_NAME=$target_name" >> $config_target_mak
25be210f 6538echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
e6e91b9c
JQ
6539if [ "$TARGET_ABI_DIR" = "" ]; then
6540 TARGET_ABI_DIR=$TARGET_ARCH
6541fi
25be210f 6542echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
adfc3e91
SS
6543if [ "$HOST_VARIANT_DIR" != "" ]; then
6544 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6545fi
3b6b7550
PB
6546
6547if supported_xen_target $target; then
6548 echo "CONFIG_XEN=y" >> $config_target_mak
6549 if test "$xen_pci_passthrough" = yes; then
eb6fda0f 6550 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
1b0c87fc 6551 fi
3b6b7550
PB
6552fi
6553if supported_kvm_target $target; then
6554 echo "CONFIG_KVM=y" >> $config_target_mak
6555 if test "$vhost_net" = "yes" ; then
d5970055 6556 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
e6a74868
MAL
6557 if test "$vhost_user" = "yes" ; then
6558 echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6559 fi
c59249f9 6560 fi
3b6b7550
PB
6561fi
6562if supported_hax_target $target; then
6563 echo "CONFIG_HAX=y" >> $config_target_mak
b0cb0a66 6564fi
de83cd02 6565if test "$target_bigendian" = "yes" ; then
25be210f 6566 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
de83cd02 6567fi
97a847bc 6568if test "$target_softmmu" = "yes" ; then
25be210f 6569 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
ca759f9e
AB
6570 if test "$mttcg" = "yes" ; then
6571 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6572 fi
43ce4dfe 6573fi
997344f3 6574if test "$target_user_only" = "yes" ; then
25be210f 6575 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
a2c80be9 6576 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
997344f3 6577fi
831b7825 6578if test "$target_linux_user" = "yes" ; then
25be210f 6579 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
831b7825 6580fi
56aebc89
PB
6581list=""
6582if test ! -z "$gdb_xml_files" ; then
6583 for x in $gdb_xml_files; do
6584 list="$list $source_path/gdb-xml/$x"
6585 done
3d0f1517 6586 echo "TARGET_XML_FILES=$list" >> $config_target_mak
56aebc89 6587fi
97a847bc 6588
e5fe0c52 6589if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
25be210f 6590 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
e5fe0c52 6591fi
84778508 6592if test "$target_bsd_user" = "yes" ; then
25be210f 6593 echo "CONFIG_BSD_USER=y" >> $config_target_mak
84778508 6594fi
5b0753e0 6595
4afddb55 6596# generate QEMU_CFLAGS/LDFLAGS for targets
fa282484 6597
4afddb55 6598cflags=""
fa282484 6599ldflags=""
9b8e111f 6600
c765fcac
PC
6601disas_config() {
6602 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6603 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6604}
6605
64656024
JQ
6606for i in $ARCH $TARGET_BASE_ARCH ; do
6607 case "$i" in
6608 alpha)
c765fcac 6609 disas_config "ALPHA"
64656024 6610 ;;
82295d8a
RH
6611 aarch64)
6612 if test -n "${cxx}"; then
c765fcac 6613 disas_config "ARM_A64"
82295d8a
RH
6614 fi
6615 ;;
64656024 6616 arm)
c765fcac 6617 disas_config "ARM"
999b53ec 6618 if test -n "${cxx}"; then
c765fcac 6619 disas_config "ARM_A64"
999b53ec 6620 fi
64656024
JQ
6621 ;;
6622 cris)
c765fcac 6623 disas_config "CRIS"
64656024 6624 ;;
429b31a2
RH
6625 hppa)
6626 disas_config "HPPA"
6627 ;;
c72b26ec 6628 i386|x86_64|x32)
c765fcac 6629 disas_config "I386"
64656024 6630 ;;
79368f49 6631 lm32)
c765fcac 6632 disas_config "LM32"
79368f49 6633 ;;
64656024 6634 m68k)
c765fcac 6635 disas_config "M68K"
64656024 6636 ;;
877fdc12 6637 microblaze*)
c765fcac 6638 disas_config "MICROBLAZE"
64656024
JQ
6639 ;;
6640 mips*)
c765fcac 6641 disas_config "MIPS"
64656024 6642 ;;
d15a9c23 6643 moxie*)
c765fcac 6644 disas_config "MOXIE"
d15a9c23 6645 ;;
e671711c
MV
6646 nios2)
6647 disas_config "NIOS2"
6648 ;;
4a09d0bb 6649 or1k)
c765fcac 6650 disas_config "OPENRISC"
e67db06e 6651 ;;
64656024 6652 ppc*)
c765fcac 6653 disas_config "PPC"
64656024 6654 ;;
24e804ec 6655 s390*)
c765fcac 6656 disas_config "S390"
64656024
JQ
6657 ;;
6658 sh4)
c765fcac 6659 disas_config "SH4"
64656024
JQ
6660 ;;
6661 sparc*)
c765fcac 6662 disas_config "SPARC"
64656024 6663 ;;
cfa550c6 6664 xtensa*)
c765fcac 6665 disas_config "XTENSA"
cfa550c6 6666 ;;
64656024
JQ
6667 esac
6668done
9195b2c2 6669if test "$tcg_interpreter" = "yes" ; then
c765fcac 6670 disas_config "TCI"
9195b2c2 6671fi
64656024 6672
6ee7126f
JQ
6673case "$ARCH" in
6674alpha)
6675 # Ensure there's only a single GP
6676 cflags="-msmall-data $cflags"
6677;;
6678esac
6679
d02c1db3 6680if test "$gprof" = "yes" ; then
25be210f 6681 echo "TARGET_GPROF=yes" >> $config_target_mak
d02c1db3
JQ
6682 if test "$target_linux_user" = "yes" ; then
6683 cflags="-p $cflags"
6684 ldflags="-p $ldflags"
6685 fi
6686 if test "$target_softmmu" = "yes" ; then
6687 ldflags="-p $ldflags"
25be210f 6688 echo "GPROF_CFLAGS=-p" >> $config_target_mak
d02c1db3
JQ
6689 fi
6690fi
6691
9b8e111f 6692if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
964c6fa1 6693 ldflags="$ldflags $textseg_ldflags"
fa282484 6694fi
fa282484 6695
e9a3591f
CB
6696# Newer kernels on s390 check for an S390_PGSTE program header and
6697# enable the pgste page table extensions in that case. This makes
6698# the vm.allocate_pgste sysctl unnecessary. We enable this program
6699# header if
6700# - we build on s390x
6701# - we build the system emulation for s390x (qemu-system-s390x)
6702# - KVM is enabled
6703# - the linker supports --s390-pgste
6704if test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes" -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6705 if ld_has --s390-pgste ; then
6706 ldflags="-Wl,--s390-pgste $ldflags"
6707 fi
6708fi
6709
25be210f
JQ
6710echo "LDFLAGS+=$ldflags" >> $config_target_mak
6711echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
fa282484 6712
97a847bc 6713done # for target in $targets
7d13299d 6714
a540f158
PC
6715if [ "$dtc_internal" = "yes" ]; then
6716 echo "config-host.h: subdir-dtc" >> $config_host_mak
6717fi
e219c499
RH
6718if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
6719 echo "config-host.h: subdir-capstone" >> $config_host_mak
6720fi
6721if test -n "$LIBCAPSTONE"; then
6722 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
6723fi
a540f158 6724
a99d57bb
WG
6725if test "$numa" = "yes"; then
6726 echo "CONFIG_NUMA=y" >> $config_host_mak
6727fi
6728
fd0e6053
JS
6729if test "$ccache_cpp2" = "yes"; then
6730 echo "export CCACHE_CPP2=y" >> $config_host_mak
6731fi
6732
d1807a4f 6733# build tree in object directory in case the source is not in the current directory
b1fb9a63 6734DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
b855f8d1 6735DIRS="$DIRS docs docs/interop fsdev scsi"
9933c305 6736DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
d1807a4f 6737DIRS="$DIRS roms/seabios roms/vgabios"
2dee8d54 6738DIRS="$DIRS qapi-generated"
c09015dd
AL
6739FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6740FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
aaa2ebc5 6741FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
d1807a4f 6742FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
446b9165 6743FILES="$FILES pc-bios/spapr-rtas/Makefile"
9933c305 6744FILES="$FILES pc-bios/s390-ccw/Makefile"
d1807a4f 6745FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4652b792 6746FILES="$FILES pc-bios/qemu-icon.bmp"
3a586d2f 6747FILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
753d11f2
RH
6748for bios_file in \
6749 $source_path/pc-bios/*.bin \
225a9ab8 6750 $source_path/pc-bios/*.lid \
5acc2ec0 6751 $source_path/pc-bios/*.aml \
753d11f2
RH
6752 $source_path/pc-bios/*.rom \
6753 $source_path/pc-bios/*.dtb \
e89e33e1 6754 $source_path/pc-bios/*.img \
753d11f2 6755 $source_path/pc-bios/openbios-* \
4e73c781 6756 $source_path/pc-bios/u-boot.* \
753d11f2
RH
6757 $source_path/pc-bios/palcode-*
6758do
89138857 6759 FILES="$FILES pc-bios/$(basename $bios_file)"
d1807a4f 6760done
89138857 6761for test_file in $(find $source_path/tests/acpi-test-data -type f)
c2304b52 6762do
89138857 6763 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
c2304b52 6764done
d1807a4f
PB
6765mkdir -p $DIRS
6766for f in $FILES ; do
cab00a5a 6767 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
f9245e10
PM
6768 symlink "$source_path/$f" "$f"
6769 fi
d1807a4f 6770done
1ad2134f 6771
c34ebfdc 6772# temporary config to build submodules
2d9f27d2 6773for rom in seabios vgabios ; do
c34ebfdc 6774 config_mak=roms/$rom/config.mak
37116c89 6775 echo "# Automatically generated by configure - do not modify" > $config_mak
c34ebfdc 6776 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
cdbd727c 6777 echo "AS=$as" >> $config_mak
5f6f0e27 6778 echo "CCAS=$ccas" >> $config_mak
c34ebfdc
AL
6779 echo "CC=$cc" >> $config_mak
6780 echo "BCC=bcc" >> $config_mak
3dd46c78 6781 echo "CPP=$cpp" >> $config_mak
c34ebfdc 6782 echo "OBJCOPY=objcopy" >> $config_mak
a31a8642 6783 echo "IASL=$iasl" >> $config_mak
c34ebfdc
AL
6784 echo "LD=$ld" >> $config_mak
6785done
6786
fe31017f
MAL
6787# set up tests data directory
6788if [ ! -e tests/data ]; then
6789 symlink "$source_path/tests/data" tests/data
6790fi
6791
76c7560a
HR
6792# set up qemu-iotests in this build directory
6793iotests_common_env="tests/qemu-iotests/common.env"
6794iotests_check="tests/qemu-iotests/check"
6795
6796echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
6797echo >> "$iotests_common_env"
6798echo "export PYTHON='$python'" >> "$iotests_common_env"
6799
6800if [ ! -e "$iotests_check" ]; then
6801 symlink "$source_path/$iotests_check" "$iotests_check"
6802fi
6803
dc655404
MT
6804# Save the configure command line for later reuse.
6805cat <<EOD >config.status
6806#!/bin/sh
6807# Generated by configure.
6808# Run this file to recreate the current configuration.
6809# Compiler output produced by configure, useful for debugging
6810# configure, is in config.log if it exists.
6811EOD
6812printf "exec" >>config.status
6813printf " '%s'" "$0" "$@" >>config.status
cf7cc929 6814echo ' "$@"' >>config.status
dc655404
MT
6815chmod +x config.status
6816
8cd05ab6 6817rm -r "$TMPDIR1"