]> Git Repo - qemu.git/blob - configure
arm: fix location of some include files
[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 TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
17
18 # NB: do not call "exit" in the trap handler; this is buggy with some shells;
19 # see <[email protected]>
20 trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21 rm -f config.log
22
23 # Print a helpful header at the top of config.log
24 echo "# QEMU configure log $(date)" >> config.log
25 printf "# Configured with:" >> config.log
26 printf " '%s'" "$0" "$@" >> config.log
27 echo >> config.log
28 echo "#" >> config.log
29
30 error_exit() {
31     echo
32     echo "ERROR: $1"
33     while test -n "$2"; do
34         echo "       $2"
35         shift
36     done
37     echo
38     exit 1
39 }
40
41 do_cc() {
42     # Run the compiler, capturing its output to the log.
43     echo $cc "$@" >> config.log
44     $cc "$@" >> config.log 2>&1 || return $?
45     # Test passed. If this is an --enable-werror build, rerun
46     # the test with -Werror and bail out if it fails. This
47     # makes warning-generating-errors in configure test code
48     # obvious to developers.
49     if test "$werror" != "yes"; then
50         return 0
51     fi
52     # Don't bother rerunning the compile if we were already using -Werror
53     case "$*" in
54         *-Werror*)
55            return 0
56         ;;
57     esac
58     echo $cc -Werror "$@" >> config.log
59     $cc -Werror "$@" >> config.log 2>&1 && return $?
60     error_exit "configure test passed without -Werror but failed with -Werror." \
61         "This is probably a bug in the configure script. The failing command" \
62         "will be at the bottom of config.log." \
63         "You can run configure with --disable-werror to bypass this check."
64 }
65
66 compile_object() {
67   do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
68 }
69
70 compile_prog() {
71   local_cflags="$1"
72   local_ldflags="$2"
73   do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
74 }
75
76 # symbolically link $1 to $2.  Portable version of "ln -sf".
77 symlink() {
78   rm -rf "$2"
79   mkdir -p "$(dirname "$2")"
80   ln -s "$1" "$2"
81 }
82
83 # check whether a command is available to this shell (may be either an
84 # executable or a builtin)
85 has() {
86     type "$1" >/dev/null 2>&1
87 }
88
89 # search for an executable in PATH
90 path_of() {
91     local_command="$1"
92     local_ifs="$IFS"
93     local_dir=""
94
95     # pathname has a dir component?
96     if [ "${local_command#*/}" != "$local_command" ]; then
97         if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
98             echo "$local_command"
99             return 0
100         fi
101     fi
102     if [ -z "$local_command" ]; then
103         return 1
104     fi
105
106     IFS=:
107     for local_dir in $PATH; do
108         if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
109             echo "$local_dir/$local_command"
110             IFS="${local_ifs:-$(printf ' \t\n')}"
111             return 0
112         fi
113     done
114     # not found
115     IFS="${local_ifs:-$(printf ' \t\n')}"
116     return 1
117 }
118
119 # default parameters
120 source_path=`dirname "$0"`
121 cpu=""
122 interp_prefix="/usr/gnemul/qemu-%M"
123 static="no"
124 cross_prefix=""
125 audio_drv_list=""
126 audio_card_list="ac97 es1370 sb16 hda"
127 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
128 block_drv_whitelist=""
129 host_cc="cc"
130 libs_softmmu=""
131 libs_tools=""
132 audio_pt_int=""
133 audio_win_int=""
134 cc_i386=i386-pc-linux-gnu-gcc
135 libs_qga=""
136 debug_info="yes"
137
138 # Don't accept a target_list environment variable.
139 unset target_list
140
141 # Default value for a variable defining feature "foo".
142 #  * foo="no"  feature will only be used if --enable-foo arg is given
143 #  * foo=""    feature will be searched for, and if found, will be used
144 #              unless --disable-foo is given
145 #  * foo="yes" this value will only be set by --enable-foo flag.
146 #              feature will searched for,
147 #              if not found, configure exits with error
148 #
149 # Always add --enable-foo and --disable-foo command line args.
150 # Distributions want to ensure that several features are compiled in, and it
151 # is impossible without a --enable-foo that exits if a feature is not found.
152
153 bluez=""
154 brlapi=""
155 curl=""
156 curses=""
157 docs=""
158 fdt=""
159 nptl=""
160 pixman=""
161 sdl=""
162 virtfs=""
163 vnc="yes"
164 sparse="no"
165 uuid=""
166 vde=""
167 vnc_tls=""
168 vnc_sasl=""
169 vnc_jpeg=""
170 vnc_png=""
171 vnc_ws=""
172 xen=""
173 xen_ctrl_version=""
174 xen_pci_passthrough=""
175 linux_aio=""
176 cap_ng=""
177 attr=""
178 libattr=""
179 xfs=""
180
181 vhost_net="no"
182 kvm="no"
183 gprof="no"
184 debug_tcg="no"
185 debug="no"
186 strip_opt="yes"
187 tcg_interpreter="no"
188 bigendian="no"
189 mingw32="no"
190 gcov="no"
191 gcov_tool="gcov"
192 EXESUF=""
193 prefix="/usr/local"
194 mandir="\${prefix}/share/man"
195 datadir="\${prefix}/share"
196 qemu_docdir="\${prefix}/share/doc/qemu"
197 bindir="\${prefix}/bin"
198 libdir="\${prefix}/lib"
199 libexecdir="\${prefix}/libexec"
200 includedir="\${prefix}/include"
201 sysconfdir="\${prefix}/etc"
202 local_statedir="\${prefix}/var"
203 confsuffix="/qemu"
204 slirp="yes"
205 fmod_lib=""
206 fmod_inc=""
207 oss_lib=""
208 bsd="no"
209 linux="no"
210 solaris="no"
211 profiler="no"
212 cocoa="no"
213 softmmu="yes"
214 linux_user="no"
215 bsd_user="no"
216 guest_base="yes"
217 uname_release=""
218 mixemu="no"
219 aix="no"
220 blobs="yes"
221 pkgversion=""
222 pie=""
223 zero_malloc=""
224 trace_backend="nop"
225 trace_file="trace"
226 spice=""
227 rbd=""
228 smartcard_nss=""
229 usb_redir=""
230 glx=""
231 zlib="yes"
232 guest_agent="yes"
233 want_tools="yes"
234 libiscsi=""
235 coroutine=""
236 seccomp=""
237 glusterfs=""
238 virtio_blk_data_plane=""
239 gtk=""
240 gtkabi="2.0"
241 tpm="no"
242
243 # parse CC options first
244 for opt do
245   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
246   case "$opt" in
247   --cross-prefix=*) cross_prefix="$optarg"
248   ;;
249   --cc=*) CC="$optarg"
250   ;;
251   --source-path=*) source_path="$optarg"
252   ;;
253   --cpu=*) cpu="$optarg"
254   ;;
255   --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
256                     EXTRA_CFLAGS="$optarg"
257   ;;
258   --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
259                      EXTRA_LDFLAGS="$optarg"
260   ;;
261   --enable-debug-info) debug_info="yes"
262   ;;
263   --disable-debug-info) debug_info="no"
264   ;;
265   esac
266 done
267 # OS specific
268 # Using uname is really, really broken.  Once we have the right set of checks
269 # we can eliminate its usage altogether.
270
271 # Preferred compiler:
272 #  ${CC} (if set)
273 #  ${cross_prefix}gcc (if cross-prefix specified)
274 #  system compiler
275 if test -z "${CC}${cross_prefix}"; then
276   cc="$host_cc"
277 else
278   cc="${CC-${cross_prefix}gcc}"
279 fi
280
281 ar="${AR-${cross_prefix}ar}"
282 as="${AS-${cross_prefix}as}"
283 cpp="${CPP-$cc -E}"
284 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
285 ld="${LD-${cross_prefix}ld}"
286 libtool="${LIBTOOL-${cross_prefix}libtool}"
287 strip="${STRIP-${cross_prefix}strip}"
288 windres="${WINDRES-${cross_prefix}windres}"
289 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
290 query_pkg_config() {
291     "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
292 }
293 pkg_config=query_pkg_config
294 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
295
296 # default flags for all hosts
297 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
298 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
299 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
300 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
301 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
302 if test "$debug_info" = "yes"; then
303     CFLAGS="-g $CFLAGS"
304     LDFLAGS="-g $LDFLAGS"
305 fi
306
307 # make source path absolute
308 source_path=`cd "$source_path"; pwd`
309
310 check_define() {
311 cat > $TMPC <<EOF
312 #if !defined($1)
313 #error $1 not defined
314 #endif
315 int main(void) { return 0; }
316 EOF
317   compile_object
318 }
319
320 if check_define __linux__ ; then
321   targetos="Linux"
322 elif check_define _WIN32 ; then
323   targetos='MINGW32'
324 elif check_define __OpenBSD__ ; then
325   targetos='OpenBSD'
326 elif check_define __sun__ ; then
327   targetos='SunOS'
328 elif check_define __HAIKU__ ; then
329   targetos='Haiku'
330 else
331   targetos=`uname -s`
332 fi
333
334 # Some host OSes need non-standard checks for which CPU to use.
335 # Note that these checks are broken for cross-compilation: if you're
336 # cross-compiling to one of these OSes then you'll need to specify
337 # the correct CPU with the --cpu option.
338 case $targetos in
339 Darwin)
340   # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
341   # run 64-bit userspace code.
342   # If the user didn't specify a CPU explicitly and the kernel says this is
343   # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
344   if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
345     cpu="x86_64"
346   fi
347   ;;
348 SunOS)
349   # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
350   if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
351     cpu="x86_64"
352   fi
353 esac
354
355 if test ! -z "$cpu" ; then
356   # command line argument
357   :
358 elif check_define __i386__ ; then
359   cpu="i386"
360 elif check_define __x86_64__ ; then
361   cpu="x86_64"
362 elif check_define __sparc__ ; then
363   if check_define __arch64__ ; then
364     cpu="sparc64"
365   else
366     cpu="sparc"
367   fi
368 elif check_define _ARCH_PPC ; then
369   if check_define _ARCH_PPC64 ; then
370     cpu="ppc64"
371   else
372     cpu="ppc"
373   fi
374 elif check_define __mips__ ; then
375   cpu="mips"
376 elif check_define __ia64__ ; then
377   cpu="ia64"
378 elif check_define __s390__ ; then
379   if check_define __s390x__ ; then
380     cpu="s390x"
381   else
382     cpu="s390"
383   fi
384 elif check_define __arm__ ; then
385   cpu="arm"
386 elif check_define __hppa__ ; then
387   cpu="hppa"
388 else
389   cpu=`uname -m`
390 fi
391
392 ARCH=
393 # Normalise host CPU name and set ARCH.
394 # Note that this case should only have supported host CPUs, not guests.
395 case "$cpu" in
396   ia64|ppc|ppc64|s390|s390x|sparc64)
397     cpu="$cpu"
398   ;;
399   i386|i486|i586|i686|i86pc|BePC)
400     cpu="i386"
401   ;;
402   x86_64|amd64)
403     cpu="x86_64"
404   ;;
405   armv*b|armv*l|arm)
406     cpu="arm"
407   ;;
408   hppa|parisc|parisc64)
409     cpu="hppa"
410   ;;
411   mips*)
412     cpu="mips"
413   ;;
414   sparc|sun4[cdmuv])
415     cpu="sparc"
416   ;;
417   *)
418     # This will result in either an error or falling back to TCI later
419     ARCH=unknown
420   ;;
421 esac
422 if test -z "$ARCH"; then
423   ARCH="$cpu"
424 fi
425
426 # OS specific
427
428 case $targetos in
429 CYGWIN*)
430   mingw32="yes"
431   QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
432   audio_possible_drivers="winwave sdl"
433   audio_drv_list="winwave"
434 ;;
435 MINGW32*)
436   mingw32="yes"
437   audio_possible_drivers="winwave dsound sdl fmod"
438   audio_drv_list="winwave"
439 ;;
440 GNU/kFreeBSD)
441   bsd="yes"
442   audio_drv_list="oss"
443   audio_possible_drivers="oss sdl esd pa"
444 ;;
445 FreeBSD)
446   bsd="yes"
447   make="${MAKE-gmake}"
448   audio_drv_list="oss"
449   audio_possible_drivers="oss sdl esd pa"
450   # needed for kinfo_getvmmap(3) in libutil.h
451   LIBS="-lutil $LIBS"
452 ;;
453 DragonFly)
454   bsd="yes"
455   make="${MAKE-gmake}"
456   audio_drv_list="oss"
457   audio_possible_drivers="oss sdl esd pa"
458 ;;
459 NetBSD)
460   bsd="yes"
461   make="${MAKE-gmake}"
462   audio_drv_list="oss"
463   audio_possible_drivers="oss sdl esd"
464   oss_lib="-lossaudio"
465 ;;
466 OpenBSD)
467   bsd="yes"
468   make="${MAKE-gmake}"
469   audio_drv_list="oss"
470   audio_possible_drivers="oss sdl esd"
471   oss_lib="-lossaudio"
472 ;;
473 Darwin)
474   bsd="yes"
475   darwin="yes"
476   if [ "$cpu" = "x86_64" ] ; then
477     QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
478     LDFLAGS="-arch x86_64 $LDFLAGS"
479   else
480     QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
481   fi
482   cocoa="yes"
483   audio_drv_list="coreaudio"
484   audio_possible_drivers="coreaudio sdl fmod"
485   LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
486   libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
487   # Disable attempts to use ObjectiveC features in os/object.h since they
488   # won't work when we're compiling with gcc as a C compiler.
489   QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
490 ;;
491 SunOS)
492   solaris="yes"
493   make="${MAKE-gmake}"
494   install="${INSTALL-ginstall}"
495   ld="gld"
496   smbd="${SMBD-/usr/sfw/sbin/smbd}"
497   needs_libsunmath="no"
498   solarisrev=`uname -r | cut -f2 -d.`
499   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
500     if test "$solarisrev" -le 9 ; then
501       if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
502         needs_libsunmath="yes"
503         QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
504         LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
505         LIBS="-lsunmath $LIBS"
506       else
507         error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
508             "libsunmath from the Sun Studio compilers tools, due to a lack of" \
509             "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
510             "Studio 11 can be downloaded from www.sun.com."
511       fi
512     fi
513   fi
514   if test -f /usr/include/sys/soundcard.h ; then
515     audio_drv_list="oss"
516   fi
517   audio_possible_drivers="oss sdl"
518 # needed for CMSG_ macros in sys/socket.h
519   QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
520 # needed for TIOCWIN* defines in termios.h
521   QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
522   QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
523   solarisnetlibs="-lsocket -lnsl -lresolv"
524   LIBS="$solarisnetlibs $LIBS"
525   libs_qga="$solarisnetlibs $libs_qga"
526 ;;
527 AIX)
528   aix="yes"
529   make="${MAKE-gmake}"
530 ;;
531 Haiku)
532   haiku="yes"
533   QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
534   LIBS="-lposix_error_mapper -lnetwork $LIBS"
535 ;;
536 *)
537   audio_drv_list="oss"
538   audio_possible_drivers="oss alsa sdl esd pa"
539   linux="yes"
540   linux_user="yes"
541   usb="linux"
542   kvm="yes"
543   vhost_net="yes"
544   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
545     audio_possible_drivers="$audio_possible_drivers fmod"
546   fi
547 ;;
548 esac
549
550 if [ "$bsd" = "yes" ] ; then
551   if [ "$darwin" != "yes" ] ; then
552     usb="bsd"
553     bsd_user="yes"
554   fi
555 fi
556
557 : ${make=${MAKE-make}}
558 : ${install=${INSTALL-install}}
559 : ${python=${PYTHON-python}}
560 : ${smbd=${SMBD-/usr/sbin/smbd}}
561
562 # Default objcc to clang if available, otherwise use CC
563 if has clang; then
564   objcc=clang
565 else
566   objcc="$cc"
567 fi
568
569 if test "$mingw32" = "yes" ; then
570   EXESUF=".exe"
571   QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
572   # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
573   QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
574   if test "$cpu" = "i386"; then
575     # We need something better than i386 for __sync_val_compare_and_swap
576     # and can expect that QEMU will only run on i686 or later.
577     QEMU_CFLAGS="-march=i686 $QEMU_CFLAGS"
578   fi
579   LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
580 cat > $TMPC << EOF
581 int main(void) { return 0; }
582 EOF
583   if compile_prog "" "-liberty" ; then
584     LIBS="-liberty $LIBS"
585   fi
586   prefix="c:/Program Files/QEMU"
587   mandir="\${prefix}"
588   datadir="\${prefix}"
589   qemu_docdir="\${prefix}"
590   bindir="\${prefix}"
591   sysconfdir="\${prefix}"
592   local_statedir="\${prefix}"
593   confsuffix=""
594   libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
595 fi
596
597 werror=""
598
599 for opt do
600   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
601   case "$opt" in
602   --help|-h) show_help=yes
603   ;;
604   --version|-V) exec cat $source_path/VERSION
605   ;;
606   --prefix=*) prefix="$optarg"
607   ;;
608   --interp-prefix=*) interp_prefix="$optarg"
609   ;;
610   --source-path=*)
611   ;;
612   --cross-prefix=*)
613   ;;
614   --cc=*)
615   ;;
616   --host-cc=*) host_cc="$optarg"
617   ;;
618   --objcc=*) objcc="$optarg"
619   ;;
620   --make=*) make="$optarg"
621   ;;
622   --install=*) install="$optarg"
623   ;;
624   --python=*) python="$optarg"
625   ;;
626   --gcov=*) gcov_tool="$optarg"
627   ;;
628   --smbd=*) smbd="$optarg"
629   ;;
630   --extra-cflags=*)
631   ;;
632   --extra-ldflags=*)
633   ;;
634   --enable-debug-info)
635   ;;
636   --disable-debug-info)
637   ;;
638   --cpu=*)
639   ;;
640   --target-list=*) target_list="$optarg"
641   ;;
642   --enable-trace-backend=*) trace_backend="$optarg"
643   ;;
644   --with-trace-file=*) trace_file="$optarg"
645   ;;
646   --enable-gprof) gprof="yes"
647   ;;
648   --enable-gcov) gcov="yes"
649   ;;
650   --static)
651     static="yes"
652     LDFLAGS="-static $LDFLAGS"
653     QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
654   ;;
655   --mandir=*) mandir="$optarg"
656   ;;
657   --bindir=*) bindir="$optarg"
658   ;;
659   --libdir=*) libdir="$optarg"
660   ;;
661   --libexecdir=*) libexecdir="$optarg"
662   ;;
663   --includedir=*) includedir="$optarg"
664   ;;
665   --datadir=*) datadir="$optarg"
666   ;;
667   --with-confsuffix=*) confsuffix="$optarg"
668   ;;
669   --docdir=*) qemu_docdir="$optarg"
670   ;;
671   --sysconfdir=*) sysconfdir="$optarg"
672   ;;
673   --localstatedir=*) local_statedir="$optarg"
674   ;;
675   --sbindir=*|--sharedstatedir=*|\
676   --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
677   --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
678     # These switches are silently ignored, for compatibility with
679     # autoconf-generated configure scripts. This allows QEMU's
680     # configure to be used by RPM and similar macros that set
681     # lots of directory switches by default.
682   ;;
683   --with-system-pixman) pixman="system"
684   ;;
685   --without-system-pixman) pixman="internal"
686   ;;
687   --without-pixman) pixman="none"
688   ;;
689   --disable-sdl) sdl="no"
690   ;;
691   --enable-sdl) sdl="yes"
692   ;;
693   --disable-virtfs) virtfs="no"
694   ;;
695   --enable-virtfs) virtfs="yes"
696   ;;
697   --disable-vnc) vnc="no"
698   ;;
699   --enable-vnc) vnc="yes"
700   ;;
701   --fmod-lib=*) fmod_lib="$optarg"
702   ;;
703   --fmod-inc=*) fmod_inc="$optarg"
704   ;;
705   --oss-lib=*) oss_lib="$optarg"
706   ;;
707   --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
708   ;;
709   --audio-drv-list=*) audio_drv_list="$optarg"
710   ;;
711   --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
712   ;;
713   --enable-debug-tcg) debug_tcg="yes"
714   ;;
715   --disable-debug-tcg) debug_tcg="no"
716   ;;
717   --enable-debug)
718       # Enable debugging options that aren't excessively noisy
719       debug_tcg="yes"
720       debug="yes"
721       strip_opt="no"
722   ;;
723   --enable-sparse) sparse="yes"
724   ;;
725   --disable-sparse) sparse="no"
726   ;;
727   --disable-strip) strip_opt="no"
728   ;;
729   --disable-vnc-tls) vnc_tls="no"
730   ;;
731   --enable-vnc-tls) vnc_tls="yes"
732   ;;
733   --disable-vnc-sasl) vnc_sasl="no"
734   ;;
735   --enable-vnc-sasl) vnc_sasl="yes"
736   ;;
737   --disable-vnc-jpeg) vnc_jpeg="no"
738   ;;
739   --enable-vnc-jpeg) vnc_jpeg="yes"
740   ;;
741   --disable-vnc-png) vnc_png="no"
742   ;;
743   --enable-vnc-png) vnc_png="yes"
744   ;;
745   --disable-vnc-ws) vnc_ws="no"
746   ;;
747   --enable-vnc-ws) vnc_ws="yes"
748   ;;
749   --disable-slirp) slirp="no"
750   ;;
751   --disable-uuid) uuid="no"
752   ;;
753   --enable-uuid) uuid="yes"
754   ;;
755   --disable-vde) vde="no"
756   ;;
757   --enable-vde) vde="yes"
758   ;;
759   --disable-xen) xen="no"
760   ;;
761   --enable-xen) xen="yes"
762   ;;
763   --disable-xen-pci-passthrough) xen_pci_passthrough="no"
764   ;;
765   --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
766   ;;
767   --disable-brlapi) brlapi="no"
768   ;;
769   --enable-brlapi) brlapi="yes"
770   ;;
771   --disable-bluez) bluez="no"
772   ;;
773   --enable-bluez) bluez="yes"
774   ;;
775   --disable-kvm) kvm="no"
776   ;;
777   --enable-kvm) kvm="yes"
778   ;;
779   --disable-tcg-interpreter) tcg_interpreter="no"
780   ;;
781   --enable-tcg-interpreter) tcg_interpreter="yes"
782   ;;
783   --disable-cap-ng)  cap_ng="no"
784   ;;
785   --enable-cap-ng) cap_ng="yes"
786   ;;
787   --disable-spice) spice="no"
788   ;;
789   --enable-spice) spice="yes"
790   ;;
791   --disable-libiscsi) libiscsi="no"
792   ;;
793   --enable-libiscsi) libiscsi="yes"
794   ;;
795   --enable-profiler) profiler="yes"
796   ;;
797   --disable-cocoa) cocoa="no"
798   ;;
799   --enable-cocoa)
800       cocoa="yes" ;
801       sdl="no" ;
802       audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
803   ;;
804   --disable-system) softmmu="no"
805   ;;
806   --enable-system) softmmu="yes"
807   ;;
808   --disable-user)
809       linux_user="no" ;
810       bsd_user="no" ;
811   ;;
812   --enable-user) ;;
813   --disable-linux-user) linux_user="no"
814   ;;
815   --enable-linux-user) linux_user="yes"
816   ;;
817   --disable-bsd-user) bsd_user="no"
818   ;;
819   --enable-bsd-user) bsd_user="yes"
820   ;;
821   --enable-guest-base) guest_base="yes"
822   ;;
823   --disable-guest-base) guest_base="no"
824   ;;
825   --enable-pie) pie="yes"
826   ;;
827   --disable-pie) pie="no"
828   ;;
829   --enable-uname-release=*) uname_release="$optarg"
830   ;;
831   --enable-werror) werror="yes"
832   ;;
833   --disable-werror) werror="no"
834   ;;
835   --disable-curses) curses="no"
836   ;;
837   --enable-curses) curses="yes"
838   ;;
839   --disable-curl) curl="no"
840   ;;
841   --enable-curl) curl="yes"
842   ;;
843   --disable-fdt) fdt="no"
844   ;;
845   --enable-fdt) fdt="yes"
846   ;;
847   --disable-nptl) nptl="no"
848   ;;
849   --enable-nptl) nptl="yes"
850   ;;
851   --enable-mixemu) mixemu="yes"
852   ;;
853   --disable-linux-aio) linux_aio="no"
854   ;;
855   --enable-linux-aio) linux_aio="yes"
856   ;;
857   --disable-attr) attr="no"
858   ;;
859   --enable-attr) attr="yes"
860   ;;
861   --disable-blobs) blobs="no"
862   ;;
863   --with-pkgversion=*) pkgversion=" ($optarg)"
864   ;;
865   --with-coroutine=*) coroutine="$optarg"
866   ;;
867   --disable-docs) docs="no"
868   ;;
869   --enable-docs) docs="yes"
870   ;;
871   --disable-vhost-net) vhost_net="no"
872   ;;
873   --enable-vhost-net) vhost_net="yes"
874   ;;
875   --disable-glx) glx="no"
876   ;;
877   --enable-glx) glx="yes"
878   ;;
879   --disable-rbd) rbd="no"
880   ;;
881   --enable-rbd) rbd="yes"
882   ;;
883   --disable-xfsctl) xfs="no"
884   ;;
885   --enable-xfsctl) xfs="yes"
886   ;;
887   --disable-smartcard-nss) smartcard_nss="no"
888   ;;
889   --enable-smartcard-nss) smartcard_nss="yes"
890   ;;
891   --disable-usb-redir) usb_redir="no"
892   ;;
893   --enable-usb-redir) usb_redir="yes"
894   ;;
895   --disable-zlib-test) zlib="no"
896   ;;
897   --enable-guest-agent) guest_agent="yes"
898   ;;
899   --disable-guest-agent) guest_agent="no"
900   ;;
901   --enable-tools) want_tools="yes"
902   ;;
903   --disable-tools) want_tools="no"
904   ;;
905   --enable-seccomp) seccomp="yes"
906   ;;
907   --disable-seccomp) seccomp="no"
908   ;;
909   --disable-glusterfs) glusterfs="no"
910   ;;
911   --enable-glusterfs) glusterfs="yes"
912   ;;
913   --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
914   ;;
915   --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
916   ;;
917   --disable-gtk) gtk="no"
918   ;;
919   --enable-gtk) gtk="yes"
920   ;;
921   --with-gtkabi=*) gtkabi="$optarg"
922   ;;
923   --enable-tpm) tpm="yes"
924   ;;
925   *) echo "ERROR: unknown option $opt"; show_help="yes"
926   ;;
927   esac
928 done
929
930 case "$cpu" in
931     sparc)
932            LDFLAGS="-m32 $LDFLAGS"
933            QEMU_CFLAGS="-m32 -mcpu=ultrasparc $QEMU_CFLAGS"
934            ;;
935     sparc64)
936            LDFLAGS="-m64 $LDFLAGS"
937            QEMU_CFLAGS="-m64 -mcpu=ultrasparc $QEMU_CFLAGS"
938            ;;
939     s390)
940            QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
941            LDFLAGS="-m31 $LDFLAGS"
942            ;;
943     s390x)
944            QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
945            LDFLAGS="-m64 $LDFLAGS"
946            ;;
947     i386)
948            QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
949            LDFLAGS="-m32 $LDFLAGS"
950            cc_i386='$(CC) -m32'
951            ;;
952     x86_64)
953            QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
954            LDFLAGS="-m64 $LDFLAGS"
955            cc_i386='$(CC) -m32'
956            ;;
957     # No special flags required for other host CPUs
958 esac
959
960 default_target_list=""
961
962 # these targets are portable
963 if [ "$softmmu" = "yes" ] ; then
964     default_target_list="\
965 i386-softmmu \
966 x86_64-softmmu \
967 alpha-softmmu \
968 arm-softmmu \
969 cris-softmmu \
970 lm32-softmmu \
971 m68k-softmmu \
972 microblaze-softmmu \
973 microblazeel-softmmu \
974 mips-softmmu \
975 mipsel-softmmu \
976 mips64-softmmu \
977 mips64el-softmmu \
978 moxie-softmmu \
979 or32-softmmu \
980 ppc-softmmu \
981 ppcemb-softmmu \
982 ppc64-softmmu \
983 sh4-softmmu \
984 sh4eb-softmmu \
985 sparc-softmmu \
986 sparc64-softmmu \
987 s390x-softmmu \
988 xtensa-softmmu \
989 xtensaeb-softmmu \
990 unicore32-softmmu \
991 "
992 fi
993 # the following are Linux specific
994 if [ "$linux_user" = "yes" ] ; then
995     default_target_list="${default_target_list}\
996 i386-linux-user \
997 x86_64-linux-user \
998 alpha-linux-user \
999 arm-linux-user \
1000 armeb-linux-user \
1001 cris-linux-user \
1002 m68k-linux-user \
1003 microblaze-linux-user \
1004 microblazeel-linux-user \
1005 mips-linux-user \
1006 mipsel-linux-user \
1007 mips64-linux-user \
1008 mips64el-linux-user \
1009 mipsn32-linux-user \
1010 mipsn32el-linux-user \
1011 or32-linux-user \
1012 ppc-linux-user \
1013 ppc64-linux-user \
1014 ppc64abi32-linux-user \
1015 sh4-linux-user \
1016 sh4eb-linux-user \
1017 sparc-linux-user \
1018 sparc64-linux-user \
1019 sparc32plus-linux-user \
1020 unicore32-linux-user \
1021 s390x-linux-user \
1022 "
1023 fi
1024 # the following are BSD specific
1025 if [ "$bsd_user" = "yes" ] ; then
1026     default_target_list="${default_target_list}\
1027 i386-bsd-user \
1028 x86_64-bsd-user \
1029 sparc-bsd-user \
1030 sparc64-bsd-user \
1031 "
1032 fi
1033
1034 if test x"$show_help" = x"yes" ; then
1035 cat << EOF
1036
1037 Usage: configure [options]
1038 Options: [defaults in brackets after descriptions]
1039
1040 EOF
1041 echo "Standard options:"
1042 echo "  --help                   print this message"
1043 echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
1044 echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
1045 echo "                           use %M for cpu name [$interp_prefix]"
1046 echo "  --target-list=LIST       set target list (default: build everything)"
1047 echo "Available targets: $default_target_list" | \
1048     fold -s -w 53 | sed -e 's/^/                           /'
1049 echo ""
1050 echo "Advanced options (experts only):"
1051 echo "  --source-path=PATH       path of source code [$source_path]"
1052 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
1053 echo "  --cc=CC                  use C compiler CC [$cc]"
1054 echo "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
1055 echo "                           build time"
1056 echo "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
1057 echo "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
1058 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
1059 echo "  --make=MAKE              use specified make [$make]"
1060 echo "  --install=INSTALL        use specified install [$install]"
1061 echo "  --python=PYTHON          use specified python [$python]"
1062 echo "  --smbd=SMBD              use specified smbd [$smbd]"
1063 echo "  --static                 enable static build [$static]"
1064 echo "  --mandir=PATH            install man pages in PATH"
1065 echo "  --datadir=PATH           install firmware in PATH$confsuffix"
1066 echo "  --docdir=PATH            install documentation in PATH$confsuffix"
1067 echo "  --bindir=PATH            install binaries in PATH"
1068 echo "  --libdir=PATH            install libraries in PATH"
1069 echo "  --sysconfdir=PATH        install config in PATH$confsuffix"
1070 echo "  --localstatedir=PATH     install local state in PATH"
1071 echo "  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1072 echo "  --enable-debug-tcg       enable TCG debugging"
1073 echo "  --disable-debug-tcg      disable TCG debugging (default)"
1074 echo "  --enable-debug-info       enable debugging information (default)"
1075 echo "  --disable-debug-info      disable debugging information"
1076 echo "  --enable-debug           enable common debug build options"
1077 echo "  --enable-sparse          enable sparse checker"
1078 echo "  --disable-sparse         disable sparse checker (default)"
1079 echo "  --disable-strip          disable stripping binaries"
1080 echo "  --disable-werror         disable compilation abort on warning"
1081 echo "  --disable-sdl            disable SDL"
1082 echo "  --enable-sdl             enable SDL"
1083 echo "  --disable-gtk            disable gtk UI"
1084 echo "  --enable-gtk             enable gtk UI"
1085 echo "  --disable-virtfs         disable VirtFS"
1086 echo "  --enable-virtfs          enable VirtFS"
1087 echo "  --disable-vnc            disable VNC"
1088 echo "  --enable-vnc             enable VNC"
1089 echo "  --disable-cocoa          disable Cocoa (Mac OS X only)"
1090 echo "  --enable-cocoa           enable Cocoa (default on Mac OS X)"
1091 echo "  --audio-drv-list=LIST    set audio drivers list:"
1092 echo "                           Available drivers: $audio_possible_drivers"
1093 echo "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
1094 echo "                           Available cards: $audio_possible_cards"
1095 echo "  --block-drv-whitelist=L  set block driver whitelist"
1096 echo "                           (affects only QEMU, not qemu-img)"
1097 echo "  --enable-mixemu          enable mixer emulation"
1098 echo "  --disable-xen            disable xen backend driver support"
1099 echo "  --enable-xen             enable xen backend driver support"
1100 echo "  --disable-xen-pci-passthrough"
1101 echo "  --enable-xen-pci-passthrough"
1102 echo "  --disable-brlapi         disable BrlAPI"
1103 echo "  --enable-brlapi          enable BrlAPI"
1104 echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
1105 echo "  --enable-vnc-tls         enable TLS encryption for VNC server"
1106 echo "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1107 echo "  --enable-vnc-sasl        enable SASL encryption for VNC server"
1108 echo "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
1109 echo "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
1110 echo "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1111 echo "  --enable-vnc-png         enable PNG compression for VNC server"
1112 echo "  --disable-vnc-ws         disable Websockets support for VNC server"
1113 echo "  --enable-vnc-ws          enable Websockets support for VNC server"
1114 echo "  --disable-curses         disable curses output"
1115 echo "  --enable-curses          enable curses output"
1116 echo "  --disable-curl           disable curl connectivity"
1117 echo "  --enable-curl            enable curl connectivity"
1118 echo "  --disable-fdt            disable fdt device tree"
1119 echo "  --enable-fdt             enable fdt device tree"
1120 echo "  --disable-bluez          disable bluez stack connectivity"
1121 echo "  --enable-bluez           enable bluez stack connectivity"
1122 echo "  --disable-slirp          disable SLIRP userspace network connectivity"
1123 echo "  --disable-kvm            disable KVM acceleration support"
1124 echo "  --enable-kvm             enable KVM acceleration support"
1125 echo "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1126 echo "  --disable-nptl           disable usermode NPTL support"
1127 echo "  --enable-nptl            enable usermode NPTL support"
1128 echo "  --enable-system          enable all system emulation targets"
1129 echo "  --disable-system         disable all system emulation targets"
1130 echo "  --enable-user            enable supported user emulation targets"
1131 echo "  --disable-user           disable all user emulation targets"
1132 echo "  --enable-linux-user      enable all linux usermode emulation targets"
1133 echo "  --disable-linux-user     disable all linux usermode emulation targets"
1134 echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
1135 echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1136 echo "  --enable-guest-base      enable GUEST_BASE support for usermode"
1137 echo "                           emulation targets"
1138 echo "  --disable-guest-base     disable GUEST_BASE support"
1139 echo "  --enable-pie             build Position Independent Executables"
1140 echo "  --disable-pie            do not build Position Independent Executables"
1141 echo "  --fmod-lib               path to FMOD library"
1142 echo "  --fmod-inc               path to FMOD includes"
1143 echo "  --oss-lib                path to OSS library"
1144 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1145 echo "  --cpu=CPU                Build for host CPU [$cpu]"
1146 echo "  --disable-uuid           disable uuid support"
1147 echo "  --enable-uuid            enable uuid support"
1148 echo "  --disable-vde            disable support for vde network"
1149 echo "  --enable-vde             enable support for vde network"
1150 echo "  --disable-linux-aio      disable Linux AIO support"
1151 echo "  --enable-linux-aio       enable Linux AIO support"
1152 echo "  --disable-cap-ng         disable libcap-ng support"
1153 echo "  --enable-cap-ng          enable libcap-ng support"
1154 echo "  --disable-attr           disables attr and xattr support"
1155 echo "  --enable-attr            enable attr and xattr support"
1156 echo "  --disable-blobs          disable installing provided firmware blobs"
1157 echo "  --enable-docs            enable documentation build"
1158 echo "  --disable-docs           disable documentation build"
1159 echo "  --disable-vhost-net      disable vhost-net acceleration support"
1160 echo "  --enable-vhost-net       enable vhost-net acceleration support"
1161 echo "  --enable-trace-backend=B Set trace backend"
1162 echo "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
1163 echo "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
1164 echo "                           Default:trace-<pid>"
1165 echo "  --disable-spice          disable spice"
1166 echo "  --enable-spice           enable spice"
1167 echo "  --enable-rbd             enable building the rados block device (rbd)"
1168 echo "  --disable-libiscsi       disable iscsi support"
1169 echo "  --enable-libiscsi        enable iscsi support"
1170 echo "  --disable-smartcard-nss  disable smartcard nss support"
1171 echo "  --enable-smartcard-nss   enable smartcard nss support"
1172 echo "  --disable-usb-redir      disable usb network redirection support"
1173 echo "  --enable-usb-redir       enable usb network redirection support"
1174 echo "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1175 echo "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1176 echo "  --disable-seccomp        disable seccomp support"
1177 echo "  --enable-seccomp         enables seccomp support"
1178 echo "  --with-coroutine=BACKEND coroutine backend. Supported options:"
1179 echo "                           gthread, ucontext, sigaltstack, windows"
1180 echo "  --enable-glusterfs       enable GlusterFS backend"
1181 echo "  --disable-glusterfs      disable GlusterFS backend"
1182 echo "  --enable-gcov            enable test coverage analysis with gcov"
1183 echo "  --gcov=GCOV              use specified gcov [$gcov_tool]"
1184 echo "  --enable-tpm             enable TPM support"
1185 echo ""
1186 echo "NOTE: The object files are built at the place where configure is launched"
1187 exit 1
1188 fi
1189
1190 # Now we have handled --enable-tcg-interpreter and know we're not just
1191 # printing the help message, bail out if the host CPU isn't supported.
1192 if test "$ARCH" = "unknown"; then
1193     if test "$tcg_interpreter" = "yes" ; then
1194         echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1195         ARCH=tci
1196     else
1197         error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1198     fi
1199 fi
1200
1201 # check that the C compiler works.
1202 cat > $TMPC <<EOF
1203 int main(void) { return 0; }
1204 EOF
1205
1206 if compile_object ; then
1207   : C compiler works ok
1208 else
1209     error_exit "\"$cc\" either does not exist or does not work"
1210 fi
1211
1212 # Consult white-list to determine whether to enable werror
1213 # by default.  Only enable by default for git builds
1214 z_version=`cut -f3 -d. $source_path/VERSION`
1215
1216 if test -z "$werror" ; then
1217     if test -d "$source_path/.git" -a \
1218         "$linux" = "yes" ; then
1219         werror="yes"
1220     else
1221         werror="no"
1222     fi
1223 fi
1224
1225 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1226 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1227 gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1228 gcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
1229 gcc_flags="-Wno-initializer-overrides $gcc_flags"
1230 # Note that we do not add -Werror to gcc_flags here, because that would
1231 # enable it for all configure tests. If a configure test failed due
1232 # to -Werror this would just silently disable some features,
1233 # so it's too error prone.
1234 cat > $TMPC << EOF
1235 int main(void) { return 0; }
1236 EOF
1237 for flag in $gcc_flags; do
1238     # Use the positive sense of the flag when testing for -Wno-wombat
1239     # support (gcc will happily accept the -Wno- form of unknown
1240     # warning options).
1241     optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1242     if compile_prog "-Werror $optflag" "" ; then
1243         QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1244     fi
1245 done
1246
1247 # Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1248 # large functions that use global variables.  The bug is in all releases of
1249 # GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1250 # 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1251 cat > $TMPC << EOF
1252 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1253 int main(void) { return 0; }
1254 #else
1255 #error No bug in this compiler.
1256 #endif
1257 EOF
1258 if compile_prog "-Werror -fno-gcse" "" ; then
1259   TRANSLATE_OPT_CFLAGS=-fno-gcse
1260 fi
1261
1262 if test "$static" = "yes" ; then
1263   if test "$pie" = "yes" ; then
1264     error_exit "static and pie are mutually incompatible"
1265   else
1266     pie="no"
1267   fi
1268 fi
1269
1270 if test "$pie" = ""; then
1271   case "$cpu-$targetos" in
1272     i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD)
1273       ;;
1274     *)
1275       pie="no"
1276       ;;
1277   esac
1278 fi
1279
1280 if test "$pie" != "no" ; then
1281   cat > $TMPC << EOF
1282
1283 #ifdef __linux__
1284 #  define THREAD __thread
1285 #else
1286 #  define THREAD
1287 #endif
1288
1289 static THREAD int tls_var;
1290
1291 int main(void) { return tls_var; }
1292
1293 EOF
1294   if compile_prog "-fPIE -DPIE" "-pie"; then
1295     QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1296     LDFLAGS="-pie $LDFLAGS"
1297     pie="yes"
1298     if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1299       LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1300     fi
1301   else
1302     if test "$pie" = "yes"; then
1303       error_exit "PIE not available due to missing toolchain support"
1304     else
1305       echo "Disabling PIE due to missing toolchain support"
1306       pie="no"
1307     fi
1308   fi
1309 fi
1310
1311 #
1312 # Solaris specific configure tool chain decisions
1313 #
1314 if test "$solaris" = "yes" ; then
1315   if has $install; then
1316     :
1317   else
1318     error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1319         "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1320         "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1321   fi
1322   if test "`path_of $install`" = "/usr/sbin/install" ; then
1323     error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1324         "try ginstall from the GNU fileutils available from www.blastwave.org" \
1325         "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1326   fi
1327   if has ar; then
1328     :
1329   else
1330     if test -f /usr/ccs/bin/ar ; then
1331       error_exit "No path includes ar" \
1332           "Add /usr/ccs/bin to your path and rerun configure"
1333     fi
1334     error_exit "No path includes ar"
1335   fi
1336 fi
1337
1338 if ! has $python; then
1339   error_exit "Python not found. Use --python=/path/to/python"
1340 fi
1341
1342 # Note that if the Python conditional here evaluates True we will exit
1343 # with status 1 which is a shell 'false' value.
1344 if ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1345   error_exit "Cannot use '$python', Python 2.4 or later is required." \
1346       "Note that Python 3 or later is not yet supported." \
1347       "Use --python=/path/to/python to specify a supported Python."
1348 fi
1349
1350 if test -z "${target_list+xxx}" ; then
1351     target_list="$default_target_list"
1352 else
1353     target_list=`echo "$target_list" | sed -e 's/,/ /g'`
1354 fi
1355 # see if system emulation was really requested
1356 case " $target_list " in
1357   *"-softmmu "*) softmmu=yes
1358   ;;
1359   *) softmmu=no
1360   ;;
1361 esac
1362
1363 feature_not_found() {
1364   feature=$1
1365
1366   error_exit "User requested feature $feature" \
1367       "configure was not able to find it"
1368 }
1369
1370 if test -z "$cross_prefix" ; then
1371
1372 # ---
1373 # big/little endian test
1374 cat > $TMPC << EOF
1375 #include <inttypes.h>
1376 int main(void) {
1377         volatile uint32_t i=0x01234567;
1378         return (*((uint8_t*)(&i))) == 0x67;
1379 }
1380 EOF
1381
1382 if compile_prog "" "" ; then
1383 $TMPE && bigendian="yes"
1384 else
1385 echo big/little test failed
1386 fi
1387
1388 else
1389
1390 # if cross compiling, cannot launch a program, so make a static guess
1391 case "$cpu" in
1392   arm)
1393     # ARM can be either way; ask the compiler which one we are
1394     if check_define __ARMEB__; then
1395       bigendian=yes
1396     fi
1397   ;;
1398   hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1399     bigendian=yes
1400   ;;
1401 esac
1402
1403 fi
1404
1405 ##########################################
1406 # pkg-config probe
1407
1408 if ! has "$pkg_config_exe"; then
1409   error_exit "pkg-config binary '$pkg_config_exe' not found"
1410 fi
1411
1412 ##########################################
1413 # NPTL probe
1414
1415 if test "$nptl" != "no" ; then
1416   cat > $TMPC <<EOF
1417 #include <sched.h>
1418 #include <linux/futex.h>
1419 int main(void) {
1420 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1421 #error bork
1422 #endif
1423   return 0;
1424 }
1425 EOF
1426
1427   if compile_object ; then
1428     nptl=yes
1429   else
1430     if test "$nptl" = "yes" ; then
1431       feature_not_found "nptl"
1432     fi
1433     nptl=no
1434   fi
1435 fi
1436
1437 ##########################################
1438 # zlib check
1439
1440 if test "$zlib" != "no" ; then
1441     cat > $TMPC << EOF
1442 #include <zlib.h>
1443 int main(void) { zlibVersion(); return 0; }
1444 EOF
1445     if compile_prog "" "-lz" ; then
1446         :
1447     else
1448         error_exit "zlib check failed" \
1449             "Make sure to have the zlib libs and headers installed."
1450     fi
1451 fi
1452
1453 ##########################################
1454 # libseccomp check
1455
1456 if test "$seccomp" != "no" ; then
1457     if $pkg_config --atleast-version=1.0.0 libseccomp --modversion >/dev/null 2>&1; then
1458         libs_softmmu="$libs_softmmu `$pkg_config --libs libseccomp`"
1459         seccomp="yes"
1460     else
1461         if test "$seccomp" = "yes"; then
1462             feature_not_found "libseccomp"
1463         fi
1464         seccomp="no"
1465     fi
1466 fi
1467 ##########################################
1468 # xen probe
1469
1470 if test "$xen" != "no" ; then
1471   xen_libs="-lxenstore -lxenctrl -lxenguest"
1472
1473   # First we test whether Xen headers and libraries are available.
1474   # If no, we are done and there is no Xen support.
1475   # If yes, more tests are run to detect the Xen version.
1476
1477   # Xen (any)
1478   cat > $TMPC <<EOF
1479 #include <xenctrl.h>
1480 int main(void) {
1481   return 0;
1482 }
1483 EOF
1484   if ! compile_prog "" "$xen_libs" ; then
1485     # Xen not found
1486     if test "$xen" = "yes" ; then
1487       feature_not_found "xen"
1488     fi
1489     xen=no
1490
1491   # Xen unstable
1492   elif
1493       cat > $TMPC <<EOF &&
1494 #include <xenctrl.h>
1495 #include <xenstore.h>
1496 #include <stdint.h>
1497 #include <xen/hvm/hvm_info_table.h>
1498 #if !defined(HVM_MAX_VCPUS)
1499 # error HVM_MAX_VCPUS not defined
1500 #endif
1501 int main(void) {
1502   xc_interface *xc;
1503   xs_daemon_open();
1504   xc = xc_interface_open(0, 0, 0);
1505   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1506   xc_gnttab_open(NULL, 0);
1507   xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1508   xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1509   return 0;
1510 }
1511 EOF
1512       compile_prog "" "$xen_libs"
1513     then
1514     xen_ctrl_version=420
1515     xen=yes
1516
1517   elif
1518       cat > $TMPC <<EOF &&
1519 #include <xenctrl.h>
1520 #include <xs.h>
1521 #include <stdint.h>
1522 #include <xen/hvm/hvm_info_table.h>
1523 #if !defined(HVM_MAX_VCPUS)
1524 # error HVM_MAX_VCPUS not defined
1525 #endif
1526 int main(void) {
1527   xs_daemon_open();
1528   xc_interface_open(0, 0, 0);
1529   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1530   xc_gnttab_open(NULL, 0);
1531   xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1532   return 0;
1533 }
1534 EOF
1535       compile_prog "" "$xen_libs"
1536     then
1537     xen_ctrl_version=410
1538     xen=yes
1539
1540   # Xen 4.0.0
1541   elif
1542       cat > $TMPC <<EOF &&
1543 #include <xenctrl.h>
1544 #include <xs.h>
1545 #include <stdint.h>
1546 #include <xen/hvm/hvm_info_table.h>
1547 #if !defined(HVM_MAX_VCPUS)
1548 # error HVM_MAX_VCPUS not defined
1549 #endif
1550 int main(void) {
1551   struct xen_add_to_physmap xatp = {
1552     .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1553   };
1554   xs_daemon_open();
1555   xc_interface_open();
1556   xc_gnttab_open();
1557   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1558   xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1559   return 0;
1560 }
1561 EOF
1562       compile_prog "" "$xen_libs"
1563     then
1564     xen_ctrl_version=400
1565     xen=yes
1566
1567   # Xen 3.4.0
1568   elif
1569       cat > $TMPC <<EOF &&
1570 #include <xenctrl.h>
1571 #include <xs.h>
1572 int main(void) {
1573   struct xen_add_to_physmap xatp = {
1574     .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1575   };
1576   xs_daemon_open();
1577   xc_interface_open();
1578   xc_gnttab_open();
1579   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1580   xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1581   return 0;
1582 }
1583 EOF
1584       compile_prog "" "$xen_libs"
1585     then
1586     xen_ctrl_version=340
1587     xen=yes
1588
1589   # Xen 3.3.0
1590   elif
1591       cat > $TMPC <<EOF &&
1592 #include <xenctrl.h>
1593 #include <xs.h>
1594 int main(void) {
1595   xs_daemon_open();
1596   xc_interface_open();
1597   xc_gnttab_open();
1598   xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1599   return 0;
1600 }
1601 EOF
1602       compile_prog "" "$xen_libs"
1603     then
1604     xen_ctrl_version=330
1605     xen=yes
1606
1607   # Xen version unsupported
1608   else
1609     if test "$xen" = "yes" ; then
1610       feature_not_found "xen (unsupported version)"
1611     fi
1612     xen=no
1613   fi
1614
1615   if test "$xen" = yes; then
1616     libs_softmmu="$xen_libs $libs_softmmu"
1617   fi
1618 fi
1619
1620 if test "$xen_pci_passthrough" != "no"; then
1621   if test "$xen" = "yes" && test "$linux" = "yes" &&
1622     test "$xen_ctrl_version" -ge 340; then
1623     xen_pci_passthrough=yes
1624   else
1625     if test "$xen_pci_passthrough" = "yes"; then
1626       if test "$xen_ctrl_version" -lt 340; then
1627         error_exit "User requested feature Xen PCI Passthrough" \
1628             "This feature does not work with Xen 3.3"
1629       fi
1630       error_exit "User requested feature Xen PCI Passthrough" \
1631           " but this feature requires /sys from Linux"
1632     fi
1633     xen_pci_passthrough=no
1634   fi
1635 fi
1636
1637 ##########################################
1638 # libtool probe
1639
1640 if ! has $libtool; then
1641     libtool=
1642 fi
1643
1644 ##########################################
1645 # Sparse probe
1646 if test "$sparse" != "no" ; then
1647   if has cgcc; then
1648     sparse=yes
1649   else
1650     if test "$sparse" = "yes" ; then
1651       feature_not_found "sparse"
1652     fi
1653     sparse=no
1654   fi
1655 fi
1656
1657 ##########################################
1658 # GTK probe
1659
1660 if test "$gtk" != "no"; then
1661     gtkpackage="gtk+-$gtkabi"
1662     if test "$gtkabi" = "3.0" ; then
1663       gtkversion="3.0.0"
1664       vtepackage="vte-2.90"
1665       vteversion="0.32.0"
1666     else
1667       gtkversion="2.18.0"
1668       vtepackage="vte"
1669       vteversion="0.24.0"
1670     fi
1671     if $pkg_config --exists "$gtkpackage >= $gtkversion" && \
1672        $pkg_config --exists "$vtepackage >= $vteversion"; then
1673         gtk_cflags=`$pkg_config --cflags $gtkpackage 2>/dev/null`
1674         gtk_libs=`$pkg_config --libs $gtkpackage 2>/dev/null`
1675         vte_cflags=`$pkg_config --cflags $vtepackage 2>/dev/null`
1676         vte_libs=`$pkg_config --libs $vtepackage 2>/dev/null`
1677         libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
1678         gtk="yes"
1679     else
1680         if test "$gtk" = "yes" ; then
1681             feature_not_found "gtk"
1682         fi
1683         gtk="no"
1684     fi
1685 fi
1686
1687 ##########################################
1688 # SDL probe
1689
1690 # Look for sdl configuration program (pkg-config or sdl-config).  Try
1691 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
1692 if test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
1693   sdl_config=sdl-config
1694 fi
1695
1696 if $pkg_config sdl --modversion >/dev/null 2>&1; then
1697   sdlconfig="$pkg_config sdl"
1698   _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1699 elif has ${sdl_config}; then
1700   sdlconfig="$sdl_config"
1701   _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1702 else
1703   if test "$sdl" = "yes" ; then
1704     feature_not_found "sdl"
1705   fi
1706   sdl=no
1707 fi
1708 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
1709   echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
1710 fi
1711
1712 sdl_too_old=no
1713 if test "$sdl" != "no" ; then
1714   cat > $TMPC << EOF
1715 #include <SDL.h>
1716 #undef main /* We don't want SDL to override our main() */
1717 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1718 EOF
1719   sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
1720   if test "$static" = "yes" ; then
1721     sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
1722   else
1723     sdl_libs=`$sdlconfig --libs 2> /dev/null`
1724   fi
1725   if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1726     if test "$_sdlversion" -lt 121 ; then
1727       sdl_too_old=yes
1728     else
1729       if test "$cocoa" = "no" ; then
1730         sdl=yes
1731       fi
1732     fi
1733
1734     # static link with sdl ? (note: sdl.pc's --static --libs is broken)
1735     if test "$sdl" = "yes" -a "$static" = "yes" ; then
1736       if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1737          sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1738          sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
1739       fi
1740       if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1741         :
1742       else
1743         sdl=no
1744       fi
1745     fi # static link
1746   else # sdl not found
1747     if test "$sdl" = "yes" ; then
1748       feature_not_found "sdl"
1749     fi
1750     sdl=no
1751   fi # sdl compile test
1752 fi
1753
1754 if test "$sdl" = "yes" ; then
1755   cat > $TMPC <<EOF
1756 #include <SDL.h>
1757 #if defined(SDL_VIDEO_DRIVER_X11)
1758 #include <X11/XKBlib.h>
1759 #else
1760 #error No x11 support
1761 #endif
1762 int main(void) { return 0; }
1763 EOF
1764   if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1765     sdl_libs="$sdl_libs -lX11"
1766   fi
1767   libs_softmmu="$sdl_libs $libs_softmmu"
1768 fi
1769
1770 ##########################################
1771 # VNC TLS/WS detection
1772 if test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then
1773   cat > $TMPC <<EOF
1774 #include <gnutls/gnutls.h>
1775 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1776 EOF
1777   vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1778   vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
1779   if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1780     if test "$vnc_tls" != "no" ; then
1781       vnc_tls=yes
1782     fi
1783     if test "$vnc_ws" != "no" ; then
1784       vnc_ws=yes
1785     fi
1786     libs_softmmu="$vnc_tls_libs $libs_softmmu"
1787     QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
1788   else
1789     if test "$vnc_tls" = "yes" ; then
1790       feature_not_found "vnc-tls"
1791     fi
1792     if test "$vnc_ws" = "yes" ; then
1793       feature_not_found "vnc-ws"
1794     fi
1795     vnc_tls=no
1796     vnc_ws=no
1797   fi
1798 fi
1799
1800 ##########################################
1801 # VNC SASL detection
1802 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
1803   cat > $TMPC <<EOF
1804 #include <sasl/sasl.h>
1805 #include <stdio.h>
1806 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1807 EOF
1808   # Assuming Cyrus-SASL installed in /usr prefix
1809   vnc_sasl_cflags=""
1810   vnc_sasl_libs="-lsasl2"
1811   if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1812     vnc_sasl=yes
1813     libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1814     QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
1815   else
1816     if test "$vnc_sasl" = "yes" ; then
1817       feature_not_found "vnc-sasl"
1818     fi
1819     vnc_sasl=no
1820   fi
1821 fi
1822
1823 ##########################################
1824 # VNC JPEG detection
1825 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
1826 cat > $TMPC <<EOF
1827 #include <stdio.h>
1828 #include <jpeglib.h>
1829 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
1830 EOF
1831     vnc_jpeg_cflags=""
1832     vnc_jpeg_libs="-ljpeg"
1833   if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
1834     vnc_jpeg=yes
1835     libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1836     QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
1837   else
1838     if test "$vnc_jpeg" = "yes" ; then
1839       feature_not_found "vnc-jpeg"
1840     fi
1841     vnc_jpeg=no
1842   fi
1843 fi
1844
1845 ##########################################
1846 # VNC PNG detection
1847 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1848 cat > $TMPC <<EOF
1849 //#include <stdio.h>
1850 #include <png.h>
1851 #include <stddef.h>
1852 int main(void) {
1853     png_structp png_ptr;
1854     png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1855     return png_ptr != 0;
1856 }
1857 EOF
1858   if $pkg_config libpng --modversion >/dev/null 2>&1; then
1859     vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
1860     vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
1861   else
1862     vnc_png_cflags=""
1863     vnc_png_libs="-lpng"
1864   fi
1865   if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1866     vnc_png=yes
1867     libs_softmmu="$vnc_png_libs $libs_softmmu"
1868     QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1869   else
1870     if test "$vnc_png" = "yes" ; then
1871       feature_not_found "vnc-png"
1872     fi
1873     vnc_png=no
1874   fi
1875 fi
1876
1877 ##########################################
1878 # fnmatch() probe, used for ACL routines
1879 fnmatch="no"
1880 cat > $TMPC << EOF
1881 #include <fnmatch.h>
1882 int main(void)
1883 {
1884     fnmatch("foo", "foo", 0);
1885     return 0;
1886 }
1887 EOF
1888 if compile_prog "" "" ; then
1889    fnmatch="yes"
1890 fi
1891
1892 ##########################################
1893 # uuid_generate() probe, used for vdi block driver
1894 if test "$uuid" != "no" ; then
1895   uuid_libs="-luuid"
1896   cat > $TMPC << EOF
1897 #include <uuid/uuid.h>
1898 int main(void)
1899 {
1900     uuid_t my_uuid;
1901     uuid_generate(my_uuid);
1902     return 0;
1903 }
1904 EOF
1905   if compile_prog "" "$uuid_libs" ; then
1906     uuid="yes"
1907     libs_softmmu="$uuid_libs $libs_softmmu"
1908     libs_tools="$uuid_libs $libs_tools"
1909   else
1910     if test "$uuid" = "yes" ; then
1911       feature_not_found "uuid"
1912     fi
1913     uuid=no
1914   fi
1915 fi
1916
1917 ##########################################
1918 # xfsctl() probe, used for raw-posix
1919 if test "$xfs" != "no" ; then
1920   cat > $TMPC << EOF
1921 #include <stddef.h>  /* NULL */
1922 #include <xfs/xfs.h>
1923 int main(void)
1924 {
1925     xfsctl(NULL, 0, 0, NULL);
1926     return 0;
1927 }
1928 EOF
1929   if compile_prog "" "" ; then
1930     xfs="yes"
1931   else
1932     if test "$xfs" = "yes" ; then
1933       feature_not_found "xfs"
1934     fi
1935     xfs=no
1936   fi
1937 fi
1938
1939 ##########################################
1940 # vde libraries probe
1941 if test "$vde" != "no" ; then
1942   vde_libs="-lvdeplug"
1943   cat > $TMPC << EOF
1944 #include <libvdeplug.h>
1945 int main(void)
1946 {
1947     struct vde_open_args a = {0, 0, 0};
1948     char s[] = "";
1949     vde_open(s, s, &a);
1950     return 0;
1951 }
1952 EOF
1953   if compile_prog "" "$vde_libs" ; then
1954     vde=yes
1955     libs_softmmu="$vde_libs $libs_softmmu"
1956     libs_tools="$vde_libs $libs_tools"
1957   else
1958     if test "$vde" = "yes" ; then
1959       feature_not_found "vde"
1960     fi
1961     vde=no
1962   fi
1963 fi
1964
1965 ##########################################
1966 # libcap-ng library probe
1967 if test "$cap_ng" != "no" ; then
1968   cap_libs="-lcap-ng"
1969   cat > $TMPC << EOF
1970 #include <cap-ng.h>
1971 int main(void)
1972 {
1973     capng_capability_to_name(CAPNG_EFFECTIVE);
1974     return 0;
1975 }
1976 EOF
1977   if compile_prog "" "$cap_libs" ; then
1978     cap_ng=yes
1979     libs_tools="$cap_libs $libs_tools"
1980   else
1981     if test "$cap_ng" = "yes" ; then
1982       feature_not_found "cap_ng"
1983     fi
1984     cap_ng=no
1985   fi
1986 fi
1987
1988 ##########################################
1989 # Sound support libraries probe
1990
1991 audio_drv_probe()
1992 {
1993     drv=$1
1994     hdr=$2
1995     lib=$3
1996     exp=$4
1997     cfl=$5
1998         cat > $TMPC << EOF
1999 #include <$hdr>
2000 int main(void) { $exp }
2001 EOF
2002     if compile_prog "$cfl" "$lib" ; then
2003         :
2004     else
2005         error_exit "$drv check failed" \
2006             "Make sure to have the $drv libs and headers installed."
2007     fi
2008 }
2009
2010 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
2011 for drv in $audio_drv_list; do
2012     case $drv in
2013     alsa)
2014     audio_drv_probe $drv alsa/asoundlib.h -lasound \
2015         "return snd_pcm_close((snd_pcm_t *)0);"
2016     libs_softmmu="-lasound $libs_softmmu"
2017     ;;
2018
2019     fmod)
2020     if test -z $fmod_lib || test -z $fmod_inc; then
2021         error_exit "You must specify path to FMOD library and headers" \
2022             "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
2023     fi
2024     audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
2025     libs_softmmu="$fmod_lib $libs_softmmu"
2026     ;;
2027
2028     esd)
2029     audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
2030     libs_softmmu="-lesd $libs_softmmu"
2031     audio_pt_int="yes"
2032     ;;
2033
2034     pa)
2035     audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
2036         "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
2037     libs_softmmu="-lpulse $libs_softmmu"
2038     audio_pt_int="yes"
2039     ;;
2040
2041     coreaudio)
2042       libs_softmmu="-framework CoreAudio $libs_softmmu"
2043     ;;
2044
2045     dsound)
2046       libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2047       audio_win_int="yes"
2048     ;;
2049
2050     oss)
2051       libs_softmmu="$oss_lib $libs_softmmu"
2052     ;;
2053
2054     sdl|wav)
2055     # XXX: Probes for CoreAudio, DirectSound, SDL(?)
2056     ;;
2057
2058     winwave)
2059       libs_softmmu="-lwinmm $libs_softmmu"
2060       audio_win_int="yes"
2061     ;;
2062
2063     *)
2064     echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
2065         error_exit "Unknown driver '$drv' selected" \
2066             "Possible drivers are: $audio_possible_drivers"
2067     }
2068     ;;
2069     esac
2070 done
2071
2072 ##########################################
2073 # BrlAPI probe
2074
2075 if test "$brlapi" != "no" ; then
2076   brlapi_libs="-lbrlapi"
2077   cat > $TMPC << EOF
2078 #include <brlapi.h>
2079 #include <stddef.h>
2080 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
2081 EOF
2082   if compile_prog "" "$brlapi_libs" ; then
2083     brlapi=yes
2084     libs_softmmu="$brlapi_libs $libs_softmmu"
2085   else
2086     if test "$brlapi" = "yes" ; then
2087       feature_not_found "brlapi"
2088     fi
2089     brlapi=no
2090   fi
2091 fi
2092
2093 ##########################################
2094 # curses probe
2095 if test "$mingw32" = "yes" ; then
2096     curses_list="-lpdcurses"
2097 else
2098     curses_list="-lncurses:-lcurses:$($pkg_config --libs ncurses 2>/dev/null)"
2099 fi
2100
2101 if test "$curses" != "no" ; then
2102   curses_found=no
2103   cat > $TMPC << EOF
2104 #include <curses.h>
2105 int main(void) {
2106   const char *s = curses_version();
2107   resize_term(0, 0);
2108   return s != 0;
2109 }
2110 EOF
2111   IFS=:
2112   for curses_lib in $curses_list; do
2113     unset IFS
2114     if compile_prog "" "$curses_lib" ; then
2115       curses_found=yes
2116       libs_softmmu="$curses_lib $libs_softmmu"
2117       break
2118     fi
2119   done
2120   unset IFS
2121   if test "$curses_found" = "yes" ; then
2122     curses=yes
2123   else
2124     if test "$curses" = "yes" ; then
2125       feature_not_found "curses"
2126     fi
2127     curses=no
2128   fi
2129 fi
2130
2131 ##########################################
2132 # curl probe
2133
2134 if $pkg_config libcurl --modversion >/dev/null 2>&1; then
2135   curlconfig="$pkg_config libcurl"
2136 else
2137   curlconfig=curl-config
2138 fi
2139
2140 if test "$curl" != "no" ; then
2141   cat > $TMPC << EOF
2142 #include <curl/curl.h>
2143 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2144 EOF
2145   curl_cflags=`$curlconfig --cflags 2>/dev/null`
2146   curl_libs=`$curlconfig --libs 2>/dev/null`
2147   if compile_prog "$curl_cflags" "$curl_libs" ; then
2148     curl=yes
2149     libs_tools="$curl_libs $libs_tools"
2150     libs_softmmu="$curl_libs $libs_softmmu"
2151   else
2152     if test "$curl" = "yes" ; then
2153       feature_not_found "curl"
2154     fi
2155     curl=no
2156   fi
2157 fi # test "$curl"
2158
2159 ##########################################
2160 # bluez support probe
2161 if test "$bluez" != "no" ; then
2162   cat > $TMPC << EOF
2163 #include <bluetooth/bluetooth.h>
2164 int main(void) { return bt_error(0); }
2165 EOF
2166   bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2167   bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
2168   if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2169     bluez=yes
2170     libs_softmmu="$bluez_libs $libs_softmmu"
2171   else
2172     if test "$bluez" = "yes" ; then
2173       feature_not_found "bluez"
2174     fi
2175     bluez="no"
2176   fi
2177 fi
2178
2179 ##########################################
2180 # glib support probe
2181
2182 if test "$mingw32" = yes; then
2183     # g_poll is required in order to integrate with the glib main loop.
2184     glib_req_ver=2.20
2185 else
2186     glib_req_ver=2.12
2187 fi
2188 if $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
2189 then
2190     glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
2191     glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
2192     LIBS="$glib_libs $LIBS"
2193     libs_qga="$glib_libs $libs_qga"
2194 else
2195     error_exit "glib-$glib_req_ver required to compile QEMU"
2196 fi
2197
2198 ##########################################
2199 # pixman support probe
2200
2201 if test "$pixman" = ""; then
2202   if test "$want_tools" = "no" -a "$softmmu" = "no"; then
2203     pixman="none"
2204   elif $pkg_config pixman-1 > /dev/null 2>&1; then
2205     pixman="system"
2206   else
2207     pixman="internal"
2208   fi
2209 fi
2210 if test "$pixman" = "none"; then
2211   if test "$want_tools" != "no" -o "$softmmu" != "no"; then
2212     error_exit "pixman disabled but system emulation or tools build" \
2213         "enabled.  You can turn off pixman only if you also" \
2214         "disable all system emulation targets and the tools" \
2215         "build with '--disable-tools --disable-system'."
2216   fi
2217   pixman_cflags=
2218   pixman_libs=
2219 elif test "$pixman" = "system"; then
2220   pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null`
2221   pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null`
2222 else
2223   if test ! -d ${source_path}/pixman/pixman; then
2224     error_exit "pixman not present. Your options:" \
2225         "  (1) Preferred: Install the pixman devel package (any recent" \
2226         "      distro should have packages as Xorg needs pixman too)." \
2227         "  (2) Fetch the pixman submodule, using:" \
2228         "      git submodule update --init pixman"
2229   fi
2230   mkdir -p pixman/pixman
2231   pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
2232   pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2233 fi
2234
2235 ##########################################
2236 # libcap probe
2237
2238 if test "$cap" != "no" ; then
2239   cat > $TMPC <<EOF
2240 #include <stdio.h>
2241 #include <sys/capability.h>
2242 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
2243 EOF
2244   if compile_prog "" "-lcap" ; then
2245     cap=yes
2246   else
2247     cap=no
2248   fi
2249 fi
2250
2251 ##########################################
2252 # pthread probe
2253 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
2254
2255 pthread=no
2256 cat > $TMPC << EOF
2257 #include <pthread.h>
2258 static void *f(void *p) { return NULL; }
2259 int main(void) {
2260   pthread_t thread;
2261   pthread_create(&thread, 0, f, 0);
2262   return 0;
2263 }
2264 EOF
2265 if compile_prog "" "" ; then
2266   pthread=yes
2267 else
2268   for pthread_lib in $PTHREADLIBS_LIST; do
2269     if compile_prog "" "$pthread_lib" ; then
2270       pthread=yes
2271       found=no
2272       for lib_entry in $LIBS; do
2273         if test "$lib_entry" = "$pthread_lib"; then
2274           found=yes
2275           break
2276         fi
2277       done
2278       if test "$found" = "no"; then
2279         LIBS="$pthread_lib $LIBS"
2280       fi
2281       break
2282     fi
2283   done
2284 fi
2285
2286 if test "$mingw32" != yes -a "$pthread" = no; then
2287   error_exit "pthread check failed" \
2288       "Make sure to have the pthread libs and headers installed."
2289 fi
2290
2291 ##########################################
2292 # rbd probe
2293 if test "$rbd" != "no" ; then
2294   cat > $TMPC <<EOF
2295 #include <stdio.h>
2296 #include <rbd/librbd.h>
2297 int main(void) {
2298     rados_t cluster;
2299     rados_create(&cluster, NULL);
2300     return 0;
2301 }
2302 EOF
2303   rbd_libs="-lrbd -lrados"
2304   if compile_prog "" "$rbd_libs" ; then
2305     rbd=yes
2306     libs_tools="$rbd_libs $libs_tools"
2307     libs_softmmu="$rbd_libs $libs_softmmu"
2308   else
2309     if test "$rbd" = "yes" ; then
2310       feature_not_found "rados block device"
2311     fi
2312     rbd=no
2313   fi
2314 fi
2315
2316 ##########################################
2317 # linux-aio probe
2318
2319 if test "$linux_aio" != "no" ; then
2320   cat > $TMPC <<EOF
2321 #include <libaio.h>
2322 #include <sys/eventfd.h>
2323 #include <stddef.h>
2324 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
2325 EOF
2326   if compile_prog "" "-laio" ; then
2327     linux_aio=yes
2328     libs_softmmu="$libs_softmmu -laio"
2329     libs_tools="$libs_tools -laio"
2330   else
2331     if test "$linux_aio" = "yes" ; then
2332       feature_not_found "linux AIO"
2333     fi
2334     linux_aio=no
2335   fi
2336 fi
2337
2338 ##########################################
2339 # adjust virtio-blk-data-plane based on linux-aio
2340
2341 if test "$virtio_blk_data_plane" = "yes" -a \
2342         "$linux_aio" != "yes" ; then
2343   error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
2344 elif test -z "$virtio_blk_data_plane" ; then
2345   virtio_blk_data_plane=$linux_aio
2346 fi
2347
2348 ##########################################
2349 # attr probe
2350
2351 if test "$attr" != "no" ; then
2352   cat > $TMPC <<EOF
2353 #include <stdio.h>
2354 #include <sys/types.h>
2355 #ifdef CONFIG_LIBATTR
2356 #include <attr/xattr.h>
2357 #else
2358 #include <sys/xattr.h>
2359 #endif
2360 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2361 EOF
2362   if compile_prog "" "" ; then
2363     attr=yes
2364   # Older distros have <attr/xattr.h>, and need -lattr:
2365   elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2366     attr=yes
2367     LIBS="-lattr $LIBS"
2368     libattr=yes
2369   else
2370     if test "$attr" = "yes" ; then
2371       feature_not_found "ATTR"
2372     fi
2373     attr=no
2374   fi
2375 fi
2376
2377 ##########################################
2378 # iovec probe
2379 cat > $TMPC <<EOF
2380 #include <sys/types.h>
2381 #include <sys/uio.h>
2382 #include <unistd.h>
2383 int main(void) { return sizeof(struct iovec); }
2384 EOF
2385 iovec=no
2386 if compile_prog "" "" ; then
2387   iovec=yes
2388 fi
2389
2390 ##########################################
2391 # preadv probe
2392 cat > $TMPC <<EOF
2393 #include <sys/types.h>
2394 #include <sys/uio.h>
2395 #include <unistd.h>
2396 int main(void) { return preadv(0, 0, 0, 0); }
2397 EOF
2398 preadv=no
2399 if compile_prog "" "" ; then
2400   preadv=yes
2401 fi
2402
2403 ##########################################
2404 # fdt probe
2405 if test "$fdt" != "no" ; then
2406   fdt_libs="-lfdt"
2407   cat > $TMPC << EOF
2408 int main(void) { return 0; }
2409 EOF
2410   if compile_prog "" "$fdt_libs" ; then
2411     fdt=yes
2412     libs_softmmu="$libs_softmmu $fdt_libs"
2413   else
2414     if test "$fdt" = "yes" ; then
2415       feature_not_found "fdt"
2416     fi
2417     fdt_libs=
2418     fdt=no
2419   fi
2420 fi
2421
2422 ##########################################
2423 # GLX probe, used by milkymist-tmu2
2424 if test "$glx" != "no" ; then
2425   glx_libs="-lGL -lX11"
2426   cat > $TMPC << EOF
2427 #include <X11/Xlib.h>
2428 #include <GL/gl.h>
2429 #include <GL/glx.h>
2430 int main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
2431 EOF
2432   if compile_prog "" "-lGL -lX11" ; then
2433     glx=yes
2434   else
2435     if test "$glx" = "yes" ; then
2436       feature_not_found "glx"
2437     fi
2438     glx_libs=
2439     glx=no
2440   fi
2441 fi
2442
2443 ##########################################
2444 # glusterfs probe
2445 if test "$glusterfs" != "no" ; then
2446   cat > $TMPC <<EOF
2447 #include <glusterfs/api/glfs.h>
2448 int main(void) {
2449     (void) glfs_new("volume");
2450     return 0;
2451 }
2452 EOF
2453   glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
2454   if compile_prog "" "$glusterfs_libs" ; then
2455     glusterfs=yes
2456     libs_tools="$glusterfs_libs $libs_tools"
2457     libs_softmmu="$glusterfs_libs $libs_softmmu"
2458   else
2459     if test "$glusterfs" = "yes" ; then
2460       feature_not_found "GlusterFS backend support"
2461     fi
2462     glusterfs=no
2463   fi
2464 fi
2465
2466 #
2467 # Check for xxxat() functions when we are building linux-user
2468 # emulator.  This is done because older glibc versions don't
2469 # have syscall stubs for these implemented.
2470 #
2471 atfile=no
2472 cat > $TMPC << EOF
2473 #define _ATFILE_SOURCE
2474 #include <sys/types.h>
2475 #include <fcntl.h>
2476 #include <unistd.h>
2477
2478 int
2479 main(void)
2480 {
2481         /* try to unlink nonexisting file */
2482         return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
2483 }
2484 EOF
2485 if compile_prog "" "" ; then
2486   atfile=yes
2487 fi
2488
2489 # Check for inotify functions when we are building linux-user
2490 # emulator.  This is done because older glibc versions don't
2491 # have syscall stubs for these implemented.  In that case we
2492 # don't provide them even if kernel supports them.
2493 #
2494 inotify=no
2495 cat > $TMPC << EOF
2496 #include <sys/inotify.h>
2497
2498 int
2499 main(void)
2500 {
2501         /* try to start inotify */
2502         return inotify_init();
2503 }
2504 EOF
2505 if compile_prog "" "" ; then
2506   inotify=yes
2507 fi
2508
2509 inotify1=no
2510 cat > $TMPC << EOF
2511 #include <sys/inotify.h>
2512
2513 int
2514 main(void)
2515 {
2516     /* try to start inotify */
2517     return inotify_init1(0);
2518 }
2519 EOF
2520 if compile_prog "" "" ; then
2521   inotify1=yes
2522 fi
2523
2524 # check if utimensat and futimens are supported
2525 utimens=no
2526 cat > $TMPC << EOF
2527 #define _ATFILE_SOURCE
2528 #include <stddef.h>
2529 #include <fcntl.h>
2530 #include <sys/stat.h>
2531
2532 int main(void)
2533 {
2534     utimensat(AT_FDCWD, "foo", NULL, 0);
2535     futimens(0, NULL);
2536     return 0;
2537 }
2538 EOF
2539 if compile_prog "" "" ; then
2540   utimens=yes
2541 fi
2542
2543 # check if pipe2 is there
2544 pipe2=no
2545 cat > $TMPC << EOF
2546 #include <unistd.h>
2547 #include <fcntl.h>
2548
2549 int main(void)
2550 {
2551     int pipefd[2];
2552     return pipe2(pipefd, O_CLOEXEC);
2553 }
2554 EOF
2555 if compile_prog "" "" ; then
2556   pipe2=yes
2557 fi
2558
2559 # check if accept4 is there
2560 accept4=no
2561 cat > $TMPC << EOF
2562 #include <sys/socket.h>
2563 #include <stddef.h>
2564
2565 int main(void)
2566 {
2567     accept4(0, NULL, NULL, SOCK_CLOEXEC);
2568     return 0;
2569 }
2570 EOF
2571 if compile_prog "" "" ; then
2572   accept4=yes
2573 fi
2574
2575 # check if tee/splice is there. vmsplice was added same time.
2576 splice=no
2577 cat > $TMPC << EOF
2578 #include <unistd.h>
2579 #include <fcntl.h>
2580 #include <limits.h>
2581
2582 int main(void)
2583 {
2584     int len, fd = 0;
2585     len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
2586     splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
2587     return 0;
2588 }
2589 EOF
2590 if compile_prog "" "" ; then
2591   splice=yes
2592 fi
2593
2594 ##########################################
2595 # signalfd probe
2596 signalfd="no"
2597 cat > $TMPC << EOF
2598 #include <unistd.h>
2599 #include <sys/syscall.h>
2600 #include <signal.h>
2601 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2602 EOF
2603
2604 if compile_prog "" "" ; then
2605   signalfd=yes
2606 fi
2607
2608 # check if eventfd is supported
2609 eventfd=no
2610 cat > $TMPC << EOF
2611 #include <sys/eventfd.h>
2612
2613 int main(void)
2614 {
2615     return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2616 }
2617 EOF
2618 if compile_prog "" "" ; then
2619   eventfd=yes
2620 fi
2621
2622 # check for fallocate
2623 fallocate=no
2624 cat > $TMPC << EOF
2625 #include <fcntl.h>
2626
2627 int main(void)
2628 {
2629     fallocate(0, 0, 0, 0);
2630     return 0;
2631 }
2632 EOF
2633 if compile_prog "" "" ; then
2634   fallocate=yes
2635 fi
2636
2637 # check for fallocate hole punching
2638 fallocate_punch_hole=no
2639 cat > $TMPC << EOF
2640 #include <fcntl.h>
2641 #include <linux/falloc.h>
2642
2643 int main(void)
2644 {
2645     fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
2646     return 0;
2647 }
2648 EOF
2649 if compile_prog "" "" ; then
2650   fallocate_punch_hole=yes
2651 fi
2652
2653 # check for sync_file_range
2654 sync_file_range=no
2655 cat > $TMPC << EOF
2656 #include <fcntl.h>
2657
2658 int main(void)
2659 {
2660     sync_file_range(0, 0, 0, 0);
2661     return 0;
2662 }
2663 EOF
2664 if compile_prog "" "" ; then
2665   sync_file_range=yes
2666 fi
2667
2668 # check for linux/fiemap.h and FS_IOC_FIEMAP
2669 fiemap=no
2670 cat > $TMPC << EOF
2671 #include <sys/ioctl.h>
2672 #include <linux/fs.h>
2673 #include <linux/fiemap.h>
2674
2675 int main(void)
2676 {
2677     ioctl(0, FS_IOC_FIEMAP, 0);
2678     return 0;
2679 }
2680 EOF
2681 if compile_prog "" "" ; then
2682   fiemap=yes
2683 fi
2684
2685 # check for dup3
2686 dup3=no
2687 cat > $TMPC << EOF
2688 #include <unistd.h>
2689
2690 int main(void)
2691 {
2692     dup3(0, 0, 0);
2693     return 0;
2694 }
2695 EOF
2696 if compile_prog "" "" ; then
2697   dup3=yes
2698 fi
2699
2700 # check for epoll support
2701 epoll=no
2702 cat > $TMPC << EOF
2703 #include <sys/epoll.h>
2704
2705 int main(void)
2706 {
2707     epoll_create(0);
2708     return 0;
2709 }
2710 EOF
2711 if compile_prog "" "" ; then
2712   epoll=yes
2713 fi
2714
2715 # epoll_create1 and epoll_pwait are later additions
2716 # so we must check separately for their presence
2717 epoll_create1=no
2718 cat > $TMPC << EOF
2719 #include <sys/epoll.h>
2720
2721 int main(void)
2722 {
2723     /* Note that we use epoll_create1 as a value, not as
2724      * a function being called. This is necessary so that on
2725      * old SPARC glibc versions where the function was present in
2726      * the library but not declared in the header file we will
2727      * fail the configure check. (Otherwise we will get a compiler
2728      * warning but not an error, and will proceed to fail the
2729      * qemu compile where we compile with -Werror.)
2730      */
2731     return (int)(uintptr_t)&epoll_create1;
2732 }
2733 EOF
2734 if compile_prog "" "" ; then
2735   epoll_create1=yes
2736 fi
2737
2738 epoll_pwait=no
2739 cat > $TMPC << EOF
2740 #include <sys/epoll.h>
2741
2742 int main(void)
2743 {
2744     epoll_pwait(0, 0, 0, 0, 0);
2745     return 0;
2746 }
2747 EOF
2748 if compile_prog "" "" ; then
2749   epoll_pwait=yes
2750 fi
2751
2752 # check for sendfile support
2753 sendfile=no
2754 cat > $TMPC << EOF
2755 #include <sys/sendfile.h>
2756
2757 int main(void)
2758 {
2759     return sendfile(0, 0, 0, 0);
2760 }
2761 EOF
2762 if compile_prog "" "" ; then
2763   sendfile=yes
2764 fi
2765
2766 # Check if tools are available to build documentation.
2767 if test "$docs" != "no" ; then
2768   if has makeinfo && has pod2man; then
2769     docs=yes
2770   else
2771     if test "$docs" = "yes" ; then
2772       feature_not_found "docs"
2773     fi
2774     docs=no
2775   fi
2776 fi
2777
2778 # Search for bswap_32 function
2779 byteswap_h=no
2780 cat > $TMPC << EOF
2781 #include <byteswap.h>
2782 int main(void) { return bswap_32(0); }
2783 EOF
2784 if compile_prog "" "" ; then
2785   byteswap_h=yes
2786 fi
2787
2788 # Search for bswap32 function
2789 bswap_h=no
2790 cat > $TMPC << EOF
2791 #include <sys/endian.h>
2792 #include <sys/types.h>
2793 #include <machine/bswap.h>
2794 int main(void) { return bswap32(0); }
2795 EOF
2796 if compile_prog "" "" ; then
2797   bswap_h=yes
2798 fi
2799
2800 ##########################################
2801 # Do we have libiscsi
2802 # We check for iscsi_unmap_sync() to make sure we have a
2803 # recent enough version of libiscsi.
2804 if test "$libiscsi" != "no" ; then
2805   cat > $TMPC << EOF
2806 #include <stdio.h>
2807 #include <iscsi/iscsi.h>
2808 int main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2809 EOF
2810   if $pkg_config --atleast-version=1.7.0 libiscsi --modversion >/dev/null 2>&1; then
2811     libiscsi="yes"
2812     libiscsi_cflags=$($pkg_config --cflags libiscsi 2>/dev/null)
2813     libiscsi_libs=$($pkg_config --libs libiscsi 2>/dev/null)
2814     CFLAGS="$CFLAGS $libiscsi_cflags"
2815     LIBS="$LIBS $libiscsi_libs"
2816   elif compile_prog "" "-liscsi" ; then
2817     libiscsi="yes"
2818     LIBS="$LIBS -liscsi"
2819   else
2820     if test "$libiscsi" = "yes" ; then
2821       feature_not_found "libiscsi"
2822     fi
2823     libiscsi="no"
2824   fi
2825 fi
2826
2827
2828 ##########################################
2829 # Do we need libm
2830 cat > $TMPC << EOF
2831 #include <math.h>
2832 int main(void) { return isnan(sin(0.0)); }
2833 EOF
2834 if compile_prog "" "" ; then
2835   :
2836 elif compile_prog "" "-lm" ; then
2837   LIBS="-lm $LIBS"
2838   libs_qga="-lm $libs_qga"
2839 else
2840   error_exit "libm check failed"
2841 fi
2842
2843 ##########################################
2844 # Do we need librt
2845 # uClibc provides 2 versions of clock_gettime(), one with realtime
2846 # support and one without. This means that the clock_gettime() don't
2847 # need -lrt. We still need it for timer_create() so we check for this
2848 # function in addition.
2849 cat > $TMPC <<EOF
2850 #include <signal.h>
2851 #include <time.h>
2852 int main(void) {
2853   timer_create(CLOCK_REALTIME, NULL, NULL);
2854   return clock_gettime(CLOCK_REALTIME, NULL);
2855 }
2856 EOF
2857
2858 if compile_prog "" "" ; then
2859   :
2860 # we need pthread for static linking. use previous pthread test result
2861 elif compile_prog "" "-lrt $pthread_lib" ; then
2862   LIBS="-lrt $LIBS"
2863   libs_qga="-lrt $libs_qga"
2864 fi
2865
2866 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2867         "$aix" != "yes" -a "$haiku" != "yes" ; then
2868     libs_softmmu="-lutil $libs_softmmu"
2869 fi
2870
2871 ##########################################
2872 # spice probe
2873 if test "$spice" != "no" ; then
2874   cat > $TMPC << EOF
2875 #include <spice.h>
2876 int main(void) { spice_server_new(); return 0; }
2877 EOF
2878   spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2879   spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2880   if $pkg_config --atleast-version=0.12.0 spice-server >/dev/null 2>&1 && \
2881      $pkg_config --atleast-version=0.12.3 spice-protocol > /dev/null 2>&1 && \
2882      compile_prog "$spice_cflags" "$spice_libs" ; then
2883     spice="yes"
2884     libs_softmmu="$libs_softmmu $spice_libs"
2885     QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2886     spice_protocol_version=$($pkg_config --modversion spice-protocol)
2887     spice_server_version=$($pkg_config --modversion spice-server)
2888   else
2889     if test "$spice" = "yes" ; then
2890       feature_not_found "spice"
2891     fi
2892     spice="no"
2893   fi
2894 fi
2895
2896 # check for libcacard for smartcard support
2897 smartcard_cflags=""
2898 # TODO - what's the minimal nss version we support?
2899 if test "$smartcard_nss" != "no"; then
2900   cat > $TMPC << EOF
2901 #include <pk11pub.h>
2902 int main(void) { PK11_FreeSlot(0); return 0; }
2903 EOF
2904     smartcard_includes="-I\$(SRC_PATH)/libcacard"
2905     libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
2906     libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
2907     test_cflags="$libcacard_cflags"
2908     # The header files in nss < 3.13.3 have a bug which causes them to
2909     # emit a warning. If we're going to compile QEMU with -Werror, then
2910     # test that the headers don't have this bug. Otherwise we would pass
2911     # the configure test but fail to compile QEMU later.
2912     if test "$werror" = "yes"; then
2913         test_cflags="-Werror $test_cflags"
2914     fi
2915     if test -n "$libtool" &&
2916             $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
2917       compile_prog "$test_cflags" "$libcacard_libs"; then
2918         smartcard_nss="yes"
2919         QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
2920         QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
2921         libs_softmmu="$libcacard_libs $libs_softmmu"
2922     else
2923         if test "$smartcard_nss" = "yes"; then
2924             feature_not_found "nss"
2925         fi
2926         smartcard_nss="no"
2927     fi
2928 fi
2929
2930 # check for usbredirparser for usb network redirection support
2931 if test "$usb_redir" != "no" ; then
2932     if $pkg_config --atleast-version=0.6 libusbredirparser-0.5 >/dev/null 2>&1 ; then
2933         usb_redir="yes"
2934         usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5 2>/dev/null)
2935         usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5 2>/dev/null)
2936         QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
2937         libs_softmmu="$libs_softmmu $usb_redir_libs"
2938     else
2939         if test "$usb_redir" = "yes"; then
2940             feature_not_found "usb-redir"
2941         fi
2942         usb_redir="no"
2943     fi
2944 fi
2945
2946 ##########################################
2947
2948 ##########################################
2949 # check if we have fdatasync
2950
2951 fdatasync=no
2952 cat > $TMPC << EOF
2953 #include <unistd.h>
2954 int main(void) {
2955 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2956 return fdatasync(0);
2957 #else
2958 #error Not supported
2959 #endif
2960 }
2961 EOF
2962 if compile_prog "" "" ; then
2963     fdatasync=yes
2964 fi
2965
2966 ##########################################
2967 # check if we have madvise
2968
2969 madvise=no
2970 cat > $TMPC << EOF
2971 #include <sys/types.h>
2972 #include <sys/mman.h>
2973 #include <stddef.h>
2974 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2975 EOF
2976 if compile_prog "" "" ; then
2977     madvise=yes
2978 fi
2979
2980 ##########################################
2981 # check if we have posix_madvise
2982
2983 posix_madvise=no
2984 cat > $TMPC << EOF
2985 #include <sys/mman.h>
2986 #include <stddef.h>
2987 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2988 EOF
2989 if compile_prog "" "" ; then
2990     posix_madvise=yes
2991 fi
2992
2993 ##########################################
2994 # check if we have usable SIGEV_THREAD_ID
2995
2996 sigev_thread_id=no
2997 cat > $TMPC << EOF
2998 #include <signal.h>
2999 int main(void) {
3000   struct sigevent ev;
3001   ev.sigev_notify = SIGEV_THREAD_ID;
3002   ev._sigev_un._tid = 0;
3003   asm volatile("" : : "g"(&ev));
3004   return 0;
3005 }
3006 EOF
3007 if compile_prog "" "" ; then
3008     sigev_thread_id=yes
3009 fi
3010
3011 ##########################################
3012 # check if trace backend exists
3013
3014 $python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
3015 if test "$?" -ne 0 ; then
3016   error_exit "invalid trace backend" \
3017       "Please choose a supported trace backend."
3018 fi
3019
3020 ##########################################
3021 # For 'ust' backend, test if ust headers are present
3022 if test "$trace_backend" = "ust"; then
3023   cat > $TMPC << EOF
3024 #include <ust/tracepoint.h>
3025 #include <ust/marker.h>
3026 int main(void) { return 0; }
3027 EOF
3028   if compile_prog "" "" ; then
3029     LIBS="-lust -lurcu-bp $LIBS"
3030     libs_qga="-lust -lurcu-bp $libs_qga"
3031   else
3032     error_exit "Trace backend 'ust' missing libust header files"
3033   fi
3034 fi
3035
3036 ##########################################
3037 # For 'dtrace' backend, test if 'dtrace' command is present
3038 if test "$trace_backend" = "dtrace"; then
3039   if ! has 'dtrace' ; then
3040     error_exit "dtrace command is not found in PATH $PATH"
3041   fi
3042   trace_backend_stap="no"
3043   if has 'stap' ; then
3044     trace_backend_stap="yes"
3045   fi
3046 fi
3047
3048 ##########################################
3049 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
3050 # use i686 as default anyway, but for those that don't, an explicit
3051 # specification is necessary
3052 if test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
3053   cat > $TMPC << EOF
3054 static int sfaa(int *ptr)
3055 {
3056   return __sync_fetch_and_and(ptr, 0);
3057 }
3058
3059 int main(void)
3060 {
3061   int val = 42;
3062   sfaa(&val);
3063   return val;
3064 }
3065 EOF
3066   if ! compile_prog "" "" ; then
3067     QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
3068   fi
3069 fi
3070
3071 ##########################################
3072 # check and set a backend for coroutine
3073
3074 # We prefer ucontext, but it's not always possible. The fallback
3075 # is sigcontext. gthread is not selectable except explicitly, because
3076 # it is not functional enough to run QEMU proper. (It is occasionally
3077 # useful for debugging purposes.)  On Windows the only valid backend
3078 # is the Windows-specific one.
3079
3080 ucontext_works=no
3081 if test "$darwin" != "yes"; then
3082   cat > $TMPC << EOF
3083 #include <ucontext.h>
3084 #ifdef __stub_makecontext
3085 #error Ignoring glibc stub makecontext which will always fail
3086 #endif
3087 int main(void) { makecontext(0, 0, 0); return 0; }
3088 EOF
3089   if compile_prog "" "" ; then
3090     ucontext_works=yes
3091   fi
3092 fi
3093
3094 if test "$coroutine" = ""; then
3095   if test "$mingw32" = "yes"; then
3096     coroutine=win32
3097   elif test "$ucontext_works" = "yes"; then
3098     coroutine=ucontext
3099   else
3100     coroutine=sigaltstack
3101   fi
3102 else
3103   case $coroutine in
3104   windows)
3105     if test "$mingw32" != "yes"; then
3106       error_exit "'windows' coroutine backend only valid for Windows"
3107     fi
3108     # Unfortunately the user visible backend name doesn't match the
3109     # coroutine-*.c filename for this case, so we have to adjust it here.
3110     coroutine=win32
3111     ;;
3112   ucontext)
3113     if test "$ucontext_works" != "yes"; then
3114       feature_not_found "ucontext"
3115     fi
3116     ;;
3117   gthread|sigaltstack)
3118     if test "$mingw32" = "yes"; then
3119       error_exit "only the 'windows' coroutine backend is valid for Windows"
3120     fi
3121     ;;
3122   *)
3123     error_exit "unknown coroutine backend $coroutine"
3124     ;;
3125   esac
3126 fi
3127
3128 ##########################################
3129 # check if we have open_by_handle_at
3130
3131 open_by_handle_at=no
3132 cat > $TMPC << EOF
3133 #include <fcntl.h>
3134 #if !defined(AT_EMPTY_PATH)
3135 # error missing definition
3136 #else
3137 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3138 #endif
3139 EOF
3140 if compile_prog "" "" ; then
3141     open_by_handle_at=yes
3142 fi
3143
3144 ########################################
3145 # check if we have linux/magic.h
3146
3147 linux_magic_h=no
3148 cat > $TMPC << EOF
3149 #include <linux/magic.h>
3150 int main(void) {
3151   return 0;
3152 }
3153 EOF
3154 if compile_prog "" "" ; then
3155     linux_magic_h=yes
3156 fi
3157
3158 ########################################
3159 # check whether we can disable warning option with a pragma (this is needed
3160 # to silence warnings in the headers of some versions of external libraries).
3161 # This test has to be compiled with -Werror as otherwise an unknown pragma is
3162 # only a warning.
3163 #
3164 # If we can't selectively disable warning in the code, disable -Werror so that
3165 # the build doesn't fail anyway.
3166
3167 pragma_disable_unused_but_set=no
3168 cat > $TMPC << EOF
3169 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3170 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
3171
3172 int main(void) {
3173     return 0;
3174 }
3175 EOF
3176 if compile_prog "-Werror" "" ; then
3177     pragma_diagnostic_available=yes
3178 else
3179     werror=no
3180 fi
3181
3182 ########################################
3183 # check if we have valgrind/valgrind.h and valgrind/memcheck.h
3184
3185 valgrind_h=no
3186 cat > $TMPC << EOF
3187 #include <valgrind/valgrind.h>
3188 #include <valgrind/memcheck.h>
3189 int main(void) {
3190   return 0;
3191 }
3192 EOF
3193 if compile_prog "" "" ; then
3194     valgrind_h=yes
3195 fi
3196
3197 ########################################
3198 # check if environ is declared
3199
3200 has_environ=no
3201 cat > $TMPC << EOF
3202 #include <unistd.h>
3203 int main(void) {
3204     environ = 0;
3205     return 0;
3206 }
3207 EOF
3208 if compile_prog "" "" ; then
3209     has_environ=yes
3210 fi
3211
3212 ########################################
3213 # check if cpuid.h is usable.
3214
3215 cpuid_h=no
3216 cat > $TMPC << EOF
3217 #include <cpuid.h>
3218 int main(void) {
3219   return 0;
3220 }
3221 EOF
3222 if compile_prog "" "" ; then
3223     cpuid_h=yes
3224 fi
3225
3226 ########################################
3227 # check if __[u]int128_t is usable.
3228
3229 int128=no
3230 cat > $TMPC << EOF
3231 __int128_t a;
3232 __uint128_t b;
3233 int main (void) {
3234   a = a + b;
3235   b = a * b;
3236   return 0;
3237 }
3238 EOF
3239 if compile_prog "" "" ; then
3240     int128=yes
3241 fi
3242
3243 ##########################################
3244 # End of CC checks
3245 # After here, no more $cc or $ld runs
3246
3247 if test "$gcov" = "yes" ; then
3248   CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
3249   LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
3250 elif test "$debug" = "no" ; then
3251   CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3252 fi
3253
3254
3255 # Disable zero malloc errors for official releases unless explicitly told to
3256 # enable/disable
3257 if test -z "$zero_malloc" ; then
3258     if test "$z_version" = "50" ; then
3259         zero_malloc="no"
3260     else
3261         zero_malloc="yes"
3262     fi
3263 fi
3264
3265 # Now we've finished running tests it's OK to add -Werror to the compiler flags
3266 if test "$werror" = "yes"; then
3267     QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
3268 fi
3269
3270 if test "$solaris" = "no" ; then
3271     if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
3272         LDFLAGS="-Wl,--warn-common $LDFLAGS"
3273     fi
3274 fi
3275
3276 # test if pod2man has --utf8 option
3277 if pod2man --help | grep -q utf8; then
3278     POD2MAN="pod2man --utf8"
3279 else
3280     POD2MAN="pod2man"
3281 fi
3282
3283 # Use ASLR, no-SEH and DEP if available
3284 if test "$mingw32" = "yes" ; then
3285     for flag in --dynamicbase --no-seh --nxcompat; do
3286         if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3287             LDFLAGS="-Wl,$flag $LDFLAGS"
3288         fi
3289     done
3290 fi
3291
3292 qemu_confdir=$sysconfdir$confsuffix
3293 qemu_datadir=$datadir$confsuffix
3294 qemu_localedir="$datadir/locale"
3295
3296 tools=""
3297 if test "$want_tools" = "yes" ; then
3298   tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
3299   if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3300     tools="qemu-nbd\$(EXESUF) $tools"
3301   fi
3302 fi
3303 if test "$softmmu" = yes ; then
3304   if test "$virtfs" != no ; then
3305     if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3306       virtfs=yes
3307       tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3308     else
3309       if test "$virtfs" = yes; then
3310         error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3311       fi
3312       virtfs=no
3313     fi
3314   fi
3315   if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3316     if [ "$guest_agent" = "yes" ]; then
3317       tools="qemu-ga\$(EXESUF) $tools"
3318     fi
3319   fi
3320 fi
3321
3322 # Mac OS X ships with a broken assembler
3323 roms=
3324 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3325         "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3326         "$softmmu" = yes ; then
3327   roms="optionrom"
3328 fi
3329 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
3330   roms="$roms spapr-rtas"
3331 fi
3332
3333 # add pixman flags after all config tests are done
3334 QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags"
3335 libs_softmmu="$libs_softmmu $pixman_libs"
3336
3337 echo "Install prefix    $prefix"
3338 echo "BIOS directory    `eval echo $qemu_datadir`"
3339 echo "binary directory  `eval echo $bindir`"
3340 echo "library directory `eval echo $libdir`"
3341 echo "libexec directory `eval echo $libexecdir`"
3342 echo "include directory `eval echo $includedir`"
3343 echo "config directory  `eval echo $sysconfdir`"
3344 echo "local state directory   `eval echo $local_statedir`"
3345 if test "$mingw32" = "no" ; then
3346 echo "Manual directory  `eval echo $mandir`"
3347 echo "ELF interp prefix $interp_prefix"
3348 fi
3349 echo "Source path       $source_path"
3350 echo "C compiler        $cc"
3351 echo "Host C compiler   $host_cc"
3352 echo "Objective-C compiler $objcc"
3353 echo "CFLAGS            $CFLAGS"
3354 echo "QEMU_CFLAGS       $QEMU_CFLAGS"
3355 echo "LDFLAGS           $LDFLAGS"
3356 echo "make              $make"
3357 echo "install           $install"
3358 echo "python            $python"
3359 if test "$slirp" = "yes" ; then
3360     echo "smbd              $smbd"
3361 fi
3362 echo "host CPU          $cpu"
3363 echo "host big endian   $bigendian"
3364 echo "target list       $target_list"
3365 echo "tcg debug enabled $debug_tcg"
3366 echo "gprof enabled     $gprof"
3367 echo "sparse enabled    $sparse"
3368 echo "strip binaries    $strip_opt"
3369 echo "profiler          $profiler"
3370 echo "static build      $static"
3371 echo "-Werror enabled   $werror"
3372 if test "$darwin" = "yes" ; then
3373     echo "Cocoa support     $cocoa"
3374 fi
3375 echo "pixman            $pixman"
3376 echo "SDL support       $sdl"
3377 echo "GTK support       $gtk"
3378 echo "curses support    $curses"
3379 echo "curl support      $curl"
3380 echo "mingw32 support   $mingw32"
3381 echo "Audio drivers     $audio_drv_list"
3382 echo "Extra audio cards $audio_card_list"
3383 echo "Block whitelist   $block_drv_whitelist"
3384 echo "Mixer emulation   $mixemu"
3385 echo "VirtFS support    $virtfs"
3386 echo "VNC support       $vnc"
3387 if test "$vnc" = "yes" ; then
3388     echo "VNC TLS support   $vnc_tls"
3389     echo "VNC SASL support  $vnc_sasl"
3390     echo "VNC JPEG support  $vnc_jpeg"
3391     echo "VNC PNG support   $vnc_png"
3392     echo "VNC WS support    $vnc_ws"
3393 fi
3394 if test -n "$sparc_cpu"; then
3395     echo "Target Sparc Arch $sparc_cpu"
3396 fi
3397 echo "xen support       $xen"
3398 echo "brlapi support    $brlapi"
3399 echo "bluez  support    $bluez"
3400 echo "Documentation     $docs"
3401 [ ! -z "$uname_release" ] && \
3402 echo "uname -r          $uname_release"
3403 echo "NPTL support      $nptl"
3404 echo "GUEST_BASE        $guest_base"
3405 echo "PIE               $pie"
3406 echo "vde support       $vde"
3407 echo "Linux AIO support $linux_aio"
3408 echo "ATTR/XATTR support $attr"
3409 echo "Install blobs     $blobs"
3410 echo "KVM support       $kvm"
3411 echo "TCG interpreter   $tcg_interpreter"
3412 echo "fdt support       $fdt"
3413 echo "preadv support    $preadv"
3414 echo "fdatasync         $fdatasync"
3415 echo "madvise           $madvise"
3416 echo "posix_madvise     $posix_madvise"
3417 echo "sigev_thread_id   $sigev_thread_id"
3418 echo "uuid support      $uuid"
3419 echo "libcap-ng support $cap_ng"
3420 echo "vhost-net support $vhost_net"
3421 echo "Trace backend     $trace_backend"
3422 echo "Trace output file $trace_file-<pid>"
3423 echo "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3424 echo "rbd support       $rbd"
3425 echo "xfsctl support    $xfs"
3426 echo "nss used          $smartcard_nss"
3427 echo "usb net redir     $usb_redir"
3428 echo "GLX support       $glx"
3429 echo "libiscsi support  $libiscsi"
3430 echo "build guest agent $guest_agent"
3431 echo "seccomp support   $seccomp"
3432 echo "coroutine backend $coroutine"
3433 echo "GlusterFS support $glusterfs"
3434 echo "virtio-blk-data-plane $virtio_blk_data_plane"
3435 echo "gcov              $gcov_tool"
3436 echo "gcov enabled      $gcov"
3437 echo "TPM support       $tpm"
3438
3439 if test "$sdl_too_old" = "yes"; then
3440 echo "-> Your SDL version is too old - please upgrade to have SDL support"
3441 fi
3442
3443 config_host_mak="config-host.mak"
3444 config_host_ld="config-host.ld"
3445
3446 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
3447
3448 echo "# Automatically generated by configure - do not modify" > $config_host_mak
3449 printf "# Configured with:" >> $config_host_mak
3450 printf " '%s'" "$0" "$@" >> $config_host_mak
3451 echo >> $config_host_mak
3452
3453 echo all: >> $config_host_mak
3454 echo "prefix=$prefix" >> $config_host_mak
3455 echo "bindir=$bindir" >> $config_host_mak
3456 echo "libdir=$libdir" >> $config_host_mak
3457 echo "libexecdir=$libexecdir" >> $config_host_mak
3458 echo "includedir=$includedir" >> $config_host_mak
3459 echo "mandir=$mandir" >> $config_host_mak
3460 echo "sysconfdir=$sysconfdir" >> $config_host_mak
3461 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
3462 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
3463 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
3464 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
3465 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
3466 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
3467 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
3468 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
3469
3470 echo "ARCH=$ARCH" >> $config_host_mak
3471 if test "$debug_tcg" = "yes" ; then
3472   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3473 fi
3474 if test "$strip_opt" = "yes" ; then
3475   echo "STRIP=${strip}" >> $config_host_mak
3476 fi
3477 if test "$bigendian" = "yes" ; then
3478   echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
3479 fi
3480 if test "$mingw32" = "yes" ; then
3481   echo "CONFIG_WIN32=y" >> $config_host_mak
3482   rc_version=`cat $source_path/VERSION`
3483   version_major=${rc_version%%.*}
3484   rc_version=${rc_version#*.}
3485   version_minor=${rc_version%%.*}
3486   rc_version=${rc_version#*.}
3487   version_subminor=${rc_version%%.*}
3488   version_micro=0
3489   echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3490   echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3491 else
3492   echo "CONFIG_POSIX=y" >> $config_host_mak
3493 fi
3494
3495 if test "$linux" = "yes" ; then
3496   echo "CONFIG_LINUX=y" >> $config_host_mak
3497 fi
3498
3499 if test "$darwin" = "yes" ; then
3500   echo "CONFIG_DARWIN=y" >> $config_host_mak
3501 fi
3502
3503 if test "$aix" = "yes" ; then
3504   echo "CONFIG_AIX=y" >> $config_host_mak
3505 fi
3506
3507 if test "$solaris" = "yes" ; then
3508   echo "CONFIG_SOLARIS=y" >> $config_host_mak
3509   echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
3510   if test "$needs_libsunmath" = "yes" ; then
3511     echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
3512   fi
3513 fi
3514 if test "$haiku" = "yes" ; then
3515   echo "CONFIG_HAIKU=y" >> $config_host_mak
3516 fi
3517 if test "$static" = "yes" ; then
3518   echo "CONFIG_STATIC=y" >> $config_host_mak
3519 fi
3520 if test "$profiler" = "yes" ; then
3521   echo "CONFIG_PROFILER=y" >> $config_host_mak
3522 fi
3523 if test "$slirp" = "yes" ; then
3524   echo "CONFIG_SLIRP=y" >> $config_host_mak
3525   echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3526 fi
3527 if test "$vde" = "yes" ; then
3528   echo "CONFIG_VDE=y" >> $config_host_mak
3529 fi
3530 if test "$cap_ng" = "yes" ; then
3531   echo "CONFIG_LIBCAP=y" >> $config_host_mak
3532 fi
3533 for card in $audio_card_list; do
3534     def=CONFIG_`echo $card | LC_ALL=C tr '[a-z]' '[A-Z]'`
3535     echo "$def=y" >> $config_host_mak
3536 done
3537 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
3538 for drv in $audio_drv_list; do
3539     def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
3540     echo "$def=y" >> $config_host_mak
3541     if test "$drv" = "fmod"; then
3542         echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3543     fi
3544 done
3545 if test "$audio_pt_int" = "yes" ; then
3546   echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
3547 fi
3548 if test "$audio_win_int" = "yes" ; then
3549   echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3550 fi
3551 echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
3552 if test "$mixemu" = "yes" ; then
3553   echo "CONFIG_MIXEMU=y" >> $config_host_mak
3554 fi
3555 if test "$vnc" = "yes" ; then
3556   echo "CONFIG_VNC=y" >> $config_host_mak
3557 fi
3558 if test "$vnc_tls" = "yes" ; then
3559   echo "CONFIG_VNC_TLS=y" >> $config_host_mak
3560 fi
3561 if test "$vnc_sasl" = "yes" ; then
3562   echo "CONFIG_VNC_SASL=y" >> $config_host_mak
3563 fi
3564 if test "$vnc_jpeg" = "yes" ; then
3565   echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
3566 fi
3567 if test "$vnc_png" = "yes" ; then
3568   echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3569 fi
3570 if test "$vnc_ws" = "yes" ; then
3571   echo "CONFIG_VNC_WS=y" >> $config_host_mak
3572   echo "VNC_WS_CFLAGS=$vnc_ws_cflags" >> $config_host_mak
3573 fi
3574 if test "$fnmatch" = "yes" ; then
3575   echo "CONFIG_FNMATCH=y" >> $config_host_mak
3576 fi
3577 if test "$uuid" = "yes" ; then
3578   echo "CONFIG_UUID=y" >> $config_host_mak
3579 fi
3580 if test "$xfs" = "yes" ; then
3581   echo "CONFIG_XFS=y" >> $config_host_mak
3582 fi
3583 qemu_version=`head $source_path/VERSION`
3584 echo "VERSION=$qemu_version" >>$config_host_mak
3585 echo "PKGVERSION=$pkgversion" >>$config_host_mak
3586 echo "SRC_PATH=$source_path" >> $config_host_mak
3587 echo "TARGET_DIRS=$target_list" >> $config_host_mak
3588 if [ "$docs" = "yes" ] ; then
3589   echo "BUILD_DOCS=yes" >> $config_host_mak
3590 fi
3591 if test "$sdl" = "yes" ; then
3592   echo "CONFIG_SDL=y" >> $config_host_mak
3593   echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
3594 fi
3595 if test "$cocoa" = "yes" ; then
3596   echo "CONFIG_COCOA=y" >> $config_host_mak
3597 fi
3598 if test "$curses" = "yes" ; then
3599   echo "CONFIG_CURSES=y" >> $config_host_mak
3600 fi
3601 if test "$atfile" = "yes" ; then
3602   echo "CONFIG_ATFILE=y" >> $config_host_mak
3603 fi
3604 if test "$utimens" = "yes" ; then
3605   echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3606 fi
3607 if test "$pipe2" = "yes" ; then
3608   echo "CONFIG_PIPE2=y" >> $config_host_mak
3609 fi
3610 if test "$accept4" = "yes" ; then
3611   echo "CONFIG_ACCEPT4=y" >> $config_host_mak
3612 fi
3613 if test "$splice" = "yes" ; then
3614   echo "CONFIG_SPLICE=y" >> $config_host_mak
3615 fi
3616 if test "$eventfd" = "yes" ; then
3617   echo "CONFIG_EVENTFD=y" >> $config_host_mak
3618 fi
3619 if test "$fallocate" = "yes" ; then
3620   echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3621 fi
3622 if test "$fallocate_punch_hole" = "yes" ; then
3623   echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
3624 fi
3625 if test "$sync_file_range" = "yes" ; then
3626   echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3627 fi
3628 if test "$fiemap" = "yes" ; then
3629   echo "CONFIG_FIEMAP=y" >> $config_host_mak
3630 fi
3631 if test "$dup3" = "yes" ; then
3632   echo "CONFIG_DUP3=y" >> $config_host_mak
3633 fi
3634 if test "$epoll" = "yes" ; then
3635   echo "CONFIG_EPOLL=y" >> $config_host_mak
3636 fi
3637 if test "$epoll_create1" = "yes" ; then
3638   echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
3639 fi
3640 if test "$epoll_pwait" = "yes" ; then
3641   echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
3642 fi
3643 if test "$sendfile" = "yes" ; then
3644   echo "CONFIG_SENDFILE=y" >> $config_host_mak
3645 fi
3646 if test "$inotify" = "yes" ; then
3647   echo "CONFIG_INOTIFY=y" >> $config_host_mak
3648 fi
3649 if test "$inotify1" = "yes" ; then
3650   echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3651 fi
3652 if test "$byteswap_h" = "yes" ; then
3653   echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
3654 fi
3655 if test "$bswap_h" = "yes" ; then
3656   echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
3657 fi
3658 if test "$curl" = "yes" ; then
3659   echo "CONFIG_CURL=y" >> $config_host_mak
3660   echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3661 fi
3662 if test "$brlapi" = "yes" ; then
3663   echo "CONFIG_BRLAPI=y" >> $config_host_mak
3664 fi
3665 if test "$bluez" = "yes" ; then
3666   echo "CONFIG_BLUEZ=y" >> $config_host_mak
3667   echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3668 fi
3669 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3670 if test "$gtk" = "yes" ; then
3671   echo "CONFIG_GTK=y" >> $config_host_mak
3672   echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
3673   echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
3674 fi
3675 if test "$xen" = "yes" ; then
3676   echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3677   echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3678 fi
3679 if test "$linux_aio" = "yes" ; then
3680   echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
3681 fi
3682 if test "$attr" = "yes" ; then
3683   echo "CONFIG_ATTR=y" >> $config_host_mak
3684 fi
3685 if test "$libattr" = "yes" ; then
3686   echo "CONFIG_LIBATTR=y" >> $config_host_mak
3687 fi
3688 if test "$virtfs" = "yes" ; then
3689   echo "CONFIG_VIRTFS=y" >> $config_host_mak
3690 fi
3691 if test "$blobs" = "yes" ; then
3692   echo "INSTALL_BLOBS=yes" >> $config_host_mak
3693 fi
3694 if test "$iovec" = "yes" ; then
3695   echo "CONFIG_IOVEC=y" >> $config_host_mak
3696 fi
3697 if test "$preadv" = "yes" ; then
3698   echo "CONFIG_PREADV=y" >> $config_host_mak
3699 fi
3700 if test "$fdt" = "yes" ; then
3701   echo "CONFIG_FDT=y" >> $config_host_mak
3702 fi
3703 if test "$signalfd" = "yes" ; then
3704   echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3705 fi
3706 if test "$tcg_interpreter" = "yes" ; then
3707   echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3708 fi
3709 if test "$fdatasync" = "yes" ; then
3710   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
3711 fi
3712 if test "$madvise" = "yes" ; then
3713   echo "CONFIG_MADVISE=y" >> $config_host_mak
3714 fi
3715 if test "$posix_madvise" = "yes" ; then
3716   echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3717 fi
3718 if test "$sigev_thread_id" = "yes" ; then
3719   echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
3720 fi
3721
3722 if test "$spice" = "yes" ; then
3723   echo "CONFIG_SPICE=y" >> $config_host_mak
3724 fi
3725
3726 if test "$smartcard_nss" = "yes" ; then
3727   echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3728   echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3729   echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3730 fi
3731
3732 if test "$usb_redir" = "yes" ; then
3733   echo "CONFIG_USB_REDIR=y" >> $config_host_mak
3734 fi
3735
3736 if test "$glx" = "yes" ; then
3737   echo "CONFIG_GLX=y" >> $config_host_mak
3738 fi
3739
3740 if test "$libiscsi" = "yes" ; then
3741   echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3742 fi
3743
3744 if test "$seccomp" = "yes"; then
3745   echo "CONFIG_SECCOMP=y" >> $config_host_mak
3746 fi
3747
3748 # XXX: suppress that
3749 if [ "$bsd" = "yes" ] ; then
3750   echo "CONFIG_BSD=y" >> $config_host_mak
3751 fi
3752
3753 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3754
3755 if test "$zero_malloc" = "yes" ; then
3756   echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
3757 fi
3758 if test "$rbd" = "yes" ; then
3759   echo "CONFIG_RBD=y" >> $config_host_mak
3760 fi
3761
3762 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
3763
3764 if test "$open_by_handle_at" = "yes" ; then
3765   echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3766 fi
3767
3768 if test "$linux_magic_h" = "yes" ; then
3769   echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3770 fi
3771
3772 if test "$pragma_diagnostic_available" = "yes" ; then
3773   echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
3774 fi
3775
3776 if test "$valgrind_h" = "yes" ; then
3777   echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
3778 fi
3779
3780 if test "$has_environ" = "yes" ; then
3781   echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
3782 fi
3783
3784 if test "$cpuid_h" = "yes" ; then
3785   echo "CONFIG_CPUID_H=y" >> $config_host_mak
3786 fi
3787
3788 if test "$int128" = "yes" ; then
3789   echo "CONFIG_INT128=y" >> $config_host_mak
3790 fi
3791
3792 if test "$glusterfs" = "yes" ; then
3793   echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
3794 fi
3795
3796 if test "$virtio_blk_data_plane" = "yes" ; then
3797   echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
3798 fi
3799
3800 # USB host support
3801 case "$usb" in
3802 linux)
3803   echo "HOST_USB=linux legacy" >> $config_host_mak
3804 ;;
3805 bsd)
3806   echo "HOST_USB=bsd" >> $config_host_mak
3807 ;;
3808 *)
3809   echo "HOST_USB=stub" >> $config_host_mak
3810 ;;
3811 esac
3812
3813 # use default implementation for tracing backend-specific routines
3814 trace_default=yes
3815 echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
3816 if test "$trace_backend" = "nop"; then
3817   echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
3818 fi
3819 if test "$trace_backend" = "simple"; then
3820   echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
3821   trace_default=no
3822   # Set the appropriate trace file.
3823   trace_file="\"$trace_file-\" FMT_pid"
3824 fi
3825 if test "$trace_backend" = "stderr"; then
3826   echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
3827   trace_default=no
3828 fi
3829 if test "$trace_backend" = "ust"; then
3830   echo "CONFIG_TRACE_UST=y" >> $config_host_mak
3831 fi
3832 if test "$trace_backend" = "dtrace"; then
3833   echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
3834   if test "$trace_backend_stap" = "yes" ; then
3835     echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
3836   fi
3837 fi
3838 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
3839 if test "$trace_default" = "yes"; then
3840   echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3841 fi
3842
3843 echo "TOOLS=$tools" >> $config_host_mak
3844 echo "ROMS=$roms" >> $config_host_mak
3845 echo "MAKE=$make" >> $config_host_mak
3846 echo "INSTALL=$install" >> $config_host_mak
3847 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
3848 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
3849 if test -n "$libtool"; then
3850   echo "INSTALL_PROG=\$(LIBTOOL) --mode=install $install -c -m 0755" >> $config_host_mak
3851   echo "INSTALL_LIB=\$(LIBTOOL) --mode=install $install -c -m 0644" >> $config_host_mak
3852 else
3853   echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
3854   echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
3855 fi
3856 echo "PYTHON=$python" >> $config_host_mak
3857 echo "CC=$cc" >> $config_host_mak
3858 echo "CC_I386=$cc_i386" >> $config_host_mak
3859 echo "HOST_CC=$host_cc" >> $config_host_mak
3860 echo "OBJCC=$objcc" >> $config_host_mak
3861 echo "AR=$ar" >> $config_host_mak
3862 echo "AS=$as" >> $config_host_mak
3863 echo "CPP=$cpp" >> $config_host_mak
3864 echo "OBJCOPY=$objcopy" >> $config_host_mak
3865 echo "LD=$ld" >> $config_host_mak
3866 echo "WINDRES=$windres" >> $config_host_mak
3867 echo "LIBTOOL=$libtool" >> $config_host_mak
3868 echo "CFLAGS=$CFLAGS" >> $config_host_mak
3869 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3870 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3871 if test "$sparse" = "yes" ; then
3872   echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3873   echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3874   echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3875 fi
3876 if test "$cross_prefix" != ""; then
3877   echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
3878 else
3879   echo "AUTOCONF_HOST := "                             >> $config_host_mak
3880 fi
3881 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
3882 echo "LIBS+=$LIBS" >> $config_host_mak
3883 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3884 echo "EXESUF=$EXESUF" >> $config_host_mak
3885 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
3886 echo "POD2MAN=$POD2MAN" >> $config_host_mak
3887 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
3888 if test "$gcov" = "yes" ; then
3889   echo "CONFIG_GCOV=y" >> $config_host_mak
3890   echo "GCOV=$gcov_tool" >> $config_host_mak
3891 fi
3892
3893 # generate list of library paths for linker script
3894
3895 $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
3896
3897 if test -f ${config_host_ld}~ ; then
3898   if cmp -s $config_host_ld ${config_host_ld}~ ; then
3899     mv ${config_host_ld}~ $config_host_ld
3900   else
3901     rm ${config_host_ld}~
3902   fi
3903 fi
3904
3905 # use included Linux headers
3906 if test "$linux" = "yes" ; then
3907   mkdir -p linux-headers
3908   case "$cpu" in
3909   i386|x86_64)
3910     linux_arch=x86
3911     ;;
3912   ppcemb|ppc|ppc64)
3913     linux_arch=powerpc
3914     ;;
3915   s390x)
3916     linux_arch=s390
3917     ;;
3918   *)
3919     # For most CPUs the kernel architecture name and QEMU CPU name match.
3920     linux_arch="$cpu"
3921     ;;
3922   esac
3923     # For non-KVM architectures we will not have asm headers
3924     if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
3925       symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
3926     fi
3927 fi
3928
3929 for target in $target_list; do
3930 target_dir="$target"
3931 config_target_mak=$target_dir/config-target.mak
3932 target_arch2=`echo $target | cut -d '-' -f 1`
3933 target_bigendian="no"
3934
3935 case "$target_arch2" in
3936   armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
3937   target_bigendian=yes
3938   ;;
3939 esac
3940 target_softmmu="no"
3941 target_user_only="no"
3942 target_linux_user="no"
3943 target_bsd_user="no"
3944 case "$target" in
3945   ${target_arch2}-softmmu)
3946     target_softmmu="yes"
3947     ;;
3948   ${target_arch2}-linux-user)
3949     if test "$linux" != "yes" ; then
3950       error_exit "Target '$target' is only available on a Linux host"
3951     fi
3952     target_user_only="yes"
3953     target_linux_user="yes"
3954     ;;
3955   ${target_arch2}-bsd-user)
3956     if test "$bsd" != "yes" ; then
3957       error_exit "Target '$target' is only available on a BSD host"
3958     fi
3959     target_user_only="yes"
3960     target_bsd_user="yes"
3961     ;;
3962   *)
3963     error_exit "Target '$target' not recognised"
3964     exit 1
3965     ;;
3966 esac
3967
3968 mkdir -p $target_dir
3969 echo "# Automatically generated by configure - do not modify" > $config_target_mak
3970
3971 bflt="no"
3972 target_nptl="no"
3973 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
3974 gdb_xml_files=""
3975 target_short_alignment=2
3976 target_int_alignment=4
3977 target_long_alignment=4
3978 target_llong_alignment=8
3979 target_libs_softmmu=
3980
3981 TARGET_ARCH="$target_arch2"
3982 TARGET_BASE_ARCH=""
3983 TARGET_ABI_DIR=""
3984
3985 case "$target_arch2" in
3986   i386)
3987   ;;
3988   x86_64)
3989     TARGET_BASE_ARCH=i386
3990     target_long_alignment=8
3991   ;;
3992   alpha)
3993     target_long_alignment=8
3994     target_nptl="yes"
3995   ;;
3996   arm|armeb)
3997     TARGET_ARCH=arm
3998     bflt="yes"
3999     target_nptl="yes"
4000     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
4001     target_llong_alignment=4
4002   ;;
4003   cris)
4004     target_nptl="yes"
4005   ;;
4006   lm32)
4007     target_libs_softmmu="$glx_libs"
4008   ;;
4009   m68k)
4010     bflt="yes"
4011     gdb_xml_files="cf-core.xml cf-fp.xml"
4012     target_int_alignment=2
4013     target_long_alignment=2
4014     target_llong_alignment=2
4015   ;;
4016   microblaze|microblazeel)
4017     TARGET_ARCH=microblaze
4018     bflt="yes"
4019     target_nptl="yes"
4020   ;;
4021   mips|mipsel)
4022     TARGET_ARCH=mips
4023     echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
4024     target_nptl="yes"
4025   ;;
4026   mipsn32|mipsn32el)
4027     TARGET_ARCH=mips64
4028     TARGET_BASE_ARCH=mips
4029     echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
4030     echo "TARGET_ABI32=y" >> $config_target_mak
4031   ;;
4032   mips64|mips64el)
4033     TARGET_ARCH=mips64
4034     TARGET_BASE_ARCH=mips
4035     echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
4036     target_long_alignment=8
4037   ;;
4038   moxie)
4039   ;;
4040   or32)
4041     TARGET_ARCH=openrisc
4042     TARGET_BASE_ARCH=openrisc
4043   ;;
4044   ppc)
4045     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
4046     target_nptl="yes"
4047   ;;
4048   ppcemb)
4049     TARGET_BASE_ARCH=ppc
4050     TARGET_ABI_DIR=ppc
4051     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
4052     target_nptl="yes"
4053   ;;
4054   ppc64)
4055     TARGET_BASE_ARCH=ppc
4056     TARGET_ABI_DIR=ppc
4057     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
4058     target_long_alignment=8
4059   ;;
4060   ppc64abi32)
4061     TARGET_ARCH=ppc64
4062     TARGET_BASE_ARCH=ppc
4063     TARGET_ABI_DIR=ppc
4064     echo "TARGET_ABI32=y" >> $config_target_mak
4065     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
4066   ;;
4067   sh4|sh4eb)
4068     TARGET_ARCH=sh4
4069     bflt="yes"
4070     target_nptl="yes"
4071   ;;
4072   sparc)
4073   ;;
4074   sparc64)
4075     TARGET_BASE_ARCH=sparc
4076     target_long_alignment=8
4077   ;;
4078   sparc32plus)
4079     TARGET_ARCH=sparc64
4080     TARGET_BASE_ARCH=sparc
4081     TARGET_ABI_DIR=sparc
4082     echo "TARGET_ABI32=y" >> $config_target_mak
4083   ;;
4084   s390x)
4085     target_nptl="yes"
4086     target_long_alignment=8
4087   ;;
4088   unicore32)
4089   ;;
4090   xtensa|xtensaeb)
4091     TARGET_ARCH=xtensa
4092   ;;
4093   *)
4094     error_exit "Unsupported target CPU"
4095   ;;
4096 esac
4097 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
4098 if [ "$TARGET_BASE_ARCH" = "" ]; then
4099   TARGET_BASE_ARCH=$TARGET_ARCH
4100 fi
4101
4102 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
4103
4104 upper() {
4105     echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
4106 }
4107
4108 case "$cpu" in
4109   i386|x86_64|ppc)
4110     # The TCG interpreter currently does not support ld/st optimization.
4111     if test "$tcg_interpreter" = "no" ; then
4112         echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_target_mak
4113     fi
4114   ;;
4115 esac
4116
4117 echo "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
4118 echo "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
4119 echo "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
4120 echo "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
4121 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
4122 target_arch_name="`upper $TARGET_ARCH`"
4123 echo "TARGET_$target_arch_name=y" >> $config_target_mak
4124 echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
4125 echo "TARGET_TYPE=TARGET_TYPE_`upper $target_arch2`" >> $config_target_mak
4126 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
4127 if [ "$TARGET_ABI_DIR" = "" ]; then
4128   TARGET_ABI_DIR=$TARGET_ARCH
4129 fi
4130 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
4131 case "$target_arch2" in
4132   i386|x86_64)
4133     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
4134       echo "CONFIG_XEN=y" >> $config_target_mak
4135       if test "$xen_pci_passthrough" = yes; then
4136         echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
4137       fi
4138     else
4139       echo "CONFIG_NO_XEN=y" >> $config_target_mak
4140     fi
4141     ;;
4142   *)
4143     echo "CONFIG_NO_XEN=y" >> $config_target_mak
4144 esac
4145 case "$target_arch2" in
4146   arm|i386|x86_64|ppcemb|ppc|ppc64|s390x)
4147     # Make sure the target and host cpus are compatible
4148     if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
4149       \( "$target_arch2" = "$cpu" -o \
4150       \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
4151       \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
4152       \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
4153       \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
4154       \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
4155       \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
4156       echo "CONFIG_KVM=y" >> $config_target_mak
4157       if test "$vhost_net" = "yes" ; then
4158         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
4159       fi
4160     fi
4161 esac
4162 case "$target_arch2" in
4163   i386|x86_64)
4164     echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
4165 esac
4166 if test "$target_bigendian" = "yes" ; then
4167   echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
4168 fi
4169 if test "$target_softmmu" = "yes" ; then
4170   echo "CONFIG_SOFTMMU=y" >> $config_target_mak
4171   echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
4172   case "$target_arch2" in
4173     i386|x86_64)
4174       echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
4175   esac
4176 fi
4177 if test "$target_user_only" = "yes" ; then
4178   echo "CONFIG_USER_ONLY=y" >> $config_target_mak
4179   echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
4180 fi
4181 if test "$target_linux_user" = "yes" ; then
4182   echo "CONFIG_LINUX_USER=y" >> $config_target_mak
4183 fi
4184 list=""
4185 if test ! -z "$gdb_xml_files" ; then
4186   for x in $gdb_xml_files; do
4187     list="$list $source_path/gdb-xml/$x"
4188   done
4189   echo "TARGET_XML_FILES=$list" >> $config_target_mak
4190 fi
4191
4192 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
4193   echo "TARGET_HAS_BFLT=y" >> $config_target_mak
4194 fi
4195 if test "$target_user_only" = "yes" \
4196         -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
4197   echo "CONFIG_USE_NPTL=y" >> $config_target_mak
4198 fi
4199 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
4200   echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
4201 fi
4202 if test "$target_bsd_user" = "yes" ; then
4203   echo "CONFIG_BSD_USER=y" >> $config_target_mak
4204 fi
4205
4206 # the static way of configuring available audio cards requires this workaround
4207 if test "$target_user_only" != "yes" && grep -q CONFIG_PCSPK $source_path/default-configs/$target.mak; then
4208   echo "CONFIG_PCSPK=y" >> $config_target_mak
4209 fi
4210
4211 # generate QEMU_CFLAGS/LDFLAGS for targets
4212
4213 cflags=""
4214 includes=""
4215 ldflags=""
4216
4217 if test "$tcg_interpreter" = "yes"; then
4218   includes="-I\$(SRC_PATH)/tcg/tci $includes"
4219 elif test "$ARCH" = "sparc64" ; then
4220   includes="-I\$(SRC_PATH)/tcg/sparc $includes"
4221 elif test "$ARCH" = "s390x" ; then
4222   includes="-I\$(SRC_PATH)/tcg/s390 $includes"
4223 elif test "$ARCH" = "x86_64" ; then
4224   includes="-I\$(SRC_PATH)/tcg/i386 $includes"
4225 else
4226   includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
4227 fi
4228 includes="-I\$(SRC_PATH)/tcg $includes"
4229
4230 if test "$linux" = "yes" ; then
4231   includes="-I\$(SRC_PATH)/linux-headers $includes"
4232 fi
4233
4234 for i in $ARCH $TARGET_BASE_ARCH ; do
4235   case "$i" in
4236   alpha)
4237     echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
4238     echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
4239   ;;
4240   arm)
4241     echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
4242     echo "CONFIG_ARM_DIS=y"  >> config-all-disas.mak
4243   ;;
4244   cris)
4245     echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
4246     echo "CONFIG_CRIS_DIS=y"  >> config-all-disas.mak
4247   ;;
4248   hppa)
4249     echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
4250     echo "CONFIG_HPPA_DIS=y"  >> config-all-disas.mak
4251   ;;
4252   i386|x86_64)
4253     echo "CONFIG_I386_DIS=y"  >> $config_target_mak
4254     echo "CONFIG_I386_DIS=y"  >> config-all-disas.mak
4255   ;;
4256   ia64*)
4257     echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
4258     echo "CONFIG_IA64_DIS=y"  >> config-all-disas.mak
4259   ;;
4260   lm32)
4261     echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
4262     echo "CONFIG_LM32_DIS=y"  >> config-all-disas.mak
4263   ;;
4264   m68k)
4265     echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
4266     echo "CONFIG_M68K_DIS=y"  >> config-all-disas.mak
4267   ;;
4268   microblaze*)
4269     echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
4270     echo "CONFIG_MICROBLAZE_DIS=y"  >> config-all-disas.mak
4271   ;;
4272   mips*)
4273     echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
4274     echo "CONFIG_MIPS_DIS=y"  >> config-all-disas.mak
4275   ;;
4276   moxie*)
4277     echo "CONFIG_MOXIE_DIS=y"  >> $config_target_mak
4278     echo "CONFIG_MOXIE_DIS=y"  >> config-all-disas.mak
4279   ;;
4280   or32)
4281     echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
4282     echo "CONFIG_OPENRISC_DIS=y"  >> config-all-disas.mak
4283   ;;
4284   ppc*)
4285     echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
4286     echo "CONFIG_PPC_DIS=y"  >> config-all-disas.mak
4287   ;;
4288   s390*)
4289     echo "CONFIG_S390_DIS=y"  >> $config_target_mak
4290     echo "CONFIG_S390_DIS=y"  >> config-all-disas.mak
4291   ;;
4292   sh4)
4293     echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
4294     echo "CONFIG_SH4_DIS=y"  >> config-all-disas.mak
4295   ;;
4296   sparc*)
4297     echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
4298     echo "CONFIG_SPARC_DIS=y"  >> config-all-disas.mak
4299   ;;
4300   xtensa*)
4301     echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
4302     echo "CONFIG_XTENSA_DIS=y"  >> config-all-disas.mak
4303   ;;
4304   esac
4305 done
4306 if test "$tcg_interpreter" = "yes" ; then
4307   echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
4308   echo "CONFIG_TCI_DIS=y"  >> config-all-disas.mak
4309 fi
4310
4311 case "$ARCH" in
4312 alpha)
4313   # Ensure there's only a single GP
4314   cflags="-msmall-data $cflags"
4315 ;;
4316 esac
4317
4318 if test "$target_softmmu" = "yes" ; then
4319   case "$TARGET_BASE_ARCH" in
4320   arm)
4321     cflags="-DHAS_AUDIO $cflags"
4322   ;;
4323   lm32)
4324     cflags="-DHAS_AUDIO $cflags"
4325   ;;
4326   i386|mips|ppc)
4327     cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
4328   ;;
4329   esac
4330 fi
4331
4332 if test "$gprof" = "yes" ; then
4333   echo "TARGET_GPROF=yes" >> $config_target_mak
4334   if test "$target_linux_user" = "yes" ; then
4335     cflags="-p $cflags"
4336     ldflags="-p $ldflags"
4337   fi
4338   if test "$target_softmmu" = "yes" ; then
4339     ldflags="-p $ldflags"
4340     echo "GPROF_CFLAGS=-p" >> $config_target_mak
4341   fi
4342 fi
4343
4344 if test "$tpm" = "yes"; then
4345   if test "$target_softmmu" = "yes" ; then
4346     echo "CONFIG_TPM=y" >> $config_host_mak
4347   fi
4348 fi
4349
4350 if test "$ARCH" = "tci"; then
4351   linker_script=""
4352 else
4353   linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/ldscripts/\$(ARCH).ld"
4354 fi
4355
4356 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4357   case "$ARCH" in
4358   alpha | s390x)
4359     # The default placement of the application is fine.
4360     ;;
4361   *)
4362     ldflags="$linker_script $ldflags"
4363     ;;
4364   esac
4365 fi
4366
4367 echo "LDFLAGS+=$ldflags" >> $config_target_mak
4368 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4369 echo "QEMU_INCLUDES+=$includes" >> $config_target_mak
4370
4371 done # for target in $targets
4372
4373 if [ "$pixman" = "internal" ]; then
4374   echo "config-host.h: subdir-pixman" >> $config_host_mak
4375 fi
4376
4377 # build tree in object directory in case the source is not in the current directory
4378 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32"
4379 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
4380 DIRS="$DIRS roms/seabios roms/vgabios"
4381 DIRS="$DIRS qapi-generated"
4382 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4383 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
4384 FILES="$FILES tests/tcg/lm32/Makefile po/Makefile"
4385 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4386 FILES="$FILES pc-bios/spapr-rtas/Makefile"
4387 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4388 FILES="$FILES pc-bios/qemu-icon.bmp"
4389 for bios_file in \
4390     $source_path/pc-bios/*.bin \
4391     $source_path/pc-bios/*.aml \
4392     $source_path/pc-bios/*.rom \
4393     $source_path/pc-bios/*.dtb \
4394     $source_path/pc-bios/openbios-* \
4395     $source_path/pc-bios/palcode-*
4396 do
4397     FILES="$FILES pc-bios/`basename $bios_file`"
4398 done
4399 mkdir -p $DIRS
4400 for f in $FILES ; do
4401     if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4402         symlink "$source_path/$f" "$f"
4403     fi
4404 done
4405
4406 # temporary config to build submodules
4407 for rom in seabios vgabios ; do
4408     config_mak=roms/$rom/config.mak
4409     echo "# Automatically generated by configure - do not modify" > $config_mak
4410     echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
4411     echo "AS=$as" >> $config_mak
4412     echo "CC=$cc" >> $config_mak
4413     echo "BCC=bcc" >> $config_mak
4414     echo "CPP=$cpp" >> $config_mak
4415     echo "OBJCOPY=objcopy" >> $config_mak
4416     echo "IASL=iasl" >> $config_mak
4417     echo "LD=$ld" >> $config_mak
4418 done
4419
4420 if test "$docs" = "yes" ; then
4421   mkdir -p QMP
4422 fi
This page took 0.260393 seconds and 4 git commands to generate.