xref: /openbmc/qemu/configure (revision a3f4d63d)
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"
1566518bf6SDon SlutzTMPB="qemu-conf-${RANDOM}-$$-${RANDOM}"
1666518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
179c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
1866518bf6SDon SlutzTMPL="${TMPDIR1}/${TMPB}.lo"
1966518bf6SDon SlutzTMPA="${TMPDIR1}/lib${TMPB}.la"
20a91b857cSmalcTMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
217d13299dSbellard
220ba8681eSLoïc Minier# NB: do not call "exit" in the trap handler; this is buggy with some shells;
230ba8681eSLoïc Minier# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
249c83ffd8SPeter Maydelltrap "rm -f $TMPC $TMPO $TMPCXX $TMPE" EXIT INT QUIT TERM
25da1d85e3SGerd Hoffmannrm -f config.log
269ac81bbbSmalc
27b48e3611SPeter Maydell# Print a helpful header at the top of config.log
28b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
29979ae168SPeter Maydellprintf "# Configured with:" >> config.log
30979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
31979ae168SPeter Maydellecho >> config.log
32b48e3611SPeter Maydellecho "#" >> config.log
33b48e3611SPeter Maydell
3476ad07a4SPeter Maydellerror_exit() {
3576ad07a4SPeter Maydell    echo
3676ad07a4SPeter Maydell    echo "ERROR: $1"
3776ad07a4SPeter Maydell    while test -n "$2"; do
3876ad07a4SPeter Maydell        echo "       $2"
3976ad07a4SPeter Maydell        shift
4076ad07a4SPeter Maydell    done
4176ad07a4SPeter Maydell    echo
4276ad07a4SPeter Maydell    exit 1
4376ad07a4SPeter Maydell}
4476ad07a4SPeter Maydell
459c83ffd8SPeter Maydelldo_compiler() {
469c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
479c83ffd8SPeter Maydell    # is compiler binary to execute.
489c83ffd8SPeter Maydell    local compiler="$1"
499c83ffd8SPeter Maydell    shift
509c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
519c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
528dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
538dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
548dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
558dc38a78SPeter Maydell    # obvious to developers.
568dc38a78SPeter Maydell    if test "$werror" != "yes"; then
578dc38a78SPeter Maydell        return 0
588dc38a78SPeter Maydell    fi
598dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
608dc38a78SPeter Maydell    case "$*" in
618dc38a78SPeter Maydell        *-Werror*)
628dc38a78SPeter Maydell           return 0
638dc38a78SPeter Maydell        ;;
648dc38a78SPeter Maydell    esac
659c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
669c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
6776ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
6876ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
6976ad07a4SPeter Maydell        "will be at the bottom of config.log." \
7076ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
718dc38a78SPeter Maydell}
728dc38a78SPeter Maydell
739c83ffd8SPeter Maydelldo_cc() {
749c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
759c83ffd8SPeter Maydell}
769c83ffd8SPeter Maydell
779c83ffd8SPeter Maydelldo_cxx() {
789c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
799c83ffd8SPeter Maydell}
809c83ffd8SPeter Maydell
819c83ffd8SPeter Maydellupdate_cxxflags() {
829c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
839c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
849c83ffd8SPeter Maydell    # because they only make sense for C programs.
859c83ffd8SPeter Maydell    QEMU_CXXFLAGS=
869c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
879c83ffd8SPeter Maydell        case $arg in
889c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
899c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
909c83ffd8SPeter Maydell                ;;
919c83ffd8SPeter Maydell            *)
929c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
939c83ffd8SPeter Maydell                ;;
949c83ffd8SPeter Maydell        esac
959c83ffd8SPeter Maydell    done
969c83ffd8SPeter Maydell}
979c83ffd8SPeter Maydell
9852166aa0SJuan Quintelacompile_object() {
998dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
10052166aa0SJuan Quintela}
10152166aa0SJuan Quintela
10252166aa0SJuan Quintelacompile_prog() {
10352166aa0SJuan Quintela  local_cflags="$1"
10452166aa0SJuan Quintela  local_ldflags="$2"
1058dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
10652166aa0SJuan Quintela}
10752166aa0SJuan Quintela
10866518bf6SDon Slutzdo_libtool() {
10966518bf6SDon Slutz    local mode=$1
11066518bf6SDon Slutz    shift
11166518bf6SDon Slutz    # Run the compiler, capturing its output to the log.
11266518bf6SDon Slutz    echo $libtool $mode --tag=CC $cc "$@" >> config.log
11366518bf6SDon Slutz    $libtool $mode --tag=CC $cc "$@" >> config.log 2>&1 || return $?
11466518bf6SDon Slutz    # Test passed. If this is an --enable-werror build, rerun
11566518bf6SDon Slutz    # the test with -Werror and bail out if it fails. This
11666518bf6SDon Slutz    # makes warning-generating-errors in configure test code
11766518bf6SDon Slutz    # obvious to developers.
11866518bf6SDon Slutz    if test "$werror" != "yes"; then
11966518bf6SDon Slutz        return 0
12066518bf6SDon Slutz    fi
12166518bf6SDon Slutz    # Don't bother rerunning the compile if we were already using -Werror
12266518bf6SDon Slutz    case "$*" in
12366518bf6SDon Slutz        *-Werror*)
12466518bf6SDon Slutz           return 0
12566518bf6SDon Slutz        ;;
12666518bf6SDon Slutz    esac
12766518bf6SDon Slutz    echo $libtool $mode --tag=CC $cc -Werror "$@" >> config.log
12866518bf6SDon Slutz    $libtool $mode --tag=CC $cc -Werror "$@" >> config.log 2>&1 && return $?
12966518bf6SDon Slutz    error_exit "configure test passed without -Werror but failed with -Werror." \
13066518bf6SDon Slutz        "This is probably a bug in the configure script. The failing command" \
13166518bf6SDon Slutz        "will be at the bottom of config.log." \
13266518bf6SDon Slutz        "You can run configure with --disable-werror to bypass this check."
13366518bf6SDon Slutz}
13466518bf6SDon Slutz
13566518bf6SDon Slutzlibtool_prog() {
13666518bf6SDon Slutz    do_libtool --mode=compile $QEMU_CFLAGS -c -fPIE -DPIE -o $TMPO $TMPC || return $?
13766518bf6SDon Slutz    do_libtool --mode=link $LDFLAGS -o $TMPA $TMPL -rpath /usr/local/lib
13866518bf6SDon Slutz}
13966518bf6SDon Slutz
14011568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
14111568d6dSPaolo Bonzinisymlink() {
14272b8b5a1SStefan Weil  rm -rf "$2"
143ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
14472b8b5a1SStefan Weil  ln -s "$1" "$2"
14511568d6dSPaolo Bonzini}
14611568d6dSPaolo Bonzini
1470dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1480dba6195SLoïc Minier# executable or a builtin)
1490dba6195SLoïc Minierhas() {
1500dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1510dba6195SLoïc Minier}
1520dba6195SLoïc Minier
1530dba6195SLoïc Minier# search for an executable in PATH
1540dba6195SLoïc Minierpath_of() {
1550dba6195SLoïc Minier    local_command="$1"
1560dba6195SLoïc Minier    local_ifs="$IFS"
1570dba6195SLoïc Minier    local_dir=""
1580dba6195SLoïc Minier
1590dba6195SLoïc Minier    # pathname has a dir component?
1600dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1610dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1620dba6195SLoïc Minier            echo "$local_command"
1630dba6195SLoïc Minier            return 0
1640dba6195SLoïc Minier        fi
1650dba6195SLoïc Minier    fi
1660dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1670dba6195SLoïc Minier        return 1
1680dba6195SLoïc Minier    fi
1690dba6195SLoïc Minier
1700dba6195SLoïc Minier    IFS=:
1710dba6195SLoïc Minier    for local_dir in $PATH; do
1720dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1730dba6195SLoïc Minier            echo "$local_dir/$local_command"
1740dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1750dba6195SLoïc Minier            return 0
1760dba6195SLoïc Minier        fi
1770dba6195SLoïc Minier    done
1780dba6195SLoïc Minier    # not found
1790dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1800dba6195SLoïc Minier    return 1
1810dba6195SLoïc Minier}
1820dba6195SLoïc Minier
1837d13299dSbellard# default parameters
184ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
1852ff6b91eSJuan Quintelacpu=""
186a31a8642SMichael S. Tsirkiniasl="iasl"
1871e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
18843ce4dfeSbellardstatic="no"
1897d13299dSbellardcross_prefix=""
1900c58ac1cSmalcaudio_drv_list=""
191b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
192b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
193e49d021eSPeter Maydellhost_cc="cc"
19473da375eSJuan Quintelalibs_softmmu=""
1953e2e0e6bSJuan Quintelalibs_tools=""
19667f86e8eSJuan Quintelaaudio_pt_int=""
197d5631638Smalcaudio_win_int=""
1982b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
199957f1f99SMichael Rothlibs_qga=""
2005bc62e01SGerd Hoffmanndebug_info="yes"
20163678e17SSteven Noonanstack_protector=""
202ac0df51dSaliguori
203afb63ebdSStefan Weil# Don't accept a target_list environment variable.
204afb63ebdSStefan Weilunset target_list
205377529c0SPaolo Bonzini
206377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
207377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
208377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
209377529c0SPaolo Bonzini#              unless --disable-foo is given
210377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
211377529c0SPaolo Bonzini#              feature will searched for,
212377529c0SPaolo Bonzini#              if not found, configure exits with error
213377529c0SPaolo Bonzini#
214377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
215377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
216377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
217377529c0SPaolo Bonzini
218377529c0SPaolo Bonzinibluez=""
219377529c0SPaolo Bonzinibrlapi=""
220377529c0SPaolo Bonzinicurl=""
221377529c0SPaolo Bonzinicurses=""
222377529c0SPaolo Bonzinidocs=""
223377529c0SPaolo Bonzinifdt=""
22458952137SVincenzo Maffionenetmap="no"
225e2134eb9SGerd Hoffmannpixman=""
226377529c0SPaolo Bonzinisdl=""
22747c03744SDave Airliesdlabi="1.2"
228983eef5aSMeador Ingevirtfs=""
229821601eaSJes Sorensenvnc="yes"
230377529c0SPaolo Bonzinisparse="no"
231377529c0SPaolo Bonziniuuid=""
232377529c0SPaolo Bonzinivde=""
233377529c0SPaolo Bonzinivnc_tls=""
234377529c0SPaolo Bonzinivnc_sasl=""
235377529c0SPaolo Bonzinivnc_jpeg=""
236377529c0SPaolo Bonzinivnc_png=""
2377536ee4bSTim Hardeckvnc_ws=""
238377529c0SPaolo Bonzinixen=""
239d5b93ddfSAnthony PERARDxen_ctrl_version=""
240eb6fda0fSAnthony PERARDxen_pci_passthrough=""
241377529c0SPaolo Bonzinilinux_aio=""
24247e98658SCorey Bryantcap_ng=""
243377529c0SPaolo Bonziniattr=""
2444f26f2b6SAvi Kivitylibattr=""
245377529c0SPaolo Bonzinixfs=""
246377529c0SPaolo Bonzini
247d41a75a2SBradvhost_net="no"
2485e9be92dSNicholas Bellingervhost_scsi="no"
249d41a75a2SBradkvm="no"
2502da776dbSMichael R. Hinesrdma=""
251377529c0SPaolo Bonzinigprof="no"
252377529c0SPaolo Bonzinidebug_tcg="no"
253377529c0SPaolo Bonzinidebug="no"
254377529c0SPaolo Bonzinistrip_opt="yes"
2559195b2c2SStefan Weiltcg_interpreter="no"
256377529c0SPaolo Bonzinibigendian="no"
257377529c0SPaolo Bonzinimingw32="no"
2581d728c39SBlue Swirlgcov="no"
2591d728c39SBlue Swirlgcov_tool="gcov"
260377529c0SPaolo BonziniEXESUF=""
26117969268SFam ZhengDSOSUF=".so"
26217969268SFam ZhengLDFLAGS_SHARED="-shared"
26317969268SFam Zhengmodules="no"
264377529c0SPaolo Bonziniprefix="/usr/local"
265377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
266528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
267850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
268377529c0SPaolo Bonzinibindir="\${prefix}/bin"
2693aa5d2beSAlon Levylibdir="\${prefix}/lib"
2708bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
2710f94d6daSAlon Levyincludedir="\${prefix}/include"
272377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
273785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
274377529c0SPaolo Bonziniconfsuffix="/qemu"
275377529c0SPaolo Bonzinislirp="yes"
276377529c0SPaolo Bonzinifmod_lib=""
277377529c0SPaolo Bonzinifmod_inc=""
278377529c0SPaolo Bonzinioss_lib=""
279377529c0SPaolo Bonzinibsd="no"
280377529c0SPaolo Bonzinilinux="no"
281377529c0SPaolo Bonzinisolaris="no"
282377529c0SPaolo Bonziniprofiler="no"
283377529c0SPaolo Bonzinicocoa="no"
284377529c0SPaolo Bonzinisoftmmu="yes"
285377529c0SPaolo Bonzinilinux_user="no"
286377529c0SPaolo Bonzinibsd_user="no"
28730163d89SPeter Maydellguest_base="yes"
288377529c0SPaolo Bonziniuname_release=""
289377529c0SPaolo Bonziniaix="no"
290377529c0SPaolo Bonziniblobs="yes"
291377529c0SPaolo Bonzinipkgversion=""
29240d6444eSAvi Kivitypie=""
293377529c0SPaolo Bonzinizero_malloc=""
2943556c233SPaolo Bonziniqom_cast_debug="yes"
295377529c0SPaolo Bonzinitrace_backend="nop"
296377529c0SPaolo Bonzinitrace_file="trace"
297377529c0SPaolo Bonzinispice=""
298377529c0SPaolo Bonzinirbd=""
299111a38b0SRobert Relyeasmartcard_nss=""
3002b2325ffSGerd Hoffmannlibusb=""
30169354a83SHans de Goedeusb_redir=""
302b1e5fff4SMichael Walleglx=""
3031ece9905SAlon Levyzlib="yes"
304607dacd0Sqiaonuohanlzo="no"
305607dacd0Sqiaonuohansnappy="no"
306e8ef31a3SMichael Tokarevguest_agent=""
307d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
308d9840e25STomoki Sekiyamavss_win32_sdk=""
309d9840e25STomoki Sekiyamawin_sdk="no"
3104b1c11fdSDaniel P. Berrangewant_tools="yes"
311c589b249SRonnie Sahlberglibiscsi=""
3126542aa9cSPeter Lievenlibnfs=""
313519175a2SAlex Barcelocoroutine=""
31470c60c08SStefan Hajnoczicoroutine_pool=""
315f794573eSEduardo Otuboseccomp=""
316eb100396SBharata B Raoglusterfs=""
3170c14fb47SBharata B Raoglusterfs_discard="no"
3187c815372SBharata B Raoglusterfs_zerofill="no"
319583f6e7bSStefan Hajnoczivirtio_blk_data_plane=""
320a4ccabcfSAnthony Liguorigtk=""
321528de90aSDaniel P. Berrangegtkabi="2.0"
322bbbf9bfbSStefan Weilvte=""
323ab214c29SStefan Bergertpm="no"
3240a12ec87SRichard W.M. Joneslibssh2=""
3254f18b782SJeff Codyvhdx=""
32695c6bff3SBenoît Canetquorum="no"
327377529c0SPaolo Bonzini
328ac0df51dSaliguori# parse CC options first
329ac0df51dSaliguorifor opt do
330ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
331ac0df51dSaliguori  case "$opt" in
332ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
333ac0df51dSaliguori  ;;
3343d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
335ac0df51dSaliguori  ;;
33683f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
33783f73fceSTomoki Sekiyama  ;;
338ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
339ca4deeb1SPaolo Bonzini  ;;
3402ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
3412ff6b91eSJuan Quintela  ;;
342a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
343f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
344e2a2ed06SJuan Quintela  ;;
345e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
346f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
347e2a2ed06SJuan Quintela  ;;
3485bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
3495bc62e01SGerd Hoffmann  ;;
3505bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
3515bc62e01SGerd Hoffmann  ;;
352ac0df51dSaliguori  esac
353ac0df51dSaliguoridone
354ac0df51dSaliguori# OS specific
355ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
35693148aa5SStefan Weil# we can eliminate its usage altogether.
357ac0df51dSaliguori
358e49d021eSPeter Maydell# Preferred compiler:
359e49d021eSPeter Maydell#  ${CC} (if set)
360e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
361e49d021eSPeter Maydell#  system compiler
362e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
363e49d021eSPeter Maydell  cc="$host_cc"
364e49d021eSPeter Maydellelse
365b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
366e49d021eSPeter Maydellfi
367e49d021eSPeter Maydell
36883f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
36983f73fceSTomoki Sekiyama  cxx="c++"
37083f73fceSTomoki Sekiyamaelse
37183f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
37283f73fceSTomoki Sekiyamafi
37383f73fceSTomoki Sekiyama
374b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
3753dd46c78SBlue Swirlas="${AS-${cross_prefix}as}"
3763dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
377b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
378b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
3793f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
380b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
381b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
38217884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
38317884d7bSSergei Trofimovichquery_pkg_config() {
38417884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
38517884d7bSSergei Trofimovich}
38617884d7bSSergei Trofimovichpkg_config=query_pkg_config
387b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
38847c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
389ac0df51dSaliguori
39045d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
39145d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
39245d285abSPeter Maydell
393be17dc90SMichael S. Tsirkin# default flags for all hosts
3944c288acbSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common $QEMU_CFLAGS"
395f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
396c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
397be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
3986b4c305cSPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
3995bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
4005bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
401be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
4025bc62e01SGerd Hoffmannfi
403be17dc90SMichael S. Tsirkin
404ca4deeb1SPaolo Bonzini# make source path absolute
405ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
406ca4deeb1SPaolo Bonzini
407ac0df51dSaliguoricheck_define() {
408ac0df51dSaliguoricat > $TMPC <<EOF
409ac0df51dSaliguori#if !defined($1)
410fd786e1aSPeter Maydell#error $1 not defined
411ac0df51dSaliguori#endif
412ac0df51dSaliguoriint main(void) { return 0; }
413ac0df51dSaliguoriEOF
41452166aa0SJuan Quintela  compile_object
415ac0df51dSaliguori}
416ac0df51dSaliguori
417bbea4050SPeter Maydellif check_define __linux__ ; then
418bbea4050SPeter Maydell  targetos="Linux"
419bbea4050SPeter Maydellelif check_define _WIN32 ; then
420bbea4050SPeter Maydell  targetos='MINGW32'
421bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
422bbea4050SPeter Maydell  targetos='OpenBSD'
423bbea4050SPeter Maydellelif check_define __sun__ ; then
424bbea4050SPeter Maydell  targetos='SunOS'
425bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
426bbea4050SPeter Maydell  targetos='Haiku'
427bbea4050SPeter Maydellelse
428bbea4050SPeter Maydell  targetos=`uname -s`
429bbea4050SPeter Maydellfi
430bbea4050SPeter Maydell
431bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
432bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
433bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
434bbea4050SPeter Maydell# the correct CPU with the --cpu option.
435bbea4050SPeter Maydellcase $targetos in
436bbea4050SPeter MaydellDarwin)
437bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
438bbea4050SPeter Maydell  # run 64-bit userspace code.
439bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
440bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
441bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
442bbea4050SPeter Maydell    cpu="x86_64"
443bbea4050SPeter Maydell  fi
444bbea4050SPeter Maydell  ;;
445bbea4050SPeter MaydellSunOS)
446bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
447bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
448bbea4050SPeter Maydell    cpu="x86_64"
449bbea4050SPeter Maydell  fi
450bbea4050SPeter Maydellesac
451bbea4050SPeter Maydell
4522ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
4532ff6b91eSJuan Quintela  # command line argument
4542ff6b91eSJuan Quintela  :
4552ff6b91eSJuan Quintelaelif check_define __i386__ ; then
456ac0df51dSaliguori  cpu="i386"
457ac0df51dSaliguorielif check_define __x86_64__ ; then
458c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
459c72b26ecSRichard Henderson    cpu="x32"
460c72b26ecSRichard Henderson  else
461ac0df51dSaliguori    cpu="x86_64"
462c72b26ecSRichard Henderson  fi
4633aa9bd6cSblueswir1elif check_define __sparc__ ; then
4643aa9bd6cSblueswir1  if check_define __arch64__ ; then
4653aa9bd6cSblueswir1    cpu="sparc64"
4663aa9bd6cSblueswir1  else
4673aa9bd6cSblueswir1    cpu="sparc"
4683aa9bd6cSblueswir1  fi
469fdf7ed96Smalcelif check_define _ARCH_PPC ; then
470fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
471fdf7ed96Smalc    cpu="ppc64"
472ac0df51dSaliguori  else
473fdf7ed96Smalc    cpu="ppc"
474fdf7ed96Smalc  fi
475afa05235SAurelien Jarnoelif check_define __mips__ ; then
476afa05235SAurelien Jarno  cpu="mips"
477477ba620SAurelien Jarnoelif check_define __ia64__ ; then
478477ba620SAurelien Jarno  cpu="ia64"
479d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
480d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
481d66ed0eaSAurelien Jarno    cpu="s390x"
482d66ed0eaSAurelien Jarno  else
483d66ed0eaSAurelien Jarno    cpu="s390"
484d66ed0eaSAurelien Jarno  fi
48521d89f84SPeter Maydellelif check_define __arm__ ; then
48621d89f84SPeter Maydell  cpu="arm"
4871f080313SClaudio Fontanaelif check_define __aarch64__ ; then
4881f080313SClaudio Fontana  cpu="aarch64"
489f28ffed5SBradelif check_define __hppa__ ; then
490f28ffed5SBrad  cpu="hppa"
491fdf7ed96Smalcelse
492fdf7ed96Smalc  cpu=`uname -m`
493ac0df51dSaliguorifi
494ac0df51dSaliguori
495359bc95dSPeter MaydellARCH=
496359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
497359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
4987d13299dSbellardcase "$cpu" in
499c72b26ecSRichard Henderson  ia64|ppc|ppc64|s390|s390x|sparc64|x32)
500ea8f20f8SJuan Quintela    cpu="$cpu"
501ea8f20f8SJuan Quintela  ;;
5027d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
50397a847bcSbellard    cpu="i386"
5047d13299dSbellard  ;;
505aaa5fa14Saurel32  x86_64|amd64)
506aaa5fa14Saurel32    cpu="x86_64"
507aaa5fa14Saurel32  ;;
50821d89f84SPeter Maydell  armv*b|armv*l|arm)
50921d89f84SPeter Maydell    cpu="arm"
5107d13299dSbellard  ;;
5111f080313SClaudio Fontana  aarch64)
5121f080313SClaudio Fontana    cpu="aarch64"
5131f080313SClaudio Fontana  ;;
514afa05235SAurelien Jarno  mips*)
515afa05235SAurelien Jarno    cpu="mips"
516afa05235SAurelien Jarno  ;;
5173142255cSblueswir1  sparc|sun4[cdmuv])
518ae228531Sbellard    cpu="sparc"
519ae228531Sbellard  ;;
5207d13299dSbellard  *)
521359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
522359bc95dSPeter Maydell    ARCH=unknown
5237d13299dSbellard  ;;
5247d13299dSbellardesac
525359bc95dSPeter Maydellif test -z "$ARCH"; then
526359bc95dSPeter Maydell  ARCH="$cpu"
527359bc95dSPeter Maydellfi
528e2d52ad3SJuan Quintela
5297d13299dSbellard# OS specific
5300dbfc675SJuan Quintela
5317d13299dSbellardcase $targetos in
532c326e0afSbellardCYGWIN*)
533c326e0afSbellard  mingw32="yes"
534a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
535d5631638Smalc  audio_possible_drivers="winwave sdl"
536d5631638Smalc  audio_drv_list="winwave"
537c326e0afSbellard;;
53867b915a5SbellardMINGW32*)
53967b915a5Sbellard  mingw32="yes"
540d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
541d5631638Smalc  audio_drv_list="winwave"
54267b915a5Sbellard;;
5435c40d2bdSthsGNU/kFreeBSD)
544a167ba50SAurelien Jarno  bsd="yes"
5450c58ac1cSmalc  audio_drv_list="oss"
546f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
5475c40d2bdSths;;
5487d3505c5SbellardFreeBSD)
5497d3505c5Sbellard  bsd="yes"
5500db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5510c58ac1cSmalc  audio_drv_list="oss"
552f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
553f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
554f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
55558952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
5567d3505c5Sbellard;;
557c5e97233Sblueswir1DragonFly)
558c5e97233Sblueswir1  bsd="yes"
5590db4a067SPaolo Bonzini  make="${MAKE-gmake}"
560c5e97233Sblueswir1  audio_drv_list="oss"
561c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
562c5e97233Sblueswir1;;
5637d3505c5SbellardNetBSD)
5647d3505c5Sbellard  bsd="yes"
5650db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5660c58ac1cSmalc  audio_drv_list="oss"
567c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
5688ef92a88Sblueswir1  oss_lib="-lossaudio"
5697d3505c5Sbellard;;
5707d3505c5SbellardOpenBSD)
5717d3505c5Sbellard  bsd="yes"
5720db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5734f6ab397SBrad Smith  audio_drv_list="sdl"
5744f6ab397SBrad Smith  audio_possible_drivers="sdl esd"
5757d3505c5Sbellard;;
57683fb7adfSbellardDarwin)
57783fb7adfSbellard  bsd="yes"
57883fb7adfSbellard  darwin="yes"
57917969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
5801b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
581a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
5820c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
5831b0f9cc2Saliguori  fi
584fd677642Sths  cocoa="yes"
5850c58ac1cSmalc  audio_drv_list="coreaudio"
586c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
5870c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
5887973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
589a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
590a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
591a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
59283fb7adfSbellard;;
593ec530c81SbellardSunOS)
594ec530c81Sbellard  solaris="yes"
5950db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5960db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
597fa58948dSBlue Swirl  ld="gld"
598e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
5990475a5caSths  needs_libsunmath="no"
600c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
601c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
6020475a5caSths    if test "$solarisrev" -le 9 ; then
6030475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
6040475a5caSths        needs_libsunmath="yes"
605f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
606f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
607f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
6080475a5caSths      else
60976ad07a4SPeter Maydell        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
61076ad07a4SPeter Maydell            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
61176ad07a4SPeter Maydell            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
61276ad07a4SPeter Maydell            "Studio 11 can be downloaded from www.sun.com."
6130475a5caSths      fi
6140475a5caSths    fi
61586b2bd93Sths  fi
6166b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
6170c58ac1cSmalc    audio_drv_list="oss"
6186b4d2ba1Sths  fi
619c2de5c91Smalc  audio_possible_drivers="oss sdl"
620d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
621d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
622d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
623d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
624a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
625560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
626560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
627560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
628ec530c81Sbellard;;
629b29fe3edSmalcAIX)
630b29fe3edSmalc  aix="yes"
6310db4a067SPaolo Bonzini  make="${MAKE-gmake}"
632b29fe3edSmalc;;
633179cf400SAndreas FärberHaiku)
634179cf400SAndreas Färber  haiku="yes"
635179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
636179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
637179cf400SAndreas Färber;;
638fb065187Sbellard*)
6390c58ac1cSmalc  audio_drv_list="oss"
640b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
6415327cf48Sbellard  linux="yes"
642831b7825Sths  linux_user="yes"
643af2be207SJan Kiszka  kvm="yes"
644af2be207SJan Kiszka  vhost_net="yes"
6455e9be92dSNicholas Bellinger  vhost_scsi="yes"
646c72b26ecSRichard Henderson  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "x32" ] ; then
647c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
648c9ec1fe4Sbellard  fi
649a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
650fb065187Sbellard;;
6517d13299dSbellardesac
6527d13299dSbellard
6537d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
654b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
65584778508Sblueswir1    bsd_user="yes"
6567d3505c5Sbellard  fi
65708de3949SAndreas Färberfi
6587d3505c5Sbellard
6590db4a067SPaolo Bonzini: ${make=${MAKE-make}}
6600db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
66152510f8bSStefan Weil: ${python=${PYTHON-python}}
662e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
6630db4a067SPaolo Bonzini
6643c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
6653c4a4d0dSPeter Maydellif has clang; then
6663c4a4d0dSPeter Maydell  objcc=clang
6673c4a4d0dSPeter Maydellelse
6683c4a4d0dSPeter Maydell  objcc="$cc"
6693c4a4d0dSPeter Maydellfi
6703c4a4d0dSPeter Maydell
6713457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
6723457a3f8SJuan Quintela  EXESUF=".exe"
67317969268SFam Zheng  DSOSUF=".dll"
674a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
675e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
676e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
677f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
678f7cf5d5bSStefan Weilcat > $TMPC << EOF
679f7cf5d5bSStefan Weilint main(void) { return 0; }
680f7cf5d5bSStefan WeilEOF
681f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
682f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
683f7cf5d5bSStefan Weil  fi
684c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
685683035deSPaolo Bonzini  mandir="\${prefix}"
686528ae5b8SEduardo Habkost  datadir="\${prefix}"
687850da188SEduardo Habkost  qemu_docdir="\${prefix}"
688683035deSPaolo Bonzini  bindir="\${prefix}"
689683035deSPaolo Bonzini  sysconfdir="\${prefix}"
6905a699bbbSLaszlo Ersek  local_statedir=
691683035deSPaolo Bonzini  confsuffix=""
692368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
6933457a3f8SJuan Quintelafi
6943457a3f8SJuan Quintela
695487fefdbSAnthony Liguoriwerror=""
69685aa5189Sbellard
6977d13299dSbellardfor opt do
698a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
6997d13299dSbellard  case "$opt" in
7002efc3265Sbellard  --help|-h) show_help=yes
7012efc3265Sbellard  ;;
70299123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
70399123e13SMike Frysinger  ;;
704b1a550a0Spbrook  --prefix=*) prefix="$optarg"
7057d13299dSbellard  ;;
706b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
70732ce6337Sbellard  ;;
708ca4deeb1SPaolo Bonzini  --source-path=*)
7097d13299dSbellard  ;;
710ac0df51dSaliguori  --cross-prefix=*)
7117d13299dSbellard  ;;
712ac0df51dSaliguori  --cc=*)
7137d13299dSbellard  ;;
714b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
71583469015Sbellard  ;;
71683f73fceSTomoki Sekiyama  --cxx=*)
71783f73fceSTomoki Sekiyama  ;;
718e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
719e007dbecSMichael S. Tsirkin  ;;
7203c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
7213c4a4d0dSPeter Maydell  ;;
722b1a550a0Spbrook  --make=*) make="$optarg"
7237d13299dSbellard  ;;
7246a882643Spbrook  --install=*) install="$optarg"
7256a882643Spbrook  ;;
726c886edfbSBlue Swirl  --python=*) python="$optarg"
727c886edfbSBlue Swirl  ;;
7281d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
7291d728c39SBlue Swirl  ;;
730e2d8830eSBrad  --smbd=*) smbd="$optarg"
731e2d8830eSBrad  ;;
732e2a2ed06SJuan Quintela  --extra-cflags=*)
7337d13299dSbellard  ;;
734e2a2ed06SJuan Quintela  --extra-ldflags=*)
7357d13299dSbellard  ;;
7365bc62e01SGerd Hoffmann  --enable-debug-info)
7375bc62e01SGerd Hoffmann  ;;
7385bc62e01SGerd Hoffmann  --disable-debug-info)
7395bc62e01SGerd Hoffmann  ;;
74017969268SFam Zheng  --enable-modules)
74117969268SFam Zheng      modules="yes"
74217969268SFam Zheng  ;;
7432ff6b91eSJuan Quintela  --cpu=*)
7447d13299dSbellard  ;;
745b1a550a0Spbrook  --target-list=*) target_list="$optarg"
746de83cd02Sbellard  ;;
74774242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
74894a420b1SStefan Hajnoczi  ;;
74974242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
7509410b56cSPrerna Saxena  ;;
7517d13299dSbellard  --enable-gprof) gprof="yes"
7527d13299dSbellard  ;;
7531d728c39SBlue Swirl  --enable-gcov) gcov="yes"
7541d728c39SBlue Swirl  ;;
75579427693SLoïc Minier  --static)
75679427693SLoïc Minier    static="yes"
75779427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
75817884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
75943ce4dfeSbellard  ;;
7600b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
7610b24e75fSPaolo Bonzini  ;;
7620b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
7630b24e75fSPaolo Bonzini  ;;
7643aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
7653aa5d2beSAlon Levy  ;;
7668bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
7678bf188aaSMichael Tokarev  ;;
7680f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
7690f94d6daSAlon Levy  ;;
770528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
7710b24e75fSPaolo Bonzini  ;;
772023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
773023d3d67SEduardo Habkost  ;;
774850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
7750b24e75fSPaolo Bonzini  ;;
776ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
77707381cc1SAnthony Liguori  ;;
778785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
779785c23aeSLuiz Capitulino  ;;
780785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
781023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
782023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
783023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
784023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
785023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
786023ddd74SMax Filippov    # lots of directory switches by default.
787023ddd74SMax Filippov  ;;
788e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
789e2134eb9SGerd Hoffmann  ;;
790e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
791e2134eb9SGerd Hoffmann  ;;
79274880fe2SRobert Schiele  --without-pixman) pixman="none"
79374880fe2SRobert Schiele  ;;
79497a847bcSbellard  --disable-sdl) sdl="no"
79597a847bcSbellard  ;;
796c4198157SJuan Quintela  --enable-sdl) sdl="yes"
797c4198157SJuan Quintela  ;;
79847c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
79947c03744SDave Airlie  ;;
8003556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
8013556c233SPaolo Bonzini  ;;
8023556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
8033556c233SPaolo Bonzini  ;;
804983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
805983eef5aSMeador Inge  ;;
806983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
807983eef5aSMeador Inge  ;;
808821601eaSJes Sorensen  --disable-vnc) vnc="no"
809821601eaSJes Sorensen  ;;
810821601eaSJes Sorensen  --enable-vnc) vnc="yes"
811821601eaSJes Sorensen  ;;
812b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
813102a52e4Sbellard  ;;
814c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
815c2de5c91Smalc  ;;
8162f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
8172f6a1ab0Sblueswir1  ;;
8180c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
8190c58ac1cSmalc  ;;
820b64ec4e4SFam Zheng  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
821b64ec4e4SFam Zheng  ;;
822b64ec4e4SFam Zheng  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
823eb852011SMarkus Armbruster  ;;
824f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
825f8393946Saurel32  ;;
826f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
827f8393946Saurel32  ;;
828f3d08ee6SPaul Brook  --enable-debug)
829f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
830f3d08ee6SPaul Brook      debug_tcg="yes"
831f3d08ee6SPaul Brook      debug="yes"
832f3d08ee6SPaul Brook      strip_opt="no"
833f3d08ee6SPaul Brook  ;;
83403b4fe7dSaliguori  --enable-sparse) sparse="yes"
83503b4fe7dSaliguori  ;;
83603b4fe7dSaliguori  --disable-sparse) sparse="no"
83703b4fe7dSaliguori  ;;
8381625af87Saliguori  --disable-strip) strip_opt="no"
8391625af87Saliguori  ;;
8408d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
8418d5d2d4cSths  ;;
8421be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
8431be10ad2SJuan Quintela  ;;
8442f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
8452f9606b3Saliguori  ;;
846ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
847ea784e3bSJuan Quintela  ;;
8482f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
8492f6f5c7aSCorentin Chary  ;;
8502f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
8512f6f5c7aSCorentin Chary  ;;
852efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
853efe556adSCorentin Chary  ;;
854efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
855efe556adSCorentin Chary  ;;
8567536ee4bSTim Hardeck  --disable-vnc-ws) vnc_ws="no"
8577536ee4bSTim Hardeck  ;;
8587536ee4bSTim Hardeck  --enable-vnc-ws) vnc_ws="yes"
8597536ee4bSTim Hardeck  ;;
860443f1376Sbellard  --disable-slirp) slirp="no"
861c20709aaSbellard  ;;
862ee682d27SStefan Weil  --disable-uuid) uuid="no"
863ee682d27SStefan Weil  ;;
864ee682d27SStefan Weil  --enable-uuid) uuid="yes"
865ee682d27SStefan Weil  ;;
866e0e6c8c0Saliguori  --disable-vde) vde="no"
8678a16d273Sths  ;;
868dfb278bdSJuan Quintela  --enable-vde) vde="yes"
869dfb278bdSJuan Quintela  ;;
87058952137SVincenzo Maffione  --disable-netmap) netmap="no"
87158952137SVincenzo Maffione  ;;
87258952137SVincenzo Maffione  --enable-netmap) netmap="yes"
87358952137SVincenzo Maffione  ;;
874e37630caSaliguori  --disable-xen) xen="no"
875e37630caSaliguori  ;;
876fc321b4bSJuan Quintela  --enable-xen) xen="yes"
877fc321b4bSJuan Quintela  ;;
878eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
879eb6fda0fSAnthony PERARD  ;;
880eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
881eb6fda0fSAnthony PERARD  ;;
8822e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
8832e4d9fb1Saurel32  ;;
8844ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
8854ffcedb6SJuan Quintela  ;;
886fb599c9aSbalrog  --disable-bluez) bluez="no"
887fb599c9aSbalrog  ;;
888a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
889a20a6f46SJuan Quintela  ;;
8907ba1e619Saliguori  --disable-kvm) kvm="no"
8917ba1e619Saliguori  ;;
892b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
893b31a0277SJuan Quintela  ;;
8949195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
8959195b2c2SStefan Weil  ;;
8969195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
8979195b2c2SStefan Weil  ;;
89847e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
89947e98658SCorey Bryant  ;;
90047e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
90147e98658SCorey Bryant  ;;
902cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
903cd4ec0b4SGerd Hoffmann  ;;
904cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
905cd4ec0b4SGerd Hoffmann  ;;
906c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
907c589b249SRonnie Sahlberg  ;;
908c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
909c589b249SRonnie Sahlberg  ;;
9106542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
9116542aa9cSPeter Lieven  ;;
9126542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
9136542aa9cSPeter Lieven  ;;
91405c2a3e7Sbellard  --enable-profiler) profiler="yes"
91505c2a3e7Sbellard  ;;
91614821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
91714821030SPavel Borzenkov  ;;
918c2de5c91Smalc  --enable-cocoa)
919c2de5c91Smalc      cocoa="yes" ;
920c2de5c91Smalc      sdl="no" ;
921c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
9225b0753e0Sbellard  ;;
923cad25d69Spbrook  --disable-system) softmmu="no"
9240a8e90f4Spbrook  ;;
925cad25d69Spbrook  --enable-system) softmmu="yes"
9260a8e90f4Spbrook  ;;
9270953a80fSZachary Amsden  --disable-user)
9280953a80fSZachary Amsden      linux_user="no" ;
9290953a80fSZachary Amsden      bsd_user="no" ;
9300953a80fSZachary Amsden  ;;
9310953a80fSZachary Amsden  --enable-user) ;;
932831b7825Sths  --disable-linux-user) linux_user="no"
9330a8e90f4Spbrook  ;;
934831b7825Sths  --enable-linux-user) linux_user="yes"
935831b7825Sths  ;;
93684778508Sblueswir1  --disable-bsd-user) bsd_user="no"
93784778508Sblueswir1  ;;
93884778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
93984778508Sblueswir1  ;;
940379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
941379f6698SPaul Brook  ;;
942379f6698SPaul Brook  --disable-guest-base) guest_base="no"
943379f6698SPaul Brook  ;;
94440d6444eSAvi Kivity  --enable-pie) pie="yes"
94534005a00SKirill A. Shutemov  ;;
94640d6444eSAvi Kivity  --disable-pie) pie="no"
94734005a00SKirill A. Shutemov  ;;
948c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
949c5937220Spbrook  ;;
95085aa5189Sbellard  --enable-werror) werror="yes"
95185aa5189Sbellard  ;;
95285aa5189Sbellard  --disable-werror) werror="no"
95385aa5189Sbellard  ;;
95463678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
95563678e17SSteven Noonan  ;;
95663678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
95763678e17SSteven Noonan  ;;
9584d3b6f6eSbalrog  --disable-curses) curses="no"
9594d3b6f6eSbalrog  ;;
960c584a6d0SJuan Quintela  --enable-curses) curses="yes"
961c584a6d0SJuan Quintela  ;;
962769ce76dSAlexander Graf  --disable-curl) curl="no"
963769ce76dSAlexander Graf  ;;
964788c8196SJuan Quintela  --enable-curl) curl="yes"
965788c8196SJuan Quintela  ;;
9662df87df7SJuan Quintela  --disable-fdt) fdt="no"
9672df87df7SJuan Quintela  ;;
9682df87df7SJuan Quintela  --enable-fdt) fdt="yes"
9692df87df7SJuan Quintela  ;;
9705c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
9715c6c3a6cSChristoph Hellwig  ;;
9725c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
9735c6c3a6cSChristoph Hellwig  ;;
974758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
975758e8e38SVenkateswararao Jujjuri (JV)  ;;
976758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
977758e8e38SVenkateswararao Jujjuri (JV)  ;;
97877755340Sths  --disable-blobs) blobs="no"
97977755340Sths  ;;
9804a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
9814a19f1ecSpbrook  ;;
982519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
983519175a2SAlex Barcelo  ;;
98470c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
98570c60c08SStefan Hajnoczi  ;;
98670c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
98770c60c08SStefan Hajnoczi  ;;
988a25dba17SJuan Quintela  --disable-docs) docs="no"
98970ec5dc0SAnthony Liguori  ;;
990a25dba17SJuan Quintela  --enable-docs) docs="yes"
99183a3ab8bSJuan Quintela  ;;
992d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
993d5970055SMichael S. Tsirkin  ;;
994d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
995d5970055SMichael S. Tsirkin  ;;
9965e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
9975e9be92dSNicholas Bellinger  ;;
9985e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
9995e9be92dSNicholas Bellinger  ;;
1000b1e5fff4SMichael Walle  --disable-glx) glx="no"
100120ff075bSMichael Walle  ;;
1002b1e5fff4SMichael Walle  --enable-glx) glx="yes"
100320ff075bSMichael Walle  ;;
1004f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1005f27aaf4bSChristian Brunner  ;;
1006f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1007f27aaf4bSChristian Brunner  ;;
10088c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
10098c84cf11SSergei Trofimovich  ;;
10108c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
10118c84cf11SSergei Trofimovich  ;;
1012111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
1013111a38b0SRobert Relyea  ;;
1014111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
1015111a38b0SRobert Relyea  ;;
10162b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
10172b2325ffSGerd Hoffmann  ;;
10182b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
10192b2325ffSGerd Hoffmann  ;;
102069354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
102169354a83SHans de Goede  ;;
102269354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
102369354a83SHans de Goede  ;;
10241ece9905SAlon Levy  --disable-zlib-test) zlib="no"
10251ece9905SAlon Levy  ;;
1026607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1027607dacd0Sqiaonuohan  ;;
1028607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1029607dacd0Sqiaonuohan  ;;
1030d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1031d138cee9SMichael Roth  ;;
1032d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1033d138cee9SMichael Roth  ;;
1034d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1035d9840e25STomoki Sekiyama  ;;
1036d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1037d9840e25STomoki Sekiyama  ;;
1038d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1039d9840e25STomoki Sekiyama  ;;
1040d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1041d9840e25STomoki Sekiyama  ;;
1042d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1043d9840e25STomoki Sekiyama  ;;
1044d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1045d9840e25STomoki Sekiyama  ;;
10464b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
10474b1c11fdSDaniel P. Berrange  ;;
10484b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
10494b1c11fdSDaniel P. Berrange  ;;
1050f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1051f794573eSEduardo Otubo  ;;
1052f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1053f794573eSEduardo Otubo  ;;
1054eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1055eb100396SBharata B Rao  ;;
1056eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1057eb100396SBharata B Rao  ;;
1058583f6e7bSStefan Hajnoczi  --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
1059583f6e7bSStefan Hajnoczi  ;;
1060583f6e7bSStefan Hajnoczi  --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
1061583f6e7bSStefan Hajnoczi  ;;
1062a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1063a4ccabcfSAnthony Liguori  ;;
1064a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1065a4ccabcfSAnthony Liguori  ;;
10662da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
10672da776dbSMichael R. Hines  ;;
10682da776dbSMichael R. Hines  --disable-rdma) rdma="no"
10692da776dbSMichael R. Hines  ;;
1070528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1071528de90aSDaniel P. Berrange  ;;
1072bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1073bbbf9bfbSStefan Weil  ;;
1074bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1075bbbf9bfbSStefan Weil  ;;
1076ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1077ab214c29SStefan Berger  ;;
10780a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
10790a12ec87SRichard W.M. Jones  ;;
10800a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
10810a12ec87SRichard W.M. Jones  ;;
10824f18b782SJeff Cody  --enable-vhdx) vhdx="yes"
10834f18b782SJeff Cody  ;;
10844f18b782SJeff Cody  --disable-vhdx) vhdx="no"
10854f18b782SJeff Cody  ;;
108695c6bff3SBenoît Canet  --disable-quorum) quorum="no"
108795c6bff3SBenoît Canet  ;;
108895c6bff3SBenoît Canet  --enable-quorum) quorum="yes"
108995c6bff3SBenoît Canet  ;;
10902d2ad6d0SFam Zheng  *)
10912d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
10922d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
10932d2ad6d0SFam Zheng      exit 1
10947f1559c6Sbalrog  ;;
10957d13299dSbellard  esac
10967d13299dSbellarddone
10977d13299dSbellard
1098f6f0b7d9SStefan Weilif ! has $python; then
1099f6f0b7d9SStefan Weil  error_exit "Python not found. Use --python=/path/to/python"
1100f6f0b7d9SStefan Weilfi
1101f6f0b7d9SStefan Weil
1102f6f0b7d9SStefan Weil# Note that if the Python conditional here evaluates True we will exit
1103f6f0b7d9SStefan Weil# with status 1 which is a shell 'false' value.
1104f6f0b7d9SStefan Weilif ! $python -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1105f6f0b7d9SStefan Weil  error_exit "Cannot use '$python', Python 2.4 or later is required." \
1106f6f0b7d9SStefan Weil      "Note that Python 3 or later is not yet supported." \
1107f6f0b7d9SStefan Weil      "Use --python=/path/to/python to specify a supported Python."
1108f6f0b7d9SStefan Weilfi
1109f6f0b7d9SStefan Weil
1110f6f0b7d9SStefan Weil# The -B switch was added in Python 2.6.
1111f6f0b7d9SStefan Weil# If it is supplied, compiled files are not written.
1112f6f0b7d9SStefan Weil# Use it for Python versions which support it.
1113f6f0b7d9SStefan Weilif $python -B -c 'import sys; sys.exit(0)' 2>/dev/null; then
1114f6f0b7d9SStefan Weil  python="$python -B"
1115f6f0b7d9SStefan Weilfi
1116f6f0b7d9SStefan Weil
111740293e58Sbellardcase "$cpu" in
1118e3608d66SRichard Henderson    ppc)
1119e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1120e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1121e3608d66SRichard Henderson           ;;
1122e3608d66SRichard Henderson    ppc64)
1123e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1124e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1125e3608d66SRichard Henderson           ;;
11269b9c37c3SRichard Henderson    sparc)
11270c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
112879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32 -mcpu=ultrasparc"
11293142255cSblueswir1           ;;
1130ed968ff1SJuan Quintela    sparc64)
11310c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
113279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
11333142255cSblueswir1           ;;
113476d83bdeSths    s390)
113579f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m31 -march=z990"
113628d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
113728d7cc49SRichard Henderson           ;;
113828d7cc49SRichard Henderson    s390x)
113979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -march=z990"
114028d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
114176d83bdeSths           ;;
114240293e58Sbellard    i386)
114379f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
11440c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
11452b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
114640293e58Sbellard           ;;
114740293e58Sbellard    x86_64)
114879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64"
11490c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
11502b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1151379f6698SPaul Brook           ;;
1152c72b26ecSRichard Henderson    x32)
1153c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1154c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1155c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1156c72b26ecSRichard Henderson           ;;
115730163d89SPeter Maydell    # No special flags required for other host CPUs
11583142255cSblueswir1esac
11593142255cSblueswir1
116079f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
116179f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
116279f3b12fSPeter Crosthwaite
116360e0df25SPeter Maydelldefault_target_list=""
116460e0df25SPeter Maydell
11656e92f823SPeter Maydellmak_wilds=""
11666e92f823SPeter Maydell
116760e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
11686e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
116960e0df25SPeter Maydellfi
117060e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
11716e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
117260e0df25SPeter Maydellfi
117360e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
11746e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
117560e0df25SPeter Maydellfi
117660e0df25SPeter Maydell
11776e92f823SPeter Maydellfor config in $mak_wilds; do
11786e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
11796e92f823SPeter Maydelldone
11806e92f823SPeter Maydell
1181af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1182af5db58eSpbrookcat << EOF
1183af5db58eSpbrook
1184af5db58eSpbrookUsage: configure [options]
1185af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1186af5db58eSpbrook
118708fb77edSStefan WeilStandard options:
118808fb77edSStefan Weil  --help                   print this message
118908fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
119008fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
119108fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
119208fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
119308fb77edSStefan Weil$(echo Available targets: $default_target_list | \
119408fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
119508fb77edSStefan Weil
119608fb77edSStefan WeilAdvanced options (experts only):
119708fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
119808fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
119908fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
120008fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
120108fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
120208fb77edSStefan Weil                           build time
120308fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
120408fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
120508fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
120608fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
120708fb77edSStefan Weil  --make=MAKE              use specified make [$make]
120808fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
120908fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
121008fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
121108fb77edSStefan Weil  --static                 enable static build [$static]
121208fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
121308fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
121408fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
121508fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
121608fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
121708fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
121808fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
1219e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
122017969268SFam Zheng  --enable-modules         enable modules support
122108fb77edSStefan Weil  --enable-debug-tcg       enable TCG debugging
122208fb77edSStefan Weil  --disable-debug-tcg      disable TCG debugging (default)
122308fb77edSStefan Weil  --enable-debug-info      enable debugging information (default)
122408fb77edSStefan Weil  --disable-debug-info     disable debugging information
122508fb77edSStefan Weil  --enable-debug           enable common debug build options
122608fb77edSStefan Weil  --enable-sparse          enable sparse checker
122708fb77edSStefan Weil  --disable-sparse         disable sparse checker (default)
122808fb77edSStefan Weil  --disable-strip          disable stripping binaries
122908fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
123063678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
123108fb77edSStefan Weil  --disable-sdl            disable SDL
123208fb77edSStefan Weil  --enable-sdl             enable SDL
123347c03744SDave Airlie  --with-sdlabi            select preferred SDL ABI 1.2 or 2.0
123408fb77edSStefan Weil  --disable-gtk            disable gtk UI
123508fb77edSStefan Weil  --enable-gtk             enable gtk UI
1236f92d61f3SCole Robinson  --with-gtkabi            select preferred GTK ABI 2.0 or 3.0
123708fb77edSStefan Weil  --disable-virtfs         disable VirtFS
123808fb77edSStefan Weil  --enable-virtfs          enable VirtFS
123908fb77edSStefan Weil  --disable-vnc            disable VNC
124008fb77edSStefan Weil  --enable-vnc             enable VNC
124108fb77edSStefan Weil  --disable-cocoa          disable Cocoa (Mac OS X only)
124208fb77edSStefan Weil  --enable-cocoa           enable Cocoa (default on Mac OS X)
124308fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
124408fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
124508fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
124608fb77edSStefan Weil  --block-drv-rw-whitelist=L
124708fb77edSStefan Weil                           set block driver read-write whitelist
124808fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
124908fb77edSStefan Weil  --block-drv-ro-whitelist=L
125008fb77edSStefan Weil                           set block driver read-only whitelist
125108fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
125208fb77edSStefan Weil  --disable-xen            disable xen backend driver support
125308fb77edSStefan Weil  --enable-xen             enable xen backend driver support
125408fb77edSStefan Weil  --disable-xen-pci-passthrough
125508fb77edSStefan Weil  --enable-xen-pci-passthrough
125608fb77edSStefan Weil  --disable-brlapi         disable BrlAPI
125708fb77edSStefan Weil  --enable-brlapi          enable BrlAPI
125808fb77edSStefan Weil  --disable-vnc-tls        disable TLS encryption for VNC server
125908fb77edSStefan Weil  --enable-vnc-tls         enable TLS encryption for VNC server
126008fb77edSStefan Weil  --disable-vnc-sasl       disable SASL encryption for VNC server
126108fb77edSStefan Weil  --enable-vnc-sasl        enable SASL encryption for VNC server
126208fb77edSStefan Weil  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server
126308fb77edSStefan Weil  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server
126408fb77edSStefan Weil  --disable-vnc-png        disable PNG compression for VNC server (default)
126508fb77edSStefan Weil  --enable-vnc-png         enable PNG compression for VNC server
126608fb77edSStefan Weil  --disable-vnc-ws         disable Websockets support for VNC server
126708fb77edSStefan Weil  --enable-vnc-ws          enable Websockets support for VNC server
126808fb77edSStefan Weil  --disable-curses         disable curses output
126908fb77edSStefan Weil  --enable-curses          enable curses output
127008fb77edSStefan Weil  --disable-curl           disable curl connectivity
127108fb77edSStefan Weil  --enable-curl            enable curl connectivity
127208fb77edSStefan Weil  --disable-fdt            disable fdt device tree
127308fb77edSStefan Weil  --enable-fdt             enable fdt device tree
127408fb77edSStefan Weil  --disable-bluez          disable bluez stack connectivity
127508fb77edSStefan Weil  --enable-bluez           enable bluez stack connectivity
127608fb77edSStefan Weil  --disable-slirp          disable SLIRP userspace network connectivity
127708fb77edSStefan Weil  --disable-kvm            disable KVM acceleration support
127808fb77edSStefan Weil  --enable-kvm             enable KVM acceleration support
127908fb77edSStefan Weil  --disable-rdma           disable RDMA-based migration support
128008fb77edSStefan Weil  --enable-rdma            enable RDMA-based migration support
128108fb77edSStefan Weil  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
128208fb77edSStefan Weil  --enable-system          enable all system emulation targets
128308fb77edSStefan Weil  --disable-system         disable all system emulation targets
128408fb77edSStefan Weil  --enable-user            enable supported user emulation targets
128508fb77edSStefan Weil  --disable-user           disable all user emulation targets
128608fb77edSStefan Weil  --enable-linux-user      enable all linux usermode emulation targets
128708fb77edSStefan Weil  --disable-linux-user     disable all linux usermode emulation targets
128808fb77edSStefan Weil  --enable-bsd-user        enable all BSD usermode emulation targets
128908fb77edSStefan Weil  --disable-bsd-user       disable all BSD usermode emulation targets
129008fb77edSStefan Weil  --enable-guest-base      enable GUEST_BASE support for usermode
129108fb77edSStefan Weil                           emulation targets
129208fb77edSStefan Weil  --disable-guest-base     disable GUEST_BASE support
129308fb77edSStefan Weil  --enable-pie             build Position Independent Executables
129408fb77edSStefan Weil  --disable-pie            do not build Position Independent Executables
129508fb77edSStefan Weil  --fmod-lib               path to FMOD library
129608fb77edSStefan Weil  --fmod-inc               path to FMOD includes
129708fb77edSStefan Weil  --oss-lib                path to OSS library
129808fb77edSStefan Weil  --enable-uname-release=R Return R for uname -r in usermode emulation
129908fb77edSStefan Weil  --cpu=CPU                Build for host CPU [$cpu]
130008fb77edSStefan Weil  --disable-uuid           disable uuid support
130108fb77edSStefan Weil  --enable-uuid            enable uuid support
130208fb77edSStefan Weil  --disable-vde            disable support for vde network
130308fb77edSStefan Weil  --enable-vde             enable support for vde network
130408fb77edSStefan Weil  --disable-netmap         disable support for netmap network
130508fb77edSStefan Weil  --enable-netmap          enable support for netmap network
130608fb77edSStefan Weil  --disable-linux-aio      disable Linux AIO support
130708fb77edSStefan Weil  --enable-linux-aio       enable Linux AIO support
130808fb77edSStefan Weil  --disable-cap-ng         disable libcap-ng support
130908fb77edSStefan Weil  --enable-cap-ng          enable libcap-ng support
131008fb77edSStefan Weil  --disable-attr           disables attr and xattr support
131108fb77edSStefan Weil  --enable-attr            enable attr and xattr support
131208fb77edSStefan Weil  --disable-blobs          disable installing provided firmware blobs
131308fb77edSStefan Weil  --enable-docs            enable documentation build
131408fb77edSStefan Weil  --disable-docs           disable documentation build
131508fb77edSStefan Weil  --disable-vhost-net      disable vhost-net acceleration support
131608fb77edSStefan Weil  --enable-vhost-net       enable vhost-net acceleration support
131708fb77edSStefan Weil  --enable-trace-backend=B Set trace backend
131808fb77edSStefan Weil                           Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
131908fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
132008fb77edSStefan Weil                           Default:trace-<pid>
132108fb77edSStefan Weil  --disable-spice          disable spice
132208fb77edSStefan Weil  --enable-spice           enable spice
132308fb77edSStefan Weil  --enable-rbd             enable building the rados block device (rbd)
132408fb77edSStefan Weil  --disable-libiscsi       disable iscsi support
132508fb77edSStefan Weil  --enable-libiscsi        enable iscsi support
13266542aa9cSPeter Lieven  --disable-libnfs         disable nfs support
13276542aa9cSPeter Lieven  --enable-libnfs          enable nfs support
132808fb77edSStefan Weil  --disable-smartcard-nss  disable smartcard nss support
132908fb77edSStefan Weil  --enable-smartcard-nss   enable smartcard nss support
133008fb77edSStefan Weil  --disable-libusb         disable libusb (for usb passthrough)
133108fb77edSStefan Weil  --enable-libusb          enable libusb (for usb passthrough)
133208fb77edSStefan Weil  --disable-usb-redir      disable usb network redirection support
133308fb77edSStefan Weil  --enable-usb-redir       enable usb network redirection support
1334607dacd0Sqiaonuohan  --enable-lzo             enable the support of lzo compression library
1335607dacd0Sqiaonuohan  --enable-snappy          enable the support of snappy compression library
133608fb77edSStefan Weil  --disable-guest-agent    disable building of the QEMU Guest Agent
133708fb77edSStefan Weil  --enable-guest-agent     enable building of the QEMU Guest Agent
133808fb77edSStefan Weil  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
133908fb77edSStefan Weil  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
134008fb77edSStefan Weil  --disable-seccomp        disable seccomp support
134108fb77edSStefan Weil  --enable-seccomp         enables seccomp support
134208fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
134308fb77edSStefan Weil                           gthread, ucontext, sigaltstack, windows
134408fb77edSStefan Weil  --disable-coroutine-pool disable coroutine freelist (worse performance)
134508fb77edSStefan Weil  --enable-coroutine-pool  enable coroutine freelist (better performance)
134608fb77edSStefan Weil  --enable-glusterfs       enable GlusterFS backend
134708fb77edSStefan Weil  --disable-glusterfs      disable GlusterFS backend
134808fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
134908fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
135008fb77edSStefan Weil  --enable-tpm             enable TPM support
135108fb77edSStefan Weil  --disable-libssh2        disable ssh block device support
135208fb77edSStefan Weil  --enable-libssh2         enable ssh block device support
135308fb77edSStefan Weil  --disable-vhdx           disables support for the Microsoft VHDX image format
135408fb77edSStefan Weil  --enable-vhdx            enable support for the Microsoft VHDX image format
135595c6bff3SBenoît Canet  --disable-quorum         disable quorum block filter support
135695c6bff3SBenoît Canet  --enable-quorum          enable quorum block filter support
135708fb77edSStefan Weil
135808fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1359af5db58eSpbrookEOF
13602d2ad6d0SFam Zhengexit 0
1361af5db58eSpbrookfi
1362af5db58eSpbrook
1363359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1364359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1365359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1366359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1367359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1368359bc95dSPeter Maydell        ARCH=tci
1369359bc95dSPeter Maydell    else
137076ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1371359bc95dSPeter Maydell    fi
1372359bc95dSPeter Maydellfi
1373359bc95dSPeter Maydell
13749c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
13759c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
13769c83ffd8SPeter Maydellz_version=`cut -f3 -d. $source_path/VERSION`
13779c83ffd8SPeter Maydell
13789c83ffd8SPeter Maydellif test -z "$werror" ; then
13799c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
13809c83ffd8SPeter Maydell        "$linux" = "yes" ; then
13819c83ffd8SPeter Maydell        werror="yes"
13829c83ffd8SPeter Maydell    else
13839c83ffd8SPeter Maydell        werror="no"
13849c83ffd8SPeter Maydell    fi
13859c83ffd8SPeter Maydellfi
13869c83ffd8SPeter Maydell
13878d05095cSPaolo Bonzini# check that the C compiler works.
13888d05095cSPaolo Bonzinicat > $TMPC <<EOF
138975cafad7SStefan Weilint main(void) { return 0; }
13908d05095cSPaolo BonziniEOF
13918d05095cSPaolo Bonzini
13928d05095cSPaolo Bonziniif compile_object ; then
13938d05095cSPaolo Bonzini  : C compiler works ok
13948d05095cSPaolo Bonzinielse
139576ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
13968d05095cSPaolo Bonzinifi
13978d05095cSPaolo Bonzini
139898b21dcdSPeter Maydell# Check that the C++ compiler exists and works with the C compiler
139998b21dcdSPeter Maydellif has $cxx; then
140098b21dcdSPeter Maydell    cat > $TMPC <<EOF
140198b21dcdSPeter Maydellint c_function(void);
140298b21dcdSPeter Maydellint main(void) { return c_function(); }
140398b21dcdSPeter MaydellEOF
140498b21dcdSPeter Maydell
140598b21dcdSPeter Maydell    compile_object
140698b21dcdSPeter Maydell
14079c83ffd8SPeter Maydell    cat > $TMPCXX <<EOF
140898b21dcdSPeter Maydellextern "C" {
140998b21dcdSPeter Maydell   int c_function(void);
141098b21dcdSPeter Maydell}
141198b21dcdSPeter Maydellint c_function(void) { return 42; }
141298b21dcdSPeter MaydellEOF
141398b21dcdSPeter Maydell
14149c83ffd8SPeter Maydell    update_cxxflags
14159c83ffd8SPeter Maydell
14169c83ffd8SPeter Maydell    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
141798b21dcdSPeter Maydell        # C++ compiler $cxx works ok with C compiler $cc
141898b21dcdSPeter Maydell        :
141998b21dcdSPeter Maydell    else
142098b21dcdSPeter Maydell        echo "C++ compiler $cxx does not work with C compiler $cc"
142198b21dcdSPeter Maydell        echo "Disabling C++ specific optional code"
142298b21dcdSPeter Maydell        cxx=
142398b21dcdSPeter Maydell    fi
142498b21dcdSPeter Maydellelse
142598b21dcdSPeter Maydell    echo "No C++ compiler available; disabling C++ specific optional code"
142698b21dcdSPeter Maydell    cxx=
142798b21dcdSPeter Maydellfi
142898b21dcdSPeter Maydell
14298d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
14308d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
14318d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
143237746c5eSMarc-André Lureaugcc_flags="-Wendif-labels $gcc_flags"
1433c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
143471429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
14356ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
14366ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
14376ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
14386ca026cbSPeter Maydell# so it's too error prone.
14398d05095cSPaolo Bonzinicat > $TMPC << EOF
14408d05095cSPaolo Bonziniint main(void) { return 0; }
14418d05095cSPaolo BonziniEOF
14428d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1443a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1444a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1445a1d29d6cSPeter Maydell    # warning options).
1446a1d29d6cSPeter Maydell    optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1447a1d29d6cSPeter Maydell    if compile_prog "-Werror $optflag" "" ; then
14488d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
14498d05095cSPaolo Bonzini    fi
14508d05095cSPaolo Bonzinidone
14518d05095cSPaolo Bonzini
145263678e17SSteven Noonanif test "$stack_protector" != "no" ; then
145363678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
145463678e17SSteven Noonan  for flag in $gcc_flags; do
1455590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1456590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1457590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1458590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
145963678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
146063678e17SSteven Noonan      LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
146163678e17SSteven Noonan      break
146263678e17SSteven Noonan    fi
146363678e17SSteven Noonan  done
146437746c5eSMarc-André Lureaufi
146537746c5eSMarc-André Lureau
1466cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1467cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1468cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1469cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1470cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1471cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1472cbdd1999SPaolo Bonziniint main(void) { return 0; }
1473cbdd1999SPaolo Bonzini#else
1474cbdd1999SPaolo Bonzini#error No bug in this compiler.
1475cbdd1999SPaolo Bonzini#endif
1476cbdd1999SPaolo BonziniEOF
1477cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1478cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1479cbdd1999SPaolo Bonzinifi
1480cbdd1999SPaolo Bonzini
148140d6444eSAvi Kivityif test "$static" = "yes" ; then
1482aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1483aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1484aa0d1f44SPaolo Bonzini  fi
148540d6444eSAvi Kivity  if test "$pie" = "yes" ; then
148676ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
148740d6444eSAvi Kivity  else
148840d6444eSAvi Kivity    pie="no"
148940d6444eSAvi Kivity  fi
149040d6444eSAvi Kivityfi
149140d6444eSAvi Kivity
149240d6444eSAvi Kivityif test "$pie" = ""; then
149340d6444eSAvi Kivity  case "$cpu-$targetos" in
1494c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
149540d6444eSAvi Kivity      ;;
149640d6444eSAvi Kivity    *)
149740d6444eSAvi Kivity      pie="no"
149840d6444eSAvi Kivity      ;;
149940d6444eSAvi Kivity  esac
150040d6444eSAvi Kivityfi
150140d6444eSAvi Kivity
150240d6444eSAvi Kivityif test "$pie" != "no" ; then
150340d6444eSAvi Kivity  cat > $TMPC << EOF
150421d4a791SAvi Kivity
150521d4a791SAvi Kivity#ifdef __linux__
150621d4a791SAvi Kivity#  define THREAD __thread
150721d4a791SAvi Kivity#else
150821d4a791SAvi Kivity#  define THREAD
150921d4a791SAvi Kivity#endif
151021d4a791SAvi Kivity
151121d4a791SAvi Kivitystatic THREAD int tls_var;
151221d4a791SAvi Kivity
151321d4a791SAvi Kivityint main(void) { return tls_var; }
151421d4a791SAvi Kivity
151540d6444eSAvi KivityEOF
151640d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
151740d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
151840d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
151940d6444eSAvi Kivity    pie="yes"
152040d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
152140d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
152240d6444eSAvi Kivity    fi
152340d6444eSAvi Kivity  else
152440d6444eSAvi Kivity    if test "$pie" = "yes"; then
152576ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
152640d6444eSAvi Kivity    else
152740d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
152840d6444eSAvi Kivity      pie="no"
152940d6444eSAvi Kivity    fi
153040d6444eSAvi Kivity  fi
153146eef33bSBrad
153246eef33bSBrad  if compile_prog "-fno-pie" "-nopie"; then
153346eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
153446eef33bSBrad    LDFLAGS_NOPIE="-nopie"
153546eef33bSBrad  fi
153640d6444eSAvi Kivityfi
153740d6444eSAvi Kivity
153866518bf6SDon Slutz# check for broken gcc and libtool in RHEL5
153966518bf6SDon Slutzif test -n "$libtool" -a "$pie" != "no" ; then
154066518bf6SDon Slutz  cat > $TMPC <<EOF
154166518bf6SDon Slutz
154266518bf6SDon Slutzvoid *f(unsigned char *buf, int len);
154366518bf6SDon Slutzvoid *g(unsigned char *buf, int len);
154466518bf6SDon Slutz
154566518bf6SDon Slutzvoid *
154666518bf6SDon Slutzf(unsigned char *buf, int len)
154766518bf6SDon Slutz{
154866518bf6SDon Slutz    return (void*)0L;
154966518bf6SDon Slutz}
155066518bf6SDon Slutz
155166518bf6SDon Slutzvoid *
155266518bf6SDon Slutzg(unsigned char *buf, int len)
155366518bf6SDon Slutz{
155466518bf6SDon Slutz    return f(buf, len);
155566518bf6SDon Slutz}
155666518bf6SDon Slutz
155766518bf6SDon SlutzEOF
155866518bf6SDon Slutz  if ! libtool_prog; then
155966518bf6SDon Slutz    echo "Disabling libtool due to broken toolchain support"
156066518bf6SDon Slutz    libtool=
156166518bf6SDon Slutz  fi
156266518bf6SDon Slutzfi
156366518bf6SDon Slutz
156409dada40SPaolo Bonzini##########################################
156509dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
156609dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
156709dada40SPaolo Bonzini# specification is necessary
156809dada40SPaolo Bonzini
156909dada40SPaolo Bonziniif test "$cpu" = "i386"; then
157009dada40SPaolo Bonzini  cat > $TMPC << EOF
157109dada40SPaolo Bonzinistatic int sfaa(int *ptr)
157209dada40SPaolo Bonzini{
157309dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
157409dada40SPaolo Bonzini}
157509dada40SPaolo Bonzini
157609dada40SPaolo Bonziniint main(void)
157709dada40SPaolo Bonzini{
157809dada40SPaolo Bonzini  int val = 42;
15791405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
158009dada40SPaolo Bonzini  sfaa(&val);
158109dada40SPaolo Bonzini  return val;
158209dada40SPaolo Bonzini}
158309dada40SPaolo BonziniEOF
158409dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
158509dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
158609dada40SPaolo Bonzini  fi
158709dada40SPaolo Bonzinifi
158809dada40SPaolo Bonzini
158909dada40SPaolo Bonzini#########################################
1590ec530c81Sbellard# Solaris specific configure tool chain decisions
159109dada40SPaolo Bonzini
1592ec530c81Sbellardif test "$solaris" = "yes" ; then
15936792aa11SLoïc Minier  if has $install; then
15946792aa11SLoïc Minier    :
15956792aa11SLoïc Minier  else
159676ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
159776ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
159876ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1599ec530c81Sbellard  fi
16006792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
160176ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
160276ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
160376ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1604ec530c81Sbellard  fi
16056792aa11SLoïc Minier  if has ar; then
16066792aa11SLoïc Minier    :
16076792aa11SLoïc Minier  else
1608ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
160976ad07a4SPeter Maydell      error_exit "No path includes ar" \
161076ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1611ec530c81Sbellard    fi
161276ad07a4SPeter Maydell    error_exit "No path includes ar"
1613ec530c81Sbellard  fi
1614ec530c81Sbellardfi
1615ec530c81Sbellard
1616afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1617121afa9eSAnthony Liguori    target_list="$default_target_list"
1618121afa9eSAnthony Liguorielse
1619121afa9eSAnthony Liguori    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
16205327cf48Sbellardfi
162125b48338SPeter Maydell
162225b48338SPeter Maydell# Check that we recognised the target name; this allows a more
162325b48338SPeter Maydell# friendly error message than if we let it fall through.
162425b48338SPeter Maydellfor target in $target_list; do
162525b48338SPeter Maydell    case " $default_target_list " in
162625b48338SPeter Maydell        *" $target "*)
162725b48338SPeter Maydell            ;;
162825b48338SPeter Maydell        *)
162925b48338SPeter Maydell            error_exit "Unknown target name '$target'"
163025b48338SPeter Maydell            ;;
163125b48338SPeter Maydell    esac
163225b48338SPeter Maydelldone
163325b48338SPeter Maydell
1634f55fe278SPaolo Bonzini# see if system emulation was really requested
1635f55fe278SPaolo Bonzinicase " $target_list " in
1636f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1637f55fe278SPaolo Bonzini  ;;
1638f55fe278SPaolo Bonzini  *) softmmu=no
1639f55fe278SPaolo Bonzini  ;;
1640f55fe278SPaolo Bonziniesac
16415327cf48Sbellard
1642249247c9SJuan Quintelafeature_not_found() {
1643249247c9SJuan Quintela  feature=$1
164421684af0SStewart Smith  remedy=$2
1645249247c9SJuan Quintela
164676ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
164721684af0SStewart Smith      "configure was not able to find it." \
164821684af0SStewart Smith      "$remedy"
1649249247c9SJuan Quintela}
1650249247c9SJuan Quintela
16517d13299dSbellard# ---
16527d13299dSbellard# big/little endian test
16537d13299dSbellardcat > $TMPC << EOF
165461cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
165561cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
165661cc919fSMike Frysingerextern int foo(short *, short *);
165761cc919fSMike Frysingerint main(int argc, char *argv[]) {
165861cc919fSMike Frysinger    return foo(big_endian, little_endian);
16597d13299dSbellard}
16607d13299dSbellardEOF
16617d13299dSbellard
166261cc919fSMike Frysingerif compile_object ; then
166361cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
166461cc919fSMike Frysinger        bigendian="yes"
166561cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
166661cc919fSMike Frysinger        bigendian="no"
16677d13299dSbellard    else
16687d13299dSbellard        echo big/little test failed
16697d13299dSbellard    fi
16707d13299dSbellardelse
167161cc919fSMike Frysinger    echo big/little test failed
16727d13299dSbellardfi
16737d13299dSbellard
1674b0a47e79SJuan Quintela##########################################
1675779ab5e3SStefan Weil# pkg-config probe
1676779ab5e3SStefan Weil
1677779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
167876ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1679779ab5e3SStefan Weilfi
1680779ab5e3SStefan Weil
1681779ab5e3SStefan Weil##########################################
1682b0a47e79SJuan Quintela# NPTL probe
1683b0a47e79SJuan Quintela
168424cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1685bd0c5661Spbrook  cat > $TMPC <<EOF
1686bd0c5661Spbrook#include <sched.h>
168730813ceaSpbrook#include <linux/futex.h>
1688182eacc0SStefan Weilint main(void) {
1689bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1690bd0c5661Spbrook#error bork
1691bd0c5661Spbrook#endif
1692182eacc0SStefan Weil  return 0;
1693bd0c5661Spbrook}
1694bd0c5661SpbrookEOF
169524cb36a6SPeter Maydell  if ! compile_object ; then
169621684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
1697b0a47e79SJuan Quintela  fi
1698bd0c5661Spbrookfi
1699bd0c5661Spbrook
170011d9f695Sbellard##########################################
1701ac62922eSbalrog# zlib check
1702ac62922eSbalrog
17031ece9905SAlon Levyif test "$zlib" != "no" ; then
1704ac62922eSbalrog    cat > $TMPC << EOF
1705ac62922eSbalrog#include <zlib.h>
1706ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1707ac62922eSbalrogEOF
170852166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1709ac62922eSbalrog        :
1710ac62922eSbalrog    else
171176ad07a4SPeter Maydell        error_exit "zlib check failed" \
171276ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1713ac62922eSbalrog    fi
17141ece9905SAlon Levyfi
1715eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
1716ac62922eSbalrog
1717ac62922eSbalrog##########################################
1718607dacd0Sqiaonuohan# lzo check
1719607dacd0Sqiaonuohan
1720607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
1721607dacd0Sqiaonuohan    cat > $TMPC << EOF
1722607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
1723607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
1724607dacd0SqiaonuohanEOF
1725607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
1726607dacd0Sqiaonuohan        :
1727607dacd0Sqiaonuohan    else
1728607dacd0Sqiaonuohan        error_exit "lzo check failed" \
1729607dacd0Sqiaonuohan            "Make sure to have the lzo libs and headers installed."
1730607dacd0Sqiaonuohan    fi
1731607dacd0Sqiaonuohan
1732607dacd0Sqiaonuohan    libs_softmmu="$libs_softmmu -llzo2"
1733607dacd0Sqiaonuohanfi
1734607dacd0Sqiaonuohan
1735607dacd0Sqiaonuohan##########################################
1736607dacd0Sqiaonuohan# snappy check
1737607dacd0Sqiaonuohan
1738607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
1739607dacd0Sqiaonuohan    cat > $TMPC << EOF
1740607dacd0Sqiaonuohan#include <snappy-c.h>
1741607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
1742607dacd0SqiaonuohanEOF
1743607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
1744607dacd0Sqiaonuohan        :
1745607dacd0Sqiaonuohan    else
1746607dacd0Sqiaonuohan        error_exit "snappy check failed" \
1747607dacd0Sqiaonuohan            "Make sure to have the snappy libs and headers installed."
1748607dacd0Sqiaonuohan    fi
1749607dacd0Sqiaonuohan
1750607dacd0Sqiaonuohan    libs_softmmu="$libs_softmmu -lsnappy"
1751607dacd0Sqiaonuohanfi
1752607dacd0Sqiaonuohan
1753607dacd0Sqiaonuohan##########################################
1754f794573eSEduardo Otubo# libseccomp check
1755f794573eSEduardo Otubo
1756f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
175765d5d3f9SStefan Weil    if $pkg_config --atleast-version=2.1.0 libseccomp; then
1758b4451996SMichael Tokarev        libs_softmmu="$libs_softmmu `$pkg_config --libs libseccomp`"
1759372e47e9SAndreas Färber        QEMU_CFLAGS="$QEMU_CFLAGS `$pkg_config --cflags libseccomp`"
1760f794573eSEduardo Otubo	seccomp="yes"
1761f794573eSEduardo Otubo    else
1762f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
176321684af0SStewart Smith            feature_not_found "libseccomp" "Install libseccomp devel >= 2.1.0"
1764f794573eSEduardo Otubo	fi
1765e84d5956SYann E. MORIN	seccomp="no"
1766f794573eSEduardo Otubo    fi
1767f794573eSEduardo Otubofi
1768f794573eSEduardo Otubo##########################################
1769e37630caSaliguori# xen probe
1770e37630caSaliguori
1771fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1772b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1773d5b93ddfSAnthony PERARD
177450ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
177550ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
177650ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
177750ced5b3SStefan Weil
177850ced5b3SStefan Weil  # Xen (any)
177950ced5b3SStefan Weil  cat > $TMPC <<EOF
178050ced5b3SStefan Weil#include <xenctrl.h>
178150ced5b3SStefan Weilint main(void) {
178250ced5b3SStefan Weil  return 0;
178350ced5b3SStefan Weil}
178450ced5b3SStefan WeilEOF
178550ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
178650ced5b3SStefan Weil    # Xen not found
178750ced5b3SStefan Weil    if test "$xen" = "yes" ; then
178821684af0SStewart Smith      feature_not_found "xen" "Install xen devel"
178950ced5b3SStefan Weil    fi
179050ced5b3SStefan Weil    xen=no
179150ced5b3SStefan Weil
1792d5b93ddfSAnthony PERARD  # Xen unstable
179369deef08SPeter Maydell  elif
179469deef08SPeter Maydell      cat > $TMPC <<EOF &&
1795e37630caSaliguori#include <xenctrl.h>
1796e108a3c1SAnthony PERARD#include <xenstore.h>
1797d5b93ddfSAnthony PERARD#include <stdint.h>
1798d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1799d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1800d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1801d5b93ddfSAnthony PERARD#endif
1802d5b93ddfSAnthony PERARDint main(void) {
1803d5b93ddfSAnthony PERARD  xc_interface *xc;
1804d5b93ddfSAnthony PERARD  xs_daemon_open();
1805d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1806d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1807d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1808b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
18098688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
18108688e065SStefano Stabellini  return 0;
18118688e065SStefano Stabellini}
18128688e065SStefano StabelliniEOF
18138688e065SStefano Stabellini      compile_prog "" "$xen_libs"
181469deef08SPeter Maydell    then
18158688e065SStefano Stabellini    xen_ctrl_version=420
18168688e065SStefano Stabellini    xen=yes
18178688e065SStefano Stabellini
181869deef08SPeter Maydell  elif
181969deef08SPeter Maydell      cat > $TMPC <<EOF &&
18208688e065SStefano Stabellini#include <xenctrl.h>
18218688e065SStefano Stabellini#include <xs.h>
18228688e065SStefano Stabellini#include <stdint.h>
18238688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
18248688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
18258688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
18268688e065SStefano Stabellini#endif
18278688e065SStefano Stabelliniint main(void) {
18288688e065SStefano Stabellini  xs_daemon_open();
18299b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
18308688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
18318688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
18328688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1833d5b93ddfSAnthony PERARD  return 0;
1834d5b93ddfSAnthony PERARD}
1835e37630caSaliguoriEOF
183650ced5b3SStefan Weil      compile_prog "" "$xen_libs"
183769deef08SPeter Maydell    then
1838d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1839fc321b4bSJuan Quintela    xen=yes
1840d5b93ddfSAnthony PERARD
1841d5b93ddfSAnthony PERARD  # Xen 4.0.0
184269deef08SPeter Maydell  elif
184369deef08SPeter Maydell      cat > $TMPC <<EOF &&
1844d5b93ddfSAnthony PERARD#include <xenctrl.h>
1845d5b93ddfSAnthony PERARD#include <xs.h>
1846d5b93ddfSAnthony PERARD#include <stdint.h>
1847d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1848d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1849d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1850d5b93ddfSAnthony PERARD#endif
1851d5b93ddfSAnthony PERARDint main(void) {
1852b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1853b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1854b87de24eSAnthony PERARD  };
1855d5b93ddfSAnthony PERARD  xs_daemon_open();
1856d5b93ddfSAnthony PERARD  xc_interface_open();
1857d5b93ddfSAnthony PERARD  xc_gnttab_open();
1858d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1859b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1860d5b93ddfSAnthony PERARD  return 0;
1861d5b93ddfSAnthony PERARD}
1862d5b93ddfSAnthony PERARDEOF
1863d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
186469deef08SPeter Maydell    then
1865d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1866d5b93ddfSAnthony PERARD    xen=yes
1867d5b93ddfSAnthony PERARD
1868b87de24eSAnthony PERARD  # Xen 3.4.0
186969deef08SPeter Maydell  elif
187069deef08SPeter Maydell      cat > $TMPC <<EOF &&
1871b87de24eSAnthony PERARD#include <xenctrl.h>
1872b87de24eSAnthony PERARD#include <xs.h>
1873b87de24eSAnthony PERARDint main(void) {
1874b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1875b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1876b87de24eSAnthony PERARD  };
1877b87de24eSAnthony PERARD  xs_daemon_open();
1878b87de24eSAnthony PERARD  xc_interface_open();
1879b87de24eSAnthony PERARD  xc_gnttab_open();
1880b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1881b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1882b87de24eSAnthony PERARD  return 0;
1883b87de24eSAnthony PERARD}
1884b87de24eSAnthony PERARDEOF
1885b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
188669deef08SPeter Maydell    then
1887b87de24eSAnthony PERARD    xen_ctrl_version=340
1888b87de24eSAnthony PERARD    xen=yes
1889b87de24eSAnthony PERARD
1890b87de24eSAnthony PERARD  # Xen 3.3.0
189169deef08SPeter Maydell  elif
189269deef08SPeter Maydell      cat > $TMPC <<EOF &&
1893d5b93ddfSAnthony PERARD#include <xenctrl.h>
1894d5b93ddfSAnthony PERARD#include <xs.h>
1895d5b93ddfSAnthony PERARDint main(void) {
1896d5b93ddfSAnthony PERARD  xs_daemon_open();
1897d5b93ddfSAnthony PERARD  xc_interface_open();
1898d5b93ddfSAnthony PERARD  xc_gnttab_open();
1899d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1900d5b93ddfSAnthony PERARD  return 0;
1901d5b93ddfSAnthony PERARD}
1902d5b93ddfSAnthony PERARDEOF
1903d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
190469deef08SPeter Maydell    then
1905d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1906d5b93ddfSAnthony PERARD    xen=yes
1907d5b93ddfSAnthony PERARD
190850ced5b3SStefan Weil  # Xen version unsupported
1909e37630caSaliguori  else
1910fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
191121684af0SStewart Smith      feature_not_found "xen (unsupported version)" "Install supported xen (e.g. 4.0, 3.4, 3.3)"
1912fc321b4bSJuan Quintela    fi
1913fc321b4bSJuan Quintela    xen=no
1914e37630caSaliguori  fi
1915d5b93ddfSAnthony PERARD
1916d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1917d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1918d5b93ddfSAnthony PERARD  fi
1919e37630caSaliguorifi
1920e37630caSaliguori
1921eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1922eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1923eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1924eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1925eb6fda0fSAnthony PERARD  else
1926eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1927eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
192876ad07a4SPeter Maydell        error_exit "User requested feature Xen PCI Passthrough" \
192976ad07a4SPeter Maydell            "This feature does not work with Xen 3.3"
1930eb6fda0fSAnthony PERARD      fi
193176ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
193276ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
1933eb6fda0fSAnthony PERARD    fi
1934eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1935eb6fda0fSAnthony PERARD  fi
1936eb6fda0fSAnthony PERARDfi
1937eb6fda0fSAnthony PERARD
1938e37630caSaliguori##########################################
193944dc0ca3SAlon Levy# libtool probe
194044dc0ca3SAlon Levy
19413f534581SBradif ! has $libtool; then
194244dc0ca3SAlon Levy    libtool=
194344dc0ca3SAlon Levyfi
194444dc0ca3SAlon Levy
19458e515b12SPeter Maydell# MacOSX ships with a libtool which isn't the GNU one; weed this
19468e515b12SPeter Maydell# out by checking whether libtool supports the --version switch
19478e515b12SPeter Maydellif test -n "$libtool"; then
19488e515b12SPeter Maydell  if ! "$libtool" --version >/dev/null 2>&1; then
19498e515b12SPeter Maydell    libtool=
19508e515b12SPeter Maydell  fi
19518e515b12SPeter Maydellfi
19528e515b12SPeter Maydell
195344dc0ca3SAlon Levy##########################################
1954dfffc653SJuan Quintela# Sparse probe
1955dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
19560dba6195SLoïc Minier  if has cgcc; then
1957dfffc653SJuan Quintela    sparse=yes
1958dfffc653SJuan Quintela  else
1959dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
196021684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
1961dfffc653SJuan Quintela    fi
1962dfffc653SJuan Quintela    sparse=no
1963dfffc653SJuan Quintela  fi
1964dfffc653SJuan Quintelafi
1965dfffc653SJuan Quintela
1966dfffc653SJuan Quintela##########################################
1967a4ccabcfSAnthony Liguori# GTK probe
1968a4ccabcfSAnthony Liguori
1969a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
1970528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
1971528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
1972528de90aSDaniel P. Berrange      gtkversion="3.0.0"
1973bbbf9bfbSStefan Weil    else
1974bbbf9bfbSStefan Weil      gtkversion="2.18.0"
1975bbbf9bfbSStefan Weil    fi
1976bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
1977bbbf9bfbSStefan Weil        gtk_cflags=`$pkg_config --cflags $gtkpackage`
1978bbbf9bfbSStefan Weil        gtk_libs=`$pkg_config --libs $gtkpackage`
1979bbbf9bfbSStefan Weil        libs_softmmu="$gtk_libs $libs_softmmu"
1980bbbf9bfbSStefan Weil        gtk="yes"
1981bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
1982bbbf9bfbSStefan Weil        feature_not_found "gtk" "Install gtk2 or gtk3 (requires --with-gtkabi=3.0 option to configure) devel"
1983bbbf9bfbSStefan Weil    else
1984bbbf9bfbSStefan Weil        gtk="no"
1985bbbf9bfbSStefan Weil    fi
1986bbbf9bfbSStefan Weilfi
1987bbbf9bfbSStefan Weil
1988bbbf9bfbSStefan Weil##########################################
1989bbbf9bfbSStefan Weil# VTE probe
1990bbbf9bfbSStefan Weil
1991bbbf9bfbSStefan Weilif test "$vte" != "no"; then
1992bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
1993528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
1994528de90aSDaniel P. Berrange      vteversion="0.32.0"
1995528de90aSDaniel P. Berrange    else
1996528de90aSDaniel P. Berrange      vtepackage="vte"
1997528de90aSDaniel P. Berrange      vteversion="0.24.0"
1998528de90aSDaniel P. Berrange    fi
1999bbbf9bfbSStefan Weil    if $pkg_config --exists "$vtepackage >= $vteversion"; then
2000ca871ec8SStefan Weil        vte_cflags=`$pkg_config --cflags $vtepackage`
2001ca871ec8SStefan Weil        vte_libs=`$pkg_config --libs $vtepackage`
2002bbbf9bfbSStefan Weil        libs_softmmu="$vte_libs $libs_softmmu"
2003bbbf9bfbSStefan Weil        vte="yes"
2004bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
2005bbbf9bfbSStefan Weil        feature_not_found "vte" "Install libvte or libvte-2.90 (requires --with-gtkabi=3.0 option to configure) devel"
2006bbbf9bfbSStefan Weil    else
2007bbbf9bfbSStefan Weil        vte="no"
2008a4ccabcfSAnthony Liguori    fi
2009a4ccabcfSAnthony Liguorifi
2010a4ccabcfSAnthony Liguori
2011a4ccabcfSAnthony Liguori##########################################
201211d9f695Sbellard# SDL probe
201311d9f695Sbellard
20143ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
20153ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
201647c03744SDave Airlie
201747c03744SDave Airlieif test $sdlabi = "2.0"; then
201847c03744SDave Airlie    sdl_config=$sdl2_config
201947c03744SDave Airlie    sdlname=sdl2
202047c03744SDave Airlie    sdlconfigname=sdl2_config
202147c03744SDave Airlieelse
202247c03744SDave Airlie    sdlname=sdl
202347c03744SDave Airlie    sdlconfigname=sdl_config
20243ec87ffeSPaolo Bonzinifi
20253ec87ffeSPaolo Bonzini
202647c03744SDave Airlieif test "`basename $sdl_config`" != $sdlconfigname && ! has ${sdl_config}; then
202747c03744SDave Airlie  sdl_config=$sdlconfigname
202847c03744SDave Airliefi
202947c03744SDave Airlie
203047c03744SDave Airlieif $pkg_config $sdlname --exists; then
203147c03744SDave Airlie  sdlconfig="$pkg_config $sdlname"
2032fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
20333ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
20343ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
20359316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
2036a0dfd8a4SLoïc Minierelse
2037a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
203821684af0SStewart Smith    feature_not_found "sdl" "Install SDL devel"
2039a0dfd8a4SLoïc Minier  fi
2040a0dfd8a4SLoïc Minier  sdl=no
20419316f803SPaolo Bonzinifi
204229e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
20433ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
20443ec87ffeSPaolo Bonzinifi
204511d9f695Sbellard
20469316f803SPaolo Bonzinisdl_too_old=no
2047c4198157SJuan Quintelaif test "$sdl" != "no" ; then
204811d9f695Sbellard  cat > $TMPC << EOF
204911d9f695Sbellard#include <SDL.h>
205011d9f695Sbellard#undef main /* We don't want SDL to override our main() */
205111d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
205211d9f695SbellardEOF
20539316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
205474f42e18STeLeMan  if test "$static" = "yes" ; then
205574f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
205674f42e18STeLeMan  else
20579316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
205874f42e18STeLeMan  fi
205952166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
206011d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
206111d9f695Sbellard      sdl_too_old=yes
206211d9f695Sbellard    else
2063fd677642Sths      if test "$cocoa" = "no" ; then
206411d9f695Sbellard        sdl=yes
206511d9f695Sbellard      fi
2066fd677642Sths    fi
20677c1f25b4Sbellard
206867c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
20691ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
207067c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2071f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
2072f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
207311d9f695Sbellard      fi
207452166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
20751ac88f28SJuan Quintela	:
20761ac88f28SJuan Quintela      else
20771ac88f28SJuan Quintela        sdl=no
20787c1f25b4Sbellard      fi
20797c1f25b4Sbellard    fi # static link
2080c4198157SJuan Quintela  else # sdl not found
2081c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
208221684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2083c4198157SJuan Quintela    fi
2084c4198157SJuan Quintela    sdl=no
20857c1f25b4Sbellard  fi # sdl compile test
2086fd677642Sthsfi
208711d9f695Sbellard
20885368a422Saliguoriif test "$sdl" = "yes" ; then
20895368a422Saliguori  cat > $TMPC <<EOF
20905368a422Saliguori#include <SDL.h>
20915368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
20925368a422Saliguori#include <X11/XKBlib.h>
20935368a422Saliguori#else
20945368a422Saliguori#error No x11 support
20955368a422Saliguori#endif
20965368a422Saliguoriint main(void) { return 0; }
20975368a422SaliguoriEOF
209852166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2099681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
21005368a422Saliguori  fi
21010705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
21025368a422Saliguorifi
21035368a422Saliguori
21048f28f3fbSths##########################################
21052da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
21062da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
21072da776dbSMichael R. Hines  cat > $TMPC <<EOF
21082da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
21092da776dbSMichael R. Hinesint main(void) { return 0; }
21102da776dbSMichael R. HinesEOF
21112da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
21122da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
21132da776dbSMichael R. Hines    rdma="yes"
21142da776dbSMichael R. Hines    libs_softmmu="$libs_softmmu $rdma_libs"
21152da776dbSMichael R. Hines  else
21162da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
21172da776dbSMichael R. Hines        error_exit \
21182da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
21192da776dbSMichael R. Hines            " Your options:" \
21202da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
21212da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
21222da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
21232da776dbSMichael R. Hines    fi
21242da776dbSMichael R. Hines    rdma="no"
21252da776dbSMichael R. Hines  fi
21262da776dbSMichael R. Hinesfi
21272da776dbSMichael R. Hines
21282da776dbSMichael R. Hines##########################################
21297536ee4bSTim Hardeck# VNC TLS/WS detection
21307536ee4bSTim Hardeckif test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then
2131ae6b5e5aSaliguori  cat > $TMPC <<EOF
2132ae6b5e5aSaliguori#include <gnutls/gnutls.h>
2133ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
2134ae6b5e5aSaliguoriEOF
2135a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
2136a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
213752166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
21387536ee4bSTim Hardeck    if test "$vnc_tls" != "no" ; then
21391be10ad2SJuan Quintela      vnc_tls=yes
21407536ee4bSTim Hardeck    fi
21417536ee4bSTim Hardeck    if test "$vnc_ws" != "no" ; then
21427536ee4bSTim Hardeck      vnc_ws=yes
21437536ee4bSTim Hardeck    fi
2144a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
2145ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
2146ae6b5e5aSaliguori  else
21471be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
214821684af0SStewart Smith      feature_not_found "vnc-tls" "Install gnutls devel"
21491be10ad2SJuan Quintela    fi
21507536ee4bSTim Hardeck    if test "$vnc_ws" = "yes" ; then
215121684af0SStewart Smith      feature_not_found "vnc-ws" "Install gnutls devel"
21527536ee4bSTim Hardeck    fi
21531be10ad2SJuan Quintela    vnc_tls=no
21547536ee4bSTim Hardeck    vnc_ws=no
21558d5d2d4cSths  fi
21568d5d2d4cSthsfi
21578d5d2d4cSths
21588d5d2d4cSths##########################################
215995c6bff3SBenoît Canet# Quorum probe (check for gnutls)
216095c6bff3SBenoît Canetif test "$quorum" != "no" ; then
216195c6bff3SBenoît Canetcat > $TMPC <<EOF
216295c6bff3SBenoît Canet#include <gnutls/gnutls.h>
216395c6bff3SBenoît Canet#include <gnutls/crypto.h>
216495c6bff3SBenoît Canetint main(void) {char data[4096], digest[32];
216595c6bff3SBenoît Canetgnutls_hash_fast(GNUTLS_DIG_SHA256, data, 4096, digest);
216695c6bff3SBenoît Canetreturn 0;
216795c6bff3SBenoît Canet}
216895c6bff3SBenoît CanetEOF
216995c6bff3SBenoît Canetquorum_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
217095c6bff3SBenoît Canetquorum_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
217195c6bff3SBenoît Canetif compile_prog "$quorum_tls_cflags" "$quorum_tls_libs" ; then
217295c6bff3SBenoît Canet  qcow_tls=yes
217395c6bff3SBenoît Canet  libs_softmmu="$quorum_tls_libs $libs_softmmu"
217495c6bff3SBenoît Canet  libs_tools="$quorum_tls_libs $libs_softmmu"
217595c6bff3SBenoît Canet  QEMU_CFLAGS="$QEMU_CFLAGS $quorum_tls_cflags"
217695c6bff3SBenoît Canetelse
217795c6bff3SBenoît Canet  echo "gnutls > 2.10.0 required to compile Quorum"
217895c6bff3SBenoît Canet  exit 1
217995c6bff3SBenoît Canetfi
218095c6bff3SBenoît Canetfi
218195c6bff3SBenoît Canet
218295c6bff3SBenoît Canet##########################################
21832f9606b3Saliguori# VNC SASL detection
2184821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
21852f9606b3Saliguori  cat > $TMPC <<EOF
21862f9606b3Saliguori#include <sasl/sasl.h>
21872f9606b3Saliguori#include <stdio.h>
21882f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
21892f9606b3SaliguoriEOF
21902f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
21912f9606b3Saliguori  vnc_sasl_cflags=""
21922f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
219352166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2194ea784e3bSJuan Quintela    vnc_sasl=yes
2195fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2196ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
21972f9606b3Saliguori  else
2198ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
219921684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2200ea784e3bSJuan Quintela    fi
2201ea784e3bSJuan Quintela    vnc_sasl=no
22022f9606b3Saliguori  fi
22032f9606b3Saliguorifi
22042f9606b3Saliguori
22052f9606b3Saliguori##########################################
22062f6f5c7aSCorentin Chary# VNC JPEG detection
2207821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
22082f6f5c7aSCorentin Charycat > $TMPC <<EOF
22092f6f5c7aSCorentin Chary#include <stdio.h>
22102f6f5c7aSCorentin Chary#include <jpeglib.h>
22112f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
22122f6f5c7aSCorentin CharyEOF
22132f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
22142f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
22152f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
22162f6f5c7aSCorentin Chary    vnc_jpeg=yes
22172f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2218ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
22192f6f5c7aSCorentin Chary  else
22202f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
222121684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
22222f6f5c7aSCorentin Chary    fi
22232f6f5c7aSCorentin Chary    vnc_jpeg=no
22242f6f5c7aSCorentin Chary  fi
22252f6f5c7aSCorentin Charyfi
22262f6f5c7aSCorentin Chary
22272f6f5c7aSCorentin Chary##########################################
2228efe556adSCorentin Chary# VNC PNG detection
2229821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2230efe556adSCorentin Charycat > $TMPC <<EOF
2231efe556adSCorentin Chary//#include <stdio.h>
2232efe556adSCorentin Chary#include <png.h>
2233832ce9c2SScott Wood#include <stddef.h>
2234efe556adSCorentin Charyint main(void) {
2235efe556adSCorentin Chary    png_structp png_ptr;
2236efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
22377edc3fedSPeter Maydell    return png_ptr != 0;
2238efe556adSCorentin Chary}
2239efe556adSCorentin CharyEOF
224065d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
2241ca871ec8SStefan Weil    vnc_png_cflags=`$pkg_config libpng --cflags`
2242ca871ec8SStefan Weil    vnc_png_libs=`$pkg_config libpng --libs`
22439af8025eSBrad  else
2244efe556adSCorentin Chary    vnc_png_cflags=""
2245efe556adSCorentin Chary    vnc_png_libs="-lpng"
22469af8025eSBrad  fi
2247efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2248efe556adSCorentin Chary    vnc_png=yes
2249efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
22509af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2251efe556adSCorentin Chary  else
2252efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
225321684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2254efe556adSCorentin Chary    fi
2255efe556adSCorentin Chary    vnc_png=no
2256efe556adSCorentin Chary  fi
2257efe556adSCorentin Charyfi
2258efe556adSCorentin Chary
2259efe556adSCorentin Chary##########################################
226076655d6dSaliguori# fnmatch() probe, used for ACL routines
226176655d6dSaliguorifnmatch="no"
226276655d6dSaliguoricat > $TMPC << EOF
226376655d6dSaliguori#include <fnmatch.h>
226476655d6dSaliguoriint main(void)
226576655d6dSaliguori{
226676655d6dSaliguori    fnmatch("foo", "foo", 0);
226776655d6dSaliguori    return 0;
226876655d6dSaliguori}
226976655d6dSaliguoriEOF
227052166aa0SJuan Quintelaif compile_prog "" "" ; then
227176655d6dSaliguori   fnmatch="yes"
227276655d6dSaliguorifi
227376655d6dSaliguori
227476655d6dSaliguori##########################################
2275ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
22762d16c8e9SPeter Maydell# Note that on some systems (notably MacOSX) no extra library
22772d16c8e9SPeter Maydell# need be linked to get the uuid functions.
2278ee682d27SStefan Weilif test "$uuid" != "no" ; then
2279ee682d27SStefan Weil  uuid_libs="-luuid"
2280ee682d27SStefan Weil  cat > $TMPC << EOF
2281ee682d27SStefan Weil#include <uuid/uuid.h>
2282ee682d27SStefan Weilint main(void)
2283ee682d27SStefan Weil{
2284ee682d27SStefan Weil    uuid_t my_uuid;
2285ee682d27SStefan Weil    uuid_generate(my_uuid);
2286ee682d27SStefan Weil    return 0;
2287ee682d27SStefan Weil}
2288ee682d27SStefan WeilEOF
22892d16c8e9SPeter Maydell  if compile_prog "" "" ; then
22902d16c8e9SPeter Maydell    uuid="yes"
22912d16c8e9SPeter Maydell  elif compile_prog "" "$uuid_libs" ; then
2292ee682d27SStefan Weil    uuid="yes"
2293ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
2294ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
2295ee682d27SStefan Weil  else
2296ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
229721684af0SStewart Smith      feature_not_found "uuid" "Install libuuid devel"
2298ee682d27SStefan Weil    fi
2299ee682d27SStefan Weil    uuid=no
2300ee682d27SStefan Weil  fi
2301ee682d27SStefan Weilfi
2302ee682d27SStefan Weil
23034f18b782SJeff Codyif test "$vhdx" = "yes" ; then
23044f18b782SJeff Cody    if test "$uuid" = "no" ; then
23054f18b782SJeff Cody        error_exit "uuid required for VHDX support"
23064f18b782SJeff Cody    fi
23074f18b782SJeff Codyelif test "$vhdx" != "no" ; then
23084f18b782SJeff Cody    if test "$uuid" = "yes" ; then
23094f18b782SJeff Cody        vhdx=yes
23104f18b782SJeff Cody    else
23114f18b782SJeff Cody        vhdx=no
23124f18b782SJeff Cody    fi
23134f18b782SJeff Codyfi
23144f18b782SJeff Cody
2315ee682d27SStefan Weil##########################################
2316dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
2317dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2318dce512deSChristoph Hellwig  cat > $TMPC << EOF
2319ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2320dce512deSChristoph Hellwig#include <xfs/xfs.h>
2321dce512deSChristoph Hellwigint main(void)
2322dce512deSChristoph Hellwig{
2323dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2324dce512deSChristoph Hellwig    return 0;
2325dce512deSChristoph Hellwig}
2326dce512deSChristoph HellwigEOF
2327dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2328dce512deSChristoph Hellwig    xfs="yes"
2329dce512deSChristoph Hellwig  else
2330dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
233121684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2332dce512deSChristoph Hellwig    fi
2333dce512deSChristoph Hellwig    xfs=no
2334dce512deSChristoph Hellwig  fi
2335dce512deSChristoph Hellwigfi
2336dce512deSChristoph Hellwig
2337dce512deSChristoph Hellwig##########################################
23388a16d273Sths# vde libraries probe
2339dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
23404baae0acSJuan Quintela  vde_libs="-lvdeplug"
23418a16d273Sths  cat > $TMPC << EOF
23428a16d273Sths#include <libvdeplug.h>
23434a7f0e06Spbrookint main(void)
23444a7f0e06Spbrook{
23454a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2346fea08e08SPeter Maydell    char s[] = "";
2347fea08e08SPeter Maydell    vde_open(s, s, &a);
23484a7f0e06Spbrook    return 0;
23494a7f0e06Spbrook}
23508a16d273SthsEOF
235152166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
23524baae0acSJuan Quintela    vde=yes
23538e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
23548e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2355dfb278bdSJuan Quintela  else
2356dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
235721684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2358dfb278bdSJuan Quintela    fi
2359dfb278bdSJuan Quintela    vde=no
23608a16d273Sths  fi
23618a16d273Sthsfi
23628a16d273Sths
23638a16d273Sths##########################################
23640a985b37SVincenzo Maffione# netmap support probe
23650a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
23660a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
23670a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
23680a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
23690a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
237058952137SVincenzo Maffioneif test "$netmap" != "no" ; then
237158952137SVincenzo Maffione  cat > $TMPC << EOF
237258952137SVincenzo Maffione#include <inttypes.h>
237358952137SVincenzo Maffione#include <net/if.h>
237458952137SVincenzo Maffione#include <net/netmap.h>
237558952137SVincenzo Maffione#include <net/netmap_user.h>
23760a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
23770a985b37SVincenzo Maffione#error
23780a985b37SVincenzo Maffione#endif
237958952137SVincenzo Maffioneint main(void) { return 0; }
238058952137SVincenzo MaffioneEOF
238158952137SVincenzo Maffione  if compile_prog "" "" ; then
238258952137SVincenzo Maffione    netmap=yes
238358952137SVincenzo Maffione  else
238458952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
238558952137SVincenzo Maffione      feature_not_found "netmap"
238658952137SVincenzo Maffione    fi
238758952137SVincenzo Maffione    netmap=no
238858952137SVincenzo Maffione  fi
238958952137SVincenzo Maffionefi
239058952137SVincenzo Maffione
239158952137SVincenzo Maffione##########################################
239247e98658SCorey Bryant# libcap-ng library probe
239347e98658SCorey Bryantif test "$cap_ng" != "no" ; then
239447e98658SCorey Bryant  cap_libs="-lcap-ng"
239547e98658SCorey Bryant  cat > $TMPC << EOF
239647e98658SCorey Bryant#include <cap-ng.h>
239747e98658SCorey Bryantint main(void)
239847e98658SCorey Bryant{
239947e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
240047e98658SCorey Bryant    return 0;
240147e98658SCorey Bryant}
240247e98658SCorey BryantEOF
240347e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
240447e98658SCorey Bryant    cap_ng=yes
240547e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
240647e98658SCorey Bryant  else
240747e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
240821684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
240947e98658SCorey Bryant    fi
241047e98658SCorey Bryant    cap_ng=no
241147e98658SCorey Bryant  fi
241247e98658SCorey Bryantfi
241347e98658SCorey Bryant
241447e98658SCorey Bryant##########################################
2415c2de5c91Smalc# Sound support libraries probe
24168f28f3fbSths
2417c2de5c91Smalcaudio_drv_probe()
2418c2de5c91Smalc{
2419c2de5c91Smalc    drv=$1
2420c2de5c91Smalc    hdr=$2
2421c2de5c91Smalc    lib=$3
2422c2de5c91Smalc    exp=$4
2423c2de5c91Smalc    cfl=$5
24248f28f3fbSths        cat > $TMPC << EOF
2425c2de5c91Smalc#include <$hdr>
2426c2de5c91Smalcint main(void) { $exp }
24278f28f3fbSthsEOF
242852166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
24298f28f3fbSths        :
24308f28f3fbSths    else
243176ad07a4SPeter Maydell        error_exit "$drv check failed" \
243276ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
24338f28f3fbSths    fi
2434c2de5c91Smalc}
2435c2de5c91Smalc
24362fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
2437c2de5c91Smalcfor drv in $audio_drv_list; do
2438c2de5c91Smalc    case $drv in
2439c2de5c91Smalc    alsa)
2440c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
2441e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
2442a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
2443c2de5c91Smalc    ;;
2444c2de5c91Smalc
2445c2de5c91Smalc    fmod)
2446c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
244776ad07a4SPeter Maydell        error_exit "You must specify path to FMOD library and headers" \
244876ad07a4SPeter Maydell            "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
24498f28f3fbSths    fi
2450c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
2451a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
2452c2de5c91Smalc    ;;
2453c2de5c91Smalc
2454c2de5c91Smalc    esd)
2455c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
2456a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
245767f86e8eSJuan Quintela    audio_pt_int="yes"
2458c2de5c91Smalc    ;;
2459b8e59f18Smalc
2460b8e59f18Smalc    pa)
2461a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
2462a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
2463a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
246467f86e8eSJuan Quintela    audio_pt_int="yes"
2465b8e59f18Smalc    ;;
2466b8e59f18Smalc
2467997e690aSJuan Quintela    coreaudio)
2468997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
2469997e690aSJuan Quintela    ;;
2470997e690aSJuan Quintela
2471a4bf6780SJuan Quintela    dsound)
2472a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2473d5631638Smalc      audio_win_int="yes"
2474a4bf6780SJuan Quintela    ;;
2475a4bf6780SJuan Quintela
2476a4bf6780SJuan Quintela    oss)
2477a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
2478a4bf6780SJuan Quintela    ;;
2479a4bf6780SJuan Quintela
2480a4bf6780SJuan Quintela    sdl|wav)
24812f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
24822f6a1ab0Sblueswir1    ;;
24832f6a1ab0Sblueswir1
2484d5631638Smalc    winwave)
2485d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
2486d5631638Smalc      audio_win_int="yes"
2487d5631638Smalc    ;;
2488d5631638Smalc
2489e4c63a6aSmalc    *)
24901c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
249176ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
249276ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
2493e4c63a6aSmalc    }
2494e4c63a6aSmalc    ;;
2495c2de5c91Smalc    esac
2496c2de5c91Smalcdone
24978f28f3fbSths
24984d3b6f6eSbalrog##########################################
24992e4d9fb1Saurel32# BrlAPI probe
25002e4d9fb1Saurel32
25014ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2502eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
25032e4d9fb1Saurel32  cat > $TMPC << EOF
25042e4d9fb1Saurel32#include <brlapi.h>
2505832ce9c2SScott Wood#include <stddef.h>
25062e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
25072e4d9fb1Saurel32EOF
250852166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
25092e4d9fb1Saurel32    brlapi=yes
2510264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
25114ffcedb6SJuan Quintela  else
25124ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
251321684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
25144ffcedb6SJuan Quintela    fi
25154ffcedb6SJuan Quintela    brlapi=no
2516eb82284fSJuan Quintela  fi
2517eb82284fSJuan Quintelafi
25182e4d9fb1Saurel32
25192e4d9fb1Saurel32##########################################
25204d3b6f6eSbalrog# curses probe
2521a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
2522e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
2523e095e2f3SStefan Weil    curses_list="-lpdcurses"
2524e095e2f3SStefan Weil  else
2525cfeda5f4SEd Maste    curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
2526e095e2f3SStefan Weil  fi
2527c584a6d0SJuan Quintela  curses_found=no
25284d3b6f6eSbalrog  cat > $TMPC << EOF
25294d3b6f6eSbalrog#include <curses.h>
2530ef9a2524SStefan Weilint main(void) {
2531ef9a2524SStefan Weil  const char *s = curses_version();
2532ef9a2524SStefan Weil  resize_term(0, 0);
2533ef9a2524SStefan Weil  return s != 0;
2534ef9a2524SStefan Weil}
25354d3b6f6eSbalrogEOF
2536ecbe251fSVadim Evard  IFS=:
25374f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
2538ecbe251fSVadim Evard    unset IFS
25394f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2540c584a6d0SJuan Quintela      curses_found=yes
25414f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
25424f78ef9aSJuan Quintela      break
25434d3b6f6eSbalrog    fi
25444f78ef9aSJuan Quintela  done
2545ecbe251fSVadim Evard  unset IFS
2546c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2547c584a6d0SJuan Quintela    curses=yes
2548c584a6d0SJuan Quintela  else
2549c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
255021684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
2551c584a6d0SJuan Quintela    fi
2552c584a6d0SJuan Quintela    curses=no
2553c584a6d0SJuan Quintela  fi
25544f78ef9aSJuan Quintelafi
25554d3b6f6eSbalrog
2556414f0dabSblueswir1##########################################
2557769ce76dSAlexander Graf# curl probe
2558a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
255965d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
2560a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
25614e2b0658SPaolo Bonzini  else
25624e2b0658SPaolo Bonzini    curlconfig=curl-config
25634e2b0658SPaolo Bonzini  fi
2564769ce76dSAlexander Graf  cat > $TMPC << EOF
2565769ce76dSAlexander Graf#include <curl/curl.h>
25660b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2567769ce76dSAlexander GrafEOF
25684e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
25694e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2570b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2571769ce76dSAlexander Graf    curl=yes
2572788c8196SJuan Quintela  else
2573788c8196SJuan Quintela    if test "$curl" = "yes" ; then
257421684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
2575788c8196SJuan Quintela    fi
2576788c8196SJuan Quintela    curl=no
2577769ce76dSAlexander Graf  fi
2578769ce76dSAlexander Graffi # test "$curl"
2579769ce76dSAlexander Graf
2580769ce76dSAlexander Graf##########################################
2581fb599c9aSbalrog# bluez support probe
2582a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2583e820e3f4Sbalrog  cat > $TMPC << EOF
2584e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2585e820e3f4Sbalrogint main(void) { return bt_error(0); }
2586e820e3f4SbalrogEOF
2587a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2588a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
258952166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2590a20a6f46SJuan Quintela    bluez=yes
2591e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2592e820e3f4Sbalrog  else
2593a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
259421684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
2595a20a6f46SJuan Quintela    fi
2596e820e3f4Sbalrog    bluez="no"
2597e820e3f4Sbalrog  fi
2598fb599c9aSbalrogfi
2599fb599c9aSbalrog
2600fb599c9aSbalrog##########################################
2601e18df141SAnthony Liguori# glib support probe
2602a52d28afSPaolo Bonzini
2603a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2604a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2605a52d28afSPaolo Bonzini    glib_req_ver=2.20
2606a52d28afSPaolo Bonzinielse
2607a52d28afSPaolo Bonzini    glib_req_ver=2.12
2608a52d28afSPaolo Bonzinifi
2609aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
2610aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
2611aa0d1f44SPaolo Bonzini    glib_modules="$glib_modules gmodule-2.0"
2612aa0d1f44SPaolo Bonzinifi
2613e26110cfSFam Zheng
2614aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
2615e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
2616e26110cfSFam Zheng        glib_cflags=`$pkg_config --cflags $i`
2617e26110cfSFam Zheng        glib_libs=`$pkg_config --libs $i`
2618ba1183daSFam Zheng        CFLAGS="$glib_cflags $CFLAGS"
261914015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
2620957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
2621e18df141SAnthony Liguori    else
2622e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2623e26110cfSFam Zheng    fi
2624e26110cfSFam Zhengdone
2625e26110cfSFam Zheng
2626e26110cfSFam Zheng##########################################
2627e26110cfSFam Zheng# SHA command probe for modules
2628e26110cfSFam Zhengif test "$modules" = yes; then
2629e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
2630e26110cfSFam Zheng    for c in $shacmd_probe; do
2631e26110cfSFam Zheng        if which $c &>/dev/null; then
2632e26110cfSFam Zheng            shacmd="$c"
2633e26110cfSFam Zheng            break
2634e26110cfSFam Zheng        fi
2635e26110cfSFam Zheng    done
2636e26110cfSFam Zheng    if test "$shacmd" = ""; then
2637e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2638e26110cfSFam Zheng    fi
2639e18df141SAnthony Liguorifi
2640e18df141SAnthony Liguori
2641e18df141SAnthony Liguori##########################################
2642e2134eb9SGerd Hoffmann# pixman support probe
2643e2134eb9SGerd Hoffmann
2644e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
264574880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
264674880fe2SRobert Schiele    pixman="none"
264774880fe2SRobert Schiele  elif $pkg_config pixman-1 > /dev/null 2>&1; then
2648e2134eb9SGerd Hoffmann    pixman="system"
2649e2134eb9SGerd Hoffmann  else
2650e2134eb9SGerd Hoffmann    pixman="internal"
2651e2134eb9SGerd Hoffmann  fi
2652e2134eb9SGerd Hoffmannfi
265374880fe2SRobert Schieleif test "$pixman" = "none"; then
265474880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
265576ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
265676ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
265776ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
265876ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
265974880fe2SRobert Schiele  fi
266074880fe2SRobert Schiele  pixman_cflags=
266174880fe2SRobert Schiele  pixman_libs=
266274880fe2SRobert Schieleelif test "$pixman" = "system"; then
2663ca871ec8SStefan Weil  pixman_cflags=`$pkg_config --cflags pixman-1`
2664ca871ec8SStefan Weil  pixman_libs=`$pkg_config --libs pixman-1`
2665e2134eb9SGerd Hoffmannelse
2666e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
266776ad07a4SPeter Maydell    error_exit "pixman not present. Your options:" \
266876ad07a4SPeter Maydell        "  (1) Preferred: Install the pixman devel package (any recent" \
266976ad07a4SPeter Maydell        "      distro should have packages as Xorg needs pixman too)." \
267076ad07a4SPeter Maydell        "  (2) Fetch the pixman submodule, using:" \
267176ad07a4SPeter Maydell        "      git submodule update --init pixman"
2672e2134eb9SGerd Hoffmann  fi
26735ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
26745ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
26755ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2676e2134eb9SGerd Hoffmannfi
2677e2134eb9SGerd Hoffmann
2678e2134eb9SGerd Hoffmann##########################################
267917bff52bSM. Mohan Kumar# libcap probe
268017bff52bSM. Mohan Kumar
268117bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
268217bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
268317bff52bSM. Mohan Kumar#include <stdio.h>
268417bff52bSM. Mohan Kumar#include <sys/capability.h>
2685cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
268617bff52bSM. Mohan KumarEOF
268717bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
268817bff52bSM. Mohan Kumar    cap=yes
268917bff52bSM. Mohan Kumar  else
269017bff52bSM. Mohan Kumar    cap=no
269117bff52bSM. Mohan Kumar  fi
269217bff52bSM. Mohan Kumarfi
269317bff52bSM. Mohan Kumar
269417bff52bSM. Mohan Kumar##########################################
2695e5d355d1Saliguori# pthread probe
26964b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
26973c529d93Saliguori
2698e5d355d1Saliguoripthread=no
2699414f0dabSblueswir1cat > $TMPC << EOF
27003c529d93Saliguori#include <pthread.h>
27017a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
27027a42bbe4SStefan Weilint main(void) {
27037a42bbe4SStefan Weil  pthread_t thread;
27047a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
27057a42bbe4SStefan Weil  return 0;
27067a42bbe4SStefan Weil}
2707414f0dabSblueswir1EOF
2708bd00d539SAndreas Färberif compile_prog "" "" ; then
2709bd00d539SAndreas Färber  pthread=yes
2710bd00d539SAndreas Färberelse
2711de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
271252166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2713e5d355d1Saliguori      pthread=yes
2714e3c56761SPeter Portante      found=no
2715e3c56761SPeter Portante      for lib_entry in $LIBS; do
2716e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2717e3c56761SPeter Portante          found=yes
2718e3c56761SPeter Portante          break
2719e3c56761SPeter Portante        fi
2720e3c56761SPeter Portante      done
2721e3c56761SPeter Portante      if test "$found" = "no"; then
27225572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2723e3c56761SPeter Portante      fi
2724de65fe0fSSebastian Herbszt      break
2725414f0dabSblueswir1    fi
2726de65fe0fSSebastian Herbszt  done
2727bd00d539SAndreas Färberfi
2728414f0dabSblueswir1
27294617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
273076ad07a4SPeter Maydell  error_exit "pthread check failed" \
273176ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
2732e5d355d1Saliguorifi
2733e5d355d1Saliguori
27345c312079SDr. David Alan Gilbert# check for pthread_setname_np
27355c312079SDr. David Alan Gilbertpthread_setname_np=no
27365c312079SDr. David Alan Gilbertcat > $TMPC << EOF
27375c312079SDr. David Alan Gilbert#include <pthread.h>
27385c312079SDr. David Alan Gilbert
27395c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
27405c312079SDr. David Alan Gilbertint main(void)
27415c312079SDr. David Alan Gilbert{
27425c312079SDr. David Alan Gilbert    pthread_t thread;
27435c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
27445c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
27455c312079SDr. David Alan Gilbert    return 0;
27465c312079SDr. David Alan Gilbert}
27475c312079SDr. David Alan GilbertEOF
27485c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
27495c312079SDr. David Alan Gilbert  pthread_setname_np=yes
27505c312079SDr. David Alan Gilbertfi
27515c312079SDr. David Alan Gilbert
2752bf9298b9Saliguori##########################################
2753f27aaf4bSChristian Brunner# rbd probe
2754f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2755f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2756f27aaf4bSChristian Brunner#include <stdio.h>
2757ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2758f27aaf4bSChristian Brunnerint main(void) {
2759ad32e9c0SJosh Durgin    rados_t cluster;
2760ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2761f27aaf4bSChristian Brunner    return 0;
2762f27aaf4bSChristian Brunner}
2763f27aaf4bSChristian BrunnerEOF
2764ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2765f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2766f27aaf4bSChristian Brunner    rbd=yes
2767f27aaf4bSChristian Brunner  else
2768f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
276921684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
2770f27aaf4bSChristian Brunner    fi
2771f27aaf4bSChristian Brunner    rbd=no
2772f27aaf4bSChristian Brunner  fi
2773f27aaf4bSChristian Brunnerfi
2774f27aaf4bSChristian Brunner
2775f27aaf4bSChristian Brunner##########################################
27760a12ec87SRichard W.M. Jones# libssh2 probe
27774fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
27780a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
277965d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
27800a12ec87SRichard W.M. Jones    libssh2_cflags=`$pkg_config libssh2 --cflags`
27810a12ec87SRichard W.M. Jones    libssh2_libs=`$pkg_config libssh2 --libs`
27820a12ec87SRichard W.M. Jones    libssh2=yes
27830a12ec87SRichard W.M. Jones  else
27840a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
27854fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
27860a12ec87SRichard W.M. Jones    fi
27870a12ec87SRichard W.M. Jones    libssh2=no
27880a12ec87SRichard W.M. Jones  fi
27890a12ec87SRichard W.M. Jonesfi
27900a12ec87SRichard W.M. Jones
27910a12ec87SRichard W.M. Jones##########################################
27929a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
27939a2d462eSRichard W.M. Jones
27949a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
27959a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
27969a2d462eSRichard W.M. Jones#include <stdio.h>
27979a2d462eSRichard W.M. Jones#include <libssh2.h>
27989a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
27999a2d462eSRichard W.M. Jonesint main(void) {
28009a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
28019a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
28029a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
28039a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
28049a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
28059a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
28069a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
28079a2d462eSRichard W.M. Jones    return 0;
28089a2d462eSRichard W.M. Jones}
28099a2d462eSRichard W.M. JonesEOF
28109a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
28119a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
28129a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
28139a2d462eSRichard W.M. Jones  fi
28149a2d462eSRichard W.M. Jonesfi
28159a2d462eSRichard W.M. Jones
28169a2d462eSRichard W.M. Jones##########################################
28175c6c3a6cSChristoph Hellwig# linux-aio probe
28185c6c3a6cSChristoph Hellwig
28195c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
28205c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
28215c6c3a6cSChristoph Hellwig#include <libaio.h>
28225c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2823832ce9c2SScott Wood#include <stddef.h>
28245c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
28255c6c3a6cSChristoph HellwigEOF
28265c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
28275c6c3a6cSChristoph Hellwig    linux_aio=yes
28285c6c3a6cSChristoph Hellwig  else
28295c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
283021684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
28315c6c3a6cSChristoph Hellwig    fi
28323cfcae3cSLuiz Capitulino    linux_aio=no
28335c6c3a6cSChristoph Hellwig  fi
28345c6c3a6cSChristoph Hellwigfi
28355c6c3a6cSChristoph Hellwig
28365c6c3a6cSChristoph Hellwig##########################################
28373b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
28383b8acc11SPaolo Bonzini
28393b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
28403b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
28413b8acc11SPaolo Bonzinielse
28423b8acc11SPaolo Bonzini  tpm_passthrough=no
28433b8acc11SPaolo Bonzinifi
28443b8acc11SPaolo Bonzini
28453b8acc11SPaolo Bonzini##########################################
2846583f6e7bSStefan Hajnoczi# adjust virtio-blk-data-plane based on linux-aio
2847583f6e7bSStefan Hajnoczi
2848583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" -a \
2849583f6e7bSStefan Hajnoczi	"$linux_aio" != "yes" ; then
285076ad07a4SPeter Maydell  error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
2851583f6e7bSStefan Hajnoczielif test -z "$virtio_blk_data_plane" ; then
2852583f6e7bSStefan Hajnoczi  virtio_blk_data_plane=$linux_aio
2853583f6e7bSStefan Hajnoczifi
2854583f6e7bSStefan Hajnoczi
2855583f6e7bSStefan Hajnoczi##########################################
2856758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2857758e8e38SVenkateswararao Jujjuri (JV)
2858758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2859758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2860758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2861758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2862f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2863f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2864f2338fb4SPavel Borzenkov#else
28654f26f2b6SAvi Kivity#include <sys/xattr.h>
2866f2338fb4SPavel Borzenkov#endif
2867758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2868758e8e38SVenkateswararao Jujjuri (JV)EOF
28694f26f2b6SAvi Kivity  if compile_prog "" "" ; then
28704f26f2b6SAvi Kivity    attr=yes
28714f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2872f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2873758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2874758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
28754f26f2b6SAvi Kivity    libattr=yes
2876758e8e38SVenkateswararao Jujjuri (JV)  else
2877758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
287821684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
2879758e8e38SVenkateswararao Jujjuri (JV)    fi
2880758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2881758e8e38SVenkateswararao Jujjuri (JV)  fi
2882758e8e38SVenkateswararao Jujjuri (JV)fi
2883758e8e38SVenkateswararao Jujjuri (JV)
2884758e8e38SVenkateswararao Jujjuri (JV)##########################################
2885bf9298b9Saliguori# iovec probe
2886bf9298b9Saliguoricat > $TMPC <<EOF
2887db34f0b3Sblueswir1#include <sys/types.h>
2888bf9298b9Saliguori#include <sys/uio.h>
2889db34f0b3Sblueswir1#include <unistd.h>
2890f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2891bf9298b9SaliguoriEOF
2892bf9298b9Saliguoriiovec=no
289352166aa0SJuan Quintelaif compile_prog "" "" ; then
2894bf9298b9Saliguori  iovec=yes
2895bf9298b9Saliguorifi
2896bf9298b9Saliguori
2897f652e6afSaurel32##########################################
2898ceb42de8Saliguori# preadv probe
2899ceb42de8Saliguoricat > $TMPC <<EOF
2900ceb42de8Saliguori#include <sys/types.h>
2901ceb42de8Saliguori#include <sys/uio.h>
2902ceb42de8Saliguori#include <unistd.h>
2903c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2904ceb42de8SaliguoriEOF
2905ceb42de8Saliguoripreadv=no
290652166aa0SJuan Quintelaif compile_prog "" "" ; then
2907ceb42de8Saliguori  preadv=yes
2908ceb42de8Saliguorifi
2909ceb42de8Saliguori
2910ceb42de8Saliguori##########################################
2911f652e6afSaurel32# fdt probe
2912e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
2913e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
2914e169e1e1SPeter Maydellfdt_required=no
2915e169e1e1SPeter Maydellfor target in $target_list; do
2916e169e1e1SPeter Maydell  case $target in
29176a49fa95SAlexander Graf    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
2918e169e1e1SPeter Maydell      fdt_required=yes
2919e169e1e1SPeter Maydell    ;;
2920e169e1e1SPeter Maydell  esac
2921e169e1e1SPeter Maydelldone
2922e169e1e1SPeter Maydell
2923e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
2924e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
2925e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
2926e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
2927e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
2928e169e1e1SPeter Maydell  fi
2929e169e1e1SPeter Maydell  fdt=yes
2930e169e1e1SPeter Maydellfi
2931e169e1e1SPeter Maydell
29322df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2933b41af4baSJuan Quintela  fdt_libs="-lfdt"
293496ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
2935f652e6afSaurel32  cat > $TMPC << EOF
293696ce6545SPeter Crosthwaite#include <libfdt_env.h>
2937f652e6afSaurel32int main(void) { return 0; }
2938f652e6afSaurel32EOF
293952166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2940a540f158SPeter Crosthwaite    # system DTC is good - use it
2941f652e6afSaurel32    fdt=yes
2942a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
2943a540f158SPeter Crosthwaite    # have submodule DTC - use it
2944a540f158SPeter Crosthwaite    fdt=yes
2945a540f158SPeter Crosthwaite    dtc_internal="yes"
2946a540f158SPeter Crosthwaite    mkdir -p dtc
2947a540f158SPeter Crosthwaite    if [ "$source_path" != `pwd` ] ; then
2948a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
2949a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
29502df87df7SJuan Quintela    fi
2951a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
2952a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
2953a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
2954a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
29553f281822SStewart Smith    error_exit "DTC (libfdt) not present. Your options:" \
29563f281822SStewart Smith        "  (1) Preferred: Install the DTC (libfdt) devel package" \
2957a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
2958a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
2959a540f158SPeter Crosthwaite  else
2960a540f158SPeter Crosthwaite    # don't have and don't want
2961de3a354aSMichael Walle    fdt_libs=
29622df87df7SJuan Quintela    fdt=no
2963f652e6afSaurel32  fi
2964f652e6afSaurel32fi
2965f652e6afSaurel32
2966a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
2967a540f158SPeter Crosthwaite
296820ff075bSMichael Walle##########################################
2969b1e5fff4SMichael Walle# GLX probe, used by milkymist-tmu2
2970b1e5fff4SMichael Walleif test "$glx" != "no" ; then
2971b1e5fff4SMichael Walle  glx_libs="-lGL -lX11"
297220ff075bSMichael Walle  cat > $TMPC << EOF
297320ff075bSMichael Walle#include <X11/Xlib.h>
297420ff075bSMichael Walle#include <GL/gl.h>
297520ff075bSMichael Walle#include <GL/glx.h>
2976d3fcbb16SMichael Walleint main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
297720ff075bSMichael WalleEOF
2978d3fcbb16SMichael Walle  if compile_prog "" "-lGL -lX11" ; then
2979b1e5fff4SMichael Walle    glx=yes
298020ff075bSMichael Walle  else
2981b1e5fff4SMichael Walle    if test "$glx" = "yes" ; then
298221684af0SStewart Smith      feature_not_found "glx" "Install GL devel (e.g. MESA)"
298320ff075bSMichael Walle    fi
2984b1e5fff4SMichael Walle    glx_libs=
2985b1e5fff4SMichael Walle    glx=no
298620ff075bSMichael Walle  fi
298720ff075bSMichael Wallefi
298820ff075bSMichael Walle
2989eb100396SBharata B Rao##########################################
2990eb100396SBharata B Rao# glusterfs probe
2991eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
299265d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
2993e01bee08SBharata B Rao    glusterfs="yes"
2994ca871ec8SStefan Weil    glusterfs_cflags=`$pkg_config --cflags glusterfs-api`
2995ca871ec8SStefan Weil    glusterfs_libs=`$pkg_config --libs glusterfs-api`
299665d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
29970c14fb47SBharata B Rao      glusterfs_discard="yes"
29980c14fb47SBharata B Rao    fi
29997c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
30007c815372SBharata B Rao      glusterfs_zerofill="yes"
30017c815372SBharata B Rao    fi
3002eb100396SBharata B Rao  else
3003eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
300421684af0SStewart Smith      feature_not_found "GlusterFS backend support" "Install glusterfs-api devel"
3005eb100396SBharata B Rao    fi
3006e01bee08SBharata B Rao    glusterfs="no"
3007eb100396SBharata B Rao  fi
3008eb100396SBharata B Raofi
3009eb100396SBharata B Rao
301039386ac7Saurel32# Check for inotify functions when we are building linux-user
30113b3f24adSaurel32# emulator.  This is done because older glibc versions don't
30123b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
30133b3f24adSaurel32# don't provide them even if kernel supports them.
30143b3f24adSaurel32#
30153b3f24adSaurel32inotify=no
30163b3f24adSaurel32cat > $TMPC << EOF
30173b3f24adSaurel32#include <sys/inotify.h>
30183b3f24adSaurel32
30193b3f24adSaurel32int
30203b3f24adSaurel32main(void)
30213b3f24adSaurel32{
30223b3f24adSaurel32	/* try to start inotify */
30238690e420Saurel32	return inotify_init();
30243b3f24adSaurel32}
30253b3f24adSaurel32EOF
302652166aa0SJuan Quintelaif compile_prog "" "" ; then
30273b3f24adSaurel32  inotify=yes
30283b3f24adSaurel32fi
30293b3f24adSaurel32
3030c05c7a73SRiku Voipioinotify1=no
3031c05c7a73SRiku Voipiocat > $TMPC << EOF
3032c05c7a73SRiku Voipio#include <sys/inotify.h>
3033c05c7a73SRiku Voipio
3034c05c7a73SRiku Voipioint
3035c05c7a73SRiku Voipiomain(void)
3036c05c7a73SRiku Voipio{
3037c05c7a73SRiku Voipio    /* try to start inotify */
3038c05c7a73SRiku Voipio    return inotify_init1(0);
3039c05c7a73SRiku Voipio}
3040c05c7a73SRiku VoipioEOF
3041c05c7a73SRiku Voipioif compile_prog "" "" ; then
3042c05c7a73SRiku Voipio  inotify1=yes
3043c05c7a73SRiku Voipiofi
3044c05c7a73SRiku Voipio
3045ebc996f3SRiku Voipio# check if utimensat and futimens are supported
3046ebc996f3SRiku Voipioutimens=no
3047ebc996f3SRiku Voipiocat > $TMPC << EOF
3048ebc996f3SRiku Voipio#define _ATFILE_SOURCE
3049ebc996f3SRiku Voipio#include <stddef.h>
3050ebc996f3SRiku Voipio#include <fcntl.h>
30513014ee00SPeter Maydell#include <sys/stat.h>
3052ebc996f3SRiku Voipio
3053ebc996f3SRiku Voipioint main(void)
3054ebc996f3SRiku Voipio{
3055ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
3056ebc996f3SRiku Voipio    futimens(0, NULL);
3057ebc996f3SRiku Voipio    return 0;
3058ebc996f3SRiku Voipio}
3059ebc996f3SRiku VoipioEOF
306052166aa0SJuan Quintelaif compile_prog "" "" ; then
3061ebc996f3SRiku Voipio  utimens=yes
3062ebc996f3SRiku Voipiofi
3063ebc996f3SRiku Voipio
3064099d6b0fSRiku Voipio# check if pipe2 is there
3065099d6b0fSRiku Voipiopipe2=no
3066099d6b0fSRiku Voipiocat > $TMPC << EOF
3067099d6b0fSRiku Voipio#include <unistd.h>
3068099d6b0fSRiku Voipio#include <fcntl.h>
3069099d6b0fSRiku Voipio
3070099d6b0fSRiku Voipioint main(void)
3071099d6b0fSRiku Voipio{
3072099d6b0fSRiku Voipio    int pipefd[2];
30739bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3074099d6b0fSRiku Voipio}
3075099d6b0fSRiku VoipioEOF
307652166aa0SJuan Quintelaif compile_prog "" "" ; then
3077099d6b0fSRiku Voipio  pipe2=yes
3078099d6b0fSRiku Voipiofi
3079099d6b0fSRiku Voipio
308040ff6d7eSKevin Wolf# check if accept4 is there
308140ff6d7eSKevin Wolfaccept4=no
308240ff6d7eSKevin Wolfcat > $TMPC << EOF
308340ff6d7eSKevin Wolf#include <sys/socket.h>
308440ff6d7eSKevin Wolf#include <stddef.h>
308540ff6d7eSKevin Wolf
308640ff6d7eSKevin Wolfint main(void)
308740ff6d7eSKevin Wolf{
308840ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
308940ff6d7eSKevin Wolf    return 0;
309040ff6d7eSKevin Wolf}
309140ff6d7eSKevin WolfEOF
309240ff6d7eSKevin Wolfif compile_prog "" "" ; then
309340ff6d7eSKevin Wolf  accept4=yes
309440ff6d7eSKevin Wolffi
309540ff6d7eSKevin Wolf
30963ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
30973ce34dfbSvibisreenivasansplice=no
30983ce34dfbSvibisreenivasancat > $TMPC << EOF
30993ce34dfbSvibisreenivasan#include <unistd.h>
31003ce34dfbSvibisreenivasan#include <fcntl.h>
31013ce34dfbSvibisreenivasan#include <limits.h>
31023ce34dfbSvibisreenivasan
31033ce34dfbSvibisreenivasanint main(void)
31043ce34dfbSvibisreenivasan{
310566ea0f22SStefan Weil    int len, fd = 0;
31063ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
31073ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
31083ce34dfbSvibisreenivasan    return 0;
31093ce34dfbSvibisreenivasan}
31103ce34dfbSvibisreenivasanEOF
311152166aa0SJuan Quintelaif compile_prog "" "" ; then
31123ce34dfbSvibisreenivasan  splice=yes
31133ce34dfbSvibisreenivasanfi
31143ce34dfbSvibisreenivasan
3115dcc38d1cSMarcelo Tosatti##########################################
3116dcc38d1cSMarcelo Tosatti# signalfd probe
3117dcc38d1cSMarcelo Tosattisignalfd="no"
3118dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3119dcc38d1cSMarcelo Tosatti#include <unistd.h>
3120dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3121dcc38d1cSMarcelo Tosatti#include <signal.h>
3122dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3123dcc38d1cSMarcelo TosattiEOF
3124dcc38d1cSMarcelo Tosatti
3125dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3126dcc38d1cSMarcelo Tosatti  signalfd=yes
3127dcc38d1cSMarcelo Tosattifi
3128dcc38d1cSMarcelo Tosatti
3129c2882b96SRiku Voipio# check if eventfd is supported
3130c2882b96SRiku Voipioeventfd=no
3131c2882b96SRiku Voipiocat > $TMPC << EOF
3132c2882b96SRiku Voipio#include <sys/eventfd.h>
3133c2882b96SRiku Voipio
3134c2882b96SRiku Voipioint main(void)
3135c2882b96SRiku Voipio{
313655cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3137c2882b96SRiku Voipio}
3138c2882b96SRiku VoipioEOF
3139c2882b96SRiku Voipioif compile_prog "" "" ; then
3140c2882b96SRiku Voipio  eventfd=yes
3141c2882b96SRiku Voipiofi
3142c2882b96SRiku Voipio
3143d0927938SUlrich Hecht# check for fallocate
3144d0927938SUlrich Hechtfallocate=no
3145d0927938SUlrich Hechtcat > $TMPC << EOF
3146d0927938SUlrich Hecht#include <fcntl.h>
3147d0927938SUlrich Hecht
3148d0927938SUlrich Hechtint main(void)
3149d0927938SUlrich Hecht{
3150d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3151d0927938SUlrich Hecht    return 0;
3152d0927938SUlrich Hecht}
3153d0927938SUlrich HechtEOF
31548fb03151SPeter Maydellif compile_prog "" "" ; then
3155d0927938SUlrich Hecht  fallocate=yes
3156d0927938SUlrich Hechtfi
3157d0927938SUlrich Hecht
31583d4fa43eSKusanagi Kouichi# check for fallocate hole punching
31593d4fa43eSKusanagi Kouichifallocate_punch_hole=no
31603d4fa43eSKusanagi Kouichicat > $TMPC << EOF
31613d4fa43eSKusanagi Kouichi#include <fcntl.h>
31623d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
31633d4fa43eSKusanagi Kouichi
31643d4fa43eSKusanagi Kouichiint main(void)
31653d4fa43eSKusanagi Kouichi{
31663d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
31673d4fa43eSKusanagi Kouichi    return 0;
31683d4fa43eSKusanagi Kouichi}
31693d4fa43eSKusanagi KouichiEOF
31703d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
31713d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
31723d4fa43eSKusanagi Kouichifi
31733d4fa43eSKusanagi Kouichi
3174c727f47dSPeter Maydell# check for sync_file_range
3175c727f47dSPeter Maydellsync_file_range=no
3176c727f47dSPeter Maydellcat > $TMPC << EOF
3177c727f47dSPeter Maydell#include <fcntl.h>
3178c727f47dSPeter Maydell
3179c727f47dSPeter Maydellint main(void)
3180c727f47dSPeter Maydell{
3181c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3182c727f47dSPeter Maydell    return 0;
3183c727f47dSPeter Maydell}
3184c727f47dSPeter MaydellEOF
31858fb03151SPeter Maydellif compile_prog "" "" ; then
3186c727f47dSPeter Maydell  sync_file_range=yes
3187c727f47dSPeter Maydellfi
3188c727f47dSPeter Maydell
3189dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3190dace20dcSPeter Maydellfiemap=no
3191dace20dcSPeter Maydellcat > $TMPC << EOF
3192dace20dcSPeter Maydell#include <sys/ioctl.h>
3193dace20dcSPeter Maydell#include <linux/fs.h>
3194dace20dcSPeter Maydell#include <linux/fiemap.h>
3195dace20dcSPeter Maydell
3196dace20dcSPeter Maydellint main(void)
3197dace20dcSPeter Maydell{
3198dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3199dace20dcSPeter Maydell    return 0;
3200dace20dcSPeter Maydell}
3201dace20dcSPeter MaydellEOF
32028fb03151SPeter Maydellif compile_prog "" "" ; then
3203dace20dcSPeter Maydell  fiemap=yes
3204dace20dcSPeter Maydellfi
3205dace20dcSPeter Maydell
3206d0927938SUlrich Hecht# check for dup3
3207d0927938SUlrich Hechtdup3=no
3208d0927938SUlrich Hechtcat > $TMPC << EOF
3209d0927938SUlrich Hecht#include <unistd.h>
3210d0927938SUlrich Hecht
3211d0927938SUlrich Hechtint main(void)
3212d0927938SUlrich Hecht{
3213d0927938SUlrich Hecht    dup3(0, 0, 0);
3214d0927938SUlrich Hecht    return 0;
3215d0927938SUlrich Hecht}
3216d0927938SUlrich HechtEOF
321778f5d726SJan Kiszkaif compile_prog "" "" ; then
3218d0927938SUlrich Hecht  dup3=yes
3219d0927938SUlrich Hechtfi
3220d0927938SUlrich Hecht
32214e0c6529SAlex Bligh# check for ppoll support
32224e0c6529SAlex Blighppoll=no
32234e0c6529SAlex Blighcat > $TMPC << EOF
32244e0c6529SAlex Bligh#include <poll.h>
32254e0c6529SAlex Bligh
32264e0c6529SAlex Blighint main(void)
32274e0c6529SAlex Bligh{
32284e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
32294e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
32304e0c6529SAlex Bligh    return 0;
32314e0c6529SAlex Bligh}
32324e0c6529SAlex BlighEOF
32334e0c6529SAlex Blighif compile_prog "" "" ; then
32344e0c6529SAlex Bligh  ppoll=yes
32354e0c6529SAlex Blighfi
32364e0c6529SAlex Bligh
3237cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3238cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3239cd758dd0SAlex Blighcat > $TMPC << EOF
3240cd758dd0SAlex Bligh#include <sys/prctl.h>
3241cd758dd0SAlex Bligh
3242cd758dd0SAlex Blighint main(void)
3243cd758dd0SAlex Bligh{
3244cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3245cd758dd0SAlex Bligh    return 0;
3246cd758dd0SAlex Bligh}
3247cd758dd0SAlex BlighEOF
3248cd758dd0SAlex Blighif compile_prog "" "" ; then
3249cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3250cd758dd0SAlex Blighfi
3251cd758dd0SAlex Bligh
32523b6edd16SPeter Maydell# check for epoll support
32533b6edd16SPeter Maydellepoll=no
32543b6edd16SPeter Maydellcat > $TMPC << EOF
32553b6edd16SPeter Maydell#include <sys/epoll.h>
32563b6edd16SPeter Maydell
32573b6edd16SPeter Maydellint main(void)
32583b6edd16SPeter Maydell{
32593b6edd16SPeter Maydell    epoll_create(0);
32603b6edd16SPeter Maydell    return 0;
32613b6edd16SPeter Maydell}
32623b6edd16SPeter MaydellEOF
32638fb03151SPeter Maydellif compile_prog "" "" ; then
32643b6edd16SPeter Maydell  epoll=yes
32653b6edd16SPeter Maydellfi
32663b6edd16SPeter Maydell
32673b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
32683b6edd16SPeter Maydell# so we must check separately for their presence
32693b6edd16SPeter Maydellepoll_create1=no
32703b6edd16SPeter Maydellcat > $TMPC << EOF
32713b6edd16SPeter Maydell#include <sys/epoll.h>
32723b6edd16SPeter Maydell
32733b6edd16SPeter Maydellint main(void)
32743b6edd16SPeter Maydell{
327519e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
327619e83f6bSPeter Maydell     * a function being called. This is necessary so that on
327719e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
327819e83f6bSPeter Maydell     * the library but not declared in the header file we will
327919e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
328019e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
328119e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
328219e83f6bSPeter Maydell     */
3283c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
32843b6edd16SPeter Maydell}
32853b6edd16SPeter MaydellEOF
32868fb03151SPeter Maydellif compile_prog "" "" ; then
32873b6edd16SPeter Maydell  epoll_create1=yes
32883b6edd16SPeter Maydellfi
32893b6edd16SPeter Maydell
32903b6edd16SPeter Maydellepoll_pwait=no
32913b6edd16SPeter Maydellcat > $TMPC << EOF
32923b6edd16SPeter Maydell#include <sys/epoll.h>
32933b6edd16SPeter Maydell
32943b6edd16SPeter Maydellint main(void)
32953b6edd16SPeter Maydell{
32963b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
32973b6edd16SPeter Maydell    return 0;
32983b6edd16SPeter Maydell}
32993b6edd16SPeter MaydellEOF
33008fb03151SPeter Maydellif compile_prog "" "" ; then
33013b6edd16SPeter Maydell  epoll_pwait=yes
33023b6edd16SPeter Maydellfi
33033b6edd16SPeter Maydell
3304a8fd1abaSPeter Maydell# check for sendfile support
3305a8fd1abaSPeter Maydellsendfile=no
3306a8fd1abaSPeter Maydellcat > $TMPC << EOF
3307a8fd1abaSPeter Maydell#include <sys/sendfile.h>
3308a8fd1abaSPeter Maydell
3309a8fd1abaSPeter Maydellint main(void)
3310a8fd1abaSPeter Maydell{
3311a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
3312a8fd1abaSPeter Maydell}
3313a8fd1abaSPeter MaydellEOF
3314a8fd1abaSPeter Maydellif compile_prog "" "" ; then
3315a8fd1abaSPeter Maydell  sendfile=yes
3316a8fd1abaSPeter Maydellfi
3317a8fd1abaSPeter Maydell
3318cc8ae6deSpbrook# Check if tools are available to build documentation.
3319a25dba17SJuan Quintelaif test "$docs" != "no" ; then
332001668d98SStefan Weil  if has makeinfo && has pod2man; then
3321a25dba17SJuan Quintela    docs=yes
332283a3ab8bSJuan Quintela  else
3323a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
332421684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
332583a3ab8bSJuan Quintela    fi
3326a25dba17SJuan Quintela    docs=no
332783a3ab8bSJuan Quintela  fi
3328cc8ae6deSpbrookfi
3329cc8ae6deSpbrook
3330f514f41cSStefan Weil# Search for bswap_32 function
33316ae9a1f4SJuan Quintelabyteswap_h=no
33326ae9a1f4SJuan Quintelacat > $TMPC << EOF
33336ae9a1f4SJuan Quintela#include <byteswap.h>
33346ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
33356ae9a1f4SJuan QuintelaEOF
333652166aa0SJuan Quintelaif compile_prog "" "" ; then
33376ae9a1f4SJuan Quintela  byteswap_h=yes
33386ae9a1f4SJuan Quintelafi
33396ae9a1f4SJuan Quintela
334075f13596SStefan Weil# Search for bswap32 function
33416ae9a1f4SJuan Quintelabswap_h=no
33426ae9a1f4SJuan Quintelacat > $TMPC << EOF
33436ae9a1f4SJuan Quintela#include <sys/endian.h>
33446ae9a1f4SJuan Quintela#include <sys/types.h>
33456ae9a1f4SJuan Quintela#include <machine/bswap.h>
33466ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
33476ae9a1f4SJuan QuintelaEOF
334852166aa0SJuan Quintelaif compile_prog "" "" ; then
33496ae9a1f4SJuan Quintela  bswap_h=yes
33506ae9a1f4SJuan Quintelafi
33516ae9a1f4SJuan Quintela
3352da93a1fdSaliguori##########################################
3353c589b249SRonnie Sahlberg# Do we have libiscsi
3354063c3378SPeter Lieven# We check for iscsi_write16_sync() to make sure we have a
3355063c3378SPeter Lieven# at least version 1.4.0 of libiscsi.
3356c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
3357c589b249SRonnie Sahlberg  cat > $TMPC << EOF
3358fa6acb0cSRonnie Sahlberg#include <stdio.h>
3359c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
3360063c3378SPeter Lievenint main(void) { iscsi_write16_sync(NULL,0,0,NULL,0,0,0,0,0,0,0); return 0; }
3361c589b249SRonnie SahlbergEOF
336265d5d3f9SStefan Weil  if $pkg_config --atleast-version=1.7.0 libiscsi; then
33633c33ea96SPaolo Bonzini    libiscsi="yes"
3364ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
3365ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
33663c33ea96SPaolo Bonzini  elif compile_prog "" "-liscsi" ; then
3367c589b249SRonnie Sahlberg    libiscsi="yes"
33686ebc91e5SFam Zheng    libiscsi_libs="-liscsi"
3369c589b249SRonnie Sahlberg  else
3370c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
337121684af0SStewart Smith      feature_not_found "libiscsi" "Install libiscsi devel"
3372c589b249SRonnie Sahlberg    fi
3373c589b249SRonnie Sahlberg    libiscsi="no"
3374c589b249SRonnie Sahlberg  fi
3375c589b249SRonnie Sahlbergfi
3376c589b249SRonnie Sahlberg
3377219c2521SStefan Weil# We also need to know the API version because there was an
3378219c2521SStefan Weil# API change from 1.4.0 to 1.5.0.
3379219c2521SStefan Weilif test "$libiscsi" = "yes"; then
3380219c2521SStefan Weil  cat >$TMPC <<EOF
3381219c2521SStefan Weil#include <iscsi/iscsi.h>
3382219c2521SStefan Weilint main(void)
3383219c2521SStefan Weil{
3384219c2521SStefan Weil  iscsi_read10_task(0, 0, 0, 0, 0, 0, 0);
3385219c2521SStefan Weil  return 0;
3386219c2521SStefan Weil}
3387219c2521SStefan WeilEOF
3388219c2521SStefan Weil  if compile_prog "" "-liscsi"; then
3389219c2521SStefan Weil    libiscsi_version="1.4.0"
3390219c2521SStefan Weil  fi
3391219c2521SStefan Weilfi
3392c589b249SRonnie Sahlberg
3393c589b249SRonnie Sahlberg##########################################
33948bacde8dSNatanael Copa# Do we need libm
33958bacde8dSNatanael Copacat > $TMPC << EOF
33968bacde8dSNatanael Copa#include <math.h>
33978bacde8dSNatanael Copaint main(void) { return isnan(sin(0.0)); }
33988bacde8dSNatanael CopaEOF
33998bacde8dSNatanael Copaif compile_prog "" "" ; then
34008bacde8dSNatanael Copa  :
34018bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
34028bacde8dSNatanael Copa  LIBS="-lm $LIBS"
34038bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
34048bacde8dSNatanael Copaelse
340576ad07a4SPeter Maydell  error_exit "libm check failed"
34068bacde8dSNatanael Copafi
34078bacde8dSNatanael Copa
34088bacde8dSNatanael Copa##########################################
3409da93a1fdSaliguori# Do we need librt
34108bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
34118bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
34128bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
34138bacde8dSNatanael Copa# function in addition.
3414da93a1fdSaliguoricat > $TMPC <<EOF
3415da93a1fdSaliguori#include <signal.h>
3416da93a1fdSaliguori#include <time.h>
34178bacde8dSNatanael Copaint main(void) {
34188bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
34198bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
34208bacde8dSNatanael Copa}
3421da93a1fdSaliguoriEOF
3422da93a1fdSaliguori
342352166aa0SJuan Quintelaif compile_prog "" "" ; then
342407ffa4bdSJuan Quintela  :
34258bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
34268bacde8dSNatanael Copaelif compile_prog "" "-lrt $pthread_lib" ; then
342707ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
34288bacde8dSNatanael Copa  libs_qga="-lrt $libs_qga"
3429da93a1fdSaliguorifi
3430da93a1fdSaliguori
343131ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
3432179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
34336362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
34346362a53fSJuan Quintelafi
34356362a53fSJuan Quintela
3436de5071c5SBlue Swirl##########################################
3437cd4ec0b4SGerd Hoffmann# spice probe
3438cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3439cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3440cd4ec0b4SGerd Hoffmann#include <spice.h>
3441cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3442cd4ec0b4SGerd HoffmannEOF
3443710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3444710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
344565d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
344665d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
3447cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3448cd4ec0b4SGerd Hoffmann    spice="yes"
3449cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
3450cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
34512e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
34522e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
3453cd4ec0b4SGerd Hoffmann  else
3454cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
345521684af0SStewart Smith      feature_not_found "spice" "Install spice-server and spice-protocol devel"
3456cd4ec0b4SGerd Hoffmann    fi
3457cd4ec0b4SGerd Hoffmann    spice="no"
3458cd4ec0b4SGerd Hoffmann  fi
3459cd4ec0b4SGerd Hoffmannfi
3460cd4ec0b4SGerd Hoffmann
3461111a38b0SRobert Relyea# check for libcacard for smartcard support
3462111a38b0SRobert Relyeasmartcard_cflags=""
3463111a38b0SRobert Relyea# TODO - what's the minimal nss version we support?
3464111a38b0SRobert Relyeaif test "$smartcard_nss" != "no"; then
34655f01e06fSSergei Trofimovich  cat > $TMPC << EOF
34665f01e06fSSergei Trofimovich#include <pk11pub.h>
34675f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
34685f01e06fSSergei TrofimovichEOF
34690b22ef0fSPeter Maydell    smartcard_includes="-I\$(SRC_PATH)/libcacard"
34708c741c22SAlon Levy    libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
34718c741c22SAlon Levy    libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
34726ca026cbSPeter Maydell    test_cflags="$libcacard_cflags"
34736ca026cbSPeter Maydell    # The header files in nss < 3.13.3 have a bug which causes them to
34746ca026cbSPeter Maydell    # emit a warning. If we're going to compile QEMU with -Werror, then
34756ca026cbSPeter Maydell    # test that the headers don't have this bug. Otherwise we would pass
34766ca026cbSPeter Maydell    # the configure test but fail to compile QEMU later.
34776ca026cbSPeter Maydell    if test "$werror" = "yes"; then
34786ca026cbSPeter Maydell        test_cflags="-Werror $test_cflags"
34796ca026cbSPeter Maydell    fi
3480b6fc675bSPaolo Bonzini    if test -n "$libtool" &&
348165d5d3f9SStefan Weil       $pkg_config --atleast-version=3.12.8 nss && \
34826ca026cbSPeter Maydell      compile_prog "$test_cflags" "$libcacard_libs"; then
34835f01e06fSSergei Trofimovich        smartcard_nss="yes"
34840b22ef0fSPeter Maydell        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
34850b22ef0fSPeter Maydell        QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
3486ad4cf3f6SPaul Brook        libs_softmmu="$libcacard_libs $libs_softmmu"
3487111a38b0SRobert Relyea    else
3488111a38b0SRobert Relyea        if test "$smartcard_nss" = "yes"; then
3489111a38b0SRobert Relyea            feature_not_found "nss"
3490111a38b0SRobert Relyea        fi
3491111a38b0SRobert Relyea        smartcard_nss="no"
3492111a38b0SRobert Relyea    fi
3493111a38b0SRobert Relyeafi
3494111a38b0SRobert Relyea
34952b2325ffSGerd Hoffmann# check for libusb
34962b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
349765d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
34982b2325ffSGerd Hoffmann        libusb="yes"
3499ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
3500ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
35012b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
35022b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
35032b2325ffSGerd Hoffmann    else
35042b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
350521684af0SStewart Smith            feature_not_found "libusb" "Install libusb devel"
35062b2325ffSGerd Hoffmann        fi
35072b2325ffSGerd Hoffmann        libusb="no"
35082b2325ffSGerd Hoffmann    fi
35092b2325ffSGerd Hoffmannfi
35102b2325ffSGerd Hoffmann
351169354a83SHans de Goede# check for usbredirparser for usb network redirection support
351269354a83SHans de Goedeif test "$usb_redir" != "no" ; then
351365d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
351469354a83SHans de Goede        usb_redir="yes"
3515ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
3516ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
351769354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
351856ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
351969354a83SHans de Goede    else
352069354a83SHans de Goede        if test "$usb_redir" = "yes"; then
352121684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
352269354a83SHans de Goede        fi
352369354a83SHans de Goede        usb_redir="no"
352469354a83SHans de Goede    fi
352569354a83SHans de Goedefi
352669354a83SHans de Goede
3527cd4ec0b4SGerd Hoffmann##########################################
3528d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
3529d9840e25STomoki Sekiyama
3530d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
3531d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
3532d9840e25STomoki Sekiyama    "")   vss_win32_include="-I$source_path" ;;
3533d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3534d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
3535d9840e25STomoki Sekiyama          vss_win32_include="-I$source_path/.sdk/vss"
3536d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3537d9840e25STomoki Sekiyama	  ;;
3538d9840e25STomoki Sekiyama    *)    vss_win32_include="-I$vss_win32_sdk"
3539d9840e25STomoki Sekiyama  esac
3540d9840e25STomoki Sekiyama  cat > $TMPC << EOF
3541d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
3542d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
3543d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
3544d9840e25STomoki SekiyamaEOF
3545d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
3546d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
3547d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
3548d9840e25STomoki Sekiyama    libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
3549d9840e25STomoki Sekiyama  else
3550d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
3551d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
3552d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3553d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3554d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
3555d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
3556d9840e25STomoki Sekiyama      feature_not_found "VSS support"
3557d9840e25STomoki Sekiyama    fi
3558d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
3559d9840e25STomoki Sekiyama  fi
3560d9840e25STomoki Sekiyamafi
3561d9840e25STomoki Sekiyama
3562d9840e25STomoki Sekiyama##########################################
3563d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
3564d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
3565d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
3566d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
3567d9840e25STomoki Sekiyama
3568d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
3569d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
3570d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
3571d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
3572d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
3573d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
3574d9840e25STomoki Sekiyama    else
3575d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
3576d9840e25STomoki Sekiyama    fi
3577d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
3578d9840e25STomoki Sekiyama    win_sdk=""
3579d9840e25STomoki Sekiyama  fi
3580d9840e25STomoki Sekiyamafi
3581d9840e25STomoki Sekiyama
3582d9840e25STomoki Sekiyama##########################################
3583cd4ec0b4SGerd Hoffmann
3584747bbdf7SBlue Swirl##########################################
35855f6b9e8fSBlue Swirl# check if we have fdatasync
35865f6b9e8fSBlue Swirl
35875f6b9e8fSBlue Swirlfdatasync=no
35885f6b9e8fSBlue Swirlcat > $TMPC << EOF
35895f6b9e8fSBlue Swirl#include <unistd.h>
3590d1722a27SAlexandre Raymondint main(void) {
3591d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
3592d1722a27SAlexandre Raymondreturn fdatasync(0);
3593d1722a27SAlexandre Raymond#else
3594e172fe11SStefan Weil#error Not supported
3595d1722a27SAlexandre Raymond#endif
3596d1722a27SAlexandre Raymond}
35975f6b9e8fSBlue SwirlEOF
35985f6b9e8fSBlue Swirlif compile_prog "" "" ; then
35995f6b9e8fSBlue Swirl    fdatasync=yes
36005f6b9e8fSBlue Swirlfi
36015f6b9e8fSBlue Swirl
360294a420b1SStefan Hajnoczi##########################################
3603e78815a5SAndreas Färber# check if we have madvise
3604e78815a5SAndreas Färber
3605e78815a5SAndreas Färbermadvise=no
3606e78815a5SAndreas Färbercat > $TMPC << EOF
3607e78815a5SAndreas Färber#include <sys/types.h>
3608e78815a5SAndreas Färber#include <sys/mman.h>
3609832ce9c2SScott Wood#include <stddef.h>
3610e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
3611e78815a5SAndreas FärberEOF
3612e78815a5SAndreas Färberif compile_prog "" "" ; then
3613e78815a5SAndreas Färber    madvise=yes
3614e78815a5SAndreas Färberfi
3615e78815a5SAndreas Färber
3616e78815a5SAndreas Färber##########################################
3617e78815a5SAndreas Färber# check if we have posix_madvise
3618e78815a5SAndreas Färber
3619e78815a5SAndreas Färberposix_madvise=no
3620e78815a5SAndreas Färbercat > $TMPC << EOF
3621e78815a5SAndreas Färber#include <sys/mman.h>
3622832ce9c2SScott Wood#include <stddef.h>
3623e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
3624e78815a5SAndreas FärberEOF
3625e78815a5SAndreas Färberif compile_prog "" "" ; then
3626e78815a5SAndreas Färber    posix_madvise=yes
3627e78815a5SAndreas Färberfi
3628e78815a5SAndreas Färber
3629e78815a5SAndreas Färber##########################################
36301e9737daSRichard Henderson# check if we have usable SIGEV_THREAD_ID
36311e9737daSRichard Henderson
36321e9737daSRichard Hendersonsigev_thread_id=no
36331e9737daSRichard Hendersoncat > $TMPC << EOF
36341e9737daSRichard Henderson#include <signal.h>
36351e9737daSRichard Hendersonint main(void) {
36361e9737daSRichard Henderson  struct sigevent ev;
36371e9737daSRichard Henderson  ev.sigev_notify = SIGEV_THREAD_ID;
36381e9737daSRichard Henderson  ev._sigev_un._tid = 0;
36391e9737daSRichard Henderson  asm volatile("" : : "g"(&ev));
36401e9737daSRichard Henderson  return 0;
36411e9737daSRichard Henderson}
36421e9737daSRichard HendersonEOF
36431e9737daSRichard Hendersonif compile_prog "" "" ; then
36441e9737daSRichard Henderson    sigev_thread_id=yes
36451e9737daSRichard Hendersonfi
36461e9737daSRichard Henderson
36471e9737daSRichard Henderson##########################################
364894a420b1SStefan Hajnoczi# check if trace backend exists
364994a420b1SStefan Hajnoczi
3650650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
365194a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
365276ad07a4SPeter Maydell  error_exit "invalid trace backend" \
365376ad07a4SPeter Maydell      "Please choose a supported trace backend."
365494a420b1SStefan Hajnoczifi
365594a420b1SStefan Hajnoczi
36567e24e92aSStefan Hajnoczi##########################################
36577e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
36587e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
36597e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
3660bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
36617e24e92aSStefan Hajnocziint main(void) { return 0; }
36627e24e92aSStefan HajnocziEOF
36637e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
3664bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
3665bf15f63cSMohamad Gebai      lttng_ust_libs=`$pkg_config --libs lttng-ust`
36667e24e92aSStefan Hajnoczi    else
3667bf15f63cSMohamad Gebai      lttng_ust_libs="-llttng-ust"
3668bf15f63cSMohamad Gebai    fi
3669bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
3670bf15f63cSMohamad Gebai      urcu_bp_libs=`$pkg_config --libs liburcu-bp`
3671bf15f63cSMohamad Gebai    else
3672bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
3673bf15f63cSMohamad Gebai    fi
3674bf15f63cSMohamad Gebai
3675bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
3676bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
3677bf15f63cSMohamad Gebai  else
3678bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
36797e24e92aSStefan Hajnoczi  fi
36807e24e92aSStefan Hajnoczifi
3681b3d08c02SDaniel P. Berrange
3682b3d08c02SDaniel P. Berrange##########################################
3683b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
3684b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
3685b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
368676ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
3687b3d08c02SDaniel P. Berrange  fi
3688c276b17dSDaniel P. Berrange  trace_backend_stap="no"
3689c276b17dSDaniel P. Berrange  if has 'stap' ; then
3690c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
3691c276b17dSDaniel P. Berrange  fi
3692b3d08c02SDaniel P. Berrangefi
3693b3d08c02SDaniel P. Berrange
36947e24e92aSStefan Hajnoczi##########################################
3695519175a2SAlex Barcelo# check and set a backend for coroutine
3696d0e2fce5SAneesh Kumar K.V
36977c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
36987c2acc70SPeter Maydell# is sigcontext. gthread is not selectable except explicitly, because
36997c2acc70SPeter Maydell# it is not functional enough to run QEMU proper. (It is occasionally
37007c2acc70SPeter Maydell# useful for debugging purposes.)  On Windows the only valid backend
37017c2acc70SPeter Maydell# is the Windows-specific one.
37027c2acc70SPeter Maydell
37037c2acc70SPeter Maydellucontext_works=no
3704d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3705d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3706d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3707cdf84806SPeter Maydell#ifdef __stub_makecontext
3708cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3709cdf84806SPeter Maydell#endif
371075cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3711d0e2fce5SAneesh Kumar K.VEOF
3712d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
37137c2acc70SPeter Maydell    ucontext_works=yes
3714d0e2fce5SAneesh Kumar K.V  fi
3715519175a2SAlex Barcelofi
37167c2acc70SPeter Maydell
37177c2acc70SPeter Maydellif test "$coroutine" = ""; then
37187c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
37197c2acc70SPeter Maydell    coroutine=win32
37207c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
37217c2acc70SPeter Maydell    coroutine=ucontext
3722519175a2SAlex Barcelo  else
37237c2acc70SPeter Maydell    coroutine=sigaltstack
37247c2acc70SPeter Maydell  fi
37257c2acc70SPeter Maydellelse
37267c2acc70SPeter Maydell  case $coroutine in
37277c2acc70SPeter Maydell  windows)
37287c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
37297c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
37307c2acc70SPeter Maydell    fi
37317c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
37327c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
37337c2acc70SPeter Maydell    coroutine=win32
37347c2acc70SPeter Maydell    ;;
37357c2acc70SPeter Maydell  ucontext)
37367c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
37377c2acc70SPeter Maydell      feature_not_found "ucontext"
37387c2acc70SPeter Maydell    fi
37397c2acc70SPeter Maydell    ;;
37407c2acc70SPeter Maydell  gthread|sigaltstack)
37417c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
37427c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
37437c2acc70SPeter Maydell    fi
37447c2acc70SPeter Maydell    ;;
37457c2acc70SPeter Maydell  *)
374676ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
37477c2acc70SPeter Maydell    ;;
37487c2acc70SPeter Maydell  esac
3749d0e2fce5SAneesh Kumar K.Vfi
3750d0e2fce5SAneesh Kumar K.V
375170c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
375270c60c08SStefan Hajnoczi  if test "$coroutine" = "gthread"; then
375370c60c08SStefan Hajnoczi    coroutine_pool=no
375470c60c08SStefan Hajnoczi  else
375570c60c08SStefan Hajnoczi    coroutine_pool=yes
375670c60c08SStefan Hajnoczi  fi
375770c60c08SStefan Hajnoczifi
375870c60c08SStefan Hajnocziif test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
375970c60c08SStefan Hajnoczi  error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
376070c60c08SStefan Hajnoczifi
376170c60c08SStefan Hajnoczi
3762d0e2fce5SAneesh Kumar K.V##########################################
3763d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
3764d2042378SAneesh Kumar K.V
37654e1797f9SStefan Weilopen_by_handle_at=no
3766d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
3767d2042378SAneesh Kumar K.V#include <fcntl.h>
3768acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
3769acc55ba8SStefan Weil# error missing definition
3770acc55ba8SStefan Weil#else
377175cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3772acc55ba8SStefan Weil#endif
3773d2042378SAneesh Kumar K.VEOF
3774d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
3775d2042378SAneesh Kumar K.V    open_by_handle_at=yes
3776d2042378SAneesh Kumar K.Vfi
3777d2042378SAneesh Kumar K.V
3778e06a765eSHarsh Prateek Bora########################################
3779e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
3780e06a765eSHarsh Prateek Bora
3781e06a765eSHarsh Prateek Boralinux_magic_h=no
3782e06a765eSHarsh Prateek Boracat > $TMPC << EOF
3783e06a765eSHarsh Prateek Bora#include <linux/magic.h>
3784e06a765eSHarsh Prateek Boraint main(void) {
378575cafad7SStefan Weil  return 0;
3786e06a765eSHarsh Prateek Bora}
3787e06a765eSHarsh Prateek BoraEOF
3788e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
3789e06a765eSHarsh Prateek Bora    linux_magic_h=yes
3790e06a765eSHarsh Prateek Borafi
3791e06a765eSHarsh Prateek Bora
37928ab1bf12SLuiz Capitulino########################################
3793c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
3794c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
3795c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
3796c95e3080SKevin Wolf# only a warning.
3797c95e3080SKevin Wolf#
3798c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
3799c95e3080SKevin Wolf# the build doesn't fail anyway.
3800c95e3080SKevin Wolf
380106d71fa1SPeter Maydellpragma_disable_unused_but_set=no
380206d71fa1SPeter Maydellcat > $TMPC << EOF
3803e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
380406d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3805c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
3806e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
3807c95e3080SKevin Wolf
380806d71fa1SPeter Maydellint main(void) {
380906d71fa1SPeter Maydell    return 0;
381006d71fa1SPeter Maydell}
381106d71fa1SPeter MaydellEOF
381206d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
3813cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
3814c95e3080SKevin Wolfelse
3815c95e3080SKevin Wolf    werror=no
381606d71fa1SPeter Maydellfi
381706d71fa1SPeter Maydell
381806d71fa1SPeter Maydell########################################
381962fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
38203f4349dcSKevin Wolf
38213f4349dcSKevin Wolfvalgrind_h=no
38223f4349dcSKevin Wolfcat > $TMPC << EOF
38233f4349dcSKevin Wolf#include <valgrind/valgrind.h>
382462fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
38253f4349dcSKevin Wolfint main(void) {
38263f4349dcSKevin Wolf  return 0;
38273f4349dcSKevin Wolf}
38283f4349dcSKevin WolfEOF
38293f4349dcSKevin Wolfif compile_prog "" "" ; then
38303f4349dcSKevin Wolf    valgrind_h=yes
38313f4349dcSKevin Wolffi
38323f4349dcSKevin Wolf
38333f4349dcSKevin Wolf########################################
38348ab1bf12SLuiz Capitulino# check if environ is declared
38358ab1bf12SLuiz Capitulino
38368ab1bf12SLuiz Capitulinohas_environ=no
38378ab1bf12SLuiz Capitulinocat > $TMPC << EOF
38388ab1bf12SLuiz Capitulino#include <unistd.h>
38398ab1bf12SLuiz Capitulinoint main(void) {
3840c075a723SBlue Swirl    environ = 0;
38418ab1bf12SLuiz Capitulino    return 0;
38428ab1bf12SLuiz Capitulino}
38438ab1bf12SLuiz CapitulinoEOF
38448ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
38458ab1bf12SLuiz Capitulino    has_environ=yes
38468ab1bf12SLuiz Capitulinofi
38478ab1bf12SLuiz Capitulino
384876a347e1SRichard Henderson########################################
384976a347e1SRichard Henderson# check if cpuid.h is usable.
385076a347e1SRichard Henderson
385176a347e1SRichard Hendersoncpuid_h=no
385276a347e1SRichard Hendersoncat > $TMPC << EOF
385376a347e1SRichard Henderson#include <cpuid.h>
385476a347e1SRichard Hendersonint main(void) {
3855774d566cSPeter Maydell    unsigned a, b, c, d;
3856774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
3857774d566cSPeter Maydell
3858774d566cSPeter Maydell    if (max >= 1) {
3859774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
3860774d566cSPeter Maydell    }
3861774d566cSPeter Maydell
3862774d566cSPeter Maydell    if (max >= 7) {
3863774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
3864774d566cSPeter Maydell    }
3865774d566cSPeter Maydell
386676a347e1SRichard Henderson    return 0;
386776a347e1SRichard Henderson}
386876a347e1SRichard HendersonEOF
386976a347e1SRichard Hendersonif compile_prog "" "" ; then
387076a347e1SRichard Henderson    cpuid_h=yes
387176a347e1SRichard Hendersonfi
387276a347e1SRichard Henderson
3873f540166bSRichard Henderson########################################
3874f540166bSRichard Henderson# check if __[u]int128_t is usable.
3875f540166bSRichard Henderson
3876f540166bSRichard Hendersonint128=no
3877f540166bSRichard Hendersoncat > $TMPC << EOF
3878a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
3879a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
3880a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
3881a00f66abSStefan Weil# endif
3882a00f66abSStefan Weil#endif
3883f540166bSRichard Henderson__int128_t a;
3884f540166bSRichard Henderson__uint128_t b;
3885f540166bSRichard Hendersonint main (void) {
3886f540166bSRichard Henderson  a = a + b;
3887f540166bSRichard Henderson  b = a * b;
3888464e3671SPeter Maydell  a = a * a;
3889f540166bSRichard Henderson  return 0;
3890f540166bSRichard Henderson}
3891f540166bSRichard HendersonEOF
3892f540166bSRichard Hendersonif compile_prog "" "" ; then
3893f540166bSRichard Henderson    int128=yes
3894f540166bSRichard Hendersonfi
389576a347e1SRichard Henderson
38961e6e9acaSRichard Henderson########################################
38971e6e9acaSRichard Henderson# check if getauxval is available.
38981e6e9acaSRichard Henderson
38991e6e9acaSRichard Hendersongetauxval=no
39001e6e9acaSRichard Hendersoncat > $TMPC << EOF
39011e6e9acaSRichard Henderson#include <sys/auxv.h>
39021e6e9acaSRichard Hendersonint main(void) {
39031e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
39041e6e9acaSRichard Henderson}
39051e6e9acaSRichard HendersonEOF
39061e6e9acaSRichard Hendersonif compile_prog "" "" ; then
39071e6e9acaSRichard Henderson    getauxval=yes
39081e6e9acaSRichard Hendersonfi
39091e6e9acaSRichard Henderson
3910d2042378SAneesh Kumar K.V##########################################
3911e86ecd4bSJuan Quintela# End of CC checks
3912e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3913e86ecd4bSJuan Quintela
39141d728c39SBlue Swirlif test "$gcov" = "yes" ; then
39151d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
39161d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
39171d728c39SBlue Swirlelif test "$debug" = "no" ; then
3918e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
3919e86ecd4bSJuan Quintelafi
3920a316e378SJuan Quintela
39216542aa9cSPeter Lieven##########################################
39226542aa9cSPeter Lieven# Do we have libnfs
39236542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
3924b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
39256542aa9cSPeter Lieven    libnfs="yes"
39266542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
39276542aa9cSPeter Lieven    LIBS="$LIBS $libnfs_libs"
39286542aa9cSPeter Lieven  else
39296542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
39306542aa9cSPeter Lieven      feature_not_found "libnfs"
39316542aa9cSPeter Lieven    fi
39326542aa9cSPeter Lieven    libnfs="no"
39336542aa9cSPeter Lieven  fi
39346542aa9cSPeter Lievenfi
39351d728c39SBlue Swirl
393620ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
393720ff6c80SAnthony Liguori# enable/disable
393820ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
393920ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
394020ff6c80SAnthony Liguori	zero_malloc="no"
394120ff6c80SAnthony Liguori    else
394220ff6c80SAnthony Liguori	zero_malloc="yes"
394320ff6c80SAnthony Liguori    fi
394420ff6c80SAnthony Liguorifi
394520ff6c80SAnthony Liguori
39466ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
39476ca026cbSPeter Maydellif test "$werror" = "yes"; then
39486ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
39496ca026cbSPeter Maydellfi
39506ca026cbSPeter Maydell
3951e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3952e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
39531156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3954e86ecd4bSJuan Quintela    fi
3955e86ecd4bSJuan Quintelafi
3956e86ecd4bSJuan Quintela
395794dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
395894dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
395994dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
396094dd53c5SGerd Hoffmannelse
396194dd53c5SGerd Hoffmann    POD2MAN="pod2man"
396294dd53c5SGerd Hoffmannfi
396394dd53c5SGerd Hoffmann
3964952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3965952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3966952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3967952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3968952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3969952afb71SBlue Swirl        fi
3970952afb71SBlue Swirl    done
3971952afb71SBlue Swirlfi
3972952afb71SBlue Swirl
397310ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3974e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
3975528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
3976834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
39775a67135aSbellard
39784b1c11fdSDaniel P. Berrangetools=""
39794b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3980ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
39814b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
39824b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
39834b1c11fdSDaniel P. Berrange  fi
39844b1c11fdSDaniel P. Berrangefi
39854b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3986983eef5aSMeador Inge  if test "$virtfs" != no ; then
3987be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3988983eef5aSMeador Inge      virtfs=yes
398917bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3990983eef5aSMeador Inge    else
3991983eef5aSMeador Inge      if test "$virtfs" = yes; then
399276ad07a4SPeter Maydell        error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3993983eef5aSMeador Inge      fi
399417500370SAndreas Färber      virtfs=no
3995983eef5aSMeador Inge    fi
399617bff52bSM. Mohan Kumar  fi
3997d138cee9SMichael Rothfi
3998e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
3999b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4000e8ef31a3SMichael Tokarev      tools="qemu-ga\$(EXESUF) $tools"
4001b39297aeSTomoki Sekiyama      if [ "$mingw32" = "yes" -a "$guest_agent_with_vss" = "yes" ]; then
4002b39297aeSTomoki Sekiyama        tools="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb $tools"
4003b39297aeSTomoki Sekiyama      fi
4004e8ef31a3SMichael Tokarev      guest_agent=yes
4005e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
4006e8ef31a3SMichael Tokarev      guest_agent=no
4007e8ef31a3SMichael Tokarev  else
4008e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
4009ca35f780SPaolo Bonzini  fi
40104b1c11fdSDaniel P. Berrangefi
4011ca35f780SPaolo Bonzini
4012ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
4013ca35f780SPaolo Bonziniroms=
4014ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
4015ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
4016ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
4017ca35f780SPaolo Bonzini  roms="optionrom"
4018ca35f780SPaolo Bonzinifi
4019d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
402039ac8455SDavid Gibson  roms="$roms spapr-rtas"
402139ac8455SDavid Gibsonfi
4022ca35f780SPaolo Bonzini
40239933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
40249933c305SChristian Borntraeger  roms="$roms s390-ccw"
40259933c305SChristian Borntraegerfi
40269933c305SChristian Borntraeger
4027964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
4028964c6fa1SRichard Hendersonif test "$pie" = "no" ; then
4029964c6fa1SRichard Henderson  textseg_addr=
4030964c6fa1SRichard Henderson  case "$cpu" in
4031c72b26ecSRichard Henderson    arm | hppa | i386 | m68k | ppc | ppc64 | s390* | sparc | sparc64 | x86_64 | x32)
4032964c6fa1SRichard Henderson      textseg_addr=0x60000000
4033964c6fa1SRichard Henderson      ;;
4034964c6fa1SRichard Henderson    mips)
4035964c6fa1SRichard Henderson      textseg_addr=0x400000
4036964c6fa1SRichard Henderson      ;;
4037964c6fa1SRichard Henderson  esac
4038964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
4039964c6fa1SRichard Henderson    cat > $TMPC <<EOF
4040964c6fa1SRichard Henderson    int main(void) { return 0; }
4041964c6fa1SRichard HendersonEOF
4042964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
4043964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
4044964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
4045964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
4046964c6fa1SRichard Henderson      # at least.
4047964c6fa1SRichard Henderson      $ld --verbose | sed \
4048964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
4049964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
4050964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
4051964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
4052964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
4053964c6fa1SRichard Henderson    fi
4054964c6fa1SRichard Henderson  fi
4055964c6fa1SRichard Hendersonfi
4056964c6fa1SRichard Henderson
40575ca9388aSGerd Hoffmann# add pixman flags after all config tests are done
4058a540f158SPeter CrosthwaiteQEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags"
40595ca9388aSGerd Hoffmannlibs_softmmu="$libs_softmmu $pixman_libs"
40605ca9388aSGerd Hoffmann
40617d13299dSbellardecho "Install prefix    $prefix"
4062c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
4063f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
40643aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
4065e26110cfSFam Zhengecho "module directory  `eval echo $qemu_moddir`"
40668bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
40670f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
40681c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
406911d9f695Sbellardif test "$mingw32" = "no" ; then
40705a699bbbSLaszlo Ersekecho "local state directory   `eval echo $local_statedir`"
4071f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
407243ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
40735a699bbbSLaszlo Ersekelse
40745a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
4075d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
407611d9f695Sbellardfi
40775a67135aSbellardecho "Source path       $source_path"
40787d13299dSbellardecho "C compiler        $cc"
407983469015Sbellardecho "Host C compiler   $host_cc"
408083f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
40813c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
408245d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
40830c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
4084a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
40850c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
40867d13299dSbellardecho "make              $make"
40876a882643Spbrookecho "install           $install"
4088c886edfbSBlue Swirlecho "python            $python"
4089e2d8830eSBradif test "$slirp" = "yes" ; then
4090e2d8830eSBrad    echo "smbd              $smbd"
4091e2d8830eSBradfi
409217969268SFam Zhengecho "module support    $modules"
4093a98fd896Sbellardecho "host CPU          $cpu"
4094de83cd02Sbellardecho "host big endian   $bigendian"
409597a847bcSbellardecho "target list       $target_list"
4096ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
40977d13299dSbellardecho "gprof enabled     $gprof"
409803b4fe7dSaliguoriecho "sparse enabled    $sparse"
40991625af87Saliguoriecho "strip binaries    $strip_opt"
410005c2a3e7Sbellardecho "profiler          $profiler"
410143ce4dfeSbellardecho "static build      $static"
41025b0753e0Sbellardif test "$darwin" = "yes" ; then
41035b0753e0Sbellard    echo "Cocoa support     $cocoa"
41045b0753e0Sbellardfi
4105e2134eb9SGerd Hoffmannecho "pixman            $pixman"
410697a847bcSbellardecho "SDL support       $sdl"
4107a4ccabcfSAnthony Liguoriecho "GTK support       $gtk"
4108bbbf9bfbSStefan Weilecho "VTE support       $vte"
41094d3b6f6eSbalrogecho "curses support    $curses"
4110769ce76dSAlexander Grafecho "curl support      $curl"
411167b915a5Sbellardecho "mingw32 support   $mingw32"
41120c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
4113b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
4114b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
4115983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
4116821601eaSJes Sorensenecho "VNC support       $vnc"
4117821601eaSJes Sorensenif test "$vnc" = "yes" ; then
41188d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
41192f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
41202f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
4121efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
41227536ee4bSTim Hardeck    echo "VNC WS support    $vnc_ws"
4123821601eaSJes Sorensenfi
41243142255cSblueswir1if test -n "$sparc_cpu"; then
41253142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
41263142255cSblueswir1fi
4127e37630caSaliguoriecho "xen support       $xen"
41282e4d9fb1Saurel32echo "brlapi support    $brlapi"
4129a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
4130a25dba17SJuan Quintelaecho "Documentation     $docs"
4131c5937220Spbrook[ ! -z "$uname_release" ] && \
4132c5937220Spbrookecho "uname -r          $uname_release"
4133379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
413440d6444eSAvi Kivityecho "PIE               $pie"
41358a16d273Sthsecho "vde support       $vde"
413658952137SVincenzo Maffioneecho "netmap support    $netmap"
41375c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
4138758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
413977755340Sthsecho "Install blobs     $blobs"
4140b31a0277SJuan Quintelaecho "KVM support       $kvm"
41412da776dbSMichael R. Hinesecho "RDMA support      $rdma"
41429195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
4143f652e6afSaurel32echo "fdt support       $fdt"
4144ceb42de8Saliguoriecho "preadv support    $preadv"
41455f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
4146e78815a5SAndreas Färberecho "madvise           $madvise"
4147e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
41481e9737daSRichard Hendersonecho "sigev_thread_id   $sigev_thread_id"
4149ee682d27SStefan Weilecho "uuid support      $uuid"
415047e98658SCorey Bryantecho "libcap-ng support $cap_ng"
4151d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
41525e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
415394a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
41549410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
4155c9dd4074SStefan Weilif test "$spice" = "yes"; then
41562e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
4157c9dd4074SStefan Weilelse
4158c9dd4074SStefan Weilecho "spice support     $spice"
4159c9dd4074SStefan Weilfi
4160f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
4161dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
4162111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
41632b2325ffSGerd Hoffmannecho "libusb            $libusb"
416469354a83SHans de Goedeecho "usb net redir     $usb_redir"
4165b1e5fff4SMichael Walleecho "GLX support       $glx"
4166219c2521SStefan Weilif test "$libiscsi_version" = "1.4.0"; then
4167219c2521SStefan Weilecho "libiscsi support  $libiscsi (1.4.0)"
4168219c2521SStefan Weilelse
4169c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
4170219c2521SStefan Weilfi
41716542aa9cSPeter Lievenecho "libnfs support    $libnfs"
4172d138cee9SMichael Rothecho "build guest agent $guest_agent"
4173d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
4174f794573eSEduardo Otuboecho "seccomp support   $seccomp"
41757c2acc70SPeter Maydellecho "coroutine backend $coroutine"
417670c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
4177eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
4178583f6e7bSStefan Hajnocziecho "virtio-blk-data-plane $virtio_blk_data_plane"
41791d728c39SBlue Swirlecho "gcov              $gcov_tool"
41801d728c39SBlue Swirlecho "gcov enabled      $gcov"
4181ab214c29SStefan Bergerecho "TPM support       $tpm"
41820a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
41833b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
41843556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
41854f18b782SJeff Codyecho "vhdx              $vhdx"
418695c6bff3SBenoît Canetecho "Quorum            $quorum"
4187607dacd0Sqiaonuohanecho "lzo support       $lzo"
4188607dacd0Sqiaonuohanecho "snappy support    $snappy"
418967b915a5Sbellard
41901ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
419124b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
4192e8cd23deSbellardfi
419397a847bcSbellard
419498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
419597a847bcSbellard
4196dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
4197dbd99ae3SStefan Weil
419898ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
419998ec69acSJuan Quintelaecho >> $config_host_mak
420098ec69acSJuan Quintela
4201e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
420299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
420399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
42043aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
42058bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
42060f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
420799d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
420899d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
420922d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
42109afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
42119afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
4212e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
42135a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
4214785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
42155a699bbbSLaszlo Ersekfi
4216f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
4217f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
4218f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
4219834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
4220f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
4221804edf29SJuan Quintela
422298ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
4223727e5283SPaolo Bonzini
4224f8393946Saurel32if test "$debug_tcg" = "yes" ; then
42252358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
4226f8393946Saurel32fi
42271625af87Saliguoriif test "$strip_opt" = "yes" ; then
422852ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
42291625af87Saliguorifi
42307d13299dSbellardif test "$bigendian" = "yes" ; then
4231e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
423297a847bcSbellardfi
423367b915a5Sbellardif test "$mingw32" = "yes" ; then
423498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
42359fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
42369fe6de94SBlue Swirl  version_major=${rc_version%%.*}
42379fe6de94SBlue Swirl  rc_version=${rc_version#*.}
42389fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
42399fe6de94SBlue Swirl  rc_version=${rc_version#*.}
42409fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
42419fe6de94SBlue Swirl  version_micro=0
42429fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
42439fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
4244d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
4245d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
4246d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
4247d9840e25STomoki Sekiyama  fi
4248210fa556Spbrookelse
424935f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
4250210fa556Spbrookfi
4251128ab2ffSblueswir1
4252dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
4253dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
4254dffcb71cSMark McLoughlinfi
4255dffcb71cSMark McLoughlin
425683fb7adfSbellardif test "$darwin" = "yes" ; then
425798ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
425883fb7adfSbellardfi
4259b29fe3edSmalc
4260b29fe3edSmalcif test "$aix" = "yes" ; then
426198ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
4262b29fe3edSmalcfi
4263b29fe3edSmalc
4264ec530c81Sbellardif test "$solaris" = "yes" ; then
426598ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
42662358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
42670475a5caSths  if test "$needs_libsunmath" = "yes" ; then
426875b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
42690475a5caSths  fi
4270ec530c81Sbellardfi
4271179cf400SAndreas Färberif test "$haiku" = "yes" ; then
4272179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
4273179cf400SAndreas Färberfi
427497a847bcSbellardif test "$static" = "yes" ; then
427598ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
427697a847bcSbellardfi
42771ba16968SStefan Weilif test "$profiler" = "yes" ; then
42782358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
427905c2a3e7Sbellardfi
4280c20709aaSbellardif test "$slirp" = "yes" ; then
428198ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
4282e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
4283c20709aaSbellardfi
42848a16d273Sthsif test "$vde" = "yes" ; then
428598ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
42868a16d273Sthsfi
428758952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
428858952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
428958952137SVincenzo Maffionefi
429047e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
429147e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
429247e98658SCorey Bryantfi
42932358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
42940c58ac1cSmalcfor drv in $audio_drv_list; do
4295bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
429698ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
4297923e4521Smalc    if test "$drv" = "fmod"; then
42987aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
4299fb065187Sbellard    fi
43000c58ac1cSmalcdone
430167f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
430267f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
430367f86e8eSJuan Quintelafi
4304d5631638Smalcif test "$audio_win_int" = "yes" ; then
4305d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
4306d5631638Smalcfi
4307b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
4308b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
4309821601eaSJes Sorensenif test "$vnc" = "yes" ; then
4310821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
4311821601eaSJes Sorensenfi
43128d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
431398ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
43148d5d2d4cSthsfi
43152f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
431698ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
43172f9606b3Saliguorifi
4318821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
43192f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
43202f6f5c7aSCorentin Charyfi
4321821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
4322efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
4323efe556adSCorentin Charyfi
43247536ee4bSTim Hardeckif test "$vnc_ws" = "yes" ; then
43257536ee4bSTim Hardeck  echo "CONFIG_VNC_WS=y" >> $config_host_mak
43267536ee4bSTim Hardeck  echo "VNC_WS_CFLAGS=$vnc_ws_cflags" >> $config_host_mak
43277536ee4bSTim Hardeckfi
432876655d6dSaliguoriif test "$fnmatch" = "yes" ; then
43292358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
433076655d6dSaliguorifi
4331ee682d27SStefan Weilif test "$uuid" = "yes" ; then
4332ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
4333ee682d27SStefan Weilfi
4334dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
4335dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
4336dce512deSChristoph Hellwigfi
4337b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
433898ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
43392358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
434098ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
434198ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
4342a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
434398ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
4344cc8ae6deSpbrookfi
434517969268SFam Zhengif test "$modules" = "yes"; then
4346e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
4347e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
4348e26110cfSFam Zheng  echo "CONFIG_STAMP=_`(echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ `" >> $config_host_mak
434917969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
435017969268SFam Zhengfi
43511ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
435298ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
4353*a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
43548ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
435549ecc3faSbellardfi
435649ecc3faSbellardif test "$cocoa" = "yes" ; then
435798ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
435849ecc3faSbellardfi
43594d3b6f6eSbalrogif test "$curses" = "yes" ; then
436098ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
4361ab4e5602SJan Kiszkafi
4362ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
43632358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
4364ebc996f3SRiku Voipiofi
4365099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
43662358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
4367099d6b0fSRiku Voipiofi
436840ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
436940ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
437040ff6d7eSKevin Wolffi
43713ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
43722358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
43733ce34dfbSvibisreenivasanfi
4374c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
4375c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
4376c2882b96SRiku Voipiofi
4377d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
4378d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
4379d0927938SUlrich Hechtfi
43803d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
43813d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
43823d4fa43eSKusanagi Kouichifi
4383c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
4384c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
4385c727f47dSPeter Maydellfi
4386dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
4387dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
4388dace20dcSPeter Maydellfi
4389d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
4390d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
4391d0927938SUlrich Hechtfi
43924e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
43934e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
43944e0c6529SAlex Blighfi
4395cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
4396cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
4397cd758dd0SAlex Blighfi
43983b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
43993b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
44003b6edd16SPeter Maydellfi
44013b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
44023b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
44033b6edd16SPeter Maydellfi
44043b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
44053b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
44063b6edd16SPeter Maydellfi
4407a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
4408a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
4409a8fd1abaSPeter Maydellfi
44103b3f24adSaurel32if test "$inotify" = "yes" ; then
44112358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
44123b3f24adSaurel32fi
4413c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
4414c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
4415c05c7a73SRiku Voipiofi
44166ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
44176ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
44186ae9a1f4SJuan Quintelafi
44196ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
44206ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
44216ae9a1f4SJuan Quintelafi
4422769ce76dSAlexander Grafif test "$curl" = "yes" ; then
4423d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
4424b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
44256ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
4426769ce76dSAlexander Graffi
44272e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
442898ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
44292e4d9fb1Saurel32fi
4430fb599c9aSbalrogif test "$bluez" = "yes" ; then
443198ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
4432ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
4433fb599c9aSbalrogfi
4434e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
4435a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
4436a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
4437*a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
4438a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
4439bbbf9bfbSStefan Weilfi
4440bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
4441bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
4442a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
4443a4ccabcfSAnthony Liguorifi
4444e37630caSaliguoriif test "$xen" = "yes" ; then
44456dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
4446d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
4447e37630caSaliguorifi
44485c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
44495c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
44505c6c3a6cSChristoph Hellwigfi
4451758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
4452758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
4453758e8e38SVenkateswararao Jujjuri (JV)fi
44544f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
44554f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
44564f26f2b6SAvi Kivityfi
4457983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
4458758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
4459758e8e38SVenkateswararao Jujjuri (JV)fi
44605e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
44615e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
44625e9be92dSNicholas Bellingerfi
446377755340Sthsif test "$blobs" = "yes" ; then
446498ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
446577755340Sthsfi
4466bf9298b9Saliguoriif test "$iovec" = "yes" ; then
44672358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
4468bf9298b9Saliguorifi
4469ceb42de8Saliguoriif test "$preadv" = "yes" ; then
44702358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
4471ceb42de8Saliguorifi
4472f652e6afSaurel32if test "$fdt" = "yes" ; then
44733f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
4474f652e6afSaurel32fi
4475dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
4476dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
4477dcc38d1cSMarcelo Tosattifi
44789195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
44799195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
44809195b2c2SStefan Weilfi
44815f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
44825f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
44835f6b9e8fSBlue Swirlfi
4484e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
4485e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
4486e78815a5SAndreas Färberfi
4487e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
4488e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
4489e78815a5SAndreas Färberfi
44901e9737daSRichard Hendersonif test "$sigev_thread_id" = "yes" ; then
44911e9737daSRichard Henderson  echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
44921e9737daSRichard Hendersonfi
449397a847bcSbellard
4494cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
4495cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
4496cd4ec0b4SGerd Hoffmannfi
4497cd4ec0b4SGerd Hoffmann
4498111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
4499111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
4500ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
4501ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
4502111a38b0SRobert Relyeafi
4503111a38b0SRobert Relyea
45042b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
45052b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
45062b2325ffSGerd Hoffmannfi
45072b2325ffSGerd Hoffmann
450869354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
450969354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
451069354a83SHans de Goedefi
451169354a83SHans de Goede
4512b1e5fff4SMichael Walleif test "$glx" = "yes" ; then
4513b1e5fff4SMichael Walle  echo "CONFIG_GLX=y" >> $config_host_mak
45142b6b7099SPaolo Bonzini  echo "GLX_LIBS=$glx_libs" >> $config_host_mak
451520ff075bSMichael Wallefi
451620ff075bSMichael Walle
4517607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
4518607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
4519607dacd0Sqiaonuohanfi
4520607dacd0Sqiaonuohan
4521607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
4522607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
4523607dacd0Sqiaonuohanfi
4524607dacd0Sqiaonuohan
4525c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
4526d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
4527219c2521SStefan Weil  if test "$libiscsi_version" = "1.4.0"; then
4528219c2521SStefan Weil    echo "CONFIG_LIBISCSI_1_4=y" >> $config_host_mak
4529219c2521SStefan Weil  fi
45306ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
45316ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
4532c589b249SRonnie Sahlbergfi
4533c589b249SRonnie Sahlberg
45346542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
45356542aa9cSPeter Lieven  echo "CONFIG_LIBNFS=y" >> $config_host_mak
45366542aa9cSPeter Lievenfi
45376542aa9cSPeter Lieven
4538f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
4539f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
4540f794573eSEduardo Otubofi
4541f794573eSEduardo Otubo
454283fb7adfSbellard# XXX: suppress that
45437d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
45442358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
45457d3505c5Sbellardfi
45467d3505c5Sbellard
45472358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
4548c5937220Spbrook
454920ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
455020ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
455120ff6c80SAnthony Liguorifi
45523556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
45533556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
45543556c233SPaolo Bonzinifi
4555f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
4556d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
45576ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
45586ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
4559f27aaf4bSChristian Brunnerfi
456020ff6c80SAnthony Liguori
45617c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
456270c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
456370c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
456470c60c08SStefan Hajnoczielse
456570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
456670c60c08SStefan Hajnoczifi
4567d0e2fce5SAneesh Kumar K.V
4568d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
4569d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
4570d2042378SAneesh Kumar K.Vfi
4571d2042378SAneesh Kumar K.V
4572e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
4573e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
4574e06a765eSHarsh Prateek Borafi
4575e06a765eSHarsh Prateek Bora
4576cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
4577cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
457806d71fa1SPeter Maydellfi
457906d71fa1SPeter Maydell
45803f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
45813f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
45823f4349dcSKevin Wolffi
45833f4349dcSKevin Wolf
45848ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
45858ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
45868ab1bf12SLuiz Capitulinofi
45878ab1bf12SLuiz Capitulino
458876a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
458976a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
459076a347e1SRichard Hendersonfi
459176a347e1SRichard Henderson
4592f540166bSRichard Hendersonif test "$int128" = "yes" ; then
4593f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
4594f540166bSRichard Hendersonfi
4595f540166bSRichard Henderson
45961e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
45971e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
45981e6e9acaSRichard Hendersonfi
45991e6e9acaSRichard Henderson
4600eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
4601d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
46026ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
46036ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
4604eb100396SBharata B Raofi
4605eb100396SBharata B Rao
46060c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
46070c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
46080c14fb47SBharata B Raofi
46090c14fb47SBharata B Rao
46107c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
46117c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
46127c815372SBharata B Raofi
46137c815372SBharata B Rao
46140a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
4615d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
46166ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
46176ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
46180a12ec87SRichard W.M. Jonesfi
46190a12ec87SRichard W.M. Jones
462095c6bff3SBenoît Canetif test "$quorum" = "yes" ; then
462195c6bff3SBenoît Canet  echo "CONFIG_QUORUM=y" >> $config_host_mak
462295c6bff3SBenoît Canetfi
462395c6bff3SBenoît Canet
4624583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" ; then
46256e790746SPaolo Bonzini  echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
4626583f6e7bSStefan Hajnoczifi
4627583f6e7bSStefan Hajnoczi
46284f18b782SJeff Codyif test "$vhdx" = "yes" ; then
46294f18b782SJeff Cody  echo "CONFIG_VHDX=y" >> $config_host_mak
46304f18b782SJeff Codyfi
46314f18b782SJeff Cody
463268063649Sblueswir1# USB host support
4633b5613fdcSGerd Hoffmannif test "$libusb" = "yes"; then
46342b2325ffSGerd Hoffmann  echo "HOST_USB=libusb legacy" >> $config_host_mak
4635b5613fdcSGerd Hoffmannelse
463698ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
4637b5613fdcSGerd Hoffmannfi
463868063649Sblueswir1
46393b8acc11SPaolo Bonzini# TPM passthrough support?
46403b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
46413b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
46423b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
46433b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
46443b8acc11SPaolo Bonzini  fi
46453b8acc11SPaolo Bonzinifi
46463b8acc11SPaolo Bonzini
4647e4858974SLluís# use default implementation for tracing backend-specific routines
4648e4858974SLluístrace_default=yes
464994a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
46506d8a764eSLluísif test "$trace_backend" = "nop"; then
46516d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
465222890ab5SPrerna Saxenafi
46539410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
46546d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
4655e4858974SLluís  trace_default=no
46566d8a764eSLluís  # Set the appropriate trace file.
4657953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
46589410b56cSPrerna Saxenafi
46596d8a764eSLluísif test "$trace_backend" = "stderr"; then
46606d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
46619a82b6a5SLluís  trace_default=no
46626d8a764eSLluísfi
46636d8a764eSLluísif test "$trace_backend" = "ust"; then
46646d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
46656d8a764eSLluísfi
46666d8a764eSLluísif test "$trace_backend" = "dtrace"; then
46676d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
46686d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
46696d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
46706d8a764eSLluís  fi
4671c276b17dSDaniel P. Berrangefi
4672781e9545SEiichi Tsukataif test "$trace_backend" = "ftrace"; then
4673781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
4674781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4675781e9545SEiichi Tsukata    trace_default=no
4676781e9545SEiichi Tsukata  else
467721684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
4678781e9545SEiichi Tsukata  fi
4679781e9545SEiichi Tsukatafi
46809410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
4681e4858974SLluísif test "$trace_default" = "yes"; then
4682e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
4683e4858974SLluísfi
46849410b56cSPrerna Saxena
46852da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
46862da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
46872da776dbSMichael R. Hinesfi
46882da776dbSMichael R. Hines
46895c312079SDr. David Alan Gilbert# Hold two types of flag:
46905c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
46915c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
46925c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
46935c312079SDr. David Alan Gilbert#                                     platform
46945c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
46955c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
46965c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
46975c312079SDr. David Alan Gilbertfi
46985c312079SDr. David Alan Gilbert
46995b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
47005b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
47015b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
47025b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
47035b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
47045b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
4705c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
47065b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
47075b5e3037SPaolo Bonzinielse
47085b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
47095b5e3037SPaolo Bonzinifi
47105b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
47115b5e3037SPaolo Bonzini
471298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
471398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4714804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4715804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
47161901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
47171901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
471821655882SPaolo Bonziniif test -n "$libtool"; then
471921655882SPaolo Bonzini  echo "INSTALL_PROG=\$(LIBTOOL) --mode=install $install -c -m 0755" >> $config_host_mak
472021655882SPaolo Bonzini  echo "INSTALL_LIB=\$(LIBTOOL) --mode=install $install -c -m 0644" >> $config_host_mak
472121655882SPaolo Bonzinielse
47221901cb14SBrad  echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
472321655882SPaolo Bonzini  echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
472421655882SPaolo Bonzinifi
4725c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
4726804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
4727a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
4728a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
4729a31a8642SMichael S. Tsirkinfi
47302b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
4731804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
473283f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
47333c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
4734804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
473545d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
47363dd46c78SBlue Swirlecho "AS=$as" >> $config_host_mak
47373dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4738804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4739804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
47409fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
474144dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
4742e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
474346eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
4744a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
4745f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
4746e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
4747e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
4748e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
4749e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
4750e39f0062SPaolo Bonzinifi
475142da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
475242da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
475342da6041SGerd Hoffmannelse
475442da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
475542da6041SGerd Hoffmannfi
4756e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
475746eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
475837746c5eSMarc-André Lureauecho "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
475973da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
47603e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
4761804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
476217969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
476317969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
4764957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
476594dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
4766cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
47671d728c39SBlue Swirlif test "$gcov" = "yes" ; then
47681d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
47691d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
47701d728c39SBlue Swirlfi
4771804edf29SJuan Quintela
47726efd7517SPeter Maydell# use included Linux headers
47736efd7517SPeter Maydellif test "$linux" = "yes" ; then
4774a307beb6SAndreas Färber  mkdir -p linux-headers
47756efd7517SPeter Maydell  case "$cpu" in
4776c72b26ecSRichard Henderson  i386|x86_64|x32)
477708312a63SPeter Maydell    linux_arch=x86
47786efd7517SPeter Maydell    ;;
47796efd7517SPeter Maydell  ppcemb|ppc|ppc64)
478008312a63SPeter Maydell    linux_arch=powerpc
47816efd7517SPeter Maydell    ;;
47826efd7517SPeter Maydell  s390x)
478308312a63SPeter Maydell    linux_arch=s390
478408312a63SPeter Maydell    ;;
47851f080313SClaudio Fontana  aarch64)
47861f080313SClaudio Fontana    linux_arch=arm64
47871f080313SClaudio Fontana    ;;
478808312a63SPeter Maydell  *)
478908312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
479008312a63SPeter Maydell    linux_arch="$cpu"
47916efd7517SPeter Maydell    ;;
47926efd7517SPeter Maydell  esac
479308312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
479408312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
479508312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
479608312a63SPeter Maydell    fi
47976efd7517SPeter Maydellfi
47986efd7517SPeter Maydell
479997a847bcSbellardfor target in $target_list; do
480097a847bcSbellardtarget_dir="$target"
480125be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
4802c1799a84SPaolo Bonzinitarget_name=`echo $target | cut -d '-' -f 1`
480397a847bcSbellardtarget_bigendian="no"
48041f3d3c8fSJuan Quintela
4805c1799a84SPaolo Bonzinicase "$target_name" in
4806d15a9c23SAnthony Green  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
4807ea2d6a39SJuan Quintela  target_bigendian=yes
4808ea2d6a39SJuan Quintela  ;;
4809ea2d6a39SJuan Quintelaesac
481097a847bcSbellardtarget_softmmu="no"
4811997344f3Sbellardtarget_user_only="no"
4812831b7825Sthstarget_linux_user="no"
481384778508Sblueswir1target_bsd_user="no"
48149e407a85Spbrookcase "$target" in
4815c1799a84SPaolo Bonzini  ${target_name}-softmmu)
48169e407a85Spbrook    target_softmmu="yes"
48179e407a85Spbrook    ;;
4818c1799a84SPaolo Bonzini  ${target_name}-linux-user)
48199c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
482076ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a Linux host"
48219c7a4202SBlue Swirl    fi
48229e407a85Spbrook    target_user_only="yes"
48239e407a85Spbrook    target_linux_user="yes"
48249e407a85Spbrook    ;;
4825c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
48269cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
482776ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a BSD host"
48289c7a4202SBlue Swirl    fi
482984778508Sblueswir1    target_user_only="yes"
483084778508Sblueswir1    target_bsd_user="yes"
483184778508Sblueswir1    ;;
48329e407a85Spbrook  *)
483376ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
48349e407a85Spbrook    exit 1
48359e407a85Spbrook    ;;
48369e407a85Spbrookesac
4837831b7825Sths
483897a847bcSbellardmkdir -p $target_dir
483925be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
484097a847bcSbellard
4841e5fe0c52Spbrookbflt="no"
4842c1799a84SPaolo Bonziniinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"`
484356aebc89Spbrookgdb_xml_files=""
48447ba1e619Saliguori
4845c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
48466acff7daSJuan QuintelaTARGET_BASE_ARCH=""
4847e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
4848e73aae67SJuan Quintela
4849c1799a84SPaolo Bonzinicase "$target_name" in
48502408a527Saurel32  i386)
48512408a527Saurel32  ;;
48522408a527Saurel32  x86_64)
48536acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
48542408a527Saurel32  ;;
48552408a527Saurel32  alpha)
48562408a527Saurel32  ;;
48572408a527Saurel32  arm|armeb)
4858b498c8a0SJuan Quintela    TARGET_ARCH=arm
4859e5fe0c52Spbrook    bflt="yes"
486056aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
48612408a527Saurel32  ;;
48626a49fa95SAlexander Graf  aarch64)
48636a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
48646a49fa95SAlexander Graf    bflt="yes"
48656a669427SPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml"
48666a49fa95SAlexander Graf  ;;
48672408a527Saurel32  cris)
48682408a527Saurel32  ;;
4869613a22c9SMichael Walle  lm32)
4870613a22c9SMichael Walle  ;;
48712408a527Saurel32  m68k)
48720938cda5Saurel32    bflt="yes"
487356aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
48742408a527Saurel32  ;;
4875877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
4876877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
487772b675caSEdgar E. Iglesias    bflt="yes"
487872b675caSEdgar E. Iglesias  ;;
48792408a527Saurel32  mips|mipsel)
4880b498c8a0SJuan Quintela    TARGET_ARCH=mips
488125be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
48822408a527Saurel32  ;;
48832408a527Saurel32  mipsn32|mipsn32el)
4884597e2cecSRichard Henderson    TARGET_ARCH=mips64
48856acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
488625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
4887597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
48882408a527Saurel32  ;;
48892408a527Saurel32  mips64|mips64el)
4890b498c8a0SJuan Quintela    TARGET_ARCH=mips64
48916acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
489225be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
48932408a527Saurel32  ;;
4894d15a9c23SAnthony Green  moxie)
4895d15a9c23SAnthony Green  ;;
4896e67db06eSJia Liu  or32)
4897e67db06eSJia Liu    TARGET_ARCH=openrisc
4898e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
4899e67db06eSJia Liu  ;;
49002408a527Saurel32  ppc)
4901c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
49022408a527Saurel32  ;;
49032408a527Saurel32  ppcemb)
49046acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4905e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4906c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
49072408a527Saurel32  ;;
49082408a527Saurel32  ppc64)
49096acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4910e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4911c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
49122408a527Saurel32  ;;
49132408a527Saurel32  ppc64abi32)
4914b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
49156acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4916e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
491725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
4918c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
49192408a527Saurel32  ;;
49202408a527Saurel32  sh4|sh4eb)
4921b498c8a0SJuan Quintela    TARGET_ARCH=sh4
49224dbed897Spbrook    bflt="yes"
49232408a527Saurel32  ;;
49242408a527Saurel32  sparc)
49252408a527Saurel32  ;;
49262408a527Saurel32  sparc64)
49276acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
49282408a527Saurel32  ;;
49292408a527Saurel32  sparc32plus)
4930b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
49316acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
4932e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
493325be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
49342408a527Saurel32  ;;
493524e804ecSAlexander Graf  s390x)
493624e804ecSAlexander Graf  ;;
4937d2fbca94SGuan Xuetao  unicore32)
4938d2fbca94SGuan Xuetao  ;;
4939cfa550c6SMax Filippov  xtensa|xtensaeb)
4940cfa550c6SMax Filippov    TARGET_ARCH=xtensa
4941cfa550c6SMax Filippov  ;;
49422408a527Saurel32  *)
494376ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
49442408a527Saurel32  ;;
49452408a527Saurel32esac
49465e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
49475e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
49485e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
49495e8861a0SPaolo Bonzinifi
49505e8861a0SPaolo Bonzini
49515e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
49525e8861a0SPaolo Bonzini
495399afc91dSDaniel P. Berrangeupper() {
495499afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
495599afc91dSDaniel P. Berrange}
495699afc91dSDaniel P. Berrange
495799afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
495825be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
4959c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
496025be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
4961e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
4962e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
4963e6e91b9cSJuan Quintelafi
496425be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
4965c1799a84SPaolo Bonzinicase "$target_name" in
49661b0c87fcSJuan Quintela  i386|x86_64)
49671b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
496825be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
4969eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
4970eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
4971eb6fda0fSAnthony PERARD      fi
4972432d268cSJun Nakajima    fi
497359d21e53SAlexander Graf    ;;
497459d21e53SAlexander Graf  *)
49751b0c87fcSJuan Quintelaesac
4976c1799a84SPaolo Bonzinicase "$target_name" in
497770a5f682SPeter Maydell  aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x)
4978c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
4979c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
4980c1799a84SPaolo Bonzini      \( "$target_name" = "$cpu" -o \
4981c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
4982c1799a84SPaolo Bonzini      \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
4983c1799a84SPaolo Bonzini      \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
4984c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
4985c1799a84SPaolo Bonzini      \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
4986c1799a84SPaolo Bonzini      \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
498725be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
49881ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
4989d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
4990d5970055SMichael S. Tsirkin      fi
4991c59249f9SJuan Quintela    fi
4992c59249f9SJuan Quintelaesac
4993de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
499425be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
499597a847bcSbellardfi
499697a847bcSbellardif test "$target_softmmu" = "yes" ; then
499725be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
4998de83cd02Sbellardfi
4999997344f3Sbellardif test "$target_user_only" = "yes" ; then
500025be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
5001a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
5002997344f3Sbellardfi
5003831b7825Sthsif test "$target_linux_user" = "yes" ; then
500425be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
5005831b7825Sthsfi
500656aebc89Spbrooklist=""
500756aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
500856aebc89Spbrook  for x in $gdb_xml_files; do
500956aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
501056aebc89Spbrook  done
501125be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
50123d0f1517SJuan Quintelafi
5013de83cd02Sbellard
5014e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
501525be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
5016e5fe0c52Spbrookfi
5017379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
501825be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
5019379f6698SPaul Brookfi
502084778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
502125be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
502284778508Sblueswir1fi
50235b0753e0Sbellard
50244afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
5025fa282484SJuan Quintela
50264afddb55SJuan Quintelacflags=""
5027fa282484SJuan Quintelaldflags=""
50289b8e111fSJuan Quintela
502964656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
503064656024SJuan Quintela  case "$i" in
503164656024SJuan Quintela  alpha)
503225be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
503376cad711SPaolo Bonzini    echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
503464656024SJuan Quintela  ;;
503582295d8aSRichard Henderson  aarch64)
503682295d8aSRichard Henderson    if test -n "${cxx}"; then
503782295d8aSRichard Henderson      echo "CONFIG_ARM_A64_DIS=y"  >> $config_target_mak
503882295d8aSRichard Henderson      echo "CONFIG_ARM_A64_DIS=y"  >> config-all-disas.mak
503982295d8aSRichard Henderson    fi
504082295d8aSRichard Henderson  ;;
504164656024SJuan Quintela  arm)
504225be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
504376cad711SPaolo Bonzini    echo "CONFIG_ARM_DIS=y"  >> config-all-disas.mak
5044999b53ecSClaudio Fontana    if test -n "${cxx}"; then
5045999b53ecSClaudio Fontana      echo "CONFIG_ARM_A64_DIS=y"  >> $config_target_mak
5046999b53ecSClaudio Fontana      echo "CONFIG_ARM_A64_DIS=y"  >> config-all-disas.mak
5047999b53ecSClaudio Fontana    fi
504864656024SJuan Quintela  ;;
504964656024SJuan Quintela  cris)
505025be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
505176cad711SPaolo Bonzini    echo "CONFIG_CRIS_DIS=y"  >> config-all-disas.mak
505264656024SJuan Quintela  ;;
505364656024SJuan Quintela  hppa)
505425be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
505576cad711SPaolo Bonzini    echo "CONFIG_HPPA_DIS=y"  >> config-all-disas.mak
505664656024SJuan Quintela  ;;
5057c72b26ecSRichard Henderson  i386|x86_64|x32)
505825be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
505976cad711SPaolo Bonzini    echo "CONFIG_I386_DIS=y"  >> config-all-disas.mak
506064656024SJuan Quintela  ;;
5061903ec55cSAurelien Jarno  ia64*)
5062903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
506376cad711SPaolo Bonzini    echo "CONFIG_IA64_DIS=y"  >> config-all-disas.mak
5064903ec55cSAurelien Jarno  ;;
506579368f49SMichael Walle  lm32)
506679368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
506776cad711SPaolo Bonzini    echo "CONFIG_LM32_DIS=y"  >> config-all-disas.mak
506879368f49SMichael Walle  ;;
506964656024SJuan Quintela  m68k)
507025be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
507176cad711SPaolo Bonzini    echo "CONFIG_M68K_DIS=y"  >> config-all-disas.mak
507264656024SJuan Quintela  ;;
5073877fdc12SEdgar E. Iglesias  microblaze*)
507425be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
507576cad711SPaolo Bonzini    echo "CONFIG_MICROBLAZE_DIS=y"  >> config-all-disas.mak
507664656024SJuan Quintela  ;;
507764656024SJuan Quintela  mips*)
507825be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
507976cad711SPaolo Bonzini    echo "CONFIG_MIPS_DIS=y"  >> config-all-disas.mak
508064656024SJuan Quintela  ;;
5081d15a9c23SAnthony Green  moxie*)
5082d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> $config_target_mak
5083d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> config-all-disas.mak
5084d15a9c23SAnthony Green  ;;
5085e67db06eSJia Liu  or32)
5086e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
508776cad711SPaolo Bonzini    echo "CONFIG_OPENRISC_DIS=y"  >> config-all-disas.mak
5088e67db06eSJia Liu  ;;
508964656024SJuan Quintela  ppc*)
509025be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
509176cad711SPaolo Bonzini    echo "CONFIG_PPC_DIS=y"  >> config-all-disas.mak
509264656024SJuan Quintela  ;;
509324e804ecSAlexander Graf  s390*)
509425be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
509576cad711SPaolo Bonzini    echo "CONFIG_S390_DIS=y"  >> config-all-disas.mak
509664656024SJuan Quintela  ;;
509764656024SJuan Quintela  sh4)
509825be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
509976cad711SPaolo Bonzini    echo "CONFIG_SH4_DIS=y"  >> config-all-disas.mak
510064656024SJuan Quintela  ;;
510164656024SJuan Quintela  sparc*)
510225be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
510376cad711SPaolo Bonzini    echo "CONFIG_SPARC_DIS=y"  >> config-all-disas.mak
510464656024SJuan Quintela  ;;
5105cfa550c6SMax Filippov  xtensa*)
5106cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
510776cad711SPaolo Bonzini    echo "CONFIG_XTENSA_DIS=y"  >> config-all-disas.mak
5108cfa550c6SMax Filippov  ;;
510964656024SJuan Quintela  esac
511064656024SJuan Quinteladone
51119195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
51129195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
511376cad711SPaolo Bonzini  echo "CONFIG_TCI_DIS=y"  >> config-all-disas.mak
51149195b2c2SStefan Weilfi
511564656024SJuan Quintela
51166ee7126fSJuan Quintelacase "$ARCH" in
51176ee7126fSJuan Quintelaalpha)
51186ee7126fSJuan Quintela  # Ensure there's only a single GP
51196ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
51206ee7126fSJuan Quintela;;
51216ee7126fSJuan Quintelaesac
51226ee7126fSJuan Quintela
5123d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
512425be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
5125d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
5126d02c1db3SJuan Quintela    cflags="-p $cflags"
5127d02c1db3SJuan Quintela    ldflags="-p $ldflags"
5128d02c1db3SJuan Quintela  fi
5129d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
5130d02c1db3SJuan Quintela    ldflags="-p $ldflags"
513125be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
5132d02c1db3SJuan Quintela  fi
5133d02c1db3SJuan Quintelafi
5134d02c1db3SJuan Quintela
51359b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
5136964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
5137fa282484SJuan Quintelafi
5138fa282484SJuan Quintela
513925be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
514025be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
5141fa282484SJuan Quintela
514297a847bcSbellarddone # for target in $targets
51437d13299dSbellard
5144b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
5145b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
5146b776eca1SGerd Hoffmannfi
5147b776eca1SGerd Hoffmann
51482da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
51492da776dbSMichael R. Hinesecho "CONFIG_RDMA=y" >> $config_host_mak
51502da776dbSMichael R. Hinesfi
51512da776dbSMichael R. Hines
5152a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
5153a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
5154a540f158SPeter Crosthwaitefi
5155a540f158SPeter Crosthwaite
5156d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
5157f93296eaSWenchao XiaDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
51582b170effSMichael TokarevDIRS="$DIRS fsdev"
51599933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
51602d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
51612dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
5162c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
5163c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
5164aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
5165ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
5166446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
51679933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
51682d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
51694652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
5170753d11f2SRichard Hendersonfor bios_file in \
5171753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
51725acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
5173753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
5174753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
5175e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
5176753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
5177753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
5178753d11f2SRichard Hendersondo
51797ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
51807ea78b74SJan Kiszkadone
5181c2304b52SMarcel Apfelbaumfor test_file in `find $source_path/tests/acpi-test-data -type f`
5182c2304b52SMarcel Apfelbaumdo
5183c2304b52SMarcel Apfelbaum    FILES="$FILES tests/acpi-test-data`echo $test_file | sed -e 's/.*acpi-test-data//'`"
5184c2304b52SMarcel Apfelbaumdone
5185d1807a4fSPaolo Bonzinimkdir -p $DIRS
51867d13299dSbellardfor f in $FILES ; do
518772b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
5188f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
5189f9245e10SPeter Maydell    fi
51907d13299dSbellarddone
51911ad2134fSPaul Brook
5192c34ebfdcSAnthony Liguori# temporary config to build submodules
51932d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
5194c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
519537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
5196c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
51973dd46c78SBlue Swirl    echo "AS=$as" >> $config_mak
5198c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
5199c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
52003dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
5201c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
5202a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
5203c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
5204c34ebfdcSAnthony Liguoridone
5205c34ebfdcSAnthony Liguori
5206b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
5207b40292e7SJan Kiszka  mkdir -p QMP
5208b40292e7SJan Kiszkafi
5209dc655404SMichael S. Tsirkin
5210dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
5211dc655404SMichael S. Tsirkincat <<EOD >config.status
5212dc655404SMichael S. Tsirkin#!/bin/sh
5213dc655404SMichael S. Tsirkin# Generated by configure.
5214dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
5215dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
5216dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
5217dc655404SMichael S. TsirkinEOD
5218dc655404SMichael S. Tsirkinprintf "exec" >>config.status
5219dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
5220dc655404SMichael S. Tsirkinecho >>config.status
5221dc655404SMichael S. Tsirkinchmod +x config.status
5222dc655404SMichael S. Tsirkin
5223