configure 125 KB
Newer Older
bellard's avatar
bellard committed
1 2
#!/bin/sh
#
bellard's avatar
bellard committed
3
# qemu configure script (c) 2003 Fabrice Bellard
bellard's avatar
bellard committed
4 5 6 7 8 9 10 11 12 13
#
# set temporary file name
if test ! -z "$TMPDIR" ; then
    TMPDIR1="${TMPDIR}"
elif test ! -z "$TEMPDIR" ; then
    TMPDIR1="${TEMPDIR}"
else
    TMPDIR1="/tmp"
fi

bellard's avatar
bellard committed
14 15
TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16
TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
bellard's avatar
bellard committed
17

18 19 20
# NB: do not call "exit" in the trap handler; this is buggy with some shells;
# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
Gerd Hoffmann's avatar
Gerd Hoffmann committed
21
rm -f config.log
22

23 24
# Print a helpful header at the top of config.log
echo "# QEMU configure log $(date)" >> config.log
25 26 27
printf "# Configured with:" >> config.log
printf " '%s'" "$0" "$@" >> config.log
echo >> config.log
28 29
echo "#" >> config.log

30 31 32 33 34 35 36 37 38 39 40 41 42
# Save the configure command line for later reuse.
cat <<EOD >config.status
#!/bin/sh
# Generated by configure.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
EOD
printf "exec" >>config.status
printf " '%s'" "$0" "$@" >>config.status
echo >>config.status
chmod +x config.status

43 44 45 46 47 48 49 50 51 52 53
error_exit() {
    echo
    echo "ERROR: $1"
    while test -n "$2"; do
        echo "       $2"
        shift
    done
    echo
    exit 1
}

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
do_cc() {
    # Run the compiler, capturing its output to the log.
    echo $cc "$@" >> config.log
    $cc "$@" >> config.log 2>&1 || return $?
    # Test passed. If this is an --enable-werror build, rerun
    # the test with -Werror and bail out if it fails. This
    # makes warning-generating-errors in configure test code
    # obvious to developers.
    if test "$werror" != "yes"; then
        return 0
    fi
    # Don't bother rerunning the compile if we were already using -Werror
    case "$*" in
        *-Werror*)
           return 0
        ;;
    esac
    echo $cc -Werror "$@" >> config.log
    $cc -Werror "$@" >> config.log 2>&1 && return $?
73 74 75 76
    error_exit "configure test passed without -Werror but failed with -Werror." \
        "This is probably a bug in the configure script. The failing command" \
        "will be at the bottom of config.log." \
        "You can run configure with --disable-werror to bypass this check."
77 78
}

79
compile_object() {
80
  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
81 82 83 84 85
}

compile_prog() {
  local_cflags="$1"
  local_ldflags="$2"
86
  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
87 88
}

89 90
# symbolically link $1 to $2.  Portable version of "ln -sf".
symlink() {
91
  rm -rf "$2"
92
  mkdir -p "$(dirname "$2")"
93
  ln -s "$1" "$2"
94 95
}

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
# check whether a command is available to this shell (may be either an
# executable or a builtin)
has() {
    type "$1" >/dev/null 2>&1
}

# search for an executable in PATH
path_of() {
    local_command="$1"
    local_ifs="$IFS"
    local_dir=""

    # pathname has a dir component?
    if [ "${local_command#*/}" != "$local_command" ]; then
        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
            echo "$local_command"
            return 0
        fi
    fi
    if [ -z "$local_command" ]; then
        return 1
    fi

    IFS=:
    for local_dir in $PATH; do
        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
            echo "$local_dir/$local_command"
            IFS="${local_ifs:-$(printf ' \t\n')}"
            return 0
        fi
    done
    # not found
    IFS="${local_ifs:-$(printf ' \t\n')}"
    return 1
}

bellard's avatar
bellard committed
132
# default parameters
133
source_path=`dirname "$0"`
134
cpu=""
135
iasl="iasl"
136
interp_prefix="/usr/gnemul/qemu-%M"
bellard's avatar
bellard committed
137
static="no"
bellard's avatar
bellard committed
138
cross_prefix=""
malc's avatar
malc committed
139
audio_drv_list=""
140 141
block_drv_rw_whitelist=""
block_drv_ro_whitelist=""
142
host_cc="cc"
Juan Quintela's avatar
Juan Quintela committed
143
libs_softmmu=""
Juan Quintela's avatar
Juan Quintela committed
144
libs_tools=""
145
audio_pt_int=""
146
audio_win_int=""
Paolo Bonzini's avatar
Paolo Bonzini committed
147
cc_i386=i386-pc-linux-gnu-gcc
148
libs_qga=""
149
debug_info="yes"
150

151 152
# Don't accept a target_list environment variable.
unset target_list
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171

