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