xref: /openbmc/qemu/configure (revision 95c6bff3)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
57d13299dSbellard# set temporary file name
67d13299dSbellardif test ! -z "$TMPDIR" ; then
77d13299dSbellard    TMPDIR1="${TMPDIR}"
87d13299dSbellardelif test ! -z "$TEMPDIR" ; then
97d13299dSbellard    TMPDIR1="${TEMPDIR}"
107d13299dSbellardelse
117d13299dSbellard    TMPDIR1="/tmp"
127d13299dSbellardfi
137d13299dSbellard
143ef693a0SbellardTMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
153ef693a0SbellardTMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16a91b857cSmalcTMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
177d13299dSbellard
180ba8681eSLoïc Minier# NB: do not call "exit" in the trap handler; this is buggy with some shells;
190ba8681eSLoïc Minier# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
200ba8681eSLoïc Miniertrap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21da1d85e3SGerd Hoffmannrm -f config.log
229ac81bbbSmalc
23b48e3611SPeter Maydell# Print a helpful header at the top of config.log
24b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
25979ae168SPeter Maydellprintf "# Configured with:" >> config.log
26979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
27979ae168SPeter Maydellecho >> config.log
28b48e3611SPeter Maydellecho "#" >> config.log
29b48e3611SPeter Maydell
30bdf523e6SStefan Weil# Save the configure command line for later reuse.
31bdf523e6SStefan Weilcat <<EOD >config.status
32bdf523e6SStefan Weil#!/bin/sh
33bdf523e6SStefan Weil# Generated by configure.
34bdf523e6SStefan Weil# Run this file to recreate the current configuration.
35bdf523e6SStefan Weil# Compiler output produced by configure, useful for debugging
36bdf523e6SStefan Weil# configure, is in config.log if it exists.
37bdf523e6SStefan WeilEOD
38bdf523e6SStefan Weilprintf "exec" >>config.status
39bdf523e6SStefan Weilprintf " '%s'" "$0" "$@" >>config.status
40bdf523e6SStefan Weilecho >>config.status
41bdf523e6SStefan Weilchmod +x config.status
42bdf523e6SStefan Weil
4376ad07a4SPeter Maydellerror_exit() {
4476ad07a4SPeter Maydell    echo
4576ad07a4SPeter Maydell    echo "ERROR: $1"
4676ad07a4SPeter Maydell    while test -n "$2"; do
4776ad07a4SPeter Maydell        echo "       $2"
4876ad07a4SPeter Maydell        shift
4976ad07a4SPeter Maydell    done
5076ad07a4SPeter Maydell    echo
5176ad07a4SPeter Maydell    exit 1
5276ad07a4SPeter Maydell}
5376ad07a4SPeter Maydell
548dc38a78SPeter Maydelldo_cc() {
558dc38a78SPeter Maydell    # Run the compiler, capturing its output to the log.
568dc38a78SPeter Maydell    echo $cc "$@" >> config.log
578dc38a78SPeter Maydell    $cc "$@" >> config.log 2>&1 || return $?
588dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
598dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
608dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
618dc38a78SPeter Maydell    # obvious to developers.
628dc38a78SPeter Maydell    if test "$werror" != "yes"; then
638dc38a78SPeter Maydell        return 0
648dc38a78SPeter Maydell    fi
658dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
668dc38a78SPeter Maydell    case "$*" in
678dc38a78SPeter Maydell        *-Werror*)
688dc38a78SPeter Maydell           return 0
698dc38a78SPeter Maydell        ;;
708dc38a78SPeter Maydell    esac
718dc38a78SPeter Maydell    echo $cc -Werror "$@" >> config.log
728dc38a78SPeter Maydell    $cc -Werror "$@" >> config.log 2>&1 && return $?
7376ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
7476ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
7576ad07a4SPeter Maydell        "will be at the bottom of config.log." \
7676ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
778dc38a78SPeter Maydell}
788dc38a78SPeter Maydell
7952166aa0SJuan Quintelacompile_object() {
808dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
8152166aa0SJuan Quintela}
8252166aa0SJuan Quintela
8352166aa0SJuan Quintelacompile_prog() {
8452166aa0SJuan Quintela  local_cflags="$1"
8552166aa0SJuan Quintela  local_ldflags="$2"
868dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
8752166aa0SJuan Quintela}
8852166aa0SJuan Quintela
8911568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
9011568d6dSPaolo Bonzinisymlink() {
9172b8b5a1SStefan Weil  rm -rf "$2"
92ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
9372b8b5a1SStefan Weil  ln -s "$1" "$2"
9411568d6dSPaolo Bonzini}
9511568d6dSPaolo Bonzini
960dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
970dba6195SLoïc Minier# executable or a builtin)
980dba6195SLoïc Minierhas() {
990dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1000dba6195SLoïc Minier}
1010dba6195SLoïc Minier
1020dba6195SLoïc Minier# search for an executable in PATH
1030dba6195SLoïc Minierpath_of() {
1040dba6195SLoïc Minier    local_command="$1"
1050dba6195SLoïc Minier    local_ifs="$IFS"
1060dba6195SLoïc Minier    local_dir=""
1070dba6195SLoïc Minier
1080dba6195SLoïc Minier    # pathname has a dir component?
1090dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1100dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1110dba6195SLoïc Minier            echo "$local_command"
1120dba6195SLoïc Minier            return 0
1130dba6195SLoïc Minier        fi
1140dba6195SLoïc Minier    fi
1150dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1160dba6195SLoïc Minier        return 1
1170dba6195SLoïc Minier    fi
1180dba6195SLoïc Minier
1190dba6195SLoïc Minier    IFS=:
1200dba6195SLoïc Minier    for local_dir in $PATH; do
1210dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1220dba6195SLoïc Minier            echo "$local_dir/$local_command"
1230dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1240dba6195SLoïc Minier            return 0
1250dba6195SLoïc Minier        fi
1260dba6195SLoïc Minier    done
1270dba6195SLoïc Minier    # not found
1280dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1290dba6195SLoïc Minier    return 1
1300dba6195SLoïc Minier}
1310dba6195SLoïc Minier
1327d13299dSbellard# default parameters
133ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
1342ff6b91eSJuan Quintelacpu=""
135a31a8642SMichael S. Tsirkiniasl="iasl"
1361e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
13743ce4dfeSbellardstatic="no"
1387d13299dSbellardcross_prefix=""
1390c58ac1cSmalcaudio_drv_list=""
140b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
141b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
142e49d021eSPeter Maydellhost_cc="cc"
14373da375eSJuan Quintelalibs_softmmu=""
1443e2e0e6bSJuan Quintelalibs_tools=""
14567f86e8eSJuan Quintelaaudio_pt_int=""
146d5631638Smalcaudio_win_int=""
1472b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
148957f1f99SMichael Rothlibs_qga=""
1495bc62e01SGerd Hoffmanndebug_info="yes"
150ac0df51dSaliguori
151afb63ebdSStefan Weil# Don't accept a target_list environment variable.
152afb63ebdSStefan Weilunset target_list
153377529c0SPaolo Bonzini
154377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
155377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
156377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
157377529c0SPaolo Bonzini#              unless --disable-foo is given
158377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
159377529c0SPaolo Bonzini#              feature will searched for,
160377529c0SPaolo Bonzini#              if not found, configure exits with error
161377529c0SPaolo Bonzini#
162377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
163377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
164377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
165377529c0SPaolo Bonzini
166377529c0SPaolo Bonzinibluez=""
167377529c0SPaolo Bonzinibrlapi=""
168377529c0SPaolo Bonzinicurl=""
169377529c0SPaolo Bonzinicurses=""
170377529c0SPaolo Bonzinidocs=""
171377529c0SPaolo Bonzinifdt=""
17258952137SVincenzo Maffionenetmap="no"
173e2134eb9SGerd Hoffmannpixman=""
174377529c0SPaolo Bonzinisdl=""
175983eef5aSMeador Ingevirtfs=""
176821601eaSJes Sorensenvnc="yes"
177377529c0SPaolo Bonzinisparse="no"
178377529c0SPaolo Bonziniuuid=""
179377529c0SPaolo Bonzinivde=""
180377529c0SPaolo Bonzinivnc_tls=""
181377529c0SPaolo Bonzinivnc_sasl=""
182377529c0SPaolo Bonzinivnc_jpeg=""
183377529c0SPaolo Bonzinivnc_png=""
1847536ee4bSTim Hardeckvnc_ws=""
185377529c0SPaolo Bonzinixen=""
186d5b93ddfSAnthony PERARDxen_ctrl_version=""
187eb6fda0fSAnthony PERARDxen_pci_passthrough=""
188377529c0SPaolo Bonzinilinux_aio=""
18947e98658SCorey Bryantcap_ng=""
190377529c0SPaolo Bonziniattr=""
1914f26f2b6SAvi Kivitylibattr=""
192377529c0SPaolo Bonzinixfs=""
193377529c0SPaolo Bonzini
194d41a75a2SBradvhost_net="no"
1955e9be92dSNicholas Bellingervhost_scsi="no"
196d41a75a2SBradkvm="no"
1972da776dbSMichael R. Hinesrdma=""
198377529c0SPaolo Bonzinigprof="no"
199377529c0SPaolo Bonzinidebug_tcg="no"
200377529c0SPaolo Bonzinidebug="no"
201377529c0SPaolo Bonzinistrip_opt="yes"
2029195b2c2SStefan Weiltcg_interpreter="no"
203377529c0SPaolo Bonzinibigendian="no"
204377529c0SPaolo Bonzinimingw32="no"
2051d728c39SBlue Swirlgcov="no"
2061d728c39SBlue Swirlgcov_tool="gcov"
207377529c0SPaolo BonziniEXESUF=""
208377529c0SPaolo Bonziniprefix="/usr/local"
209377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
210528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
211850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
212377529c0SPaolo Bonzinibindir="\${prefix}/bin"
2133aa5d2beSAlon Levylibdir="\${prefix}/lib"
2148bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
2150f94d6daSAlon Levyincludedir="\${prefix}/include"
216377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
217785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
218377529c0SPaolo Bonziniconfsuffix="/qemu"
219377529c0SPaolo Bonzinislirp="yes"
220377529c0SPaolo Bonzinifmod_lib=""
221377529c0SPaolo Bonzinifmod_inc=""
222377529c0SPaolo Bonzinioss_lib=""
223377529c0SPaolo Bonzinibsd="no"
224377529c0SPaolo Bonzinilinux="no"
225377529c0SPaolo Bonzinisolaris="no"
226377529c0SPaolo Bonziniprofiler="no"
227377529c0SPaolo Bonzinicocoa="no"
228377529c0SPaolo Bonzinisoftmmu="yes"
229377529c0SPaolo Bonzinilinux_user="no"
230377529c0SPaolo Bonzinibsd_user="no"
23130163d89SPeter Maydellguest_base="yes"
232377529c0SPaolo Bonziniuname_release=""
233377529c0SPaolo Bonziniaix="no"
234377529c0SPaolo Bonziniblobs="yes"
235377529c0SPaolo Bonzinipkgversion=""
23640d6444eSAvi Kivitypie=""
237377529c0SPaolo Bonzinizero_malloc=""
2383556c233SPaolo Bonziniqom_cast_debug="yes"
239377529c0SPaolo Bonzinitrace_backend="nop"
240377529c0SPaolo Bonzinitrace_file="trace"
241377529c0SPaolo Bonzinispice=""
242377529c0SPaolo Bonzinirbd=""
243111a38b0SRobert Relyeasmartcard_nss=""
2442b2325ffSGerd Hoffmannlibusb=""
24569354a83SHans de Goedeusb_redir=""
246b1e5fff4SMichael Walleglx=""
2471ece9905SAlon Levyzlib="yes"
248e8ef31a3SMichael Tokarevguest_agent=""
249d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
250d9840e25STomoki Sekiyamavss_win32_sdk=""
251d9840e25STomoki Sekiyamawin_sdk="no"
2524b1c11fdSDaniel P. Berrangewant_tools="yes"
253c589b249SRonnie Sahlberglibiscsi=""
2546542aa9cSPeter Lievenlibnfs=""
255519175a2SAlex Barcelocoroutine=""
25670c60c08SStefan Hajnoczicoroutine_pool=""
257f794573eSEduardo Otuboseccomp=""
258eb100396SBharata B Raoglusterfs=""
2590c14fb47SBharata B Raoglusterfs_discard="no"
2607c815372SBharata B Raoglusterfs_zerofill="no"
261583f6e7bSStefan Hajnoczivirtio_blk_data_plane=""
262a4ccabcfSAnthony Liguorigtk=""
263528de90aSDaniel P. Berrangegtkabi="2.0"
264ab214c29SStefan Bergertpm="no"
2650a12ec87SRichard W.M. Joneslibssh2=""
2664f18b782SJeff Codyvhdx=""
267*95c6bff3SBenoît Canetquorum="no"
268377529c0SPaolo Bonzini
269ac0df51dSaliguori# parse CC options first
270ac0df51dSaliguorifor opt do
271ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
272ac0df51dSaliguori  case "$opt" in
273ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
274ac0df51dSaliguori  ;;
2753d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
276ac0df51dSaliguori  ;;
27783f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
27883f73fceSTomoki Sekiyama  ;;
279ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
280ca4deeb1SPaolo Bonzini  ;;
2812ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2822ff6b91eSJuan Quintela  ;;
283a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
284f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
285e2a2ed06SJuan Quintela  ;;
286e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
287f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
288e2a2ed06SJuan Quintela  ;;
2895bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2905bc62e01SGerd Hoffmann  ;;
2915bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2925bc62e01SGerd Hoffmann  ;;
293ac0df51dSaliguori  esac
294ac0df51dSaliguoridone
295ac0df51dSaliguori# OS specific
296ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
29793148aa5SStefan Weil# we can eliminate its usage altogether.
298ac0df51dSaliguori
299e49d021eSPeter Maydell# Preferred compiler:
300e49d021eSPeter Maydell#  ${CC} (if set)
301e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
302e49d021eSPeter Maydell#  system compiler
303e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
304e49d021eSPeter Maydell  cc="$host_cc"
305e49d021eSPeter Maydellelse
306b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
307e49d021eSPeter Maydellfi
308e49d021eSPeter Maydell
30983f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
31083f73fceSTomoki Sekiyama  cxx="c++"
31183f73fceSTomoki Sekiyamaelse
31283f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
31383f73fceSTomoki Sekiyamafi
31483f73fceSTomoki Sekiyama
315b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
3163dd46c78SBlue Swirlas="${AS-${cross_prefix}as}"
3173dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
318b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
319b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
3203f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
321b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
322b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
32317884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
32417884d7bSSergei Trofimovichquery_pkg_config() {
32517884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
32617884d7bSSergei Trofimovich}
32717884d7bSSergei Trofimovichpkg_config=query_pkg_config
328b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
329ac0df51dSaliguori
33045d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
33145d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
33245d285abSPeter Maydell
333be17dc90SMichael S. Tsirkin# default flags for all hosts
334be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
335f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
336c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
337be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
3386b4c305cSPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
3395bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
3405bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
341be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
3425bc62e01SGerd Hoffmannfi
343be17dc90SMichael S. Tsirkin
344ca4deeb1SPaolo Bonzini# make source path absolute
345ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
346ca4deeb1SPaolo Bonzini
347ac0df51dSaliguoricheck_define() {
348ac0df51dSaliguoricat > $TMPC <<EOF
349ac0df51dSaliguori#if !defined($1)
350fd786e1aSPeter Maydell#error $1 not defined
351ac0df51dSaliguori#endif
352ac0df51dSaliguoriint main(void) { return 0; }
353ac0df51dSaliguoriEOF
35452166aa0SJuan Quintela  compile_object
355ac0df51dSaliguori}
356ac0df51dSaliguori
357bbea4050SPeter Maydellif check_define __linux__ ; then
358bbea4050SPeter Maydell  targetos="Linux"
359bbea4050SPeter Maydellelif check_define _WIN32 ; then
360bbea4050SPeter Maydell  targetos='MINGW32'
361bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
362bbea4050SPeter Maydell  targetos='OpenBSD'
363bbea4050SPeter Maydellelif check_define __sun__ ; then
364bbea4050SPeter Maydell  targetos='SunOS'
365bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
366bbea4050SPeter Maydell  targetos='Haiku'
367bbea4050SPeter Maydellelse
368bbea4050SPeter Maydell  targetos=`uname -s`
369bbea4050SPeter Maydellfi
370bbea4050SPeter Maydell
371bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
372bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
373bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
374bbea4050SPeter Maydell# the correct CPU with the --cpu option.
375bbea4050SPeter Maydellcase $targetos in
376bbea4050SPeter MaydellDarwin)
377bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
378bbea4050SPeter Maydell  # run 64-bit userspace code.
379bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
380bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
381bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
382bbea4050SPeter Maydell    cpu="x86_64"
383bbea4050SPeter Maydell  fi
384bbea4050SPeter Maydell  ;;
385bbea4050SPeter MaydellSunOS)
386bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
387bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
388bbea4050SPeter Maydell    cpu="x86_64"
389bbea4050SPeter Maydell  fi
390bbea4050SPeter Maydellesac
391bbea4050SPeter Maydell
3922ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3932ff6b91eSJuan Quintela  # command line argument
3942ff6b91eSJuan Quintela  :
3952ff6b91eSJuan Quintelaelif check_define __i386__ ; then
396ac0df51dSaliguori  cpu="i386"
397ac0df51dSaliguorielif check_define __x86_64__ ; then
398c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
399c72b26ecSRichard Henderson    cpu="x32"
400c72b26ecSRichard Henderson  else
401ac0df51dSaliguori    cpu="x86_64"
402c72b26ecSRichard Henderson  fi
4033aa9bd6cSblueswir1elif check_define __sparc__ ; then
4043aa9bd6cSblueswir1  if check_define __arch64__ ; then
4053aa9bd6cSblueswir1    cpu="sparc64"
4063aa9bd6cSblueswir1  else
4073aa9bd6cSblueswir1    cpu="sparc"
4083aa9bd6cSblueswir1  fi
409fdf7ed96Smalcelif check_define _ARCH_PPC ; then
410fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
411fdf7ed96Smalc    cpu="ppc64"
412ac0df51dSaliguori  else
413fdf7ed96Smalc    cpu="ppc"
414fdf7ed96Smalc  fi
415afa05235SAurelien Jarnoelif check_define __mips__ ; then
416afa05235SAurelien Jarno  cpu="mips"
417477ba620SAurelien Jarnoelif check_define __ia64__ ; then
418477ba620SAurelien Jarno  cpu="ia64"
419d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
420d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
421d66ed0eaSAurelien Jarno    cpu="s390x"
422d66ed0eaSAurelien Jarno  else
423d66ed0eaSAurelien Jarno    cpu="s390"
424d66ed0eaSAurelien Jarno  fi
42521d89f84SPeter Maydellelif check_define __arm__ ; then
42621d89f84SPeter Maydell  cpu="arm"
4271f080313SClaudio Fontanaelif check_define __aarch64__ ; then
4281f080313SClaudio Fontana  cpu="aarch64"
429f28ffed5SBradelif check_define __hppa__ ; then
430f28ffed5SBrad  cpu="hppa"
431fdf7ed96Smalcelse
432fdf7ed96Smalc  cpu=`uname -m`
433ac0df51dSaliguorifi
434ac0df51dSaliguori
435359bc95dSPeter MaydellARCH=
436359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
437359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
4387d13299dSbellardcase "$cpu" in
439c72b26ecSRichard Henderson  ia64|ppc|ppc64|s390|s390x|sparc64|x32)
440ea8f20f8SJuan Quintela    cpu="$cpu"
441ea8f20f8SJuan Quintela  ;;
4427d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
44397a847bcSbellard    cpu="i386"
4447d13299dSbellard  ;;
445aaa5fa14Saurel32  x86_64|amd64)
446aaa5fa14Saurel32    cpu="x86_64"
447aaa5fa14Saurel32  ;;
44821d89f84SPeter Maydell  armv*b|armv*l|arm)
44921d89f84SPeter Maydell    cpu="arm"
4507d13299dSbellard  ;;
4511f080313SClaudio Fontana  aarch64)
4521f080313SClaudio Fontana    cpu="aarch64"
4531f080313SClaudio Fontana  ;;
454afa05235SAurelien Jarno  mips*)
455afa05235SAurelien Jarno    cpu="mips"
456afa05235SAurelien Jarno  ;;
4573142255cSblueswir1  sparc|sun4[cdmuv])
458ae228531Sbellard    cpu="sparc"
459ae228531Sbellard  ;;
4607d13299dSbellard  *)
461359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
462359bc95dSPeter Maydell    ARCH=unknown
4637d13299dSbellard  ;;
4647d13299dSbellardesac
465359bc95dSPeter Maydellif test -z "$ARCH"; then
466359bc95dSPeter Maydell  ARCH="$cpu"
467359bc95dSPeter Maydellfi
468e2d52ad3SJuan Quintela
4697d13299dSbellard# OS specific
4700dbfc675SJuan Quintela
4717d13299dSbellardcase $targetos in
472c326e0afSbellardCYGWIN*)
473c326e0afSbellard  mingw32="yes"
474a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
475d5631638Smalc  audio_possible_drivers="winwave sdl"
476d5631638Smalc  audio_drv_list="winwave"
477c326e0afSbellard;;
47867b915a5SbellardMINGW32*)
47967b915a5Sbellard  mingw32="yes"
480d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
481d5631638Smalc  audio_drv_list="winwave"
48267b915a5Sbellard;;
4835c40d2bdSthsGNU/kFreeBSD)
484a167ba50SAurelien Jarno  bsd="yes"
4850c58ac1cSmalc  audio_drv_list="oss"
486f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4875c40d2bdSths;;
4887d3505c5SbellardFreeBSD)
4897d3505c5Sbellard  bsd="yes"
4900db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4910c58ac1cSmalc  audio_drv_list="oss"
492f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
493f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
494f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
49558952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
4967d3505c5Sbellard;;
497c5e97233Sblueswir1DragonFly)
498c5e97233Sblueswir1  bsd="yes"
4990db4a067SPaolo Bonzini  make="${MAKE-gmake}"
500c5e97233Sblueswir1  audio_drv_list="oss"
501c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
502c5e97233Sblueswir1;;
5037d3505c5SbellardNetBSD)
5047d3505c5Sbellard  bsd="yes"
5050db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5060c58ac1cSmalc  audio_drv_list="oss"
507c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
5088ef92a88Sblueswir1  oss_lib="-lossaudio"
5097d3505c5Sbellard;;
5107d3505c5SbellardOpenBSD)
5117d3505c5Sbellard  bsd="yes"
5120db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5134f6ab397SBrad Smith  audio_drv_list="sdl"
5144f6ab397SBrad Smith  audio_possible_drivers="sdl esd"
5157d3505c5Sbellard;;
51683fb7adfSbellardDarwin)
51783fb7adfSbellard  bsd="yes"
51883fb7adfSbellard  darwin="yes"
5191b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
520a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
5210c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
5221b0f9cc2Saliguori  else
523a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
5241b0f9cc2Saliguori  fi
525fd677642Sths  cocoa="yes"
5260c58ac1cSmalc  audio_drv_list="coreaudio"
527c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
5280c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
5297973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
530a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
531a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
532a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
53383fb7adfSbellard;;
534ec530c81SbellardSunOS)
535ec530c81Sbellard  solaris="yes"
5360db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5370db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
538fa58948dSBlue Swirl  ld="gld"
539e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
5400475a5caSths  needs_libsunmath="no"
541c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
542c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
5430475a5caSths    if test "$solarisrev" -le 9 ; then
5440475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
5450475a5caSths        needs_libsunmath="yes"
546f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
547f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
548f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
5490475a5caSths      else
55076ad07a4SPeter Maydell        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
55176ad07a4SPeter Maydell            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
55276ad07a4SPeter Maydell            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
55376ad07a4SPeter Maydell            "Studio 11 can be downloaded from www.sun.com."
5540475a5caSths      fi
5550475a5caSths    fi
55686b2bd93Sths  fi
5576b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
5580c58ac1cSmalc    audio_drv_list="oss"
5596b4d2ba1Sths  fi
560c2de5c91Smalc  audio_possible_drivers="oss sdl"
561d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
562d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
563d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
564d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
565a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
566560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
567560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
568560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
569ec530c81Sbellard;;
570b29fe3edSmalcAIX)
571b29fe3edSmalc  aix="yes"
5720db4a067SPaolo Bonzini  make="${MAKE-gmake}"
573b29fe3edSmalc;;
574179cf400SAndreas FärberHaiku)
575179cf400SAndreas Färber  haiku="yes"
576179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
577179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
578179cf400SAndreas Färber;;
579fb065187Sbellard*)
5800c58ac1cSmalc  audio_drv_list="oss"
581b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5825327cf48Sbellard  linux="yes"
583831b7825Sths  linux_user="yes"
584af2be207SJan Kiszka  kvm="yes"
585af2be207SJan Kiszka  vhost_net="yes"
5865e9be92dSNicholas Bellinger  vhost_scsi="yes"
587c72b26ecSRichard Henderson  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "x32" ] ; then
588c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
589c9ec1fe4Sbellard  fi
590a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
591fb065187Sbellard;;
5927d13299dSbellardesac
5937d13299dSbellard
5947d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
595b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
59684778508Sblueswir1    bsd_user="yes"
5977d3505c5Sbellard  fi
59808de3949SAndreas Färberfi
5997d3505c5Sbellard
6000db4a067SPaolo Bonzini: ${make=${MAKE-make}}
6010db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
60252510f8bSStefan Weil: ${python=${PYTHON-python}}
603e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
6040db4a067SPaolo Bonzini
6053c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
6063c4a4d0dSPeter Maydellif has clang; then
6073c4a4d0dSPeter Maydell  objcc=clang
6083c4a4d0dSPeter Maydellelse
6093c4a4d0dSPeter Maydell  objcc="$cc"
6103c4a4d0dSPeter Maydellfi
6113c4a4d0dSPeter Maydell
6123457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
6133457a3f8SJuan Quintela  EXESUF=".exe"
614a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
615e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
616e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
617f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
618f7cf5d5bSStefan Weilcat > $TMPC << EOF
619f7cf5d5bSStefan Weilint main(void) { return 0; }
620f7cf5d5bSStefan WeilEOF
621f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
622f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
623f7cf5d5bSStefan Weil  fi
624c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
625683035deSPaolo Bonzini  mandir="\${prefix}"
626528ae5b8SEduardo Habkost  datadir="\${prefix}"
627850da188SEduardo Habkost  qemu_docdir="\${prefix}"
628683035deSPaolo Bonzini  bindir="\${prefix}"
629683035deSPaolo Bonzini  sysconfdir="\${prefix}"
6305a699bbbSLaszlo Ersek  local_statedir=
631683035deSPaolo Bonzini  confsuffix=""
632368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
6333457a3f8SJuan Quintelafi
6343457a3f8SJuan Quintela
635487fefdbSAnthony Liguoriwerror=""
63685aa5189Sbellard
6377d13299dSbellardfor opt do
638a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
6397d13299dSbellard  case "$opt" in
6402efc3265Sbellard  --help|-h) show_help=yes
6412efc3265Sbellard  ;;
64299123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
64399123e13SMike Frysinger  ;;
644b1a550a0Spbrook  --prefix=*) prefix="$optarg"
6457d13299dSbellard  ;;
646b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
64732ce6337Sbellard  ;;
648ca4deeb1SPaolo Bonzini  --source-path=*)
6497d13299dSbellard  ;;
650ac0df51dSaliguori  --cross-prefix=*)
6517d13299dSbellard  ;;
652ac0df51dSaliguori  --cc=*)
6537d13299dSbellard  ;;
654b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
65583469015Sbellard  ;;
65683f73fceSTomoki Sekiyama  --cxx=*)
65783f73fceSTomoki Sekiyama  ;;
658e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
659e007dbecSMichael S. Tsirkin  ;;
6603c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
6613c4a4d0dSPeter Maydell  ;;
662b1a550a0Spbrook  --make=*) make="$optarg"
6637d13299dSbellard  ;;
6646a882643Spbrook  --install=*) install="$optarg"
6656a882643Spbrook  ;;
666c886edfbSBlue Swirl  --python=*) python="$optarg"
667c886edfbSBlue Swirl  ;;
6681d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
6691d728c39SBlue Swirl  ;;
670e2d8830eSBrad  --smbd=*) smbd="$optarg"
671e2d8830eSBrad  ;;
672e2a2ed06SJuan Quintela  --extra-cflags=*)
6737d13299dSbellard  ;;
674e2a2ed06SJuan Quintela  --extra-ldflags=*)
6757d13299dSbellard  ;;
6765bc62e01SGerd Hoffmann  --enable-debug-info)
6775bc62e01SGerd Hoffmann  ;;
6785bc62e01SGerd Hoffmann  --disable-debug-info)
6795bc62e01SGerd Hoffmann  ;;
6802ff6b91eSJuan Quintela  --cpu=*)
6817d13299dSbellard  ;;
682b1a550a0Spbrook  --target-list=*) target_list="$optarg"
683de83cd02Sbellard  ;;
68474242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
68594a420b1SStefan Hajnoczi  ;;
68674242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6879410b56cSPrerna Saxena  ;;
6887d13299dSbellard  --enable-gprof) gprof="yes"
6897d13299dSbellard  ;;
6901d728c39SBlue Swirl  --enable-gcov) gcov="yes"
6911d728c39SBlue Swirl  ;;
69279427693SLoïc Minier  --static)
69379427693SLoïc Minier    static="yes"
69479427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
69517884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
69643ce4dfeSbellard  ;;
6970b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6980b24e75fSPaolo Bonzini  ;;
6990b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
7000b24e75fSPaolo Bonzini  ;;
7013aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
7023aa5d2beSAlon Levy  ;;
7038bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
7048bf188aaSMichael Tokarev  ;;
7050f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
7060f94d6daSAlon Levy  ;;
707528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
7080b24e75fSPaolo Bonzini  ;;
709023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
710023d3d67SEduardo Habkost  ;;
711850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
7120b24e75fSPaolo Bonzini  ;;
713ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
71407381cc1SAnthony Liguori  ;;
715785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
716785c23aeSLuiz Capitulino  ;;
717785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
718023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
719023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
720023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
721023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
722023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
723023ddd74SMax Filippov    # lots of directory switches by default.
724023ddd74SMax Filippov  ;;
725e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
726e2134eb9SGerd Hoffmann  ;;
727e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
728e2134eb9SGerd Hoffmann  ;;
72974880fe2SRobert Schiele  --without-pixman) pixman="none"
73074880fe2SRobert Schiele  ;;
73197a847bcSbellard  --disable-sdl) sdl="no"
73297a847bcSbellard  ;;
733c4198157SJuan Quintela  --enable-sdl) sdl="yes"
734c4198157SJuan Quintela  ;;
7353556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
7363556c233SPaolo Bonzini  ;;
7373556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
7383556c233SPaolo Bonzini  ;;
739983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
740983eef5aSMeador Inge  ;;
741983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
742983eef5aSMeador Inge  ;;
743821601eaSJes Sorensen  --disable-vnc) vnc="no"
744821601eaSJes Sorensen  ;;
745821601eaSJes Sorensen  --enable-vnc) vnc="yes"
746821601eaSJes Sorensen  ;;
747b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
748102a52e4Sbellard  ;;
749c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
750c2de5c91Smalc  ;;
7512f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
7522f6a1ab0Sblueswir1  ;;
7530c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
7540c58ac1cSmalc  ;;
755b64ec4e4SFam Zheng  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
756b64ec4e4SFam Zheng  ;;
757b64ec4e4SFam Zheng  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
758eb852011SMarkus Armbruster  ;;
759f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
760f8393946Saurel32  ;;
761f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
762f8393946Saurel32  ;;
763f3d08ee6SPaul Brook  --enable-debug)
764f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
765f3d08ee6SPaul Brook      debug_tcg="yes"
766f3d08ee6SPaul Brook      debug="yes"
767f3d08ee6SPaul Brook      strip_opt="no"
768f3d08ee6SPaul Brook  ;;
76903b4fe7dSaliguori  --enable-sparse) sparse="yes"
77003b4fe7dSaliguori  ;;
77103b4fe7dSaliguori  --disable-sparse) sparse="no"
77203b4fe7dSaliguori  ;;
7731625af87Saliguori  --disable-strip) strip_opt="no"
7741625af87Saliguori  ;;
7758d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
7768d5d2d4cSths  ;;
7771be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
7781be10ad2SJuan Quintela  ;;
7792f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
7802f9606b3Saliguori  ;;
781ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
782ea784e3bSJuan Quintela  ;;
7832f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
7842f6f5c7aSCorentin Chary  ;;
7852f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
7862f6f5c7aSCorentin Chary  ;;
787efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
788efe556adSCorentin Chary  ;;
789efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
790efe556adSCorentin Chary  ;;
7917536ee4bSTim Hardeck  --disable-vnc-ws) vnc_ws="no"
7927536ee4bSTim Hardeck  ;;
7937536ee4bSTim Hardeck  --enable-vnc-ws) vnc_ws="yes"
7947536ee4bSTim Hardeck  ;;
795443f1376Sbellard  --disable-slirp) slirp="no"
796c20709aaSbellard  ;;
797ee682d27SStefan Weil  --disable-uuid) uuid="no"
798ee682d27SStefan Weil  ;;
799ee682d27SStefan Weil  --enable-uuid) uuid="yes"
800ee682d27SStefan Weil  ;;
801e0e6c8c0Saliguori  --disable-vde) vde="no"
8028a16d273Sths  ;;
803dfb278bdSJuan Quintela  --enable-vde) vde="yes"
804dfb278bdSJuan Quintela  ;;
80558952137SVincenzo Maffione  --disable-netmap) netmap="no"
80658952137SVincenzo Maffione  ;;
80758952137SVincenzo Maffione  --enable-netmap) netmap="yes"
80858952137SVincenzo Maffione  ;;
809e37630caSaliguori  --disable-xen) xen="no"
810e37630caSaliguori  ;;
811fc321b4bSJuan Quintela  --enable-xen) xen="yes"
812fc321b4bSJuan Quintela  ;;
813eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
814eb6fda0fSAnthony PERARD  ;;
815eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
816eb6fda0fSAnthony PERARD  ;;
8172e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
8182e4d9fb1Saurel32  ;;
8194ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
8204ffcedb6SJuan Quintela  ;;
821fb599c9aSbalrog  --disable-bluez) bluez="no"
822fb599c9aSbalrog  ;;
823a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
824a20a6f46SJuan Quintela  ;;
8257ba1e619Saliguori  --disable-kvm) kvm="no"
8267ba1e619Saliguori  ;;
827b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
828b31a0277SJuan Quintela  ;;
8299195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
8309195b2c2SStefan Weil  ;;
8319195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
8329195b2c2SStefan Weil  ;;
83347e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
83447e98658SCorey Bryant  ;;
83547e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
83647e98658SCorey Bryant  ;;
837cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
838cd4ec0b4SGerd Hoffmann  ;;
839cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
840cd4ec0b4SGerd Hoffmann  ;;
841c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
842c589b249SRonnie Sahlberg  ;;
843c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
844c589b249SRonnie Sahlberg  ;;
8456542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
8466542aa9cSPeter Lieven  ;;
8476542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
8486542aa9cSPeter Lieven  ;;
84905c2a3e7Sbellard  --enable-profiler) profiler="yes"
85005c2a3e7Sbellard  ;;
85114821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
85214821030SPavel Borzenkov  ;;
853c2de5c91Smalc  --enable-cocoa)
854c2de5c91Smalc      cocoa="yes" ;
855c2de5c91Smalc      sdl="no" ;
856c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
8575b0753e0Sbellard  ;;
858cad25d69Spbrook  --disable-system) softmmu="no"
8590a8e90f4Spbrook  ;;
860cad25d69Spbrook  --enable-system) softmmu="yes"
8610a8e90f4Spbrook  ;;
8620953a80fSZachary Amsden  --disable-user)
8630953a80fSZachary Amsden      linux_user="no" ;
8640953a80fSZachary Amsden      bsd_user="no" ;
8650953a80fSZachary Amsden  ;;
8660953a80fSZachary Amsden  --enable-user) ;;
867831b7825Sths  --disable-linux-user) linux_user="no"
8680a8e90f4Spbrook  ;;
869831b7825Sths  --enable-linux-user) linux_user="yes"
870831b7825Sths  ;;
87184778508Sblueswir1  --disable-bsd-user) bsd_user="no"
87284778508Sblueswir1  ;;
87384778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
87484778508Sblueswir1  ;;
875379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
876379f6698SPaul Brook  ;;
877379f6698SPaul Brook  --disable-guest-base) guest_base="no"
878379f6698SPaul Brook  ;;
87940d6444eSAvi Kivity  --enable-pie) pie="yes"
88034005a00SKirill A. Shutemov  ;;
88140d6444eSAvi Kivity  --disable-pie) pie="no"
88234005a00SKirill A. Shutemov  ;;
883c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
884c5937220Spbrook  ;;
88585aa5189Sbellard  --enable-werror) werror="yes"
88685aa5189Sbellard  ;;
88785aa5189Sbellard  --disable-werror) werror="no"
88885aa5189Sbellard  ;;
8894d3b6f6eSbalrog  --disable-curses) curses="no"
8904d3b6f6eSbalrog  ;;
891c584a6d0SJuan Quintela  --enable-curses) curses="yes"
892c584a6d0SJuan Quintela  ;;
893769ce76dSAlexander Graf  --disable-curl) curl="no"
894769ce76dSAlexander Graf  ;;
895788c8196SJuan Quintela  --enable-curl) curl="yes"
896788c8196SJuan Quintela  ;;
8972df87df7SJuan Quintela  --disable-fdt) fdt="no"
8982df87df7SJuan Quintela  ;;
8992df87df7SJuan Quintela  --enable-fdt) fdt="yes"
9002df87df7SJuan Quintela  ;;
9015c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
9025c6c3a6cSChristoph Hellwig  ;;
9035c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
9045c6c3a6cSChristoph Hellwig  ;;
905758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
906758e8e38SVenkateswararao Jujjuri (JV)  ;;
907758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
908758e8e38SVenkateswararao Jujjuri (JV)  ;;
90977755340Sths  --disable-blobs) blobs="no"
91077755340Sths  ;;
9114a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
9124a19f1ecSpbrook  ;;
913519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
914519175a2SAlex Barcelo  ;;
91570c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
91670c60c08SStefan Hajnoczi  ;;
91770c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
91870c60c08SStefan Hajnoczi  ;;
919a25dba17SJuan Quintela  --disable-docs) docs="no"
92070ec5dc0SAnthony Liguori  ;;
921a25dba17SJuan Quintela  --enable-docs) docs="yes"
92283a3ab8bSJuan Quintela  ;;
923d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
924d5970055SMichael S. Tsirkin  ;;
925d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
926d5970055SMichael S. Tsirkin  ;;
9275e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
9285e9be92dSNicholas Bellinger  ;;
9295e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
9305e9be92dSNicholas Bellinger  ;;
931b1e5fff4SMichael Walle  --disable-glx) glx="no"
93220ff075bSMichael Walle  ;;
933b1e5fff4SMichael Walle  --enable-glx) glx="yes"
93420ff075bSMichael Walle  ;;
935f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
936f27aaf4bSChristian Brunner  ;;
937f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
938f27aaf4bSChristian Brunner  ;;
9398c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
9408c84cf11SSergei Trofimovich  ;;
9418c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
9428c84cf11SSergei Trofimovich  ;;
943111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
944111a38b0SRobert Relyea  ;;
945111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
946111a38b0SRobert Relyea  ;;
9472b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
9482b2325ffSGerd Hoffmann  ;;
9492b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
9502b2325ffSGerd Hoffmann  ;;
95169354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
95269354a83SHans de Goede  ;;
95369354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
95469354a83SHans de Goede  ;;
9551ece9905SAlon Levy  --disable-zlib-test) zlib="no"
9561ece9905SAlon Levy  ;;
957d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
958d138cee9SMichael Roth  ;;
959d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
960d138cee9SMichael Roth  ;;
961d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
962d9840e25STomoki Sekiyama  ;;
963d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
964d9840e25STomoki Sekiyama  ;;
965d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
966d9840e25STomoki Sekiyama  ;;
967d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
968d9840e25STomoki Sekiyama  ;;
969d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
970d9840e25STomoki Sekiyama  ;;
971d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
972d9840e25STomoki Sekiyama  ;;
9734b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
9744b1c11fdSDaniel P. Berrange  ;;
9754b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
9764b1c11fdSDaniel P. Berrange  ;;
977f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
978f794573eSEduardo Otubo  ;;
979f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
980f794573eSEduardo Otubo  ;;
981eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
982eb100396SBharata B Rao  ;;
983eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
984eb100396SBharata B Rao  ;;
985583f6e7bSStefan Hajnoczi  --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
986583f6e7bSStefan Hajnoczi  ;;
987583f6e7bSStefan Hajnoczi  --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
988583f6e7bSStefan Hajnoczi  ;;
989a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
990a4ccabcfSAnthony Liguori  ;;
991a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
992a4ccabcfSAnthony Liguori  ;;
9932da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
9942da776dbSMichael R. Hines  ;;
9952da776dbSMichael R. Hines  --disable-rdma) rdma="no"
9962da776dbSMichael R. Hines  ;;
997528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
998528de90aSDaniel P. Berrange  ;;
999ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1000ab214c29SStefan Berger  ;;
10010a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
10020a12ec87SRichard W.M. Jones  ;;
10030a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
10040a12ec87SRichard W.M. Jones  ;;
10054f18b782SJeff Cody  --enable-vhdx) vhdx="yes"
10064f18b782SJeff Cody  ;;
10074f18b782SJeff Cody  --disable-vhdx) vhdx="no"
10084f18b782SJeff Cody  ;;
1009*95c6bff3SBenoît Canet  --disable-quorum) quorum="no"
1010*95c6bff3SBenoît Canet  ;;
1011*95c6bff3SBenoît Canet  --enable-quorum) quorum="yes"
1012*95c6bff3SBenoît Canet  ;;
10137f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
10147f1559c6Sbalrog  ;;
10157d13299dSbellard  esac
10167d13299dSbellarddone
10177d13299dSbellard
1018f6f0b7d9SStefan Weilif ! has $python; then
1019f6f0b7d9SStefan Weil  error_exit "Python not found. Use --python=/path/to/python"
1020f6f0b7d9SStefan Weilfi
1021f6f0b7d9SStefan Weil
1022f6f0b7d9SStefan Weil# Note that if the Python conditional here evaluates True we will exit
1023f6f0b7d9SStefan Weil# with status 1 which is a shell 'false' value.
1024f6f0b7d9SStefan Weilif ! $python -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1025f6f0b7d9SStefan Weil  error_exit "Cannot use '$python', Python 2.4 or later is required." \
1026f6f0b7d9SStefan Weil      "Note that Python 3 or later is not yet supported." \
1027f6f0b7d9SStefan Weil      "Use --python=/path/to/python to specify a supported Python."
1028f6f0b7d9SStefan Weilfi
1029f6f0b7d9SStefan Weil
1030f6f0b7d9SStefan Weil# The -B switch was added in Python 2.6.
1031f6f0b7d9SStefan Weil# If it is supplied, compiled files are not written.
1032f6f0b7d9SStefan Weil# Use it for Python versions which support it.
1033f6f0b7d9SStefan Weilif $python -B -c 'import sys; sys.exit(0)' 2>/dev/null; then
1034f6f0b7d9SStefan Weil  python="$python -B"
1035f6f0b7d9SStefan Weilfi
1036f6f0b7d9SStefan Weil
103740293e58Sbellardcase "$cpu" in
1038e3608d66SRichard Henderson    ppc)
1039e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1040e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1041e3608d66SRichard Henderson           ;;
1042e3608d66SRichard Henderson    ppc64)
1043e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1044e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1045e3608d66SRichard Henderson           ;;
10469b9c37c3SRichard Henderson    sparc)
10470c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
104879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32 -mcpu=ultrasparc"
10493142255cSblueswir1           ;;
1050ed968ff1SJuan Quintela    sparc64)
10510c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
105279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
10533142255cSblueswir1           ;;
105476d83bdeSths    s390)
105579f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m31 -march=z990"
105628d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
105728d7cc49SRichard Henderson           ;;
105828d7cc49SRichard Henderson    s390x)
105979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -march=z990"
106028d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
106176d83bdeSths           ;;
106240293e58Sbellard    i386)
106379f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
10640c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
10652b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
106640293e58Sbellard           ;;
106740293e58Sbellard    x86_64)
106879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64"
10690c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
10702b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1071379f6698SPaul Brook           ;;
1072c72b26ecSRichard Henderson    x32)
1073c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1074c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1075c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1076c72b26ecSRichard Henderson           ;;
107730163d89SPeter Maydell    # No special flags required for other host CPUs
10783142255cSblueswir1esac
10793142255cSblueswir1
108079f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
108179f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
108279f3b12fSPeter Crosthwaite
108360e0df25SPeter Maydelldefault_target_list=""
108460e0df25SPeter Maydell
10856e92f823SPeter Maydellmak_wilds=""
10866e92f823SPeter Maydell
108760e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
10886e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
108960e0df25SPeter Maydellfi
109060e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
10916e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
109260e0df25SPeter Maydellfi
109360e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
10946e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
109560e0df25SPeter Maydellfi
109660e0df25SPeter Maydell
10976e92f823SPeter Maydellfor config in $mak_wilds; do
10986e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
10996e92f823SPeter Maydelldone
11006e92f823SPeter Maydell
1101af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1102af5db58eSpbrookcat << EOF
1103af5db58eSpbrook
1104af5db58eSpbrookUsage: configure [options]
1105af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1106af5db58eSpbrook
110708fb77edSStefan WeilStandard options:
110808fb77edSStefan Weil  --help                   print this message
110908fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
111008fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
111108fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
111208fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
111308fb77edSStefan Weil$(echo Available targets: $default_target_list | \
111408fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
111508fb77edSStefan Weil
111608fb77edSStefan WeilAdvanced options (experts only):
111708fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
111808fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
111908fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
112008fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
112108fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
112208fb77edSStefan Weil                           build time
112308fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
112408fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
112508fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
112608fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
112708fb77edSStefan Weil  --make=MAKE              use specified make [$make]
112808fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
112908fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
113008fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
113108fb77edSStefan Weil  --static                 enable static build [$static]
113208fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
113308fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
113408fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
113508fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
113608fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
113708fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
113808fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
113908fb77edSStefan Weil  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]
114008fb77edSStefan Weil  --enable-debug-tcg       enable TCG debugging
114108fb77edSStefan Weil  --disable-debug-tcg      disable TCG debugging (default)
114208fb77edSStefan Weil  --enable-debug-info       enable debugging information (default)
114308fb77edSStefan Weil  --disable-debug-info      disable debugging information
114408fb77edSStefan Weil  --enable-debug           enable common debug build options
114508fb77edSStefan Weil  --enable-sparse          enable sparse checker
114608fb77edSStefan Weil  --disable-sparse         disable sparse checker (default)
114708fb77edSStefan Weil  --disable-strip          disable stripping binaries
114808fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
114908fb77edSStefan Weil  --disable-sdl            disable SDL
115008fb77edSStefan Weil  --enable-sdl             enable SDL
115108fb77edSStefan Weil  --disable-gtk            disable gtk UI
115208fb77edSStefan Weil  --enable-gtk             enable gtk UI
115308fb77edSStefan Weil  --disable-virtfs         disable VirtFS
115408fb77edSStefan Weil  --enable-virtfs          enable VirtFS
115508fb77edSStefan Weil  --disable-vnc            disable VNC
115608fb77edSStefan Weil  --enable-vnc             enable VNC
115708fb77edSStefan Weil  --disable-cocoa          disable Cocoa (Mac OS X only)
115808fb77edSStefan Weil  --enable-cocoa           enable Cocoa (default on Mac OS X)
115908fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
116008fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
116108fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
116208fb77edSStefan Weil  --block-drv-rw-whitelist=L
116308fb77edSStefan Weil                           set block driver read-write whitelist
116408fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
116508fb77edSStefan Weil  --block-drv-ro-whitelist=L
116608fb77edSStefan Weil                           set block driver read-only whitelist
116708fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
116808fb77edSStefan Weil  --disable-xen            disable xen backend driver support
116908fb77edSStefan Weil  --enable-xen             enable xen backend driver support
117008fb77edSStefan Weil  --disable-xen-pci-passthrough
117108fb77edSStefan Weil  --enable-xen-pci-passthrough
117208fb77edSStefan Weil  --disable-brlapi         disable BrlAPI
117308fb77edSStefan Weil  --enable-brlapi          enable BrlAPI
117408fb77edSStefan Weil  --disable-vnc-tls        disable TLS encryption for VNC server
117508fb77edSStefan Weil  --enable-vnc-tls         enable TLS encryption for VNC server
117608fb77edSStefan Weil  --disable-vnc-sasl       disable SASL encryption for VNC server
117708fb77edSStefan Weil  --enable-vnc-sasl        enable SASL encryption for VNC server
117808fb77edSStefan Weil  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server
117908fb77edSStefan Weil  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server
118008fb77edSStefan Weil  --disable-vnc-png        disable PNG compression for VNC server (default)
118108fb77edSStefan Weil  --enable-vnc-png         enable PNG compression for VNC server
118208fb77edSStefan Weil  --disable-vnc-ws         disable Websockets support for VNC server
118308fb77edSStefan Weil  --enable-vnc-ws          enable Websockets support for VNC server
118408fb77edSStefan Weil  --disable-curses         disable curses output
118508fb77edSStefan Weil  --enable-curses          enable curses output
118608fb77edSStefan Weil  --disable-curl           disable curl connectivity
118708fb77edSStefan Weil  --enable-curl            enable curl connectivity
118808fb77edSStefan Weil  --disable-fdt            disable fdt device tree
118908fb77edSStefan Weil  --enable-fdt             enable fdt device tree
119008fb77edSStefan Weil  --disable-bluez          disable bluez stack connectivity
119108fb77edSStefan Weil  --enable-bluez           enable bluez stack connectivity
119208fb77edSStefan Weil  --disable-slirp          disable SLIRP userspace network connectivity
119308fb77edSStefan Weil  --disable-kvm            disable KVM acceleration support
119408fb77edSStefan Weil  --enable-kvm             enable KVM acceleration support
119508fb77edSStefan Weil  --disable-rdma           disable RDMA-based migration support
119608fb77edSStefan Weil  --enable-rdma            enable RDMA-based migration support
119708fb77edSStefan Weil  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
119808fb77edSStefan Weil  --enable-system          enable all system emulation targets
119908fb77edSStefan Weil  --disable-system         disable all system emulation targets
120008fb77edSStefan Weil  --enable-user            enable supported user emulation targets
120108fb77edSStefan Weil  --disable-user           disable all user emulation targets
120208fb77edSStefan Weil  --enable-linux-user      enable all linux usermode emulation targets
120308fb77edSStefan Weil  --disable-linux-user     disable all linux usermode emulation targets
120408fb77edSStefan Weil  --enable-bsd-user        enable all BSD usermode emulation targets
120508fb77edSStefan Weil  --disable-bsd-user       disable all BSD usermode emulation targets
120608fb77edSStefan Weil  --enable-guest-base      enable GUEST_BASE support for usermode
120708fb77edSStefan Weil                           emulation targets
120808fb77edSStefan Weil  --disable-guest-base     disable GUEST_BASE support
120908fb77edSStefan Weil  --enable-pie             build Position Independent Executables
121008fb77edSStefan Weil  --disable-pie            do not build Position Independent Executables
121108fb77edSStefan Weil  --fmod-lib               path to FMOD library
121208fb77edSStefan Weil  --fmod-inc               path to FMOD includes
121308fb77edSStefan Weil  --oss-lib                path to OSS library
121408fb77edSStefan Weil  --enable-uname-release=R Return R for uname -r in usermode emulation
121508fb77edSStefan Weil  --cpu=CPU                Build for host CPU [$cpu]
121608fb77edSStefan Weil  --disable-uuid           disable uuid support
121708fb77edSStefan Weil  --enable-uuid            enable uuid support
121808fb77edSStefan Weil  --disable-vde            disable support for vde network
121908fb77edSStefan Weil  --enable-vde             enable support for vde network
122008fb77edSStefan Weil  --disable-netmap         disable support for netmap network
122108fb77edSStefan Weil  --enable-netmap          enable support for netmap network
122208fb77edSStefan Weil  --disable-linux-aio      disable Linux AIO support
122308fb77edSStefan Weil  --enable-linux-aio       enable Linux AIO support
122408fb77edSStefan Weil  --disable-cap-ng         disable libcap-ng support
122508fb77edSStefan Weil  --enable-cap-ng          enable libcap-ng support
122608fb77edSStefan Weil  --disable-attr           disables attr and xattr support
122708fb77edSStefan Weil  --enable-attr            enable attr and xattr support
122808fb77edSStefan Weil  --disable-blobs          disable installing provided firmware blobs
122908fb77edSStefan Weil  --enable-docs            enable documentation build
123008fb77edSStefan Weil  --disable-docs           disable documentation build
123108fb77edSStefan Weil  --disable-vhost-net      disable vhost-net acceleration support
123208fb77edSStefan Weil  --enable-vhost-net       enable vhost-net acceleration support
123308fb77edSStefan Weil  --enable-trace-backend=B Set trace backend
123408fb77edSStefan Weil                           Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
123508fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
123608fb77edSStefan Weil                           Default:trace-<pid>
123708fb77edSStefan Weil  --disable-spice          disable spice
123808fb77edSStefan Weil  --enable-spice           enable spice
123908fb77edSStefan Weil  --enable-rbd             enable building the rados block device (rbd)
124008fb77edSStefan Weil  --disable-libiscsi       disable iscsi support
124108fb77edSStefan Weil  --enable-libiscsi        enable iscsi support
12426542aa9cSPeter Lieven  --disable-libnfs         disable nfs support
12436542aa9cSPeter Lieven  --enable-libnfs          enable nfs support
124408fb77edSStefan Weil  --disable-smartcard-nss  disable smartcard nss support
124508fb77edSStefan Weil  --enable-smartcard-nss   enable smartcard nss support
124608fb77edSStefan Weil  --disable-libusb         disable libusb (for usb passthrough)
124708fb77edSStefan Weil  --enable-libusb          enable libusb (for usb passthrough)
124808fb77edSStefan Weil  --disable-usb-redir      disable usb network redirection support
124908fb77edSStefan Weil  --enable-usb-redir       enable usb network redirection support
125008fb77edSStefan Weil  --disable-guest-agent    disable building of the QEMU Guest Agent
125108fb77edSStefan Weil  --enable-guest-agent     enable building of the QEMU Guest Agent
125208fb77edSStefan Weil  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
125308fb77edSStefan Weil  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
125408fb77edSStefan Weil  --disable-seccomp        disable seccomp support
125508fb77edSStefan Weil  --enable-seccomp         enables seccomp support
125608fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
125708fb77edSStefan Weil                           gthread, ucontext, sigaltstack, windows
125808fb77edSStefan Weil  --disable-coroutine-pool disable coroutine freelist (worse performance)
125908fb77edSStefan Weil  --enable-coroutine-pool  enable coroutine freelist (better performance)
126008fb77edSStefan Weil  --enable-glusterfs       enable GlusterFS backend
126108fb77edSStefan Weil  --disable-glusterfs      disable GlusterFS backend
126208fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
126308fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
126408fb77edSStefan Weil  --enable-tpm             enable TPM support
126508fb77edSStefan Weil  --disable-libssh2        disable ssh block device support
126608fb77edSStefan Weil  --enable-libssh2         enable ssh block device support
126708fb77edSStefan Weil  --disable-vhdx           disables support for the Microsoft VHDX image format
126808fb77edSStefan Weil  --enable-vhdx            enable support for the Microsoft VHDX image format
1269*95c6bff3SBenoît Canet  --disable-quorum         disable quorum block filter support
1270*95c6bff3SBenoît Canet  --enable-quorum          enable quorum block filter support
127108fb77edSStefan Weil
127208fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1273af5db58eSpbrookEOF
1274af5db58eSpbrookexit 1
1275af5db58eSpbrookfi
1276af5db58eSpbrook
1277359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1278359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1279359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1280359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1281359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1282359bc95dSPeter Maydell        ARCH=tci
1283359bc95dSPeter Maydell    else
128476ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1285359bc95dSPeter Maydell    fi
1286359bc95dSPeter Maydellfi
1287359bc95dSPeter Maydell
12888d05095cSPaolo Bonzini# check that the C compiler works.
12898d05095cSPaolo Bonzinicat > $TMPC <<EOF
129075cafad7SStefan Weilint main(void) { return 0; }
12918d05095cSPaolo BonziniEOF
12928d05095cSPaolo Bonzini
12938d05095cSPaolo Bonziniif compile_object ; then
12948d05095cSPaolo Bonzini  : C compiler works ok
12958d05095cSPaolo Bonzinielse
129676ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
12978d05095cSPaolo Bonzinifi
12988d05095cSPaolo Bonzini
1299417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1300417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1301417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1302417c9d72SAlexander Graf
1303417c9d72SAlexander Grafif test -z "$werror" ; then
13046c8fec83SAndreas Färber    if test -d "$source_path/.git" -a \
1305417c9d72SAlexander Graf        "$linux" = "yes" ; then
1306417c9d72SAlexander Graf        werror="yes"
1307417c9d72SAlexander Graf    else
1308417c9d72SAlexander Graf        werror="no"
1309417c9d72SAlexander Graf    fi
1310417c9d72SAlexander Graffi
1311417c9d72SAlexander Graf
13128d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
13138d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
13148d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
131537746c5eSMarc-André Lureaugcc_flags="-Wendif-labels $gcc_flags"
1316c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
131771429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
13186ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
13196ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
13206ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
13216ca026cbSPeter Maydell# so it's too error prone.
13228d05095cSPaolo Bonzinicat > $TMPC << EOF
13238d05095cSPaolo Bonziniint main(void) { return 0; }
13248d05095cSPaolo BonziniEOF
13258d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1326a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1327a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1328a1d29d6cSPeter Maydell    # warning options).
1329a1d29d6cSPeter Maydell    optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1330a1d29d6cSPeter Maydell    if compile_prog "-Werror $optflag" "" ; then
13318d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
13328d05095cSPaolo Bonzini    fi
13338d05095cSPaolo Bonzinidone
13348d05095cSPaolo Bonzini
133537746c5eSMarc-André Lureauif compile_prog "-Werror -fstack-protector-all" "" ; then
133637746c5eSMarc-André Lureau    QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
133737746c5eSMarc-André Lureau    LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
133837746c5eSMarc-André Lureaufi
133937746c5eSMarc-André Lureau
1340cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1341cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1342cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1343cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1344cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1345cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1346cbdd1999SPaolo Bonziniint main(void) { return 0; }
1347cbdd1999SPaolo Bonzini#else
1348cbdd1999SPaolo Bonzini#error No bug in this compiler.
1349cbdd1999SPaolo Bonzini#endif
1350cbdd1999SPaolo BonziniEOF
1351cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1352cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1353cbdd1999SPaolo Bonzinifi
1354cbdd1999SPaolo Bonzini
135540d6444eSAvi Kivityif test "$static" = "yes" ; then
135640d6444eSAvi Kivity  if test "$pie" = "yes" ; then
135776ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
135840d6444eSAvi Kivity  else
135940d6444eSAvi Kivity    pie="no"
136040d6444eSAvi Kivity  fi
136140d6444eSAvi Kivityfi
136240d6444eSAvi Kivity
136340d6444eSAvi Kivityif test "$pie" = ""; then
136440d6444eSAvi Kivity  case "$cpu-$targetos" in
1365c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
136640d6444eSAvi Kivity      ;;
136740d6444eSAvi Kivity    *)
136840d6444eSAvi Kivity      pie="no"
136940d6444eSAvi Kivity      ;;
137040d6444eSAvi Kivity  esac
137140d6444eSAvi Kivityfi
137240d6444eSAvi Kivity
137340d6444eSAvi Kivityif test "$pie" != "no" ; then
137440d6444eSAvi Kivity  cat > $TMPC << EOF
137521d4a791SAvi Kivity
137621d4a791SAvi Kivity#ifdef __linux__
137721d4a791SAvi Kivity#  define THREAD __thread
137821d4a791SAvi Kivity#else
137921d4a791SAvi Kivity#  define THREAD
138021d4a791SAvi Kivity#endif
138121d4a791SAvi Kivity
138221d4a791SAvi Kivitystatic THREAD int tls_var;
138321d4a791SAvi Kivity
138421d4a791SAvi Kivityint main(void) { return tls_var; }
138521d4a791SAvi Kivity
138640d6444eSAvi KivityEOF
138740d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
138840d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
138940d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
139040d6444eSAvi Kivity    pie="yes"
139140d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
139240d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
139340d6444eSAvi Kivity    fi
139440d6444eSAvi Kivity  else
139540d6444eSAvi Kivity    if test "$pie" = "yes"; then
139676ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
139740d6444eSAvi Kivity    else
139840d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
139940d6444eSAvi Kivity      pie="no"
140040d6444eSAvi Kivity    fi
140140d6444eSAvi Kivity  fi
140246eef33bSBrad
140346eef33bSBrad  if compile_prog "-fno-pie" "-nopie"; then
140446eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
140546eef33bSBrad    LDFLAGS_NOPIE="-nopie"
140646eef33bSBrad  fi
140740d6444eSAvi Kivityfi
140840d6444eSAvi Kivity
140909dada40SPaolo Bonzini##########################################
141009dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
141109dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
141209dada40SPaolo Bonzini# specification is necessary
141309dada40SPaolo Bonzini
141409dada40SPaolo Bonziniif test "$cpu" = "i386"; then
141509dada40SPaolo Bonzini  cat > $TMPC << EOF
141609dada40SPaolo Bonzinistatic int sfaa(int *ptr)
141709dada40SPaolo Bonzini{
141809dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
141909dada40SPaolo Bonzini}
142009dada40SPaolo Bonzini
142109dada40SPaolo Bonziniint main(void)
142209dada40SPaolo Bonzini{
142309dada40SPaolo Bonzini  int val = 42;
14241405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
142509dada40SPaolo Bonzini  sfaa(&val);
142609dada40SPaolo Bonzini  return val;
142709dada40SPaolo Bonzini}
142809dada40SPaolo BonziniEOF
142909dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
143009dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
143109dada40SPaolo Bonzini  fi
143209dada40SPaolo Bonzinifi
143309dada40SPaolo Bonzini
143409dada40SPaolo Bonzini#########################################
1435ec530c81Sbellard# Solaris specific configure tool chain decisions
143609dada40SPaolo Bonzini
1437ec530c81Sbellardif test "$solaris" = "yes" ; then
14386792aa11SLoïc Minier  if has $install; then
14396792aa11SLoïc Minier    :
14406792aa11SLoïc Minier  else
144176ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
144276ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
144376ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1444ec530c81Sbellard  fi
14456792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
144676ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
144776ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
144876ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1449ec530c81Sbellard  fi
14506792aa11SLoïc Minier  if has ar; then
14516792aa11SLoïc Minier    :
14526792aa11SLoïc Minier  else
1453ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
145476ad07a4SPeter Maydell      error_exit "No path includes ar" \
145576ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1456ec530c81Sbellard    fi
145776ad07a4SPeter Maydell    error_exit "No path includes ar"
1458ec530c81Sbellard  fi
1459ec530c81Sbellardfi
1460ec530c81Sbellard
1461afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1462121afa9eSAnthony Liguori    target_list="$default_target_list"
1463121afa9eSAnthony Liguorielse
1464121afa9eSAnthony Liguori    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
14655327cf48Sbellardfi
146625b48338SPeter Maydell
146725b48338SPeter Maydell# Check that we recognised the target name; this allows a more
146825b48338SPeter Maydell# friendly error message than if we let it fall through.
146925b48338SPeter Maydellfor target in $target_list; do
147025b48338SPeter Maydell    case " $default_target_list " in
147125b48338SPeter Maydell        *" $target "*)
147225b48338SPeter Maydell            ;;
147325b48338SPeter Maydell        *)
147425b48338SPeter Maydell            error_exit "Unknown target name '$target'"
147525b48338SPeter Maydell            ;;
147625b48338SPeter Maydell    esac
147725b48338SPeter Maydelldone
147825b48338SPeter Maydell
1479f55fe278SPaolo Bonzini# see if system emulation was really requested
1480f55fe278SPaolo Bonzinicase " $target_list " in
1481f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1482f55fe278SPaolo Bonzini  ;;
1483f55fe278SPaolo Bonzini  *) softmmu=no
1484f55fe278SPaolo Bonzini  ;;
1485f55fe278SPaolo Bonziniesac
14865327cf48Sbellard
1487249247c9SJuan Quintelafeature_not_found() {
1488249247c9SJuan Quintela  feature=$1
148921684af0SStewart Smith  remedy=$2
1490249247c9SJuan Quintela
149176ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
149221684af0SStewart Smith      "configure was not able to find it." \
149321684af0SStewart Smith      "$remedy"
1494249247c9SJuan Quintela}
1495249247c9SJuan Quintela
14967d13299dSbellard# ---
14977d13299dSbellard# big/little endian test
14987d13299dSbellardcat > $TMPC << EOF
149961cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
150061cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
150161cc919fSMike Frysingerextern int foo(short *, short *);
150261cc919fSMike Frysingerint main(int argc, char *argv[]) {
150361cc919fSMike Frysinger    return foo(big_endian, little_endian);
15047d13299dSbellard}
15057d13299dSbellardEOF
15067d13299dSbellard
150761cc919fSMike Frysingerif compile_object ; then
150861cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
150961cc919fSMike Frysinger        bigendian="yes"
151061cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
151161cc919fSMike Frysinger        bigendian="no"
15127d13299dSbellard    else
15137d13299dSbellard        echo big/little test failed
15147d13299dSbellard    fi
15157d13299dSbellardelse
151661cc919fSMike Frysinger    echo big/little test failed
15177d13299dSbellardfi
15187d13299dSbellard
1519b0a47e79SJuan Quintela##########################################
1520779ab5e3SStefan Weil# pkg-config probe
1521779ab5e3SStefan Weil
1522779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
152376ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1524779ab5e3SStefan Weilfi
1525779ab5e3SStefan Weil
1526779ab5e3SStefan Weil##########################################
1527b0a47e79SJuan Quintela# NPTL probe
1528b0a47e79SJuan Quintela
152924cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1530bd0c5661Spbrook  cat > $TMPC <<EOF
1531bd0c5661Spbrook#include <sched.h>
153230813ceaSpbrook#include <linux/futex.h>
1533182eacc0SStefan Weilint main(void) {
1534bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1535bd0c5661Spbrook#error bork
1536bd0c5661Spbrook#endif
1537182eacc0SStefan Weil  return 0;
1538bd0c5661Spbrook}
1539bd0c5661SpbrookEOF
154024cb36a6SPeter Maydell  if ! compile_object ; then
154121684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
1542b0a47e79SJuan Quintela  fi
1543bd0c5661Spbrookfi
1544bd0c5661Spbrook
154511d9f695Sbellard##########################################
1546ac62922eSbalrog# zlib check
1547ac62922eSbalrog
15481ece9905SAlon Levyif test "$zlib" != "no" ; then
1549ac62922eSbalrog    cat > $TMPC << EOF
1550ac62922eSbalrog#include <zlib.h>
1551ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1552ac62922eSbalrogEOF
155352166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1554ac62922eSbalrog        :
1555ac62922eSbalrog    else
155676ad07a4SPeter Maydell        error_exit "zlib check failed" \
155776ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1558ac62922eSbalrog    fi
15591ece9905SAlon Levyfi
1560f544a488SPaolo Bonzinilibs_softmmu="$libs_softmmu -lz"
1561ac62922eSbalrog
1562ac62922eSbalrog##########################################
1563f794573eSEduardo Otubo# libseccomp check
1564f794573eSEduardo Otubo
1565f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
156665d5d3f9SStefan Weil    if $pkg_config --atleast-version=2.1.0 libseccomp; then
1567b4451996SMichael Tokarev        libs_softmmu="$libs_softmmu `$pkg_config --libs libseccomp`"
1568372e47e9SAndreas Färber        QEMU_CFLAGS="$QEMU_CFLAGS `$pkg_config --cflags libseccomp`"
1569f794573eSEduardo Otubo	seccomp="yes"
1570f794573eSEduardo Otubo    else
1571f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
157221684af0SStewart Smith            feature_not_found "libseccomp" "Install libseccomp devel >= 2.1.0"
1573f794573eSEduardo Otubo	fi
1574e84d5956SYann E. MORIN	seccomp="no"
1575f794573eSEduardo Otubo    fi
1576f794573eSEduardo Otubofi
1577f794573eSEduardo Otubo##########################################
1578e37630caSaliguori# xen probe
1579e37630caSaliguori
1580fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1581b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1582d5b93ddfSAnthony PERARD
158350ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
158450ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
158550ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
158650ced5b3SStefan Weil
158750ced5b3SStefan Weil  # Xen (any)
158850ced5b3SStefan Weil  cat > $TMPC <<EOF
158950ced5b3SStefan Weil#include <xenctrl.h>
159050ced5b3SStefan Weilint main(void) {
159150ced5b3SStefan Weil  return 0;
159250ced5b3SStefan Weil}
159350ced5b3SStefan WeilEOF
159450ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
159550ced5b3SStefan Weil    # Xen not found
159650ced5b3SStefan Weil    if test "$xen" = "yes" ; then
159721684af0SStewart Smith      feature_not_found "xen" "Install xen devel"
159850ced5b3SStefan Weil    fi
159950ced5b3SStefan Weil    xen=no
160050ced5b3SStefan Weil
1601d5b93ddfSAnthony PERARD  # Xen unstable
160269deef08SPeter Maydell  elif
160369deef08SPeter Maydell      cat > $TMPC <<EOF &&
1604e37630caSaliguori#include <xenctrl.h>
1605e108a3c1SAnthony PERARD#include <xenstore.h>
1606d5b93ddfSAnthony PERARD#include <stdint.h>
1607d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1608d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1609d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1610d5b93ddfSAnthony PERARD#endif
1611d5b93ddfSAnthony PERARDint main(void) {
1612d5b93ddfSAnthony PERARD  xc_interface *xc;
1613d5b93ddfSAnthony PERARD  xs_daemon_open();
1614d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1615d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1616d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1617b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
16188688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
16198688e065SStefano Stabellini  return 0;
16208688e065SStefano Stabellini}
16218688e065SStefano StabelliniEOF
16228688e065SStefano Stabellini      compile_prog "" "$xen_libs"
162369deef08SPeter Maydell    then
16248688e065SStefano Stabellini    xen_ctrl_version=420
16258688e065SStefano Stabellini    xen=yes
16268688e065SStefano Stabellini
162769deef08SPeter Maydell  elif
162869deef08SPeter Maydell      cat > $TMPC <<EOF &&
16298688e065SStefano Stabellini#include <xenctrl.h>
16308688e065SStefano Stabellini#include <xs.h>
16318688e065SStefano Stabellini#include <stdint.h>
16328688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
16338688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
16348688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
16358688e065SStefano Stabellini#endif
16368688e065SStefano Stabelliniint main(void) {
16378688e065SStefano Stabellini  xs_daemon_open();
16389b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
16398688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
16408688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
16418688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1642d5b93ddfSAnthony PERARD  return 0;
1643d5b93ddfSAnthony PERARD}
1644e37630caSaliguoriEOF
164550ced5b3SStefan Weil      compile_prog "" "$xen_libs"
164669deef08SPeter Maydell    then
1647d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1648fc321b4bSJuan Quintela    xen=yes
1649d5b93ddfSAnthony PERARD
1650d5b93ddfSAnthony PERARD  # Xen 4.0.0
165169deef08SPeter Maydell  elif
165269deef08SPeter Maydell      cat > $TMPC <<EOF &&
1653d5b93ddfSAnthony PERARD#include <xenctrl.h>
1654d5b93ddfSAnthony PERARD#include <xs.h>
1655d5b93ddfSAnthony PERARD#include <stdint.h>
1656d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1657d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1658d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1659d5b93ddfSAnthony PERARD#endif
1660d5b93ddfSAnthony PERARDint main(void) {
1661b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1662b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1663b87de24eSAnthony PERARD  };
1664d5b93ddfSAnthony PERARD  xs_daemon_open();
1665d5b93ddfSAnthony PERARD  xc_interface_open();
1666d5b93ddfSAnthony PERARD  xc_gnttab_open();
1667d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1668b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1669d5b93ddfSAnthony PERARD  return 0;
1670d5b93ddfSAnthony PERARD}
1671d5b93ddfSAnthony PERARDEOF
1672d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
167369deef08SPeter Maydell    then
1674d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1675d5b93ddfSAnthony PERARD    xen=yes
1676d5b93ddfSAnthony PERARD
1677b87de24eSAnthony PERARD  # Xen 3.4.0
167869deef08SPeter Maydell  elif
167969deef08SPeter Maydell      cat > $TMPC <<EOF &&
1680b87de24eSAnthony PERARD#include <xenctrl.h>
1681b87de24eSAnthony PERARD#include <xs.h>
1682b87de24eSAnthony PERARDint main(void) {
1683b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1684b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1685b87de24eSAnthony PERARD  };
1686b87de24eSAnthony PERARD  xs_daemon_open();
1687b87de24eSAnthony PERARD  xc_interface_open();
1688b87de24eSAnthony PERARD  xc_gnttab_open();
1689b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1690b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1691b87de24eSAnthony PERARD  return 0;
1692b87de24eSAnthony PERARD}
1693b87de24eSAnthony PERARDEOF
1694b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
169569deef08SPeter Maydell    then
1696b87de24eSAnthony PERARD    xen_ctrl_version=340
1697b87de24eSAnthony PERARD    xen=yes
1698b87de24eSAnthony PERARD
1699b87de24eSAnthony PERARD  # Xen 3.3.0
170069deef08SPeter Maydell  elif
170169deef08SPeter Maydell      cat > $TMPC <<EOF &&
1702d5b93ddfSAnthony PERARD#include <xenctrl.h>
1703d5b93ddfSAnthony PERARD#include <xs.h>
1704d5b93ddfSAnthony PERARDint main(void) {
1705d5b93ddfSAnthony PERARD  xs_daemon_open();
1706d5b93ddfSAnthony PERARD  xc_interface_open();
1707d5b93ddfSAnthony PERARD  xc_gnttab_open();
1708d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1709d5b93ddfSAnthony PERARD  return 0;
1710d5b93ddfSAnthony PERARD}
1711d5b93ddfSAnthony PERARDEOF
1712d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
171369deef08SPeter Maydell    then
1714d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1715d5b93ddfSAnthony PERARD    xen=yes
1716d5b93ddfSAnthony PERARD
171750ced5b3SStefan Weil  # Xen version unsupported
1718e37630caSaliguori  else
1719fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
172021684af0SStewart Smith      feature_not_found "xen (unsupported version)" "Install supported xen (e.g. 4.0, 3.4, 3.3)"
1721fc321b4bSJuan Quintela    fi
1722fc321b4bSJuan Quintela    xen=no
1723e37630caSaliguori  fi
1724d5b93ddfSAnthony PERARD
1725d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1726d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1727d5b93ddfSAnthony PERARD  fi
1728e37630caSaliguorifi
1729e37630caSaliguori
1730eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1731eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1732eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1733eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1734eb6fda0fSAnthony PERARD  else
1735eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1736eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
173776ad07a4SPeter Maydell        error_exit "User requested feature Xen PCI Passthrough" \
173876ad07a4SPeter Maydell            "This feature does not work with Xen 3.3"
1739eb6fda0fSAnthony PERARD      fi
174076ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
174176ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
1742eb6fda0fSAnthony PERARD    fi
1743eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1744eb6fda0fSAnthony PERARD  fi
1745eb6fda0fSAnthony PERARDfi
1746eb6fda0fSAnthony PERARD
1747e37630caSaliguori##########################################
174844dc0ca3SAlon Levy# libtool probe
174944dc0ca3SAlon Levy
17503f534581SBradif ! has $libtool; then
175144dc0ca3SAlon Levy    libtool=
175244dc0ca3SAlon Levyfi
175344dc0ca3SAlon Levy
17548e515b12SPeter Maydell# MacOSX ships with a libtool which isn't the GNU one; weed this
17558e515b12SPeter Maydell# out by checking whether libtool supports the --version switch
17568e515b12SPeter Maydellif test -n "$libtool"; then
17578e515b12SPeter Maydell  if ! "$libtool" --version >/dev/null 2>&1; then
17588e515b12SPeter Maydell    libtool=
17598e515b12SPeter Maydell  fi
17608e515b12SPeter Maydellfi
17618e515b12SPeter Maydell
176244dc0ca3SAlon Levy##########################################
1763dfffc653SJuan Quintela# Sparse probe
1764dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
17650dba6195SLoïc Minier  if has cgcc; then
1766dfffc653SJuan Quintela    sparse=yes
1767dfffc653SJuan Quintela  else
1768dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
176921684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
1770dfffc653SJuan Quintela    fi
1771dfffc653SJuan Quintela    sparse=no
1772dfffc653SJuan Quintela  fi
1773dfffc653SJuan Quintelafi
1774dfffc653SJuan Quintela
1775dfffc653SJuan Quintela##########################################
1776a4ccabcfSAnthony Liguori# GTK probe
1777a4ccabcfSAnthony Liguori
1778a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
1779528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
1780528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
1781528de90aSDaniel P. Berrange      gtkversion="3.0.0"
1782528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
1783528de90aSDaniel P. Berrange      vteversion="0.32.0"
1784528de90aSDaniel P. Berrange    else
1785528de90aSDaniel P. Berrange      gtkversion="2.18.0"
1786528de90aSDaniel P. Berrange      vtepackage="vte"
1787528de90aSDaniel P. Berrange      vteversion="0.24.0"
1788528de90aSDaniel P. Berrange    fi
17890d185e63SPeter Maydell    if ! $pkg_config --exists "$gtkpackage >= $gtkversion"; then
17900d185e63SPeter Maydell        if test "$gtk" = "yes" ; then
179121684af0SStewart Smith            feature_not_found "gtk" "Install gtk2 or gtk3 (requires --with-gtkabi=3.0 option to configure) devel"
17920d185e63SPeter Maydell        fi
17930d185e63SPeter Maydell        gtk="no"
17940d185e63SPeter Maydell    elif ! $pkg_config --exists "$vtepackage >= $vteversion"; then
17950d185e63SPeter Maydell        if test "$gtk" = "yes" ; then
17960d185e63SPeter Maydell            error_exit "libvte not found (required for gtk support)"
17970d185e63SPeter Maydell        fi
17980d185e63SPeter Maydell        gtk="no"
17990d185e63SPeter Maydell    else
1800ca871ec8SStefan Weil	gtk_cflags=`$pkg_config --cflags $gtkpackage`
1801ca871ec8SStefan Weil	gtk_libs=`$pkg_config --libs $gtkpackage`
1802ca871ec8SStefan Weil	vte_cflags=`$pkg_config --cflags $vtepackage`
1803ca871ec8SStefan Weil	vte_libs=`$pkg_config --libs $vtepackage`
1804a4ccabcfSAnthony Liguori	libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
1805a4ccabcfSAnthony Liguori	gtk="yes"
1806a4ccabcfSAnthony Liguori    fi
1807a4ccabcfSAnthony Liguorifi
1808a4ccabcfSAnthony Liguori
1809a4ccabcfSAnthony Liguori##########################################
181011d9f695Sbellard# SDL probe
181111d9f695Sbellard
18123ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
18133ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
18143ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
18153ec87ffeSPaolo Bonzini  sdl_config=sdl-config
18163ec87ffeSPaolo Bonzinifi
18173ec87ffeSPaolo Bonzini
181865d5d3f9SStefan Weilif $pkg_config sdl --exists; then
1819a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1820fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
18213ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
18223ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
18239316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1824a0dfd8a4SLoïc Minierelse
1825a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
182621684af0SStewart Smith    feature_not_found "sdl" "Install SDL devel"
1827a0dfd8a4SLoïc Minier  fi
1828a0dfd8a4SLoïc Minier  sdl=no
18299316f803SPaolo Bonzinifi
183029e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
18313ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
18323ec87ffeSPaolo Bonzinifi
183311d9f695Sbellard
18349316f803SPaolo Bonzinisdl_too_old=no
1835c4198157SJuan Quintelaif test "$sdl" != "no" ; then
183611d9f695Sbellard  cat > $TMPC << EOF
183711d9f695Sbellard#include <SDL.h>
183811d9f695Sbellard#undef main /* We don't want SDL to override our main() */
183911d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
184011d9f695SbellardEOF
18419316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
184274f42e18STeLeMan  if test "$static" = "yes" ; then
184374f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
184474f42e18STeLeMan  else
18459316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
184674f42e18STeLeMan  fi
184752166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
184811d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
184911d9f695Sbellard      sdl_too_old=yes
185011d9f695Sbellard    else
1851fd677642Sths      if test "$cocoa" = "no" ; then
185211d9f695Sbellard        sdl=yes
185311d9f695Sbellard      fi
1854fd677642Sths    fi
18557c1f25b4Sbellard
185667c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
18571ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
185867c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1859f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1860f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
186111d9f695Sbellard      fi
186252166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
18631ac88f28SJuan Quintela	:
18641ac88f28SJuan Quintela      else
18651ac88f28SJuan Quintela        sdl=no
18667c1f25b4Sbellard      fi
18677c1f25b4Sbellard    fi # static link
1868c4198157SJuan Quintela  else # sdl not found
1869c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
187021684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
1871c4198157SJuan Quintela    fi
1872c4198157SJuan Quintela    sdl=no
18737c1f25b4Sbellard  fi # sdl compile test
1874fd677642Sthsfi
187511d9f695Sbellard
18765368a422Saliguoriif test "$sdl" = "yes" ; then
18775368a422Saliguori  cat > $TMPC <<EOF
18785368a422Saliguori#include <SDL.h>
18795368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
18805368a422Saliguori#include <X11/XKBlib.h>
18815368a422Saliguori#else
18825368a422Saliguori#error No x11 support
18835368a422Saliguori#endif
18845368a422Saliguoriint main(void) { return 0; }
18855368a422SaliguoriEOF
188652166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1887681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
18885368a422Saliguori  fi
18890705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
18905368a422Saliguorifi
18915368a422Saliguori
18928f28f3fbSths##########################################
18932da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
18942da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
18952da776dbSMichael R. Hines  cat > $TMPC <<EOF
18962da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
18972da776dbSMichael R. Hinesint main(void) { return 0; }
18982da776dbSMichael R. HinesEOF
18992da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
19002da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
19012da776dbSMichael R. Hines    rdma="yes"
19022da776dbSMichael R. Hines    libs_softmmu="$libs_softmmu $rdma_libs"
19032da776dbSMichael R. Hines  else
19042da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
19052da776dbSMichael R. Hines        error_exit \
19062da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
19072da776dbSMichael R. Hines            " Your options:" \
19082da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
19092da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
19102da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
19112da776dbSMichael R. Hines    fi
19122da776dbSMichael R. Hines    rdma="no"
19132da776dbSMichael R. Hines  fi
19142da776dbSMichael R. Hinesfi
19152da776dbSMichael R. Hines
19162da776dbSMichael R. Hines##########################################
19177536ee4bSTim Hardeck# VNC TLS/WS detection
19187536ee4bSTim Hardeckif test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then
1919ae6b5e5aSaliguori  cat > $TMPC <<EOF
1920ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1921ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1922ae6b5e5aSaliguoriEOF
1923a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1924a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
192552166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
19267536ee4bSTim Hardeck    if test "$vnc_tls" != "no" ; then
19271be10ad2SJuan Quintela      vnc_tls=yes
19287536ee4bSTim Hardeck    fi
19297536ee4bSTim Hardeck    if test "$vnc_ws" != "no" ; then
19307536ee4bSTim Hardeck      vnc_ws=yes
19317536ee4bSTim Hardeck    fi
1932a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1933ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
1934ae6b5e5aSaliguori  else
19351be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
193621684af0SStewart Smith      feature_not_found "vnc-tls" "Install gnutls devel"
19371be10ad2SJuan Quintela    fi
19387536ee4bSTim Hardeck    if test "$vnc_ws" = "yes" ; then
193921684af0SStewart Smith      feature_not_found "vnc-ws" "Install gnutls devel"
19407536ee4bSTim Hardeck    fi
19411be10ad2SJuan Quintela    vnc_tls=no
19427536ee4bSTim Hardeck    vnc_ws=no
19438d5d2d4cSths  fi
19448d5d2d4cSthsfi
19458d5d2d4cSths
19468d5d2d4cSths##########################################
1947*95c6bff3SBenoît Canet# Quorum probe (check for gnutls)
1948*95c6bff3SBenoît Canetif test "$quorum" != "no" ; then
1949*95c6bff3SBenoît Canetcat > $TMPC <<EOF
1950*95c6bff3SBenoît Canet#include <gnutls/gnutls.h>
1951*95c6bff3SBenoît Canet#include <gnutls/crypto.h>
1952*95c6bff3SBenoît Canetint main(void) {char data[4096], digest[32];
1953*95c6bff3SBenoît Canetgnutls_hash_fast(GNUTLS_DIG_SHA256, data, 4096, digest);
1954*95c6bff3SBenoît Canetreturn 0;
1955*95c6bff3SBenoît Canet}
1956*95c6bff3SBenoît CanetEOF
1957*95c6bff3SBenoît Canetquorum_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1958*95c6bff3SBenoît Canetquorum_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
1959*95c6bff3SBenoît Canetif compile_prog "$quorum_tls_cflags" "$quorum_tls_libs" ; then
1960*95c6bff3SBenoît Canet  qcow_tls=yes
1961*95c6bff3SBenoît Canet  libs_softmmu="$quorum_tls_libs $libs_softmmu"
1962*95c6bff3SBenoît Canet  libs_tools="$quorum_tls_libs $libs_softmmu"
1963*95c6bff3SBenoît Canet  QEMU_CFLAGS="$QEMU_CFLAGS $quorum_tls_cflags"
1964*95c6bff3SBenoît Canetelse
1965*95c6bff3SBenoît Canet  echo "gnutls > 2.10.0 required to compile Quorum"
1966*95c6bff3SBenoît Canet  exit 1
1967*95c6bff3SBenoît Canetfi
1968*95c6bff3SBenoît Canetfi
1969*95c6bff3SBenoît Canet
1970*95c6bff3SBenoît Canet##########################################
19712f9606b3Saliguori# VNC SASL detection
1972821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
19732f9606b3Saliguori  cat > $TMPC <<EOF
19742f9606b3Saliguori#include <sasl/sasl.h>
19752f9606b3Saliguori#include <stdio.h>
19762f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
19772f9606b3SaliguoriEOF
19782f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
19792f9606b3Saliguori  vnc_sasl_cflags=""
19802f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
198152166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1982ea784e3bSJuan Quintela    vnc_sasl=yes
1983fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1984ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
19852f9606b3Saliguori  else
1986ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
198721684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
1988ea784e3bSJuan Quintela    fi
1989ea784e3bSJuan Quintela    vnc_sasl=no
19902f9606b3Saliguori  fi
19912f9606b3Saliguorifi
19922f9606b3Saliguori
19932f9606b3Saliguori##########################################
19942f6f5c7aSCorentin Chary# VNC JPEG detection
1995821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
19962f6f5c7aSCorentin Charycat > $TMPC <<EOF
19972f6f5c7aSCorentin Chary#include <stdio.h>
19982f6f5c7aSCorentin Chary#include <jpeglib.h>
19992f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
20002f6f5c7aSCorentin CharyEOF
20012f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
20022f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
20032f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
20042f6f5c7aSCorentin Chary    vnc_jpeg=yes
20052f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2006ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
20072f6f5c7aSCorentin Chary  else
20082f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
200921684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
20102f6f5c7aSCorentin Chary    fi
20112f6f5c7aSCorentin Chary    vnc_jpeg=no
20122f6f5c7aSCorentin Chary  fi
20132f6f5c7aSCorentin Charyfi
20142f6f5c7aSCorentin Chary
20152f6f5c7aSCorentin Chary##########################################
2016efe556adSCorentin Chary# VNC PNG detection
2017821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2018efe556adSCorentin Charycat > $TMPC <<EOF
2019efe556adSCorentin Chary//#include <stdio.h>
2020efe556adSCorentin Chary#include <png.h>
2021832ce9c2SScott Wood#include <stddef.h>
2022efe556adSCorentin Charyint main(void) {
2023efe556adSCorentin Chary    png_structp png_ptr;
2024efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
20257edc3fedSPeter Maydell    return png_ptr != 0;
2026efe556adSCorentin Chary}
2027efe556adSCorentin CharyEOF
202865d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
2029ca871ec8SStefan Weil    vnc_png_cflags=`$pkg_config libpng --cflags`
2030ca871ec8SStefan Weil    vnc_png_libs=`$pkg_config libpng --libs`
20319af8025eSBrad  else
2032efe556adSCorentin Chary    vnc_png_cflags=""
2033efe556adSCorentin Chary    vnc_png_libs="-lpng"
20349af8025eSBrad  fi
2035efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2036efe556adSCorentin Chary    vnc_png=yes
2037efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
20389af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2039efe556adSCorentin Chary  else
2040efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
204121684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2042efe556adSCorentin Chary    fi
2043efe556adSCorentin Chary    vnc_png=no
2044efe556adSCorentin Chary  fi
2045efe556adSCorentin Charyfi
2046efe556adSCorentin Chary
2047efe556adSCorentin Chary##########################################
204876655d6dSaliguori# fnmatch() probe, used for ACL routines
204976655d6dSaliguorifnmatch="no"
205076655d6dSaliguoricat > $TMPC << EOF
205176655d6dSaliguori#include <fnmatch.h>
205276655d6dSaliguoriint main(void)
205376655d6dSaliguori{
205476655d6dSaliguori    fnmatch("foo", "foo", 0);
205576655d6dSaliguori    return 0;
205676655d6dSaliguori}
205776655d6dSaliguoriEOF
205852166aa0SJuan Quintelaif compile_prog "" "" ; then
205976655d6dSaliguori   fnmatch="yes"
206076655d6dSaliguorifi
206176655d6dSaliguori
206276655d6dSaliguori##########################################
2063ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
20642d16c8e9SPeter Maydell# Note that on some systems (notably MacOSX) no extra library
20652d16c8e9SPeter Maydell# need be linked to get the uuid functions.
2066ee682d27SStefan Weilif test "$uuid" != "no" ; then
2067ee682d27SStefan Weil  uuid_libs="-luuid"
2068ee682d27SStefan Weil  cat > $TMPC << EOF
2069ee682d27SStefan Weil#include <uuid/uuid.h>
2070ee682d27SStefan Weilint main(void)
2071ee682d27SStefan Weil{
2072ee682d27SStefan Weil    uuid_t my_uuid;
2073ee682d27SStefan Weil    uuid_generate(my_uuid);
2074ee682d27SStefan Weil    return 0;
2075ee682d27SStefan Weil}
2076ee682d27SStefan WeilEOF
20772d16c8e9SPeter Maydell  if compile_prog "" "" ; then
20782d16c8e9SPeter Maydell    uuid="yes"
20792d16c8e9SPeter Maydell  elif compile_prog "" "$uuid_libs" ; then
2080ee682d27SStefan Weil    uuid="yes"
2081ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
2082ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
2083ee682d27SStefan Weil  else
2084ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
208521684af0SStewart Smith      feature_not_found "uuid" "Install libuuid devel"
2086ee682d27SStefan Weil    fi
2087ee682d27SStefan Weil    uuid=no
2088ee682d27SStefan Weil  fi
2089ee682d27SStefan Weilfi
2090ee682d27SStefan Weil
20914f18b782SJeff Codyif test "$vhdx" = "yes" ; then
20924f18b782SJeff Cody    if test "$uuid" = "no" ; then
20934f18b782SJeff Cody        error_exit "uuid required for VHDX support"
20944f18b782SJeff Cody    fi
20954f18b782SJeff Codyelif test "$vhdx" != "no" ; then
20964f18b782SJeff Cody    if test "$uuid" = "yes" ; then
20974f18b782SJeff Cody        vhdx=yes
20984f18b782SJeff Cody    else
20994f18b782SJeff Cody        vhdx=no
21004f18b782SJeff Cody    fi
21014f18b782SJeff Codyfi
21024f18b782SJeff Cody
2103ee682d27SStefan Weil##########################################
2104dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
2105dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2106dce512deSChristoph Hellwig  cat > $TMPC << EOF
2107ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2108dce512deSChristoph Hellwig#include <xfs/xfs.h>
2109dce512deSChristoph Hellwigint main(void)
2110dce512deSChristoph Hellwig{
2111dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2112dce512deSChristoph Hellwig    return 0;
2113dce512deSChristoph Hellwig}
2114dce512deSChristoph HellwigEOF
2115dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2116dce512deSChristoph Hellwig    xfs="yes"
2117dce512deSChristoph Hellwig  else
2118dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
211921684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2120dce512deSChristoph Hellwig    fi
2121dce512deSChristoph Hellwig    xfs=no
2122dce512deSChristoph Hellwig  fi
2123dce512deSChristoph Hellwigfi
2124dce512deSChristoph Hellwig
2125dce512deSChristoph Hellwig##########################################
21268a16d273Sths# vde libraries probe
2127dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
21284baae0acSJuan Quintela  vde_libs="-lvdeplug"
21298a16d273Sths  cat > $TMPC << EOF
21308a16d273Sths#include <libvdeplug.h>
21314a7f0e06Spbrookint main(void)
21324a7f0e06Spbrook{
21334a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2134fea08e08SPeter Maydell    char s[] = "";
2135fea08e08SPeter Maydell    vde_open(s, s, &a);
21364a7f0e06Spbrook    return 0;
21374a7f0e06Spbrook}
21388a16d273SthsEOF
213952166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
21404baae0acSJuan Quintela    vde=yes
21418e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
21428e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2143dfb278bdSJuan Quintela  else
2144dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
214521684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2146dfb278bdSJuan Quintela    fi
2147dfb278bdSJuan Quintela    vde=no
21488a16d273Sths  fi
21498a16d273Sthsfi
21508a16d273Sths
21518a16d273Sths##########################################
215258952137SVincenzo Maffione# netmap headers probe
215358952137SVincenzo Maffioneif test "$netmap" != "no" ; then
215458952137SVincenzo Maffione  cat > $TMPC << EOF
215558952137SVincenzo Maffione#include <inttypes.h>
215658952137SVincenzo Maffione#include <net/if.h>
215758952137SVincenzo Maffione#include <net/netmap.h>
215858952137SVincenzo Maffione#include <net/netmap_user.h>
215958952137SVincenzo Maffioneint main(void) { return 0; }
216058952137SVincenzo MaffioneEOF
216158952137SVincenzo Maffione  if compile_prog "" "" ; then
216258952137SVincenzo Maffione    netmap=yes
216358952137SVincenzo Maffione  else
216458952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
216558952137SVincenzo Maffione      feature_not_found "netmap"
216658952137SVincenzo Maffione    fi
216758952137SVincenzo Maffione    netmap=no
216858952137SVincenzo Maffione  fi
216958952137SVincenzo Maffionefi
217058952137SVincenzo Maffione
217158952137SVincenzo Maffione##########################################
217247e98658SCorey Bryant# libcap-ng library probe
217347e98658SCorey Bryantif test "$cap_ng" != "no" ; then
217447e98658SCorey Bryant  cap_libs="-lcap-ng"
217547e98658SCorey Bryant  cat > $TMPC << EOF
217647e98658SCorey Bryant#include <cap-ng.h>
217747e98658SCorey Bryantint main(void)
217847e98658SCorey Bryant{
217947e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
218047e98658SCorey Bryant    return 0;
218147e98658SCorey Bryant}
218247e98658SCorey BryantEOF
218347e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
218447e98658SCorey Bryant    cap_ng=yes
218547e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
218647e98658SCorey Bryant  else
218747e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
218821684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
218947e98658SCorey Bryant    fi
219047e98658SCorey Bryant    cap_ng=no
219147e98658SCorey Bryant  fi
219247e98658SCorey Bryantfi
219347e98658SCorey Bryant
219447e98658SCorey Bryant##########################################
2195c2de5c91Smalc# Sound support libraries probe
21968f28f3fbSths
2197c2de5c91Smalcaudio_drv_probe()
2198c2de5c91Smalc{
2199c2de5c91Smalc    drv=$1
2200c2de5c91Smalc    hdr=$2
2201c2de5c91Smalc    lib=$3
2202c2de5c91Smalc    exp=$4
2203c2de5c91Smalc    cfl=$5
22048f28f3fbSths        cat > $TMPC << EOF
2205c2de5c91Smalc#include <$hdr>
2206c2de5c91Smalcint main(void) { $exp }
22078f28f3fbSthsEOF
220852166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
22098f28f3fbSths        :
22108f28f3fbSths    else
221176ad07a4SPeter Maydell        error_exit "$drv check failed" \
221276ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
22138f28f3fbSths    fi
2214c2de5c91Smalc}
2215c2de5c91Smalc
22162fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
2217c2de5c91Smalcfor drv in $audio_drv_list; do
2218c2de5c91Smalc    case $drv in
2219c2de5c91Smalc    alsa)
2220c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
2221e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
2222a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
2223c2de5c91Smalc    ;;
2224c2de5c91Smalc
2225c2de5c91Smalc    fmod)
2226c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
222776ad07a4SPeter Maydell        error_exit "You must specify path to FMOD library and headers" \
222876ad07a4SPeter Maydell            "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
22298f28f3fbSths    fi
2230c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
2231a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
2232c2de5c91Smalc    ;;
2233c2de5c91Smalc
2234c2de5c91Smalc    esd)
2235c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
2236a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
223767f86e8eSJuan Quintela    audio_pt_int="yes"
2238c2de5c91Smalc    ;;
2239b8e59f18Smalc
2240b8e59f18Smalc    pa)
2241a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
2242a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
2243a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
224467f86e8eSJuan Quintela    audio_pt_int="yes"
2245b8e59f18Smalc    ;;
2246b8e59f18Smalc
2247997e690aSJuan Quintela    coreaudio)
2248997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
2249997e690aSJuan Quintela    ;;
2250997e690aSJuan Quintela
2251a4bf6780SJuan Quintela    dsound)
2252a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2253d5631638Smalc      audio_win_int="yes"
2254a4bf6780SJuan Quintela    ;;
2255a4bf6780SJuan Quintela
2256a4bf6780SJuan Quintela    oss)
2257a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
2258a4bf6780SJuan Quintela    ;;
2259a4bf6780SJuan Quintela
2260a4bf6780SJuan Quintela    sdl|wav)
22612f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
22622f6a1ab0Sblueswir1    ;;
22632f6a1ab0Sblueswir1
2264d5631638Smalc    winwave)
2265d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
2266d5631638Smalc      audio_win_int="yes"
2267d5631638Smalc    ;;
2268d5631638Smalc
2269e4c63a6aSmalc    *)
22701c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
227176ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
227276ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
2273e4c63a6aSmalc    }
2274e4c63a6aSmalc    ;;
2275c2de5c91Smalc    esac
2276c2de5c91Smalcdone
22778f28f3fbSths
22784d3b6f6eSbalrog##########################################
22792e4d9fb1Saurel32# BrlAPI probe
22802e4d9fb1Saurel32
22814ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2282eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
22832e4d9fb1Saurel32  cat > $TMPC << EOF
22842e4d9fb1Saurel32#include <brlapi.h>
2285832ce9c2SScott Wood#include <stddef.h>
22862e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
22872e4d9fb1Saurel32EOF
228852166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
22892e4d9fb1Saurel32    brlapi=yes
2290264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
22914ffcedb6SJuan Quintela  else
22924ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
229321684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
22944ffcedb6SJuan Quintela    fi
22954ffcedb6SJuan Quintela    brlapi=no
2296eb82284fSJuan Quintela  fi
2297eb82284fSJuan Quintelafi
22982e4d9fb1Saurel32
22992e4d9fb1Saurel32##########################################
23004d3b6f6eSbalrog# curses probe
2301a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
2302e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
2303e095e2f3SStefan Weil    curses_list="-lpdcurses"
2304e095e2f3SStefan Weil  else
2305cfeda5f4SEd Maste    curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
2306e095e2f3SStefan Weil  fi
2307c584a6d0SJuan Quintela  curses_found=no
23084d3b6f6eSbalrog  cat > $TMPC << EOF
23094d3b6f6eSbalrog#include <curses.h>
2310ef9a2524SStefan Weilint main(void) {
2311ef9a2524SStefan Weil  const char *s = curses_version();
2312ef9a2524SStefan Weil  resize_term(0, 0);
2313ef9a2524SStefan Weil  return s != 0;
2314ef9a2524SStefan Weil}
23154d3b6f6eSbalrogEOF
2316ecbe251fSVadim Evard  IFS=:
23174f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
2318ecbe251fSVadim Evard    unset IFS
23194f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2320c584a6d0SJuan Quintela      curses_found=yes
23214f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
23224f78ef9aSJuan Quintela      break
23234d3b6f6eSbalrog    fi
23244f78ef9aSJuan Quintela  done
2325ecbe251fSVadim Evard  unset IFS
2326c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2327c584a6d0SJuan Quintela    curses=yes
2328c584a6d0SJuan Quintela  else
2329c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
233021684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
2331c584a6d0SJuan Quintela    fi
2332c584a6d0SJuan Quintela    curses=no
2333c584a6d0SJuan Quintela  fi
23344f78ef9aSJuan Quintelafi
23354d3b6f6eSbalrog
2336414f0dabSblueswir1##########################################
2337769ce76dSAlexander Graf# curl probe
2338a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
233965d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
2340a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
23414e2b0658SPaolo Bonzini  else
23424e2b0658SPaolo Bonzini    curlconfig=curl-config
23434e2b0658SPaolo Bonzini  fi
2344769ce76dSAlexander Graf  cat > $TMPC << EOF
2345769ce76dSAlexander Graf#include <curl/curl.h>
23460b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2347769ce76dSAlexander GrafEOF
23484e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
23494e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2350b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2351769ce76dSAlexander Graf    curl=yes
2352f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2353f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2354788c8196SJuan Quintela  else
2355788c8196SJuan Quintela    if test "$curl" = "yes" ; then
235621684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
2357788c8196SJuan Quintela    fi
2358788c8196SJuan Quintela    curl=no
2359769ce76dSAlexander Graf  fi
2360769ce76dSAlexander Graffi # test "$curl"
2361769ce76dSAlexander Graf
2362769ce76dSAlexander Graf##########################################
2363fb599c9aSbalrog# bluez support probe
2364a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2365e820e3f4Sbalrog  cat > $TMPC << EOF
2366e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2367e820e3f4Sbalrogint main(void) { return bt_error(0); }
2368e820e3f4SbalrogEOF
2369a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2370a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
237152166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2372a20a6f46SJuan Quintela    bluez=yes
2373e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2374e820e3f4Sbalrog  else
2375a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
237621684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
2377a20a6f46SJuan Quintela    fi
2378e820e3f4Sbalrog    bluez="no"
2379e820e3f4Sbalrog  fi
2380fb599c9aSbalrogfi
2381fb599c9aSbalrog
2382fb599c9aSbalrog##########################################
2383e18df141SAnthony Liguori# glib support probe
2384a52d28afSPaolo Bonzini
2385a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2386a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2387a52d28afSPaolo Bonzini    glib_req_ver=2.20
2388a52d28afSPaolo Bonzinielse
2389a52d28afSPaolo Bonzini    glib_req_ver=2.12
2390a52d28afSPaolo Bonzinifi
239165d5d3f9SStefan Weilif $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then
2392ca871ec8SStefan Weil    glib_cflags=`$pkg_config --cflags gthread-2.0`
2393ca871ec8SStefan Weil    glib_libs=`$pkg_config --libs gthread-2.0`
239414015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2395957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2396e18df141SAnthony Liguorielse
239776ad07a4SPeter Maydell    error_exit "glib-$glib_req_ver required to compile QEMU"
2398e18df141SAnthony Liguorifi
2399e18df141SAnthony Liguori
2400e18df141SAnthony Liguori##########################################
2401e2134eb9SGerd Hoffmann# pixman support probe
2402e2134eb9SGerd Hoffmann
2403e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
240474880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
240574880fe2SRobert Schiele    pixman="none"
240674880fe2SRobert Schiele  elif $pkg_config pixman-1 > /dev/null 2>&1; then
2407e2134eb9SGerd Hoffmann    pixman="system"
2408e2134eb9SGerd Hoffmann  else
2409e2134eb9SGerd Hoffmann    pixman="internal"
2410e2134eb9SGerd Hoffmann  fi
2411e2134eb9SGerd Hoffmannfi
241274880fe2SRobert Schieleif test "$pixman" = "none"; then
241374880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
241476ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
241576ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
241676ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
241776ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
241874880fe2SRobert Schiele  fi
241974880fe2SRobert Schiele  pixman_cflags=
242074880fe2SRobert Schiele  pixman_libs=
242174880fe2SRobert Schieleelif test "$pixman" = "system"; then
2422ca871ec8SStefan Weil  pixman_cflags=`$pkg_config --cflags pixman-1`
2423ca871ec8SStefan Weil  pixman_libs=`$pkg_config --libs pixman-1`
2424e2134eb9SGerd Hoffmannelse
2425e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
242676ad07a4SPeter Maydell    error_exit "pixman not present. Your options:" \
242776ad07a4SPeter Maydell        "  (1) Preferred: Install the pixman devel package (any recent" \
242876ad07a4SPeter Maydell        "      distro should have packages as Xorg needs pixman too)." \
242976ad07a4SPeter Maydell        "  (2) Fetch the pixman submodule, using:" \
243076ad07a4SPeter Maydell        "      git submodule update --init pixman"
2431e2134eb9SGerd Hoffmann  fi
24325ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
24335ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
24345ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2435e2134eb9SGerd Hoffmannfi
2436e2134eb9SGerd Hoffmann
2437e2134eb9SGerd Hoffmann##########################################
243817bff52bSM. Mohan Kumar# libcap probe
243917bff52bSM. Mohan Kumar
244017bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
244117bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
244217bff52bSM. Mohan Kumar#include <stdio.h>
244317bff52bSM. Mohan Kumar#include <sys/capability.h>
2444cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
244517bff52bSM. Mohan KumarEOF
244617bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
244717bff52bSM. Mohan Kumar    cap=yes
244817bff52bSM. Mohan Kumar  else
244917bff52bSM. Mohan Kumar    cap=no
245017bff52bSM. Mohan Kumar  fi
245117bff52bSM. Mohan Kumarfi
245217bff52bSM. Mohan Kumar
245317bff52bSM. Mohan Kumar##########################################
2454e5d355d1Saliguori# pthread probe
24554b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
24563c529d93Saliguori
2457e5d355d1Saliguoripthread=no
2458414f0dabSblueswir1cat > $TMPC << EOF
24593c529d93Saliguori#include <pthread.h>
24607a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
24617a42bbe4SStefan Weilint main(void) {
24627a42bbe4SStefan Weil  pthread_t thread;
24637a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
24647a42bbe4SStefan Weil  return 0;
24657a42bbe4SStefan Weil}
2466414f0dabSblueswir1EOF
2467bd00d539SAndreas Färberif compile_prog "" "" ; then
2468bd00d539SAndreas Färber  pthread=yes
2469bd00d539SAndreas Färberelse
2470de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
247152166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2472e5d355d1Saliguori      pthread=yes
2473e3c56761SPeter Portante      found=no
2474e3c56761SPeter Portante      for lib_entry in $LIBS; do
2475e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2476e3c56761SPeter Portante          found=yes
2477e3c56761SPeter Portante          break
2478e3c56761SPeter Portante        fi
2479e3c56761SPeter Portante      done
2480e3c56761SPeter Portante      if test "$found" = "no"; then
24815572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2482e3c56761SPeter Portante      fi
2483de65fe0fSSebastian Herbszt      break
2484414f0dabSblueswir1    fi
2485de65fe0fSSebastian Herbszt  done
2486bd00d539SAndreas Färberfi
2487414f0dabSblueswir1
24884617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
248976ad07a4SPeter Maydell  error_exit "pthread check failed" \
249076ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
2491e5d355d1Saliguorifi
2492e5d355d1Saliguori
2493bf9298b9Saliguori##########################################
2494f27aaf4bSChristian Brunner# rbd probe
2495f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2496f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2497f27aaf4bSChristian Brunner#include <stdio.h>
2498ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2499f27aaf4bSChristian Brunnerint main(void) {
2500ad32e9c0SJosh Durgin    rados_t cluster;
2501ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2502f27aaf4bSChristian Brunner    return 0;
2503f27aaf4bSChristian Brunner}
2504f27aaf4bSChristian BrunnerEOF
2505ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2506f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2507f27aaf4bSChristian Brunner    rbd=yes
2508f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2509f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2510f27aaf4bSChristian Brunner  else
2511f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
251221684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
2513f27aaf4bSChristian Brunner    fi
2514f27aaf4bSChristian Brunner    rbd=no
2515f27aaf4bSChristian Brunner  fi
2516f27aaf4bSChristian Brunnerfi
2517f27aaf4bSChristian Brunner
2518f27aaf4bSChristian Brunner##########################################
25190a12ec87SRichard W.M. Jones# libssh2 probe
25204fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
25210a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
252265d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
25230a12ec87SRichard W.M. Jones    libssh2_cflags=`$pkg_config libssh2 --cflags`
25240a12ec87SRichard W.M. Jones    libssh2_libs=`$pkg_config libssh2 --libs`
25250a12ec87SRichard W.M. Jones    libssh2=yes
25260a12ec87SRichard W.M. Jones    libs_tools="$libssh2_libs $libs_tools"
25270a12ec87SRichard W.M. Jones    libs_softmmu="$libssh2_libs $libs_softmmu"
25280a12ec87SRichard W.M. Jones    QEMU_CFLAGS="$QEMU_CFLAGS $libssh2_cflags"
25290a12ec87SRichard W.M. Jones  else
25300a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
25314fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
25320a12ec87SRichard W.M. Jones    fi
25330a12ec87SRichard W.M. Jones    libssh2=no
25340a12ec87SRichard W.M. Jones  fi
25350a12ec87SRichard W.M. Jonesfi
25360a12ec87SRichard W.M. Jones
25370a12ec87SRichard W.M. Jones##########################################
25389a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
25399a2d462eSRichard W.M. Jones
25409a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
25419a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
25429a2d462eSRichard W.M. Jones#include <stdio.h>
25439a2d462eSRichard W.M. Jones#include <libssh2.h>
25449a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
25459a2d462eSRichard W.M. Jonesint main(void) {
25469a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
25479a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
25489a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
25499a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
25509a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
25519a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
25529a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
25539a2d462eSRichard W.M. Jones    return 0;
25549a2d462eSRichard W.M. Jones}
25559a2d462eSRichard W.M. JonesEOF
25569a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
25579a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
25589a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
25599a2d462eSRichard W.M. Jones  fi
25609a2d462eSRichard W.M. Jonesfi
25619a2d462eSRichard W.M. Jones
25629a2d462eSRichard W.M. Jones##########################################
25635c6c3a6cSChristoph Hellwig# linux-aio probe
25645c6c3a6cSChristoph Hellwig
25655c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
25665c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
25675c6c3a6cSChristoph Hellwig#include <libaio.h>
25685c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2569832ce9c2SScott Wood#include <stddef.h>
25705c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
25715c6c3a6cSChristoph HellwigEOF
25725c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
25735c6c3a6cSChristoph Hellwig    linux_aio=yes
2574048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2575048d179fSPaul Brook    libs_tools="$libs_tools -laio"
25765c6c3a6cSChristoph Hellwig  else
25775c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
257821684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
25795c6c3a6cSChristoph Hellwig    fi
25803cfcae3cSLuiz Capitulino    linux_aio=no
25815c6c3a6cSChristoph Hellwig  fi
25825c6c3a6cSChristoph Hellwigfi
25835c6c3a6cSChristoph Hellwig
25845c6c3a6cSChristoph Hellwig##########################################
25853b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
25863b8acc11SPaolo Bonzini
25873b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
25883b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
25893b8acc11SPaolo Bonzinielse
25903b8acc11SPaolo Bonzini  tpm_passthrough=no
25913b8acc11SPaolo Bonzinifi
25923b8acc11SPaolo Bonzini
25933b8acc11SPaolo Bonzini##########################################
2594583f6e7bSStefan Hajnoczi# adjust virtio-blk-data-plane based on linux-aio
2595583f6e7bSStefan Hajnoczi
2596583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" -a \
2597583f6e7bSStefan Hajnoczi	"$linux_aio" != "yes" ; then
259876ad07a4SPeter Maydell  error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
2599583f6e7bSStefan Hajnoczielif test -z "$virtio_blk_data_plane" ; then
2600583f6e7bSStefan Hajnoczi  virtio_blk_data_plane=$linux_aio
2601583f6e7bSStefan Hajnoczifi
2602583f6e7bSStefan Hajnoczi
2603583f6e7bSStefan Hajnoczi##########################################
2604758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2605758e8e38SVenkateswararao Jujjuri (JV)
2606758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2607758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2608758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2609758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2610f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2611f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2612f2338fb4SPavel Borzenkov#else
26134f26f2b6SAvi Kivity#include <sys/xattr.h>
2614f2338fb4SPavel Borzenkov#endif
2615758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2616758e8e38SVenkateswararao Jujjuri (JV)EOF
26174f26f2b6SAvi Kivity  if compile_prog "" "" ; then
26184f26f2b6SAvi Kivity    attr=yes
26194f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2620f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2621758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2622758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
26234f26f2b6SAvi Kivity    libattr=yes
2624758e8e38SVenkateswararao Jujjuri (JV)  else
2625758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
262621684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
2627758e8e38SVenkateswararao Jujjuri (JV)    fi
2628758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2629758e8e38SVenkateswararao Jujjuri (JV)  fi
2630758e8e38SVenkateswararao Jujjuri (JV)fi
2631758e8e38SVenkateswararao Jujjuri (JV)
2632758e8e38SVenkateswararao Jujjuri (JV)##########################################
2633bf9298b9Saliguori# iovec probe
2634bf9298b9Saliguoricat > $TMPC <<EOF
2635db34f0b3Sblueswir1#include <sys/types.h>
2636bf9298b9Saliguori#include <sys/uio.h>
2637db34f0b3Sblueswir1#include <unistd.h>
2638f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2639bf9298b9SaliguoriEOF
2640bf9298b9Saliguoriiovec=no
264152166aa0SJuan Quintelaif compile_prog "" "" ; then
2642bf9298b9Saliguori  iovec=yes
2643bf9298b9Saliguorifi
2644bf9298b9Saliguori
2645f652e6afSaurel32##########################################
2646ceb42de8Saliguori# preadv probe
2647ceb42de8Saliguoricat > $TMPC <<EOF
2648ceb42de8Saliguori#include <sys/types.h>
2649ceb42de8Saliguori#include <sys/uio.h>
2650ceb42de8Saliguori#include <unistd.h>
2651c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2652ceb42de8SaliguoriEOF
2653ceb42de8Saliguoripreadv=no
265452166aa0SJuan Quintelaif compile_prog "" "" ; then
2655ceb42de8Saliguori  preadv=yes
2656ceb42de8Saliguorifi
2657ceb42de8Saliguori
2658ceb42de8Saliguori##########################################
2659f652e6afSaurel32# fdt probe
2660e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
2661e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
2662e169e1e1SPeter Maydellfdt_required=no
2663e169e1e1SPeter Maydellfor target in $target_list; do
2664e169e1e1SPeter Maydell  case $target in
26656a49fa95SAlexander Graf    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
2666e169e1e1SPeter Maydell      fdt_required=yes
2667e169e1e1SPeter Maydell    ;;
2668e169e1e1SPeter Maydell  esac
2669e169e1e1SPeter Maydelldone
2670e169e1e1SPeter Maydell
2671e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
2672e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
2673e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
2674e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
2675e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
2676e169e1e1SPeter Maydell  fi
2677e169e1e1SPeter Maydell  fdt=yes
2678e169e1e1SPeter Maydellfi
2679e169e1e1SPeter Maydell
26802df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2681b41af4baSJuan Quintela  fdt_libs="-lfdt"
268296ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
2683f652e6afSaurel32  cat > $TMPC << EOF
268496ce6545SPeter Crosthwaite#include <libfdt_env.h>
2685f652e6afSaurel32int main(void) { return 0; }
2686f652e6afSaurel32EOF
268752166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2688a540f158SPeter Crosthwaite    # system DTC is good - use it
2689f652e6afSaurel32    fdt=yes
2690a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
2691a540f158SPeter Crosthwaite    # have submodule DTC - use it
2692a540f158SPeter Crosthwaite    fdt=yes
2693a540f158SPeter Crosthwaite    dtc_internal="yes"
2694a540f158SPeter Crosthwaite    mkdir -p dtc
2695a540f158SPeter Crosthwaite    if [ "$source_path" != `pwd` ] ; then
2696a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
2697a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
26982df87df7SJuan Quintela    fi
2699a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
2700a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
2701a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
2702a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
27033f281822SStewart Smith    error_exit "DTC (libfdt) not present. Your options:" \
27043f281822SStewart Smith        "  (1) Preferred: Install the DTC (libfdt) devel package" \
2705a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
2706a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
2707a540f158SPeter Crosthwaite  else
2708a540f158SPeter Crosthwaite    # don't have and don't want
2709de3a354aSMichael Walle    fdt_libs=
27102df87df7SJuan Quintela    fdt=no
2711f652e6afSaurel32  fi
2712f652e6afSaurel32fi
2713f652e6afSaurel32
2714a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
2715a540f158SPeter Crosthwaite
271620ff075bSMichael Walle##########################################
2717b1e5fff4SMichael Walle# GLX probe, used by milkymist-tmu2
2718b1e5fff4SMichael Walleif test "$glx" != "no" ; then
2719b1e5fff4SMichael Walle  glx_libs="-lGL -lX11"
272020ff075bSMichael Walle  cat > $TMPC << EOF
272120ff075bSMichael Walle#include <X11/Xlib.h>
272220ff075bSMichael Walle#include <GL/gl.h>
272320ff075bSMichael Walle#include <GL/glx.h>
2724d3fcbb16SMichael Walleint main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
272520ff075bSMichael WalleEOF
2726d3fcbb16SMichael Walle  if compile_prog "" "-lGL -lX11" ; then
2727b1e5fff4SMichael Walle    glx=yes
272820ff075bSMichael Walle  else
2729b1e5fff4SMichael Walle    if test "$glx" = "yes" ; then
273021684af0SStewart Smith      feature_not_found "glx" "Install GL devel (e.g. MESA)"
273120ff075bSMichael Walle    fi
2732b1e5fff4SMichael Walle    glx_libs=
2733b1e5fff4SMichael Walle    glx=no
273420ff075bSMichael Walle  fi
273520ff075bSMichael Wallefi
273620ff075bSMichael Walle
2737eb100396SBharata B Rao##########################################
2738eb100396SBharata B Rao# glusterfs probe
2739eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
274065d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
2741e01bee08SBharata B Rao    glusterfs="yes"
2742ca871ec8SStefan Weil    glusterfs_cflags=`$pkg_config --cflags glusterfs-api`
2743ca871ec8SStefan Weil    glusterfs_libs=`$pkg_config --libs glusterfs-api`
2744e01bee08SBharata B Rao    CFLAGS="$CFLAGS $glusterfs_cflags"
2745eb100396SBharata B Rao    libs_tools="$glusterfs_libs $libs_tools"
2746eb100396SBharata B Rao    libs_softmmu="$glusterfs_libs $libs_softmmu"
274765d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
27480c14fb47SBharata B Rao      glusterfs_discard="yes"
27490c14fb47SBharata B Rao    fi
27507c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
27517c815372SBharata B Rao      glusterfs_zerofill="yes"
27527c815372SBharata B Rao    fi
2753eb100396SBharata B Rao  else
2754eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
275521684af0SStewart Smith      feature_not_found "GlusterFS backend support" "Install glusterfs-api devel"
2756eb100396SBharata B Rao    fi
2757e01bee08SBharata B Rao    glusterfs="no"
2758eb100396SBharata B Rao  fi
2759eb100396SBharata B Raofi
2760eb100396SBharata B Rao
276139386ac7Saurel32# Check for inotify functions when we are building linux-user
27623b3f24adSaurel32# emulator.  This is done because older glibc versions don't
27633b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
27643b3f24adSaurel32# don't provide them even if kernel supports them.
27653b3f24adSaurel32#
27663b3f24adSaurel32inotify=no
27673b3f24adSaurel32cat > $TMPC << EOF
27683b3f24adSaurel32#include <sys/inotify.h>
27693b3f24adSaurel32
27703b3f24adSaurel32int
27713b3f24adSaurel32main(void)
27723b3f24adSaurel32{
27733b3f24adSaurel32	/* try to start inotify */
27748690e420Saurel32	return inotify_init();
27753b3f24adSaurel32}
27763b3f24adSaurel32EOF
277752166aa0SJuan Quintelaif compile_prog "" "" ; then
27783b3f24adSaurel32  inotify=yes
27793b3f24adSaurel32fi
27803b3f24adSaurel32
2781c05c7a73SRiku Voipioinotify1=no
2782c05c7a73SRiku Voipiocat > $TMPC << EOF
2783c05c7a73SRiku Voipio#include <sys/inotify.h>
2784c05c7a73SRiku Voipio
2785c05c7a73SRiku Voipioint
2786c05c7a73SRiku Voipiomain(void)
2787c05c7a73SRiku Voipio{
2788c05c7a73SRiku Voipio    /* try to start inotify */
2789c05c7a73SRiku Voipio    return inotify_init1(0);
2790c05c7a73SRiku Voipio}
2791c05c7a73SRiku VoipioEOF
2792c05c7a73SRiku Voipioif compile_prog "" "" ; then
2793c05c7a73SRiku Voipio  inotify1=yes
2794c05c7a73SRiku Voipiofi
2795c05c7a73SRiku Voipio
2796ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2797ebc996f3SRiku Voipioutimens=no
2798ebc996f3SRiku Voipiocat > $TMPC << EOF
2799ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2800ebc996f3SRiku Voipio#include <stddef.h>
2801ebc996f3SRiku Voipio#include <fcntl.h>
28023014ee00SPeter Maydell#include <sys/stat.h>
2803ebc996f3SRiku Voipio
2804ebc996f3SRiku Voipioint main(void)
2805ebc996f3SRiku Voipio{
2806ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2807ebc996f3SRiku Voipio    futimens(0, NULL);
2808ebc996f3SRiku Voipio    return 0;
2809ebc996f3SRiku Voipio}
2810ebc996f3SRiku VoipioEOF
281152166aa0SJuan Quintelaif compile_prog "" "" ; then
2812ebc996f3SRiku Voipio  utimens=yes
2813ebc996f3SRiku Voipiofi
2814ebc996f3SRiku Voipio
2815099d6b0fSRiku Voipio# check if pipe2 is there
2816099d6b0fSRiku Voipiopipe2=no
2817099d6b0fSRiku Voipiocat > $TMPC << EOF
2818099d6b0fSRiku Voipio#include <unistd.h>
2819099d6b0fSRiku Voipio#include <fcntl.h>
2820099d6b0fSRiku Voipio
2821099d6b0fSRiku Voipioint main(void)
2822099d6b0fSRiku Voipio{
2823099d6b0fSRiku Voipio    int pipefd[2];
28249bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
2825099d6b0fSRiku Voipio}
2826099d6b0fSRiku VoipioEOF
282752166aa0SJuan Quintelaif compile_prog "" "" ; then
2828099d6b0fSRiku Voipio  pipe2=yes
2829099d6b0fSRiku Voipiofi
2830099d6b0fSRiku Voipio
283140ff6d7eSKevin Wolf# check if accept4 is there
283240ff6d7eSKevin Wolfaccept4=no
283340ff6d7eSKevin Wolfcat > $TMPC << EOF
283440ff6d7eSKevin Wolf#include <sys/socket.h>
283540ff6d7eSKevin Wolf#include <stddef.h>
283640ff6d7eSKevin Wolf
283740ff6d7eSKevin Wolfint main(void)
283840ff6d7eSKevin Wolf{
283940ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
284040ff6d7eSKevin Wolf    return 0;
284140ff6d7eSKevin Wolf}
284240ff6d7eSKevin WolfEOF
284340ff6d7eSKevin Wolfif compile_prog "" "" ; then
284440ff6d7eSKevin Wolf  accept4=yes
284540ff6d7eSKevin Wolffi
284640ff6d7eSKevin Wolf
28473ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
28483ce34dfbSvibisreenivasansplice=no
28493ce34dfbSvibisreenivasancat > $TMPC << EOF
28503ce34dfbSvibisreenivasan#include <unistd.h>
28513ce34dfbSvibisreenivasan#include <fcntl.h>
28523ce34dfbSvibisreenivasan#include <limits.h>
28533ce34dfbSvibisreenivasan
28543ce34dfbSvibisreenivasanint main(void)
28553ce34dfbSvibisreenivasan{
285666ea0f22SStefan Weil    int len, fd = 0;
28573ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
28583ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
28593ce34dfbSvibisreenivasan    return 0;
28603ce34dfbSvibisreenivasan}
28613ce34dfbSvibisreenivasanEOF
286252166aa0SJuan Quintelaif compile_prog "" "" ; then
28633ce34dfbSvibisreenivasan  splice=yes
28643ce34dfbSvibisreenivasanfi
28653ce34dfbSvibisreenivasan
2866dcc38d1cSMarcelo Tosatti##########################################
2867dcc38d1cSMarcelo Tosatti# signalfd probe
2868dcc38d1cSMarcelo Tosattisignalfd="no"
2869dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2870dcc38d1cSMarcelo Tosatti#include <unistd.h>
2871dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2872dcc38d1cSMarcelo Tosatti#include <signal.h>
2873dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2874dcc38d1cSMarcelo TosattiEOF
2875dcc38d1cSMarcelo Tosatti
2876dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2877dcc38d1cSMarcelo Tosatti  signalfd=yes
2878dcc38d1cSMarcelo Tosattifi
2879dcc38d1cSMarcelo Tosatti
2880c2882b96SRiku Voipio# check if eventfd is supported
2881c2882b96SRiku Voipioeventfd=no
2882c2882b96SRiku Voipiocat > $TMPC << EOF
2883c2882b96SRiku Voipio#include <sys/eventfd.h>
2884c2882b96SRiku Voipio
2885c2882b96SRiku Voipioint main(void)
2886c2882b96SRiku Voipio{
288755cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2888c2882b96SRiku Voipio}
2889c2882b96SRiku VoipioEOF
2890c2882b96SRiku Voipioif compile_prog "" "" ; then
2891c2882b96SRiku Voipio  eventfd=yes
2892c2882b96SRiku Voipiofi
2893c2882b96SRiku Voipio
2894d0927938SUlrich Hecht# check for fallocate
2895d0927938SUlrich Hechtfallocate=no
2896d0927938SUlrich Hechtcat > $TMPC << EOF
2897d0927938SUlrich Hecht#include <fcntl.h>
2898d0927938SUlrich Hecht
2899d0927938SUlrich Hechtint main(void)
2900d0927938SUlrich Hecht{
2901d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2902d0927938SUlrich Hecht    return 0;
2903d0927938SUlrich Hecht}
2904d0927938SUlrich HechtEOF
29058fb03151SPeter Maydellif compile_prog "" "" ; then
2906d0927938SUlrich Hecht  fallocate=yes
2907d0927938SUlrich Hechtfi
2908d0927938SUlrich Hecht
29093d4fa43eSKusanagi Kouichi# check for fallocate hole punching
29103d4fa43eSKusanagi Kouichifallocate_punch_hole=no
29113d4fa43eSKusanagi Kouichicat > $TMPC << EOF
29123d4fa43eSKusanagi Kouichi#include <fcntl.h>
29133d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
29143d4fa43eSKusanagi Kouichi
29153d4fa43eSKusanagi Kouichiint main(void)
29163d4fa43eSKusanagi Kouichi{
29173d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
29183d4fa43eSKusanagi Kouichi    return 0;
29193d4fa43eSKusanagi Kouichi}
29203d4fa43eSKusanagi KouichiEOF
29213d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
29223d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
29233d4fa43eSKusanagi Kouichifi
29243d4fa43eSKusanagi Kouichi
2925c727f47dSPeter Maydell# check for sync_file_range
2926c727f47dSPeter Maydellsync_file_range=no
2927c727f47dSPeter Maydellcat > $TMPC << EOF
2928c727f47dSPeter Maydell#include <fcntl.h>
2929c727f47dSPeter Maydell
2930c727f47dSPeter Maydellint main(void)
2931c727f47dSPeter Maydell{
2932c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2933c727f47dSPeter Maydell    return 0;
2934c727f47dSPeter Maydell}
2935c727f47dSPeter MaydellEOF
29368fb03151SPeter Maydellif compile_prog "" "" ; then
2937c727f47dSPeter Maydell  sync_file_range=yes
2938c727f47dSPeter Maydellfi
2939c727f47dSPeter Maydell
2940dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2941dace20dcSPeter Maydellfiemap=no
2942dace20dcSPeter Maydellcat > $TMPC << EOF
2943dace20dcSPeter Maydell#include <sys/ioctl.h>
2944dace20dcSPeter Maydell#include <linux/fs.h>
2945dace20dcSPeter Maydell#include <linux/fiemap.h>
2946dace20dcSPeter Maydell
2947dace20dcSPeter Maydellint main(void)
2948dace20dcSPeter Maydell{
2949dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2950dace20dcSPeter Maydell    return 0;
2951dace20dcSPeter Maydell}
2952dace20dcSPeter MaydellEOF
29538fb03151SPeter Maydellif compile_prog "" "" ; then
2954dace20dcSPeter Maydell  fiemap=yes
2955dace20dcSPeter Maydellfi
2956dace20dcSPeter Maydell
2957d0927938SUlrich Hecht# check for dup3
2958d0927938SUlrich Hechtdup3=no
2959d0927938SUlrich Hechtcat > $TMPC << EOF
2960d0927938SUlrich Hecht#include <unistd.h>
2961d0927938SUlrich Hecht
2962d0927938SUlrich Hechtint main(void)
2963d0927938SUlrich Hecht{
2964d0927938SUlrich Hecht    dup3(0, 0, 0);
2965d0927938SUlrich Hecht    return 0;
2966d0927938SUlrich Hecht}
2967d0927938SUlrich HechtEOF
296878f5d726SJan Kiszkaif compile_prog "" "" ; then
2969d0927938SUlrich Hecht  dup3=yes
2970d0927938SUlrich Hechtfi
2971d0927938SUlrich Hecht
29724e0c6529SAlex Bligh# check for ppoll support
29734e0c6529SAlex Blighppoll=no
29744e0c6529SAlex Blighcat > $TMPC << EOF
29754e0c6529SAlex Bligh#include <poll.h>
29764e0c6529SAlex Bligh
29774e0c6529SAlex Blighint main(void)
29784e0c6529SAlex Bligh{
29794e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
29804e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
29814e0c6529SAlex Bligh    return 0;
29824e0c6529SAlex Bligh}
29834e0c6529SAlex BlighEOF
29844e0c6529SAlex Blighif compile_prog "" "" ; then
29854e0c6529SAlex Bligh  ppoll=yes
29864e0c6529SAlex Blighfi
29874e0c6529SAlex Bligh
2988cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
2989cd758dd0SAlex Blighprctl_pr_set_timerslack=no
2990cd758dd0SAlex Blighcat > $TMPC << EOF
2991cd758dd0SAlex Bligh#include <sys/prctl.h>
2992cd758dd0SAlex Bligh
2993cd758dd0SAlex Blighint main(void)
2994cd758dd0SAlex Bligh{
2995cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
2996cd758dd0SAlex Bligh    return 0;
2997cd758dd0SAlex Bligh}
2998cd758dd0SAlex BlighEOF
2999cd758dd0SAlex Blighif compile_prog "" "" ; then
3000cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3001cd758dd0SAlex Blighfi
3002cd758dd0SAlex Bligh
30033b6edd16SPeter Maydell# check for epoll support
30043b6edd16SPeter Maydellepoll=no
30053b6edd16SPeter Maydellcat > $TMPC << EOF
30063b6edd16SPeter Maydell#include <sys/epoll.h>
30073b6edd16SPeter Maydell
30083b6edd16SPeter Maydellint main(void)
30093b6edd16SPeter Maydell{
30103b6edd16SPeter Maydell    epoll_create(0);
30113b6edd16SPeter Maydell    return 0;
30123b6edd16SPeter Maydell}
30133b6edd16SPeter MaydellEOF
30148fb03151SPeter Maydellif compile_prog "" "" ; then
30153b6edd16SPeter Maydell  epoll=yes
30163b6edd16SPeter Maydellfi
30173b6edd16SPeter Maydell
30183b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
30193b6edd16SPeter Maydell# so we must check separately for their presence
30203b6edd16SPeter Maydellepoll_create1=no
30213b6edd16SPeter Maydellcat > $TMPC << EOF
30223b6edd16SPeter Maydell#include <sys/epoll.h>
30233b6edd16SPeter Maydell
30243b6edd16SPeter Maydellint main(void)
30253b6edd16SPeter Maydell{
302619e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
302719e83f6bSPeter Maydell     * a function being called. This is necessary so that on
302819e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
302919e83f6bSPeter Maydell     * the library but not declared in the header file we will
303019e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
303119e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
303219e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
303319e83f6bSPeter Maydell     */
3034c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
30353b6edd16SPeter Maydell}
30363b6edd16SPeter MaydellEOF
30378fb03151SPeter Maydellif compile_prog "" "" ; then
30383b6edd16SPeter Maydell  epoll_create1=yes
30393b6edd16SPeter Maydellfi
30403b6edd16SPeter Maydell
30413b6edd16SPeter Maydellepoll_pwait=no
30423b6edd16SPeter Maydellcat > $TMPC << EOF
30433b6edd16SPeter Maydell#include <sys/epoll.h>
30443b6edd16SPeter Maydell
30453b6edd16SPeter Maydellint main(void)
30463b6edd16SPeter Maydell{
30473b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
30483b6edd16SPeter Maydell    return 0;
30493b6edd16SPeter Maydell}
30503b6edd16SPeter MaydellEOF
30518fb03151SPeter Maydellif compile_prog "" "" ; then
30523b6edd16SPeter Maydell  epoll_pwait=yes
30533b6edd16SPeter Maydellfi
30543b6edd16SPeter Maydell
3055a8fd1abaSPeter Maydell# check for sendfile support
3056a8fd1abaSPeter Maydellsendfile=no
3057a8fd1abaSPeter Maydellcat > $TMPC << EOF
3058a8fd1abaSPeter Maydell#include <sys/sendfile.h>
3059a8fd1abaSPeter Maydell
3060a8fd1abaSPeter Maydellint main(void)
3061a8fd1abaSPeter Maydell{
3062a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
3063a8fd1abaSPeter Maydell}
3064a8fd1abaSPeter MaydellEOF
3065a8fd1abaSPeter Maydellif compile_prog "" "" ; then
3066a8fd1abaSPeter Maydell  sendfile=yes
3067a8fd1abaSPeter Maydellfi
3068a8fd1abaSPeter Maydell
3069cc8ae6deSpbrook# Check if tools are available to build documentation.
3070a25dba17SJuan Quintelaif test "$docs" != "no" ; then
307101668d98SStefan Weil  if has makeinfo && has pod2man; then
3072a25dba17SJuan Quintela    docs=yes
307383a3ab8bSJuan Quintela  else
3074a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
307521684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
307683a3ab8bSJuan Quintela    fi
3077a25dba17SJuan Quintela    docs=no
307883a3ab8bSJuan Quintela  fi
3079cc8ae6deSpbrookfi
3080cc8ae6deSpbrook
3081f514f41cSStefan Weil# Search for bswap_32 function
30826ae9a1f4SJuan Quintelabyteswap_h=no
30836ae9a1f4SJuan Quintelacat > $TMPC << EOF
30846ae9a1f4SJuan Quintela#include <byteswap.h>
30856ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
30866ae9a1f4SJuan QuintelaEOF
308752166aa0SJuan Quintelaif compile_prog "" "" ; then
30886ae9a1f4SJuan Quintela  byteswap_h=yes
30896ae9a1f4SJuan Quintelafi
30906ae9a1f4SJuan Quintela
309175f13596SStefan Weil# Search for bswap32 function
30926ae9a1f4SJuan Quintelabswap_h=no
30936ae9a1f4SJuan Quintelacat > $TMPC << EOF
30946ae9a1f4SJuan Quintela#include <sys/endian.h>
30956ae9a1f4SJuan Quintela#include <sys/types.h>
30966ae9a1f4SJuan Quintela#include <machine/bswap.h>
30976ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
30986ae9a1f4SJuan QuintelaEOF
309952166aa0SJuan Quintelaif compile_prog "" "" ; then
31006ae9a1f4SJuan Quintela  bswap_h=yes
31016ae9a1f4SJuan Quintelafi
31026ae9a1f4SJuan Quintela
3103da93a1fdSaliguori##########################################
3104c589b249SRonnie Sahlberg# Do we have libiscsi
3105063c3378SPeter Lieven# We check for iscsi_write16_sync() to make sure we have a
3106063c3378SPeter Lieven# at least version 1.4.0 of libiscsi.
3107c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
3108c589b249SRonnie Sahlberg  cat > $TMPC << EOF
3109fa6acb0cSRonnie Sahlberg#include <stdio.h>
3110c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
3111063c3378SPeter Lievenint main(void) { iscsi_write16_sync(NULL,0,0,NULL,0,0,0,0,0,0,0); return 0; }
3112c589b249SRonnie SahlbergEOF
311365d5d3f9SStefan Weil  if $pkg_config --atleast-version=1.7.0 libiscsi; then
31143c33ea96SPaolo Bonzini    libiscsi="yes"
3115ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
3116ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
31173c33ea96SPaolo Bonzini    CFLAGS="$CFLAGS $libiscsi_cflags"
31183c33ea96SPaolo Bonzini    LIBS="$LIBS $libiscsi_libs"
31193c33ea96SPaolo Bonzini  elif compile_prog "" "-liscsi" ; then
3120c589b249SRonnie Sahlberg    libiscsi="yes"
3121c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
3122c589b249SRonnie Sahlberg  else
3123c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
312421684af0SStewart Smith      feature_not_found "libiscsi" "Install libiscsi devel"
3125c589b249SRonnie Sahlberg    fi
3126c589b249SRonnie Sahlberg    libiscsi="no"
3127c589b249SRonnie Sahlberg  fi
3128c589b249SRonnie Sahlbergfi
3129c589b249SRonnie Sahlberg
3130219c2521SStefan Weil# We also need to know the API version because there was an
3131219c2521SStefan Weil# API change from 1.4.0 to 1.5.0.
3132219c2521SStefan Weilif test "$libiscsi" = "yes"; then
3133219c2521SStefan Weil  cat >$TMPC <<EOF
3134219c2521SStefan Weil#include <iscsi/iscsi.h>
3135219c2521SStefan Weilint main(void)
3136219c2521SStefan Weil{
3137219c2521SStefan Weil  iscsi_read10_task(0, 0, 0, 0, 0, 0, 0);
3138219c2521SStefan Weil  return 0;
3139219c2521SStefan Weil}
3140219c2521SStefan WeilEOF
3141219c2521SStefan Weil  if compile_prog "" "-liscsi"; then
3142219c2521SStefan Weil    libiscsi_version="1.4.0"
3143219c2521SStefan Weil  fi
3144219c2521SStefan Weilfi
3145c589b249SRonnie Sahlberg
3146c589b249SRonnie Sahlberg##########################################
31478bacde8dSNatanael Copa# Do we need libm
31488bacde8dSNatanael Copacat > $TMPC << EOF
31498bacde8dSNatanael Copa#include <math.h>
31508bacde8dSNatanael Copaint main(void) { return isnan(sin(0.0)); }
31518bacde8dSNatanael CopaEOF
31528bacde8dSNatanael Copaif compile_prog "" "" ; then
31538bacde8dSNatanael Copa  :
31548bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
31558bacde8dSNatanael Copa  LIBS="-lm $LIBS"
31568bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
31578bacde8dSNatanael Copaelse
315876ad07a4SPeter Maydell  error_exit "libm check failed"
31598bacde8dSNatanael Copafi
31608bacde8dSNatanael Copa
31618bacde8dSNatanael Copa##########################################
3162da93a1fdSaliguori# Do we need librt
31638bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
31648bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
31658bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
31668bacde8dSNatanael Copa# function in addition.
3167da93a1fdSaliguoricat > $TMPC <<EOF
3168da93a1fdSaliguori#include <signal.h>
3169da93a1fdSaliguori#include <time.h>
31708bacde8dSNatanael Copaint main(void) {
31718bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
31728bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
31738bacde8dSNatanael Copa}
3174da93a1fdSaliguoriEOF
3175da93a1fdSaliguori
317652166aa0SJuan Quintelaif compile_prog "" "" ; then
317707ffa4bdSJuan Quintela  :
31788bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
31798bacde8dSNatanael Copaelif compile_prog "" "-lrt $pthread_lib" ; then
318007ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
31818bacde8dSNatanael Copa  libs_qga="-lrt $libs_qga"
3182da93a1fdSaliguorifi
3183da93a1fdSaliguori
318431ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
3185179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
31866362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
31876362a53fSJuan Quintelafi
31886362a53fSJuan Quintela
3189de5071c5SBlue Swirl##########################################
3190cd4ec0b4SGerd Hoffmann# spice probe
3191cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3192cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3193cd4ec0b4SGerd Hoffmann#include <spice.h>
3194cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3195cd4ec0b4SGerd HoffmannEOF
3196710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3197710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
319865d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
319965d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
3200cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3201cd4ec0b4SGerd Hoffmann    spice="yes"
3202cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
3203cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
32042e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
32052e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
3206cd4ec0b4SGerd Hoffmann  else
3207cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
320821684af0SStewart Smith      feature_not_found "spice" "Install spice-server and spice-protocol devel"
3209cd4ec0b4SGerd Hoffmann    fi
3210cd4ec0b4SGerd Hoffmann    spice="no"
3211cd4ec0b4SGerd Hoffmann  fi
3212cd4ec0b4SGerd Hoffmannfi
3213cd4ec0b4SGerd Hoffmann
3214111a38b0SRobert Relyea# check for libcacard for smartcard support
3215111a38b0SRobert Relyeasmartcard_cflags=""
3216111a38b0SRobert Relyea# TODO - what's the minimal nss version we support?
3217111a38b0SRobert Relyeaif test "$smartcard_nss" != "no"; then
32185f01e06fSSergei Trofimovich  cat > $TMPC << EOF
32195f01e06fSSergei Trofimovich#include <pk11pub.h>
32205f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
32215f01e06fSSergei TrofimovichEOF
32220b22ef0fSPeter Maydell    smartcard_includes="-I\$(SRC_PATH)/libcacard"
32238c741c22SAlon Levy    libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
32248c741c22SAlon Levy    libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
32256ca026cbSPeter Maydell    test_cflags="$libcacard_cflags"
32266ca026cbSPeter Maydell    # The header files in nss < 3.13.3 have a bug which causes them to
32276ca026cbSPeter Maydell    # emit a warning. If we're going to compile QEMU with -Werror, then
32286ca026cbSPeter Maydell    # test that the headers don't have this bug. Otherwise we would pass
32296ca026cbSPeter Maydell    # the configure test but fail to compile QEMU later.
32306ca026cbSPeter Maydell    if test "$werror" = "yes"; then
32316ca026cbSPeter Maydell        test_cflags="-Werror $test_cflags"
32326ca026cbSPeter Maydell    fi
3233b6fc675bSPaolo Bonzini    if test -n "$libtool" &&
323465d5d3f9SStefan Weil       $pkg_config --atleast-version=3.12.8 nss && \
32356ca026cbSPeter Maydell      compile_prog "$test_cflags" "$libcacard_libs"; then
32365f01e06fSSergei Trofimovich        smartcard_nss="yes"
32370b22ef0fSPeter Maydell        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
32380b22ef0fSPeter Maydell        QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
3239ad4cf3f6SPaul Brook        libs_softmmu="$libcacard_libs $libs_softmmu"
3240111a38b0SRobert Relyea    else
3241111a38b0SRobert Relyea        if test "$smartcard_nss" = "yes"; then
3242111a38b0SRobert Relyea            feature_not_found "nss"
3243111a38b0SRobert Relyea        fi
3244111a38b0SRobert Relyea        smartcard_nss="no"
3245111a38b0SRobert Relyea    fi
3246111a38b0SRobert Relyeafi
3247111a38b0SRobert Relyea
32482b2325ffSGerd Hoffmann# check for libusb
32492b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
325065d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
32512b2325ffSGerd Hoffmann        libusb="yes"
3252ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
3253ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
32542b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
32552b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
32562b2325ffSGerd Hoffmann    else
32572b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
325821684af0SStewart Smith            feature_not_found "libusb" "Install libusb devel"
32592b2325ffSGerd Hoffmann        fi
32602b2325ffSGerd Hoffmann        libusb="no"
32612b2325ffSGerd Hoffmann    fi
32622b2325ffSGerd Hoffmannfi
32632b2325ffSGerd Hoffmann
326469354a83SHans de Goede# check for usbredirparser for usb network redirection support
326569354a83SHans de Goedeif test "$usb_redir" != "no" ; then
326665d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
326769354a83SHans de Goede        usb_redir="yes"
3268ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
3269ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
327069354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
327156ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
327269354a83SHans de Goede    else
327369354a83SHans de Goede        if test "$usb_redir" = "yes"; then
327421684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
327569354a83SHans de Goede        fi
327669354a83SHans de Goede        usb_redir="no"
327769354a83SHans de Goede    fi
327869354a83SHans de Goedefi
327969354a83SHans de Goede
3280cd4ec0b4SGerd Hoffmann##########################################
3281d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
3282d9840e25STomoki Sekiyama
3283d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
3284d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
3285d9840e25STomoki Sekiyama    "")   vss_win32_include="-I$source_path" ;;
3286d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3287d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
3288d9840e25STomoki Sekiyama          vss_win32_include="-I$source_path/.sdk/vss"
3289d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3290d9840e25STomoki Sekiyama	  ;;
3291d9840e25STomoki Sekiyama    *)    vss_win32_include="-I$vss_win32_sdk"
3292d9840e25STomoki Sekiyama  esac
3293d9840e25STomoki Sekiyama  cat > $TMPC << EOF
3294d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
3295d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
3296d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
3297d9840e25STomoki SekiyamaEOF
3298d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
3299d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
3300d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
3301d9840e25STomoki Sekiyama    libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
3302d9840e25STomoki Sekiyama  else
3303d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
3304d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
3305d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3306d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3307d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
3308d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
3309d9840e25STomoki Sekiyama      feature_not_found "VSS support"
3310d9840e25STomoki Sekiyama    fi
3311d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
3312d9840e25STomoki Sekiyama  fi
3313d9840e25STomoki Sekiyamafi
3314d9840e25STomoki Sekiyama
3315d9840e25STomoki Sekiyama##########################################
3316d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
3317d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
3318d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
3319d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
3320d9840e25STomoki Sekiyama
3321d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
3322d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
3323d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
3324d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
3325d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
3326d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
3327d9840e25STomoki Sekiyama    else
3328d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
3329d9840e25STomoki Sekiyama    fi
3330d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
3331d9840e25STomoki Sekiyama    win_sdk=""
3332d9840e25STomoki Sekiyama  fi
3333d9840e25STomoki Sekiyamafi
3334d9840e25STomoki Sekiyama
3335d9840e25STomoki Sekiyama##########################################
3336cd4ec0b4SGerd Hoffmann
3337747bbdf7SBlue Swirl##########################################
33385f6b9e8fSBlue Swirl# check if we have fdatasync
33395f6b9e8fSBlue Swirl
33405f6b9e8fSBlue Swirlfdatasync=no
33415f6b9e8fSBlue Swirlcat > $TMPC << EOF
33425f6b9e8fSBlue Swirl#include <unistd.h>
3343d1722a27SAlexandre Raymondint main(void) {
3344d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
3345d1722a27SAlexandre Raymondreturn fdatasync(0);
3346d1722a27SAlexandre Raymond#else
3347e172fe11SStefan Weil#error Not supported
3348d1722a27SAlexandre Raymond#endif
3349d1722a27SAlexandre Raymond}
33505f6b9e8fSBlue SwirlEOF
33515f6b9e8fSBlue Swirlif compile_prog "" "" ; then
33525f6b9e8fSBlue Swirl    fdatasync=yes
33535f6b9e8fSBlue Swirlfi
33545f6b9e8fSBlue Swirl
335594a420b1SStefan Hajnoczi##########################################
3356e78815a5SAndreas Färber# check if we have madvise
3357e78815a5SAndreas Färber
3358e78815a5SAndreas Färbermadvise=no
3359e78815a5SAndreas Färbercat > $TMPC << EOF
3360e78815a5SAndreas Färber#include <sys/types.h>
3361e78815a5SAndreas Färber#include <sys/mman.h>
3362832ce9c2SScott Wood#include <stddef.h>
3363e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
3364e78815a5SAndreas FärberEOF
3365e78815a5SAndreas Färberif compile_prog "" "" ; then
3366e78815a5SAndreas Färber    madvise=yes
3367e78815a5SAndreas Färberfi
3368e78815a5SAndreas Färber
3369e78815a5SAndreas Färber##########################################
3370e78815a5SAndreas Färber# check if we have posix_madvise
3371e78815a5SAndreas Färber
3372e78815a5SAndreas Färberposix_madvise=no
3373e78815a5SAndreas Färbercat > $TMPC << EOF
3374e78815a5SAndreas Färber#include <sys/mman.h>
3375832ce9c2SScott Wood#include <stddef.h>
3376e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
3377e78815a5SAndreas FärberEOF
3378e78815a5SAndreas Färberif compile_prog "" "" ; then
3379e78815a5SAndreas Färber    posix_madvise=yes
3380e78815a5SAndreas Färberfi
3381e78815a5SAndreas Färber
3382e78815a5SAndreas Färber##########################################
33831e9737daSRichard Henderson# check if we have usable SIGEV_THREAD_ID
33841e9737daSRichard Henderson
33851e9737daSRichard Hendersonsigev_thread_id=no
33861e9737daSRichard Hendersoncat > $TMPC << EOF
33871e9737daSRichard Henderson#include <signal.h>
33881e9737daSRichard Hendersonint main(void) {
33891e9737daSRichard Henderson  struct sigevent ev;
33901e9737daSRichard Henderson  ev.sigev_notify = SIGEV_THREAD_ID;
33911e9737daSRichard Henderson  ev._sigev_un._tid = 0;
33921e9737daSRichard Henderson  asm volatile("" : : "g"(&ev));
33931e9737daSRichard Henderson  return 0;
33941e9737daSRichard Henderson}
33951e9737daSRichard HendersonEOF
33961e9737daSRichard Hendersonif compile_prog "" "" ; then
33971e9737daSRichard Henderson    sigev_thread_id=yes
33981e9737daSRichard Hendersonfi
33991e9737daSRichard Henderson
34001e9737daSRichard Henderson##########################################
340194a420b1SStefan Hajnoczi# check if trace backend exists
340294a420b1SStefan Hajnoczi
3403650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
340494a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
340576ad07a4SPeter Maydell  error_exit "invalid trace backend" \
340676ad07a4SPeter Maydell      "Please choose a supported trace backend."
340794a420b1SStefan Hajnoczifi
340894a420b1SStefan Hajnoczi
34097e24e92aSStefan Hajnoczi##########################################
34107e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
34117e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
34127e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
3413bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
34147e24e92aSStefan Hajnocziint main(void) { return 0; }
34157e24e92aSStefan HajnocziEOF
34167e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
3417bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
3418bf15f63cSMohamad Gebai      lttng_ust_libs=`$pkg_config --libs lttng-ust`
34197e24e92aSStefan Hajnoczi    else
3420bf15f63cSMohamad Gebai      lttng_ust_libs="-llttng-ust"
3421bf15f63cSMohamad Gebai    fi
3422bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
3423bf15f63cSMohamad Gebai      urcu_bp_libs=`$pkg_config --libs liburcu-bp`
3424bf15f63cSMohamad Gebai    else
3425bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
3426bf15f63cSMohamad Gebai    fi
3427bf15f63cSMohamad Gebai
3428bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
3429bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
3430bf15f63cSMohamad Gebai  else
3431bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
34327e24e92aSStefan Hajnoczi  fi
34337e24e92aSStefan Hajnoczifi
3434b3d08c02SDaniel P. Berrange
3435b3d08c02SDaniel P. Berrange##########################################
3436b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
3437b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
3438b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
343976ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
3440b3d08c02SDaniel P. Berrange  fi
3441c276b17dSDaniel P. Berrange  trace_backend_stap="no"
3442c276b17dSDaniel P. Berrange  if has 'stap' ; then
3443c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
3444c276b17dSDaniel P. Berrange  fi
3445b3d08c02SDaniel P. Berrangefi
3446b3d08c02SDaniel P. Berrange
34477e24e92aSStefan Hajnoczi##########################################
3448519175a2SAlex Barcelo# check and set a backend for coroutine
3449d0e2fce5SAneesh Kumar K.V
34507c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
34517c2acc70SPeter Maydell# is sigcontext. gthread is not selectable except explicitly, because
34527c2acc70SPeter Maydell# it is not functional enough to run QEMU proper. (It is occasionally
34537c2acc70SPeter Maydell# useful for debugging purposes.)  On Windows the only valid backend
34547c2acc70SPeter Maydell# is the Windows-specific one.
34557c2acc70SPeter Maydell
34567c2acc70SPeter Maydellucontext_works=no
3457d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3458d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3459d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3460cdf84806SPeter Maydell#ifdef __stub_makecontext
3461cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3462cdf84806SPeter Maydell#endif
346375cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3464d0e2fce5SAneesh Kumar K.VEOF
3465d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
34667c2acc70SPeter Maydell    ucontext_works=yes
3467d0e2fce5SAneesh Kumar K.V  fi
3468519175a2SAlex Barcelofi
34697c2acc70SPeter Maydell
34707c2acc70SPeter Maydellif test "$coroutine" = ""; then
34717c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
34727c2acc70SPeter Maydell    coroutine=win32
34737c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
34747c2acc70SPeter Maydell    coroutine=ucontext
3475519175a2SAlex Barcelo  else
34767c2acc70SPeter Maydell    coroutine=sigaltstack
34777c2acc70SPeter Maydell  fi
34787c2acc70SPeter Maydellelse
34797c2acc70SPeter Maydell  case $coroutine in
34807c2acc70SPeter Maydell  windows)
34817c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
34827c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
34837c2acc70SPeter Maydell    fi
34847c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
34857c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
34867c2acc70SPeter Maydell    coroutine=win32
34877c2acc70SPeter Maydell    ;;
34887c2acc70SPeter Maydell  ucontext)
34897c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
34907c2acc70SPeter Maydell      feature_not_found "ucontext"
34917c2acc70SPeter Maydell    fi
34927c2acc70SPeter Maydell    ;;
34937c2acc70SPeter Maydell  gthread|sigaltstack)
34947c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
34957c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
34967c2acc70SPeter Maydell    fi
34977c2acc70SPeter Maydell    ;;
34987c2acc70SPeter Maydell  *)
349976ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
35007c2acc70SPeter Maydell    ;;
35017c2acc70SPeter Maydell  esac
3502d0e2fce5SAneesh Kumar K.Vfi
3503d0e2fce5SAneesh Kumar K.V
350470c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
350570c60c08SStefan Hajnoczi  if test "$coroutine" = "gthread"; then
350670c60c08SStefan Hajnoczi    coroutine_pool=no
350770c60c08SStefan Hajnoczi  else
350870c60c08SStefan Hajnoczi    coroutine_pool=yes
350970c60c08SStefan Hajnoczi  fi
351070c60c08SStefan Hajnoczifi
351170c60c08SStefan Hajnocziif test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
351270c60c08SStefan Hajnoczi  error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
351370c60c08SStefan Hajnoczifi
351470c60c08SStefan Hajnoczi
3515d0e2fce5SAneesh Kumar K.V##########################################
3516d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
3517d2042378SAneesh Kumar K.V
35184e1797f9SStefan Weilopen_by_handle_at=no
3519d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
3520d2042378SAneesh Kumar K.V#include <fcntl.h>
3521acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
3522acc55ba8SStefan Weil# error missing definition
3523acc55ba8SStefan Weil#else
352475cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3525acc55ba8SStefan Weil#endif
3526d2042378SAneesh Kumar K.VEOF
3527d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
3528d2042378SAneesh Kumar K.V    open_by_handle_at=yes
3529d2042378SAneesh Kumar K.Vfi
3530d2042378SAneesh Kumar K.V
3531e06a765eSHarsh Prateek Bora########################################
3532e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
3533e06a765eSHarsh Prateek Bora
3534e06a765eSHarsh Prateek Boralinux_magic_h=no
3535e06a765eSHarsh Prateek Boracat > $TMPC << EOF
3536e06a765eSHarsh Prateek Bora#include <linux/magic.h>
3537e06a765eSHarsh Prateek Boraint main(void) {
353875cafad7SStefan Weil  return 0;
3539e06a765eSHarsh Prateek Bora}
3540e06a765eSHarsh Prateek BoraEOF
3541e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
3542e06a765eSHarsh Prateek Bora    linux_magic_h=yes
3543e06a765eSHarsh Prateek Borafi
3544e06a765eSHarsh Prateek Bora
35458ab1bf12SLuiz Capitulino########################################
3546c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
3547c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
3548c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
3549c95e3080SKevin Wolf# only a warning.
3550c95e3080SKevin Wolf#
3551c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
3552c95e3080SKevin Wolf# the build doesn't fail anyway.
3553c95e3080SKevin Wolf
355406d71fa1SPeter Maydellpragma_disable_unused_but_set=no
355506d71fa1SPeter Maydellcat > $TMPC << EOF
3556e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
355706d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3558c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
3559e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
3560c95e3080SKevin Wolf
356106d71fa1SPeter Maydellint main(void) {
356206d71fa1SPeter Maydell    return 0;
356306d71fa1SPeter Maydell}
356406d71fa1SPeter MaydellEOF
356506d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
3566cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
3567c95e3080SKevin Wolfelse
3568c95e3080SKevin Wolf    werror=no
356906d71fa1SPeter Maydellfi
357006d71fa1SPeter Maydell
357106d71fa1SPeter Maydell########################################
357262fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
35733f4349dcSKevin Wolf
35743f4349dcSKevin Wolfvalgrind_h=no
35753f4349dcSKevin Wolfcat > $TMPC << EOF
35763f4349dcSKevin Wolf#include <valgrind/valgrind.h>
357762fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
35783f4349dcSKevin Wolfint main(void) {
35793f4349dcSKevin Wolf  return 0;
35803f4349dcSKevin Wolf}
35813f4349dcSKevin WolfEOF
35823f4349dcSKevin Wolfif compile_prog "" "" ; then
35833f4349dcSKevin Wolf    valgrind_h=yes
35843f4349dcSKevin Wolffi
35853f4349dcSKevin Wolf
35863f4349dcSKevin Wolf########################################
35878ab1bf12SLuiz Capitulino# check if environ is declared
35888ab1bf12SLuiz Capitulino
35898ab1bf12SLuiz Capitulinohas_environ=no
35908ab1bf12SLuiz Capitulinocat > $TMPC << EOF
35918ab1bf12SLuiz Capitulino#include <unistd.h>
35928ab1bf12SLuiz Capitulinoint main(void) {
3593c075a723SBlue Swirl    environ = 0;
35948ab1bf12SLuiz Capitulino    return 0;
35958ab1bf12SLuiz Capitulino}
35968ab1bf12SLuiz CapitulinoEOF
35978ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
35988ab1bf12SLuiz Capitulino    has_environ=yes
35998ab1bf12SLuiz Capitulinofi
36008ab1bf12SLuiz Capitulino
360176a347e1SRichard Henderson########################################
360276a347e1SRichard Henderson# check if cpuid.h is usable.
360376a347e1SRichard Henderson
360476a347e1SRichard Hendersoncpuid_h=no
360576a347e1SRichard Hendersoncat > $TMPC << EOF
360676a347e1SRichard Henderson#include <cpuid.h>
360776a347e1SRichard Hendersonint main(void) {
3608774d566cSPeter Maydell    unsigned a, b, c, d;
3609774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
3610774d566cSPeter Maydell
3611774d566cSPeter Maydell    if (max >= 1) {
3612774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
3613774d566cSPeter Maydell    }
3614774d566cSPeter Maydell
3615774d566cSPeter Maydell    if (max >= 7) {
3616774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
3617774d566cSPeter Maydell    }
3618774d566cSPeter Maydell
361976a347e1SRichard Henderson    return 0;
362076a347e1SRichard Henderson}
362176a347e1SRichard HendersonEOF
362276a347e1SRichard Hendersonif compile_prog "" "" ; then
362376a347e1SRichard Henderson    cpuid_h=yes
362476a347e1SRichard Hendersonfi
362576a347e1SRichard Henderson
3626f540166bSRichard Henderson########################################
3627f540166bSRichard Henderson# check if __[u]int128_t is usable.
3628f540166bSRichard Henderson
3629f540166bSRichard Hendersonint128=no
3630f540166bSRichard Hendersoncat > $TMPC << EOF
3631f540166bSRichard Henderson__int128_t a;
3632f540166bSRichard Henderson__uint128_t b;
3633f540166bSRichard Hendersonint main (void) {
3634f540166bSRichard Henderson  a = a + b;
3635f540166bSRichard Henderson  b = a * b;
3636464e3671SPeter Maydell  a = a * a;
3637f540166bSRichard Henderson  return 0;
3638f540166bSRichard Henderson}
3639f540166bSRichard HendersonEOF
3640f540166bSRichard Hendersonif compile_prog "" "" ; then
3641f540166bSRichard Henderson    int128=yes
3642f540166bSRichard Hendersonfi
364376a347e1SRichard Henderson
36441e6e9acaSRichard Henderson########################################
36451e6e9acaSRichard Henderson# check if getauxval is available.
36461e6e9acaSRichard Henderson
36471e6e9acaSRichard Hendersongetauxval=no
36481e6e9acaSRichard Hendersoncat > $TMPC << EOF
36491e6e9acaSRichard Henderson#include <sys/auxv.h>
36501e6e9acaSRichard Hendersonint main(void) {
36511e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
36521e6e9acaSRichard Henderson}
36531e6e9acaSRichard HendersonEOF
36541e6e9acaSRichard Hendersonif compile_prog "" "" ; then
36551e6e9acaSRichard Henderson    getauxval=yes
36561e6e9acaSRichard Hendersonfi
36571e6e9acaSRichard Henderson
3658d2042378SAneesh Kumar K.V##########################################
3659e86ecd4bSJuan Quintela# End of CC checks
3660e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3661e86ecd4bSJuan Quintela
36621d728c39SBlue Swirlif test "$gcov" = "yes" ; then
36631d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
36641d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
36651d728c39SBlue Swirlelif test "$debug" = "no" ; then
3666e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
3667e86ecd4bSJuan Quintelafi
3668a316e378SJuan Quintela
36696542aa9cSPeter Lieven##########################################
36706542aa9cSPeter Lieven# Do we have libnfs
36716542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
36726542aa9cSPeter Lieven  if $pkg_config --atleast-version=1.9.2 libnfs; then
36736542aa9cSPeter Lieven    libnfs="yes"
36746542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
36756542aa9cSPeter Lieven    LIBS="$LIBS $libnfs_libs"
36766542aa9cSPeter Lieven  else
36776542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
36786542aa9cSPeter Lieven      feature_not_found "libnfs"
36796542aa9cSPeter Lieven    fi
36806542aa9cSPeter Lieven    libnfs="no"
36816542aa9cSPeter Lieven  fi
36826542aa9cSPeter Lievenfi
36831d728c39SBlue Swirl
368420ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
368520ff6c80SAnthony Liguori# enable/disable
368620ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
368720ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
368820ff6c80SAnthony Liguori	zero_malloc="no"
368920ff6c80SAnthony Liguori    else
369020ff6c80SAnthony Liguori	zero_malloc="yes"
369120ff6c80SAnthony Liguori    fi
369220ff6c80SAnthony Liguorifi
369320ff6c80SAnthony Liguori
36946ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
36956ca026cbSPeter Maydellif test "$werror" = "yes"; then
36966ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
36976ca026cbSPeter Maydellfi
36986ca026cbSPeter Maydell
3699e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3700e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
37011156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3702e86ecd4bSJuan Quintela    fi
3703e86ecd4bSJuan Quintelafi
3704e86ecd4bSJuan Quintela
370594dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
370694dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
370794dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
370894dd53c5SGerd Hoffmannelse
370994dd53c5SGerd Hoffmann    POD2MAN="pod2man"
371094dd53c5SGerd Hoffmannfi
371194dd53c5SGerd Hoffmann
3712952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3713952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3714952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3715952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3716952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3717952afb71SBlue Swirl        fi
3718952afb71SBlue Swirl    done
3719952afb71SBlue Swirlfi
3720952afb71SBlue Swirl
372110ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3722528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
3723834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
37245a67135aSbellard
37254b1c11fdSDaniel P. Berrangetools=""
37264b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3727ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
37284b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
37294b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
37304b1c11fdSDaniel P. Berrange  fi
37314b1c11fdSDaniel P. Berrangefi
37324b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3733983eef5aSMeador Inge  if test "$virtfs" != no ; then
3734be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3735983eef5aSMeador Inge      virtfs=yes
373617bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3737983eef5aSMeador Inge    else
3738983eef5aSMeador Inge      if test "$virtfs" = yes; then
373976ad07a4SPeter Maydell        error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3740983eef5aSMeador Inge      fi
374117500370SAndreas Färber      virtfs=no
3742983eef5aSMeador Inge    fi
374317bff52bSM. Mohan Kumar  fi
3744d138cee9SMichael Rothfi
3745e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
3746b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
3747e8ef31a3SMichael Tokarev      tools="qemu-ga\$(EXESUF) $tools"
3748b39297aeSTomoki Sekiyama      if [ "$mingw32" = "yes" -a "$guest_agent_with_vss" = "yes" ]; then
3749b39297aeSTomoki Sekiyama        tools="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb $tools"
3750b39297aeSTomoki Sekiyama      fi
3751e8ef31a3SMichael Tokarev      guest_agent=yes
3752e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
3753e8ef31a3SMichael Tokarev      guest_agent=no
3754e8ef31a3SMichael Tokarev  else
3755e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
3756ca35f780SPaolo Bonzini  fi
37574b1c11fdSDaniel P. Berrangefi
3758ca35f780SPaolo Bonzini
3759ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3760ca35f780SPaolo Bonziniroms=
3761ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3762ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3763ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3764ca35f780SPaolo Bonzini  roms="optionrom"
3765ca35f780SPaolo Bonzinifi
3766d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
376739ac8455SDavid Gibson  roms="$roms spapr-rtas"
376839ac8455SDavid Gibsonfi
3769ca35f780SPaolo Bonzini
37709933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
37719933c305SChristian Borntraeger  roms="$roms s390-ccw"
37729933c305SChristian Borntraegerfi
37739933c305SChristian Borntraeger
3774964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
3775964c6fa1SRichard Hendersonif test "$pie" = "no" ; then
3776964c6fa1SRichard Henderson  textseg_addr=
3777964c6fa1SRichard Henderson  case "$cpu" in
3778c72b26ecSRichard Henderson    arm | hppa | i386 | m68k | ppc | ppc64 | s390* | sparc | sparc64 | x86_64 | x32)
3779964c6fa1SRichard Henderson      textseg_addr=0x60000000
3780964c6fa1SRichard Henderson      ;;
3781964c6fa1SRichard Henderson    mips)
3782964c6fa1SRichard Henderson      textseg_addr=0x400000
3783964c6fa1SRichard Henderson      ;;
3784964c6fa1SRichard Henderson  esac
3785964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
3786964c6fa1SRichard Henderson    cat > $TMPC <<EOF
3787964c6fa1SRichard Henderson    int main(void) { return 0; }
3788964c6fa1SRichard HendersonEOF
3789964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
3790964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
3791964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
3792964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
3793964c6fa1SRichard Henderson      # at least.
3794964c6fa1SRichard Henderson      $ld --verbose | sed \
3795964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
3796964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
3797964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
3798964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
3799964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
3800964c6fa1SRichard Henderson    fi
3801964c6fa1SRichard Henderson  fi
3802964c6fa1SRichard Hendersonfi
3803964c6fa1SRichard Henderson
38045ca9388aSGerd Hoffmann# add pixman flags after all config tests are done
3805a540f158SPeter CrosthwaiteQEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags"
38065ca9388aSGerd Hoffmannlibs_softmmu="$libs_softmmu $pixman_libs"
38075ca9388aSGerd Hoffmann
38087d13299dSbellardecho "Install prefix    $prefix"
3809c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3810f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
38113aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
38128bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
38130f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
38141c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
381511d9f695Sbellardif test "$mingw32" = "no" ; then
38165a699bbbSLaszlo Ersekecho "local state directory   `eval echo $local_statedir`"
3817f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
381843ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
38195a699bbbSLaszlo Ersekelse
38205a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
3821d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
382211d9f695Sbellardfi
38235a67135aSbellardecho "Source path       $source_path"
38247d13299dSbellardecho "C compiler        $cc"
382583469015Sbellardecho "Host C compiler   $host_cc"
382683f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
38273c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
382845d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
38290c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3830a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
38310c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
38327d13299dSbellardecho "make              $make"
38336a882643Spbrookecho "install           $install"
3834c886edfbSBlue Swirlecho "python            $python"
3835e2d8830eSBradif test "$slirp" = "yes" ; then
3836e2d8830eSBrad    echo "smbd              $smbd"
3837e2d8830eSBradfi
3838a98fd896Sbellardecho "host CPU          $cpu"
3839de83cd02Sbellardecho "host big endian   $bigendian"
384097a847bcSbellardecho "target list       $target_list"
3841ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
38427d13299dSbellardecho "gprof enabled     $gprof"
384303b4fe7dSaliguoriecho "sparse enabled    $sparse"
38441625af87Saliguoriecho "strip binaries    $strip_opt"
384505c2a3e7Sbellardecho "profiler          $profiler"
384643ce4dfeSbellardecho "static build      $static"
384785aa5189Sbellardecho "-Werror enabled   $werror"
38485b0753e0Sbellardif test "$darwin" = "yes" ; then
38495b0753e0Sbellard    echo "Cocoa support     $cocoa"
38505b0753e0Sbellardfi
3851e2134eb9SGerd Hoffmannecho "pixman            $pixman"
385297a847bcSbellardecho "SDL support       $sdl"
3853a4ccabcfSAnthony Liguoriecho "GTK support       $gtk"
38544d3b6f6eSbalrogecho "curses support    $curses"
3855769ce76dSAlexander Grafecho "curl support      $curl"
385667b915a5Sbellardecho "mingw32 support   $mingw32"
38570c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
3858b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
3859b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
3860983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3861821601eaSJes Sorensenecho "VNC support       $vnc"
3862821601eaSJes Sorensenif test "$vnc" = "yes" ; then
38638d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
38642f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
38652f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3866efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
38677536ee4bSTim Hardeck    echo "VNC WS support    $vnc_ws"
3868821601eaSJes Sorensenfi
38693142255cSblueswir1if test -n "$sparc_cpu"; then
38703142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
38713142255cSblueswir1fi
3872e37630caSaliguoriecho "xen support       $xen"
38732e4d9fb1Saurel32echo "brlapi support    $brlapi"
3874a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3875a25dba17SJuan Quintelaecho "Documentation     $docs"
3876c5937220Spbrook[ ! -z "$uname_release" ] && \
3877c5937220Spbrookecho "uname -r          $uname_release"
3878379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
387940d6444eSAvi Kivityecho "PIE               $pie"
38808a16d273Sthsecho "vde support       $vde"
388158952137SVincenzo Maffioneecho "netmap support    $netmap"
38825c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3883758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
388477755340Sthsecho "Install blobs     $blobs"
3885b31a0277SJuan Quintelaecho "KVM support       $kvm"
38862da776dbSMichael R. Hinesecho "RDMA support      $rdma"
38879195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3888f652e6afSaurel32echo "fdt support       $fdt"
3889ceb42de8Saliguoriecho "preadv support    $preadv"
38905f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3891e78815a5SAndreas Färberecho "madvise           $madvise"
3892e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
38931e9737daSRichard Hendersonecho "sigev_thread_id   $sigev_thread_id"
3894ee682d27SStefan Weilecho "uuid support      $uuid"
389547e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3896d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
38975e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
389894a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
38999410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
39002e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3901f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3902dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3903111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
39042b2325ffSGerd Hoffmannecho "libusb            $libusb"
390569354a83SHans de Goedeecho "usb net redir     $usb_redir"
3906b1e5fff4SMichael Walleecho "GLX support       $glx"
3907219c2521SStefan Weilif test "$libiscsi_version" = "1.4.0"; then
3908219c2521SStefan Weilecho "libiscsi support  $libiscsi (1.4.0)"
3909219c2521SStefan Weilelse
3910c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3911219c2521SStefan Weilfi
39126542aa9cSPeter Lievenecho "libnfs support    $libnfs"
3913d138cee9SMichael Rothecho "build guest agent $guest_agent"
3914d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
3915f794573eSEduardo Otuboecho "seccomp support   $seccomp"
39167c2acc70SPeter Maydellecho "coroutine backend $coroutine"
391770c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
3918eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
3919583f6e7bSStefan Hajnocziecho "virtio-blk-data-plane $virtio_blk_data_plane"
39201d728c39SBlue Swirlecho "gcov              $gcov_tool"
39211d728c39SBlue Swirlecho "gcov enabled      $gcov"
3922ab214c29SStefan Bergerecho "TPM support       $tpm"
39230a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
39243b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
39253556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
39264f18b782SJeff Codyecho "vhdx              $vhdx"
3927*95c6bff3SBenoît Canetecho "Quorum            $quorum"
392867b915a5Sbellard
39291ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
393024b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3931e8cd23deSbellardfi
393297a847bcSbellard
393398ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
393497a847bcSbellard
3935dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
3936dbd99ae3SStefan Weil
393798ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
393898ec69acSJuan Quintelaecho >> $config_host_mak
393998ec69acSJuan Quintela
3940e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
394199d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
394299d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
39433aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
39448bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
39450f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
394699d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
394799d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
394822d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
39499afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
39509afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
39515a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
3952785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
39535a699bbbSLaszlo Ersekfi
3954f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
3955f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
3956f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
3957834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
3958f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
3959804edf29SJuan Quintela
396098ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3961727e5283SPaolo Bonzini
3962f8393946Saurel32if test "$debug_tcg" = "yes" ; then
39632358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3964f8393946Saurel32fi
39651625af87Saliguoriif test "$strip_opt" = "yes" ; then
396652ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
39671625af87Saliguorifi
39687d13299dSbellardif test "$bigendian" = "yes" ; then
3969e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
397097a847bcSbellardfi
397167b915a5Sbellardif test "$mingw32" = "yes" ; then
397298ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
39739fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
39749fe6de94SBlue Swirl  version_major=${rc_version%%.*}
39759fe6de94SBlue Swirl  rc_version=${rc_version#*.}
39769fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
39779fe6de94SBlue Swirl  rc_version=${rc_version#*.}
39789fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
39799fe6de94SBlue Swirl  version_micro=0
39809fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
39819fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3982d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
3983d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
3984d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3985d9840e25STomoki Sekiyama  fi
3986210fa556Spbrookelse
398735f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3988210fa556Spbrookfi
3989128ab2ffSblueswir1
3990dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3991dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3992dffcb71cSMark McLoughlinfi
3993dffcb71cSMark McLoughlin
399483fb7adfSbellardif test "$darwin" = "yes" ; then
399598ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
399683fb7adfSbellardfi
3997b29fe3edSmalc
3998b29fe3edSmalcif test "$aix" = "yes" ; then
399998ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
4000b29fe3edSmalcfi
4001b29fe3edSmalc
4002ec530c81Sbellardif test "$solaris" = "yes" ; then
400398ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
40042358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
40050475a5caSths  if test "$needs_libsunmath" = "yes" ; then
400675b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
40070475a5caSths  fi
4008ec530c81Sbellardfi
4009179cf400SAndreas Färberif test "$haiku" = "yes" ; then
4010179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
4011179cf400SAndreas Färberfi
401297a847bcSbellardif test "$static" = "yes" ; then
401398ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
401497a847bcSbellardfi
40151ba16968SStefan Weilif test "$profiler" = "yes" ; then
40162358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
401705c2a3e7Sbellardfi
4018c20709aaSbellardif test "$slirp" = "yes" ; then
401998ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
4020e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
4021c20709aaSbellardfi
40228a16d273Sthsif test "$vde" = "yes" ; then
402398ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
40248a16d273Sthsfi
402558952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
402658952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
402758952137SVincenzo Maffionefi
402847e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
402947e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
403047e98658SCorey Bryantfi
40312358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
40320c58ac1cSmalcfor drv in $audio_drv_list; do
4033bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
403498ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
4035923e4521Smalc    if test "$drv" = "fmod"; then
40367aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
4037fb065187Sbellard    fi
40380c58ac1cSmalcdone
403967f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
404067f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
404167f86e8eSJuan Quintelafi
4042d5631638Smalcif test "$audio_win_int" = "yes" ; then
4043d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
4044d5631638Smalcfi
4045b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
4046b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
4047821601eaSJes Sorensenif test "$vnc" = "yes" ; then
4048821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
4049821601eaSJes Sorensenfi
40508d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
405198ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
40528d5d2d4cSthsfi
40532f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
405498ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
40552f9606b3Saliguorifi
4056821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
40572f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
40582f6f5c7aSCorentin Charyfi
4059821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
4060efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
4061efe556adSCorentin Charyfi
40627536ee4bSTim Hardeckif test "$vnc_ws" = "yes" ; then
40637536ee4bSTim Hardeck  echo "CONFIG_VNC_WS=y" >> $config_host_mak
40647536ee4bSTim Hardeck  echo "VNC_WS_CFLAGS=$vnc_ws_cflags" >> $config_host_mak
40657536ee4bSTim Hardeckfi
406676655d6dSaliguoriif test "$fnmatch" = "yes" ; then
40672358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
406876655d6dSaliguorifi
4069ee682d27SStefan Weilif test "$uuid" = "yes" ; then
4070ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
4071ee682d27SStefan Weilfi
4072dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
4073dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
4074dce512deSChristoph Hellwigfi
4075b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
407698ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
40772358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
407898ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
407998ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
4080a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
408198ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
4082cc8ae6deSpbrookfi
40831ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
408498ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
40858ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
408649ecc3faSbellardfi
408749ecc3faSbellardif test "$cocoa" = "yes" ; then
408898ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
408949ecc3faSbellardfi
40904d3b6f6eSbalrogif test "$curses" = "yes" ; then
409198ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
4092ab4e5602SJan Kiszkafi
4093ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
40942358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
4095ebc996f3SRiku Voipiofi
4096099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
40972358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
4098099d6b0fSRiku Voipiofi
409940ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
410040ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
410140ff6d7eSKevin Wolffi
41023ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
41032358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
41043ce34dfbSvibisreenivasanfi
4105c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
4106c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
4107c2882b96SRiku Voipiofi
4108d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
4109d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
4110d0927938SUlrich Hechtfi
41113d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
41123d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
41133d4fa43eSKusanagi Kouichifi
4114c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
4115c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
4116c727f47dSPeter Maydellfi
4117dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
4118dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
4119dace20dcSPeter Maydellfi
4120d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
4121d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
4122d0927938SUlrich Hechtfi
41234e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
41244e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
41254e0c6529SAlex Blighfi
4126cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
4127cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
4128cd758dd0SAlex Blighfi
41293b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
41303b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
41313b6edd16SPeter Maydellfi
41323b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
41333b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
41343b6edd16SPeter Maydellfi
41353b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
41363b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
41373b6edd16SPeter Maydellfi
4138a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
4139a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
4140a8fd1abaSPeter Maydellfi
41413b3f24adSaurel32if test "$inotify" = "yes" ; then
41422358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
41433b3f24adSaurel32fi
4144c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
4145c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
4146c05c7a73SRiku Voipiofi
41476ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
41486ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
41496ae9a1f4SJuan Quintelafi
41506ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
41516ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
41526ae9a1f4SJuan Quintelafi
4153769ce76dSAlexander Grafif test "$curl" = "yes" ; then
415498ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
4155b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
4156769ce76dSAlexander Graffi
41572e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
415898ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
41592e4d9fb1Saurel32fi
4160fb599c9aSbalrogif test "$bluez" = "yes" ; then
416198ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
4162ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
4163fb599c9aSbalrogfi
4164e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
4165a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
4166a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
4167a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
4168a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
4169a4ccabcfSAnthony Liguorifi
4170e37630caSaliguoriif test "$xen" = "yes" ; then
41716dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
4172d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
4173e37630caSaliguorifi
41745c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
41755c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
41765c6c3a6cSChristoph Hellwigfi
4177758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
4178758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
4179758e8e38SVenkateswararao Jujjuri (JV)fi
41804f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
41814f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
41824f26f2b6SAvi Kivityfi
4183983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
4184758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
4185758e8e38SVenkateswararao Jujjuri (JV)fi
41865e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
41875e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
41885e9be92dSNicholas Bellingerfi
418977755340Sthsif test "$blobs" = "yes" ; then
419098ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
419177755340Sthsfi
4192bf9298b9Saliguoriif test "$iovec" = "yes" ; then
41932358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
4194bf9298b9Saliguorifi
4195ceb42de8Saliguoriif test "$preadv" = "yes" ; then
41962358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
4197ceb42de8Saliguorifi
4198f652e6afSaurel32if test "$fdt" = "yes" ; then
41993f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
4200f652e6afSaurel32fi
4201dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
4202dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
4203dcc38d1cSMarcelo Tosattifi
42049195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
42059195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
42069195b2c2SStefan Weilfi
42075f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
42085f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
42095f6b9e8fSBlue Swirlfi
4210e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
4211e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
4212e78815a5SAndreas Färberfi
4213e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
4214e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
4215e78815a5SAndreas Färberfi
42161e9737daSRichard Hendersonif test "$sigev_thread_id" = "yes" ; then
42171e9737daSRichard Henderson  echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
42181e9737daSRichard Hendersonfi
421997a847bcSbellard
4220cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
4221cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
4222cd4ec0b4SGerd Hoffmannfi
4223cd4ec0b4SGerd Hoffmann
4224111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
4225111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
4226ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
4227ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
4228111a38b0SRobert Relyeafi
4229111a38b0SRobert Relyea
42302b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
42312b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
42322b2325ffSGerd Hoffmannfi
42332b2325ffSGerd Hoffmann
423469354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
423569354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
423669354a83SHans de Goedefi
423769354a83SHans de Goede
4238b1e5fff4SMichael Walleif test "$glx" = "yes" ; then
4239b1e5fff4SMichael Walle  echo "CONFIG_GLX=y" >> $config_host_mak
42402b6b7099SPaolo Bonzini  echo "GLX_LIBS=$glx_libs" >> $config_host_mak
424120ff075bSMichael Wallefi
424220ff075bSMichael Walle
4243c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
4244c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
4245219c2521SStefan Weil  if test "$libiscsi_version" = "1.4.0"; then
4246219c2521SStefan Weil    echo "CONFIG_LIBISCSI_1_4=y" >> $config_host_mak
4247219c2521SStefan Weil  fi
4248c589b249SRonnie Sahlbergfi
4249c589b249SRonnie Sahlberg
42506542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
42516542aa9cSPeter Lieven  echo "CONFIG_LIBNFS=y" >> $config_host_mak
42526542aa9cSPeter Lievenfi
42536542aa9cSPeter Lieven
4254f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
4255f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
4256f794573eSEduardo Otubofi
4257f794573eSEduardo Otubo
425883fb7adfSbellard# XXX: suppress that
42597d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
42602358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
42617d3505c5Sbellardfi
42627d3505c5Sbellard
42632358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
4264c5937220Spbrook
426520ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
426620ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
426720ff6c80SAnthony Liguorifi
42683556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
42693556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
42703556c233SPaolo Bonzinifi
4271f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
4272f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
4273f27aaf4bSChristian Brunnerfi
427420ff6c80SAnthony Liguori
42757c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
427670c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
427770c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
427870c60c08SStefan Hajnoczielse
427970c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
428070c60c08SStefan Hajnoczifi
4281d0e2fce5SAneesh Kumar K.V
4282d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
4283d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
4284d2042378SAneesh Kumar K.Vfi
4285d2042378SAneesh Kumar K.V
4286e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
4287e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
4288e06a765eSHarsh Prateek Borafi
4289e06a765eSHarsh Prateek Bora
4290cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
4291cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
429206d71fa1SPeter Maydellfi
429306d71fa1SPeter Maydell
42943f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
42953f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
42963f4349dcSKevin Wolffi
42973f4349dcSKevin Wolf
42988ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
42998ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
43008ab1bf12SLuiz Capitulinofi
43018ab1bf12SLuiz Capitulino
430276a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
430376a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
430476a347e1SRichard Hendersonfi
430576a347e1SRichard Henderson
4306f540166bSRichard Hendersonif test "$int128" = "yes" ; then
4307f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
4308f540166bSRichard Hendersonfi
4309f540166bSRichard Henderson
43101e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
43111e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
43121e6e9acaSRichard Hendersonfi
43131e6e9acaSRichard Henderson
4314eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
4315eb100396SBharata B Rao  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
4316eb100396SBharata B Raofi
4317eb100396SBharata B Rao
43180c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
43190c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
43200c14fb47SBharata B Raofi
43210c14fb47SBharata B Rao
43227c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
43237c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
43247c815372SBharata B Raofi
43257c815372SBharata B Rao
43260a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
43270a12ec87SRichard W.M. Jones  echo "CONFIG_LIBSSH2=y" >> $config_host_mak
43280a12ec87SRichard W.M. Jonesfi
43290a12ec87SRichard W.M. Jones
4330*95c6bff3SBenoît Canetif test "$quorum" = "yes" ; then
4331*95c6bff3SBenoît Canet  echo "CONFIG_QUORUM=y" >> $config_host_mak
4332*95c6bff3SBenoît Canetfi
4333*95c6bff3SBenoît Canet
4334583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" ; then
43356e790746SPaolo Bonzini  echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
4336583f6e7bSStefan Hajnoczifi
4337583f6e7bSStefan Hajnoczi
43384f18b782SJeff Codyif test "$vhdx" = "yes" ; then
43394f18b782SJeff Cody  echo "CONFIG_VHDX=y" >> $config_host_mak
43404f18b782SJeff Codyfi
43414f18b782SJeff Cody
434268063649Sblueswir1# USB host support
4343b5613fdcSGerd Hoffmannif test "$libusb" = "yes"; then
43442b2325ffSGerd Hoffmann  echo "HOST_USB=libusb legacy" >> $config_host_mak
4345b5613fdcSGerd Hoffmannelse
434698ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
4347b5613fdcSGerd Hoffmannfi
434868063649Sblueswir1
43493b8acc11SPaolo Bonzini# TPM passthrough support?
43503b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
43513b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
43523b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
43533b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
43543b8acc11SPaolo Bonzini  fi
43553b8acc11SPaolo Bonzinifi
43563b8acc11SPaolo Bonzini
4357e4858974SLluís# use default implementation for tracing backend-specific routines
4358e4858974SLluístrace_default=yes
435994a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
43606d8a764eSLluísif test "$trace_backend" = "nop"; then
43616d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
436222890ab5SPrerna Saxenafi
43639410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
43646d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
4365e4858974SLluís  trace_default=no
43666d8a764eSLluís  # Set the appropriate trace file.
4367953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
43689410b56cSPrerna Saxenafi
43696d8a764eSLluísif test "$trace_backend" = "stderr"; then
43706d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
43719a82b6a5SLluís  trace_default=no
43726d8a764eSLluísfi
43736d8a764eSLluísif test "$trace_backend" = "ust"; then
43746d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
43756d8a764eSLluísfi
43766d8a764eSLluísif test "$trace_backend" = "dtrace"; then
43776d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
43786d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
43796d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
43806d8a764eSLluís  fi
4381c276b17dSDaniel P. Berrangefi
4382781e9545SEiichi Tsukataif test "$trace_backend" = "ftrace"; then
4383781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
4384781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4385781e9545SEiichi Tsukata    trace_default=no
4386781e9545SEiichi Tsukata  else
438721684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
4388781e9545SEiichi Tsukata  fi
4389781e9545SEiichi Tsukatafi
43909410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
4391e4858974SLluísif test "$trace_default" = "yes"; then
4392e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
4393e4858974SLluísfi
43949410b56cSPrerna Saxena
43952da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
43962da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
43972da776dbSMichael R. Hinesfi
43982da776dbSMichael R. Hines
43995b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
44005b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
44015b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
44025b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
44035b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
44045b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
4405c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
44065b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
44075b5e3037SPaolo Bonzinielse
44085b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
44095b5e3037SPaolo Bonzinifi
44105b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
44115b5e3037SPaolo Bonzini
441298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
441398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4414804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4415804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
44161901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
44171901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
441821655882SPaolo Bonziniif test -n "$libtool"; then
441921655882SPaolo Bonzini  echo "INSTALL_PROG=\$(LIBTOOL) --mode=install $install -c -m 0755" >> $config_host_mak
442021655882SPaolo Bonzini  echo "INSTALL_LIB=\$(LIBTOOL) --mode=install $install -c -m 0644" >> $config_host_mak
442121655882SPaolo Bonzinielse
44221901cb14SBrad  echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
442321655882SPaolo Bonzini  echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
442421655882SPaolo Bonzinifi
4425c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
4426804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
4427a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
4428a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
4429a31a8642SMichael S. Tsirkinfi
44302b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
4431804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
443283f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
44333c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
4434804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
443545d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
44363dd46c78SBlue Swirlecho "AS=$as" >> $config_host_mak
44373dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4438804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4439804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
44409fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
444144dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
4442e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
444346eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
4444a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
4445f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
4446e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
4447e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
4448e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
4449e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
4450e39f0062SPaolo Bonzinifi
445142da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
445242da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
445342da6041SGerd Hoffmannelse
445442da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
445542da6041SGerd Hoffmannfi
4456e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
445746eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
445837746c5eSMarc-André Lureauecho "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
445973da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
44603e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
4461804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
4462957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
446394dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
4464cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
44651d728c39SBlue Swirlif test "$gcov" = "yes" ; then
44661d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
44671d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
44681d728c39SBlue Swirlfi
4469804edf29SJuan Quintela
44706efd7517SPeter Maydell# use included Linux headers
44716efd7517SPeter Maydellif test "$linux" = "yes" ; then
4472a307beb6SAndreas Färber  mkdir -p linux-headers
44736efd7517SPeter Maydell  case "$cpu" in
4474c72b26ecSRichard Henderson  i386|x86_64|x32)
447508312a63SPeter Maydell    linux_arch=x86
44766efd7517SPeter Maydell    ;;
44776efd7517SPeter Maydell  ppcemb|ppc|ppc64)
447808312a63SPeter Maydell    linux_arch=powerpc
44796efd7517SPeter Maydell    ;;
44806efd7517SPeter Maydell  s390x)
448108312a63SPeter Maydell    linux_arch=s390
448208312a63SPeter Maydell    ;;
44831f080313SClaudio Fontana  aarch64)
44841f080313SClaudio Fontana    linux_arch=arm64
44851f080313SClaudio Fontana    ;;
448608312a63SPeter Maydell  *)
448708312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
448808312a63SPeter Maydell    linux_arch="$cpu"
44896efd7517SPeter Maydell    ;;
44906efd7517SPeter Maydell  esac
449108312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
449208312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
449308312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
449408312a63SPeter Maydell    fi
44956efd7517SPeter Maydellfi
44966efd7517SPeter Maydell
449797a847bcSbellardfor target in $target_list; do
449897a847bcSbellardtarget_dir="$target"
449925be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
4500c1799a84SPaolo Bonzinitarget_name=`echo $target | cut -d '-' -f 1`
450197a847bcSbellardtarget_bigendian="no"
45021f3d3c8fSJuan Quintela
4503c1799a84SPaolo Bonzinicase "$target_name" in
4504d15a9c23SAnthony Green  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
4505ea2d6a39SJuan Quintela  target_bigendian=yes
4506ea2d6a39SJuan Quintela  ;;
4507ea2d6a39SJuan Quintelaesac
450897a847bcSbellardtarget_softmmu="no"
4509997344f3Sbellardtarget_user_only="no"
4510831b7825Sthstarget_linux_user="no"
451184778508Sblueswir1target_bsd_user="no"
45129e407a85Spbrookcase "$target" in
4513c1799a84SPaolo Bonzini  ${target_name}-softmmu)
45149e407a85Spbrook    target_softmmu="yes"
45159e407a85Spbrook    ;;
4516c1799a84SPaolo Bonzini  ${target_name}-linux-user)
45179c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
451876ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a Linux host"
45199c7a4202SBlue Swirl    fi
45209e407a85Spbrook    target_user_only="yes"
45219e407a85Spbrook    target_linux_user="yes"
45229e407a85Spbrook    ;;
4523c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
45249cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
452576ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a BSD host"
45269c7a4202SBlue Swirl    fi
452784778508Sblueswir1    target_user_only="yes"
452884778508Sblueswir1    target_bsd_user="yes"
452984778508Sblueswir1    ;;
45309e407a85Spbrook  *)
453176ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
45329e407a85Spbrook    exit 1
45339e407a85Spbrook    ;;
45349e407a85Spbrookesac
4535831b7825Sths
453697a847bcSbellardmkdir -p $target_dir
453725be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
453897a847bcSbellard
4539e5fe0c52Spbrookbflt="no"
4540c1799a84SPaolo Bonziniinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"`
454156aebc89Spbrookgdb_xml_files=""
45427ba1e619Saliguori
4543c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
45446acff7daSJuan QuintelaTARGET_BASE_ARCH=""
4545e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
4546e73aae67SJuan Quintela
4547c1799a84SPaolo Bonzinicase "$target_name" in
45482408a527Saurel32  i386)
45492408a527Saurel32  ;;
45502408a527Saurel32  x86_64)
45516acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
45522408a527Saurel32  ;;
45532408a527Saurel32  alpha)
45542408a527Saurel32  ;;
45552408a527Saurel32  arm|armeb)
4556b498c8a0SJuan Quintela    TARGET_ARCH=arm
4557e5fe0c52Spbrook    bflt="yes"
455856aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
45592408a527Saurel32  ;;
45606a49fa95SAlexander Graf  aarch64)
45616a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
45626a49fa95SAlexander Graf    bflt="yes"
45636a669427SPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml"
45646a49fa95SAlexander Graf  ;;
45652408a527Saurel32  cris)
45662408a527Saurel32  ;;
4567613a22c9SMichael Walle  lm32)
4568613a22c9SMichael Walle  ;;
45692408a527Saurel32  m68k)
45700938cda5Saurel32    bflt="yes"
457156aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
45722408a527Saurel32  ;;
4573877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
4574877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
457572b675caSEdgar E. Iglesias    bflt="yes"
457672b675caSEdgar E. Iglesias  ;;
45772408a527Saurel32  mips|mipsel)
4578b498c8a0SJuan Quintela    TARGET_ARCH=mips
457925be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
45802408a527Saurel32  ;;
45812408a527Saurel32  mipsn32|mipsn32el)
4582597e2cecSRichard Henderson    TARGET_ARCH=mips64
45836acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
458425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
4585597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
45862408a527Saurel32  ;;
45872408a527Saurel32  mips64|mips64el)
4588b498c8a0SJuan Quintela    TARGET_ARCH=mips64
45896acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
459025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
45912408a527Saurel32  ;;
4592d15a9c23SAnthony Green  moxie)
4593d15a9c23SAnthony Green  ;;
4594e67db06eSJia Liu  or32)
4595e67db06eSJia Liu    TARGET_ARCH=openrisc
4596e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
4597e67db06eSJia Liu  ;;
45982408a527Saurel32  ppc)
4599c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
46002408a527Saurel32  ;;
46012408a527Saurel32  ppcemb)
46026acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4603e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4604c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
46052408a527Saurel32  ;;
46062408a527Saurel32  ppc64)
46076acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4608e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4609c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
46102408a527Saurel32  ;;
46112408a527Saurel32  ppc64abi32)
4612b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
46136acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4614e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
461525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
4616c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
46172408a527Saurel32  ;;
46182408a527Saurel32  sh4|sh4eb)
4619b498c8a0SJuan Quintela    TARGET_ARCH=sh4
46204dbed897Spbrook    bflt="yes"
46212408a527Saurel32  ;;
46222408a527Saurel32  sparc)
46232408a527Saurel32  ;;
46242408a527Saurel32  sparc64)
46256acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
46262408a527Saurel32  ;;
46272408a527Saurel32  sparc32plus)
4628b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
46296acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
4630e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
463125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
46322408a527Saurel32  ;;
463324e804ecSAlexander Graf  s390x)
463424e804ecSAlexander Graf  ;;
4635d2fbca94SGuan Xuetao  unicore32)
4636d2fbca94SGuan Xuetao  ;;
4637cfa550c6SMax Filippov  xtensa|xtensaeb)
4638cfa550c6SMax Filippov    TARGET_ARCH=xtensa
4639cfa550c6SMax Filippov  ;;
46402408a527Saurel32  *)
464176ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
46422408a527Saurel32  ;;
46432408a527Saurel32esac
46445e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
46455e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
46465e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
46475e8861a0SPaolo Bonzinifi
46485e8861a0SPaolo Bonzini
46495e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
46505e8861a0SPaolo Bonzini
465199afc91dSDaniel P. Berrangeupper() {
465299afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
465399afc91dSDaniel P. Berrange}
465499afc91dSDaniel P. Berrange
465599afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
465625be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
4657c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
465825be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
4659e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
4660e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
4661e6e91b9cSJuan Quintelafi
466225be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
4663c1799a84SPaolo Bonzinicase "$target_name" in
46641b0c87fcSJuan Quintela  i386|x86_64)
46651b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
466625be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
4667eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
4668eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
4669eb6fda0fSAnthony PERARD      fi
4670432d268cSJun Nakajima    fi
467159d21e53SAlexander Graf    ;;
467259d21e53SAlexander Graf  *)
46731b0c87fcSJuan Quintelaesac
4674c1799a84SPaolo Bonzinicase "$target_name" in
467570a5f682SPeter Maydell  aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x)
4676c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
4677c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
4678c1799a84SPaolo Bonzini      \( "$target_name" = "$cpu" -o \
4679c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
4680c1799a84SPaolo Bonzini      \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
4681c1799a84SPaolo Bonzini      \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
4682c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
4683c1799a84SPaolo Bonzini      \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
4684c1799a84SPaolo Bonzini      \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
468525be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
46861ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
4687d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
4688d5970055SMichael S. Tsirkin      fi
4689c59249f9SJuan Quintela    fi
4690c59249f9SJuan Quintelaesac
4691de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
469225be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
469397a847bcSbellardfi
469497a847bcSbellardif test "$target_softmmu" = "yes" ; then
469525be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
4696de83cd02Sbellardfi
4697997344f3Sbellardif test "$target_user_only" = "yes" ; then
469825be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
4699a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
4700997344f3Sbellardfi
4701831b7825Sthsif test "$target_linux_user" = "yes" ; then
470225be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
4703831b7825Sthsfi
470456aebc89Spbrooklist=""
470556aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
470656aebc89Spbrook  for x in $gdb_xml_files; do
470756aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
470856aebc89Spbrook  done
470925be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
47103d0f1517SJuan Quintelafi
4711de83cd02Sbellard
4712e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
471325be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
4714e5fe0c52Spbrookfi
4715379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
471625be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
4717379f6698SPaul Brookfi
471884778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
471925be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
472084778508Sblueswir1fi
47215b0753e0Sbellard
47224afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
4723fa282484SJuan Quintela
47244afddb55SJuan Quintelacflags=""
4725fa282484SJuan Quintelaldflags=""
47269b8e111fSJuan Quintela
472764656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
472864656024SJuan Quintela  case "$i" in
472964656024SJuan Quintela  alpha)
473025be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
473176cad711SPaolo Bonzini    echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
473264656024SJuan Quintela  ;;
473364656024SJuan Quintela  arm)
473425be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
473576cad711SPaolo Bonzini    echo "CONFIG_ARM_DIS=y"  >> config-all-disas.mak
4736999b53ecSClaudio Fontana    if test -n "${cxx}"; then
4737999b53ecSClaudio Fontana      echo "CONFIG_ARM_A64_DIS=y"  >> $config_target_mak
4738999b53ecSClaudio Fontana      echo "CONFIG_ARM_A64_DIS=y"  >> config-all-disas.mak
4739999b53ecSClaudio Fontana    fi
474064656024SJuan Quintela  ;;
474164656024SJuan Quintela  cris)
474225be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
474376cad711SPaolo Bonzini    echo "CONFIG_CRIS_DIS=y"  >> config-all-disas.mak
474464656024SJuan Quintela  ;;
474564656024SJuan Quintela  hppa)
474625be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
474776cad711SPaolo Bonzini    echo "CONFIG_HPPA_DIS=y"  >> config-all-disas.mak
474864656024SJuan Quintela  ;;
4749c72b26ecSRichard Henderson  i386|x86_64|x32)
475025be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
475176cad711SPaolo Bonzini    echo "CONFIG_I386_DIS=y"  >> config-all-disas.mak
475264656024SJuan Quintela  ;;
4753903ec55cSAurelien Jarno  ia64*)
4754903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
475576cad711SPaolo Bonzini    echo "CONFIG_IA64_DIS=y"  >> config-all-disas.mak
4756903ec55cSAurelien Jarno  ;;
475779368f49SMichael Walle  lm32)
475879368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
475976cad711SPaolo Bonzini    echo "CONFIG_LM32_DIS=y"  >> config-all-disas.mak
476079368f49SMichael Walle  ;;
476164656024SJuan Quintela  m68k)
476225be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
476376cad711SPaolo Bonzini    echo "CONFIG_M68K_DIS=y"  >> config-all-disas.mak
476464656024SJuan Quintela  ;;
4765877fdc12SEdgar E. Iglesias  microblaze*)
476625be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
476776cad711SPaolo Bonzini    echo "CONFIG_MICROBLAZE_DIS=y"  >> config-all-disas.mak
476864656024SJuan Quintela  ;;
476964656024SJuan Quintela  mips*)
477025be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
477176cad711SPaolo Bonzini    echo "CONFIG_MIPS_DIS=y"  >> config-all-disas.mak
477264656024SJuan Quintela  ;;
4773d15a9c23SAnthony Green  moxie*)
4774d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> $config_target_mak
4775d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> config-all-disas.mak
4776d15a9c23SAnthony Green  ;;
4777e67db06eSJia Liu  or32)
4778e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
477976cad711SPaolo Bonzini    echo "CONFIG_OPENRISC_DIS=y"  >> config-all-disas.mak
4780e67db06eSJia Liu  ;;
478164656024SJuan Quintela  ppc*)
478225be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
478376cad711SPaolo Bonzini    echo "CONFIG_PPC_DIS=y"  >> config-all-disas.mak
478464656024SJuan Quintela  ;;
478524e804ecSAlexander Graf  s390*)
478625be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
478776cad711SPaolo Bonzini    echo "CONFIG_S390_DIS=y"  >> config-all-disas.mak
478864656024SJuan Quintela  ;;
478964656024SJuan Quintela  sh4)
479025be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
479176cad711SPaolo Bonzini    echo "CONFIG_SH4_DIS=y"  >> config-all-disas.mak
479264656024SJuan Quintela  ;;
479364656024SJuan Quintela  sparc*)
479425be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
479576cad711SPaolo Bonzini    echo "CONFIG_SPARC_DIS=y"  >> config-all-disas.mak
479664656024SJuan Quintela  ;;
4797cfa550c6SMax Filippov  xtensa*)
4798cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
479976cad711SPaolo Bonzini    echo "CONFIG_XTENSA_DIS=y"  >> config-all-disas.mak
4800cfa550c6SMax Filippov  ;;
480164656024SJuan Quintela  esac
480264656024SJuan Quinteladone
48039195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
48049195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
480576cad711SPaolo Bonzini  echo "CONFIG_TCI_DIS=y"  >> config-all-disas.mak
48069195b2c2SStefan Weilfi
480764656024SJuan Quintela
48086ee7126fSJuan Quintelacase "$ARCH" in
48096ee7126fSJuan Quintelaalpha)
48106ee7126fSJuan Quintela  # Ensure there's only a single GP
48116ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
48126ee7126fSJuan Quintela;;
48136ee7126fSJuan Quintelaesac
48146ee7126fSJuan Quintela
4815d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
481625be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4817d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4818d02c1db3SJuan Quintela    cflags="-p $cflags"
4819d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4820d02c1db3SJuan Quintela  fi
4821d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4822d02c1db3SJuan Quintela    ldflags="-p $ldflags"
482325be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4824d02c1db3SJuan Quintela  fi
4825d02c1db3SJuan Quintelafi
4826d02c1db3SJuan Quintela
48279b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4828964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
4829fa282484SJuan Quintelafi
4830fa282484SJuan Quintela
483125be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
483225be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4833fa282484SJuan Quintela
483497a847bcSbellarddone # for target in $targets
48357d13299dSbellard
4836b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
4837b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
4838b776eca1SGerd Hoffmannfi
4839b776eca1SGerd Hoffmann
48402da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
48412da776dbSMichael R. Hinesecho "CONFIG_RDMA=y" >> $config_host_mak
48422da776dbSMichael R. Hinesfi
48432da776dbSMichael R. Hines
4844a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
4845a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
4846a540f158SPeter Crosthwaitefi
4847a540f158SPeter Crosthwaite
4848d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
4849f93296eaSWenchao XiaDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
48502b170effSMichael TokarevDIRS="$DIRS fsdev"
48519933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
48522d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
48532dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
4854c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4855c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
4856aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
4857ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4858446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
48599933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
48602d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
48614652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
4862753d11f2SRichard Hendersonfor bios_file in \
4863753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
48645acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
4865753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4866753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4867e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
4868753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4869753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4870753d11f2SRichard Hendersondo
48717ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
48727ea78b74SJan Kiszkadone
4873c2304b52SMarcel Apfelbaumfor test_file in `find $source_path/tests/acpi-test-data -type f`
4874c2304b52SMarcel Apfelbaumdo
4875c2304b52SMarcel Apfelbaum    FILES="$FILES tests/acpi-test-data`echo $test_file | sed -e 's/.*acpi-test-data//'`"
4876c2304b52SMarcel Apfelbaumdone
4877d1807a4fSPaolo Bonzinimkdir -p $DIRS
48787d13299dSbellardfor f in $FILES ; do
487972b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4880f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4881f9245e10SPeter Maydell    fi
48827d13299dSbellarddone
48831ad2134fSPaul Brook
4884c34ebfdcSAnthony Liguori# temporary config to build submodules
48852d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4886c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
488737116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4888c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
48893dd46c78SBlue Swirl    echo "AS=$as" >> $config_mak
4890c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4891c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
48923dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
4893c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4894a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
4895c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4896c34ebfdcSAnthony Liguoridone
4897c34ebfdcSAnthony Liguori
4898b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4899b40292e7SJan Kiszka  mkdir -p QMP
4900b40292e7SJan Kiszkafi
4901