# Default value for a variable defining feature "foo".
#  * foo="no"  feature will only be used if --enable-foo arg is given
#  * foo=""    feature will be searched for, and if found, will be used
#              unless --disable-foo is given
#  * foo="yes" this value will only be set by --enable-foo flag.
#              feature will searched for,
#              if not found, configure exits with error
#
# Always add --enable-foo and --disable-foo command line args.
# Distributions want to ensure that several features are compiled in, and it
# is impossible without a --enable-foo that exits if a feature is not found.

bluez=""
brlapi=""
curl=""
curses=""
docs=""
fdt=""
172
netmap="no"
173
pixman=""
174
sdl=""
175
virtfs=""
Jes Sorensen's avatar
Jes Sorensen committed
176
vnc="yes"
177 178 179 180 181 182 183
sparse="no"
uuid=""
vde=""
vnc_tls=""
vnc_sasl=""
vnc_jpeg=""
vnc_png=""
184
vnc_ws=""
185
xen=""
186
xen_ctrl_version=""
187
xen_pci_passthrough=""
188
linux_aio=""
189
cap_ng=""
190
attr=""
191
libattr=""
192 193
xfs=""

194
vhost_net="no"
195
vhost_scsi="no"
196
kvm="no"
Michael R. Hines's avatar
Michael R. Hines committed
197
rdma=""
198 199 200 201
gprof="no"
debug_tcg="no"
debug="no"
strip_opt="yes"
202
tcg_interpreter="no"
203 204
bigendian="no"
mingw32="no"
Blue Swirl's avatar
Blue Swirl committed
205 206
gcov="no"
gcov_tool="gcov"
207 208 209
EXESUF=""
prefix="/usr/local"
mandir="\${prefix}/share/man"
210
datadir="\${prefix}/share"
211
qemu_docdir="\${prefix}/share/doc/qemu"
212
bindir="\${prefix}/bin"
213
libdir="\${prefix}/lib"
214
libexecdir="\${prefix}/libexec"
215
includedir="\${prefix}/include"
216
sysconfdir="\${prefix}/etc"
217
local_statedir="\${prefix}/var"
218 219 220 221 222 223 224 225 226 227 228 229 230
confsuffix="/qemu"
slirp="yes"
fmod_lib=""
fmod_inc=""
oss_lib=""
bsd="no"
linux="no"
solaris="no"
profiler="no"
cocoa="no"
softmmu="yes"
linux_user="no"
bsd_user="no"
231
guest_base="yes"
232 233 234 235
uname_release=""
aix="no"
blobs="yes"
pkgversion=""
236
pie=""
237
zero_malloc=""
238
qom_cast_debug="yes"
239 240 241 242
trace_backend="nop"
trace_file="trace"
spice=""
rbd=""
Robert Relyea's avatar
Robert Relyea committed
243
smartcard_nss=""
Gerd Hoffmann's avatar
Gerd Hoffmann committed
244
libusb=""
245
usb_redir=""
246
glx=""
247
zlib="yes"
248
guest_agent=""
249 250 251
guest_agent_with_vss="no"
vss_win32_sdk=""
win_sdk="no"
252
want_tools="yes"
Ronnie Sahlberg's avatar
Ronnie Sahlberg committed
253
libiscsi=""
254
coroutine=""
255
coroutine_pool=""
256
seccomp=""
257
glusterfs=""
258
glusterfs_discard="no"
259
glusterfs_zerofill="no"
260
virtio_blk_data_plane=""
Anthony Liguori's avatar
Anthony Liguori committed
261
gtk=""
262
gtkabi="2.0"
Stefan Berger's avatar
Stefan Berger committed
263
tpm="no"
264
libssh2=""
265
vhdx=""
266

267 268 269 270 271 272
# parse CC options first
for opt do
  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
  case "$opt" in
  --cross-prefix=*) cross_prefix="$optarg"
  ;;
273
  --cc=*) CC="$optarg"
274
  ;;
275 276
  --cxx=*) CXX="$optarg"
  ;;
277 278
  --source-path=*) source_path="$optarg"
  ;;
279 280
  --cpu=*) cpu="$optarg"
  ;;
281
  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
282
                    EXTRA_CFLAGS="$optarg"
283 284
  ;;
  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
285
                     EXTRA_LDFLAGS="$optarg"
286
  ;;
287 288 289 290
  --enable-debug-info) debug_info="yes"
  ;;
  --disable-debug-info) debug_info="no"
  ;;
291 292 293 294
  esac
done
# OS specific
# Using uname is really, really broken.  Once we have the right set of checks
295
# we can eliminate its usage altogether.
296

297 298 299 300 301 302 303 304 305 306
# Preferred compiler:
#  ${CC} (if set)
#  ${cross_prefix}gcc (if cross-prefix specified)
#  system compiler
if test -z "${CC}${cross_prefix}"; then
  cc="$host_cc"
