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