xref: /openbmc/qemu/configure (revision c19a7981)
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
128afb63ebdSStefan Weil# Don't accept a target_list environment variable.
129afb63ebdSStefan Weilunset target_list
130377529c0SPaolo Bonzini
131377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
132377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
133377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
134377529c0SPaolo Bonzini#              unless --disable-foo is given
135377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
136377529c0SPaolo Bonzini#              feature will searched for,
137377529c0SPaolo Bonzini#              if not found, configure exits with error
138377529c0SPaolo Bonzini#
139377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
140377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
141377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
142377529c0SPaolo Bonzini
143377529c0SPaolo Bonzinibluez=""
144377529c0SPaolo Bonzinibrlapi=""
145377529c0SPaolo Bonzinicurl=""
146377529c0SPaolo Bonzinicurses=""
147377529c0SPaolo Bonzinidocs=""
148377529c0SPaolo Bonzinifdt=""
149377529c0SPaolo Bonzininptl=""
150377529c0SPaolo Bonzinisdl=""
151983eef5aSMeador Ingevirtfs=""
152821601eaSJes Sorensenvnc="yes"
153377529c0SPaolo Bonzinisparse="no"
154377529c0SPaolo Bonziniuuid=""
155377529c0SPaolo Bonzinivde=""
156377529c0SPaolo Bonzinivnc_tls=""
157377529c0SPaolo Bonzinivnc_sasl=""
158377529c0SPaolo Bonzinivnc_jpeg=""
159377529c0SPaolo Bonzinivnc_png=""
160377529c0SPaolo Bonzinixen=""
161d5b93ddfSAnthony PERARDxen_ctrl_version=""
162eb6fda0fSAnthony PERARDxen_pci_passthrough=""
163377529c0SPaolo Bonzinilinux_aio=""
16447e98658SCorey Bryantcap_ng=""
165377529c0SPaolo Bonziniattr=""
1664f26f2b6SAvi Kivitylibattr=""
167377529c0SPaolo Bonzinixfs=""
168377529c0SPaolo Bonzini
169d41a75a2SBradvhost_net="no"
170d41a75a2SBradkvm="no"
171377529c0SPaolo Bonzinigprof="no"
172377529c0SPaolo Bonzinidebug_tcg="no"
173377529c0SPaolo Bonzinidebug="no"
174377529c0SPaolo Bonzinistrip_opt="yes"
1759195b2c2SStefan Weiltcg_interpreter="no"
176377529c0SPaolo Bonzinibigendian="no"
177377529c0SPaolo Bonzinimingw32="no"
178377529c0SPaolo BonziniEXESUF=""
179377529c0SPaolo Bonziniprefix="/usr/local"
180377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
181528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
182850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
183377529c0SPaolo Bonzinibindir="\${prefix}/bin"
1843aa5d2beSAlon Levylibdir="\${prefix}/lib"
1858bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
1860f94d6daSAlon Levyincludedir="\${prefix}/include"
187377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
188785c23aeSLuiz Capitulinolocal_statedir="\${prefix}/var"
189377529c0SPaolo Bonziniconfsuffix="/qemu"
190377529c0SPaolo Bonzinislirp="yes"
191377529c0SPaolo Bonzinifmod_lib=""
192377529c0SPaolo Bonzinifmod_inc=""
193377529c0SPaolo Bonzinioss_lib=""
194377529c0SPaolo Bonzinibsd="no"
195377529c0SPaolo Bonzinilinux="no"
196377529c0SPaolo Bonzinisolaris="no"
197377529c0SPaolo Bonziniprofiler="no"
198377529c0SPaolo Bonzinicocoa="no"
199377529c0SPaolo Bonzinisoftmmu="yes"
200377529c0SPaolo Bonzinilinux_user="no"
201377529c0SPaolo Bonzinibsd_user="no"
20230163d89SPeter Maydellguest_base="yes"
203377529c0SPaolo Bonziniuname_release=""
204377529c0SPaolo Bonzinimixemu="no"
205377529c0SPaolo Bonziniaix="no"
206377529c0SPaolo Bonziniblobs="yes"
207377529c0SPaolo Bonzinipkgversion=""
20840d6444eSAvi Kivitypie=""
209377529c0SPaolo Bonzinizero_malloc=""
210377529c0SPaolo Bonzinitrace_backend="nop"
211377529c0SPaolo Bonzinitrace_file="trace"
212377529c0SPaolo Bonzinispice=""
213377529c0SPaolo Bonzinirbd=""
21436707144SAlon Levysmartcard=""
215111a38b0SRobert Relyeasmartcard_nss=""
21669354a83SHans de Goedeusb_redir=""
217430a3c18SMichael Walleopengl=""
2181ece9905SAlon Levyzlib="yes"
219d138cee9SMichael Rothguest_agent="yes"
2204b1c11fdSDaniel P. Berrangewant_tools="yes"
221c589b249SRonnie Sahlberglibiscsi=""
222519175a2SAlex Barcelocoroutine=""
223f794573eSEduardo Otuboseccomp=""
224eb100396SBharata B Raoglusterfs=""
225377529c0SPaolo Bonzini
226ac0df51dSaliguori# parse CC options first
227ac0df51dSaliguorifor opt do
228ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
229ac0df51dSaliguori  case "$opt" in
230ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
231ac0df51dSaliguori  ;;
2323d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
233ac0df51dSaliguori  ;;
234ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
235ca4deeb1SPaolo Bonzini  ;;
2362ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2372ff6b91eSJuan Quintela  ;;
238a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
239e2a2ed06SJuan Quintela  ;;
240e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
241e2a2ed06SJuan Quintela  ;;
2425bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2435bc62e01SGerd Hoffmann  ;;
2445bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2455bc62e01SGerd Hoffmann  ;;
246ac0df51dSaliguori  esac
247ac0df51dSaliguoridone
248ac0df51dSaliguori# OS specific
249ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
25093148aa5SStefan Weil# we can eliminate its usage altogether.
251ac0df51dSaliguori
252b3198cc2SStuart Yodercc="${CC-${cross_prefix}gcc}"
253b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
254b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
255b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
2563f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
257b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
258b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
25917884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
26017884d7bSSergei Trofimovichquery_pkg_config() {
26117884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
26217884d7bSSergei Trofimovich}
26317884d7bSSergei Trofimovichpkg_config=query_pkg_config
264b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
265ac0df51dSaliguori
266be17dc90SMichael S. Tsirkin# default flags for all hosts
267be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
268f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
269be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
270be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
271cbbab922SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu"
2725bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
2735bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
274be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
2755bc62e01SGerd Hoffmannfi
276be17dc90SMichael S. Tsirkin
277ca4deeb1SPaolo Bonzini# make source path absolute
278ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
279ca4deeb1SPaolo Bonzini
280ac0df51dSaliguoricheck_define() {
281ac0df51dSaliguoricat > $TMPC <<EOF
282ac0df51dSaliguori#if !defined($1)
283fd786e1aSPeter Maydell#error $1 not defined
284ac0df51dSaliguori#endif
285ac0df51dSaliguoriint main(void) { return 0; }
286ac0df51dSaliguoriEOF
28752166aa0SJuan Quintela  compile_object
288ac0df51dSaliguori}
289ac0df51dSaliguori
290bbea4050SPeter Maydellif check_define __linux__ ; then
291bbea4050SPeter Maydell  targetos="Linux"
292bbea4050SPeter Maydellelif check_define _WIN32 ; then
293bbea4050SPeter Maydell  targetos='MINGW32'
294bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
295bbea4050SPeter Maydell  targetos='OpenBSD'
296bbea4050SPeter Maydellelif check_define __sun__ ; then
297bbea4050SPeter Maydell  targetos='SunOS'
298bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
299bbea4050SPeter Maydell  targetos='Haiku'
300bbea4050SPeter Maydellelse
301bbea4050SPeter Maydell  targetos=`uname -s`
302bbea4050SPeter Maydellfi
303bbea4050SPeter Maydell
304bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
305bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
306bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
307bbea4050SPeter Maydell# the correct CPU with the --cpu option.
308bbea4050SPeter Maydellcase $targetos in
309bbea4050SPeter MaydellDarwin)
310bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
311bbea4050SPeter Maydell  # run 64-bit userspace code.
312bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
313bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
314bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
315bbea4050SPeter Maydell    cpu="x86_64"
316bbea4050SPeter Maydell  fi
317bbea4050SPeter Maydell  ;;
318bbea4050SPeter MaydellSunOS)
319bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
320bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
321bbea4050SPeter Maydell    cpu="x86_64"
322bbea4050SPeter Maydell  fi
323bbea4050SPeter Maydellesac
324bbea4050SPeter Maydell
3252ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3262ff6b91eSJuan Quintela  # command line argument
3272ff6b91eSJuan Quintela  :
3282ff6b91eSJuan Quintelaelif check_define __i386__ ; then
329ac0df51dSaliguori  cpu="i386"
330ac0df51dSaliguorielif check_define __x86_64__ ; then
331ac0df51dSaliguori  cpu="x86_64"
3323aa9bd6cSblueswir1elif check_define __sparc__ ; then
3333aa9bd6cSblueswir1  if check_define __arch64__ ; then
3343aa9bd6cSblueswir1    cpu="sparc64"
3353aa9bd6cSblueswir1  else
3363aa9bd6cSblueswir1    cpu="sparc"
3373aa9bd6cSblueswir1  fi
338fdf7ed96Smalcelif check_define _ARCH_PPC ; then
339fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
340fdf7ed96Smalc    cpu="ppc64"
341ac0df51dSaliguori  else
342fdf7ed96Smalc    cpu="ppc"
343fdf7ed96Smalc  fi
344afa05235SAurelien Jarnoelif check_define __mips__ ; then
345afa05235SAurelien Jarno  cpu="mips"
346477ba620SAurelien Jarnoelif check_define __ia64__ ; then
347477ba620SAurelien Jarno  cpu="ia64"
348d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
349d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
350d66ed0eaSAurelien Jarno    cpu="s390x"
351d66ed0eaSAurelien Jarno  else
352d66ed0eaSAurelien Jarno    cpu="s390"
353d66ed0eaSAurelien Jarno  fi
35421d89f84SPeter Maydellelif check_define __arm__ ; then
35521d89f84SPeter Maydell  cpu="arm"
356f28ffed5SBradelif check_define __hppa__ ; then
357f28ffed5SBrad  cpu="hppa"
358fdf7ed96Smalcelse
359fdf7ed96Smalc  cpu=`uname -m`
360ac0df51dSaliguorifi
361ac0df51dSaliguori
362359bc95dSPeter MaydellARCH=
363359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
364359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
3657d13299dSbellardcase "$cpu" in
366359bc95dSPeter Maydell  ia64|ppc|ppc64|s390|s390x|sparc64)
367ea8f20f8SJuan Quintela    cpu="$cpu"
368ea8f20f8SJuan Quintela  ;;
3697d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
37097a847bcSbellard    cpu="i386"
3717d13299dSbellard  ;;
372aaa5fa14Saurel32  x86_64|amd64)
373aaa5fa14Saurel32    cpu="x86_64"
374aaa5fa14Saurel32  ;;
37521d89f84SPeter Maydell  armv*b|armv*l|arm)
37621d89f84SPeter Maydell    cpu="arm"
3777d13299dSbellard  ;;
378f28ffed5SBrad  hppa|parisc|parisc64)
379f54b3f92Saurel32    cpu="hppa"
380f54b3f92Saurel32  ;;
381afa05235SAurelien Jarno  mips*)
382afa05235SAurelien Jarno    cpu="mips"
383afa05235SAurelien Jarno  ;;
3843142255cSblueswir1  sparc|sun4[cdmuv])
385ae228531Sbellard    cpu="sparc"
386ae228531Sbellard  ;;
3877d13299dSbellard  *)
388359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
389359bc95dSPeter Maydell    ARCH=unknown
3907d13299dSbellard  ;;
3917d13299dSbellardesac
392359bc95dSPeter Maydellif test -z "$ARCH"; then
393359bc95dSPeter Maydell  ARCH="$cpu"
394359bc95dSPeter Maydellfi
395e2d52ad3SJuan Quintela
3967d13299dSbellard# OS specific
3970dbfc675SJuan Quintela
3987d13299dSbellardcase $targetos in
399c326e0afSbellardCYGWIN*)
400c326e0afSbellard  mingw32="yes"
401a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
402d5631638Smalc  audio_possible_drivers="winwave sdl"
403d5631638Smalc  audio_drv_list="winwave"
404c326e0afSbellard;;
40567b915a5SbellardMINGW32*)
40667b915a5Sbellard  mingw32="yes"
407d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
408d5631638Smalc  audio_drv_list="winwave"
40967b915a5Sbellard;;
4105c40d2bdSthsGNU/kFreeBSD)
411a167ba50SAurelien Jarno  bsd="yes"
4120c58ac1cSmalc  audio_drv_list="oss"
413f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4145c40d2bdSths;;
4157d3505c5SbellardFreeBSD)
4167d3505c5Sbellard  bsd="yes"
4170db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4180c58ac1cSmalc  audio_drv_list="oss"
419f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
420f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
421f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
4227d3505c5Sbellard;;
423c5e97233Sblueswir1DragonFly)
424c5e97233Sblueswir1  bsd="yes"
4250db4a067SPaolo Bonzini  make="${MAKE-gmake}"
426c5e97233Sblueswir1  audio_drv_list="oss"
427c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
428c5e97233Sblueswir1;;
4297d3505c5SbellardNetBSD)
4307d3505c5Sbellard  bsd="yes"
4310db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4320c58ac1cSmalc  audio_drv_list="oss"
433c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4348ef92a88Sblueswir1  oss_lib="-lossaudio"
4357d3505c5Sbellard;;
4367d3505c5SbellardOpenBSD)
4377d3505c5Sbellard  bsd="yes"
4380db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4390c58ac1cSmalc  audio_drv_list="oss"
440c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4412f6a1ab0Sblueswir1  oss_lib="-lossaudio"
4427d3505c5Sbellard;;
44383fb7adfSbellardDarwin)
44483fb7adfSbellard  bsd="yes"
44583fb7adfSbellard  darwin="yes"
4461b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
447a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4480c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4491b0f9cc2Saliguori  else
450a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
4511b0f9cc2Saliguori  fi
452fd677642Sths  cocoa="yes"
4530c58ac1cSmalc  audio_drv_list="coreaudio"
454c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4550c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4567973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
457a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
458a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
459a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
46083fb7adfSbellard;;
461ec530c81SbellardSunOS)
462ec530c81Sbellard  solaris="yes"
4630db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4640db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
465fa58948dSBlue Swirl  ld="gld"
466e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
4670475a5caSths  needs_libsunmath="no"
468c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
469c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4700475a5caSths    if test "$solarisrev" -le 9 ; then
4710475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4720475a5caSths        needs_libsunmath="yes"
473f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
474f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
475f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4760475a5caSths      else
4770475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4780475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4790475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4800475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4810475a5caSths        exit 1
4820475a5caSths      fi
4830475a5caSths    fi
48486b2bd93Sths  fi
4856b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4860c58ac1cSmalc    audio_drv_list="oss"
4876b4d2ba1Sths  fi
488c2de5c91Smalc  audio_possible_drivers="oss sdl"
489d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
490d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
491d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
492d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
493a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
494560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
495560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
496560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
497ec530c81Sbellard;;
498b29fe3edSmalcAIX)
499b29fe3edSmalc  aix="yes"
5000db4a067SPaolo Bonzini  make="${MAKE-gmake}"
501b29fe3edSmalc;;
502179cf400SAndreas FärberHaiku)
503179cf400SAndreas Färber  haiku="yes"
504179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
505179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
506179cf400SAndreas Färber;;
507fb065187Sbellard*)
5080c58ac1cSmalc  audio_drv_list="oss"
509b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5105327cf48Sbellard  linux="yes"
511831b7825Sths  linux_user="yes"
51268063649Sblueswir1  usb="linux"
513af2be207SJan Kiszka  kvm="yes"
514af2be207SJan Kiszka  vhost_net="yes"
51507f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
516c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
517c9ec1fe4Sbellard  fi
518fb065187Sbellard;;
5197d13299dSbellardesac
5207d13299dSbellard
5217d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
522b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
52368063649Sblueswir1    usb="bsd"
52484778508Sblueswir1    bsd_user="yes"
5257d3505c5Sbellard  fi
52608de3949SAndreas Färberfi
5277d3505c5Sbellard
5280db4a067SPaolo Bonzini: ${make=${MAKE-make}}
5290db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
530c886edfbSBlue Swirl: ${python=${PYTHON-python}}
531e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
5320db4a067SPaolo Bonzini
5333c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
5343c4a4d0dSPeter Maydellif has clang; then
5353c4a4d0dSPeter Maydell  objcc=clang
5363c4a4d0dSPeter Maydellelse
5373c4a4d0dSPeter Maydell  objcc="$cc"
5383c4a4d0dSPeter Maydellfi
5393c4a4d0dSPeter Maydell
5403457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
5413457a3f8SJuan Quintela  EXESUF=".exe"
542a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
543e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
544e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
545f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
546f7cf5d5bSStefan Weilcat > $TMPC << EOF
547f7cf5d5bSStefan Weilint main(void) { return 0; }
548f7cf5d5bSStefan WeilEOF
549f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
550f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
551f7cf5d5bSStefan Weil  fi
552c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
553683035deSPaolo Bonzini  mandir="\${prefix}"
554528ae5b8SEduardo Habkost  datadir="\${prefix}"
555850da188SEduardo Habkost  qemu_docdir="\${prefix}"
556683035deSPaolo Bonzini  bindir="\${prefix}"
557683035deSPaolo Bonzini  sysconfdir="\${prefix}"
558785c23aeSLuiz Capitulino  local_statedir="\${prefix}"
559683035deSPaolo Bonzini  confsuffix=""
560368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
5613457a3f8SJuan Quintelafi
5623457a3f8SJuan Quintela
563487fefdbSAnthony Liguoriwerror=""
56485aa5189Sbellard
5657d13299dSbellardfor opt do
566a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
5677d13299dSbellard  case "$opt" in
5682efc3265Sbellard  --help|-h) show_help=yes
5692efc3265Sbellard  ;;
57099123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
57199123e13SMike Frysinger  ;;
572b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5737d13299dSbellard  ;;
574b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
57532ce6337Sbellard  ;;
576ca4deeb1SPaolo Bonzini  --source-path=*)
5777d13299dSbellard  ;;
578ac0df51dSaliguori  --cross-prefix=*)
5797d13299dSbellard  ;;
580ac0df51dSaliguori  --cc=*)
5817d13299dSbellard  ;;
582b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
58383469015Sbellard  ;;
5843c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
5853c4a4d0dSPeter Maydell  ;;
586b1a550a0Spbrook  --make=*) make="$optarg"
5877d13299dSbellard  ;;
5886a882643Spbrook  --install=*) install="$optarg"
5896a882643Spbrook  ;;
590c886edfbSBlue Swirl  --python=*) python="$optarg"
591c886edfbSBlue Swirl  ;;
592e2d8830eSBrad  --smbd=*) smbd="$optarg"
593e2d8830eSBrad  ;;
594e2a2ed06SJuan Quintela  --extra-cflags=*)
5957d13299dSbellard  ;;
596e2a2ed06SJuan Quintela  --extra-ldflags=*)
5977d13299dSbellard  ;;
5985bc62e01SGerd Hoffmann  --enable-debug-info)
5995bc62e01SGerd Hoffmann  ;;
6005bc62e01SGerd Hoffmann  --disable-debug-info)
6015bc62e01SGerd Hoffmann  ;;
6022ff6b91eSJuan Quintela  --cpu=*)
6037d13299dSbellard  ;;
604b1a550a0Spbrook  --target-list=*) target_list="$optarg"
605de83cd02Sbellard  ;;
60674242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
60794a420b1SStefan Hajnoczi  ;;
60874242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6099410b56cSPrerna Saxena  ;;
6107d13299dSbellard  --enable-gprof) gprof="yes"
6117d13299dSbellard  ;;
61279427693SLoïc Minier  --static)
61379427693SLoïc Minier    static="yes"
61479427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
61517884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
61643ce4dfeSbellard  ;;
6170b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6180b24e75fSPaolo Bonzini  ;;
6190b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
6200b24e75fSPaolo Bonzini  ;;
6213aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
6223aa5d2beSAlon Levy  ;;
6238bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
6248bf188aaSMichael Tokarev  ;;
6250f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
6260f94d6daSAlon Levy  ;;
627528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
6280b24e75fSPaolo Bonzini  ;;
629023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
630023d3d67SEduardo Habkost  ;;
631850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
6320b24e75fSPaolo Bonzini  ;;
633ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
63407381cc1SAnthony Liguori  ;;
635785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
636785c23aeSLuiz Capitulino  ;;
637785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
638023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
639023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
640023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
641023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
642023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
643023ddd74SMax Filippov    # lots of directory switches by default.
644023ddd74SMax Filippov  ;;
64597a847bcSbellard  --disable-sdl) sdl="no"
64697a847bcSbellard  ;;
647c4198157SJuan Quintela  --enable-sdl) sdl="yes"
648c4198157SJuan Quintela  ;;
649983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
650983eef5aSMeador Inge  ;;
651983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
652983eef5aSMeador Inge  ;;
653821601eaSJes Sorensen  --disable-vnc) vnc="no"
654821601eaSJes Sorensen  ;;
655821601eaSJes Sorensen  --enable-vnc) vnc="yes"
656821601eaSJes Sorensen  ;;
657b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
658102a52e4Sbellard  ;;
659c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
660c2de5c91Smalc  ;;
6612f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
6622f6a1ab0Sblueswir1  ;;
6632fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
6640c58ac1cSmalc  ;;
6650c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
6660c58ac1cSmalc  ;;
667eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
668eb852011SMarkus Armbruster  ;;
669f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
670f8393946Saurel32  ;;
671f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
672f8393946Saurel32  ;;
673f3d08ee6SPaul Brook  --enable-debug)
674f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
675f3d08ee6SPaul Brook      debug_tcg="yes"
676f3d08ee6SPaul Brook      debug="yes"
677f3d08ee6SPaul Brook      strip_opt="no"
678f3d08ee6SPaul Brook  ;;
67903b4fe7dSaliguori  --enable-sparse) sparse="yes"
68003b4fe7dSaliguori  ;;
68103b4fe7dSaliguori  --disable-sparse) sparse="no"
68203b4fe7dSaliguori  ;;
6831625af87Saliguori  --disable-strip) strip_opt="no"
6841625af87Saliguori  ;;
6858d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
6868d5d2d4cSths  ;;
6871be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
6881be10ad2SJuan Quintela  ;;
6892f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
6902f9606b3Saliguori  ;;
691ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
692ea784e3bSJuan Quintela  ;;
6932f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
6942f6f5c7aSCorentin Chary  ;;
6952f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
6962f6f5c7aSCorentin Chary  ;;
697efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
698efe556adSCorentin Chary  ;;
699efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
700efe556adSCorentin Chary  ;;
701443f1376Sbellard  --disable-slirp) slirp="no"
702c20709aaSbellard  ;;
703ee682d27SStefan Weil  --disable-uuid) uuid="no"
704ee682d27SStefan Weil  ;;
705ee682d27SStefan Weil  --enable-uuid) uuid="yes"
706ee682d27SStefan Weil  ;;
707e0e6c8c0Saliguori  --disable-vde) vde="no"
7088a16d273Sths  ;;
709dfb278bdSJuan Quintela  --enable-vde) vde="yes"
710dfb278bdSJuan Quintela  ;;
711e37630caSaliguori  --disable-xen) xen="no"
712e37630caSaliguori  ;;
713fc321b4bSJuan Quintela  --enable-xen) xen="yes"
714fc321b4bSJuan Quintela  ;;
715eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
716eb6fda0fSAnthony PERARD  ;;
717eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
718eb6fda0fSAnthony PERARD  ;;
7192e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
7202e4d9fb1Saurel32  ;;
7214ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
7224ffcedb6SJuan Quintela  ;;
723fb599c9aSbalrog  --disable-bluez) bluez="no"
724fb599c9aSbalrog  ;;
725a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
726a20a6f46SJuan Quintela  ;;
7277ba1e619Saliguori  --disable-kvm) kvm="no"
7287ba1e619Saliguori  ;;
729b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
730b31a0277SJuan Quintela  ;;
7319195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
7329195b2c2SStefan Weil  ;;
7339195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
7349195b2c2SStefan Weil  ;;
73547e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
73647e98658SCorey Bryant  ;;
73747e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
73847e98658SCorey Bryant  ;;
739cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
740cd4ec0b4SGerd Hoffmann  ;;
741cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
742cd4ec0b4SGerd Hoffmann  ;;
743c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
744c589b249SRonnie Sahlberg  ;;
745c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
746c589b249SRonnie Sahlberg  ;;
74705c2a3e7Sbellard  --enable-profiler) profiler="yes"
74805c2a3e7Sbellard  ;;
74914821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
75014821030SPavel Borzenkov  ;;
751c2de5c91Smalc  --enable-cocoa)
752c2de5c91Smalc      cocoa="yes" ;
753c2de5c91Smalc      sdl="no" ;
754c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
7555b0753e0Sbellard  ;;
756cad25d69Spbrook  --disable-system) softmmu="no"
7570a8e90f4Spbrook  ;;
758cad25d69Spbrook  --enable-system) softmmu="yes"
7590a8e90f4Spbrook  ;;
7600953a80fSZachary Amsden  --disable-user)
7610953a80fSZachary Amsden      linux_user="no" ;
7620953a80fSZachary Amsden      bsd_user="no" ;
7630953a80fSZachary Amsden  ;;
7640953a80fSZachary Amsden  --enable-user) ;;
765831b7825Sths  --disable-linux-user) linux_user="no"
7660a8e90f4Spbrook  ;;
767831b7825Sths  --enable-linux-user) linux_user="yes"
768831b7825Sths  ;;
76984778508Sblueswir1  --disable-bsd-user) bsd_user="no"
77084778508Sblueswir1  ;;
77184778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
77284778508Sblueswir1  ;;
773379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
774379f6698SPaul Brook  ;;
775379f6698SPaul Brook  --disable-guest-base) guest_base="no"
776379f6698SPaul Brook  ;;
77740d6444eSAvi Kivity  --enable-pie) pie="yes"
77834005a00SKirill A. Shutemov  ;;
77940d6444eSAvi Kivity  --disable-pie) pie="no"
78034005a00SKirill A. Shutemov  ;;
781c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
782c5937220Spbrook  ;;
78385aa5189Sbellard  --enable-werror) werror="yes"
78485aa5189Sbellard  ;;
78585aa5189Sbellard  --disable-werror) werror="no"
78685aa5189Sbellard  ;;
7874d3b6f6eSbalrog  --disable-curses) curses="no"
7884d3b6f6eSbalrog  ;;
789c584a6d0SJuan Quintela  --enable-curses) curses="yes"
790c584a6d0SJuan Quintela  ;;
791769ce76dSAlexander Graf  --disable-curl) curl="no"
792769ce76dSAlexander Graf  ;;
793788c8196SJuan Quintela  --enable-curl) curl="yes"
794788c8196SJuan Quintela  ;;
7952df87df7SJuan Quintela  --disable-fdt) fdt="no"
7962df87df7SJuan Quintela  ;;
7972df87df7SJuan Quintela  --enable-fdt) fdt="yes"
7982df87df7SJuan Quintela  ;;
799bd0c5661Spbrook  --disable-nptl) nptl="no"
800bd0c5661Spbrook  ;;
801b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
802b0a47e79SJuan Quintela  ;;
8038ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
8048ff9cbf7Smalc  ;;
8055c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
8065c6c3a6cSChristoph Hellwig  ;;
8075c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
8085c6c3a6cSChristoph Hellwig  ;;
809758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
810758e8e38SVenkateswararao Jujjuri (JV)  ;;
811758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
812758e8e38SVenkateswararao Jujjuri (JV)  ;;
81377755340Sths  --disable-blobs) blobs="no"
81477755340Sths  ;;
8154a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
8164a19f1ecSpbrook  ;;
817519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
818519175a2SAlex Barcelo  ;;
819a25dba17SJuan Quintela  --disable-docs) docs="no"
82070ec5dc0SAnthony Liguori  ;;
821a25dba17SJuan Quintela  --enable-docs) docs="yes"
82283a3ab8bSJuan Quintela  ;;
823d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
824d5970055SMichael S. Tsirkin  ;;
825d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
826d5970055SMichael S. Tsirkin  ;;
82720ff075bSMichael Walle  --disable-opengl) opengl="no"
82820ff075bSMichael Walle  ;;
82920ff075bSMichael Walle  --enable-opengl) opengl="yes"
83020ff075bSMichael Walle  ;;
831f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
832f27aaf4bSChristian Brunner  ;;
833f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
834f27aaf4bSChristian Brunner  ;;
8358c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
8368c84cf11SSergei Trofimovich  ;;
8378c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
8388c84cf11SSergei Trofimovich  ;;
83936707144SAlon Levy  --disable-smartcard) smartcard="no"
84036707144SAlon Levy  ;;
84136707144SAlon Levy  --enable-smartcard) smartcard="yes"
84236707144SAlon Levy  ;;
843111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
844111a38b0SRobert Relyea  ;;
845111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
846111a38b0SRobert Relyea  ;;
84769354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
84869354a83SHans de Goede  ;;
84969354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
85069354a83SHans de Goede  ;;
8511ece9905SAlon Levy  --disable-zlib-test) zlib="no"
8521ece9905SAlon Levy  ;;
853d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
854d138cee9SMichael Roth  ;;
855d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
856d138cee9SMichael Roth  ;;
8574b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
8584b1c11fdSDaniel P. Berrange  ;;
8594b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
8604b1c11fdSDaniel P. Berrange  ;;
861f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
862f794573eSEduardo Otubo  ;;
863f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
864f794573eSEduardo Otubo  ;;
865eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
866eb100396SBharata B Rao  ;;
867eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
868eb100396SBharata B Rao  ;;
8697f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
8707f1559c6Sbalrog  ;;
8717d13299dSbellard  esac
8727d13299dSbellarddone
8737d13299dSbellard
87440293e58Sbellardcase "$cpu" in
8759b9c37c3SRichard Henderson    sparc)
8760c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
8779b9c37c3SRichard Henderson           QEMU_CFLAGS="-m32 -mcpu=ultrasparc $QEMU_CFLAGS"
8783142255cSblueswir1           ;;
879ed968ff1SJuan Quintela    sparc64)
8800c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8819b9c37c3SRichard Henderson           QEMU_CFLAGS="-m64 -mcpu=ultrasparc $QEMU_CFLAGS"
8823142255cSblueswir1           ;;
88376d83bdeSths    s390)
88428d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
88528d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
88628d7cc49SRichard Henderson           ;;
88728d7cc49SRichard Henderson    s390x)
88828d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
88928d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
89076d83bdeSths           ;;
89140293e58Sbellard    i386)
892a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
8930c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
8942b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
89540293e58Sbellard           ;;
89640293e58Sbellard    x86_64)
897a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
8980c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8992b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
900379f6698SPaul Brook           ;;
90130163d89SPeter Maydell    # No special flags required for other host CPUs
9023142255cSblueswir1esac
9033142255cSblueswir1
90460e0df25SPeter Maydelldefault_target_list=""
90560e0df25SPeter Maydell
90660e0df25SPeter Maydell# these targets are portable
90760e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
90860e0df25SPeter Maydell    default_target_list="\
90960e0df25SPeter Maydelli386-softmmu \
91060e0df25SPeter Maydellx86_64-softmmu \
91127cdad67SRichard Hendersonalpha-softmmu \
91260e0df25SPeter Maydellarm-softmmu \
91360e0df25SPeter Maydellcris-softmmu \
91460e0df25SPeter Maydelllm32-softmmu \
91560e0df25SPeter Maydellm68k-softmmu \
91660e0df25SPeter Maydellmicroblaze-softmmu \
91760e0df25SPeter Maydellmicroblazeel-softmmu \
91860e0df25SPeter Maydellmips-softmmu \
91960e0df25SPeter Maydellmipsel-softmmu \
92060e0df25SPeter Maydellmips64-softmmu \
92160e0df25SPeter Maydellmips64el-softmmu \
922e67db06eSJia Liuor32-softmmu \
92360e0df25SPeter Maydellppc-softmmu \
92460e0df25SPeter Maydellppcemb-softmmu \
92560e0df25SPeter Maydellppc64-softmmu \
92660e0df25SPeter Maydellsh4-softmmu \
92760e0df25SPeter Maydellsh4eb-softmmu \
92860e0df25SPeter Maydellsparc-softmmu \
92960e0df25SPeter Maydellsparc64-softmmu \
9300f3301d4SAlexander Grafs390x-softmmu \
931cfa550c6SMax Filippovxtensa-softmmu \
932cfa550c6SMax Filippovxtensaeb-softmmu \
9334f23a1e6SGuan Xuetaounicore32-softmmu \
93460e0df25SPeter Maydell"
93560e0df25SPeter Maydellfi
93660e0df25SPeter Maydell# the following are Linux specific
93760e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
93860e0df25SPeter Maydell    default_target_list="${default_target_list}\
93960e0df25SPeter Maydelli386-linux-user \
94060e0df25SPeter Maydellx86_64-linux-user \
94160e0df25SPeter Maydellalpha-linux-user \
94260e0df25SPeter Maydellarm-linux-user \
94360e0df25SPeter Maydellarmeb-linux-user \
94460e0df25SPeter Maydellcris-linux-user \
94560e0df25SPeter Maydellm68k-linux-user \
94660e0df25SPeter Maydellmicroblaze-linux-user \
94760e0df25SPeter Maydellmicroblazeel-linux-user \
94860e0df25SPeter Maydellmips-linux-user \
94960e0df25SPeter Maydellmipsel-linux-user \
950d962783eSJia Liuor32-linux-user \
95160e0df25SPeter Maydellppc-linux-user \
95260e0df25SPeter Maydellppc64-linux-user \
95360e0df25SPeter Maydellppc64abi32-linux-user \
95460e0df25SPeter Maydellsh4-linux-user \
95560e0df25SPeter Maydellsh4eb-linux-user \
95660e0df25SPeter Maydellsparc-linux-user \
95760e0df25SPeter Maydellsparc64-linux-user \
95860e0df25SPeter Maydellsparc32plus-linux-user \
95960e0df25SPeter Maydellunicore32-linux-user \
9600f3301d4SAlexander Grafs390x-linux-user \
96160e0df25SPeter Maydell"
96260e0df25SPeter Maydellfi
96360e0df25SPeter Maydell# the following are BSD specific
96460e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
96560e0df25SPeter Maydell    default_target_list="${default_target_list}\
96660e0df25SPeter Maydelli386-bsd-user \
96760e0df25SPeter Maydellx86_64-bsd-user \
96860e0df25SPeter Maydellsparc-bsd-user \
96960e0df25SPeter Maydellsparc64-bsd-user \
97060e0df25SPeter Maydell"
97160e0df25SPeter Maydellfi
97260e0df25SPeter Maydell
973af5db58eSpbrookif test x"$show_help" = x"yes" ; then
974af5db58eSpbrookcat << EOF
975af5db58eSpbrook
976af5db58eSpbrookUsage: configure [options]
977af5db58eSpbrookOptions: [defaults in brackets after descriptions]
978af5db58eSpbrook
979af5db58eSpbrookEOF
980af5db58eSpbrookecho "Standard options:"
981af5db58eSpbrookecho "  --help                   print this message"
982af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
983af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
984af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
98560e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
98660e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
98760e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
988af5db58eSpbrookecho ""
989af5db58eSpbrookecho "Advanced options (experts only):"
990af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
991af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
992af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
9930bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
9940bfe8cc0SPaolo Bonziniecho "                           build time"
9953c4a4d0dSPeter Maydellecho "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
996a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
997e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
998af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
9996a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
1000c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
1001e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
1002af5db58eSpbrookecho "  --static                 enable static build [$static]"
10030b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
1004023d3d67SEduardo Habkostecho "  --datadir=PATH           install firmware in PATH$confsuffix"
1005023d3d67SEduardo Habkostecho "  --docdir=PATH            install documentation in PATH$confsuffix"
10060b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
1007023d3d67SEduardo Habkostecho "  --sysconfdir=PATH        install config in PATH$confsuffix"
1008785c23aeSLuiz Capitulinoecho "  --localstatedir=PATH     install local state in PATH"
10092ae4748fSStefan Weilecho "  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1010f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
1011f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
101209695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
1013890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
1014890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
10151625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
101685aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
1017fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
1018c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
1019983eef5aSMeador Ingeecho "  --disable-virtfs         disable VirtFS"
1020983eef5aSMeador Ingeecho "  --enable-virtfs          enable VirtFS"
1021821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
1022821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
102314821030SPavel Borzenkovecho "  --disable-cocoa          disable Cocoa (Mac OS X only)"
102414821030SPavel Borzenkovecho "  --enable-cocoa           enable Cocoa (default on Mac OS X)"
1025c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
1026c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
10274c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
10284c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
1029eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
1030eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
10318ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
1032e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
1033fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
1034eb6fda0fSAnthony PERARDecho "  --disable-xen-pci-passthrough"
1035eb6fda0fSAnthony PERARDecho "  --enable-xen-pci-passthrough"
10362e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
10374ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
10388d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
10391be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
10402f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1041ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
10422f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
10432f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
104496763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1045efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
1046af896aaaSpbrookecho "  --disable-curses         disable curses output"
1047c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1048769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1049788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
10502df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
10512df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
1052fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1053a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
10546093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
10557ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1056b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
10579195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1058bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
1059e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
1060af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1061af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
10620953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
10630953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1064831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1065831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
106684778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
106784778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1068379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1069379f6698SPaul Brookecho "                           emulation targets"
1070379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
107140d6444eSAvi Kivityecho "  --enable-pie             build Position Independent Executables"
107240d6444eSAvi Kivityecho "  --disable-pie            do not build Position Independent Executables"
1073af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1074af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
10752f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1076c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1077235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
10783142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
1079ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1080ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1081e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1082dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
10835c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
10845c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
108547e98658SCorey Bryantecho "  --disable-cap-ng         disable libcap-ng support"
108647e98658SCorey Bryantecho "  --enable-cap-ng          enable libcap-ng support"
1087758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1088758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
108977755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1090d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1091d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1092d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1093d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1094320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1095650ab98dSLluís Vilanovaecho "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
109674242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
10979410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1098cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1099cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1100f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1101c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1102c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
110336707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
110436707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1105111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1106111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
110769354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
110869354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1109d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1110d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1111f794573eSEduardo Otuboecho "  --disable-seccomp        disable seccomp support"
1112f794573eSEduardo Otuboecho "  --enable-seccomp         enables seccomp support"
1113519175a2SAlex Barceloecho "  --with-coroutine=BACKEND coroutine backend. Supported options:"
1114fe91bfa8SAlex Barceloecho "                           gthread, ucontext, sigaltstack, windows"
1115eb100396SBharata B Raoecho "  --enable-glusterfs       enable GlusterFS backend"
1116eb100396SBharata B Raoecho "  --disable-glusterfs      disable GlusterFS backend"
1117af5db58eSpbrookecho ""
11185bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1119af5db58eSpbrookexit 1
1120af5db58eSpbrookfi
1121af5db58eSpbrook
1122359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1123359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1124359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1125359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1126359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1127359bc95dSPeter Maydell        ARCH=tci
1128359bc95dSPeter Maydell    else
1129359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1130359bc95dSPeter Maydell        exit 1
1131359bc95dSPeter Maydell    fi
1132359bc95dSPeter Maydellfi
1133359bc95dSPeter Maydell
11348d05095cSPaolo Bonzini# check that the C compiler works.
11358d05095cSPaolo Bonzinicat > $TMPC <<EOF
113675cafad7SStefan Weilint main(void) { return 0; }
11378d05095cSPaolo BonziniEOF
11388d05095cSPaolo Bonzini
11398d05095cSPaolo Bonziniif compile_object ; then
11408d05095cSPaolo Bonzini  : C compiler works ok
11418d05095cSPaolo Bonzinielse
11428d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
11438d05095cSPaolo Bonzini    exit 1
11448d05095cSPaolo Bonzinifi
11458d05095cSPaolo Bonzini
1146417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1147417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1148417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1149417c9d72SAlexander Graf
1150417c9d72SAlexander Grafif test -z "$werror" ; then
1151417c9d72SAlexander Graf    if test "$z_version" = "50" -a \
1152417c9d72SAlexander Graf        "$linux" = "yes" ; then
1153417c9d72SAlexander Graf        werror="yes"
1154417c9d72SAlexander Graf    else
1155417c9d72SAlexander Graf        werror="no"
1156417c9d72SAlexander Graf    fi
1157417c9d72SAlexander Graffi
1158417c9d72SAlexander Graf
11598d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
11608d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
11618d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1162f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
1163c1556a81SPeter Maydellgcc_flags="-Wno-initializer-overrides $gcc_flags"
11646ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
11656ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
11666ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
11676ca026cbSPeter Maydell# so it's too error prone.
11688d05095cSPaolo Bonzinicat > $TMPC << EOF
11698d05095cSPaolo Bonziniint main(void) { return 0; }
11708d05095cSPaolo BonziniEOF
11718d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1172a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1173a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1174a1d29d6cSPeter Maydell    # warning options).
1175a1d29d6cSPeter Maydell    optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1176a1d29d6cSPeter Maydell    if compile_prog "-Werror $optflag" "" ; then
11778d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
11788d05095cSPaolo Bonzini    fi
11798d05095cSPaolo Bonzinidone
11808d05095cSPaolo Bonzini
118140d6444eSAvi Kivityif test "$static" = "yes" ; then
118240d6444eSAvi Kivity  if test "$pie" = "yes" ; then
118340d6444eSAvi Kivity    echo "static and pie are mutually incompatible"
118440d6444eSAvi Kivity    exit 1
118540d6444eSAvi Kivity  else
118640d6444eSAvi Kivity    pie="no"
118740d6444eSAvi Kivity  fi
118840d6444eSAvi Kivityfi
118940d6444eSAvi Kivity
119040d6444eSAvi Kivityif test "$pie" = ""; then
119140d6444eSAvi Kivity  case "$cpu-$targetos" in
1192f9db31a2SBrad    i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD)
119340d6444eSAvi Kivity      ;;
119440d6444eSAvi Kivity    *)
119540d6444eSAvi Kivity      pie="no"
119640d6444eSAvi Kivity      ;;
119740d6444eSAvi Kivity  esac
119840d6444eSAvi Kivityfi
119940d6444eSAvi Kivity
120040d6444eSAvi Kivityif test "$pie" != "no" ; then
120140d6444eSAvi Kivity  cat > $TMPC << EOF
120221d4a791SAvi Kivity
120321d4a791SAvi Kivity#ifdef __linux__
120421d4a791SAvi Kivity#  define THREAD __thread
120521d4a791SAvi Kivity#else
120621d4a791SAvi Kivity#  define THREAD
120721d4a791SAvi Kivity#endif
120821d4a791SAvi Kivity
120921d4a791SAvi Kivitystatic THREAD int tls_var;
121021d4a791SAvi Kivity
121121d4a791SAvi Kivityint main(void) { return tls_var; }
121221d4a791SAvi Kivity
121340d6444eSAvi KivityEOF
121440d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
121540d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
121640d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
121740d6444eSAvi Kivity    pie="yes"
121840d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
121940d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
122040d6444eSAvi Kivity    fi
122140d6444eSAvi Kivity  else
122240d6444eSAvi Kivity    if test "$pie" = "yes"; then
122340d6444eSAvi Kivity      echo "PIE not available due to missing toolchain support"
122440d6444eSAvi Kivity      exit 1
122540d6444eSAvi Kivity    else
122640d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
122740d6444eSAvi Kivity      pie="no"
122840d6444eSAvi Kivity    fi
122940d6444eSAvi Kivity  fi
123040d6444eSAvi Kivityfi
123140d6444eSAvi Kivity
1232ec530c81Sbellard#
1233ec530c81Sbellard# Solaris specific configure tool chain decisions
1234ec530c81Sbellard#
1235ec530c81Sbellardif test "$solaris" = "yes" ; then
12366792aa11SLoïc Minier  if has $install; then
12376792aa11SLoïc Minier    :
12386792aa11SLoïc Minier  else
1239ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1240ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1241ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1242ec530c81Sbellard    exit 1
1243ec530c81Sbellard  fi
12446792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1245ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1246ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1247ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1248ec530c81Sbellard    exit 1
1249ec530c81Sbellard  fi
12506792aa11SLoïc Minier  if has ar; then
12516792aa11SLoïc Minier    :
12526792aa11SLoïc Minier  else
1253ec530c81Sbellard    echo "Error: No path includes ar"
1254ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1255ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1256ec530c81Sbellard    fi
1257ec530c81Sbellard    exit 1
1258ec530c81Sbellard  fi
1259ec530c81Sbellardfi
1260ec530c81Sbellard
12617a3fc891SSebastian Herbsztif ! has $python; then
1262c886edfbSBlue Swirl  echo "Python not found. Use --python=/path/to/python"
1263c886edfbSBlue Swirl  exit 1
1264c886edfbSBlue Swirlfi
1265c886edfbSBlue Swirl
12666ccea1e4SPeter Maydell# Note that if the Python conditional here evaluates True we will exit
12676ccea1e4SPeter Maydell# with status 1 which is a shell 'false' value.
1268e120d449SStefan Hajnocziif ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1269e120d449SStefan Hajnoczi  echo "Cannot use '$python', Python 2.4 or later is required."
1270e120d449SStefan Hajnoczi  echo "Note that Python 3 or later is not yet supported."
1271e120d449SStefan Hajnoczi  echo "Use --python=/path/to/python to specify a supported Python."
12726ccea1e4SPeter Maydell  exit 1
12736ccea1e4SPeter Maydellfi
12746ccea1e4SPeter Maydell
1275afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1276121afa9eSAnthony Liguori    target_list="$default_target_list"
1277121afa9eSAnthony Liguorielse
1278121afa9eSAnthony Liguori    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
12795327cf48Sbellardfi
1280f55fe278SPaolo Bonzini# see if system emulation was really requested
1281f55fe278SPaolo Bonzinicase " $target_list " in
1282f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1283f55fe278SPaolo Bonzini  ;;
1284f55fe278SPaolo Bonzini  *) softmmu=no
1285f55fe278SPaolo Bonzini  ;;
1286f55fe278SPaolo Bonziniesac
12875327cf48Sbellard
1288249247c9SJuan Quintelafeature_not_found() {
1289249247c9SJuan Quintela  feature=$1
1290249247c9SJuan Quintela
1291249247c9SJuan Quintela  echo "ERROR"
1292249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
12939332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1294249247c9SJuan Quintela  echo "ERROR"
1295249247c9SJuan Quintela  exit 1;
1296249247c9SJuan Quintela}
1297249247c9SJuan Quintela
12987d13299dSbellardif test -z "$cross_prefix" ; then
12997d13299dSbellard
13007d13299dSbellard# ---
13017d13299dSbellard# big/little endian test
13027d13299dSbellardcat > $TMPC << EOF
13037d13299dSbellard#include <inttypes.h>
1304abab1a0fSStefan Weilint main(void) {
13057d13299dSbellard        volatile uint32_t i=0x01234567;
13067d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
13077d13299dSbellard}
13087d13299dSbellardEOF
13097d13299dSbellard
131052166aa0SJuan Quintelaif compile_prog "" "" ; then
13117d13299dSbellard$TMPE && bigendian="yes"
13127d13299dSbellardelse
13137d13299dSbellardecho big/little test failed
13147d13299dSbellardfi
13157d13299dSbellard
13167d13299dSbellardelse
13177d13299dSbellard
13187d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1319ea8f20f8SJuan Quintelacase "$cpu" in
132021d89f84SPeter Maydell  arm)
132121d89f84SPeter Maydell    # ARM can be either way; ask the compiler which one we are
132221d89f84SPeter Maydell    if check_define __ARMEB__; then
132321d89f84SPeter Maydell      bigendian=yes
132421d89f84SPeter Maydell    fi
132521d89f84SPeter Maydell  ;;
132621d89f84SPeter Maydell  hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1327ea8f20f8SJuan Quintela    bigendian=yes
1328ea8f20f8SJuan Quintela  ;;
1329ea8f20f8SJuan Quintelaesac
13307d13299dSbellard
13317d13299dSbellardfi
13327d13299dSbellard
1333b0a47e79SJuan Quintela##########################################
1334b0a47e79SJuan Quintela# NPTL probe
1335b0a47e79SJuan Quintela
1336b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1337bd0c5661Spbrook  cat > $TMPC <<EOF
1338bd0c5661Spbrook#include <sched.h>
133930813ceaSpbrook#include <linux/futex.h>
1340182eacc0SStefan Weilint main(void) {
1341bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1342bd0c5661Spbrook#error bork
1343bd0c5661Spbrook#endif
1344182eacc0SStefan Weil  return 0;
1345bd0c5661Spbrook}
1346bd0c5661SpbrookEOF
1347bd0c5661Spbrook
134852166aa0SJuan Quintela  if compile_object ; then
1349b0a47e79SJuan Quintela    nptl=yes
1350bd0c5661Spbrook  else
1351b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1352b0a47e79SJuan Quintela      feature_not_found "nptl"
1353b0a47e79SJuan Quintela    fi
1354b0a47e79SJuan Quintela    nptl=no
1355b0a47e79SJuan Quintela  fi
1356bd0c5661Spbrookfi
1357bd0c5661Spbrook
135811d9f695Sbellard##########################################
1359ac62922eSbalrog# zlib check
1360ac62922eSbalrog
13611ece9905SAlon Levyif test "$zlib" != "no" ; then
1362ac62922eSbalrog    cat > $TMPC << EOF
1363ac62922eSbalrog#include <zlib.h>
1364ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1365ac62922eSbalrogEOF
136652166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1367ac62922eSbalrog        :
1368ac62922eSbalrog    else
1369ac62922eSbalrog        echo
1370ac62922eSbalrog        echo "Error: zlib check failed"
1371ac62922eSbalrog        echo "Make sure to have the zlib libs and headers installed."
1372ac62922eSbalrog        echo
1373ac62922eSbalrog        exit 1
1374ac62922eSbalrog    fi
13751ece9905SAlon Levyfi
1376ac62922eSbalrog
1377ac62922eSbalrog##########################################
1378f794573eSEduardo Otubo# libseccomp check
1379f794573eSEduardo Otubo
1380f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
1381f794573eSEduardo Otubo    if $pkg_config libseccomp --modversion >/dev/null 2>&1; then
1382f794573eSEduardo Otubo        LIBS=`$pkg_config --libs libseccomp`
1383f794573eSEduardo Otubo	seccomp="yes"
1384f794573eSEduardo Otubo    else
1385f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
1386f794573eSEduardo Otubo            feature_not_found "libseccomp"
1387f794573eSEduardo Otubo	fi
1388e84d5956SYann E. MORIN	seccomp="no"
1389f794573eSEduardo Otubo    fi
1390f794573eSEduardo Otubofi
1391f794573eSEduardo Otubo##########################################
1392e37630caSaliguori# xen probe
1393e37630caSaliguori
1394fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1395b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1396d5b93ddfSAnthony PERARD
139750ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
139850ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
139950ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
140050ced5b3SStefan Weil
140150ced5b3SStefan Weil  # Xen (any)
140250ced5b3SStefan Weil  cat > $TMPC <<EOF
140350ced5b3SStefan Weil#include <xenctrl.h>
140450ced5b3SStefan Weilint main(void) {
140550ced5b3SStefan Weil  return 0;
140650ced5b3SStefan Weil}
140750ced5b3SStefan WeilEOF
140850ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
140950ced5b3SStefan Weil    # Xen not found
141050ced5b3SStefan Weil    if test "$xen" = "yes" ; then
141150ced5b3SStefan Weil      feature_not_found "xen"
141250ced5b3SStefan Weil    fi
141350ced5b3SStefan Weil    xen=no
141450ced5b3SStefan Weil
1415d5b93ddfSAnthony PERARD  # Xen unstable
141669deef08SPeter Maydell  elif
141769deef08SPeter Maydell      cat > $TMPC <<EOF &&
1418e37630caSaliguori#include <xenctrl.h>
1419e108a3c1SAnthony PERARD#include <xenstore.h>
1420d5b93ddfSAnthony PERARD#include <stdint.h>
1421d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1422d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1423d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1424d5b93ddfSAnthony PERARD#endif
1425d5b93ddfSAnthony PERARDint main(void) {
1426d5b93ddfSAnthony PERARD  xc_interface *xc;
1427d5b93ddfSAnthony PERARD  xs_daemon_open();
1428d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1429d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1430d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1431b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
14328688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
14338688e065SStefano Stabellini  return 0;
14348688e065SStefano Stabellini}
14358688e065SStefano StabelliniEOF
14368688e065SStefano Stabellini      compile_prog "" "$xen_libs"
143769deef08SPeter Maydell    then
14388688e065SStefano Stabellini    xen_ctrl_version=420
14398688e065SStefano Stabellini    xen=yes
14408688e065SStefano Stabellini
144169deef08SPeter Maydell  elif
144269deef08SPeter Maydell      cat > $TMPC <<EOF &&
14438688e065SStefano Stabellini#include <xenctrl.h>
14448688e065SStefano Stabellini#include <xs.h>
14458688e065SStefano Stabellini#include <stdint.h>
14468688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
14478688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
14488688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
14498688e065SStefano Stabellini#endif
14508688e065SStefano Stabelliniint main(void) {
14518688e065SStefano Stabellini  xs_daemon_open();
14529b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
14538688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
14548688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
14558688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1456d5b93ddfSAnthony PERARD  return 0;
1457d5b93ddfSAnthony PERARD}
1458e37630caSaliguoriEOF
145950ced5b3SStefan Weil      compile_prog "" "$xen_libs"
146069deef08SPeter Maydell    then
1461d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1462fc321b4bSJuan Quintela    xen=yes
1463d5b93ddfSAnthony PERARD
1464d5b93ddfSAnthony PERARD  # Xen 4.0.0
146569deef08SPeter Maydell  elif
146669deef08SPeter Maydell      cat > $TMPC <<EOF &&
1467d5b93ddfSAnthony PERARD#include <xenctrl.h>
1468d5b93ddfSAnthony PERARD#include <xs.h>
1469d5b93ddfSAnthony PERARD#include <stdint.h>
1470d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1471d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1472d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1473d5b93ddfSAnthony PERARD#endif
1474d5b93ddfSAnthony PERARDint main(void) {
1475b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1476b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1477b87de24eSAnthony PERARD  };
1478d5b93ddfSAnthony PERARD  xs_daemon_open();
1479d5b93ddfSAnthony PERARD  xc_interface_open();
1480d5b93ddfSAnthony PERARD  xc_gnttab_open();
1481d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1482b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1483d5b93ddfSAnthony PERARD  return 0;
1484d5b93ddfSAnthony PERARD}
1485d5b93ddfSAnthony PERARDEOF
1486d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
148769deef08SPeter Maydell    then
1488d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1489d5b93ddfSAnthony PERARD    xen=yes
1490d5b93ddfSAnthony PERARD
1491b87de24eSAnthony PERARD  # Xen 3.4.0
149269deef08SPeter Maydell  elif
149369deef08SPeter Maydell      cat > $TMPC <<EOF &&
1494b87de24eSAnthony PERARD#include <xenctrl.h>
1495b87de24eSAnthony PERARD#include <xs.h>
1496b87de24eSAnthony PERARDint main(void) {
1497b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1498b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1499b87de24eSAnthony PERARD  };
1500b87de24eSAnthony PERARD  xs_daemon_open();
1501b87de24eSAnthony PERARD  xc_interface_open();
1502b87de24eSAnthony PERARD  xc_gnttab_open();
1503b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1504b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1505b87de24eSAnthony PERARD  return 0;
1506b87de24eSAnthony PERARD}
1507b87de24eSAnthony PERARDEOF
1508b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
150969deef08SPeter Maydell    then
1510b87de24eSAnthony PERARD    xen_ctrl_version=340
1511b87de24eSAnthony PERARD    xen=yes
1512b87de24eSAnthony PERARD
1513b87de24eSAnthony PERARD  # Xen 3.3.0
151469deef08SPeter Maydell  elif
151569deef08SPeter Maydell      cat > $TMPC <<EOF &&
1516d5b93ddfSAnthony PERARD#include <xenctrl.h>
1517d5b93ddfSAnthony PERARD#include <xs.h>
1518d5b93ddfSAnthony PERARDint main(void) {
1519d5b93ddfSAnthony PERARD  xs_daemon_open();
1520d5b93ddfSAnthony PERARD  xc_interface_open();
1521d5b93ddfSAnthony PERARD  xc_gnttab_open();
1522d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1523d5b93ddfSAnthony PERARD  return 0;
1524d5b93ddfSAnthony PERARD}
1525d5b93ddfSAnthony PERARDEOF
1526d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
152769deef08SPeter Maydell    then
1528d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1529d5b93ddfSAnthony PERARD    xen=yes
1530d5b93ddfSAnthony PERARD
153150ced5b3SStefan Weil  # Xen version unsupported
1532e37630caSaliguori  else
1533fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
153450ced5b3SStefan Weil      feature_not_found "xen (unsupported version)"
1535fc321b4bSJuan Quintela    fi
1536fc321b4bSJuan Quintela    xen=no
1537e37630caSaliguori  fi
1538d5b93ddfSAnthony PERARD
1539d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1540d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1541d5b93ddfSAnthony PERARD  fi
1542e37630caSaliguorifi
1543e37630caSaliguori
1544eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1545eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1546eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1547eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1548eb6fda0fSAnthony PERARD  else
1549eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1550eb6fda0fSAnthony PERARD      echo "ERROR"
1551eb6fda0fSAnthony PERARD      echo "ERROR: User requested feature Xen PCI Passthrough"
1552eb6fda0fSAnthony PERARD      echo "ERROR: but this feature require /sys from Linux"
1553eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
1554eb6fda0fSAnthony PERARD        echo "ERROR: This feature does not work with Xen 3.3"
1555eb6fda0fSAnthony PERARD      fi
1556eb6fda0fSAnthony PERARD      echo "ERROR"
1557eb6fda0fSAnthony PERARD      exit 1;
1558eb6fda0fSAnthony PERARD    fi
1559eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1560eb6fda0fSAnthony PERARD  fi
1561eb6fda0fSAnthony PERARDfi
1562eb6fda0fSAnthony PERARD
1563e37630caSaliguori##########################################
1564a8bd70adSPaolo Bonzini# pkg-config probe
1565f91672e5SPaolo Bonzini
156617884d7bSSergei Trofimovichif ! has "$pkg_config_exe"; then
156717884d7bSSergei Trofimovich  echo "Error: pkg-config binary '$pkg_config_exe' not found"
1568a213fcb2SPeter Maydell  exit 1
1569f91672e5SPaolo Bonzinifi
1570f91672e5SPaolo Bonzini
1571f91672e5SPaolo Bonzini##########################################
157244dc0ca3SAlon Levy# libtool probe
157344dc0ca3SAlon Levy
15743f534581SBradif ! has $libtool; then
157544dc0ca3SAlon Levy    libtool=
157644dc0ca3SAlon Levyfi
157744dc0ca3SAlon Levy
157844dc0ca3SAlon Levy##########################################
1579dfffc653SJuan Quintela# Sparse probe
1580dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
15810dba6195SLoïc Minier  if has cgcc; then
1582dfffc653SJuan Quintela    sparse=yes
1583dfffc653SJuan Quintela  else
1584dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1585dfffc653SJuan Quintela      feature_not_found "sparse"
1586dfffc653SJuan Quintela    fi
1587dfffc653SJuan Quintela    sparse=no
1588dfffc653SJuan Quintela  fi
1589dfffc653SJuan Quintelafi
1590dfffc653SJuan Quintela
1591dfffc653SJuan Quintela##########################################
159211d9f695Sbellard# SDL probe
159311d9f695Sbellard
15943ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
15953ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
15963ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
15973ec87ffeSPaolo Bonzini  sdl_config=sdl-config
15983ec87ffeSPaolo Bonzinifi
15993ec87ffeSPaolo Bonzini
16003ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1601a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1602fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
16033ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
16043ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
16059316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1606a0dfd8a4SLoïc Minierelse
1607a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1608a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1609a0dfd8a4SLoïc Minier  fi
1610a0dfd8a4SLoïc Minier  sdl=no
16119316f803SPaolo Bonzinifi
161229e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
16133ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
16143ec87ffeSPaolo Bonzinifi
161511d9f695Sbellard
16169316f803SPaolo Bonzinisdl_too_old=no
1617c4198157SJuan Quintelaif test "$sdl" != "no" ; then
161811d9f695Sbellard  cat > $TMPC << EOF
161911d9f695Sbellard#include <SDL.h>
162011d9f695Sbellard#undef main /* We don't want SDL to override our main() */
162111d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
162211d9f695SbellardEOF
16239316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
162474f42e18STeLeMan  if test "$static" = "yes" ; then
162574f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
162674f42e18STeLeMan  else
16279316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
162874f42e18STeLeMan  fi
162952166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
163011d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
163111d9f695Sbellard      sdl_too_old=yes
163211d9f695Sbellard    else
1633fd677642Sths      if test "$cocoa" = "no" ; then
163411d9f695Sbellard        sdl=yes
163511d9f695Sbellard      fi
1636fd677642Sths    fi
16377c1f25b4Sbellard
163867c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
16391ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
164067c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1641f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1642f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
164311d9f695Sbellard      fi
164452166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
16451ac88f28SJuan Quintela	:
16461ac88f28SJuan Quintela      else
16471ac88f28SJuan Quintela        sdl=no
16487c1f25b4Sbellard      fi
16497c1f25b4Sbellard    fi # static link
1650c4198157SJuan Quintela  else # sdl not found
1651c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1652c4198157SJuan Quintela      feature_not_found "sdl"
1653c4198157SJuan Quintela    fi
1654c4198157SJuan Quintela    sdl=no
16557c1f25b4Sbellard  fi # sdl compile test
1656fd677642Sthsfi
165711d9f695Sbellard
16585368a422Saliguoriif test "$sdl" = "yes" ; then
16595368a422Saliguori  cat > $TMPC <<EOF
16605368a422Saliguori#include <SDL.h>
16615368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
16625368a422Saliguori#include <X11/XKBlib.h>
16635368a422Saliguori#else
16645368a422Saliguori#error No x11 support
16655368a422Saliguori#endif
16665368a422Saliguoriint main(void) { return 0; }
16675368a422SaliguoriEOF
166852166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1669681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
16705368a422Saliguori  fi
16710705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
16725368a422Saliguorifi
16735368a422Saliguori
16748f28f3fbSths##########################################
16758d5d2d4cSths# VNC TLS detection
1676821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1677ae6b5e5aSaliguori  cat > $TMPC <<EOF
1678ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1679ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1680ae6b5e5aSaliguoriEOF
1681a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1682a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
168352166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
16841be10ad2SJuan Quintela    vnc_tls=yes
1685a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1686ae6b5e5aSaliguori  else
16871be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
16881be10ad2SJuan Quintela      feature_not_found "vnc-tls"
16891be10ad2SJuan Quintela    fi
16901be10ad2SJuan Quintela    vnc_tls=no
16918d5d2d4cSths  fi
16928d5d2d4cSthsfi
16938d5d2d4cSths
16948d5d2d4cSths##########################################
16952f9606b3Saliguori# VNC SASL detection
1696821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
16972f9606b3Saliguori  cat > $TMPC <<EOF
16982f9606b3Saliguori#include <sasl/sasl.h>
16992f9606b3Saliguori#include <stdio.h>
17002f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
17012f9606b3SaliguoriEOF
17022f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
17032f9606b3Saliguori  vnc_sasl_cflags=""
17042f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
170552166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1706ea784e3bSJuan Quintela    vnc_sasl=yes
1707fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
17082f9606b3Saliguori  else
1709ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1710ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1711ea784e3bSJuan Quintela    fi
1712ea784e3bSJuan Quintela    vnc_sasl=no
17132f9606b3Saliguori  fi
17142f9606b3Saliguorifi
17152f9606b3Saliguori
17162f9606b3Saliguori##########################################
17172f6f5c7aSCorentin Chary# VNC JPEG detection
1718821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
17192f6f5c7aSCorentin Charycat > $TMPC <<EOF
17202f6f5c7aSCorentin Chary#include <stdio.h>
17212f6f5c7aSCorentin Chary#include <jpeglib.h>
17222f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
17232f6f5c7aSCorentin CharyEOF
17242f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
17252f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
17262f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
17272f6f5c7aSCorentin Chary    vnc_jpeg=yes
17282f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
17292f6f5c7aSCorentin Chary  else
17302f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
17312f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
17322f6f5c7aSCorentin Chary    fi
17332f6f5c7aSCorentin Chary    vnc_jpeg=no
17342f6f5c7aSCorentin Chary  fi
17352f6f5c7aSCorentin Charyfi
17362f6f5c7aSCorentin Chary
17372f6f5c7aSCorentin Chary##########################################
1738efe556adSCorentin Chary# VNC PNG detection
1739821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1740efe556adSCorentin Charycat > $TMPC <<EOF
1741efe556adSCorentin Chary//#include <stdio.h>
1742efe556adSCorentin Chary#include <png.h>
1743832ce9c2SScott Wood#include <stddef.h>
1744efe556adSCorentin Charyint main(void) {
1745efe556adSCorentin Chary    png_structp png_ptr;
1746efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
17477edc3fedSPeter Maydell    return png_ptr != 0;
1748efe556adSCorentin Chary}
1749efe556adSCorentin CharyEOF
17509af8025eSBrad  if $pkg_config libpng --modversion >/dev/null 2>&1; then
17519af8025eSBrad    vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
17529af8025eSBrad    vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
17539af8025eSBrad  else
1754efe556adSCorentin Chary    vnc_png_cflags=""
1755efe556adSCorentin Chary    vnc_png_libs="-lpng"
17569af8025eSBrad  fi
1757efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1758efe556adSCorentin Chary    vnc_png=yes
1759efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
17609af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1761efe556adSCorentin Chary  else
1762efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1763efe556adSCorentin Chary      feature_not_found "vnc-png"
1764efe556adSCorentin Chary    fi
1765efe556adSCorentin Chary    vnc_png=no
1766efe556adSCorentin Chary  fi
1767efe556adSCorentin Charyfi
1768efe556adSCorentin Chary
1769efe556adSCorentin Chary##########################################
177076655d6dSaliguori# fnmatch() probe, used for ACL routines
177176655d6dSaliguorifnmatch="no"
177276655d6dSaliguoricat > $TMPC << EOF
177376655d6dSaliguori#include <fnmatch.h>
177476655d6dSaliguoriint main(void)
177576655d6dSaliguori{
177676655d6dSaliguori    fnmatch("foo", "foo", 0);
177776655d6dSaliguori    return 0;
177876655d6dSaliguori}
177976655d6dSaliguoriEOF
178052166aa0SJuan Quintelaif compile_prog "" "" ; then
178176655d6dSaliguori   fnmatch="yes"
178276655d6dSaliguorifi
178376655d6dSaliguori
178476655d6dSaliguori##########################################
1785ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1786ee682d27SStefan Weilif test "$uuid" != "no" ; then
1787ee682d27SStefan Weil  uuid_libs="-luuid"
1788ee682d27SStefan Weil  cat > $TMPC << EOF
1789ee682d27SStefan Weil#include <uuid/uuid.h>
1790ee682d27SStefan Weilint main(void)
1791ee682d27SStefan Weil{
1792ee682d27SStefan Weil    uuid_t my_uuid;
1793ee682d27SStefan Weil    uuid_generate(my_uuid);
1794ee682d27SStefan Weil    return 0;
1795ee682d27SStefan Weil}
1796ee682d27SStefan WeilEOF
1797ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1798ee682d27SStefan Weil    uuid="yes"
1799ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1800ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1801ee682d27SStefan Weil  else
1802ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1803ee682d27SStefan Weil      feature_not_found "uuid"
1804ee682d27SStefan Weil    fi
1805ee682d27SStefan Weil    uuid=no
1806ee682d27SStefan Weil  fi
1807ee682d27SStefan Weilfi
1808ee682d27SStefan Weil
1809ee682d27SStefan Weil##########################################
1810dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1811dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1812dce512deSChristoph Hellwig  cat > $TMPC << EOF
1813ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
1814dce512deSChristoph Hellwig#include <xfs/xfs.h>
1815dce512deSChristoph Hellwigint main(void)
1816dce512deSChristoph Hellwig{
1817dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1818dce512deSChristoph Hellwig    return 0;
1819dce512deSChristoph Hellwig}
1820dce512deSChristoph HellwigEOF
1821dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1822dce512deSChristoph Hellwig    xfs="yes"
1823dce512deSChristoph Hellwig  else
1824dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1825dce512deSChristoph Hellwig      feature_not_found "xfs"
1826dce512deSChristoph Hellwig    fi
1827dce512deSChristoph Hellwig    xfs=no
1828dce512deSChristoph Hellwig  fi
1829dce512deSChristoph Hellwigfi
1830dce512deSChristoph Hellwig
1831dce512deSChristoph Hellwig##########################################
18328a16d273Sths# vde libraries probe
1833dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
18344baae0acSJuan Quintela  vde_libs="-lvdeplug"
18358a16d273Sths  cat > $TMPC << EOF
18368a16d273Sths#include <libvdeplug.h>
18374a7f0e06Spbrookint main(void)
18384a7f0e06Spbrook{
18394a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
1840fea08e08SPeter Maydell    char s[] = "";
1841fea08e08SPeter Maydell    vde_open(s, s, &a);
18424a7f0e06Spbrook    return 0;
18434a7f0e06Spbrook}
18448a16d273SthsEOF
184552166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
18464baae0acSJuan Quintela    vde=yes
18478e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
18488e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1849dfb278bdSJuan Quintela  else
1850dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1851dfb278bdSJuan Quintela      feature_not_found "vde"
1852dfb278bdSJuan Quintela    fi
1853dfb278bdSJuan Quintela    vde=no
18548a16d273Sths  fi
18558a16d273Sthsfi
18568a16d273Sths
18578a16d273Sths##########################################
185847e98658SCorey Bryant# libcap-ng library probe
185947e98658SCorey Bryantif test "$cap_ng" != "no" ; then
186047e98658SCorey Bryant  cap_libs="-lcap-ng"
186147e98658SCorey Bryant  cat > $TMPC << EOF
186247e98658SCorey Bryant#include <cap-ng.h>
186347e98658SCorey Bryantint main(void)
186447e98658SCorey Bryant{
186547e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
186647e98658SCorey Bryant    return 0;
186747e98658SCorey Bryant}
186847e98658SCorey BryantEOF
186947e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
187047e98658SCorey Bryant    cap_ng=yes
187147e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
187247e98658SCorey Bryant  else
187347e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
187447e98658SCorey Bryant      feature_not_found "cap_ng"
187547e98658SCorey Bryant    fi
187647e98658SCorey Bryant    cap_ng=no
187747e98658SCorey Bryant  fi
187847e98658SCorey Bryantfi
187947e98658SCorey Bryant
188047e98658SCorey Bryant##########################################
1881c2de5c91Smalc# Sound support libraries probe
18828f28f3fbSths
1883c2de5c91Smalcaudio_drv_probe()
1884c2de5c91Smalc{
1885c2de5c91Smalc    drv=$1
1886c2de5c91Smalc    hdr=$2
1887c2de5c91Smalc    lib=$3
1888c2de5c91Smalc    exp=$4
1889c2de5c91Smalc    cfl=$5
18908f28f3fbSths        cat > $TMPC << EOF
1891c2de5c91Smalc#include <$hdr>
1892c2de5c91Smalcint main(void) { $exp }
18938f28f3fbSthsEOF
189452166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
18958f28f3fbSths        :
18968f28f3fbSths    else
18978f28f3fbSths        echo
1898c2de5c91Smalc        echo "Error: $drv check failed"
1899c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
19008f28f3fbSths        echo
19018f28f3fbSths        exit 1
19028f28f3fbSths    fi
1903c2de5c91Smalc}
1904c2de5c91Smalc
19052fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1906c2de5c91Smalcfor drv in $audio_drv_list; do
1907c2de5c91Smalc    case $drv in
1908c2de5c91Smalc    alsa)
1909c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1910e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
1911a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1912c2de5c91Smalc    ;;
1913c2de5c91Smalc
1914c2de5c91Smalc    fmod)
1915c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1916c2de5c91Smalc        echo
1917c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1918c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1919c2de5c91Smalc        echo
1920c2de5c91Smalc        exit 1
19218f28f3fbSths    fi
1922c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1923a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1924c2de5c91Smalc    ;;
1925c2de5c91Smalc
1926c2de5c91Smalc    esd)
1927c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1928a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
192967f86e8eSJuan Quintela    audio_pt_int="yes"
1930c2de5c91Smalc    ;;
1931b8e59f18Smalc
1932b8e59f18Smalc    pa)
1933a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
1934a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
1935a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
193667f86e8eSJuan Quintela    audio_pt_int="yes"
1937b8e59f18Smalc    ;;
1938b8e59f18Smalc
1939997e690aSJuan Quintela    coreaudio)
1940997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1941997e690aSJuan Quintela    ;;
1942997e690aSJuan Quintela
1943a4bf6780SJuan Quintela    dsound)
1944a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1945d5631638Smalc      audio_win_int="yes"
1946a4bf6780SJuan Quintela    ;;
1947a4bf6780SJuan Quintela
1948a4bf6780SJuan Quintela    oss)
1949a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1950a4bf6780SJuan Quintela    ;;
1951a4bf6780SJuan Quintela
1952a4bf6780SJuan Quintela    sdl|wav)
19532f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
19542f6a1ab0Sblueswir1    ;;
19552f6a1ab0Sblueswir1
1956d5631638Smalc    winwave)
1957d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1958d5631638Smalc      audio_win_int="yes"
1959d5631638Smalc    ;;
1960d5631638Smalc
1961e4c63a6aSmalc    *)
19621c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1963e4c63a6aSmalc        echo
1964e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1965e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1966e4c63a6aSmalc        echo
1967e4c63a6aSmalc        exit 1
1968e4c63a6aSmalc    }
1969e4c63a6aSmalc    ;;
1970c2de5c91Smalc    esac
1971c2de5c91Smalcdone
19728f28f3fbSths
19734d3b6f6eSbalrog##########################################
19742e4d9fb1Saurel32# BrlAPI probe
19752e4d9fb1Saurel32
19764ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1977eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
19782e4d9fb1Saurel32  cat > $TMPC << EOF
19792e4d9fb1Saurel32#include <brlapi.h>
1980832ce9c2SScott Wood#include <stddef.h>
19812e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
19822e4d9fb1Saurel32EOF
198352166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
19842e4d9fb1Saurel32    brlapi=yes
1985264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
19864ffcedb6SJuan Quintela  else
19874ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
19884ffcedb6SJuan Quintela      feature_not_found "brlapi"
19894ffcedb6SJuan Quintela    fi
19904ffcedb6SJuan Quintela    brlapi=no
1991eb82284fSJuan Quintela  fi
1992eb82284fSJuan Quintelafi
19932e4d9fb1Saurel32
19942e4d9fb1Saurel32##########################################
19954d3b6f6eSbalrog# curses probe
1996e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
1997e095e2f3SStefan Weil    curses_list="-lpdcurses"
1998e095e2f3SStefan Weilelse
19994f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
2000e095e2f3SStefan Weilfi
20014d3b6f6eSbalrog
2002c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
2003c584a6d0SJuan Quintela  curses_found=no
20044d3b6f6eSbalrog  cat > $TMPC << EOF
20054d3b6f6eSbalrog#include <curses.h>
2006ef9a2524SStefan Weilint main(void) {
2007ef9a2524SStefan Weil  const char *s = curses_version();
2008ef9a2524SStefan Weil  resize_term(0, 0);
2009ef9a2524SStefan Weil  return s != 0;
2010ef9a2524SStefan Weil}
20114d3b6f6eSbalrogEOF
20124f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
20134f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2014c584a6d0SJuan Quintela      curses_found=yes
20154f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
20164f78ef9aSJuan Quintela      break
20174d3b6f6eSbalrog    fi
20184f78ef9aSJuan Quintela  done
2019c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2020c584a6d0SJuan Quintela    curses=yes
2021c584a6d0SJuan Quintela  else
2022c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
2023c584a6d0SJuan Quintela      feature_not_found "curses"
2024c584a6d0SJuan Quintela    fi
2025c584a6d0SJuan Quintela    curses=no
2026c584a6d0SJuan Quintela  fi
20274f78ef9aSJuan Quintelafi
20284d3b6f6eSbalrog
2029414f0dabSblueswir1##########################################
2030769ce76dSAlexander Graf# curl probe
2031769ce76dSAlexander Graf
2032a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
2033a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
20344e2b0658SPaolo Bonzinielse
20354e2b0658SPaolo Bonzini  curlconfig=curl-config
20364e2b0658SPaolo Bonzinifi
20374e2b0658SPaolo Bonzini
2038788c8196SJuan Quintelaif test "$curl" != "no" ; then
2039769ce76dSAlexander Graf  cat > $TMPC << EOF
2040769ce76dSAlexander Graf#include <curl/curl.h>
20410b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2042769ce76dSAlexander GrafEOF
20434e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
20444e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2045b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2046769ce76dSAlexander Graf    curl=yes
2047f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2048f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2049788c8196SJuan Quintela  else
2050788c8196SJuan Quintela    if test "$curl" = "yes" ; then
2051788c8196SJuan Quintela      feature_not_found "curl"
2052788c8196SJuan Quintela    fi
2053788c8196SJuan Quintela    curl=no
2054769ce76dSAlexander Graf  fi
2055769ce76dSAlexander Graffi # test "$curl"
2056769ce76dSAlexander Graf
2057769ce76dSAlexander Graf##########################################
2058fb599c9aSbalrog# bluez support probe
2059a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2060e820e3f4Sbalrog  cat > $TMPC << EOF
2061e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2062e820e3f4Sbalrogint main(void) { return bt_error(0); }
2063e820e3f4SbalrogEOF
2064a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2065a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
206652166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2067a20a6f46SJuan Quintela    bluez=yes
2068e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2069e820e3f4Sbalrog  else
2070a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
2071a20a6f46SJuan Quintela      feature_not_found "bluez"
2072a20a6f46SJuan Quintela    fi
2073e820e3f4Sbalrog    bluez="no"
2074e820e3f4Sbalrog  fi
2075fb599c9aSbalrogfi
2076fb599c9aSbalrog
2077fb599c9aSbalrog##########################################
2078e18df141SAnthony Liguori# glib support probe
2079a52d28afSPaolo Bonzini
2080a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2081a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2082a52d28afSPaolo Bonzini    glib_req_ver=2.20
2083a52d28afSPaolo Bonzinielse
2084a52d28afSPaolo Bonzini    glib_req_ver=2.12
2085a52d28afSPaolo Bonzinifi
2086a52d28afSPaolo Bonziniif $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
2087a52d28afSPaolo Bonzinithen
20884b76a481SStefan Hajnoczi    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
20894b76a481SStefan Hajnoczi    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
209014015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2091957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2092e18df141SAnthony Liguorielse
2093a52d28afSPaolo Bonzini    echo "glib-$glib_req_ver required to compile QEMU"
2094e18df141SAnthony Liguori    exit 1
2095e18df141SAnthony Liguorifi
2096e18df141SAnthony Liguori
2097e18df141SAnthony Liguori##########################################
209817bff52bSM. Mohan Kumar# libcap probe
209917bff52bSM. Mohan Kumar
210017bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
210117bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
210217bff52bSM. Mohan Kumar#include <stdio.h>
210317bff52bSM. Mohan Kumar#include <sys/capability.h>
2104cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
210517bff52bSM. Mohan KumarEOF
210617bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
210717bff52bSM. Mohan Kumar    cap=yes
210817bff52bSM. Mohan Kumar  else
210917bff52bSM. Mohan Kumar    cap=no
211017bff52bSM. Mohan Kumar  fi
211117bff52bSM. Mohan Kumarfi
211217bff52bSM. Mohan Kumar
211317bff52bSM. Mohan Kumar##########################################
2114e5d355d1Saliguori# pthread probe
21154b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
21163c529d93Saliguori
2117e5d355d1Saliguoripthread=no
2118414f0dabSblueswir1cat > $TMPC << EOF
21193c529d93Saliguori#include <pthread.h>
21207a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
21217a42bbe4SStefan Weilint main(void) {
21227a42bbe4SStefan Weil  pthread_t thread;
21237a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
21247a42bbe4SStefan Weil  return 0;
21257a42bbe4SStefan Weil}
2126414f0dabSblueswir1EOF
2127bd00d539SAndreas Färberif compile_prog "" "" ; then
2128bd00d539SAndreas Färber  pthread=yes
2129bd00d539SAndreas Färberelse
2130de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
213152166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2132e5d355d1Saliguori      pthread=yes
2133e3c56761SPeter Portante      found=no
2134e3c56761SPeter Portante      for lib_entry in $LIBS; do
2135e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2136e3c56761SPeter Portante          found=yes
2137e3c56761SPeter Portante          break
2138e3c56761SPeter Portante        fi
2139e3c56761SPeter Portante      done
2140e3c56761SPeter Portante      if test "$found" = "no"; then
21415572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2142e3c56761SPeter Portante      fi
2143de65fe0fSSebastian Herbszt      break
2144414f0dabSblueswir1    fi
2145de65fe0fSSebastian Herbszt  done
2146bd00d539SAndreas Färberfi
2147414f0dabSblueswir1
21484617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
21494dd75c70SChristoph Hellwig  echo
21504dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
21514dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
21524dd75c70SChristoph Hellwig  echo
21534dd75c70SChristoph Hellwig  exit 1
2154e5d355d1Saliguorifi
2155e5d355d1Saliguori
2156bf9298b9Saliguori##########################################
2157f27aaf4bSChristian Brunner# rbd probe
2158f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2159f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2160f27aaf4bSChristian Brunner#include <stdio.h>
2161ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2162f27aaf4bSChristian Brunnerint main(void) {
2163ad32e9c0SJosh Durgin    rados_t cluster;
2164ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2165f27aaf4bSChristian Brunner    return 0;
2166f27aaf4bSChristian Brunner}
2167f27aaf4bSChristian BrunnerEOF
2168ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2169f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2170f27aaf4bSChristian Brunner    rbd=yes
2171f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2172f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2173f27aaf4bSChristian Brunner  else
2174f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
2175f27aaf4bSChristian Brunner      feature_not_found "rados block device"
2176f27aaf4bSChristian Brunner    fi
2177f27aaf4bSChristian Brunner    rbd=no
2178f27aaf4bSChristian Brunner  fi
2179f27aaf4bSChristian Brunnerfi
2180f27aaf4bSChristian Brunner
2181f27aaf4bSChristian Brunner##########################################
21825c6c3a6cSChristoph Hellwig# linux-aio probe
21835c6c3a6cSChristoph Hellwig
21845c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
21855c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
21865c6c3a6cSChristoph Hellwig#include <libaio.h>
21875c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2188832ce9c2SScott Wood#include <stddef.h>
21895c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
21905c6c3a6cSChristoph HellwigEOF
21915c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
21925c6c3a6cSChristoph Hellwig    linux_aio=yes
2193048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2194048d179fSPaul Brook    libs_tools="$libs_tools -laio"
21955c6c3a6cSChristoph Hellwig  else
21965c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
21975c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
21985c6c3a6cSChristoph Hellwig    fi
21993cfcae3cSLuiz Capitulino    linux_aio=no
22005c6c3a6cSChristoph Hellwig  fi
22015c6c3a6cSChristoph Hellwigfi
22025c6c3a6cSChristoph Hellwig
22035c6c3a6cSChristoph Hellwig##########################################
2204758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2205758e8e38SVenkateswararao Jujjuri (JV)
2206758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2207758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2208758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2209758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2210f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2211f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2212f2338fb4SPavel Borzenkov#else
22134f26f2b6SAvi Kivity#include <sys/xattr.h>
2214f2338fb4SPavel Borzenkov#endif
2215758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2216758e8e38SVenkateswararao Jujjuri (JV)EOF
22174f26f2b6SAvi Kivity  if compile_prog "" "" ; then
22184f26f2b6SAvi Kivity    attr=yes
22194f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2220f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2221758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2222758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
22234f26f2b6SAvi Kivity    libattr=yes
2224758e8e38SVenkateswararao Jujjuri (JV)  else
2225758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2226758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2227758e8e38SVenkateswararao Jujjuri (JV)    fi
2228758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2229758e8e38SVenkateswararao Jujjuri (JV)  fi
2230758e8e38SVenkateswararao Jujjuri (JV)fi
2231758e8e38SVenkateswararao Jujjuri (JV)
2232758e8e38SVenkateswararao Jujjuri (JV)##########################################
2233bf9298b9Saliguori# iovec probe
2234bf9298b9Saliguoricat > $TMPC <<EOF
2235db34f0b3Sblueswir1#include <sys/types.h>
2236bf9298b9Saliguori#include <sys/uio.h>
2237db34f0b3Sblueswir1#include <unistd.h>
2238f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2239bf9298b9SaliguoriEOF
2240bf9298b9Saliguoriiovec=no
224152166aa0SJuan Quintelaif compile_prog "" "" ; then
2242bf9298b9Saliguori  iovec=yes
2243bf9298b9Saliguorifi
2244bf9298b9Saliguori
2245f652e6afSaurel32##########################################
2246ceb42de8Saliguori# preadv probe
2247ceb42de8Saliguoricat > $TMPC <<EOF
2248ceb42de8Saliguori#include <sys/types.h>
2249ceb42de8Saliguori#include <sys/uio.h>
2250ceb42de8Saliguori#include <unistd.h>
2251c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2252ceb42de8SaliguoriEOF
2253ceb42de8Saliguoripreadv=no
225452166aa0SJuan Quintelaif compile_prog "" "" ; then
2255ceb42de8Saliguori  preadv=yes
2256ceb42de8Saliguorifi
2257ceb42de8Saliguori
2258ceb42de8Saliguori##########################################
2259f652e6afSaurel32# fdt probe
22602df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2261b41af4baSJuan Quintela  fdt_libs="-lfdt"
2262f652e6afSaurel32  cat > $TMPC << EOF
2263f652e6afSaurel32int main(void) { return 0; }
2264f652e6afSaurel32EOF
226552166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2266f652e6afSaurel32    fdt=yes
22672df87df7SJuan Quintela  else
22682df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
22692df87df7SJuan Quintela      feature_not_found "fdt"
22702df87df7SJuan Quintela    fi
2271de3a354aSMichael Walle    fdt_libs=
22722df87df7SJuan Quintela    fdt=no
2273f652e6afSaurel32  fi
2274f652e6afSaurel32fi
2275f652e6afSaurel32
227620ff075bSMichael Walle##########################################
227720ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
227820ff075bSMichael Walleif test "$opengl" != "no" ; then
227920ff075bSMichael Walle  opengl_libs="-lGL"
228020ff075bSMichael Walle  cat > $TMPC << EOF
228120ff075bSMichael Walle#include <X11/Xlib.h>
228220ff075bSMichael Walle#include <GL/gl.h>
228320ff075bSMichael Walle#include <GL/glx.h>
228484972cbbSStefan Weilint main(void) { return GL_VERSION != 0; }
228520ff075bSMichael WalleEOF
228620ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
228720ff075bSMichael Walle    opengl=yes
228820ff075bSMichael Walle  else
228920ff075bSMichael Walle    if test "$opengl" = "yes" ; then
229020ff075bSMichael Walle      feature_not_found "opengl"
229120ff075bSMichael Walle    fi
2292de3a354aSMichael Walle    opengl_libs=
229320ff075bSMichael Walle    opengl=no
229420ff075bSMichael Walle  fi
229520ff075bSMichael Wallefi
229620ff075bSMichael Walle
2297eb100396SBharata B Rao##########################################
2298eb100396SBharata B Rao# glusterfs probe
2299eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
2300eb100396SBharata B Rao  cat > $TMPC <<EOF
2301eb100396SBharata B Rao#include <glusterfs/api/glfs.h>
2302eb100396SBharata B Raoint main(void) {
2303eb100396SBharata B Rao    (void) glfs_new("volume");
2304eb100396SBharata B Rao    return 0;
2305eb100396SBharata B Rao}
2306eb100396SBharata B RaoEOF
2307eb100396SBharata B Rao  glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
2308eb100396SBharata B Rao  if compile_prog "" "$glusterfs_libs" ; then
2309eb100396SBharata B Rao    glusterfs=yes
2310eb100396SBharata B Rao    libs_tools="$glusterfs_libs $libs_tools"
2311eb100396SBharata B Rao    libs_softmmu="$glusterfs_libs $libs_softmmu"
2312eb100396SBharata B Rao  else
2313eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
2314eb100396SBharata B Rao      feature_not_found "GlusterFS backend support"
2315eb100396SBharata B Rao    fi
2316eb100396SBharata B Rao    glusterfs=no
2317eb100396SBharata B Rao  fi
2318eb100396SBharata B Raofi
2319eb100396SBharata B Rao
23203b3f24adSaurel32#
23213b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
23223b3f24adSaurel32# emulator.  This is done because older glibc versions don't
23233b3f24adSaurel32# have syscall stubs for these implemented.
23243b3f24adSaurel32#
23253b3f24adSaurel32atfile=no
23263b3f24adSaurel32cat > $TMPC << EOF
23273b3f24adSaurel32#define _ATFILE_SOURCE
23283b3f24adSaurel32#include <sys/types.h>
23293b3f24adSaurel32#include <fcntl.h>
23303b3f24adSaurel32#include <unistd.h>
23313b3f24adSaurel32
23323b3f24adSaurel32int
23333b3f24adSaurel32main(void)
23343b3f24adSaurel32{
23353b3f24adSaurel32	/* try to unlink nonexisting file */
23363b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
23373b3f24adSaurel32}
23383b3f24adSaurel32EOF
233952166aa0SJuan Quintelaif compile_prog "" "" ; then
23403b3f24adSaurel32  atfile=yes
23413b3f24adSaurel32fi
23423b3f24adSaurel32
234339386ac7Saurel32# Check for inotify functions when we are building linux-user
23443b3f24adSaurel32# emulator.  This is done because older glibc versions don't
23453b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
23463b3f24adSaurel32# don't provide them even if kernel supports them.
23473b3f24adSaurel32#
23483b3f24adSaurel32inotify=no
23493b3f24adSaurel32cat > $TMPC << EOF
23503b3f24adSaurel32#include <sys/inotify.h>
23513b3f24adSaurel32
23523b3f24adSaurel32int
23533b3f24adSaurel32main(void)
23543b3f24adSaurel32{
23553b3f24adSaurel32	/* try to start inotify */
23568690e420Saurel32	return inotify_init();
23573b3f24adSaurel32}
23583b3f24adSaurel32EOF
235952166aa0SJuan Quintelaif compile_prog "" "" ; then
23603b3f24adSaurel32  inotify=yes
23613b3f24adSaurel32fi
23623b3f24adSaurel32
2363c05c7a73SRiku Voipioinotify1=no
2364c05c7a73SRiku Voipiocat > $TMPC << EOF
2365c05c7a73SRiku Voipio#include <sys/inotify.h>
2366c05c7a73SRiku Voipio
2367c05c7a73SRiku Voipioint
2368c05c7a73SRiku Voipiomain(void)
2369c05c7a73SRiku Voipio{
2370c05c7a73SRiku Voipio    /* try to start inotify */
2371c05c7a73SRiku Voipio    return inotify_init1(0);
2372c05c7a73SRiku Voipio}
2373c05c7a73SRiku VoipioEOF
2374c05c7a73SRiku Voipioif compile_prog "" "" ; then
2375c05c7a73SRiku Voipio  inotify1=yes
2376c05c7a73SRiku Voipiofi
2377c05c7a73SRiku Voipio
2378ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2379ebc996f3SRiku Voipioutimens=no
2380ebc996f3SRiku Voipiocat > $TMPC << EOF
2381ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2382ebc996f3SRiku Voipio#include <stddef.h>
2383ebc996f3SRiku Voipio#include <fcntl.h>
23843014ee00SPeter Maydell#include <sys/stat.h>
2385ebc996f3SRiku Voipio
2386ebc996f3SRiku Voipioint main(void)
2387ebc996f3SRiku Voipio{
2388ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2389ebc996f3SRiku Voipio    futimens(0, NULL);
2390ebc996f3SRiku Voipio    return 0;
2391ebc996f3SRiku Voipio}
2392ebc996f3SRiku VoipioEOF
239352166aa0SJuan Quintelaif compile_prog "" "" ; then
2394ebc996f3SRiku Voipio  utimens=yes
2395ebc996f3SRiku Voipiofi
2396ebc996f3SRiku Voipio
2397099d6b0fSRiku Voipio# check if pipe2 is there
2398099d6b0fSRiku Voipiopipe2=no
2399099d6b0fSRiku Voipiocat > $TMPC << EOF
2400099d6b0fSRiku Voipio#include <unistd.h>
2401099d6b0fSRiku Voipio#include <fcntl.h>
2402099d6b0fSRiku Voipio
2403099d6b0fSRiku Voipioint main(void)
2404099d6b0fSRiku Voipio{
2405099d6b0fSRiku Voipio    int pipefd[2];
24069bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
2407099d6b0fSRiku Voipio}
2408099d6b0fSRiku VoipioEOF
240952166aa0SJuan Quintelaif compile_prog "" "" ; then
2410099d6b0fSRiku Voipio  pipe2=yes
2411099d6b0fSRiku Voipiofi
2412099d6b0fSRiku Voipio
241340ff6d7eSKevin Wolf# check if accept4 is there
241440ff6d7eSKevin Wolfaccept4=no
241540ff6d7eSKevin Wolfcat > $TMPC << EOF
241640ff6d7eSKevin Wolf#include <sys/socket.h>
241740ff6d7eSKevin Wolf#include <stddef.h>
241840ff6d7eSKevin Wolf
241940ff6d7eSKevin Wolfint main(void)
242040ff6d7eSKevin Wolf{
242140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
242240ff6d7eSKevin Wolf    return 0;
242340ff6d7eSKevin Wolf}
242440ff6d7eSKevin WolfEOF
242540ff6d7eSKevin Wolfif compile_prog "" "" ; then
242640ff6d7eSKevin Wolf  accept4=yes
242740ff6d7eSKevin Wolffi
242840ff6d7eSKevin Wolf
24293ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
24303ce34dfbSvibisreenivasansplice=no
24313ce34dfbSvibisreenivasancat > $TMPC << EOF
24323ce34dfbSvibisreenivasan#include <unistd.h>
24333ce34dfbSvibisreenivasan#include <fcntl.h>
24343ce34dfbSvibisreenivasan#include <limits.h>
24353ce34dfbSvibisreenivasan
24363ce34dfbSvibisreenivasanint main(void)
24373ce34dfbSvibisreenivasan{
243866ea0f22SStefan Weil    int len, fd = 0;
24393ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
24403ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
24413ce34dfbSvibisreenivasan    return 0;
24423ce34dfbSvibisreenivasan}
24433ce34dfbSvibisreenivasanEOF
244452166aa0SJuan Quintelaif compile_prog "" "" ; then
24453ce34dfbSvibisreenivasan  splice=yes
24463ce34dfbSvibisreenivasanfi
24473ce34dfbSvibisreenivasan
2448dcc38d1cSMarcelo Tosatti##########################################
2449dcc38d1cSMarcelo Tosatti# signalfd probe
2450dcc38d1cSMarcelo Tosattisignalfd="no"
2451dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2452dcc38d1cSMarcelo Tosatti#include <unistd.h>
2453dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2454dcc38d1cSMarcelo Tosatti#include <signal.h>
2455dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2456dcc38d1cSMarcelo TosattiEOF
2457dcc38d1cSMarcelo Tosatti
2458dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2459dcc38d1cSMarcelo Tosatti  signalfd=yes
2460dcc38d1cSMarcelo Tosattifi
2461dcc38d1cSMarcelo Tosatti
2462c2882b96SRiku Voipio# check if eventfd is supported
2463c2882b96SRiku Voipioeventfd=no
2464c2882b96SRiku Voipiocat > $TMPC << EOF
2465c2882b96SRiku Voipio#include <sys/eventfd.h>
2466c2882b96SRiku Voipio
2467c2882b96SRiku Voipioint main(void)
2468c2882b96SRiku Voipio{
246955cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2470c2882b96SRiku Voipio}
2471c2882b96SRiku VoipioEOF
2472c2882b96SRiku Voipioif compile_prog "" "" ; then
2473c2882b96SRiku Voipio  eventfd=yes
2474c2882b96SRiku Voipiofi
2475c2882b96SRiku Voipio
2476d0927938SUlrich Hecht# check for fallocate
2477d0927938SUlrich Hechtfallocate=no
2478d0927938SUlrich Hechtcat > $TMPC << EOF
2479d0927938SUlrich Hecht#include <fcntl.h>
2480d0927938SUlrich Hecht
2481d0927938SUlrich Hechtint main(void)
2482d0927938SUlrich Hecht{
2483d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2484d0927938SUlrich Hecht    return 0;
2485d0927938SUlrich Hecht}
2486d0927938SUlrich HechtEOF
24878fb03151SPeter Maydellif compile_prog "" "" ; then
2488d0927938SUlrich Hecht  fallocate=yes
2489d0927938SUlrich Hechtfi
2490d0927938SUlrich Hecht
2491c727f47dSPeter Maydell# check for sync_file_range
2492c727f47dSPeter Maydellsync_file_range=no
2493c727f47dSPeter Maydellcat > $TMPC << EOF
2494c727f47dSPeter Maydell#include <fcntl.h>
2495c727f47dSPeter Maydell
2496c727f47dSPeter Maydellint main(void)
2497c727f47dSPeter Maydell{
2498c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2499c727f47dSPeter Maydell    return 0;
2500c727f47dSPeter Maydell}
2501c727f47dSPeter MaydellEOF
25028fb03151SPeter Maydellif compile_prog "" "" ; then
2503c727f47dSPeter Maydell  sync_file_range=yes
2504c727f47dSPeter Maydellfi
2505c727f47dSPeter Maydell
2506dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2507dace20dcSPeter Maydellfiemap=no
2508dace20dcSPeter Maydellcat > $TMPC << EOF
2509dace20dcSPeter Maydell#include <sys/ioctl.h>
2510dace20dcSPeter Maydell#include <linux/fs.h>
2511dace20dcSPeter Maydell#include <linux/fiemap.h>
2512dace20dcSPeter Maydell
2513dace20dcSPeter Maydellint main(void)
2514dace20dcSPeter Maydell{
2515dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2516dace20dcSPeter Maydell    return 0;
2517dace20dcSPeter Maydell}
2518dace20dcSPeter MaydellEOF
25198fb03151SPeter Maydellif compile_prog "" "" ; then
2520dace20dcSPeter Maydell  fiemap=yes
2521dace20dcSPeter Maydellfi
2522dace20dcSPeter Maydell
2523d0927938SUlrich Hecht# check for dup3
2524d0927938SUlrich Hechtdup3=no
2525d0927938SUlrich Hechtcat > $TMPC << EOF
2526d0927938SUlrich Hecht#include <unistd.h>
2527d0927938SUlrich Hecht
2528d0927938SUlrich Hechtint main(void)
2529d0927938SUlrich Hecht{
2530d0927938SUlrich Hecht    dup3(0, 0, 0);
2531d0927938SUlrich Hecht    return 0;
2532d0927938SUlrich Hecht}
2533d0927938SUlrich HechtEOF
253478f5d726SJan Kiszkaif compile_prog "" "" ; then
2535d0927938SUlrich Hecht  dup3=yes
2536d0927938SUlrich Hechtfi
2537d0927938SUlrich Hecht
25383b6edd16SPeter Maydell# check for epoll support
25393b6edd16SPeter Maydellepoll=no
25403b6edd16SPeter Maydellcat > $TMPC << EOF
25413b6edd16SPeter Maydell#include <sys/epoll.h>
25423b6edd16SPeter Maydell
25433b6edd16SPeter Maydellint main(void)
25443b6edd16SPeter Maydell{
25453b6edd16SPeter Maydell    epoll_create(0);
25463b6edd16SPeter Maydell    return 0;
25473b6edd16SPeter Maydell}
25483b6edd16SPeter MaydellEOF
25498fb03151SPeter Maydellif compile_prog "" "" ; then
25503b6edd16SPeter Maydell  epoll=yes
25513b6edd16SPeter Maydellfi
25523b6edd16SPeter Maydell
25533b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
25543b6edd16SPeter Maydell# so we must check separately for their presence
25553b6edd16SPeter Maydellepoll_create1=no
25563b6edd16SPeter Maydellcat > $TMPC << EOF
25573b6edd16SPeter Maydell#include <sys/epoll.h>
25583b6edd16SPeter Maydell
25593b6edd16SPeter Maydellint main(void)
25603b6edd16SPeter Maydell{
256119e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
256219e83f6bSPeter Maydell     * a function being called. This is necessary so that on
256319e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
256419e83f6bSPeter Maydell     * the library but not declared in the header file we will
256519e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
256619e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
256719e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
256819e83f6bSPeter Maydell     */
2569c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
25703b6edd16SPeter Maydell}
25713b6edd16SPeter MaydellEOF
25728fb03151SPeter Maydellif compile_prog "" "" ; then
25733b6edd16SPeter Maydell  epoll_create1=yes
25743b6edd16SPeter Maydellfi
25753b6edd16SPeter Maydell
25763b6edd16SPeter Maydellepoll_pwait=no
25773b6edd16SPeter Maydellcat > $TMPC << EOF
25783b6edd16SPeter Maydell#include <sys/epoll.h>
25793b6edd16SPeter Maydell
25803b6edd16SPeter Maydellint main(void)
25813b6edd16SPeter Maydell{
25823b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
25833b6edd16SPeter Maydell    return 0;
25843b6edd16SPeter Maydell}
25853b6edd16SPeter MaydellEOF
25868fb03151SPeter Maydellif compile_prog "" "" ; then
25873b6edd16SPeter Maydell  epoll_pwait=yes
25883b6edd16SPeter Maydellfi
25893b6edd16SPeter Maydell
2590cc8ae6deSpbrook# Check if tools are available to build documentation.
2591a25dba17SJuan Quintelaif test "$docs" != "no" ; then
259201668d98SStefan Weil  if has makeinfo && has pod2man; then
2593a25dba17SJuan Quintela    docs=yes
259483a3ab8bSJuan Quintela  else
2595a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2596a25dba17SJuan Quintela      feature_not_found "docs"
259783a3ab8bSJuan Quintela    fi
2598a25dba17SJuan Quintela    docs=no
259983a3ab8bSJuan Quintela  fi
2600cc8ae6deSpbrookfi
2601cc8ae6deSpbrook
2602f514f41cSStefan Weil# Search for bswap_32 function
26036ae9a1f4SJuan Quintelabyteswap_h=no
26046ae9a1f4SJuan Quintelacat > $TMPC << EOF
26056ae9a1f4SJuan Quintela#include <byteswap.h>
26066ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
26076ae9a1f4SJuan QuintelaEOF
260852166aa0SJuan Quintelaif compile_prog "" "" ; then
26096ae9a1f4SJuan Quintela  byteswap_h=yes
26106ae9a1f4SJuan Quintelafi
26116ae9a1f4SJuan Quintela
2612f514f41cSStefan Weil# Search for bswap_32 function
26136ae9a1f4SJuan Quintelabswap_h=no
26146ae9a1f4SJuan Quintelacat > $TMPC << EOF
26156ae9a1f4SJuan Quintela#include <sys/endian.h>
26166ae9a1f4SJuan Quintela#include <sys/types.h>
26176ae9a1f4SJuan Quintela#include <machine/bswap.h>
26186ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
26196ae9a1f4SJuan QuintelaEOF
262052166aa0SJuan Quintelaif compile_prog "" "" ; then
26216ae9a1f4SJuan Quintela  bswap_h=yes
26226ae9a1f4SJuan Quintelafi
26236ae9a1f4SJuan Quintela
2624da93a1fdSaliguori##########################################
2625c589b249SRonnie Sahlberg# Do we have libiscsi
2626fa6acb0cSRonnie Sahlberg# We check for iscsi_unmap_sync() to make sure we have a
2627fa6acb0cSRonnie Sahlberg# recent enough version of libiscsi.
2628c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2629c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2630fa6acb0cSRonnie Sahlberg#include <stdio.h>
2631c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2632fa6acb0cSRonnie Sahlbergint main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2633c589b249SRonnie SahlbergEOF
2634417c9d72SAlexander Graf  if compile_prog "" "-liscsi" ; then
2635c589b249SRonnie Sahlberg    libiscsi="yes"
2636c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2637c589b249SRonnie Sahlberg  else
2638c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2639c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2640c589b249SRonnie Sahlberg    fi
2641c589b249SRonnie Sahlberg    libiscsi="no"
2642c589b249SRonnie Sahlberg  fi
2643c589b249SRonnie Sahlbergfi
2644c589b249SRonnie Sahlberg
2645c589b249SRonnie Sahlberg
2646c589b249SRonnie Sahlberg##########################################
26478bacde8dSNatanael Copa# Do we need libm
26488bacde8dSNatanael Copacat > $TMPC << EOF
26498bacde8dSNatanael Copa#include <math.h>
26508bacde8dSNatanael Copaint main(void) { return isnan(sin(0.0)); }
26518bacde8dSNatanael CopaEOF
26528bacde8dSNatanael Copaif compile_prog "" "" ; then
26538bacde8dSNatanael Copa  :
26548bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
26558bacde8dSNatanael Copa  LIBS="-lm $LIBS"
26568bacde8dSNatanael Copa  libs_qga="-lm $libs_qga"
26578bacde8dSNatanael Copaelse
26588bacde8dSNatanael Copa  echo
26598bacde8dSNatanael Copa  echo "Error: libm check failed"
26608bacde8dSNatanael Copa  echo
26618bacde8dSNatanael Copa  exit 1
26628bacde8dSNatanael Copafi
26638bacde8dSNatanael Copa
26648bacde8dSNatanael Copa##########################################
2665da93a1fdSaliguori# Do we need librt
26668bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
26678bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
26688bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
26698bacde8dSNatanael Copa# function in addition.
2670da93a1fdSaliguoricat > $TMPC <<EOF
2671da93a1fdSaliguori#include <signal.h>
2672da93a1fdSaliguori#include <time.h>
26738bacde8dSNatanael Copaint main(void) {
26748bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
26758bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
26768bacde8dSNatanael Copa}
2677da93a1fdSaliguoriEOF
2678da93a1fdSaliguori
267952166aa0SJuan Quintelaif compile_prog "" "" ; then
268007ffa4bdSJuan Quintela  :
26818bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
26828bacde8dSNatanael Copaelif compile_prog "" "-lrt $pthread_lib" ; then
268307ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
26848bacde8dSNatanael Copa  libs_qga="-lrt $libs_qga"
2685da93a1fdSaliguorifi
2686da93a1fdSaliguori
268731ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2688179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
26896362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
26906362a53fSJuan Quintelafi
26916362a53fSJuan Quintela
2692de5071c5SBlue Swirl##########################################
2693cd4ec0b4SGerd Hoffmann# spice probe
2694cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2695cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2696cd4ec0b4SGerd Hoffmann#include <spice.h>
2697cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2698cd4ec0b4SGerd HoffmannEOF
2699710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2700710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
270167be6726SGerd Hoffmann  if $pkg_config --atleast-version=0.12.0 spice-server >/dev/null 2>&1 && \
270267be6726SGerd Hoffmann     $pkg_config --atleast-version=0.12.2 spice-protocol > /dev/null 2>&1 && \
2703cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2704cd4ec0b4SGerd Hoffmann    spice="yes"
2705cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2706cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
27072e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
27082e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
2709cd4ec0b4SGerd Hoffmann  else
2710cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2711cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2712cd4ec0b4SGerd Hoffmann    fi
2713cd4ec0b4SGerd Hoffmann    spice="no"
2714cd4ec0b4SGerd Hoffmann  fi
2715cd4ec0b4SGerd Hoffmannfi
2716cd4ec0b4SGerd Hoffmann
2717111a38b0SRobert Relyea# check for libcacard for smartcard support
2718111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2719111a38b0SRobert Relyea    smartcard="yes"
2720111a38b0SRobert Relyea    smartcard_cflags=""
2721111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2722111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
27235f01e06fSSergei Trofimovich      cat > $TMPC << EOF
27245f01e06fSSergei Trofimovich#include <pk11pub.h>
27255f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
27265f01e06fSSergei TrofimovichEOF
27270b22ef0fSPeter Maydell        smartcard_includes="-I\$(SRC_PATH)/libcacard"
27288c741c22SAlon Levy        libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
27298c741c22SAlon Levy        libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
27306ca026cbSPeter Maydell        test_cflags="$libcacard_cflags"
27316ca026cbSPeter Maydell        # The header files in nss < 3.13.3 have a bug which causes them to
27326ca026cbSPeter Maydell        # emit a warning. If we're going to compile QEMU with -Werror, then
27336ca026cbSPeter Maydell        # test that the headers don't have this bug. Otherwise we would pass
27346ca026cbSPeter Maydell        # the configure test but fail to compile QEMU later.
27356ca026cbSPeter Maydell        if test "$werror" = "yes"; then
27366ca026cbSPeter Maydell            test_cflags="-Werror $test_cflags"
27376ca026cbSPeter Maydell        fi
27385f01e06fSSergei Trofimovich        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
27396ca026cbSPeter Maydell          compile_prog "$test_cflags" "$libcacard_libs"; then
27405f01e06fSSergei Trofimovich            smartcard_nss="yes"
27410b22ef0fSPeter Maydell            QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
27420b22ef0fSPeter Maydell            QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
2743ad4cf3f6SPaul Brook            libs_softmmu="$libcacard_libs $libs_softmmu"
2744111a38b0SRobert Relyea        else
2745111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2746111a38b0SRobert Relyea                feature_not_found "nss"
2747111a38b0SRobert Relyea            fi
2748111a38b0SRobert Relyea            smartcard_nss="no"
2749111a38b0SRobert Relyea        fi
2750111a38b0SRobert Relyea    fi
2751111a38b0SRobert Relyeafi
2752111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2753111a38b0SRobert Relyea    smartcard_nss="no"
2754111a38b0SRobert Relyeafi
2755111a38b0SRobert Relyea
275669354a83SHans de Goede# check for usbredirparser for usb network redirection support
275769354a83SHans de Goedeif test "$usb_redir" != "no" ; then
2758*c19a7981SHans de Goede    if $pkg_config --atleast-version=0.5.3 libusbredirparser-0.5 >/dev/null 2>&1 ; then
275969354a83SHans de Goede        usb_redir="yes"
27608b626aa7SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5 2>/dev/null)
27618b626aa7SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5 2>/dev/null)
276269354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
276356ab2ad1SAurelien Jarno        libs_softmmu="$libs_softmmu $usb_redir_libs"
276469354a83SHans de Goede    else
276569354a83SHans de Goede        if test "$usb_redir" = "yes"; then
276669354a83SHans de Goede            feature_not_found "usb-redir"
276769354a83SHans de Goede        fi
276869354a83SHans de Goede        usb_redir="no"
276969354a83SHans de Goede    fi
277069354a83SHans de Goedefi
277169354a83SHans de Goede
2772cd4ec0b4SGerd Hoffmann##########################################
2773cd4ec0b4SGerd Hoffmann
2774747bbdf7SBlue Swirl##########################################
27755f6b9e8fSBlue Swirl# check if we have fdatasync
27765f6b9e8fSBlue Swirl
27775f6b9e8fSBlue Swirlfdatasync=no
27785f6b9e8fSBlue Swirlcat > $TMPC << EOF
27795f6b9e8fSBlue Swirl#include <unistd.h>
2780d1722a27SAlexandre Raymondint main(void) {
2781d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2782d1722a27SAlexandre Raymondreturn fdatasync(0);
2783d1722a27SAlexandre Raymond#else
2784e172fe11SStefan Weil#error Not supported
2785d1722a27SAlexandre Raymond#endif
2786d1722a27SAlexandre Raymond}
27875f6b9e8fSBlue SwirlEOF
27885f6b9e8fSBlue Swirlif compile_prog "" "" ; then
27895f6b9e8fSBlue Swirl    fdatasync=yes
27905f6b9e8fSBlue Swirlfi
27915f6b9e8fSBlue Swirl
279294a420b1SStefan Hajnoczi##########################################
2793e78815a5SAndreas Färber# check if we have madvise
2794e78815a5SAndreas Färber
2795e78815a5SAndreas Färbermadvise=no
2796e78815a5SAndreas Färbercat > $TMPC << EOF
2797e78815a5SAndreas Färber#include <sys/types.h>
2798e78815a5SAndreas Färber#include <sys/mman.h>
2799832ce9c2SScott Wood#include <stddef.h>
2800e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2801e78815a5SAndreas FärberEOF
2802e78815a5SAndreas Färberif compile_prog "" "" ; then
2803e78815a5SAndreas Färber    madvise=yes
2804e78815a5SAndreas Färberfi
2805e78815a5SAndreas Färber
2806e78815a5SAndreas Färber##########################################
2807e78815a5SAndreas Färber# check if we have posix_madvise
2808e78815a5SAndreas Färber
2809e78815a5SAndreas Färberposix_madvise=no
2810e78815a5SAndreas Färbercat > $TMPC << EOF
2811e78815a5SAndreas Färber#include <sys/mman.h>
2812832ce9c2SScott Wood#include <stddef.h>
2813e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2814e78815a5SAndreas FärberEOF
2815e78815a5SAndreas Färberif compile_prog "" "" ; then
2816e78815a5SAndreas Färber    posix_madvise=yes
2817e78815a5SAndreas Färberfi
2818e78815a5SAndreas Färber
2819e78815a5SAndreas Färber##########################################
28201e9737daSRichard Henderson# check if we have usable SIGEV_THREAD_ID
28211e9737daSRichard Henderson
28221e9737daSRichard Hendersonsigev_thread_id=no
28231e9737daSRichard Hendersoncat > $TMPC << EOF
28241e9737daSRichard Henderson#include <signal.h>
28251e9737daSRichard Hendersonint main(void) {
28261e9737daSRichard Henderson  struct sigevent ev;
28271e9737daSRichard Henderson  ev.sigev_notify = SIGEV_THREAD_ID;
28281e9737daSRichard Henderson  ev._sigev_un._tid = 0;
28291e9737daSRichard Henderson  asm volatile("" : : "g"(&ev));
28301e9737daSRichard Henderson  return 0;
28311e9737daSRichard Henderson}
28321e9737daSRichard HendersonEOF
28331e9737daSRichard Hendersonif compile_prog "" "" ; then
28341e9737daSRichard Henderson    sigev_thread_id=yes
28351e9737daSRichard Hendersonfi
28361e9737daSRichard Henderson
28371e9737daSRichard Henderson##########################################
283894a420b1SStefan Hajnoczi# check if trace backend exists
283994a420b1SStefan Hajnoczi
2840650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
284194a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
284294a420b1SStefan Hajnoczi  echo
284394a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
284494a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
284594a420b1SStefan Hajnoczi  echo
284694a420b1SStefan Hajnoczi  exit 1
284794a420b1SStefan Hajnoczifi
284894a420b1SStefan Hajnoczi
28497e24e92aSStefan Hajnoczi##########################################
28507e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
28517e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
28527e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
28537e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
28547e24e92aSStefan Hajnoczi#include <ust/marker.h>
28557e24e92aSStefan Hajnocziint main(void) { return 0; }
28567e24e92aSStefan HajnocziEOF
28577e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
285894b4fefaSLluís Vilanova    LIBS="-lust -lurcu-bp $LIBS"
2859c9a2e37cSLluís Vilanova    libs_qga="-lust -lurcu-bp $libs_qga"
28607e24e92aSStefan Hajnoczi  else
28617e24e92aSStefan Hajnoczi    echo
28627e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
28637e24e92aSStefan Hajnoczi    echo
28647e24e92aSStefan Hajnoczi    exit 1
28657e24e92aSStefan Hajnoczi  fi
28667e24e92aSStefan Hajnoczifi
2867b3d08c02SDaniel P. Berrange
2868b3d08c02SDaniel P. Berrange##########################################
2869b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2870b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2871b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2872b3d08c02SDaniel P. Berrange    echo
2873b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2874b3d08c02SDaniel P. Berrange    echo
2875b3d08c02SDaniel P. Berrange    exit 1
2876b3d08c02SDaniel P. Berrange  fi
2877c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2878c276b17dSDaniel P. Berrange  if has 'stap' ; then
2879c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2880c276b17dSDaniel P. Berrange  fi
2881b3d08c02SDaniel P. Berrangefi
2882b3d08c02SDaniel P. Berrange
28837e24e92aSStefan Hajnoczi##########################################
2884023367e6SWolfgang Mauerer# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2885023367e6SWolfgang Mauerer# use i686 as default anyway, but for those that don't, an explicit
2886023367e6SWolfgang Mauerer# specification is necessary
28871ba16968SStefan Weilif test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
2888023367e6SWolfgang Mauerer  cat > $TMPC << EOF
28897ace252aSStefan Weilstatic int sfaa(int *ptr)
2890023367e6SWolfgang Mauerer{
2891023367e6SWolfgang Mauerer  return __sync_fetch_and_and(ptr, 0);
2892023367e6SWolfgang Mauerer}
2893023367e6SWolfgang Mauerer
2894abab1a0fSStefan Weilint main(void)
2895023367e6SWolfgang Mauerer{
2896023367e6SWolfgang Mauerer  int val = 42;
2897023367e6SWolfgang Mauerer  sfaa(&val);
2898023367e6SWolfgang Mauerer  return val;
2899023367e6SWolfgang Mauerer}
2900023367e6SWolfgang MauererEOF
2901023367e6SWolfgang Mauerer  if ! compile_prog "" "" ; then
2902caa50971SPeter Maydell    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2903023367e6SWolfgang Mauerer  fi
2904023367e6SWolfgang Mauererfi
2905023367e6SWolfgang Mauerer
2906023367e6SWolfgang Mauerer##########################################
2907519175a2SAlex Barcelo# check and set a backend for coroutine
2908d0e2fce5SAneesh Kumar K.V
2909519175a2SAlex Barcelo# default is ucontext, but always fallback to gthread
2910519175a2SAlex Barcelo# windows autodetected by make
2911519175a2SAlex Barceloif test "$coroutine" = "" -o "$coroutine" = "ucontext"; then
2912d0e2fce5SAneesh Kumar K.V  if test "$darwin" != "yes"; then
2913d0e2fce5SAneesh Kumar K.V    cat > $TMPC << EOF
2914d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
2915cdf84806SPeter Maydell#ifdef __stub_makecontext
2916cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
2917cdf84806SPeter Maydell#endif
291875cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
2919d0e2fce5SAneesh Kumar K.VEOF
2920d0e2fce5SAneesh Kumar K.V    if compile_prog "" "" ; then
2921519175a2SAlex Barcelo        coroutine_backend=ucontext
2922519175a2SAlex Barcelo    else
2923519175a2SAlex Barcelo	coroutine_backend=gthread
2924d0e2fce5SAneesh Kumar K.V    fi
2925519175a2SAlex Barcelo  else
2926519175a2SAlex Barcelo    echo "Silently falling back into gthread backend under darwin"
2927519175a2SAlex Barcelo  fi
2928519175a2SAlex Barceloelif test "$coroutine" = "gthread" ; then
2929519175a2SAlex Barcelo  coroutine_backend=gthread
2930519175a2SAlex Barceloelif test "$coroutine" = "windows" ; then
2931519175a2SAlex Barcelo  coroutine_backend=windows
2932fe91bfa8SAlex Barceloelif test "$coroutine" = "sigaltstack" ; then
2933fe91bfa8SAlex Barcelo  coroutine_backend=sigaltstack
2934519175a2SAlex Barceloelse
2935519175a2SAlex Barcelo  echo
2936519175a2SAlex Barcelo  echo "Error: unknown coroutine backend $coroutine"
2937519175a2SAlex Barcelo  echo
2938519175a2SAlex Barcelo  exit 1
2939d0e2fce5SAneesh Kumar K.Vfi
2940d0e2fce5SAneesh Kumar K.V
2941d0e2fce5SAneesh Kumar K.V##########################################
2942d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
2943d2042378SAneesh Kumar K.V
29444e1797f9SStefan Weilopen_by_handle_at=no
2945d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
2946d2042378SAneesh Kumar K.V#include <fcntl.h>
2947acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
2948acc55ba8SStefan Weil# error missing definition
2949acc55ba8SStefan Weil#else
295075cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
2951acc55ba8SStefan Weil#endif
2952d2042378SAneesh Kumar K.VEOF
2953d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
2954d2042378SAneesh Kumar K.V    open_by_handle_at=yes
2955d2042378SAneesh Kumar K.Vfi
2956d2042378SAneesh Kumar K.V
2957e06a765eSHarsh Prateek Bora########################################
2958e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
2959e06a765eSHarsh Prateek Bora
2960e06a765eSHarsh Prateek Boralinux_magic_h=no
2961e06a765eSHarsh Prateek Boracat > $TMPC << EOF
2962e06a765eSHarsh Prateek Bora#include <linux/magic.h>
2963e06a765eSHarsh Prateek Boraint main(void) {
296475cafad7SStefan Weil  return 0;
2965e06a765eSHarsh Prateek Bora}
2966e06a765eSHarsh Prateek BoraEOF
2967e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
2968e06a765eSHarsh Prateek Bora    linux_magic_h=yes
2969e06a765eSHarsh Prateek Borafi
2970e06a765eSHarsh Prateek Bora
29718ab1bf12SLuiz Capitulino########################################
297206d71fa1SPeter Maydell# check whether we can disable the -Wunused-but-set-variable
297306d71fa1SPeter Maydell# option with a pragma (this is needed to silence a warning in
297406d71fa1SPeter Maydell# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.)
297506d71fa1SPeter Maydell# This test has to be compiled with -Werror as otherwise an
297606d71fa1SPeter Maydell# unknown pragma is only a warning.
297706d71fa1SPeter Maydellpragma_disable_unused_but_set=no
297806d71fa1SPeter Maydellcat > $TMPC << EOF
297906d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
298006d71fa1SPeter Maydellint main(void) {
298106d71fa1SPeter Maydell    return 0;
298206d71fa1SPeter Maydell}
298306d71fa1SPeter MaydellEOF
298406d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
298506d71fa1SPeter Maydell    pragma_disable_unused_but_set=yes
298606d71fa1SPeter Maydellfi
298706d71fa1SPeter Maydell
298806d71fa1SPeter Maydell########################################
298962fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
29903f4349dcSKevin Wolf
29913f4349dcSKevin Wolfvalgrind_h=no
29923f4349dcSKevin Wolfcat > $TMPC << EOF
29933f4349dcSKevin Wolf#include <valgrind/valgrind.h>
299462fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
29953f4349dcSKevin Wolfint main(void) {
29963f4349dcSKevin Wolf  return 0;
29973f4349dcSKevin Wolf}
29983f4349dcSKevin WolfEOF
29993f4349dcSKevin Wolfif compile_prog "" "" ; then
30003f4349dcSKevin Wolf    valgrind_h=yes
30013f4349dcSKevin Wolffi
30023f4349dcSKevin Wolf
30033f4349dcSKevin Wolf########################################
30048ab1bf12SLuiz Capitulino# check if environ is declared
30058ab1bf12SLuiz Capitulino
30068ab1bf12SLuiz Capitulinohas_environ=no
30078ab1bf12SLuiz Capitulinocat > $TMPC << EOF
30088ab1bf12SLuiz Capitulino#include <unistd.h>
30098ab1bf12SLuiz Capitulinoint main(void) {
3010c075a723SBlue Swirl    environ = 0;
30118ab1bf12SLuiz Capitulino    return 0;
30128ab1bf12SLuiz Capitulino}
30138ab1bf12SLuiz CapitulinoEOF
30148ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
30158ab1bf12SLuiz Capitulino    has_environ=yes
30168ab1bf12SLuiz Capitulinofi
30178ab1bf12SLuiz Capitulino
3018d2042378SAneesh Kumar K.V##########################################
3019e86ecd4bSJuan Quintela# End of CC checks
3020e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3021e86ecd4bSJuan Quintela
3022e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
30238be74dc0SAvi Kivity  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3024e86ecd4bSJuan Quintelafi
3025a316e378SJuan Quintela
302620ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
302720ff6c80SAnthony Liguori# enable/disable
302820ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
302920ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
303020ff6c80SAnthony Liguori	zero_malloc="no"
303120ff6c80SAnthony Liguori    else
303220ff6c80SAnthony Liguori	zero_malloc="yes"
303320ff6c80SAnthony Liguori    fi
303420ff6c80SAnthony Liguorifi
303520ff6c80SAnthony Liguori
30366ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
30376ca026cbSPeter Maydellif test "$werror" = "yes"; then
30386ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
30396ca026cbSPeter Maydellfi
30406ca026cbSPeter Maydell
3041e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3042e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
30431156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3044e86ecd4bSJuan Quintela    fi
3045e86ecd4bSJuan Quintelafi
3046e86ecd4bSJuan Quintela
304794dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
304894dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
304994dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
305094dd53c5SGerd Hoffmannelse
305194dd53c5SGerd Hoffmann    POD2MAN="pod2man"
305294dd53c5SGerd Hoffmannfi
305394dd53c5SGerd Hoffmann
3054952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3055952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3056952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3057952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3058952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3059952afb71SBlue Swirl        fi
3060952afb71SBlue Swirl    done
3061952afb71SBlue Swirlfi
3062952afb71SBlue Swirl
306310ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3064528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
30655a67135aSbellard
30664b1c11fdSDaniel P. Berrangetools=""
30674b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3068ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
30694b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
30704b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
30714b1c11fdSDaniel P. Berrange  fi
30724b1c11fdSDaniel P. Berrangefi
30734b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3074983eef5aSMeador Inge  if test "$virtfs" != no ; then
3075be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3076983eef5aSMeador Inge      virtfs=yes
307717bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3078983eef5aSMeador Inge    else
3079983eef5aSMeador Inge      if test "$virtfs" = yes; then
3080263ddcc8SHarsh Prateek Bora        echo "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3081263ddcc8SHarsh Prateek Bora        exit 1
3082983eef5aSMeador Inge      fi
308317500370SAndreas Färber      virtfs=no
3084983eef5aSMeador Inge    fi
308517bff52bSM. Mohan Kumar  fi
3086ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3087d138cee9SMichael Roth    if [ "$guest_agent" = "yes" ]; then
308848ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
3089d138cee9SMichael Roth    fi
3090ca35f780SPaolo Bonzini  fi
309100c705fbSPaolo Bonzini  if test "$smartcard_nss" = "yes" ; then
309200c705fbSPaolo Bonzini    tools="vscclient\$(EXESUF) $tools"
309300c705fbSPaolo Bonzini  fi
30944b1c11fdSDaniel P. Berrangefi
3095ca35f780SPaolo Bonzini
3096ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3097ca35f780SPaolo Bonziniroms=
3098ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3099ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3100ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3101ca35f780SPaolo Bonzini  roms="optionrom"
3102ca35f780SPaolo Bonzinifi
3103d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
310439ac8455SDavid Gibson  roms="$roms spapr-rtas"
310539ac8455SDavid Gibsonfi
3106ca35f780SPaolo Bonzini
31077d13299dSbellardecho "Install prefix    $prefix"
3108c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3109f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
31103aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
31118bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
31120f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
31131c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
3114785c23aeSLuiz Capitulinoecho "local state directory   `eval echo $local_statedir`"
311511d9f695Sbellardif test "$mingw32" = "no" ; then
3116f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
311743ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
311811d9f695Sbellardfi
31195a67135aSbellardecho "Source path       $source_path"
31207d13299dSbellardecho "C compiler        $cc"
312183469015Sbellardecho "Host C compiler   $host_cc"
31223c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
31230c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3124a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
31250c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
31267d13299dSbellardecho "make              $make"
31276a882643Spbrookecho "install           $install"
3128c886edfbSBlue Swirlecho "python            $python"
3129e2d8830eSBradif test "$slirp" = "yes" ; then
3130e2d8830eSBrad    echo "smbd              $smbd"
3131e2d8830eSBradfi
3132a98fd896Sbellardecho "host CPU          $cpu"
3133de83cd02Sbellardecho "host big endian   $bigendian"
313497a847bcSbellardecho "target list       $target_list"
3135ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
31367d13299dSbellardecho "gprof enabled     $gprof"
313703b4fe7dSaliguoriecho "sparse enabled    $sparse"
31381625af87Saliguoriecho "strip binaries    $strip_opt"
313905c2a3e7Sbellardecho "profiler          $profiler"
314043ce4dfeSbellardecho "static build      $static"
314185aa5189Sbellardecho "-Werror enabled   $werror"
31425b0753e0Sbellardif test "$darwin" = "yes" ; then
31435b0753e0Sbellard    echo "Cocoa support     $cocoa"
31445b0753e0Sbellardfi
314597a847bcSbellardecho "SDL support       $sdl"
31464d3b6f6eSbalrogecho "curses support    $curses"
3147769ce76dSAlexander Grafecho "curl support      $curl"
314867b915a5Sbellardecho "mingw32 support   $mingw32"
31490c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
31500c58ac1cSmalcecho "Extra audio cards $audio_card_list"
3151eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
31528ff9cbf7Smalcecho "Mixer emulation   $mixemu"
3153983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3154821601eaSJes Sorensenecho "VNC support       $vnc"
3155821601eaSJes Sorensenif test "$vnc" = "yes" ; then
31568d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
31572f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
31582f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3159efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
3160821601eaSJes Sorensenfi
31613142255cSblueswir1if test -n "$sparc_cpu"; then
31623142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
31633142255cSblueswir1fi
3164e37630caSaliguoriecho "xen support       $xen"
31652e4d9fb1Saurel32echo "brlapi support    $brlapi"
3166a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3167a25dba17SJuan Quintelaecho "Documentation     $docs"
3168c5937220Spbrook[ ! -z "$uname_release" ] && \
3169c5937220Spbrookecho "uname -r          $uname_release"
3170bd0c5661Spbrookecho "NPTL support      $nptl"
3171379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
317240d6444eSAvi Kivityecho "PIE               $pie"
31738a16d273Sthsecho "vde support       $vde"
31745c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3175758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
317677755340Sthsecho "Install blobs     $blobs"
3177b31a0277SJuan Quintelaecho "KVM support       $kvm"
31789195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3179f652e6afSaurel32echo "fdt support       $fdt"
3180ceb42de8Saliguoriecho "preadv support    $preadv"
31815f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3182e78815a5SAndreas Färberecho "madvise           $madvise"
3183e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
31841e9737daSRichard Hendersonecho "sigev_thread_id   $sigev_thread_id"
3185ee682d27SStefan Weilecho "uuid support      $uuid"
318647e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3187d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
318894a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
31899410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
31902e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3191f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3192dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3193111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
319469354a83SHans de Goedeecho "usb net redir     $usb_redir"
319520ff075bSMichael Walleecho "OpenGL support    $opengl"
3196c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3197d138cee9SMichael Rothecho "build guest agent $guest_agent"
3198f794573eSEduardo Otuboecho "seccomp support   $seccomp"
3199519175a2SAlex Barceloecho "coroutine backend $coroutine_backend"
3200eb100396SBharata B Raoecho "GlusterFS support $glusterfs"
320167b915a5Sbellard
32021ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
320324b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3204e8cd23deSbellardfi
320597a847bcSbellard
320698ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
32074bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
320897a847bcSbellard
320998ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
321098ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
321198ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
321298ec69acSJuan Quintelaecho >> $config_host_mak
321398ec69acSJuan Quintela
3214e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
321599d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
321699d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
32173aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
32188bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
32190f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
322099d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
322199d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
322222d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
32239afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
32249afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
3225785c23aeSLuiz Capitulinoecho "qemu_localstatedir=$local_statedir" >> $config_host_mak
3226f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
3227804edf29SJuan Quintela
322898ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3229f8393946Saurel32if test "$debug_tcg" = "yes" ; then
32302358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3231f8393946Saurel32fi
3232f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
32332358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
3234f3d08ee6SPaul Brookfi
32351625af87Saliguoriif test "$strip_opt" = "yes" ; then
323652ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
32371625af87Saliguorifi
32387d13299dSbellardif test "$bigendian" = "yes" ; then
3239e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
324097a847bcSbellardfi
324167b915a5Sbellardif test "$mingw32" = "yes" ; then
324298ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
32439fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
32449fe6de94SBlue Swirl  version_major=${rc_version%%.*}
32459fe6de94SBlue Swirl  rc_version=${rc_version#*.}
32469fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
32479fe6de94SBlue Swirl  rc_version=${rc_version#*.}
32489fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
32499fe6de94SBlue Swirl  version_micro=0
32509fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
32519fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3252210fa556Spbrookelse
325335f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3254210fa556Spbrookfi
3255128ab2ffSblueswir1
3256dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3257dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3258dffcb71cSMark McLoughlinfi
3259dffcb71cSMark McLoughlin
326083fb7adfSbellardif test "$darwin" = "yes" ; then
326198ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
326283fb7adfSbellardfi
3263b29fe3edSmalc
3264b29fe3edSmalcif test "$aix" = "yes" ; then
326598ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
3266b29fe3edSmalcfi
3267b29fe3edSmalc
3268ec530c81Sbellardif test "$solaris" = "yes" ; then
326998ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
32702358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
32710475a5caSths  if test "$needs_libsunmath" = "yes" ; then
327275b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
32730475a5caSths  fi
3274ec530c81Sbellardfi
3275179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3276179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3277179cf400SAndreas Färberfi
327897a847bcSbellardif test "$static" = "yes" ; then
327998ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
328097a847bcSbellardfi
32811ba16968SStefan Weilif test "$profiler" = "yes" ; then
32822358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
328305c2a3e7Sbellardfi
3284c20709aaSbellardif test "$slirp" = "yes" ; then
328598ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
3286e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3287f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
3288c20709aaSbellardfi
32898a16d273Sthsif test "$vde" = "yes" ; then
329098ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
32918a16d273Sthsfi
329247e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
329347e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
329447e98658SCorey Bryantfi
32950c58ac1cSmalcfor card in $audio_card_list; do
3296bb55b712SStefan Weil    def=CONFIG_`echo $card | LC_ALL=C tr '[a-z]' '[A-Z]'`
329798ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
32980c58ac1cSmalcdone
32992358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
33000c58ac1cSmalcfor drv in $audio_drv_list; do
3301bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
330298ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
3303923e4521Smalc    if test "$drv" = "fmod"; then
33047aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3305fb065187Sbellard    fi
33060c58ac1cSmalcdone
330767f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
330867f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
330967f86e8eSJuan Quintelafi
3310d5631638Smalcif test "$audio_win_int" = "yes" ; then
3311d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3312d5631638Smalcfi
3313eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
33148ff9cbf7Smalcif test "$mixemu" = "yes" ; then
331598ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
33168ff9cbf7Smalcfi
3317821601eaSJes Sorensenif test "$vnc" = "yes" ; then
3318821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
3319821601eaSJes Sorensenfi
33208d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
332198ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
3322525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
33238d5d2d4cSthsfi
33242f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
332598ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
332660ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
33272f9606b3Saliguorifi
3328821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
33292f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
33302f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
33312f6f5c7aSCorentin Charyfi
3332821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
3333efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3334efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
3335efe556adSCorentin Charyfi
333676655d6dSaliguoriif test "$fnmatch" = "yes" ; then
33372358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
333876655d6dSaliguorifi
3339ee682d27SStefan Weilif test "$uuid" = "yes" ; then
3340ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
3341ee682d27SStefan Weilfi
3342dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3343dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3344dce512deSChristoph Hellwigfi
3345b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
334698ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
33472358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
334898ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
334998ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
3350a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
335198ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
3352cc8ae6deSpbrookfi
33531ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
335498ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
33558ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
335649ecc3faSbellardfi
335749ecc3faSbellardif test "$cocoa" = "yes" ; then
335898ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
335949ecc3faSbellardfi
33604d3b6f6eSbalrogif test "$curses" = "yes" ; then
336198ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
3362ab4e5602SJan Kiszkafi
33633b3f24adSaurel32if test "$atfile" = "yes" ; then
33642358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
33653b3f24adSaurel32fi
3366ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
33672358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3368ebc996f3SRiku Voipiofi
3369099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
33702358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
3371099d6b0fSRiku Voipiofi
337240ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
337340ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
337440ff6d7eSKevin Wolffi
33753ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
33762358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
33773ce34dfbSvibisreenivasanfi
3378c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
3379c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
3380c2882b96SRiku Voipiofi
3381d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
3382d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3383d0927938SUlrich Hechtfi
3384c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
3385c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3386c727f47dSPeter Maydellfi
3387dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
3388dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
3389dace20dcSPeter Maydellfi
3390d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
3391d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
3392d0927938SUlrich Hechtfi
33933b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
33943b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
33953b6edd16SPeter Maydellfi
33963b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
33973b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
33983b6edd16SPeter Maydellfi
33993b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
34003b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
34013b6edd16SPeter Maydellfi
34023b3f24adSaurel32if test "$inotify" = "yes" ; then
34032358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
34043b3f24adSaurel32fi
3405c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3406c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3407c05c7a73SRiku Voipiofi
34086ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
34096ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
34106ae9a1f4SJuan Quintelafi
34116ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
34126ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
34136ae9a1f4SJuan Quintelafi
3414769ce76dSAlexander Grafif test "$curl" = "yes" ; then
341598ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3416b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3417769ce76dSAlexander Graffi
34182e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
341998ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
34202e4d9fb1Saurel32fi
3421fb599c9aSbalrogif test "$bluez" = "yes" ; then
342298ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3423ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3424fb599c9aSbalrogfi
3425e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3426e37630caSaliguoriif test "$xen" = "yes" ; then
34276dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3428d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3429e37630caSaliguorifi
34305c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
34315c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
34325c6c3a6cSChristoph Hellwigfi
3433758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3434758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3435758e8e38SVenkateswararao Jujjuri (JV)fi
34364f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
34374f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
34384f26f2b6SAvi Kivityfi
3439983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
3440758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
3441758e8e38SVenkateswararao Jujjuri (JV)fi
344277755340Sthsif test "$blobs" = "yes" ; then
344398ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
344477755340Sthsfi
3445bf9298b9Saliguoriif test "$iovec" = "yes" ; then
34462358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3447bf9298b9Saliguorifi
3448ceb42de8Saliguoriif test "$preadv" = "yes" ; then
34492358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3450ceb42de8Saliguorifi
3451f652e6afSaurel32if test "$fdt" = "yes" ; then
34523f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3453f652e6afSaurel32fi
3454dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3455dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3456dcc38d1cSMarcelo Tosattifi
34579195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
34589195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
34599195b2c2SStefan Weilfi
34605f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
34615f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
34625f6b9e8fSBlue Swirlfi
3463e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3464e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3465e78815a5SAndreas Färberfi
3466e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3467e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3468e78815a5SAndreas Färberfi
34691e9737daSRichard Hendersonif test "$sigev_thread_id" = "yes" ; then
34701e9737daSRichard Henderson  echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
34711e9737daSRichard Hendersonfi
347297a847bcSbellard
3473cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3474cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3475cd4ec0b4SGerd Hoffmannfi
3476cd4ec0b4SGerd Hoffmann
347736707144SAlon Levyif test "$smartcard" = "yes" ; then
347836707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
347936707144SAlon Levyfi
348036707144SAlon Levy
3481111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3482111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3483ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3484ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3485111a38b0SRobert Relyeafi
3486111a38b0SRobert Relyea
348769354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
348869354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
348969354a83SHans de Goedefi
349069354a83SHans de Goede
349120ff075bSMichael Walleif test "$opengl" = "yes" ; then
349220ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
349320ff075bSMichael Wallefi
349420ff075bSMichael Walle
3495c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3496c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3497c589b249SRonnie Sahlbergfi
3498c589b249SRonnie Sahlberg
3499f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
3500f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
3501f794573eSEduardo Otubofi
3502f794573eSEduardo Otubo
350383fb7adfSbellard# XXX: suppress that
35047d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
35052358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
35067d3505c5Sbellardfi
35077d3505c5Sbellard
35082358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3509c5937220Spbrook
351020ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
351120ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
351220ff6c80SAnthony Liguorifi
3513f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3514f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3515f27aaf4bSChristian Brunnerfi
351620ff6c80SAnthony Liguori
3517519175a2SAlex Barceloif test "$coroutine_backend" = "ucontext" ; then
3518d0e2fce5SAneesh Kumar K.V  echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
3519fe91bfa8SAlex Barceloelif test "$coroutine_backend" = "sigaltstack" ; then
3520fe91bfa8SAlex Barcelo  echo "CONFIG_SIGALTSTACK_COROUTINE=y" >> $config_host_mak
3521d0e2fce5SAneesh Kumar K.Vfi
3522d0e2fce5SAneesh Kumar K.V
3523d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
3524d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3525d2042378SAneesh Kumar K.Vfi
3526d2042378SAneesh Kumar K.V
3527e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
3528e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3529e06a765eSHarsh Prateek Borafi
3530e06a765eSHarsh Prateek Bora
353106d71fa1SPeter Maydellif test "$pragma_disable_unused_but_set" = "yes" ; then
353206d71fa1SPeter Maydell  echo "CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET=y" >> $config_host_mak
353306d71fa1SPeter Maydellfi
353406d71fa1SPeter Maydell
35353f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
35363f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
35373f4349dcSKevin Wolffi
35383f4349dcSKevin Wolf
35398ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
35408ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
35418ab1bf12SLuiz Capitulinofi
35428ab1bf12SLuiz Capitulino
3543eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
3544eb100396SBharata B Rao  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
3545eb100396SBharata B Raofi
3546eb100396SBharata B Rao
354768063649Sblueswir1# USB host support
354868063649Sblueswir1case "$usb" in
354968063649Sblueswir1linux)
355098ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
355168063649Sblueswir1;;
355268063649Sblueswir1bsd)
355398ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
355468063649Sblueswir1;;
355568063649Sblueswir1*)
355698ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
355768063649Sblueswir1;;
355868063649Sblueswir1esac
355968063649Sblueswir1
3560e4858974SLluís# use default implementation for tracing backend-specific routines
3561e4858974SLluístrace_default=yes
356294a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
35636d8a764eSLluísif test "$trace_backend" = "nop"; then
35646d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
356522890ab5SPrerna Saxenafi
35669410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
35676d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
3568e4858974SLluís  trace_default=no
35696d8a764eSLluís  # Set the appropriate trace file.
3570953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
35719410b56cSPrerna Saxenafi
35726d8a764eSLluísif test "$trace_backend" = "stderr"; then
35736d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
35749a82b6a5SLluís  trace_default=no
35756d8a764eSLluísfi
35766d8a764eSLluísif test "$trace_backend" = "ust"; then
35776d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
35786d8a764eSLluísfi
35796d8a764eSLluísif test "$trace_backend" = "dtrace"; then
35806d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
35816d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
35826d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
35836d8a764eSLluís  fi
3584c276b17dSDaniel P. Berrangefi
35859410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
3586e4858974SLluísif test "$trace_default" = "yes"; then
3587e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3588e4858974SLluísfi
35899410b56cSPrerna Saxena
359098ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
359198ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3592804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3593804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
35941901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
35951901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
35961901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
3597c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
3598804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
35992b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3600804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
36013c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
3602804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3603804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3604804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
36059fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
360644dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3607e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3608a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3609f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3610e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3611e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3612e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3613e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3614e39f0062SPaolo Bonzinifi
3615e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3616a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3617a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
361873da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
36193e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3620804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3621957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
362294dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
3623804edf29SJuan Quintela
36244bf6b55bSJuan Quintela# generate list of library paths for linker script
36254bf6b55bSJuan Quintela
36264bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
36274bf6b55bSJuan Quintela
36284bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
36294bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
36304bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
36314bf6b55bSJuan Quintela  else
36324bf6b55bSJuan Quintela    rm ${config_host_ld}~
36334bf6b55bSJuan Quintela  fi
36344bf6b55bSJuan Quintelafi
36354bf6b55bSJuan Quintela
36364d904533SBlue Swirlfor d in libdis libdis-user; do
363772b8b5a1SStefan Weil    symlink "$source_path/Makefile.dis" "$d/Makefile"
36384d904533SBlue Swirl    echo > $d/config.mak
36394d904533SBlue Swirldone
36404d904533SBlue Swirl
36416efd7517SPeter Maydell# use included Linux headers
36426efd7517SPeter Maydellif test "$linux" = "yes" ; then
3643a307beb6SAndreas Färber  mkdir -p linux-headers
36446efd7517SPeter Maydell  case "$cpu" in
36456efd7517SPeter Maydell  i386|x86_64)
364608312a63SPeter Maydell    linux_arch=x86
36476efd7517SPeter Maydell    ;;
36486efd7517SPeter Maydell  ppcemb|ppc|ppc64)
364908312a63SPeter Maydell    linux_arch=powerpc
36506efd7517SPeter Maydell    ;;
36516efd7517SPeter Maydell  s390x)
365208312a63SPeter Maydell    linux_arch=s390
365308312a63SPeter Maydell    ;;
365408312a63SPeter Maydell  *)
365508312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
365608312a63SPeter Maydell    linux_arch="$cpu"
36576efd7517SPeter Maydell    ;;
36586efd7517SPeter Maydell  esac
365908312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
366008312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
366108312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
366208312a63SPeter Maydell    fi
36636efd7517SPeter Maydellfi
36646efd7517SPeter Maydell
366597a847bcSbellardfor target in $target_list; do
366697a847bcSbellardtarget_dir="$target"
366725be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3668600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
366997a847bcSbellardtarget_bigendian="no"
36701f3d3c8fSJuan Quintela
3671ea2d6a39SJuan Quintelacase "$target_arch2" in
3672e67db06eSJia Liu  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
3673ea2d6a39SJuan Quintela  target_bigendian=yes
3674ea2d6a39SJuan Quintela  ;;
3675ea2d6a39SJuan Quintelaesac
367697a847bcSbellardtarget_softmmu="no"
3677997344f3Sbellardtarget_user_only="no"
3678831b7825Sthstarget_linux_user="no"
367984778508Sblueswir1target_bsd_user="no"
36809e407a85Spbrookcase "$target" in
3681600309b6SBlue Swirl  ${target_arch2}-softmmu)
36829e407a85Spbrook    target_softmmu="yes"
36839e407a85Spbrook    ;;
3684600309b6SBlue Swirl  ${target_arch2}-linux-user)
36859c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
36869c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
36879c7a4202SBlue Swirl      exit 1
36889c7a4202SBlue Swirl    fi
36899e407a85Spbrook    target_user_only="yes"
36909e407a85Spbrook    target_linux_user="yes"
36919e407a85Spbrook    ;;
3692600309b6SBlue Swirl  ${target_arch2}-bsd-user)
36939cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
36949c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
36959c7a4202SBlue Swirl      exit 1
36969c7a4202SBlue Swirl    fi
369784778508Sblueswir1    target_user_only="yes"
369884778508Sblueswir1    target_bsd_user="yes"
369984778508Sblueswir1    ;;
37009e407a85Spbrook  *)
37019e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
37029e407a85Spbrook    exit 1
37039e407a85Spbrook    ;;
37049e407a85Spbrookesac
3705831b7825Sths
370697a847bcSbellardmkdir -p $target_dir
370725be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
370897a847bcSbellard
3709e5fe0c52Spbrookbflt="no"
3710bd0c5661Spbrooktarget_nptl="no"
3711600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
371256aebc89Spbrookgdb_xml_files=""
3713c2e3dee6SLaurent Viviertarget_short_alignment=2
3714c2e3dee6SLaurent Viviertarget_int_alignment=4
3715c2e3dee6SLaurent Viviertarget_long_alignment=4
3716c2e3dee6SLaurent Viviertarget_llong_alignment=8
3717de3a354aSMichael Walletarget_libs_softmmu=
37187ba1e619Saliguori
3719938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
37206acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3721e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3722e73aae67SJuan Quintela
3723600309b6SBlue Swirlcase "$target_arch2" in
37242408a527Saurel32  i386)
37252408a527Saurel32  ;;
37262408a527Saurel32  x86_64)
37276acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
3728c2e3dee6SLaurent Vivier    target_long_alignment=8
37292408a527Saurel32  ;;
37302408a527Saurel32  alpha)
3731c2e3dee6SLaurent Vivier    target_long_alignment=8
3732a4b388ffSRichard Henderson    target_nptl="yes"
37332408a527Saurel32  ;;
37342408a527Saurel32  arm|armeb)
3735b498c8a0SJuan Quintela    TARGET_ARCH=arm
3736e5fe0c52Spbrook    bflt="yes"
3737bd0c5661Spbrook    target_nptl="yes"
373856aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
3739c2e3dee6SLaurent Vivier    target_llong_alignment=4
3740412beee6SGrant Likely    target_libs_softmmu="$fdt_libs"
37412408a527Saurel32  ;;
37422408a527Saurel32  cris)
3743253bd7f8Sedgar_igl    target_nptl="yes"
37442408a527Saurel32  ;;
3745613a22c9SMichael Walle  lm32)
3746de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3747613a22c9SMichael Walle  ;;
37482408a527Saurel32  m68k)
37490938cda5Saurel32    bflt="yes"
375056aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
3751c2e3dee6SLaurent Vivier    target_int_alignment=2
3752c2e3dee6SLaurent Vivier    target_long_alignment=2
3753c2e3dee6SLaurent Vivier    target_llong_alignment=2
37542408a527Saurel32  ;;
3755877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3756877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
375772b675caSEdgar E. Iglesias    bflt="yes"
375872b675caSEdgar E. Iglesias    target_nptl="yes"
3759de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
376072b675caSEdgar E. Iglesias  ;;
37612408a527Saurel32  mips|mipsel)
3762b498c8a0SJuan Quintela    TARGET_ARCH=mips
376325be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3764f04dc72fSPaul Brook    target_nptl="yes"
37652408a527Saurel32  ;;
37662408a527Saurel32  mipsn32|mipsn32el)
3767b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
37686acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
376925be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
37702408a527Saurel32  ;;
37712408a527Saurel32  mips64|mips64el)
3772b498c8a0SJuan Quintela    TARGET_ARCH=mips64
37736acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
377425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
3775c2e3dee6SLaurent Vivier    target_long_alignment=8
37762408a527Saurel32  ;;
3777e67db06eSJia Liu  or32)
3778e67db06eSJia Liu    TARGET_ARCH=openrisc
3779e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
3780e67db06eSJia Liu  ;;
37812408a527Saurel32  ppc)
3782c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3783d6630708SNathan Froyd    target_nptl="yes"
3784de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37852408a527Saurel32  ;;
37862408a527Saurel32  ppcemb)
37876acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3788e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3789c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3790d6630708SNathan Froyd    target_nptl="yes"
3791de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37922408a527Saurel32  ;;
37932408a527Saurel32  ppc64)
37946acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3795e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3796c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3797c2e3dee6SLaurent Vivier    target_long_alignment=8
3798de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37992408a527Saurel32  ;;
38002408a527Saurel32  ppc64abi32)
3801b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
38026acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3803e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
380425be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3805c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3806de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
38072408a527Saurel32  ;;
38082408a527Saurel32  sh4|sh4eb)
3809b498c8a0SJuan Quintela    TARGET_ARCH=sh4
38104dbed897Spbrook    bflt="yes"
38110b6d3ae0Saurel32    target_nptl="yes"
38122408a527Saurel32  ;;
38132408a527Saurel32  sparc)
38142408a527Saurel32  ;;
38152408a527Saurel32  sparc64)
38166acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3817c2e3dee6SLaurent Vivier    target_long_alignment=8
38182408a527Saurel32  ;;
38192408a527Saurel32  sparc32plus)
3820b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
38216acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3822e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
382325be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
38242408a527Saurel32  ;;
382524e804ecSAlexander Graf  s390x)
3826bc434676SUlrich Hecht    target_nptl="yes"
38277b3da903SAlexander Graf    target_long_alignment=8
382824e804ecSAlexander Graf  ;;
3829d2fbca94SGuan Xuetao  unicore32)
3830d2fbca94SGuan Xuetao  ;;
3831cfa550c6SMax Filippov  xtensa|xtensaeb)
3832cfa550c6SMax Filippov    TARGET_ARCH=xtensa
3833cfa550c6SMax Filippov  ;;
38342408a527Saurel32  *)
3835de83cd02Sbellard    echo "Unsupported target CPU"
3836de83cd02Sbellard    exit 1
38372408a527Saurel32  ;;
38382408a527Saurel32esac
38395e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
38405e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
38415e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
38425e8861a0SPaolo Bonzinifi
38435e8861a0SPaolo Bonzini
38445e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
38455e8861a0SPaolo Bonzini
384699afc91dSDaniel P. Berrangeupper() {
384799afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
384899afc91dSDaniel P. Berrange}
384999afc91dSDaniel P. Berrange
3850c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3851c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3852c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3853c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
385425be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
385599afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
385625be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
385725be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
385899afc91dSDaniel P. Berrangeecho "TARGET_TYPE=TARGET_TYPE_`upper $target_arch2`" >> $config_target_mak
385925be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3860e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3861e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3862e6e91b9cSJuan Quintelafi
386325be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
38641b0c87fcSJuan Quintelacase "$target_arch2" in
38651b0c87fcSJuan Quintela  i386|x86_64)
38661b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
386725be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
3868eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
3869eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
3870eb6fda0fSAnthony PERARD      fi
387159d21e53SAlexander Graf    else
387259d21e53SAlexander Graf      echo "CONFIG_NO_XEN=y" >> $config_target_mak
3873432d268cSJun Nakajima    fi
387459d21e53SAlexander Graf    ;;
387559d21e53SAlexander Graf  *)
387659d21e53SAlexander Graf    echo "CONFIG_NO_XEN=y" >> $config_target_mak
38771b0c87fcSJuan Quintelaesac
3878c59249f9SJuan Quintelacase "$target_arch2" in
38790e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3880c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3881c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3882c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3883c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
38845f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3885adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3886adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3887c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3888c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
388925be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
38901ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
3891d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3892d5970055SMichael S. Tsirkin      fi
3893c59249f9SJuan Quintela    fi
3894c59249f9SJuan Quintelaesac
3895fae001f5SWen Congyangcase "$target_arch2" in
3896fae001f5SWen Congyang  i386|x86_64)
3897fae001f5SWen Congyang    echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
3898fae001f5SWen Congyangesac
38997f762366SBlue Swirlif test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then
39000a6b8ddeSAlexander Graf  echo "CONFIG_PSERIES=y" >> $config_target_mak
39010a6b8ddeSAlexander Graffi
3902de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
390325be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
390497a847bcSbellardfi
390597a847bcSbellardif test "$target_softmmu" = "yes" ; then
390625be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3907de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
3908ad4cf3f6SPaul Brook  if test "$smartcard_nss" = "yes" ; then
3909ad4cf3f6SPaul Brook    echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3910ad4cf3f6SPaul Brook  fi
39119fecbed0SWen Congyang  case "$target_arch2" in
39129fecbed0SWen Congyang    i386|x86_64)
39139fecbed0SWen Congyang      echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
39149fecbed0SWen Congyang  esac
3915de83cd02Sbellardfi
3916997344f3Sbellardif test "$target_user_only" = "yes" ; then
391725be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3918a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
3919997344f3Sbellardfi
3920831b7825Sthsif test "$target_linux_user" = "yes" ; then
392125be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3922831b7825Sthsfi
392356aebc89Spbrooklist=""
392456aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
392556aebc89Spbrook  for x in $gdb_xml_files; do
392656aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
392756aebc89Spbrook  done
392825be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
39293d0f1517SJuan Quintelafi
3930de83cd02Sbellard
3931e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
393225be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3933e5fe0c52Spbrookfi
3934bd0c5661Spbrookif test "$target_user_only" = "yes" \
3935bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
393625be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3937bd0c5661Spbrookfi
3938379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
393925be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3940379f6698SPaul Brookfi
394184778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
394225be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
394384778508Sblueswir1fi
39445b0753e0Sbellard
39455a4d701aSJan Kiszka# the static way of configuring available audio cards requires this workaround
39465a4d701aSJan Kiszkaif test "$target_user_only" != "yes" && grep -q CONFIG_PCSPK $source_path/default-configs/$target.mak; then
39475a4d701aSJan Kiszka  echo "CONFIG_PCSPK=y" >> $config_target_mak
39485a4d701aSJan Kiszkafi
39495a4d701aSJan Kiszka
39504afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3951fa282484SJuan Quintela
39524afddb55SJuan Quintelacflags=""
3953f9728943SPaolo Bonziniincludes=""
3954fa282484SJuan Quintelaldflags=""
39559b8e111fSJuan Quintela
39569195b2c2SStefan Weilif test "$tcg_interpreter" = "yes"; then
39579195b2c2SStefan Weil  includes="-I\$(SRC_PATH)/tcg/tci $includes"
39589195b2c2SStefan Weilelif test "$ARCH" = "sparc64" ; then
3959f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
396024e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3961f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
39625d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3963f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
396457ddfbf7SJuan Quintelaelse
3965f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
396657ddfbf7SJuan Quintelafi
3967f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
396857ddfbf7SJuan Quintela
39696efd7517SPeter Maydellif test "$linux" = "yes" ; then
39706efd7517SPeter Maydell  includes="-I\$(SRC_PATH)/linux-headers $includes"
39716efd7517SPeter Maydellfi
39726efd7517SPeter Maydell
39734d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
39744d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
39754d904533SBlue Swirlelse
39764d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
39774d904533SBlue Swirlfi
39784d904533SBlue Swirl
397964656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
398064656024SJuan Quintela  case "$i" in
398164656024SJuan Quintela  alpha)
398225be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
39834d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
398464656024SJuan Quintela  ;;
398564656024SJuan Quintela  arm)
398625be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
39874d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
398864656024SJuan Quintela  ;;
398964656024SJuan Quintela  cris)
399025be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
39914d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
399264656024SJuan Quintela  ;;
399364656024SJuan Quintela  hppa)
399425be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
39954d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
399664656024SJuan Quintela  ;;
399764656024SJuan Quintela  i386|x86_64)
399825be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
39994d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
400064656024SJuan Quintela  ;;
4001903ec55cSAurelien Jarno  ia64*)
4002903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
4003903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
4004903ec55cSAurelien Jarno  ;;
400579368f49SMichael Walle  lm32)
400679368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
400779368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $libdis_config_mak
400879368f49SMichael Walle  ;;
400964656024SJuan Quintela  m68k)
401025be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
40114d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
401264656024SJuan Quintela  ;;
4013877fdc12SEdgar E. Iglesias  microblaze*)
401425be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
40154d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
401664656024SJuan Quintela  ;;
401764656024SJuan Quintela  mips*)
401825be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
40194d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
402064656024SJuan Quintela  ;;
4021e67db06eSJia Liu  or32)
4022e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
4023e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $libdis_config_mak
4024e67db06eSJia Liu  ;;
402564656024SJuan Quintela  ppc*)
402625be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
40274d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
402864656024SJuan Quintela  ;;
402924e804ecSAlexander Graf  s390*)
403025be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
40314d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
403264656024SJuan Quintela  ;;
403364656024SJuan Quintela  sh4)
403425be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
40354d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
403664656024SJuan Quintela  ;;
403764656024SJuan Quintela  sparc*)
403825be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
40394d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
404064656024SJuan Quintela  ;;
4041cfa550c6SMax Filippov  xtensa*)
4042cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
4043cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $libdis_config_mak
4044cfa550c6SMax Filippov  ;;
404564656024SJuan Quintela  esac
404664656024SJuan Quinteladone
40479195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
40489195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
40499195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $libdis_config_mak
40509195b2c2SStefan Weilfi
405164656024SJuan Quintela
40526ee7126fSJuan Quintelacase "$ARCH" in
40536ee7126fSJuan Quintelaalpha)
40546ee7126fSJuan Quintela  # Ensure there's only a single GP
40556ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
40566ee7126fSJuan Quintela;;
40576ee7126fSJuan Quintelaesac
40586ee7126fSJuan Quintela
405955d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
406055d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
406155d9c04bSJuan Quintela  arm)
406255d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
406355d9c04bSJuan Quintela  ;;
406425a8bb96SMichael Walle  lm32)
406525a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
406625a8bb96SMichael Walle  ;;
406755d9c04bSJuan Quintela  i386|mips|ppc)
406855d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
406955d9c04bSJuan Quintela  ;;
407055d9c04bSJuan Quintela  esac
407155d9c04bSJuan Quintelafi
407255d9c04bSJuan Quintela
4073d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
407425be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4075d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4076d02c1db3SJuan Quintela    cflags="-p $cflags"
4077d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4078d02c1db3SJuan Quintela  fi
4079d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4080d02c1db3SJuan Quintela    ldflags="-p $ldflags"
408125be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4082d02c1db3SJuan Quintela  fi
4083d02c1db3SJuan Quintelafi
4084d02c1db3SJuan Quintela
40859195b2c2SStefan Weilif test "$ARCH" = "tci"; then
40869195b2c2SStefan Weil  linker_script=""
40879195b2c2SStefan Weilelse
40886ee7126fSJuan Quintela  linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
40899195b2c2SStefan Weilfi
40909195b2c2SStefan Weil
40919b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4092fa282484SJuan Quintela  case "$ARCH" in
40934d58be06SRichard Henderson  alpha | s390x)
40944d58be06SRichard Henderson    # The default placement of the application is fine.
40954d58be06SRichard Henderson    ;;
4096fd76e73aSRichard Henderson  *)
4097322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
4098fa282484SJuan Quintela    ;;
4099fa282484SJuan Quintela  esac
4100fa282484SJuan Quintelafi
4101fa282484SJuan Quintela
410225be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
410325be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4104f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
4105fa282484SJuan Quintela
410697a847bcSbellarddone # for target in $targets
41077d13299dSbellard
4108d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
4109927b241dSMichael WalleDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32"
41102dee8d54SPaolo BonziniDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
41112d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
41122dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
411300c705fbSPaolo BonziniDIRS="$DIRS libcacard libcacard/libcacard libcacard/trace"
4114c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4115c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
411600c705fbSPaolo BonziniFILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile"
4117ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4118446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
41192d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4120753d11f2SRichard Hendersonfor bios_file in \
4121753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
4122753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4123753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4124753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4125753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4126753d11f2SRichard Hendersondo
41277ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
41287ea78b74SJan Kiszkadone
4129d1807a4fSPaolo Bonzinimkdir -p $DIRS
41307d13299dSbellardfor f in $FILES ; do
413172b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4132f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4133f9245e10SPeter Maydell    fi
41347d13299dSbellarddone
41351ad2134fSPaul Brook
4136c34ebfdcSAnthony Liguori# temporary config to build submodules
41372d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4138c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
413937116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4140c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
4141c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4142c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
4143c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
4144c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4145c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
4146c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4147c34ebfdcSAnthony Liguoridone
4148c34ebfdcSAnthony Liguori
4149add16157SBlue Swirld=libuser
415072b8b5a1SStefan Weilsymlink "$source_path/Makefile.user" "$d/Makefile"
4151b40292e7SJan Kiszka
4152b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4153b40292e7SJan Kiszka  mkdir -p QMP
4154b40292e7SJan Kiszkafi
4155