else
  cc="${CC-${cross_prefix}gcc}"
fi

307 308 309 310 311 312
if test -z "${CXX}${cross_prefix}"; then
  cxx="c++"
else
  cxx="${CXX-${cross_prefix}g++}"
fi

313
ar="${AR-${cross_prefix}ar}"
314 315
as="${AS-${cross_prefix}as}"
cpp="${CPP-$cc -E}"
316 317
objcopy="${OBJCOPY-${cross_prefix}objcopy}"
ld="${LD-${cross_prefix}ld}"
Brad's avatar
Brad committed
318
libtool="${LIBTOOL-${cross_prefix}libtool}"
319 320
strip="${STRIP-${cross_prefix}strip}"
windres="${WINDRES-${cross_prefix}windres}"
321 322 323 324 325
pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
query_pkg_config() {
    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
}
pkg_config=query_pkg_config
326
sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
327

328 329 330
# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
ARFLAGS="${ARFLAGS-rv}"

331 332
# default flags for all hosts
QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
333
QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
Kevin Wolf's avatar
Kevin Wolf committed
334
QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
335
QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
336
QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
337 338 339 340
if test "$debug_info" = "yes"; then
    CFLAGS="-g $CFLAGS"
    LDFLAGS="-g $LDFLAGS"
fi
341

342 343 344
# make source path absolute
source_path=`cd "$source_path"; pwd`

345 346 347
check_define() {
cat > $TMPC <<EOF
#if !defined($1)
348
#error $1 not defined
349 350 351
#endif
int main(void) { return 0; }
EOF
352
  compile_object
353 354
}

355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
if check_define __linux__ ; then
  targetos="Linux"
elif check_define _WIN32 ; then
  targetos='MINGW32'
elif check_define __OpenBSD__ ; then
  targetos='OpenBSD'
elif check_define __sun__ ; then
  targetos='SunOS'
elif check_define __HAIKU__ ; then
  targetos='Haiku'
else
  targetos=`uname -s`
fi

# Some host OSes need non-standard checks for which CPU to use.
# Note that these checks are broken for cross-compilation: if you're
# cross-compiling to one of these OSes then you'll need to specify
# the correct CPU with the --cpu option.
case $targetos in
Darwin)
  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
  # run 64-bit userspace code.
  # If the user didn't specify a CPU explicitly and the kernel says this is
  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
    cpu="x86_64"
  fi
  ;;
SunOS)
  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
    cpu="x86_64"
  fi
esac

390 391 392 393
if test ! -z "$cpu" ; then
  # command line argument
  :
elif check_define __i386__ ; then
394 395
  cpu="i386"
elif check_define __x86_64__ ; then
396 397 398 399 400
  if check_define __ILP32__ ; then
    cpu="x32"
  else
    cpu="x86_64"
  fi
blueswir1's avatar
blueswir1 committed
401 402 403 404 405 406
elif check_define __sparc__ ; then
  if check_define __arch64__ ; then
    cpu="sparc64"
  else
    cpu="sparc"
  fi
malc's avatar
malc committed
407 408 409 410 411 412
elif check_define _ARCH_PPC ; then
  if check_define _ARCH_PPC64 ; then
    cpu="ppc64"
  else
    cpu="ppc"
  fi
Aurelien Jarno's avatar
Aurelien Jarno committed
413 414
elif check_define __mips__ ; then
  cpu="mips"
Aurelien Jarno's avatar
Aurelien Jarno committed
415 416
elif check_define __ia64__ ; then
  cpu="ia64"
417 418 419 420 421 422
elif check_define __s390__ ; then
  if check_define __s390x__ ; then
    cpu="s390x"
  else
    cpu="s390"
  fi
423 424
elif check_define __arm__ ; then
  cpu="arm"
425 426
elif check_define __aarch64__ ; then
  cpu="aarch64"
427 428
elif check_define __hppa__ ; then
  cpu="hppa"
429
else
malc's avatar
malc committed
430
  cpu=`uname -m`
431 432
fi

433 434 435
ARCH=
# Normalise host CPU name and set ARCH.
# Note that this case should only have supported host CPUs, not guests.
bellard's avatar
bellard committed
436
case "$cpu" in
437
  ia64|ppc|ppc64|s390|s390x|sparc64|x32)
438 439
    cpu="$cpu"
  ;;
bellard's avatar
bellard committed
440
  i386|i486|i586|i686|i86pc|BePC)
441
    cpu="i386"
bellard's avatar
bellard committed
442
  ;;
aurel32's avatar
aurel32 committed
443 444 445
  x86_64|amd64)
    cpu="x86_64"
  ;;
