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