xref: /openbmc/qemu/configure (revision 83f73fce)
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=""
158e2134eb9SGerd Hoffmannpixman=""
159377529c0SPaolo Bonzinisdl=""
160983eef5aSMeador Ingevirtfs=""
161821601eaSJes Sorensenvnc="yes"
162377529c0SPaolo Bonzinisparse="no"
163377529c0SPaolo Bonziniuuid=""
164377529c0SPaolo Bonzinivde=""
165377529c0SPaolo Bonzinivnc_tls=""
166377529c0SPaolo Bonzinivnc_sasl=""
167377529c0SPaolo Bonzinivnc_jpeg=""
168377529c0SPaolo Bonzinivnc_png=""
1697536ee4bSTim Hardeckvnc_ws=""
170377529c0SPaolo Bonzinixen=""
171d5b93ddfSAnthony PERARDxen_ctrl_version=""
172eb6fda0fSAnthony PERARDxen_pci_passthrough=""
173377529c0SPaolo Bonzinilinux_aio=""
17447e98658SCorey Bryantcap_ng=""
175377529c0SPaolo Bonziniattr=""
1764f26f2b6SAvi Kivitylibattr=""
177377529c0SPaolo Bonzinixfs=""
178377529c0SPaolo Bonzini
179d41a75a2SBradvhost_net="no"
1805e9be92dSNicholas Bellingervhost_scsi="no"
181d41a75a2SBradkvm="no"
1822da776dbSMichael R. Hinesrdma=""
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"
234e8ef31a3SMichael Tokarevguest_agent=""
2354b1c11fdSDaniel P. Berrangewant_tools="yes"
236c589b249SRonnie Sahlberglibiscsi=""
237519175a2SAlex Barcelocoroutine=""
238f794573eSEduardo Otuboseccomp=""
239eb100396SBharata B Raoglusterfs=""
2400c14fb47SBharata B Raoglusterfs_discard="no"
241583f6e7bSStefan Hajnoczivirtio_blk_data_plane=""
242a4ccabcfSAnthony Liguorigtk=""
243528de90aSDaniel P. Berrangegtkabi="2.0"
244ab214c29SStefan Bergertpm="no"
2450a12ec87SRichard W.M. Joneslibssh2=""
246377529c0SPaolo Bonzini
247ac0df51dSaliguori# parse CC options first
248ac0df51dSaliguorifor opt do
249ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
250ac0df51dSaliguori  case "$opt" in
251ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
252ac0df51dSaliguori  ;;
2533d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
254ac0df51dSaliguori  ;;
255*83f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
256*83f73fceSTomoki Sekiyama  ;;
257ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
258ca4deeb1SPaolo Bonzini  ;;
2592ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2602ff6b91eSJuan Quintela  ;;
261a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
262f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
263e2a2ed06SJuan Quintela  ;;
264e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
265f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
266e2a2ed06SJuan Quintela  ;;
2675bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2685bc62e01SGerd Hoffmann  ;;
2695bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2705bc62e01SGerd Hoffmann  ;;
271ac0df51dSaliguori  esac
272ac0df51dSaliguoridone
273ac0df51dSaliguori# OS specific
274ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
27593148aa5SStefan Weil# we can eliminate its usage altogether.
276ac0df51dSaliguori
277e49d021eSPeter Maydell# Preferred compiler:
278e49d021eSPeter Maydell#  ${CC} (if set)
279e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
280e49d021eSPeter Maydell#  system compiler
281e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
282e49d021eSPeter Maydell  cc="$host_cc"
283e49d021eSPeter Maydellelse
284b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
285e49d021eSPeter Maydellfi
286e49d021eSPeter Maydell
287*83f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
288*83f73fceSTomoki Sekiyama  cxx="c++"
289*83f73fceSTomoki Sekiyamaelse
290*83f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
291*83f73fceSTomoki Sekiyamafi
292*83f73fceSTomoki Sekiyama
293b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
2943dd46c78SBlue Swirlas="${AS-${cross_prefix}as}"
2953dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
296b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
297b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
2983f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
299b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
300b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
30117884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
30217884d7bSSergei Trofimovichquery_pkg_config() {
30317884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
30417884d7bSSergei Trofimovich}
30517884d7bSSergei Trofimovichpkg_config=query_pkg_config
306b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
307ac0df51dSaliguori
308be17dc90SMichael S. Tsirkin# default flags for all hosts
309be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
310f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
311c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
312be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
3136b4c305cSPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
3145bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
3155bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
316be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
3175bc62e01SGerd Hoffmannfi
318be17dc90SMichael S. Tsirkin
319ca4deeb1SPaolo Bonzini# make source path absolute
320ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
321ca4deeb1SPaolo Bonzini
322ac0df51dSaliguoricheck_define() {
323ac0df51dSaliguoricat > $TMPC <<EOF
324ac0df51dSaliguori#if !defined($1)
325fd786e1aSPeter Maydell#error $1 not defined
326ac0df51dSaliguori#endif
327ac0df51dSaliguoriint main(void) { return 0; }
328ac0df51dSaliguoriEOF
32952166aa0SJuan Quintela  compile_object
330ac0df51dSaliguori}
331ac0df51dSaliguori
332bbea4050SPeter Maydellif check_define __linux__ ; then
333bbea4050SPeter Maydell  targetos="Linux"
334bbea4050SPeter Maydellelif check_define _WIN32 ; then
335bbea4050SPeter Maydell  targetos='MINGW32'
336bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
337bbea4050SPeter Maydell  targetos='OpenBSD'
338bbea4050SPeter Maydellelif check_define __sun__ ; then
339bbea4050SPeter Maydell  targetos='SunOS'
340bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
341bbea4050SPeter Maydell  targetos='Haiku'
342bbea4050SPeter Maydellelse
343bbea4050SPeter Maydell  targetos=`uname -s`
344bbea4050SPeter Maydellfi
345bbea4050SPeter Maydell
346bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
347bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
348bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
349bbea4050SPeter Maydell# the correct CPU with the --cpu option.
350bbea4050SPeter Maydellcase $targetos in
351bbea4050SPeter MaydellDarwin)
352bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
353bbea4050SPeter Maydell  # run 64-bit userspace code.
354bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
355bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
356bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
357bbea4050SPeter Maydell    cpu="x86_64"
358bbea4050SPeter Maydell  fi
359bbea4050SPeter Maydell  ;;
360bbea4050SPeter MaydellSunOS)
361bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
362bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
363bbea4050SPeter Maydell    cpu="x86_64"
364bbea4050SPeter Maydell  fi
365bbea4050SPeter Maydellesac
366bbea4050SPeter Maydell
3672ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3682ff6b91eSJuan Quintela  # command line argument
3692ff6b91eSJuan Quintela  :
3702ff6b91eSJuan Quintelaelif check_define __i386__ ; then
371ac0df51dSaliguori  cpu="i386"
372ac0df51dSaliguorielif check_define __x86_64__ ; then
373c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
374c72b26ecSRichard Henderson    cpu="x32"
375c72b26ecSRichard Henderson  else
376ac0df51dSaliguori    cpu="x86_64"
377c72b26ecSRichard Henderson  fi
3783aa9bd6cSblueswir1elif check_define __sparc__ ; then
3793aa9bd6cSblueswir1  if check_define __arch64__ ; then
3803aa9bd6cSblueswir1    cpu="sparc64"
3813aa9bd6cSblueswir1  else
3823aa9bd6cSblueswir1    cpu="sparc"
3833aa9bd6cSblueswir1  fi
384fdf7ed96Smalcelif check_define _ARCH_PPC ; then
385fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
386fdf7ed96Smalc    cpu="ppc64"
387ac0df51dSaliguori  else
388fdf7ed96Smalc    cpu="ppc"
389fdf7ed96Smalc  fi
390afa05235SAurelien Jarnoelif check_define __mips__ ; then
391afa05235SAurelien Jarno  cpu="mips"
392477ba620SAurelien Jarnoelif check_define __ia64__ ; then
393477ba620SAurelien Jarno  cpu="ia64"
394d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
395d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
396d66ed0eaSAurelien Jarno    cpu="s390x"
397d66ed0eaSAurelien Jarno  else
398d66ed0eaSAurelien Jarno    cpu="s390"
399d66ed0eaSAurelien Jarno  fi
40021d89f84SPeter Maydellelif check_define __arm__ ; then
40121d89f84SPeter Maydell  cpu="arm"
4021f080313SClaudio Fontanaelif check_define __aarch64__ ; then
4031f080313SClaudio Fontana  cpu="aarch64"
404f28ffed5SBradelif check_define __hppa__ ; then
405f28ffed5SBrad  cpu="hppa"
406fdf7ed96Smalcelse
407fdf7ed96Smalc  cpu=`uname -m`
408ac0df51dSaliguorifi
409ac0df51dSaliguori
410359bc95dSPeter MaydellARCH=
411359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
412359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
4137d13299dSbellardcase "$cpu" in
414c72b26ecSRichard Henderson  ia64|ppc|ppc64|s390|s390x|sparc64|x32)
415ea8f20f8SJuan Quintela    cpu="$cpu"
416ea8f20f8SJuan Quintela  ;;
4177d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
41897a847bcSbellard    cpu="i386"
4197d13299dSbellard  ;;
420aaa5fa14Saurel32  x86_64|amd64)
421aaa5fa14Saurel32    cpu="x86_64"
422aaa5fa14Saurel32  ;;
42321d89f84SPeter Maydell  armv*b|armv*l|arm)
42421d89f84SPeter Maydell    cpu="arm"
4257d13299dSbellard  ;;
4261f080313SClaudio Fontana  aarch64)
4271f080313SClaudio Fontana    cpu="aarch64"
4281f080313SClaudio Fontana  ;;
429f28ffed5SBrad  hppa|parisc|parisc64)
430f54b3f92Saurel32    cpu="hppa"
431f54b3f92Saurel32  ;;
432afa05235SAurelien Jarno  mips*)
433afa05235SAurelien Jarno    cpu="mips"
434afa05235SAurelien Jarno  ;;
4353142255cSblueswir1  sparc|sun4[cdmuv])
436ae228531Sbellard    cpu="sparc"
437ae228531Sbellard  ;;
4387d13299dSbellard  *)
439359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
440359bc95dSPeter Maydell    ARCH=unknown
4417d13299dSbellard  ;;
4427d13299dSbellardesac
443359bc95dSPeter Maydellif test -z "$ARCH"; then
444359bc95dSPeter Maydell  ARCH="$cpu"
445359bc95dSPeter Maydellfi
446e2d52ad3SJuan Quintela
4477d13299dSbellard# OS specific
4480dbfc675SJuan Quintela
4497d13299dSbellardcase $targetos in
450c326e0afSbellardCYGWIN*)
451c326e0afSbellard  mingw32="yes"
452a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
453d5631638Smalc  audio_possible_drivers="winwave sdl"
454d5631638Smalc  audio_drv_list="winwave"
455c326e0afSbellard;;
45667b915a5SbellardMINGW32*)
45767b915a5Sbellard  mingw32="yes"
458d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
459d5631638Smalc  audio_drv_list="winwave"
46067b915a5Sbellard;;
4615c40d2bdSthsGNU/kFreeBSD)
462a167ba50SAurelien Jarno  bsd="yes"
4630c58ac1cSmalc  audio_drv_list="oss"
464f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4655c40d2bdSths;;
4667d3505c5SbellardFreeBSD)
4677d3505c5Sbellard  bsd="yes"
4680db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4690c58ac1cSmalc  audio_drv_list="oss"
470f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
471f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
472f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
4737d3505c5Sbellard;;
474c5e97233Sblueswir1DragonFly)
475c5e97233Sblueswir1  bsd="yes"
4760db4a067SPaolo Bonzini  make="${MAKE-gmake}"
477c5e97233Sblueswir1  audio_drv_list="oss"
478c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
479c5e97233Sblueswir1;;
4807d3505c5SbellardNetBSD)
4817d3505c5Sbellard  bsd="yes"
4820db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4830c58ac1cSmalc  audio_drv_list="oss"
484c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4858ef92a88Sblueswir1  oss_lib="-lossaudio"
4867d3505c5Sbellard;;
4877d3505c5SbellardOpenBSD)
4887d3505c5Sbellard  bsd="yes"
4890db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4904f6ab397SBrad Smith  audio_drv_list="sdl"
4914f6ab397SBrad Smith  audio_possible_drivers="sdl esd"
4927d3505c5Sbellard;;
49383fb7adfSbellardDarwin)
49483fb7adfSbellard  bsd="yes"
49583fb7adfSbellard  darwin="yes"
4961b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
497a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4980c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4991b0f9cc2Saliguori  else
500a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
5011b0f9cc2Saliguori  fi
502fd677642Sths  cocoa="yes"
5030c58ac1cSmalc  audio_drv_list="coreaudio"
504c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
5050c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
5067973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
507a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
508a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
509a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
51083fb7adfSbellard;;
511ec530c81SbellardSunOS)
512ec530c81Sbellard  solaris="yes"
5130db4a067SPaolo Bonzini  make="${MAKE-gmake}"
5140db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
515fa58948dSBlue Swirl  ld="gld"
516e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
5170475a5caSths  needs_libsunmath="no"
518c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
519c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
5200475a5caSths    if test "$solarisrev" -le 9 ; then
5210475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
5220475a5caSths        needs_libsunmath="yes"
523f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
524f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
525f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
5260475a5caSths      else
52776ad07a4SPeter Maydell        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
52876ad07a4SPeter Maydell            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
52976ad07a4SPeter Maydell            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
53076ad07a4SPeter Maydell            "Studio 11 can be downloaded from www.sun.com."
5310475a5caSths      fi
5320475a5caSths    fi
53386b2bd93Sths  fi
5346b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
5350c58ac1cSmalc    audio_drv_list="oss"
5366b4d2ba1Sths  fi
537c2de5c91Smalc  audio_possible_drivers="oss sdl"
538d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
539d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
540d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
541d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
542a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
543560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
544560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
545560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
546ec530c81Sbellard;;
547b29fe3edSmalcAIX)
548b29fe3edSmalc  aix="yes"
5490db4a067SPaolo Bonzini  make="${MAKE-gmake}"
550b29fe3edSmalc;;
551179cf400SAndreas FärberHaiku)
552179cf400SAndreas Färber  haiku="yes"
553179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
554179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
555179cf400SAndreas Färber;;
556fb065187Sbellard*)
5570c58ac1cSmalc  audio_drv_list="oss"
558b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5595327cf48Sbellard  linux="yes"
560831b7825Sths  linux_user="yes"
56168063649Sblueswir1  usb="linux"
562af2be207SJan Kiszka  kvm="yes"
563af2be207SJan Kiszka  vhost_net="yes"
5645e9be92dSNicholas Bellinger  vhost_scsi="yes"
565c72b26ecSRichard Henderson  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "x32" ] ; then
566c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
567c9ec1fe4Sbellard  fi
568a585140dSAlexey Kardashevskiy  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
569fb065187Sbellard;;
5707d13299dSbellardesac
5717d13299dSbellard
5727d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
573b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
57445f0b043SEd Maste    if [ "$targetos" != "FreeBSD" ]; then
57568063649Sblueswir1      usb="bsd"
57645f0b043SEd Maste    fi
57784778508Sblueswir1    bsd_user="yes"
5787d3505c5Sbellard  fi
57908de3949SAndreas Färberfi
5807d3505c5Sbellard
5810db4a067SPaolo Bonzini: ${make=${MAKE-make}}
5820db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
5831d984a67SStefan Weil: ${python=${PYTHON-python -B}}
584e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
5850db4a067SPaolo Bonzini
5863c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
5873c4a4d0dSPeter Maydellif has clang; then
5883c4a4d0dSPeter Maydell  objcc=clang
5893c4a4d0dSPeter Maydellelse
5903c4a4d0dSPeter Maydell  objcc="$cc"
5913c4a4d0dSPeter Maydellfi
5923c4a4d0dSPeter Maydell
5933457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
5943457a3f8SJuan Quintela  EXESUF=".exe"
595a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
596e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
597e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
598f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
599f7cf5d5bSStefan Weilcat > $TMPC << EOF
600f7cf5d5bSStefan Weilint main(void) { return 0; }
601f7cf5d5bSStefan WeilEOF
602f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
603f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
604f7cf5d5bSStefan Weil  fi
605c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
606683035deSPaolo Bonzini  mandir="\${prefix}"
607528ae5b8SEduardo Habkost  datadir="\${prefix}"
608850da188SEduardo Habkost  qemu_docdir="\${prefix}"
609683035deSPaolo Bonzini  bindir="\${prefix}"
610683035deSPaolo Bonzini  sysconfdir="\${prefix}"
6115a699bbbSLaszlo Ersek  local_statedir=
612683035deSPaolo Bonzini  confsuffix=""
613368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
6143457a3f8SJuan Quintelafi
6153457a3f8SJuan Quintela
616487fefdbSAnthony Liguoriwerror=""
61785aa5189Sbellard
6187d13299dSbellardfor opt do
619a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
6207d13299dSbellard  case "$opt" in
6212efc3265Sbellard  --help|-h) show_help=yes
6222efc3265Sbellard  ;;
62399123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
62499123e13SMike Frysinger  ;;
625b1a550a0Spbrook  --prefix=*) prefix="$optarg"
6267d13299dSbellard  ;;
627b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
62832ce6337Sbellard  ;;
629ca4deeb1SPaolo Bonzini  --source-path=*)
6307d13299dSbellard  ;;
631ac0df51dSaliguori  --cross-prefix=*)
6327d13299dSbellard  ;;
633ac0df51dSaliguori  --cc=*)
6347d13299dSbellard  ;;
635b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
63683469015Sbellard  ;;
637*83f73fceSTomoki Sekiyama  --cxx=*)
638*83f73fceSTomoki Sekiyama  ;;
6393c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
6403c4a4d0dSPeter Maydell  ;;
641b1a550a0Spbrook  --make=*) make="$optarg"
6427d13299dSbellard  ;;
6436a882643Spbrook  --install=*) install="$optarg"
6446a882643Spbrook  ;;
645c886edfbSBlue Swirl  --python=*) python="$optarg"
646c886edfbSBlue Swirl  ;;
6471d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
6481d728c39SBlue Swirl  ;;
649e2d8830eSBrad  --smbd=*) smbd="$optarg"
650e2d8830eSBrad  ;;
651e2a2ed06SJuan Quintela  --extra-cflags=*)
6527d13299dSbellard  ;;
653e2a2ed06SJuan Quintela  --extra-ldflags=*)
6547d13299dSbellard  ;;
6555bc62e01SGerd Hoffmann  --enable-debug-info)
6565bc62e01SGerd Hoffmann  ;;
6575bc62e01SGerd Hoffmann  --disable-debug-info)
6585bc62e01SGerd Hoffmann  ;;
6592ff6b91eSJuan Quintela  --cpu=*)
6607d13299dSbellard  ;;
661b1a550a0Spbrook  --target-list=*) target_list="$optarg"
662de83cd02Sbellard  ;;
66374242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
66494a420b1SStefan Hajnoczi  ;;
66574242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6669410b56cSPrerna Saxena  ;;
6677d13299dSbellard  --enable-gprof) gprof="yes"
6687d13299dSbellard  ;;
6691d728c39SBlue Swirl  --enable-gcov) gcov="yes"
6701d728c39SBlue Swirl  ;;
67179427693SLoïc Minier  --static)
67279427693SLoïc Minier    static="yes"
67379427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
67417884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
67543ce4dfeSbellard  ;;
6760b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6770b24e75fSPaolo Bonzini  ;;
6780b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
6790b24e75fSPaolo Bonzini  ;;
6803aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
6813aa5d2beSAlon Levy  ;;
6828bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
6838bf188aaSMichael Tokarev  ;;
6840f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
6850f94d6daSAlon Levy  ;;
686528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
6870b24e75fSPaolo Bonzini  ;;
688023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
689023d3d67SEduardo Habkost  ;;
690850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
6910b24e75fSPaolo Bonzini  ;;
692ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
69307381cc1SAnthony Liguori  ;;
694785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
695785c23aeSLuiz Capitulino  ;;
696785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
697023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
698023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
699023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
700023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
701023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
702023ddd74SMax Filippov    # lots of directory switches by default.
703023ddd74SMax Filippov  ;;
704e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
705e2134eb9SGerd Hoffmann  ;;
706e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
707e2134eb9SGerd Hoffmann  ;;
70874880fe2SRobert Schiele  --without-pixman) pixman="none"
70974880fe2SRobert Schiele  ;;
71097a847bcSbellard  --disable-sdl) sdl="no"
71197a847bcSbellard  ;;
712c4198157SJuan Quintela  --enable-sdl) sdl="yes"
713c4198157SJuan Quintela  ;;
7143556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
7153556c233SPaolo Bonzini  ;;
7163556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
7173556c233SPaolo Bonzini  ;;
718983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
719983eef5aSMeador Inge  ;;
720983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
721983eef5aSMeador Inge  ;;
722821601eaSJes Sorensen  --disable-vnc) vnc="no"
723821601eaSJes Sorensen  ;;
724821601eaSJes Sorensen  --enable-vnc) vnc="yes"
725821601eaSJes Sorensen  ;;
726b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
727102a52e4Sbellard  ;;
728c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
729c2de5c91Smalc  ;;
7302f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
7312f6a1ab0Sblueswir1  ;;
7320c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
7330c58ac1cSmalc  ;;
734b64ec4e4SFam Zheng  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
735b64ec4e4SFam Zheng  ;;
736b64ec4e4SFam Zheng  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
737eb852011SMarkus Armbruster  ;;
738f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
739f8393946Saurel32  ;;
740f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
741f8393946Saurel32  ;;
742f3d08ee6SPaul Brook  --enable-debug)
743f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
744f3d08ee6SPaul Brook      debug_tcg="yes"
745f3d08ee6SPaul Brook      debug="yes"
746f3d08ee6SPaul Brook      strip_opt="no"
747f3d08ee6SPaul Brook  ;;
74803b4fe7dSaliguori  --enable-sparse) sparse="yes"
74903b4fe7dSaliguori  ;;
75003b4fe7dSaliguori  --disable-sparse) sparse="no"
75103b4fe7dSaliguori  ;;
7521625af87Saliguori  --disable-strip) strip_opt="no"
7531625af87Saliguori  ;;
7548d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
7558d5d2d4cSths  ;;
7561be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
7571be10ad2SJuan Quintela  ;;
7582f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
7592f9606b3Saliguori  ;;
760ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
761ea784e3bSJuan Quintela  ;;
7622f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
7632f6f5c7aSCorentin Chary  ;;
7642f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
7652f6f5c7aSCorentin Chary  ;;
766efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
767efe556adSCorentin Chary  ;;
768efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
769efe556adSCorentin Chary  ;;
7707536ee4bSTim Hardeck  --disable-vnc-ws) vnc_ws="no"
7717536ee4bSTim Hardeck  ;;
7727536ee4bSTim Hardeck  --enable-vnc-ws) vnc_ws="yes"
7737536ee4bSTim Hardeck  ;;
774443f1376Sbellard  --disable-slirp) slirp="no"
775c20709aaSbellard  ;;
776ee682d27SStefan Weil  --disable-uuid) uuid="no"
777ee682d27SStefan Weil  ;;
778ee682d27SStefan Weil  --enable-uuid) uuid="yes"
779ee682d27SStefan Weil  ;;
780e0e6c8c0Saliguori  --disable-vde) vde="no"
7818a16d273Sths  ;;
782dfb278bdSJuan Quintela  --enable-vde) vde="yes"
783dfb278bdSJuan Quintela  ;;
784e37630caSaliguori  --disable-xen) xen="no"
785e37630caSaliguori  ;;
786fc321b4bSJuan Quintela  --enable-xen) xen="yes"
787fc321b4bSJuan Quintela  ;;
788eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
789eb6fda0fSAnthony PERARD  ;;
790eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
791eb6fda0fSAnthony PERARD  ;;
7922e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
7932e4d9fb1Saurel32  ;;
7944ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
7954ffcedb6SJuan Quintela  ;;
796fb599c9aSbalrog  --disable-bluez) bluez="no"
797fb599c9aSbalrog  ;;
798a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
799a20a6f46SJuan Quintela  ;;
8007ba1e619Saliguori  --disable-kvm) kvm="no"
8017ba1e619Saliguori  ;;
802b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
803b31a0277SJuan Quintela  ;;
8049195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
8059195b2c2SStefan Weil  ;;
8069195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
8079195b2c2SStefan Weil  ;;
80847e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
80947e98658SCorey Bryant  ;;
81047e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
81147e98658SCorey Bryant  ;;
812cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
813cd4ec0b4SGerd Hoffmann  ;;
814cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
815cd4ec0b4SGerd Hoffmann  ;;
816c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
817c589b249SRonnie Sahlberg  ;;
818c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
819c589b249SRonnie Sahlberg  ;;
82005c2a3e7Sbellard  --enable-profiler) profiler="yes"
82105c2a3e7Sbellard  ;;
82214821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
82314821030SPavel Borzenkov  ;;
824c2de5c91Smalc  --enable-cocoa)
825c2de5c91Smalc      cocoa="yes" ;
826c2de5c91Smalc      sdl="no" ;
827c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
8285b0753e0Sbellard  ;;
829cad25d69Spbrook  --disable-system) softmmu="no"
8300a8e90f4Spbrook  ;;
831cad25d69Spbrook  --enable-system) softmmu="yes"
8320a8e90f4Spbrook  ;;
8330953a80fSZachary Amsden  --disable-user)
8340953a80fSZachary Amsden      linux_user="no" ;
8350953a80fSZachary Amsden      bsd_user="no" ;
8360953a80fSZachary Amsden  ;;
8370953a80fSZachary Amsden  --enable-user) ;;
838831b7825Sths  --disable-linux-user) linux_user="no"
8390a8e90f4Spbrook  ;;
840831b7825Sths  --enable-linux-user) linux_user="yes"
841831b7825Sths  ;;
84284778508Sblueswir1  --disable-bsd-user) bsd_user="no"
84384778508Sblueswir1  ;;
84484778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
84584778508Sblueswir1  ;;
846379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
847379f6698SPaul Brook  ;;
848379f6698SPaul Brook  --disable-guest-base) guest_base="no"
849379f6698SPaul Brook  ;;
85040d6444eSAvi Kivity  --enable-pie) pie="yes"
85134005a00SKirill A. Shutemov  ;;
85240d6444eSAvi Kivity  --disable-pie) pie="no"
85334005a00SKirill A. Shutemov  ;;
854c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
855c5937220Spbrook  ;;
85685aa5189Sbellard  --enable-werror) werror="yes"
85785aa5189Sbellard  ;;
85885aa5189Sbellard  --disable-werror) werror="no"
85985aa5189Sbellard  ;;
8604d3b6f6eSbalrog  --disable-curses) curses="no"
8614d3b6f6eSbalrog  ;;
862c584a6d0SJuan Quintela  --enable-curses) curses="yes"
863c584a6d0SJuan Quintela  ;;
864769ce76dSAlexander Graf  --disable-curl) curl="no"
865769ce76dSAlexander Graf  ;;
866788c8196SJuan Quintela  --enable-curl) curl="yes"
867788c8196SJuan Quintela  ;;
8682df87df7SJuan Quintela  --disable-fdt) fdt="no"
8692df87df7SJuan Quintela  ;;
8702df87df7SJuan Quintela  --enable-fdt) fdt="yes"
8712df87df7SJuan Quintela  ;;
8728ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
8738ff9cbf7Smalc  ;;
8745c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
8755c6c3a6cSChristoph Hellwig  ;;
8765c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
8775c6c3a6cSChristoph Hellwig  ;;
878758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
879758e8e38SVenkateswararao Jujjuri (JV)  ;;
880758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
881758e8e38SVenkateswararao Jujjuri (JV)  ;;
88277755340Sths  --disable-blobs) blobs="no"
88377755340Sths  ;;
8844a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
8854a19f1ecSpbrook  ;;
886519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
887519175a2SAlex Barcelo  ;;
888a25dba17SJuan Quintela  --disable-docs) docs="no"
88970ec5dc0SAnthony Liguori  ;;
890a25dba17SJuan Quintela  --enable-docs) docs="yes"
89183a3ab8bSJuan Quintela  ;;
892d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
893d5970055SMichael S. Tsirkin  ;;
894d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
895d5970055SMichael S. Tsirkin  ;;
8965e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
8975e9be92dSNicholas Bellinger  ;;
8985e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
8995e9be92dSNicholas Bellinger  ;;
900b1e5fff4SMichael Walle  --disable-glx) glx="no"
90120ff075bSMichael Walle  ;;
902b1e5fff4SMichael Walle  --enable-glx) glx="yes"
90320ff075bSMichael Walle  ;;
904f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
905f27aaf4bSChristian Brunner  ;;
906f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
907f27aaf4bSChristian Brunner  ;;
9088c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
9098c84cf11SSergei Trofimovich  ;;
9108c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
9118c84cf11SSergei Trofimovich  ;;
912111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
913111a38b0SRobert Relyea  ;;
914111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
915111a38b0SRobert Relyea  ;;
9162b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
9172b2325ffSGerd Hoffmann  ;;
9182b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
9192b2325ffSGerd Hoffmann  ;;
92069354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
92169354a83SHans de Goede  ;;
92269354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
92369354a83SHans de Goede  ;;
9241ece9905SAlon Levy  --disable-zlib-test) zlib="no"
9251ece9905SAlon Levy  ;;
926d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
927d138cee9SMichael Roth  ;;
928d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
929d138cee9SMichael Roth  ;;
9304b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
9314b1c11fdSDaniel P. Berrange  ;;
9324b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
9334b1c11fdSDaniel P. Berrange  ;;
934f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
935f794573eSEduardo Otubo  ;;
936f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
937f794573eSEduardo Otubo  ;;
938eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
939eb100396SBharata B Rao  ;;
940eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
941eb100396SBharata B Rao  ;;
942583f6e7bSStefan Hajnoczi  --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
943583f6e7bSStefan Hajnoczi  ;;
944583f6e7bSStefan Hajnoczi  --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
945583f6e7bSStefan Hajnoczi  ;;
946a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
947a4ccabcfSAnthony Liguori  ;;
948a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
949a4ccabcfSAnthony Liguori  ;;
9502da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
9512da776dbSMichael R. Hines  ;;
9522da776dbSMichael R. Hines  --disable-rdma) rdma="no"
9532da776dbSMichael R. Hines  ;;
954528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
955528de90aSDaniel P. Berrange  ;;
956ab214c29SStefan Berger  --enable-tpm) tpm="yes"
957ab214c29SStefan Berger  ;;
9580a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
9590a12ec87SRichard W.M. Jones  ;;
9600a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
9610a12ec87SRichard W.M. Jones  ;;
9627f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
9637f1559c6Sbalrog  ;;
9647d13299dSbellard  esac
9657d13299dSbellarddone
9667d13299dSbellard
96740293e58Sbellardcase "$cpu" in
9689b9c37c3SRichard Henderson    sparc)
9690c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
97079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32 -mcpu=ultrasparc"
9713142255cSblueswir1           ;;
972ed968ff1SJuan Quintela    sparc64)
9730c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
97479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
9753142255cSblueswir1           ;;
97676d83bdeSths    s390)
97779f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m31 -march=z990"
97828d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
97928d7cc49SRichard Henderson           ;;
98028d7cc49SRichard Henderson    s390x)
98179f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -march=z990"
98228d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
98376d83bdeSths           ;;
98440293e58Sbellard    i386)
98579f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
9860c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
9872b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
98840293e58Sbellard           ;;
98940293e58Sbellard    x86_64)
99079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64"
9910c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
9922b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
993379f6698SPaul Brook           ;;
994c72b26ecSRichard Henderson    x32)
995c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
996c72b26ecSRichard Henderson           LDFLAGS="-mx32 $LDFLAGS"
997c72b26ecSRichard Henderson           cc_i386='$(CC) -m32'
998c72b26ecSRichard Henderson           ;;
99930163d89SPeter Maydell    # No special flags required for other host CPUs
10003142255cSblueswir1esac
10013142255cSblueswir1
100279f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
100379f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
100479f3b12fSPeter Crosthwaite
100560e0df25SPeter Maydelldefault_target_list=""
100660e0df25SPeter Maydell
10076e92f823SPeter Maydellmak_wilds=""
10086e92f823SPeter Maydell
100960e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
10106e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
101160e0df25SPeter Maydellfi
101260e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
10136e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
101460e0df25SPeter Maydellfi
101560e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
10166e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
101760e0df25SPeter Maydellfi
101860e0df25SPeter Maydell
10196e92f823SPeter Maydellfor config in $mak_wilds; do
10206e92f823SPeter Maydell    default_target_list="${default_target_list} $(basename "$config" .mak)"
10216e92f823SPeter Maydelldone
10226e92f823SPeter Maydell
1023af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1024af5db58eSpbrookcat << EOF
1025af5db58eSpbrook
1026af5db58eSpbrookUsage: configure [options]
1027af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1028af5db58eSpbrook
1029af5db58eSpbrookEOF
1030af5db58eSpbrookecho "Standard options:"
1031af5db58eSpbrookecho "  --help                   print this message"
1032af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
1033af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
1034af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
103560e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
103660e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
103760e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
1038af5db58eSpbrookecho ""
1039af5db58eSpbrookecho "Advanced options (experts only):"
1040af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
1041af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
1042af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
10430bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
10440bfe8cc0SPaolo Bonziniecho "                           build time"
1045*83f73fceSTomoki Sekiyamaecho "  --cxx=CXX                use C++ compiler CXX [$cxx]"
10463c4a4d0dSPeter Maydellecho "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
1047a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
1048e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
1049af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
10506a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
1051c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
1052e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
1053af5db58eSpbrookecho "  --static                 enable static build [$static]"
10540b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
1055023d3d67SEduardo Habkostecho "  --datadir=PATH           install firmware in PATH$confsuffix"
1056023d3d67SEduardo Habkostecho "  --docdir=PATH            install documentation in PATH$confsuffix"
10570b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
1058a7b66fa7SDoug Goldsteinecho "  --libdir=PATH            install libraries in PATH"
1059023d3d67SEduardo Habkostecho "  --sysconfdir=PATH        install config in PATH$confsuffix"
10605a699bbbSLaszlo Ersekecho "  --localstatedir=PATH     install local state in PATH (set at runtime on win32)"
10612ae4748fSStefan Weilecho "  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1062f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
1063f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
10649941afdeSDunrong Huangecho "  --enable-debug-info       enable debugging information (default)"
10659941afdeSDunrong Huangecho "  --disable-debug-info      disable debugging information"
106609695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
1067890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
1068890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
10691625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
107085aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
1071fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
1072c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
1073ab400449SHu Taoecho "  --disable-gtk            disable gtk UI"
1074ab400449SHu Taoecho "  --enable-gtk             enable gtk UI"
1075983eef5aSMeador Ingeecho "  --disable-virtfs         disable VirtFS"
1076983eef5aSMeador Ingeecho "  --enable-virtfs          enable VirtFS"
1077821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
1078821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
107914821030SPavel Borzenkovecho "  --disable-cocoa          disable Cocoa (Mac OS X only)"
108014821030SPavel Borzenkovecho "  --enable-cocoa           enable Cocoa (default on Mac OS X)"
1081c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
1082c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
1083b64ec4e4SFam Zhengecho "  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L"
1084b64ec4e4SFam Zhengecho "  --block-drv-rw-whitelist=L"
1085b64ec4e4SFam Zhengecho "                           set block driver read-write whitelist"
1086b64ec4e4SFam Zhengecho "                           (affects only QEMU, not qemu-img)"
1087b64ec4e4SFam Zhengecho "  --block-drv-ro-whitelist=L"
1088b64ec4e4SFam Zhengecho "                           set block driver read-only whitelist"
1089eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
10908ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
1091e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
1092fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
1093eb6fda0fSAnthony PERARDecho "  --disable-xen-pci-passthrough"
1094eb6fda0fSAnthony PERARDecho "  --enable-xen-pci-passthrough"
10952e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
10964ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
10978d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
10981be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
10992f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1100ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
11012f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
11022f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
110396763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1104efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
11057536ee4bSTim Hardeckecho "  --disable-vnc-ws         disable Websockets support for VNC server"
11067536ee4bSTim Hardeckecho "  --enable-vnc-ws          enable Websockets support for VNC server"
1107af896aaaSpbrookecho "  --disable-curses         disable curses output"
1108c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1109769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1110788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
11112df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
11122df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
1113fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1114a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
11156093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
11167ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1117b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
11182da776dbSMichael R. Hinesecho "  --disable-rdma           disable RDMA-based migration support"
11192da776dbSMichael R. Hinesecho "  --enable-rdma            enable RDMA-based migration support"
11209195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1121af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1122af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
11230953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
11240953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1125831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1126831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
112784778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
112884778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1129379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1130379f6698SPaul Brookecho "                           emulation targets"
1131379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
113240d6444eSAvi Kivityecho "  --enable-pie             build Position Independent Executables"
113340d6444eSAvi Kivityecho "  --disable-pie            do not build Position Independent Executables"
1134af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1135af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
11362f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1137c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1138235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
1139ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1140ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1141e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1142dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
11435c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
11445c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
114547e98658SCorey Bryantecho "  --disable-cap-ng         disable libcap-ng support"
114647e98658SCorey Bryantecho "  --enable-cap-ng          enable libcap-ng support"
1147758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1148758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
114977755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1150d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1151d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1152d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1153d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1154320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1155650ab98dSLluís Vilanovaecho "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
115674242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
11579410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1158cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1159cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1160f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1161c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1162c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
1163111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1164111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
11652b2325ffSGerd Hoffmannecho "  --disable-libusb         disable libusb (for usb passthrough)"
11662b2325ffSGerd Hoffmannecho "  --enable-libusb          enable libusb (for usb passthrough)"
116769354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
116869354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1169d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1170d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1171f794573eSEduardo Otuboecho "  --disable-seccomp        disable seccomp support"
1172f794573eSEduardo Otuboecho "  --enable-seccomp         enables seccomp support"
1173519175a2SAlex Barceloecho "  --with-coroutine=BACKEND coroutine backend. Supported options:"
1174fe91bfa8SAlex Barceloecho "                           gthread, ucontext, sigaltstack, windows"
1175eb100396SBharata B Raoecho "  --enable-glusterfs       enable GlusterFS backend"
1176eb100396SBharata B Raoecho "  --disable-glusterfs      disable GlusterFS backend"
11771d728c39SBlue Swirlecho "  --enable-gcov            enable test coverage analysis with gcov"
11781d728c39SBlue Swirlecho "  --gcov=GCOV              use specified gcov [$gcov_tool]"
1179ab214c29SStefan Bergerecho "  --enable-tpm             enable TPM support"
11800a12ec87SRichard W.M. Jonesecho "  --disable-libssh2        disable ssh block device support"
11810a12ec87SRichard W.M. Jonesecho "  --enable-libssh2         enable ssh block device support"
1182af5db58eSpbrookecho ""
11835bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1184af5db58eSpbrookexit 1
1185af5db58eSpbrookfi
1186af5db58eSpbrook
1187359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1188359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1189359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1190359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1191359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1192359bc95dSPeter Maydell        ARCH=tci
1193359bc95dSPeter Maydell    else
119476ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1195359bc95dSPeter Maydell    fi
1196359bc95dSPeter Maydellfi
1197359bc95dSPeter Maydell
11988d05095cSPaolo Bonzini# check that the C compiler works.
11998d05095cSPaolo Bonzinicat > $TMPC <<EOF
120075cafad7SStefan Weilint main(void) { return 0; }
12018d05095cSPaolo BonziniEOF
12028d05095cSPaolo Bonzini
12038d05095cSPaolo Bonziniif compile_object ; then
12048d05095cSPaolo Bonzini  : C compiler works ok
12058d05095cSPaolo Bonzinielse
120676ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
12078d05095cSPaolo Bonzinifi
12088d05095cSPaolo Bonzini
1209417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1210417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1211417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1212417c9d72SAlexander Graf
1213417c9d72SAlexander Grafif test -z "$werror" ; then
12146c8fec83SAndreas Färber    if test -d "$source_path/.git" -a \
1215417c9d72SAlexander Graf        "$linux" = "yes" ; then
1216417c9d72SAlexander Graf        werror="yes"
1217417c9d72SAlexander Graf    else
1218417c9d72SAlexander Graf        werror="no"
1219417c9d72SAlexander Graf    fi
1220417c9d72SAlexander Graffi
1221417c9d72SAlexander Graf
12228d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
12238d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
12248d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
122537746c5eSMarc-André Lureaugcc_flags="-Wendif-labels $gcc_flags"
1226c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
122771429097SPeter Maydellgcc_flags="-Wno-string-plus-int $gcc_flags"
12286ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
12296ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
12306ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
12316ca026cbSPeter Maydell# so it's too error prone.
12328d05095cSPaolo Bonzinicat > $TMPC << EOF
12338d05095cSPaolo Bonziniint main(void) { return 0; }
12348d05095cSPaolo BonziniEOF
12358d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1236a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1237a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1238a1d29d6cSPeter Maydell    # warning options).
1239a1d29d6cSPeter Maydell    optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1240a1d29d6cSPeter Maydell    if compile_prog "-Werror $optflag" "" ; then
12418d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
12428d05095cSPaolo Bonzini    fi
12438d05095cSPaolo Bonzinidone
12448d05095cSPaolo Bonzini
124537746c5eSMarc-André Lureauif compile_prog "-Werror -fstack-protector-all" "" ; then
124637746c5eSMarc-André Lureau    QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
124737746c5eSMarc-André Lureau    LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
124837746c5eSMarc-André Lureaufi
124937746c5eSMarc-André Lureau
1250cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1251cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1252cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1253cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1254cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1255cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1256cbdd1999SPaolo Bonziniint main(void) { return 0; }
1257cbdd1999SPaolo Bonzini#else
1258cbdd1999SPaolo Bonzini#error No bug in this compiler.
1259cbdd1999SPaolo Bonzini#endif
1260cbdd1999SPaolo BonziniEOF
1261cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1262cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1263cbdd1999SPaolo Bonzinifi
1264cbdd1999SPaolo Bonzini
126540d6444eSAvi Kivityif test "$static" = "yes" ; then
126640d6444eSAvi Kivity  if test "$pie" = "yes" ; then
126776ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
126840d6444eSAvi Kivity  else
126940d6444eSAvi Kivity    pie="no"
127040d6444eSAvi Kivity  fi
127140d6444eSAvi Kivityfi
127240d6444eSAvi Kivity
127340d6444eSAvi Kivityif test "$pie" = ""; then
127440d6444eSAvi Kivity  case "$cpu-$targetos" in
1275c72b26ecSRichard Henderson    i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
127640d6444eSAvi Kivity      ;;
127740d6444eSAvi Kivity    *)
127840d6444eSAvi Kivity      pie="no"
127940d6444eSAvi Kivity      ;;
128040d6444eSAvi Kivity  esac
128140d6444eSAvi Kivityfi
128240d6444eSAvi Kivity
128340d6444eSAvi Kivityif test "$pie" != "no" ; then
128440d6444eSAvi Kivity  cat > $TMPC << EOF
128521d4a791SAvi Kivity
128621d4a791SAvi Kivity#ifdef __linux__
128721d4a791SAvi Kivity#  define THREAD __thread
128821d4a791SAvi Kivity#else
128921d4a791SAvi Kivity#  define THREAD
129021d4a791SAvi Kivity#endif
129121d4a791SAvi Kivity
129221d4a791SAvi Kivitystatic THREAD int tls_var;
129321d4a791SAvi Kivity
129421d4a791SAvi Kivityint main(void) { return tls_var; }
129521d4a791SAvi Kivity
129640d6444eSAvi KivityEOF
129740d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
129840d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
129940d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
130040d6444eSAvi Kivity    pie="yes"
130140d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
130240d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
130340d6444eSAvi Kivity    fi
130440d6444eSAvi Kivity  else
130540d6444eSAvi Kivity    if test "$pie" = "yes"; then
130676ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
130740d6444eSAvi Kivity    else
130840d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
130940d6444eSAvi Kivity      pie="no"
131040d6444eSAvi Kivity    fi
131140d6444eSAvi Kivity  fi
131240d6444eSAvi Kivityfi
131340d6444eSAvi Kivity
131409dada40SPaolo Bonzini##########################################
131509dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
131609dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
131709dada40SPaolo Bonzini# specification is necessary
131809dada40SPaolo Bonzini
131909dada40SPaolo Bonziniif test "$cpu" = "i386"; then
132009dada40SPaolo Bonzini  cat > $TMPC << EOF
132109dada40SPaolo Bonzinistatic int sfaa(int *ptr)
132209dada40SPaolo Bonzini{
132309dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
132409dada40SPaolo Bonzini}
132509dada40SPaolo Bonzini
132609dada40SPaolo Bonziniint main(void)
132709dada40SPaolo Bonzini{
132809dada40SPaolo Bonzini  int val = 42;
13291405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
133009dada40SPaolo Bonzini  sfaa(&val);
133109dada40SPaolo Bonzini  return val;
133209dada40SPaolo Bonzini}
133309dada40SPaolo BonziniEOF
133409dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
133509dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
133609dada40SPaolo Bonzini  fi
133709dada40SPaolo Bonzinifi
133809dada40SPaolo Bonzini
133909dada40SPaolo Bonzini#########################################
1340ec530c81Sbellard# Solaris specific configure tool chain decisions
134109dada40SPaolo Bonzini
1342ec530c81Sbellardif test "$solaris" = "yes" ; then
13436792aa11SLoïc Minier  if has $install; then
13446792aa11SLoïc Minier    :
13456792aa11SLoïc Minier  else
134676ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
134776ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
134876ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1349ec530c81Sbellard  fi
13506792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
135176ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
135276ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
135376ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1354ec530c81Sbellard  fi
13556792aa11SLoïc Minier  if has ar; then
13566792aa11SLoïc Minier    :
13576792aa11SLoïc Minier  else
1358ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
135976ad07a4SPeter Maydell      error_exit "No path includes ar" \
136076ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1361ec530c81Sbellard    fi
136276ad07a4SPeter Maydell    error_exit "No path includes ar"
1363ec530c81Sbellard  fi
1364ec530c81Sbellardfi
1365ec530c81Sbellard
13667a3fc891SSebastian Herbsztif ! has $python; then
136776ad07a4SPeter Maydell  error_exit "Python not found. Use --python=/path/to/python"
1368c886edfbSBlue Swirlfi
1369c886edfbSBlue Swirl
13706ccea1e4SPeter Maydell# Note that if the Python conditional here evaluates True we will exit
13716ccea1e4SPeter Maydell# with status 1 which is a shell 'false' value.
13721d984a67SStefan Weilif ! $python -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
137376ad07a4SPeter Maydell  error_exit "Cannot use '$python', Python 2.4 or later is required." \
137476ad07a4SPeter Maydell      "Note that Python 3 or later is not yet supported." \
137576ad07a4SPeter Maydell      "Use --python=/path/to/python to specify a supported Python."
13766ccea1e4SPeter Maydellfi
13776ccea1e4SPeter Maydell
1378afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1379121afa9eSAnthony Liguori    target_list="$default_target_list"
1380121afa9eSAnthony Liguorielse
1381121afa9eSAnthony Liguori    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
13825327cf48Sbellardfi
138325b48338SPeter Maydell
138425b48338SPeter Maydell# Check that we recognised the target name; this allows a more
138525b48338SPeter Maydell# friendly error message than if we let it fall through.
138625b48338SPeter Maydellfor target in $target_list; do
138725b48338SPeter Maydell    case " $default_target_list " in
138825b48338SPeter Maydell        *" $target "*)
138925b48338SPeter Maydell            ;;
139025b48338SPeter Maydell        *)
139125b48338SPeter Maydell            error_exit "Unknown target name '$target'"
139225b48338SPeter Maydell            ;;
139325b48338SPeter Maydell    esac
139425b48338SPeter Maydelldone
139525b48338SPeter Maydell
1396f55fe278SPaolo Bonzini# see if system emulation was really requested
1397f55fe278SPaolo Bonzinicase " $target_list " in
1398f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1399f55fe278SPaolo Bonzini  ;;
1400f55fe278SPaolo Bonzini  *) softmmu=no
1401f55fe278SPaolo Bonzini  ;;
1402f55fe278SPaolo Bonziniesac
14035327cf48Sbellard
1404249247c9SJuan Quintelafeature_not_found() {
1405249247c9SJuan Quintela  feature=$1
1406249247c9SJuan Quintela
140776ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
140876ad07a4SPeter Maydell      "configure was not able to find it"
1409249247c9SJuan Quintela}
1410249247c9SJuan Quintela
14117d13299dSbellardif test -z "$cross_prefix" ; then
14127d13299dSbellard
14137d13299dSbellard# ---
14147d13299dSbellard# big/little endian test
14157d13299dSbellardcat > $TMPC << EOF
14167d13299dSbellard#include <inttypes.h>
1417abab1a0fSStefan Weilint main(void) {
14187d13299dSbellard        volatile uint32_t i=0x01234567;
14197d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
14207d13299dSbellard}
14217d13299dSbellardEOF
14227d13299dSbellard
142352166aa0SJuan Quintelaif compile_prog "" "" ; then
14247d13299dSbellard$TMPE && bigendian="yes"
14257d13299dSbellardelse
14267d13299dSbellardecho big/little test failed
14277d13299dSbellardfi
14287d13299dSbellard
14297d13299dSbellardelse
14307d13299dSbellard
14317d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1432ea8f20f8SJuan Quintelacase "$cpu" in
143321d89f84SPeter Maydell  arm)
143421d89f84SPeter Maydell    # ARM can be either way; ask the compiler which one we are
143521d89f84SPeter Maydell    if check_define __ARMEB__; then
143621d89f84SPeter Maydell      bigendian=yes
143721d89f84SPeter Maydell    fi
143821d89f84SPeter Maydell  ;;
143921d89f84SPeter Maydell  hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1440ea8f20f8SJuan Quintela    bigendian=yes
1441ea8f20f8SJuan Quintela  ;;
1442ea8f20f8SJuan Quintelaesac
14437d13299dSbellard
14447d13299dSbellardfi
14457d13299dSbellard
1446b0a47e79SJuan Quintela##########################################
1447779ab5e3SStefan Weil# pkg-config probe
1448779ab5e3SStefan Weil
1449779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
145076ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1451779ab5e3SStefan Weilfi
1452779ab5e3SStefan Weil
1453779ab5e3SStefan Weil##########################################
1454b0a47e79SJuan Quintela# NPTL probe
1455b0a47e79SJuan Quintela
145624cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
1457bd0c5661Spbrook  cat > $TMPC <<EOF
1458bd0c5661Spbrook#include <sched.h>
145930813ceaSpbrook#include <linux/futex.h>
1460182eacc0SStefan Weilint main(void) {
1461bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1462bd0c5661Spbrook#error bork
1463bd0c5661Spbrook#endif
1464182eacc0SStefan Weil  return 0;
1465bd0c5661Spbrook}
1466bd0c5661SpbrookEOF
146724cb36a6SPeter Maydell  if ! compile_object ; then
1468b0a47e79SJuan Quintela    feature_not_found "nptl"
1469b0a47e79SJuan Quintela  fi
1470bd0c5661Spbrookfi
1471bd0c5661Spbrook
147211d9f695Sbellard##########################################
1473ac62922eSbalrog# zlib check
1474ac62922eSbalrog
14751ece9905SAlon Levyif test "$zlib" != "no" ; then
1476ac62922eSbalrog    cat > $TMPC << EOF
1477ac62922eSbalrog#include <zlib.h>
1478ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1479ac62922eSbalrogEOF
148052166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1481ac62922eSbalrog        :
1482ac62922eSbalrog    else
148376ad07a4SPeter Maydell        error_exit "zlib check failed" \
148476ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1485ac62922eSbalrog    fi
14861ece9905SAlon Levyfi
1487f544a488SPaolo Bonzinilibs_softmmu="$libs_softmmu -lz"
1488ac62922eSbalrog
1489ac62922eSbalrog##########################################
1490f794573eSEduardo Otubo# libseccomp check
1491f794573eSEduardo Otubo
1492f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
149365d5d3f9SStefan Weil    if $pkg_config --atleast-version=2.1.0 libseccomp; then
1494b4451996SMichael Tokarev        libs_softmmu="$libs_softmmu `$pkg_config --libs libseccomp`"
1495372e47e9SAndreas Färber        QEMU_CFLAGS="$QEMU_CFLAGS `$pkg_config --cflags libseccomp`"
1496f794573eSEduardo Otubo	seccomp="yes"
1497f794573eSEduardo Otubo    else
1498f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
1499f794573eSEduardo Otubo            feature_not_found "libseccomp"
1500f794573eSEduardo Otubo	fi
1501e84d5956SYann E. MORIN	seccomp="no"
1502f794573eSEduardo Otubo    fi
1503f794573eSEduardo Otubofi
1504f794573eSEduardo Otubo##########################################
1505e37630caSaliguori# xen probe
1506e37630caSaliguori
1507fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1508b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1509d5b93ddfSAnthony PERARD
151050ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
151150ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
151250ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
151350ced5b3SStefan Weil
151450ced5b3SStefan Weil  # Xen (any)
151550ced5b3SStefan Weil  cat > $TMPC <<EOF
151650ced5b3SStefan Weil#include <xenctrl.h>
151750ced5b3SStefan Weilint main(void) {
151850ced5b3SStefan Weil  return 0;
151950ced5b3SStefan Weil}
152050ced5b3SStefan WeilEOF
152150ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
152250ced5b3SStefan Weil    # Xen not found
152350ced5b3SStefan Weil    if test "$xen" = "yes" ; then
152450ced5b3SStefan Weil      feature_not_found "xen"
152550ced5b3SStefan Weil    fi
152650ced5b3SStefan Weil    xen=no
152750ced5b3SStefan Weil
1528d5b93ddfSAnthony PERARD  # Xen unstable
152969deef08SPeter Maydell  elif
153069deef08SPeter Maydell      cat > $TMPC <<EOF &&
1531e37630caSaliguori#include <xenctrl.h>
1532e108a3c1SAnthony PERARD#include <xenstore.h>
1533d5b93ddfSAnthony PERARD#include <stdint.h>
1534d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1535d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1536d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1537d5b93ddfSAnthony PERARD#endif
1538d5b93ddfSAnthony PERARDint main(void) {
1539d5b93ddfSAnthony PERARD  xc_interface *xc;
1540d5b93ddfSAnthony PERARD  xs_daemon_open();
1541d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1542d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1543d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1544b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
15458688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
15468688e065SStefano Stabellini  return 0;
15478688e065SStefano Stabellini}
15488688e065SStefano StabelliniEOF
15498688e065SStefano Stabellini      compile_prog "" "$xen_libs"
155069deef08SPeter Maydell    then
15518688e065SStefano Stabellini    xen_ctrl_version=420
15528688e065SStefano Stabellini    xen=yes
15538688e065SStefano Stabellini
155469deef08SPeter Maydell  elif
155569deef08SPeter Maydell      cat > $TMPC <<EOF &&
15568688e065SStefano Stabellini#include <xenctrl.h>
15578688e065SStefano Stabellini#include <xs.h>
15588688e065SStefano Stabellini#include <stdint.h>
15598688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
15608688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
15618688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
15628688e065SStefano Stabellini#endif
15638688e065SStefano Stabelliniint main(void) {
15648688e065SStefano Stabellini  xs_daemon_open();
15659b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
15668688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
15678688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
15688688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1569d5b93ddfSAnthony PERARD  return 0;
1570d5b93ddfSAnthony PERARD}
1571e37630caSaliguoriEOF
157250ced5b3SStefan Weil      compile_prog "" "$xen_libs"
157369deef08SPeter Maydell    then
1574d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1575fc321b4bSJuan Quintela    xen=yes
1576d5b93ddfSAnthony PERARD
1577d5b93ddfSAnthony PERARD  # Xen 4.0.0
157869deef08SPeter Maydell  elif
157969deef08SPeter Maydell      cat > $TMPC <<EOF &&
1580d5b93ddfSAnthony PERARD#include <xenctrl.h>
1581d5b93ddfSAnthony PERARD#include <xs.h>
1582d5b93ddfSAnthony PERARD#include <stdint.h>
1583d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1584d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1585d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1586d5b93ddfSAnthony PERARD#endif
1587d5b93ddfSAnthony PERARDint main(void) {
1588b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1589b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1590b87de24eSAnthony PERARD  };
1591d5b93ddfSAnthony PERARD  xs_daemon_open();
1592d5b93ddfSAnthony PERARD  xc_interface_open();
1593d5b93ddfSAnthony PERARD  xc_gnttab_open();
1594d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1595b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1596d5b93ddfSAnthony PERARD  return 0;
1597d5b93ddfSAnthony PERARD}
1598d5b93ddfSAnthony PERARDEOF
1599d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
160069deef08SPeter Maydell    then
1601d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1602d5b93ddfSAnthony PERARD    xen=yes
1603d5b93ddfSAnthony PERARD
1604b87de24eSAnthony PERARD  # Xen 3.4.0
160569deef08SPeter Maydell  elif
160669deef08SPeter Maydell      cat > $TMPC <<EOF &&
1607b87de24eSAnthony PERARD#include <xenctrl.h>
1608b87de24eSAnthony PERARD#include <xs.h>
1609b87de24eSAnthony PERARDint main(void) {
1610b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1611b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1612b87de24eSAnthony PERARD  };
1613b87de24eSAnthony PERARD  xs_daemon_open();
1614b87de24eSAnthony PERARD  xc_interface_open();
1615b87de24eSAnthony PERARD  xc_gnttab_open();
1616b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1617b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1618b87de24eSAnthony PERARD  return 0;
1619b87de24eSAnthony PERARD}
1620b87de24eSAnthony PERARDEOF
1621b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
162269deef08SPeter Maydell    then
1623b87de24eSAnthony PERARD    xen_ctrl_version=340
1624b87de24eSAnthony PERARD    xen=yes
1625b87de24eSAnthony PERARD
1626b87de24eSAnthony PERARD  # Xen 3.3.0
162769deef08SPeter Maydell  elif
162869deef08SPeter Maydell      cat > $TMPC <<EOF &&
1629d5b93ddfSAnthony PERARD#include <xenctrl.h>
1630d5b93ddfSAnthony PERARD#include <xs.h>
1631d5b93ddfSAnthony PERARDint main(void) {
1632d5b93ddfSAnthony PERARD  xs_daemon_open();
1633d5b93ddfSAnthony PERARD  xc_interface_open();
1634d5b93ddfSAnthony PERARD  xc_gnttab_open();
1635d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1636d5b93ddfSAnthony PERARD  return 0;
1637d5b93ddfSAnthony PERARD}
1638d5b93ddfSAnthony PERARDEOF
1639d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
164069deef08SPeter Maydell    then
1641d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1642d5b93ddfSAnthony PERARD    xen=yes
1643d5b93ddfSAnthony PERARD
164450ced5b3SStefan Weil  # Xen version unsupported
1645e37630caSaliguori  else
1646fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
164750ced5b3SStefan Weil      feature_not_found "xen (unsupported version)"
1648fc321b4bSJuan Quintela    fi
1649fc321b4bSJuan Quintela    xen=no
1650e37630caSaliguori  fi
1651d5b93ddfSAnthony PERARD
1652d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1653d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1654d5b93ddfSAnthony PERARD  fi
1655e37630caSaliguorifi
1656e37630caSaliguori
1657eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1658eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1659eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1660eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1661eb6fda0fSAnthony PERARD  else
1662eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1663eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
166476ad07a4SPeter Maydell        error_exit "User requested feature Xen PCI Passthrough" \
166576ad07a4SPeter Maydell            "This feature does not work with Xen 3.3"
1666eb6fda0fSAnthony PERARD      fi
166776ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
166876ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
1669eb6fda0fSAnthony PERARD    fi
1670eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1671eb6fda0fSAnthony PERARD  fi
1672eb6fda0fSAnthony PERARDfi
1673eb6fda0fSAnthony PERARD
1674e37630caSaliguori##########################################
167544dc0ca3SAlon Levy# libtool probe
167644dc0ca3SAlon Levy
16773f534581SBradif ! has $libtool; then
167844dc0ca3SAlon Levy    libtool=
167944dc0ca3SAlon Levyfi
168044dc0ca3SAlon Levy
16818e515b12SPeter Maydell# MacOSX ships with a libtool which isn't the GNU one; weed this
16828e515b12SPeter Maydell# out by checking whether libtool supports the --version switch
16838e515b12SPeter Maydellif test -n "$libtool"; then
16848e515b12SPeter Maydell  if ! "$libtool" --version >/dev/null 2>&1; then
16858e515b12SPeter Maydell    libtool=
16868e515b12SPeter Maydell  fi
16878e515b12SPeter Maydellfi
16888e515b12SPeter Maydell
168944dc0ca3SAlon Levy##########################################
1690dfffc653SJuan Quintela# Sparse probe
1691dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
16920dba6195SLoïc Minier  if has cgcc; then
1693dfffc653SJuan Quintela    sparse=yes
1694dfffc653SJuan Quintela  else
1695dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1696dfffc653SJuan Quintela      feature_not_found "sparse"
1697dfffc653SJuan Quintela    fi
1698dfffc653SJuan Quintela    sparse=no
1699dfffc653SJuan Quintela  fi
1700dfffc653SJuan Quintelafi
1701dfffc653SJuan Quintela
1702dfffc653SJuan Quintela##########################################
1703a4ccabcfSAnthony Liguori# GTK probe
1704a4ccabcfSAnthony Liguori
1705a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
1706528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
1707528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
1708528de90aSDaniel P. Berrange      gtkversion="3.0.0"
1709528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
1710528de90aSDaniel P. Berrange      vteversion="0.32.0"
1711528de90aSDaniel P. Berrange    else
1712528de90aSDaniel P. Berrange      gtkversion="2.18.0"
1713528de90aSDaniel P. Berrange      vtepackage="vte"
1714528de90aSDaniel P. Berrange      vteversion="0.24.0"
1715528de90aSDaniel P. Berrange    fi
17160d185e63SPeter Maydell    if ! $pkg_config --exists "$gtkpackage >= $gtkversion"; then
17170d185e63SPeter Maydell        if test "$gtk" = "yes" ; then
17180d185e63SPeter Maydell            feature_not_found "gtk"
17190d185e63SPeter Maydell        fi
17200d185e63SPeter Maydell        gtk="no"
17210d185e63SPeter Maydell    elif ! $pkg_config --exists "$vtepackage >= $vteversion"; then
17220d185e63SPeter Maydell        if test "$gtk" = "yes" ; then
17230d185e63SPeter Maydell            error_exit "libvte not found (required for gtk support)"
17240d185e63SPeter Maydell        fi
17250d185e63SPeter Maydell        gtk="no"
17260d185e63SPeter Maydell    else
1727ca871ec8SStefan Weil	gtk_cflags=`$pkg_config --cflags $gtkpackage`
1728ca871ec8SStefan Weil	gtk_libs=`$pkg_config --libs $gtkpackage`
1729ca871ec8SStefan Weil	vte_cflags=`$pkg_config --cflags $vtepackage`
1730ca871ec8SStefan Weil	vte_libs=`$pkg_config --libs $vtepackage`
1731a4ccabcfSAnthony Liguori	libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
1732a4ccabcfSAnthony Liguori	gtk="yes"
1733a4ccabcfSAnthony Liguori    fi
1734a4ccabcfSAnthony Liguorifi
1735a4ccabcfSAnthony Liguori
1736a4ccabcfSAnthony Liguori##########################################
173711d9f695Sbellard# SDL probe
173811d9f695Sbellard
17393ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
17403ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
17413ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
17423ec87ffeSPaolo Bonzini  sdl_config=sdl-config
17433ec87ffeSPaolo Bonzinifi
17443ec87ffeSPaolo Bonzini
174565d5d3f9SStefan Weilif $pkg_config sdl --exists; then
1746a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1747fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
17483ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
17493ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
17509316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1751a0dfd8a4SLoïc Minierelse
1752a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1753a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1754a0dfd8a4SLoïc Minier  fi
1755a0dfd8a4SLoïc Minier  sdl=no
17569316f803SPaolo Bonzinifi
175729e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
17583ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
17593ec87ffeSPaolo Bonzinifi
176011d9f695Sbellard
17619316f803SPaolo Bonzinisdl_too_old=no
1762c4198157SJuan Quintelaif test "$sdl" != "no" ; then
176311d9f695Sbellard  cat > $TMPC << EOF
176411d9f695Sbellard#include <SDL.h>
176511d9f695Sbellard#undef main /* We don't want SDL to override our main() */
176611d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
176711d9f695SbellardEOF
17689316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
176974f42e18STeLeMan  if test "$static" = "yes" ; then
177074f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
177174f42e18STeLeMan  else
17729316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
177374f42e18STeLeMan  fi
177452166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
177511d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
177611d9f695Sbellard      sdl_too_old=yes
177711d9f695Sbellard    else
1778fd677642Sths      if test "$cocoa" = "no" ; then
177911d9f695Sbellard        sdl=yes
178011d9f695Sbellard      fi
1781fd677642Sths    fi
17827c1f25b4Sbellard
178367c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
17841ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
178567c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1786f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1787f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
178811d9f695Sbellard      fi
178952166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
17901ac88f28SJuan Quintela	:
17911ac88f28SJuan Quintela      else
17921ac88f28SJuan Quintela        sdl=no
17937c1f25b4Sbellard      fi
17947c1f25b4Sbellard    fi # static link
1795c4198157SJuan Quintela  else # sdl not found
1796c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1797c4198157SJuan Quintela      feature_not_found "sdl"
1798c4198157SJuan Quintela    fi
1799c4198157SJuan Quintela    sdl=no
18007c1f25b4Sbellard  fi # sdl compile test
1801fd677642Sthsfi
180211d9f695Sbellard
18035368a422Saliguoriif test "$sdl" = "yes" ; then
18045368a422Saliguori  cat > $TMPC <<EOF
18055368a422Saliguori#include <SDL.h>
18065368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
18075368a422Saliguori#include <X11/XKBlib.h>
18085368a422Saliguori#else
18095368a422Saliguori#error No x11 support
18105368a422Saliguori#endif
18115368a422Saliguoriint main(void) { return 0; }
18125368a422SaliguoriEOF
181352166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1814681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
18155368a422Saliguori  fi
18160705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
18175368a422Saliguorifi
18185368a422Saliguori
18198f28f3fbSths##########################################
18202da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
18212da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
18222da776dbSMichael R. Hines  cat > $TMPC <<EOF
18232da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
18242da776dbSMichael R. Hinesint main(void) { return 0; }
18252da776dbSMichael R. HinesEOF
18262da776dbSMichael R. Hines  rdma_libs="-lrdmacm -libverbs"
18272da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
18282da776dbSMichael R. Hines    rdma="yes"
18292da776dbSMichael R. Hines    libs_softmmu="$libs_softmmu $rdma_libs"
18302da776dbSMichael R. Hines  else
18312da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
18322da776dbSMichael R. Hines        error_exit \
18332da776dbSMichael R. Hines            " OpenFabrics librdmacm/libibverbs not present." \
18342da776dbSMichael R. Hines            " Your options:" \
18352da776dbSMichael R. Hines            "  (1) Fast: Install infiniband packages from your distro." \
18362da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
18372da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
18382da776dbSMichael R. Hines    fi
18392da776dbSMichael R. Hines    rdma="no"
18402da776dbSMichael R. Hines  fi
18412da776dbSMichael R. Hinesfi
18422da776dbSMichael R. Hines
18432da776dbSMichael R. Hines##########################################
18447536ee4bSTim Hardeck# VNC TLS/WS detection
18457536ee4bSTim Hardeckif test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then
1846ae6b5e5aSaliguori  cat > $TMPC <<EOF
1847ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1848ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1849ae6b5e5aSaliguoriEOF
1850a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1851a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
185252166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
18537536ee4bSTim Hardeck    if test "$vnc_tls" != "no" ; then
18541be10ad2SJuan Quintela      vnc_tls=yes
18557536ee4bSTim Hardeck    fi
18567536ee4bSTim Hardeck    if test "$vnc_ws" != "no" ; then
18577536ee4bSTim Hardeck      vnc_ws=yes
18587536ee4bSTim Hardeck    fi
1859a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1860ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
1861ae6b5e5aSaliguori  else
18621be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
18631be10ad2SJuan Quintela      feature_not_found "vnc-tls"
18641be10ad2SJuan Quintela    fi
18657536ee4bSTim Hardeck    if test "$vnc_ws" = "yes" ; then
18667536ee4bSTim Hardeck      feature_not_found "vnc-ws"
18677536ee4bSTim Hardeck    fi
18681be10ad2SJuan Quintela    vnc_tls=no
18697536ee4bSTim Hardeck    vnc_ws=no
18708d5d2d4cSths  fi
18718d5d2d4cSthsfi
18728d5d2d4cSths
18738d5d2d4cSths##########################################
18742f9606b3Saliguori# VNC SASL detection
1875821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
18762f9606b3Saliguori  cat > $TMPC <<EOF
18772f9606b3Saliguori#include <sasl/sasl.h>
18782f9606b3Saliguori#include <stdio.h>
18792f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
18802f9606b3SaliguoriEOF
18812f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
18822f9606b3Saliguori  vnc_sasl_cflags=""
18832f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
188452166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1885ea784e3bSJuan Quintela    vnc_sasl=yes
1886fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1887ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
18882f9606b3Saliguori  else
1889ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1890ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1891ea784e3bSJuan Quintela    fi
1892ea784e3bSJuan Quintela    vnc_sasl=no
18932f9606b3Saliguori  fi
18942f9606b3Saliguorifi
18952f9606b3Saliguori
18962f9606b3Saliguori##########################################
18972f6f5c7aSCorentin Chary# VNC JPEG detection
1898821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
18992f6f5c7aSCorentin Charycat > $TMPC <<EOF
19002f6f5c7aSCorentin Chary#include <stdio.h>
19012f6f5c7aSCorentin Chary#include <jpeglib.h>
19022f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
19032f6f5c7aSCorentin CharyEOF
19042f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
19052f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
19062f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
19072f6f5c7aSCorentin Chary    vnc_jpeg=yes
19082f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1909ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
19102f6f5c7aSCorentin Chary  else
19112f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
19122f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
19132f6f5c7aSCorentin Chary    fi
19142f6f5c7aSCorentin Chary    vnc_jpeg=no
19152f6f5c7aSCorentin Chary  fi
19162f6f5c7aSCorentin Charyfi
19172f6f5c7aSCorentin Chary
19182f6f5c7aSCorentin Chary##########################################
1919efe556adSCorentin Chary# VNC PNG detection
1920821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1921efe556adSCorentin Charycat > $TMPC <<EOF
1922efe556adSCorentin Chary//#include <stdio.h>
1923efe556adSCorentin Chary#include <png.h>
1924832ce9c2SScott Wood#include <stddef.h>
1925efe556adSCorentin Charyint main(void) {
1926efe556adSCorentin Chary    png_structp png_ptr;
1927efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
19287edc3fedSPeter Maydell    return png_ptr != 0;
1929efe556adSCorentin Chary}
1930efe556adSCorentin CharyEOF
193165d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
1932ca871ec8SStefan Weil    vnc_png_cflags=`$pkg_config libpng --cflags`
1933ca871ec8SStefan Weil    vnc_png_libs=`$pkg_config libpng --libs`
19349af8025eSBrad  else
1935efe556adSCorentin Chary    vnc_png_cflags=""
1936efe556adSCorentin Chary    vnc_png_libs="-lpng"
19379af8025eSBrad  fi
1938efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1939efe556adSCorentin Chary    vnc_png=yes
1940efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
19419af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1942efe556adSCorentin Chary  else
1943efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1944efe556adSCorentin Chary      feature_not_found "vnc-png"
1945efe556adSCorentin Chary    fi
1946efe556adSCorentin Chary    vnc_png=no
1947efe556adSCorentin Chary  fi
1948efe556adSCorentin Charyfi
1949efe556adSCorentin Chary
1950efe556adSCorentin Chary##########################################
195176655d6dSaliguori# fnmatch() probe, used for ACL routines
195276655d6dSaliguorifnmatch="no"
195376655d6dSaliguoricat > $TMPC << EOF
195476655d6dSaliguori#include <fnmatch.h>
195576655d6dSaliguoriint main(void)
195676655d6dSaliguori{
195776655d6dSaliguori    fnmatch("foo", "foo", 0);
195876655d6dSaliguori    return 0;
195976655d6dSaliguori}
196076655d6dSaliguoriEOF
196152166aa0SJuan Quintelaif compile_prog "" "" ; then
196276655d6dSaliguori   fnmatch="yes"
196376655d6dSaliguorifi
196476655d6dSaliguori
196576655d6dSaliguori##########################################
1966ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
19672d16c8e9SPeter Maydell# Note that on some systems (notably MacOSX) no extra library
19682d16c8e9SPeter Maydell# need be linked to get the uuid functions.
1969ee682d27SStefan Weilif test "$uuid" != "no" ; then
1970ee682d27SStefan Weil  uuid_libs="-luuid"
1971ee682d27SStefan Weil  cat > $TMPC << EOF
1972ee682d27SStefan Weil#include <uuid/uuid.h>
1973ee682d27SStefan Weilint main(void)
1974ee682d27SStefan Weil{
1975ee682d27SStefan Weil    uuid_t my_uuid;
1976ee682d27SStefan Weil    uuid_generate(my_uuid);
1977ee682d27SStefan Weil    return 0;
1978ee682d27SStefan Weil}
1979ee682d27SStefan WeilEOF
19802d16c8e9SPeter Maydell  if compile_prog "" "" ; then
19812d16c8e9SPeter Maydell    uuid="yes"
19822d16c8e9SPeter Maydell  elif compile_prog "" "$uuid_libs" ; then
1983ee682d27SStefan Weil    uuid="yes"
1984ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1985ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1986ee682d27SStefan Weil  else
1987ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1988ee682d27SStefan Weil      feature_not_found "uuid"
1989ee682d27SStefan Weil    fi
1990ee682d27SStefan Weil    uuid=no
1991ee682d27SStefan Weil  fi
1992ee682d27SStefan Weilfi
1993ee682d27SStefan Weil
1994ee682d27SStefan Weil##########################################
1995dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1996dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1997dce512deSChristoph Hellwig  cat > $TMPC << EOF
1998ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
1999dce512deSChristoph Hellwig#include <xfs/xfs.h>
2000dce512deSChristoph Hellwigint main(void)
2001dce512deSChristoph Hellwig{
2002dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2003dce512deSChristoph Hellwig    return 0;
2004dce512deSChristoph Hellwig}
2005dce512deSChristoph HellwigEOF
2006dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2007dce512deSChristoph Hellwig    xfs="yes"
2008dce512deSChristoph Hellwig  else
2009dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
2010dce512deSChristoph Hellwig      feature_not_found "xfs"
2011dce512deSChristoph Hellwig    fi
2012dce512deSChristoph Hellwig    xfs=no
2013dce512deSChristoph Hellwig  fi
2014dce512deSChristoph Hellwigfi
2015dce512deSChristoph Hellwig
2016dce512deSChristoph Hellwig##########################################
20178a16d273Sths# vde libraries probe
2018dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
20194baae0acSJuan Quintela  vde_libs="-lvdeplug"
20208a16d273Sths  cat > $TMPC << EOF
20218a16d273Sths#include <libvdeplug.h>
20224a7f0e06Spbrookint main(void)
20234a7f0e06Spbrook{
20244a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2025fea08e08SPeter Maydell    char s[] = "";
2026fea08e08SPeter Maydell    vde_open(s, s, &a);
20274a7f0e06Spbrook    return 0;
20284a7f0e06Spbrook}
20298a16d273SthsEOF
203052166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
20314baae0acSJuan Quintela    vde=yes
20328e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
20338e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2034dfb278bdSJuan Quintela  else
2035dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
2036dfb278bdSJuan Quintela      feature_not_found "vde"
2037dfb278bdSJuan Quintela    fi
2038dfb278bdSJuan Quintela    vde=no
20398a16d273Sths  fi
20408a16d273Sthsfi
20418a16d273Sths
20428a16d273Sths##########################################
204347e98658SCorey Bryant# libcap-ng library probe
204447e98658SCorey Bryantif test "$cap_ng" != "no" ; then
204547e98658SCorey Bryant  cap_libs="-lcap-ng"
204647e98658SCorey Bryant  cat > $TMPC << EOF
204747e98658SCorey Bryant#include <cap-ng.h>
204847e98658SCorey Bryantint main(void)
204947e98658SCorey Bryant{
205047e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
205147e98658SCorey Bryant    return 0;
205247e98658SCorey Bryant}
205347e98658SCorey BryantEOF
205447e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
205547e98658SCorey Bryant    cap_ng=yes
205647e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
205747e98658SCorey Bryant  else
205847e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
205947e98658SCorey Bryant      feature_not_found "cap_ng"
206047e98658SCorey Bryant    fi
206147e98658SCorey Bryant    cap_ng=no
206247e98658SCorey Bryant  fi
206347e98658SCorey Bryantfi
206447e98658SCorey Bryant
206547e98658SCorey Bryant##########################################
2066c2de5c91Smalc# Sound support libraries probe
20678f28f3fbSths
2068c2de5c91Smalcaudio_drv_probe()
2069c2de5c91Smalc{
2070c2de5c91Smalc    drv=$1
2071c2de5c91Smalc    hdr=$2
2072c2de5c91Smalc    lib=$3
2073c2de5c91Smalc    exp=$4
2074c2de5c91Smalc    cfl=$5
20758f28f3fbSths        cat > $TMPC << EOF
2076c2de5c91Smalc#include <$hdr>
2077c2de5c91Smalcint main(void) { $exp }
20788f28f3fbSthsEOF
207952166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
20808f28f3fbSths        :
20818f28f3fbSths    else
208276ad07a4SPeter Maydell        error_exit "$drv check failed" \
208376ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
20848f28f3fbSths    fi
2085c2de5c91Smalc}
2086c2de5c91Smalc
20872fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
2088c2de5c91Smalcfor drv in $audio_drv_list; do
2089c2de5c91Smalc    case $drv in
2090c2de5c91Smalc    alsa)
2091c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
2092e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
2093a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
2094c2de5c91Smalc    ;;
2095c2de5c91Smalc
2096c2de5c91Smalc    fmod)
2097c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
209876ad07a4SPeter Maydell        error_exit "You must specify path to FMOD library and headers" \
209976ad07a4SPeter Maydell            "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
21008f28f3fbSths    fi
2101c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
2102a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
2103c2de5c91Smalc    ;;
2104c2de5c91Smalc
2105c2de5c91Smalc    esd)
2106c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
2107a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
210867f86e8eSJuan Quintela    audio_pt_int="yes"
2109c2de5c91Smalc    ;;
2110b8e59f18Smalc
2111b8e59f18Smalc    pa)
2112a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
2113a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
2114a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
211567f86e8eSJuan Quintela    audio_pt_int="yes"
2116b8e59f18Smalc    ;;
2117b8e59f18Smalc
2118997e690aSJuan Quintela    coreaudio)
2119997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
2120997e690aSJuan Quintela    ;;
2121997e690aSJuan Quintela
2122a4bf6780SJuan Quintela    dsound)
2123a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2124d5631638Smalc      audio_win_int="yes"
2125a4bf6780SJuan Quintela    ;;
2126a4bf6780SJuan Quintela
2127a4bf6780SJuan Quintela    oss)
2128a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
2129a4bf6780SJuan Quintela    ;;
2130a4bf6780SJuan Quintela
2131a4bf6780SJuan Quintela    sdl|wav)
21322f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
21332f6a1ab0Sblueswir1    ;;
21342f6a1ab0Sblueswir1
2135d5631638Smalc    winwave)
2136d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
2137d5631638Smalc      audio_win_int="yes"
2138d5631638Smalc    ;;
2139d5631638Smalc
2140e4c63a6aSmalc    *)
21411c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
214276ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
214376ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
2144e4c63a6aSmalc    }
2145e4c63a6aSmalc    ;;
2146c2de5c91Smalc    esac
2147c2de5c91Smalcdone
21488f28f3fbSths
21494d3b6f6eSbalrog##########################################
21502e4d9fb1Saurel32# BrlAPI probe
21512e4d9fb1Saurel32
21524ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2153eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
21542e4d9fb1Saurel32  cat > $TMPC << EOF
21552e4d9fb1Saurel32#include <brlapi.h>
2156832ce9c2SScott Wood#include <stddef.h>
21572e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
21582e4d9fb1Saurel32EOF
215952166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
21602e4d9fb1Saurel32    brlapi=yes
2161264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
21624ffcedb6SJuan Quintela  else
21634ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
21644ffcedb6SJuan Quintela      feature_not_found "brlapi"
21654ffcedb6SJuan Quintela    fi
21664ffcedb6SJuan Quintela    brlapi=no
2167eb82284fSJuan Quintela  fi
2168eb82284fSJuan Quintelafi
21692e4d9fb1Saurel32
21702e4d9fb1Saurel32##########################################
21714d3b6f6eSbalrog# curses probe
2172a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
2173e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
2174e095e2f3SStefan Weil    curses_list="-lpdcurses"
2175e095e2f3SStefan Weil  else
2176cfeda5f4SEd Maste    curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
2177e095e2f3SStefan Weil  fi
2178c584a6d0SJuan Quintela  curses_found=no
21794d3b6f6eSbalrog  cat > $TMPC << EOF
21804d3b6f6eSbalrog#include <curses.h>
2181ef9a2524SStefan Weilint main(void) {
2182ef9a2524SStefan Weil  const char *s = curses_version();
2183ef9a2524SStefan Weil  resize_term(0, 0);
2184ef9a2524SStefan Weil  return s != 0;
2185ef9a2524SStefan Weil}
21864d3b6f6eSbalrogEOF
2187ecbe251fSVadim Evard  IFS=:
21884f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
2189ecbe251fSVadim Evard    unset IFS
21904f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2191c584a6d0SJuan Quintela      curses_found=yes
21924f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
21934f78ef9aSJuan Quintela      break
21944d3b6f6eSbalrog    fi
21954f78ef9aSJuan Quintela  done
2196ecbe251fSVadim Evard  unset IFS
2197c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2198c584a6d0SJuan Quintela    curses=yes
2199c584a6d0SJuan Quintela  else
2200c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
2201c584a6d0SJuan Quintela      feature_not_found "curses"
2202c584a6d0SJuan Quintela    fi
2203c584a6d0SJuan Quintela    curses=no
2204c584a6d0SJuan Quintela  fi
22054f78ef9aSJuan Quintelafi
22064d3b6f6eSbalrog
2207414f0dabSblueswir1##########################################
2208769ce76dSAlexander Graf# curl probe
2209a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
221065d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
2211a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
22124e2b0658SPaolo Bonzini  else
22134e2b0658SPaolo Bonzini    curlconfig=curl-config
22144e2b0658SPaolo Bonzini  fi
2215769ce76dSAlexander Graf  cat > $TMPC << EOF
2216769ce76dSAlexander Graf#include <curl/curl.h>
22170b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2218769ce76dSAlexander GrafEOF
22194e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
22204e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2221b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2222769ce76dSAlexander Graf    curl=yes
2223f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2224f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2225788c8196SJuan Quintela  else
2226788c8196SJuan Quintela    if test "$curl" = "yes" ; then
2227788c8196SJuan Quintela      feature_not_found "curl"
2228788c8196SJuan Quintela    fi
2229788c8196SJuan Quintela    curl=no
2230769ce76dSAlexander Graf  fi
2231769ce76dSAlexander Graffi # test "$curl"
2232769ce76dSAlexander Graf
2233769ce76dSAlexander Graf##########################################
2234fb599c9aSbalrog# bluez support probe
2235a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2236e820e3f4Sbalrog  cat > $TMPC << EOF
2237e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2238e820e3f4Sbalrogint main(void) { return bt_error(0); }
2239e820e3f4SbalrogEOF
2240a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2241a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
224252166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2243a20a6f46SJuan Quintela    bluez=yes
2244e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2245e820e3f4Sbalrog  else
2246a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
2247a20a6f46SJuan Quintela      feature_not_found "bluez"
2248a20a6f46SJuan Quintela    fi
2249e820e3f4Sbalrog    bluez="no"
2250e820e3f4Sbalrog  fi
2251fb599c9aSbalrogfi
2252fb599c9aSbalrog
2253fb599c9aSbalrog##########################################
2254e18df141SAnthony Liguori# glib support probe
2255a52d28afSPaolo Bonzini
2256a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2257a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2258a52d28afSPaolo Bonzini    glib_req_ver=2.20
2259a52d28afSPaolo Bonzinielse
2260a52d28afSPaolo Bonzini    glib_req_ver=2.12
2261a52d28afSPaolo Bonzinifi
226265d5d3f9SStefan Weilif $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then
2263ca871ec8SStefan Weil    glib_cflags=`$pkg_config --cflags gthread-2.0`
2264ca871ec8SStefan Weil    glib_libs=`$pkg_config --libs gthread-2.0`
226514015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2266957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2267e18df141SAnthony Liguorielse
226876ad07a4SPeter Maydell    error_exit "glib-$glib_req_ver required to compile QEMU"
2269e18df141SAnthony Liguorifi
2270e18df141SAnthony Liguori
2271e18df141SAnthony Liguori##########################################
2272e2134eb9SGerd Hoffmann# pixman support probe
2273e2134eb9SGerd Hoffmann
2274e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
227574880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
227674880fe2SRobert Schiele    pixman="none"
227774880fe2SRobert Schiele  elif $pkg_config pixman-1 > /dev/null 2>&1; then
2278e2134eb9SGerd Hoffmann    pixman="system"
2279e2134eb9SGerd Hoffmann  else
2280e2134eb9SGerd Hoffmann    pixman="internal"
2281e2134eb9SGerd Hoffmann  fi
2282e2134eb9SGerd Hoffmannfi
228374880fe2SRobert Schieleif test "$pixman" = "none"; then
228474880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
228576ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
228676ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
228776ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
228876ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
228974880fe2SRobert Schiele  fi
229074880fe2SRobert Schiele  pixman_cflags=
229174880fe2SRobert Schiele  pixman_libs=
229274880fe2SRobert Schieleelif test "$pixman" = "system"; then
2293ca871ec8SStefan Weil  pixman_cflags=`$pkg_config --cflags pixman-1`
2294ca871ec8SStefan Weil  pixman_libs=`$pkg_config --libs pixman-1`
2295e2134eb9SGerd Hoffmannelse
2296e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
229776ad07a4SPeter Maydell    error_exit "pixman not present. Your options:" \
229876ad07a4SPeter Maydell        "  (1) Preferred: Install the pixman devel package (any recent" \
229976ad07a4SPeter Maydell        "      distro should have packages as Xorg needs pixman too)." \
230076ad07a4SPeter Maydell        "  (2) Fetch the pixman submodule, using:" \
230176ad07a4SPeter Maydell        "      git submodule update --init pixman"
2302e2134eb9SGerd Hoffmann  fi
23035ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
23045ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
23055ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2306e2134eb9SGerd Hoffmannfi
2307e2134eb9SGerd Hoffmann
2308e2134eb9SGerd Hoffmann##########################################
230917bff52bSM. Mohan Kumar# libcap probe
231017bff52bSM. Mohan Kumar
231117bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
231217bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
231317bff52bSM. Mohan Kumar#include <stdio.h>
231417bff52bSM. Mohan Kumar#include <sys/capability.h>
2315cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
231617bff52bSM. Mohan KumarEOF
231717bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
231817bff52bSM. Mohan Kumar    cap=yes
231917bff52bSM. Mohan Kumar  else
232017bff52bSM. Mohan Kumar    cap=no
232117bff52bSM. Mohan Kumar  fi
232217bff52bSM. Mohan Kumarfi
232317bff52bSM. Mohan Kumar
232417bff52bSM. Mohan Kumar##########################################
2325e5d355d1Saliguori# pthread probe
23264b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
23273c529d93Saliguori
2328e5d355d1Saliguoripthread=no
2329414f0dabSblueswir1cat > $TMPC << EOF
23303c529d93Saliguori#include <pthread.h>
23317a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
23327a42bbe4SStefan Weilint main(void) {
23337a42bbe4SStefan Weil  pthread_t thread;
23347a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
23357a42bbe4SStefan Weil  return 0;
23367a42bbe4SStefan Weil}
2337414f0dabSblueswir1EOF
2338bd00d539SAndreas Färberif compile_prog "" "" ; then
2339bd00d539SAndreas Färber  pthread=yes
2340bd00d539SAndreas Färberelse
2341de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
234252166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2343e5d355d1Saliguori      pthread=yes
2344e3c56761SPeter Portante      found=no
2345e3c56761SPeter Portante      for lib_entry in $LIBS; do
2346e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2347e3c56761SPeter Portante          found=yes
2348e3c56761SPeter Portante          break
2349e3c56761SPeter Portante        fi
2350e3c56761SPeter Portante      done
2351e3c56761SPeter Portante      if test "$found" = "no"; then
23525572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2353e3c56761SPeter Portante      fi
2354de65fe0fSSebastian Herbszt      break
2355414f0dabSblueswir1    fi
2356de65fe0fSSebastian Herbszt  done
2357bd00d539SAndreas Färberfi
2358414f0dabSblueswir1
23594617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
236076ad07a4SPeter Maydell  error_exit "pthread check failed" \
236176ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
2362e5d355d1Saliguorifi
2363e5d355d1Saliguori
2364bf9298b9Saliguori##########################################
2365f27aaf4bSChristian Brunner# rbd probe
2366f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2367f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2368f27aaf4bSChristian Brunner#include <stdio.h>
2369ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2370f27aaf4bSChristian Brunnerint main(void) {
2371ad32e9c0SJosh Durgin    rados_t cluster;
2372ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2373f27aaf4bSChristian Brunner    return 0;
2374f27aaf4bSChristian Brunner}
2375f27aaf4bSChristian BrunnerEOF
2376ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2377f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2378f27aaf4bSChristian Brunner    rbd=yes
2379f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2380f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2381f27aaf4bSChristian Brunner  else
2382f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
2383f27aaf4bSChristian Brunner      feature_not_found "rados block device"
2384f27aaf4bSChristian Brunner    fi
2385f27aaf4bSChristian Brunner    rbd=no
2386f27aaf4bSChristian Brunner  fi
2387f27aaf4bSChristian Brunnerfi
2388f27aaf4bSChristian Brunner
2389f27aaf4bSChristian Brunner##########################################
23900a12ec87SRichard W.M. Jones# libssh2 probe
23914fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
23920a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
239365d5d3f9SStefan Weil  if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
23940a12ec87SRichard W.M. Jones    libssh2_cflags=`$pkg_config libssh2 --cflags`
23950a12ec87SRichard W.M. Jones    libssh2_libs=`$pkg_config libssh2 --libs`
23960a12ec87SRichard W.M. Jones    libssh2=yes
23970a12ec87SRichard W.M. Jones    libs_tools="$libssh2_libs $libs_tools"
23980a12ec87SRichard W.M. Jones    libs_softmmu="$libssh2_libs $libs_softmmu"
23990a12ec87SRichard W.M. Jones    QEMU_CFLAGS="$QEMU_CFLAGS $libssh2_cflags"
24000a12ec87SRichard W.M. Jones  else
24010a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
24024fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
24030a12ec87SRichard W.M. Jones    fi
24040a12ec87SRichard W.M. Jones    libssh2=no
24050a12ec87SRichard W.M. Jones  fi
24060a12ec87SRichard W.M. Jonesfi
24070a12ec87SRichard W.M. Jones
24080a12ec87SRichard W.M. Jones##########################################
24099a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
24109a2d462eSRichard W.M. Jones
24119a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
24129a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
24139a2d462eSRichard W.M. Jones#include <stdio.h>
24149a2d462eSRichard W.M. Jones#include <libssh2.h>
24159a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
24169a2d462eSRichard W.M. Jonesint main(void) {
24179a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
24189a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
24199a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
24209a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
24219a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
24229a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
24239a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
24249a2d462eSRichard W.M. Jones    return 0;
24259a2d462eSRichard W.M. Jones}
24269a2d462eSRichard W.M. JonesEOF
24279a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
24289a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
24299a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
24309a2d462eSRichard W.M. Jones  fi
24319a2d462eSRichard W.M. Jonesfi
24329a2d462eSRichard W.M. Jones
24339a2d462eSRichard W.M. Jones##########################################
24345c6c3a6cSChristoph Hellwig# linux-aio probe
24355c6c3a6cSChristoph Hellwig
24365c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
24375c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
24385c6c3a6cSChristoph Hellwig#include <libaio.h>
24395c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2440832ce9c2SScott Wood#include <stddef.h>
24415c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
24425c6c3a6cSChristoph HellwigEOF
24435c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
24445c6c3a6cSChristoph Hellwig    linux_aio=yes
2445048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2446048d179fSPaul Brook    libs_tools="$libs_tools -laio"
24475c6c3a6cSChristoph Hellwig  else
24485c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
24495c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
24505c6c3a6cSChristoph Hellwig    fi
24513cfcae3cSLuiz Capitulino    linux_aio=no
24525c6c3a6cSChristoph Hellwig  fi
24535c6c3a6cSChristoph Hellwigfi
24545c6c3a6cSChristoph Hellwig
24555c6c3a6cSChristoph Hellwig##########################################
24563b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
24573b8acc11SPaolo Bonzini
24583b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
24593b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
24603b8acc11SPaolo Bonzinielse
24613b8acc11SPaolo Bonzini  tpm_passthrough=no
24623b8acc11SPaolo Bonzinifi
24633b8acc11SPaolo Bonzini
24643b8acc11SPaolo Bonzini##########################################
2465583f6e7bSStefan Hajnoczi# adjust virtio-blk-data-plane based on linux-aio
2466583f6e7bSStefan Hajnoczi
2467583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" -a \
2468583f6e7bSStefan Hajnoczi	"$linux_aio" != "yes" ; then
246976ad07a4SPeter Maydell  error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
2470583f6e7bSStefan Hajnoczielif test -z "$virtio_blk_data_plane" ; then
2471583f6e7bSStefan Hajnoczi  virtio_blk_data_plane=$linux_aio
2472583f6e7bSStefan Hajnoczifi
2473583f6e7bSStefan Hajnoczi
2474583f6e7bSStefan Hajnoczi##########################################
2475758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2476758e8e38SVenkateswararao Jujjuri (JV)
2477758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2478758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2479758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2480758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2481f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2482f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2483f2338fb4SPavel Borzenkov#else
24844f26f2b6SAvi Kivity#include <sys/xattr.h>
2485f2338fb4SPavel Borzenkov#endif
2486758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2487758e8e38SVenkateswararao Jujjuri (JV)EOF
24884f26f2b6SAvi Kivity  if compile_prog "" "" ; then
24894f26f2b6SAvi Kivity    attr=yes
24904f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2491f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2492758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2493758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
24944f26f2b6SAvi Kivity    libattr=yes
2495758e8e38SVenkateswararao Jujjuri (JV)  else
2496758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2497758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2498758e8e38SVenkateswararao Jujjuri (JV)    fi
2499758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2500758e8e38SVenkateswararao Jujjuri (JV)  fi
2501758e8e38SVenkateswararao Jujjuri (JV)fi
2502758e8e38SVenkateswararao Jujjuri (JV)
2503758e8e38SVenkateswararao Jujjuri (JV)##########################################
2504bf9298b9Saliguori# iovec probe
2505bf9298b9Saliguoricat > $TMPC <<EOF
2506db34f0b3Sblueswir1#include <sys/types.h>
2507bf9298b9Saliguori#include <sys/uio.h>
2508db34f0b3Sblueswir1#include <unistd.h>
2509f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2510bf9298b9SaliguoriEOF
2511bf9298b9Saliguoriiovec=no
251252166aa0SJuan Quintelaif compile_prog "" "" ; then
2513bf9298b9Saliguori  iovec=yes
2514bf9298b9Saliguorifi
2515bf9298b9Saliguori
2516f652e6afSaurel32##########################################
2517ceb42de8Saliguori# preadv probe
2518ceb42de8Saliguoricat > $TMPC <<EOF
2519ceb42de8Saliguori#include <sys/types.h>
2520ceb42de8Saliguori#include <sys/uio.h>
2521ceb42de8Saliguori#include <unistd.h>
2522c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2523ceb42de8SaliguoriEOF
2524ceb42de8Saliguoripreadv=no
252552166aa0SJuan Quintelaif compile_prog "" "" ; then
2526ceb42de8Saliguori  preadv=yes
2527ceb42de8Saliguorifi
2528ceb42de8Saliguori
2529ceb42de8Saliguori##########################################
2530f652e6afSaurel32# fdt probe
2531e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
2532e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
2533e169e1e1SPeter Maydellfdt_required=no
2534e169e1e1SPeter Maydellfor target in $target_list; do
2535e169e1e1SPeter Maydell  case $target in
2536e169e1e1SPeter Maydell    arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
2537e169e1e1SPeter Maydell      fdt_required=yes
2538e169e1e1SPeter Maydell    ;;
2539e169e1e1SPeter Maydell  esac
2540e169e1e1SPeter Maydelldone
2541e169e1e1SPeter Maydell
2542e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
2543e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
2544e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
2545e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
2546e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
2547e169e1e1SPeter Maydell  fi
2548e169e1e1SPeter Maydell  fdt=yes
2549e169e1e1SPeter Maydellfi
2550e169e1e1SPeter Maydell
25512df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2552b41af4baSJuan Quintela  fdt_libs="-lfdt"
255396ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
2554f652e6afSaurel32  cat > $TMPC << EOF
255596ce6545SPeter Crosthwaite#include <libfdt_env.h>
2556f652e6afSaurel32int main(void) { return 0; }
2557f652e6afSaurel32EOF
255852166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2559a540f158SPeter Crosthwaite    # system DTC is good - use it
2560f652e6afSaurel32    fdt=yes
2561a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
2562a540f158SPeter Crosthwaite    # have submodule DTC - use it
2563a540f158SPeter Crosthwaite    fdt=yes
2564a540f158SPeter Crosthwaite    dtc_internal="yes"
2565a540f158SPeter Crosthwaite    mkdir -p dtc
2566a540f158SPeter Crosthwaite    if [ "$source_path" != `pwd` ] ; then
2567a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
2568a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
25692df87df7SJuan Quintela    fi
2570a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
2571a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
2572a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
2573a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
2574f2c4ddd9SAndreas Färber    error_exit "DTC not present. Your options:" \
2575a540f158SPeter Crosthwaite        "  (1) Preferred: Install the DTC devel package" \
2576a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
2577a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
2578a540f158SPeter Crosthwaite  else
2579a540f158SPeter Crosthwaite    # don't have and don't want
2580de3a354aSMichael Walle    fdt_libs=
25812df87df7SJuan Quintela    fdt=no
2582f652e6afSaurel32  fi
2583f652e6afSaurel32fi
2584f652e6afSaurel32
2585a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
2586a540f158SPeter Crosthwaite
258720ff075bSMichael Walle##########################################
2588b1e5fff4SMichael Walle# GLX probe, used by milkymist-tmu2
2589b1e5fff4SMichael Walleif test "$glx" != "no" ; then
2590b1e5fff4SMichael Walle  glx_libs="-lGL -lX11"
259120ff075bSMichael Walle  cat > $TMPC << EOF
259220ff075bSMichael Walle#include <X11/Xlib.h>
259320ff075bSMichael Walle#include <GL/gl.h>
259420ff075bSMichael Walle#include <GL/glx.h>
2595d3fcbb16SMichael Walleint main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
259620ff075bSMichael WalleEOF
2597d3fcbb16SMichael Walle  if compile_prog "" "-lGL -lX11" ; then
2598b1e5fff4SMichael Walle    glx=yes
259920ff075bSMichael Walle  else
2600b1e5fff4SMichael Walle    if test "$glx" = "yes" ; then
2601b1e5fff4SMichael Walle      feature_not_found "glx"
260220ff075bSMichael Walle    fi
2603b1e5fff4SMichael Walle    glx_libs=
2604b1e5fff4SMichael Walle    glx=no
260520ff075bSMichael Walle  fi
260620ff075bSMichael Wallefi
260720ff075bSMichael Walle
2608eb100396SBharata B Rao##########################################
2609eb100396SBharata B Rao# glusterfs probe
2610eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
261165d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
2612e01bee08SBharata B Rao    glusterfs="yes"
2613ca871ec8SStefan Weil    glusterfs_cflags=`$pkg_config --cflags glusterfs-api`
2614ca871ec8SStefan Weil    glusterfs_libs=`$pkg_config --libs glusterfs-api`
2615e01bee08SBharata B Rao    CFLAGS="$CFLAGS $glusterfs_cflags"
2616eb100396SBharata B Rao    libs_tools="$glusterfs_libs $libs_tools"
2617eb100396SBharata B Rao    libs_softmmu="$glusterfs_libs $libs_softmmu"
261865d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
26190c14fb47SBharata B Rao      glusterfs_discard="yes"
26200c14fb47SBharata B Rao    fi
2621eb100396SBharata B Rao  else
2622eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
2623eb100396SBharata B Rao      feature_not_found "GlusterFS backend support"
2624eb100396SBharata B Rao    fi
2625e01bee08SBharata B Rao    glusterfs="no"
2626eb100396SBharata B Rao  fi
2627eb100396SBharata B Raofi
2628eb100396SBharata B Rao
262939386ac7Saurel32# Check for inotify functions when we are building linux-user
26303b3f24adSaurel32# emulator.  This is done because older glibc versions don't
26313b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
26323b3f24adSaurel32# don't provide them even if kernel supports them.
26333b3f24adSaurel32#
26343b3f24adSaurel32inotify=no
26353b3f24adSaurel32cat > $TMPC << EOF
26363b3f24adSaurel32#include <sys/inotify.h>
26373b3f24adSaurel32
26383b3f24adSaurel32int
26393b3f24adSaurel32main(void)
26403b3f24adSaurel32{
26413b3f24adSaurel32	/* try to start inotify */
26428690e420Saurel32	return inotify_init();
26433b3f24adSaurel32}
26443b3f24adSaurel32EOF
264552166aa0SJuan Quintelaif compile_prog "" "" ; then
26463b3f24adSaurel32  inotify=yes
26473b3f24adSaurel32fi
26483b3f24adSaurel32
2649c05c7a73SRiku Voipioinotify1=no
2650c05c7a73SRiku Voipiocat > $TMPC << EOF
2651c05c7a73SRiku Voipio#include <sys/inotify.h>
2652c05c7a73SRiku Voipio
2653c05c7a73SRiku Voipioint
2654c05c7a73SRiku Voipiomain(void)
2655c05c7a73SRiku Voipio{
2656c05c7a73SRiku Voipio    /* try to start inotify */
2657c05c7a73SRiku Voipio    return inotify_init1(0);
2658c05c7a73SRiku Voipio}
2659c05c7a73SRiku VoipioEOF
2660c05c7a73SRiku Voipioif compile_prog "" "" ; then
2661c05c7a73SRiku Voipio  inotify1=yes
2662c05c7a73SRiku Voipiofi
2663c05c7a73SRiku Voipio
2664ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2665ebc996f3SRiku Voipioutimens=no
2666ebc996f3SRiku Voipiocat > $TMPC << EOF
2667ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2668ebc996f3SRiku Voipio#include <stddef.h>
2669ebc996f3SRiku Voipio#include <fcntl.h>
26703014ee00SPeter Maydell#include <sys/stat.h>
2671ebc996f3SRiku Voipio
2672ebc996f3SRiku Voipioint main(void)
2673ebc996f3SRiku Voipio{
2674ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2675ebc996f3SRiku Voipio    futimens(0, NULL);
2676ebc996f3SRiku Voipio    return 0;
2677ebc996f3SRiku Voipio}
2678ebc996f3SRiku VoipioEOF
267952166aa0SJuan Quintelaif compile_prog "" "" ; then
2680ebc996f3SRiku Voipio  utimens=yes
2681ebc996f3SRiku Voipiofi
2682ebc996f3SRiku Voipio
2683099d6b0fSRiku Voipio# check if pipe2 is there
2684099d6b0fSRiku Voipiopipe2=no
2685099d6b0fSRiku Voipiocat > $TMPC << EOF
2686099d6b0fSRiku Voipio#include <unistd.h>
2687099d6b0fSRiku Voipio#include <fcntl.h>
2688099d6b0fSRiku Voipio
2689099d6b0fSRiku Voipioint main(void)
2690099d6b0fSRiku Voipio{
2691099d6b0fSRiku Voipio    int pipefd[2];
26929bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
2693099d6b0fSRiku Voipio}
2694099d6b0fSRiku VoipioEOF
269552166aa0SJuan Quintelaif compile_prog "" "" ; then
2696099d6b0fSRiku Voipio  pipe2=yes
2697099d6b0fSRiku Voipiofi
2698099d6b0fSRiku Voipio
269940ff6d7eSKevin Wolf# check if accept4 is there
270040ff6d7eSKevin Wolfaccept4=no
270140ff6d7eSKevin Wolfcat > $TMPC << EOF
270240ff6d7eSKevin Wolf#include <sys/socket.h>
270340ff6d7eSKevin Wolf#include <stddef.h>
270440ff6d7eSKevin Wolf
270540ff6d7eSKevin Wolfint main(void)
270640ff6d7eSKevin Wolf{
270740ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
270840ff6d7eSKevin Wolf    return 0;
270940ff6d7eSKevin Wolf}
271040ff6d7eSKevin WolfEOF
271140ff6d7eSKevin Wolfif compile_prog "" "" ; then
271240ff6d7eSKevin Wolf  accept4=yes
271340ff6d7eSKevin Wolffi
271440ff6d7eSKevin Wolf
27153ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
27163ce34dfbSvibisreenivasansplice=no
27173ce34dfbSvibisreenivasancat > $TMPC << EOF
27183ce34dfbSvibisreenivasan#include <unistd.h>
27193ce34dfbSvibisreenivasan#include <fcntl.h>
27203ce34dfbSvibisreenivasan#include <limits.h>
27213ce34dfbSvibisreenivasan
27223ce34dfbSvibisreenivasanint main(void)
27233ce34dfbSvibisreenivasan{
272466ea0f22SStefan Weil    int len, fd = 0;
27253ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
27263ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
27273ce34dfbSvibisreenivasan    return 0;
27283ce34dfbSvibisreenivasan}
27293ce34dfbSvibisreenivasanEOF
273052166aa0SJuan Quintelaif compile_prog "" "" ; then
27313ce34dfbSvibisreenivasan  splice=yes
27323ce34dfbSvibisreenivasanfi
27333ce34dfbSvibisreenivasan
2734dcc38d1cSMarcelo Tosatti##########################################
2735dcc38d1cSMarcelo Tosatti# signalfd probe
2736dcc38d1cSMarcelo Tosattisignalfd="no"
2737dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2738dcc38d1cSMarcelo Tosatti#include <unistd.h>
2739dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2740dcc38d1cSMarcelo Tosatti#include <signal.h>
2741dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2742dcc38d1cSMarcelo TosattiEOF
2743dcc38d1cSMarcelo Tosatti
2744dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2745dcc38d1cSMarcelo Tosatti  signalfd=yes
2746dcc38d1cSMarcelo Tosattifi
2747dcc38d1cSMarcelo Tosatti
2748c2882b96SRiku Voipio# check if eventfd is supported
2749c2882b96SRiku Voipioeventfd=no
2750c2882b96SRiku Voipiocat > $TMPC << EOF
2751c2882b96SRiku Voipio#include <sys/eventfd.h>
2752c2882b96SRiku Voipio
2753c2882b96SRiku Voipioint main(void)
2754c2882b96SRiku Voipio{
275555cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2756c2882b96SRiku Voipio}
2757c2882b96SRiku VoipioEOF
2758c2882b96SRiku Voipioif compile_prog "" "" ; then
2759c2882b96SRiku Voipio  eventfd=yes
2760c2882b96SRiku Voipiofi
2761c2882b96SRiku Voipio
2762d0927938SUlrich Hecht# check for fallocate
2763d0927938SUlrich Hechtfallocate=no
2764d0927938SUlrich Hechtcat > $TMPC << EOF
2765d0927938SUlrich Hecht#include <fcntl.h>
2766d0927938SUlrich Hecht
2767d0927938SUlrich Hechtint main(void)
2768d0927938SUlrich Hecht{
2769d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2770d0927938SUlrich Hecht    return 0;
2771d0927938SUlrich Hecht}
2772d0927938SUlrich HechtEOF
27738fb03151SPeter Maydellif compile_prog "" "" ; then
2774d0927938SUlrich Hecht  fallocate=yes
2775d0927938SUlrich Hechtfi
2776d0927938SUlrich Hecht
27773d4fa43eSKusanagi Kouichi# check for fallocate hole punching
27783d4fa43eSKusanagi Kouichifallocate_punch_hole=no
27793d4fa43eSKusanagi Kouichicat > $TMPC << EOF
27803d4fa43eSKusanagi Kouichi#include <fcntl.h>
27813d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
27823d4fa43eSKusanagi Kouichi
27833d4fa43eSKusanagi Kouichiint main(void)
27843d4fa43eSKusanagi Kouichi{
27853d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
27863d4fa43eSKusanagi Kouichi    return 0;
27873d4fa43eSKusanagi Kouichi}
27883d4fa43eSKusanagi KouichiEOF
27893d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
27903d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
27913d4fa43eSKusanagi Kouichifi
27923d4fa43eSKusanagi Kouichi
2793c727f47dSPeter Maydell# check for sync_file_range
2794c727f47dSPeter Maydellsync_file_range=no
2795c727f47dSPeter Maydellcat > $TMPC << EOF
2796c727f47dSPeter Maydell#include <fcntl.h>
2797c727f47dSPeter Maydell
2798c727f47dSPeter Maydellint main(void)
2799c727f47dSPeter Maydell{
2800c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2801c727f47dSPeter Maydell    return 0;
2802c727f47dSPeter Maydell}
2803c727f47dSPeter MaydellEOF
28048fb03151SPeter Maydellif compile_prog "" "" ; then
2805c727f47dSPeter Maydell  sync_file_range=yes
2806c727f47dSPeter Maydellfi
2807c727f47dSPeter Maydell
2808dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2809dace20dcSPeter Maydellfiemap=no
2810dace20dcSPeter Maydellcat > $TMPC << EOF
2811dace20dcSPeter Maydell#include <sys/ioctl.h>
2812dace20dcSPeter Maydell#include <linux/fs.h>
2813dace20dcSPeter Maydell#include <linux/fiemap.h>
2814dace20dcSPeter Maydell
2815dace20dcSPeter Maydellint main(void)
2816dace20dcSPeter Maydell{
2817dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2818dace20dcSPeter Maydell    return 0;
2819dace20dcSPeter Maydell}
2820dace20dcSPeter MaydellEOF
28218fb03151SPeter Maydellif compile_prog "" "" ; then
2822dace20dcSPeter Maydell  fiemap=yes
2823dace20dcSPeter Maydellfi
2824dace20dcSPeter Maydell
2825d0927938SUlrich Hecht# check for dup3
2826d0927938SUlrich Hechtdup3=no
2827d0927938SUlrich Hechtcat > $TMPC << EOF
2828d0927938SUlrich Hecht#include <unistd.h>
2829d0927938SUlrich Hecht
2830d0927938SUlrich Hechtint main(void)
2831d0927938SUlrich Hecht{
2832d0927938SUlrich Hecht    dup3(0, 0, 0);
2833d0927938SUlrich Hecht    return 0;
2834d0927938SUlrich Hecht}
2835d0927938SUlrich HechtEOF
283678f5d726SJan Kiszkaif compile_prog "" "" ; then
2837d0927938SUlrich Hecht  dup3=yes
2838d0927938SUlrich Hechtfi
2839d0927938SUlrich Hecht
28404e0c6529SAlex Bligh# check for ppoll support
28414e0c6529SAlex Blighppoll=no
28424e0c6529SAlex Blighcat > $TMPC << EOF
28434e0c6529SAlex Bligh#include <poll.h>
28444e0c6529SAlex Bligh
28454e0c6529SAlex Blighint main(void)
28464e0c6529SAlex Bligh{
28474e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
28484e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
28494e0c6529SAlex Bligh    return 0;
28504e0c6529SAlex Bligh}
28514e0c6529SAlex BlighEOF
28524e0c6529SAlex Blighif compile_prog "" "" ; then
28534e0c6529SAlex Bligh  ppoll=yes
28544e0c6529SAlex Blighfi
28554e0c6529SAlex Bligh
2856cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
2857cd758dd0SAlex Blighprctl_pr_set_timerslack=no
2858cd758dd0SAlex Blighcat > $TMPC << EOF
2859cd758dd0SAlex Bligh#include <sys/prctl.h>
2860cd758dd0SAlex Bligh
2861cd758dd0SAlex Blighint main(void)
2862cd758dd0SAlex Bligh{
2863cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
2864cd758dd0SAlex Bligh    return 0;
2865cd758dd0SAlex Bligh}
2866cd758dd0SAlex BlighEOF
2867cd758dd0SAlex Blighif compile_prog "" "" ; then
2868cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
2869cd758dd0SAlex Blighfi
2870cd758dd0SAlex Bligh
28713b6edd16SPeter Maydell# check for epoll support
28723b6edd16SPeter Maydellepoll=no
28733b6edd16SPeter Maydellcat > $TMPC << EOF
28743b6edd16SPeter Maydell#include <sys/epoll.h>
28753b6edd16SPeter Maydell
28763b6edd16SPeter Maydellint main(void)
28773b6edd16SPeter Maydell{
28783b6edd16SPeter Maydell    epoll_create(0);
28793b6edd16SPeter Maydell    return 0;
28803b6edd16SPeter Maydell}
28813b6edd16SPeter MaydellEOF
28828fb03151SPeter Maydellif compile_prog "" "" ; then
28833b6edd16SPeter Maydell  epoll=yes
28843b6edd16SPeter Maydellfi
28853b6edd16SPeter Maydell
28863b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
28873b6edd16SPeter Maydell# so we must check separately for their presence
28883b6edd16SPeter Maydellepoll_create1=no
28893b6edd16SPeter Maydellcat > $TMPC << EOF
28903b6edd16SPeter Maydell#include <sys/epoll.h>
28913b6edd16SPeter Maydell
28923b6edd16SPeter Maydellint main(void)
28933b6edd16SPeter Maydell{
289419e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
289519e83f6bSPeter Maydell     * a function being called. This is necessary so that on
289619e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
289719e83f6bSPeter Maydell     * the library but not declared in the header file we will
289819e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
289919e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
290019e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
290119e83f6bSPeter Maydell     */
2902c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
29033b6edd16SPeter Maydell}
29043b6edd16SPeter MaydellEOF
29058fb03151SPeter Maydellif compile_prog "" "" ; then
29063b6edd16SPeter Maydell  epoll_create1=yes
29073b6edd16SPeter Maydellfi
29083b6edd16SPeter Maydell
29093b6edd16SPeter Maydellepoll_pwait=no
29103b6edd16SPeter Maydellcat > $TMPC << EOF
29113b6edd16SPeter Maydell#include <sys/epoll.h>
29123b6edd16SPeter Maydell
29133b6edd16SPeter Maydellint main(void)
29143b6edd16SPeter Maydell{
29153b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
29163b6edd16SPeter Maydell    return 0;
29173b6edd16SPeter Maydell}
29183b6edd16SPeter MaydellEOF
29198fb03151SPeter Maydellif compile_prog "" "" ; then
29203b6edd16SPeter Maydell  epoll_pwait=yes
29213b6edd16SPeter Maydellfi
29223b6edd16SPeter Maydell
2923a8fd1abaSPeter Maydell# check for sendfile support
2924a8fd1abaSPeter Maydellsendfile=no
2925a8fd1abaSPeter Maydellcat > $TMPC << EOF
2926a8fd1abaSPeter Maydell#include <sys/sendfile.h>
2927a8fd1abaSPeter Maydell
2928a8fd1abaSPeter Maydellint main(void)
2929a8fd1abaSPeter Maydell{
2930a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
2931a8fd1abaSPeter Maydell}
2932a8fd1abaSPeter MaydellEOF
2933a8fd1abaSPeter Maydellif compile_prog "" "" ; then
2934a8fd1abaSPeter Maydell  sendfile=yes
2935a8fd1abaSPeter Maydellfi
2936a8fd1abaSPeter Maydell
2937cc8ae6deSpbrook# Check if tools are available to build documentation.
2938a25dba17SJuan Quintelaif test "$docs" != "no" ; then
293901668d98SStefan Weil  if has makeinfo && has pod2man; then
2940a25dba17SJuan Quintela    docs=yes
294183a3ab8bSJuan Quintela  else
2942a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2943a25dba17SJuan Quintela      feature_not_found "docs"
294483a3ab8bSJuan Quintela    fi
2945a25dba17SJuan Quintela    docs=no
294683a3ab8bSJuan Quintela  fi
2947cc8ae6deSpbrookfi
2948cc8ae6deSpbrook
2949f514f41cSStefan Weil# Search for bswap_32 function
29506ae9a1f4SJuan Quintelabyteswap_h=no
29516ae9a1f4SJuan Quintelacat > $TMPC << EOF
29526ae9a1f4SJuan Quintela#include <byteswap.h>
29536ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
29546ae9a1f4SJuan QuintelaEOF
295552166aa0SJuan Quintelaif compile_prog "" "" ; then
29566ae9a1f4SJuan Quintela  byteswap_h=yes
29576ae9a1f4SJuan Quintelafi
29586ae9a1f4SJuan Quintela
295975f13596SStefan Weil# Search for bswap32 function
29606ae9a1f4SJuan Quintelabswap_h=no
29616ae9a1f4SJuan Quintelacat > $TMPC << EOF
29626ae9a1f4SJuan Quintela#include <sys/endian.h>
29636ae9a1f4SJuan Quintela#include <sys/types.h>
29646ae9a1f4SJuan Quintela#include <machine/bswap.h>
29656ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
29666ae9a1f4SJuan QuintelaEOF
296752166aa0SJuan Quintelaif compile_prog "" "" ; then
29686ae9a1f4SJuan Quintela  bswap_h=yes
29696ae9a1f4SJuan Quintelafi
29706ae9a1f4SJuan Quintela
2971da93a1fdSaliguori##########################################
2972c589b249SRonnie Sahlberg# Do we have libiscsi
2973fa6acb0cSRonnie Sahlberg# We check for iscsi_unmap_sync() to make sure we have a
2974fa6acb0cSRonnie Sahlberg# recent enough version of libiscsi.
2975c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2976c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2977fa6acb0cSRonnie Sahlberg#include <stdio.h>
2978c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2979fa6acb0cSRonnie Sahlbergint main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2980c589b249SRonnie SahlbergEOF
298165d5d3f9SStefan Weil  if $pkg_config --atleast-version=1.7.0 libiscsi; then
29823c33ea96SPaolo Bonzini    libiscsi="yes"
2983ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
2984ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
29853c33ea96SPaolo Bonzini    CFLAGS="$CFLAGS $libiscsi_cflags"
29863c33ea96SPaolo Bonzini    LIBS="$LIBS $libiscsi_libs"
29873c33ea96SPaolo Bonzini  elif compile_prog "" "-liscsi" ; then
2988c589b249SRonnie Sahlberg    libiscsi="yes"
2989c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2990c589b249SRonnie Sahlberg  else
2991c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2992c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2993c589b249SRonnie Sahlberg    fi
2994c589b249SRonnie Sahlberg    libiscsi="no"
2995c589b249SRonnie Sahlberg  fi
2996c589b249SRonnie Sahlbergfi
2997c589b249SRonnie Sahlberg
2998c589b249SRonnie Sahlberg
2999c589b249SRonnie Sahlberg##########################################
30008bacde8dSNatanael Copa# Do we need libm
30018bacde8dSNatanael Copacat > $TMPC << EOF
30028bacde8dSNatanael Copa#include <math.h>
30038bacde8dSNatanael Copaint main(void) { return isnan(sin(0.0)); }
30048bacde8dSNatanael CopaEOF
30058bacde8dSNatanael Copaif compile_prog "" "" ; then
30068bacde8dSNatanael Copa  :
30078bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
30088bacde8dSNatanael Copa  LIBS="-lm $LIBS"
30098bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
30108bacde8dSNatanael Copaelse
301176ad07a4SPeter Maydell  error_exit "libm check failed"
30128bacde8dSNatanael Copafi
30138bacde8dSNatanael Copa
30148bacde8dSNatanael Copa##########################################
3015da93a1fdSaliguori# Do we need librt
30168bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
30178bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
30188bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
30198bacde8dSNatanael Copa# function in addition.
3020da93a1fdSaliguoricat > $TMPC <<EOF
3021da93a1fdSaliguori#include <signal.h>
3022da93a1fdSaliguori#include <time.h>
30238bacde8dSNatanael Copaint main(void) {
30248bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
30258bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
30268bacde8dSNatanael Copa}
3027da93a1fdSaliguoriEOF
3028da93a1fdSaliguori
302952166aa0SJuan Quintelaif compile_prog "" "" ; then
303007ffa4bdSJuan Quintela  :
30318bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
30328bacde8dSNatanael Copaelif compile_prog "" "-lrt $pthread_lib" ; then
303307ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
30348bacde8dSNatanael Copa  libs_qga="-lrt $libs_qga"
3035da93a1fdSaliguorifi
3036da93a1fdSaliguori
303731ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
3038179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
30396362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
30406362a53fSJuan Quintelafi
30416362a53fSJuan Quintela
3042de5071c5SBlue Swirl##########################################
3043cd4ec0b4SGerd Hoffmann# spice probe
3044cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3045cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3046cd4ec0b4SGerd Hoffmann#include <spice.h>
3047cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3048cd4ec0b4SGerd HoffmannEOF
3049710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3050710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
305165d5d3f9SStefan Weil  if $pkg_config --atleast-version=0.12.0 spice-server && \
305265d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
3053cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3054cd4ec0b4SGerd Hoffmann    spice="yes"
3055cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
3056cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
30572e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
30582e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
3059cd4ec0b4SGerd Hoffmann  else
3060cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
3061cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
3062cd4ec0b4SGerd Hoffmann    fi
3063cd4ec0b4SGerd Hoffmann    spice="no"
3064cd4ec0b4SGerd Hoffmann  fi
3065cd4ec0b4SGerd Hoffmannfi
3066cd4ec0b4SGerd Hoffmann
3067111a38b0SRobert Relyea# check for libcacard for smartcard support
3068111a38b0SRobert Relyeasmartcard_cflags=""
3069111a38b0SRobert Relyea# TODO - what's the minimal nss version we support?
3070111a38b0SRobert Relyeaif test "$smartcard_nss" != "no"; then
30715f01e06fSSergei Trofimovich  cat > $TMPC << EOF
30725f01e06fSSergei Trofimovich#include <pk11pub.h>
30735f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
30745f01e06fSSergei TrofimovichEOF
30750b22ef0fSPeter Maydell    smartcard_includes="-I\$(SRC_PATH)/libcacard"
30768c741c22SAlon Levy    libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
30778c741c22SAlon Levy    libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
30786ca026cbSPeter Maydell    test_cflags="$libcacard_cflags"
30796ca026cbSPeter Maydell    # The header files in nss < 3.13.3 have a bug which causes them to
30806ca026cbSPeter Maydell    # emit a warning. If we're going to compile QEMU with -Werror, then
30816ca026cbSPeter Maydell    # test that the headers don't have this bug. Otherwise we would pass
30826ca026cbSPeter Maydell    # the configure test but fail to compile QEMU later.
30836ca026cbSPeter Maydell    if test "$werror" = "yes"; then
30846ca026cbSPeter Maydell        test_cflags="-Werror $test_cflags"
30856ca026cbSPeter Maydell    fi
3086b6fc675bSPaolo Bonzini    if test -n "$libtool" &&
308765d5d3f9SStefan Weil       $pkg_config --atleast-version=3.12.8 nss && \
30886ca026cbSPeter Maydell      compile_prog "$test_cflags" "$libcacard_libs"; then
30895f01e06fSSergei Trofimovich        smartcard_nss="yes"
30900b22ef0fSPeter Maydell        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
30910b22ef0fSPeter Maydell        QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
3092ad4cf3f6SPaul Brook        libs_softmmu="$libcacard_libs $libs_softmmu"
3093111a38b0SRobert Relyea    else
3094111a38b0SRobert Relyea        if test "$smartcard_nss" = "yes"; then
3095111a38b0SRobert Relyea            feature_not_found "nss"
3096111a38b0SRobert Relyea        fi
3097111a38b0SRobert Relyea        smartcard_nss="no"
3098111a38b0SRobert Relyea    fi
3099111a38b0SRobert Relyeafi
3100111a38b0SRobert Relyea
31012b2325ffSGerd Hoffmann# check for libusb
31022b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
310365d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
31042b2325ffSGerd Hoffmann        libusb="yes"
31052b2325ffSGerd Hoffmann	usb="libusb"
3106ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
3107ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
31082b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
31092b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
31102b2325ffSGerd Hoffmann    else
31112b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
31122b2325ffSGerd Hoffmann            feature_not_found "libusb"
31132b2325ffSGerd Hoffmann        fi
31142b2325ffSGerd Hoffmann        libusb="no"
31152b2325ffSGerd Hoffmann    fi
31162b2325ffSGerd Hoffmannfi
31172b2325ffSGerd Hoffmann
311869354a83SHans de Goede# check for usbredirparser for usb network redirection support
311969354a83SHans de Goedeif test "$usb_redir" != "no" ; then
312065d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
312169354a83SHans de Goede        usb_redir="yes"
3122ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
3123ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
312469354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
312556ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
312669354a83SHans de Goede    else
312769354a83SHans de Goede        if test "$usb_redir" = "yes"; then
312869354a83SHans de Goede            feature_not_found "usb-redir"
312969354a83SHans de Goede        fi
313069354a83SHans de Goede        usb_redir="no"
313169354a83SHans de Goede    fi
313269354a83SHans de Goedefi
313369354a83SHans de Goede
3134cd4ec0b4SGerd Hoffmann##########################################
3135cd4ec0b4SGerd Hoffmann
3136747bbdf7SBlue Swirl##########################################
31375f6b9e8fSBlue Swirl# check if we have fdatasync
31385f6b9e8fSBlue Swirl
31395f6b9e8fSBlue Swirlfdatasync=no
31405f6b9e8fSBlue Swirlcat > $TMPC << EOF
31415f6b9e8fSBlue Swirl#include <unistd.h>
3142d1722a27SAlexandre Raymondint main(void) {
3143d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
3144d1722a27SAlexandre Raymondreturn fdatasync(0);
3145d1722a27SAlexandre Raymond#else
3146e172fe11SStefan Weil#error Not supported
3147d1722a27SAlexandre Raymond#endif
3148d1722a27SAlexandre Raymond}
31495f6b9e8fSBlue SwirlEOF
31505f6b9e8fSBlue Swirlif compile_prog "" "" ; then
31515f6b9e8fSBlue Swirl    fdatasync=yes
31525f6b9e8fSBlue Swirlfi
31535f6b9e8fSBlue Swirl
315494a420b1SStefan Hajnoczi##########################################
3155e78815a5SAndreas Färber# check if we have madvise
3156e78815a5SAndreas Färber
3157e78815a5SAndreas Färbermadvise=no
3158e78815a5SAndreas Färbercat > $TMPC << EOF
3159e78815a5SAndreas Färber#include <sys/types.h>
3160e78815a5SAndreas Färber#include <sys/mman.h>
3161832ce9c2SScott Wood#include <stddef.h>
3162e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
3163e78815a5SAndreas FärberEOF
3164e78815a5SAndreas Färberif compile_prog "" "" ; then
3165e78815a5SAndreas Färber    madvise=yes
3166e78815a5SAndreas Färberfi
3167e78815a5SAndreas Färber
3168e78815a5SAndreas Färber##########################################
3169e78815a5SAndreas Färber# check if we have posix_madvise
3170e78815a5SAndreas Färber
3171e78815a5SAndreas Färberposix_madvise=no
3172e78815a5SAndreas Färbercat > $TMPC << EOF
3173e78815a5SAndreas Färber#include <sys/mman.h>
3174832ce9c2SScott Wood#include <stddef.h>
3175e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
3176e78815a5SAndreas FärberEOF
3177e78815a5SAndreas Färberif compile_prog "" "" ; then
3178e78815a5SAndreas Färber    posix_madvise=yes
3179e78815a5SAndreas Färberfi
3180e78815a5SAndreas Färber
3181e78815a5SAndreas Färber##########################################
31821e9737daSRichard Henderson# check if we have usable SIGEV_THREAD_ID
31831e9737daSRichard Henderson
31841e9737daSRichard Hendersonsigev_thread_id=no
31851e9737daSRichard Hendersoncat > $TMPC << EOF
31861e9737daSRichard Henderson#include <signal.h>
31871e9737daSRichard Hendersonint main(void) {
31881e9737daSRichard Henderson  struct sigevent ev;
31891e9737daSRichard Henderson  ev.sigev_notify = SIGEV_THREAD_ID;
31901e9737daSRichard Henderson  ev._sigev_un._tid = 0;
31911e9737daSRichard Henderson  asm volatile("" : : "g"(&ev));
31921e9737daSRichard Henderson  return 0;
31931e9737daSRichard Henderson}
31941e9737daSRichard HendersonEOF
31951e9737daSRichard Hendersonif compile_prog "" "" ; then
31961e9737daSRichard Henderson    sigev_thread_id=yes
31971e9737daSRichard Hendersonfi
31981e9737daSRichard Henderson
31991e9737daSRichard Henderson##########################################
320094a420b1SStefan Hajnoczi# check if trace backend exists
320194a420b1SStefan Hajnoczi
3202650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
320394a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
320476ad07a4SPeter Maydell  error_exit "invalid trace backend" \
320576ad07a4SPeter Maydell      "Please choose a supported trace backend."
320694a420b1SStefan Hajnoczifi
320794a420b1SStefan Hajnoczi
32087e24e92aSStefan Hajnoczi##########################################
32097e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
32107e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
32117e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
32127e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
32137e24e92aSStefan Hajnoczi#include <ust/marker.h>
32147e24e92aSStefan Hajnocziint main(void) { return 0; }
32157e24e92aSStefan HajnocziEOF
32167e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
321794b4fefaSLluís Vilanova    LIBS="-lust -lurcu-bp $LIBS"
3218c9a2e37cSLluís Vilanova    libs_qga="-lust -lurcu-bp $libs_qga"
32197e24e92aSStefan Hajnoczi  else
322076ad07a4SPeter Maydell    error_exit "Trace backend 'ust' missing libust header files"
32217e24e92aSStefan Hajnoczi  fi
32227e24e92aSStefan Hajnoczifi
3223b3d08c02SDaniel P. Berrange
3224b3d08c02SDaniel P. Berrange##########################################
3225b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
3226b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
3227b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
322876ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
3229b3d08c02SDaniel P. Berrange  fi
3230c276b17dSDaniel P. Berrange  trace_backend_stap="no"
3231c276b17dSDaniel P. Berrange  if has 'stap' ; then
3232c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
3233c276b17dSDaniel P. Berrange  fi
3234b3d08c02SDaniel P. Berrangefi
3235b3d08c02SDaniel P. Berrange
32367e24e92aSStefan Hajnoczi##########################################
3237519175a2SAlex Barcelo# check and set a backend for coroutine
3238d0e2fce5SAneesh Kumar K.V
32397c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
32407c2acc70SPeter Maydell# is sigcontext. gthread is not selectable except explicitly, because
32417c2acc70SPeter Maydell# it is not functional enough to run QEMU proper. (It is occasionally
32427c2acc70SPeter Maydell# useful for debugging purposes.)  On Windows the only valid backend
32437c2acc70SPeter Maydell# is the Windows-specific one.
32447c2acc70SPeter Maydell
32457c2acc70SPeter Maydellucontext_works=no
3246d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3247d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3248d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3249cdf84806SPeter Maydell#ifdef __stub_makecontext
3250cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3251cdf84806SPeter Maydell#endif
325275cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3253d0e2fce5SAneesh Kumar K.VEOF
3254d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
32557c2acc70SPeter Maydell    ucontext_works=yes
3256d0e2fce5SAneesh Kumar K.V  fi
3257519175a2SAlex Barcelofi
32587c2acc70SPeter Maydell
32597c2acc70SPeter Maydellif test "$coroutine" = ""; then
32607c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
32617c2acc70SPeter Maydell    coroutine=win32
32627c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
32637c2acc70SPeter Maydell    coroutine=ucontext
3264519175a2SAlex Barcelo  else
32657c2acc70SPeter Maydell    coroutine=sigaltstack
32667c2acc70SPeter Maydell  fi
32677c2acc70SPeter Maydellelse
32687c2acc70SPeter Maydell  case $coroutine in
32697c2acc70SPeter Maydell  windows)
32707c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
32717c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
32727c2acc70SPeter Maydell    fi
32737c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
32747c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
32757c2acc70SPeter Maydell    coroutine=win32
32767c2acc70SPeter Maydell    ;;
32777c2acc70SPeter Maydell  ucontext)
32787c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
32797c2acc70SPeter Maydell      feature_not_found "ucontext"
32807c2acc70SPeter Maydell    fi
32817c2acc70SPeter Maydell    ;;
32827c2acc70SPeter Maydell  gthread|sigaltstack)
32837c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
32847c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
32857c2acc70SPeter Maydell    fi
32867c2acc70SPeter Maydell    ;;
32877c2acc70SPeter Maydell  *)
328876ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
32897c2acc70SPeter Maydell    ;;
32907c2acc70SPeter Maydell  esac
3291d0e2fce5SAneesh Kumar K.Vfi
3292d0e2fce5SAneesh Kumar K.V
3293d0e2fce5SAneesh Kumar K.V##########################################
3294d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
3295d2042378SAneesh Kumar K.V
32964e1797f9SStefan Weilopen_by_handle_at=no
3297d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
3298d2042378SAneesh Kumar K.V#include <fcntl.h>
3299acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
3300acc55ba8SStefan Weil# error missing definition
3301acc55ba8SStefan Weil#else
330275cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3303acc55ba8SStefan Weil#endif
3304d2042378SAneesh Kumar K.VEOF
3305d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
3306d2042378SAneesh Kumar K.V    open_by_handle_at=yes
3307d2042378SAneesh Kumar K.Vfi
3308d2042378SAneesh Kumar K.V
3309e06a765eSHarsh Prateek Bora########################################
3310e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
3311e06a765eSHarsh Prateek Bora
3312e06a765eSHarsh Prateek Boralinux_magic_h=no
3313e06a765eSHarsh Prateek Boracat > $TMPC << EOF
3314e06a765eSHarsh Prateek Bora#include <linux/magic.h>
3315e06a765eSHarsh Prateek Boraint main(void) {
331675cafad7SStefan Weil  return 0;
3317e06a765eSHarsh Prateek Bora}
3318e06a765eSHarsh Prateek BoraEOF
3319e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
3320e06a765eSHarsh Prateek Bora    linux_magic_h=yes
3321e06a765eSHarsh Prateek Borafi
3322e06a765eSHarsh Prateek Bora
33238ab1bf12SLuiz Capitulino########################################
3324c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
3325c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
3326c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
3327c95e3080SKevin Wolf# only a warning.
3328c95e3080SKevin Wolf#
3329c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
3330c95e3080SKevin Wolf# the build doesn't fail anyway.
3331c95e3080SKevin Wolf
333206d71fa1SPeter Maydellpragma_disable_unused_but_set=no
333306d71fa1SPeter Maydellcat > $TMPC << EOF
3334e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
333506d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3336c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
3337e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
3338c95e3080SKevin Wolf
333906d71fa1SPeter Maydellint main(void) {
334006d71fa1SPeter Maydell    return 0;
334106d71fa1SPeter Maydell}
334206d71fa1SPeter MaydellEOF
334306d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
3344cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
3345c95e3080SKevin Wolfelse
3346c95e3080SKevin Wolf    werror=no
334706d71fa1SPeter Maydellfi
334806d71fa1SPeter Maydell
334906d71fa1SPeter Maydell########################################
335062fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
33513f4349dcSKevin Wolf
33523f4349dcSKevin Wolfvalgrind_h=no
33533f4349dcSKevin Wolfcat > $TMPC << EOF
33543f4349dcSKevin Wolf#include <valgrind/valgrind.h>
335562fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
33563f4349dcSKevin Wolfint main(void) {
33573f4349dcSKevin Wolf  return 0;
33583f4349dcSKevin Wolf}
33593f4349dcSKevin WolfEOF
33603f4349dcSKevin Wolfif compile_prog "" "" ; then
33613f4349dcSKevin Wolf    valgrind_h=yes
33623f4349dcSKevin Wolffi
33633f4349dcSKevin Wolf
33643f4349dcSKevin Wolf########################################
33658ab1bf12SLuiz Capitulino# check if environ is declared
33668ab1bf12SLuiz Capitulino
33678ab1bf12SLuiz Capitulinohas_environ=no
33688ab1bf12SLuiz Capitulinocat > $TMPC << EOF
33698ab1bf12SLuiz Capitulino#include <unistd.h>
33708ab1bf12SLuiz Capitulinoint main(void) {
3371c075a723SBlue Swirl    environ = 0;
33728ab1bf12SLuiz Capitulino    return 0;
33738ab1bf12SLuiz Capitulino}
33748ab1bf12SLuiz CapitulinoEOF
33758ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
33768ab1bf12SLuiz Capitulino    has_environ=yes
33778ab1bf12SLuiz Capitulinofi
33788ab1bf12SLuiz Capitulino
337976a347e1SRichard Henderson########################################
338076a347e1SRichard Henderson# check if cpuid.h is usable.
338176a347e1SRichard Henderson
338276a347e1SRichard Hendersoncpuid_h=no
338376a347e1SRichard Hendersoncat > $TMPC << EOF
338476a347e1SRichard Henderson#include <cpuid.h>
338576a347e1SRichard Hendersonint main(void) {
338676a347e1SRichard Henderson  return 0;
338776a347e1SRichard Henderson}
338876a347e1SRichard HendersonEOF
338976a347e1SRichard Hendersonif compile_prog "" "" ; then
339076a347e1SRichard Henderson    cpuid_h=yes
339176a347e1SRichard Hendersonfi
339276a347e1SRichard Henderson
3393f540166bSRichard Henderson########################################
3394f540166bSRichard Henderson# check if __[u]int128_t is usable.
3395f540166bSRichard Henderson
3396f540166bSRichard Hendersonint128=no
3397f540166bSRichard Hendersoncat > $TMPC << EOF
3398f540166bSRichard Henderson__int128_t a;
3399f540166bSRichard Henderson__uint128_t b;
3400f540166bSRichard Hendersonint main (void) {
3401f540166bSRichard Henderson  a = a + b;
3402f540166bSRichard Henderson  b = a * b;
3403464e3671SPeter Maydell  a = a * a;
3404f540166bSRichard Henderson  return 0;
3405f540166bSRichard Henderson}
3406f540166bSRichard HendersonEOF
3407f540166bSRichard Hendersonif compile_prog "" "" ; then
3408f540166bSRichard Henderson    int128=yes
3409f540166bSRichard Hendersonfi
341076a347e1SRichard Henderson
34111e6e9acaSRichard Henderson########################################
34121e6e9acaSRichard Henderson# check if getauxval is available.
34131e6e9acaSRichard Henderson
34141e6e9acaSRichard Hendersongetauxval=no
34151e6e9acaSRichard Hendersoncat > $TMPC << EOF
34161e6e9acaSRichard Henderson#include <sys/auxv.h>
34171e6e9acaSRichard Hendersonint main(void) {
34181e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
34191e6e9acaSRichard Henderson}
34201e6e9acaSRichard HendersonEOF
34211e6e9acaSRichard Hendersonif compile_prog "" "" ; then
34221e6e9acaSRichard Henderson    getauxval=yes
34231e6e9acaSRichard Hendersonfi
34241e6e9acaSRichard Henderson
3425d2042378SAneesh Kumar K.V##########################################
3426e86ecd4bSJuan Quintela# End of CC checks
3427e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3428e86ecd4bSJuan Quintela
34291d728c39SBlue Swirlif test "$gcov" = "yes" ; then
34301d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
34311d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
34321d728c39SBlue Swirlelif test "$debug" = "no" ; then
34338be74dc0SAvi Kivity  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3434e86ecd4bSJuan Quintelafi
3435a316e378SJuan Quintela
34361d728c39SBlue Swirl
343720ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
343820ff6c80SAnthony Liguori# enable/disable
343920ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
344020ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
344120ff6c80SAnthony Liguori	zero_malloc="no"
344220ff6c80SAnthony Liguori    else
344320ff6c80SAnthony Liguori	zero_malloc="yes"
344420ff6c80SAnthony Liguori    fi
344520ff6c80SAnthony Liguorifi
344620ff6c80SAnthony Liguori
34476ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
34486ca026cbSPeter Maydellif test "$werror" = "yes"; then
34496ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
34506ca026cbSPeter Maydellfi
34516ca026cbSPeter Maydell
3452e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3453e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
34541156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3455e86ecd4bSJuan Quintela    fi
3456e86ecd4bSJuan Quintelafi
3457e86ecd4bSJuan Quintela
345894dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
345994dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
346094dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
346194dd53c5SGerd Hoffmannelse
346294dd53c5SGerd Hoffmann    POD2MAN="pod2man"
346394dd53c5SGerd Hoffmannfi
346494dd53c5SGerd Hoffmann
3465952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3466952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3467952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3468952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3469952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3470952afb71SBlue Swirl        fi
3471952afb71SBlue Swirl    done
3472952afb71SBlue Swirlfi
3473952afb71SBlue Swirl
347410ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3475528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
3476834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
34775a67135aSbellard
34784b1c11fdSDaniel P. Berrangetools=""
34794b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3480ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
34814b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
34824b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
34834b1c11fdSDaniel P. Berrange  fi
34844b1c11fdSDaniel P. Berrangefi
34854b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3486983eef5aSMeador Inge  if test "$virtfs" != no ; then
3487be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3488983eef5aSMeador Inge      virtfs=yes
348917bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3490983eef5aSMeador Inge    else
3491983eef5aSMeador Inge      if test "$virtfs" = yes; then
349276ad07a4SPeter Maydell        error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3493983eef5aSMeador Inge      fi
349417500370SAndreas Färber      virtfs=no
3495983eef5aSMeador Inge    fi
349617bff52bSM. Mohan Kumar  fi
3497d138cee9SMichael Rothfi
3498e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
3499e8ef31a3SMichael Tokarev  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3500e8ef31a3SMichael Tokarev      tools="qemu-ga\$(EXESUF) $tools"
3501e8ef31a3SMichael Tokarev      guest_agent=yes
3502e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
3503e8ef31a3SMichael Tokarev      guest_agent=no
3504e8ef31a3SMichael Tokarev  else
3505e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
3506ca35f780SPaolo Bonzini  fi
35074b1c11fdSDaniel P. Berrangefi
3508ca35f780SPaolo Bonzini
3509ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3510ca35f780SPaolo Bonziniroms=
3511ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3512ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3513ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3514ca35f780SPaolo Bonzini  roms="optionrom"
3515ca35f780SPaolo Bonzinifi
3516d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
351739ac8455SDavid Gibson  roms="$roms spapr-rtas"
351839ac8455SDavid Gibsonfi
3519ca35f780SPaolo Bonzini
35209933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
35219933c305SChristian Borntraeger  roms="$roms s390-ccw"
35229933c305SChristian Borntraegerfi
35239933c305SChristian Borntraeger
3524964c6fa1SRichard Henderson# Probe for the need for relocating the user-only binary.
3525964c6fa1SRichard Hendersonif test "$pie" = "no" ; then
3526964c6fa1SRichard Henderson  textseg_addr=
3527964c6fa1SRichard Henderson  case "$cpu" in
3528c72b26ecSRichard Henderson    arm | hppa | i386 | m68k | ppc | ppc64 | s390* | sparc | sparc64 | x86_64 | x32)
3529964c6fa1SRichard Henderson      textseg_addr=0x60000000
3530964c6fa1SRichard Henderson      ;;
3531964c6fa1SRichard Henderson    mips)
3532964c6fa1SRichard Henderson      textseg_addr=0x400000
3533964c6fa1SRichard Henderson      ;;
3534964c6fa1SRichard Henderson  esac
3535964c6fa1SRichard Henderson  if [ -n "$textseg_addr" ]; then
3536964c6fa1SRichard Henderson    cat > $TMPC <<EOF
3537964c6fa1SRichard Henderson    int main(void) { return 0; }
3538964c6fa1SRichard HendersonEOF
3539964c6fa1SRichard Henderson    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
3540964c6fa1SRichard Henderson    if ! compile_prog "" "$textseg_ldflags"; then
3541964c6fa1SRichard Henderson      # In case ld does not support -Ttext-segment, edit the default linker
3542964c6fa1SRichard Henderson      # script via sed to set the .text start addr.  This is needed on FreeBSD
3543964c6fa1SRichard Henderson      # at least.
3544964c6fa1SRichard Henderson      $ld --verbose | sed \
3545964c6fa1SRichard Henderson        -e '1,/==================================================/d' \
3546964c6fa1SRichard Henderson        -e '/==================================================/,$d' \
3547964c6fa1SRichard Henderson        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
3548964c6fa1SRichard Henderson        -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
3549964c6fa1SRichard Henderson      textseg_ldflags="-Wl,-T../config-host.ld"
3550964c6fa1SRichard Henderson    fi
3551964c6fa1SRichard Henderson  fi
3552964c6fa1SRichard Hendersonfi
3553964c6fa1SRichard Henderson
35545ca9388aSGerd Hoffmann# add pixman flags after all config tests are done
3555a540f158SPeter CrosthwaiteQEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags"
35565ca9388aSGerd Hoffmannlibs_softmmu="$libs_softmmu $pixman_libs"
35575ca9388aSGerd Hoffmann
35587d13299dSbellardecho "Install prefix    $prefix"
3559c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3560f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
35613aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
35628bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
35630f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
35641c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
356511d9f695Sbellardif test "$mingw32" = "no" ; then
35665a699bbbSLaszlo Ersekecho "local state directory   `eval echo $local_statedir`"
3567f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
356843ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
35695a699bbbSLaszlo Ersekelse
35705a699bbbSLaszlo Ersekecho "local state directory   queried at runtime"
357111d9f695Sbellardfi
35725a67135aSbellardecho "Source path       $source_path"
35737d13299dSbellardecho "C compiler        $cc"
357483469015Sbellardecho "Host C compiler   $host_cc"
3575*83f73fceSTomoki Sekiyamaecho "C++ compiler      $cxx"
35763c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
35770c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3578a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
35790c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
35807d13299dSbellardecho "make              $make"
35816a882643Spbrookecho "install           $install"
3582c886edfbSBlue Swirlecho "python            $python"
3583e2d8830eSBradif test "$slirp" = "yes" ; then
3584e2d8830eSBrad    echo "smbd              $smbd"
3585e2d8830eSBradfi
3586a98fd896Sbellardecho "host CPU          $cpu"
3587de83cd02Sbellardecho "host big endian   $bigendian"
358897a847bcSbellardecho "target list       $target_list"
3589ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
35907d13299dSbellardecho "gprof enabled     $gprof"
359103b4fe7dSaliguoriecho "sparse enabled    $sparse"
35921625af87Saliguoriecho "strip binaries    $strip_opt"
359305c2a3e7Sbellardecho "profiler          $profiler"
359443ce4dfeSbellardecho "static build      $static"
359585aa5189Sbellardecho "-Werror enabled   $werror"
35965b0753e0Sbellardif test "$darwin" = "yes" ; then
35975b0753e0Sbellard    echo "Cocoa support     $cocoa"
35985b0753e0Sbellardfi
3599e2134eb9SGerd Hoffmannecho "pixman            $pixman"
360097a847bcSbellardecho "SDL support       $sdl"
3601a4ccabcfSAnthony Liguoriecho "GTK support       $gtk"
36024d3b6f6eSbalrogecho "curses support    $curses"
3603769ce76dSAlexander Grafecho "curl support      $curl"
360467b915a5Sbellardecho "mingw32 support   $mingw32"
36050c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
3606b64ec4e4SFam Zhengecho "Block whitelist (rw) $block_drv_rw_whitelist"
3607b64ec4e4SFam Zhengecho "Block whitelist (ro) $block_drv_ro_whitelist"
36088ff9cbf7Smalcecho "Mixer emulation   $mixemu"
3609983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3610821601eaSJes Sorensenecho "VNC support       $vnc"
3611821601eaSJes Sorensenif test "$vnc" = "yes" ; then
36128d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
36132f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
36142f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3615efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
36167536ee4bSTim Hardeck    echo "VNC WS support    $vnc_ws"
3617821601eaSJes Sorensenfi
36183142255cSblueswir1if test -n "$sparc_cpu"; then
36193142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
36203142255cSblueswir1fi
3621e37630caSaliguoriecho "xen support       $xen"
36222e4d9fb1Saurel32echo "brlapi support    $brlapi"
3623a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3624a25dba17SJuan Quintelaecho "Documentation     $docs"
3625c5937220Spbrook[ ! -z "$uname_release" ] && \
3626c5937220Spbrookecho "uname -r          $uname_release"
3627379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
362840d6444eSAvi Kivityecho "PIE               $pie"
36298a16d273Sthsecho "vde support       $vde"
36305c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3631758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
363277755340Sthsecho "Install blobs     $blobs"
3633b31a0277SJuan Quintelaecho "KVM support       $kvm"
36342da776dbSMichael R. Hinesecho "RDMA support      $rdma"
36359195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3636f652e6afSaurel32echo "fdt support       $fdt"
3637ceb42de8Saliguoriecho "preadv support    $preadv"
36385f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3639e78815a5SAndreas Färberecho "madvise           $madvise"
3640e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
36411e9737daSRichard Hendersonecho "sigev_thread_id   $sigev_thread_id"
3642ee682d27SStefan Weilecho "uuid support      $uuid"
364347e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3644d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
36455e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
364694a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
36479410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
36482e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3649f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3650dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3651111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
36522b2325ffSGerd Hoffmannecho "libusb            $libusb"
365369354a83SHans de Goedeecho "usb net redir     $usb_redir"
3654b1e5fff4SMichael Walleecho "GLX support       $glx"
3655c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3656d138cee9SMichael Rothecho "build guest agent $guest_agent"
3657f794573eSEduardo Otuboecho "seccomp support   $seccomp"
36587c2acc70SPeter Maydellecho "coroutine backend $coroutine"
3659eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
3660583f6e7bSStefan Hajnocziecho "virtio-blk-data-plane $virtio_blk_data_plane"
36611d728c39SBlue Swirlecho "gcov              $gcov_tool"
36621d728c39SBlue Swirlecho "gcov enabled      $gcov"
3663ab214c29SStefan Bergerecho "TPM support       $tpm"
36640a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
36653b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
36663556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
366767b915a5Sbellard
36681ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
366924b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3670e8cd23deSbellardfi
367197a847bcSbellard
367298ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
367397a847bcSbellard
3674dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
3675dbd99ae3SStefan Weil
367698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
367798ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
367898ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
367998ec69acSJuan Quintelaecho >> $config_host_mak
368098ec69acSJuan Quintela
3681e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
368299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
368399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
36843aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
36858bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
36860f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
368799d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
368899d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
368922d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
36909afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
36919afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
36925a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
3693785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
36945a699bbbSLaszlo Ersekfi
3695f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
3696f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
3697f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
3698834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
3699f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
3700804edf29SJuan Quintela
370198ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3702727e5283SPaolo Bonzini
3703727e5283SPaolo Bonzinicase "$cpu" in
3704c72b26ecSRichard Henderson  arm|i386|x86_64|x32|ppc|aarch64)
3705727e5283SPaolo Bonzini    # The TCG interpreter currently does not support ld/st optimization.
3706727e5283SPaolo Bonzini    if test "$tcg_interpreter" = "no" ; then
3707727e5283SPaolo Bonzini        echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_host_mak
3708727e5283SPaolo Bonzini    fi
3709727e5283SPaolo Bonzini  ;;
3710727e5283SPaolo Bonziniesac
3711f8393946Saurel32if test "$debug_tcg" = "yes" ; then
37122358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3713f8393946Saurel32fi
37141625af87Saliguoriif test "$strip_opt" = "yes" ; then
371552ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
37161625af87Saliguorifi
37177d13299dSbellardif test "$bigendian" = "yes" ; then
3718e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
371997a847bcSbellardfi
372067b915a5Sbellardif test "$mingw32" = "yes" ; then
372198ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
37229fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
37239fe6de94SBlue Swirl  version_major=${rc_version%%.*}
37249fe6de94SBlue Swirl  rc_version=${rc_version#*.}
37259fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
37269fe6de94SBlue Swirl  rc_version=${rc_version#*.}
37279fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
37289fe6de94SBlue Swirl  version_micro=0
37299fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
37309fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3731210fa556Spbrookelse
373235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3733210fa556Spbrookfi
3734128ab2ffSblueswir1
3735dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3736dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3737dffcb71cSMark McLoughlinfi
3738dffcb71cSMark McLoughlin
373983fb7adfSbellardif test "$darwin" = "yes" ; then
374098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
374183fb7adfSbellardfi
3742b29fe3edSmalc
3743b29fe3edSmalcif test "$aix" = "yes" ; then
374498ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
3745b29fe3edSmalcfi
3746b29fe3edSmalc
3747ec530c81Sbellardif test "$solaris" = "yes" ; then
374898ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
37492358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
37500475a5caSths  if test "$needs_libsunmath" = "yes" ; then
375175b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
37520475a5caSths  fi
3753ec530c81Sbellardfi
3754179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3755179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3756179cf400SAndreas Färberfi
375797a847bcSbellardif test "$static" = "yes" ; then
375898ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
375997a847bcSbellardfi
37601ba16968SStefan Weilif test "$profiler" = "yes" ; then
37612358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
376205c2a3e7Sbellardfi
3763c20709aaSbellardif test "$slirp" = "yes" ; then
376498ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
3765e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3766c20709aaSbellardfi
37678a16d273Sthsif test "$vde" = "yes" ; then
376898ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
37698a16d273Sthsfi
377047e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
377147e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
377247e98658SCorey Bryantfi
37732358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
37740c58ac1cSmalcfor drv in $audio_drv_list; do
3775bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
377698ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
3777923e4521Smalc    if test "$drv" = "fmod"; then
37787aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3779fb065187Sbellard    fi
37800c58ac1cSmalcdone
378167f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
378267f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
378367f86e8eSJuan Quintelafi
3784d5631638Smalcif test "$audio_win_int" = "yes" ; then
3785d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3786d5631638Smalcfi
3787b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
3788b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
37898ff9cbf7Smalcif test "$mixemu" = "yes" ; then
379098ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
37918ff9cbf7Smalcfi
3792821601eaSJes Sorensenif test "$vnc" = "yes" ; then
3793821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
3794821601eaSJes Sorensenfi
37958d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
379698ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
37978d5d2d4cSthsfi
37982f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
379998ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
38002f9606b3Saliguorifi
3801821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
38022f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
38032f6f5c7aSCorentin Charyfi
3804821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
3805efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3806efe556adSCorentin Charyfi
38077536ee4bSTim Hardeckif test "$vnc_ws" = "yes" ; then
38087536ee4bSTim Hardeck  echo "CONFIG_VNC_WS=y" >> $config_host_mak
38097536ee4bSTim Hardeck  echo "VNC_WS_CFLAGS=$vnc_ws_cflags" >> $config_host_mak
38107536ee4bSTim Hardeckfi
381176655d6dSaliguoriif test "$fnmatch" = "yes" ; then
38122358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
381376655d6dSaliguorifi
3814ee682d27SStefan Weilif test "$uuid" = "yes" ; then
3815ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
3816ee682d27SStefan Weilfi
3817dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3818dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3819dce512deSChristoph Hellwigfi
3820b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
382198ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
38222358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
382398ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
382498ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
3825a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
382698ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
3827cc8ae6deSpbrookfi
38281ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
382998ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
38308ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
383149ecc3faSbellardfi
383249ecc3faSbellardif test "$cocoa" = "yes" ; then
383398ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
383449ecc3faSbellardfi
38354d3b6f6eSbalrogif test "$curses" = "yes" ; then
383698ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
3837ab4e5602SJan Kiszkafi
3838ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
38392358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3840ebc996f3SRiku Voipiofi
3841099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
38422358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
3843099d6b0fSRiku Voipiofi
384440ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
384540ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
384640ff6d7eSKevin Wolffi
38473ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
38482358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
38493ce34dfbSvibisreenivasanfi
3850c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
3851c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
3852c2882b96SRiku Voipiofi
3853d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
3854d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3855d0927938SUlrich Hechtfi
38563d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
38573d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
38583d4fa43eSKusanagi Kouichifi
3859c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
3860c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3861c727f47dSPeter Maydellfi
3862dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
3863dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
3864dace20dcSPeter Maydellfi
3865d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
3866d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
3867d0927938SUlrich Hechtfi
38684e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
38694e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
38704e0c6529SAlex Blighfi
3871cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
3872cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
3873cd758dd0SAlex Blighfi
38743b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
38753b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
38763b6edd16SPeter Maydellfi
38773b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
38783b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
38793b6edd16SPeter Maydellfi
38803b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
38813b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
38823b6edd16SPeter Maydellfi
3883a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
3884a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
3885a8fd1abaSPeter Maydellfi
38863b3f24adSaurel32if test "$inotify" = "yes" ; then
38872358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
38883b3f24adSaurel32fi
3889c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3890c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3891c05c7a73SRiku Voipiofi
38926ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
38936ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
38946ae9a1f4SJuan Quintelafi
38956ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
38966ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
38976ae9a1f4SJuan Quintelafi
3898769ce76dSAlexander Grafif test "$curl" = "yes" ; then
389998ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3900b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3901769ce76dSAlexander Graffi
39022e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
390398ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
39042e4d9fb1Saurel32fi
3905fb599c9aSbalrogif test "$bluez" = "yes" ; then
390698ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3907ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3908fb599c9aSbalrogfi
3909e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3910a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
3911a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
3912a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
3913a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
3914a4ccabcfSAnthony Liguorifi
3915e37630caSaliguoriif test "$xen" = "yes" ; then
39166dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3917d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3918e37630caSaliguorifi
39195c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
39205c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
39215c6c3a6cSChristoph Hellwigfi
3922758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3923758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3924758e8e38SVenkateswararao Jujjuri (JV)fi
39254f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
39264f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
39274f26f2b6SAvi Kivityfi
3928983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
3929758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
3930758e8e38SVenkateswararao Jujjuri (JV)fi
39315e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
39325e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
39335e9be92dSNicholas Bellingerfi
393477755340Sthsif test "$blobs" = "yes" ; then
393598ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
393677755340Sthsfi
3937bf9298b9Saliguoriif test "$iovec" = "yes" ; then
39382358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3939bf9298b9Saliguorifi
3940ceb42de8Saliguoriif test "$preadv" = "yes" ; then
39412358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3942ceb42de8Saliguorifi
3943f652e6afSaurel32if test "$fdt" = "yes" ; then
39443f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3945f652e6afSaurel32fi
3946dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3947dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3948dcc38d1cSMarcelo Tosattifi
39499195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
39509195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
39519195b2c2SStefan Weilfi
39525f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
39535f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
39545f6b9e8fSBlue Swirlfi
3955e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3956e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3957e78815a5SAndreas Färberfi
3958e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3959e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3960e78815a5SAndreas Färberfi
39611e9737daSRichard Hendersonif test "$sigev_thread_id" = "yes" ; then
39621e9737daSRichard Henderson  echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
39631e9737daSRichard Hendersonfi
396497a847bcSbellard
3965cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3966cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3967cd4ec0b4SGerd Hoffmannfi
3968cd4ec0b4SGerd Hoffmann
3969111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3970111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3971ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3972ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3973111a38b0SRobert Relyeafi
3974111a38b0SRobert Relyea
39752b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
39762b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
39772b2325ffSGerd Hoffmannfi
39782b2325ffSGerd Hoffmann
397969354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
398069354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
398169354a83SHans de Goedefi
398269354a83SHans de Goede
3983b1e5fff4SMichael Walleif test "$glx" = "yes" ; then
3984b1e5fff4SMichael Walle  echo "CONFIG_GLX=y" >> $config_host_mak
39852b6b7099SPaolo Bonzini  echo "GLX_LIBS=$glx_libs" >> $config_host_mak
398620ff075bSMichael Wallefi
398720ff075bSMichael Walle
3988c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3989c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3990c589b249SRonnie Sahlbergfi
3991c589b249SRonnie Sahlberg
3992f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
3993f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
3994f794573eSEduardo Otubofi
3995f794573eSEduardo Otubo
399683fb7adfSbellard# XXX: suppress that
39977d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
39982358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
39997d3505c5Sbellardfi
40007d3505c5Sbellard
40012358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
4002c5937220Spbrook
400320ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
400420ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
400520ff6c80SAnthony Liguorifi
40063556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
40073556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
40083556c233SPaolo Bonzinifi
4009f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
4010f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
4011f27aaf4bSChristian Brunnerfi
401220ff6c80SAnthony Liguori
40137c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
4014d0e2fce5SAneesh Kumar K.V
4015d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
4016d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
4017d2042378SAneesh Kumar K.Vfi
4018d2042378SAneesh Kumar K.V
4019e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
4020e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
4021e06a765eSHarsh Prateek Borafi
4022e06a765eSHarsh Prateek Bora
4023cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
4024cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
402506d71fa1SPeter Maydellfi
402606d71fa1SPeter Maydell
40273f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
40283f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
40293f4349dcSKevin Wolffi
40303f4349dcSKevin Wolf
40318ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
40328ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
40338ab1bf12SLuiz Capitulinofi
40348ab1bf12SLuiz Capitulino
403576a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
403676a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
403776a347e1SRichard Hendersonfi
403876a347e1SRichard Henderson
4039f540166bSRichard Hendersonif test "$int128" = "yes" ; then
4040f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
4041f540166bSRichard Hendersonfi
4042f540166bSRichard Henderson
40431e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
40441e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
40451e6e9acaSRichard Hendersonfi
40461e6e9acaSRichard Henderson
4047eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
4048eb100396SBharata B Rao  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
4049eb100396SBharata B Raofi
4050eb100396SBharata B Rao
40510c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
40520c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
40530c14fb47SBharata B Raofi
40540c14fb47SBharata B Rao
40550a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
40560a12ec87SRichard W.M. Jones  echo "CONFIG_LIBSSH2=y" >> $config_host_mak
40570a12ec87SRichard W.M. Jonesfi
40580a12ec87SRichard W.M. Jones
4059583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" ; then
40606e790746SPaolo Bonzini  echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
4061583f6e7bSStefan Hajnoczifi
4062583f6e7bSStefan Hajnoczi
406368063649Sblueswir1# USB host support
406468063649Sblueswir1case "$usb" in
406568063649Sblueswir1linux)
40664075975dSGerd Hoffmann  echo "HOST_USB=linux legacy" >> $config_host_mak
406768063649Sblueswir1;;
406868063649Sblueswir1bsd)
406998ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
407068063649Sblueswir1;;
40712b2325ffSGerd Hoffmannlibusb)
40722b2325ffSGerd Hoffmann  if test "$linux" = "yes"; then
40732b2325ffSGerd Hoffmann    echo "HOST_USB=libusb linux legacy" >> $config_host_mak
40742b2325ffSGerd Hoffmann  else
40752b2325ffSGerd Hoffmann    echo "HOST_USB=libusb legacy" >> $config_host_mak
40762b2325ffSGerd Hoffmann  fi
40772b2325ffSGerd Hoffmann;;
407868063649Sblueswir1*)
407998ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
408068063649Sblueswir1;;
408168063649Sblueswir1esac
408268063649Sblueswir1
40833b8acc11SPaolo Bonzini# TPM passthrough support?
40843b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
40853b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
40863b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
40873b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
40883b8acc11SPaolo Bonzini  fi
40893b8acc11SPaolo Bonzinifi
40903b8acc11SPaolo Bonzini
4091e4858974SLluís# use default implementation for tracing backend-specific routines
4092e4858974SLluístrace_default=yes
409394a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
40946d8a764eSLluísif test "$trace_backend" = "nop"; then
40956d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
409622890ab5SPrerna Saxenafi
40979410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
40986d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
4099e4858974SLluís  trace_default=no
41006d8a764eSLluís  # Set the appropriate trace file.
4101953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
41029410b56cSPrerna Saxenafi
41036d8a764eSLluísif test "$trace_backend" = "stderr"; then
41046d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
41059a82b6a5SLluís  trace_default=no
41066d8a764eSLluísfi
41076d8a764eSLluísif test "$trace_backend" = "ust"; then
41086d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
41096d8a764eSLluísfi
41106d8a764eSLluísif test "$trace_backend" = "dtrace"; then
41116d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
41126d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
41136d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
41146d8a764eSLluís  fi
4115c276b17dSDaniel P. Berrangefi
4116781e9545SEiichi Tsukataif test "$trace_backend" = "ftrace"; then
4117781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
4118781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4119781e9545SEiichi Tsukata    trace_default=no
4120781e9545SEiichi Tsukata  else
4121781e9545SEiichi Tsukata    feature_not_found "ftrace(trace backend)"
4122781e9545SEiichi Tsukata  fi
4123781e9545SEiichi Tsukatafi
41249410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
4125e4858974SLluísif test "$trace_default" = "yes"; then
4126e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
4127e4858974SLluísfi
41289410b56cSPrerna Saxena
41292da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
41302da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
41312da776dbSMichael R. Hinesfi
41322da776dbSMichael R. Hines
41335b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
41345b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
41355b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
41365b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
41375b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
41385b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
4139c72b26ecSRichard Hendersonelif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
41405b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
41415b5e3037SPaolo Bonzinielse
41425b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
41435b5e3037SPaolo Bonzinifi
41445b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
41455b5e3037SPaolo Bonzini
414698ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
414798ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4148804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4149804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
41501901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
41511901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
415221655882SPaolo Bonziniif test -n "$libtool"; then
415321655882SPaolo Bonzini  echo "INSTALL_PROG=\$(LIBTOOL) --mode=install $install -c -m 0755" >> $config_host_mak
415421655882SPaolo Bonzini  echo "INSTALL_LIB=\$(LIBTOOL) --mode=install $install -c -m 0644" >> $config_host_mak
415521655882SPaolo Bonzinielse
41561901cb14SBrad  echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
415721655882SPaolo Bonzini  echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
415821655882SPaolo Bonzinifi
4159c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
4160804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
41612b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
4162804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
4163*83f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
41643c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
4165804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
41663dd46c78SBlue Swirlecho "AS=$as" >> $config_host_mak
41673dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4168804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4169804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
41709fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
417144dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
4172e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
4173a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
4174f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
4175e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
4176e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
4177e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
4178e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
4179e39f0062SPaolo Bonzinifi
418042da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
418142da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
418242da6041SGerd Hoffmannelse
418342da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
418442da6041SGerd Hoffmannfi
4185e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
418637746c5eSMarc-André Lureauecho "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
418773da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
41883e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
4189804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
4190957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
419194dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
4192cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
41931d728c39SBlue Swirlif test "$gcov" = "yes" ; then
41941d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
41951d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
41961d728c39SBlue Swirlfi
4197804edf29SJuan Quintela
41986efd7517SPeter Maydell# use included Linux headers
41996efd7517SPeter Maydellif test "$linux" = "yes" ; then
4200a307beb6SAndreas Färber  mkdir -p linux-headers
42016efd7517SPeter Maydell  case "$cpu" in
4202c72b26ecSRichard Henderson  i386|x86_64|x32)
420308312a63SPeter Maydell    linux_arch=x86
42046efd7517SPeter Maydell    ;;
42056efd7517SPeter Maydell  ppcemb|ppc|ppc64)
420608312a63SPeter Maydell    linux_arch=powerpc
42076efd7517SPeter Maydell    ;;
42086efd7517SPeter Maydell  s390x)
420908312a63SPeter Maydell    linux_arch=s390
421008312a63SPeter Maydell    ;;
42111f080313SClaudio Fontana  aarch64)
42121f080313SClaudio Fontana    linux_arch=arm64
42131f080313SClaudio Fontana    ;;
421408312a63SPeter Maydell  *)
421508312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
421608312a63SPeter Maydell    linux_arch="$cpu"
42176efd7517SPeter Maydell    ;;
42186efd7517SPeter Maydell  esac
421908312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
422008312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
422108312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
422208312a63SPeter Maydell    fi
42236efd7517SPeter Maydellfi
42246efd7517SPeter Maydell
422597a847bcSbellardfor target in $target_list; do
422697a847bcSbellardtarget_dir="$target"
422725be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
4228c1799a84SPaolo Bonzinitarget_name=`echo $target | cut -d '-' -f 1`
422997a847bcSbellardtarget_bigendian="no"
42301f3d3c8fSJuan Quintela
4231c1799a84SPaolo Bonzinicase "$target_name" in
4232d15a9c23SAnthony Green  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
4233ea2d6a39SJuan Quintela  target_bigendian=yes
4234ea2d6a39SJuan Quintela  ;;
4235ea2d6a39SJuan Quintelaesac
423697a847bcSbellardtarget_softmmu="no"
4237997344f3Sbellardtarget_user_only="no"
4238831b7825Sthstarget_linux_user="no"
423984778508Sblueswir1target_bsd_user="no"
42409e407a85Spbrookcase "$target" in
4241c1799a84SPaolo Bonzini  ${target_name}-softmmu)
42429e407a85Spbrook    target_softmmu="yes"
42439e407a85Spbrook    ;;
4244c1799a84SPaolo Bonzini  ${target_name}-linux-user)
42459c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
424676ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a Linux host"
42479c7a4202SBlue Swirl    fi
42489e407a85Spbrook    target_user_only="yes"
42499e407a85Spbrook    target_linux_user="yes"
42509e407a85Spbrook    ;;
4251c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
42529cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
425376ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a BSD host"
42549c7a4202SBlue Swirl    fi
425584778508Sblueswir1    target_user_only="yes"
425684778508Sblueswir1    target_bsd_user="yes"
425784778508Sblueswir1    ;;
42589e407a85Spbrook  *)
425976ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
42609e407a85Spbrook    exit 1
42619e407a85Spbrook    ;;
42629e407a85Spbrookesac
4263831b7825Sths
426497a847bcSbellardmkdir -p $target_dir
426525be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
426697a847bcSbellard
4267e5fe0c52Spbrookbflt="no"
4268c1799a84SPaolo Bonziniinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"`
426956aebc89Spbrookgdb_xml_files=""
42707ba1e619Saliguori
4271c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
42726acff7daSJuan QuintelaTARGET_BASE_ARCH=""
4273e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
4274e73aae67SJuan Quintela
4275c1799a84SPaolo Bonzinicase "$target_name" in
42762408a527Saurel32  i386)
42772408a527Saurel32  ;;
42782408a527Saurel32  x86_64)
42796acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
42802408a527Saurel32  ;;
42812408a527Saurel32  alpha)
42822408a527Saurel32  ;;
42832408a527Saurel32  arm|armeb)
4284b498c8a0SJuan Quintela    TARGET_ARCH=arm
4285e5fe0c52Spbrook    bflt="yes"
428656aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
42872408a527Saurel32  ;;
42882408a527Saurel32  cris)
42892408a527Saurel32  ;;
4290613a22c9SMichael Walle  lm32)
4291613a22c9SMichael Walle  ;;
42922408a527Saurel32  m68k)
42930938cda5Saurel32    bflt="yes"
429456aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
42952408a527Saurel32  ;;
4296877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
4297877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
429872b675caSEdgar E. Iglesias    bflt="yes"
429972b675caSEdgar E. Iglesias  ;;
43002408a527Saurel32  mips|mipsel)
4301b498c8a0SJuan Quintela    TARGET_ARCH=mips
430225be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
43032408a527Saurel32  ;;
43042408a527Saurel32  mipsn32|mipsn32el)
4305597e2cecSRichard Henderson    TARGET_ARCH=mips64
43066acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
430725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
4308597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
43092408a527Saurel32  ;;
43102408a527Saurel32  mips64|mips64el)
4311b498c8a0SJuan Quintela    TARGET_ARCH=mips64
43126acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
431325be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
43142408a527Saurel32  ;;
4315d15a9c23SAnthony Green  moxie)
4316d15a9c23SAnthony Green  ;;
4317e67db06eSJia Liu  or32)
4318e67db06eSJia Liu    TARGET_ARCH=openrisc
4319e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
4320e67db06eSJia Liu  ;;
43212408a527Saurel32  ppc)
4322c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
43232408a527Saurel32  ;;
43242408a527Saurel32  ppcemb)
43256acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4326e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4327c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
43282408a527Saurel32  ;;
43292408a527Saurel32  ppc64)
43306acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4331e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4332c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
43332408a527Saurel32  ;;
43342408a527Saurel32  ppc64abi32)
4335b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
43366acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4337e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
433825be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
4339c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
43402408a527Saurel32  ;;
43412408a527Saurel32  sh4|sh4eb)
4342b498c8a0SJuan Quintela    TARGET_ARCH=sh4
43434dbed897Spbrook    bflt="yes"
43442408a527Saurel32  ;;
43452408a527Saurel32  sparc)
43462408a527Saurel32  ;;
43472408a527Saurel32  sparc64)
43486acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
43492408a527Saurel32  ;;
43502408a527Saurel32  sparc32plus)
4351b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
43526acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
4353e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
435425be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
43552408a527Saurel32  ;;
435624e804ecSAlexander Graf  s390x)
435724e804ecSAlexander Graf  ;;
4358d2fbca94SGuan Xuetao  unicore32)
4359d2fbca94SGuan Xuetao  ;;
4360cfa550c6SMax Filippov  xtensa|xtensaeb)
4361cfa550c6SMax Filippov    TARGET_ARCH=xtensa
4362cfa550c6SMax Filippov  ;;
43632408a527Saurel32  *)
436476ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
43652408a527Saurel32  ;;
43662408a527Saurel32esac
43675e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
43685e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
43695e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
43705e8861a0SPaolo Bonzinifi
43715e8861a0SPaolo Bonzini
43725e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
43735e8861a0SPaolo Bonzini
437499afc91dSDaniel P. Berrangeupper() {
437599afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
437699afc91dSDaniel P. Berrange}
437799afc91dSDaniel P. Berrange
437899afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
437925be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
4380c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
438125be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
4382e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
4383e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
4384e6e91b9cSJuan Quintelafi
438525be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
4386c1799a84SPaolo Bonzinicase "$target_name" in
43871b0c87fcSJuan Quintela  i386|x86_64)
43881b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
438925be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
4390eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
4391eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
4392eb6fda0fSAnthony PERARD      fi
4393432d268cSJun Nakajima    fi
439459d21e53SAlexander Graf    ;;
439559d21e53SAlexander Graf  *)
43961b0c87fcSJuan Quintelaesac
4397c1799a84SPaolo Bonzinicase "$target_name" in
439868b05c42SPeter Maydell  arm|i386|x86_64|ppcemb|ppc|ppc64|s390x)
4399c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
4400c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
4401c1799a84SPaolo Bonzini      \( "$target_name" = "$cpu" -o \
4402c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
4403c1799a84SPaolo Bonzini      \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
4404c1799a84SPaolo Bonzini      \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
4405c1799a84SPaolo Bonzini      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
4406c1799a84SPaolo Bonzini      \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
4407c1799a84SPaolo Bonzini      \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
440825be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
44091ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
4410d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
4411d5970055SMichael S. Tsirkin      fi
4412c59249f9SJuan Quintela    fi
4413c59249f9SJuan Quintelaesac
4414de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
441525be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
441697a847bcSbellardfi
441797a847bcSbellardif test "$target_softmmu" = "yes" ; then
441825be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
4419de83cd02Sbellardfi
4420997344f3Sbellardif test "$target_user_only" = "yes" ; then
442125be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
4422a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
4423997344f3Sbellardfi
4424831b7825Sthsif test "$target_linux_user" = "yes" ; then
442525be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
4426831b7825Sthsfi
442756aebc89Spbrooklist=""
442856aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
442956aebc89Spbrook  for x in $gdb_xml_files; do
443056aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
443156aebc89Spbrook  done
443225be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
44333d0f1517SJuan Quintelafi
4434de83cd02Sbellard
4435e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
443625be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
4437e5fe0c52Spbrookfi
4438379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
443925be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
4440379f6698SPaul Brookfi
444184778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
444225be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
444384778508Sblueswir1fi
44445b0753e0Sbellard
44454afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
4446fa282484SJuan Quintela
44474afddb55SJuan Quintelacflags=""
4448fa282484SJuan Quintelaldflags=""
44499b8e111fSJuan Quintela
445064656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
445164656024SJuan Quintela  case "$i" in
445264656024SJuan Quintela  alpha)
445325be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
445476cad711SPaolo Bonzini    echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
445564656024SJuan Quintela  ;;
445664656024SJuan Quintela  arm)
445725be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
445876cad711SPaolo Bonzini    echo "CONFIG_ARM_DIS=y"  >> config-all-disas.mak
445964656024SJuan Quintela  ;;
446064656024SJuan Quintela  cris)
446125be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
446276cad711SPaolo Bonzini    echo "CONFIG_CRIS_DIS=y"  >> config-all-disas.mak
446364656024SJuan Quintela  ;;
446464656024SJuan Quintela  hppa)
446525be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
446676cad711SPaolo Bonzini    echo "CONFIG_HPPA_DIS=y"  >> config-all-disas.mak
446764656024SJuan Quintela  ;;
4468c72b26ecSRichard Henderson  i386|x86_64|x32)
446925be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
447076cad711SPaolo Bonzini    echo "CONFIG_I386_DIS=y"  >> config-all-disas.mak
447164656024SJuan Quintela  ;;
4472903ec55cSAurelien Jarno  ia64*)
4473903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
447476cad711SPaolo Bonzini    echo "CONFIG_IA64_DIS=y"  >> config-all-disas.mak
4475903ec55cSAurelien Jarno  ;;
447679368f49SMichael Walle  lm32)
447779368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
447876cad711SPaolo Bonzini    echo "CONFIG_LM32_DIS=y"  >> config-all-disas.mak
447979368f49SMichael Walle  ;;
448064656024SJuan Quintela  m68k)
448125be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
448276cad711SPaolo Bonzini    echo "CONFIG_M68K_DIS=y"  >> config-all-disas.mak
448364656024SJuan Quintela  ;;
4484877fdc12SEdgar E. Iglesias  microblaze*)
448525be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
448676cad711SPaolo Bonzini    echo "CONFIG_MICROBLAZE_DIS=y"  >> config-all-disas.mak
448764656024SJuan Quintela  ;;
448864656024SJuan Quintela  mips*)
448925be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
449076cad711SPaolo Bonzini    echo "CONFIG_MIPS_DIS=y"  >> config-all-disas.mak
449164656024SJuan Quintela  ;;
4492d15a9c23SAnthony Green  moxie*)
4493d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> $config_target_mak
4494d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> config-all-disas.mak
4495d15a9c23SAnthony Green  ;;
4496e67db06eSJia Liu  or32)
4497e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
449876cad711SPaolo Bonzini    echo "CONFIG_OPENRISC_DIS=y"  >> config-all-disas.mak
4499e67db06eSJia Liu  ;;
450064656024SJuan Quintela  ppc*)
450125be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
450276cad711SPaolo Bonzini    echo "CONFIG_PPC_DIS=y"  >> config-all-disas.mak
450364656024SJuan Quintela  ;;
450424e804ecSAlexander Graf  s390*)
450525be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
450676cad711SPaolo Bonzini    echo "CONFIG_S390_DIS=y"  >> config-all-disas.mak
450764656024SJuan Quintela  ;;
450864656024SJuan Quintela  sh4)
450925be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
451076cad711SPaolo Bonzini    echo "CONFIG_SH4_DIS=y"  >> config-all-disas.mak
451164656024SJuan Quintela  ;;
451264656024SJuan Quintela  sparc*)
451325be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
451476cad711SPaolo Bonzini    echo "CONFIG_SPARC_DIS=y"  >> config-all-disas.mak
451564656024SJuan Quintela  ;;
4516cfa550c6SMax Filippov  xtensa*)
4517cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
451876cad711SPaolo Bonzini    echo "CONFIG_XTENSA_DIS=y"  >> config-all-disas.mak
4519cfa550c6SMax Filippov  ;;
452064656024SJuan Quintela  esac
452164656024SJuan Quinteladone
45229195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
45239195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
452476cad711SPaolo Bonzini  echo "CONFIG_TCI_DIS=y"  >> config-all-disas.mak
45259195b2c2SStefan Weilfi
452664656024SJuan Quintela
45276ee7126fSJuan Quintelacase "$ARCH" in
45286ee7126fSJuan Quintelaalpha)
45296ee7126fSJuan Quintela  # Ensure there's only a single GP
45306ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
45316ee7126fSJuan Quintela;;
45326ee7126fSJuan Quintelaesac
45336ee7126fSJuan Quintela
4534d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
453525be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4536d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4537d02c1db3SJuan Quintela    cflags="-p $cflags"
4538d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4539d02c1db3SJuan Quintela  fi
4540d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4541d02c1db3SJuan Quintela    ldflags="-p $ldflags"
454225be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4543d02c1db3SJuan Quintela  fi
4544d02c1db3SJuan Quintelafi
4545d02c1db3SJuan Quintela
45469b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4547964c6fa1SRichard Henderson  ldflags="$ldflags $textseg_ldflags"
4548fa282484SJuan Quintelafi
4549fa282484SJuan Quintela
455025be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
455125be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4552fa282484SJuan Quintela
455397a847bcSbellarddone # for target in $targets
45547d13299dSbellard
4555b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
4556b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
4557b776eca1SGerd Hoffmannfi
4558b776eca1SGerd Hoffmann
45592da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
45602da776dbSMichael R. Hinesecho "CONFIG_RDMA=y" >> $config_host_mak
45612da776dbSMichael R. Hinesfi
45622da776dbSMichael R. Hines
4563a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
4564a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
4565a540f158SPeter Crosthwaitefi
4566a540f158SPeter Crosthwaite
4567d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
456864160cd2SAnthony LiguoriDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa"
45699933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
45702d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
45712dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
4572c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4573c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
4574aaa2ebc5SAndreas FärberFILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
4575ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4576446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
45779933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
45782d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
45794652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
4580753d11f2SRichard Hendersonfor bios_file in \
4581753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
45825acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
4583753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4584753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4585e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
4586753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4587753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4588753d11f2SRichard Hendersondo
45897ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
45907ea78b74SJan Kiszkadone
4591d1807a4fSPaolo Bonzinimkdir -p $DIRS
45927d13299dSbellardfor f in $FILES ; do
459372b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4594f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4595f9245e10SPeter Maydell    fi
45967d13299dSbellarddone
45971ad2134fSPaul Brook
4598c34ebfdcSAnthony Liguori# temporary config to build submodules
45992d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4600c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
460137116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4602c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
46033dd46c78SBlue Swirl    echo "AS=$as" >> $config_mak
4604c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4605c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
46063dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
4607c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4608c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
4609c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4610c34ebfdcSAnthony Liguoridone
4611c34ebfdcSAnthony Liguori
4612b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4613b40292e7SJan Kiszka  mkdir -p QMP
4614b40292e7SJan Kiszkafi
4615