xref: /openbmc/qemu/configure (revision f9943cd58f8a053172aa701d79da512ccd10d758)
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
308dc38a78SPeter Maydelldo_cc() {
318dc38a78SPeter Maydell    # Run the compiler, capturing its output to the log.
328dc38a78SPeter Maydell    echo $cc "$@" >> config.log
338dc38a78SPeter Maydell    $cc "$@" >> config.log 2>&1 || return $?
348dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
358dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
368dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
378dc38a78SPeter Maydell    # obvious to developers.
388dc38a78SPeter Maydell    if test "$werror" != "yes"; then
398dc38a78SPeter Maydell        return 0
408dc38a78SPeter Maydell    fi
418dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
428dc38a78SPeter Maydell    case "$*" in
438dc38a78SPeter Maydell        *-Werror*)
448dc38a78SPeter Maydell           return 0
458dc38a78SPeter Maydell        ;;
468dc38a78SPeter Maydell    esac
478dc38a78SPeter Maydell    echo $cc -Werror "$@" >> config.log
488dc38a78SPeter Maydell    $cc -Werror "$@" >> config.log 2>&1 && return $?
498dc38a78SPeter Maydell    echo "ERROR: configure test passed without -Werror but failed with -Werror."
508dc38a78SPeter Maydell    echo "This is probably a bug in the configure script. The failing command"
518dc38a78SPeter Maydell    echo "will be at the bottom of config.log."
528dc38a78SPeter Maydell    echo "You can run configure with --disable-werror to bypass this check."
538dc38a78SPeter Maydell    exit 1
548dc38a78SPeter Maydell}
558dc38a78SPeter Maydell
5652166aa0SJuan Quintelacompile_object() {
578dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
5852166aa0SJuan Quintela}
5952166aa0SJuan Quintela
6052166aa0SJuan Quintelacompile_prog() {
6152166aa0SJuan Quintela  local_cflags="$1"
6252166aa0SJuan Quintela  local_ldflags="$2"
638dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
6452166aa0SJuan Quintela}
6552166aa0SJuan Quintela
6611568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
6711568d6dSPaolo Bonzinisymlink() {
6872b8b5a1SStefan Weil  rm -rf "$2"
69ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
7072b8b5a1SStefan Weil  ln -s "$1" "$2"
7111568d6dSPaolo Bonzini}
7211568d6dSPaolo Bonzini
730dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
740dba6195SLoïc Minier# executable or a builtin)
750dba6195SLoïc Minierhas() {
760dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
770dba6195SLoïc Minier}
780dba6195SLoïc Minier
790dba6195SLoïc Minier# search for an executable in PATH
800dba6195SLoïc Minierpath_of() {
810dba6195SLoïc Minier    local_command="$1"
820dba6195SLoïc Minier    local_ifs="$IFS"
830dba6195SLoïc Minier    local_dir=""
840dba6195SLoïc Minier
850dba6195SLoïc Minier    # pathname has a dir component?
860dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
870dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
880dba6195SLoïc Minier            echo "$local_command"
890dba6195SLoïc Minier            return 0
900dba6195SLoïc Minier        fi
910dba6195SLoïc Minier    fi
920dba6195SLoïc Minier    if [ -z "$local_command" ]; then
930dba6195SLoïc Minier        return 1
940dba6195SLoïc Minier    fi
950dba6195SLoïc Minier
960dba6195SLoïc Minier    IFS=:
970dba6195SLoïc Minier    for local_dir in $PATH; do
980dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
990dba6195SLoïc Minier            echo "$local_dir/$local_command"
1000dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1010dba6195SLoïc Minier            return 0
1020dba6195SLoïc Minier        fi
1030dba6195SLoïc Minier    done
1040dba6195SLoïc Minier    # not found
1050dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1060dba6195SLoïc Minier    return 1
1070dba6195SLoïc Minier}
1080dba6195SLoïc Minier
1097d13299dSbellard# default parameters
110ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
1112ff6b91eSJuan Quintelacpu=""
1121e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
11343ce4dfeSbellardstatic="no"
1147d13299dSbellardcross_prefix=""
1150c58ac1cSmalcaudio_drv_list=""
11661dc008fSAnthony Liguoriaudio_card_list="ac97 es1370 sb16 hda"
11761dc008fSAnthony Liguoriaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
118eb852011SMarkus Armbrusterblock_drv_whitelist=""
119e49d021eSPeter Maydellhost_cc="cc"
12073da375eSJuan Quintelalibs_softmmu=""
1213e2e0e6bSJuan Quintelalibs_tools=""
12267f86e8eSJuan Quintelaaudio_pt_int=""
123d5631638Smalcaudio_win_int=""
1242b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
125957f1f99SMichael Rothlibs_qga=""
1265bc62e01SGerd Hoffmanndebug_info="yes"
127ac0df51dSaliguori
128afb63ebdSStefan Weil# Don't accept a target_list environment variable.
129afb63ebdSStefan Weilunset target_list
130377529c0SPaolo Bonzini
131377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
132377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
133377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
134377529c0SPaolo Bonzini#              unless --disable-foo is given
135377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
136377529c0SPaolo Bonzini#              feature will searched for,
137377529c0SPaolo Bonzini#              if not found, configure exits with error
138377529c0SPaolo Bonzini#
139377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
140377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
141377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
142377529c0SPaolo Bonzini
143377529c0SPaolo Bonzinibluez=""
144377529c0SPaolo Bonzinibrlapi=""
145377529c0SPaolo Bonzinicurl=""
146377529c0SPaolo Bonzinicurses=""
147377529c0SPaolo Bonzinidocs=""
148377529c0SPaolo Bonzinifdt=""
149377529c0SPaolo Bonzininptl=""
150e2134eb9SGerd Hoffmannpixman=""
151377529c0SPaolo Bonzinisdl=""
152983eef5aSMeador Ingevirtfs=""
153821601eaSJes Sorensenvnc="yes"
154377529c0SPaolo Bonzinisparse="no"
155377529c0SPaolo Bonziniuuid=""
156377529c0SPaolo Bonzinivde=""
157377529c0SPaolo Bonzinivnc_tls=""
158377529c0SPaolo Bonzinivnc_sasl=""
159377529c0SPaolo Bonzinivnc_jpeg=""
160377529c0SPaolo Bonzinivnc_png=""
161377529c0SPaolo Bonzinixen=""
162d5b93ddfSAnthony PERARDxen_ctrl_version=""
163eb6fda0fSAnthony PERARDxen_pci_passthrough=""
164377529c0SPaolo Bonzinilinux_aio=""
16547e98658SCorey Bryantcap_ng=""
166377529c0SPaolo Bonziniattr=""
1674f26f2b6SAvi Kivitylibattr=""
168377529c0SPaolo Bonzinixfs=""
169377529c0SPaolo Bonzini
170d41a75a2SBradvhost_net="no"
171d41a75a2SBradkvm="no"
172377529c0SPaolo Bonzinigprof="no"
173377529c0SPaolo Bonzinidebug_tcg="no"
174377529c0SPaolo Bonzinidebug="no"
175377529c0SPaolo Bonzinistrip_opt="yes"
1769195b2c2SStefan Weiltcg_interpreter="no"
177377529c0SPaolo Bonzinibigendian="no"
178377529c0SPaolo Bonzinimingw32="no"
1791d728c39SBlue Swirlgcov="no"
1801d728c39SBlue Swirlgcov_tool="gcov"
181377529c0SPaolo BonziniEXESUF=""
182377529c0SPaolo Bonziniprefix="/usr/local"
183377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
184528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
185850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
186377529c0SPaolo Bonzinibindir="\${prefix}/bin"
1873aa5d2beSAlon Levylibdir="\${prefix}/lib"
1888bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
1890f94d6daSAlon Levyincludedir="\${prefix}/include"
190377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
191785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
192377529c0SPaolo Bonziniconfsuffix="/qemu"
193377529c0SPaolo Bonzinislirp="yes"
194377529c0SPaolo Bonzinifmod_lib=""
195377529c0SPaolo Bonzinifmod_inc=""
196377529c0SPaolo Bonzinioss_lib=""
197377529c0SPaolo Bonzinibsd="no"
198377529c0SPaolo Bonzinilinux="no"
199377529c0SPaolo Bonzinisolaris="no"
200377529c0SPaolo Bonziniprofiler="no"
201377529c0SPaolo Bonzinicocoa="no"
202377529c0SPaolo Bonzinisoftmmu="yes"
203377529c0SPaolo Bonzinilinux_user="no"
204377529c0SPaolo Bonzinibsd_user="no"
20530163d89SPeter Maydellguest_base="yes"
206377529c0SPaolo Bonziniuname_release=""
207377529c0SPaolo Bonzinimixemu="no"
208377529c0SPaolo Bonziniaix="no"
209377529c0SPaolo Bonziniblobs="yes"
210377529c0SPaolo Bonzinipkgversion=""
21140d6444eSAvi Kivitypie=""
212377529c0SPaolo Bonzinizero_malloc=""
213377529c0SPaolo Bonzinitrace_backend="nop"
214377529c0SPaolo Bonzinitrace_file="trace"
215377529c0SPaolo Bonzinispice=""
216377529c0SPaolo Bonzinirbd=""
21736707144SAlon Levysmartcard=""
218111a38b0SRobert Relyeasmartcard_nss=""
21969354a83SHans de Goedeusb_redir=""
220430a3c18SMichael Walleopengl=""
2211ece9905SAlon Levyzlib="yes"
222d138cee9SMichael Rothguest_agent="yes"
2234b1c11fdSDaniel P. Berrangewant_tools="yes"
224c589b249SRonnie Sahlberglibiscsi=""
225519175a2SAlex Barcelocoroutine=""
226f794573eSEduardo Otuboseccomp=""
227eb100396SBharata B Raoglusterfs=""
228583f6e7bSStefan Hajnoczivirtio_blk_data_plane=""
229377529c0SPaolo Bonzini
230ac0df51dSaliguori# parse CC options first
231ac0df51dSaliguorifor opt do
232ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
233ac0df51dSaliguori  case "$opt" in
234ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
235ac0df51dSaliguori  ;;
2363d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
237ac0df51dSaliguori  ;;
238ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
239ca4deeb1SPaolo Bonzini  ;;
2402ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2412ff6b91eSJuan Quintela  ;;
242a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
243*f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
244e2a2ed06SJuan Quintela  ;;
245e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
246*f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
247e2a2ed06SJuan Quintela  ;;
2485bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2495bc62e01SGerd Hoffmann  ;;
2505bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2515bc62e01SGerd Hoffmann  ;;
252ac0df51dSaliguori  esac
253ac0df51dSaliguoridone
254ac0df51dSaliguori# OS specific
255ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
25693148aa5SStefan Weil# we can eliminate its usage altogether.
257ac0df51dSaliguori
258e49d021eSPeter Maydell# Preferred compiler:
259e49d021eSPeter Maydell#  ${CC} (if set)
260e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
261e49d021eSPeter Maydell#  system compiler
262e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
263e49d021eSPeter Maydell  cc="$host_cc"
264e49d021eSPeter Maydellelse
265b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
266e49d021eSPeter Maydellfi
267e49d021eSPeter Maydell
268b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
2693dd46c78SBlue Swirlas="${AS-${cross_prefix}as}"
2703dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
271b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
272b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
2733f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
274b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
275b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
27617884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
27717884d7bSSergei Trofimovichquery_pkg_config() {
27817884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
27917884d7bSSergei Trofimovich}
28017884d7bSSergei Trofimovichpkg_config=query_pkg_config
281b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
282ac0df51dSaliguori
283be17dc90SMichael S. Tsirkin# default flags for all hosts
284be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
285f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
286be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
287be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
2886b4c305cSPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
2895bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
2905bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
291be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
2925bc62e01SGerd Hoffmannfi
293be17dc90SMichael S. Tsirkin
294ca4deeb1SPaolo Bonzini# make source path absolute
295ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
296ca4deeb1SPaolo Bonzini
297ac0df51dSaliguoricheck_define() {
298ac0df51dSaliguoricat > $TMPC <<EOF
299ac0df51dSaliguori#if !defined($1)
300fd786e1aSPeter Maydell#error $1 not defined
301ac0df51dSaliguori#endif
302ac0df51dSaliguoriint main(void) { return 0; }
303ac0df51dSaliguoriEOF
30452166aa0SJuan Quintela  compile_object
305ac0df51dSaliguori}
306ac0df51dSaliguori
307bbea4050SPeter Maydellif check_define __linux__ ; then
308bbea4050SPeter Maydell  targetos="Linux"
309bbea4050SPeter Maydellelif check_define _WIN32 ; then
310bbea4050SPeter Maydell  targetos='MINGW32'
311bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
312bbea4050SPeter Maydell  targetos='OpenBSD'
313bbea4050SPeter Maydellelif check_define __sun__ ; then
314bbea4050SPeter Maydell  targetos='SunOS'
315bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
316bbea4050SPeter Maydell  targetos='Haiku'
317bbea4050SPeter Maydellelse
318bbea4050SPeter Maydell  targetos=`uname -s`
319bbea4050SPeter Maydellfi
320bbea4050SPeter Maydell
321bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
322bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
323bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
324bbea4050SPeter Maydell# the correct CPU with the --cpu option.
325bbea4050SPeter Maydellcase $targetos in
326bbea4050SPeter MaydellDarwin)
327bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
328bbea4050SPeter Maydell  # run 64-bit userspace code.
329bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
330bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
331bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
332bbea4050SPeter Maydell    cpu="x86_64"
333bbea4050SPeter Maydell  fi
334bbea4050SPeter Maydell  ;;
335bbea4050SPeter MaydellSunOS)
336bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
337bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
338bbea4050SPeter Maydell    cpu="x86_64"
339bbea4050SPeter Maydell  fi
340bbea4050SPeter Maydellesac
341bbea4050SPeter Maydell
3422ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3432ff6b91eSJuan Quintela  # command line argument
3442ff6b91eSJuan Quintela  :
3452ff6b91eSJuan Quintelaelif check_define __i386__ ; then
346ac0df51dSaliguori  cpu="i386"
347ac0df51dSaliguorielif check_define __x86_64__ ; then
348ac0df51dSaliguori  cpu="x86_64"
3493aa9bd6cSblueswir1elif check_define __sparc__ ; then
3503aa9bd6cSblueswir1  if check_define __arch64__ ; then
3513aa9bd6cSblueswir1    cpu="sparc64"
3523aa9bd6cSblueswir1  else
3533aa9bd6cSblueswir1    cpu="sparc"
3543aa9bd6cSblueswir1  fi
355fdf7ed96Smalcelif check_define _ARCH_PPC ; then
356fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
357fdf7ed96Smalc    cpu="ppc64"
358ac0df51dSaliguori  else
359fdf7ed96Smalc    cpu="ppc"
360fdf7ed96Smalc  fi
361afa05235SAurelien Jarnoelif check_define __mips__ ; then
362afa05235SAurelien Jarno  cpu="mips"
363477ba620SAurelien Jarnoelif check_define __ia64__ ; then
364477ba620SAurelien Jarno  cpu="ia64"
365d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
366d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
367d66ed0eaSAurelien Jarno    cpu="s390x"
368d66ed0eaSAurelien Jarno  else
369d66ed0eaSAurelien Jarno    cpu="s390"
370d66ed0eaSAurelien Jarno  fi
37121d89f84SPeter Maydellelif check_define __arm__ ; then
37221d89f84SPeter Maydell  cpu="arm"
373f28ffed5SBradelif check_define __hppa__ ; then
374f28ffed5SBrad  cpu="hppa"
375fdf7ed96Smalcelse
376fdf7ed96Smalc  cpu=`uname -m`
377ac0df51dSaliguorifi
378ac0df51dSaliguori
379359bc95dSPeter MaydellARCH=
380359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
381359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
3827d13299dSbellardcase "$cpu" in
383359bc95dSPeter Maydell  ia64|ppc|ppc64|s390|s390x|sparc64)
384ea8f20f8SJuan Quintela    cpu="$cpu"
385ea8f20f8SJuan Quintela  ;;
3867d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
38797a847bcSbellard    cpu="i386"
3887d13299dSbellard  ;;
389aaa5fa14Saurel32  x86_64|amd64)
390aaa5fa14Saurel32    cpu="x86_64"
391aaa5fa14Saurel32  ;;
39221d89f84SPeter Maydell  armv*b|armv*l|arm)
39321d89f84SPeter Maydell    cpu="arm"
3947d13299dSbellard  ;;
395f28ffed5SBrad  hppa|parisc|parisc64)
396f54b3f92Saurel32    cpu="hppa"
397f54b3f92Saurel32  ;;
398afa05235SAurelien Jarno  mips*)
399afa05235SAurelien Jarno    cpu="mips"
400afa05235SAurelien Jarno  ;;
4013142255cSblueswir1  sparc|sun4[cdmuv])
402ae228531Sbellard    cpu="sparc"
403ae228531Sbellard  ;;
4047d13299dSbellard  *)
405359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
406359bc95dSPeter Maydell    ARCH=unknown
4077d13299dSbellard  ;;
4087d13299dSbellardesac
409359bc95dSPeter Maydellif test -z "$ARCH"; then
410359bc95dSPeter Maydell  ARCH="$cpu"
411359bc95dSPeter Maydellfi
412e2d52ad3SJuan Quintela
4137d13299dSbellard# OS specific
4140dbfc675SJuan Quintela
4157d13299dSbellardcase $targetos in
416c326e0afSbellardCYGWIN*)
417c326e0afSbellard  mingw32="yes"
418a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
419d5631638Smalc  audio_possible_drivers="winwave sdl"
420d5631638Smalc  audio_drv_list="winwave"
421c326e0afSbellard;;
42267b915a5SbellardMINGW32*)
42367b915a5Sbellard  mingw32="yes"
424d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
425d5631638Smalc  audio_drv_list="winwave"
42667b915a5Sbellard;;
4275c40d2bdSthsGNU/kFreeBSD)
428a167ba50SAurelien Jarno  bsd="yes"
4290c58ac1cSmalc  audio_drv_list="oss"
430f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4315c40d2bdSths;;
4327d3505c5SbellardFreeBSD)
4337d3505c5Sbellard  bsd="yes"
4340db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4350c58ac1cSmalc  audio_drv_list="oss"
436f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
437f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
438f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
4397d3505c5Sbellard;;
440c5e97233Sblueswir1DragonFly)
441c5e97233Sblueswir1  bsd="yes"
4420db4a067SPaolo Bonzini  make="${MAKE-gmake}"
443c5e97233Sblueswir1  audio_drv_list="oss"
444c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
445c5e97233Sblueswir1;;
4467d3505c5SbellardNetBSD)
4477d3505c5Sbellard  bsd="yes"
4480db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4490c58ac1cSmalc  audio_drv_list="oss"
450c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4518ef92a88Sblueswir1  oss_lib="-lossaudio"
4527d3505c5Sbellard;;
4537d3505c5SbellardOpenBSD)
4547d3505c5Sbellard  bsd="yes"
4550db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4560c58ac1cSmalc  audio_drv_list="oss"
457c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4582f6a1ab0Sblueswir1  oss_lib="-lossaudio"
4597d3505c5Sbellard;;
46083fb7adfSbellardDarwin)
46183fb7adfSbellard  bsd="yes"
46283fb7adfSbellard  darwin="yes"
4631b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
464a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4650c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4661b0f9cc2Saliguori  else
467a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
4681b0f9cc2Saliguori  fi
469fd677642Sths  cocoa="yes"
4700c58ac1cSmalc  audio_drv_list="coreaudio"
471c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4720c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4737973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
474a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
475a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
476a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
47783fb7adfSbellard;;
478ec530c81SbellardSunOS)
479ec530c81Sbellard  solaris="yes"
4800db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4810db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
482fa58948dSBlue Swirl  ld="gld"
483e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
4840475a5caSths  needs_libsunmath="no"
485c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
486c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4870475a5caSths    if test "$solarisrev" -le 9 ; then
4880475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4890475a5caSths        needs_libsunmath="yes"
490f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
491f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
492f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4930475a5caSths      else
4940475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4950475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4960475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4970475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4980475a5caSths        exit 1
4990475a5caSths      fi
5000475a5caSths    fi
50186b2bd93Sths  fi
5026b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
5030c58ac1cSmalc    audio_drv_list="oss"
5046b4d2ba1Sths  fi
505c2de5c91Smalc  audio_possible_drivers="oss sdl"
506d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
507d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
508d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
509d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
510a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
511560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
512560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
513560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
514ec530c81Sbellard;;
515b29fe3edSmalcAIX)
516b29fe3edSmalc  aix="yes"
5170db4a067SPaolo Bonzini  make="${MAKE-gmake}"
518b29fe3edSmalc;;
519179cf400SAndreas FärberHaiku)
520179cf400SAndreas Färber  haiku="yes"
521179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
522179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
523179cf400SAndreas Färber;;
524fb065187Sbellard*)
5250c58ac1cSmalc  audio_drv_list="oss"
526b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5275327cf48Sbellard  linux="yes"
528831b7825Sths  linux_user="yes"
52968063649Sblueswir1  usb="linux"
530af2be207SJan Kiszka  kvm="yes"
531af2be207SJan Kiszka  vhost_net="yes"
53207f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
533c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
534c9ec1fe4Sbellard  fi
535fb065187Sbellard;;
5367d13299dSbellardesac
5377d13299dSbellard
5387d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
539b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
54068063649Sblueswir1    usb="bsd"
54184778508Sblueswir1    bsd_user="yes"
5427d3505c5Sbellard  fi
54308de3949SAndreas Färberfi
5447d3505c5Sbellard
5450db4a067SPaolo Bonzini: ${make=${MAKE-make}}
5460db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
547c886edfbSBlue Swirl: ${python=${PYTHON-python}}
548e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
5490db4a067SPaolo Bonzini
5503c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
5513c4a4d0dSPeter Maydellif has clang; then
5523c4a4d0dSPeter Maydell  objcc=clang
5533c4a4d0dSPeter Maydellelse
5543c4a4d0dSPeter Maydell  objcc="$cc"
5553c4a4d0dSPeter Maydellfi
5563c4a4d0dSPeter Maydell
5573457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
5583457a3f8SJuan Quintela  EXESUF=".exe"
559a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
560e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
561e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
562f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
563f7cf5d5bSStefan Weilcat > $TMPC << EOF
564f7cf5d5bSStefan Weilint main(void) { return 0; }
565f7cf5d5bSStefan WeilEOF
566f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
567f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
568f7cf5d5bSStefan Weil  fi
569c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
570683035deSPaolo Bonzini  mandir="\${prefix}"
571528ae5b8SEduardo Habkost  datadir="\${prefix}"
572850da188SEduardo Habkost  qemu_docdir="\${prefix}"
573683035deSPaolo Bonzini  bindir="\${prefix}"
574683035deSPaolo Bonzini  sysconfdir="\${prefix}"
575785c23aeSLuiz Capitulino  local_statedir="\${prefix}"
576683035deSPaolo Bonzini  confsuffix=""
577368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
5783457a3f8SJuan Quintelafi
5793457a3f8SJuan Quintela
580487fefdbSAnthony Liguoriwerror=""
58185aa5189Sbellard
5827d13299dSbellardfor opt do
583a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
5847d13299dSbellard  case "$opt" in
5852efc3265Sbellard  --help|-h) show_help=yes
5862efc3265Sbellard  ;;
58799123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
58899123e13SMike Frysinger  ;;
589b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5907d13299dSbellard  ;;
591b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
59232ce6337Sbellard  ;;
593ca4deeb1SPaolo Bonzini  --source-path=*)
5947d13299dSbellard  ;;
595ac0df51dSaliguori  --cross-prefix=*)
5967d13299dSbellard  ;;
597ac0df51dSaliguori  --cc=*)
5987d13299dSbellard  ;;
599b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
60083469015Sbellard  ;;
6013c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
6023c4a4d0dSPeter Maydell  ;;
603b1a550a0Spbrook  --make=*) make="$optarg"
6047d13299dSbellard  ;;
6056a882643Spbrook  --install=*) install="$optarg"
6066a882643Spbrook  ;;
607c886edfbSBlue Swirl  --python=*) python="$optarg"
608c886edfbSBlue Swirl  ;;
6091d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
6101d728c39SBlue Swirl  ;;
611e2d8830eSBrad  --smbd=*) smbd="$optarg"
612e2d8830eSBrad  ;;
613e2a2ed06SJuan Quintela  --extra-cflags=*)
6147d13299dSbellard  ;;
615e2a2ed06SJuan Quintela  --extra-ldflags=*)
6167d13299dSbellard  ;;
6175bc62e01SGerd Hoffmann  --enable-debug-info)
6185bc62e01SGerd Hoffmann  ;;
6195bc62e01SGerd Hoffmann  --disable-debug-info)
6205bc62e01SGerd Hoffmann  ;;
6212ff6b91eSJuan Quintela  --cpu=*)
6227d13299dSbellard  ;;
623b1a550a0Spbrook  --target-list=*) target_list="$optarg"
624de83cd02Sbellard  ;;
62574242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
62694a420b1SStefan Hajnoczi  ;;
62774242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6289410b56cSPrerna Saxena  ;;
6297d13299dSbellard  --enable-gprof) gprof="yes"
6307d13299dSbellard  ;;
6311d728c39SBlue Swirl  --enable-gcov) gcov="yes"
6321d728c39SBlue Swirl  ;;
63379427693SLoïc Minier  --static)
63479427693SLoïc Minier    static="yes"
63579427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
63617884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
63743ce4dfeSbellard  ;;
6380b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6390b24e75fSPaolo Bonzini  ;;
6400b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
6410b24e75fSPaolo Bonzini  ;;
6423aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
6433aa5d2beSAlon Levy  ;;
6448bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
6458bf188aaSMichael Tokarev  ;;
6460f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
6470f94d6daSAlon Levy  ;;
648528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
6490b24e75fSPaolo Bonzini  ;;
650023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
651023d3d67SEduardo Habkost  ;;
652850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
6530b24e75fSPaolo Bonzini  ;;
654ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
65507381cc1SAnthony Liguori  ;;
656785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
657785c23aeSLuiz Capitulino  ;;
658785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
659023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
660023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
661023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
662023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
663023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
664023ddd74SMax Filippov    # lots of directory switches by default.
665023ddd74SMax Filippov  ;;
666e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
667e2134eb9SGerd Hoffmann  ;;
668e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
669e2134eb9SGerd Hoffmann  ;;
67074880fe2SRobert Schiele  --without-pixman) pixman="none"
67174880fe2SRobert Schiele  ;;
67297a847bcSbellard  --disable-sdl) sdl="no"
67397a847bcSbellard  ;;
674c4198157SJuan Quintela  --enable-sdl) sdl="yes"
675c4198157SJuan Quintela  ;;
676983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
677983eef5aSMeador Inge  ;;
678983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
679983eef5aSMeador Inge  ;;
680821601eaSJes Sorensen  --disable-vnc) vnc="no"
681821601eaSJes Sorensen  ;;
682821601eaSJes Sorensen  --enable-vnc) vnc="yes"
683821601eaSJes Sorensen  ;;
684b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
685102a52e4Sbellard  ;;
686c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
687c2de5c91Smalc  ;;
6882f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
6892f6a1ab0Sblueswir1  ;;
6902fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
6910c58ac1cSmalc  ;;
6920c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
6930c58ac1cSmalc  ;;
694eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
695eb852011SMarkus Armbruster  ;;
696f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
697f8393946Saurel32  ;;
698f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
699f8393946Saurel32  ;;
700f3d08ee6SPaul Brook  --enable-debug)
701f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
702f3d08ee6SPaul Brook      debug_tcg="yes"
703f3d08ee6SPaul Brook      debug="yes"
704f3d08ee6SPaul Brook      strip_opt="no"
705f3d08ee6SPaul Brook  ;;
70603b4fe7dSaliguori  --enable-sparse) sparse="yes"
70703b4fe7dSaliguori  ;;
70803b4fe7dSaliguori  --disable-sparse) sparse="no"
70903b4fe7dSaliguori  ;;
7101625af87Saliguori  --disable-strip) strip_opt="no"
7111625af87Saliguori  ;;
7128d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
7138d5d2d4cSths  ;;
7141be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
7151be10ad2SJuan Quintela  ;;
7162f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
7172f9606b3Saliguori  ;;
718ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
719ea784e3bSJuan Quintela  ;;
7202f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
7212f6f5c7aSCorentin Chary  ;;
7222f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
7232f6f5c7aSCorentin Chary  ;;
724efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
725efe556adSCorentin Chary  ;;
726efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
727efe556adSCorentin Chary  ;;
728443f1376Sbellard  --disable-slirp) slirp="no"
729c20709aaSbellard  ;;
730ee682d27SStefan Weil  --disable-uuid) uuid="no"
731ee682d27SStefan Weil  ;;
732ee682d27SStefan Weil  --enable-uuid) uuid="yes"
733ee682d27SStefan Weil  ;;
734e0e6c8c0Saliguori  --disable-vde) vde="no"
7358a16d273Sths  ;;
736dfb278bdSJuan Quintela  --enable-vde) vde="yes"
737dfb278bdSJuan Quintela  ;;
738e37630caSaliguori  --disable-xen) xen="no"
739e37630caSaliguori  ;;
740fc321b4bSJuan Quintela  --enable-xen) xen="yes"
741fc321b4bSJuan Quintela  ;;
742eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
743eb6fda0fSAnthony PERARD  ;;
744eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
745eb6fda0fSAnthony PERARD  ;;
7462e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
7472e4d9fb1Saurel32  ;;
7484ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
7494ffcedb6SJuan Quintela  ;;
750fb599c9aSbalrog  --disable-bluez) bluez="no"
751fb599c9aSbalrog  ;;
752a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
753a20a6f46SJuan Quintela  ;;
7547ba1e619Saliguori  --disable-kvm) kvm="no"
7557ba1e619Saliguori  ;;
756b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
757b31a0277SJuan Quintela  ;;
7589195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
7599195b2c2SStefan Weil  ;;
7609195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
7619195b2c2SStefan Weil  ;;
76247e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
76347e98658SCorey Bryant  ;;
76447e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
76547e98658SCorey Bryant  ;;
766cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
767cd4ec0b4SGerd Hoffmann  ;;
768cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
769cd4ec0b4SGerd Hoffmann  ;;
770c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
771c589b249SRonnie Sahlberg  ;;
772c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
773c589b249SRonnie Sahlberg  ;;
77405c2a3e7Sbellard  --enable-profiler) profiler="yes"
77505c2a3e7Sbellard  ;;
77614821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
77714821030SPavel Borzenkov  ;;
778c2de5c91Smalc  --enable-cocoa)
779c2de5c91Smalc      cocoa="yes" ;
780c2de5c91Smalc      sdl="no" ;
781c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
7825b0753e0Sbellard  ;;
783cad25d69Spbrook  --disable-system) softmmu="no"
7840a8e90f4Spbrook  ;;
785cad25d69Spbrook  --enable-system) softmmu="yes"
7860a8e90f4Spbrook  ;;
7870953a80fSZachary Amsden  --disable-user)
7880953a80fSZachary Amsden      linux_user="no" ;
7890953a80fSZachary Amsden      bsd_user="no" ;
7900953a80fSZachary Amsden  ;;
7910953a80fSZachary Amsden  --enable-user) ;;
792831b7825Sths  --disable-linux-user) linux_user="no"
7930a8e90f4Spbrook  ;;
794831b7825Sths  --enable-linux-user) linux_user="yes"
795831b7825Sths  ;;
79684778508Sblueswir1  --disable-bsd-user) bsd_user="no"
79784778508Sblueswir1  ;;
79884778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
79984778508Sblueswir1  ;;
800379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
801379f6698SPaul Brook  ;;
802379f6698SPaul Brook  --disable-guest-base) guest_base="no"
803379f6698SPaul Brook  ;;
80440d6444eSAvi Kivity  --enable-pie) pie="yes"
80534005a00SKirill A. Shutemov  ;;
80640d6444eSAvi Kivity  --disable-pie) pie="no"
80734005a00SKirill A. Shutemov  ;;
808c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
809c5937220Spbrook  ;;
81085aa5189Sbellard  --enable-werror) werror="yes"
81185aa5189Sbellard  ;;
81285aa5189Sbellard  --disable-werror) werror="no"
81385aa5189Sbellard  ;;
8144d3b6f6eSbalrog  --disable-curses) curses="no"
8154d3b6f6eSbalrog  ;;
816c584a6d0SJuan Quintela  --enable-curses) curses="yes"
817c584a6d0SJuan Quintela  ;;
818769ce76dSAlexander Graf  --disable-curl) curl="no"
819769ce76dSAlexander Graf  ;;
820788c8196SJuan Quintela  --enable-curl) curl="yes"
821788c8196SJuan Quintela  ;;
8222df87df7SJuan Quintela  --disable-fdt) fdt="no"
8232df87df7SJuan Quintela  ;;
8242df87df7SJuan Quintela  --enable-fdt) fdt="yes"
8252df87df7SJuan Quintela  ;;
826bd0c5661Spbrook  --disable-nptl) nptl="no"
827bd0c5661Spbrook  ;;
828b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
829b0a47e79SJuan Quintela  ;;
8308ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
8318ff9cbf7Smalc  ;;
8325c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
8335c6c3a6cSChristoph Hellwig  ;;
8345c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
8355c6c3a6cSChristoph Hellwig  ;;
836758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
837758e8e38SVenkateswararao Jujjuri (JV)  ;;
838758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
839758e8e38SVenkateswararao Jujjuri (JV)  ;;
84077755340Sths  --disable-blobs) blobs="no"
84177755340Sths  ;;
8424a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
8434a19f1ecSpbrook  ;;
844519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
845519175a2SAlex Barcelo  ;;
846a25dba17SJuan Quintela  --disable-docs) docs="no"
84770ec5dc0SAnthony Liguori  ;;
848a25dba17SJuan Quintela  --enable-docs) docs="yes"
84983a3ab8bSJuan Quintela  ;;
850d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
851d5970055SMichael S. Tsirkin  ;;
852d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
853d5970055SMichael S. Tsirkin  ;;
85420ff075bSMichael Walle  --disable-opengl) opengl="no"
85520ff075bSMichael Walle  ;;
85620ff075bSMichael Walle  --enable-opengl) opengl="yes"
85720ff075bSMichael Walle  ;;
858f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
859f27aaf4bSChristian Brunner  ;;
860f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
861f27aaf4bSChristian Brunner  ;;
8628c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
8638c84cf11SSergei Trofimovich  ;;
8648c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
8658c84cf11SSergei Trofimovich  ;;
86636707144SAlon Levy  --disable-smartcard) smartcard="no"
86736707144SAlon Levy  ;;
86836707144SAlon Levy  --enable-smartcard) smartcard="yes"
86936707144SAlon Levy  ;;
870111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
871111a38b0SRobert Relyea  ;;
872111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
873111a38b0SRobert Relyea  ;;
87469354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
87569354a83SHans de Goede  ;;
87669354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
87769354a83SHans de Goede  ;;
8781ece9905SAlon Levy  --disable-zlib-test) zlib="no"
8791ece9905SAlon Levy  ;;
880d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
881d138cee9SMichael Roth  ;;
882d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
883d138cee9SMichael Roth  ;;
8844b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
8854b1c11fdSDaniel P. Berrange  ;;
8864b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
8874b1c11fdSDaniel P. Berrange  ;;
888f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
889f794573eSEduardo Otubo  ;;
890f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
891f794573eSEduardo Otubo  ;;
892eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
893eb100396SBharata B Rao  ;;
894eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
895eb100396SBharata B Rao  ;;
896583f6e7bSStefan Hajnoczi  --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
897583f6e7bSStefan Hajnoczi  ;;
898583f6e7bSStefan Hajnoczi  --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
899583f6e7bSStefan Hajnoczi  ;;
9007f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
9017f1559c6Sbalrog  ;;
9027d13299dSbellard  esac
9037d13299dSbellarddone
9047d13299dSbellard
90540293e58Sbellardcase "$cpu" in
9069b9c37c3SRichard Henderson    sparc)
9070c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
9089b9c37c3SRichard Henderson           QEMU_CFLAGS="-m32 -mcpu=ultrasparc $QEMU_CFLAGS"
9093142255cSblueswir1           ;;
910ed968ff1SJuan Quintela    sparc64)
9110c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
9129b9c37c3SRichard Henderson           QEMU_CFLAGS="-m64 -mcpu=ultrasparc $QEMU_CFLAGS"
9133142255cSblueswir1           ;;
91476d83bdeSths    s390)
91528d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
91628d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
91728d7cc49SRichard Henderson           ;;
91828d7cc49SRichard Henderson    s390x)
91928d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
92028d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
92176d83bdeSths           ;;
92240293e58Sbellard    i386)
923a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
9240c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
9252b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
92640293e58Sbellard           ;;
92740293e58Sbellard    x86_64)
928a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
9290c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
9302b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
931379f6698SPaul Brook           ;;
93230163d89SPeter Maydell    # No special flags required for other host CPUs
9333142255cSblueswir1esac
9343142255cSblueswir1
93560e0df25SPeter Maydelldefault_target_list=""
93660e0df25SPeter Maydell
93760e0df25SPeter Maydell# these targets are portable
93860e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
93960e0df25SPeter Maydell    default_target_list="\
94060e0df25SPeter Maydelli386-softmmu \
94160e0df25SPeter Maydellx86_64-softmmu \
94227cdad67SRichard Hendersonalpha-softmmu \
94360e0df25SPeter Maydellarm-softmmu \
94460e0df25SPeter Maydellcris-softmmu \
94560e0df25SPeter Maydelllm32-softmmu \
94660e0df25SPeter Maydellm68k-softmmu \
94760e0df25SPeter Maydellmicroblaze-softmmu \
94860e0df25SPeter Maydellmicroblazeel-softmmu \
94960e0df25SPeter Maydellmips-softmmu \
95060e0df25SPeter Maydellmipsel-softmmu \
95160e0df25SPeter Maydellmips64-softmmu \
95260e0df25SPeter Maydellmips64el-softmmu \
953e67db06eSJia Liuor32-softmmu \
95460e0df25SPeter Maydellppc-softmmu \
95560e0df25SPeter Maydellppcemb-softmmu \
95660e0df25SPeter Maydellppc64-softmmu \
95760e0df25SPeter Maydellsh4-softmmu \
95860e0df25SPeter Maydellsh4eb-softmmu \
95960e0df25SPeter Maydellsparc-softmmu \
96060e0df25SPeter Maydellsparc64-softmmu \
9610f3301d4SAlexander Grafs390x-softmmu \
962cfa550c6SMax Filippovxtensa-softmmu \
963cfa550c6SMax Filippovxtensaeb-softmmu \
9644f23a1e6SGuan Xuetaounicore32-softmmu \
96560e0df25SPeter Maydell"
96660e0df25SPeter Maydellfi
96760e0df25SPeter Maydell# the following are Linux specific
96860e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
96960e0df25SPeter Maydell    default_target_list="${default_target_list}\
97060e0df25SPeter Maydelli386-linux-user \
97160e0df25SPeter Maydellx86_64-linux-user \
97260e0df25SPeter Maydellalpha-linux-user \
97360e0df25SPeter Maydellarm-linux-user \
97460e0df25SPeter Maydellarmeb-linux-user \
97560e0df25SPeter Maydellcris-linux-user \
97660e0df25SPeter Maydellm68k-linux-user \
97760e0df25SPeter Maydellmicroblaze-linux-user \
97860e0df25SPeter Maydellmicroblazeel-linux-user \
97960e0df25SPeter Maydellmips-linux-user \
98060e0df25SPeter Maydellmipsel-linux-user \
981d962783eSJia Liuor32-linux-user \
98260e0df25SPeter Maydellppc-linux-user \
98360e0df25SPeter Maydellppc64-linux-user \
98460e0df25SPeter Maydellppc64abi32-linux-user \
98560e0df25SPeter Maydellsh4-linux-user \
98660e0df25SPeter Maydellsh4eb-linux-user \
98760e0df25SPeter Maydellsparc-linux-user \
98860e0df25SPeter Maydellsparc64-linux-user \
98960e0df25SPeter Maydellsparc32plus-linux-user \
99060e0df25SPeter Maydellunicore32-linux-user \
9910f3301d4SAlexander Grafs390x-linux-user \
99260e0df25SPeter Maydell"
99360e0df25SPeter Maydellfi
99460e0df25SPeter Maydell# the following are BSD specific
99560e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
99660e0df25SPeter Maydell    default_target_list="${default_target_list}\
99760e0df25SPeter Maydelli386-bsd-user \
99860e0df25SPeter Maydellx86_64-bsd-user \
99960e0df25SPeter Maydellsparc-bsd-user \
100060e0df25SPeter Maydellsparc64-bsd-user \
100160e0df25SPeter Maydell"
100260e0df25SPeter Maydellfi
100360e0df25SPeter Maydell
1004af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1005af5db58eSpbrookcat << EOF
1006af5db58eSpbrook
1007af5db58eSpbrookUsage: configure [options]
1008af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1009af5db58eSpbrook
1010af5db58eSpbrookEOF
1011af5db58eSpbrookecho "Standard options:"
1012af5db58eSpbrookecho "  --help                   print this message"
1013af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
1014af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
1015af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
101660e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
101760e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
101860e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
1019af5db58eSpbrookecho ""
1020af5db58eSpbrookecho "Advanced options (experts only):"
1021af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
1022af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
1023af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
10240bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
10250bfe8cc0SPaolo Bonziniecho "                           build time"
10263c4a4d0dSPeter Maydellecho "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
1027a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
1028e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
1029af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
10306a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
1031c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
1032e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
1033af5db58eSpbrookecho "  --static                 enable static build [$static]"
10340b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
1035023d3d67SEduardo Habkostecho "  --datadir=PATH           install firmware in PATH$confsuffix"
1036023d3d67SEduardo Habkostecho "  --docdir=PATH            install documentation in PATH$confsuffix"
10370b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
1038023d3d67SEduardo Habkostecho "  --sysconfdir=PATH        install config in PATH$confsuffix"
1039785c23aeSLuiz Capitulinoecho "  --localstatedir=PATH     install local state in PATH"
10402ae4748fSStefan Weilecho "  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1041f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
1042f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
104309695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
1044890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
1045890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
10461625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
104785aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
1048fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
1049c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
1050983eef5aSMeador Ingeecho "  --disable-virtfs         disable VirtFS"
1051983eef5aSMeador Ingeecho "  --enable-virtfs          enable VirtFS"
1052821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
1053821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
105414821030SPavel Borzenkovecho "  --disable-cocoa          disable Cocoa (Mac OS X only)"
105514821030SPavel Borzenkovecho "  --enable-cocoa           enable Cocoa (default on Mac OS X)"
1056c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
1057c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
10584c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
10594c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
1060eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
1061eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
10628ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
1063e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
1064fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
1065eb6fda0fSAnthony PERARDecho "  --disable-xen-pci-passthrough"
1066eb6fda0fSAnthony PERARDecho "  --enable-xen-pci-passthrough"
10672e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
10684ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
10698d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
10701be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
10712f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1072ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
10732f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
10742f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
107596763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1076efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
1077af896aaaSpbrookecho "  --disable-curses         disable curses output"
1078c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1079769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1080788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
10812df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
10822df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
1083fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1084a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
10856093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
10867ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1087b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
10889195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1089bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
1090e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
1091af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1092af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
10930953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
10940953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1095831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1096831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
109784778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
109884778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1099379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1100379f6698SPaul Brookecho "                           emulation targets"
1101379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
110240d6444eSAvi Kivityecho "  --enable-pie             build Position Independent Executables"
110340d6444eSAvi Kivityecho "  --disable-pie            do not build Position Independent Executables"
1104af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1105af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
11062f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1107c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1108235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
1109ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1110ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1111e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1112dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
11135c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
11145c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
111547e98658SCorey Bryantecho "  --disable-cap-ng         disable libcap-ng support"
111647e98658SCorey Bryantecho "  --enable-cap-ng          enable libcap-ng support"
1117758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1118758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
111977755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1120d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1121d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1122d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1123d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1124320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1125650ab98dSLluís Vilanovaecho "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
112674242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
11279410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1128cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1129cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1130f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1131c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1132c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
113336707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
113436707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1135111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1136111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
113769354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
113869354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1139d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1140d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1141f794573eSEduardo Otuboecho "  --disable-seccomp        disable seccomp support"
1142f794573eSEduardo Otuboecho "  --enable-seccomp         enables seccomp support"
1143519175a2SAlex Barceloecho "  --with-coroutine=BACKEND coroutine backend. Supported options:"
1144fe91bfa8SAlex Barceloecho "                           gthread, ucontext, sigaltstack, windows"
1145eb100396SBharata B Raoecho "  --enable-glusterfs       enable GlusterFS backend"
1146eb100396SBharata B Raoecho "  --disable-glusterfs      disable GlusterFS backend"
11471d728c39SBlue Swirlecho "  --enable-gcov            enable test coverage analysis with gcov"
11481d728c39SBlue Swirlecho "  --gcov=GCOV              use specified gcov [$gcov_tool]"
1149af5db58eSpbrookecho ""
11505bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1151af5db58eSpbrookexit 1
1152af5db58eSpbrookfi
1153af5db58eSpbrook
1154359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1155359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1156359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1157359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1158359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1159359bc95dSPeter Maydell        ARCH=tci
1160359bc95dSPeter Maydell    else
1161359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1162359bc95dSPeter Maydell        exit 1
1163359bc95dSPeter Maydell    fi
1164359bc95dSPeter Maydellfi
1165359bc95dSPeter Maydell
11668d05095cSPaolo Bonzini# check that the C compiler works.
11678d05095cSPaolo Bonzinicat > $TMPC <<EOF
116875cafad7SStefan Weilint main(void) { return 0; }
11698d05095cSPaolo BonziniEOF
11708d05095cSPaolo Bonzini
11718d05095cSPaolo Bonziniif compile_object ; then
11728d05095cSPaolo Bonzini  : C compiler works ok
11738d05095cSPaolo Bonzinielse
11748d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
11758d05095cSPaolo Bonzini    exit 1
11768d05095cSPaolo Bonzinifi
11778d05095cSPaolo Bonzini
1178417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1179417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1180417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1181417c9d72SAlexander Graf
1182417c9d72SAlexander Grafif test -z "$werror" ; then
1183417c9d72SAlexander Graf    if test "$z_version" = "50" -a \
1184417c9d72SAlexander Graf        "$linux" = "yes" ; then
1185417c9d72SAlexander Graf        werror="yes"
1186417c9d72SAlexander Graf    else
1187417c9d72SAlexander Graf        werror="no"
1188417c9d72SAlexander Graf    fi
1189417c9d72SAlexander Graffi
1190417c9d72SAlexander Graf
11918d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
11928d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
11938d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1194f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
1195c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
11966ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
11976ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
11986ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
11996ca026cbSPeter Maydell# so it's too error prone.
12008d05095cSPaolo Bonzinicat > $TMPC << EOF
12018d05095cSPaolo Bonziniint main(void) { return 0; }
12028d05095cSPaolo BonziniEOF
12038d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1204a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1205a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1206a1d29d6cSPeter Maydell    # warning options).
1207a1d29d6cSPeter Maydell    optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1208a1d29d6cSPeter Maydell    if compile_prog "-Werror $optflag" "" ; then
12098d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
12108d05095cSPaolo Bonzini    fi
12118d05095cSPaolo Bonzinidone
12128d05095cSPaolo Bonzini
1213cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1214cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1215cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1216cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1217cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1218cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1219cbdd1999SPaolo Bonziniint main(void) { return 0; }
1220cbdd1999SPaolo Bonzini#else
1221cbdd1999SPaolo Bonzini#error No bug in this compiler.
1222cbdd1999SPaolo Bonzini#endif
1223cbdd1999SPaolo BonziniEOF
1224cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1225cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1226cbdd1999SPaolo Bonzinifi
1227cbdd1999SPaolo Bonzini
122840d6444eSAvi Kivityif test "$static" = "yes" ; then
122940d6444eSAvi Kivity  if test "$pie" = "yes" ; then
123040d6444eSAvi Kivity    echo "static and pie are mutually incompatible"
123140d6444eSAvi Kivity    exit 1
123240d6444eSAvi Kivity  else
123340d6444eSAvi Kivity    pie="no"
123440d6444eSAvi Kivity  fi
123540d6444eSAvi Kivityfi
123640d6444eSAvi Kivity
123740d6444eSAvi Kivityif test "$pie" = ""; then
123840d6444eSAvi Kivity  case "$cpu-$targetos" in
1239f9db31a2SBrad    i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD)
124040d6444eSAvi Kivity      ;;
124140d6444eSAvi Kivity    *)
124240d6444eSAvi Kivity      pie="no"
124340d6444eSAvi Kivity      ;;
124440d6444eSAvi Kivity  esac
124540d6444eSAvi Kivityfi
124640d6444eSAvi Kivity
124740d6444eSAvi Kivityif test "$pie" != "no" ; then
124840d6444eSAvi Kivity  cat > $TMPC << EOF
124921d4a791SAvi Kivity
125021d4a791SAvi Kivity#ifdef __linux__
125121d4a791SAvi Kivity#  define THREAD __thread
125221d4a791SAvi Kivity#else
125321d4a791SAvi Kivity#  define THREAD
125421d4a791SAvi Kivity#endif
125521d4a791SAvi Kivity
125621d4a791SAvi Kivitystatic THREAD int tls_var;
125721d4a791SAvi Kivity
125821d4a791SAvi Kivityint main(void) { return tls_var; }
125921d4a791SAvi Kivity
126040d6444eSAvi KivityEOF
126140d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
126240d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
126340d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
126440d6444eSAvi Kivity    pie="yes"
126540d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
126640d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
126740d6444eSAvi Kivity    fi
126840d6444eSAvi Kivity  else
126940d6444eSAvi Kivity    if test "$pie" = "yes"; then
127040d6444eSAvi Kivity      echo "PIE not available due to missing toolchain support"
127140d6444eSAvi Kivity      exit 1
127240d6444eSAvi Kivity    else
127340d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
127440d6444eSAvi Kivity      pie="no"
127540d6444eSAvi Kivity    fi
127640d6444eSAvi Kivity  fi
127740d6444eSAvi Kivityfi
127840d6444eSAvi Kivity
1279ec530c81Sbellard#
1280ec530c81Sbellard# Solaris specific configure tool chain decisions
1281ec530c81Sbellard#
1282ec530c81Sbellardif test "$solaris" = "yes" ; then
12836792aa11SLoïc Minier  if has $install; then
12846792aa11SLoïc Minier    :
12856792aa11SLoïc Minier  else
1286ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1287ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1288ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1289ec530c81Sbellard    exit 1
1290ec530c81Sbellard  fi
12916792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1292ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1293ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1294ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1295ec530c81Sbellard    exit 1
1296ec530c81Sbellard  fi
12976792aa11SLoïc Minier  if has ar; then
12986792aa11SLoïc Minier    :
12996792aa11SLoïc Minier  else
1300ec530c81Sbellard    echo "Error: No path includes ar"
1301ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1302ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1303ec530c81Sbellard    fi
1304ec530c81Sbellard    exit 1
1305ec530c81Sbellard  fi
1306ec530c81Sbellardfi
1307ec530c81Sbellard
13087a3fc891SSebastian Herbsztif ! has $python; then
1309c886edfbSBlue Swirl  echo "Python not found. Use --python=/path/to/python"
1310c886edfbSBlue Swirl  exit 1
1311c886edfbSBlue Swirlfi
1312c886edfbSBlue Swirl
13136ccea1e4SPeter Maydell# Note that if the Python conditional here evaluates True we will exit
13146ccea1e4SPeter Maydell# with status 1 which is a shell 'false' value.
1315e120d449SStefan Hajnocziif ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1316e120d449SStefan Hajnoczi  echo "Cannot use '$python', Python 2.4 or later is required."
1317e120d449SStefan Hajnoczi  echo "Note that Python 3 or later is not yet supported."
1318e120d449SStefan Hajnoczi  echo "Use --python=/path/to/python to specify a supported Python."
13196ccea1e4SPeter Maydell  exit 1
13206ccea1e4SPeter Maydellfi
13216ccea1e4SPeter Maydell
1322afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1323121afa9eSAnthony Liguori    target_list="$default_target_list"
1324121afa9eSAnthony Liguorielse
1325121afa9eSAnthony Liguori    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
13265327cf48Sbellardfi
1327f55fe278SPaolo Bonzini# see if system emulation was really requested
1328f55fe278SPaolo Bonzinicase " $target_list " in
1329f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1330f55fe278SPaolo Bonzini  ;;
1331f55fe278SPaolo Bonzini  *) softmmu=no
1332f55fe278SPaolo Bonzini  ;;
1333f55fe278SPaolo Bonziniesac
13345327cf48Sbellard
1335249247c9SJuan Quintelafeature_not_found() {
1336249247c9SJuan Quintela  feature=$1
1337249247c9SJuan Quintela
1338249247c9SJuan Quintela  echo "ERROR"
1339249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
13409332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1341249247c9SJuan Quintela  echo "ERROR"
1342249247c9SJuan Quintela  exit 1;
1343249247c9SJuan Quintela}
1344249247c9SJuan Quintela
13457d13299dSbellardif test -z "$cross_prefix" ; then
13467d13299dSbellard
13477d13299dSbellard# ---
13487d13299dSbellard# big/little endian test
13497d13299dSbellardcat > $TMPC << EOF
13507d13299dSbellard#include <inttypes.h>
1351abab1a0fSStefan Weilint main(void) {
13527d13299dSbellard        volatile uint32_t i=0x01234567;
13537d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
13547d13299dSbellard}
13557d13299dSbellardEOF
13567d13299dSbellard
135752166aa0SJuan Quintelaif compile_prog "" "" ; then
13587d13299dSbellard$TMPE && bigendian="yes"
13597d13299dSbellardelse
13607d13299dSbellardecho big/little test failed
13617d13299dSbellardfi
13627d13299dSbellard
13637d13299dSbellardelse
13647d13299dSbellard
13657d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1366ea8f20f8SJuan Quintelacase "$cpu" in
136721d89f84SPeter Maydell  arm)
136821d89f84SPeter Maydell    # ARM can be either way; ask the compiler which one we are
136921d89f84SPeter Maydell    if check_define __ARMEB__; then
137021d89f84SPeter Maydell      bigendian=yes
137121d89f84SPeter Maydell    fi
137221d89f84SPeter Maydell  ;;
137321d89f84SPeter Maydell  hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1374ea8f20f8SJuan Quintela    bigendian=yes
1375ea8f20f8SJuan Quintela  ;;
1376ea8f20f8SJuan Quintelaesac
13777d13299dSbellard
13787d13299dSbellardfi
13797d13299dSbellard
1380b0a47e79SJuan Quintela##########################################
1381779ab5e3SStefan Weil# pkg-config probe
1382779ab5e3SStefan Weil
1383779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
1384779ab5e3SStefan Weil  echo "Error: pkg-config binary '$pkg_config_exe' not found"
1385779ab5e3SStefan Weil  exit 1
1386779ab5e3SStefan Weilfi
1387779ab5e3SStefan Weil
1388779ab5e3SStefan Weil##########################################
1389b0a47e79SJuan Quintela# NPTL probe
1390b0a47e79SJuan Quintela
1391b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1392bd0c5661Spbrook  cat > $TMPC <<EOF
1393bd0c5661Spbrook#include <sched.h>
139430813ceaSpbrook#include <linux/futex.h>
1395182eacc0SStefan Weilint main(void) {
1396bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1397bd0c5661Spbrook#error bork
1398bd0c5661Spbrook#endif
1399182eacc0SStefan Weil  return 0;
1400bd0c5661Spbrook}
1401bd0c5661SpbrookEOF
1402bd0c5661Spbrook
140352166aa0SJuan Quintela  if compile_object ; then
1404b0a47e79SJuan Quintela    nptl=yes
1405bd0c5661Spbrook  else
1406b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1407b0a47e79SJuan Quintela      feature_not_found "nptl"
1408b0a47e79SJuan Quintela    fi
1409b0a47e79SJuan Quintela    nptl=no
1410b0a47e79SJuan Quintela  fi
1411bd0c5661Spbrookfi
1412bd0c5661Spbrook
141311d9f695Sbellard##########################################
1414ac62922eSbalrog# zlib check
1415ac62922eSbalrog
14161ece9905SAlon Levyif test "$zlib" != "no" ; then
1417ac62922eSbalrog    cat > $TMPC << EOF
1418ac62922eSbalrog#include <zlib.h>
1419ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1420ac62922eSbalrogEOF
142152166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1422ac62922eSbalrog        :
1423ac62922eSbalrog    else
1424ac62922eSbalrog        echo
1425ac62922eSbalrog        echo "Error: zlib check failed"
1426ac62922eSbalrog        echo "Make sure to have the zlib libs and headers installed."
1427ac62922eSbalrog        echo
1428ac62922eSbalrog        exit 1
1429ac62922eSbalrog    fi
14301ece9905SAlon Levyfi
1431ac62922eSbalrog
1432ac62922eSbalrog##########################################
1433f794573eSEduardo Otubo# libseccomp check
1434f794573eSEduardo Otubo
1435f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
14362c5c4451SBlue Swirl    if $pkg_config --atleast-version=1.0.0 libseccomp --modversion >/dev/null 2>&1; then
1437f794573eSEduardo Otubo        LIBS=`$pkg_config --libs libseccomp`
1438f794573eSEduardo Otubo	seccomp="yes"
1439f794573eSEduardo Otubo    else
1440f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
1441f794573eSEduardo Otubo            feature_not_found "libseccomp"
1442f794573eSEduardo Otubo	fi
1443e84d5956SYann E. MORIN	seccomp="no"
1444f794573eSEduardo Otubo    fi
1445f794573eSEduardo Otubofi
1446f794573eSEduardo Otubo##########################################
1447e37630caSaliguori# xen probe
1448e37630caSaliguori
1449fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1450b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1451d5b93ddfSAnthony PERARD
145250ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
145350ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
145450ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
145550ced5b3SStefan Weil
145650ced5b3SStefan Weil  # Xen (any)
145750ced5b3SStefan Weil  cat > $TMPC <<EOF
145850ced5b3SStefan Weil#include <xenctrl.h>
145950ced5b3SStefan Weilint main(void) {
146050ced5b3SStefan Weil  return 0;
146150ced5b3SStefan Weil}
146250ced5b3SStefan WeilEOF
146350ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
146450ced5b3SStefan Weil    # Xen not found
146550ced5b3SStefan Weil    if test "$xen" = "yes" ; then
146650ced5b3SStefan Weil      feature_not_found "xen"
146750ced5b3SStefan Weil    fi
146850ced5b3SStefan Weil    xen=no
146950ced5b3SStefan Weil
1470d5b93ddfSAnthony PERARD  # Xen unstable
147169deef08SPeter Maydell  elif
147269deef08SPeter Maydell      cat > $TMPC <<EOF &&
1473e37630caSaliguori#include <xenctrl.h>
1474e108a3c1SAnthony PERARD#include <xenstore.h>
1475d5b93ddfSAnthony PERARD#include <stdint.h>
1476d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1477d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1478d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1479d5b93ddfSAnthony PERARD#endif
1480d5b93ddfSAnthony PERARDint main(void) {
1481d5b93ddfSAnthony PERARD  xc_interface *xc;
1482d5b93ddfSAnthony PERARD  xs_daemon_open();
1483d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1484d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1485d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1486b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
14878688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
14888688e065SStefano Stabellini  return 0;
14898688e065SStefano Stabellini}
14908688e065SStefano StabelliniEOF
14918688e065SStefano Stabellini      compile_prog "" "$xen_libs"
149269deef08SPeter Maydell    then
14938688e065SStefano Stabellini    xen_ctrl_version=420
14948688e065SStefano Stabellini    xen=yes
14958688e065SStefano Stabellini
149669deef08SPeter Maydell  elif
149769deef08SPeter Maydell      cat > $TMPC <<EOF &&
14988688e065SStefano Stabellini#include <xenctrl.h>
14998688e065SStefano Stabellini#include <xs.h>
15008688e065SStefano Stabellini#include <stdint.h>
15018688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
15028688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
15038688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
15048688e065SStefano Stabellini#endif
15058688e065SStefano Stabelliniint main(void) {
15068688e065SStefano Stabellini  xs_daemon_open();
15079b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
15088688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
15098688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
15108688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1511d5b93ddfSAnthony PERARD  return 0;
1512d5b93ddfSAnthony PERARD}
1513e37630caSaliguoriEOF
151450ced5b3SStefan Weil      compile_prog "" "$xen_libs"
151569deef08SPeter Maydell    then
1516d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1517fc321b4bSJuan Quintela    xen=yes
1518d5b93ddfSAnthony PERARD
1519d5b93ddfSAnthony PERARD  # Xen 4.0.0
152069deef08SPeter Maydell  elif
152169deef08SPeter Maydell      cat > $TMPC <<EOF &&
1522d5b93ddfSAnthony PERARD#include <xenctrl.h>
1523d5b93ddfSAnthony PERARD#include <xs.h>
1524d5b93ddfSAnthony PERARD#include <stdint.h>
1525d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1526d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1527d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1528d5b93ddfSAnthony PERARD#endif
1529d5b93ddfSAnthony PERARDint main(void) {
1530b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1531b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1532b87de24eSAnthony PERARD  };
1533d5b93ddfSAnthony PERARD  xs_daemon_open();
1534d5b93ddfSAnthony PERARD  xc_interface_open();
1535d5b93ddfSAnthony PERARD  xc_gnttab_open();
1536d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1537b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1538d5b93ddfSAnthony PERARD  return 0;
1539d5b93ddfSAnthony PERARD}
1540d5b93ddfSAnthony PERARDEOF
1541d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
154269deef08SPeter Maydell    then
1543d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1544d5b93ddfSAnthony PERARD    xen=yes
1545d5b93ddfSAnthony PERARD
1546b87de24eSAnthony PERARD  # Xen 3.4.0
154769deef08SPeter Maydell  elif
154869deef08SPeter Maydell      cat > $TMPC <<EOF &&
1549b87de24eSAnthony PERARD#include <xenctrl.h>
1550b87de24eSAnthony PERARD#include <xs.h>
1551b87de24eSAnthony PERARDint main(void) {
1552b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1553b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1554b87de24eSAnthony PERARD  };
1555b87de24eSAnthony PERARD  xs_daemon_open();
1556b87de24eSAnthony PERARD  xc_interface_open();
1557b87de24eSAnthony PERARD  xc_gnttab_open();
1558b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1559b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1560b87de24eSAnthony PERARD  return 0;
1561b87de24eSAnthony PERARD}
1562b87de24eSAnthony PERARDEOF
1563b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
156469deef08SPeter Maydell    then
1565b87de24eSAnthony PERARD    xen_ctrl_version=340
1566b87de24eSAnthony PERARD    xen=yes
1567b87de24eSAnthony PERARD
1568b87de24eSAnthony PERARD  # Xen 3.3.0
156969deef08SPeter Maydell  elif
157069deef08SPeter Maydell      cat > $TMPC <<EOF &&
1571d5b93ddfSAnthony PERARD#include <xenctrl.h>
1572d5b93ddfSAnthony PERARD#include <xs.h>
1573d5b93ddfSAnthony PERARDint main(void) {
1574d5b93ddfSAnthony PERARD  xs_daemon_open();
1575d5b93ddfSAnthony PERARD  xc_interface_open();
1576d5b93ddfSAnthony PERARD  xc_gnttab_open();
1577d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1578d5b93ddfSAnthony PERARD  return 0;
1579d5b93ddfSAnthony PERARD}
1580d5b93ddfSAnthony PERARDEOF
1581d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
158269deef08SPeter Maydell    then
1583d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1584d5b93ddfSAnthony PERARD    xen=yes
1585d5b93ddfSAnthony PERARD
158650ced5b3SStefan Weil  # Xen version unsupported
1587e37630caSaliguori  else
1588fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
158950ced5b3SStefan Weil      feature_not_found "xen (unsupported version)"
1590fc321b4bSJuan Quintela    fi
1591fc321b4bSJuan Quintela    xen=no
1592e37630caSaliguori  fi
1593d5b93ddfSAnthony PERARD
1594d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1595d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1596d5b93ddfSAnthony PERARD  fi
1597e37630caSaliguorifi
1598e37630caSaliguori
1599eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1600eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1601eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1602eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1603eb6fda0fSAnthony PERARD  else
1604eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1605eb6fda0fSAnthony PERARD      echo "ERROR"
1606eb6fda0fSAnthony PERARD      echo "ERROR: User requested feature Xen PCI Passthrough"
1607eb6fda0fSAnthony PERARD      echo "ERROR: but this feature require /sys from Linux"
1608eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
1609eb6fda0fSAnthony PERARD        echo "ERROR: This feature does not work with Xen 3.3"
1610eb6fda0fSAnthony PERARD      fi
1611eb6fda0fSAnthony PERARD      echo "ERROR"
1612eb6fda0fSAnthony PERARD      exit 1;
1613eb6fda0fSAnthony PERARD    fi
1614eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1615eb6fda0fSAnthony PERARD  fi
1616eb6fda0fSAnthony PERARDfi
1617eb6fda0fSAnthony PERARD
1618e37630caSaliguori##########################################
161944dc0ca3SAlon Levy# libtool probe
162044dc0ca3SAlon Levy
16213f534581SBradif ! has $libtool; then
162244dc0ca3SAlon Levy    libtool=
162344dc0ca3SAlon Levyfi
162444dc0ca3SAlon Levy
162544dc0ca3SAlon Levy##########################################
1626dfffc653SJuan Quintela# Sparse probe
1627dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
16280dba6195SLoïc Minier  if has cgcc; then
1629dfffc653SJuan Quintela    sparse=yes
1630dfffc653SJuan Quintela  else
1631dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1632dfffc653SJuan Quintela      feature_not_found "sparse"
1633dfffc653SJuan Quintela    fi
1634dfffc653SJuan Quintela    sparse=no
1635dfffc653SJuan Quintela  fi
1636dfffc653SJuan Quintelafi
1637dfffc653SJuan Quintela
1638dfffc653SJuan Quintela##########################################
163911d9f695Sbellard# SDL probe
164011d9f695Sbellard
16413ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
16423ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
16433ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
16443ec87ffeSPaolo Bonzini  sdl_config=sdl-config
16453ec87ffeSPaolo Bonzinifi
16463ec87ffeSPaolo Bonzini
16473ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1648a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1649fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
16503ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
16513ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
16529316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1653a0dfd8a4SLoïc Minierelse
1654a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1655a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1656a0dfd8a4SLoïc Minier  fi
1657a0dfd8a4SLoïc Minier  sdl=no
16589316f803SPaolo Bonzinifi
165929e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
16603ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
16613ec87ffeSPaolo Bonzinifi
166211d9f695Sbellard
16639316f803SPaolo Bonzinisdl_too_old=no
1664c4198157SJuan Quintelaif test "$sdl" != "no" ; then
166511d9f695Sbellard  cat > $TMPC << EOF
166611d9f695Sbellard#include <SDL.h>
166711d9f695Sbellard#undef main /* We don't want SDL to override our main() */
166811d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
166911d9f695SbellardEOF
16709316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
167174f42e18STeLeMan  if test "$static" = "yes" ; then
167274f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
167374f42e18STeLeMan  else
16749316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
167574f42e18STeLeMan  fi
167652166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
167711d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
167811d9f695Sbellard      sdl_too_old=yes
167911d9f695Sbellard    else
1680fd677642Sths      if test "$cocoa" = "no" ; then
168111d9f695Sbellard        sdl=yes
168211d9f695Sbellard      fi
1683fd677642Sths    fi
16847c1f25b4Sbellard
168567c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
16861ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
168767c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1688f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1689f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
169011d9f695Sbellard      fi
169152166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
16921ac88f28SJuan Quintela	:
16931ac88f28SJuan Quintela      else
16941ac88f28SJuan Quintela        sdl=no
16957c1f25b4Sbellard      fi
16967c1f25b4Sbellard    fi # static link
1697c4198157SJuan Quintela  else # sdl not found
1698c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1699c4198157SJuan Quintela      feature_not_found "sdl"
1700c4198157SJuan Quintela    fi
1701c4198157SJuan Quintela    sdl=no
17027c1f25b4Sbellard  fi # sdl compile test
1703fd677642Sthsfi
170411d9f695Sbellard
17055368a422Saliguoriif test "$sdl" = "yes" ; then
17065368a422Saliguori  cat > $TMPC <<EOF
17075368a422Saliguori#include <SDL.h>
17085368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
17095368a422Saliguori#include <X11/XKBlib.h>
17105368a422Saliguori#else
17115368a422Saliguori#error No x11 support
17125368a422Saliguori#endif
17135368a422Saliguoriint main(void) { return 0; }
17145368a422SaliguoriEOF
171552166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1716681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
17175368a422Saliguori  fi
17180705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
17195368a422Saliguorifi
17205368a422Saliguori
17218f28f3fbSths##########################################
17228d5d2d4cSths# VNC TLS detection
1723821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1724ae6b5e5aSaliguori  cat > $TMPC <<EOF
1725ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1726ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1727ae6b5e5aSaliguoriEOF
1728a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1729a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
173052166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
17311be10ad2SJuan Quintela    vnc_tls=yes
1732a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1733ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
1734ae6b5e5aSaliguori  else
17351be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
17361be10ad2SJuan Quintela      feature_not_found "vnc-tls"
17371be10ad2SJuan Quintela    fi
17381be10ad2SJuan Quintela    vnc_tls=no
17398d5d2d4cSths  fi
17408d5d2d4cSthsfi
17418d5d2d4cSths
17428d5d2d4cSths##########################################
17432f9606b3Saliguori# VNC SASL detection
1744821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
17452f9606b3Saliguori  cat > $TMPC <<EOF
17462f9606b3Saliguori#include <sasl/sasl.h>
17472f9606b3Saliguori#include <stdio.h>
17482f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
17492f9606b3SaliguoriEOF
17502f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
17512f9606b3Saliguori  vnc_sasl_cflags=""
17522f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
175352166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1754ea784e3bSJuan Quintela    vnc_sasl=yes
1755fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1756ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
17572f9606b3Saliguori  else
1758ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1759ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1760ea784e3bSJuan Quintela    fi
1761ea784e3bSJuan Quintela    vnc_sasl=no
17622f9606b3Saliguori  fi
17632f9606b3Saliguorifi
17642f9606b3Saliguori
17652f9606b3Saliguori##########################################
17662f6f5c7aSCorentin Chary# VNC JPEG detection
1767821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
17682f6f5c7aSCorentin Charycat > $TMPC <<EOF
17692f6f5c7aSCorentin Chary#include <stdio.h>
17702f6f5c7aSCorentin Chary#include <jpeglib.h>
17712f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
17722f6f5c7aSCorentin CharyEOF
17732f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
17742f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
17752f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
17762f6f5c7aSCorentin Chary    vnc_jpeg=yes
17772f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1778ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
17792f6f5c7aSCorentin Chary  else
17802f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
17812f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
17822f6f5c7aSCorentin Chary    fi
17832f6f5c7aSCorentin Chary    vnc_jpeg=no
17842f6f5c7aSCorentin Chary  fi
17852f6f5c7aSCorentin Charyfi
17862f6f5c7aSCorentin Chary
17872f6f5c7aSCorentin Chary##########################################
1788efe556adSCorentin Chary# VNC PNG detection
1789821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1790efe556adSCorentin Charycat > $TMPC <<EOF
1791efe556adSCorentin Chary//#include <stdio.h>
1792efe556adSCorentin Chary#include <png.h>
1793832ce9c2SScott Wood#include <stddef.h>
1794efe556adSCorentin Charyint main(void) {
1795efe556adSCorentin Chary    png_structp png_ptr;
1796efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
17977edc3fedSPeter Maydell    return png_ptr != 0;
1798efe556adSCorentin Chary}
1799efe556adSCorentin CharyEOF
18009af8025eSBrad  if $pkg_config libpng --modversion >/dev/null 2>&1; then
18019af8025eSBrad    vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
18029af8025eSBrad    vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
18039af8025eSBrad  else
1804efe556adSCorentin Chary    vnc_png_cflags=""
1805efe556adSCorentin Chary    vnc_png_libs="-lpng"
18069af8025eSBrad  fi
1807efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1808efe556adSCorentin Chary    vnc_png=yes
1809efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
18109af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1811efe556adSCorentin Chary  else
1812efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1813efe556adSCorentin Chary      feature_not_found "vnc-png"
1814efe556adSCorentin Chary    fi
1815efe556adSCorentin Chary    vnc_png=no
1816efe556adSCorentin Chary  fi
1817efe556adSCorentin Charyfi
1818efe556adSCorentin Chary
1819efe556adSCorentin Chary##########################################
182076655d6dSaliguori# fnmatch() probe, used for ACL routines
182176655d6dSaliguorifnmatch="no"
182276655d6dSaliguoricat > $TMPC << EOF
182376655d6dSaliguori#include <fnmatch.h>
182476655d6dSaliguoriint main(void)
182576655d6dSaliguori{
182676655d6dSaliguori    fnmatch("foo", "foo", 0);
182776655d6dSaliguori    return 0;
182876655d6dSaliguori}
182976655d6dSaliguoriEOF
183052166aa0SJuan Quintelaif compile_prog "" "" ; then
183176655d6dSaliguori   fnmatch="yes"
183276655d6dSaliguorifi
183376655d6dSaliguori
183476655d6dSaliguori##########################################
1835ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1836ee682d27SStefan Weilif test "$uuid" != "no" ; then
1837ee682d27SStefan Weil  uuid_libs="-luuid"
1838ee682d27SStefan Weil  cat > $TMPC << EOF
1839ee682d27SStefan Weil#include <uuid/uuid.h>
1840ee682d27SStefan Weilint main(void)
1841ee682d27SStefan Weil{
1842ee682d27SStefan Weil    uuid_t my_uuid;
1843ee682d27SStefan Weil    uuid_generate(my_uuid);
1844ee682d27SStefan Weil    return 0;
1845ee682d27SStefan Weil}
1846ee682d27SStefan WeilEOF
1847ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1848ee682d27SStefan Weil    uuid="yes"
1849ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1850ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1851ee682d27SStefan Weil  else
1852ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1853ee682d27SStefan Weil      feature_not_found "uuid"
1854ee682d27SStefan Weil    fi
1855ee682d27SStefan Weil    uuid=no
1856ee682d27SStefan Weil  fi
1857ee682d27SStefan Weilfi
1858ee682d27SStefan Weil
1859ee682d27SStefan Weil##########################################
1860dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1861dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1862dce512deSChristoph Hellwig  cat > $TMPC << EOF
1863ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
1864dce512deSChristoph Hellwig#include <xfs/xfs.h>
1865dce512deSChristoph Hellwigint main(void)
1866dce512deSChristoph Hellwig{
1867dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1868dce512deSChristoph Hellwig    return 0;
1869dce512deSChristoph Hellwig}
1870dce512deSChristoph HellwigEOF
1871dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1872dce512deSChristoph Hellwig    xfs="yes"
1873dce512deSChristoph Hellwig  else
1874dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1875dce512deSChristoph Hellwig      feature_not_found "xfs"
1876dce512deSChristoph Hellwig    fi
1877dce512deSChristoph Hellwig    xfs=no
1878dce512deSChristoph Hellwig  fi
1879dce512deSChristoph Hellwigfi
1880dce512deSChristoph Hellwig
1881dce512deSChristoph Hellwig##########################################
18828a16d273Sths# vde libraries probe
1883dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
18844baae0acSJuan Quintela  vde_libs="-lvdeplug"
18858a16d273Sths  cat > $TMPC << EOF
18868a16d273Sths#include <libvdeplug.h>
18874a7f0e06Spbrookint main(void)
18884a7f0e06Spbrook{
18894a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
1890fea08e08SPeter Maydell    char s[] = "";
1891fea08e08SPeter Maydell    vde_open(s, s, &a);
18924a7f0e06Spbrook    return 0;
18934a7f0e06Spbrook}
18948a16d273SthsEOF
189552166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
18964baae0acSJuan Quintela    vde=yes
18978e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
18988e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1899dfb278bdSJuan Quintela  else
1900dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1901dfb278bdSJuan Quintela      feature_not_found "vde"
1902dfb278bdSJuan Quintela    fi
1903dfb278bdSJuan Quintela    vde=no
19048a16d273Sths  fi
19058a16d273Sthsfi
19068a16d273Sths
19078a16d273Sths##########################################
190847e98658SCorey Bryant# libcap-ng library probe
190947e98658SCorey Bryantif test "$cap_ng" != "no" ; then
191047e98658SCorey Bryant  cap_libs="-lcap-ng"
191147e98658SCorey Bryant  cat > $TMPC << EOF
191247e98658SCorey Bryant#include <cap-ng.h>
191347e98658SCorey Bryantint main(void)
191447e98658SCorey Bryant{
191547e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
191647e98658SCorey Bryant    return 0;
191747e98658SCorey Bryant}
191847e98658SCorey BryantEOF
191947e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
192047e98658SCorey Bryant    cap_ng=yes
192147e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
192247e98658SCorey Bryant  else
192347e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
192447e98658SCorey Bryant      feature_not_found "cap_ng"
192547e98658SCorey Bryant    fi
192647e98658SCorey Bryant    cap_ng=no
192747e98658SCorey Bryant  fi
192847e98658SCorey Bryantfi
192947e98658SCorey Bryant
193047e98658SCorey Bryant##########################################
1931c2de5c91Smalc# Sound support libraries probe
19328f28f3fbSths
1933c2de5c91Smalcaudio_drv_probe()
1934c2de5c91Smalc{
1935c2de5c91Smalc    drv=$1
1936c2de5c91Smalc    hdr=$2
1937c2de5c91Smalc    lib=$3
1938c2de5c91Smalc    exp=$4
1939c2de5c91Smalc    cfl=$5
19408f28f3fbSths        cat > $TMPC << EOF
1941c2de5c91Smalc#include <$hdr>
1942c2de5c91Smalcint main(void) { $exp }
19438f28f3fbSthsEOF
194452166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
19458f28f3fbSths        :
19468f28f3fbSths    else
19478f28f3fbSths        echo
1948c2de5c91Smalc        echo "Error: $drv check failed"
1949c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
19508f28f3fbSths        echo
19518f28f3fbSths        exit 1
19528f28f3fbSths    fi
1953c2de5c91Smalc}
1954c2de5c91Smalc
19552fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1956c2de5c91Smalcfor drv in $audio_drv_list; do
1957c2de5c91Smalc    case $drv in
1958c2de5c91Smalc    alsa)
1959c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1960e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
1961a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1962c2de5c91Smalc    ;;
1963c2de5c91Smalc
1964c2de5c91Smalc    fmod)
1965c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1966c2de5c91Smalc        echo
1967c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1968c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1969c2de5c91Smalc        echo
1970c2de5c91Smalc        exit 1
19718f28f3fbSths    fi
1972c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1973a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1974c2de5c91Smalc    ;;
1975c2de5c91Smalc
1976c2de5c91Smalc    esd)
1977c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1978a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
197967f86e8eSJuan Quintela    audio_pt_int="yes"
1980c2de5c91Smalc    ;;
1981b8e59f18Smalc
1982b8e59f18Smalc    pa)
1983a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
1984a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
1985a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
198667f86e8eSJuan Quintela    audio_pt_int="yes"
1987b8e59f18Smalc    ;;
1988b8e59f18Smalc
1989997e690aSJuan Quintela    coreaudio)
1990997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1991997e690aSJuan Quintela    ;;
1992997e690aSJuan Quintela
1993a4bf6780SJuan Quintela    dsound)
1994a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1995d5631638Smalc      audio_win_int="yes"
1996a4bf6780SJuan Quintela    ;;
1997a4bf6780SJuan Quintela
1998a4bf6780SJuan Quintela    oss)
1999a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
2000a4bf6780SJuan Quintela    ;;
2001a4bf6780SJuan Quintela
2002a4bf6780SJuan Quintela    sdl|wav)
20032f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
20042f6a1ab0Sblueswir1    ;;
20052f6a1ab0Sblueswir1
2006d5631638Smalc    winwave)
2007d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
2008d5631638Smalc      audio_win_int="yes"
2009d5631638Smalc    ;;
2010d5631638Smalc
2011e4c63a6aSmalc    *)
20121c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
2013e4c63a6aSmalc        echo
2014e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
2015e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
2016e4c63a6aSmalc        echo
2017e4c63a6aSmalc        exit 1
2018e4c63a6aSmalc    }
2019e4c63a6aSmalc    ;;
2020c2de5c91Smalc    esac
2021c2de5c91Smalcdone
20228f28f3fbSths
20234d3b6f6eSbalrog##########################################
20242e4d9fb1Saurel32# BrlAPI probe
20252e4d9fb1Saurel32
20264ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2027eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
20282e4d9fb1Saurel32  cat > $TMPC << EOF
20292e4d9fb1Saurel32#include <brlapi.h>
2030832ce9c2SScott Wood#include <stddef.h>
20312e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
20322e4d9fb1Saurel32EOF
203352166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
20342e4d9fb1Saurel32    brlapi=yes
2035264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
20364ffcedb6SJuan Quintela  else
20374ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
20384ffcedb6SJuan Quintela      feature_not_found "brlapi"
20394ffcedb6SJuan Quintela    fi
20404ffcedb6SJuan Quintela    brlapi=no
2041eb82284fSJuan Quintela  fi
2042eb82284fSJuan Quintelafi
20432e4d9fb1Saurel32
20442e4d9fb1Saurel32##########################################
20454d3b6f6eSbalrog# curses probe
2046e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
2047e095e2f3SStefan Weil    curses_list="-lpdcurses"
2048e095e2f3SStefan Weilelse
20494f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
2050e095e2f3SStefan Weilfi
20514d3b6f6eSbalrog
2052c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
2053c584a6d0SJuan Quintela  curses_found=no
20544d3b6f6eSbalrog  cat > $TMPC << EOF
20554d3b6f6eSbalrog#include <curses.h>
2056ef9a2524SStefan Weilint main(void) {
2057ef9a2524SStefan Weil  const char *s = curses_version();
2058ef9a2524SStefan Weil  resize_term(0, 0);
2059ef9a2524SStefan Weil  return s != 0;
2060ef9a2524SStefan Weil}
20614d3b6f6eSbalrogEOF
20624f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
20634f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2064c584a6d0SJuan Quintela      curses_found=yes
20654f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
20664f78ef9aSJuan Quintela      break
20674d3b6f6eSbalrog    fi
20684f78ef9aSJuan Quintela  done
2069c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2070c584a6d0SJuan Quintela    curses=yes
2071c584a6d0SJuan Quintela  else
2072c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
2073c584a6d0SJuan Quintela      feature_not_found "curses"
2074c584a6d0SJuan Quintela    fi
2075c584a6d0SJuan Quintela    curses=no
2076c584a6d0SJuan Quintela  fi
20774f78ef9aSJuan Quintelafi
20784d3b6f6eSbalrog
2079414f0dabSblueswir1##########################################
2080769ce76dSAlexander Graf# curl probe
2081769ce76dSAlexander Graf
2082a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
2083a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
20844e2b0658SPaolo Bonzinielse
20854e2b0658SPaolo Bonzini  curlconfig=curl-config
20864e2b0658SPaolo Bonzinifi
20874e2b0658SPaolo Bonzini
2088788c8196SJuan Quintelaif test "$curl" != "no" ; then
2089769ce76dSAlexander Graf  cat > $TMPC << EOF
2090769ce76dSAlexander Graf#include <curl/curl.h>
20910b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2092769ce76dSAlexander GrafEOF
20934e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
20944e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2095b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2096769ce76dSAlexander Graf    curl=yes
2097f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2098f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2099788c8196SJuan Quintela  else
2100788c8196SJuan Quintela    if test "$curl" = "yes" ; then
2101788c8196SJuan Quintela      feature_not_found "curl"
2102788c8196SJuan Quintela    fi
2103788c8196SJuan Quintela    curl=no
2104769ce76dSAlexander Graf  fi
2105769ce76dSAlexander Graffi # test "$curl"
2106769ce76dSAlexander Graf
2107769ce76dSAlexander Graf##########################################
2108fb599c9aSbalrog# bluez support probe
2109a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2110e820e3f4Sbalrog  cat > $TMPC << EOF
2111e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2112e820e3f4Sbalrogint main(void) { return bt_error(0); }
2113e820e3f4SbalrogEOF
2114a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2115a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
211652166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2117a20a6f46SJuan Quintela    bluez=yes
2118e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2119e820e3f4Sbalrog  else
2120a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
2121a20a6f46SJuan Quintela      feature_not_found "bluez"
2122a20a6f46SJuan Quintela    fi
2123e820e3f4Sbalrog    bluez="no"
2124e820e3f4Sbalrog  fi
2125fb599c9aSbalrogfi
2126fb599c9aSbalrog
2127fb599c9aSbalrog##########################################
2128e18df141SAnthony Liguori# glib support probe
2129a52d28afSPaolo Bonzini
2130a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2131a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2132a52d28afSPaolo Bonzini    glib_req_ver=2.20
2133a52d28afSPaolo Bonzinielse
2134a52d28afSPaolo Bonzini    glib_req_ver=2.12
2135a52d28afSPaolo Bonzinifi
2136a52d28afSPaolo Bonziniif $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
2137a52d28afSPaolo Bonzinithen
21384b76a481SStefan Hajnoczi    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
21394b76a481SStefan Hajnoczi    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
214014015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2141957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2142e18df141SAnthony Liguorielse
2143a52d28afSPaolo Bonzini    echo "glib-$glib_req_ver required to compile QEMU"
2144e18df141SAnthony Liguori    exit 1
2145e18df141SAnthony Liguorifi
2146e18df141SAnthony Liguori
2147e18df141SAnthony Liguori##########################################
2148e2134eb9SGerd Hoffmann# pixman support probe
2149e2134eb9SGerd Hoffmann
2150e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
215174880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
215274880fe2SRobert Schiele    pixman="none"
215374880fe2SRobert Schiele  elif $pkg_config pixman-1 > /dev/null 2>&1; then
2154e2134eb9SGerd Hoffmann    pixman="system"
2155e2134eb9SGerd Hoffmann  else
2156e2134eb9SGerd Hoffmann    pixman="internal"
2157e2134eb9SGerd Hoffmann  fi
2158e2134eb9SGerd Hoffmannfi
215974880fe2SRobert Schieleif test "$pixman" = "none"; then
216074880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
216174880fe2SRobert Schiele    echo "ERROR: pixman disabled but system emulation or tools build"
216274880fe2SRobert Schiele    echo "       enabled.  You can turn off pixman only if you also"
216374880fe2SRobert Schiele    echo "       disable all system emulation targets and the tools"
216474880fe2SRobert Schiele    echo "       build with '--disable-tools --disable-system'."
216574880fe2SRobert Schiele    exit 1
216674880fe2SRobert Schiele  fi
216774880fe2SRobert Schiele  pixman_cflags=
216874880fe2SRobert Schiele  pixman_libs=
216974880fe2SRobert Schieleelif test "$pixman" = "system"; then
2170e2134eb9SGerd Hoffmann  pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null`
2171e2134eb9SGerd Hoffmann  pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null`
2172e2134eb9SGerd Hoffmannelse
2173e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
2174cb1d40d7SGerd Hoffmann    echo "ERROR: pixman not present. Your options:"
2175eac29d87SStefan Weil    echo "  (1) Preferred: Install the pixman devel package (any recent"
2176e2134eb9SGerd Hoffmann    echo "      distro should have packages as Xorg needs pixman too)."
2177e2134eb9SGerd Hoffmann    echo "  (2) Fetch the pixman submodule, using:"
2178e2134eb9SGerd Hoffmann    echo "      git submodule update --init pixman"
2179e2134eb9SGerd Hoffmann    exit 1
2180e2134eb9SGerd Hoffmann  fi
21815ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
21825ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
21835ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2184e2134eb9SGerd Hoffmannfi
2185e2134eb9SGerd Hoffmann
2186e2134eb9SGerd Hoffmann##########################################
218717bff52bSM. Mohan Kumar# libcap probe
218817bff52bSM. Mohan Kumar
218917bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
219017bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
219117bff52bSM. Mohan Kumar#include <stdio.h>
219217bff52bSM. Mohan Kumar#include <sys/capability.h>
2193cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
219417bff52bSM. Mohan KumarEOF
219517bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
219617bff52bSM. Mohan Kumar    cap=yes
219717bff52bSM. Mohan Kumar  else
219817bff52bSM. Mohan Kumar    cap=no
219917bff52bSM. Mohan Kumar  fi
220017bff52bSM. Mohan Kumarfi
220117bff52bSM. Mohan Kumar
220217bff52bSM. Mohan Kumar##########################################
2203e5d355d1Saliguori# pthread probe
22044b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
22053c529d93Saliguori
2206e5d355d1Saliguoripthread=no
2207414f0dabSblueswir1cat > $TMPC << EOF
22083c529d93Saliguori#include <pthread.h>
22097a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
22107a42bbe4SStefan Weilint main(void) {
22117a42bbe4SStefan Weil  pthread_t thread;
22127a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
22137a42bbe4SStefan Weil  return 0;
22147a42bbe4SStefan Weil}
2215414f0dabSblueswir1EOF
2216bd00d539SAndreas Färberif compile_prog "" "" ; then
2217bd00d539SAndreas Färber  pthread=yes
2218bd00d539SAndreas Färberelse
2219de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
222052166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2221e5d355d1Saliguori      pthread=yes
2222e3c56761SPeter Portante      found=no
2223e3c56761SPeter Portante      for lib_entry in $LIBS; do
2224e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2225e3c56761SPeter Portante          found=yes
2226e3c56761SPeter Portante          break
2227e3c56761SPeter Portante        fi
2228e3c56761SPeter Portante      done
2229e3c56761SPeter Portante      if test "$found" = "no"; then
22305572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2231e3c56761SPeter Portante      fi
2232de65fe0fSSebastian Herbszt      break
2233414f0dabSblueswir1    fi
2234de65fe0fSSebastian Herbszt  done
2235bd00d539SAndreas Färberfi
2236414f0dabSblueswir1
22374617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
22384dd75c70SChristoph Hellwig  echo
22394dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
22404dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
22414dd75c70SChristoph Hellwig  echo
22424dd75c70SChristoph Hellwig  exit 1
2243e5d355d1Saliguorifi
2244e5d355d1Saliguori
2245bf9298b9Saliguori##########################################
2246f27aaf4bSChristian Brunner# rbd probe
2247f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2248f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2249f27aaf4bSChristian Brunner#include <stdio.h>
2250ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2251f27aaf4bSChristian Brunnerint main(void) {
2252ad32e9c0SJosh Durgin    rados_t cluster;
2253ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2254f27aaf4bSChristian Brunner    return 0;
2255f27aaf4bSChristian Brunner}
2256f27aaf4bSChristian BrunnerEOF
2257ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2258f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2259f27aaf4bSChristian Brunner    rbd=yes
2260f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2261f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2262f27aaf4bSChristian Brunner  else
2263f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
2264f27aaf4bSChristian Brunner      feature_not_found "rados block device"
2265f27aaf4bSChristian Brunner    fi
2266f27aaf4bSChristian Brunner    rbd=no
2267f27aaf4bSChristian Brunner  fi
2268f27aaf4bSChristian Brunnerfi
2269f27aaf4bSChristian Brunner
2270f27aaf4bSChristian Brunner##########################################
22715c6c3a6cSChristoph Hellwig# linux-aio probe
22725c6c3a6cSChristoph Hellwig
22735c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
22745c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
22755c6c3a6cSChristoph Hellwig#include <libaio.h>
22765c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2277832ce9c2SScott Wood#include <stddef.h>
22785c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
22795c6c3a6cSChristoph HellwigEOF
22805c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
22815c6c3a6cSChristoph Hellwig    linux_aio=yes
2282048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2283048d179fSPaul Brook    libs_tools="$libs_tools -laio"
22845c6c3a6cSChristoph Hellwig  else
22855c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
22865c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
22875c6c3a6cSChristoph Hellwig    fi
22883cfcae3cSLuiz Capitulino    linux_aio=no
22895c6c3a6cSChristoph Hellwig  fi
22905c6c3a6cSChristoph Hellwigfi
22915c6c3a6cSChristoph Hellwig
22925c6c3a6cSChristoph Hellwig##########################################
2293583f6e7bSStefan Hajnoczi# adjust virtio-blk-data-plane based on linux-aio
2294583f6e7bSStefan Hajnoczi
2295583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" -a \
2296583f6e7bSStefan Hajnoczi	"$linux_aio" != "yes" ; then
2297583f6e7bSStefan Hajnoczi  echo "Error: virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
2298583f6e7bSStefan Hajnoczi  exit 1
2299583f6e7bSStefan Hajnoczielif test -z "$virtio_blk_data_plane" ; then
2300583f6e7bSStefan Hajnoczi  virtio_blk_data_plane=$linux_aio
2301583f6e7bSStefan Hajnoczifi
2302583f6e7bSStefan Hajnoczi
2303583f6e7bSStefan Hajnoczi##########################################
2304758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2305758e8e38SVenkateswararao Jujjuri (JV)
2306758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2307758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2308758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2309758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2310f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2311f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2312f2338fb4SPavel Borzenkov#else
23134f26f2b6SAvi Kivity#include <sys/xattr.h>
2314f2338fb4SPavel Borzenkov#endif
2315758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2316758e8e38SVenkateswararao Jujjuri (JV)EOF
23174f26f2b6SAvi Kivity  if compile_prog "" "" ; then
23184f26f2b6SAvi Kivity    attr=yes
23194f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2320f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2321758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2322758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
23234f26f2b6SAvi Kivity    libattr=yes
2324758e8e38SVenkateswararao Jujjuri (JV)  else
2325758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2326758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2327758e8e38SVenkateswararao Jujjuri (JV)    fi
2328758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2329758e8e38SVenkateswararao Jujjuri (JV)  fi
2330758e8e38SVenkateswararao Jujjuri (JV)fi
2331758e8e38SVenkateswararao Jujjuri (JV)
2332758e8e38SVenkateswararao Jujjuri (JV)##########################################
2333bf9298b9Saliguori# iovec probe
2334bf9298b9Saliguoricat > $TMPC <<EOF
2335db34f0b3Sblueswir1#include <sys/types.h>
2336bf9298b9Saliguori#include <sys/uio.h>
2337db34f0b3Sblueswir1#include <unistd.h>
2338f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2339bf9298b9SaliguoriEOF
2340bf9298b9Saliguoriiovec=no
234152166aa0SJuan Quintelaif compile_prog "" "" ; then
2342bf9298b9Saliguori  iovec=yes
2343bf9298b9Saliguorifi
2344bf9298b9Saliguori
2345f652e6afSaurel32##########################################
2346ceb42de8Saliguori# preadv probe
2347ceb42de8Saliguoricat > $TMPC <<EOF
2348ceb42de8Saliguori#include <sys/types.h>
2349ceb42de8Saliguori#include <sys/uio.h>
2350ceb42de8Saliguori#include <unistd.h>
2351c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2352ceb42de8SaliguoriEOF
2353ceb42de8Saliguoripreadv=no
235452166aa0SJuan Quintelaif compile_prog "" "" ; then
2355ceb42de8Saliguori  preadv=yes
2356ceb42de8Saliguorifi
2357ceb42de8Saliguori
2358ceb42de8Saliguori##########################################
2359f652e6afSaurel32# fdt probe
23602df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2361b41af4baSJuan Quintela  fdt_libs="-lfdt"
2362f652e6afSaurel32  cat > $TMPC << EOF
2363f652e6afSaurel32int main(void) { return 0; }
2364f652e6afSaurel32EOF
236552166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2366f652e6afSaurel32    fdt=yes
23672df87df7SJuan Quintela  else
23682df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
23692df87df7SJuan Quintela      feature_not_found "fdt"
23702df87df7SJuan Quintela    fi
2371de3a354aSMichael Walle    fdt_libs=
23722df87df7SJuan Quintela    fdt=no
2373f652e6afSaurel32  fi
2374f652e6afSaurel32fi
2375f652e6afSaurel32
237620ff075bSMichael Walle##########################################
237720ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
237820ff075bSMichael Walleif test "$opengl" != "no" ; then
237920ff075bSMichael Walle  opengl_libs="-lGL"
238020ff075bSMichael Walle  cat > $TMPC << EOF
238120ff075bSMichael Walle#include <X11/Xlib.h>
238220ff075bSMichael Walle#include <GL/gl.h>
238320ff075bSMichael Walle#include <GL/glx.h>
238484972cbbSStefan Weilint main(void) { return GL_VERSION != 0; }
238520ff075bSMichael WalleEOF
238620ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
238720ff075bSMichael Walle    opengl=yes
238820ff075bSMichael Walle  else
238920ff075bSMichael Walle    if test "$opengl" = "yes" ; then
239020ff075bSMichael Walle      feature_not_found "opengl"
239120ff075bSMichael Walle    fi
2392de3a354aSMichael Walle    opengl_libs=
239320ff075bSMichael Walle    opengl=no
239420ff075bSMichael Walle  fi
239520ff075bSMichael Wallefi
239620ff075bSMichael Walle
2397eb100396SBharata B Rao##########################################
2398eb100396SBharata B Rao# glusterfs probe
2399eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
2400eb100396SBharata B Rao  cat > $TMPC <<EOF
2401eb100396SBharata B Rao#include <glusterfs/api/glfs.h>
2402eb100396SBharata B Raoint main(void) {
2403eb100396SBharata B Rao    (void) glfs_new("volume");
2404eb100396SBharata B Rao    return 0;
2405eb100396SBharata B Rao}
2406eb100396SBharata B RaoEOF
2407eb100396SBharata B Rao  glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
2408eb100396SBharata B Rao  if compile_prog "" "$glusterfs_libs" ; then
2409eb100396SBharata B Rao    glusterfs=yes
2410eb100396SBharata B Rao    libs_tools="$glusterfs_libs $libs_tools"
2411eb100396SBharata B Rao    libs_softmmu="$glusterfs_libs $libs_softmmu"
2412eb100396SBharata B Rao  else
2413eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
2414eb100396SBharata B Rao      feature_not_found "GlusterFS backend support"
2415eb100396SBharata B Rao    fi
2416eb100396SBharata B Rao    glusterfs=no
2417eb100396SBharata B Rao  fi
2418eb100396SBharata B Raofi
2419eb100396SBharata B Rao
24203b3f24adSaurel32#
24213b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
24223b3f24adSaurel32# emulator.  This is done because older glibc versions don't
24233b3f24adSaurel32# have syscall stubs for these implemented.
24243b3f24adSaurel32#
24253b3f24adSaurel32atfile=no
24263b3f24adSaurel32cat > $TMPC << EOF
24273b3f24adSaurel32#define _ATFILE_SOURCE
24283b3f24adSaurel32#include <sys/types.h>
24293b3f24adSaurel32#include <fcntl.h>
24303b3f24adSaurel32#include <unistd.h>
24313b3f24adSaurel32
24323b3f24adSaurel32int
24333b3f24adSaurel32main(void)
24343b3f24adSaurel32{
24353b3f24adSaurel32	/* try to unlink nonexisting file */
24363b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
24373b3f24adSaurel32}
24383b3f24adSaurel32EOF
243952166aa0SJuan Quintelaif compile_prog "" "" ; then
24403b3f24adSaurel32  atfile=yes
24413b3f24adSaurel32fi
24423b3f24adSaurel32
244339386ac7Saurel32# Check for inotify functions when we are building linux-user
24443b3f24adSaurel32# emulator.  This is done because older glibc versions don't
24453b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
24463b3f24adSaurel32# don't provide them even if kernel supports them.
24473b3f24adSaurel32#
24483b3f24adSaurel32inotify=no
24493b3f24adSaurel32cat > $TMPC << EOF
24503b3f24adSaurel32#include <sys/inotify.h>
24513b3f24adSaurel32
24523b3f24adSaurel32int
24533b3f24adSaurel32main(void)
24543b3f24adSaurel32{
24553b3f24adSaurel32	/* try to start inotify */
24568690e420Saurel32	return inotify_init();
24573b3f24adSaurel32}
24583b3f24adSaurel32EOF
245952166aa0SJuan Quintelaif compile_prog "" "" ; then
24603b3f24adSaurel32  inotify=yes
24613b3f24adSaurel32fi
24623b3f24adSaurel32
2463c05c7a73SRiku Voipioinotify1=no
2464c05c7a73SRiku Voipiocat > $TMPC << EOF
2465c05c7a73SRiku Voipio#include <sys/inotify.h>
2466c05c7a73SRiku Voipio
2467c05c7a73SRiku Voipioint
2468c05c7a73SRiku Voipiomain(void)
2469c05c7a73SRiku Voipio{
2470c05c7a73SRiku Voipio    /* try to start inotify */
2471c05c7a73SRiku Voipio    return inotify_init1(0);
2472c05c7a73SRiku Voipio}
2473c05c7a73SRiku VoipioEOF
2474c05c7a73SRiku Voipioif compile_prog "" "" ; then
2475c05c7a73SRiku Voipio  inotify1=yes
2476c05c7a73SRiku Voipiofi
2477c05c7a73SRiku Voipio
2478ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2479ebc996f3SRiku Voipioutimens=no
2480ebc996f3SRiku Voipiocat > $TMPC << EOF
2481ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2482ebc996f3SRiku Voipio#include <stddef.h>
2483ebc996f3SRiku Voipio#include <fcntl.h>
24843014ee00SPeter Maydell#include <sys/stat.h>
2485ebc996f3SRiku Voipio
2486ebc996f3SRiku Voipioint main(void)
2487ebc996f3SRiku Voipio{
2488ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2489ebc996f3SRiku Voipio    futimens(0, NULL);
2490ebc996f3SRiku Voipio    return 0;
2491ebc996f3SRiku Voipio}
2492ebc996f3SRiku VoipioEOF
249352166aa0SJuan Quintelaif compile_prog "" "" ; then
2494ebc996f3SRiku Voipio  utimens=yes
2495ebc996f3SRiku Voipiofi
2496ebc996f3SRiku Voipio
2497099d6b0fSRiku Voipio# check if pipe2 is there
2498099d6b0fSRiku Voipiopipe2=no
2499099d6b0fSRiku Voipiocat > $TMPC << EOF
2500099d6b0fSRiku Voipio#include <unistd.h>
2501099d6b0fSRiku Voipio#include <fcntl.h>
2502099d6b0fSRiku Voipio
2503099d6b0fSRiku Voipioint main(void)
2504099d6b0fSRiku Voipio{
2505099d6b0fSRiku Voipio    int pipefd[2];
25069bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
2507099d6b0fSRiku Voipio}
2508099d6b0fSRiku VoipioEOF
250952166aa0SJuan Quintelaif compile_prog "" "" ; then
2510099d6b0fSRiku Voipio  pipe2=yes
2511099d6b0fSRiku Voipiofi
2512099d6b0fSRiku Voipio
251340ff6d7eSKevin Wolf# check if accept4 is there
251440ff6d7eSKevin Wolfaccept4=no
251540ff6d7eSKevin Wolfcat > $TMPC << EOF
251640ff6d7eSKevin Wolf#include <sys/socket.h>
251740ff6d7eSKevin Wolf#include <stddef.h>
251840ff6d7eSKevin Wolf
251940ff6d7eSKevin Wolfint main(void)
252040ff6d7eSKevin Wolf{
252140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
252240ff6d7eSKevin Wolf    return 0;
252340ff6d7eSKevin Wolf}
252440ff6d7eSKevin WolfEOF
252540ff6d7eSKevin Wolfif compile_prog "" "" ; then
252640ff6d7eSKevin Wolf  accept4=yes
252740ff6d7eSKevin Wolffi
252840ff6d7eSKevin Wolf
25293ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
25303ce34dfbSvibisreenivasansplice=no
25313ce34dfbSvibisreenivasancat > $TMPC << EOF
25323ce34dfbSvibisreenivasan#include <unistd.h>
25333ce34dfbSvibisreenivasan#include <fcntl.h>
25343ce34dfbSvibisreenivasan#include <limits.h>
25353ce34dfbSvibisreenivasan
25363ce34dfbSvibisreenivasanint main(void)
25373ce34dfbSvibisreenivasan{
253866ea0f22SStefan Weil    int len, fd = 0;
25393ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
25403ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
25413ce34dfbSvibisreenivasan    return 0;
25423ce34dfbSvibisreenivasan}
25433ce34dfbSvibisreenivasanEOF
254452166aa0SJuan Quintelaif compile_prog "" "" ; then
25453ce34dfbSvibisreenivasan  splice=yes
25463ce34dfbSvibisreenivasanfi
25473ce34dfbSvibisreenivasan
2548dcc38d1cSMarcelo Tosatti##########################################
2549dcc38d1cSMarcelo Tosatti# signalfd probe
2550dcc38d1cSMarcelo Tosattisignalfd="no"
2551dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2552dcc38d1cSMarcelo Tosatti#include <unistd.h>
2553dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2554dcc38d1cSMarcelo Tosatti#include <signal.h>
2555dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2556dcc38d1cSMarcelo TosattiEOF
2557dcc38d1cSMarcelo Tosatti
2558dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2559dcc38d1cSMarcelo Tosatti  signalfd=yes
2560dcc38d1cSMarcelo Tosattifi
2561dcc38d1cSMarcelo Tosatti
2562c2882b96SRiku Voipio# check if eventfd is supported
2563c2882b96SRiku Voipioeventfd=no
2564c2882b96SRiku Voipiocat > $TMPC << EOF
2565c2882b96SRiku Voipio#include <sys/eventfd.h>
2566c2882b96SRiku Voipio
2567c2882b96SRiku Voipioint main(void)
2568c2882b96SRiku Voipio{
256955cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2570c2882b96SRiku Voipio}
2571c2882b96SRiku VoipioEOF
2572c2882b96SRiku Voipioif compile_prog "" "" ; then
2573c2882b96SRiku Voipio  eventfd=yes
2574c2882b96SRiku Voipiofi
2575c2882b96SRiku Voipio
2576d0927938SUlrich Hecht# check for fallocate
2577d0927938SUlrich Hechtfallocate=no
2578d0927938SUlrich Hechtcat > $TMPC << EOF
2579d0927938SUlrich Hecht#include <fcntl.h>
2580d0927938SUlrich Hecht
2581d0927938SUlrich Hechtint main(void)
2582d0927938SUlrich Hecht{
2583d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2584d0927938SUlrich Hecht    return 0;
2585d0927938SUlrich Hecht}
2586d0927938SUlrich HechtEOF
25878fb03151SPeter Maydellif compile_prog "" "" ; then
2588d0927938SUlrich Hecht  fallocate=yes
2589d0927938SUlrich Hechtfi
2590d0927938SUlrich Hecht
2591c727f47dSPeter Maydell# check for sync_file_range
2592c727f47dSPeter Maydellsync_file_range=no
2593c727f47dSPeter Maydellcat > $TMPC << EOF
2594c727f47dSPeter Maydell#include <fcntl.h>
2595c727f47dSPeter Maydell
2596c727f47dSPeter Maydellint main(void)
2597c727f47dSPeter Maydell{
2598c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2599c727f47dSPeter Maydell    return 0;
2600c727f47dSPeter Maydell}
2601c727f47dSPeter MaydellEOF
26028fb03151SPeter Maydellif compile_prog "" "" ; then
2603c727f47dSPeter Maydell  sync_file_range=yes
2604c727f47dSPeter Maydellfi
2605c727f47dSPeter Maydell
2606dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2607dace20dcSPeter Maydellfiemap=no
2608dace20dcSPeter Maydellcat > $TMPC << EOF
2609dace20dcSPeter Maydell#include <sys/ioctl.h>
2610dace20dcSPeter Maydell#include <linux/fs.h>
2611dace20dcSPeter Maydell#include <linux/fiemap.h>
2612dace20dcSPeter Maydell
2613dace20dcSPeter Maydellint main(void)
2614dace20dcSPeter Maydell{
2615dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2616dace20dcSPeter Maydell    return 0;
2617dace20dcSPeter Maydell}
2618dace20dcSPeter MaydellEOF
26198fb03151SPeter Maydellif compile_prog "" "" ; then
2620dace20dcSPeter Maydell  fiemap=yes
2621dace20dcSPeter Maydellfi
2622dace20dcSPeter Maydell
2623d0927938SUlrich Hecht# check for dup3
2624d0927938SUlrich Hechtdup3=no
2625d0927938SUlrich Hechtcat > $TMPC << EOF
2626d0927938SUlrich Hecht#include <unistd.h>
2627d0927938SUlrich Hecht
2628d0927938SUlrich Hechtint main(void)
2629d0927938SUlrich Hecht{
2630d0927938SUlrich Hecht    dup3(0, 0, 0);
2631d0927938SUlrich Hecht    return 0;
2632d0927938SUlrich Hecht}
2633d0927938SUlrich HechtEOF
263478f5d726SJan Kiszkaif compile_prog "" "" ; then
2635d0927938SUlrich Hecht  dup3=yes
2636d0927938SUlrich Hechtfi
2637d0927938SUlrich Hecht
26383b6edd16SPeter Maydell# check for epoll support
26393b6edd16SPeter Maydellepoll=no
26403b6edd16SPeter Maydellcat > $TMPC << EOF
26413b6edd16SPeter Maydell#include <sys/epoll.h>
26423b6edd16SPeter Maydell
26433b6edd16SPeter Maydellint main(void)
26443b6edd16SPeter Maydell{
26453b6edd16SPeter Maydell    epoll_create(0);
26463b6edd16SPeter Maydell    return 0;
26473b6edd16SPeter Maydell}
26483b6edd16SPeter MaydellEOF
26498fb03151SPeter Maydellif compile_prog "" "" ; then
26503b6edd16SPeter Maydell  epoll=yes
26513b6edd16SPeter Maydellfi
26523b6edd16SPeter Maydell
26533b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
26543b6edd16SPeter Maydell# so we must check separately for their presence
26553b6edd16SPeter Maydellepoll_create1=no
26563b6edd16SPeter Maydellcat > $TMPC << EOF
26573b6edd16SPeter Maydell#include <sys/epoll.h>
26583b6edd16SPeter Maydell
26593b6edd16SPeter Maydellint main(void)
26603b6edd16SPeter Maydell{
266119e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
266219e83f6bSPeter Maydell     * a function being called. This is necessary so that on
266319e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
266419e83f6bSPeter Maydell     * the library but not declared in the header file we will
266519e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
266619e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
266719e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
266819e83f6bSPeter Maydell     */
2669c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
26703b6edd16SPeter Maydell}
26713b6edd16SPeter MaydellEOF
26728fb03151SPeter Maydellif compile_prog "" "" ; then
26733b6edd16SPeter Maydell  epoll_create1=yes
26743b6edd16SPeter Maydellfi
26753b6edd16SPeter Maydell
26763b6edd16SPeter Maydellepoll_pwait=no
26773b6edd16SPeter Maydellcat > $TMPC << EOF
26783b6edd16SPeter Maydell#include <sys/epoll.h>
26793b6edd16SPeter Maydell
26803b6edd16SPeter Maydellint main(void)
26813b6edd16SPeter Maydell{
26823b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
26833b6edd16SPeter Maydell    return 0;
26843b6edd16SPeter Maydell}
26853b6edd16SPeter MaydellEOF
26868fb03151SPeter Maydellif compile_prog "" "" ; then
26873b6edd16SPeter Maydell  epoll_pwait=yes
26883b6edd16SPeter Maydellfi
26893b6edd16SPeter Maydell
2690cc8ae6deSpbrook# Check if tools are available to build documentation.
2691a25dba17SJuan Quintelaif test "$docs" != "no" ; then
269201668d98SStefan Weil  if has makeinfo && has pod2man; then
2693a25dba17SJuan Quintela    docs=yes
269483a3ab8bSJuan Quintela  else
2695a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2696a25dba17SJuan Quintela      feature_not_found "docs"
269783a3ab8bSJuan Quintela    fi
2698a25dba17SJuan Quintela    docs=no
269983a3ab8bSJuan Quintela  fi
2700cc8ae6deSpbrookfi
2701cc8ae6deSpbrook
2702f514f41cSStefan Weil# Search for bswap_32 function
27036ae9a1f4SJuan Quintelabyteswap_h=no
27046ae9a1f4SJuan Quintelacat > $TMPC << EOF
27056ae9a1f4SJuan Quintela#include <byteswap.h>
27066ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
27076ae9a1f4SJuan QuintelaEOF
270852166aa0SJuan Quintelaif compile_prog "" "" ; then
27096ae9a1f4SJuan Quintela  byteswap_h=yes
27106ae9a1f4SJuan Quintelafi
27116ae9a1f4SJuan Quintela
271275f13596SStefan Weil# Search for bswap32 function
27136ae9a1f4SJuan Quintelabswap_h=no
27146ae9a1f4SJuan Quintelacat > $TMPC << EOF
27156ae9a1f4SJuan Quintela#include <sys/endian.h>
27166ae9a1f4SJuan Quintela#include <sys/types.h>
27176ae9a1f4SJuan Quintela#include <machine/bswap.h>
27186ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
27196ae9a1f4SJuan QuintelaEOF
272052166aa0SJuan Quintelaif compile_prog "" "" ; then
27216ae9a1f4SJuan Quintela  bswap_h=yes
27226ae9a1f4SJuan Quintelafi
27236ae9a1f4SJuan Quintela
2724da93a1fdSaliguori##########################################
2725c589b249SRonnie Sahlberg# Do we have libiscsi
2726fa6acb0cSRonnie Sahlberg# We check for iscsi_unmap_sync() to make sure we have a
2727fa6acb0cSRonnie Sahlberg# recent enough version of libiscsi.
2728c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2729c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2730fa6acb0cSRonnie Sahlberg#include <stdio.h>
2731c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2732fa6acb0cSRonnie Sahlbergint main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2733c589b249SRonnie SahlbergEOF
2734417c9d72SAlexander Graf  if compile_prog "" "-liscsi" ; then
2735c589b249SRonnie Sahlberg    libiscsi="yes"
2736c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2737c589b249SRonnie Sahlberg  else
2738c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2739c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2740c589b249SRonnie Sahlberg    fi
2741c589b249SRonnie Sahlberg    libiscsi="no"
2742c589b249SRonnie Sahlberg  fi
2743c589b249SRonnie Sahlbergfi
2744c589b249SRonnie Sahlberg
2745c589b249SRonnie Sahlberg
2746c589b249SRonnie Sahlberg##########################################
27478bacde8dSNatanael Copa# Do we need libm
27488bacde8dSNatanael Copacat > $TMPC << EOF
27498bacde8dSNatanael Copa#include <math.h>
27508bacde8dSNatanael Copaint main(void) { return isnan(sin(0.0)); }
27518bacde8dSNatanael CopaEOF
27528bacde8dSNatanael Copaif compile_prog "" "" ; then
27538bacde8dSNatanael Copa  :
27548bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
27558bacde8dSNatanael Copa  LIBS="-lm $LIBS"
27568bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
27578bacde8dSNatanael Copaelse
27588bacde8dSNatanael Copa  echo
27598bacde8dSNatanael Copa  echo "Error: libm check failed"
27608bacde8dSNatanael Copa  echo
27618bacde8dSNatanael Copa  exit 1
27628bacde8dSNatanael Copafi
27638bacde8dSNatanael Copa
27648bacde8dSNatanael Copa##########################################
2765da93a1fdSaliguori# Do we need librt
27668bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
27678bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
27688bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
27698bacde8dSNatanael Copa# function in addition.
2770da93a1fdSaliguoricat > $TMPC <<EOF
2771da93a1fdSaliguori#include <signal.h>
2772da93a1fdSaliguori#include <time.h>
27738bacde8dSNatanael Copaint main(void) {
27748bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
27758bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
27768bacde8dSNatanael Copa}
2777da93a1fdSaliguoriEOF
2778da93a1fdSaliguori
277952166aa0SJuan Quintelaif compile_prog "" "" ; then
278007ffa4bdSJuan Quintela  :
27818bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
27828bacde8dSNatanael Copaelif compile_prog "" "-lrt $pthread_lib" ; then
278307ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
27848bacde8dSNatanael Copa  libs_qga="-lrt $libs_qga"
2785da93a1fdSaliguorifi
2786da93a1fdSaliguori
278731ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2788179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
27896362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
27906362a53fSJuan Quintelafi
27916362a53fSJuan Quintela
2792de5071c5SBlue Swirl##########################################
2793cd4ec0b4SGerd Hoffmann# spice probe
2794cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2795cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2796cd4ec0b4SGerd Hoffmann#include <spice.h>
2797cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2798cd4ec0b4SGerd HoffmannEOF
2799710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2800710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
280167be6726SGerd Hoffmann  if $pkg_config --atleast-version=0.12.0 spice-server >/dev/null 2>&1 && \
280267be6726SGerd Hoffmann     $pkg_config --atleast-version=0.12.2 spice-protocol > /dev/null 2>&1 && \
2803cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2804cd4ec0b4SGerd Hoffmann    spice="yes"
2805cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2806cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
28072e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
28082e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
2809cd4ec0b4SGerd Hoffmann  else
2810cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2811cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2812cd4ec0b4SGerd Hoffmann    fi
2813cd4ec0b4SGerd Hoffmann    spice="no"
2814cd4ec0b4SGerd Hoffmann  fi
2815cd4ec0b4SGerd Hoffmannfi
2816cd4ec0b4SGerd Hoffmann
2817111a38b0SRobert Relyea# check for libcacard for smartcard support
2818111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2819111a38b0SRobert Relyea    smartcard="yes"
2820111a38b0SRobert Relyea    smartcard_cflags=""
2821111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2822111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
28235f01e06fSSergei Trofimovich      cat > $TMPC << EOF
28245f01e06fSSergei Trofimovich#include <pk11pub.h>
28255f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
28265f01e06fSSergei TrofimovichEOF
28270b22ef0fSPeter Maydell        smartcard_includes="-I\$(SRC_PATH)/libcacard"
28288c741c22SAlon Levy        libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
28298c741c22SAlon Levy        libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
28306ca026cbSPeter Maydell        test_cflags="$libcacard_cflags"
28316ca026cbSPeter Maydell        # The header files in nss < 3.13.3 have a bug which causes them to
28326ca026cbSPeter Maydell        # emit a warning. If we're going to compile QEMU with -Werror, then
28336ca026cbSPeter Maydell        # test that the headers don't have this bug. Otherwise we would pass
28346ca026cbSPeter Maydell        # the configure test but fail to compile QEMU later.
28356ca026cbSPeter Maydell        if test "$werror" = "yes"; then
28366ca026cbSPeter Maydell            test_cflags="-Werror $test_cflags"
28376ca026cbSPeter Maydell        fi
28385f01e06fSSergei Trofimovich        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
28396ca026cbSPeter Maydell          compile_prog "$test_cflags" "$libcacard_libs"; then
28405f01e06fSSergei Trofimovich            smartcard_nss="yes"
28410b22ef0fSPeter Maydell            QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
28420b22ef0fSPeter Maydell            QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
2843ad4cf3f6SPaul Brook            libs_softmmu="$libcacard_libs $libs_softmmu"
2844111a38b0SRobert Relyea        else
2845111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2846111a38b0SRobert Relyea                feature_not_found "nss"
2847111a38b0SRobert Relyea            fi
2848111a38b0SRobert Relyea            smartcard_nss="no"
2849111a38b0SRobert Relyea        fi
2850111a38b0SRobert Relyea    fi
2851111a38b0SRobert Relyeafi
2852111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2853111a38b0SRobert Relyea    smartcard_nss="no"
2854111a38b0SRobert Relyeafi
2855111a38b0SRobert Relyea
285669354a83SHans de Goede# check for usbredirparser for usb network redirection support
285769354a83SHans de Goedeif test "$usb_redir" != "no" ; then
2858b2d1fe67SHans de Goede    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5 >/dev/null 2>&1 ; then
285969354a83SHans de Goede        usb_redir="yes"
28608b626aa7SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5 2>/dev/null)
28618b626aa7SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5 2>/dev/null)
286269354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
286356ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
286469354a83SHans de Goede    else
286569354a83SHans de Goede        if test "$usb_redir" = "yes"; then
286669354a83SHans de Goede            feature_not_found "usb-redir"
286769354a83SHans de Goede        fi
286869354a83SHans de Goede        usb_redir="no"
286969354a83SHans de Goede    fi
287069354a83SHans de Goedefi
287169354a83SHans de Goede
2872cd4ec0b4SGerd Hoffmann##########################################
2873cd4ec0b4SGerd Hoffmann
2874747bbdf7SBlue Swirl##########################################
28755f6b9e8fSBlue Swirl# check if we have fdatasync
28765f6b9e8fSBlue Swirl
28775f6b9e8fSBlue Swirlfdatasync=no
28785f6b9e8fSBlue Swirlcat > $TMPC << EOF
28795f6b9e8fSBlue Swirl#include <unistd.h>
2880d1722a27SAlexandre Raymondint main(void) {
2881d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2882d1722a27SAlexandre Raymondreturn fdatasync(0);
2883d1722a27SAlexandre Raymond#else
2884e172fe11SStefan Weil#error Not supported
2885d1722a27SAlexandre Raymond#endif
2886d1722a27SAlexandre Raymond}
28875f6b9e8fSBlue SwirlEOF
28885f6b9e8fSBlue Swirlif compile_prog "" "" ; then
28895f6b9e8fSBlue Swirl    fdatasync=yes
28905f6b9e8fSBlue Swirlfi
28915f6b9e8fSBlue Swirl
289294a420b1SStefan Hajnoczi##########################################
2893e78815a5SAndreas Färber# check if we have madvise
2894e78815a5SAndreas Färber
2895e78815a5SAndreas Färbermadvise=no
2896e78815a5SAndreas Färbercat > $TMPC << EOF
2897e78815a5SAndreas Färber#include <sys/types.h>
2898e78815a5SAndreas Färber#include <sys/mman.h>
2899832ce9c2SScott Wood#include <stddef.h>
2900e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2901e78815a5SAndreas FärberEOF
2902e78815a5SAndreas Färberif compile_prog "" "" ; then
2903e78815a5SAndreas Färber    madvise=yes
2904e78815a5SAndreas Färberfi
2905e78815a5SAndreas Färber
2906e78815a5SAndreas Färber##########################################
2907e78815a5SAndreas Färber# check if we have posix_madvise
2908e78815a5SAndreas Färber
2909e78815a5SAndreas Färberposix_madvise=no
2910e78815a5SAndreas Färbercat > $TMPC << EOF
2911e78815a5SAndreas Färber#include <sys/mman.h>
2912832ce9c2SScott Wood#include <stddef.h>
2913e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2914e78815a5SAndreas FärberEOF
2915e78815a5SAndreas Färberif compile_prog "" "" ; then
2916e78815a5SAndreas Färber    posix_madvise=yes
2917e78815a5SAndreas Färberfi
2918e78815a5SAndreas Färber
2919e78815a5SAndreas Färber##########################################
29201e9737daSRichard Henderson# check if we have usable SIGEV_THREAD_ID
29211e9737daSRichard Henderson
29221e9737daSRichard Hendersonsigev_thread_id=no
29231e9737daSRichard Hendersoncat > $TMPC << EOF
29241e9737daSRichard Henderson#include <signal.h>
29251e9737daSRichard Hendersonint main(void) {
29261e9737daSRichard Henderson  struct sigevent ev;
29271e9737daSRichard Henderson  ev.sigev_notify = SIGEV_THREAD_ID;
29281e9737daSRichard Henderson  ev._sigev_un._tid = 0;
29291e9737daSRichard Henderson  asm volatile("" : : "g"(&ev));
29301e9737daSRichard Henderson  return 0;
29311e9737daSRichard Henderson}
29321e9737daSRichard HendersonEOF
29331e9737daSRichard Hendersonif compile_prog "" "" ; then
29341e9737daSRichard Henderson    sigev_thread_id=yes
29351e9737daSRichard Hendersonfi
29361e9737daSRichard Henderson
29371e9737daSRichard Henderson##########################################
293894a420b1SStefan Hajnoczi# check if trace backend exists
293994a420b1SStefan Hajnoczi
2940650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
294194a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
294294a420b1SStefan Hajnoczi  echo
294394a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
294494a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
294594a420b1SStefan Hajnoczi  echo
294694a420b1SStefan Hajnoczi  exit 1
294794a420b1SStefan Hajnoczifi
294894a420b1SStefan Hajnoczi
29497e24e92aSStefan Hajnoczi##########################################
29507e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
29517e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
29527e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
29537e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
29547e24e92aSStefan Hajnoczi#include <ust/marker.h>
29557e24e92aSStefan Hajnocziint main(void) { return 0; }
29567e24e92aSStefan HajnocziEOF
29577e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
295894b4fefaSLluís Vilanova    LIBS="-lust -lurcu-bp $LIBS"
2959c9a2e37cSLluís Vilanova    libs_qga="-lust -lurcu-bp $libs_qga"
29607e24e92aSStefan Hajnoczi  else
29617e24e92aSStefan Hajnoczi    echo
29627e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
29637e24e92aSStefan Hajnoczi    echo
29647e24e92aSStefan Hajnoczi    exit 1
29657e24e92aSStefan Hajnoczi  fi
29667e24e92aSStefan Hajnoczifi
2967b3d08c02SDaniel P. Berrange
2968b3d08c02SDaniel P. Berrange##########################################
2969b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2970b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2971b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2972b3d08c02SDaniel P. Berrange    echo
2973b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2974b3d08c02SDaniel P. Berrange    echo
2975b3d08c02SDaniel P. Berrange    exit 1
2976b3d08c02SDaniel P. Berrange  fi
2977c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2978c276b17dSDaniel P. Berrange  if has 'stap' ; then
2979c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2980c276b17dSDaniel P. Berrange  fi
2981b3d08c02SDaniel P. Berrangefi
2982b3d08c02SDaniel P. Berrange
29837e24e92aSStefan Hajnoczi##########################################
2984023367e6SWolfgang Mauerer# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2985023367e6SWolfgang Mauerer# use i686 as default anyway, but for those that don't, an explicit
2986023367e6SWolfgang Mauerer# specification is necessary
29871ba16968SStefan Weilif test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
2988023367e6SWolfgang Mauerer  cat > $TMPC << EOF
29897ace252aSStefan Weilstatic int sfaa(int *ptr)
2990023367e6SWolfgang Mauerer{
2991023367e6SWolfgang Mauerer  return __sync_fetch_and_and(ptr, 0);
2992023367e6SWolfgang Mauerer}
2993023367e6SWolfgang Mauerer
2994abab1a0fSStefan Weilint main(void)
2995023367e6SWolfgang Mauerer{
2996023367e6SWolfgang Mauerer  int val = 42;
2997023367e6SWolfgang Mauerer  sfaa(&val);
2998023367e6SWolfgang Mauerer  return val;
2999023367e6SWolfgang Mauerer}
3000023367e6SWolfgang MauererEOF
3001023367e6SWolfgang Mauerer  if ! compile_prog "" "" ; then
3002caa50971SPeter Maydell    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
3003023367e6SWolfgang Mauerer  fi
3004023367e6SWolfgang Mauererfi
3005023367e6SWolfgang Mauerer
3006023367e6SWolfgang Mauerer##########################################
3007519175a2SAlex Barcelo# check and set a backend for coroutine
3008d0e2fce5SAneesh Kumar K.V
3009519175a2SAlex Barcelo# default is ucontext, but always fallback to gthread
3010519175a2SAlex Barcelo# windows autodetected by make
3011519175a2SAlex Barceloif test "$coroutine" = "" -o "$coroutine" = "ucontext"; then
3012d0e2fce5SAneesh Kumar K.V  if test "$darwin" != "yes"; then
3013d0e2fce5SAneesh Kumar K.V    cat > $TMPC << EOF
3014d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3015cdf84806SPeter Maydell#ifdef __stub_makecontext
3016cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3017cdf84806SPeter Maydell#endif
301875cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3019d0e2fce5SAneesh Kumar K.VEOF
3020d0e2fce5SAneesh Kumar K.V    if compile_prog "" "" ; then
3021519175a2SAlex Barcelo        coroutine_backend=ucontext
3022519175a2SAlex Barcelo    else
3023519175a2SAlex Barcelo	coroutine_backend=gthread
3024d0e2fce5SAneesh Kumar K.V    fi
3025519175a2SAlex Barcelo  fi
3026519175a2SAlex Barceloelif test "$coroutine" = "gthread" ; then
3027519175a2SAlex Barcelo  coroutine_backend=gthread
3028519175a2SAlex Barceloelif test "$coroutine" = "windows" ; then
3029519175a2SAlex Barcelo  coroutine_backend=windows
3030fe91bfa8SAlex Barceloelif test "$coroutine" = "sigaltstack" ; then
3031fe91bfa8SAlex Barcelo  coroutine_backend=sigaltstack
3032519175a2SAlex Barceloelse
3033519175a2SAlex Barcelo  echo
3034519175a2SAlex Barcelo  echo "Error: unknown coroutine backend $coroutine"
3035519175a2SAlex Barcelo  echo
3036519175a2SAlex Barcelo  exit 1
3037d0e2fce5SAneesh Kumar K.Vfi
3038d0e2fce5SAneesh Kumar K.V
3039d0e2fce5SAneesh Kumar K.V##########################################
3040d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
3041d2042378SAneesh Kumar K.V
30424e1797f9SStefan Weilopen_by_handle_at=no
3043d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
3044d2042378SAneesh Kumar K.V#include <fcntl.h>
3045acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
3046acc55ba8SStefan Weil# error missing definition
3047acc55ba8SStefan Weil#else
304875cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3049acc55ba8SStefan Weil#endif
3050d2042378SAneesh Kumar K.VEOF
3051d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
3052d2042378SAneesh Kumar K.V    open_by_handle_at=yes
3053d2042378SAneesh Kumar K.Vfi
3054d2042378SAneesh Kumar K.V
3055e06a765eSHarsh Prateek Bora########################################
3056e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
3057e06a765eSHarsh Prateek Bora
3058e06a765eSHarsh Prateek Boralinux_magic_h=no
3059e06a765eSHarsh Prateek Boracat > $TMPC << EOF
3060e06a765eSHarsh Prateek Bora#include <linux/magic.h>
3061e06a765eSHarsh Prateek Boraint main(void) {
306275cafad7SStefan Weil  return 0;
3063e06a765eSHarsh Prateek Bora}
3064e06a765eSHarsh Prateek BoraEOF
3065e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
3066e06a765eSHarsh Prateek Bora    linux_magic_h=yes
3067e06a765eSHarsh Prateek Borafi
3068e06a765eSHarsh Prateek Bora
30698ab1bf12SLuiz Capitulino########################################
307006d71fa1SPeter Maydell# check whether we can disable the -Wunused-but-set-variable
307106d71fa1SPeter Maydell# option with a pragma (this is needed to silence a warning in
307206d71fa1SPeter Maydell# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.)
307306d71fa1SPeter Maydell# This test has to be compiled with -Werror as otherwise an
307406d71fa1SPeter Maydell# unknown pragma is only a warning.
307506d71fa1SPeter Maydellpragma_disable_unused_but_set=no
307606d71fa1SPeter Maydellcat > $TMPC << EOF
307706d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
307806d71fa1SPeter Maydellint main(void) {
307906d71fa1SPeter Maydell    return 0;
308006d71fa1SPeter Maydell}
308106d71fa1SPeter MaydellEOF
308206d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
3083cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
308406d71fa1SPeter Maydellfi
308506d71fa1SPeter Maydell
308606d71fa1SPeter Maydell########################################
308762fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
30883f4349dcSKevin Wolf
30893f4349dcSKevin Wolfvalgrind_h=no
30903f4349dcSKevin Wolfcat > $TMPC << EOF
30913f4349dcSKevin Wolf#include <valgrind/valgrind.h>
309262fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
30933f4349dcSKevin Wolfint main(void) {
30943f4349dcSKevin Wolf  return 0;
30953f4349dcSKevin Wolf}
30963f4349dcSKevin WolfEOF
30973f4349dcSKevin Wolfif compile_prog "" "" ; then
30983f4349dcSKevin Wolf    valgrind_h=yes
30993f4349dcSKevin Wolffi
31003f4349dcSKevin Wolf
31013f4349dcSKevin Wolf########################################
31028ab1bf12SLuiz Capitulino# check if environ is declared
31038ab1bf12SLuiz Capitulino
31048ab1bf12SLuiz Capitulinohas_environ=no
31058ab1bf12SLuiz Capitulinocat > $TMPC << EOF
31068ab1bf12SLuiz Capitulino#include <unistd.h>
31078ab1bf12SLuiz Capitulinoint main(void) {
3108c075a723SBlue Swirl    environ = 0;
31098ab1bf12SLuiz Capitulino    return 0;
31108ab1bf12SLuiz Capitulino}
31118ab1bf12SLuiz CapitulinoEOF
31128ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
31138ab1bf12SLuiz Capitulino    has_environ=yes
31148ab1bf12SLuiz Capitulinofi
31158ab1bf12SLuiz Capitulino
311676a347e1SRichard Henderson########################################
311776a347e1SRichard Henderson# check if cpuid.h is usable.
311876a347e1SRichard Henderson
311976a347e1SRichard Hendersoncpuid_h=no
312076a347e1SRichard Hendersoncat > $TMPC << EOF
312176a347e1SRichard Henderson#include <cpuid.h>
312276a347e1SRichard Hendersonint main(void) {
312376a347e1SRichard Henderson  return 0;
312476a347e1SRichard Henderson}
312576a347e1SRichard HendersonEOF
312676a347e1SRichard Hendersonif compile_prog "" "" ; then
312776a347e1SRichard Henderson    cpuid_h=yes
312876a347e1SRichard Hendersonfi
312976a347e1SRichard Henderson
313076a347e1SRichard Henderson
3131d2042378SAneesh Kumar K.V##########################################
3132e86ecd4bSJuan Quintela# End of CC checks
3133e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3134e86ecd4bSJuan Quintela
31351d728c39SBlue Swirlif test "$gcov" = "yes" ; then
31361d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
31371d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
31381d728c39SBlue Swirlelif test "$debug" = "no" ; then
31398be74dc0SAvi Kivity  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3140e86ecd4bSJuan Quintelafi
3141a316e378SJuan Quintela
31421d728c39SBlue Swirl
314320ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
314420ff6c80SAnthony Liguori# enable/disable
314520ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
314620ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
314720ff6c80SAnthony Liguori	zero_malloc="no"
314820ff6c80SAnthony Liguori    else
314920ff6c80SAnthony Liguori	zero_malloc="yes"
315020ff6c80SAnthony Liguori    fi
315120ff6c80SAnthony Liguorifi
315220ff6c80SAnthony Liguori
31536ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
31546ca026cbSPeter Maydellif test "$werror" = "yes"; then
31556ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
31566ca026cbSPeter Maydellfi
31576ca026cbSPeter Maydell
3158e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3159e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
31601156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3161e86ecd4bSJuan Quintela    fi
3162e86ecd4bSJuan Quintelafi
3163e86ecd4bSJuan Quintela
316494dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
316594dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
316694dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
316794dd53c5SGerd Hoffmannelse
316894dd53c5SGerd Hoffmann    POD2MAN="pod2man"
316994dd53c5SGerd Hoffmannfi
317094dd53c5SGerd Hoffmann
3171952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3172952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3173952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3174952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3175952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3176952afb71SBlue Swirl        fi
3177952afb71SBlue Swirl    done
3178952afb71SBlue Swirlfi
3179952afb71SBlue Swirl
318010ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3181528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
31825a67135aSbellard
31834b1c11fdSDaniel P. Berrangetools=""
31844b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3185ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
31864b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
31874b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
31884b1c11fdSDaniel P. Berrange  fi
31894b1c11fdSDaniel P. Berrangefi
31904b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3191983eef5aSMeador Inge  if test "$virtfs" != no ; then
3192be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3193983eef5aSMeador Inge      virtfs=yes
319417bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3195983eef5aSMeador Inge    else
3196983eef5aSMeador Inge      if test "$virtfs" = yes; then
3197263ddcc8SHarsh Prateek Bora        echo "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3198263ddcc8SHarsh Prateek Bora        exit 1
3199983eef5aSMeador Inge      fi
320017500370SAndreas Färber      virtfs=no
3201983eef5aSMeador Inge    fi
320217bff52bSM. Mohan Kumar  fi
3203ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3204d138cee9SMichael Roth    if [ "$guest_agent" = "yes" ]; then
320548ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
3206d138cee9SMichael Roth    fi
3207ca35f780SPaolo Bonzini  fi
320800c705fbSPaolo Bonzini  if test "$smartcard_nss" = "yes" ; then
320900c705fbSPaolo Bonzini    tools="vscclient\$(EXESUF) $tools"
321000c705fbSPaolo Bonzini  fi
32114b1c11fdSDaniel P. Berrangefi
3212ca35f780SPaolo Bonzini
3213ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3214ca35f780SPaolo Bonziniroms=
3215ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3216ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3217ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3218ca35f780SPaolo Bonzini  roms="optionrom"
3219ca35f780SPaolo Bonzinifi
3220d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
322139ac8455SDavid Gibson  roms="$roms spapr-rtas"
322239ac8455SDavid Gibsonfi
3223ca35f780SPaolo Bonzini
32245ca9388aSGerd Hoffmann# add pixman flags after all config tests are done
32255ca9388aSGerd HoffmannQEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags"
32265ca9388aSGerd Hoffmannlibs_softmmu="$libs_softmmu $pixman_libs"
32275ca9388aSGerd Hoffmann
32287d13299dSbellardecho "Install prefix    $prefix"
3229c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3230f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
32313aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
32328bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
32330f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
32341c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
3235785c23aeSLuiz Capitulinoecho "local state directory   `eval echo $local_statedir`"
323611d9f695Sbellardif test "$mingw32" = "no" ; then
3237f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
323843ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
323911d9f695Sbellardfi
32405a67135aSbellardecho "Source path       $source_path"
32417d13299dSbellardecho "C compiler        $cc"
324283469015Sbellardecho "Host C compiler   $host_cc"
32433c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
32440c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3245a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
32460c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
32477d13299dSbellardecho "make              $make"
32486a882643Spbrookecho "install           $install"
3249c886edfbSBlue Swirlecho "python            $python"
3250e2d8830eSBradif test "$slirp" = "yes" ; then
3251e2d8830eSBrad    echo "smbd              $smbd"
3252e2d8830eSBradfi
3253a98fd896Sbellardecho "host CPU          $cpu"
3254de83cd02Sbellardecho "host big endian   $bigendian"
325597a847bcSbellardecho "target list       $target_list"
3256ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
32577d13299dSbellardecho "gprof enabled     $gprof"
325803b4fe7dSaliguoriecho "sparse enabled    $sparse"
32591625af87Saliguoriecho "strip binaries    $strip_opt"
326005c2a3e7Sbellardecho "profiler          $profiler"
326143ce4dfeSbellardecho "static build      $static"
326285aa5189Sbellardecho "-Werror enabled   $werror"
32635b0753e0Sbellardif test "$darwin" = "yes" ; then
32645b0753e0Sbellard    echo "Cocoa support     $cocoa"
32655b0753e0Sbellardfi
3266e2134eb9SGerd Hoffmannecho "pixman            $pixman"
326797a847bcSbellardecho "SDL support       $sdl"
32684d3b6f6eSbalrogecho "curses support    $curses"
3269769ce76dSAlexander Grafecho "curl support      $curl"
327067b915a5Sbellardecho "mingw32 support   $mingw32"
32710c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
32720c58ac1cSmalcecho "Extra audio cards $audio_card_list"
3273eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
32748ff9cbf7Smalcecho "Mixer emulation   $mixemu"
3275983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3276821601eaSJes Sorensenecho "VNC support       $vnc"
3277821601eaSJes Sorensenif test "$vnc" = "yes" ; then
32788d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
32792f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
32802f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3281efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
3282821601eaSJes Sorensenfi
32833142255cSblueswir1if test -n "$sparc_cpu"; then
32843142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
32853142255cSblueswir1fi
3286e37630caSaliguoriecho "xen support       $xen"
32872e4d9fb1Saurel32echo "brlapi support    $brlapi"
3288a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3289a25dba17SJuan Quintelaecho "Documentation     $docs"
3290c5937220Spbrook[ ! -z "$uname_release" ] && \
3291c5937220Spbrookecho "uname -r          $uname_release"
3292bd0c5661Spbrookecho "NPTL support      $nptl"
3293379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
329440d6444eSAvi Kivityecho "PIE               $pie"
32958a16d273Sthsecho "vde support       $vde"
32965c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3297758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
329877755340Sthsecho "Install blobs     $blobs"
3299b31a0277SJuan Quintelaecho "KVM support       $kvm"
33009195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3301f652e6afSaurel32echo "fdt support       $fdt"
3302ceb42de8Saliguoriecho "preadv support    $preadv"
33035f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3304e78815a5SAndreas Färberecho "madvise           $madvise"
3305e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
33061e9737daSRichard Hendersonecho "sigev_thread_id   $sigev_thread_id"
3307ee682d27SStefan Weilecho "uuid support      $uuid"
330847e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3309d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
331094a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
33119410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
33122e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3313f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3314dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3315111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
331669354a83SHans de Goedeecho "usb net redir     $usb_redir"
331720ff075bSMichael Walleecho "OpenGL support    $opengl"
3318c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3319d138cee9SMichael Rothecho "build guest agent $guest_agent"
3320f794573eSEduardo Otuboecho "seccomp support   $seccomp"
3321519175a2SAlex Barceloecho "coroutine backend $coroutine_backend"
3322eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
3323583f6e7bSStefan Hajnocziecho "virtio-blk-data-plane $virtio_blk_data_plane"
33241d728c39SBlue Swirlecho "gcov              $gcov_tool"
33251d728c39SBlue Swirlecho "gcov enabled      $gcov"
332667b915a5Sbellard
33271ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
332824b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3329e8cd23deSbellardfi
333097a847bcSbellard
333198ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
33324bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
333397a847bcSbellard
3334dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
3335dbd99ae3SStefan Weil
333698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
333798ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
333898ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
333998ec69acSJuan Quintelaecho >> $config_host_mak
334098ec69acSJuan Quintela
3341e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
334299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
334399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
33443aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
33458bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
33460f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
334799d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
334899d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
334922d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
33509afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
33519afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
3352785c23aeSLuiz Capitulinoecho "qemu_localstatedir=$local_statedir" >> $config_host_mak
3353f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
3354*f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
3355*f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
3356804edf29SJuan Quintela
335798ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3358f8393946Saurel32if test "$debug_tcg" = "yes" ; then
33592358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3360f8393946Saurel32fi
3361f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
33622358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
3363f3d08ee6SPaul Brookfi
33641625af87Saliguoriif test "$strip_opt" = "yes" ; then
336552ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
33661625af87Saliguorifi
33677d13299dSbellardif test "$bigendian" = "yes" ; then
3368e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
336997a847bcSbellardfi
337067b915a5Sbellardif test "$mingw32" = "yes" ; then
337198ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
33729fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
33739fe6de94SBlue Swirl  version_major=${rc_version%%.*}
33749fe6de94SBlue Swirl  rc_version=${rc_version#*.}
33759fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
33769fe6de94SBlue Swirl  rc_version=${rc_version#*.}
33779fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
33789fe6de94SBlue Swirl  version_micro=0
33799fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
33809fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3381210fa556Spbrookelse
338235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3383210fa556Spbrookfi
3384128ab2ffSblueswir1
3385dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3386dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3387dffcb71cSMark McLoughlinfi
3388dffcb71cSMark McLoughlin
338983fb7adfSbellardif test "$darwin" = "yes" ; then
339098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
339183fb7adfSbellardfi
3392b29fe3edSmalc
3393b29fe3edSmalcif test "$aix" = "yes" ; then
339498ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
3395b29fe3edSmalcfi
3396b29fe3edSmalc
3397ec530c81Sbellardif test "$solaris" = "yes" ; then
339898ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
33992358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
34000475a5caSths  if test "$needs_libsunmath" = "yes" ; then
340175b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
34020475a5caSths  fi
3403ec530c81Sbellardfi
3404179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3405179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3406179cf400SAndreas Färberfi
340797a847bcSbellardif test "$static" = "yes" ; then
340898ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
340997a847bcSbellardfi
34101ba16968SStefan Weilif test "$profiler" = "yes" ; then
34112358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
341205c2a3e7Sbellardfi
3413c20709aaSbellardif test "$slirp" = "yes" ; then
341498ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
3415e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3416c20709aaSbellardfi
34178a16d273Sthsif test "$vde" = "yes" ; then
341898ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
34198a16d273Sthsfi
342047e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
342147e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
342247e98658SCorey Bryantfi
34230c58ac1cSmalcfor card in $audio_card_list; do
3424bb55b712SStefan Weil    def=CONFIG_`echo $card | LC_ALL=C tr '[a-z]' '[A-Z]'`
342598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
34260c58ac1cSmalcdone
34272358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
34280c58ac1cSmalcfor drv in $audio_drv_list; do
3429bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
343098ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
3431923e4521Smalc    if test "$drv" = "fmod"; then
34327aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3433fb065187Sbellard    fi
34340c58ac1cSmalcdone
343567f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
343667f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
343767f86e8eSJuan Quintelafi
3438d5631638Smalcif test "$audio_win_int" = "yes" ; then
3439d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3440d5631638Smalcfi
3441eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
34428ff9cbf7Smalcif test "$mixemu" = "yes" ; then
344398ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
34448ff9cbf7Smalcfi
3445821601eaSJes Sorensenif test "$vnc" = "yes" ; then
3446821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
3447821601eaSJes Sorensenfi
34488d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
344998ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
34508d5d2d4cSthsfi
34512f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
345298ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
34532f9606b3Saliguorifi
3454821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
34552f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
34562f6f5c7aSCorentin Charyfi
3457821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
3458efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3459efe556adSCorentin Charyfi
346076655d6dSaliguoriif test "$fnmatch" = "yes" ; then
34612358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
346276655d6dSaliguorifi
3463ee682d27SStefan Weilif test "$uuid" = "yes" ; then
3464ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
3465ee682d27SStefan Weilfi
3466dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3467dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3468dce512deSChristoph Hellwigfi
3469b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
347098ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
34712358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
347298ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
347398ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
3474a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
347598ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
3476cc8ae6deSpbrookfi
34771ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
347898ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
34798ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
348049ecc3faSbellardfi
348149ecc3faSbellardif test "$cocoa" = "yes" ; then
348298ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
348349ecc3faSbellardfi
34844d3b6f6eSbalrogif test "$curses" = "yes" ; then
348598ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
3486ab4e5602SJan Kiszkafi
34873b3f24adSaurel32if test "$atfile" = "yes" ; then
34882358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
34893b3f24adSaurel32fi
3490ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
34912358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3492ebc996f3SRiku Voipiofi
3493099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
34942358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
3495099d6b0fSRiku Voipiofi
349640ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
349740ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
349840ff6d7eSKevin Wolffi
34993ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
35002358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
35013ce34dfbSvibisreenivasanfi
3502c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
3503c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
3504c2882b96SRiku Voipiofi
3505d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
3506d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3507d0927938SUlrich Hechtfi
3508c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
3509c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3510c727f47dSPeter Maydellfi
3511dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
3512dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
3513dace20dcSPeter Maydellfi
3514d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
3515d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
3516d0927938SUlrich Hechtfi
35173b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
35183b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
35193b6edd16SPeter Maydellfi
35203b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
35213b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
35223b6edd16SPeter Maydellfi
35233b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
35243b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
35253b6edd16SPeter Maydellfi
35263b3f24adSaurel32if test "$inotify" = "yes" ; then
35272358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
35283b3f24adSaurel32fi
3529c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3530c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3531c05c7a73SRiku Voipiofi
35326ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
35336ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
35346ae9a1f4SJuan Quintelafi
35356ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
35366ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
35376ae9a1f4SJuan Quintelafi
3538769ce76dSAlexander Grafif test "$curl" = "yes" ; then
353998ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3540b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3541769ce76dSAlexander Graffi
35422e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
354398ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
35442e4d9fb1Saurel32fi
3545fb599c9aSbalrogif test "$bluez" = "yes" ; then
354698ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3547ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3548fb599c9aSbalrogfi
3549e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3550e37630caSaliguoriif test "$xen" = "yes" ; then
35516dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3552d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3553e37630caSaliguorifi
35545c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
35555c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
35565c6c3a6cSChristoph Hellwigfi
3557758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3558758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3559758e8e38SVenkateswararao Jujjuri (JV)fi
35604f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
35614f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
35624f26f2b6SAvi Kivityfi
3563983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
3564758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
3565758e8e38SVenkateswararao Jujjuri (JV)fi
356677755340Sthsif test "$blobs" = "yes" ; then
356798ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
356877755340Sthsfi
3569bf9298b9Saliguoriif test "$iovec" = "yes" ; then
35702358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3571bf9298b9Saliguorifi
3572ceb42de8Saliguoriif test "$preadv" = "yes" ; then
35732358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3574ceb42de8Saliguorifi
3575f652e6afSaurel32if test "$fdt" = "yes" ; then
35763f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3577f652e6afSaurel32fi
3578dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3579dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3580dcc38d1cSMarcelo Tosattifi
35819195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
35829195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
35839195b2c2SStefan Weilfi
35845f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
35855f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
35865f6b9e8fSBlue Swirlfi
3587e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3588e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3589e78815a5SAndreas Färberfi
3590e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3591e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3592e78815a5SAndreas Färberfi
35931e9737daSRichard Hendersonif test "$sigev_thread_id" = "yes" ; then
35941e9737daSRichard Henderson  echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
35951e9737daSRichard Hendersonfi
359697a847bcSbellard
3597cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3598cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3599cd4ec0b4SGerd Hoffmannfi
3600cd4ec0b4SGerd Hoffmann
360136707144SAlon Levyif test "$smartcard" = "yes" ; then
360236707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
360336707144SAlon Levyfi
360436707144SAlon Levy
3605111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3606111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3607ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3608ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3609111a38b0SRobert Relyeafi
3610111a38b0SRobert Relyea
361169354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
361269354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
361369354a83SHans de Goedefi
361469354a83SHans de Goede
361520ff075bSMichael Walleif test "$opengl" = "yes" ; then
361620ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
361720ff075bSMichael Wallefi
361820ff075bSMichael Walle
3619c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3620c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3621c589b249SRonnie Sahlbergfi
3622c589b249SRonnie Sahlberg
3623f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
3624f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
3625f794573eSEduardo Otubofi
3626f794573eSEduardo Otubo
362783fb7adfSbellard# XXX: suppress that
36287d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
36292358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
36307d3505c5Sbellardfi
36317d3505c5Sbellard
36322358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3633c5937220Spbrook
363420ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
363520ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
363620ff6c80SAnthony Liguorifi
3637f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3638f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3639f27aaf4bSChristian Brunnerfi
364020ff6c80SAnthony Liguori
3641519175a2SAlex Barceloif test "$coroutine_backend" = "ucontext" ; then
3642d0e2fce5SAneesh Kumar K.V  echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
3643fe91bfa8SAlex Barceloelif test "$coroutine_backend" = "sigaltstack" ; then
3644fe91bfa8SAlex Barcelo  echo "CONFIG_SIGALTSTACK_COROUTINE=y" >> $config_host_mak
3645d0e2fce5SAneesh Kumar K.Vfi
3646d0e2fce5SAneesh Kumar K.V
3647d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
3648d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3649d2042378SAneesh Kumar K.Vfi
3650d2042378SAneesh Kumar K.V
3651e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
3652e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3653e06a765eSHarsh Prateek Borafi
3654e06a765eSHarsh Prateek Bora
3655cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
3656cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
365706d71fa1SPeter Maydellfi
365806d71fa1SPeter Maydell
36593f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
36603f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
36613f4349dcSKevin Wolffi
36623f4349dcSKevin Wolf
36638ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
36648ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
36658ab1bf12SLuiz Capitulinofi
36668ab1bf12SLuiz Capitulino
366776a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
366876a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
366976a347e1SRichard Hendersonfi
367076a347e1SRichard Henderson
3671eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
3672eb100396SBharata B Rao  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
3673eb100396SBharata B Raofi
3674eb100396SBharata B Rao
3675583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" ; then
3676583f6e7bSStefan Hajnoczi  echo "CONFIG_VIRTIO_BLK_DATA_PLANE=y" >> $config_host_mak
3677583f6e7bSStefan Hajnoczifi
3678583f6e7bSStefan Hajnoczi
367968063649Sblueswir1# USB host support
368068063649Sblueswir1case "$usb" in
368168063649Sblueswir1linux)
368298ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
368368063649Sblueswir1;;
368468063649Sblueswir1bsd)
368598ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
368668063649Sblueswir1;;
368768063649Sblueswir1*)
368898ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
368968063649Sblueswir1;;
369068063649Sblueswir1esac
369168063649Sblueswir1
3692e4858974SLluís# use default implementation for tracing backend-specific routines
3693e4858974SLluístrace_default=yes
369494a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
36956d8a764eSLluísif test "$trace_backend" = "nop"; then
36966d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
369722890ab5SPrerna Saxenafi
36989410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
36996d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
3700e4858974SLluís  trace_default=no
37016d8a764eSLluís  # Set the appropriate trace file.
3702953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
37039410b56cSPrerna Saxenafi
37046d8a764eSLluísif test "$trace_backend" = "stderr"; then
37056d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
37069a82b6a5SLluís  trace_default=no
37076d8a764eSLluísfi
37086d8a764eSLluísif test "$trace_backend" = "ust"; then
37096d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
37106d8a764eSLluísfi
37116d8a764eSLluísif test "$trace_backend" = "dtrace"; then
37126d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
37136d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
37146d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
37156d8a764eSLluís  fi
3716c276b17dSDaniel P. Berrangefi
37179410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
3718e4858974SLluísif test "$trace_default" = "yes"; then
3719e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3720e4858974SLluísfi
37219410b56cSPrerna Saxena
372298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
372398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3724804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3725804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
37261901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
37271901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
37281901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
3729c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
3730804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
37312b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3732804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
37333c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
3734804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
37353dd46c78SBlue Swirlecho "AS=$as" >> $config_host_mak
37363dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
3737804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3738804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
37399fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
374044dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3741e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3742a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3743f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3744e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3745e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3746e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3747e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3748e39f0062SPaolo Bonzinifi
374942da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
375042da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
375142da6041SGerd Hoffmannelse
375242da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
375342da6041SGerd Hoffmannfi
3754e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3755a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3756a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
375773da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
37583e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3759804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3760957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
376194dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
3762cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
37631d728c39SBlue Swirlif test "$gcov" = "yes" ; then
37641d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
37651d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
37661d728c39SBlue Swirlfi
3767804edf29SJuan Quintela
37684bf6b55bSJuan Quintela# generate list of library paths for linker script
37694bf6b55bSJuan Quintela
37704bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
37714bf6b55bSJuan Quintela
37724bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
37734bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
37744bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
37754bf6b55bSJuan Quintela  else
37764bf6b55bSJuan Quintela    rm ${config_host_ld}~
37774bf6b55bSJuan Quintela  fi
37784bf6b55bSJuan Quintelafi
37794bf6b55bSJuan Quintela
37806efd7517SPeter Maydell# use included Linux headers
37816efd7517SPeter Maydellif test "$linux" = "yes" ; then
3782a307beb6SAndreas Färber  mkdir -p linux-headers
37836efd7517SPeter Maydell  case "$cpu" in
37846efd7517SPeter Maydell  i386|x86_64)
378508312a63SPeter Maydell    linux_arch=x86
37866efd7517SPeter Maydell    ;;
37876efd7517SPeter Maydell  ppcemb|ppc|ppc64)
378808312a63SPeter Maydell    linux_arch=powerpc
37896efd7517SPeter Maydell    ;;
37906efd7517SPeter Maydell  s390x)
379108312a63SPeter Maydell    linux_arch=s390
379208312a63SPeter Maydell    ;;
379308312a63SPeter Maydell  *)
379408312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
379508312a63SPeter Maydell    linux_arch="$cpu"
37966efd7517SPeter Maydell    ;;
37976efd7517SPeter Maydell  esac
379808312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
379908312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
380008312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
380108312a63SPeter Maydell    fi
38026efd7517SPeter Maydellfi
38036efd7517SPeter Maydell
380497a847bcSbellardfor target in $target_list; do
380597a847bcSbellardtarget_dir="$target"
380625be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3807600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
380897a847bcSbellardtarget_bigendian="no"
38091f3d3c8fSJuan Quintela
3810ea2d6a39SJuan Quintelacase "$target_arch2" in
3811e67db06eSJia Liu  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
3812ea2d6a39SJuan Quintela  target_bigendian=yes
3813ea2d6a39SJuan Quintela  ;;
3814ea2d6a39SJuan Quintelaesac
381597a847bcSbellardtarget_softmmu="no"
3816997344f3Sbellardtarget_user_only="no"
3817831b7825Sthstarget_linux_user="no"
381884778508Sblueswir1target_bsd_user="no"
38199e407a85Spbrookcase "$target" in
3820600309b6SBlue Swirl  ${target_arch2}-softmmu)
38219e407a85Spbrook    target_softmmu="yes"
38229e407a85Spbrook    ;;
3823600309b6SBlue Swirl  ${target_arch2}-linux-user)
38249c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
38259c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
38269c7a4202SBlue Swirl      exit 1
38279c7a4202SBlue Swirl    fi
38289e407a85Spbrook    target_user_only="yes"
38299e407a85Spbrook    target_linux_user="yes"
38309e407a85Spbrook    ;;
3831600309b6SBlue Swirl  ${target_arch2}-bsd-user)
38329cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
38339c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
38349c7a4202SBlue Swirl      exit 1
38359c7a4202SBlue Swirl    fi
383684778508Sblueswir1    target_user_only="yes"
383784778508Sblueswir1    target_bsd_user="yes"
383884778508Sblueswir1    ;;
38399e407a85Spbrook  *)
38409e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
38419e407a85Spbrook    exit 1
38429e407a85Spbrook    ;;
38439e407a85Spbrookesac
3844831b7825Sths
384597a847bcSbellardmkdir -p $target_dir
384625be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
384797a847bcSbellard
3848e5fe0c52Spbrookbflt="no"
3849bd0c5661Spbrooktarget_nptl="no"
3850600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
385156aebc89Spbrookgdb_xml_files=""
3852c2e3dee6SLaurent Viviertarget_short_alignment=2
3853c2e3dee6SLaurent Viviertarget_int_alignment=4
3854c2e3dee6SLaurent Viviertarget_long_alignment=4
3855c2e3dee6SLaurent Viviertarget_llong_alignment=8
3856de3a354aSMichael Walletarget_libs_softmmu=
38577ba1e619Saliguori
3858938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
38596acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3860e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3861e73aae67SJuan Quintela
3862600309b6SBlue Swirlcase "$target_arch2" in
38632408a527Saurel32  i386)
38642408a527Saurel32  ;;
38652408a527Saurel32  x86_64)
38666acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
3867c2e3dee6SLaurent Vivier    target_long_alignment=8
38682408a527Saurel32  ;;
38692408a527Saurel32  alpha)
3870c2e3dee6SLaurent Vivier    target_long_alignment=8
3871a4b388ffSRichard Henderson    target_nptl="yes"
38722408a527Saurel32  ;;
38732408a527Saurel32  arm|armeb)
3874b498c8a0SJuan Quintela    TARGET_ARCH=arm
3875e5fe0c52Spbrook    bflt="yes"
3876bd0c5661Spbrook    target_nptl="yes"
387756aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
3878c2e3dee6SLaurent Vivier    target_llong_alignment=4
3879412beee6SGrant Likely    target_libs_softmmu="$fdt_libs"
38802408a527Saurel32  ;;
38812408a527Saurel32  cris)
3882253bd7f8Sedgar_igl    target_nptl="yes"
38832408a527Saurel32  ;;
3884613a22c9SMichael Walle  lm32)
3885de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3886613a22c9SMichael Walle  ;;
38872408a527Saurel32  m68k)
38880938cda5Saurel32    bflt="yes"
388956aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
3890c2e3dee6SLaurent Vivier    target_int_alignment=2
3891c2e3dee6SLaurent Vivier    target_long_alignment=2
3892c2e3dee6SLaurent Vivier    target_llong_alignment=2
38932408a527Saurel32  ;;
3894877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3895877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
389672b675caSEdgar E. Iglesias    bflt="yes"
389772b675caSEdgar E. Iglesias    target_nptl="yes"
3898de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
389972b675caSEdgar E. Iglesias  ;;
39002408a527Saurel32  mips|mipsel)
3901b498c8a0SJuan Quintela    TARGET_ARCH=mips
390225be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3903f04dc72fSPaul Brook    target_nptl="yes"
39042408a527Saurel32  ;;
39052408a527Saurel32  mipsn32|mipsn32el)
3906b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
39076acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
390825be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
39092408a527Saurel32  ;;
39102408a527Saurel32  mips64|mips64el)
3911b498c8a0SJuan Quintela    TARGET_ARCH=mips64
39126acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
391325be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
3914c2e3dee6SLaurent Vivier    target_long_alignment=8
39152408a527Saurel32  ;;
3916e67db06eSJia Liu  or32)
3917e67db06eSJia Liu    TARGET_ARCH=openrisc
3918e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
3919e67db06eSJia Liu  ;;
39202408a527Saurel32  ppc)
3921c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3922d6630708SNathan Froyd    target_nptl="yes"
3923de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
39242408a527Saurel32  ;;
39252408a527Saurel32  ppcemb)
39266acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3927e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3928c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3929d6630708SNathan Froyd    target_nptl="yes"
3930de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
39312408a527Saurel32  ;;
39322408a527Saurel32  ppc64)
39336acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3934e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3935c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3936c2e3dee6SLaurent Vivier    target_long_alignment=8
3937de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
39382408a527Saurel32  ;;
39392408a527Saurel32  ppc64abi32)
3940b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
39416acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3942e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
394325be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3944c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3945de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
39462408a527Saurel32  ;;
39472408a527Saurel32  sh4|sh4eb)
3948b498c8a0SJuan Quintela    TARGET_ARCH=sh4
39494dbed897Spbrook    bflt="yes"
39500b6d3ae0Saurel32    target_nptl="yes"
39512408a527Saurel32  ;;
39522408a527Saurel32  sparc)
39532408a527Saurel32  ;;
39542408a527Saurel32  sparc64)
39556acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3956c2e3dee6SLaurent Vivier    target_long_alignment=8
39572408a527Saurel32  ;;
39582408a527Saurel32  sparc32plus)
3959b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
39606acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3961e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
396225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
39632408a527Saurel32  ;;
396424e804ecSAlexander Graf  s390x)
3965bc434676SUlrich Hecht    target_nptl="yes"
39667b3da903SAlexander Graf    target_long_alignment=8
396724e804ecSAlexander Graf  ;;
3968d2fbca94SGuan Xuetao  unicore32)
3969d2fbca94SGuan Xuetao  ;;
3970cfa550c6SMax Filippov  xtensa|xtensaeb)
3971cfa550c6SMax Filippov    TARGET_ARCH=xtensa
3972cfa550c6SMax Filippov  ;;
39732408a527Saurel32  *)
3974de83cd02Sbellard    echo "Unsupported target CPU"
3975de83cd02Sbellard    exit 1
39762408a527Saurel32  ;;
39772408a527Saurel32esac
39785e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
39795e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
39805e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
39815e8861a0SPaolo Bonzinifi
39825e8861a0SPaolo Bonzini
39835e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
39845e8861a0SPaolo Bonzini
398599afc91dSDaniel P. Berrangeupper() {
398699afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
398799afc91dSDaniel P. Berrange}
398899afc91dSDaniel P. Berrange
398932761257SYeongkyoon Leecase "$cpu" in
3990ed224a56Smalc  i386|x86_64|ppc)
399113586813SStefan Weil    # The TCG interpreter currently does not support ld/st optimization.
399213586813SStefan Weil    if test "$tcg_interpreter" = "no" ; then
399332761257SYeongkyoon Lee        echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_target_mak
399413586813SStefan Weil    fi
399532761257SYeongkyoon Lee  ;;
399632761257SYeongkyoon Leeesac
399732761257SYeongkyoon Lee
3998c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3999c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
4000c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
4001c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
400225be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
400399afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
400425be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
400525be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
400699afc91dSDaniel P. Berrangeecho "TARGET_TYPE=TARGET_TYPE_`upper $target_arch2`" >> $config_target_mak
400725be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
4008e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
4009e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
4010e6e91b9cSJuan Quintelafi
401125be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
40121b0c87fcSJuan Quintelacase "$target_arch2" in
40131b0c87fcSJuan Quintela  i386|x86_64)
40141b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
401525be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
4016eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
4017eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
4018eb6fda0fSAnthony PERARD      fi
401959d21e53SAlexander Graf    else
402059d21e53SAlexander Graf      echo "CONFIG_NO_XEN=y" >> $config_target_mak
4021432d268cSJun Nakajima    fi
402259d21e53SAlexander Graf    ;;
402359d21e53SAlexander Graf  *)
402459d21e53SAlexander Graf    echo "CONFIG_NO_XEN=y" >> $config_target_mak
40251b0c87fcSJuan Quintelaesac
4026c59249f9SJuan Quintelacase "$target_arch2" in
40270e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
4028c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
4029c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
4030c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
4031c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
40325f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
4033adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
4034adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
4035c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
4036c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
403725be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
40381ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
4039d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
4040d5970055SMichael S. Tsirkin      fi
4041c59249f9SJuan Quintela    fi
4042c59249f9SJuan Quintelaesac
4043fae001f5SWen Congyangcase "$target_arch2" in
4044fae001f5SWen Congyang  i386|x86_64)
4045fae001f5SWen Congyang    echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
4046fae001f5SWen Congyangesac
40477f762366SBlue Swirlif test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then
40480a6b8ddeSAlexander Graf  echo "CONFIG_PSERIES=y" >> $config_target_mak
40490a6b8ddeSAlexander Graffi
4050de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
405125be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
405297a847bcSbellardfi
405397a847bcSbellardif test "$target_softmmu" = "yes" ; then
405425be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
4055de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
4056ad4cf3f6SPaul Brook  if test "$smartcard_nss" = "yes" ; then
4057ad4cf3f6SPaul Brook    echo "subdir-$target: subdir-libcacard" >> $config_host_mak
4058ad4cf3f6SPaul Brook  fi
40599fecbed0SWen Congyang  case "$target_arch2" in
40609fecbed0SWen Congyang    i386|x86_64)
40619fecbed0SWen Congyang      echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
40629fecbed0SWen Congyang  esac
4063de83cd02Sbellardfi
4064997344f3Sbellardif test "$target_user_only" = "yes" ; then
406525be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
4066a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
4067997344f3Sbellardfi
4068831b7825Sthsif test "$target_linux_user" = "yes" ; then
406925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
4070831b7825Sthsfi
407156aebc89Spbrooklist=""
407256aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
407356aebc89Spbrook  for x in $gdb_xml_files; do
407456aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
407556aebc89Spbrook  done
407625be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
40773d0f1517SJuan Quintelafi
4078de83cd02Sbellard
4079e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
408025be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
4081e5fe0c52Spbrookfi
4082bd0c5661Spbrookif test "$target_user_only" = "yes" \
4083bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
408425be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
4085bd0c5661Spbrookfi
4086379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
408725be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
4088379f6698SPaul Brookfi
408984778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
409025be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
409184778508Sblueswir1fi
40925b0753e0Sbellard
40935a4d701aSJan Kiszka# the static way of configuring available audio cards requires this workaround
40945a4d701aSJan Kiszkaif test "$target_user_only" != "yes" && grep -q CONFIG_PCSPK $source_path/default-configs/$target.mak; then
40955a4d701aSJan Kiszka  echo "CONFIG_PCSPK=y" >> $config_target_mak
40965a4d701aSJan Kiszkafi
40975a4d701aSJan Kiszka
40984afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
4099fa282484SJuan Quintela
41004afddb55SJuan Quintelacflags=""
4101f9728943SPaolo Bonziniincludes=""
4102fa282484SJuan Quintelaldflags=""
41039b8e111fSJuan Quintela
41049195b2c2SStefan Weilif test "$tcg_interpreter" = "yes"; then
41059195b2c2SStefan Weil  includes="-I\$(SRC_PATH)/tcg/tci $includes"
41069195b2c2SStefan Weilelif test "$ARCH" = "sparc64" ; then
4107f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
410824e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
4109f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
41105d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
4111f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
411257ddfbf7SJuan Quintelaelse
4113f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
411457ddfbf7SJuan Quintelafi
4115f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
411657ddfbf7SJuan Quintela
41176efd7517SPeter Maydellif test "$linux" = "yes" ; then
41186efd7517SPeter Maydell  includes="-I\$(SRC_PATH)/linux-headers $includes"
41196efd7517SPeter Maydellfi
41206efd7517SPeter Maydell
412164656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
412264656024SJuan Quintela  case "$i" in
412364656024SJuan Quintela  alpha)
412425be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
412576cad711SPaolo Bonzini    echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
412664656024SJuan Quintela  ;;
412764656024SJuan Quintela  arm)
412825be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
412976cad711SPaolo Bonzini    echo "CONFIG_ARM_DIS=y"  >> config-all-disas.mak
413064656024SJuan Quintela  ;;
413164656024SJuan Quintela  cris)
413225be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
413376cad711SPaolo Bonzini    echo "CONFIG_CRIS_DIS=y"  >> config-all-disas.mak
413464656024SJuan Quintela  ;;
413564656024SJuan Quintela  hppa)
413625be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
413776cad711SPaolo Bonzini    echo "CONFIG_HPPA_DIS=y"  >> config-all-disas.mak
413864656024SJuan Quintela  ;;
413964656024SJuan Quintela  i386|x86_64)
414025be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
414176cad711SPaolo Bonzini    echo "CONFIG_I386_DIS=y"  >> config-all-disas.mak
414264656024SJuan Quintela  ;;
4143903ec55cSAurelien Jarno  ia64*)
4144903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
414576cad711SPaolo Bonzini    echo "CONFIG_IA64_DIS=y"  >> config-all-disas.mak
4146903ec55cSAurelien Jarno  ;;
414779368f49SMichael Walle  lm32)
414879368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
414976cad711SPaolo Bonzini    echo "CONFIG_LM32_DIS=y"  >> config-all-disas.mak
415079368f49SMichael Walle  ;;
415164656024SJuan Quintela  m68k)
415225be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
415376cad711SPaolo Bonzini    echo "CONFIG_M68K_DIS=y"  >> config-all-disas.mak
415464656024SJuan Quintela  ;;
4155877fdc12SEdgar E. Iglesias  microblaze*)
415625be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
415776cad711SPaolo Bonzini    echo "CONFIG_MICROBLAZE_DIS=y"  >> config-all-disas.mak
415864656024SJuan Quintela  ;;
415964656024SJuan Quintela  mips*)
416025be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
416176cad711SPaolo Bonzini    echo "CONFIG_MIPS_DIS=y"  >> config-all-disas.mak
416264656024SJuan Quintela  ;;
4163e67db06eSJia Liu  or32)
4164e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
416576cad711SPaolo Bonzini    echo "CONFIG_OPENRISC_DIS=y"  >> config-all-disas.mak
4166e67db06eSJia Liu  ;;
416764656024SJuan Quintela  ppc*)
416825be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
416976cad711SPaolo Bonzini    echo "CONFIG_PPC_DIS=y"  >> config-all-disas.mak
417064656024SJuan Quintela  ;;
417124e804ecSAlexander Graf  s390*)
417225be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
417376cad711SPaolo Bonzini    echo "CONFIG_S390_DIS=y"  >> config-all-disas.mak
417464656024SJuan Quintela  ;;
417564656024SJuan Quintela  sh4)
417625be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
417776cad711SPaolo Bonzini    echo "CONFIG_SH4_DIS=y"  >> config-all-disas.mak
417864656024SJuan Quintela  ;;
417964656024SJuan Quintela  sparc*)
418025be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
418176cad711SPaolo Bonzini    echo "CONFIG_SPARC_DIS=y"  >> config-all-disas.mak
418264656024SJuan Quintela  ;;
4183cfa550c6SMax Filippov  xtensa*)
4184cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
418576cad711SPaolo Bonzini    echo "CONFIG_XTENSA_DIS=y"  >> config-all-disas.mak
4186cfa550c6SMax Filippov  ;;
418764656024SJuan Quintela  esac
418864656024SJuan Quinteladone
41899195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
41909195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
419176cad711SPaolo Bonzini  echo "CONFIG_TCI_DIS=y"  >> config-all-disas.mak
41929195b2c2SStefan Weilfi
419364656024SJuan Quintela
41946ee7126fSJuan Quintelacase "$ARCH" in
41956ee7126fSJuan Quintelaalpha)
41966ee7126fSJuan Quintela  # Ensure there's only a single GP
41976ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
41986ee7126fSJuan Quintela;;
41996ee7126fSJuan Quintelaesac
42006ee7126fSJuan Quintela
420155d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
420255d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
420355d9c04bSJuan Quintela  arm)
420455d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
420555d9c04bSJuan Quintela  ;;
420625a8bb96SMichael Walle  lm32)
420725a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
420825a8bb96SMichael Walle  ;;
420955d9c04bSJuan Quintela  i386|mips|ppc)
421055d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
421155d9c04bSJuan Quintela  ;;
421255d9c04bSJuan Quintela  esac
421355d9c04bSJuan Quintelafi
421455d9c04bSJuan Quintela
4215d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
421625be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4217d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4218d02c1db3SJuan Quintela    cflags="-p $cflags"
4219d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4220d02c1db3SJuan Quintela  fi
4221d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4222d02c1db3SJuan Quintela    ldflags="-p $ldflags"
422325be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4224d02c1db3SJuan Quintela  fi
4225d02c1db3SJuan Quintelafi
4226d02c1db3SJuan Quintela
42279195b2c2SStefan Weilif test "$ARCH" = "tci"; then
42289195b2c2SStefan Weil  linker_script=""
42299195b2c2SStefan Weilelse
4230c1c93672SPaolo Bonzini  linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/ldscripts/\$(ARCH).ld"
42319195b2c2SStefan Weilfi
42329195b2c2SStefan Weil
42339b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4234fa282484SJuan Quintela  case "$ARCH" in
42354d58be06SRichard Henderson  alpha | s390x)
42364d58be06SRichard Henderson    # The default placement of the application is fine.
42374d58be06SRichard Henderson    ;;
4238fd76e73aSRichard Henderson  *)
4239322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
4240fa282484SJuan Quintela    ;;
4241fa282484SJuan Quintela  esac
4242fa282484SJuan Quintelafi
4243fa282484SJuan Quintela
424425be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
424525be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4246f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
4247fa282484SJuan Quintela
424897a847bcSbellarddone # for target in $targets
42497d13299dSbellard
4250b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
4251b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
4252b776eca1SGerd Hoffmannfi
4253b776eca1SGerd Hoffmann
4254d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
4255927b241dSMichael WalleDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32"
42562dee8d54SPaolo BonziniDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
42572d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
42582dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
425900c705fbSPaolo BonziniDIRS="$DIRS libcacard libcacard/libcacard libcacard/trace"
4260c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4261c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
426200c705fbSPaolo BonziniFILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile"
4263ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4264446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
42652d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4266753d11f2SRichard Hendersonfor bios_file in \
4267753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
42685acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
4269753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4270753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4271753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4272753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4273753d11f2SRichard Hendersondo
42747ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
42757ea78b74SJan Kiszkadone
4276d1807a4fSPaolo Bonzinimkdir -p $DIRS
42777d13299dSbellardfor f in $FILES ; do
427872b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4279f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4280f9245e10SPeter Maydell    fi
42817d13299dSbellarddone
42821ad2134fSPaul Brook
4283c34ebfdcSAnthony Liguori# temporary config to build submodules
42842d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4285c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
428637116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4287c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
42883dd46c78SBlue Swirl    echo "AS=$as" >> $config_mak
4289c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4290c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
42913dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
4292c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4293c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
4294c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4295c34ebfdcSAnthony Liguoridone
4296c34ebfdcSAnthony Liguori
4297b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4298b40292e7SJan Kiszka  mkdir -p QMP
4299b40292e7SJan Kiszkafi
4300