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