move "ln -sf" emulation to a function
[qemu.git] / configure
blob5bbf909f4488b1999c7857a2dca3001806315e15
1 #!/bin/sh
3 # qemu configure script (c) 2003 Fabrice Bellard
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"
14 TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
18 # NB: do not call "exit" in the trap handler; this is buggy with some shells;
19 # see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
20 trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21 rm -f config.log
23 compile_object() {
24 echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
25 $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
28 compile_prog() {
29 local_cflags="$1"
30 local_ldflags="$2"
31 echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
32 $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
35 # symbolically link $1 to $2. Portable version of "ln -sf".
36 symlink() {
37 rm -f $2
38 ln -s $1 $2
41 # check whether a command is available to this shell (may be either an
42 # executable or a builtin)
43 has() {
44 type "$1" >/dev/null 2>&1
47 # search for an executable in PATH
48 path_of() {
49 local_command="$1"
50 local_ifs="$IFS"
51 local_dir=""
53 # pathname has a dir component?
54 if [ "${local_command#*/}" != "$local_command" ]; then
55 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
56 echo "$local_command"
57 return 0
60 if [ -z "$local_command" ]; then
61 return 1
64 IFS=:
65 for local_dir in $PATH; do
66 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
67 echo "$local_dir/$local_command"
68 IFS="${local_ifs:-$(printf ' \t\n')}"
69 return 0
71 done
72 # not found
73 IFS="${local_ifs:-$(printf ' \t\n')}"
74 return 1
77 # default parameters
78 cpu=""
79 interp_prefix="/usr/gnemul/qemu-%M"
80 static="no"
81 sparc_cpu=""
82 cross_prefix=""
83 audio_drv_list=""
84 audio_card_list="ac97 es1370 sb16 hda"
85 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
86 block_drv_whitelist=""
87 host_cc="gcc"
88 helper_cflags=""
89 libs_softmmu=""
90 libs_tools=""
91 audio_pt_int=""
92 audio_win_int=""
93 cc_i386=i386-pc-linux-gnu-gcc
95 target_list=""
97 # Default value for a variable defining feature "foo".
98 # * foo="no" feature will only be used if --enable-foo arg is given
99 # * foo="" feature will be searched for, and if found, will be used
100 # unless --disable-foo is given
101 # * foo="yes" this value will only be set by --enable-foo flag.
102 # feature will searched for,
103 # if not found, configure exits with error
105 # Always add --enable-foo and --disable-foo command line args.
106 # Distributions want to ensure that several features are compiled in, and it
107 # is impossible without a --enable-foo that exits if a feature is not found.
109 bluez=""
110 brlapi=""
111 curl=""
112 curses=""
113 docs=""
114 fdt=""
115 kvm=""
116 kvm_para=""
117 nptl=""
118 sdl=""
119 sparse="no"
120 uuid=""
121 vde=""
122 vnc_tls=""
123 vnc_sasl=""
124 vnc_jpeg=""
125 vnc_png=""
126 vnc_thread="no"
127 xen=""
128 linux_aio=""
129 attr=""
130 vhost_net=""
131 xfs=""
133 gprof="no"
134 debug_tcg="no"
135 debug_mon="no"
136 debug="no"
137 strip_opt="yes"
138 bigendian="no"
139 mingw32="no"
140 EXESUF=""
141 prefix="/usr/local"
142 mandir="\${prefix}/share/man"
143 datadir="\${prefix}/share/qemu"
144 docdir="\${prefix}/share/doc/qemu"
145 bindir="\${prefix}/bin"
146 sysconfdir="\${prefix}/etc"
147 confsuffix="/qemu"
148 slirp="yes"
149 fmod_lib=""
150 fmod_inc=""
151 oss_lib=""
152 bsd="no"
153 linux="no"
154 solaris="no"
155 profiler="no"
156 cocoa="no"
157 softmmu="yes"
158 linux_user="no"
159 darwin_user="no"
160 bsd_user="no"
161 guest_base=""
162 uname_release=""
163 io_thread="no"
164 mixemu="no"
165 kerneldir=""
166 aix="no"
167 blobs="yes"
168 pkgversion=""
169 check_utests="no"
170 user_pie="no"
171 zero_malloc=""
172 trace_backend="nop"
173 trace_file="trace"
174 spice=""
175 rbd=""
177 # parse CC options first
178 for opt do
179 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
180 case "$opt" in
181 --cross-prefix=*) cross_prefix="$optarg"
183 --cc=*) CC="$optarg"
185 --cpu=*) cpu="$optarg"
187 --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
189 --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
191 --sparc_cpu=*)
192 sparc_cpu="$optarg"
193 case $sparc_cpu in
194 v7|v8|v8plus|v8plusa)
195 cpu="sparc"
198 cpu="sparc64"
201 echo "undefined SPARC architecture. Exiting";
202 exit 1
204 esac
206 esac
207 done
208 # OS specific
209 # Using uname is really, really broken. Once we have the right set of checks
210 # we can eliminate it's usage altogether
212 cc="${cross_prefix}${CC-gcc}"
213 ar="${cross_prefix}${AR-ar}"
214 objcopy="${cross_prefix}${OBJCOPY-objcopy}"
215 ld="${cross_prefix}${LD-ld}"
216 strip="${cross_prefix}${STRIP-strip}"
217 windres="${cross_prefix}${WINDRES-windres}"
218 pkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
219 sdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
221 # default flags for all hosts
222 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
223 CFLAGS="-g $CFLAGS"
224 QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
225 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
226 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
227 QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
228 QEMU_INCLUDES="-I. -I\$(SRC_PATH)"
229 LDFLAGS="-g $LDFLAGS"
231 check_define() {
232 cat > $TMPC <<EOF
233 #if !defined($1)
234 #error Not defined
235 #endif
236 int main(void) { return 0; }
238 compile_object
241 if test ! -z "$cpu" ; then
242 # command line argument
244 elif check_define __i386__ ; then
245 cpu="i386"
246 elif check_define __x86_64__ ; then
247 cpu="x86_64"
248 elif check_define __sparc__ ; then
249 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
250 # They must be specified using --sparc_cpu
251 if check_define __arch64__ ; then
252 cpu="sparc64"
253 else
254 cpu="sparc"
256 elif check_define _ARCH_PPC ; then
257 if check_define _ARCH_PPC64 ; then
258 cpu="ppc64"
259 else
260 cpu="ppc"
262 elif check_define __mips__ ; then
263 cpu="mips"
264 elif check_define __ia64__ ; then
265 cpu="ia64"
266 elif check_define __s390__ ; then
267 if check_define __s390x__ ; then
268 cpu="s390x"
269 else
270 cpu="s390"
272 else
273 cpu=`uname -m`
276 case "$cpu" in
277 alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
278 cpu="$cpu"
280 i386|i486|i586|i686|i86pc|BePC)
281 cpu="i386"
283 x86_64|amd64)
284 cpu="x86_64"
286 armv*b)
287 cpu="armv4b"
289 armv*l)
290 cpu="armv4l"
292 parisc|parisc64)
293 cpu="hppa"
295 mips*)
296 cpu="mips"
298 s390)
299 cpu="s390"
301 s390x)
302 cpu="s390x"
304 sparc|sun4[cdmuv])
305 cpu="sparc"
308 echo "Unsupported CPU = $cpu"
309 exit 1
311 esac
313 # OS specific
314 if check_define __linux__ ; then
315 targetos="Linux"
316 elif check_define _WIN32 ; then
317 targetos='MINGW32'
318 elif check_define __OpenBSD__ ; then
319 targetos='OpenBSD'
320 elif check_define __sun__ ; then
321 targetos='SunOS'
322 elif check_define __HAIKU__ ; then
323 targetos='Haiku'
324 else
325 targetos=`uname -s`
328 case $targetos in
329 CYGWIN*)
330 mingw32="yes"
331 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
332 audio_possible_drivers="winwave sdl"
333 audio_drv_list="winwave"
335 MINGW32*)
336 mingw32="yes"
337 audio_possible_drivers="winwave dsound sdl fmod"
338 audio_drv_list="winwave"
340 GNU/kFreeBSD)
341 bsd="yes"
342 audio_drv_list="oss"
343 audio_possible_drivers="oss sdl esd pa"
345 FreeBSD)
346 bsd="yes"
347 make="${MAKE-gmake}"
348 audio_drv_list="oss"
349 audio_possible_drivers="oss sdl esd pa"
350 # needed for kinfo_getvmmap(3) in libutil.h
351 LIBS="-lutil $LIBS"
353 DragonFly)
354 bsd="yes"
355 make="${MAKE-gmake}"
356 audio_drv_list="oss"
357 audio_possible_drivers="oss sdl esd pa"
359 NetBSD)
360 bsd="yes"
361 make="${MAKE-gmake}"
362 audio_drv_list="oss"
363 audio_possible_drivers="oss sdl esd"
364 oss_lib="-lossaudio"
366 OpenBSD)
367 bsd="yes"
368 make="${MAKE-gmake}"
369 audio_drv_list="oss"
370 audio_possible_drivers="oss sdl esd"
371 oss_lib="-lossaudio"
373 Darwin)
374 bsd="yes"
375 darwin="yes"
376 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
377 # run 64-bit userspace code
378 if [ "$cpu" = "i386" ] ; then
379 is_x86_64=`sysctl -n hw.optional.x86_64`
380 [ "$is_x86_64" = "1" ] && cpu=x86_64
382 if [ "$cpu" = "x86_64" ] ; then
383 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
384 LDFLAGS="-arch x86_64 $LDFLAGS"
385 else
386 QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
388 darwin_user="yes"
389 cocoa="yes"
390 audio_drv_list="coreaudio"
391 audio_possible_drivers="coreaudio sdl fmod"
392 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
393 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
395 SunOS)
396 solaris="yes"
397 make="${MAKE-gmake}"
398 install="${INSTALL-ginstall}"
399 ld="gld"
400 needs_libsunmath="no"
401 solarisrev=`uname -r | cut -f2 -d.`
402 # have to select again, because `uname -m` returns i86pc
403 # even on an x86_64 box.
404 solariscpu=`isainfo -k`
405 if test "${solariscpu}" = "amd64" ; then
406 cpu="x86_64"
408 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
409 if test "$solarisrev" -le 9 ; then
410 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
411 needs_libsunmath="yes"
412 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
413 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
414 LIBS="-lsunmath $LIBS"
415 else
416 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
417 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
418 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
419 echo "Studio 11 can be downloaded from www.sun.com."
420 exit 1
424 if test -f /usr/include/sys/soundcard.h ; then
425 audio_drv_list="oss"
427 audio_possible_drivers="oss sdl"
428 # needed for CMSG_ macros in sys/socket.h
429 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
430 # needed for TIOCWIN* defines in termios.h
431 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
432 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
433 LIBS="-lsocket -lnsl -lresolv $LIBS"
435 AIX)
436 aix="yes"
437 make="${MAKE-gmake}"
439 Haiku)
440 haiku="yes"
441 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
442 LIBS="-lposix_error_mapper -lnetwork $LIBS"
445 audio_drv_list="oss"
446 audio_possible_drivers="oss alsa sdl esd pa"
447 linux="yes"
448 linux_user="yes"
449 usb="linux"
450 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
451 audio_possible_drivers="$audio_possible_drivers fmod"
454 esac
456 if [ "$bsd" = "yes" ] ; then
457 if [ "$darwin" != "yes" ] ; then
458 usb="bsd"
460 bsd_user="yes"
463 : ${make=${MAKE-make}}
464 : ${install=${INSTALL-install}}
466 if test "$mingw32" = "yes" ; then
467 EXESUF=".exe"
468 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
469 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
470 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
471 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
472 prefix="c:/Program Files/Qemu"
473 mandir="\${prefix}"
474 datadir="\${prefix}"
475 docdir="\${prefix}"
476 bindir="\${prefix}"
477 sysconfdir="\${prefix}"
478 confsuffix=""
481 # find source path
482 source_path=`dirname "$0"`
483 source_path_used="no"
484 workdir=`pwd`
485 if [ -z "$source_path" ]; then
486 source_path=$workdir
487 else
488 source_path=`cd "$source_path"; pwd`
490 [ -f "$workdir/vl.c" ] || source_path_used="yes"
492 werror=""
494 for opt do
495 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
496 case "$opt" in
497 --help|-h) show_help=yes
499 --prefix=*) prefix="$optarg"
501 --interp-prefix=*) interp_prefix="$optarg"
503 --source-path=*) source_path="$optarg"
504 source_path_used="yes"
506 --cross-prefix=*)
508 --cc=*)
510 --host-cc=*) host_cc="$optarg"
512 --make=*) make="$optarg"
514 --install=*) install="$optarg"
516 --extra-cflags=*)
518 --extra-ldflags=*)
520 --cpu=*)
522 --target-list=*) target_list="$optarg"
524 --trace-backend=*) trace_backend="$optarg"
526 --trace-file=*) trace_file="$optarg"
528 --enable-gprof) gprof="yes"
530 --static)
531 static="yes"
532 LDFLAGS="-static $LDFLAGS"
534 --mandir=*) mandir="$optarg"
536 --bindir=*) bindir="$optarg"
538 --datadir=*) datadir="$optarg"
540 --docdir=*) docdir="$optarg"
542 --sysconfdir=*) sysconfdir="$optarg"
544 --disable-sdl) sdl="no"
546 --enable-sdl) sdl="yes"
548 --fmod-lib=*) fmod_lib="$optarg"
550 --fmod-inc=*) fmod_inc="$optarg"
552 --oss-lib=*) oss_lib="$optarg"
554 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
556 --audio-drv-list=*) audio_drv_list="$optarg"
558 --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
560 --enable-debug-tcg) debug_tcg="yes"
562 --disable-debug-tcg) debug_tcg="no"
564 --enable-debug-mon) debug_mon="yes"
566 --disable-debug-mon) debug_mon="no"
568 --enable-debug)
569 # Enable debugging options that aren't excessively noisy
570 debug_tcg="yes"
571 debug_mon="yes"
572 debug="yes"
573 strip_opt="no"
575 --enable-sparse) sparse="yes"
577 --disable-sparse) sparse="no"
579 --disable-strip) strip_opt="no"
581 --disable-vnc-tls) vnc_tls="no"
583 --enable-vnc-tls) vnc_tls="yes"
585 --disable-vnc-sasl) vnc_sasl="no"
587 --enable-vnc-sasl) vnc_sasl="yes"
589 --disable-vnc-jpeg) vnc_jpeg="no"
591 --enable-vnc-jpeg) vnc_jpeg="yes"
593 --disable-vnc-png) vnc_png="no"
595 --enable-vnc-png) vnc_png="yes"
597 --disable-vnc-thread) vnc_thread="no"
599 --enable-vnc-thread) vnc_thread="yes"
601 --disable-slirp) slirp="no"
603 --disable-uuid) uuid="no"
605 --enable-uuid) uuid="yes"
607 --disable-vde) vde="no"
609 --enable-vde) vde="yes"
611 --disable-xen) xen="no"
613 --enable-xen) xen="yes"
615 --disable-brlapi) brlapi="no"
617 --enable-brlapi) brlapi="yes"
619 --disable-bluez) bluez="no"
621 --enable-bluez) bluez="yes"
623 --disable-kvm) kvm="no"
625 --enable-kvm) kvm="yes"
627 --disable-spice) spice="no"
629 --enable-spice) spice="yes"
631 --enable-profiler) profiler="yes"
633 --enable-cocoa)
634 cocoa="yes" ;
635 sdl="no" ;
636 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
638 --disable-system) softmmu="no"
640 --enable-system) softmmu="yes"
642 --disable-user)
643 linux_user="no" ;
644 bsd_user="no" ;
645 darwin_user="no"
647 --enable-user) ;;
648 --disable-linux-user) linux_user="no"
650 --enable-linux-user) linux_user="yes"
652 --disable-darwin-user) darwin_user="no"
654 --enable-darwin-user) darwin_user="yes"
656 --disable-bsd-user) bsd_user="no"
658 --enable-bsd-user) bsd_user="yes"
660 --enable-guest-base) guest_base="yes"
662 --disable-guest-base) guest_base="no"
664 --enable-user-pie) user_pie="yes"
666 --disable-user-pie) user_pie="no"
668 --enable-uname-release=*) uname_release="$optarg"
670 --sparc_cpu=*)
672 --enable-werror) werror="yes"
674 --disable-werror) werror="no"
676 --disable-curses) curses="no"
678 --enable-curses) curses="yes"
680 --disable-curl) curl="no"
682 --enable-curl) curl="yes"
684 --disable-fdt) fdt="no"
686 --enable-fdt) fdt="yes"
688 --disable-check-utests) check_utests="no"
690 --enable-check-utests) check_utests="yes"
692 --disable-nptl) nptl="no"
694 --enable-nptl) nptl="yes"
696 --enable-mixemu) mixemu="yes"
698 --disable-linux-aio) linux_aio="no"
700 --enable-linux-aio) linux_aio="yes"
702 --disable-attr) attr="no"
704 --enable-attr) attr="yes"
706 --enable-io-thread) io_thread="yes"
708 --disable-blobs) blobs="no"
710 --kerneldir=*) kerneldir="$optarg"
712 --with-pkgversion=*) pkgversion=" ($optarg)"
714 --disable-docs) docs="no"
716 --enable-docs) docs="yes"
718 --disable-vhost-net) vhost_net="no"
720 --enable-vhost-net) vhost_net="yes"
722 --*dir)
724 --disable-rbd) rbd="no"
726 --enable-rbd) rbd="yes"
728 *) echo "ERROR: unknown option $opt"; show_help="yes"
730 esac
731 done
734 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
735 # QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
737 host_guest_base="no"
738 case "$cpu" in
739 sparc) case $sparc_cpu in
740 v7|v8)
741 QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
743 v8plus|v8plusa)
744 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
746 *) # sparc_cpu not defined in the command line
747 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
748 esac
749 LDFLAGS="-m32 $LDFLAGS"
750 QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
751 if test "$solaris" = "no" ; then
752 QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
753 helper_cflags="-ffixed-i0"
756 sparc64)
757 QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
758 LDFLAGS="-m64 $LDFLAGS"
759 QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
760 if test "$solaris" != "no" ; then
761 QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
764 s390)
765 QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
766 LDFLAGS="-m31 $LDFLAGS"
767 host_guest_base="yes"
769 s390x)
770 QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
771 LDFLAGS="-m64 $LDFLAGS"
772 host_guest_base="yes"
774 i386)
775 QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
776 LDFLAGS="-m32 $LDFLAGS"
777 cc_i386='$(CC) -m32'
778 helper_cflags="-fomit-frame-pointer"
779 host_guest_base="yes"
781 x86_64)
782 QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
783 LDFLAGS="-m64 $LDFLAGS"
784 cc_i386='$(CC) -m32'
785 host_guest_base="yes"
787 arm*)
788 host_guest_base="yes"
790 ppc*)
791 host_guest_base="yes"
793 mips*)
794 host_guest_base="yes"
796 ia64*)
797 host_guest_base="yes"
799 hppa*)
800 host_guest_base="yes"
802 esac
804 [ -z "$guest_base" ] && guest_base="$host_guest_base"
806 if test x"$show_help" = x"yes" ; then
807 cat << EOF
809 Usage: configure [options]
810 Options: [defaults in brackets after descriptions]
813 echo "Standard options:"
814 echo " --help print this message"
815 echo " --prefix=PREFIX install in PREFIX [$prefix]"
816 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
817 echo " use %M for cpu name [$interp_prefix]"
818 echo " --target-list=LIST set target list [$target_list]"
819 echo ""
820 echo "Advanced options (experts only):"
821 echo " --source-path=PATH path of source code [$source_path]"
822 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
823 echo " --cc=CC use C compiler CC [$cc]"
824 echo " --host-cc=CC use C compiler CC [$host_cc] for code run at"
825 echo " build time"
826 echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
827 echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
828 echo " --make=MAKE use specified make [$make]"
829 echo " --install=INSTALL use specified install [$install]"
830 echo " --static enable static build [$static]"
831 echo " --mandir=PATH install man pages in PATH"
832 echo " --datadir=PATH install firmware in PATH"
833 echo " --docdir=PATH install documentation in PATH"
834 echo " --bindir=PATH install binaries in PATH"
835 echo " --sysconfdir=PATH install config in PATH/qemu"
836 echo " --enable-debug-tcg enable TCG debugging"
837 echo " --disable-debug-tcg disable TCG debugging (default)"
838 echo " --enable-debug enable common debug build options"
839 echo " --enable-sparse enable sparse checker"
840 echo " --disable-sparse disable sparse checker (default)"
841 echo " --disable-strip disable stripping binaries"
842 echo " --disable-werror disable compilation abort on warning"
843 echo " --disable-sdl disable SDL"
844 echo " --enable-sdl enable SDL"
845 echo " --enable-cocoa enable COCOA (Mac OS X only)"
846 echo " --audio-drv-list=LIST set audio drivers list:"
847 echo " Available drivers: $audio_possible_drivers"
848 echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
849 echo " Available cards: $audio_possible_cards"
850 echo " --block-drv-whitelist=L set block driver whitelist"
851 echo " (affects only QEMU, not qemu-img)"
852 echo " --enable-mixemu enable mixer emulation"
853 echo " --disable-xen disable xen backend driver support"
854 echo " --enable-xen enable xen backend driver support"
855 echo " --disable-brlapi disable BrlAPI"
856 echo " --enable-brlapi enable BrlAPI"
857 echo " --disable-vnc-tls disable TLS encryption for VNC server"
858 echo " --enable-vnc-tls enable TLS encryption for VNC server"
859 echo " --disable-vnc-sasl disable SASL encryption for VNC server"
860 echo " --enable-vnc-sasl enable SASL encryption for VNC server"
861 echo " --disable-vnc-jpeg disable JPEG lossy compression for VNC server"
862 echo " --enable-vnc-jpeg enable JPEG lossy compression for VNC server"
863 echo " --disable-vnc-png disable PNG compression for VNC server (default)"
864 echo " --enable-vnc-png enable PNG compression for VNC server"
865 echo " --disable-vnc-thread disable threaded VNC server"
866 echo " --enable-vnc-thread enable threaded VNC server"
867 echo " --disable-curses disable curses output"
868 echo " --enable-curses enable curses output"
869 echo " --disable-curl disable curl connectivity"
870 echo " --enable-curl enable curl connectivity"
871 echo " --disable-fdt disable fdt device tree"
872 echo " --enable-fdt enable fdt device tree"
873 echo " --disable-check-utests disable check unit-tests"
874 echo " --enable-check-utests enable check unit-tests"
875 echo " --disable-bluez disable bluez stack connectivity"
876 echo " --enable-bluez enable bluez stack connectivity"
877 echo " --disable-kvm disable KVM acceleration support"
878 echo " --enable-kvm enable KVM acceleration support"
879 echo " --disable-nptl disable usermode NPTL support"
880 echo " --enable-nptl enable usermode NPTL support"
881 echo " --enable-system enable all system emulation targets"
882 echo " --disable-system disable all system emulation targets"
883 echo " --enable-user enable supported user emulation targets"
884 echo " --disable-user disable all user emulation targets"
885 echo " --enable-linux-user enable all linux usermode emulation targets"
886 echo " --disable-linux-user disable all linux usermode emulation targets"
887 echo " --enable-darwin-user enable all darwin usermode emulation targets"
888 echo " --disable-darwin-user disable all darwin usermode emulation targets"
889 echo " --enable-bsd-user enable all BSD usermode emulation targets"
890 echo " --disable-bsd-user disable all BSD usermode emulation targets"
891 echo " --enable-guest-base enable GUEST_BASE support for usermode"
892 echo " emulation targets"
893 echo " --disable-guest-base disable GUEST_BASE support"
894 echo " --enable-user-pie build usermode emulation targets as PIE"
895 echo " --disable-user-pie do not build usermode emulation targets as PIE"
896 echo " --fmod-lib path to FMOD library"
897 echo " --fmod-inc path to FMOD includes"
898 echo " --oss-lib path to OSS library"
899 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
900 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
901 echo " --disable-uuid disable uuid support"
902 echo " --enable-uuid enable uuid support"
903 echo " --disable-vde disable support for vde network"
904 echo " --enable-vde enable support for vde network"
905 echo " --disable-linux-aio disable Linux AIO support"
906 echo " --enable-linux-aio enable Linux AIO support"
907 echo " --disable-attr disables attr and xattr support"
908 echo " --enable-attr enable attr and xattr support"
909 echo " --enable-io-thread enable IO thread"
910 echo " --disable-blobs disable installing provided firmware blobs"
911 echo " --kerneldir=PATH look for kernel includes in PATH"
912 echo " --enable-docs enable documentation build"
913 echo " --disable-docs disable documentation build"
914 echo " --disable-vhost-net disable vhost-net acceleration support"
915 echo " --enable-vhost-net enable vhost-net acceleration support"
916 echo " --trace-backend=B Trace backend nop simple ust dtrace"
917 echo " --trace-file=NAME Full PATH,NAME of file to store traces"
918 echo " Default:trace-<pid>"
919 echo " --disable-spice disable spice"
920 echo " --enable-spice enable spice"
921 echo " --enable-rbd enable building the rados block device (rbd)"
922 echo ""
923 echo "NOTE: The object files are built at the place where configure is launched"
924 exit 1
927 # check that the C compiler works.
928 cat > $TMPC <<EOF
929 int main(void) {}
932 if compile_object ; then
933 : C compiler works ok
934 else
935 echo "ERROR: \"$cc\" either does not exist or does not work"
936 exit 1
939 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
940 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
941 gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
942 gcc_flags="-fstack-protector-all $gcc_flags"
943 cat > $TMPC << EOF
944 int main(void) { return 0; }
946 for flag in $gcc_flags; do
947 if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
948 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
950 done
953 # Solaris specific configure tool chain decisions
955 if test "$solaris" = "yes" ; then
956 if has $install; then
958 else
959 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
960 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
961 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
962 exit 1
964 if test "`path_of $install`" = "/usr/sbin/install" ; then
965 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
966 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
967 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
968 exit 1
970 if has ar; then
972 else
973 echo "Error: No path includes ar"
974 if test -f /usr/ccs/bin/ar ; then
975 echo "Add /usr/ccs/bin to your path and rerun configure"
977 exit 1
982 if test -z "$target_list" ; then
983 # these targets are portable
984 if [ "$softmmu" = "yes" ] ; then
985 target_list="\
986 i386-softmmu \
987 x86_64-softmmu \
988 arm-softmmu \
989 cris-softmmu \
990 m68k-softmmu \
991 microblaze-softmmu \
992 mips-softmmu \
993 mipsel-softmmu \
994 mips64-softmmu \
995 mips64el-softmmu \
996 ppc-softmmu \
997 ppcemb-softmmu \
998 ppc64-softmmu \
999 sh4-softmmu \
1000 sh4eb-softmmu \
1001 sparc-softmmu \
1002 sparc64-softmmu \
1005 # the following are Linux specific
1006 if [ "$linux_user" = "yes" ] ; then
1007 target_list="${target_list}\
1008 i386-linux-user \
1009 x86_64-linux-user \
1010 alpha-linux-user \
1011 arm-linux-user \
1012 armeb-linux-user \
1013 cris-linux-user \
1014 m68k-linux-user \
1015 microblaze-linux-user \
1016 mips-linux-user \
1017 mipsel-linux-user \
1018 ppc-linux-user \
1019 ppc64-linux-user \
1020 ppc64abi32-linux-user \
1021 sh4-linux-user \
1022 sh4eb-linux-user \
1023 sparc-linux-user \
1024 sparc64-linux-user \
1025 sparc32plus-linux-user \
1028 # the following are Darwin specific
1029 if [ "$darwin_user" = "yes" ] ; then
1030 target_list="$target_list i386-darwin-user ppc-darwin-user "
1032 # the following are BSD specific
1033 if [ "$bsd_user" = "yes" ] ; then
1034 target_list="${target_list}\
1035 i386-bsd-user \
1036 x86_64-bsd-user \
1037 sparc-bsd-user \
1038 sparc64-bsd-user \
1041 else
1042 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
1044 if test -z "$target_list" ; then
1045 echo "No targets enabled"
1046 exit 1
1048 # see if system emulation was really requested
1049 case " $target_list " in
1050 *"-softmmu "*) softmmu=yes
1052 *) softmmu=no
1054 esac
1056 feature_not_found() {
1057 feature=$1
1059 echo "ERROR"
1060 echo "ERROR: User requested feature $feature"
1061 echo "ERROR: configure was not able to find it"
1062 echo "ERROR"
1063 exit 1;
1066 if test -z "$cross_prefix" ; then
1068 # ---
1069 # big/little endian test
1070 cat > $TMPC << EOF
1071 #include <inttypes.h>
1072 int main(int argc, char ** argv){
1073 volatile uint32_t i=0x01234567;
1074 return (*((uint8_t*)(&i))) == 0x67;
1078 if compile_prog "" "" ; then
1079 $TMPE && bigendian="yes"
1080 else
1081 echo big/little test failed
1084 else
1086 # if cross compiling, cannot launch a program, so make a static guess
1087 case "$cpu" in
1088 armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1089 bigendian=yes
1091 esac
1095 # host long bits test, actually a pointer size test
1096 cat > $TMPC << EOF
1097 int sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
1099 if compile_object; then
1100 hostlongbits=64
1101 else
1102 hostlongbits=32
1106 ##########################################
1107 # NPTL probe
1109 if test "$nptl" != "no" ; then
1110 cat > $TMPC <<EOF
1111 #include <sched.h>
1112 #include <linux/futex.h>
1113 void foo()
1115 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1116 #error bork
1117 #endif
1121 if compile_object ; then
1122 nptl=yes
1123 else
1124 if test "$nptl" = "yes" ; then
1125 feature_not_found "nptl"
1127 nptl=no
1131 ##########################################
1132 # zlib check
1134 cat > $TMPC << EOF
1135 #include <zlib.h>
1136 int main(void) { zlibVersion(); return 0; }
1138 if compile_prog "" "-lz" ; then
1140 else
1141 echo
1142 echo "Error: zlib check failed"
1143 echo "Make sure to have the zlib libs and headers installed."
1144 echo
1145 exit 1
1148 ##########################################
1149 # xen probe
1151 if test "$xen" != "no" ; then
1152 xen_libs="-lxenstore -lxenctrl -lxenguest"
1153 cat > $TMPC <<EOF
1154 #include <xenctrl.h>
1155 #include <xs.h>
1156 int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1158 if compile_prog "" "$xen_libs" ; then
1159 xen=yes
1160 libs_softmmu="$xen_libs $libs_softmmu"
1161 else
1162 if test "$xen" = "yes" ; then
1163 feature_not_found "xen"
1165 xen=no
1169 ##########################################
1170 # pkg-config probe
1172 if ! has $pkg_config; then
1173 echo warning: proceeding without "$pkg_config" >&2
1174 pkg_config=/bin/false
1177 ##########################################
1178 # Sparse probe
1179 if test "$sparse" != "no" ; then
1180 if has cgcc; then
1181 sparse=yes
1182 else
1183 if test "$sparse" = "yes" ; then
1184 feature_not_found "sparse"
1186 sparse=no
1190 ##########################################
1191 # SDL probe
1193 # Look for sdl configuration program (pkg-config or sdl-config). Try
1194 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
1195 if test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
1196 sdl_config=sdl-config
1199 if $pkg_config sdl --modversion >/dev/null 2>&1; then
1200 sdlconfig="$pkg_config sdl"
1201 _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1202 elif has ${sdl_config}; then
1203 sdlconfig="$sdl_config"
1204 _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1205 else
1206 if test "$sdl" = "yes" ; then
1207 feature_not_found "sdl"
1209 sdl=no
1211 if test -n "$cross_prefix" && test "`basename $sdlconfig`" = sdl-config; then
1212 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
1215 sdl_too_old=no
1216 if test "$sdl" != "no" ; then
1217 cat > $TMPC << EOF
1218 #include <SDL.h>
1219 #undef main /* We don't want SDL to override our main() */
1220 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1222 sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
1223 if test "$static" = "yes" ; then
1224 sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
1225 else
1226 sdl_libs=`$sdlconfig --libs 2> /dev/null`
1228 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1229 if test "$_sdlversion" -lt 121 ; then
1230 sdl_too_old=yes
1231 else
1232 if test "$cocoa" = "no" ; then
1233 sdl=yes
1237 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
1238 if test "$sdl" = "yes" -a "$static" = "yes" ; then
1239 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1240 sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1241 sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
1243 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1245 else
1246 sdl=no
1248 fi # static link
1249 else # sdl not found
1250 if test "$sdl" = "yes" ; then
1251 feature_not_found "sdl"
1253 sdl=no
1254 fi # sdl compile test
1257 if test "$sdl" = "yes" ; then
1258 cat > $TMPC <<EOF
1259 #include <SDL.h>
1260 #if defined(SDL_VIDEO_DRIVER_X11)
1261 #include <X11/XKBlib.h>
1262 #else
1263 #error No x11 support
1264 #endif
1265 int main(void) { return 0; }
1267 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1268 sdl_libs="$sdl_libs -lX11"
1270 if test "$mingw32" = "yes" ; then
1271 sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1273 libs_softmmu="$sdl_libs $libs_softmmu"
1276 ##########################################
1277 # VNC TLS detection
1278 if test "$vnc_tls" != "no" ; then
1279 cat > $TMPC <<EOF
1280 #include <gnutls/gnutls.h>
1281 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1283 vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1284 vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
1285 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1286 vnc_tls=yes
1287 libs_softmmu="$vnc_tls_libs $libs_softmmu"
1288 else
1289 if test "$vnc_tls" = "yes" ; then
1290 feature_not_found "vnc-tls"
1292 vnc_tls=no
1296 ##########################################
1297 # VNC SASL detection
1298 if test "$vnc_sasl" != "no" ; then
1299 cat > $TMPC <<EOF
1300 #include <sasl/sasl.h>
1301 #include <stdio.h>
1302 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1304 # Assuming Cyrus-SASL installed in /usr prefix
1305 vnc_sasl_cflags=""
1306 vnc_sasl_libs="-lsasl2"
1307 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1308 vnc_sasl=yes
1309 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1310 else
1311 if test "$vnc_sasl" = "yes" ; then
1312 feature_not_found "vnc-sasl"
1314 vnc_sasl=no
1318 ##########################################
1319 # VNC JPEG detection
1320 if test "$vnc_jpeg" != "no" ; then
1321 cat > $TMPC <<EOF
1322 #include <stdio.h>
1323 #include <jpeglib.h>
1324 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
1326 vnc_jpeg_cflags=""
1327 vnc_jpeg_libs="-ljpeg"
1328 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
1329 vnc_jpeg=yes
1330 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1331 else
1332 if test "$vnc_jpeg" = "yes" ; then
1333 feature_not_found "vnc-jpeg"
1335 vnc_jpeg=no
1339 ##########################################
1340 # VNC PNG detection
1341 if test "$vnc_png" != "no" ; then
1342 cat > $TMPC <<EOF
1343 //#include <stdio.h>
1344 #include <png.h>
1345 #include <stddef.h>
1346 int main(void) {
1347 png_structp png_ptr;
1348 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1349 return 0;
1352 vnc_png_cflags=""
1353 vnc_png_libs="-lpng"
1354 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1355 vnc_png=yes
1356 libs_softmmu="$vnc_png_libs $libs_softmmu"
1357 else
1358 if test "$vnc_png" = "yes" ; then
1359 feature_not_found "vnc-png"
1361 vnc_png=no
1365 ##########################################
1366 # fnmatch() probe, used for ACL routines
1367 fnmatch="no"
1368 cat > $TMPC << EOF
1369 #include <fnmatch.h>
1370 int main(void)
1372 fnmatch("foo", "foo", 0);
1373 return 0;
1376 if compile_prog "" "" ; then
1377 fnmatch="yes"
1380 ##########################################
1381 # uuid_generate() probe, used for vdi block driver
1382 if test "$uuid" != "no" ; then
1383 uuid_libs="-luuid"
1384 cat > $TMPC << EOF
1385 #include <uuid/uuid.h>
1386 int main(void)
1388 uuid_t my_uuid;
1389 uuid_generate(my_uuid);
1390 return 0;
1393 if compile_prog "" "$uuid_libs" ; then
1394 uuid="yes"
1395 libs_softmmu="$uuid_libs $libs_softmmu"
1396 libs_tools="$uuid_libs $libs_tools"
1397 else
1398 if test "$uuid" = "yes" ; then
1399 feature_not_found "uuid"
1401 uuid=no
1405 ##########################################
1406 # xfsctl() probe, used for raw-posix
1407 if test "$xfs" != "no" ; then
1408 cat > $TMPC << EOF
1409 #include <xfs/xfs.h>
1410 int main(void)
1412 xfsctl(NULL, 0, 0, NULL);
1413 return 0;
1416 if compile_prog "" "" ; then
1417 xfs="yes"
1418 else
1419 if test "$xfs" = "yes" ; then
1420 feature_not_found "xfs"
1422 xfs=no
1426 ##########################################
1427 # vde libraries probe
1428 if test "$vde" != "no" ; then
1429 vde_libs="-lvdeplug"
1430 cat > $TMPC << EOF
1431 #include <libvdeplug.h>
1432 int main(void)
1434 struct vde_open_args a = {0, 0, 0};
1435 vde_open("", "", &a);
1436 return 0;
1439 if compile_prog "" "$vde_libs" ; then
1440 vde=yes
1441 libs_softmmu="$vde_libs $libs_softmmu"
1442 libs_tools="$vde_libs $libs_tools"
1443 else
1444 if test "$vde" = "yes" ; then
1445 feature_not_found "vde"
1447 vde=no
1451 ##########################################
1452 # Sound support libraries probe
1454 audio_drv_probe()
1456 drv=$1
1457 hdr=$2
1458 lib=$3
1459 exp=$4
1460 cfl=$5
1461 cat > $TMPC << EOF
1462 #include <$hdr>
1463 int main(void) { $exp }
1465 if compile_prog "$cfl" "$lib" ; then
1467 else
1468 echo
1469 echo "Error: $drv check failed"
1470 echo "Make sure to have the $drv libs and headers installed."
1471 echo
1472 exit 1
1476 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1477 for drv in $audio_drv_list; do
1478 case $drv in
1479 alsa)
1480 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1481 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1482 libs_softmmu="-lasound $libs_softmmu"
1485 fmod)
1486 if test -z $fmod_lib || test -z $fmod_inc; then
1487 echo
1488 echo "Error: You must specify path to FMOD library and headers"
1489 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1490 echo
1491 exit 1
1493 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1494 libs_softmmu="$fmod_lib $libs_softmmu"
1497 esd)
1498 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1499 libs_softmmu="-lesd $libs_softmmu"
1500 audio_pt_int="yes"
1504 audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1505 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1506 libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
1507 audio_pt_int="yes"
1510 coreaudio)
1511 libs_softmmu="-framework CoreAudio $libs_softmmu"
1514 dsound)
1515 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1516 audio_win_int="yes"
1519 oss)
1520 libs_softmmu="$oss_lib $libs_softmmu"
1523 sdl|wav)
1524 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1527 winwave)
1528 libs_softmmu="-lwinmm $libs_softmmu"
1529 audio_win_int="yes"
1533 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1534 echo
1535 echo "Error: Unknown driver '$drv' selected"
1536 echo "Possible drivers are: $audio_possible_drivers"
1537 echo
1538 exit 1
1541 esac
1542 done
1544 ##########################################
1545 # BrlAPI probe
1547 if test "$brlapi" != "no" ; then
1548 brlapi_libs="-lbrlapi"
1549 cat > $TMPC << EOF
1550 #include <brlapi.h>
1551 #include <stddef.h>
1552 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1554 if compile_prog "" "$brlapi_libs" ; then
1555 brlapi=yes
1556 libs_softmmu="$brlapi_libs $libs_softmmu"
1557 else
1558 if test "$brlapi" = "yes" ; then
1559 feature_not_found "brlapi"
1561 brlapi=no
1565 ##########################################
1566 # curses probe
1567 curses_list="-lncurses -lcurses"
1569 if test "$curses" != "no" ; then
1570 curses_found=no
1571 cat > $TMPC << EOF
1572 #include <curses.h>
1573 #ifdef __OpenBSD__
1574 #define resize_term resizeterm
1575 #endif
1576 int main(void) { resize_term(0, 0); return curses_version(); }
1578 for curses_lib in $curses_list; do
1579 if compile_prog "" "$curses_lib" ; then
1580 curses_found=yes
1581 libs_softmmu="$curses_lib $libs_softmmu"
1582 break
1584 done
1585 if test "$curses_found" = "yes" ; then
1586 curses=yes
1587 else
1588 if test "$curses" = "yes" ; then
1589 feature_not_found "curses"
1591 curses=no
1595 ##########################################
1596 # curl probe
1598 if $pkg_config libcurl --modversion >/dev/null 2>&1; then
1599 curlconfig="$pkg_config libcurl"
1600 else
1601 curlconfig=curl-config
1604 if test "$curl" != "no" ; then
1605 cat > $TMPC << EOF
1606 #include <curl/curl.h>
1607 int main(void) { return curl_easy_init(); }
1609 curl_cflags=`$curlconfig --cflags 2>/dev/null`
1610 curl_libs=`$curlconfig --libs 2>/dev/null`
1611 if compile_prog "$curl_cflags" "$curl_libs" ; then
1612 curl=yes
1613 libs_tools="$curl_libs $libs_tools"
1614 libs_softmmu="$curl_libs $libs_softmmu"
1615 else
1616 if test "$curl" = "yes" ; then
1617 feature_not_found "curl"
1619 curl=no
1621 fi # test "$curl"
1623 ##########################################
1624 # check framework probe
1626 if test "$check_utests" != "no" ; then
1627 cat > $TMPC << EOF
1628 #include <check.h>
1629 int main(void) { suite_create("qemu test"); return 0; }
1631 check_libs=`$pkg_config --libs check`
1632 if compile_prog "" $check_libs ; then
1633 check_utests=yes
1634 libs_tools="$check_libs $libs_tools"
1635 else
1636 if test "$check_utests" = "yes" ; then
1637 feature_not_found "check"
1639 check_utests=no
1641 fi # test "$check_utests"
1643 ##########################################
1644 # bluez support probe
1645 if test "$bluez" != "no" ; then
1646 cat > $TMPC << EOF
1647 #include <bluetooth/bluetooth.h>
1648 int main(void) { return bt_error(0); }
1650 bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1651 bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
1652 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1653 bluez=yes
1654 libs_softmmu="$bluez_libs $libs_softmmu"
1655 else
1656 if test "$bluez" = "yes" ; then
1657 feature_not_found "bluez"
1659 bluez="no"
1663 ##########################################
1664 # kvm probe
1665 if test "$kvm" != "no" ; then
1666 cat > $TMPC <<EOF
1667 #include <linux/kvm.h>
1668 #if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1669 #error Invalid KVM version
1670 #endif
1671 #if !defined(KVM_CAP_USER_MEMORY)
1672 #error Missing KVM capability KVM_CAP_USER_MEMORY
1673 #endif
1674 #if !defined(KVM_CAP_SET_TSS_ADDR)
1675 #error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1676 #endif
1677 #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1678 #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1679 #endif
1680 int main(void) { return 0; }
1682 if test "$kerneldir" != "" ; then
1683 kvm_cflags=-I"$kerneldir"/include
1684 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1685 -a -d "$kerneldir/arch/x86/include" ; then
1686 kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1687 elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1688 kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1689 elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
1690 kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
1691 elif test -d "$kerneldir/arch/$cpu/include" ; then
1692 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1694 else
1695 kvm_cflags=`$pkg_config --cflags kvm-kmod 2>/dev/null`
1697 if compile_prog "$kvm_cflags" "" ; then
1698 kvm=yes
1699 cat > $TMPC <<EOF
1700 #include <linux/kvm_para.h>
1701 int main(void) { return 0; }
1703 if compile_prog "$kvm_cflags" "" ; then
1704 kvm_para=yes
1706 else
1707 if test "$kvm" = "yes" ; then
1708 if has awk && has grep; then
1709 kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1710 | grep "error: " \
1711 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1712 if test "$kvmerr" != "" ; then
1713 echo -e "${kvmerr}\n\
1714 NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1715 recent kvm-kmod from http://sourceforge.net/projects/kvm."
1718 feature_not_found "kvm"
1720 kvm=no
1724 ##########################################
1725 # test for vhost net
1727 if test "$vhost_net" != "no"; then
1728 if test "$kvm" != "no"; then
1729 cat > $TMPC <<EOF
1730 #include <linux/vhost.h>
1731 int main(void) { return 0; }
1733 if compile_prog "$kvm_cflags" "" ; then
1734 vhost_net=yes
1735 else
1736 if test "$vhost_net" = "yes" ; then
1737 feature_not_found "vhost-net"
1739 vhost_net=no
1741 else
1742 if test "$vhost_net" = "yes" ; then
1743 echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1744 feature_not_found "vhost-net"
1746 vhost_net=no
1750 ##########################################
1751 # pthread probe
1752 PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1754 pthread=no
1755 cat > $TMPC << EOF
1756 #include <pthread.h>
1757 int main(void) { pthread_create(0,0,0,0); return 0; }
1759 if compile_prog "" "" ; then
1760 pthread=yes
1761 else
1762 for pthread_lib in $PTHREADLIBS_LIST; do
1763 if compile_prog "" "$pthread_lib" ; then
1764 pthread=yes
1765 LIBS="$pthread_lib $LIBS"
1766 break
1768 done
1771 if test "$mingw32" != yes -a "$pthread" = no; then
1772 echo
1773 echo "Error: pthread check failed"
1774 echo "Make sure to have the pthread libs and headers installed."
1775 echo
1776 exit 1
1779 ##########################################
1780 # rbd probe
1781 if test "$rbd" != "no" ; then
1782 cat > $TMPC <<EOF
1783 #include <stdio.h>
1784 #include <rados/librados.h>
1785 int main(void) { rados_initialize(0, NULL); return 0; }
1787 rbd_libs="-lrados -lcrypto"
1788 if compile_prog "" "$rbd_libs" ; then
1789 librados_too_old=no
1790 cat > $TMPC <<EOF
1791 #include <stdio.h>
1792 #include <rados/librados.h>
1793 #ifndef CEPH_OSD_TMAP_SET
1794 #error missing CEPH_OSD_TMAP_SET
1795 #endif
1796 int main(void) {
1797 int (*func)(const rados_pool_t pool, uint64_t *snapid) = rados_selfmanaged_snap_create;
1798 rados_initialize(0, NULL);
1799 return 0;
1802 if compile_prog "" "$rbd_libs" ; then
1803 rbd=yes
1804 libs_tools="$rbd_libs $libs_tools"
1805 libs_softmmu="$rbd_libs $libs_softmmu"
1806 else
1807 rbd=no
1808 librados_too_old=yes
1810 else
1811 if test "$rbd" = "yes" ; then
1812 feature_not_found "rados block device"
1814 rbd=no
1816 if test "$librados_too_old" = "yes" ; then
1817 echo "-> Your librados version is too old - upgrade needed to have rbd support"
1821 ##########################################
1822 # linux-aio probe
1824 if test "$linux_aio" != "no" ; then
1825 cat > $TMPC <<EOF
1826 #include <libaio.h>
1827 #include <sys/eventfd.h>
1828 #include <stddef.h>
1829 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1831 if compile_prog "" "-laio" ; then
1832 linux_aio=yes
1833 libs_softmmu="$libs_softmmu -laio"
1834 libs_tools="$libs_tools -laio"
1835 else
1836 if test "$linux_aio" = "yes" ; then
1837 feature_not_found "linux AIO"
1839 linux_aio=no
1843 ##########################################
1844 # attr probe
1846 if test "$attr" != "no" ; then
1847 cat > $TMPC <<EOF
1848 #include <stdio.h>
1849 #include <sys/types.h>
1850 #include <attr/xattr.h>
1851 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1853 if compile_prog "" "-lattr" ; then
1854 attr=yes
1855 LIBS="-lattr $LIBS"
1856 else
1857 if test "$attr" = "yes" ; then
1858 feature_not_found "ATTR"
1860 attr=no
1864 ##########################################
1865 # iovec probe
1866 cat > $TMPC <<EOF
1867 #include <sys/types.h>
1868 #include <sys/uio.h>
1869 #include <unistd.h>
1870 int main(void) { struct iovec iov; return 0; }
1872 iovec=no
1873 if compile_prog "" "" ; then
1874 iovec=yes
1877 ##########################################
1878 # preadv probe
1879 cat > $TMPC <<EOF
1880 #include <sys/types.h>
1881 #include <sys/uio.h>
1882 #include <unistd.h>
1883 int main(void) { preadv; }
1885 preadv=no
1886 if compile_prog "" "" ; then
1887 preadv=yes
1890 ##########################################
1891 # fdt probe
1892 if test "$fdt" != "no" ; then
1893 fdt_libs="-lfdt"
1894 cat > $TMPC << EOF
1895 int main(void) { return 0; }
1897 if compile_prog "" "$fdt_libs" ; then
1898 fdt=yes
1899 libs_softmmu="$fdt_libs $libs_softmmu"
1900 else
1901 if test "$fdt" = "yes" ; then
1902 feature_not_found "fdt"
1904 fdt=no
1909 # Check for xxxat() functions when we are building linux-user
1910 # emulator. This is done because older glibc versions don't
1911 # have syscall stubs for these implemented.
1913 atfile=no
1914 cat > $TMPC << EOF
1915 #define _ATFILE_SOURCE
1916 #include <sys/types.h>
1917 #include <fcntl.h>
1918 #include <unistd.h>
1921 main(void)
1923 /* try to unlink nonexisting file */
1924 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1927 if compile_prog "" "" ; then
1928 atfile=yes
1931 # Check for inotify functions when we are building linux-user
1932 # emulator. This is done because older glibc versions don't
1933 # have syscall stubs for these implemented. In that case we
1934 # don't provide them even if kernel supports them.
1936 inotify=no
1937 cat > $TMPC << EOF
1938 #include <sys/inotify.h>
1941 main(void)
1943 /* try to start inotify */
1944 return inotify_init();
1947 if compile_prog "" "" ; then
1948 inotify=yes
1951 inotify1=no
1952 cat > $TMPC << EOF
1953 #include <sys/inotify.h>
1956 main(void)
1958 /* try to start inotify */
1959 return inotify_init1(0);
1962 if compile_prog "" "" ; then
1963 inotify1=yes
1966 # check if utimensat and futimens are supported
1967 utimens=no
1968 cat > $TMPC << EOF
1969 #define _ATFILE_SOURCE
1970 #include <stddef.h>
1971 #include <fcntl.h>
1973 int main(void)
1975 utimensat(AT_FDCWD, "foo", NULL, 0);
1976 futimens(0, NULL);
1977 return 0;
1980 if compile_prog "" "" ; then
1981 utimens=yes
1984 # check if pipe2 is there
1985 pipe2=no
1986 cat > $TMPC << EOF
1987 #include <unistd.h>
1988 #include <fcntl.h>
1990 int main(void)
1992 int pipefd[2];
1993 pipe2(pipefd, O_CLOEXEC);
1994 return 0;
1997 if compile_prog "" "" ; then
1998 pipe2=yes
2001 # check if accept4 is there
2002 accept4=no
2003 cat > $TMPC << EOF
2004 #include <sys/socket.h>
2005 #include <stddef.h>
2007 int main(void)
2009 accept4(0, NULL, NULL, SOCK_CLOEXEC);
2010 return 0;
2013 if compile_prog "" "" ; then
2014 accept4=yes
2017 # check if tee/splice is there. vmsplice was added same time.
2018 splice=no
2019 cat > $TMPC << EOF
2020 #include <unistd.h>
2021 #include <fcntl.h>
2022 #include <limits.h>
2024 int main(void)
2026 int len, fd;
2027 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
2028 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
2029 return 0;
2032 if compile_prog "" "" ; then
2033 splice=yes
2036 ##########################################
2037 # signalfd probe
2038 signalfd="no"
2039 cat > $TMPC << EOF
2040 #define _GNU_SOURCE
2041 #include <unistd.h>
2042 #include <sys/syscall.h>
2043 #include <signal.h>
2044 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2047 if compile_prog "" "" ; then
2048 signalfd=yes
2051 # check if eventfd is supported
2052 eventfd=no
2053 cat > $TMPC << EOF
2054 #include <sys/eventfd.h>
2056 int main(void)
2058 int efd = eventfd(0, 0);
2059 return 0;
2062 if compile_prog "" "" ; then
2063 eventfd=yes
2066 # check for fallocate
2067 fallocate=no
2068 cat > $TMPC << EOF
2069 #include <fcntl.h>
2071 int main(void)
2073 fallocate(0, 0, 0, 0);
2074 return 0;
2077 if compile_prog "$ARCH_CFLAGS" "" ; then
2078 fallocate=yes
2081 # check for sync_file_range
2082 sync_file_range=no
2083 cat > $TMPC << EOF
2084 #include <fcntl.h>
2086 int main(void)
2088 sync_file_range(0, 0, 0, 0);
2089 return 0;
2092 if compile_prog "$ARCH_CFLAGS" "" ; then
2093 sync_file_range=yes
2096 # check for linux/fiemap.h and FS_IOC_FIEMAP
2097 fiemap=no
2098 cat > $TMPC << EOF
2099 #include <sys/ioctl.h>
2100 #include <linux/fs.h>
2101 #include <linux/fiemap.h>
2103 int main(void)
2105 ioctl(0, FS_IOC_FIEMAP, 0);
2106 return 0;
2109 if compile_prog "$ARCH_CFLAGS" "" ; then
2110 fiemap=yes
2113 # check for dup3
2114 dup3=no
2115 cat > $TMPC << EOF
2116 #include <unistd.h>
2118 int main(void)
2120 dup3(0, 0, 0);
2121 return 0;
2124 if compile_prog "" "" ; then
2125 dup3=yes
2128 # Check if tools are available to build documentation.
2129 if test "$docs" != "no" ; then
2130 if has makeinfo && has pod2man; then
2131 docs=yes
2132 else
2133 if test "$docs" = "yes" ; then
2134 feature_not_found "docs"
2136 docs=no
2140 # Search for bswap_32 function
2141 byteswap_h=no
2142 cat > $TMPC << EOF
2143 #include <byteswap.h>
2144 int main(void) { return bswap_32(0); }
2146 if compile_prog "" "" ; then
2147 byteswap_h=yes
2150 # Search for bswap_32 function
2151 bswap_h=no
2152 cat > $TMPC << EOF
2153 #include <sys/endian.h>
2154 #include <sys/types.h>
2155 #include <machine/bswap.h>
2156 int main(void) { return bswap32(0); }
2158 if compile_prog "" "" ; then
2159 bswap_h=yes
2162 ##########################################
2163 # Do we need librt
2164 cat > $TMPC <<EOF
2165 #include <signal.h>
2166 #include <time.h>
2167 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
2170 if compile_prog "" "" ; then
2172 elif compile_prog "" "-lrt" ; then
2173 LIBS="-lrt $LIBS"
2176 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2177 "$aix" != "yes" -a "$haiku" != "yes" ; then
2178 libs_softmmu="-lutil $libs_softmmu"
2181 ##########################################
2182 # check if the compiler defines offsetof
2184 need_offsetof=yes
2185 cat > $TMPC << EOF
2186 #include <stddef.h>
2187 int main(void) { struct s { int f; }; return offsetof(struct s, f); }
2189 if compile_prog "" "" ; then
2190 need_offsetof=no
2193 ##########################################
2194 # check if the compiler understands attribute warn_unused_result
2196 # This could be smarter, but gcc -Werror does not error out even when warning
2197 # about attribute warn_unused_result
2199 gcc_attribute_warn_unused_result=no
2200 cat > $TMPC << EOF
2201 #if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2202 #error gcc 3.3 or older
2203 #endif
2204 int main(void) { return 0;}
2206 if compile_prog "" ""; then
2207 gcc_attribute_warn_unused_result=yes
2210 # spice probe
2211 if test "$spice" != "no" ; then
2212 cat > $TMPC << EOF
2213 #include <spice.h>
2214 int main(void) { spice_server_new(); return 0; }
2216 spice_cflags=$($pkgconfig --cflags spice-protocol spice-server 2>/dev/null)
2217 spice_libs=$($pkgconfig --libs spice-protocol spice-server 2>/dev/null)
2218 if $pkgconfig --atleast-version=0.5.3 spice-server >/dev/null 2>&1 && \
2219 compile_prog "$spice_cflags" "$spice_libs" ; then
2220 spice="yes"
2221 libs_softmmu="$libs_softmmu $spice_libs"
2222 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2223 else
2224 if test "$spice" = "yes" ; then
2225 feature_not_found "spice"
2227 spice="no"
2231 ##########################################
2233 ##########################################
2234 # check if we have fdatasync
2236 fdatasync=no
2237 cat > $TMPC << EOF
2238 #include <unistd.h>
2239 int main(void) { return fdatasync(0); }
2241 if compile_prog "" "" ; then
2242 fdatasync=yes
2245 ##########################################
2246 # check if we have madvise
2248 madvise=no
2249 cat > $TMPC << EOF
2250 #include <sys/types.h>
2251 #include <sys/mman.h>
2252 #include <stddef.h>
2253 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2255 if compile_prog "" "" ; then
2256 madvise=yes
2259 ##########################################
2260 # check if we have posix_madvise
2262 posix_madvise=no
2263 cat > $TMPC << EOF
2264 #include <sys/mman.h>
2265 #include <stddef.h>
2266 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2268 if compile_prog "" "" ; then
2269 posix_madvise=yes
2272 ##########################################
2273 # check if trace backend exists
2275 sh "$source_path/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
2276 if test "$?" -ne 0 ; then
2277 echo
2278 echo "Error: invalid trace backend"
2279 echo "Please choose a supported trace backend."
2280 echo
2281 exit 1
2284 ##########################################
2285 # For 'ust' backend, test if ust headers are present
2286 if test "$trace_backend" = "ust"; then
2287 cat > $TMPC << EOF
2288 #include <ust/tracepoint.h>
2289 #include <ust/marker.h>
2290 int main(void) { return 0; }
2292 if compile_prog "" "" ; then
2293 LIBS="-lust $LIBS"
2294 else
2295 echo
2296 echo "Error: Trace backend 'ust' missing libust header files"
2297 echo
2298 exit 1
2302 ##########################################
2303 # For 'dtrace' backend, test if 'dtrace' command is present
2304 if test "$trace_backend" = "dtrace"; then
2305 if ! has 'dtrace' ; then
2306 echo
2307 echo "Error: dtrace command is not found in PATH $PATH"
2308 echo
2309 exit 1
2311 trace_backend_stap="no"
2312 if has 'stap' ; then
2313 trace_backend_stap="yes"
2317 ##########################################
2318 # End of CC checks
2319 # After here, no more $cc or $ld runs
2321 if test "$debug" = "no" ; then
2322 CFLAGS="-O2 $CFLAGS"
2325 # Consult white-list to determine whether to enable werror
2326 # by default. Only enable by default for git builds
2327 z_version=`cut -f3 -d. $source_path/VERSION`
2329 if test -z "$werror" ; then
2330 if test "$z_version" = "50" -a \
2331 "$linux" = "yes" ; then
2332 werror="yes"
2333 else
2334 werror="no"
2338 # Disable zero malloc errors for official releases unless explicitly told to
2339 # enable/disable
2340 if test -z "$zero_malloc" ; then
2341 if test "$z_version" = "50" ; then
2342 zero_malloc="no"
2343 else
2344 zero_malloc="yes"
2348 if test "$werror" = "yes" ; then
2349 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2352 if test "$solaris" = "no" ; then
2353 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
2354 LDFLAGS="-Wl,--warn-common $LDFLAGS"
2358 # Use ASLR, no-SEH and DEP if available
2359 if test "$mingw32" = "yes" ; then
2360 for flag in --dynamicbase --no-seh --nxcompat; do
2361 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2362 LDFLAGS="-Wl,$flag $LDFLAGS"
2364 done
2367 confdir=$sysconfdir$confsuffix
2369 tools=
2370 if test "$softmmu" = yes ; then
2371 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2372 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2373 tools="qemu-nbd\$(EXESUF) $tools"
2374 if [ "$check_utests" = "yes" ]; then
2375 tools="check-qint check-qstring check-qdict check-qlist $tools"
2376 tools="check-qfloat check-qjson $tools"
2381 # Mac OS X ships with a broken assembler
2382 roms=
2383 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2384 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2385 "$softmmu" = yes ; then
2386 roms="optionrom"
2390 echo "Install prefix $prefix"
2391 echo "BIOS directory `eval echo $datadir`"
2392 echo "binary directory `eval echo $bindir`"
2393 echo "config directory `eval echo $sysconfdir`"
2394 if test "$mingw32" = "no" ; then
2395 echo "Manual directory `eval echo $mandir`"
2396 echo "ELF interp prefix $interp_prefix"
2398 echo "Source path $source_path"
2399 echo "C compiler $cc"
2400 echo "Host C compiler $host_cc"
2401 echo "CFLAGS $CFLAGS"
2402 echo "QEMU_CFLAGS $QEMU_CFLAGS"
2403 echo "LDFLAGS $LDFLAGS"
2404 echo "make $make"
2405 echo "install $install"
2406 echo "host CPU $cpu"
2407 echo "host big endian $bigendian"
2408 echo "target list $target_list"
2409 echo "tcg debug enabled $debug_tcg"
2410 echo "Mon debug enabled $debug_mon"
2411 echo "gprof enabled $gprof"
2412 echo "sparse enabled $sparse"
2413 echo "strip binaries $strip_opt"
2414 echo "profiler $profiler"
2415 echo "static build $static"
2416 echo "-Werror enabled $werror"
2417 if test "$darwin" = "yes" ; then
2418 echo "Cocoa support $cocoa"
2420 echo "SDL support $sdl"
2421 echo "curses support $curses"
2422 echo "curl support $curl"
2423 echo "check support $check_utests"
2424 echo "mingw32 support $mingw32"
2425 echo "Audio drivers $audio_drv_list"
2426 echo "Extra audio cards $audio_card_list"
2427 echo "Block whitelist $block_drv_whitelist"
2428 echo "Mixer emulation $mixemu"
2429 echo "VNC TLS support $vnc_tls"
2430 echo "VNC SASL support $vnc_sasl"
2431 echo "VNC JPEG support $vnc_jpeg"
2432 echo "VNC PNG support $vnc_png"
2433 echo "VNC thread $vnc_thread"
2434 if test -n "$sparc_cpu"; then
2435 echo "Target Sparc Arch $sparc_cpu"
2437 echo "xen support $xen"
2438 echo "brlapi support $brlapi"
2439 echo "bluez support $bluez"
2440 echo "Documentation $docs"
2441 [ ! -z "$uname_release" ] && \
2442 echo "uname -r $uname_release"
2443 echo "NPTL support $nptl"
2444 echo "GUEST_BASE $guest_base"
2445 echo "PIE user targets $user_pie"
2446 echo "vde support $vde"
2447 echo "IO thread $io_thread"
2448 echo "Linux AIO support $linux_aio"
2449 echo "ATTR/XATTR support $attr"
2450 echo "Install blobs $blobs"
2451 echo "KVM support $kvm"
2452 echo "fdt support $fdt"
2453 echo "preadv support $preadv"
2454 echo "fdatasync $fdatasync"
2455 echo "madvise $madvise"
2456 echo "posix_madvise $posix_madvise"
2457 echo "uuid support $uuid"
2458 echo "vhost-net support $vhost_net"
2459 echo "Trace backend $trace_backend"
2460 echo "Trace output file $trace_file-<pid>"
2461 echo "spice support $spice"
2462 echo "rbd support $rbd"
2463 echo "xfsctl support $xfs"
2465 if test $sdl_too_old = "yes"; then
2466 echo "-> Your SDL version is too old - please upgrade to have SDL support"
2469 config_host_mak="config-host.mak"
2470 config_host_ld="config-host.ld"
2472 echo "# Automatically generated by configure - do not modify" > $config_host_mak
2473 printf "# Configured with:" >> $config_host_mak
2474 printf " '%s'" "$0" "$@" >> $config_host_mak
2475 echo >> $config_host_mak
2477 echo all: >> $config_host_mak
2478 echo "prefix=$prefix" >> $config_host_mak
2479 echo "bindir=$bindir" >> $config_host_mak
2480 echo "mandir=$mandir" >> $config_host_mak
2481 echo "datadir=$datadir" >> $config_host_mak
2482 echo "sysconfdir=$sysconfdir" >> $config_host_mak
2483 echo "docdir=$docdir" >> $config_host_mak
2484 echo "confdir=$confdir" >> $config_host_mak
2486 case "$cpu" in
2487 i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2488 ARCH=$cpu
2490 armv4b|armv4l)
2491 ARCH=arm
2493 esac
2494 echo "ARCH=$ARCH" >> $config_host_mak
2495 if test "$debug_tcg" = "yes" ; then
2496 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2498 if test "$debug_mon" = "yes" ; then
2499 echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2501 if test "$debug" = "yes" ; then
2502 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2504 if test "$strip_opt" = "yes" ; then
2505 echo "STRIP=${strip}" >> $config_host_mak
2507 if test "$bigendian" = "yes" ; then
2508 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
2510 echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
2511 if test "$mingw32" = "yes" ; then
2512 echo "CONFIG_WIN32=y" >> $config_host_mak
2513 rc_version=`cat $source_path/VERSION`
2514 version_major=${rc_version%%.*}
2515 rc_version=${rc_version#*.}
2516 version_minor=${rc_version%%.*}
2517 rc_version=${rc_version#*.}
2518 version_subminor=${rc_version%%.*}
2519 version_micro=0
2520 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2521 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2522 else
2523 echo "CONFIG_POSIX=y" >> $config_host_mak
2526 if test "$linux" = "yes" ; then
2527 echo "CONFIG_LINUX=y" >> $config_host_mak
2530 if test "$darwin" = "yes" ; then
2531 echo "CONFIG_DARWIN=y" >> $config_host_mak
2534 if test "$aix" = "yes" ; then
2535 echo "CONFIG_AIX=y" >> $config_host_mak
2538 if test "$solaris" = "yes" ; then
2539 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2540 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
2541 if test "$needs_libsunmath" = "yes" ; then
2542 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
2545 if test "$haiku" = "yes" ; then
2546 echo "CONFIG_HAIKU=y" >> $config_host_mak
2548 if test "$static" = "yes" ; then
2549 echo "CONFIG_STATIC=y" >> $config_host_mak
2551 if test $profiler = "yes" ; then
2552 echo "CONFIG_PROFILER=y" >> $config_host_mak
2554 if test "$slirp" = "yes" ; then
2555 echo "CONFIG_SLIRP=y" >> $config_host_mak
2556 QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
2558 if test "$vde" = "yes" ; then
2559 echo "CONFIG_VDE=y" >> $config_host_mak
2561 for card in $audio_card_list; do
2562 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
2563 echo "$def=y" >> $config_host_mak
2564 done
2565 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
2566 for drv in $audio_drv_list; do
2567 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
2568 echo "$def=y" >> $config_host_mak
2569 if test "$drv" = "fmod"; then
2570 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2572 done
2573 if test "$audio_pt_int" = "yes" ; then
2574 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
2576 if test "$audio_win_int" = "yes" ; then
2577 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2579 echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
2580 if test "$mixemu" = "yes" ; then
2581 echo "CONFIG_MIXEMU=y" >> $config_host_mak
2583 if test "$vnc_tls" = "yes" ; then
2584 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2585 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
2587 if test "$vnc_sasl" = "yes" ; then
2588 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2589 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
2591 if test "$vnc_jpeg" != "no" ; then
2592 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2593 echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
2595 if test "$vnc_png" != "no" ; then
2596 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2597 echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2599 if test "$vnc_thread" != "no" ; then
2600 echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2601 echo "CONFIG_THREAD=y" >> $config_host_mak
2603 if test "$fnmatch" = "yes" ; then
2604 echo "CONFIG_FNMATCH=y" >> $config_host_mak
2606 if test "$uuid" = "yes" ; then
2607 echo "CONFIG_UUID=y" >> $config_host_mak
2609 if test "$xfs" = "yes" ; then
2610 echo "CONFIG_XFS=y" >> $config_host_mak
2612 qemu_version=`head $source_path/VERSION`
2613 echo "VERSION=$qemu_version" >>$config_host_mak
2614 echo "PKGVERSION=$pkgversion" >>$config_host_mak
2615 echo "SRC_PATH=$source_path" >> $config_host_mak
2616 echo "TARGET_DIRS=$target_list" >> $config_host_mak
2617 if [ "$docs" = "yes" ] ; then
2618 echo "BUILD_DOCS=yes" >> $config_host_mak
2620 if test "$sdl" = "yes" ; then
2621 echo "CONFIG_SDL=y" >> $config_host_mak
2622 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
2624 if test "$cocoa" = "yes" ; then
2625 echo "CONFIG_COCOA=y" >> $config_host_mak
2627 if test "$curses" = "yes" ; then
2628 echo "CONFIG_CURSES=y" >> $config_host_mak
2630 if test "$atfile" = "yes" ; then
2631 echo "CONFIG_ATFILE=y" >> $config_host_mak
2633 if test "$utimens" = "yes" ; then
2634 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2636 if test "$pipe2" = "yes" ; then
2637 echo "CONFIG_PIPE2=y" >> $config_host_mak
2639 if test "$accept4" = "yes" ; then
2640 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
2642 if test "$splice" = "yes" ; then
2643 echo "CONFIG_SPLICE=y" >> $config_host_mak
2645 if test "$eventfd" = "yes" ; then
2646 echo "CONFIG_EVENTFD=y" >> $config_host_mak
2648 if test "$fallocate" = "yes" ; then
2649 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2651 if test "$sync_file_range" = "yes" ; then
2652 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2654 if test "$fiemap" = "yes" ; then
2655 echo "CONFIG_FIEMAP=y" >> $config_host_mak
2657 if test "$dup3" = "yes" ; then
2658 echo "CONFIG_DUP3=y" >> $config_host_mak
2660 if test "$inotify" = "yes" ; then
2661 echo "CONFIG_INOTIFY=y" >> $config_host_mak
2663 if test "$inotify1" = "yes" ; then
2664 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2666 if test "$byteswap_h" = "yes" ; then
2667 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
2669 if test "$bswap_h" = "yes" ; then
2670 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
2672 if test "$curl" = "yes" ; then
2673 echo "CONFIG_CURL=y" >> $config_host_mak
2674 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2676 if test "$brlapi" = "yes" ; then
2677 echo "CONFIG_BRLAPI=y" >> $config_host_mak
2679 if test "$bluez" = "yes" ; then
2680 echo "CONFIG_BLUEZ=y" >> $config_host_mak
2681 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2683 if test "$xen" = "yes" ; then
2684 echo "CONFIG_XEN=y" >> $config_host_mak
2686 if test "$io_thread" = "yes" ; then
2687 echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2688 echo "CONFIG_THREAD=y" >> $config_host_mak
2690 if test "$linux_aio" = "yes" ; then
2691 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
2693 if test "$attr" = "yes" ; then
2694 echo "CONFIG_ATTR=y" >> $config_host_mak
2696 if test "$linux" = "yes" ; then
2697 if test "$attr" = "yes" ; then
2698 echo "CONFIG_VIRTFS=y" >> $config_host_mak
2701 if test "$blobs" = "yes" ; then
2702 echo "INSTALL_BLOBS=yes" >> $config_host_mak
2704 if test "$iovec" = "yes" ; then
2705 echo "CONFIG_IOVEC=y" >> $config_host_mak
2707 if test "$preadv" = "yes" ; then
2708 echo "CONFIG_PREADV=y" >> $config_host_mak
2710 if test "$fdt" = "yes" ; then
2711 echo "CONFIG_FDT=y" >> $config_host_mak
2713 if test "$signalfd" = "yes" ; then
2714 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2716 if test "$need_offsetof" = "yes" ; then
2717 echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2719 if test "$gcc_attribute_warn_unused_result" = "yes" ; then
2720 echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2722 if test "$fdatasync" = "yes" ; then
2723 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
2725 if test "$madvise" = "yes" ; then
2726 echo "CONFIG_MADVISE=y" >> $config_host_mak
2728 if test "$posix_madvise" = "yes" ; then
2729 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2732 if test "$spice" = "yes" ; then
2733 echo "CONFIG_SPICE=y" >> $config_host_mak
2736 # XXX: suppress that
2737 if [ "$bsd" = "yes" ] ; then
2738 echo "CONFIG_BSD=y" >> $config_host_mak
2741 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2743 if test "$zero_malloc" = "yes" ; then
2744 echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
2746 if test "$rbd" = "yes" ; then
2747 echo "CONFIG_RBD=y" >> $config_host_mak
2750 # USB host support
2751 case "$usb" in
2752 linux)
2753 echo "HOST_USB=linux" >> $config_host_mak
2755 bsd)
2756 echo "HOST_USB=bsd" >> $config_host_mak
2759 echo "HOST_USB=stub" >> $config_host_mak
2761 esac
2763 echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
2764 if test "$trace_backend" = "simple"; then
2765 echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
2767 # Set the appropriate trace file.
2768 if test "$trace_backend" = "simple"; then
2769 trace_file="\"$trace_file-%u\""
2771 if test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
2772 echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
2774 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
2776 echo "TOOLS=$tools" >> $config_host_mak
2777 echo "ROMS=$roms" >> $config_host_mak
2778 echo "MAKE=$make" >> $config_host_mak
2779 echo "INSTALL=$install" >> $config_host_mak
2780 echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2781 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2782 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2783 echo "CC=$cc" >> $config_host_mak
2784 echo "CC_I386=$cc_i386" >> $config_host_mak
2785 echo "HOST_CC=$host_cc" >> $config_host_mak
2786 echo "AR=$ar" >> $config_host_mak
2787 echo "OBJCOPY=$objcopy" >> $config_host_mak
2788 echo "LD=$ld" >> $config_host_mak
2789 echo "WINDRES=$windres" >> $config_host_mak
2790 echo "CFLAGS=$CFLAGS" >> $config_host_mak
2791 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2792 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
2793 if test "$sparse" = "yes" ; then
2794 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
2795 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
2796 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2798 echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2799 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
2800 echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2801 echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
2802 echo "LIBS+=$LIBS" >> $config_host_mak
2803 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2804 echo "EXESUF=$EXESUF" >> $config_host_mak
2806 # generate list of library paths for linker script
2808 $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
2810 if test -f ${config_host_ld}~ ; then
2811 if cmp -s $config_host_ld ${config_host_ld}~ ; then
2812 mv ${config_host_ld}~ $config_host_ld
2813 else
2814 rm ${config_host_ld}~
2818 for d in libdis libdis-user; do
2819 mkdir -p $d
2820 symlink $source_path/Makefile.dis $d/Makefile
2821 echo > $d/config.mak
2822 done
2823 if test "$static" = "no" -a "$user_pie" = "yes" ; then
2824 echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2827 for target in $target_list; do
2828 target_dir="$target"
2829 config_target_mak=$target_dir/config-target.mak
2830 target_arch2=`echo $target | cut -d '-' -f 1`
2831 target_bigendian="no"
2833 case "$target_arch2" in
2834 armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2835 target_bigendian=yes
2837 esac
2838 target_softmmu="no"
2839 target_user_only="no"
2840 target_linux_user="no"
2841 target_darwin_user="no"
2842 target_bsd_user="no"
2843 case "$target" in
2844 ${target_arch2}-softmmu)
2845 target_softmmu="yes"
2847 ${target_arch2}-linux-user)
2848 if test "$linux" != "yes" ; then
2849 echo "ERROR: Target '$target' is only available on a Linux host"
2850 exit 1
2852 target_user_only="yes"
2853 target_linux_user="yes"
2855 ${target_arch2}-darwin-user)
2856 if test "$darwin" != "yes" ; then
2857 echo "ERROR: Target '$target' is only available on a Darwin host"
2858 exit 1
2860 target_user_only="yes"
2861 target_darwin_user="yes"
2863 ${target_arch2}-bsd-user)
2864 if test "$bsd" != "yes" ; then
2865 echo "ERROR: Target '$target' is only available on a BSD host"
2866 exit 1
2868 target_user_only="yes"
2869 target_bsd_user="yes"
2872 echo "ERROR: Target '$target' not recognised"
2873 exit 1
2875 esac
2877 mkdir -p $target_dir
2878 mkdir -p $target_dir/fpu
2879 mkdir -p $target_dir/tcg
2880 mkdir -p $target_dir/ide
2881 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
2882 mkdir -p $target_dir/nwfpe
2884 symlink $source_path/Makefile.target $target_dir/Makefile
2887 echo "# Automatically generated by configure - do not modify" > $config_target_mak
2889 bflt="no"
2890 target_nptl="no"
2891 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
2892 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
2893 gdb_xml_files=""
2895 TARGET_ARCH="$target_arch2"
2896 TARGET_BASE_ARCH=""
2897 TARGET_ABI_DIR=""
2899 case "$target_arch2" in
2900 i386)
2901 target_phys_bits=32
2903 x86_64)
2904 TARGET_BASE_ARCH=i386
2905 target_phys_bits=64
2907 alpha)
2908 target_phys_bits=64
2909 target_nptl="yes"
2911 arm|armeb)
2912 TARGET_ARCH=arm
2913 bflt="yes"
2914 target_nptl="yes"
2915 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2916 target_phys_bits=32
2918 cris)
2919 target_nptl="yes"
2920 target_phys_bits=32
2922 m68k)
2923 bflt="yes"
2924 gdb_xml_files="cf-core.xml cf-fp.xml"
2925 target_phys_bits=32
2927 microblaze)
2928 bflt="yes"
2929 target_nptl="yes"
2930 target_phys_bits=32
2932 mips|mipsel)
2933 TARGET_ARCH=mips
2934 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2935 target_nptl="yes"
2936 target_phys_bits=64
2938 mipsn32|mipsn32el)
2939 TARGET_ARCH=mipsn32
2940 TARGET_BASE_ARCH=mips
2941 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
2942 target_phys_bits=64
2944 mips64|mips64el)
2945 TARGET_ARCH=mips64
2946 TARGET_BASE_ARCH=mips
2947 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2948 target_phys_bits=64
2950 ppc)
2951 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2952 target_phys_bits=32
2953 target_nptl="yes"
2955 ppcemb)
2956 TARGET_BASE_ARCH=ppc
2957 TARGET_ABI_DIR=ppc
2958 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2959 target_phys_bits=64
2960 target_nptl="yes"
2962 ppc64)
2963 TARGET_BASE_ARCH=ppc
2964 TARGET_ABI_DIR=ppc
2965 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2966 target_phys_bits=64
2968 ppc64abi32)
2969 TARGET_ARCH=ppc64
2970 TARGET_BASE_ARCH=ppc
2971 TARGET_ABI_DIR=ppc
2972 echo "TARGET_ABI32=y" >> $config_target_mak
2973 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2974 target_phys_bits=64
2976 sh4|sh4eb)
2977 TARGET_ARCH=sh4
2978 bflt="yes"
2979 target_nptl="yes"
2980 target_phys_bits=32
2982 sparc)
2983 target_phys_bits=64
2985 sparc64)
2986 TARGET_BASE_ARCH=sparc
2987 target_phys_bits=64
2989 sparc32plus)
2990 TARGET_ARCH=sparc64
2991 TARGET_BASE_ARCH=sparc
2992 TARGET_ABI_DIR=sparc
2993 echo "TARGET_ABI32=y" >> $config_target_mak
2994 target_phys_bits=64
2996 s390x)
2997 target_phys_bits=64
3000 echo "Unsupported target CPU"
3001 exit 1
3003 esac
3004 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3005 target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
3006 echo "TARGET_$target_arch_name=y" >> $config_target_mak
3007 echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
3008 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
3009 if [ "$TARGET_BASE_ARCH" = "" ]; then
3010 TARGET_BASE_ARCH=$TARGET_ARCH
3012 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3013 if [ "$TARGET_ABI_DIR" = "" ]; then
3014 TARGET_ABI_DIR=$TARGET_ARCH
3016 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
3017 case "$target_arch2" in
3018 i386|x86_64)
3019 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
3020 echo "CONFIG_XEN=y" >> $config_target_mak
3022 esac
3023 case "$target_arch2" in
3024 i386|x86_64|ppcemb|ppc|ppc64|s390x)
3025 # Make sure the target and host cpus are compatible
3026 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3027 \( "$target_arch2" = "$cpu" -o \
3028 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
3029 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
3030 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
3031 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
3032 echo "CONFIG_KVM=y" >> $config_target_mak
3033 echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
3034 if test "$kvm_para" = "yes"; then
3035 echo "CONFIG_KVM_PARA=y" >> $config_target_mak
3037 if test $vhost_net = "yes" ; then
3038 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3041 esac
3042 if test "$target_bigendian" = "yes" ; then
3043 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
3045 if test "$target_softmmu" = "yes" ; then
3046 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
3047 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3048 echo "LIBS+=$libs_softmmu" >> $config_target_mak
3049 echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
3050 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3052 if test "$target_user_only" = "yes" ; then
3053 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3055 if test "$target_linux_user" = "yes" ; then
3056 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3058 if test "$target_darwin_user" = "yes" ; then
3059 echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3061 list=""
3062 if test ! -z "$gdb_xml_files" ; then
3063 for x in $gdb_xml_files; do
3064 list="$list $source_path/gdb-xml/$x"
3065 done
3066 echo "TARGET_XML_FILES=$list" >> $config_target_mak
3069 case "$target_arch2" in
3070 alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
3071 echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
3074 echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
3076 esac
3078 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
3079 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3081 if test "$target_user_only" = "yes" \
3082 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
3083 echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3085 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
3086 echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3088 if test "$target_bsd_user" = "yes" ; then
3089 echo "CONFIG_BSD_USER=y" >> $config_target_mak
3092 # generate QEMU_CFLAGS/LDFLAGS for targets
3094 cflags=""
3095 includes=""
3096 ldflags=""
3098 if test "$ARCH" = "sparc64" ; then
3099 includes="-I\$(SRC_PATH)/tcg/sparc $includes"
3100 elif test "$ARCH" = "s390x" ; then
3101 includes="-I\$(SRC_PATH)/tcg/s390 $includes"
3102 elif test "$ARCH" = "x86_64" ; then
3103 includes="-I\$(SRC_PATH)/tcg/i386 $includes"
3104 else
3105 includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
3107 includes="-I\$(SRC_PATH)/tcg $includes"
3108 includes="-I\$(SRC_PATH)/fpu $includes"
3110 if test "$target_user_only" = "yes" ; then
3111 libdis_config_mak=libdis-user/config.mak
3112 else
3113 libdis_config_mak=libdis/config.mak
3116 for i in $ARCH $TARGET_BASE_ARCH ; do
3117 case "$i" in
3118 alpha)
3119 echo "CONFIG_ALPHA_DIS=y" >> $config_target_mak
3120 echo "CONFIG_ALPHA_DIS=y" >> $libdis_config_mak
3122 arm)
3123 echo "CONFIG_ARM_DIS=y" >> $config_target_mak
3124 echo "CONFIG_ARM_DIS=y" >> $libdis_config_mak
3126 cris)
3127 echo "CONFIG_CRIS_DIS=y" >> $config_target_mak
3128 echo "CONFIG_CRIS_DIS=y" >> $libdis_config_mak
3130 hppa)
3131 echo "CONFIG_HPPA_DIS=y" >> $config_target_mak
3132 echo "CONFIG_HPPA_DIS=y" >> $libdis_config_mak
3134 i386|x86_64)
3135 echo "CONFIG_I386_DIS=y" >> $config_target_mak
3136 echo "CONFIG_I386_DIS=y" >> $libdis_config_mak
3138 ia64*)
3139 echo "CONFIG_IA64_DIS=y" >> $config_target_mak
3140 echo "CONFIG_IA64_DIS=y" >> $libdis_config_mak
3142 m68k)
3143 echo "CONFIG_M68K_DIS=y" >> $config_target_mak
3144 echo "CONFIG_M68K_DIS=y" >> $libdis_config_mak
3146 microblaze)
3147 echo "CONFIG_MICROBLAZE_DIS=y" >> $config_target_mak
3148 echo "CONFIG_MICROBLAZE_DIS=y" >> $libdis_config_mak
3150 mips*)
3151 echo "CONFIG_MIPS_DIS=y" >> $config_target_mak
3152 echo "CONFIG_MIPS_DIS=y" >> $libdis_config_mak
3154 ppc*)
3155 echo "CONFIG_PPC_DIS=y" >> $config_target_mak
3156 echo "CONFIG_PPC_DIS=y" >> $libdis_config_mak
3158 s390*)
3159 echo "CONFIG_S390_DIS=y" >> $config_target_mak
3160 echo "CONFIG_S390_DIS=y" >> $libdis_config_mak
3162 sh4)
3163 echo "CONFIG_SH4_DIS=y" >> $config_target_mak
3164 echo "CONFIG_SH4_DIS=y" >> $libdis_config_mak
3166 sparc*)
3167 echo "CONFIG_SPARC_DIS=y" >> $config_target_mak
3168 echo "CONFIG_SPARC_DIS=y" >> $libdis_config_mak
3170 esac
3171 done
3173 case "$ARCH" in
3174 alpha)
3175 # Ensure there's only a single GP
3176 cflags="-msmall-data $cflags"
3178 esac
3180 if test "$target_softmmu" = "yes" ; then
3181 case "$TARGET_BASE_ARCH" in
3182 arm)
3183 cflags="-DHAS_AUDIO $cflags"
3185 i386|mips|ppc)
3186 cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
3188 esac
3191 if test "$target_user_only" = "yes" -a "$static" = "no" -a \
3192 "$user_pie" = "yes" ; then
3193 cflags="-fpie $cflags"
3194 ldflags="-pie $ldflags"
3197 if test "$target_softmmu" = "yes" -a \( \
3198 "$TARGET_ARCH" = "microblaze" -o \
3199 "$TARGET_ARCH" = "cris" \) ; then
3200 echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3203 if test "$gprof" = "yes" ; then
3204 echo "TARGET_GPROF=yes" >> $config_target_mak
3205 if test "$target_linux_user" = "yes" ; then
3206 cflags="-p $cflags"
3207 ldflags="-p $ldflags"
3209 if test "$target_softmmu" = "yes" ; then
3210 ldflags="-p $ldflags"
3211 echo "GPROF_CFLAGS=-p" >> $config_target_mak
3215 linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
3216 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3217 case "$ARCH" in
3218 sparc)
3219 # -static is used to avoid g1/g3 usage by the dynamic linker
3220 ldflags="$linker_script -static $ldflags"
3222 alpha | s390x)
3223 # The default placement of the application is fine.
3226 ldflags="$linker_script $ldflags"
3228 esac
3231 echo "LDFLAGS+=$ldflags" >> $config_target_mak
3232 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3233 echo "QEMU_INCLUDES+=$includes" >> $config_target_mak
3235 done # for target in $targets
3237 # build tree in object directory if source path is different from current one
3238 if test "$source_path_used" = "yes" ; then
3239 DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3240 DIRS="$DIRS roms/seabios roms/vgabios"
3241 DIRS="$DIRS fsdev ui"
3242 FILES="Makefile tests/Makefile"
3243 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3244 FILES="$FILES tests/test-mmap.c"
3245 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3246 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
3247 for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
3248 FILES="$FILES pc-bios/`basename $bios_file`"
3249 done
3250 for dir in $DIRS ; do
3251 mkdir -p $dir
3252 done
3253 for f in $FILES ; do
3254 symlink $source_path/$f $f
3255 done
3258 # temporary config to build submodules
3259 for rom in seabios vgabios ; do
3260 config_mak=roms/$rom/config.mak
3261 echo "# Automatically generated by configure - do not modify" > $config_mak
3262 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3263 echo "CC=$cc" >> $config_mak
3264 echo "BCC=bcc" >> $config_mak
3265 echo "CPP=${cross_prefix}cpp" >> $config_mak
3266 echo "OBJCOPY=objcopy" >> $config_mak
3267 echo "IASL=iasl" >> $config_mak
3268 echo "HOST_CC=$host_cc" >> $config_mak
3269 echo "LD=$ld" >> $config_mak
3270 done
3272 for hwlib in 32 64; do
3273 d=libhw$hwlib
3274 mkdir -p $d
3275 mkdir -p $d/ide
3276 symlink $source_path/Makefile.hw $d/Makefile
3277 echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
3278 done
3280 d=libuser
3281 mkdir -p $d
3282 symlink $source_path/Makefile.user $d/Makefile
3283 if test "$static" = "no" -a "$user_pie" = "yes" ; then
3284 echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3287 if test "$docs" = "yes" ; then
3288 mkdir -p QMP