xref: /openbmc/qemu/configure (revision e4650c81)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
58cd05ab6SPeter Maydell
699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools,
799519e67SCornelia Huck# just as autoconf does.
899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS=
999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS
1099519e67SCornelia Huck
115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests!
125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes
135e4dfd3dSJohn Snow
148cd05ab6SPeter Maydell# Temporary directory used for files created while
158cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
168cd05ab6SPeter Maydell# we can safely blow away any previous version of it
178cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
188cd05ab6SPeter Maydell# it when configure exits.)
198cd05ab6SPeter MaydellTMPDIR1="config-temp"
208cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
218cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
228cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
238cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
248cd05ab6SPeter Maydell    exit 1
257d13299dSbellardfi
267d13299dSbellard
278cd05ab6SPeter MaydellTMPB="qemu-conf"
288cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
2966518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
309c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
3166518bf6SDon SlutzTMPL="${TMPDIR1}/${TMPB}.lo"
3266518bf6SDon SlutzTMPA="${TMPDIR1}/lib${TMPB}.la"
338cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
346969ec6cSJames ClarkeTMPMO="${TMPDIR1}/${TMPB}.mo"
357d13299dSbellard
36da1d85e3SGerd Hoffmannrm -f config.log
379ac81bbbSmalc
38b48e3611SPeter Maydell# Print a helpful header at the top of config.log
39b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
40979ae168SPeter Maydellprintf "# Configured with:" >> config.log
41979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
42979ae168SPeter Maydellecho >> config.log
43b48e3611SPeter Maydellecho "#" >> config.log
44b48e3611SPeter Maydell
4576ad07a4SPeter Maydellerror_exit() {
4676ad07a4SPeter Maydell    echo
4776ad07a4SPeter Maydell    echo "ERROR: $1"
4876ad07a4SPeter Maydell    while test -n "$2"; do
4976ad07a4SPeter Maydell        echo "       $2"
5076ad07a4SPeter Maydell        shift
5176ad07a4SPeter Maydell    done
5276ad07a4SPeter Maydell    echo
5376ad07a4SPeter Maydell    exit 1
5476ad07a4SPeter Maydell}
5576ad07a4SPeter Maydell
569c83ffd8SPeter Maydelldo_compiler() {
579c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
589c83ffd8SPeter Maydell    # is compiler binary to execute.
599c83ffd8SPeter Maydell    local compiler="$1"
609c83ffd8SPeter Maydell    shift
619c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
629c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
638dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
648dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
658dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
668dc38a78SPeter Maydell    # obvious to developers.
678dc38a78SPeter Maydell    if test "$werror" != "yes"; then
688dc38a78SPeter Maydell        return 0
698dc38a78SPeter Maydell    fi
708dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
718dc38a78SPeter Maydell    case "$*" in
728dc38a78SPeter Maydell        *-Werror*)
738dc38a78SPeter Maydell           return 0
748dc38a78SPeter Maydell        ;;
758dc38a78SPeter Maydell    esac
769c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
779c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
7876ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
7976ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
8076ad07a4SPeter Maydell        "will be at the bottom of config.log." \
8176ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
828dc38a78SPeter Maydell}
838dc38a78SPeter Maydell
849c83ffd8SPeter Maydelldo_cc() {
859c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
869c83ffd8SPeter Maydell}
879c83ffd8SPeter Maydell
889c83ffd8SPeter Maydelldo_cxx() {
899c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
909c83ffd8SPeter Maydell}
919c83ffd8SPeter Maydell
929c83ffd8SPeter Maydellupdate_cxxflags() {
939c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
949c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
959c83ffd8SPeter Maydell    # because they only make sense for C programs.
969c83ffd8SPeter Maydell    QEMU_CXXFLAGS=
979c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
989c83ffd8SPeter Maydell        case $arg in
999c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1009c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1019c83ffd8SPeter Maydell                ;;
1029c83ffd8SPeter Maydell            *)
1039c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1049c83ffd8SPeter Maydell                ;;
1059c83ffd8SPeter Maydell        esac
1069c83ffd8SPeter Maydell    done
1079c83ffd8SPeter Maydell}
1089c83ffd8SPeter Maydell
10952166aa0SJuan Quintelacompile_object() {
110fd0e6053SJohn Snow  local_cflags="$1"
111fd0e6053SJohn Snow  do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
11252166aa0SJuan Quintela}
11352166aa0SJuan Quintela
11452166aa0SJuan Quintelacompile_prog() {
11552166aa0SJuan Quintela  local_cflags="$1"
11652166aa0SJuan Quintela  local_ldflags="$2"
1178dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
11852166aa0SJuan Quintela}
11952166aa0SJuan Quintela
12011568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
12111568d6dSPaolo Bonzinisymlink() {
12272b8b5a1SStefan Weil  rm -rf "$2"
123ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
12472b8b5a1SStefan Weil  ln -s "$1" "$2"
12511568d6dSPaolo Bonzini}
12611568d6dSPaolo Bonzini
1270dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1280dba6195SLoïc Minier# executable or a builtin)
1290dba6195SLoïc Minierhas() {
1300dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1310dba6195SLoïc Minier}
1320dba6195SLoïc Minier
1330dba6195SLoïc Minier# search for an executable in PATH
1340dba6195SLoïc Minierpath_of() {
1350dba6195SLoïc Minier    local_command="$1"
1360dba6195SLoïc Minier    local_ifs="$IFS"
1370dba6195SLoïc Minier    local_dir=""
1380dba6195SLoïc Minier
1390dba6195SLoïc Minier    # pathname has a dir component?
1400dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1410dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1420dba6195SLoïc Minier            echo "$local_command"
1430dba6195SLoïc Minier            return 0
1440dba6195SLoïc Minier        fi
1450dba6195SLoïc Minier    fi
1460dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1470dba6195SLoïc Minier        return 1
1480dba6195SLoïc Minier    fi
1490dba6195SLoïc Minier
1500dba6195SLoïc Minier    IFS=:
1510dba6195SLoïc Minier    for local_dir in $PATH; do
1520dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1530dba6195SLoïc Minier            echo "$local_dir/$local_command"
1540dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1550dba6195SLoïc Minier            return 0
1560dba6195SLoïc Minier        fi
1570dba6195SLoïc Minier    done
1580dba6195SLoïc Minier    # not found
1590dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1600dba6195SLoïc Minier    return 1
1610dba6195SLoïc Minier}
1620dba6195SLoïc Minier
1635b808275SLluís Vilanovahave_backend () {
1645b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
1655b808275SLluís Vilanova}
1665b808275SLluís Vilanova
1677d13299dSbellard# default parameters
16889138857SStefan Weilsource_path=$(dirname "$0")
1692ff6b91eSJuan Quintelacpu=""
170a31a8642SMichael S. Tsirkiniasl="iasl"
1711e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
17243ce4dfeSbellardstatic="no"
1737d13299dSbellardcross_prefix=""
1740c58ac1cSmalcaudio_drv_list=""
175b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
176b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
177e49d021eSPeter Maydellhost_cc="cc"
17873da375eSJuan Quintelalibs_softmmu=""
1793e2e0e6bSJuan Quintelalibs_tools=""
18067f86e8eSJuan Quintelaaudio_pt_int=""
181d5631638Smalcaudio_win_int=""
1822b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
183957f1f99SMichael Rothlibs_qga=""
1845bc62e01SGerd Hoffmanndebug_info="yes"
18563678e17SSteven Noonanstack_protector=""
186ac0df51dSaliguori
187afb63ebdSStefan Weil# Don't accept a target_list environment variable.
188afb63ebdSStefan Weilunset target_list
189377529c0SPaolo Bonzini
190377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
191377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
192377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
193377529c0SPaolo Bonzini#              unless --disable-foo is given
194377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
195377529c0SPaolo Bonzini#              feature will searched for,
196377529c0SPaolo Bonzini#              if not found, configure exits with error
197377529c0SPaolo Bonzini#
198377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
199377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
200377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
201377529c0SPaolo Bonzini
202377529c0SPaolo Bonzinibluez=""
203377529c0SPaolo Bonzinibrlapi=""
204377529c0SPaolo Bonzinicurl=""
205377529c0SPaolo Bonzinicurses=""
206377529c0SPaolo Bonzinidocs=""
207377529c0SPaolo Bonzinifdt=""
20858952137SVincenzo Maffionenetmap="no"
209e2134eb9SGerd Hoffmannpixman=""
210377529c0SPaolo Bonzinisdl=""
211ee8466d0SCole Robinsonsdlabi=""
212983eef5aSMeador Ingevirtfs=""
213821601eaSJes Sorensenvnc="yes"
214377529c0SPaolo Bonzinisparse="no"
215377529c0SPaolo Bonziniuuid=""
216377529c0SPaolo Bonzinivde=""
217377529c0SPaolo Bonzinivnc_sasl=""
218377529c0SPaolo Bonzinivnc_jpeg=""
219377529c0SPaolo Bonzinivnc_png=""
220377529c0SPaolo Bonzinixen=""
221d5b93ddfSAnthony PERARDxen_ctrl_version=""
22264a7ad6fSIan Campbellxen_pv_domain_build="no"
223eb6fda0fSAnthony PERARDxen_pci_passthrough=""
224377529c0SPaolo Bonzinilinux_aio=""
22547e98658SCorey Bryantcap_ng=""
226377529c0SPaolo Bonziniattr=""
2274f26f2b6SAvi Kivitylibattr=""
228377529c0SPaolo Bonzinixfs=""
229377529c0SPaolo Bonzini
230d41a75a2SBradvhost_net="no"
2315e9be92dSNicholas Bellingervhost_scsi="no"
232d41a75a2SBradkvm="no"
2332da776dbSMichael R. Hinesrdma=""
234377529c0SPaolo Bonzinigprof="no"
235377529c0SPaolo Bonzinidebug_tcg="no"
236377529c0SPaolo Bonzinidebug="no"
237b553a042SJohn Snowfortify_source=""
238377529c0SPaolo Bonzinistrip_opt="yes"
2399195b2c2SStefan Weiltcg_interpreter="no"
240377529c0SPaolo Bonzinibigendian="no"
241377529c0SPaolo Bonzinimingw32="no"
2421d728c39SBlue Swirlgcov="no"
2431d728c39SBlue Swirlgcov_tool="gcov"
244377529c0SPaolo BonziniEXESUF=""
24517969268SFam ZhengDSOSUF=".so"
24617969268SFam ZhengLDFLAGS_SHARED="-shared"
24717969268SFam Zhengmodules="no"
248377529c0SPaolo Bonziniprefix="/usr/local"
249377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
250528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
251850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
252377529c0SPaolo Bonzinibindir="\${prefix}/bin"
2533aa5d2beSAlon Levylibdir="\${prefix}/lib"
2548bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
2550f94d6daSAlon Levyincludedir="\${prefix}/include"
256377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
257785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
258377529c0SPaolo Bonziniconfsuffix="/qemu"
259377529c0SPaolo Bonzinislirp="yes"
260377529c0SPaolo Bonzinioss_lib=""
261377529c0SPaolo Bonzinibsd="no"
262377529c0SPaolo Bonzinilinux="no"
263377529c0SPaolo Bonzinisolaris="no"
264377529c0SPaolo Bonziniprofiler="no"
265377529c0SPaolo Bonzinicocoa="no"
266377529c0SPaolo Bonzinisoftmmu="yes"
267377529c0SPaolo Bonzinilinux_user="no"
268377529c0SPaolo Bonzinibsd_user="no"
269377529c0SPaolo Bonziniaix="no"
270377529c0SPaolo Bonziniblobs="yes"
271377529c0SPaolo Bonzinipkgversion=""
27240d6444eSAvi Kivitypie=""
2733556c233SPaolo Bonziniqom_cast_debug="yes"
274baf86d6bSPaolo Bonzinitrace_backends="log"
275377529c0SPaolo Bonzinitrace_file="trace"
276377529c0SPaolo Bonzinispice=""
277377529c0SPaolo Bonzinirbd=""
2787b02f544SMarc-André Lureausmartcard=""
2792b2325ffSGerd Hoffmannlibusb=""
28069354a83SHans de Goedeusb_redir=""
281da076ffeSGerd Hoffmannopengl=""
282014cb152SGerd Hoffmannopengl_dmabuf="no"
28399f2dbd3SLiang Liavx2_opt="no"
2841ece9905SAlon Levyzlib="yes"
285b25c9dffSStefan Weillzo=""
286b25c9dffSStefan Weilsnappy=""
2876b383c08SPeter Wubzip2=""
288e8ef31a3SMichael Tokarevguest_agent=""
289d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
29050cbebb9SMichael Rothguest_agent_ntddscsi="no"
2919dacf32dSYossi Hindinguest_agent_msi=""
292d9840e25STomoki Sekiyamavss_win32_sdk=""
293d9840e25STomoki Sekiyamawin_sdk="no"
2944b1c11fdSDaniel P. Berrangewant_tools="yes"
295c589b249SRonnie Sahlberglibiscsi=""
2966542aa9cSPeter Lievenlibnfs=""
297519175a2SAlex Barcelocoroutine=""
29870c60c08SStefan Hajnoczicoroutine_pool=""
299f794573eSEduardo Otuboseccomp=""
300eb100396SBharata B Raoglusterfs=""
301d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
3020c14fb47SBharata B Raoglusterfs_discard="no"
3037c815372SBharata B Raoglusterfs_zerofill="no"
3046a460ed1SStefan Hajnocziarchipelago="no"
305a4ccabcfSAnthony Liguorigtk=""
3069e04c683SStefan Weilgtkabi=""
307925a0400SGerd Hoffmanngtk_gl="no"
308ddbb0d09SDaniel P. Berrangegnutls=""
309ddbb0d09SDaniel P. Berrangegnutls_hash=""
310b917da4cSDaniel P. Berrangegnutls_rnd=""
31191bfcdb0SDaniel P. Berrangenettle=""
312fff2f982SDaniel P. Berrangenettle_kdf="no"
31391bfcdb0SDaniel P. Berrangegcrypt=""
31437788f25SDaniel P. Berrangegcrypt_kdf="no"
315bbbf9bfbSStefan Weilvte=""
3169d9e1521SGerd Hoffmannvirglrenderer=""
317e91c793cSCole Robinsontpm="yes"
3180a12ec87SRichard W.M. Joneslibssh2=""
3194f18b782SJeff Codyvhdx=""
320a99d57bbSWanlong Gaonuma=""
3212847b469SFam Zhengtcmalloc="no"
3227b01cb97SAlexandre Derumierjemalloc="no"
323377529c0SPaolo Bonzini
324ac0df51dSaliguori# parse CC options first
325ac0df51dSaliguorifor opt do
32689138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
327ac0df51dSaliguori  case "$opt" in
328ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
329ac0df51dSaliguori  ;;
3303d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
331ac0df51dSaliguori  ;;
33283f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
33383f73fceSTomoki Sekiyama  ;;
334ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
335ca4deeb1SPaolo Bonzini  ;;
3362ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
3372ff6b91eSJuan Quintela  ;;
338de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
339f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
340e2a2ed06SJuan Quintela  ;;
341a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
342f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
343e2a2ed06SJuan Quintela  ;;
3445bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
3455bc62e01SGerd Hoffmann  ;;
3465bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
3475bc62e01SGerd Hoffmann  ;;
348ac0df51dSaliguori  esac
349ac0df51dSaliguoridone
350ac0df51dSaliguori# OS specific
351ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
35293148aa5SStefan Weil# we can eliminate its usage altogether.
353ac0df51dSaliguori
354e49d021eSPeter Maydell# Preferred compiler:
355e49d021eSPeter Maydell#  ${CC} (if set)
356e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
357e49d021eSPeter Maydell#  system compiler
358e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
359e49d021eSPeter Maydell  cc="$host_cc"
360e49d021eSPeter Maydellelse
361b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
362e49d021eSPeter Maydellfi
363e49d021eSPeter Maydell
36483f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
36583f73fceSTomoki Sekiyama  cxx="c++"
36683f73fceSTomoki Sekiyamaelse
36783f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
36883f73fceSTomoki Sekiyamafi
36983f73fceSTomoki Sekiyama
370b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
3713dd46c78SBlue Swirlas="${AS-${cross_prefix}as}"
3723dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
373b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
374b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
3754852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
376b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
377b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
37817884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
37917884d7bSSergei Trofimovichquery_pkg_config() {
38017884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
38117884d7bSSergei Trofimovich}
38217884d7bSSergei Trofimovichpkg_config=query_pkg_config
383b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
38447c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
385ac0df51dSaliguori
38645d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
38745d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
38845d285abSPeter Maydell
389be17dc90SMichael S. Tsirkin# default flags for all hosts
3904c288acbSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common $QEMU_CFLAGS"
391f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
392c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
393be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
3946b4c305cSPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
3955bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
3965bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
397be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
3985bc62e01SGerd Hoffmannfi
399be17dc90SMichael S. Tsirkin
400ca4deeb1SPaolo Bonzini# make source path absolute
40189138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
402ca4deeb1SPaolo Bonzini
403cab00a5aSMichael S. Tsirkin# running configure in the source tree?
404cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
405cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
406cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
407cab00a5aSMichael S. Tsirkinelse
408cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
409cab00a5aSMichael S. Tsirkinfi
410cab00a5aSMichael S. Tsirkin
411ac0df51dSaliguoricheck_define() {
412ac0df51dSaliguoricat > $TMPC <<EOF
413ac0df51dSaliguori#if !defined($1)
414fd786e1aSPeter Maydell#error $1 not defined
415ac0df51dSaliguori#endif
416ac0df51dSaliguoriint main(void) { return 0; }
417ac0df51dSaliguoriEOF
41852166aa0SJuan Quintela  compile_object
419ac0df51dSaliguori}
420ac0df51dSaliguori
421307119e7SGerd Hoffmanncheck_include() {
422307119e7SGerd Hoffmanncat > $TMPC <<EOF
423307119e7SGerd Hoffmann#include <$1>
424307119e7SGerd Hoffmannint main(void) { return 0; }
425307119e7SGerd HoffmannEOF
426307119e7SGerd Hoffmann  compile_object
427307119e7SGerd Hoffmann}
428307119e7SGerd Hoffmann
42993b25869SJohn Snowwrite_c_skeleton() {
43093b25869SJohn Snow    cat > $TMPC <<EOF
43193b25869SJohn Snowint main(void) { return 0; }
43293b25869SJohn SnowEOF
43393b25869SJohn Snow}
43493b25869SJohn Snow
435bbea4050SPeter Maydellif check_define __linux__ ; then
436bbea4050SPeter Maydell  targetos="Linux"
437bbea4050SPeter Maydellelif check_define _WIN32 ; then
438bbea4050SPeter Maydell  targetos='MINGW32'
439bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
440bbea4050SPeter Maydell  targetos='OpenBSD'
441bbea4050SPeter Maydellelif check_define __sun__ ; then
442bbea4050SPeter Maydell  targetos='SunOS'
443bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
444bbea4050SPeter Maydell  targetos='Haiku'
445bbea4050SPeter Maydellelse
44689138857SStefan Weil  targetos=$(uname -s)
447bbea4050SPeter Maydellfi
448bbea4050SPeter Maydell
449bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
450bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
451bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
452bbea4050SPeter Maydell# the correct CPU with the --cpu option.
453bbea4050SPeter Maydellcase $targetos in
454bbea4050SPeter MaydellDarwin)
455bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
456bbea4050SPeter Maydell  # run 64-bit userspace code.
457bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
458bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
459bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
460bbea4050SPeter Maydell    cpu="x86_64"
461bbea4050SPeter Maydell  fi
462bbea4050SPeter Maydell  ;;
463bbea4050SPeter MaydellSunOS)
46489138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
465bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
466bbea4050SPeter Maydell    cpu="x86_64"
467bbea4050SPeter Maydell  fi
468bbea4050SPeter Maydellesac
469bbea4050SPeter Maydell
4702ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
4712ff6b91eSJuan Quintela  # command line argument
4722ff6b91eSJuan Quintela  :
4732ff6b91eSJuan Quintelaelif check_define __i386__ ; then
474ac0df51dSaliguori  cpu="i386"
475ac0df51dSaliguorielif check_define __x86_64__ ; then
476c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
477c72b26ecSRichard Henderson    cpu="x32"
478c72b26ecSRichard Henderson  else
479ac0df51dSaliguori    cpu="x86_64"
480c72b26ecSRichard Henderson  fi
4813aa9bd6cSblueswir1elif check_define __sparc__ ; then
4823aa9bd6cSblueswir1  if check_define __arch64__ ; then
4833aa9bd6cSblueswir1    cpu="sparc64"
4843aa9bd6cSblueswir1  else
4853aa9bd6cSblueswir1    cpu="sparc"
4863aa9bd6cSblueswir1  fi
487fdf7ed96Smalcelif check_define _ARCH_PPC ; then
488fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
489fdf7ed96Smalc    cpu="ppc64"
490ac0df51dSaliguori  else
491fdf7ed96Smalc    cpu="ppc"
492fdf7ed96Smalc  fi
493afa05235SAurelien Jarnoelif check_define __mips__ ; then
494afa05235SAurelien Jarno  cpu="mips"
495477ba620SAurelien Jarnoelif check_define __ia64__ ; then
496477ba620SAurelien Jarno  cpu="ia64"
497d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
498d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
499d66ed0eaSAurelien Jarno    cpu="s390x"
500d66ed0eaSAurelien Jarno  else
501d66ed0eaSAurelien Jarno    cpu="s390"
502d66ed0eaSAurelien Jarno  fi
50321d89f84SPeter Maydellelif check_define __arm__ ; then
50421d89f84SPeter Maydell  cpu="arm"
5051f080313SClaudio Fontanaelif check_define __aarch64__ ; then
5061f080313SClaudio Fontana  cpu="aarch64"
507f28ffed5SBradelif check_define __hppa__ ; then
508f28ffed5SBrad  cpu="hppa"
509fdf7ed96Smalcelse
51089138857SStefan Weil  cpu=$(uname -m)
511ac0df51dSaliguorifi
512ac0df51dSaliguori
513359bc95dSPeter MaydellARCH=
514359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
515359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
5167d13299dSbellardcase "$cpu" in
517c72b26ecSRichard Henderson  ia64|ppc|ppc64|s390|s390x|sparc64|x32)
518ea8f20f8SJuan Quintela    cpu="$cpu"
519ea8f20f8SJuan Quintela  ;;
5207d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
52197a847bcSbellard    cpu="i386"
5227d13299dSbellard  ;;
523aaa5fa14Saurel32  x86_64|amd64)
524aaa5fa14Saurel32    cpu="x86_64"
525aaa5fa14Saurel32  ;;
52621d89f84SPeter Maydell  armv*b|armv*l|arm)
52721d89f84SPeter Maydell    cpu="arm"
5287d13299dSbellard  ;;
5291f080313SClaudio Fontana  aarch64)
5301f080313SClaudio Fontana    cpu="aarch64"
5311f080313SClaudio Fontana  ;;
532afa05235SAurelien Jarno  mips*)
533afa05235SAurelien Jarno    cpu="mips"
534afa05235SAurelien Jarno  ;;
5353142255cSblueswir1  sparc|sun4[cdmuv])
536ae228531Sbellard    cpu="sparc"
537ae228531Sbellard  ;;
5387d13299dSbellard  *)
539359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
540359bc95dSPeter Maydell    ARCH=unknown
5417d13299dSbellard  ;;
5427d13299dSbellardesac
543359bc95dSPeter Maydellif test -z "$ARCH"; then
544359bc95dSPeter Maydell  ARCH="$cpu"
545359bc95dSPeter Maydellfi
546e2d52ad3SJuan Quintela
5477d13299dSbellard# OS specific
5480dbfc675SJuan Quintela
549adfc3e91SStacey Son# host *BSD for user mode
550adfc3e91SStacey SonHOST_VARIANT_DIR=""
551adfc3e91SStacey Son
5527d13299dSbellardcase $targetos in
553c326e0afSbellardCYGWIN*)
554c326e0afSbellard  mingw32="yes"
555a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
5563cec7cc2SKővágó, Zoltán  audio_possible_drivers="sdl"
5573cec7cc2SKővágó, Zoltán  audio_drv_list="sdl"
558c326e0afSbellard;;
55967b915a5SbellardMINGW32*)
56067b915a5Sbellard  mingw32="yes"
5613cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
562307119e7SGerd Hoffmann  if check_include dsound.h; then
5633cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
564307119e7SGerd Hoffmann  else
565307119e7SGerd Hoffmann    audio_drv_list=""
566307119e7SGerd Hoffmann  fi
56767b915a5Sbellard;;
5685c40d2bdSthsGNU/kFreeBSD)
569a167ba50SAurelien Jarno  bsd="yes"
5700c58ac1cSmalc  audio_drv_list="oss"
5710bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
5725c40d2bdSths;;
5737d3505c5SbellardFreeBSD)
5747d3505c5Sbellard  bsd="yes"
5750db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5760c58ac1cSmalc  audio_drv_list="oss"
5770bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
578f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
579f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
58058952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
581adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
5827d3505c5Sbellard;;
583c5e97233Sblueswir1DragonFly)
584c5e97233Sblueswir1  bsd="yes"
5850db4a067SPaolo Bonzini  make="${MAKE-gmake}"
586c5e97233Sblueswir1  audio_drv_list="oss"
5870bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
588adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
589c5e97233Sblueswir1;;
5907d3505c5SbellardNetBSD)
5917d3505c5Sbellard  bsd="yes"
5920db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5930c58ac1cSmalc  audio_drv_list="oss"
5940bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
5958ef92a88Sblueswir1  oss_lib="-lossaudio"
596adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
5977d3505c5Sbellard;;
5987d3505c5SbellardOpenBSD)
5997d3505c5Sbellard  bsd="yes"
6000db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6014f6ab397SBrad Smith  audio_drv_list="sdl"
6020bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
603adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
6047d3505c5Sbellard;;
60583fb7adfSbellardDarwin)
60683fb7adfSbellard  bsd="yes"
60783fb7adfSbellard  darwin="yes"
60817969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
6091b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
610a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
6110c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
6121b0f9cc2Saliguori  fi
613fd677642Sths  cocoa="yes"
6140c58ac1cSmalc  audio_drv_list="coreaudio"
61514382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
6160c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
6177973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
618a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
619a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
620a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
621adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
62283fb7adfSbellard;;
623ec530c81SbellardSunOS)
624ec530c81Sbellard  solaris="yes"
6250db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6260db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
627fa58948dSBlue Swirl  ld="gld"
628e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
6290475a5caSths  needs_libsunmath="no"
63089138857SStefan Weil  solarisrev=$(uname -r | cut -f2 -d.)
631c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
6320475a5caSths    if test "$solarisrev" -le 9 ; then
6330475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
6340475a5caSths        needs_libsunmath="yes"
635f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
636f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
637f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
6380475a5caSths      else
63976ad07a4SPeter Maydell        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
64076ad07a4SPeter Maydell            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
64176ad07a4SPeter Maydell            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
64276ad07a4SPeter Maydell            "Studio 11 can be downloaded from www.sun.com."
6430475a5caSths      fi
6440475a5caSths    fi
64586b2bd93Sths  fi
6466b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
6470c58ac1cSmalc    audio_drv_list="oss"
6486b4d2ba1Sths  fi
649c2de5c91Smalc  audio_possible_drivers="oss sdl"
650d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
651d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
652d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
653d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
654a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
655560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
656560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
657560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
658ec530c81Sbellard;;
659b29fe3edSmalcAIX)
660b29fe3edSmalc  aix="yes"
6610db4a067SPaolo Bonzini  make="${MAKE-gmake}"
662b29fe3edSmalc;;
663179cf400SAndreas FärberHaiku)
664179cf400SAndreas Färber  haiku="yes"
665179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
666179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
667179cf400SAndreas Färber;;
668fb065187Sbellard*)
6690c58ac1cSmalc  audio_drv_list="oss"
6700bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
6715327cf48Sbellard  linux="yes"
672831b7825Sths  linux_user="yes"
673af2be207SJan Kiszka  kvm="yes"
674af2be207SJan Kiszka  vhost_net="yes"
6755e9be92dSNicholas Bellinger  vhost_scsi="yes"
676a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
677fb065187Sbellard;;
6787d13299dSbellardesac
6797d13299dSbellard
6807d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
681b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
68284778508Sblueswir1    bsd_user="yes"
6837d3505c5Sbellard  fi
68408de3949SAndreas Färberfi
6857d3505c5Sbellard
6860db4a067SPaolo Bonzini: ${make=${MAKE-make}}
6870db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
68852510f8bSStefan Weil: ${python=${PYTHON-python}}
689e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
6900db4a067SPaolo Bonzini
6913c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
6923c4a4d0dSPeter Maydellif has clang; then
6933c4a4d0dSPeter Maydell  objcc=clang
6943c4a4d0dSPeter Maydellelse
6953c4a4d0dSPeter Maydell  objcc="$cc"
6963c4a4d0dSPeter Maydellfi
6973c4a4d0dSPeter Maydell
6983457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
6993457a3f8SJuan Quintela  EXESUF=".exe"
70017969268SFam Zheng  DSOSUF=".dll"
701a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
702e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
703e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
70478e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
70578e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
706f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
70793b25869SJohn Snow  write_c_skeleton;
708f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
709f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
710f7cf5d5bSStefan Weil  fi
711c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
712683035deSPaolo Bonzini  mandir="\${prefix}"
713528ae5b8SEduardo Habkost  datadir="\${prefix}"
714850da188SEduardo Habkost  qemu_docdir="\${prefix}"
715683035deSPaolo Bonzini  bindir="\${prefix}"
716683035deSPaolo Bonzini  sysconfdir="\${prefix}"
7175a699bbbSLaszlo Ersek  local_statedir=
718683035deSPaolo Bonzini  confsuffix=""
719259434b8SMarc-André Lureau  libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 $libs_qga"
7203457a3f8SJuan Quintelafi
7213457a3f8SJuan Quintela
722487fefdbSAnthony Liguoriwerror=""
72385aa5189Sbellard
7247d13299dSbellardfor opt do
72589138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
7267d13299dSbellard  case "$opt" in
7272efc3265Sbellard  --help|-h) show_help=yes
7282efc3265Sbellard  ;;
72999123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
73099123e13SMike Frysinger  ;;
731b1a550a0Spbrook  --prefix=*) prefix="$optarg"
7327d13299dSbellard  ;;
733b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
73432ce6337Sbellard  ;;
735ca4deeb1SPaolo Bonzini  --source-path=*)
7367d13299dSbellard  ;;
737ac0df51dSaliguori  --cross-prefix=*)
7387d13299dSbellard  ;;
739ac0df51dSaliguori  --cc=*)
7407d13299dSbellard  ;;
741b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
74283469015Sbellard  ;;
74383f73fceSTomoki Sekiyama  --cxx=*)
74483f73fceSTomoki Sekiyama  ;;
745e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
746e007dbecSMichael S. Tsirkin  ;;
7473c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
7483c4a4d0dSPeter Maydell  ;;
749b1a550a0Spbrook  --make=*) make="$optarg"
7507d13299dSbellard  ;;
7516a882643Spbrook  --install=*) install="$optarg"
7526a882643Spbrook  ;;
753c886edfbSBlue Swirl  --python=*) python="$optarg"
754c886edfbSBlue Swirl  ;;
7551d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
7561d728c39SBlue Swirl  ;;
757e2d8830eSBrad  --smbd=*) smbd="$optarg"
758e2d8830eSBrad  ;;
759e2a2ed06SJuan Quintela  --extra-cflags=*)
7607d13299dSbellard  ;;
761e2a2ed06SJuan Quintela  --extra-ldflags=*)
7627d13299dSbellard  ;;
7635bc62e01SGerd Hoffmann  --enable-debug-info)
7645bc62e01SGerd Hoffmann  ;;
7655bc62e01SGerd Hoffmann  --disable-debug-info)
7665bc62e01SGerd Hoffmann  ;;
76717969268SFam Zheng  --enable-modules)
76817969268SFam Zheng      modules="yes"
76917969268SFam Zheng  ;;
7703aa88b31SStefan Hajnoczi  --disable-modules)
7713aa88b31SStefan Hajnoczi      modules="no"
7723aa88b31SStefan Hajnoczi  ;;
7732ff6b91eSJuan Quintela  --cpu=*)
7747d13299dSbellard  ;;
775b1a550a0Spbrook  --target-list=*) target_list="$optarg"
776de83cd02Sbellard  ;;
7775b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
7785b808275SLluís Vilanova  ;;
7795b808275SLluís Vilanova  # XXX: backwards compatibility
7805b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
78194a420b1SStefan Hajnoczi  ;;
78274242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
7839410b56cSPrerna Saxena  ;;
7847d13299dSbellard  --enable-gprof) gprof="yes"
7857d13299dSbellard  ;;
7861d728c39SBlue Swirl  --enable-gcov) gcov="yes"
7871d728c39SBlue Swirl  ;;
78879427693SLoïc Minier  --static)
78979427693SLoïc Minier    static="yes"
79079427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
79117884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
79243ce4dfeSbellard  ;;
7930b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
7940b24e75fSPaolo Bonzini  ;;
7950b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
7960b24e75fSPaolo Bonzini  ;;
7973aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
7983aa5d2beSAlon Levy  ;;
7998bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
8008bf188aaSMichael Tokarev  ;;
8010f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
8020f94d6daSAlon Levy  ;;
803528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
8040b24e75fSPaolo Bonzini  ;;
805023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
806023d3d67SEduardo Habkost  ;;
807850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
8080b24e75fSPaolo Bonzini  ;;
809ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
81007381cc1SAnthony Liguori  ;;
811785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
812785c23aeSLuiz Capitulino  ;;
813785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
814023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
815023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
816023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
817023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
818023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
819023ddd74SMax Filippov    # lots of directory switches by default.
820023ddd74SMax Filippov  ;;
821e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
822e2134eb9SGerd Hoffmann  ;;
823e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
824e2134eb9SGerd Hoffmann  ;;
82574880fe2SRobert Schiele  --without-pixman) pixman="none"
82674880fe2SRobert Schiele  ;;
82797a847bcSbellard  --disable-sdl) sdl="no"
82897a847bcSbellard  ;;
829c4198157SJuan Quintela  --enable-sdl) sdl="yes"
830c4198157SJuan Quintela  ;;
83147c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
83247c03744SDave Airlie  ;;
8333556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
8343556c233SPaolo Bonzini  ;;
8353556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
8363556c233SPaolo Bonzini  ;;
837983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
838983eef5aSMeador Inge  ;;
839983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
840983eef5aSMeador Inge  ;;
841821601eaSJes Sorensen  --disable-vnc) vnc="no"
842821601eaSJes Sorensen  ;;
843821601eaSJes Sorensen  --enable-vnc) vnc="yes"
844821601eaSJes Sorensen  ;;
8452f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
8462f6a1ab0Sblueswir1  ;;
8470c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
8480c58ac1cSmalc  ;;
84989138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
850b64ec4e4SFam Zheng  ;;
85189138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
852eb852011SMarkus Armbruster  ;;
853f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
854f8393946Saurel32  ;;
855f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
856f8393946Saurel32  ;;
857f3d08ee6SPaul Brook  --enable-debug)
858f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
859f3d08ee6SPaul Brook      debug_tcg="yes"
860f3d08ee6SPaul Brook      debug="yes"
861f3d08ee6SPaul Brook      strip_opt="no"
862b553a042SJohn Snow      fortify_source="no"
863f3d08ee6SPaul Brook  ;;
86403b4fe7dSaliguori  --enable-sparse) sparse="yes"
86503b4fe7dSaliguori  ;;
86603b4fe7dSaliguori  --disable-sparse) sparse="no"
86703b4fe7dSaliguori  ;;
8681625af87Saliguori  --disable-strip) strip_opt="no"
8691625af87Saliguori  ;;
8702f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
8712f9606b3Saliguori  ;;
872ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
873ea784e3bSJuan Quintela  ;;
8742f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
8752f6f5c7aSCorentin Chary  ;;
8762f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
8772f6f5c7aSCorentin Chary  ;;
878efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
879efe556adSCorentin Chary  ;;
880efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
881efe556adSCorentin Chary  ;;
882443f1376Sbellard  --disable-slirp) slirp="no"
883c20709aaSbellard  ;;
884ee682d27SStefan Weil  --disable-uuid) uuid="no"
885ee682d27SStefan Weil  ;;
886ee682d27SStefan Weil  --enable-uuid) uuid="yes"
887ee682d27SStefan Weil  ;;
888e0e6c8c0Saliguori  --disable-vde) vde="no"
8898a16d273Sths  ;;
890dfb278bdSJuan Quintela  --enable-vde) vde="yes"
891dfb278bdSJuan Quintela  ;;
89258952137SVincenzo Maffione  --disable-netmap) netmap="no"
89358952137SVincenzo Maffione  ;;
89458952137SVincenzo Maffione  --enable-netmap) netmap="yes"
89558952137SVincenzo Maffione  ;;
896e37630caSaliguori  --disable-xen) xen="no"
897e37630caSaliguori  ;;
898fc321b4bSJuan Quintela  --enable-xen) xen="yes"
899fc321b4bSJuan Quintela  ;;
900eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
901eb6fda0fSAnthony PERARD  ;;
902eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
903eb6fda0fSAnthony PERARD  ;;
90464a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
90564a7ad6fSIan Campbell  ;;
90664a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
90764a7ad6fSIan Campbell  ;;
9082e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
9092e4d9fb1Saurel32  ;;
9104ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
9114ffcedb6SJuan Quintela  ;;
912fb599c9aSbalrog  --disable-bluez) bluez="no"
913fb599c9aSbalrog  ;;
914a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
915a20a6f46SJuan Quintela  ;;
9167ba1e619Saliguori  --disable-kvm) kvm="no"
9177ba1e619Saliguori  ;;
918b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
919b31a0277SJuan Quintela  ;;
9209195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
9219195b2c2SStefan Weil  ;;
9229195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
9239195b2c2SStefan Weil  ;;
92447e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
92547e98658SCorey Bryant  ;;
92647e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
92747e98658SCorey Bryant  ;;
928cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
929cd4ec0b4SGerd Hoffmann  ;;
930cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
931cd4ec0b4SGerd Hoffmann  ;;
932c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
933c589b249SRonnie Sahlberg  ;;
934c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
935c589b249SRonnie Sahlberg  ;;
9366542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
9376542aa9cSPeter Lieven  ;;
9386542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
9396542aa9cSPeter Lieven  ;;
94005c2a3e7Sbellard  --enable-profiler) profiler="yes"
94105c2a3e7Sbellard  ;;
94214821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
94314821030SPavel Borzenkov  ;;
944c2de5c91Smalc  --enable-cocoa)
945c2de5c91Smalc      cocoa="yes" ;
94689138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
9475b0753e0Sbellard  ;;
948cad25d69Spbrook  --disable-system) softmmu="no"
9490a8e90f4Spbrook  ;;
950cad25d69Spbrook  --enable-system) softmmu="yes"
9510a8e90f4Spbrook  ;;
9520953a80fSZachary Amsden  --disable-user)
9530953a80fSZachary Amsden      linux_user="no" ;
9540953a80fSZachary Amsden      bsd_user="no" ;
9550953a80fSZachary Amsden  ;;
9560953a80fSZachary Amsden  --enable-user) ;;
957831b7825Sths  --disable-linux-user) linux_user="no"
9580a8e90f4Spbrook  ;;
959831b7825Sths  --enable-linux-user) linux_user="yes"
960831b7825Sths  ;;
96184778508Sblueswir1  --disable-bsd-user) bsd_user="no"
96284778508Sblueswir1  ;;
96384778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
96484778508Sblueswir1  ;;
96540d6444eSAvi Kivity  --enable-pie) pie="yes"
96634005a00SKirill A. Shutemov  ;;
96740d6444eSAvi Kivity  --disable-pie) pie="no"
96834005a00SKirill A. Shutemov  ;;
96985aa5189Sbellard  --enable-werror) werror="yes"
97085aa5189Sbellard  ;;
97185aa5189Sbellard  --disable-werror) werror="no"
97285aa5189Sbellard  ;;
97363678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
97463678e17SSteven Noonan  ;;
97563678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
97663678e17SSteven Noonan  ;;
9774d3b6f6eSbalrog  --disable-curses) curses="no"
9784d3b6f6eSbalrog  ;;
979c584a6d0SJuan Quintela  --enable-curses) curses="yes"
980c584a6d0SJuan Quintela  ;;
981769ce76dSAlexander Graf  --disable-curl) curl="no"
982769ce76dSAlexander Graf  ;;
983788c8196SJuan Quintela  --enable-curl) curl="yes"
984788c8196SJuan Quintela  ;;
9852df87df7SJuan Quintela  --disable-fdt) fdt="no"
9862df87df7SJuan Quintela  ;;
9872df87df7SJuan Quintela  --enable-fdt) fdt="yes"
9882df87df7SJuan Quintela  ;;
9895c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
9905c6c3a6cSChristoph Hellwig  ;;
9915c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
9925c6c3a6cSChristoph Hellwig  ;;
993758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
994758e8e38SVenkateswararao Jujjuri (JV)  ;;
995758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
996758e8e38SVenkateswararao Jujjuri (JV)  ;;
99777755340Sths  --disable-blobs) blobs="no"
99877755340Sths  ;;
9994a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
10004a19f1ecSpbrook  ;;
1001519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1002519175a2SAlex Barcelo  ;;
100370c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
100470c60c08SStefan Hajnoczi  ;;
100570c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
100670c60c08SStefan Hajnoczi  ;;
1007a25dba17SJuan Quintela  --disable-docs) docs="no"
100870ec5dc0SAnthony Liguori  ;;
1009a25dba17SJuan Quintela  --enable-docs) docs="yes"
101083a3ab8bSJuan Quintela  ;;
1011d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1012d5970055SMichael S. Tsirkin  ;;
1013d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1014d5970055SMichael S. Tsirkin  ;;
10155e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
10165e9be92dSNicholas Bellinger  ;;
10175e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
10185e9be92dSNicholas Bellinger  ;;
1019da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
102020ff075bSMichael Walle  ;;
1021da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
102220ff075bSMichael Walle  ;;
1023f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1024f27aaf4bSChristian Brunner  ;;
1025f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1026f27aaf4bSChristian Brunner  ;;
10278c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
10288c84cf11SSergei Trofimovich  ;;
10298c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
10308c84cf11SSergei Trofimovich  ;;
10317b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1032111a38b0SRobert Relyea  ;;
10337b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1034111a38b0SRobert Relyea  ;;
10352b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
10362b2325ffSGerd Hoffmann  ;;
10372b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
10382b2325ffSGerd Hoffmann  ;;
103969354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
104069354a83SHans de Goede  ;;
104169354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
104269354a83SHans de Goede  ;;
10431ece9905SAlon Levy  --disable-zlib-test) zlib="no"
10441ece9905SAlon Levy  ;;
1045b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1046b25c9dffSStefan Weil  ;;
1047607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1048607dacd0Sqiaonuohan  ;;
1049b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1050b25c9dffSStefan Weil  ;;
1051607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1052607dacd0Sqiaonuohan  ;;
10536b383c08SPeter Wu  --disable-bzip2) bzip2="no"
10546b383c08SPeter Wu  ;;
10556b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
10566b383c08SPeter Wu  ;;
1057d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1058d138cee9SMichael Roth  ;;
1059d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1060d138cee9SMichael Roth  ;;
10619dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
10629dacf32dSYossi Hindin  ;;
10639dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
10649dacf32dSYossi Hindin  ;;
1065d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1066d9840e25STomoki Sekiyama  ;;
1067d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1068d9840e25STomoki Sekiyama  ;;
1069d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1070d9840e25STomoki Sekiyama  ;;
1071d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1072d9840e25STomoki Sekiyama  ;;
1073d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1074d9840e25STomoki Sekiyama  ;;
1075d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1076d9840e25STomoki Sekiyama  ;;
10774b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
10784b1c11fdSDaniel P. Berrange  ;;
10794b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
10804b1c11fdSDaniel P. Berrange  ;;
1081f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1082f794573eSEduardo Otubo  ;;
1083f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1084f794573eSEduardo Otubo  ;;
1085eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1086eb100396SBharata B Rao  ;;
1087eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1088eb100396SBharata B Rao  ;;
1089c9a12e75SChrysostomos Nanakos  --disable-archipelago) archipelago="no"
1090c9a12e75SChrysostomos Nanakos  ;;
1091c9a12e75SChrysostomos Nanakos  --enable-archipelago) archipelago="yes"
1092c9a12e75SChrysostomos Nanakos  ;;
109352b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
109452b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1095583f6e7bSStefan Hajnoczi  ;;
1096a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1097a4ccabcfSAnthony Liguori  ;;
1098a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1099a4ccabcfSAnthony Liguori  ;;
1100ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1101ddbb0d09SDaniel P. Berrange  ;;
1102ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1103ddbb0d09SDaniel P. Berrange  ;;
110491bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
110591bfcdb0SDaniel P. Berrange  ;;
110691bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
110791bfcdb0SDaniel P. Berrange  ;;
110891bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
110991bfcdb0SDaniel P. Berrange  ;;
111091bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
111191bfcdb0SDaniel P. Berrange  ;;
11122da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
11132da776dbSMichael R. Hines  ;;
11142da776dbSMichael R. Hines  --disable-rdma) rdma="no"
11152da776dbSMichael R. Hines  ;;
1116528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1117528de90aSDaniel P. Berrange  ;;
1118bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1119bbbf9bfbSStefan Weil  ;;
1120bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1121bbbf9bfbSStefan Weil  ;;
11229d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
11239d9e1521SGerd Hoffmann  ;;
11249d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
11259d9e1521SGerd Hoffmann  ;;
1126e91c793cSCole Robinson  --disable-tpm) tpm="no"
1127e91c793cSCole Robinson  ;;
1128ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1129ab214c29SStefan Berger  ;;
11300a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
11310a12ec87SRichard W.M. Jones  ;;
11320a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
11330a12ec87SRichard W.M. Jones  ;;
11344f18b782SJeff Cody  --enable-vhdx) vhdx="yes"
11354f18b782SJeff Cody  ;;
11364f18b782SJeff Cody  --disable-vhdx) vhdx="no"
11374f18b782SJeff Cody  ;;
1138a99d57bbSWanlong Gao  --disable-numa) numa="no"
1139a99d57bbSWanlong Gao  ;;
1140a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1141a99d57bbSWanlong Gao  ;;
11422847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
11432847b469SFam Zheng  ;;
11442847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
11452847b469SFam Zheng  ;;
11467b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
11477b01cb97SAlexandre Derumier  ;;
11487b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
11497b01cb97SAlexandre Derumier  ;;
11502d2ad6d0SFam Zheng  *)
11512d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
11522d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
11532d2ad6d0SFam Zheng      exit 1
11547f1559c6Sbalrog  ;;
11557d13299dSbellard  esac
11567d13299dSbellarddone
11577d13299dSbellard
1158f6f0b7d9SStefan Weilif ! has $python; then
1159f6f0b7d9SStefan Weil  error_exit "Python not found. Use --python=/path/to/python"
1160f6f0b7d9SStefan Weilfi
1161f6f0b7d9SStefan Weil
1162f6f0b7d9SStefan Weil# Note that if the Python conditional here evaluates True we will exit
1163f6f0b7d9SStefan Weil# with status 1 which is a shell 'false' value.
1164fec21036SMarkus Armbrusterif ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1165fec21036SMarkus Armbruster  error_exit "Cannot use '$python', Python 2.6 or later is required." \
1166f6f0b7d9SStefan Weil      "Note that Python 3 or later is not yet supported." \
1167f6f0b7d9SStefan Weil      "Use --python=/path/to/python to specify a supported Python."
1168f6f0b7d9SStefan Weilfi
1169f6f0b7d9SStefan Weil
1170fec21036SMarkus Armbruster# Suppress writing compiled files
1171f6f0b7d9SStefan Weilpython="$python -B"
1172f6f0b7d9SStefan Weil
117340293e58Sbellardcase "$cpu" in
1174e3608d66SRichard Henderson    ppc)
1175e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1176e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1177e3608d66SRichard Henderson           ;;
1178e3608d66SRichard Henderson    ppc64)
1179e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1180e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1181e3608d66SRichard Henderson           ;;
11829b9c37c3SRichard Henderson    sparc)
11830c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
118479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32 -mcpu=ultrasparc"
11853142255cSblueswir1           ;;
1186ed968ff1SJuan Quintela    sparc64)
11870c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
118879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
11893142255cSblueswir1           ;;
119076d83bdeSths    s390)
1191061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
119228d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
119328d7cc49SRichard Henderson           ;;
119428d7cc49SRichard Henderson    s390x)
1195061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
119628d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
119776d83bdeSths           ;;
119840293e58Sbellard    i386)
119979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
12000c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
12012b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
120240293e58Sbellard           ;;
120340293e58Sbellard    x86_64)
120479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64"
12050c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
12062b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1207379f6698SPaul Brook           ;;
1208c72b26ecSRichard Henderson    x32)
1209c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1210c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1211c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1212c72b26ecSRichard Henderson           ;;
121330163d89SPeter Maydell    # No special flags required for other host CPUs
12143142255cSblueswir1esac
12153142255cSblueswir1
121679f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
121779f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
121879f3b12fSPeter Crosthwaite
121960e0df25SPeter Maydelldefault_target_list=""
122060e0df25SPeter Maydell
12216e92f823SPeter Maydellmak_wilds=""
12226e92f823SPeter Maydell
122360e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
12246e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
122560e0df25SPeter Maydellfi
122660e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
12276e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
122860e0df25SPeter Maydellfi
122960e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
12306e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
123160e0df25SPeter Maydellfi
123260e0df25SPeter Maydell
12336e92f823SPeter Maydellfor config in $mak_wilds; do
12346e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
12356e92f823SPeter Maydelldone
12366e92f823SPeter Maydell
1237af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1238af5db58eSpbrookcat << EOF
1239af5db58eSpbrook
1240af5db58eSpbrookUsage: configure [options]
1241af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1242af5db58eSpbrook
124308fb77edSStefan WeilStandard options:
124408fb77edSStefan Weil  --help                   print this message
124508fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
124608fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
124708fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
124808fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
124908fb77edSStefan Weil$(echo Available targets: $default_target_list | \
125008fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
125108fb77edSStefan Weil
125208fb77edSStefan WeilAdvanced options (experts only):
125308fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
125408fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
125508fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
125608fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
125708fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
125808fb77edSStefan Weil                           build time
125908fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
126008fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
126108fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
126208fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
126308fb77edSStefan Weil  --make=MAKE              use specified make [$make]
126408fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
126508fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
126608fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
126708fb77edSStefan Weil  --static                 enable static build [$static]
126808fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
126908fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
127008fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
127108fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
127208fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
127308fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
127408fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
1275e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
127608fb77edSStefan Weil  --enable-debug           enable common debug build options
127708fb77edSStefan Weil  --disable-strip          disable stripping binaries
127808fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
127963678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
128008fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
128108fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
128208fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
128308fb77edSStefan Weil  --block-drv-rw-whitelist=L
128408fb77edSStefan Weil                           set block driver read-write whitelist
128508fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
128608fb77edSStefan Weil  --block-drv-ro-whitelist=L
128708fb77edSStefan Weil                           set block driver read-only whitelist
128808fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
12895b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
129008fb77edSStefan Weil                           Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
129108fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
129208fb77edSStefan Weil                           Default:trace-<pid>
1293c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1294c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1295c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1296c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
129708fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
129808fb77edSStefan Weil                           gthread, ucontext, sigaltstack, windows
129908fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
130008fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1301c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1302c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1303c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1304c23f23b9SMichael Tokarev
1305c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1306c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1307c23f23b9SMichael Tokarev
1308c23f23b9SMichael Tokarev  system          all system emulation targets
1309c23f23b9SMichael Tokarev  user            supported user emulation targets
1310c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1311c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1312c23f23b9SMichael Tokarev  docs            build documentation
1313c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1314c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1315c23f23b9SMichael Tokarev  pie             Position Independent Executables
1316c23f23b9SMichael Tokarev  modules         modules support
1317c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1318c23f23b9SMichael Tokarev  debug-info      debugging information
1319c23f23b9SMichael Tokarev  sparse          sparse checker
1320c23f23b9SMichael Tokarev
1321ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
132291bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
132391bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1324c23f23b9SMichael Tokarev  sdl             SDL UI
1325c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1326c23f23b9SMichael Tokarev  gtk             gtk UI
1327c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1328c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1329c23f23b9SMichael Tokarev  curses          curses UI
1330c23f23b9SMichael Tokarev  vnc             VNC UI support
1331c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1332c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1333c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1334c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1335c23f23b9SMichael Tokarev  virtfs          VirtFS
1336c23f23b9SMichael Tokarev  xen             xen backend driver support
1337c23f23b9SMichael Tokarev  xen-pci-passthrough
1338c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1339c23f23b9SMichael Tokarev  curl            curl connectivity
1340c23f23b9SMichael Tokarev  fdt             fdt device tree
1341c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1342c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1343c23f23b9SMichael Tokarev  rdma            RDMA-based migration support
1344c23f23b9SMichael Tokarev  uuid            uuid support
1345c23f23b9SMichael Tokarev  vde             support for vde network
1346c23f23b9SMichael Tokarev  netmap          support for netmap network
1347c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1348c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1349c23f23b9SMichael Tokarev  attr            attr and xattr support
1350c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1351c23f23b9SMichael Tokarev  spice           spice
1352c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1353c23f23b9SMichael Tokarev  libiscsi        iscsi support
1354c23f23b9SMichael Tokarev  libnfs          nfs support
13557b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1356c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1357c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1358c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1359c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1360c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1361c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1362c23f23b9SMichael Tokarev  seccomp         seccomp support
1363c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1364c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1365c23f23b9SMichael Tokarev  archipelago     Archipelago backend
1366c23f23b9SMichael Tokarev  tpm             TPM support
1367c23f23b9SMichael Tokarev  libssh2         ssh block device support
1368c23f23b9SMichael Tokarev  vhdx            support for the Microsoft VHDX image format
1369c23f23b9SMichael Tokarev  numa            libnuma support
1370c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
13717b01cb97SAlexandre Derumier  jemalloc        jemalloc support
137208fb77edSStefan Weil
137308fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1374af5db58eSpbrookEOF
13752d2ad6d0SFam Zhengexit 0
1376af5db58eSpbrookfi
1377af5db58eSpbrook
1378359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1379359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1380359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1381359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1382359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1383359bc95dSPeter Maydell        ARCH=tci
1384359bc95dSPeter Maydell    else
138576ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1386359bc95dSPeter Maydell    fi
1387359bc95dSPeter Maydellfi
1388359bc95dSPeter Maydell
13899c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
13909c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
13919c83ffd8SPeter Maydellif test -z "$werror" ; then
13929c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1393*e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
13949c83ffd8SPeter Maydell        werror="yes"
13959c83ffd8SPeter Maydell    else
13969c83ffd8SPeter Maydell        werror="no"
13979c83ffd8SPeter Maydell    fi
13989c83ffd8SPeter Maydellfi
13999c83ffd8SPeter Maydell
14008d05095cSPaolo Bonzini# check that the C compiler works.
140193b25869SJohn Snowwrite_c_skeleton;
14028d05095cSPaolo Bonziniif compile_object ; then
14038d05095cSPaolo Bonzini  : C compiler works ok
14048d05095cSPaolo Bonzinielse
140576ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
14068d05095cSPaolo Bonzinifi
14070ef74c74SPeter Maydellif ! compile_prog ; then
14080ef74c74SPeter Maydell    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
14090ef74c74SPeter Maydellfi
14108d05095cSPaolo Bonzini
141198b21dcdSPeter Maydell# Check that the C++ compiler exists and works with the C compiler
141298b21dcdSPeter Maydellif has $cxx; then
141398b21dcdSPeter Maydell    cat > $TMPC <<EOF
141498b21dcdSPeter Maydellint c_function(void);
141598b21dcdSPeter Maydellint main(void) { return c_function(); }
141698b21dcdSPeter MaydellEOF
141798b21dcdSPeter Maydell
141898b21dcdSPeter Maydell    compile_object
141998b21dcdSPeter Maydell
14209c83ffd8SPeter Maydell    cat > $TMPCXX <<EOF
142198b21dcdSPeter Maydellextern "C" {
142298b21dcdSPeter Maydell   int c_function(void);
142398b21dcdSPeter Maydell}
142498b21dcdSPeter Maydellint c_function(void) { return 42; }
142598b21dcdSPeter MaydellEOF
142698b21dcdSPeter Maydell
14279c83ffd8SPeter Maydell    update_cxxflags
14289c83ffd8SPeter Maydell
14299c83ffd8SPeter Maydell    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
143098b21dcdSPeter Maydell        # C++ compiler $cxx works ok with C compiler $cc
143198b21dcdSPeter Maydell        :
143298b21dcdSPeter Maydell    else
143398b21dcdSPeter Maydell        echo "C++ compiler $cxx does not work with C compiler $cc"
143498b21dcdSPeter Maydell        echo "Disabling C++ specific optional code"
143598b21dcdSPeter Maydell        cxx=
143698b21dcdSPeter Maydell    fi
143798b21dcdSPeter Maydellelse
143898b21dcdSPeter Maydell    echo "No C++ compiler available; disabling C++ specific optional code"
143998b21dcdSPeter Maydell    cxx=
144098b21dcdSPeter Maydellfi
144198b21dcdSPeter Maydell
14428d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
14438d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
14448d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
144537746c5eSMarc-André Lureaugcc_flags="-Wendif-labels $gcc_flags"
1446c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
144771429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
14486ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
14496ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
14506ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
14516ca026cbSPeter Maydell# so it's too error prone.
145293b25869SJohn Snow
145393b25869SJohn Snowcc_has_warning_flag() {
145493b25869SJohn Snow    write_c_skeleton;
145593b25869SJohn Snow
1456a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1457a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1458a1d29d6cSPeter Maydell    # warning options).
145993b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
146093b25869SJohn Snow    compile_prog "-Werror $optflag" ""
146193b25869SJohn Snow}
146293b25869SJohn Snow
146393b25869SJohn Snowfor flag in $gcc_flags; do
146493b25869SJohn Snow    if cc_has_warning_flag $flag ; then
14658d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
14668d05095cSPaolo Bonzini    fi
14678d05095cSPaolo Bonzinidone
14688d05095cSPaolo Bonzini
146963678e17SSteven Noonanif test "$stack_protector" != "no"; then
1470fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1471fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1472fccd35a0SRodrigo Rebello{
1473fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1474fccd35a0SRodrigo Rebello    while (*c) {
1475fccd35a0SRodrigo Rebello        *p++ = *c++;
1476fccd35a0SRodrigo Rebello    }
1477fccd35a0SRodrigo Rebello    return 0;
1478fccd35a0SRodrigo Rebello}
1479fccd35a0SRodrigo RebelloEOF
148063678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
14813b463a3fSMiroslav Rezanina  sp_on=0
148263678e17SSteven Noonan  for flag in $gcc_flags; do
1483590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1484590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1485590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1486590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
148763678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
14883b463a3fSMiroslav Rezanina      sp_on=1
148963678e17SSteven Noonan      break
149063678e17SSteven Noonan    fi
149163678e17SSteven Noonan  done
14923b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
14933b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
14943b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
14953b463a3fSMiroslav Rezanina    fi
14963b463a3fSMiroslav Rezanina  fi
149737746c5eSMarc-André Lureaufi
149837746c5eSMarc-André Lureau
1499cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1500cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1501cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1502cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1503cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1504cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1505cbdd1999SPaolo Bonziniint main(void) { return 0; }
1506cbdd1999SPaolo Bonzini#else
1507cbdd1999SPaolo Bonzini#error No bug in this compiler.
1508cbdd1999SPaolo Bonzini#endif
1509cbdd1999SPaolo BonziniEOF
1510cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1511cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1512cbdd1999SPaolo Bonzinifi
1513cbdd1999SPaolo Bonzini
151440d6444eSAvi Kivityif test "$static" = "yes" ; then
1515aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1516aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1517aa0d1f44SPaolo Bonzini  fi
151840d6444eSAvi Kivity  if test "$pie" = "yes" ; then
151976ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
152040d6444eSAvi Kivity  else
152140d6444eSAvi Kivity    pie="no"
152240d6444eSAvi Kivity  fi
152340d6444eSAvi Kivityfi
152440d6444eSAvi Kivity
1525768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1526768b7855SEmilio G. Cota  cat > $TMPC << EOF
1527768b7855SEmilio G. Cotastatic __thread int tls_var;
1528768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1529768b7855SEmilio G. CotaEOF
1530768b7855SEmilio G. Cota
1531768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1532768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1533768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1534768b7855SEmilio G. Cotafi
1535768b7855SEmilio G. Cota
153640d6444eSAvi Kivityif test "$pie" = ""; then
153740d6444eSAvi Kivity  case "$cpu-$targetos" in
1538c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
153940d6444eSAvi Kivity      ;;
154040d6444eSAvi Kivity    *)
154140d6444eSAvi Kivity      pie="no"
154240d6444eSAvi Kivity      ;;
154340d6444eSAvi Kivity  esac
154440d6444eSAvi Kivityfi
154540d6444eSAvi Kivity
154640d6444eSAvi Kivityif test "$pie" != "no" ; then
154740d6444eSAvi Kivity  cat > $TMPC << EOF
154821d4a791SAvi Kivity
154921d4a791SAvi Kivity#ifdef __linux__
155021d4a791SAvi Kivity#  define THREAD __thread
155121d4a791SAvi Kivity#else
155221d4a791SAvi Kivity#  define THREAD
155321d4a791SAvi Kivity#endif
155421d4a791SAvi Kivity
155521d4a791SAvi Kivitystatic THREAD int tls_var;
155621d4a791SAvi Kivity
155721d4a791SAvi Kivityint main(void) { return tls_var; }
155821d4a791SAvi Kivity
155940d6444eSAvi KivityEOF
156040d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
156140d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
156240d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
156340d6444eSAvi Kivity    pie="yes"
156440d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
156540d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
156640d6444eSAvi Kivity    fi
156740d6444eSAvi Kivity  else
156840d6444eSAvi Kivity    if test "$pie" = "yes"; then
156976ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
157040d6444eSAvi Kivity    else
157140d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
157240d6444eSAvi Kivity      pie="no"
157340d6444eSAvi Kivity    fi
157440d6444eSAvi Kivity  fi
157546eef33bSBrad
1576e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
157746eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
157846eef33bSBrad    LDFLAGS_NOPIE="-nopie"
157946eef33bSBrad  fi
158040d6444eSAvi Kivityfi
158140d6444eSAvi Kivity
158209dada40SPaolo Bonzini##########################################
158309dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
158409dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
158509dada40SPaolo Bonzini# specification is necessary
158609dada40SPaolo Bonzini
158709dada40SPaolo Bonziniif test "$cpu" = "i386"; then
158809dada40SPaolo Bonzini  cat > $TMPC << EOF
158909dada40SPaolo Bonzinistatic int sfaa(int *ptr)
159009dada40SPaolo Bonzini{
159109dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
159209dada40SPaolo Bonzini}
159309dada40SPaolo Bonzini
159409dada40SPaolo Bonziniint main(void)
159509dada40SPaolo Bonzini{
159609dada40SPaolo Bonzini  int val = 42;
15971405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
159809dada40SPaolo Bonzini  sfaa(&val);
159909dada40SPaolo Bonzini  return val;
160009dada40SPaolo Bonzini}
160109dada40SPaolo BonziniEOF
160209dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
160309dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
160409dada40SPaolo Bonzini  fi
160509dada40SPaolo Bonzinifi
160609dada40SPaolo Bonzini
160709dada40SPaolo Bonzini#########################################
1608ec530c81Sbellard# Solaris specific configure tool chain decisions
160909dada40SPaolo Bonzini
1610ec530c81Sbellardif test "$solaris" = "yes" ; then
16116792aa11SLoïc Minier  if has $install; then
16126792aa11SLoïc Minier    :
16136792aa11SLoïc Minier  else
161476ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
161576ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
161676ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1617ec530c81Sbellard  fi
161889138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
161976ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
162076ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
162176ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1622ec530c81Sbellard  fi
16236792aa11SLoïc Minier  if has ar; then
16246792aa11SLoïc Minier    :
16256792aa11SLoïc Minier  else
1626ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
162776ad07a4SPeter Maydell      error_exit "No path includes ar" \
162876ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1629ec530c81Sbellard    fi
163076ad07a4SPeter Maydell    error_exit "No path includes ar"
1631ec530c81Sbellard  fi
1632ec530c81Sbellardfi
1633ec530c81Sbellard
1634afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1635121afa9eSAnthony Liguori    target_list="$default_target_list"
1636121afa9eSAnthony Liguorielse
163789138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
16385327cf48Sbellardfi
163925b48338SPeter Maydell
164025b48338SPeter Maydell# Check that we recognised the target name; this allows a more
164125b48338SPeter Maydell# friendly error message than if we let it fall through.
164225b48338SPeter Maydellfor target in $target_list; do
164325b48338SPeter Maydell    case " $default_target_list " in
164425b48338SPeter Maydell        *" $target "*)
164525b48338SPeter Maydell            ;;
164625b48338SPeter Maydell        *)
164725b48338SPeter Maydell            error_exit "Unknown target name '$target'"
164825b48338SPeter Maydell            ;;
164925b48338SPeter Maydell    esac
165025b48338SPeter Maydelldone
165125b48338SPeter Maydell
1652f55fe278SPaolo Bonzini# see if system emulation was really requested
1653f55fe278SPaolo Bonzinicase " $target_list " in
1654f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1655f55fe278SPaolo Bonzini  ;;
1656f55fe278SPaolo Bonzini  *) softmmu=no
1657f55fe278SPaolo Bonzini  ;;
1658f55fe278SPaolo Bonziniesac
16595327cf48Sbellard
1660249247c9SJuan Quintelafeature_not_found() {
1661249247c9SJuan Quintela  feature=$1
166221684af0SStewart Smith  remedy=$2
1663249247c9SJuan Quintela
166476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
166521684af0SStewart Smith      "configure was not able to find it." \
166621684af0SStewart Smith      "$remedy"
1667249247c9SJuan Quintela}
1668249247c9SJuan Quintela
16697d13299dSbellard# ---
16707d13299dSbellard# big/little endian test
16717d13299dSbellardcat > $TMPC << EOF
167261cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
167361cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
167461cc919fSMike Frysingerextern int foo(short *, short *);
167561cc919fSMike Frysingerint main(int argc, char *argv[]) {
167661cc919fSMike Frysinger    return foo(big_endian, little_endian);
16777d13299dSbellard}
16787d13299dSbellardEOF
16797d13299dSbellard
168061cc919fSMike Frysingerif compile_object ; then
168161cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
168261cc919fSMike Frysinger        bigendian="yes"
168361cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
168461cc919fSMike Frysinger        bigendian="no"
16857d13299dSbellard    else
16867d13299dSbellard        echo big/little test failed
16877d13299dSbellard    fi
16887d13299dSbellardelse
168961cc919fSMike Frysinger    echo big/little test failed
16907d13299dSbellardfi
16917d13299dSbellard
1692b0a47e79SJuan Quintela##########################################
1693a30878e7SPeter Maydell# cocoa implies not SDL or GTK
1694a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
1695a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
1696a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
1697a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
1698a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1699a30878e7SPeter Maydell    fi
1700a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
1701a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1702a30878e7SPeter Maydell    fi
1703a30878e7SPeter Maydell    gtk=no
1704a30878e7SPeter Maydell    sdl=no
1705a30878e7SPeter Maydellfi
1706a30878e7SPeter Maydell
1707a30878e7SPeter Maydell##########################################
1708015a33bdSGonglei# L2TPV3 probe
1709015a33bdSGonglei
1710015a33bdSGongleicat > $TMPC <<EOF
1711015a33bdSGonglei#include <sys/socket.h>
1712bff6cb72SMichael Tokarev#include <linux/ip.h>
1713015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
1714015a33bdSGongleiEOF
1715015a33bdSGongleiif compile_prog "" "" ; then
1716015a33bdSGonglei  l2tpv3=yes
1717015a33bdSGongleielse
1718015a33bdSGonglei  l2tpv3=no
1719015a33bdSGongleifi
1720015a33bdSGonglei
1721015a33bdSGonglei##########################################
17224d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
17234d9310f4SDaniel P. Berrange
17244d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
17254d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
17264d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
17274d9310f4SDaniel P. Berrange    #
17284d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
17294d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
17304d9310f4SDaniel P. Berrange    #
17314d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
17324d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
17334d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
17344d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
17354d9310f4SDaniel P. Berrange    # that for you.
17364d9310f4SDaniel P. Berrange    #
17374d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
17384d9310f4SDaniel P. Berrange    # are not in fact redundant.
17394d9310f4SDaniel P. Berrangecat > $TMPC << EOF
17404d9310f4SDaniel P. Berrange#include <unistd.h>
17414d9310f4SDaniel P. Berrange#include <time.h>
17424d9310f4SDaniel P. Berrange#undef localtime_r
17434d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
17444d9310f4SDaniel P. BerrangeEOF
17454d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
17464d9310f4SDaniel P. Berrange        localtime_r="yes"
17474d9310f4SDaniel P. Berrange    else
17484d9310f4SDaniel P. Berrange        localtime_r="no"
17494d9310f4SDaniel P. Berrange    fi
17504d9310f4SDaniel P. Berrangefi
17514d9310f4SDaniel P. Berrange
17524d9310f4SDaniel P. Berrange##########################################
1753779ab5e3SStefan Weil# pkg-config probe
1754779ab5e3SStefan Weil
1755779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
175676ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1757779ab5e3SStefan Weilfi
1758779ab5e3SStefan Weil
1759779ab5e3SStefan Weil##########################################
1760b0a47e79SJuan Quintela# NPTL probe
1761b0a47e79SJuan Quintela
176224cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1763bd0c5661Spbrook  cat > $TMPC <<EOF
1764bd0c5661Spbrook#include <sched.h>
176530813ceaSpbrook#include <linux/futex.h>
1766182eacc0SStefan Weilint main(void) {
1767bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1768bd0c5661Spbrook#error bork
1769bd0c5661Spbrook#endif
1770182eacc0SStefan Weil  return 0;
1771bd0c5661Spbrook}
1772bd0c5661SpbrookEOF
177324cb36a6SPeter Maydell  if ! compile_object ; then
177421684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
1775b0a47e79SJuan Quintela  fi
1776bd0c5661Spbrookfi
1777bd0c5661Spbrook
177811d9f695Sbellard##########################################
177999f2dbd3SLiang Li# avx2 optimization requirement check
178099f2dbd3SLiang Li
178199f2dbd3SLiang Licat > $TMPC << EOF
178299f2dbd3SLiang Listatic void bar(void) {}
178399f2dbd3SLiang Listatic void *bar_ifunc(void) {return (void*) bar;}
178499f2dbd3SLiang Listatic void foo(void) __attribute__((ifunc("bar_ifunc")));
178599f2dbd3SLiang Liint main(void) { foo(); return 0; }
178699f2dbd3SLiang LiEOF
178799f2dbd3SLiang Liif compile_prog "-mavx2" "" ; then
178899f2dbd3SLiang Li    if readelf --syms $TMPE |grep "IFUNC.*foo" >/dev/null 2>&1; then
178999f2dbd3SLiang Li        avx2_opt="yes"
179099f2dbd3SLiang Li    fi
179199f2dbd3SLiang Lifi
179299f2dbd3SLiang Li
179399f2dbd3SLiang Li#########################################
1794ac62922eSbalrog# zlib check
1795ac62922eSbalrog
17961ece9905SAlon Levyif test "$zlib" != "no" ; then
1797ac62922eSbalrog    cat > $TMPC << EOF
1798ac62922eSbalrog#include <zlib.h>
1799ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1800ac62922eSbalrogEOF
180152166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1802ac62922eSbalrog        :
1803ac62922eSbalrog    else
180476ad07a4SPeter Maydell        error_exit "zlib check failed" \
180576ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1806ac62922eSbalrog    fi
18071ece9905SAlon Levyfi
1808eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
1809ac62922eSbalrog
1810ac62922eSbalrog##########################################
1811607dacd0Sqiaonuohan# lzo check
1812607dacd0Sqiaonuohan
1813607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
1814607dacd0Sqiaonuohan    cat > $TMPC << EOF
1815607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
1816607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
1817607dacd0SqiaonuohanEOF
1818607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
1819607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
1820b25c9dffSStefan Weil        lzo="yes"
1821b25c9dffSStefan Weil    else
1822b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
1823b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
1824b25c9dffSStefan Weil        fi
1825b25c9dffSStefan Weil        lzo="no"
1826b25c9dffSStefan Weil    fi
1827607dacd0Sqiaonuohanfi
1828607dacd0Sqiaonuohan
1829607dacd0Sqiaonuohan##########################################
1830607dacd0Sqiaonuohan# snappy check
1831607dacd0Sqiaonuohan
1832607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
1833607dacd0Sqiaonuohan    cat > $TMPC << EOF
1834607dacd0Sqiaonuohan#include <snappy-c.h>
1835607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
1836607dacd0SqiaonuohanEOF
1837607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
1838607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
1839b25c9dffSStefan Weil        snappy="yes"
1840b25c9dffSStefan Weil    else
1841b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
1842b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
1843b25c9dffSStefan Weil        fi
1844b25c9dffSStefan Weil        snappy="no"
1845b25c9dffSStefan Weil    fi
1846607dacd0Sqiaonuohanfi
1847607dacd0Sqiaonuohan
1848607dacd0Sqiaonuohan##########################################
18496b383c08SPeter Wu# bzip2 check
18506b383c08SPeter Wu
18516b383c08SPeter Wuif test "$bzip2" != "no" ; then
18526b383c08SPeter Wu    cat > $TMPC << EOF
18536b383c08SPeter Wu#include <bzlib.h>
18546b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
18556b383c08SPeter WuEOF
18566b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
18576b383c08SPeter Wu        bzip2="yes"
18586b383c08SPeter Wu    else
18596b383c08SPeter Wu        if test "$bzip2" = "yes"; then
18606b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
18616b383c08SPeter Wu        fi
18626b383c08SPeter Wu        bzip2="no"
18636b383c08SPeter Wu    fi
18646b383c08SPeter Wufi
18656b383c08SPeter Wu
18666b383c08SPeter Wu##########################################
1867f794573eSEduardo Otubo# libseccomp check
1868f794573eSEduardo Otubo
1869f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
1870693e5910SAndrew Jones    case "$cpu" in
1871693e5910SAndrew Jones    i386|x86_64)
1872ba060c53Sdann frazier        libseccomp_minver="2.1.0"
1873693e5910SAndrew Jones        ;;
18745ce43972SJames Hogan    mips)
18755ce43972SJames Hogan        libseccomp_minver="2.2.0"
18765ce43972SJames Hogan        ;;
1877693e5910SAndrew Jones    arm|aarch64)
1878693e5910SAndrew Jones        libseccomp_minver="2.2.3"
1879693e5910SAndrew Jones        ;;
1880693e5910SAndrew Jones    *)
1881693e5910SAndrew Jones        libseccomp_minver=""
1882693e5910SAndrew Jones        ;;
1883693e5910SAndrew Jones    esac
1884693e5910SAndrew Jones
1885693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
1886693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
188789138857SStefan Weil        libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
188889138857SStefan Weil        QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
1889f794573eSEduardo Otubo        seccomp="yes"
1890f794573eSEduardo Otubo    else
1891f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
1892693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
1893693e5910SAndrew Jones                feature_not_found "libseccomp" \
1894693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
1895693e5910SAndrew Jones            else
1896693e5910SAndrew Jones                feature_not_found "libseccomp" \
1897693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
1898693e5910SAndrew Jones            fi
1899896848f0SEduardo Otubo        fi
1900e84d5956SYann E. MORIN        seccomp="no"
1901f794573eSEduardo Otubo    fi
1902f794573eSEduardo Otubofi
1903f794573eSEduardo Otubo##########################################
1904e37630caSaliguori# xen probe
1905e37630caSaliguori
1906fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1907b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
19085eeb39c2SIan Campbell  xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1909d5b93ddfSAnthony PERARD
191050ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
191150ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
191250ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
191350ced5b3SStefan Weil
191450ced5b3SStefan Weil  # Xen (any)
191550ced5b3SStefan Weil  cat > $TMPC <<EOF
191650ced5b3SStefan Weil#include <xenctrl.h>
191750ced5b3SStefan Weilint main(void) {
191850ced5b3SStefan Weil  return 0;
191950ced5b3SStefan Weil}
192050ced5b3SStefan WeilEOF
192150ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
192250ced5b3SStefan Weil    # Xen not found
192350ced5b3SStefan Weil    if test "$xen" = "yes" ; then
192421684af0SStewart Smith      feature_not_found "xen" "Install xen devel"
192550ced5b3SStefan Weil    fi
192650ced5b3SStefan Weil    xen=no
192750ced5b3SStefan Weil
1928d5b93ddfSAnthony PERARD  # Xen unstable
192969deef08SPeter Maydell  elif
193069deef08SPeter Maydell      cat > $TMPC <<EOF &&
19315eeb39c2SIan Campbell/*
19325eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
19335eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
19345eeb39c2SIan Campbell */
19355eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
19365eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
19375eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
19385eeb39c2SIan Campbell#include <xenctrl.h>
19395eeb39c2SIan Campbell#include <xenstore.h>
19405eeb39c2SIan Campbell#include <xenevtchn.h>
19415eeb39c2SIan Campbell#include <xengnttab.h>
19425eeb39c2SIan Campbell#include <xenforeignmemory.h>
19435eeb39c2SIan Campbell#include <stdint.h>
19445eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
19455eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
19465eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
19475eeb39c2SIan Campbell#endif
19485eeb39c2SIan Campbellint main(void) {
19495eeb39c2SIan Campbell  xc_interface *xc = NULL;
19505eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
19515eeb39c2SIan Campbell  xenevtchn_handle *xe;
19525eeb39c2SIan Campbell  xengnttab_handle *xg;
19535eeb39c2SIan Campbell  xen_domain_handle_t handle;
19545eeb39c2SIan Campbell
19555eeb39c2SIan Campbell  xs_daemon_open();
19565eeb39c2SIan Campbell
19575eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
19585eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
19595eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
19605eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
19615eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
19625eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
19635eeb39c2SIan Campbell
19645eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
19655eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
19665eeb39c2SIan Campbell
19675eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
19685eeb39c2SIan Campbell  xenevtchn_fd(xe);
19695eeb39c2SIan Campbell
19705eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
19715eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
19725eeb39c2SIan Campbell
19735eeb39c2SIan Campbell  return 0;
19745eeb39c2SIan Campbell}
19755eeb39c2SIan CampbellEOF
19765eeb39c2SIan Campbell      compile_prog "" "$xen_libs $xen_stable_libs"
19775eeb39c2SIan Campbell    then
19785eeb39c2SIan Campbell    xen_ctrl_version=471
19795eeb39c2SIan Campbell    xen=yes
19805eeb39c2SIan Campbell  elif
19815eeb39c2SIan Campbell      cat > $TMPC <<EOF &&
1982e37630caSaliguori#include <xenctrl.h>
1983cdadde39SRoger Pau Monne#include <stdint.h>
1984cdadde39SRoger Pau Monneint main(void) {
1985cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
1986cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
1987cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
1988cdadde39SRoger Pau Monne  return 0;
1989cdadde39SRoger Pau Monne}
1990cdadde39SRoger Pau MonneEOF
1991cdadde39SRoger Pau Monne      compile_prog "" "$xen_libs"
1992cdadde39SRoger Pau Monne    then
1993cdadde39SRoger Pau Monne    xen_ctrl_version=470
1994cdadde39SRoger Pau Monne    xen=yes
1995cdadde39SRoger Pau Monne
1996cdadde39SRoger Pau Monne  # Xen 4.6
1997cdadde39SRoger Pau Monne  elif
1998cdadde39SRoger Pau Monne      cat > $TMPC <<EOF &&
1999cdadde39SRoger Pau Monne#include <xenctrl.h>
2000e108a3c1SAnthony PERARD#include <xenstore.h>
2001d5b93ddfSAnthony PERARD#include <stdint.h>
2002d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2003d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2004d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2005d5b93ddfSAnthony PERARD#endif
2006d5b93ddfSAnthony PERARDint main(void) {
2007d5b93ddfSAnthony PERARD  xc_interface *xc;
2008d5b93ddfSAnthony PERARD  xs_daemon_open();
2009d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2010d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2011d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2012b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
20138688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2014d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
201520a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2016d8b441a3SJan Beulich  return 0;
2017d8b441a3SJan Beulich}
2018d8b441a3SJan BeulichEOF
2019d8b441a3SJan Beulich      compile_prog "" "$xen_libs"
2020d8b441a3SJan Beulich    then
2021d8b441a3SJan Beulich    xen_ctrl_version=460
2022d8b441a3SJan Beulich    xen=yes
2023d8b441a3SJan Beulich
2024d8b441a3SJan Beulich  # Xen 4.5
2025d8b441a3SJan Beulich  elif
2026d8b441a3SJan Beulich      cat > $TMPC <<EOF &&
2027d8b441a3SJan Beulich#include <xenctrl.h>
2028d8b441a3SJan Beulich#include <xenstore.h>
2029d8b441a3SJan Beulich#include <stdint.h>
2030d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2031d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2032d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2033d8b441a3SJan Beulich#endif
2034d8b441a3SJan Beulichint main(void) {
2035d8b441a3SJan Beulich  xc_interface *xc;
2036d8b441a3SJan Beulich  xs_daemon_open();
2037d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2038d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2039d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2040d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2041d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
20423996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
20433996e85cSPaul Durrant  return 0;
20443996e85cSPaul Durrant}
20453996e85cSPaul DurrantEOF
20463996e85cSPaul Durrant      compile_prog "" "$xen_libs"
20473996e85cSPaul Durrant    then
20483996e85cSPaul Durrant    xen_ctrl_version=450
20493996e85cSPaul Durrant    xen=yes
20503996e85cSPaul Durrant
20513996e85cSPaul Durrant  elif
20523996e85cSPaul Durrant      cat > $TMPC <<EOF &&
20533996e85cSPaul Durrant#include <xenctrl.h>
20543996e85cSPaul Durrant#include <xenstore.h>
20553996e85cSPaul Durrant#include <stdint.h>
20563996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
20573996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
20583996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
20593996e85cSPaul Durrant#endif
20603996e85cSPaul Durrantint main(void) {
20613996e85cSPaul Durrant  xc_interface *xc;
20623996e85cSPaul Durrant  xs_daemon_open();
20633996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
20643996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
20653996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
20663996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
20673996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
20688688e065SStefano Stabellini  return 0;
20698688e065SStefano Stabellini}
20708688e065SStefano StabelliniEOF
20718688e065SStefano Stabellini      compile_prog "" "$xen_libs"
207269deef08SPeter Maydell    then
20738688e065SStefano Stabellini    xen_ctrl_version=420
20748688e065SStefano Stabellini    xen=yes
20758688e065SStefano Stabellini
2076e37630caSaliguori  else
2077fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
2078edfb07edSIan Campbell      feature_not_found "xen (unsupported version)" \
2079edfb07edSIan Campbell                        "Install a supported xen (xen 4.2 or newer)"
2080fc321b4bSJuan Quintela    fi
2081fc321b4bSJuan Quintela    xen=no
2082e37630caSaliguori  fi
2083d5b93ddfSAnthony PERARD
2084d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
20855eeb39c2SIan Campbell    if test $xen_ctrl_version -ge 471  ; then
20865eeb39c2SIan Campbell      libs_softmmu="$xen_stable_libs $libs_softmmu"
20875eeb39c2SIan Campbell    fi
2088d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
2089d5b93ddfSAnthony PERARD  fi
2090e37630caSaliguorifi
2091e37630caSaliguori
2092eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2093edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2094eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2095eb6fda0fSAnthony PERARD  else
2096eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
209776ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
209876ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2099eb6fda0fSAnthony PERARD    fi
2100eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2101eb6fda0fSAnthony PERARD  fi
2102eb6fda0fSAnthony PERARDfi
2103eb6fda0fSAnthony PERARD
210464a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
210564a7ad6fSIan Campbell   test "$xen" != "yes"; then
210664a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
210764a7ad6fSIan Campbell	       "which requires Xen support."
210864a7ad6fSIan Campbellfi
210964a7ad6fSIan Campbell
2110e37630caSaliguori##########################################
2111dfffc653SJuan Quintela# Sparse probe
2112dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
21130dba6195SLoïc Minier  if has cgcc; then
2114dfffc653SJuan Quintela    sparse=yes
2115dfffc653SJuan Quintela  else
2116dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
211721684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2118dfffc653SJuan Quintela    fi
2119dfffc653SJuan Quintela    sparse=no
2120dfffc653SJuan Quintela  fi
2121dfffc653SJuan Quintelafi
2122dfffc653SJuan Quintela
2123dfffc653SJuan Quintela##########################################
2124f676c67eSJeremy White# X11 probe
2125f676c67eSJeremy Whitex11_cflags=
2126f676c67eSJeremy Whitex11_libs=-lX11
2127f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
212889138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
212989138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2130f676c67eSJeremy Whitefi
2131f676c67eSJeremy White
2132f676c67eSJeremy White##########################################
2133a4ccabcfSAnthony Liguori# GTK probe
2134a4ccabcfSAnthony Liguori
21359e04c683SStefan Weilif test "$gtkabi" = ""; then
21369e04c683SStefan Weil    # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
21379e04c683SStefan Weil    # Use 3.0 as a fallback if that is available.
21389e04c683SStefan Weil    if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
21399e04c683SStefan Weil        gtkabi=2.0
21409e04c683SStefan Weil    elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
21419e04c683SStefan Weil        gtkabi=3.0
21429e04c683SStefan Weil    else
21439e04c683SStefan Weil        gtkabi=2.0
21449e04c683SStefan Weil    fi
21459e04c683SStefan Weilfi
21469e04c683SStefan Weil
2147a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
2148528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
21490a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2150528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2151528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2152bbbf9bfbSStefan Weil    else
2153bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2154bbbf9bfbSStefan Weil    fi
2155bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
215689138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
215789138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
215889138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
21590a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2160f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2161f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
21620a337ed0SGerd Hoffmann        fi
2163bbbf9bfbSStefan Weil        libs_softmmu="$gtk_libs $libs_softmmu"
2164bbbf9bfbSStefan Weil        gtk="yes"
2165bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
21669e04c683SStefan Weil        feature_not_found "gtk" "Install gtk2 or gtk3 devel"
2167bbbf9bfbSStefan Weil    else
2168bbbf9bfbSStefan Weil        gtk="no"
2169bbbf9bfbSStefan Weil    fi
2170bbbf9bfbSStefan Weilfi
2171bbbf9bfbSStefan Weil
2172ddbb0d09SDaniel P. Berrange
2173ddbb0d09SDaniel P. Berrange##########################################
2174ddbb0d09SDaniel P. Berrange# GNUTLS probe
2175ddbb0d09SDaniel P. Berrange
217637371299SPeter Maydellgnutls_works() {
217737371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
217837371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
217937371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
218037371299SPeter Maydell    # builds doesn't work:
218137371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
218237371299SPeter Maydell    #
218337371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
218437371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
218537371299SPeter Maydell        return 1
218637371299SPeter Maydell    fi
218737371299SPeter Maydell
218837371299SPeter Maydell    write_c_skeleton
218937371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
219037371299SPeter Maydell}
219137371299SPeter Maydell
219262893b67SDaniel P. Berrangegnutls_gcrypt=no
2193ed754746SDaniel P. Berrangegnutls_nettle=no
2194ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
219537371299SPeter Maydell    if gnutls_works; then
219689138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
219789138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2198ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2199ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2200ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2201ddbb0d09SDaniel P. Berrange        gnutls="yes"
2202ddbb0d09SDaniel P. Berrange
2203ddbb0d09SDaniel P. Berrange	# gnutls_hash_init requires >= 2.9.10
2204ddbb0d09SDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.9.10"; then
2205ddbb0d09SDaniel P. Berrange            gnutls_hash="yes"
2206ddbb0d09SDaniel P. Berrange	else
2207ddbb0d09SDaniel P. Berrange	    gnutls_hash="no"
2208ddbb0d09SDaniel P. Berrange	fi
220962893b67SDaniel P. Berrange
2210b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2211b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2212b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2213b917da4cSDaniel P. Berrange	else
2214b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2215b917da4cSDaniel P. Berrange	fi
2216b917da4cSDaniel P. Berrange
221762893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
221862893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2219ed754746SDaniel P. Berrange	    gnutls_nettle=yes
222062893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
222189138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2222ed754746SDaniel P. Berrange		*gcrypt*)
2223ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2224ed754746SDaniel P. Berrange		    gnutls_nettle=no
2225ed754746SDaniel P. Berrange		    ;;
2226ed754746SDaniel P. Berrange		*nettle*)
2227ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2228ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2229ed754746SDaniel P. Berrange		    ;;
2230ed754746SDaniel P. Berrange		*)
2231ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2232ed754746SDaniel P. Berrange		    gnutls_nettle=no
2233ed754746SDaniel P. Berrange		    ;;
223462893b67SDaniel P. Berrange	    esac
223562893b67SDaniel P. Berrange	else
223662893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2237ed754746SDaniel P. Berrange	    gnutls_nettle=no
223862893b67SDaniel P. Berrange	fi
2239ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2240ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2241ddbb0d09SDaniel P. Berrange    else
2242ddbb0d09SDaniel P. Berrange        gnutls="no"
2243ddbb0d09SDaniel P. Berrange        gnutls_hash="no"
2244b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2245ddbb0d09SDaniel P. Berrange    fi
2246ddbb0d09SDaniel P. Berrangeelse
2247ddbb0d09SDaniel P. Berrange    gnutls_hash="no"
2248b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2249ddbb0d09SDaniel P. Berrangefi
2250ddbb0d09SDaniel P. Berrange
225191bfcdb0SDaniel P. Berrange
225291bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
225391bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
225491bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
225591bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
225691bfcdb0SDaniel P. Berrangethen
225791bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
225891bfcdb0SDaniel P. Berrange    then
225991bfcdb0SDaniel P. Berrange        gcrypt="no"
226091bfcdb0SDaniel P. Berrange    fi
226191bfcdb0SDaniel P. Berrangefi
226291bfcdb0SDaniel P. Berrange
226391bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
226491bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
226591bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
226691bfcdb0SDaniel P. Berrangeif test -z "$nettle"
226791bfcdb0SDaniel P. Berrangethen
226891bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
226991bfcdb0SDaniel P. Berrange    then
227091bfcdb0SDaniel P. Berrange        nettle="no"
227191bfcdb0SDaniel P. Berrange    fi
227291bfcdb0SDaniel P. Berrangefi
227391bfcdb0SDaniel P. Berrange
227491bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
227591bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
227691bfcdb0SDaniel P. Berrange    then
227791bfcdb0SDaniel P. Berrange	return 1
227891bfcdb0SDaniel P. Berrange    fi
227991bfcdb0SDaniel P. Berrange
228091bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
228191bfcdb0SDaniel P. Berrange    then
228289138857SStefan Weil	host=$(libgcrypt-config --host)
228391bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
228491bfcdb0SDaniel P. Berrange	then
228591bfcdb0SDaniel P. Berrange	    return 1
228691bfcdb0SDaniel P. Berrange	fi
228791bfcdb0SDaniel P. Berrange    fi
228891bfcdb0SDaniel P. Berrange
228991bfcdb0SDaniel P. Berrange    return 0
229091bfcdb0SDaniel P. Berrange}
229191bfcdb0SDaniel P. Berrange
229291bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
229391bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
229489138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
229589138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
229691bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
229791bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
229891bfcdb0SDaniel P. Berrange        # turn breaks static builds...
229991bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
230091bfcdb0SDaniel P. Berrange        then
230191bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
230291bfcdb0SDaniel P. Berrange        fi
230362893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
230462893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
230562893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
230691bfcdb0SDaniel P. Berrange        gcrypt="yes"
230791bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
230891bfcdb0SDaniel P. Berrange           nettle="no"
230991bfcdb0SDaniel P. Berrange        fi
231037788f25SDaniel P. Berrange
231137788f25SDaniel P. Berrange        cat > $TMPC << EOF
231237788f25SDaniel P. Berrange#include <gcrypt.h>
231337788f25SDaniel P. Berrangeint main(void) {
231437788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
231537788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
231637788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
231737788f25SDaniel P. Berrange return 0;
231837788f25SDaniel P. Berrange}
231937788f25SDaniel P. BerrangeEOF
232037788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
232137788f25SDaniel P. Berrange            gcrypt_kdf=yes
232237788f25SDaniel P. Berrange        fi
232362893b67SDaniel P. Berrange    else
232491bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
232562893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
232691bfcdb0SDaniel P. Berrange        else
232791bfcdb0SDaniel P. Berrange            gcrypt="no"
232891bfcdb0SDaniel P. Berrange        fi
232962893b67SDaniel P. Berrange    fi
233062893b67SDaniel P. Berrangefi
233162893b67SDaniel P. Berrange
2332ddbb0d09SDaniel P. Berrange
233391bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2334ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
233589138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
233689138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
233789138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2338ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2339ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2340ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
234191bfcdb0SDaniel P. Berrange        nettle="yes"
2342fff2f982SDaniel P. Berrange
2343fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
23449e87a691SSteven Luo#include <stddef.h>
2345fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2346fff2f982SDaniel P. Berrangeint main(void) {
2347fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2348fff2f982SDaniel P. Berrange     return 0;
2349fff2f982SDaniel P. Berrange}
2350fff2f982SDaniel P. BerrangeEOF
2351fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2352fff2f982SDaniel P. Berrange            nettle_kdf=yes
2353fff2f982SDaniel P. Berrange        fi
2354ed754746SDaniel P. Berrange    else
235591bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2356ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
235791bfcdb0SDaniel P. Berrange        else
235891bfcdb0SDaniel P. Berrange            nettle="no"
2359ed754746SDaniel P. Berrange        fi
2360ed754746SDaniel P. Berrange    fi
236191bfcdb0SDaniel P. Berrangefi
236291bfcdb0SDaniel P. Berrange
236391bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
236491bfcdb0SDaniel P. Berrangethen
236591bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
236691bfcdb0SDaniel P. Berrangefi
2367ed754746SDaniel P. Berrange
23689a2fd434SDaniel P. Berrange##########################################
23699a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
23709a2fd434SDaniel P. Berrange
23719a2fd434SDaniel P. Berrangetasn1=yes
237290246037SDaniel P. Berrangetasn1_cflags=""
237390246037SDaniel P. Berrangetasn1_libs=""
23749a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
237589138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
237689138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
23779a2fd434SDaniel P. Berrangeelse
23789a2fd434SDaniel P. Berrange    tasn1=no
23799a2fd434SDaniel P. Berrangefi
23809a2fd434SDaniel P. Berrange
2381ed754746SDaniel P. Berrange
2382bbbf9bfbSStefan Weil##########################################
2383559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2384559607eaSDaniel P. Berrange
2385559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2386559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2387559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2388559607eaSDaniel P. Berrangefi
2389559607eaSDaniel P. Berrange
2390559607eaSDaniel P. Berrange##########################################
2391bbbf9bfbSStefan Weil# VTE probe
2392bbbf9bfbSStefan Weil
2393bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2394bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2395c6feff9eSCole Robinson      vteminversion="0.32.0"
2396c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2397c6feff9eSCole Robinson        vtepackage="vte-2.91"
2398c6feff9eSCole Robinson      else
2399528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2400c6feff9eSCole Robinson      fi
2401528de90aSDaniel P. Berrange    else
2402528de90aSDaniel P. Berrange      vtepackage="vte"
2403c6feff9eSCole Robinson      vteminversion="0.24.0"
2404528de90aSDaniel P. Berrange    fi
2405c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
240689138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
240789138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
240889138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2409bbbf9bfbSStefan Weil        libs_softmmu="$vte_libs $libs_softmmu"
2410bbbf9bfbSStefan Weil        vte="yes"
2411bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
24129e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2413c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
24149e04c683SStefan Weil        else
24159e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
24169e04c683SStefan Weil        fi
2417bbbf9bfbSStefan Weil    else
2418bbbf9bfbSStefan Weil        vte="no"
2419a4ccabcfSAnthony Liguori    fi
2420a4ccabcfSAnthony Liguorifi
2421a4ccabcfSAnthony Liguori
2422a4ccabcfSAnthony Liguori##########################################
242311d9f695Sbellard# SDL probe
242411d9f695Sbellard
24253ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
24263ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
242747c03744SDave Airlie
2428ee8466d0SCole Robinsonif test "$sdlabi" = ""; then
2429ee8466d0SCole Robinson    if $pkg_config --exists "sdl"; then
2430ee8466d0SCole Robinson        sdlabi=1.2
2431ee8466d0SCole Robinson    elif $pkg_config --exists "sdl2"; then
2432ee8466d0SCole Robinson        sdlabi=2.0
2433ee8466d0SCole Robinson    else
2434ee8466d0SCole Robinson        sdlabi=1.2
2435ee8466d0SCole Robinson    fi
2436ee8466d0SCole Robinsonfi
2437ee8466d0SCole Robinson
243847c03744SDave Airlieif test $sdlabi = "2.0"; then
243947c03744SDave Airlie    sdl_config=$sdl2_config
244047c03744SDave Airlie    sdlname=sdl2
244147c03744SDave Airlie    sdlconfigname=sdl2_config
2442e07047cfSCole Robinsonelif test $sdlabi = "1.2"; then
244347c03744SDave Airlie    sdlname=sdl
244447c03744SDave Airlie    sdlconfigname=sdl_config
2445e07047cfSCole Robinsonelse
2446e07047cfSCole Robinson    error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
24473ec87ffeSPaolo Bonzinifi
24483ec87ffeSPaolo Bonzini
244989138857SStefan Weilif test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
245047c03744SDave Airlie  sdl_config=$sdlconfigname
245147c03744SDave Airliefi
245247c03744SDave Airlie
245347c03744SDave Airlieif $pkg_config $sdlname --exists; then
245447c03744SDave Airlie  sdlconfig="$pkg_config $sdlname"
245589138857SStefan Weil  sdlversion=$($sdlconfig --modversion 2>/dev/null)
24563ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
24573ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
245889138857SStefan Weil  sdlversion=$($sdlconfig --version)
2459a0dfd8a4SLoïc Minierelse
2460a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
246121684af0SStewart Smith    feature_not_found "sdl" "Install SDL devel"
2462a0dfd8a4SLoïc Minier  fi
2463a0dfd8a4SLoïc Minier  sdl=no
24649316f803SPaolo Bonzinifi
246529e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
24663ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
24673ec87ffeSPaolo Bonzinifi
246811d9f695Sbellard
24699316f803SPaolo Bonzinisdl_too_old=no
2470c4198157SJuan Quintelaif test "$sdl" != "no" ; then
247111d9f695Sbellard  cat > $TMPC << EOF
247211d9f695Sbellard#include <SDL.h>
247311d9f695Sbellard#undef main /* We don't want SDL to override our main() */
247411d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
247511d9f695SbellardEOF
247689138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
247774f42e18STeLeMan  if test "$static" = "yes" ; then
247889138857SStefan Weil    sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
247974f42e18STeLeMan  else
248089138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
248174f42e18STeLeMan  fi
248252166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
248389138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
248411d9f695Sbellard      sdl_too_old=yes
248511d9f695Sbellard    else
248611d9f695Sbellard      sdl=yes
248711d9f695Sbellard    fi
24887c1f25b4Sbellard
248967c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
24901ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
249167c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
249289138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
249389138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
249411d9f695Sbellard      fi
249552166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
24961ac88f28SJuan Quintela	:
24971ac88f28SJuan Quintela      else
24981ac88f28SJuan Quintela        sdl=no
24997c1f25b4Sbellard      fi
25007c1f25b4Sbellard    fi # static link
2501c4198157SJuan Quintela  else # sdl not found
2502c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
250321684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2504c4198157SJuan Quintela    fi
2505c4198157SJuan Quintela    sdl=no
25067c1f25b4Sbellard  fi # sdl compile test
2507fd677642Sthsfi
250811d9f695Sbellard
25095368a422Saliguoriif test "$sdl" = "yes" ; then
25105368a422Saliguori  cat > $TMPC <<EOF
25115368a422Saliguori#include <SDL.h>
25125368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
25135368a422Saliguori#include <X11/XKBlib.h>
25145368a422Saliguori#else
25155368a422Saliguori#error No x11 support
25165368a422Saliguori#endif
25175368a422Saliguoriint main(void) { return 0; }
25185368a422SaliguoriEOF
2519f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2520f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
2521f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
25225368a422Saliguori  fi
25230705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
25245368a422Saliguorifi
25255368a422Saliguori
25268f28f3fbSths##########################################
25272da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
25282da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
25292da776dbSMichael R. Hines  cat > $TMPC <<EOF
25302da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
25312da776dbSMichael R. Hinesint main(void) { return 0; }
25322da776dbSMichael R. HinesEOF
25332da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
25342da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
25352da776dbSMichael R. Hines    rdma="yes"
25362da776dbSMichael R. Hines    libs_softmmu="$libs_softmmu $rdma_libs"
25372da776dbSMichael R. Hines  else
25382da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
25392da776dbSMichael R. Hines        error_exit \
25402da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
25412da776dbSMichael R. Hines            " Your options:" \
25422da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
25432da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
25442da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
25452da776dbSMichael R. Hines    fi
25462da776dbSMichael R. Hines    rdma="no"
25472da776dbSMichael R. Hines  fi
25482da776dbSMichael R. Hinesfi
25492da776dbSMichael R. Hines
255095c6bff3SBenoît Canet
255195c6bff3SBenoît Canet##########################################
25522f9606b3Saliguori# VNC SASL detection
2553821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
25542f9606b3Saliguori  cat > $TMPC <<EOF
25552f9606b3Saliguori#include <sasl/sasl.h>
25562f9606b3Saliguori#include <stdio.h>
25572f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
25582f9606b3SaliguoriEOF
25592f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
25602f9606b3Saliguori  vnc_sasl_cflags=""
25612f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
256252166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2563ea784e3bSJuan Quintela    vnc_sasl=yes
2564fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2565ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
25662f9606b3Saliguori  else
2567ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
256821684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2569ea784e3bSJuan Quintela    fi
2570ea784e3bSJuan Quintela    vnc_sasl=no
25712f9606b3Saliguori  fi
25722f9606b3Saliguorifi
25732f9606b3Saliguori
25742f9606b3Saliguori##########################################
25752f6f5c7aSCorentin Chary# VNC JPEG detection
2576821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
25772f6f5c7aSCorentin Charycat > $TMPC <<EOF
25782f6f5c7aSCorentin Chary#include <stdio.h>
25792f6f5c7aSCorentin Chary#include <jpeglib.h>
25802f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
25812f6f5c7aSCorentin CharyEOF
25822f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
25832f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
25842f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
25852f6f5c7aSCorentin Chary    vnc_jpeg=yes
25862f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2587ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
25882f6f5c7aSCorentin Chary  else
25892f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
259021684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
25912f6f5c7aSCorentin Chary    fi
25922f6f5c7aSCorentin Chary    vnc_jpeg=no
25932f6f5c7aSCorentin Chary  fi
25942f6f5c7aSCorentin Charyfi
25952f6f5c7aSCorentin Chary
25962f6f5c7aSCorentin Chary##########################################
2597efe556adSCorentin Chary# VNC PNG detection
2598821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2599efe556adSCorentin Charycat > $TMPC <<EOF
2600efe556adSCorentin Chary//#include <stdio.h>
2601efe556adSCorentin Chary#include <png.h>
2602832ce9c2SScott Wood#include <stddef.h>
2603efe556adSCorentin Charyint main(void) {
2604efe556adSCorentin Chary    png_structp png_ptr;
2605efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
26067edc3fedSPeter Maydell    return png_ptr != 0;
2607efe556adSCorentin Chary}
2608efe556adSCorentin CharyEOF
260965d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
261089138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
261189138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
26129af8025eSBrad  else
2613efe556adSCorentin Chary    vnc_png_cflags=""
2614efe556adSCorentin Chary    vnc_png_libs="-lpng"
26159af8025eSBrad  fi
2616efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2617efe556adSCorentin Chary    vnc_png=yes
2618efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
26199af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2620efe556adSCorentin Chary  else
2621efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
262221684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2623efe556adSCorentin Chary    fi
2624efe556adSCorentin Chary    vnc_png=no
2625efe556adSCorentin Chary  fi
2626efe556adSCorentin Charyfi
2627efe556adSCorentin Chary
2628efe556adSCorentin Chary##########################################
262976655d6dSaliguori# fnmatch() probe, used for ACL routines
263076655d6dSaliguorifnmatch="no"
263176655d6dSaliguoricat > $TMPC << EOF
263276655d6dSaliguori#include <fnmatch.h>
263376655d6dSaliguoriint main(void)
263476655d6dSaliguori{
263576655d6dSaliguori    fnmatch("foo", "foo", 0);
263676655d6dSaliguori    return 0;
263776655d6dSaliguori}
263876655d6dSaliguoriEOF
263952166aa0SJuan Quintelaif compile_prog "" "" ; then
264076655d6dSaliguori   fnmatch="yes"
264176655d6dSaliguorifi
264276655d6dSaliguori
264376655d6dSaliguori##########################################
2644ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
26452d16c8e9SPeter Maydell# Note that on some systems (notably MacOSX) no extra library
26462d16c8e9SPeter Maydell# need be linked to get the uuid functions.
2647ee682d27SStefan Weilif test "$uuid" != "no" ; then
2648ee682d27SStefan Weil  uuid_libs="-luuid"
2649ee682d27SStefan Weil  cat > $TMPC << EOF
2650ee682d27SStefan Weil#include <uuid/uuid.h>
2651ee682d27SStefan Weilint main(void)
2652ee682d27SStefan Weil{
2653ee682d27SStefan Weil    uuid_t my_uuid;
2654ee682d27SStefan Weil    uuid_generate(my_uuid);
2655ee682d27SStefan Weil    return 0;
2656ee682d27SStefan Weil}
2657ee682d27SStefan WeilEOF
26582d16c8e9SPeter Maydell  if compile_prog "" "" ; then
26592d16c8e9SPeter Maydell    uuid="yes"
26602d16c8e9SPeter Maydell  elif compile_prog "" "$uuid_libs" ; then
2661ee682d27SStefan Weil    uuid="yes"
2662ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
2663ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
2664ee682d27SStefan Weil  else
2665ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
266621684af0SStewart Smith      feature_not_found "uuid" "Install libuuid devel"
2667ee682d27SStefan Weil    fi
2668ee682d27SStefan Weil    uuid=no
2669ee682d27SStefan Weil  fi
2670ee682d27SStefan Weilfi
2671ee682d27SStefan Weil
26724f18b782SJeff Codyif test "$vhdx" = "yes" ; then
26734f18b782SJeff Cody    if test "$uuid" = "no" ; then
26744f18b782SJeff Cody        error_exit "uuid required for VHDX support"
26754f18b782SJeff Cody    fi
26764f18b782SJeff Codyelif test "$vhdx" != "no" ; then
26774f18b782SJeff Cody    if test "$uuid" = "yes" ; then
26784f18b782SJeff Cody        vhdx=yes
26794f18b782SJeff Cody    else
26804f18b782SJeff Cody        vhdx=no
26814f18b782SJeff Cody    fi
26824f18b782SJeff Codyfi
26834f18b782SJeff Cody
2684ee682d27SStefan Weil##########################################
2685dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
2686dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2687dce512deSChristoph Hellwig  cat > $TMPC << EOF
2688ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2689dce512deSChristoph Hellwig#include <xfs/xfs.h>
2690dce512deSChristoph Hellwigint main(void)
2691dce512deSChristoph Hellwig{
2692dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2693dce512deSChristoph Hellwig    return 0;
2694dce512deSChristoph Hellwig}
2695dce512deSChristoph HellwigEOF
2696dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2697dce512deSChristoph Hellwig    xfs="yes"
2698dce512deSChristoph Hellwig  else
2699dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
270021684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2701dce512deSChristoph Hellwig    fi
2702dce512deSChristoph Hellwig    xfs=no
2703dce512deSChristoph Hellwig  fi
2704dce512deSChristoph Hellwigfi
2705dce512deSChristoph Hellwig
2706dce512deSChristoph Hellwig##########################################
27078a16d273Sths# vde libraries probe
2708dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
27094baae0acSJuan Quintela  vde_libs="-lvdeplug"
27108a16d273Sths  cat > $TMPC << EOF
27118a16d273Sths#include <libvdeplug.h>
27124a7f0e06Spbrookint main(void)
27134a7f0e06Spbrook{
27144a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2715fea08e08SPeter Maydell    char s[] = "";
2716fea08e08SPeter Maydell    vde_open(s, s, &a);
27174a7f0e06Spbrook    return 0;
27184a7f0e06Spbrook}
27198a16d273SthsEOF
272052166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
27214baae0acSJuan Quintela    vde=yes
27228e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
27238e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2724dfb278bdSJuan Quintela  else
2725dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
272621684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2727dfb278bdSJuan Quintela    fi
2728dfb278bdSJuan Quintela    vde=no
27298a16d273Sths  fi
27308a16d273Sthsfi
27318a16d273Sths
27328a16d273Sths##########################################
27330a985b37SVincenzo Maffione# netmap support probe
27340a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
27350a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
27360a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
27370a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
27380a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
273958952137SVincenzo Maffioneif test "$netmap" != "no" ; then
274058952137SVincenzo Maffione  cat > $TMPC << EOF
274158952137SVincenzo Maffione#include <inttypes.h>
274258952137SVincenzo Maffione#include <net/if.h>
274358952137SVincenzo Maffione#include <net/netmap.h>
274458952137SVincenzo Maffione#include <net/netmap_user.h>
27450a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
27460a985b37SVincenzo Maffione#error
27470a985b37SVincenzo Maffione#endif
274858952137SVincenzo Maffioneint main(void) { return 0; }
274958952137SVincenzo MaffioneEOF
275058952137SVincenzo Maffione  if compile_prog "" "" ; then
275158952137SVincenzo Maffione    netmap=yes
275258952137SVincenzo Maffione  else
275358952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
275458952137SVincenzo Maffione      feature_not_found "netmap"
275558952137SVincenzo Maffione    fi
275658952137SVincenzo Maffione    netmap=no
275758952137SVincenzo Maffione  fi
275858952137SVincenzo Maffionefi
275958952137SVincenzo Maffione
276058952137SVincenzo Maffione##########################################
276147e98658SCorey Bryant# libcap-ng library probe
276247e98658SCorey Bryantif test "$cap_ng" != "no" ; then
276347e98658SCorey Bryant  cap_libs="-lcap-ng"
276447e98658SCorey Bryant  cat > $TMPC << EOF
276547e98658SCorey Bryant#include <cap-ng.h>
276647e98658SCorey Bryantint main(void)
276747e98658SCorey Bryant{
276847e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
276947e98658SCorey Bryant    return 0;
277047e98658SCorey Bryant}
277147e98658SCorey BryantEOF
277247e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
277347e98658SCorey Bryant    cap_ng=yes
277447e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
277547e98658SCorey Bryant  else
277647e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
277721684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
277847e98658SCorey Bryant    fi
277947e98658SCorey Bryant    cap_ng=no
278047e98658SCorey Bryant  fi
278147e98658SCorey Bryantfi
278247e98658SCorey Bryant
278347e98658SCorey Bryant##########################################
2784c2de5c91Smalc# Sound support libraries probe
27858f28f3fbSths
2786c2de5c91Smalcaudio_drv_probe()
2787c2de5c91Smalc{
2788c2de5c91Smalc    drv=$1
2789c2de5c91Smalc    hdr=$2
2790c2de5c91Smalc    lib=$3
2791c2de5c91Smalc    exp=$4
2792c2de5c91Smalc    cfl=$5
27938f28f3fbSths        cat > $TMPC << EOF
2794c2de5c91Smalc#include <$hdr>
2795c2de5c91Smalcint main(void) { $exp }
27968f28f3fbSthsEOF
279752166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
27988f28f3fbSths        :
27998f28f3fbSths    else
280076ad07a4SPeter Maydell        error_exit "$drv check failed" \
280176ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
28028f28f3fbSths    fi
2803c2de5c91Smalc}
2804c2de5c91Smalc
280589138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
2806c2de5c91Smalcfor drv in $audio_drv_list; do
2807c2de5c91Smalc    case $drv in
2808c2de5c91Smalc    alsa)
2809c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
2810e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
2811a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
2812c2de5c91Smalc    ;;
2813c2de5c91Smalc
2814b8e59f18Smalc    pa)
2815e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
2816e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
2817a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
281867f86e8eSJuan Quintela    audio_pt_int="yes"
2819b8e59f18Smalc    ;;
2820b8e59f18Smalc
2821997e690aSJuan Quintela    coreaudio)
2822997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
2823997e690aSJuan Quintela    ;;
2824997e690aSJuan Quintela
2825a4bf6780SJuan Quintela    dsound)
2826a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2827d5631638Smalc      audio_win_int="yes"
2828a4bf6780SJuan Quintela    ;;
2829a4bf6780SJuan Quintela
2830a4bf6780SJuan Quintela    oss)
2831a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
2832a4bf6780SJuan Quintela    ;;
2833a4bf6780SJuan Quintela
2834a4bf6780SJuan Quintela    sdl|wav)
28352f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
28362f6a1ab0Sblueswir1    ;;
28372f6a1ab0Sblueswir1
2838e4c63a6aSmalc    *)
28391c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
284076ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
284176ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
2842e4c63a6aSmalc    }
2843e4c63a6aSmalc    ;;
2844c2de5c91Smalc    esac
2845c2de5c91Smalcdone
28468f28f3fbSths
28474d3b6f6eSbalrog##########################################
28482e4d9fb1Saurel32# BrlAPI probe
28492e4d9fb1Saurel32
28504ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2851eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
28522e4d9fb1Saurel32  cat > $TMPC << EOF
28532e4d9fb1Saurel32#include <brlapi.h>
2854832ce9c2SScott Wood#include <stddef.h>
28552e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
28562e4d9fb1Saurel32EOF
285752166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
28582e4d9fb1Saurel32    brlapi=yes
2859264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
28604ffcedb6SJuan Quintela  else
28614ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
286221684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
28634ffcedb6SJuan Quintela    fi
28644ffcedb6SJuan Quintela    brlapi=no
2865eb82284fSJuan Quintela  fi
2866eb82284fSJuan Quintelafi
28672e4d9fb1Saurel32
28682e4d9fb1Saurel32##########################################
28694d3b6f6eSbalrog# curses probe
2870a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
2871e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
2872ae629634SStefan Weil    curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
2873e095e2f3SStefan Weil  else
2874cfeda5f4SEd Maste    curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
2875e095e2f3SStefan Weil  fi
2876c584a6d0SJuan Quintela  curses_found=no
28774d3b6f6eSbalrog  cat > $TMPC << EOF
28784d3b6f6eSbalrog#include <curses.h>
2879ef9a2524SStefan Weilint main(void) {
2880ef9a2524SStefan Weil  const char *s = curses_version();
2881ef9a2524SStefan Weil  resize_term(0, 0);
2882ef9a2524SStefan Weil  return s != 0;
2883ef9a2524SStefan Weil}
28844d3b6f6eSbalrogEOF
2885ecbe251fSVadim Evard  IFS=:
28864f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
2887ecbe251fSVadim Evard    unset IFS
28884f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2889c584a6d0SJuan Quintela      curses_found=yes
28904f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
28914f78ef9aSJuan Quintela      break
28924d3b6f6eSbalrog    fi
28934f78ef9aSJuan Quintela  done
2894ecbe251fSVadim Evard  unset IFS
2895c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2896c584a6d0SJuan Quintela    curses=yes
2897c584a6d0SJuan Quintela  else
2898c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
289921684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
2900c584a6d0SJuan Quintela    fi
2901c584a6d0SJuan Quintela    curses=no
2902c584a6d0SJuan Quintela  fi
29034f78ef9aSJuan Quintelafi
29044d3b6f6eSbalrog
2905414f0dabSblueswir1##########################################
2906769ce76dSAlexander Graf# curl probe
2907a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
290865d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
2909a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
29104e2b0658SPaolo Bonzini  else
29114e2b0658SPaolo Bonzini    curlconfig=curl-config
29124e2b0658SPaolo Bonzini  fi
2913769ce76dSAlexander Graf  cat > $TMPC << EOF
2914769ce76dSAlexander Graf#include <curl/curl.h>
29150b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2916769ce76dSAlexander GrafEOF
291789138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
291889138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
2919b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2920769ce76dSAlexander Graf    curl=yes
2921788c8196SJuan Quintela  else
2922788c8196SJuan Quintela    if test "$curl" = "yes" ; then
292321684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
2924788c8196SJuan Quintela    fi
2925788c8196SJuan Quintela    curl=no
2926769ce76dSAlexander Graf  fi
2927769ce76dSAlexander Graffi # test "$curl"
2928769ce76dSAlexander Graf
2929769ce76dSAlexander Graf##########################################
2930fb599c9aSbalrog# bluez support probe
2931a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2932e820e3f4Sbalrog  cat > $TMPC << EOF
2933e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2934e820e3f4Sbalrogint main(void) { return bt_error(0); }
2935e820e3f4SbalrogEOF
293689138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
293789138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
293852166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2939a20a6f46SJuan Quintela    bluez=yes
2940e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2941e820e3f4Sbalrog  else
2942a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
294321684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
2944a20a6f46SJuan Quintela    fi
2945e820e3f4Sbalrog    bluez="no"
2946e820e3f4Sbalrog  fi
2947fb599c9aSbalrogfi
2948fb599c9aSbalrog
2949fb599c9aSbalrog##########################################
2950e18df141SAnthony Liguori# glib support probe
2951a52d28afSPaolo Bonzini
2952f40685c6SJohn Snowglib_req_ver=2.22
2953aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
2954aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
2955aa0d1f44SPaolo Bonzini    glib_modules="$glib_modules gmodule-2.0"
2956aa0d1f44SPaolo Bonzinifi
2957e26110cfSFam Zheng
2958aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
2959e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
296089138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
296189138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
2962ba1183daSFam Zheng        CFLAGS="$glib_cflags $CFLAGS"
296314015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
2964957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
2965e18df141SAnthony Liguori    else
2966e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2967e26110cfSFam Zheng    fi
2968e26110cfSFam Zhengdone
2969e26110cfSFam Zheng
2970977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
2971977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
2972977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
2973977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
2974977a82abSDaniel P. Berrangecat > $TMPC <<EOF
2975977a82abSDaniel P. Berrange#include <glib.h>
2976977a82abSDaniel P. Berrange#include <unistd.h>
2977977a82abSDaniel P. Berrange
2978977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
2979977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2980977a82abSDaniel P. Berrange
2981977a82abSDaniel P. Berrangeint main(void) {
2982977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2983977a82abSDaniel P. Berrange   return 0;
2984977a82abSDaniel P. Berrange}
2985977a82abSDaniel P. BerrangeEOF
2986977a82abSDaniel P. Berrange
29875919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
2988977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2989977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
2990977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
2991977a82abSDaniel P. Berrange	       "build target"
2992977a82abSDaniel P. Berrangefi
2993977a82abSDaniel P. Berrange
29949d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
29959d41401bSMichael S. Tsirkinglib_subprocess=yes
29969d41401bSMichael S. Tsirkinif ! $pkg_config --atleast-version=2.38 glib-2.0; then
29979d41401bSMichael S. Tsirkin    glib_subprocess=no
29989d41401bSMichael S. Tsirkinfi
29999d41401bSMichael S. Tsirkin
3000bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3001bbbf2e04SJohn Snowcat > $TMPC << EOF
3002bbbf2e04SJohn Snow#include <glib.h>
3003bbbf2e04SJohn Snowint main(void) { return 0; }
3004bbbf2e04SJohn SnowEOF
3005bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3006bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3007bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3008bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3009bbbf2e04SJohn Snow    fi
3010bbbf2e04SJohn Snowfi
3011bbbf2e04SJohn Snow
3012e26110cfSFam Zheng##########################################
3013e26110cfSFam Zheng# SHA command probe for modules
3014e26110cfSFam Zhengif test "$modules" = yes; then
3015e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3016e26110cfSFam Zheng    for c in $shacmd_probe; do
30178ccefb91SFam Zheng        if has $c; then
3018e26110cfSFam Zheng            shacmd="$c"
3019e26110cfSFam Zheng            break
3020e26110cfSFam Zheng        fi
3021e26110cfSFam Zheng    done
3022e26110cfSFam Zheng    if test "$shacmd" = ""; then
3023e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3024e26110cfSFam Zheng    fi
3025e18df141SAnthony Liguorifi
3026e18df141SAnthony Liguori
3027e18df141SAnthony Liguori##########################################
3028e2134eb9SGerd Hoffmann# pixman support probe
3029e2134eb9SGerd Hoffmann
3030e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
303174880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
303274880fe2SRobert Schiele    pixman="none"
3033236f282cSHu Tao  elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3034e2134eb9SGerd Hoffmann    pixman="system"
3035e2134eb9SGerd Hoffmann  else
3036e2134eb9SGerd Hoffmann    pixman="internal"
3037e2134eb9SGerd Hoffmann  fi
3038e2134eb9SGerd Hoffmannfi
303974880fe2SRobert Schieleif test "$pixman" = "none"; then
304074880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
304176ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
304276ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
304376ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
304476ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
304574880fe2SRobert Schiele  fi
304674880fe2SRobert Schiele  pixman_cflags=
304774880fe2SRobert Schiele  pixman_libs=
304874880fe2SRobert Schieleelif test "$pixman" = "system"; then
3049236f282cSHu Tao  # pixman version has been checked above
305089138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
305189138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3052e2134eb9SGerd Hoffmannelse
3053e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
3054236f282cSHu Tao    error_exit "pixman >= 0.21.8 not present. Your options:" \
305576ad07a4SPeter Maydell        "  (1) Preferred: Install the pixman devel package (any recent" \
305676ad07a4SPeter Maydell        "      distro should have packages as Xorg needs pixman too)." \
305776ad07a4SPeter Maydell        "  (2) Fetch the pixman submodule, using:" \
305876ad07a4SPeter Maydell        "      git submodule update --init pixman"
3059e2134eb9SGerd Hoffmann  fi
30605ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
30615ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
30625ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
3063e2134eb9SGerd Hoffmannfi
3064e2134eb9SGerd Hoffmann
3065e2134eb9SGerd Hoffmann##########################################
306617bff52bSM. Mohan Kumar# libcap probe
306717bff52bSM. Mohan Kumar
306817bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
306917bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
307017bff52bSM. Mohan Kumar#include <stdio.h>
307117bff52bSM. Mohan Kumar#include <sys/capability.h>
3072cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
307317bff52bSM. Mohan KumarEOF
307417bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
307517bff52bSM. Mohan Kumar    cap=yes
307617bff52bSM. Mohan Kumar  else
307717bff52bSM. Mohan Kumar    cap=no
307817bff52bSM. Mohan Kumar  fi
307917bff52bSM. Mohan Kumarfi
308017bff52bSM. Mohan Kumar
308117bff52bSM. Mohan Kumar##########################################
3082e5d355d1Saliguori# pthread probe
30834b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
30843c529d93Saliguori
3085e5d355d1Saliguoripthread=no
3086414f0dabSblueswir1cat > $TMPC << EOF
30873c529d93Saliguori#include <pthread.h>
30887a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
30897a42bbe4SStefan Weilint main(void) {
30907a42bbe4SStefan Weil  pthread_t thread;
30917a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
30927a42bbe4SStefan Weil  return 0;
30937a42bbe4SStefan Weil}
3094414f0dabSblueswir1EOF
3095bd00d539SAndreas Färberif compile_prog "" "" ; then
3096bd00d539SAndreas Färber  pthread=yes
3097bd00d539SAndreas Färberelse
3098de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
309952166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3100e5d355d1Saliguori      pthread=yes
3101e3c56761SPeter Portante      found=no
3102e3c56761SPeter Portante      for lib_entry in $LIBS; do
3103e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3104e3c56761SPeter Portante          found=yes
3105e3c56761SPeter Portante          break
3106e3c56761SPeter Portante        fi
3107e3c56761SPeter Portante      done
3108e3c56761SPeter Portante      if test "$found" = "no"; then
31095572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3110e3c56761SPeter Portante      fi
3111de65fe0fSSebastian Herbszt      break
3112414f0dabSblueswir1    fi
3113de65fe0fSSebastian Herbszt  done
3114bd00d539SAndreas Färberfi
3115414f0dabSblueswir1
31164617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
311776ad07a4SPeter Maydell  error_exit "pthread check failed" \
311876ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3119e5d355d1Saliguorifi
3120e5d355d1Saliguori
31215c312079SDr. David Alan Gilbert# check for pthread_setname_np
31225c312079SDr. David Alan Gilbertpthread_setname_np=no
31235c312079SDr. David Alan Gilbertcat > $TMPC << EOF
31245c312079SDr. David Alan Gilbert#include <pthread.h>
31255c312079SDr. David Alan Gilbert
31265c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
31275c312079SDr. David Alan Gilbertint main(void)
31285c312079SDr. David Alan Gilbert{
31295c312079SDr. David Alan Gilbert    pthread_t thread;
31305c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
31315c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
31325c312079SDr. David Alan Gilbert    return 0;
31335c312079SDr. David Alan Gilbert}
31345c312079SDr. David Alan GilbertEOF
31355c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
31365c312079SDr. David Alan Gilbert  pthread_setname_np=yes
31375c312079SDr. David Alan Gilbertfi
31385c312079SDr. David Alan Gilbert
3139bf9298b9Saliguori##########################################
3140f27aaf4bSChristian Brunner# rbd probe
3141f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3142f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3143f27aaf4bSChristian Brunner#include <stdio.h>
3144ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3145f27aaf4bSChristian Brunnerint main(void) {
3146ad32e9c0SJosh Durgin    rados_t cluster;
3147ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3148f27aaf4bSChristian Brunner    return 0;
3149f27aaf4bSChristian Brunner}
3150f27aaf4bSChristian BrunnerEOF
3151ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3152f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3153f27aaf4bSChristian Brunner    rbd=yes
3154f27aaf4bSChristian Brunner  else
3155f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
315621684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3157f27aaf4bSChristian Brunner    fi
3158f27aaf4bSChristian Brunner    rbd=no
3159f27aaf4bSChristian Brunner  fi
3160f27aaf4bSChristian Brunnerfi
3161f27aaf4bSChristian Brunner
3162f27aaf4bSChristian Brunner##########################################
31630a12ec87SRichard W.M. Jones# libssh2 probe
31644fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
31650a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
316665d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
316789138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
316889138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
31690a12ec87SRichard W.M. Jones    libssh2=yes
31700a12ec87SRichard W.M. Jones  else
31710a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
31724fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
31730a12ec87SRichard W.M. Jones    fi
31740a12ec87SRichard W.M. Jones    libssh2=no
31750a12ec87SRichard W.M. Jones  fi
31760a12ec87SRichard W.M. Jonesfi
31770a12ec87SRichard W.M. Jones
31780a12ec87SRichard W.M. Jones##########################################
31799a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
31809a2d462eSRichard W.M. Jones
31819a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
31829a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
31839a2d462eSRichard W.M. Jones#include <stdio.h>
31849a2d462eSRichard W.M. Jones#include <libssh2.h>
31859a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
31869a2d462eSRichard W.M. Jonesint main(void) {
31879a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
31889a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
31899a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
31909a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
31919a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
31929a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
31939a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
31949a2d462eSRichard W.M. Jones    return 0;
31959a2d462eSRichard W.M. Jones}
31969a2d462eSRichard W.M. JonesEOF
31979a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
31989a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
31999a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
32009a2d462eSRichard W.M. Jones  fi
32019a2d462eSRichard W.M. Jonesfi
32029a2d462eSRichard W.M. Jones
32039a2d462eSRichard W.M. Jones##########################################
32045c6c3a6cSChristoph Hellwig# linux-aio probe
32055c6c3a6cSChristoph Hellwig
32065c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
32075c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
32085c6c3a6cSChristoph Hellwig#include <libaio.h>
32095c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3210832ce9c2SScott Wood#include <stddef.h>
32115c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
32125c6c3a6cSChristoph HellwigEOF
32135c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
32145c6c3a6cSChristoph Hellwig    linux_aio=yes
32155c6c3a6cSChristoph Hellwig  else
32165c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
321721684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
32185c6c3a6cSChristoph Hellwig    fi
32193cfcae3cSLuiz Capitulino    linux_aio=no
32205c6c3a6cSChristoph Hellwig  fi
32215c6c3a6cSChristoph Hellwigfi
32225c6c3a6cSChristoph Hellwig
32235c6c3a6cSChristoph Hellwig##########################################
32243b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
32253b8acc11SPaolo Bonzini
32263b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
32273b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
32283b8acc11SPaolo Bonzinielse
32293b8acc11SPaolo Bonzini  tpm_passthrough=no
32303b8acc11SPaolo Bonzinifi
32313b8acc11SPaolo Bonzini
32323b8acc11SPaolo Bonzini##########################################
3233758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3234758e8e38SVenkateswararao Jujjuri (JV)
3235758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3236758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3237758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3238758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3239f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3240f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3241f2338fb4SPavel Borzenkov#else
32424f26f2b6SAvi Kivity#include <sys/xattr.h>
3243f2338fb4SPavel Borzenkov#endif
3244758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3245758e8e38SVenkateswararao Jujjuri (JV)EOF
32464f26f2b6SAvi Kivity  if compile_prog "" "" ; then
32474f26f2b6SAvi Kivity    attr=yes
32484f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3249f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3250758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3251758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
32524f26f2b6SAvi Kivity    libattr=yes
3253758e8e38SVenkateswararao Jujjuri (JV)  else
3254758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
325521684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3256758e8e38SVenkateswararao Jujjuri (JV)    fi
3257758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3258758e8e38SVenkateswararao Jujjuri (JV)  fi
3259758e8e38SVenkateswararao Jujjuri (JV)fi
3260758e8e38SVenkateswararao Jujjuri (JV)
3261758e8e38SVenkateswararao Jujjuri (JV)##########################################
3262bf9298b9Saliguori# iovec probe
3263bf9298b9Saliguoricat > $TMPC <<EOF
3264db34f0b3Sblueswir1#include <sys/types.h>
3265bf9298b9Saliguori#include <sys/uio.h>
3266db34f0b3Sblueswir1#include <unistd.h>
3267f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3268bf9298b9SaliguoriEOF
3269bf9298b9Saliguoriiovec=no
327052166aa0SJuan Quintelaif compile_prog "" "" ; then
3271bf9298b9Saliguori  iovec=yes
3272bf9298b9Saliguorifi
3273bf9298b9Saliguori
3274f652e6afSaurel32##########################################
3275ceb42de8Saliguori# preadv probe
3276ceb42de8Saliguoricat > $TMPC <<EOF
3277ceb42de8Saliguori#include <sys/types.h>
3278ceb42de8Saliguori#include <sys/uio.h>
3279ceb42de8Saliguori#include <unistd.h>
3280c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3281ceb42de8SaliguoriEOF
3282ceb42de8Saliguoripreadv=no
328352166aa0SJuan Quintelaif compile_prog "" "" ; then
3284ceb42de8Saliguori  preadv=yes
3285ceb42de8Saliguorifi
3286ceb42de8Saliguori
3287ceb42de8Saliguori##########################################
3288f652e6afSaurel32# fdt probe
3289e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3290e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3291e169e1e1SPeter Maydellfdt_required=no
3292e169e1e1SPeter Maydellfor target in $target_list; do
3293e169e1e1SPeter Maydell  case $target in
32946a49fa95SAlexander Graf    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
3295e169e1e1SPeter Maydell      fdt_required=yes
3296e169e1e1SPeter Maydell    ;;
3297e169e1e1SPeter Maydell  esac
3298e169e1e1SPeter Maydelldone
3299e169e1e1SPeter Maydell
3300e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3301e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3302e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3303e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3304e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3305e169e1e1SPeter Maydell  fi
3306e169e1e1SPeter Maydell  fdt=yes
3307e169e1e1SPeter Maydellfi
3308e169e1e1SPeter Maydell
33092df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3310b41af4baSJuan Quintela  fdt_libs="-lfdt"
331196ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
331231ce0adbSThomas Huth  # and test for required functions to make sure we are on a version >= 1.4.0
3313f652e6afSaurel32  cat > $TMPC << EOF
331431ce0adbSThomas Huth#include <libfdt.h>
331596ce6545SPeter Crosthwaite#include <libfdt_env.h>
331631ce0adbSThomas Huthint main(void) { fdt_get_property_by_offset(0, 0, 0); return 0; }
3317f652e6afSaurel32EOF
331852166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3319a540f158SPeter Crosthwaite    # system DTC is good - use it
3320f652e6afSaurel32    fdt=yes
3321a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
3322a540f158SPeter Crosthwaite    # have submodule DTC - use it
3323a540f158SPeter Crosthwaite    fdt=yes
3324a540f158SPeter Crosthwaite    dtc_internal="yes"
3325a540f158SPeter Crosthwaite    mkdir -p dtc
3326cab00a5aSMichael S. Tsirkin    if [ "$pwd_is_source_path" != "y" ] ; then
3327a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3328a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
33292df87df7SJuan Quintela    fi
3330a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3331a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3332a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
3333a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
333431ce0adbSThomas Huth    error_exit "DTC (libfdt) version >= 1.4.0 not present. Your options:" \
33353f281822SStewart Smith        "  (1) Preferred: Install the DTC (libfdt) devel package" \
3336a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
3337a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
3338a540f158SPeter Crosthwaite  else
3339a540f158SPeter Crosthwaite    # don't have and don't want
3340de3a354aSMichael Walle    fdt_libs=
33412df87df7SJuan Quintela    fdt=no
3342f652e6afSaurel32  fi
3343f652e6afSaurel32fi
3344f652e6afSaurel32
3345a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3346a540f158SPeter Crosthwaite
334720ff075bSMichael Walle##########################################
3348fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3349b1546f32SGerd Hoffmann
3350da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3351014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
3352fb719563SOGAWA Hirofumi  if $pkg_config $opengl_pkgs x11; then
3353f676c67eSJeremy White    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3354f676c67eSJeremy White    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3355da076ffeSGerd Hoffmann    opengl=yes
3356925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3357925a0400SGerd Hoffmann        gtk_gl="yes"
3358925a0400SGerd Hoffmann    fi
335920ff075bSMichael Walle  else
3360da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3361dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
336220ff075bSMichael Walle    fi
3363f676c67eSJeremy White    opengl_cflags=""
3364da076ffeSGerd Hoffmann    opengl_libs=""
3365da076ffeSGerd Hoffmann    opengl=no
336620ff075bSMichael Walle  fi
336720ff075bSMichael Wallefi
336820ff075bSMichael Walle
3369014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3370014cb152SGerd Hoffmann  cat > $TMPC << EOF
3371014cb152SGerd Hoffmann#include <epoxy/egl.h>
3372014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3373014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3374014cb152SGerd Hoffmann#endif
3375014cb152SGerd Hoffmannint main(void) { return 0; }
3376014cb152SGerd HoffmannEOF
3377014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3378014cb152SGerd Hoffmann    opengl_dmabuf=yes
3379014cb152SGerd Hoffmann  fi
3380014cb152SGerd Hoffmannfi
3381c9a12e75SChrysostomos Nanakos
3382c9a12e75SChrysostomos Nanakos##########################################
3383c9a12e75SChrysostomos Nanakos# archipelago probe
3384c9a12e75SChrysostomos Nanakosif test "$archipelago" != "no" ; then
3385c9a12e75SChrysostomos Nanakos    cat > $TMPC <<EOF
3386c9a12e75SChrysostomos Nanakos#include <stdio.h>
3387c9a12e75SChrysostomos Nanakos#include <xseg/xseg.h>
3388c9a12e75SChrysostomos Nanakos#include <xseg/protocol.h>
3389c9a12e75SChrysostomos Nanakosint main(void) {
3390c9a12e75SChrysostomos Nanakos    xseg_initialize();
3391c9a12e75SChrysostomos Nanakos    return 0;
3392c9a12e75SChrysostomos Nanakos}
3393c9a12e75SChrysostomos NanakosEOF
3394c9a12e75SChrysostomos Nanakos    archipelago_libs=-lxseg
3395c9a12e75SChrysostomos Nanakos    if compile_prog "" "$archipelago_libs"; then
3396c9a12e75SChrysostomos Nanakos        archipelago="yes"
3397c9a12e75SChrysostomos Nanakos        libs_tools="$archipelago_libs $libs_tools"
3398c9a12e75SChrysostomos Nanakos        libs_softmmu="$archipelago_libs $libs_softmmu"
33996a460ed1SStefan Hajnoczi
34006a460ed1SStefan Hajnoczi	echo "WARNING: Please check the licenses of QEMU and libxseg carefully."
34016a460ed1SStefan Hajnoczi	echo "GPLv3 versions of libxseg may not be compatible with QEMU's"
34026a460ed1SStefan Hajnoczi	echo "license and therefore prevent redistribution."
34036a460ed1SStefan Hajnoczi	echo
34046a460ed1SStefan Hajnoczi	echo "To disable Archipelago, use --disable-archipelago"
3405c9a12e75SChrysostomos Nanakos    else
3406c9a12e75SChrysostomos Nanakos      if test "$archipelago" = "yes" ; then
3407c9a12e75SChrysostomos Nanakos        feature_not_found "Archipelago backend support" "Install libxseg devel"
3408c9a12e75SChrysostomos Nanakos      fi
3409c9a12e75SChrysostomos Nanakos      archipelago="no"
3410c9a12e75SChrysostomos Nanakos    fi
3411c9a12e75SChrysostomos Nanakosfi
3412c9a12e75SChrysostomos Nanakos
3413c9a12e75SChrysostomos Nanakos
3414eb100396SBharata B Rao##########################################
3415eb100396SBharata B Rao# glusterfs probe
3416eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
341765d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3418e01bee08SBharata B Rao    glusterfs="yes"
341989138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
342089138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3421d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3422d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3423d85fa9ebSJeff Cody    fi
342465d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
34250c14fb47SBharata B Rao      glusterfs_discard="yes"
34260c14fb47SBharata B Rao    fi
34277c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
34287c815372SBharata B Rao      glusterfs_zerofill="yes"
34297c815372SBharata B Rao    fi
3430eb100396SBharata B Rao  else
3431eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
34328efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
34338efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3434eb100396SBharata B Rao    fi
3435e01bee08SBharata B Rao    glusterfs="no"
3436eb100396SBharata B Rao  fi
3437eb100396SBharata B Raofi
3438eb100396SBharata B Rao
343939386ac7Saurel32# Check for inotify functions when we are building linux-user
34403b3f24adSaurel32# emulator.  This is done because older glibc versions don't
34413b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
34423b3f24adSaurel32# don't provide them even if kernel supports them.
34433b3f24adSaurel32#
34443b3f24adSaurel32inotify=no
34453b3f24adSaurel32cat > $TMPC << EOF
34463b3f24adSaurel32#include <sys/inotify.h>
34473b3f24adSaurel32
34483b3f24adSaurel32int
34493b3f24adSaurel32main(void)
34503b3f24adSaurel32{
34513b3f24adSaurel32	/* try to start inotify */
34528690e420Saurel32	return inotify_init();
34533b3f24adSaurel32}
34543b3f24adSaurel32EOF
345552166aa0SJuan Quintelaif compile_prog "" "" ; then
34563b3f24adSaurel32  inotify=yes
34573b3f24adSaurel32fi
34583b3f24adSaurel32
3459c05c7a73SRiku Voipioinotify1=no
3460c05c7a73SRiku Voipiocat > $TMPC << EOF
3461c05c7a73SRiku Voipio#include <sys/inotify.h>
3462c05c7a73SRiku Voipio
3463c05c7a73SRiku Voipioint
3464c05c7a73SRiku Voipiomain(void)
3465c05c7a73SRiku Voipio{
3466c05c7a73SRiku Voipio    /* try to start inotify */
3467c05c7a73SRiku Voipio    return inotify_init1(0);
3468c05c7a73SRiku Voipio}
3469c05c7a73SRiku VoipioEOF
3470c05c7a73SRiku Voipioif compile_prog "" "" ; then
3471c05c7a73SRiku Voipio  inotify1=yes
3472c05c7a73SRiku Voipiofi
3473c05c7a73SRiku Voipio
3474ebc996f3SRiku Voipio# check if utimensat and futimens are supported
3475ebc996f3SRiku Voipioutimens=no
3476ebc996f3SRiku Voipiocat > $TMPC << EOF
3477ebc996f3SRiku Voipio#define _ATFILE_SOURCE
3478ebc996f3SRiku Voipio#include <stddef.h>
3479ebc996f3SRiku Voipio#include <fcntl.h>
34803014ee00SPeter Maydell#include <sys/stat.h>
3481ebc996f3SRiku Voipio
3482ebc996f3SRiku Voipioint main(void)
3483ebc996f3SRiku Voipio{
3484ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
3485ebc996f3SRiku Voipio    futimens(0, NULL);
3486ebc996f3SRiku Voipio    return 0;
3487ebc996f3SRiku Voipio}
3488ebc996f3SRiku VoipioEOF
348952166aa0SJuan Quintelaif compile_prog "" "" ; then
3490ebc996f3SRiku Voipio  utimens=yes
3491ebc996f3SRiku Voipiofi
3492ebc996f3SRiku Voipio
3493099d6b0fSRiku Voipio# check if pipe2 is there
3494099d6b0fSRiku Voipiopipe2=no
3495099d6b0fSRiku Voipiocat > $TMPC << EOF
3496099d6b0fSRiku Voipio#include <unistd.h>
3497099d6b0fSRiku Voipio#include <fcntl.h>
3498099d6b0fSRiku Voipio
3499099d6b0fSRiku Voipioint main(void)
3500099d6b0fSRiku Voipio{
3501099d6b0fSRiku Voipio    int pipefd[2];
35029bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3503099d6b0fSRiku Voipio}
3504099d6b0fSRiku VoipioEOF
350552166aa0SJuan Quintelaif compile_prog "" "" ; then
3506099d6b0fSRiku Voipio  pipe2=yes
3507099d6b0fSRiku Voipiofi
3508099d6b0fSRiku Voipio
350940ff6d7eSKevin Wolf# check if accept4 is there
351040ff6d7eSKevin Wolfaccept4=no
351140ff6d7eSKevin Wolfcat > $TMPC << EOF
351240ff6d7eSKevin Wolf#include <sys/socket.h>
351340ff6d7eSKevin Wolf#include <stddef.h>
351440ff6d7eSKevin Wolf
351540ff6d7eSKevin Wolfint main(void)
351640ff6d7eSKevin Wolf{
351740ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
351840ff6d7eSKevin Wolf    return 0;
351940ff6d7eSKevin Wolf}
352040ff6d7eSKevin WolfEOF
352140ff6d7eSKevin Wolfif compile_prog "" "" ; then
352240ff6d7eSKevin Wolf  accept4=yes
352340ff6d7eSKevin Wolffi
352440ff6d7eSKevin Wolf
35253ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
35263ce34dfbSvibisreenivasansplice=no
35273ce34dfbSvibisreenivasancat > $TMPC << EOF
35283ce34dfbSvibisreenivasan#include <unistd.h>
35293ce34dfbSvibisreenivasan#include <fcntl.h>
35303ce34dfbSvibisreenivasan#include <limits.h>
35313ce34dfbSvibisreenivasan
35323ce34dfbSvibisreenivasanint main(void)
35333ce34dfbSvibisreenivasan{
353466ea0f22SStefan Weil    int len, fd = 0;
35353ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
35363ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
35373ce34dfbSvibisreenivasan    return 0;
35383ce34dfbSvibisreenivasan}
35393ce34dfbSvibisreenivasanEOF
354052166aa0SJuan Quintelaif compile_prog "" "" ; then
35413ce34dfbSvibisreenivasan  splice=yes
35423ce34dfbSvibisreenivasanfi
35433ce34dfbSvibisreenivasan
3544dcc38d1cSMarcelo Tosatti##########################################
3545a99d57bbSWanlong Gao# libnuma probe
3546a99d57bbSWanlong Gao
3547a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3548a99d57bbSWanlong Gao  cat > $TMPC << EOF
3549a99d57bbSWanlong Gao#include <numa.h>
3550a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3551a99d57bbSWanlong GaoEOF
3552a99d57bbSWanlong Gao
3553a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3554a99d57bbSWanlong Gao    numa=yes
3555a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
3556a99d57bbSWanlong Gao  else
3557a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3558a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3559a99d57bbSWanlong Gao    fi
3560a99d57bbSWanlong Gao    numa=no
3561a99d57bbSWanlong Gao  fi
3562a99d57bbSWanlong Gaofi
3563a99d57bbSWanlong Gao
35647b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
35657b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
35667b01cb97SAlexandre Derumier    exit 1
35677b01cb97SAlexandre Derumierfi
35687b01cb97SAlexandre Derumier
3569a99d57bbSWanlong Gao##########################################
35702847b469SFam Zheng# tcmalloc probe
35712847b469SFam Zheng
35722847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
35732847b469SFam Zheng  cat > $TMPC << EOF
35742847b469SFam Zheng#include <stdlib.h>
35752847b469SFam Zhengint main(void) { malloc(1); return 0; }
35762847b469SFam ZhengEOF
35772847b469SFam Zheng
35782847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
35792847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
35802847b469SFam Zheng  else
35812847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
35822847b469SFam Zheng  fi
35832847b469SFam Zhengfi
35842847b469SFam Zheng
35852847b469SFam Zheng##########################################
35867b01cb97SAlexandre Derumier# jemalloc probe
35877b01cb97SAlexandre Derumier
35887b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
35897b01cb97SAlexandre Derumier  cat > $TMPC << EOF
35907b01cb97SAlexandre Derumier#include <stdlib.h>
35917b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
35927b01cb97SAlexandre DerumierEOF
35937b01cb97SAlexandre Derumier
35947b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
35957b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
35967b01cb97SAlexandre Derumier  else
35977b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
35987b01cb97SAlexandre Derumier  fi
35997b01cb97SAlexandre Derumierfi
36007b01cb97SAlexandre Derumier
36017b01cb97SAlexandre Derumier##########################################
3602dcc38d1cSMarcelo Tosatti# signalfd probe
3603dcc38d1cSMarcelo Tosattisignalfd="no"
3604dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3605dcc38d1cSMarcelo Tosatti#include <unistd.h>
3606dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3607dcc38d1cSMarcelo Tosatti#include <signal.h>
3608dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3609dcc38d1cSMarcelo TosattiEOF
3610dcc38d1cSMarcelo Tosatti
3611dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3612dcc38d1cSMarcelo Tosatti  signalfd=yes
3613dcc38d1cSMarcelo Tosattifi
3614dcc38d1cSMarcelo Tosatti
3615c2882b96SRiku Voipio# check if eventfd is supported
3616c2882b96SRiku Voipioeventfd=no
3617c2882b96SRiku Voipiocat > $TMPC << EOF
3618c2882b96SRiku Voipio#include <sys/eventfd.h>
3619c2882b96SRiku Voipio
3620c2882b96SRiku Voipioint main(void)
3621c2882b96SRiku Voipio{
362255cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3623c2882b96SRiku Voipio}
3624c2882b96SRiku VoipioEOF
3625c2882b96SRiku Voipioif compile_prog "" "" ; then
3626c2882b96SRiku Voipio  eventfd=yes
3627c2882b96SRiku Voipiofi
3628c2882b96SRiku Voipio
3629751bcc39SMarc-André Lureau# check if memfd is supported
3630751bcc39SMarc-André Lureaumemfd=no
3631751bcc39SMarc-André Lureaucat > $TMPC << EOF
3632751bcc39SMarc-André Lureau#include <sys/memfd.h>
3633751bcc39SMarc-André Lureau
3634751bcc39SMarc-André Lureauint main(void)
3635751bcc39SMarc-André Lureau{
3636751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3637751bcc39SMarc-André Lureau}
3638751bcc39SMarc-André LureauEOF
3639751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3640751bcc39SMarc-André Lureau  memfd=yes
3641751bcc39SMarc-André Lureaufi
3642751bcc39SMarc-André Lureau
3643751bcc39SMarc-André Lureau
3644751bcc39SMarc-André Lureau
3645d0927938SUlrich Hecht# check for fallocate
3646d0927938SUlrich Hechtfallocate=no
3647d0927938SUlrich Hechtcat > $TMPC << EOF
3648d0927938SUlrich Hecht#include <fcntl.h>
3649d0927938SUlrich Hecht
3650d0927938SUlrich Hechtint main(void)
3651d0927938SUlrich Hecht{
3652d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3653d0927938SUlrich Hecht    return 0;
3654d0927938SUlrich Hecht}
3655d0927938SUlrich HechtEOF
36568fb03151SPeter Maydellif compile_prog "" "" ; then
3657d0927938SUlrich Hecht  fallocate=yes
3658d0927938SUlrich Hechtfi
3659d0927938SUlrich Hecht
36603d4fa43eSKusanagi Kouichi# check for fallocate hole punching
36613d4fa43eSKusanagi Kouichifallocate_punch_hole=no
36623d4fa43eSKusanagi Kouichicat > $TMPC << EOF
36633d4fa43eSKusanagi Kouichi#include <fcntl.h>
36643d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
36653d4fa43eSKusanagi Kouichi
36663d4fa43eSKusanagi Kouichiint main(void)
36673d4fa43eSKusanagi Kouichi{
36683d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
36693d4fa43eSKusanagi Kouichi    return 0;
36703d4fa43eSKusanagi Kouichi}
36713d4fa43eSKusanagi KouichiEOF
36723d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
36733d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
36743d4fa43eSKusanagi Kouichifi
36753d4fa43eSKusanagi Kouichi
3676b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3677b953f075SDenis V. Lunevfallocate_zero_range=no
3678b953f075SDenis V. Lunevcat > $TMPC << EOF
3679b953f075SDenis V. Lunev#include <fcntl.h>
3680b953f075SDenis V. Lunev#include <linux/falloc.h>
3681b953f075SDenis V. Lunev
3682b953f075SDenis V. Lunevint main(void)
3683b953f075SDenis V. Lunev{
3684b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3685b953f075SDenis V. Lunev    return 0;
3686b953f075SDenis V. Lunev}
3687b953f075SDenis V. LunevEOF
3688b953f075SDenis V. Lunevif compile_prog "" "" ; then
3689b953f075SDenis V. Lunev  fallocate_zero_range=yes
3690b953f075SDenis V. Lunevfi
3691b953f075SDenis V. Lunev
3692ed911435SKevin Wolf# check for posix_fallocate
3693ed911435SKevin Wolfposix_fallocate=no
3694ed911435SKevin Wolfcat > $TMPC << EOF
3695ed911435SKevin Wolf#include <fcntl.h>
3696ed911435SKevin Wolf
3697ed911435SKevin Wolfint main(void)
3698ed911435SKevin Wolf{
3699ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3700ed911435SKevin Wolf    return 0;
3701ed911435SKevin Wolf}
3702ed911435SKevin WolfEOF
3703ed911435SKevin Wolfif compile_prog "" "" ; then
3704ed911435SKevin Wolf    posix_fallocate=yes
3705ed911435SKevin Wolffi
3706ed911435SKevin Wolf
3707c727f47dSPeter Maydell# check for sync_file_range
3708c727f47dSPeter Maydellsync_file_range=no
3709c727f47dSPeter Maydellcat > $TMPC << EOF
3710c727f47dSPeter Maydell#include <fcntl.h>
3711c727f47dSPeter Maydell
3712c727f47dSPeter Maydellint main(void)
3713c727f47dSPeter Maydell{
3714c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3715c727f47dSPeter Maydell    return 0;
3716c727f47dSPeter Maydell}
3717c727f47dSPeter MaydellEOF
37188fb03151SPeter Maydellif compile_prog "" "" ; then
3719c727f47dSPeter Maydell  sync_file_range=yes
3720c727f47dSPeter Maydellfi
3721c727f47dSPeter Maydell
3722dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3723dace20dcSPeter Maydellfiemap=no
3724dace20dcSPeter Maydellcat > $TMPC << EOF
3725dace20dcSPeter Maydell#include <sys/ioctl.h>
3726dace20dcSPeter Maydell#include <linux/fs.h>
3727dace20dcSPeter Maydell#include <linux/fiemap.h>
3728dace20dcSPeter Maydell
3729dace20dcSPeter Maydellint main(void)
3730dace20dcSPeter Maydell{
3731dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3732dace20dcSPeter Maydell    return 0;
3733dace20dcSPeter Maydell}
3734dace20dcSPeter MaydellEOF
37358fb03151SPeter Maydellif compile_prog "" "" ; then
3736dace20dcSPeter Maydell  fiemap=yes
3737dace20dcSPeter Maydellfi
3738dace20dcSPeter Maydell
3739d0927938SUlrich Hecht# check for dup3
3740d0927938SUlrich Hechtdup3=no
3741d0927938SUlrich Hechtcat > $TMPC << EOF
3742d0927938SUlrich Hecht#include <unistd.h>
3743d0927938SUlrich Hecht
3744d0927938SUlrich Hechtint main(void)
3745d0927938SUlrich Hecht{
3746d0927938SUlrich Hecht    dup3(0, 0, 0);
3747d0927938SUlrich Hecht    return 0;
3748d0927938SUlrich Hecht}
3749d0927938SUlrich HechtEOF
375078f5d726SJan Kiszkaif compile_prog "" "" ; then
3751d0927938SUlrich Hecht  dup3=yes
3752d0927938SUlrich Hechtfi
3753d0927938SUlrich Hecht
37544e0c6529SAlex Bligh# check for ppoll support
37554e0c6529SAlex Blighppoll=no
37564e0c6529SAlex Blighcat > $TMPC << EOF
37574e0c6529SAlex Bligh#include <poll.h>
37584e0c6529SAlex Bligh
37594e0c6529SAlex Blighint main(void)
37604e0c6529SAlex Bligh{
37614e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
37624e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
37634e0c6529SAlex Bligh    return 0;
37644e0c6529SAlex Bligh}
37654e0c6529SAlex BlighEOF
37664e0c6529SAlex Blighif compile_prog "" "" ; then
37674e0c6529SAlex Bligh  ppoll=yes
37684e0c6529SAlex Blighfi
37694e0c6529SAlex Bligh
3770cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3771cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3772cd758dd0SAlex Blighcat > $TMPC << EOF
3773cd758dd0SAlex Bligh#include <sys/prctl.h>
3774cd758dd0SAlex Bligh
3775cd758dd0SAlex Blighint main(void)
3776cd758dd0SAlex Bligh{
3777cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3778cd758dd0SAlex Bligh    return 0;
3779cd758dd0SAlex Bligh}
3780cd758dd0SAlex BlighEOF
3781cd758dd0SAlex Blighif compile_prog "" "" ; then
3782cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3783cd758dd0SAlex Blighfi
3784cd758dd0SAlex Bligh
37853b6edd16SPeter Maydell# check for epoll support
37863b6edd16SPeter Maydellepoll=no
37873b6edd16SPeter Maydellcat > $TMPC << EOF
37883b6edd16SPeter Maydell#include <sys/epoll.h>
37893b6edd16SPeter Maydell
37903b6edd16SPeter Maydellint main(void)
37913b6edd16SPeter Maydell{
37923b6edd16SPeter Maydell    epoll_create(0);
37933b6edd16SPeter Maydell    return 0;
37943b6edd16SPeter Maydell}
37953b6edd16SPeter MaydellEOF
37968fb03151SPeter Maydellif compile_prog "" "" ; then
37973b6edd16SPeter Maydell  epoll=yes
37983b6edd16SPeter Maydellfi
37993b6edd16SPeter Maydell
3800227f0214SPeter Maydell# epoll_create1 is a later addition
3801227f0214SPeter Maydell# so we must check separately for its presence
38023b6edd16SPeter Maydellepoll_create1=no
38033b6edd16SPeter Maydellcat > $TMPC << EOF
38043b6edd16SPeter Maydell#include <sys/epoll.h>
38053b6edd16SPeter Maydell
38063b6edd16SPeter Maydellint main(void)
38073b6edd16SPeter Maydell{
380819e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
380919e83f6bSPeter Maydell     * a function being called. This is necessary so that on
381019e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
381119e83f6bSPeter Maydell     * the library but not declared in the header file we will
381219e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
381319e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
381419e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
381519e83f6bSPeter Maydell     */
3816c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
38173b6edd16SPeter Maydell}
38183b6edd16SPeter MaydellEOF
38198fb03151SPeter Maydellif compile_prog "" "" ; then
38203b6edd16SPeter Maydell  epoll_create1=yes
38213b6edd16SPeter Maydellfi
38223b6edd16SPeter Maydell
3823a8fd1abaSPeter Maydell# check for sendfile support
3824a8fd1abaSPeter Maydellsendfile=no
3825a8fd1abaSPeter Maydellcat > $TMPC << EOF
3826a8fd1abaSPeter Maydell#include <sys/sendfile.h>
3827a8fd1abaSPeter Maydell
3828a8fd1abaSPeter Maydellint main(void)
3829a8fd1abaSPeter Maydell{
3830a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
3831a8fd1abaSPeter Maydell}
3832a8fd1abaSPeter MaydellEOF
3833a8fd1abaSPeter Maydellif compile_prog "" "" ; then
3834a8fd1abaSPeter Maydell  sendfile=yes
3835a8fd1abaSPeter Maydellfi
3836a8fd1abaSPeter Maydell
383751834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
383851834341SRiku Voipiotimerfd=no
383951834341SRiku Voipiocat > $TMPC << EOF
384051834341SRiku Voipio#include <sys/timerfd.h>
384151834341SRiku Voipio
384251834341SRiku Voipioint main(void)
384351834341SRiku Voipio{
384451834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
384551834341SRiku Voipio}
384651834341SRiku VoipioEOF
384751834341SRiku Voipioif compile_prog "" "" ; then
384851834341SRiku Voipio  timerfd=yes
384951834341SRiku Voipiofi
385051834341SRiku Voipio
38519af5c906SRiku Voipio# check for setns and unshare support
38529af5c906SRiku Voipiosetns=no
38539af5c906SRiku Voipiocat > $TMPC << EOF
38549af5c906SRiku Voipio#include <sched.h>
38559af5c906SRiku Voipio
38569af5c906SRiku Voipioint main(void)
38579af5c906SRiku Voipio{
38589af5c906SRiku Voipio    int ret;
38599af5c906SRiku Voipio    ret = setns(0, 0);
38609af5c906SRiku Voipio    ret = unshare(0);
38619af5c906SRiku Voipio    return ret;
38629af5c906SRiku Voipio}
38639af5c906SRiku VoipioEOF
38649af5c906SRiku Voipioif compile_prog "" "" ; then
38659af5c906SRiku Voipio  setns=yes
38669af5c906SRiku Voipiofi
38679af5c906SRiku Voipio
3868cc8ae6deSpbrook# Check if tools are available to build documentation.
3869a25dba17SJuan Quintelaif test "$docs" != "no" ; then
387001668d98SStefan Weil  if has makeinfo && has pod2man; then
3871a25dba17SJuan Quintela    docs=yes
387283a3ab8bSJuan Quintela  else
3873a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
387421684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
387583a3ab8bSJuan Quintela    fi
3876a25dba17SJuan Quintela    docs=no
387783a3ab8bSJuan Quintela  fi
3878cc8ae6deSpbrookfi
3879cc8ae6deSpbrook
3880f514f41cSStefan Weil# Search for bswap_32 function
38816ae9a1f4SJuan Quintelabyteswap_h=no
38826ae9a1f4SJuan Quintelacat > $TMPC << EOF
38836ae9a1f4SJuan Quintela#include <byteswap.h>
38846ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
38856ae9a1f4SJuan QuintelaEOF
388652166aa0SJuan Quintelaif compile_prog "" "" ; then
38876ae9a1f4SJuan Quintela  byteswap_h=yes
38886ae9a1f4SJuan Quintelafi
38896ae9a1f4SJuan Quintela
389075f13596SStefan Weil# Search for bswap32 function
38916ae9a1f4SJuan Quintelabswap_h=no
38926ae9a1f4SJuan Quintelacat > $TMPC << EOF
38936ae9a1f4SJuan Quintela#include <sys/endian.h>
38946ae9a1f4SJuan Quintela#include <sys/types.h>
38956ae9a1f4SJuan Quintela#include <machine/bswap.h>
38966ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
38976ae9a1f4SJuan QuintelaEOF
389852166aa0SJuan Quintelaif compile_prog "" "" ; then
38996ae9a1f4SJuan Quintela  bswap_h=yes
39006ae9a1f4SJuan Quintelafi
39016ae9a1f4SJuan Quintela
3902da93a1fdSaliguori##########################################
3903e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
3904c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
3905e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
39063c33ea96SPaolo Bonzini    libiscsi="yes"
3907ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
3908ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
3909c589b249SRonnie Sahlberg  else
3910c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
3911e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
3912c589b249SRonnie Sahlberg    fi
3913c589b249SRonnie Sahlberg    libiscsi="no"
3914c589b249SRonnie Sahlberg  fi
3915c589b249SRonnie Sahlbergfi
3916c589b249SRonnie Sahlberg
3917c589b249SRonnie Sahlberg##########################################
39188bacde8dSNatanael Copa# Do we need libm
39198bacde8dSNatanael Copacat > $TMPC << EOF
39208bacde8dSNatanael Copa#include <math.h>
3921f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
39228bacde8dSNatanael CopaEOF
39238bacde8dSNatanael Copaif compile_prog "" "" ; then
39248bacde8dSNatanael Copa  :
39258bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
39268bacde8dSNatanael Copa  LIBS="-lm $LIBS"
39278bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
39288bacde8dSNatanael Copaelse
392976ad07a4SPeter Maydell  error_exit "libm check failed"
39308bacde8dSNatanael Copafi
39318bacde8dSNatanael Copa
39328bacde8dSNatanael Copa##########################################
3933da93a1fdSaliguori# Do we need librt
39348bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
39358bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
39368bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
39378bacde8dSNatanael Copa# function in addition.
3938da93a1fdSaliguoricat > $TMPC <<EOF
3939da93a1fdSaliguori#include <signal.h>
3940da93a1fdSaliguori#include <time.h>
39418bacde8dSNatanael Copaint main(void) {
39428bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
39438bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
39448bacde8dSNatanael Copa}
3945da93a1fdSaliguoriEOF
3946da93a1fdSaliguori
394752166aa0SJuan Quintelaif compile_prog "" "" ; then
394807ffa4bdSJuan Quintela  :
39498bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
395018e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
395118e588b1SRick Liu  LIBS="$LIBS -lrt"
395218e588b1SRick Liu  libs_qga="$libs_qga -lrt"
3953da93a1fdSaliguorifi
3954da93a1fdSaliguori
395531ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
3956179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
39576362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
39586362a53fSJuan Quintelafi
39596362a53fSJuan Quintela
3960de5071c5SBlue Swirl##########################################
3961cd4ec0b4SGerd Hoffmann# spice probe
3962cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3963cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3964cd4ec0b4SGerd Hoffmann#include <spice.h>
3965cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3966cd4ec0b4SGerd HoffmannEOF
3967710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3968710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
396965d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
397065d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
3971cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3972cd4ec0b4SGerd Hoffmann    spice="yes"
3973cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
3974cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
39752e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
39762e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
3977cd4ec0b4SGerd Hoffmann  else
3978cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
39798efc9363SHu Tao      feature_not_found "spice" \
39808efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
3981cd4ec0b4SGerd Hoffmann    fi
3982cd4ec0b4SGerd Hoffmann    spice="no"
3983cd4ec0b4SGerd Hoffmann  fi
3984cd4ec0b4SGerd Hoffmannfi
3985cd4ec0b4SGerd Hoffmann
39867b02f544SMarc-André Lureau# check for smartcard support
3987111a38b0SRobert Relyeasmartcard_cflags=""
39887b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
39897b02f544SMarc-André Lureau    if $pkg_config libcacard; then
39907b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
39917b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
39927b02f544SMarc-André Lureau        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
39937b02f544SMarc-André Lureau        libs_softmmu="$libs_softmmu $libcacard_libs"
39947b02f544SMarc-André Lureau        smartcard="yes"
3995111a38b0SRobert Relyea    else
39967b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
39977b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
3998111a38b0SRobert Relyea        fi
39997b02f544SMarc-André Lureau        smartcard="no"
4000111a38b0SRobert Relyea    fi
4001111a38b0SRobert Relyeafi
4002111a38b0SRobert Relyea
40032b2325ffSGerd Hoffmann# check for libusb
40042b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
400565d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
40062b2325ffSGerd Hoffmann        libusb="yes"
4007ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4008ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
40092b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
40102b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
40112b2325ffSGerd Hoffmann    else
40122b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
40138efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
40142b2325ffSGerd Hoffmann        fi
40152b2325ffSGerd Hoffmann        libusb="no"
40162b2325ffSGerd Hoffmann    fi
40172b2325ffSGerd Hoffmannfi
40182b2325ffSGerd Hoffmann
401969354a83SHans de Goede# check for usbredirparser for usb network redirection support
402069354a83SHans de Goedeif test "$usb_redir" != "no" ; then
402165d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
402269354a83SHans de Goede        usb_redir="yes"
4023ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4024ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
402569354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
402656ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
402769354a83SHans de Goede    else
402869354a83SHans de Goede        if test "$usb_redir" = "yes"; then
402921684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
403069354a83SHans de Goede        fi
403169354a83SHans de Goede        usb_redir="no"
403269354a83SHans de Goede    fi
403369354a83SHans de Goedefi
403469354a83SHans de Goede
4035cd4ec0b4SGerd Hoffmann##########################################
4036d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4037d9840e25STomoki Sekiyama
4038d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4039d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4040d9840e25STomoki Sekiyama    "")   vss_win32_include="-I$source_path" ;;
4041d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4042d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4043d9840e25STomoki Sekiyama          vss_win32_include="-I$source_path/.sdk/vss"
4044d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4045d9840e25STomoki Sekiyama	  ;;
4046d9840e25STomoki Sekiyama    *)    vss_win32_include="-I$vss_win32_sdk"
4047d9840e25STomoki Sekiyama  esac
4048d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4049d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4050d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4051d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4052d9840e25STomoki SekiyamaEOF
4053d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4054d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4055d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4056d9840e25STomoki Sekiyama    libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4057f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4058d9840e25STomoki Sekiyama  else
4059d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4060d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4061d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4062d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4063d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4064d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4065d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4066d9840e25STomoki Sekiyama    fi
4067d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4068d9840e25STomoki Sekiyama  fi
4069d9840e25STomoki Sekiyamafi
4070d9840e25STomoki Sekiyama
4071d9840e25STomoki Sekiyama##########################################
4072d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4073d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4074d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4075d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4076d9840e25STomoki Sekiyama
4077d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4078d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4079d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4080d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4081d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4082d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4083d9840e25STomoki Sekiyama    else
4084d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4085d9840e25STomoki Sekiyama    fi
4086d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4087d9840e25STomoki Sekiyama    win_sdk=""
4088d9840e25STomoki Sekiyama  fi
4089d9840e25STomoki Sekiyamafi
4090d9840e25STomoki Sekiyama
4091d9840e25STomoki Sekiyama##########################################
409250cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
409350cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
409450cbebb9SMichael Roth  cat > $TMPC << EOF
409550cbebb9SMichael Roth#include <windows.h>
409650cbebb9SMichael Roth#include <ntddscsi.h>
409750cbebb9SMichael Rothint main(void) {
409850cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
409950cbebb9SMichael Roth#error Missing required ioctl definitions
410050cbebb9SMichael Roth#endif
410150cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
410250cbebb9SMichael Roth  return addr.Lun;
410350cbebb9SMichael Roth}
410450cbebb9SMichael RothEOF
410550cbebb9SMichael Roth  if compile_prog "" "" ; then
410650cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4107c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
410850cbebb9SMichael Roth  fi
410950cbebb9SMichael Rothfi
411050cbebb9SMichael Roth
411150cbebb9SMichael Roth##########################################
41129d9e1521SGerd Hoffmann# virgl renderer probe
41139d9e1521SGerd Hoffmann
41149d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
41159d9e1521SGerd Hoffmann  cat > $TMPC << EOF
41169d9e1521SGerd Hoffmann#include <virglrenderer.h>
41179d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
41189d9e1521SGerd HoffmannEOF
41199d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
41209d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
41219d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
41229d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
41239d9e1521SGerd Hoffmann    virglrenderer="yes"
41249d9e1521SGerd Hoffmann  else
41259d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
41269d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
41279d9e1521SGerd Hoffmann    fi
41289d9e1521SGerd Hoffmann    virglrenderer="no"
41299d9e1521SGerd Hoffmann  fi
41309d9e1521SGerd Hoffmannfi
41319d9e1521SGerd Hoffmann
41329d9e1521SGerd Hoffmann##########################################
41335f6b9e8fSBlue Swirl# check if we have fdatasync
41345f6b9e8fSBlue Swirl
41355f6b9e8fSBlue Swirlfdatasync=no
41365f6b9e8fSBlue Swirlcat > $TMPC << EOF
41375f6b9e8fSBlue Swirl#include <unistd.h>
4138d1722a27SAlexandre Raymondint main(void) {
4139d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4140d1722a27SAlexandre Raymondreturn fdatasync(0);
4141d1722a27SAlexandre Raymond#else
4142e172fe11SStefan Weil#error Not supported
4143d1722a27SAlexandre Raymond#endif
4144d1722a27SAlexandre Raymond}
41455f6b9e8fSBlue SwirlEOF
41465f6b9e8fSBlue Swirlif compile_prog "" "" ; then
41475f6b9e8fSBlue Swirl    fdatasync=yes
41485f6b9e8fSBlue Swirlfi
41495f6b9e8fSBlue Swirl
415094a420b1SStefan Hajnoczi##########################################
4151e78815a5SAndreas Färber# check if we have madvise
4152e78815a5SAndreas Färber
4153e78815a5SAndreas Färbermadvise=no
4154e78815a5SAndreas Färbercat > $TMPC << EOF
4155e78815a5SAndreas Färber#include <sys/types.h>
4156e78815a5SAndreas Färber#include <sys/mman.h>
4157832ce9c2SScott Wood#include <stddef.h>
4158e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4159e78815a5SAndreas FärberEOF
4160e78815a5SAndreas Färberif compile_prog "" "" ; then
4161e78815a5SAndreas Färber    madvise=yes
4162e78815a5SAndreas Färberfi
4163e78815a5SAndreas Färber
4164e78815a5SAndreas Färber##########################################
4165e78815a5SAndreas Färber# check if we have posix_madvise
4166e78815a5SAndreas Färber
4167e78815a5SAndreas Färberposix_madvise=no
4168e78815a5SAndreas Färbercat > $TMPC << EOF
4169e78815a5SAndreas Färber#include <sys/mman.h>
4170832ce9c2SScott Wood#include <stddef.h>
4171e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4172e78815a5SAndreas FärberEOF
4173e78815a5SAndreas Färberif compile_prog "" "" ; then
4174e78815a5SAndreas Färber    posix_madvise=yes
4175e78815a5SAndreas Färberfi
4176e78815a5SAndreas Färber
4177e78815a5SAndreas Färber##########################################
41781e9737daSRichard Henderson# check if we have usable SIGEV_THREAD_ID
41791e9737daSRichard Henderson
41801e9737daSRichard Hendersonsigev_thread_id=no
41811e9737daSRichard Hendersoncat > $TMPC << EOF
41821e9737daSRichard Henderson#include <signal.h>
41831e9737daSRichard Hendersonint main(void) {
41841e9737daSRichard Henderson  struct sigevent ev;
41851e9737daSRichard Henderson  ev.sigev_notify = SIGEV_THREAD_ID;
41861e9737daSRichard Henderson  ev._sigev_un._tid = 0;
41871e9737daSRichard Henderson  asm volatile("" : : "g"(&ev));
41881e9737daSRichard Henderson  return 0;
41891e9737daSRichard Henderson}
41901e9737daSRichard HendersonEOF
41911e9737daSRichard Hendersonif compile_prog "" "" ; then
41921e9737daSRichard Henderson    sigev_thread_id=yes
41931e9737daSRichard Hendersonfi
41941e9737daSRichard Henderson
41951e9737daSRichard Henderson##########################################
419694a420b1SStefan Hajnoczi# check if trace backend exists
419794a420b1SStefan Hajnoczi
41985b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
419994a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
42005b808275SLluís Vilanova  error_exit "invalid trace backends" \
42015b808275SLluís Vilanova      "Please choose supported trace backends."
420294a420b1SStefan Hajnoczifi
420394a420b1SStefan Hajnoczi
42047e24e92aSStefan Hajnoczi##########################################
42057e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
42065b808275SLluís Vilanovaif have_backend "ust"; then
42077e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4208bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
42097e24e92aSStefan Hajnocziint main(void) { return 0; }
42107e24e92aSStefan HajnocziEOF
42117e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
4212bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
421389138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
42147e24e92aSStefan Hajnoczi    else
4215bf15f63cSMohamad Gebai      lttng_ust_libs="-llttng-ust"
4216bf15f63cSMohamad Gebai    fi
4217bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
421889138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4219bf15f63cSMohamad Gebai    else
4220bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4221bf15f63cSMohamad Gebai    fi
4222bf15f63cSMohamad Gebai
4223bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4224bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4225bf15f63cSMohamad Gebai  else
4226bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
42277e24e92aSStefan Hajnoczi  fi
42287e24e92aSStefan Hajnoczifi
4229b3d08c02SDaniel P. Berrange
4230b3d08c02SDaniel P. Berrange##########################################
4231b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
42325b808275SLluís Vilanovaif have_backend "dtrace"; then
4233b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
423476ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4235b3d08c02SDaniel P. Berrange  fi
4236c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4237c276b17dSDaniel P. Berrange  if has 'stap' ; then
4238c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4239c276b17dSDaniel P. Berrange  fi
4240b3d08c02SDaniel P. Berrangefi
4241b3d08c02SDaniel P. Berrange
42427e24e92aSStefan Hajnoczi##########################################
4243519175a2SAlex Barcelo# check and set a backend for coroutine
4244d0e2fce5SAneesh Kumar K.V
42457c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
42467c2acc70SPeter Maydell# is sigcontext. gthread is not selectable except explicitly, because
42477c2acc70SPeter Maydell# it is not functional enough to run QEMU proper. (It is occasionally
42487c2acc70SPeter Maydell# useful for debugging purposes.)  On Windows the only valid backend
42497c2acc70SPeter Maydell# is the Windows-specific one.
42507c2acc70SPeter Maydell
42517c2acc70SPeter Maydellucontext_works=no
4252d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4253d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4254d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4255cdf84806SPeter Maydell#ifdef __stub_makecontext
4256cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4257cdf84806SPeter Maydell#endif
425875cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4259d0e2fce5SAneesh Kumar K.VEOF
4260d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
42617c2acc70SPeter Maydell    ucontext_works=yes
4262d0e2fce5SAneesh Kumar K.V  fi
4263519175a2SAlex Barcelofi
42647c2acc70SPeter Maydell
42657c2acc70SPeter Maydellif test "$coroutine" = ""; then
42667c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
42677c2acc70SPeter Maydell    coroutine=win32
42687c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
42697c2acc70SPeter Maydell    coroutine=ucontext
4270519175a2SAlex Barcelo  else
42717c2acc70SPeter Maydell    coroutine=sigaltstack
42727c2acc70SPeter Maydell  fi
42737c2acc70SPeter Maydellelse
42747c2acc70SPeter Maydell  case $coroutine in
42757c2acc70SPeter Maydell  windows)
42767c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
42777c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
42787c2acc70SPeter Maydell    fi
42797c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
42807c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
42817c2acc70SPeter Maydell    coroutine=win32
42827c2acc70SPeter Maydell    ;;
42837c2acc70SPeter Maydell  ucontext)
42847c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
42857c2acc70SPeter Maydell      feature_not_found "ucontext"
42867c2acc70SPeter Maydell    fi
42877c2acc70SPeter Maydell    ;;
42887c2acc70SPeter Maydell  gthread|sigaltstack)
42897c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
42907c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
42917c2acc70SPeter Maydell    fi
42927c2acc70SPeter Maydell    ;;
42937c2acc70SPeter Maydell  *)
429476ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
42957c2acc70SPeter Maydell    ;;
42967c2acc70SPeter Maydell  esac
4297d0e2fce5SAneesh Kumar K.Vfi
4298d0e2fce5SAneesh Kumar K.V
429970c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
430070c60c08SStefan Hajnoczi  if test "$coroutine" = "gthread"; then
430170c60c08SStefan Hajnoczi    coroutine_pool=no
430270c60c08SStefan Hajnoczi  else
430370c60c08SStefan Hajnoczi    coroutine_pool=yes
430470c60c08SStefan Hajnoczi  fi
430570c60c08SStefan Hajnoczifi
430670c60c08SStefan Hajnocziif test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
430770c60c08SStefan Hajnoczi  error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
430870c60c08SStefan Hajnoczifi
430970c60c08SStefan Hajnoczi
4310d0e2fce5SAneesh Kumar K.V##########################################
4311d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4312d2042378SAneesh Kumar K.V
43134e1797f9SStefan Weilopen_by_handle_at=no
4314d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4315d2042378SAneesh Kumar K.V#include <fcntl.h>
4316acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4317acc55ba8SStefan Weil# error missing definition
4318acc55ba8SStefan Weil#else
431975cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4320acc55ba8SStefan Weil#endif
4321d2042378SAneesh Kumar K.VEOF
4322d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4323d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4324d2042378SAneesh Kumar K.Vfi
4325d2042378SAneesh Kumar K.V
4326e06a765eSHarsh Prateek Bora########################################
4327e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4328e06a765eSHarsh Prateek Bora
4329e06a765eSHarsh Prateek Boralinux_magic_h=no
4330e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4331e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4332e06a765eSHarsh Prateek Boraint main(void) {
433375cafad7SStefan Weil  return 0;
4334e06a765eSHarsh Prateek Bora}
4335e06a765eSHarsh Prateek BoraEOF
4336e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4337e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4338e06a765eSHarsh Prateek Borafi
4339e06a765eSHarsh Prateek Bora
43408ab1bf12SLuiz Capitulino########################################
4341c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4342c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4343c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4344c95e3080SKevin Wolf# only a warning.
4345c95e3080SKevin Wolf#
4346c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4347c95e3080SKevin Wolf# the build doesn't fail anyway.
4348c95e3080SKevin Wolf
434906d71fa1SPeter Maydellpragma_disable_unused_but_set=no
435006d71fa1SPeter Maydellcat > $TMPC << EOF
4351e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
435206d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4353c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4354e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4355c95e3080SKevin Wolf
435606d71fa1SPeter Maydellint main(void) {
435706d71fa1SPeter Maydell    return 0;
435806d71fa1SPeter Maydell}
435906d71fa1SPeter MaydellEOF
436006d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4361cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4362c95e3080SKevin Wolfelse
4363c95e3080SKevin Wolf    werror=no
436406d71fa1SPeter Maydellfi
436506d71fa1SPeter Maydell
436606d71fa1SPeter Maydell########################################
4367541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
43683f4349dcSKevin Wolf
43693f4349dcSKevin Wolfvalgrind_h=no
43703f4349dcSKevin Wolfcat > $TMPC << EOF
43713f4349dcSKevin Wolf#include <valgrind/valgrind.h>
43723f4349dcSKevin Wolfint main(void) {
43733f4349dcSKevin Wolf  return 0;
43743f4349dcSKevin Wolf}
43753f4349dcSKevin WolfEOF
43763f4349dcSKevin Wolfif compile_prog "" "" ; then
43773f4349dcSKevin Wolf    valgrind_h=yes
43783f4349dcSKevin Wolffi
43793f4349dcSKevin Wolf
43803f4349dcSKevin Wolf########################################
43818ab1bf12SLuiz Capitulino# check if environ is declared
43828ab1bf12SLuiz Capitulino
43838ab1bf12SLuiz Capitulinohas_environ=no
43848ab1bf12SLuiz Capitulinocat > $TMPC << EOF
43858ab1bf12SLuiz Capitulino#include <unistd.h>
43868ab1bf12SLuiz Capitulinoint main(void) {
4387c075a723SBlue Swirl    environ = 0;
43888ab1bf12SLuiz Capitulino    return 0;
43898ab1bf12SLuiz Capitulino}
43908ab1bf12SLuiz CapitulinoEOF
43918ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
43928ab1bf12SLuiz Capitulino    has_environ=yes
43938ab1bf12SLuiz Capitulinofi
43948ab1bf12SLuiz Capitulino
439576a347e1SRichard Henderson########################################
439676a347e1SRichard Henderson# check if cpuid.h is usable.
439776a347e1SRichard Henderson
439876a347e1SRichard Hendersoncpuid_h=no
439976a347e1SRichard Hendersoncat > $TMPC << EOF
440076a347e1SRichard Henderson#include <cpuid.h>
440176a347e1SRichard Hendersonint main(void) {
4402774d566cSPeter Maydell    unsigned a, b, c, d;
4403774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4404774d566cSPeter Maydell
4405774d566cSPeter Maydell    if (max >= 1) {
4406774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4407774d566cSPeter Maydell    }
4408774d566cSPeter Maydell
4409774d566cSPeter Maydell    if (max >= 7) {
4410774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4411774d566cSPeter Maydell    }
4412774d566cSPeter Maydell
441376a347e1SRichard Henderson    return 0;
441476a347e1SRichard Henderson}
441576a347e1SRichard HendersonEOF
441676a347e1SRichard Hendersonif compile_prog "" "" ; then
441776a347e1SRichard Henderson    cpuid_h=yes
441876a347e1SRichard Hendersonfi
441976a347e1SRichard Henderson
4420f540166bSRichard Henderson########################################
4421f540166bSRichard Henderson# check if __[u]int128_t is usable.
4422f540166bSRichard Henderson
4423f540166bSRichard Hendersonint128=no
4424f540166bSRichard Hendersoncat > $TMPC << EOF
4425a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
4426a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4427a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
4428a00f66abSStefan Weil# endif
4429a00f66abSStefan Weil#endif
4430f540166bSRichard Henderson__int128_t a;
4431f540166bSRichard Henderson__uint128_t b;
4432f540166bSRichard Hendersonint main (void) {
4433f540166bSRichard Henderson  a = a + b;
4434f540166bSRichard Henderson  b = a * b;
4435464e3671SPeter Maydell  a = a * a;
4436f540166bSRichard Henderson  return 0;
4437f540166bSRichard Henderson}
4438f540166bSRichard HendersonEOF
4439f540166bSRichard Hendersonif compile_prog "" "" ; then
4440f540166bSRichard Henderson    int128=yes
4441f540166bSRichard Hendersonfi
444276a347e1SRichard Henderson
44431e6e9acaSRichard Henderson########################################
44441e6e9acaSRichard Henderson# check if getauxval is available.
44451e6e9acaSRichard Henderson
44461e6e9acaSRichard Hendersongetauxval=no
44471e6e9acaSRichard Hendersoncat > $TMPC << EOF
44481e6e9acaSRichard Henderson#include <sys/auxv.h>
44491e6e9acaSRichard Hendersonint main(void) {
44501e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
44511e6e9acaSRichard Henderson}
44521e6e9acaSRichard HendersonEOF
44531e6e9acaSRichard Hendersonif compile_prog "" "" ; then
44541e6e9acaSRichard Henderson    getauxval=yes
44551e6e9acaSRichard Hendersonfi
44561e6e9acaSRichard Henderson
4457fd0e6053SJohn Snow########################################
4458fd0e6053SJohn Snow# check if ccache is interfering with
4459fd0e6053SJohn Snow# semantic analysis of macros
4460fd0e6053SJohn Snow
44615e4dfd3dSJohn Snowunset CCACHE_CPP2
4462fd0e6053SJohn Snowccache_cpp2=no
4463fd0e6053SJohn Snowcat > $TMPC << EOF
4464fd0e6053SJohn Snowstatic const int Z = 1;
4465fd0e6053SJohn Snow#define fn() ({ Z; })
4466fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4467fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4468fd0e6053SJohn Snow#define ID(X) (X)
4469fd0e6053SJohn Snowint main(int argc, char *argv[])
4470fd0e6053SJohn Snow{
4471fd0e6053SJohn Snow    int x = 0, y = 0;
4472fd0e6053SJohn Snow    x = ID(x);
4473fd0e6053SJohn Snow    x = fn();
4474fd0e6053SJohn Snow    fn();
4475fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4476fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4477fd0e6053SJohn Snow    return 0;
4478fd0e6053SJohn Snow}
4479fd0e6053SJohn SnowEOF
4480fd0e6053SJohn Snow
4481fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4482fd0e6053SJohn Snow    ccache_cpp2=yes
4483fd0e6053SJohn Snowfi
4484fd0e6053SJohn Snow
4485b553a042SJohn Snow#################################################
4486b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4487b553a042SJohn Snow
4488b553a042SJohn Snowif test "$fortify_source" != "no"; then
4489b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4490b553a042SJohn Snow    fortify_source="no";
4491cfcc7c14SJohn Snow  elif test -n "$cxx" &&
4492cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4493b553a042SJohn Snow    fortify_source="no";
4494b553a042SJohn Snow  else
4495b553a042SJohn Snow    fortify_source="yes"
4496b553a042SJohn Snow  fi
4497b553a042SJohn Snowfi
4498b553a042SJohn Snow
4499d2042378SAneesh Kumar K.V##########################################
4500277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4501277abf15SJan Vesely
4502277abf15SJan Veselyhave_fsxattr=no
4503277abf15SJan Veselycat > $TMPC << EOF
4504277abf15SJan Vesely#include <linux/fs.h>
4505277abf15SJan Veselystruct fsxattr foo;
4506277abf15SJan Veselyint main(void) {
4507277abf15SJan Vesely  return 0;
4508277abf15SJan Vesely}
4509277abf15SJan VeselyEOF
4510277abf15SJan Veselyif compile_prog "" "" ; then
4511277abf15SJan Vesely    have_fsxattr=yes
4512277abf15SJan Veselyfi
4513277abf15SJan Vesely
4514b66e10e4SPeter Maydell##########################################
4515b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
4516575b22b1SLaurent Vivierhave_rtnetlink=no
4517575b22b1SLaurent Viviercat > $TMPC << EOF
4518575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
4519575b22b1SLaurent Vivierint main(void) {
4520575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
4521575b22b1SLaurent Vivier}
4522575b22b1SLaurent VivierEOF
4523575b22b1SLaurent Vivierif compile_prog "" "" ; then
4524575b22b1SLaurent Vivier    have_rtnetlink=yes
4525575b22b1SLaurent Vivierfi
4526575b22b1SLaurent Vivier
45276969ec6cSJames Clarke#################################################
45286969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
45296969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
45306969ec6cSJames Clarke# given. It does no harm to give it on other
45316969ec6cSJames Clarke# platforms too.
45326969ec6cSJames Clarke
45336969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
45346969ec6cSJames Clarke#       contains -Wmissing-prototypes
45356969ec6cSJames Clarkecat > $TMPC << EOF
45366969ec6cSJames Clarkeextern int foo(void);
45376969ec6cSJames Clarkeint foo(void) { return 0; }
45386969ec6cSJames ClarkeEOF
45396969ec6cSJames Clarkeif ! compile_object ""; then
45406969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
45416969ec6cSJames Clarkefi
45426969ec6cSJames Clarkeif do_cc -nostdlib -Wl,-r -Wl,--no-relax -o $TMPMO $TMPO; then
45436969ec6cSJames Clarke  LD_REL_FLAGS="-Wl,--no-relax"
45446969ec6cSJames Clarkefi
45456969ec6cSJames Clarke
4546277abf15SJan Vesely##########################################
4547e86ecd4bSJuan Quintela# End of CC checks
4548e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4549e86ecd4bSJuan Quintela
45501d728c39SBlue Swirlif test "$gcov" = "yes" ; then
45511d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
45521d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4553b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
4554e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4555ce278618SPeter Maydellelif test "$debug" = "no"; then
4556ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
4557e86ecd4bSJuan Quintelafi
4558a316e378SJuan Quintela
45596542aa9cSPeter Lieven##########################################
45606542aa9cSPeter Lieven# Do we have libnfs
45616542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
4562b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
45636542aa9cSPeter Lieven    libnfs="yes"
45646542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
45656542aa9cSPeter Lieven    LIBS="$LIBS $libnfs_libs"
45666542aa9cSPeter Lieven  else
45676542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
45688efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
45696542aa9cSPeter Lieven    fi
45706542aa9cSPeter Lieven    libnfs="no"
45716542aa9cSPeter Lieven  fi
45726542aa9cSPeter Lievenfi
45731d728c39SBlue Swirl
45746ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
45756ca026cbSPeter Maydellif test "$werror" = "yes"; then
45766ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
45776ca026cbSPeter Maydellfi
45786ca026cbSPeter Maydell
4579e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
4580e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
45811156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
4582e86ecd4bSJuan Quintela    fi
4583e86ecd4bSJuan Quintelafi
4584e86ecd4bSJuan Quintela
458594dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
458694dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
458794dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
458894dd53c5SGerd Hoffmannelse
458994dd53c5SGerd Hoffmann    POD2MAN="pod2man"
459094dd53c5SGerd Hoffmannfi
459194dd53c5SGerd Hoffmann
4592952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
4593952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
4594952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
4595952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4596952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
4597952afb71SBlue Swirl        fi
4598952afb71SBlue Swirl    done
4599952afb71SBlue Swirlfi
4600952afb71SBlue Swirl
460110ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
4602e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
4603528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
4604834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
46055a67135aSbellard
46064b1c11fdSDaniel P. Berrangetools=""
46074b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
4608ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
46094b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
46104b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
4611a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
46124b1c11fdSDaniel P. Berrange  fi
46134b1c11fdSDaniel P. Berrangefi
46144b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
4615983eef5aSMeador Inge  if test "$virtfs" != no ; then
4616be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4617983eef5aSMeador Inge      virtfs=yes
461817bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4619983eef5aSMeador Inge    else
4620983eef5aSMeador Inge      if test "$virtfs" = yes; then
46213f3b5388SStefan Weil        error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
4622983eef5aSMeador Inge      fi
462317500370SAndreas Färber      virtfs=no
4624983eef5aSMeador Inge    fi
462517bff52bSM. Mohan Kumar  fi
4626d138cee9SMichael Rothfi
46279d6bc27bSMichael Roth
46289d6bc27bSMichael Roth# Probe for guest agent support/options
46299d6bc27bSMichael Roth
4630e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
4631b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4632fafcaf1dSMichael Roth      tools="qemu-ga $tools"
4633e8ef31a3SMichael Tokarev      guest_agent=yes
4634e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
4635e8ef31a3SMichael Tokarev      guest_agent=no
4636e8ef31a3SMichael Tokarev  else
4637e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
4638ca35f780SPaolo Bonzini  fi
46394b1c11fdSDaniel P. Berrangefi
4640ca35f780SPaolo Bonzini
46419d6bc27bSMichael Roth# Guest agent Window MSI  package
46429d6bc27bSMichael Roth
46439d6bc27bSMichael Rothif test "$guest_agent" != yes; then
46449d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
46459d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
46469d6bc27bSMichael Roth  fi
46479d6bc27bSMichael Roth  guest_agent_msi=no
46489d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
46499d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
46509d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
46519d6bc27bSMichael Roth  fi
46529d6bc27bSMichael Roth  guest_agent_msi=no
46539d6bc27bSMichael Rothelif ! has wixl; then
46549d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
46559d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
46569d6bc27bSMichael Roth  fi
46579d6bc27bSMichael Roth  guest_agent_msi=no
46581a34904eSMichael Rothelse
46591a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
46601a34904eSMichael Roth  # disabled explicitly
46611a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
46621a34904eSMichael Roth    guest_agent_msi=yes
46631a34904eSMichael Roth  fi
46649d6bc27bSMichael Rothfi
46659d6bc27bSMichael Roth
46661a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
46679d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
46689d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
46699d6bc27bSMichael Roth  fi
46709d6bc27bSMichael Roth
46719d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
46729d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
46739d6bc27bSMichael Roth  fi
46749d6bc27bSMichael Roth
46759d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
46769d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
46779d6bc27bSMichael Roth  fi
46789d6bc27bSMichael Roth
46799d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
468089138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
46819d6bc27bSMichael Roth  fi
46829d6bc27bSMichael Roth
468389138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
46849d6bc27bSMichael Roth
46859d6bc27bSMichael Roth  case "$cpu" in
46869d6bc27bSMichael Roth  x86_64)
46879d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
46889d6bc27bSMichael Roth    ;;
46899d6bc27bSMichael Roth  i386)
46909d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
46919d6bc27bSMichael Roth    ;;
46929d6bc27bSMichael Roth  *)
46939d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
46949d6bc27bSMichael Roth    ;;
46959d6bc27bSMichael Roth  esac
46969d6bc27bSMichael Rothfi
46979d6bc27bSMichael Roth
4698ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
4699ca35f780SPaolo Bonziniroms=
4700ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
4701ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
4702ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
4703ca35f780SPaolo Bonzini  roms="optionrom"
4704ca35f780SPaolo Bonzinifi
4705d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
470639ac8455SDavid Gibson  roms="$roms spapr-rtas"
470739ac8455SDavid Gibsonfi
4708ca35f780SPaolo Bonzini
47099933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
47109933c305SChristian Borntraeger  roms="$roms s390-ccw"
47119933c305SChristian Borntraegerfi
47129933c305SChristian Borntraeger
4713964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
4714964c6fa1SRichard Hendersonif test "$pie" = "no" ; then
4715964c6fa1SRichard Henderson  textseg_addr=
4716964c6fa1SRichard Henderson  case "$cpu" in
4717479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
4718479eb121SRichard Henderson      # ??? Rationale for choosing this address
4719964c6fa1SRichard Henderson      textseg_addr=0x60000000
4720964c6fa1SRichard Henderson      ;;
4721964c6fa1SRichard Henderson    mips)
4722479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
4723479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
4724479eb121SRichard Henderson      textseg_addr=0x60000000
4725964c6fa1SRichard Henderson      ;;
4726964c6fa1SRichard Henderson  esac
4727964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
4728964c6fa1SRichard Henderson    cat > $TMPC <<EOF
4729964c6fa1SRichard Henderson    int main(void) { return 0; }
4730964c6fa1SRichard HendersonEOF
4731964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
4732964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
4733964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
4734964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
4735964c6fa1SRichard Henderson      # at least.
4736964c6fa1SRichard Henderson      $ld --verbose | sed \
4737964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
4738964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
4739964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
4740964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
4741964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
4742964c6fa1SRichard Henderson    fi
4743964c6fa1SRichard Henderson  fi
4744964c6fa1SRichard Hendersonfi
4745964c6fa1SRichard Henderson
474602d34f62SCole Robinsonecho_version() {
474702d34f62SCole Robinson    if test "$1" = "yes" ; then
474802d34f62SCole Robinson        echo "($2)"
474902d34f62SCole Robinson    fi
475002d34f62SCole Robinson}
475102d34f62SCole Robinson
475250e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
475350e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
475450e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
47555ca9388aSGerd Hoffmann
47567d13299dSbellardecho "Install prefix    $prefix"
475789138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
475889138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
475989138857SStefan Weilecho "library directory $(eval echo $libdir)"
476089138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
476189138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
476289138857SStefan Weilecho "include directory $(eval echo $includedir)"
476389138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
476411d9f695Sbellardif test "$mingw32" = "no" ; then
476589138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
476689138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
476743ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
47685a699bbbSLaszlo Ersekelse
47695a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
4770d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
477111d9f695Sbellardfi
47725a67135aSbellardecho "Source path       $source_path"
47737d13299dSbellardecho "C compiler        $cc"
477483469015Sbellardecho "Host C compiler   $host_cc"
477583f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
47763c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
477745d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
47780c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
4779a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
47800c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
47817d13299dSbellardecho "make              $make"
47826a882643Spbrookecho "install           $install"
4783c886edfbSBlue Swirlecho "python            $python"
4784e2d8830eSBradif test "$slirp" = "yes" ; then
4785e2d8830eSBrad    echo "smbd              $smbd"
4786e2d8830eSBradfi
478717969268SFam Zhengecho "module support    $modules"
4788a98fd896Sbellardecho "host CPU          $cpu"
4789de83cd02Sbellardecho "host big endian   $bigendian"
479097a847bcSbellardecho "target list       $target_list"
4791ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
47927d13299dSbellardecho "gprof enabled     $gprof"
479303b4fe7dSaliguoriecho "sparse enabled    $sparse"
47941625af87Saliguoriecho "strip binaries    $strip_opt"
479505c2a3e7Sbellardecho "profiler          $profiler"
479643ce4dfeSbellardecho "static build      $static"
47975b0753e0Sbellardif test "$darwin" = "yes" ; then
47985b0753e0Sbellard    echo "Cocoa support     $cocoa"
47995b0753e0Sbellardfi
4800e2134eb9SGerd Hoffmannecho "pixman            $pixman"
480189138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
480289138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
4803925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
480489138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
4805ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
4806ddbb0d09SDaniel P. Berrangeecho "GNUTLS hash       $gnutls_hash"
4807b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
480891bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
480937788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
481089138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
4811fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
48129a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
48134d3b6f6eSbalrogecho "curses support    $curses"
48149d9e1521SGerd Hoffmannecho "virgl support     $virglrenderer"
4815769ce76dSAlexander Grafecho "curl support      $curl"
481667b915a5Sbellardecho "mingw32 support   $mingw32"
48170c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
4818b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
4819b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
4820983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
4821821601eaSJes Sorensenecho "VNC support       $vnc"
4822821601eaSJes Sorensenif test "$vnc" = "yes" ; then
48232f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
48242f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
4825efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
4826821601eaSJes Sorensenfi
48273142255cSblueswir1if test -n "$sparc_cpu"; then
48283142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
48293142255cSblueswir1fi
4830e37630caSaliguoriecho "xen support       $xen"
48313996e85cSPaul Durrantif test "$xen" = "yes" ; then
48323996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
483364a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
48343996e85cSPaul Durrantfi
48352e4d9fb1Saurel32echo "brlapi support    $brlapi"
4836a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
4837a25dba17SJuan Quintelaecho "Documentation     $docs"
483840d6444eSAvi Kivityecho "PIE               $pie"
48398a16d273Sthsecho "vde support       $vde"
484058952137SVincenzo Maffioneecho "netmap support    $netmap"
48415c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
4842758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
484377755340Sthsecho "Install blobs     $blobs"
4844b31a0277SJuan Quintelaecho "KVM support       $kvm"
48452da776dbSMichael R. Hinesecho "RDMA support      $rdma"
48469195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
4847f652e6afSaurel32echo "fdt support       $fdt"
4848ceb42de8Saliguoriecho "preadv support    $preadv"
48495f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
4850e78815a5SAndreas Färberecho "madvise           $madvise"
4851e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
48521e9737daSRichard Hendersonecho "sigev_thread_id   $sigev_thread_id"
4853ee682d27SStefan Weilecho "uuid support      $uuid"
485447e98658SCorey Bryantecho "libcap-ng support $cap_ng"
4855d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
48565e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
48575b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
4858713572a7SMarc-André Lureauif have_backend "simple"; then
48599410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
4860e00e36fbSStefan Weilfi
486189138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
4862f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
4863dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
48647b02f544SMarc-André Lureauecho "smartcard support $smartcard"
48652b2325ffSGerd Hoffmannecho "libusb            $libusb"
486669354a83SHans de Goedeecho "usb net redir     $usb_redir"
4867da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
4868014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
4869c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
48706542aa9cSPeter Lievenecho "libnfs support    $libnfs"
4871d138cee9SMichael Rothecho "build guest agent $guest_agent"
4872d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
487350cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
48744c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
4875f794573eSEduardo Otuboecho "seccomp support   $seccomp"
48767c2acc70SPeter Maydellecho "coroutine backend $coroutine"
487770c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
4878eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
4879c9a12e75SChrysostomos Nanakosecho "Archipelago support $archipelago"
48801d728c39SBlue Swirlecho "gcov              $gcov_tool"
48811d728c39SBlue Swirlecho "gcov enabled      $gcov"
4882ab214c29SStefan Bergerecho "TPM support       $tpm"
48830a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
48843b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
48853556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
48864f18b782SJeff Codyecho "vhdx              $vhdx"
4887607dacd0Sqiaonuohanecho "lzo support       $lzo"
4888607dacd0Sqiaonuohanecho "snappy support    $snappy"
48896b383c08SPeter Wuecho "bzip2 support     $bzip2"
4890a99d57bbSWanlong Gaoecho "NUMA host support $numa"
48912847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
48927b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
489399f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
489467b915a5Sbellard
48951ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
489624b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
4897e8cd23deSbellardfi
489897a847bcSbellard
489998ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
490097a847bcSbellard
4901dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
4902dbd99ae3SStefan Weil
490398ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
490498ec69acSJuan Quintelaecho >> $config_host_mak
490598ec69acSJuan Quintela
4906e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
490799d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
490899d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
49093aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
49108bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
49110f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
491299d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
491399d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
491422d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
49159afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
49169afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
4917e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
49185a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
4919785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
49205a699bbbSLaszlo Ersekfi
4921f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
4922f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
4923f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
4924834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
4925f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
4926804edf29SJuan Quintela
492798ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
4928727e5283SPaolo Bonzini
4929f8393946Saurel32if test "$debug_tcg" = "yes" ; then
49302358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
4931f8393946Saurel32fi
49321625af87Saliguoriif test "$strip_opt" = "yes" ; then
493352ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
49341625af87Saliguorifi
49357d13299dSbellardif test "$bigendian" = "yes" ; then
4936e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
493797a847bcSbellardfi
493867b915a5Sbellardif test "$mingw32" = "yes" ; then
493998ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
494089138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
49419fe6de94SBlue Swirl  version_major=${rc_version%%.*}
49429fe6de94SBlue Swirl  rc_version=${rc_version#*.}
49439fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
49449fe6de94SBlue Swirl  rc_version=${rc_version#*.}
49459fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
49469fe6de94SBlue Swirl  version_micro=0
49479fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
49489fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
4949d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
4950d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
4951f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
4952d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
4953d9840e25STomoki Sekiyama  fi
495450cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
495550cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
495650cbebb9SMichael Roth  fi
49571a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
49589dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
49599dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
49609dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
49619dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
49629dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
49639dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
49649dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
49659dacf32dSYossi Hindin  fi
4966210fa556Spbrookelse
496735f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
4968210fa556Spbrookfi
4969128ab2ffSblueswir1
4970dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
4971dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
4972dffcb71cSMark McLoughlinfi
4973dffcb71cSMark McLoughlin
497483fb7adfSbellardif test "$darwin" = "yes" ; then
497598ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
497683fb7adfSbellardfi
4977b29fe3edSmalc
4978b29fe3edSmalcif test "$aix" = "yes" ; then
497998ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
4980b29fe3edSmalcfi
4981b29fe3edSmalc
4982ec530c81Sbellardif test "$solaris" = "yes" ; then
498398ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
49842358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
49850475a5caSths  if test "$needs_libsunmath" = "yes" ; then
498675b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
49870475a5caSths  fi
4988ec530c81Sbellardfi
4989179cf400SAndreas Färberif test "$haiku" = "yes" ; then
4990179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
4991179cf400SAndreas Färberfi
499297a847bcSbellardif test "$static" = "yes" ; then
499398ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
499497a847bcSbellardfi
49951ba16968SStefan Weilif test "$profiler" = "yes" ; then
49962358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
499705c2a3e7Sbellardfi
4998c20709aaSbellardif test "$slirp" = "yes" ; then
499998ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
5000e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5001c20709aaSbellardfi
50028a16d273Sthsif test "$vde" = "yes" ; then
500398ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
50048a16d273Sthsfi
500558952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
500658952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
500758952137SVincenzo Maffionefi
5008015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5009015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5010015a33bdSGongleifi
501147e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
501247e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
501347e98658SCorey Bryantfi
50142358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
50150c58ac1cSmalcfor drv in $audio_drv_list; do
501689138857SStefan Weil    def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
501798ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
50180c58ac1cSmalcdone
501967f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
502067f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
502167f86e8eSJuan Quintelafi
5022d5631638Smalcif test "$audio_win_int" = "yes" ; then
5023d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5024d5631638Smalcfi
5025b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5026b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5027821601eaSJes Sorensenif test "$vnc" = "yes" ; then
5028821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
5029821601eaSJes Sorensenfi
50302f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
503198ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
50322f9606b3Saliguorifi
5033821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
50342f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
50352f6f5c7aSCorentin Charyfi
5036821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
5037efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5038efe556adSCorentin Charyfi
503976655d6dSaliguoriif test "$fnmatch" = "yes" ; then
50402358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
504176655d6dSaliguorifi
5042ee682d27SStefan Weilif test "$uuid" = "yes" ; then
5043ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
5044ee682d27SStefan Weilfi
5045dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5046dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5047dce512deSChristoph Hellwigfi
504889138857SStefan Weilqemu_version=$(head $source_path/VERSION)
504998ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
50502358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
505198ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
505298ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
5053a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
505498ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
5055cc8ae6deSpbrookfi
505617969268SFam Zhengif test "$modules" = "yes"; then
5057e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5058e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
505989138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
506017969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
506117969268SFam Zhengfi
50621ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
506398ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
5064a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
50658ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
506649ecc3faSbellardfi
506749ecc3faSbellardif test "$cocoa" = "yes" ; then
506898ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
506949ecc3faSbellardfi
50704d3b6f6eSbalrogif test "$curses" = "yes" ; then
507198ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
5072ab4e5602SJan Kiszkafi
5073ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
50742358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
5075ebc996f3SRiku Voipiofi
5076099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
50772358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5078099d6b0fSRiku Voipiofi
507940ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
508040ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
508140ff6d7eSKevin Wolffi
50823ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
50832358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
50843ce34dfbSvibisreenivasanfi
5085c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5086c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5087c2882b96SRiku Voipiofi
5088751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5089751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5090751bcc39SMarc-André Lureaufi
5091d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5092d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5093d0927938SUlrich Hechtfi
50943d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
50953d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
50963d4fa43eSKusanagi Kouichifi
5097b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5098b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5099b953f075SDenis V. Lunevfi
5100ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5101ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5102ed911435SKevin Wolffi
5103c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5104c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5105c727f47dSPeter Maydellfi
5106dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5107dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5108dace20dcSPeter Maydellfi
5109d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5110d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5111d0927938SUlrich Hechtfi
51124e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
51134e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
51144e0c6529SAlex Blighfi
5115cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5116cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5117cd758dd0SAlex Blighfi
51183b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
51193b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
51203b6edd16SPeter Maydellfi
51213b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
51223b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
51233b6edd16SPeter Maydellfi
5124a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5125a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5126a8fd1abaSPeter Maydellfi
512751834341SRiku Voipioif test "$timerfd" = "yes" ; then
512851834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
512951834341SRiku Voipiofi
51309af5c906SRiku Voipioif test "$setns" = "yes" ; then
51319af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
51329af5c906SRiku Voipiofi
51333b3f24adSaurel32if test "$inotify" = "yes" ; then
51342358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
51353b3f24adSaurel32fi
5136c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5137c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5138c05c7a73SRiku Voipiofi
51396ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
51406ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
51416ae9a1f4SJuan Quintelafi
51426ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
51436ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
51446ae9a1f4SJuan Quintelafi
5145769ce76dSAlexander Grafif test "$curl" = "yes" ; then
5146d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
5147b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
51486ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5149769ce76dSAlexander Graffi
51502e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
515198ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
51522e4d9fb1Saurel32fi
5153fb599c9aSbalrogif test "$bluez" = "yes" ; then
515498ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
5155ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5156fb599c9aSbalrogfi
5157d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
51589d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
51599d41401bSMichael S. Tsirkinfi
5160e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
5161a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
5162a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
5163a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5164a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5165014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5166925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
5167925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
5168925a0400SGerd Hoffmann  fi
5169bbbf9bfbSStefan Weilfi
5170ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5171ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5172ddbb0d09SDaniel P. Berrangefi
5173ddbb0d09SDaniel P. Berrangeif test "$gnutls_hash" = "yes" ; then
5174ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS_HASH=y" >> $config_host_mak
5175ddbb0d09SDaniel P. Berrangefi
5176b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
5177b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5178b917da4cSDaniel P. Berrangefi
517991bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
518091bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
518137788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
518237788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
518337788f25SDaniel P. Berrange  fi
518462893b67SDaniel P. Berrangefi
518591bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
518691bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5187becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5188fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
5189fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5190fff2f982SDaniel P. Berrange  fi
5191ed754746SDaniel P. Berrangefi
51929a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
51939a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
51949a2fd434SDaniel P. Berrangefi
5195559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
5196559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5197559607eaSDaniel P. Berrangefi
5198277abf15SJan Vesely
5199277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5200277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5201277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5202277abf15SJan Vesely# if this macro is set.
5203277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5204277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5205277abf15SJan Veselyfi
5206bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5207bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5208a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5209a4ccabcfSAnthony Liguorifi
52109d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
52119d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
52129d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
52139d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
52149d9e1521SGerd Hoffmannfi
5215e37630caSaliguoriif test "$xen" = "yes" ; then
52166dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5217d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
521864a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
521964a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
522064a7ad6fSIan Campbell  fi
5221e37630caSaliguorifi
52225c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
52235c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
52245c6c3a6cSChristoph Hellwigfi
5225758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
5226758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
5227758e8e38SVenkateswararao Jujjuri (JV)fi
52284f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
52294f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
52304f26f2b6SAvi Kivityfi
5231983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
5232758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
5233758e8e38SVenkateswararao Jujjuri (JV)fi
52345e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
52355e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
52365e9be92dSNicholas Bellingerfi
523703ce5744SNikolay Nikolaevif test "$vhost_net" = "yes" ; then
523803ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
523903ce5744SNikolay Nikolaevfi
524077755340Sthsif test "$blobs" = "yes" ; then
524198ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
524277755340Sthsfi
5243bf9298b9Saliguoriif test "$iovec" = "yes" ; then
52442358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5245bf9298b9Saliguorifi
5246ceb42de8Saliguoriif test "$preadv" = "yes" ; then
52472358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
5248ceb42de8Saliguorifi
5249f652e6afSaurel32if test "$fdt" = "yes" ; then
52503f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
5251f652e6afSaurel32fi
5252dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5253dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5254dcc38d1cSMarcelo Tosattifi
52559195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
52569195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
52579195b2c2SStefan Weilfi
52585f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
52595f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
52605f6b9e8fSBlue Swirlfi
5261e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5262e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5263e78815a5SAndreas Färberfi
5264e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5265e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5266e78815a5SAndreas Färberfi
52671e9737daSRichard Hendersonif test "$sigev_thread_id" = "yes" ; then
52681e9737daSRichard Henderson  echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
52691e9737daSRichard Hendersonfi
527097a847bcSbellard
5271cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5272cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
5273cd4ec0b4SGerd Hoffmannfi
5274cd4ec0b4SGerd Hoffmann
52757b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
52767b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
5277111a38b0SRobert Relyeafi
5278111a38b0SRobert Relyea
52792b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
52802b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
52812b2325ffSGerd Hoffmannfi
52822b2325ffSGerd Hoffmann
528369354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
528469354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
528569354a83SHans de Goedefi
528669354a83SHans de Goede
5287da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5288da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5289f676c67eSJeremy White  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
5290da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5291014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
5292014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5293014cb152SGerd Hoffmann  fi
529420ff075bSMichael Wallefi
529520ff075bSMichael Walle
529699f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
529799f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
529899f2dbd3SLiang Lifi
529999f2dbd3SLiang Li
5300607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
5301607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
5302607dacd0Sqiaonuohanfi
5303607dacd0Sqiaonuohan
5304607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
5305607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
5306607dacd0Sqiaonuohanfi
5307607dacd0Sqiaonuohan
53086b383c08SPeter Wuif test "$bzip2" = "yes" ; then
53096b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
53106b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
53116b383c08SPeter Wufi
53126b383c08SPeter Wu
5313c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
5314d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
53156ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
53166ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5317c589b249SRonnie Sahlbergfi
5318c589b249SRonnie Sahlberg
53196542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
53206542aa9cSPeter Lieven  echo "CONFIG_LIBNFS=y" >> $config_host_mak
53216542aa9cSPeter Lievenfi
53226542aa9cSPeter Lieven
5323f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
5324f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
5325f794573eSEduardo Otubofi
5326f794573eSEduardo Otubo
532783fb7adfSbellard# XXX: suppress that
53287d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
53292358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
53307d3505c5Sbellardfi
53317d3505c5Sbellard
53324d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
53334d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
53344d9310f4SDaniel P. Berrangefi
53353556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
53363556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
53373556c233SPaolo Bonzinifi
5338f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
5339d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
53406ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
53416ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5342f27aaf4bSChristian Brunnerfi
534320ff6c80SAnthony Liguori
53447c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
534570c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
534670c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
534770c60c08SStefan Hajnoczielse
534870c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
534970c60c08SStefan Hajnoczifi
5350d0e2fce5SAneesh Kumar K.V
5351d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5352d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5353d2042378SAneesh Kumar K.Vfi
5354d2042378SAneesh Kumar K.V
5355e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5356e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5357e06a765eSHarsh Prateek Borafi
5358e06a765eSHarsh Prateek Bora
5359cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
5360cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
536106d71fa1SPeter Maydellfi
536206d71fa1SPeter Maydell
53633f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
53643f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
53653f4349dcSKevin Wolffi
53663f4349dcSKevin Wolf
53678ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
53688ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
53698ab1bf12SLuiz Capitulinofi
53708ab1bf12SLuiz Capitulino
537176a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
537276a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
537376a347e1SRichard Hendersonfi
537476a347e1SRichard Henderson
5375f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5376f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5377f540166bSRichard Hendersonfi
5378f540166bSRichard Henderson
53791e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
53801e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
53811e6e9acaSRichard Hendersonfi
53821e6e9acaSRichard Henderson
5383eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
5384d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
53856ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
53866ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5387eb100396SBharata B Raofi
5388eb100396SBharata B Rao
5389d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
5390d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5391d85fa9ebSJeff Codyfi
5392d85fa9ebSJeff Cody
53930c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
53940c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
53950c14fb47SBharata B Raofi
53960c14fb47SBharata B Rao
53977c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
53987c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
53997c815372SBharata B Raofi
54007c815372SBharata B Rao
5401c9a12e75SChrysostomos Nanakosif test "$archipelago" = "yes" ; then
5402c9a12e75SChrysostomos Nanakos  echo "CONFIG_ARCHIPELAGO=m" >> $config_host_mak
5403c9a12e75SChrysostomos Nanakos  echo "ARCHIPELAGO_LIBS=$archipelago_libs" >> $config_host_mak
5404c9a12e75SChrysostomos Nanakosfi
5405c9a12e75SChrysostomos Nanakos
54060a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
5407d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
54086ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
54096ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
54100a12ec87SRichard W.M. Jonesfi
54110a12ec87SRichard W.M. Jones
54124f18b782SJeff Codyif test "$vhdx" = "yes" ; then
54134f18b782SJeff Cody  echo "CONFIG_VHDX=y" >> $config_host_mak
54144f18b782SJeff Codyfi
54154f18b782SJeff Cody
541668063649Sblueswir1# USB host support
5417b5613fdcSGerd Hoffmannif test "$libusb" = "yes"; then
54182b2325ffSGerd Hoffmann  echo "HOST_USB=libusb legacy" >> $config_host_mak
5419b5613fdcSGerd Hoffmannelse
542098ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
5421b5613fdcSGerd Hoffmannfi
542268063649Sblueswir1
54233b8acc11SPaolo Bonzini# TPM passthrough support?
54243b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
54253b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
54263b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
54273b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
54283b8acc11SPaolo Bonzini  fi
54293b8acc11SPaolo Bonzinifi
54303b8acc11SPaolo Bonzini
54315b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
54325b808275SLluís Vilanovaif have_backend "nop"; then
54336d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
543422890ab5SPrerna Saxenafi
54355b808275SLluís Vilanovaif have_backend "simple"; then
54366d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
54376d8a764eSLluís  # Set the appropriate trace file.
5438953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
54399410b56cSPrerna Saxenafi
5440ed7f5f1dSPaolo Bonziniif have_backend "log"; then
5441ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
54426d8a764eSLluísfi
54435b808275SLluís Vilanovaif have_backend "ust"; then
54446d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
54456d8a764eSLluísfi
54465b808275SLluís Vilanovaif have_backend "dtrace"; then
54476d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
54486d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
54496d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
54506d8a764eSLluís  fi
5451c276b17dSDaniel P. Berrangefi
54525b808275SLluís Vilanovaif have_backend "ftrace"; then
5453781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
5454781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5455781e9545SEiichi Tsukata  else
545621684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5457781e9545SEiichi Tsukata  fi
5458781e9545SEiichi Tsukatafi
54599410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
54609410b56cSPrerna Saxena
54612da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
54622da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
54632da776dbSMichael R. Hinesfi
54642da776dbSMichael R. Hines
5465575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
5466575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5467575b22b1SLaurent Vivierfi
5468575b22b1SLaurent Vivier
54695c312079SDr. David Alan Gilbert# Hold two types of flag:
54705c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
54715c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
54725c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
54735c312079SDr. David Alan Gilbert#                                     platform
54745c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
54755c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
54765c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
54775c312079SDr. David Alan Gilbertfi
54785c312079SDr. David Alan Gilbert
54795b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
54805b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
54815b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
54825b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
54835b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
54845b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
5485c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
54865b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
548740d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
548840d964b5SRichard Henderson  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
54895b5e3037SPaolo Bonzinielse
54905b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
54915b5e3037SPaolo Bonzinifi
54925b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
54935b5e3037SPaolo Bonzini
549498ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
549598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
5496804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
5497804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
54981901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
54991901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
55001901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
550121655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
5502c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
5503804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
5504a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
5505a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
5506a31a8642SMichael S. Tsirkinfi
55072b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
5508804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
550983f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
55103c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
5511804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
551245d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
55133dd46c78SBlue Swirlecho "AS=$as" >> $config_host_mak
55143dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
5515804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
5516804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
55174852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
55189fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
5519e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
552046eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
5521a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
5522f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
5523e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
5524e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
552580fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
55262944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
5527e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
5528e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
5529e39f0062SPaolo Bonzinifi
553042da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
553142da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
553242da6041SGerd Hoffmannelse
553342da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
553442da6041SGerd Hoffmannfi
5535e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
553646eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
55376969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
553873da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
55393e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
5540804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
554117969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
554217969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
5543957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
554490246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
554590246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
554694dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
5547cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
55481d728c39SBlue Swirlif test "$gcov" = "yes" ; then
55491d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
55501d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
55511d728c39SBlue Swirlfi
5552804edf29SJuan Quintela
55536efd7517SPeter Maydell# use included Linux headers
55546efd7517SPeter Maydellif test "$linux" = "yes" ; then
5555a307beb6SAndreas Färber  mkdir -p linux-headers
55566efd7517SPeter Maydell  case "$cpu" in
5557c72b26ecSRichard Henderson  i386|x86_64|x32)
555808312a63SPeter Maydell    linux_arch=x86
55596efd7517SPeter Maydell    ;;
55606efd7517SPeter Maydell  ppcemb|ppc|ppc64)
556108312a63SPeter Maydell    linux_arch=powerpc
55626efd7517SPeter Maydell    ;;
55636efd7517SPeter Maydell  s390x)
556408312a63SPeter Maydell    linux_arch=s390
556508312a63SPeter Maydell    ;;
55661f080313SClaudio Fontana  aarch64)
55671f080313SClaudio Fontana    linux_arch=arm64
55681f080313SClaudio Fontana    ;;
5569222e7d11SSanjay Lal  mips64)
5570222e7d11SSanjay Lal    linux_arch=mips
5571222e7d11SSanjay Lal    ;;
557208312a63SPeter Maydell  *)
557308312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
557408312a63SPeter Maydell    linux_arch="$cpu"
55756efd7517SPeter Maydell    ;;
55766efd7517SPeter Maydell  esac
557708312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
557808312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
557908312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
558008312a63SPeter Maydell    fi
55816efd7517SPeter Maydellfi
55826efd7517SPeter Maydell
558397a847bcSbellardfor target in $target_list; do
558497a847bcSbellardtarget_dir="$target"
558525be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
558689138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
558797a847bcSbellardtarget_bigendian="no"
55881f3d3c8fSJuan Quintela
5589c1799a84SPaolo Bonzinicase "$target_name" in
5590d15a9c23SAnthony Green  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
5591ea2d6a39SJuan Quintela  target_bigendian=yes
5592ea2d6a39SJuan Quintela  ;;
5593ea2d6a39SJuan Quintelaesac
559497a847bcSbellardtarget_softmmu="no"
5595997344f3Sbellardtarget_user_only="no"
5596831b7825Sthstarget_linux_user="no"
559784778508Sblueswir1target_bsd_user="no"
55989e407a85Spbrookcase "$target" in
5599c1799a84SPaolo Bonzini  ${target_name}-softmmu)
56009e407a85Spbrook    target_softmmu="yes"
56019e407a85Spbrook    ;;
5602c1799a84SPaolo Bonzini  ${target_name}-linux-user)
56039c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
560476ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a Linux host"
56059c7a4202SBlue Swirl    fi
56069e407a85Spbrook    target_user_only="yes"
56079e407a85Spbrook    target_linux_user="yes"
56089e407a85Spbrook    ;;
5609c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
56109cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
561176ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a BSD host"
56129c7a4202SBlue Swirl    fi
561384778508Sblueswir1    target_user_only="yes"
561484778508Sblueswir1    target_bsd_user="yes"
561584778508Sblueswir1    ;;
56169e407a85Spbrook  *)
561776ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
56189e407a85Spbrook    exit 1
56199e407a85Spbrook    ;;
56209e407a85Spbrookesac
5621831b7825Sths
562297a847bcSbellardmkdir -p $target_dir
562325be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
562497a847bcSbellard
5625e5fe0c52Spbrookbflt="no"
562689138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
562756aebc89Spbrookgdb_xml_files=""
56287ba1e619Saliguori
5629c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
56306acff7daSJuan QuintelaTARGET_BASE_ARCH=""
5631e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
5632e73aae67SJuan Quintela
5633c1799a84SPaolo Bonzinicase "$target_name" in
56342408a527Saurel32  i386)
56352408a527Saurel32  ;;
56362408a527Saurel32  x86_64)
56376acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
56382408a527Saurel32  ;;
56392408a527Saurel32  alpha)
56402408a527Saurel32  ;;
56412408a527Saurel32  arm|armeb)
5642b498c8a0SJuan Quintela    TARGET_ARCH=arm
5643e5fe0c52Spbrook    bflt="yes"
564456aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
56452408a527Saurel32  ;;
56466a49fa95SAlexander Graf  aarch64)
56476a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
56486a49fa95SAlexander Graf    bflt="yes"
56498f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
56506a49fa95SAlexander Graf  ;;
56512408a527Saurel32  cris)
56522408a527Saurel32  ;;
5653613a22c9SMichael Walle  lm32)
5654613a22c9SMichael Walle  ;;
56552408a527Saurel32  m68k)
56560938cda5Saurel32    bflt="yes"
565756aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
56582408a527Saurel32  ;;
5659877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
5660877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
566172b675caSEdgar E. Iglesias    bflt="yes"
566272b675caSEdgar E. Iglesias  ;;
56632408a527Saurel32  mips|mipsel)
5664b498c8a0SJuan Quintela    TARGET_ARCH=mips
566525be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
56662408a527Saurel32  ;;
56672408a527Saurel32  mipsn32|mipsn32el)
5668597e2cecSRichard Henderson    TARGET_ARCH=mips64
56696acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
567025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
5671597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
56722408a527Saurel32  ;;
56732408a527Saurel32  mips64|mips64el)
5674b498c8a0SJuan Quintela    TARGET_ARCH=mips64
56756acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
567625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
56772408a527Saurel32  ;;
5678d15a9c23SAnthony Green  moxie)
5679d15a9c23SAnthony Green  ;;
5680e67db06eSJia Liu  or32)
5681e67db06eSJia Liu    TARGET_ARCH=openrisc
5682e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
5683e67db06eSJia Liu  ;;
56842408a527Saurel32  ppc)
5685c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
56862408a527Saurel32  ;;
56872408a527Saurel32  ppcemb)
56886acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
5689e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
5690c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
56912408a527Saurel32  ;;
56922408a527Saurel32  ppc64)
56936acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
5694e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
56951438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
56962408a527Saurel32  ;;
56979c35126cSDoug Kwan  ppc64le)
56989c35126cSDoug Kwan    TARGET_ARCH=ppc64
56999c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
57009c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
57011438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
57029c35126cSDoug Kwan  ;;
57032408a527Saurel32  ppc64abi32)
5704b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
57056acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
5706e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
570725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
57081438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
57092408a527Saurel32  ;;
57102408a527Saurel32  sh4|sh4eb)
5711b498c8a0SJuan Quintela    TARGET_ARCH=sh4
57124dbed897Spbrook    bflt="yes"
57132408a527Saurel32  ;;
57142408a527Saurel32  sparc)
57152408a527Saurel32  ;;
57162408a527Saurel32  sparc64)
57176acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
57182408a527Saurel32  ;;
57192408a527Saurel32  sparc32plus)
5720b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
57216acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
5722e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
572325be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
57242408a527Saurel32  ;;
572524e804ecSAlexander Graf  s390x)
57268a641ff6SDavid Hildenbrand    gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
572724e804ecSAlexander Graf  ;;
5728444e06b1SChen Gang  tilegx)
5729444e06b1SChen Gang  ;;
57305ecaa4edSPeter Crosthwaite  tricore)
57315ecaa4edSPeter Crosthwaite  ;;
5732d2fbca94SGuan Xuetao  unicore32)
5733d2fbca94SGuan Xuetao  ;;
5734cfa550c6SMax Filippov  xtensa|xtensaeb)
5735cfa550c6SMax Filippov    TARGET_ARCH=xtensa
5736cfa550c6SMax Filippov  ;;
57372408a527Saurel32  *)
573876ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
57392408a527Saurel32  ;;
57402408a527Saurel32esac
57415e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
57425e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
57435e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
57445e8861a0SPaolo Bonzinifi
57455e8861a0SPaolo Bonzini
57465e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
57475e8861a0SPaolo Bonzini
574899afc91dSDaniel P. Berrangeupper() {
574999afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
575099afc91dSDaniel P. Berrange}
575199afc91dSDaniel P. Berrange
575289138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
575325be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
5754c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
575525be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
5756e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
5757e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
5758e6e91b9cSJuan Quintelafi
575925be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
5760adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
5761adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
5762adfc3e91SStacey Sonfi
5763c1799a84SPaolo Bonzinicase "$target_name" in
57641b0c87fcSJuan Quintela  i386|x86_64)
57651b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
576625be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
5767eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
5768eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
5769eb6fda0fSAnthony PERARD      fi
5770432d268cSJun Nakajima    fi
577159d21e53SAlexander Graf    ;;
577259d21e53SAlexander Graf  *)
57731b0c87fcSJuan Quintelaesac
5774c1799a84SPaolo Bonzinicase "$target_name" in
5775222e7d11SSanjay Lal  aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
5776c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
5777c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
5778c1799a84SPaolo Bonzini      \( "$target_name" = "$cpu" -o \
5779c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
5780c1799a84SPaolo Bonzini      \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
5781c1799a84SPaolo Bonzini      \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
5782c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
5783222e7d11SSanjay Lal      \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
5784c1799a84SPaolo Bonzini      \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
578518b8263eSMichael Tokarev      \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) -o \
578618b8263eSMichael Tokarev      \( "$target_name" = "x86_64" -a "$cpu" = "x32"   \) -o \
578718b8263eSMichael Tokarev      \( "$target_name" = "i386"   -a "$cpu" = "x32" \) \) ; then
578825be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
57891ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
5790d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
5791421f4448SMarc-André Lureau        echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
5792d5970055SMichael S. Tsirkin      fi
5793c59249f9SJuan Quintela    fi
5794c59249f9SJuan Quintelaesac
5795de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
579625be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
579797a847bcSbellardfi
579897a847bcSbellardif test "$target_softmmu" = "yes" ; then
579925be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
5800de83cd02Sbellardfi
5801997344f3Sbellardif test "$target_user_only" = "yes" ; then
580225be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
5803a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
5804997344f3Sbellardfi
5805831b7825Sthsif test "$target_linux_user" = "yes" ; then
580625be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
5807831b7825Sthsfi
580856aebc89Spbrooklist=""
580956aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
581056aebc89Spbrook  for x in $gdb_xml_files; do
581156aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
581256aebc89Spbrook  done
581325be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
58143d0f1517SJuan Quintelafi
5815de83cd02Sbellard
5816e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
581725be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
5818e5fe0c52Spbrookfi
581984778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
582025be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
582184778508Sblueswir1fi
58225b0753e0Sbellard
58234afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
5824fa282484SJuan Quintela
58254afddb55SJuan Quintelacflags=""
5826fa282484SJuan Quintelaldflags=""
58279b8e111fSJuan Quintela
5828c765fcacSPeter Crosthwaitedisas_config() {
5829c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
5830c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
5831c765fcacSPeter Crosthwaite}
5832c765fcacSPeter Crosthwaite
583364656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
583464656024SJuan Quintela  case "$i" in
583564656024SJuan Quintela  alpha)
5836c765fcacSPeter Crosthwaite    disas_config "ALPHA"
583764656024SJuan Quintela  ;;
583882295d8aSRichard Henderson  aarch64)
583982295d8aSRichard Henderson    if test -n "${cxx}"; then
5840c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
584182295d8aSRichard Henderson    fi
584282295d8aSRichard Henderson  ;;
584364656024SJuan Quintela  arm)
5844c765fcacSPeter Crosthwaite    disas_config "ARM"
5845999b53ecSClaudio Fontana    if test -n "${cxx}"; then
5846c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
5847999b53ecSClaudio Fontana    fi
584864656024SJuan Quintela  ;;
584964656024SJuan Quintela  cris)
5850c765fcacSPeter Crosthwaite    disas_config "CRIS"
585164656024SJuan Quintela  ;;
585264656024SJuan Quintela  hppa)
5853c765fcacSPeter Crosthwaite    disas_config "HPPA"
585464656024SJuan Quintela  ;;
5855c72b26ecSRichard Henderson  i386|x86_64|x32)
5856c765fcacSPeter Crosthwaite    disas_config "I386"
585764656024SJuan Quintela  ;;
5858903ec55cSAurelien Jarno  ia64*)
5859c765fcacSPeter Crosthwaite    disas_config "IA64"
5860903ec55cSAurelien Jarno  ;;
586179368f49SMichael Walle  lm32)
5862c765fcacSPeter Crosthwaite    disas_config "LM32"
586379368f49SMichael Walle  ;;
586464656024SJuan Quintela  m68k)
5865c765fcacSPeter Crosthwaite    disas_config "M68K"
586664656024SJuan Quintela  ;;
5867877fdc12SEdgar E. Iglesias  microblaze*)
5868c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
586964656024SJuan Quintela  ;;
587064656024SJuan Quintela  mips*)
5871c765fcacSPeter Crosthwaite    disas_config "MIPS"
587264656024SJuan Quintela  ;;
5873d15a9c23SAnthony Green  moxie*)
5874c765fcacSPeter Crosthwaite    disas_config "MOXIE"
5875d15a9c23SAnthony Green  ;;
5876e67db06eSJia Liu  or32)
5877c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
5878e67db06eSJia Liu  ;;
587964656024SJuan Quintela  ppc*)
5880c765fcacSPeter Crosthwaite    disas_config "PPC"
588164656024SJuan Quintela  ;;
588224e804ecSAlexander Graf  s390*)
5883c765fcacSPeter Crosthwaite    disas_config "S390"
588464656024SJuan Quintela  ;;
588564656024SJuan Quintela  sh4)
5886c765fcacSPeter Crosthwaite    disas_config "SH4"
588764656024SJuan Quintela  ;;
588864656024SJuan Quintela  sparc*)
5889c765fcacSPeter Crosthwaite    disas_config "SPARC"
589064656024SJuan Quintela  ;;
5891cfa550c6SMax Filippov  xtensa*)
5892c765fcacSPeter Crosthwaite    disas_config "XTENSA"
5893cfa550c6SMax Filippov  ;;
589464656024SJuan Quintela  esac
589564656024SJuan Quinteladone
58969195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
5897c765fcacSPeter Crosthwaite  disas_config "TCI"
58989195b2c2SStefan Weilfi
589964656024SJuan Quintela
59006ee7126fSJuan Quintelacase "$ARCH" in
59016ee7126fSJuan Quintelaalpha)
59026ee7126fSJuan Quintela  # Ensure there's only a single GP
59036ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
59046ee7126fSJuan Quintela;;
59056ee7126fSJuan Quintelaesac
59066ee7126fSJuan Quintela
5907d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
590825be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
5909d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
5910d02c1db3SJuan Quintela    cflags="-p $cflags"
5911d02c1db3SJuan Quintela    ldflags="-p $ldflags"
5912d02c1db3SJuan Quintela  fi
5913d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
5914d02c1db3SJuan Quintela    ldflags="-p $ldflags"
591525be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
5916d02c1db3SJuan Quintela  fi
5917d02c1db3SJuan Quintelafi
5918d02c1db3SJuan Quintela
59199b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
5920964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
5921fa282484SJuan Quintelafi
5922fa282484SJuan Quintela
592325be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
592425be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
5925fa282484SJuan Quintela
592697a847bcSbellarddone # for target in $targets
59277d13299dSbellard
5928b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
5929b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
5930b776eca1SGerd Hoffmannfi
5931b776eca1SGerd Hoffmann
5932a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
5933a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
5934a540f158SPeter Crosthwaitefi
5935a540f158SPeter Crosthwaite
5936a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
5937a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
5938a99d57bbSWanlong Gaofi
5939a99d57bbSWanlong Gao
5940fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
5941fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
5942fd0e6053SJohn Snowfi
5943fd0e6053SJohn Snow
5944d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
5945f93296eaSWenchao XiaDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
59462b170effSMichael TokarevDIRS="$DIRS fsdev"
59479933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
59482d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
59492dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
5950c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
5951c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
5952aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
5953ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
5954446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
59559933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
59562d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
59574652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
5958753d11f2SRichard Hendersonfor bios_file in \
5959753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
59605acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
5961753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
5962753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
5963e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
5964753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
59654e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
5966753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
5967753d11f2SRichard Hendersondo
596889138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
59697ea78b74SJan Kiszkadone
597089138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
5971c2304b52SMarcel Apfelbaumdo
597289138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
5973c2304b52SMarcel Apfelbaumdone
5974d1807a4fSPaolo Bonzinimkdir -p $DIRS
59757d13299dSbellardfor f in $FILES ; do
5976cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
5977f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
5978f9245e10SPeter Maydell    fi
59797d13299dSbellarddone
59801ad2134fSPaul Brook
5981c34ebfdcSAnthony Liguori# temporary config to build submodules
59822d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
5983c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
598437116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
5985c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
59863dd46c78SBlue Swirl    echo "AS=$as" >> $config_mak
5987c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
5988c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
59893dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
5990c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
5991a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
5992c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
5993c34ebfdcSAnthony Liguoridone
5994c34ebfdcSAnthony Liguori
599576c7560aSMax Reitz# set up qemu-iotests in this build directory
599676c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
599776c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
599876c7560aSMax Reitz
599976c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
600076c7560aSMax Reitzecho >> "$iotests_common_env"
600176c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
600276c7560aSMax Reitz
600376c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
600476c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
600576c7560aSMax Reitzfi
600676c7560aSMax Reitz
6007dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6008dc655404SMichael S. Tsirkincat <<EOD >config.status
6009dc655404SMichael S. Tsirkin#!/bin/sh
6010dc655404SMichael S. Tsirkin# Generated by configure.
6011dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6012dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6013dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6014dc655404SMichael S. TsirkinEOD
6015dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6016dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
6017cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6018dc655404SMichael S. Tsirkinchmod +x config.status
6019dc655404SMichael S. Tsirkin
60208cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6021