xref: /openbmc/qemu/configure (revision 1405b6290fa2143e02dcede90b116d8d663ae669)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
57d13299dSbellard# set temporary file name
67d13299dSbellardif test ! -z "$TMPDIR" ; then
77d13299dSbellard    TMPDIR1="${TMPDIR}"
87d13299dSbellardelif test ! -z "$TEMPDIR" ; then
97d13299dSbellard    TMPDIR1="${TEMPDIR}"
107d13299dSbellardelse
117d13299dSbellard    TMPDIR1="/tmp"
127d13299dSbellardfi
137d13299dSbellard
143ef693a0SbellardTMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
153ef693a0SbellardTMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16a91b857cSmalcTMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
177d13299dSbellard
180ba8681eSLoïc Minier# NB: do not call "exit" in the trap handler; this is buggy with some shells;
190ba8681eSLoïc Minier# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
200ba8681eSLoïc Miniertrap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21da1d85e3SGerd Hoffmannrm -f config.log
229ac81bbbSmalc
23b48e3611SPeter Maydell# Print a helpful header at the top of config.log
24b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
25979ae168SPeter Maydellprintf "# Configured with:" >> config.log
26979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
27979ae168SPeter Maydellecho >> config.log
28b48e3611SPeter Maydellecho "#" >> config.log
29b48e3611SPeter Maydell
3076ad07a4SPeter Maydellerror_exit() {
3176ad07a4SPeter Maydell    echo
3276ad07a4SPeter Maydell    echo "ERROR: $1"
3376ad07a4SPeter Maydell    while test -n "$2"; do
3476ad07a4SPeter Maydell        echo "       $2"
3576ad07a4SPeter Maydell        shift
3676ad07a4SPeter Maydell    done
3776ad07a4SPeter Maydell    echo
3876ad07a4SPeter Maydell    exit 1
3976ad07a4SPeter Maydell}
4076ad07a4SPeter Maydell
418dc38a78SPeter Maydelldo_cc() {
428dc38a78SPeter Maydell    # Run the compiler, capturing its output to the log.
438dc38a78SPeter Maydell    echo $cc "$@" >> config.log
448dc38a78SPeter Maydell    $cc "$@" >> config.log 2>&1 || return $?
458dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
468dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
478dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
488dc38a78SPeter Maydell    # obvious to developers.
498dc38a78SPeter Maydell    if test "$werror" != "yes"; then
508dc38a78SPeter Maydell        return 0
518dc38a78SPeter Maydell    fi
528dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
538dc38a78SPeter Maydell    case "$*" in
548dc38a78SPeter Maydell        *-Werror*)
558dc38a78SPeter Maydell           return 0
568dc38a78SPeter Maydell        ;;
578dc38a78SPeter Maydell    esac
588dc38a78SPeter Maydell    echo $cc -Werror "$@" >> config.log
598dc38a78SPeter Maydell    $cc -Werror "$@" >> config.log 2>&1 && return $?
6076ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
6176ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
6276ad07a4SPeter Maydell        "will be at the bottom of config.log." \
6376ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
648dc38a78SPeter Maydell}
658dc38a78SPeter Maydell
6652166aa0SJuan Quintelacompile_object() {
678dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
6852166aa0SJuan Quintela}
6952166aa0SJuan Quintela
7052166aa0SJuan Quintelacompile_prog() {
7152166aa0SJuan Quintela  local_cflags="$1"
7252166aa0SJuan Quintela  local_ldflags="$2"
738dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
7452166aa0SJuan Quintela}
7552166aa0SJuan Quintela
7611568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
7711568d6dSPaolo Bonzinisymlink() {
7872b8b5a1SStefan Weil  rm -rf "$2"
79ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
8072b8b5a1SStefan Weil  ln -s "$1" "$2"
8111568d6dSPaolo Bonzini}
8211568d6dSPaolo Bonzini
830dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
840dba6195SLoïc Minier# executable or a builtin)
850dba6195SLoïc Minierhas() {
860dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
870dba6195SLoïc Minier}
880dba6195SLoïc Minier
890dba6195SLoïc Minier# search for an executable in PATH
900dba6195SLoïc Minierpath_of() {
910dba6195SLoïc Minier    local_command="$1"
920dba6195SLoïc Minier    local_ifs="$IFS"
930dba6195SLoïc Minier    local_dir=""
940dba6195SLoïc Minier
950dba6195SLoïc Minier    # pathname has a dir component?
960dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
970dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
980dba6195SLoïc Minier            echo "$local_command"
990dba6195SLoïc Minier            return 0
1000dba6195SLoïc Minier        fi
1010dba6195SLoïc Minier    fi
1020dba6195SLoïc Minier    if [ -z "$local_command" ]; then
1030dba6195SLoïc Minier        return 1
1040dba6195SLoïc Minier    fi
1050dba6195SLoïc Minier
1060dba6195SLoïc Minier    IFS=:
1070dba6195SLoïc Minier    for local_dir in $PATH; do
1080dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
1090dba6195SLoïc Minier            echo "$local_dir/$local_command"
1100dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1110dba6195SLoïc Minier            return 0
1120dba6195SLoïc Minier        fi
1130dba6195SLoïc Minier    done
1140dba6195SLoïc Minier    # not found
1150dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1160dba6195SLoïc Minier    return 1
1170dba6195SLoïc Minier}
1180dba6195SLoïc Minier
1197d13299dSbellard# default parameters
120ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
1212ff6b91eSJuan Quintelacpu=""
1221e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
12343ce4dfeSbellardstatic="no"
1247d13299dSbellardcross_prefix=""
1250c58ac1cSmalcaudio_drv_list=""
126eb852011SMarkus Armbrusterblock_drv_whitelist=""
127e49d021eSPeter Maydellhost_cc="cc"
12873da375eSJuan Quintelalibs_softmmu=""
1293e2e0e6bSJuan Quintelalibs_tools=""
13067f86e8eSJuan Quintelaaudio_pt_int=""
131d5631638Smalcaudio_win_int=""
1322b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
133957f1f99SMichael Rothlibs_qga=""
1345bc62e01SGerd Hoffmanndebug_info="yes"
135ac0df51dSaliguori
136afb63ebdSStefan Weil# Don't accept a target_list environment variable.
137afb63ebdSStefan Weilunset target_list
138377529c0SPaolo Bonzini
139377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
140377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
141377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
142377529c0SPaolo Bonzini#              unless --disable-foo is given
143377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
144377529c0SPaolo Bonzini#              feature will searched for,
145377529c0SPaolo Bonzini#              if not found, configure exits with error
146377529c0SPaolo Bonzini#
147377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
148377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
149377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
150377529c0SPaolo Bonzini
151377529c0SPaolo Bonzinibluez=""
152377529c0SPaolo Bonzinibrlapi=""
153377529c0SPaolo Bonzinicurl=""
154377529c0SPaolo Bonzinicurses=""
155377529c0SPaolo Bonzinidocs=""
156377529c0SPaolo Bonzinifdt=""
157377529c0SPaolo Bonzininptl=""
158e2134eb9SGerd Hoffmannpixman=""
159377529c0SPaolo Bonzinisdl=""
160983eef5aSMeador Ingevirtfs=""
161821601eaSJes Sorensenvnc="yes"
162377529c0SPaolo Bonzinisparse="no"
163377529c0SPaolo Bonziniuuid=""
164377529c0SPaolo Bonzinivde=""
165377529c0SPaolo Bonzinivnc_tls=""
166377529c0SPaolo Bonzinivnc_sasl=""
167377529c0SPaolo Bonzinivnc_jpeg=""
168377529c0SPaolo Bonzinivnc_png=""
1697536ee4bSTim Hardeckvnc_ws=""
170377529c0SPaolo Bonzinixen=""
171d5b93ddfSAnthony PERARDxen_ctrl_version=""
172eb6fda0fSAnthony PERARDxen_pci_passthrough=""
173377529c0SPaolo Bonzinilinux_aio=""
17447e98658SCorey Bryantcap_ng=""
175377529c0SPaolo Bonziniattr=""
1764f26f2b6SAvi Kivitylibattr=""
177377529c0SPaolo Bonzinixfs=""
178377529c0SPaolo Bonzini
179d41a75a2SBradvhost_net="no"
1805e9be92dSNicholas Bellingervhost_scsi="no"
181d41a75a2SBradkvm="no"
182377529c0SPaolo Bonzinigprof="no"
183377529c0SPaolo Bonzinidebug_tcg="no"
184377529c0SPaolo Bonzinidebug="no"
185377529c0SPaolo Bonzinistrip_opt="yes"
1869195b2c2SStefan Weiltcg_interpreter="no"
187377529c0SPaolo Bonzinibigendian="no"
188377529c0SPaolo Bonzinimingw32="no"
1891d728c39SBlue Swirlgcov="no"
1901d728c39SBlue Swirlgcov_tool="gcov"
191377529c0SPaolo BonziniEXESUF=""
192377529c0SPaolo Bonziniprefix="/usr/local"
193377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
194528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
195850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
196377529c0SPaolo Bonzinibindir="\${prefix}/bin"
1973aa5d2beSAlon Levylibdir="\${prefix}/lib"
1988bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
1990f94d6daSAlon Levyincludedir="\${prefix}/include"
200377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
201785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
202377529c0SPaolo Bonziniconfsuffix="/qemu"
203377529c0SPaolo Bonzinislirp="yes"
204377529c0SPaolo Bonzinifmod_lib=""
205377529c0SPaolo Bonzinifmod_inc=""
206377529c0SPaolo Bonzinioss_lib=""
207377529c0SPaolo Bonzinibsd="no"
208377529c0SPaolo Bonzinilinux="no"
209377529c0SPaolo Bonzinisolaris="no"
210377529c0SPaolo Bonziniprofiler="no"
211377529c0SPaolo Bonzinicocoa="no"
212377529c0SPaolo Bonzinisoftmmu="yes"
213377529c0SPaolo Bonzinilinux_user="no"
214377529c0SPaolo Bonzinibsd_user="no"
21530163d89SPeter Maydellguest_base="yes"
216377529c0SPaolo Bonziniuname_release=""
217377529c0SPaolo Bonzinimixemu="no"
218377529c0SPaolo Bonziniaix="no"
219377529c0SPaolo Bonziniblobs="yes"
220377529c0SPaolo Bonzinipkgversion=""
22140d6444eSAvi Kivitypie=""
222377529c0SPaolo Bonzinizero_malloc=""
2233556c233SPaolo Bonziniqom_cast_debug="yes"
224377529c0SPaolo Bonzinitrace_backend="nop"
225377529c0SPaolo Bonzinitrace_file="trace"
226377529c0SPaolo Bonzinispice=""
227377529c0SPaolo Bonzinirbd=""
228111a38b0SRobert Relyeasmartcard_nss=""
2292b2325ffSGerd Hoffmannlibusb=""
23069354a83SHans de Goedeusb_redir=""
231b1e5fff4SMichael Walleglx=""
2321ece9905SAlon Levyzlib="yes"
233d138cee9SMichael Rothguest_agent="yes"
2344b1c11fdSDaniel P. Berrangewant_tools="yes"
235c589b249SRonnie Sahlberglibiscsi=""
236519175a2SAlex Barcelocoroutine=""
237f794573eSEduardo Otuboseccomp=""
238eb100396SBharata B Raoglusterfs=""
239583f6e7bSStefan Hajnoczivirtio_blk_data_plane=""
240a4ccabcfSAnthony Liguorigtk=""
241528de90aSDaniel P. Berrangegtkabi="2.0"
242ab214c29SStefan Bergertpm="no"
2430a12ec87SRichard W.M. Joneslibssh2=""
244377529c0SPaolo Bonzini
245ac0df51dSaliguori# parse CC options first
246ac0df51dSaliguorifor opt do
247ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
248ac0df51dSaliguori  case "$opt" in
249ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
250ac0df51dSaliguori  ;;
2513d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
252ac0df51dSaliguori  ;;
253ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
254ca4deeb1SPaolo Bonzini  ;;
2552ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2562ff6b91eSJuan Quintela  ;;
257a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
258f9943cd5SGerd Hoffmann                    EXTRA_CFLAGS="$optarg"
259e2a2ed06SJuan Quintela  ;;
260e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
261f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
262e2a2ed06SJuan Quintela  ;;
2635bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2645bc62e01SGerd Hoffmann  ;;
2655bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2665bc62e01SGerd Hoffmann  ;;
267ac0df51dSaliguori  esac
268ac0df51dSaliguoridone
269ac0df51dSaliguori# OS specific
270ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
27193148aa5SStefan Weil# we can eliminate its usage altogether.
272ac0df51dSaliguori
273e49d021eSPeter Maydell# Preferred compiler:
274e49d021eSPeter Maydell#  ${CC} (if set)
275e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
276e49d021eSPeter Maydell#  system compiler
277e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
278e49d021eSPeter Maydell  cc="$host_cc"
279e49d021eSPeter Maydellelse
280b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
281e49d021eSPeter Maydellfi
282e49d021eSPeter Maydell
283b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
2843dd46c78SBlue Swirlas="${AS-${cross_prefix}as}"
2853dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
286b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
287b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
2883f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
289b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
290b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
29117884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
29217884d7bSSergei Trofimovichquery_pkg_config() {
29317884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
29417884d7bSSergei Trofimovich}
29517884d7bSSergei Trofimovichpkg_config=query_pkg_config
296b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
297ac0df51dSaliguori
298be17dc90SMichael S. Tsirkin# default flags for all hosts
299be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
300f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
301c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
302be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
3036b4c305cSPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
3045bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
3055bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
306be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
3075bc62e01SGerd Hoffmannfi
308be17dc90SMichael S. Tsirkin
309ca4deeb1SPaolo Bonzini# make source path absolute
310ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
311ca4deeb1SPaolo Bonzini
312ac0df51dSaliguoricheck_define() {
313ac0df51dSaliguoricat > $TMPC <<EOF
314ac0df51dSaliguori#if !defined($1)
315fd786e1aSPeter Maydell#error $1 not defined
316ac0df51dSaliguori#endif
317ac0df51dSaliguoriint main(void) { return 0; }
318ac0df51dSaliguoriEOF
31952166aa0SJuan Quintela  compile_object
320ac0df51dSaliguori}
321ac0df51dSaliguori
322bbea4050SPeter Maydellif check_define __linux__ ; then
323bbea4050SPeter Maydell  targetos="Linux"
324bbea4050SPeter Maydellelif check_define _WIN32 ; then
325bbea4050SPeter Maydell  targetos='MINGW32'
326bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
327bbea4050SPeter Maydell  targetos='OpenBSD'
328bbea4050SPeter Maydellelif check_define __sun__ ; then
329bbea4050SPeter Maydell  targetos='SunOS'
330bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
331bbea4050SPeter Maydell  targetos='Haiku'
332bbea4050SPeter Maydellelse
333bbea4050SPeter Maydell  targetos=`uname -s`
334bbea4050SPeter Maydellfi
335bbea4050SPeter Maydell
336bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
337bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
338bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
339bbea4050SPeter Maydell# the correct CPU with the --cpu option.
340bbea4050SPeter Maydellcase $targetos in
341bbea4050SPeter MaydellDarwin)
342bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
343bbea4050SPeter Maydell  # run 64-bit userspace code.
344bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
345bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
346bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
347bbea4050SPeter Maydell    cpu="x86_64"
348bbea4050SPeter Maydell  fi
349bbea4050SPeter Maydell  ;;
350bbea4050SPeter MaydellSunOS)
351bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
352bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
353bbea4050SPeter Maydell    cpu="x86_64"
354bbea4050SPeter Maydell  fi
355bbea4050SPeter Maydellesac
356bbea4050SPeter Maydell
3572ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3582ff6b91eSJuan Quintela  # command line argument
3592ff6b91eSJuan Quintela  :
3602ff6b91eSJuan Quintelaelif check_define __i386__ ; then
361ac0df51dSaliguori  cpu="i386"
362ac0df51dSaliguorielif check_define __x86_64__ ; then
363ac0df51dSaliguori  cpu="x86_64"
3643aa9bd6cSblueswir1elif check_define __sparc__ ; then
3653aa9bd6cSblueswir1  if check_define __arch64__ ; then
3663aa9bd6cSblueswir1    cpu="sparc64"
3673aa9bd6cSblueswir1  else
3683aa9bd6cSblueswir1    cpu="sparc"
3693aa9bd6cSblueswir1  fi
370fdf7ed96Smalcelif check_define _ARCH_PPC ; then
371fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
372fdf7ed96Smalc    cpu="ppc64"
373ac0df51dSaliguori  else
374fdf7ed96Smalc    cpu="ppc"
375fdf7ed96Smalc  fi
376afa05235SAurelien Jarnoelif check_define __mips__ ; then
377afa05235SAurelien Jarno  cpu="mips"
378477ba620SAurelien Jarnoelif check_define __ia64__ ; then
379477ba620SAurelien Jarno  cpu="ia64"
380d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
381d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
382d66ed0eaSAurelien Jarno    cpu="s390x"
383d66ed0eaSAurelien Jarno  else
384d66ed0eaSAurelien Jarno    cpu="s390"
385d66ed0eaSAurelien Jarno  fi
38621d89f84SPeter Maydellelif check_define __arm__ ; then
38721d89f84SPeter Maydell  cpu="arm"
388f28ffed5SBradelif check_define __hppa__ ; then
389f28ffed5SBrad  cpu="hppa"
390fdf7ed96Smalcelse
391fdf7ed96Smalc  cpu=`uname -m`
392ac0df51dSaliguorifi
393ac0df51dSaliguori
394359bc95dSPeter MaydellARCH=
395359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
396359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
3977d13299dSbellardcase "$cpu" in
398359bc95dSPeter Maydell  ia64|ppc|ppc64|s390|s390x|sparc64)
399ea8f20f8SJuan Quintela    cpu="$cpu"
400ea8f20f8SJuan Quintela  ;;
4017d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
40297a847bcSbellard    cpu="i386"
4037d13299dSbellard  ;;
404aaa5fa14Saurel32  x86_64|amd64)
405aaa5fa14Saurel32    cpu="x86_64"
406aaa5fa14Saurel32  ;;
40721d89f84SPeter Maydell  armv*b|armv*l|arm)
40821d89f84SPeter Maydell    cpu="arm"
4097d13299dSbellard  ;;
410f28ffed5SBrad  hppa|parisc|parisc64)
411f54b3f92Saurel32    cpu="hppa"
412f54b3f92Saurel32  ;;
413afa05235SAurelien Jarno  mips*)
414afa05235SAurelien Jarno    cpu="mips"
415afa05235SAurelien Jarno  ;;
4163142255cSblueswir1  sparc|sun4[cdmuv])
417ae228531Sbellard    cpu="sparc"
418ae228531Sbellard  ;;
4197d13299dSbellard  *)
420359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
421359bc95dSPeter Maydell    ARCH=unknown
4227d13299dSbellard  ;;
4237d13299dSbellardesac
424359bc95dSPeter Maydellif test -z "$ARCH"; then
425359bc95dSPeter Maydell  ARCH="$cpu"
426359bc95dSPeter Maydellfi
427e2d52ad3SJuan Quintela
4287d13299dSbellard# OS specific
4290dbfc675SJuan Quintela
4307d13299dSbellardcase $targetos in
431c326e0afSbellardCYGWIN*)
432c326e0afSbellard  mingw32="yes"
433a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
434d5631638Smalc  audio_possible_drivers="winwave sdl"
435d5631638Smalc  audio_drv_list="winwave"
436c326e0afSbellard;;
43767b915a5SbellardMINGW32*)
43867b915a5Sbellard  mingw32="yes"
439d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
440d5631638Smalc  audio_drv_list="winwave"
44167b915a5Sbellard;;
4425c40d2bdSthsGNU/kFreeBSD)
443a167ba50SAurelien Jarno  bsd="yes"
4440c58ac1cSmalc  audio_drv_list="oss"
445f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4465c40d2bdSths;;
4477d3505c5SbellardFreeBSD)
4487d3505c5Sbellard  bsd="yes"
4490db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4500c58ac1cSmalc  audio_drv_list="oss"
451f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
452f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
453f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
4547d3505c5Sbellard;;
455c5e97233Sblueswir1DragonFly)
456c5e97233Sblueswir1  bsd="yes"
4570db4a067SPaolo Bonzini  make="${MAKE-gmake}"
458c5e97233Sblueswir1  audio_drv_list="oss"
459c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
460c5e97233Sblueswir1;;
4617d3505c5SbellardNetBSD)
4627d3505c5Sbellard  bsd="yes"
4630db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4640c58ac1cSmalc  audio_drv_list="oss"
465c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4668ef92a88Sblueswir1  oss_lib="-lossaudio"
4677d3505c5Sbellard;;
4687d3505c5SbellardOpenBSD)
4697d3505c5Sbellard  bsd="yes"
4700db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4710c58ac1cSmalc  audio_drv_list="oss"
472c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4732f6a1ab0Sblueswir1  oss_lib="-lossaudio"
4747d3505c5Sbellard;;
47583fb7adfSbellardDarwin)
47683fb7adfSbellard  bsd="yes"
47783fb7adfSbellard  darwin="yes"
4781b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
479a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4800c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4811b0f9cc2Saliguori  else
482a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
4831b0f9cc2Saliguori  fi
484fd677642Sths  cocoa="yes"
4850c58ac1cSmalc  audio_drv_list="coreaudio"
486c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4870c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4887973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
489a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
490a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
491a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
49283fb7adfSbellard;;
493ec530c81SbellardSunOS)
494ec530c81Sbellard  solaris="yes"
4950db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4960db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
497fa58948dSBlue Swirl  ld="gld"
498e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
4990475a5caSths  needs_libsunmath="no"
500c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
501c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
5020475a5caSths    if test "$solarisrev" -le 9 ; then
5030475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
5040475a5caSths        needs_libsunmath="yes"
505f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
506f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
507f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
5080475a5caSths      else
50976ad07a4SPeter Maydell        error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
51076ad07a4SPeter Maydell            "libsunmath from the Sun Studio compilers tools, due to a lack of" \
51176ad07a4SPeter Maydell            "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
51276ad07a4SPeter Maydell            "Studio 11 can be downloaded from www.sun.com."
5130475a5caSths      fi
5140475a5caSths    fi
51586b2bd93Sths  fi
5166b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
5170c58ac1cSmalc    audio_drv_list="oss"
5186b4d2ba1Sths  fi
519c2de5c91Smalc  audio_possible_drivers="oss sdl"
520d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
521d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
522d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
523d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
524a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
525560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
526560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
527560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
528ec530c81Sbellard;;
529b29fe3edSmalcAIX)
530b29fe3edSmalc  aix="yes"
5310db4a067SPaolo Bonzini  make="${MAKE-gmake}"
532b29fe3edSmalc;;
533179cf400SAndreas FärberHaiku)
534179cf400SAndreas Färber  haiku="yes"
535179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
536179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
537179cf400SAndreas Färber;;
538fb065187Sbellard*)
5390c58ac1cSmalc  audio_drv_list="oss"
540b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5415327cf48Sbellard  linux="yes"
542831b7825Sths  linux_user="yes"
54368063649Sblueswir1  usb="linux"
544af2be207SJan Kiszka  kvm="yes"
545af2be207SJan Kiszka  vhost_net="yes"
5465e9be92dSNicholas Bellinger  vhost_scsi="yes"
54707f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
548c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
549c9ec1fe4Sbellard  fi
550fd123245SJan Kiszka  QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers $QEMU_INCLUDES"
551fb065187Sbellard;;
5527d13299dSbellardesac
5537d13299dSbellard
5547d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
555b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
55668063649Sblueswir1    usb="bsd"
55784778508Sblueswir1    bsd_user="yes"
5587d3505c5Sbellard  fi
55908de3949SAndreas Färberfi
5607d3505c5Sbellard
5610db4a067SPaolo Bonzini: ${make=${MAKE-make}}
5620db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
563c886edfbSBlue Swirl: ${python=${PYTHON-python}}
564e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
5650db4a067SPaolo Bonzini
5663c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
5673c4a4d0dSPeter Maydellif has clang; then
5683c4a4d0dSPeter Maydell  objcc=clang
5693c4a4d0dSPeter Maydellelse
5703c4a4d0dSPeter Maydell  objcc="$cc"
5713c4a4d0dSPeter Maydellfi
5723c4a4d0dSPeter Maydell
5733457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
5743457a3f8SJuan Quintela  EXESUF=".exe"
575a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
576e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
577e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
578f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
579f7cf5d5bSStefan Weilcat > $TMPC << EOF
580f7cf5d5bSStefan Weilint main(void) { return 0; }
581f7cf5d5bSStefan WeilEOF
582f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
583f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
584f7cf5d5bSStefan Weil  fi
585c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
586683035deSPaolo Bonzini  mandir="\${prefix}"
587528ae5b8SEduardo Habkost  datadir="\${prefix}"
588850da188SEduardo Habkost  qemu_docdir="\${prefix}"
589683035deSPaolo Bonzini  bindir="\${prefix}"
590683035deSPaolo Bonzini  sysconfdir="\${prefix}"
591785c23aeSLuiz Capitulino  local_statedir="\${prefix}"
592683035deSPaolo Bonzini  confsuffix=""
593368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
5943457a3f8SJuan Quintelafi
5953457a3f8SJuan Quintela
596487fefdbSAnthony Liguoriwerror=""
59785aa5189Sbellard
5987d13299dSbellardfor opt do
599a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
6007d13299dSbellard  case "$opt" in
6012efc3265Sbellard  --help|-h) show_help=yes
6022efc3265Sbellard  ;;
60399123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
60499123e13SMike Frysinger  ;;
605b1a550a0Spbrook  --prefix=*) prefix="$optarg"
6067d13299dSbellard  ;;
607b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
60832ce6337Sbellard  ;;
609ca4deeb1SPaolo Bonzini  --source-path=*)
6107d13299dSbellard  ;;
611ac0df51dSaliguori  --cross-prefix=*)
6127d13299dSbellard  ;;
613ac0df51dSaliguori  --cc=*)
6147d13299dSbellard  ;;
615b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
61683469015Sbellard  ;;
6173c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
6183c4a4d0dSPeter Maydell  ;;
619b1a550a0Spbrook  --make=*) make="$optarg"
6207d13299dSbellard  ;;
6216a882643Spbrook  --install=*) install="$optarg"
6226a882643Spbrook  ;;
623c886edfbSBlue Swirl  --python=*) python="$optarg"
624c886edfbSBlue Swirl  ;;
6251d728c39SBlue Swirl  --gcov=*) gcov_tool="$optarg"
6261d728c39SBlue Swirl  ;;
627e2d8830eSBrad  --smbd=*) smbd="$optarg"
628e2d8830eSBrad  ;;
629e2a2ed06SJuan Quintela  --extra-cflags=*)
6307d13299dSbellard  ;;
631e2a2ed06SJuan Quintela  --extra-ldflags=*)
6327d13299dSbellard  ;;
6335bc62e01SGerd Hoffmann  --enable-debug-info)
6345bc62e01SGerd Hoffmann  ;;
6355bc62e01SGerd Hoffmann  --disable-debug-info)
6365bc62e01SGerd Hoffmann  ;;
6372ff6b91eSJuan Quintela  --cpu=*)
6387d13299dSbellard  ;;
639b1a550a0Spbrook  --target-list=*) target_list="$optarg"
640de83cd02Sbellard  ;;
64174242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
64294a420b1SStefan Hajnoczi  ;;
64374242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6449410b56cSPrerna Saxena  ;;
6457d13299dSbellard  --enable-gprof) gprof="yes"
6467d13299dSbellard  ;;
6471d728c39SBlue Swirl  --enable-gcov) gcov="yes"
6481d728c39SBlue Swirl  ;;
64979427693SLoïc Minier  --static)
65079427693SLoïc Minier    static="yes"
65179427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
65217884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
65343ce4dfeSbellard  ;;
6540b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6550b24e75fSPaolo Bonzini  ;;
6560b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
6570b24e75fSPaolo Bonzini  ;;
6583aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
6593aa5d2beSAlon Levy  ;;
6608bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
6618bf188aaSMichael Tokarev  ;;
6620f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
6630f94d6daSAlon Levy  ;;
664528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
6650b24e75fSPaolo Bonzini  ;;
666023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
667023d3d67SEduardo Habkost  ;;
668850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
6690b24e75fSPaolo Bonzini  ;;
670ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
67107381cc1SAnthony Liguori  ;;
672785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
673785c23aeSLuiz Capitulino  ;;
674785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
675023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
676023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
677023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
678023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
679023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
680023ddd74SMax Filippov    # lots of directory switches by default.
681023ddd74SMax Filippov  ;;
682e2134eb9SGerd Hoffmann  --with-system-pixman) pixman="system"
683e2134eb9SGerd Hoffmann  ;;
684e2134eb9SGerd Hoffmann  --without-system-pixman) pixman="internal"
685e2134eb9SGerd Hoffmann  ;;
68674880fe2SRobert Schiele  --without-pixman) pixman="none"
68774880fe2SRobert Schiele  ;;
68897a847bcSbellard  --disable-sdl) sdl="no"
68997a847bcSbellard  ;;
690c4198157SJuan Quintela  --enable-sdl) sdl="yes"
691c4198157SJuan Quintela  ;;
6923556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
6933556c233SPaolo Bonzini  ;;
6943556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
6953556c233SPaolo Bonzini  ;;
696983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
697983eef5aSMeador Inge  ;;
698983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
699983eef5aSMeador Inge  ;;
700821601eaSJes Sorensen  --disable-vnc) vnc="no"
701821601eaSJes Sorensen  ;;
702821601eaSJes Sorensen  --enable-vnc) vnc="yes"
703821601eaSJes Sorensen  ;;
704b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
705102a52e4Sbellard  ;;
706c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
707c2de5c91Smalc  ;;
7082f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
7092f6a1ab0Sblueswir1  ;;
7100c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
7110c58ac1cSmalc  ;;
712eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
713eb852011SMarkus Armbruster  ;;
714f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
715f8393946Saurel32  ;;
716f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
717f8393946Saurel32  ;;
718f3d08ee6SPaul Brook  --enable-debug)
719f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
720f3d08ee6SPaul Brook      debug_tcg="yes"
721f3d08ee6SPaul Brook      debug="yes"
722f3d08ee6SPaul Brook      strip_opt="no"
723f3d08ee6SPaul Brook  ;;
72403b4fe7dSaliguori  --enable-sparse) sparse="yes"
72503b4fe7dSaliguori  ;;
72603b4fe7dSaliguori  --disable-sparse) sparse="no"
72703b4fe7dSaliguori  ;;
7281625af87Saliguori  --disable-strip) strip_opt="no"
7291625af87Saliguori  ;;
7308d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
7318d5d2d4cSths  ;;
7321be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
7331be10ad2SJuan Quintela  ;;
7342f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
7352f9606b3Saliguori  ;;
736ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
737ea784e3bSJuan Quintela  ;;
7382f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
7392f6f5c7aSCorentin Chary  ;;
7402f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
7412f6f5c7aSCorentin Chary  ;;
742efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
743efe556adSCorentin Chary  ;;
744efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
745efe556adSCorentin Chary  ;;
7467536ee4bSTim Hardeck  --disable-vnc-ws) vnc_ws="no"
7477536ee4bSTim Hardeck  ;;
7487536ee4bSTim Hardeck  --enable-vnc-ws) vnc_ws="yes"
7497536ee4bSTim Hardeck  ;;
750443f1376Sbellard  --disable-slirp) slirp="no"
751c20709aaSbellard  ;;
752ee682d27SStefan Weil  --disable-uuid) uuid="no"
753ee682d27SStefan Weil  ;;
754ee682d27SStefan Weil  --enable-uuid) uuid="yes"
755ee682d27SStefan Weil  ;;
756e0e6c8c0Saliguori  --disable-vde) vde="no"
7578a16d273Sths  ;;
758dfb278bdSJuan Quintela  --enable-vde) vde="yes"
759dfb278bdSJuan Quintela  ;;
760e37630caSaliguori  --disable-xen) xen="no"
761e37630caSaliguori  ;;
762fc321b4bSJuan Quintela  --enable-xen) xen="yes"
763fc321b4bSJuan Quintela  ;;
764eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
765eb6fda0fSAnthony PERARD  ;;
766eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
767eb6fda0fSAnthony PERARD  ;;
7682e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
7692e4d9fb1Saurel32  ;;
7704ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
7714ffcedb6SJuan Quintela  ;;
772fb599c9aSbalrog  --disable-bluez) bluez="no"
773fb599c9aSbalrog  ;;
774a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
775a20a6f46SJuan Quintela  ;;
7767ba1e619Saliguori  --disable-kvm) kvm="no"
7777ba1e619Saliguori  ;;
778b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
779b31a0277SJuan Quintela  ;;
7809195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
7819195b2c2SStefan Weil  ;;
7829195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
7839195b2c2SStefan Weil  ;;
78447e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
78547e98658SCorey Bryant  ;;
78647e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
78747e98658SCorey Bryant  ;;
788cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
789cd4ec0b4SGerd Hoffmann  ;;
790cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
791cd4ec0b4SGerd Hoffmann  ;;
792c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
793c589b249SRonnie Sahlberg  ;;
794c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
795c589b249SRonnie Sahlberg  ;;
79605c2a3e7Sbellard  --enable-profiler) profiler="yes"
79705c2a3e7Sbellard  ;;
79814821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
79914821030SPavel Borzenkov  ;;
800c2de5c91Smalc  --enable-cocoa)
801c2de5c91Smalc      cocoa="yes" ;
802c2de5c91Smalc      sdl="no" ;
803c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
8045b0753e0Sbellard  ;;
805cad25d69Spbrook  --disable-system) softmmu="no"
8060a8e90f4Spbrook  ;;
807cad25d69Spbrook  --enable-system) softmmu="yes"
8080a8e90f4Spbrook  ;;
8090953a80fSZachary Amsden  --disable-user)
8100953a80fSZachary Amsden      linux_user="no" ;
8110953a80fSZachary Amsden      bsd_user="no" ;
8120953a80fSZachary Amsden  ;;
8130953a80fSZachary Amsden  --enable-user) ;;
814831b7825Sths  --disable-linux-user) linux_user="no"
8150a8e90f4Spbrook  ;;
816831b7825Sths  --enable-linux-user) linux_user="yes"
817831b7825Sths  ;;
81884778508Sblueswir1  --disable-bsd-user) bsd_user="no"
81984778508Sblueswir1  ;;
82084778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
82184778508Sblueswir1  ;;
822379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
823379f6698SPaul Brook  ;;
824379f6698SPaul Brook  --disable-guest-base) guest_base="no"
825379f6698SPaul Brook  ;;
82640d6444eSAvi Kivity  --enable-pie) pie="yes"
82734005a00SKirill A. Shutemov  ;;
82840d6444eSAvi Kivity  --disable-pie) pie="no"
82934005a00SKirill A. Shutemov  ;;
830c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
831c5937220Spbrook  ;;
83285aa5189Sbellard  --enable-werror) werror="yes"
83385aa5189Sbellard  ;;
83485aa5189Sbellard  --disable-werror) werror="no"
83585aa5189Sbellard  ;;
8364d3b6f6eSbalrog  --disable-curses) curses="no"
8374d3b6f6eSbalrog  ;;
838c584a6d0SJuan Quintela  --enable-curses) curses="yes"
839c584a6d0SJuan Quintela  ;;
840769ce76dSAlexander Graf  --disable-curl) curl="no"
841769ce76dSAlexander Graf  ;;
842788c8196SJuan Quintela  --enable-curl) curl="yes"
843788c8196SJuan Quintela  ;;
8442df87df7SJuan Quintela  --disable-fdt) fdt="no"
8452df87df7SJuan Quintela  ;;
8462df87df7SJuan Quintela  --enable-fdt) fdt="yes"
8472df87df7SJuan Quintela  ;;
848bd0c5661Spbrook  --disable-nptl) nptl="no"
849bd0c5661Spbrook  ;;
850b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
851b0a47e79SJuan Quintela  ;;
8528ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
8538ff9cbf7Smalc  ;;
8545c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
8555c6c3a6cSChristoph Hellwig  ;;
8565c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
8575c6c3a6cSChristoph Hellwig  ;;
858758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
859758e8e38SVenkateswararao Jujjuri (JV)  ;;
860758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
861758e8e38SVenkateswararao Jujjuri (JV)  ;;
86277755340Sths  --disable-blobs) blobs="no"
86377755340Sths  ;;
8644a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
8654a19f1ecSpbrook  ;;
866519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
867519175a2SAlex Barcelo  ;;
868a25dba17SJuan Quintela  --disable-docs) docs="no"
86970ec5dc0SAnthony Liguori  ;;
870a25dba17SJuan Quintela  --enable-docs) docs="yes"
87183a3ab8bSJuan Quintela  ;;
872d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
873d5970055SMichael S. Tsirkin  ;;
874d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
875d5970055SMichael S. Tsirkin  ;;
8765e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
8775e9be92dSNicholas Bellinger  ;;
8785e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
8795e9be92dSNicholas Bellinger  ;;
880b1e5fff4SMichael Walle  --disable-glx) glx="no"
88120ff075bSMichael Walle  ;;
882b1e5fff4SMichael Walle  --enable-glx) glx="yes"
88320ff075bSMichael Walle  ;;
884f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
885f27aaf4bSChristian Brunner  ;;
886f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
887f27aaf4bSChristian Brunner  ;;
8888c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
8898c84cf11SSergei Trofimovich  ;;
8908c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
8918c84cf11SSergei Trofimovich  ;;
892111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
893111a38b0SRobert Relyea  ;;
894111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
895111a38b0SRobert Relyea  ;;
8962b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
8972b2325ffSGerd Hoffmann  ;;
8982b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
8992b2325ffSGerd Hoffmann  ;;
90069354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
90169354a83SHans de Goede  ;;
90269354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
90369354a83SHans de Goede  ;;
9041ece9905SAlon Levy  --disable-zlib-test) zlib="no"
9051ece9905SAlon Levy  ;;
906d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
907d138cee9SMichael Roth  ;;
908d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
909d138cee9SMichael Roth  ;;
9104b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
9114b1c11fdSDaniel P. Berrange  ;;
9124b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
9134b1c11fdSDaniel P. Berrange  ;;
914f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
915f794573eSEduardo Otubo  ;;
916f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
917f794573eSEduardo Otubo  ;;
918eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
919eb100396SBharata B Rao  ;;
920eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
921eb100396SBharata B Rao  ;;
922583f6e7bSStefan Hajnoczi  --disable-virtio-blk-data-plane) virtio_blk_data_plane="no"
923583f6e7bSStefan Hajnoczi  ;;
924583f6e7bSStefan Hajnoczi  --enable-virtio-blk-data-plane) virtio_blk_data_plane="yes"
925583f6e7bSStefan Hajnoczi  ;;
926a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
927a4ccabcfSAnthony Liguori  ;;
928a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
929a4ccabcfSAnthony Liguori  ;;
930528de90aSDaniel P. Berrange  --with-gtkabi=*) gtkabi="$optarg"
931528de90aSDaniel P. Berrange  ;;
932ab214c29SStefan Berger  --enable-tpm) tpm="yes"
933ab214c29SStefan Berger  ;;
9340a12ec87SRichard W.M. Jones  --disable-libssh2) libssh2="no"
9350a12ec87SRichard W.M. Jones  ;;
9360a12ec87SRichard W.M. Jones  --enable-libssh2) libssh2="yes"
9370a12ec87SRichard W.M. Jones  ;;
9387f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
9397f1559c6Sbalrog  ;;
9407d13299dSbellard  esac
9417d13299dSbellarddone
9427d13299dSbellard
94340293e58Sbellardcase "$cpu" in
9449b9c37c3SRichard Henderson    sparc)
9450c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
94679f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32 -mcpu=ultrasparc"
9473142255cSblueswir1           ;;
948ed968ff1SJuan Quintela    sparc64)
9490c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
95079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
9513142255cSblueswir1           ;;
95276d83bdeSths    s390)
95379f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m31 -march=z990"
95428d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
95528d7cc49SRichard Henderson           ;;
95628d7cc49SRichard Henderson    s390x)
95779f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -march=z990"
95828d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
95976d83bdeSths           ;;
96040293e58Sbellard    i386)
96179f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
9620c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
9632b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
96440293e58Sbellard           ;;
96540293e58Sbellard    x86_64)
96679f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64"
9670c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
9682b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
969379f6698SPaul Brook           ;;
97030163d89SPeter Maydell    # No special flags required for other host CPUs
9713142255cSblueswir1esac
9723142255cSblueswir1
97379f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
97479f3b12fSPeter CrosthwaiteEXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
97579f3b12fSPeter Crosthwaite
97660e0df25SPeter Maydelldefault_target_list=""
97760e0df25SPeter Maydell
97860e0df25SPeter Maydell# these targets are portable
97960e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
98060e0df25SPeter Maydell    default_target_list="\
98160e0df25SPeter Maydelli386-softmmu \
98260e0df25SPeter Maydellx86_64-softmmu \
98327cdad67SRichard Hendersonalpha-softmmu \
98460e0df25SPeter Maydellarm-softmmu \
98560e0df25SPeter Maydellcris-softmmu \
98660e0df25SPeter Maydelllm32-softmmu \
98760e0df25SPeter Maydellm68k-softmmu \
98860e0df25SPeter Maydellmicroblaze-softmmu \
98960e0df25SPeter Maydellmicroblazeel-softmmu \
99060e0df25SPeter Maydellmips-softmmu \
99160e0df25SPeter Maydellmipsel-softmmu \
99260e0df25SPeter Maydellmips64-softmmu \
99360e0df25SPeter Maydellmips64el-softmmu \
994d15a9c23SAnthony Greenmoxie-softmmu \
995e67db06eSJia Liuor32-softmmu \
99660e0df25SPeter Maydellppc-softmmu \
99760e0df25SPeter Maydellppcemb-softmmu \
99860e0df25SPeter Maydellppc64-softmmu \
99960e0df25SPeter Maydellsh4-softmmu \
100060e0df25SPeter Maydellsh4eb-softmmu \
100160e0df25SPeter Maydellsparc-softmmu \
100260e0df25SPeter Maydellsparc64-softmmu \
10030f3301d4SAlexander Grafs390x-softmmu \
1004cfa550c6SMax Filippovxtensa-softmmu \
1005cfa550c6SMax Filippovxtensaeb-softmmu \
10064f23a1e6SGuan Xuetaounicore32-softmmu \
100760e0df25SPeter Maydell"
100860e0df25SPeter Maydellfi
100960e0df25SPeter Maydell# the following are Linux specific
101060e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
101160e0df25SPeter Maydell    default_target_list="${default_target_list}\
101260e0df25SPeter Maydelli386-linux-user \
101360e0df25SPeter Maydellx86_64-linux-user \
101460e0df25SPeter Maydellalpha-linux-user \
101560e0df25SPeter Maydellarm-linux-user \
101660e0df25SPeter Maydellarmeb-linux-user \
101760e0df25SPeter Maydellcris-linux-user \
101860e0df25SPeter Maydellm68k-linux-user \
101960e0df25SPeter Maydellmicroblaze-linux-user \
102060e0df25SPeter Maydellmicroblazeel-linux-user \
102160e0df25SPeter Maydellmips-linux-user \
102260e0df25SPeter Maydellmipsel-linux-user \
102351cd14d3SRichard Hendersonmips64-linux-user \
102451cd14d3SRichard Hendersonmips64el-linux-user \
102551cd14d3SRichard Hendersonmipsn32-linux-user \
102651cd14d3SRichard Hendersonmipsn32el-linux-user \
1027d962783eSJia Liuor32-linux-user \
102860e0df25SPeter Maydellppc-linux-user \
102960e0df25SPeter Maydellppc64-linux-user \
103060e0df25SPeter Maydellppc64abi32-linux-user \
103160e0df25SPeter Maydellsh4-linux-user \
103260e0df25SPeter Maydellsh4eb-linux-user \
103360e0df25SPeter Maydellsparc-linux-user \
103460e0df25SPeter Maydellsparc64-linux-user \
103560e0df25SPeter Maydellsparc32plus-linux-user \
103660e0df25SPeter Maydellunicore32-linux-user \
10370f3301d4SAlexander Grafs390x-linux-user \
103860e0df25SPeter Maydell"
103960e0df25SPeter Maydellfi
104060e0df25SPeter Maydell# the following are BSD specific
104160e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
104260e0df25SPeter Maydell    default_target_list="${default_target_list}\
104360e0df25SPeter Maydelli386-bsd-user \
104460e0df25SPeter Maydellx86_64-bsd-user \
104560e0df25SPeter Maydellsparc-bsd-user \
104660e0df25SPeter Maydellsparc64-bsd-user \
104760e0df25SPeter Maydell"
104860e0df25SPeter Maydellfi
104960e0df25SPeter Maydell
1050af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1051af5db58eSpbrookcat << EOF
1052af5db58eSpbrook
1053af5db58eSpbrookUsage: configure [options]
1054af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1055af5db58eSpbrook
1056af5db58eSpbrookEOF
1057af5db58eSpbrookecho "Standard options:"
1058af5db58eSpbrookecho "  --help                   print this message"
1059af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
1060af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
1061af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
106260e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
106360e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
106460e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
1065af5db58eSpbrookecho ""
1066af5db58eSpbrookecho "Advanced options (experts only):"
1067af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
1068af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
1069af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
10700bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
10710bfe8cc0SPaolo Bonziniecho "                           build time"
10723c4a4d0dSPeter Maydellecho "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
1073a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
1074e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
1075af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
10766a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
1077c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
1078e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
1079af5db58eSpbrookecho "  --static                 enable static build [$static]"
10800b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
1081023d3d67SEduardo Habkostecho "  --datadir=PATH           install firmware in PATH$confsuffix"
1082023d3d67SEduardo Habkostecho "  --docdir=PATH            install documentation in PATH$confsuffix"
10830b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
1084a7b66fa7SDoug Goldsteinecho "  --libdir=PATH            install libraries in PATH"
1085023d3d67SEduardo Habkostecho "  --sysconfdir=PATH        install config in PATH$confsuffix"
1086785c23aeSLuiz Capitulinoecho "  --localstatedir=PATH     install local state in PATH"
10872ae4748fSStefan Weilecho "  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1088f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
1089f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
10909941afdeSDunrong Huangecho "  --enable-debug-info       enable debugging information (default)"
10919941afdeSDunrong Huangecho "  --disable-debug-info      disable debugging information"
109209695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
1093890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
1094890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
10951625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
109685aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
1097fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
1098c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
1099ab400449SHu Taoecho "  --disable-gtk            disable gtk UI"
1100ab400449SHu Taoecho "  --enable-gtk             enable gtk UI"
1101983eef5aSMeador Ingeecho "  --disable-virtfs         disable VirtFS"
1102983eef5aSMeador Ingeecho "  --enable-virtfs          enable VirtFS"
1103821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
1104821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
110514821030SPavel Borzenkovecho "  --disable-cocoa          disable Cocoa (Mac OS X only)"
110614821030SPavel Borzenkovecho "  --enable-cocoa           enable Cocoa (default on Mac OS X)"
1107c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
1108c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
1109eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
1110eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
11118ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
1112e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
1113fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
1114eb6fda0fSAnthony PERARDecho "  --disable-xen-pci-passthrough"
1115eb6fda0fSAnthony PERARDecho "  --enable-xen-pci-passthrough"
11162e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
11174ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
11188d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
11191be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
11202f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1121ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
11222f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
11232f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
112496763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1125efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
11267536ee4bSTim Hardeckecho "  --disable-vnc-ws         disable Websockets support for VNC server"
11277536ee4bSTim Hardeckecho "  --enable-vnc-ws          enable Websockets support for VNC server"
1128af896aaaSpbrookecho "  --disable-curses         disable curses output"
1129c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1130769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1131788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
11322df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
11332df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
1134fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1135a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
11366093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
11377ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1138b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
11399195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1140bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
1141e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
1142af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1143af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
11440953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
11450953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1146831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1147831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
114884778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
114984778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1150379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1151379f6698SPaul Brookecho "                           emulation targets"
1152379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
115340d6444eSAvi Kivityecho "  --enable-pie             build Position Independent Executables"
115440d6444eSAvi Kivityecho "  --disable-pie            do not build Position Independent Executables"
1155af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1156af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
11572f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1158c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1159235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
1160ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1161ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1162e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1163dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
11645c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
11655c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
116647e98658SCorey Bryantecho "  --disable-cap-ng         disable libcap-ng support"
116747e98658SCorey Bryantecho "  --enable-cap-ng          enable libcap-ng support"
1168758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1169758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
117077755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1171d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1172d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1173d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1174d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1175320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1176650ab98dSLluís Vilanovaecho "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
117774242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
11789410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1179cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1180cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1181f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1182c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1183c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
1184111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1185111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
11862b2325ffSGerd Hoffmannecho "  --disable-libusb         disable libusb (for usb passthrough)"
11872b2325ffSGerd Hoffmannecho "  --enable-libusb          enable libusb (for usb passthrough)"
118869354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
118969354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1190d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1191d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1192f794573eSEduardo Otuboecho "  --disable-seccomp        disable seccomp support"
1193f794573eSEduardo Otuboecho "  --enable-seccomp         enables seccomp support"
1194519175a2SAlex Barceloecho "  --with-coroutine=BACKEND coroutine backend. Supported options:"
1195fe91bfa8SAlex Barceloecho "                           gthread, ucontext, sigaltstack, windows"
1196eb100396SBharata B Raoecho "  --enable-glusterfs       enable GlusterFS backend"
1197eb100396SBharata B Raoecho "  --disable-glusterfs      disable GlusterFS backend"
11981d728c39SBlue Swirlecho "  --enable-gcov            enable test coverage analysis with gcov"
11991d728c39SBlue Swirlecho "  --gcov=GCOV              use specified gcov [$gcov_tool]"
1200ab214c29SStefan Bergerecho "  --enable-tpm             enable TPM support"
12010a12ec87SRichard W.M. Jonesecho "  --disable-libssh2        disable ssh block device support"
12020a12ec87SRichard W.M. Jonesecho "  --enable-libssh2         enable ssh block device support"
1203af5db58eSpbrookecho ""
12045bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1205af5db58eSpbrookexit 1
1206af5db58eSpbrookfi
1207af5db58eSpbrook
1208359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1209359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1210359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1211359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1212359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1213359bc95dSPeter Maydell        ARCH=tci
1214359bc95dSPeter Maydell    else
121576ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1216359bc95dSPeter Maydell    fi
1217359bc95dSPeter Maydellfi
1218359bc95dSPeter Maydell
12198d05095cSPaolo Bonzini# check that the C compiler works.
12208d05095cSPaolo Bonzinicat > $TMPC <<EOF
122175cafad7SStefan Weilint main(void) { return 0; }
12228d05095cSPaolo BonziniEOF
12238d05095cSPaolo Bonzini
12248d05095cSPaolo Bonziniif compile_object ; then
12258d05095cSPaolo Bonzini  : C compiler works ok
12268d05095cSPaolo Bonzinielse
122776ad07a4SPeter Maydell    error_exit "\"$cc\" either does not exist or does not work"
12288d05095cSPaolo Bonzinifi
12298d05095cSPaolo Bonzini
1230417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1231417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1232417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1233417c9d72SAlexander Graf
1234417c9d72SAlexander Grafif test -z "$werror" ; then
12356c8fec83SAndreas Färber    if test -d "$source_path/.git" -a \
1236417c9d72SAlexander Graf        "$linux" = "yes" ; then
1237417c9d72SAlexander Graf        werror="yes"
1238417c9d72SAlexander Graf    else
1239417c9d72SAlexander Graf        werror="no"
1240417c9d72SAlexander Graf    fi
1241417c9d72SAlexander Graffi
1242417c9d72SAlexander Graf
12438d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
12448d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
12458d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
124637746c5eSMarc-André Lureaugcc_flags="-Wendif-labels $gcc_flags"
1247c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
12486ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
12496ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
12506ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
12516ca026cbSPeter Maydell# so it's too error prone.
12528d05095cSPaolo Bonzinicat > $TMPC << EOF
12538d05095cSPaolo Bonziniint main(void) { return 0; }
12548d05095cSPaolo BonziniEOF
12558d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1256a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1257a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1258a1d29d6cSPeter Maydell    # warning options).
1259a1d29d6cSPeter Maydell    optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1260a1d29d6cSPeter Maydell    if compile_prog "-Werror $optflag" "" ; then
12618d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
12628d05095cSPaolo Bonzini    fi
12638d05095cSPaolo Bonzinidone
12648d05095cSPaolo Bonzini
126537746c5eSMarc-André Lureauif compile_prog "-Werror -fstack-protector-all" "" ; then
126637746c5eSMarc-André Lureau    QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
126737746c5eSMarc-André Lureau    LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
126837746c5eSMarc-André Lureaufi
126937746c5eSMarc-André Lureau
1270cbdd1999SPaolo Bonzini# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
1271cbdd1999SPaolo Bonzini# large functions that use global variables.  The bug is in all releases of
1272cbdd1999SPaolo Bonzini# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
1273cbdd1999SPaolo Bonzini# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
1274cbdd1999SPaolo Bonzinicat > $TMPC << EOF
1275cbdd1999SPaolo Bonzini#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1276cbdd1999SPaolo Bonziniint main(void) { return 0; }
1277cbdd1999SPaolo Bonzini#else
1278cbdd1999SPaolo Bonzini#error No bug in this compiler.
1279cbdd1999SPaolo Bonzini#endif
1280cbdd1999SPaolo BonziniEOF
1281cbdd1999SPaolo Bonziniif compile_prog "-Werror -fno-gcse" "" ; then
1282cbdd1999SPaolo Bonzini  TRANSLATE_OPT_CFLAGS=-fno-gcse
1283cbdd1999SPaolo Bonzinifi
1284cbdd1999SPaolo Bonzini
128540d6444eSAvi Kivityif test "$static" = "yes" ; then
128640d6444eSAvi Kivity  if test "$pie" = "yes" ; then
128776ad07a4SPeter Maydell    error_exit "static and pie are mutually incompatible"
128840d6444eSAvi Kivity  else
128940d6444eSAvi Kivity    pie="no"
129040d6444eSAvi Kivity  fi
129140d6444eSAvi Kivityfi
129240d6444eSAvi Kivity
129340d6444eSAvi Kivityif test "$pie" = ""; then
129440d6444eSAvi Kivity  case "$cpu-$targetos" in
1295f9db31a2SBrad    i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD)
129640d6444eSAvi Kivity      ;;
129740d6444eSAvi Kivity    *)
129840d6444eSAvi Kivity      pie="no"
129940d6444eSAvi Kivity      ;;
130040d6444eSAvi Kivity  esac
130140d6444eSAvi Kivityfi
130240d6444eSAvi Kivity
130340d6444eSAvi Kivityif test "$pie" != "no" ; then
130440d6444eSAvi Kivity  cat > $TMPC << EOF
130521d4a791SAvi Kivity
130621d4a791SAvi Kivity#ifdef __linux__
130721d4a791SAvi Kivity#  define THREAD __thread
130821d4a791SAvi Kivity#else
130921d4a791SAvi Kivity#  define THREAD
131021d4a791SAvi Kivity#endif
131121d4a791SAvi Kivity
131221d4a791SAvi Kivitystatic THREAD int tls_var;
131321d4a791SAvi Kivity
131421d4a791SAvi Kivityint main(void) { return tls_var; }
131521d4a791SAvi Kivity
131640d6444eSAvi KivityEOF
131740d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
131840d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
131940d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
132040d6444eSAvi Kivity    pie="yes"
132140d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
132240d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
132340d6444eSAvi Kivity    fi
132440d6444eSAvi Kivity  else
132540d6444eSAvi Kivity    if test "$pie" = "yes"; then
132676ad07a4SPeter Maydell      error_exit "PIE not available due to missing toolchain support"
132740d6444eSAvi Kivity    else
132840d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
132940d6444eSAvi Kivity      pie="no"
133040d6444eSAvi Kivity    fi
133140d6444eSAvi Kivity  fi
133240d6444eSAvi Kivityfi
133340d6444eSAvi Kivity
133409dada40SPaolo Bonzini##########################################
133509dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
133609dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
133709dada40SPaolo Bonzini# specification is necessary
133809dada40SPaolo Bonzini
133909dada40SPaolo Bonziniif test "$cpu" = "i386"; then
134009dada40SPaolo Bonzini  cat > $TMPC << EOF
134109dada40SPaolo Bonzinistatic int sfaa(int *ptr)
134209dada40SPaolo Bonzini{
134309dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
134409dada40SPaolo Bonzini}
134509dada40SPaolo Bonzini
134609dada40SPaolo Bonziniint main(void)
134709dada40SPaolo Bonzini{
134809dada40SPaolo Bonzini  int val = 42;
1349*1405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
135009dada40SPaolo Bonzini  sfaa(&val);
135109dada40SPaolo Bonzini  return val;
135209dada40SPaolo Bonzini}
135309dada40SPaolo BonziniEOF
135409dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
135509dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
135609dada40SPaolo Bonzini  fi
135709dada40SPaolo Bonzinifi
135809dada40SPaolo Bonzini
135909dada40SPaolo Bonzini#########################################
1360ec530c81Sbellard# Solaris specific configure tool chain decisions
136109dada40SPaolo Bonzini
1362ec530c81Sbellardif test "$solaris" = "yes" ; then
13636792aa11SLoïc Minier  if has $install; then
13646792aa11SLoïc Minier    :
13656792aa11SLoïc Minier  else
136676ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
136776ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
136876ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1369ec530c81Sbellard  fi
13706792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
137176ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
137276ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
137376ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1374ec530c81Sbellard  fi
13756792aa11SLoïc Minier  if has ar; then
13766792aa11SLoïc Minier    :
13776792aa11SLoïc Minier  else
1378ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
137976ad07a4SPeter Maydell      error_exit "No path includes ar" \
138076ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
1381ec530c81Sbellard    fi
138276ad07a4SPeter Maydell    error_exit "No path includes ar"
1383ec530c81Sbellard  fi
1384ec530c81Sbellardfi
1385ec530c81Sbellard
13867a3fc891SSebastian Herbsztif ! has $python; then
138776ad07a4SPeter Maydell  error_exit "Python not found. Use --python=/path/to/python"
1388c886edfbSBlue Swirlfi
1389c886edfbSBlue Swirl
13906ccea1e4SPeter Maydell# Note that if the Python conditional here evaluates True we will exit
13916ccea1e4SPeter Maydell# with status 1 which is a shell 'false' value.
1392e120d449SStefan Hajnocziif ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
139376ad07a4SPeter Maydell  error_exit "Cannot use '$python', Python 2.4 or later is required." \
139476ad07a4SPeter Maydell      "Note that Python 3 or later is not yet supported." \
139576ad07a4SPeter Maydell      "Use --python=/path/to/python to specify a supported Python."
13966ccea1e4SPeter Maydellfi
13976ccea1e4SPeter Maydell
1398afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1399121afa9eSAnthony Liguori    target_list="$default_target_list"
1400121afa9eSAnthony Liguorielse
1401121afa9eSAnthony Liguori    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
14025327cf48Sbellardfi
1403f55fe278SPaolo Bonzini# see if system emulation was really requested
1404f55fe278SPaolo Bonzinicase " $target_list " in
1405f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1406f55fe278SPaolo Bonzini  ;;
1407f55fe278SPaolo Bonzini  *) softmmu=no
1408f55fe278SPaolo Bonzini  ;;
1409f55fe278SPaolo Bonziniesac
14105327cf48Sbellard
1411249247c9SJuan Quintelafeature_not_found() {
1412249247c9SJuan Quintela  feature=$1
1413249247c9SJuan Quintela
141476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
141576ad07a4SPeter Maydell      "configure was not able to find it"
1416249247c9SJuan Quintela}
1417249247c9SJuan Quintela
14187d13299dSbellardif test -z "$cross_prefix" ; then
14197d13299dSbellard
14207d13299dSbellard# ---
14217d13299dSbellard# big/little endian test
14227d13299dSbellardcat > $TMPC << EOF
14237d13299dSbellard#include <inttypes.h>
1424abab1a0fSStefan Weilint main(void) {
14257d13299dSbellard        volatile uint32_t i=0x01234567;
14267d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
14277d13299dSbellard}
14287d13299dSbellardEOF
14297d13299dSbellard
143052166aa0SJuan Quintelaif compile_prog "" "" ; then
14317d13299dSbellard$TMPE && bigendian="yes"
14327d13299dSbellardelse
14337d13299dSbellardecho big/little test failed
14347d13299dSbellardfi
14357d13299dSbellard
14367d13299dSbellardelse
14377d13299dSbellard
14387d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1439ea8f20f8SJuan Quintelacase "$cpu" in
144021d89f84SPeter Maydell  arm)
144121d89f84SPeter Maydell    # ARM can be either way; ask the compiler which one we are
144221d89f84SPeter Maydell    if check_define __ARMEB__; then
144321d89f84SPeter Maydell      bigendian=yes
144421d89f84SPeter Maydell    fi
144521d89f84SPeter Maydell  ;;
144621d89f84SPeter Maydell  hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1447ea8f20f8SJuan Quintela    bigendian=yes
1448ea8f20f8SJuan Quintela  ;;
1449ea8f20f8SJuan Quintelaesac
14507d13299dSbellard
14517d13299dSbellardfi
14527d13299dSbellard
1453b0a47e79SJuan Quintela##########################################
1454779ab5e3SStefan Weil# pkg-config probe
1455779ab5e3SStefan Weil
1456779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
145776ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1458779ab5e3SStefan Weilfi
1459779ab5e3SStefan Weil
1460779ab5e3SStefan Weil##########################################
1461b0a47e79SJuan Quintela# NPTL probe
1462b0a47e79SJuan Quintela
1463b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1464bd0c5661Spbrook  cat > $TMPC <<EOF
1465bd0c5661Spbrook#include <sched.h>
146630813ceaSpbrook#include <linux/futex.h>
1467182eacc0SStefan Weilint main(void) {
1468bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1469bd0c5661Spbrook#error bork
1470bd0c5661Spbrook#endif
1471182eacc0SStefan Weil  return 0;
1472bd0c5661Spbrook}
1473bd0c5661SpbrookEOF
1474bd0c5661Spbrook
147552166aa0SJuan Quintela  if compile_object ; then
1476b0a47e79SJuan Quintela    nptl=yes
1477bd0c5661Spbrook  else
1478b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1479b0a47e79SJuan Quintela      feature_not_found "nptl"
1480b0a47e79SJuan Quintela    fi
1481b0a47e79SJuan Quintela    nptl=no
1482b0a47e79SJuan Quintela  fi
1483bd0c5661Spbrookfi
1484bd0c5661Spbrook
148511d9f695Sbellard##########################################
1486ac62922eSbalrog# zlib check
1487ac62922eSbalrog
14881ece9905SAlon Levyif test "$zlib" != "no" ; then
1489ac62922eSbalrog    cat > $TMPC << EOF
1490ac62922eSbalrog#include <zlib.h>
1491ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1492ac62922eSbalrogEOF
149352166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1494ac62922eSbalrog        :
1495ac62922eSbalrog    else
149676ad07a4SPeter Maydell        error_exit "zlib check failed" \
149776ad07a4SPeter Maydell            "Make sure to have the zlib libs and headers installed."
1498ac62922eSbalrog    fi
14991ece9905SAlon Levyfi
1500f544a488SPaolo Bonzinilibs_softmmu="$libs_softmmu -lz"
1501ac62922eSbalrog
1502ac62922eSbalrog##########################################
1503f794573eSEduardo Otubo# libseccomp check
1504f794573eSEduardo Otubo
1505f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
15062c5c4451SBlue Swirl    if $pkg_config --atleast-version=1.0.0 libseccomp --modversion >/dev/null 2>&1; then
1507b4451996SMichael Tokarev        libs_softmmu="$libs_softmmu `$pkg_config --libs libseccomp`"
1508372e47e9SAndreas Färber        QEMU_CFLAGS="$QEMU_CFLAGS `$pkg_config --cflags libseccomp`"
1509f794573eSEduardo Otubo	seccomp="yes"
1510f794573eSEduardo Otubo    else
1511f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
1512f794573eSEduardo Otubo            feature_not_found "libseccomp"
1513f794573eSEduardo Otubo	fi
1514e84d5956SYann E. MORIN	seccomp="no"
1515f794573eSEduardo Otubo    fi
1516f794573eSEduardo Otubofi
1517f794573eSEduardo Otubo##########################################
1518e37630caSaliguori# xen probe
1519e37630caSaliguori
1520fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1521b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1522d5b93ddfSAnthony PERARD
152350ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
152450ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
152550ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
152650ced5b3SStefan Weil
152750ced5b3SStefan Weil  # Xen (any)
152850ced5b3SStefan Weil  cat > $TMPC <<EOF
152950ced5b3SStefan Weil#include <xenctrl.h>
153050ced5b3SStefan Weilint main(void) {
153150ced5b3SStefan Weil  return 0;
153250ced5b3SStefan Weil}
153350ced5b3SStefan WeilEOF
153450ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
153550ced5b3SStefan Weil    # Xen not found
153650ced5b3SStefan Weil    if test "$xen" = "yes" ; then
153750ced5b3SStefan Weil      feature_not_found "xen"
153850ced5b3SStefan Weil    fi
153950ced5b3SStefan Weil    xen=no
154050ced5b3SStefan Weil
1541d5b93ddfSAnthony PERARD  # Xen unstable
154269deef08SPeter Maydell  elif
154369deef08SPeter Maydell      cat > $TMPC <<EOF &&
1544e37630caSaliguori#include <xenctrl.h>
1545e108a3c1SAnthony PERARD#include <xenstore.h>
1546d5b93ddfSAnthony PERARD#include <stdint.h>
1547d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1548d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1549d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1550d5b93ddfSAnthony PERARD#endif
1551d5b93ddfSAnthony PERARDint main(void) {
1552d5b93ddfSAnthony PERARD  xc_interface *xc;
1553d5b93ddfSAnthony PERARD  xs_daemon_open();
1554d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1555d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1556d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1557b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
15588688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
15598688e065SStefano Stabellini  return 0;
15608688e065SStefano Stabellini}
15618688e065SStefano StabelliniEOF
15628688e065SStefano Stabellini      compile_prog "" "$xen_libs"
156369deef08SPeter Maydell    then
15648688e065SStefano Stabellini    xen_ctrl_version=420
15658688e065SStefano Stabellini    xen=yes
15668688e065SStefano Stabellini
156769deef08SPeter Maydell  elif
156869deef08SPeter Maydell      cat > $TMPC <<EOF &&
15698688e065SStefano Stabellini#include <xenctrl.h>
15708688e065SStefano Stabellini#include <xs.h>
15718688e065SStefano Stabellini#include <stdint.h>
15728688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
15738688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
15748688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
15758688e065SStefano Stabellini#endif
15768688e065SStefano Stabelliniint main(void) {
15778688e065SStefano Stabellini  xs_daemon_open();
15789b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
15798688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
15808688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
15818688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1582d5b93ddfSAnthony PERARD  return 0;
1583d5b93ddfSAnthony PERARD}
1584e37630caSaliguoriEOF
158550ced5b3SStefan Weil      compile_prog "" "$xen_libs"
158669deef08SPeter Maydell    then
1587d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1588fc321b4bSJuan Quintela    xen=yes
1589d5b93ddfSAnthony PERARD
1590d5b93ddfSAnthony PERARD  # Xen 4.0.0
159169deef08SPeter Maydell  elif
159269deef08SPeter Maydell      cat > $TMPC <<EOF &&
1593d5b93ddfSAnthony PERARD#include <xenctrl.h>
1594d5b93ddfSAnthony PERARD#include <xs.h>
1595d5b93ddfSAnthony PERARD#include <stdint.h>
1596d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1597d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1598d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1599d5b93ddfSAnthony PERARD#endif
1600d5b93ddfSAnthony PERARDint main(void) {
1601b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1602b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1603b87de24eSAnthony PERARD  };
1604d5b93ddfSAnthony PERARD  xs_daemon_open();
1605d5b93ddfSAnthony PERARD  xc_interface_open();
1606d5b93ddfSAnthony PERARD  xc_gnttab_open();
1607d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1608b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1609d5b93ddfSAnthony PERARD  return 0;
1610d5b93ddfSAnthony PERARD}
1611d5b93ddfSAnthony PERARDEOF
1612d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
161369deef08SPeter Maydell    then
1614d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1615d5b93ddfSAnthony PERARD    xen=yes
1616d5b93ddfSAnthony PERARD
1617b87de24eSAnthony PERARD  # Xen 3.4.0
161869deef08SPeter Maydell  elif
161969deef08SPeter Maydell      cat > $TMPC <<EOF &&
1620b87de24eSAnthony PERARD#include <xenctrl.h>
1621b87de24eSAnthony PERARD#include <xs.h>
1622b87de24eSAnthony PERARDint main(void) {
1623b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1624b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1625b87de24eSAnthony PERARD  };
1626b87de24eSAnthony PERARD  xs_daemon_open();
1627b87de24eSAnthony PERARD  xc_interface_open();
1628b87de24eSAnthony PERARD  xc_gnttab_open();
1629b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1630b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1631b87de24eSAnthony PERARD  return 0;
1632b87de24eSAnthony PERARD}
1633b87de24eSAnthony PERARDEOF
1634b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
163569deef08SPeter Maydell    then
1636b87de24eSAnthony PERARD    xen_ctrl_version=340
1637b87de24eSAnthony PERARD    xen=yes
1638b87de24eSAnthony PERARD
1639b87de24eSAnthony PERARD  # Xen 3.3.0
164069deef08SPeter Maydell  elif
164169deef08SPeter Maydell      cat > $TMPC <<EOF &&
1642d5b93ddfSAnthony PERARD#include <xenctrl.h>
1643d5b93ddfSAnthony PERARD#include <xs.h>
1644d5b93ddfSAnthony PERARDint main(void) {
1645d5b93ddfSAnthony PERARD  xs_daemon_open();
1646d5b93ddfSAnthony PERARD  xc_interface_open();
1647d5b93ddfSAnthony PERARD  xc_gnttab_open();
1648d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1649d5b93ddfSAnthony PERARD  return 0;
1650d5b93ddfSAnthony PERARD}
1651d5b93ddfSAnthony PERARDEOF
1652d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
165369deef08SPeter Maydell    then
1654d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1655d5b93ddfSAnthony PERARD    xen=yes
1656d5b93ddfSAnthony PERARD
165750ced5b3SStefan Weil  # Xen version unsupported
1658e37630caSaliguori  else
1659fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
166050ced5b3SStefan Weil      feature_not_found "xen (unsupported version)"
1661fc321b4bSJuan Quintela    fi
1662fc321b4bSJuan Quintela    xen=no
1663e37630caSaliguori  fi
1664d5b93ddfSAnthony PERARD
1665d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1666d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1667d5b93ddfSAnthony PERARD  fi
1668e37630caSaliguorifi
1669e37630caSaliguori
1670eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1671eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1672eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1673eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1674eb6fda0fSAnthony PERARD  else
1675eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1676eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
167776ad07a4SPeter Maydell        error_exit "User requested feature Xen PCI Passthrough" \
167876ad07a4SPeter Maydell            "This feature does not work with Xen 3.3"
1679eb6fda0fSAnthony PERARD      fi
168076ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
168176ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
1682eb6fda0fSAnthony PERARD    fi
1683eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1684eb6fda0fSAnthony PERARD  fi
1685eb6fda0fSAnthony PERARDfi
1686eb6fda0fSAnthony PERARD
1687e37630caSaliguori##########################################
168844dc0ca3SAlon Levy# libtool probe
168944dc0ca3SAlon Levy
16903f534581SBradif ! has $libtool; then
169144dc0ca3SAlon Levy    libtool=
169244dc0ca3SAlon Levyfi
169344dc0ca3SAlon Levy
16948e515b12SPeter Maydell# MacOSX ships with a libtool which isn't the GNU one; weed this
16958e515b12SPeter Maydell# out by checking whether libtool supports the --version switch
16968e515b12SPeter Maydellif test -n "$libtool"; then
16978e515b12SPeter Maydell  if ! "$libtool" --version >/dev/null 2>&1; then
16988e515b12SPeter Maydell    libtool=
16998e515b12SPeter Maydell  fi
17008e515b12SPeter Maydellfi
17018e515b12SPeter Maydell
170244dc0ca3SAlon Levy##########################################
1703dfffc653SJuan Quintela# Sparse probe
1704dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
17050dba6195SLoïc Minier  if has cgcc; then
1706dfffc653SJuan Quintela    sparse=yes
1707dfffc653SJuan Quintela  else
1708dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1709dfffc653SJuan Quintela      feature_not_found "sparse"
1710dfffc653SJuan Quintela    fi
1711dfffc653SJuan Quintela    sparse=no
1712dfffc653SJuan Quintela  fi
1713dfffc653SJuan Quintelafi
1714dfffc653SJuan Quintela
1715dfffc653SJuan Quintela##########################################
1716a4ccabcfSAnthony Liguori# GTK probe
1717a4ccabcfSAnthony Liguori
1718a4ccabcfSAnthony Liguoriif test "$gtk" != "no"; then
1719528de90aSDaniel P. Berrange    gtkpackage="gtk+-$gtkabi"
1720528de90aSDaniel P. Berrange    if test "$gtkabi" = "3.0" ; then
1721528de90aSDaniel P. Berrange      gtkversion="3.0.0"
1722528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
1723528de90aSDaniel P. Berrange      vteversion="0.32.0"
1724528de90aSDaniel P. Berrange    else
1725528de90aSDaniel P. Berrange      gtkversion="2.18.0"
1726528de90aSDaniel P. Berrange      vtepackage="vte"
1727528de90aSDaniel P. Berrange      vteversion="0.24.0"
1728528de90aSDaniel P. Berrange    fi
1729528de90aSDaniel P. Berrange    if $pkg_config --exists "$gtkpackage >= $gtkversion" && \
1730528de90aSDaniel P. Berrange       $pkg_config --exists "$vtepackage >= $vteversion"; then
1731528de90aSDaniel P. Berrange	gtk_cflags=`$pkg_config --cflags $gtkpackage 2>/dev/null`
1732528de90aSDaniel P. Berrange	gtk_libs=`$pkg_config --libs $gtkpackage 2>/dev/null`
1733528de90aSDaniel P. Berrange	vte_cflags=`$pkg_config --cflags $vtepackage 2>/dev/null`
1734528de90aSDaniel P. Berrange	vte_libs=`$pkg_config --libs $vtepackage 2>/dev/null`
1735a4ccabcfSAnthony Liguori	libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
1736a4ccabcfSAnthony Liguori	gtk="yes"
1737a4ccabcfSAnthony Liguori    else
1738a4ccabcfSAnthony Liguori	if test "$gtk" = "yes" ; then
1739a4ccabcfSAnthony Liguori	    feature_not_found "gtk"
1740a4ccabcfSAnthony Liguori	fi
1741a4ccabcfSAnthony Liguori	gtk="no"
1742a4ccabcfSAnthony Liguori    fi
1743a4ccabcfSAnthony Liguorifi
1744a4ccabcfSAnthony Liguori
1745a4ccabcfSAnthony Liguori##########################################
174611d9f695Sbellard# SDL probe
174711d9f695Sbellard
17483ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
17493ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
17503ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
17513ec87ffeSPaolo Bonzini  sdl_config=sdl-config
17523ec87ffeSPaolo Bonzinifi
17533ec87ffeSPaolo Bonzini
17543ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1755a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1756fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
17573ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
17583ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
17599316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1760a0dfd8a4SLoïc Minierelse
1761a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1762a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1763a0dfd8a4SLoïc Minier  fi
1764a0dfd8a4SLoïc Minier  sdl=no
17659316f803SPaolo Bonzinifi
176629e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
17673ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
17683ec87ffeSPaolo Bonzinifi
176911d9f695Sbellard
17709316f803SPaolo Bonzinisdl_too_old=no
1771c4198157SJuan Quintelaif test "$sdl" != "no" ; then
177211d9f695Sbellard  cat > $TMPC << EOF
177311d9f695Sbellard#include <SDL.h>
177411d9f695Sbellard#undef main /* We don't want SDL to override our main() */
177511d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
177611d9f695SbellardEOF
17779316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
177874f42e18STeLeMan  if test "$static" = "yes" ; then
177974f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
178074f42e18STeLeMan  else
17819316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
178274f42e18STeLeMan  fi
178352166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
178411d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
178511d9f695Sbellard      sdl_too_old=yes
178611d9f695Sbellard    else
1787fd677642Sths      if test "$cocoa" = "no" ; then
178811d9f695Sbellard        sdl=yes
178911d9f695Sbellard      fi
1790fd677642Sths    fi
17917c1f25b4Sbellard
179267c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
17931ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
179467c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1795f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1796f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
179711d9f695Sbellard      fi
179852166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
17991ac88f28SJuan Quintela	:
18001ac88f28SJuan Quintela      else
18011ac88f28SJuan Quintela        sdl=no
18027c1f25b4Sbellard      fi
18037c1f25b4Sbellard    fi # static link
1804c4198157SJuan Quintela  else # sdl not found
1805c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1806c4198157SJuan Quintela      feature_not_found "sdl"
1807c4198157SJuan Quintela    fi
1808c4198157SJuan Quintela    sdl=no
18097c1f25b4Sbellard  fi # sdl compile test
1810fd677642Sthsfi
181111d9f695Sbellard
18125368a422Saliguoriif test "$sdl" = "yes" ; then
18135368a422Saliguori  cat > $TMPC <<EOF
18145368a422Saliguori#include <SDL.h>
18155368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
18165368a422Saliguori#include <X11/XKBlib.h>
18175368a422Saliguori#else
18185368a422Saliguori#error No x11 support
18195368a422Saliguori#endif
18205368a422Saliguoriint main(void) { return 0; }
18215368a422SaliguoriEOF
182252166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1823681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
18245368a422Saliguori  fi
18250705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
18265368a422Saliguorifi
18275368a422Saliguori
18288f28f3fbSths##########################################
18297536ee4bSTim Hardeck# VNC TLS/WS detection
18307536ee4bSTim Hardeckif test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then
1831ae6b5e5aSaliguori  cat > $TMPC <<EOF
1832ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1833ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1834ae6b5e5aSaliguoriEOF
1835a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1836a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
183752166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
18387536ee4bSTim Hardeck    if test "$vnc_tls" != "no" ; then
18391be10ad2SJuan Quintela      vnc_tls=yes
18407536ee4bSTim Hardeck    fi
18417536ee4bSTim Hardeck    if test "$vnc_ws" != "no" ; then
18427536ee4bSTim Hardeck      vnc_ws=yes
18437536ee4bSTim Hardeck    fi
1844a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1845ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
1846ae6b5e5aSaliguori  else
18471be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
18481be10ad2SJuan Quintela      feature_not_found "vnc-tls"
18491be10ad2SJuan Quintela    fi
18507536ee4bSTim Hardeck    if test "$vnc_ws" = "yes" ; then
18517536ee4bSTim Hardeck      feature_not_found "vnc-ws"
18527536ee4bSTim Hardeck    fi
18531be10ad2SJuan Quintela    vnc_tls=no
18547536ee4bSTim Hardeck    vnc_ws=no
18558d5d2d4cSths  fi
18568d5d2d4cSthsfi
18578d5d2d4cSths
18588d5d2d4cSths##########################################
18592f9606b3Saliguori# VNC SASL detection
1860821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
18612f9606b3Saliguori  cat > $TMPC <<EOF
18622f9606b3Saliguori#include <sasl/sasl.h>
18632f9606b3Saliguori#include <stdio.h>
18642f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
18652f9606b3SaliguoriEOF
18662f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
18672f9606b3Saliguori  vnc_sasl_cflags=""
18682f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
186952166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1870ea784e3bSJuan Quintela    vnc_sasl=yes
1871fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1872ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
18732f9606b3Saliguori  else
1874ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1875ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1876ea784e3bSJuan Quintela    fi
1877ea784e3bSJuan Quintela    vnc_sasl=no
18782f9606b3Saliguori  fi
18792f9606b3Saliguorifi
18802f9606b3Saliguori
18812f9606b3Saliguori##########################################
18822f6f5c7aSCorentin Chary# VNC JPEG detection
1883821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
18842f6f5c7aSCorentin Charycat > $TMPC <<EOF
18852f6f5c7aSCorentin Chary#include <stdio.h>
18862f6f5c7aSCorentin Chary#include <jpeglib.h>
18872f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
18882f6f5c7aSCorentin CharyEOF
18892f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
18902f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
18912f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
18922f6f5c7aSCorentin Chary    vnc_jpeg=yes
18932f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1894ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
18952f6f5c7aSCorentin Chary  else
18962f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
18972f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
18982f6f5c7aSCorentin Chary    fi
18992f6f5c7aSCorentin Chary    vnc_jpeg=no
19002f6f5c7aSCorentin Chary  fi
19012f6f5c7aSCorentin Charyfi
19022f6f5c7aSCorentin Chary
19032f6f5c7aSCorentin Chary##########################################
1904efe556adSCorentin Chary# VNC PNG detection
1905821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1906efe556adSCorentin Charycat > $TMPC <<EOF
1907efe556adSCorentin Chary//#include <stdio.h>
1908efe556adSCorentin Chary#include <png.h>
1909832ce9c2SScott Wood#include <stddef.h>
1910efe556adSCorentin Charyint main(void) {
1911efe556adSCorentin Chary    png_structp png_ptr;
1912efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
19137edc3fedSPeter Maydell    return png_ptr != 0;
1914efe556adSCorentin Chary}
1915efe556adSCorentin CharyEOF
19169af8025eSBrad  if $pkg_config libpng --modversion >/dev/null 2>&1; then
19179af8025eSBrad    vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
19189af8025eSBrad    vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
19199af8025eSBrad  else
1920efe556adSCorentin Chary    vnc_png_cflags=""
1921efe556adSCorentin Chary    vnc_png_libs="-lpng"
19229af8025eSBrad  fi
1923efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1924efe556adSCorentin Chary    vnc_png=yes
1925efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
19269af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1927efe556adSCorentin Chary  else
1928efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1929efe556adSCorentin Chary      feature_not_found "vnc-png"
1930efe556adSCorentin Chary    fi
1931efe556adSCorentin Chary    vnc_png=no
1932efe556adSCorentin Chary  fi
1933efe556adSCorentin Charyfi
1934efe556adSCorentin Chary
1935efe556adSCorentin Chary##########################################
193676655d6dSaliguori# fnmatch() probe, used for ACL routines
193776655d6dSaliguorifnmatch="no"
193876655d6dSaliguoricat > $TMPC << EOF
193976655d6dSaliguori#include <fnmatch.h>
194076655d6dSaliguoriint main(void)
194176655d6dSaliguori{
194276655d6dSaliguori    fnmatch("foo", "foo", 0);
194376655d6dSaliguori    return 0;
194476655d6dSaliguori}
194576655d6dSaliguoriEOF
194652166aa0SJuan Quintelaif compile_prog "" "" ; then
194776655d6dSaliguori   fnmatch="yes"
194876655d6dSaliguorifi
194976655d6dSaliguori
195076655d6dSaliguori##########################################
1951ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
19522d16c8e9SPeter Maydell# Note that on some systems (notably MacOSX) no extra library
19532d16c8e9SPeter Maydell# need be linked to get the uuid functions.
1954ee682d27SStefan Weilif test "$uuid" != "no" ; then
1955ee682d27SStefan Weil  uuid_libs="-luuid"
1956ee682d27SStefan Weil  cat > $TMPC << EOF
1957ee682d27SStefan Weil#include <uuid/uuid.h>
1958ee682d27SStefan Weilint main(void)
1959ee682d27SStefan Weil{
1960ee682d27SStefan Weil    uuid_t my_uuid;
1961ee682d27SStefan Weil    uuid_generate(my_uuid);
1962ee682d27SStefan Weil    return 0;
1963ee682d27SStefan Weil}
1964ee682d27SStefan WeilEOF
19652d16c8e9SPeter Maydell  if compile_prog "" "" ; then
19662d16c8e9SPeter Maydell    uuid="yes"
19672d16c8e9SPeter Maydell  elif compile_prog "" "$uuid_libs" ; then
1968ee682d27SStefan Weil    uuid="yes"
1969ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1970ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1971ee682d27SStefan Weil  else
1972ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1973ee682d27SStefan Weil      feature_not_found "uuid"
1974ee682d27SStefan Weil    fi
1975ee682d27SStefan Weil    uuid=no
1976ee682d27SStefan Weil  fi
1977ee682d27SStefan Weilfi
1978ee682d27SStefan Weil
1979ee682d27SStefan Weil##########################################
1980dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1981dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1982dce512deSChristoph Hellwig  cat > $TMPC << EOF
1983ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
1984dce512deSChristoph Hellwig#include <xfs/xfs.h>
1985dce512deSChristoph Hellwigint main(void)
1986dce512deSChristoph Hellwig{
1987dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1988dce512deSChristoph Hellwig    return 0;
1989dce512deSChristoph Hellwig}
1990dce512deSChristoph HellwigEOF
1991dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1992dce512deSChristoph Hellwig    xfs="yes"
1993dce512deSChristoph Hellwig  else
1994dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1995dce512deSChristoph Hellwig      feature_not_found "xfs"
1996dce512deSChristoph Hellwig    fi
1997dce512deSChristoph Hellwig    xfs=no
1998dce512deSChristoph Hellwig  fi
1999dce512deSChristoph Hellwigfi
2000dce512deSChristoph Hellwig
2001dce512deSChristoph Hellwig##########################################
20028a16d273Sths# vde libraries probe
2003dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
20044baae0acSJuan Quintela  vde_libs="-lvdeplug"
20058a16d273Sths  cat > $TMPC << EOF
20068a16d273Sths#include <libvdeplug.h>
20074a7f0e06Spbrookint main(void)
20084a7f0e06Spbrook{
20094a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2010fea08e08SPeter Maydell    char s[] = "";
2011fea08e08SPeter Maydell    vde_open(s, s, &a);
20124a7f0e06Spbrook    return 0;
20134a7f0e06Spbrook}
20148a16d273SthsEOF
201552166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
20164baae0acSJuan Quintela    vde=yes
20178e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
20188e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
2019dfb278bdSJuan Quintela  else
2020dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
2021dfb278bdSJuan Quintela      feature_not_found "vde"
2022dfb278bdSJuan Quintela    fi
2023dfb278bdSJuan Quintela    vde=no
20248a16d273Sths  fi
20258a16d273Sthsfi
20268a16d273Sths
20278a16d273Sths##########################################
202847e98658SCorey Bryant# libcap-ng library probe
202947e98658SCorey Bryantif test "$cap_ng" != "no" ; then
203047e98658SCorey Bryant  cap_libs="-lcap-ng"
203147e98658SCorey Bryant  cat > $TMPC << EOF
203247e98658SCorey Bryant#include <cap-ng.h>
203347e98658SCorey Bryantint main(void)
203447e98658SCorey Bryant{
203547e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
203647e98658SCorey Bryant    return 0;
203747e98658SCorey Bryant}
203847e98658SCorey BryantEOF
203947e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
204047e98658SCorey Bryant    cap_ng=yes
204147e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
204247e98658SCorey Bryant  else
204347e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
204447e98658SCorey Bryant      feature_not_found "cap_ng"
204547e98658SCorey Bryant    fi
204647e98658SCorey Bryant    cap_ng=no
204747e98658SCorey Bryant  fi
204847e98658SCorey Bryantfi
204947e98658SCorey Bryant
205047e98658SCorey Bryant##########################################
2051c2de5c91Smalc# Sound support libraries probe
20528f28f3fbSths
2053c2de5c91Smalcaudio_drv_probe()
2054c2de5c91Smalc{
2055c2de5c91Smalc    drv=$1
2056c2de5c91Smalc    hdr=$2
2057c2de5c91Smalc    lib=$3
2058c2de5c91Smalc    exp=$4
2059c2de5c91Smalc    cfl=$5
20608f28f3fbSths        cat > $TMPC << EOF
2061c2de5c91Smalc#include <$hdr>
2062c2de5c91Smalcint main(void) { $exp }
20638f28f3fbSthsEOF
206452166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
20658f28f3fbSths        :
20668f28f3fbSths    else
206776ad07a4SPeter Maydell        error_exit "$drv check failed" \
206876ad07a4SPeter Maydell            "Make sure to have the $drv libs and headers installed."
20698f28f3fbSths    fi
2070c2de5c91Smalc}
2071c2de5c91Smalc
20722fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
2073c2de5c91Smalcfor drv in $audio_drv_list; do
2074c2de5c91Smalc    case $drv in
2075c2de5c91Smalc    alsa)
2076c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
2077e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
2078a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
2079c2de5c91Smalc    ;;
2080c2de5c91Smalc
2081c2de5c91Smalc    fmod)
2082c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
208376ad07a4SPeter Maydell        error_exit "You must specify path to FMOD library and headers" \
208476ad07a4SPeter Maydell            "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
20858f28f3fbSths    fi
2086c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
2087a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
2088c2de5c91Smalc    ;;
2089c2de5c91Smalc
2090c2de5c91Smalc    esd)
2091c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
2092a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
209367f86e8eSJuan Quintela    audio_pt_int="yes"
2094c2de5c91Smalc    ;;
2095b8e59f18Smalc
2096b8e59f18Smalc    pa)
2097a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
2098a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
2099a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
210067f86e8eSJuan Quintela    audio_pt_int="yes"
2101b8e59f18Smalc    ;;
2102b8e59f18Smalc
2103997e690aSJuan Quintela    coreaudio)
2104997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
2105997e690aSJuan Quintela    ;;
2106997e690aSJuan Quintela
2107a4bf6780SJuan Quintela    dsound)
2108a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2109d5631638Smalc      audio_win_int="yes"
2110a4bf6780SJuan Quintela    ;;
2111a4bf6780SJuan Quintela
2112a4bf6780SJuan Quintela    oss)
2113a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
2114a4bf6780SJuan Quintela    ;;
2115a4bf6780SJuan Quintela
2116a4bf6780SJuan Quintela    sdl|wav)
21172f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
21182f6a1ab0Sblueswir1    ;;
21192f6a1ab0Sblueswir1
2120d5631638Smalc    winwave)
2121d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
2122d5631638Smalc      audio_win_int="yes"
2123d5631638Smalc    ;;
2124d5631638Smalc
2125e4c63a6aSmalc    *)
21261c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
212776ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
212876ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
2129e4c63a6aSmalc    }
2130e4c63a6aSmalc    ;;
2131c2de5c91Smalc    esac
2132c2de5c91Smalcdone
21338f28f3fbSths
21344d3b6f6eSbalrog##########################################
21352e4d9fb1Saurel32# BrlAPI probe
21362e4d9fb1Saurel32
21374ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2138eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
21392e4d9fb1Saurel32  cat > $TMPC << EOF
21402e4d9fb1Saurel32#include <brlapi.h>
2141832ce9c2SScott Wood#include <stddef.h>
21422e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
21432e4d9fb1Saurel32EOF
214452166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
21452e4d9fb1Saurel32    brlapi=yes
2146264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
21474ffcedb6SJuan Quintela  else
21484ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
21494ffcedb6SJuan Quintela      feature_not_found "brlapi"
21504ffcedb6SJuan Quintela    fi
21514ffcedb6SJuan Quintela    brlapi=no
2152eb82284fSJuan Quintela  fi
2153eb82284fSJuan Quintelafi
21542e4d9fb1Saurel32
21552e4d9fb1Saurel32##########################################
21564d3b6f6eSbalrog# curses probe
2157e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
2158e095e2f3SStefan Weil    curses_list="-lpdcurses"
2159e095e2f3SStefan Weilelse
2160acf15c89SVadim Evard    curses_list="-lncurses:-lcurses:$($pkg_config --libs ncurses 2>/dev/null)"
2161e095e2f3SStefan Weilfi
21624d3b6f6eSbalrog
2163c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
2164c584a6d0SJuan Quintela  curses_found=no
21654d3b6f6eSbalrog  cat > $TMPC << EOF
21664d3b6f6eSbalrog#include <curses.h>
2167ef9a2524SStefan Weilint main(void) {
2168ef9a2524SStefan Weil  const char *s = curses_version();
2169ef9a2524SStefan Weil  resize_term(0, 0);
2170ef9a2524SStefan Weil  return s != 0;
2171ef9a2524SStefan Weil}
21724d3b6f6eSbalrogEOF
2173ecbe251fSVadim Evard  IFS=:
21744f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
2175ecbe251fSVadim Evard    unset IFS
21764f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2177c584a6d0SJuan Quintela      curses_found=yes
21784f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
21794f78ef9aSJuan Quintela      break
21804d3b6f6eSbalrog    fi
21814f78ef9aSJuan Quintela  done
2182ecbe251fSVadim Evard  unset IFS
2183c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2184c584a6d0SJuan Quintela    curses=yes
2185c584a6d0SJuan Quintela  else
2186c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
2187c584a6d0SJuan Quintela      feature_not_found "curses"
2188c584a6d0SJuan Quintela    fi
2189c584a6d0SJuan Quintela    curses=no
2190c584a6d0SJuan Quintela  fi
21914f78ef9aSJuan Quintelafi
21924d3b6f6eSbalrog
2193414f0dabSblueswir1##########################################
2194769ce76dSAlexander Graf# curl probe
2195769ce76dSAlexander Graf
2196a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
2197a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
21984e2b0658SPaolo Bonzinielse
21994e2b0658SPaolo Bonzini  curlconfig=curl-config
22004e2b0658SPaolo Bonzinifi
22014e2b0658SPaolo Bonzini
2202788c8196SJuan Quintelaif test "$curl" != "no" ; then
2203769ce76dSAlexander Graf  cat > $TMPC << EOF
2204769ce76dSAlexander Graf#include <curl/curl.h>
22050b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2206769ce76dSAlexander GrafEOF
22074e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
22084e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2209b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2210769ce76dSAlexander Graf    curl=yes
2211f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2212f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2213788c8196SJuan Quintela  else
2214788c8196SJuan Quintela    if test "$curl" = "yes" ; then
2215788c8196SJuan Quintela      feature_not_found "curl"
2216788c8196SJuan Quintela    fi
2217788c8196SJuan Quintela    curl=no
2218769ce76dSAlexander Graf  fi
2219769ce76dSAlexander Graffi # test "$curl"
2220769ce76dSAlexander Graf
2221769ce76dSAlexander Graf##########################################
2222fb599c9aSbalrog# bluez support probe
2223a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2224e820e3f4Sbalrog  cat > $TMPC << EOF
2225e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2226e820e3f4Sbalrogint main(void) { return bt_error(0); }
2227e820e3f4SbalrogEOF
2228a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2229a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
223052166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2231a20a6f46SJuan Quintela    bluez=yes
2232e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2233e820e3f4Sbalrog  else
2234a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
2235a20a6f46SJuan Quintela      feature_not_found "bluez"
2236a20a6f46SJuan Quintela    fi
2237e820e3f4Sbalrog    bluez="no"
2238e820e3f4Sbalrog  fi
2239fb599c9aSbalrogfi
2240fb599c9aSbalrog
2241fb599c9aSbalrog##########################################
2242e18df141SAnthony Liguori# glib support probe
2243a52d28afSPaolo Bonzini
2244a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2245a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2246a52d28afSPaolo Bonzini    glib_req_ver=2.20
2247a52d28afSPaolo Bonzinielse
2248a52d28afSPaolo Bonzini    glib_req_ver=2.12
2249a52d28afSPaolo Bonzinifi
2250a52d28afSPaolo Bonziniif $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
2251a52d28afSPaolo Bonzinithen
22524b76a481SStefan Hajnoczi    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
22534b76a481SStefan Hajnoczi    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
225414015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2255957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2256e18df141SAnthony Liguorielse
225776ad07a4SPeter Maydell    error_exit "glib-$glib_req_ver required to compile QEMU"
2258e18df141SAnthony Liguorifi
2259e18df141SAnthony Liguori
2260e18df141SAnthony Liguori##########################################
2261e2134eb9SGerd Hoffmann# pixman support probe
2262e2134eb9SGerd Hoffmann
2263e2134eb9SGerd Hoffmannif test "$pixman" = ""; then
226474880fe2SRobert Schiele  if test "$want_tools" = "no" -a "$softmmu" = "no"; then
226574880fe2SRobert Schiele    pixman="none"
226674880fe2SRobert Schiele  elif $pkg_config pixman-1 > /dev/null 2>&1; then
2267e2134eb9SGerd Hoffmann    pixman="system"
2268e2134eb9SGerd Hoffmann  else
2269e2134eb9SGerd Hoffmann    pixman="internal"
2270e2134eb9SGerd Hoffmann  fi
2271e2134eb9SGerd Hoffmannfi
227274880fe2SRobert Schieleif test "$pixman" = "none"; then
227374880fe2SRobert Schiele  if test "$want_tools" != "no" -o "$softmmu" != "no"; then
227476ad07a4SPeter Maydell    error_exit "pixman disabled but system emulation or tools build" \
227576ad07a4SPeter Maydell        "enabled.  You can turn off pixman only if you also" \
227676ad07a4SPeter Maydell        "disable all system emulation targets and the tools" \
227776ad07a4SPeter Maydell        "build with '--disable-tools --disable-system'."
227874880fe2SRobert Schiele  fi
227974880fe2SRobert Schiele  pixman_cflags=
228074880fe2SRobert Schiele  pixman_libs=
228174880fe2SRobert Schieleelif test "$pixman" = "system"; then
2282e2134eb9SGerd Hoffmann  pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null`
2283e2134eb9SGerd Hoffmann  pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null`
2284e2134eb9SGerd Hoffmannelse
2285e2134eb9SGerd Hoffmann  if test ! -d ${source_path}/pixman/pixman; then
228676ad07a4SPeter Maydell    error_exit "pixman not present. Your options:" \
228776ad07a4SPeter Maydell        "  (1) Preferred: Install the pixman devel package (any recent" \
228876ad07a4SPeter Maydell        "      distro should have packages as Xorg needs pixman too)." \
228976ad07a4SPeter Maydell        "  (2) Fetch the pixman submodule, using:" \
229076ad07a4SPeter Maydell        "      git submodule update --init pixman"
2291e2134eb9SGerd Hoffmann  fi
22925ca9388aSGerd Hoffmann  mkdir -p pixman/pixman
22935ca9388aSGerd Hoffmann  pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
22945ca9388aSGerd Hoffmann  pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2295e2134eb9SGerd Hoffmannfi
2296e2134eb9SGerd Hoffmann
2297e2134eb9SGerd Hoffmann##########################################
229817bff52bSM. Mohan Kumar# libcap probe
229917bff52bSM. Mohan Kumar
230017bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
230117bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
230217bff52bSM. Mohan Kumar#include <stdio.h>
230317bff52bSM. Mohan Kumar#include <sys/capability.h>
2304cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
230517bff52bSM. Mohan KumarEOF
230617bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
230717bff52bSM. Mohan Kumar    cap=yes
230817bff52bSM. Mohan Kumar  else
230917bff52bSM. Mohan Kumar    cap=no
231017bff52bSM. Mohan Kumar  fi
231117bff52bSM. Mohan Kumarfi
231217bff52bSM. Mohan Kumar
231317bff52bSM. Mohan Kumar##########################################
2314e5d355d1Saliguori# pthread probe
23154b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
23163c529d93Saliguori
2317e5d355d1Saliguoripthread=no
2318414f0dabSblueswir1cat > $TMPC << EOF
23193c529d93Saliguori#include <pthread.h>
23207a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
23217a42bbe4SStefan Weilint main(void) {
23227a42bbe4SStefan Weil  pthread_t thread;
23237a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
23247a42bbe4SStefan Weil  return 0;
23257a42bbe4SStefan Weil}
2326414f0dabSblueswir1EOF
2327bd00d539SAndreas Färberif compile_prog "" "" ; then
2328bd00d539SAndreas Färber  pthread=yes
2329bd00d539SAndreas Färberelse
2330de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
233152166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2332e5d355d1Saliguori      pthread=yes
2333e3c56761SPeter Portante      found=no
2334e3c56761SPeter Portante      for lib_entry in $LIBS; do
2335e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2336e3c56761SPeter Portante          found=yes
2337e3c56761SPeter Portante          break
2338e3c56761SPeter Portante        fi
2339e3c56761SPeter Portante      done
2340e3c56761SPeter Portante      if test "$found" = "no"; then
23415572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2342e3c56761SPeter Portante      fi
2343de65fe0fSSebastian Herbszt      break
2344414f0dabSblueswir1    fi
2345de65fe0fSSebastian Herbszt  done
2346bd00d539SAndreas Färberfi
2347414f0dabSblueswir1
23484617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
234976ad07a4SPeter Maydell  error_exit "pthread check failed" \
235076ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
2351e5d355d1Saliguorifi
2352e5d355d1Saliguori
2353bf9298b9Saliguori##########################################
2354f27aaf4bSChristian Brunner# rbd probe
2355f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2356f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2357f27aaf4bSChristian Brunner#include <stdio.h>
2358ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2359f27aaf4bSChristian Brunnerint main(void) {
2360ad32e9c0SJosh Durgin    rados_t cluster;
2361ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2362f27aaf4bSChristian Brunner    return 0;
2363f27aaf4bSChristian Brunner}
2364f27aaf4bSChristian BrunnerEOF
2365ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2366f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2367f27aaf4bSChristian Brunner    rbd=yes
2368f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2369f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2370f27aaf4bSChristian Brunner  else
2371f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
2372f27aaf4bSChristian Brunner      feature_not_found "rados block device"
2373f27aaf4bSChristian Brunner    fi
2374f27aaf4bSChristian Brunner    rbd=no
2375f27aaf4bSChristian Brunner  fi
2376f27aaf4bSChristian Brunnerfi
2377f27aaf4bSChristian Brunner
2378f27aaf4bSChristian Brunner##########################################
23790a12ec87SRichard W.M. Jones# libssh2 probe
23804fc16838SRichard W.M. Jonesmin_libssh2_version=1.2.8
23810a12ec87SRichard W.M. Jonesif test "$libssh2" != "no" ; then
23824fc16838SRichard W.M. Jones  if $pkg_config --atleast-version=$min_libssh2_version libssh2 >/dev/null 2>&1
23834fc16838SRichard W.M. Jones  then
23840a12ec87SRichard W.M. Jones    libssh2_cflags=`$pkg_config libssh2 --cflags`
23850a12ec87SRichard W.M. Jones    libssh2_libs=`$pkg_config libssh2 --libs`
23860a12ec87SRichard W.M. Jones    libssh2=yes
23870a12ec87SRichard W.M. Jones    libs_tools="$libssh2_libs $libs_tools"
23880a12ec87SRichard W.M. Jones    libs_softmmu="$libssh2_libs $libs_softmmu"
23890a12ec87SRichard W.M. Jones    QEMU_CFLAGS="$QEMU_CFLAGS $libssh2_cflags"
23900a12ec87SRichard W.M. Jones  else
23910a12ec87SRichard W.M. Jones    if test "$libssh2" = "yes" ; then
23924fc16838SRichard W.M. Jones      error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
23930a12ec87SRichard W.M. Jones    fi
23940a12ec87SRichard W.M. Jones    libssh2=no
23950a12ec87SRichard W.M. Jones  fi
23960a12ec87SRichard W.M. Jonesfi
23970a12ec87SRichard W.M. Jones
23980a12ec87SRichard W.M. Jones##########################################
23999a2d462eSRichard W.M. Jones# libssh2_sftp_fsync probe
24009a2d462eSRichard W.M. Jones
24019a2d462eSRichard W.M. Jonesif test "$libssh2" = "yes"; then
24029a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
24039a2d462eSRichard W.M. Jones#include <stdio.h>
24049a2d462eSRichard W.M. Jones#include <libssh2.h>
24059a2d462eSRichard W.M. Jones#include <libssh2_sftp.h>
24069a2d462eSRichard W.M. Jonesint main(void) {
24079a2d462eSRichard W.M. Jones    LIBSSH2_SESSION *session;
24089a2d462eSRichard W.M. Jones    LIBSSH2_SFTP *sftp;
24099a2d462eSRichard W.M. Jones    LIBSSH2_SFTP_HANDLE *sftp_handle;
24109a2d462eSRichard W.M. Jones    session = libssh2_session_init ();
24119a2d462eSRichard W.M. Jones    sftp = libssh2_sftp_init (session);
24129a2d462eSRichard W.M. Jones    sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
24139a2d462eSRichard W.M. Jones    libssh2_sftp_fsync (sftp_handle);
24149a2d462eSRichard W.M. Jones    return 0;
24159a2d462eSRichard W.M. Jones}
24169a2d462eSRichard W.M. JonesEOF
24179a2d462eSRichard W.M. Jones  # libssh2_cflags/libssh2_libs defined in previous test.
24189a2d462eSRichard W.M. Jones  if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
24199a2d462eSRichard W.M. Jones    QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
24209a2d462eSRichard W.M. Jones  fi
24219a2d462eSRichard W.M. Jonesfi
24229a2d462eSRichard W.M. Jones
24239a2d462eSRichard W.M. Jones##########################################
24245c6c3a6cSChristoph Hellwig# linux-aio probe
24255c6c3a6cSChristoph Hellwig
24265c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
24275c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
24285c6c3a6cSChristoph Hellwig#include <libaio.h>
24295c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2430832ce9c2SScott Wood#include <stddef.h>
24315c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
24325c6c3a6cSChristoph HellwigEOF
24335c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
24345c6c3a6cSChristoph Hellwig    linux_aio=yes
2435048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2436048d179fSPaul Brook    libs_tools="$libs_tools -laio"
24375c6c3a6cSChristoph Hellwig  else
24385c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
24395c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
24405c6c3a6cSChristoph Hellwig    fi
24413cfcae3cSLuiz Capitulino    linux_aio=no
24425c6c3a6cSChristoph Hellwig  fi
24435c6c3a6cSChristoph Hellwigfi
24445c6c3a6cSChristoph Hellwig
24455c6c3a6cSChristoph Hellwig##########################################
24463b8acc11SPaolo Bonzini# TPM passthrough is only on x86 Linux
24473b8acc11SPaolo Bonzini
24483b8acc11SPaolo Bonziniif test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
24493b8acc11SPaolo Bonzini  tpm_passthrough=$tpm
24503b8acc11SPaolo Bonzinielse
24513b8acc11SPaolo Bonzini  tpm_passthrough=no
24523b8acc11SPaolo Bonzinifi
24533b8acc11SPaolo Bonzini
24543b8acc11SPaolo Bonzini##########################################
2455583f6e7bSStefan Hajnoczi# adjust virtio-blk-data-plane based on linux-aio
2456583f6e7bSStefan Hajnoczi
2457583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" -a \
2458583f6e7bSStefan Hajnoczi	"$linux_aio" != "yes" ; then
245976ad07a4SPeter Maydell  error_exit "virtio-blk-data-plane requires Linux AIO, please try --enable-linux-aio"
2460583f6e7bSStefan Hajnoczielif test -z "$virtio_blk_data_plane" ; then
2461583f6e7bSStefan Hajnoczi  virtio_blk_data_plane=$linux_aio
2462583f6e7bSStefan Hajnoczifi
2463583f6e7bSStefan Hajnoczi
2464583f6e7bSStefan Hajnoczi##########################################
2465758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2466758e8e38SVenkateswararao Jujjuri (JV)
2467758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2468758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2469758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2470758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2471f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2472f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2473f2338fb4SPavel Borzenkov#else
24744f26f2b6SAvi Kivity#include <sys/xattr.h>
2475f2338fb4SPavel Borzenkov#endif
2476758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2477758e8e38SVenkateswararao Jujjuri (JV)EOF
24784f26f2b6SAvi Kivity  if compile_prog "" "" ; then
24794f26f2b6SAvi Kivity    attr=yes
24804f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2481f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2482758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2483758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
24844f26f2b6SAvi Kivity    libattr=yes
2485758e8e38SVenkateswararao Jujjuri (JV)  else
2486758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2487758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2488758e8e38SVenkateswararao Jujjuri (JV)    fi
2489758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2490758e8e38SVenkateswararao Jujjuri (JV)  fi
2491758e8e38SVenkateswararao Jujjuri (JV)fi
2492758e8e38SVenkateswararao Jujjuri (JV)
2493758e8e38SVenkateswararao Jujjuri (JV)##########################################
2494bf9298b9Saliguori# iovec probe
2495bf9298b9Saliguoricat > $TMPC <<EOF
2496db34f0b3Sblueswir1#include <sys/types.h>
2497bf9298b9Saliguori#include <sys/uio.h>
2498db34f0b3Sblueswir1#include <unistd.h>
2499f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2500bf9298b9SaliguoriEOF
2501bf9298b9Saliguoriiovec=no
250252166aa0SJuan Quintelaif compile_prog "" "" ; then
2503bf9298b9Saliguori  iovec=yes
2504bf9298b9Saliguorifi
2505bf9298b9Saliguori
2506f652e6afSaurel32##########################################
2507ceb42de8Saliguori# preadv probe
2508ceb42de8Saliguoricat > $TMPC <<EOF
2509ceb42de8Saliguori#include <sys/types.h>
2510ceb42de8Saliguori#include <sys/uio.h>
2511ceb42de8Saliguori#include <unistd.h>
2512c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2513ceb42de8SaliguoriEOF
2514ceb42de8Saliguoripreadv=no
251552166aa0SJuan Quintelaif compile_prog "" "" ; then
2516ceb42de8Saliguori  preadv=yes
2517ceb42de8Saliguorifi
2518ceb42de8Saliguori
2519ceb42de8Saliguori##########################################
2520f652e6afSaurel32# fdt probe
25212df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2522b41af4baSJuan Quintela  fdt_libs="-lfdt"
2523f652e6afSaurel32  cat > $TMPC << EOF
2524f652e6afSaurel32int main(void) { return 0; }
2525f652e6afSaurel32EOF
252652166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2527a540f158SPeter Crosthwaite    # system DTC is good - use it
2528f652e6afSaurel32    fdt=yes
2529a540f158SPeter Crosthwaite  elif test -d ${source_path}/dtc/libfdt ; then
2530a540f158SPeter Crosthwaite    # have submodule DTC - use it
2531a540f158SPeter Crosthwaite    fdt=yes
2532a540f158SPeter Crosthwaite    dtc_internal="yes"
2533a540f158SPeter Crosthwaite    mkdir -p dtc
2534a540f158SPeter Crosthwaite    if [ "$source_path" != `pwd` ] ; then
2535a540f158SPeter Crosthwaite       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
2536a540f158SPeter Crosthwaite       symlink "$source_path/dtc/scripts" "dtc/scripts"
25372df87df7SJuan Quintela    fi
2538a540f158SPeter Crosthwaite    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
2539a540f158SPeter Crosthwaite    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
2540a540f158SPeter Crosthwaite  elif test "$fdt" = "yes" ; then
2541a540f158SPeter Crosthwaite    # have neither and want - prompt for system/submodule install
2542a540f158SPeter Crosthwaite    error_exit "ERROR: DTC not present. Your options:" \
2543a540f158SPeter Crosthwaite        "  (1) Preferred: Install the DTC devel package" \
2544a540f158SPeter Crosthwaite        "  (2) Fetch the DTC submodule, using:" \
2545a540f158SPeter Crosthwaite        "      git submodule update --init dtc"
2546a540f158SPeter Crosthwaite  else
2547a540f158SPeter Crosthwaite    # don't have and don't want
2548de3a354aSMichael Walle    fdt_libs=
25492df87df7SJuan Quintela    fdt=no
2550f652e6afSaurel32  fi
2551f652e6afSaurel32fi
2552f652e6afSaurel32
2553a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
2554a540f158SPeter Crosthwaite
255520ff075bSMichael Walle##########################################
2556b1e5fff4SMichael Walle# GLX probe, used by milkymist-tmu2
2557b1e5fff4SMichael Walleif test "$glx" != "no" ; then
2558b1e5fff4SMichael Walle  glx_libs="-lGL -lX11"
255920ff075bSMichael Walle  cat > $TMPC << EOF
256020ff075bSMichael Walle#include <X11/Xlib.h>
256120ff075bSMichael Walle#include <GL/gl.h>
256220ff075bSMichael Walle#include <GL/glx.h>
2563d3fcbb16SMichael Walleint main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
256420ff075bSMichael WalleEOF
2565d3fcbb16SMichael Walle  if compile_prog "" "-lGL -lX11" ; then
2566b1e5fff4SMichael Walle    glx=yes
256720ff075bSMichael Walle  else
2568b1e5fff4SMichael Walle    if test "$glx" = "yes" ; then
2569b1e5fff4SMichael Walle      feature_not_found "glx"
257020ff075bSMichael Walle    fi
2571b1e5fff4SMichael Walle    glx_libs=
2572b1e5fff4SMichael Walle    glx=no
257320ff075bSMichael Walle  fi
257420ff075bSMichael Wallefi
257520ff075bSMichael Walle
2576eb100396SBharata B Rao##########################################
2577eb100396SBharata B Rao# glusterfs probe
2578eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
2579eb100396SBharata B Rao  cat > $TMPC <<EOF
2580eb100396SBharata B Rao#include <glusterfs/api/glfs.h>
2581eb100396SBharata B Raoint main(void) {
2582eb100396SBharata B Rao    (void) glfs_new("volume");
2583eb100396SBharata B Rao    return 0;
2584eb100396SBharata B Rao}
2585eb100396SBharata B RaoEOF
2586eb100396SBharata B Rao  glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
2587eb100396SBharata B Rao  if compile_prog "" "$glusterfs_libs" ; then
2588eb100396SBharata B Rao    glusterfs=yes
2589eb100396SBharata B Rao    libs_tools="$glusterfs_libs $libs_tools"
2590eb100396SBharata B Rao    libs_softmmu="$glusterfs_libs $libs_softmmu"
2591eb100396SBharata B Rao  else
2592eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
2593eb100396SBharata B Rao      feature_not_found "GlusterFS backend support"
2594eb100396SBharata B Rao    fi
2595eb100396SBharata B Rao    glusterfs=no
2596eb100396SBharata B Rao  fi
2597eb100396SBharata B Raofi
2598eb100396SBharata B Rao
25993b3f24adSaurel32#
26003b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
26013b3f24adSaurel32# emulator.  This is done because older glibc versions don't
26023b3f24adSaurel32# have syscall stubs for these implemented.
26033b3f24adSaurel32#
26043b3f24adSaurel32atfile=no
26053b3f24adSaurel32cat > $TMPC << EOF
26063b3f24adSaurel32#define _ATFILE_SOURCE
26073b3f24adSaurel32#include <sys/types.h>
26083b3f24adSaurel32#include <fcntl.h>
26093b3f24adSaurel32#include <unistd.h>
26103b3f24adSaurel32
26113b3f24adSaurel32int
26123b3f24adSaurel32main(void)
26133b3f24adSaurel32{
26143b3f24adSaurel32	/* try to unlink nonexisting file */
26153b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
26163b3f24adSaurel32}
26173b3f24adSaurel32EOF
261852166aa0SJuan Quintelaif compile_prog "" "" ; then
26193b3f24adSaurel32  atfile=yes
26203b3f24adSaurel32fi
26213b3f24adSaurel32
262239386ac7Saurel32# Check for inotify functions when we are building linux-user
26233b3f24adSaurel32# emulator.  This is done because older glibc versions don't
26243b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
26253b3f24adSaurel32# don't provide them even if kernel supports them.
26263b3f24adSaurel32#
26273b3f24adSaurel32inotify=no
26283b3f24adSaurel32cat > $TMPC << EOF
26293b3f24adSaurel32#include <sys/inotify.h>
26303b3f24adSaurel32
26313b3f24adSaurel32int
26323b3f24adSaurel32main(void)
26333b3f24adSaurel32{
26343b3f24adSaurel32	/* try to start inotify */
26358690e420Saurel32	return inotify_init();
26363b3f24adSaurel32}
26373b3f24adSaurel32EOF
263852166aa0SJuan Quintelaif compile_prog "" "" ; then
26393b3f24adSaurel32  inotify=yes
26403b3f24adSaurel32fi
26413b3f24adSaurel32
2642c05c7a73SRiku Voipioinotify1=no
2643c05c7a73SRiku Voipiocat > $TMPC << EOF
2644c05c7a73SRiku Voipio#include <sys/inotify.h>
2645c05c7a73SRiku Voipio
2646c05c7a73SRiku Voipioint
2647c05c7a73SRiku Voipiomain(void)
2648c05c7a73SRiku Voipio{
2649c05c7a73SRiku Voipio    /* try to start inotify */
2650c05c7a73SRiku Voipio    return inotify_init1(0);
2651c05c7a73SRiku Voipio}
2652c05c7a73SRiku VoipioEOF
2653c05c7a73SRiku Voipioif compile_prog "" "" ; then
2654c05c7a73SRiku Voipio  inotify1=yes
2655c05c7a73SRiku Voipiofi
2656c05c7a73SRiku Voipio
2657ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2658ebc996f3SRiku Voipioutimens=no
2659ebc996f3SRiku Voipiocat > $TMPC << EOF
2660ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2661ebc996f3SRiku Voipio#include <stddef.h>
2662ebc996f3SRiku Voipio#include <fcntl.h>
26633014ee00SPeter Maydell#include <sys/stat.h>
2664ebc996f3SRiku Voipio
2665ebc996f3SRiku Voipioint main(void)
2666ebc996f3SRiku Voipio{
2667ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2668ebc996f3SRiku Voipio    futimens(0, NULL);
2669ebc996f3SRiku Voipio    return 0;
2670ebc996f3SRiku Voipio}
2671ebc996f3SRiku VoipioEOF
267252166aa0SJuan Quintelaif compile_prog "" "" ; then
2673ebc996f3SRiku Voipio  utimens=yes
2674ebc996f3SRiku Voipiofi
2675ebc996f3SRiku Voipio
2676099d6b0fSRiku Voipio# check if pipe2 is there
2677099d6b0fSRiku Voipiopipe2=no
2678099d6b0fSRiku Voipiocat > $TMPC << EOF
2679099d6b0fSRiku Voipio#include <unistd.h>
2680099d6b0fSRiku Voipio#include <fcntl.h>
2681099d6b0fSRiku Voipio
2682099d6b0fSRiku Voipioint main(void)
2683099d6b0fSRiku Voipio{
2684099d6b0fSRiku Voipio    int pipefd[2];
26859bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
2686099d6b0fSRiku Voipio}
2687099d6b0fSRiku VoipioEOF
268852166aa0SJuan Quintelaif compile_prog "" "" ; then
2689099d6b0fSRiku Voipio  pipe2=yes
2690099d6b0fSRiku Voipiofi
2691099d6b0fSRiku Voipio
269240ff6d7eSKevin Wolf# check if accept4 is there
269340ff6d7eSKevin Wolfaccept4=no
269440ff6d7eSKevin Wolfcat > $TMPC << EOF
269540ff6d7eSKevin Wolf#include <sys/socket.h>
269640ff6d7eSKevin Wolf#include <stddef.h>
269740ff6d7eSKevin Wolf
269840ff6d7eSKevin Wolfint main(void)
269940ff6d7eSKevin Wolf{
270040ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
270140ff6d7eSKevin Wolf    return 0;
270240ff6d7eSKevin Wolf}
270340ff6d7eSKevin WolfEOF
270440ff6d7eSKevin Wolfif compile_prog "" "" ; then
270540ff6d7eSKevin Wolf  accept4=yes
270640ff6d7eSKevin Wolffi
270740ff6d7eSKevin Wolf
27083ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
27093ce34dfbSvibisreenivasansplice=no
27103ce34dfbSvibisreenivasancat > $TMPC << EOF
27113ce34dfbSvibisreenivasan#include <unistd.h>
27123ce34dfbSvibisreenivasan#include <fcntl.h>
27133ce34dfbSvibisreenivasan#include <limits.h>
27143ce34dfbSvibisreenivasan
27153ce34dfbSvibisreenivasanint main(void)
27163ce34dfbSvibisreenivasan{
271766ea0f22SStefan Weil    int len, fd = 0;
27183ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
27193ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
27203ce34dfbSvibisreenivasan    return 0;
27213ce34dfbSvibisreenivasan}
27223ce34dfbSvibisreenivasanEOF
272352166aa0SJuan Quintelaif compile_prog "" "" ; then
27243ce34dfbSvibisreenivasan  splice=yes
27253ce34dfbSvibisreenivasanfi
27263ce34dfbSvibisreenivasan
2727dcc38d1cSMarcelo Tosatti##########################################
2728dcc38d1cSMarcelo Tosatti# signalfd probe
2729dcc38d1cSMarcelo Tosattisignalfd="no"
2730dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2731dcc38d1cSMarcelo Tosatti#include <unistd.h>
2732dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2733dcc38d1cSMarcelo Tosatti#include <signal.h>
2734dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2735dcc38d1cSMarcelo TosattiEOF
2736dcc38d1cSMarcelo Tosatti
2737dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2738dcc38d1cSMarcelo Tosatti  signalfd=yes
2739dcc38d1cSMarcelo Tosattifi
2740dcc38d1cSMarcelo Tosatti
2741c2882b96SRiku Voipio# check if eventfd is supported
2742c2882b96SRiku Voipioeventfd=no
2743c2882b96SRiku Voipiocat > $TMPC << EOF
2744c2882b96SRiku Voipio#include <sys/eventfd.h>
2745c2882b96SRiku Voipio
2746c2882b96SRiku Voipioint main(void)
2747c2882b96SRiku Voipio{
274855cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2749c2882b96SRiku Voipio}
2750c2882b96SRiku VoipioEOF
2751c2882b96SRiku Voipioif compile_prog "" "" ; then
2752c2882b96SRiku Voipio  eventfd=yes
2753c2882b96SRiku Voipiofi
2754c2882b96SRiku Voipio
2755d0927938SUlrich Hecht# check for fallocate
2756d0927938SUlrich Hechtfallocate=no
2757d0927938SUlrich Hechtcat > $TMPC << EOF
2758d0927938SUlrich Hecht#include <fcntl.h>
2759d0927938SUlrich Hecht
2760d0927938SUlrich Hechtint main(void)
2761d0927938SUlrich Hecht{
2762d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2763d0927938SUlrich Hecht    return 0;
2764d0927938SUlrich Hecht}
2765d0927938SUlrich HechtEOF
27668fb03151SPeter Maydellif compile_prog "" "" ; then
2767d0927938SUlrich Hecht  fallocate=yes
2768d0927938SUlrich Hechtfi
2769d0927938SUlrich Hecht
27703d4fa43eSKusanagi Kouichi# check for fallocate hole punching
27713d4fa43eSKusanagi Kouichifallocate_punch_hole=no
27723d4fa43eSKusanagi Kouichicat > $TMPC << EOF
27733d4fa43eSKusanagi Kouichi#include <fcntl.h>
27743d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
27753d4fa43eSKusanagi Kouichi
27763d4fa43eSKusanagi Kouichiint main(void)
27773d4fa43eSKusanagi Kouichi{
27783d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
27793d4fa43eSKusanagi Kouichi    return 0;
27803d4fa43eSKusanagi Kouichi}
27813d4fa43eSKusanagi KouichiEOF
27823d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
27833d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
27843d4fa43eSKusanagi Kouichifi
27853d4fa43eSKusanagi Kouichi
2786c727f47dSPeter Maydell# check for sync_file_range
2787c727f47dSPeter Maydellsync_file_range=no
2788c727f47dSPeter Maydellcat > $TMPC << EOF
2789c727f47dSPeter Maydell#include <fcntl.h>
2790c727f47dSPeter Maydell
2791c727f47dSPeter Maydellint main(void)
2792c727f47dSPeter Maydell{
2793c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2794c727f47dSPeter Maydell    return 0;
2795c727f47dSPeter Maydell}
2796c727f47dSPeter MaydellEOF
27978fb03151SPeter Maydellif compile_prog "" "" ; then
2798c727f47dSPeter Maydell  sync_file_range=yes
2799c727f47dSPeter Maydellfi
2800c727f47dSPeter Maydell
2801dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2802dace20dcSPeter Maydellfiemap=no
2803dace20dcSPeter Maydellcat > $TMPC << EOF
2804dace20dcSPeter Maydell#include <sys/ioctl.h>
2805dace20dcSPeter Maydell#include <linux/fs.h>
2806dace20dcSPeter Maydell#include <linux/fiemap.h>
2807dace20dcSPeter Maydell
2808dace20dcSPeter Maydellint main(void)
2809dace20dcSPeter Maydell{
2810dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2811dace20dcSPeter Maydell    return 0;
2812dace20dcSPeter Maydell}
2813dace20dcSPeter MaydellEOF
28148fb03151SPeter Maydellif compile_prog "" "" ; then
2815dace20dcSPeter Maydell  fiemap=yes
2816dace20dcSPeter Maydellfi
2817dace20dcSPeter Maydell
2818d0927938SUlrich Hecht# check for dup3
2819d0927938SUlrich Hechtdup3=no
2820d0927938SUlrich Hechtcat > $TMPC << EOF
2821d0927938SUlrich Hecht#include <unistd.h>
2822d0927938SUlrich Hecht
2823d0927938SUlrich Hechtint main(void)
2824d0927938SUlrich Hecht{
2825d0927938SUlrich Hecht    dup3(0, 0, 0);
2826d0927938SUlrich Hecht    return 0;
2827d0927938SUlrich Hecht}
2828d0927938SUlrich HechtEOF
282978f5d726SJan Kiszkaif compile_prog "" "" ; then
2830d0927938SUlrich Hecht  dup3=yes
2831d0927938SUlrich Hechtfi
2832d0927938SUlrich Hecht
28333b6edd16SPeter Maydell# check for epoll support
28343b6edd16SPeter Maydellepoll=no
28353b6edd16SPeter Maydellcat > $TMPC << EOF
28363b6edd16SPeter Maydell#include <sys/epoll.h>
28373b6edd16SPeter Maydell
28383b6edd16SPeter Maydellint main(void)
28393b6edd16SPeter Maydell{
28403b6edd16SPeter Maydell    epoll_create(0);
28413b6edd16SPeter Maydell    return 0;
28423b6edd16SPeter Maydell}
28433b6edd16SPeter MaydellEOF
28448fb03151SPeter Maydellif compile_prog "" "" ; then
28453b6edd16SPeter Maydell  epoll=yes
28463b6edd16SPeter Maydellfi
28473b6edd16SPeter Maydell
28483b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
28493b6edd16SPeter Maydell# so we must check separately for their presence
28503b6edd16SPeter Maydellepoll_create1=no
28513b6edd16SPeter Maydellcat > $TMPC << EOF
28523b6edd16SPeter Maydell#include <sys/epoll.h>
28533b6edd16SPeter Maydell
28543b6edd16SPeter Maydellint main(void)
28553b6edd16SPeter Maydell{
285619e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
285719e83f6bSPeter Maydell     * a function being called. This is necessary so that on
285819e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
285919e83f6bSPeter Maydell     * the library but not declared in the header file we will
286019e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
286119e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
286219e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
286319e83f6bSPeter Maydell     */
2864c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
28653b6edd16SPeter Maydell}
28663b6edd16SPeter MaydellEOF
28678fb03151SPeter Maydellif compile_prog "" "" ; then
28683b6edd16SPeter Maydell  epoll_create1=yes
28693b6edd16SPeter Maydellfi
28703b6edd16SPeter Maydell
28713b6edd16SPeter Maydellepoll_pwait=no
28723b6edd16SPeter Maydellcat > $TMPC << EOF
28733b6edd16SPeter Maydell#include <sys/epoll.h>
28743b6edd16SPeter Maydell
28753b6edd16SPeter Maydellint main(void)
28763b6edd16SPeter Maydell{
28773b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
28783b6edd16SPeter Maydell    return 0;
28793b6edd16SPeter Maydell}
28803b6edd16SPeter MaydellEOF
28818fb03151SPeter Maydellif compile_prog "" "" ; then
28823b6edd16SPeter Maydell  epoll_pwait=yes
28833b6edd16SPeter Maydellfi
28843b6edd16SPeter Maydell
2885a8fd1abaSPeter Maydell# check for sendfile support
2886a8fd1abaSPeter Maydellsendfile=no
2887a8fd1abaSPeter Maydellcat > $TMPC << EOF
2888a8fd1abaSPeter Maydell#include <sys/sendfile.h>
2889a8fd1abaSPeter Maydell
2890a8fd1abaSPeter Maydellint main(void)
2891a8fd1abaSPeter Maydell{
2892a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
2893a8fd1abaSPeter Maydell}
2894a8fd1abaSPeter MaydellEOF
2895a8fd1abaSPeter Maydellif compile_prog "" "" ; then
2896a8fd1abaSPeter Maydell  sendfile=yes
2897a8fd1abaSPeter Maydellfi
2898a8fd1abaSPeter Maydell
2899cc8ae6deSpbrook# Check if tools are available to build documentation.
2900a25dba17SJuan Quintelaif test "$docs" != "no" ; then
290101668d98SStefan Weil  if has makeinfo && has pod2man; then
2902a25dba17SJuan Quintela    docs=yes
290383a3ab8bSJuan Quintela  else
2904a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2905a25dba17SJuan Quintela      feature_not_found "docs"
290683a3ab8bSJuan Quintela    fi
2907a25dba17SJuan Quintela    docs=no
290883a3ab8bSJuan Quintela  fi
2909cc8ae6deSpbrookfi
2910cc8ae6deSpbrook
2911f514f41cSStefan Weil# Search for bswap_32 function
29126ae9a1f4SJuan Quintelabyteswap_h=no
29136ae9a1f4SJuan Quintelacat > $TMPC << EOF
29146ae9a1f4SJuan Quintela#include <byteswap.h>
29156ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
29166ae9a1f4SJuan QuintelaEOF
291752166aa0SJuan Quintelaif compile_prog "" "" ; then
29186ae9a1f4SJuan Quintela  byteswap_h=yes
29196ae9a1f4SJuan Quintelafi
29206ae9a1f4SJuan Quintela
292175f13596SStefan Weil# Search for bswap32 function
29226ae9a1f4SJuan Quintelabswap_h=no
29236ae9a1f4SJuan Quintelacat > $TMPC << EOF
29246ae9a1f4SJuan Quintela#include <sys/endian.h>
29256ae9a1f4SJuan Quintela#include <sys/types.h>
29266ae9a1f4SJuan Quintela#include <machine/bswap.h>
29276ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
29286ae9a1f4SJuan QuintelaEOF
292952166aa0SJuan Quintelaif compile_prog "" "" ; then
29306ae9a1f4SJuan Quintela  bswap_h=yes
29316ae9a1f4SJuan Quintelafi
29326ae9a1f4SJuan Quintela
2933da93a1fdSaliguori##########################################
2934c589b249SRonnie Sahlberg# Do we have libiscsi
2935fa6acb0cSRonnie Sahlberg# We check for iscsi_unmap_sync() to make sure we have a
2936fa6acb0cSRonnie Sahlberg# recent enough version of libiscsi.
2937c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2938c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2939fa6acb0cSRonnie Sahlberg#include <stdio.h>
2940c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2941fa6acb0cSRonnie Sahlbergint main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2942c589b249SRonnie SahlbergEOF
29433c33ea96SPaolo Bonzini  if $pkg_config --atleast-version=1.7.0 libiscsi --modversion >/dev/null 2>&1; then
29443c33ea96SPaolo Bonzini    libiscsi="yes"
29453c33ea96SPaolo Bonzini    libiscsi_cflags=$($pkg_config --cflags libiscsi 2>/dev/null)
29463c33ea96SPaolo Bonzini    libiscsi_libs=$($pkg_config --libs libiscsi 2>/dev/null)
29473c33ea96SPaolo Bonzini    CFLAGS="$CFLAGS $libiscsi_cflags"
29483c33ea96SPaolo Bonzini    LIBS="$LIBS $libiscsi_libs"
29493c33ea96SPaolo Bonzini  elif compile_prog "" "-liscsi" ; then
2950c589b249SRonnie Sahlberg    libiscsi="yes"
2951c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2952c589b249SRonnie Sahlberg  else
2953c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2954c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2955c589b249SRonnie Sahlberg    fi
2956c589b249SRonnie Sahlberg    libiscsi="no"
2957c589b249SRonnie Sahlberg  fi
2958c589b249SRonnie Sahlbergfi
2959c589b249SRonnie Sahlberg
2960c589b249SRonnie Sahlberg
2961c589b249SRonnie Sahlberg##########################################
29628bacde8dSNatanael Copa# Do we need libm
29638bacde8dSNatanael Copacat > $TMPC << EOF
29648bacde8dSNatanael Copa#include <math.h>
29658bacde8dSNatanael Copaint main(void) { return isnan(sin(0.0)); }
29668bacde8dSNatanael CopaEOF
29678bacde8dSNatanael Copaif compile_prog "" "" ; then
29688bacde8dSNatanael Copa  :
29698bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
29708bacde8dSNatanael Copa  LIBS="-lm $LIBS"
29718bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
29728bacde8dSNatanael Copaelse
297376ad07a4SPeter Maydell  error_exit "libm check failed"
29748bacde8dSNatanael Copafi
29758bacde8dSNatanael Copa
29768bacde8dSNatanael Copa##########################################
2977da93a1fdSaliguori# Do we need librt
29788bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
29798bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
29808bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
29818bacde8dSNatanael Copa# function in addition.
2982da93a1fdSaliguoricat > $TMPC <<EOF
2983da93a1fdSaliguori#include <signal.h>
2984da93a1fdSaliguori#include <time.h>
29858bacde8dSNatanael Copaint main(void) {
29868bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
29878bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
29888bacde8dSNatanael Copa}
2989da93a1fdSaliguoriEOF
2990da93a1fdSaliguori
299152166aa0SJuan Quintelaif compile_prog "" "" ; then
299207ffa4bdSJuan Quintela  :
29938bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
29948bacde8dSNatanael Copaelif compile_prog "" "-lrt $pthread_lib" ; then
299507ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
29968bacde8dSNatanael Copa  libs_qga="-lrt $libs_qga"
2997da93a1fdSaliguorifi
2998da93a1fdSaliguori
299931ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
3000179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
30016362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
30026362a53fSJuan Quintelafi
30036362a53fSJuan Quintela
3004de5071c5SBlue Swirl##########################################
3005cd4ec0b4SGerd Hoffmann# spice probe
3006cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3007cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3008cd4ec0b4SGerd Hoffmann#include <spice.h>
3009cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3010cd4ec0b4SGerd HoffmannEOF
3011710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3012710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
301367be6726SGerd Hoffmann  if $pkg_config --atleast-version=0.12.0 spice-server >/dev/null 2>&1 && \
3014358689feSMichal Privoznik     $pkg_config --atleast-version=0.12.3 spice-protocol > /dev/null 2>&1 && \
3015cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3016cd4ec0b4SGerd Hoffmann    spice="yes"
3017cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
3018cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
30192e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
30202e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
3021cd4ec0b4SGerd Hoffmann  else
3022cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
3023cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
3024cd4ec0b4SGerd Hoffmann    fi
3025cd4ec0b4SGerd Hoffmann    spice="no"
3026cd4ec0b4SGerd Hoffmann  fi
3027cd4ec0b4SGerd Hoffmannfi
3028cd4ec0b4SGerd Hoffmann
3029111a38b0SRobert Relyea# check for libcacard for smartcard support
3030111a38b0SRobert Relyeasmartcard_cflags=""
3031111a38b0SRobert Relyea# TODO - what's the minimal nss version we support?
3032111a38b0SRobert Relyeaif test "$smartcard_nss" != "no"; then
30335f01e06fSSergei Trofimovich  cat > $TMPC << EOF
30345f01e06fSSergei Trofimovich#include <pk11pub.h>
30355f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
30365f01e06fSSergei TrofimovichEOF
30370b22ef0fSPeter Maydell    smartcard_includes="-I\$(SRC_PATH)/libcacard"
30388c741c22SAlon Levy    libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
30398c741c22SAlon Levy    libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
30406ca026cbSPeter Maydell    test_cflags="$libcacard_cflags"
30416ca026cbSPeter Maydell    # The header files in nss < 3.13.3 have a bug which causes them to
30426ca026cbSPeter Maydell    # emit a warning. If we're going to compile QEMU with -Werror, then
30436ca026cbSPeter Maydell    # test that the headers don't have this bug. Otherwise we would pass
30446ca026cbSPeter Maydell    # the configure test but fail to compile QEMU later.
30456ca026cbSPeter Maydell    if test "$werror" = "yes"; then
30466ca026cbSPeter Maydell        test_cflags="-Werror $test_cflags"
30476ca026cbSPeter Maydell    fi
3048b6fc675bSPaolo Bonzini    if test -n "$libtool" &&
3049b6fc675bSPaolo Bonzini            $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
30506ca026cbSPeter Maydell      compile_prog "$test_cflags" "$libcacard_libs"; then
30515f01e06fSSergei Trofimovich        smartcard_nss="yes"
30520b22ef0fSPeter Maydell        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
30530b22ef0fSPeter Maydell        QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
3054ad4cf3f6SPaul Brook        libs_softmmu="$libcacard_libs $libs_softmmu"
3055111a38b0SRobert Relyea    else
3056111a38b0SRobert Relyea        if test "$smartcard_nss" = "yes"; then
3057111a38b0SRobert Relyea            feature_not_found "nss"
3058111a38b0SRobert Relyea        fi
3059111a38b0SRobert Relyea        smartcard_nss="no"
3060111a38b0SRobert Relyea    fi
3061111a38b0SRobert Relyeafi
3062111a38b0SRobert Relyea
30632b2325ffSGerd Hoffmann# check for libusb
30642b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
30653f5cc97eSGerd Hoffmann    if $pkg_config --atleast-version=1.0.13 libusb-1.0 >/dev/null 2>&1 ; then
30662b2325ffSGerd Hoffmann        libusb="yes"
30672b2325ffSGerd Hoffmann	usb="libusb"
30682b2325ffSGerd Hoffmann        libusb_cflags=$($pkg_config --cflags libusb-1.0 2>/dev/null)
30692b2325ffSGerd Hoffmann        libusb_libs=$($pkg_config --libs libusb-1.0 2>/dev/null)
30702b2325ffSGerd Hoffmann        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
30712b2325ffSGerd Hoffmann        libs_softmmu="$libs_softmmu $libusb_libs"
30722b2325ffSGerd Hoffmann    else
30732b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
30742b2325ffSGerd Hoffmann            feature_not_found "libusb"
30752b2325ffSGerd Hoffmann        fi
30762b2325ffSGerd Hoffmann        libusb="no"
30772b2325ffSGerd Hoffmann    fi
30782b2325ffSGerd Hoffmannfi
30792b2325ffSGerd Hoffmann
308069354a83SHans de Goede# check for usbredirparser for usb network redirection support
308169354a83SHans de Goedeif test "$usb_redir" != "no" ; then
3082b2d1fe67SHans de Goede    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5 >/dev/null 2>&1 ; then
308369354a83SHans de Goede        usb_redir="yes"
30848b626aa7SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5 2>/dev/null)
30858b626aa7SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5 2>/dev/null)
308669354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
308756ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
308869354a83SHans de Goede    else
308969354a83SHans de Goede        if test "$usb_redir" = "yes"; then
309069354a83SHans de Goede            feature_not_found "usb-redir"
309169354a83SHans de Goede        fi
309269354a83SHans de Goede        usb_redir="no"
309369354a83SHans de Goede    fi
309469354a83SHans de Goedefi
309569354a83SHans de Goede
3096cd4ec0b4SGerd Hoffmann##########################################
3097cd4ec0b4SGerd Hoffmann
3098747bbdf7SBlue Swirl##########################################
30995f6b9e8fSBlue Swirl# check if we have fdatasync
31005f6b9e8fSBlue Swirl
31015f6b9e8fSBlue Swirlfdatasync=no
31025f6b9e8fSBlue Swirlcat > $TMPC << EOF
31035f6b9e8fSBlue Swirl#include <unistd.h>
3104d1722a27SAlexandre Raymondint main(void) {
3105d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
3106d1722a27SAlexandre Raymondreturn fdatasync(0);
3107d1722a27SAlexandre Raymond#else
3108e172fe11SStefan Weil#error Not supported
3109d1722a27SAlexandre Raymond#endif
3110d1722a27SAlexandre Raymond}
31115f6b9e8fSBlue SwirlEOF
31125f6b9e8fSBlue Swirlif compile_prog "" "" ; then
31135f6b9e8fSBlue Swirl    fdatasync=yes
31145f6b9e8fSBlue Swirlfi
31155f6b9e8fSBlue Swirl
311694a420b1SStefan Hajnoczi##########################################
3117e78815a5SAndreas Färber# check if we have madvise
3118e78815a5SAndreas Färber
3119e78815a5SAndreas Färbermadvise=no
3120e78815a5SAndreas Färbercat > $TMPC << EOF
3121e78815a5SAndreas Färber#include <sys/types.h>
3122e78815a5SAndreas Färber#include <sys/mman.h>
3123832ce9c2SScott Wood#include <stddef.h>
3124e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
3125e78815a5SAndreas FärberEOF
3126e78815a5SAndreas Färberif compile_prog "" "" ; then
3127e78815a5SAndreas Färber    madvise=yes
3128e78815a5SAndreas Färberfi
3129e78815a5SAndreas Färber
3130e78815a5SAndreas Färber##########################################
3131e78815a5SAndreas Färber# check if we have posix_madvise
3132e78815a5SAndreas Färber
3133e78815a5SAndreas Färberposix_madvise=no
3134e78815a5SAndreas Färbercat > $TMPC << EOF
3135e78815a5SAndreas Färber#include <sys/mman.h>
3136832ce9c2SScott Wood#include <stddef.h>
3137e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
3138e78815a5SAndreas FärberEOF
3139e78815a5SAndreas Färberif compile_prog "" "" ; then
3140e78815a5SAndreas Färber    posix_madvise=yes
3141e78815a5SAndreas Färberfi
3142e78815a5SAndreas Färber
3143e78815a5SAndreas Färber##########################################
31441e9737daSRichard Henderson# check if we have usable SIGEV_THREAD_ID
31451e9737daSRichard Henderson
31461e9737daSRichard Hendersonsigev_thread_id=no
31471e9737daSRichard Hendersoncat > $TMPC << EOF
31481e9737daSRichard Henderson#include <signal.h>
31491e9737daSRichard Hendersonint main(void) {
31501e9737daSRichard Henderson  struct sigevent ev;
31511e9737daSRichard Henderson  ev.sigev_notify = SIGEV_THREAD_ID;
31521e9737daSRichard Henderson  ev._sigev_un._tid = 0;
31531e9737daSRichard Henderson  asm volatile("" : : "g"(&ev));
31541e9737daSRichard Henderson  return 0;
31551e9737daSRichard Henderson}
31561e9737daSRichard HendersonEOF
31571e9737daSRichard Hendersonif compile_prog "" "" ; then
31581e9737daSRichard Henderson    sigev_thread_id=yes
31591e9737daSRichard Hendersonfi
31601e9737daSRichard Henderson
31611e9737daSRichard Henderson##########################################
316294a420b1SStefan Hajnoczi# check if trace backend exists
316394a420b1SStefan Hajnoczi
3164650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
316594a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
316676ad07a4SPeter Maydell  error_exit "invalid trace backend" \
316776ad07a4SPeter Maydell      "Please choose a supported trace backend."
316894a420b1SStefan Hajnoczifi
316994a420b1SStefan Hajnoczi
31707e24e92aSStefan Hajnoczi##########################################
31717e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
31727e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
31737e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
31747e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
31757e24e92aSStefan Hajnoczi#include <ust/marker.h>
31767e24e92aSStefan Hajnocziint main(void) { return 0; }
31777e24e92aSStefan HajnocziEOF
31787e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
317994b4fefaSLluís Vilanova    LIBS="-lust -lurcu-bp $LIBS"
3180c9a2e37cSLluís Vilanova    libs_qga="-lust -lurcu-bp $libs_qga"
31817e24e92aSStefan Hajnoczi  else
318276ad07a4SPeter Maydell    error_exit "Trace backend 'ust' missing libust header files"
31837e24e92aSStefan Hajnoczi  fi
31847e24e92aSStefan Hajnoczifi
3185b3d08c02SDaniel P. Berrange
3186b3d08c02SDaniel P. Berrange##########################################
3187b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
3188b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
3189b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
319076ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
3191b3d08c02SDaniel P. Berrange  fi
3192c276b17dSDaniel P. Berrange  trace_backend_stap="no"
3193c276b17dSDaniel P. Berrange  if has 'stap' ; then
3194c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
3195c276b17dSDaniel P. Berrange  fi
3196b3d08c02SDaniel P. Berrangefi
3197b3d08c02SDaniel P. Berrange
31987e24e92aSStefan Hajnoczi##########################################
3199519175a2SAlex Barcelo# check and set a backend for coroutine
3200d0e2fce5SAneesh Kumar K.V
32017c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
32027c2acc70SPeter Maydell# is sigcontext. gthread is not selectable except explicitly, because
32037c2acc70SPeter Maydell# it is not functional enough to run QEMU proper. (It is occasionally
32047c2acc70SPeter Maydell# useful for debugging purposes.)  On Windows the only valid backend
32057c2acc70SPeter Maydell# is the Windows-specific one.
32067c2acc70SPeter Maydell
32077c2acc70SPeter Maydellucontext_works=no
3208d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3209d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3210d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3211cdf84806SPeter Maydell#ifdef __stub_makecontext
3212cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3213cdf84806SPeter Maydell#endif
321475cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3215d0e2fce5SAneesh Kumar K.VEOF
3216d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
32177c2acc70SPeter Maydell    ucontext_works=yes
3218d0e2fce5SAneesh Kumar K.V  fi
3219519175a2SAlex Barcelofi
32207c2acc70SPeter Maydell
32217c2acc70SPeter Maydellif test "$coroutine" = ""; then
32227c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
32237c2acc70SPeter Maydell    coroutine=win32
32247c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
32257c2acc70SPeter Maydell    coroutine=ucontext
3226519175a2SAlex Barcelo  else
32277c2acc70SPeter Maydell    coroutine=sigaltstack
32287c2acc70SPeter Maydell  fi
32297c2acc70SPeter Maydellelse
32307c2acc70SPeter Maydell  case $coroutine in
32317c2acc70SPeter Maydell  windows)
32327c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
32337c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
32347c2acc70SPeter Maydell    fi
32357c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
32367c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
32377c2acc70SPeter Maydell    coroutine=win32
32387c2acc70SPeter Maydell    ;;
32397c2acc70SPeter Maydell  ucontext)
32407c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
32417c2acc70SPeter Maydell      feature_not_found "ucontext"
32427c2acc70SPeter Maydell    fi
32437c2acc70SPeter Maydell    ;;
32447c2acc70SPeter Maydell  gthread|sigaltstack)
32457c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
32467c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
32477c2acc70SPeter Maydell    fi
32487c2acc70SPeter Maydell    ;;
32497c2acc70SPeter Maydell  *)
325076ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
32517c2acc70SPeter Maydell    ;;
32527c2acc70SPeter Maydell  esac
3253d0e2fce5SAneesh Kumar K.Vfi
3254d0e2fce5SAneesh Kumar K.V
3255d0e2fce5SAneesh Kumar K.V##########################################
3256d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
3257d2042378SAneesh Kumar K.V
32584e1797f9SStefan Weilopen_by_handle_at=no
3259d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
3260d2042378SAneesh Kumar K.V#include <fcntl.h>
3261acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
3262acc55ba8SStefan Weil# error missing definition
3263acc55ba8SStefan Weil#else
326475cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3265acc55ba8SStefan Weil#endif
3266d2042378SAneesh Kumar K.VEOF
3267d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
3268d2042378SAneesh Kumar K.V    open_by_handle_at=yes
3269d2042378SAneesh Kumar K.Vfi
3270d2042378SAneesh Kumar K.V
3271e06a765eSHarsh Prateek Bora########################################
3272e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
3273e06a765eSHarsh Prateek Bora
3274e06a765eSHarsh Prateek Boralinux_magic_h=no
3275e06a765eSHarsh Prateek Boracat > $TMPC << EOF
3276e06a765eSHarsh Prateek Bora#include <linux/magic.h>
3277e06a765eSHarsh Prateek Boraint main(void) {
327875cafad7SStefan Weil  return 0;
3279e06a765eSHarsh Prateek Bora}
3280e06a765eSHarsh Prateek BoraEOF
3281e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
3282e06a765eSHarsh Prateek Bora    linux_magic_h=yes
3283e06a765eSHarsh Prateek Borafi
3284e06a765eSHarsh Prateek Bora
32858ab1bf12SLuiz Capitulino########################################
3286c95e3080SKevin Wolf# check whether we can disable warning option with a pragma (this is needed
3287c95e3080SKevin Wolf# to silence warnings in the headers of some versions of external libraries).
3288c95e3080SKevin Wolf# This test has to be compiled with -Werror as otherwise an unknown pragma is
3289c95e3080SKevin Wolf# only a warning.
3290c95e3080SKevin Wolf#
3291c95e3080SKevin Wolf# If we can't selectively disable warning in the code, disable -Werror so that
3292c95e3080SKevin Wolf# the build doesn't fail anyway.
3293c95e3080SKevin Wolf
329406d71fa1SPeter Maydellpragma_disable_unused_but_set=no
329506d71fa1SPeter Maydellcat > $TMPC << EOF
3296e6f53fd5SMarkus Armbruster#pragma GCC diagnostic push
329706d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3298c95e3080SKevin Wolf#pragma GCC diagnostic ignored "-Wstrict-prototypes"
3299e6f53fd5SMarkus Armbruster#pragma GCC diagnostic pop
3300c95e3080SKevin Wolf
330106d71fa1SPeter Maydellint main(void) {
330206d71fa1SPeter Maydell    return 0;
330306d71fa1SPeter Maydell}
330406d71fa1SPeter MaydellEOF
330506d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
3306cc6e3ca9SGerd Hoffmann    pragma_diagnostic_available=yes
3307c95e3080SKevin Wolfelse
3308c95e3080SKevin Wolf    werror=no
330906d71fa1SPeter Maydellfi
331006d71fa1SPeter Maydell
331106d71fa1SPeter Maydell########################################
331262fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
33133f4349dcSKevin Wolf
33143f4349dcSKevin Wolfvalgrind_h=no
33153f4349dcSKevin Wolfcat > $TMPC << EOF
33163f4349dcSKevin Wolf#include <valgrind/valgrind.h>
331762fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
33183f4349dcSKevin Wolfint main(void) {
33193f4349dcSKevin Wolf  return 0;
33203f4349dcSKevin Wolf}
33213f4349dcSKevin WolfEOF
33223f4349dcSKevin Wolfif compile_prog "" "" ; then
33233f4349dcSKevin Wolf    valgrind_h=yes
33243f4349dcSKevin Wolffi
33253f4349dcSKevin Wolf
33263f4349dcSKevin Wolf########################################
33278ab1bf12SLuiz Capitulino# check if environ is declared
33288ab1bf12SLuiz Capitulino
33298ab1bf12SLuiz Capitulinohas_environ=no
33308ab1bf12SLuiz Capitulinocat > $TMPC << EOF
33318ab1bf12SLuiz Capitulino#include <unistd.h>
33328ab1bf12SLuiz Capitulinoint main(void) {
3333c075a723SBlue Swirl    environ = 0;
33348ab1bf12SLuiz Capitulino    return 0;
33358ab1bf12SLuiz Capitulino}
33368ab1bf12SLuiz CapitulinoEOF
33378ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
33388ab1bf12SLuiz Capitulino    has_environ=yes
33398ab1bf12SLuiz Capitulinofi
33408ab1bf12SLuiz Capitulino
334176a347e1SRichard Henderson########################################
334276a347e1SRichard Henderson# check if cpuid.h is usable.
334376a347e1SRichard Henderson
334476a347e1SRichard Hendersoncpuid_h=no
334576a347e1SRichard Hendersoncat > $TMPC << EOF
334676a347e1SRichard Henderson#include <cpuid.h>
334776a347e1SRichard Hendersonint main(void) {
334876a347e1SRichard Henderson  return 0;
334976a347e1SRichard Henderson}
335076a347e1SRichard HendersonEOF
335176a347e1SRichard Hendersonif compile_prog "" "" ; then
335276a347e1SRichard Henderson    cpuid_h=yes
335376a347e1SRichard Hendersonfi
335476a347e1SRichard Henderson
3355f540166bSRichard Henderson########################################
3356f540166bSRichard Henderson# check if __[u]int128_t is usable.
3357f540166bSRichard Henderson
3358f540166bSRichard Hendersonint128=no
3359f540166bSRichard Hendersoncat > $TMPC << EOF
3360f540166bSRichard Henderson__int128_t a;
3361f540166bSRichard Henderson__uint128_t b;
3362f540166bSRichard Hendersonint main (void) {
3363f540166bSRichard Henderson  a = a + b;
3364f540166bSRichard Henderson  b = a * b;
3365f540166bSRichard Henderson  return 0;
3366f540166bSRichard Henderson}
3367f540166bSRichard HendersonEOF
3368f540166bSRichard Hendersonif compile_prog "" "" ; then
3369f540166bSRichard Henderson    int128=yes
3370f540166bSRichard Hendersonfi
337176a347e1SRichard Henderson
33721e6e9acaSRichard Henderson########################################
33731e6e9acaSRichard Henderson# check if getauxval is available.
33741e6e9acaSRichard Henderson
33751e6e9acaSRichard Hendersongetauxval=no
33761e6e9acaSRichard Hendersoncat > $TMPC << EOF
33771e6e9acaSRichard Henderson#include <sys/auxv.h>
33781e6e9acaSRichard Hendersonint main(void) {
33791e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
33801e6e9acaSRichard Henderson}
33811e6e9acaSRichard HendersonEOF
33821e6e9acaSRichard Hendersonif compile_prog "" "" ; then
33831e6e9acaSRichard Henderson    getauxval=yes
33841e6e9acaSRichard Hendersonfi
33851e6e9acaSRichard Henderson
3386d2042378SAneesh Kumar K.V##########################################
3387e86ecd4bSJuan Quintela# End of CC checks
3388e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3389e86ecd4bSJuan Quintela
33901d728c39SBlue Swirlif test "$gcov" = "yes" ; then
33911d728c39SBlue Swirl  CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
33921d728c39SBlue Swirl  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
33931d728c39SBlue Swirlelif test "$debug" = "no" ; then
33948be74dc0SAvi Kivity  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3395e86ecd4bSJuan Quintelafi
3396a316e378SJuan Quintela
33971d728c39SBlue Swirl
339820ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
339920ff6c80SAnthony Liguori# enable/disable
340020ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
340120ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
340220ff6c80SAnthony Liguori	zero_malloc="no"
340320ff6c80SAnthony Liguori    else
340420ff6c80SAnthony Liguori	zero_malloc="yes"
340520ff6c80SAnthony Liguori    fi
340620ff6c80SAnthony Liguorifi
340720ff6c80SAnthony Liguori
34086ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
34096ca026cbSPeter Maydellif test "$werror" = "yes"; then
34106ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
34116ca026cbSPeter Maydellfi
34126ca026cbSPeter Maydell
3413e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3414e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
34151156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3416e86ecd4bSJuan Quintela    fi
3417e86ecd4bSJuan Quintelafi
3418e86ecd4bSJuan Quintela
341994dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
342094dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
342194dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
342294dd53c5SGerd Hoffmannelse
342394dd53c5SGerd Hoffmann    POD2MAN="pod2man"
342494dd53c5SGerd Hoffmannfi
342594dd53c5SGerd Hoffmann
3426952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3427952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3428952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3429952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3430952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3431952afb71SBlue Swirl        fi
3432952afb71SBlue Swirl    done
3433952afb71SBlue Swirlfi
3434952afb71SBlue Swirl
343510ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3436528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
3437834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
34385a67135aSbellard
34394b1c11fdSDaniel P. Berrangetools=""
34404b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3441ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
34424b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
34434b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
34444b1c11fdSDaniel P. Berrange  fi
34454b1c11fdSDaniel P. Berrangefi
34464b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3447983eef5aSMeador Inge  if test "$virtfs" != no ; then
3448be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3449983eef5aSMeador Inge      virtfs=yes
345017bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3451983eef5aSMeador Inge    else
3452983eef5aSMeador Inge      if test "$virtfs" = yes; then
345376ad07a4SPeter Maydell        error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3454983eef5aSMeador Inge      fi
345517500370SAndreas Färber      virtfs=no
3456983eef5aSMeador Inge    fi
345717bff52bSM. Mohan Kumar  fi
3458ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3459d138cee9SMichael Roth    if [ "$guest_agent" = "yes" ]; then
346048ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
3461d138cee9SMichael Roth    fi
3462ca35f780SPaolo Bonzini  fi
34634b1c11fdSDaniel P. Berrangefi
3464ca35f780SPaolo Bonzini
3465ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3466ca35f780SPaolo Bonziniroms=
3467ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3468ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3469ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3470ca35f780SPaolo Bonzini  roms="optionrom"
3471ca35f780SPaolo Bonzinifi
3472d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
347339ac8455SDavid Gibson  roms="$roms spapr-rtas"
347439ac8455SDavid Gibsonfi
3475ca35f780SPaolo Bonzini
34769933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
34779933c305SChristian Borntraeger  roms="$roms s390-ccw"
34789933c305SChristian Borntraegerfi
34799933c305SChristian Borntraeger
34805ca9388aSGerd Hoffmann# add pixman flags after all config tests are done
3481a540f158SPeter CrosthwaiteQEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags"
34825ca9388aSGerd Hoffmannlibs_softmmu="$libs_softmmu $pixman_libs"
34835ca9388aSGerd Hoffmann
34847d13299dSbellardecho "Install prefix    $prefix"
3485c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3486f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
34873aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
34888bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
34890f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
34901c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
3491785c23aeSLuiz Capitulinoecho "local state directory   `eval echo $local_statedir`"
349211d9f695Sbellardif test "$mingw32" = "no" ; then
3493f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
349443ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
349511d9f695Sbellardfi
34965a67135aSbellardecho "Source path       $source_path"
34977d13299dSbellardecho "C compiler        $cc"
349883469015Sbellardecho "Host C compiler   $host_cc"
34993c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
35000c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3501a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
35020c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
35037d13299dSbellardecho "make              $make"
35046a882643Spbrookecho "install           $install"
3505c886edfbSBlue Swirlecho "python            $python"
3506e2d8830eSBradif test "$slirp" = "yes" ; then
3507e2d8830eSBrad    echo "smbd              $smbd"
3508e2d8830eSBradfi
3509a98fd896Sbellardecho "host CPU          $cpu"
3510de83cd02Sbellardecho "host big endian   $bigendian"
351197a847bcSbellardecho "target list       $target_list"
3512ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
35137d13299dSbellardecho "gprof enabled     $gprof"
351403b4fe7dSaliguoriecho "sparse enabled    $sparse"
35151625af87Saliguoriecho "strip binaries    $strip_opt"
351605c2a3e7Sbellardecho "profiler          $profiler"
351743ce4dfeSbellardecho "static build      $static"
351885aa5189Sbellardecho "-Werror enabled   $werror"
35195b0753e0Sbellardif test "$darwin" = "yes" ; then
35205b0753e0Sbellard    echo "Cocoa support     $cocoa"
35215b0753e0Sbellardfi
3522e2134eb9SGerd Hoffmannecho "pixman            $pixman"
352397a847bcSbellardecho "SDL support       $sdl"
3524a4ccabcfSAnthony Liguoriecho "GTK support       $gtk"
35254d3b6f6eSbalrogecho "curses support    $curses"
3526769ce76dSAlexander Grafecho "curl support      $curl"
352767b915a5Sbellardecho "mingw32 support   $mingw32"
35280c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
3529eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
35308ff9cbf7Smalcecho "Mixer emulation   $mixemu"
3531983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3532821601eaSJes Sorensenecho "VNC support       $vnc"
3533821601eaSJes Sorensenif test "$vnc" = "yes" ; then
35348d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
35352f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
35362f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3537efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
35387536ee4bSTim Hardeck    echo "VNC WS support    $vnc_ws"
3539821601eaSJes Sorensenfi
35403142255cSblueswir1if test -n "$sparc_cpu"; then
35413142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
35423142255cSblueswir1fi
3543e37630caSaliguoriecho "xen support       $xen"
35442e4d9fb1Saurel32echo "brlapi support    $brlapi"
3545a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3546a25dba17SJuan Quintelaecho "Documentation     $docs"
3547c5937220Spbrook[ ! -z "$uname_release" ] && \
3548c5937220Spbrookecho "uname -r          $uname_release"
3549bd0c5661Spbrookecho "NPTL support      $nptl"
3550379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
355140d6444eSAvi Kivityecho "PIE               $pie"
35528a16d273Sthsecho "vde support       $vde"
35535c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3554758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
355577755340Sthsecho "Install blobs     $blobs"
3556b31a0277SJuan Quintelaecho "KVM support       $kvm"
35579195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3558f652e6afSaurel32echo "fdt support       $fdt"
3559ceb42de8Saliguoriecho "preadv support    $preadv"
35605f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3561e78815a5SAndreas Färberecho "madvise           $madvise"
3562e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
35631e9737daSRichard Hendersonecho "sigev_thread_id   $sigev_thread_id"
3564ee682d27SStefan Weilecho "uuid support      $uuid"
356547e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3566d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
35675e9be92dSNicholas Bellingerecho "vhost-scsi support $vhost_scsi"
356894a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
35699410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
35702e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3571f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3572dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3573111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
35742b2325ffSGerd Hoffmannecho "libusb            $libusb"
357569354a83SHans de Goedeecho "usb net redir     $usb_redir"
3576b1e5fff4SMichael Walleecho "GLX support       $glx"
3577c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3578d138cee9SMichael Rothecho "build guest agent $guest_agent"
3579f794573eSEduardo Otuboecho "seccomp support   $seccomp"
35807c2acc70SPeter Maydellecho "coroutine backend $coroutine"
3581eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
3582583f6e7bSStefan Hajnocziecho "virtio-blk-data-plane $virtio_blk_data_plane"
35831d728c39SBlue Swirlecho "gcov              $gcov_tool"
35841d728c39SBlue Swirlecho "gcov enabled      $gcov"
3585ab214c29SStefan Bergerecho "TPM support       $tpm"
35860a12ec87SRichard W.M. Jonesecho "libssh2 support   $libssh2"
35873b8acc11SPaolo Bonziniecho "TPM passthrough   $tpm_passthrough"
35883556c233SPaolo Bonziniecho "QOM debugging     $qom_cast_debug"
358967b915a5Sbellard
35901ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
359124b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3592e8cd23deSbellardfi
359397a847bcSbellard
359498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
35954bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
359697a847bcSbellard
3597dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
3598dbd99ae3SStefan Weil
359998ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
360098ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
360198ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
360298ec69acSJuan Quintelaecho >> $config_host_mak
360398ec69acSJuan Quintela
3604e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
360599d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
360699d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
36073aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
36088bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
36090f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
361099d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
361199d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
361222d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
36139afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
36149afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
3615785c23aeSLuiz Capitulinoecho "qemu_localstatedir=$local_statedir" >> $config_host_mak
3616f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
3617f9943cd5SGerd Hoffmannecho "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
3618f9943cd5SGerd Hoffmannecho "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
3619834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
3620f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
3621804edf29SJuan Quintela
362298ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3623727e5283SPaolo Bonzini
3624727e5283SPaolo Bonzinicase "$cpu" in
3625df5e0ef7SRichard Henderson  arm|i386|x86_64|ppc)
3626727e5283SPaolo Bonzini    # The TCG interpreter currently does not support ld/st optimization.
3627727e5283SPaolo Bonzini    if test "$tcg_interpreter" = "no" ; then
3628727e5283SPaolo Bonzini        echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_host_mak
3629727e5283SPaolo Bonzini    fi
3630727e5283SPaolo Bonzini  ;;
3631727e5283SPaolo Bonziniesac
3632f8393946Saurel32if test "$debug_tcg" = "yes" ; then
36332358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3634f8393946Saurel32fi
36351625af87Saliguoriif test "$strip_opt" = "yes" ; then
363652ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
36371625af87Saliguorifi
36387d13299dSbellardif test "$bigendian" = "yes" ; then
3639e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
364097a847bcSbellardfi
364167b915a5Sbellardif test "$mingw32" = "yes" ; then
364298ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
36439fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
36449fe6de94SBlue Swirl  version_major=${rc_version%%.*}
36459fe6de94SBlue Swirl  rc_version=${rc_version#*.}
36469fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
36479fe6de94SBlue Swirl  rc_version=${rc_version#*.}
36489fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
36499fe6de94SBlue Swirl  version_micro=0
36509fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
36519fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3652210fa556Spbrookelse
365335f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3654210fa556Spbrookfi
3655128ab2ffSblueswir1
3656dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3657dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3658dffcb71cSMark McLoughlinfi
3659dffcb71cSMark McLoughlin
366083fb7adfSbellardif test "$darwin" = "yes" ; then
366198ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
366283fb7adfSbellardfi
3663b29fe3edSmalc
3664b29fe3edSmalcif test "$aix" = "yes" ; then
366598ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
3666b29fe3edSmalcfi
3667b29fe3edSmalc
3668ec530c81Sbellardif test "$solaris" = "yes" ; then
366998ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
36702358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
36710475a5caSths  if test "$needs_libsunmath" = "yes" ; then
367275b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
36730475a5caSths  fi
3674ec530c81Sbellardfi
3675179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3676179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3677179cf400SAndreas Färberfi
367897a847bcSbellardif test "$static" = "yes" ; then
367998ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
368097a847bcSbellardfi
36811ba16968SStefan Weilif test "$profiler" = "yes" ; then
36822358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
368305c2a3e7Sbellardfi
3684c20709aaSbellardif test "$slirp" = "yes" ; then
368598ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
3686e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3687c20709aaSbellardfi
36888a16d273Sthsif test "$vde" = "yes" ; then
368998ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
36908a16d273Sthsfi
369147e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
369247e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
369347e98658SCorey Bryantfi
36942358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
36950c58ac1cSmalcfor drv in $audio_drv_list; do
3696bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
369798ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
3698923e4521Smalc    if test "$drv" = "fmod"; then
36997aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3700fb065187Sbellard    fi
37010c58ac1cSmalcdone
370267f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
370367f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
370467f86e8eSJuan Quintelafi
3705d5631638Smalcif test "$audio_win_int" = "yes" ; then
3706d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3707d5631638Smalcfi
3708eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
37098ff9cbf7Smalcif test "$mixemu" = "yes" ; then
371098ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
37118ff9cbf7Smalcfi
3712821601eaSJes Sorensenif test "$vnc" = "yes" ; then
3713821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
3714821601eaSJes Sorensenfi
37158d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
371698ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
37178d5d2d4cSthsfi
37182f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
371998ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
37202f9606b3Saliguorifi
3721821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
37222f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
37232f6f5c7aSCorentin Charyfi
3724821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
3725efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3726efe556adSCorentin Charyfi
37277536ee4bSTim Hardeckif test "$vnc_ws" = "yes" ; then
37287536ee4bSTim Hardeck  echo "CONFIG_VNC_WS=y" >> $config_host_mak
37297536ee4bSTim Hardeck  echo "VNC_WS_CFLAGS=$vnc_ws_cflags" >> $config_host_mak
37307536ee4bSTim Hardeckfi
373176655d6dSaliguoriif test "$fnmatch" = "yes" ; then
37322358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
373376655d6dSaliguorifi
3734ee682d27SStefan Weilif test "$uuid" = "yes" ; then
3735ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
3736ee682d27SStefan Weilfi
3737dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3738dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3739dce512deSChristoph Hellwigfi
3740b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
374198ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
37422358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
374398ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
374498ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
3745a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
374698ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
3747cc8ae6deSpbrookfi
37481ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
374998ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
37508ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
375149ecc3faSbellardfi
375249ecc3faSbellardif test "$cocoa" = "yes" ; then
375398ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
375449ecc3faSbellardfi
37554d3b6f6eSbalrogif test "$curses" = "yes" ; then
375698ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
3757ab4e5602SJan Kiszkafi
37583b3f24adSaurel32if test "$atfile" = "yes" ; then
37592358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
37603b3f24adSaurel32fi
3761ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
37622358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3763ebc996f3SRiku Voipiofi
3764099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
37652358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
3766099d6b0fSRiku Voipiofi
376740ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
376840ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
376940ff6d7eSKevin Wolffi
37703ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
37712358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
37723ce34dfbSvibisreenivasanfi
3773c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
3774c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
3775c2882b96SRiku Voipiofi
3776d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
3777d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3778d0927938SUlrich Hechtfi
37793d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
37803d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
37813d4fa43eSKusanagi Kouichifi
3782c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
3783c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3784c727f47dSPeter Maydellfi
3785dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
3786dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
3787dace20dcSPeter Maydellfi
3788d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
3789d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
3790d0927938SUlrich Hechtfi
37913b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
37923b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
37933b6edd16SPeter Maydellfi
37943b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
37953b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
37963b6edd16SPeter Maydellfi
37973b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
37983b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
37993b6edd16SPeter Maydellfi
3800a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
3801a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
3802a8fd1abaSPeter Maydellfi
38033b3f24adSaurel32if test "$inotify" = "yes" ; then
38042358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
38053b3f24adSaurel32fi
3806c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3807c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3808c05c7a73SRiku Voipiofi
38096ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
38106ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
38116ae9a1f4SJuan Quintelafi
38126ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
38136ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
38146ae9a1f4SJuan Quintelafi
3815769ce76dSAlexander Grafif test "$curl" = "yes" ; then
381698ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3817b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3818769ce76dSAlexander Graffi
38192e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
382098ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
38212e4d9fb1Saurel32fi
3822fb599c9aSbalrogif test "$bluez" = "yes" ; then
382398ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3824ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3825fb599c9aSbalrogfi
3826e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3827a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
3828a4ccabcfSAnthony Liguori  echo "CONFIG_GTK=y" >> $config_host_mak
3829a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
3830a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
3831a4ccabcfSAnthony Liguorifi
3832e37630caSaliguoriif test "$xen" = "yes" ; then
38336dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3834d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3835e37630caSaliguorifi
38365c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
38375c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
38385c6c3a6cSChristoph Hellwigfi
3839758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3840758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3841758e8e38SVenkateswararao Jujjuri (JV)fi
38424f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
38434f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
38444f26f2b6SAvi Kivityfi
3845983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
3846758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
3847758e8e38SVenkateswararao Jujjuri (JV)fi
38485e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
38495e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
38505e9be92dSNicholas Bellingerfi
385177755340Sthsif test "$blobs" = "yes" ; then
385298ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
385377755340Sthsfi
3854bf9298b9Saliguoriif test "$iovec" = "yes" ; then
38552358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3856bf9298b9Saliguorifi
3857ceb42de8Saliguoriif test "$preadv" = "yes" ; then
38582358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3859ceb42de8Saliguorifi
3860f652e6afSaurel32if test "$fdt" = "yes" ; then
38613f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3862f652e6afSaurel32fi
3863dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3864dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3865dcc38d1cSMarcelo Tosattifi
38669195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
38679195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
38689195b2c2SStefan Weilfi
38695f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
38705f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
38715f6b9e8fSBlue Swirlfi
3872e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3873e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3874e78815a5SAndreas Färberfi
3875e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3876e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3877e78815a5SAndreas Färberfi
38781e9737daSRichard Hendersonif test "$sigev_thread_id" = "yes" ; then
38791e9737daSRichard Henderson  echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
38801e9737daSRichard Hendersonfi
388197a847bcSbellard
3882cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3883cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3884cd4ec0b4SGerd Hoffmannfi
3885cd4ec0b4SGerd Hoffmann
3886111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3887111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3888ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3889ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3890111a38b0SRobert Relyeafi
3891111a38b0SRobert Relyea
38922b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
38932b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
38942b2325ffSGerd Hoffmannfi
38952b2325ffSGerd Hoffmann
389669354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
389769354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
389869354a83SHans de Goedefi
389969354a83SHans de Goede
3900b1e5fff4SMichael Walleif test "$glx" = "yes" ; then
3901b1e5fff4SMichael Walle  echo "CONFIG_GLX=y" >> $config_host_mak
39022b6b7099SPaolo Bonzini  echo "GLX_LIBS=$glx_libs" >> $config_host_mak
390320ff075bSMichael Wallefi
390420ff075bSMichael Walle
3905c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3906c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3907c589b249SRonnie Sahlbergfi
3908c589b249SRonnie Sahlberg
3909f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
3910f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
3911f794573eSEduardo Otubofi
3912f794573eSEduardo Otubo
391383fb7adfSbellard# XXX: suppress that
39147d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
39152358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
39167d3505c5Sbellardfi
39177d3505c5Sbellard
39182358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3919c5937220Spbrook
392020ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
392120ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
392220ff6c80SAnthony Liguorifi
39233556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
39243556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
39253556c233SPaolo Bonzinifi
3926f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3927f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3928f27aaf4bSChristian Brunnerfi
392920ff6c80SAnthony Liguori
39307c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
3931d0e2fce5SAneesh Kumar K.V
3932d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
3933d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3934d2042378SAneesh Kumar K.Vfi
3935d2042378SAneesh Kumar K.V
3936e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
3937e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3938e06a765eSHarsh Prateek Borafi
3939e06a765eSHarsh Prateek Bora
3940cc6e3ca9SGerd Hoffmannif test "$pragma_diagnostic_available" = "yes" ; then
3941cc6e3ca9SGerd Hoffmann  echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
394206d71fa1SPeter Maydellfi
394306d71fa1SPeter Maydell
39443f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
39453f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
39463f4349dcSKevin Wolffi
39473f4349dcSKevin Wolf
39488ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
39498ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
39508ab1bf12SLuiz Capitulinofi
39518ab1bf12SLuiz Capitulino
395276a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
395376a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
395476a347e1SRichard Hendersonfi
395576a347e1SRichard Henderson
3956f540166bSRichard Hendersonif test "$int128" = "yes" ; then
3957f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
3958f540166bSRichard Hendersonfi
3959f540166bSRichard Henderson
39601e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
39611e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
39621e6e9acaSRichard Hendersonfi
39631e6e9acaSRichard Henderson
3964eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
3965eb100396SBharata B Rao  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
3966eb100396SBharata B Raofi
3967eb100396SBharata B Rao
39680a12ec87SRichard W.M. Jonesif test "$libssh2" = "yes" ; then
39690a12ec87SRichard W.M. Jones  echo "CONFIG_LIBSSH2=y" >> $config_host_mak
39700a12ec87SRichard W.M. Jonesfi
39710a12ec87SRichard W.M. Jones
3972583f6e7bSStefan Hajnocziif test "$virtio_blk_data_plane" = "yes" ; then
39736e790746SPaolo Bonzini  echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
3974583f6e7bSStefan Hajnoczifi
3975583f6e7bSStefan Hajnoczi
397668063649Sblueswir1# USB host support
397768063649Sblueswir1case "$usb" in
397868063649Sblueswir1linux)
39794075975dSGerd Hoffmann  echo "HOST_USB=linux legacy" >> $config_host_mak
398068063649Sblueswir1;;
398168063649Sblueswir1bsd)
398298ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
398368063649Sblueswir1;;
39842b2325ffSGerd Hoffmannlibusb)
39852b2325ffSGerd Hoffmann  if test "$linux" = "yes"; then
39862b2325ffSGerd Hoffmann    echo "HOST_USB=libusb linux legacy" >> $config_host_mak
39872b2325ffSGerd Hoffmann  else
39882b2325ffSGerd Hoffmann    echo "HOST_USB=libusb legacy" >> $config_host_mak
39892b2325ffSGerd Hoffmann  fi
39902b2325ffSGerd Hoffmann;;
399168063649Sblueswir1*)
399298ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
399368063649Sblueswir1;;
399468063649Sblueswir1esac
399568063649Sblueswir1
39963b8acc11SPaolo Bonzini# TPM passthrough support?
39973b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
39983b8acc11SPaolo Bonzini  echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
39993b8acc11SPaolo Bonzini  if test "$tpm_passthrough" = "yes"; then
40003b8acc11SPaolo Bonzini    echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
40013b8acc11SPaolo Bonzini  fi
40023b8acc11SPaolo Bonzinifi
40033b8acc11SPaolo Bonzini
4004e4858974SLluís# use default implementation for tracing backend-specific routines
4005e4858974SLluístrace_default=yes
400694a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
40076d8a764eSLluísif test "$trace_backend" = "nop"; then
40086d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
400922890ab5SPrerna Saxenafi
40109410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
40116d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
4012e4858974SLluís  trace_default=no
40136d8a764eSLluís  # Set the appropriate trace file.
4014953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
40159410b56cSPrerna Saxenafi
40166d8a764eSLluísif test "$trace_backend" = "stderr"; then
40176d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
40189a82b6a5SLluís  trace_default=no
40196d8a764eSLluísfi
40206d8a764eSLluísif test "$trace_backend" = "ust"; then
40216d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
40226d8a764eSLluísfi
40236d8a764eSLluísif test "$trace_backend" = "dtrace"; then
40246d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
40256d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
40266d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
40276d8a764eSLluís  fi
4028c276b17dSDaniel P. Berrangefi
4029781e9545SEiichi Tsukataif test "$trace_backend" = "ftrace"; then
4030781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
4031781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4032781e9545SEiichi Tsukata    trace_default=no
4033781e9545SEiichi Tsukata  else
4034781e9545SEiichi Tsukata    feature_not_found "ftrace(trace backend)"
4035781e9545SEiichi Tsukata  fi
4036781e9545SEiichi Tsukatafi
40379410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
4038e4858974SLluísif test "$trace_default" = "yes"; then
4039e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
4040e4858974SLluísfi
40419410b56cSPrerna Saxena
40425b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
40435b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
40445b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
40455b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
40465b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
40475b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
40485b5e3037SPaolo Bonzinielif test "$ARCH" = "x86_64" ; then
40495b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
40505b5e3037SPaolo Bonzinielse
40515b5e3037SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
40525b5e3037SPaolo Bonzinifi
40535b5e3037SPaolo BonziniQEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
40545b5e3037SPaolo Bonzini
405598ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
405698ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4057804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4058804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
40591901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
40601901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
406121655882SPaolo Bonziniif test -n "$libtool"; then
406221655882SPaolo Bonzini  echo "INSTALL_PROG=\$(LIBTOOL) --mode=install $install -c -m 0755" >> $config_host_mak
406321655882SPaolo Bonzini  echo "INSTALL_LIB=\$(LIBTOOL) --mode=install $install -c -m 0644" >> $config_host_mak
406421655882SPaolo Bonzinielse
40651901cb14SBrad  echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
406621655882SPaolo Bonzini  echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
406721655882SPaolo Bonzinifi
4068c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
4069804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
40702b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
4071804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
40723c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
4073804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
40743dd46c78SBlue Swirlecho "AS=$as" >> $config_host_mak
40753dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4076804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4077804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
40789fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
407944dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
4080e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
4081a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
4082f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
4083e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
4084e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
4085e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
4086e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
4087e39f0062SPaolo Bonzinifi
408842da6041SGerd Hoffmannif test "$cross_prefix" != ""; then
408942da6041SGerd Hoffmann  echo "AUTOCONF_HOST := --host=${cross_prefix%-}"     >> $config_host_mak
409042da6041SGerd Hoffmannelse
409142da6041SGerd Hoffmann  echo "AUTOCONF_HOST := "                             >> $config_host_mak
409242da6041SGerd Hoffmannfi
4093e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
409437746c5eSMarc-André Lureauecho "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
409573da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
40963e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
4097804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
4098957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
409994dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
4100cbdd1999SPaolo Bonziniecho "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
41011d728c39SBlue Swirlif test "$gcov" = "yes" ; then
41021d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
41031d728c39SBlue Swirl  echo "GCOV=$gcov_tool" >> $config_host_mak
41041d728c39SBlue Swirlfi
4105804edf29SJuan Quintela
41064bf6b55bSJuan Quintela# generate list of library paths for linker script
41074bf6b55bSJuan Quintela
41084bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
41094bf6b55bSJuan Quintela
41104bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
41114bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
41124bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
41134bf6b55bSJuan Quintela  else
41144bf6b55bSJuan Quintela    rm ${config_host_ld}~
41154bf6b55bSJuan Quintela  fi
41164bf6b55bSJuan Quintelafi
41174bf6b55bSJuan Quintela
41186efd7517SPeter Maydell# use included Linux headers
41196efd7517SPeter Maydellif test "$linux" = "yes" ; then
4120a307beb6SAndreas Färber  mkdir -p linux-headers
41216efd7517SPeter Maydell  case "$cpu" in
41226efd7517SPeter Maydell  i386|x86_64)
412308312a63SPeter Maydell    linux_arch=x86
41246efd7517SPeter Maydell    ;;
41256efd7517SPeter Maydell  ppcemb|ppc|ppc64)
412608312a63SPeter Maydell    linux_arch=powerpc
41276efd7517SPeter Maydell    ;;
41286efd7517SPeter Maydell  s390x)
412908312a63SPeter Maydell    linux_arch=s390
413008312a63SPeter Maydell    ;;
413108312a63SPeter Maydell  *)
413208312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
413308312a63SPeter Maydell    linux_arch="$cpu"
41346efd7517SPeter Maydell    ;;
41356efd7517SPeter Maydell  esac
413608312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
413708312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
413808312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
413908312a63SPeter Maydell    fi
41406efd7517SPeter Maydellfi
41416efd7517SPeter Maydell
414297a847bcSbellardfor target in $target_list; do
414397a847bcSbellardtarget_dir="$target"
414425be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
4145600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
414697a847bcSbellardtarget_bigendian="no"
41471f3d3c8fSJuan Quintela
4148ea2d6a39SJuan Quintelacase "$target_arch2" in
4149d15a9c23SAnthony Green  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
4150ea2d6a39SJuan Quintela  target_bigendian=yes
4151ea2d6a39SJuan Quintela  ;;
4152ea2d6a39SJuan Quintelaesac
415397a847bcSbellardtarget_softmmu="no"
4154997344f3Sbellardtarget_user_only="no"
4155831b7825Sthstarget_linux_user="no"
415684778508Sblueswir1target_bsd_user="no"
41579e407a85Spbrookcase "$target" in
4158600309b6SBlue Swirl  ${target_arch2}-softmmu)
41599e407a85Spbrook    target_softmmu="yes"
41609e407a85Spbrook    ;;
4161600309b6SBlue Swirl  ${target_arch2}-linux-user)
41629c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
416376ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a Linux host"
41649c7a4202SBlue Swirl    fi
41659e407a85Spbrook    target_user_only="yes"
41669e407a85Spbrook    target_linux_user="yes"
41679e407a85Spbrook    ;;
4168600309b6SBlue Swirl  ${target_arch2}-bsd-user)
41699cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
417076ad07a4SPeter Maydell      error_exit "Target '$target' is only available on a BSD host"
41719c7a4202SBlue Swirl    fi
417284778508Sblueswir1    target_user_only="yes"
417384778508Sblueswir1    target_bsd_user="yes"
417484778508Sblueswir1    ;;
41759e407a85Spbrook  *)
417676ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
41779e407a85Spbrook    exit 1
41789e407a85Spbrook    ;;
41799e407a85Spbrookesac
4180831b7825Sths
418197a847bcSbellardmkdir -p $target_dir
418225be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
418397a847bcSbellard
4184e5fe0c52Spbrookbflt="no"
4185bd0c5661Spbrooktarget_nptl="no"
4186600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
418756aebc89Spbrookgdb_xml_files=""
41887ba1e619Saliguori
4189938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
41906acff7daSJuan QuintelaTARGET_BASE_ARCH=""
4191e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
4192e73aae67SJuan Quintela
4193600309b6SBlue Swirlcase "$target_arch2" in
41942408a527Saurel32  i386)
41952408a527Saurel32  ;;
41962408a527Saurel32  x86_64)
41976acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
41982408a527Saurel32  ;;
41992408a527Saurel32  alpha)
4200a4b388ffSRichard Henderson    target_nptl="yes"
42012408a527Saurel32  ;;
42022408a527Saurel32  arm|armeb)
4203b498c8a0SJuan Quintela    TARGET_ARCH=arm
4204e5fe0c52Spbrook    bflt="yes"
4205bd0c5661Spbrook    target_nptl="yes"
420656aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
42072408a527Saurel32  ;;
42082408a527Saurel32  cris)
4209253bd7f8Sedgar_igl    target_nptl="yes"
42102408a527Saurel32  ;;
4211613a22c9SMichael Walle  lm32)
4212613a22c9SMichael Walle  ;;
42132408a527Saurel32  m68k)
42140938cda5Saurel32    bflt="yes"
421556aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
42162408a527Saurel32  ;;
4217877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
4218877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
421972b675caSEdgar E. Iglesias    bflt="yes"
422072b675caSEdgar E. Iglesias    target_nptl="yes"
422172b675caSEdgar E. Iglesias  ;;
42222408a527Saurel32  mips|mipsel)
4223b498c8a0SJuan Quintela    TARGET_ARCH=mips
422425be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
4225f04dc72fSPaul Brook    target_nptl="yes"
42262408a527Saurel32  ;;
42272408a527Saurel32  mipsn32|mipsn32el)
4228597e2cecSRichard Henderson    TARGET_ARCH=mips64
42296acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
423025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
4231597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
42322408a527Saurel32  ;;
42332408a527Saurel32  mips64|mips64el)
4234b498c8a0SJuan Quintela    TARGET_ARCH=mips64
42356acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
423625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
42372408a527Saurel32  ;;
4238d15a9c23SAnthony Green  moxie)
4239d15a9c23SAnthony Green  ;;
4240e67db06eSJia Liu  or32)
4241e67db06eSJia Liu    TARGET_ARCH=openrisc
4242e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
4243e67db06eSJia Liu  ;;
42442408a527Saurel32  ppc)
4245c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
4246d6630708SNathan Froyd    target_nptl="yes"
42472408a527Saurel32  ;;
42482408a527Saurel32  ppcemb)
42496acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4250e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4251c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
4252d6630708SNathan Froyd    target_nptl="yes"
42532408a527Saurel32  ;;
42542408a527Saurel32  ppc64)
42556acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4256e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
4257c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
42582408a527Saurel32  ;;
42592408a527Saurel32  ppc64abi32)
4260b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
42616acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
4262e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
426325be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
4264c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
42652408a527Saurel32  ;;
42662408a527Saurel32  sh4|sh4eb)
4267b498c8a0SJuan Quintela    TARGET_ARCH=sh4
42684dbed897Spbrook    bflt="yes"
42690b6d3ae0Saurel32    target_nptl="yes"
42702408a527Saurel32  ;;
42712408a527Saurel32  sparc)
42722408a527Saurel32  ;;
42732408a527Saurel32  sparc64)
42746acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
42752408a527Saurel32  ;;
42762408a527Saurel32  sparc32plus)
4277b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
42786acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
4279e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
428025be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
42812408a527Saurel32  ;;
428224e804ecSAlexander Graf  s390x)
4283bc434676SUlrich Hecht    target_nptl="yes"
428424e804ecSAlexander Graf  ;;
4285d2fbca94SGuan Xuetao  unicore32)
4286d2fbca94SGuan Xuetao  ;;
4287cfa550c6SMax Filippov  xtensa|xtensaeb)
4288cfa550c6SMax Filippov    TARGET_ARCH=xtensa
4289cfa550c6SMax Filippov  ;;
42902408a527Saurel32  *)
429176ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
42922408a527Saurel32  ;;
42932408a527Saurel32esac
42945e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
42955e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
42965e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
42975e8861a0SPaolo Bonzinifi
42985e8861a0SPaolo Bonzini
42995e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
43005e8861a0SPaolo Bonzini
430199afc91dSDaniel P. Berrangeupper() {
430299afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
430399afc91dSDaniel P. Berrange}
430499afc91dSDaniel P. Berrange
430525be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
430699afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
430725be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
430825be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
430999afc91dSDaniel P. Berrangeecho "TARGET_TYPE=TARGET_TYPE_`upper $target_arch2`" >> $config_target_mak
431025be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
4311e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
4312e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
4313e6e91b9cSJuan Quintelafi
431425be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
43151b0c87fcSJuan Quintelacase "$target_arch2" in
43161b0c87fcSJuan Quintela  i386|x86_64)
43171b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
431825be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
4319eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
4320eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
4321eb6fda0fSAnthony PERARD      fi
4322432d268cSJun Nakajima    fi
432359d21e53SAlexander Graf    ;;
432459d21e53SAlexander Graf  *)
43251b0c87fcSJuan Quintelaesac
4326c59249f9SJuan Quintelacase "$target_arch2" in
432768b05c42SPeter Maydell  arm|i386|x86_64|ppcemb|ppc|ppc64|s390x)
4328c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
4329c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
4330c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
4331c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
43325f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
4333adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
4334adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
4335c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
4336c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
433725be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
43381ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
4339d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
4340d5970055SMichael S. Tsirkin      fi
4341c59249f9SJuan Quintela    fi
4342c59249f9SJuan Quintelaesac
4343fae001f5SWen Congyangcase "$target_arch2" in
4344fae001f5SWen Congyang  i386|x86_64)
4345fae001f5SWen Congyang    echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
4346fae001f5SWen Congyangesac
4347de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
434825be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
434997a847bcSbellardfi
435097a847bcSbellardif test "$target_softmmu" = "yes" ; then
435125be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
43529fecbed0SWen Congyang  case "$target_arch2" in
43539fecbed0SWen Congyang    i386|x86_64)
43549fecbed0SWen Congyang      echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
43559fecbed0SWen Congyang  esac
4356de83cd02Sbellardfi
4357997344f3Sbellardif test "$target_user_only" = "yes" ; then
435825be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
4359a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
4360997344f3Sbellardfi
4361831b7825Sthsif test "$target_linux_user" = "yes" ; then
436225be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
4363831b7825Sthsfi
436456aebc89Spbrooklist=""
436556aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
436656aebc89Spbrook  for x in $gdb_xml_files; do
436756aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
436856aebc89Spbrook  done
436925be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
43703d0f1517SJuan Quintelafi
4371de83cd02Sbellard
4372e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
437325be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
4374e5fe0c52Spbrookfi
4375bd0c5661Spbrookif test "$target_user_only" = "yes" \
4376bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
437725be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
4378bd0c5661Spbrookfi
4379379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
438025be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
4381379f6698SPaul Brookfi
438284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
438325be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
438484778508Sblueswir1fi
43855b0753e0Sbellard
43864afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
4387fa282484SJuan Quintela
43884afddb55SJuan Quintelacflags=""
4389fa282484SJuan Quintelaldflags=""
43909b8e111fSJuan Quintela
439164656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
439264656024SJuan Quintela  case "$i" in
439364656024SJuan Quintela  alpha)
439425be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
439576cad711SPaolo Bonzini    echo "CONFIG_ALPHA_DIS=y"  >> config-all-disas.mak
439664656024SJuan Quintela  ;;
439764656024SJuan Quintela  arm)
439825be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
439976cad711SPaolo Bonzini    echo "CONFIG_ARM_DIS=y"  >> config-all-disas.mak
440064656024SJuan Quintela  ;;
440164656024SJuan Quintela  cris)
440225be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
440376cad711SPaolo Bonzini    echo "CONFIG_CRIS_DIS=y"  >> config-all-disas.mak
440464656024SJuan Quintela  ;;
440564656024SJuan Quintela  hppa)
440625be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
440776cad711SPaolo Bonzini    echo "CONFIG_HPPA_DIS=y"  >> config-all-disas.mak
440864656024SJuan Quintela  ;;
440964656024SJuan Quintela  i386|x86_64)
441025be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
441176cad711SPaolo Bonzini    echo "CONFIG_I386_DIS=y"  >> config-all-disas.mak
441264656024SJuan Quintela  ;;
4413903ec55cSAurelien Jarno  ia64*)
4414903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
441576cad711SPaolo Bonzini    echo "CONFIG_IA64_DIS=y"  >> config-all-disas.mak
4416903ec55cSAurelien Jarno  ;;
441779368f49SMichael Walle  lm32)
441879368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
441976cad711SPaolo Bonzini    echo "CONFIG_LM32_DIS=y"  >> config-all-disas.mak
442079368f49SMichael Walle  ;;
442164656024SJuan Quintela  m68k)
442225be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
442376cad711SPaolo Bonzini    echo "CONFIG_M68K_DIS=y"  >> config-all-disas.mak
442464656024SJuan Quintela  ;;
4425877fdc12SEdgar E. Iglesias  microblaze*)
442625be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
442776cad711SPaolo Bonzini    echo "CONFIG_MICROBLAZE_DIS=y"  >> config-all-disas.mak
442864656024SJuan Quintela  ;;
442964656024SJuan Quintela  mips*)
443025be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
443176cad711SPaolo Bonzini    echo "CONFIG_MIPS_DIS=y"  >> config-all-disas.mak
443264656024SJuan Quintela  ;;
4433d15a9c23SAnthony Green  moxie*)
4434d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> $config_target_mak
4435d15a9c23SAnthony Green    echo "CONFIG_MOXIE_DIS=y"  >> config-all-disas.mak
4436d15a9c23SAnthony Green  ;;
4437e67db06eSJia Liu  or32)
4438e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
443976cad711SPaolo Bonzini    echo "CONFIG_OPENRISC_DIS=y"  >> config-all-disas.mak
4440e67db06eSJia Liu  ;;
444164656024SJuan Quintela  ppc*)
444225be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
444376cad711SPaolo Bonzini    echo "CONFIG_PPC_DIS=y"  >> config-all-disas.mak
444464656024SJuan Quintela  ;;
444524e804ecSAlexander Graf  s390*)
444625be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
444776cad711SPaolo Bonzini    echo "CONFIG_S390_DIS=y"  >> config-all-disas.mak
444864656024SJuan Quintela  ;;
444964656024SJuan Quintela  sh4)
445025be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
445176cad711SPaolo Bonzini    echo "CONFIG_SH4_DIS=y"  >> config-all-disas.mak
445264656024SJuan Quintela  ;;
445364656024SJuan Quintela  sparc*)
445425be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
445576cad711SPaolo Bonzini    echo "CONFIG_SPARC_DIS=y"  >> config-all-disas.mak
445664656024SJuan Quintela  ;;
4457cfa550c6SMax Filippov  xtensa*)
4458cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
445976cad711SPaolo Bonzini    echo "CONFIG_XTENSA_DIS=y"  >> config-all-disas.mak
4460cfa550c6SMax Filippov  ;;
446164656024SJuan Quintela  esac
446264656024SJuan Quinteladone
44639195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
44649195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
446576cad711SPaolo Bonzini  echo "CONFIG_TCI_DIS=y"  >> config-all-disas.mak
44669195b2c2SStefan Weilfi
446764656024SJuan Quintela
44686ee7126fSJuan Quintelacase "$ARCH" in
44696ee7126fSJuan Quintelaalpha)
44706ee7126fSJuan Quintela  # Ensure there's only a single GP
44716ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
44726ee7126fSJuan Quintela;;
44736ee7126fSJuan Quintelaesac
44746ee7126fSJuan Quintela
4475d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
447625be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4477d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4478d02c1db3SJuan Quintela    cflags="-p $cflags"
4479d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4480d02c1db3SJuan Quintela  fi
4481d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4482d02c1db3SJuan Quintela    ldflags="-p $ldflags"
448325be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4484d02c1db3SJuan Quintela  fi
4485d02c1db3SJuan Quintelafi
4486d02c1db3SJuan Quintela
44879195b2c2SStefan Weilif test "$ARCH" = "tci"; then
44889195b2c2SStefan Weil  linker_script=""
44899195b2c2SStefan Weilelse
4490c1c93672SPaolo Bonzini  linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/ldscripts/\$(ARCH).ld"
44919195b2c2SStefan Weilfi
44929195b2c2SStefan Weil
44939b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4494fa282484SJuan Quintela  case "$ARCH" in
44954d58be06SRichard Henderson  alpha | s390x)
44964d58be06SRichard Henderson    # The default placement of the application is fine.
44974d58be06SRichard Henderson    ;;
4498fd76e73aSRichard Henderson  *)
4499322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
4500fa282484SJuan Quintela    ;;
4501fa282484SJuan Quintela  esac
4502fa282484SJuan Quintelafi
4503fa282484SJuan Quintela
450425be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
450525be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4506fa282484SJuan Quintela
450797a847bcSbellarddone # for target in $targets
45087d13299dSbellard
4509b776eca1SGerd Hoffmannif [ "$pixman" = "internal" ]; then
4510b776eca1SGerd Hoffmann  echo "config-host.h: subdir-pixman" >> $config_host_mak
4511b776eca1SGerd Hoffmannfi
4512b776eca1SGerd Hoffmann
4513a540f158SPeter Crosthwaiteif [ "$dtc_internal" = "yes" ]; then
4514a540f158SPeter Crosthwaite  echo "config-host.h: subdir-dtc" >> $config_host_mak
4515a540f158SPeter Crosthwaitefi
4516a540f158SPeter Crosthwaite
4517d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
4518c4efe1caSAnthony LiguoriDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos"
45199933c305SChristian BorntraegerDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
45202d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
45212dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
4522c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4523c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
4524834574eaSAnthony LiguoriFILES="$FILES tests/tcg/lm32/Makefile po/Makefile"
4525ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4526446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
45279933c305SChristian BorntraegerFILES="$FILES pc-bios/s390-ccw/Makefile"
45282d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
45294652b792SJan KiszkaFILES="$FILES pc-bios/qemu-icon.bmp"
4530753d11f2SRichard Hendersonfor bios_file in \
4531753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
45325acc2ec0SGerd Hoffmann    $source_path/pc-bios/*.aml \
4533753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4534753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4535e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
4536753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4537753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4538753d11f2SRichard Hendersondo
45397ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
45407ea78b74SJan Kiszkadone
4541d1807a4fSPaolo Bonzinimkdir -p $DIRS
45427d13299dSbellardfor f in $FILES ; do
454372b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4544f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4545f9245e10SPeter Maydell    fi
45467d13299dSbellarddone
45471ad2134fSPaul Brook
4548c34ebfdcSAnthony Liguori# temporary config to build submodules
45492d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4550c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
455137116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4552c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
45533dd46c78SBlue Swirl    echo "AS=$as" >> $config_mak
4554c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4555c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
45563dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
4557c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4558c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
4559c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4560c34ebfdcSAnthony Liguoridone
4561c34ebfdcSAnthony Liguori
4562b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4563b40292e7SJan Kiszka  mkdir -p QMP
4564b40292e7SJan Kiszkafi
4565