446 447
  armv*b|armv*l|arm)
    cpu="arm"
bellard's avatar
bellard committed
448
  ;;
449 450 451
  aarch64)
    cpu="aarch64"
  ;;
Aurelien Jarno's avatar
Aurelien Jarno committed
452 453 454
  mips*)
    cpu="mips"
  ;;
455
  sparc|sun4[cdmuv])
bellard's avatar
bellard committed
456 457
    cpu="sparc"
  ;;
bellard's avatar
bellard committed
458
  *)
459 460
    # This will result in either an error or falling back to TCI later
    ARCH=unknown
bellard's avatar
bellard committed
461 462
  ;;
esac
463 464 465
if test -z "$ARCH"; then
  ARCH="$cpu"
fi
Juan Quintela's avatar
Juan Quintela committed
466

bellard's avatar
bellard committed
467
# OS specific
468

bellard's avatar
bellard committed
469
case $targetos in
bellard's avatar
bellard committed
470
CYGWIN*)
471
  mingw32="yes"
472
  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
473 474
  audio_possible_drivers="winwave sdl"
  audio_drv_list="winwave"
bellard's avatar
bellard committed
475
;;
bellard's avatar
bellard committed
476
MINGW32*)
477
  mingw32="yes"
478 479
  audio_possible_drivers="winwave dsound sdl fmod"
  audio_drv_list="winwave"
bellard's avatar
bellard committed
480
;;
ths's avatar
ths committed
481
GNU/kFreeBSD)
482
  bsd="yes"
483 484
  audio_drv_list="oss"
  audio_possible_drivers="oss sdl esd pa"
ths's avatar
ths committed
485
;;
bellard's avatar
bellard committed
486
FreeBSD)
487
  bsd="yes"
488
  make="${MAKE-gmake}"
489 490
  audio_drv_list="oss"
  audio_possible_drivers="oss sdl esd pa"
491 492
  # needed for kinfo_getvmmap(3) in libutil.h
  LIBS="-lutil $LIBS"
493
  netmap=""  # enable netmap autodetect
bellard's avatar
bellard committed
494
;;
495
DragonFly)
496
  bsd="yes"
497
  make="${MAKE-gmake}"
498 499
  audio_drv_list="oss"
  audio_possible_drivers="oss sdl esd pa"
500
;;
bellard's avatar
bellard committed
501
NetBSD)
502
  bsd="yes"
503
  make="${MAKE-gmake}"
504 505 506
  audio_drv_list="oss"
  audio_possible_drivers="oss sdl esd"
  oss_lib="-lossaudio"
bellard's avatar
bellard committed
507 508
;;
OpenBSD)
509
  bsd="yes"
510
  make="${MAKE-gmake}"
Brad Smith's avatar
Brad Smith committed
511 512
  audio_drv_list="sdl"
  audio_possible_drivers="sdl esd"
bellard's avatar
bellard committed
513
;;
514
Darwin)
515 516 517
  bsd="yes"
  darwin="yes"
  if [ "$cpu" = "x86_64" ] ; then
518
    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
519
    LDFLAGS="-arch x86_64 $LDFLAGS"
520
  else
521
    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
522 523 524 525 526
  fi
  cocoa="yes"
  audio_drv_list="coreaudio"
  audio_possible_drivers="coreaudio sdl fmod"
  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
527
  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
528 529 530
  # Disable attempts to use ObjectiveC features in os/object.h since they
  # won't work when we're compiling with gcc as a C compiler.
  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
531
;;
bellard's avatar
bellard committed
532
SunOS)
533
  solaris="yes"
534 535
  make="${MAKE-gmake}"
  install="${INSTALL-ginstall}"
536
  ld="gld"
537
  smbd="${SMBD-/usr/sfw/sbin/smbd}"
538 539 540 541 542 543
  needs_libsunmath="no"
  solarisrev=`uname -r | cut -f2 -d.`
  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
    if test "$solarisrev" -le 9 ; then
      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
        needs_libsunmath="yes"
544 545 546
        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
        LIBS="-lsunmath $LIBS"
547
      else
548 549 550 551
        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
            "Studio 11 can be downloaded from www.sun.com."
552
      fi
ths's avatar
ths committed
553
    fi
554 555 556 557 558
  fi
  if test -f /usr/include/sys/soundcard.h ; then
    audio_drv_list="oss"
  fi
  audio_possible_drivers="oss sdl"
559 560 561 562
# needed for CMSG_ macros in sys/socket.h
  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
# needed for TIOCWIN* defines in termios.h
  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
563
  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
564 565 566
  solarisnetlibs="-lsocket -lnsl -lresolv"
  LIBS="$solarisnetlibs $LIBS"
  libs_qga="$solarisnetlibs $libs_qga"
