xref: /openbmc/qemu/configure (revision 180fb750)
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 Bonzinivde=""
216377529c0SPaolo Bonzinivnc_sasl=""
217377529c0SPaolo Bonzinivnc_jpeg=""
218377529c0SPaolo Bonzinivnc_png=""
219377529c0SPaolo Bonzinixen=""
220d5b93ddfSAnthony PERARDxen_ctrl_version=""
22164a7ad6fSIan Campbellxen_pv_domain_build="no"
222eb6fda0fSAnthony PERARDxen_pci_passthrough=""
223377529c0SPaolo Bonzinilinux_aio=""
22447e98658SCorey Bryantcap_ng=""
225377529c0SPaolo Bonziniattr=""
2264f26f2b6SAvi Kivitylibattr=""
227377529c0SPaolo Bonzinixfs=""
228377529c0SPaolo Bonzini
229d41a75a2SBradvhost_net="no"
2305e9be92dSNicholas Bellingervhost_scsi="no"
231fc0b9b0eSStefan Hajnoczivhost_vsock="no"
232d41a75a2SBradkvm="no"
233*180fb750Szhanghailiangcolo="yes"
2342da776dbSMichael R. Hinesrdma=""
235377529c0SPaolo Bonzinigprof="no"
236377529c0SPaolo Bonzinidebug_tcg="no"
237377529c0SPaolo Bonzinidebug="no"
238b553a042SJohn Snowfortify_source=""
239377529c0SPaolo Bonzinistrip_opt="yes"
2409195b2c2SStefan Weiltcg_interpreter="no"
241377529c0SPaolo Bonzinibigendian="no"
242377529c0SPaolo Bonzinimingw32="no"
2431d728c39SBlue Swirlgcov="no"
2441d728c39SBlue Swirlgcov_tool="gcov"
245377529c0SPaolo BonziniEXESUF=""
24617969268SFam ZhengDSOSUF=".so"
24717969268SFam ZhengLDFLAGS_SHARED="-shared"
24817969268SFam Zhengmodules="no"
249377529c0SPaolo Bonziniprefix="/usr/local"
250377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
251528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
252850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
253377529c0SPaolo Bonzinibindir="\${prefix}/bin"
2543aa5d2beSAlon Levylibdir="\${prefix}/lib"
2558bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
2560f94d6daSAlon Levyincludedir="\${prefix}/include"
257377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
258785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
259377529c0SPaolo Bonziniconfsuffix="/qemu"
260377529c0SPaolo Bonzinislirp="yes"
261377529c0SPaolo Bonzinioss_lib=""
262377529c0SPaolo Bonzinibsd="no"
263377529c0SPaolo Bonzinilinux="no"
264377529c0SPaolo Bonzinisolaris="no"
265377529c0SPaolo Bonziniprofiler="no"
266377529c0SPaolo Bonzinicocoa="no"
267377529c0SPaolo Bonzinisoftmmu="yes"
268377529c0SPaolo Bonzinilinux_user="no"
269377529c0SPaolo Bonzinibsd_user="no"
270377529c0SPaolo Bonziniaix="no"
271377529c0SPaolo Bonziniblobs="yes"
272377529c0SPaolo Bonzinipkgversion=""
27340d6444eSAvi Kivitypie=""
2743556c233SPaolo Bonziniqom_cast_debug="yes"
275baf86d6bSPaolo Bonzinitrace_backends="log"
276377529c0SPaolo Bonzinitrace_file="trace"
277377529c0SPaolo Bonzinispice=""
278377529c0SPaolo Bonzinirbd=""
2797b02f544SMarc-André Lureausmartcard=""
2802b2325ffSGerd Hoffmannlibusb=""
28169354a83SHans de Goedeusb_redir=""
282da076ffeSGerd Hoffmannopengl=""
283014cb152SGerd Hoffmannopengl_dmabuf="no"
28499f2dbd3SLiang Liavx2_opt="no"
2851ece9905SAlon Levyzlib="yes"
286b25c9dffSStefan Weillzo=""
287b25c9dffSStefan Weilsnappy=""
2886b383c08SPeter Wubzip2=""
289e8ef31a3SMichael Tokarevguest_agent=""
290d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
29150cbebb9SMichael Rothguest_agent_ntddscsi="no"
2929dacf32dSYossi Hindinguest_agent_msi=""
293d9840e25STomoki Sekiyamavss_win32_sdk=""
294d9840e25STomoki Sekiyamawin_sdk="no"
2954b1c11fdSDaniel P. Berrangewant_tools="yes"
296c589b249SRonnie Sahlberglibiscsi=""
2976542aa9cSPeter Lievenlibnfs=""
298519175a2SAlex Barcelocoroutine=""
29970c60c08SStefan Hajnoczicoroutine_pool=""
3007d992e4dSPeter Lievendebug_stack_usage="no"
301f794573eSEduardo Otuboseccomp=""
302eb100396SBharata B Raoglusterfs=""
303d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
3040c14fb47SBharata B Raoglusterfs_discard="no"
3057c815372SBharata B Raoglusterfs_zerofill="no"
3066a460ed1SStefan Hajnocziarchipelago="no"
307a4ccabcfSAnthony Liguorigtk=""
3089e04c683SStefan Weilgtkabi=""
309925a0400SGerd Hoffmanngtk_gl="no"
310a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
311ddbb0d09SDaniel P. Berrangegnutls=""
312b917da4cSDaniel P. Berrangegnutls_rnd=""
31391bfcdb0SDaniel P. Berrangenettle=""
314fff2f982SDaniel P. Berrangenettle_kdf="no"
31591bfcdb0SDaniel P. Berrangegcrypt=""
31637788f25SDaniel P. Berrangegcrypt_kdf="no"
317bbbf9bfbSStefan Weilvte=""
3189d9e1521SGerd Hoffmannvirglrenderer=""
319e91c793cSCole Robinsontpm="yes"
3200a12ec87SRichard W.M. Joneslibssh2=""
321a99d57bbSWanlong Gaonuma=""
3222847b469SFam Zhengtcmalloc="no"
3237b01cb97SAlexandre Derumierjemalloc="no"
324a6b1d4c0SChanglong Xiereplication="yes"
325377529c0SPaolo Bonzini
326ac0df51dSaliguori# parse CC options first
327ac0df51dSaliguorifor opt do
32889138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
329ac0df51dSaliguori  case "$opt" in
330ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
331ac0df51dSaliguori  ;;
3323d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
333ac0df51dSaliguori  ;;
33483f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
33583f73fceSTomoki Sekiyama  ;;
336ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
337ca4deeb1SPaolo Bonzini  ;;
3382ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
3392ff6b91eSJuan Quintela  ;;
340de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
341f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
342e2a2ed06SJuan Quintela  ;;
343a4969e90SAlex Bennée  --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
344f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
345e2a2ed06SJuan Quintela  ;;
3465bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
3475bc62e01SGerd Hoffmann  ;;
3485bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
3495bc62e01SGerd Hoffmann  ;;
350ac0df51dSaliguori  esac
351ac0df51dSaliguoridone
352ac0df51dSaliguori# OS specific
353ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
35493148aa5SStefan Weil# we can eliminate its usage altogether.
355ac0df51dSaliguori
356e49d021eSPeter Maydell# Preferred compiler:
357e49d021eSPeter Maydell#  ${CC} (if set)
358e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
359e49d021eSPeter Maydell#  system compiler
360e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
361e49d021eSPeter Maydell  cc="$host_cc"
362e49d021eSPeter Maydellelse
363b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
364e49d021eSPeter Maydellfi
365e49d021eSPeter Maydell
36683f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
36783f73fceSTomoki Sekiyama  cxx="c++"
36883f73fceSTomoki Sekiyamaelse
36983f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
37083f73fceSTomoki Sekiyamafi
37183f73fceSTomoki Sekiyama
372b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
373cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
3745f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
3753dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
376b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
377b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
3784852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
379b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
380b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
38117884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
38217884d7bSSergei Trofimovichquery_pkg_config() {
38317884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
38417884d7bSSergei Trofimovich}
38517884d7bSSergei Trofimovichpkg_config=query_pkg_config
386b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
38747c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
388ac0df51dSaliguori
38945d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
39045d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
39145d285abSPeter Maydell
392be17dc90SMichael S. Tsirkin# default flags for all hosts
3932d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
3942d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
3952d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
3962d31515bSPeter Maydell# provides these semantics.)
3972d31515bSPeter MaydellQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
398f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
399c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
400be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
4016b4c305cSPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
4025bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
4035bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
404be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
4055bc62e01SGerd Hoffmannfi
406be17dc90SMichael S. Tsirkin
407ca4deeb1SPaolo Bonzini# make source path absolute
40889138857SStefan Weilsource_path=$(cd "$source_path"; pwd)
409ca4deeb1SPaolo Bonzini
410cab00a5aSMichael S. Tsirkin# running configure in the source tree?
411cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
412cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
413cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
414cab00a5aSMichael S. Tsirkinelse
415cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
416cab00a5aSMichael S. Tsirkinfi
417cab00a5aSMichael S. Tsirkin
418ac0df51dSaliguoricheck_define() {
419ac0df51dSaliguoricat > $TMPC <<EOF
420ac0df51dSaliguori#if !defined($1)
421fd786e1aSPeter Maydell#error $1 not defined
422ac0df51dSaliguori#endif
423ac0df51dSaliguoriint main(void) { return 0; }
424ac0df51dSaliguoriEOF
42552166aa0SJuan Quintela  compile_object
426ac0df51dSaliguori}
427ac0df51dSaliguori
428307119e7SGerd Hoffmanncheck_include() {
429307119e7SGerd Hoffmanncat > $TMPC <<EOF
430307119e7SGerd Hoffmann#include <$1>
431307119e7SGerd Hoffmannint main(void) { return 0; }
432307119e7SGerd HoffmannEOF
433307119e7SGerd Hoffmann  compile_object
434307119e7SGerd Hoffmann}
435307119e7SGerd Hoffmann
43693b25869SJohn Snowwrite_c_skeleton() {
43793b25869SJohn Snow    cat > $TMPC <<EOF
43893b25869SJohn Snowint main(void) { return 0; }
43993b25869SJohn SnowEOF
44093b25869SJohn Snow}
44193b25869SJohn Snow
442bbea4050SPeter Maydellif check_define __linux__ ; then
443bbea4050SPeter Maydell  targetos="Linux"
444bbea4050SPeter Maydellelif check_define _WIN32 ; then
445bbea4050SPeter Maydell  targetos='MINGW32'
446bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
447bbea4050SPeter Maydell  targetos='OpenBSD'
448bbea4050SPeter Maydellelif check_define __sun__ ; then
449bbea4050SPeter Maydell  targetos='SunOS'
450bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
451bbea4050SPeter Maydell  targetos='Haiku'
452bbea4050SPeter Maydellelse
45389138857SStefan Weil  targetos=$(uname -s)
454bbea4050SPeter Maydellfi
455bbea4050SPeter Maydell
456bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
457bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
458bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
459bbea4050SPeter Maydell# the correct CPU with the --cpu option.
460bbea4050SPeter Maydellcase $targetos in
461bbea4050SPeter MaydellDarwin)
462bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
463bbea4050SPeter Maydell  # run 64-bit userspace code.
464bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
465bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
466bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
467bbea4050SPeter Maydell    cpu="x86_64"
468bbea4050SPeter Maydell  fi
469bbea4050SPeter Maydell  ;;
470bbea4050SPeter MaydellSunOS)
47189138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
472bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
473bbea4050SPeter Maydell    cpu="x86_64"
474bbea4050SPeter Maydell  fi
475bbea4050SPeter Maydellesac
476bbea4050SPeter Maydell
4772ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
4782ff6b91eSJuan Quintela  # command line argument
4792ff6b91eSJuan Quintela  :
4802ff6b91eSJuan Quintelaelif check_define __i386__ ; then
481ac0df51dSaliguori  cpu="i386"
482ac0df51dSaliguorielif check_define __x86_64__ ; then
483c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
484c72b26ecSRichard Henderson    cpu="x32"
485c72b26ecSRichard Henderson  else
486ac0df51dSaliguori    cpu="x86_64"
487c72b26ecSRichard Henderson  fi
4883aa9bd6cSblueswir1elif check_define __sparc__ ; then
4893aa9bd6cSblueswir1  if check_define __arch64__ ; then
4903aa9bd6cSblueswir1    cpu="sparc64"
4913aa9bd6cSblueswir1  else
4923aa9bd6cSblueswir1    cpu="sparc"
4933aa9bd6cSblueswir1  fi
494fdf7ed96Smalcelif check_define _ARCH_PPC ; then
495fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
496fdf7ed96Smalc    cpu="ppc64"
497ac0df51dSaliguori  else
498fdf7ed96Smalc    cpu="ppc"
499fdf7ed96Smalc  fi
500afa05235SAurelien Jarnoelif check_define __mips__ ; then
501afa05235SAurelien Jarno  cpu="mips"
502477ba620SAurelien Jarnoelif check_define __ia64__ ; then
503477ba620SAurelien Jarno  cpu="ia64"
504d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
505d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
506d66ed0eaSAurelien Jarno    cpu="s390x"
507d66ed0eaSAurelien Jarno  else
508d66ed0eaSAurelien Jarno    cpu="s390"
509d66ed0eaSAurelien Jarno  fi
51021d89f84SPeter Maydellelif check_define __arm__ ; then
51121d89f84SPeter Maydell  cpu="arm"
5121f080313SClaudio Fontanaelif check_define __aarch64__ ; then
5131f080313SClaudio Fontana  cpu="aarch64"
514fdf7ed96Smalcelse
51589138857SStefan Weil  cpu=$(uname -m)
516ac0df51dSaliguorifi
517ac0df51dSaliguori
518359bc95dSPeter MaydellARCH=
519359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
520359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
5217d13299dSbellardcase "$cpu" in
522c72b26ecSRichard Henderson  ia64|ppc|ppc64|s390|s390x|sparc64|x32)
523ea8f20f8SJuan Quintela    cpu="$cpu"
524ea8f20f8SJuan Quintela  ;;
5257d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
52697a847bcSbellard    cpu="i386"
5277d13299dSbellard  ;;
528aaa5fa14Saurel32  x86_64|amd64)
529aaa5fa14Saurel32    cpu="x86_64"
530aaa5fa14Saurel32  ;;
53121d89f84SPeter Maydell  armv*b|armv*l|arm)
53221d89f84SPeter Maydell    cpu="arm"
5337d13299dSbellard  ;;
5341f080313SClaudio Fontana  aarch64)
5351f080313SClaudio Fontana    cpu="aarch64"
5361f080313SClaudio Fontana  ;;
537afa05235SAurelien Jarno  mips*)
538afa05235SAurelien Jarno    cpu="mips"
539afa05235SAurelien Jarno  ;;
5403142255cSblueswir1  sparc|sun4[cdmuv])
541ae228531Sbellard    cpu="sparc"
542ae228531Sbellard  ;;
5437d13299dSbellard  *)
544359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
545359bc95dSPeter Maydell    ARCH=unknown
5467d13299dSbellard  ;;
5477d13299dSbellardesac
548359bc95dSPeter Maydellif test -z "$ARCH"; then
549359bc95dSPeter Maydell  ARCH="$cpu"
550359bc95dSPeter Maydellfi
551e2d52ad3SJuan Quintela
5527d13299dSbellard# OS specific
5530dbfc675SJuan Quintela
554adfc3e91SStacey Son# host *BSD for user mode
555adfc3e91SStacey SonHOST_VARIANT_DIR=""
556adfc3e91SStacey Son
5577d13299dSbellardcase $targetos in
558c326e0afSbellardCYGWIN*)
559c326e0afSbellard  mingw32="yes"
560a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
5613cec7cc2SKővágó, Zoltán  audio_possible_drivers="sdl"
5623cec7cc2SKővágó, Zoltán  audio_drv_list="sdl"
563c326e0afSbellard;;
56467b915a5SbellardMINGW32*)
56567b915a5Sbellard  mingw32="yes"
5663cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
567307119e7SGerd Hoffmann  if check_include dsound.h; then
5683cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
569307119e7SGerd Hoffmann  else
570307119e7SGerd Hoffmann    audio_drv_list=""
571307119e7SGerd Hoffmann  fi
57267b915a5Sbellard;;
5735c40d2bdSthsGNU/kFreeBSD)
574a167ba50SAurelien Jarno  bsd="yes"
5750c58ac1cSmalc  audio_drv_list="oss"
5760bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
5775c40d2bdSths;;
5787d3505c5SbellardFreeBSD)
5797d3505c5Sbellard  bsd="yes"
5800db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5810c58ac1cSmalc  audio_drv_list="oss"
5820bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
583f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
584f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
58558952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
586adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
5877d3505c5Sbellard;;
588c5e97233Sblueswir1DragonFly)
589c5e97233Sblueswir1  bsd="yes"
5900db4a067SPaolo Bonzini  make="${MAKE-gmake}"
591c5e97233Sblueswir1  audio_drv_list="oss"
5920bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
593adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
594c5e97233Sblueswir1;;
5957d3505c5SbellardNetBSD)
5967d3505c5Sbellard  bsd="yes"
5970db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5980c58ac1cSmalc  audio_drv_list="oss"
5990bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
6008ef92a88Sblueswir1  oss_lib="-lossaudio"
601adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
6027d3505c5Sbellard;;
6037d3505c5SbellardOpenBSD)
6047d3505c5Sbellard  bsd="yes"
6050db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6064f6ab397SBrad Smith  audio_drv_list="sdl"
6070bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
608adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
6097d3505c5Sbellard;;
61083fb7adfSbellardDarwin)
61183fb7adfSbellard  bsd="yes"
61283fb7adfSbellard  darwin="yes"
61317969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
6141b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
615a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
6160c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
6171b0f9cc2Saliguori  fi
618fd677642Sths  cocoa="yes"
6190c58ac1cSmalc  audio_drv_list="coreaudio"
62014382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
6210c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
6227973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
623a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
624a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
625a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
626adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
62783fb7adfSbellard;;
628ec530c81SbellardSunOS)
629ec530c81Sbellard  solaris="yes"
6300db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6310db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
632fa58948dSBlue Swirl  ld="gld"
633e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
6340475a5caSths  needs_libsunmath="no"
63589138857SStefan Weil  solarisrev=$(uname -r | cut -f2 -d.)
636c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
6370475a5caSths    if test "$solarisrev" -le 9 ; then
6380475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
6390475a5caSths        needs_libsunmath="yes"
640f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
641f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
642f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
6430475a5caSths      else
64476ad07a4SPeter Maydell        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
64576ad07a4SPeter Maydell            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
64676ad07a4SPeter Maydell            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
64776ad07a4SPeter Maydell            "Studio 11 can be downloaded from www.sun.com."
6480475a5caSths      fi
6490475a5caSths    fi
65086b2bd93Sths  fi
6516b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
6520c58ac1cSmalc    audio_drv_list="oss"
6536b4d2ba1Sths  fi
654c2de5c91Smalc  audio_possible_drivers="oss sdl"
655d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
656d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
657d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
658d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
659a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
660560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
661560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
662560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
663ec530c81Sbellard;;
664b29fe3edSmalcAIX)
665b29fe3edSmalc  aix="yes"
6660db4a067SPaolo Bonzini  make="${MAKE-gmake}"
667b29fe3edSmalc;;
668179cf400SAndreas FärberHaiku)
669179cf400SAndreas Färber  haiku="yes"
670179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
671179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
672179cf400SAndreas Färber;;
673fb065187Sbellard*)
6740c58ac1cSmalc  audio_drv_list="oss"
6750bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
6765327cf48Sbellard  linux="yes"
677831b7825Sths  linux_user="yes"
678af2be207SJan Kiszka  kvm="yes"
679af2be207SJan Kiszka  vhost_net="yes"
6805e9be92dSNicholas Bellinger  vhost_scsi="yes"
681fc0b9b0eSStefan Hajnoczi  vhost_vsock="yes"
682a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
683fb065187Sbellard;;
6847d13299dSbellardesac
6857d13299dSbellard
6867d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
687b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
68884778508Sblueswir1    bsd_user="yes"
6897d3505c5Sbellard  fi
69008de3949SAndreas Färberfi
6917d3505c5Sbellard
6920db4a067SPaolo Bonzini: ${make=${MAKE-make}}
6930db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
69452510f8bSStefan Weil: ${python=${PYTHON-python}}
695e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
6960db4a067SPaolo Bonzini
6973c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
6983c4a4d0dSPeter Maydellif has clang; then
6993c4a4d0dSPeter Maydell  objcc=clang
7003c4a4d0dSPeter Maydellelse
7013c4a4d0dSPeter Maydell  objcc="$cc"
7023c4a4d0dSPeter Maydellfi
7033c4a4d0dSPeter Maydell
7043457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
7053457a3f8SJuan Quintela  EXESUF=".exe"
70617969268SFam Zheng  DSOSUF=".dll"
707a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
708e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
709e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
71078e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
71178e9d4adSStefan Weil  QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
712f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
71393b25869SJohn Snow  write_c_skeleton;
714f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
715f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
716f7cf5d5bSStefan Weil  fi
717c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
718683035deSPaolo Bonzini  mandir="\${prefix}"
719528ae5b8SEduardo Habkost  datadir="\${prefix}"
720850da188SEduardo Habkost  qemu_docdir="\${prefix}"
721683035deSPaolo Bonzini  bindir="\${prefix}"
722683035deSPaolo Bonzini  sysconfdir="\${prefix}"
7235a699bbbSLaszlo Ersek  local_statedir=
724683035deSPaolo Bonzini  confsuffix=""
725259434b8SMarc-André Lureau  libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 $libs_qga"
7263457a3f8SJuan Quintelafi
7273457a3f8SJuan Quintela
728487fefdbSAnthony Liguoriwerror=""
72985aa5189Sbellard
7307d13299dSbellardfor opt do
73189138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
7327d13299dSbellard  case "$opt" in
7332efc3265Sbellard  --help|-h) show_help=yes
7342efc3265Sbellard  ;;
73599123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
73699123e13SMike Frysinger  ;;
737b1a550a0Spbrook  --prefix=*) prefix="$optarg"
7387d13299dSbellard  ;;
739b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
74032ce6337Sbellard  ;;
741ca4deeb1SPaolo Bonzini  --source-path=*)
7427d13299dSbellard  ;;
743ac0df51dSaliguori  --cross-prefix=*)
7447d13299dSbellard  ;;
745ac0df51dSaliguori  --cc=*)
7467d13299dSbellard  ;;
747b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
74883469015Sbellard  ;;
74983f73fceSTomoki Sekiyama  --cxx=*)
75083f73fceSTomoki Sekiyama  ;;
751e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
752e007dbecSMichael S. Tsirkin  ;;
7533c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
7543c4a4d0dSPeter Maydell  ;;
755b1a550a0Spbrook  --make=*) make="$optarg"
7567d13299dSbellard  ;;
7576a882643Spbrook  --install=*) install="$optarg"
7586a882643Spbrook  ;;
759c886edfbSBlue Swirl  --python=*) python="$optarg"
760c886edfbSBlue Swirl  ;;
7611d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
7621d728c39SBlue Swirl  ;;
763e2d8830eSBrad  --smbd=*) smbd="$optarg"
764e2d8830eSBrad  ;;
765e2a2ed06SJuan Quintela  --extra-cflags=*)
7667d13299dSbellard  ;;
767e2a2ed06SJuan Quintela  --extra-ldflags=*)
7687d13299dSbellard  ;;
7695bc62e01SGerd Hoffmann  --enable-debug-info)
7705bc62e01SGerd Hoffmann  ;;
7715bc62e01SGerd Hoffmann  --disable-debug-info)
7725bc62e01SGerd Hoffmann  ;;
77317969268SFam Zheng  --enable-modules)
77417969268SFam Zheng      modules="yes"
77517969268SFam Zheng  ;;
7763aa88b31SStefan Hajnoczi  --disable-modules)
7773aa88b31SStefan Hajnoczi      modules="no"
7783aa88b31SStefan Hajnoczi  ;;
7792ff6b91eSJuan Quintela  --cpu=*)
7807d13299dSbellard  ;;
781b1a550a0Spbrook  --target-list=*) target_list="$optarg"
782de83cd02Sbellard  ;;
7835b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
7845b808275SLluís Vilanova  ;;
7855b808275SLluís Vilanova  # XXX: backwards compatibility
7865b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
78794a420b1SStefan Hajnoczi  ;;
78874242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
7899410b56cSPrerna Saxena  ;;
7907d13299dSbellard  --enable-gprof) gprof="yes"
7917d13299dSbellard  ;;
7921d728c39SBlue Swirl  --enable-gcov) gcov="yes"
7931d728c39SBlue Swirl  ;;
79479427693SLoïc Minier  --static)
79579427693SLoïc Minier    static="yes"
79679427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
79717884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
79843ce4dfeSbellard  ;;
7990b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
8000b24e75fSPaolo Bonzini  ;;
8010b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
8020b24e75fSPaolo Bonzini  ;;
8033aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
8043aa5d2beSAlon Levy  ;;
8058bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
8068bf188aaSMichael Tokarev  ;;
8070f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
8080f94d6daSAlon Levy  ;;
809528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
8100b24e75fSPaolo Bonzini  ;;
811023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
812023d3d67SEduardo Habkost  ;;
813850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
8140b24e75fSPaolo Bonzini  ;;
815ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
81607381cc1SAnthony Liguori  ;;
817785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
818785c23aeSLuiz Capitulino  ;;
819785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
820023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
821023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
822023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
823023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
824023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
825023ddd74SMax Filippov    # lots of directory switches by default.
826023ddd74SMax Filippov  ;;
827e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
828e2134eb9SGerd Hoffmann  ;;
829e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
830e2134eb9SGerd Hoffmann  ;;
83174880fe2SRobert Schiele  --without-pixman) pixman="none"
83274880fe2SRobert Schiele  ;;
83397a847bcSbellard  --disable-sdl) sdl="no"
83497a847bcSbellard  ;;
835c4198157SJuan Quintela  --enable-sdl) sdl="yes"
836c4198157SJuan Quintela  ;;
83747c03744SDave Airlie  --with-sdlabi=*) sdlabi="$optarg"
83847c03744SDave Airlie  ;;
8393556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
8403556c233SPaolo Bonzini  ;;
8413556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
8423556c233SPaolo Bonzini  ;;
843983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
844983eef5aSMeador Inge  ;;
845983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
846983eef5aSMeador Inge  ;;
847821601eaSJes Sorensen  --disable-vnc) vnc="no"
848821601eaSJes Sorensen  ;;
849821601eaSJes Sorensen  --enable-vnc) vnc="yes"
850821601eaSJes Sorensen  ;;
8512f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
8522f6a1ab0Sblueswir1  ;;
8530c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
8540c58ac1cSmalc  ;;
85589138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
856b64ec4e4SFam Zheng  ;;
85789138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
858eb852011SMarkus Armbruster  ;;
859f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
860f8393946Saurel32  ;;
861f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
862f8393946Saurel32  ;;
863f3d08ee6SPaul Brook  --enable-debug)
864f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
865f3d08ee6SPaul Brook      debug_tcg="yes"
866f3d08ee6SPaul Brook      debug="yes"
867f3d08ee6SPaul Brook      strip_opt="no"
868b553a042SJohn Snow      fortify_source="no"
869f3d08ee6SPaul Brook  ;;
87003b4fe7dSaliguori  --enable-sparse) sparse="yes"
87103b4fe7dSaliguori  ;;
87203b4fe7dSaliguori  --disable-sparse) sparse="no"
87303b4fe7dSaliguori  ;;
8741625af87Saliguori  --disable-strip) strip_opt="no"
8751625af87Saliguori  ;;
8762f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
8772f9606b3Saliguori  ;;
878ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
879ea784e3bSJuan Quintela  ;;
8802f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
8812f6f5c7aSCorentin Chary  ;;
8822f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
8832f6f5c7aSCorentin Chary  ;;
884efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
885efe556adSCorentin Chary  ;;
886efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
887efe556adSCorentin Chary  ;;
888443f1376Sbellard  --disable-slirp) slirp="no"
889c20709aaSbellard  ;;
890e0e6c8c0Saliguori  --disable-vde) vde="no"
8918a16d273Sths  ;;
892dfb278bdSJuan Quintela  --enable-vde) vde="yes"
893dfb278bdSJuan Quintela  ;;
89458952137SVincenzo Maffione  --disable-netmap) netmap="no"
89558952137SVincenzo Maffione  ;;
89658952137SVincenzo Maffione  --enable-netmap) netmap="yes"
89758952137SVincenzo Maffione  ;;
898e37630caSaliguori  --disable-xen) xen="no"
899e37630caSaliguori  ;;
900fc321b4bSJuan Quintela  --enable-xen) xen="yes"
901fc321b4bSJuan Quintela  ;;
902eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
903eb6fda0fSAnthony PERARD  ;;
904eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
905eb6fda0fSAnthony PERARD  ;;
90664a7ad6fSIan Campbell  --disable-xen-pv-domain-build) xen_pv_domain_build="no"
90764a7ad6fSIan Campbell  ;;
90864a7ad6fSIan Campbell  --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
90964a7ad6fSIan Campbell  ;;
9102e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
9112e4d9fb1Saurel32  ;;
9124ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
9134ffcedb6SJuan Quintela  ;;
914fb599c9aSbalrog  --disable-bluez) bluez="no"
915fb599c9aSbalrog  ;;
916a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
917a20a6f46SJuan Quintela  ;;
9187ba1e619Saliguori  --disable-kvm) kvm="no"
9197ba1e619Saliguori  ;;
920b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
921b31a0277SJuan Quintela  ;;
922*180fb750Szhanghailiang  --disable-colo) colo="no"
923*180fb750Szhanghailiang  ;;
924*180fb750Szhanghailiang  --enable-colo) colo="yes"
925*180fb750Szhanghailiang  ;;
9269195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
9279195b2c2SStefan Weil  ;;
9289195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
9299195b2c2SStefan Weil  ;;
93047e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
93147e98658SCorey Bryant  ;;
93247e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
93347e98658SCorey Bryant  ;;
934cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
935cd4ec0b4SGerd Hoffmann  ;;
936cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
937cd4ec0b4SGerd Hoffmann  ;;
938c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
939c589b249SRonnie Sahlberg  ;;
940c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
941c589b249SRonnie Sahlberg  ;;
9426542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
9436542aa9cSPeter Lieven  ;;
9446542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
9456542aa9cSPeter Lieven  ;;
94605c2a3e7Sbellard  --enable-profiler) profiler="yes"
94705c2a3e7Sbellard  ;;
94814821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
94914821030SPavel Borzenkov  ;;
950c2de5c91Smalc  --enable-cocoa)
951c2de5c91Smalc      cocoa="yes" ;
95289138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
9535b0753e0Sbellard  ;;
954cad25d69Spbrook  --disable-system) softmmu="no"
9550a8e90f4Spbrook  ;;
956cad25d69Spbrook  --enable-system) softmmu="yes"
9570a8e90f4Spbrook  ;;
9580953a80fSZachary Amsden  --disable-user)
9590953a80fSZachary Amsden      linux_user="no" ;
9600953a80fSZachary Amsden      bsd_user="no" ;
9610953a80fSZachary Amsden  ;;
9620953a80fSZachary Amsden  --enable-user) ;;
963831b7825Sths  --disable-linux-user) linux_user="no"
9640a8e90f4Spbrook  ;;
965831b7825Sths  --enable-linux-user) linux_user="yes"
966831b7825Sths  ;;
96784778508Sblueswir1  --disable-bsd-user) bsd_user="no"
96884778508Sblueswir1  ;;
96984778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
97084778508Sblueswir1  ;;
97140d6444eSAvi Kivity  --enable-pie) pie="yes"
97234005a00SKirill A. Shutemov  ;;
97340d6444eSAvi Kivity  --disable-pie) pie="no"
97434005a00SKirill A. Shutemov  ;;
97585aa5189Sbellard  --enable-werror) werror="yes"
97685aa5189Sbellard  ;;
97785aa5189Sbellard  --disable-werror) werror="no"
97885aa5189Sbellard  ;;
97963678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
98063678e17SSteven Noonan  ;;
98163678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
98263678e17SSteven Noonan  ;;
9834d3b6f6eSbalrog  --disable-curses) curses="no"
9844d3b6f6eSbalrog  ;;
985c584a6d0SJuan Quintela  --enable-curses) curses="yes"
986c584a6d0SJuan Quintela  ;;
987769ce76dSAlexander Graf  --disable-curl) curl="no"
988769ce76dSAlexander Graf  ;;
989788c8196SJuan Quintela  --enable-curl) curl="yes"
990788c8196SJuan Quintela  ;;
9912df87df7SJuan Quintela  --disable-fdt) fdt="no"
9922df87df7SJuan Quintela  ;;
9932df87df7SJuan Quintela  --enable-fdt) fdt="yes"
9942df87df7SJuan Quintela  ;;
9955c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
9965c6c3a6cSChristoph Hellwig  ;;
9975c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
9985c6c3a6cSChristoph Hellwig  ;;
999758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1000758e8e38SVenkateswararao Jujjuri (JV)  ;;
1001758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1002758e8e38SVenkateswararao Jujjuri (JV)  ;;
100377755340Sths  --disable-blobs) blobs="no"
100477755340Sths  ;;
10054a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
10064a19f1ecSpbrook  ;;
1007519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1008519175a2SAlex Barcelo  ;;
100970c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
101070c60c08SStefan Hajnoczi  ;;
101170c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
101270c60c08SStefan Hajnoczi  ;;
10137d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
10147d992e4dSPeter Lieven  ;;
1015a25dba17SJuan Quintela  --disable-docs) docs="no"
101670ec5dc0SAnthony Liguori  ;;
1017a25dba17SJuan Quintela  --enable-docs) docs="yes"
101883a3ab8bSJuan Quintela  ;;
1019d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1020d5970055SMichael S. Tsirkin  ;;
1021d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1022d5970055SMichael S. Tsirkin  ;;
10235e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
10245e9be92dSNicholas Bellinger  ;;
10255e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
10265e9be92dSNicholas Bellinger  ;;
1027fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1028fc0b9b0eSStefan Hajnoczi  ;;
1029fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1030fc0b9b0eSStefan Hajnoczi  ;;
1031da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
103220ff075bSMichael Walle  ;;
1033da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
103420ff075bSMichael Walle  ;;
1035f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1036f27aaf4bSChristian Brunner  ;;
1037f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1038f27aaf4bSChristian Brunner  ;;
10398c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
10408c84cf11SSergei Trofimovich  ;;
10418c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
10428c84cf11SSergei Trofimovich  ;;
10437b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1044111a38b0SRobert Relyea  ;;
10457b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1046111a38b0SRobert Relyea  ;;
10472b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
10482b2325ffSGerd Hoffmann  ;;
10492b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
10502b2325ffSGerd Hoffmann  ;;
105169354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
105269354a83SHans de Goede  ;;
105369354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
105469354a83SHans de Goede  ;;
10551ece9905SAlon Levy  --disable-zlib-test) zlib="no"
10561ece9905SAlon Levy  ;;
1057b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1058b25c9dffSStefan Weil  ;;
1059607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1060607dacd0Sqiaonuohan  ;;
1061b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1062b25c9dffSStefan Weil  ;;
1063607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1064607dacd0Sqiaonuohan  ;;
10656b383c08SPeter Wu  --disable-bzip2) bzip2="no"
10666b383c08SPeter Wu  ;;
10676b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
10686b383c08SPeter Wu  ;;
1069d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1070d138cee9SMichael Roth  ;;
1071d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1072d138cee9SMichael Roth  ;;
10739dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
10749dacf32dSYossi Hindin  ;;
10759dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
10769dacf32dSYossi Hindin  ;;
1077d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1078d9840e25STomoki Sekiyama  ;;
1079d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1080d9840e25STomoki Sekiyama  ;;
1081d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1082d9840e25STomoki Sekiyama  ;;
1083d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1084d9840e25STomoki Sekiyama  ;;
1085d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1086d9840e25STomoki Sekiyama  ;;
1087d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1088d9840e25STomoki Sekiyama  ;;
10894b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
10904b1c11fdSDaniel P. Berrange  ;;
10914b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
10924b1c11fdSDaniel P. Berrange  ;;
1093f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1094f794573eSEduardo Otubo  ;;
1095f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1096f794573eSEduardo Otubo  ;;
1097eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1098eb100396SBharata B Rao  ;;
1099eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1100eb100396SBharata B Rao  ;;
1101c9a12e75SChrysostomos Nanakos  --disable-archipelago) archipelago="no"
1102c9a12e75SChrysostomos Nanakos  ;;
1103c9a12e75SChrysostomos Nanakos  --enable-archipelago) archipelago="yes"
1104c9a12e75SChrysostomos Nanakos  ;;
110552b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
110652b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1107583f6e7bSStefan Hajnoczi  ;;
1108cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1109cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1110cb6414dfSFam Zheng  ;;
1111315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1112315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1113315d3184SFam Zheng  ;;
1114a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1115a4ccabcfSAnthony Liguori  ;;
1116a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1117a4ccabcfSAnthony Liguori  ;;
1118a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1119a1c5e949SDaniel P. Berrange  ;;
1120ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1121ddbb0d09SDaniel P. Berrange  ;;
1122ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1123ddbb0d09SDaniel P. Berrange  ;;
112491bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
112591bfcdb0SDaniel P. Berrange  ;;
112691bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
112791bfcdb0SDaniel P. Berrange  ;;
112891bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
112991bfcdb0SDaniel P. Berrange  ;;
113091bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
113191bfcdb0SDaniel P. Berrange  ;;
11322da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
11332da776dbSMichael R. Hines  ;;
11342da776dbSMichael R. Hines  --disable-rdma) rdma="no"
11352da776dbSMichael R. Hines  ;;
1136528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
1137528de90aSDaniel P. Berrange  ;;
1138bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1139bbbf9bfbSStefan Weil  ;;
1140bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1141bbbf9bfbSStefan Weil  ;;
11429d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
11439d9e1521SGerd Hoffmann  ;;
11449d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
11459d9e1521SGerd Hoffmann  ;;
1146e91c793cSCole Robinson  --disable-tpm) tpm="no"
1147e91c793cSCole Robinson  ;;
1148ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1149ab214c29SStefan Berger  ;;
11500a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
11510a12ec87SRichard W.M. Jones  ;;
11520a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
11530a12ec87SRichard W.M. Jones  ;;
1154a99d57bbSWanlong Gao  --disable-numa) numa="no"
1155a99d57bbSWanlong Gao  ;;
1156a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1157a99d57bbSWanlong Gao  ;;
11582847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
11592847b469SFam Zheng  ;;
11602847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
11612847b469SFam Zheng  ;;
11627b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
11637b01cb97SAlexandre Derumier  ;;
11647b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
11657b01cb97SAlexandre Derumier  ;;
1166a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1167a6b1d4c0SChanglong Xie  ;;
1168a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1169a6b1d4c0SChanglong Xie  ;;
11702d2ad6d0SFam Zheng  *)
11712d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
11722d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
11732d2ad6d0SFam Zheng      exit 1
11747f1559c6Sbalrog  ;;
11757d13299dSbellard  esac
11767d13299dSbellarddone
11777d13299dSbellard
1178f6f0b7d9SStefan Weilif ! has $python; then
1179f6f0b7d9SStefan Weil  error_exit "Python not found. Use --python=/path/to/python"
1180f6f0b7d9SStefan Weilfi
1181f6f0b7d9SStefan Weil
1182f6f0b7d9SStefan Weil# Note that if the Python conditional here evaluates True we will exit
1183f6f0b7d9SStefan Weil# with status 1 which is a shell 'false' value.
1184fec21036SMarkus Armbrusterif ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1185fec21036SMarkus Armbruster  error_exit "Cannot use '$python', Python 2.6 or later is required." \
1186f6f0b7d9SStefan Weil      "Note that Python 3 or later is not yet supported." \
1187f6f0b7d9SStefan Weil      "Use --python=/path/to/python to specify a supported Python."
1188f6f0b7d9SStefan Weilfi
1189f6f0b7d9SStefan Weil
1190fec21036SMarkus Armbruster# Suppress writing compiled files
1191f6f0b7d9SStefan Weilpython="$python -B"
1192f6f0b7d9SStefan Weil
119340293e58Sbellardcase "$cpu" in
1194e3608d66SRichard Henderson    ppc)
1195e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1196e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1197e3608d66SRichard Henderson           ;;
1198e3608d66SRichard Henderson    ppc64)
1199e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1200e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1201e3608d66SRichard Henderson           ;;
12029b9c37c3SRichard Henderson    sparc)
12030c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
120479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32 -mcpu=ultrasparc"
12053142255cSblueswir1           ;;
1206ed968ff1SJuan Quintela    sparc64)
12070c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
120879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
12093142255cSblueswir1           ;;
121076d83bdeSths    s390)
1211061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
121228d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
121328d7cc49SRichard Henderson           ;;
121428d7cc49SRichard Henderson    s390x)
1215061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
121628d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
121776d83bdeSths           ;;
121840293e58Sbellard    i386)
121979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
12200c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
12212b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
122240293e58Sbellard           ;;
122340293e58Sbellard    x86_64)
12247ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
12257ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
12267ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
12277ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
12280c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
12292b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1230379f6698SPaul Brook           ;;
1231c72b26ecSRichard Henderson    x32)
1232c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1233c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1234c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1235c72b26ecSRichard Henderson           ;;
123630163d89SPeter Maydell    # No special flags required for other host CPUs
12373142255cSblueswir1esac
12383142255cSblueswir1
123979f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
124079f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
124179f3b12fSPeter Crosthwaite
1242affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1243affc88ccSPeter Maydell# support, even if we're using TCI.
1244affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1245affc88ccSPeter Maydell  bsd_user="no"
1246affc88ccSPeter Maydell  linux_user="no"
1247affc88ccSPeter Maydellfi
1248affc88ccSPeter Maydell
124960e0df25SPeter Maydelldefault_target_list=""
125060e0df25SPeter Maydell
12516e92f823SPeter Maydellmak_wilds=""
12526e92f823SPeter Maydell
125360e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
12546e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
125560e0df25SPeter Maydellfi
125660e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
12576e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
125860e0df25SPeter Maydellfi
125960e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
12606e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
126160e0df25SPeter Maydellfi
126260e0df25SPeter Maydell
12636e92f823SPeter Maydellfor config in $mak_wilds; do
12646e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
12656e92f823SPeter Maydelldone
12666e92f823SPeter Maydell
1267af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1268af5db58eSpbrookcat << EOF
1269af5db58eSpbrook
1270af5db58eSpbrookUsage: configure [options]
1271af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1272af5db58eSpbrook
127308fb77edSStefan WeilStandard options:
127408fb77edSStefan Weil  --help                   print this message
127508fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
127608fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
127708fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
127808fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
127908fb77edSStefan Weil$(echo Available targets: $default_target_list | \
128008fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
128108fb77edSStefan Weil
128208fb77edSStefan WeilAdvanced options (experts only):
128308fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
128408fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
128508fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
128608fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
128708fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
128808fb77edSStefan Weil                           build time
128908fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
129008fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
129108fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
129208fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
129308fb77edSStefan Weil  --make=MAKE              use specified make [$make]
129408fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
129508fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
129608fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
129708fb77edSStefan Weil  --static                 enable static build [$static]
129808fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
129908fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
130008fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
130108fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
130208fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
130308fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
130408fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
1305e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
130608fb77edSStefan Weil  --enable-debug           enable common debug build options
130708fb77edSStefan Weil  --disable-strip          disable stripping binaries
130808fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
130963678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
131008fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
131108fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
131208fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
131308fb77edSStefan Weil  --block-drv-rw-whitelist=L
131408fb77edSStefan Weil                           set block driver read-write whitelist
131508fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
131608fb77edSStefan Weil  --block-drv-ro-whitelist=L
131708fb77edSStefan Weil                           set block driver read-only whitelist
131808fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
13195b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
132008fb77edSStefan Weil                           Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
132108fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
132208fb77edSStefan Weil                           Default:trace-<pid>
1323c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1324c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1325c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1326c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
132708fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
132808fb77edSStefan Weil                           gthread, ucontext, sigaltstack, windows
132908fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
133008fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
1331c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1332c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1333c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1334a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1335c23f23b9SMichael Tokarev
1336c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1337c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1338c23f23b9SMichael Tokarev
1339c23f23b9SMichael Tokarev  system          all system emulation targets
1340c23f23b9SMichael Tokarev  user            supported user emulation targets
1341c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1342c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1343c23f23b9SMichael Tokarev  docs            build documentation
1344c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1345c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1346c23f23b9SMichael Tokarev  pie             Position Independent Executables
1347c23f23b9SMichael Tokarev  modules         modules support
1348c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1349c23f23b9SMichael Tokarev  debug-info      debugging information
1350c23f23b9SMichael Tokarev  sparse          sparse checker
1351c23f23b9SMichael Tokarev
1352ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
135391bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
135491bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
1355c23f23b9SMichael Tokarev  sdl             SDL UI
1356c23f23b9SMichael Tokarev  --with-sdlabi     select preferred SDL ABI 1.2 or 2.0
1357c23f23b9SMichael Tokarev  gtk             gtk UI
1358c23f23b9SMichael Tokarev  --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
1359c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1360c23f23b9SMichael Tokarev  curses          curses UI
1361c23f23b9SMichael Tokarev  vnc             VNC UI support
1362c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1363c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1364c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1365c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1366c23f23b9SMichael Tokarev  virtfs          VirtFS
1367c23f23b9SMichael Tokarev  xen             xen backend driver support
1368c23f23b9SMichael Tokarev  xen-pci-passthrough
1369c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1370c23f23b9SMichael Tokarev  curl            curl connectivity
1371c23f23b9SMichael Tokarev  fdt             fdt device tree
1372c23f23b9SMichael Tokarev  bluez           bluez stack connectivity
1373c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1374*180fb750Szhanghailiang  colo            COarse-grain LOck-stepping VM for Non-stop Service
1375c23f23b9SMichael Tokarev  rdma            RDMA-based migration support
1376c23f23b9SMichael Tokarev  vde             support for vde network
1377c23f23b9SMichael Tokarev  netmap          support for netmap network
1378c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1379c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1380c23f23b9SMichael Tokarev  attr            attr and xattr support
1381c23f23b9SMichael Tokarev  vhost-net       vhost-net acceleration support
1382c23f23b9SMichael Tokarev  spice           spice
1383c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1384c23f23b9SMichael Tokarev  libiscsi        iscsi support
1385c23f23b9SMichael Tokarev  libnfs          nfs support
13867b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1387c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1388c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1389c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1390c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1391c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1392c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
1393c23f23b9SMichael Tokarev  seccomp         seccomp support
1394c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1395c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1396c23f23b9SMichael Tokarev  archipelago     Archipelago backend
1397c23f23b9SMichael Tokarev  tpm             TPM support
1398c23f23b9SMichael Tokarev  libssh2         ssh block device support
1399c23f23b9SMichael Tokarev  numa            libnuma support
1400c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
14017b01cb97SAlexandre Derumier  jemalloc        jemalloc support
1402a6b1d4c0SChanglong Xie  replication     replication support
140308fb77edSStefan Weil
140408fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1405af5db58eSpbrookEOF
14062d2ad6d0SFam Zhengexit 0
1407af5db58eSpbrookfi
1408af5db58eSpbrook
1409359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1410359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1411359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1412359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1413359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1414359bc95dSPeter Maydell    else
141576ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1416359bc95dSPeter Maydell    fi
1417359bc95dSPeter Maydellfi
1418359bc95dSPeter Maydell
14199c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
14209c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
14219c83ffd8SPeter Maydellif test -z "$werror" ; then
14229c83ffd8SPeter Maydell    if test -d "$source_path/.git" -a \
1423e4650c81SThomas Huth        \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
14249c83ffd8SPeter Maydell        werror="yes"
14259c83ffd8SPeter Maydell    else
14269c83ffd8SPeter Maydell        werror="no"
14279c83ffd8SPeter Maydell    fi
14289c83ffd8SPeter Maydellfi
14299c83ffd8SPeter Maydell
14308d05095cSPaolo Bonzini# check that the C compiler works.
143193b25869SJohn Snowwrite_c_skeleton;
14328d05095cSPaolo Bonziniif compile_object ; then
14338d05095cSPaolo Bonzini  : C compiler works ok
14348d05095cSPaolo Bonzinielse
143576ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
14368d05095cSPaolo Bonzinifi
14370ef74c74SPeter Maydellif ! compile_prog ; then
14380ef74c74SPeter Maydell    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
14390ef74c74SPeter Maydellfi
14408d05095cSPaolo Bonzini
144198b21dcdSPeter Maydell# Check that the C++ compiler exists and works with the C compiler
144298b21dcdSPeter Maydellif has $cxx; then
144398b21dcdSPeter Maydell    cat > $TMPC <<EOF
144498b21dcdSPeter Maydellint c_function(void);
144598b21dcdSPeter Maydellint main(void) { return c_function(); }
144698b21dcdSPeter MaydellEOF
144798b21dcdSPeter Maydell
144898b21dcdSPeter Maydell    compile_object
144998b21dcdSPeter Maydell
14509c83ffd8SPeter Maydell    cat > $TMPCXX <<EOF
145198b21dcdSPeter Maydellextern "C" {
145298b21dcdSPeter Maydell   int c_function(void);
145398b21dcdSPeter Maydell}
145498b21dcdSPeter Maydellint c_function(void) { return 42; }
145598b21dcdSPeter MaydellEOF
145698b21dcdSPeter Maydell
14579c83ffd8SPeter Maydell    update_cxxflags
14589c83ffd8SPeter Maydell
14599c83ffd8SPeter Maydell    if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
146098b21dcdSPeter Maydell        # C++ compiler $cxx works ok with C compiler $cc
146198b21dcdSPeter Maydell        :
146298b21dcdSPeter Maydell    else
146398b21dcdSPeter Maydell        echo "C++ compiler $cxx does not work with C compiler $cc"
146498b21dcdSPeter Maydell        echo "Disabling C++ specific optional code"
146598b21dcdSPeter Maydell        cxx=
146698b21dcdSPeter Maydell    fi
146798b21dcdSPeter Maydellelse
146898b21dcdSPeter Maydell    echo "No C++ compiler available; disabling C++ specific optional code"
146998b21dcdSPeter Maydell    cxx=
147098b21dcdSPeter Maydellfi
147198b21dcdSPeter Maydell
14728d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
14738d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
14748d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1475435405acSPranith Kumargcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1476c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
147771429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
14786ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
14796ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
14806ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
14816ca026cbSPeter Maydell# so it's too error prone.
148293b25869SJohn Snow
148393b25869SJohn Snowcc_has_warning_flag() {
148493b25869SJohn Snow    write_c_skeleton;
148593b25869SJohn Snow
1486a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1487a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1488a1d29d6cSPeter Maydell    # warning options).
148993b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
149093b25869SJohn Snow    compile_prog "-Werror $optflag" ""
149193b25869SJohn Snow}
149293b25869SJohn Snow
149393b25869SJohn Snowfor flag in $gcc_flags; do
149493b25869SJohn Snow    if cc_has_warning_flag $flag ; then
14958d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
14968d05095cSPaolo Bonzini    fi
14978d05095cSPaolo Bonzinidone
14988d05095cSPaolo Bonzini
149963678e17SSteven Noonanif test "$stack_protector" != "no"; then
1500fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1501fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1502fccd35a0SRodrigo Rebello{
1503fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1504fccd35a0SRodrigo Rebello    while (*c) {
1505fccd35a0SRodrigo Rebello        *p++ = *c++;
1506fccd35a0SRodrigo Rebello    }
1507fccd35a0SRodrigo Rebello    return 0;
1508fccd35a0SRodrigo Rebello}
1509fccd35a0SRodrigo RebelloEOF
151063678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
15113b463a3fSMiroslav Rezanina  sp_on=0
151263678e17SSteven Noonan  for flag in $gcc_flags; do
1513590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1514590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1515590e5dd9SPeter Maydell    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1516590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
151763678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
15183b463a3fSMiroslav Rezanina      sp_on=1
151963678e17SSteven Noonan      break
152063678e17SSteven Noonan    fi
152163678e17SSteven Noonan  done
15223b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
15233b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
15243b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
15253b463a3fSMiroslav Rezanina    fi
15263b463a3fSMiroslav Rezanina  fi
152737746c5eSMarc-André Lureaufi
152837746c5eSMarc-André Lureau
1529cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1530cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1531cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1532cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1533cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1534cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1535cbdd1999SPaolo Bonziniint main(void) { return 0; }
1536cbdd1999SPaolo Bonzini#else
1537cbdd1999SPaolo Bonzini#error No bug in this compiler.
1538cbdd1999SPaolo Bonzini#endif
1539cbdd1999SPaolo BonziniEOF
1540cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1541cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1542cbdd1999SPaolo Bonzinifi
1543cbdd1999SPaolo Bonzini
154440d6444eSAvi Kivityif test "$static" = "yes" ; then
1545aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1546aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1547aa0d1f44SPaolo Bonzini  fi
154840d6444eSAvi Kivity  if test "$pie" = "yes" ; then
154976ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
155040d6444eSAvi Kivity  else
155140d6444eSAvi Kivity    pie="no"
155240d6444eSAvi Kivity  fi
155340d6444eSAvi Kivityfi
155440d6444eSAvi Kivity
1555768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
1556768b7855SEmilio G. Cota  cat > $TMPC << EOF
1557768b7855SEmilio G. Cotastatic __thread int tls_var;
1558768b7855SEmilio G. Cotaint main(void) { return tls_var; }
1559768b7855SEmilio G. CotaEOF
1560768b7855SEmilio G. Cota
1561768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
1562768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
1563768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
1564768b7855SEmilio G. Cotafi
1565768b7855SEmilio G. Cota
156640d6444eSAvi Kivityif test "$pie" = ""; then
156740d6444eSAvi Kivity  case "$cpu-$targetos" in
1568c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
156940d6444eSAvi Kivity      ;;
157040d6444eSAvi Kivity    *)
157140d6444eSAvi Kivity      pie="no"
157240d6444eSAvi Kivity      ;;
157340d6444eSAvi Kivity  esac
157440d6444eSAvi Kivityfi
157540d6444eSAvi Kivity
157640d6444eSAvi Kivityif test "$pie" != "no" ; then
157740d6444eSAvi Kivity  cat > $TMPC << EOF
157821d4a791SAvi Kivity
157921d4a791SAvi Kivity#ifdef __linux__
158021d4a791SAvi Kivity#  define THREAD __thread
158121d4a791SAvi Kivity#else
158221d4a791SAvi Kivity#  define THREAD
158321d4a791SAvi Kivity#endif
158421d4a791SAvi Kivity
158521d4a791SAvi Kivitystatic THREAD int tls_var;
158621d4a791SAvi Kivity
158721d4a791SAvi Kivityint main(void) { return tls_var; }
158821d4a791SAvi Kivity
158940d6444eSAvi KivityEOF
159040d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
159140d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
159240d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
159340d6444eSAvi Kivity    pie="yes"
159440d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
159540d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
159640d6444eSAvi Kivity    fi
159740d6444eSAvi Kivity  else
159840d6444eSAvi Kivity    if test "$pie" = "yes"; then
159976ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
160040d6444eSAvi Kivity    else
160140d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
160240d6444eSAvi Kivity      pie="no"
160340d6444eSAvi Kivity    fi
160440d6444eSAvi Kivity  fi
160546eef33bSBrad
1606e4a7b344SStefan Hajnoczi  if compile_prog "-Werror -fno-pie" "-nopie"; then
160746eef33bSBrad    CFLAGS_NOPIE="-fno-pie"
160846eef33bSBrad    LDFLAGS_NOPIE="-nopie"
160946eef33bSBrad  fi
161040d6444eSAvi Kivityfi
161140d6444eSAvi Kivity
161209dada40SPaolo Bonzini##########################################
161309dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
161409dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
161509dada40SPaolo Bonzini# specification is necessary
161609dada40SPaolo Bonzini
161709dada40SPaolo Bonziniif test "$cpu" = "i386"; then
161809dada40SPaolo Bonzini  cat > $TMPC << EOF
161909dada40SPaolo Bonzinistatic int sfaa(int *ptr)
162009dada40SPaolo Bonzini{
162109dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
162209dada40SPaolo Bonzini}
162309dada40SPaolo Bonzini
162409dada40SPaolo Bonziniint main(void)
162509dada40SPaolo Bonzini{
162609dada40SPaolo Bonzini  int val = 42;
16271405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
162809dada40SPaolo Bonzini  sfaa(&val);
162909dada40SPaolo Bonzini  return val;
163009dada40SPaolo Bonzini}
163109dada40SPaolo BonziniEOF
163209dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
163309dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
163409dada40SPaolo Bonzini  fi
163509dada40SPaolo Bonzinifi
163609dada40SPaolo Bonzini
163709dada40SPaolo Bonzini#########################################
1638ec530c81Sbellard# Solaris specific configure tool chain decisions
163909dada40SPaolo Bonzini
1640ec530c81Sbellardif test "$solaris" = "yes" ; then
16416792aa11SLoïc Minier  if has $install; then
16426792aa11SLoïc Minier    :
16436792aa11SLoïc Minier  else
164476ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
164576ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
164676ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1647ec530c81Sbellard  fi
164889138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
164976ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
165076ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
165176ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1652ec530c81Sbellard  fi
16536792aa11SLoïc Minier  if has ar; then
16546792aa11SLoïc Minier    :
16556792aa11SLoïc Minier  else
1656ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
165776ad07a4SPeter Maydell      error_exit "No path includes ar" \
165876ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1659ec530c81Sbellard    fi
166076ad07a4SPeter Maydell    error_exit "No path includes ar"
1661ec530c81Sbellard  fi
1662ec530c81Sbellardfi
1663ec530c81Sbellard
1664afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1665121afa9eSAnthony Liguori    target_list="$default_target_list"
1666121afa9eSAnthony Liguorielse
166789138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
16685327cf48Sbellardfi
166925b48338SPeter Maydell
167025b48338SPeter Maydell# Check that we recognised the target name; this allows a more
167125b48338SPeter Maydell# friendly error message than if we let it fall through.
167225b48338SPeter Maydellfor target in $target_list; do
167325b48338SPeter Maydell    case " $default_target_list " in
167425b48338SPeter Maydell        *" $target "*)
167525b48338SPeter Maydell            ;;
167625b48338SPeter Maydell        *)
167725b48338SPeter Maydell            error_exit "Unknown target name '$target'"
167825b48338SPeter Maydell            ;;
167925b48338SPeter Maydell    esac
168025b48338SPeter Maydelldone
168125b48338SPeter Maydell
1682f55fe278SPaolo Bonzini# see if system emulation was really requested
1683f55fe278SPaolo Bonzinicase " $target_list " in
1684f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1685f55fe278SPaolo Bonzini  ;;
1686f55fe278SPaolo Bonzini  *) softmmu=no
1687f55fe278SPaolo Bonzini  ;;
1688f55fe278SPaolo Bonziniesac
16895327cf48Sbellard
1690249247c9SJuan Quintelafeature_not_found() {
1691249247c9SJuan Quintela  feature=$1
169221684af0SStewart Smith  remedy=$2
1693249247c9SJuan Quintela
169476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
169521684af0SStewart Smith      "configure was not able to find it." \
169621684af0SStewart Smith      "$remedy"
1697249247c9SJuan Quintela}
1698249247c9SJuan Quintela
16997d13299dSbellard# ---
17007d13299dSbellard# big/little endian test
17017d13299dSbellardcat > $TMPC << EOF
170261cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
170361cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
170461cc919fSMike Frysingerextern int foo(short *, short *);
170561cc919fSMike Frysingerint main(int argc, char *argv[]) {
170661cc919fSMike Frysinger    return foo(big_endian, little_endian);
17077d13299dSbellard}
17087d13299dSbellardEOF
17097d13299dSbellard
171061cc919fSMike Frysingerif compile_object ; then
171161cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
171261cc919fSMike Frysinger        bigendian="yes"
171361cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
171461cc919fSMike Frysinger        bigendian="no"
17157d13299dSbellard    else
17167d13299dSbellard        echo big/little test failed
17177d13299dSbellard    fi
17187d13299dSbellardelse
171961cc919fSMike Frysinger    echo big/little test failed
17207d13299dSbellardfi
17217d13299dSbellard
1722b0a47e79SJuan Quintela##########################################
1723a30878e7SPeter Maydell# cocoa implies not SDL or GTK
1724a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
1725a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
1726a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
1727a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
1728a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1729a30878e7SPeter Maydell    fi
1730a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
1731a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1732a30878e7SPeter Maydell    fi
1733a30878e7SPeter Maydell    gtk=no
1734a30878e7SPeter Maydell    sdl=no
1735a30878e7SPeter Maydellfi
1736a30878e7SPeter Maydell
17376b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
17386b39b063SEric Blakecat > $TMPC << EOF
17396b39b063SEric Blake#include <stdint.h>
17406b39b063SEric Blake#include <stdio.h>
17416b39b063SEric Blakeint main(int argc, char *argv[]) {
17426b39b063SEric Blake    return printf("%zu", SIZE_MAX);
17436b39b063SEric Blake}
17446b39b063SEric BlakeEOF
17456b39b063SEric Blakehave_broken_size_max=no
17466b39b063SEric Blakeif ! compile_object -Werror ; then
17476b39b063SEric Blake    have_broken_size_max=yes
17486b39b063SEric Blakefi
17496b39b063SEric Blake
1750a30878e7SPeter Maydell##########################################
1751015a33bdSGonglei# L2TPV3 probe
1752015a33bdSGonglei
1753015a33bdSGongleicat > $TMPC <<EOF
1754015a33bdSGonglei#include <sys/socket.h>
1755bff6cb72SMichael Tokarev#include <linux/ip.h>
1756015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
1757015a33bdSGongleiEOF
1758015a33bdSGongleiif compile_prog "" "" ; then
1759015a33bdSGonglei  l2tpv3=yes
1760015a33bdSGongleielse
1761015a33bdSGonglei  l2tpv3=no
1762015a33bdSGongleifi
1763015a33bdSGonglei
1764015a33bdSGonglei##########################################
17654d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
17664d9310f4SDaniel P. Berrange
17674d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
17684d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
17694d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
17704d9310f4SDaniel P. Berrange    #
17714d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
17724d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
17734d9310f4SDaniel P. Berrange    #
17744d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
17754d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
17764d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
17774d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
17784d9310f4SDaniel P. Berrange    # that for you.
17794d9310f4SDaniel P. Berrange    #
17804d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
17814d9310f4SDaniel P. Berrange    # are not in fact redundant.
17824d9310f4SDaniel P. Berrangecat > $TMPC << EOF
17834d9310f4SDaniel P. Berrange#include <unistd.h>
17844d9310f4SDaniel P. Berrange#include <time.h>
17854d9310f4SDaniel P. Berrange#undef localtime_r
17864d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
17874d9310f4SDaniel P. BerrangeEOF
17884d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
17894d9310f4SDaniel P. Berrange        localtime_r="yes"
17904d9310f4SDaniel P. Berrange    else
17914d9310f4SDaniel P. Berrange        localtime_r="no"
17924d9310f4SDaniel P. Berrange    fi
17934d9310f4SDaniel P. Berrangefi
17944d9310f4SDaniel P. Berrange
17954d9310f4SDaniel P. Berrange##########################################
1796779ab5e3SStefan Weil# pkg-config probe
1797779ab5e3SStefan Weil
1798779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
179976ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1800779ab5e3SStefan Weilfi
1801779ab5e3SStefan Weil
1802779ab5e3SStefan Weil##########################################
1803b0a47e79SJuan Quintela# NPTL probe
1804b0a47e79SJuan Quintela
180524cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1806bd0c5661Spbrook  cat > $TMPC <<EOF
1807bd0c5661Spbrook#include <sched.h>
180830813ceaSpbrook#include <linux/futex.h>
1809182eacc0SStefan Weilint main(void) {
1810bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1811bd0c5661Spbrook#error bork
1812bd0c5661Spbrook#endif
1813182eacc0SStefan Weil  return 0;
1814bd0c5661Spbrook}
1815bd0c5661SpbrookEOF
181624cb36a6SPeter Maydell  if ! compile_object ; then
181721684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
1818b0a47e79SJuan Quintela  fi
1819bd0c5661Spbrookfi
1820bd0c5661Spbrook
182111d9f695Sbellard##########################################
182299f2dbd3SLiang Li# avx2 optimization requirement check
182399f2dbd3SLiang Li
182499f2dbd3SLiang Licat > $TMPC << EOF
18254fb8320aSDr. David Alan Gilbert#pragma GCC push_options
18264fb8320aSDr. David Alan Gilbert#pragma GCC target("avx2")
18274fb8320aSDr. David Alan Gilbert#include <cpuid.h>
18284fb8320aSDr. David Alan Gilbert#include <immintrin.h>
18294fb8320aSDr. David Alan Gilbertstatic int bar(void *a) {
18305e33a872SRichard Henderson    __m256i x = *(__m256i *)a;
18315e33a872SRichard Henderson    return _mm256_testz_si256(x, x);
18324fb8320aSDr. David Alan Gilbert}
18335e33a872SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
183499f2dbd3SLiang LiEOF
18354fb8320aSDr. David Alan Gilbertif compile_object "" ; then
183699f2dbd3SLiang Li  avx2_opt="yes"
183799f2dbd3SLiang Lifi
183899f2dbd3SLiang Li
183999f2dbd3SLiang Li#########################################
1840ac62922eSbalrog# zlib check
1841ac62922eSbalrog
18421ece9905SAlon Levyif test "$zlib" != "no" ; then
1843ac62922eSbalrog    cat > $TMPC << EOF
1844ac62922eSbalrog#include <zlib.h>
1845ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1846ac62922eSbalrogEOF
184752166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1848ac62922eSbalrog        :
1849ac62922eSbalrog    else
185076ad07a4SPeter Maydell        error_exit "zlib check failed" \
185176ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1852ac62922eSbalrog    fi
18531ece9905SAlon Levyfi
1854eb0ecd5aSWill NewtonLIBS="$LIBS -lz"
1855ac62922eSbalrog
1856ac62922eSbalrog##########################################
1857607dacd0Sqiaonuohan# lzo check
1858607dacd0Sqiaonuohan
1859607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
1860607dacd0Sqiaonuohan    cat > $TMPC << EOF
1861607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
1862607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
1863607dacd0SqiaonuohanEOF
1864607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
1865607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
1866b25c9dffSStefan Weil        lzo="yes"
1867b25c9dffSStefan Weil    else
1868b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
1869b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
1870b25c9dffSStefan Weil        fi
1871b25c9dffSStefan Weil        lzo="no"
1872b25c9dffSStefan Weil    fi
1873607dacd0Sqiaonuohanfi
1874607dacd0Sqiaonuohan
1875607dacd0Sqiaonuohan##########################################
1876607dacd0Sqiaonuohan# snappy check
1877607dacd0Sqiaonuohan
1878607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
1879607dacd0Sqiaonuohan    cat > $TMPC << EOF
1880607dacd0Sqiaonuohan#include <snappy-c.h>
1881607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
1882607dacd0SqiaonuohanEOF
1883607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
1884607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
1885b25c9dffSStefan Weil        snappy="yes"
1886b25c9dffSStefan Weil    else
1887b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
1888b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
1889b25c9dffSStefan Weil        fi
1890b25c9dffSStefan Weil        snappy="no"
1891b25c9dffSStefan Weil    fi
1892607dacd0Sqiaonuohanfi
1893607dacd0Sqiaonuohan
1894607dacd0Sqiaonuohan##########################################
18956b383c08SPeter Wu# bzip2 check
18966b383c08SPeter Wu
18976b383c08SPeter Wuif test "$bzip2" != "no" ; then
18986b383c08SPeter Wu    cat > $TMPC << EOF
18996b383c08SPeter Wu#include <bzlib.h>
19006b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
19016b383c08SPeter WuEOF
19026b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
19036b383c08SPeter Wu        bzip2="yes"
19046b383c08SPeter Wu    else
19056b383c08SPeter Wu        if test "$bzip2" = "yes"; then
19066b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
19076b383c08SPeter Wu        fi
19086b383c08SPeter Wu        bzip2="no"
19096b383c08SPeter Wu    fi
19106b383c08SPeter Wufi
19116b383c08SPeter Wu
19126b383c08SPeter Wu##########################################
1913f794573eSEduardo Otubo# libseccomp check
1914f794573eSEduardo Otubo
1915f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
1916693e5910SAndrew Jones    case "$cpu" in
1917693e5910SAndrew Jones    i386|x86_64)
1918ba060c53Sdann frazier        libseccomp_minver="2.1.0"
1919693e5910SAndrew Jones        ;;
19205ce43972SJames Hogan    mips)
19215ce43972SJames Hogan        libseccomp_minver="2.2.0"
19225ce43972SJames Hogan        ;;
1923693e5910SAndrew Jones    arm|aarch64)
1924693e5910SAndrew Jones        libseccomp_minver="2.2.3"
1925693e5910SAndrew Jones        ;;
19263e684455SMichael Strosaker    ppc|ppc64)
19273e684455SMichael Strosaker        libseccomp_minver="2.3.0"
19283e684455SMichael Strosaker        ;;
1929693e5910SAndrew Jones    *)
1930693e5910SAndrew Jones        libseccomp_minver=""
1931693e5910SAndrew Jones        ;;
1932693e5910SAndrew Jones    esac
1933693e5910SAndrew Jones
1934693e5910SAndrew Jones    if test "$libseccomp_minver" != "" &&
1935693e5910SAndrew Jones       $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
193689138857SStefan Weil        libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
193789138857SStefan Weil        QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
1938f794573eSEduardo Otubo        seccomp="yes"
1939f794573eSEduardo Otubo    else
1940f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
1941693e5910SAndrew Jones            if test "$libseccomp_minver" != "" ; then
1942693e5910SAndrew Jones                feature_not_found "libseccomp" \
1943693e5910SAndrew Jones                    "Install libseccomp devel >= $libseccomp_minver"
1944693e5910SAndrew Jones            else
1945693e5910SAndrew Jones                feature_not_found "libseccomp" \
1946693e5910SAndrew Jones                    "libseccomp is not supported for host cpu $cpu"
1947693e5910SAndrew Jones            fi
1948896848f0SEduardo Otubo        fi
1949e84d5956SYann E. MORIN        seccomp="no"
1950f794573eSEduardo Otubo    fi
1951f794573eSEduardo Otubofi
1952f794573eSEduardo Otubo##########################################
1953e37630caSaliguori# xen probe
1954e37630caSaliguori
1955fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1956b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
19575eeb39c2SIan Campbell  xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1958d5b93ddfSAnthony PERARD
195950ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
196050ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
196150ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
196250ced5b3SStefan Weil
196350ced5b3SStefan Weil  # Xen (any)
196450ced5b3SStefan Weil  cat > $TMPC <<EOF
196550ced5b3SStefan Weil#include <xenctrl.h>
196650ced5b3SStefan Weilint main(void) {
196750ced5b3SStefan Weil  return 0;
196850ced5b3SStefan Weil}
196950ced5b3SStefan WeilEOF
197050ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
197150ced5b3SStefan Weil    # Xen not found
197250ced5b3SStefan Weil    if test "$xen" = "yes" ; then
197321684af0SStewart Smith      feature_not_found "xen" "Install xen devel"
197450ced5b3SStefan Weil    fi
197550ced5b3SStefan Weil    xen=no
197650ced5b3SStefan Weil
1977d5b93ddfSAnthony PERARD  # Xen unstable
197869deef08SPeter Maydell  elif
197969deef08SPeter Maydell      cat > $TMPC <<EOF &&
19805eeb39c2SIan Campbell/*
19815eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
19825eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
1983b6eb9b45SPaulina Szubarczyk *
1984b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
1985b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
1986b6eb9b45SPaulina Szubarczyk */
1987b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
1988b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
1989b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
1990b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
1991b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
1992b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
1993b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
1994b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
1995b6eb9b45SPaulina Szubarczyk#include <stdint.h>
1996b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
1997b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
1998b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
1999b6eb9b45SPaulina Szubarczyk#endif
2000b6eb9b45SPaulina Szubarczykint main(void) {
2001b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2002b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2003b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2004b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2005b6eb9b45SPaulina Szubarczyk  xen_domain_handle_t handle;
2006b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2007b6eb9b45SPaulina Szubarczyk
2008b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2009b6eb9b45SPaulina Szubarczyk
2010b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2011b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2012b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2013b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2014b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2015b6eb9b45SPaulina Szubarczyk  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2016b6eb9b45SPaulina Szubarczyk
2017b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2018b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2019b6eb9b45SPaulina Szubarczyk
2020b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2021b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2022b6eb9b45SPaulina Szubarczyk
2023b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2024b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2025b6eb9b45SPaulina Szubarczyk
2026b6eb9b45SPaulina Szubarczyk  return 0;
2027b6eb9b45SPaulina Szubarczyk}
2028b6eb9b45SPaulina SzubarczykEOF
2029b6eb9b45SPaulina Szubarczyk      compile_prog "" "$xen_libs $xen_stable_libs"
2030b6eb9b45SPaulina Szubarczyk    then
2031b6eb9b45SPaulina Szubarczyk    xen_ctrl_version=480
2032b6eb9b45SPaulina Szubarczyk    xen=yes
2033b6eb9b45SPaulina Szubarczyk  elif
2034b6eb9b45SPaulina Szubarczyk      cat > $TMPC <<EOF &&
2035b6eb9b45SPaulina Szubarczyk/*
2036b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2037b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
20385eeb39c2SIan Campbell */
20395eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
20405eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
20415eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
20425eeb39c2SIan Campbell#include <xenctrl.h>
20435eeb39c2SIan Campbell#include <xenstore.h>
20445eeb39c2SIan Campbell#include <xenevtchn.h>
20455eeb39c2SIan Campbell#include <xengnttab.h>
20465eeb39c2SIan Campbell#include <xenforeignmemory.h>
20475eeb39c2SIan Campbell#include <stdint.h>
20485eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
20495eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
20505eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
20515eeb39c2SIan Campbell#endif
20525eeb39c2SIan Campbellint main(void) {
20535eeb39c2SIan Campbell  xc_interface *xc = NULL;
20545eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
20555eeb39c2SIan Campbell  xenevtchn_handle *xe;
20565eeb39c2SIan Campbell  xengnttab_handle *xg;
20575eeb39c2SIan Campbell  xen_domain_handle_t handle;
20585eeb39c2SIan Campbell
20595eeb39c2SIan Campbell  xs_daemon_open();
20605eeb39c2SIan Campbell
20615eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
20625eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
20635eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
20645eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
20655eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
20665eeb39c2SIan Campbell  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
20675eeb39c2SIan Campbell
20685eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
20695eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
20705eeb39c2SIan Campbell
20715eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
20725eeb39c2SIan Campbell  xenevtchn_fd(xe);
20735eeb39c2SIan Campbell
20745eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
20755eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
20765eeb39c2SIan Campbell
20775eeb39c2SIan Campbell  return 0;
20785eeb39c2SIan Campbell}
20795eeb39c2SIan CampbellEOF
20805eeb39c2SIan Campbell      compile_prog "" "$xen_libs $xen_stable_libs"
20815eeb39c2SIan Campbell    then
20825eeb39c2SIan Campbell    xen_ctrl_version=471
20835eeb39c2SIan Campbell    xen=yes
20845eeb39c2SIan Campbell  elif
20855eeb39c2SIan Campbell      cat > $TMPC <<EOF &&
2086e37630caSaliguori#include <xenctrl.h>
2087cdadde39SRoger Pau Monne#include <stdint.h>
2088cdadde39SRoger Pau Monneint main(void) {
2089cdadde39SRoger Pau Monne  xc_interface *xc = NULL;
2090cdadde39SRoger Pau Monne  xen_domain_handle_t handle;
2091cdadde39SRoger Pau Monne  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2092cdadde39SRoger Pau Monne  return 0;
2093cdadde39SRoger Pau Monne}
2094cdadde39SRoger Pau MonneEOF
2095cdadde39SRoger Pau Monne      compile_prog "" "$xen_libs"
2096cdadde39SRoger Pau Monne    then
2097cdadde39SRoger Pau Monne    xen_ctrl_version=470
2098cdadde39SRoger Pau Monne    xen=yes
2099cdadde39SRoger Pau Monne
2100cdadde39SRoger Pau Monne  # Xen 4.6
2101cdadde39SRoger Pau Monne  elif
2102cdadde39SRoger Pau Monne      cat > $TMPC <<EOF &&
2103cdadde39SRoger Pau Monne#include <xenctrl.h>
2104e108a3c1SAnthony PERARD#include <xenstore.h>
2105d5b93ddfSAnthony PERARD#include <stdint.h>
2106d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2107d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2108d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2109d5b93ddfSAnthony PERARD#endif
2110d5b93ddfSAnthony PERARDint main(void) {
2111d5b93ddfSAnthony PERARD  xc_interface *xc;
2112d5b93ddfSAnthony PERARD  xs_daemon_open();
2113d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2114d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2115d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2116b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
21178688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2118d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
211920a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2120d8b441a3SJan Beulich  return 0;
2121d8b441a3SJan Beulich}
2122d8b441a3SJan BeulichEOF
2123d8b441a3SJan Beulich      compile_prog "" "$xen_libs"
2124d8b441a3SJan Beulich    then
2125d8b441a3SJan Beulich    xen_ctrl_version=460
2126d8b441a3SJan Beulich    xen=yes
2127d8b441a3SJan Beulich
2128d8b441a3SJan Beulich  # Xen 4.5
2129d8b441a3SJan Beulich  elif
2130d8b441a3SJan Beulich      cat > $TMPC <<EOF &&
2131d8b441a3SJan Beulich#include <xenctrl.h>
2132d8b441a3SJan Beulich#include <xenstore.h>
2133d8b441a3SJan Beulich#include <stdint.h>
2134d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2135d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2136d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2137d8b441a3SJan Beulich#endif
2138d8b441a3SJan Beulichint main(void) {
2139d8b441a3SJan Beulich  xc_interface *xc;
2140d8b441a3SJan Beulich  xs_daemon_open();
2141d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2142d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2143d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2144d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2145d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
21463996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
21473996e85cSPaul Durrant  return 0;
21483996e85cSPaul Durrant}
21493996e85cSPaul DurrantEOF
21503996e85cSPaul Durrant      compile_prog "" "$xen_libs"
21513996e85cSPaul Durrant    then
21523996e85cSPaul Durrant    xen_ctrl_version=450
21533996e85cSPaul Durrant    xen=yes
21543996e85cSPaul Durrant
21553996e85cSPaul Durrant  elif
21563996e85cSPaul Durrant      cat > $TMPC <<EOF &&
21573996e85cSPaul Durrant#include <xenctrl.h>
21583996e85cSPaul Durrant#include <xenstore.h>
21593996e85cSPaul Durrant#include <stdint.h>
21603996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
21613996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
21623996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
21633996e85cSPaul Durrant#endif
21643996e85cSPaul Durrantint main(void) {
21653996e85cSPaul Durrant  xc_interface *xc;
21663996e85cSPaul Durrant  xs_daemon_open();
21673996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
21683996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
21693996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
21703996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
21713996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
21728688e065SStefano Stabellini  return 0;
21738688e065SStefano Stabellini}
21748688e065SStefano StabelliniEOF
21758688e065SStefano Stabellini      compile_prog "" "$xen_libs"
217669deef08SPeter Maydell    then
21778688e065SStefano Stabellini    xen_ctrl_version=420
21788688e065SStefano Stabellini    xen=yes
21798688e065SStefano Stabellini
2180e37630caSaliguori  else
2181fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
2182edfb07edSIan Campbell      feature_not_found "xen (unsupported version)" \
2183edfb07edSIan Campbell                        "Install a supported xen (xen 4.2 or newer)"
2184fc321b4bSJuan Quintela    fi
2185fc321b4bSJuan Quintela    xen=no
2186e37630caSaliguori  fi
2187d5b93ddfSAnthony PERARD
2188d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
21895eeb39c2SIan Campbell    if test $xen_ctrl_version -ge 471  ; then
21905eeb39c2SIan Campbell      libs_softmmu="$xen_stable_libs $libs_softmmu"
21915eeb39c2SIan Campbell    fi
2192d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
2193d5b93ddfSAnthony PERARD  fi
2194e37630caSaliguorifi
2195e37630caSaliguori
2196eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2197edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2198eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2199eb6fda0fSAnthony PERARD  else
2200eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
220176ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
220276ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2203eb6fda0fSAnthony PERARD    fi
2204eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2205eb6fda0fSAnthony PERARD  fi
2206eb6fda0fSAnthony PERARDfi
2207eb6fda0fSAnthony PERARD
220864a7ad6fSIan Campbellif test "$xen_pv_domain_build" = "yes" &&
220964a7ad6fSIan Campbell   test "$xen" != "yes"; then
221064a7ad6fSIan Campbell    error_exit "User requested Xen PV domain builder support" \
221164a7ad6fSIan Campbell	       "which requires Xen support."
221264a7ad6fSIan Campbellfi
221364a7ad6fSIan Campbell
2214e37630caSaliguori##########################################
2215dfffc653SJuan Quintela# Sparse probe
2216dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
22170dba6195SLoïc Minier  if has cgcc; then
2218dfffc653SJuan Quintela    sparse=yes
2219dfffc653SJuan Quintela  else
2220dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
222121684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
2222dfffc653SJuan Quintela    fi
2223dfffc653SJuan Quintela    sparse=no
2224dfffc653SJuan Quintela  fi
2225dfffc653SJuan Quintelafi
2226dfffc653SJuan Quintela
2227dfffc653SJuan Quintela##########################################
2228f676c67eSJeremy White# X11 probe
2229f676c67eSJeremy Whitex11_cflags=
2230f676c67eSJeremy Whitex11_libs=-lX11
2231f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
223289138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
223389138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2234f676c67eSJeremy Whitefi
2235f676c67eSJeremy White
2236f676c67eSJeremy White##########################################
2237a4ccabcfSAnthony Liguori# GTK probe
2238a4ccabcfSAnthony Liguori
22399e04c683SStefan Weilif test "$gtkabi" = ""; then
22409e04c683SStefan Weil    # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
22419e04c683SStefan Weil    # Use 3.0 as a fallback if that is available.
22429e04c683SStefan Weil    if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
22439e04c683SStefan Weil        gtkabi=2.0
22449e04c683SStefan Weil    elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
22459e04c683SStefan Weil        gtkabi=3.0
22469e04c683SStefan Weil    else
22479e04c683SStefan Weil        gtkabi=2.0
22489e04c683SStefan Weil    fi
22499e04c683SStefan Weilfi
22509e04c683SStefan Weil
2251a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
2252528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
22530a337ed0SGerd Hoffmann    gtkx11package="gtk+-x11-$gtkabi"
2254528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
2255528de90aSDaniel P. Berrange      gtkversion="3.0.0"
2256bbbf9bfbSStefan Weil    else
2257bbbf9bfbSStefan Weil      gtkversion="2.18.0"
2258bbbf9bfbSStefan Weil    fi
2259bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
226089138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
226189138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
226289138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
22630a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2264f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2265f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
22660a337ed0SGerd Hoffmann        fi
2267bbbf9bfbSStefan Weil        libs_softmmu="$gtk_libs $libs_softmmu"
2268bbbf9bfbSStefan Weil        gtk="yes"
2269bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
22709e04c683SStefan Weil        feature_not_found "gtk" "Install gtk2 or gtk3 devel"
2271bbbf9bfbSStefan Weil    else
2272bbbf9bfbSStefan Weil        gtk="no"
2273bbbf9bfbSStefan Weil    fi
2274bbbf9bfbSStefan Weilfi
2275bbbf9bfbSStefan Weil
2276ddbb0d09SDaniel P. Berrange
2277ddbb0d09SDaniel P. Berrange##########################################
2278ddbb0d09SDaniel P. Berrange# GNUTLS probe
2279ddbb0d09SDaniel P. Berrange
228037371299SPeter Maydellgnutls_works() {
228137371299SPeter Maydell    # Unfortunately some distros have bad pkg-config information for gnutls
228237371299SPeter Maydell    # such that it claims to exist but you get a compiler error if you try
228337371299SPeter Maydell    # to use the options returned by --libs. Specifically, Ubuntu for --static
228437371299SPeter Maydell    # builds doesn't work:
228537371299SPeter Maydell    # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
228637371299SPeter Maydell    #
228737371299SPeter Maydell    # So sanity check the cflags/libs before assuming gnutls can be used.
228837371299SPeter Maydell    if ! $pkg_config --exists "gnutls"; then
228937371299SPeter Maydell        return 1
229037371299SPeter Maydell    fi
229137371299SPeter Maydell
229237371299SPeter Maydell    write_c_skeleton
229337371299SPeter Maydell    compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
229437371299SPeter Maydell}
229537371299SPeter Maydell
229662893b67SDaniel P. Berrangegnutls_gcrypt=no
2297ed754746SDaniel P. Berrangegnutls_nettle=no
2298ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
229937371299SPeter Maydell    if gnutls_works; then
230089138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
230189138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2302ddbb0d09SDaniel P. Berrange        libs_softmmu="$gnutls_libs $libs_softmmu"
2303ddbb0d09SDaniel P. Berrange        libs_tools="$gnutls_libs $libs_tools"
2304ddbb0d09SDaniel P. Berrange	QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2305ddbb0d09SDaniel P. Berrange        gnutls="yes"
2306ddbb0d09SDaniel P. Berrange
2307b917da4cSDaniel P. Berrange	# gnutls_rnd requires >= 2.11.0
2308b917da4cSDaniel P. Berrange	if $pkg_config --exists "gnutls >= 2.11.0"; then
2309b917da4cSDaniel P. Berrange	    gnutls_rnd="yes"
2310b917da4cSDaniel P. Berrange	else
2311b917da4cSDaniel P. Berrange	    gnutls_rnd="no"
2312b917da4cSDaniel P. Berrange	fi
2313b917da4cSDaniel P. Berrange
231462893b67SDaniel P. Berrange	if $pkg_config --exists 'gnutls >= 3.0'; then
231562893b67SDaniel P. Berrange	    gnutls_gcrypt=no
2316ed754746SDaniel P. Berrange	    gnutls_nettle=yes
231762893b67SDaniel P. Berrange	elif $pkg_config --exists 'gnutls >= 2.12'; then
231889138857SStefan Weil	    case $($pkg_config --libs --static gnutls) in
2319ed754746SDaniel P. Berrange		*gcrypt*)
2320ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2321ed754746SDaniel P. Berrange		    gnutls_nettle=no
2322ed754746SDaniel P. Berrange		    ;;
2323ed754746SDaniel P. Berrange		*nettle*)
2324ed754746SDaniel P. Berrange		    gnutls_gcrypt=no
2325ed754746SDaniel P. Berrange		    gnutls_nettle=yes
2326ed754746SDaniel P. Berrange		    ;;
2327ed754746SDaniel P. Berrange		*)
2328ed754746SDaniel P. Berrange		    gnutls_gcrypt=yes
2329ed754746SDaniel P. Berrange		    gnutls_nettle=no
2330ed754746SDaniel P. Berrange		    ;;
233162893b67SDaniel P. Berrange	    esac
233262893b67SDaniel P. Berrange	else
233362893b67SDaniel P. Berrange	    gnutls_gcrypt=yes
2334ed754746SDaniel P. Berrange	    gnutls_nettle=no
233562893b67SDaniel P. Berrange	fi
2336ddbb0d09SDaniel P. Berrange    elif test "$gnutls" = "yes"; then
2337ddbb0d09SDaniel P. Berrange	feature_not_found "gnutls" "Install gnutls devel"
2338ddbb0d09SDaniel P. Berrange    else
2339ddbb0d09SDaniel P. Berrange        gnutls="no"
2340b917da4cSDaniel P. Berrange        gnutls_rnd="no"
2341ddbb0d09SDaniel P. Berrange    fi
2342ddbb0d09SDaniel P. Berrangeelse
2343b917da4cSDaniel P. Berrange    gnutls_rnd="no"
2344ddbb0d09SDaniel P. Berrangefi
2345ddbb0d09SDaniel P. Berrange
234691bfcdb0SDaniel P. Berrange
234791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
234891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
234991bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to nettle
235091bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
235191bfcdb0SDaniel P. Berrangethen
235291bfcdb0SDaniel P. Berrange    if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
235391bfcdb0SDaniel P. Berrange    then
235491bfcdb0SDaniel P. Berrange        gcrypt="no"
235591bfcdb0SDaniel P. Berrange    fi
235691bfcdb0SDaniel P. Berrangefi
235791bfcdb0SDaniel P. Berrange
235891bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
235991bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
236091bfcdb0SDaniel P. Berrange# explicitly, or if gnutls links to gcrypt
236191bfcdb0SDaniel P. Berrangeif test -z "$nettle"
236291bfcdb0SDaniel P. Berrangethen
236391bfcdb0SDaniel P. Berrange    if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
236491bfcdb0SDaniel P. Berrange    then
236591bfcdb0SDaniel P. Berrange        nettle="no"
236691bfcdb0SDaniel P. Berrange    fi
236791bfcdb0SDaniel P. Berrangefi
236891bfcdb0SDaniel P. Berrange
236991bfcdb0SDaniel P. Berrangehas_libgcrypt_config() {
237091bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
237191bfcdb0SDaniel P. Berrange    then
237291bfcdb0SDaniel P. Berrange	return 1
237391bfcdb0SDaniel P. Berrange    fi
237491bfcdb0SDaniel P. Berrange
237591bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
237691bfcdb0SDaniel P. Berrange    then
237789138857SStefan Weil	host=$(libgcrypt-config --host)
237891bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
237991bfcdb0SDaniel P. Berrange	then
238091bfcdb0SDaniel P. Berrange	    return 1
238191bfcdb0SDaniel P. Berrange	fi
238291bfcdb0SDaniel P. Berrange    fi
238391bfcdb0SDaniel P. Berrange
238491bfcdb0SDaniel P. Berrange    return 0
238591bfcdb0SDaniel P. Berrange}
238691bfcdb0SDaniel P. Berrange
238791bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
238891bfcdb0SDaniel P. Berrange    if has_libgcrypt_config; then
238989138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
239089138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
239191bfcdb0SDaniel P. Berrange        # Debian has remove -lgpg-error from libgcrypt-config
239291bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
239391bfcdb0SDaniel P. Berrange        # turn breaks static builds...
239491bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
239591bfcdb0SDaniel P. Berrange        then
239691bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
239791bfcdb0SDaniel P. Berrange        fi
239862893b67SDaniel P. Berrange        libs_softmmu="$gcrypt_libs $libs_softmmu"
239962893b67SDaniel P. Berrange        libs_tools="$gcrypt_libs $libs_tools"
240062893b67SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
240191bfcdb0SDaniel P. Berrange        gcrypt="yes"
240291bfcdb0SDaniel P. Berrange        if test -z "$nettle"; then
240391bfcdb0SDaniel P. Berrange           nettle="no"
240491bfcdb0SDaniel P. Berrange        fi
240537788f25SDaniel P. Berrange
240637788f25SDaniel P. Berrange        cat > $TMPC << EOF
240737788f25SDaniel P. Berrange#include <gcrypt.h>
240837788f25SDaniel P. Berrangeint main(void) {
240937788f25SDaniel P. Berrange  gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
241037788f25SDaniel P. Berrange                  GCRY_MD_SHA256,
241137788f25SDaniel P. Berrange                  NULL, 0, 0, 0, NULL);
241237788f25SDaniel P. Berrange return 0;
241337788f25SDaniel P. Berrange}
241437788f25SDaniel P. BerrangeEOF
241537788f25SDaniel P. Berrange        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
241637788f25SDaniel P. Berrange            gcrypt_kdf=yes
241737788f25SDaniel P. Berrange        fi
241862893b67SDaniel P. Berrange    else
241991bfcdb0SDaniel P. Berrange        if test "$gcrypt" = "yes"; then
242062893b67SDaniel P. Berrange            feature_not_found "gcrypt" "Install gcrypt devel"
242191bfcdb0SDaniel P. Berrange        else
242291bfcdb0SDaniel P. Berrange            gcrypt="no"
242391bfcdb0SDaniel P. Berrange        fi
242462893b67SDaniel P. Berrange    fi
242562893b67SDaniel P. Berrangefi
242662893b67SDaniel P. Berrange
2427ddbb0d09SDaniel P. Berrange
242891bfcdb0SDaniel P. Berrangeif test "$nettle" != "no"; then
2429ed754746SDaniel P. Berrange    if $pkg_config --exists "nettle"; then
243089138857SStefan Weil        nettle_cflags=$($pkg_config --cflags nettle)
243189138857SStefan Weil        nettle_libs=$($pkg_config --libs nettle)
243289138857SStefan Weil        nettle_version=$($pkg_config --modversion nettle)
2433ed754746SDaniel P. Berrange        libs_softmmu="$nettle_libs $libs_softmmu"
2434ed754746SDaniel P. Berrange        libs_tools="$nettle_libs $libs_tools"
2435ed754746SDaniel P. Berrange        QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
243691bfcdb0SDaniel P. Berrange        nettle="yes"
2437fff2f982SDaniel P. Berrange
2438fff2f982SDaniel P. Berrange        cat > $TMPC << EOF
24399e87a691SSteven Luo#include <stddef.h>
2440fff2f982SDaniel P. Berrange#include <nettle/pbkdf2.h>
2441fff2f982SDaniel P. Berrangeint main(void) {
2442fff2f982SDaniel P. Berrange     pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2443fff2f982SDaniel P. Berrange     return 0;
2444fff2f982SDaniel P. Berrange}
2445fff2f982SDaniel P. BerrangeEOF
2446fff2f982SDaniel P. Berrange        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2447fff2f982SDaniel P. Berrange            nettle_kdf=yes
2448fff2f982SDaniel P. Berrange        fi
2449ed754746SDaniel P. Berrange    else
245091bfcdb0SDaniel P. Berrange        if test "$nettle" = "yes"; then
2451ed754746SDaniel P. Berrange            feature_not_found "nettle" "Install nettle devel"
245291bfcdb0SDaniel P. Berrange        else
245391bfcdb0SDaniel P. Berrange            nettle="no"
2454ed754746SDaniel P. Berrange        fi
2455ed754746SDaniel P. Berrange    fi
245691bfcdb0SDaniel P. Berrangefi
245791bfcdb0SDaniel P. Berrange
245891bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
245991bfcdb0SDaniel P. Berrangethen
246091bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
246191bfcdb0SDaniel P. Berrangefi
2462ed754746SDaniel P. Berrange
24639a2fd434SDaniel P. Berrange##########################################
24649a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
24659a2fd434SDaniel P. Berrange
24669a2fd434SDaniel P. Berrangetasn1=yes
246790246037SDaniel P. Berrangetasn1_cflags=""
246890246037SDaniel P. Berrangetasn1_libs=""
24699a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
247089138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
247189138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
24729a2fd434SDaniel P. Berrangeelse
24739a2fd434SDaniel P. Berrange    tasn1=no
24749a2fd434SDaniel P. Berrangefi
24759a2fd434SDaniel P. Berrange
2476ed754746SDaniel P. Berrange
2477bbbf9bfbSStefan Weil##########################################
2478559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
2479559607eaSDaniel P. Berrange
2480559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
2481559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
2482559607eaSDaniel P. Berrange  have_ifaddrs_h=no
2483559607eaSDaniel P. Berrangefi
2484559607eaSDaniel P. Berrange
2485559607eaSDaniel P. Berrange##########################################
2486bbbf9bfbSStefan Weil# VTE probe
2487bbbf9bfbSStefan Weil
2488bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2489bbbf9bfbSStefan Weil    if test "$gtkabi" = "3.0"; then
2490c6feff9eSCole Robinson      vteminversion="0.32.0"
2491c6feff9eSCole Robinson      if $pkg_config --exists "vte-2.91"; then
2492c6feff9eSCole Robinson        vtepackage="vte-2.91"
2493c6feff9eSCole Robinson      else
2494528de90aSDaniel P. Berrange        vtepackage="vte-2.90"
2495c6feff9eSCole Robinson      fi
2496528de90aSDaniel P. Berrange    else
2497528de90aSDaniel P. Berrange      vtepackage="vte"
2498c6feff9eSCole Robinson      vteminversion="0.24.0"
2499528de90aSDaniel P. Berrange    fi
2500c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
250189138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
250289138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
250389138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2504bbbf9bfbSStefan Weil        libs_softmmu="$vte_libs $libs_softmmu"
2505bbbf9bfbSStefan Weil        vte="yes"
2506bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
25079e04c683SStefan Weil        if test "$gtkabi" = "3.0"; then
2508c6feff9eSCole Robinson            feature_not_found "vte" "Install libvte-2.90/2.91 devel"
25099e04c683SStefan Weil        else
25109e04c683SStefan Weil            feature_not_found "vte" "Install libvte devel"
25119e04c683SStefan Weil        fi
2512bbbf9bfbSStefan Weil    else
2513bbbf9bfbSStefan Weil        vte="no"
2514a4ccabcfSAnthony Liguori    fi
2515a4ccabcfSAnthony Liguorifi
2516a4ccabcfSAnthony Liguori
2517a4ccabcfSAnthony Liguori##########################################
251811d9f695Sbellard# SDL probe
251911d9f695Sbellard
25203ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
25213ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
252247c03744SDave Airlie
2523ee8466d0SCole Robinsonif test "$sdlabi" = ""; then
2524ee8466d0SCole Robinson    if $pkg_config --exists "sdl"; then
2525ee8466d0SCole Robinson        sdlabi=1.2
2526ee8466d0SCole Robinson    elif $pkg_config --exists "sdl2"; then
2527ee8466d0SCole Robinson        sdlabi=2.0
2528ee8466d0SCole Robinson    else
2529ee8466d0SCole Robinson        sdlabi=1.2
2530ee8466d0SCole Robinson    fi
2531ee8466d0SCole Robinsonfi
2532ee8466d0SCole Robinson
253347c03744SDave Airlieif test $sdlabi = "2.0"; then
253447c03744SDave Airlie    sdl_config=$sdl2_config
253547c03744SDave Airlie    sdlname=sdl2
253647c03744SDave Airlie    sdlconfigname=sdl2_config
2537e07047cfSCole Robinsonelif test $sdlabi = "1.2"; then
253847c03744SDave Airlie    sdlname=sdl
253947c03744SDave Airlie    sdlconfigname=sdl_config
2540e07047cfSCole Robinsonelse
2541e07047cfSCole Robinson    error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
25423ec87ffeSPaolo Bonzinifi
25433ec87ffeSPaolo Bonzini
254489138857SStefan Weilif test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
254547c03744SDave Airlie  sdl_config=$sdlconfigname
254647c03744SDave Airliefi
254747c03744SDave Airlie
254847c03744SDave Airlieif $pkg_config $sdlname --exists; then
254947c03744SDave Airlie  sdlconfig="$pkg_config $sdlname"
255089138857SStefan Weil  sdlversion=$($sdlconfig --modversion 2>/dev/null)
25513ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
25523ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
255389138857SStefan Weil  sdlversion=$($sdlconfig --version)
2554a0dfd8a4SLoïc Minierelse
2555a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
255621684af0SStewart Smith    feature_not_found "sdl" "Install SDL devel"
2557a0dfd8a4SLoïc Minier  fi
2558a0dfd8a4SLoïc Minier  sdl=no
25599316f803SPaolo Bonzinifi
256029e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
25613ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
25623ec87ffeSPaolo Bonzinifi
256311d9f695Sbellard
25649316f803SPaolo Bonzinisdl_too_old=no
2565c4198157SJuan Quintelaif test "$sdl" != "no" ; then
256611d9f695Sbellard  cat > $TMPC << EOF
256711d9f695Sbellard#include <SDL.h>
256811d9f695Sbellard#undef main /* We don't want SDL to override our main() */
256911d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
257011d9f695SbellardEOF
257189138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
257274f42e18STeLeMan  if test "$static" = "yes" ; then
257389138857SStefan Weil    sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
257474f42e18STeLeMan  else
257589138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
257674f42e18STeLeMan  fi
257752166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
257889138857SStefan Weil    if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
257911d9f695Sbellard      sdl_too_old=yes
258011d9f695Sbellard    else
258111d9f695Sbellard      sdl=yes
258211d9f695Sbellard    fi
25837c1f25b4Sbellard
258467c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
25851ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
258667c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
258789138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
258889138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
258911d9f695Sbellard      fi
259052166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
25911ac88f28SJuan Quintela	:
25921ac88f28SJuan Quintela      else
25931ac88f28SJuan Quintela        sdl=no
25947c1f25b4Sbellard      fi
25957c1f25b4Sbellard    fi # static link
2596c4198157SJuan Quintela  else # sdl not found
2597c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
259821684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
2599c4198157SJuan Quintela    fi
2600c4198157SJuan Quintela    sdl=no
26017c1f25b4Sbellard  fi # sdl compile test
2602fd677642Sthsfi
260311d9f695Sbellard
26045368a422Saliguoriif test "$sdl" = "yes" ; then
26055368a422Saliguori  cat > $TMPC <<EOF
26065368a422Saliguori#include <SDL.h>
26075368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
26085368a422Saliguori#include <X11/XKBlib.h>
26095368a422Saliguori#else
26105368a422Saliguori#error No x11 support
26115368a422Saliguori#endif
26125368a422Saliguoriint main(void) { return 0; }
26135368a422SaliguoriEOF
2614f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2615f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
2616f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
26175368a422Saliguori  fi
26180705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
26195368a422Saliguorifi
26205368a422Saliguori
26218f28f3fbSths##########################################
26222da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
26232da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
26242da776dbSMichael R. Hines  cat > $TMPC <<EOF
26252da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
26262da776dbSMichael R. Hinesint main(void) { return 0; }
26272da776dbSMichael R. HinesEOF
26282da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
26292da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
26302da776dbSMichael R. Hines    rdma="yes"
26312da776dbSMichael R. Hines    libs_softmmu="$libs_softmmu $rdma_libs"
26322da776dbSMichael R. Hines  else
26332da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
26342da776dbSMichael R. Hines        error_exit \
26352da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
26362da776dbSMichael R. Hines            " Your options:" \
26372da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
26382da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
26392da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
26402da776dbSMichael R. Hines    fi
26412da776dbSMichael R. Hines    rdma="no"
26422da776dbSMichael R. Hines  fi
26432da776dbSMichael R. Hinesfi
26442da776dbSMichael R. Hines
264595c6bff3SBenoît Canet
264695c6bff3SBenoît Canet##########################################
26472f9606b3Saliguori# VNC SASL detection
2648821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
26492f9606b3Saliguori  cat > $TMPC <<EOF
26502f9606b3Saliguori#include <sasl/sasl.h>
26512f9606b3Saliguori#include <stdio.h>
26522f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
26532f9606b3SaliguoriEOF
26542f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
26552f9606b3Saliguori  vnc_sasl_cflags=""
26562f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
265752166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2658ea784e3bSJuan Quintela    vnc_sasl=yes
2659fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2660ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
26612f9606b3Saliguori  else
2662ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
266321684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2664ea784e3bSJuan Quintela    fi
2665ea784e3bSJuan Quintela    vnc_sasl=no
26662f9606b3Saliguori  fi
26672f9606b3Saliguorifi
26682f9606b3Saliguori
26692f9606b3Saliguori##########################################
26702f6f5c7aSCorentin Chary# VNC JPEG detection
2671821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
26722f6f5c7aSCorentin Charycat > $TMPC <<EOF
26732f6f5c7aSCorentin Chary#include <stdio.h>
26742f6f5c7aSCorentin Chary#include <jpeglib.h>
26752f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
26762f6f5c7aSCorentin CharyEOF
26772f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
26782f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
26792f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
26802f6f5c7aSCorentin Chary    vnc_jpeg=yes
26812f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2682ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
26832f6f5c7aSCorentin Chary  else
26842f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
268521684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
26862f6f5c7aSCorentin Chary    fi
26872f6f5c7aSCorentin Chary    vnc_jpeg=no
26882f6f5c7aSCorentin Chary  fi
26892f6f5c7aSCorentin Charyfi
26902f6f5c7aSCorentin Chary
26912f6f5c7aSCorentin Chary##########################################
2692efe556adSCorentin Chary# VNC PNG detection
2693821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2694efe556adSCorentin Charycat > $TMPC <<EOF
2695efe556adSCorentin Chary//#include <stdio.h>
2696efe556adSCorentin Chary#include <png.h>
2697832ce9c2SScott Wood#include <stddef.h>
2698efe556adSCorentin Charyint main(void) {
2699efe556adSCorentin Chary    png_structp png_ptr;
2700efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
27017edc3fedSPeter Maydell    return png_ptr != 0;
2702efe556adSCorentin Chary}
2703efe556adSCorentin CharyEOF
270465d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
270589138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
270689138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
27079af8025eSBrad  else
2708efe556adSCorentin Chary    vnc_png_cflags=""
2709efe556adSCorentin Chary    vnc_png_libs="-lpng"
27109af8025eSBrad  fi
2711efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2712efe556adSCorentin Chary    vnc_png=yes
2713efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
27149af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2715efe556adSCorentin Chary  else
2716efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
271721684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2718efe556adSCorentin Chary    fi
2719efe556adSCorentin Chary    vnc_png=no
2720efe556adSCorentin Chary  fi
2721efe556adSCorentin Charyfi
2722efe556adSCorentin Chary
2723efe556adSCorentin Chary##########################################
272476655d6dSaliguori# fnmatch() probe, used for ACL routines
272576655d6dSaliguorifnmatch="no"
272676655d6dSaliguoricat > $TMPC << EOF
272776655d6dSaliguori#include <fnmatch.h>
272876655d6dSaliguoriint main(void)
272976655d6dSaliguori{
273076655d6dSaliguori    fnmatch("foo", "foo", 0);
273176655d6dSaliguori    return 0;
273276655d6dSaliguori}
273376655d6dSaliguoriEOF
273452166aa0SJuan Quintelaif compile_prog "" "" ; then
273576655d6dSaliguori   fnmatch="yes"
273676655d6dSaliguorifi
273776655d6dSaliguori
273876655d6dSaliguori##########################################
2739dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
2740dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2741dce512deSChristoph Hellwig  cat > $TMPC << EOF
2742ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2743dce512deSChristoph Hellwig#include <xfs/xfs.h>
2744dce512deSChristoph Hellwigint main(void)
2745dce512deSChristoph Hellwig{
2746dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2747dce512deSChristoph Hellwig    return 0;
2748dce512deSChristoph Hellwig}
2749dce512deSChristoph HellwigEOF
2750dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2751dce512deSChristoph Hellwig    xfs="yes"
2752dce512deSChristoph Hellwig  else
2753dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
275421684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2755dce512deSChristoph Hellwig    fi
2756dce512deSChristoph Hellwig    xfs=no
2757dce512deSChristoph Hellwig  fi
2758dce512deSChristoph Hellwigfi
2759dce512deSChristoph Hellwig
2760dce512deSChristoph Hellwig##########################################
27618a16d273Sths# vde libraries probe
2762dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
27634baae0acSJuan Quintela  vde_libs="-lvdeplug"
27648a16d273Sths  cat > $TMPC << EOF
27658a16d273Sths#include <libvdeplug.h>
27664a7f0e06Spbrookint main(void)
27674a7f0e06Spbrook{
27684a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2769fea08e08SPeter Maydell    char s[] = "";
2770fea08e08SPeter Maydell    vde_open(s, s, &a);
27714a7f0e06Spbrook    return 0;
27724a7f0e06Spbrook}
27738a16d273SthsEOF
277452166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
27754baae0acSJuan Quintela    vde=yes
27768e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
27778e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2778dfb278bdSJuan Quintela  else
2779dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
278021684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2781dfb278bdSJuan Quintela    fi
2782dfb278bdSJuan Quintela    vde=no
27838a16d273Sths  fi
27848a16d273Sthsfi
27858a16d273Sths
27868a16d273Sths##########################################
27870a985b37SVincenzo Maffione# netmap support probe
27880a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
27890a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
27900a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
27910a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
27920a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
279358952137SVincenzo Maffioneif test "$netmap" != "no" ; then
279458952137SVincenzo Maffione  cat > $TMPC << EOF
279558952137SVincenzo Maffione#include <inttypes.h>
279658952137SVincenzo Maffione#include <net/if.h>
279758952137SVincenzo Maffione#include <net/netmap.h>
279858952137SVincenzo Maffione#include <net/netmap_user.h>
27990a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
28000a985b37SVincenzo Maffione#error
28010a985b37SVincenzo Maffione#endif
280258952137SVincenzo Maffioneint main(void) { return 0; }
280358952137SVincenzo MaffioneEOF
280458952137SVincenzo Maffione  if compile_prog "" "" ; then
280558952137SVincenzo Maffione    netmap=yes
280658952137SVincenzo Maffione  else
280758952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
280858952137SVincenzo Maffione      feature_not_found "netmap"
280958952137SVincenzo Maffione    fi
281058952137SVincenzo Maffione    netmap=no
281158952137SVincenzo Maffione  fi
281258952137SVincenzo Maffionefi
281358952137SVincenzo Maffione
281458952137SVincenzo Maffione##########################################
281547e98658SCorey Bryant# libcap-ng library probe
281647e98658SCorey Bryantif test "$cap_ng" != "no" ; then
281747e98658SCorey Bryant  cap_libs="-lcap-ng"
281847e98658SCorey Bryant  cat > $TMPC << EOF
281947e98658SCorey Bryant#include <cap-ng.h>
282047e98658SCorey Bryantint main(void)
282147e98658SCorey Bryant{
282247e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
282347e98658SCorey Bryant    return 0;
282447e98658SCorey Bryant}
282547e98658SCorey BryantEOF
282647e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
282747e98658SCorey Bryant    cap_ng=yes
282847e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
282947e98658SCorey Bryant  else
283047e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
283121684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
283247e98658SCorey Bryant    fi
283347e98658SCorey Bryant    cap_ng=no
283447e98658SCorey Bryant  fi
283547e98658SCorey Bryantfi
283647e98658SCorey Bryant
283747e98658SCorey Bryant##########################################
2838c2de5c91Smalc# Sound support libraries probe
28398f28f3fbSths
2840c2de5c91Smalcaudio_drv_probe()
2841c2de5c91Smalc{
2842c2de5c91Smalc    drv=$1
2843c2de5c91Smalc    hdr=$2
2844c2de5c91Smalc    lib=$3
2845c2de5c91Smalc    exp=$4
2846c2de5c91Smalc    cfl=$5
28478f28f3fbSths        cat > $TMPC << EOF
2848c2de5c91Smalc#include <$hdr>
2849c2de5c91Smalcint main(void) { $exp }
28508f28f3fbSthsEOF
285152166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
28528f28f3fbSths        :
28538f28f3fbSths    else
285476ad07a4SPeter Maydell        error_exit "$drv check failed" \
285576ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
28568f28f3fbSths    fi
2857c2de5c91Smalc}
2858c2de5c91Smalc
285989138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
2860c2de5c91Smalcfor drv in $audio_drv_list; do
2861c2de5c91Smalc    case $drv in
2862c2de5c91Smalc    alsa)
2863c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
2864e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
2865a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
2866c2de5c91Smalc    ;;
2867c2de5c91Smalc
2868b8e59f18Smalc    pa)
2869e58ff62dSPeter Krempa    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
2870e58ff62dSPeter Krempa        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
2871a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
287267f86e8eSJuan Quintela    audio_pt_int="yes"
2873b8e59f18Smalc    ;;
2874b8e59f18Smalc
2875997e690aSJuan Quintela    coreaudio)
2876997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
2877997e690aSJuan Quintela    ;;
2878997e690aSJuan Quintela
2879a4bf6780SJuan Quintela    dsound)
2880a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2881d5631638Smalc      audio_win_int="yes"
2882a4bf6780SJuan Quintela    ;;
2883a4bf6780SJuan Quintela
2884a4bf6780SJuan Quintela    oss)
2885a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
2886a4bf6780SJuan Quintela    ;;
2887a4bf6780SJuan Quintela
2888a4bf6780SJuan Quintela    sdl|wav)
28892f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
28902f6a1ab0Sblueswir1    ;;
28912f6a1ab0Sblueswir1
2892e4c63a6aSmalc    *)
28931c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
289476ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
289576ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
2896e4c63a6aSmalc    }
2897e4c63a6aSmalc    ;;
2898c2de5c91Smalc    esac
2899c2de5c91Smalcdone
29008f28f3fbSths
29014d3b6f6eSbalrog##########################################
29022e4d9fb1Saurel32# BrlAPI probe
29032e4d9fb1Saurel32
29044ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2905eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
29062e4d9fb1Saurel32  cat > $TMPC << EOF
29072e4d9fb1Saurel32#include <brlapi.h>
2908832ce9c2SScott Wood#include <stddef.h>
29092e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
29102e4d9fb1Saurel32EOF
291152166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
29122e4d9fb1Saurel32    brlapi=yes
2913264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
29144ffcedb6SJuan Quintela  else
29154ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
291621684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
29174ffcedb6SJuan Quintela    fi
29184ffcedb6SJuan Quintela    brlapi=no
2919eb82284fSJuan Quintela  fi
2920eb82284fSJuan Quintelafi
29212e4d9fb1Saurel32
29222e4d9fb1Saurel32##########################################
29234d3b6f6eSbalrog# curses probe
2924a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
2925e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
29268ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
29278ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
2928e095e2f3SStefan Weil  else
29298ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):"
29308ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
2931e095e2f3SStefan Weil  fi
2932c584a6d0SJuan Quintela  curses_found=no
29334d3b6f6eSbalrog  cat > $TMPC << EOF
29348ddc5bf9SSamuel Thibault#include <locale.h>
29354d3b6f6eSbalrog#include <curses.h>
29368ddc5bf9SSamuel Thibault#include <wchar.h>
2937ef9a2524SStefan Weilint main(void) {
2938ef9a2524SStefan Weil  const char *s = curses_version();
29398ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
29408ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
2941ef9a2524SStefan Weil  resize_term(0, 0);
29428ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
29438ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
2944ef9a2524SStefan Weil  return s != 0;
2945ef9a2524SStefan Weil}
29464d3b6f6eSbalrogEOF
2947ecbe251fSVadim Evard  IFS=:
29488ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
29498ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
2950ecbe251fSVadim Evard      unset IFS
29518ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
2952c584a6d0SJuan Quintela        curses_found=yes
29538ddc5bf9SSamuel Thibault        QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
29544f78ef9aSJuan Quintela        libs_softmmu="$curses_lib $libs_softmmu"
29554f78ef9aSJuan Quintela        break
29564d3b6f6eSbalrog      fi
29574f78ef9aSJuan Quintela    done
29588ddc5bf9SSamuel Thibault  done
2959ecbe251fSVadim Evard  unset IFS
2960c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2961c584a6d0SJuan Quintela    curses=yes
2962c584a6d0SJuan Quintela  else
2963c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
296421684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
2965c584a6d0SJuan Quintela    fi
2966c584a6d0SJuan Quintela    curses=no
2967c584a6d0SJuan Quintela  fi
29684f78ef9aSJuan Quintelafi
29694d3b6f6eSbalrog
2970414f0dabSblueswir1##########################################
2971769ce76dSAlexander Graf# curl probe
2972a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
297365d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
2974a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
29754e2b0658SPaolo Bonzini  else
29764e2b0658SPaolo Bonzini    curlconfig=curl-config
29774e2b0658SPaolo Bonzini  fi
2978769ce76dSAlexander Graf  cat > $TMPC << EOF
2979769ce76dSAlexander Graf#include <curl/curl.h>
29800b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2981769ce76dSAlexander GrafEOF
298289138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
298389138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
2984b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2985769ce76dSAlexander Graf    curl=yes
2986788c8196SJuan Quintela  else
2987788c8196SJuan Quintela    if test "$curl" = "yes" ; then
298821684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
2989788c8196SJuan Quintela    fi
2990788c8196SJuan Quintela    curl=no
2991769ce76dSAlexander Graf  fi
2992769ce76dSAlexander Graffi # test "$curl"
2993769ce76dSAlexander Graf
2994769ce76dSAlexander Graf##########################################
2995fb599c9aSbalrog# bluez support probe
2996a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2997e820e3f4Sbalrog  cat > $TMPC << EOF
2998e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2999e820e3f4Sbalrogint main(void) { return bt_error(0); }
3000e820e3f4SbalrogEOF
300189138857SStefan Weil  bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
300289138857SStefan Weil  bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
300352166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3004a20a6f46SJuan Quintela    bluez=yes
3005e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
3006e820e3f4Sbalrog  else
3007a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
300821684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3009a20a6f46SJuan Quintela    fi
3010e820e3f4Sbalrog    bluez="no"
3011e820e3f4Sbalrog  fi
3012fb599c9aSbalrogfi
3013fb599c9aSbalrog
3014fb599c9aSbalrog##########################################
3015e18df141SAnthony Liguori# glib support probe
3016a52d28afSPaolo Bonzini
3017f40685c6SJohn Snowglib_req_ver=2.22
3018aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3019aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3020aa0d1f44SPaolo Bonzini    glib_modules="$glib_modules gmodule-2.0"
3021aa0d1f44SPaolo Bonzinifi
3022e26110cfSFam Zheng
3023aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3024e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
302589138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
302689138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
30274a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
302814015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3029957f1f99SMichael Roth        libs_qga="$glib_libs $libs_qga"
3030e18df141SAnthony Liguori    else
3031e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3032e26110cfSFam Zheng    fi
3033e26110cfSFam Zhengdone
3034e26110cfSFam Zheng
3035977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3036977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3037977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3038977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3039977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3040977a82abSDaniel P. Berrange#include <glib.h>
3041977a82abSDaniel P. Berrange#include <unistd.h>
3042977a82abSDaniel P. Berrange
3043977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3044977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3045977a82abSDaniel P. Berrange
3046977a82abSDaniel P. Berrangeint main(void) {
3047977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3048977a82abSDaniel P. Berrange   return 0;
3049977a82abSDaniel P. Berrange}
3050977a82abSDaniel P. BerrangeEOF
3051977a82abSDaniel P. Berrange
30525919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3053977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3054977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3055977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3056977a82abSDaniel P. Berrange	       "build target"
3057977a82abSDaniel P. Berrangefi
3058977a82abSDaniel P. Berrange
30599d41401bSMichael S. Tsirkin# g_test_trap_subprocess added in 2.38. Used by some tests.
30609d41401bSMichael S. Tsirkinglib_subprocess=yes
30617ad9339eSEduardo Habkostif test "$mingw32" = "yes" || ! $pkg_config --atleast-version=2.38 glib-2.0; then
30629d41401bSMichael S. Tsirkin    glib_subprocess=no
30639d41401bSMichael S. Tsirkinfi
30649d41401bSMichael S. Tsirkin
3065bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3066bbbf2e04SJohn Snowcat > $TMPC << EOF
3067bbbf2e04SJohn Snow#include <glib.h>
3068bbbf2e04SJohn Snowint main(void) { return 0; }
3069bbbf2e04SJohn SnowEOF
3070bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3071bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3072bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3073bbbf2e04SJohn Snow        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3074bbbf2e04SJohn Snow    fi
3075bbbf2e04SJohn Snowfi
3076bbbf2e04SJohn Snow
3077e26110cfSFam Zheng##########################################
3078e26110cfSFam Zheng# SHA command probe for modules
3079e26110cfSFam Zhengif test "$modules" = yes; then
3080e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3081e26110cfSFam Zheng    for c in $shacmd_probe; do
30828ccefb91SFam Zheng        if has $c; then
3083e26110cfSFam Zheng            shacmd="$c"
3084e26110cfSFam Zheng            break
3085e26110cfSFam Zheng        fi
3086e26110cfSFam Zheng    done
3087e26110cfSFam Zheng    if test "$shacmd" = ""; then
3088e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3089e26110cfSFam Zheng    fi
3090e18df141SAnthony Liguorifi
3091e18df141SAnthony Liguori
3092e18df141SAnthony Liguori##########################################
3093e2134eb9SGerd Hoffmann# pixman support probe
3094e2134eb9SGerd Hoffmann
3095e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
309674880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
309774880fe2SRobert Schiele    pixman="none"
3098236f282cSHu Tao  elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3099e2134eb9SGerd Hoffmann    pixman="system"
3100e2134eb9SGerd Hoffmann  else
3101e2134eb9SGerd Hoffmann    pixman="internal"
3102e2134eb9SGerd Hoffmann  fi
3103e2134eb9SGerd Hoffmannfi
310474880fe2SRobert Schieleif test "$pixman" = "none"; then
310574880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
310676ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
310776ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
310876ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
310976ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
311074880fe2SRobert Schiele  fi
311174880fe2SRobert Schiele  pixman_cflags=
311274880fe2SRobert Schiele  pixman_libs=
311374880fe2SRobert Schieleelif test "$pixman" = "system"; then
3114236f282cSHu Tao  # pixman version has been checked above
311589138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
311689138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
3117e2134eb9SGerd Hoffmannelse
3118e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
3119236f282cSHu Tao    error_exit "pixman >= 0.21.8 not present. Your options:" \
312076ad07a4SPeter Maydell        "  (1) Preferred: Install the pixman devel package (any recent" \
312176ad07a4SPeter Maydell        "      distro should have packages as Xorg needs pixman too)." \
312276ad07a4SPeter Maydell        "  (2) Fetch the pixman submodule, using:" \
312376ad07a4SPeter Maydell        "      git submodule update --init pixman"
3124e2134eb9SGerd Hoffmann  fi
31255ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
31265ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
31275ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
3128e2134eb9SGerd Hoffmannfi
3129e2134eb9SGerd Hoffmann
3130e2134eb9SGerd Hoffmann##########################################
313117bff52bSM. Mohan Kumar# libcap probe
313217bff52bSM. Mohan Kumar
313317bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
313417bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
313517bff52bSM. Mohan Kumar#include <stdio.h>
313617bff52bSM. Mohan Kumar#include <sys/capability.h>
3137cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
313817bff52bSM. Mohan KumarEOF
313917bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
314017bff52bSM. Mohan Kumar    cap=yes
314117bff52bSM. Mohan Kumar  else
314217bff52bSM. Mohan Kumar    cap=no
314317bff52bSM. Mohan Kumar  fi
314417bff52bSM. Mohan Kumarfi
314517bff52bSM. Mohan Kumar
314617bff52bSM. Mohan Kumar##########################################
3147e5d355d1Saliguori# pthread probe
31484b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
31493c529d93Saliguori
3150e5d355d1Saliguoripthread=no
3151414f0dabSblueswir1cat > $TMPC << EOF
31523c529d93Saliguori#include <pthread.h>
31537a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
31547a42bbe4SStefan Weilint main(void) {
31557a42bbe4SStefan Weil  pthread_t thread;
31567a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
31577a42bbe4SStefan Weil  return 0;
31587a42bbe4SStefan Weil}
3159414f0dabSblueswir1EOF
3160bd00d539SAndreas Färberif compile_prog "" "" ; then
3161bd00d539SAndreas Färber  pthread=yes
3162bd00d539SAndreas Färberelse
3163de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
316452166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3165e5d355d1Saliguori      pthread=yes
3166e3c56761SPeter Portante      found=no
3167e3c56761SPeter Portante      for lib_entry in $LIBS; do
3168e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3169e3c56761SPeter Portante          found=yes
3170e3c56761SPeter Portante          break
3171e3c56761SPeter Portante        fi
3172e3c56761SPeter Portante      done
3173e3c56761SPeter Portante      if test "$found" = "no"; then
31745572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3175e3c56761SPeter Portante      fi
3176409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3177de65fe0fSSebastian Herbszt      break
3178414f0dabSblueswir1    fi
3179de65fe0fSSebastian Herbszt  done
3180bd00d539SAndreas Färberfi
3181414f0dabSblueswir1
31824617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
318376ad07a4SPeter Maydell  error_exit "pthread check failed" \
318476ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3185e5d355d1Saliguorifi
3186e5d355d1Saliguori
31875c312079SDr. David Alan Gilbert# check for pthread_setname_np
31885c312079SDr. David Alan Gilbertpthread_setname_np=no
31895c312079SDr. David Alan Gilbertcat > $TMPC << EOF
31905c312079SDr. David Alan Gilbert#include <pthread.h>
31915c312079SDr. David Alan Gilbert
31925c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
31935c312079SDr. David Alan Gilbertint main(void)
31945c312079SDr. David Alan Gilbert{
31955c312079SDr. David Alan Gilbert    pthread_t thread;
31965c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
31975c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
31985c312079SDr. David Alan Gilbert    return 0;
31995c312079SDr. David Alan Gilbert}
32005c312079SDr. David Alan GilbertEOF
32015c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
32025c312079SDr. David Alan Gilbert  pthread_setname_np=yes
32035c312079SDr. David Alan Gilbertfi
32045c312079SDr. David Alan Gilbert
3205bf9298b9Saliguori##########################################
3206f27aaf4bSChristian Brunner# rbd probe
3207f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3208f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3209f27aaf4bSChristian Brunner#include <stdio.h>
3210ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3211f27aaf4bSChristian Brunnerint main(void) {
3212ad32e9c0SJosh Durgin    rados_t cluster;
3213ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3214f27aaf4bSChristian Brunner    return 0;
3215f27aaf4bSChristian Brunner}
3216f27aaf4bSChristian BrunnerEOF
3217ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3218f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3219f27aaf4bSChristian Brunner    rbd=yes
3220f27aaf4bSChristian Brunner  else
3221f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
322221684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3223f27aaf4bSChristian Brunner    fi
3224f27aaf4bSChristian Brunner    rbd=no
3225f27aaf4bSChristian Brunner  fi
3226f27aaf4bSChristian Brunnerfi
3227f27aaf4bSChristian Brunner
3228f27aaf4bSChristian Brunner##########################################
32290a12ec87SRichard W.M. Jones# libssh2 probe
32304fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
32310a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
323265d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
323389138857SStefan Weil    libssh2_cflags=$($pkg_config libssh2 --cflags)
323489138857SStefan Weil    libssh2_libs=$($pkg_config libssh2 --libs)
32350a12ec87SRichard W.M. Jones    libssh2=yes
32360a12ec87SRichard W.M. Jones  else
32370a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
32384fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
32390a12ec87SRichard W.M. Jones    fi
32400a12ec87SRichard W.M. Jones    libssh2=no
32410a12ec87SRichard W.M. Jones  fi
32420a12ec87SRichard W.M. Jonesfi
32430a12ec87SRichard W.M. Jones
32440a12ec87SRichard W.M. Jones##########################################
32459a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
32469a2d462eSRichard W.M. Jones
32479a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
32489a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
32499a2d462eSRichard W.M. Jones#include <stdio.h>
32509a2d462eSRichard W.M. Jones#include <libssh2.h>
32519a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
32529a2d462eSRichard W.M. Jonesint main(void) {
32539a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
32549a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
32559a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
32569a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
32579a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
32589a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
32599a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
32609a2d462eSRichard W.M. Jones    return 0;
32619a2d462eSRichard W.M. Jones}
32629a2d462eSRichard W.M. JonesEOF
32639a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
32649a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
32659a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
32669a2d462eSRichard W.M. Jones  fi
32679a2d462eSRichard W.M. Jonesfi
32689a2d462eSRichard W.M. Jones
32699a2d462eSRichard W.M. Jones##########################################
32705c6c3a6cSChristoph Hellwig# linux-aio probe
32715c6c3a6cSChristoph Hellwig
32725c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
32735c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
32745c6c3a6cSChristoph Hellwig#include <libaio.h>
32755c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3276832ce9c2SScott Wood#include <stddef.h>
32775c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
32785c6c3a6cSChristoph HellwigEOF
32795c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
32805c6c3a6cSChristoph Hellwig    linux_aio=yes
32815c6c3a6cSChristoph Hellwig  else
32825c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
328321684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
32845c6c3a6cSChristoph Hellwig    fi
32853cfcae3cSLuiz Capitulino    linux_aio=no
32865c6c3a6cSChristoph Hellwig  fi
32875c6c3a6cSChristoph Hellwigfi
32885c6c3a6cSChristoph Hellwig
32895c6c3a6cSChristoph Hellwig##########################################
32903b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
32913b8acc11SPaolo Bonzini
32923b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
32933b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
32943b8acc11SPaolo Bonzinielse
32953b8acc11SPaolo Bonzini  tpm_passthrough=no
32963b8acc11SPaolo Bonzinifi
32973b8acc11SPaolo Bonzini
32983b8acc11SPaolo Bonzini##########################################
3299758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3300758e8e38SVenkateswararao Jujjuri (JV)
3301758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3302758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3303758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3304758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3305f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3306f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3307f2338fb4SPavel Borzenkov#else
33084f26f2b6SAvi Kivity#include <sys/xattr.h>
3309f2338fb4SPavel Borzenkov#endif
3310758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3311758e8e38SVenkateswararao Jujjuri (JV)EOF
33124f26f2b6SAvi Kivity  if compile_prog "" "" ; then
33134f26f2b6SAvi Kivity    attr=yes
33144f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3315f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3316758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3317758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
33184f26f2b6SAvi Kivity    libattr=yes
3319758e8e38SVenkateswararao Jujjuri (JV)  else
3320758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
332121684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3322758e8e38SVenkateswararao Jujjuri (JV)    fi
3323758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3324758e8e38SVenkateswararao Jujjuri (JV)  fi
3325758e8e38SVenkateswararao Jujjuri (JV)fi
3326758e8e38SVenkateswararao Jujjuri (JV)
3327758e8e38SVenkateswararao Jujjuri (JV)##########################################
3328bf9298b9Saliguori# iovec probe
3329bf9298b9Saliguoricat > $TMPC <<EOF
3330db34f0b3Sblueswir1#include <sys/types.h>
3331bf9298b9Saliguori#include <sys/uio.h>
3332db34f0b3Sblueswir1#include <unistd.h>
3333f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3334bf9298b9SaliguoriEOF
3335bf9298b9Saliguoriiovec=no
333652166aa0SJuan Quintelaif compile_prog "" "" ; then
3337bf9298b9Saliguori  iovec=yes
3338bf9298b9Saliguorifi
3339bf9298b9Saliguori
3340f652e6afSaurel32##########################################
3341ceb42de8Saliguori# preadv probe
3342ceb42de8Saliguoricat > $TMPC <<EOF
3343ceb42de8Saliguori#include <sys/types.h>
3344ceb42de8Saliguori#include <sys/uio.h>
3345ceb42de8Saliguori#include <unistd.h>
3346c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3347ceb42de8SaliguoriEOF
3348ceb42de8Saliguoripreadv=no
334952166aa0SJuan Quintelaif compile_prog "" "" ; then
3350ceb42de8Saliguori  preadv=yes
3351ceb42de8Saliguorifi
3352ceb42de8Saliguori
3353ceb42de8Saliguori##########################################
3354f652e6afSaurel32# fdt probe
3355e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
3356e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
3357e169e1e1SPeter Maydellfdt_required=no
3358e169e1e1SPeter Maydellfor target in $target_list; do
3359e169e1e1SPeter Maydell  case $target in
33606a49fa95SAlexander Graf    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
3361e169e1e1SPeter Maydell      fdt_required=yes
3362e169e1e1SPeter Maydell    ;;
3363e169e1e1SPeter Maydell  esac
3364e169e1e1SPeter Maydelldone
3365e169e1e1SPeter Maydell
3366e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
3367e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
3368e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
3369e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
3370e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
3371e169e1e1SPeter Maydell  fi
3372e169e1e1SPeter Maydell  fdt=yes
3373e169e1e1SPeter Maydellfi
3374e169e1e1SPeter Maydell
33752df87df7SJuan Quintelaif test "$fdt" != "no" ; then
3376b41af4baSJuan Quintela  fdt_libs="-lfdt"
337796ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
337831ce0adbSThomas Huth  # and test for required functions to make sure we are on a version >= 1.4.0
3379f652e6afSaurel32  cat > $TMPC << EOF
338031ce0adbSThomas Huth#include <libfdt.h>
338196ce6545SPeter Crosthwaite#include <libfdt_env.h>
338231ce0adbSThomas Huthint main(void) { fdt_get_property_by_offset(0, 0, 0); return 0; }
3383f652e6afSaurel32EOF
338452166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
3385a540f158SPeter Crosthwaite    # system DTC is good - use it
3386f652e6afSaurel32    fdt=yes
3387a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
3388a540f158SPeter Crosthwaite    # have submodule DTC - use it
3389a540f158SPeter Crosthwaite    fdt=yes
3390a540f158SPeter Crosthwaite    dtc_internal="yes"
3391a540f158SPeter Crosthwaite    mkdir -p dtc
3392cab00a5aSMichael S. Tsirkin    if [ "$pwd_is_source_path" != "y" ] ; then
3393a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3394a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
33952df87df7SJuan Quintela    fi
3396a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3397a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3398a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
3399a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
340031ce0adbSThomas Huth    error_exit "DTC (libfdt) version >= 1.4.0 not present. Your options:" \
34013f281822SStewart Smith        "  (1) Preferred: Install the DTC (libfdt) devel package" \
3402a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
3403a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
3404a540f158SPeter Crosthwaite  else
3405a540f158SPeter Crosthwaite    # don't have and don't want
3406de3a354aSMichael Walle    fdt_libs=
34072df87df7SJuan Quintela    fdt=no
3408f652e6afSaurel32  fi
3409f652e6afSaurel32fi
3410f652e6afSaurel32
3411a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
3412a540f158SPeter Crosthwaite
341320ff075bSMichael Walle##########################################
3414fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3415b1546f32SGerd Hoffmann
3416da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3417014cb152SGerd Hoffmann  opengl_pkgs="epoxy libdrm gbm"
3418fb719563SOGAWA Hirofumi  if $pkg_config $opengl_pkgs x11; then
3419f676c67eSJeremy White    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3420f676c67eSJeremy White    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3421da076ffeSGerd Hoffmann    opengl=yes
3422925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3423925a0400SGerd Hoffmann        gtk_gl="yes"
3424925a0400SGerd Hoffmann    fi
342520ff075bSMichael Walle  else
3426da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3427dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
342820ff075bSMichael Walle    fi
3429f676c67eSJeremy White    opengl_cflags=""
3430da076ffeSGerd Hoffmann    opengl_libs=""
3431da076ffeSGerd Hoffmann    opengl=no
343220ff075bSMichael Walle  fi
343320ff075bSMichael Wallefi
343420ff075bSMichael Walle
3435014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3436014cb152SGerd Hoffmann  cat > $TMPC << EOF
3437014cb152SGerd Hoffmann#include <epoxy/egl.h>
3438014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3439014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3440014cb152SGerd Hoffmann#endif
3441014cb152SGerd Hoffmannint main(void) { return 0; }
3442014cb152SGerd HoffmannEOF
3443014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3444014cb152SGerd Hoffmann    opengl_dmabuf=yes
3445014cb152SGerd Hoffmann  fi
3446014cb152SGerd Hoffmannfi
3447c9a12e75SChrysostomos Nanakos
3448c9a12e75SChrysostomos Nanakos##########################################
3449c9a12e75SChrysostomos Nanakos# archipelago probe
3450c9a12e75SChrysostomos Nanakosif test "$archipelago" != "no" ; then
3451c9a12e75SChrysostomos Nanakos    cat > $TMPC <<EOF
3452c9a12e75SChrysostomos Nanakos#include <stdio.h>
3453c9a12e75SChrysostomos Nanakos#include <xseg/xseg.h>
3454c9a12e75SChrysostomos Nanakos#include <xseg/protocol.h>
3455c9a12e75SChrysostomos Nanakosint main(void) {
3456c9a12e75SChrysostomos Nanakos    xseg_initialize();
3457c9a12e75SChrysostomos Nanakos    return 0;
3458c9a12e75SChrysostomos Nanakos}
3459c9a12e75SChrysostomos NanakosEOF
3460c9a12e75SChrysostomos Nanakos    archipelago_libs=-lxseg
3461c9a12e75SChrysostomos Nanakos    if compile_prog "" "$archipelago_libs"; then
3462c9a12e75SChrysostomos Nanakos        archipelago="yes"
3463c9a12e75SChrysostomos Nanakos        libs_tools="$archipelago_libs $libs_tools"
3464c9a12e75SChrysostomos Nanakos        libs_softmmu="$archipelago_libs $libs_softmmu"
34656a460ed1SStefan Hajnoczi
34666a460ed1SStefan Hajnoczi	echo "WARNING: Please check the licenses of QEMU and libxseg carefully."
34676a460ed1SStefan Hajnoczi	echo "GPLv3 versions of libxseg may not be compatible with QEMU's"
34686a460ed1SStefan Hajnoczi	echo "license and therefore prevent redistribution."
34696a460ed1SStefan Hajnoczi	echo
34706a460ed1SStefan Hajnoczi	echo "To disable Archipelago, use --disable-archipelago"
3471c9a12e75SChrysostomos Nanakos    else
3472c9a12e75SChrysostomos Nanakos      if test "$archipelago" = "yes" ; then
3473c9a12e75SChrysostomos Nanakos        feature_not_found "Archipelago backend support" "Install libxseg devel"
3474c9a12e75SChrysostomos Nanakos      fi
3475c9a12e75SChrysostomos Nanakos      archipelago="no"
3476c9a12e75SChrysostomos Nanakos    fi
3477c9a12e75SChrysostomos Nanakosfi
3478c9a12e75SChrysostomos Nanakos
3479c9a12e75SChrysostomos Nanakos
3480eb100396SBharata B Rao##########################################
3481eb100396SBharata B Rao# glusterfs probe
3482eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
348365d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3484e01bee08SBharata B Rao    glusterfs="yes"
348589138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
348689138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3487d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3488d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3489d85fa9ebSJeff Cody    fi
349065d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
34910c14fb47SBharata B Rao      glusterfs_discard="yes"
34920c14fb47SBharata B Rao    fi
34937c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
34947c815372SBharata B Rao      glusterfs_zerofill="yes"
34957c815372SBharata B Rao    fi
3496eb100396SBharata B Rao  else
3497eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
34988efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
34998efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3500eb100396SBharata B Rao    fi
3501e01bee08SBharata B Rao    glusterfs="no"
3502eb100396SBharata B Rao  fi
3503eb100396SBharata B Raofi
3504eb100396SBharata B Rao
350539386ac7Saurel32# Check for inotify functions when we are building linux-user
35063b3f24adSaurel32# emulator.  This is done because older glibc versions don't
35073b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
35083b3f24adSaurel32# don't provide them even if kernel supports them.
35093b3f24adSaurel32#
35103b3f24adSaurel32inotify=no
35113b3f24adSaurel32cat > $TMPC << EOF
35123b3f24adSaurel32#include <sys/inotify.h>
35133b3f24adSaurel32
35143b3f24adSaurel32int
35153b3f24adSaurel32main(void)
35163b3f24adSaurel32{
35173b3f24adSaurel32	/* try to start inotify */
35188690e420Saurel32	return inotify_init();
35193b3f24adSaurel32}
35203b3f24adSaurel32EOF
352152166aa0SJuan Quintelaif compile_prog "" "" ; then
35223b3f24adSaurel32  inotify=yes
35233b3f24adSaurel32fi
35243b3f24adSaurel32
3525c05c7a73SRiku Voipioinotify1=no
3526c05c7a73SRiku Voipiocat > $TMPC << EOF
3527c05c7a73SRiku Voipio#include <sys/inotify.h>
3528c05c7a73SRiku Voipio
3529c05c7a73SRiku Voipioint
3530c05c7a73SRiku Voipiomain(void)
3531c05c7a73SRiku Voipio{
3532c05c7a73SRiku Voipio    /* try to start inotify */
3533c05c7a73SRiku Voipio    return inotify_init1(0);
3534c05c7a73SRiku Voipio}
3535c05c7a73SRiku VoipioEOF
3536c05c7a73SRiku Voipioif compile_prog "" "" ; then
3537c05c7a73SRiku Voipio  inotify1=yes
3538c05c7a73SRiku Voipiofi
3539c05c7a73SRiku Voipio
3540ebc996f3SRiku Voipio# check if utimensat and futimens are supported
3541ebc996f3SRiku Voipioutimens=no
3542ebc996f3SRiku Voipiocat > $TMPC << EOF
3543ebc996f3SRiku Voipio#define _ATFILE_SOURCE
3544ebc996f3SRiku Voipio#include <stddef.h>
3545ebc996f3SRiku Voipio#include <fcntl.h>
35463014ee00SPeter Maydell#include <sys/stat.h>
3547ebc996f3SRiku Voipio
3548ebc996f3SRiku Voipioint main(void)
3549ebc996f3SRiku Voipio{
3550ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
3551ebc996f3SRiku Voipio    futimens(0, NULL);
3552ebc996f3SRiku Voipio    return 0;
3553ebc996f3SRiku Voipio}
3554ebc996f3SRiku VoipioEOF
355552166aa0SJuan Quintelaif compile_prog "" "" ; then
3556ebc996f3SRiku Voipio  utimens=yes
3557ebc996f3SRiku Voipiofi
3558ebc996f3SRiku Voipio
3559099d6b0fSRiku Voipio# check if pipe2 is there
3560099d6b0fSRiku Voipiopipe2=no
3561099d6b0fSRiku Voipiocat > $TMPC << EOF
3562099d6b0fSRiku Voipio#include <unistd.h>
3563099d6b0fSRiku Voipio#include <fcntl.h>
3564099d6b0fSRiku Voipio
3565099d6b0fSRiku Voipioint main(void)
3566099d6b0fSRiku Voipio{
3567099d6b0fSRiku Voipio    int pipefd[2];
35689bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3569099d6b0fSRiku Voipio}
3570099d6b0fSRiku VoipioEOF
357152166aa0SJuan Quintelaif compile_prog "" "" ; then
3572099d6b0fSRiku Voipio  pipe2=yes
3573099d6b0fSRiku Voipiofi
3574099d6b0fSRiku Voipio
357540ff6d7eSKevin Wolf# check if accept4 is there
357640ff6d7eSKevin Wolfaccept4=no
357740ff6d7eSKevin Wolfcat > $TMPC << EOF
357840ff6d7eSKevin Wolf#include <sys/socket.h>
357940ff6d7eSKevin Wolf#include <stddef.h>
358040ff6d7eSKevin Wolf
358140ff6d7eSKevin Wolfint main(void)
358240ff6d7eSKevin Wolf{
358340ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
358440ff6d7eSKevin Wolf    return 0;
358540ff6d7eSKevin Wolf}
358640ff6d7eSKevin WolfEOF
358740ff6d7eSKevin Wolfif compile_prog "" "" ; then
358840ff6d7eSKevin Wolf  accept4=yes
358940ff6d7eSKevin Wolffi
359040ff6d7eSKevin Wolf
35913ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
35923ce34dfbSvibisreenivasansplice=no
35933ce34dfbSvibisreenivasancat > $TMPC << EOF
35943ce34dfbSvibisreenivasan#include <unistd.h>
35953ce34dfbSvibisreenivasan#include <fcntl.h>
35963ce34dfbSvibisreenivasan#include <limits.h>
35973ce34dfbSvibisreenivasan
35983ce34dfbSvibisreenivasanint main(void)
35993ce34dfbSvibisreenivasan{
360066ea0f22SStefan Weil    int len, fd = 0;
36013ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
36023ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
36033ce34dfbSvibisreenivasan    return 0;
36043ce34dfbSvibisreenivasan}
36053ce34dfbSvibisreenivasanEOF
360652166aa0SJuan Quintelaif compile_prog "" "" ; then
36073ce34dfbSvibisreenivasan  splice=yes
36083ce34dfbSvibisreenivasanfi
36093ce34dfbSvibisreenivasan
3610dcc38d1cSMarcelo Tosatti##########################################
3611a99d57bbSWanlong Gao# libnuma probe
3612a99d57bbSWanlong Gao
3613a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3614a99d57bbSWanlong Gao  cat > $TMPC << EOF
3615a99d57bbSWanlong Gao#include <numa.h>
3616a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3617a99d57bbSWanlong GaoEOF
3618a99d57bbSWanlong Gao
3619a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3620a99d57bbSWanlong Gao    numa=yes
3621a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
3622a99d57bbSWanlong Gao  else
3623a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3624a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3625a99d57bbSWanlong Gao    fi
3626a99d57bbSWanlong Gao    numa=no
3627a99d57bbSWanlong Gao  fi
3628a99d57bbSWanlong Gaofi
3629a99d57bbSWanlong Gao
36307b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
36317b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
36327b01cb97SAlexandre Derumier    exit 1
36337b01cb97SAlexandre Derumierfi
36347b01cb97SAlexandre Derumier
3635a99d57bbSWanlong Gao##########################################
36362847b469SFam Zheng# tcmalloc probe
36372847b469SFam Zheng
36382847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
36392847b469SFam Zheng  cat > $TMPC << EOF
36402847b469SFam Zheng#include <stdlib.h>
36412847b469SFam Zhengint main(void) { malloc(1); return 0; }
36422847b469SFam ZhengEOF
36432847b469SFam Zheng
36442847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
36452847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
36462847b469SFam Zheng  else
36472847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
36482847b469SFam Zheng  fi
36492847b469SFam Zhengfi
36502847b469SFam Zheng
36512847b469SFam Zheng##########################################
36527b01cb97SAlexandre Derumier# jemalloc probe
36537b01cb97SAlexandre Derumier
36547b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
36557b01cb97SAlexandre Derumier  cat > $TMPC << EOF
36567b01cb97SAlexandre Derumier#include <stdlib.h>
36577b01cb97SAlexandre Derumierint main(void) { malloc(1); return 0; }
36587b01cb97SAlexandre DerumierEOF
36597b01cb97SAlexandre Derumier
36607b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
36617b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
36627b01cb97SAlexandre Derumier  else
36637b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
36647b01cb97SAlexandre Derumier  fi
36657b01cb97SAlexandre Derumierfi
36667b01cb97SAlexandre Derumier
36677b01cb97SAlexandre Derumier##########################################
3668dcc38d1cSMarcelo Tosatti# signalfd probe
3669dcc38d1cSMarcelo Tosattisignalfd="no"
3670dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3671dcc38d1cSMarcelo Tosatti#include <unistd.h>
3672dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3673dcc38d1cSMarcelo Tosatti#include <signal.h>
3674dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3675dcc38d1cSMarcelo TosattiEOF
3676dcc38d1cSMarcelo Tosatti
3677dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3678dcc38d1cSMarcelo Tosatti  signalfd=yes
3679dcc38d1cSMarcelo Tosattifi
3680dcc38d1cSMarcelo Tosatti
3681c2882b96SRiku Voipio# check if eventfd is supported
3682c2882b96SRiku Voipioeventfd=no
3683c2882b96SRiku Voipiocat > $TMPC << EOF
3684c2882b96SRiku Voipio#include <sys/eventfd.h>
3685c2882b96SRiku Voipio
3686c2882b96SRiku Voipioint main(void)
3687c2882b96SRiku Voipio{
368855cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3689c2882b96SRiku Voipio}
3690c2882b96SRiku VoipioEOF
3691c2882b96SRiku Voipioif compile_prog "" "" ; then
3692c2882b96SRiku Voipio  eventfd=yes
3693c2882b96SRiku Voipiofi
3694c2882b96SRiku Voipio
3695751bcc39SMarc-André Lureau# check if memfd is supported
3696751bcc39SMarc-André Lureaumemfd=no
3697751bcc39SMarc-André Lureaucat > $TMPC << EOF
3698751bcc39SMarc-André Lureau#include <sys/memfd.h>
3699751bcc39SMarc-André Lureau
3700751bcc39SMarc-André Lureauint main(void)
3701751bcc39SMarc-André Lureau{
3702751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3703751bcc39SMarc-André Lureau}
3704751bcc39SMarc-André LureauEOF
3705751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3706751bcc39SMarc-André Lureau  memfd=yes
3707751bcc39SMarc-André Lureaufi
3708751bcc39SMarc-André Lureau
3709751bcc39SMarc-André Lureau
3710751bcc39SMarc-André Lureau
3711d0927938SUlrich Hecht# check for fallocate
3712d0927938SUlrich Hechtfallocate=no
3713d0927938SUlrich Hechtcat > $TMPC << EOF
3714d0927938SUlrich Hecht#include <fcntl.h>
3715d0927938SUlrich Hecht
3716d0927938SUlrich Hechtint main(void)
3717d0927938SUlrich Hecht{
3718d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3719d0927938SUlrich Hecht    return 0;
3720d0927938SUlrich Hecht}
3721d0927938SUlrich HechtEOF
37228fb03151SPeter Maydellif compile_prog "" "" ; then
3723d0927938SUlrich Hecht  fallocate=yes
3724d0927938SUlrich Hechtfi
3725d0927938SUlrich Hecht
37263d4fa43eSKusanagi Kouichi# check for fallocate hole punching
37273d4fa43eSKusanagi Kouichifallocate_punch_hole=no
37283d4fa43eSKusanagi Kouichicat > $TMPC << EOF
37293d4fa43eSKusanagi Kouichi#include <fcntl.h>
37303d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
37313d4fa43eSKusanagi Kouichi
37323d4fa43eSKusanagi Kouichiint main(void)
37333d4fa43eSKusanagi Kouichi{
37343d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
37353d4fa43eSKusanagi Kouichi    return 0;
37363d4fa43eSKusanagi Kouichi}
37373d4fa43eSKusanagi KouichiEOF
37383d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
37393d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
37403d4fa43eSKusanagi Kouichifi
37413d4fa43eSKusanagi Kouichi
3742b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3743b953f075SDenis V. Lunevfallocate_zero_range=no
3744b953f075SDenis V. Lunevcat > $TMPC << EOF
3745b953f075SDenis V. Lunev#include <fcntl.h>
3746b953f075SDenis V. Lunev#include <linux/falloc.h>
3747b953f075SDenis V. Lunev
3748b953f075SDenis V. Lunevint main(void)
3749b953f075SDenis V. Lunev{
3750b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3751b953f075SDenis V. Lunev    return 0;
3752b953f075SDenis V. Lunev}
3753b953f075SDenis V. LunevEOF
3754b953f075SDenis V. Lunevif compile_prog "" "" ; then
3755b953f075SDenis V. Lunev  fallocate_zero_range=yes
3756b953f075SDenis V. Lunevfi
3757b953f075SDenis V. Lunev
3758ed911435SKevin Wolf# check for posix_fallocate
3759ed911435SKevin Wolfposix_fallocate=no
3760ed911435SKevin Wolfcat > $TMPC << EOF
3761ed911435SKevin Wolf#include <fcntl.h>
3762ed911435SKevin Wolf
3763ed911435SKevin Wolfint main(void)
3764ed911435SKevin Wolf{
3765ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3766ed911435SKevin Wolf    return 0;
3767ed911435SKevin Wolf}
3768ed911435SKevin WolfEOF
3769ed911435SKevin Wolfif compile_prog "" "" ; then
3770ed911435SKevin Wolf    posix_fallocate=yes
3771ed911435SKevin Wolffi
3772ed911435SKevin Wolf
3773c727f47dSPeter Maydell# check for sync_file_range
3774c727f47dSPeter Maydellsync_file_range=no
3775c727f47dSPeter Maydellcat > $TMPC << EOF
3776c727f47dSPeter Maydell#include <fcntl.h>
3777c727f47dSPeter Maydell
3778c727f47dSPeter Maydellint main(void)
3779c727f47dSPeter Maydell{
3780c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3781c727f47dSPeter Maydell    return 0;
3782c727f47dSPeter Maydell}
3783c727f47dSPeter MaydellEOF
37848fb03151SPeter Maydellif compile_prog "" "" ; then
3785c727f47dSPeter Maydell  sync_file_range=yes
3786c727f47dSPeter Maydellfi
3787c727f47dSPeter Maydell
3788dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3789dace20dcSPeter Maydellfiemap=no
3790dace20dcSPeter Maydellcat > $TMPC << EOF
3791dace20dcSPeter Maydell#include <sys/ioctl.h>
3792dace20dcSPeter Maydell#include <linux/fs.h>
3793dace20dcSPeter Maydell#include <linux/fiemap.h>
3794dace20dcSPeter Maydell
3795dace20dcSPeter Maydellint main(void)
3796dace20dcSPeter Maydell{
3797dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3798dace20dcSPeter Maydell    return 0;
3799dace20dcSPeter Maydell}
3800dace20dcSPeter MaydellEOF
38018fb03151SPeter Maydellif compile_prog "" "" ; then
3802dace20dcSPeter Maydell  fiemap=yes
3803dace20dcSPeter Maydellfi
3804dace20dcSPeter Maydell
3805d0927938SUlrich Hecht# check for dup3
3806d0927938SUlrich Hechtdup3=no
3807d0927938SUlrich Hechtcat > $TMPC << EOF
3808d0927938SUlrich Hecht#include <unistd.h>
3809d0927938SUlrich Hecht
3810d0927938SUlrich Hechtint main(void)
3811d0927938SUlrich Hecht{
3812d0927938SUlrich Hecht    dup3(0, 0, 0);
3813d0927938SUlrich Hecht    return 0;
3814d0927938SUlrich Hecht}
3815d0927938SUlrich HechtEOF
381678f5d726SJan Kiszkaif compile_prog "" "" ; then
3817d0927938SUlrich Hecht  dup3=yes
3818d0927938SUlrich Hechtfi
3819d0927938SUlrich Hecht
38204e0c6529SAlex Bligh# check for ppoll support
38214e0c6529SAlex Blighppoll=no
38224e0c6529SAlex Blighcat > $TMPC << EOF
38234e0c6529SAlex Bligh#include <poll.h>
38244e0c6529SAlex Bligh
38254e0c6529SAlex Blighint main(void)
38264e0c6529SAlex Bligh{
38274e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
38284e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
38294e0c6529SAlex Bligh    return 0;
38304e0c6529SAlex Bligh}
38314e0c6529SAlex BlighEOF
38324e0c6529SAlex Blighif compile_prog "" "" ; then
38334e0c6529SAlex Bligh  ppoll=yes
38344e0c6529SAlex Blighfi
38354e0c6529SAlex Bligh
3836cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3837cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3838cd758dd0SAlex Blighcat > $TMPC << EOF
3839cd758dd0SAlex Bligh#include <sys/prctl.h>
3840cd758dd0SAlex Bligh
3841cd758dd0SAlex Blighint main(void)
3842cd758dd0SAlex Bligh{
3843cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3844cd758dd0SAlex Bligh    return 0;
3845cd758dd0SAlex Bligh}
3846cd758dd0SAlex BlighEOF
3847cd758dd0SAlex Blighif compile_prog "" "" ; then
3848cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3849cd758dd0SAlex Blighfi
3850cd758dd0SAlex Bligh
38513b6edd16SPeter Maydell# check for epoll support
38523b6edd16SPeter Maydellepoll=no
38533b6edd16SPeter Maydellcat > $TMPC << EOF
38543b6edd16SPeter Maydell#include <sys/epoll.h>
38553b6edd16SPeter Maydell
38563b6edd16SPeter Maydellint main(void)
38573b6edd16SPeter Maydell{
38583b6edd16SPeter Maydell    epoll_create(0);
38593b6edd16SPeter Maydell    return 0;
38603b6edd16SPeter Maydell}
38613b6edd16SPeter MaydellEOF
38628fb03151SPeter Maydellif compile_prog "" "" ; then
38633b6edd16SPeter Maydell  epoll=yes
38643b6edd16SPeter Maydellfi
38653b6edd16SPeter Maydell
3866227f0214SPeter Maydell# epoll_create1 is a later addition
3867227f0214SPeter Maydell# so we must check separately for its presence
38683b6edd16SPeter Maydellepoll_create1=no
38693b6edd16SPeter Maydellcat > $TMPC << EOF
38703b6edd16SPeter Maydell#include <sys/epoll.h>
38713b6edd16SPeter Maydell
38723b6edd16SPeter Maydellint main(void)
38733b6edd16SPeter Maydell{
387419e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
387519e83f6bSPeter Maydell     * a function being called. This is necessary so that on
387619e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
387719e83f6bSPeter Maydell     * the library but not declared in the header file we will
387819e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
387919e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
388019e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
388119e83f6bSPeter Maydell     */
3882c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
38833b6edd16SPeter Maydell}
38843b6edd16SPeter MaydellEOF
38858fb03151SPeter Maydellif compile_prog "" "" ; then
38863b6edd16SPeter Maydell  epoll_create1=yes
38873b6edd16SPeter Maydellfi
38883b6edd16SPeter Maydell
3889a8fd1abaSPeter Maydell# check for sendfile support
3890a8fd1abaSPeter Maydellsendfile=no
3891a8fd1abaSPeter Maydellcat > $TMPC << EOF
3892a8fd1abaSPeter Maydell#include <sys/sendfile.h>
3893a8fd1abaSPeter Maydell
3894a8fd1abaSPeter Maydellint main(void)
3895a8fd1abaSPeter Maydell{
3896a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
3897a8fd1abaSPeter Maydell}
3898a8fd1abaSPeter MaydellEOF
3899a8fd1abaSPeter Maydellif compile_prog "" "" ; then
3900a8fd1abaSPeter Maydell  sendfile=yes
3901a8fd1abaSPeter Maydellfi
3902a8fd1abaSPeter Maydell
390351834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
390451834341SRiku Voipiotimerfd=no
390551834341SRiku Voipiocat > $TMPC << EOF
390651834341SRiku Voipio#include <sys/timerfd.h>
390751834341SRiku Voipio
390851834341SRiku Voipioint main(void)
390951834341SRiku Voipio{
391051834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
391151834341SRiku Voipio}
391251834341SRiku VoipioEOF
391351834341SRiku Voipioif compile_prog "" "" ; then
391451834341SRiku Voipio  timerfd=yes
391551834341SRiku Voipiofi
391651834341SRiku Voipio
39179af5c906SRiku Voipio# check for setns and unshare support
39189af5c906SRiku Voipiosetns=no
39199af5c906SRiku Voipiocat > $TMPC << EOF
39209af5c906SRiku Voipio#include <sched.h>
39219af5c906SRiku Voipio
39229af5c906SRiku Voipioint main(void)
39239af5c906SRiku Voipio{
39249af5c906SRiku Voipio    int ret;
39259af5c906SRiku Voipio    ret = setns(0, 0);
39269af5c906SRiku Voipio    ret = unshare(0);
39279af5c906SRiku Voipio    return ret;
39289af5c906SRiku Voipio}
39299af5c906SRiku VoipioEOF
39309af5c906SRiku Voipioif compile_prog "" "" ; then
39319af5c906SRiku Voipio  setns=yes
39329af5c906SRiku Voipiofi
39339af5c906SRiku Voipio
393438860a03SAleksandar Markovic# clock_adjtime probe
393538860a03SAleksandar Markovicclock_adjtime=no
393638860a03SAleksandar Markoviccat > $TMPC <<EOF
393738860a03SAleksandar Markovic#include <time.h>
393838860a03SAleksandar Markovic
393938860a03SAleksandar Markovicint main(void)
394038860a03SAleksandar Markovic{
394138860a03SAleksandar Markovic    return clock_adjtime(0, 0);
394238860a03SAleksandar Markovic}
394338860a03SAleksandar MarkovicEOF
394438860a03SAleksandar Markovicclock_adjtime=no
394538860a03SAleksandar Markovicif compile_prog "" "" ; then
394638860a03SAleksandar Markovic  clock_adjtime=yes
394738860a03SAleksandar Markovicfi
394838860a03SAleksandar Markovic
39495a03cd00SAleksandar Markovic# syncfs probe
39505a03cd00SAleksandar Markovicsyncfs=no
39515a03cd00SAleksandar Markoviccat > $TMPC <<EOF
39525a03cd00SAleksandar Markovic#include <unistd.h>
39535a03cd00SAleksandar Markovic
39545a03cd00SAleksandar Markovicint main(void)
39555a03cd00SAleksandar Markovic{
39565a03cd00SAleksandar Markovic    return syncfs(0);
39575a03cd00SAleksandar Markovic}
39585a03cd00SAleksandar MarkovicEOF
39595a03cd00SAleksandar Markovicsyncfs=no
39605a03cd00SAleksandar Markovicif compile_prog "" "" ; then
39615a03cd00SAleksandar Markovic  syncfs=yes
39625a03cd00SAleksandar Markovicfi
39635a03cd00SAleksandar Markovic
3964cc8ae6deSpbrook# Check if tools are available to build documentation.
3965a25dba17SJuan Quintelaif test "$docs" != "no" ; then
396601668d98SStefan Weil  if has makeinfo && has pod2man; then
3967a25dba17SJuan Quintela    docs=yes
396883a3ab8bSJuan Quintela  else
3969a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
397021684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
397183a3ab8bSJuan Quintela    fi
3972a25dba17SJuan Quintela    docs=no
397383a3ab8bSJuan Quintela  fi
3974cc8ae6deSpbrookfi
3975cc8ae6deSpbrook
3976f514f41cSStefan Weil# Search for bswap_32 function
39776ae9a1f4SJuan Quintelabyteswap_h=no
39786ae9a1f4SJuan Quintelacat > $TMPC << EOF
39796ae9a1f4SJuan Quintela#include <byteswap.h>
39806ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
39816ae9a1f4SJuan QuintelaEOF
398252166aa0SJuan Quintelaif compile_prog "" "" ; then
39836ae9a1f4SJuan Quintela  byteswap_h=yes
39846ae9a1f4SJuan Quintelafi
39856ae9a1f4SJuan Quintela
398675f13596SStefan Weil# Search for bswap32 function
39876ae9a1f4SJuan Quintelabswap_h=no
39886ae9a1f4SJuan Quintelacat > $TMPC << EOF
39896ae9a1f4SJuan Quintela#include <sys/endian.h>
39906ae9a1f4SJuan Quintela#include <sys/types.h>
39916ae9a1f4SJuan Quintela#include <machine/bswap.h>
39926ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
39936ae9a1f4SJuan QuintelaEOF
399452166aa0SJuan Quintelaif compile_prog "" "" ; then
39956ae9a1f4SJuan Quintela  bswap_h=yes
39966ae9a1f4SJuan Quintelafi
39976ae9a1f4SJuan Quintela
3998da93a1fdSaliguori##########################################
3999e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4000c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4001e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
40023c33ea96SPaolo Bonzini    libiscsi="yes"
4003ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4004ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4005c589b249SRonnie Sahlberg  else
4006c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4007e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4008c589b249SRonnie Sahlberg    fi
4009c589b249SRonnie Sahlberg    libiscsi="no"
4010c589b249SRonnie Sahlberg  fi
4011c589b249SRonnie Sahlbergfi
4012c589b249SRonnie Sahlberg
4013c589b249SRonnie Sahlberg##########################################
40148bacde8dSNatanael Copa# Do we need libm
40158bacde8dSNatanael Copacat > $TMPC << EOF
40168bacde8dSNatanael Copa#include <math.h>
4017f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
40188bacde8dSNatanael CopaEOF
40198bacde8dSNatanael Copaif compile_prog "" "" ; then
40208bacde8dSNatanael Copa  :
40218bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
40228bacde8dSNatanael Copa  LIBS="-lm $LIBS"
40238bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
40248bacde8dSNatanael Copaelse
402576ad07a4SPeter Maydell  error_exit "libm check failed"
40268bacde8dSNatanael Copafi
40278bacde8dSNatanael Copa
40288bacde8dSNatanael Copa##########################################
4029da93a1fdSaliguori# Do we need librt
40308bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
40318bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
40328bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
40338bacde8dSNatanael Copa# function in addition.
4034da93a1fdSaliguoricat > $TMPC <<EOF
4035da93a1fdSaliguori#include <signal.h>
4036da93a1fdSaliguori#include <time.h>
40378bacde8dSNatanael Copaint main(void) {
40388bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
40398bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
40408bacde8dSNatanael Copa}
4041da93a1fdSaliguoriEOF
4042da93a1fdSaliguori
404352166aa0SJuan Quintelaif compile_prog "" "" ; then
404407ffa4bdSJuan Quintela  :
40458bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
404618e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
404718e588b1SRick Liu  LIBS="$LIBS -lrt"
404818e588b1SRick Liu  libs_qga="$libs_qga -lrt"
4049da93a1fdSaliguorifi
4050da93a1fdSaliguori
405131ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4052179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
40536362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
40546362a53fSJuan Quintelafi
40556362a53fSJuan Quintela
4056de5071c5SBlue Swirl##########################################
4057cd4ec0b4SGerd Hoffmann# spice probe
4058cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4059cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4060cd4ec0b4SGerd Hoffmann#include <spice.h>
4061cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4062cd4ec0b4SGerd HoffmannEOF
4063710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4064710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
406565d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
406665d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4067cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4068cd4ec0b4SGerd Hoffmann    spice="yes"
4069cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
4070cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
40712e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
40722e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
4073cd4ec0b4SGerd Hoffmann  else
4074cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
40758efc9363SHu Tao      feature_not_found "spice" \
40768efc9363SHu Tao          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4077cd4ec0b4SGerd Hoffmann    fi
4078cd4ec0b4SGerd Hoffmann    spice="no"
4079cd4ec0b4SGerd Hoffmann  fi
4080cd4ec0b4SGerd Hoffmannfi
4081cd4ec0b4SGerd Hoffmann
40827b02f544SMarc-André Lureau# check for smartcard support
4083111a38b0SRobert Relyeasmartcard_cflags=""
40847b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
40857b02f544SMarc-André Lureau    if $pkg_config libcacard; then
40867b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
40877b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
40887b02f544SMarc-André Lureau        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
40897b02f544SMarc-André Lureau        libs_softmmu="$libs_softmmu $libcacard_libs"
40907b02f544SMarc-André Lureau        smartcard="yes"
4091111a38b0SRobert Relyea    else
40927b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
40937b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4094111a38b0SRobert Relyea        fi
40957b02f544SMarc-André Lureau        smartcard="no"
4096111a38b0SRobert Relyea    fi
4097111a38b0SRobert Relyeafi
4098111a38b0SRobert Relyea
40992b2325ffSGerd Hoffmann# check for libusb
41002b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
410165d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
41022b2325ffSGerd Hoffmann        libusb="yes"
4103ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4104ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
41052b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
41062b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
41072b2325ffSGerd Hoffmann    else
41082b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
41098efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
41102b2325ffSGerd Hoffmann        fi
41112b2325ffSGerd Hoffmann        libusb="no"
41122b2325ffSGerd Hoffmann    fi
41132b2325ffSGerd Hoffmannfi
41142b2325ffSGerd Hoffmann
411569354a83SHans de Goede# check for usbredirparser for usb network redirection support
411669354a83SHans de Goedeif test "$usb_redir" != "no" ; then
411765d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
411869354a83SHans de Goede        usb_redir="yes"
4119ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4120ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
412169354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
412256ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
412369354a83SHans de Goede    else
412469354a83SHans de Goede        if test "$usb_redir" = "yes"; then
412521684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
412669354a83SHans de Goede        fi
412769354a83SHans de Goede        usb_redir="no"
412869354a83SHans de Goede    fi
412969354a83SHans de Goedefi
413069354a83SHans de Goede
4131cd4ec0b4SGerd Hoffmann##########################################
4132d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4133d9840e25STomoki Sekiyama
4134d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4135d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4136690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4137d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4138d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4139690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4140d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4141d9840e25STomoki Sekiyama	  ;;
4142690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4143d9840e25STomoki Sekiyama  esac
4144d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4145d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4146d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4147d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4148d9840e25STomoki SekiyamaEOF
4149d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4150d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4151d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4152315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4153f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4154d9840e25STomoki Sekiyama  else
4155d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4156d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4157d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4158d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4159d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4160d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4161d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4162d9840e25STomoki Sekiyama    fi
4163d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4164d9840e25STomoki Sekiyama  fi
4165d9840e25STomoki Sekiyamafi
4166d9840e25STomoki Sekiyama
4167d9840e25STomoki Sekiyama##########################################
4168d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4169d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4170d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4171d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4172d9840e25STomoki Sekiyama
4173d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4174d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4175d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4176d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4177d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4178d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4179d9840e25STomoki Sekiyama    else
4180d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4181d9840e25STomoki Sekiyama    fi
4182d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4183d9840e25STomoki Sekiyama    win_sdk=""
4184d9840e25STomoki Sekiyama  fi
4185d9840e25STomoki Sekiyamafi
4186d9840e25STomoki Sekiyama
4187d9840e25STomoki Sekiyama##########################################
418850cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
418950cbebb9SMichael Rothif test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
419050cbebb9SMichael Roth  cat > $TMPC << EOF
419150cbebb9SMichael Roth#include <windows.h>
419250cbebb9SMichael Roth#include <ntddscsi.h>
419350cbebb9SMichael Rothint main(void) {
419450cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
419550cbebb9SMichael Roth#error Missing required ioctl definitions
419650cbebb9SMichael Roth#endif
419750cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
419850cbebb9SMichael Roth  return addr.Lun;
419950cbebb9SMichael Roth}
420050cbebb9SMichael RothEOF
420150cbebb9SMichael Roth  if compile_prog "" "" ; then
420250cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4203c54e1eb4SMichael Roth    libs_qga="-lsetupapi $libs_qga"
420450cbebb9SMichael Roth  fi
420550cbebb9SMichael Rothfi
420650cbebb9SMichael Roth
420750cbebb9SMichael Roth##########################################
42089d9e1521SGerd Hoffmann# virgl renderer probe
42099d9e1521SGerd Hoffmann
42109d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
42119d9e1521SGerd Hoffmann  cat > $TMPC << EOF
42129d9e1521SGerd Hoffmann#include <virglrenderer.h>
42139d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
42149d9e1521SGerd HoffmannEOF
42159d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
42169d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
42179d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
42189d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
42199d9e1521SGerd Hoffmann    virglrenderer="yes"
42209d9e1521SGerd Hoffmann  else
42219d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
42229d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
42239d9e1521SGerd Hoffmann    fi
42249d9e1521SGerd Hoffmann    virglrenderer="no"
42259d9e1521SGerd Hoffmann  fi
42269d9e1521SGerd Hoffmannfi
42279d9e1521SGerd Hoffmann
42289d9e1521SGerd Hoffmann##########################################
42295f6b9e8fSBlue Swirl# check if we have fdatasync
42305f6b9e8fSBlue Swirl
42315f6b9e8fSBlue Swirlfdatasync=no
42325f6b9e8fSBlue Swirlcat > $TMPC << EOF
42335f6b9e8fSBlue Swirl#include <unistd.h>
4234d1722a27SAlexandre Raymondint main(void) {
4235d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4236d1722a27SAlexandre Raymondreturn fdatasync(0);
4237d1722a27SAlexandre Raymond#else
4238e172fe11SStefan Weil#error Not supported
4239d1722a27SAlexandre Raymond#endif
4240d1722a27SAlexandre Raymond}
42415f6b9e8fSBlue SwirlEOF
42425f6b9e8fSBlue Swirlif compile_prog "" "" ; then
42435f6b9e8fSBlue Swirl    fdatasync=yes
42445f6b9e8fSBlue Swirlfi
42455f6b9e8fSBlue Swirl
424694a420b1SStefan Hajnoczi##########################################
4247e78815a5SAndreas Färber# check if we have madvise
4248e78815a5SAndreas Färber
4249e78815a5SAndreas Färbermadvise=no
4250e78815a5SAndreas Färbercat > $TMPC << EOF
4251e78815a5SAndreas Färber#include <sys/types.h>
4252e78815a5SAndreas Färber#include <sys/mman.h>
4253832ce9c2SScott Wood#include <stddef.h>
4254e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4255e78815a5SAndreas FärberEOF
4256e78815a5SAndreas Färberif compile_prog "" "" ; then
4257e78815a5SAndreas Färber    madvise=yes
4258e78815a5SAndreas Färberfi
4259e78815a5SAndreas Färber
4260e78815a5SAndreas Färber##########################################
4261e78815a5SAndreas Färber# check if we have posix_madvise
4262e78815a5SAndreas Färber
4263e78815a5SAndreas Färberposix_madvise=no
4264e78815a5SAndreas Färbercat > $TMPC << EOF
4265e78815a5SAndreas Färber#include <sys/mman.h>
4266832ce9c2SScott Wood#include <stddef.h>
4267e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4268e78815a5SAndreas FärberEOF
4269e78815a5SAndreas Färberif compile_prog "" "" ; then
4270e78815a5SAndreas Färber    posix_madvise=yes
4271e78815a5SAndreas Färberfi
4272e78815a5SAndreas Färber
4273e78815a5SAndreas Färber##########################################
42740a852417SPaul Durrant# check if we have posix_syslog
42750a852417SPaul Durrant
42760a852417SPaul Durrantposix_syslog=no
42770a852417SPaul Durrantcat > $TMPC << EOF
42780a852417SPaul Durrant#include <syslog.h>
42790a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
42800a852417SPaul DurrantEOF
42810a852417SPaul Durrantif compile_prog "" "" ; then
42820a852417SPaul Durrant    posix_syslog=yes
42830a852417SPaul Durrantfi
42840a852417SPaul Durrant
42850a852417SPaul Durrant##########################################
428694a420b1SStefan Hajnoczi# check if trace backend exists
428794a420b1SStefan Hajnoczi
42885b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
428994a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
42905b808275SLluís Vilanova  error_exit "invalid trace backends" \
42915b808275SLluís Vilanova      "Please choose supported trace backends."
429294a420b1SStefan Hajnoczifi
429394a420b1SStefan Hajnoczi
42947e24e92aSStefan Hajnoczi##########################################
42957e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
42965b808275SLluís Vilanovaif have_backend "ust"; then
42977e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4298bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
42997e24e92aSStefan Hajnocziint main(void) { return 0; }
43007e24e92aSStefan HajnocziEOF
43017e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
4302bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
430389138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
43047e24e92aSStefan Hajnoczi    else
4305bf15f63cSMohamad Gebai      lttng_ust_libs="-llttng-ust"
4306bf15f63cSMohamad Gebai    fi
4307bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
430889138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4309bf15f63cSMohamad Gebai    else
4310bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4311bf15f63cSMohamad Gebai    fi
4312bf15f63cSMohamad Gebai
4313bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4314bf15f63cSMohamad Gebai    libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4315bf15f63cSMohamad Gebai  else
4316bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
43177e24e92aSStefan Hajnoczi  fi
43187e24e92aSStefan Hajnoczifi
4319b3d08c02SDaniel P. Berrange
4320b3d08c02SDaniel P. Berrange##########################################
4321b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
43225b808275SLluís Vilanovaif have_backend "dtrace"; then
4323b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
432476ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4325b3d08c02SDaniel P. Berrange  fi
4326c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4327c276b17dSDaniel P. Berrange  if has 'stap' ; then
4328c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
4329c276b17dSDaniel P. Berrange  fi
4330b3d08c02SDaniel P. Berrangefi
4331b3d08c02SDaniel P. Berrange
43327e24e92aSStefan Hajnoczi##########################################
4333519175a2SAlex Barcelo# check and set a backend for coroutine
4334d0e2fce5SAneesh Kumar K.V
43357c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
43367c2acc70SPeter Maydell# is sigcontext. gthread is not selectable except explicitly, because
43377c2acc70SPeter Maydell# it is not functional enough to run QEMU proper. (It is occasionally
43387c2acc70SPeter Maydell# useful for debugging purposes.)  On Windows the only valid backend
43397c2acc70SPeter Maydell# is the Windows-specific one.
43407c2acc70SPeter Maydell
43417c2acc70SPeter Maydellucontext_works=no
4342d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4343d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4344d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4345cdf84806SPeter Maydell#ifdef __stub_makecontext
4346cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4347cdf84806SPeter Maydell#endif
434875cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4349d0e2fce5SAneesh Kumar K.VEOF
4350d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
43517c2acc70SPeter Maydell    ucontext_works=yes
4352d0e2fce5SAneesh Kumar K.V  fi
4353519175a2SAlex Barcelofi
43547c2acc70SPeter Maydell
43557c2acc70SPeter Maydellif test "$coroutine" = ""; then
43567c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
43577c2acc70SPeter Maydell    coroutine=win32
43587c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
43597c2acc70SPeter Maydell    coroutine=ucontext
4360519175a2SAlex Barcelo  else
43617c2acc70SPeter Maydell    coroutine=sigaltstack
43627c2acc70SPeter Maydell  fi
43637c2acc70SPeter Maydellelse
43647c2acc70SPeter Maydell  case $coroutine in
43657c2acc70SPeter Maydell  windows)
43667c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
43677c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
43687c2acc70SPeter Maydell    fi
43697c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
43707c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
43717c2acc70SPeter Maydell    coroutine=win32
43727c2acc70SPeter Maydell    ;;
43737c2acc70SPeter Maydell  ucontext)
43747c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
43757c2acc70SPeter Maydell      feature_not_found "ucontext"
43767c2acc70SPeter Maydell    fi
43777c2acc70SPeter Maydell    ;;
43787c2acc70SPeter Maydell  gthread|sigaltstack)
43797c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
43807c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
43817c2acc70SPeter Maydell    fi
43827c2acc70SPeter Maydell    ;;
43837c2acc70SPeter Maydell  *)
438476ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
43857c2acc70SPeter Maydell    ;;
43867c2acc70SPeter Maydell  esac
4387d0e2fce5SAneesh Kumar K.Vfi
4388d0e2fce5SAneesh Kumar K.V
438970c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
439070c60c08SStefan Hajnoczi  if test "$coroutine" = "gthread"; then
439170c60c08SStefan Hajnoczi    coroutine_pool=no
439270c60c08SStefan Hajnoczi  else
439370c60c08SStefan Hajnoczi    coroutine_pool=yes
439470c60c08SStefan Hajnoczi  fi
439570c60c08SStefan Hajnoczifi
439670c60c08SStefan Hajnocziif test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
439770c60c08SStefan Hajnoczi  error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
439870c60c08SStefan Hajnoczifi
439970c60c08SStefan Hajnoczi
44007d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
44017d992e4dSPeter Lieven  if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
44027d992e4dSPeter Lieven    error_exit "stack usage debugging is not supported for $cpu"
44037d992e4dSPeter Lieven  fi
44047d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
44057d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
44067d992e4dSPeter Lieven    coroutine_pool=no
44077d992e4dSPeter Lieven  fi
44087d992e4dSPeter Lievenfi
44097d992e4dSPeter Lieven
44107d992e4dSPeter Lieven
4411d0e2fce5SAneesh Kumar K.V##########################################
4412d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4413d2042378SAneesh Kumar K.V
44144e1797f9SStefan Weilopen_by_handle_at=no
4415d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4416d2042378SAneesh Kumar K.V#include <fcntl.h>
4417acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4418acc55ba8SStefan Weil# error missing definition
4419acc55ba8SStefan Weil#else
442075cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4421acc55ba8SStefan Weil#endif
4422d2042378SAneesh Kumar K.VEOF
4423d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4424d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4425d2042378SAneesh Kumar K.Vfi
4426d2042378SAneesh Kumar K.V
4427e06a765eSHarsh Prateek Bora########################################
4428e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4429e06a765eSHarsh Prateek Bora
4430e06a765eSHarsh Prateek Boralinux_magic_h=no
4431e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4432e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4433e06a765eSHarsh Prateek Boraint main(void) {
443475cafad7SStefan Weil  return 0;
4435e06a765eSHarsh Prateek Bora}
4436e06a765eSHarsh Prateek BoraEOF
4437e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4438e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4439e06a765eSHarsh Prateek Borafi
4440e06a765eSHarsh Prateek Bora
44418ab1bf12SLuiz Capitulino########################################
4442c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
4443c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
4444c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
4445c95e3080SKevin Wolf# only a warning.
4446c95e3080SKevin Wolf#
4447c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
4448c95e3080SKevin Wolf# the build doesn't fail anyway.
4449c95e3080SKevin Wolf
445006d71fa1SPeter Maydellpragma_disable_unused_but_set=no
445106d71fa1SPeter Maydellcat > $TMPC << EOF
4452e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
445306d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4454c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
4455e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
4456c95e3080SKevin Wolf
445706d71fa1SPeter Maydellint main(void) {
445806d71fa1SPeter Maydell    return 0;
445906d71fa1SPeter Maydell}
446006d71fa1SPeter MaydellEOF
446106d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
4462cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
4463c95e3080SKevin Wolfelse
4464c95e3080SKevin Wolf    werror=no
446506d71fa1SPeter Maydellfi
446606d71fa1SPeter Maydell
446706d71fa1SPeter Maydell########################################
4468541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
44693f4349dcSKevin Wolf
44703f4349dcSKevin Wolfvalgrind_h=no
44713f4349dcSKevin Wolfcat > $TMPC << EOF
44723f4349dcSKevin Wolf#include <valgrind/valgrind.h>
44733f4349dcSKevin Wolfint main(void) {
44743f4349dcSKevin Wolf  return 0;
44753f4349dcSKevin Wolf}
44763f4349dcSKevin WolfEOF
44773f4349dcSKevin Wolfif compile_prog "" "" ; then
44783f4349dcSKevin Wolf    valgrind_h=yes
44793f4349dcSKevin Wolffi
44803f4349dcSKevin Wolf
44813f4349dcSKevin Wolf########################################
44828ab1bf12SLuiz Capitulino# check if environ is declared
44838ab1bf12SLuiz Capitulino
44848ab1bf12SLuiz Capitulinohas_environ=no
44858ab1bf12SLuiz Capitulinocat > $TMPC << EOF
44868ab1bf12SLuiz Capitulino#include <unistd.h>
44878ab1bf12SLuiz Capitulinoint main(void) {
4488c075a723SBlue Swirl    environ = 0;
44898ab1bf12SLuiz Capitulino    return 0;
44908ab1bf12SLuiz Capitulino}
44918ab1bf12SLuiz CapitulinoEOF
44928ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
44938ab1bf12SLuiz Capitulino    has_environ=yes
44948ab1bf12SLuiz Capitulinofi
44958ab1bf12SLuiz Capitulino
449676a347e1SRichard Henderson########################################
449776a347e1SRichard Henderson# check if cpuid.h is usable.
449876a347e1SRichard Henderson
449976a347e1SRichard Hendersoncpuid_h=no
450076a347e1SRichard Hendersoncat > $TMPC << EOF
450176a347e1SRichard Henderson#include <cpuid.h>
450276a347e1SRichard Hendersonint main(void) {
4503774d566cSPeter Maydell    unsigned a, b, c, d;
4504774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4505774d566cSPeter Maydell
4506774d566cSPeter Maydell    if (max >= 1) {
4507774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4508774d566cSPeter Maydell    }
4509774d566cSPeter Maydell
4510774d566cSPeter Maydell    if (max >= 7) {
4511774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4512774d566cSPeter Maydell    }
4513774d566cSPeter Maydell
451476a347e1SRichard Henderson    return 0;
451576a347e1SRichard Henderson}
451676a347e1SRichard HendersonEOF
451776a347e1SRichard Hendersonif compile_prog "" "" ; then
451876a347e1SRichard Henderson    cpuid_h=yes
451976a347e1SRichard Hendersonfi
452076a347e1SRichard Henderson
4521f540166bSRichard Henderson########################################
4522f540166bSRichard Henderson# check if __[u]int128_t is usable.
4523f540166bSRichard Henderson
4524f540166bSRichard Hendersonint128=no
4525f540166bSRichard Hendersoncat > $TMPC << EOF
4526a00f66abSStefan Weil#if defined(__clang_major__) && defined(__clang_minor__)
4527a00f66abSStefan Weil# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4528a00f66abSStefan Weil#  error __int128_t does not work in CLANG before 3.2
4529a00f66abSStefan Weil# endif
4530a00f66abSStefan Weil#endif
4531f540166bSRichard Henderson__int128_t a;
4532f540166bSRichard Henderson__uint128_t b;
4533f540166bSRichard Hendersonint main (void) {
4534f540166bSRichard Henderson  a = a + b;
4535f540166bSRichard Henderson  b = a * b;
4536464e3671SPeter Maydell  a = a * a;
4537f540166bSRichard Henderson  return 0;
4538f540166bSRichard Henderson}
4539f540166bSRichard HendersonEOF
4540f540166bSRichard Hendersonif compile_prog "" "" ; then
4541f540166bSRichard Henderson    int128=yes
4542f540166bSRichard Hendersonfi
454376a347e1SRichard Henderson
45447ebee43eSRichard Henderson#########################################
45457ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
45467ebee43eSRichard Henderson
45477ebee43eSRichard Hendersonatomic128=no
45487ebee43eSRichard Hendersonif test "$int128" = "yes"; then
45497ebee43eSRichard Henderson  cat > $TMPC << EOF
45507ebee43eSRichard Hendersonint main(void)
45517ebee43eSRichard Henderson{
45527ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
45537ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
45547ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
45557ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
45567ebee43eSRichard Henderson  return 0;
45577ebee43eSRichard Henderson}
45587ebee43eSRichard HendersonEOF
45597ebee43eSRichard Henderson  if compile_prog "" "" ; then
45607ebee43eSRichard Henderson    atomic128=yes
45617ebee43eSRichard Henderson  fi
45627ebee43eSRichard Hendersonfi
45637ebee43eSRichard Henderson
4564df79b996SRichard Henderson#########################################
4565df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4566df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4567df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4568df79b996SRichard Henderson
4569df79b996SRichard Hendersoncat > $TMPC << EOF
4570df79b996SRichard Henderson#include <stdint.h>
4571df79b996SRichard Hendersonint main(void)
4572df79b996SRichard Henderson{
4573df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4574df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
4575df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
4576df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
4577df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4578df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
4579df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
4580df79b996SRichard Henderson#else
4581df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4582df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4583df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4584df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4585df79b996SRichard Henderson#endif
4586df79b996SRichard Henderson  return 0;
4587df79b996SRichard Henderson}
4588df79b996SRichard HendersonEOF
4589df79b996SRichard Hendersonif compile_prog "" "" ; then
4590df79b996SRichard Henderson  atomic64=yes
4591df79b996SRichard Hendersonfi
4592df79b996SRichard Henderson
45931e6e9acaSRichard Henderson########################################
45941e6e9acaSRichard Henderson# check if getauxval is available.
45951e6e9acaSRichard Henderson
45961e6e9acaSRichard Hendersongetauxval=no
45971e6e9acaSRichard Hendersoncat > $TMPC << EOF
45981e6e9acaSRichard Henderson#include <sys/auxv.h>
45991e6e9acaSRichard Hendersonint main(void) {
46001e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
46011e6e9acaSRichard Henderson}
46021e6e9acaSRichard HendersonEOF
46031e6e9acaSRichard Hendersonif compile_prog "" "" ; then
46041e6e9acaSRichard Henderson    getauxval=yes
46051e6e9acaSRichard Hendersonfi
46061e6e9acaSRichard Henderson
4607fd0e6053SJohn Snow########################################
4608fd0e6053SJohn Snow# check if ccache is interfering with
4609fd0e6053SJohn Snow# semantic analysis of macros
4610fd0e6053SJohn Snow
46115e4dfd3dSJohn Snowunset CCACHE_CPP2
4612fd0e6053SJohn Snowccache_cpp2=no
4613fd0e6053SJohn Snowcat > $TMPC << EOF
4614fd0e6053SJohn Snowstatic const int Z = 1;
4615fd0e6053SJohn Snow#define fn() ({ Z; })
4616fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4617fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4618fd0e6053SJohn Snow#define ID(X) (X)
4619fd0e6053SJohn Snowint main(int argc, char *argv[])
4620fd0e6053SJohn Snow{
4621fd0e6053SJohn Snow    int x = 0, y = 0;
4622fd0e6053SJohn Snow    x = ID(x);
4623fd0e6053SJohn Snow    x = fn();
4624fd0e6053SJohn Snow    fn();
4625fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4626fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4627fd0e6053SJohn Snow    return 0;
4628fd0e6053SJohn Snow}
4629fd0e6053SJohn SnowEOF
4630fd0e6053SJohn Snow
4631fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4632fd0e6053SJohn Snow    ccache_cpp2=yes
4633fd0e6053SJohn Snowfi
4634fd0e6053SJohn Snow
4635b553a042SJohn Snow#################################################
4636b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4637b553a042SJohn Snow
4638b553a042SJohn Snowif test "$fortify_source" != "no"; then
4639b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4640b553a042SJohn Snow    fortify_source="no";
4641cfcc7c14SJohn Snow  elif test -n "$cxx" &&
4642cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4643b553a042SJohn Snow    fortify_source="no";
4644b553a042SJohn Snow  else
4645b553a042SJohn Snow    fortify_source="yes"
4646b553a042SJohn Snow  fi
4647b553a042SJohn Snowfi
4648b553a042SJohn Snow
4649d2042378SAneesh Kumar K.V##########################################
4650277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4651277abf15SJan Vesely
4652277abf15SJan Veselyhave_fsxattr=no
4653277abf15SJan Veselycat > $TMPC << EOF
4654277abf15SJan Vesely#include <linux/fs.h>
4655277abf15SJan Veselystruct fsxattr foo;
4656277abf15SJan Veselyint main(void) {
4657277abf15SJan Vesely  return 0;
4658277abf15SJan Vesely}
4659277abf15SJan VeselyEOF
4660277abf15SJan Veselyif compile_prog "" "" ; then
4661277abf15SJan Vesely    have_fsxattr=yes
4662277abf15SJan Veselyfi
4663277abf15SJan Vesely
4664b66e10e4SPeter Maydell##########################################
4665b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
4666575b22b1SLaurent Vivierhave_rtnetlink=no
4667575b22b1SLaurent Viviercat > $TMPC << EOF
4668575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
4669575b22b1SLaurent Vivierint main(void) {
4670575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
4671575b22b1SLaurent Vivier}
4672575b22b1SLaurent VivierEOF
4673575b22b1SLaurent Vivierif compile_prog "" "" ; then
4674575b22b1SLaurent Vivier    have_rtnetlink=yes
4675575b22b1SLaurent Vivierfi
4676575b22b1SLaurent Vivier
46776969ec6cSJames Clarke#################################################
46786969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
46796969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
46806969ec6cSJames Clarke# given. It does no harm to give it on other
46816969ec6cSJames Clarke# platforms too.
46826969ec6cSJames Clarke
46836969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
46846969ec6cSJames Clarke#       contains -Wmissing-prototypes
46856969ec6cSJames Clarkecat > $TMPC << EOF
46866969ec6cSJames Clarkeextern int foo(void);
46876969ec6cSJames Clarkeint foo(void) { return 0; }
46886969ec6cSJames ClarkeEOF
46896969ec6cSJames Clarkeif ! compile_object ""; then
46906969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
46916969ec6cSJames Clarkefi
46926969ec6cSJames Clarkeif do_cc -nostdlib -Wl,-r -Wl,--no-relax -o $TMPMO $TMPO; then
46936969ec6cSJames Clarke  LD_REL_FLAGS="-Wl,--no-relax"
46946969ec6cSJames Clarkefi
46956969ec6cSJames Clarke
4696277abf15SJan Vesely##########################################
4697e86ecd4bSJuan Quintela# End of CC checks
4698e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4699e86ecd4bSJuan Quintela
47001d728c39SBlue Swirlif test "$gcov" = "yes" ; then
47011d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
47021d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4703b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
4704e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4705ce278618SPeter Maydellelif test "$debug" = "no"; then
4706ce278618SPeter Maydell  CFLAGS="-O2 $CFLAGS"
4707e86ecd4bSJuan Quintelafi
4708a316e378SJuan Quintela
47096542aa9cSPeter Lieven##########################################
47106542aa9cSPeter Lieven# Do we have libnfs
47116542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
4712b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
47136542aa9cSPeter Lieven    libnfs="yes"
47146542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
47156542aa9cSPeter Lieven  else
47166542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
47178efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
47186542aa9cSPeter Lieven    fi
47196542aa9cSPeter Lieven    libnfs="no"
47206542aa9cSPeter Lieven  fi
47216542aa9cSPeter Lievenfi
47221d728c39SBlue Swirl
47236ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
47246ca026cbSPeter Maydellif test "$werror" = "yes"; then
47256ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
47266ca026cbSPeter Maydellfi
47276ca026cbSPeter Maydell
4728e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
4729e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
47301156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
4731e86ecd4bSJuan Quintela    fi
4732e86ecd4bSJuan Quintelafi
4733e86ecd4bSJuan Quintela
473494dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
473594dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
473694dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
473794dd53c5SGerd Hoffmannelse
473894dd53c5SGerd Hoffmann    POD2MAN="pod2man"
473994dd53c5SGerd Hoffmannfi
474094dd53c5SGerd Hoffmann
4741952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
4742952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
4743952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
4744952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4745952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
4746952afb71SBlue Swirl        fi
4747952afb71SBlue Swirl    done
4748952afb71SBlue Swirlfi
4749952afb71SBlue Swirl
475010ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
4751e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
4752528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
4753834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
47545a67135aSbellard
47554b1c11fdSDaniel P. Berrangetools=""
47564b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
4757ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
47584b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
47594b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
4760a75eb03bSDavid Marchand    tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
47614b1c11fdSDaniel P. Berrange  fi
47624b1c11fdSDaniel P. Berrangefi
47634b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
4764983eef5aSMeador Inge  if test "$virtfs" != no ; then
4765be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4766983eef5aSMeador Inge      virtfs=yes
476717bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4768983eef5aSMeador Inge    else
4769983eef5aSMeador Inge      if test "$virtfs" = yes; then
47703f3b5388SStefan Weil        error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
4771983eef5aSMeador Inge      fi
477217500370SAndreas Färber      virtfs=no
4773983eef5aSMeador Inge    fi
477417bff52bSM. Mohan Kumar  fi
4775d138cee9SMichael Rothfi
47769d6bc27bSMichael Roth
47779d6bc27bSMichael Roth# Probe for guest agent support/options
47789d6bc27bSMichael Roth
4779e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
4780b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4781fafcaf1dSMichael Roth      tools="qemu-ga $tools"
4782e8ef31a3SMichael Tokarev      guest_agent=yes
4783e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
4784e8ef31a3SMichael Tokarev      guest_agent=no
4785e8ef31a3SMichael Tokarev  else
4786e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
4787ca35f780SPaolo Bonzini  fi
47884b1c11fdSDaniel P. Berrangefi
4789ca35f780SPaolo Bonzini
47909d6bc27bSMichael Roth# Guest agent Window MSI  package
47919d6bc27bSMichael Roth
47929d6bc27bSMichael Rothif test "$guest_agent" != yes; then
47939d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
47949d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
47959d6bc27bSMichael Roth  fi
47969d6bc27bSMichael Roth  guest_agent_msi=no
47979d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
47989d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
47999d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
48009d6bc27bSMichael Roth  fi
48019d6bc27bSMichael Roth  guest_agent_msi=no
48029d6bc27bSMichael Rothelif ! has wixl; then
48039d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
48049d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
48059d6bc27bSMichael Roth  fi
48069d6bc27bSMichael Roth  guest_agent_msi=no
48071a34904eSMichael Rothelse
48081a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
48091a34904eSMichael Roth  # disabled explicitly
48101a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
48111a34904eSMichael Roth    guest_agent_msi=yes
48121a34904eSMichael Roth  fi
48139d6bc27bSMichael Rothfi
48149d6bc27bSMichael Roth
48151a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
48169d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
48179d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
48189d6bc27bSMichael Roth  fi
48199d6bc27bSMichael Roth
48209d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
48219d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
48229d6bc27bSMichael Roth  fi
48239d6bc27bSMichael Roth
48249d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
48259d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
48269d6bc27bSMichael Roth  fi
48279d6bc27bSMichael Roth
48289d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
482989138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
48309d6bc27bSMichael Roth  fi
48319d6bc27bSMichael Roth
483289138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
48339d6bc27bSMichael Roth
48349d6bc27bSMichael Roth  case "$cpu" in
48359d6bc27bSMichael Roth  x86_64)
48369d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
48379d6bc27bSMichael Roth    ;;
48389d6bc27bSMichael Roth  i386)
48399d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
48409d6bc27bSMichael Roth    ;;
48419d6bc27bSMichael Roth  *)
48429d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
48439d6bc27bSMichael Roth    ;;
48449d6bc27bSMichael Roth  esac
48459d6bc27bSMichael Rothfi
48469d6bc27bSMichael Roth
4847ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
4848ca35f780SPaolo Bonziniroms=
4849ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
4850ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
4851ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
4852e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
4853e57218b6SPeter Maydell    # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
4854e57218b6SPeter Maydell    # variant; and Windows uses i386pe.
4855e57218b6SPeter Maydell    for emu in elf_i386 elf_i386_fbsd i386pe; do
4856e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
4857e57218b6SPeter Maydell            ld_i386_emulation="$emu"
4858ca35f780SPaolo Bonzini            roms="optionrom"
4859e57218b6SPeter Maydell            break
4860e57218b6SPeter Maydell        fi
4861e57218b6SPeter Maydell    done
4862ca35f780SPaolo Bonzinifi
4863d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
486439ac8455SDavid Gibson  roms="$roms spapr-rtas"
486539ac8455SDavid Gibsonfi
4866ca35f780SPaolo Bonzini
48679933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
48689933c305SChristian Borntraeger  roms="$roms s390-ccw"
48699933c305SChristian Borntraegerfi
48709933c305SChristian Borntraeger
4871964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
487292fe2ba8SPeter Maydellif ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
4873964c6fa1SRichard Henderson  textseg_addr=
4874964c6fa1SRichard Henderson  case "$cpu" in
4875479eb121SRichard Henderson    arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
4876479eb121SRichard Henderson      # ??? Rationale for choosing this address
4877964c6fa1SRichard Henderson      textseg_addr=0x60000000
4878964c6fa1SRichard Henderson      ;;
4879964c6fa1SRichard Henderson    mips)
4880479eb121SRichard Henderson      # A 256M aligned address, high in the address space, with enough
4881479eb121SRichard Henderson      # room for the code_gen_buffer above it before the stack.
4882479eb121SRichard Henderson      textseg_addr=0x60000000
4883964c6fa1SRichard Henderson      ;;
4884964c6fa1SRichard Henderson  esac
4885964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
4886964c6fa1SRichard Henderson    cat > $TMPC <<EOF
4887964c6fa1SRichard Henderson    int main(void) { return 0; }
4888964c6fa1SRichard HendersonEOF
4889964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
4890964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
4891964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
4892964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
4893964c6fa1SRichard Henderson      # at least.
489492fe2ba8SPeter Maydell      if ! $ld --verbose >/dev/null 2>&1; then
489592fe2ba8SPeter Maydell        error_exit \
489692fe2ba8SPeter Maydell            "We need to link the QEMU user mode binaries at a" \
489792fe2ba8SPeter Maydell            "specific text address. Unfortunately your linker" \
489892fe2ba8SPeter Maydell            "doesn't support either the -Ttext-segment option or" \
489992fe2ba8SPeter Maydell            "printing the default linker script with --verbose." \
490092fe2ba8SPeter Maydell            "If you don't want the user mode binaries, pass the" \
490192fe2ba8SPeter Maydell            "--disable-user option to configure."
490292fe2ba8SPeter Maydell      fi
490392fe2ba8SPeter Maydell
4904964c6fa1SRichard Henderson      $ld --verbose | sed \
4905964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
4906964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
4907964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
4908964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
4909964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
4910964c6fa1SRichard Henderson    fi
4911964c6fa1SRichard Henderson  fi
4912964c6fa1SRichard Hendersonfi
4913964c6fa1SRichard Henderson
491402d34f62SCole Robinsonecho_version() {
491502d34f62SCole Robinson    if test "$1" = "yes" ; then
491602d34f62SCole Robinson        echo "($2)"
491702d34f62SCole Robinson    fi
491802d34f62SCole Robinson}
491902d34f62SCole Robinson
492050e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
492150e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
492250e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
49235ca9388aSGerd Hoffmann
49247d13299dSbellardecho "Install prefix    $prefix"
492589138857SStefan Weilecho "BIOS directory    $(eval echo $qemu_datadir)"
492689138857SStefan Weilecho "binary directory  $(eval echo $bindir)"
492789138857SStefan Weilecho "library directory $(eval echo $libdir)"
492889138857SStefan Weilecho "module directory  $(eval echo $qemu_moddir)"
492989138857SStefan Weilecho "libexec directory $(eval echo $libexecdir)"
493089138857SStefan Weilecho "include directory $(eval echo $includedir)"
493189138857SStefan Weilecho "config directory  $(eval echo $sysconfdir)"
493211d9f695Sbellardif test "$mingw32" = "no" ; then
493389138857SStefan Weilecho "local state directory   $(eval echo $local_statedir)"
493489138857SStefan Weilecho "Manual directory  $(eval echo $mandir)"
493543ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
49365a699bbbSLaszlo Ersekelse
49375a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
4938d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
493911d9f695Sbellardfi
49405a67135aSbellardecho "Source path       $source_path"
49417d13299dSbellardecho "C compiler        $cc"
494283469015Sbellardecho "Host C compiler   $host_cc"
494383f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
49443c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
494545d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
49460c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
4947a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
49480c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
49497d13299dSbellardecho "make              $make"
49506a882643Spbrookecho "install           $install"
4951c886edfbSBlue Swirlecho "python            $python"
4952e2d8830eSBradif test "$slirp" = "yes" ; then
4953e2d8830eSBrad    echo "smbd              $smbd"
4954e2d8830eSBradfi
495517969268SFam Zhengecho "module support    $modules"
4956a98fd896Sbellardecho "host CPU          $cpu"
4957de83cd02Sbellardecho "host big endian   $bigendian"
495897a847bcSbellardecho "target list       $target_list"
4959ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
49607d13299dSbellardecho "gprof enabled     $gprof"
496103b4fe7dSaliguoriecho "sparse enabled    $sparse"
49621625af87Saliguoriecho "strip binaries    $strip_opt"
496305c2a3e7Sbellardecho "profiler          $profiler"
496443ce4dfeSbellardecho "static build      $static"
49655b0753e0Sbellardif test "$darwin" = "yes" ; then
49665b0753e0Sbellard    echo "Cocoa support     $cocoa"
49675b0753e0Sbellardfi
4968e2134eb9SGerd Hoffmannecho "pixman            $pixman"
496989138857SStefan Weilecho "SDL support       $sdl $(echo_version $sdl $sdlversion)"
497089138857SStefan Weilecho "GTK support       $gtk $(echo_version $gtk $gtk_version)"
4971925a0400SGerd Hoffmannecho "GTK GL support    $gtk_gl"
497289138857SStefan Weilecho "VTE support       $vte $(echo_version $vte $vteversion)"
4973a1c5e949SDaniel P. Berrangeecho "TLS priority      $tls_priority"
4974ddbb0d09SDaniel P. Berrangeecho "GNUTLS support    $gnutls"
4975b917da4cSDaniel P. Berrangeecho "GNUTLS rnd        $gnutls_rnd"
497691bfcdb0SDaniel P. Berrangeecho "libgcrypt         $gcrypt"
497737788f25SDaniel P. Berrangeecho "libgcrypt kdf     $gcrypt_kdf"
497889138857SStefan Weilecho "nettle            $nettle $(echo_version $nettle $nettle_version)"
4979fff2f982SDaniel P. Berrangeecho "nettle kdf        $nettle_kdf"
49809a2fd434SDaniel P. Berrangeecho "libtasn1          $tasn1"
49814d3b6f6eSbalrogecho "curses support    $curses"
49829d9e1521SGerd Hoffmannecho "virgl support     $virglrenderer"
4983769ce76dSAlexander Grafecho "curl support      $curl"
498467b915a5Sbellardecho "mingw32 support   $mingw32"
49850c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
4986b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
4987b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
4988983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
4989821601eaSJes Sorensenecho "VNC support       $vnc"
4990821601eaSJes Sorensenif test "$vnc" = "yes" ; then
49912f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
49922f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
4993efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
4994821601eaSJes Sorensenfi
49953142255cSblueswir1if test -n "$sparc_cpu"; then
49963142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
49973142255cSblueswir1fi
4998e37630caSaliguoriecho "xen support       $xen"
49993996e85cSPaul Durrantif test "$xen" = "yes" ; then
50003996e85cSPaul Durrant  echo "xen ctrl version  $xen_ctrl_version"
500164a7ad6fSIan Campbell  echo "pv dom build      $xen_pv_domain_build"
50023996e85cSPaul Durrantfi
50032e4d9fb1Saurel32echo "brlapi support    $brlapi"
5004a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
5005a25dba17SJuan Quintelaecho "Documentation     $docs"
500640d6444eSAvi Kivityecho "PIE               $pie"
50078a16d273Sthsecho "vde support       $vde"
500858952137SVincenzo Maffioneecho "netmap support    $netmap"
50095c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
5010758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
501177755340Sthsecho "Install blobs     $blobs"
5012b31a0277SJuan Quintelaecho "KVM support       $kvm"
5013*180fb750Szhanghailiangecho "COLO support      $colo"
50142da776dbSMichael R. Hinesecho "RDMA support      $rdma"
50159195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
5016f652e6afSaurel32echo "fdt support       $fdt"
5017ceb42de8Saliguoriecho "preadv support    $preadv"
50185f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
5019e78815a5SAndreas Färberecho "madvise           $madvise"
5020e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
502147e98658SCorey Bryantecho "libcap-ng support $cap_ng"
5022d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
50235e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
5024fc0b9b0eSStefan Hajnocziecho "vhost-vsock support $vhost_vsock"
50255b808275SLluís Vilanovaecho "Trace backends    $trace_backends"
5026713572a7SMarc-André Lureauif have_backend "simple"; then
50279410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
5028e00e36fbSStefan Weilfi
502989138857SStefan Weilecho "spice support     $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5030f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
5031dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
50327b02f544SMarc-André Lureauecho "smartcard support $smartcard"
50332b2325ffSGerd Hoffmannecho "libusb            $libusb"
503469354a83SHans de Goedeecho "usb net redir     $usb_redir"
5035da076ffeSGerd Hoffmannecho "OpenGL support    $opengl"
5036014cb152SGerd Hoffmannecho "OpenGL dmabufs    $opengl_dmabuf"
5037c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
50386542aa9cSPeter Lievenecho "libnfs support    $libnfs"
5039d138cee9SMichael Rothecho "build guest agent $guest_agent"
5040d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
504150cbebb9SMichael Rothecho "QGA w32 disk info $guest_agent_ntddscsi"
50424c875d89SMichael Rothecho "QGA MSI support   $guest_agent_msi"
5043f794573eSEduardo Otuboecho "seccomp support   $seccomp"
50447c2acc70SPeter Maydellecho "coroutine backend $coroutine"
504570c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
50467d992e4dSPeter Lievenecho "debug stack usage $debug_stack_usage"
5047eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
5048c9a12e75SChrysostomos Nanakosecho "Archipelago support $archipelago"
50491d728c39SBlue Swirlecho "gcov              $gcov_tool"
50501d728c39SBlue Swirlecho "gcov enabled      $gcov"
5051ab214c29SStefan Bergerecho "TPM support       $tpm"
50520a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
50533b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
50543556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
5055607dacd0Sqiaonuohanecho "lzo support       $lzo"
5056607dacd0Sqiaonuohanecho "snappy support    $snappy"
50576b383c08SPeter Wuecho "bzip2 support     $bzip2"
5058a99d57bbSWanlong Gaoecho "NUMA host support $numa"
50592847b469SFam Zhengecho "tcmalloc support  $tcmalloc"
50607b01cb97SAlexandre Derumierecho "jemalloc support  $jemalloc"
506199f2dbd3SLiang Liecho "avx2 optimization $avx2_opt"
5062a6b1d4c0SChanglong Xieecho "replication support $replication"
506367b915a5Sbellard
50641ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
506524b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
5066e8cd23deSbellardfi
506797a847bcSbellard
506898ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
506997a847bcSbellard
5070dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
5071dbd99ae3SStefan Weil
507298ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
507398ec69acSJuan Quintelaecho >> $config_host_mak
507498ec69acSJuan Quintela
5075e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
507699d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
507799d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
50783aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
50798bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
50800f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
508199d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
508299d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
508322d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
50849afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
50859afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
5086e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
50875a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
5088785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
50895a699bbbSLaszlo Ersekfi
5090f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
5091f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
5092f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5093834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
5094f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
5095804edf29SJuan Quintela
509698ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5097727e5283SPaolo Bonzini
5098f8393946Saurel32if test "$debug_tcg" = "yes" ; then
50992358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5100f8393946Saurel32fi
51011625af87Saliguoriif test "$strip_opt" = "yes" ; then
510252ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
51031625af87Saliguorifi
51047d13299dSbellardif test "$bigendian" = "yes" ; then
5105e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
510697a847bcSbellardfi
510767b915a5Sbellardif test "$mingw32" = "yes" ; then
510898ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
510989138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
51109fe6de94SBlue Swirl  version_major=${rc_version%%.*}
51119fe6de94SBlue Swirl  rc_version=${rc_version#*.}
51129fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
51139fe6de94SBlue Swirl  rc_version=${rc_version#*.}
51149fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
51159fe6de94SBlue Swirl  version_micro=0
51169fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
51179fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5118d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5119d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5120f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5121d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5122d9840e25STomoki Sekiyama  fi
512350cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
512450cbebb9SMichael Roth    echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
512550cbebb9SMichael Roth  fi
51261a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
51279dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
51289dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
51299dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
51309dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
51319dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
51329dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
51339dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
51349dacf32dSYossi Hindin  fi
5135210fa556Spbrookelse
513635f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5137210fa556Spbrookfi
5138128ab2ffSblueswir1
5139dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5140dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5141dffcb71cSMark McLoughlinfi
5142dffcb71cSMark McLoughlin
514383fb7adfSbellardif test "$darwin" = "yes" ; then
514498ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
514583fb7adfSbellardfi
5146b29fe3edSmalc
5147b29fe3edSmalcif test "$aix" = "yes" ; then
514898ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
5149b29fe3edSmalcfi
5150b29fe3edSmalc
5151ec530c81Sbellardif test "$solaris" = "yes" ; then
515298ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
51532358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
51540475a5caSths  if test "$needs_libsunmath" = "yes" ; then
515575b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
51560475a5caSths  fi
5157ec530c81Sbellardfi
5158179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5159179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5160179cf400SAndreas Färberfi
516197a847bcSbellardif test "$static" = "yes" ; then
516298ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
516397a847bcSbellardfi
51641ba16968SStefan Weilif test "$profiler" = "yes" ; then
51652358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
516605c2a3e7Sbellardfi
5167c20709aaSbellardif test "$slirp" = "yes" ; then
516898ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
5169e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5170c20709aaSbellardfi
51718a16d273Sthsif test "$vde" = "yes" ; then
517298ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
51738a16d273Sthsfi
517458952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
517558952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
517658952137SVincenzo Maffionefi
5177015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5178015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5179015a33bdSGongleifi
518047e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
518147e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
518247e98658SCorey Bryantfi
51832358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
51840c58ac1cSmalcfor drv in $audio_drv_list; do
518589138857SStefan Weil    def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
518698ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
51870c58ac1cSmalcdone
518867f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
518967f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
519067f86e8eSJuan Quintelafi
5191d5631638Smalcif test "$audio_win_int" = "yes" ; then
5192d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5193d5631638Smalcfi
5194b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5195b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5196821601eaSJes Sorensenif test "$vnc" = "yes" ; then
5197821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
5198821601eaSJes Sorensenfi
51992f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
520098ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
52012f9606b3Saliguorifi
5202821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
52032f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
52042f6f5c7aSCorentin Charyfi
5205821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
5206efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5207efe556adSCorentin Charyfi
520876655d6dSaliguoriif test "$fnmatch" = "yes" ; then
52092358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
521076655d6dSaliguorifi
5211dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5212dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5213dce512deSChristoph Hellwigfi
521489138857SStefan Weilqemu_version=$(head $source_path/VERSION)
521598ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
52162358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
521798ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
521898ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
5219a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
522098ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
5221cc8ae6deSpbrookfi
522217969268SFam Zhengif test "$modules" = "yes"; then
5223e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5224e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
522589138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
522617969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
522717969268SFam Zhengfi
52281ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
522998ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
5230a3f4d63dSCole Robinson  echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
52318ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
523249ecc3faSbellardfi
523349ecc3faSbellardif test "$cocoa" = "yes" ; then
523498ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
523549ecc3faSbellardfi
52364d3b6f6eSbalrogif test "$curses" = "yes" ; then
523798ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
5238ab4e5602SJan Kiszkafi
5239ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
52402358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
5241ebc996f3SRiku Voipiofi
5242099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
52432358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5244099d6b0fSRiku Voipiofi
524540ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
524640ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
524740ff6d7eSKevin Wolffi
52483ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
52492358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
52503ce34dfbSvibisreenivasanfi
5251c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5252c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5253c2882b96SRiku Voipiofi
5254751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5255751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5256751bcc39SMarc-André Lureaufi
5257d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5258d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5259d0927938SUlrich Hechtfi
52603d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
52613d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
52623d4fa43eSKusanagi Kouichifi
5263b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5264b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5265b953f075SDenis V. Lunevfi
5266ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5267ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5268ed911435SKevin Wolffi
5269c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5270c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5271c727f47dSPeter Maydellfi
5272dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5273dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5274dace20dcSPeter Maydellfi
5275d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5276d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5277d0927938SUlrich Hechtfi
52784e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
52794e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
52804e0c6529SAlex Blighfi
5281cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5282cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5283cd758dd0SAlex Blighfi
52843b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
52853b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
52863b6edd16SPeter Maydellfi
52873b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
52883b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
52893b6edd16SPeter Maydellfi
5290a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5291a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5292a8fd1abaSPeter Maydellfi
529351834341SRiku Voipioif test "$timerfd" = "yes" ; then
529451834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
529551834341SRiku Voipiofi
52969af5c906SRiku Voipioif test "$setns" = "yes" ; then
52979af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
52989af5c906SRiku Voipiofi
529938860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
530038860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
530138860a03SAleksandar Markovicfi
53025a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
53035a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
53045a03cd00SAleksandar Markovicfi
53053b3f24adSaurel32if test "$inotify" = "yes" ; then
53062358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
53073b3f24adSaurel32fi
5308c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5309c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5310c05c7a73SRiku Voipiofi
53116ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
53126ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
53136ae9a1f4SJuan Quintelafi
53146ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
53156ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
53166ae9a1f4SJuan Quintelafi
5317769ce76dSAlexander Grafif test "$curl" = "yes" ; then
5318d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
5319b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
53206ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5321769ce76dSAlexander Graffi
53222e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
532398ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
53242e4d9fb1Saurel32fi
5325fb599c9aSbalrogif test "$bluez" = "yes" ; then
532698ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
5327ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5328fb599c9aSbalrogfi
5329d46f7c9eSDr. David Alan Gilbertif test "$glib_subprocess" = "yes" ; then
53309d41401bSMichael S. Tsirkin  echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
53319d41401bSMichael S. Tsirkinfi
5332a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
5333a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
5334a3f4d63dSCole Robinson  echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5335a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5336014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5337925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
5338925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
5339925a0400SGerd Hoffmann  fi
5340bbbf9bfbSStefan Weilfi
5341a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5342ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5343ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5344ddbb0d09SDaniel P. Berrangefi
5345b917da4cSDaniel P. Berrangeif test "$gnutls_rnd" = "yes" ; then
5346b917da4cSDaniel P. Berrange  echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5347b917da4cSDaniel P. Berrangefi
534891bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
534991bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
535037788f25SDaniel P. Berrange  if test "$gcrypt_kdf" = "yes" ; then
535137788f25SDaniel P. Berrange    echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
535237788f25SDaniel P. Berrange  fi
535362893b67SDaniel P. Berrangefi
535491bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
535591bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5356becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5357fff2f982SDaniel P. Berrange  if test "$nettle_kdf" = "yes" ; then
5358fff2f982SDaniel P. Berrange    echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5359fff2f982SDaniel P. Berrange  fi
5360ed754746SDaniel P. Berrangefi
53619a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
53629a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
53639a2fd434SDaniel P. Berrangefi
5364559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
5365559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5366559607eaSDaniel P. Berrangefi
53676b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
53686b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
53696b39b063SEric Blakefi
5370277abf15SJan Vesely
5371277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5372277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5373277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5374277abf15SJan Vesely# if this macro is set.
5375277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5376277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5377277abf15SJan Veselyfi
5378bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5379bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5380a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5381a4ccabcfSAnthony Liguorifi
53829d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
53839d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
53849d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
53859d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
53869d9e1521SGerd Hoffmannfi
5387e37630caSaliguoriif test "$xen" = "yes" ; then
53886dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5389d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
539064a7ad6fSIan Campbell  if test "$xen_pv_domain_build" = "yes" ; then
539164a7ad6fSIan Campbell    echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
539264a7ad6fSIan Campbell  fi
5393e37630caSaliguorifi
53945c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
53955c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
53965c6c3a6cSChristoph Hellwigfi
5397758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
5398758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
5399758e8e38SVenkateswararao Jujjuri (JV)fi
54004f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
54014f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
54024f26f2b6SAvi Kivityfi
5403983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
5404758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
5405758e8e38SVenkateswararao Jujjuri (JV)fi
54065e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
54075e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
54085e9be92dSNicholas Bellingerfi
540903ce5744SNikolay Nikolaevif test "$vhost_net" = "yes" ; then
541003ce5744SNikolay Nikolaev  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
541103ce5744SNikolay Nikolaevfi
5412fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
5413fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5414fc0b9b0eSStefan Hajnoczifi
541577755340Sthsif test "$blobs" = "yes" ; then
541698ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
541777755340Sthsfi
5418bf9298b9Saliguoriif test "$iovec" = "yes" ; then
54192358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5420bf9298b9Saliguorifi
5421ceb42de8Saliguoriif test "$preadv" = "yes" ; then
54222358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
5423ceb42de8Saliguorifi
5424f652e6afSaurel32if test "$fdt" = "yes" ; then
54253f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
5426f652e6afSaurel32fi
5427dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5428dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5429dcc38d1cSMarcelo Tosattifi
54309195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
54319195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
54329195b2c2SStefan Weilfi
54335f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
54345f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
54355f6b9e8fSBlue Swirlfi
5436e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5437e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5438e78815a5SAndreas Färberfi
5439e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5440e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5441e78815a5SAndreas Färberfi
544297a847bcSbellard
5443cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5444cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
5445cd4ec0b4SGerd Hoffmannfi
5446cd4ec0b4SGerd Hoffmann
54477b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
54487b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
5449111a38b0SRobert Relyeafi
5450111a38b0SRobert Relyea
54512b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
54522b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
54532b2325ffSGerd Hoffmannfi
54542b2325ffSGerd Hoffmann
545569354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
545669354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
545769354a83SHans de Goedefi
545869354a83SHans de Goede
5459da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5460da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5461f676c67eSJeremy White  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
5462da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5463014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
5464014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5465014cb152SGerd Hoffmann  fi
546620ff075bSMichael Wallefi
546720ff075bSMichael Walle
546899f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
546999f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
547099f2dbd3SLiang Lifi
547199f2dbd3SLiang Li
5472607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
5473607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
5474607dacd0Sqiaonuohanfi
5475607dacd0Sqiaonuohan
5476607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
5477607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
5478607dacd0Sqiaonuohanfi
5479607dacd0Sqiaonuohan
54806b383c08SPeter Wuif test "$bzip2" = "yes" ; then
54816b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
54826b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
54836b383c08SPeter Wufi
54846b383c08SPeter Wu
5485c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
5486d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
54876ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
54886ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5489c589b249SRonnie Sahlbergfi
5490c589b249SRonnie Sahlberg
54916542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
54924be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
54934be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
54946542aa9cSPeter Lievenfi
54956542aa9cSPeter Lieven
5496f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
5497f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
5498f794573eSEduardo Otubofi
5499f794573eSEduardo Otubo
550083fb7adfSbellard# XXX: suppress that
55017d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
55022358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
55037d3505c5Sbellardfi
55047d3505c5Sbellard
55054d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
55064d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
55074d9310f4SDaniel P. Berrangefi
55083556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
55093556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
55103556c233SPaolo Bonzinifi
5511f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
5512d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
55136ebc91e5SFam Zheng  echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
55146ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5515f27aaf4bSChristian Brunnerfi
551620ff6c80SAnthony Liguori
55177c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
551870c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
551970c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
552070c60c08SStefan Hajnoczielse
552170c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
552270c60c08SStefan Hajnoczifi
5523d0e2fce5SAneesh Kumar K.V
55247d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
55257d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
55267d992e4dSPeter Lievenfi
55277d992e4dSPeter Lieven
5528d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5529d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5530d2042378SAneesh Kumar K.Vfi
5531d2042378SAneesh Kumar K.V
5532e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5533e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5534e06a765eSHarsh Prateek Borafi
5535e06a765eSHarsh Prateek Bora
5536cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
5537cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
553806d71fa1SPeter Maydellfi
553906d71fa1SPeter Maydell
55403f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
55413f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
55423f4349dcSKevin Wolffi
55433f4349dcSKevin Wolf
55448ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
55458ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
55468ab1bf12SLuiz Capitulinofi
55478ab1bf12SLuiz Capitulino
554876a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
554976a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
555076a347e1SRichard Hendersonfi
555176a347e1SRichard Henderson
5552f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5553f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5554f540166bSRichard Hendersonfi
5555f540166bSRichard Henderson
55567ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
55577ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
55587ebee43eSRichard Hendersonfi
55597ebee43eSRichard Henderson
5560df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
5561df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5562df79b996SRichard Hendersonfi
5563df79b996SRichard Henderson
55641e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
55651e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
55661e6e9acaSRichard Hendersonfi
55671e6e9acaSRichard Henderson
5568eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
5569d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
55706ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
55716ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5572eb100396SBharata B Raofi
5573eb100396SBharata B Rao
5574d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
5575d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5576d85fa9ebSJeff Codyfi
5577d85fa9ebSJeff Cody
55780c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
55790c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
55800c14fb47SBharata B Raofi
55810c14fb47SBharata B Rao
55827c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
55837c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
55847c815372SBharata B Raofi
55857c815372SBharata B Rao
5586c9a12e75SChrysostomos Nanakosif test "$archipelago" = "yes" ; then
5587c9a12e75SChrysostomos Nanakos  echo "CONFIG_ARCHIPELAGO=m" >> $config_host_mak
5588c9a12e75SChrysostomos Nanakos  echo "ARCHIPELAGO_LIBS=$archipelago_libs" >> $config_host_mak
5589c9a12e75SChrysostomos Nanakosfi
5590c9a12e75SChrysostomos Nanakos
55910a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
5592d3399d7cSFam Zheng  echo "CONFIG_LIBSSH2=m" >> $config_host_mak
55936ebc91e5SFam Zheng  echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
55946ebc91e5SFam Zheng  echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
55950a12ec87SRichard W.M. Jonesfi
55960a12ec87SRichard W.M. Jones
559768063649Sblueswir1# USB host support
5598b5613fdcSGerd Hoffmannif test "$libusb" = "yes"; then
55992b2325ffSGerd Hoffmann  echo "HOST_USB=libusb legacy" >> $config_host_mak
5600b5613fdcSGerd Hoffmannelse
560198ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
5602b5613fdcSGerd Hoffmannfi
560368063649Sblueswir1
56043b8acc11SPaolo Bonzini# TPM passthrough support?
56053b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
56063b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
56073b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
56083b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
56093b8acc11SPaolo Bonzini  fi
56103b8acc11SPaolo Bonzinifi
56113b8acc11SPaolo Bonzini
56125b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
56135b808275SLluís Vilanovaif have_backend "nop"; then
56146d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
561522890ab5SPrerna Saxenafi
56165b808275SLluís Vilanovaif have_backend "simple"; then
56176d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
56186d8a764eSLluís  # Set the appropriate trace file.
5619953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
56209410b56cSPrerna Saxenafi
5621ed7f5f1dSPaolo Bonziniif have_backend "log"; then
5622ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
56236d8a764eSLluísfi
56245b808275SLluís Vilanovaif have_backend "ust"; then
56256d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
56266d8a764eSLluísfi
56275b808275SLluís Vilanovaif have_backend "dtrace"; then
56286d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
56296d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
56306d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
56316d8a764eSLluís  fi
5632c276b17dSDaniel P. Berrangefi
56335b808275SLluís Vilanovaif have_backend "ftrace"; then
5634781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
5635781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5636781e9545SEiichi Tsukata  else
563721684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5638781e9545SEiichi Tsukata  fi
5639781e9545SEiichi Tsukatafi
56400a852417SPaul Durrantif have_backend "syslog"; then
56410a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
56420a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
56430a852417SPaul Durrant  else
56440a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
56450a852417SPaul Durrant  fi
56460a852417SPaul Durrantfi
56479410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
56489410b56cSPrerna Saxena
5649*180fb750Szhanghailiangif test "$colo" = "yes"; then
5650*180fb750Szhanghailiang  echo "CONFIG_COLO=y" >> $config_host_mak
5651*180fb750Szhanghailiangfi
5652*180fb750Szhanghailiang
56532da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
56542da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
56552da776dbSMichael R. Hinesfi
56562da776dbSMichael R. Hines
5657575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
5658575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5659575b22b1SLaurent Vivierfi
5660575b22b1SLaurent Vivier
5661a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
5662a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
5663a6b1d4c0SChanglong Xiefi
5664a6b1d4c0SChanglong Xie
56655c312079SDr. David Alan Gilbert# Hold two types of flag:
56665c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
56675c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
56685c312079SDr. David Alan Gilbert#   CONFIG_PTHREAD_SETNAME_NP       - A way of doing it on a particular
56695c312079SDr. David Alan Gilbert#                                     platform
56705c312079SDr. David Alan Gilbertif test "$pthread_setname_np" = "yes" ; then
56715c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
56725c312079SDr. David Alan Gilbert  echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
56735c312079SDr. David Alan Gilbertfi
56745c312079SDr. David Alan Gilbert
56755b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
56765b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
56775b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
56785b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
56795b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
56805b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
5681c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
56825b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
568340d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
568440d964b5SRichard Henderson  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
56855b5e3037SPaolo Bonzinielse
56865b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
56875b5e3037SPaolo Bonzinifi
56885b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
56895b5e3037SPaolo Bonzini
569098ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
569198ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
5692804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
5693804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
56941901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
56951901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
56961901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
569721655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
5698c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
5699804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
5700a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
5701a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
5702a31a8642SMichael S. Tsirkinfi
57032b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
5704804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
570583f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
57063c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
5707804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
570845d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
5709cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
57105f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
57113dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
5712804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
5713804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
57144852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
57159fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
5716e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
571746eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
5718a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
5719f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
5720e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
5721e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
572280fd48dfSChristian Borntraeger  echo "CPP          := REAL_CC=\"\$(CPP)\" cgcc"      >> $config_host_mak
57232944d742SGerd Hoffmann  echo "CXX          := REAL_CC=\"\$(CXX)\" cgcc"      >> $config_host_mak
5724e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
5725e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
5726e39f0062SPaolo Bonzinifi
572742da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
572842da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
572942da6041SGerd Hoffmannelse
573042da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
573142da6041SGerd Hoffmannfi
5732e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
573346eef33bSBradecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
57346969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
5735e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
573673da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
57373e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
5738409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
5739804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
574017969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
574117969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
5742957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
574390246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
574490246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
574594dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
5746cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
57471d728c39SBlue Swirlif test "$gcov" = "yes" ; then
57481d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
57491d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
57501d728c39SBlue Swirlfi
5751804edf29SJuan Quintela
57526efd7517SPeter Maydell# use included Linux headers
57536efd7517SPeter Maydellif test "$linux" = "yes" ; then
5754a307beb6SAndreas Färber  mkdir -p linux-headers
57556efd7517SPeter Maydell  case "$cpu" in
5756c72b26ecSRichard Henderson  i386|x86_64|x32)
575708312a63SPeter Maydell    linux_arch=x86
57586efd7517SPeter Maydell    ;;
57596efd7517SPeter Maydell  ppcemb|ppc|ppc64)
576008312a63SPeter Maydell    linux_arch=powerpc
57616efd7517SPeter Maydell    ;;
57626efd7517SPeter Maydell  s390x)
576308312a63SPeter Maydell    linux_arch=s390
576408312a63SPeter Maydell    ;;
57651f080313SClaudio Fontana  aarch64)
57661f080313SClaudio Fontana    linux_arch=arm64
57671f080313SClaudio Fontana    ;;
5768222e7d11SSanjay Lal  mips64)
5769222e7d11SSanjay Lal    linux_arch=mips
5770222e7d11SSanjay Lal    ;;
577108312a63SPeter Maydell  *)
577208312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
577308312a63SPeter Maydell    linux_arch="$cpu"
57746efd7517SPeter Maydell    ;;
57756efd7517SPeter Maydell  esac
577608312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
577708312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
577808312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
577908312a63SPeter Maydell    fi
57806efd7517SPeter Maydellfi
57816efd7517SPeter Maydell
578297a847bcSbellardfor target in $target_list; do
578397a847bcSbellardtarget_dir="$target"
578425be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
578589138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
578697a847bcSbellardtarget_bigendian="no"
57871f3d3c8fSJuan Quintela
5788c1799a84SPaolo Bonzinicase "$target_name" in
5789d15a9c23SAnthony Green  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
5790ea2d6a39SJuan Quintela  target_bigendian=yes
5791ea2d6a39SJuan Quintela  ;;
5792ea2d6a39SJuan Quintelaesac
579397a847bcSbellardtarget_softmmu="no"
5794997344f3Sbellardtarget_user_only="no"
5795831b7825Sthstarget_linux_user="no"
579684778508Sblueswir1target_bsd_user="no"
57979e407a85Spbrookcase "$target" in
5798c1799a84SPaolo Bonzini  ${target_name}-softmmu)
57999e407a85Spbrook    target_softmmu="yes"
58009e407a85Spbrook    ;;
5801c1799a84SPaolo Bonzini  ${target_name}-linux-user)
58029c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
580376ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a Linux host"
58049c7a4202SBlue Swirl    fi
58059e407a85Spbrook    target_user_only="yes"
58069e407a85Spbrook    target_linux_user="yes"
58079e407a85Spbrook    ;;
5808c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
58099cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
581076ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a BSD host"
58119c7a4202SBlue Swirl    fi
581284778508Sblueswir1    target_user_only="yes"
581384778508Sblueswir1    target_bsd_user="yes"
581484778508Sblueswir1    ;;
58159e407a85Spbrook  *)
581676ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
58179e407a85Spbrook    exit 1
58189e407a85Spbrook    ;;
58199e407a85Spbrookesac
5820831b7825Sths
582197a847bcSbellardmkdir -p $target_dir
582225be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
582397a847bcSbellard
5824e5fe0c52Spbrookbflt="no"
582589138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
582656aebc89Spbrookgdb_xml_files=""
58277ba1e619Saliguori
5828c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
58296acff7daSJuan QuintelaTARGET_BASE_ARCH=""
5830e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
5831e73aae67SJuan Quintela
5832c1799a84SPaolo Bonzinicase "$target_name" in
58332408a527Saurel32  i386)
58342408a527Saurel32  ;;
58352408a527Saurel32  x86_64)
58366acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
58372408a527Saurel32  ;;
58382408a527Saurel32  alpha)
58392408a527Saurel32  ;;
58402408a527Saurel32  arm|armeb)
5841b498c8a0SJuan Quintela    TARGET_ARCH=arm
5842e5fe0c52Spbrook    bflt="yes"
584356aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
58442408a527Saurel32  ;;
58456a49fa95SAlexander Graf  aarch64)
58466a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
58476a49fa95SAlexander Graf    bflt="yes"
58488f95ce2eSPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
58496a49fa95SAlexander Graf  ;;
58502408a527Saurel32  cris)
58512408a527Saurel32  ;;
5852613a22c9SMichael Walle  lm32)
5853613a22c9SMichael Walle  ;;
58542408a527Saurel32  m68k)
58550938cda5Saurel32    bflt="yes"
585656aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
58572408a527Saurel32  ;;
5858877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
5859877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
586072b675caSEdgar E. Iglesias    bflt="yes"
586172b675caSEdgar E. Iglesias  ;;
58622408a527Saurel32  mips|mipsel)
5863b498c8a0SJuan Quintela    TARGET_ARCH=mips
586425be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
58652408a527Saurel32  ;;
58662408a527Saurel32  mipsn32|mipsn32el)
5867597e2cecSRichard Henderson    TARGET_ARCH=mips64
58686acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
586925be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
5870597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
58712408a527Saurel32  ;;
58722408a527Saurel32  mips64|mips64el)
5873b498c8a0SJuan Quintela    TARGET_ARCH=mips64
58746acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
587525be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
58762408a527Saurel32  ;;
5877d15a9c23SAnthony Green  moxie)
5878d15a9c23SAnthony Green  ;;
5879e67db06eSJia Liu  or32)
5880e67db06eSJia Liu    TARGET_ARCH=openrisc
5881e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
5882e67db06eSJia Liu  ;;
58832408a527Saurel32  ppc)
5884c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
58852408a527Saurel32  ;;
58862408a527Saurel32  ppcemb)
58876acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
5888e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
5889c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
58902408a527Saurel32  ;;
58912408a527Saurel32  ppc64)
58926acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
5893e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
58941438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
58952408a527Saurel32  ;;
58969c35126cSDoug Kwan  ppc64le)
58979c35126cSDoug Kwan    TARGET_ARCH=ppc64
58989c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
58999c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
59001438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
59019c35126cSDoug Kwan  ;;
59022408a527Saurel32  ppc64abi32)
5903b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
59046acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
5905e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
590625be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
59071438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
59082408a527Saurel32  ;;
59092408a527Saurel32  sh4|sh4eb)
5910b498c8a0SJuan Quintela    TARGET_ARCH=sh4
59114dbed897Spbrook    bflt="yes"
59122408a527Saurel32  ;;
59132408a527Saurel32  sparc)
59142408a527Saurel32  ;;
59152408a527Saurel32  sparc64)
59166acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
59172408a527Saurel32  ;;
59182408a527Saurel32  sparc32plus)
5919b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
59206acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
5921e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
592225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
59232408a527Saurel32  ;;
592424e804ecSAlexander Graf  s390x)
59258a641ff6SDavid Hildenbrand    gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
592624e804ecSAlexander Graf  ;;
5927444e06b1SChen Gang  tilegx)
5928444e06b1SChen Gang  ;;
59295ecaa4edSPeter Crosthwaite  tricore)
59305ecaa4edSPeter Crosthwaite  ;;
5931d2fbca94SGuan Xuetao  unicore32)
5932d2fbca94SGuan Xuetao  ;;
5933cfa550c6SMax Filippov  xtensa|xtensaeb)
5934cfa550c6SMax Filippov    TARGET_ARCH=xtensa
5935cfa550c6SMax Filippov  ;;
59362408a527Saurel32  *)
593776ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
59382408a527Saurel32  ;;
59392408a527Saurel32esac
59405e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
59415e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
59425e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
59435e8861a0SPaolo Bonzinifi
59445e8861a0SPaolo Bonzini
59455e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
59465e8861a0SPaolo Bonzini
594799afc91dSDaniel P. Berrangeupper() {
594899afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
594999afc91dSDaniel P. Berrange}
595099afc91dSDaniel P. Berrange
595189138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
595225be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
5953c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
595425be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
5955e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
5956e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
5957e6e91b9cSJuan Quintelafi
595825be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
5959adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
5960adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
5961adfc3e91SStacey Sonfi
5962c1799a84SPaolo Bonzinicase "$target_name" in
59631b0c87fcSJuan Quintela  i386|x86_64)
59641b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
596525be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
5966eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
5967eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
5968eb6fda0fSAnthony PERARD      fi
5969432d268cSJun Nakajima    fi
597059d21e53SAlexander Graf    ;;
597159d21e53SAlexander Graf  *)
59721b0c87fcSJuan Quintelaesac
5973c1799a84SPaolo Bonzinicase "$target_name" in
5974222e7d11SSanjay Lal  aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
5975c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
5976c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
5977c1799a84SPaolo Bonzini      \( "$target_name" = "$cpu" -o \
5978c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
5979c1799a84SPaolo Bonzini      \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
5980c1799a84SPaolo Bonzini      \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
5981c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
5982222e7d11SSanjay Lal      \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
5983c1799a84SPaolo Bonzini      \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
598418b8263eSMichael Tokarev      \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) -o \
598518b8263eSMichael Tokarev      \( "$target_name" = "x86_64" -a "$cpu" = "x32"   \) -o \
598618b8263eSMichael Tokarev      \( "$target_name" = "i386"   -a "$cpu" = "x32" \) \) ; then
598725be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
59881ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
5989d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
5990421f4448SMarc-André Lureau        echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
5991d5970055SMichael S. Tsirkin      fi
5992c59249f9SJuan Quintela    fi
5993c59249f9SJuan Quintelaesac
5994de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
599525be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
599697a847bcSbellardfi
599797a847bcSbellardif test "$target_softmmu" = "yes" ; then
599825be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
5999de83cd02Sbellardfi
6000997344f3Sbellardif test "$target_user_only" = "yes" ; then
600125be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6002a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6003997344f3Sbellardfi
6004831b7825Sthsif test "$target_linux_user" = "yes" ; then
600525be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6006831b7825Sthsfi
600756aebc89Spbrooklist=""
600856aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
600956aebc89Spbrook  for x in $gdb_xml_files; do
601056aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
601156aebc89Spbrook  done
601225be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
60133d0f1517SJuan Quintelafi
6014de83cd02Sbellard
6015e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
601625be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6017e5fe0c52Spbrookfi
601884778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
601925be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
602084778508Sblueswir1fi
60215b0753e0Sbellard
60224afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
6023fa282484SJuan Quintela
60244afddb55SJuan Quintelacflags=""
6025fa282484SJuan Quintelaldflags=""
60269b8e111fSJuan Quintela
6027c765fcacSPeter Crosthwaitedisas_config() {
6028c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6029c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6030c765fcacSPeter Crosthwaite}
6031c765fcacSPeter Crosthwaite
603264656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
603364656024SJuan Quintela  case "$i" in
603464656024SJuan Quintela  alpha)
6035c765fcacSPeter Crosthwaite    disas_config "ALPHA"
603664656024SJuan Quintela  ;;
603782295d8aSRichard Henderson  aarch64)
603882295d8aSRichard Henderson    if test -n "${cxx}"; then
6039c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
604082295d8aSRichard Henderson    fi
604182295d8aSRichard Henderson  ;;
604264656024SJuan Quintela  arm)
6043c765fcacSPeter Crosthwaite    disas_config "ARM"
6044999b53ecSClaudio Fontana    if test -n "${cxx}"; then
6045c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
6046999b53ecSClaudio Fontana    fi
604764656024SJuan Quintela  ;;
604864656024SJuan Quintela  cris)
6049c765fcacSPeter Crosthwaite    disas_config "CRIS"
605064656024SJuan Quintela  ;;
6051c72b26ecSRichard Henderson  i386|x86_64|x32)
6052c765fcacSPeter Crosthwaite    disas_config "I386"
605364656024SJuan Quintela  ;;
6054903ec55cSAurelien Jarno  ia64*)
6055c765fcacSPeter Crosthwaite    disas_config "IA64"
6056903ec55cSAurelien Jarno  ;;
605779368f49SMichael Walle  lm32)
6058c765fcacSPeter Crosthwaite    disas_config "LM32"
605979368f49SMichael Walle  ;;
606064656024SJuan Quintela  m68k)
6061c765fcacSPeter Crosthwaite    disas_config "M68K"
606264656024SJuan Quintela  ;;
6063877fdc12SEdgar E. Iglesias  microblaze*)
6064c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
606564656024SJuan Quintela  ;;
606664656024SJuan Quintela  mips*)
6067c765fcacSPeter Crosthwaite    disas_config "MIPS"
606864656024SJuan Quintela  ;;
6069d15a9c23SAnthony Green  moxie*)
6070c765fcacSPeter Crosthwaite    disas_config "MOXIE"
6071d15a9c23SAnthony Green  ;;
6072e67db06eSJia Liu  or32)
6073c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
6074e67db06eSJia Liu  ;;
607564656024SJuan Quintela  ppc*)
6076c765fcacSPeter Crosthwaite    disas_config "PPC"
607764656024SJuan Quintela  ;;
607824e804ecSAlexander Graf  s390*)
6079c765fcacSPeter Crosthwaite    disas_config "S390"
608064656024SJuan Quintela  ;;
608164656024SJuan Quintela  sh4)
6082c765fcacSPeter Crosthwaite    disas_config "SH4"
608364656024SJuan Quintela  ;;
608464656024SJuan Quintela  sparc*)
6085c765fcacSPeter Crosthwaite    disas_config "SPARC"
608664656024SJuan Quintela  ;;
6087cfa550c6SMax Filippov  xtensa*)
6088c765fcacSPeter Crosthwaite    disas_config "XTENSA"
6089cfa550c6SMax Filippov  ;;
609064656024SJuan Quintela  esac
609164656024SJuan Quinteladone
60929195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
6093c765fcacSPeter Crosthwaite  disas_config "TCI"
60949195b2c2SStefan Weilfi
609564656024SJuan Quintela
60966ee7126fSJuan Quintelacase "$ARCH" in
60976ee7126fSJuan Quintelaalpha)
60986ee7126fSJuan Quintela  # Ensure there's only a single GP
60996ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
61006ee7126fSJuan Quintela;;
61016ee7126fSJuan Quintelaesac
61026ee7126fSJuan Quintela
6103d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
610425be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
6105d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
6106d02c1db3SJuan Quintela    cflags="-p $cflags"
6107d02c1db3SJuan Quintela    ldflags="-p $ldflags"
6108d02c1db3SJuan Quintela  fi
6109d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
6110d02c1db3SJuan Quintela    ldflags="-p $ldflags"
611125be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
6112d02c1db3SJuan Quintela  fi
6113d02c1db3SJuan Quintelafi
6114d02c1db3SJuan Quintela
61159b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6116964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
6117fa282484SJuan Quintelafi
6118fa282484SJuan Quintela
611925be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
612025be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6121fa282484SJuan Quintela
612297a847bcSbellarddone # for target in $targets
61237d13299dSbellard
6124b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
6125b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
6126b776eca1SGerd Hoffmannfi
6127b776eca1SGerd Hoffmann
6128a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
6129a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
6130a540f158SPeter Crosthwaitefi
6131a540f158SPeter Crosthwaite
6132a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6133a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6134a99d57bbSWanlong Gaofi
6135a99d57bbSWanlong Gao
6136fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6137fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6138fd0e6053SJohn Snowfi
6139fd0e6053SJohn Snow
6140d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
6141f93296eaSWenchao XiaDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
61422b170effSMichael TokarevDIRS="$DIRS fsdev"
61439933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
61442d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
61452dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
6146c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6147c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6148aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6149ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6150446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
61519933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
61522d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
61534652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
6154753d11f2SRichard Hendersonfor bios_file in \
6155753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
6156225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
61575acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
6158753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6159753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6160e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6161753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
61624e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
6163753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6164753d11f2SRichard Hendersondo
616589138857SStefan Weil    FILES="$FILES pc-bios/$(basename $bios_file)"
61667ea78b74SJan Kiszkadone
616789138857SStefan Weilfor test_file in $(find $source_path/tests/acpi-test-data -type f)
6168c2304b52SMarcel Apfelbaumdo
616989138857SStefan Weil    FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6170c2304b52SMarcel Apfelbaumdone
6171d1807a4fSPaolo Bonzinimkdir -p $DIRS
61727d13299dSbellardfor f in $FILES ; do
6173cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6174f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6175f9245e10SPeter Maydell    fi
61767d13299dSbellarddone
61771ad2134fSPaul Brook
6178c34ebfdcSAnthony Liguori# temporary config to build submodules
61792d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
6180c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
618137116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6182c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6183cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
61845f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6185c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6186c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
61873dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6188c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6189a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6190c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
6191c34ebfdcSAnthony Liguoridone
6192c34ebfdcSAnthony Liguori
6193fe31017fSMarc-André Lureau# set up tests data directory
6194fe31017fSMarc-André Lureauif [ ! -e tests/data ]; then
6195fe31017fSMarc-André Lureau    symlink "$source_path/tests/data" tests/data
6196fe31017fSMarc-André Lureaufi
6197fe31017fSMarc-André Lureau
619876c7560aSMax Reitz# set up qemu-iotests in this build directory
619976c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
620076c7560aSMax Reitziotests_check="tests/qemu-iotests/check"
620176c7560aSMax Reitz
620276c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
620376c7560aSMax Reitzecho >> "$iotests_common_env"
620476c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
620576c7560aSMax Reitz
620676c7560aSMax Reitzif [ ! -e "$iotests_check" ]; then
620776c7560aSMax Reitz    symlink "$source_path/$iotests_check" "$iotests_check"
620876c7560aSMax Reitzfi
620976c7560aSMax Reitz
6210dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6211dc655404SMichael S. Tsirkincat <<EOD >config.status
6212dc655404SMichael S. Tsirkin#!/bin/sh
6213dc655404SMichael S. Tsirkin# Generated by configure.
6214dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6215dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6216dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6217dc655404SMichael S. TsirkinEOD
6218dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6219dc655404SMichael S. Tsirkinprintf " '%s'" "$0" "$@" >>config.status
6220cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6221dc655404SMichael S. Tsirkinchmod +x config.status
6222dc655404SMichael S. Tsirkin
62238cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6224