xref: /openbmc/qemu/configure (revision 21684af0233df1d2b554db736e4feb774950d488)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
57d13299dSbellard# set temporary file name
67d13299dSbellardif test ! -z "$TMPDIR" ; then
77d13299dSbellard    TMPDIR1="${TMPDIR}"
87d13299dSbellardelif test ! -z "$TEMPDIR" ; then
97d13299dSbellard    TMPDIR1="${TEMPDIR}"
107d13299dSbellardelse
117d13299dSbellard    TMPDIR1="/tmp"
127d13299dSbellardfi
137d13299dSbellard
143ef693a0SbellardTMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
153ef693a0SbellardTMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16a91b857cSmalcTMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
177d13299dSbellard
180ba8681eSLoïc Minier# NB: do not call "exit" in the trap handler; this is buggy with some shells;
190ba8681eSLoïc Minier# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
200ba8681eSLoïc Miniertrap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21da1d85e3SGerd Hoffmannrm -f config.log
229ac81bbbSmalc
23b48e3611SPeter Maydell# Print a helpful header at the top of config.log
24b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
25979ae168SPeter Maydellprintf "# Configured with:" >> config.log
26979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
27979ae168SPeter Maydellecho >> config.log
28b48e3611SPeter Maydellecho "#" >> config.log
29b48e3611SPeter Maydell
30bdf523e6SStefan Weil# Save the configure command line for later reuse.
31bdf523e6SStefan Weilcat <<EOD >config.status
32bdf523e6SStefan Weil#!/bin/sh
33bdf523e6SStefan Weil# Generated by configure.
34bdf523e6SStefan Weil# Run this file to recreate the current configuration.
35bdf523e6SStefan Weil# Compiler output produced by configure, useful for debugging
36bdf523e6SStefan Weil# configure, is in config.log if it exists.
37bdf523e6SStefan WeilEOD
38bdf523e6SStefan Weilprintf "exec" >>config.status
39bdf523e6SStefan Weilprintf " '%s'" "$0" "$@" >>config.status
40bdf523e6SStefan Weilecho >>config.status
41bdf523e6SStefan Weilchmod +x config.status
42bdf523e6SStefan Weil
4376ad07a4SPeter Maydellerror_exit() {
4476ad07a4SPeter Maydell    echo
4576ad07a4SPeter Maydell    echo "ERROR: $1"
4676ad07a4SPeter Maydell    while test -n "$2"; do
4776ad07a4SPeter Maydell        echo "       $2"
4876ad07a4SPeter Maydell        shift
4976ad07a4SPeter Maydell    done
5076ad07a4SPeter Maydell    echo
5176ad07a4SPeter Maydell    exit 1
5276ad07a4SPeter Maydell}
5376ad07a4SPeter Maydell
548dc38a78SPeter Maydelldo_cc() {
558dc38a78SPeter Maydell    # Run the compiler, capturing its output to the log.
568dc38a78SPeter Maydell    echo $cc "$@" >> config.log
578dc38a78SPeter Maydell    $cc "$@" >> config.log 2>&1 || return $?
588dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
598dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
608dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
618dc38a78SPeter Maydell    # obvious to developers.
628dc38a78SPeter Maydell    if test "$werror" != "yes"; then
638dc38a78SPeter Maydell        return 0
648dc38a78SPeter Maydell    fi
658dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
668dc38a78SPeter Maydell    case "$*" in
678dc38a78SPeter Maydell        *-Werror*)
688dc38a78SPeter Maydell           return 0
698dc38a78SPeter Maydell        ;;
708dc38a78SPeter Maydell    esac
718dc38a78SPeter Maydell    echo $cc -Werror "$@" >> config.log
728dc38a78SPeter Maydell    $cc -Werror "$@" >> config.log 2>&1 && return $?
7376ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
7476ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
7576ad07a4SPeter Maydell        "will be at the bottom of config.log." \
7676ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
778dc38a78SPeter Maydell}
788dc38a78SPeter Maydell
7952166aa0SJuan Quintelacompile_object() {
808dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
8152166aa0SJuan Quintela}
8252166aa0SJuan Quintela
8352166aa0SJuan Quintelacompile_prog() {
8452166aa0SJuan Quintela  local_cflags="$1"
8552166aa0SJuan Quintela  local_ldflags="$2"
868dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
8752166aa0SJuan Quintela}
8852166aa0SJuan Quintela
8911568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
9011568d6dSPaolo Bonzinisymlink() {
9172b8b5a1SStefan Weil  rm -rf "$2"
92ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
9372b8b5a1SStefan Weil  ln -s "$1" "$2"
9411568d6dSPaolo Bonzini}
9511568d6dSPaolo Bonzini
960dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
970dba6195SLoïc Minier# executable or a builtin)
980dba6195SLoïc Minierhas() {
990dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1000dba6195SLoïc Minier}
1010dba6195SLoïc Minier
1020dba6195SLoïc Minier# search for an executable in PATH
1030dba6195SLoïc Minierpath_of() {
1040dba6195SLoïc Minier    local_command="$1"
1050dba6195SLoïc Minier    local_ifs="$IFS"
1060dba6195SLoïc Minier    local_dir=""
1070dba6195SLoïc Minier
1080dba6195SLoïc Minier    # pathname has a dir component?
1090dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
1100dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
1110dba6195SLoïc Minier            echo "$local_command"
1120dba6195SLoïc Minier            return 0
1130dba6195SLoïc Minier        fi
1140dba6195SLoïc Minier    fi
1150dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1160dba6195SLoïc Minier        return 1
1170dba6195SLoïc Minier    fi
1180dba6195SLoïc Minier
1190dba6195SLoïc Minier    IFS=:
1200dba6195SLoïc Minier    for local_dir in $PATH; do
1210dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1220dba6195SLoïc Minier            echo "$local_dir/$local_command"
1230dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1240dba6195SLoïc Minier            return 0
1250dba6195SLoïc Minier        fi
1260dba6195SLoïc Minier    done
1270dba6195SLoïc Minier    # not found
1280dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1290dba6195SLoïc Minier    return 1
1300dba6195SLoïc Minier}
1310dba6195SLoïc Minier
1327d13299dSbellard# default parameters
133ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
1342ff6b91eSJuan Quintelacpu=""
135a31a8642SMichael S. Tsirkiniasl="iasl"
1361e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
13743ce4dfeSbellardstatic="no"
1387d13299dSbellardcross_prefix=""
1390c58ac1cSmalcaudio_drv_list=""
140b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
141b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
142e49d021eSPeter Maydellhost_cc="cc"
14373da375eSJuan Quintelalibs_softmmu=""
1443e2e0e6bSJuan Quintelalibs_tools=""
14567f86e8eSJuan Quintelaaudio_pt_int=""
146d5631638Smalcaudio_win_int=""
1472b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
148957f1f99SMichael Rothlibs_qga=""
1495bc62e01SGerd Hoffmanndebug_info="yes"
150ac0df51dSaliguori
151afb63ebdSStefan Weil# Don't accept a target_list environment variable.
152afb63ebdSStefan Weilunset target_list
153377529c0SPaolo Bonzini
154377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
155377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
156377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
157377529c0SPaolo Bonzini#              unless --disable-foo is given
158377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
159377529c0SPaolo Bonzini#              feature will searched for,
160377529c0SPaolo Bonzini#              if not found, configure exits with error
161377529c0SPaolo Bonzini#
162377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
163377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
164377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
165377529c0SPaolo Bonzini
166377529c0SPaolo Bonzinibluez=""
167377529c0SPaolo Bonzinibrlapi=""
168377529c0SPaolo Bonzinicurl=""
169377529c0SPaolo Bonzinicurses=""
170377529c0SPaolo Bonzinidocs=""
171377529c0SPaolo Bonzinifdt=""
17258952137SVincenzo Maffionenetmap="no"
173e2134eb9SGerd Hoffmannpixman=""
174377529c0SPaolo Bonzinisdl=""
175983eef5aSMeador Ingevirtfs=""
176821601eaSJes Sorensenvnc="yes"
177377529c0SPaolo Bonzinisparse="no"
178377529c0SPaolo Bonziniuuid=""
179377529c0SPaolo Bonzinivde=""
180377529c0SPaolo Bonzinivnc_tls=""
181377529c0SPaolo Bonzinivnc_sasl=""
182377529c0SPaolo Bonzinivnc_jpeg=""
183377529c0SPaolo Bonzinivnc_png=""
1847536ee4bSTim Hardeckvnc_ws=""
185377529c0SPaolo Bonzinixen=""
186d5b93ddfSAnthony PERARDxen_ctrl_version=""
187eb6fda0fSAnthony PERARDxen_pci_passthrough=""
188377529c0SPaolo Bonzinilinux_aio=""
18947e98658SCorey Bryantcap_ng=""
190377529c0SPaolo Bonziniattr=""
1914f26f2b6SAvi Kivitylibattr=""
192377529c0SPaolo Bonzinixfs=""
193377529c0SPaolo Bonzini
194d41a75a2SBradvhost_net="no"
1955e9be92dSNicholas Bellingervhost_scsi="no"
196d41a75a2SBradkvm="no"
1972da776dbSMichael R. Hinesrdma=""
198377529c0SPaolo Bonzinigprof="no"
199377529c0SPaolo Bonzinidebug_tcg="no"
200377529c0SPaolo Bonzinidebug="no"
201377529c0SPaolo Bonzinistrip_opt="yes"
2029195b2c2SStefan Weiltcg_interpreter="no"
203377529c0SPaolo Bonzinibigendian="no"
204377529c0SPaolo Bonzinimingw32="no"
2051d728c39SBlue Swirlgcov="no"
2061d728c39SBlue Swirlgcov_tool="gcov"
207377529c0SPaolo BonziniEXESUF=""
208377529c0SPaolo Bonziniprefix="/usr/local"
209377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
210528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
211850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
212377529c0SPaolo Bonzinibindir="\${prefix}/bin"
2133aa5d2beSAlon Levylibdir="\${prefix}/lib"
2148bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
2150f94d6daSAlon Levyincludedir="\${prefix}/include"
216377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
217785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
218377529c0SPaolo Bonziniconfsuffix="/qemu"
219377529c0SPaolo Bonzinislirp="yes"
220377529c0SPaolo Bonzinifmod_lib=""
221377529c0SPaolo Bonzinifmod_inc=""
222377529c0SPaolo Bonzinioss_lib=""
223377529c0SPaolo Bonzinibsd="no"
224377529c0SPaolo Bonzinilinux="no"
225377529c0SPaolo Bonzinisolaris="no"
226377529c0SPaolo Bonziniprofiler="no"
227377529c0SPaolo Bonzinicocoa="no"
228377529c0SPaolo Bonzinisoftmmu="yes"
229377529c0SPaolo Bonzinilinux_user="no"
230377529c0SPaolo Bonzinibsd_user="no"
23130163d89SPeter Maydellguest_base="yes"
232377529c0SPaolo Bonziniuname_release=""
233377529c0SPaolo Bonziniaix="no"
234377529c0SPaolo Bonziniblobs="yes"
235377529c0SPaolo Bonzinipkgversion=""
23640d6444eSAvi Kivitypie=""
237377529c0SPaolo Bonzinizero_malloc=""
2383556c233SPaolo Bonziniqom_cast_debug="yes"
239377529c0SPaolo Bonzinitrace_backend="nop"
240377529c0SPaolo Bonzinitrace_file="trace"
241377529c0SPaolo Bonzinispice=""
242377529c0SPaolo Bonzinirbd=""
243111a38b0SRobert Relyeasmartcard_nss=""
2442b2325ffSGerd Hoffmannlibusb=""
24569354a83SHans de Goedeusb_redir=""
246b1e5fff4SMichael Walleglx=""
2471ece9905SAlon Levyzlib="yes"
248e8ef31a3SMichael Tokarevguest_agent=""
249d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
250d9840e25STomoki Sekiyamavss_win32_sdk=""
251d9840e25STomoki Sekiyamawin_sdk="no"
2524b1c11fdSDaniel P. Berrangewant_tools="yes"
253c589b249SRonnie Sahlberglibiscsi=""
2546542aa9cSPeter Lievenlibnfs=""
255519175a2SAlex Barcelocoroutine=""
25670c60c08SStefan Hajnoczicoroutine_pool=""
257f794573eSEduardo Otuboseccomp=""
258eb100396SBharata B Raoglusterfs=""
2590c14fb47SBharata B Raoglusterfs_discard="no"
2607c815372SBharata B Raoglusterfs_zerofill="no"
261583f6e7bSStefan Hajnoczivirtio_blk_data_plane=""
262a4ccabcfSAnthony Liguorigtk=""
263528de90aSDaniel P. Berrangegtkabi="2.0"
264ab214c29SStefan Bergertpm="no"
2650a12ec87SRichard W.M. Joneslibssh2=""
2664f18b782SJeff Codyvhdx=""
267377529c0SPaolo Bonzini
268ac0df51dSaliguori# parse CC options first
269ac0df51dSaliguorifor opt do
270ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
271ac0df51dSaliguori  case "$opt" in
272ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
273ac0df51dSaliguori  ;;
2743d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
275ac0df51dSaliguori  ;;
27683f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
27783f73fceSTomoki Sekiyama  ;;
278ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
279ca4deeb1SPaolo Bonzini  ;;
2802ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2812ff6b91eSJuan Quintela  ;;
282a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
283f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
284e2a2ed06SJuan Quintela  ;;
285e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
286f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
287e2a2ed06SJuan Quintela  ;;
2885bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2895bc62e01SGerd Hoffmann  ;;
2905bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2915bc62e01SGerd Hoffmann  ;;
292ac0df51dSaliguori  esac
293ac0df51dSaliguoridone
294ac0df51dSaliguori# OS specific
295ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
29693148aa5SStefan Weil# we can eliminate its usage altogether.
297ac0df51dSaliguori
298e49d021eSPeter Maydell# Preferred compiler:
299e49d021eSPeter Maydell#  ${CC} (if set)
300e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
301e49d021eSPeter Maydell#  system compiler
302e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
303e49d021eSPeter Maydell  cc="$host_cc"
304e49d021eSPeter Maydellelse
305b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
306e49d021eSPeter Maydellfi
307e49d021eSPeter Maydell
30883f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
30983f73fceSTomoki Sekiyama  cxx="c++"
31083f73fceSTomoki Sekiyamaelse
31183f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
31283f73fceSTomoki Sekiyamafi
31383f73fceSTomoki Sekiyama
314b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
3153dd46c78SBlue Swirlas="${AS-${cross_prefix}as}"
3163dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
317b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
318b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
3193f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
320b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
321b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
32217884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
32317884d7bSSergei Trofimovichquery_pkg_config() {
32417884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
32517884d7bSSergei Trofimovich}
32617884d7bSSergei Trofimovichpkg_config=query_pkg_config
327b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
328ac0df51dSaliguori
32945d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
33045d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
33145d285abSPeter Maydell
332be17dc90SMichael S. Tsirkin# default flags for all hosts
333be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
334f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
335c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
336be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
3376b4c305cSPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
3385bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
3395bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
340be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
3415bc62e01SGerd Hoffmannfi
342be17dc90SMichael S. Tsirkin
343ca4deeb1SPaolo Bonzini# make source path absolute
344ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
345ca4deeb1SPaolo Bonzini
346ac0df51dSaliguoricheck_define() {
347ac0df51dSaliguoricat > $TMPC <<EOF
348ac0df51dSaliguori#if !defined($1)
349fd786e1aSPeter Maydell#error $1 not defined
350ac0df51dSaliguori#endif
351ac0df51dSaliguoriint main(void) { return 0; }
352ac0df51dSaliguoriEOF
35352166aa0SJuan Quintela  compile_object
354ac0df51dSaliguori}
355ac0df51dSaliguori
356bbea4050SPeter Maydellif check_define __linux__ ; then
357bbea4050SPeter Maydell  targetos="Linux"
358bbea4050SPeter Maydellelif check_define _WIN32 ; then
359bbea4050SPeter Maydell  targetos='MINGW32'
360bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
361bbea4050SPeter Maydell  targetos='OpenBSD'
362bbea4050SPeter Maydellelif check_define __sun__ ; then
363bbea4050SPeter Maydell  targetos='SunOS'
364bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
365bbea4050SPeter Maydell  targetos='Haiku'
366bbea4050SPeter Maydellelse
367bbea4050SPeter Maydell  targetos=`uname -s`
368bbea4050SPeter Maydellfi
369bbea4050SPeter Maydell
370bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
371bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
372bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
373bbea4050SPeter Maydell# the correct CPU with the --cpu option.
374bbea4050SPeter Maydellcase $targetos in
375bbea4050SPeter MaydellDarwin)
376bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
377bbea4050SPeter Maydell  # run 64-bit userspace code.
378bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
379bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
380bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
381bbea4050SPeter Maydell    cpu="x86_64"
382bbea4050SPeter Maydell  fi
383bbea4050SPeter Maydell  ;;
384bbea4050SPeter MaydellSunOS)
385bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
386bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
387bbea4050SPeter Maydell    cpu="x86_64"
388bbea4050SPeter Maydell  fi
389bbea4050SPeter Maydellesac
390bbea4050SPeter Maydell
3912ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3922ff6b91eSJuan Quintela  # command line argument
3932ff6b91eSJuan Quintela  :
3942ff6b91eSJuan Quintelaelif check_define __i386__ ; then
395ac0df51dSaliguori  cpu="i386"
396ac0df51dSaliguorielif check_define __x86_64__ ; then
397c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
398c72b26ecSRichard Henderson    cpu="x32"
399c72b26ecSRichard Henderson  else
400ac0df51dSaliguori    cpu="x86_64"
401c72b26ecSRichard Henderson  fi
4023aa9bd6cSblueswir1elif check_define __sparc__ ; then
4033aa9bd6cSblueswir1  if check_define __arch64__ ; then
4043aa9bd6cSblueswir1    cpu="sparc64"
4053aa9bd6cSblueswir1  else
4063aa9bd6cSblueswir1    cpu="sparc"
4073aa9bd6cSblueswir1  fi
408fdf7ed96Smalcelif check_define _ARCH_PPC ; then
409fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
410fdf7ed96Smalc    cpu="ppc64"
411ac0df51dSaliguori  else
412fdf7ed96Smalc    cpu="ppc"
413fdf7ed96Smalc  fi
414afa05235SAurelien Jarnoelif check_define __mips__ ; then
415afa05235SAurelien Jarno  cpu="mips"
416477ba620SAurelien Jarnoelif check_define __ia64__ ; then
417477ba620SAurelien Jarno  cpu="ia64"
418d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
419d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
420d66ed0eaSAurelien Jarno    cpu="s390x"
421d66ed0eaSAurelien Jarno  else
422d66ed0eaSAurelien Jarno    cpu="s390"
423d66ed0eaSAurelien Jarno  fi
42421d89f84SPeter Maydellelif check_define __arm__ ; then
42521d89f84SPeter Maydell  cpu="arm"
4261f080313SClaudio Fontanaelif check_define __aarch64__ ; then
4271f080313SClaudio Fontana  cpu="aarch64"
428f28ffed5SBradelif check_define __hppa__ ; then
429f28ffed5SBrad  cpu="hppa"
430fdf7ed96Smalcelse
431fdf7ed96Smalc  cpu=`uname -m`
432ac0df51dSaliguorifi
433ac0df51dSaliguori
434359bc95dSPeter MaydellARCH=
435359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
436359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
4377d13299dSbellardcase "$cpu" in
438c72b26ecSRichard Henderson  ia64|ppc|ppc64|s390|s390x|sparc64|x32)
439ea8f20f8SJuan Quintela    cpu="$cpu"
440ea8f20f8SJuan Quintela  ;;
4417d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
44297a847bcSbellard    cpu="i386"
4437d13299dSbellard  ;;
444aaa5fa14Saurel32  x86_64|amd64)
445aaa5fa14Saurel32    cpu="x86_64"
446aaa5fa14Saurel32  ;;
44721d89f84SPeter Maydell  armv*b|armv*l|arm)
44821d89f84SPeter Maydell    cpu="arm"
4497d13299dSbellard  ;;
4501f080313SClaudio Fontana  aarch64)
4511f080313SClaudio Fontana    cpu="aarch64"
4521f080313SClaudio Fontana  ;;
453afa05235SAurelien Jarno  mips*)
454afa05235SAurelien Jarno    cpu="mips"
455afa05235SAurelien Jarno  ;;
4563142255cSblueswir1  sparc|sun4[cdmuv])
457ae228531Sbellard    cpu="sparc"
458ae228531Sbellard  ;;
4597d13299dSbellard  *)
460359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
461359bc95dSPeter Maydell    ARCH=unknown
4627d13299dSbellard  ;;
4637d13299dSbellardesac
464359bc95dSPeter Maydellif test -z "$ARCH"; then
465359bc95dSPeter Maydell  ARCH="$cpu"
466359bc95dSPeter Maydellfi
467e2d52ad3SJuan Quintela
4687d13299dSbellard# OS specific
4690dbfc675SJuan Quintela
4707d13299dSbellardcase $targetos in
471c326e0afSbellardCYGWIN*)
472c326e0afSbellard  mingw32="yes"
473a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
474d5631638Smalc  audio_possible_drivers="winwave sdl"
475d5631638Smalc  audio_drv_list="winwave"
476c326e0afSbellard;;
47767b915a5SbellardMINGW32*)
47867b915a5Sbellard  mingw32="yes"
479d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
480d5631638Smalc  audio_drv_list="winwave"
48167b915a5Sbellard;;
4825c40d2bdSthsGNU/kFreeBSD)
483a167ba50SAurelien Jarno  bsd="yes"
4840c58ac1cSmalc  audio_drv_list="oss"
485f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4865c40d2bdSths;;
4877d3505c5SbellardFreeBSD)
4887d3505c5Sbellard  bsd="yes"
4890db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4900c58ac1cSmalc  audio_drv_list="oss"
491f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
492f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
493f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
49458952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
4957d3505c5Sbellard;;
496c5e97233Sblueswir1DragonFly)
497c5e97233Sblueswir1  bsd="yes"
4980db4a067SPaolo Bonzini  make="${MAKE-gmake}"
499c5e97233Sblueswir1  audio_drv_list="oss"
500c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
501c5e97233Sblueswir1;;
5027d3505c5SbellardNetBSD)
5037d3505c5Sbellard  bsd="yes"
5040db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5050c58ac1cSmalc  audio_drv_list="oss"
506c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
5078ef92a88Sblueswir1  oss_lib="-lossaudio"
5087d3505c5Sbellard;;
5097d3505c5SbellardOpenBSD)
5107d3505c5Sbellard  bsd="yes"
5110db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5124f6ab397SBrad Smith  audio_drv_list="sdl"
5134f6ab397SBrad Smith  audio_possible_drivers="sdl esd"
5147d3505c5Sbellard;;
51583fb7adfSbellardDarwin)
51683fb7adfSbellard  bsd="yes"
51783fb7adfSbellard  darwin="yes"
5181b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
519a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
5200c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
5211b0f9cc2Saliguori  else
522a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
5231b0f9cc2Saliguori  fi
524fd677642Sths  cocoa="yes"
5250c58ac1cSmalc  audio_drv_list="coreaudio"
526c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
5270c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
5287973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
529a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
530a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
531a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
53283fb7adfSbellard;;
533ec530c81SbellardSunOS)
534ec530c81Sbellard  solaris="yes"
5350db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5360db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
537fa58948dSBlue Swirl  ld="gld"
538e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
5390475a5caSths  needs_libsunmath="no"
540c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
541c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
5420475a5caSths    if test "$solarisrev" -le 9 ; then
5430475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
5440475a5caSths        needs_libsunmath="yes"
545f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
546f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
547f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
5480475a5caSths      else
54976ad07a4SPeter Maydell        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
55076ad07a4SPeter Maydell            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
55176ad07a4SPeter Maydell            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
55276ad07a4SPeter Maydell            "Studio 11 can be downloaded from www.sun.com."
5530475a5caSths      fi
5540475a5caSths    fi
55586b2bd93Sths  fi
5566b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
5570c58ac1cSmalc    audio_drv_list="oss"
5586b4d2ba1Sths  fi
559c2de5c91Smalc  audio_possible_drivers="oss sdl"
560d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
561d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
562d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
563d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
564a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
565560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
566560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
567560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
568ec530c81Sbellard;;
569b29fe3edSmalcAIX)
570b29fe3edSmalc  aix="yes"
5710db4a067SPaolo Bonzini  make="${MAKE-gmake}"
572b29fe3edSmalc;;
573179cf400SAndreas FärberHaiku)
574179cf400SAndreas Färber  haiku="yes"
575179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
576179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
577179cf400SAndreas Färber;;
578fb065187Sbellard*)
5790c58ac1cSmalc  audio_drv_list="oss"
580b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5815327cf48Sbellard  linux="yes"
582831b7825Sths  linux_user="yes"
583af2be207SJan Kiszka  kvm="yes"
584af2be207SJan Kiszka  vhost_net="yes"
5855e9be92dSNicholas Bellinger  vhost_scsi="yes"
586c72b26ecSRichard Henderson  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "x32" ] ; then
587c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
588c9ec1fe4Sbellard  fi
589a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
590fb065187Sbellard;;
5917d13299dSbellardesac
5927d13299dSbellard
5937d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
594b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
59584778508Sblueswir1    bsd_user="yes"
5967d3505c5Sbellard  fi
59708de3949SAndreas Färberfi
5987d3505c5Sbellard
5990db4a067SPaolo Bonzini: ${make=${MAKE-make}}
6000db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
60152510f8bSStefan Weil: ${python=${PYTHON-python}}
602e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
6030db4a067SPaolo Bonzini
6043c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
6053c4a4d0dSPeter Maydellif has clang; then
6063c4a4d0dSPeter Maydell  objcc=clang
6073c4a4d0dSPeter Maydellelse
6083c4a4d0dSPeter Maydell  objcc="$cc"
6093c4a4d0dSPeter Maydellfi
6103c4a4d0dSPeter Maydell
6113457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
6123457a3f8SJuan Quintela  EXESUF=".exe"
613a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
614e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
615e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
616f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
617f7cf5d5bSStefan Weilcat > $TMPC << EOF
618f7cf5d5bSStefan Weilint main(void) { return 0; }
619f7cf5d5bSStefan WeilEOF
620f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
621f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
622f7cf5d5bSStefan Weil  fi
623c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
624683035deSPaolo Bonzini  mandir="\${prefix}"
625528ae5b8SEduardo Habkost  datadir="\${prefix}"
626850da188SEduardo Habkost  qemu_docdir="\${prefix}"
627683035deSPaolo Bonzini  bindir="\${prefix}"
628683035deSPaolo Bonzini  sysconfdir="\${prefix}"
6295a699bbbSLaszlo Ersek  local_statedir=
630683035deSPaolo Bonzini  confsuffix=""
631368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
6323457a3f8SJuan Quintelafi
6333457a3f8SJuan Quintela
634487fefdbSAnthony Liguoriwerror=""
63585aa5189Sbellard
6367d13299dSbellardfor opt do
637a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
6387d13299dSbellard  case "$opt" in
6392efc3265Sbellard  --help|-h) show_help=yes
6402efc3265Sbellard  ;;
64199123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
64299123e13SMike Frysinger  ;;
643b1a550a0Spbrook  --prefix=*) prefix="$optarg"
6447d13299dSbellard  ;;
645b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
64632ce6337Sbellard  ;;
647ca4deeb1SPaolo Bonzini  --source-path=*)
6487d13299dSbellard  ;;
649ac0df51dSaliguori  --cross-prefix=*)
6507d13299dSbellard  ;;
651ac0df51dSaliguori  --cc=*)
6527d13299dSbellard  ;;
653b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
65483469015Sbellard  ;;
65583f73fceSTomoki Sekiyama  --cxx=*)
65683f73fceSTomoki Sekiyama  ;;
657e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
658e007dbecSMichael S. Tsirkin  ;;
6593c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
6603c4a4d0dSPeter Maydell  ;;
661b1a550a0Spbrook  --make=*) make="$optarg"
6627d13299dSbellard  ;;
6636a882643Spbrook  --install=*) install="$optarg"
6646a882643Spbrook  ;;
665c886edfbSBlue Swirl  --python=*) python="$optarg"
666c886edfbSBlue Swirl  ;;
6671d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
6681d728c39SBlue Swirl  ;;
669e2d8830eSBrad  --smbd=*) smbd="$optarg"
670e2d8830eSBrad  ;;
671e2a2ed06SJuan Quintela  --extra-cflags=*)
6727d13299dSbellard  ;;
673e2a2ed06SJuan Quintela  --extra-ldflags=*)
6747d13299dSbellard  ;;
6755bc62e01SGerd Hoffmann  --enable-debug-info)
6765bc62e01SGerd Hoffmann  ;;
6775bc62e01SGerd Hoffmann  --disable-debug-info)
6785bc62e01SGerd Hoffmann  ;;
6792ff6b91eSJuan Quintela  --cpu=*)
6807d13299dSbellard  ;;
681b1a550a0Spbrook  --target-list=*) target_list="$optarg"
682de83cd02Sbellard  ;;
68374242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
68494a420b1SStefan Hajnoczi  ;;
68574242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6869410b56cSPrerna Saxena  ;;
6877d13299dSbellard  --enable-gprof) gprof="yes"
6887d13299dSbellard  ;;
6891d728c39SBlue Swirl  --enable-gcov) gcov="yes"
6901d728c39SBlue Swirl  ;;
69179427693SLoïc Minier  --static)
69279427693SLoïc Minier    static="yes"
69379427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
69417884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
69543ce4dfeSbellard  ;;
6960b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6970b24e75fSPaolo Bonzini  ;;
6980b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
6990b24e75fSPaolo Bonzini  ;;
7003aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
7013aa5d2beSAlon Levy  ;;
7028bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
7038bf188aaSMichael Tokarev  ;;
7040f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
7050f94d6daSAlon Levy  ;;
706528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
7070b24e75fSPaolo Bonzini  ;;
708023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
709023d3d67SEduardo Habkost  ;;
710850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
7110b24e75fSPaolo Bonzini  ;;
712ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
71307381cc1SAnthony Liguori  ;;
714785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
715785c23aeSLuiz Capitulino  ;;
716785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
717023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
718023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
719023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
720023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
721023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
722023ddd74SMax Filippov    # lots of directory switches by default.
723023ddd74SMax Filippov  ;;
724e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
725e2134eb9SGerd Hoffmann  ;;
726e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
727e2134eb9SGerd Hoffmann  ;;
72874880fe2SRobert Schiele  --without-pixman) pixman="none"
72974880fe2SRobert Schiele  ;;
73097a847bcSbellard  --disable-sdl) sdl="no"
73197a847bcSbellard  ;;
732c4198157SJuan Quintela  --enable-sdl) sdl="yes"
733c4198157SJuan Quintela  ;;
7343556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
7353556c233SPaolo Bonzini  ;;
7363556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
7373556c233SPaolo Bonzini  ;;
738983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
739983eef5aSMeador Inge  ;;
740983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
741983eef5aSMeador Inge  ;;
742821601eaSJes Sorensen  --disable-vnc) vnc="no"
743821601eaSJes Sorensen  ;;
744821601eaSJes Sorensen  --enable-vnc) vnc="yes"
745821601eaSJes Sorensen  ;;
746b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
747102a52e4Sbellard  ;;
748c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
749c2de5c91Smalc  ;;
7502f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
7512f6a1ab0Sblueswir1  ;;
7520c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
7530c58ac1cSmalc  ;;
754b64ec4e4SFam Zheng  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
755b64ec4e4SFam Zheng  ;;
756b64ec4e4SFam Zheng  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
757eb852011SMarkus Armbruster  ;;
758f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
759f8393946Saurel32  ;;
760f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
761f8393946Saurel32  ;;
762f3d08ee6SPaul Brook  --enable-debug)
763f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
764f3d08ee6SPaul Brook      debug_tcg="yes"
765f3d08ee6SPaul Brook      debug="yes"
766f3d08ee6SPaul Brook      strip_opt="no"
767f3d08ee6SPaul Brook  ;;
76803b4fe7dSaliguori  --enable-sparse) sparse="yes"
76903b4fe7dSaliguori  ;;
77003b4fe7dSaliguori  --disable-sparse) sparse="no"
77103b4fe7dSaliguori  ;;
7721625af87Saliguori  --disable-strip) strip_opt="no"
7731625af87Saliguori  ;;
7748d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
7758d5d2d4cSths  ;;
7761be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
7771be10ad2SJuan Quintela  ;;
7782f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
7792f9606b3Saliguori  ;;
780ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
781ea784e3bSJuan Quintela  ;;
7822f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
7832f6f5c7aSCorentin Chary  ;;
7842f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
7852f6f5c7aSCorentin Chary  ;;
786efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
787efe556adSCorentin Chary  ;;
788efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
789efe556adSCorentin Chary  ;;
7907536ee4bSTim Hardeck  --disable-vnc-ws) vnc_ws="no"
7917536ee4bSTim Hardeck  ;;
7927536ee4bSTim Hardeck  --enable-vnc-ws) vnc_ws="yes"
7937536ee4bSTim Hardeck  ;;
794443f1376Sbellard  --disable-slirp) slirp="no"
795c20709aaSbellard  ;;
796ee682d27SStefan Weil  --disable-uuid) uuid="no"
797ee682d27SStefan Weil  ;;
798ee682d27SStefan Weil  --enable-uuid) uuid="yes"
799ee682d27SStefan Weil  ;;
800e0e6c8c0Saliguori  --disable-vde) vde="no"
8018a16d273Sths  ;;
802dfb278bdSJuan Quintela  --enable-vde) vde="yes"
803dfb278bdSJuan Quintela  ;;
80458952137SVincenzo Maffione  --disable-netmap) netmap="no"
80558952137SVincenzo Maffione  ;;
80658952137SVincenzo Maffione  --enable-netmap) netmap="yes"
80758952137SVincenzo Maffione  ;;
808e37630caSaliguori  --disable-xen) xen="no"
809e37630caSaliguori  ;;
810fc321b4bSJuan Quintela  --enable-xen) xen="yes"
811fc321b4bSJuan Quintela  ;;
812eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
813eb6fda0fSAnthony PERARD  ;;
814eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
815eb6fda0fSAnthony PERARD  ;;
8162e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
8172e4d9fb1Saurel32  ;;
8184ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
8194ffcedb6SJuan Quintela  ;;
820fb599c9aSbalrog  --disable-bluez) bluez="no"
821fb599c9aSbalrog  ;;
822a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
823a20a6f46SJuan Quintela  ;;
8247ba1e619Saliguori  --disable-kvm) kvm="no"
8257ba1e619Saliguori  ;;
826b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
827b31a0277SJuan Quintela  ;;
8289195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
8299195b2c2SStefan Weil  ;;
8309195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
8319195b2c2SStefan Weil  ;;
83247e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
83347e98658SCorey Bryant  ;;
83447e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
83547e98658SCorey Bryant  ;;
836cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
837cd4ec0b4SGerd Hoffmann  ;;
838cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
839cd4ec0b4SGerd Hoffmann  ;;
840c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
841c589b249SRonnie Sahlberg  ;;
842c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
843c589b249SRonnie Sahlberg  ;;
8446542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
8456542aa9cSPeter Lieven  ;;
8466542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
8476542aa9cSPeter Lieven  ;;
84805c2a3e7Sbellard  --enable-profiler) profiler="yes"
84905c2a3e7Sbellard  ;;
85014821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
85114821030SPavel Borzenkov  ;;
852c2de5c91Smalc  --enable-cocoa)
853c2de5c91Smalc      cocoa="yes" ;
854c2de5c91Smalc      sdl="no" ;
855c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
8565b0753e0Sbellard  ;;
857cad25d69Spbrook  --disable-system) softmmu="no"
8580a8e90f4Spbrook  ;;
859cad25d69Spbrook  --enable-system) softmmu="yes"
8600a8e90f4Spbrook  ;;
8610953a80fSZachary Amsden  --disable-user)
8620953a80fSZachary Amsden      linux_user="no" ;
8630953a80fSZachary Amsden      bsd_user="no" ;
8640953a80fSZachary Amsden  ;;
8650953a80fSZachary Amsden  --enable-user) ;;
866831b7825Sths  --disable-linux-user) linux_user="no"
8670a8e90f4Spbrook  ;;
868831b7825Sths  --enable-linux-user) linux_user="yes"
869831b7825Sths  ;;
87084778508Sblueswir1  --disable-bsd-user) bsd_user="no"
87184778508Sblueswir1  ;;
87284778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
87384778508Sblueswir1  ;;
874379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
875379f6698SPaul Brook  ;;
876379f6698SPaul Brook  --disable-guest-base) guest_base="no"
877379f6698SPaul Brook  ;;
87840d6444eSAvi Kivity  --enable-pie) pie="yes"
87934005a00SKirill A. Shutemov  ;;
88040d6444eSAvi Kivity  --disable-pie) pie="no"
88134005a00SKirill A. Shutemov  ;;
882c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
883c5937220Spbrook  ;;
88485aa5189Sbellard  --enable-werror) werror="yes"
88585aa5189Sbellard  ;;
88685aa5189Sbellard  --disable-werror) werror="no"
88785aa5189Sbellard  ;;
8884d3b6f6eSbalrog  --disable-curses) curses="no"
8894d3b6f6eSbalrog  ;;
890c584a6d0SJuan Quintela  --enable-curses) curses="yes"
891c584a6d0SJuan Quintela  ;;
892769ce76dSAlexander Graf  --disable-curl) curl="no"
893769ce76dSAlexander Graf  ;;
894788c8196SJuan Quintela  --enable-curl) curl="yes"
895788c8196SJuan Quintela  ;;
8962df87df7SJuan Quintela  --disable-fdt) fdt="no"
8972df87df7SJuan Quintela  ;;
8982df87df7SJuan Quintela  --enable-fdt) fdt="yes"
8992df87df7SJuan Quintela  ;;
9005c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
9015c6c3a6cSChristoph Hellwig  ;;
9025c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
9035c6c3a6cSChristoph Hellwig  ;;
904758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
905758e8e38SVenkateswararao Jujjuri (JV)  ;;
906758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
907758e8e38SVenkateswararao Jujjuri (JV)  ;;
90877755340Sths  --disable-blobs) blobs="no"
90977755340Sths  ;;
9104a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
9114a19f1ecSpbrook  ;;
912519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
913519175a2SAlex Barcelo  ;;
91470c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
91570c60c08SStefan Hajnoczi  ;;
91670c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
91770c60c08SStefan Hajnoczi  ;;
918a25dba17SJuan Quintela  --disable-docs) docs="no"
91970ec5dc0SAnthony Liguori  ;;
920a25dba17SJuan Quintela  --enable-docs) docs="yes"
92183a3ab8bSJuan Quintela  ;;
922d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
923d5970055SMichael S. Tsirkin  ;;
924d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
925d5970055SMichael S. Tsirkin  ;;
9265e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
9275e9be92dSNicholas Bellinger  ;;
9285e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
9295e9be92dSNicholas Bellinger  ;;
930b1e5fff4SMichael Walle  --disable-glx) glx="no"
93120ff075bSMichael Walle  ;;
932b1e5fff4SMichael Walle  --enable-glx) glx="yes"
93320ff075bSMichael Walle  ;;
934f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
935f27aaf4bSChristian Brunner  ;;
936f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
937f27aaf4bSChristian Brunner  ;;
9388c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
9398c84cf11SSergei Trofimovich  ;;
9408c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
9418c84cf11SSergei Trofimovich  ;;
942111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
943111a38b0SRobert Relyea  ;;
944111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
945111a38b0SRobert Relyea  ;;
9462b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
9472b2325ffSGerd Hoffmann  ;;
9482b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
9492b2325ffSGerd Hoffmann  ;;
95069354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
95169354a83SHans de Goede  ;;
95269354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
95369354a83SHans de Goede  ;;
9541ece9905SAlon Levy  --disable-zlib-test) zlib="no"
9551ece9905SAlon Levy  ;;
956d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
957d138cee9SMichael Roth  ;;
958d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
959d138cee9SMichael Roth  ;;
960d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
961d9840e25STomoki Sekiyama  ;;
962d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
963d9840e25STomoki Sekiyama  ;;
964d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
965d9840e25STomoki Sekiyama  ;;
966d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
967d9840e25STomoki Sekiyama  ;;
968d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
969d9840e25STomoki Sekiyama  ;;
970d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
971d9840e25STomoki Sekiyama  ;;
9724b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
9734b1c11fdSDaniel P. Berrange  ;;
9744b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
9754b1c11fdSDaniel P. Berrange  ;;
976f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
977f794573eSEduardo Otubo  ;;
978f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
979f794573eSEduardo Otubo  ;;
980eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
981eb100396SBharata B Rao  ;;
982eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
983eb100396SBharata B Rao  ;;
984583f6e7bSStefan Hajnoczi  --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
985583f6e7bSStefan Hajnoczi  ;;
986583f6e7bSStefan Hajnoczi  --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
987583f6e7bSStefan Hajnoczi  ;;
988a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
989a4ccabcfSAnthony Liguori  ;;
990a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
991a4ccabcfSAnthony Liguori  ;;
9922da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
9932da776dbSMichael R. Hines  ;;
9942da776dbSMichael R. Hines  --disable-rdma) rdma="no"
9952da776dbSMichael R. Hines  ;;
996528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
997528de90aSDaniel P. Berrange  ;;
998ab214c29SStefan Berger  --enable-tpm) tpm="yes"
999ab214c29SStefan Berger  ;;
10000a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
10010a12ec87SRichard W.M. Jones  ;;
10020a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
10030a12ec87SRichard W.M. Jones  ;;
10044f18b782SJeff Cody  --enable-vhdx) vhdx="yes"
10054f18b782SJeff Cody  ;;
10064f18b782SJeff Cody  --disable-vhdx) vhdx="no"
10074f18b782SJeff Cody  ;;
10087f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
10097f1559c6Sbalrog  ;;
10107d13299dSbellard  esac
10117d13299dSbellarddone
10127d13299dSbellard
1013f6f0b7d9SStefan Weilif ! has $python; then
1014f6f0b7d9SStefan Weil  error_exit "Python not found. Use --python=/path/to/python"
1015f6f0b7d9SStefan Weilfi
1016f6f0b7d9SStefan Weil
1017f6f0b7d9SStefan Weil# Note that if the Python conditional here evaluates True we will exit
1018f6f0b7d9SStefan Weil# with status 1 which is a shell 'false' value.
1019f6f0b7d9SStefan Weilif ! $python -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1020f6f0b7d9SStefan Weil  error_exit "Cannot use '$python', Python 2.4 or later is required." \
1021f6f0b7d9SStefan Weil      "Note that Python 3 or later is not yet supported." \
1022f6f0b7d9SStefan Weil      "Use --python=/path/to/python to specify a supported Python."
1023f6f0b7d9SStefan Weilfi
1024f6f0b7d9SStefan Weil
1025f6f0b7d9SStefan Weil# The -B switch was added in Python 2.6.
1026f6f0b7d9SStefan Weil# If it is supplied, compiled files are not written.
1027f6f0b7d9SStefan Weil# Use it for Python versions which support it.
1028f6f0b7d9SStefan Weilif $python -B -c 'import sys; sys.exit(0)' 2>/dev/null; then
1029f6f0b7d9SStefan Weil  python="$python -B"
1030f6f0b7d9SStefan Weilfi
1031f6f0b7d9SStefan Weil
103240293e58Sbellardcase "$cpu" in
1033e3608d66SRichard Henderson    ppc)
1034e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1035e3608d66SRichard Henderson           LDFLAGS="-m32 $LDFLAGS"
1036e3608d66SRichard Henderson           ;;
1037e3608d66SRichard Henderson    ppc64)
1038e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1039e3608d66SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
1040e3608d66SRichard Henderson           ;;
10419b9c37c3SRichard Henderson    sparc)
10420c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
104379f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32 -mcpu=ultrasparc"
10443142255cSblueswir1           ;;
1045ed968ff1SJuan Quintela    sparc64)
10460c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
104779f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
10483142255cSblueswir1           ;;
104976d83bdeSths    s390)
105079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m31 -march=z990"
105128d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
105228d7cc49SRichard Henderson           ;;
105328d7cc49SRichard Henderson    s390x)
105479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -march=z990"
105528d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
105676d83bdeSths           ;;
105740293e58Sbellard    i386)
105879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
10590c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
10602b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
106140293e58Sbellard           ;;
106240293e58Sbellard    x86_64)
106379f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64"
10640c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
10652b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
1066379f6698SPaul Brook           ;;
1067c72b26ecSRichard Henderson    x32)
1068c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1069c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
1070c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
1071c72b26ecSRichard Henderson           ;;
107230163d89SPeter Maydell    # No special flags required for other host CPUs
10733142255cSblueswir1esac
10743142255cSblueswir1
107579f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
107679f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
107779f3b12fSPeter Crosthwaite
107860e0df25SPeter Maydelldefault_target_list=""
107960e0df25SPeter Maydell
10806e92f823SPeter Maydellmak_wilds=""
10816e92f823SPeter Maydell
108260e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
10836e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
108460e0df25SPeter Maydellfi
108560e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
10866e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
108760e0df25SPeter Maydellfi
108860e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
10896e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
109060e0df25SPeter Maydellfi
109160e0df25SPeter Maydell
10926e92f823SPeter Maydellfor config in $mak_wilds; do
10936e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
10946e92f823SPeter Maydelldone
10956e92f823SPeter Maydell
1096af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1097af5db58eSpbrookcat << EOF
1098af5db58eSpbrook
1099af5db58eSpbrookUsage: configure [options]
1100af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1101af5db58eSpbrook
110208fb77edSStefan WeilStandard options:
110308fb77edSStefan Weil  --help                   print this message
110408fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
110508fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
110608fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
110708fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
110808fb77edSStefan Weil$(echo Available targets: $default_target_list | \
110908fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
111008fb77edSStefan Weil
111108fb77edSStefan WeilAdvanced options (experts only):
111208fb77edSStefan Weil  --source-path=PATH       path of source code [$source_path]
111308fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
111408fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
111508fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
111608fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
111708fb77edSStefan Weil                           build time
111808fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
111908fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
112008fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
112108fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
112208fb77edSStefan Weil  --make=MAKE              use specified make [$make]
112308fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
112408fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
112508fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
112608fb77edSStefan Weil  --static                 enable static build [$static]
112708fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
112808fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
112908fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
113008fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
113108fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
113208fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
113308fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
113408fb77edSStefan Weil  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]
113508fb77edSStefan Weil  --enable-debug-tcg       enable TCG debugging
113608fb77edSStefan Weil  --disable-debug-tcg      disable TCG debugging (default)
113708fb77edSStefan Weil  --enable-debug-info       enable debugging information (default)
113808fb77edSStefan Weil  --disable-debug-info      disable debugging information
113908fb77edSStefan Weil  --enable-debug           enable common debug build options
114008fb77edSStefan Weil  --enable-sparse          enable sparse checker
114108fb77edSStefan Weil  --disable-sparse         disable sparse checker (default)
114208fb77edSStefan Weil  --disable-strip          disable stripping binaries
114308fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
114408fb77edSStefan Weil  --disable-sdl            disable SDL
114508fb77edSStefan Weil  --enable-sdl             enable SDL
114608fb77edSStefan Weil  --disable-gtk            disable gtk UI
114708fb77edSStefan Weil  --enable-gtk             enable gtk UI
114808fb77edSStefan Weil  --disable-virtfs         disable VirtFS
114908fb77edSStefan Weil  --enable-virtfs          enable VirtFS
115008fb77edSStefan Weil  --disable-vnc            disable VNC
115108fb77edSStefan Weil  --enable-vnc             enable VNC
115208fb77edSStefan Weil  --disable-cocoa          disable Cocoa (Mac OS X only)
115308fb77edSStefan Weil  --enable-cocoa           enable Cocoa (default on Mac OS X)
115408fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
115508fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
115608fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
115708fb77edSStefan Weil  --block-drv-rw-whitelist=L
115808fb77edSStefan Weil                           set block driver read-write whitelist
115908fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
116008fb77edSStefan Weil  --block-drv-ro-whitelist=L
116108fb77edSStefan Weil                           set block driver read-only whitelist
116208fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
116308fb77edSStefan Weil  --disable-xen            disable xen backend driver support
116408fb77edSStefan Weil  --enable-xen             enable xen backend driver support
116508fb77edSStefan Weil  --disable-xen-pci-passthrough
116608fb77edSStefan Weil  --enable-xen-pci-passthrough
116708fb77edSStefan Weil  --disable-brlapi         disable BrlAPI
116808fb77edSStefan Weil  --enable-brlapi          enable BrlAPI
116908fb77edSStefan Weil  --disable-vnc-tls        disable TLS encryption for VNC server
117008fb77edSStefan Weil  --enable-vnc-tls         enable TLS encryption for VNC server
117108fb77edSStefan Weil  --disable-vnc-sasl       disable SASL encryption for VNC server
117208fb77edSStefan Weil  --enable-vnc-sasl        enable SASL encryption for VNC server
117308fb77edSStefan Weil  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server
117408fb77edSStefan Weil  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server
117508fb77edSStefan Weil  --disable-vnc-png        disable PNG compression for VNC server (default)
117608fb77edSStefan Weil  --enable-vnc-png         enable PNG compression for VNC server
117708fb77edSStefan Weil  --disable-vnc-ws         disable Websockets support for VNC server
117808fb77edSStefan Weil  --enable-vnc-ws          enable Websockets support for VNC server
117908fb77edSStefan Weil  --disable-curses         disable curses output
118008fb77edSStefan Weil  --enable-curses          enable curses output
118108fb77edSStefan Weil  --disable-curl           disable curl connectivity
118208fb77edSStefan Weil  --enable-curl            enable curl connectivity
118308fb77edSStefan Weil  --disable-fdt            disable fdt device tree
118408fb77edSStefan Weil  --enable-fdt             enable fdt device tree
118508fb77edSStefan Weil  --disable-bluez          disable bluez stack connectivity
118608fb77edSStefan Weil  --enable-bluez           enable bluez stack connectivity
118708fb77edSStefan Weil  --disable-slirp          disable SLIRP userspace network connectivity
118808fb77edSStefan Weil  --disable-kvm            disable KVM acceleration support
118908fb77edSStefan Weil  --enable-kvm             enable KVM acceleration support
119008fb77edSStefan Weil  --disable-rdma           disable RDMA-based migration support
119108fb77edSStefan Weil  --enable-rdma            enable RDMA-based migration support
119208fb77edSStefan Weil  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
119308fb77edSStefan Weil  --enable-system          enable all system emulation targets
119408fb77edSStefan Weil  --disable-system         disable all system emulation targets
119508fb77edSStefan Weil  --enable-user            enable supported user emulation targets
119608fb77edSStefan Weil  --disable-user           disable all user emulation targets
119708fb77edSStefan Weil  --enable-linux-user      enable all linux usermode emulation targets
119808fb77edSStefan Weil  --disable-linux-user     disable all linux usermode emulation targets
119908fb77edSStefan Weil  --enable-bsd-user        enable all BSD usermode emulation targets
120008fb77edSStefan Weil  --disable-bsd-user       disable all BSD usermode emulation targets
120108fb77edSStefan Weil  --enable-guest-base      enable GUEST_BASE support for usermode
120208fb77edSStefan Weil                           emulation targets
120308fb77edSStefan Weil  --disable-guest-base     disable GUEST_BASE support
120408fb77edSStefan Weil  --enable-pie             build Position Independent Executables
120508fb77edSStefan Weil  --disable-pie            do not build Position Independent Executables
120608fb77edSStefan Weil  --fmod-lib               path to FMOD library
120708fb77edSStefan Weil  --fmod-inc               path to FMOD includes
120808fb77edSStefan Weil  --oss-lib                path to OSS library
120908fb77edSStefan Weil  --enable-uname-release=R Return R for uname -r in usermode emulation
121008fb77edSStefan Weil  --cpu=CPU                Build for host CPU [$cpu]
121108fb77edSStefan Weil  --disable-uuid           disable uuid support
121208fb77edSStefan Weil  --enable-uuid            enable uuid support
121308fb77edSStefan Weil  --disable-vde            disable support for vde network
121408fb77edSStefan Weil  --enable-vde             enable support for vde network
121508fb77edSStefan Weil  --disable-netmap         disable support for netmap network
121608fb77edSStefan Weil  --enable-netmap          enable support for netmap network
121708fb77edSStefan Weil  --disable-linux-aio      disable Linux AIO support
121808fb77edSStefan Weil  --enable-linux-aio       enable Linux AIO support
121908fb77edSStefan Weil  --disable-cap-ng         disable libcap-ng support
122008fb77edSStefan Weil  --enable-cap-ng          enable libcap-ng support
122108fb77edSStefan Weil  --disable-attr           disables attr and xattr support
122208fb77edSStefan Weil  --enable-attr            enable attr and xattr support
122308fb77edSStefan Weil  --disable-blobs          disable installing provided firmware blobs
122408fb77edSStefan Weil  --enable-docs            enable documentation build
122508fb77edSStefan Weil  --disable-docs           disable documentation build
122608fb77edSStefan Weil  --disable-vhost-net      disable vhost-net acceleration support
122708fb77edSStefan Weil  --enable-vhost-net       enable vhost-net acceleration support
122808fb77edSStefan Weil  --enable-trace-backend=B Set trace backend
122908fb77edSStefan Weil                           Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
123008fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
123108fb77edSStefan Weil                           Default:trace-<pid>
123208fb77edSStefan Weil  --disable-spice          disable spice
123308fb77edSStefan Weil  --enable-spice           enable spice
123408fb77edSStefan Weil  --enable-rbd             enable building the rados block device (rbd)
123508fb77edSStefan Weil  --disable-libiscsi       disable iscsi support
123608fb77edSStefan Weil  --enable-libiscsi        enable iscsi support
12376542aa9cSPeter Lieven  --disable-libnfs         disable nfs support
12386542aa9cSPeter Lieven  --enable-libnfs          enable nfs support
123908fb77edSStefan Weil  --disable-smartcard-nss  disable smartcard nss support
124008fb77edSStefan Weil  --enable-smartcard-nss   enable smartcard nss support
124108fb77edSStefan Weil  --disable-libusb         disable libusb (for usb passthrough)
124208fb77edSStefan Weil  --enable-libusb          enable libusb (for usb passthrough)
124308fb77edSStefan Weil  --disable-usb-redir      disable usb network redirection support
124408fb77edSStefan Weil  --enable-usb-redir       enable usb network redirection support
124508fb77edSStefan Weil  --disable-guest-agent    disable building of the QEMU Guest Agent
124608fb77edSStefan Weil  --enable-guest-agent     enable building of the QEMU Guest Agent
124708fb77edSStefan Weil  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
124808fb77edSStefan Weil  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
124908fb77edSStefan Weil  --disable-seccomp        disable seccomp support
125008fb77edSStefan Weil  --enable-seccomp         enables seccomp support
125108fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
125208fb77edSStefan Weil                           gthread, ucontext, sigaltstack, windows
125308fb77edSStefan Weil  --disable-coroutine-pool disable coroutine freelist (worse performance)
125408fb77edSStefan Weil  --enable-coroutine-pool  enable coroutine freelist (better performance)
125508fb77edSStefan Weil  --enable-glusterfs       enable GlusterFS backend
125608fb77edSStefan Weil  --disable-glusterfs      disable GlusterFS backend
125708fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
125808fb77edSStefan Weil  --gcov=GCOV              use specified gcov [$gcov_tool]
125908fb77edSStefan Weil  --enable-tpm             enable TPM support
126008fb77edSStefan Weil  --disable-libssh2        disable ssh block device support
126108fb77edSStefan Weil  --enable-libssh2         enable ssh block device support
126208fb77edSStefan Weil  --disable-vhdx           disables support for the Microsoft VHDX image format
126308fb77edSStefan Weil  --enable-vhdx            enable support for the Microsoft VHDX image format
126408fb77edSStefan Weil
126508fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1266af5db58eSpbrookEOF
1267af5db58eSpbrookexit 1
1268af5db58eSpbrookfi
1269af5db58eSpbrook
1270359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1271359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1272359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1273359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1274359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1275359bc95dSPeter Maydell        ARCH=tci
1276359bc95dSPeter Maydell    else
127776ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1278359bc95dSPeter Maydell    fi
1279359bc95dSPeter Maydellfi
1280359bc95dSPeter Maydell
12818d05095cSPaolo Bonzini# check that the C compiler works.
12828d05095cSPaolo Bonzinicat > $TMPC <<EOF
128375cafad7SStefan Weilint main(void) { return 0; }
12848d05095cSPaolo BonziniEOF
12858d05095cSPaolo Bonzini
12868d05095cSPaolo Bonziniif compile_object ; then
12878d05095cSPaolo Bonzini  : C compiler works ok
12888d05095cSPaolo Bonzinielse
128976ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
12908d05095cSPaolo Bonzinifi
12918d05095cSPaolo Bonzini
1292417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1293417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1294417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1295417c9d72SAlexander Graf
1296417c9d72SAlexander Grafif test -z "$werror" ; then
12976c8fec83SAndreas Färber    if test -d "$source_path/.git" -a \
1298417c9d72SAlexander Graf        "$linux" = "yes" ; then
1299417c9d72SAlexander Graf        werror="yes"
1300417c9d72SAlexander Graf    else
1301417c9d72SAlexander Graf        werror="no"
1302417c9d72SAlexander Graf    fi
1303417c9d72SAlexander Graffi
1304417c9d72SAlexander Graf
13058d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
13068d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
13078d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
130837746c5eSMarc-André Lureaugcc_flags="-Wendif-labels $gcc_flags"
1309c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
131071429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
13116ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
13126ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
13136ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
13146ca026cbSPeter Maydell# so it's too error prone.
13158d05095cSPaolo Bonzinicat > $TMPC << EOF
13168d05095cSPaolo Bonziniint main(void) { return 0; }
13178d05095cSPaolo BonziniEOF
13188d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1319a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1320a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1321a1d29d6cSPeter Maydell    # warning options).
1322a1d29d6cSPeter Maydell    optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1323a1d29d6cSPeter Maydell    if compile_prog "-Werror $optflag" "" ; then
13248d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
13258d05095cSPaolo Bonzini    fi
13268d05095cSPaolo Bonzinidone
13278d05095cSPaolo Bonzini
132837746c5eSMarc-André Lureauif compile_prog "-Werror -fstack-protector-all" "" ; then
132937746c5eSMarc-André Lureau    QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
133037746c5eSMarc-André Lureau    LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
133137746c5eSMarc-André Lureaufi
133237746c5eSMarc-André Lureau
1333cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1334cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1335cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1336cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1337cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1338cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1339cbdd1999SPaolo Bonziniint main(void) { return 0; }
1340cbdd1999SPaolo Bonzini#else
1341cbdd1999SPaolo Bonzini#error No bug in this compiler.
1342cbdd1999SPaolo Bonzini#endif
1343cbdd1999SPaolo BonziniEOF
1344cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1345cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1346cbdd1999SPaolo Bonzinifi
1347cbdd1999SPaolo Bonzini
134840d6444eSAvi Kivityif test "$static" = "yes" ; then
134940d6444eSAvi Kivity  if test "$pie" = "yes" ; then
135076ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
135140d6444eSAvi Kivity  else
135240d6444eSAvi Kivity    pie="no"
135340d6444eSAvi Kivity  fi
135440d6444eSAvi Kivityfi
135540d6444eSAvi Kivity
135640d6444eSAvi Kivityif test "$pie" = ""; then
135740d6444eSAvi Kivity  case "$cpu-$targetos" in
1358c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
135940d6444eSAvi Kivity      ;;
136040d6444eSAvi Kivity    *)
136140d6444eSAvi Kivity      pie="no"
136240d6444eSAvi Kivity      ;;
136340d6444eSAvi Kivity  esac
136440d6444eSAvi Kivityfi
136540d6444eSAvi Kivity
136640d6444eSAvi Kivityif test "$pie" != "no" ; then
136740d6444eSAvi Kivity  cat > $TMPC << EOF
136821d4a791SAvi Kivity
136921d4a791SAvi Kivity#ifdef __linux__
137021d4a791SAvi Kivity#  define THREAD __thread
137121d4a791SAvi Kivity#else
137221d4a791SAvi Kivity#  define THREAD
137321d4a791SAvi Kivity#endif
137421d4a791SAvi Kivity
137521d4a791SAvi Kivitystatic THREAD int tls_var;
137621d4a791SAvi Kivity
137721d4a791SAvi Kivityint main(void) { return tls_var; }
137821d4a791SAvi Kivity
137940d6444eSAvi KivityEOF
138040d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
138140d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
138240d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
138340d6444eSAvi Kivity    pie="yes"
138440d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
138540d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
138640d6444eSAvi Kivity    fi
138740d6444eSAvi Kivity  else
138840d6444eSAvi Kivity    if test "$pie" = "yes"; then
138976ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
139040d6444eSAvi Kivity    else
139140d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
139240d6444eSAvi Kivity      pie="no"
139340d6444eSAvi Kivity    fi
139440d6444eSAvi Kivity  fi
139540d6444eSAvi Kivityfi
139640d6444eSAvi Kivity
139709dada40SPaolo Bonzini##########################################
139809dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
139909dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
140009dada40SPaolo Bonzini# specification is necessary
140109dada40SPaolo Bonzini
140209dada40SPaolo Bonziniif test "$cpu" = "i386"; then
140309dada40SPaolo Bonzini  cat > $TMPC << EOF
140409dada40SPaolo Bonzinistatic int sfaa(int *ptr)
140509dada40SPaolo Bonzini{
140609dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
140709dada40SPaolo Bonzini}
140809dada40SPaolo Bonzini
140909dada40SPaolo Bonziniint main(void)
141009dada40SPaolo Bonzini{
141109dada40SPaolo Bonzini  int val = 42;
14121405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
141309dada40SPaolo Bonzini  sfaa(&val);
141409dada40SPaolo Bonzini  return val;
141509dada40SPaolo Bonzini}
141609dada40SPaolo BonziniEOF
141709dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
141809dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
141909dada40SPaolo Bonzini  fi
142009dada40SPaolo Bonzinifi
142109dada40SPaolo Bonzini
142209dada40SPaolo Bonzini#########################################
1423ec530c81Sbellard# Solaris specific configure tool chain decisions
142409dada40SPaolo Bonzini
1425ec530c81Sbellardif test "$solaris" = "yes" ; then
14266792aa11SLoïc Minier  if has $install; then
14276792aa11SLoïc Minier    :
14286792aa11SLoïc Minier  else
142976ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
143076ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
143176ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1432ec530c81Sbellard  fi
14336792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
143476ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
143576ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
143676ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1437ec530c81Sbellard  fi
14386792aa11SLoïc Minier  if has ar; then
14396792aa11SLoïc Minier    :
14406792aa11SLoïc Minier  else
1441ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
144276ad07a4SPeter Maydell      error_exit "No path includes ar" \
144376ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1444ec530c81Sbellard    fi
144576ad07a4SPeter Maydell    error_exit "No path includes ar"
1446ec530c81Sbellard  fi
1447ec530c81Sbellardfi
1448ec530c81Sbellard
1449afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1450121afa9eSAnthony Liguori    target_list="$default_target_list"
1451121afa9eSAnthony Liguorielse
1452121afa9eSAnthony Liguori    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
14535327cf48Sbellardfi
145425b48338SPeter Maydell
145525b48338SPeter Maydell# Check that we recognised the target name; this allows a more
145625b48338SPeter Maydell# friendly error message than if we let it fall through.
145725b48338SPeter Maydellfor target in $target_list; do
145825b48338SPeter Maydell    case " $default_target_list " in
145925b48338SPeter Maydell        *" $target "*)
146025b48338SPeter Maydell            ;;
146125b48338SPeter Maydell        *)
146225b48338SPeter Maydell            error_exit "Unknown target name '$target'"
146325b48338SPeter Maydell            ;;
146425b48338SPeter Maydell    esac
146525b48338SPeter Maydelldone
146625b48338SPeter Maydell
1467f55fe278SPaolo Bonzini# see if system emulation was really requested
1468f55fe278SPaolo Bonzinicase " $target_list " in
1469f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1470f55fe278SPaolo Bonzini  ;;
1471f55fe278SPaolo Bonzini  *) softmmu=no
1472f55fe278SPaolo Bonzini  ;;
1473f55fe278SPaolo Bonziniesac
14745327cf48Sbellard
1475249247c9SJuan Quintelafeature_not_found() {
1476249247c9SJuan Quintela  feature=$1
1477*21684af0SStewart Smith  remedy=$2
1478249247c9SJuan Quintela
147976ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
1480*21684af0SStewart Smith      "configure was not able to find it." \
1481*21684af0SStewart Smith      "$remedy"
1482249247c9SJuan Quintela}
1483249247c9SJuan Quintela
14847d13299dSbellard# ---
14857d13299dSbellard# big/little endian test
14867d13299dSbellardcat > $TMPC << EOF
148761cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
148861cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
148961cc919fSMike Frysingerextern int foo(short *, short *);
149061cc919fSMike Frysingerint main(int argc, char *argv[]) {
149161cc919fSMike Frysinger    return foo(big_endian, little_endian);
14927d13299dSbellard}
14937d13299dSbellardEOF
14947d13299dSbellard
149561cc919fSMike Frysingerif compile_object ; then
149661cc919fSMike Frysinger    if grep -q BiGeNdIaN $TMPO ; then
149761cc919fSMike Frysinger        bigendian="yes"
149861cc919fSMike Frysinger    elif grep -q LiTtLeEnDiAn $TMPO ; then
149961cc919fSMike Frysinger        bigendian="no"
15007d13299dSbellard    else
15017d13299dSbellard        echo big/little test failed
15027d13299dSbellard    fi
15037d13299dSbellardelse
150461cc919fSMike Frysinger    echo big/little test failed
15057d13299dSbellardfi
15067d13299dSbellard
1507b0a47e79SJuan Quintela##########################################
1508779ab5e3SStefan Weil# pkg-config probe
1509779ab5e3SStefan Weil
1510779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
151176ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1512779ab5e3SStefan Weilfi
1513779ab5e3SStefan Weil
1514779ab5e3SStefan Weil##########################################
1515b0a47e79SJuan Quintela# NPTL probe
1516b0a47e79SJuan Quintela
151724cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1518bd0c5661Spbrook  cat > $TMPC <<EOF
1519bd0c5661Spbrook#include <sched.h>
152030813ceaSpbrook#include <linux/futex.h>
1521182eacc0SStefan Weilint main(void) {
1522bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1523bd0c5661Spbrook#error bork
1524bd0c5661Spbrook#endif
1525182eacc0SStefan Weil  return 0;
1526bd0c5661Spbrook}
1527bd0c5661SpbrookEOF
152824cb36a6SPeter Maydell  if ! compile_object ; then
1529*21684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
1530b0a47e79SJuan Quintela  fi
1531bd0c5661Spbrookfi
1532bd0c5661Spbrook
153311d9f695Sbellard##########################################
1534ac62922eSbalrog# zlib check
1535ac62922eSbalrog
15361ece9905SAlon Levyif test "$zlib" != "no" ; then
1537ac62922eSbalrog    cat > $TMPC << EOF
1538ac62922eSbalrog#include <zlib.h>
1539ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1540ac62922eSbalrogEOF
154152166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1542ac62922eSbalrog        :
1543ac62922eSbalrog    else
154476ad07a4SPeter Maydell        error_exit "zlib check failed" \
154576ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1546ac62922eSbalrog    fi
15471ece9905SAlon Levyfi
1548f544a488SPaolo Bonzinilibs_softmmu="$libs_softmmu -lz"
1549ac62922eSbalrog
1550ac62922eSbalrog##########################################
1551f794573eSEduardo Otubo# libseccomp check
1552f794573eSEduardo Otubo
1553f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
155465d5d3f9SStefan Weil    if $pkg_config --atleast-version=2.1.0 libseccomp; then
1555b4451996SMichael Tokarev        libs_softmmu="$libs_softmmu `$pkg_config --libs libseccomp`"
1556372e47e9SAndreas Färber        QEMU_CFLAGS="$QEMU_CFLAGS `$pkg_config --cflags libseccomp`"
1557f794573eSEduardo Otubo	seccomp="yes"
1558f794573eSEduardo Otubo    else
1559f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
1560*21684af0SStewart Smith            feature_not_found "libseccomp" "Install libseccomp devel >= 2.1.0"
1561f794573eSEduardo Otubo	fi
1562e84d5956SYann E. MORIN	seccomp="no"
1563f794573eSEduardo Otubo    fi
1564f794573eSEduardo Otubofi
1565f794573eSEduardo Otubo##########################################
1566e37630caSaliguori# xen probe
1567e37630caSaliguori
1568fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1569b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1570d5b93ddfSAnthony PERARD
157150ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
157250ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
157350ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
157450ced5b3SStefan Weil
157550ced5b3SStefan Weil  # Xen (any)
157650ced5b3SStefan Weil  cat > $TMPC <<EOF
157750ced5b3SStefan Weil#include <xenctrl.h>
157850ced5b3SStefan Weilint main(void) {
157950ced5b3SStefan Weil  return 0;
158050ced5b3SStefan Weil}
158150ced5b3SStefan WeilEOF
158250ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
158350ced5b3SStefan Weil    # Xen not found
158450ced5b3SStefan Weil    if test "$xen" = "yes" ; then
1585*21684af0SStewart Smith      feature_not_found "xen" "Install xen devel"
158650ced5b3SStefan Weil    fi
158750ced5b3SStefan Weil    xen=no
158850ced5b3SStefan Weil
1589d5b93ddfSAnthony PERARD  # Xen unstable
159069deef08SPeter Maydell  elif
159169deef08SPeter Maydell      cat > $TMPC <<EOF &&
1592e37630caSaliguori#include <xenctrl.h>
1593e108a3c1SAnthony PERARD#include <xenstore.h>
1594d5b93ddfSAnthony PERARD#include <stdint.h>
1595d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1596d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1597d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1598d5b93ddfSAnthony PERARD#endif
1599d5b93ddfSAnthony PERARDint main(void) {
1600d5b93ddfSAnthony PERARD  xc_interface *xc;
1601d5b93ddfSAnthony PERARD  xs_daemon_open();
1602d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1603d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1604d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1605b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
16068688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
16078688e065SStefano Stabellini  return 0;
16088688e065SStefano Stabellini}
16098688e065SStefano StabelliniEOF
16108688e065SStefano Stabellini      compile_prog "" "$xen_libs"
161169deef08SPeter Maydell    then
16128688e065SStefano Stabellini    xen_ctrl_version=420
16138688e065SStefano Stabellini    xen=yes
16148688e065SStefano Stabellini
161569deef08SPeter Maydell  elif
161669deef08SPeter Maydell      cat > $TMPC <<EOF &&
16178688e065SStefano Stabellini#include <xenctrl.h>
16188688e065SStefano Stabellini#include <xs.h>
16198688e065SStefano Stabellini#include <stdint.h>
16208688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
16218688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
16228688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
16238688e065SStefano Stabellini#endif
16248688e065SStefano Stabelliniint main(void) {
16258688e065SStefano Stabellini  xs_daemon_open();
16269b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
16278688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
16288688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
16298688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1630d5b93ddfSAnthony PERARD  return 0;
1631d5b93ddfSAnthony PERARD}
1632e37630caSaliguoriEOF
163350ced5b3SStefan Weil      compile_prog "" "$xen_libs"
163469deef08SPeter Maydell    then
1635d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1636fc321b4bSJuan Quintela    xen=yes
1637d5b93ddfSAnthony PERARD
1638d5b93ddfSAnthony PERARD  # Xen 4.0.0
163969deef08SPeter Maydell  elif
164069deef08SPeter Maydell      cat > $TMPC <<EOF &&
1641d5b93ddfSAnthony PERARD#include <xenctrl.h>
1642d5b93ddfSAnthony PERARD#include <xs.h>
1643d5b93ddfSAnthony PERARD#include <stdint.h>
1644d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1645d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1646d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1647d5b93ddfSAnthony PERARD#endif
1648d5b93ddfSAnthony PERARDint main(void) {
1649b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1650b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1651b87de24eSAnthony PERARD  };
1652d5b93ddfSAnthony PERARD  xs_daemon_open();
1653d5b93ddfSAnthony PERARD  xc_interface_open();
1654d5b93ddfSAnthony PERARD  xc_gnttab_open();
1655d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1656b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1657d5b93ddfSAnthony PERARD  return 0;
1658d5b93ddfSAnthony PERARD}
1659d5b93ddfSAnthony PERARDEOF
1660d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
166169deef08SPeter Maydell    then
1662d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1663d5b93ddfSAnthony PERARD    xen=yes
1664d5b93ddfSAnthony PERARD
1665b87de24eSAnthony PERARD  # Xen 3.4.0
166669deef08SPeter Maydell  elif
166769deef08SPeter Maydell      cat > $TMPC <<EOF &&
1668b87de24eSAnthony PERARD#include <xenctrl.h>
1669b87de24eSAnthony PERARD#include <xs.h>
1670b87de24eSAnthony PERARDint main(void) {
1671b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1672b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1673b87de24eSAnthony PERARD  };
1674b87de24eSAnthony PERARD  xs_daemon_open();
1675b87de24eSAnthony PERARD  xc_interface_open();
1676b87de24eSAnthony PERARD  xc_gnttab_open();
1677b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1678b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1679b87de24eSAnthony PERARD  return 0;
1680b87de24eSAnthony PERARD}
1681b87de24eSAnthony PERARDEOF
1682b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
168369deef08SPeter Maydell    then
1684b87de24eSAnthony PERARD    xen_ctrl_version=340
1685b87de24eSAnthony PERARD    xen=yes
1686b87de24eSAnthony PERARD
1687b87de24eSAnthony PERARD  # Xen 3.3.0
168869deef08SPeter Maydell  elif
168969deef08SPeter Maydell      cat > $TMPC <<EOF &&
1690d5b93ddfSAnthony PERARD#include <xenctrl.h>
1691d5b93ddfSAnthony PERARD#include <xs.h>
1692d5b93ddfSAnthony PERARDint main(void) {
1693d5b93ddfSAnthony PERARD  xs_daemon_open();
1694d5b93ddfSAnthony PERARD  xc_interface_open();
1695d5b93ddfSAnthony PERARD  xc_gnttab_open();
1696d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1697d5b93ddfSAnthony PERARD  return 0;
1698d5b93ddfSAnthony PERARD}
1699d5b93ddfSAnthony PERARDEOF
1700d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
170169deef08SPeter Maydell    then
1702d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1703d5b93ddfSAnthony PERARD    xen=yes
1704d5b93ddfSAnthony PERARD
170550ced5b3SStefan Weil  # Xen version unsupported
1706e37630caSaliguori  else
1707fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1708*21684af0SStewart Smith      feature_not_found "xen (unsupported version)" "Install supported xen (e.g. 4.0, 3.4, 3.3)"
1709fc321b4bSJuan Quintela    fi
1710fc321b4bSJuan Quintela    xen=no
1711e37630caSaliguori  fi
1712d5b93ddfSAnthony PERARD
1713d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1714d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1715d5b93ddfSAnthony PERARD  fi
1716e37630caSaliguorifi
1717e37630caSaliguori
1718eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1719eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1720eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1721eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1722eb6fda0fSAnthony PERARD  else
1723eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1724eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
172576ad07a4SPeter Maydell        error_exit "User requested feature Xen PCI Passthrough" \
172676ad07a4SPeter Maydell            "This feature does not work with Xen 3.3"
1727eb6fda0fSAnthony PERARD      fi
172876ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
172976ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
1730eb6fda0fSAnthony PERARD    fi
1731eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1732eb6fda0fSAnthony PERARD  fi
1733eb6fda0fSAnthony PERARDfi
1734eb6fda0fSAnthony PERARD
1735e37630caSaliguori##########################################
173644dc0ca3SAlon Levy# libtool probe
173744dc0ca3SAlon Levy
17383f534581SBradif ! has $libtool; then
173944dc0ca3SAlon Levy    libtool=
174044dc0ca3SAlon Levyfi
174144dc0ca3SAlon Levy
17428e515b12SPeter Maydell# MacOSX ships with a libtool which isn't the GNU one; weed this
17438e515b12SPeter Maydell# out by checking whether libtool supports the --version switch
17448e515b12SPeter Maydellif test -n "$libtool"; then
17458e515b12SPeter Maydell  if ! "$libtool" --version >/dev/null 2>&1; then
17468e515b12SPeter Maydell    libtool=
17478e515b12SPeter Maydell  fi
17488e515b12SPeter Maydellfi
17498e515b12SPeter Maydell
175044dc0ca3SAlon Levy##########################################
1751dfffc653SJuan Quintela# Sparse probe
1752dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
17530dba6195SLoïc Minier  if has cgcc; then
1754dfffc653SJuan Quintela    sparse=yes
1755dfffc653SJuan Quintela  else
1756dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1757*21684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
1758dfffc653SJuan Quintela    fi
1759dfffc653SJuan Quintela    sparse=no
1760dfffc653SJuan Quintela  fi
1761dfffc653SJuan Quintelafi
1762dfffc653SJuan Quintela
1763dfffc653SJuan Quintela##########################################
1764a4ccabcfSAnthony Liguori# GTK probe
1765a4ccabcfSAnthony Liguori
1766a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
1767528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
1768528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
1769528de90aSDaniel P. Berrange      gtkversion="3.0.0"
1770528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
1771528de90aSDaniel P. Berrange      vteversion="0.32.0"
1772528de90aSDaniel P. Berrange    else
1773528de90aSDaniel P. Berrange      gtkversion="2.18.0"
1774528de90aSDaniel P. Berrange      vtepackage="vte"
1775528de90aSDaniel P. Berrange      vteversion="0.24.0"
1776528de90aSDaniel P. Berrange    fi
17770d185e63SPeter Maydell    if ! $pkg_config --exists "$gtkpackage >= $gtkversion"; then
17780d185e63SPeter Maydell        if test "$gtk" = "yes" ; then
1779*21684af0SStewart Smith            feature_not_found "gtk" "Install gtk2 or gtk3 (requires --with-gtkabi=3.0 option to configure) devel"
17800d185e63SPeter Maydell        fi
17810d185e63SPeter Maydell        gtk="no"
17820d185e63SPeter Maydell    elif ! $pkg_config --exists "$vtepackage >= $vteversion"; then
17830d185e63SPeter Maydell        if test "$gtk" = "yes" ; then
17840d185e63SPeter Maydell            error_exit "libvte not found (required for gtk support)"
17850d185e63SPeter Maydell        fi
17860d185e63SPeter Maydell        gtk="no"
17870d185e63SPeter Maydell    else
1788ca871ec8SStefan Weil	gtk_cflags=`$pkg_config --cflags $gtkpackage`
1789ca871ec8SStefan Weil	gtk_libs=`$pkg_config --libs $gtkpackage`
1790ca871ec8SStefan Weil	vte_cflags=`$pkg_config --cflags $vtepackage`
1791ca871ec8SStefan Weil	vte_libs=`$pkg_config --libs $vtepackage`
1792a4ccabcfSAnthony Liguori	libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
1793a4ccabcfSAnthony Liguori	gtk="yes"
1794a4ccabcfSAnthony Liguori    fi
1795a4ccabcfSAnthony Liguorifi
1796a4ccabcfSAnthony Liguori
1797a4ccabcfSAnthony Liguori##########################################
179811d9f695Sbellard# SDL probe
179911d9f695Sbellard
18003ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
18013ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
18023ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
18033ec87ffeSPaolo Bonzini  sdl_config=sdl-config
18043ec87ffeSPaolo Bonzinifi
18053ec87ffeSPaolo Bonzini
180665d5d3f9SStefan Weilif $pkg_config sdl --exists; then
1807a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1808fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
18093ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
18103ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
18119316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1812a0dfd8a4SLoïc Minierelse
1813a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1814*21684af0SStewart Smith    feature_not_found "sdl" "Install SDL devel"
1815a0dfd8a4SLoïc Minier  fi
1816a0dfd8a4SLoïc Minier  sdl=no
18179316f803SPaolo Bonzinifi
181829e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
18193ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
18203ec87ffeSPaolo Bonzinifi
182111d9f695Sbellard
18229316f803SPaolo Bonzinisdl_too_old=no
1823c4198157SJuan Quintelaif test "$sdl" != "no" ; then
182411d9f695Sbellard  cat > $TMPC << EOF
182511d9f695Sbellard#include <SDL.h>
182611d9f695Sbellard#undef main /* We don't want SDL to override our main() */
182711d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
182811d9f695SbellardEOF
18299316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
183074f42e18STeLeMan  if test "$static" = "yes" ; then
183174f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
183274f42e18STeLeMan  else
18339316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
183474f42e18STeLeMan  fi
183552166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
183611d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
183711d9f695Sbellard      sdl_too_old=yes
183811d9f695Sbellard    else
1839fd677642Sths      if test "$cocoa" = "no" ; then
184011d9f695Sbellard        sdl=yes
184111d9f695Sbellard      fi
1842fd677642Sths    fi
18437c1f25b4Sbellard
184467c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
18451ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
184667c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1847f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1848f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
184911d9f695Sbellard      fi
185052166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
18511ac88f28SJuan Quintela	:
18521ac88f28SJuan Quintela      else
18531ac88f28SJuan Quintela        sdl=no
18547c1f25b4Sbellard      fi
18557c1f25b4Sbellard    fi # static link
1856c4198157SJuan Quintela  else # sdl not found
1857c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1858*21684af0SStewart Smith      feature_not_found "sdl" "Install SDL devel"
1859c4198157SJuan Quintela    fi
1860c4198157SJuan Quintela    sdl=no
18617c1f25b4Sbellard  fi # sdl compile test
1862fd677642Sthsfi
186311d9f695Sbellard
18645368a422Saliguoriif test "$sdl" = "yes" ; then
18655368a422Saliguori  cat > $TMPC <<EOF
18665368a422Saliguori#include <SDL.h>
18675368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
18685368a422Saliguori#include <X11/XKBlib.h>
18695368a422Saliguori#else
18705368a422Saliguori#error No x11 support
18715368a422Saliguori#endif
18725368a422Saliguoriint main(void) { return 0; }
18735368a422SaliguoriEOF
187452166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1875681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
18765368a422Saliguori  fi
18770705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
18785368a422Saliguorifi
18795368a422Saliguori
18808f28f3fbSths##########################################
18812da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
18822da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
18832da776dbSMichael R. Hines  cat > $TMPC <<EOF
18842da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
18852da776dbSMichael R. Hinesint main(void) { return 0; }
18862da776dbSMichael R. HinesEOF
18872da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
18882da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
18892da776dbSMichael R. Hines    rdma="yes"
18902da776dbSMichael R. Hines    libs_softmmu="$libs_softmmu $rdma_libs"
18912da776dbSMichael R. Hines  else
18922da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
18932da776dbSMichael R. Hines        error_exit \
18942da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
18952da776dbSMichael R. Hines            " Your options:" \
18962da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
18972da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
18982da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
18992da776dbSMichael R. Hines    fi
19002da776dbSMichael R. Hines    rdma="no"
19012da776dbSMichael R. Hines  fi
19022da776dbSMichael R. Hinesfi
19032da776dbSMichael R. Hines
19042da776dbSMichael R. Hines##########################################
19057536ee4bSTim Hardeck# VNC TLS/WS detection
19067536ee4bSTim Hardeckif test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then
1907ae6b5e5aSaliguori  cat > $TMPC <<EOF
1908ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1909ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1910ae6b5e5aSaliguoriEOF
1911a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1912a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
191352166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
19147536ee4bSTim Hardeck    if test "$vnc_tls" != "no" ; then
19151be10ad2SJuan Quintela      vnc_tls=yes
19167536ee4bSTim Hardeck    fi
19177536ee4bSTim Hardeck    if test "$vnc_ws" != "no" ; then
19187536ee4bSTim Hardeck      vnc_ws=yes
19197536ee4bSTim Hardeck    fi
1920a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1921ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
1922ae6b5e5aSaliguori  else
19231be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
1924*21684af0SStewart Smith      feature_not_found "vnc-tls" "Install gnutls devel"
19251be10ad2SJuan Quintela    fi
19267536ee4bSTim Hardeck    if test "$vnc_ws" = "yes" ; then
1927*21684af0SStewart Smith      feature_not_found "vnc-ws" "Install gnutls devel"
19287536ee4bSTim Hardeck    fi
19291be10ad2SJuan Quintela    vnc_tls=no
19307536ee4bSTim Hardeck    vnc_ws=no
19318d5d2d4cSths  fi
19328d5d2d4cSthsfi
19338d5d2d4cSths
19348d5d2d4cSths##########################################
19352f9606b3Saliguori# VNC SASL detection
1936821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
19372f9606b3Saliguori  cat > $TMPC <<EOF
19382f9606b3Saliguori#include <sasl/sasl.h>
19392f9606b3Saliguori#include <stdio.h>
19402f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
19412f9606b3SaliguoriEOF
19422f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
19432f9606b3Saliguori  vnc_sasl_cflags=""
19442f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
194552166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1946ea784e3bSJuan Quintela    vnc_sasl=yes
1947fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1948ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
19492f9606b3Saliguori  else
1950ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1951*21684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
1952ea784e3bSJuan Quintela    fi
1953ea784e3bSJuan Quintela    vnc_sasl=no
19542f9606b3Saliguori  fi
19552f9606b3Saliguorifi
19562f9606b3Saliguori
19572f9606b3Saliguori##########################################
19582f6f5c7aSCorentin Chary# VNC JPEG detection
1959821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
19602f6f5c7aSCorentin Charycat > $TMPC <<EOF
19612f6f5c7aSCorentin Chary#include <stdio.h>
19622f6f5c7aSCorentin Chary#include <jpeglib.h>
19632f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
19642f6f5c7aSCorentin CharyEOF
19652f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
19662f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
19672f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
19682f6f5c7aSCorentin Chary    vnc_jpeg=yes
19692f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1970ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
19712f6f5c7aSCorentin Chary  else
19722f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
1973*21684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
19742f6f5c7aSCorentin Chary    fi
19752f6f5c7aSCorentin Chary    vnc_jpeg=no
19762f6f5c7aSCorentin Chary  fi
19772f6f5c7aSCorentin Charyfi
19782f6f5c7aSCorentin Chary
19792f6f5c7aSCorentin Chary##########################################
1980efe556adSCorentin Chary# VNC PNG detection
1981821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1982efe556adSCorentin Charycat > $TMPC <<EOF
1983efe556adSCorentin Chary//#include <stdio.h>
1984efe556adSCorentin Chary#include <png.h>
1985832ce9c2SScott Wood#include <stddef.h>
1986efe556adSCorentin Charyint main(void) {
1987efe556adSCorentin Chary    png_structp png_ptr;
1988efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
19897edc3fedSPeter Maydell    return png_ptr != 0;
1990efe556adSCorentin Chary}
1991efe556adSCorentin CharyEOF
199265d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
1993ca871ec8SStefan Weil    vnc_png_cflags=`$pkg_config libpng --cflags`
1994ca871ec8SStefan Weil    vnc_png_libs=`$pkg_config libpng --libs`
19959af8025eSBrad  else
1996efe556adSCorentin Chary    vnc_png_cflags=""
1997efe556adSCorentin Chary    vnc_png_libs="-lpng"
19989af8025eSBrad  fi
1999efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2000efe556adSCorentin Chary    vnc_png=yes
2001efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
20029af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2003efe556adSCorentin Chary  else
2004efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
2005*21684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
2006efe556adSCorentin Chary    fi
2007efe556adSCorentin Chary    vnc_png=no
2008efe556adSCorentin Chary  fi
2009efe556adSCorentin Charyfi
2010efe556adSCorentin Chary
2011efe556adSCorentin Chary##########################################
201276655d6dSaliguori# fnmatch() probe, used for ACL routines
201376655d6dSaliguorifnmatch="no"
201476655d6dSaliguoricat > $TMPC << EOF
201576655d6dSaliguori#include <fnmatch.h>
201676655d6dSaliguoriint main(void)
201776655d6dSaliguori{
201876655d6dSaliguori    fnmatch("foo", "foo", 0);
201976655d6dSaliguori    return 0;
202076655d6dSaliguori}
202176655d6dSaliguoriEOF
202252166aa0SJuan Quintelaif compile_prog "" "" ; then
202376655d6dSaliguori   fnmatch="yes"
202476655d6dSaliguorifi
202576655d6dSaliguori
202676655d6dSaliguori##########################################
2027ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
20282d16c8e9SPeter Maydell# Note that on some systems (notably MacOSX) no extra library
20292d16c8e9SPeter Maydell# need be linked to get the uuid functions.
2030ee682d27SStefan Weilif test "$uuid" != "no" ; then
2031ee682d27SStefan Weil  uuid_libs="-luuid"
2032ee682d27SStefan Weil  cat > $TMPC << EOF
2033ee682d27SStefan Weil#include <uuid/uuid.h>
2034ee682d27SStefan Weilint main(void)
2035ee682d27SStefan Weil{
2036ee682d27SStefan Weil    uuid_t my_uuid;
2037ee682d27SStefan Weil    uuid_generate(my_uuid);
2038ee682d27SStefan Weil    return 0;
2039ee682d27SStefan Weil}
2040ee682d27SStefan WeilEOF
20412d16c8e9SPeter Maydell  if compile_prog "" "" ; then
20422d16c8e9SPeter Maydell    uuid="yes"
20432d16c8e9SPeter Maydell  elif compile_prog "" "$uuid_libs" ; then
2044ee682d27SStefan Weil    uuid="yes"
2045ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
2046ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
2047ee682d27SStefan Weil  else
2048ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
2049*21684af0SStewart Smith      feature_not_found "uuid" "Install libuuid devel"
2050ee682d27SStefan Weil    fi
2051ee682d27SStefan Weil    uuid=no
2052ee682d27SStefan Weil  fi
2053ee682d27SStefan Weilfi
2054ee682d27SStefan Weil
20554f18b782SJeff Codyif test "$vhdx" = "yes" ; then
20564f18b782SJeff Cody    if test "$uuid" = "no" ; then
20574f18b782SJeff Cody        error_exit "uuid required for VHDX support"
20584f18b782SJeff Cody    fi
20594f18b782SJeff Codyelif test "$vhdx" != "no" ; then
20604f18b782SJeff Cody    if test "$uuid" = "yes" ; then
20614f18b782SJeff Cody        vhdx=yes
20624f18b782SJeff Cody    else
20634f18b782SJeff Cody        vhdx=no
20644f18b782SJeff Cody    fi
20654f18b782SJeff Codyfi
20664f18b782SJeff Cody
2067ee682d27SStefan Weil##########################################
2068dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
2069dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2070dce512deSChristoph Hellwig  cat > $TMPC << EOF
2071ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2072dce512deSChristoph Hellwig#include <xfs/xfs.h>
2073dce512deSChristoph Hellwigint main(void)
2074dce512deSChristoph Hellwig{
2075dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2076dce512deSChristoph Hellwig    return 0;
2077dce512deSChristoph Hellwig}
2078dce512deSChristoph HellwigEOF
2079dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2080dce512deSChristoph Hellwig    xfs="yes"
2081dce512deSChristoph Hellwig  else
2082dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
2083*21684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2084dce512deSChristoph Hellwig    fi
2085dce512deSChristoph Hellwig    xfs=no
2086dce512deSChristoph Hellwig  fi
2087dce512deSChristoph Hellwigfi
2088dce512deSChristoph Hellwig
2089dce512deSChristoph Hellwig##########################################
20908a16d273Sths# vde libraries probe
2091dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
20924baae0acSJuan Quintela  vde_libs="-lvdeplug"
20938a16d273Sths  cat > $TMPC << EOF
20948a16d273Sths#include <libvdeplug.h>
20954a7f0e06Spbrookint main(void)
20964a7f0e06Spbrook{
20974a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2098fea08e08SPeter Maydell    char s[] = "";
2099fea08e08SPeter Maydell    vde_open(s, s, &a);
21004a7f0e06Spbrook    return 0;
21014a7f0e06Spbrook}
21028a16d273SthsEOF
210352166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
21044baae0acSJuan Quintela    vde=yes
21058e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
21068e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2107dfb278bdSJuan Quintela  else
2108dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
2109*21684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2110dfb278bdSJuan Quintela    fi
2111dfb278bdSJuan Quintela    vde=no
21128a16d273Sths  fi
21138a16d273Sthsfi
21148a16d273Sths
21158a16d273Sths##########################################
211658952137SVincenzo Maffione# netmap headers probe
211758952137SVincenzo Maffioneif test "$netmap" != "no" ; then
211858952137SVincenzo Maffione  cat > $TMPC << EOF
211958952137SVincenzo Maffione#include <inttypes.h>
212058952137SVincenzo Maffione#include <net/if.h>
212158952137SVincenzo Maffione#include <net/netmap.h>
212258952137SVincenzo Maffione#include <net/netmap_user.h>
212358952137SVincenzo Maffioneint main(void) { return 0; }
212458952137SVincenzo MaffioneEOF
212558952137SVincenzo Maffione  if compile_prog "" "" ; then
212658952137SVincenzo Maffione    netmap=yes
212758952137SVincenzo Maffione  else
212858952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
212958952137SVincenzo Maffione      feature_not_found "netmap"
213058952137SVincenzo Maffione    fi
213158952137SVincenzo Maffione    netmap=no
213258952137SVincenzo Maffione  fi
213358952137SVincenzo Maffionefi
213458952137SVincenzo Maffione
213558952137SVincenzo Maffione##########################################
213647e98658SCorey Bryant# libcap-ng library probe
213747e98658SCorey Bryantif test "$cap_ng" != "no" ; then
213847e98658SCorey Bryant  cap_libs="-lcap-ng"
213947e98658SCorey Bryant  cat > $TMPC << EOF
214047e98658SCorey Bryant#include <cap-ng.h>
214147e98658SCorey Bryantint main(void)
214247e98658SCorey Bryant{
214347e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
214447e98658SCorey Bryant    return 0;
214547e98658SCorey Bryant}
214647e98658SCorey BryantEOF
214747e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
214847e98658SCorey Bryant    cap_ng=yes
214947e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
215047e98658SCorey Bryant  else
215147e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
2152*21684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
215347e98658SCorey Bryant    fi
215447e98658SCorey Bryant    cap_ng=no
215547e98658SCorey Bryant  fi
215647e98658SCorey Bryantfi
215747e98658SCorey Bryant
215847e98658SCorey Bryant##########################################
2159c2de5c91Smalc# Sound support libraries probe
21608f28f3fbSths
2161c2de5c91Smalcaudio_drv_probe()
2162c2de5c91Smalc{
2163c2de5c91Smalc    drv=$1
2164c2de5c91Smalc    hdr=$2
2165c2de5c91Smalc    lib=$3
2166c2de5c91Smalc    exp=$4
2167c2de5c91Smalc    cfl=$5
21688f28f3fbSths        cat > $TMPC << EOF
2169c2de5c91Smalc#include <$hdr>
2170c2de5c91Smalcint main(void) { $exp }
21718f28f3fbSthsEOF
217252166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
21738f28f3fbSths        :
21748f28f3fbSths    else
217576ad07a4SPeter Maydell        error_exit "$drv check failed" \
217676ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
21778f28f3fbSths    fi
2178c2de5c91Smalc}
2179c2de5c91Smalc
21802fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
2181c2de5c91Smalcfor drv in $audio_drv_list; do
2182c2de5c91Smalc    case $drv in
2183c2de5c91Smalc    alsa)
2184c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
2185e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
2186a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
2187c2de5c91Smalc    ;;
2188c2de5c91Smalc
2189c2de5c91Smalc    fmod)
2190c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
219176ad07a4SPeter Maydell        error_exit "You must specify path to FMOD library and headers" \
219276ad07a4SPeter Maydell            "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
21938f28f3fbSths    fi
2194c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
2195a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
2196c2de5c91Smalc    ;;
2197c2de5c91Smalc
2198c2de5c91Smalc    esd)
2199c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
2200a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
220167f86e8eSJuan Quintela    audio_pt_int="yes"
2202c2de5c91Smalc    ;;
2203b8e59f18Smalc
2204b8e59f18Smalc    pa)
2205a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
2206a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
2207a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
220867f86e8eSJuan Quintela    audio_pt_int="yes"
2209b8e59f18Smalc    ;;
2210b8e59f18Smalc
2211997e690aSJuan Quintela    coreaudio)
2212997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
2213997e690aSJuan Quintela    ;;
2214997e690aSJuan Quintela
2215a4bf6780SJuan Quintela    dsound)
2216a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2217d5631638Smalc      audio_win_int="yes"
2218a4bf6780SJuan Quintela    ;;
2219a4bf6780SJuan Quintela
2220a4bf6780SJuan Quintela    oss)
2221a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
2222a4bf6780SJuan Quintela    ;;
2223a4bf6780SJuan Quintela
2224a4bf6780SJuan Quintela    sdl|wav)
22252f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
22262f6a1ab0Sblueswir1    ;;
22272f6a1ab0Sblueswir1
2228d5631638Smalc    winwave)
2229d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
2230d5631638Smalc      audio_win_int="yes"
2231d5631638Smalc    ;;
2232d5631638Smalc
2233e4c63a6aSmalc    *)
22341c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
223576ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
223676ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
2237e4c63a6aSmalc    }
2238e4c63a6aSmalc    ;;
2239c2de5c91Smalc    esac
2240c2de5c91Smalcdone
22418f28f3fbSths
22424d3b6f6eSbalrog##########################################
22432e4d9fb1Saurel32# BrlAPI probe
22442e4d9fb1Saurel32
22454ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2246eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
22472e4d9fb1Saurel32  cat > $TMPC << EOF
22482e4d9fb1Saurel32#include <brlapi.h>
2249832ce9c2SScott Wood#include <stddef.h>
22502e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
22512e4d9fb1Saurel32EOF
225252166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
22532e4d9fb1Saurel32    brlapi=yes
2254264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
22554ffcedb6SJuan Quintela  else
22564ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
2257*21684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
22584ffcedb6SJuan Quintela    fi
22594ffcedb6SJuan Quintela    brlapi=no
2260eb82284fSJuan Quintela  fi
2261eb82284fSJuan Quintelafi
22622e4d9fb1Saurel32
22632e4d9fb1Saurel32##########################################
22644d3b6f6eSbalrog# curses probe
2265a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
2266e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
2267e095e2f3SStefan Weil    curses_list="-lpdcurses"
2268e095e2f3SStefan Weil  else
2269cfeda5f4SEd Maste    curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
2270e095e2f3SStefan Weil  fi
2271c584a6d0SJuan Quintela  curses_found=no
22724d3b6f6eSbalrog  cat > $TMPC << EOF
22734d3b6f6eSbalrog#include <curses.h>
2274ef9a2524SStefan Weilint main(void) {
2275ef9a2524SStefan Weil  const char *s = curses_version();
2276ef9a2524SStefan Weil  resize_term(0, 0);
2277ef9a2524SStefan Weil  return s != 0;
2278ef9a2524SStefan Weil}
22794d3b6f6eSbalrogEOF
2280ecbe251fSVadim Evard  IFS=:
22814f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
2282ecbe251fSVadim Evard    unset IFS
22834f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2284c584a6d0SJuan Quintela      curses_found=yes
22854f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
22864f78ef9aSJuan Quintela      break
22874d3b6f6eSbalrog    fi
22884f78ef9aSJuan Quintela  done
2289ecbe251fSVadim Evard  unset IFS
2290c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2291c584a6d0SJuan Quintela    curses=yes
2292c584a6d0SJuan Quintela  else
2293c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
2294*21684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
2295c584a6d0SJuan Quintela    fi
2296c584a6d0SJuan Quintela    curses=no
2297c584a6d0SJuan Quintela  fi
22984f78ef9aSJuan Quintelafi
22994d3b6f6eSbalrog
2300414f0dabSblueswir1##########################################
2301769ce76dSAlexander Graf# curl probe
2302a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
230365d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
2304a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
23054e2b0658SPaolo Bonzini  else
23064e2b0658SPaolo Bonzini    curlconfig=curl-config
23074e2b0658SPaolo Bonzini  fi
2308769ce76dSAlexander Graf  cat > $TMPC << EOF
2309769ce76dSAlexander Graf#include <curl/curl.h>
23100b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2311769ce76dSAlexander GrafEOF
23124e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
23134e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2314b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2315769ce76dSAlexander Graf    curl=yes
2316f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2317f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2318788c8196SJuan Quintela  else
2319788c8196SJuan Quintela    if test "$curl" = "yes" ; then
2320*21684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
2321788c8196SJuan Quintela    fi
2322788c8196SJuan Quintela    curl=no
2323769ce76dSAlexander Graf  fi
2324769ce76dSAlexander Graffi # test "$curl"
2325769ce76dSAlexander Graf
2326769ce76dSAlexander Graf##########################################
2327fb599c9aSbalrog# bluez support probe
2328a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2329e820e3f4Sbalrog  cat > $TMPC << EOF
2330e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2331e820e3f4Sbalrogint main(void) { return bt_error(0); }
2332e820e3f4SbalrogEOF
2333a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2334a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
233552166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2336a20a6f46SJuan Quintela    bluez=yes
2337e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2338e820e3f4Sbalrog  else
2339a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
2340*21684af0SStewart Smith      feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
2341a20a6f46SJuan Quintela    fi
2342e820e3f4Sbalrog    bluez="no"
2343e820e3f4Sbalrog  fi
2344fb599c9aSbalrogfi
2345fb599c9aSbalrog
2346fb599c9aSbalrog##########################################
2347e18df141SAnthony Liguori# glib support probe
2348a52d28afSPaolo Bonzini
2349a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2350a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2351a52d28afSPaolo Bonzini    glib_req_ver=2.20
2352a52d28afSPaolo Bonzinielse
2353a52d28afSPaolo Bonzini    glib_req_ver=2.12
2354a52d28afSPaolo Bonzinifi
235565d5d3f9SStefan Weilif $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then
2356ca871ec8SStefan Weil    glib_cflags=`$pkg_config --cflags gthread-2.0`
2357ca871ec8SStefan Weil    glib_libs=`$pkg_config --libs gthread-2.0`
235814015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2359957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2360e18df141SAnthony Liguorielse
236176ad07a4SPeter Maydell    error_exit "glib-$glib_req_ver required to compile QEMU"
2362e18df141SAnthony Liguorifi
2363e18df141SAnthony Liguori
2364e18df141SAnthony Liguori##########################################
2365e2134eb9SGerd Hoffmann# pixman support probe
2366e2134eb9SGerd Hoffmann
2367e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
236874880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
236974880fe2SRobert Schiele    pixman="none"
237074880fe2SRobert Schiele  elif $pkg_config pixman-1 > /dev/null 2>&1; then
2371e2134eb9SGerd Hoffmann    pixman="system"
2372e2134eb9SGerd Hoffmann  else
2373e2134eb9SGerd Hoffmann    pixman="internal"
2374e2134eb9SGerd Hoffmann  fi
2375e2134eb9SGerd Hoffmannfi
237674880fe2SRobert Schieleif test "$pixman" = "none"; then
237774880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
237876ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
237976ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
238076ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
238176ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
238274880fe2SRobert Schiele  fi
238374880fe2SRobert Schiele  pixman_cflags=
238474880fe2SRobert Schiele  pixman_libs=
238574880fe2SRobert Schieleelif test "$pixman" = "system"; then
2386ca871ec8SStefan Weil  pixman_cflags=`$pkg_config --cflags pixman-1`
2387ca871ec8SStefan Weil  pixman_libs=`$pkg_config --libs pixman-1`
2388e2134eb9SGerd Hoffmannelse
2389e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
239076ad07a4SPeter Maydell    error_exit "pixman not present. Your options:" \
239176ad07a4SPeter Maydell        "  (1) Preferred: Install the pixman devel package (any recent" \
239276ad07a4SPeter Maydell        "      distro should have packages as Xorg needs pixman too)." \
239376ad07a4SPeter Maydell        "  (2) Fetch the pixman submodule, using:" \
239476ad07a4SPeter Maydell        "      git submodule update --init pixman"
2395e2134eb9SGerd Hoffmann  fi
23965ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
23975ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
23985ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2399e2134eb9SGerd Hoffmannfi
2400e2134eb9SGerd Hoffmann
2401e2134eb9SGerd Hoffmann##########################################
240217bff52bSM. Mohan Kumar# libcap probe
240317bff52bSM. Mohan Kumar
240417bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
240517bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
240617bff52bSM. Mohan Kumar#include <stdio.h>
240717bff52bSM. Mohan Kumar#include <sys/capability.h>
2408cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
240917bff52bSM. Mohan KumarEOF
241017bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
241117bff52bSM. Mohan Kumar    cap=yes
241217bff52bSM. Mohan Kumar  else
241317bff52bSM. Mohan Kumar    cap=no
241417bff52bSM. Mohan Kumar  fi
241517bff52bSM. Mohan Kumarfi
241617bff52bSM. Mohan Kumar
241717bff52bSM. Mohan Kumar##########################################
2418e5d355d1Saliguori# pthread probe
24194b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
24203c529d93Saliguori
2421e5d355d1Saliguoripthread=no
2422414f0dabSblueswir1cat > $TMPC << EOF
24233c529d93Saliguori#include <pthread.h>
24247a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
24257a42bbe4SStefan Weilint main(void) {
24267a42bbe4SStefan Weil  pthread_t thread;
24277a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
24287a42bbe4SStefan Weil  return 0;
24297a42bbe4SStefan Weil}
2430414f0dabSblueswir1EOF
2431bd00d539SAndreas Färberif compile_prog "" "" ; then
2432bd00d539SAndreas Färber  pthread=yes
2433bd00d539SAndreas Färberelse
2434de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
243552166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2436e5d355d1Saliguori      pthread=yes
2437e3c56761SPeter Portante      found=no
2438e3c56761SPeter Portante      for lib_entry in $LIBS; do
2439e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2440e3c56761SPeter Portante          found=yes
2441e3c56761SPeter Portante          break
2442e3c56761SPeter Portante        fi
2443e3c56761SPeter Portante      done
2444e3c56761SPeter Portante      if test "$found" = "no"; then
24455572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2446e3c56761SPeter Portante      fi
2447de65fe0fSSebastian Herbszt      break
2448414f0dabSblueswir1    fi
2449de65fe0fSSebastian Herbszt  done
2450bd00d539SAndreas Färberfi
2451414f0dabSblueswir1
24524617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
245376ad07a4SPeter Maydell  error_exit "pthread check failed" \
245476ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
2455e5d355d1Saliguorifi
2456e5d355d1Saliguori
2457bf9298b9Saliguori##########################################
2458f27aaf4bSChristian Brunner# rbd probe
2459f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2460f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2461f27aaf4bSChristian Brunner#include <stdio.h>
2462ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2463f27aaf4bSChristian Brunnerint main(void) {
2464ad32e9c0SJosh Durgin    rados_t cluster;
2465ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2466f27aaf4bSChristian Brunner    return 0;
2467f27aaf4bSChristian Brunner}
2468f27aaf4bSChristian BrunnerEOF
2469ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2470f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2471f27aaf4bSChristian Brunner    rbd=yes
2472f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2473f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2474f27aaf4bSChristian Brunner  else
2475f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
2476*21684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
2477f27aaf4bSChristian Brunner    fi
2478f27aaf4bSChristian Brunner    rbd=no
2479f27aaf4bSChristian Brunner  fi
2480f27aaf4bSChristian Brunnerfi
2481f27aaf4bSChristian Brunner
2482f27aaf4bSChristian Brunner##########################################
24830a12ec87SRichard W.M. Jones# libssh2 probe
24844fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
24850a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
248665d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
24870a12ec87SRichard W.M. Jones    libssh2_cflags=`$pkg_config libssh2 --cflags`
24880a12ec87SRichard W.M. Jones    libssh2_libs=`$pkg_config libssh2 --libs`
24890a12ec87SRichard W.M. Jones    libssh2=yes
24900a12ec87SRichard W.M. Jones    libs_tools="$libssh2_libs $libs_tools"
24910a12ec87SRichard W.M. Jones    libs_softmmu="$libssh2_libs $libs_softmmu"
24920a12ec87SRichard W.M. Jones    QEMU_CFLAGS="$QEMU_CFLAGS $libssh2_cflags"
24930a12ec87SRichard W.M. Jones  else
24940a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
24954fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
24960a12ec87SRichard W.M. Jones    fi
24970a12ec87SRichard W.M. Jones    libssh2=no
24980a12ec87SRichard W.M. Jones  fi
24990a12ec87SRichard W.M. Jonesfi
25000a12ec87SRichard W.M. Jones
25010a12ec87SRichard W.M. Jones##########################################
25029a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
25039a2d462eSRichard W.M. Jones
25049a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
25059a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
25069a2d462eSRichard W.M. Jones#include <stdio.h>
25079a2d462eSRichard W.M. Jones#include <libssh2.h>
25089a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
25099a2d462eSRichard W.M. Jonesint main(void) {
25109a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
25119a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
25129a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
25139a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
25149a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
25159a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
25169a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
25179a2d462eSRichard W.M. Jones    return 0;
25189a2d462eSRichard W.M. Jones}
25199a2d462eSRichard W.M. JonesEOF
25209a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
25219a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
25229a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
25239a2d462eSRichard W.M. Jones  fi
25249a2d462eSRichard W.M. Jonesfi
25259a2d462eSRichard W.M. Jones
25269a2d462eSRichard W.M. Jones##########################################
25275c6c3a6cSChristoph Hellwig# linux-aio probe
25285c6c3a6cSChristoph Hellwig
25295c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
25305c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
25315c6c3a6cSChristoph Hellwig#include <libaio.h>
25325c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2533832ce9c2SScott Wood#include <stddef.h>
25345c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
25355c6c3a6cSChristoph HellwigEOF
25365c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
25375c6c3a6cSChristoph Hellwig    linux_aio=yes
2538048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2539048d179fSPaul Brook    libs_tools="$libs_tools -laio"
25405c6c3a6cSChristoph Hellwig  else
25415c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
2542*21684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
25435c6c3a6cSChristoph Hellwig    fi
25443cfcae3cSLuiz Capitulino    linux_aio=no
25455c6c3a6cSChristoph Hellwig  fi
25465c6c3a6cSChristoph Hellwigfi
25475c6c3a6cSChristoph Hellwig
25485c6c3a6cSChristoph Hellwig##########################################
25493b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
25503b8acc11SPaolo Bonzini
25513b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
25523b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
25533b8acc11SPaolo Bonzinielse
25543b8acc11SPaolo Bonzini  tpm_passthrough=no
25553b8acc11SPaolo Bonzinifi
25563b8acc11SPaolo Bonzini
25573b8acc11SPaolo Bonzini##########################################
2558583f6e7bSStefan Hajnoczi# adjust virtio-blk-data-plane based on linux-aio
2559583f6e7bSStefan Hajnoczi
2560583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" -a \
2561583f6e7bSStefan Hajnoczi	"$linux_aio" != "yes" ; then
256276ad07a4SPeter Maydell  error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
2563583f6e7bSStefan Hajnoczielif test -z "$virtio_blk_data_plane" ; then
2564583f6e7bSStefan Hajnoczi  virtio_blk_data_plane=$linux_aio
2565583f6e7bSStefan Hajnoczifi
2566583f6e7bSStefan Hajnoczi
2567583f6e7bSStefan Hajnoczi##########################################
2568758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2569758e8e38SVenkateswararao Jujjuri (JV)
2570758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2571758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2572758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2573758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2574f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2575f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2576f2338fb4SPavel Borzenkov#else
25774f26f2b6SAvi Kivity#include <sys/xattr.h>
2578f2338fb4SPavel Borzenkov#endif
2579758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2580758e8e38SVenkateswararao Jujjuri (JV)EOF
25814f26f2b6SAvi Kivity  if compile_prog "" "" ; then
25824f26f2b6SAvi Kivity    attr=yes
25834f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2584f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2585758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2586758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
25874f26f2b6SAvi Kivity    libattr=yes
2588758e8e38SVenkateswararao Jujjuri (JV)  else
2589758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2590*21684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
2591758e8e38SVenkateswararao Jujjuri (JV)    fi
2592758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2593758e8e38SVenkateswararao Jujjuri (JV)  fi
2594758e8e38SVenkateswararao Jujjuri (JV)fi
2595758e8e38SVenkateswararao Jujjuri (JV)
2596758e8e38SVenkateswararao Jujjuri (JV)##########################################
2597bf9298b9Saliguori# iovec probe
2598bf9298b9Saliguoricat > $TMPC <<EOF
2599db34f0b3Sblueswir1#include <sys/types.h>
2600bf9298b9Saliguori#include <sys/uio.h>
2601db34f0b3Sblueswir1#include <unistd.h>
2602f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2603bf9298b9SaliguoriEOF
2604bf9298b9Saliguoriiovec=no
260552166aa0SJuan Quintelaif compile_prog "" "" ; then
2606bf9298b9Saliguori  iovec=yes
2607bf9298b9Saliguorifi
2608bf9298b9Saliguori
2609f652e6afSaurel32##########################################
2610ceb42de8Saliguori# preadv probe
2611ceb42de8Saliguoricat > $TMPC <<EOF
2612ceb42de8Saliguori#include <sys/types.h>
2613ceb42de8Saliguori#include <sys/uio.h>
2614ceb42de8Saliguori#include <unistd.h>
2615c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2616ceb42de8SaliguoriEOF
2617ceb42de8Saliguoripreadv=no
261852166aa0SJuan Quintelaif compile_prog "" "" ; then
2619ceb42de8Saliguori  preadv=yes
2620ceb42de8Saliguorifi
2621ceb42de8Saliguori
2622ceb42de8Saliguori##########################################
2623f652e6afSaurel32# fdt probe
2624e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
2625e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
2626e169e1e1SPeter Maydellfdt_required=no
2627e169e1e1SPeter Maydellfor target in $target_list; do
2628e169e1e1SPeter Maydell  case $target in
26296a49fa95SAlexander Graf    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
2630e169e1e1SPeter Maydell      fdt_required=yes
2631e169e1e1SPeter Maydell    ;;
2632e169e1e1SPeter Maydell  esac
2633e169e1e1SPeter Maydelldone
2634e169e1e1SPeter Maydell
2635e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
2636e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
2637e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
2638e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
2639e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
2640e169e1e1SPeter Maydell  fi
2641e169e1e1SPeter Maydell  fdt=yes
2642e169e1e1SPeter Maydellfi
2643e169e1e1SPeter Maydell
26442df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2645b41af4baSJuan Quintela  fdt_libs="-lfdt"
264696ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
2647f652e6afSaurel32  cat > $TMPC << EOF
264896ce6545SPeter Crosthwaite#include <libfdt_env.h>
2649f652e6afSaurel32int main(void) { return 0; }
2650f652e6afSaurel32EOF
265152166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2652a540f158SPeter Crosthwaite    # system DTC is good - use it
2653f652e6afSaurel32    fdt=yes
2654a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
2655a540f158SPeter Crosthwaite    # have submodule DTC - use it
2656a540f158SPeter Crosthwaite    fdt=yes
2657a540f158SPeter Crosthwaite    dtc_internal="yes"
2658a540f158SPeter Crosthwaite    mkdir -p dtc
2659a540f158SPeter Crosthwaite    if [ "$source_path" != `pwd` ] ; then
2660a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
2661a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
26622df87df7SJuan Quintela    fi
2663a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
2664a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
2665a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
2666a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
26673f281822SStewart Smith    error_exit "DTC (libfdt) not present. Your options:" \
26683f281822SStewart Smith        "  (1) Preferred: Install the DTC (libfdt) devel package" \
2669a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
2670a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
2671a540f158SPeter Crosthwaite  else
2672a540f158SPeter Crosthwaite    # don't have and don't want
2673de3a354aSMichael Walle    fdt_libs=
26742df87df7SJuan Quintela    fdt=no
2675f652e6afSaurel32  fi
2676f652e6afSaurel32fi
2677f652e6afSaurel32
2678a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
2679a540f158SPeter Crosthwaite
268020ff075bSMichael Walle##########################################
2681b1e5fff4SMichael Walle# GLX probe, used by milkymist-tmu2
2682b1e5fff4SMichael Walleif test "$glx" != "no" ; then
2683b1e5fff4SMichael Walle  glx_libs="-lGL -lX11"
268420ff075bSMichael Walle  cat > $TMPC << EOF
268520ff075bSMichael Walle#include <X11/Xlib.h>
268620ff075bSMichael Walle#include <GL/gl.h>
268720ff075bSMichael Walle#include <GL/glx.h>
2688d3fcbb16SMichael Walleint main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
268920ff075bSMichael WalleEOF
2690d3fcbb16SMichael Walle  if compile_prog "" "-lGL -lX11" ; then
2691b1e5fff4SMichael Walle    glx=yes
269220ff075bSMichael Walle  else
2693b1e5fff4SMichael Walle    if test "$glx" = "yes" ; then
2694*21684af0SStewart Smith      feature_not_found "glx" "Install GL devel (e.g. MESA)"
269520ff075bSMichael Walle    fi
2696b1e5fff4SMichael Walle    glx_libs=
2697b1e5fff4SMichael Walle    glx=no
269820ff075bSMichael Walle  fi
269920ff075bSMichael Wallefi
270020ff075bSMichael Walle
2701eb100396SBharata B Rao##########################################
2702eb100396SBharata B Rao# glusterfs probe
2703eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
270465d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
2705e01bee08SBharata B Rao    glusterfs="yes"
2706ca871ec8SStefan Weil    glusterfs_cflags=`$pkg_config --cflags glusterfs-api`
2707ca871ec8SStefan Weil    glusterfs_libs=`$pkg_config --libs glusterfs-api`
2708e01bee08SBharata B Rao    CFLAGS="$CFLAGS $glusterfs_cflags"
2709eb100396SBharata B Rao    libs_tools="$glusterfs_libs $libs_tools"
2710eb100396SBharata B Rao    libs_softmmu="$glusterfs_libs $libs_softmmu"
271165d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
27120c14fb47SBharata B Rao      glusterfs_discard="yes"
27130c14fb47SBharata B Rao    fi
27147c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
27157c815372SBharata B Rao      glusterfs_zerofill="yes"
27167c815372SBharata B Rao    fi
2717eb100396SBharata B Rao  else
2718eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
2719*21684af0SStewart Smith      feature_not_found "GlusterFS backend support" "Install glusterfs-api devel"
2720eb100396SBharata B Rao    fi
2721e01bee08SBharata B Rao    glusterfs="no"
2722eb100396SBharata B Rao  fi
2723eb100396SBharata B Raofi
2724eb100396SBharata B Rao
272539386ac7Saurel32# Check for inotify functions when we are building linux-user
27263b3f24adSaurel32# emulator.  This is done because older glibc versions don't
27273b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
27283b3f24adSaurel32# don't provide them even if kernel supports them.
27293b3f24adSaurel32#
27303b3f24adSaurel32inotify=no
27313b3f24adSaurel32cat > $TMPC << EOF
27323b3f24adSaurel32#include <sys/inotify.h>
27333b3f24adSaurel32
27343b3f24adSaurel32int
27353b3f24adSaurel32main(void)
27363b3f24adSaurel32{
27373b3f24adSaurel32	/* try to start inotify */
27388690e420Saurel32	return inotify_init();
27393b3f24adSaurel32}
27403b3f24adSaurel32EOF
274152166aa0SJuan Quintelaif compile_prog "" "" ; then
27423b3f24adSaurel32  inotify=yes
27433b3f24adSaurel32fi
27443b3f24adSaurel32
2745c05c7a73SRiku Voipioinotify1=no
2746c05c7a73SRiku Voipiocat > $TMPC << EOF
2747c05c7a73SRiku Voipio#include <sys/inotify.h>
2748c05c7a73SRiku Voipio
2749c05c7a73SRiku Voipioint
2750c05c7a73SRiku Voipiomain(void)
2751c05c7a73SRiku Voipio{
2752c05c7a73SRiku Voipio    /* try to start inotify */
2753c05c7a73SRiku Voipio    return inotify_init1(0);
2754c05c7a73SRiku Voipio}
2755c05c7a73SRiku VoipioEOF
2756c05c7a73SRiku Voipioif compile_prog "" "" ; then
2757c05c7a73SRiku Voipio  inotify1=yes
2758c05c7a73SRiku Voipiofi
2759c05c7a73SRiku Voipio
2760ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2761ebc996f3SRiku Voipioutimens=no
2762ebc996f3SRiku Voipiocat > $TMPC << EOF
2763ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2764ebc996f3SRiku Voipio#include <stddef.h>
2765ebc996f3SRiku Voipio#include <fcntl.h>
27663014ee00SPeter Maydell#include <sys/stat.h>
2767ebc996f3SRiku Voipio
2768ebc996f3SRiku Voipioint main(void)
2769ebc996f3SRiku Voipio{
2770ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2771ebc996f3SRiku Voipio    futimens(0, NULL);
2772ebc996f3SRiku Voipio    return 0;
2773ebc996f3SRiku Voipio}
2774ebc996f3SRiku VoipioEOF
277552166aa0SJuan Quintelaif compile_prog "" "" ; then
2776ebc996f3SRiku Voipio  utimens=yes
2777ebc996f3SRiku Voipiofi
2778ebc996f3SRiku Voipio
2779099d6b0fSRiku Voipio# check if pipe2 is there
2780099d6b0fSRiku Voipiopipe2=no
2781099d6b0fSRiku Voipiocat > $TMPC << EOF
2782099d6b0fSRiku Voipio#include <unistd.h>
2783099d6b0fSRiku Voipio#include <fcntl.h>
2784099d6b0fSRiku Voipio
2785099d6b0fSRiku Voipioint main(void)
2786099d6b0fSRiku Voipio{
2787099d6b0fSRiku Voipio    int pipefd[2];
27889bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
2789099d6b0fSRiku Voipio}
2790099d6b0fSRiku VoipioEOF
279152166aa0SJuan Quintelaif compile_prog "" "" ; then
2792099d6b0fSRiku Voipio  pipe2=yes
2793099d6b0fSRiku Voipiofi
2794099d6b0fSRiku Voipio
279540ff6d7eSKevin Wolf# check if accept4 is there
279640ff6d7eSKevin Wolfaccept4=no
279740ff6d7eSKevin Wolfcat > $TMPC << EOF
279840ff6d7eSKevin Wolf#include <sys/socket.h>
279940ff6d7eSKevin Wolf#include <stddef.h>
280040ff6d7eSKevin Wolf
280140ff6d7eSKevin Wolfint main(void)
280240ff6d7eSKevin Wolf{
280340ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
280440ff6d7eSKevin Wolf    return 0;
280540ff6d7eSKevin Wolf}
280640ff6d7eSKevin WolfEOF
280740ff6d7eSKevin Wolfif compile_prog "" "" ; then
280840ff6d7eSKevin Wolf  accept4=yes
280940ff6d7eSKevin Wolffi
281040ff6d7eSKevin Wolf
28113ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
28123ce34dfbSvibisreenivasansplice=no
28133ce34dfbSvibisreenivasancat > $TMPC << EOF
28143ce34dfbSvibisreenivasan#include <unistd.h>
28153ce34dfbSvibisreenivasan#include <fcntl.h>
28163ce34dfbSvibisreenivasan#include <limits.h>
28173ce34dfbSvibisreenivasan
28183ce34dfbSvibisreenivasanint main(void)
28193ce34dfbSvibisreenivasan{
282066ea0f22SStefan Weil    int len, fd = 0;
28213ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
28223ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
28233ce34dfbSvibisreenivasan    return 0;
28243ce34dfbSvibisreenivasan}
28253ce34dfbSvibisreenivasanEOF
282652166aa0SJuan Quintelaif compile_prog "" "" ; then
28273ce34dfbSvibisreenivasan  splice=yes
28283ce34dfbSvibisreenivasanfi
28293ce34dfbSvibisreenivasan
2830dcc38d1cSMarcelo Tosatti##########################################
2831dcc38d1cSMarcelo Tosatti# signalfd probe
2832dcc38d1cSMarcelo Tosattisignalfd="no"
2833dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2834dcc38d1cSMarcelo Tosatti#include <unistd.h>
2835dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2836dcc38d1cSMarcelo Tosatti#include <signal.h>
2837dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2838dcc38d1cSMarcelo TosattiEOF
2839dcc38d1cSMarcelo Tosatti
2840dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2841dcc38d1cSMarcelo Tosatti  signalfd=yes
2842dcc38d1cSMarcelo Tosattifi
2843dcc38d1cSMarcelo Tosatti
2844c2882b96SRiku Voipio# check if eventfd is supported
2845c2882b96SRiku Voipioeventfd=no
2846c2882b96SRiku Voipiocat > $TMPC << EOF
2847c2882b96SRiku Voipio#include <sys/eventfd.h>
2848c2882b96SRiku Voipio
2849c2882b96SRiku Voipioint main(void)
2850c2882b96SRiku Voipio{
285155cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2852c2882b96SRiku Voipio}
2853c2882b96SRiku VoipioEOF
2854c2882b96SRiku Voipioif compile_prog "" "" ; then
2855c2882b96SRiku Voipio  eventfd=yes
2856c2882b96SRiku Voipiofi
2857c2882b96SRiku Voipio
2858d0927938SUlrich Hecht# check for fallocate
2859d0927938SUlrich Hechtfallocate=no
2860d0927938SUlrich Hechtcat > $TMPC << EOF
2861d0927938SUlrich Hecht#include <fcntl.h>
2862d0927938SUlrich Hecht
2863d0927938SUlrich Hechtint main(void)
2864d0927938SUlrich Hecht{
2865d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2866d0927938SUlrich Hecht    return 0;
2867d0927938SUlrich Hecht}
2868d0927938SUlrich HechtEOF
28698fb03151SPeter Maydellif compile_prog "" "" ; then
2870d0927938SUlrich Hecht  fallocate=yes
2871d0927938SUlrich Hechtfi
2872d0927938SUlrich Hecht
28733d4fa43eSKusanagi Kouichi# check for fallocate hole punching
28743d4fa43eSKusanagi Kouichifallocate_punch_hole=no
28753d4fa43eSKusanagi Kouichicat > $TMPC << EOF
28763d4fa43eSKusanagi Kouichi#include <fcntl.h>
28773d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
28783d4fa43eSKusanagi Kouichi
28793d4fa43eSKusanagi Kouichiint main(void)
28803d4fa43eSKusanagi Kouichi{
28813d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
28823d4fa43eSKusanagi Kouichi    return 0;
28833d4fa43eSKusanagi Kouichi}
28843d4fa43eSKusanagi KouichiEOF
28853d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
28863d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
28873d4fa43eSKusanagi Kouichifi
28883d4fa43eSKusanagi Kouichi
2889c727f47dSPeter Maydell# check for sync_file_range
2890c727f47dSPeter Maydellsync_file_range=no
2891c727f47dSPeter Maydellcat > $TMPC << EOF
2892c727f47dSPeter Maydell#include <fcntl.h>
2893c727f47dSPeter Maydell
2894c727f47dSPeter Maydellint main(void)
2895c727f47dSPeter Maydell{
2896c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2897c727f47dSPeter Maydell    return 0;
2898c727f47dSPeter Maydell}
2899c727f47dSPeter MaydellEOF
29008fb03151SPeter Maydellif compile_prog "" "" ; then
2901c727f47dSPeter Maydell  sync_file_range=yes
2902c727f47dSPeter Maydellfi
2903c727f47dSPeter Maydell
2904dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2905dace20dcSPeter Maydellfiemap=no
2906dace20dcSPeter Maydellcat > $TMPC << EOF
2907dace20dcSPeter Maydell#include <sys/ioctl.h>
2908dace20dcSPeter Maydell#include <linux/fs.h>
2909dace20dcSPeter Maydell#include <linux/fiemap.h>
2910dace20dcSPeter Maydell
2911dace20dcSPeter Maydellint main(void)
2912dace20dcSPeter Maydell{
2913dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2914dace20dcSPeter Maydell    return 0;
2915dace20dcSPeter Maydell}
2916dace20dcSPeter MaydellEOF
29178fb03151SPeter Maydellif compile_prog "" "" ; then
2918dace20dcSPeter Maydell  fiemap=yes
2919dace20dcSPeter Maydellfi
2920dace20dcSPeter Maydell
2921d0927938SUlrich Hecht# check for dup3
2922d0927938SUlrich Hechtdup3=no
2923d0927938SUlrich Hechtcat > $TMPC << EOF
2924d0927938SUlrich Hecht#include <unistd.h>
2925d0927938SUlrich Hecht
2926d0927938SUlrich Hechtint main(void)
2927d0927938SUlrich Hecht{
2928d0927938SUlrich Hecht    dup3(0, 0, 0);
2929d0927938SUlrich Hecht    return 0;
2930d0927938SUlrich Hecht}
2931d0927938SUlrich HechtEOF
293278f5d726SJan Kiszkaif compile_prog "" "" ; then
2933d0927938SUlrich Hecht  dup3=yes
2934d0927938SUlrich Hechtfi
2935d0927938SUlrich Hecht
29364e0c6529SAlex Bligh# check for ppoll support
29374e0c6529SAlex Blighppoll=no
29384e0c6529SAlex Blighcat > $TMPC << EOF
29394e0c6529SAlex Bligh#include <poll.h>
29404e0c6529SAlex Bligh
29414e0c6529SAlex Blighint main(void)
29424e0c6529SAlex Bligh{
29434e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
29444e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
29454e0c6529SAlex Bligh    return 0;
29464e0c6529SAlex Bligh}
29474e0c6529SAlex BlighEOF
29484e0c6529SAlex Blighif compile_prog "" "" ; then
29494e0c6529SAlex Bligh  ppoll=yes
29504e0c6529SAlex Blighfi
29514e0c6529SAlex Bligh
2952cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
2953cd758dd0SAlex Blighprctl_pr_set_timerslack=no
2954cd758dd0SAlex Blighcat > $TMPC << EOF
2955cd758dd0SAlex Bligh#include <sys/prctl.h>
2956cd758dd0SAlex Bligh
2957cd758dd0SAlex Blighint main(void)
2958cd758dd0SAlex Bligh{
2959cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
2960cd758dd0SAlex Bligh    return 0;
2961cd758dd0SAlex Bligh}
2962cd758dd0SAlex BlighEOF
2963cd758dd0SAlex Blighif compile_prog "" "" ; then
2964cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
2965cd758dd0SAlex Blighfi
2966cd758dd0SAlex Bligh
29673b6edd16SPeter Maydell# check for epoll support
29683b6edd16SPeter Maydellepoll=no
29693b6edd16SPeter Maydellcat > $TMPC << EOF
29703b6edd16SPeter Maydell#include <sys/epoll.h>
29713b6edd16SPeter Maydell
29723b6edd16SPeter Maydellint main(void)
29733b6edd16SPeter Maydell{
29743b6edd16SPeter Maydell    epoll_create(0);
29753b6edd16SPeter Maydell    return 0;
29763b6edd16SPeter Maydell}
29773b6edd16SPeter MaydellEOF
29788fb03151SPeter Maydellif compile_prog "" "" ; then
29793b6edd16SPeter Maydell  epoll=yes
29803b6edd16SPeter Maydellfi
29813b6edd16SPeter Maydell
29823b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
29833b6edd16SPeter Maydell# so we must check separately for their presence
29843b6edd16SPeter Maydellepoll_create1=no
29853b6edd16SPeter Maydellcat > $TMPC << EOF
29863b6edd16SPeter Maydell#include <sys/epoll.h>
29873b6edd16SPeter Maydell
29883b6edd16SPeter Maydellint main(void)
29893b6edd16SPeter Maydell{
299019e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
299119e83f6bSPeter Maydell     * a function being called. This is necessary so that on
299219e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
299319e83f6bSPeter Maydell     * the library but not declared in the header file we will
299419e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
299519e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
299619e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
299719e83f6bSPeter Maydell     */
2998c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
29993b6edd16SPeter Maydell}
30003b6edd16SPeter MaydellEOF
30018fb03151SPeter Maydellif compile_prog "" "" ; then
30023b6edd16SPeter Maydell  epoll_create1=yes
30033b6edd16SPeter Maydellfi
30043b6edd16SPeter Maydell
30053b6edd16SPeter Maydellepoll_pwait=no
30063b6edd16SPeter Maydellcat > $TMPC << EOF
30073b6edd16SPeter Maydell#include <sys/epoll.h>
30083b6edd16SPeter Maydell
30093b6edd16SPeter Maydellint main(void)
30103b6edd16SPeter Maydell{
30113b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
30123b6edd16SPeter Maydell    return 0;
30133b6edd16SPeter Maydell}
30143b6edd16SPeter MaydellEOF
30158fb03151SPeter Maydellif compile_prog "" "" ; then
30163b6edd16SPeter Maydell  epoll_pwait=yes
30173b6edd16SPeter Maydellfi
30183b6edd16SPeter Maydell
3019a8fd1abaSPeter Maydell# check for sendfile support
3020a8fd1abaSPeter Maydellsendfile=no
3021a8fd1abaSPeter Maydellcat > $TMPC << EOF
3022a8fd1abaSPeter Maydell#include <sys/sendfile.h>
3023a8fd1abaSPeter Maydell
3024a8fd1abaSPeter Maydellint main(void)
3025a8fd1abaSPeter Maydell{
3026a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
3027a8fd1abaSPeter Maydell}
3028a8fd1abaSPeter MaydellEOF
3029a8fd1abaSPeter Maydellif compile_prog "" "" ; then
3030a8fd1abaSPeter Maydell  sendfile=yes
3031a8fd1abaSPeter Maydellfi
3032a8fd1abaSPeter Maydell
3033cc8ae6deSpbrook# Check if tools are available to build documentation.
3034a25dba17SJuan Quintelaif test "$docs" != "no" ; then
303501668d98SStefan Weil  if has makeinfo && has pod2man; then
3036a25dba17SJuan Quintela    docs=yes
303783a3ab8bSJuan Quintela  else
3038a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
3039*21684af0SStewart Smith      feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
304083a3ab8bSJuan Quintela    fi
3041a25dba17SJuan Quintela    docs=no
304283a3ab8bSJuan Quintela  fi
3043cc8ae6deSpbrookfi
3044cc8ae6deSpbrook
3045f514f41cSStefan Weil# Search for bswap_32 function
30466ae9a1f4SJuan Quintelabyteswap_h=no
30476ae9a1f4SJuan Quintelacat > $TMPC << EOF
30486ae9a1f4SJuan Quintela#include <byteswap.h>
30496ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
30506ae9a1f4SJuan QuintelaEOF
305152166aa0SJuan Quintelaif compile_prog "" "" ; then
30526ae9a1f4SJuan Quintela  byteswap_h=yes
30536ae9a1f4SJuan Quintelafi
30546ae9a1f4SJuan Quintela
305575f13596SStefan Weil# Search for bswap32 function
30566ae9a1f4SJuan Quintelabswap_h=no
30576ae9a1f4SJuan Quintelacat > $TMPC << EOF
30586ae9a1f4SJuan Quintela#include <sys/endian.h>
30596ae9a1f4SJuan Quintela#include <sys/types.h>
30606ae9a1f4SJuan Quintela#include <machine/bswap.h>
30616ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
30626ae9a1f4SJuan QuintelaEOF
306352166aa0SJuan Quintelaif compile_prog "" "" ; then
30646ae9a1f4SJuan Quintela  bswap_h=yes
30656ae9a1f4SJuan Quintelafi
30666ae9a1f4SJuan Quintela
3067da93a1fdSaliguori##########################################
3068c589b249SRonnie Sahlberg# Do we have libiscsi
3069063c3378SPeter Lieven# We check for iscsi_write16_sync() to make sure we have a
3070063c3378SPeter Lieven# at least version 1.4.0 of libiscsi.
3071c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
3072c589b249SRonnie Sahlberg  cat > $TMPC << EOF
3073fa6acb0cSRonnie Sahlberg#include <stdio.h>
3074c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
3075063c3378SPeter Lievenint main(void) { iscsi_write16_sync(NULL,0,0,NULL,0,0,0,0,0,0,0); return 0; }
3076c589b249SRonnie SahlbergEOF
307765d5d3f9SStefan Weil  if $pkg_config --atleast-version=1.7.0 libiscsi; then
30783c33ea96SPaolo Bonzini    libiscsi="yes"
3079ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
3080ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
30813c33ea96SPaolo Bonzini    CFLAGS="$CFLAGS $libiscsi_cflags"
30823c33ea96SPaolo Bonzini    LIBS="$LIBS $libiscsi_libs"
30833c33ea96SPaolo Bonzini  elif compile_prog "" "-liscsi" ; then
3084c589b249SRonnie Sahlberg    libiscsi="yes"
3085c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
3086c589b249SRonnie Sahlberg  else
3087c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
3088*21684af0SStewart Smith      feature_not_found "libiscsi" "Install libiscsi devel"
3089c589b249SRonnie Sahlberg    fi
3090c589b249SRonnie Sahlberg    libiscsi="no"
3091c589b249SRonnie Sahlberg  fi
3092c589b249SRonnie Sahlbergfi
3093c589b249SRonnie Sahlberg
3094219c2521SStefan Weil# We also need to know the API version because there was an
3095219c2521SStefan Weil# API change from 1.4.0 to 1.5.0.
3096219c2521SStefan Weilif test "$libiscsi" = "yes"; then
3097219c2521SStefan Weil  cat >$TMPC <<EOF
3098219c2521SStefan Weil#include <iscsi/iscsi.h>
3099219c2521SStefan Weilint main(void)
3100219c2521SStefan Weil{
3101219c2521SStefan Weil  iscsi_read10_task(0, 0, 0, 0, 0, 0, 0);
3102219c2521SStefan Weil  return 0;
3103219c2521SStefan Weil}
3104219c2521SStefan WeilEOF
3105219c2521SStefan Weil  if compile_prog "" "-liscsi"; then
3106219c2521SStefan Weil    libiscsi_version="1.4.0"
3107219c2521SStefan Weil  fi
3108219c2521SStefan Weilfi
3109c589b249SRonnie Sahlberg
3110c589b249SRonnie Sahlberg##########################################
31118bacde8dSNatanael Copa# Do we need libm
31128bacde8dSNatanael Copacat > $TMPC << EOF
31138bacde8dSNatanael Copa#include <math.h>
31148bacde8dSNatanael Copaint main(void) { return isnan(sin(0.0)); }
31158bacde8dSNatanael CopaEOF
31168bacde8dSNatanael Copaif compile_prog "" "" ; then
31178bacde8dSNatanael Copa  :
31188bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
31198bacde8dSNatanael Copa  LIBS="-lm $LIBS"
31208bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
31218bacde8dSNatanael Copaelse
312276ad07a4SPeter Maydell  error_exit "libm check failed"
31238bacde8dSNatanael Copafi
31248bacde8dSNatanael Copa
31258bacde8dSNatanael Copa##########################################
3126da93a1fdSaliguori# Do we need librt
31278bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
31288bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
31298bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
31308bacde8dSNatanael Copa# function in addition.
3131da93a1fdSaliguoricat > $TMPC <<EOF
3132da93a1fdSaliguori#include <signal.h>
3133da93a1fdSaliguori#include <time.h>
31348bacde8dSNatanael Copaint main(void) {
31358bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
31368bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
31378bacde8dSNatanael Copa}
3138da93a1fdSaliguoriEOF
3139da93a1fdSaliguori
314052166aa0SJuan Quintelaif compile_prog "" "" ; then
314107ffa4bdSJuan Quintela  :
31428bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
31438bacde8dSNatanael Copaelif compile_prog "" "-lrt $pthread_lib" ; then
314407ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
31458bacde8dSNatanael Copa  libs_qga="-lrt $libs_qga"
3146da93a1fdSaliguorifi
3147da93a1fdSaliguori
314831ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
3149179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
31506362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
31516362a53fSJuan Quintelafi
31526362a53fSJuan Quintela
3153de5071c5SBlue Swirl##########################################
3154cd4ec0b4SGerd Hoffmann# spice probe
3155cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3156cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3157cd4ec0b4SGerd Hoffmann#include <spice.h>
3158cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3159cd4ec0b4SGerd HoffmannEOF
3160710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3161710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
316265d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
316365d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
3164cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3165cd4ec0b4SGerd Hoffmann    spice="yes"
3166cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
3167cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
31682e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
31692e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
3170cd4ec0b4SGerd Hoffmann  else
3171cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
3172*21684af0SStewart Smith      feature_not_found "spice" "Install spice-server and spice-protocol devel"
3173cd4ec0b4SGerd Hoffmann    fi
3174cd4ec0b4SGerd Hoffmann    spice="no"
3175cd4ec0b4SGerd Hoffmann  fi
3176cd4ec0b4SGerd Hoffmannfi
3177cd4ec0b4SGerd Hoffmann
3178111a38b0SRobert Relyea# check for libcacard for smartcard support
3179111a38b0SRobert Relyeasmartcard_cflags=""
3180111a38b0SRobert Relyea# TODO - what's the minimal nss version we support?
3181111a38b0SRobert Relyeaif test "$smartcard_nss" != "no"; then
31825f01e06fSSergei Trofimovich  cat > $TMPC << EOF
31835f01e06fSSergei Trofimovich#include <pk11pub.h>
31845f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
31855f01e06fSSergei TrofimovichEOF
31860b22ef0fSPeter Maydell    smartcard_includes="-I\$(SRC_PATH)/libcacard"
31878c741c22SAlon Levy    libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
31888c741c22SAlon Levy    libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
31896ca026cbSPeter Maydell    test_cflags="$libcacard_cflags"
31906ca026cbSPeter Maydell    # The header files in nss < 3.13.3 have a bug which causes them to
31916ca026cbSPeter Maydell    # emit a warning. If we're going to compile QEMU with -Werror, then
31926ca026cbSPeter Maydell    # test that the headers don't have this bug. Otherwise we would pass
31936ca026cbSPeter Maydell    # the configure test but fail to compile QEMU later.
31946ca026cbSPeter Maydell    if test "$werror" = "yes"; then
31956ca026cbSPeter Maydell        test_cflags="-Werror $test_cflags"
31966ca026cbSPeter Maydell    fi
3197b6fc675bSPaolo Bonzini    if test -n "$libtool" &&
319865d5d3f9SStefan Weil       $pkg_config --atleast-version=3.12.8 nss && \
31996ca026cbSPeter Maydell      compile_prog "$test_cflags" "$libcacard_libs"; then
32005f01e06fSSergei Trofimovich        smartcard_nss="yes"
32010b22ef0fSPeter Maydell        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
32020b22ef0fSPeter Maydell        QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
3203ad4cf3f6SPaul Brook        libs_softmmu="$libcacard_libs $libs_softmmu"
3204111a38b0SRobert Relyea    else
3205111a38b0SRobert Relyea        if test "$smartcard_nss" = "yes"; then
3206111a38b0SRobert Relyea            feature_not_found "nss"
3207111a38b0SRobert Relyea        fi
3208111a38b0SRobert Relyea        smartcard_nss="no"
3209111a38b0SRobert Relyea    fi
3210111a38b0SRobert Relyeafi
3211111a38b0SRobert Relyea
32122b2325ffSGerd Hoffmann# check for libusb
32132b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
321465d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
32152b2325ffSGerd Hoffmann        libusb="yes"
3216ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
3217ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
32182b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
32192b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
32202b2325ffSGerd Hoffmann    else
32212b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
3222*21684af0SStewart Smith            feature_not_found "libusb" "Install libusb devel"
32232b2325ffSGerd Hoffmann        fi
32242b2325ffSGerd Hoffmann        libusb="no"
32252b2325ffSGerd Hoffmann    fi
32262b2325ffSGerd Hoffmannfi
32272b2325ffSGerd Hoffmann
322869354a83SHans de Goede# check for usbredirparser for usb network redirection support
322969354a83SHans de Goedeif test "$usb_redir" != "no" ; then
323065d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
323169354a83SHans de Goede        usb_redir="yes"
3232ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
3233ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
323469354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
323556ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
323669354a83SHans de Goede    else
323769354a83SHans de Goede        if test "$usb_redir" = "yes"; then
3238*21684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
323969354a83SHans de Goede        fi
324069354a83SHans de Goede        usb_redir="no"
324169354a83SHans de Goede    fi
324269354a83SHans de Goedefi
324369354a83SHans de Goede
3244cd4ec0b4SGerd Hoffmann##########################################
3245d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
3246d9840e25STomoki Sekiyama
3247d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
3248d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
3249d9840e25STomoki Sekiyama    "")   vss_win32_include="-I$source_path" ;;
3250d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3251d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
3252d9840e25STomoki Sekiyama          vss_win32_include="-I$source_path/.sdk/vss"
3253d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3254d9840e25STomoki Sekiyama	  ;;
3255d9840e25STomoki Sekiyama    *)    vss_win32_include="-I$vss_win32_sdk"
3256d9840e25STomoki Sekiyama  esac
3257d9840e25STomoki Sekiyama  cat > $TMPC << EOF
3258d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
3259d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
3260d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
3261d9840e25STomoki SekiyamaEOF
3262d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
3263d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
3264d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
3265d9840e25STomoki Sekiyama    libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
3266d9840e25STomoki Sekiyama  else
3267d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
3268d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
3269d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3270d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3271d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
3272d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
3273d9840e25STomoki Sekiyama      feature_not_found "VSS support"
3274d9840e25STomoki Sekiyama    fi
3275d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
3276d9840e25STomoki Sekiyama  fi
3277d9840e25STomoki Sekiyamafi
3278d9840e25STomoki Sekiyama
3279d9840e25STomoki Sekiyama##########################################
3280d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
3281d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
3282d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
3283d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
3284d9840e25STomoki Sekiyama
3285d9840e25STomoki Sekiyamaif test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
3286d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
3287d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
3288d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
3289d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
3290d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
3291d9840e25STomoki Sekiyama    else
3292d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
3293d9840e25STomoki Sekiyama    fi
3294d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
3295d9840e25STomoki Sekiyama    win_sdk=""
3296d9840e25STomoki Sekiyama  fi
3297d9840e25STomoki Sekiyamafi
3298d9840e25STomoki Sekiyama
3299d9840e25STomoki Sekiyama##########################################
3300cd4ec0b4SGerd Hoffmann
3301747bbdf7SBlue Swirl##########################################
33025f6b9e8fSBlue Swirl# check if we have fdatasync
33035f6b9e8fSBlue Swirl
33045f6b9e8fSBlue Swirlfdatasync=no
33055f6b9e8fSBlue Swirlcat > $TMPC << EOF
33065f6b9e8fSBlue Swirl#include <unistd.h>
3307d1722a27SAlexandre Raymondint main(void) {
3308d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
3309d1722a27SAlexandre Raymondreturn fdatasync(0);
3310d1722a27SAlexandre Raymond#else
3311e172fe11SStefan Weil#error Not supported
3312d1722a27SAlexandre Raymond#endif
3313d1722a27SAlexandre Raymond}
33145f6b9e8fSBlue SwirlEOF
33155f6b9e8fSBlue Swirlif compile_prog "" "" ; then
33165f6b9e8fSBlue Swirl    fdatasync=yes
33175f6b9e8fSBlue Swirlfi
33185f6b9e8fSBlue Swirl
331994a420b1SStefan Hajnoczi##########################################
3320e78815a5SAndreas Färber# check if we have madvise
3321e78815a5SAndreas Färber
3322e78815a5SAndreas Färbermadvise=no
3323e78815a5SAndreas Färbercat > $TMPC << EOF
3324e78815a5SAndreas Färber#include <sys/types.h>
3325e78815a5SAndreas Färber#include <sys/mman.h>
3326832ce9c2SScott Wood#include <stddef.h>
3327e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
3328e78815a5SAndreas FärberEOF
3329e78815a5SAndreas Färberif compile_prog "" "" ; then
3330e78815a5SAndreas Färber    madvise=yes
3331e78815a5SAndreas Färberfi
3332e78815a5SAndreas Färber
3333e78815a5SAndreas Färber##########################################
3334e78815a5SAndreas Färber# check if we have posix_madvise
3335e78815a5SAndreas Färber
3336e78815a5SAndreas Färberposix_madvise=no
3337e78815a5SAndreas Färbercat > $TMPC << EOF
3338e78815a5SAndreas Färber#include <sys/mman.h>
3339832ce9c2SScott Wood#include <stddef.h>
3340e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
3341e78815a5SAndreas FärberEOF
3342e78815a5SAndreas Färberif compile_prog "" "" ; then
3343e78815a5SAndreas Färber    posix_madvise=yes
3344e78815a5SAndreas Färberfi
3345e78815a5SAndreas Färber
3346e78815a5SAndreas Färber##########################################
33471e9737daSRichard Henderson# check if we have usable SIGEV_THREAD_ID
33481e9737daSRichard Henderson
33491e9737daSRichard Hendersonsigev_thread_id=no
33501e9737daSRichard Hendersoncat > $TMPC << EOF
33511e9737daSRichard Henderson#include <signal.h>
33521e9737daSRichard Hendersonint main(void) {
33531e9737daSRichard Henderson  struct sigevent ev;
33541e9737daSRichard Henderson  ev.sigev_notify = SIGEV_THREAD_ID;
33551e9737daSRichard Henderson  ev._sigev_un._tid = 0;
33561e9737daSRichard Henderson  asm volatile("" : : "g"(&ev));
33571e9737daSRichard Henderson  return 0;
33581e9737daSRichard Henderson}
33591e9737daSRichard HendersonEOF
33601e9737daSRichard Hendersonif compile_prog "" "" ; then
33611e9737daSRichard Henderson    sigev_thread_id=yes
33621e9737daSRichard Hendersonfi
33631e9737daSRichard Henderson
33641e9737daSRichard Henderson##########################################
336594a420b1SStefan Hajnoczi# check if trace backend exists
336694a420b1SStefan Hajnoczi
3367650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
336894a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
336976ad07a4SPeter Maydell  error_exit "invalid trace backend" \
337076ad07a4SPeter Maydell      "Please choose a supported trace backend."
337194a420b1SStefan Hajnoczifi
337294a420b1SStefan Hajnoczi
33737e24e92aSStefan Hajnoczi##########################################
33747e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
33757e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
33767e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
33777e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
33787e24e92aSStefan Hajnoczi#include <ust/marker.h>
33797e24e92aSStefan Hajnocziint main(void) { return 0; }
33807e24e92aSStefan HajnocziEOF
33817e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
338294b4fefaSLluís Vilanova    LIBS="-lust -lurcu-bp $LIBS"
3383c9a2e37cSLluís Vilanova    libs_qga="-lust -lurcu-bp $libs_qga"
33847e24e92aSStefan Hajnoczi  else
338576ad07a4SPeter Maydell    error_exit "Trace backend 'ust' missing libust header files"
33867e24e92aSStefan Hajnoczi  fi
33877e24e92aSStefan Hajnoczifi
3388b3d08c02SDaniel P. Berrange
3389b3d08c02SDaniel P. Berrange##########################################
3390b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
3391b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
3392b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
339376ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
3394b3d08c02SDaniel P. Berrange  fi
3395c276b17dSDaniel P. Berrange  trace_backend_stap="no"
3396c276b17dSDaniel P. Berrange  if has 'stap' ; then
3397c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
3398c276b17dSDaniel P. Berrange  fi
3399b3d08c02SDaniel P. Berrangefi
3400b3d08c02SDaniel P. Berrange
34017e24e92aSStefan Hajnoczi##########################################
3402519175a2SAlex Barcelo# check and set a backend for coroutine
3403d0e2fce5SAneesh Kumar K.V
34047c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
34057c2acc70SPeter Maydell# is sigcontext. gthread is not selectable except explicitly, because
34067c2acc70SPeter Maydell# it is not functional enough to run QEMU proper. (It is occasionally
34077c2acc70SPeter Maydell# useful for debugging purposes.)  On Windows the only valid backend
34087c2acc70SPeter Maydell# is the Windows-specific one.
34097c2acc70SPeter Maydell
34107c2acc70SPeter Maydellucontext_works=no
3411d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3412d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3413d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3414cdf84806SPeter Maydell#ifdef __stub_makecontext
3415cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3416cdf84806SPeter Maydell#endif
341775cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3418d0e2fce5SAneesh Kumar K.VEOF
3419d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
34207c2acc70SPeter Maydell    ucontext_works=yes
3421d0e2fce5SAneesh Kumar K.V  fi
3422519175a2SAlex Barcelofi
34237c2acc70SPeter Maydell
34247c2acc70SPeter Maydellif test "$coroutine" = ""; then
34257c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
34267c2acc70SPeter Maydell    coroutine=win32
34277c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
34287c2acc70SPeter Maydell    coroutine=ucontext
3429519175a2SAlex Barcelo  else
34307c2acc70SPeter Maydell    coroutine=sigaltstack
34317c2acc70SPeter Maydell  fi
34327c2acc70SPeter Maydellelse
34337c2acc70SPeter Maydell  case $coroutine in
34347c2acc70SPeter Maydell  windows)
34357c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
34367c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
34377c2acc70SPeter Maydell    fi
34387c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
34397c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
34407c2acc70SPeter Maydell    coroutine=win32
34417c2acc70SPeter Maydell    ;;
34427c2acc70SPeter Maydell  ucontext)
34437c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
34447c2acc70SPeter Maydell      feature_not_found "ucontext"
34457c2acc70SPeter Maydell    fi
34467c2acc70SPeter Maydell    ;;
34477c2acc70SPeter Maydell  gthread|sigaltstack)
34487c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
34497c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
34507c2acc70SPeter Maydell    fi
34517c2acc70SPeter Maydell    ;;
34527c2acc70SPeter Maydell  *)
345376ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
34547c2acc70SPeter Maydell    ;;
34557c2acc70SPeter Maydell  esac
3456d0e2fce5SAneesh Kumar K.Vfi
3457d0e2fce5SAneesh Kumar K.V
345870c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
345970c60c08SStefan Hajnoczi  if test "$coroutine" = "gthread"; then
346070c60c08SStefan Hajnoczi    coroutine_pool=no
346170c60c08SStefan Hajnoczi  else
346270c60c08SStefan Hajnoczi    coroutine_pool=yes
346370c60c08SStefan Hajnoczi  fi
346470c60c08SStefan Hajnoczifi
346570c60c08SStefan Hajnocziif test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
346670c60c08SStefan Hajnoczi  error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
346770c60c08SStefan Hajnoczifi
346870c60c08SStefan Hajnoczi
3469d0e2fce5SAneesh Kumar K.V##########################################
3470d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
3471d2042378SAneesh Kumar K.V
34724e1797f9SStefan Weilopen_by_handle_at=no
3473d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
3474d2042378SAneesh Kumar K.V#include <fcntl.h>
3475acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
3476acc55ba8SStefan Weil# error missing definition
3477acc55ba8SStefan Weil#else
347875cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3479acc55ba8SStefan Weil#endif
3480d2042378SAneesh Kumar K.VEOF
3481d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
3482d2042378SAneesh Kumar K.V    open_by_handle_at=yes
3483d2042378SAneesh Kumar K.Vfi
3484d2042378SAneesh Kumar K.V
3485e06a765eSHarsh Prateek Bora########################################
3486e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
3487e06a765eSHarsh Prateek Bora
3488e06a765eSHarsh Prateek Boralinux_magic_h=no
3489e06a765eSHarsh Prateek Boracat > $TMPC << EOF
3490e06a765eSHarsh Prateek Bora#include <linux/magic.h>
3491e06a765eSHarsh Prateek Boraint main(void) {
349275cafad7SStefan Weil  return 0;
3493e06a765eSHarsh Prateek Bora}
3494e06a765eSHarsh Prateek BoraEOF
3495e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
3496e06a765eSHarsh Prateek Bora    linux_magic_h=yes
3497e06a765eSHarsh Prateek Borafi
3498e06a765eSHarsh Prateek Bora
34998ab1bf12SLuiz Capitulino########################################
3500c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
3501c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
3502c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
3503c95e3080SKevin Wolf# only a warning.
3504c95e3080SKevin Wolf#
3505c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
3506c95e3080SKevin Wolf# the build doesn't fail anyway.
3507c95e3080SKevin Wolf
350806d71fa1SPeter Maydellpragma_disable_unused_but_set=no
350906d71fa1SPeter Maydellcat > $TMPC << EOF
3510e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
351106d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3512c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
3513e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
3514c95e3080SKevin Wolf
351506d71fa1SPeter Maydellint main(void) {
351606d71fa1SPeter Maydell    return 0;
351706d71fa1SPeter Maydell}
351806d71fa1SPeter MaydellEOF
351906d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
3520cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
3521c95e3080SKevin Wolfelse
3522c95e3080SKevin Wolf    werror=no
352306d71fa1SPeter Maydellfi
352406d71fa1SPeter Maydell
352506d71fa1SPeter Maydell########################################
352662fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
35273f4349dcSKevin Wolf
35283f4349dcSKevin Wolfvalgrind_h=no
35293f4349dcSKevin Wolfcat > $TMPC << EOF
35303f4349dcSKevin Wolf#include <valgrind/valgrind.h>
353162fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
35323f4349dcSKevin Wolfint main(void) {
35333f4349dcSKevin Wolf  return 0;
35343f4349dcSKevin Wolf}
35353f4349dcSKevin WolfEOF
35363f4349dcSKevin Wolfif compile_prog "" "" ; then
35373f4349dcSKevin Wolf    valgrind_h=yes
35383f4349dcSKevin Wolffi
35393f4349dcSKevin Wolf
35403f4349dcSKevin Wolf########################################
35418ab1bf12SLuiz Capitulino# check if environ is declared
35428ab1bf12SLuiz Capitulino
35438ab1bf12SLuiz Capitulinohas_environ=no
35448ab1bf12SLuiz Capitulinocat > $TMPC << EOF
35458ab1bf12SLuiz Capitulino#include <unistd.h>
35468ab1bf12SLuiz Capitulinoint main(void) {
3547c075a723SBlue Swirl    environ = 0;
35488ab1bf12SLuiz Capitulino    return 0;
35498ab1bf12SLuiz Capitulino}
35508ab1bf12SLuiz CapitulinoEOF
35518ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
35528ab1bf12SLuiz Capitulino    has_environ=yes
35538ab1bf12SLuiz Capitulinofi
35548ab1bf12SLuiz Capitulino
355576a347e1SRichard Henderson########################################
355676a347e1SRichard Henderson# check if cpuid.h is usable.
355776a347e1SRichard Henderson
355876a347e1SRichard Hendersoncpuid_h=no
355976a347e1SRichard Hendersoncat > $TMPC << EOF
356076a347e1SRichard Henderson#include <cpuid.h>
356176a347e1SRichard Hendersonint main(void) {
356276a347e1SRichard Henderson  return 0;
356376a347e1SRichard Henderson}
356476a347e1SRichard HendersonEOF
356576a347e1SRichard Hendersonif compile_prog "" "" ; then
356676a347e1SRichard Henderson    cpuid_h=yes
356776a347e1SRichard Hendersonfi
356876a347e1SRichard Henderson
3569f540166bSRichard Henderson########################################
3570f540166bSRichard Henderson# check if __[u]int128_t is usable.
3571f540166bSRichard Henderson
3572f540166bSRichard Hendersonint128=no
3573f540166bSRichard Hendersoncat > $TMPC << EOF
3574f540166bSRichard Henderson__int128_t a;
3575f540166bSRichard Henderson__uint128_t b;
3576f540166bSRichard Hendersonint main (void) {
3577f540166bSRichard Henderson  a = a + b;
3578f540166bSRichard Henderson  b = a * b;
3579464e3671SPeter Maydell  a = a * a;
3580f540166bSRichard Henderson  return 0;
3581f540166bSRichard Henderson}
3582f540166bSRichard HendersonEOF
3583f540166bSRichard Hendersonif compile_prog "" "" ; then
3584f540166bSRichard Henderson    int128=yes
3585f540166bSRichard Hendersonfi
358676a347e1SRichard Henderson
35871e6e9acaSRichard Henderson########################################
35881e6e9acaSRichard Henderson# check if getauxval is available.
35891e6e9acaSRichard Henderson
35901e6e9acaSRichard Hendersongetauxval=no
35911e6e9acaSRichard Hendersoncat > $TMPC << EOF
35921e6e9acaSRichard Henderson#include <sys/auxv.h>
35931e6e9acaSRichard Hendersonint main(void) {
35941e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
35951e6e9acaSRichard Henderson}
35961e6e9acaSRichard HendersonEOF
35971e6e9acaSRichard Hendersonif compile_prog "" "" ; then
35981e6e9acaSRichard Henderson    getauxval=yes
35991e6e9acaSRichard Hendersonfi
36001e6e9acaSRichard Henderson
3601d2042378SAneesh Kumar K.V##########################################
3602e86ecd4bSJuan Quintela# End of CC checks
3603e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3604e86ecd4bSJuan Quintela
36051d728c39SBlue Swirlif test "$gcov" = "yes" ; then
36061d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
36071d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
36081d728c39SBlue Swirlelif test "$debug" = "no" ; then
3609e600cdf3SMichal Privoznik  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
3610e86ecd4bSJuan Quintelafi
3611a316e378SJuan Quintela
36126542aa9cSPeter Lieven##########################################
36136542aa9cSPeter Lieven# Do we have libnfs
36146542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
36156542aa9cSPeter Lieven  if $pkg_config --atleast-version=1.9.2 libnfs; then
36166542aa9cSPeter Lieven    libnfs="yes"
36176542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
36186542aa9cSPeter Lieven    LIBS="$LIBS $libnfs_libs"
36196542aa9cSPeter Lieven  else
36206542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
36216542aa9cSPeter Lieven      feature_not_found "libnfs"
36226542aa9cSPeter Lieven    fi
36236542aa9cSPeter Lieven    libnfs="no"
36246542aa9cSPeter Lieven  fi
36256542aa9cSPeter Lievenfi
36261d728c39SBlue Swirl
362720ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
362820ff6c80SAnthony Liguori# enable/disable
362920ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
363020ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
363120ff6c80SAnthony Liguori	zero_malloc="no"
363220ff6c80SAnthony Liguori    else
363320ff6c80SAnthony Liguori	zero_malloc="yes"
363420ff6c80SAnthony Liguori    fi
363520ff6c80SAnthony Liguorifi
363620ff6c80SAnthony Liguori
36376ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
36386ca026cbSPeter Maydellif test "$werror" = "yes"; then
36396ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
36406ca026cbSPeter Maydellfi
36416ca026cbSPeter Maydell
3642e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3643e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
36441156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3645e86ecd4bSJuan Quintela    fi
3646e86ecd4bSJuan Quintelafi
3647e86ecd4bSJuan Quintela
364894dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
364994dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
365094dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
365194dd53c5SGerd Hoffmannelse
365294dd53c5SGerd Hoffmann    POD2MAN="pod2man"
365394dd53c5SGerd Hoffmannfi
365494dd53c5SGerd Hoffmann
3655952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3656952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3657952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3658952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3659952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3660952afb71SBlue Swirl        fi
3661952afb71SBlue Swirl    done
3662952afb71SBlue Swirlfi
3663952afb71SBlue Swirl
366410ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3665528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
3666834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
36675a67135aSbellard
36684b1c11fdSDaniel P. Berrangetools=""
36694b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3670ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
36714b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
36724b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
36734b1c11fdSDaniel P. Berrange  fi
36744b1c11fdSDaniel P. Berrangefi
36754b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3676983eef5aSMeador Inge  if test "$virtfs" != no ; then
3677be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3678983eef5aSMeador Inge      virtfs=yes
367917bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3680983eef5aSMeador Inge    else
3681983eef5aSMeador Inge      if test "$virtfs" = yes; then
368276ad07a4SPeter Maydell        error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3683983eef5aSMeador Inge      fi
368417500370SAndreas Färber      virtfs=no
3685983eef5aSMeador Inge    fi
368617bff52bSM. Mohan Kumar  fi
3687d138cee9SMichael Rothfi
3688e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
3689b39297aeSTomoki Sekiyama  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
3690e8ef31a3SMichael Tokarev      tools="qemu-ga\$(EXESUF) $tools"
3691b39297aeSTomoki Sekiyama      if [ "$mingw32" = "yes" -a "$guest_agent_with_vss" = "yes" ]; then
3692b39297aeSTomoki Sekiyama        tools="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb $tools"
3693b39297aeSTomoki Sekiyama      fi
3694e8ef31a3SMichael Tokarev      guest_agent=yes
3695e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
3696e8ef31a3SMichael Tokarev      guest_agent=no
3697e8ef31a3SMichael Tokarev  else
3698e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
3699ca35f780SPaolo Bonzini  fi
37004b1c11fdSDaniel P. Berrangefi
3701ca35f780SPaolo Bonzini
3702ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3703ca35f780SPaolo Bonziniroms=
3704ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3705ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3706ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3707ca35f780SPaolo Bonzini  roms="optionrom"
3708ca35f780SPaolo Bonzinifi
3709d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
371039ac8455SDavid Gibson  roms="$roms spapr-rtas"
371139ac8455SDavid Gibsonfi
3712ca35f780SPaolo Bonzini
37139933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
37149933c305SChristian Borntraeger  roms="$roms s390-ccw"
37159933c305SChristian Borntraegerfi
37169933c305SChristian Borntraeger
3717964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
3718964c6fa1SRichard Hendersonif test "$pie" = "no" ; then
3719964c6fa1SRichard Henderson  textseg_addr=
3720964c6fa1SRichard Henderson  case "$cpu" in
3721c72b26ecSRichard Henderson    arm | hppa | i386 | m68k | ppc | ppc64 | s390* | sparc | sparc64 | x86_64 | x32)
3722964c6fa1SRichard Henderson      textseg_addr=0x60000000
3723964c6fa1SRichard Henderson      ;;
3724964c6fa1SRichard Henderson    mips)
3725964c6fa1SRichard Henderson      textseg_addr=0x400000
3726964c6fa1SRichard Henderson      ;;
3727964c6fa1SRichard Henderson  esac
3728964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
3729964c6fa1SRichard Henderson    cat > $TMPC <<EOF
3730964c6fa1SRichard Henderson    int main(void) { return 0; }
3731964c6fa1SRichard HendersonEOF
3732964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
3733964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
3734964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
3735964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
3736964c6fa1SRichard Henderson      # at least.
3737964c6fa1SRichard Henderson      $ld --verbose | sed \
3738964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
3739964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
3740964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
3741964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
3742964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
3743964c6fa1SRichard Henderson    fi
3744964c6fa1SRichard Henderson  fi
3745964c6fa1SRichard Hendersonfi
3746964c6fa1SRichard Henderson
37475ca9388aSGerd Hoffmann# add pixman flags after all config tests are done
3748a540f158SPeter CrosthwaiteQEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags"
37495ca9388aSGerd Hoffmannlibs_softmmu="$libs_softmmu $pixman_libs"
37505ca9388aSGerd Hoffmann
37517d13299dSbellardecho "Install prefix    $prefix"
3752c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3753f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
37543aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
37558bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
37560f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
37571c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
375811d9f695Sbellardif test "$mingw32" = "no" ; then
37595a699bbbSLaszlo Ersekecho "local state directory   `eval echo $local_statedir`"
3760f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
376143ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
37625a699bbbSLaszlo Ersekelse
37635a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
3764d9840e25STomoki Sekiyamaecho "Windows SDK       $win_sdk"
376511d9f695Sbellardfi
37665a67135aSbellardecho "Source path       $source_path"
37677d13299dSbellardecho "C compiler        $cc"
376883469015Sbellardecho "Host C compiler   $host_cc"
376983f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
37703c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
377145d285abSPeter Maydellecho "ARFLAGS           $ARFLAGS"
37720c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3773a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
37740c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
37757d13299dSbellardecho "make              $make"
37766a882643Spbrookecho "install           $install"
3777c886edfbSBlue Swirlecho "python            $python"
3778e2d8830eSBradif test "$slirp" = "yes" ; then
3779e2d8830eSBrad    echo "smbd              $smbd"
3780e2d8830eSBradfi
3781a98fd896Sbellardecho "host CPU          $cpu"
3782de83cd02Sbellardecho "host big endian   $bigendian"
378397a847bcSbellardecho "target list       $target_list"
3784ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
37857d13299dSbellardecho "gprof enabled     $gprof"
378603b4fe7dSaliguoriecho "sparse enabled    $sparse"
37871625af87Saliguoriecho "strip binaries    $strip_opt"
378805c2a3e7Sbellardecho "profiler          $profiler"
378943ce4dfeSbellardecho "static build      $static"
379085aa5189Sbellardecho "-Werror enabled   $werror"
37915b0753e0Sbellardif test "$darwin" = "yes" ; then
37925b0753e0Sbellard    echo "Cocoa support     $cocoa"
37935b0753e0Sbellardfi
3794e2134eb9SGerd Hoffmannecho "pixman            $pixman"
379597a847bcSbellardecho "SDL support       $sdl"
3796a4ccabcfSAnthony Liguoriecho "GTK support       $gtk"
37974d3b6f6eSbalrogecho "curses support    $curses"
3798769ce76dSAlexander Grafecho "curl support      $curl"
379967b915a5Sbellardecho "mingw32 support   $mingw32"
38000c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
3801b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
3802b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
3803983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3804821601eaSJes Sorensenecho "VNC support       $vnc"
3805821601eaSJes Sorensenif test "$vnc" = "yes" ; then
38068d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
38072f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
38082f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3809efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
38107536ee4bSTim Hardeck    echo "VNC WS support    $vnc_ws"
3811821601eaSJes Sorensenfi
38123142255cSblueswir1if test -n "$sparc_cpu"; then
38133142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
38143142255cSblueswir1fi
3815e37630caSaliguoriecho "xen support       $xen"
38162e4d9fb1Saurel32echo "brlapi support    $brlapi"
3817a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3818a25dba17SJuan Quintelaecho "Documentation     $docs"
3819c5937220Spbrook[ ! -z "$uname_release" ] && \
3820c5937220Spbrookecho "uname -r          $uname_release"
3821379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
382240d6444eSAvi Kivityecho "PIE               $pie"
38238a16d273Sthsecho "vde support       $vde"
382458952137SVincenzo Maffioneecho "netmap support    $netmap"
38255c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3826758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
382777755340Sthsecho "Install blobs     $blobs"
3828b31a0277SJuan Quintelaecho "KVM support       $kvm"
38292da776dbSMichael R. Hinesecho "RDMA support      $rdma"
38309195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3831f652e6afSaurel32echo "fdt support       $fdt"
3832ceb42de8Saliguoriecho "preadv support    $preadv"
38335f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3834e78815a5SAndreas Färberecho "madvise           $madvise"
3835e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
38361e9737daSRichard Hendersonecho "sigev_thread_id   $sigev_thread_id"
3837ee682d27SStefan Weilecho "uuid support      $uuid"
383847e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3839d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
38405e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
384194a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
38429410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
38432e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3844f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3845dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3846111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
38472b2325ffSGerd Hoffmannecho "libusb            $libusb"
384869354a83SHans de Goedeecho "usb net redir     $usb_redir"
3849b1e5fff4SMichael Walleecho "GLX support       $glx"
3850219c2521SStefan Weilif test "$libiscsi_version" = "1.4.0"; then
3851219c2521SStefan Weilecho "libiscsi support  $libiscsi (1.4.0)"
3852219c2521SStefan Weilelse
3853c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3854219c2521SStefan Weilfi
38556542aa9cSPeter Lievenecho "libnfs support    $libnfs"
3856d138cee9SMichael Rothecho "build guest agent $guest_agent"
3857d9840e25STomoki Sekiyamaecho "QGA VSS support   $guest_agent_with_vss"
3858f794573eSEduardo Otuboecho "seccomp support   $seccomp"
38597c2acc70SPeter Maydellecho "coroutine backend $coroutine"
386070c60c08SStefan Hajnocziecho "coroutine pool    $coroutine_pool"
3861eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
3862583f6e7bSStefan Hajnocziecho "virtio-blk-data-plane $virtio_blk_data_plane"
38631d728c39SBlue Swirlecho "gcov              $gcov_tool"
38641d728c39SBlue Swirlecho "gcov enabled      $gcov"
3865ab214c29SStefan Bergerecho "TPM support       $tpm"
38660a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
38673b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
38683556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
38694f18b782SJeff Codyecho "vhdx              $vhdx"
387067b915a5Sbellard
38711ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
387224b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3873e8cd23deSbellardfi
387497a847bcSbellard
387598ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
387697a847bcSbellard
3877dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
3878dbd99ae3SStefan Weil
387998ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
388098ec69acSJuan Quintelaecho >> $config_host_mak
388198ec69acSJuan Quintela
3882e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
388399d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
388499d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
38853aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
38868bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
38870f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
388899d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
388999d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
389022d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
38919afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
38929afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
38935a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
3894785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
38955a699bbbSLaszlo Ersekfi
3896f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
3897f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
3898f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
3899834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
3900f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
3901804edf29SJuan Quintela
390298ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3903727e5283SPaolo Bonzini
3904f8393946Saurel32if test "$debug_tcg" = "yes" ; then
39052358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3906f8393946Saurel32fi
39071625af87Saliguoriif test "$strip_opt" = "yes" ; then
390852ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
39091625af87Saliguorifi
39107d13299dSbellardif test "$bigendian" = "yes" ; then
3911e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
391297a847bcSbellardfi
391367b915a5Sbellardif test "$mingw32" = "yes" ; then
391498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
39159fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
39169fe6de94SBlue Swirl  version_major=${rc_version%%.*}
39179fe6de94SBlue Swirl  rc_version=${rc_version#*.}
39189fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
39199fe6de94SBlue Swirl  rc_version=${rc_version#*.}
39209fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
39219fe6de94SBlue Swirl  version_micro=0
39229fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
39239fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3924d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
3925d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
3926d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3927d9840e25STomoki Sekiyama  fi
3928210fa556Spbrookelse
392935f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3930210fa556Spbrookfi
3931128ab2ffSblueswir1
3932dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3933dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3934dffcb71cSMark McLoughlinfi
3935dffcb71cSMark McLoughlin
393683fb7adfSbellardif test "$darwin" = "yes" ; then
393798ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
393883fb7adfSbellardfi
3939b29fe3edSmalc
3940b29fe3edSmalcif test "$aix" = "yes" ; then
394198ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
3942b29fe3edSmalcfi
3943b29fe3edSmalc
3944ec530c81Sbellardif test "$solaris" = "yes" ; then
394598ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
39462358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
39470475a5caSths  if test "$needs_libsunmath" = "yes" ; then
394875b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
39490475a5caSths  fi
3950ec530c81Sbellardfi
3951179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3952179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3953179cf400SAndreas Färberfi
395497a847bcSbellardif test "$static" = "yes" ; then
395598ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
395697a847bcSbellardfi
39571ba16968SStefan Weilif test "$profiler" = "yes" ; then
39582358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
395905c2a3e7Sbellardfi
3960c20709aaSbellardif test "$slirp" = "yes" ; then
396198ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
3962e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3963c20709aaSbellardfi
39648a16d273Sthsif test "$vde" = "yes" ; then
396598ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
39668a16d273Sthsfi
396758952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
396858952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
396958952137SVincenzo Maffionefi
397047e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
397147e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
397247e98658SCorey Bryantfi
39732358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
39740c58ac1cSmalcfor drv in $audio_drv_list; do
3975bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
397698ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
3977923e4521Smalc    if test "$drv" = "fmod"; then
39787aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3979fb065187Sbellard    fi
39800c58ac1cSmalcdone
398167f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
398267f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
398367f86e8eSJuan Quintelafi
3984d5631638Smalcif test "$audio_win_int" = "yes" ; then
3985d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3986d5631638Smalcfi
3987b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
3988b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
3989821601eaSJes Sorensenif test "$vnc" = "yes" ; then
3990821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
3991821601eaSJes Sorensenfi
39928d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
399398ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
39948d5d2d4cSthsfi
39952f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
399698ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
39972f9606b3Saliguorifi
3998821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
39992f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
40002f6f5c7aSCorentin Charyfi
4001821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
4002efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
4003efe556adSCorentin Charyfi
40047536ee4bSTim Hardeckif test "$vnc_ws" = "yes" ; then
40057536ee4bSTim Hardeck  echo "CONFIG_VNC_WS=y" >> $config_host_mak
40067536ee4bSTim Hardeck  echo "VNC_WS_CFLAGS=$vnc_ws_cflags" >> $config_host_mak
40077536ee4bSTim Hardeckfi
400876655d6dSaliguoriif test "$fnmatch" = "yes" ; then
40092358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
401076655d6dSaliguorifi
4011ee682d27SStefan Weilif test "$uuid" = "yes" ; then
4012ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
4013ee682d27SStefan Weilfi
4014dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
4015dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
4016dce512deSChristoph Hellwigfi
4017b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
401898ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
40192358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
402098ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
402198ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
4022a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
402398ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
4024cc8ae6deSpbrookfi
40251ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
402698ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
40278ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
402849ecc3faSbellardfi
402949ecc3faSbellardif test "$cocoa" = "yes" ; then
403098ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
403149ecc3faSbellardfi
40324d3b6f6eSbalrogif test "$curses" = "yes" ; then
403398ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
4034ab4e5602SJan Kiszkafi
4035ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
40362358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
4037ebc996f3SRiku Voipiofi
4038099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
40392358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
4040099d6b0fSRiku Voipiofi
404140ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
404240ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
404340ff6d7eSKevin Wolffi
40443ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
40452358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
40463ce34dfbSvibisreenivasanfi
4047c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
4048c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
4049c2882b96SRiku Voipiofi
4050d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
4051d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
4052d0927938SUlrich Hechtfi
40533d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
40543d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
40553d4fa43eSKusanagi Kouichifi
4056c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
4057c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
4058c727f47dSPeter Maydellfi
4059dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
4060dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
4061dace20dcSPeter Maydellfi
4062d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
4063d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
4064d0927938SUlrich Hechtfi
40654e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
40664e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
40674e0c6529SAlex Blighfi
4068cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
4069cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
4070cd758dd0SAlex Blighfi
40713b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
40723b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
40733b6edd16SPeter Maydellfi
40743b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
40753b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
40763b6edd16SPeter Maydellfi
40773b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
40783b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
40793b6edd16SPeter Maydellfi
4080a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
4081a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
4082a8fd1abaSPeter Maydellfi
40833b3f24adSaurel32if test "$inotify" = "yes" ; then
40842358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
40853b3f24adSaurel32fi
4086c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
4087c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
4088c05c7a73SRiku Voipiofi
40896ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
40906ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
40916ae9a1f4SJuan Quintelafi
40926ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
40936ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
40946ae9a1f4SJuan Quintelafi
4095769ce76dSAlexander Grafif test "$curl" = "yes" ; then
409698ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
4097b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
4098769ce76dSAlexander Graffi
40992e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
410098ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
41012e4d9fb1Saurel32fi
4102fb599c9aSbalrogif test "$bluez" = "yes" ; then
410398ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
4104ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
4105fb599c9aSbalrogfi
4106e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
4107a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
4108a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
4109a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
4110a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
4111a4ccabcfSAnthony Liguorifi
4112e37630caSaliguoriif test "$xen" = "yes" ; then
41136dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
4114d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
4115e37630caSaliguorifi
41165c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
41175c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
41185c6c3a6cSChristoph Hellwigfi
4119758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
4120758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
4121758e8e38SVenkateswararao Jujjuri (JV)fi
41224f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
41234f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
41244f26f2b6SAvi Kivityfi
4125983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
4126758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
4127758e8e38SVenkateswararao Jujjuri (JV)fi
41285e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
41295e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
41305e9be92dSNicholas Bellingerfi
413177755340Sthsif test "$blobs" = "yes" ; then
413298ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
413377755340Sthsfi
4134bf9298b9Saliguoriif test "$iovec" = "yes" ; then
41352358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
4136bf9298b9Saliguorifi
4137ceb42de8Saliguoriif test "$preadv" = "yes" ; then
41382358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
4139ceb42de8Saliguorifi
4140f652e6afSaurel32if test "$fdt" = "yes" ; then
41413f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
4142f652e6afSaurel32fi
4143dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
4144dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
4145dcc38d1cSMarcelo Tosattifi
41469195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
41479195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
41489195b2c2SStefan Weilfi
41495f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
41505f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
41515f6b9e8fSBlue Swirlfi
4152e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
4153e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
4154e78815a5SAndreas Färberfi
4155e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
4156e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
4157e78815a5SAndreas Färberfi
41581e9737daSRichard Hendersonif test "$sigev_thread_id" = "yes" ; then
41591e9737daSRichard Henderson  echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
41601e9737daSRichard Hendersonfi
416197a847bcSbellard
4162cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
4163cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
4164cd4ec0b4SGerd Hoffmannfi
4165cd4ec0b4SGerd Hoffmann
4166111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
4167111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
4168ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
4169ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
4170111a38b0SRobert Relyeafi
4171111a38b0SRobert Relyea
41722b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
41732b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
41742b2325ffSGerd Hoffmannfi
41752b2325ffSGerd Hoffmann
417669354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
417769354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
417869354a83SHans de Goedefi
417969354a83SHans de Goede
4180b1e5fff4SMichael Walleif test "$glx" = "yes" ; then
4181b1e5fff4SMichael Walle  echo "CONFIG_GLX=y" >> $config_host_mak
41822b6b7099SPaolo Bonzini  echo "GLX_LIBS=$glx_libs" >> $config_host_mak
418320ff075bSMichael Wallefi
418420ff075bSMichael Walle
4185c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
4186c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
4187219c2521SStefan Weil  if test "$libiscsi_version" = "1.4.0"; then
4188219c2521SStefan Weil    echo "CONFIG_LIBISCSI_1_4=y" >> $config_host_mak
4189219c2521SStefan Weil  fi
4190c589b249SRonnie Sahlbergfi
4191c589b249SRonnie Sahlberg
41926542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
41936542aa9cSPeter Lieven  echo "CONFIG_LIBNFS=y" >> $config_host_mak
41946542aa9cSPeter Lievenfi
41956542aa9cSPeter Lieven
4196f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
4197f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
4198f794573eSEduardo Otubofi
4199f794573eSEduardo Otubo
420083fb7adfSbellard# XXX: suppress that
42017d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
42022358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
42037d3505c5Sbellardfi
42047d3505c5Sbellard
42052358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
4206c5937220Spbrook
420720ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
420820ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
420920ff6c80SAnthony Liguorifi
42103556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
42113556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
42123556c233SPaolo Bonzinifi
4213f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
4214f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
4215f27aaf4bSChristian Brunnerfi
421620ff6c80SAnthony Liguori
42177c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
421870c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
421970c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
422070c60c08SStefan Hajnoczielse
422170c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
422270c60c08SStefan Hajnoczifi
4223d0e2fce5SAneesh Kumar K.V
4224d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
4225d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
4226d2042378SAneesh Kumar K.Vfi
4227d2042378SAneesh Kumar K.V
4228e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
4229e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
4230e06a765eSHarsh Prateek Borafi
4231e06a765eSHarsh Prateek Bora
4232cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
4233cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
423406d71fa1SPeter Maydellfi
423506d71fa1SPeter Maydell
42363f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
42373f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
42383f4349dcSKevin Wolffi
42393f4349dcSKevin Wolf
42408ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
42418ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
42428ab1bf12SLuiz Capitulinofi
42438ab1bf12SLuiz Capitulino
424476a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
424576a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
424676a347e1SRichard Hendersonfi
424776a347e1SRichard Henderson
4248f540166bSRichard Hendersonif test "$int128" = "yes" ; then
4249f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
4250f540166bSRichard Hendersonfi
4251f540166bSRichard Henderson
42521e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
42531e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
42541e6e9acaSRichard Hendersonfi
42551e6e9acaSRichard Henderson
4256eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
4257eb100396SBharata B Rao  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
4258eb100396SBharata B Raofi
4259eb100396SBharata B Rao
42600c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
42610c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
42620c14fb47SBharata B Raofi
42630c14fb47SBharata B Rao
42647c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
42657c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
42667c815372SBharata B Raofi
42677c815372SBharata B Rao
42680a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
42690a12ec87SRichard W.M. Jones  echo "CONFIG_LIBSSH2=y" >> $config_host_mak
42700a12ec87SRichard W.M. Jonesfi
42710a12ec87SRichard W.M. Jones
4272583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" ; then
42736e790746SPaolo Bonzini  echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
4274583f6e7bSStefan Hajnoczifi
4275583f6e7bSStefan Hajnoczi
42764f18b782SJeff Codyif test "$vhdx" = "yes" ; then
42774f18b782SJeff Cody  echo "CONFIG_VHDX=y" >> $config_host_mak
42784f18b782SJeff Codyfi
42794f18b782SJeff Cody
428068063649Sblueswir1# USB host support
4281b5613fdcSGerd Hoffmannif test "$libusb" = "yes"; then
42822b2325ffSGerd Hoffmann  echo "HOST_USB=libusb legacy" >> $config_host_mak
4283b5613fdcSGerd Hoffmannelse
428498ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
4285b5613fdcSGerd Hoffmannfi
428668063649Sblueswir1
42873b8acc11SPaolo Bonzini# TPM passthrough support?
42883b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
42893b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
42903b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
42913b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
42923b8acc11SPaolo Bonzini  fi
42933b8acc11SPaolo Bonzinifi
42943b8acc11SPaolo Bonzini
4295e4858974SLluís# use default implementation for tracing backend-specific routines
4296e4858974SLluístrace_default=yes
429794a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
42986d8a764eSLluísif test "$trace_backend" = "nop"; then
42996d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
430022890ab5SPrerna Saxenafi
43019410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
43026d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
4303e4858974SLluís  trace_default=no
43046d8a764eSLluís  # Set the appropriate trace file.
4305953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
43069410b56cSPrerna Saxenafi
43076d8a764eSLluísif test "$trace_backend" = "stderr"; then
43086d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
43099a82b6a5SLluís  trace_default=no
43106d8a764eSLluísfi
43116d8a764eSLluísif test "$trace_backend" = "ust"; then
43126d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
43136d8a764eSLluísfi
43146d8a764eSLluísif test "$trace_backend" = "dtrace"; then
43156d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
43166d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
43176d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
43186d8a764eSLluís  fi
4319c276b17dSDaniel P. Berrangefi
4320781e9545SEiichi Tsukataif test "$trace_backend" = "ftrace"; then
4321781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
4322781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4323781e9545SEiichi Tsukata    trace_default=no
4324781e9545SEiichi Tsukata  else
4325*21684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
4326781e9545SEiichi Tsukata  fi
4327781e9545SEiichi Tsukatafi
43289410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
4329e4858974SLluísif test "$trace_default" = "yes"; then
4330e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
4331e4858974SLluísfi
43329410b56cSPrerna Saxena
43332da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
43342da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
43352da776dbSMichael R. Hinesfi
43362da776dbSMichael R. Hines
43375b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
43385b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
43395b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
43405b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
43415b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
43425b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
4343c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
43445b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
43455b5e3037SPaolo Bonzinielse
43465b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
43475b5e3037SPaolo Bonzinifi
43485b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
43495b5e3037SPaolo Bonzini
435098ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
435198ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4352804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4353804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
43541901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
43551901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
435621655882SPaolo Bonziniif test -n "$libtool"; then
435721655882SPaolo Bonzini  echo "INSTALL_PROG=\$(LIBTOOL) --mode=install $install -c -m 0755" >> $config_host_mak
435821655882SPaolo Bonzini  echo "INSTALL_LIB=\$(LIBTOOL) --mode=install $install -c -m 0644" >> $config_host_mak
435921655882SPaolo Bonzinielse
43601901cb14SBrad  echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
436121655882SPaolo Bonzini  echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
436221655882SPaolo Bonzinifi
4363c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
4364804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
4365a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
4366a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
4367a31a8642SMichael S. Tsirkinfi
43682b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
4369804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
437083f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
43713c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
4372804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
437345d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
43743dd46c78SBlue Swirlecho "AS=$as" >> $config_host_mak
43753dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4376804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4377804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
43789fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
437944dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
4380e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
4381a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
4382f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
4383e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
4384e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
4385e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
4386e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
4387e39f0062SPaolo Bonzinifi
438842da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
438942da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
439042da6041SGerd Hoffmannelse
439142da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
439242da6041SGerd Hoffmannfi
4393e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
439437746c5eSMarc-André Lureauecho "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
439573da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
43963e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
4397804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
4398957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
439994dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
4400cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
44011d728c39SBlue Swirlif test "$gcov" = "yes" ; then
44021d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
44031d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
44041d728c39SBlue Swirlfi
4405804edf29SJuan Quintela
44066efd7517SPeter Maydell# use included Linux headers
44076efd7517SPeter Maydellif test "$linux" = "yes" ; then
4408a307beb6SAndreas Färber  mkdir -p linux-headers
44096efd7517SPeter Maydell  case "$cpu" in
4410c72b26ecSRichard Henderson  i386|x86_64|x32)
441108312a63SPeter Maydell    linux_arch=x86
44126efd7517SPeter Maydell    ;;
44136efd7517SPeter Maydell  ppcemb|ppc|ppc64)
441408312a63SPeter Maydell    linux_arch=powerpc
44156efd7517SPeter Maydell    ;;
44166efd7517SPeter Maydell  s390x)
441708312a63SPeter Maydell    linux_arch=s390
441808312a63SPeter Maydell    ;;
44191f080313SClaudio Fontana  aarch64)
44201f080313SClaudio Fontana    linux_arch=arm64
44211f080313SClaudio Fontana    ;;
442208312a63SPeter Maydell  *)
442308312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
442408312a63SPeter Maydell    linux_arch="$cpu"
44256efd7517SPeter Maydell    ;;
44266efd7517SPeter Maydell  esac
442708312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
442808312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
442908312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
443008312a63SPeter Maydell    fi
44316efd7517SPeter Maydellfi
44326efd7517SPeter Maydell
443397a847bcSbellardfor target in $target_list; do
443497a847bcSbellardtarget_dir="$target"
443525be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
4436c1799a84SPaolo Bonzinitarget_name=`echo $target | cut -d '-' -f 1`
443797a847bcSbellardtarget_bigendian="no"
44381f3d3c8fSJuan Quintela
4439c1799a84SPaolo Bonzinicase "$target_name" in
4440d15a9c23SAnthony Green  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
4441ea2d6a39SJuan Quintela  target_bigendian=yes
4442ea2d6a39SJuan Quintela  ;;
4443ea2d6a39SJuan Quintelaesac
444497a847bcSbellardtarget_softmmu="no"
4445997344f3Sbellardtarget_user_only="no"
4446831b7825Sthstarget_linux_user="no"
444784778508Sblueswir1target_bsd_user="no"
44489e407a85Spbrookcase "$target" in
4449c1799a84SPaolo Bonzini  ${target_name}-softmmu)
44509e407a85Spbrook    target_softmmu="yes"
44519e407a85Spbrook    ;;
4452c1799a84SPaolo Bonzini  ${target_name}-linux-user)
44539c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
445476ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a Linux host"
44559c7a4202SBlue Swirl    fi
44569e407a85Spbrook    target_user_only="yes"
44579e407a85Spbrook    target_linux_user="yes"
44589e407a85Spbrook    ;;
4459c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
44609cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
446176ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a BSD host"
44629c7a4202SBlue Swirl    fi
446384778508Sblueswir1    target_user_only="yes"
446484778508Sblueswir1    target_bsd_user="yes"
446584778508Sblueswir1    ;;
44669e407a85Spbrook  *)
446776ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
44689e407a85Spbrook    exit 1
44699e407a85Spbrook    ;;
44709e407a85Spbrookesac
4471831b7825Sths
447297a847bcSbellardmkdir -p $target_dir
447325be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
447497a847bcSbellard
4475e5fe0c52Spbrookbflt="no"
4476c1799a84SPaolo Bonziniinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"`
447756aebc89Spbrookgdb_xml_files=""
44787ba1e619Saliguori
4479c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
44806acff7daSJuan QuintelaTARGET_BASE_ARCH=""
4481e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
4482e73aae67SJuan Quintela
4483c1799a84SPaolo Bonzinicase "$target_name" in
44842408a527Saurel32  i386)
44852408a527Saurel32  ;;
44862408a527Saurel32  x86_64)
44876acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
44882408a527Saurel32  ;;
44892408a527Saurel32  alpha)
44902408a527Saurel32  ;;
44912408a527Saurel32  arm|armeb)
4492b498c8a0SJuan Quintela    TARGET_ARCH=arm
4493e5fe0c52Spbrook    bflt="yes"
449456aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
44952408a527Saurel32  ;;
44966a49fa95SAlexander Graf  aarch64)
44976a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
44986a49fa95SAlexander Graf    bflt="yes"
44996a669427SPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml"
45006a49fa95SAlexander Graf  ;;
45012408a527Saurel32  cris)
45022408a527Saurel32  ;;
4503613a22c9SMichael Walle  lm32)
4504613a22c9SMichael Walle  ;;
45052408a527Saurel32  m68k)
45060938cda5Saurel32    bflt="yes"
450756aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
45082408a527Saurel32  ;;
4509877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
4510877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
451172b675caSEdgar E. Iglesias    bflt="yes"
451272b675caSEdgar E. Iglesias  ;;
45132408a527Saurel32  mips|mipsel)
4514b498c8a0SJuan Quintela    TARGET_ARCH=mips
451525be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
45162408a527Saurel32  ;;
45172408a527Saurel32  mipsn32|mipsn32el)
4518597e2cecSRichard Henderson    TARGET_ARCH=mips64
45196acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
452025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
4521597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
45222408a527Saurel32  ;;
45232408a527Saurel32  mips64|mips64el)
4524b498c8a0SJuan Quintela    TARGET_ARCH=mips64
45256acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
452625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
45272408a527Saurel32  ;;
4528d15a9c23SAnthony Green  moxie)
4529d15a9c23SAnthony Green  ;;
4530e67db06eSJia Liu  or32)
4531e67db06eSJia Liu    TARGET_ARCH=openrisc
4532e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
4533e67db06eSJia Liu  ;;
45342408a527Saurel32  ppc)
4535c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
45362408a527Saurel32  ;;
45372408a527Saurel32  ppcemb)
45386acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4539e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4540c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
45412408a527Saurel32  ;;
45422408a527Saurel32  ppc64)
45436acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4544e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4545c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
45462408a527Saurel32  ;;
45472408a527Saurel32  ppc64abi32)
4548b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
45496acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4550e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
455125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
4552c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
45532408a527Saurel32  ;;
45542408a527Saurel32  sh4|sh4eb)
4555b498c8a0SJuan Quintela    TARGET_ARCH=sh4
45564dbed897Spbrook    bflt="yes"
45572408a527Saurel32  ;;
45582408a527Saurel32  sparc)
45592408a527Saurel32  ;;
45602408a527Saurel32  sparc64)
45616acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
45622408a527Saurel32  ;;
45632408a527Saurel32  sparc32plus)
4564b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
45656acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
4566e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
456725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
45682408a527Saurel32  ;;
456924e804ecSAlexander Graf  s390x)
457024e804ecSAlexander Graf  ;;
4571d2fbca94SGuan Xuetao  unicore32)
4572d2fbca94SGuan Xuetao  ;;
4573cfa550c6SMax Filippov  xtensa|xtensaeb)
4574cfa550c6SMax Filippov    TARGET_ARCH=xtensa
4575cfa550c6SMax Filippov  ;;
45762408a527Saurel32  *)
457776ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
45782408a527Saurel32  ;;
45792408a527Saurel32esac
45805e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
45815e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
45825e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
45835e8861a0SPaolo Bonzinifi
45845e8861a0SPaolo Bonzini
45855e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
45865e8861a0SPaolo Bonzini
458799afc91dSDaniel P. Berrangeupper() {
458899afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
458999afc91dSDaniel P. Berrange}
459099afc91dSDaniel P. Berrange
459199afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
459225be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
4593c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
459425be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
4595e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
4596e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
4597e6e91b9cSJuan Quintelafi
459825be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
4599c1799a84SPaolo Bonzinicase "$target_name" in
46001b0c87fcSJuan Quintela  i386|x86_64)
46011b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
460225be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
4603eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
4604eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
4605eb6fda0fSAnthony PERARD      fi
4606432d268cSJun Nakajima    fi
460759d21e53SAlexander Graf    ;;
460859d21e53SAlexander Graf  *)
46091b0c87fcSJuan Quintelaesac
4610c1799a84SPaolo Bonzinicase "$target_name" in
461170a5f682SPeter Maydell  aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x)
4612c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
4613c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
4614c1799a84SPaolo Bonzini      \( "$target_name" = "$cpu" -o \
4615c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
4616c1799a84SPaolo Bonzini      \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
4617c1799a84SPaolo Bonzini      \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
4618c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
4619c1799a84SPaolo Bonzini      \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
4620c1799a84SPaolo Bonzini      \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
462125be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
46221ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
4623d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
4624d5970055SMichael S. Tsirkin      fi
4625c59249f9SJuan Quintela    fi
4626c59249f9SJuan Quintelaesac
4627de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
462825be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
462997a847bcSbellardfi
463097a847bcSbellardif test "$target_softmmu" = "yes" ; then
463125be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
4632de83cd02Sbellardfi
4633997344f3Sbellardif test "$target_user_only" = "yes" ; then
463425be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
4635a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
4636997344f3Sbellardfi
4637831b7825Sthsif test "$target_linux_user" = "yes" ; then
463825be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
4639831b7825Sthsfi
464056aebc89Spbrooklist=""
464156aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
464256aebc89Spbrook  for x in $gdb_xml_files; do
464356aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
464456aebc89Spbrook  done
464525be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
46463d0f1517SJuan Quintelafi
4647de83cd02Sbellard
4648e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
464925be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
4650e5fe0c52Spbrookfi
4651379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
465225be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
4653379f6698SPaul Brookfi
465484778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
465525be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
465684778508Sblueswir1fi
46575b0753e0Sbellard
46584afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
4659fa282484SJuan Quintela
46604afddb55SJuan Quintelacflags=""
4661fa282484SJuan Quintelaldflags=""
46629b8e111fSJuan Quintela
466364656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
466464656024SJuan Quintela  case "$i" in
466564656024SJuan Quintela  alpha)
466625be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
466776cad711SPaolo Bonzini    echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
466864656024SJuan Quintela  ;;
466964656024SJuan Quintela  arm)
467025be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
467176cad711SPaolo Bonzini    echo "CONFIG_ARM_DIS=y"  >> config-all-disas.mak
4672999b53ecSClaudio Fontana    if test -n "${cxx}"; then
4673999b53ecSClaudio Fontana      echo "CONFIG_ARM_A64_DIS=y"  >> $config_target_mak
4674999b53ecSClaudio Fontana      echo "CONFIG_ARM_A64_DIS=y"  >> config-all-disas.mak
4675999b53ecSClaudio Fontana    fi
467664656024SJuan Quintela  ;;
467764656024SJuan Quintela  cris)
467825be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
467976cad711SPaolo Bonzini    echo "CONFIG_CRIS_DIS=y"  >> config-all-disas.mak
468064656024SJuan Quintela  ;;
468164656024SJuan Quintela  hppa)
468225be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
468376cad711SPaolo Bonzini    echo "CONFIG_HPPA_DIS=y"  >> config-all-disas.mak
468464656024SJuan Quintela  ;;
4685c72b26ecSRichard Henderson  i386|x86_64|x32)
468625be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
468776cad711SPaolo Bonzini    echo "CONFIG_I386_DIS=y"  >> config-all-disas.mak
468864656024SJuan Quintela  ;;
4689903ec55cSAurelien Jarno  ia64*)
4690903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
469176cad711SPaolo Bonzini    echo "CONFIG_IA64_DIS=y"  >> config-all-disas.mak
4692903ec55cSAurelien Jarno  ;;
469379368f49SMichael Walle  lm32)
469479368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
469576cad711SPaolo Bonzini    echo "CONFIG_LM32_DIS=y"  >> config-all-disas.mak
469679368f49SMichael Walle  ;;
469764656024SJuan Quintela  m68k)
469825be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
469976cad711SPaolo Bonzini    echo "CONFIG_M68K_DIS=y"  >> config-all-disas.mak
470064656024SJuan Quintela  ;;
4701877fdc12SEdgar E. Iglesias  microblaze*)
470225be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
470376cad711SPaolo Bonzini    echo "CONFIG_MICROBLAZE_DIS=y"  >> config-all-disas.mak
470464656024SJuan Quintela  ;;
470564656024SJuan Quintela  mips*)
470625be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
470776cad711SPaolo Bonzini    echo "CONFIG_MIPS_DIS=y"  >> config-all-disas.mak
470864656024SJuan Quintela  ;;
4709d15a9c23SAnthony Green  moxie*)
4710d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> $config_target_mak
4711d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> config-all-disas.mak
4712d15a9c23SAnthony Green  ;;
4713e67db06eSJia Liu  or32)
4714e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
471576cad711SPaolo Bonzini    echo "CONFIG_OPENRISC_DIS=y"  >> config-all-disas.mak
4716e67db06eSJia Liu  ;;
471764656024SJuan Quintela  ppc*)
471825be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
471976cad711SPaolo Bonzini    echo "CONFIG_PPC_DIS=y"  >> config-all-disas.mak
472064656024SJuan Quintela  ;;
472124e804ecSAlexander Graf  s390*)
472225be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
472376cad711SPaolo Bonzini    echo "CONFIG_S390_DIS=y"  >> config-all-disas.mak
472464656024SJuan Quintela  ;;
472564656024SJuan Quintela  sh4)
472625be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
472776cad711SPaolo Bonzini    echo "CONFIG_SH4_DIS=y"  >> config-all-disas.mak
472864656024SJuan Quintela  ;;
472964656024SJuan Quintela  sparc*)
473025be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
473176cad711SPaolo Bonzini    echo "CONFIG_SPARC_DIS=y"  >> config-all-disas.mak
473264656024SJuan Quintela  ;;
4733cfa550c6SMax Filippov  xtensa*)
4734cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
473576cad711SPaolo Bonzini    echo "CONFIG_XTENSA_DIS=y"  >> config-all-disas.mak
4736cfa550c6SMax Filippov  ;;
473764656024SJuan Quintela  esac
473864656024SJuan Quinteladone
47399195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
47409195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
474176cad711SPaolo Bonzini  echo "CONFIG_TCI_DIS=y"  >> config-all-disas.mak
47429195b2c2SStefan Weilfi
474364656024SJuan Quintela
47446ee7126fSJuan Quintelacase "$ARCH" in
47456ee7126fSJuan Quintelaalpha)
47466ee7126fSJuan Quintela  # Ensure there's only a single GP
47476ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
47486ee7126fSJuan Quintela;;
47496ee7126fSJuan Quintelaesac
47506ee7126fSJuan Quintela
4751d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
475225be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4753d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4754d02c1db3SJuan Quintela    cflags="-p $cflags"
4755d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4756d02c1db3SJuan Quintela  fi
4757d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4758d02c1db3SJuan Quintela    ldflags="-p $ldflags"
475925be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4760d02c1db3SJuan Quintela  fi
4761d02c1db3SJuan Quintelafi
4762d02c1db3SJuan Quintela
47639b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4764964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
4765fa282484SJuan Quintelafi
4766fa282484SJuan Quintela
476725be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
476825be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4769fa282484SJuan Quintela
477097a847bcSbellarddone # for target in $targets
47717d13299dSbellard
4772b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
4773b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
4774b776eca1SGerd Hoffmannfi
4775b776eca1SGerd Hoffmann
47762da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
47772da776dbSMichael R. Hinesecho "CONFIG_RDMA=y" >> $config_host_mak
47782da776dbSMichael R. Hinesfi
47792da776dbSMichael R. Hines
4780a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
4781a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
4782a540f158SPeter Crosthwaitefi
4783a540f158SPeter Crosthwaite
4784d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
4785f93296eaSWenchao XiaDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
47862b170effSMichael TokarevDIRS="$DIRS fsdev"
47879933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
47882d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
47892dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
4790c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4791c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
4792aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
4793ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4794446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
47959933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
47962d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
47974652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
4798753d11f2SRichard Hendersonfor bios_file in \
4799753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
48005acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
4801753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4802753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4803e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
4804753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4805753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4806753d11f2SRichard Hendersondo
48077ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
48087ea78b74SJan Kiszkadone
4809c2304b52SMarcel Apfelbaumfor test_file in `find $source_path/tests/acpi-test-data -type f`
4810c2304b52SMarcel Apfelbaumdo
4811c2304b52SMarcel Apfelbaum    FILES="$FILES tests/acpi-test-data`echo $test_file | sed -e 's/.*acpi-test-data//'`"
4812c2304b52SMarcel Apfelbaumdone
4813d1807a4fSPaolo Bonzinimkdir -p $DIRS
48147d13299dSbellardfor f in $FILES ; do
481572b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4816f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4817f9245e10SPeter Maydell    fi
48187d13299dSbellarddone
48191ad2134fSPaul Brook
4820c34ebfdcSAnthony Liguori# temporary config to build submodules
48212d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4822c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
482337116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4824c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
48253dd46c78SBlue Swirl    echo "AS=$as" >> $config_mak
4826c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4827c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
48283dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
4829c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4830a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
4831c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4832c34ebfdcSAnthony Liguoridone
4833c34ebfdcSAnthony Liguori
4834b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4835b40292e7SJan Kiszka  mkdir -p QMP
4836b40292e7SJan Kiszkafi
4837