ths's avatar
ths committed
567
;;
malc's avatar
malc committed
568
AIX)
569
  aix="yes"
570
  make="${MAKE-gmake}"
malc's avatar
malc committed
571
;;
572 573 574 575 576
Haiku)
  haiku="yes"
  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
  LIBS="-lposix_error_mapper -lnetwork $LIBS"
;;
577
*)
578 579 580 581
  audio_drv_list="oss"
  audio_possible_drivers="oss alsa sdl esd pa"
  linux="yes"
  linux_user="yes"
582 583
  kvm="yes"
  vhost_net="yes"
584
  vhost_scsi="yes"
585
  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "x32" ] ; then
586
    audio_possible_drivers="$audio_possible_drivers fmod"
587
  fi
588
  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
589
;;
bellard's avatar
bellard committed
590 591
esac

bellard's avatar
bellard committed
592
if [ "$bsd" = "yes" ] ; then
593
  if [ "$darwin" != "yes" ] ; then
594
    bsd_user="yes"
595
  fi
bellard's avatar
bellard committed
596 597
fi

598 599
: ${make=${MAKE-make}}
: ${install=${INSTALL-install}}
600
: ${python=${PYTHON-python}}
601
: ${smbd=${SMBD-/usr/sbin/smbd}}
602

603 604 605 606 607 608 609
# Default objcc to clang if available, otherwise use CC
if has clang; then
  objcc=clang
else
  objcc="$cc"
fi

610 611
if test "$mingw32" = "yes" ; then
  EXESUF=".exe"
612
  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
613 614
  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
615 616 617 618 619 620 621
  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
cat > $TMPC << EOF
int main(void) { return 0; }
EOF
  if compile_prog "" "-liberty" ; then
    LIBS="-liberty $LIBS"
  fi
622
  prefix="c:/Program Files/QEMU"
623
  mandir="\${prefix}"
624
  datadir="\${prefix}"
625
  qemu_docdir="\${prefix}"
626 627
  bindir="\${prefix}"
  sysconfdir="\${prefix}"
628
  local_statedir=
629
  confsuffix=""
630
  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
631 632
fi

633
werror=""
634

bellard's avatar
bellard committed
635
for opt do
pbrook's avatar
pbrook committed
636
  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
bellard's avatar
bellard committed
637
  case "$opt" in
638 639
  --help|-h) show_help=yes
  ;;
640 641
  --version|-V) exec cat $source_path/VERSION
  ;;
642
  --prefix=*) prefix="$optarg"
bellard's avatar
bellard committed
643
  ;;
644
  --interp-prefix=*) interp_prefix="$optarg"
bellard's avatar
bellard committed
645
  ;;
646
  --source-path=*)
bellard's avatar
bellard committed
647
  ;;
648
  --cross-prefix=*)
bellard's avatar
bellard committed
649
  ;;
650
  --cc=*)
bellard's avatar
bellard committed
651
  ;;
652
  --host-cc=*) host_cc="$optarg"
bellard's avatar
bellard committed
653
  ;;
654 655
  --cxx=*)
  ;;
656 657
  --iasl=*) iasl="$optarg"
  ;;
658 659
  --objcc=*) objcc="$optarg"
  ;;
660
  --make=*) make="$optarg"
bellard's avatar
bellard committed
661
  ;;
662 663
  --install=*) install="$optarg"
  ;;
Blue Swirl's avatar
Blue Swirl committed
664 665
  --python=*) python="$optarg"
  ;;
Blue Swirl's avatar
Blue Swirl committed
666 667
  --gcov=*) gcov_tool="$optarg"
  ;;
668 669
  --smbd=*) smbd="$optarg"
  ;;
670
  --extra-cflags=*)
bellard's avatar
bellard committed
671
  ;;
672
  --extra-ldflags=*)
bellard's avatar
bellard committed
673
  ;;
674 675 676 677
  --enable-debug-info)
  ;;
  --disable-debug-info)
  ;;
678
  --cpu=*)
bellard's avatar
bellard committed
679
  ;;
680
  --target-list=*) target_list="$optarg"
bellard's avatar
bellard committed
681
  ;;
682
  --enable-trace-backend=*) trace_backend="$optarg"
683
  ;;
684
  --with-trace-file=*) trace_file="$optarg"
685
  ;;
bellard's avatar
bellard committed
686 687
  --enable-gprof) gprof="yes"
  ;;
Blue Swirl's avatar
Blue Swirl committed
688 689
  --enable-gcov) gcov="yes"
  ;;
690 691 692
  --static)
    static="yes"
    LDFLAGS="-static $LDFLAGS"
693
    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
bellard's avatar
bellard committed
694
  ;;
695 696 697 698
  --mandir=*) mandir="$optarg"
  ;;
  --bindir=*) bindir="$optarg"
  ;;
