xref: /openbmc/qemu/configure (revision 0d185e638861bd9b05b2abb43774a368cadabd38)
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
3076ad07a4SPeter Maydellerror_exit() {
3176ad07a4SPeter Maydell    echo
3276ad07a4SPeter Maydell    echo "ERROR: $1"
3376ad07a4SPeter Maydell    while test -n "$2"; do
3476ad07a4SPeter Maydell        echo "       $2"
3576ad07a4SPeter Maydell        shift
3676ad07a4SPeter Maydell    done
3776ad07a4SPeter Maydell    echo
3876ad07a4SPeter Maydell    exit 1
3976ad07a4SPeter Maydell}
4076ad07a4SPeter Maydell
418dc38a78SPeter Maydelldo_cc() {
428dc38a78SPeter Maydell    # Run the compiler, capturing its output to the log.
438dc38a78SPeter Maydell    echo $cc "$@" >> config.log
448dc38a78SPeter Maydell    $cc "$@" >> config.log 2>&1 || return $?
458dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
468dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
478dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
488dc38a78SPeter Maydell    # obvious to developers.
498dc38a78SPeter Maydell    if test "$werror" != "yes"; then
508dc38a78SPeter Maydell        return 0
518dc38a78SPeter Maydell    fi
528dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
538dc38a78SPeter Maydell    case "$*" in
548dc38a78SPeter Maydell        *-Werror*)
558dc38a78SPeter Maydell           return 0
568dc38a78SPeter Maydell        ;;
578dc38a78SPeter Maydell    esac
588dc38a78SPeter Maydell    echo $cc -Werror "$@" >> config.log
598dc38a78SPeter Maydell    $cc -Werror "$@" >> config.log 2>&1 && return $?
6076ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
6176ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
6276ad07a4SPeter Maydell        "will be at the bottom of config.log." \
6376ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
648dc38a78SPeter Maydell}
658dc38a78SPeter Maydell
6652166aa0SJuan Quintelacompile_object() {
678dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
6852166aa0SJuan Quintela}
6952166aa0SJuan Quintela
7052166aa0SJuan Quintelacompile_prog() {
7152166aa0SJuan Quintela  local_cflags="$1"
7252166aa0SJuan Quintela  local_ldflags="$2"
738dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
7452166aa0SJuan Quintela}
7552166aa0SJuan Quintela
7611568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
7711568d6dSPaolo Bonzinisymlink() {
7872b8b5a1SStefan Weil  rm -rf "$2"
79ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
8072b8b5a1SStefan Weil  ln -s "$1" "$2"
8111568d6dSPaolo Bonzini}
8211568d6dSPaolo Bonzini
830dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
840dba6195SLoïc Minier# executable or a builtin)
850dba6195SLoïc Minierhas() {
860dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
870dba6195SLoïc Minier}
880dba6195SLoïc Minier
890dba6195SLoïc Minier# search for an executable in PATH
900dba6195SLoïc Minierpath_of() {
910dba6195SLoïc Minier    local_command="$1"
920dba6195SLoïc Minier    local_ifs="$IFS"
930dba6195SLoïc Minier    local_dir=""
940dba6195SLoïc Minier
950dba6195SLoïc Minier    # pathname has a dir component?
960dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
970dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
980dba6195SLoïc Minier            echo "$local_command"
990dba6195SLoïc Minier            return 0
1000dba6195SLoïc Minier        fi
1010dba6195SLoïc Minier    fi
1020dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1030dba6195SLoïc Minier        return 1
1040dba6195SLoïc Minier    fi
1050dba6195SLoïc Minier
1060dba6195SLoïc Minier    IFS=:
1070dba6195SLoïc Minier    for local_dir in $PATH; do
1080dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1090dba6195SLoïc Minier            echo "$local_dir/$local_command"
1100dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1110dba6195SLoïc Minier            return 0
1120dba6195SLoïc Minier        fi
1130dba6195SLoïc Minier    done
1140dba6195SLoïc Minier    # not found
1150dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1160dba6195SLoïc Minier    return 1
1170dba6195SLoïc Minier}
1180dba6195SLoïc Minier
1197d13299dSbellard# default parameters
120ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
1212ff6b91eSJuan Quintelacpu=""
1221e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
12343ce4dfeSbellardstatic="no"
1247d13299dSbellardcross_prefix=""
1250c58ac1cSmalcaudio_drv_list=""
126b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
127b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
128e49d021eSPeter Maydellhost_cc="cc"
12973da375eSJuan Quintelalibs_softmmu=""
1303e2e0e6bSJuan Quintelalibs_tools=""
13167f86e8eSJuan Quintelaaudio_pt_int=""
132d5631638Smalcaudio_win_int=""
1332b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
134957f1f99SMichael Rothlibs_qga=""
1355bc62e01SGerd Hoffmanndebug_info="yes"
136ac0df51dSaliguori
137afb63ebdSStefan Weil# Don't accept a target_list environment variable.
138afb63ebdSStefan Weilunset target_list
139377529c0SPaolo Bonzini
140377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
141377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
142377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
143377529c0SPaolo Bonzini#              unless --disable-foo is given
144377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
145377529c0SPaolo Bonzini#              feature will searched for,
146377529c0SPaolo Bonzini#              if not found, configure exits with error
147377529c0SPaolo Bonzini#
148377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
149377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
150377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
151377529c0SPaolo Bonzini
152377529c0SPaolo Bonzinibluez=""
153377529c0SPaolo Bonzinibrlapi=""
154377529c0SPaolo Bonzinicurl=""
155377529c0SPaolo Bonzinicurses=""
156377529c0SPaolo Bonzinidocs=""
157377529c0SPaolo Bonzinifdt=""
158377529c0SPaolo Bonzininptl=""
159e2134eb9SGerd Hoffmannpixman=""
160377529c0SPaolo Bonzinisdl=""
161983eef5aSMeador Ingevirtfs=""
162821601eaSJes Sorensenvnc="yes"
163377529c0SPaolo Bonzinisparse="no"
164377529c0SPaolo Bonziniuuid=""
165377529c0SPaolo Bonzinivde=""
166377529c0SPaolo Bonzinivnc_tls=""
167377529c0SPaolo Bonzinivnc_sasl=""
168377529c0SPaolo Bonzinivnc_jpeg=""
169377529c0SPaolo Bonzinivnc_png=""
1707536ee4bSTim Hardeckvnc_ws=""
171377529c0SPaolo Bonzinixen=""
172d5b93ddfSAnthony PERARDxen_ctrl_version=""
173eb6fda0fSAnthony PERARDxen_pci_passthrough=""
174377529c0SPaolo Bonzinilinux_aio=""
17547e98658SCorey Bryantcap_ng=""
176377529c0SPaolo Bonziniattr=""
1774f26f2b6SAvi Kivitylibattr=""
178377529c0SPaolo Bonzinixfs=""
179377529c0SPaolo Bonzini
180d41a75a2SBradvhost_net="no"
1815e9be92dSNicholas Bellingervhost_scsi="no"
182d41a75a2SBradkvm="no"
183377529c0SPaolo Bonzinigprof="no"
184377529c0SPaolo Bonzinidebug_tcg="no"
185377529c0SPaolo Bonzinidebug="no"
186377529c0SPaolo Bonzinistrip_opt="yes"
1879195b2c2SStefan Weiltcg_interpreter="no"
188377529c0SPaolo Bonzinibigendian="no"
189377529c0SPaolo Bonzinimingw32="no"
1901d728c39SBlue Swirlgcov="no"
1911d728c39SBlue Swirlgcov_tool="gcov"
192377529c0SPaolo BonziniEXESUF=""
193377529c0SPaolo Bonziniprefix="/usr/local"
194377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
195528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
196850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
197377529c0SPaolo Bonzinibindir="\${prefix}/bin"
1983aa5d2beSAlon Levylibdir="\${prefix}/lib"
1998bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
2000f94d6daSAlon Levyincludedir="\${prefix}/include"
201377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
202785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
203377529c0SPaolo Bonziniconfsuffix="/qemu"
204377529c0SPaolo Bonzinislirp="yes"
205377529c0SPaolo Bonzinifmod_lib=""
206377529c0SPaolo Bonzinifmod_inc=""
207377529c0SPaolo Bonzinioss_lib=""
208377529c0SPaolo Bonzinibsd="no"
209377529c0SPaolo Bonzinilinux="no"
210377529c0SPaolo Bonzinisolaris="no"
211377529c0SPaolo Bonziniprofiler="no"
212377529c0SPaolo Bonzinicocoa="no"
213377529c0SPaolo Bonzinisoftmmu="yes"
214377529c0SPaolo Bonzinilinux_user="no"
215377529c0SPaolo Bonzinibsd_user="no"
21630163d89SPeter Maydellguest_base="yes"
217377529c0SPaolo Bonziniuname_release=""
218377529c0SPaolo Bonzinimixemu="no"
219377529c0SPaolo Bonziniaix="no"
220377529c0SPaolo Bonziniblobs="yes"
221377529c0SPaolo Bonzinipkgversion=""
22240d6444eSAvi Kivitypie=""
223377529c0SPaolo Bonzinizero_malloc=""
2243556c233SPaolo Bonziniqom_cast_debug="yes"
225377529c0SPaolo Bonzinitrace_backend="nop"
226377529c0SPaolo Bonzinitrace_file="trace"
227377529c0SPaolo Bonzinispice=""
228377529c0SPaolo Bonzinirbd=""
229111a38b0SRobert Relyeasmartcard_nss=""
2302b2325ffSGerd Hoffmannlibusb=""
23169354a83SHans de Goedeusb_redir=""
232b1e5fff4SMichael Walleglx=""
2331ece9905SAlon Levyzlib="yes"
234d138cee9SMichael Rothguest_agent="yes"
2354b1c11fdSDaniel P. Berrangewant_tools="yes"
236c589b249SRonnie Sahlberglibiscsi=""
237519175a2SAlex Barcelocoroutine=""
238f794573eSEduardo Otuboseccomp=""
239eb100396SBharata B Raoglusterfs=""
240583f6e7bSStefan Hajnoczivirtio_blk_data_plane=""
241a4ccabcfSAnthony Liguorigtk=""
242528de90aSDaniel P. Berrangegtkabi="2.0"
243ab214c29SStefan Bergertpm="no"
2440a12ec87SRichard W.M. Joneslibssh2=""
245377529c0SPaolo Bonzini
246ac0df51dSaliguori# parse CC options first
247ac0df51dSaliguorifor opt do
248ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
249ac0df51dSaliguori  case "$opt" in
250ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
251ac0df51dSaliguori  ;;
2523d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
253ac0df51dSaliguori  ;;
254ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
255ca4deeb1SPaolo Bonzini  ;;
2562ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2572ff6b91eSJuan Quintela  ;;
258a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
259f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
260e2a2ed06SJuan Quintela  ;;
261e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
262f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
263e2a2ed06SJuan Quintela  ;;
2645bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2655bc62e01SGerd Hoffmann  ;;
2665bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2675bc62e01SGerd Hoffmann  ;;
268ac0df51dSaliguori  esac
269ac0df51dSaliguoridone
270ac0df51dSaliguori# OS specific
271ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
27293148aa5SStefan Weil# we can eliminate its usage altogether.
273ac0df51dSaliguori
274e49d021eSPeter Maydell# Preferred compiler:
275e49d021eSPeter Maydell#  ${CC} (if set)
276e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
277e49d021eSPeter Maydell#  system compiler
278e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
279e49d021eSPeter Maydell  cc="$host_cc"
280e49d021eSPeter Maydellelse
281b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
282e49d021eSPeter Maydellfi
283e49d021eSPeter Maydell
284b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
2853dd46c78SBlue Swirlas="${AS-${cross_prefix}as}"
2863dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
287b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
288b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
2893f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
290b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
291b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
29217884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
29317884d7bSSergei Trofimovichquery_pkg_config() {
29417884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
29517884d7bSSergei Trofimovich}
29617884d7bSSergei Trofimovichpkg_config=query_pkg_config
297b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
298ac0df51dSaliguori
299be17dc90SMichael S. Tsirkin# default flags for all hosts
300be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
301f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
302c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
303be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
3046b4c305cSPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
3055bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
3065bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
307be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
3085bc62e01SGerd Hoffmannfi
309be17dc90SMichael S. Tsirkin
310ca4deeb1SPaolo Bonzini# make source path absolute
311ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
312ca4deeb1SPaolo Bonzini
313ac0df51dSaliguoricheck_define() {
314ac0df51dSaliguoricat > $TMPC <<EOF
315ac0df51dSaliguori#if !defined($1)
316fd786e1aSPeter Maydell#error $1 not defined
317ac0df51dSaliguori#endif
318ac0df51dSaliguoriint main(void) { return 0; }
319ac0df51dSaliguoriEOF
32052166aa0SJuan Quintela  compile_object
321ac0df51dSaliguori}
322ac0df51dSaliguori
323bbea4050SPeter Maydellif check_define __linux__ ; then
324bbea4050SPeter Maydell  targetos="Linux"
325bbea4050SPeter Maydellelif check_define _WIN32 ; then
326bbea4050SPeter Maydell  targetos='MINGW32'
327bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
328bbea4050SPeter Maydell  targetos='OpenBSD'
329bbea4050SPeter Maydellelif check_define __sun__ ; then
330bbea4050SPeter Maydell  targetos='SunOS'
331bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
332bbea4050SPeter Maydell  targetos='Haiku'
333bbea4050SPeter Maydellelse
334bbea4050SPeter Maydell  targetos=`uname -s`
335bbea4050SPeter Maydellfi
336bbea4050SPeter Maydell
337bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
338bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
339bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
340bbea4050SPeter Maydell# the correct CPU with the --cpu option.
341bbea4050SPeter Maydellcase $targetos in
342bbea4050SPeter MaydellDarwin)
343bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
344bbea4050SPeter Maydell  # run 64-bit userspace code.
345bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
346bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
347bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
348bbea4050SPeter Maydell    cpu="x86_64"
349bbea4050SPeter Maydell  fi
350bbea4050SPeter Maydell  ;;
351bbea4050SPeter MaydellSunOS)
352bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
353bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
354bbea4050SPeter Maydell    cpu="x86_64"
355bbea4050SPeter Maydell  fi
356bbea4050SPeter Maydellesac
357bbea4050SPeter Maydell
3582ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3592ff6b91eSJuan Quintela  # command line argument
3602ff6b91eSJuan Quintela  :
3612ff6b91eSJuan Quintelaelif check_define __i386__ ; then
362ac0df51dSaliguori  cpu="i386"
363ac0df51dSaliguorielif check_define __x86_64__ ; then
364ac0df51dSaliguori  cpu="x86_64"
3653aa9bd6cSblueswir1elif check_define __sparc__ ; then
3663aa9bd6cSblueswir1  if check_define __arch64__ ; then
3673aa9bd6cSblueswir1    cpu="sparc64"
3683aa9bd6cSblueswir1  else
3693aa9bd6cSblueswir1    cpu="sparc"
3703aa9bd6cSblueswir1  fi
371fdf7ed96Smalcelif check_define _ARCH_PPC ; then
372fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
373fdf7ed96Smalc    cpu="ppc64"
374ac0df51dSaliguori  else
375fdf7ed96Smalc    cpu="ppc"
376fdf7ed96Smalc  fi
377afa05235SAurelien Jarnoelif check_define __mips__ ; then
378afa05235SAurelien Jarno  cpu="mips"
379477ba620SAurelien Jarnoelif check_define __ia64__ ; then
380477ba620SAurelien Jarno  cpu="ia64"
381d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
382d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
383d66ed0eaSAurelien Jarno    cpu="s390x"
384d66ed0eaSAurelien Jarno  else
385d66ed0eaSAurelien Jarno    cpu="s390"
386d66ed0eaSAurelien Jarno  fi
38721d89f84SPeter Maydellelif check_define __arm__ ; then
38821d89f84SPeter Maydell  cpu="arm"
3891f080313SClaudio Fontanaelif check_define __aarch64__ ; then
3901f080313SClaudio Fontana  cpu="aarch64"
391f28ffed5SBradelif check_define __hppa__ ; then
392f28ffed5SBrad  cpu="hppa"
393fdf7ed96Smalcelse
394fdf7ed96Smalc  cpu=`uname -m`
395ac0df51dSaliguorifi
396ac0df51dSaliguori
397359bc95dSPeter MaydellARCH=
398359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
399359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
4007d13299dSbellardcase "$cpu" in
401359bc95dSPeter Maydell  ia64|ppc|ppc64|s390|s390x|sparc64)
402ea8f20f8SJuan Quintela    cpu="$cpu"
403ea8f20f8SJuan Quintela  ;;
4047d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
40597a847bcSbellard    cpu="i386"
4067d13299dSbellard  ;;
407aaa5fa14Saurel32  x86_64|amd64)
408aaa5fa14Saurel32    cpu="x86_64"
409aaa5fa14Saurel32  ;;
41021d89f84SPeter Maydell  armv*b|armv*l|arm)
41121d89f84SPeter Maydell    cpu="arm"
4127d13299dSbellard  ;;
4131f080313SClaudio Fontana  aarch64)
4141f080313SClaudio Fontana    cpu="aarch64"
4151f080313SClaudio Fontana  ;;
416f28ffed5SBrad  hppa|parisc|parisc64)
417f54b3f92Saurel32    cpu="hppa"
418f54b3f92Saurel32  ;;
419afa05235SAurelien Jarno  mips*)
420afa05235SAurelien Jarno    cpu="mips"
421afa05235SAurelien Jarno  ;;
4223142255cSblueswir1  sparc|sun4[cdmuv])
423ae228531Sbellard    cpu="sparc"
424ae228531Sbellard  ;;
4257d13299dSbellard  *)
426359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
427359bc95dSPeter Maydell    ARCH=unknown
4287d13299dSbellard  ;;
4297d13299dSbellardesac
430359bc95dSPeter Maydellif test -z "$ARCH"; then
431359bc95dSPeter Maydell  ARCH="$cpu"
432359bc95dSPeter Maydellfi
433e2d52ad3SJuan Quintela
4347d13299dSbellard# OS specific
4350dbfc675SJuan Quintela
4367d13299dSbellardcase $targetos in
437c326e0afSbellardCYGWIN*)
438c326e0afSbellard  mingw32="yes"
439a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
440d5631638Smalc  audio_possible_drivers="winwave sdl"
441d5631638Smalc  audio_drv_list="winwave"
442c326e0afSbellard;;
44367b915a5SbellardMINGW32*)
44467b915a5Sbellard  mingw32="yes"
445d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
446d5631638Smalc  audio_drv_list="winwave"
44767b915a5Sbellard;;
4485c40d2bdSthsGNU/kFreeBSD)
449a167ba50SAurelien Jarno  bsd="yes"
4500c58ac1cSmalc  audio_drv_list="oss"
451f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4525c40d2bdSths;;
4537d3505c5SbellardFreeBSD)
4547d3505c5Sbellard  bsd="yes"
4550db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4560c58ac1cSmalc  audio_drv_list="oss"
457f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
458f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
459f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
4607d3505c5Sbellard;;
461c5e97233Sblueswir1DragonFly)
462c5e97233Sblueswir1  bsd="yes"
4630db4a067SPaolo Bonzini  make="${MAKE-gmake}"
464c5e97233Sblueswir1  audio_drv_list="oss"
465c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
466c5e97233Sblueswir1;;
4677d3505c5SbellardNetBSD)
4687d3505c5Sbellard  bsd="yes"
4690db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4700c58ac1cSmalc  audio_drv_list="oss"
471c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4728ef92a88Sblueswir1  oss_lib="-lossaudio"
4737d3505c5Sbellard;;
4747d3505c5SbellardOpenBSD)
4757d3505c5Sbellard  bsd="yes"
4760db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4774f6ab397SBrad Smith  audio_drv_list="sdl"
4784f6ab397SBrad Smith  audio_possible_drivers="sdl esd"
4797d3505c5Sbellard;;
48083fb7adfSbellardDarwin)
48183fb7adfSbellard  bsd="yes"
48283fb7adfSbellard  darwin="yes"
4831b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
484a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4850c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4861b0f9cc2Saliguori  else
487a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
4881b0f9cc2Saliguori  fi
489fd677642Sths  cocoa="yes"
4900c58ac1cSmalc  audio_drv_list="coreaudio"
491c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4920c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4937973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
494a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
495a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
496a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
49783fb7adfSbellard;;
498ec530c81SbellardSunOS)
499ec530c81Sbellard  solaris="yes"
5000db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5010db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
502fa58948dSBlue Swirl  ld="gld"
503e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
5040475a5caSths  needs_libsunmath="no"
505c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
506c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
5070475a5caSths    if test "$solarisrev" -le 9 ; then
5080475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
5090475a5caSths        needs_libsunmath="yes"
510f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
511f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
512f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
5130475a5caSths      else
51476ad07a4SPeter Maydell        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
51576ad07a4SPeter Maydell            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
51676ad07a4SPeter Maydell            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
51776ad07a4SPeter Maydell            "Studio 11 can be downloaded from www.sun.com."
5180475a5caSths      fi
5190475a5caSths    fi
52086b2bd93Sths  fi
5216b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
5220c58ac1cSmalc    audio_drv_list="oss"
5236b4d2ba1Sths  fi
524c2de5c91Smalc  audio_possible_drivers="oss sdl"
525d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
526d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
527d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
528d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
529a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
530560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
531560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
532560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
533ec530c81Sbellard;;
534b29fe3edSmalcAIX)
535b29fe3edSmalc  aix="yes"
5360db4a067SPaolo Bonzini  make="${MAKE-gmake}"
537b29fe3edSmalc;;
538179cf400SAndreas FärberHaiku)
539179cf400SAndreas Färber  haiku="yes"
540179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
541179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
542179cf400SAndreas Färber;;
543fb065187Sbellard*)
5440c58ac1cSmalc  audio_drv_list="oss"
545b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5465327cf48Sbellard  linux="yes"
547831b7825Sths  linux_user="yes"
54868063649Sblueswir1  usb="linux"
549af2be207SJan Kiszka  kvm="yes"
550af2be207SJan Kiszka  vhost_net="yes"
5515e9be92dSNicholas Bellinger  vhost_scsi="yes"
55207f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
553c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
554c9ec1fe4Sbellard  fi
555a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
556fb065187Sbellard;;
5577d13299dSbellardesac
5587d13299dSbellard
5597d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
560b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
56145f0b043SEd Maste    if [ "$targetos" != "FreeBSD" ]; then
56268063649Sblueswir1      usb="bsd"
56345f0b043SEd Maste    fi
56484778508Sblueswir1    bsd_user="yes"
5657d3505c5Sbellard  fi
56608de3949SAndreas Färberfi
5677d3505c5Sbellard
5680db4a067SPaolo Bonzini: ${make=${MAKE-make}}
5690db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
570c886edfbSBlue Swirl: ${python=${PYTHON-python}}
571e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
5720db4a067SPaolo Bonzini
5733c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
5743c4a4d0dSPeter Maydellif has clang; then
5753c4a4d0dSPeter Maydell  objcc=clang
5763c4a4d0dSPeter Maydellelse
5773c4a4d0dSPeter Maydell  objcc="$cc"
5783c4a4d0dSPeter Maydellfi
5793c4a4d0dSPeter Maydell
5803457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
5813457a3f8SJuan Quintela  EXESUF=".exe"
582a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
583e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
584e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
585f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
586f7cf5d5bSStefan Weilcat > $TMPC << EOF
587f7cf5d5bSStefan Weilint main(void) { return 0; }
588f7cf5d5bSStefan WeilEOF
589f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
590f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
591f7cf5d5bSStefan Weil  fi
592c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
593683035deSPaolo Bonzini  mandir="\${prefix}"
594528ae5b8SEduardo Habkost  datadir="\${prefix}"
595850da188SEduardo Habkost  qemu_docdir="\${prefix}"
596683035deSPaolo Bonzini  bindir="\${prefix}"
597683035deSPaolo Bonzini  sysconfdir="\${prefix}"
5985a699bbbSLaszlo Ersek  local_statedir=
599683035deSPaolo Bonzini  confsuffix=""
600368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
6013457a3f8SJuan Quintelafi
6023457a3f8SJuan Quintela
603487fefdbSAnthony Liguoriwerror=""
60485aa5189Sbellard
6057d13299dSbellardfor opt do
606a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
6077d13299dSbellard  case "$opt" in
6082efc3265Sbellard  --help|-h) show_help=yes
6092efc3265Sbellard  ;;
61099123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
61199123e13SMike Frysinger  ;;
612b1a550a0Spbrook  --prefix=*) prefix="$optarg"
6137d13299dSbellard  ;;
614b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
61532ce6337Sbellard  ;;
616ca4deeb1SPaolo Bonzini  --source-path=*)
6177d13299dSbellard  ;;
618ac0df51dSaliguori  --cross-prefix=*)
6197d13299dSbellard  ;;
620ac0df51dSaliguori  --cc=*)
6217d13299dSbellard  ;;
622b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
62383469015Sbellard  ;;
6243c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
6253c4a4d0dSPeter Maydell  ;;
626b1a550a0Spbrook  --make=*) make="$optarg"
6277d13299dSbellard  ;;
6286a882643Spbrook  --install=*) install="$optarg"
6296a882643Spbrook  ;;
630c886edfbSBlue Swirl  --python=*) python="$optarg"
631c886edfbSBlue Swirl  ;;
6321d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
6331d728c39SBlue Swirl  ;;
634e2d8830eSBrad  --smbd=*) smbd="$optarg"
635e2d8830eSBrad  ;;
636e2a2ed06SJuan Quintela  --extra-cflags=*)
6377d13299dSbellard  ;;
638e2a2ed06SJuan Quintela  --extra-ldflags=*)
6397d13299dSbellard  ;;
6405bc62e01SGerd Hoffmann  --enable-debug-info)
6415bc62e01SGerd Hoffmann  ;;
6425bc62e01SGerd Hoffmann  --disable-debug-info)
6435bc62e01SGerd Hoffmann  ;;
6442ff6b91eSJuan Quintela  --cpu=*)
6457d13299dSbellard  ;;
646b1a550a0Spbrook  --target-list=*) target_list="$optarg"
647de83cd02Sbellard  ;;
64874242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
64994a420b1SStefan Hajnoczi  ;;
65074242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6519410b56cSPrerna Saxena  ;;
6527d13299dSbellard  --enable-gprof) gprof="yes"
6537d13299dSbellard  ;;
6541d728c39SBlue Swirl  --enable-gcov) gcov="yes"
6551d728c39SBlue Swirl  ;;
65679427693SLoïc Minier  --static)
65779427693SLoïc Minier    static="yes"
65879427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
65917884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
66043ce4dfeSbellard  ;;
6610b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6620b24e75fSPaolo Bonzini  ;;
6630b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
6640b24e75fSPaolo Bonzini  ;;
6653aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
6663aa5d2beSAlon Levy  ;;
6678bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
6688bf188aaSMichael Tokarev  ;;
6690f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
6700f94d6daSAlon Levy  ;;
671528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
6720b24e75fSPaolo Bonzini  ;;
673023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
674023d3d67SEduardo Habkost  ;;
675850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
6760b24e75fSPaolo Bonzini  ;;
677ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
67807381cc1SAnthony Liguori  ;;
679785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
680785c23aeSLuiz Capitulino  ;;
681785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
682023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
683023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
684023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
685023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
686023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
687023ddd74SMax Filippov    # lots of directory switches by default.
688023ddd74SMax Filippov  ;;
689e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
690e2134eb9SGerd Hoffmann  ;;
691e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
692e2134eb9SGerd Hoffmann  ;;
69374880fe2SRobert Schiele  --without-pixman) pixman="none"
69474880fe2SRobert Schiele  ;;
69597a847bcSbellard  --disable-sdl) sdl="no"
69697a847bcSbellard  ;;
697c4198157SJuan Quintela  --enable-sdl) sdl="yes"
698c4198157SJuan Quintela  ;;
6993556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
7003556c233SPaolo Bonzini  ;;
7013556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
7023556c233SPaolo Bonzini  ;;
703983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
704983eef5aSMeador Inge  ;;
705983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
706983eef5aSMeador Inge  ;;
707821601eaSJes Sorensen  --disable-vnc) vnc="no"
708821601eaSJes Sorensen  ;;
709821601eaSJes Sorensen  --enable-vnc) vnc="yes"
710821601eaSJes Sorensen  ;;
711b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
712102a52e4Sbellard  ;;
713c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
714c2de5c91Smalc  ;;
7152f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
7162f6a1ab0Sblueswir1  ;;
7170c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
7180c58ac1cSmalc  ;;
719b64ec4e4SFam Zheng  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
720b64ec4e4SFam Zheng  ;;
721b64ec4e4SFam Zheng  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
722eb852011SMarkus Armbruster  ;;
723f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
724f8393946Saurel32  ;;
725f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
726f8393946Saurel32  ;;
727f3d08ee6SPaul Brook  --enable-debug)
728f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
729f3d08ee6SPaul Brook      debug_tcg="yes"
730f3d08ee6SPaul Brook      debug="yes"
731f3d08ee6SPaul Brook      strip_opt="no"
732f3d08ee6SPaul Brook  ;;
73303b4fe7dSaliguori  --enable-sparse) sparse="yes"
73403b4fe7dSaliguori  ;;
73503b4fe7dSaliguori  --disable-sparse) sparse="no"
73603b4fe7dSaliguori  ;;
7371625af87Saliguori  --disable-strip) strip_opt="no"
7381625af87Saliguori  ;;
7398d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
7408d5d2d4cSths  ;;
7411be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
7421be10ad2SJuan Quintela  ;;
7432f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
7442f9606b3Saliguori  ;;
745ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
746ea784e3bSJuan Quintela  ;;
7472f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
7482f6f5c7aSCorentin Chary  ;;
7492f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
7502f6f5c7aSCorentin Chary  ;;
751efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
752efe556adSCorentin Chary  ;;
753efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
754efe556adSCorentin Chary  ;;
7557536ee4bSTim Hardeck  --disable-vnc-ws) vnc_ws="no"
7567536ee4bSTim Hardeck  ;;
7577536ee4bSTim Hardeck  --enable-vnc-ws) vnc_ws="yes"
7587536ee4bSTim Hardeck  ;;
759443f1376Sbellard  --disable-slirp) slirp="no"
760c20709aaSbellard  ;;
761ee682d27SStefan Weil  --disable-uuid) uuid="no"
762ee682d27SStefan Weil  ;;
763ee682d27SStefan Weil  --enable-uuid) uuid="yes"
764ee682d27SStefan Weil  ;;
765e0e6c8c0Saliguori  --disable-vde) vde="no"
7668a16d273Sths  ;;
767dfb278bdSJuan Quintela  --enable-vde) vde="yes"
768dfb278bdSJuan Quintela  ;;
769e37630caSaliguori  --disable-xen) xen="no"
770e37630caSaliguori  ;;
771fc321b4bSJuan Quintela  --enable-xen) xen="yes"
772fc321b4bSJuan Quintela  ;;
773eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
774eb6fda0fSAnthony PERARD  ;;
775eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
776eb6fda0fSAnthony PERARD  ;;
7772e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
7782e4d9fb1Saurel32  ;;
7794ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
7804ffcedb6SJuan Quintela  ;;
781fb599c9aSbalrog  --disable-bluez) bluez="no"
782fb599c9aSbalrog  ;;
783a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
784a20a6f46SJuan Quintela  ;;
7857ba1e619Saliguori  --disable-kvm) kvm="no"
7867ba1e619Saliguori  ;;
787b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
788b31a0277SJuan Quintela  ;;
7899195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
7909195b2c2SStefan Weil  ;;
7919195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
7929195b2c2SStefan Weil  ;;
79347e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
79447e98658SCorey Bryant  ;;
79547e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
79647e98658SCorey Bryant  ;;
797cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
798cd4ec0b4SGerd Hoffmann  ;;
799cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
800cd4ec0b4SGerd Hoffmann  ;;
801c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
802c589b249SRonnie Sahlberg  ;;
803c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
804c589b249SRonnie Sahlberg  ;;
80505c2a3e7Sbellard  --enable-profiler) profiler="yes"
80605c2a3e7Sbellard  ;;
80714821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
80814821030SPavel Borzenkov  ;;
809c2de5c91Smalc  --enable-cocoa)
810c2de5c91Smalc      cocoa="yes" ;
811c2de5c91Smalc      sdl="no" ;
812c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
8135b0753e0Sbellard  ;;
814cad25d69Spbrook  --disable-system) softmmu="no"
8150a8e90f4Spbrook  ;;
816cad25d69Spbrook  --enable-system) softmmu="yes"
8170a8e90f4Spbrook  ;;
8180953a80fSZachary Amsden  --disable-user)
8190953a80fSZachary Amsden      linux_user="no" ;
8200953a80fSZachary Amsden      bsd_user="no" ;
8210953a80fSZachary Amsden  ;;
8220953a80fSZachary Amsden  --enable-user) ;;
823831b7825Sths  --disable-linux-user) linux_user="no"
8240a8e90f4Spbrook  ;;
825831b7825Sths  --enable-linux-user) linux_user="yes"
826831b7825Sths  ;;
82784778508Sblueswir1  --disable-bsd-user) bsd_user="no"
82884778508Sblueswir1  ;;
82984778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
83084778508Sblueswir1  ;;
831379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
832379f6698SPaul Brook  ;;
833379f6698SPaul Brook  --disable-guest-base) guest_base="no"
834379f6698SPaul Brook  ;;
83540d6444eSAvi Kivity  --enable-pie) pie="yes"
83634005a00SKirill A. Shutemov  ;;
83740d6444eSAvi Kivity  --disable-pie) pie="no"
83834005a00SKirill A. Shutemov  ;;
839c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
840c5937220Spbrook  ;;
84185aa5189Sbellard  --enable-werror) werror="yes"
84285aa5189Sbellard  ;;
84385aa5189Sbellard  --disable-werror) werror="no"
84485aa5189Sbellard  ;;
8454d3b6f6eSbalrog  --disable-curses) curses="no"
8464d3b6f6eSbalrog  ;;
847c584a6d0SJuan Quintela  --enable-curses) curses="yes"
848c584a6d0SJuan Quintela  ;;
849769ce76dSAlexander Graf  --disable-curl) curl="no"
850769ce76dSAlexander Graf  ;;
851788c8196SJuan Quintela  --enable-curl) curl="yes"
852788c8196SJuan Quintela  ;;
8532df87df7SJuan Quintela  --disable-fdt) fdt="no"
8542df87df7SJuan Quintela  ;;
8552df87df7SJuan Quintela  --enable-fdt) fdt="yes"
8562df87df7SJuan Quintela  ;;
857bd0c5661Spbrook  --disable-nptl) nptl="no"
858bd0c5661Spbrook  ;;
859b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
860b0a47e79SJuan Quintela  ;;
8618ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
8628ff9cbf7Smalc  ;;
8635c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
8645c6c3a6cSChristoph Hellwig  ;;
8655c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
8665c6c3a6cSChristoph Hellwig  ;;
867758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
868758e8e38SVenkateswararao Jujjuri (JV)  ;;
869758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
870758e8e38SVenkateswararao Jujjuri (JV)  ;;
87177755340Sths  --disable-blobs) blobs="no"
87277755340Sths  ;;
8734a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
8744a19f1ecSpbrook  ;;
875519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
876519175a2SAlex Barcelo  ;;
877a25dba17SJuan Quintela  --disable-docs) docs="no"
87870ec5dc0SAnthony Liguori  ;;
879a25dba17SJuan Quintela  --enable-docs) docs="yes"
88083a3ab8bSJuan Quintela  ;;
881d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
882d5970055SMichael S. Tsirkin  ;;
883d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
884d5970055SMichael S. Tsirkin  ;;
8855e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
8865e9be92dSNicholas Bellinger  ;;
8875e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
8885e9be92dSNicholas Bellinger  ;;
889b1e5fff4SMichael Walle  --disable-glx) glx="no"
89020ff075bSMichael Walle  ;;
891b1e5fff4SMichael Walle  --enable-glx) glx="yes"
89220ff075bSMichael Walle  ;;
893f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
894f27aaf4bSChristian Brunner  ;;
895f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
896f27aaf4bSChristian Brunner  ;;
8978c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
8988c84cf11SSergei Trofimovich  ;;
8998c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
9008c84cf11SSergei Trofimovich  ;;
901111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
902111a38b0SRobert Relyea  ;;
903111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
904111a38b0SRobert Relyea  ;;
9052b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
9062b2325ffSGerd Hoffmann  ;;
9072b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
9082b2325ffSGerd Hoffmann  ;;
90969354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
91069354a83SHans de Goede  ;;
91169354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
91269354a83SHans de Goede  ;;
9131ece9905SAlon Levy  --disable-zlib-test) zlib="no"
9141ece9905SAlon Levy  ;;
915d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
916d138cee9SMichael Roth  ;;
917d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
918d138cee9SMichael Roth  ;;
9194b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
9204b1c11fdSDaniel P. Berrange  ;;
9214b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
9224b1c11fdSDaniel P. Berrange  ;;
923f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
924f794573eSEduardo Otubo  ;;
925f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
926f794573eSEduardo Otubo  ;;
927eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
928eb100396SBharata B Rao  ;;
929eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
930eb100396SBharata B Rao  ;;
931583f6e7bSStefan Hajnoczi  --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
932583f6e7bSStefan Hajnoczi  ;;
933583f6e7bSStefan Hajnoczi  --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
934583f6e7bSStefan Hajnoczi  ;;
935a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
936a4ccabcfSAnthony Liguori  ;;
937a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
938a4ccabcfSAnthony Liguori  ;;
939528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
940528de90aSDaniel P. Berrange  ;;
941ab214c29SStefan Berger  --enable-tpm) tpm="yes"
942ab214c29SStefan Berger  ;;
9430a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
9440a12ec87SRichard W.M. Jones  ;;
9450a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
9460a12ec87SRichard W.M. Jones  ;;
9477f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
9487f1559c6Sbalrog  ;;
9497d13299dSbellard  esac
9507d13299dSbellarddone
9517d13299dSbellard
95240293e58Sbellardcase "$cpu" in
9539b9c37c3SRichard Henderson    sparc)
9540c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
95579f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32 -mcpu=ultrasparc"
9563142255cSblueswir1           ;;
957ed968ff1SJuan Quintela    sparc64)
9580c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
95979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
9603142255cSblueswir1           ;;
96176d83bdeSths    s390)
96279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m31 -march=z990"
96328d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
96428d7cc49SRichard Henderson           ;;
96528d7cc49SRichard Henderson    s390x)
96679f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -march=z990"
96728d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
96876d83bdeSths           ;;
96940293e58Sbellard    i386)
97079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
9710c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
9722b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
97340293e58Sbellard           ;;
97440293e58Sbellard    x86_64)
97579f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64"
9760c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
9772b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
978379f6698SPaul Brook           ;;
97930163d89SPeter Maydell    # No special flags required for other host CPUs
9803142255cSblueswir1esac
9813142255cSblueswir1
98279f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
98379f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
98479f3b12fSPeter Crosthwaite
98560e0df25SPeter Maydelldefault_target_list=""
98660e0df25SPeter Maydell
9876e92f823SPeter Maydellmak_wilds=""
9886e92f823SPeter Maydell
98960e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
9906e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
99160e0df25SPeter Maydellfi
99260e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
9936e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
99460e0df25SPeter Maydellfi
99560e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
9966e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
99760e0df25SPeter Maydellfi
99860e0df25SPeter Maydell
9996e92f823SPeter Maydellfor config in $mak_wilds; do
10006e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
10016e92f823SPeter Maydelldone
10026e92f823SPeter Maydell
1003af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1004af5db58eSpbrookcat << EOF
1005af5db58eSpbrook
1006af5db58eSpbrookUsage: configure [options]
1007af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1008af5db58eSpbrook
1009af5db58eSpbrookEOF
1010af5db58eSpbrookecho "Standard options:"
1011af5db58eSpbrookecho "  --help                   print this message"
1012af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
1013af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
1014af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
101560e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
101660e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
101760e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
1018af5db58eSpbrookecho ""
1019af5db58eSpbrookecho "Advanced options (experts only):"
1020af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
1021af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
1022af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
10230bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
10240bfe8cc0SPaolo Bonziniecho "                           build time"
10253c4a4d0dSPeter Maydellecho "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
1026a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
1027e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
1028af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
10296a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
1030c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
1031e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
1032af5db58eSpbrookecho "  --static                 enable static build [$static]"
10330b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
1034023d3d67SEduardo Habkostecho "  --datadir=PATH           install firmware in PATH$confsuffix"
1035023d3d67SEduardo Habkostecho "  --docdir=PATH            install documentation in PATH$confsuffix"
10360b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
1037a7b66fa7SDoug Goldsteinecho "  --libdir=PATH            install libraries in PATH"
1038023d3d67SEduardo Habkostecho "  --sysconfdir=PATH        install config in PATH$confsuffix"
10395a699bbbSLaszlo Ersekecho "  --localstatedir=PATH     install local state in PATH (set at runtime on win32)"
10402ae4748fSStefan Weilecho "  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1041f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
1042f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
10439941afdeSDunrong Huangecho "  --enable-debug-info       enable debugging information (default)"
10449941afdeSDunrong Huangecho "  --disable-debug-info      disable debugging information"
104509695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
1046890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
1047890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
10481625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
104985aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
1050fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
1051c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
1052ab400449SHu Taoecho "  --disable-gtk            disable gtk UI"
1053ab400449SHu Taoecho "  --enable-gtk             enable gtk UI"
1054983eef5aSMeador Ingeecho "  --disable-virtfs         disable VirtFS"
1055983eef5aSMeador Ingeecho "  --enable-virtfs          enable VirtFS"
1056821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
1057821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
105814821030SPavel Borzenkovecho "  --disable-cocoa          disable Cocoa (Mac OS X only)"
105914821030SPavel Borzenkovecho "  --enable-cocoa           enable Cocoa (default on Mac OS X)"
1060c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
1061c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
1062b64ec4e4SFam Zhengecho "  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L"
1063b64ec4e4SFam Zhengecho "  --block-drv-rw-whitelist=L"
1064b64ec4e4SFam Zhengecho "                           set block driver read-write whitelist"
1065b64ec4e4SFam Zhengecho "                           (affects only QEMU, not qemu-img)"
1066b64ec4e4SFam Zhengecho "  --block-drv-ro-whitelist=L"
1067b64ec4e4SFam Zhengecho "                           set block driver read-only whitelist"
1068eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
10698ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
1070e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
1071fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
1072eb6fda0fSAnthony PERARDecho "  --disable-xen-pci-passthrough"
1073eb6fda0fSAnthony PERARDecho "  --enable-xen-pci-passthrough"
10742e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
10754ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
10768d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
10771be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
10782f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1079ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
10802f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
10812f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
108296763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1083efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
10847536ee4bSTim Hardeckecho "  --disable-vnc-ws         disable Websockets support for VNC server"
10857536ee4bSTim Hardeckecho "  --enable-vnc-ws          enable Websockets support for VNC server"
1086af896aaaSpbrookecho "  --disable-curses         disable curses output"
1087c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1088769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1089788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
10902df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
10912df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
1092fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1093a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
10946093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
10957ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1096b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
10979195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1098bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
1099e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
1100af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1101af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
11020953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
11030953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1104831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1105831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
110684778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
110784778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1108379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1109379f6698SPaul Brookecho "                           emulation targets"
1110379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
111140d6444eSAvi Kivityecho "  --enable-pie             build Position Independent Executables"
111240d6444eSAvi Kivityecho "  --disable-pie            do not build Position Independent Executables"
1113af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1114af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
11152f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1116c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1117235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
1118ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1119ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1120e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1121dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
11225c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
11235c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
112447e98658SCorey Bryantecho "  --disable-cap-ng         disable libcap-ng support"
112547e98658SCorey Bryantecho "  --enable-cap-ng          enable libcap-ng support"
1126758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1127758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
112877755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1129d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1130d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1131d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1132d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1133320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1134650ab98dSLluís Vilanovaecho "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
113574242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
11369410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1137cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1138cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1139f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1140c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1141c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
1142111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1143111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
11442b2325ffSGerd Hoffmannecho "  --disable-libusb         disable libusb (for usb passthrough)"
11452b2325ffSGerd Hoffmannecho "  --enable-libusb          enable libusb (for usb passthrough)"
114669354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
114769354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1148d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1149d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1150f794573eSEduardo Otuboecho "  --disable-seccomp        disable seccomp support"
1151f794573eSEduardo Otuboecho "  --enable-seccomp         enables seccomp support"
1152519175a2SAlex Barceloecho "  --with-coroutine=BACKEND coroutine backend. Supported options:"
1153fe91bfa8SAlex Barceloecho "                           gthread, ucontext, sigaltstack, windows"
1154eb100396SBharata B Raoecho "  --enable-glusterfs       enable GlusterFS backend"
1155eb100396SBharata B Raoecho "  --disable-glusterfs      disable GlusterFS backend"
11561d728c39SBlue Swirlecho "  --enable-gcov            enable test coverage analysis with gcov"
11571d728c39SBlue Swirlecho "  --gcov=GCOV              use specified gcov [$gcov_tool]"
1158ab214c29SStefan Bergerecho "  --enable-tpm             enable TPM support"
11590a12ec87SRichard W.M. Jonesecho "  --disable-libssh2        disable ssh block device support"
11600a12ec87SRichard W.M. Jonesecho "  --enable-libssh2         enable ssh block device support"
1161af5db58eSpbrookecho ""
11625bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1163af5db58eSpbrookexit 1
1164af5db58eSpbrookfi
1165af5db58eSpbrook
1166359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1167359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1168359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1169359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1170359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1171359bc95dSPeter Maydell        ARCH=tci
1172359bc95dSPeter Maydell    else
117376ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1174359bc95dSPeter Maydell    fi
1175359bc95dSPeter Maydellfi
1176359bc95dSPeter Maydell
11778d05095cSPaolo Bonzini# check that the C compiler works.
11788d05095cSPaolo Bonzinicat > $TMPC <<EOF
117975cafad7SStefan Weilint main(void) { return 0; }
11808d05095cSPaolo BonziniEOF
11818d05095cSPaolo Bonzini
11828d05095cSPaolo Bonziniif compile_object ; then
11838d05095cSPaolo Bonzini  : C compiler works ok
11848d05095cSPaolo Bonzinielse
118576ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
11868d05095cSPaolo Bonzinifi
11878d05095cSPaolo Bonzini
1188417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1189417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1190417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1191417c9d72SAlexander Graf
1192417c9d72SAlexander Grafif test -z "$werror" ; then
11936c8fec83SAndreas Färber    if test -d "$source_path/.git" -a \
1194417c9d72SAlexander Graf        "$linux" = "yes" ; then
1195417c9d72SAlexander Graf        werror="yes"
1196417c9d72SAlexander Graf    else
1197417c9d72SAlexander Graf        werror="no"
1198417c9d72SAlexander Graf    fi
1199417c9d72SAlexander Graffi
1200417c9d72SAlexander Graf
12018d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
12028d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
12038d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
120437746c5eSMarc-André Lureaugcc_flags="-Wendif-labels $gcc_flags"
1205c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
12066ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
12076ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
12086ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
12096ca026cbSPeter Maydell# so it's too error prone.
12108d05095cSPaolo Bonzinicat > $TMPC << EOF
12118d05095cSPaolo Bonziniint main(void) { return 0; }
12128d05095cSPaolo BonziniEOF
12138d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1214a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1215a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1216a1d29d6cSPeter Maydell    # warning options).
1217a1d29d6cSPeter Maydell    optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1218a1d29d6cSPeter Maydell    if compile_prog "-Werror $optflag" "" ; then
12198d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
12208d05095cSPaolo Bonzini    fi
12218d05095cSPaolo Bonzinidone
12228d05095cSPaolo Bonzini
122337746c5eSMarc-André Lureauif compile_prog "-Werror -fstack-protector-all" "" ; then
122437746c5eSMarc-André Lureau    QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
122537746c5eSMarc-André Lureau    LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
122637746c5eSMarc-André Lureaufi
122737746c5eSMarc-André Lureau
1228cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1229cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1230cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1231cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1232cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1233cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1234cbdd1999SPaolo Bonziniint main(void) { return 0; }
1235cbdd1999SPaolo Bonzini#else
1236cbdd1999SPaolo Bonzini#error No bug in this compiler.
1237cbdd1999SPaolo Bonzini#endif
1238cbdd1999SPaolo BonziniEOF
1239cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1240cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1241cbdd1999SPaolo Bonzinifi
1242cbdd1999SPaolo Bonzini
124340d6444eSAvi Kivityif test "$static" = "yes" ; then
124440d6444eSAvi Kivity  if test "$pie" = "yes" ; then
124576ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
124640d6444eSAvi Kivity  else
124740d6444eSAvi Kivity    pie="no"
124840d6444eSAvi Kivity  fi
124940d6444eSAvi Kivityfi
125040d6444eSAvi Kivity
125140d6444eSAvi Kivityif test "$pie" = ""; then
125240d6444eSAvi Kivity  case "$cpu-$targetos" in
1253f9db31a2SBrad    i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD)
125440d6444eSAvi Kivity      ;;
125540d6444eSAvi Kivity    *)
125640d6444eSAvi Kivity      pie="no"
125740d6444eSAvi Kivity      ;;
125840d6444eSAvi Kivity  esac
125940d6444eSAvi Kivityfi
126040d6444eSAvi Kivity
126140d6444eSAvi Kivityif test "$pie" != "no" ; then
126240d6444eSAvi Kivity  cat > $TMPC << EOF
126321d4a791SAvi Kivity
126421d4a791SAvi Kivity#ifdef __linux__
126521d4a791SAvi Kivity#  define THREAD __thread
126621d4a791SAvi Kivity#else
126721d4a791SAvi Kivity#  define THREAD
126821d4a791SAvi Kivity#endif
126921d4a791SAvi Kivity
127021d4a791SAvi Kivitystatic THREAD int tls_var;
127121d4a791SAvi Kivity
127221d4a791SAvi Kivityint main(void) { return tls_var; }
127321d4a791SAvi Kivity
127440d6444eSAvi KivityEOF
127540d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
127640d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
127740d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
127840d6444eSAvi Kivity    pie="yes"
127940d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
128040d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
128140d6444eSAvi Kivity    fi
128240d6444eSAvi Kivity  else
128340d6444eSAvi Kivity    if test "$pie" = "yes"; then
128476ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
128540d6444eSAvi Kivity    else
128640d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
128740d6444eSAvi Kivity      pie="no"
128840d6444eSAvi Kivity    fi
128940d6444eSAvi Kivity  fi
129040d6444eSAvi Kivityfi
129140d6444eSAvi Kivity
129209dada40SPaolo Bonzini##########################################
129309dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
129409dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
129509dada40SPaolo Bonzini# specification is necessary
129609dada40SPaolo Bonzini
129709dada40SPaolo Bonziniif test "$cpu" = "i386"; then
129809dada40SPaolo Bonzini  cat > $TMPC << EOF
129909dada40SPaolo Bonzinistatic int sfaa(int *ptr)
130009dada40SPaolo Bonzini{
130109dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
130209dada40SPaolo Bonzini}
130309dada40SPaolo Bonzini
130409dada40SPaolo Bonziniint main(void)
130509dada40SPaolo Bonzini{
130609dada40SPaolo Bonzini  int val = 42;
13071405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
130809dada40SPaolo Bonzini  sfaa(&val);
130909dada40SPaolo Bonzini  return val;
131009dada40SPaolo Bonzini}
131109dada40SPaolo BonziniEOF
131209dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
131309dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
131409dada40SPaolo Bonzini  fi
131509dada40SPaolo Bonzinifi
131609dada40SPaolo Bonzini
131709dada40SPaolo Bonzini#########################################
1318ec530c81Sbellard# Solaris specific configure tool chain decisions
131909dada40SPaolo Bonzini
1320ec530c81Sbellardif test "$solaris" = "yes" ; then
13216792aa11SLoïc Minier  if has $install; then
13226792aa11SLoïc Minier    :
13236792aa11SLoïc Minier  else
132476ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
132576ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
132676ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1327ec530c81Sbellard  fi
13286792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
132976ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
133076ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
133176ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1332ec530c81Sbellard  fi
13336792aa11SLoïc Minier  if has ar; then
13346792aa11SLoïc Minier    :
13356792aa11SLoïc Minier  else
1336ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
133776ad07a4SPeter Maydell      error_exit "No path includes ar" \
133876ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1339ec530c81Sbellard    fi
134076ad07a4SPeter Maydell    error_exit "No path includes ar"
1341ec530c81Sbellard  fi
1342ec530c81Sbellardfi
1343ec530c81Sbellard
13447a3fc891SSebastian Herbsztif ! has $python; then
134576ad07a4SPeter Maydell  error_exit "Python not found. Use --python=/path/to/python"
1346c886edfbSBlue Swirlfi
1347c886edfbSBlue Swirl
13486ccea1e4SPeter Maydell# Note that if the Python conditional here evaluates True we will exit
13496ccea1e4SPeter Maydell# with status 1 which is a shell 'false' value.
1350e120d449SStefan Hajnocziif ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
135176ad07a4SPeter Maydell  error_exit "Cannot use '$python', Python 2.4 or later is required." \
135276ad07a4SPeter Maydell      "Note that Python 3 or later is not yet supported." \
135376ad07a4SPeter Maydell      "Use --python=/path/to/python to specify a supported Python."
13546ccea1e4SPeter Maydellfi
13556ccea1e4SPeter Maydell
1356afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1357121afa9eSAnthony Liguori    target_list="$default_target_list"
1358121afa9eSAnthony Liguorielse
1359121afa9eSAnthony Liguori    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
13605327cf48Sbellardfi
136125b48338SPeter Maydell
136225b48338SPeter Maydell# Check that we recognised the target name; this allows a more
136325b48338SPeter Maydell# friendly error message than if we let it fall through.
136425b48338SPeter Maydellfor target in $target_list; do
136525b48338SPeter Maydell    case " $default_target_list " in
136625b48338SPeter Maydell        *" $target "*)
136725b48338SPeter Maydell            ;;
136825b48338SPeter Maydell        *)
136925b48338SPeter Maydell            error_exit "Unknown target name '$target'"
137025b48338SPeter Maydell            ;;
137125b48338SPeter Maydell    esac
137225b48338SPeter Maydelldone
137325b48338SPeter Maydell
1374f55fe278SPaolo Bonzini# see if system emulation was really requested
1375f55fe278SPaolo Bonzinicase " $target_list " in
1376f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1377f55fe278SPaolo Bonzini  ;;
1378f55fe278SPaolo Bonzini  *) softmmu=no
1379f55fe278SPaolo Bonzini  ;;
1380f55fe278SPaolo Bonziniesac
13815327cf48Sbellard
1382249247c9SJuan Quintelafeature_not_found() {
1383249247c9SJuan Quintela  feature=$1
1384249247c9SJuan Quintela
138576ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
138676ad07a4SPeter Maydell      "configure was not able to find it"
1387249247c9SJuan Quintela}
1388249247c9SJuan Quintela
13897d13299dSbellardif test -z "$cross_prefix" ; then
13907d13299dSbellard
13917d13299dSbellard# ---
13927d13299dSbellard# big/little endian test
13937d13299dSbellardcat > $TMPC << EOF
13947d13299dSbellard#include <inttypes.h>
1395abab1a0fSStefan Weilint main(void) {
13967d13299dSbellard        volatile uint32_t i=0x01234567;
13977d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
13987d13299dSbellard}
13997d13299dSbellardEOF
14007d13299dSbellard
140152166aa0SJuan Quintelaif compile_prog "" "" ; then
14027d13299dSbellard$TMPE && bigendian="yes"
14037d13299dSbellardelse
14047d13299dSbellardecho big/little test failed
14057d13299dSbellardfi
14067d13299dSbellard
14077d13299dSbellardelse
14087d13299dSbellard
14097d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1410ea8f20f8SJuan Quintelacase "$cpu" in
141121d89f84SPeter Maydell  arm)
141221d89f84SPeter Maydell    # ARM can be either way; ask the compiler which one we are
141321d89f84SPeter Maydell    if check_define __ARMEB__; then
141421d89f84SPeter Maydell      bigendian=yes
141521d89f84SPeter Maydell    fi
141621d89f84SPeter Maydell  ;;
141721d89f84SPeter Maydell  hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1418ea8f20f8SJuan Quintela    bigendian=yes
1419ea8f20f8SJuan Quintela  ;;
1420ea8f20f8SJuan Quintelaesac
14217d13299dSbellard
14227d13299dSbellardfi
14237d13299dSbellard
1424b0a47e79SJuan Quintela##########################################
1425779ab5e3SStefan Weil# pkg-config probe
1426779ab5e3SStefan Weil
1427779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
142876ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1429779ab5e3SStefan Weilfi
1430779ab5e3SStefan Weil
1431779ab5e3SStefan Weil##########################################
1432b0a47e79SJuan Quintela# NPTL probe
1433b0a47e79SJuan Quintela
1434b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1435bd0c5661Spbrook  cat > $TMPC <<EOF
1436bd0c5661Spbrook#include <sched.h>
143730813ceaSpbrook#include <linux/futex.h>
1438182eacc0SStefan Weilint main(void) {
1439bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1440bd0c5661Spbrook#error bork
1441bd0c5661Spbrook#endif
1442182eacc0SStefan Weil  return 0;
1443bd0c5661Spbrook}
1444bd0c5661SpbrookEOF
1445bd0c5661Spbrook
144652166aa0SJuan Quintela  if compile_object ; then
1447b0a47e79SJuan Quintela    nptl=yes
1448bd0c5661Spbrook  else
1449b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1450b0a47e79SJuan Quintela      feature_not_found "nptl"
1451b0a47e79SJuan Quintela    fi
1452b0a47e79SJuan Quintela    nptl=no
1453b0a47e79SJuan Quintela  fi
1454bd0c5661Spbrookfi
1455bd0c5661Spbrook
145611d9f695Sbellard##########################################
1457ac62922eSbalrog# zlib check
1458ac62922eSbalrog
14591ece9905SAlon Levyif test "$zlib" != "no" ; then
1460ac62922eSbalrog    cat > $TMPC << EOF
1461ac62922eSbalrog#include <zlib.h>
1462ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1463ac62922eSbalrogEOF
146452166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1465ac62922eSbalrog        :
1466ac62922eSbalrog    else
146776ad07a4SPeter Maydell        error_exit "zlib check failed" \
146876ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1469ac62922eSbalrog    fi
14701ece9905SAlon Levyfi
1471f544a488SPaolo Bonzinilibs_softmmu="$libs_softmmu -lz"
1472ac62922eSbalrog
1473ac62922eSbalrog##########################################
1474f794573eSEduardo Otubo# libseccomp check
1475f794573eSEduardo Otubo
1476f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
14772c5c4451SBlue Swirl    if $pkg_config --atleast-version=1.0.0 libseccomp --modversion >/dev/null 2>&1; then
1478b4451996SMichael Tokarev        libs_softmmu="$libs_softmmu `$pkg_config --libs libseccomp`"
1479372e47e9SAndreas Färber        QEMU_CFLAGS="$QEMU_CFLAGS `$pkg_config --cflags libseccomp`"
1480f794573eSEduardo Otubo	seccomp="yes"
1481f794573eSEduardo Otubo    else
1482f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
1483f794573eSEduardo Otubo            feature_not_found "libseccomp"
1484f794573eSEduardo Otubo	fi
1485e84d5956SYann E. MORIN	seccomp="no"
1486f794573eSEduardo Otubo    fi
1487f794573eSEduardo Otubofi
1488f794573eSEduardo Otubo##########################################
1489e37630caSaliguori# xen probe
1490e37630caSaliguori
1491fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1492b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1493d5b93ddfSAnthony PERARD
149450ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
149550ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
149650ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
149750ced5b3SStefan Weil
149850ced5b3SStefan Weil  # Xen (any)
149950ced5b3SStefan Weil  cat > $TMPC <<EOF
150050ced5b3SStefan Weil#include <xenctrl.h>
150150ced5b3SStefan Weilint main(void) {
150250ced5b3SStefan Weil  return 0;
150350ced5b3SStefan Weil}
150450ced5b3SStefan WeilEOF
150550ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
150650ced5b3SStefan Weil    # Xen not found
150750ced5b3SStefan Weil    if test "$xen" = "yes" ; then
150850ced5b3SStefan Weil      feature_not_found "xen"
150950ced5b3SStefan Weil    fi
151050ced5b3SStefan Weil    xen=no
151150ced5b3SStefan Weil
1512d5b93ddfSAnthony PERARD  # Xen unstable
151369deef08SPeter Maydell  elif
151469deef08SPeter Maydell      cat > $TMPC <<EOF &&
1515e37630caSaliguori#include <xenctrl.h>
1516e108a3c1SAnthony PERARD#include <xenstore.h>
1517d5b93ddfSAnthony PERARD#include <stdint.h>
1518d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1519d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1520d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1521d5b93ddfSAnthony PERARD#endif
1522d5b93ddfSAnthony PERARDint main(void) {
1523d5b93ddfSAnthony PERARD  xc_interface *xc;
1524d5b93ddfSAnthony PERARD  xs_daemon_open();
1525d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1526d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1527d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1528b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
15298688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
15308688e065SStefano Stabellini  return 0;
15318688e065SStefano Stabellini}
15328688e065SStefano StabelliniEOF
15338688e065SStefano Stabellini      compile_prog "" "$xen_libs"
153469deef08SPeter Maydell    then
15358688e065SStefano Stabellini    xen_ctrl_version=420
15368688e065SStefano Stabellini    xen=yes
15378688e065SStefano Stabellini
153869deef08SPeter Maydell  elif
153969deef08SPeter Maydell      cat > $TMPC <<EOF &&
15408688e065SStefano Stabellini#include <xenctrl.h>
15418688e065SStefano Stabellini#include <xs.h>
15428688e065SStefano Stabellini#include <stdint.h>
15438688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
15448688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
15458688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
15468688e065SStefano Stabellini#endif
15478688e065SStefano Stabelliniint main(void) {
15488688e065SStefano Stabellini  xs_daemon_open();
15499b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
15508688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
15518688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
15528688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1553d5b93ddfSAnthony PERARD  return 0;
1554d5b93ddfSAnthony PERARD}
1555e37630caSaliguoriEOF
155650ced5b3SStefan Weil      compile_prog "" "$xen_libs"
155769deef08SPeter Maydell    then
1558d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1559fc321b4bSJuan Quintela    xen=yes
1560d5b93ddfSAnthony PERARD
1561d5b93ddfSAnthony PERARD  # Xen 4.0.0
156269deef08SPeter Maydell  elif
156369deef08SPeter Maydell      cat > $TMPC <<EOF &&
1564d5b93ddfSAnthony PERARD#include <xenctrl.h>
1565d5b93ddfSAnthony PERARD#include <xs.h>
1566d5b93ddfSAnthony PERARD#include <stdint.h>
1567d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1568d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1569d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1570d5b93ddfSAnthony PERARD#endif
1571d5b93ddfSAnthony PERARDint main(void) {
1572b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1573b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1574b87de24eSAnthony PERARD  };
1575d5b93ddfSAnthony PERARD  xs_daemon_open();
1576d5b93ddfSAnthony PERARD  xc_interface_open();
1577d5b93ddfSAnthony PERARD  xc_gnttab_open();
1578d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1579b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1580d5b93ddfSAnthony PERARD  return 0;
1581d5b93ddfSAnthony PERARD}
1582d5b93ddfSAnthony PERARDEOF
1583d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
158469deef08SPeter Maydell    then
1585d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1586d5b93ddfSAnthony PERARD    xen=yes
1587d5b93ddfSAnthony PERARD
1588b87de24eSAnthony PERARD  # Xen 3.4.0
158969deef08SPeter Maydell  elif
159069deef08SPeter Maydell      cat > $TMPC <<EOF &&
1591b87de24eSAnthony PERARD#include <xenctrl.h>
1592b87de24eSAnthony PERARD#include <xs.h>
1593b87de24eSAnthony PERARDint main(void) {
1594b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1595b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1596b87de24eSAnthony PERARD  };
1597b87de24eSAnthony PERARD  xs_daemon_open();
1598b87de24eSAnthony PERARD  xc_interface_open();
1599b87de24eSAnthony PERARD  xc_gnttab_open();
1600b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1601b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1602b87de24eSAnthony PERARD  return 0;
1603b87de24eSAnthony PERARD}
1604b87de24eSAnthony PERARDEOF
1605b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
160669deef08SPeter Maydell    then
1607b87de24eSAnthony PERARD    xen_ctrl_version=340
1608b87de24eSAnthony PERARD    xen=yes
1609b87de24eSAnthony PERARD
1610b87de24eSAnthony PERARD  # Xen 3.3.0
161169deef08SPeter Maydell  elif
161269deef08SPeter Maydell      cat > $TMPC <<EOF &&
1613d5b93ddfSAnthony PERARD#include <xenctrl.h>
1614d5b93ddfSAnthony PERARD#include <xs.h>
1615d5b93ddfSAnthony PERARDint main(void) {
1616d5b93ddfSAnthony PERARD  xs_daemon_open();
1617d5b93ddfSAnthony PERARD  xc_interface_open();
1618d5b93ddfSAnthony PERARD  xc_gnttab_open();
1619d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1620d5b93ddfSAnthony PERARD  return 0;
1621d5b93ddfSAnthony PERARD}
1622d5b93ddfSAnthony PERARDEOF
1623d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
162469deef08SPeter Maydell    then
1625d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1626d5b93ddfSAnthony PERARD    xen=yes
1627d5b93ddfSAnthony PERARD
162850ced5b3SStefan Weil  # Xen version unsupported
1629e37630caSaliguori  else
1630fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
163150ced5b3SStefan Weil      feature_not_found "xen (unsupported version)"
1632fc321b4bSJuan Quintela    fi
1633fc321b4bSJuan Quintela    xen=no
1634e37630caSaliguori  fi
1635d5b93ddfSAnthony PERARD
1636d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1637d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1638d5b93ddfSAnthony PERARD  fi
1639e37630caSaliguorifi
1640e37630caSaliguori
1641eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1642eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1643eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1644eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1645eb6fda0fSAnthony PERARD  else
1646eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1647eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
164876ad07a4SPeter Maydell        error_exit "User requested feature Xen PCI Passthrough" \
164976ad07a4SPeter Maydell            "This feature does not work with Xen 3.3"
1650eb6fda0fSAnthony PERARD      fi
165176ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
165276ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
1653eb6fda0fSAnthony PERARD    fi
1654eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1655eb6fda0fSAnthony PERARD  fi
1656eb6fda0fSAnthony PERARDfi
1657eb6fda0fSAnthony PERARD
1658e37630caSaliguori##########################################
165944dc0ca3SAlon Levy# libtool probe
166044dc0ca3SAlon Levy
16613f534581SBradif ! has $libtool; then
166244dc0ca3SAlon Levy    libtool=
166344dc0ca3SAlon Levyfi
166444dc0ca3SAlon Levy
16658e515b12SPeter Maydell# MacOSX ships with a libtool which isn't the GNU one; weed this
16668e515b12SPeter Maydell# out by checking whether libtool supports the --version switch
16678e515b12SPeter Maydellif test -n "$libtool"; then
16688e515b12SPeter Maydell  if ! "$libtool" --version >/dev/null 2>&1; then
16698e515b12SPeter Maydell    libtool=
16708e515b12SPeter Maydell  fi
16718e515b12SPeter Maydellfi
16728e515b12SPeter Maydell
167344dc0ca3SAlon Levy##########################################
1674dfffc653SJuan Quintela# Sparse probe
1675dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
16760dba6195SLoïc Minier  if has cgcc; then
1677dfffc653SJuan Quintela    sparse=yes
1678dfffc653SJuan Quintela  else
1679dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1680dfffc653SJuan Quintela      feature_not_found "sparse"
1681dfffc653SJuan Quintela    fi
1682dfffc653SJuan Quintela    sparse=no
1683dfffc653SJuan Quintela  fi
1684dfffc653SJuan Quintelafi
1685dfffc653SJuan Quintela
1686dfffc653SJuan Quintela##########################################
1687a4ccabcfSAnthony Liguori# GTK probe
1688a4ccabcfSAnthony Liguori
1689a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
1690528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
1691528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
1692528de90aSDaniel P. Berrange      gtkversion="3.0.0"
1693528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
1694528de90aSDaniel P. Berrange      vteversion="0.32.0"
1695528de90aSDaniel P. Berrange    else
1696528de90aSDaniel P. Berrange      gtkversion="2.18.0"
1697528de90aSDaniel P. Berrange      vtepackage="vte"
1698528de90aSDaniel P. Berrange      vteversion="0.24.0"
1699528de90aSDaniel P. Berrange    fi
1700*0d185e63SPeter Maydell    if ! $pkg_config --exists "$gtkpackage >= $gtkversion"; then
1701*0d185e63SPeter Maydell        if test "$gtk" = "yes" ; then
1702*0d185e63SPeter Maydell            feature_not_found "gtk"
1703*0d185e63SPeter Maydell        fi
1704*0d185e63SPeter Maydell        gtk="no"
1705*0d185e63SPeter Maydell    elif ! $pkg_config --exists "$vtepackage >= $vteversion"; then
1706*0d185e63SPeter Maydell        if test "$gtk" = "yes" ; then
1707*0d185e63SPeter Maydell            error_exit "libvte not found (required for gtk support)"
1708*0d185e63SPeter Maydell        fi
1709*0d185e63SPeter Maydell        gtk="no"
1710*0d185e63SPeter Maydell    else
1711528de90aSDaniel P. Berrange	gtk_cflags=`$pkg_config --cflags $gtkpackage 2>/dev/null`
1712528de90aSDaniel P. Berrange	gtk_libs=`$pkg_config --libs $gtkpackage 2>/dev/null`
1713528de90aSDaniel P. Berrange	vte_cflags=`$pkg_config --cflags $vtepackage 2>/dev/null`
1714528de90aSDaniel P. Berrange	vte_libs=`$pkg_config --libs $vtepackage 2>/dev/null`
1715a4ccabcfSAnthony Liguori	libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
1716a4ccabcfSAnthony Liguori	gtk="yes"
1717a4ccabcfSAnthony Liguori    fi
1718a4ccabcfSAnthony Liguorifi
1719a4ccabcfSAnthony Liguori
1720a4ccabcfSAnthony Liguori##########################################
172111d9f695Sbellard# SDL probe
172211d9f695Sbellard
17233ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
17243ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
17253ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
17263ec87ffeSPaolo Bonzini  sdl_config=sdl-config
17273ec87ffeSPaolo Bonzinifi
17283ec87ffeSPaolo Bonzini
17293ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1730a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1731fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
17323ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
17333ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
17349316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1735a0dfd8a4SLoïc Minierelse
1736a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1737a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1738a0dfd8a4SLoïc Minier  fi
1739a0dfd8a4SLoïc Minier  sdl=no
17409316f803SPaolo Bonzinifi
174129e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
17423ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
17433ec87ffeSPaolo Bonzinifi
174411d9f695Sbellard
17459316f803SPaolo Bonzinisdl_too_old=no
1746c4198157SJuan Quintelaif test "$sdl" != "no" ; then
174711d9f695Sbellard  cat > $TMPC << EOF
174811d9f695Sbellard#include <SDL.h>
174911d9f695Sbellard#undef main /* We don't want SDL to override our main() */
175011d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
175111d9f695SbellardEOF
17529316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
175374f42e18STeLeMan  if test "$static" = "yes" ; then
175474f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
175574f42e18STeLeMan  else
17569316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
175774f42e18STeLeMan  fi
175852166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
175911d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
176011d9f695Sbellard      sdl_too_old=yes
176111d9f695Sbellard    else
1762fd677642Sths      if test "$cocoa" = "no" ; then
176311d9f695Sbellard        sdl=yes
176411d9f695Sbellard      fi
1765fd677642Sths    fi
17667c1f25b4Sbellard
176767c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
17681ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
176967c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1770f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1771f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
177211d9f695Sbellard      fi
177352166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
17741ac88f28SJuan Quintela	:
17751ac88f28SJuan Quintela      else
17761ac88f28SJuan Quintela        sdl=no
17777c1f25b4Sbellard      fi
17787c1f25b4Sbellard    fi # static link
1779c4198157SJuan Quintela  else # sdl not found
1780c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1781c4198157SJuan Quintela      feature_not_found "sdl"
1782c4198157SJuan Quintela    fi
1783c4198157SJuan Quintela    sdl=no
17847c1f25b4Sbellard  fi # sdl compile test
1785fd677642Sthsfi
178611d9f695Sbellard
17875368a422Saliguoriif test "$sdl" = "yes" ; then
17885368a422Saliguori  cat > $TMPC <<EOF
17895368a422Saliguori#include <SDL.h>
17905368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
17915368a422Saliguori#include <X11/XKBlib.h>
17925368a422Saliguori#else
17935368a422Saliguori#error No x11 support
17945368a422Saliguori#endif
17955368a422Saliguoriint main(void) { return 0; }
17965368a422SaliguoriEOF
179752166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1798681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
17995368a422Saliguori  fi
18000705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
18015368a422Saliguorifi
18025368a422Saliguori
18038f28f3fbSths##########################################
18047536ee4bSTim Hardeck# VNC TLS/WS detection
18057536ee4bSTim Hardeckif test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then
1806ae6b5e5aSaliguori  cat > $TMPC <<EOF
1807ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1808ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1809ae6b5e5aSaliguoriEOF
1810a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1811a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
181252166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
18137536ee4bSTim Hardeck    if test "$vnc_tls" != "no" ; then
18141be10ad2SJuan Quintela      vnc_tls=yes
18157536ee4bSTim Hardeck    fi
18167536ee4bSTim Hardeck    if test "$vnc_ws" != "no" ; then
18177536ee4bSTim Hardeck      vnc_ws=yes
18187536ee4bSTim Hardeck    fi
1819a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1820ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
1821ae6b5e5aSaliguori  else
18221be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
18231be10ad2SJuan Quintela      feature_not_found "vnc-tls"
18241be10ad2SJuan Quintela    fi
18257536ee4bSTim Hardeck    if test "$vnc_ws" = "yes" ; then
18267536ee4bSTim Hardeck      feature_not_found "vnc-ws"
18277536ee4bSTim Hardeck    fi
18281be10ad2SJuan Quintela    vnc_tls=no
18297536ee4bSTim Hardeck    vnc_ws=no
18308d5d2d4cSths  fi
18318d5d2d4cSthsfi
18328d5d2d4cSths
18338d5d2d4cSths##########################################
18342f9606b3Saliguori# VNC SASL detection
1835821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
18362f9606b3Saliguori  cat > $TMPC <<EOF
18372f9606b3Saliguori#include <sasl/sasl.h>
18382f9606b3Saliguori#include <stdio.h>
18392f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
18402f9606b3SaliguoriEOF
18412f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
18422f9606b3Saliguori  vnc_sasl_cflags=""
18432f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
184452166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1845ea784e3bSJuan Quintela    vnc_sasl=yes
1846fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1847ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
18482f9606b3Saliguori  else
1849ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1850ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1851ea784e3bSJuan Quintela    fi
1852ea784e3bSJuan Quintela    vnc_sasl=no
18532f9606b3Saliguori  fi
18542f9606b3Saliguorifi
18552f9606b3Saliguori
18562f9606b3Saliguori##########################################
18572f6f5c7aSCorentin Chary# VNC JPEG detection
1858821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
18592f6f5c7aSCorentin Charycat > $TMPC <<EOF
18602f6f5c7aSCorentin Chary#include <stdio.h>
18612f6f5c7aSCorentin Chary#include <jpeglib.h>
18622f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
18632f6f5c7aSCorentin CharyEOF
18642f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
18652f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
18662f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
18672f6f5c7aSCorentin Chary    vnc_jpeg=yes
18682f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1869ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
18702f6f5c7aSCorentin Chary  else
18712f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
18722f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
18732f6f5c7aSCorentin Chary    fi
18742f6f5c7aSCorentin Chary    vnc_jpeg=no
18752f6f5c7aSCorentin Chary  fi
18762f6f5c7aSCorentin Charyfi
18772f6f5c7aSCorentin Chary
18782f6f5c7aSCorentin Chary##########################################
1879efe556adSCorentin Chary# VNC PNG detection
1880821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1881efe556adSCorentin Charycat > $TMPC <<EOF
1882efe556adSCorentin Chary//#include <stdio.h>
1883efe556adSCorentin Chary#include <png.h>
1884832ce9c2SScott Wood#include <stddef.h>
1885efe556adSCorentin Charyint main(void) {
1886efe556adSCorentin Chary    png_structp png_ptr;
1887efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
18887edc3fedSPeter Maydell    return png_ptr != 0;
1889efe556adSCorentin Chary}
1890efe556adSCorentin CharyEOF
18919af8025eSBrad  if $pkg_config libpng --modversion >/dev/null 2>&1; then
18929af8025eSBrad    vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
18939af8025eSBrad    vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
18949af8025eSBrad  else
1895efe556adSCorentin Chary    vnc_png_cflags=""
1896efe556adSCorentin Chary    vnc_png_libs="-lpng"
18979af8025eSBrad  fi
1898efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1899efe556adSCorentin Chary    vnc_png=yes
1900efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
19019af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1902efe556adSCorentin Chary  else
1903efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1904efe556adSCorentin Chary      feature_not_found "vnc-png"
1905efe556adSCorentin Chary    fi
1906efe556adSCorentin Chary    vnc_png=no
1907efe556adSCorentin Chary  fi
1908efe556adSCorentin Charyfi
1909efe556adSCorentin Chary
1910efe556adSCorentin Chary##########################################
191176655d6dSaliguori# fnmatch() probe, used for ACL routines
191276655d6dSaliguorifnmatch="no"
191376655d6dSaliguoricat > $TMPC << EOF
191476655d6dSaliguori#include <fnmatch.h>
191576655d6dSaliguoriint main(void)
191676655d6dSaliguori{
191776655d6dSaliguori    fnmatch("foo", "foo", 0);
191876655d6dSaliguori    return 0;
191976655d6dSaliguori}
192076655d6dSaliguoriEOF
192152166aa0SJuan Quintelaif compile_prog "" "" ; then
192276655d6dSaliguori   fnmatch="yes"
192376655d6dSaliguorifi
192476655d6dSaliguori
192576655d6dSaliguori##########################################
1926ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
19272d16c8e9SPeter Maydell# Note that on some systems (notably MacOSX) no extra library
19282d16c8e9SPeter Maydell# need be linked to get the uuid functions.
1929ee682d27SStefan Weilif test "$uuid" != "no" ; then
1930ee682d27SStefan Weil  uuid_libs="-luuid"
1931ee682d27SStefan Weil  cat > $TMPC << EOF
1932ee682d27SStefan Weil#include <uuid/uuid.h>
1933ee682d27SStefan Weilint main(void)
1934ee682d27SStefan Weil{
1935ee682d27SStefan Weil    uuid_t my_uuid;
1936ee682d27SStefan Weil    uuid_generate(my_uuid);
1937ee682d27SStefan Weil    return 0;
1938ee682d27SStefan Weil}
1939ee682d27SStefan WeilEOF
19402d16c8e9SPeter Maydell  if compile_prog "" "" ; then
19412d16c8e9SPeter Maydell    uuid="yes"
19422d16c8e9SPeter Maydell  elif compile_prog "" "$uuid_libs" ; then
1943ee682d27SStefan Weil    uuid="yes"
1944ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1945ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1946ee682d27SStefan Weil  else
1947ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1948ee682d27SStefan Weil      feature_not_found "uuid"
1949ee682d27SStefan Weil    fi
1950ee682d27SStefan Weil    uuid=no
1951ee682d27SStefan Weil  fi
1952ee682d27SStefan Weilfi
1953ee682d27SStefan Weil
1954ee682d27SStefan Weil##########################################
1955dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1956dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1957dce512deSChristoph Hellwig  cat > $TMPC << EOF
1958ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
1959dce512deSChristoph Hellwig#include <xfs/xfs.h>
1960dce512deSChristoph Hellwigint main(void)
1961dce512deSChristoph Hellwig{
1962dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1963dce512deSChristoph Hellwig    return 0;
1964dce512deSChristoph Hellwig}
1965dce512deSChristoph HellwigEOF
1966dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1967dce512deSChristoph Hellwig    xfs="yes"
1968dce512deSChristoph Hellwig  else
1969dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1970dce512deSChristoph Hellwig      feature_not_found "xfs"
1971dce512deSChristoph Hellwig    fi
1972dce512deSChristoph Hellwig    xfs=no
1973dce512deSChristoph Hellwig  fi
1974dce512deSChristoph Hellwigfi
1975dce512deSChristoph Hellwig
1976dce512deSChristoph Hellwig##########################################
19778a16d273Sths# vde libraries probe
1978dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
19794baae0acSJuan Quintela  vde_libs="-lvdeplug"
19808a16d273Sths  cat > $TMPC << EOF
19818a16d273Sths#include <libvdeplug.h>
19824a7f0e06Spbrookint main(void)
19834a7f0e06Spbrook{
19844a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
1985fea08e08SPeter Maydell    char s[] = "";
1986fea08e08SPeter Maydell    vde_open(s, s, &a);
19874a7f0e06Spbrook    return 0;
19884a7f0e06Spbrook}
19898a16d273SthsEOF
199052166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
19914baae0acSJuan Quintela    vde=yes
19928e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
19938e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1994dfb278bdSJuan Quintela  else
1995dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1996dfb278bdSJuan Quintela      feature_not_found "vde"
1997dfb278bdSJuan Quintela    fi
1998dfb278bdSJuan Quintela    vde=no
19998a16d273Sths  fi
20008a16d273Sthsfi
20018a16d273Sths
20028a16d273Sths##########################################
200347e98658SCorey Bryant# libcap-ng library probe
200447e98658SCorey Bryantif test "$cap_ng" != "no" ; then
200547e98658SCorey Bryant  cap_libs="-lcap-ng"
200647e98658SCorey Bryant  cat > $TMPC << EOF
200747e98658SCorey Bryant#include <cap-ng.h>
200847e98658SCorey Bryantint main(void)
200947e98658SCorey Bryant{
201047e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
201147e98658SCorey Bryant    return 0;
201247e98658SCorey Bryant}
201347e98658SCorey BryantEOF
201447e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
201547e98658SCorey Bryant    cap_ng=yes
201647e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
201747e98658SCorey Bryant  else
201847e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
201947e98658SCorey Bryant      feature_not_found "cap_ng"
202047e98658SCorey Bryant    fi
202147e98658SCorey Bryant    cap_ng=no
202247e98658SCorey Bryant  fi
202347e98658SCorey Bryantfi
202447e98658SCorey Bryant
202547e98658SCorey Bryant##########################################
2026c2de5c91Smalc# Sound support libraries probe
20278f28f3fbSths
2028c2de5c91Smalcaudio_drv_probe()
2029c2de5c91Smalc{
2030c2de5c91Smalc    drv=$1
2031c2de5c91Smalc    hdr=$2
2032c2de5c91Smalc    lib=$3
2033c2de5c91Smalc    exp=$4
2034c2de5c91Smalc    cfl=$5
20358f28f3fbSths        cat > $TMPC << EOF
2036c2de5c91Smalc#include <$hdr>
2037c2de5c91Smalcint main(void) { $exp }
20388f28f3fbSthsEOF
203952166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
20408f28f3fbSths        :
20418f28f3fbSths    else
204276ad07a4SPeter Maydell        error_exit "$drv check failed" \
204376ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
20448f28f3fbSths    fi
2045c2de5c91Smalc}
2046c2de5c91Smalc
20472fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
2048c2de5c91Smalcfor drv in $audio_drv_list; do
2049c2de5c91Smalc    case $drv in
2050c2de5c91Smalc    alsa)
2051c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
2052e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
2053a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
2054c2de5c91Smalc    ;;
2055c2de5c91Smalc
2056c2de5c91Smalc    fmod)
2057c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
205876ad07a4SPeter Maydell        error_exit "You must specify path to FMOD library and headers" \
205976ad07a4SPeter Maydell            "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
20608f28f3fbSths    fi
2061c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
2062a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
2063c2de5c91Smalc    ;;
2064c2de5c91Smalc
2065c2de5c91Smalc    esd)
2066c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
2067a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
206867f86e8eSJuan Quintela    audio_pt_int="yes"
2069c2de5c91Smalc    ;;
2070b8e59f18Smalc
2071b8e59f18Smalc    pa)
2072a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
2073a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
2074a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
207567f86e8eSJuan Quintela    audio_pt_int="yes"
2076b8e59f18Smalc    ;;
2077b8e59f18Smalc
2078997e690aSJuan Quintela    coreaudio)
2079997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
2080997e690aSJuan Quintela    ;;
2081997e690aSJuan Quintela
2082a4bf6780SJuan Quintela    dsound)
2083a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2084d5631638Smalc      audio_win_int="yes"
2085a4bf6780SJuan Quintela    ;;
2086a4bf6780SJuan Quintela
2087a4bf6780SJuan Quintela    oss)
2088a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
2089a4bf6780SJuan Quintela    ;;
2090a4bf6780SJuan Quintela
2091a4bf6780SJuan Quintela    sdl|wav)
20922f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
20932f6a1ab0Sblueswir1    ;;
20942f6a1ab0Sblueswir1
2095d5631638Smalc    winwave)
2096d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
2097d5631638Smalc      audio_win_int="yes"
2098d5631638Smalc    ;;
2099d5631638Smalc
2100e4c63a6aSmalc    *)
21011c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
210276ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
210376ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
2104e4c63a6aSmalc    }
2105e4c63a6aSmalc    ;;
2106c2de5c91Smalc    esac
2107c2de5c91Smalcdone
21088f28f3fbSths
21094d3b6f6eSbalrog##########################################
21102e4d9fb1Saurel32# BrlAPI probe
21112e4d9fb1Saurel32
21124ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2113eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
21142e4d9fb1Saurel32  cat > $TMPC << EOF
21152e4d9fb1Saurel32#include <brlapi.h>
2116832ce9c2SScott Wood#include <stddef.h>
21172e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
21182e4d9fb1Saurel32EOF
211952166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
21202e4d9fb1Saurel32    brlapi=yes
2121264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
21224ffcedb6SJuan Quintela  else
21234ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
21244ffcedb6SJuan Quintela      feature_not_found "brlapi"
21254ffcedb6SJuan Quintela    fi
21264ffcedb6SJuan Quintela    brlapi=no
2127eb82284fSJuan Quintela  fi
2128eb82284fSJuan Quintelafi
21292e4d9fb1Saurel32
21302e4d9fb1Saurel32##########################################
21314d3b6f6eSbalrog# curses probe
2132a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
2133e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
2134e095e2f3SStefan Weil    curses_list="-lpdcurses"
2135e095e2f3SStefan Weil  else
2136cfeda5f4SEd Maste    curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
2137e095e2f3SStefan Weil  fi
2138c584a6d0SJuan Quintela  curses_found=no
21394d3b6f6eSbalrog  cat > $TMPC << EOF
21404d3b6f6eSbalrog#include <curses.h>
2141ef9a2524SStefan Weilint main(void) {
2142ef9a2524SStefan Weil  const char *s = curses_version();
2143ef9a2524SStefan Weil  resize_term(0, 0);
2144ef9a2524SStefan Weil  return s != 0;
2145ef9a2524SStefan Weil}
21464d3b6f6eSbalrogEOF
2147ecbe251fSVadim Evard  IFS=:
21484f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
2149ecbe251fSVadim Evard    unset IFS
21504f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2151c584a6d0SJuan Quintela      curses_found=yes
21524f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
21534f78ef9aSJuan Quintela      break
21544d3b6f6eSbalrog    fi
21554f78ef9aSJuan Quintela  done
2156ecbe251fSVadim Evard  unset IFS
2157c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2158c584a6d0SJuan Quintela    curses=yes
2159c584a6d0SJuan Quintela  else
2160c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
2161c584a6d0SJuan Quintela      feature_not_found "curses"
2162c584a6d0SJuan Quintela    fi
2163c584a6d0SJuan Quintela    curses=no
2164c584a6d0SJuan Quintela  fi
21654f78ef9aSJuan Quintelafi
21664d3b6f6eSbalrog
2167414f0dabSblueswir1##########################################
2168769ce76dSAlexander Graf# curl probe
2169a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
2170a8bd70adSPaolo Bonzini  if $pkg_config libcurl --modversion >/dev/null 2>&1; then
2171a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
21724e2b0658SPaolo Bonzini  else
21734e2b0658SPaolo Bonzini    curlconfig=curl-config
21744e2b0658SPaolo Bonzini  fi
2175769ce76dSAlexander Graf  cat > $TMPC << EOF
2176769ce76dSAlexander Graf#include <curl/curl.h>
21770b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2178769ce76dSAlexander GrafEOF
21794e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
21804e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2181b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2182769ce76dSAlexander Graf    curl=yes
2183f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2184f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2185788c8196SJuan Quintela  else
2186788c8196SJuan Quintela    if test "$curl" = "yes" ; then
2187788c8196SJuan Quintela      feature_not_found "curl"
2188788c8196SJuan Quintela    fi
2189788c8196SJuan Quintela    curl=no
2190769ce76dSAlexander Graf  fi
2191769ce76dSAlexander Graffi # test "$curl"
2192769ce76dSAlexander Graf
2193769ce76dSAlexander Graf##########################################
2194fb599c9aSbalrog# bluez support probe
2195a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2196e820e3f4Sbalrog  cat > $TMPC << EOF
2197e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2198e820e3f4Sbalrogint main(void) { return bt_error(0); }
2199e820e3f4SbalrogEOF
2200a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2201a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
220252166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2203a20a6f46SJuan Quintela    bluez=yes
2204e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2205e820e3f4Sbalrog  else
2206a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
2207a20a6f46SJuan Quintela      feature_not_found "bluez"
2208a20a6f46SJuan Quintela    fi
2209e820e3f4Sbalrog    bluez="no"
2210e820e3f4Sbalrog  fi
2211fb599c9aSbalrogfi
2212fb599c9aSbalrog
2213fb599c9aSbalrog##########################################
2214e18df141SAnthony Liguori# glib support probe
2215a52d28afSPaolo Bonzini
2216a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2217a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2218a52d28afSPaolo Bonzini    glib_req_ver=2.20
2219a52d28afSPaolo Bonzinielse
2220a52d28afSPaolo Bonzini    glib_req_ver=2.12
2221a52d28afSPaolo Bonzinifi
2222a52d28afSPaolo Bonziniif $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
2223a52d28afSPaolo Bonzinithen
22244b76a481SStefan Hajnoczi    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
22254b76a481SStefan Hajnoczi    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
222614015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2227957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2228e18df141SAnthony Liguorielse
222976ad07a4SPeter Maydell    error_exit "glib-$glib_req_ver required to compile QEMU"
2230e18df141SAnthony Liguorifi
2231e18df141SAnthony Liguori
2232e18df141SAnthony Liguori##########################################
2233e2134eb9SGerd Hoffmann# pixman support probe
2234e2134eb9SGerd Hoffmann
2235e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
223674880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
223774880fe2SRobert Schiele    pixman="none"
223874880fe2SRobert Schiele  elif $pkg_config pixman-1 > /dev/null 2>&1; then
2239e2134eb9SGerd Hoffmann    pixman="system"
2240e2134eb9SGerd Hoffmann  else
2241e2134eb9SGerd Hoffmann    pixman="internal"
2242e2134eb9SGerd Hoffmann  fi
2243e2134eb9SGerd Hoffmannfi
224474880fe2SRobert Schieleif test "$pixman" = "none"; then
224574880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
224676ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
224776ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
224876ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
224976ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
225074880fe2SRobert Schiele  fi
225174880fe2SRobert Schiele  pixman_cflags=
225274880fe2SRobert Schiele  pixman_libs=
225374880fe2SRobert Schieleelif test "$pixman" = "system"; then
2254e2134eb9SGerd Hoffmann  pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null`
2255e2134eb9SGerd Hoffmann  pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null`
2256e2134eb9SGerd Hoffmannelse
2257e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
225876ad07a4SPeter Maydell    error_exit "pixman not present. Your options:" \
225976ad07a4SPeter Maydell        "  (1) Preferred: Install the pixman devel package (any recent" \
226076ad07a4SPeter Maydell        "      distro should have packages as Xorg needs pixman too)." \
226176ad07a4SPeter Maydell        "  (2) Fetch the pixman submodule, using:" \
226276ad07a4SPeter Maydell        "      git submodule update --init pixman"
2263e2134eb9SGerd Hoffmann  fi
22645ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
22655ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
22665ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2267e2134eb9SGerd Hoffmannfi
2268e2134eb9SGerd Hoffmann
2269e2134eb9SGerd Hoffmann##########################################
227017bff52bSM. Mohan Kumar# libcap probe
227117bff52bSM. Mohan Kumar
227217bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
227317bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
227417bff52bSM. Mohan Kumar#include <stdio.h>
227517bff52bSM. Mohan Kumar#include <sys/capability.h>
2276cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
227717bff52bSM. Mohan KumarEOF
227817bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
227917bff52bSM. Mohan Kumar    cap=yes
228017bff52bSM. Mohan Kumar  else
228117bff52bSM. Mohan Kumar    cap=no
228217bff52bSM. Mohan Kumar  fi
228317bff52bSM. Mohan Kumarfi
228417bff52bSM. Mohan Kumar
228517bff52bSM. Mohan Kumar##########################################
2286e5d355d1Saliguori# pthread probe
22874b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
22883c529d93Saliguori
2289e5d355d1Saliguoripthread=no
2290414f0dabSblueswir1cat > $TMPC << EOF
22913c529d93Saliguori#include <pthread.h>
22927a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
22937a42bbe4SStefan Weilint main(void) {
22947a42bbe4SStefan Weil  pthread_t thread;
22957a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
22967a42bbe4SStefan Weil  return 0;
22977a42bbe4SStefan Weil}
2298414f0dabSblueswir1EOF
2299bd00d539SAndreas Färberif compile_prog "" "" ; then
2300bd00d539SAndreas Färber  pthread=yes
2301bd00d539SAndreas Färberelse
2302de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
230352166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2304e5d355d1Saliguori      pthread=yes
2305e3c56761SPeter Portante      found=no
2306e3c56761SPeter Portante      for lib_entry in $LIBS; do
2307e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2308e3c56761SPeter Portante          found=yes
2309e3c56761SPeter Portante          break
2310e3c56761SPeter Portante        fi
2311e3c56761SPeter Portante      done
2312e3c56761SPeter Portante      if test "$found" = "no"; then
23135572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2314e3c56761SPeter Portante      fi
2315de65fe0fSSebastian Herbszt      break
2316414f0dabSblueswir1    fi
2317de65fe0fSSebastian Herbszt  done
2318bd00d539SAndreas Färberfi
2319414f0dabSblueswir1
23204617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
232176ad07a4SPeter Maydell  error_exit "pthread check failed" \
232276ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
2323e5d355d1Saliguorifi
2324e5d355d1Saliguori
2325bf9298b9Saliguori##########################################
2326f27aaf4bSChristian Brunner# rbd probe
2327f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2328f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2329f27aaf4bSChristian Brunner#include <stdio.h>
2330ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2331f27aaf4bSChristian Brunnerint main(void) {
2332ad32e9c0SJosh Durgin    rados_t cluster;
2333ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2334f27aaf4bSChristian Brunner    return 0;
2335f27aaf4bSChristian Brunner}
2336f27aaf4bSChristian BrunnerEOF
2337ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2338f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2339f27aaf4bSChristian Brunner    rbd=yes
2340f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2341f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2342f27aaf4bSChristian Brunner  else
2343f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
2344f27aaf4bSChristian Brunner      feature_not_found "rados block device"
2345f27aaf4bSChristian Brunner    fi
2346f27aaf4bSChristian Brunner    rbd=no
2347f27aaf4bSChristian Brunner  fi
2348f27aaf4bSChristian Brunnerfi
2349f27aaf4bSChristian Brunner
2350f27aaf4bSChristian Brunner##########################################
23510a12ec87SRichard W.M. Jones# libssh2 probe
23524fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
23530a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
23544fc16838SRichard W.M. Jones  if $pkg_config --atleast-version=$min_libssh2_version libssh2 >/dev/null 2>&1
23554fc16838SRichard W.M. Jones  then
23560a12ec87SRichard W.M. Jones    libssh2_cflags=`$pkg_config libssh2 --cflags`
23570a12ec87SRichard W.M. Jones    libssh2_libs=`$pkg_config libssh2 --libs`
23580a12ec87SRichard W.M. Jones    libssh2=yes
23590a12ec87SRichard W.M. Jones    libs_tools="$libssh2_libs $libs_tools"
23600a12ec87SRichard W.M. Jones    libs_softmmu="$libssh2_libs $libs_softmmu"
23610a12ec87SRichard W.M. Jones    QEMU_CFLAGS="$QEMU_CFLAGS $libssh2_cflags"
23620a12ec87SRichard W.M. Jones  else
23630a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
23644fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
23650a12ec87SRichard W.M. Jones    fi
23660a12ec87SRichard W.M. Jones    libssh2=no
23670a12ec87SRichard W.M. Jones  fi
23680a12ec87SRichard W.M. Jonesfi
23690a12ec87SRichard W.M. Jones
23700a12ec87SRichard W.M. Jones##########################################
23719a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
23729a2d462eSRichard W.M. Jones
23739a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
23749a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
23759a2d462eSRichard W.M. Jones#include <stdio.h>
23769a2d462eSRichard W.M. Jones#include <libssh2.h>
23779a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
23789a2d462eSRichard W.M. Jonesint main(void) {
23799a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
23809a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
23819a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
23829a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
23839a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
23849a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
23859a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
23869a2d462eSRichard W.M. Jones    return 0;
23879a2d462eSRichard W.M. Jones}
23889a2d462eSRichard W.M. JonesEOF
23899a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
23909a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
23919a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
23929a2d462eSRichard W.M. Jones  fi
23939a2d462eSRichard W.M. Jonesfi
23949a2d462eSRichard W.M. Jones
23959a2d462eSRichard W.M. Jones##########################################
23965c6c3a6cSChristoph Hellwig# linux-aio probe
23975c6c3a6cSChristoph Hellwig
23985c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
23995c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
24005c6c3a6cSChristoph Hellwig#include <libaio.h>
24015c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2402832ce9c2SScott Wood#include <stddef.h>
24035c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
24045c6c3a6cSChristoph HellwigEOF
24055c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
24065c6c3a6cSChristoph Hellwig    linux_aio=yes
2407048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2408048d179fSPaul Brook    libs_tools="$libs_tools -laio"
24095c6c3a6cSChristoph Hellwig  else
24105c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
24115c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
24125c6c3a6cSChristoph Hellwig    fi
24133cfcae3cSLuiz Capitulino    linux_aio=no
24145c6c3a6cSChristoph Hellwig  fi
24155c6c3a6cSChristoph Hellwigfi
24165c6c3a6cSChristoph Hellwig
24175c6c3a6cSChristoph Hellwig##########################################
24183b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
24193b8acc11SPaolo Bonzini
24203b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
24213b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
24223b8acc11SPaolo Bonzinielse
24233b8acc11SPaolo Bonzini  tpm_passthrough=no
24243b8acc11SPaolo Bonzinifi
24253b8acc11SPaolo Bonzini
24263b8acc11SPaolo Bonzini##########################################
2427583f6e7bSStefan Hajnoczi# adjust virtio-blk-data-plane based on linux-aio
2428583f6e7bSStefan Hajnoczi
2429583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" -a \
2430583f6e7bSStefan Hajnoczi	"$linux_aio" != "yes" ; then
243176ad07a4SPeter Maydell  error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
2432583f6e7bSStefan Hajnoczielif test -z "$virtio_blk_data_plane" ; then
2433583f6e7bSStefan Hajnoczi  virtio_blk_data_plane=$linux_aio
2434583f6e7bSStefan Hajnoczifi
2435583f6e7bSStefan Hajnoczi
2436583f6e7bSStefan Hajnoczi##########################################
2437758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2438758e8e38SVenkateswararao Jujjuri (JV)
2439758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2440758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2441758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2442758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2443f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2444f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2445f2338fb4SPavel Borzenkov#else
24464f26f2b6SAvi Kivity#include <sys/xattr.h>
2447f2338fb4SPavel Borzenkov#endif
2448758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2449758e8e38SVenkateswararao Jujjuri (JV)EOF
24504f26f2b6SAvi Kivity  if compile_prog "" "" ; then
24514f26f2b6SAvi Kivity    attr=yes
24524f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2453f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2454758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2455758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
24564f26f2b6SAvi Kivity    libattr=yes
2457758e8e38SVenkateswararao Jujjuri (JV)  else
2458758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2459758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2460758e8e38SVenkateswararao Jujjuri (JV)    fi
2461758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2462758e8e38SVenkateswararao Jujjuri (JV)  fi
2463758e8e38SVenkateswararao Jujjuri (JV)fi
2464758e8e38SVenkateswararao Jujjuri (JV)
2465758e8e38SVenkateswararao Jujjuri (JV)##########################################
2466bf9298b9Saliguori# iovec probe
2467bf9298b9Saliguoricat > $TMPC <<EOF
2468db34f0b3Sblueswir1#include <sys/types.h>
2469bf9298b9Saliguori#include <sys/uio.h>
2470db34f0b3Sblueswir1#include <unistd.h>
2471f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2472bf9298b9SaliguoriEOF
2473bf9298b9Saliguoriiovec=no
247452166aa0SJuan Quintelaif compile_prog "" "" ; then
2475bf9298b9Saliguori  iovec=yes
2476bf9298b9Saliguorifi
2477bf9298b9Saliguori
2478f652e6afSaurel32##########################################
2479ceb42de8Saliguori# preadv probe
2480ceb42de8Saliguoricat > $TMPC <<EOF
2481ceb42de8Saliguori#include <sys/types.h>
2482ceb42de8Saliguori#include <sys/uio.h>
2483ceb42de8Saliguori#include <unistd.h>
2484c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2485ceb42de8SaliguoriEOF
2486ceb42de8Saliguoripreadv=no
248752166aa0SJuan Quintelaif compile_prog "" "" ; then
2488ceb42de8Saliguori  preadv=yes
2489ceb42de8Saliguorifi
2490ceb42de8Saliguori
2491ceb42de8Saliguori##########################################
2492f652e6afSaurel32# fdt probe
2493e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
2494e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
2495e169e1e1SPeter Maydellfdt_required=no
2496e169e1e1SPeter Maydellfor target in $target_list; do
2497e169e1e1SPeter Maydell  case $target in
2498e169e1e1SPeter Maydell    arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
2499e169e1e1SPeter Maydell      fdt_required=yes
2500e169e1e1SPeter Maydell    ;;
2501e169e1e1SPeter Maydell  esac
2502e169e1e1SPeter Maydelldone
2503e169e1e1SPeter Maydell
2504e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
2505e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
2506e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
2507e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
2508e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
2509e169e1e1SPeter Maydell  fi
2510e169e1e1SPeter Maydell  fdt=yes
2511e169e1e1SPeter Maydellfi
2512e169e1e1SPeter Maydell
25132df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2514b41af4baSJuan Quintela  fdt_libs="-lfdt"
251596ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
2516f652e6afSaurel32  cat > $TMPC << EOF
251796ce6545SPeter Crosthwaite#include <libfdt_env.h>
2518f652e6afSaurel32int main(void) { return 0; }
2519f652e6afSaurel32EOF
252052166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2521a540f158SPeter Crosthwaite    # system DTC is good - use it
2522f652e6afSaurel32    fdt=yes
2523a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
2524a540f158SPeter Crosthwaite    # have submodule DTC - use it
2525a540f158SPeter Crosthwaite    fdt=yes
2526a540f158SPeter Crosthwaite    dtc_internal="yes"
2527a540f158SPeter Crosthwaite    mkdir -p dtc
2528a540f158SPeter Crosthwaite    if [ "$source_path" != `pwd` ] ; then
2529a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
2530a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
25312df87df7SJuan Quintela    fi
2532a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
2533a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
2534a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
2535a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
2536f2c4ddd9SAndreas Färber    error_exit "DTC not present. Your options:" \
2537a540f158SPeter Crosthwaite        "  (1) Preferred: Install the DTC devel package" \
2538a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
2539a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
2540a540f158SPeter Crosthwaite  else
2541a540f158SPeter Crosthwaite    # don't have and don't want
2542de3a354aSMichael Walle    fdt_libs=
25432df87df7SJuan Quintela    fdt=no
2544f652e6afSaurel32  fi
2545f652e6afSaurel32fi
2546f652e6afSaurel32
2547a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
2548a540f158SPeter Crosthwaite
254920ff075bSMichael Walle##########################################
2550b1e5fff4SMichael Walle# GLX probe, used by milkymist-tmu2
2551b1e5fff4SMichael Walleif test "$glx" != "no" ; then
2552b1e5fff4SMichael Walle  glx_libs="-lGL -lX11"
255320ff075bSMichael Walle  cat > $TMPC << EOF
255420ff075bSMichael Walle#include <X11/Xlib.h>
255520ff075bSMichael Walle#include <GL/gl.h>
255620ff075bSMichael Walle#include <GL/glx.h>
2557d3fcbb16SMichael Walleint main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
255820ff075bSMichael WalleEOF
2559d3fcbb16SMichael Walle  if compile_prog "" "-lGL -lX11" ; then
2560b1e5fff4SMichael Walle    glx=yes
256120ff075bSMichael Walle  else
2562b1e5fff4SMichael Walle    if test "$glx" = "yes" ; then
2563b1e5fff4SMichael Walle      feature_not_found "glx"
256420ff075bSMichael Walle    fi
2565b1e5fff4SMichael Walle    glx_libs=
2566b1e5fff4SMichael Walle    glx=no
256720ff075bSMichael Walle  fi
256820ff075bSMichael Wallefi
256920ff075bSMichael Walle
2570eb100396SBharata B Rao##########################################
2571eb100396SBharata B Rao# glusterfs probe
2572eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
2573eb100396SBharata B Rao  cat > $TMPC <<EOF
2574eb100396SBharata B Rao#include <glusterfs/api/glfs.h>
2575eb100396SBharata B Raoint main(void) {
2576eb100396SBharata B Rao    (void) glfs_new("volume");
2577eb100396SBharata B Rao    return 0;
2578eb100396SBharata B Rao}
2579eb100396SBharata B RaoEOF
2580eb100396SBharata B Rao  glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
2581eb100396SBharata B Rao  if compile_prog "" "$glusterfs_libs" ; then
2582eb100396SBharata B Rao    glusterfs=yes
2583eb100396SBharata B Rao    libs_tools="$glusterfs_libs $libs_tools"
2584eb100396SBharata B Rao    libs_softmmu="$glusterfs_libs $libs_softmmu"
2585eb100396SBharata B Rao  else
2586eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
2587eb100396SBharata B Rao      feature_not_found "GlusterFS backend support"
2588eb100396SBharata B Rao    fi
2589eb100396SBharata B Rao    glusterfs=no
2590eb100396SBharata B Rao  fi
2591eb100396SBharata B Raofi
2592eb100396SBharata B Rao
259339386ac7Saurel32# Check for inotify functions when we are building linux-user
25943b3f24adSaurel32# emulator.  This is done because older glibc versions don't
25953b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
25963b3f24adSaurel32# don't provide them even if kernel supports them.
25973b3f24adSaurel32#
25983b3f24adSaurel32inotify=no
25993b3f24adSaurel32cat > $TMPC << EOF
26003b3f24adSaurel32#include <sys/inotify.h>
26013b3f24adSaurel32
26023b3f24adSaurel32int
26033b3f24adSaurel32main(void)
26043b3f24adSaurel32{
26053b3f24adSaurel32	/* try to start inotify */
26068690e420Saurel32	return inotify_init();
26073b3f24adSaurel32}
26083b3f24adSaurel32EOF
260952166aa0SJuan Quintelaif compile_prog "" "" ; then
26103b3f24adSaurel32  inotify=yes
26113b3f24adSaurel32fi
26123b3f24adSaurel32
2613c05c7a73SRiku Voipioinotify1=no
2614c05c7a73SRiku Voipiocat > $TMPC << EOF
2615c05c7a73SRiku Voipio#include <sys/inotify.h>
2616c05c7a73SRiku Voipio
2617c05c7a73SRiku Voipioint
2618c05c7a73SRiku Voipiomain(void)
2619c05c7a73SRiku Voipio{
2620c05c7a73SRiku Voipio    /* try to start inotify */
2621c05c7a73SRiku Voipio    return inotify_init1(0);
2622c05c7a73SRiku Voipio}
2623c05c7a73SRiku VoipioEOF
2624c05c7a73SRiku Voipioif compile_prog "" "" ; then
2625c05c7a73SRiku Voipio  inotify1=yes
2626c05c7a73SRiku Voipiofi
2627c05c7a73SRiku Voipio
2628ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2629ebc996f3SRiku Voipioutimens=no
2630ebc996f3SRiku Voipiocat > $TMPC << EOF
2631ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2632ebc996f3SRiku Voipio#include <stddef.h>
2633ebc996f3SRiku Voipio#include <fcntl.h>
26343014ee00SPeter Maydell#include <sys/stat.h>
2635ebc996f3SRiku Voipio
2636ebc996f3SRiku Voipioint main(void)
2637ebc996f3SRiku Voipio{
2638ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2639ebc996f3SRiku Voipio    futimens(0, NULL);
2640ebc996f3SRiku Voipio    return 0;
2641ebc996f3SRiku Voipio}
2642ebc996f3SRiku VoipioEOF
264352166aa0SJuan Quintelaif compile_prog "" "" ; then
2644ebc996f3SRiku Voipio  utimens=yes
2645ebc996f3SRiku Voipiofi
2646ebc996f3SRiku Voipio
2647099d6b0fSRiku Voipio# check if pipe2 is there
2648099d6b0fSRiku Voipiopipe2=no
2649099d6b0fSRiku Voipiocat > $TMPC << EOF
2650099d6b0fSRiku Voipio#include <unistd.h>
2651099d6b0fSRiku Voipio#include <fcntl.h>
2652099d6b0fSRiku Voipio
2653099d6b0fSRiku Voipioint main(void)
2654099d6b0fSRiku Voipio{
2655099d6b0fSRiku Voipio    int pipefd[2];
26569bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
2657099d6b0fSRiku Voipio}
2658099d6b0fSRiku VoipioEOF
265952166aa0SJuan Quintelaif compile_prog "" "" ; then
2660099d6b0fSRiku Voipio  pipe2=yes
2661099d6b0fSRiku Voipiofi
2662099d6b0fSRiku Voipio
266340ff6d7eSKevin Wolf# check if accept4 is there
266440ff6d7eSKevin Wolfaccept4=no
266540ff6d7eSKevin Wolfcat > $TMPC << EOF
266640ff6d7eSKevin Wolf#include <sys/socket.h>
266740ff6d7eSKevin Wolf#include <stddef.h>
266840ff6d7eSKevin Wolf
266940ff6d7eSKevin Wolfint main(void)
267040ff6d7eSKevin Wolf{
267140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
267240ff6d7eSKevin Wolf    return 0;
267340ff6d7eSKevin Wolf}
267440ff6d7eSKevin WolfEOF
267540ff6d7eSKevin Wolfif compile_prog "" "" ; then
267640ff6d7eSKevin Wolf  accept4=yes
267740ff6d7eSKevin Wolffi
267840ff6d7eSKevin Wolf
26793ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
26803ce34dfbSvibisreenivasansplice=no
26813ce34dfbSvibisreenivasancat > $TMPC << EOF
26823ce34dfbSvibisreenivasan#include <unistd.h>
26833ce34dfbSvibisreenivasan#include <fcntl.h>
26843ce34dfbSvibisreenivasan#include <limits.h>
26853ce34dfbSvibisreenivasan
26863ce34dfbSvibisreenivasanint main(void)
26873ce34dfbSvibisreenivasan{
268866ea0f22SStefan Weil    int len, fd = 0;
26893ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
26903ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
26913ce34dfbSvibisreenivasan    return 0;
26923ce34dfbSvibisreenivasan}
26933ce34dfbSvibisreenivasanEOF
269452166aa0SJuan Quintelaif compile_prog "" "" ; then
26953ce34dfbSvibisreenivasan  splice=yes
26963ce34dfbSvibisreenivasanfi
26973ce34dfbSvibisreenivasan
2698dcc38d1cSMarcelo Tosatti##########################################
2699dcc38d1cSMarcelo Tosatti# signalfd probe
2700dcc38d1cSMarcelo Tosattisignalfd="no"
2701dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2702dcc38d1cSMarcelo Tosatti#include <unistd.h>
2703dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2704dcc38d1cSMarcelo Tosatti#include <signal.h>
2705dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2706dcc38d1cSMarcelo TosattiEOF
2707dcc38d1cSMarcelo Tosatti
2708dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2709dcc38d1cSMarcelo Tosatti  signalfd=yes
2710dcc38d1cSMarcelo Tosattifi
2711dcc38d1cSMarcelo Tosatti
2712c2882b96SRiku Voipio# check if eventfd is supported
2713c2882b96SRiku Voipioeventfd=no
2714c2882b96SRiku Voipiocat > $TMPC << EOF
2715c2882b96SRiku Voipio#include <sys/eventfd.h>
2716c2882b96SRiku Voipio
2717c2882b96SRiku Voipioint main(void)
2718c2882b96SRiku Voipio{
271955cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2720c2882b96SRiku Voipio}
2721c2882b96SRiku VoipioEOF
2722c2882b96SRiku Voipioif compile_prog "" "" ; then
2723c2882b96SRiku Voipio  eventfd=yes
2724c2882b96SRiku Voipiofi
2725c2882b96SRiku Voipio
2726d0927938SUlrich Hecht# check for fallocate
2727d0927938SUlrich Hechtfallocate=no
2728d0927938SUlrich Hechtcat > $TMPC << EOF
2729d0927938SUlrich Hecht#include <fcntl.h>
2730d0927938SUlrich Hecht
2731d0927938SUlrich Hechtint main(void)
2732d0927938SUlrich Hecht{
2733d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2734d0927938SUlrich Hecht    return 0;
2735d0927938SUlrich Hecht}
2736d0927938SUlrich HechtEOF
27378fb03151SPeter Maydellif compile_prog "" "" ; then
2738d0927938SUlrich Hecht  fallocate=yes
2739d0927938SUlrich Hechtfi
2740d0927938SUlrich Hecht
27413d4fa43eSKusanagi Kouichi# check for fallocate hole punching
27423d4fa43eSKusanagi Kouichifallocate_punch_hole=no
27433d4fa43eSKusanagi Kouichicat > $TMPC << EOF
27443d4fa43eSKusanagi Kouichi#include <fcntl.h>
27453d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
27463d4fa43eSKusanagi Kouichi
27473d4fa43eSKusanagi Kouichiint main(void)
27483d4fa43eSKusanagi Kouichi{
27493d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
27503d4fa43eSKusanagi Kouichi    return 0;
27513d4fa43eSKusanagi Kouichi}
27523d4fa43eSKusanagi KouichiEOF
27533d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
27543d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
27553d4fa43eSKusanagi Kouichifi
27563d4fa43eSKusanagi Kouichi
2757c727f47dSPeter Maydell# check for sync_file_range
2758c727f47dSPeter Maydellsync_file_range=no
2759c727f47dSPeter Maydellcat > $TMPC << EOF
2760c727f47dSPeter Maydell#include <fcntl.h>
2761c727f47dSPeter Maydell
2762c727f47dSPeter Maydellint main(void)
2763c727f47dSPeter Maydell{
2764c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2765c727f47dSPeter Maydell    return 0;
2766c727f47dSPeter Maydell}
2767c727f47dSPeter MaydellEOF
27688fb03151SPeter Maydellif compile_prog "" "" ; then
2769c727f47dSPeter Maydell  sync_file_range=yes
2770c727f47dSPeter Maydellfi
2771c727f47dSPeter Maydell
2772dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2773dace20dcSPeter Maydellfiemap=no
2774dace20dcSPeter Maydellcat > $TMPC << EOF
2775dace20dcSPeter Maydell#include <sys/ioctl.h>
2776dace20dcSPeter Maydell#include <linux/fs.h>
2777dace20dcSPeter Maydell#include <linux/fiemap.h>
2778dace20dcSPeter Maydell
2779dace20dcSPeter Maydellint main(void)
2780dace20dcSPeter Maydell{
2781dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2782dace20dcSPeter Maydell    return 0;
2783dace20dcSPeter Maydell}
2784dace20dcSPeter MaydellEOF
27858fb03151SPeter Maydellif compile_prog "" "" ; then
2786dace20dcSPeter Maydell  fiemap=yes
2787dace20dcSPeter Maydellfi
2788dace20dcSPeter Maydell
2789d0927938SUlrich Hecht# check for dup3
2790d0927938SUlrich Hechtdup3=no
2791d0927938SUlrich Hechtcat > $TMPC << EOF
2792d0927938SUlrich Hecht#include <unistd.h>
2793d0927938SUlrich Hecht
2794d0927938SUlrich Hechtint main(void)
2795d0927938SUlrich Hecht{
2796d0927938SUlrich Hecht    dup3(0, 0, 0);
2797d0927938SUlrich Hecht    return 0;
2798d0927938SUlrich Hecht}
2799d0927938SUlrich HechtEOF
280078f5d726SJan Kiszkaif compile_prog "" "" ; then
2801d0927938SUlrich Hecht  dup3=yes
2802d0927938SUlrich Hechtfi
2803d0927938SUlrich Hecht
28043b6edd16SPeter Maydell# check for epoll support
28053b6edd16SPeter Maydellepoll=no
28063b6edd16SPeter Maydellcat > $TMPC << EOF
28073b6edd16SPeter Maydell#include <sys/epoll.h>
28083b6edd16SPeter Maydell
28093b6edd16SPeter Maydellint main(void)
28103b6edd16SPeter Maydell{
28113b6edd16SPeter Maydell    epoll_create(0);
28123b6edd16SPeter Maydell    return 0;
28133b6edd16SPeter Maydell}
28143b6edd16SPeter MaydellEOF
28158fb03151SPeter Maydellif compile_prog "" "" ; then
28163b6edd16SPeter Maydell  epoll=yes
28173b6edd16SPeter Maydellfi
28183b6edd16SPeter Maydell
28193b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
28203b6edd16SPeter Maydell# so we must check separately for their presence
28213b6edd16SPeter Maydellepoll_create1=no
28223b6edd16SPeter Maydellcat > $TMPC << EOF
28233b6edd16SPeter Maydell#include <sys/epoll.h>
28243b6edd16SPeter Maydell
28253b6edd16SPeter Maydellint main(void)
28263b6edd16SPeter Maydell{
282719e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
282819e83f6bSPeter Maydell     * a function being called. This is necessary so that on
282919e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
283019e83f6bSPeter Maydell     * the library but not declared in the header file we will
283119e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
283219e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
283319e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
283419e83f6bSPeter Maydell     */
2835c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
28363b6edd16SPeter Maydell}
28373b6edd16SPeter MaydellEOF
28388fb03151SPeter Maydellif compile_prog "" "" ; then
28393b6edd16SPeter Maydell  epoll_create1=yes
28403b6edd16SPeter Maydellfi
28413b6edd16SPeter Maydell
28423b6edd16SPeter Maydellepoll_pwait=no
28433b6edd16SPeter Maydellcat > $TMPC << EOF
28443b6edd16SPeter Maydell#include <sys/epoll.h>
28453b6edd16SPeter Maydell
28463b6edd16SPeter Maydellint main(void)
28473b6edd16SPeter Maydell{
28483b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
28493b6edd16SPeter Maydell    return 0;
28503b6edd16SPeter Maydell}
28513b6edd16SPeter MaydellEOF
28528fb03151SPeter Maydellif compile_prog "" "" ; then
28533b6edd16SPeter Maydell  epoll_pwait=yes
28543b6edd16SPeter Maydellfi
28553b6edd16SPeter Maydell
2856a8fd1abaSPeter Maydell# check for sendfile support
2857a8fd1abaSPeter Maydellsendfile=no
2858a8fd1abaSPeter Maydellcat > $TMPC << EOF
2859a8fd1abaSPeter Maydell#include <sys/sendfile.h>
2860a8fd1abaSPeter Maydell
2861a8fd1abaSPeter Maydellint main(void)
2862a8fd1abaSPeter Maydell{
2863a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
2864a8fd1abaSPeter Maydell}
2865a8fd1abaSPeter MaydellEOF
2866a8fd1abaSPeter Maydellif compile_prog "" "" ; then
2867a8fd1abaSPeter Maydell  sendfile=yes
2868a8fd1abaSPeter Maydellfi
2869a8fd1abaSPeter Maydell
2870cc8ae6deSpbrook# Check if tools are available to build documentation.
2871a25dba17SJuan Quintelaif test "$docs" != "no" ; then
287201668d98SStefan Weil  if has makeinfo && has pod2man; then
2873a25dba17SJuan Quintela    docs=yes
287483a3ab8bSJuan Quintela  else
2875a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2876a25dba17SJuan Quintela      feature_not_found "docs"
287783a3ab8bSJuan Quintela    fi
2878a25dba17SJuan Quintela    docs=no
287983a3ab8bSJuan Quintela  fi
2880cc8ae6deSpbrookfi
2881cc8ae6deSpbrook
2882f514f41cSStefan Weil# Search for bswap_32 function
28836ae9a1f4SJuan Quintelabyteswap_h=no
28846ae9a1f4SJuan Quintelacat > $TMPC << EOF
28856ae9a1f4SJuan Quintela#include <byteswap.h>
28866ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
28876ae9a1f4SJuan QuintelaEOF
288852166aa0SJuan Quintelaif compile_prog "" "" ; then
28896ae9a1f4SJuan Quintela  byteswap_h=yes
28906ae9a1f4SJuan Quintelafi
28916ae9a1f4SJuan Quintela
289275f13596SStefan Weil# Search for bswap32 function
28936ae9a1f4SJuan Quintelabswap_h=no
28946ae9a1f4SJuan Quintelacat > $TMPC << EOF
28956ae9a1f4SJuan Quintela#include <sys/endian.h>
28966ae9a1f4SJuan Quintela#include <sys/types.h>
28976ae9a1f4SJuan Quintela#include <machine/bswap.h>
28986ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
28996ae9a1f4SJuan QuintelaEOF
290052166aa0SJuan Quintelaif compile_prog "" "" ; then
29016ae9a1f4SJuan Quintela  bswap_h=yes
29026ae9a1f4SJuan Quintelafi
29036ae9a1f4SJuan Quintela
2904da93a1fdSaliguori##########################################
2905c589b249SRonnie Sahlberg# Do we have libiscsi
2906fa6acb0cSRonnie Sahlberg# We check for iscsi_unmap_sync() to make sure we have a
2907fa6acb0cSRonnie Sahlberg# recent enough version of libiscsi.
2908c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2909c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2910fa6acb0cSRonnie Sahlberg#include <stdio.h>
2911c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2912fa6acb0cSRonnie Sahlbergint main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2913c589b249SRonnie SahlbergEOF
29143c33ea96SPaolo Bonzini  if $pkg_config --atleast-version=1.7.0 libiscsi --modversion >/dev/null 2>&1; then
29153c33ea96SPaolo Bonzini    libiscsi="yes"
29163c33ea96SPaolo Bonzini    libiscsi_cflags=$($pkg_config --cflags libiscsi 2>/dev/null)
29173c33ea96SPaolo Bonzini    libiscsi_libs=$($pkg_config --libs libiscsi 2>/dev/null)
29183c33ea96SPaolo Bonzini    CFLAGS="$CFLAGS $libiscsi_cflags"
29193c33ea96SPaolo Bonzini    LIBS="$LIBS $libiscsi_libs"
29203c33ea96SPaolo Bonzini  elif compile_prog "" "-liscsi" ; then
2921c589b249SRonnie Sahlberg    libiscsi="yes"
2922c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2923c589b249SRonnie Sahlberg  else
2924c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2925c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2926c589b249SRonnie Sahlberg    fi
2927c589b249SRonnie Sahlberg    libiscsi="no"
2928c589b249SRonnie Sahlberg  fi
2929c589b249SRonnie Sahlbergfi
2930c589b249SRonnie Sahlberg
2931c589b249SRonnie Sahlberg
2932c589b249SRonnie Sahlberg##########################################
29338bacde8dSNatanael Copa# Do we need libm
29348bacde8dSNatanael Copacat > $TMPC << EOF
29358bacde8dSNatanael Copa#include <math.h>
29368bacde8dSNatanael Copaint main(void) { return isnan(sin(0.0)); }
29378bacde8dSNatanael CopaEOF
29388bacde8dSNatanael Copaif compile_prog "" "" ; then
29398bacde8dSNatanael Copa  :
29408bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
29418bacde8dSNatanael Copa  LIBS="-lm $LIBS"
29428bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
29438bacde8dSNatanael Copaelse
294476ad07a4SPeter Maydell  error_exit "libm check failed"
29458bacde8dSNatanael Copafi
29468bacde8dSNatanael Copa
29478bacde8dSNatanael Copa##########################################
2948da93a1fdSaliguori# Do we need librt
29498bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
29508bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
29518bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
29528bacde8dSNatanael Copa# function in addition.
2953da93a1fdSaliguoricat > $TMPC <<EOF
2954da93a1fdSaliguori#include <signal.h>
2955da93a1fdSaliguori#include <time.h>
29568bacde8dSNatanael Copaint main(void) {
29578bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
29588bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
29598bacde8dSNatanael Copa}
2960da93a1fdSaliguoriEOF
2961da93a1fdSaliguori
296252166aa0SJuan Quintelaif compile_prog "" "" ; then
296307ffa4bdSJuan Quintela  :
29648bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
29658bacde8dSNatanael Copaelif compile_prog "" "-lrt $pthread_lib" ; then
296607ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
29678bacde8dSNatanael Copa  libs_qga="-lrt $libs_qga"
2968da93a1fdSaliguorifi
2969da93a1fdSaliguori
297031ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2971179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
29726362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
29736362a53fSJuan Quintelafi
29746362a53fSJuan Quintela
2975de5071c5SBlue Swirl##########################################
2976cd4ec0b4SGerd Hoffmann# spice probe
2977cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2978cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2979cd4ec0b4SGerd Hoffmann#include <spice.h>
2980cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2981cd4ec0b4SGerd HoffmannEOF
2982710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2983710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
298467be6726SGerd Hoffmann  if $pkg_config --atleast-version=0.12.0 spice-server >/dev/null 2>&1 && \
2985358689feSMichal Privoznik     $pkg_config --atleast-version=0.12.3 spice-protocol > /dev/null 2>&1 && \
2986cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2987cd4ec0b4SGerd Hoffmann    spice="yes"
2988cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2989cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
29902e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
29912e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
2992cd4ec0b4SGerd Hoffmann  else
2993cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2994cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2995cd4ec0b4SGerd Hoffmann    fi
2996cd4ec0b4SGerd Hoffmann    spice="no"
2997cd4ec0b4SGerd Hoffmann  fi
2998cd4ec0b4SGerd Hoffmannfi
2999cd4ec0b4SGerd Hoffmann
3000111a38b0SRobert Relyea# check for libcacard for smartcard support
3001111a38b0SRobert Relyeasmartcard_cflags=""
3002111a38b0SRobert Relyea# TODO - what's the minimal nss version we support?
3003111a38b0SRobert Relyeaif test "$smartcard_nss" != "no"; then
30045f01e06fSSergei Trofimovich  cat > $TMPC << EOF
30055f01e06fSSergei Trofimovich#include <pk11pub.h>
30065f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
30075f01e06fSSergei TrofimovichEOF
30080b22ef0fSPeter Maydell    smartcard_includes="-I\$(SRC_PATH)/libcacard"
30098c741c22SAlon Levy    libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
30108c741c22SAlon Levy    libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
30116ca026cbSPeter Maydell    test_cflags="$libcacard_cflags"
30126ca026cbSPeter Maydell    # The header files in nss < 3.13.3 have a bug which causes them to
30136ca026cbSPeter Maydell    # emit a warning. If we're going to compile QEMU with -Werror, then
30146ca026cbSPeter Maydell    # test that the headers don't have this bug. Otherwise we would pass
30156ca026cbSPeter Maydell    # the configure test but fail to compile QEMU later.
30166ca026cbSPeter Maydell    if test "$werror" = "yes"; then
30176ca026cbSPeter Maydell        test_cflags="-Werror $test_cflags"
30186ca026cbSPeter Maydell    fi
3019b6fc675bSPaolo Bonzini    if test -n "$libtool" &&
3020b6fc675bSPaolo Bonzini            $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
30216ca026cbSPeter Maydell      compile_prog "$test_cflags" "$libcacard_libs"; then
30225f01e06fSSergei Trofimovich        smartcard_nss="yes"
30230b22ef0fSPeter Maydell        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
30240b22ef0fSPeter Maydell        QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
3025ad4cf3f6SPaul Brook        libs_softmmu="$libcacard_libs $libs_softmmu"
3026111a38b0SRobert Relyea    else
3027111a38b0SRobert Relyea        if test "$smartcard_nss" = "yes"; then
3028111a38b0SRobert Relyea            feature_not_found "nss"
3029111a38b0SRobert Relyea        fi
3030111a38b0SRobert Relyea        smartcard_nss="no"
3031111a38b0SRobert Relyea    fi
3032111a38b0SRobert Relyeafi
3033111a38b0SRobert Relyea
30342b2325ffSGerd Hoffmann# check for libusb
30352b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
30363f5cc97eSGerd Hoffmann    if $pkg_config --atleast-version=1.0.13 libusb-1.0 >/dev/null 2>&1 ; then
30372b2325ffSGerd Hoffmann        libusb="yes"
30382b2325ffSGerd Hoffmann	usb="libusb"
30392b2325ffSGerd Hoffmann        libusb_cflags=$($pkg_config --cflags libusb-1.0 2>/dev/null)
30402b2325ffSGerd Hoffmann        libusb_libs=$($pkg_config --libs libusb-1.0 2>/dev/null)
30412b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
30422b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
30432b2325ffSGerd Hoffmann    else
30442b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
30452b2325ffSGerd Hoffmann            feature_not_found "libusb"
30462b2325ffSGerd Hoffmann        fi
30472b2325ffSGerd Hoffmann        libusb="no"
30482b2325ffSGerd Hoffmann    fi
30492b2325ffSGerd Hoffmannfi
30502b2325ffSGerd Hoffmann
305169354a83SHans de Goede# check for usbredirparser for usb network redirection support
305269354a83SHans de Goedeif test "$usb_redir" != "no" ; then
3053b2d1fe67SHans de Goede    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5 >/dev/null 2>&1 ; then
305469354a83SHans de Goede        usb_redir="yes"
30558b626aa7SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5 2>/dev/null)
30568b626aa7SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5 2>/dev/null)
305769354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
305856ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
305969354a83SHans de Goede    else
306069354a83SHans de Goede        if test "$usb_redir" = "yes"; then
306169354a83SHans de Goede            feature_not_found "usb-redir"
306269354a83SHans de Goede        fi
306369354a83SHans de Goede        usb_redir="no"
306469354a83SHans de Goede    fi
306569354a83SHans de Goedefi
306669354a83SHans de Goede
3067cd4ec0b4SGerd Hoffmann##########################################
3068cd4ec0b4SGerd Hoffmann
3069747bbdf7SBlue Swirl##########################################
30705f6b9e8fSBlue Swirl# check if we have fdatasync
30715f6b9e8fSBlue Swirl
30725f6b9e8fSBlue Swirlfdatasync=no
30735f6b9e8fSBlue Swirlcat > $TMPC << EOF
30745f6b9e8fSBlue Swirl#include <unistd.h>
3075d1722a27SAlexandre Raymondint main(void) {
3076d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
3077d1722a27SAlexandre Raymondreturn fdatasync(0);
3078d1722a27SAlexandre Raymond#else
3079e172fe11SStefan Weil#error Not supported
3080d1722a27SAlexandre Raymond#endif
3081d1722a27SAlexandre Raymond}
30825f6b9e8fSBlue SwirlEOF
30835f6b9e8fSBlue Swirlif compile_prog "" "" ; then
30845f6b9e8fSBlue Swirl    fdatasync=yes
30855f6b9e8fSBlue Swirlfi
30865f6b9e8fSBlue Swirl
308794a420b1SStefan Hajnoczi##########################################
3088e78815a5SAndreas Färber# check if we have madvise
3089e78815a5SAndreas Färber
3090e78815a5SAndreas Färbermadvise=no
3091e78815a5SAndreas Färbercat > $TMPC << EOF
3092e78815a5SAndreas Färber#include <sys/types.h>
3093e78815a5SAndreas Färber#include <sys/mman.h>
3094832ce9c2SScott Wood#include <stddef.h>
3095e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
3096e78815a5SAndreas FärberEOF
3097e78815a5SAndreas Färberif compile_prog "" "" ; then
3098e78815a5SAndreas Färber    madvise=yes
3099e78815a5SAndreas Färberfi
3100e78815a5SAndreas Färber
3101e78815a5SAndreas Färber##########################################
3102e78815a5SAndreas Färber# check if we have posix_madvise
3103e78815a5SAndreas Färber
3104e78815a5SAndreas Färberposix_madvise=no
3105e78815a5SAndreas Färbercat > $TMPC << EOF
3106e78815a5SAndreas Färber#include <sys/mman.h>
3107832ce9c2SScott Wood#include <stddef.h>
3108e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
3109e78815a5SAndreas FärberEOF
3110e78815a5SAndreas Färberif compile_prog "" "" ; then
3111e78815a5SAndreas Färber    posix_madvise=yes
3112e78815a5SAndreas Färberfi
3113e78815a5SAndreas Färber
3114e78815a5SAndreas Färber##########################################
31151e9737daSRichard Henderson# check if we have usable SIGEV_THREAD_ID
31161e9737daSRichard Henderson
31171e9737daSRichard Hendersonsigev_thread_id=no
31181e9737daSRichard Hendersoncat > $TMPC << EOF
31191e9737daSRichard Henderson#include <signal.h>
31201e9737daSRichard Hendersonint main(void) {
31211e9737daSRichard Henderson  struct sigevent ev;
31221e9737daSRichard Henderson  ev.sigev_notify = SIGEV_THREAD_ID;
31231e9737daSRichard Henderson  ev._sigev_un._tid = 0;
31241e9737daSRichard Henderson  asm volatile("" : : "g"(&ev));
31251e9737daSRichard Henderson  return 0;
31261e9737daSRichard Henderson}
31271e9737daSRichard HendersonEOF
31281e9737daSRichard Hendersonif compile_prog "" "" ; then
31291e9737daSRichard Henderson    sigev_thread_id=yes
31301e9737daSRichard Hendersonfi
31311e9737daSRichard Henderson
31321e9737daSRichard Henderson##########################################
313394a420b1SStefan Hajnoczi# check if trace backend exists
313494a420b1SStefan Hajnoczi
3135650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
313694a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
313776ad07a4SPeter Maydell  error_exit "invalid trace backend" \
313876ad07a4SPeter Maydell      "Please choose a supported trace backend."
313994a420b1SStefan Hajnoczifi
314094a420b1SStefan Hajnoczi
31417e24e92aSStefan Hajnoczi##########################################
31427e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
31437e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
31447e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
31457e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
31467e24e92aSStefan Hajnoczi#include <ust/marker.h>
31477e24e92aSStefan Hajnocziint main(void) { return 0; }
31487e24e92aSStefan HajnocziEOF
31497e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
315094b4fefaSLluís Vilanova    LIBS="-lust -lurcu-bp $LIBS"
3151c9a2e37cSLluís Vilanova    libs_qga="-lust -lurcu-bp $libs_qga"
31527e24e92aSStefan Hajnoczi  else
315376ad07a4SPeter Maydell    error_exit "Trace backend 'ust' missing libust header files"
31547e24e92aSStefan Hajnoczi  fi
31557e24e92aSStefan Hajnoczifi
3156b3d08c02SDaniel P. Berrange
3157b3d08c02SDaniel P. Berrange##########################################
3158b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
3159b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
3160b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
316176ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
3162b3d08c02SDaniel P. Berrange  fi
3163c276b17dSDaniel P. Berrange  trace_backend_stap="no"
3164c276b17dSDaniel P. Berrange  if has 'stap' ; then
3165c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
3166c276b17dSDaniel P. Berrange  fi
3167b3d08c02SDaniel P. Berrangefi
3168b3d08c02SDaniel P. Berrange
31697e24e92aSStefan Hajnoczi##########################################
3170519175a2SAlex Barcelo# check and set a backend for coroutine
3171d0e2fce5SAneesh Kumar K.V
31727c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
31737c2acc70SPeter Maydell# is sigcontext. gthread is not selectable except explicitly, because
31747c2acc70SPeter Maydell# it is not functional enough to run QEMU proper. (It is occasionally
31757c2acc70SPeter Maydell# useful for debugging purposes.)  On Windows the only valid backend
31767c2acc70SPeter Maydell# is the Windows-specific one.
31777c2acc70SPeter Maydell
31787c2acc70SPeter Maydellucontext_works=no
3179d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3180d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3181d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3182cdf84806SPeter Maydell#ifdef __stub_makecontext
3183cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3184cdf84806SPeter Maydell#endif
318575cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3186d0e2fce5SAneesh Kumar K.VEOF
3187d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
31887c2acc70SPeter Maydell    ucontext_works=yes
3189d0e2fce5SAneesh Kumar K.V  fi
3190519175a2SAlex Barcelofi
31917c2acc70SPeter Maydell
31927c2acc70SPeter Maydellif test "$coroutine" = ""; then
31937c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
31947c2acc70SPeter Maydell    coroutine=win32
31957c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
31967c2acc70SPeter Maydell    coroutine=ucontext
3197519175a2SAlex Barcelo  else
31987c2acc70SPeter Maydell    coroutine=sigaltstack
31997c2acc70SPeter Maydell  fi
32007c2acc70SPeter Maydellelse
32017c2acc70SPeter Maydell  case $coroutine in
32027c2acc70SPeter Maydell  windows)
32037c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
32047c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
32057c2acc70SPeter Maydell    fi
32067c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
32077c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
32087c2acc70SPeter Maydell    coroutine=win32
32097c2acc70SPeter Maydell    ;;
32107c2acc70SPeter Maydell  ucontext)
32117c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
32127c2acc70SPeter Maydell      feature_not_found "ucontext"
32137c2acc70SPeter Maydell    fi
32147c2acc70SPeter Maydell    ;;
32157c2acc70SPeter Maydell  gthread|sigaltstack)
32167c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
32177c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
32187c2acc70SPeter Maydell    fi
32197c2acc70SPeter Maydell    ;;
32207c2acc70SPeter Maydell  *)
322176ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
32227c2acc70SPeter Maydell    ;;
32237c2acc70SPeter Maydell  esac
3224d0e2fce5SAneesh Kumar K.Vfi
3225d0e2fce5SAneesh Kumar K.V
3226d0e2fce5SAneesh Kumar K.V##########################################
3227d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
3228d2042378SAneesh Kumar K.V
32294e1797f9SStefan Weilopen_by_handle_at=no
3230d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
3231d2042378SAneesh Kumar K.V#include <fcntl.h>
3232acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
3233acc55ba8SStefan Weil# error missing definition
3234acc55ba8SStefan Weil#else
323575cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3236acc55ba8SStefan Weil#endif
3237d2042378SAneesh Kumar K.VEOF
3238d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
3239d2042378SAneesh Kumar K.V    open_by_handle_at=yes
3240d2042378SAneesh Kumar K.Vfi
3241d2042378SAneesh Kumar K.V
3242e06a765eSHarsh Prateek Bora########################################
3243e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
3244e06a765eSHarsh Prateek Bora
3245e06a765eSHarsh Prateek Boralinux_magic_h=no
3246e06a765eSHarsh Prateek Boracat > $TMPC << EOF
3247e06a765eSHarsh Prateek Bora#include <linux/magic.h>
3248e06a765eSHarsh Prateek Boraint main(void) {
324975cafad7SStefan Weil  return 0;
3250e06a765eSHarsh Prateek Bora}
3251e06a765eSHarsh Prateek BoraEOF
3252e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
3253e06a765eSHarsh Prateek Bora    linux_magic_h=yes
3254e06a765eSHarsh Prateek Borafi
3255e06a765eSHarsh Prateek Bora
32568ab1bf12SLuiz Capitulino########################################
3257c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
3258c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
3259c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
3260c95e3080SKevin Wolf# only a warning.
3261c95e3080SKevin Wolf#
3262c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
3263c95e3080SKevin Wolf# the build doesn't fail anyway.
3264c95e3080SKevin Wolf
326506d71fa1SPeter Maydellpragma_disable_unused_but_set=no
326606d71fa1SPeter Maydellcat > $TMPC << EOF
3267e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
326806d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3269c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
3270e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
3271c95e3080SKevin Wolf
327206d71fa1SPeter Maydellint main(void) {
327306d71fa1SPeter Maydell    return 0;
327406d71fa1SPeter Maydell}
327506d71fa1SPeter MaydellEOF
327606d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
3277cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
3278c95e3080SKevin Wolfelse
3279c95e3080SKevin Wolf    werror=no
328006d71fa1SPeter Maydellfi
328106d71fa1SPeter Maydell
328206d71fa1SPeter Maydell########################################
328362fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
32843f4349dcSKevin Wolf
32853f4349dcSKevin Wolfvalgrind_h=no
32863f4349dcSKevin Wolfcat > $TMPC << EOF
32873f4349dcSKevin Wolf#include <valgrind/valgrind.h>
328862fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
32893f4349dcSKevin Wolfint main(void) {
32903f4349dcSKevin Wolf  return 0;
32913f4349dcSKevin Wolf}
32923f4349dcSKevin WolfEOF
32933f4349dcSKevin Wolfif compile_prog "" "" ; then
32943f4349dcSKevin Wolf    valgrind_h=yes
32953f4349dcSKevin Wolffi
32963f4349dcSKevin Wolf
32973f4349dcSKevin Wolf########################################
32988ab1bf12SLuiz Capitulino# check if environ is declared
32998ab1bf12SLuiz Capitulino
33008ab1bf12SLuiz Capitulinohas_environ=no
33018ab1bf12SLuiz Capitulinocat > $TMPC << EOF
33028ab1bf12SLuiz Capitulino#include <unistd.h>
33038ab1bf12SLuiz Capitulinoint main(void) {
3304c075a723SBlue Swirl    environ = 0;
33058ab1bf12SLuiz Capitulino    return 0;
33068ab1bf12SLuiz Capitulino}
33078ab1bf12SLuiz CapitulinoEOF
33088ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
33098ab1bf12SLuiz Capitulino    has_environ=yes
33108ab1bf12SLuiz Capitulinofi
33118ab1bf12SLuiz Capitulino
331276a347e1SRichard Henderson########################################
331376a347e1SRichard Henderson# check if cpuid.h is usable.
331476a347e1SRichard Henderson
331576a347e1SRichard Hendersoncpuid_h=no
331676a347e1SRichard Hendersoncat > $TMPC << EOF
331776a347e1SRichard Henderson#include <cpuid.h>
331876a347e1SRichard Hendersonint main(void) {
331976a347e1SRichard Henderson  return 0;
332076a347e1SRichard Henderson}
332176a347e1SRichard HendersonEOF
332276a347e1SRichard Hendersonif compile_prog "" "" ; then
332376a347e1SRichard Henderson    cpuid_h=yes
332476a347e1SRichard Hendersonfi
332576a347e1SRichard Henderson
3326f540166bSRichard Henderson########################################
3327f540166bSRichard Henderson# check if __[u]int128_t is usable.
3328f540166bSRichard Henderson
3329f540166bSRichard Hendersonint128=no
3330f540166bSRichard Hendersoncat > $TMPC << EOF
3331f540166bSRichard Henderson__int128_t a;
3332f540166bSRichard Henderson__uint128_t b;
3333f540166bSRichard Hendersonint main (void) {
3334f540166bSRichard Henderson  a = a + b;
3335f540166bSRichard Henderson  b = a * b;
3336464e3671SPeter Maydell  a = a * a;
3337f540166bSRichard Henderson  return 0;
3338f540166bSRichard Henderson}
3339f540166bSRichard HendersonEOF
3340f540166bSRichard Hendersonif compile_prog "" "" ; then
3341f540166bSRichard Henderson    int128=yes
3342f540166bSRichard Hendersonfi
334376a347e1SRichard Henderson
33441e6e9acaSRichard Henderson########################################
33451e6e9acaSRichard Henderson# check if getauxval is available.
33461e6e9acaSRichard Henderson
33471e6e9acaSRichard Hendersongetauxval=no
33481e6e9acaSRichard Hendersoncat > $TMPC << EOF
33491e6e9acaSRichard Henderson#include <sys/auxv.h>
33501e6e9acaSRichard Hendersonint main(void) {
33511e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
33521e6e9acaSRichard Henderson}
33531e6e9acaSRichard HendersonEOF
33541e6e9acaSRichard Hendersonif compile_prog "" "" ; then
33551e6e9acaSRichard Henderson    getauxval=yes
33561e6e9acaSRichard Hendersonfi
33571e6e9acaSRichard Henderson
3358d2042378SAneesh Kumar K.V##########################################
3359e86ecd4bSJuan Quintela# End of CC checks
3360e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3361e86ecd4bSJuan Quintela
33621d728c39SBlue Swirlif test "$gcov" = "yes" ; then
33631d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
33641d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
33651d728c39SBlue Swirlelif test "$debug" = "no" ; then
33668be74dc0SAvi Kivity  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3367e86ecd4bSJuan Quintelafi
3368a316e378SJuan Quintela
33691d728c39SBlue Swirl
337020ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
337120ff6c80SAnthony Liguori# enable/disable
337220ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
337320ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
337420ff6c80SAnthony Liguori	zero_malloc="no"
337520ff6c80SAnthony Liguori    else
337620ff6c80SAnthony Liguori	zero_malloc="yes"
337720ff6c80SAnthony Liguori    fi
337820ff6c80SAnthony Liguorifi
337920ff6c80SAnthony Liguori
33806ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
33816ca026cbSPeter Maydellif test "$werror" = "yes"; then
33826ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
33836ca026cbSPeter Maydellfi
33846ca026cbSPeter Maydell
3385e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3386e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
33871156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3388e86ecd4bSJuan Quintela    fi
3389e86ecd4bSJuan Quintelafi
3390e86ecd4bSJuan Quintela
339194dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
339294dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
339394dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
339494dd53c5SGerd Hoffmannelse
339594dd53c5SGerd Hoffmann    POD2MAN="pod2man"
339694dd53c5SGerd Hoffmannfi
339794dd53c5SGerd Hoffmann
3398952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3399952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3400952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3401952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3402952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3403952afb71SBlue Swirl        fi
3404952afb71SBlue Swirl    done
3405952afb71SBlue Swirlfi
3406952afb71SBlue Swirl
340710ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3408528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
3409834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
34105a67135aSbellard
34114b1c11fdSDaniel P. Berrangetools=""
34124b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3413ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
34144b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
34154b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
34164b1c11fdSDaniel P. Berrange  fi
34174b1c11fdSDaniel P. Berrangefi
34184b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3419983eef5aSMeador Inge  if test "$virtfs" != no ; then
3420be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3421983eef5aSMeador Inge      virtfs=yes
342217bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3423983eef5aSMeador Inge    else
3424983eef5aSMeador Inge      if test "$virtfs" = yes; then
342576ad07a4SPeter Maydell        error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3426983eef5aSMeador Inge      fi
342717500370SAndreas Färber      virtfs=no
3428983eef5aSMeador Inge    fi
342917bff52bSM. Mohan Kumar  fi
3430ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3431d138cee9SMichael Roth    if [ "$guest_agent" = "yes" ]; then
343248ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
3433d138cee9SMichael Roth    fi
3434ca35f780SPaolo Bonzini  fi
34354b1c11fdSDaniel P. Berrangefi
3436ca35f780SPaolo Bonzini
3437ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3438ca35f780SPaolo Bonziniroms=
3439ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3440ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3441ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3442ca35f780SPaolo Bonzini  roms="optionrom"
3443ca35f780SPaolo Bonzinifi
3444d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
344539ac8455SDavid Gibson  roms="$roms spapr-rtas"
344639ac8455SDavid Gibsonfi
3447ca35f780SPaolo Bonzini
34489933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
34499933c305SChristian Borntraeger  roms="$roms s390-ccw"
34509933c305SChristian Borntraegerfi
34519933c305SChristian Borntraeger
3452964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
3453964c6fa1SRichard Hendersonif test "$pie" = "no" ; then
3454964c6fa1SRichard Henderson  textseg_addr=
3455964c6fa1SRichard Henderson  case "$cpu" in
3456964c6fa1SRichard Henderson    arm | hppa | i386 | m68k | ppc | ppc64 | s390* | sparc | sparc64 | x86_64)
3457964c6fa1SRichard Henderson      textseg_addr=0x60000000
3458964c6fa1SRichard Henderson      ;;
3459964c6fa1SRichard Henderson    mips)
3460964c6fa1SRichard Henderson      textseg_addr=0x400000
3461964c6fa1SRichard Henderson      ;;
3462964c6fa1SRichard Henderson  esac
3463964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
3464964c6fa1SRichard Henderson    cat > $TMPC <<EOF
3465964c6fa1SRichard Henderson    int main(void) { return 0; }
3466964c6fa1SRichard HendersonEOF
3467964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
3468964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
3469964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
3470964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
3471964c6fa1SRichard Henderson      # at least.
3472964c6fa1SRichard Henderson      $ld --verbose | sed \
3473964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
3474964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
3475964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
3476964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
3477964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
3478964c6fa1SRichard Henderson    fi
3479964c6fa1SRichard Henderson  fi
3480964c6fa1SRichard Hendersonfi
3481964c6fa1SRichard Henderson
34825ca9388aSGerd Hoffmann# add pixman flags after all config tests are done
3483a540f158SPeter CrosthwaiteQEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags"
34845ca9388aSGerd Hoffmannlibs_softmmu="$libs_softmmu $pixman_libs"
34855ca9388aSGerd Hoffmann
34867d13299dSbellardecho "Install prefix    $prefix"
3487c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3488f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
34893aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
34908bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
34910f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
34921c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
349311d9f695Sbellardif test "$mingw32" = "no" ; then
34945a699bbbSLaszlo Ersekecho "local state directory   `eval echo $local_statedir`"
3495f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
349643ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
34975a699bbbSLaszlo Ersekelse
34985a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
349911d9f695Sbellardfi
35005a67135aSbellardecho "Source path       $source_path"
35017d13299dSbellardecho "C compiler        $cc"
350283469015Sbellardecho "Host C compiler   $host_cc"
35033c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
35040c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3505a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
35060c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
35077d13299dSbellardecho "make              $make"
35086a882643Spbrookecho "install           $install"
3509c886edfbSBlue Swirlecho "python            $python"
3510e2d8830eSBradif test "$slirp" = "yes" ; then
3511e2d8830eSBrad    echo "smbd              $smbd"
3512e2d8830eSBradfi
3513a98fd896Sbellardecho "host CPU          $cpu"
3514de83cd02Sbellardecho "host big endian   $bigendian"
351597a847bcSbellardecho "target list       $target_list"
3516ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
35177d13299dSbellardecho "gprof enabled     $gprof"
351803b4fe7dSaliguoriecho "sparse enabled    $sparse"
35191625af87Saliguoriecho "strip binaries    $strip_opt"
352005c2a3e7Sbellardecho "profiler          $profiler"
352143ce4dfeSbellardecho "static build      $static"
352285aa5189Sbellardecho "-Werror enabled   $werror"
35235b0753e0Sbellardif test "$darwin" = "yes" ; then
35245b0753e0Sbellard    echo "Cocoa support     $cocoa"
35255b0753e0Sbellardfi
3526e2134eb9SGerd Hoffmannecho "pixman            $pixman"
352797a847bcSbellardecho "SDL support       $sdl"
3528a4ccabcfSAnthony Liguoriecho "GTK support       $gtk"
35294d3b6f6eSbalrogecho "curses support    $curses"
3530769ce76dSAlexander Grafecho "curl support      $curl"
353167b915a5Sbellardecho "mingw32 support   $mingw32"
35320c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
3533b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
3534b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
35358ff9cbf7Smalcecho "Mixer emulation   $mixemu"
3536983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3537821601eaSJes Sorensenecho "VNC support       $vnc"
3538821601eaSJes Sorensenif test "$vnc" = "yes" ; then
35398d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
35402f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
35412f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3542efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
35437536ee4bSTim Hardeck    echo "VNC WS support    $vnc_ws"
3544821601eaSJes Sorensenfi
35453142255cSblueswir1if test -n "$sparc_cpu"; then
35463142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
35473142255cSblueswir1fi
3548e37630caSaliguoriecho "xen support       $xen"
35492e4d9fb1Saurel32echo "brlapi support    $brlapi"
3550a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3551a25dba17SJuan Quintelaecho "Documentation     $docs"
3552c5937220Spbrook[ ! -z "$uname_release" ] && \
3553c5937220Spbrookecho "uname -r          $uname_release"
3554bd0c5661Spbrookecho "NPTL support      $nptl"
3555379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
355640d6444eSAvi Kivityecho "PIE               $pie"
35578a16d273Sthsecho "vde support       $vde"
35585c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3559758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
356077755340Sthsecho "Install blobs     $blobs"
3561b31a0277SJuan Quintelaecho "KVM support       $kvm"
35629195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3563f652e6afSaurel32echo "fdt support       $fdt"
3564ceb42de8Saliguoriecho "preadv support    $preadv"
35655f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3566e78815a5SAndreas Färberecho "madvise           $madvise"
3567e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
35681e9737daSRichard Hendersonecho "sigev_thread_id   $sigev_thread_id"
3569ee682d27SStefan Weilecho "uuid support      $uuid"
357047e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3571d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
35725e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
357394a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
35749410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
35752e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3576f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3577dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3578111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
35792b2325ffSGerd Hoffmannecho "libusb            $libusb"
358069354a83SHans de Goedeecho "usb net redir     $usb_redir"
3581b1e5fff4SMichael Walleecho "GLX support       $glx"
3582c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3583d138cee9SMichael Rothecho "build guest agent $guest_agent"
3584f794573eSEduardo Otuboecho "seccomp support   $seccomp"
35857c2acc70SPeter Maydellecho "coroutine backend $coroutine"
3586eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
3587583f6e7bSStefan Hajnocziecho "virtio-blk-data-plane $virtio_blk_data_plane"
35881d728c39SBlue Swirlecho "gcov              $gcov_tool"
35891d728c39SBlue Swirlecho "gcov enabled      $gcov"
3590ab214c29SStefan Bergerecho "TPM support       $tpm"
35910a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
35923b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
35933556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
359467b915a5Sbellard
35951ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
359624b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3597e8cd23deSbellardfi
359897a847bcSbellard
359998ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
360097a847bcSbellard
3601dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
3602dbd99ae3SStefan Weil
360398ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
360498ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
360598ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
360698ec69acSJuan Quintelaecho >> $config_host_mak
360798ec69acSJuan Quintela
3608e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
360999d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
361099d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
36113aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
36128bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
36130f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
361499d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
361599d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
361622d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
36179afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
36189afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
36195a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
3620785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
36215a699bbbSLaszlo Ersekfi
3622f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
3623f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
3624f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
3625834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
3626f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
3627804edf29SJuan Quintela
362898ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3629727e5283SPaolo Bonzini
3630727e5283SPaolo Bonzinicase "$cpu" in
3631df5e0ef7SRichard Henderson  arm|i386|x86_64|ppc)
3632727e5283SPaolo Bonzini    # The TCG interpreter currently does not support ld/st optimization.
3633727e5283SPaolo Bonzini    if test "$tcg_interpreter" = "no" ; then
3634727e5283SPaolo Bonzini        echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_host_mak
3635727e5283SPaolo Bonzini    fi
3636727e5283SPaolo Bonzini  ;;
3637727e5283SPaolo Bonziniesac
3638f8393946Saurel32if test "$debug_tcg" = "yes" ; then
36392358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3640f8393946Saurel32fi
36411625af87Saliguoriif test "$strip_opt" = "yes" ; then
364252ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
36431625af87Saliguorifi
36447d13299dSbellardif test "$bigendian" = "yes" ; then
3645e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
364697a847bcSbellardfi
364767b915a5Sbellardif test "$mingw32" = "yes" ; then
364898ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
36499fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
36509fe6de94SBlue Swirl  version_major=${rc_version%%.*}
36519fe6de94SBlue Swirl  rc_version=${rc_version#*.}
36529fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
36539fe6de94SBlue Swirl  rc_version=${rc_version#*.}
36549fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
36559fe6de94SBlue Swirl  version_micro=0
36569fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
36579fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3658210fa556Spbrookelse
365935f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3660210fa556Spbrookfi
3661128ab2ffSblueswir1
3662dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3663dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3664dffcb71cSMark McLoughlinfi
3665dffcb71cSMark McLoughlin
366683fb7adfSbellardif test "$darwin" = "yes" ; then
366798ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
366883fb7adfSbellardfi
3669b29fe3edSmalc
3670b29fe3edSmalcif test "$aix" = "yes" ; then
367198ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
3672b29fe3edSmalcfi
3673b29fe3edSmalc
3674ec530c81Sbellardif test "$solaris" = "yes" ; then
367598ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
36762358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
36770475a5caSths  if test "$needs_libsunmath" = "yes" ; then
367875b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
36790475a5caSths  fi
3680ec530c81Sbellardfi
3681179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3682179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3683179cf400SAndreas Färberfi
368497a847bcSbellardif test "$static" = "yes" ; then
368598ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
368697a847bcSbellardfi
36871ba16968SStefan Weilif test "$profiler" = "yes" ; then
36882358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
368905c2a3e7Sbellardfi
3690c20709aaSbellardif test "$slirp" = "yes" ; then
369198ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
3692e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3693c20709aaSbellardfi
36948a16d273Sthsif test "$vde" = "yes" ; then
369598ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
36968a16d273Sthsfi
369747e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
369847e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
369947e98658SCorey Bryantfi
37002358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
37010c58ac1cSmalcfor drv in $audio_drv_list; do
3702bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
370398ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
3704923e4521Smalc    if test "$drv" = "fmod"; then
37057aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3706fb065187Sbellard    fi
37070c58ac1cSmalcdone
370867f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
370967f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
371067f86e8eSJuan Quintelafi
3711d5631638Smalcif test "$audio_win_int" = "yes" ; then
3712d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3713d5631638Smalcfi
3714b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
3715b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
37168ff9cbf7Smalcif test "$mixemu" = "yes" ; then
371798ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
37188ff9cbf7Smalcfi
3719821601eaSJes Sorensenif test "$vnc" = "yes" ; then
3720821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
3721821601eaSJes Sorensenfi
37228d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
372398ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
37248d5d2d4cSthsfi
37252f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
372698ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
37272f9606b3Saliguorifi
3728821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
37292f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
37302f6f5c7aSCorentin Charyfi
3731821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
3732efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3733efe556adSCorentin Charyfi
37347536ee4bSTim Hardeckif test "$vnc_ws" = "yes" ; then
37357536ee4bSTim Hardeck  echo "CONFIG_VNC_WS=y" >> $config_host_mak
37367536ee4bSTim Hardeck  echo "VNC_WS_CFLAGS=$vnc_ws_cflags" >> $config_host_mak
37377536ee4bSTim Hardeckfi
373876655d6dSaliguoriif test "$fnmatch" = "yes" ; then
37392358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
374076655d6dSaliguorifi
3741ee682d27SStefan Weilif test "$uuid" = "yes" ; then
3742ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
3743ee682d27SStefan Weilfi
3744dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3745dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3746dce512deSChristoph Hellwigfi
3747b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
374898ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
37492358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
375098ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
375198ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
3752a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
375398ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
3754cc8ae6deSpbrookfi
37551ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
375698ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
37578ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
375849ecc3faSbellardfi
375949ecc3faSbellardif test "$cocoa" = "yes" ; then
376098ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
376149ecc3faSbellardfi
37624d3b6f6eSbalrogif test "$curses" = "yes" ; then
376398ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
3764ab4e5602SJan Kiszkafi
3765ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
37662358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3767ebc996f3SRiku Voipiofi
3768099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
37692358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
3770099d6b0fSRiku Voipiofi
377140ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
377240ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
377340ff6d7eSKevin Wolffi
37743ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
37752358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
37763ce34dfbSvibisreenivasanfi
3777c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
3778c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
3779c2882b96SRiku Voipiofi
3780d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
3781d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3782d0927938SUlrich Hechtfi
37833d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
37843d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
37853d4fa43eSKusanagi Kouichifi
3786c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
3787c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3788c727f47dSPeter Maydellfi
3789dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
3790dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
3791dace20dcSPeter Maydellfi
3792d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
3793d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
3794d0927938SUlrich Hechtfi
37953b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
37963b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
37973b6edd16SPeter Maydellfi
37983b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
37993b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
38003b6edd16SPeter Maydellfi
38013b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
38023b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
38033b6edd16SPeter Maydellfi
3804a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
3805a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
3806a8fd1abaSPeter Maydellfi
38073b3f24adSaurel32if test "$inotify" = "yes" ; then
38082358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
38093b3f24adSaurel32fi
3810c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3811c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3812c05c7a73SRiku Voipiofi
38136ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
38146ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
38156ae9a1f4SJuan Quintelafi
38166ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
38176ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
38186ae9a1f4SJuan Quintelafi
3819769ce76dSAlexander Grafif test "$curl" = "yes" ; then
382098ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3821b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3822769ce76dSAlexander Graffi
38232e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
382498ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
38252e4d9fb1Saurel32fi
3826fb599c9aSbalrogif test "$bluez" = "yes" ; then
382798ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3828ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3829fb599c9aSbalrogfi
3830e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3831a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
3832a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
3833a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
3834a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
3835a4ccabcfSAnthony Liguorifi
3836e37630caSaliguoriif test "$xen" = "yes" ; then
38376dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3838d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3839e37630caSaliguorifi
38405c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
38415c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
38425c6c3a6cSChristoph Hellwigfi
3843758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3844758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3845758e8e38SVenkateswararao Jujjuri (JV)fi
38464f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
38474f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
38484f26f2b6SAvi Kivityfi
3849983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
3850758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
3851758e8e38SVenkateswararao Jujjuri (JV)fi
38525e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
38535e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
38545e9be92dSNicholas Bellingerfi
385577755340Sthsif test "$blobs" = "yes" ; then
385698ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
385777755340Sthsfi
3858bf9298b9Saliguoriif test "$iovec" = "yes" ; then
38592358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3860bf9298b9Saliguorifi
3861ceb42de8Saliguoriif test "$preadv" = "yes" ; then
38622358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3863ceb42de8Saliguorifi
3864f652e6afSaurel32if test "$fdt" = "yes" ; then
38653f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3866f652e6afSaurel32fi
3867dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3868dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3869dcc38d1cSMarcelo Tosattifi
38709195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
38719195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
38729195b2c2SStefan Weilfi
38735f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
38745f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
38755f6b9e8fSBlue Swirlfi
3876e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3877e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3878e78815a5SAndreas Färberfi
3879e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3880e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3881e78815a5SAndreas Färberfi
38821e9737daSRichard Hendersonif test "$sigev_thread_id" = "yes" ; then
38831e9737daSRichard Henderson  echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
38841e9737daSRichard Hendersonfi
388597a847bcSbellard
3886cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3887cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3888cd4ec0b4SGerd Hoffmannfi
3889cd4ec0b4SGerd Hoffmann
3890111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3891111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3892ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3893ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3894111a38b0SRobert Relyeafi
3895111a38b0SRobert Relyea
38962b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
38972b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
38982b2325ffSGerd Hoffmannfi
38992b2325ffSGerd Hoffmann
390069354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
390169354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
390269354a83SHans de Goedefi
390369354a83SHans de Goede
3904b1e5fff4SMichael Walleif test "$glx" = "yes" ; then
3905b1e5fff4SMichael Walle  echo "CONFIG_GLX=y" >> $config_host_mak
39062b6b7099SPaolo Bonzini  echo "GLX_LIBS=$glx_libs" >> $config_host_mak
390720ff075bSMichael Wallefi
390820ff075bSMichael Walle
3909c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3910c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3911c589b249SRonnie Sahlbergfi
3912c589b249SRonnie Sahlberg
3913f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
3914f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
3915f794573eSEduardo Otubofi
3916f794573eSEduardo Otubo
391783fb7adfSbellard# XXX: suppress that
39187d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
39192358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
39207d3505c5Sbellardfi
39217d3505c5Sbellard
39222358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3923c5937220Spbrook
392420ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
392520ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
392620ff6c80SAnthony Liguorifi
39273556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
39283556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
39293556c233SPaolo Bonzinifi
3930f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3931f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3932f27aaf4bSChristian Brunnerfi
393320ff6c80SAnthony Liguori
39347c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
3935d0e2fce5SAneesh Kumar K.V
3936d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
3937d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3938d2042378SAneesh Kumar K.Vfi
3939d2042378SAneesh Kumar K.V
3940e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
3941e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3942e06a765eSHarsh Prateek Borafi
3943e06a765eSHarsh Prateek Bora
3944cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
3945cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
394606d71fa1SPeter Maydellfi
394706d71fa1SPeter Maydell
39483f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
39493f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
39503f4349dcSKevin Wolffi
39513f4349dcSKevin Wolf
39528ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
39538ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
39548ab1bf12SLuiz Capitulinofi
39558ab1bf12SLuiz Capitulino
395676a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
395776a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
395876a347e1SRichard Hendersonfi
395976a347e1SRichard Henderson
3960f540166bSRichard Hendersonif test "$int128" = "yes" ; then
3961f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
3962f540166bSRichard Hendersonfi
3963f540166bSRichard Henderson
39641e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
39651e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
39661e6e9acaSRichard Hendersonfi
39671e6e9acaSRichard Henderson
3968eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
3969eb100396SBharata B Rao  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
3970eb100396SBharata B Raofi
3971eb100396SBharata B Rao
39720a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
39730a12ec87SRichard W.M. Jones  echo "CONFIG_LIBSSH2=y" >> $config_host_mak
39740a12ec87SRichard W.M. Jonesfi
39750a12ec87SRichard W.M. Jones
3976583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" ; then
39776e790746SPaolo Bonzini  echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
3978583f6e7bSStefan Hajnoczifi
3979583f6e7bSStefan Hajnoczi
398068063649Sblueswir1# USB host support
398168063649Sblueswir1case "$usb" in
398268063649Sblueswir1linux)
39834075975dSGerd Hoffmann  echo "HOST_USB=linux legacy" >> $config_host_mak
398468063649Sblueswir1;;
398568063649Sblueswir1bsd)
398698ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
398768063649Sblueswir1;;
39882b2325ffSGerd Hoffmannlibusb)
39892b2325ffSGerd Hoffmann  if test "$linux" = "yes"; then
39902b2325ffSGerd Hoffmann    echo "HOST_USB=libusb linux legacy" >> $config_host_mak
39912b2325ffSGerd Hoffmann  else
39922b2325ffSGerd Hoffmann    echo "HOST_USB=libusb legacy" >> $config_host_mak
39932b2325ffSGerd Hoffmann  fi
39942b2325ffSGerd Hoffmann;;
399568063649Sblueswir1*)
399698ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
399768063649Sblueswir1;;
399868063649Sblueswir1esac
399968063649Sblueswir1
40003b8acc11SPaolo Bonzini# TPM passthrough support?
40013b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
40023b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
40033b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
40043b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
40053b8acc11SPaolo Bonzini  fi
40063b8acc11SPaolo Bonzinifi
40073b8acc11SPaolo Bonzini
4008e4858974SLluís# use default implementation for tracing backend-specific routines
4009e4858974SLluístrace_default=yes
401094a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
40116d8a764eSLluísif test "$trace_backend" = "nop"; then
40126d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
401322890ab5SPrerna Saxenafi
40149410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
40156d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
4016e4858974SLluís  trace_default=no
40176d8a764eSLluís  # Set the appropriate trace file.
4018953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
40199410b56cSPrerna Saxenafi
40206d8a764eSLluísif test "$trace_backend" = "stderr"; then
40216d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
40229a82b6a5SLluís  trace_default=no
40236d8a764eSLluísfi
40246d8a764eSLluísif test "$trace_backend" = "ust"; then
40256d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
40266d8a764eSLluísfi
40276d8a764eSLluísif test "$trace_backend" = "dtrace"; then
40286d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
40296d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
40306d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
40316d8a764eSLluís  fi
4032c276b17dSDaniel P. Berrangefi
4033781e9545SEiichi Tsukataif test "$trace_backend" = "ftrace"; then
4034781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
4035781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4036781e9545SEiichi Tsukata    trace_default=no
4037781e9545SEiichi Tsukata  else
4038781e9545SEiichi Tsukata    feature_not_found "ftrace(trace backend)"
4039781e9545SEiichi Tsukata  fi
4040781e9545SEiichi Tsukatafi
40419410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
4042e4858974SLluísif test "$trace_default" = "yes"; then
4043e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
4044e4858974SLluísfi
40459410b56cSPrerna Saxena
40465b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
40475b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
40485b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
40495b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
40505b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
40515b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
40525b5e3037SPaolo Bonzinielif test "$ARCH" = "x86_64" ; then
40535b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
40545b5e3037SPaolo Bonzinielse
40555b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
40565b5e3037SPaolo Bonzinifi
40575b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
40585b5e3037SPaolo Bonzini
405998ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
406098ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4061804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4062804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
40631901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
40641901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
406521655882SPaolo Bonziniif test -n "$libtool"; then
406621655882SPaolo Bonzini  echo "INSTALL_PROG=\$(LIBTOOL) --mode=install $install -c -m 0755" >> $config_host_mak
406721655882SPaolo Bonzini  echo "INSTALL_LIB=\$(LIBTOOL) --mode=install $install -c -m 0644" >> $config_host_mak
406821655882SPaolo Bonzinielse
40691901cb14SBrad  echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
407021655882SPaolo Bonzini  echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
407121655882SPaolo Bonzinifi
4072c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
4073804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
40742b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
4075804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
40763c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
4077804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
40783dd46c78SBlue Swirlecho "AS=$as" >> $config_host_mak
40793dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4080804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4081804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
40829fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
408344dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
4084e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
4085a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
4086f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
4087e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
4088e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
4089e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
4090e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
4091e39f0062SPaolo Bonzinifi
409242da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
409342da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
409442da6041SGerd Hoffmannelse
409542da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
409642da6041SGerd Hoffmannfi
4097e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
409837746c5eSMarc-André Lureauecho "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
409973da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
41003e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
4101804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
4102957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
410394dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
4104cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
41051d728c39SBlue Swirlif test "$gcov" = "yes" ; then
41061d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
41071d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
41081d728c39SBlue Swirlfi
4109804edf29SJuan Quintela
41106efd7517SPeter Maydell# use included Linux headers
41116efd7517SPeter Maydellif test "$linux" = "yes" ; then
4112a307beb6SAndreas Färber  mkdir -p linux-headers
41136efd7517SPeter Maydell  case "$cpu" in
41146efd7517SPeter Maydell  i386|x86_64)
411508312a63SPeter Maydell    linux_arch=x86
41166efd7517SPeter Maydell    ;;
41176efd7517SPeter Maydell  ppcemb|ppc|ppc64)
411808312a63SPeter Maydell    linux_arch=powerpc
41196efd7517SPeter Maydell    ;;
41206efd7517SPeter Maydell  s390x)
412108312a63SPeter Maydell    linux_arch=s390
412208312a63SPeter Maydell    ;;
41231f080313SClaudio Fontana  aarch64)
41241f080313SClaudio Fontana    linux_arch=arm64
41251f080313SClaudio Fontana    ;;
412608312a63SPeter Maydell  *)
412708312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
412808312a63SPeter Maydell    linux_arch="$cpu"
41296efd7517SPeter Maydell    ;;
41306efd7517SPeter Maydell  esac
413108312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
413208312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
413308312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
413408312a63SPeter Maydell    fi
41356efd7517SPeter Maydellfi
41366efd7517SPeter Maydell
413797a847bcSbellardfor target in $target_list; do
413897a847bcSbellardtarget_dir="$target"
413925be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
4140c1799a84SPaolo Bonzinitarget_name=`echo $target | cut -d '-' -f 1`
414197a847bcSbellardtarget_bigendian="no"
41421f3d3c8fSJuan Quintela
4143c1799a84SPaolo Bonzinicase "$target_name" in
4144d15a9c23SAnthony Green  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
4145ea2d6a39SJuan Quintela  target_bigendian=yes
4146ea2d6a39SJuan Quintela  ;;
4147ea2d6a39SJuan Quintelaesac
414897a847bcSbellardtarget_softmmu="no"
4149997344f3Sbellardtarget_user_only="no"
4150831b7825Sthstarget_linux_user="no"
415184778508Sblueswir1target_bsd_user="no"
41529e407a85Spbrookcase "$target" in
4153c1799a84SPaolo Bonzini  ${target_name}-softmmu)
41549e407a85Spbrook    target_softmmu="yes"
41559e407a85Spbrook    ;;
4156c1799a84SPaolo Bonzini  ${target_name}-linux-user)
41579c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
415876ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a Linux host"
41599c7a4202SBlue Swirl    fi
41609e407a85Spbrook    target_user_only="yes"
41619e407a85Spbrook    target_linux_user="yes"
41629e407a85Spbrook    ;;
4163c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
41649cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
416576ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a BSD host"
41669c7a4202SBlue Swirl    fi
416784778508Sblueswir1    target_user_only="yes"
416884778508Sblueswir1    target_bsd_user="yes"
416984778508Sblueswir1    ;;
41709e407a85Spbrook  *)
417176ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
41729e407a85Spbrook    exit 1
41739e407a85Spbrook    ;;
41749e407a85Spbrookesac
4175831b7825Sths
417697a847bcSbellardmkdir -p $target_dir
417725be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
417897a847bcSbellard
4179e5fe0c52Spbrookbflt="no"
4180bd0c5661Spbrooktarget_nptl="no"
4181c1799a84SPaolo Bonziniinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"`
418256aebc89Spbrookgdb_xml_files=""
41837ba1e619Saliguori
4184c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
41856acff7daSJuan QuintelaTARGET_BASE_ARCH=""
4186e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
4187e73aae67SJuan Quintela
4188c1799a84SPaolo Bonzinicase "$target_name" in
41892408a527Saurel32  i386)
41902408a527Saurel32  ;;
41912408a527Saurel32  x86_64)
41926acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
41932408a527Saurel32  ;;
41942408a527Saurel32  alpha)
4195a4b388ffSRichard Henderson    target_nptl="yes"
41962408a527Saurel32  ;;
41972408a527Saurel32  arm|armeb)
4198b498c8a0SJuan Quintela    TARGET_ARCH=arm
4199e5fe0c52Spbrook    bflt="yes"
4200bd0c5661Spbrook    target_nptl="yes"
420156aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
42022408a527Saurel32  ;;
42032408a527Saurel32  cris)
4204253bd7f8Sedgar_igl    target_nptl="yes"
42052408a527Saurel32  ;;
4206613a22c9SMichael Walle  lm32)
4207613a22c9SMichael Walle  ;;
42082408a527Saurel32  m68k)
42090938cda5Saurel32    bflt="yes"
421056aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
42112408a527Saurel32  ;;
4212877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
4213877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
421472b675caSEdgar E. Iglesias    bflt="yes"
421572b675caSEdgar E. Iglesias    target_nptl="yes"
421672b675caSEdgar E. Iglesias  ;;
42172408a527Saurel32  mips|mipsel)
4218b498c8a0SJuan Quintela    TARGET_ARCH=mips
421925be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
4220f04dc72fSPaul Brook    target_nptl="yes"
42212408a527Saurel32  ;;
42222408a527Saurel32  mipsn32|mipsn32el)
4223597e2cecSRichard Henderson    TARGET_ARCH=mips64
42246acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
422525be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
4226597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
42272408a527Saurel32  ;;
42282408a527Saurel32  mips64|mips64el)
4229b498c8a0SJuan Quintela    TARGET_ARCH=mips64
42306acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
423125be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
42322408a527Saurel32  ;;
4233d15a9c23SAnthony Green  moxie)
4234d15a9c23SAnthony Green  ;;
4235e67db06eSJia Liu  or32)
4236e67db06eSJia Liu    TARGET_ARCH=openrisc
4237e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
4238e67db06eSJia Liu  ;;
42392408a527Saurel32  ppc)
4240c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
4241d6630708SNathan Froyd    target_nptl="yes"
42422408a527Saurel32  ;;
42432408a527Saurel32  ppcemb)
42446acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4245e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4246c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
4247d6630708SNathan Froyd    target_nptl="yes"
42482408a527Saurel32  ;;
42492408a527Saurel32  ppc64)
42506acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4251e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4252c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
42532408a527Saurel32  ;;
42542408a527Saurel32  ppc64abi32)
4255b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
42566acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4257e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
425825be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
4259c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
42602408a527Saurel32  ;;
42612408a527Saurel32  sh4|sh4eb)
4262b498c8a0SJuan Quintela    TARGET_ARCH=sh4
42634dbed897Spbrook    bflt="yes"
42640b6d3ae0Saurel32    target_nptl="yes"
42652408a527Saurel32  ;;
42662408a527Saurel32  sparc)
42672408a527Saurel32  ;;
42682408a527Saurel32  sparc64)
42696acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
42702408a527Saurel32  ;;
42712408a527Saurel32  sparc32plus)
4272b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
42736acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
4274e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
427525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
42762408a527Saurel32  ;;
427724e804ecSAlexander Graf  s390x)
4278bc434676SUlrich Hecht    target_nptl="yes"
427924e804ecSAlexander Graf  ;;
4280d2fbca94SGuan Xuetao  unicore32)
4281d2fbca94SGuan Xuetao  ;;
4282cfa550c6SMax Filippov  xtensa|xtensaeb)
4283cfa550c6SMax Filippov    TARGET_ARCH=xtensa
4284cfa550c6SMax Filippov  ;;
42852408a527Saurel32  *)
428676ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
42872408a527Saurel32  ;;
42882408a527Saurel32esac
42895e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
42905e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
42915e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
42925e8861a0SPaolo Bonzinifi
42935e8861a0SPaolo Bonzini
42945e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
42955e8861a0SPaolo Bonzini
429699afc91dSDaniel P. Berrangeupper() {
429799afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
429899afc91dSDaniel P. Berrange}
429999afc91dSDaniel P. Berrange
430099afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
430125be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
4302c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
430325be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
4304e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
4305e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
4306e6e91b9cSJuan Quintelafi
430725be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
4308c1799a84SPaolo Bonzinicase "$target_name" in
43091b0c87fcSJuan Quintela  i386|x86_64)
43101b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
431125be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
4312eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
4313eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
4314eb6fda0fSAnthony PERARD      fi
4315432d268cSJun Nakajima    fi
431659d21e53SAlexander Graf    ;;
431759d21e53SAlexander Graf  *)
43181b0c87fcSJuan Quintelaesac
4319c1799a84SPaolo Bonzinicase "$target_name" in
432068b05c42SPeter Maydell  arm|i386|x86_64|ppcemb|ppc|ppc64|s390x)
4321c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
4322c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
4323c1799a84SPaolo Bonzini      \( "$target_name" = "$cpu" -o \
4324c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
4325c1799a84SPaolo Bonzini      \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
4326c1799a84SPaolo Bonzini      \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
4327c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
4328c1799a84SPaolo Bonzini      \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
4329c1799a84SPaolo Bonzini      \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
433025be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
43311ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
4332d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
4333d5970055SMichael S. Tsirkin      fi
4334c59249f9SJuan Quintela    fi
4335c59249f9SJuan Quintelaesac
4336de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
433725be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
433897a847bcSbellardfi
433997a847bcSbellardif test "$target_softmmu" = "yes" ; then
434025be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
4341de83cd02Sbellardfi
4342997344f3Sbellardif test "$target_user_only" = "yes" ; then
434325be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
4344a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
4345997344f3Sbellardfi
4346831b7825Sthsif test "$target_linux_user" = "yes" ; then
434725be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
4348831b7825Sthsfi
434956aebc89Spbrooklist=""
435056aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
435156aebc89Spbrook  for x in $gdb_xml_files; do
435256aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
435356aebc89Spbrook  done
435425be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
43553d0f1517SJuan Quintelafi
4356de83cd02Sbellard
4357e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
435825be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
4359e5fe0c52Spbrookfi
4360bd0c5661Spbrookif test "$target_user_only" = "yes" \
4361bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
436225be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
4363bd0c5661Spbrookfi
4364379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
436525be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
4366379f6698SPaul Brookfi
436784778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
436825be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
436984778508Sblueswir1fi
43705b0753e0Sbellard
43714afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
4372fa282484SJuan Quintela
43734afddb55SJuan Quintelacflags=""
4374fa282484SJuan Quintelaldflags=""
43759b8e111fSJuan Quintela
437664656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
437764656024SJuan Quintela  case "$i" in
437864656024SJuan Quintela  alpha)
437925be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
438076cad711SPaolo Bonzini    echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
438164656024SJuan Quintela  ;;
438264656024SJuan Quintela  arm)
438325be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
438476cad711SPaolo Bonzini    echo "CONFIG_ARM_DIS=y"  >> config-all-disas.mak
438564656024SJuan Quintela  ;;
438664656024SJuan Quintela  cris)
438725be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
438876cad711SPaolo Bonzini    echo "CONFIG_CRIS_DIS=y"  >> config-all-disas.mak
438964656024SJuan Quintela  ;;
439064656024SJuan Quintela  hppa)
439125be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
439276cad711SPaolo Bonzini    echo "CONFIG_HPPA_DIS=y"  >> config-all-disas.mak
439364656024SJuan Quintela  ;;
439464656024SJuan Quintela  i386|x86_64)
439525be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
439676cad711SPaolo Bonzini    echo "CONFIG_I386_DIS=y"  >> config-all-disas.mak
439764656024SJuan Quintela  ;;
4398903ec55cSAurelien Jarno  ia64*)
4399903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
440076cad711SPaolo Bonzini    echo "CONFIG_IA64_DIS=y"  >> config-all-disas.mak
4401903ec55cSAurelien Jarno  ;;
440279368f49SMichael Walle  lm32)
440379368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
440476cad711SPaolo Bonzini    echo "CONFIG_LM32_DIS=y"  >> config-all-disas.mak
440579368f49SMichael Walle  ;;
440664656024SJuan Quintela  m68k)
440725be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
440876cad711SPaolo Bonzini    echo "CONFIG_M68K_DIS=y"  >> config-all-disas.mak
440964656024SJuan Quintela  ;;
4410877fdc12SEdgar E. Iglesias  microblaze*)
441125be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
441276cad711SPaolo Bonzini    echo "CONFIG_MICROBLAZE_DIS=y"  >> config-all-disas.mak
441364656024SJuan Quintela  ;;
441464656024SJuan Quintela  mips*)
441525be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
441676cad711SPaolo Bonzini    echo "CONFIG_MIPS_DIS=y"  >> config-all-disas.mak
441764656024SJuan Quintela  ;;
4418d15a9c23SAnthony Green  moxie*)
4419d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> $config_target_mak
4420d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> config-all-disas.mak
4421d15a9c23SAnthony Green  ;;
4422e67db06eSJia Liu  or32)
4423e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
442476cad711SPaolo Bonzini    echo "CONFIG_OPENRISC_DIS=y"  >> config-all-disas.mak
4425e67db06eSJia Liu  ;;
442664656024SJuan Quintela  ppc*)
442725be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
442876cad711SPaolo Bonzini    echo "CONFIG_PPC_DIS=y"  >> config-all-disas.mak
442964656024SJuan Quintela  ;;
443024e804ecSAlexander Graf  s390*)
443125be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
443276cad711SPaolo Bonzini    echo "CONFIG_S390_DIS=y"  >> config-all-disas.mak
443364656024SJuan Quintela  ;;
443464656024SJuan Quintela  sh4)
443525be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
443676cad711SPaolo Bonzini    echo "CONFIG_SH4_DIS=y"  >> config-all-disas.mak
443764656024SJuan Quintela  ;;
443864656024SJuan Quintela  sparc*)
443925be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
444076cad711SPaolo Bonzini    echo "CONFIG_SPARC_DIS=y"  >> config-all-disas.mak
444164656024SJuan Quintela  ;;
4442cfa550c6SMax Filippov  xtensa*)
4443cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
444476cad711SPaolo Bonzini    echo "CONFIG_XTENSA_DIS=y"  >> config-all-disas.mak
4445cfa550c6SMax Filippov  ;;
444664656024SJuan Quintela  esac
444764656024SJuan Quinteladone
44489195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
44499195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
445076cad711SPaolo Bonzini  echo "CONFIG_TCI_DIS=y"  >> config-all-disas.mak
44519195b2c2SStefan Weilfi
445264656024SJuan Quintela
44536ee7126fSJuan Quintelacase "$ARCH" in
44546ee7126fSJuan Quintelaalpha)
44556ee7126fSJuan Quintela  # Ensure there's only a single GP
44566ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
44576ee7126fSJuan Quintela;;
44586ee7126fSJuan Quintelaesac
44596ee7126fSJuan Quintela
4460d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
446125be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4462d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4463d02c1db3SJuan Quintela    cflags="-p $cflags"
4464d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4465d02c1db3SJuan Quintela  fi
4466d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4467d02c1db3SJuan Quintela    ldflags="-p $ldflags"
446825be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4469d02c1db3SJuan Quintela  fi
4470d02c1db3SJuan Quintelafi
4471d02c1db3SJuan Quintela
44729b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4473964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
4474fa282484SJuan Quintelafi
4475fa282484SJuan Quintela
447625be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
447725be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4478fa282484SJuan Quintela
447997a847bcSbellarddone # for target in $targets
44807d13299dSbellard
4481b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
4482b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
4483b776eca1SGerd Hoffmannfi
4484b776eca1SGerd Hoffmann
4485a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
4486a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
4487a540f158SPeter Crosthwaitefi
4488a540f158SPeter Crosthwaite
4489d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
4490c4efe1caSAnthony LiguoriDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos"
44919933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
44922d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
44932dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
4494c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4495c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
4496834574eaSAnthony LiguoriFILES="$FILES tests/tcg/lm32/Makefile po/Makefile"
4497ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4498446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
44999933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
45002d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
45014652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
4502753d11f2SRichard Hendersonfor bios_file in \
4503753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
45045acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
4505753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4506753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4507e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
4508753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4509753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4510753d11f2SRichard Hendersondo
45117ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
45127ea78b74SJan Kiszkadone
4513d1807a4fSPaolo Bonzinimkdir -p $DIRS
45147d13299dSbellardfor f in $FILES ; do
451572b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4516f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4517f9245e10SPeter Maydell    fi
45187d13299dSbellarddone
45191ad2134fSPaul Brook
4520c34ebfdcSAnthony Liguori# temporary config to build submodules
45212d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4522c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
452337116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4524c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
45253dd46c78SBlue Swirl    echo "AS=$as" >> $config_mak
4526c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4527c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
45283dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
4529c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4530c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
4531c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4532c34ebfdcSAnthony Liguoridone
4533c34ebfdcSAnthony Liguori
4534b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4535b40292e7SJan Kiszka  mkdir -p QMP
4536b40292e7SJan Kiszkafi
4537