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