xref: /openbmc/qemu/configure (revision eb100396b9d2658e8bf9cdc14bfcb16a9152f464)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
57d13299dSbellard# set temporary file name
67d13299dSbellardif test ! -z "$TMPDIR" ; then
77d13299dSbellard    TMPDIR1="${TMPDIR}"
87d13299dSbellardelif test ! -z "$TEMPDIR" ; then
97d13299dSbellard    TMPDIR1="${TEMPDIR}"
107d13299dSbellardelse
117d13299dSbellard    TMPDIR1="/tmp"
127d13299dSbellardfi
137d13299dSbellard
143ef693a0SbellardTMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
153ef693a0SbellardTMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16a91b857cSmalcTMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
177d13299dSbellard
180ba8681eSLoïc Minier# NB: do not call "exit" in the trap handler; this is buggy with some shells;
190ba8681eSLoïc Minier# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
200ba8681eSLoïc Miniertrap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21da1d85e3SGerd Hoffmannrm -f config.log
229ac81bbbSmalc
23b48e3611SPeter Maydell# Print a helpful header at the top of config.log
24b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
25979ae168SPeter Maydellprintf "# Configured with:" >> config.log
26979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
27979ae168SPeter Maydellecho >> config.log
28b48e3611SPeter Maydellecho "#" >> config.log
29b48e3611SPeter Maydell
308dc38a78SPeter Maydelldo_cc() {
318dc38a78SPeter Maydell    # Run the compiler, capturing its output to the log.
328dc38a78SPeter Maydell    echo $cc "$@" >> config.log
338dc38a78SPeter Maydell    $cc "$@" >> config.log 2>&1 || return $?
348dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
358dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
368dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
378dc38a78SPeter Maydell    # obvious to developers.
388dc38a78SPeter Maydell    if test "$werror" != "yes"; then
398dc38a78SPeter Maydell        return 0
408dc38a78SPeter Maydell    fi
418dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
428dc38a78SPeter Maydell    case "$*" in
438dc38a78SPeter Maydell        *-Werror*)
448dc38a78SPeter Maydell           return 0
458dc38a78SPeter Maydell        ;;
468dc38a78SPeter Maydell    esac
478dc38a78SPeter Maydell    echo $cc -Werror "$@" >> config.log
488dc38a78SPeter Maydell    $cc -Werror "$@" >> config.log 2>&1 && return $?
498dc38a78SPeter Maydell    echo "ERROR: configure test passed without -Werror but failed with -Werror."
508dc38a78SPeter Maydell    echo "This is probably a bug in the configure script. The failing command"
518dc38a78SPeter Maydell    echo "will be at the bottom of config.log."
528dc38a78SPeter Maydell    echo "You can run configure with --disable-werror to bypass this check."
538dc38a78SPeter Maydell    exit 1
548dc38a78SPeter Maydell}
558dc38a78SPeter Maydell
5652166aa0SJuan Quintelacompile_object() {
578dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
5852166aa0SJuan Quintela}
5952166aa0SJuan Quintela
6052166aa0SJuan Quintelacompile_prog() {
6152166aa0SJuan Quintela  local_cflags="$1"
6252166aa0SJuan Quintela  local_ldflags="$2"
638dc38a78SPeter Maydell  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
6452166aa0SJuan Quintela}
6552166aa0SJuan Quintela
6611568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
6711568d6dSPaolo Bonzinisymlink() {
6872b8b5a1SStefan Weil  rm -rf "$2"
69ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
7072b8b5a1SStefan Weil  ln -s "$1" "$2"
7111568d6dSPaolo Bonzini}
7211568d6dSPaolo Bonzini
730dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
740dba6195SLoïc Minier# executable or a builtin)
750dba6195SLoïc Minierhas() {
760dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
770dba6195SLoïc Minier}
780dba6195SLoïc Minier
790dba6195SLoïc Minier# search for an executable in PATH
800dba6195SLoïc Minierpath_of() {
810dba6195SLoïc Minier    local_command="$1"
820dba6195SLoïc Minier    local_ifs="$IFS"
830dba6195SLoïc Minier    local_dir=""
840dba6195SLoïc Minier
850dba6195SLoïc Minier    # pathname has a dir component?
860dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
870dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
880dba6195SLoïc Minier            echo "$local_command"
890dba6195SLoïc Minier            return 0
900dba6195SLoïc Minier        fi
910dba6195SLoïc Minier    fi
920dba6195SLoïc Minier    if [ -z "$local_command" ]; then
930dba6195SLoïc Minier        return 1
940dba6195SLoïc Minier    fi
950dba6195SLoïc Minier
960dba6195SLoïc Minier    IFS=:
970dba6195SLoïc Minier    for local_dir in $PATH; do
980dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
990dba6195SLoïc Minier            echo "$local_dir/$local_command"
1000dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
1010dba6195SLoïc Minier            return 0
1020dba6195SLoïc Minier        fi
1030dba6195SLoïc Minier    done
1040dba6195SLoïc Minier    # not found
1050dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
1060dba6195SLoïc Minier    return 1
1070dba6195SLoïc Minier}
1080dba6195SLoïc Minier
1097d13299dSbellard# default parameters
110ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
1112ff6b91eSJuan Quintelacpu=""
1121e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
11343ce4dfeSbellardstatic="no"
1147d13299dSbellardcross_prefix=""
1150c58ac1cSmalcaudio_drv_list=""
11661dc008fSAnthony Liguoriaudio_card_list="ac97 es1370 sb16 hda"
11761dc008fSAnthony Liguoriaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
118eb852011SMarkus Armbrusterblock_drv_whitelist=""
1197d13299dSbellardhost_cc="gcc"
12073da375eSJuan Quintelalibs_softmmu=""
1213e2e0e6bSJuan Quintelalibs_tools=""
12267f86e8eSJuan Quintelaaudio_pt_int=""
123d5631638Smalcaudio_win_int=""
1242b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
125957f1f99SMichael Rothlibs_qga=""
1265bc62e01SGerd Hoffmanndebug_info="yes"
127ac0df51dSaliguori
128121afa9eSAnthony Liguoritarget_list=""
129377529c0SPaolo Bonzini
130377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
131377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
132377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
133377529c0SPaolo Bonzini#              unless --disable-foo is given
134377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
135377529c0SPaolo Bonzini#              feature will searched for,
136377529c0SPaolo Bonzini#              if not found, configure exits with error
137377529c0SPaolo Bonzini#
138377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
139377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
140377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
141377529c0SPaolo Bonzini
142377529c0SPaolo Bonzinibluez=""
143377529c0SPaolo Bonzinibrlapi=""
144377529c0SPaolo Bonzinicurl=""
145377529c0SPaolo Bonzinicurses=""
146377529c0SPaolo Bonzinidocs=""
147377529c0SPaolo Bonzinifdt=""
148377529c0SPaolo Bonzininptl=""
149377529c0SPaolo Bonzinisdl=""
150983eef5aSMeador Ingevirtfs=""
151821601eaSJes Sorensenvnc="yes"
152377529c0SPaolo Bonzinisparse="no"
153377529c0SPaolo Bonziniuuid=""
154377529c0SPaolo Bonzinivde=""
155377529c0SPaolo Bonzinivnc_tls=""
156377529c0SPaolo Bonzinivnc_sasl=""
157377529c0SPaolo Bonzinivnc_jpeg=""
158377529c0SPaolo Bonzinivnc_png=""
159377529c0SPaolo Bonzinixen=""
160d5b93ddfSAnthony PERARDxen_ctrl_version=""
161eb6fda0fSAnthony PERARDxen_pci_passthrough=""
162377529c0SPaolo Bonzinilinux_aio=""
16347e98658SCorey Bryantcap_ng=""
164377529c0SPaolo Bonziniattr=""
1654f26f2b6SAvi Kivitylibattr=""
166377529c0SPaolo Bonzinixfs=""
167377529c0SPaolo Bonzini
168d41a75a2SBradvhost_net="no"
169d41a75a2SBradkvm="no"
170377529c0SPaolo Bonzinigprof="no"
171377529c0SPaolo Bonzinidebug_tcg="no"
172377529c0SPaolo Bonzinidebug="no"
173377529c0SPaolo Bonzinistrip_opt="yes"
1749195b2c2SStefan Weiltcg_interpreter="no"
175377529c0SPaolo Bonzinibigendian="no"
176377529c0SPaolo Bonzinimingw32="no"
177377529c0SPaolo BonziniEXESUF=""
178377529c0SPaolo Bonziniprefix="/usr/local"
179377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
180528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
181850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
182377529c0SPaolo Bonzinibindir="\${prefix}/bin"
1833aa5d2beSAlon Levylibdir="\${prefix}/lib"
1848bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
1850f94d6daSAlon Levyincludedir="\${prefix}/include"
186377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
187377529c0SPaolo Bonziniconfsuffix="/qemu"
188377529c0SPaolo Bonzinislirp="yes"
189377529c0SPaolo Bonzinifmod_lib=""
190377529c0SPaolo Bonzinifmod_inc=""
191377529c0SPaolo Bonzinioss_lib=""
192377529c0SPaolo Bonzinibsd="no"
193377529c0SPaolo Bonzinilinux="no"
194377529c0SPaolo Bonzinisolaris="no"
195377529c0SPaolo Bonziniprofiler="no"
196377529c0SPaolo Bonzinicocoa="no"
197377529c0SPaolo Bonzinisoftmmu="yes"
198377529c0SPaolo Bonzinilinux_user="no"
199377529c0SPaolo Bonzinibsd_user="no"
200377529c0SPaolo Bonziniguest_base=""
201377529c0SPaolo Bonziniuname_release=""
202377529c0SPaolo Bonzinimixemu="no"
203377529c0SPaolo Bonziniaix="no"
204377529c0SPaolo Bonziniblobs="yes"
205377529c0SPaolo Bonzinipkgversion=""
20640d6444eSAvi Kivitypie=""
207377529c0SPaolo Bonzinizero_malloc=""
208377529c0SPaolo Bonzinitrace_backend="nop"
209377529c0SPaolo Bonzinitrace_file="trace"
210377529c0SPaolo Bonzinispice=""
211377529c0SPaolo Bonzinirbd=""
21236707144SAlon Levysmartcard=""
213111a38b0SRobert Relyeasmartcard_nss=""
21469354a83SHans de Goedeusb_redir=""
215430a3c18SMichael Walleopengl=""
2161ece9905SAlon Levyzlib="yes"
217d138cee9SMichael Rothguest_agent="yes"
2184b1c11fdSDaniel P. Berrangewant_tools="yes"
219c589b249SRonnie Sahlberglibiscsi=""
220519175a2SAlex Barcelocoroutine=""
221f794573eSEduardo Otuboseccomp=""
222*eb100396SBharata B Raoglusterfs=""
223377529c0SPaolo Bonzini
224ac0df51dSaliguori# parse CC options first
225ac0df51dSaliguorifor opt do
226ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
227ac0df51dSaliguori  case "$opt" in
228ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
229ac0df51dSaliguori  ;;
2303d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
231ac0df51dSaliguori  ;;
232ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
233ca4deeb1SPaolo Bonzini  ;;
2342ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2352ff6b91eSJuan Quintela  ;;
236a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
237e2a2ed06SJuan Quintela  ;;
238e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
239e2a2ed06SJuan Quintela  ;;
2405bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2415bc62e01SGerd Hoffmann  ;;
2425bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2435bc62e01SGerd Hoffmann  ;;
244ac0df51dSaliguori  esac
245ac0df51dSaliguoridone
246ac0df51dSaliguori# OS specific
247ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
24893148aa5SStefan Weil# we can eliminate its usage altogether.
249ac0df51dSaliguori
250b3198cc2SStuart Yodercc="${CC-${cross_prefix}gcc}"
251b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
252b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
253b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
2543f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
255b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
256b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
25717884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
25817884d7bSSergei Trofimovichquery_pkg_config() {
25917884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
26017884d7bSSergei Trofimovich}
26117884d7bSSergei Trofimovichpkg_config=query_pkg_config
262b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
263ac0df51dSaliguori
264be17dc90SMichael S. Tsirkin# default flags for all hosts
265be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
266f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
267be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
268be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
269cbbab922SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu"
2705bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
2715bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
272be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
2735bc62e01SGerd Hoffmannfi
274be17dc90SMichael S. Tsirkin
275ca4deeb1SPaolo Bonzini# make source path absolute
276ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
277ca4deeb1SPaolo Bonzini
278ac0df51dSaliguoricheck_define() {
279ac0df51dSaliguoricat > $TMPC <<EOF
280ac0df51dSaliguori#if !defined($1)
281fd786e1aSPeter Maydell#error $1 not defined
282ac0df51dSaliguori#endif
283ac0df51dSaliguoriint main(void) { return 0; }
284ac0df51dSaliguoriEOF
28552166aa0SJuan Quintela  compile_object
286ac0df51dSaliguori}
287ac0df51dSaliguori
288bbea4050SPeter Maydellif check_define __linux__ ; then
289bbea4050SPeter Maydell  targetos="Linux"
290bbea4050SPeter Maydellelif check_define _WIN32 ; then
291bbea4050SPeter Maydell  targetos='MINGW32'
292bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
293bbea4050SPeter Maydell  targetos='OpenBSD'
294bbea4050SPeter Maydellelif check_define __sun__ ; then
295bbea4050SPeter Maydell  targetos='SunOS'
296bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
297bbea4050SPeter Maydell  targetos='Haiku'
298bbea4050SPeter Maydellelse
299bbea4050SPeter Maydell  targetos=`uname -s`
300bbea4050SPeter Maydellfi
301bbea4050SPeter Maydell
302bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
303bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
304bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
305bbea4050SPeter Maydell# the correct CPU with the --cpu option.
306bbea4050SPeter Maydellcase $targetos in
307bbea4050SPeter MaydellDarwin)
308bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
309bbea4050SPeter Maydell  # run 64-bit userspace code.
310bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
311bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
312bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
313bbea4050SPeter Maydell    cpu="x86_64"
314bbea4050SPeter Maydell  fi
315bbea4050SPeter Maydell  ;;
316bbea4050SPeter MaydellSunOS)
317bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
318bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
319bbea4050SPeter Maydell    cpu="x86_64"
320bbea4050SPeter Maydell  fi
321bbea4050SPeter Maydellesac
322bbea4050SPeter Maydell
3232ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3242ff6b91eSJuan Quintela  # command line argument
3252ff6b91eSJuan Quintela  :
3262ff6b91eSJuan Quintelaelif check_define __i386__ ; then
327ac0df51dSaliguori  cpu="i386"
328ac0df51dSaliguorielif check_define __x86_64__ ; then
329ac0df51dSaliguori  cpu="x86_64"
3303aa9bd6cSblueswir1elif check_define __sparc__ ; then
3313aa9bd6cSblueswir1  if check_define __arch64__ ; then
3323aa9bd6cSblueswir1    cpu="sparc64"
3333aa9bd6cSblueswir1  else
3343aa9bd6cSblueswir1    cpu="sparc"
3353aa9bd6cSblueswir1  fi
336fdf7ed96Smalcelif check_define _ARCH_PPC ; then
337fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
338fdf7ed96Smalc    cpu="ppc64"
339ac0df51dSaliguori  else
340fdf7ed96Smalc    cpu="ppc"
341fdf7ed96Smalc  fi
342afa05235SAurelien Jarnoelif check_define __mips__ ; then
343afa05235SAurelien Jarno  cpu="mips"
344477ba620SAurelien Jarnoelif check_define __ia64__ ; then
345477ba620SAurelien Jarno  cpu="ia64"
346d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
347d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
348d66ed0eaSAurelien Jarno    cpu="s390x"
349d66ed0eaSAurelien Jarno  else
350d66ed0eaSAurelien Jarno    cpu="s390"
351d66ed0eaSAurelien Jarno  fi
35221d89f84SPeter Maydellelif check_define __arm__ ; then
35321d89f84SPeter Maydell  cpu="arm"
354f28ffed5SBradelif check_define __hppa__ ; then
355f28ffed5SBrad  cpu="hppa"
356fdf7ed96Smalcelse
357fdf7ed96Smalc  cpu=`uname -m`
358ac0df51dSaliguorifi
359ac0df51dSaliguori
360359bc95dSPeter MaydellARCH=
361359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
362359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
3637d13299dSbellardcase "$cpu" in
364359bc95dSPeter Maydell  ia64|ppc|ppc64|s390|s390x|sparc64)
365ea8f20f8SJuan Quintela    cpu="$cpu"
366ea8f20f8SJuan Quintela  ;;
3677d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
36897a847bcSbellard    cpu="i386"
3697d13299dSbellard  ;;
370aaa5fa14Saurel32  x86_64|amd64)
371aaa5fa14Saurel32    cpu="x86_64"
372aaa5fa14Saurel32  ;;
37321d89f84SPeter Maydell  armv*b|armv*l|arm)
37421d89f84SPeter Maydell    cpu="arm"
3757d13299dSbellard  ;;
376f28ffed5SBrad  hppa|parisc|parisc64)
377f54b3f92Saurel32    cpu="hppa"
378f54b3f92Saurel32  ;;
379afa05235SAurelien Jarno  mips*)
380afa05235SAurelien Jarno    cpu="mips"
381afa05235SAurelien Jarno  ;;
3823142255cSblueswir1  sparc|sun4[cdmuv])
383ae228531Sbellard    cpu="sparc"
384ae228531Sbellard  ;;
3857d13299dSbellard  *)
386359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
387359bc95dSPeter Maydell    ARCH=unknown
3887d13299dSbellard  ;;
3897d13299dSbellardesac
390359bc95dSPeter Maydellif test -z "$ARCH"; then
391359bc95dSPeter Maydell  ARCH="$cpu"
392359bc95dSPeter Maydellfi
393e2d52ad3SJuan Quintela
3947d13299dSbellard# OS specific
3950dbfc675SJuan Quintela
3967d13299dSbellardcase $targetos in
397c326e0afSbellardCYGWIN*)
398c326e0afSbellard  mingw32="yes"
399a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
400d5631638Smalc  audio_possible_drivers="winwave sdl"
401d5631638Smalc  audio_drv_list="winwave"
402c326e0afSbellard;;
40367b915a5SbellardMINGW32*)
40467b915a5Sbellard  mingw32="yes"
405d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
406d5631638Smalc  audio_drv_list="winwave"
40767b915a5Sbellard;;
4085c40d2bdSthsGNU/kFreeBSD)
409a167ba50SAurelien Jarno  bsd="yes"
4100c58ac1cSmalc  audio_drv_list="oss"
411f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4125c40d2bdSths;;
4137d3505c5SbellardFreeBSD)
4147d3505c5Sbellard  bsd="yes"
4150db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4160c58ac1cSmalc  audio_drv_list="oss"
417f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
418f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
419f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
4207d3505c5Sbellard;;
421c5e97233Sblueswir1DragonFly)
422c5e97233Sblueswir1  bsd="yes"
4230db4a067SPaolo Bonzini  make="${MAKE-gmake}"
424c5e97233Sblueswir1  audio_drv_list="oss"
425c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
426c5e97233Sblueswir1;;
4277d3505c5SbellardNetBSD)
4287d3505c5Sbellard  bsd="yes"
4290db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4300c58ac1cSmalc  audio_drv_list="oss"
431c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4328ef92a88Sblueswir1  oss_lib="-lossaudio"
4337d3505c5Sbellard;;
4347d3505c5SbellardOpenBSD)
4357d3505c5Sbellard  bsd="yes"
4360db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4370c58ac1cSmalc  audio_drv_list="oss"
438c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4392f6a1ab0Sblueswir1  oss_lib="-lossaudio"
4407d3505c5Sbellard;;
44183fb7adfSbellardDarwin)
44283fb7adfSbellard  bsd="yes"
44383fb7adfSbellard  darwin="yes"
4441b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
445a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4460c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4471b0f9cc2Saliguori  else
448a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
4491b0f9cc2Saliguori  fi
450fd677642Sths  cocoa="yes"
4510c58ac1cSmalc  audio_drv_list="coreaudio"
452c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4530c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4547973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
455a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
456a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
457a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
45883fb7adfSbellard;;
459ec530c81SbellardSunOS)
460ec530c81Sbellard  solaris="yes"
4610db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4620db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
463fa58948dSBlue Swirl  ld="gld"
464e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
4650475a5caSths  needs_libsunmath="no"
466c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
467c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4680475a5caSths    if test "$solarisrev" -le 9 ; then
4690475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4700475a5caSths        needs_libsunmath="yes"
471f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
472f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
473f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4740475a5caSths      else
4750475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4760475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4770475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4780475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4790475a5caSths        exit 1
4800475a5caSths      fi
4810475a5caSths    fi
48286b2bd93Sths  fi
4836b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4840c58ac1cSmalc    audio_drv_list="oss"
4856b4d2ba1Sths  fi
486c2de5c91Smalc  audio_possible_drivers="oss sdl"
487d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
488d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
489d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
490d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
491a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
492560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
493560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
494560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
495ec530c81Sbellard;;
496b29fe3edSmalcAIX)
497b29fe3edSmalc  aix="yes"
4980db4a067SPaolo Bonzini  make="${MAKE-gmake}"
499b29fe3edSmalc;;
500179cf400SAndreas FärberHaiku)
501179cf400SAndreas Färber  haiku="yes"
502179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
503179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
504179cf400SAndreas Färber;;
505fb065187Sbellard*)
5060c58ac1cSmalc  audio_drv_list="oss"
507b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5085327cf48Sbellard  linux="yes"
509831b7825Sths  linux_user="yes"
51068063649Sblueswir1  usb="linux"
511af2be207SJan Kiszka  kvm="yes"
512af2be207SJan Kiszka  vhost_net="yes"
51307f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
514c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
515c9ec1fe4Sbellard  fi
516fb065187Sbellard;;
5177d13299dSbellardesac
5187d13299dSbellard
5197d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
520b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
52168063649Sblueswir1    usb="bsd"
52284778508Sblueswir1    bsd_user="yes"
5237d3505c5Sbellard  fi
52408de3949SAndreas Färberfi
5257d3505c5Sbellard
5260db4a067SPaolo Bonzini: ${make=${MAKE-make}}
5270db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
528c886edfbSBlue Swirl: ${python=${PYTHON-python}}
529e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
5300db4a067SPaolo Bonzini
5313c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
5323c4a4d0dSPeter Maydellif has clang; then
5333c4a4d0dSPeter Maydell  objcc=clang
5343c4a4d0dSPeter Maydellelse
5353c4a4d0dSPeter Maydell  objcc="$cc"
5363c4a4d0dSPeter Maydellfi
5373c4a4d0dSPeter Maydell
5383457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
5393457a3f8SJuan Quintela  EXESUF=".exe"
540a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
541e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
542e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
543f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
544f7cf5d5bSStefan Weilcat > $TMPC << EOF
545f7cf5d5bSStefan Weilint main(void) { return 0; }
546f7cf5d5bSStefan WeilEOF
547f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
548f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
549f7cf5d5bSStefan Weil  fi
550c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
551683035deSPaolo Bonzini  mandir="\${prefix}"
552528ae5b8SEduardo Habkost  datadir="\${prefix}"
553850da188SEduardo Habkost  qemu_docdir="\${prefix}"
554683035deSPaolo Bonzini  bindir="\${prefix}"
555683035deSPaolo Bonzini  sysconfdir="\${prefix}"
556683035deSPaolo Bonzini  confsuffix=""
557368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
5583457a3f8SJuan Quintelafi
5593457a3f8SJuan Quintela
560487fefdbSAnthony Liguoriwerror=""
56185aa5189Sbellard
5627d13299dSbellardfor opt do
563a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
5647d13299dSbellard  case "$opt" in
5652efc3265Sbellard  --help|-h) show_help=yes
5662efc3265Sbellard  ;;
56799123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
56899123e13SMike Frysinger  ;;
569b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5707d13299dSbellard  ;;
571b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
57232ce6337Sbellard  ;;
573ca4deeb1SPaolo Bonzini  --source-path=*)
5747d13299dSbellard  ;;
575ac0df51dSaliguori  --cross-prefix=*)
5767d13299dSbellard  ;;
577ac0df51dSaliguori  --cc=*)
5787d13299dSbellard  ;;
579b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
58083469015Sbellard  ;;
5813c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
5823c4a4d0dSPeter Maydell  ;;
583b1a550a0Spbrook  --make=*) make="$optarg"
5847d13299dSbellard  ;;
5856a882643Spbrook  --install=*) install="$optarg"
5866a882643Spbrook  ;;
587c886edfbSBlue Swirl  --python=*) python="$optarg"
588c886edfbSBlue Swirl  ;;
589e2d8830eSBrad  --smbd=*) smbd="$optarg"
590e2d8830eSBrad  ;;
591e2a2ed06SJuan Quintela  --extra-cflags=*)
5927d13299dSbellard  ;;
593e2a2ed06SJuan Quintela  --extra-ldflags=*)
5947d13299dSbellard  ;;
5955bc62e01SGerd Hoffmann  --enable-debug-info)
5965bc62e01SGerd Hoffmann  ;;
5975bc62e01SGerd Hoffmann  --disable-debug-info)
5985bc62e01SGerd Hoffmann  ;;
5992ff6b91eSJuan Quintela  --cpu=*)
6007d13299dSbellard  ;;
601b1a550a0Spbrook  --target-list=*) target_list="$optarg"
602de83cd02Sbellard  ;;
60374242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
60494a420b1SStefan Hajnoczi  ;;
60574242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6069410b56cSPrerna Saxena  ;;
6077d13299dSbellard  --enable-gprof) gprof="yes"
6087d13299dSbellard  ;;
60979427693SLoïc Minier  --static)
61079427693SLoïc Minier    static="yes"
61179427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
61217884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
61343ce4dfeSbellard  ;;
6140b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6150b24e75fSPaolo Bonzini  ;;
6160b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
6170b24e75fSPaolo Bonzini  ;;
6183aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
6193aa5d2beSAlon Levy  ;;
6208bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
6218bf188aaSMichael Tokarev  ;;
6220f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
6230f94d6daSAlon Levy  ;;
624528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
6250b24e75fSPaolo Bonzini  ;;
626023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
627023d3d67SEduardo Habkost  ;;
628850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
6290b24e75fSPaolo Bonzini  ;;
630ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
63107381cc1SAnthony Liguori  ;;
6328bf188aaSMichael Tokarev  --sbindir=*|--sharedstatedir=*|--localstatedir=*|\
633023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
634023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
635023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
636023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
637023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
638023ddd74SMax Filippov    # lots of directory switches by default.
639023ddd74SMax Filippov  ;;
64097a847bcSbellard  --disable-sdl) sdl="no"
64197a847bcSbellard  ;;
642c4198157SJuan Quintela  --enable-sdl) sdl="yes"
643c4198157SJuan Quintela  ;;
644983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
645983eef5aSMeador Inge  ;;
646983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
647983eef5aSMeador Inge  ;;
648821601eaSJes Sorensen  --disable-vnc) vnc="no"
649821601eaSJes Sorensen  ;;
650821601eaSJes Sorensen  --enable-vnc) vnc="yes"
651821601eaSJes Sorensen  ;;
652b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
653102a52e4Sbellard  ;;
654c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
655c2de5c91Smalc  ;;
6562f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
6572f6a1ab0Sblueswir1  ;;
6582fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
6590c58ac1cSmalc  ;;
6600c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
6610c58ac1cSmalc  ;;
662eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
663eb852011SMarkus Armbruster  ;;
664f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
665f8393946Saurel32  ;;
666f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
667f8393946Saurel32  ;;
668f3d08ee6SPaul Brook  --enable-debug)
669f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
670f3d08ee6SPaul Brook      debug_tcg="yes"
671f3d08ee6SPaul Brook      debug="yes"
672f3d08ee6SPaul Brook      strip_opt="no"
673f3d08ee6SPaul Brook  ;;
67403b4fe7dSaliguori  --enable-sparse) sparse="yes"
67503b4fe7dSaliguori  ;;
67603b4fe7dSaliguori  --disable-sparse) sparse="no"
67703b4fe7dSaliguori  ;;
6781625af87Saliguori  --disable-strip) strip_opt="no"
6791625af87Saliguori  ;;
6808d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
6818d5d2d4cSths  ;;
6821be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
6831be10ad2SJuan Quintela  ;;
6842f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
6852f9606b3Saliguori  ;;
686ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
687ea784e3bSJuan Quintela  ;;
6882f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
6892f6f5c7aSCorentin Chary  ;;
6902f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
6912f6f5c7aSCorentin Chary  ;;
692efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
693efe556adSCorentin Chary  ;;
694efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
695efe556adSCorentin Chary  ;;
696443f1376Sbellard  --disable-slirp) slirp="no"
697c20709aaSbellard  ;;
698ee682d27SStefan Weil  --disable-uuid) uuid="no"
699ee682d27SStefan Weil  ;;
700ee682d27SStefan Weil  --enable-uuid) uuid="yes"
701ee682d27SStefan Weil  ;;
702e0e6c8c0Saliguori  --disable-vde) vde="no"
7038a16d273Sths  ;;
704dfb278bdSJuan Quintela  --enable-vde) vde="yes"
705dfb278bdSJuan Quintela  ;;
706e37630caSaliguori  --disable-xen) xen="no"
707e37630caSaliguori  ;;
708fc321b4bSJuan Quintela  --enable-xen) xen="yes"
709fc321b4bSJuan Quintela  ;;
710eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
711eb6fda0fSAnthony PERARD  ;;
712eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
713eb6fda0fSAnthony PERARD  ;;
7142e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
7152e4d9fb1Saurel32  ;;
7164ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
7174ffcedb6SJuan Quintela  ;;
718fb599c9aSbalrog  --disable-bluez) bluez="no"
719fb599c9aSbalrog  ;;
720a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
721a20a6f46SJuan Quintela  ;;
7227ba1e619Saliguori  --disable-kvm) kvm="no"
7237ba1e619Saliguori  ;;
724b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
725b31a0277SJuan Quintela  ;;
7269195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
7279195b2c2SStefan Weil  ;;
7289195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
7299195b2c2SStefan Weil  ;;
73047e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
73147e98658SCorey Bryant  ;;
73247e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
73347e98658SCorey Bryant  ;;
734cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
735cd4ec0b4SGerd Hoffmann  ;;
736cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
737cd4ec0b4SGerd Hoffmann  ;;
738c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
739c589b249SRonnie Sahlberg  ;;
740c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
741c589b249SRonnie Sahlberg  ;;
74205c2a3e7Sbellard  --enable-profiler) profiler="yes"
74305c2a3e7Sbellard  ;;
74414821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
74514821030SPavel Borzenkov  ;;
746c2de5c91Smalc  --enable-cocoa)
747c2de5c91Smalc      cocoa="yes" ;
748c2de5c91Smalc      sdl="no" ;
749c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
7505b0753e0Sbellard  ;;
751cad25d69Spbrook  --disable-system) softmmu="no"
7520a8e90f4Spbrook  ;;
753cad25d69Spbrook  --enable-system) softmmu="yes"
7540a8e90f4Spbrook  ;;
7550953a80fSZachary Amsden  --disable-user)
7560953a80fSZachary Amsden      linux_user="no" ;
7570953a80fSZachary Amsden      bsd_user="no" ;
7580953a80fSZachary Amsden  ;;
7590953a80fSZachary Amsden  --enable-user) ;;
760831b7825Sths  --disable-linux-user) linux_user="no"
7610a8e90f4Spbrook  ;;
762831b7825Sths  --enable-linux-user) linux_user="yes"
763831b7825Sths  ;;
76484778508Sblueswir1  --disable-bsd-user) bsd_user="no"
76584778508Sblueswir1  ;;
76684778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
76784778508Sblueswir1  ;;
768379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
769379f6698SPaul Brook  ;;
770379f6698SPaul Brook  --disable-guest-base) guest_base="no"
771379f6698SPaul Brook  ;;
77240d6444eSAvi Kivity  --enable-pie) pie="yes"
77334005a00SKirill A. Shutemov  ;;
77440d6444eSAvi Kivity  --disable-pie) pie="no"
77534005a00SKirill A. Shutemov  ;;
776c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
777c5937220Spbrook  ;;
77885aa5189Sbellard  --enable-werror) werror="yes"
77985aa5189Sbellard  ;;
78085aa5189Sbellard  --disable-werror) werror="no"
78185aa5189Sbellard  ;;
7824d3b6f6eSbalrog  --disable-curses) curses="no"
7834d3b6f6eSbalrog  ;;
784c584a6d0SJuan Quintela  --enable-curses) curses="yes"
785c584a6d0SJuan Quintela  ;;
786769ce76dSAlexander Graf  --disable-curl) curl="no"
787769ce76dSAlexander Graf  ;;
788788c8196SJuan Quintela  --enable-curl) curl="yes"
789788c8196SJuan Quintela  ;;
7902df87df7SJuan Quintela  --disable-fdt) fdt="no"
7912df87df7SJuan Quintela  ;;
7922df87df7SJuan Quintela  --enable-fdt) fdt="yes"
7932df87df7SJuan Quintela  ;;
794bd0c5661Spbrook  --disable-nptl) nptl="no"
795bd0c5661Spbrook  ;;
796b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
797b0a47e79SJuan Quintela  ;;
7988ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
7998ff9cbf7Smalc  ;;
8005c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
8015c6c3a6cSChristoph Hellwig  ;;
8025c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
8035c6c3a6cSChristoph Hellwig  ;;
804758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
805758e8e38SVenkateswararao Jujjuri (JV)  ;;
806758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
807758e8e38SVenkateswararao Jujjuri (JV)  ;;
80877755340Sths  --disable-blobs) blobs="no"
80977755340Sths  ;;
8104a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
8114a19f1ecSpbrook  ;;
812519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
813519175a2SAlex Barcelo  ;;
814a25dba17SJuan Quintela  --disable-docs) docs="no"
81570ec5dc0SAnthony Liguori  ;;
816a25dba17SJuan Quintela  --enable-docs) docs="yes"
81783a3ab8bSJuan Quintela  ;;
818d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
819d5970055SMichael S. Tsirkin  ;;
820d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
821d5970055SMichael S. Tsirkin  ;;
82220ff075bSMichael Walle  --disable-opengl) opengl="no"
82320ff075bSMichael Walle  ;;
82420ff075bSMichael Walle  --enable-opengl) opengl="yes"
82520ff075bSMichael Walle  ;;
826f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
827f27aaf4bSChristian Brunner  ;;
828f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
829f27aaf4bSChristian Brunner  ;;
8308c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
8318c84cf11SSergei Trofimovich  ;;
8328c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
8338c84cf11SSergei Trofimovich  ;;
83436707144SAlon Levy  --disable-smartcard) smartcard="no"
83536707144SAlon Levy  ;;
83636707144SAlon Levy  --enable-smartcard) smartcard="yes"
83736707144SAlon Levy  ;;
838111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
839111a38b0SRobert Relyea  ;;
840111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
841111a38b0SRobert Relyea  ;;
84269354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
84369354a83SHans de Goede  ;;
84469354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
84569354a83SHans de Goede  ;;
8461ece9905SAlon Levy  --disable-zlib-test) zlib="no"
8471ece9905SAlon Levy  ;;
848d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
849d138cee9SMichael Roth  ;;
850d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
851d138cee9SMichael Roth  ;;
8524b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
8534b1c11fdSDaniel P. Berrange  ;;
8544b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
8554b1c11fdSDaniel P. Berrange  ;;
856f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
857f794573eSEduardo Otubo  ;;
858f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
859f794573eSEduardo Otubo  ;;
860*eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
861*eb100396SBharata B Rao  ;;
862*eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
863*eb100396SBharata B Rao  ;;
8647f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
8657f1559c6Sbalrog  ;;
8667d13299dSbellard  esac
8677d13299dSbellarddone
8687d13299dSbellard
869379f6698SPaul Brookhost_guest_base="no"
87040293e58Sbellardcase "$cpu" in
8719b9c37c3SRichard Henderson    sparc)
8720c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
8739b9c37c3SRichard Henderson           QEMU_CFLAGS="-m32 -mcpu=ultrasparc $QEMU_CFLAGS"
874c6f7e4fbSRichard Henderson           host_guest_base="yes"
8753142255cSblueswir1           ;;
876ed968ff1SJuan Quintela    sparc64)
8770c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8789b9c37c3SRichard Henderson           QEMU_CFLAGS="-m64 -mcpu=ultrasparc $QEMU_CFLAGS"
879c6f7e4fbSRichard Henderson           host_guest_base="yes"
8803142255cSblueswir1           ;;
88176d83bdeSths    s390)
88228d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
88328d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
88448bb3750SRichard Henderson           host_guest_base="yes"
88528d7cc49SRichard Henderson           ;;
88628d7cc49SRichard Henderson    s390x)
88728d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
88828d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
88948bb3750SRichard Henderson           host_guest_base="yes"
89076d83bdeSths           ;;
89140293e58Sbellard    i386)
892a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
8930c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
8942b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
895379f6698SPaul Brook           host_guest_base="yes"
89640293e58Sbellard           ;;
89740293e58Sbellard    x86_64)
898a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
8990c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
9002b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
901379f6698SPaul Brook           host_guest_base="yes"
902379f6698SPaul Brook           ;;
903379f6698SPaul Brook    arm*)
904379f6698SPaul Brook           host_guest_base="yes"
90540293e58Sbellard           ;;
906f6548c0aSmalc    ppc*)
907f6548c0aSmalc           host_guest_base="yes"
908f6548c0aSmalc           ;;
909cc01cc8eSAurelien Jarno    mips*)
910cc01cc8eSAurelien Jarno           host_guest_base="yes"
911cc01cc8eSAurelien Jarno           ;;
912477ba620SAurelien Jarno    ia64*)
913477ba620SAurelien Jarno           host_guest_base="yes"
914477ba620SAurelien Jarno           ;;
915fd76e73aSRichard Henderson    hppa*)
916fd76e73aSRichard Henderson           host_guest_base="yes"
917fd76e73aSRichard Henderson           ;;
918d2fbca94SGuan Xuetao    unicore32*)
919d2fbca94SGuan Xuetao           host_guest_base="yes"
920d2fbca94SGuan Xuetao           ;;
9213142255cSblueswir1esac
9223142255cSblueswir1
923379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
924379f6698SPaul Brook
92560e0df25SPeter Maydell
92660e0df25SPeter Maydelldefault_target_list=""
92760e0df25SPeter Maydell
92860e0df25SPeter Maydell# these targets are portable
92960e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
93060e0df25SPeter Maydell    default_target_list="\
93160e0df25SPeter Maydelli386-softmmu \
93260e0df25SPeter Maydellx86_64-softmmu \
93327cdad67SRichard Hendersonalpha-softmmu \
93460e0df25SPeter Maydellarm-softmmu \
93560e0df25SPeter Maydellcris-softmmu \
93660e0df25SPeter Maydelllm32-softmmu \
93760e0df25SPeter Maydellm68k-softmmu \
93860e0df25SPeter Maydellmicroblaze-softmmu \
93960e0df25SPeter Maydellmicroblazeel-softmmu \
94060e0df25SPeter Maydellmips-softmmu \
94160e0df25SPeter Maydellmipsel-softmmu \
94260e0df25SPeter Maydellmips64-softmmu \
94360e0df25SPeter Maydellmips64el-softmmu \
944e67db06eSJia Liuor32-softmmu \
94560e0df25SPeter Maydellppc-softmmu \
94660e0df25SPeter Maydellppcemb-softmmu \
94760e0df25SPeter Maydellppc64-softmmu \
94860e0df25SPeter Maydellsh4-softmmu \
94960e0df25SPeter Maydellsh4eb-softmmu \
95060e0df25SPeter Maydellsparc-softmmu \
95160e0df25SPeter Maydellsparc64-softmmu \
9520f3301d4SAlexander Grafs390x-softmmu \
953cfa550c6SMax Filippovxtensa-softmmu \
954cfa550c6SMax Filippovxtensaeb-softmmu \
9554f23a1e6SGuan Xuetaounicore32-softmmu \
95660e0df25SPeter Maydell"
95760e0df25SPeter Maydellfi
95860e0df25SPeter Maydell# the following are Linux specific
95960e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
96060e0df25SPeter Maydell    default_target_list="${default_target_list}\
96160e0df25SPeter Maydelli386-linux-user \
96260e0df25SPeter Maydellx86_64-linux-user \
96360e0df25SPeter Maydellalpha-linux-user \
96460e0df25SPeter Maydellarm-linux-user \
96560e0df25SPeter Maydellarmeb-linux-user \
96660e0df25SPeter Maydellcris-linux-user \
96760e0df25SPeter Maydellm68k-linux-user \
96860e0df25SPeter Maydellmicroblaze-linux-user \
96960e0df25SPeter Maydellmicroblazeel-linux-user \
97060e0df25SPeter Maydellmips-linux-user \
97160e0df25SPeter Maydellmipsel-linux-user \
972d962783eSJia Liuor32-linux-user \
97360e0df25SPeter Maydellppc-linux-user \
97460e0df25SPeter Maydellppc64-linux-user \
97560e0df25SPeter Maydellppc64abi32-linux-user \
97660e0df25SPeter Maydellsh4-linux-user \
97760e0df25SPeter Maydellsh4eb-linux-user \
97860e0df25SPeter Maydellsparc-linux-user \
97960e0df25SPeter Maydellsparc64-linux-user \
98060e0df25SPeter Maydellsparc32plus-linux-user \
98160e0df25SPeter Maydellunicore32-linux-user \
9820f3301d4SAlexander Grafs390x-linux-user \
98360e0df25SPeter Maydell"
98460e0df25SPeter Maydellfi
98560e0df25SPeter Maydell# the following are BSD specific
98660e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
98760e0df25SPeter Maydell    default_target_list="${default_target_list}\
98860e0df25SPeter Maydelli386-bsd-user \
98960e0df25SPeter Maydellx86_64-bsd-user \
99060e0df25SPeter Maydellsparc-bsd-user \
99160e0df25SPeter Maydellsparc64-bsd-user \
99260e0df25SPeter Maydell"
99360e0df25SPeter Maydellfi
99460e0df25SPeter Maydell
995af5db58eSpbrookif test x"$show_help" = x"yes" ; then
996af5db58eSpbrookcat << EOF
997af5db58eSpbrook
998af5db58eSpbrookUsage: configure [options]
999af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1000af5db58eSpbrook
1001af5db58eSpbrookEOF
1002af5db58eSpbrookecho "Standard options:"
1003af5db58eSpbrookecho "  --help                   print this message"
1004af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
1005af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
1006af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
100760e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
100860e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
100960e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
1010af5db58eSpbrookecho ""
1011af5db58eSpbrookecho "Advanced options (experts only):"
1012af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
1013af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
1014af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
10150bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
10160bfe8cc0SPaolo Bonziniecho "                           build time"
10173c4a4d0dSPeter Maydellecho "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
1018a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
1019e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
1020af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
10216a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
1022c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
1023e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
1024af5db58eSpbrookecho "  --static                 enable static build [$static]"
10250b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
1026023d3d67SEduardo Habkostecho "  --datadir=PATH           install firmware in PATH$confsuffix"
1027023d3d67SEduardo Habkostecho "  --docdir=PATH            install documentation in PATH$confsuffix"
10280b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
1029023d3d67SEduardo Habkostecho "  --sysconfdir=PATH        install config in PATH$confsuffix"
10302ae4748fSStefan Weilecho "  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1031f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
1032f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
103309695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
1034890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
1035890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
10361625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
103785aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
1038fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
1039c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
1040983eef5aSMeador Ingeecho "  --disable-virtfs         disable VirtFS"
1041983eef5aSMeador Ingeecho "  --enable-virtfs          enable VirtFS"
1042821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
1043821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
104414821030SPavel Borzenkovecho "  --disable-cocoa          disable Cocoa (Mac OS X only)"
104514821030SPavel Borzenkovecho "  --enable-cocoa           enable Cocoa (default on Mac OS X)"
1046c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
1047c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
10484c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
10494c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
1050eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
1051eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
10528ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
1053e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
1054fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
1055eb6fda0fSAnthony PERARDecho "  --disable-xen-pci-passthrough"
1056eb6fda0fSAnthony PERARDecho "  --enable-xen-pci-passthrough"
10572e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
10584ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
10598d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
10601be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
10612f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1062ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
10632f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
10642f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
106596763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1066efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
1067af896aaaSpbrookecho "  --disable-curses         disable curses output"
1068c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1069769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1070788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
10712df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
10722df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
1073fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1074a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
10756093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
10767ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1077b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
10789195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1079bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
1080e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
1081af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1082af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
10830953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
10840953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1085831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1086831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
108784778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
108884778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1089379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1090379f6698SPaul Brookecho "                           emulation targets"
1091379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
109240d6444eSAvi Kivityecho "  --enable-pie             build Position Independent Executables"
109340d6444eSAvi Kivityecho "  --disable-pie            do not build Position Independent Executables"
1094af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1095af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
10962f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1097c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1098235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
10993142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
1100ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1101ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1102e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1103dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
11045c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
11055c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
110647e98658SCorey Bryantecho "  --disable-cap-ng         disable libcap-ng support"
110747e98658SCorey Bryantecho "  --enable-cap-ng          enable libcap-ng support"
1108758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1109758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
111077755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1111d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1112d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1113d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1114d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1115320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1116650ab98dSLluís Vilanovaecho "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
111774242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
11189410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1119cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1120cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1121f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1122c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1123c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
112436707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
112536707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1126111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1127111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
112869354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
112969354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1130d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1131d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1132f794573eSEduardo Otuboecho "  --disable-seccomp        disable seccomp support"
1133f794573eSEduardo Otuboecho "  --enable-seccomp         enables seccomp support"
1134519175a2SAlex Barceloecho "  --with-coroutine=BACKEND coroutine backend. Supported options:"
1135fe91bfa8SAlex Barceloecho "                           gthread, ucontext, sigaltstack, windows"
1136*eb100396SBharata B Raoecho "  --enable-glusterfs       enable GlusterFS backend"
1137*eb100396SBharata B Raoecho "  --disable-glusterfs      disable GlusterFS backend"
1138af5db58eSpbrookecho ""
11395bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1140af5db58eSpbrookexit 1
1141af5db58eSpbrookfi
1142af5db58eSpbrook
1143359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1144359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1145359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1146359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1147359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1148359bc95dSPeter Maydell        ARCH=tci
1149359bc95dSPeter Maydell    else
1150359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1151359bc95dSPeter Maydell        exit 1
1152359bc95dSPeter Maydell    fi
1153359bc95dSPeter Maydellfi
1154359bc95dSPeter Maydell
11558d05095cSPaolo Bonzini# check that the C compiler works.
11568d05095cSPaolo Bonzinicat > $TMPC <<EOF
115775cafad7SStefan Weilint main(void) { return 0; }
11588d05095cSPaolo BonziniEOF
11598d05095cSPaolo Bonzini
11608d05095cSPaolo Bonziniif compile_object ; then
11618d05095cSPaolo Bonzini  : C compiler works ok
11628d05095cSPaolo Bonzinielse
11638d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
11648d05095cSPaolo Bonzini    exit 1
11658d05095cSPaolo Bonzinifi
11668d05095cSPaolo Bonzini
1167417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1168417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1169417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1170417c9d72SAlexander Graf
1171417c9d72SAlexander Grafif test -z "$werror" ; then
1172417c9d72SAlexander Graf    if test "$z_version" = "50" -a \
1173417c9d72SAlexander Graf        "$linux" = "yes" ; then
1174417c9d72SAlexander Graf        werror="yes"
1175417c9d72SAlexander Graf    else
1176417c9d72SAlexander Graf        werror="no"
1177417c9d72SAlexander Graf    fi
1178417c9d72SAlexander Graffi
1179417c9d72SAlexander Graf
11808d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
11818d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
11828d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1183f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
11846ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
11856ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
11866ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
11876ca026cbSPeter Maydell# so it's too error prone.
11888d05095cSPaolo Bonzinicat > $TMPC << EOF
11898d05095cSPaolo Bonziniint main(void) { return 0; }
11908d05095cSPaolo BonziniEOF
11918d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1192bd947d30SStefan Weil    if compile_prog "-Werror $flag" "" ; then
11938d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
11948d05095cSPaolo Bonzini    fi
11958d05095cSPaolo Bonzinidone
11968d05095cSPaolo Bonzini
119740d6444eSAvi Kivityif test "$static" = "yes" ; then
119840d6444eSAvi Kivity  if test "$pie" = "yes" ; then
119940d6444eSAvi Kivity    echo "static and pie are mutually incompatible"
120040d6444eSAvi Kivity    exit 1
120140d6444eSAvi Kivity  else
120240d6444eSAvi Kivity    pie="no"
120340d6444eSAvi Kivity  fi
120440d6444eSAvi Kivityfi
120540d6444eSAvi Kivity
120640d6444eSAvi Kivityif test "$pie" = ""; then
120740d6444eSAvi Kivity  case "$cpu-$targetos" in
1208f9db31a2SBrad    i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD)
120940d6444eSAvi Kivity      ;;
121040d6444eSAvi Kivity    *)
121140d6444eSAvi Kivity      pie="no"
121240d6444eSAvi Kivity      ;;
121340d6444eSAvi Kivity  esac
121440d6444eSAvi Kivityfi
121540d6444eSAvi Kivity
121640d6444eSAvi Kivityif test "$pie" != "no" ; then
121740d6444eSAvi Kivity  cat > $TMPC << EOF
121821d4a791SAvi Kivity
121921d4a791SAvi Kivity#ifdef __linux__
122021d4a791SAvi Kivity#  define THREAD __thread
122121d4a791SAvi Kivity#else
122221d4a791SAvi Kivity#  define THREAD
122321d4a791SAvi Kivity#endif
122421d4a791SAvi Kivity
122521d4a791SAvi Kivitystatic THREAD int tls_var;
122621d4a791SAvi Kivity
122721d4a791SAvi Kivityint main(void) { return tls_var; }
122821d4a791SAvi Kivity
122940d6444eSAvi KivityEOF
123040d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
123140d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
123240d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
123340d6444eSAvi Kivity    pie="yes"
123440d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
123540d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
123640d6444eSAvi Kivity    fi
123740d6444eSAvi Kivity  else
123840d6444eSAvi Kivity    if test "$pie" = "yes"; then
123940d6444eSAvi Kivity      echo "PIE not available due to missing toolchain support"
124040d6444eSAvi Kivity      exit 1
124140d6444eSAvi Kivity    else
124240d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
124340d6444eSAvi Kivity      pie="no"
124440d6444eSAvi Kivity    fi
124540d6444eSAvi Kivity  fi
124640d6444eSAvi Kivityfi
124740d6444eSAvi Kivity
1248ec530c81Sbellard#
1249ec530c81Sbellard# Solaris specific configure tool chain decisions
1250ec530c81Sbellard#
1251ec530c81Sbellardif test "$solaris" = "yes" ; then
12526792aa11SLoïc Minier  if has $install; then
12536792aa11SLoïc Minier    :
12546792aa11SLoïc Minier  else
1255ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1256ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1257ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1258ec530c81Sbellard    exit 1
1259ec530c81Sbellard  fi
12606792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1261ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1262ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1263ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1264ec530c81Sbellard    exit 1
1265ec530c81Sbellard  fi
12666792aa11SLoïc Minier  if has ar; then
12676792aa11SLoïc Minier    :
12686792aa11SLoïc Minier  else
1269ec530c81Sbellard    echo "Error: No path includes ar"
1270ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1271ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1272ec530c81Sbellard    fi
1273ec530c81Sbellard    exit 1
1274ec530c81Sbellard  fi
1275ec530c81Sbellardfi
1276ec530c81Sbellard
12777a3fc891SSebastian Herbsztif ! has $python; then
1278c886edfbSBlue Swirl  echo "Python not found. Use --python=/path/to/python"
1279c886edfbSBlue Swirl  exit 1
1280c886edfbSBlue Swirlfi
1281c886edfbSBlue Swirl
12826ccea1e4SPeter Maydell# Note that if the Python conditional here evaluates True we will exit
12836ccea1e4SPeter Maydell# with status 1 which is a shell 'false' value.
1284e120d449SStefan Hajnocziif ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1285e120d449SStefan Hajnoczi  echo "Cannot use '$python', Python 2.4 or later is required."
1286e120d449SStefan Hajnoczi  echo "Note that Python 3 or later is not yet supported."
1287e120d449SStefan Hajnoczi  echo "Use --python=/path/to/python to specify a supported Python."
12886ccea1e4SPeter Maydell  exit 1
12896ccea1e4SPeter Maydellfi
12906ccea1e4SPeter Maydell
1291121afa9eSAnthony Liguoriif test -z "$target_list" ; then
1292121afa9eSAnthony Liguori    target_list="$default_target_list"
1293121afa9eSAnthony Liguorielse
1294121afa9eSAnthony Liguori    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
12955327cf48Sbellardfi
1296f55fe278SPaolo Bonzini# see if system emulation was really requested
1297f55fe278SPaolo Bonzinicase " $target_list " in
1298f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1299f55fe278SPaolo Bonzini  ;;
1300f55fe278SPaolo Bonzini  *) softmmu=no
1301f55fe278SPaolo Bonzini  ;;
1302f55fe278SPaolo Bonziniesac
13035327cf48Sbellard
1304249247c9SJuan Quintelafeature_not_found() {
1305249247c9SJuan Quintela  feature=$1
1306249247c9SJuan Quintela
1307249247c9SJuan Quintela  echo "ERROR"
1308249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
13099332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1310249247c9SJuan Quintela  echo "ERROR"
1311249247c9SJuan Quintela  exit 1;
1312249247c9SJuan Quintela}
1313249247c9SJuan Quintela
13147d13299dSbellardif test -z "$cross_prefix" ; then
13157d13299dSbellard
13167d13299dSbellard# ---
13177d13299dSbellard# big/little endian test
13187d13299dSbellardcat > $TMPC << EOF
13197d13299dSbellard#include <inttypes.h>
13207d13299dSbellardint main(int argc, char ** argv){
13217d13299dSbellard        volatile uint32_t i=0x01234567;
13227d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
13237d13299dSbellard}
13247d13299dSbellardEOF
13257d13299dSbellard
132652166aa0SJuan Quintelaif compile_prog "" "" ; then
13277d13299dSbellard$TMPE && bigendian="yes"
13287d13299dSbellardelse
13297d13299dSbellardecho big/little test failed
13307d13299dSbellardfi
13317d13299dSbellard
13327d13299dSbellardelse
13337d13299dSbellard
13347d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1335ea8f20f8SJuan Quintelacase "$cpu" in
133621d89f84SPeter Maydell  arm)
133721d89f84SPeter Maydell    # ARM can be either way; ask the compiler which one we are
133821d89f84SPeter Maydell    if check_define __ARMEB__; then
133921d89f84SPeter Maydell      bigendian=yes
134021d89f84SPeter Maydell    fi
134121d89f84SPeter Maydell  ;;
134221d89f84SPeter Maydell  hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1343ea8f20f8SJuan Quintela    bigendian=yes
1344ea8f20f8SJuan Quintela  ;;
1345ea8f20f8SJuan Quintelaesac
13467d13299dSbellard
13477d13299dSbellardfi
13487d13299dSbellard
1349b0a47e79SJuan Quintela##########################################
1350b0a47e79SJuan Quintela# NPTL probe
1351b0a47e79SJuan Quintela
1352b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1353bd0c5661Spbrook  cat > $TMPC <<EOF
1354bd0c5661Spbrook#include <sched.h>
135530813ceaSpbrook#include <linux/futex.h>
1356182eacc0SStefan Weilint main(void) {
1357bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1358bd0c5661Spbrook#error bork
1359bd0c5661Spbrook#endif
1360182eacc0SStefan Weil  return 0;
1361bd0c5661Spbrook}
1362bd0c5661SpbrookEOF
1363bd0c5661Spbrook
136452166aa0SJuan Quintela  if compile_object ; then
1365b0a47e79SJuan Quintela    nptl=yes
1366bd0c5661Spbrook  else
1367b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1368b0a47e79SJuan Quintela      feature_not_found "nptl"
1369b0a47e79SJuan Quintela    fi
1370b0a47e79SJuan Quintela    nptl=no
1371b0a47e79SJuan Quintela  fi
1372bd0c5661Spbrookfi
1373bd0c5661Spbrook
137411d9f695Sbellard##########################################
1375ac62922eSbalrog# zlib check
1376ac62922eSbalrog
13771ece9905SAlon Levyif test "$zlib" != "no" ; then
1378ac62922eSbalrog    cat > $TMPC << EOF
1379ac62922eSbalrog#include <zlib.h>
1380ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1381ac62922eSbalrogEOF
138252166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1383ac62922eSbalrog        :
1384ac62922eSbalrog    else
1385ac62922eSbalrog        echo
1386ac62922eSbalrog        echo "Error: zlib check failed"
1387ac62922eSbalrog        echo "Make sure to have the zlib libs and headers installed."
1388ac62922eSbalrog        echo
1389ac62922eSbalrog        exit 1
1390ac62922eSbalrog    fi
13911ece9905SAlon Levyfi
1392ac62922eSbalrog
1393ac62922eSbalrog##########################################
1394f794573eSEduardo Otubo# libseccomp check
1395f794573eSEduardo Otubo
1396f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
1397f794573eSEduardo Otubo    if $pkg_config libseccomp --modversion >/dev/null 2>&1; then
1398f794573eSEduardo Otubo        LIBS=`$pkg_config --libs libseccomp`
1399f794573eSEduardo Otubo	seccomp="yes"
1400f794573eSEduardo Otubo    else
1401f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
1402f794573eSEduardo Otubo            feature_not_found "libseccomp"
1403f794573eSEduardo Otubo	fi
1404e84d5956SYann E. MORIN	seccomp="no"
1405f794573eSEduardo Otubo    fi
1406f794573eSEduardo Otubofi
1407f794573eSEduardo Otubo##########################################
1408e37630caSaliguori# xen probe
1409e37630caSaliguori
1410fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1411b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1412d5b93ddfSAnthony PERARD
141350ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
141450ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
141550ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
141650ced5b3SStefan Weil
141750ced5b3SStefan Weil  # Xen (any)
141850ced5b3SStefan Weil  cat > $TMPC <<EOF
141950ced5b3SStefan Weil#include <xenctrl.h>
142050ced5b3SStefan Weilint main(void) {
142150ced5b3SStefan Weil  return 0;
142250ced5b3SStefan Weil}
142350ced5b3SStefan WeilEOF
142450ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
142550ced5b3SStefan Weil    # Xen not found
142650ced5b3SStefan Weil    if test "$xen" = "yes" ; then
142750ced5b3SStefan Weil      feature_not_found "xen"
142850ced5b3SStefan Weil    fi
142950ced5b3SStefan Weil    xen=no
143050ced5b3SStefan Weil
1431d5b93ddfSAnthony PERARD  # Xen unstable
143269deef08SPeter Maydell  elif
143369deef08SPeter Maydell      cat > $TMPC <<EOF &&
1434e37630caSaliguori#include <xenctrl.h>
1435e108a3c1SAnthony PERARD#include <xenstore.h>
1436d5b93ddfSAnthony PERARD#include <stdint.h>
1437d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1438d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1439d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1440d5b93ddfSAnthony PERARD#endif
1441d5b93ddfSAnthony PERARDint main(void) {
1442d5b93ddfSAnthony PERARD  xc_interface *xc;
1443d5b93ddfSAnthony PERARD  xs_daemon_open();
1444d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1445d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1446d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1447b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
14488688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
14498688e065SStefano Stabellini  return 0;
14508688e065SStefano Stabellini}
14518688e065SStefano StabelliniEOF
14528688e065SStefano Stabellini      compile_prog "" "$xen_libs"
145369deef08SPeter Maydell    then
14548688e065SStefano Stabellini    xen_ctrl_version=420
14558688e065SStefano Stabellini    xen=yes
14568688e065SStefano Stabellini
145769deef08SPeter Maydell  elif
145869deef08SPeter Maydell      cat > $TMPC <<EOF &&
14598688e065SStefano Stabellini#include <xenctrl.h>
14608688e065SStefano Stabellini#include <xs.h>
14618688e065SStefano Stabellini#include <stdint.h>
14628688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
14638688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
14648688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
14658688e065SStefano Stabellini#endif
14668688e065SStefano Stabelliniint main(void) {
14678688e065SStefano Stabellini  xs_daemon_open();
14689b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
14698688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
14708688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
14718688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1472d5b93ddfSAnthony PERARD  return 0;
1473d5b93ddfSAnthony PERARD}
1474e37630caSaliguoriEOF
147550ced5b3SStefan Weil      compile_prog "" "$xen_libs"
147669deef08SPeter Maydell    then
1477d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1478fc321b4bSJuan Quintela    xen=yes
1479d5b93ddfSAnthony PERARD
1480d5b93ddfSAnthony PERARD  # Xen 4.0.0
148169deef08SPeter Maydell  elif
148269deef08SPeter Maydell      cat > $TMPC <<EOF &&
1483d5b93ddfSAnthony PERARD#include <xenctrl.h>
1484d5b93ddfSAnthony PERARD#include <xs.h>
1485d5b93ddfSAnthony PERARD#include <stdint.h>
1486d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1487d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1488d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1489d5b93ddfSAnthony PERARD#endif
1490d5b93ddfSAnthony PERARDint main(void) {
1491b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1492b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1493b87de24eSAnthony PERARD  };
1494d5b93ddfSAnthony PERARD  xs_daemon_open();
1495d5b93ddfSAnthony PERARD  xc_interface_open();
1496d5b93ddfSAnthony PERARD  xc_gnttab_open();
1497d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1498b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1499d5b93ddfSAnthony PERARD  return 0;
1500d5b93ddfSAnthony PERARD}
1501d5b93ddfSAnthony PERARDEOF
1502d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
150369deef08SPeter Maydell    then
1504d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1505d5b93ddfSAnthony PERARD    xen=yes
1506d5b93ddfSAnthony PERARD
1507b87de24eSAnthony PERARD  # Xen 3.4.0
150869deef08SPeter Maydell  elif
150969deef08SPeter Maydell      cat > $TMPC <<EOF &&
1510b87de24eSAnthony PERARD#include <xenctrl.h>
1511b87de24eSAnthony PERARD#include <xs.h>
1512b87de24eSAnthony PERARDint main(void) {
1513b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1514b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1515b87de24eSAnthony PERARD  };
1516b87de24eSAnthony PERARD  xs_daemon_open();
1517b87de24eSAnthony PERARD  xc_interface_open();
1518b87de24eSAnthony PERARD  xc_gnttab_open();
1519b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1520b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1521b87de24eSAnthony PERARD  return 0;
1522b87de24eSAnthony PERARD}
1523b87de24eSAnthony PERARDEOF
1524b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
152569deef08SPeter Maydell    then
1526b87de24eSAnthony PERARD    xen_ctrl_version=340
1527b87de24eSAnthony PERARD    xen=yes
1528b87de24eSAnthony PERARD
1529b87de24eSAnthony PERARD  # Xen 3.3.0
153069deef08SPeter Maydell  elif
153169deef08SPeter Maydell      cat > $TMPC <<EOF &&
1532d5b93ddfSAnthony PERARD#include <xenctrl.h>
1533d5b93ddfSAnthony PERARD#include <xs.h>
1534d5b93ddfSAnthony PERARDint main(void) {
1535d5b93ddfSAnthony PERARD  xs_daemon_open();
1536d5b93ddfSAnthony PERARD  xc_interface_open();
1537d5b93ddfSAnthony PERARD  xc_gnttab_open();
1538d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1539d5b93ddfSAnthony PERARD  return 0;
1540d5b93ddfSAnthony PERARD}
1541d5b93ddfSAnthony PERARDEOF
1542d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
154369deef08SPeter Maydell    then
1544d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1545d5b93ddfSAnthony PERARD    xen=yes
1546d5b93ddfSAnthony PERARD
154750ced5b3SStefan Weil  # Xen version unsupported
1548e37630caSaliguori  else
1549fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
155050ced5b3SStefan Weil      feature_not_found "xen (unsupported version)"
1551fc321b4bSJuan Quintela    fi
1552fc321b4bSJuan Quintela    xen=no
1553e37630caSaliguori  fi
1554d5b93ddfSAnthony PERARD
1555d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1556d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1557d5b93ddfSAnthony PERARD  fi
1558e37630caSaliguorifi
1559e37630caSaliguori
1560eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1561eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1562eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1563eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1564eb6fda0fSAnthony PERARD  else
1565eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1566eb6fda0fSAnthony PERARD      echo "ERROR"
1567eb6fda0fSAnthony PERARD      echo "ERROR: User requested feature Xen PCI Passthrough"
1568eb6fda0fSAnthony PERARD      echo "ERROR: but this feature require /sys from Linux"
1569eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
1570eb6fda0fSAnthony PERARD        echo "ERROR: This feature does not work with Xen 3.3"
1571eb6fda0fSAnthony PERARD      fi
1572eb6fda0fSAnthony PERARD      echo "ERROR"
1573eb6fda0fSAnthony PERARD      exit 1;
1574eb6fda0fSAnthony PERARD    fi
1575eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1576eb6fda0fSAnthony PERARD  fi
1577eb6fda0fSAnthony PERARDfi
1578eb6fda0fSAnthony PERARD
1579e37630caSaliguori##########################################
1580a8bd70adSPaolo Bonzini# pkg-config probe
1581f91672e5SPaolo Bonzini
158217884d7bSSergei Trofimovichif ! has "$pkg_config_exe"; then
158317884d7bSSergei Trofimovich  echo "Error: pkg-config binary '$pkg_config_exe' not found"
1584a213fcb2SPeter Maydell  exit 1
1585f91672e5SPaolo Bonzinifi
1586f91672e5SPaolo Bonzini
1587f91672e5SPaolo Bonzini##########################################
158844dc0ca3SAlon Levy# libtool probe
158944dc0ca3SAlon Levy
15903f534581SBradif ! has $libtool; then
159144dc0ca3SAlon Levy    libtool=
159244dc0ca3SAlon Levyfi
159344dc0ca3SAlon Levy
159444dc0ca3SAlon Levy##########################################
1595dfffc653SJuan Quintela# Sparse probe
1596dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
15970dba6195SLoïc Minier  if has cgcc; then
1598dfffc653SJuan Quintela    sparse=yes
1599dfffc653SJuan Quintela  else
1600dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1601dfffc653SJuan Quintela      feature_not_found "sparse"
1602dfffc653SJuan Quintela    fi
1603dfffc653SJuan Quintela    sparse=no
1604dfffc653SJuan Quintela  fi
1605dfffc653SJuan Quintelafi
1606dfffc653SJuan Quintela
1607dfffc653SJuan Quintela##########################################
160811d9f695Sbellard# SDL probe
160911d9f695Sbellard
16103ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
16113ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
16123ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
16133ec87ffeSPaolo Bonzini  sdl_config=sdl-config
16143ec87ffeSPaolo Bonzinifi
16153ec87ffeSPaolo Bonzini
16163ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1617a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1618fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
16193ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
16203ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
16219316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1622a0dfd8a4SLoïc Minierelse
1623a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1624a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1625a0dfd8a4SLoïc Minier  fi
1626a0dfd8a4SLoïc Minier  sdl=no
16279316f803SPaolo Bonzinifi
162829e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
16293ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
16303ec87ffeSPaolo Bonzinifi
163111d9f695Sbellard
16329316f803SPaolo Bonzinisdl_too_old=no
1633c4198157SJuan Quintelaif test "$sdl" != "no" ; then
163411d9f695Sbellard  cat > $TMPC << EOF
163511d9f695Sbellard#include <SDL.h>
163611d9f695Sbellard#undef main /* We don't want SDL to override our main() */
163711d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
163811d9f695SbellardEOF
16399316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
164074f42e18STeLeMan  if test "$static" = "yes" ; then
164174f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
164274f42e18STeLeMan  else
16439316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
164474f42e18STeLeMan  fi
164552166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
164611d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
164711d9f695Sbellard      sdl_too_old=yes
164811d9f695Sbellard    else
1649fd677642Sths      if test "$cocoa" = "no" ; then
165011d9f695Sbellard        sdl=yes
165111d9f695Sbellard      fi
1652fd677642Sths    fi
16537c1f25b4Sbellard
165467c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
16551ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
165667c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1657f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1658f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
165911d9f695Sbellard      fi
166052166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
16611ac88f28SJuan Quintela	:
16621ac88f28SJuan Quintela      else
16631ac88f28SJuan Quintela        sdl=no
16647c1f25b4Sbellard      fi
16657c1f25b4Sbellard    fi # static link
1666c4198157SJuan Quintela  else # sdl not found
1667c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1668c4198157SJuan Quintela      feature_not_found "sdl"
1669c4198157SJuan Quintela    fi
1670c4198157SJuan Quintela    sdl=no
16717c1f25b4Sbellard  fi # sdl compile test
1672fd677642Sthsfi
167311d9f695Sbellard
16745368a422Saliguoriif test "$sdl" = "yes" ; then
16755368a422Saliguori  cat > $TMPC <<EOF
16765368a422Saliguori#include <SDL.h>
16775368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
16785368a422Saliguori#include <X11/XKBlib.h>
16795368a422Saliguori#else
16805368a422Saliguori#error No x11 support
16815368a422Saliguori#endif
16825368a422Saliguoriint main(void) { return 0; }
16835368a422SaliguoriEOF
168452166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1685681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
16865368a422Saliguori  fi
16870705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
16885368a422Saliguorifi
16895368a422Saliguori
16908f28f3fbSths##########################################
16918d5d2d4cSths# VNC TLS detection
1692821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1693ae6b5e5aSaliguori  cat > $TMPC <<EOF
1694ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1695ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1696ae6b5e5aSaliguoriEOF
1697a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1698a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
169952166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
17001be10ad2SJuan Quintela    vnc_tls=yes
1701a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1702ae6b5e5aSaliguori  else
17031be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
17041be10ad2SJuan Quintela      feature_not_found "vnc-tls"
17051be10ad2SJuan Quintela    fi
17061be10ad2SJuan Quintela    vnc_tls=no
17078d5d2d4cSths  fi
17088d5d2d4cSthsfi
17098d5d2d4cSths
17108d5d2d4cSths##########################################
17112f9606b3Saliguori# VNC SASL detection
1712821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
17132f9606b3Saliguori  cat > $TMPC <<EOF
17142f9606b3Saliguori#include <sasl/sasl.h>
17152f9606b3Saliguori#include <stdio.h>
17162f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
17172f9606b3SaliguoriEOF
17182f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
17192f9606b3Saliguori  vnc_sasl_cflags=""
17202f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
172152166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1722ea784e3bSJuan Quintela    vnc_sasl=yes
1723fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
17242f9606b3Saliguori  else
1725ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1726ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1727ea784e3bSJuan Quintela    fi
1728ea784e3bSJuan Quintela    vnc_sasl=no
17292f9606b3Saliguori  fi
17302f9606b3Saliguorifi
17312f9606b3Saliguori
17322f9606b3Saliguori##########################################
17332f6f5c7aSCorentin Chary# VNC JPEG detection
1734821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
17352f6f5c7aSCorentin Charycat > $TMPC <<EOF
17362f6f5c7aSCorentin Chary#include <stdio.h>
17372f6f5c7aSCorentin Chary#include <jpeglib.h>
17382f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
17392f6f5c7aSCorentin CharyEOF
17402f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
17412f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
17422f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
17432f6f5c7aSCorentin Chary    vnc_jpeg=yes
17442f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
17452f6f5c7aSCorentin Chary  else
17462f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
17472f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
17482f6f5c7aSCorentin Chary    fi
17492f6f5c7aSCorentin Chary    vnc_jpeg=no
17502f6f5c7aSCorentin Chary  fi
17512f6f5c7aSCorentin Charyfi
17522f6f5c7aSCorentin Chary
17532f6f5c7aSCorentin Chary##########################################
1754efe556adSCorentin Chary# VNC PNG detection
1755821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1756efe556adSCorentin Charycat > $TMPC <<EOF
1757efe556adSCorentin Chary//#include <stdio.h>
1758efe556adSCorentin Chary#include <png.h>
1759832ce9c2SScott Wood#include <stddef.h>
1760efe556adSCorentin Charyint main(void) {
1761efe556adSCorentin Chary    png_structp png_ptr;
1762efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
17637edc3fedSPeter Maydell    return png_ptr != 0;
1764efe556adSCorentin Chary}
1765efe556adSCorentin CharyEOF
17669af8025eSBrad  if $pkg_config libpng --modversion >/dev/null 2>&1; then
17679af8025eSBrad    vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
17689af8025eSBrad    vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
17699af8025eSBrad  else
1770efe556adSCorentin Chary    vnc_png_cflags=""
1771efe556adSCorentin Chary    vnc_png_libs="-lpng"
17729af8025eSBrad  fi
1773efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1774efe556adSCorentin Chary    vnc_png=yes
1775efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
17769af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1777efe556adSCorentin Chary  else
1778efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1779efe556adSCorentin Chary      feature_not_found "vnc-png"
1780efe556adSCorentin Chary    fi
1781efe556adSCorentin Chary    vnc_png=no
1782efe556adSCorentin Chary  fi
1783efe556adSCorentin Charyfi
1784efe556adSCorentin Chary
1785efe556adSCorentin Chary##########################################
178676655d6dSaliguori# fnmatch() probe, used for ACL routines
178776655d6dSaliguorifnmatch="no"
178876655d6dSaliguoricat > $TMPC << EOF
178976655d6dSaliguori#include <fnmatch.h>
179076655d6dSaliguoriint main(void)
179176655d6dSaliguori{
179276655d6dSaliguori    fnmatch("foo", "foo", 0);
179376655d6dSaliguori    return 0;
179476655d6dSaliguori}
179576655d6dSaliguoriEOF
179652166aa0SJuan Quintelaif compile_prog "" "" ; then
179776655d6dSaliguori   fnmatch="yes"
179876655d6dSaliguorifi
179976655d6dSaliguori
180076655d6dSaliguori##########################################
1801ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1802ee682d27SStefan Weilif test "$uuid" != "no" ; then
1803ee682d27SStefan Weil  uuid_libs="-luuid"
1804ee682d27SStefan Weil  cat > $TMPC << EOF
1805ee682d27SStefan Weil#include <uuid/uuid.h>
1806ee682d27SStefan Weilint main(void)
1807ee682d27SStefan Weil{
1808ee682d27SStefan Weil    uuid_t my_uuid;
1809ee682d27SStefan Weil    uuid_generate(my_uuid);
1810ee682d27SStefan Weil    return 0;
1811ee682d27SStefan Weil}
1812ee682d27SStefan WeilEOF
1813ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1814ee682d27SStefan Weil    uuid="yes"
1815ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1816ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1817ee682d27SStefan Weil  else
1818ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1819ee682d27SStefan Weil      feature_not_found "uuid"
1820ee682d27SStefan Weil    fi
1821ee682d27SStefan Weil    uuid=no
1822ee682d27SStefan Weil  fi
1823ee682d27SStefan Weilfi
1824ee682d27SStefan Weil
1825ee682d27SStefan Weil##########################################
1826dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1827dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1828dce512deSChristoph Hellwig  cat > $TMPC << EOF
1829ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
1830dce512deSChristoph Hellwig#include <xfs/xfs.h>
1831dce512deSChristoph Hellwigint main(void)
1832dce512deSChristoph Hellwig{
1833dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1834dce512deSChristoph Hellwig    return 0;
1835dce512deSChristoph Hellwig}
1836dce512deSChristoph HellwigEOF
1837dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1838dce512deSChristoph Hellwig    xfs="yes"
1839dce512deSChristoph Hellwig  else
1840dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1841dce512deSChristoph Hellwig      feature_not_found "xfs"
1842dce512deSChristoph Hellwig    fi
1843dce512deSChristoph Hellwig    xfs=no
1844dce512deSChristoph Hellwig  fi
1845dce512deSChristoph Hellwigfi
1846dce512deSChristoph Hellwig
1847dce512deSChristoph Hellwig##########################################
18488a16d273Sths# vde libraries probe
1849dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
18504baae0acSJuan Quintela  vde_libs="-lvdeplug"
18518a16d273Sths  cat > $TMPC << EOF
18528a16d273Sths#include <libvdeplug.h>
18534a7f0e06Spbrookint main(void)
18544a7f0e06Spbrook{
18554a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
1856fea08e08SPeter Maydell    char s[] = "";
1857fea08e08SPeter Maydell    vde_open(s, s, &a);
18584a7f0e06Spbrook    return 0;
18594a7f0e06Spbrook}
18608a16d273SthsEOF
186152166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
18624baae0acSJuan Quintela    vde=yes
18638e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
18648e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1865dfb278bdSJuan Quintela  else
1866dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1867dfb278bdSJuan Quintela      feature_not_found "vde"
1868dfb278bdSJuan Quintela    fi
1869dfb278bdSJuan Quintela    vde=no
18708a16d273Sths  fi
18718a16d273Sthsfi
18728a16d273Sths
18738a16d273Sths##########################################
187447e98658SCorey Bryant# libcap-ng library probe
187547e98658SCorey Bryantif test "$cap_ng" != "no" ; then
187647e98658SCorey Bryant  cap_libs="-lcap-ng"
187747e98658SCorey Bryant  cat > $TMPC << EOF
187847e98658SCorey Bryant#include <cap-ng.h>
187947e98658SCorey Bryantint main(void)
188047e98658SCorey Bryant{
188147e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
188247e98658SCorey Bryant    return 0;
188347e98658SCorey Bryant}
188447e98658SCorey BryantEOF
188547e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
188647e98658SCorey Bryant    cap_ng=yes
188747e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
188847e98658SCorey Bryant  else
188947e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
189047e98658SCorey Bryant      feature_not_found "cap_ng"
189147e98658SCorey Bryant    fi
189247e98658SCorey Bryant    cap_ng=no
189347e98658SCorey Bryant  fi
189447e98658SCorey Bryantfi
189547e98658SCorey Bryant
189647e98658SCorey Bryant##########################################
1897c2de5c91Smalc# Sound support libraries probe
18988f28f3fbSths
1899c2de5c91Smalcaudio_drv_probe()
1900c2de5c91Smalc{
1901c2de5c91Smalc    drv=$1
1902c2de5c91Smalc    hdr=$2
1903c2de5c91Smalc    lib=$3
1904c2de5c91Smalc    exp=$4
1905c2de5c91Smalc    cfl=$5
19068f28f3fbSths        cat > $TMPC << EOF
1907c2de5c91Smalc#include <$hdr>
1908c2de5c91Smalcint main(void) { $exp }
19098f28f3fbSthsEOF
191052166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
19118f28f3fbSths        :
19128f28f3fbSths    else
19138f28f3fbSths        echo
1914c2de5c91Smalc        echo "Error: $drv check failed"
1915c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
19168f28f3fbSths        echo
19178f28f3fbSths        exit 1
19188f28f3fbSths    fi
1919c2de5c91Smalc}
1920c2de5c91Smalc
19212fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1922c2de5c91Smalcfor drv in $audio_drv_list; do
1923c2de5c91Smalc    case $drv in
1924c2de5c91Smalc    alsa)
1925c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1926e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
1927a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1928c2de5c91Smalc    ;;
1929c2de5c91Smalc
1930c2de5c91Smalc    fmod)
1931c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1932c2de5c91Smalc        echo
1933c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1934c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1935c2de5c91Smalc        echo
1936c2de5c91Smalc        exit 1
19378f28f3fbSths    fi
1938c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1939a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1940c2de5c91Smalc    ;;
1941c2de5c91Smalc
1942c2de5c91Smalc    esd)
1943c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1944a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
194567f86e8eSJuan Quintela    audio_pt_int="yes"
1946c2de5c91Smalc    ;;
1947b8e59f18Smalc
1948b8e59f18Smalc    pa)
1949a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
1950a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
1951a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
195267f86e8eSJuan Quintela    audio_pt_int="yes"
1953b8e59f18Smalc    ;;
1954b8e59f18Smalc
1955997e690aSJuan Quintela    coreaudio)
1956997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1957997e690aSJuan Quintela    ;;
1958997e690aSJuan Quintela
1959a4bf6780SJuan Quintela    dsound)
1960a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1961d5631638Smalc      audio_win_int="yes"
1962a4bf6780SJuan Quintela    ;;
1963a4bf6780SJuan Quintela
1964a4bf6780SJuan Quintela    oss)
1965a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1966a4bf6780SJuan Quintela    ;;
1967a4bf6780SJuan Quintela
1968a4bf6780SJuan Quintela    sdl|wav)
19692f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
19702f6a1ab0Sblueswir1    ;;
19712f6a1ab0Sblueswir1
1972d5631638Smalc    winwave)
1973d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1974d5631638Smalc      audio_win_int="yes"
1975d5631638Smalc    ;;
1976d5631638Smalc
1977e4c63a6aSmalc    *)
19781c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1979e4c63a6aSmalc        echo
1980e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1981e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1982e4c63a6aSmalc        echo
1983e4c63a6aSmalc        exit 1
1984e4c63a6aSmalc    }
1985e4c63a6aSmalc    ;;
1986c2de5c91Smalc    esac
1987c2de5c91Smalcdone
19888f28f3fbSths
19894d3b6f6eSbalrog##########################################
19902e4d9fb1Saurel32# BrlAPI probe
19912e4d9fb1Saurel32
19924ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1993eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
19942e4d9fb1Saurel32  cat > $TMPC << EOF
19952e4d9fb1Saurel32#include <brlapi.h>
1996832ce9c2SScott Wood#include <stddef.h>
19972e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
19982e4d9fb1Saurel32EOF
199952166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
20002e4d9fb1Saurel32    brlapi=yes
2001264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
20024ffcedb6SJuan Quintela  else
20034ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
20044ffcedb6SJuan Quintela      feature_not_found "brlapi"
20054ffcedb6SJuan Quintela    fi
20064ffcedb6SJuan Quintela    brlapi=no
2007eb82284fSJuan Quintela  fi
2008eb82284fSJuan Quintelafi
20092e4d9fb1Saurel32
20102e4d9fb1Saurel32##########################################
20114d3b6f6eSbalrog# curses probe
2012e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
2013e095e2f3SStefan Weil    curses_list="-lpdcurses"
2014e095e2f3SStefan Weilelse
20154f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
2016e095e2f3SStefan Weilfi
20174d3b6f6eSbalrog
2018c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
2019c584a6d0SJuan Quintela  curses_found=no
20204d3b6f6eSbalrog  cat > $TMPC << EOF
20214d3b6f6eSbalrog#include <curses.h>
2022ef9a2524SStefan Weilint main(void) {
2023ef9a2524SStefan Weil  const char *s = curses_version();
2024ef9a2524SStefan Weil  resize_term(0, 0);
2025ef9a2524SStefan Weil  return s != 0;
2026ef9a2524SStefan Weil}
20274d3b6f6eSbalrogEOF
20284f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
20294f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2030c584a6d0SJuan Quintela      curses_found=yes
20314f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
20324f78ef9aSJuan Quintela      break
20334d3b6f6eSbalrog    fi
20344f78ef9aSJuan Quintela  done
2035c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2036c584a6d0SJuan Quintela    curses=yes
2037c584a6d0SJuan Quintela  else
2038c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
2039c584a6d0SJuan Quintela      feature_not_found "curses"
2040c584a6d0SJuan Quintela    fi
2041c584a6d0SJuan Quintela    curses=no
2042c584a6d0SJuan Quintela  fi
20434f78ef9aSJuan Quintelafi
20444d3b6f6eSbalrog
2045414f0dabSblueswir1##########################################
2046769ce76dSAlexander Graf# curl probe
2047769ce76dSAlexander Graf
2048a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
2049a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
20504e2b0658SPaolo Bonzinielse
20514e2b0658SPaolo Bonzini  curlconfig=curl-config
20524e2b0658SPaolo Bonzinifi
20534e2b0658SPaolo Bonzini
2054788c8196SJuan Quintelaif test "$curl" != "no" ; then
2055769ce76dSAlexander Graf  cat > $TMPC << EOF
2056769ce76dSAlexander Graf#include <curl/curl.h>
20570b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2058769ce76dSAlexander GrafEOF
20594e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
20604e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2061b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2062769ce76dSAlexander Graf    curl=yes
2063f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2064f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2065788c8196SJuan Quintela  else
2066788c8196SJuan Quintela    if test "$curl" = "yes" ; then
2067788c8196SJuan Quintela      feature_not_found "curl"
2068788c8196SJuan Quintela    fi
2069788c8196SJuan Quintela    curl=no
2070769ce76dSAlexander Graf  fi
2071769ce76dSAlexander Graffi # test "$curl"
2072769ce76dSAlexander Graf
2073769ce76dSAlexander Graf##########################################
2074fb599c9aSbalrog# bluez support probe
2075a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2076e820e3f4Sbalrog  cat > $TMPC << EOF
2077e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2078e820e3f4Sbalrogint main(void) { return bt_error(0); }
2079e820e3f4SbalrogEOF
2080a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2081a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
208252166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2083a20a6f46SJuan Quintela    bluez=yes
2084e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2085e820e3f4Sbalrog  else
2086a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
2087a20a6f46SJuan Quintela      feature_not_found "bluez"
2088a20a6f46SJuan Quintela    fi
2089e820e3f4Sbalrog    bluez="no"
2090e820e3f4Sbalrog  fi
2091fb599c9aSbalrogfi
2092fb599c9aSbalrog
2093fb599c9aSbalrog##########################################
2094e18df141SAnthony Liguori# glib support probe
2095a52d28afSPaolo Bonzini
2096a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2097a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2098a52d28afSPaolo Bonzini    glib_req_ver=2.20
2099a52d28afSPaolo Bonzinielse
2100a52d28afSPaolo Bonzini    glib_req_ver=2.12
2101a52d28afSPaolo Bonzinifi
2102a52d28afSPaolo Bonziniif $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
2103a52d28afSPaolo Bonzinithen
21044b76a481SStefan Hajnoczi    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
21054b76a481SStefan Hajnoczi    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
210614015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2107957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2108e18df141SAnthony Liguorielse
2109a52d28afSPaolo Bonzini    echo "glib-$glib_req_ver required to compile QEMU"
2110e18df141SAnthony Liguori    exit 1
2111e18df141SAnthony Liguorifi
2112e18df141SAnthony Liguori
2113e18df141SAnthony Liguori##########################################
211417bff52bSM. Mohan Kumar# libcap probe
211517bff52bSM. Mohan Kumar
211617bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
211717bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
211817bff52bSM. Mohan Kumar#include <stdio.h>
211917bff52bSM. Mohan Kumar#include <sys/capability.h>
2120cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
212117bff52bSM. Mohan KumarEOF
212217bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
212317bff52bSM. Mohan Kumar    cap=yes
212417bff52bSM. Mohan Kumar  else
212517bff52bSM. Mohan Kumar    cap=no
212617bff52bSM. Mohan Kumar  fi
212717bff52bSM. Mohan Kumarfi
212817bff52bSM. Mohan Kumar
212917bff52bSM. Mohan Kumar##########################################
2130e5d355d1Saliguori# pthread probe
21314b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
21323c529d93Saliguori
2133e5d355d1Saliguoripthread=no
2134414f0dabSblueswir1cat > $TMPC << EOF
21353c529d93Saliguori#include <pthread.h>
21367a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
21377a42bbe4SStefan Weilint main(void) {
21387a42bbe4SStefan Weil  pthread_t thread;
21397a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
21407a42bbe4SStefan Weil  return 0;
21417a42bbe4SStefan Weil}
2142414f0dabSblueswir1EOF
2143bd00d539SAndreas Färberif compile_prog "" "" ; then
2144bd00d539SAndreas Färber  pthread=yes
2145bd00d539SAndreas Färberelse
2146de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
214752166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2148e5d355d1Saliguori      pthread=yes
2149e3c56761SPeter Portante      found=no
2150e3c56761SPeter Portante      for lib_entry in $LIBS; do
2151e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2152e3c56761SPeter Portante          found=yes
2153e3c56761SPeter Portante          break
2154e3c56761SPeter Portante        fi
2155e3c56761SPeter Portante      done
2156e3c56761SPeter Portante      if test "$found" = "no"; then
21575572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2158e3c56761SPeter Portante      fi
2159de65fe0fSSebastian Herbszt      break
2160414f0dabSblueswir1    fi
2161de65fe0fSSebastian Herbszt  done
2162bd00d539SAndreas Färberfi
2163414f0dabSblueswir1
21644617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
21654dd75c70SChristoph Hellwig  echo
21664dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
21674dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
21684dd75c70SChristoph Hellwig  echo
21694dd75c70SChristoph Hellwig  exit 1
2170e5d355d1Saliguorifi
2171e5d355d1Saliguori
2172bf9298b9Saliguori##########################################
2173f27aaf4bSChristian Brunner# rbd probe
2174f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2175f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2176f27aaf4bSChristian Brunner#include <stdio.h>
2177ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2178f27aaf4bSChristian Brunnerint main(void) {
2179ad32e9c0SJosh Durgin    rados_t cluster;
2180ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2181f27aaf4bSChristian Brunner    return 0;
2182f27aaf4bSChristian Brunner}
2183f27aaf4bSChristian BrunnerEOF
2184ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2185f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2186f27aaf4bSChristian Brunner    rbd=yes
2187f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2188f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2189f27aaf4bSChristian Brunner  else
2190f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
2191f27aaf4bSChristian Brunner      feature_not_found "rados block device"
2192f27aaf4bSChristian Brunner    fi
2193f27aaf4bSChristian Brunner    rbd=no
2194f27aaf4bSChristian Brunner  fi
2195f27aaf4bSChristian Brunnerfi
2196f27aaf4bSChristian Brunner
2197f27aaf4bSChristian Brunner##########################################
21985c6c3a6cSChristoph Hellwig# linux-aio probe
21995c6c3a6cSChristoph Hellwig
22005c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
22015c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
22025c6c3a6cSChristoph Hellwig#include <libaio.h>
22035c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2204832ce9c2SScott Wood#include <stddef.h>
22055c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
22065c6c3a6cSChristoph HellwigEOF
22075c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
22085c6c3a6cSChristoph Hellwig    linux_aio=yes
2209048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2210048d179fSPaul Brook    libs_tools="$libs_tools -laio"
22115c6c3a6cSChristoph Hellwig  else
22125c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
22135c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
22145c6c3a6cSChristoph Hellwig    fi
22153cfcae3cSLuiz Capitulino    linux_aio=no
22165c6c3a6cSChristoph Hellwig  fi
22175c6c3a6cSChristoph Hellwigfi
22185c6c3a6cSChristoph Hellwig
22195c6c3a6cSChristoph Hellwig##########################################
2220758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2221758e8e38SVenkateswararao Jujjuri (JV)
2222758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2223758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2224758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2225758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2226f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2227f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2228f2338fb4SPavel Borzenkov#else
22294f26f2b6SAvi Kivity#include <sys/xattr.h>
2230f2338fb4SPavel Borzenkov#endif
2231758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2232758e8e38SVenkateswararao Jujjuri (JV)EOF
22334f26f2b6SAvi Kivity  if compile_prog "" "" ; then
22344f26f2b6SAvi Kivity    attr=yes
22354f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2236f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2237758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2238758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
22394f26f2b6SAvi Kivity    libattr=yes
2240758e8e38SVenkateswararao Jujjuri (JV)  else
2241758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2242758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2243758e8e38SVenkateswararao Jujjuri (JV)    fi
2244758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2245758e8e38SVenkateswararao Jujjuri (JV)  fi
2246758e8e38SVenkateswararao Jujjuri (JV)fi
2247758e8e38SVenkateswararao Jujjuri (JV)
2248758e8e38SVenkateswararao Jujjuri (JV)##########################################
2249bf9298b9Saliguori# iovec probe
2250bf9298b9Saliguoricat > $TMPC <<EOF
2251db34f0b3Sblueswir1#include <sys/types.h>
2252bf9298b9Saliguori#include <sys/uio.h>
2253db34f0b3Sblueswir1#include <unistd.h>
2254f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2255bf9298b9SaliguoriEOF
2256bf9298b9Saliguoriiovec=no
225752166aa0SJuan Quintelaif compile_prog "" "" ; then
2258bf9298b9Saliguori  iovec=yes
2259bf9298b9Saliguorifi
2260bf9298b9Saliguori
2261f652e6afSaurel32##########################################
2262ceb42de8Saliguori# preadv probe
2263ceb42de8Saliguoricat > $TMPC <<EOF
2264ceb42de8Saliguori#include <sys/types.h>
2265ceb42de8Saliguori#include <sys/uio.h>
2266ceb42de8Saliguori#include <unistd.h>
2267c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2268ceb42de8SaliguoriEOF
2269ceb42de8Saliguoripreadv=no
227052166aa0SJuan Quintelaif compile_prog "" "" ; then
2271ceb42de8Saliguori  preadv=yes
2272ceb42de8Saliguorifi
2273ceb42de8Saliguori
2274ceb42de8Saliguori##########################################
2275f652e6afSaurel32# fdt probe
22762df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2277b41af4baSJuan Quintela  fdt_libs="-lfdt"
2278f652e6afSaurel32  cat > $TMPC << EOF
2279f652e6afSaurel32int main(void) { return 0; }
2280f652e6afSaurel32EOF
228152166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2282f652e6afSaurel32    fdt=yes
22832df87df7SJuan Quintela  else
22842df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
22852df87df7SJuan Quintela      feature_not_found "fdt"
22862df87df7SJuan Quintela    fi
2287de3a354aSMichael Walle    fdt_libs=
22882df87df7SJuan Quintela    fdt=no
2289f652e6afSaurel32  fi
2290f652e6afSaurel32fi
2291f652e6afSaurel32
229220ff075bSMichael Walle##########################################
229320ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
229420ff075bSMichael Walleif test "$opengl" != "no" ; then
229520ff075bSMichael Walle  opengl_libs="-lGL"
229620ff075bSMichael Walle  cat > $TMPC << EOF
229720ff075bSMichael Walle#include <X11/Xlib.h>
229820ff075bSMichael Walle#include <GL/gl.h>
229920ff075bSMichael Walle#include <GL/glx.h>
230084972cbbSStefan Weilint main(void) { return GL_VERSION != 0; }
230120ff075bSMichael WalleEOF
230220ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
230320ff075bSMichael Walle    opengl=yes
230420ff075bSMichael Walle  else
230520ff075bSMichael Walle    if test "$opengl" = "yes" ; then
230620ff075bSMichael Walle      feature_not_found "opengl"
230720ff075bSMichael Walle    fi
2308de3a354aSMichael Walle    opengl_libs=
230920ff075bSMichael Walle    opengl=no
231020ff075bSMichael Walle  fi
231120ff075bSMichael Wallefi
231220ff075bSMichael Walle
2313*eb100396SBharata B Rao##########################################
2314*eb100396SBharata B Rao# glusterfs probe
2315*eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
2316*eb100396SBharata B Rao  cat > $TMPC <<EOF
2317*eb100396SBharata B Rao#include <glusterfs/api/glfs.h>
2318*eb100396SBharata B Raoint main(void) {
2319*eb100396SBharata B Rao    (void) glfs_new("volume");
2320*eb100396SBharata B Rao    return 0;
2321*eb100396SBharata B Rao}
2322*eb100396SBharata B RaoEOF
2323*eb100396SBharata B Rao  glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
2324*eb100396SBharata B Rao  if compile_prog "" "$glusterfs_libs" ; then
2325*eb100396SBharata B Rao    glusterfs=yes
2326*eb100396SBharata B Rao    libs_tools="$glusterfs_libs $libs_tools"
2327*eb100396SBharata B Rao    libs_softmmu="$glusterfs_libs $libs_softmmu"
2328*eb100396SBharata B Rao  else
2329*eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
2330*eb100396SBharata B Rao      feature_not_found "GlusterFS backend support"
2331*eb100396SBharata B Rao    fi
2332*eb100396SBharata B Rao    glusterfs=no
2333*eb100396SBharata B Rao  fi
2334*eb100396SBharata B Raofi
2335*eb100396SBharata B Rao
23363b3f24adSaurel32#
23373b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
23383b3f24adSaurel32# emulator.  This is done because older glibc versions don't
23393b3f24adSaurel32# have syscall stubs for these implemented.
23403b3f24adSaurel32#
23413b3f24adSaurel32atfile=no
23423b3f24adSaurel32cat > $TMPC << EOF
23433b3f24adSaurel32#define _ATFILE_SOURCE
23443b3f24adSaurel32#include <sys/types.h>
23453b3f24adSaurel32#include <fcntl.h>
23463b3f24adSaurel32#include <unistd.h>
23473b3f24adSaurel32
23483b3f24adSaurel32int
23493b3f24adSaurel32main(void)
23503b3f24adSaurel32{
23513b3f24adSaurel32	/* try to unlink nonexisting file */
23523b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
23533b3f24adSaurel32}
23543b3f24adSaurel32EOF
235552166aa0SJuan Quintelaif compile_prog "" "" ; then
23563b3f24adSaurel32  atfile=yes
23573b3f24adSaurel32fi
23583b3f24adSaurel32
235939386ac7Saurel32# Check for inotify functions when we are building linux-user
23603b3f24adSaurel32# emulator.  This is done because older glibc versions don't
23613b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
23623b3f24adSaurel32# don't provide them even if kernel supports them.
23633b3f24adSaurel32#
23643b3f24adSaurel32inotify=no
23653b3f24adSaurel32cat > $TMPC << EOF
23663b3f24adSaurel32#include <sys/inotify.h>
23673b3f24adSaurel32
23683b3f24adSaurel32int
23693b3f24adSaurel32main(void)
23703b3f24adSaurel32{
23713b3f24adSaurel32	/* try to start inotify */
23728690e420Saurel32	return inotify_init();
23733b3f24adSaurel32}
23743b3f24adSaurel32EOF
237552166aa0SJuan Quintelaif compile_prog "" "" ; then
23763b3f24adSaurel32  inotify=yes
23773b3f24adSaurel32fi
23783b3f24adSaurel32
2379c05c7a73SRiku Voipioinotify1=no
2380c05c7a73SRiku Voipiocat > $TMPC << EOF
2381c05c7a73SRiku Voipio#include <sys/inotify.h>
2382c05c7a73SRiku Voipio
2383c05c7a73SRiku Voipioint
2384c05c7a73SRiku Voipiomain(void)
2385c05c7a73SRiku Voipio{
2386c05c7a73SRiku Voipio    /* try to start inotify */
2387c05c7a73SRiku Voipio    return inotify_init1(0);
2388c05c7a73SRiku Voipio}
2389c05c7a73SRiku VoipioEOF
2390c05c7a73SRiku Voipioif compile_prog "" "" ; then
2391c05c7a73SRiku Voipio  inotify1=yes
2392c05c7a73SRiku Voipiofi
2393c05c7a73SRiku Voipio
2394ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2395ebc996f3SRiku Voipioutimens=no
2396ebc996f3SRiku Voipiocat > $TMPC << EOF
2397ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2398ebc996f3SRiku Voipio#include <stddef.h>
2399ebc996f3SRiku Voipio#include <fcntl.h>
24003014ee00SPeter Maydell#include <sys/stat.h>
2401ebc996f3SRiku Voipio
2402ebc996f3SRiku Voipioint main(void)
2403ebc996f3SRiku Voipio{
2404ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2405ebc996f3SRiku Voipio    futimens(0, NULL);
2406ebc996f3SRiku Voipio    return 0;
2407ebc996f3SRiku Voipio}
2408ebc996f3SRiku VoipioEOF
240952166aa0SJuan Quintelaif compile_prog "" "" ; then
2410ebc996f3SRiku Voipio  utimens=yes
2411ebc996f3SRiku Voipiofi
2412ebc996f3SRiku Voipio
2413099d6b0fSRiku Voipio# check if pipe2 is there
2414099d6b0fSRiku Voipiopipe2=no
2415099d6b0fSRiku Voipiocat > $TMPC << EOF
2416099d6b0fSRiku Voipio#include <unistd.h>
2417099d6b0fSRiku Voipio#include <fcntl.h>
2418099d6b0fSRiku Voipio
2419099d6b0fSRiku Voipioint main(void)
2420099d6b0fSRiku Voipio{
2421099d6b0fSRiku Voipio    int pipefd[2];
2422099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2423099d6b0fSRiku Voipio    return 0;
2424099d6b0fSRiku Voipio}
2425099d6b0fSRiku VoipioEOF
242652166aa0SJuan Quintelaif compile_prog "" "" ; then
2427099d6b0fSRiku Voipio  pipe2=yes
2428099d6b0fSRiku Voipiofi
2429099d6b0fSRiku Voipio
243040ff6d7eSKevin Wolf# check if accept4 is there
243140ff6d7eSKevin Wolfaccept4=no
243240ff6d7eSKevin Wolfcat > $TMPC << EOF
243340ff6d7eSKevin Wolf#include <sys/socket.h>
243440ff6d7eSKevin Wolf#include <stddef.h>
243540ff6d7eSKevin Wolf
243640ff6d7eSKevin Wolfint main(void)
243740ff6d7eSKevin Wolf{
243840ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
243940ff6d7eSKevin Wolf    return 0;
244040ff6d7eSKevin Wolf}
244140ff6d7eSKevin WolfEOF
244240ff6d7eSKevin Wolfif compile_prog "" "" ; then
244340ff6d7eSKevin Wolf  accept4=yes
244440ff6d7eSKevin Wolffi
244540ff6d7eSKevin Wolf
24463ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
24473ce34dfbSvibisreenivasansplice=no
24483ce34dfbSvibisreenivasancat > $TMPC << EOF
24493ce34dfbSvibisreenivasan#include <unistd.h>
24503ce34dfbSvibisreenivasan#include <fcntl.h>
24513ce34dfbSvibisreenivasan#include <limits.h>
24523ce34dfbSvibisreenivasan
24533ce34dfbSvibisreenivasanint main(void)
24543ce34dfbSvibisreenivasan{
245566ea0f22SStefan Weil    int len, fd = 0;
24563ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
24573ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
24583ce34dfbSvibisreenivasan    return 0;
24593ce34dfbSvibisreenivasan}
24603ce34dfbSvibisreenivasanEOF
246152166aa0SJuan Quintelaif compile_prog "" "" ; then
24623ce34dfbSvibisreenivasan  splice=yes
24633ce34dfbSvibisreenivasanfi
24643ce34dfbSvibisreenivasan
2465dcc38d1cSMarcelo Tosatti##########################################
2466dcc38d1cSMarcelo Tosatti# signalfd probe
2467dcc38d1cSMarcelo Tosattisignalfd="no"
2468dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2469dcc38d1cSMarcelo Tosatti#include <unistd.h>
2470dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2471dcc38d1cSMarcelo Tosatti#include <signal.h>
2472dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2473dcc38d1cSMarcelo TosattiEOF
2474dcc38d1cSMarcelo Tosatti
2475dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2476dcc38d1cSMarcelo Tosatti  signalfd=yes
2477dcc38d1cSMarcelo Tosattifi
2478dcc38d1cSMarcelo Tosatti
2479c2882b96SRiku Voipio# check if eventfd is supported
2480c2882b96SRiku Voipioeventfd=no
2481c2882b96SRiku Voipiocat > $TMPC << EOF
2482c2882b96SRiku Voipio#include <sys/eventfd.h>
2483c2882b96SRiku Voipio
2484c2882b96SRiku Voipioint main(void)
2485c2882b96SRiku Voipio{
248655cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2487c2882b96SRiku Voipio}
2488c2882b96SRiku VoipioEOF
2489c2882b96SRiku Voipioif compile_prog "" "" ; then
2490c2882b96SRiku Voipio  eventfd=yes
2491c2882b96SRiku Voipiofi
2492c2882b96SRiku Voipio
2493d0927938SUlrich Hecht# check for fallocate
2494d0927938SUlrich Hechtfallocate=no
2495d0927938SUlrich Hechtcat > $TMPC << EOF
2496d0927938SUlrich Hecht#include <fcntl.h>
2497d0927938SUlrich Hecht
2498d0927938SUlrich Hechtint main(void)
2499d0927938SUlrich Hecht{
2500d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2501d0927938SUlrich Hecht    return 0;
2502d0927938SUlrich Hecht}
2503d0927938SUlrich HechtEOF
25048fb03151SPeter Maydellif compile_prog "" "" ; then
2505d0927938SUlrich Hecht  fallocate=yes
2506d0927938SUlrich Hechtfi
2507d0927938SUlrich Hecht
2508c727f47dSPeter Maydell# check for sync_file_range
2509c727f47dSPeter Maydellsync_file_range=no
2510c727f47dSPeter Maydellcat > $TMPC << EOF
2511c727f47dSPeter Maydell#include <fcntl.h>
2512c727f47dSPeter Maydell
2513c727f47dSPeter Maydellint main(void)
2514c727f47dSPeter Maydell{
2515c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2516c727f47dSPeter Maydell    return 0;
2517c727f47dSPeter Maydell}
2518c727f47dSPeter MaydellEOF
25198fb03151SPeter Maydellif compile_prog "" "" ; then
2520c727f47dSPeter Maydell  sync_file_range=yes
2521c727f47dSPeter Maydellfi
2522c727f47dSPeter Maydell
2523dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2524dace20dcSPeter Maydellfiemap=no
2525dace20dcSPeter Maydellcat > $TMPC << EOF
2526dace20dcSPeter Maydell#include <sys/ioctl.h>
2527dace20dcSPeter Maydell#include <linux/fs.h>
2528dace20dcSPeter Maydell#include <linux/fiemap.h>
2529dace20dcSPeter Maydell
2530dace20dcSPeter Maydellint main(void)
2531dace20dcSPeter Maydell{
2532dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2533dace20dcSPeter Maydell    return 0;
2534dace20dcSPeter Maydell}
2535dace20dcSPeter MaydellEOF
25368fb03151SPeter Maydellif compile_prog "" "" ; then
2537dace20dcSPeter Maydell  fiemap=yes
2538dace20dcSPeter Maydellfi
2539dace20dcSPeter Maydell
2540d0927938SUlrich Hecht# check for dup3
2541d0927938SUlrich Hechtdup3=no
2542d0927938SUlrich Hechtcat > $TMPC << EOF
2543d0927938SUlrich Hecht#include <unistd.h>
2544d0927938SUlrich Hecht
2545d0927938SUlrich Hechtint main(void)
2546d0927938SUlrich Hecht{
2547d0927938SUlrich Hecht    dup3(0, 0, 0);
2548d0927938SUlrich Hecht    return 0;
2549d0927938SUlrich Hecht}
2550d0927938SUlrich HechtEOF
255178f5d726SJan Kiszkaif compile_prog "" "" ; then
2552d0927938SUlrich Hecht  dup3=yes
2553d0927938SUlrich Hechtfi
2554d0927938SUlrich Hecht
25553b6edd16SPeter Maydell# check for epoll support
25563b6edd16SPeter Maydellepoll=no
25573b6edd16SPeter Maydellcat > $TMPC << EOF
25583b6edd16SPeter Maydell#include <sys/epoll.h>
25593b6edd16SPeter Maydell
25603b6edd16SPeter Maydellint main(void)
25613b6edd16SPeter Maydell{
25623b6edd16SPeter Maydell    epoll_create(0);
25633b6edd16SPeter Maydell    return 0;
25643b6edd16SPeter Maydell}
25653b6edd16SPeter MaydellEOF
25668fb03151SPeter Maydellif compile_prog "" "" ; then
25673b6edd16SPeter Maydell  epoll=yes
25683b6edd16SPeter Maydellfi
25693b6edd16SPeter Maydell
25703b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
25713b6edd16SPeter Maydell# so we must check separately for their presence
25723b6edd16SPeter Maydellepoll_create1=no
25733b6edd16SPeter Maydellcat > $TMPC << EOF
25743b6edd16SPeter Maydell#include <sys/epoll.h>
25753b6edd16SPeter Maydell
25763b6edd16SPeter Maydellint main(void)
25773b6edd16SPeter Maydell{
257819e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
257919e83f6bSPeter Maydell     * a function being called. This is necessary so that on
258019e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
258119e83f6bSPeter Maydell     * the library but not declared in the header file we will
258219e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
258319e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
258419e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
258519e83f6bSPeter Maydell     */
2586c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
25873b6edd16SPeter Maydell}
25883b6edd16SPeter MaydellEOF
25898fb03151SPeter Maydellif compile_prog "" "" ; then
25903b6edd16SPeter Maydell  epoll_create1=yes
25913b6edd16SPeter Maydellfi
25923b6edd16SPeter Maydell
25933b6edd16SPeter Maydellepoll_pwait=no
25943b6edd16SPeter Maydellcat > $TMPC << EOF
25953b6edd16SPeter Maydell#include <sys/epoll.h>
25963b6edd16SPeter Maydell
25973b6edd16SPeter Maydellint main(void)
25983b6edd16SPeter Maydell{
25993b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
26003b6edd16SPeter Maydell    return 0;
26013b6edd16SPeter Maydell}
26023b6edd16SPeter MaydellEOF
26038fb03151SPeter Maydellif compile_prog "" "" ; then
26043b6edd16SPeter Maydell  epoll_pwait=yes
26053b6edd16SPeter Maydellfi
26063b6edd16SPeter Maydell
2607cc8ae6deSpbrook# Check if tools are available to build documentation.
2608a25dba17SJuan Quintelaif test "$docs" != "no" ; then
260901668d98SStefan Weil  if has makeinfo && has pod2man; then
2610a25dba17SJuan Quintela    docs=yes
261183a3ab8bSJuan Quintela  else
2612a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2613a25dba17SJuan Quintela      feature_not_found "docs"
261483a3ab8bSJuan Quintela    fi
2615a25dba17SJuan Quintela    docs=no
261683a3ab8bSJuan Quintela  fi
2617cc8ae6deSpbrookfi
2618cc8ae6deSpbrook
2619f514f41cSStefan Weil# Search for bswap_32 function
26206ae9a1f4SJuan Quintelabyteswap_h=no
26216ae9a1f4SJuan Quintelacat > $TMPC << EOF
26226ae9a1f4SJuan Quintela#include <byteswap.h>
26236ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
26246ae9a1f4SJuan QuintelaEOF
262552166aa0SJuan Quintelaif compile_prog "" "" ; then
26266ae9a1f4SJuan Quintela  byteswap_h=yes
26276ae9a1f4SJuan Quintelafi
26286ae9a1f4SJuan Quintela
2629f514f41cSStefan Weil# Search for bswap_32 function
26306ae9a1f4SJuan Quintelabswap_h=no
26316ae9a1f4SJuan Quintelacat > $TMPC << EOF
26326ae9a1f4SJuan Quintela#include <sys/endian.h>
26336ae9a1f4SJuan Quintela#include <sys/types.h>
26346ae9a1f4SJuan Quintela#include <machine/bswap.h>
26356ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
26366ae9a1f4SJuan QuintelaEOF
263752166aa0SJuan Quintelaif compile_prog "" "" ; then
26386ae9a1f4SJuan Quintela  bswap_h=yes
26396ae9a1f4SJuan Quintelafi
26406ae9a1f4SJuan Quintela
2641da93a1fdSaliguori##########################################
2642c589b249SRonnie Sahlberg# Do we have libiscsi
2643fa6acb0cSRonnie Sahlberg# We check for iscsi_unmap_sync() to make sure we have a
2644fa6acb0cSRonnie Sahlberg# recent enough version of libiscsi.
2645c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2646c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2647fa6acb0cSRonnie Sahlberg#include <stdio.h>
2648c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2649fa6acb0cSRonnie Sahlbergint main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2650c589b249SRonnie SahlbergEOF
2651417c9d72SAlexander Graf  if compile_prog "" "-liscsi" ; then
2652c589b249SRonnie Sahlberg    libiscsi="yes"
2653c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2654c589b249SRonnie Sahlberg  else
2655c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2656c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2657c589b249SRonnie Sahlberg    fi
2658c589b249SRonnie Sahlberg    libiscsi="no"
2659c589b249SRonnie Sahlberg  fi
2660c589b249SRonnie Sahlbergfi
2661c589b249SRonnie Sahlberg
2662c589b249SRonnie Sahlberg
2663c589b249SRonnie Sahlberg##########################################
26648bacde8dSNatanael Copa# Do we need libm
26658bacde8dSNatanael Copacat > $TMPC << EOF
26668bacde8dSNatanael Copa#include <math.h>
26678bacde8dSNatanael Copaint main(void) { return isnan(sin(0.0)); }
26688bacde8dSNatanael CopaEOF
26698bacde8dSNatanael Copaif compile_prog "" "" ; then
26708bacde8dSNatanael Copa  :
26718bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
26728bacde8dSNatanael Copa  LIBS="-lm $LIBS"
26738bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
26748bacde8dSNatanael Copaelse
26758bacde8dSNatanael Copa  echo
26768bacde8dSNatanael Copa  echo "Error: libm check failed"
26778bacde8dSNatanael Copa  echo
26788bacde8dSNatanael Copa  exit 1
26798bacde8dSNatanael Copafi
26808bacde8dSNatanael Copa
26818bacde8dSNatanael Copa##########################################
2682da93a1fdSaliguori# Do we need librt
26838bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
26848bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
26858bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
26868bacde8dSNatanael Copa# function in addition.
2687da93a1fdSaliguoricat > $TMPC <<EOF
2688da93a1fdSaliguori#include <signal.h>
2689da93a1fdSaliguori#include <time.h>
26908bacde8dSNatanael Copaint main(void) {
26918bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
26928bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
26938bacde8dSNatanael Copa}
2694da93a1fdSaliguoriEOF
2695da93a1fdSaliguori
269652166aa0SJuan Quintelaif compile_prog "" "" ; then
269707ffa4bdSJuan Quintela  :
26988bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
26998bacde8dSNatanael Copaelif compile_prog "" "-lrt $pthread_lib" ; then
270007ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
27018bacde8dSNatanael Copa  libs_qga="-lrt $libs_qga"
2702da93a1fdSaliguorifi
2703da93a1fdSaliguori
270431ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2705179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
27066362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
27076362a53fSJuan Quintelafi
27086362a53fSJuan Quintela
2709de5071c5SBlue Swirl##########################################
2710cd4ec0b4SGerd Hoffmann# spice probe
2711cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2712cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2713cd4ec0b4SGerd Hoffmann#include <spice.h>
2714cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2715cd4ec0b4SGerd HoffmannEOF
2716710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2717710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
27184295e15aSAlon Levy  if $pkg_config --atleast-version=0.8.2 spice-server >/dev/null 2>&1 && \
27197e3efdacSAlon Levy     $pkg_config --atleast-version=0.8.1 spice-protocol > /dev/null 2>&1 && \
2720cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2721cd4ec0b4SGerd Hoffmann    spice="yes"
2722cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2723cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
27242e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
27252e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
2726020af1c4SAlon Levy    if $pkg_config --atleast-version=0.12.0 spice-protocol >/dev/null 2>&1; then
2727020af1c4SAlon Levy        spice_qxl_io_monitors_config_async="yes"
2728020af1c4SAlon Levy    fi
2729a639ab04SAlon Levy    if $pkg_config --atleast-version=0.12.2 spice-protocol > /dev/null 2>&1; then
2730a639ab04SAlon Levy        spice_qxl_client_monitors_config="yes"
2731a639ab04SAlon Levy    fi
2732cd4ec0b4SGerd Hoffmann  else
2733cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2734cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2735cd4ec0b4SGerd Hoffmann    fi
2736cd4ec0b4SGerd Hoffmann    spice="no"
2737cd4ec0b4SGerd Hoffmann  fi
2738cd4ec0b4SGerd Hoffmannfi
2739cd4ec0b4SGerd Hoffmann
2740111a38b0SRobert Relyea# check for libcacard for smartcard support
2741111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2742111a38b0SRobert Relyea    smartcard="yes"
2743111a38b0SRobert Relyea    smartcard_cflags=""
2744111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2745111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
27465f01e06fSSergei Trofimovich      cat > $TMPC << EOF
27475f01e06fSSergei Trofimovich#include <pk11pub.h>
27485f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
27495f01e06fSSergei TrofimovichEOF
27500b22ef0fSPeter Maydell        smartcard_includes="-I\$(SRC_PATH)/libcacard"
27518c741c22SAlon Levy        libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
27528c741c22SAlon Levy        libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
27536ca026cbSPeter Maydell        test_cflags="$libcacard_cflags"
27546ca026cbSPeter Maydell        # The header files in nss < 3.13.3 have a bug which causes them to
27556ca026cbSPeter Maydell        # emit a warning. If we're going to compile QEMU with -Werror, then
27566ca026cbSPeter Maydell        # test that the headers don't have this bug. Otherwise we would pass
27576ca026cbSPeter Maydell        # the configure test but fail to compile QEMU later.
27586ca026cbSPeter Maydell        if test "$werror" = "yes"; then
27596ca026cbSPeter Maydell            test_cflags="-Werror $test_cflags"
27606ca026cbSPeter Maydell        fi
27615f01e06fSSergei Trofimovich        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
27626ca026cbSPeter Maydell          compile_prog "$test_cflags" "$libcacard_libs"; then
27635f01e06fSSergei Trofimovich            smartcard_nss="yes"
27640b22ef0fSPeter Maydell            QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
27650b22ef0fSPeter Maydell            QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
2766ad4cf3f6SPaul Brook            libs_softmmu="$libcacard_libs $libs_softmmu"
2767111a38b0SRobert Relyea        else
2768111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2769111a38b0SRobert Relyea                feature_not_found "nss"
2770111a38b0SRobert Relyea            fi
2771111a38b0SRobert Relyea            smartcard_nss="no"
2772111a38b0SRobert Relyea        fi
2773111a38b0SRobert Relyea    fi
2774111a38b0SRobert Relyeafi
2775111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2776111a38b0SRobert Relyea    smartcard_nss="no"
2777111a38b0SRobert Relyeafi
2778111a38b0SRobert Relyea
277969354a83SHans de Goede# check for usbredirparser for usb network redirection support
278069354a83SHans de Goedeif test "$usb_redir" != "no" ; then
2781be4a8928SHans de Goede    if $pkg_config --atleast-version=0.5 libusbredirparser >/dev/null 2>&1 ; then
278269354a83SHans de Goede        usb_redir="yes"
278369354a83SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
278469354a83SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
278569354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
278656ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
278769354a83SHans de Goede    else
278869354a83SHans de Goede        if test "$usb_redir" = "yes"; then
278969354a83SHans de Goede            feature_not_found "usb-redir"
279069354a83SHans de Goede        fi
279169354a83SHans de Goede        usb_redir="no"
279269354a83SHans de Goede    fi
279369354a83SHans de Goedefi
279469354a83SHans de Goede
2795cd4ec0b4SGerd Hoffmann##########################################
2796cd4ec0b4SGerd Hoffmann
2797747bbdf7SBlue Swirl##########################################
27985f6b9e8fSBlue Swirl# check if we have fdatasync
27995f6b9e8fSBlue Swirl
28005f6b9e8fSBlue Swirlfdatasync=no
28015f6b9e8fSBlue Swirlcat > $TMPC << EOF
28025f6b9e8fSBlue Swirl#include <unistd.h>
2803d1722a27SAlexandre Raymondint main(void) {
2804d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2805d1722a27SAlexandre Raymondreturn fdatasync(0);
2806d1722a27SAlexandre Raymond#else
2807e172fe11SStefan Weil#error Not supported
2808d1722a27SAlexandre Raymond#endif
2809d1722a27SAlexandre Raymond}
28105f6b9e8fSBlue SwirlEOF
28115f6b9e8fSBlue Swirlif compile_prog "" "" ; then
28125f6b9e8fSBlue Swirl    fdatasync=yes
28135f6b9e8fSBlue Swirlfi
28145f6b9e8fSBlue Swirl
281594a420b1SStefan Hajnoczi##########################################
2816e78815a5SAndreas Färber# check if we have madvise
2817e78815a5SAndreas Färber
2818e78815a5SAndreas Färbermadvise=no
2819e78815a5SAndreas Färbercat > $TMPC << EOF
2820e78815a5SAndreas Färber#include <sys/types.h>
2821e78815a5SAndreas Färber#include <sys/mman.h>
2822832ce9c2SScott Wood#include <stddef.h>
2823e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2824e78815a5SAndreas FärberEOF
2825e78815a5SAndreas Färberif compile_prog "" "" ; then
2826e78815a5SAndreas Färber    madvise=yes
2827e78815a5SAndreas Färberfi
2828e78815a5SAndreas Färber
2829e78815a5SAndreas Färber##########################################
2830e78815a5SAndreas Färber# check if we have posix_madvise
2831e78815a5SAndreas Färber
2832e78815a5SAndreas Färberposix_madvise=no
2833e78815a5SAndreas Färbercat > $TMPC << EOF
2834e78815a5SAndreas Färber#include <sys/mman.h>
2835832ce9c2SScott Wood#include <stddef.h>
2836e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2837e78815a5SAndreas FärberEOF
2838e78815a5SAndreas Färberif compile_prog "" "" ; then
2839e78815a5SAndreas Färber    posix_madvise=yes
2840e78815a5SAndreas Färberfi
2841e78815a5SAndreas Färber
2842e78815a5SAndreas Färber##########################################
284394a420b1SStefan Hajnoczi# check if trace backend exists
284494a420b1SStefan Hajnoczi
2845650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
284694a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
284794a420b1SStefan Hajnoczi  echo
284894a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
284994a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
285094a420b1SStefan Hajnoczi  echo
285194a420b1SStefan Hajnoczi  exit 1
285294a420b1SStefan Hajnoczifi
285394a420b1SStefan Hajnoczi
28547e24e92aSStefan Hajnoczi##########################################
28557e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
28567e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
28577e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
28587e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
28597e24e92aSStefan Hajnoczi#include <ust/marker.h>
28607e24e92aSStefan Hajnocziint main(void) { return 0; }
28617e24e92aSStefan HajnocziEOF
28627e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
286394b4fefaSLluís Vilanova    LIBS="-lust -lurcu-bp $LIBS"
2864c9a2e37cSLluís Vilanova    libs_qga="-lust -lurcu-bp $libs_qga"
28657e24e92aSStefan Hajnoczi  else
28667e24e92aSStefan Hajnoczi    echo
28677e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
28687e24e92aSStefan Hajnoczi    echo
28697e24e92aSStefan Hajnoczi    exit 1
28707e24e92aSStefan Hajnoczi  fi
28717e24e92aSStefan Hajnoczifi
2872b3d08c02SDaniel P. Berrange
2873b3d08c02SDaniel P. Berrange##########################################
2874b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2875b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2876b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2877b3d08c02SDaniel P. Berrange    echo
2878b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2879b3d08c02SDaniel P. Berrange    echo
2880b3d08c02SDaniel P. Berrange    exit 1
2881b3d08c02SDaniel P. Berrange  fi
2882c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2883c276b17dSDaniel P. Berrange  if has 'stap' ; then
2884c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2885c276b17dSDaniel P. Berrange  fi
2886b3d08c02SDaniel P. Berrangefi
2887b3d08c02SDaniel P. Berrange
28887e24e92aSStefan Hajnoczi##########################################
2889023367e6SWolfgang Mauerer# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2890023367e6SWolfgang Mauerer# use i686 as default anyway, but for those that don't, an explicit
2891023367e6SWolfgang Mauerer# specification is necessary
28921ba16968SStefan Weilif test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
2893023367e6SWolfgang Mauerer  cat > $TMPC << EOF
28947ace252aSStefan Weilstatic int sfaa(int *ptr)
2895023367e6SWolfgang Mauerer{
2896023367e6SWolfgang Mauerer  return __sync_fetch_and_and(ptr, 0);
2897023367e6SWolfgang Mauerer}
2898023367e6SWolfgang Mauerer
2899023367e6SWolfgang Mauererint main(int argc, char **argv)
2900023367e6SWolfgang Mauerer{
2901023367e6SWolfgang Mauerer  int val = 42;
2902023367e6SWolfgang Mauerer  sfaa(&val);
2903023367e6SWolfgang Mauerer  return val;
2904023367e6SWolfgang Mauerer}
2905023367e6SWolfgang MauererEOF
2906023367e6SWolfgang Mauerer  if ! compile_prog "" "" ; then
2907caa50971SPeter Maydell    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2908023367e6SWolfgang Mauerer  fi
2909023367e6SWolfgang Mauererfi
2910023367e6SWolfgang Mauerer
2911023367e6SWolfgang Mauerer##########################################
2912519175a2SAlex Barcelo# check and set a backend for coroutine
2913d0e2fce5SAneesh Kumar K.V
2914519175a2SAlex Barcelo# default is ucontext, but always fallback to gthread
2915519175a2SAlex Barcelo# windows autodetected by make
2916519175a2SAlex Barceloif test "$coroutine" = "" -o "$coroutine" = "ucontext"; then
2917d0e2fce5SAneesh Kumar K.V  if test "$darwin" != "yes"; then
2918d0e2fce5SAneesh Kumar K.V    cat > $TMPC << EOF
2919d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
2920cdf84806SPeter Maydell#ifdef __stub_makecontext
2921cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
2922cdf84806SPeter Maydell#endif
292375cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
2924d0e2fce5SAneesh Kumar K.VEOF
2925d0e2fce5SAneesh Kumar K.V    if compile_prog "" "" ; then
2926519175a2SAlex Barcelo        coroutine_backend=ucontext
2927519175a2SAlex Barcelo    else
2928519175a2SAlex Barcelo	coroutine_backend=gthread
2929d0e2fce5SAneesh Kumar K.V    fi
2930519175a2SAlex Barcelo  else
2931519175a2SAlex Barcelo    echo "Silently falling back into gthread backend under darwin"
2932519175a2SAlex Barcelo  fi
2933519175a2SAlex Barceloelif test "$coroutine" = "gthread" ; then
2934519175a2SAlex Barcelo  coroutine_backend=gthread
2935519175a2SAlex Barceloelif test "$coroutine" = "windows" ; then
2936519175a2SAlex Barcelo  coroutine_backend=windows
2937fe91bfa8SAlex Barceloelif test "$coroutine" = "sigaltstack" ; then
2938fe91bfa8SAlex Barcelo  coroutine_backend=sigaltstack
2939519175a2SAlex Barceloelse
2940519175a2SAlex Barcelo  echo
2941519175a2SAlex Barcelo  echo "Error: unknown coroutine backend $coroutine"
2942519175a2SAlex Barcelo  echo
2943519175a2SAlex Barcelo  exit 1
2944d0e2fce5SAneesh Kumar K.Vfi
2945d0e2fce5SAneesh Kumar K.V
2946d0e2fce5SAneesh Kumar K.V##########################################
2947d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
2948d2042378SAneesh Kumar K.V
29494e1797f9SStefan Weilopen_by_handle_at=no
2950d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
2951d2042378SAneesh Kumar K.V#include <fcntl.h>
2952acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
2953acc55ba8SStefan Weil# error missing definition
2954acc55ba8SStefan Weil#else
295575cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
2956acc55ba8SStefan Weil#endif
2957d2042378SAneesh Kumar K.VEOF
2958d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
2959d2042378SAneesh Kumar K.V    open_by_handle_at=yes
2960d2042378SAneesh Kumar K.Vfi
2961d2042378SAneesh Kumar K.V
2962e06a765eSHarsh Prateek Bora########################################
2963e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
2964e06a765eSHarsh Prateek Bora
2965e06a765eSHarsh Prateek Boralinux_magic_h=no
2966e06a765eSHarsh Prateek Boracat > $TMPC << EOF
2967e06a765eSHarsh Prateek Bora#include <linux/magic.h>
2968e06a765eSHarsh Prateek Boraint main(void) {
296975cafad7SStefan Weil  return 0;
2970e06a765eSHarsh Prateek Bora}
2971e06a765eSHarsh Prateek BoraEOF
2972e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
2973e06a765eSHarsh Prateek Bora    linux_magic_h=yes
2974e06a765eSHarsh Prateek Borafi
2975e06a765eSHarsh Prateek Bora
29768ab1bf12SLuiz Capitulino########################################
297706d71fa1SPeter Maydell# check whether we can disable the -Wunused-but-set-variable
297806d71fa1SPeter Maydell# option with a pragma (this is needed to silence a warning in
297906d71fa1SPeter Maydell# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.)
298006d71fa1SPeter Maydell# This test has to be compiled with -Werror as otherwise an
298106d71fa1SPeter Maydell# unknown pragma is only a warning.
298206d71fa1SPeter Maydellpragma_disable_unused_but_set=no
298306d71fa1SPeter Maydellcat > $TMPC << EOF
298406d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
298506d71fa1SPeter Maydellint main(void) {
298606d71fa1SPeter Maydell    return 0;
298706d71fa1SPeter Maydell}
298806d71fa1SPeter MaydellEOF
298906d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
299006d71fa1SPeter Maydell    pragma_disable_unused_but_set=yes
299106d71fa1SPeter Maydellfi
299206d71fa1SPeter Maydell
299306d71fa1SPeter Maydell########################################
299462fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
29953f4349dcSKevin Wolf
29963f4349dcSKevin Wolfvalgrind_h=no
29973f4349dcSKevin Wolfcat > $TMPC << EOF
29983f4349dcSKevin Wolf#include <valgrind/valgrind.h>
299962fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
30003f4349dcSKevin Wolfint main(void) {
30013f4349dcSKevin Wolf  return 0;
30023f4349dcSKevin Wolf}
30033f4349dcSKevin WolfEOF
30043f4349dcSKevin Wolfif compile_prog "" "" ; then
30053f4349dcSKevin Wolf    valgrind_h=yes
30063f4349dcSKevin Wolffi
30073f4349dcSKevin Wolf
30083f4349dcSKevin Wolf########################################
30098ab1bf12SLuiz Capitulino# check if environ is declared
30108ab1bf12SLuiz Capitulino
30118ab1bf12SLuiz Capitulinohas_environ=no
30128ab1bf12SLuiz Capitulinocat > $TMPC << EOF
30138ab1bf12SLuiz Capitulino#include <unistd.h>
30148ab1bf12SLuiz Capitulinoint main(void) {
3015c075a723SBlue Swirl    environ = 0;
30168ab1bf12SLuiz Capitulino    return 0;
30178ab1bf12SLuiz Capitulino}
30188ab1bf12SLuiz CapitulinoEOF
30198ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
30208ab1bf12SLuiz Capitulino    has_environ=yes
30218ab1bf12SLuiz Capitulinofi
30228ab1bf12SLuiz Capitulino
3023d2042378SAneesh Kumar K.V##########################################
3024e86ecd4bSJuan Quintela# End of CC checks
3025e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3026e86ecd4bSJuan Quintela
3027e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
30288be74dc0SAvi Kivity  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3029e86ecd4bSJuan Quintelafi
3030a316e378SJuan Quintela
303120ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
303220ff6c80SAnthony Liguori# enable/disable
303320ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
303420ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
303520ff6c80SAnthony Liguori	zero_malloc="no"
303620ff6c80SAnthony Liguori    else
303720ff6c80SAnthony Liguori	zero_malloc="yes"
303820ff6c80SAnthony Liguori    fi
303920ff6c80SAnthony Liguorifi
304020ff6c80SAnthony Liguori
30416ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
30426ca026cbSPeter Maydellif test "$werror" = "yes"; then
30436ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
30446ca026cbSPeter Maydellfi
30456ca026cbSPeter Maydell
3046e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3047e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
30481156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3049e86ecd4bSJuan Quintela    fi
3050e86ecd4bSJuan Quintelafi
3051e86ecd4bSJuan Quintela
305294dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
305394dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
305494dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
305594dd53c5SGerd Hoffmannelse
305694dd53c5SGerd Hoffmann    POD2MAN="pod2man"
305794dd53c5SGerd Hoffmannfi
305894dd53c5SGerd Hoffmann
3059952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3060952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3061952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3062952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3063952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3064952afb71SBlue Swirl        fi
3065952afb71SBlue Swirl    done
3066952afb71SBlue Swirlfi
3067952afb71SBlue Swirl
306810ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3069528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
30705a67135aSbellard
30714b1c11fdSDaniel P. Berrangetools=""
30724b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3073ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
30744b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
30754b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
30764b1c11fdSDaniel P. Berrange  fi
30774b1c11fdSDaniel P. Berrangefi
30784b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3079983eef5aSMeador Inge  if test "$virtfs" != no ; then
3080be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3081983eef5aSMeador Inge      virtfs=yes
308217bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3083983eef5aSMeador Inge    else
3084983eef5aSMeador Inge      if test "$virtfs" = yes; then
3085263ddcc8SHarsh Prateek Bora        echo "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3086263ddcc8SHarsh Prateek Bora        exit 1
3087983eef5aSMeador Inge      fi
308817500370SAndreas Färber      virtfs=no
3089983eef5aSMeador Inge    fi
309017bff52bSM. Mohan Kumar  fi
3091ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3092d138cee9SMichael Roth    if [ "$guest_agent" = "yes" ]; then
309348ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
3094d138cee9SMichael Roth    fi
3095ca35f780SPaolo Bonzini  fi
309600c705fbSPaolo Bonzini  if test "$smartcard_nss" = "yes" ; then
309700c705fbSPaolo Bonzini    tools="vscclient\$(EXESUF) $tools"
309800c705fbSPaolo Bonzini  fi
30994b1c11fdSDaniel P. Berrangefi
3100ca35f780SPaolo Bonzini
3101ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3102ca35f780SPaolo Bonziniroms=
3103ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3104ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3105ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3106ca35f780SPaolo Bonzini  roms="optionrom"
3107ca35f780SPaolo Bonzinifi
3108d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
310939ac8455SDavid Gibson  roms="$roms spapr-rtas"
311039ac8455SDavid Gibsonfi
3111ca35f780SPaolo Bonzini
31127d13299dSbellardecho "Install prefix    $prefix"
3113c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3114f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
31153aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
31168bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
31170f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
31181c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
311911d9f695Sbellardif test "$mingw32" = "no" ; then
3120f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
312143ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
312211d9f695Sbellardfi
31235a67135aSbellardecho "Source path       $source_path"
31247d13299dSbellardecho "C compiler        $cc"
312583469015Sbellardecho "Host C compiler   $host_cc"
31263c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
31270c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3128a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
31290c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
31307d13299dSbellardecho "make              $make"
31316a882643Spbrookecho "install           $install"
3132c886edfbSBlue Swirlecho "python            $python"
3133e2d8830eSBradif test "$slirp" = "yes" ; then
3134e2d8830eSBrad    echo "smbd              $smbd"
3135e2d8830eSBradfi
3136a98fd896Sbellardecho "host CPU          $cpu"
3137de83cd02Sbellardecho "host big endian   $bigendian"
313897a847bcSbellardecho "target list       $target_list"
3139ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
31407d13299dSbellardecho "gprof enabled     $gprof"
314103b4fe7dSaliguoriecho "sparse enabled    $sparse"
31421625af87Saliguoriecho "strip binaries    $strip_opt"
314305c2a3e7Sbellardecho "profiler          $profiler"
314443ce4dfeSbellardecho "static build      $static"
314585aa5189Sbellardecho "-Werror enabled   $werror"
31465b0753e0Sbellardif test "$darwin" = "yes" ; then
31475b0753e0Sbellard    echo "Cocoa support     $cocoa"
31485b0753e0Sbellardfi
314997a847bcSbellardecho "SDL support       $sdl"
31504d3b6f6eSbalrogecho "curses support    $curses"
3151769ce76dSAlexander Grafecho "curl support      $curl"
315267b915a5Sbellardecho "mingw32 support   $mingw32"
31530c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
31540c58ac1cSmalcecho "Extra audio cards $audio_card_list"
3155eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
31568ff9cbf7Smalcecho "Mixer emulation   $mixemu"
3157983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3158821601eaSJes Sorensenecho "VNC support       $vnc"
3159821601eaSJes Sorensenif test "$vnc" = "yes" ; then
31608d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
31612f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
31622f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3163efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
3164821601eaSJes Sorensenfi
31653142255cSblueswir1if test -n "$sparc_cpu"; then
31663142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
31673142255cSblueswir1fi
3168e37630caSaliguoriecho "xen support       $xen"
31692e4d9fb1Saurel32echo "brlapi support    $brlapi"
3170a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3171a25dba17SJuan Quintelaecho "Documentation     $docs"
3172c5937220Spbrook[ ! -z "$uname_release" ] && \
3173c5937220Spbrookecho "uname -r          $uname_release"
3174bd0c5661Spbrookecho "NPTL support      $nptl"
3175379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
317640d6444eSAvi Kivityecho "PIE               $pie"
31778a16d273Sthsecho "vde support       $vde"
31785c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3179758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
318077755340Sthsecho "Install blobs     $blobs"
3181b31a0277SJuan Quintelaecho "KVM support       $kvm"
31829195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3183f652e6afSaurel32echo "fdt support       $fdt"
3184ceb42de8Saliguoriecho "preadv support    $preadv"
31855f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3186e78815a5SAndreas Färberecho "madvise           $madvise"
3187e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
3188ee682d27SStefan Weilecho "uuid support      $uuid"
318947e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3190d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
319194a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
31929410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
31932e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3194f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3195dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3196111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
319769354a83SHans de Goedeecho "usb net redir     $usb_redir"
319820ff075bSMichael Walleecho "OpenGL support    $opengl"
3199c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3200d138cee9SMichael Rothecho "build guest agent $guest_agent"
3201f794573eSEduardo Otuboecho "seccomp support   $seccomp"
3202519175a2SAlex Barceloecho "coroutine backend $coroutine_backend"
3203*eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
320467b915a5Sbellard
32051ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
320624b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3207e8cd23deSbellardfi
320897a847bcSbellard
320998ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
32104bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
321197a847bcSbellard
321298ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
321398ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
321498ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
321598ec69acSJuan Quintelaecho >> $config_host_mak
321698ec69acSJuan Quintela
3217e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
321899d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
321999d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
32203aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
32218bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
32220f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
322399d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
322499d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
322522d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
32269afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
32279afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
32288bf188aaSMichael Tokarevecho "CONFIG_QEMU_HELPERDIR=\"$libexecdir\"" >> $config_host_mak
3229804edf29SJuan Quintela
323098ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3231f8393946Saurel32if test "$debug_tcg" = "yes" ; then
32322358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3233f8393946Saurel32fi
3234f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
32352358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
3236f3d08ee6SPaul Brookfi
32371625af87Saliguoriif test "$strip_opt" = "yes" ; then
323852ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
32391625af87Saliguorifi
32407d13299dSbellardif test "$bigendian" = "yes" ; then
3241e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
324297a847bcSbellardfi
324367b915a5Sbellardif test "$mingw32" = "yes" ; then
324498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
32459fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
32469fe6de94SBlue Swirl  version_major=${rc_version%%.*}
32479fe6de94SBlue Swirl  rc_version=${rc_version#*.}
32489fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
32499fe6de94SBlue Swirl  rc_version=${rc_version#*.}
32509fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
32519fe6de94SBlue Swirl  version_micro=0
32529fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
32539fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3254210fa556Spbrookelse
325535f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3256210fa556Spbrookfi
3257128ab2ffSblueswir1
3258dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3259dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3260dffcb71cSMark McLoughlinfi
3261dffcb71cSMark McLoughlin
326283fb7adfSbellardif test "$darwin" = "yes" ; then
326398ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
326483fb7adfSbellardfi
3265b29fe3edSmalc
3266b29fe3edSmalcif test "$aix" = "yes" ; then
326798ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
3268b29fe3edSmalcfi
3269b29fe3edSmalc
3270ec530c81Sbellardif test "$solaris" = "yes" ; then
327198ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
32722358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
32730475a5caSths  if test "$needs_libsunmath" = "yes" ; then
327475b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
32750475a5caSths  fi
3276ec530c81Sbellardfi
3277179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3278179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3279179cf400SAndreas Färberfi
328097a847bcSbellardif test "$static" = "yes" ; then
328198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
328297a847bcSbellardfi
32831ba16968SStefan Weilif test "$profiler" = "yes" ; then
32842358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
328505c2a3e7Sbellardfi
3286c20709aaSbellardif test "$slirp" = "yes" ; then
328798ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
3288e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3289f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
3290c20709aaSbellardfi
32918a16d273Sthsif test "$vde" = "yes" ; then
329298ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
32938a16d273Sthsfi
329447e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
329547e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
329647e98658SCorey Bryantfi
32970c58ac1cSmalcfor card in $audio_card_list; do
3298bb55b712SStefan Weil    def=CONFIG_`echo $card | LC_ALL=C tr '[a-z]' '[A-Z]'`
329998ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
33000c58ac1cSmalcdone
33012358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
33020c58ac1cSmalcfor drv in $audio_drv_list; do
3303bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
330498ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
3305923e4521Smalc    if test "$drv" = "fmod"; then
33067aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3307fb065187Sbellard    fi
33080c58ac1cSmalcdone
330967f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
331067f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
331167f86e8eSJuan Quintelafi
3312d5631638Smalcif test "$audio_win_int" = "yes" ; then
3313d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3314d5631638Smalcfi
3315eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
33168ff9cbf7Smalcif test "$mixemu" = "yes" ; then
331798ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
33188ff9cbf7Smalcfi
3319821601eaSJes Sorensenif test "$vnc" = "yes" ; then
3320821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
3321821601eaSJes Sorensenfi
33228d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
332398ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
3324525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
33258d5d2d4cSthsfi
33262f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
332798ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
332860ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
33292f9606b3Saliguorifi
3330821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
33312f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
33322f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
33332f6f5c7aSCorentin Charyfi
3334821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
3335efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3336efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
3337efe556adSCorentin Charyfi
333876655d6dSaliguoriif test "$fnmatch" = "yes" ; then
33392358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
334076655d6dSaliguorifi
3341ee682d27SStefan Weilif test "$uuid" = "yes" ; then
3342ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
3343ee682d27SStefan Weilfi
3344dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3345dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3346dce512deSChristoph Hellwigfi
3347b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
334898ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
33492358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
335098ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
335198ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
3352a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
335398ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
3354cc8ae6deSpbrookfi
33551ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
335698ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
33578ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
335849ecc3faSbellardfi
335949ecc3faSbellardif test "$cocoa" = "yes" ; then
336098ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
336149ecc3faSbellardfi
33624d3b6f6eSbalrogif test "$curses" = "yes" ; then
336398ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
3364ab4e5602SJan Kiszkafi
33653b3f24adSaurel32if test "$atfile" = "yes" ; then
33662358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
33673b3f24adSaurel32fi
3368ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
33692358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3370ebc996f3SRiku Voipiofi
3371099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
33722358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
3373099d6b0fSRiku Voipiofi
337440ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
337540ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
337640ff6d7eSKevin Wolffi
33773ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
33782358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
33793ce34dfbSvibisreenivasanfi
3380c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
3381c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
3382c2882b96SRiku Voipiofi
3383d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
3384d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3385d0927938SUlrich Hechtfi
3386c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
3387c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3388c727f47dSPeter Maydellfi
3389dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
3390dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
3391dace20dcSPeter Maydellfi
3392d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
3393d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
3394d0927938SUlrich Hechtfi
33953b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
33963b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
33973b6edd16SPeter Maydellfi
33983b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
33993b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
34003b6edd16SPeter Maydellfi
34013b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
34023b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
34033b6edd16SPeter Maydellfi
34043b3f24adSaurel32if test "$inotify" = "yes" ; then
34052358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
34063b3f24adSaurel32fi
3407c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3408c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3409c05c7a73SRiku Voipiofi
34106ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
34116ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
34126ae9a1f4SJuan Quintelafi
34136ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
34146ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
34156ae9a1f4SJuan Quintelafi
3416769ce76dSAlexander Grafif test "$curl" = "yes" ; then
341798ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3418b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3419769ce76dSAlexander Graffi
34202e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
342198ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
34222e4d9fb1Saurel32fi
3423fb599c9aSbalrogif test "$bluez" = "yes" ; then
342498ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3425ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3426fb599c9aSbalrogfi
3427e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3428e37630caSaliguoriif test "$xen" = "yes" ; then
34296dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3430d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3431e37630caSaliguorifi
34325c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
34335c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
34345c6c3a6cSChristoph Hellwigfi
3435758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3436758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3437758e8e38SVenkateswararao Jujjuri (JV)fi
34384f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
34394f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
34404f26f2b6SAvi Kivityfi
3441983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
3442758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
3443758e8e38SVenkateswararao Jujjuri (JV)fi
344477755340Sthsif test "$blobs" = "yes" ; then
344598ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
344677755340Sthsfi
3447bf9298b9Saliguoriif test "$iovec" = "yes" ; then
34482358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3449bf9298b9Saliguorifi
3450ceb42de8Saliguoriif test "$preadv" = "yes" ; then
34512358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3452ceb42de8Saliguorifi
3453f652e6afSaurel32if test "$fdt" = "yes" ; then
34543f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3455f652e6afSaurel32fi
3456dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3457dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3458dcc38d1cSMarcelo Tosattifi
34599195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
34609195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
34619195b2c2SStefan Weilfi
34625f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
34635f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
34645f6b9e8fSBlue Swirlfi
3465e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3466e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3467e78815a5SAndreas Färberfi
3468e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3469e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3470e78815a5SAndreas Färberfi
347197a847bcSbellard
3472cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3473cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3474cd4ec0b4SGerd Hoffmannfi
3475cd4ec0b4SGerd Hoffmann
3476020af1c4SAlon Levyif test "$spice_qxl_io_monitors_config_async" = "yes" ; then
3477020af1c4SAlon Levy  echo "CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC=y" >> $config_host_mak
3478020af1c4SAlon Levyfi
3479020af1c4SAlon Levy
3480a639ab04SAlon Levyif test "$spice_qxl_client_monitors_config" = "yes" ; then
3481a639ab04SAlon Levy  echo "CONFIG_QXL_CLIENT_MONITORS_CONFIG=y" >> $config_host_mak
3482a639ab04SAlon Levyfi
3483a639ab04SAlon Levy
348436707144SAlon Levyif test "$smartcard" = "yes" ; then
348536707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
348636707144SAlon Levyfi
348736707144SAlon Levy
3488111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3489111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3490ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3491ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3492111a38b0SRobert Relyeafi
3493111a38b0SRobert Relyea
349469354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
349569354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
349669354a83SHans de Goedefi
349769354a83SHans de Goede
349820ff075bSMichael Walleif test "$opengl" = "yes" ; then
349920ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
350020ff075bSMichael Wallefi
350120ff075bSMichael Walle
3502c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3503c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3504c589b249SRonnie Sahlbergfi
3505c589b249SRonnie Sahlberg
3506f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
3507f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
3508f794573eSEduardo Otubofi
3509f794573eSEduardo Otubo
351083fb7adfSbellard# XXX: suppress that
35117d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
35122358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
35137d3505c5Sbellardfi
35147d3505c5Sbellard
35152358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3516c5937220Spbrook
351720ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
351820ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
351920ff6c80SAnthony Liguorifi
3520f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3521f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3522f27aaf4bSChristian Brunnerfi
352320ff6c80SAnthony Liguori
3524519175a2SAlex Barceloif test "$coroutine_backend" = "ucontext" ; then
3525d0e2fce5SAneesh Kumar K.V  echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
3526fe91bfa8SAlex Barceloelif test "$coroutine_backend" = "sigaltstack" ; then
3527fe91bfa8SAlex Barcelo  echo "CONFIG_SIGALTSTACK_COROUTINE=y" >> $config_host_mak
3528d0e2fce5SAneesh Kumar K.Vfi
3529d0e2fce5SAneesh Kumar K.V
3530d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
3531d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3532d2042378SAneesh Kumar K.Vfi
3533d2042378SAneesh Kumar K.V
3534e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
3535e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3536e06a765eSHarsh Prateek Borafi
3537e06a765eSHarsh Prateek Bora
353806d71fa1SPeter Maydellif test "$pragma_disable_unused_but_set" = "yes" ; then
353906d71fa1SPeter Maydell  echo "CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET=y" >> $config_host_mak
354006d71fa1SPeter Maydellfi
354106d71fa1SPeter Maydell
35423f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
35433f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
35443f4349dcSKevin Wolffi
35453f4349dcSKevin Wolf
35468ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
35478ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
35488ab1bf12SLuiz Capitulinofi
35498ab1bf12SLuiz Capitulino
3550*eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
3551*eb100396SBharata B Rao  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
3552*eb100396SBharata B Raofi
3553*eb100396SBharata B Rao
355468063649Sblueswir1# USB host support
355568063649Sblueswir1case "$usb" in
355668063649Sblueswir1linux)
355798ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
355868063649Sblueswir1;;
355968063649Sblueswir1bsd)
356098ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
356168063649Sblueswir1;;
356268063649Sblueswir1*)
356398ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
356468063649Sblueswir1;;
356568063649Sblueswir1esac
356668063649Sblueswir1
3567e4858974SLluís# use default implementation for tracing backend-specific routines
3568e4858974SLluístrace_default=yes
356994a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
35706d8a764eSLluísif test "$trace_backend" = "nop"; then
35716d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
357222890ab5SPrerna Saxenafi
35739410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
35746d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
3575e4858974SLluís  trace_default=no
35766d8a764eSLluís  # Set the appropriate trace file.
3577953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
35789410b56cSPrerna Saxenafi
35796d8a764eSLluísif test "$trace_backend" = "stderr"; then
35806d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
35819a82b6a5SLluís  trace_default=no
35826d8a764eSLluísfi
35836d8a764eSLluísif test "$trace_backend" = "ust"; then
35846d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
35856d8a764eSLluísfi
35866d8a764eSLluísif test "$trace_backend" = "dtrace"; then
35876d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
35886d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
35896d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
35906d8a764eSLluís  fi
3591c276b17dSDaniel P. Berrangefi
35929410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
3593e4858974SLluísif test "$trace_default" = "yes"; then
3594e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3595e4858974SLluísfi
35969410b56cSPrerna Saxena
359798ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
359898ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3599804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3600804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
36011901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
36021901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
36031901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
3604c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
3605804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
36062b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3607804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
36083c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
3609804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3610804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3611804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
36129fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
361344dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3614e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3615a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3616f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3617e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3618e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3619e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3620e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3621e39f0062SPaolo Bonzinifi
3622e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3623a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3624a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
362573da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
36263e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3627804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3628957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
362994dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
3630804edf29SJuan Quintela
36314bf6b55bSJuan Quintela# generate list of library paths for linker script
36324bf6b55bSJuan Quintela
36334bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
36344bf6b55bSJuan Quintela
36354bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
36364bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
36374bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
36384bf6b55bSJuan Quintela  else
36394bf6b55bSJuan Quintela    rm ${config_host_ld}~
36404bf6b55bSJuan Quintela  fi
36414bf6b55bSJuan Quintelafi
36424bf6b55bSJuan Quintela
36434d904533SBlue Swirlfor d in libdis libdis-user; do
364472b8b5a1SStefan Weil    symlink "$source_path/Makefile.dis" "$d/Makefile"
36454d904533SBlue Swirl    echo > $d/config.mak
36464d904533SBlue Swirldone
36474d904533SBlue Swirl
36486efd7517SPeter Maydell# use included Linux headers
36496efd7517SPeter Maydellif test "$linux" = "yes" ; then
3650a307beb6SAndreas Färber  mkdir -p linux-headers
36516efd7517SPeter Maydell  case "$cpu" in
36526efd7517SPeter Maydell  i386|x86_64)
365308312a63SPeter Maydell    linux_arch=x86
36546efd7517SPeter Maydell    ;;
36556efd7517SPeter Maydell  ppcemb|ppc|ppc64)
365608312a63SPeter Maydell    linux_arch=powerpc
36576efd7517SPeter Maydell    ;;
36586efd7517SPeter Maydell  s390x)
365908312a63SPeter Maydell    linux_arch=s390
366008312a63SPeter Maydell    ;;
366108312a63SPeter Maydell  *)
366208312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
366308312a63SPeter Maydell    linux_arch="$cpu"
36646efd7517SPeter Maydell    ;;
36656efd7517SPeter Maydell  esac
366608312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
366708312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
366808312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
366908312a63SPeter Maydell    fi
36706efd7517SPeter Maydellfi
36716efd7517SPeter Maydell
367297a847bcSbellardfor target in $target_list; do
367397a847bcSbellardtarget_dir="$target"
367425be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3675600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
367697a847bcSbellardtarget_bigendian="no"
36771f3d3c8fSJuan Quintela
3678ea2d6a39SJuan Quintelacase "$target_arch2" in
3679e67db06eSJia Liu  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
3680ea2d6a39SJuan Quintela  target_bigendian=yes
3681ea2d6a39SJuan Quintela  ;;
3682ea2d6a39SJuan Quintelaesac
368397a847bcSbellardtarget_softmmu="no"
3684997344f3Sbellardtarget_user_only="no"
3685831b7825Sthstarget_linux_user="no"
368684778508Sblueswir1target_bsd_user="no"
36879e407a85Spbrookcase "$target" in
3688600309b6SBlue Swirl  ${target_arch2}-softmmu)
36899e407a85Spbrook    target_softmmu="yes"
36909e407a85Spbrook    ;;
3691600309b6SBlue Swirl  ${target_arch2}-linux-user)
36929c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
36939c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
36949c7a4202SBlue Swirl      exit 1
36959c7a4202SBlue Swirl    fi
36969e407a85Spbrook    target_user_only="yes"
36979e407a85Spbrook    target_linux_user="yes"
36989e407a85Spbrook    ;;
3699600309b6SBlue Swirl  ${target_arch2}-bsd-user)
37009cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
37019c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
37029c7a4202SBlue Swirl      exit 1
37039c7a4202SBlue Swirl    fi
370484778508Sblueswir1    target_user_only="yes"
370584778508Sblueswir1    target_bsd_user="yes"
370684778508Sblueswir1    ;;
37079e407a85Spbrook  *)
37089e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
37099e407a85Spbrook    exit 1
37109e407a85Spbrook    ;;
37119e407a85Spbrookesac
3712831b7825Sths
371397a847bcSbellardmkdir -p $target_dir
371425be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
371597a847bcSbellard
3716e5fe0c52Spbrookbflt="no"
3717bd0c5661Spbrooktarget_nptl="no"
3718600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
371956aebc89Spbrookgdb_xml_files=""
3720c2e3dee6SLaurent Viviertarget_short_alignment=2
3721c2e3dee6SLaurent Viviertarget_int_alignment=4
3722c2e3dee6SLaurent Viviertarget_long_alignment=4
3723c2e3dee6SLaurent Viviertarget_llong_alignment=8
3724de3a354aSMichael Walletarget_libs_softmmu=
37257ba1e619Saliguori
3726938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
37276acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3728e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3729e73aae67SJuan Quintela
3730600309b6SBlue Swirlcase "$target_arch2" in
37312408a527Saurel32  i386)
373271deff27SAurelien Jarno    target_phys_bits=64
37332408a527Saurel32  ;;
37342408a527Saurel32  x86_64)
37356acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
37361ad2134fSPaul Brook    target_phys_bits=64
3737c2e3dee6SLaurent Vivier    target_long_alignment=8
37382408a527Saurel32  ;;
37392408a527Saurel32  alpha)
37401ad2134fSPaul Brook    target_phys_bits=64
3741c2e3dee6SLaurent Vivier    target_long_alignment=8
3742a4b388ffSRichard Henderson    target_nptl="yes"
37432408a527Saurel32  ;;
37442408a527Saurel32  arm|armeb)
3745b498c8a0SJuan Quintela    TARGET_ARCH=arm
3746e5fe0c52Spbrook    bflt="yes"
3747bd0c5661Spbrook    target_nptl="yes"
374856aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
37493cc0cd61SPeter Maydell    target_phys_bits=64
3750c2e3dee6SLaurent Vivier    target_llong_alignment=4
3751412beee6SGrant Likely    target_libs_softmmu="$fdt_libs"
37522408a527Saurel32  ;;
37532408a527Saurel32  cris)
3754253bd7f8Sedgar_igl    target_nptl="yes"
37551ad2134fSPaul Brook    target_phys_bits=32
37562408a527Saurel32  ;;
3757613a22c9SMichael Walle  lm32)
3758613a22c9SMichael Walle    target_phys_bits=32
3759de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3760613a22c9SMichael Walle  ;;
37612408a527Saurel32  m68k)
37620938cda5Saurel32    bflt="yes"
376356aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
37641ad2134fSPaul Brook    target_phys_bits=32
3765c2e3dee6SLaurent Vivier    target_int_alignment=2
3766c2e3dee6SLaurent Vivier    target_long_alignment=2
3767c2e3dee6SLaurent Vivier    target_llong_alignment=2
37682408a527Saurel32  ;;
3769877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3770877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
377172b675caSEdgar E. Iglesias    bflt="yes"
377272b675caSEdgar E. Iglesias    target_nptl="yes"
377372b675caSEdgar E. Iglesias    target_phys_bits=32
3774de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
377572b675caSEdgar E. Iglesias  ;;
37762408a527Saurel32  mips|mipsel)
3777b498c8a0SJuan Quintela    TARGET_ARCH=mips
377825be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3779f04dc72fSPaul Brook    target_nptl="yes"
37801ad2134fSPaul Brook    target_phys_bits=64
37812408a527Saurel32  ;;
37822408a527Saurel32  mipsn32|mipsn32el)
3783b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
37846acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
378525be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
37861ad2134fSPaul Brook    target_phys_bits=64
37872408a527Saurel32  ;;
37882408a527Saurel32  mips64|mips64el)
3789b498c8a0SJuan Quintela    TARGET_ARCH=mips64
37906acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
379125be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
37921ad2134fSPaul Brook    target_phys_bits=64
3793c2e3dee6SLaurent Vivier    target_long_alignment=8
37942408a527Saurel32  ;;
3795e67db06eSJia Liu  or32)
3796e67db06eSJia Liu    TARGET_ARCH=openrisc
3797e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
3798e67db06eSJia Liu    target_phys_bits=32
3799e67db06eSJia Liu  ;;
38002408a527Saurel32  ppc)
3801c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
38028b242ebaSAlexander Graf    target_phys_bits=64
3803d6630708SNathan Froyd    target_nptl="yes"
3804de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
38052408a527Saurel32  ;;
38062408a527Saurel32  ppcemb)
38076acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3808e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3809c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
38101ad2134fSPaul Brook    target_phys_bits=64
3811d6630708SNathan Froyd    target_nptl="yes"
3812de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
38132408a527Saurel32  ;;
38142408a527Saurel32  ppc64)
38156acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3816e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3817c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
38181ad2134fSPaul Brook    target_phys_bits=64
3819c2e3dee6SLaurent Vivier    target_long_alignment=8
3820de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
38212408a527Saurel32  ;;
38222408a527Saurel32  ppc64abi32)
3823b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
38246acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3825e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
382625be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3827c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
38281ad2134fSPaul Brook    target_phys_bits=64
3829de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
38302408a527Saurel32  ;;
38312408a527Saurel32  sh4|sh4eb)
3832b498c8a0SJuan Quintela    TARGET_ARCH=sh4
38334dbed897Spbrook    bflt="yes"
38340b6d3ae0Saurel32    target_nptl="yes"
38351ad2134fSPaul Brook    target_phys_bits=32
38362408a527Saurel32  ;;
38372408a527Saurel32  sparc)
38381ad2134fSPaul Brook    target_phys_bits=64
38392408a527Saurel32  ;;
38402408a527Saurel32  sparc64)
38416acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
38421ad2134fSPaul Brook    target_phys_bits=64
3843c2e3dee6SLaurent Vivier    target_long_alignment=8
38442408a527Saurel32  ;;
38452408a527Saurel32  sparc32plus)
3846b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
38476acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3848e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
384925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
38501ad2134fSPaul Brook    target_phys_bits=64
38512408a527Saurel32  ;;
385224e804ecSAlexander Graf  s390x)
3853bc434676SUlrich Hecht    target_nptl="yes"
385424e804ecSAlexander Graf    target_phys_bits=64
38557b3da903SAlexander Graf    target_long_alignment=8
385624e804ecSAlexander Graf  ;;
3857d2fbca94SGuan Xuetao  unicore32)
3858d2fbca94SGuan Xuetao    target_phys_bits=32
3859d2fbca94SGuan Xuetao  ;;
3860cfa550c6SMax Filippov  xtensa|xtensaeb)
3861cfa550c6SMax Filippov    TARGET_ARCH=xtensa
3862cfa550c6SMax Filippov    target_phys_bits=32
3863cfa550c6SMax Filippov  ;;
38642408a527Saurel32  *)
3865de83cd02Sbellard    echo "Unsupported target CPU"
3866de83cd02Sbellard    exit 1
38672408a527Saurel32  ;;
38682408a527Saurel32esac
38695e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
38705e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
38715e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
38725e8861a0SPaolo Bonzinifi
38735e8861a0SPaolo Bonzini
38745e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
38755e8861a0SPaolo Bonzini
387699afc91dSDaniel P. Berrangeupper() {
387799afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
387899afc91dSDaniel P. Berrange}
387999afc91dSDaniel P. Berrange
3880c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3881c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3882c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3883c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
388425be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
388599afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
388625be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
388725be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
388899afc91dSDaniel P. Berrangeecho "TARGET_TYPE=TARGET_TYPE_`upper $target_arch2`" >> $config_target_mak
388925be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3890e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3891e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3892e6e91b9cSJuan Quintelafi
389325be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
38941b0c87fcSJuan Quintelacase "$target_arch2" in
38951b0c87fcSJuan Quintela  i386|x86_64)
38961b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
389764b3cfdbSAnthony PERARD      target_phys_bits=64
389825be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
3899eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
3900eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
3901eb6fda0fSAnthony PERARD      fi
390259d21e53SAlexander Graf    else
390359d21e53SAlexander Graf      echo "CONFIG_NO_XEN=y" >> $config_target_mak
3904432d268cSJun Nakajima    fi
390559d21e53SAlexander Graf    ;;
390659d21e53SAlexander Graf  *)
390759d21e53SAlexander Graf    echo "CONFIG_NO_XEN=y" >> $config_target_mak
39081b0c87fcSJuan Quintelaesac
3909c59249f9SJuan Quintelacase "$target_arch2" in
39100e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3911c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3912c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3913c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3914c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
39155f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3916adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3917adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3918c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3919c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
392025be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
39211ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
3922d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3923d5970055SMichael S. Tsirkin      fi
3924c59249f9SJuan Quintela    fi
3925c59249f9SJuan Quintelaesac
3926fae001f5SWen Congyangcase "$target_arch2" in
3927fae001f5SWen Congyang  i386|x86_64)
3928fae001f5SWen Congyang    echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
3929fae001f5SWen Congyangesac
39307f762366SBlue Swirlif test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then
39310a6b8ddeSAlexander Graf  echo "CONFIG_PSERIES=y" >> $config_target_mak
39320a6b8ddeSAlexander Graffi
3933de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
393425be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
393597a847bcSbellardfi
393697a847bcSbellardif test "$target_softmmu" = "yes" ; then
3937b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
393825be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3939de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
39400e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
39415791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3942ad4cf3f6SPaul Brook  if test "$smartcard_nss" = "yes" ; then
3943ad4cf3f6SPaul Brook    echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3944ad4cf3f6SPaul Brook  fi
39459fecbed0SWen Congyang  case "$target_arch2" in
39469fecbed0SWen Congyang    i386|x86_64)
39479fecbed0SWen Congyang      echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
39489fecbed0SWen Congyang  esac
3949de83cd02Sbellardfi
3950997344f3Sbellardif test "$target_user_only" = "yes" ; then
395125be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3952a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
3953997344f3Sbellardfi
3954831b7825Sthsif test "$target_linux_user" = "yes" ; then
395525be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3956831b7825Sthsfi
395756aebc89Spbrooklist=""
395856aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
395956aebc89Spbrook  for x in $gdb_xml_files; do
396056aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
396156aebc89Spbrook  done
396225be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
39633d0f1517SJuan Quintelafi
3964de83cd02Sbellard
3965e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
396625be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3967e5fe0c52Spbrookfi
3968bd0c5661Spbrookif test "$target_user_only" = "yes" \
3969bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
397025be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3971bd0c5661Spbrookfi
3972379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
397325be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3974379f6698SPaul Brookfi
397584778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
397625be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
397784778508Sblueswir1fi
39785b0753e0Sbellard
39795a4d701aSJan Kiszka# the static way of configuring available audio cards requires this workaround
39805a4d701aSJan Kiszkaif test "$target_user_only" != "yes" && grep -q CONFIG_PCSPK $source_path/default-configs/$target.mak; then
39815a4d701aSJan Kiszka  echo "CONFIG_PCSPK=y" >> $config_target_mak
39825a4d701aSJan Kiszkafi
39835a4d701aSJan Kiszka
39844afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3985fa282484SJuan Quintela
39864afddb55SJuan Quintelacflags=""
3987f9728943SPaolo Bonziniincludes=""
3988fa282484SJuan Quintelaldflags=""
39899b8e111fSJuan Quintela
39909195b2c2SStefan Weilif test "$tcg_interpreter" = "yes"; then
39919195b2c2SStefan Weil  includes="-I\$(SRC_PATH)/tcg/tci $includes"
39929195b2c2SStefan Weilelif test "$ARCH" = "sparc64" ; then
3993f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
399424e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3995f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
39965d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3997f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
399857ddfbf7SJuan Quintelaelse
3999f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
400057ddfbf7SJuan Quintelafi
4001f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
400257ddfbf7SJuan Quintela
40036efd7517SPeter Maydellif test "$linux" = "yes" ; then
40046efd7517SPeter Maydell  includes="-I\$(SRC_PATH)/linux-headers $includes"
40056efd7517SPeter Maydellfi
40066efd7517SPeter Maydell
40074d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
40084d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
40094d904533SBlue Swirlelse
40104d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
40114d904533SBlue Swirlfi
40124d904533SBlue Swirl
401364656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
401464656024SJuan Quintela  case "$i" in
401564656024SJuan Quintela  alpha)
401625be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
40174d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
401864656024SJuan Quintela  ;;
401964656024SJuan Quintela  arm)
402025be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
40214d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
402264656024SJuan Quintela  ;;
402364656024SJuan Quintela  cris)
402425be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
40254d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
402664656024SJuan Quintela  ;;
402764656024SJuan Quintela  hppa)
402825be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
40294d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
403064656024SJuan Quintela  ;;
403164656024SJuan Quintela  i386|x86_64)
403225be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
40334d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
403464656024SJuan Quintela  ;;
4035903ec55cSAurelien Jarno  ia64*)
4036903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
4037903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
4038903ec55cSAurelien Jarno  ;;
403979368f49SMichael Walle  lm32)
404079368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
404179368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $libdis_config_mak
404279368f49SMichael Walle  ;;
404364656024SJuan Quintela  m68k)
404425be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
40454d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
404664656024SJuan Quintela  ;;
4047877fdc12SEdgar E. Iglesias  microblaze*)
404825be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
40494d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
405064656024SJuan Quintela  ;;
405164656024SJuan Quintela  mips*)
405225be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
40534d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
405464656024SJuan Quintela  ;;
4055e67db06eSJia Liu  or32)
4056e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
4057e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $libdis_config_mak
4058e67db06eSJia Liu  ;;
405964656024SJuan Quintela  ppc*)
406025be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
40614d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
406264656024SJuan Quintela  ;;
406324e804ecSAlexander Graf  s390*)
406425be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
40654d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
406664656024SJuan Quintela  ;;
406764656024SJuan Quintela  sh4)
406825be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
40694d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
407064656024SJuan Quintela  ;;
407164656024SJuan Quintela  sparc*)
407225be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
40734d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
407464656024SJuan Quintela  ;;
4075cfa550c6SMax Filippov  xtensa*)
4076cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
4077cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $libdis_config_mak
4078cfa550c6SMax Filippov  ;;
407964656024SJuan Quintela  esac
408064656024SJuan Quinteladone
40819195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
40829195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
40839195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $libdis_config_mak
40849195b2c2SStefan Weilfi
408564656024SJuan Quintela
40866ee7126fSJuan Quintelacase "$ARCH" in
40876ee7126fSJuan Quintelaalpha)
40886ee7126fSJuan Quintela  # Ensure there's only a single GP
40896ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
40906ee7126fSJuan Quintela;;
40916ee7126fSJuan Quintelaesac
40926ee7126fSJuan Quintela
409355d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
409455d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
409555d9c04bSJuan Quintela  arm)
409655d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
409755d9c04bSJuan Quintela  ;;
409825a8bb96SMichael Walle  lm32)
409925a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
410025a8bb96SMichael Walle  ;;
410155d9c04bSJuan Quintela  i386|mips|ppc)
410255d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
410355d9c04bSJuan Quintela  ;;
410455d9c04bSJuan Quintela  esac
410555d9c04bSJuan Quintelafi
410655d9c04bSJuan Quintela
4107d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
410825be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4109d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4110d02c1db3SJuan Quintela    cflags="-p $cflags"
4111d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4112d02c1db3SJuan Quintela  fi
4113d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4114d02c1db3SJuan Quintela    ldflags="-p $ldflags"
411525be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4116d02c1db3SJuan Quintela  fi
4117d02c1db3SJuan Quintelafi
4118d02c1db3SJuan Quintela
41199195b2c2SStefan Weilif test "$ARCH" = "tci"; then
41209195b2c2SStefan Weil  linker_script=""
41219195b2c2SStefan Weilelse
41226ee7126fSJuan Quintela  linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
41239195b2c2SStefan Weilfi
41249195b2c2SStefan Weil
41259b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4126fa282484SJuan Quintela  case "$ARCH" in
41274d58be06SRichard Henderson  alpha | s390x)
41284d58be06SRichard Henderson    # The default placement of the application is fine.
41294d58be06SRichard Henderson    ;;
4130fd76e73aSRichard Henderson  *)
4131322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
4132fa282484SJuan Quintela    ;;
4133fa282484SJuan Quintela  esac
4134fa282484SJuan Quintelafi
4135fa282484SJuan Quintela
413625be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
413725be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4138f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
4139fa282484SJuan Quintela
414097a847bcSbellarddone # for target in $targets
41417d13299dSbellard
4142d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
4143927b241dSMichael WalleDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32"
41442dee8d54SPaolo BonziniDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
41452d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
41462dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
414700c705fbSPaolo BonziniDIRS="$DIRS libcacard libcacard/libcacard libcacard/trace"
4148c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4149c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
415000c705fbSPaolo BonziniFILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile"
4151ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4152446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
41532d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4154753d11f2SRichard Hendersonfor bios_file in \
4155753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
4156753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4157753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4158753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4159753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4160753d11f2SRichard Hendersondo
41617ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
41627ea78b74SJan Kiszkadone
4163d1807a4fSPaolo Bonzinimkdir -p $DIRS
41647d13299dSbellardfor f in $FILES ; do
416572b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4166f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4167f9245e10SPeter Maydell    fi
41687d13299dSbellarddone
41691ad2134fSPaul Brook
4170c34ebfdcSAnthony Liguori# temporary config to build submodules
41712d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4172c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
417337116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4174c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
4175c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4176c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
4177c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
4178c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4179c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
4180c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4181c34ebfdcSAnthony Liguoridone
4182c34ebfdcSAnthony Liguori
41831ad2134fSPaul Brookfor hwlib in 32 64; do
41841ad2134fSPaul Brook  d=libhw$hwlib
418572b8b5a1SStefan Weil  symlink "$source_path/Makefile.hw" "$d/Makefile"
418637116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
41871ad2134fSPaul Brookdone
4188add16157SBlue Swirl
4189add16157SBlue Swirld=libuser
419072b8b5a1SStefan Weilsymlink "$source_path/Makefile.user" "$d/Makefile"
4191b40292e7SJan Kiszka
4192b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4193b40292e7SJan Kiszka  mkdir -p QMP
4194b40292e7SJan Kiszkafi
4195