699 700
  --libdir=*) libdir="$optarg"
  ;;
701 702
  --libexecdir=*) libexecdir="$optarg"
  ;;
703 704
  --includedir=*) includedir="$optarg"
  ;;
705
  --datadir=*) datadir="$optarg"
706
  ;;
707 708
  --with-confsuffix=*) confsuffix="$optarg"
  ;;
709
  --docdir=*) qemu_docdir="$optarg"
710
  ;;
711
  --sysconfdir=*) sysconfdir="$optarg"
712
  ;;
713 714 715
  --localstatedir=*) local_statedir="$optarg"
  ;;
  --sbindir=*|--sharedstatedir=*|\
716 717 718 719 720 721 722
  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
    # These switches are silently ignored, for compatibility with
    # autoconf-generated configure scripts. This allows QEMU's
    # configure to be used by RPM and similar macros that set
    # lots of directory switches by default.
  ;;
723 724 725 726
  --with-system-pixman) pixman="system"
  ;;
  --without-system-pixman) pixman="internal"
  ;;
727 728
  --without-pixman) pixman="none"
  ;;
729 730
  --disable-sdl) sdl="no"
  ;;
731 732
  --enable-sdl) sdl="yes"
  ;;
733 734 735 736
  --disable-qom-cast-debug) qom_cast_debug="no"
  ;;
  --enable-qom-cast-debug) qom_cast_debug="yes"
  ;;
737 738 739 740
  --disable-virtfs) virtfs="no"
  ;;
  --enable-virtfs) virtfs="yes"
  ;;
Jes Sorensen's avatar
Jes Sorensen committed
741 742 743 744
  --disable-vnc) vnc="no"
  ;;
  --enable-vnc) vnc="yes"
  ;;
malc's avatar
malc committed
745
  --fmod-lib=*) fmod_lib="$optarg"
746
  ;;
747 748
  --fmod-inc=*) fmod_inc="$optarg"
  ;;
blueswir1's avatar
blueswir1 committed
749 750
  --oss-lib=*) oss_lib="$optarg"
  ;;
malc's avatar
malc committed
751
  --audio-drv-list=*) audio_drv_list="$optarg"
bellard's avatar
bellard committed
752
  ;;
753 754 755
  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
  ;;
  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
756
  ;;
757 758 759 760
  --enable-debug-tcg) debug_tcg="yes"
  ;;
  --disable-debug-tcg) debug_tcg="no"
  ;;
Paul Brook's avatar
Paul Brook committed
761 762 763 764 765 766
  --enable-debug)
      # Enable debugging options that aren't excessively noisy
      debug_tcg="yes"
      debug="yes"
      strip_opt="no"
  ;;
767 768 769 770
  --enable-sparse) sparse="yes"
  ;;
  --disable-sparse) sparse="no"
  ;;
771 772
  --disable-strip) strip_opt="no"
  ;;
773 774
  --disable-vnc-tls) vnc_tls="no"
  ;;
775 776
  --enable-vnc-tls) vnc_tls="yes"
  ;;
777 778
  --disable-vnc-sasl) vnc_sasl="no"
  ;;
779 780
  --enable-vnc-sasl) vnc_sasl="yes"
  ;;
781 782 783 784
  --disable-vnc-jpeg) vnc_jpeg="no"
  ;;
  --enable-vnc-jpeg) vnc_jpeg="yes"
  ;;
Corentin Chary's avatar
Corentin Chary committed
785 786 787 788
  --disable-vnc-png) vnc_png="no"
  ;;
  --enable-vnc-png) vnc_png="yes"
  ;;
789 790 791 792
  --disable-vnc-ws) vnc_ws="no"
  ;;
  --enable-vnc-ws) vnc_ws="yes"
  ;;
bellard's avatar
bellard committed
793
  --disable-slirp) slirp="no"
794
  ;;
795 796 797 798
  --disable-uuid) uuid="no"
  ;;
  --enable-uuid) uuid="yes"
  ;;
799
  --disable-vde) vde="no"
800
  ;;
801 802
  --enable-vde) vde="yes"
  ;;
803 804 805 806
  --disable-netmap) netmap="no"
  ;;
  --enable-netmap) netmap="yes"
  ;;
807 808
  --disable-xen) xen="no"
  ;;
809 810
  --enable-xen) xen="yes"
  ;;
811 812 813 814
  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
  ;;
  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
  ;;
aurel32's avatar
aurel32 committed
815 816
  --disable-brlapi) brlapi="no"
  ;;
817 818
  --enable-brlapi) brlapi="yes"
  ;;
819 820
  --disable-bluez) bluez="no"
  ;;
821 822
  --enable-bluez) bluez="yes"
  ;;
aliguori's avatar
aliguori committed
823 824
  --disable-kvm) kvm="no"
  ;;
