]> git.proxmox.com Git - mirror_qemu.git/blame_incremental - configure
fix test_path
[mirror_qemu.git] / configure
... / ...
CommitLineData
1#!/bin/sh
2#
3# qemu configure script (c) 2003 Fabrice Bellard
4#
5# set temporary file name
6if test ! -z "$TMPDIR" ; then
7 TMPDIR1="${TMPDIR}"
8elif test ! -z "$TEMPDIR" ; then
9 TMPDIR1="${TEMPDIR}"
10else
11 TMPDIR1="/tmp"
12fi
13
14TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
15TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16TMPE="${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 <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
20trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21rm -f config.log
22
23compile_object() {
24 echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
25 $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
26}
27
28compile_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
33}
34
35# check whether a command is available to this shell (may be either an
36# executable or a builtin)
37has() {
38 type "$1" >/dev/null 2>&1
39}
40
41# search for an executable in PATH
42path_of() {
43 local_command="$1"
44 local_ifs="$IFS"
45 local_dir=""
46
47 # pathname has a dir component?
48 if [ "${local_command#*/}" != "$local_command" ]; then
49 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
50 echo "$local_command"
51 return 0
52 fi
53 fi
54 if [ -z "$local_command" ]; then
55 return 1
56 fi
57
58 IFS=:
59 for local_dir in $PATH; do
60 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
61 echo "$local_dir/$local_command"
62 IFS="${local_ifs:-$(printf ' \t\n')}"
63 return 0
64 fi
65 done
66 # not found
67 IFS="${local_ifs:-$(printf ' \t\n')}"
68 return 1
69}
70
71# default parameters
72cpu=""
73interp_prefix="/usr/gnemul/qemu-%M"
74static="no"
75sparc_cpu=""
76cross_prefix=""
77cc="gcc"
78audio_drv_list=""
79audio_card_list="ac97 es1370 sb16"
80audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
81block_drv_whitelist=""
82host_cc="gcc"
83ar="ar"
84make="make"
85install="install"
86objcopy="objcopy"
87ld="ld"
88strip="strip"
89windres="windres"
90helper_cflags=""
91libs_softmmu=""
92libs_tools=""
93audio_pt_int=""
94audio_win_int=""
95
96# parse CC options first
97for opt do
98 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
99 case "$opt" in
100 --cross-prefix=*) cross_prefix="$optarg"
101 ;;
102 --cc=*) cc="$optarg"
103 ;;
104 --cpu=*) cpu="$optarg"
105 ;;
106 --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
107 ;;
108 --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
109 ;;
110 --sparc_cpu=*)
111 sparc_cpu="$optarg"
112 case $sparc_cpu in
113 v7|v8|v8plus|v8plusa)
114 cpu="sparc"
115 ;;
116 v9)
117 cpu="sparc64"
118 ;;
119 *)
120 echo "undefined SPARC architecture. Exiting";
121 exit 1
122 ;;
123 esac
124 ;;
125 esac
126done
127# OS specific
128# Using uname is really, really broken. Once we have the right set of checks
129# we can eliminate it's usage altogether
130
131cc="${cross_prefix}${cc}"
132ar="${cross_prefix}${ar}"
133objcopy="${cross_prefix}${objcopy}"
134ld="${cross_prefix}${ld}"
135strip="${cross_prefix}${strip}"
136windres="${cross_prefix}${windres}"
137
138# default flags for all hosts
139QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
140CFLAGS="-g $CFLAGS"
141QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
142QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
143QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
144QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
145QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
146LDFLAGS="-g $LDFLAGS"
147
148gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
149gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
150gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
151gcc_flags="-fstack-protector-all $gcc_flags"
152cat > $TMPC << EOF
153int main(void) { return 0; }
154EOF
155for flag in $gcc_flags; do
156 if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
157 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
158 fi
159done
160
161# check that the C compiler works.
162cat > $TMPC <<EOF
163int main(void) {}
164EOF
165
166if compile_object ; then
167 : C compiler works ok
168else
169 echo "ERROR: \"$cc\" either does not exist or does not work"
170 exit 1
171fi
172
173check_define() {
174cat > $TMPC <<EOF
175#if !defined($1)
176#error Not defined
177#endif
178int main(void) { return 0; }
179EOF
180 compile_object
181}
182
183if test ! -z "$cpu" ; then
184 # command line argument
185 :
186elif check_define __i386__ ; then
187 cpu="i386"
188elif check_define __x86_64__ ; then
189 cpu="x86_64"
190elif check_define __sparc__ ; then
191 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
192 # They must be specified using --sparc_cpu
193 if check_define __arch64__ ; then
194 cpu="sparc64"
195 else
196 cpu="sparc"
197 fi
198elif check_define _ARCH_PPC ; then
199 if check_define _ARCH_PPC64 ; then
200 cpu="ppc64"
201 else
202 cpu="ppc"
203 fi
204elif check_define __mips__ ; then
205 cpu="mips"
206elif check_define __ia64__ ; then
207 cpu="ia64"
208elif check_define __s390__ ; then
209 if check_define __s390x__ ; then
210 cpu="s390x"
211 else
212 cpu="s390"
213 fi
214else
215 cpu=`uname -m`
216fi
217
218target_list=""
219case "$cpu" in
220 alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
221 cpu="$cpu"
222 ;;
223 i386|i486|i586|i686|i86pc|BePC)
224 cpu="i386"
225 ;;
226 x86_64|amd64)
227 cpu="x86_64"
228 ;;
229 armv*b)
230 cpu="armv4b"
231 ;;
232 armv*l)
233 cpu="armv4l"
234 ;;
235 parisc|parisc64)
236 cpu="hppa"
237 ;;
238 mips*)
239 cpu="mips"
240 ;;
241 s390)
242 cpu="s390"
243 ;;
244 s390x)
245 cpu="s390x"
246 ;;
247 sparc|sun4[cdmuv])
248 cpu="sparc"
249 ;;
250 *)
251 echo "Unsupported CPU = $cpu"
252 exit 1
253 ;;
254esac
255
256# Default value for a variable defining feature "foo".
257# * foo="no" feature will only be used if --enable-foo arg is given
258# * foo="" feature will be searched for, and if found, will be used
259# unless --disable-foo is given
260# * foo="yes" this value will only be set by --enable-foo flag.
261# feature will searched for,
262# if not found, configure exits with error
263#
264# Always add --enable-foo and --disable-foo command line args.
265# Distributions want to ensure that several features are compiled in, and it
266# is impossible without a --enable-foo that exits if a feature is not found.
267
268bluez=""
269brlapi=""
270curl=""
271curses=""
272docs=""
273fdt=""
274kvm=""
275kvm_para=""
276nptl=""
277sdl=""
278sparse="no"
279uuid=""
280vde=""
281vnc_tls=""
282vnc_sasl=""
283vnc_jpeg=""
284vnc_png=""
285vnc_thread="no"
286xen=""
287linux_aio=""
288attr=""
289vhost_net=""
290
291gprof="no"
292debug_tcg="no"
293debug_mon="no"
294debug="no"
295strip_opt="yes"
296bigendian="no"
297mingw32="no"
298EXESUF=""
299prefix="/usr/local"
300mandir="\${prefix}/share/man"
301datadir="\${prefix}/share/qemu"
302docdir="\${prefix}/share/doc/qemu"
303bindir="\${prefix}/bin"
304sysconfdir="\${prefix}/etc"
305confsuffix="/qemu"
306slirp="yes"
307fmod_lib=""
308fmod_inc=""
309oss_lib=""
310bsd="no"
311linux="no"
312solaris="no"
313profiler="no"
314cocoa="no"
315softmmu="yes"
316linux_user="no"
317darwin_user="no"
318bsd_user="no"
319guest_base=""
320uname_release=""
321io_thread="no"
322mixemu="no"
323kerneldir=""
324aix="no"
325haiku="no"
326blobs="yes"
327pkgversion=""
328check_utests="no"
329user_pie="no"
330zero_malloc=""
331trace_backend="nop"
332trace_file="trace"
333spice=""
334
335# OS specific
336if check_define __linux__ ; then
337 targetos="Linux"
338elif check_define _WIN32 ; then
339 targetos='MINGW32'
340elif check_define __OpenBSD__ ; then
341 targetos='OpenBSD'
342elif check_define __sun__ ; then
343 targetos='SunOS'
344elif check_define __HAIKU__ ; then
345 targetos='Haiku'
346else
347 targetos=`uname -s`
348fi
349
350case $targetos in
351CYGWIN*)
352 mingw32="yes"
353 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
354 audio_possible_drivers="winwave sdl"
355 audio_drv_list="winwave"
356;;
357MINGW32*)
358 mingw32="yes"
359 audio_possible_drivers="winwave dsound sdl fmod"
360 audio_drv_list="winwave"
361;;
362GNU/kFreeBSD)
363 bsd="yes"
364 audio_drv_list="oss"
365 audio_possible_drivers="oss sdl esd pa"
366;;
367FreeBSD)
368 bsd="yes"
369 make="gmake"
370 audio_drv_list="oss"
371 audio_possible_drivers="oss sdl esd pa"
372 # needed for kinfo_getvmmap(3) in libutil.h
373 LIBS="-lutil $LIBS"
374;;
375DragonFly)
376 bsd="yes"
377 make="gmake"
378 audio_drv_list="oss"
379 audio_possible_drivers="oss sdl esd pa"
380;;
381NetBSD)
382 bsd="yes"
383 make="gmake"
384 audio_drv_list="oss"
385 audio_possible_drivers="oss sdl esd"
386 oss_lib="-lossaudio"
387;;
388OpenBSD)
389 bsd="yes"
390 make="gmake"
391 audio_drv_list="oss"
392 audio_possible_drivers="oss sdl esd"
393 oss_lib="-lossaudio"
394;;
395Darwin)
396 bsd="yes"
397 darwin="yes"
398 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
399 # run 64-bit userspace code
400 if [ "$cpu" = "i386" ] ; then
401 is_x86_64=`sysctl -n hw.optional.x86_64`
402 [ "$is_x86_64" = "1" ] && cpu=x86_64
403 fi
404 if [ "$cpu" = "x86_64" ] ; then
405 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
406 LDFLAGS="-arch x86_64 $LDFLAGS"
407 else
408 QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
409 fi
410 darwin_user="yes"
411 cocoa="yes"
412 audio_drv_list="coreaudio"
413 audio_possible_drivers="coreaudio sdl fmod"
414 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
415 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
416;;
417SunOS)
418 solaris="yes"
419 make="gmake"
420 install="ginstall"
421 ld="gld"
422 needs_libsunmath="no"
423 solarisrev=`uname -r | cut -f2 -d.`
424 # have to select again, because `uname -m` returns i86pc
425 # even on an x86_64 box.
426 solariscpu=`isainfo -k`
427 if test "${solariscpu}" = "amd64" ; then
428 cpu="x86_64"
429 fi
430 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
431 if test "$solarisrev" -le 9 ; then
432 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
433 needs_libsunmath="yes"
434 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
435 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
436 LIBS="-lsunmath $LIBS"
437 else
438 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
439 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
440 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
441 echo "Studio 11 can be downloaded from www.sun.com."
442 exit 1
443 fi
444 fi
445 fi
446 if test -f /usr/include/sys/soundcard.h ; then
447 audio_drv_list="oss"
448 fi
449 audio_possible_drivers="oss sdl"
450# needed for CMSG_ macros in sys/socket.h
451 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
452# needed for TIOCWIN* defines in termios.h
453 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
454 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
455 LIBS="-lsocket -lnsl -lresolv $LIBS"
456;;
457AIX)
458 aix="yes"
459 make="gmake"
460;;
461Haiku)
462 haiku="yes"
463 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
464 LIBS="-lposix_error_mapper -lnetwork $LIBS"
465;;
466*)
467 audio_drv_list="oss"
468 audio_possible_drivers="oss alsa sdl esd pa"
469 linux="yes"
470 linux_user="yes"
471 usb="linux"
472 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
473 audio_possible_drivers="$audio_possible_drivers fmod"
474 fi
475;;
476esac
477
478if [ "$bsd" = "yes" ] ; then
479 if [ "$darwin" != "yes" ] ; then
480 usb="bsd"
481 fi
482 bsd_user="yes"
483fi
484
485if test "$mingw32" = "yes" ; then
486 EXESUF=".exe"
487 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
488 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
489 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
490 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
491 prefix="c:/Program Files/Qemu"
492 mandir="\${prefix}"
493 datadir="\${prefix}"
494 docdir="\${prefix}"
495 bindir="\${prefix}"
496 sysconfdir="\${prefix}"
497 confsuffix=""
498fi
499
500# find source path
501source_path=`dirname "$0"`
502source_path_used="no"
503workdir=`pwd`
504if [ -z "$source_path" ]; then
505 source_path=$workdir
506else
507 source_path=`cd "$source_path"; pwd`
508fi
509[ -f "$workdir/vl.c" ] || source_path_used="yes"
510
511werror=""
512
513for opt do
514 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
515 case "$opt" in
516 --help|-h) show_help=yes
517 ;;
518 --prefix=*) prefix="$optarg"
519 ;;
520 --interp-prefix=*) interp_prefix="$optarg"
521 ;;
522 --source-path=*) source_path="$optarg"
523 source_path_used="yes"
524 ;;
525 --cross-prefix=*)
526 ;;
527 --cc=*)
528 ;;
529 --host-cc=*) host_cc="$optarg"
530 ;;
531 --make=*) make="$optarg"
532 ;;
533 --install=*) install="$optarg"
534 ;;
535 --extra-cflags=*)
536 ;;
537 --extra-ldflags=*)
538 ;;
539 --cpu=*)
540 ;;
541 --target-list=*) target_list="$optarg"
542 ;;
543 --trace-backend=*) trace_backend="$optarg"
544 ;;
545 --trace-file=*) trace_file="$optarg"
546 ;;
547 --enable-gprof) gprof="yes"
548 ;;
549 --static)
550 static="yes"
551 LDFLAGS="-static $LDFLAGS"
552 ;;
553 --mandir=*) mandir="$optarg"
554 ;;
555 --bindir=*) bindir="$optarg"
556 ;;
557 --datadir=*) datadir="$optarg"
558 ;;
559 --docdir=*) docdir="$optarg"
560 ;;
561 --sysconfdir=*) sysconfdir="$optarg"
562 ;;
563 --disable-sdl) sdl="no"
564 ;;
565 --enable-sdl) sdl="yes"
566 ;;
567 --fmod-lib=*) fmod_lib="$optarg"
568 ;;
569 --fmod-inc=*) fmod_inc="$optarg"
570 ;;
571 --oss-lib=*) oss_lib="$optarg"
572 ;;
573 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
574 ;;
575 --audio-drv-list=*) audio_drv_list="$optarg"
576 ;;
577 --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
578 ;;
579 --enable-debug-tcg) debug_tcg="yes"
580 ;;
581 --disable-debug-tcg) debug_tcg="no"
582 ;;
583 --enable-debug-mon) debug_mon="yes"
584 ;;
585 --disable-debug-mon) debug_mon="no"
586 ;;
587 --enable-debug)
588 # Enable debugging options that aren't excessively noisy
589 debug_tcg="yes"
590 debug_mon="yes"
591 debug="yes"
592 strip_opt="no"
593 ;;
594 --enable-sparse) sparse="yes"
595 ;;
596 --disable-sparse) sparse="no"
597 ;;
598 --disable-strip) strip_opt="no"
599 ;;
600 --disable-vnc-tls) vnc_tls="no"
601 ;;
602 --enable-vnc-tls) vnc_tls="yes"
603 ;;
604 --disable-vnc-sasl) vnc_sasl="no"
605 ;;
606 --enable-vnc-sasl) vnc_sasl="yes"
607 ;;
608 --disable-vnc-jpeg) vnc_jpeg="no"
609 ;;
610 --enable-vnc-jpeg) vnc_jpeg="yes"
611 ;;
612 --disable-vnc-png) vnc_png="no"
613 ;;
614 --enable-vnc-png) vnc_png="yes"
615 ;;
616 --disable-vnc-thread) vnc_thread="no"
617 ;;
618 --enable-vnc-thread) vnc_thread="yes"
619 ;;
620 --disable-slirp) slirp="no"
621 ;;
622 --disable-uuid) uuid="no"
623 ;;
624 --enable-uuid) uuid="yes"
625 ;;
626 --disable-vde) vde="no"
627 ;;
628 --enable-vde) vde="yes"
629 ;;
630 --disable-xen) xen="no"
631 ;;
632 --enable-xen) xen="yes"
633 ;;
634 --disable-brlapi) brlapi="no"
635 ;;
636 --enable-brlapi) brlapi="yes"
637 ;;
638 --disable-bluez) bluez="no"
639 ;;
640 --enable-bluez) bluez="yes"
641 ;;
642 --disable-kvm) kvm="no"
643 ;;
644 --enable-kvm) kvm="yes"
645 ;;
646 --disable-spice) spice="no"
647 ;;
648 --enable-spice) spice="yes"
649 ;;
650 --enable-profiler) profiler="yes"
651 ;;
652 --enable-cocoa)
653 cocoa="yes" ;
654 sdl="no" ;
655 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
656 ;;
657 --disable-system) softmmu="no"
658 ;;
659 --enable-system) softmmu="yes"
660 ;;
661 --disable-user)
662 linux_user="no" ;
663 bsd_user="no" ;
664 darwin_user="no"
665 ;;
666 --enable-user) ;;
667 --disable-linux-user) linux_user="no"
668 ;;
669 --enable-linux-user) linux_user="yes"
670 ;;
671 --disable-darwin-user) darwin_user="no"
672 ;;
673 --enable-darwin-user) darwin_user="yes"
674 ;;
675 --disable-bsd-user) bsd_user="no"
676 ;;
677 --enable-bsd-user) bsd_user="yes"
678 ;;
679 --enable-guest-base) guest_base="yes"
680 ;;
681 --disable-guest-base) guest_base="no"
682 ;;
683 --enable-user-pie) user_pie="yes"
684 ;;
685 --disable-user-pie) user_pie="no"
686 ;;
687 --enable-uname-release=*) uname_release="$optarg"
688 ;;
689 --sparc_cpu=*)
690 ;;
691 --enable-werror) werror="yes"
692 ;;
693 --disable-werror) werror="no"
694 ;;
695 --disable-curses) curses="no"
696 ;;
697 --enable-curses) curses="yes"
698 ;;
699 --disable-curl) curl="no"
700 ;;
701 --enable-curl) curl="yes"
702 ;;
703 --disable-fdt) fdt="no"
704 ;;
705 --enable-fdt) fdt="yes"
706 ;;
707 --disable-check-utests) check_utests="no"
708 ;;
709 --enable-check-utests) check_utests="yes"
710 ;;
711 --disable-nptl) nptl="no"
712 ;;
713 --enable-nptl) nptl="yes"
714 ;;
715 --enable-mixemu) mixemu="yes"
716 ;;
717 --disable-linux-aio) linux_aio="no"
718 ;;
719 --enable-linux-aio) linux_aio="yes"
720 ;;
721 --disable-attr) attr="no"
722 ;;
723 --enable-attr) attr="yes"
724 ;;
725 --enable-io-thread) io_thread="yes"
726 ;;
727 --disable-blobs) blobs="no"
728 ;;
729 --kerneldir=*) kerneldir="$optarg"
730 ;;
731 --with-pkgversion=*) pkgversion=" ($optarg)"
732 ;;
733 --disable-docs) docs="no"
734 ;;
735 --enable-docs) docs="yes"
736 ;;
737 --disable-vhost-net) vhost_net="no"
738 ;;
739 --enable-vhost-net) vhost_net="yes"
740 ;;
741 --*dir)
742 ;;
743 *) echo "ERROR: unknown option $opt"; show_help="yes"
744 ;;
745 esac
746done
747
748#
749# If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
750# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
751#
752host_guest_base="no"
753case "$cpu" in
754 sparc) case $sparc_cpu in
755 v7|v8)
756 QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
757 ;;
758 v8plus|v8plusa)
759 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
760 ;;
761 *) # sparc_cpu not defined in the command line
762 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
763 esac
764 LDFLAGS="-m32 $LDFLAGS"
765 QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
766 if test "$solaris" = "no" ; then
767 QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
768 helper_cflags="-ffixed-i0"
769 fi
770 ;;
771 sparc64)
772 QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
773 LDFLAGS="-m64 $LDFLAGS"
774 QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
775 if test "$solaris" != "no" ; then
776 QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
777 fi
778 ;;
779 s390)
780 QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
781 LDFLAGS="-m31 $LDFLAGS"
782 host_guest_base="yes"
783 ;;
784 s390x)
785 QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
786 LDFLAGS="-m64 $LDFLAGS"
787 host_guest_base="yes"
788 ;;
789 i386)
790 QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
791 LDFLAGS="-m32 $LDFLAGS"
792 helper_cflags="-fomit-frame-pointer"
793 host_guest_base="yes"
794 ;;
795 x86_64)
796 QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
797 LDFLAGS="-m64 $LDFLAGS"
798 host_guest_base="yes"
799 ;;
800 arm*)
801 host_guest_base="yes"
802 ;;
803 ppc*)
804 host_guest_base="yes"
805 ;;
806 mips*)
807 host_guest_base="yes"
808 ;;
809 ia64*)
810 host_guest_base="yes"
811 ;;
812 hppa*)
813 host_guest_base="yes"
814 ;;
815esac
816
817[ -z "$guest_base" ] && guest_base="$host_guest_base"
818
819if test x"$show_help" = x"yes" ; then
820cat << EOF
821
822Usage: configure [options]
823Options: [defaults in brackets after descriptions]
824
825EOF
826echo "Standard options:"
827echo " --help print this message"
828echo " --prefix=PREFIX install in PREFIX [$prefix]"
829echo " --interp-prefix=PREFIX where to find shared libraries, etc."
830echo " use %M for cpu name [$interp_prefix]"
831echo " --target-list=LIST set target list [$target_list]"
832echo ""
833echo "Advanced options (experts only):"
834echo " --source-path=PATH path of source code [$source_path]"
835echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
836echo " --cc=CC use C compiler CC [$cc]"
837echo " --host-cc=CC use C compiler CC [$host_cc] for code run at"
838echo " build time"
839echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
840echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
841echo " --make=MAKE use specified make [$make]"
842echo " --install=INSTALL use specified install [$install]"
843echo " --static enable static build [$static]"
844echo " --mandir=PATH install man pages in PATH"
845echo " --datadir=PATH install firmware in PATH"
846echo " --docdir=PATH install documentation in PATH"
847echo " --bindir=PATH install binaries in PATH"
848echo " --sysconfdir=PATH install config in PATH/qemu"
849echo " --enable-debug-tcg enable TCG debugging"
850echo " --disable-debug-tcg disable TCG debugging (default)"
851echo " --enable-debug enable common debug build options"
852echo " --enable-sparse enable sparse checker"
853echo " --disable-sparse disable sparse checker (default)"
854echo " --disable-strip disable stripping binaries"
855echo " --disable-werror disable compilation abort on warning"
856echo " --disable-sdl disable SDL"
857echo " --enable-sdl enable SDL"
858echo " --enable-cocoa enable COCOA (Mac OS X only)"
859echo " --audio-drv-list=LIST set audio drivers list:"
860echo " Available drivers: $audio_possible_drivers"
861echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
862echo " Available cards: $audio_possible_cards"
863echo " --block-drv-whitelist=L set block driver whitelist"
864echo " (affects only QEMU, not qemu-img)"
865echo " --enable-mixemu enable mixer emulation"
866echo " --disable-xen disable xen backend driver support"
867echo " --enable-xen enable xen backend driver support"
868echo " --disable-brlapi disable BrlAPI"
869echo " --enable-brlapi enable BrlAPI"
870echo " --disable-vnc-tls disable TLS encryption for VNC server"
871echo " --enable-vnc-tls enable TLS encryption for VNC server"
872echo " --disable-vnc-sasl disable SASL encryption for VNC server"
873echo " --enable-vnc-sasl enable SASL encryption for VNC server"
874echo " --disable-vnc-jpeg disable JPEG lossy compression for VNC server"
875echo " --enable-vnc-jpeg enable JPEG lossy compression for VNC server"
876echo " --disable-vnc-png disable PNG compression for VNC server (default)"
877echo " --enable-vnc-png enable PNG compression for VNC server"
878echo " --disable-vnc-thread disable threaded VNC server"
879echo " --enable-vnc-thread enable threaded VNC server"
880echo " --disable-curses disable curses output"
881echo " --enable-curses enable curses output"
882echo " --disable-curl disable curl connectivity"
883echo " --enable-curl enable curl connectivity"
884echo " --disable-fdt disable fdt device tree"
885echo " --enable-fdt enable fdt device tree"
886echo " --disable-check-utests disable check unit-tests"
887echo " --enable-check-utests enable check unit-tests"
888echo " --disable-bluez disable bluez stack connectivity"
889echo " --enable-bluez enable bluez stack connectivity"
890echo " --disable-kvm disable KVM acceleration support"
891echo " --enable-kvm enable KVM acceleration support"
892echo " --disable-nptl disable usermode NPTL support"
893echo " --enable-nptl enable usermode NPTL support"
894echo " --enable-system enable all system emulation targets"
895echo " --disable-system disable all system emulation targets"
896echo " --enable-user enable supported user emulation targets"
897echo " --disable-user disable all user emulation targets"
898echo " --enable-linux-user enable all linux usermode emulation targets"
899echo " --disable-linux-user disable all linux usermode emulation targets"
900echo " --enable-darwin-user enable all darwin usermode emulation targets"
901echo " --disable-darwin-user disable all darwin usermode emulation targets"
902echo " --enable-bsd-user enable all BSD usermode emulation targets"
903echo " --disable-bsd-user disable all BSD usermode emulation targets"
904echo " --enable-guest-base enable GUEST_BASE support for usermode"
905echo " emulation targets"
906echo " --disable-guest-base disable GUEST_BASE support"
907echo " --enable-user-pie build usermode emulation targets as PIE"
908echo " --disable-user-pie do not build usermode emulation targets as PIE"
909echo " --fmod-lib path to FMOD library"
910echo " --fmod-inc path to FMOD includes"
911echo " --oss-lib path to OSS library"
912echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
913echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
914echo " --disable-uuid disable uuid support"
915echo " --enable-uuid enable uuid support"
916echo " --disable-vde disable support for vde network"
917echo " --enable-vde enable support for vde network"
918echo " --disable-linux-aio disable Linux AIO support"
919echo " --enable-linux-aio enable Linux AIO support"
920echo " --disable-attr disables attr and xattr support"
921echo " --enable-attr enable attr and xattr support"
922echo " --enable-io-thread enable IO thread"
923echo " --disable-blobs disable installing provided firmware blobs"
924echo " --kerneldir=PATH look for kernel includes in PATH"
925echo " --enable-docs enable documentation build"
926echo " --disable-docs disable documentation build"
927echo " --disable-vhost-net disable vhost-net acceleration support"
928echo " --enable-vhost-net enable vhost-net acceleration support"
929echo " --trace-backend=B Trace backend nop simple ust"
930echo " --trace-file=NAME Full PATH,NAME of file to store traces"
931echo " Default:trace-<pid>"
932echo " --disable-spice disable spice"
933echo " --enable-spice enable spice"
934echo ""
935echo "NOTE: The object files are built at the place where configure is launched"
936exit 1
937fi
938
939#
940# Solaris specific configure tool chain decisions
941#
942if test "$solaris" = "yes" ; then
943 if has $install; then
944 :
945 else
946 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
947 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
948 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
949 exit 1
950 fi
951 if test "`path_of $install`" = "/usr/sbin/install" ; then
952 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
953 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
954 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
955 exit 1
956 fi
957 if has ar; then
958 :
959 else
960 echo "Error: No path includes ar"
961 if test -f /usr/ccs/bin/ar ; then
962 echo "Add /usr/ccs/bin to your path and rerun configure"
963 fi
964 exit 1
965 fi
966fi
967
968
969if test -z "$target_list" ; then
970# these targets are portable
971 if [ "$softmmu" = "yes" ] ; then
972 target_list="\
973i386-softmmu \
974x86_64-softmmu \
975arm-softmmu \
976cris-softmmu \
977m68k-softmmu \
978microblaze-softmmu \
979mips-softmmu \
980mipsel-softmmu \
981mips64-softmmu \
982mips64el-softmmu \
983ppc-softmmu \
984ppcemb-softmmu \
985ppc64-softmmu \
986sh4-softmmu \
987sh4eb-softmmu \
988sparc-softmmu \
989sparc64-softmmu \
990"
991 fi
992# the following are Linux specific
993 if [ "$linux_user" = "yes" ] ; then
994 target_list="${target_list}\
995i386-linux-user \
996x86_64-linux-user \
997alpha-linux-user \
998arm-linux-user \
999armeb-linux-user \
1000cris-linux-user \
1001m68k-linux-user \
1002microblaze-linux-user \
1003mips-linux-user \
1004mipsel-linux-user \
1005ppc-linux-user \
1006ppc64-linux-user \
1007ppc64abi32-linux-user \
1008sh4-linux-user \
1009sh4eb-linux-user \
1010sparc-linux-user \
1011sparc64-linux-user \
1012sparc32plus-linux-user \
1013"
1014 fi
1015# the following are Darwin specific
1016 if [ "$darwin_user" = "yes" ] ; then
1017 target_list="$target_list i386-darwin-user ppc-darwin-user "
1018 fi
1019# the following are BSD specific
1020 if [ "$bsd_user" = "yes" ] ; then
1021 target_list="${target_list}\
1022i386-bsd-user \
1023x86_64-bsd-user \
1024sparc-bsd-user \
1025sparc64-bsd-user \
1026"
1027 fi
1028else
1029 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
1030fi
1031if test -z "$target_list" ; then
1032 echo "No targets enabled"
1033 exit 1
1034fi
1035# see if system emulation was really requested
1036case " $target_list " in
1037 *"-softmmu "*) softmmu=yes
1038 ;;
1039 *) softmmu=no
1040 ;;
1041esac
1042
1043feature_not_found() {
1044 feature=$1
1045
1046 echo "ERROR"
1047 echo "ERROR: User requested feature $feature"
1048 echo "ERROR: configure was not able to find it"
1049 echo "ERROR"
1050 exit 1;
1051}
1052
1053if test -z "$cross_prefix" ; then
1054
1055# ---
1056# big/little endian test
1057cat > $TMPC << EOF
1058#include <inttypes.h>
1059int main(int argc, char ** argv){
1060 volatile uint32_t i=0x01234567;
1061 return (*((uint8_t*)(&i))) == 0x67;
1062}
1063EOF
1064
1065if compile_prog "" "" ; then
1066$TMPE && bigendian="yes"
1067else
1068echo big/little test failed
1069fi
1070
1071else
1072
1073# if cross compiling, cannot launch a program, so make a static guess
1074case "$cpu" in
1075 armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1076 bigendian=yes
1077 ;;
1078esac
1079
1080fi
1081
1082# host long bits test
1083hostlongbits="32"
1084case "$cpu" in
1085 x86_64|alpha|ia64|sparc64|ppc64|s390x)
1086 hostlongbits=64
1087 ;;
1088esac
1089
1090
1091##########################################
1092# NPTL probe
1093
1094if test "$nptl" != "no" ; then
1095 cat > $TMPC <<EOF
1096#include <sched.h>
1097#include <linux/futex.h>
1098void foo()
1099{
1100#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1101#error bork
1102#endif
1103}
1104EOF
1105
1106 if compile_object ; then
1107 nptl=yes
1108 else
1109 if test "$nptl" = "yes" ; then
1110 feature_not_found "nptl"
1111 fi
1112 nptl=no
1113 fi
1114fi
1115
1116##########################################
1117# zlib check
1118
1119cat > $TMPC << EOF
1120#include <zlib.h>
1121int main(void) { zlibVersion(); return 0; }
1122EOF
1123if compile_prog "" "-lz" ; then
1124 :
1125else
1126 echo
1127 echo "Error: zlib check failed"
1128 echo "Make sure to have the zlib libs and headers installed."
1129 echo
1130 exit 1
1131fi
1132
1133##########################################
1134# xen probe
1135
1136if test "$xen" != "no" ; then
1137 xen_libs="-lxenstore -lxenctrl -lxenguest"
1138 cat > $TMPC <<EOF
1139#include <xenctrl.h>
1140#include <xs.h>
1141int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1142EOF
1143 if compile_prog "" "$xen_libs" ; then
1144 xen=yes
1145 libs_softmmu="$xen_libs $libs_softmmu"
1146 else
1147 if test "$xen" = "yes" ; then
1148 feature_not_found "xen"
1149 fi
1150 xen=no
1151 fi
1152fi
1153
1154##########################################
1155# pkgconfig probe
1156
1157pkgconfig="${cross_prefix}pkg-config"
1158if ! has $pkgconfig; then
1159 # likely not cross compiling, or hope for the best
1160 pkgconfig=pkg-config
1161fi
1162
1163##########################################
1164# Sparse probe
1165if test "$sparse" != "no" ; then
1166 if has cgcc; then
1167 sparse=yes
1168 else
1169 if test "$sparse" = "yes" ; then
1170 feature_not_found "sparse"
1171 fi
1172 sparse=no
1173 fi
1174fi
1175
1176##########################################
1177# SDL probe
1178
1179# Look for sdl configuration program (pkg-config or sdl-config).
1180# Prefer variant with cross prefix if cross compiling,
1181# and favour pkg-config with sdl over sdl-config.
1182if test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
1183 $pkgconfig sdl --modversion >/dev/null 2>&1; then
1184 sdlconfig="$pkgconfig sdl"
1185 _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1186elif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
1187 sdlconfig="${cross_prefix}sdl-config"
1188 _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1189elif $pkgconfig sdl --modversion >/dev/null 2>&1; then
1190 sdlconfig="$pkgconfig sdl"
1191 _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1192elif has sdl-config; then
1193 sdlconfig='sdl-config'
1194 _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1195else
1196 if test "$sdl" = "yes" ; then
1197 feature_not_found "sdl"
1198 fi
1199 sdl=no
1200fi
1201
1202sdl_too_old=no
1203if test "$sdl" != "no" ; then
1204 cat > $TMPC << EOF
1205#include <SDL.h>
1206#undef main /* We don't want SDL to override our main() */
1207int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1208EOF
1209 sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
1210 if test "$static" = "yes" ; then
1211 sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
1212 else
1213 sdl_libs=`$sdlconfig --libs 2> /dev/null`
1214 fi
1215 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1216 if test "$_sdlversion" -lt 121 ; then
1217 sdl_too_old=yes
1218 else
1219 if test "$cocoa" = "no" ; then
1220 sdl=yes
1221 fi
1222 fi
1223
1224 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
1225 if test "$sdl" = "yes" -a "$static" = "yes" ; then
1226 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1227 sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1228 sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
1229 fi
1230 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1231 :
1232 else
1233 sdl=no
1234 fi
1235 fi # static link
1236 else # sdl not found
1237 if test "$sdl" = "yes" ; then
1238 feature_not_found "sdl"
1239 fi
1240 sdl=no
1241 fi # sdl compile test
1242fi
1243
1244if test "$sdl" = "yes" ; then
1245 cat > $TMPC <<EOF
1246#include <SDL.h>
1247#if defined(SDL_VIDEO_DRIVER_X11)
1248#include <X11/XKBlib.h>
1249#else
1250#error No x11 support
1251#endif
1252int main(void) { return 0; }
1253EOF
1254 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1255 sdl_libs="$sdl_libs -lX11"
1256 fi
1257 if test "$mingw32" = "yes" ; then
1258 sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1259 fi
1260 libs_softmmu="$sdl_libs $libs_softmmu"
1261fi
1262
1263##########################################
1264# VNC TLS detection
1265if test "$vnc_tls" != "no" ; then
1266 cat > $TMPC <<EOF
1267#include <gnutls/gnutls.h>
1268int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1269EOF
1270 vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
1271 vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
1272 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1273 vnc_tls=yes
1274 libs_softmmu="$vnc_tls_libs $libs_softmmu"
1275 else
1276 if test "$vnc_tls" = "yes" ; then
1277 feature_not_found "vnc-tls"
1278 fi
1279 vnc_tls=no
1280 fi
1281fi
1282
1283##########################################
1284# VNC SASL detection
1285if test "$vnc_sasl" != "no" ; then
1286 cat > $TMPC <<EOF
1287#include <sasl/sasl.h>
1288#include <stdio.h>
1289int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1290EOF
1291 # Assuming Cyrus-SASL installed in /usr prefix
1292 vnc_sasl_cflags=""
1293 vnc_sasl_libs="-lsasl2"
1294 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1295 vnc_sasl=yes
1296 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1297 else
1298 if test "$vnc_sasl" = "yes" ; then
1299 feature_not_found "vnc-sasl"
1300 fi
1301 vnc_sasl=no
1302 fi
1303fi
1304
1305##########################################
1306# VNC JPEG detection
1307if test "$vnc_jpeg" != "no" ; then
1308cat > $TMPC <<EOF
1309#include <stdio.h>
1310#include <jpeglib.h>
1311int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
1312EOF
1313 vnc_jpeg_cflags=""
1314 vnc_jpeg_libs="-ljpeg"
1315 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
1316 vnc_jpeg=yes
1317 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1318 else
1319 if test "$vnc_jpeg" = "yes" ; then
1320 feature_not_found "vnc-jpeg"
1321 fi
1322 vnc_jpeg=no
1323 fi
1324fi
1325
1326##########################################
1327# VNC PNG detection
1328if test "$vnc_png" != "no" ; then
1329cat > $TMPC <<EOF
1330//#include <stdio.h>
1331#include <png.h>
1332#include <stddef.h>
1333int main(void) {
1334 png_structp png_ptr;
1335 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1336 return 0;
1337}
1338EOF
1339 vnc_png_cflags=""
1340 vnc_png_libs="-lpng"
1341 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1342 vnc_png=yes
1343 libs_softmmu="$vnc_png_libs $libs_softmmu"
1344 else
1345 if test "$vnc_png" = "yes" ; then
1346 feature_not_found "vnc-png"
1347 fi
1348 vnc_png=no
1349 fi
1350fi
1351
1352##########################################
1353# fnmatch() probe, used for ACL routines
1354fnmatch="no"
1355cat > $TMPC << EOF
1356#include <fnmatch.h>
1357int main(void)
1358{
1359 fnmatch("foo", "foo", 0);
1360 return 0;
1361}
1362EOF
1363if compile_prog "" "" ; then
1364 fnmatch="yes"
1365fi
1366
1367##########################################
1368# uuid_generate() probe, used for vdi block driver
1369if test "$uuid" != "no" ; then
1370 uuid_libs="-luuid"
1371 cat > $TMPC << EOF
1372#include <uuid/uuid.h>
1373int main(void)
1374{
1375 uuid_t my_uuid;
1376 uuid_generate(my_uuid);
1377 return 0;
1378}
1379EOF
1380 if compile_prog "" "$uuid_libs" ; then
1381 uuid="yes"
1382 libs_softmmu="$uuid_libs $libs_softmmu"
1383 libs_tools="$uuid_libs $libs_tools"
1384 else
1385 if test "$uuid" = "yes" ; then
1386 feature_not_found "uuid"
1387 fi
1388 uuid=no
1389 fi
1390fi
1391
1392##########################################
1393# vde libraries probe
1394if test "$vde" != "no" ; then
1395 vde_libs="-lvdeplug"
1396 cat > $TMPC << EOF
1397#include <libvdeplug.h>
1398int main(void)
1399{
1400 struct vde_open_args a = {0, 0, 0};
1401 vde_open("", "", &a);
1402 return 0;
1403}
1404EOF
1405 if compile_prog "" "$vde_libs" ; then
1406 vde=yes
1407 libs_softmmu="$vde_libs $libs_softmmu"
1408 libs_tools="$vde_libs $libs_tools"
1409 else
1410 if test "$vde" = "yes" ; then
1411 feature_not_found "vde"
1412 fi
1413 vde=no
1414 fi
1415fi
1416
1417##########################################
1418# Sound support libraries probe
1419
1420audio_drv_probe()
1421{
1422 drv=$1
1423 hdr=$2
1424 lib=$3
1425 exp=$4
1426 cfl=$5
1427 cat > $TMPC << EOF
1428#include <$hdr>
1429int main(void) { $exp }
1430EOF
1431 if compile_prog "$cfl" "$lib" ; then
1432 :
1433 else
1434 echo
1435 echo "Error: $drv check failed"
1436 echo "Make sure to have the $drv libs and headers installed."
1437 echo
1438 exit 1
1439 fi
1440}
1441
1442audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1443for drv in $audio_drv_list; do
1444 case $drv in
1445 alsa)
1446 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1447 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1448 libs_softmmu="-lasound $libs_softmmu"
1449 ;;
1450
1451 fmod)
1452 if test -z $fmod_lib || test -z $fmod_inc; then
1453 echo
1454 echo "Error: You must specify path to FMOD library and headers"
1455 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1456 echo
1457 exit 1
1458 fi
1459 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1460 libs_softmmu="$fmod_lib $libs_softmmu"
1461 ;;
1462
1463 esd)
1464 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1465 libs_softmmu="-lesd $libs_softmmu"
1466 audio_pt_int="yes"
1467 ;;
1468
1469 pa)
1470 audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1471 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1472 libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
1473 audio_pt_int="yes"
1474 ;;
1475
1476 coreaudio)
1477 libs_softmmu="-framework CoreAudio $libs_softmmu"
1478 ;;
1479
1480 dsound)
1481 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1482 audio_win_int="yes"
1483 ;;
1484
1485 oss)
1486 libs_softmmu="$oss_lib $libs_softmmu"
1487 ;;
1488
1489 sdl|wav)
1490 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1491 ;;
1492
1493 winwave)
1494 libs_softmmu="-lwinmm $libs_softmmu"
1495 audio_win_int="yes"
1496 ;;
1497
1498 *)
1499 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1500 echo
1501 echo "Error: Unknown driver '$drv' selected"
1502 echo "Possible drivers are: $audio_possible_drivers"
1503 echo
1504 exit 1
1505 }
1506 ;;
1507 esac
1508done
1509
1510##########################################
1511# BrlAPI probe
1512
1513if test "$brlapi" != "no" ; then
1514 brlapi_libs="-lbrlapi"
1515 cat > $TMPC << EOF
1516#include <brlapi.h>
1517#include <stddef.h>
1518int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1519EOF
1520 if compile_prog "" "$brlapi_libs" ; then
1521 brlapi=yes
1522 libs_softmmu="$brlapi_libs $libs_softmmu"
1523 else
1524 if test "$brlapi" = "yes" ; then
1525 feature_not_found "brlapi"
1526 fi
1527 brlapi=no
1528 fi
1529fi
1530
1531##########################################
1532# curses probe
1533curses_list="-lncurses -lcurses"
1534
1535if test "$curses" != "no" ; then
1536 curses_found=no
1537 cat > $TMPC << EOF
1538#include <curses.h>
1539#ifdef __OpenBSD__
1540#define resize_term resizeterm
1541#endif
1542int main(void) { resize_term(0, 0); return curses_version(); }
1543EOF
1544 for curses_lib in $curses_list; do
1545 if compile_prog "" "$curses_lib" ; then
1546 curses_found=yes
1547 libs_softmmu="$curses_lib $libs_softmmu"
1548 break
1549 fi
1550 done
1551 if test "$curses_found" = "yes" ; then
1552 curses=yes
1553 else
1554 if test "$curses" = "yes" ; then
1555 feature_not_found "curses"
1556 fi
1557 curses=no
1558 fi
1559fi
1560
1561##########################################
1562# curl probe
1563
1564if $pkgconfig libcurl --modversion >/dev/null 2>&1; then
1565 curlconfig="$pkgconfig libcurl"
1566else
1567 curlconfig=curl-config
1568fi
1569
1570if test "$curl" != "no" ; then
1571 cat > $TMPC << EOF
1572#include <curl/curl.h>
1573int main(void) { return curl_easy_init(); }
1574EOF
1575 curl_cflags=`$curlconfig --cflags 2>/dev/null`
1576 curl_libs=`$curlconfig --libs 2>/dev/null`
1577 if compile_prog "$curl_cflags" "$curl_libs" ; then
1578 curl=yes
1579 libs_tools="$curl_libs $libs_tools"
1580 libs_softmmu="$curl_libs $libs_softmmu"
1581 else
1582 if test "$curl" = "yes" ; then
1583 feature_not_found "curl"
1584 fi
1585 curl=no
1586 fi
1587fi # test "$curl"
1588
1589##########################################
1590# check framework probe
1591
1592if test "$check_utests" != "no" ; then
1593 cat > $TMPC << EOF
1594#include <check.h>
1595int main(void) { suite_create("qemu test"); return 0; }
1596EOF
1597 check_libs=`$pkgconfig --libs check`
1598 if compile_prog "" $check_libs ; then
1599 check_utests=yes
1600 libs_tools="$check_libs $libs_tools"
1601 else
1602 if test "$check_utests" = "yes" ; then
1603 feature_not_found "check"
1604 fi
1605 check_utests=no
1606 fi
1607fi # test "$check_utests"
1608
1609##########################################
1610# bluez support probe
1611if test "$bluez" != "no" ; then
1612 cat > $TMPC << EOF
1613#include <bluetooth/bluetooth.h>
1614int main(void) { return bt_error(0); }
1615EOF
1616 bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
1617 bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
1618 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1619 bluez=yes
1620 libs_softmmu="$bluez_libs $libs_softmmu"
1621 else
1622 if test "$bluez" = "yes" ; then
1623 feature_not_found "bluez"
1624 fi
1625 bluez="no"
1626 fi
1627fi
1628
1629##########################################
1630# kvm probe
1631if test "$kvm" != "no" ; then
1632 cat > $TMPC <<EOF
1633#include <linux/kvm.h>
1634#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1635#error Invalid KVM version
1636#endif
1637#if !defined(KVM_CAP_USER_MEMORY)
1638#error Missing KVM capability KVM_CAP_USER_MEMORY
1639#endif
1640#if !defined(KVM_CAP_SET_TSS_ADDR)
1641#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1642#endif
1643#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1644#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1645#endif
1646int main(void) { return 0; }
1647EOF
1648 if test "$kerneldir" != "" ; then
1649 kvm_cflags=-I"$kerneldir"/include
1650 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1651 -a -d "$kerneldir/arch/x86/include" ; then
1652 kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1653 elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1654 kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1655 elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
1656 kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
1657 elif test -d "$kerneldir/arch/$cpu/include" ; then
1658 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1659 fi
1660 else
1661 kvm_cflags=`$pkgconfig --cflags kvm-kmod 2>/dev/null`
1662 fi
1663 if compile_prog "$kvm_cflags" "" ; then
1664 kvm=yes
1665 cat > $TMPC <<EOF
1666#include <linux/kvm_para.h>
1667int main(void) { return 0; }
1668EOF
1669 if compile_prog "$kvm_cflags" "" ; then
1670 kvm_para=yes
1671 fi
1672 else
1673 if test "$kvm" = "yes" ; then
1674 if has awk && has grep; then
1675 kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1676 | grep "error: " \
1677 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1678 if test "$kvmerr" != "" ; then
1679 echo -e "${kvmerr}\n\
1680 NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1681 recent kvm-kmod from http://sourceforge.net/projects/kvm."
1682 fi
1683 fi
1684 feature_not_found "kvm"
1685 fi
1686 kvm=no
1687 fi
1688fi
1689
1690##########################################
1691# test for vhost net
1692
1693if test "$vhost_net" != "no"; then
1694 if test "$kvm" != "no"; then
1695 cat > $TMPC <<EOF
1696 #include <linux/vhost.h>
1697 int main(void) { return 0; }
1698EOF
1699 if compile_prog "$kvm_cflags" "" ; then
1700 vhost_net=yes
1701 else
1702 if test "$vhost_net" = "yes" ; then
1703 feature_not_found "vhost-net"
1704 fi
1705 vhost_net=no
1706 fi
1707 else
1708 if test "$vhost_net" = "yes" ; then
1709 echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1710 feature_not_found "vhost-net"
1711 fi
1712 vhost_net=no
1713 fi
1714fi
1715
1716##########################################
1717# pthread probe
1718PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1719
1720pthread=no
1721cat > $TMPC << EOF
1722#include <pthread.h>
1723int main(void) { pthread_create(0,0,0,0); return 0; }
1724EOF
1725if compile_prog "" "" ; then
1726 pthread=yes
1727else
1728 for pthread_lib in $PTHREADLIBS_LIST; do
1729 if compile_prog "" "$pthread_lib" ; then
1730 pthread=yes
1731 LIBS="$pthread_lib $LIBS"
1732 break
1733 fi
1734 done
1735fi
1736
1737if test "$mingw32" != yes -a "$pthread" = no; then
1738 echo
1739 echo "Error: pthread check failed"
1740 echo "Make sure to have the pthread libs and headers installed."
1741 echo
1742 exit 1
1743fi
1744
1745##########################################
1746# linux-aio probe
1747
1748if test "$linux_aio" != "no" ; then
1749 cat > $TMPC <<EOF
1750#include <libaio.h>
1751#include <sys/eventfd.h>
1752#include <stddef.h>
1753int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1754EOF
1755 if compile_prog "" "-laio" ; then
1756 linux_aio=yes
1757 libs_softmmu="$libs_softmmu -laio"
1758 libs_tools="$libs_tools -laio"
1759 else
1760 if test "$linux_aio" = "yes" ; then
1761 feature_not_found "linux AIO"
1762 fi
1763 linux_aio=no
1764 fi
1765fi
1766
1767##########################################
1768# attr probe
1769
1770if test "$attr" != "no" ; then
1771 cat > $TMPC <<EOF
1772#include <stdio.h>
1773#include <sys/types.h>
1774#include <attr/xattr.h>
1775int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1776EOF
1777 if compile_prog "" "-lattr" ; then
1778 attr=yes
1779 LIBS="-lattr $LIBS"
1780 else
1781 if test "$attr" = "yes" ; then
1782 feature_not_found "ATTR"
1783 fi
1784 attr=no
1785 fi
1786fi
1787
1788##########################################
1789# iovec probe
1790cat > $TMPC <<EOF
1791#include <sys/types.h>
1792#include <sys/uio.h>
1793#include <unistd.h>
1794int main(void) { struct iovec iov; return 0; }
1795EOF
1796iovec=no
1797if compile_prog "" "" ; then
1798 iovec=yes
1799fi
1800
1801##########################################
1802# preadv probe
1803cat > $TMPC <<EOF
1804#include <sys/types.h>
1805#include <sys/uio.h>
1806#include <unistd.h>
1807int main(void) { preadv; }
1808EOF
1809preadv=no
1810if compile_prog "" "" ; then
1811 preadv=yes
1812fi
1813
1814##########################################
1815# fdt probe
1816if test "$fdt" != "no" ; then
1817 fdt_libs="-lfdt"
1818 cat > $TMPC << EOF
1819int main(void) { return 0; }
1820EOF
1821 if compile_prog "" "$fdt_libs" ; then
1822 fdt=yes
1823 libs_softmmu="$fdt_libs $libs_softmmu"
1824 else
1825 if test "$fdt" = "yes" ; then
1826 feature_not_found "fdt"
1827 fi
1828 fdt=no
1829 fi
1830fi
1831
1832#
1833# Check for xxxat() functions when we are building linux-user
1834# emulator. This is done because older glibc versions don't
1835# have syscall stubs for these implemented.
1836#
1837atfile=no
1838cat > $TMPC << EOF
1839#define _ATFILE_SOURCE
1840#include <sys/types.h>
1841#include <fcntl.h>
1842#include <unistd.h>
1843
1844int
1845main(void)
1846{
1847 /* try to unlink nonexisting file */
1848 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1849}
1850EOF
1851if compile_prog "" "" ; then
1852 atfile=yes
1853fi
1854
1855# Check for inotify functions when we are building linux-user
1856# emulator. This is done because older glibc versions don't
1857# have syscall stubs for these implemented. In that case we
1858# don't provide them even if kernel supports them.
1859#
1860inotify=no
1861cat > $TMPC << EOF
1862#include <sys/inotify.h>
1863
1864int
1865main(void)
1866{
1867 /* try to start inotify */
1868 return inotify_init();
1869}
1870EOF
1871if compile_prog "" "" ; then
1872 inotify=yes
1873fi
1874
1875inotify1=no
1876cat > $TMPC << EOF
1877#include <sys/inotify.h>
1878
1879int
1880main(void)
1881{
1882 /* try to start inotify */
1883 return inotify_init1(0);
1884}
1885EOF
1886if compile_prog "" "" ; then
1887 inotify1=yes
1888fi
1889
1890# check if utimensat and futimens are supported
1891utimens=no
1892cat > $TMPC << EOF
1893#define _ATFILE_SOURCE
1894#include <stddef.h>
1895#include <fcntl.h>
1896
1897int main(void)
1898{
1899 utimensat(AT_FDCWD, "foo", NULL, 0);
1900 futimens(0, NULL);
1901 return 0;
1902}
1903EOF
1904if compile_prog "" "" ; then
1905 utimens=yes
1906fi
1907
1908# check if pipe2 is there
1909pipe2=no
1910cat > $TMPC << EOF
1911#include <unistd.h>
1912#include <fcntl.h>
1913
1914int main(void)
1915{
1916 int pipefd[2];
1917 pipe2(pipefd, O_CLOEXEC);
1918 return 0;
1919}
1920EOF
1921if compile_prog "" "" ; then
1922 pipe2=yes
1923fi
1924
1925# check if accept4 is there
1926accept4=no
1927cat > $TMPC << EOF
1928#include <sys/socket.h>
1929#include <stddef.h>
1930
1931int main(void)
1932{
1933 accept4(0, NULL, NULL, SOCK_CLOEXEC);
1934 return 0;
1935}
1936EOF
1937if compile_prog "" "" ; then
1938 accept4=yes
1939fi
1940
1941# check if tee/splice is there. vmsplice was added same time.
1942splice=no
1943cat > $TMPC << EOF
1944#include <unistd.h>
1945#include <fcntl.h>
1946#include <limits.h>
1947
1948int main(void)
1949{
1950 int len, fd;
1951 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1952 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1953 return 0;
1954}
1955EOF
1956if compile_prog "" "" ; then
1957 splice=yes
1958fi
1959
1960##########################################
1961# signalfd probe
1962signalfd="no"
1963cat > $TMPC << EOF
1964#define _GNU_SOURCE
1965#include <unistd.h>
1966#include <sys/syscall.h>
1967#include <signal.h>
1968int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
1969EOF
1970
1971if compile_prog "" "" ; then
1972 signalfd=yes
1973fi
1974
1975# check if eventfd is supported
1976eventfd=no
1977cat > $TMPC << EOF
1978#include <sys/eventfd.h>
1979
1980int main(void)
1981{
1982 int efd = eventfd(0, 0);
1983 return 0;
1984}
1985EOF
1986if compile_prog "" "" ; then
1987 eventfd=yes
1988fi
1989
1990# check for fallocate
1991fallocate=no
1992cat > $TMPC << EOF
1993#include <fcntl.h>
1994
1995int main(void)
1996{
1997 fallocate(0, 0, 0, 0);
1998 return 0;
1999}
2000EOF
2001if compile_prog "$ARCH_CFLAGS" "" ; then
2002 fallocate=yes
2003fi
2004
2005# check for dup3
2006dup3=no
2007cat > $TMPC << EOF
2008#include <unistd.h>
2009
2010int main(void)
2011{
2012 dup3(0, 0, 0);
2013 return 0;
2014}
2015EOF
2016if compile_prog "" "" ; then
2017 dup3=yes
2018fi
2019
2020# Check if tools are available to build documentation.
2021if test "$docs" != "no" ; then
2022 if has makeinfo && has pod2man; then
2023 docs=yes
2024 else
2025 if test "$docs" = "yes" ; then
2026 feature_not_found "docs"
2027 fi
2028 docs=no
2029 fi
2030fi
2031
2032# Search for bswap_32 function
2033byteswap_h=no
2034cat > $TMPC << EOF
2035#include <byteswap.h>
2036int main(void) { return bswap_32(0); }
2037EOF
2038if compile_prog "" "" ; then
2039 byteswap_h=yes
2040fi
2041
2042# Search for bswap_32 function
2043bswap_h=no
2044cat > $TMPC << EOF
2045#include <sys/endian.h>
2046#include <sys/types.h>
2047#include <machine/bswap.h>
2048int main(void) { return bswap32(0); }
2049EOF
2050if compile_prog "" "" ; then
2051 bswap_h=yes
2052fi
2053
2054##########################################
2055# Do we need librt
2056cat > $TMPC <<EOF
2057#include <signal.h>
2058#include <time.h>
2059int main(void) { clockid_t id; return clock_gettime(id, NULL); }
2060EOF
2061
2062if compile_prog "" "" ; then
2063 :
2064elif compile_prog "" "-lrt" ; then
2065 LIBS="-lrt $LIBS"
2066fi
2067
2068if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2069 "$aix" != "yes" -a "$haiku" != "yes" ; then
2070 libs_softmmu="-lutil $libs_softmmu"
2071fi
2072
2073##########################################
2074# check if the compiler defines offsetof
2075
2076need_offsetof=yes
2077cat > $TMPC << EOF
2078#include <stddef.h>
2079int main(void) { struct s { int f; }; return offsetof(struct s, f); }
2080EOF
2081if compile_prog "" "" ; then
2082 need_offsetof=no
2083fi
2084
2085##########################################
2086# check if the compiler understands attribute warn_unused_result
2087#
2088# This could be smarter, but gcc -Werror does not error out even when warning
2089# about attribute warn_unused_result
2090
2091gcc_attribute_warn_unused_result=no
2092cat > $TMPC << EOF
2093#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2094#error gcc 3.3 or older
2095#endif
2096int main(void) { return 0;}
2097EOF
2098if compile_prog "" ""; then
2099 gcc_attribute_warn_unused_result=yes
2100fi
2101
2102# spice probe
2103if test "$spice" != "no" ; then
2104 cat > $TMPC << EOF
2105#include <spice.h>
2106int main(void) { spice_server_new(); return 0; }
2107EOF
2108 spice_cflags=$($pkgconfig --cflags spice-protocol spice-server 2>/dev/null)
2109 spice_libs=$($pkgconfig --libs spice-protocol spice-server 2>/dev/null)
2110 if $pkgconfig --atleast-version=0.5.3 spice-server >/dev/null 2>&1 && \
2111 compile_prog "$spice_cflags" "$spice_libs" ; then
2112 spice="yes"
2113 libs_softmmu="$libs_softmmu $spice_libs"
2114 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2115 else
2116 if test "$spice" = "yes" ; then
2117 feature_not_found "spice"
2118 fi
2119 spice="no"
2120 fi
2121fi
2122
2123##########################################
2124
2125##########################################
2126# check if we have fdatasync
2127
2128fdatasync=no
2129cat > $TMPC << EOF
2130#include <unistd.h>
2131int main(void) { return fdatasync(0); }
2132EOF
2133if compile_prog "" "" ; then
2134 fdatasync=yes
2135fi
2136
2137##########################################
2138# check if we have madvise
2139
2140madvise=no
2141cat > $TMPC << EOF
2142#include <sys/types.h>
2143#include <sys/mman.h>
2144#include <stddef.h>
2145int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2146EOF
2147if compile_prog "" "" ; then
2148 madvise=yes
2149fi
2150
2151##########################################
2152# check if we have posix_madvise
2153
2154posix_madvise=no
2155cat > $TMPC << EOF
2156#include <sys/mman.h>
2157#include <stddef.h>
2158int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2159EOF
2160if compile_prog "" "" ; then
2161 posix_madvise=yes
2162fi
2163
2164##########################################
2165# check if trace backend exists
2166
2167sh "$source_path/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
2168if test "$?" -ne 0 ; then
2169 echo
2170 echo "Error: invalid trace backend"
2171 echo "Please choose a supported trace backend."
2172 echo
2173 exit 1
2174fi
2175
2176##########################################
2177# For 'ust' backend, test if ust headers are present
2178if test "$trace_backend" = "ust"; then
2179 cat > $TMPC << EOF
2180#include <ust/tracepoint.h>
2181#include <ust/marker.h>
2182int main(void) { return 0; }
2183EOF
2184 if compile_prog "" "" ; then
2185 LIBS="-lust $LIBS"
2186 else
2187 echo
2188 echo "Error: Trace backend 'ust' missing libust header files"
2189 echo
2190 exit 1
2191 fi
2192fi
2193##########################################
2194# End of CC checks
2195# After here, no more $cc or $ld runs
2196
2197if test "$debug" = "no" ; then
2198 CFLAGS="-O2 $CFLAGS"
2199fi
2200
2201# Consult white-list to determine whether to enable werror
2202# by default. Only enable by default for git builds
2203z_version=`cut -f3 -d. $source_path/VERSION`
2204
2205if test -z "$werror" ; then
2206 if test "$z_version" = "50" -a \
2207 "$linux" = "yes" ; then
2208 werror="yes"
2209 else
2210 werror="no"
2211 fi
2212fi
2213
2214# Disable zero malloc errors for official releases unless explicitly told to
2215# enable/disable
2216if test -z "$zero_malloc" ; then
2217 if test "$z_version" = "50" ; then
2218 zero_malloc="no"
2219 else
2220 zero_malloc="yes"
2221 fi
2222fi
2223
2224if test "$werror" = "yes" ; then
2225 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2226fi
2227
2228if test "$solaris" = "no" ; then
2229 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
2230 LDFLAGS="-Wl,--warn-common $LDFLAGS"
2231 fi
2232fi
2233
2234# Use ASLR, no-SEH and DEP if available
2235if test "$mingw32" = "yes" ; then
2236 for flag in --dynamicbase --no-seh --nxcompat; do
2237 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2238 LDFLAGS="-Wl,$flag $LDFLAGS"
2239 fi
2240 done
2241fi
2242
2243confdir=$sysconfdir$confsuffix
2244
2245tools=
2246if test "$softmmu" = yes ; then
2247 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2248 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2249 tools="qemu-nbd\$(EXESUF) $tools"
2250 if [ "$check_utests" = "yes" ]; then
2251 tools="check-qint check-qstring check-qdict check-qlist $tools"
2252 tools="check-qfloat check-qjson $tools"
2253 fi
2254 fi
2255fi
2256
2257# Mac OS X ships with a broken assembler
2258roms=
2259if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2260 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2261 "$softmmu" = yes ; then
2262 roms="optionrom"
2263fi
2264
2265
2266echo "Install prefix $prefix"
2267echo "BIOS directory `eval echo $datadir`"
2268echo "binary directory `eval echo $bindir`"
2269echo "config directory `eval echo $sysconfdir`"
2270if test "$mingw32" = "no" ; then
2271echo "Manual directory `eval echo $mandir`"
2272echo "ELF interp prefix $interp_prefix"
2273fi
2274echo "Source path $source_path"
2275echo "C compiler $cc"
2276echo "Host C compiler $host_cc"
2277echo "CFLAGS $CFLAGS"
2278echo "QEMU_CFLAGS $QEMU_CFLAGS"
2279echo "LDFLAGS $LDFLAGS"
2280echo "make $make"
2281echo "install $install"
2282echo "host CPU $cpu"
2283echo "host big endian $bigendian"
2284echo "target list $target_list"
2285echo "tcg debug enabled $debug_tcg"
2286echo "Mon debug enabled $debug_mon"
2287echo "gprof enabled $gprof"
2288echo "sparse enabled $sparse"
2289echo "strip binaries $strip_opt"
2290echo "profiler $profiler"
2291echo "static build $static"
2292echo "-Werror enabled $werror"
2293if test "$darwin" = "yes" ; then
2294 echo "Cocoa support $cocoa"
2295fi
2296echo "SDL support $sdl"
2297echo "curses support $curses"
2298echo "curl support $curl"
2299echo "check support $check_utests"
2300echo "mingw32 support $mingw32"
2301echo "Audio drivers $audio_drv_list"
2302echo "Extra audio cards $audio_card_list"
2303echo "Block whitelist $block_drv_whitelist"
2304echo "Mixer emulation $mixemu"
2305echo "VNC TLS support $vnc_tls"
2306echo "VNC SASL support $vnc_sasl"
2307echo "VNC JPEG support $vnc_jpeg"
2308echo "VNC PNG support $vnc_png"
2309echo "VNC thread $vnc_thread"
2310if test -n "$sparc_cpu"; then
2311 echo "Target Sparc Arch $sparc_cpu"
2312fi
2313echo "xen support $xen"
2314echo "brlapi support $brlapi"
2315echo "bluez support $bluez"
2316echo "Documentation $docs"
2317[ ! -z "$uname_release" ] && \
2318echo "uname -r $uname_release"
2319echo "NPTL support $nptl"
2320echo "GUEST_BASE $guest_base"
2321echo "PIE user targets $user_pie"
2322echo "vde support $vde"
2323echo "IO thread $io_thread"
2324echo "Linux AIO support $linux_aio"
2325echo "ATTR/XATTR support $attr"
2326echo "Install blobs $blobs"
2327echo "KVM support $kvm"
2328echo "fdt support $fdt"
2329echo "preadv support $preadv"
2330echo "fdatasync $fdatasync"
2331echo "madvise $madvise"
2332echo "posix_madvise $posix_madvise"
2333echo "uuid support $uuid"
2334echo "vhost-net support $vhost_net"
2335echo "Trace backend $trace_backend"
2336echo "Trace output file $trace_file-<pid>"
2337echo "spice support $spice"
2338
2339if test $sdl_too_old = "yes"; then
2340echo "-> Your SDL version is too old - please upgrade to have SDL support"
2341fi
2342
2343config_host_mak="config-host.mak"
2344config_host_ld="config-host.ld"
2345
2346echo "# Automatically generated by configure - do not modify" > $config_host_mak
2347printf "# Configured with:" >> $config_host_mak
2348printf " '%s'" "$0" "$@" >> $config_host_mak
2349echo >> $config_host_mak
2350
2351echo all: >> $config_host_mak
2352echo "prefix=$prefix" >> $config_host_mak
2353echo "bindir=$bindir" >> $config_host_mak
2354echo "mandir=$mandir" >> $config_host_mak
2355echo "datadir=$datadir" >> $config_host_mak
2356echo "sysconfdir=$sysconfdir" >> $config_host_mak
2357echo "docdir=$docdir" >> $config_host_mak
2358echo "confdir=$confdir" >> $config_host_mak
2359
2360case "$cpu" in
2361 i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2362 ARCH=$cpu
2363 ;;
2364 armv4b|armv4l)
2365 ARCH=arm
2366 ;;
2367esac
2368echo "ARCH=$ARCH" >> $config_host_mak
2369if test "$debug_tcg" = "yes" ; then
2370 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2371fi
2372if test "$debug_mon" = "yes" ; then
2373 echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2374fi
2375if test "$debug" = "yes" ; then
2376 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2377fi
2378if test "$strip_opt" = "yes" ; then
2379 echo "STRIP=${strip}" >> $config_host_mak
2380fi
2381if test "$bigendian" = "yes" ; then
2382 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
2383fi
2384echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
2385if test "$mingw32" = "yes" ; then
2386 echo "CONFIG_WIN32=y" >> $config_host_mak
2387 rc_version=`cat $source_path/VERSION`
2388 version_major=${rc_version%%.*}
2389 rc_version=${rc_version#*.}
2390 version_minor=${rc_version%%.*}
2391 rc_version=${rc_version#*.}
2392 version_subminor=${rc_version%%.*}
2393 version_micro=0
2394 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2395 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2396else
2397 echo "CONFIG_POSIX=y" >> $config_host_mak
2398fi
2399
2400if test "$linux" = "yes" ; then
2401 echo "CONFIG_LINUX=y" >> $config_host_mak
2402fi
2403
2404if test "$darwin" = "yes" ; then
2405 echo "CONFIG_DARWIN=y" >> $config_host_mak
2406fi
2407
2408if test "$aix" = "yes" ; then
2409 echo "CONFIG_AIX=y" >> $config_host_mak
2410fi
2411
2412if test "$solaris" = "yes" ; then
2413 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2414 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
2415 if test "$needs_libsunmath" = "yes" ; then
2416 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
2417 fi
2418fi
2419if test "$haiku" = "yes" ; then
2420 echo "CONFIG_HAIKU=y" >> $config_host_mak
2421fi
2422if test "$static" = "yes" ; then
2423 echo "CONFIG_STATIC=y" >> $config_host_mak
2424fi
2425if test $profiler = "yes" ; then
2426 echo "CONFIG_PROFILER=y" >> $config_host_mak
2427fi
2428if test "$slirp" = "yes" ; then
2429 echo "CONFIG_SLIRP=y" >> $config_host_mak
2430 QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
2431fi
2432if test "$vde" = "yes" ; then
2433 echo "CONFIG_VDE=y" >> $config_host_mak
2434fi
2435for card in $audio_card_list; do
2436 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
2437 echo "$def=y" >> $config_host_mak
2438done
2439echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
2440for drv in $audio_drv_list; do
2441 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
2442 echo "$def=y" >> $config_host_mak
2443 if test "$drv" = "fmod"; then
2444 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2445 fi
2446done
2447if test "$audio_pt_int" = "yes" ; then
2448 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
2449fi
2450if test "$audio_win_int" = "yes" ; then
2451 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2452fi
2453echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
2454if test "$mixemu" = "yes" ; then
2455 echo "CONFIG_MIXEMU=y" >> $config_host_mak
2456fi
2457if test "$vnc_tls" = "yes" ; then
2458 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2459 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
2460fi
2461if test "$vnc_sasl" = "yes" ; then
2462 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2463 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
2464fi
2465if test "$vnc_jpeg" != "no" ; then
2466 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2467 echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
2468fi
2469if test "$vnc_png" != "no" ; then
2470 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2471 echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2472fi
2473if test "$vnc_thread" != "no" ; then
2474 echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2475 echo "CONFIG_THREAD=y" >> $config_host_mak
2476fi
2477if test "$fnmatch" = "yes" ; then
2478 echo "CONFIG_FNMATCH=y" >> $config_host_mak
2479fi
2480if test "$uuid" = "yes" ; then
2481 echo "CONFIG_UUID=y" >> $config_host_mak
2482fi
2483qemu_version=`head $source_path/VERSION`
2484echo "VERSION=$qemu_version" >>$config_host_mak
2485echo "PKGVERSION=$pkgversion" >>$config_host_mak
2486echo "SRC_PATH=$source_path" >> $config_host_mak
2487echo "TARGET_DIRS=$target_list" >> $config_host_mak
2488if [ "$docs" = "yes" ] ; then
2489 echo "BUILD_DOCS=yes" >> $config_host_mak
2490fi
2491if test "$sdl" = "yes" ; then
2492 echo "CONFIG_SDL=y" >> $config_host_mak
2493 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
2494fi
2495if test "$cocoa" = "yes" ; then
2496 echo "CONFIG_COCOA=y" >> $config_host_mak
2497fi
2498if test "$curses" = "yes" ; then
2499 echo "CONFIG_CURSES=y" >> $config_host_mak
2500fi
2501if test "$atfile" = "yes" ; then
2502 echo "CONFIG_ATFILE=y" >> $config_host_mak
2503fi
2504if test "$utimens" = "yes" ; then
2505 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2506fi
2507if test "$pipe2" = "yes" ; then
2508 echo "CONFIG_PIPE2=y" >> $config_host_mak
2509fi
2510if test "$accept4" = "yes" ; then
2511 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
2512fi
2513if test "$splice" = "yes" ; then
2514 echo "CONFIG_SPLICE=y" >> $config_host_mak
2515fi
2516if test "$eventfd" = "yes" ; then
2517 echo "CONFIG_EVENTFD=y" >> $config_host_mak
2518fi
2519if test "$fallocate" = "yes" ; then
2520 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2521fi
2522if test "$dup3" = "yes" ; then
2523 echo "CONFIG_DUP3=y" >> $config_host_mak
2524fi
2525if test "$inotify" = "yes" ; then
2526 echo "CONFIG_INOTIFY=y" >> $config_host_mak
2527fi
2528if test "$inotify1" = "yes" ; then
2529 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2530fi
2531if test "$byteswap_h" = "yes" ; then
2532 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
2533fi
2534if test "$bswap_h" = "yes" ; then
2535 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
2536fi
2537if test "$curl" = "yes" ; then
2538 echo "CONFIG_CURL=y" >> $config_host_mak
2539 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2540fi
2541if test "$brlapi" = "yes" ; then
2542 echo "CONFIG_BRLAPI=y" >> $config_host_mak
2543fi
2544if test "$bluez" = "yes" ; then
2545 echo "CONFIG_BLUEZ=y" >> $config_host_mak
2546 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2547fi
2548if test "$xen" = "yes" ; then
2549 echo "CONFIG_XEN=y" >> $config_host_mak
2550fi
2551if test "$io_thread" = "yes" ; then
2552 echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2553 echo "CONFIG_THREAD=y" >> $config_host_mak
2554fi
2555if test "$linux_aio" = "yes" ; then
2556 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
2557fi
2558if test "$attr" = "yes" ; then
2559 echo "CONFIG_ATTR=y" >> $config_host_mak
2560fi
2561if test "$linux" = "yes" ; then
2562 if test "$attr" = "yes" ; then
2563 echo "CONFIG_VIRTFS=y" >> $config_host_mak
2564 fi
2565fi
2566if test "$blobs" = "yes" ; then
2567 echo "INSTALL_BLOBS=yes" >> $config_host_mak
2568fi
2569if test "$iovec" = "yes" ; then
2570 echo "CONFIG_IOVEC=y" >> $config_host_mak
2571fi
2572if test "$preadv" = "yes" ; then
2573 echo "CONFIG_PREADV=y" >> $config_host_mak
2574fi
2575if test "$fdt" = "yes" ; then
2576 echo "CONFIG_FDT=y" >> $config_host_mak
2577fi
2578if test "$signalfd" = "yes" ; then
2579 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2580fi
2581if test "$need_offsetof" = "yes" ; then
2582 echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2583fi
2584if test "$gcc_attribute_warn_unused_result" = "yes" ; then
2585 echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2586fi
2587if test "$fdatasync" = "yes" ; then
2588 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
2589fi
2590if test "$madvise" = "yes" ; then
2591 echo "CONFIG_MADVISE=y" >> $config_host_mak
2592fi
2593if test "$posix_madvise" = "yes" ; then
2594 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2595fi
2596
2597if test "$spice" = "yes" ; then
2598 echo "CONFIG_SPICE=y" >> $config_host_mak
2599fi
2600
2601# XXX: suppress that
2602if [ "$bsd" = "yes" ] ; then
2603 echo "CONFIG_BSD=y" >> $config_host_mak
2604fi
2605
2606echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2607
2608if test "$zero_malloc" = "yes" ; then
2609 echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
2610fi
2611
2612# USB host support
2613case "$usb" in
2614linux)
2615 echo "HOST_USB=linux" >> $config_host_mak
2616;;
2617bsd)
2618 echo "HOST_USB=bsd" >> $config_host_mak
2619;;
2620*)
2621 echo "HOST_USB=stub" >> $config_host_mak
2622;;
2623esac
2624
2625echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
2626if test "$trace_backend" = "simple"; then
2627 echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
2628fi
2629# Set the appropriate trace file.
2630if test "$trace_backend" = "simple"; then
2631 trace_file="\"$trace_file-%u\""
2632fi
2633echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
2634
2635echo "TOOLS=$tools" >> $config_host_mak
2636echo "ROMS=$roms" >> $config_host_mak
2637echo "MAKE=$make" >> $config_host_mak
2638echo "INSTALL=$install" >> $config_host_mak
2639echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2640echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2641echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2642echo "CC=$cc" >> $config_host_mak
2643echo "HOST_CC=$host_cc" >> $config_host_mak
2644if test "$sparse" = "yes" ; then
2645 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
2646 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
2647 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2648fi
2649echo "AR=$ar" >> $config_host_mak
2650echo "OBJCOPY=$objcopy" >> $config_host_mak
2651echo "LD=$ld" >> $config_host_mak
2652echo "WINDRES=$windres" >> $config_host_mak
2653echo "CFLAGS=$CFLAGS" >> $config_host_mak
2654echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2655echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2656echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
2657echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2658echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
2659echo "LIBS+=$LIBS" >> $config_host_mak
2660echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2661echo "EXESUF=$EXESUF" >> $config_host_mak
2662
2663# generate list of library paths for linker script
2664
2665$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
2666
2667if test -f ${config_host_ld}~ ; then
2668 if cmp -s $config_host_ld ${config_host_ld}~ ; then
2669 mv ${config_host_ld}~ $config_host_ld
2670 else
2671 rm ${config_host_ld}~
2672 fi
2673fi
2674
2675for d in libdis libdis-user; do
2676 mkdir -p $d
2677 rm -f $d/Makefile
2678 ln -s $source_path/Makefile.dis $d/Makefile
2679 echo > $d/config.mak
2680done
2681if test "$static" = "no" -a "$user_pie" = "yes" ; then
2682 echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2683fi
2684
2685for target in $target_list; do
2686target_dir="$target"
2687config_target_mak=$target_dir/config-target.mak
2688target_arch2=`echo $target | cut -d '-' -f 1`
2689target_bigendian="no"
2690
2691case "$target_arch2" in
2692 armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2693 target_bigendian=yes
2694 ;;
2695esac
2696target_softmmu="no"
2697target_user_only="no"
2698target_linux_user="no"
2699target_darwin_user="no"
2700target_bsd_user="no"
2701case "$target" in
2702 ${target_arch2}-softmmu)
2703 target_softmmu="yes"
2704 ;;
2705 ${target_arch2}-linux-user)
2706 if test "$linux" != "yes" ; then
2707 echo "ERROR: Target '$target' is only available on a Linux host"
2708 exit 1
2709 fi
2710 target_user_only="yes"
2711 target_linux_user="yes"
2712 ;;
2713 ${target_arch2}-darwin-user)
2714 if test "$darwin" != "yes" ; then
2715 echo "ERROR: Target '$target' is only available on a Darwin host"
2716 exit 1
2717 fi
2718 target_user_only="yes"
2719 target_darwin_user="yes"
2720 ;;
2721 ${target_arch2}-bsd-user)
2722 if test "$bsd" != "yes" ; then
2723 echo "ERROR: Target '$target' is only available on a BSD host"
2724 exit 1
2725 fi
2726 target_user_only="yes"
2727 target_bsd_user="yes"
2728 ;;
2729 *)
2730 echo "ERROR: Target '$target' not recognised"
2731 exit 1
2732 ;;
2733esac
2734
2735mkdir -p $target_dir
2736mkdir -p $target_dir/fpu
2737mkdir -p $target_dir/tcg
2738mkdir -p $target_dir/ide
2739if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
2740 mkdir -p $target_dir/nwfpe
2741fi
2742
2743#
2744# don't use ln -sf as not all "ln -sf" over write the file/link
2745#
2746rm -f $target_dir/Makefile
2747ln -s $source_path/Makefile.target $target_dir/Makefile
2748
2749
2750echo "# Automatically generated by configure - do not modify" > $config_target_mak
2751
2752bflt="no"
2753target_nptl="no"
2754interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
2755echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
2756gdb_xml_files=""
2757
2758TARGET_ARCH="$target_arch2"
2759TARGET_BASE_ARCH=""
2760TARGET_ABI_DIR=""
2761
2762case "$target_arch2" in
2763 i386)
2764 target_phys_bits=32
2765 ;;
2766 x86_64)
2767 TARGET_BASE_ARCH=i386
2768 target_phys_bits=64
2769 ;;
2770 alpha)
2771 target_phys_bits=64
2772 target_nptl="yes"
2773 ;;
2774 arm|armeb)
2775 TARGET_ARCH=arm
2776 bflt="yes"
2777 target_nptl="yes"
2778 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2779 target_phys_bits=32
2780 ;;
2781 cris)
2782 target_nptl="yes"
2783 target_phys_bits=32
2784 ;;
2785 m68k)
2786 bflt="yes"
2787 gdb_xml_files="cf-core.xml cf-fp.xml"
2788 target_phys_bits=32
2789 ;;
2790 microblaze)
2791 bflt="yes"
2792 target_nptl="yes"
2793 target_phys_bits=32
2794 ;;
2795 mips|mipsel)
2796 TARGET_ARCH=mips
2797 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2798 target_nptl="yes"
2799 target_phys_bits=64
2800 ;;
2801 mipsn32|mipsn32el)
2802 TARGET_ARCH=mipsn32
2803 TARGET_BASE_ARCH=mips
2804 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
2805 target_phys_bits=64
2806 ;;
2807 mips64|mips64el)
2808 TARGET_ARCH=mips64
2809 TARGET_BASE_ARCH=mips
2810 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2811 target_phys_bits=64
2812 ;;
2813 ppc)
2814 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2815 target_phys_bits=32
2816 target_nptl="yes"
2817 ;;
2818 ppcemb)
2819 TARGET_BASE_ARCH=ppc
2820 TARGET_ABI_DIR=ppc
2821 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2822 target_phys_bits=64
2823 target_nptl="yes"
2824 ;;
2825 ppc64)
2826 TARGET_BASE_ARCH=ppc
2827 TARGET_ABI_DIR=ppc
2828 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2829 target_phys_bits=64
2830 ;;
2831 ppc64abi32)
2832 TARGET_ARCH=ppc64
2833 TARGET_BASE_ARCH=ppc
2834 TARGET_ABI_DIR=ppc
2835 echo "TARGET_ABI32=y" >> $config_target_mak
2836 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2837 target_phys_bits=64
2838 ;;
2839 sh4|sh4eb)
2840 TARGET_ARCH=sh4
2841 bflt="yes"
2842 target_nptl="yes"
2843 target_phys_bits=32
2844 ;;
2845 sparc)
2846 target_phys_bits=64
2847 ;;
2848 sparc64)
2849 TARGET_BASE_ARCH=sparc
2850 target_phys_bits=64
2851 ;;
2852 sparc32plus)
2853 TARGET_ARCH=sparc64
2854 TARGET_BASE_ARCH=sparc
2855 TARGET_ABI_DIR=sparc
2856 echo "TARGET_ABI32=y" >> $config_target_mak
2857 target_phys_bits=64
2858 ;;
2859 s390x)
2860 target_phys_bits=64
2861 ;;
2862 *)
2863 echo "Unsupported target CPU"
2864 exit 1
2865 ;;
2866esac
2867echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2868target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
2869echo "TARGET_$target_arch_name=y" >> $config_target_mak
2870echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
2871# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
2872if [ "$TARGET_BASE_ARCH" = "" ]; then
2873 TARGET_BASE_ARCH=$TARGET_ARCH
2874fi
2875echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2876if [ "$TARGET_ABI_DIR" = "" ]; then
2877 TARGET_ABI_DIR=$TARGET_ARCH
2878fi
2879echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
2880case "$target_arch2" in
2881 i386|x86_64)
2882 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2883 echo "CONFIG_XEN=y" >> $config_target_mak
2884 fi
2885esac
2886case "$target_arch2" in
2887 i386|x86_64|ppcemb|ppc|ppc64|s390x)
2888 # Make sure the target and host cpus are compatible
2889 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2890 \( "$target_arch2" = "$cpu" -o \
2891 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2892 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
2893 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
2894 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
2895 echo "CONFIG_KVM=y" >> $config_target_mak
2896 echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2897 if test "$kvm_para" = "yes"; then
2898 echo "CONFIG_KVM_PARA=y" >> $config_target_mak
2899 fi
2900 if test $vhost_net = "yes" ; then
2901 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
2902 fi
2903 fi
2904esac
2905if test "$target_bigendian" = "yes" ; then
2906 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
2907fi
2908if test "$target_softmmu" = "yes" ; then
2909 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
2910 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
2911 echo "LIBS+=$libs_softmmu" >> $config_target_mak
2912 echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
2913 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2914fi
2915if test "$target_user_only" = "yes" ; then
2916 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2917fi
2918if test "$target_linux_user" = "yes" ; then
2919 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2920fi
2921if test "$target_darwin_user" = "yes" ; then
2922 echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2923fi
2924list=""
2925if test ! -z "$gdb_xml_files" ; then
2926 for x in $gdb_xml_files; do
2927 list="$list $source_path/gdb-xml/$x"
2928 done
2929 echo "TARGET_XML_FILES=$list" >> $config_target_mak
2930fi
2931
2932case "$target_arch2" in
2933 alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
2934 echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2935 ;;
2936 *)
2937 echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2938 ;;
2939esac
2940
2941if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2942 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2943fi
2944if test "$target_user_only" = "yes" \
2945 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2946 echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2947fi
2948if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2949 echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2950fi
2951if test "$target_bsd_user" = "yes" ; then
2952 echo "CONFIG_BSD_USER=y" >> $config_target_mak
2953fi
2954
2955# generate QEMU_CFLAGS/LDFLAGS for targets
2956
2957cflags=""
2958ldflags=""
2959
2960if test "$ARCH" = "sparc64" ; then
2961 cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
2962elif test "$ARCH" = "s390x" ; then
2963 cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
2964elif test "$ARCH" = "x86_64" ; then
2965 cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
2966else
2967 cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
2968fi
2969cflags="-I\$(SRC_PATH)/tcg $cflags"
2970cflags="-I\$(SRC_PATH)/fpu $cflags"
2971
2972if test "$target_user_only" = "yes" ; then
2973 libdis_config_mak=libdis-user/config.mak
2974else
2975 libdis_config_mak=libdis/config.mak
2976fi
2977
2978for i in $ARCH $TARGET_BASE_ARCH ; do
2979 case "$i" in
2980 alpha)
2981 echo "CONFIG_ALPHA_DIS=y" >> $config_target_mak
2982 echo "CONFIG_ALPHA_DIS=y" >> $libdis_config_mak
2983 ;;
2984 arm)
2985 echo "CONFIG_ARM_DIS=y" >> $config_target_mak
2986 echo "CONFIG_ARM_DIS=y" >> $libdis_config_mak
2987 ;;
2988 cris)
2989 echo "CONFIG_CRIS_DIS=y" >> $config_target_mak
2990 echo "CONFIG_CRIS_DIS=y" >> $libdis_config_mak
2991 ;;
2992 hppa)
2993 echo "CONFIG_HPPA_DIS=y" >> $config_target_mak
2994 echo "CONFIG_HPPA_DIS=y" >> $libdis_config_mak
2995 ;;
2996 i386|x86_64)
2997 echo "CONFIG_I386_DIS=y" >> $config_target_mak
2998 echo "CONFIG_I386_DIS=y" >> $libdis_config_mak
2999 ;;
3000 ia64*)
3001 echo "CONFIG_IA64_DIS=y" >> $config_target_mak
3002 echo "CONFIG_IA64_DIS=y" >> $libdis_config_mak
3003 ;;
3004 m68k)
3005 echo "CONFIG_M68K_DIS=y" >> $config_target_mak
3006 echo "CONFIG_M68K_DIS=y" >> $libdis_config_mak
3007 ;;
3008 microblaze)
3009 echo "CONFIG_MICROBLAZE_DIS=y" >> $config_target_mak
3010 echo "CONFIG_MICROBLAZE_DIS=y" >> $libdis_config_mak
3011 ;;
3012 mips*)
3013 echo "CONFIG_MIPS_DIS=y" >> $config_target_mak
3014 echo "CONFIG_MIPS_DIS=y" >> $libdis_config_mak
3015 ;;
3016 ppc*)
3017 echo "CONFIG_PPC_DIS=y" >> $config_target_mak
3018 echo "CONFIG_PPC_DIS=y" >> $libdis_config_mak
3019 ;;
3020 s390*)
3021 echo "CONFIG_S390_DIS=y" >> $config_target_mak
3022 echo "CONFIG_S390_DIS=y" >> $libdis_config_mak
3023 ;;
3024 sh4)
3025 echo "CONFIG_SH4_DIS=y" >> $config_target_mak
3026 echo "CONFIG_SH4_DIS=y" >> $libdis_config_mak
3027 ;;
3028 sparc*)
3029 echo "CONFIG_SPARC_DIS=y" >> $config_target_mak
3030 echo "CONFIG_SPARC_DIS=y" >> $libdis_config_mak
3031 ;;
3032 esac
3033done
3034
3035case "$ARCH" in
3036alpha)
3037 # Ensure there's only a single GP
3038 cflags="-msmall-data $cflags"
3039;;
3040esac
3041
3042if test "$target_softmmu" = "yes" ; then
3043 case "$TARGET_BASE_ARCH" in
3044 arm)
3045 cflags="-DHAS_AUDIO $cflags"
3046 ;;
3047 i386|mips|ppc)
3048 cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
3049 ;;
3050 esac
3051fi
3052
3053if test "$target_user_only" = "yes" -a "$static" = "no" -a \
3054 "$user_pie" = "yes" ; then
3055 cflags="-fpie $cflags"
3056 ldflags="-pie $ldflags"
3057fi
3058
3059if test "$target_softmmu" = "yes" -a \( \
3060 "$TARGET_ARCH" = "microblaze" -o \
3061 "$TARGET_ARCH" = "cris" \) ; then
3062 echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3063fi
3064
3065if test "$gprof" = "yes" ; then
3066 echo "TARGET_GPROF=yes" >> $config_target_mak
3067 if test "$target_linux_user" = "yes" ; then
3068 cflags="-p $cflags"
3069 ldflags="-p $ldflags"
3070 fi
3071 if test "$target_softmmu" = "yes" ; then
3072 ldflags="-p $ldflags"
3073 echo "GPROF_CFLAGS=-p" >> $config_target_mak
3074 fi
3075fi
3076
3077linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
3078if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3079 case "$ARCH" in
3080 sparc)
3081 # -static is used to avoid g1/g3 usage by the dynamic linker
3082 ldflags="$linker_script -static $ldflags"
3083 ;;
3084 alpha | s390x)
3085 # The default placement of the application is fine.
3086 ;;
3087 *)
3088 ldflags="$linker_script $ldflags"
3089 ;;
3090 esac
3091fi
3092
3093echo "LDFLAGS+=$ldflags" >> $config_target_mak
3094echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3095
3096done # for target in $targets
3097
3098# build tree in object directory if source path is different from current one
3099if test "$source_path_used" = "yes" ; then
3100 DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3101 DIRS="$DIRS roms/seabios roms/vgabios"
3102 DIRS="$DIRS fsdev ui"
3103 FILES="Makefile tests/Makefile"
3104 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3105 FILES="$FILES tests/test-mmap.c"
3106 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3107 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
3108 for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
3109 FILES="$FILES pc-bios/`basename $bios_file`"
3110 done
3111 for dir in $DIRS ; do
3112 mkdir -p $dir
3113 done
3114 # remove the link and recreate it, as not all "ln -sf" overwrite the link
3115 for f in $FILES ; do
3116 rm -f $f
3117 ln -s $source_path/$f $f
3118 done
3119fi
3120
3121# temporary config to build submodules
3122for rom in seabios vgabios ; do
3123 config_mak=roms/$rom/config.mak
3124 echo "# Automatically generated by configure - do not modify" > $config_mak
3125 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3126 echo "CC=$cc" >> $config_mak
3127 echo "BCC=bcc" >> $config_mak
3128 echo "CPP=${cross_prefix}cpp" >> $config_mak
3129 echo "OBJCOPY=objcopy" >> $config_mak
3130 echo "IASL=iasl" >> $config_mak
3131 echo "HOST_CC=$host_cc" >> $config_mak
3132 echo "LD=$ld" >> $config_mak
3133done
3134
3135for hwlib in 32 64; do
3136 d=libhw$hwlib
3137 mkdir -p $d
3138 mkdir -p $d/ide
3139 rm -f $d/Makefile
3140 ln -s $source_path/Makefile.hw $d/Makefile
3141 echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
3142done
3143
3144d=libuser
3145mkdir -p $d
3146rm -f $d/Makefile
3147ln -s $source_path/Makefile.user $d/Makefile
3148if test "$static" = "no" -a "$user_pie" = "yes" ; then
3149 echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3150fi
3151
3152if test "$docs" = "yes" ; then
3153 mkdir -p QMP
3154fi