VirtGL: remove device
[sdk/emulator/qemu.git] / configure
1 #!/bin/sh
2 #
3 # qemu configure script (c) 2003 Fabrice Bellard
4 #
5 # set temporary file name
6 if test ! -z "$TMPDIR" ; then
7     TMPDIR1="${TMPDIR}"
8 elif test ! -z "$TEMPDIR" ; then
9     TMPDIR1="${TEMPDIR}"
10 else
11     TMPDIR1="/tmp"
12 fi
13
14 TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPB="qemu-conf-${RANDOM}-$$-${RANDOM}"
16 TMPO="${TMPDIR1}/${TMPB}.o"
17 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
18 TMPL="${TMPDIR1}/${TMPB}.lo"
19 TMPA="${TMPDIR1}/lib${TMPB}.la"
20 TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
21
22 # NB: do not call "exit" in the trap handler; this is buggy with some shells;
23 # see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
24 trap "rm -f $TMPC $TMPO $TMPCXX $TMPE" EXIT INT QUIT TERM
25 rm -f config.log
26
27 # Print a helpful header at the top of config.log
28 echo "# QEMU configure log $(date)" >> config.log
29 printf "# Configured with:" >> config.log
30 printf " '%s'" "$0" "$@" >> config.log
31 echo >> config.log
32 echo "#" >> config.log
33
34 error_exit() {
35     echo
36     echo "ERROR: $1"
37     while test -n "$2"; do
38         echo "       $2"
39         shift
40     done
41     echo
42     exit 1
43 }
44
45 do_compiler() {
46     # Run the compiler, capturing its output to the log. First argument
47     # is compiler binary to execute.
48     local compiler="$1"
49     shift
50     echo $compiler "$@" >> config.log
51     $compiler "$@" >> config.log 2>&1 || return $?
52     # Test passed. If this is an --enable-werror build, rerun
53     # the test with -Werror and bail out if it fails. This
54     # makes warning-generating-errors in configure test code
55     # obvious to developers.
56     if test "$werror" != "yes"; then
57         return 0
58     fi
59     # Don't bother rerunning the compile if we were already using -Werror
60     case "$*" in
61         *-Werror*)
62            return 0
63         ;;
64     esac
65     echo $compiler -Werror "$@" >> config.log
66     $compiler -Werror "$@" >> config.log 2>&1 && return $?
67     error_exit "configure test passed without -Werror but failed with -Werror." \
68         "This is probably a bug in the configure script. The failing command" \
69         "will be at the bottom of config.log." \
70         "You can run configure with --disable-werror to bypass this check."
71 }
72
73 do_cc() {
74     do_compiler "$cc" "$@"
75 }
76
77 do_cxx() {
78     do_compiler "$cxx" "$@"
79 }
80
81 update_cxxflags() {
82     # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
83     # options which some versions of GCC's C++ compiler complain about
84     # because they only make sense for C programs.
85     QEMU_CXXFLAGS=
86     for arg in $QEMU_CFLAGS; do
87         case $arg in
88             -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
89             -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
90                 ;;
91             *)
92                 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
93                 ;;
94         esac
95     done
96 }
97
98 compile_object() {
99   do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
100 }
101
102 compile_prog() {
103   local_cflags="$1"
104   local_ldflags="$2"
105   do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
106 }
107
108 do_libtool() {
109     local mode=$1
110     shift
111     # Run the compiler, capturing its output to the log.
112     echo $libtool $mode --tag=CC $cc "$@" >> config.log
113     $libtool $mode --tag=CC $cc "$@" >> config.log 2>&1 || return $?
114     # Test passed. If this is an --enable-werror build, rerun
115     # the test with -Werror and bail out if it fails. This
116     # makes warning-generating-errors in configure test code
117     # obvious to developers.
118     if test "$werror" != "yes"; then
119         return 0
120     fi
121     # Don't bother rerunning the compile if we were already using -Werror
122     case "$*" in
123         *-Werror*)
124            return 0
125         ;;
126     esac
127     echo $libtool $mode --tag=CC $cc -Werror "$@" >> config.log
128     $libtool $mode --tag=CC $cc -Werror "$@" >> config.log 2>&1 && return $?
129     error_exit "configure test passed without -Werror but failed with -Werror." \
130         "This is probably a bug in the configure script. The failing command" \
131         "will be at the bottom of config.log." \
132         "You can run configure with --disable-werror to bypass this check."
133 }
134
135 libtool_prog() {
136     do_libtool --mode=compile $QEMU_CFLAGS -c -fPIE -DPIE -o $TMPO $TMPC || return $?
137     do_libtool --mode=link $LDFLAGS -o $TMPA $TMPL -rpath /usr/local/lib
138 }
139
140 # symbolically link $1 to $2.  Portable version of "ln -sf".
141 symlink() {
142   rm -rf "$2"
143   mkdir -p "$(dirname "$2")"
144   ln -s "$1" "$2"
145 }
146
147 # check whether a command is available to this shell (may be either an
148 # executable or a builtin)
149 has() {
150     type "$1" >/dev/null 2>&1
151 }
152
153 # search for an executable in PATH
154 path_of() {
155     local_command="$1"
156     local_ifs="$IFS"
157     local_dir=""
158
159     # pathname has a dir component?
160     if [ "${local_command#*/}" != "$local_command" ]; then
161         if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
162             echo "$local_command"
163             return 0
164         fi
165     fi
166     if [ -z "$local_command" ]; then
167         return 1
168     fi
169
170     IFS=:
171     for local_dir in $PATH; do
172         if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
173             echo "$local_dir/$local_command"
174             IFS="${local_ifs:-$(printf ' \t\n')}"
175             return 0
176         fi
177     done
178     # not found
179     IFS="${local_ifs:-$(printf ' \t\n')}"
180     return 1
181 }
182
183 # default parameters
184 source_path=`dirname "$0"`
185 cpu=""
186 iasl="iasl"
187 interp_prefix="/usr/gnemul/qemu-%M"
188 static="no"
189 cross_prefix=""
190 audio_drv_list=""
191 block_drv_rw_whitelist=""
192 block_drv_ro_whitelist=""
193 host_cc="cc"
194 libs_softmmu=""
195 libs_tools=""
196 audio_pt_int=""
197 audio_win_int=""
198 cc_i386=i386-pc-linux-gnu-gcc
199 libs_qga=""
200 debug_info="yes"
201 stack_protector=""
202
203 # Don't accept a target_list environment variable.
204 unset target_list
205
206 # Default value for a variable defining feature "foo".
207 #  * foo="no"  feature will only be used if --enable-foo arg is given
208 #  * foo=""    feature will be searched for, and if found, will be used
209 #              unless --disable-foo is given
210 #  * foo="yes" this value will only be set by --enable-foo flag.
211 #              feature will searched for,
212 #              if not found, configure exits with error
213 #
214 # Always add --enable-foo and --disable-foo command line args.
215 # Distributions want to ensure that several features are compiled in, and it
216 # is impossible without a --enable-foo that exits if a feature is not found.
217
218 bluez=""
219 brlapi=""
220 curl=""
221 curses=""
222 docs=""
223 fdt=""
224 netmap="no"
225 pixman=""
226 sdl=""
227 sdlabi="1.2"
228 virtfs=""
229 vnc="yes"
230 sparse="no"
231 uuid=""
232 vde=""
233 vnc_tls=""
234 vnc_sasl=""
235 vnc_jpeg=""
236 vnc_png=""
237 vnc_ws=""
238 xen=""
239 xen_ctrl_version=""
240 xen_pci_passthrough=""
241 linux_aio=""
242 cap_ng=""
243 attr=""
244 libattr=""
245 xfs=""
246
247 vhost_net="no"
248 vhost_scsi="no"
249 kvm="no"
250 hax="no"
251 rdma=""
252 gprof="no"
253 debug_tcg="no"
254 debug="no"
255 strip_opt="yes"
256 tcg_interpreter="no"
257 bigendian="no"
258 mingw32="no"
259 gcov="no"
260 gcov_tool="gcov"
261 EXESUF=""
262 DSOSUF=".so"
263 LDFLAGS_SHARED="-shared"
264 modules="no"
265 prefix="/usr/local"
266 mandir="\${prefix}/share/man"
267 datadir="\${prefix}/share"
268 qemu_docdir="\${prefix}/share/doc/qemu"
269 bindir="\${prefix}/bin"
270 libdir="\${prefix}/lib"
271 libexecdir="\${prefix}/libexec"
272 includedir="\${prefix}/include"
273 sysconfdir="\${prefix}/etc"
274 local_statedir="\${prefix}/var"
275 confsuffix="/qemu"
276 slirp="yes"
277 fmod_lib=""
278 fmod_inc=""
279 oss_lib=""
280 bsd="no"
281 linux="no"
282 solaris="no"
283 profiler="no"
284 cocoa="no"
285 softmmu="yes"
286 linux_user="no"
287 bsd_user="no"
288 guest_base="yes"
289 uname_release=""
290 aix="no"
291 blobs="yes"
292 pkgversion=""
293 pie=""
294 zero_malloc=""
295 qom_cast_debug="yes"
296 trace_backend="nop"
297 trace_file="trace"
298 spice=""
299 rbd=""
300 smartcard_nss=""
301 libusb=""
302 usb_redir=""
303 opengl=""
304 efence="no"
305 yagl="no"
306 yagl_stats="no"
307 glx=""
308 vigs="no"
309 zlib="yes"
310 lzo="no"
311 snappy="no"
312 guest_agent=""
313 guest_agent_with_vss="no"
314 vss_win32_sdk=""
315 win_sdk="no"
316 want_tools="yes"
317 libiscsi=""
318 libnfs=""
319 coroutine=""
320 coroutine_pool=""
321 seccomp=""
322
323 # for TIZEN-maru 
324 maru="no"
325 shm="no"
326 libav="no"
327 png="no"
328 #
329 glusterfs=""
330 glusterfs_discard="no"
331 glusterfs_zerofill="no"
332 virtio_blk_data_plane=""
333 gtk=""
334 gtkabi="2.0"
335 vte=""
336 tpm="no"
337 libssh2=""
338 vhdx=""
339 quorum="no"
340
341 # parse CC options first
342 for opt do
343   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
344   case "$opt" in
345   --cross-prefix=*) cross_prefix="$optarg"
346   ;;
347   --cc=*) CC="$optarg"
348   ;;
349   --cxx=*) CXX="$optarg"
350   ;;
351   --source-path=*) source_path="$optarg"
352   ;;
353   --cpu=*) cpu="$optarg"
354   ;;
355   --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
356                     EXTRA_CFLAGS="$optarg"
357   ;;
358   --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
359                      EXTRA_LDFLAGS="$optarg"
360   ;;
361   --enable-debug-info) debug_info="yes"
362   ;;
363   --disable-debug-info) debug_info="no"
364   ;;
365   esac
366 done
367 # OS specific
368 # Using uname is really, really broken.  Once we have the right set of checks
369 # we can eliminate its usage altogether.
370
371 # Preferred compiler:
372 #  ${CC} (if set)
373 #  ${cross_prefix}gcc (if cross-prefix specified)
374 #  system compiler
375 if test -z "${CC}${cross_prefix}"; then
376   cc="$host_cc"
377 else
378   cc="${CC-${cross_prefix}gcc}"
379 fi
380
381 if test -z "${CXX}${cross_prefix}"; then
382   cxx="c++"
383 else
384   cxx="${CXX-${cross_prefix}g++}"
385 fi
386
387 ar="${AR-${cross_prefix}ar}"
388 as="${AS-${cross_prefix}as}"
389 cpp="${CPP-$cc -E}"
390 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
391 ld="${LD-${cross_prefix}ld}"
392 libtool="${LIBTOOL-${cross_prefix}libtool}"
393 strip="${STRIP-${cross_prefix}strip}"
394 windres="${WINDRES-${cross_prefix}windres}"
395 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
396 query_pkg_config() {
397     "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
398 }
399 pkg_config=query_pkg_config
400 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
401 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
402
403 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
404 ARFLAGS="${ARFLAGS-rv}"
405
406 # default flags for all hosts
407 QEMU_CFLAGS="-fno-strict-aliasing -fno-common $QEMU_CFLAGS"
408 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
409 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
410 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
411 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
412 if test "$debug_info" = "yes"; then
413     CFLAGS="-g $CFLAGS"
414     LDFLAGS="-g $LDFLAGS"
415 fi
416
417 # make source path absolute
418 source_path=`cd "$source_path"; pwd`
419
420 check_define() {
421 cat > $TMPC <<EOF
422 #if !defined($1)
423 #error $1 not defined
424 #endif
425 int main(void) { return 0; }
426 EOF
427   compile_object
428 }
429
430 if check_define __linux__ ; then
431   targetos="Linux"
432 elif check_define _WIN32 ; then
433   targetos='MINGW32'
434 elif check_define __OpenBSD__ ; then
435   targetos='OpenBSD'
436 elif check_define __sun__ ; then
437   targetos='SunOS'
438 elif check_define __HAIKU__ ; then
439   targetos='Haiku'
440 else
441   targetos=`uname -s`
442 fi
443
444 # Some host OSes need non-standard checks for which CPU to use.
445 # Note that these checks are broken for cross-compilation: if you're
446 # cross-compiling to one of these OSes then you'll need to specify
447 # the correct CPU with the --cpu option.
448 case $targetos in
449 Darwin)
450   # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
451   # run 64-bit userspace code.
452   # If the user didn't specify a CPU explicitly and the kernel says this is
453   # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
454   if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
455     cpu="x86_64"
456   fi
457   ;;
458 SunOS)
459   # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
460   if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
461     cpu="x86_64"
462   fi
463 esac
464
465 if test ! -z "$cpu" ; then
466   # command line argument
467   :
468 elif check_define __i386__ ; then
469   cpu="i386"
470 elif check_define __x86_64__ ; then
471   if check_define __ILP32__ ; then
472     cpu="x32"
473   else
474     cpu="x86_64"
475   fi
476 elif check_define __sparc__ ; then
477   if check_define __arch64__ ; then
478     cpu="sparc64"
479   else
480     cpu="sparc"
481   fi
482 elif check_define _ARCH_PPC ; then
483   if check_define _ARCH_PPC64 ; then
484     cpu="ppc64"
485   else
486     cpu="ppc"
487   fi
488 elif check_define __mips__ ; then
489   cpu="mips"
490 elif check_define __ia64__ ; then
491   cpu="ia64"
492 elif check_define __s390__ ; then
493   if check_define __s390x__ ; then
494     cpu="s390x"
495   else
496     cpu="s390"
497   fi
498 elif check_define __arm__ ; then
499   cpu="arm"
500 elif check_define __aarch64__ ; then
501   cpu="aarch64"
502 elif check_define __hppa__ ; then
503   cpu="hppa"
504 else
505   cpu=`uname -m`
506 fi
507
508 ARCH=
509 # Normalise host CPU name and set ARCH.
510 # Note that this case should only have supported host CPUs, not guests.
511 case "$cpu" in
512   ia64|ppc|ppc64|s390|s390x|sparc64|x32)
513     cpu="$cpu"
514   ;;
515   i386|i486|i586|i686|i86pc|BePC)
516     cpu="i386"
517   ;;
518   x86_64|amd64)
519     cpu="x86_64"
520   ;;
521   armv*b|armv*l|arm)
522     cpu="arm"
523   ;;
524   aarch64)
525     cpu="aarch64"
526   ;;
527   mips*)
528     cpu="mips"
529   ;;
530   sparc|sun4[cdmuv])
531     cpu="sparc"
532   ;;
533   *)
534     # This will result in either an error or falling back to TCI later
535     ARCH=unknown
536   ;;
537 esac
538 if test -z "$ARCH"; then
539   ARCH="$cpu"
540 fi
541
542 # OS specific
543
544 case $targetos in
545 CYGWIN*)
546   mingw32="yes"
547   QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
548   audio_possible_drivers="winwave sdl"
549   audio_drv_list="winwave"
550 ;;
551 MINGW32*)
552   mingw32="yes"
553   audio_possible_drivers="winwave dsound sdl fmod"
554   audio_drv_list="winwave"
555 ;;
556 GNU/kFreeBSD)
557   bsd="yes"
558   audio_drv_list="oss"
559   audio_possible_drivers="oss sdl esd pa"
560 ;;
561 FreeBSD)
562   bsd="yes"
563   make="${MAKE-gmake}"
564   audio_drv_list="oss"
565   audio_possible_drivers="oss sdl esd pa"
566   # needed for kinfo_getvmmap(3) in libutil.h
567   LIBS="-lutil $LIBS"
568   netmap=""  # enable netmap autodetect
569 ;;
570 DragonFly)
571   bsd="yes"
572   make="${MAKE-gmake}"
573   audio_drv_list="oss"
574   audio_possible_drivers="oss sdl esd pa"
575 ;;
576 NetBSD)
577   bsd="yes"
578   make="${MAKE-gmake}"
579   audio_drv_list="oss"
580   audio_possible_drivers="oss sdl esd"
581   oss_lib="-lossaudio"
582 ;;
583 OpenBSD)
584   bsd="yes"
585   make="${MAKE-gmake}"
586   audio_drv_list="sdl"
587   audio_possible_drivers="sdl esd"
588 ;;
589 Darwin)
590   bsd="yes"
591   darwin="yes"
592   LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
593   if [ "$cpu" = "x86_64" ] ; then
594     QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
595     LDFLAGS="-arch x86_64 $LDFLAGS"
596   fi
597   cocoa="yes"
598   audio_drv_list="coreaudio"
599   audio_possible_drivers="coreaudio sdl fmod"
600   LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
601   libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
602   # Disable attempts to use ObjectiveC features in os/object.h since they
603   # won't work when we're compiling with gcc as a C compiler.
604   QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
605 ;;
606 SunOS)
607   solaris="yes"
608   make="${MAKE-gmake}"
609   install="${INSTALL-ginstall}"
610   ld="gld"
611   smbd="${SMBD-/usr/sfw/sbin/smbd}"
612   needs_libsunmath="no"
613   solarisrev=`uname -r | cut -f2 -d.`
614   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
615     if test "$solarisrev" -le 9 ; then
616       if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
617         needs_libsunmath="yes"
618         QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
619         LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
620         LIBS="-lsunmath $LIBS"
621       else
622         error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
623             "libsunmath from the Sun Studio compilers tools, due to a lack of" \
624             "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
625             "Studio 11 can be downloaded from www.sun.com."
626       fi
627     fi
628   fi
629   if test -f /usr/include/sys/soundcard.h ; then
630     audio_drv_list="oss"
631   fi
632   audio_possible_drivers="oss sdl"
633 # needed for CMSG_ macros in sys/socket.h
634   QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
635 # needed for TIOCWIN* defines in termios.h
636   QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
637   QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
638   solarisnetlibs="-lsocket -lnsl -lresolv"
639   LIBS="$solarisnetlibs $LIBS"
640   libs_qga="$solarisnetlibs $libs_qga"
641 ;;
642 AIX)
643   aix="yes"
644   make="${MAKE-gmake}"
645 ;;
646 Haiku)
647   haiku="yes"
648   QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
649   LIBS="-lposix_error_mapper -lnetwork $LIBS"
650 ;;
651 *)
652   audio_drv_list="oss"
653   audio_possible_drivers="oss alsa sdl esd pa"
654   linux="yes"
655   linux_user="yes"
656   kvm="yes"
657   vhost_net="yes"
658   vhost_scsi="yes"
659   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "x32" ] ; then
660     audio_possible_drivers="$audio_possible_drivers fmod"
661   fi
662
663 # fix linking error on Ubuntu 13.04
664 #  libs_qga="-lrt $libs_qga"
665 #  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
666   QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
667 ;;
668 esac
669
670 if [ "$bsd" = "yes" ] ; then
671   if [ "$darwin" != "yes" ] ; then
672     bsd_user="yes"
673   fi
674 fi
675
676 : ${make=${MAKE-make}}
677 : ${install=${INSTALL-install}}
678 : ${python=${PYTHON-python}}
679 : ${smbd=${SMBD-/usr/sbin/smbd}}
680
681 # Default objcc to clang if available, otherwise use CC
682 if has clang; then
683   objcc=clang
684 else
685   objcc="$cc"
686 fi
687
688 if test "$mingw32" = "yes" ; then
689   EXESUF=".exe"
690   DSOSUF=".dll"
691   QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
692   # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
693   QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
694   LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
695 cat > $TMPC << EOF
696 int main(void) { return 0; }
697 EOF
698   if compile_prog "" "-liberty" ; then
699     LIBS="-liberty $LIBS"
700   fi
701   prefix="c:/Program Files/QEMU"
702   mandir="\${prefix}"
703   datadir="\${prefix}"
704   qemu_docdir="\${prefix}"
705   bindir="\${prefix}"
706   sysconfdir="\${prefix}"
707   local_statedir=
708   confsuffix=""
709   libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
710 fi
711
712 werror=""
713
714 for opt do
715   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
716   case "$opt" in
717   --help|-h) show_help=yes
718   ;;
719   --version|-V) exec cat $source_path/VERSION
720   ;;
721   --prefix=*) prefix="$optarg"
722   ;;
723   --interp-prefix=*) interp_prefix="$optarg"
724   ;;
725   --source-path=*)
726   ;;
727   --cross-prefix=*)
728   ;;
729   --cc=*)
730   ;;
731   --host-cc=*) host_cc="$optarg"
732   ;;
733   --cxx=*)
734   ;;
735   --iasl=*) iasl="$optarg"
736   ;;
737   --objcc=*) objcc="$optarg"
738   ;;
739   --make=*) make="$optarg"
740   ;;
741   --install=*) install="$optarg"
742   ;;
743   --python=*) python="$optarg"
744   ;;
745   --gcov=*) gcov_tool="$optarg"
746   ;;
747   --smbd=*) smbd="$optarg"
748   ;;
749   --extra-cflags=*)
750   ;;
751   --extra-ldflags=*)
752   ;;
753   --enable-debug-info)
754   ;;
755   --disable-debug-info)
756   ;;
757   --enable-modules)
758       modules="yes"
759   ;;
760   --cpu=*)
761   ;;
762   --target-list=*) target_list="$optarg"
763   ;;
764   --enable-trace-backend=*) trace_backend="$optarg"
765   ;;
766   --with-trace-file=*) trace_file="$optarg"
767   ;;
768   --enable-gprof) gprof="yes"
769   ;;
770   --enable-gcov) gcov="yes"
771   ;;
772   --static)
773     static="yes"
774     LDFLAGS="-static $LDFLAGS"
775     QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
776   ;;
777   --mandir=*) mandir="$optarg"
778   ;;
779   --bindir=*) bindir="$optarg"
780   ;;
781   --libdir=*) libdir="$optarg"
782   ;;
783   --libexecdir=*) libexecdir="$optarg"
784   ;;
785   --includedir=*) includedir="$optarg"
786   ;;
787   --datadir=*) datadir="$optarg"
788   ;;
789   --with-confsuffix=*) confsuffix="$optarg"
790   ;;
791   --docdir=*) qemu_docdir="$optarg"
792   ;;
793   --sysconfdir=*) sysconfdir="$optarg"
794   ;;
795   --localstatedir=*) local_statedir="$optarg"
796   ;;
797   --sbindir=*|--sharedstatedir=*|\
798   --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
799   --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
800     # These switches are silently ignored, for compatibility with
801     # autoconf-generated configure scripts. This allows QEMU's
802     # configure to be used by RPM and similar macros that set
803     # lots of directory switches by default.
804   ;;
805   --with-system-pixman) pixman="system"
806   ;;
807   --without-system-pixman) pixman="internal"
808   ;;
809   --without-pixman) pixman="none"
810   ;;
811   --disable-sdl) sdl="no"
812   ;;
813   --enable-sdl) sdl="yes"
814   ;;
815   --with-sdlabi=*) sdlabi="$optarg"
816   ;;
817   --disable-qom-cast-debug) qom_cast_debug="no"
818   ;;
819   --enable-qom-cast-debug) qom_cast_debug="yes"
820   ;;
821   --disable-virtfs) virtfs="no"
822   ;;
823   --enable-virtfs) virtfs="yes"
824   ;;
825   --disable-vnc) vnc="no"
826   ;;
827   --enable-vnc) vnc="yes"
828   ;;
829   --fmod-lib=*) fmod_lib="$optarg"
830   ;;
831   --fmod-inc=*) fmod_inc="$optarg"
832   ;;
833   --oss-lib=*) oss_lib="$optarg"
834   ;;
835   --audio-drv-list=*) audio_drv_list="$optarg"
836   ;;
837   --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
838   ;;
839   --block-drv-ro-whitelist=*) block_drv_ro_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
840   ;;
841   --enable-debug-tcg) debug_tcg="yes"
842   ;;
843   --disable-debug-tcg) debug_tcg="no"
844   ;;
845   --enable-debug)
846       # Enable debugging options that aren't excessively noisy
847       debug_tcg="yes"
848       debug="yes"
849       strip_opt="no"
850   ;;
851   --enable-sparse) sparse="yes"
852   ;;
853   --disable-sparse) sparse="no"
854   ;;
855   --disable-strip) strip_opt="no"
856   ;;
857   --disable-vnc-tls) vnc_tls="no"
858   ;;
859   --enable-vnc-tls) vnc_tls="yes"
860   ;;
861   --disable-vnc-sasl) vnc_sasl="no"
862   ;;
863   --enable-vnc-sasl) vnc_sasl="yes"
864   ;;
865   --disable-vnc-jpeg) vnc_jpeg="no"
866   ;;
867   --enable-vnc-jpeg) vnc_jpeg="yes"
868   ;;
869   --disable-vnc-png) vnc_png="no"
870   ;;
871   --enable-vnc-png) vnc_png="yes"
872   ;;
873   --disable-vnc-ws) vnc_ws="no"
874   ;;
875   --enable-vnc-ws) vnc_ws="yes"
876   ;;
877   --disable-slirp) slirp="no"
878   ;;
879   --disable-uuid) uuid="no"
880   ;;
881   --enable-uuid) uuid="yes"
882   ;;
883   --disable-vde) vde="no"
884   ;;
885   --enable-vde) vde="yes"
886   ;;
887   --disable-netmap) netmap="no"
888   ;;
889   --enable-netmap) netmap="yes"
890   ;;
891   --disable-xen) xen="no"
892   ;;
893   --enable-xen) xen="yes"
894   ;;
895   --disable-xen-pci-passthrough) xen_pci_passthrough="no"
896   ;;
897   --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
898   ;;
899   --disable-brlapi) brlapi="no"
900   ;;
901   --enable-brlapi) brlapi="yes"
902   ;;
903   --disable-bluez) bluez="no"
904   ;;
905   --enable-bluez) bluez="yes"
906   ;;
907   --disable-kvm) kvm="no"
908   ;;
909   --enable-kvm) kvm="yes"
910   ;;
911   --disable-hax) hax="no"
912   ;;
913   --enable-hax) hax="yes"
914   ;;
915   --disable-tcg-interpreter) tcg_interpreter="no"
916   ;;
917   --enable-tcg-interpreter) tcg_interpreter="yes"
918   ;;
919   --disable-cap-ng)  cap_ng="no"
920   ;;
921   --enable-cap-ng) cap_ng="yes"
922   ;;
923   --disable-spice) spice="no"
924   ;;
925   --enable-spice) spice="yes"
926   ;;
927   --disable-libiscsi) libiscsi="no"
928   ;;
929   --enable-libiscsi) libiscsi="yes"
930   ;;
931   --disable-libnfs) libnfs="no"
932   ;;
933   --enable-libnfs) libnfs="yes"
934   ;;
935   --enable-profiler) profiler="yes"
936   ;;
937   --disable-cocoa) cocoa="no"
938   ;;
939   --enable-cocoa)
940       cocoa="yes" ;
941       sdl="no" ;
942       audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
943   ;;
944   --disable-system) softmmu="no"
945   ;;
946   --enable-system) softmmu="yes"
947   ;;
948   --disable-user)
949       linux_user="no" ;
950       bsd_user="no" ;
951   ;;
952   --enable-user) ;;
953   --disable-linux-user) linux_user="no"
954   ;;
955   --enable-linux-user) linux_user="yes"
956   ;;
957   --disable-bsd-user) bsd_user="no"
958   ;;
959   --enable-bsd-user) bsd_user="yes"
960   ;;
961   --enable-guest-base) guest_base="yes"
962   ;;
963   --disable-guest-base) guest_base="no"
964   ;;
965   --enable-pie) pie="yes"
966   ;;
967   --disable-pie) pie="no"
968   ;;
969   --enable-uname-release=*) uname_release="$optarg"
970   ;;
971   --enable-werror) werror="yes"
972   ;;
973   --disable-werror) werror="no"
974   ;;
975   --enable-stack-protector) stack_protector="yes"
976   ;;
977   --disable-stack-protector) stack_protector="no"
978   ;;
979   --disable-curses) curses="no"
980   ;;
981   --enable-curses) curses="yes"
982   ;;
983   --disable-curl) curl="no"
984   ;;
985   --enable-curl) curl="yes"
986   ;;
987   --disable-fdt) fdt="no"
988   ;;
989   --enable-fdt) fdt="yes"
990   ;;
991   --disable-linux-aio) linux_aio="no"
992   ;;
993   --enable-linux-aio) linux_aio="yes"
994   ;;
995   --disable-attr) attr="no"
996   ;;
997   --enable-attr) attr="yes"
998   ;;
999   --disable-blobs) blobs="no"
1000   ;;
1001   --with-pkgversion=*) pkgversion=" ($optarg)"
1002   ;;
1003   --with-coroutine=*) coroutine="$optarg"
1004   ;;
1005   --disable-coroutine-pool) coroutine_pool="no"
1006   ;;
1007   --enable-coroutine-pool) coroutine_pool="yes"
1008   ;;
1009   --disable-docs) docs="no"
1010   ;;
1011   --enable-docs) docs="yes"
1012   ;;
1013   --disable-vhost-net) vhost_net="no"
1014   ;;
1015   --enable-vhost-net) vhost_net="yes"
1016   ;;
1017   --enable-efence) efence="yes"
1018   ;;
1019   --disable-efence) efence="no"
1020   ;;
1021   --enable-yagl) yagl="yes"
1022   ;;
1023   --disable-yagl) yagl="no"
1024   ;;
1025   --enable-yagl-stats) yagl_stats="yes"
1026   ;;
1027   --disable-yagl-stats) yagl_stats="no"
1028   ;;
1029   --enable-opengl) opengl="yes"
1030   ;;
1031   --enable-vigs) vigs="yes"
1032   ;;
1033   --disable-vigs) vigs="no"
1034   ;;
1035   --disable-opengl) opengl="no"
1036   ;;
1037   --disable-vhost-scsi) vhost_scsi="no"
1038   ;;
1039   --enable-vhost-scsi) vhost_scsi="yes"
1040   ;;
1041   --disable-glx) glx="no"
1042   ;;
1043   --enable-glx) glx="yes"
1044   ;;
1045   --disable-rbd) rbd="no"
1046   ;;
1047   --enable-rbd) rbd="yes"
1048   ;;
1049   --disable-xfsctl) xfs="no"
1050   ;;
1051   --enable-xfsctl) xfs="yes"
1052   ;;
1053   --disable-smartcard-nss) smartcard_nss="no"
1054   ;;
1055   --enable-smartcard-nss) smartcard_nss="yes"
1056   ;;
1057   --disable-libusb) libusb="no"
1058   ;;
1059   --enable-libusb) libusb="yes"
1060   ;;
1061   --disable-usb-redir) usb_redir="no"
1062   ;;
1063   --enable-usb-redir) usb_redir="yes"
1064   ;;
1065   --disable-zlib-test) zlib="no"
1066   ;;
1067   --enable-lzo) lzo="yes"
1068   ;;
1069   --enable-snappy) snappy="yes"
1070   ;;
1071   --enable-guest-agent) guest_agent="yes"
1072   ;;
1073   --disable-guest-agent) guest_agent="no"
1074   ;;
1075   --with-vss-sdk) vss_win32_sdk=""
1076   ;;
1077   --with-vss-sdk=*) vss_win32_sdk="$optarg"
1078   ;;
1079   --without-vss-sdk) vss_win32_sdk="no"
1080   ;;
1081   --with-win-sdk) win_sdk=""
1082   ;;
1083   --with-win-sdk=*) win_sdk="$optarg"
1084   ;;
1085   --without-win-sdk) win_sdk="no"
1086   ;;
1087   --enable-tools) want_tools="yes"
1088   ;;
1089   --disable-tools) want_tools="no"
1090   ;;
1091   --enable-seccomp) seccomp="yes"
1092   ;;
1093   --disable-seccomp) seccomp="no"
1094   ;;
1095 # for TIZEN-maru
1096   --enable-maru) maru="yes"
1097   ;;
1098   --enable-shm) shm="yes"
1099   ;;
1100   --enable-libav) libav="yes"
1101   ;;
1102   --enable-png) png="yes"
1103   ;;
1104 #
1105   --disable-glusterfs) glusterfs="no"
1106   ;;
1107   --enable-glusterfs) glusterfs="yes"
1108   ;;
1109   --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
1110   ;;
1111   --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
1112   ;;
1113   --disable-gtk) gtk="no"
1114   ;;
1115   --enable-gtk) gtk="yes"
1116   ;;
1117   --enable-rdma) rdma="yes"
1118   ;;
1119   --disable-rdma) rdma="no"
1120   ;;
1121   --with-gtkabi=*) gtkabi="$optarg"
1122   ;;
1123   --disable-vte) vte="no"
1124   ;;
1125   --enable-vte) vte="yes"
1126   ;;
1127   --enable-tpm) tpm="yes"
1128   ;;
1129   --disable-libssh2) libssh2="no"
1130   ;;
1131   --enable-libssh2) libssh2="yes"
1132   ;;
1133   --enable-vhdx) vhdx="yes"
1134   ;;
1135   --disable-vhdx) vhdx="no"
1136   ;;
1137   --disable-quorum) quorum="no"
1138   ;;
1139   --enable-quorum) quorum="yes"
1140   ;;
1141   *) echo "ERROR: unknown option $opt"; show_help="yes"
1142   ;;
1143   esac
1144 done
1145
1146 if ! has $python; then
1147   error_exit "Python not found. Use --python=/path/to/python"
1148 fi
1149
1150 # Note that if the Python conditional here evaluates True we will exit
1151 # with status 1 which is a shell 'false' value.
1152 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1153   error_exit "Cannot use '$python', Python 2.4 or later is required." \
1154       "Note that Python 3 or later is not yet supported." \
1155       "Use --python=/path/to/python to specify a supported Python."
1156 fi
1157
1158 # The -B switch was added in Python 2.6.
1159 # If it is supplied, compiled files are not written.
1160 # Use it for Python versions which support it.
1161 if $python -B -c 'import sys; sys.exit(0)' 2>/dev/null; then
1162   python="$python -B"
1163 fi
1164
1165 case "$cpu" in
1166     ppc)
1167            CPU_CFLAGS="-m32"
1168            LDFLAGS="-m32 $LDFLAGS"
1169            ;;
1170     ppc64)
1171            CPU_CFLAGS="-m64"
1172            LDFLAGS="-m64 $LDFLAGS"
1173            ;;
1174     sparc)
1175            LDFLAGS="-m32 $LDFLAGS"
1176            CPU_CFLAGS="-m32 -mcpu=ultrasparc"
1177            ;;
1178     sparc64)
1179            LDFLAGS="-m64 $LDFLAGS"
1180            CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1181            ;;
1182     s390)
1183            CPU_CFLAGS="-m31 -march=z990"
1184            LDFLAGS="-m31 $LDFLAGS"
1185            ;;
1186     s390x)
1187            CPU_CFLAGS="-m64 -march=z990"
1188            LDFLAGS="-m64 $LDFLAGS"
1189            ;;
1190     i386)
1191            CPU_CFLAGS="-m32"
1192            LDFLAGS="-m32 $LDFLAGS"
1193            cc_i386='$(CC) -m32'
1194            ;;
1195     x86_64)
1196            CPU_CFLAGS="-m64"
1197            LDFLAGS="-m64 $LDFLAGS"
1198            cc_i386='$(CC) -m32'
1199            ;;
1200     x32)
1201            CPU_CFLAGS="-mx32"
1202            LDFLAGS="-mx32 $LDFLAGS"
1203            cc_i386='$(CC) -m32'
1204            ;;
1205     # No special flags required for other host CPUs
1206 esac
1207
1208 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1209 EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1210
1211 default_target_list=""
1212
1213 mak_wilds=""
1214
1215 if [ "$softmmu" = "yes" ]; then
1216     mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1217 fi
1218 if [ "$linux_user" = "yes" ]; then
1219     mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1220 fi
1221 if [ "$bsd_user" = "yes" ]; then
1222     mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1223 fi
1224
1225 for config in $mak_wilds; do
1226     default_target_list="${default_target_list} $(basename "$config" .mak)"
1227 done
1228
1229 if test x"$show_help" = x"yes" ; then
1230 cat << EOF
1231
1232 Usage: configure [options]
1233 Options: [defaults in brackets after descriptions]
1234
1235 Standard options:
1236   --help                   print this message
1237   --prefix=PREFIX          install in PREFIX [$prefix]
1238   --interp-prefix=PREFIX   where to find shared libraries, etc.
1239                            use %M for cpu name [$interp_prefix]
1240   --target-list=LIST       set target list (default: build everything)
1241 $(echo Available targets: $default_target_list | \
1242   fold -s -w 53 | sed -e 's/^/                           /')
1243
1244 Advanced options (experts only):
1245   --source-path=PATH       path of source code [$source_path]
1246   --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
1247   --cc=CC                  use C compiler CC [$cc]
1248   --iasl=IASL              use ACPI compiler IASL [$iasl]
1249   --host-cc=CC             use C compiler CC [$host_cc] for code run at
1250                            build time
1251   --cxx=CXX                use C++ compiler CXX [$cxx]
1252   --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
1253   --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
1254   --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1255   --make=MAKE              use specified make [$make]
1256   --install=INSTALL        use specified install [$install]
1257   --python=PYTHON          use specified python [$python]
1258   --smbd=SMBD              use specified smbd [$smbd]
1259   --static                 enable static build [$static]
1260   --mandir=PATH            install man pages in PATH
1261   --datadir=PATH           install firmware in PATH$confsuffix
1262   --docdir=PATH            install documentation in PATH$confsuffix
1263   --bindir=PATH            install binaries in PATH
1264   --libdir=PATH            install libraries in PATH
1265   --sysconfdir=PATH        install config in PATH$confsuffix
1266   --localstatedir=PATH     install local state in PATH (set at runtime on win32)
1267   --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1268   --enable-modules         enable modules support
1269   --enable-debug-tcg       enable TCG debugging
1270   --disable-debug-tcg      disable TCG debugging (default)
1271   --enable-debug-info       enable debugging information (default)
1272   --disable-debug-info      disable debugging information
1273   --enable-debug           enable common debug build options
1274   --enable-sparse          enable sparse checker
1275   --disable-sparse         disable sparse checker (default)
1276   --disable-strip          disable stripping binaries
1277   --disable-werror         disable compilation abort on warning
1278   --disable-stack-protector disable compiler-provided stack protection
1279   --disable-sdl            disable SDL
1280   --enable-sdl             enable SDL
1281   --with-sdlabi            select preferred SDL ABI 1.2 or 2.0
1282   --disable-gtk            disable gtk UI
1283   --enable-gtk             enable gtk UI
1284   --disable-virtfs         disable VirtFS
1285   --enable-virtfs          enable VirtFS
1286   --disable-vnc            disable VNC
1287   --enable-vnc             enable VNC
1288   --disable-cocoa          disable Cocoa (Mac OS X only)
1289   --enable-cocoa           enable Cocoa (default on Mac OS X)
1290   --audio-drv-list=LIST    set audio drivers list:
1291                            Available drivers: $audio_possible_drivers
1292   --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
1293   --block-drv-rw-whitelist=L
1294                            set block driver read-write whitelist
1295                            (affects only QEMU, not qemu-img)
1296   --block-drv-ro-whitelist=L
1297                            set block driver read-only whitelist
1298                            (affects only QEMU, not qemu-img)
1299   --disable-xen            disable xen backend driver support
1300   --enable-xen             enable xen backend driver support
1301   --disable-xen-pci-passthrough
1302   --enable-xen-pci-passthrough
1303   --disable-brlapi         disable BrlAPI
1304   --enable-brlapi          enable BrlAPI
1305   --disable-vnc-tls        disable TLS encryption for VNC server
1306   --enable-vnc-tls         enable TLS encryption for VNC server
1307   --disable-vnc-sasl       disable SASL encryption for VNC server
1308   --enable-vnc-sasl        enable SASL encryption for VNC server
1309   --disable-vnc-jpeg       disable JPEG lossy compression for VNC server
1310   --enable-vnc-jpeg        enable JPEG lossy compression for VNC server
1311   --disable-vnc-png        disable PNG compression for VNC server (default)
1312   --enable-vnc-png         enable PNG compression for VNC server
1313   --disable-vnc-ws         disable Websockets support for VNC server
1314   --enable-vnc-ws          enable Websockets support for VNC server
1315   --disable-curses         disable curses output
1316   --enable-curses          enable curses output
1317   --disable-curl           disable curl connectivity
1318   --enable-curl            enable curl connectivity
1319   --disable-fdt            disable fdt device tree
1320   --enable-fdt             enable fdt device tree
1321   --disable-bluez          disable bluez stack connectivity
1322   --enable-bluez           enable bluez stack connectivity
1323   --disable-slirp          disable SLIRP userspace network connectivity
1324   --disable-kvm            disable KVM acceleration support
1325   --enable-kvm             enable KVM acceleration support
1326   --disable-rdma           disable RDMA-based migration support
1327   --enable-rdma            enable RDMA-based migration support
1328   --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1329   --enable-system          enable all system emulation targets
1330   --disable-system         disable all system emulation targets
1331   --enable-user            enable supported user emulation targets
1332   --disable-user           disable all user emulation targets
1333   --enable-linux-user      enable all linux usermode emulation targets
1334   --disable-linux-user     disable all linux usermode emulation targets
1335   --enable-bsd-user        enable all BSD usermode emulation targets
1336   --disable-bsd-user       disable all BSD usermode emulation targets
1337   --enable-guest-base      enable GUEST_BASE support for usermode
1338                            emulation targets
1339   --disable-guest-base     disable GUEST_BASE support
1340   --enable-pie             build Position Independent Executables
1341   --disable-pie            do not build Position Independent Executables
1342   --fmod-lib               path to FMOD library
1343   --fmod-inc               path to FMOD includes
1344   --oss-lib                path to OSS library
1345   --enable-uname-release=R Return R for uname -r in usermode emulation
1346   --cpu=CPU                Build for host CPU [$cpu]
1347   --disable-uuid           disable uuid support
1348   --enable-uuid            enable uuid support
1349   --disable-vde            disable support for vde network
1350   --enable-vde             enable support for vde network
1351   --disable-netmap         disable support for netmap network
1352   --enable-netmap          enable support for netmap network
1353   --disable-linux-aio      disable Linux AIO support
1354   --enable-linux-aio       enable Linux AIO support
1355   --disable-cap-ng         disable libcap-ng support
1356   --enable-cap-ng          enable libcap-ng support
1357   --disable-attr           disables attr and xattr support
1358   --enable-attr            enable attr and xattr support
1359   --disable-blobs          disable installing provided firmware blobs
1360   --enable-docs            enable documentation build
1361   --disable-docs           disable documentation build
1362   --disable-vhost-net      disable vhost-net acceleration support
1363   --enable-vhost-net       enable vhost-net acceleration support
1364   --enable-trace-backend=B Set trace backend
1365                            Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
1366   --with-trace-file=NAME   Full PATH,NAME of file to store traces
1367                            Default:trace-<pid>
1368   --disable-spice          disable spice
1369   --enable-spice           enable spice
1370   --enable-rbd             enable building the rados block device (rbd)
1371   --disable-libiscsi       disable iscsi support
1372   --enable-libiscsi        enable iscsi support
1373   --disable-libnfs         disable nfs support
1374   --enable-libnfs          enable nfs support
1375   --disable-smartcard-nss  disable smartcard nss support
1376   --enable-smartcard-nss   enable smartcard nss support
1377   --disable-libusb         disable libusb (for usb passthrough)
1378   --enable-libusb          enable libusb (for usb passthrough)
1379   --disable-usb-redir      disable usb network redirection support
1380   --enable-usb-redir       enable usb network redirection support
1381   --enable-lzo             enable the support of lzo compression library
1382   --enable-snappy          enable the support of snappy compression library
1383   --disable-guest-agent    disable building of the QEMU Guest Agent
1384   --enable-guest-agent     enable building of the QEMU Guest Agent
1385   --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1386   --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1387   --disable-seccomp        disable seccomp support
1388   --enable-seccomp         enables seccomp support
1389   --with-coroutine=BACKEND coroutine backend. Supported options:
1390                            gthread, ucontext, sigaltstack, windows
1391   --disable-coroutine-pool disable coroutine freelist (worse performance)
1392   --enable-coroutine-pool  enable coroutine freelist (better performance)
1393   --enable-glusterfs       enable GlusterFS backend
1394   --disable-glusterfs      disable GlusterFS backend
1395   --enable-gcov            enable test coverage analysis with gcov
1396   --gcov=GCOV              use specified gcov [$gcov_tool]
1397   --enable-tpm             enable TPM support
1398   --disable-libssh2        disable ssh block device support
1399   --enable-libssh2         enable ssh block device support
1400   --disable-vhdx           disables support for the Microsoft VHDX image format
1401   --enable-vhdx            enable support for the Microsoft VHDX image format
1402   --disable-quorum         disable quorum block filter support
1403   --enable-quorum          enable quorum block filter support
1404
1405   --disable-hax            disable HAX acceleration support
1406   --enable-hax             enable HAX acceleration support
1407   --enable-yagl            enable YaGL device
1408   --disable-yagl           disable YaGL device
1409   --enable-yagl-stats      enable YaGL stats
1410   --disable-yagl-stats     disable YaGL stats
1411   --enable-vigs            enable VIGS device
1412   --disable-vigs           disable VIGS device
1413
1414 TIZEN-maru options:
1415   --enable-maru            enable maru board
1416   --enable-shm             enable shared memory for framebuffer
1417   --enable-libav           enable libav library
1418   --enable-png             enable png library
1419
1420 NOTE: The object files are built at the place where configure is launched
1421 EOF
1422 exit 1
1423 fi
1424
1425 # Now we have handled --enable-tcg-interpreter and know we're not just
1426 # printing the help message, bail out if the host CPU isn't supported.
1427 if test "$ARCH" = "unknown"; then
1428     if test "$tcg_interpreter" = "yes" ; then
1429         echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1430         ARCH=tci
1431     else
1432         error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1433     fi
1434 fi
1435
1436 # Consult white-list to determine whether to enable werror
1437 # by default.  Only enable by default for git builds
1438 z_version=`cut -f3 -d. $source_path/VERSION`
1439
1440 if test -z "$werror" ; then
1441     if test -d "$source_path/.git" -a \
1442         "$linux" = "yes" ; then
1443         werror="yes"
1444     else
1445         werror="no"
1446     fi
1447 fi
1448
1449 # check that the C compiler works.
1450 cat > $TMPC <<EOF
1451 int main(void) { return 0; }
1452 EOF
1453
1454 if compile_object ; then
1455   : C compiler works ok
1456 else
1457     error_exit "\"$cc\" either does not exist or does not work"
1458 fi
1459
1460 # Check that the C++ compiler exists and works with the C compiler
1461 if has $cxx; then
1462     cat > $TMPC <<EOF
1463 int c_function(void);
1464 int main(void) { return c_function(); }
1465 EOF
1466
1467     compile_object
1468
1469     cat > $TMPCXX <<EOF
1470 extern "C" {
1471    int c_function(void);
1472 }
1473 int c_function(void) { return 42; }
1474 EOF
1475
1476     update_cxxflags
1477
1478     if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
1479         # C++ compiler $cxx works ok with C compiler $cc
1480         :
1481     else
1482         echo "C++ compiler $cxx does not work with C compiler $cc"
1483         echo "Disabling C++ specific optional code"
1484         cxx=
1485     fi
1486 else
1487     echo "No C++ compiler available; disabling C++ specific optional code"
1488     cxx=
1489 fi
1490
1491 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1492 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1493 gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1494 gcc_flags="-Wendif-labels $gcc_flags"
1495 gcc_flags="-Wno-initializer-overrides $gcc_flags"
1496 gcc_flags="-Wno-string-plus-int $gcc_flags"
1497 # Note that we do not add -Werror to gcc_flags here, because that would
1498 # enable it for all configure tests. If a configure test failed due
1499 # to -Werror this would just silently disable some features,
1500 # so it's too error prone.
1501 cat > $TMPC << EOF
1502 int main(void) { return 0; }
1503 EOF
1504 for flag in $gcc_flags; do
1505     # Use the positive sense of the flag when testing for -Wno-wombat
1506     # support (gcc will happily accept the -Wno- form of unknown
1507     # warning options).
1508     optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1509     if compile_prog "-Werror $optflag" "" ; then
1510         QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1511     fi
1512 done
1513
1514 if test "$stack_protector" != "no" ; then
1515   gcc_flags="-fstack-protector-strong -fstack-protector-all"
1516   for flag in $gcc_flags; do
1517     # We need to check both a compile and a link, since some compiler
1518     # setups fail only on a .c->.o compile and some only at link time
1519     if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1520        compile_prog "-Werror $flag" ""; then
1521       QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1522       LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
1523       break
1524     fi
1525   done
1526 fi
1527
1528 # Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1529 # large functions that use global variables.  The bug is in all releases of
1530 # GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1531 # 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1532 cat > $TMPC << EOF
1533 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1534 int main(void) { return 0; }
1535 #else
1536 #error No bug in this compiler.
1537 #endif
1538 EOF
1539 if compile_prog "-Werror -fno-gcse" "" ; then
1540   TRANSLATE_OPT_CFLAGS=-fno-gcse
1541 fi
1542
1543 if test "$static" = "yes" ; then
1544   if test "$modules" = "yes" ; then
1545     error_exit "static and modules are mutually incompatible"
1546   fi
1547   if test "$pie" = "yes" ; then
1548     error_exit "static and pie are mutually incompatible"
1549   else
1550     pie="no"
1551   fi
1552 fi
1553
1554 if test "$pie" = ""; then
1555   case "$cpu-$targetos" in
1556     i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
1557       ;;
1558     *)
1559       pie="no"
1560       ;;
1561   esac
1562 fi
1563
1564 if test "$pie" != "no" ; then
1565   cat > $TMPC << EOF
1566
1567 #ifdef __linux__
1568 #  define THREAD __thread
1569 #else
1570 #  define THREAD
1571 #endif
1572
1573 static THREAD int tls_var;
1574
1575 int main(void) { return tls_var; }
1576
1577 EOF
1578   if compile_prog "-fPIE -DPIE" "-pie"; then
1579     QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1580     LDFLAGS="-pie $LDFLAGS"
1581     pie="yes"
1582     if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1583       LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1584     fi
1585   else
1586     if test "$pie" = "yes"; then
1587       error_exit "PIE not available due to missing toolchain support"
1588     else
1589       echo "Disabling PIE due to missing toolchain support"
1590       pie="no"
1591     fi
1592   fi
1593
1594   if compile_prog "-fno-pie" "-nopie"; then
1595     CFLAGS_NOPIE="-fno-pie"
1596     LDFLAGS_NOPIE="-nopie"
1597   fi
1598 fi
1599
1600 # check for broken gcc and libtool in RHEL5
1601 if test -n "$libtool" -a "$pie" != "no" ; then
1602   cat > $TMPC <<EOF
1603
1604 void *f(unsigned char *buf, int len);
1605 void *g(unsigned char *buf, int len);
1606
1607 void *
1608 f(unsigned char *buf, int len)
1609 {
1610     return (void*)0L;
1611 }
1612
1613 void *
1614 g(unsigned char *buf, int len)
1615 {
1616     return f(buf, len);
1617 }
1618
1619 EOF
1620   if ! libtool_prog; then
1621     echo "Disabling libtool due to broken toolchain support"
1622     libtool=
1623   fi
1624 fi
1625
1626 ##########################################
1627 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1628 # use i686 as default anyway, but for those that don't, an explicit
1629 # specification is necessary
1630
1631 if test "$cpu" = "i386"; then
1632   cat > $TMPC << EOF
1633 static int sfaa(int *ptr)
1634 {
1635   return __sync_fetch_and_and(ptr, 0);
1636 }
1637
1638 int main(void)
1639 {
1640   int val = 42;
1641   val = __sync_val_compare_and_swap(&val, 0, 1);
1642   sfaa(&val);
1643   return val;
1644 }
1645 EOF
1646   if ! compile_prog "" "" ; then
1647     QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1648   fi
1649 fi
1650
1651 #########################################
1652 # Solaris specific configure tool chain decisions
1653
1654 if test "$solaris" = "yes" ; then
1655   if has $install; then
1656     :
1657   else
1658     error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1659         "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1660         "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1661   fi
1662   if test "`path_of $install`" = "/usr/sbin/install" ; then
1663     error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1664         "try ginstall from the GNU fileutils available from www.blastwave.org" \
1665         "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1666   fi
1667   if has ar; then
1668     :
1669   else
1670     if test -f /usr/ccs/bin/ar ; then
1671       error_exit "No path includes ar" \
1672           "Add /usr/ccs/bin to your path and rerun configure"
1673     fi
1674     error_exit "No path includes ar"
1675   fi
1676 fi
1677
1678 if test -z "${target_list+xxx}" ; then
1679     target_list="$default_target_list"
1680 else
1681     target_list=`echo "$target_list" | sed -e 's/,/ /g'`
1682 fi
1683
1684 # Check that we recognised the target name; this allows a more
1685 # friendly error message than if we let it fall through.
1686 for target in $target_list; do
1687     case " $default_target_list " in
1688         *" $target "*)
1689             ;;
1690         *)
1691             error_exit "Unknown target name '$target'"
1692             ;;
1693     esac
1694 done
1695
1696 # see if system emulation was really requested
1697 case " $target_list " in
1698   *"-softmmu "*) softmmu=yes
1699   ;;
1700   *) softmmu=no
1701   ;;
1702 esac
1703
1704 feature_not_found() {
1705   feature=$1
1706   remedy=$2
1707
1708   error_exit "User requested feature $feature" \
1709       "configure was not able to find it." \
1710       "$remedy"
1711 }
1712
1713 # ---
1714 # big/little endian test
1715 cat > $TMPC << EOF
1716 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1717 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1718 extern int foo(short *, short *);
1719 int main(int argc, char *argv[]) {
1720     return foo(big_endian, little_endian);
1721 }
1722 EOF
1723
1724 if compile_object ; then
1725     if grep -q BiGeNdIaN $TMPO ; then
1726         bigendian="yes"
1727     elif grep -q LiTtLeEnDiAn $TMPO ; then
1728         bigendian="no"
1729     else
1730         echo big/little test failed
1731     fi
1732 else
1733     echo big/little test failed
1734 fi
1735
1736 ##########################################
1737 # pkg-config probe
1738
1739 if ! has "$pkg_config_exe"; then
1740   error_exit "pkg-config binary '$pkg_config_exe' not found"
1741 fi
1742
1743 ##########################################
1744 # NPTL probe
1745
1746 if test "$linux_user" = "yes"; then
1747   cat > $TMPC <<EOF
1748 #include <sched.h>
1749 #include <linux/futex.h>
1750 int main(void) {
1751 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1752 #error bork
1753 #endif
1754   return 0;
1755 }
1756 EOF
1757   if ! compile_object ; then
1758     feature_not_found "nptl" "Install glibc and linux kernel headers."
1759   fi
1760 fi
1761
1762 ##########################################
1763 # zlib check
1764
1765 if test "$zlib" != "no" ; then
1766     cat > $TMPC << EOF
1767 #include <zlib.h>
1768 int main(void) { zlibVersion(); return 0; }
1769 EOF
1770     if compile_prog "" "-lz" ; then
1771         :
1772     else
1773         error_exit "zlib check failed" \
1774             "Make sure to have the zlib libs and headers installed."
1775     fi
1776 fi
1777 LIBS="$LIBS -lz"
1778
1779 ##########################################
1780 # lzo check
1781
1782 if test "$lzo" != "no" ; then
1783     cat > $TMPC << EOF
1784 #include <lzo/lzo1x.h>
1785 int main(void) { lzo_version(); return 0; }
1786 EOF
1787     if compile_prog "" "-llzo2" ; then
1788         :
1789     else
1790         error_exit "lzo check failed" \
1791             "Make sure to have the lzo libs and headers installed."
1792     fi
1793
1794     libs_softmmu="$libs_softmmu -llzo2"
1795 fi
1796
1797 ##########################################
1798 # snappy check
1799
1800 if test "$snappy" != "no" ; then
1801     cat > $TMPC << EOF
1802 #include <snappy-c.h>
1803 int main(void) { snappy_max_compressed_length(4096); return 0; }
1804 EOF
1805     if compile_prog "" "-lsnappy" ; then
1806         :
1807     else
1808         error_exit "snappy check failed" \
1809             "Make sure to have the snappy libs and headers installed."
1810     fi
1811
1812     libs_softmmu="$libs_softmmu -lsnappy"
1813 fi
1814
1815 ##########################################
1816 # libseccomp check
1817
1818 if test "$seccomp" != "no" ; then
1819     if $pkg_config --atleast-version=2.1.0 libseccomp; then
1820         libs_softmmu="$libs_softmmu `$pkg_config --libs libseccomp`"
1821         QEMU_CFLAGS="$QEMU_CFLAGS `$pkg_config --cflags libseccomp`"
1822         seccomp="yes"
1823     else
1824         if test "$seccomp" = "yes"; then
1825             feature_not_found "libseccomp" "Install libseccomp devel >= 2.1.0"
1826         fi
1827         seccomp="no"
1828     fi
1829 fi
1830 ##########################################
1831 # xen probe
1832
1833 if test "$xen" != "no" ; then
1834   xen_libs="-lxenstore -lxenctrl -lxenguest"
1835
1836   # First we test whether Xen headers and libraries are available.
1837   # If no, we are done and there is no Xen support.
1838   # If yes, more tests are run to detect the Xen version.
1839
1840   # Xen (any)
1841   cat > $TMPC <<EOF
1842 #include <xenctrl.h>
1843 int main(void) {
1844   return 0;
1845 }
1846 EOF
1847   if ! compile_prog "" "$xen_libs" ; then
1848     # Xen not found
1849     if test "$xen" = "yes" ; then
1850       feature_not_found "xen" "Install xen devel"
1851     fi
1852     xen=no
1853
1854   # Xen unstable
1855   elif
1856       cat > $TMPC <<EOF &&
1857 #include <xenctrl.h>
1858 #include <xenstore.h>
1859 #include <stdint.h>
1860 #include <xen/hvm/hvm_info_table.h>
1861 #if !defined(HVM_MAX_VCPUS)
1862 # error HVM_MAX_VCPUS not defined
1863 #endif
1864 int main(void) {
1865   xc_interface *xc;
1866   xs_daemon_open();
1867   xc = xc_interface_open(0, 0, 0);
1868   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1869   xc_gnttab_open(NULL, 0);
1870   xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1871   xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1872   return 0;
1873 }
1874 EOF
1875       compile_prog "" "$xen_libs"
1876     then
1877     xen_ctrl_version=420
1878     xen=yes
1879
1880   elif
1881       cat > $TMPC <<EOF &&
1882 #include <xenctrl.h>
1883 #include <xs.h>
1884 #include <stdint.h>
1885 #include <xen/hvm/hvm_info_table.h>
1886 #if !defined(HVM_MAX_VCPUS)
1887 # error HVM_MAX_VCPUS not defined
1888 #endif
1889 int main(void) {
1890   xs_daemon_open();
1891   xc_interface_open(0, 0, 0);
1892   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1893   xc_gnttab_open(NULL, 0);
1894   xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1895   return 0;
1896 }
1897 EOF
1898       compile_prog "" "$xen_libs"
1899     then
1900     xen_ctrl_version=410
1901     xen=yes
1902
1903   # Xen 4.0.0
1904   elif
1905       cat > $TMPC <<EOF &&
1906 #include <xenctrl.h>
1907 #include <xs.h>
1908 #include <stdint.h>
1909 #include <xen/hvm/hvm_info_table.h>
1910 #if !defined(HVM_MAX_VCPUS)
1911 # error HVM_MAX_VCPUS not defined
1912 #endif
1913 int main(void) {
1914   struct xen_add_to_physmap xatp = {
1915     .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1916   };
1917   xs_daemon_open();
1918   xc_interface_open();
1919   xc_gnttab_open();
1920   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1921   xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1922   return 0;
1923 }
1924 EOF
1925       compile_prog "" "$xen_libs"
1926     then
1927     xen_ctrl_version=400
1928     xen=yes
1929
1930   # Xen 3.4.0
1931   elif
1932       cat > $TMPC <<EOF &&
1933 #include <xenctrl.h>
1934 #include <xs.h>
1935 int main(void) {
1936   struct xen_add_to_physmap xatp = {
1937     .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1938   };
1939   xs_daemon_open();
1940   xc_interface_open();
1941   xc_gnttab_open();
1942   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1943   xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1944   return 0;
1945 }
1946 EOF
1947       compile_prog "" "$xen_libs"
1948     then
1949     xen_ctrl_version=340
1950     xen=yes
1951
1952   # Xen 3.3.0
1953   elif
1954       cat > $TMPC <<EOF &&
1955 #include <xenctrl.h>
1956 #include <xs.h>
1957 int main(void) {
1958   xs_daemon_open();
1959   xc_interface_open();
1960   xc_gnttab_open();
1961   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1962   return 0;
1963 }
1964 EOF
1965       compile_prog "" "$xen_libs"
1966     then
1967     xen_ctrl_version=330
1968     xen=yes
1969
1970   # Xen version unsupported
1971   else
1972     if test "$xen" = "yes" ; then
1973       feature_not_found "xen (unsupported version)" "Install supported xen (e.g. 4.0, 3.4, 3.3)"
1974     fi
1975     xen=no
1976   fi
1977
1978   if test "$xen" = yes; then
1979     libs_softmmu="$xen_libs $libs_softmmu"
1980   fi
1981 fi
1982
1983 if test "$xen_pci_passthrough" != "no"; then
1984   if test "$xen" = "yes" && test "$linux" = "yes" &&
1985     test "$xen_ctrl_version" -ge 340; then
1986     xen_pci_passthrough=yes
1987   else
1988     if test "$xen_pci_passthrough" = "yes"; then
1989       if test "$xen_ctrl_version" -lt 340; then
1990         error_exit "User requested feature Xen PCI Passthrough" \
1991             "This feature does not work with Xen 3.3"
1992       fi
1993       error_exit "User requested feature Xen PCI Passthrough" \
1994           " but this feature requires /sys from Linux"
1995     fi
1996     xen_pci_passthrough=no
1997   fi
1998 fi
1999
2000 ##########################################
2001 # libtool probe
2002
2003 if ! has $libtool; then
2004     libtool=
2005 fi
2006
2007 # MacOSX ships with a libtool which isn't the GNU one; weed this
2008 # out by checking whether libtool supports the --version switch
2009 if test -n "$libtool"; then
2010   if ! "$libtool" --version >/dev/null 2>&1; then
2011     libtool=
2012   fi
2013 fi
2014
2015 ##########################################
2016 # Sparse probe
2017 if test "$sparse" != "no" ; then
2018   if has cgcc; then
2019     sparse=yes
2020   else
2021     if test "$sparse" = "yes" ; then
2022       feature_not_found "sparse" "Install sparse binary"
2023     fi
2024     sparse=no
2025   fi
2026 fi
2027
2028 ##########################################
2029 # GTK probe
2030
2031 if test "$gtk" != "no"; then
2032     gtkpackage="gtk+-$gtkabi"
2033     if test "$gtkabi" = "3.0" ; then
2034       gtkversion="3.0.0"
2035     else
2036       gtkversion="2.18.0"
2037     fi
2038     if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2039         gtk_cflags=`$pkg_config --cflags $gtkpackage`
2040         gtk_libs=`$pkg_config --libs $gtkpackage`
2041         libs_softmmu="$gtk_libs $libs_softmmu"
2042         gtk="yes"
2043     elif test "$gtk" = "yes"; then
2044         feature_not_found "gtk" "Install gtk2 or gtk3 (requires --with-gtkabi=3.0 option to configure) devel"
2045     else
2046         gtk="no"
2047     fi
2048 fi
2049
2050 ##########################################
2051 # VTE probe
2052
2053 if test "$vte" != "no"; then
2054     if test "$gtkabi" = "3.0"; then
2055       vtepackage="vte-2.90"
2056       vteversion="0.32.0"
2057     else
2058       vtepackage="vte"
2059       vteversion="0.24.0"
2060     fi
2061     if $pkg_config --exists "$vtepackage >= $vteversion"; then
2062         vte_cflags=`$pkg_config --cflags $vtepackage`
2063         vte_libs=`$pkg_config --libs $vtepackage`
2064         libs_softmmu="$vte_libs $libs_softmmu"
2065         vte="yes"
2066     elif test "$vte" = "yes"; then
2067         feature_not_found "vte" "Install libvte or libvte-2.90 (requires --with-gtkabi=3.0 option to configure) devel"
2068     else
2069         vte="no"
2070     fi
2071 fi
2072
2073 ##########################################
2074 # SDL probe
2075
2076 # Look for sdl configuration program (pkg-config or sdl-config).  Try
2077 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2078
2079 if test $sdlabi = "2.0"; then
2080     sdl_config=$sdl2_config
2081     sdlname=sdl2
2082     sdlconfigname=sdl2_config
2083 else
2084     sdlname=sdl
2085     sdlconfigname=sdl_config
2086 fi
2087
2088 if test "`basename $sdl_config`" != $sdlconfigname && ! has ${sdl_config}; then
2089   sdl_config=$sdlconfigname
2090 fi
2091
2092 if $pkg_config $sdlname --exists; then
2093   sdlconfig="$pkg_config $sdlname"
2094   _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
2095 elif has ${sdl_config}; then
2096   sdlconfig="$sdl_config"
2097   _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
2098 else
2099   if test "$sdl" = "yes" ; then
2100     feature_not_found "sdl" "Install SDL devel"
2101   fi
2102   sdl=no
2103 fi
2104 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2105   echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2106 fi
2107
2108 sdl_too_old=no
2109 if test "$sdl" != "no" ; then
2110   cat > $TMPC << EOF
2111 #include <SDL.h>
2112 #undef main /* We don't want SDL to override our main() */
2113 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2114 EOF
2115   sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
2116   if test "$static" = "yes" ; then
2117     sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
2118   else
2119     sdl_libs=`$sdlconfig --libs 2> /dev/null`
2120   fi
2121   if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2122     if test "$_sdlversion" -lt 121 ; then
2123       sdl_too_old=yes
2124     else
2125       if test "$cocoa" = "no" ; then
2126         sdl=yes
2127       fi
2128     fi
2129
2130     # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2131     if test "$sdl" = "yes" -a "$static" = "yes" ; then
2132       if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2133          sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
2134          sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
2135       fi
2136       if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2137         :
2138       else
2139         sdl=no
2140       fi
2141     fi # static link
2142   else # sdl not found
2143     if test "$sdl" = "yes" ; then
2144       feature_not_found "sdl" "Install SDL devel"
2145     fi
2146     sdl=no
2147   fi # sdl compile test
2148 fi
2149
2150 if test "$sdl" = "yes" ; then
2151   cat > $TMPC <<EOF
2152 #include <SDL.h>
2153 #if defined(SDL_VIDEO_DRIVER_X11)
2154 #include <X11/XKBlib.h>
2155 #else
2156 #error No x11 support
2157 #endif
2158 int main(void) { return 0; }
2159 EOF
2160   if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2161     sdl_libs="$sdl_libs -lX11"
2162   fi
2163   libs_softmmu="$sdl_libs $libs_softmmu"
2164 fi
2165
2166 ##########################################
2167 # RDMA needs OpenFabrics libraries
2168 if test "$rdma" != "no" ; then
2169   cat > $TMPC <<EOF
2170 #include <rdma/rdma_cma.h>
2171 int main(void) { return 0; }
2172 EOF
2173   rdma_libs="-lrdmacm -libverbs"
2174   if compile_prog "" "$rdma_libs" ; then
2175     rdma="yes"
2176     libs_softmmu="$libs_softmmu $rdma_libs"
2177   else
2178     if test "$rdma" = "yes" ; then
2179         error_exit \
2180             " OpenFabrics librdmacm/libibverbs not present." \
2181             " Your options:" \
2182             "  (1) Fast: Install infiniband packages from your distro." \
2183             "  (2) Cleanest: Install libraries from www.openfabrics.org" \
2184             "  (3) Also: Install softiwarp if you don't have RDMA hardware"
2185     fi
2186     rdma="no"
2187   fi
2188 fi
2189
2190 ##########################################
2191 # VNC TLS/WS detection
2192 if test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then
2193   cat > $TMPC <<EOF
2194 #include <gnutls/gnutls.h>
2195 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
2196 EOF
2197   vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
2198   vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
2199   if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
2200     if test "$vnc_tls" != "no" ; then
2201       vnc_tls=yes
2202     fi
2203     if test "$vnc_ws" != "no" ; then
2204       vnc_ws=yes
2205     fi
2206     libs_softmmu="$vnc_tls_libs $libs_softmmu"
2207     QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
2208   else
2209     if test "$vnc_tls" = "yes" ; then
2210       feature_not_found "vnc-tls" "Install gnutls devel"
2211     fi
2212     if test "$vnc_ws" = "yes" ; then
2213       feature_not_found "vnc-ws" "Install gnutls devel"
2214     fi
2215     vnc_tls=no
2216     vnc_ws=no
2217   fi
2218 fi
2219
2220 ##########################################
2221 # Quorum probe (check for gnutls)
2222 if test "$quorum" != "no" ; then
2223 cat > $TMPC <<EOF
2224 #include <gnutls/gnutls.h>
2225 #include <gnutls/crypto.h>
2226 int main(void) {char data[4096], digest[32];
2227 gnutls_hash_fast(GNUTLS_DIG_SHA256, data, 4096, digest);
2228 return 0;
2229 }
2230 EOF
2231 quorum_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
2232 quorum_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
2233 if compile_prog "$quorum_tls_cflags" "$quorum_tls_libs" ; then
2234   qcow_tls=yes
2235   libs_softmmu="$quorum_tls_libs $libs_softmmu"
2236   libs_tools="$quorum_tls_libs $libs_softmmu"
2237   QEMU_CFLAGS="$QEMU_CFLAGS $quorum_tls_cflags"
2238 else
2239   echo "gnutls > 2.10.0 required to compile Quorum"
2240   exit 1
2241 fi
2242 fi
2243
2244 ##########################################
2245 # VNC SASL detection
2246 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
2247   cat > $TMPC <<EOF
2248 #include <sasl/sasl.h>
2249 #include <stdio.h>
2250 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2251 EOF
2252   # Assuming Cyrus-SASL installed in /usr prefix
2253   vnc_sasl_cflags=""
2254   vnc_sasl_libs="-lsasl2"
2255   if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2256     vnc_sasl=yes
2257     libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2258     QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
2259   else
2260     if test "$vnc_sasl" = "yes" ; then
2261       feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2262     fi
2263     vnc_sasl=no
2264   fi
2265 fi
2266
2267 ##########################################
2268 # VNC JPEG detection
2269 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2270 cat > $TMPC <<EOF
2271 #include <stdio.h>
2272 #include <jpeglib.h>
2273 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2274 EOF
2275     vnc_jpeg_cflags=""
2276     vnc_jpeg_libs="-ljpeg"
2277   if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2278     vnc_jpeg=yes
2279     libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2280     QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2281   else
2282     if test "$vnc_jpeg" = "yes" ; then
2283       feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2284     fi
2285     vnc_jpeg=no
2286   fi
2287 fi
2288
2289 ##########################################
2290 # VNC PNG detection
2291 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2292 cat > $TMPC <<EOF
2293 //#include <stdio.h>
2294 #include <png.h>
2295 #include <stddef.h>
2296 int main(void) {
2297     png_structp png_ptr;
2298     png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
2299     return png_ptr != 0;
2300 }
2301 EOF
2302   if $pkg_config libpng --exists; then
2303     vnc_png_cflags=`$pkg_config libpng --cflags`
2304     vnc_png_libs=`$pkg_config libpng --libs`
2305   else
2306     vnc_png_cflags=""
2307     vnc_png_libs="-lpng"
2308   fi
2309   if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2310     vnc_png=yes
2311     libs_softmmu="$vnc_png_libs $libs_softmmu"
2312     QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2313   else
2314     if test "$vnc_png" = "yes" ; then
2315       feature_not_found "vnc-png" "Install libpng devel"
2316     fi
2317     vnc_png=no
2318   fi
2319 fi
2320
2321 ##########################################
2322 # fnmatch() probe, used for ACL routines
2323 fnmatch="no"
2324 cat > $TMPC << EOF
2325 #include <fnmatch.h>
2326 int main(void)
2327 {
2328     fnmatch("foo", "foo", 0);
2329     return 0;
2330 }
2331 EOF
2332 if compile_prog "" "" ; then
2333    fnmatch="yes"
2334 fi
2335
2336 ##########################################
2337 # uuid_generate() probe, used for vdi block driver
2338 # Note that on some systems (notably MacOSX) no extra library
2339 # need be linked to get the uuid functions.
2340 if test "$uuid" != "no" ; then
2341   uuid_libs="-luuid"
2342   cat > $TMPC << EOF
2343 #include <uuid/uuid.h>
2344 int main(void)
2345 {
2346     uuid_t my_uuid;
2347     uuid_generate(my_uuid);
2348     return 0;
2349 }
2350 EOF
2351   if compile_prog "" "" ; then
2352     uuid="yes"
2353   elif compile_prog "" "$uuid_libs" ; then
2354     uuid="yes"
2355     libs_softmmu="$uuid_libs $libs_softmmu"
2356     libs_tools="$uuid_libs $libs_tools"
2357   else
2358     if test "$uuid" = "yes" ; then
2359       feature_not_found "uuid" "Install libuuid devel"
2360     fi
2361     uuid=no
2362   fi
2363 fi
2364
2365 if test "$vhdx" = "yes" ; then
2366     if test "$uuid" = "no" ; then
2367         error_exit "uuid required for VHDX support"
2368     fi
2369 elif test "$vhdx" != "no" ; then
2370     if test "$uuid" = "yes" ; then
2371         vhdx=yes
2372     else
2373         vhdx=no
2374     fi
2375 fi
2376
2377 ##########################################
2378 # xfsctl() probe, used for raw-posix
2379 if test "$xfs" != "no" ; then
2380   cat > $TMPC << EOF
2381 #include <stddef.h>  /* NULL */
2382 #include <xfs/xfs.h>
2383 int main(void)
2384 {
2385     xfsctl(NULL, 0, 0, NULL);
2386     return 0;
2387 }
2388 EOF
2389   if compile_prog "" "" ; then
2390     xfs="yes"
2391   else
2392     if test "$xfs" = "yes" ; then
2393       feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2394     fi
2395     xfs=no
2396   fi
2397 fi
2398
2399 ##########################################
2400 # vde libraries probe
2401 if test "$vde" != "no" ; then
2402   vde_libs="-lvdeplug"
2403   cat > $TMPC << EOF
2404 #include <libvdeplug.h>
2405 int main(void)
2406 {
2407     struct vde_open_args a = {0, 0, 0};
2408     char s[] = "";
2409     vde_open(s, s, &a);
2410     return 0;
2411 }
2412 EOF
2413   if compile_prog "" "$vde_libs" ; then
2414     vde=yes
2415     libs_softmmu="$vde_libs $libs_softmmu"
2416     libs_tools="$vde_libs $libs_tools"
2417   else
2418     if test "$vde" = "yes" ; then
2419       feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2420     fi
2421     vde=no
2422   fi
2423 fi
2424
2425 ##########################################
2426 # netmap support probe
2427 # Apart from looking for netmap headers, we make sure that the host API version
2428 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
2429 # a minor/major version number. Minor new features will be marked with values up
2430 # to 15, and if something happens that requires a change to the backend we will
2431 # move above 15, submit the backend fixes and modify this two bounds.
2432 if test "$netmap" != "no" ; then
2433   cat > $TMPC << EOF
2434 #include <inttypes.h>
2435 #include <net/if.h>
2436 #include <net/netmap.h>
2437 #include <net/netmap_user.h>
2438 #if (NETMAP_API < 11) || (NETMAP_API > 15)
2439 #error
2440 #endif
2441 int main(void) { return 0; }
2442 EOF
2443   if compile_prog "" "" ; then
2444     netmap=yes
2445   else
2446     if test "$netmap" = "yes" ; then
2447       feature_not_found "netmap"
2448     fi
2449     netmap=no
2450   fi
2451 fi
2452
2453 ##########################################
2454 # libcap-ng library probe
2455 if test "$cap_ng" != "no" ; then
2456   cap_libs="-lcap-ng"
2457   cat > $TMPC << EOF
2458 #include <cap-ng.h>
2459 int main(void)
2460 {
2461     capng_capability_to_name(CAPNG_EFFECTIVE);
2462     return 0;
2463 }
2464 EOF
2465   if compile_prog "" "$cap_libs" ; then
2466     cap_ng=yes
2467     libs_tools="$cap_libs $libs_tools"
2468   else
2469     if test "$cap_ng" = "yes" ; then
2470       feature_not_found "cap_ng" "Install libcap-ng devel"
2471     fi
2472     cap_ng=no
2473   fi
2474 fi
2475
2476 ##########################################
2477 # Sound support libraries probe
2478
2479 audio_drv_probe()
2480 {
2481     drv=$1
2482     hdr=$2
2483     lib=$3
2484     exp=$4
2485     cfl=$5
2486         cat > $TMPC << EOF
2487 #include <$hdr>
2488 int main(void) { $exp }
2489 EOF
2490     if compile_prog "$cfl" "$lib" ; then
2491         :
2492     else
2493         error_exit "$drv check failed" \
2494             "Make sure to have the $drv libs and headers installed."
2495     fi
2496 }
2497
2498 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
2499 for drv in $audio_drv_list; do
2500     case $drv in
2501     alsa)
2502     audio_drv_probe $drv alsa/asoundlib.h -lasound \
2503         "return snd_pcm_close((snd_pcm_t *)0);"
2504     libs_softmmu="-lasound $libs_softmmu"
2505     ;;
2506
2507     fmod)
2508     if test -z $fmod_lib || test -z $fmod_inc; then
2509         error_exit "You must specify path to FMOD library and headers" \
2510             "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
2511     fi
2512     audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
2513     libs_softmmu="$fmod_lib $libs_softmmu"
2514     ;;
2515
2516     esd)
2517     audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
2518     libs_softmmu="-lesd $libs_softmmu"
2519     audio_pt_int="yes"
2520     ;;
2521
2522     pa)
2523     audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
2524         "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
2525     libs_softmmu="-lpulse $libs_softmmu"
2526     audio_pt_int="yes"
2527     ;;
2528
2529     coreaudio)
2530       libs_softmmu="-framework CoreAudio $libs_softmmu"
2531     ;;
2532
2533     dsound)
2534       libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2535       audio_win_int="yes"
2536     ;;
2537
2538     oss)
2539       libs_softmmu="$oss_lib $libs_softmmu"
2540     ;;
2541
2542     sdl|wav)
2543     # XXX: Probes for CoreAudio, DirectSound, SDL(?)
2544     ;;
2545
2546     winwave)
2547       libs_softmmu="-lwinmm $libs_softmmu"
2548       audio_win_int="yes"
2549     ;;
2550
2551     *)
2552     echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
2553         error_exit "Unknown driver '$drv' selected" \
2554             "Possible drivers are: $audio_possible_drivers"
2555     }
2556     ;;
2557     esac
2558 done
2559
2560 ##########################################
2561 # BrlAPI probe
2562
2563 if test "$brlapi" != "no" ; then
2564   brlapi_libs="-lbrlapi"
2565   cat > $TMPC << EOF
2566 #include <brlapi.h>
2567 #include <stddef.h>
2568 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
2569 EOF
2570   if compile_prog "" "$brlapi_libs" ; then
2571     brlapi=yes
2572     libs_softmmu="$brlapi_libs $libs_softmmu"
2573   else
2574     if test "$brlapi" = "yes" ; then
2575       feature_not_found "brlapi" "Install brlapi devel"
2576     fi
2577     brlapi=no
2578   fi
2579 fi
2580
2581 ##########################################
2582 # curses probe
2583 if test "$curses" != "no" ; then
2584   if test "$mingw32" = "yes" ; then
2585     curses_list="-lpdcurses"
2586   else
2587     curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
2588   fi
2589   curses_found=no
2590   cat > $TMPC << EOF
2591 #include <curses.h>
2592 int main(void) {
2593   const char *s = curses_version();
2594   resize_term(0, 0);
2595   return s != 0;
2596 }
2597 EOF
2598   IFS=:
2599   for curses_lib in $curses_list; do
2600     unset IFS
2601     if compile_prog "" "$curses_lib" ; then
2602       curses_found=yes
2603       libs_softmmu="$curses_lib $libs_softmmu"
2604       break
2605     fi
2606   done
2607   unset IFS
2608   if test "$curses_found" = "yes" ; then
2609     curses=yes
2610   else
2611     if test "$curses" = "yes" ; then
2612       feature_not_found "curses" "Install ncurses devel"
2613     fi
2614     curses=no
2615   fi
2616 fi
2617
2618 ##########################################
2619 # curl probe
2620 if test "$curl" != "no" ; then
2621   if $pkg_config libcurl --exists; then
2622     curlconfig="$pkg_config libcurl"
2623   else
2624     curlconfig=curl-config
2625   fi
2626   cat > $TMPC << EOF
2627 #include <curl/curl.h>
2628 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2629 EOF
2630   curl_cflags=`$curlconfig --cflags 2>/dev/null`
2631   curl_libs=`$curlconfig --libs 2>/dev/null`
2632   if compile_prog "$curl_cflags" "$curl_libs" ; then
2633     curl=yes
2634   else
2635     if test "$curl" = "yes" ; then
2636       feature_not_found "curl" "Install libcurl devel"
2637     fi
2638     curl=no
2639   fi
2640 fi # test "$curl"
2641
2642 ##########################################
2643 # bluez support probe
2644 if test "$bluez" != "no" ; then
2645   cat > $TMPC << EOF
2646 #include <bluetooth/bluetooth.h>
2647 int main(void) { return bt_error(0); }
2648 EOF
2649   bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2650   bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
2651   if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2652     bluez=yes
2653     libs_softmmu="$bluez_libs $libs_softmmu"
2654   else
2655     if test "$bluez" = "yes" ; then
2656       feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
2657     fi
2658     bluez="no"
2659   fi
2660 fi
2661
2662 ##########################################
2663 # glib support probe
2664
2665 if test "$mingw32" = yes; then
2666     # g_poll is required in order to integrate with the glib main loop.
2667     glib_req_ver=2.20
2668 else
2669     glib_req_ver=2.12
2670 fi
2671 glib_modules=gthread-2.0
2672 if test "$modules" = yes; then
2673     glib_modules="$glib_modules gmodule-2.0"
2674 fi
2675
2676 for i in $glib_modules; do
2677     if $pkg_config --atleast-version=$glib_req_ver $i; then
2678         glib_cflags=`$pkg_config --cflags $i`
2679         glib_libs=`$pkg_config --libs $i`
2680         CFLAGS="$glib_cflags $CFLAGS"
2681         LIBS="$glib_libs $LIBS"
2682         libs_qga="$glib_libs $libs_qga"
2683     else
2684         error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2685     fi
2686 done
2687
2688 ##########################################
2689 # SHA command probe for modules
2690 if test "$modules" = yes; then
2691     shacmd_probe="sha1sum sha1 shasum"
2692     for c in $shacmd_probe; do
2693         if which $c &>/dev/null; then
2694             shacmd="$c"
2695             break
2696         fi
2697     done
2698     if test "$shacmd" = ""; then
2699         error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2700     fi
2701 fi
2702
2703 ##########################################
2704 # pixman support probe
2705
2706 if test "$pixman" = ""; then
2707   if test "$want_tools" = "no" -a "$softmmu" = "no"; then
2708     pixman="none"
2709   elif $pkg_config pixman-1 > /dev/null 2>&1; then
2710     pixman="system"
2711   else
2712     pixman="internal"
2713   fi
2714 fi
2715 if test "$pixman" = "none"; then
2716   if test "$want_tools" != "no" -o "$softmmu" != "no"; then
2717     error_exit "pixman disabled but system emulation or tools build" \
2718         "enabled.  You can turn off pixman only if you also" \
2719         "disable all system emulation targets and the tools" \
2720         "build with '--disable-tools --disable-system'."
2721   fi
2722   pixman_cflags=
2723   pixman_libs=
2724 elif test "$pixman" = "system"; then
2725   pixman_cflags=`$pkg_config --cflags pixman-1`
2726   pixman_libs=`$pkg_config --libs pixman-1`
2727 else
2728   if test ! -d ${source_path}/pixman/pixman; then
2729     error_exit "pixman not present. Your options:" \
2730         "  (1) Preferred: Install the pixman devel package (any recent" \
2731         "      distro should have packages as Xorg needs pixman too)." \
2732         "  (2) Fetch the pixman submodule, using:" \
2733         "      git submodule update --init pixman"
2734   fi
2735   mkdir -p pixman/pixman
2736   pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
2737   pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2738 fi
2739
2740 ##########################################
2741 # libcap probe
2742
2743 if test "$cap" != "no" ; then
2744   cat > $TMPC <<EOF
2745 #include <stdio.h>
2746 #include <sys/capability.h>
2747 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
2748 EOF
2749   if compile_prog "" "-lcap" ; then
2750     cap=yes
2751   else
2752     cap=no
2753   fi
2754 fi
2755
2756 ##########################################
2757 # pthread probe
2758 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
2759
2760 pthread=no
2761 cat > $TMPC << EOF
2762 #include <pthread.h>
2763 static void *f(void *p) { return NULL; }
2764 int main(void) {
2765   pthread_t thread;
2766   pthread_create(&thread, 0, f, 0);
2767   return 0;
2768 }
2769 EOF
2770 if compile_prog "" "" ; then
2771   pthread=yes
2772 else
2773   for pthread_lib in $PTHREADLIBS_LIST; do
2774     if compile_prog "" "$pthread_lib" ; then
2775       pthread=yes
2776       found=no
2777       for lib_entry in $LIBS; do
2778         if test "$lib_entry" = "$pthread_lib"; then
2779           found=yes
2780           break
2781         fi
2782       done
2783       if test "$found" = "no"; then
2784         LIBS="$pthread_lib $LIBS"
2785       fi
2786       break
2787     fi
2788   done
2789 fi
2790
2791 if test "$mingw32" != yes -a "$pthread" = no; then
2792   error_exit "pthread check failed" \
2793       "Make sure to have the pthread libs and headers installed."
2794 fi
2795
2796 # check for pthread_setname_np
2797 pthread_setname_np=no
2798 cat > $TMPC << EOF
2799 #include <pthread.h>
2800
2801 static void *f(void *p) { return NULL; }
2802 int main(void)
2803 {
2804     pthread_t thread;
2805     pthread_create(&thread, 0, f, 0);
2806     pthread_setname_np(thread, "QEMU");
2807     return 0;
2808 }
2809 EOF
2810 if compile_prog "" "$pthread_lib" ; then
2811   pthread_setname_np=yes
2812 fi
2813
2814 ##########################################
2815 # rbd probe
2816 if test "$rbd" != "no" ; then
2817   cat > $TMPC <<EOF
2818 #include <stdio.h>
2819 #include <rbd/librbd.h>
2820 int main(void) {
2821     rados_t cluster;
2822     rados_create(&cluster, NULL);
2823     return 0;
2824 }
2825 EOF
2826   rbd_libs="-lrbd -lrados"
2827   if compile_prog "" "$rbd_libs" ; then
2828     rbd=yes
2829   else
2830     if test "$rbd" = "yes" ; then
2831       feature_not_found "rados block device" "Install librbd/ceph devel"
2832     fi
2833     rbd=no
2834   fi
2835 fi
2836
2837 ##########################################
2838 # libssh2 probe
2839 min_libssh2_version=1.2.8
2840 if test "$libssh2" != "no" ; then
2841   if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
2842     libssh2_cflags=`$pkg_config libssh2 --cflags`
2843     libssh2_libs=`$pkg_config libssh2 --libs`
2844     libssh2=yes
2845   else
2846     if test "$libssh2" = "yes" ; then
2847       error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
2848     fi
2849     libssh2=no
2850   fi
2851 fi
2852
2853 ##########################################
2854 # libssh2_sftp_fsync probe
2855
2856 if test "$libssh2" = "yes"; then
2857   cat > $TMPC <<EOF
2858 #include <stdio.h>
2859 #include <libssh2.h>
2860 #include <libssh2_sftp.h>
2861 int main(void) {
2862     LIBSSH2_SESSION *session;
2863     LIBSSH2_SFTP *sftp;
2864     LIBSSH2_SFTP_HANDLE *sftp_handle;
2865     session = libssh2_session_init ();
2866     sftp = libssh2_sftp_init (session);
2867     sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
2868     libssh2_sftp_fsync (sftp_handle);
2869     return 0;
2870 }
2871 EOF
2872   # libssh2_cflags/libssh2_libs defined in previous test.
2873   if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
2874     QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
2875   fi
2876 fi
2877
2878 ##########################################
2879 # linux-aio probe
2880
2881 if test "$linux_aio" != "no" ; then
2882   cat > $TMPC <<EOF
2883 #include <libaio.h>
2884 #include <sys/eventfd.h>
2885 #include <stddef.h>
2886 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
2887 EOF
2888   if compile_prog "" "-laio" ; then
2889     linux_aio=yes
2890   else
2891     if test "$linux_aio" = "yes" ; then
2892       feature_not_found "linux AIO" "Install libaio devel"
2893     fi
2894     linux_aio=no
2895   fi
2896 fi
2897
2898 ##########################################
2899 # TPM passthrough is only on x86 Linux
2900
2901 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
2902   tpm_passthrough=$tpm
2903 else
2904   tpm_passthrough=no
2905 fi
2906
2907 ##########################################
2908 # adjust virtio-blk-data-plane based on linux-aio
2909
2910 if test "$virtio_blk_data_plane" = "yes" -a \
2911         "$linux_aio" != "yes" ; then
2912   error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
2913 elif test -z "$virtio_blk_data_plane" ; then
2914   virtio_blk_data_plane=$linux_aio
2915 fi
2916
2917 ##########################################
2918 # attr probe
2919
2920 if test "$attr" != "no" ; then
2921   cat > $TMPC <<EOF
2922 #include <stdio.h>
2923 #include <sys/types.h>
2924 #ifdef CONFIG_LIBATTR
2925 #include <attr/xattr.h>
2926 #else
2927 #include <sys/xattr.h>
2928 #endif
2929 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2930 EOF
2931   if compile_prog "" "" ; then
2932     attr=yes
2933   # Older distros have <attr/xattr.h>, and need -lattr:
2934   elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2935     attr=yes
2936     LIBS="-lattr $LIBS"
2937     libattr=yes
2938   else
2939     if test "$attr" = "yes" ; then
2940       feature_not_found "ATTR" "Install libc6 or libattr devel"
2941     fi
2942     attr=no
2943   fi
2944 fi
2945
2946 ##########################################
2947 # iovec probe
2948 cat > $TMPC <<EOF
2949 #include <sys/types.h>
2950 #include <sys/uio.h>
2951 #include <unistd.h>
2952 int main(void) { return sizeof(struct iovec); }
2953 EOF
2954 iovec=no
2955 if compile_prog "" "" ; then
2956   iovec=yes
2957 fi
2958
2959 ##########################################
2960 # preadv probe
2961 cat > $TMPC <<EOF
2962 #include <sys/types.h>
2963 #include <sys/uio.h>
2964 #include <unistd.h>
2965 int main(void) { return preadv(0, 0, 0, 0); }
2966 EOF
2967 preadv=no
2968 if compile_prog "" "" ; then
2969   preadv=yes
2970 fi
2971
2972 ##########################################
2973 # fdt probe
2974 # fdt support is mandatory for at least some target architectures,
2975 # so insist on it if we're building those system emulators.
2976 fdt_required=no
2977 for target in $target_list; do
2978   case $target in
2979     aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
2980       fdt_required=yes
2981     ;;
2982   esac
2983 done
2984
2985 if test "$fdt_required" = "yes"; then
2986   if test "$fdt" = "no"; then
2987     error_exit "fdt disabled but some requested targets require it." \
2988       "You can turn off fdt only if you also disable all the system emulation" \
2989       "targets which need it (by specifying a cut down --target-list)."
2990   fi
2991   fdt=yes
2992 fi
2993
2994 if test "$fdt" != "no" ; then
2995   fdt_libs="-lfdt"
2996   # explicitly check for libfdt_env.h as it is missing in some stable installs
2997   cat > $TMPC << EOF
2998 #include <libfdt_env.h>
2999 int main(void) { return 0; }
3000 EOF
3001   if compile_prog "" "$fdt_libs" ; then
3002     # system DTC is good - use it
3003     fdt=yes
3004   elif test -d ${source_path}/dtc/libfdt ; then
3005     # have submodule DTC - use it
3006     fdt=yes
3007     dtc_internal="yes"
3008     mkdir -p dtc
3009     if [ "$source_path" != `pwd` ] ; then
3010        symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3011        symlink "$source_path/dtc/scripts" "dtc/scripts"
3012     fi
3013     fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3014     fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3015   elif test "$fdt" = "yes" ; then
3016     # have neither and want - prompt for system/submodule install
3017     error_exit "DTC (libfdt) not present. Your options:" \
3018         "  (1) Preferred: Install the DTC (libfdt) devel package" \
3019         "  (2) Fetch the DTC submodule, using:" \
3020         "      git submodule update --init dtc"
3021   else
3022     # don't have and don't want
3023     fdt_libs=
3024     fdt=no
3025   fi
3026 fi
3027
3028 libs_softmmu="$libs_softmmu $fdt_libs"
3029
3030 ##########################################
3031 # GLX probe, used by milkymist-tmu2
3032 if test "$glx" != "no" ; then
3033   glx_libs="-lGL -lX11"
3034   cat > $TMPC << EOF
3035 #include <X11/Xlib.h>
3036 #include <GL/gl.h>
3037 #include <GL/glx.h>
3038 int main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
3039 EOF
3040   if compile_prog "" "-lGL -lX11" ; then
3041     glx=yes
3042   else
3043     if test "$glx" = "yes" ; then
3044       feature_not_found "glx" "Install GL devel (e.g. MESA)"
3045     fi
3046     glx_libs=
3047     glx=no
3048   fi
3049 fi
3050
3051 ##########################################
3052 # glusterfs probe
3053 if test "$glusterfs" != "no" ; then
3054   if $pkg_config --atleast-version=3 glusterfs-api; then
3055     glusterfs="yes"
3056     glusterfs_cflags=`$pkg_config --cflags glusterfs-api`
3057     glusterfs_libs=`$pkg_config --libs glusterfs-api`
3058     if $pkg_config --atleast-version=5 glusterfs-api; then
3059       glusterfs_discard="yes"
3060     fi
3061     if $pkg_config --atleast-version=6 glusterfs-api; then
3062       glusterfs_zerofill="yes"
3063     fi
3064   else
3065     if test "$glusterfs" = "yes" ; then
3066       feature_not_found "GlusterFS backend support" "Install glusterfs-api devel"
3067     fi
3068     glusterfs="no"
3069   fi
3070 fi
3071
3072 # Check for inotify functions when we are building linux-user
3073 # emulator.  This is done because older glibc versions don't
3074 # have syscall stubs for these implemented.  In that case we
3075 # don't provide them even if kernel supports them.
3076 #
3077 inotify=no
3078 cat > $TMPC << EOF
3079 #include <sys/inotify.h>
3080
3081 int
3082 main(void)
3083 {
3084         /* try to start inotify */
3085         return inotify_init();
3086 }
3087 EOF
3088 if compile_prog "" "" ; then
3089   inotify=yes
3090 fi
3091
3092 inotify1=no
3093 cat > $TMPC << EOF
3094 #include <sys/inotify.h>
3095
3096 int
3097 main(void)
3098 {
3099     /* try to start inotify */
3100     return inotify_init1(0);
3101 }
3102 EOF
3103 if compile_prog "" "" ; then
3104   inotify1=yes
3105 fi
3106
3107 # check if utimensat and futimens are supported
3108 utimens=no
3109 cat > $TMPC << EOF
3110 #define _ATFILE_SOURCE
3111 #include <stddef.h>
3112 #include <fcntl.h>
3113 #include <sys/stat.h>
3114
3115 int main(void)
3116 {
3117     utimensat(AT_FDCWD, "foo", NULL, 0);
3118     futimens(0, NULL);
3119     return 0;
3120 }
3121 EOF
3122 if compile_prog "" "" ; then
3123   utimens=yes
3124 fi
3125
3126 # check if pipe2 is there
3127 pipe2=no
3128 cat > $TMPC << EOF
3129 #include <unistd.h>
3130 #include <fcntl.h>
3131
3132 int main(void)
3133 {
3134     int pipefd[2];
3135     return pipe2(pipefd, O_CLOEXEC);
3136 }
3137 EOF
3138 if compile_prog "" "" ; then
3139   pipe2=yes
3140 fi
3141
3142 # check if accept4 is there
3143 accept4=no
3144 cat > $TMPC << EOF
3145 #include <sys/socket.h>
3146 #include <stddef.h>
3147
3148 int main(void)
3149 {
3150     accept4(0, NULL, NULL, SOCK_CLOEXEC);
3151     return 0;
3152 }
3153 EOF
3154 if compile_prog "" "" ; then
3155   accept4=yes
3156 fi
3157
3158 # check if tee/splice is there. vmsplice was added same time.
3159 splice=no
3160 cat > $TMPC << EOF
3161 #include <unistd.h>
3162 #include <fcntl.h>
3163 #include <limits.h>
3164
3165 int main(void)
3166 {
3167     int len, fd = 0;
3168     len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3169     splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3170     return 0;
3171 }
3172 EOF
3173 if compile_prog "" "" ; then
3174   splice=yes
3175 fi
3176
3177 ##########################################
3178 # signalfd probe
3179 signalfd="no"
3180 cat > $TMPC << EOF
3181 #include <unistd.h>
3182 #include <sys/syscall.h>
3183 #include <signal.h>
3184 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3185 EOF
3186
3187 if compile_prog "" "" ; then
3188   signalfd=yes
3189 fi
3190
3191 # check if eventfd is supported
3192 eventfd=no
3193 cat > $TMPC << EOF
3194 #include <sys/eventfd.h>
3195
3196 int main(void)
3197 {
3198     return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3199 }
3200 EOF
3201 if compile_prog "" "" ; then
3202   eventfd=yes
3203 fi
3204
3205 # check for fallocate
3206 fallocate=no
3207 cat > $TMPC << EOF
3208 #include <fcntl.h>
3209
3210 int main(void)
3211 {
3212     fallocate(0, 0, 0, 0);
3213     return 0;
3214 }
3215 EOF
3216 if compile_prog "" "" ; then
3217   fallocate=yes
3218 fi
3219
3220 # check for fallocate hole punching
3221 fallocate_punch_hole=no
3222 cat > $TMPC << EOF
3223 #include <fcntl.h>
3224 #include <linux/falloc.h>
3225
3226 int main(void)
3227 {
3228     fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
3229     return 0;
3230 }
3231 EOF
3232 if compile_prog "" "" ; then
3233   fallocate_punch_hole=yes
3234 fi
3235
3236 # check for sync_file_range
3237 sync_file_range=no
3238 cat > $TMPC << EOF
3239 #include <fcntl.h>
3240
3241 int main(void)
3242 {
3243     sync_file_range(0, 0, 0, 0);
3244     return 0;
3245 }
3246 EOF
3247 if compile_prog "" "" ; then
3248   sync_file_range=yes
3249 fi
3250
3251 # check for linux/fiemap.h and FS_IOC_FIEMAP
3252 fiemap=no
3253 cat > $TMPC << EOF
3254 #include <sys/ioctl.h>
3255 #include <linux/fs.h>
3256 #include <linux/fiemap.h>
3257
3258 int main(void)
3259 {
3260     ioctl(0, FS_IOC_FIEMAP, 0);
3261     return 0;
3262 }
3263 EOF
3264 if compile_prog "" "" ; then
3265   fiemap=yes
3266 fi
3267
3268 # check for dup3
3269 dup3=no
3270 cat > $TMPC << EOF
3271 #include <unistd.h>
3272
3273 int main(void)
3274 {
3275     dup3(0, 0, 0);
3276     return 0;
3277 }
3278 EOF
3279 if compile_prog "" "" ; then
3280   dup3=yes
3281 fi
3282
3283 # check for ppoll support
3284 ppoll=no
3285 cat > $TMPC << EOF
3286 #include <poll.h>
3287
3288 int main(void)
3289 {
3290     struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
3291     ppoll(&pfd, 1, 0, 0);
3292     return 0;
3293 }
3294 EOF
3295 if compile_prog "" "" ; then
3296   ppoll=yes
3297 fi
3298
3299 # check for prctl(PR_SET_TIMERSLACK , ... ) support
3300 prctl_pr_set_timerslack=no
3301 cat > $TMPC << EOF
3302 #include <sys/prctl.h>
3303
3304 int main(void)
3305 {
3306     prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3307     return 0;
3308 }
3309 EOF
3310 if compile_prog "" "" ; then
3311   prctl_pr_set_timerslack=yes
3312 fi
3313
3314 # check for epoll support
3315 epoll=no
3316 cat > $TMPC << EOF
3317 #include <sys/epoll.h>
3318
3319 int main(void)
3320 {
3321     epoll_create(0);
3322     return 0;
3323 }
3324 EOF
3325 if compile_prog "" "" ; then
3326   epoll=yes
3327 fi
3328
3329 # epoll_create1 and epoll_pwait are later additions
3330 # so we must check separately for their presence
3331 epoll_create1=no
3332 cat > $TMPC << EOF
3333 #include <sys/epoll.h>
3334
3335 int main(void)
3336 {
3337     /* Note that we use epoll_create1 as a value, not as
3338      * a function being called. This is necessary so that on
3339      * old SPARC glibc versions where the function was present in
3340      * the library but not declared in the header file we will
3341      * fail the configure check. (Otherwise we will get a compiler
3342      * warning but not an error, and will proceed to fail the
3343      * qemu compile where we compile with -Werror.)
3344      */
3345     return (int)(uintptr_t)&epoll_create1;
3346 }
3347 EOF
3348 if compile_prog "" "" ; then
3349   epoll_create1=yes
3350 fi
3351
3352 epoll_pwait=no
3353 cat > $TMPC << EOF
3354 #include <sys/epoll.h>
3355
3356 int main(void)
3357 {
3358     epoll_pwait(0, 0, 0, 0, 0);
3359     return 0;
3360 }
3361 EOF
3362 if compile_prog "" "" ; then
3363   epoll_pwait=yes
3364 fi
3365
3366 # check for sendfile support
3367 sendfile=no
3368 cat > $TMPC << EOF
3369 #include <sys/sendfile.h>
3370
3371 int main(void)
3372 {
3373     return sendfile(0, 0, 0, 0);
3374 }
3375 EOF
3376 if compile_prog "" "" ; then
3377   sendfile=yes
3378 fi
3379
3380 # Check if tools are available to build documentation.
3381 if test "$docs" != "no" ; then
3382   if has makeinfo && has pod2man; then
3383     docs=yes
3384   else
3385     if test "$docs" = "yes" ; then
3386       feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
3387     fi
3388     docs=no
3389   fi
3390 fi
3391
3392 # Search for bswap_32 function
3393 byteswap_h=no
3394 cat > $TMPC << EOF
3395 #include <byteswap.h>
3396 int main(void) { return bswap_32(0); }
3397 EOF
3398 if compile_prog "" "" ; then
3399   byteswap_h=yes
3400 fi
3401
3402 # Search for bswap32 function
3403 bswap_h=no
3404 cat > $TMPC << EOF
3405 #include <sys/endian.h>
3406 #include <sys/types.h>
3407 #include <machine/bswap.h>
3408 int main(void) { return bswap32(0); }
3409 EOF
3410 if compile_prog "" "" ; then
3411   bswap_h=yes
3412 fi
3413
3414 ##########################################
3415 # Do we have libiscsi
3416 # We check for iscsi_write16_sync() to make sure we have a
3417 # at least version 1.4.0 of libiscsi.
3418 if test "$libiscsi" != "no" ; then
3419   cat > $TMPC << EOF
3420 #include <stdio.h>
3421 #include <iscsi/iscsi.h>
3422 int main(void) { iscsi_write16_sync(NULL,0,0,NULL,0,0,0,0,0,0,0); return 0; }
3423 EOF
3424   if $pkg_config --atleast-version=1.7.0 libiscsi; then
3425     libiscsi="yes"
3426     libiscsi_cflags=$($pkg_config --cflags libiscsi)
3427     libiscsi_libs=$($pkg_config --libs libiscsi)
3428   elif compile_prog "" "-liscsi" ; then
3429     libiscsi="yes"
3430     libiscsi_libs="-liscsi"
3431   else
3432     if test "$libiscsi" = "yes" ; then
3433       feature_not_found "libiscsi" "Install libiscsi devel"
3434     fi
3435     libiscsi="no"
3436   fi
3437 fi
3438
3439 # We also need to know the API version because there was an
3440 # API change from 1.4.0 to 1.5.0.
3441 if test "$libiscsi" = "yes"; then
3442   cat >$TMPC <<EOF
3443 #include <iscsi/iscsi.h>
3444 int main(void)
3445 {
3446   iscsi_read10_task(0, 0, 0, 0, 0, 0, 0);
3447   return 0;
3448 }
3449 EOF
3450   if compile_prog "" "-liscsi"; then
3451     libiscsi_version="1.4.0"
3452   fi
3453 fi
3454
3455 ##########################################
3456 # Do we need libm
3457 cat > $TMPC << EOF
3458 #include <math.h>
3459 int main(void) { return isnan(sin(0.0)); }
3460 EOF
3461 if compile_prog "" "" ; then
3462   :
3463 elif compile_prog "" "-lm" ; then
3464   LIBS="-lm $LIBS"
3465   libs_qga="-lm $libs_qga"
3466 else
3467   error_exit "libm check failed"
3468 fi
3469
3470 ##########################################
3471 # Do we need librt
3472 # uClibc provides 2 versions of clock_gettime(), one with realtime
3473 # support and one without. This means that the clock_gettime() don't
3474 # need -lrt. We still need it for timer_create() so we check for this
3475 # function in addition.
3476 cat > $TMPC <<EOF
3477 #include <signal.h>
3478 #include <time.h>
3479 int main(void) {
3480   timer_create(CLOCK_REALTIME, NULL, NULL);
3481   return clock_gettime(CLOCK_REALTIME, NULL);
3482 }
3483 EOF
3484
3485 if compile_prog "" "" ; then
3486   :
3487 # we need pthread for static linking. use previous pthread test result
3488 elif compile_prog "" "-lrt $pthread_lib" ; then
3489   LIBS="-lrt $LIBS"
3490   libs_qga="-lrt $libs_qga"
3491 fi
3492
3493 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
3494         "$aix" != "yes" -a "$haiku" != "yes" ; then
3495     libs_softmmu="-lutil $libs_softmmu"
3496 fi
3497
3498 ##########################################
3499 # spice probe
3500 if test "$spice" != "no" ; then
3501   cat > $TMPC << EOF
3502 #include <spice.h>
3503 int main(void) { spice_server_new(); return 0; }
3504 EOF
3505   spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3506   spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
3507   if $pkg_config --atleast-version=0.12.0 spice-server && \
3508      $pkg_config --atleast-version=0.12.3 spice-protocol && \
3509      compile_prog "$spice_cflags" "$spice_libs" ; then
3510     spice="yes"
3511     libs_softmmu="$libs_softmmu $spice_libs"
3512     QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
3513     spice_protocol_version=$($pkg_config --modversion spice-protocol)
3514     spice_server_version=$($pkg_config --modversion spice-server)
3515   else
3516     if test "$spice" = "yes" ; then
3517       feature_not_found "spice" "Install spice-server and spice-protocol devel"
3518     fi
3519     spice="no"
3520   fi
3521 fi
3522
3523 # check for libcacard for smartcard support
3524 smartcard_cflags=""
3525 # TODO - what's the minimal nss version we support?
3526 if test "$smartcard_nss" != "no"; then
3527   cat > $TMPC << EOF
3528 #include <pk11pub.h>
3529 int main(void) { PK11_FreeSlot(0); return 0; }
3530 EOF
3531     smartcard_includes="-I\$(SRC_PATH)/libcacard"
3532     libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
3533     libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
3534     test_cflags="$libcacard_cflags"
3535     # The header files in nss < 3.13.3 have a bug which causes them to
3536     # emit a warning. If we're going to compile QEMU with -Werror, then
3537     # test that the headers don't have this bug. Otherwise we would pass
3538     # the configure test but fail to compile QEMU later.
3539     if test "$werror" = "yes"; then
3540         test_cflags="-Werror $test_cflags"
3541     fi
3542     if test -n "$libtool" &&
3543        $pkg_config --atleast-version=3.12.8 nss && \
3544       compile_prog "$test_cflags" "$libcacard_libs"; then
3545         smartcard_nss="yes"
3546         QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
3547         QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
3548         libs_softmmu="$libcacard_libs $libs_softmmu"
3549     else
3550         if test "$smartcard_nss" = "yes"; then
3551             feature_not_found "nss"
3552         fi
3553         smartcard_nss="no"
3554     fi
3555 fi
3556
3557 # check for libusb
3558 if test "$libusb" != "no" ; then
3559     if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
3560         libusb="yes"
3561         libusb_cflags=$($pkg_config --cflags libusb-1.0)
3562         libusb_libs=$($pkg_config --libs libusb-1.0)
3563         QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
3564         libs_softmmu="$libs_softmmu $libusb_libs"
3565     else
3566         if test "$libusb" = "yes"; then
3567             feature_not_found "libusb" "Install libusb devel"
3568         fi
3569         libusb="no"
3570     fi
3571 fi
3572
3573 # check for usbredirparser for usb network redirection support
3574 if test "$usb_redir" != "no" ; then
3575     if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
3576         usb_redir="yes"
3577         usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
3578         usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
3579         QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
3580         libs_softmmu="$libs_softmmu $usb_redir_libs"
3581     else
3582         if test "$usb_redir" = "yes"; then
3583             feature_not_found "usb-redir" "Install usbredir devel"
3584         fi
3585         usb_redir="no"
3586     fi
3587 fi
3588
3589 ##########################################
3590 # check if we have VSS SDK headers for win
3591
3592 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
3593   case "$vss_win32_sdk" in
3594     "")   vss_win32_include="-I$source_path" ;;
3595     *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3596           # handle path with spaces. So we symlink the headers into ".sdk/vss".
3597           vss_win32_include="-I$source_path/.sdk/vss"
3598           symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3599           ;;
3600     *)    vss_win32_include="-I$vss_win32_sdk"
3601   esac
3602   cat > $TMPC << EOF
3603 #define __MIDL_user_allocate_free_DEFINED__
3604 #include <inc/win2003/vss.h>
3605 int main(void) { return VSS_CTX_BACKUP; }
3606 EOF
3607   if compile_prog "$vss_win32_include" "" ; then
3608     guest_agent_with_vss="yes"
3609     QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
3610     libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
3611   else
3612     if test "$vss_win32_sdk" != "" ; then
3613       echo "ERROR: Please download and install Microsoft VSS SDK:"
3614       echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3615       echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3616       echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
3617       echo "ERROR: The headers are extracted in the directory \`inc'."
3618       feature_not_found "VSS support"
3619     fi
3620     guest_agent_with_vss="no"
3621   fi
3622 fi
3623
3624 ##########################################
3625 # lookup Windows platform SDK (if not specified)
3626 # The SDK is needed only to build .tlb (type library) file of guest agent
3627 # VSS provider from the source. It is usually unnecessary because the
3628 # pre-compiled .tlb file is included.
3629
3630 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
3631   if test -z "$win_sdk"; then
3632     programfiles="$PROGRAMFILES"
3633     test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
3634     if test -n "$programfiles"; then
3635       win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
3636     else
3637       feature_not_found "Windows SDK"
3638     fi
3639   elif test "$win_sdk" = "no"; then
3640     win_sdk=""
3641   fi
3642 fi
3643
3644 ##########################################
3645
3646 ##########################################
3647 # check if we have fdatasync
3648
3649 fdatasync=no
3650 cat > $TMPC << EOF
3651 #include <unistd.h>
3652 int main(void) {
3653 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
3654 return fdatasync(0);
3655 #else
3656 #error Not supported
3657 #endif
3658 }
3659 EOF
3660 if compile_prog "" "" ; then
3661     fdatasync=yes
3662 fi
3663
3664 ##########################################
3665 # check if we have madvise
3666
3667 madvise=no
3668 cat > $TMPC << EOF
3669 #include <sys/types.h>
3670 #include <sys/mman.h>
3671 #include <stddef.h>
3672 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
3673 EOF
3674 if compile_prog "" "" ; then
3675     madvise=yes
3676 fi
3677
3678 ##########################################
3679 # check if we have posix_madvise
3680
3681 posix_madvise=no
3682 cat > $TMPC << EOF
3683 #include <sys/mman.h>
3684 #include <stddef.h>
3685 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
3686 EOF
3687 if compile_prog "" "" ; then
3688     posix_madvise=yes
3689 fi
3690
3691 ##########################################
3692 # check if we have usable SIGEV_THREAD_ID
3693
3694 sigev_thread_id=no
3695 cat > $TMPC << EOF
3696 #include <signal.h>
3697 int main(void) {
3698   struct sigevent ev;
3699   ev.sigev_notify = SIGEV_THREAD_ID;
3700   ev._sigev_un._tid = 0;
3701   asm volatile("" : : "g"(&ev));
3702   return 0;
3703 }
3704 EOF
3705 if compile_prog "" "" ; then
3706     sigev_thread_id=yes
3707 fi
3708
3709 ##########################################
3710 # check if trace backend exists
3711
3712 $python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
3713 if test "$?" -ne 0 ; then
3714   error_exit "invalid trace backend" \
3715       "Please choose a supported trace backend."
3716 fi
3717
3718 ##########################################
3719 # For 'ust' backend, test if ust headers are present
3720 if test "$trace_backend" = "ust"; then
3721   cat > $TMPC << EOF
3722 #include <lttng/tracepoint.h>
3723 int main(void) { return 0; }
3724 EOF
3725   if compile_prog "" "" ; then
3726     if $pkg_config lttng-ust --exists; then
3727       lttng_ust_libs=`$pkg_config --libs lttng-ust`
3728     else
3729       lttng_ust_libs="-llttng-ust"
3730     fi
3731     if $pkg_config liburcu-bp --exists; then
3732       urcu_bp_libs=`$pkg_config --libs liburcu-bp`
3733     else
3734       urcu_bp_libs="-lurcu-bp"
3735     fi
3736
3737     LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
3738     libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
3739   else
3740     error_exit "Trace backend 'ust' missing lttng-ust header files"
3741   fi
3742 fi
3743
3744 ##########################################
3745 # For 'dtrace' backend, test if 'dtrace' command is present
3746 if test "$trace_backend" = "dtrace"; then
3747   if ! has 'dtrace' ; then
3748     error_exit "dtrace command is not found in PATH $PATH"
3749   fi
3750   trace_backend_stap="no"
3751   if has 'stap' ; then
3752     trace_backend_stap="yes"
3753   fi
3754 fi
3755
3756 ##########################################
3757 # check and set a backend for coroutine
3758
3759 # We prefer ucontext, but it's not always possible. The fallback
3760 # is sigcontext. gthread is not selectable except explicitly, because
3761 # it is not functional enough to run QEMU proper. (It is occasionally
3762 # useful for debugging purposes.)  On Windows the only valid backend
3763 # is the Windows-specific one.
3764
3765 ucontext_works=no
3766 if test "$darwin" != "yes"; then
3767   cat > $TMPC << EOF
3768 #include <ucontext.h>
3769 #ifdef __stub_makecontext
3770 #error Ignoring glibc stub makecontext which will always fail
3771 #endif
3772 int main(void) { makecontext(0, 0, 0); return 0; }
3773 EOF
3774   if compile_prog "" "" ; then
3775     ucontext_works=yes
3776   fi
3777 fi
3778
3779 if test "$coroutine" = ""; then
3780   if test "$mingw32" = "yes"; then
3781     coroutine=win32
3782   elif test "$ucontext_works" = "yes"; then
3783     coroutine=ucontext
3784   else
3785     coroutine=sigaltstack
3786   fi
3787 else
3788   case $coroutine in
3789   windows)
3790     if test "$mingw32" != "yes"; then
3791       error_exit "'windows' coroutine backend only valid for Windows"
3792     fi
3793     # Unfortunately the user visible backend name doesn't match the
3794     # coroutine-*.c filename for this case, so we have to adjust it here.
3795     coroutine=win32
3796     ;;
3797   ucontext)
3798     if test "$ucontext_works" != "yes"; then
3799       feature_not_found "ucontext"
3800     fi
3801     ;;
3802   gthread|sigaltstack)
3803     if test "$mingw32" = "yes"; then
3804       error_exit "only the 'windows' coroutine backend is valid for Windows"
3805     fi
3806     ;;
3807   *)
3808     error_exit "unknown coroutine backend $coroutine"
3809     ;;
3810   esac
3811 fi
3812
3813 if test "$coroutine_pool" = ""; then
3814   if test "$coroutine" = "gthread"; then
3815     coroutine_pool=no
3816   else
3817     coroutine_pool=yes
3818   fi
3819 fi
3820 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
3821   error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
3822 fi
3823
3824 ##########################################
3825 # check if we have open_by_handle_at
3826
3827 open_by_handle_at=no
3828 cat > $TMPC << EOF
3829 #include <fcntl.h>
3830 #if !defined(AT_EMPTY_PATH)
3831 # error missing definition
3832 #else
3833 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3834 #endif
3835 EOF
3836 if compile_prog "" "" ; then
3837     open_by_handle_at=yes
3838 fi
3839
3840 ########################################
3841 # check if we have linux/magic.h
3842
3843 linux_magic_h=no
3844 cat > $TMPC << EOF
3845 #include <linux/magic.h>
3846 int main(void) {
3847   return 0;
3848 }
3849 EOF
3850 if compile_prog "" "" ; then
3851     linux_magic_h=yes
3852 fi
3853
3854 ########################################
3855 # check whether we can disable warning option with a pragma (this is needed
3856 # to silence warnings in the headers of some versions of external libraries).
3857 # This test has to be compiled with -Werror as otherwise an unknown pragma is
3858 # only a warning.
3859 #
3860 # If we can't selectively disable warning in the code, disable -Werror so that
3861 # the build doesn't fail anyway.
3862
3863 pragma_disable_unused_but_set=no
3864 cat > $TMPC << EOF
3865 #pragma GCC diagnostic push
3866 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3867 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
3868 #pragma GCC diagnostic pop
3869
3870 int main(void) {
3871     return 0;
3872 }
3873 EOF
3874 if compile_prog "-Werror" "" ; then
3875     pragma_diagnostic_available=yes
3876 else
3877     werror=no
3878 fi
3879
3880 ########################################
3881 # check if we have valgrind/valgrind.h and valgrind/memcheck.h
3882
3883 valgrind_h=no
3884 cat > $TMPC << EOF
3885 #include <valgrind/valgrind.h>
3886 #include <valgrind/memcheck.h>
3887 int main(void) {
3888   return 0;
3889 }
3890 EOF
3891 if compile_prog "" "" ; then
3892     valgrind_h=yes
3893 fi
3894
3895 ########################################
3896 # check if environ is declared
3897
3898 has_environ=no
3899 cat > $TMPC << EOF
3900 #include <unistd.h>
3901 int main(void) {
3902     environ = 0;
3903     return 0;
3904 }
3905 EOF
3906 if compile_prog "" "" ; then
3907     has_environ=yes
3908 fi
3909
3910 ########################################
3911 # check if cpuid.h is usable.
3912
3913 cpuid_h=no
3914 cat > $TMPC << EOF
3915 #include <cpuid.h>
3916 int main(void) {
3917     unsigned a, b, c, d;
3918     int max = __get_cpuid_max(0, 0);
3919
3920     if (max >= 1) {
3921         __cpuid(1, a, b, c, d);
3922     }
3923
3924     if (max >= 7) {
3925         __cpuid_count(7, 0, a, b, c, d);
3926     }
3927
3928     return 0;
3929 }
3930 EOF
3931 if compile_prog "" "" ; then
3932     cpuid_h=yes
3933 fi
3934
3935 ########################################
3936 # check if __[u]int128_t is usable.
3937
3938 int128=no
3939 cat > $TMPC << EOF
3940 #if defined(__clang_major__) && defined(__clang_minor__)
3941 # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
3942 #  error __int128_t does not work in CLANG before 3.2
3943 # endif
3944 #endif
3945 __int128_t a;
3946 __uint128_t b;
3947 int main (void) {
3948   a = a + b;
3949   b = a * b;
3950   a = a * a;
3951   return 0;
3952 }
3953 EOF
3954 if compile_prog "" "" ; then
3955     int128=yes
3956 fi
3957
3958 ########################################
3959 # check if getauxval is available.
3960
3961 getauxval=no
3962 cat > $TMPC << EOF
3963 #include <sys/auxv.h>
3964 int main(void) {
3965   return getauxval(AT_HWCAP) == 0;
3966 }
3967 EOF
3968 if compile_prog "" "" ; then
3969     getauxval=yes
3970 fi
3971
3972 ##########################################
3973 # libav probe
3974
3975 if test "$libav" != "no"; then
3976     libavcodec_package="libavcodec"
3977     libavcodec_version="54.35.0"
3978     libavutil_package="libavutil"
3979     libavutil_version="52.3.0"
3980     libavformat_package="libavformat"
3981     libavformat_version="54.20.3"
3982     libavresample_package="libavresample"
3983     libavresample_version="1.0.1"
3984
3985     if $pkg_config --exists "$libavcodec_package >= $libavcodec_version" ; then
3986         libav_cflags=`$pkg_config --cflags $libavcodec_package`
3987         libav_libs=`$pkg_config --libs $libavcodec_package`
3988         libs_softmmu="$libav_libs $libs_softmmu"
3989         QEMU_CFLAGS="$QEMU_CFLAGS $libav_cflags"
3990         libav="yes"
3991     else
3992         if test "$libav" = "yes" ; then
3993             feature_not_found "libav"
3994         fi
3995         libav="no"
3996     fi
3997
3998     if $pkg_config --exists "$libavutil_package >= $libavutil_version" ; then
3999         libav_libs=`$pkg_config --libs-only-l $libavutil_package`
4000         libs_softmmu="$libav_libs $libs_softmmu"
4001         libav="yes"
4002     else
4003         if test "$libav" = "yes" ; then
4004             feature_not_found "libav"
4005         fi
4006         libav="no"
4007     fi
4008
4009     if $pkg_config --exists "$libavformat_package >= $libavformat_version" ; then
4010         libav_libs=`$pkg_config --libs-only-l $libavformat_package`
4011         libs_softmmu="$libav_libs $libs_softmmu"
4012         libav="yes"
4013     else
4014         if test "$libav" = "yes" ; then
4015             feature_not_found "libav"
4016         fi
4017         libav="no"
4018     fi
4019
4020     if $pkg_config --exists "$libavresample_package >= $libavresample_version" ; then
4021         libav_libs=`$pkg_config --libs-only-l $libavresample_package`
4022         libs_softmmu="$libav_libs $libs_softmmu"
4023         libav="yes"
4024     else
4025         if test "$libav" = "yes" ; then
4026             feature_not_found "libav"
4027         fi
4028         libav="no"
4029     fi
4030
4031 fi
4032
4033 ##########################################
4034 # png probe
4035
4036 if test "$png" != "no"; then
4037     png_package="libpng"
4038
4039     if $pkg_config --exists "$png_package" ; then
4040         png_cflags=`$pkg_config --cflags $png_package`
4041         png_libs=`$pkg_config --libs $png_package`
4042         libs_softmmu="$png_libs $libs_softmmu"
4043         QEMU_CFLAGS="$QEMU_CFLAGS $png_cflags"
4044         png="yes"
4045     else
4046         if test "$png" = "yes" ; then
4047             feature_not_found "png"
4048         fi
4049         png="no"
4050     fi
4051 fi
4052
4053 ##########################################
4054 # End of CC checks
4055 # After here, no more $cc or $ld runs
4056
4057 if test "$gcov" = "yes" ; then
4058   CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
4059   LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4060 elif test "$debug" = "no" ; then
4061   CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4062 fi
4063
4064 ##########################################
4065 # Do we have libnfs
4066 if test "$libnfs" != "no" ; then
4067   if $pkg_config --atleast-version=1.9.3 libnfs; then
4068     libnfs="yes"
4069     libnfs_libs=$($pkg_config --libs libnfs)
4070     LIBS="$LIBS $libnfs_libs"
4071   else
4072     if test "$libnfs" = "yes" ; then
4073       feature_not_found "libnfs"
4074     fi
4075     libnfs="no"
4076   fi
4077 fi
4078
4079 # Disable zero malloc errors for official releases unless explicitly told to
4080 # enable/disable
4081 if test -z "$zero_malloc" ; then
4082     if test "$z_version" = "50" ; then
4083         zero_malloc="no"
4084     else
4085         zero_malloc="yes"
4086     fi
4087 fi
4088
4089 # Now we've finished running tests it's OK to add -Werror to the compiler flags
4090 if test "$werror" = "yes"; then
4091     QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
4092 fi
4093
4094 if test "$solaris" = "no" ; then
4095     if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
4096         LDFLAGS="-Wl,--warn-common $LDFLAGS"
4097     fi
4098 fi
4099
4100 # test if pod2man has --utf8 option
4101 if pod2man --help | grep -q utf8; then
4102     POD2MAN="pod2man --utf8"
4103 else
4104     POD2MAN="pod2man"
4105 fi
4106
4107 # Use ASLR, no-SEH and DEP if available
4108 if test "$mingw32" = "yes" ; then
4109     for flag in --dynamicbase --no-seh --nxcompat; do
4110         if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4111             LDFLAGS="-Wl,$flag $LDFLAGS"
4112         fi
4113     done
4114 fi
4115
4116 qemu_confdir=$sysconfdir$confsuffix
4117 qemu_moddir=$libdir$confsuffix
4118 qemu_datadir=$datadir$confsuffix
4119 qemu_localedir="$datadir/locale"
4120
4121 tools=""
4122 if test "$want_tools" = "yes" ; then
4123   tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
4124   if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
4125     tools="qemu-nbd\$(EXESUF) $tools"
4126   fi
4127 fi
4128 if test "$softmmu" = yes ; then
4129   if test "$virtfs" != no ; then
4130     if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4131       virtfs=yes
4132       tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4133     else
4134       if test "$virtfs" = yes; then
4135         error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
4136       fi
4137       virtfs=no
4138     fi
4139   fi
4140 fi
4141 if [ "$guest_agent" != "no" ]; then
4142   if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4143       tools="qemu-ga\$(EXESUF) $tools"
4144       if [ "$mingw32" = "yes" -a "$guest_agent_with_vss" = "yes" ]; then
4145         tools="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb $tools"
4146       fi
4147       guest_agent=yes
4148   elif [ "$guest_agent" != yes ]; then
4149       guest_agent=no
4150   else
4151       error_exit "Guest agent is not supported on this platform"
4152   fi
4153 fi
4154
4155 # Mac OS X ships with a broken assembler
4156 roms=
4157 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
4158         "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
4159         "$softmmu" = yes ; then
4160   roms="optionrom"
4161 fi
4162 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
4163   roms="$roms spapr-rtas"
4164 fi
4165
4166 if test "$cpu" = "s390x" ; then
4167   roms="$roms s390-ccw"
4168 fi
4169
4170 # Probe for the need for relocating the user-only binary.
4171 if test "$pie" = "no" ; then
4172   textseg_addr=
4173   case "$cpu" in
4174     arm | hppa | i386 | m68k | ppc | ppc64 | s390* | sparc | sparc64 | x86_64 | x32)
4175       textseg_addr=0x60000000
4176       ;;
4177     mips)
4178       textseg_addr=0x400000
4179       ;;
4180   esac
4181   if [ -n "$textseg_addr" ]; then
4182     cat > $TMPC <<EOF
4183     int main(void) { return 0; }
4184 EOF
4185     textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
4186     if ! compile_prog "" "$textseg_ldflags"; then
4187       # In case ld does not support -Ttext-segment, edit the default linker
4188       # script via sed to set the .text start addr.  This is needed on FreeBSD
4189       # at least.
4190       $ld --verbose | sed \
4191         -e '1,/==================================================/d' \
4192         -e '/==================================================/,$d' \
4193         -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
4194         -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
4195       textseg_ldflags="-Wl,-T../config-host.ld"
4196     fi
4197   fi
4198 fi
4199
4200 # add pixman flags after all config tests are done
4201 QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags"
4202 libs_softmmu="$libs_softmmu $pixman_libs"
4203
4204 echo "Install prefix    $prefix"
4205 echo "BIOS directory    `eval echo $qemu_datadir`"
4206 echo "binary directory  `eval echo $bindir`"
4207 echo "library directory `eval echo $libdir`"
4208 echo "module directory  `eval echo $qemu_moddir`"
4209 echo "libexec directory `eval echo $libexecdir`"
4210 echo "include directory `eval echo $includedir`"
4211 echo "config directory  `eval echo $sysconfdir`"
4212 if test "$mingw32" = "no" ; then
4213 echo "local state directory   `eval echo $local_statedir`"
4214 echo "Manual directory  `eval echo $mandir`"
4215 echo "ELF interp prefix $interp_prefix"
4216 else
4217 echo "local state directory   queried at runtime"
4218 echo "Windows SDK       $win_sdk"
4219 fi
4220 echo "Source path       $source_path"
4221 echo "C compiler        $cc"
4222 echo "Host C compiler   $host_cc"
4223 echo "C++ compiler      $cxx"
4224 echo "Objective-C compiler $objcc"
4225 echo "ARFLAGS           $ARFLAGS"
4226 echo "CFLAGS            $CFLAGS"
4227 echo "QEMU_CFLAGS       $QEMU_CFLAGS"
4228 echo "LDFLAGS           $LDFLAGS"
4229 echo "make              $make"
4230 echo "install           $install"
4231 echo "python            $python"
4232 if test "$slirp" = "yes" ; then
4233     echo "smbd              $smbd"
4234 fi
4235 echo "module support    $modules"
4236 echo "host CPU          $cpu"
4237 echo "host big endian   $bigendian"
4238 echo "target list       $target_list"
4239 echo "tcg debug enabled $debug_tcg"
4240 echo "gprof enabled     $gprof"
4241 echo "sparse enabled    $sparse"
4242 echo "strip binaries    $strip_opt"
4243 echo "profiler          $profiler"
4244 echo "static build      $static"
4245 echo "-Werror enabled   $werror"
4246 if test "$darwin" = "yes" ; then
4247     echo "Cocoa support     $cocoa"
4248 fi
4249 echo "pixman            $pixman"
4250 echo "SDL support       $sdl"
4251 echo "GTK support       $gtk"
4252 echo "VTE support       $vte"
4253 echo "curses support    $curses"
4254 echo "curl support      $curl"
4255 echo "mingw32 support   $mingw32"
4256 echo "Audio drivers     $audio_drv_list"
4257 echo "Block whitelist (rw) $block_drv_rw_whitelist"
4258 echo "Block whitelist (ro) $block_drv_ro_whitelist"
4259 echo "VirtFS support    $virtfs"
4260 echo "VNC support       $vnc"
4261 if test "$vnc" = "yes" ; then
4262     echo "VNC TLS support   $vnc_tls"
4263     echo "VNC SASL support  $vnc_sasl"
4264     echo "VNC JPEG support  $vnc_jpeg"
4265     echo "VNC PNG support   $vnc_png"
4266     echo "VNC WS support    $vnc_ws"
4267 fi
4268 if test -n "$sparc_cpu"; then
4269     echo "Target Sparc Arch $sparc_cpu"
4270 fi
4271 echo "xen support       $xen"
4272 echo "brlapi support    $brlapi"
4273 echo "bluez  support    $bluez"
4274 echo "Documentation     $docs"
4275 [ ! -z "$uname_release" ] && \
4276 echo "uname -r          $uname_release"
4277 echo "GUEST_BASE        $guest_base"
4278 echo "PIE               $pie"
4279 echo "vde support       $vde"
4280 echo "netmap support    $netmap"
4281 echo "Linux AIO support $linux_aio"
4282 echo "ATTR/XATTR support $attr"
4283 echo "Install blobs     $blobs"
4284 echo "KVM support       $kvm"
4285 echo "RDMA support      $rdma"
4286 echo "TCG interpreter   $tcg_interpreter"
4287 echo "fdt support       $fdt"
4288 echo "preadv support    $preadv"
4289 echo "fdatasync         $fdatasync"
4290 echo "madvise           $madvise"
4291 echo "posix_madvise     $posix_madvise"
4292 echo "sigev_thread_id   $sigev_thread_id"
4293 echo "uuid support      $uuid"
4294 echo "libcap-ng support $cap_ng"
4295 echo "vhost-net support $vhost_net"
4296 echo "vhost-scsi support $vhost_scsi"
4297 echo "Trace backend     $trace_backend"
4298 echo "Trace output file $trace_file-<pid>"
4299 if test "$spice" = "yes"; then
4300 echo "spice support     $spice ($spice_protocol_version/$spice_server_version)"
4301 else
4302 echo "spice support     $spice"
4303 fi
4304 echo "rbd support       $rbd"
4305 echo "xfsctl support    $xfs"
4306 echo "nss used          $smartcard_nss"
4307 echo "libusb            $libusb"
4308 echo "usb net redir     $usb_redir"
4309 echo "EFence support    $efence"
4310 echo "GLX support       $glx"
4311 if test "$libiscsi_version" = "1.4.0"; then
4312 echo "libiscsi support  $libiscsi (1.4.0)"
4313 else
4314 echo "libiscsi support  $libiscsi"
4315 fi
4316 echo "libnfs support    $libnfs"
4317 echo "build guest agent $guest_agent"
4318 echo "QGA VSS support   $guest_agent_with_vss"
4319 echo "seccomp support   $seccomp"
4320 echo "coroutine backend $coroutine"
4321 echo "coroutine pool    $coroutine_pool"
4322 echo "GlusterFS support $glusterfs"
4323 echo "virtio-blk-data-plane $virtio_blk_data_plane"
4324 echo "gcov              $gcov_tool"
4325 echo "gcov enabled      $gcov"
4326 echo "TPM support       $tpm"
4327 echo "libssh2 support   $libssh2"
4328 echo "TPM passthrough   $tpm_passthrough"
4329 echo "QOM debugging     $qom_cast_debug"
4330 echo "vhdx              $vhdx"
4331 echo "Quorum            $quorum"
4332 echo "lzo support       $lzo"
4333 echo "snappy support    $snappy"
4334
4335 echo "HAX support       $hax"
4336 echo "YaGL support      $yagl"
4337 echo "YaGL stats        $yagl_stats"
4338 echo "OpenGL support    $opengl"
4339 echo "VIGS support      $vigs"
4340
4341 # for TIZEN-maru
4342 echo "TIZEN-maru support $maru"
4343 echo "TIZEN-maru shared framebuffer support $shm"
4344 echo "TIZEN-maru libav support $libav"
4345 echo "TIZEN-maru png support $png"
4346 #
4347
4348 if test "$sdl_too_old" = "yes"; then
4349 echo "-> Your SDL version is too old - please upgrade to have SDL support"
4350 fi
4351
4352 config_host_mak="config-host.mak"
4353
4354 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
4355
4356 echo "# Automatically generated by configure - do not modify" > $config_host_mak
4357 echo >> $config_host_mak
4358
4359 echo all: >> $config_host_mak
4360 echo "prefix=$prefix" >> $config_host_mak
4361 echo "bindir=$bindir" >> $config_host_mak
4362 echo "libdir=$libdir" >> $config_host_mak
4363 echo "libexecdir=$libexecdir" >> $config_host_mak
4364 echo "includedir=$includedir" >> $config_host_mak
4365 echo "mandir=$mandir" >> $config_host_mak
4366 echo "sysconfdir=$sysconfdir" >> $config_host_mak
4367 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
4368 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
4369 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
4370 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
4371 if test "$mingw32" = "no" ; then
4372   echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
4373 fi
4374 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
4375 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
4376 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
4377 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
4378 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
4379
4380 echo "ARCH=$ARCH" >> $config_host_mak
4381
4382 if test "$debug_tcg" = "yes" ; then
4383   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
4384 fi
4385 if test "$strip_opt" = "yes" ; then
4386   echo "STRIP=${strip}" >> $config_host_mak
4387 fi
4388 if test "$bigendian" = "yes" ; then
4389   echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
4390 fi
4391 if test "$mingw32" = "yes" ; then
4392   echo "CONFIG_WIN32=y" >> $config_host_mak
4393   rc_version=`cat $source_path/VERSION`
4394   version_major=${rc_version%%.*}
4395   rc_version=${rc_version#*.}
4396   version_minor=${rc_version%%.*}
4397   rc_version=${rc_version#*.}
4398   version_subminor=${rc_version%%.*}
4399   version_micro=0
4400   echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
4401   echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
4402   if test "$guest_agent_with_vss" = "yes" ; then
4403     echo "CONFIG_QGA_VSS=y" >> $config_host_mak
4404     echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
4405   fi
4406 else
4407   echo "CONFIG_POSIX=y" >> $config_host_mak
4408 fi
4409
4410 if test "$linux" = "yes" ; then
4411   echo "CONFIG_LINUX=y" >> $config_host_mak
4412 fi
4413
4414 if test "$darwin" = "yes" ; then
4415   echo "CONFIG_DARWIN=y" >> $config_host_mak
4416 fi
4417
4418 if test "$aix" = "yes" ; then
4419   echo "CONFIG_AIX=y" >> $config_host_mak
4420 fi
4421
4422 if test "$solaris" = "yes" ; then
4423   echo "CONFIG_SOLARIS=y" >> $config_host_mak
4424   echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
4425   if test "$needs_libsunmath" = "yes" ; then
4426     echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
4427   fi
4428 fi
4429 if test "$haiku" = "yes" ; then
4430   echo "CONFIG_HAIKU=y" >> $config_host_mak
4431 fi
4432 if test "$static" = "yes" ; then
4433   echo "CONFIG_STATIC=y" >> $config_host_mak
4434 fi
4435 if test "$profiler" = "yes" ; then
4436   echo "CONFIG_PROFILER=y" >> $config_host_mak
4437 fi
4438 if test "$slirp" = "yes" ; then
4439   echo "CONFIG_SLIRP=y" >> $config_host_mak
4440   echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
4441 fi
4442 if test "$vde" = "yes" ; then
4443   echo "CONFIG_VDE=y" >> $config_host_mak
4444 fi
4445 if test "$netmap" = "yes" ; then
4446   echo "CONFIG_NETMAP=y" >> $config_host_mak
4447 fi
4448 if test "$cap_ng" = "yes" ; then
4449   echo "CONFIG_LIBCAP=y" >> $config_host_mak
4450 fi
4451 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
4452 for drv in $audio_drv_list; do
4453     def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
4454     echo "$def=y" >> $config_host_mak
4455     if test "$drv" = "fmod"; then
4456         echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
4457     fi
4458 done
4459 if test "$audio_pt_int" = "yes" ; then
4460   echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
4461 fi
4462 if test "$audio_win_int" = "yes" ; then
4463   echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
4464 fi
4465 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
4466 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
4467 if test "$vnc" = "yes" ; then
4468   echo "CONFIG_VNC=y" >> $config_host_mak
4469 fi
4470 if test "$vnc_tls" = "yes" ; then
4471   echo "CONFIG_VNC_TLS=y" >> $config_host_mak
4472 fi
4473 if test "$vnc_sasl" = "yes" ; then
4474   echo "CONFIG_VNC_SASL=y" >> $config_host_mak
4475 fi
4476 if test "$vnc_jpeg" = "yes" ; then
4477   echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
4478 fi
4479 if test "$vnc_png" = "yes" ; then
4480   echo "CONFIG_VNC_PNG=y" >> $config_host_mak
4481 fi
4482 if test "$vnc_ws" = "yes" ; then
4483   echo "CONFIG_VNC_WS=y" >> $config_host_mak
4484   echo "VNC_WS_CFLAGS=$vnc_ws_cflags" >> $config_host_mak
4485 fi
4486 if test "$fnmatch" = "yes" ; then
4487   echo "CONFIG_FNMATCH=y" >> $config_host_mak
4488 fi
4489 if test "$uuid" = "yes" ; then
4490   echo "CONFIG_UUID=y" >> $config_host_mak
4491 fi
4492 if test "$xfs" = "yes" ; then
4493   echo "CONFIG_XFS=y" >> $config_host_mak
4494 fi
4495 qemu_version=`head $source_path/VERSION`
4496 echo "VERSION=$qemu_version" >>$config_host_mak
4497 echo "PKGVERSION=$pkgversion" >>$config_host_mak
4498 echo "SRC_PATH=$source_path" >> $config_host_mak
4499 echo "TARGET_DIRS=$target_list" >> $config_host_mak
4500 if [ "$docs" = "yes" ] ; then
4501   echo "BUILD_DOCS=yes" >> $config_host_mak
4502 fi
4503 if test "$modules" = "yes"; then
4504   # $shacmd can generate a hash started with digit, which the compiler doesn't
4505   # like as an symbol. So prefix it with an underscore
4506   echo "CONFIG_STAMP=_`(echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ `" >> $config_host_mak
4507   echo "CONFIG_MODULES=y" >> $config_host_mak
4508 fi
4509 if test "$sdl" = "yes" ; then
4510   echo "CONFIG_SDL=y" >> $config_host_mak
4511   echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
4512 fi
4513 if test "$cocoa" = "yes" ; then
4514   echo "CONFIG_COCOA=y" >> $config_host_mak
4515 fi
4516 if test "$curses" = "yes" ; then
4517   echo "CONFIG_CURSES=y" >> $config_host_mak
4518 fi
4519 if test "$utimens" = "yes" ; then
4520   echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
4521 fi
4522 if test "$pipe2" = "yes" ; then
4523   echo "CONFIG_PIPE2=y" >> $config_host_mak
4524 fi
4525 if test "$accept4" = "yes" ; then
4526   echo "CONFIG_ACCEPT4=y" >> $config_host_mak
4527 fi
4528 if test "$splice" = "yes" ; then
4529   echo "CONFIG_SPLICE=y" >> $config_host_mak
4530 fi
4531 if test "$eventfd" = "yes" ; then
4532   echo "CONFIG_EVENTFD=y" >> $config_host_mak
4533 fi
4534 if test "$fallocate" = "yes" ; then
4535   echo "CONFIG_FALLOCATE=y" >> $config_host_mak
4536 fi
4537 if test "$fallocate_punch_hole" = "yes" ; then
4538   echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
4539 fi
4540 if test "$sync_file_range" = "yes" ; then
4541   echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
4542 fi
4543 if test "$fiemap" = "yes" ; then
4544   echo "CONFIG_FIEMAP=y" >> $config_host_mak
4545 fi
4546 if test "$dup3" = "yes" ; then
4547   echo "CONFIG_DUP3=y" >> $config_host_mak
4548 fi
4549 if test "$ppoll" = "yes" ; then
4550   echo "CONFIG_PPOLL=y" >> $config_host_mak
4551 fi
4552 if test "$prctl_pr_set_timerslack" = "yes" ; then
4553   echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
4554 fi
4555 if test "$epoll" = "yes" ; then
4556   echo "CONFIG_EPOLL=y" >> $config_host_mak
4557 fi
4558 if test "$epoll_create1" = "yes" ; then
4559   echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
4560 fi
4561 if test "$epoll_pwait" = "yes" ; then
4562   echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
4563 fi
4564 if test "$sendfile" = "yes" ; then
4565   echo "CONFIG_SENDFILE=y" >> $config_host_mak
4566 fi
4567 if test "$inotify" = "yes" ; then
4568   echo "CONFIG_INOTIFY=y" >> $config_host_mak
4569 fi
4570 if test "$inotify1" = "yes" ; then
4571   echo "CONFIG_INOTIFY1=y" >> $config_host_mak
4572 fi
4573 if test "$byteswap_h" = "yes" ; then
4574   echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
4575 fi
4576 if test "$bswap_h" = "yes" ; then
4577   echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
4578 fi
4579 if test "$curl" = "yes" ; then
4580   echo "CONFIG_CURL=m" >> $config_host_mak
4581   echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
4582   echo "CURL_LIBS=$curl_libs" >> $config_host_mak
4583 fi
4584 if test "$brlapi" = "yes" ; then
4585   echo "CONFIG_BRLAPI=y" >> $config_host_mak
4586 fi
4587 if test "$bluez" = "yes" ; then
4588   echo "CONFIG_BLUEZ=y" >> $config_host_mak
4589   echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
4590 fi
4591 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
4592 if test "$gtk" = "yes" ; then
4593   echo "CONFIG_GTK=y" >> $config_host_mak
4594   echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
4595 fi
4596 if test "$vte" = "yes" ; then
4597   echo "CONFIG_VTE=y" >> $config_host_mak
4598   echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
4599 fi
4600 if test "$xen" = "yes" ; then
4601   echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
4602   echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
4603 fi
4604 if test "$linux_aio" = "yes" ; then
4605   echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
4606 fi
4607 if test "$attr" = "yes" ; then
4608   echo "CONFIG_ATTR=y" >> $config_host_mak
4609 fi
4610 if test "$libattr" = "yes" ; then
4611   echo "CONFIG_LIBATTR=y" >> $config_host_mak
4612 fi
4613 if test "$virtfs" = "yes" ; then
4614   echo "CONFIG_VIRTFS=y" >> $config_host_mak
4615 fi
4616 if test "$vhost_scsi" = "yes" ; then
4617   echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
4618 fi
4619 if test "$blobs" = "yes" ; then
4620   echo "INSTALL_BLOBS=yes" >> $config_host_mak
4621 fi
4622 if test "$iovec" = "yes" ; then
4623   echo "CONFIG_IOVEC=y" >> $config_host_mak
4624 fi
4625 if test "$preadv" = "yes" ; then
4626   echo "CONFIG_PREADV=y" >> $config_host_mak
4627 fi
4628 if test "$fdt" = "yes" ; then
4629   echo "CONFIG_FDT=y" >> $config_host_mak
4630 fi
4631 if test "$signalfd" = "yes" ; then
4632   echo "CONFIG_SIGNALFD=y" >> $config_host_mak
4633 fi
4634 if test "$tcg_interpreter" = "yes" ; then
4635   echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
4636 fi
4637 if test "$fdatasync" = "yes" ; then
4638   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
4639 fi
4640 if test "$madvise" = "yes" ; then
4641   echo "CONFIG_MADVISE=y" >> $config_host_mak
4642 fi
4643 if test "$posix_madvise" = "yes" ; then
4644   echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
4645 fi
4646 if test "$sigev_thread_id" = "yes" ; then
4647   echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
4648 fi
4649
4650 if test "$spice" = "yes" ; then
4651   echo "CONFIG_SPICE=y" >> $config_host_mak
4652 fi
4653
4654 if test "$efence" = "yes" ; then
4655   echo "CONFIG_EFENCE=y" >> $config_host_mak
4656 fi
4657
4658 if test "$yagl" = "yes" ; then
4659   echo "CONFIG_YAGL=y" >> $config_host_mak
4660   if test "$linux" = "yes" ; then
4661     LIBS="-lGLU -ldl $LIBS"
4662   elif test "$mingw32" = "yes" ; then
4663     LIBS="-lopengl32 -lglu32 $LIBS"
4664   elif test "$darwin" = "yes" ; then
4665     LIBS="-framework OpenGL -framework AGL -framework GLUT $LIBS"
4666   else
4667     echo "ERROR: YaGL is not available on $targetos"
4668     exit 1
4669   fi
4670 fi
4671
4672 if test "$yagl_stats" = "yes" ; then
4673   echo "CONFIG_YAGL_STATS=y" >> $config_host_mak
4674 fi
4675
4676 if test "$vigs" = "yes" ; then
4677   echo "CONFIG_VIGS=y" >> $config_host_mak
4678 fi
4679
4680 if test "$smartcard" = "yes" ; then
4681   echo "CONFIG_SMARTCARD=y" >> $config_host_mak
4682 fi
4683
4684 if test "$smartcard_nss" = "yes" ; then
4685   echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
4686   echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
4687   echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
4688 fi
4689
4690 if test "$libusb" = "yes" ; then
4691   echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
4692 fi
4693
4694 if test "$usb_redir" = "yes" ; then
4695   echo "CONFIG_USB_REDIR=y" >> $config_host_mak
4696 fi
4697
4698 if test "$glx" = "yes" ; then
4699   echo "CONFIG_GLX=y" >> $config_host_mak
4700   echo "GLX_LIBS=$glx_libs" >> $config_host_mak
4701 fi
4702
4703 if test "$lzo" = "yes" ; then
4704   echo "CONFIG_LZO=y" >> $config_host_mak
4705 fi
4706
4707 if test "$snappy" = "yes" ; then
4708   echo "CONFIG_SNAPPY=y" >> $config_host_mak
4709 fi
4710
4711 if test "$libiscsi" = "yes" ; then
4712   echo "CONFIG_LIBISCSI=m" >> $config_host_mak
4713   if test "$libiscsi_version" = "1.4.0"; then
4714     echo "CONFIG_LIBISCSI_1_4=y" >> $config_host_mak
4715   fi
4716   echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
4717   echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
4718 fi
4719
4720 if test "$libnfs" = "yes" ; then
4721   echo "CONFIG_LIBNFS=y" >> $config_host_mak
4722 fi
4723
4724 if test "$seccomp" = "yes"; then
4725   echo "CONFIG_SECCOMP=y" >> $config_host_mak
4726 fi
4727
4728 # XXX: suppress that
4729 if [ "$bsd" = "yes" ] ; then
4730   echo "CONFIG_BSD=y" >> $config_host_mak
4731 fi
4732
4733 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
4734
4735 if test "$zero_malloc" = "yes" ; then
4736   echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
4737 fi
4738 if test "$qom_cast_debug" = "yes" ; then
4739   echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
4740 fi
4741 if test "$rbd" = "yes" ; then
4742   echo "CONFIG_RBD=m" >> $config_host_mak
4743   echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
4744   echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
4745 fi
4746
4747 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
4748 if test "$coroutine_pool" = "yes" ; then
4749   echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
4750 else
4751   echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
4752 fi
4753
4754 if test "$open_by_handle_at" = "yes" ; then
4755   echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
4756 fi
4757
4758 if test "$linux_magic_h" = "yes" ; then
4759   echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
4760 fi
4761
4762 if test "$pragma_diagnostic_available" = "yes" ; then
4763   echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
4764 fi
4765
4766 if test "$valgrind_h" = "yes" ; then
4767   echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
4768 fi
4769
4770 if test "$has_environ" = "yes" ; then
4771   echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
4772 fi
4773
4774 if test "$cpuid_h" = "yes" ; then
4775   echo "CONFIG_CPUID_H=y" >> $config_host_mak
4776 fi
4777
4778 if test "$int128" = "yes" ; then
4779   echo "CONFIG_INT128=y" >> $config_host_mak
4780 fi
4781
4782 if test "$getauxval" = "yes" ; then
4783   echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
4784 fi
4785
4786 if test "$glusterfs" = "yes" ; then
4787   echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
4788   echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
4789   echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
4790 fi
4791
4792 if test "$glusterfs_discard" = "yes" ; then
4793   echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
4794 fi
4795
4796 if test "$glusterfs_zerofill" = "yes" ; then
4797   echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
4798 fi
4799
4800 if test "$libssh2" = "yes" ; then
4801   echo "CONFIG_LIBSSH2=m" >> $config_host_mak
4802   echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
4803   echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
4804 fi
4805
4806 if test "$quorum" = "yes" ; then
4807   echo "CONFIG_QUORUM=y" >> $config_host_mak
4808 fi
4809
4810 if test "$virtio_blk_data_plane" = "yes" ; then
4811   echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
4812 fi
4813
4814 if test "$vhdx" = "yes" ; then
4815   echo "CONFIG_VHDX=y" >> $config_host_mak
4816 fi
4817
4818 # USB host support
4819 if test "$libusb" = "yes"; then
4820   echo "HOST_USB=libusb legacy" >> $config_host_mak
4821 else
4822   echo "HOST_USB=stub" >> $config_host_mak
4823 fi
4824
4825 # for TIZEN-maru
4826 if test "$maru" = "yes" ; then
4827   echo "CONFIG_MARU=y" >> $config_host_mak
4828 fi
4829 if test "$shm" = "yes" ; then
4830   echo "CONFIG_USE_SHM=y" >> $config_host_mak
4831 fi
4832 if test "$libav" = "yes" ; then
4833   echo "CONFIG_LIBAV=y" >> $config_host_mak
4834 fi
4835 if test "$png" = "yes" ; then
4836   echo "CONFIG_PNG=y" >> $config_host_mak
4837 fi
4838
4839 # TPM passthrough support?
4840 if test "$tpm" = "yes"; then
4841   echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
4842   if test "$tpm_passthrough" = "yes"; then
4843     echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
4844   fi
4845 fi
4846
4847 # use default implementation for tracing backend-specific routines
4848 trace_default=yes
4849 echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
4850 if test "$trace_backend" = "nop"; then
4851   echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
4852 fi
4853 if test "$trace_backend" = "simple"; then
4854   echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
4855   trace_default=no
4856   # Set the appropriate trace file.
4857   trace_file="\"$trace_file-\" FMT_pid"
4858 fi
4859 if test "$trace_backend" = "stderr"; then
4860   echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
4861   trace_default=no
4862 fi
4863 if test "$trace_backend" = "ust"; then
4864   echo "CONFIG_TRACE_UST=y" >> $config_host_mak
4865 fi
4866 if test "$trace_backend" = "dtrace"; then
4867   echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
4868   if test "$trace_backend_stap" = "yes" ; then
4869     echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
4870   fi
4871 fi
4872 if test "$trace_backend" = "ftrace"; then
4873   if test "$linux" = "yes" ; then
4874     echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4875     trace_default=no
4876   else
4877     feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
4878   fi
4879 fi
4880 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
4881 if test "$trace_default" = "yes"; then
4882   echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
4883 fi
4884 if test "$hax" = "yes" ; then
4885   if test "$mingw32" = "yes" ; then
4886     echo "CONFIG_HAX_BACKEND=y" >> $config_host_mak
4887   elif test "$darwin" = "yes" ; then
4888     echo "CONFIG_HAX_BACKEND=y" >> $config_host_mak
4889   else
4890     hax="no"
4891   fi
4892 fi
4893
4894 if test "$rdma" = "yes" ; then
4895   echo "CONFIG_RDMA=y" >> $config_host_mak
4896 fi
4897
4898 # Hold two types of flag:
4899 #   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
4900 #                                     a thread we have a handle to
4901 #   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
4902 #                                     platform
4903 if test "$pthread_setname_np" = "yes" ; then
4904   echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
4905   echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
4906 fi
4907
4908 if test "$tcg_interpreter" = "yes"; then
4909   QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
4910 elif test "$ARCH" = "sparc64" ; then
4911   QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
4912 elif test "$ARCH" = "s390x" ; then
4913   QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
4914 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
4915   QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
4916 else
4917   QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
4918 fi
4919 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
4920
4921 echo "TOOLS=$tools" >> $config_host_mak
4922 echo "ROMS=$roms" >> $config_host_mak
4923 echo "MAKE=$make" >> $config_host_mak
4924 echo "INSTALL=$install" >> $config_host_mak
4925 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
4926 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
4927 if test -n "$libtool"; then
4928   echo "INSTALL_PROG=\$(LIBTOOL) --mode=install $install -c -m 0755" >> $config_host_mak
4929   echo "INSTALL_LIB=\$(LIBTOOL) --mode=install $install -c -m 0644" >> $config_host_mak
4930 else
4931   echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
4932   echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
4933 fi
4934 echo "PYTHON=$python" >> $config_host_mak
4935 echo "CC=$cc" >> $config_host_mak
4936 if $iasl -h > /dev/null 2>&1; then
4937   echo "IASL=$iasl" >> $config_host_mak
4938 fi
4939 echo "CC_I386=$cc_i386" >> $config_host_mak
4940 echo "HOST_CC=$host_cc" >> $config_host_mak
4941 echo "CXX=$cxx" >> $config_host_mak
4942 echo "OBJCC=$objcc" >> $config_host_mak
4943 echo "AR=$ar" >> $config_host_mak
4944 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
4945 echo "AS=$as" >> $config_host_mak
4946 echo "CPP=$cpp" >> $config_host_mak
4947 echo "OBJCOPY=$objcopy" >> $config_host_mak
4948 echo "LD=$ld" >> $config_host_mak
4949 echo "WINDRES=$windres" >> $config_host_mak
4950 echo "LIBTOOL=$libtool" >> $config_host_mak
4951 echo "CFLAGS=$CFLAGS" >> $config_host_mak
4952 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
4953 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
4954 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
4955 if test "$sparse" = "yes" ; then
4956   echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
4957   echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
4958   echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
4959 fi
4960 if test "$cross_prefix" != ""; then
4961   echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
4962 else
4963   echo "AUTOCONF_HOST := "                             >> $config_host_mak
4964 fi
4965 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
4966 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
4967 echo "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
4968 echo "LIBS+=$LIBS" >> $config_host_mak
4969 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
4970 echo "EXESUF=$EXESUF" >> $config_host_mak
4971 echo "DSOSUF=$DSOSUF" >> $config_host_mak
4972 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
4973 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
4974 echo "POD2MAN=$POD2MAN" >> $config_host_mak
4975 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
4976 if test "$gcov" = "yes" ; then
4977   echo "CONFIG_GCOV=y" >> $config_host_mak
4978   echo "GCOV=$gcov_tool" >> $config_host_mak
4979 fi
4980
4981 # use included Linux headers
4982 if test "$linux" = "yes" ; then
4983   mkdir -p linux-headers
4984   case "$cpu" in
4985   i386|x86_64|x32)
4986     linux_arch=x86
4987     ;;
4988   ppcemb|ppc|ppc64)
4989     linux_arch=powerpc
4990     ;;
4991   s390x)
4992     linux_arch=s390
4993     ;;
4994   aarch64)
4995     linux_arch=arm64
4996     ;;
4997   *)
4998     # For most CPUs the kernel architecture name and QEMU CPU name match.
4999     linux_arch="$cpu"
5000     ;;
5001   esac
5002     # For non-KVM architectures we will not have asm headers
5003     if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
5004       symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
5005     fi
5006 fi
5007
5008 for target in $target_list; do
5009 target_dir="$target"
5010 config_target_mak=$target_dir/config-target.mak
5011 target_name=`echo $target | cut -d '-' -f 1`
5012 target_bigendian="no"
5013
5014 case "$target_name" in
5015   armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
5016   target_bigendian=yes
5017   ;;
5018 esac
5019 target_softmmu="no"
5020 target_user_only="no"
5021 target_linux_user="no"
5022 target_bsd_user="no"
5023 case "$target" in
5024   ${target_name}-softmmu)
5025     target_softmmu="yes"
5026     ;;
5027   ${target_name}-linux-user)
5028     if test "$linux" != "yes" ; then
5029       error_exit "Target '$target' is only available on a Linux host"
5030     fi
5031     target_user_only="yes"
5032     target_linux_user="yes"
5033     ;;
5034   ${target_name}-bsd-user)
5035     if test "$bsd" != "yes" ; then
5036       error_exit "Target '$target' is only available on a BSD host"
5037     fi
5038     target_user_only="yes"
5039     target_bsd_user="yes"
5040     ;;
5041   *)
5042     error_exit "Target '$target' not recognised"
5043     exit 1
5044     ;;
5045 esac
5046
5047 mkdir -p $target_dir
5048 echo "# Automatically generated by configure - do not modify" > $config_target_mak
5049
5050 bflt="no"
5051 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"`
5052 gdb_xml_files=""
5053
5054 TARGET_ARCH="$target_name"
5055 TARGET_BASE_ARCH=""
5056 TARGET_ABI_DIR=""
5057
5058 case "$target_name" in
5059   i386)
5060   ;;
5061   x86_64)
5062     TARGET_BASE_ARCH=i386
5063   ;;
5064   alpha)
5065   ;;
5066   arm|armeb)
5067     TARGET_ARCH=arm
5068     bflt="yes"
5069     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
5070   ;;
5071   aarch64)
5072     TARGET_BASE_ARCH=arm
5073     bflt="yes"
5074     gdb_xml_files="aarch64-core.xml aarch64-fpu.xml"
5075   ;;
5076   cris)
5077   ;;
5078   lm32)
5079   ;;
5080   m68k)
5081     bflt="yes"
5082     gdb_xml_files="cf-core.xml cf-fp.xml"
5083   ;;
5084   microblaze|microblazeel)
5085     TARGET_ARCH=microblaze
5086     bflt="yes"
5087   ;;
5088   mips|mipsel)
5089     TARGET_ARCH=mips
5090     echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
5091   ;;
5092   mipsn32|mipsn32el)
5093     TARGET_ARCH=mips64
5094     TARGET_BASE_ARCH=mips
5095     echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
5096     echo "TARGET_ABI32=y" >> $config_target_mak
5097   ;;
5098   mips64|mips64el)
5099     TARGET_ARCH=mips64
5100     TARGET_BASE_ARCH=mips
5101     echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
5102   ;;
5103   moxie)
5104   ;;
5105   or32)
5106     TARGET_ARCH=openrisc
5107     TARGET_BASE_ARCH=openrisc
5108   ;;
5109   ppc)
5110     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
5111   ;;
5112   ppcemb)
5113     TARGET_BASE_ARCH=ppc
5114     TARGET_ABI_DIR=ppc
5115     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
5116   ;;
5117   ppc64)
5118     TARGET_BASE_ARCH=ppc
5119     TARGET_ABI_DIR=ppc
5120     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
5121   ;;
5122   ppc64abi32)
5123     TARGET_ARCH=ppc64
5124     TARGET_BASE_ARCH=ppc
5125     TARGET_ABI_DIR=ppc
5126     echo "TARGET_ABI32=y" >> $config_target_mak
5127     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
5128   ;;
5129   sh4|sh4eb)
5130     TARGET_ARCH=sh4
5131     bflt="yes"
5132   ;;
5133   sparc)
5134   ;;
5135   sparc64)
5136     TARGET_BASE_ARCH=sparc
5137   ;;
5138   sparc32plus)
5139     TARGET_ARCH=sparc64
5140     TARGET_BASE_ARCH=sparc
5141     TARGET_ABI_DIR=sparc
5142     echo "TARGET_ABI32=y" >> $config_target_mak
5143   ;;
5144   s390x)
5145   ;;
5146   unicore32)
5147   ;;
5148   xtensa|xtensaeb)
5149     TARGET_ARCH=xtensa
5150   ;;
5151   *)
5152     error_exit "Unsupported target CPU"
5153   ;;
5154 esac
5155 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
5156 if [ "$TARGET_BASE_ARCH" = "" ]; then
5157   TARGET_BASE_ARCH=$TARGET_ARCH
5158 fi
5159
5160 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
5161
5162 upper() {
5163     echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
5164 }
5165
5166 target_arch_name="`upper $TARGET_ARCH`"
5167 echo "TARGET_$target_arch_name=y" >> $config_target_mak
5168 echo "TARGET_NAME=$target_name" >> $config_target_mak
5169 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
5170 if [ "$TARGET_ABI_DIR" = "" ]; then
5171   TARGET_ABI_DIR=$TARGET_ARCH
5172 fi
5173 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
5174 case "$target_name" in
5175   i386|x86_64)
5176     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
5177       echo "CONFIG_XEN=y" >> $config_target_mak
5178       if test "$xen_pci_passthrough" = yes; then
5179         echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
5180       fi
5181     fi
5182     ;;
5183   *)
5184 esac
5185 case "$target_name" in
5186   aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x)
5187     # Make sure the target and host cpus are compatible
5188     if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
5189       \( "$target_name" = "$cpu" -o \
5190       \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
5191       \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
5192       \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
5193       \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
5194       \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
5195       \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
5196       echo "CONFIG_KVM=y" >> $config_target_mak
5197       if test "$vhost_net" = "yes" ; then
5198         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
5199       fi
5200     fi
5201 esac
5202 case "$target_name" in
5203   i386|x86_64)
5204     echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
5205 esac
5206 if test "$hax" = "yes" ; then
5207   if test "$target_softmmu" = "yes" ; then
5208     case "$target_name" in
5209     i386|x86_64)
5210       echo "CONFIG_HAX=y" >> $config_target_mak
5211     ;;
5212     *)
5213       echo "CONFIG_NO_HAX=y" >> $config_target_mak
5214     ;;
5215     esac
5216   else
5217     echo "CONFIG_NO_HAX=y" >> $config_target_mak
5218   fi
5219 fi
5220 if test "$target_bigendian" = "yes" ; then
5221   echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
5222 fi
5223 if test "$target_softmmu" = "yes" ; then
5224   echo "CONFIG_SOFTMMU=y" >> $config_target_mak
5225 fi
5226 if test "$target_user_only" = "yes" ; then
5227   echo "CONFIG_USER_ONLY=y" >> $config_target_mak
5228   echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
5229 fi
5230 if test "$target_linux_user" = "yes" ; then
5231   echo "CONFIG_LINUX_USER=y" >> $config_target_mak
5232 fi
5233 list=""
5234 if test ! -z "$gdb_xml_files" ; then
5235   for x in $gdb_xml_files; do
5236     list="$list $source_path/gdb-xml/$x"
5237   done
5238   echo "TARGET_XML_FILES=$list" >> $config_target_mak
5239 fi
5240
5241 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
5242   echo "TARGET_HAS_BFLT=y" >> $config_target_mak
5243 fi
5244 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
5245   echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
5246 fi
5247 if test "$target_bsd_user" = "yes" ; then
5248   echo "CONFIG_BSD_USER=y" >> $config_target_mak
5249 fi
5250
5251 # generate QEMU_CFLAGS/LDFLAGS for targets
5252
5253 cflags=""
5254 ldflags=""
5255
5256 if test "$tcg_interpreter" = "yes"; then
5257   includes="-I\$(SRC_PATH)/tcg/tci $includes"
5258 elif test "$ARCH" = "sparc64" ; then
5259   includes="-I\$(SRC_PATH)/tcg/sparc $includes"
5260 elif test "$ARCH" = "s390x" ; then
5261   includes="-I\$(SRC_PATH)/tcg/s390 $includes"
5262 elif test "$ARCH" = "x86_64" ; then
5263   includes="-I\$(SRC_PATH)/tcg/i386 $includes"
5264 else
5265   includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
5266 fi
5267 includes="-I\$(SRC_PATH)/tcg $includes"
5268
5269 if test "$linux" = "yes" ; then
5270   includes="-I\$(SRC_PATH)/linux-headers $includes"
5271 fi
5272
5273 if test "$target_user_only" = "yes" ; then
5274     libdis_config_mak=libdis-user/config.mak
5275 else
5276     libdis_config_mak=libdis/config.mak
5277 fi
5278
5279 if test "$efence" = "yes" ; then
5280   echo "CONFIG_BUILD_WITH_EFENCE=y" >> $config_target_mak
5281   echo "LIBS+=-lefence" >> $config_target_mak
5282 fi
5283
5284 if test "$yagl" = "yes" ; then
5285   echo "CONFIG_BUILD_YAGL=y" >> $config_target_mak
5286 fi
5287
5288 if test "$vigs" = "yes" ; then
5289   echo "CONFIG_BUILD_VIGS=y" >> $config_target_mak
5290 fi
5291
5292 for i in $ARCH $TARGET_BASE_ARCH ; do
5293   case "$i" in
5294   alpha)
5295     echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
5296     echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
5297   ;;
5298   aarch64)
5299     if test -n "${cxx}"; then
5300       echo "CONFIG_ARM_A64_DIS=y"  >> $config_target_mak
5301       echo "CONFIG_ARM_A64_DIS=y"  >> config-all-disas.mak
5302     fi
5303   ;;
5304   arm)
5305     echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
5306     echo "CONFIG_ARM_DIS=y"  >> config-all-disas.mak
5307     if test -n "${cxx}"; then
5308       echo "CONFIG_ARM_A64_DIS=y"  >> $config_target_mak
5309       echo "CONFIG_ARM_A64_DIS=y"  >> config-all-disas.mak
5310     fi
5311   ;;
5312   cris)
5313     echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
5314     echo "CONFIG_CRIS_DIS=y"  >> config-all-disas.mak
5315   ;;
5316   hppa)
5317     echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
5318     echo "CONFIG_HPPA_DIS=y"  >> config-all-disas.mak
5319   ;;
5320   i386|x86_64|x32)
5321     echo "CONFIG_I386_DIS=y"  >> $config_target_mak
5322     echo "CONFIG_I386_DIS=y"  >> config-all-disas.mak
5323   ;;
5324   ia64*)
5325     echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
5326     echo "CONFIG_IA64_DIS=y"  >> config-all-disas.mak
5327   ;;
5328   lm32)
5329     echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
5330     echo "CONFIG_LM32_DIS=y"  >> config-all-disas.mak
5331   ;;
5332   m68k)
5333     echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
5334     echo "CONFIG_M68K_DIS=y"  >> config-all-disas.mak
5335   ;;
5336   microblaze*)
5337     echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
5338     echo "CONFIG_MICROBLAZE_DIS=y"  >> config-all-disas.mak
5339   ;;
5340   mips*)
5341     echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
5342     echo "CONFIG_MIPS_DIS=y"  >> config-all-disas.mak
5343   ;;
5344   moxie*)
5345     echo "CONFIG_MOXIE_DIS=y"  >> $config_target_mak
5346     echo "CONFIG_MOXIE_DIS=y"  >> config-all-disas.mak
5347   ;;
5348   or32)
5349     echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
5350     echo "CONFIG_OPENRISC_DIS=y"  >> config-all-disas.mak
5351   ;;
5352   ppc*)
5353     echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
5354     echo "CONFIG_PPC_DIS=y"  >> config-all-disas.mak
5355   ;;
5356   s390*)
5357     echo "CONFIG_S390_DIS=y"  >> $config_target_mak
5358     echo "CONFIG_S390_DIS=y"  >> config-all-disas.mak
5359   ;;
5360   sh4)
5361     echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
5362     echo "CONFIG_SH4_DIS=y"  >> config-all-disas.mak
5363   ;;
5364   sparc*)
5365     echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
5366     echo "CONFIG_SPARC_DIS=y"  >> config-all-disas.mak
5367   ;;
5368   xtensa*)
5369     echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
5370     echo "CONFIG_XTENSA_DIS=y"  >> config-all-disas.mak
5371   ;;
5372   esac
5373 done
5374 if test "$tcg_interpreter" = "yes" ; then
5375   echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
5376   echo "CONFIG_TCI_DIS=y"  >> config-all-disas.mak
5377 fi
5378
5379 case "$ARCH" in
5380 alpha)
5381   # Ensure there's only a single GP
5382   cflags="-msmall-data $cflags"
5383 ;;
5384 esac
5385
5386 if test "$target_softmmu" = "yes" ; then
5387   case "$TARGET_BASE_ARCH" in
5388   arm)
5389     cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
5390   ;;
5391   lm32)
5392     cflags="-DHAS_AUDIO $cflags"
5393   ;;
5394   i386|mips|ppc)
5395     cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
5396   ;;
5397   esac
5398 fi
5399
5400 if test "$gprof" = "yes" ; then
5401   echo "TARGET_GPROF=yes" >> $config_target_mak
5402   if test "$target_linux_user" = "yes" ; then
5403     cflags="-p $cflags"
5404     ldflags="-p $ldflags"
5405   fi
5406   if test "$target_softmmu" = "yes" ; then
5407     ldflags="-p $ldflags"
5408     echo "GPROF_CFLAGS=-p" >> $config_target_mak
5409   fi
5410 fi
5411
5412 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
5413   ldflags="$ldflags $textseg_ldflags"
5414 fi
5415
5416 echo "LDFLAGS+=$ldflags" >> $config_target_mak
5417 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
5418
5419 done # for target in $targets
5420
5421 if [ "$pixman" = "internal" ]; then
5422   echo "config-host.h: subdir-pixman" >> $config_host_mak
5423 fi
5424
5425 if test "$rdma" = "yes" ; then
5426 echo "CONFIG_RDMA=y" >> $config_host_mak
5427 fi
5428
5429 if [ "$dtc_internal" = "yes" ]; then
5430   echo "config-host.h: subdir-dtc" >> $config_host_mak
5431 fi
5432
5433 # build tree in object directory in case the source is not in the current directory
5434 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
5435 DIRS="$DIRS fsdev"
5436 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
5437 DIRS="$DIRS roms/seabios roms/vgabios"
5438 DIRS="$DIRS qapi-generated"
5439 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
5440 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
5441 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
5442 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
5443 FILES="$FILES pc-bios/spapr-rtas/Makefile"
5444 FILES="$FILES pc-bios/s390-ccw/Makefile"
5445 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
5446 FILES="$FILES pc-bios/qemu-icon.bmp"
5447 for bios_file in \
5448     $source_path/pc-bios/*.bin \
5449     $source_path/pc-bios/*.aml \
5450     $source_path/pc-bios/*.rom \
5451     $source_path/pc-bios/*.dtb \
5452     $source_path/pc-bios/*.img \
5453     $source_path/pc-bios/openbios-* \
5454     $source_path/pc-bios/palcode-*
5455 do
5456     FILES="$FILES pc-bios/`basename $bios_file`"
5457 done
5458 for test_file in `find $source_path/tests/acpi-test-data -type f`
5459 do
5460     FILES="$FILES tests/acpi-test-data`echo $test_file | sed -e 's/.*acpi-test-data//'`"
5461 done
5462 mkdir -p $DIRS
5463 for f in $FILES ; do
5464     if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
5465         symlink "$source_path/$f" "$f"
5466     fi
5467 done
5468
5469 # temporary config to build submodules
5470 for rom in seabios vgabios ; do
5471     config_mak=roms/$rom/config.mak
5472     echo "# Automatically generated by configure - do not modify" > $config_mak
5473     echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
5474     echo "AS=$as" >> $config_mak
5475     echo "CC=$cc" >> $config_mak
5476     echo "BCC=bcc" >> $config_mak
5477     echo "CPP=$cpp" >> $config_mak
5478     echo "OBJCOPY=objcopy" >> $config_mak
5479     echo "IASL=$iasl" >> $config_mak
5480     echo "LD=$ld" >> $config_mak
5481 done
5482
5483 if test "$docs" = "yes" ; then
5484   mkdir -p QMP
5485 fi
5486
5487 # Save the configure command line for later reuse.
5488 cat <<EOD >config.status
5489 #!/bin/sh
5490 # Generated by configure.
5491 # Run this file to recreate the current configuration.
5492 # Compiler output produced by configure, useful for debugging
5493 # configure, is in config.log if it exists.
5494 EOD
5495 printf "exec" >>config.status
5496 printf " '%s'" "$0" "$@" >>config.status
5497 echo >>config.status
5498 chmod +x config.status
5499