825 826
  --enable-kvm) kvm="yes"
  ;;
827 828 829 830
  --disable-tcg-interpreter) tcg_interpreter="no"
  ;;
  --enable-tcg-interpreter) tcg_interpreter="yes"
  ;;
831 832 833 834
  --disable-cap-ng)  cap_ng="no"
  ;;
  --enable-cap-ng) cap_ng="yes"
  ;;
835 836 837 838
  --disable-spice) spice="no"
  ;;
  --enable-spice) spice="yes"
  ;;
Ronnie Sahlberg's avatar
Ronnie Sahlberg committed
839 840 841 842
  --disable-libiscsi) libiscsi="no"
  ;;
  --enable-libiscsi) libiscsi="yes"
  ;;
843 844
  --enable-profiler) profiler="yes"
  ;;
845 846
  --disable-cocoa) cocoa="no"
  ;;
847 848 849 850
  --enable-cocoa)
      cocoa="yes" ;
      sdl="no" ;
      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
851
  ;;
852
  --disable-system) softmmu="no"
853
  ;;
854
  --enable-system) softmmu="yes"
855
  ;;
856 857 858 859 860
  --disable-user)
      linux_user="no" ;
      bsd_user="no" ;
  ;;
  --enable-user) ;;
861
  --disable-linux-user) linux_user="no"
862
  ;;
863 864
  --enable-linux-user) linux_user="yes"
  ;;
865 866 867 868
  --disable-bsd-user) bsd_user="no"
  ;;
  --enable-bsd-user) bsd_user="yes"
  ;;
869 870 871 872
  --enable-guest-base) guest_base="yes"
  ;;
  --disable-guest-base) guest_base="no"
  ;;
873
  --enable-pie) pie="yes"
874
  ;;
875
  --disable-pie) pie="no"
876
  ;;
877 878
  --enable-uname-release=*) uname_release="$optarg"
  ;;
879 880 881 882
  --enable-werror) werror="yes"
  ;;
  --disable-werror) werror="no"
  ;;
balrog's avatar
balrog committed
883 884
  --disable-curses) curses="no"
  ;;
885 886
  --enable-curses) curses="yes"
  ;;
887 888
  --disable-curl) curl="no"
  ;;
889 890
  --enable-curl) curl="yes"
  ;;
891 892 893 894
  --disable-fdt) fdt="no"
  ;;
  --enable-fdt) fdt="yes"
  ;;
895 896 897 898
  --disable-linux-aio) linux_aio="no"
  ;;
  --enable-linux-aio) linux_aio="yes"
  ;;
899 900 901 902
  --disable-attr) attr="no"
  ;;
  --enable-attr) attr="yes"
  ;;
ths's avatar
ths committed
903 904
  --disable-blobs) blobs="no"
  ;;
pbrook's avatar
pbrook committed
905 906
  --with-pkgversion=*) pkgversion=" ($optarg)"
  ;;
907 908
  --with-coroutine=*) coroutine="$optarg"
  ;;
909 910 911 912
  --disable-coroutine-pool) coroutine_pool="no"
  ;;
  --enable-coroutine-pool) coroutine_pool="yes"
  ;;
Juan Quintela's avatar
Juan Quintela committed
913
  --disable-docs) docs="no"
914
  ;;
Juan Quintela's avatar
Juan Quintela committed
915
  --enable-docs) docs="yes"
916
  ;;
917 918 919 920
  --disable-vhost-net) vhost_net="no"
  ;;
  --enable-vhost-net) vhost_net="yes"
  ;;
921 922 923 924
  --disable-vhost-scsi) vhost_scsi="no"
  ;;
  --enable-vhost-scsi) vhost_scsi="yes"
  ;;
925
  --disable-glx) glx="no"
926
  ;;
927
  --enable-glx) glx="yes"
928
  ;;
929 930 931 932
  --disable-rbd) rbd="no"
  ;;
  --enable-rbd) rbd="yes"
  ;;
933 934 935 936
  --disable-xfsctl) xfs="no"
  ;;
  --enable-xfsctl) xfs="yes"
  ;;
Robert Relyea's avatar
Robert Relyea committed
937 938 939 940
  --disable-smartcard-nss) smartcard_nss="no"
  ;;
  --enable-smartcard-nss) smartcard_nss="yes"
  ;;
Gerd Hoffmann's avatar
Gerd Hoffmann committed
941 942 943 944
  --disable-libusb) libusb="no"
  ;;
  --enable-libusb) libusb="yes"
  ;;
945 946 947 948
  --disable-usb-redir) usb_redir="no"
  ;;
  --enable-usb-redir) usb_redir="yes"
  ;;
949 950
  --disable-zlib-test) zlib="no"
  ;;
951 952 953 954
  --enable-guest-agent) guest_agent="yes"
  ;;
  --disable-guest-agent) guest_agent="no"
  ;;
955 956 957 958 959 960 961 962 963 964 965 966
  --with-vss-sdk) vss_win32_sdk=""
  ;;
  --with-vss-sdk=*) vss_win32_sdk="$optarg"
  ;;
  --without-vss-sdk) vss_win32_sdk="no"
  ;;
  --with-win-sdk) win_sdk=""
  ;;
  --with-win-sdk=*) win_sdk="$optarg"
  ;;
  --without-win-sdk) win_sdk="no"
  ;;
967 968 969 970
  --enable-tools) want_tools="yes"
  ;;
  --disable-tools) want_tools="no"
  ;;
971 972 973 974
  --enable-seccomp) seccomp="yes"
  ;;
  --disable-seccomp) seccomp="no"
  ;;
975 976 977 978
  --disable-glusterfs) glusterfs="no"
  ;;
  --enable-glusterfs) glusterfs="yes"
  ;;
979 980 981 982
  --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
  ;;
  --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
  ;;
Anthony Liguori's avatar
Anthony Liguori committed
983 984 985 986
  --disable-gtk) gtk="no"
  ;;
  --enable-gtk) gtk="yes"
  ;;
Michael R. Hines's avatar
Michael R. Hines committed
987 988 989 990
  --enable-rdma) rdma="yes"
  ;;
  --disable-rdma) rdma="no"
  ;;
991 992
  --with-gtkabi=*) gtkabi="$optarg"
  ;;
Stefan Berger's avatar
Stefan Berger committed
993 994
  --enable-tpm) tpm="yes"
  ;;
995 996 997 998
  --disable-libssh2) libssh2="no"
  ;;
  --enable-libssh2) libssh2="yes"
  ;;
999 1000 1001 1002
  --enable-vhdx) vhdx="yes"
  ;;
  --disable-vhdx) vhdx="no"
  ;;
1003 1004
  *) echo "ERROR: unknown option $opt"; show_help="yes"
  ;;
bellard's avatar
bellard committed
1005 1006 1007
  esac
done

1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
if ! has $python; then
  error_exit "Python not found. Use --python=/path/to/python"
fi

# Note that if the Python conditional here evaluates True we will exit
# with status 1 which is a shell 'false' value.
if ! $python -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
  error_exit "Cannot use '$python', Python 2.4 or later is required." \
      "Note that Python 3 or later is not yet supported." \
      "Use --python=/path/to/python to specify a supported Python."
fi

# The -B switch was added in Python 2.6.
# If it is supplied, compiled files are not written.
# Use it for Python versions which support it.
if $python -B -c 'import sys; sys.exit(0)' 2>/dev/null; then
  python="$python -B"
fi

1027
case "$cpu" in
1028 1029 1030 1031 1032 1033 1034 1035
    ppc)
           CPU_CFLAGS="-m32"
           LDFLAGS="-m32 $LDFLAGS"
           ;;
    ppc64)
           CPU_CFLAGS="-m64"
           LDFLAGS="-m64 $LDFLAGS"
           ;;
1036
    sparc)
1037
           LDFLAGS="-m32 $LDFLAGS"
1038
           CPU_CFLAGS="-m32 -mcpu=ultrasparc"
1039
           ;;
1040 1041
    sparc64)
           LDFLAGS="-m64 $LDFLAGS"
1042
           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1043
           ;;
1044
    s390)
1045
           CPU_CFLAGS="-m31 -march=z990"
1046 1047 1048
           LDFLAGS="-m31 $LDFLAGS"
           ;;
    s390x)
1049
           CPU_CFLAGS="-m64 -march=z990"
1050
           LDFLAGS="-m64 $LDFLAGS"
1051
           ;;
1052
    i386)
1053
           CPU_CFLAGS="-m32"
1054
           LDFLAGS="-m32 $LDFLAGS"
Paolo Bonzini's avatar
Paolo Bonzini committed
1055
           cc_i386='$(CC) -m32'
1056 1057
           ;;
    x86_64)
1058
           CPU_CFLAGS="-m64"
1059
           LDFLAGS="-m64 $LDFLAGS"
Paolo Bonzini's avatar
Paolo Bonzini committed
1060
           cc_i386='$(CC) -m32'
1061
           ;;
1062 1063 1064 1065 1066
    x32)
           CPU_CFLAGS="-mx32"
           LDFLAGS="-mx32 $LDFLAGS"
           cc_i386='$(CC) -m32'
           ;;
1067
    # No special flags required for other host CPUs
1068 1069
esac

1070 1071 1072
QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"

1073 1074
default_target_list=""

1075 1076 1077 1078
mak_wilds=""

if [ "$softmmu" = "yes" ]; then
    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1079
fi