xref: /openbmc/qemu/configure (revision 66d5499b3754b83c09487259c08fe2ce73188a59)
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"
114ed968ff1SJuan Quintelasparc_cpu=""
1157d13299dSbellardcross_prefix=""
1160c58ac1cSmalcaudio_drv_list=""
11761dc008fSAnthony Liguoriaudio_card_list="ac97 es1370 sb16 hda"
11861dc008fSAnthony Liguoriaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
119eb852011SMarkus Armbrusterblock_drv_whitelist=""
1207d13299dSbellardhost_cc="gcc"
121c81da56eSJuan Quintelahelper_cflags=""
12273da375eSJuan Quintelalibs_softmmu=""
1233e2e0e6bSJuan Quintelalibs_tools=""
12467f86e8eSJuan Quintelaaudio_pt_int=""
125d5631638Smalcaudio_win_int=""
1262b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
127957f1f99SMichael Rothlibs_qga=""
1285bc62e01SGerd Hoffmanndebug_info="yes"
129ac0df51dSaliguori
130*66d5499bSDaniel P. Berrangetarget_list="DEFAULT"
131377529c0SPaolo Bonzini
132377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
133377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
134377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
135377529c0SPaolo Bonzini#              unless --disable-foo is given
136377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
137377529c0SPaolo Bonzini#              feature will searched for,
138377529c0SPaolo Bonzini#              if not found, configure exits with error
139377529c0SPaolo Bonzini#
140377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
141377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
142377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
143377529c0SPaolo Bonzini
144377529c0SPaolo Bonzinibluez=""
145377529c0SPaolo Bonzinibrlapi=""
146377529c0SPaolo Bonzinicurl=""
147377529c0SPaolo Bonzinicurses=""
148377529c0SPaolo Bonzinidocs=""
149377529c0SPaolo Bonzinifdt=""
150377529c0SPaolo Bonzininptl=""
151377529c0SPaolo Bonzinisdl=""
152983eef5aSMeador Ingevirtfs=""
153821601eaSJes Sorensenvnc="yes"
154377529c0SPaolo Bonzinisparse="no"
155377529c0SPaolo Bonziniuuid=""
156377529c0SPaolo Bonzinivde=""
157377529c0SPaolo Bonzinivnc_tls=""
158377529c0SPaolo Bonzinivnc_sasl=""
159377529c0SPaolo Bonzinivnc_jpeg=""
160377529c0SPaolo Bonzinivnc_png=""
161377529c0SPaolo Bonzinixen=""
162d5b93ddfSAnthony PERARDxen_ctrl_version=""
163eb6fda0fSAnthony PERARDxen_pci_passthrough=""
164377529c0SPaolo Bonzinilinux_aio=""
16547e98658SCorey Bryantcap_ng=""
166377529c0SPaolo Bonziniattr=""
1674f26f2b6SAvi Kivitylibattr=""
168377529c0SPaolo Bonzinixfs=""
169377529c0SPaolo Bonzini
170d41a75a2SBradvhost_net="no"
171d41a75a2SBradkvm="no"
172377529c0SPaolo Bonzinigprof="no"
173377529c0SPaolo Bonzinidebug_tcg="no"
174377529c0SPaolo Bonzinidebug="no"
175377529c0SPaolo Bonzinistrip_opt="yes"
1769195b2c2SStefan Weiltcg_interpreter="no"
177377529c0SPaolo Bonzinibigendian="no"
178377529c0SPaolo Bonzinimingw32="no"
179377529c0SPaolo BonziniEXESUF=""
180377529c0SPaolo Bonziniprefix="/usr/local"
181377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
182528ae5b8SEduardo Habkostdatadir="\${prefix}/share"
183850da188SEduardo Habkostqemu_docdir="\${prefix}/share/doc/qemu"
184377529c0SPaolo Bonzinibindir="\${prefix}/bin"
1853aa5d2beSAlon Levylibdir="\${prefix}/lib"
1868bf188aaSMichael Tokarevlibexecdir="\${prefix}/libexec"
1870f94d6daSAlon Levyincludedir="\${prefix}/include"
188377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
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"
202377529c0SPaolo Bonziniguest_base=""
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"
220c589b249SRonnie Sahlberglibiscsi=""
221519175a2SAlex Barcelocoroutine=""
222f794573eSEduardo Otuboseccomp=""
223377529c0SPaolo Bonzini
224ac0df51dSaliguori# parse CC options first
225ac0df51dSaliguorifor opt do
226ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
227ac0df51dSaliguori  case "$opt" in
228ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
229ac0df51dSaliguori  ;;
2303d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
231ac0df51dSaliguori  ;;
232ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
233ca4deeb1SPaolo Bonzini  ;;
2342ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2352ff6b91eSJuan Quintela  ;;
236a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
237e2a2ed06SJuan Quintela  ;;
238e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
239e2a2ed06SJuan Quintela  ;;
2405bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2415bc62e01SGerd Hoffmann  ;;
2425bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2435bc62e01SGerd Hoffmann  ;;
24450e7b1a0SJuan Quintela  --sparc_cpu=*)
24550e7b1a0SJuan Quintela    sparc_cpu="$optarg"
24650e7b1a0SJuan Quintela    case $sparc_cpu in
247ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
24850e7b1a0SJuan Quintela      cpu="sparc"
24950e7b1a0SJuan Quintela    ;;
25050e7b1a0SJuan Quintela    v9)
25150e7b1a0SJuan Quintela      cpu="sparc64"
25250e7b1a0SJuan Quintela    ;;
25350e7b1a0SJuan Quintela    *)
25450e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
25550e7b1a0SJuan Quintela      exit 1
25650e7b1a0SJuan Quintela    ;;
25750e7b1a0SJuan Quintela    esac
25850e7b1a0SJuan Quintela  ;;
259ac0df51dSaliguori  esac
260ac0df51dSaliguoridone
261ac0df51dSaliguori# OS specific
262ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
26393148aa5SStefan Weil# we can eliminate its usage altogether.
264ac0df51dSaliguori
265b3198cc2SStuart Yodercc="${CC-${cross_prefix}gcc}"
266b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
267b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
268b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
2693f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
270b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
271b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
27217884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
27317884d7bSSergei Trofimovichquery_pkg_config() {
27417884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
27517884d7bSSergei Trofimovich}
27617884d7bSSergei Trofimovichpkg_config=query_pkg_config
277b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
278ac0df51dSaliguori
279be17dc90SMichael S. Tsirkin# default flags for all hosts
280be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
281f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
282be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
283be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
284cbbab922SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu"
2855bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
2865bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
287be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
2885bc62e01SGerd Hoffmannfi
289be17dc90SMichael S. Tsirkin
290ca4deeb1SPaolo Bonzini# make source path absolute
291ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
292ca4deeb1SPaolo Bonzini
293ac0df51dSaliguoricheck_define() {
294ac0df51dSaliguoricat > $TMPC <<EOF
295ac0df51dSaliguori#if !defined($1)
296fd786e1aSPeter Maydell#error $1 not defined
297ac0df51dSaliguori#endif
298ac0df51dSaliguoriint main(void) { return 0; }
299ac0df51dSaliguoriEOF
30052166aa0SJuan Quintela  compile_object
301ac0df51dSaliguori}
302ac0df51dSaliguori
303bbea4050SPeter Maydellif check_define __linux__ ; then
304bbea4050SPeter Maydell  targetos="Linux"
305bbea4050SPeter Maydellelif check_define _WIN32 ; then
306bbea4050SPeter Maydell  targetos='MINGW32'
307bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
308bbea4050SPeter Maydell  targetos='OpenBSD'
309bbea4050SPeter Maydellelif check_define __sun__ ; then
310bbea4050SPeter Maydell  targetos='SunOS'
311bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
312bbea4050SPeter Maydell  targetos='Haiku'
313bbea4050SPeter Maydellelse
314bbea4050SPeter Maydell  targetos=`uname -s`
315bbea4050SPeter Maydellfi
316bbea4050SPeter Maydell
317bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
318bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
319bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
320bbea4050SPeter Maydell# the correct CPU with the --cpu option.
321bbea4050SPeter Maydellcase $targetos in
322bbea4050SPeter MaydellDarwin)
323bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
324bbea4050SPeter Maydell  # run 64-bit userspace code.
325bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
326bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
327bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
328bbea4050SPeter Maydell    cpu="x86_64"
329bbea4050SPeter Maydell  fi
330bbea4050SPeter Maydell  ;;
331bbea4050SPeter MaydellSunOS)
332bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
333bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
334bbea4050SPeter Maydell    cpu="x86_64"
335bbea4050SPeter Maydell  fi
336bbea4050SPeter Maydellesac
337bbea4050SPeter Maydell
3382ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3392ff6b91eSJuan Quintela  # command line argument
3402ff6b91eSJuan Quintela  :
3412ff6b91eSJuan Quintelaelif check_define __i386__ ; then
342ac0df51dSaliguori  cpu="i386"
343ac0df51dSaliguorielif check_define __x86_64__ ; then
344ac0df51dSaliguori  cpu="x86_64"
3453aa9bd6cSblueswir1elif check_define __sparc__ ; then
3463aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
3473aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
3483aa9bd6cSblueswir1  if check_define __arch64__ ; then
3493aa9bd6cSblueswir1    cpu="sparc64"
3503aa9bd6cSblueswir1  else
3513aa9bd6cSblueswir1    cpu="sparc"
3523aa9bd6cSblueswir1  fi
353fdf7ed96Smalcelif check_define _ARCH_PPC ; then
354fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
355fdf7ed96Smalc    cpu="ppc64"
356ac0df51dSaliguori  else
357fdf7ed96Smalc    cpu="ppc"
358fdf7ed96Smalc  fi
359afa05235SAurelien Jarnoelif check_define __mips__ ; then
360afa05235SAurelien Jarno  cpu="mips"
361477ba620SAurelien Jarnoelif check_define __ia64__ ; then
362477ba620SAurelien Jarno  cpu="ia64"
363d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
364d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
365d66ed0eaSAurelien Jarno    cpu="s390x"
366d66ed0eaSAurelien Jarno  else
367d66ed0eaSAurelien Jarno    cpu="s390"
368d66ed0eaSAurelien Jarno  fi
36921d89f84SPeter Maydellelif check_define __arm__ ; then
37021d89f84SPeter Maydell  cpu="arm"
371f28ffed5SBradelif check_define __hppa__ ; then
372f28ffed5SBrad  cpu="hppa"
373fdf7ed96Smalcelse
374fdf7ed96Smalc  cpu=`uname -m`
375ac0df51dSaliguorifi
376ac0df51dSaliguori
377359bc95dSPeter MaydellARCH=
378359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
379359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
3807d13299dSbellardcase "$cpu" in
381359bc95dSPeter Maydell  ia64|ppc|ppc64|s390|s390x|sparc64)
382ea8f20f8SJuan Quintela    cpu="$cpu"
383ea8f20f8SJuan Quintela  ;;
3847d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
38597a847bcSbellard    cpu="i386"
3867d13299dSbellard  ;;
387aaa5fa14Saurel32  x86_64|amd64)
388aaa5fa14Saurel32    cpu="x86_64"
389aaa5fa14Saurel32  ;;
39021d89f84SPeter Maydell  armv*b|armv*l|arm)
39121d89f84SPeter Maydell    cpu="arm"
3927d13299dSbellard  ;;
393f28ffed5SBrad  hppa|parisc|parisc64)
394f54b3f92Saurel32    cpu="hppa"
395f54b3f92Saurel32  ;;
396afa05235SAurelien Jarno  mips*)
397afa05235SAurelien Jarno    cpu="mips"
398afa05235SAurelien Jarno  ;;
3993142255cSblueswir1  sparc|sun4[cdmuv])
400ae228531Sbellard    cpu="sparc"
401ae228531Sbellard  ;;
4027d13299dSbellard  *)
403359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
404359bc95dSPeter Maydell    ARCH=unknown
4057d13299dSbellard  ;;
4067d13299dSbellardesac
407359bc95dSPeter Maydellif test -z "$ARCH"; then
408359bc95dSPeter Maydell  ARCH="$cpu"
409359bc95dSPeter Maydellfi
410e2d52ad3SJuan Quintela
4117d13299dSbellard# OS specific
4120dbfc675SJuan Quintela
4137d13299dSbellardcase $targetos in
414c326e0afSbellardCYGWIN*)
415c326e0afSbellard  mingw32="yes"
416a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
417d5631638Smalc  audio_possible_drivers="winwave sdl"
418d5631638Smalc  audio_drv_list="winwave"
419c326e0afSbellard;;
42067b915a5SbellardMINGW32*)
42167b915a5Sbellard  mingw32="yes"
422d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
423d5631638Smalc  audio_drv_list="winwave"
42467b915a5Sbellard;;
4255c40d2bdSthsGNU/kFreeBSD)
426a167ba50SAurelien Jarno  bsd="yes"
4270c58ac1cSmalc  audio_drv_list="oss"
428f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4295c40d2bdSths;;
4307d3505c5SbellardFreeBSD)
4317d3505c5Sbellard  bsd="yes"
4320db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4330c58ac1cSmalc  audio_drv_list="oss"
434f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
435f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
436f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
4377d3505c5Sbellard;;
438c5e97233Sblueswir1DragonFly)
439c5e97233Sblueswir1  bsd="yes"
4400db4a067SPaolo Bonzini  make="${MAKE-gmake}"
441c5e97233Sblueswir1  audio_drv_list="oss"
442c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
443c5e97233Sblueswir1;;
4447d3505c5SbellardNetBSD)
4457d3505c5Sbellard  bsd="yes"
4460db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4470c58ac1cSmalc  audio_drv_list="oss"
448c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4498ef92a88Sblueswir1  oss_lib="-lossaudio"
4507d3505c5Sbellard;;
4517d3505c5SbellardOpenBSD)
4527d3505c5Sbellard  bsd="yes"
4530db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4540c58ac1cSmalc  audio_drv_list="oss"
455c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4562f6a1ab0Sblueswir1  oss_lib="-lossaudio"
4577d3505c5Sbellard;;
45883fb7adfSbellardDarwin)
45983fb7adfSbellard  bsd="yes"
46083fb7adfSbellard  darwin="yes"
4611b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
462a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4630c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4641b0f9cc2Saliguori  else
465a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
4661b0f9cc2Saliguori  fi
467fd677642Sths  cocoa="yes"
4680c58ac1cSmalc  audio_drv_list="coreaudio"
469c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4700c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4717973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
472a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
473a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
474a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
47583fb7adfSbellard;;
476ec530c81SbellardSunOS)
477ec530c81Sbellard  solaris="yes"
4780db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4790db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
480fa58948dSBlue Swirl  ld="gld"
481e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
4820475a5caSths  needs_libsunmath="no"
483c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
484c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4850475a5caSths    if test "$solarisrev" -le 9 ; then
4860475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4870475a5caSths        needs_libsunmath="yes"
488f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
489f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
490f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4910475a5caSths      else
4920475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4930475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4940475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4950475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4960475a5caSths        exit 1
4970475a5caSths      fi
4980475a5caSths    fi
49986b2bd93Sths  fi
5006b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
5010c58ac1cSmalc    audio_drv_list="oss"
5026b4d2ba1Sths  fi
503c2de5c91Smalc  audio_possible_drivers="oss sdl"
504d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
505d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
506d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
507d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
508a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
509560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
510560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
511560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
512ec530c81Sbellard;;
513b29fe3edSmalcAIX)
514b29fe3edSmalc  aix="yes"
5150db4a067SPaolo Bonzini  make="${MAKE-gmake}"
516b29fe3edSmalc;;
517179cf400SAndreas FärberHaiku)
518179cf400SAndreas Färber  haiku="yes"
519179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
520179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
521179cf400SAndreas Färber;;
522fb065187Sbellard*)
5230c58ac1cSmalc  audio_drv_list="oss"
524b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5255327cf48Sbellard  linux="yes"
526831b7825Sths  linux_user="yes"
52768063649Sblueswir1  usb="linux"
528af2be207SJan Kiszka  kvm="yes"
529af2be207SJan Kiszka  vhost_net="yes"
53007f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
531c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
532c9ec1fe4Sbellard  fi
533fb065187Sbellard;;
5347d13299dSbellardesac
5357d13299dSbellard
5367d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
537b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
53868063649Sblueswir1    usb="bsd"
53984778508Sblueswir1    bsd_user="yes"
5407d3505c5Sbellard  fi
54108de3949SAndreas Färberfi
5427d3505c5Sbellard
5430db4a067SPaolo Bonzini: ${make=${MAKE-make}}
5440db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
545c886edfbSBlue Swirl: ${python=${PYTHON-python}}
546e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
5470db4a067SPaolo Bonzini
5483c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
5493c4a4d0dSPeter Maydellif has clang; then
5503c4a4d0dSPeter Maydell  objcc=clang
5513c4a4d0dSPeter Maydellelse
5523c4a4d0dSPeter Maydell  objcc="$cc"
5533c4a4d0dSPeter Maydellfi
5543c4a4d0dSPeter Maydell
5553457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
5563457a3f8SJuan Quintela  EXESUF=".exe"
557a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
558e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
559e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
560f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
561f7cf5d5bSStefan Weilcat > $TMPC << EOF
562f7cf5d5bSStefan Weilint main(void) { return 0; }
563f7cf5d5bSStefan WeilEOF
564f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
565f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
566f7cf5d5bSStefan Weil  fi
567c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
568683035deSPaolo Bonzini  mandir="\${prefix}"
569528ae5b8SEduardo Habkost  datadir="\${prefix}"
570850da188SEduardo Habkost  qemu_docdir="\${prefix}"
571683035deSPaolo Bonzini  bindir="\${prefix}"
572683035deSPaolo Bonzini  sysconfdir="\${prefix}"
573683035deSPaolo Bonzini  confsuffix=""
574368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
5753457a3f8SJuan Quintelafi
5763457a3f8SJuan Quintela
577487fefdbSAnthony Liguoriwerror=""
57885aa5189Sbellard
5797d13299dSbellardfor opt do
580a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
5817d13299dSbellard  case "$opt" in
5822efc3265Sbellard  --help|-h) show_help=yes
5832efc3265Sbellard  ;;
58499123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
58599123e13SMike Frysinger  ;;
586b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5877d13299dSbellard  ;;
588b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
58932ce6337Sbellard  ;;
590ca4deeb1SPaolo Bonzini  --source-path=*)
5917d13299dSbellard  ;;
592ac0df51dSaliguori  --cross-prefix=*)
5937d13299dSbellard  ;;
594ac0df51dSaliguori  --cc=*)
5957d13299dSbellard  ;;
596b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
59783469015Sbellard  ;;
5983c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
5993c4a4d0dSPeter Maydell  ;;
600b1a550a0Spbrook  --make=*) make="$optarg"
6017d13299dSbellard  ;;
6026a882643Spbrook  --install=*) install="$optarg"
6036a882643Spbrook  ;;
604c886edfbSBlue Swirl  --python=*) python="$optarg"
605c886edfbSBlue Swirl  ;;
606e2d8830eSBrad  --smbd=*) smbd="$optarg"
607e2d8830eSBrad  ;;
608e2a2ed06SJuan Quintela  --extra-cflags=*)
6097d13299dSbellard  ;;
610e2a2ed06SJuan Quintela  --extra-ldflags=*)
6117d13299dSbellard  ;;
6125bc62e01SGerd Hoffmann  --enable-debug-info)
6135bc62e01SGerd Hoffmann  ;;
6145bc62e01SGerd Hoffmann  --disable-debug-info)
6155bc62e01SGerd Hoffmann  ;;
6162ff6b91eSJuan Quintela  --cpu=*)
6177d13299dSbellard  ;;
618b1a550a0Spbrook  --target-list=*) target_list="$optarg"
619de83cd02Sbellard  ;;
62074242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
62194a420b1SStefan Hajnoczi  ;;
62274242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6239410b56cSPrerna Saxena  ;;
6247d13299dSbellard  --enable-gprof) gprof="yes"
6257d13299dSbellard  ;;
62679427693SLoïc Minier  --static)
62779427693SLoïc Minier    static="yes"
62879427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
62917884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
63043ce4dfeSbellard  ;;
6310b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6320b24e75fSPaolo Bonzini  ;;
6330b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
6340b24e75fSPaolo Bonzini  ;;
6353aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
6363aa5d2beSAlon Levy  ;;
6378bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
6388bf188aaSMichael Tokarev  ;;
6390f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
6400f94d6daSAlon Levy  ;;
641528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
6420b24e75fSPaolo Bonzini  ;;
643023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
644023d3d67SEduardo Habkost  ;;
645850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
6460b24e75fSPaolo Bonzini  ;;
647ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
64807381cc1SAnthony Liguori  ;;
6498bf188aaSMichael Tokarev  --sbindir=*|--sharedstatedir=*|--localstatedir=*|\
650023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
651023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
652023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
653023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
654023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
655023ddd74SMax Filippov    # lots of directory switches by default.
656023ddd74SMax Filippov  ;;
65797a847bcSbellard  --disable-sdl) sdl="no"
65897a847bcSbellard  ;;
659c4198157SJuan Quintela  --enable-sdl) sdl="yes"
660c4198157SJuan Quintela  ;;
661983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
662983eef5aSMeador Inge  ;;
663983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
664983eef5aSMeador Inge  ;;
665821601eaSJes Sorensen  --disable-vnc) vnc="no"
666821601eaSJes Sorensen  ;;
667821601eaSJes Sorensen  --enable-vnc) vnc="yes"
668821601eaSJes Sorensen  ;;
669b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
670102a52e4Sbellard  ;;
671c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
672c2de5c91Smalc  ;;
6732f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
6742f6a1ab0Sblueswir1  ;;
6752fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
6760c58ac1cSmalc  ;;
6770c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
6780c58ac1cSmalc  ;;
679eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
680eb852011SMarkus Armbruster  ;;
681f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
682f8393946Saurel32  ;;
683f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
684f8393946Saurel32  ;;
685f3d08ee6SPaul Brook  --enable-debug)
686f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
687f3d08ee6SPaul Brook      debug_tcg="yes"
688f3d08ee6SPaul Brook      debug="yes"
689f3d08ee6SPaul Brook      strip_opt="no"
690f3d08ee6SPaul Brook  ;;
69103b4fe7dSaliguori  --enable-sparse) sparse="yes"
69203b4fe7dSaliguori  ;;
69303b4fe7dSaliguori  --disable-sparse) sparse="no"
69403b4fe7dSaliguori  ;;
6951625af87Saliguori  --disable-strip) strip_opt="no"
6961625af87Saliguori  ;;
6978d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
6988d5d2d4cSths  ;;
6991be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
7001be10ad2SJuan Quintela  ;;
7012f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
7022f9606b3Saliguori  ;;
703ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
704ea784e3bSJuan Quintela  ;;
7052f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
7062f6f5c7aSCorentin Chary  ;;
7072f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
7082f6f5c7aSCorentin Chary  ;;
709efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
710efe556adSCorentin Chary  ;;
711efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
712efe556adSCorentin Chary  ;;
713443f1376Sbellard  --disable-slirp) slirp="no"
714c20709aaSbellard  ;;
715ee682d27SStefan Weil  --disable-uuid) uuid="no"
716ee682d27SStefan Weil  ;;
717ee682d27SStefan Weil  --enable-uuid) uuid="yes"
718ee682d27SStefan Weil  ;;
719e0e6c8c0Saliguori  --disable-vde) vde="no"
7208a16d273Sths  ;;
721dfb278bdSJuan Quintela  --enable-vde) vde="yes"
722dfb278bdSJuan Quintela  ;;
723e37630caSaliguori  --disable-xen) xen="no"
724e37630caSaliguori  ;;
725fc321b4bSJuan Quintela  --enable-xen) xen="yes"
726fc321b4bSJuan Quintela  ;;
727eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
728eb6fda0fSAnthony PERARD  ;;
729eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
730eb6fda0fSAnthony PERARD  ;;
7312e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
7322e4d9fb1Saurel32  ;;
7334ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
7344ffcedb6SJuan Quintela  ;;
735fb599c9aSbalrog  --disable-bluez) bluez="no"
736fb599c9aSbalrog  ;;
737a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
738a20a6f46SJuan Quintela  ;;
7397ba1e619Saliguori  --disable-kvm) kvm="no"
7407ba1e619Saliguori  ;;
741b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
742b31a0277SJuan Quintela  ;;
7439195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
7449195b2c2SStefan Weil  ;;
7459195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
7469195b2c2SStefan Weil  ;;
74747e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
74847e98658SCorey Bryant  ;;
74947e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
75047e98658SCorey Bryant  ;;
751cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
752cd4ec0b4SGerd Hoffmann  ;;
753cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
754cd4ec0b4SGerd Hoffmann  ;;
755c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
756c589b249SRonnie Sahlberg  ;;
757c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
758c589b249SRonnie Sahlberg  ;;
75905c2a3e7Sbellard  --enable-profiler) profiler="yes"
76005c2a3e7Sbellard  ;;
76114821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
76214821030SPavel Borzenkov  ;;
763c2de5c91Smalc  --enable-cocoa)
764c2de5c91Smalc      cocoa="yes" ;
765c2de5c91Smalc      sdl="no" ;
766c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
7675b0753e0Sbellard  ;;
768cad25d69Spbrook  --disable-system) softmmu="no"
7690a8e90f4Spbrook  ;;
770cad25d69Spbrook  --enable-system) softmmu="yes"
7710a8e90f4Spbrook  ;;
7720953a80fSZachary Amsden  --disable-user)
7730953a80fSZachary Amsden      linux_user="no" ;
7740953a80fSZachary Amsden      bsd_user="no" ;
7750953a80fSZachary Amsden  ;;
7760953a80fSZachary Amsden  --enable-user) ;;
777831b7825Sths  --disable-linux-user) linux_user="no"
7780a8e90f4Spbrook  ;;
779831b7825Sths  --enable-linux-user) linux_user="yes"
780831b7825Sths  ;;
78184778508Sblueswir1  --disable-bsd-user) bsd_user="no"
78284778508Sblueswir1  ;;
78384778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
78484778508Sblueswir1  ;;
785379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
786379f6698SPaul Brook  ;;
787379f6698SPaul Brook  --disable-guest-base) guest_base="no"
788379f6698SPaul Brook  ;;
78940d6444eSAvi Kivity  --enable-pie) pie="yes"
79034005a00SKirill A. Shutemov  ;;
79140d6444eSAvi Kivity  --disable-pie) pie="no"
79234005a00SKirill A. Shutemov  ;;
793c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
794c5937220Spbrook  ;;
7953142255cSblueswir1  --sparc_cpu=*)
7963142255cSblueswir1  ;;
79785aa5189Sbellard  --enable-werror) werror="yes"
79885aa5189Sbellard  ;;
79985aa5189Sbellard  --disable-werror) werror="no"
80085aa5189Sbellard  ;;
8014d3b6f6eSbalrog  --disable-curses) curses="no"
8024d3b6f6eSbalrog  ;;
803c584a6d0SJuan Quintela  --enable-curses) curses="yes"
804c584a6d0SJuan Quintela  ;;
805769ce76dSAlexander Graf  --disable-curl) curl="no"
806769ce76dSAlexander Graf  ;;
807788c8196SJuan Quintela  --enable-curl) curl="yes"
808788c8196SJuan Quintela  ;;
8092df87df7SJuan Quintela  --disable-fdt) fdt="no"
8102df87df7SJuan Quintela  ;;
8112df87df7SJuan Quintela  --enable-fdt) fdt="yes"
8122df87df7SJuan Quintela  ;;
813bd0c5661Spbrook  --disable-nptl) nptl="no"
814bd0c5661Spbrook  ;;
815b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
816b0a47e79SJuan Quintela  ;;
8178ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
8188ff9cbf7Smalc  ;;
8195c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
8205c6c3a6cSChristoph Hellwig  ;;
8215c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
8225c6c3a6cSChristoph Hellwig  ;;
823758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
824758e8e38SVenkateswararao Jujjuri (JV)  ;;
825758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
826758e8e38SVenkateswararao Jujjuri (JV)  ;;
82777755340Sths  --disable-blobs) blobs="no"
82877755340Sths  ;;
8294a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
8304a19f1ecSpbrook  ;;
831519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
832519175a2SAlex Barcelo  ;;
833a25dba17SJuan Quintela  --disable-docs) docs="no"
83470ec5dc0SAnthony Liguori  ;;
835a25dba17SJuan Quintela  --enable-docs) docs="yes"
83683a3ab8bSJuan Quintela  ;;
837d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
838d5970055SMichael S. Tsirkin  ;;
839d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
840d5970055SMichael S. Tsirkin  ;;
84120ff075bSMichael Walle  --disable-opengl) opengl="no"
84220ff075bSMichael Walle  ;;
84320ff075bSMichael Walle  --enable-opengl) opengl="yes"
84420ff075bSMichael Walle  ;;
845f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
846f27aaf4bSChristian Brunner  ;;
847f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
848f27aaf4bSChristian Brunner  ;;
8498c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
8508c84cf11SSergei Trofimovich  ;;
8518c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
8528c84cf11SSergei Trofimovich  ;;
85336707144SAlon Levy  --disable-smartcard) smartcard="no"
85436707144SAlon Levy  ;;
85536707144SAlon Levy  --enable-smartcard) smartcard="yes"
85636707144SAlon Levy  ;;
857111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
858111a38b0SRobert Relyea  ;;
859111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
860111a38b0SRobert Relyea  ;;
86169354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
86269354a83SHans de Goede  ;;
86369354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
86469354a83SHans de Goede  ;;
8651ece9905SAlon Levy  --disable-zlib-test) zlib="no"
8661ece9905SAlon Levy  ;;
867d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
868d138cee9SMichael Roth  ;;
869d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
870d138cee9SMichael Roth  ;;
871f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
872f794573eSEduardo Otubo  ;;
873f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
874f794573eSEduardo Otubo  ;;
8757f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
8767f1559c6Sbalrog  ;;
8777d13299dSbellard  esac
8787d13299dSbellarddone
8797d13299dSbellard
8803142255cSblueswir1#
8813142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
882a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
8833142255cSblueswir1#
884379f6698SPaul Brookhost_guest_base="no"
88540293e58Sbellardcase "$cpu" in
886ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
887ed968ff1SJuan Quintela           v7|v8)
888a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
889ed968ff1SJuan Quintela           ;;
890ed968ff1SJuan Quintela           v8plus|v8plusa)
891a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
892ed968ff1SJuan Quintela           ;;
893ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
894a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
895ed968ff1SJuan Quintela           esac
8960c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
897a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
898762e8230Sblueswir1           if test "$solaris" = "no" ; then
899a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
900c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
901762e8230Sblueswir1           fi
9023142255cSblueswir1           ;;
903ed968ff1SJuan Quintela    sparc64)
904a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
9050c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
906a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
907ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
908a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
909762e8230Sblueswir1           fi
9103142255cSblueswir1           ;;
91176d83bdeSths    s390)
91228d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
91328d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
91448bb3750SRichard Henderson           host_guest_base="yes"
91528d7cc49SRichard Henderson           ;;
91628d7cc49SRichard Henderson    s390x)
91728d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
91828d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
91948bb3750SRichard Henderson           host_guest_base="yes"
92076d83bdeSths           ;;
92140293e58Sbellard    i386)
922a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
9230c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
9242b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
925c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
926379f6698SPaul Brook           host_guest_base="yes"
92740293e58Sbellard           ;;
92840293e58Sbellard    x86_64)
929a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
9300c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
9312b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
932379f6698SPaul Brook           host_guest_base="yes"
933379f6698SPaul Brook           ;;
934379f6698SPaul Brook    arm*)
935379f6698SPaul Brook           host_guest_base="yes"
93640293e58Sbellard           ;;
937f6548c0aSmalc    ppc*)
938f6548c0aSmalc           host_guest_base="yes"
939f6548c0aSmalc           ;;
940cc01cc8eSAurelien Jarno    mips*)
941cc01cc8eSAurelien Jarno           host_guest_base="yes"
942cc01cc8eSAurelien Jarno           ;;
943477ba620SAurelien Jarno    ia64*)
944477ba620SAurelien Jarno           host_guest_base="yes"
945477ba620SAurelien Jarno           ;;
946fd76e73aSRichard Henderson    hppa*)
947fd76e73aSRichard Henderson           host_guest_base="yes"
948fd76e73aSRichard Henderson           ;;
949d2fbca94SGuan Xuetao    unicore32*)
950d2fbca94SGuan Xuetao           host_guest_base="yes"
951d2fbca94SGuan Xuetao           ;;
9523142255cSblueswir1esac
9533142255cSblueswir1
954379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
955379f6698SPaul Brook
95660e0df25SPeter Maydell
95760e0df25SPeter Maydelldefault_target_list=""
95860e0df25SPeter Maydell
95960e0df25SPeter Maydell# these targets are portable
96060e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
96160e0df25SPeter Maydell    default_target_list="\
96260e0df25SPeter Maydelli386-softmmu \
96360e0df25SPeter Maydellx86_64-softmmu \
96427cdad67SRichard Hendersonalpha-softmmu \
96560e0df25SPeter Maydellarm-softmmu \
96660e0df25SPeter Maydellcris-softmmu \
96760e0df25SPeter Maydelllm32-softmmu \
96860e0df25SPeter Maydellm68k-softmmu \
96960e0df25SPeter Maydellmicroblaze-softmmu \
97060e0df25SPeter Maydellmicroblazeel-softmmu \
97160e0df25SPeter Maydellmips-softmmu \
97260e0df25SPeter Maydellmipsel-softmmu \
97360e0df25SPeter Maydellmips64-softmmu \
97460e0df25SPeter Maydellmips64el-softmmu \
975e67db06eSJia Liuor32-softmmu \
97660e0df25SPeter Maydellppc-softmmu \
97760e0df25SPeter Maydellppcemb-softmmu \
97860e0df25SPeter Maydellppc64-softmmu \
97960e0df25SPeter Maydellsh4-softmmu \
98060e0df25SPeter Maydellsh4eb-softmmu \
98160e0df25SPeter Maydellsparc-softmmu \
98260e0df25SPeter Maydellsparc64-softmmu \
9830f3301d4SAlexander Grafs390x-softmmu \
984cfa550c6SMax Filippovxtensa-softmmu \
985cfa550c6SMax Filippovxtensaeb-softmmu \
9864f23a1e6SGuan Xuetaounicore32-softmmu \
98760e0df25SPeter Maydell"
98860e0df25SPeter Maydellfi
98960e0df25SPeter Maydell# the following are Linux specific
99060e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
99160e0df25SPeter Maydell    default_target_list="${default_target_list}\
99260e0df25SPeter Maydelli386-linux-user \
99360e0df25SPeter Maydellx86_64-linux-user \
99460e0df25SPeter Maydellalpha-linux-user \
99560e0df25SPeter Maydellarm-linux-user \
99660e0df25SPeter Maydellarmeb-linux-user \
99760e0df25SPeter Maydellcris-linux-user \
99860e0df25SPeter Maydellm68k-linux-user \
99960e0df25SPeter Maydellmicroblaze-linux-user \
100060e0df25SPeter Maydellmicroblazeel-linux-user \
100160e0df25SPeter Maydellmips-linux-user \
100260e0df25SPeter Maydellmipsel-linux-user \
1003d962783eSJia Liuor32-linux-user \
100460e0df25SPeter Maydellppc-linux-user \
100560e0df25SPeter Maydellppc64-linux-user \
100660e0df25SPeter Maydellppc64abi32-linux-user \
100760e0df25SPeter Maydellsh4-linux-user \
100860e0df25SPeter Maydellsh4eb-linux-user \
100960e0df25SPeter Maydellsparc-linux-user \
101060e0df25SPeter Maydellsparc64-linux-user \
101160e0df25SPeter Maydellsparc32plus-linux-user \
101260e0df25SPeter Maydellunicore32-linux-user \
10130f3301d4SAlexander Grafs390x-linux-user \
101460e0df25SPeter Maydell"
101560e0df25SPeter Maydellfi
101660e0df25SPeter Maydell# the following are BSD specific
101760e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
101860e0df25SPeter Maydell    default_target_list="${default_target_list}\
101960e0df25SPeter Maydelli386-bsd-user \
102060e0df25SPeter Maydellx86_64-bsd-user \
102160e0df25SPeter Maydellsparc-bsd-user \
102260e0df25SPeter Maydellsparc64-bsd-user \
102360e0df25SPeter Maydell"
102460e0df25SPeter Maydellfi
102560e0df25SPeter Maydell
1026af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1027af5db58eSpbrookcat << EOF
1028af5db58eSpbrook
1029af5db58eSpbrookUsage: configure [options]
1030af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1031af5db58eSpbrook
1032af5db58eSpbrookEOF
1033af5db58eSpbrookecho "Standard options:"
1034af5db58eSpbrookecho "  --help                   print this message"
1035af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
1036af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
1037af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
103860e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
103960e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
104060e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
1041af5db58eSpbrookecho ""
1042af5db58eSpbrookecho "Advanced options (experts only):"
1043af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
1044af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
1045af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
10460bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
10470bfe8cc0SPaolo Bonziniecho "                           build time"
10483c4a4d0dSPeter Maydellecho "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
1049a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
1050e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
1051af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
10526a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
1053c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
1054e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
1055af5db58eSpbrookecho "  --static                 enable static build [$static]"
10560b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
1057023d3d67SEduardo Habkostecho "  --datadir=PATH           install firmware in PATH$confsuffix"
1058023d3d67SEduardo Habkostecho "  --docdir=PATH            install documentation in PATH$confsuffix"
10590b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
1060023d3d67SEduardo Habkostecho "  --sysconfdir=PATH        install config in PATH$confsuffix"
10612ae4748fSStefan Weilecho "  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1062f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
1063f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
106409695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
1065890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
1066890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
10671625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
106885aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
1069fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
1070c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
1071983eef5aSMeador Ingeecho "  --disable-virtfs         disable VirtFS"
1072983eef5aSMeador Ingeecho "  --enable-virtfs          enable VirtFS"
1073821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
1074821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
107514821030SPavel Borzenkovecho "  --disable-cocoa          disable Cocoa (Mac OS X only)"
107614821030SPavel Borzenkovecho "  --enable-cocoa           enable Cocoa (default on Mac OS X)"
1077c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
1078c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
10794c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
10804c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
1081eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
1082eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
10838ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
1084e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
1085fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
1086eb6fda0fSAnthony PERARDecho "  --disable-xen-pci-passthrough"
1087eb6fda0fSAnthony PERARDecho "  --enable-xen-pci-passthrough"
10882e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
10894ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
10908d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
10911be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
10922f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1093ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
10942f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
10952f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
109696763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1097efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
1098af896aaaSpbrookecho "  --disable-curses         disable curses output"
1099c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1100769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1101788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
11022df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
11032df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
1104fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1105a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
11066093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
11077ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1108b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
11099195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1110bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
1111e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
1112af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1113af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
11140953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
11150953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1116831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1117831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
111884778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
111984778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1120379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1121379f6698SPaul Brookecho "                           emulation targets"
1122379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
112340d6444eSAvi Kivityecho "  --enable-pie             build Position Independent Executables"
112440d6444eSAvi Kivityecho "  --disable-pie            do not build Position Independent Executables"
1125af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1126af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
11272f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1128c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1129235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
11303142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
1131ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1132ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1133e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1134dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
11355c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
11365c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
113747e98658SCorey Bryantecho "  --disable-cap-ng         disable libcap-ng support"
113847e98658SCorey Bryantecho "  --enable-cap-ng          enable libcap-ng support"
1139758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1140758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
114177755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1142d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1143d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1144d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1145d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1146320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1147650ab98dSLluís Vilanovaecho "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
114874242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
11499410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1150cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1151cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1152f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1153c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1154c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
115536707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
115636707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1157111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1158111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
115969354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
116069354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1161d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1162d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1163f794573eSEduardo Otuboecho "  --disable-seccomp        disable seccomp support"
1164f794573eSEduardo Otuboecho "  --enable-seccomp         enables seccomp support"
1165519175a2SAlex Barceloecho "  --with-coroutine=BACKEND coroutine backend. Supported options:"
1166fe91bfa8SAlex Barceloecho "                           gthread, ucontext, sigaltstack, windows"
1167af5db58eSpbrookecho ""
11685bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1169af5db58eSpbrookexit 1
1170af5db58eSpbrookfi
1171af5db58eSpbrook
1172359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1173359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1174359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1175359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1176359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1177359bc95dSPeter Maydell        ARCH=tci
1178359bc95dSPeter Maydell    else
1179359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1180359bc95dSPeter Maydell        exit 1
1181359bc95dSPeter Maydell    fi
1182359bc95dSPeter Maydellfi
1183359bc95dSPeter Maydell
11848d05095cSPaolo Bonzini# check that the C compiler works.
11858d05095cSPaolo Bonzinicat > $TMPC <<EOF
118675cafad7SStefan Weilint main(void) { return 0; }
11878d05095cSPaolo BonziniEOF
11888d05095cSPaolo Bonzini
11898d05095cSPaolo Bonziniif compile_object ; then
11908d05095cSPaolo Bonzini  : C compiler works ok
11918d05095cSPaolo Bonzinielse
11928d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
11938d05095cSPaolo Bonzini    exit 1
11948d05095cSPaolo Bonzinifi
11958d05095cSPaolo Bonzini
1196417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1197417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1198417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1199417c9d72SAlexander Graf
1200417c9d72SAlexander Grafif test -z "$werror" ; then
1201417c9d72SAlexander Graf    if test "$z_version" = "50" -a \
1202417c9d72SAlexander Graf        "$linux" = "yes" ; then
1203417c9d72SAlexander Graf        werror="yes"
1204417c9d72SAlexander Graf    else
1205417c9d72SAlexander Graf        werror="no"
1206417c9d72SAlexander Graf    fi
1207417c9d72SAlexander Graffi
1208417c9d72SAlexander Graf
12098d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
12108d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
12118d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1212f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
12136ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
12146ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
12156ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
12166ca026cbSPeter Maydell# so it's too error prone.
12178d05095cSPaolo Bonzinicat > $TMPC << EOF
12188d05095cSPaolo Bonziniint main(void) { return 0; }
12198d05095cSPaolo BonziniEOF
12208d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1221bd947d30SStefan Weil    if compile_prog "-Werror $flag" "" ; then
12228d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
12238d05095cSPaolo Bonzini    fi
12248d05095cSPaolo Bonzinidone
12258d05095cSPaolo Bonzini
122640d6444eSAvi Kivityif test "$static" = "yes" ; then
122740d6444eSAvi Kivity  if test "$pie" = "yes" ; then
122840d6444eSAvi Kivity    echo "static and pie are mutually incompatible"
122940d6444eSAvi Kivity    exit 1
123040d6444eSAvi Kivity  else
123140d6444eSAvi Kivity    pie="no"
123240d6444eSAvi Kivity  fi
123340d6444eSAvi Kivityfi
123440d6444eSAvi Kivity
123540d6444eSAvi Kivityif test "$pie" = ""; then
123640d6444eSAvi Kivity  case "$cpu-$targetos" in
1237f9db31a2SBrad    i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD)
123840d6444eSAvi Kivity      ;;
123940d6444eSAvi Kivity    *)
124040d6444eSAvi Kivity      pie="no"
124140d6444eSAvi Kivity      ;;
124240d6444eSAvi Kivity  esac
124340d6444eSAvi Kivityfi
124440d6444eSAvi Kivity
124540d6444eSAvi Kivityif test "$pie" != "no" ; then
124640d6444eSAvi Kivity  cat > $TMPC << EOF
124721d4a791SAvi Kivity
124821d4a791SAvi Kivity#ifdef __linux__
124921d4a791SAvi Kivity#  define THREAD __thread
125021d4a791SAvi Kivity#else
125121d4a791SAvi Kivity#  define THREAD
125221d4a791SAvi Kivity#endif
125321d4a791SAvi Kivity
125421d4a791SAvi Kivitystatic THREAD int tls_var;
125521d4a791SAvi Kivity
125621d4a791SAvi Kivityint main(void) { return tls_var; }
125721d4a791SAvi Kivity
125840d6444eSAvi KivityEOF
125940d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
126040d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
126140d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
126240d6444eSAvi Kivity    pie="yes"
126340d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
126440d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
126540d6444eSAvi Kivity    fi
126640d6444eSAvi Kivity  else
126740d6444eSAvi Kivity    if test "$pie" = "yes"; then
126840d6444eSAvi Kivity      echo "PIE not available due to missing toolchain support"
126940d6444eSAvi Kivity      exit 1
127040d6444eSAvi Kivity    else
127140d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
127240d6444eSAvi Kivity      pie="no"
127340d6444eSAvi Kivity    fi
127440d6444eSAvi Kivity  fi
127540d6444eSAvi Kivityfi
127640d6444eSAvi Kivity
1277ec530c81Sbellard#
1278ec530c81Sbellard# Solaris specific configure tool chain decisions
1279ec530c81Sbellard#
1280ec530c81Sbellardif test "$solaris" = "yes" ; then
12816792aa11SLoïc Minier  if has $install; then
12826792aa11SLoïc Minier    :
12836792aa11SLoïc Minier  else
1284ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1285ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1286ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1287ec530c81Sbellard    exit 1
1288ec530c81Sbellard  fi
12896792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1290ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1291ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1292ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1293ec530c81Sbellard    exit 1
1294ec530c81Sbellard  fi
12956792aa11SLoïc Minier  if has ar; then
12966792aa11SLoïc Minier    :
12976792aa11SLoïc Minier  else
1298ec530c81Sbellard    echo "Error: No path includes ar"
1299ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1300ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1301ec530c81Sbellard    fi
1302ec530c81Sbellard    exit 1
1303ec530c81Sbellard  fi
1304ec530c81Sbellardfi
1305ec530c81Sbellard
13067a3fc891SSebastian Herbsztif ! has $python; then
1307c886edfbSBlue Swirl  echo "Python not found. Use --python=/path/to/python"
1308c886edfbSBlue Swirl  exit 1
1309c886edfbSBlue Swirlfi
1310c886edfbSBlue Swirl
13116ccea1e4SPeter Maydell# Note that if the Python conditional here evaluates True we will exit
13126ccea1e4SPeter Maydell# with status 1 which is a shell 'false' value.
1313e120d449SStefan Hajnocziif ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1314e120d449SStefan Hajnoczi  echo "Cannot use '$python', Python 2.4 or later is required."
1315e120d449SStefan Hajnoczi  echo "Note that Python 3 or later is not yet supported."
1316e120d449SStefan Hajnoczi  echo "Use --python=/path/to/python to specify a supported Python."
13176ccea1e4SPeter Maydell  exit 1
13186ccea1e4SPeter Maydellfi
13196ccea1e4SPeter Maydell
1320*66d5499bSDaniel P. Berrangeif test "$target_list" = "DEFAULT" ; then
1321*66d5499bSDaniel P. Berrange    target_list=`echo "$default_target_list" | sed -e 's/,/ /g'`
13225327cf48Sbellardfi
1323*66d5499bSDaniel P. Berrange
1324f55fe278SPaolo Bonzini# see if system emulation was really requested
1325f55fe278SPaolo Bonzinicase " $target_list " in
1326f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1327f55fe278SPaolo Bonzini  ;;
1328f55fe278SPaolo Bonzini  *) softmmu=no
1329f55fe278SPaolo Bonzini  ;;
1330f55fe278SPaolo Bonziniesac
13315327cf48Sbellard
1332249247c9SJuan Quintelafeature_not_found() {
1333249247c9SJuan Quintela  feature=$1
1334249247c9SJuan Quintela
1335249247c9SJuan Quintela  echo "ERROR"
1336249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
13379332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1338249247c9SJuan Quintela  echo "ERROR"
1339249247c9SJuan Quintela  exit 1;
1340249247c9SJuan Quintela}
1341249247c9SJuan Quintela
13427d13299dSbellardif test -z "$cross_prefix" ; then
13437d13299dSbellard
13447d13299dSbellard# ---
13457d13299dSbellard# big/little endian test
13467d13299dSbellardcat > $TMPC << EOF
13477d13299dSbellard#include <inttypes.h>
13487d13299dSbellardint main(int argc, char ** argv){
13497d13299dSbellard        volatile uint32_t i=0x01234567;
13507d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
13517d13299dSbellard}
13527d13299dSbellardEOF
13537d13299dSbellard
135452166aa0SJuan Quintelaif compile_prog "" "" ; then
13557d13299dSbellard$TMPE && bigendian="yes"
13567d13299dSbellardelse
13577d13299dSbellardecho big/little test failed
13587d13299dSbellardfi
13597d13299dSbellard
13607d13299dSbellardelse
13617d13299dSbellard
13627d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1363ea8f20f8SJuan Quintelacase "$cpu" in
136421d89f84SPeter Maydell  arm)
136521d89f84SPeter Maydell    # ARM can be either way; ask the compiler which one we are
136621d89f84SPeter Maydell    if check_define __ARMEB__; then
136721d89f84SPeter Maydell      bigendian=yes
136821d89f84SPeter Maydell    fi
136921d89f84SPeter Maydell  ;;
137021d89f84SPeter Maydell  hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1371ea8f20f8SJuan Quintela    bigendian=yes
1372ea8f20f8SJuan Quintela  ;;
1373ea8f20f8SJuan Quintelaesac
13747d13299dSbellard
13757d13299dSbellardfi
13767d13299dSbellard
1377b0a47e79SJuan Quintela##########################################
1378b0a47e79SJuan Quintela# NPTL probe
1379b0a47e79SJuan Quintela
1380b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1381bd0c5661Spbrook  cat > $TMPC <<EOF
1382bd0c5661Spbrook#include <sched.h>
138330813ceaSpbrook#include <linux/futex.h>
1384182eacc0SStefan Weilint main(void) {
1385bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1386bd0c5661Spbrook#error bork
1387bd0c5661Spbrook#endif
1388182eacc0SStefan Weil  return 0;
1389bd0c5661Spbrook}
1390bd0c5661SpbrookEOF
1391bd0c5661Spbrook
139252166aa0SJuan Quintela  if compile_object ; then
1393b0a47e79SJuan Quintela    nptl=yes
1394bd0c5661Spbrook  else
1395b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1396b0a47e79SJuan Quintela      feature_not_found "nptl"
1397b0a47e79SJuan Quintela    fi
1398b0a47e79SJuan Quintela    nptl=no
1399b0a47e79SJuan Quintela  fi
1400bd0c5661Spbrookfi
1401bd0c5661Spbrook
140211d9f695Sbellard##########################################
1403ac62922eSbalrog# zlib check
1404ac62922eSbalrog
14051ece9905SAlon Levyif test "$zlib" != "no" ; then
1406ac62922eSbalrog    cat > $TMPC << EOF
1407ac62922eSbalrog#include <zlib.h>
1408ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1409ac62922eSbalrogEOF
141052166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1411ac62922eSbalrog        :
1412ac62922eSbalrog    else
1413ac62922eSbalrog        echo
1414ac62922eSbalrog        echo "Error: zlib check failed"
1415ac62922eSbalrog        echo "Make sure to have the zlib libs and headers installed."
1416ac62922eSbalrog        echo
1417ac62922eSbalrog        exit 1
1418ac62922eSbalrog    fi
14191ece9905SAlon Levyfi
1420ac62922eSbalrog
1421ac62922eSbalrog##########################################
1422f794573eSEduardo Otubo# libseccomp check
1423f794573eSEduardo Otubo
1424f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
1425f794573eSEduardo Otubo    if $pkg_config libseccomp --modversion >/dev/null 2>&1; then
1426f794573eSEduardo Otubo        LIBS=`$pkg_config --libs libseccomp`
1427f794573eSEduardo Otubo	seccomp="yes"
1428f794573eSEduardo Otubo    else
1429f794573eSEduardo Otubo	seccomp="no"
1430f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
1431f794573eSEduardo Otubo            feature_not_found "libseccomp"
1432f794573eSEduardo Otubo	fi
1433f794573eSEduardo Otubo    fi
1434f794573eSEduardo Otubofi
1435f794573eSEduardo Otubo##########################################
1436e37630caSaliguori# xen probe
1437e37630caSaliguori
1438fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1439b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1440d5b93ddfSAnthony PERARD
144150ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
144250ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
144350ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
144450ced5b3SStefan Weil
144550ced5b3SStefan Weil  # Xen (any)
144650ced5b3SStefan Weil  cat > $TMPC <<EOF
144750ced5b3SStefan Weil#include <xenctrl.h>
144850ced5b3SStefan Weilint main(void) {
144950ced5b3SStefan Weil  return 0;
145050ced5b3SStefan Weil}
145150ced5b3SStefan WeilEOF
145250ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
145350ced5b3SStefan Weil    # Xen not found
145450ced5b3SStefan Weil    if test "$xen" = "yes" ; then
145550ced5b3SStefan Weil      feature_not_found "xen"
145650ced5b3SStefan Weil    fi
145750ced5b3SStefan Weil    xen=no
145850ced5b3SStefan Weil
1459d5b93ddfSAnthony PERARD  # Xen unstable
146069deef08SPeter Maydell  elif
146169deef08SPeter Maydell      cat > $TMPC <<EOF &&
1462e37630caSaliguori#include <xenctrl.h>
1463e108a3c1SAnthony PERARD#include <xenstore.h>
1464d5b93ddfSAnthony PERARD#include <stdint.h>
1465d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1466d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1467d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1468d5b93ddfSAnthony PERARD#endif
1469d5b93ddfSAnthony PERARDint main(void) {
1470d5b93ddfSAnthony PERARD  xc_interface *xc;
1471d5b93ddfSAnthony PERARD  xs_daemon_open();
1472d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1473d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1474d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1475b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
14768688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
14778688e065SStefano Stabellini  return 0;
14788688e065SStefano Stabellini}
14798688e065SStefano StabelliniEOF
14808688e065SStefano Stabellini      compile_prog "" "$xen_libs"
148169deef08SPeter Maydell    then
14828688e065SStefano Stabellini    xen_ctrl_version=420
14838688e065SStefano Stabellini    xen=yes
14848688e065SStefano Stabellini
148569deef08SPeter Maydell  elif
148669deef08SPeter Maydell      cat > $TMPC <<EOF &&
14878688e065SStefano Stabellini#include <xenctrl.h>
14888688e065SStefano Stabellini#include <xs.h>
14898688e065SStefano Stabellini#include <stdint.h>
14908688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
14918688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
14928688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
14938688e065SStefano Stabellini#endif
14948688e065SStefano Stabelliniint main(void) {
14958688e065SStefano Stabellini  xs_daemon_open();
14969b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
14978688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
14988688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
14998688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1500d5b93ddfSAnthony PERARD  return 0;
1501d5b93ddfSAnthony PERARD}
1502e37630caSaliguoriEOF
150350ced5b3SStefan Weil      compile_prog "" "$xen_libs"
150469deef08SPeter Maydell    then
1505d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1506fc321b4bSJuan Quintela    xen=yes
1507d5b93ddfSAnthony PERARD
1508d5b93ddfSAnthony PERARD  # Xen 4.0.0
150969deef08SPeter Maydell  elif
151069deef08SPeter Maydell      cat > $TMPC <<EOF &&
1511d5b93ddfSAnthony PERARD#include <xenctrl.h>
1512d5b93ddfSAnthony PERARD#include <xs.h>
1513d5b93ddfSAnthony PERARD#include <stdint.h>
1514d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1515d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1516d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1517d5b93ddfSAnthony PERARD#endif
1518d5b93ddfSAnthony PERARDint main(void) {
1519b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1520b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1521b87de24eSAnthony PERARD  };
1522d5b93ddfSAnthony PERARD  xs_daemon_open();
1523d5b93ddfSAnthony PERARD  xc_interface_open();
1524d5b93ddfSAnthony PERARD  xc_gnttab_open();
1525d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1526b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1527d5b93ddfSAnthony PERARD  return 0;
1528d5b93ddfSAnthony PERARD}
1529d5b93ddfSAnthony PERARDEOF
1530d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
153169deef08SPeter Maydell    then
1532d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1533d5b93ddfSAnthony PERARD    xen=yes
1534d5b93ddfSAnthony PERARD
1535b87de24eSAnthony PERARD  # Xen 3.4.0
153669deef08SPeter Maydell  elif
153769deef08SPeter Maydell      cat > $TMPC <<EOF &&
1538b87de24eSAnthony PERARD#include <xenctrl.h>
1539b87de24eSAnthony PERARD#include <xs.h>
1540b87de24eSAnthony PERARDint main(void) {
1541b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1542b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1543b87de24eSAnthony PERARD  };
1544b87de24eSAnthony PERARD  xs_daemon_open();
1545b87de24eSAnthony PERARD  xc_interface_open();
1546b87de24eSAnthony PERARD  xc_gnttab_open();
1547b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1548b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1549b87de24eSAnthony PERARD  return 0;
1550b87de24eSAnthony PERARD}
1551b87de24eSAnthony PERARDEOF
1552b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
155369deef08SPeter Maydell    then
1554b87de24eSAnthony PERARD    xen_ctrl_version=340
1555b87de24eSAnthony PERARD    xen=yes
1556b87de24eSAnthony PERARD
1557b87de24eSAnthony PERARD  # Xen 3.3.0
155869deef08SPeter Maydell  elif
155969deef08SPeter Maydell      cat > $TMPC <<EOF &&
1560d5b93ddfSAnthony PERARD#include <xenctrl.h>
1561d5b93ddfSAnthony PERARD#include <xs.h>
1562d5b93ddfSAnthony PERARDint main(void) {
1563d5b93ddfSAnthony PERARD  xs_daemon_open();
1564d5b93ddfSAnthony PERARD  xc_interface_open();
1565d5b93ddfSAnthony PERARD  xc_gnttab_open();
1566d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1567d5b93ddfSAnthony PERARD  return 0;
1568d5b93ddfSAnthony PERARD}
1569d5b93ddfSAnthony PERARDEOF
1570d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
157169deef08SPeter Maydell    then
1572d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1573d5b93ddfSAnthony PERARD    xen=yes
1574d5b93ddfSAnthony PERARD
157550ced5b3SStefan Weil  # Xen version unsupported
1576e37630caSaliguori  else
1577fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
157850ced5b3SStefan Weil      feature_not_found "xen (unsupported version)"
1579fc321b4bSJuan Quintela    fi
1580fc321b4bSJuan Quintela    xen=no
1581e37630caSaliguori  fi
1582d5b93ddfSAnthony PERARD
1583d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1584d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1585d5b93ddfSAnthony PERARD  fi
1586e37630caSaliguorifi
1587e37630caSaliguori
1588eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1589eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1590eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1591eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1592eb6fda0fSAnthony PERARD  else
1593eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1594eb6fda0fSAnthony PERARD      echo "ERROR"
1595eb6fda0fSAnthony PERARD      echo "ERROR: User requested feature Xen PCI Passthrough"
1596eb6fda0fSAnthony PERARD      echo "ERROR: but this feature require /sys from Linux"
1597eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
1598eb6fda0fSAnthony PERARD        echo "ERROR: This feature does not work with Xen 3.3"
1599eb6fda0fSAnthony PERARD      fi
1600eb6fda0fSAnthony PERARD      echo "ERROR"
1601eb6fda0fSAnthony PERARD      exit 1;
1602eb6fda0fSAnthony PERARD    fi
1603eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1604eb6fda0fSAnthony PERARD  fi
1605eb6fda0fSAnthony PERARDfi
1606eb6fda0fSAnthony PERARD
1607e37630caSaliguori##########################################
1608a8bd70adSPaolo Bonzini# pkg-config probe
1609f91672e5SPaolo Bonzini
161017884d7bSSergei Trofimovichif ! has "$pkg_config_exe"; then
161117884d7bSSergei Trofimovich  echo "Error: pkg-config binary '$pkg_config_exe' not found"
1612a213fcb2SPeter Maydell  exit 1
1613f91672e5SPaolo Bonzinifi
1614f91672e5SPaolo Bonzini
1615f91672e5SPaolo Bonzini##########################################
161644dc0ca3SAlon Levy# libtool probe
161744dc0ca3SAlon Levy
16183f534581SBradif ! has $libtool; then
161944dc0ca3SAlon Levy    libtool=
162044dc0ca3SAlon Levyfi
162144dc0ca3SAlon Levy
162244dc0ca3SAlon Levy##########################################
1623dfffc653SJuan Quintela# Sparse probe
1624dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
16250dba6195SLoïc Minier  if has cgcc; then
1626dfffc653SJuan Quintela    sparse=yes
1627dfffc653SJuan Quintela  else
1628dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1629dfffc653SJuan Quintela      feature_not_found "sparse"
1630dfffc653SJuan Quintela    fi
1631dfffc653SJuan Quintela    sparse=no
1632dfffc653SJuan Quintela  fi
1633dfffc653SJuan Quintelafi
1634dfffc653SJuan Quintela
1635dfffc653SJuan Quintela##########################################
163611d9f695Sbellard# SDL probe
163711d9f695Sbellard
16383ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
16393ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
16403ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
16413ec87ffeSPaolo Bonzini  sdl_config=sdl-config
16423ec87ffeSPaolo Bonzinifi
16433ec87ffeSPaolo Bonzini
16443ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1645a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1646fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
16473ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
16483ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
16499316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1650a0dfd8a4SLoïc Minierelse
1651a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1652a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1653a0dfd8a4SLoïc Minier  fi
1654a0dfd8a4SLoïc Minier  sdl=no
16559316f803SPaolo Bonzinifi
165629e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
16573ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
16583ec87ffeSPaolo Bonzinifi
165911d9f695Sbellard
16609316f803SPaolo Bonzinisdl_too_old=no
1661c4198157SJuan Quintelaif test "$sdl" != "no" ; then
166211d9f695Sbellard  cat > $TMPC << EOF
166311d9f695Sbellard#include <SDL.h>
166411d9f695Sbellard#undef main /* We don't want SDL to override our main() */
166511d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
166611d9f695SbellardEOF
16679316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
166874f42e18STeLeMan  if test "$static" = "yes" ; then
166974f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
167074f42e18STeLeMan  else
16719316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
167274f42e18STeLeMan  fi
167352166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
167411d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
167511d9f695Sbellard      sdl_too_old=yes
167611d9f695Sbellard    else
1677fd677642Sths      if test "$cocoa" = "no" ; then
167811d9f695Sbellard        sdl=yes
167911d9f695Sbellard      fi
1680fd677642Sths    fi
16817c1f25b4Sbellard
168267c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
16831ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
168467c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1685f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1686f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
168711d9f695Sbellard      fi
168852166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
16891ac88f28SJuan Quintela	:
16901ac88f28SJuan Quintela      else
16911ac88f28SJuan Quintela        sdl=no
16927c1f25b4Sbellard      fi
16937c1f25b4Sbellard    fi # static link
1694c4198157SJuan Quintela  else # sdl not found
1695c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1696c4198157SJuan Quintela      feature_not_found "sdl"
1697c4198157SJuan Quintela    fi
1698c4198157SJuan Quintela    sdl=no
16997c1f25b4Sbellard  fi # sdl compile test
1700fd677642Sthsfi
170111d9f695Sbellard
17025368a422Saliguoriif test "$sdl" = "yes" ; then
17035368a422Saliguori  cat > $TMPC <<EOF
17045368a422Saliguori#include <SDL.h>
17055368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
17065368a422Saliguori#include <X11/XKBlib.h>
17075368a422Saliguori#else
17085368a422Saliguori#error No x11 support
17095368a422Saliguori#endif
17105368a422Saliguoriint main(void) { return 0; }
17115368a422SaliguoriEOF
171252166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1713681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
17145368a422Saliguori  fi
17150705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
17165368a422Saliguorifi
17175368a422Saliguori
17188f28f3fbSths##########################################
17198d5d2d4cSths# VNC TLS detection
1720821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1721ae6b5e5aSaliguori  cat > $TMPC <<EOF
1722ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1723ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1724ae6b5e5aSaliguoriEOF
1725a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1726a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
172752166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
17281be10ad2SJuan Quintela    vnc_tls=yes
1729a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1730ae6b5e5aSaliguori  else
17311be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
17321be10ad2SJuan Quintela      feature_not_found "vnc-tls"
17331be10ad2SJuan Quintela    fi
17341be10ad2SJuan Quintela    vnc_tls=no
17358d5d2d4cSths  fi
17368d5d2d4cSthsfi
17378d5d2d4cSths
17388d5d2d4cSths##########################################
17392f9606b3Saliguori# VNC SASL detection
1740821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
17412f9606b3Saliguori  cat > $TMPC <<EOF
17422f9606b3Saliguori#include <sasl/sasl.h>
17432f9606b3Saliguori#include <stdio.h>
17442f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
17452f9606b3SaliguoriEOF
17462f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
17472f9606b3Saliguori  vnc_sasl_cflags=""
17482f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
174952166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1750ea784e3bSJuan Quintela    vnc_sasl=yes
1751fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
17522f9606b3Saliguori  else
1753ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1754ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1755ea784e3bSJuan Quintela    fi
1756ea784e3bSJuan Quintela    vnc_sasl=no
17572f9606b3Saliguori  fi
17582f9606b3Saliguorifi
17592f9606b3Saliguori
17602f9606b3Saliguori##########################################
17612f6f5c7aSCorentin Chary# VNC JPEG detection
1762821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
17632f6f5c7aSCorentin Charycat > $TMPC <<EOF
17642f6f5c7aSCorentin Chary#include <stdio.h>
17652f6f5c7aSCorentin Chary#include <jpeglib.h>
17662f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
17672f6f5c7aSCorentin CharyEOF
17682f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
17692f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
17702f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
17712f6f5c7aSCorentin Chary    vnc_jpeg=yes
17722f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
17732f6f5c7aSCorentin Chary  else
17742f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
17752f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
17762f6f5c7aSCorentin Chary    fi
17772f6f5c7aSCorentin Chary    vnc_jpeg=no
17782f6f5c7aSCorentin Chary  fi
17792f6f5c7aSCorentin Charyfi
17802f6f5c7aSCorentin Chary
17812f6f5c7aSCorentin Chary##########################################
1782efe556adSCorentin Chary# VNC PNG detection
1783821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1784efe556adSCorentin Charycat > $TMPC <<EOF
1785efe556adSCorentin Chary//#include <stdio.h>
1786efe556adSCorentin Chary#include <png.h>
1787832ce9c2SScott Wood#include <stddef.h>
1788efe556adSCorentin Charyint main(void) {
1789efe556adSCorentin Chary    png_structp png_ptr;
1790efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
17917edc3fedSPeter Maydell    return png_ptr != 0;
1792efe556adSCorentin Chary}
1793efe556adSCorentin CharyEOF
17949af8025eSBrad  if $pkg_config libpng --modversion >/dev/null 2>&1; then
17959af8025eSBrad    vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
17969af8025eSBrad    vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
17979af8025eSBrad  else
1798efe556adSCorentin Chary    vnc_png_cflags=""
1799efe556adSCorentin Chary    vnc_png_libs="-lpng"
18009af8025eSBrad  fi
1801efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1802efe556adSCorentin Chary    vnc_png=yes
1803efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
18049af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1805efe556adSCorentin Chary  else
1806efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1807efe556adSCorentin Chary      feature_not_found "vnc-png"
1808efe556adSCorentin Chary    fi
1809efe556adSCorentin Chary    vnc_png=no
1810efe556adSCorentin Chary  fi
1811efe556adSCorentin Charyfi
1812efe556adSCorentin Chary
1813efe556adSCorentin Chary##########################################
181476655d6dSaliguori# fnmatch() probe, used for ACL routines
181576655d6dSaliguorifnmatch="no"
181676655d6dSaliguoricat > $TMPC << EOF
181776655d6dSaliguori#include <fnmatch.h>
181876655d6dSaliguoriint main(void)
181976655d6dSaliguori{
182076655d6dSaliguori    fnmatch("foo", "foo", 0);
182176655d6dSaliguori    return 0;
182276655d6dSaliguori}
182376655d6dSaliguoriEOF
182452166aa0SJuan Quintelaif compile_prog "" "" ; then
182576655d6dSaliguori   fnmatch="yes"
182676655d6dSaliguorifi
182776655d6dSaliguori
182876655d6dSaliguori##########################################
1829ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1830ee682d27SStefan Weilif test "$uuid" != "no" ; then
1831ee682d27SStefan Weil  uuid_libs="-luuid"
1832ee682d27SStefan Weil  cat > $TMPC << EOF
1833ee682d27SStefan Weil#include <uuid/uuid.h>
1834ee682d27SStefan Weilint main(void)
1835ee682d27SStefan Weil{
1836ee682d27SStefan Weil    uuid_t my_uuid;
1837ee682d27SStefan Weil    uuid_generate(my_uuid);
1838ee682d27SStefan Weil    return 0;
1839ee682d27SStefan Weil}
1840ee682d27SStefan WeilEOF
1841ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1842ee682d27SStefan Weil    uuid="yes"
1843ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1844ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1845ee682d27SStefan Weil  else
1846ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1847ee682d27SStefan Weil      feature_not_found "uuid"
1848ee682d27SStefan Weil    fi
1849ee682d27SStefan Weil    uuid=no
1850ee682d27SStefan Weil  fi
1851ee682d27SStefan Weilfi
1852ee682d27SStefan Weil
1853ee682d27SStefan Weil##########################################
1854dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1855dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1856dce512deSChristoph Hellwig  cat > $TMPC << EOF
1857ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
1858dce512deSChristoph Hellwig#include <xfs/xfs.h>
1859dce512deSChristoph Hellwigint main(void)
1860dce512deSChristoph Hellwig{
1861dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1862dce512deSChristoph Hellwig    return 0;
1863dce512deSChristoph Hellwig}
1864dce512deSChristoph HellwigEOF
1865dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1866dce512deSChristoph Hellwig    xfs="yes"
1867dce512deSChristoph Hellwig  else
1868dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1869dce512deSChristoph Hellwig      feature_not_found "xfs"
1870dce512deSChristoph Hellwig    fi
1871dce512deSChristoph Hellwig    xfs=no
1872dce512deSChristoph Hellwig  fi
1873dce512deSChristoph Hellwigfi
1874dce512deSChristoph Hellwig
1875dce512deSChristoph Hellwig##########################################
18768a16d273Sths# vde libraries probe
1877dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
18784baae0acSJuan Quintela  vde_libs="-lvdeplug"
18798a16d273Sths  cat > $TMPC << EOF
18808a16d273Sths#include <libvdeplug.h>
18814a7f0e06Spbrookint main(void)
18824a7f0e06Spbrook{
18834a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
1884fea08e08SPeter Maydell    char s[] = "";
1885fea08e08SPeter Maydell    vde_open(s, s, &a);
18864a7f0e06Spbrook    return 0;
18874a7f0e06Spbrook}
18888a16d273SthsEOF
188952166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
18904baae0acSJuan Quintela    vde=yes
18918e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
18928e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1893dfb278bdSJuan Quintela  else
1894dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1895dfb278bdSJuan Quintela      feature_not_found "vde"
1896dfb278bdSJuan Quintela    fi
1897dfb278bdSJuan Quintela    vde=no
18988a16d273Sths  fi
18998a16d273Sthsfi
19008a16d273Sths
19018a16d273Sths##########################################
190247e98658SCorey Bryant# libcap-ng library probe
190347e98658SCorey Bryantif test "$cap_ng" != "no" ; then
190447e98658SCorey Bryant  cap_libs="-lcap-ng"
190547e98658SCorey Bryant  cat > $TMPC << EOF
190647e98658SCorey Bryant#include <cap-ng.h>
190747e98658SCorey Bryantint main(void)
190847e98658SCorey Bryant{
190947e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
191047e98658SCorey Bryant    return 0;
191147e98658SCorey Bryant}
191247e98658SCorey BryantEOF
191347e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
191447e98658SCorey Bryant    cap_ng=yes
191547e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
191647e98658SCorey Bryant  else
191747e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
191847e98658SCorey Bryant      feature_not_found "cap_ng"
191947e98658SCorey Bryant    fi
192047e98658SCorey Bryant    cap_ng=no
192147e98658SCorey Bryant  fi
192247e98658SCorey Bryantfi
192347e98658SCorey Bryant
192447e98658SCorey Bryant##########################################
1925c2de5c91Smalc# Sound support libraries probe
19268f28f3fbSths
1927c2de5c91Smalcaudio_drv_probe()
1928c2de5c91Smalc{
1929c2de5c91Smalc    drv=$1
1930c2de5c91Smalc    hdr=$2
1931c2de5c91Smalc    lib=$3
1932c2de5c91Smalc    exp=$4
1933c2de5c91Smalc    cfl=$5
19348f28f3fbSths        cat > $TMPC << EOF
1935c2de5c91Smalc#include <$hdr>
1936c2de5c91Smalcint main(void) { $exp }
19378f28f3fbSthsEOF
193852166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
19398f28f3fbSths        :
19408f28f3fbSths    else
19418f28f3fbSths        echo
1942c2de5c91Smalc        echo "Error: $drv check failed"
1943c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
19448f28f3fbSths        echo
19458f28f3fbSths        exit 1
19468f28f3fbSths    fi
1947c2de5c91Smalc}
1948c2de5c91Smalc
19492fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1950c2de5c91Smalcfor drv in $audio_drv_list; do
1951c2de5c91Smalc    case $drv in
1952c2de5c91Smalc    alsa)
1953c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1954e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
1955a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1956c2de5c91Smalc    ;;
1957c2de5c91Smalc
1958c2de5c91Smalc    fmod)
1959c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1960c2de5c91Smalc        echo
1961c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1962c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1963c2de5c91Smalc        echo
1964c2de5c91Smalc        exit 1
19658f28f3fbSths    fi
1966c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1967a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1968c2de5c91Smalc    ;;
1969c2de5c91Smalc
1970c2de5c91Smalc    esd)
1971c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1972a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
197367f86e8eSJuan Quintela    audio_pt_int="yes"
1974c2de5c91Smalc    ;;
1975b8e59f18Smalc
1976b8e59f18Smalc    pa)
1977a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
1978a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
1979a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
198067f86e8eSJuan Quintela    audio_pt_int="yes"
1981b8e59f18Smalc    ;;
1982b8e59f18Smalc
1983997e690aSJuan Quintela    coreaudio)
1984997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1985997e690aSJuan Quintela    ;;
1986997e690aSJuan Quintela
1987a4bf6780SJuan Quintela    dsound)
1988a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1989d5631638Smalc      audio_win_int="yes"
1990a4bf6780SJuan Quintela    ;;
1991a4bf6780SJuan Quintela
1992a4bf6780SJuan Quintela    oss)
1993a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1994a4bf6780SJuan Quintela    ;;
1995a4bf6780SJuan Quintela
1996a4bf6780SJuan Quintela    sdl|wav)
19972f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
19982f6a1ab0Sblueswir1    ;;
19992f6a1ab0Sblueswir1
2000d5631638Smalc    winwave)
2001d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
2002d5631638Smalc      audio_win_int="yes"
2003d5631638Smalc    ;;
2004d5631638Smalc
2005e4c63a6aSmalc    *)
20061c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
2007e4c63a6aSmalc        echo
2008e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
2009e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
2010e4c63a6aSmalc        echo
2011e4c63a6aSmalc        exit 1
2012e4c63a6aSmalc    }
2013e4c63a6aSmalc    ;;
2014c2de5c91Smalc    esac
2015c2de5c91Smalcdone
20168f28f3fbSths
20174d3b6f6eSbalrog##########################################
20182e4d9fb1Saurel32# BrlAPI probe
20192e4d9fb1Saurel32
20204ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2021eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
20222e4d9fb1Saurel32  cat > $TMPC << EOF
20232e4d9fb1Saurel32#include <brlapi.h>
2024832ce9c2SScott Wood#include <stddef.h>
20252e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
20262e4d9fb1Saurel32EOF
202752166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
20282e4d9fb1Saurel32    brlapi=yes
2029264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
20304ffcedb6SJuan Quintela  else
20314ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
20324ffcedb6SJuan Quintela      feature_not_found "brlapi"
20334ffcedb6SJuan Quintela    fi
20344ffcedb6SJuan Quintela    brlapi=no
2035eb82284fSJuan Quintela  fi
2036eb82284fSJuan Quintelafi
20372e4d9fb1Saurel32
20382e4d9fb1Saurel32##########################################
20394d3b6f6eSbalrog# curses probe
2040e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
2041e095e2f3SStefan Weil    curses_list="-lpdcurses"
2042e095e2f3SStefan Weilelse
20434f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
2044e095e2f3SStefan Weilfi
20454d3b6f6eSbalrog
2046c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
2047c584a6d0SJuan Quintela  curses_found=no
20484d3b6f6eSbalrog  cat > $TMPC << EOF
20494d3b6f6eSbalrog#include <curses.h>
2050ef9a2524SStefan Weilint main(void) {
2051ef9a2524SStefan Weil  const char *s = curses_version();
2052ef9a2524SStefan Weil  resize_term(0, 0);
2053ef9a2524SStefan Weil  return s != 0;
2054ef9a2524SStefan Weil}
20554d3b6f6eSbalrogEOF
20564f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
20574f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2058c584a6d0SJuan Quintela      curses_found=yes
20594f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
20604f78ef9aSJuan Quintela      break
20614d3b6f6eSbalrog    fi
20624f78ef9aSJuan Quintela  done
2063c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2064c584a6d0SJuan Quintela    curses=yes
2065c584a6d0SJuan Quintela  else
2066c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
2067c584a6d0SJuan Quintela      feature_not_found "curses"
2068c584a6d0SJuan Quintela    fi
2069c584a6d0SJuan Quintela    curses=no
2070c584a6d0SJuan Quintela  fi
20714f78ef9aSJuan Quintelafi
20724d3b6f6eSbalrog
2073414f0dabSblueswir1##########################################
2074769ce76dSAlexander Graf# curl probe
2075769ce76dSAlexander Graf
2076a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
2077a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
20784e2b0658SPaolo Bonzinielse
20794e2b0658SPaolo Bonzini  curlconfig=curl-config
20804e2b0658SPaolo Bonzinifi
20814e2b0658SPaolo Bonzini
2082788c8196SJuan Quintelaif test "$curl" != "no" ; then
2083769ce76dSAlexander Graf  cat > $TMPC << EOF
2084769ce76dSAlexander Graf#include <curl/curl.h>
20850b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2086769ce76dSAlexander GrafEOF
20874e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
20884e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2089b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2090769ce76dSAlexander Graf    curl=yes
2091f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2092f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2093788c8196SJuan Quintela  else
2094788c8196SJuan Quintela    if test "$curl" = "yes" ; then
2095788c8196SJuan Quintela      feature_not_found "curl"
2096788c8196SJuan Quintela    fi
2097788c8196SJuan Quintela    curl=no
2098769ce76dSAlexander Graf  fi
2099769ce76dSAlexander Graffi # test "$curl"
2100769ce76dSAlexander Graf
2101769ce76dSAlexander Graf##########################################
2102fb599c9aSbalrog# bluez support probe
2103a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2104e820e3f4Sbalrog  cat > $TMPC << EOF
2105e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2106e820e3f4Sbalrogint main(void) { return bt_error(0); }
2107e820e3f4SbalrogEOF
2108a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2109a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
211052166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2111a20a6f46SJuan Quintela    bluez=yes
2112e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2113e820e3f4Sbalrog  else
2114a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
2115a20a6f46SJuan Quintela      feature_not_found "bluez"
2116a20a6f46SJuan Quintela    fi
2117e820e3f4Sbalrog    bluez="no"
2118e820e3f4Sbalrog  fi
2119fb599c9aSbalrogfi
2120fb599c9aSbalrog
2121fb599c9aSbalrog##########################################
2122e18df141SAnthony Liguori# glib support probe
2123a52d28afSPaolo Bonzini
2124a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2125a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2126a52d28afSPaolo Bonzini    glib_req_ver=2.20
2127a52d28afSPaolo Bonzinielse
2128a52d28afSPaolo Bonzini    glib_req_ver=2.12
2129a52d28afSPaolo Bonzinifi
2130a52d28afSPaolo Bonziniif $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
2131a52d28afSPaolo Bonzinithen
21324b76a481SStefan Hajnoczi    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
21334b76a481SStefan Hajnoczi    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
213414015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2135957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2136e18df141SAnthony Liguorielse
2137a52d28afSPaolo Bonzini    echo "glib-$glib_req_ver required to compile QEMU"
2138e18df141SAnthony Liguori    exit 1
2139e18df141SAnthony Liguorifi
2140e18df141SAnthony Liguori
2141e18df141SAnthony Liguori##########################################
214217bff52bSM. Mohan Kumar# libcap probe
214317bff52bSM. Mohan Kumar
214417bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
214517bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
214617bff52bSM. Mohan Kumar#include <stdio.h>
214717bff52bSM. Mohan Kumar#include <sys/capability.h>
2148cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
214917bff52bSM. Mohan KumarEOF
215017bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
215117bff52bSM. Mohan Kumar    cap=yes
215217bff52bSM. Mohan Kumar  else
215317bff52bSM. Mohan Kumar    cap=no
215417bff52bSM. Mohan Kumar  fi
215517bff52bSM. Mohan Kumarfi
215617bff52bSM. Mohan Kumar
215717bff52bSM. Mohan Kumar##########################################
2158e5d355d1Saliguori# pthread probe
21594b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
21603c529d93Saliguori
2161e5d355d1Saliguoripthread=no
2162414f0dabSblueswir1cat > $TMPC << EOF
21633c529d93Saliguori#include <pthread.h>
21647a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
21657a42bbe4SStefan Weilint main(void) {
21667a42bbe4SStefan Weil  pthread_t thread;
21677a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
21687a42bbe4SStefan Weil  return 0;
21697a42bbe4SStefan Weil}
2170414f0dabSblueswir1EOF
2171bd00d539SAndreas Färberif compile_prog "" "" ; then
2172bd00d539SAndreas Färber  pthread=yes
2173bd00d539SAndreas Färberelse
2174de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
217552166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2176e5d355d1Saliguori      pthread=yes
2177e3c56761SPeter Portante      found=no
2178e3c56761SPeter Portante      for lib_entry in $LIBS; do
2179e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2180e3c56761SPeter Portante          found=yes
2181e3c56761SPeter Portante          break
2182e3c56761SPeter Portante        fi
2183e3c56761SPeter Portante      done
2184e3c56761SPeter Portante      if test "$found" = "no"; then
21855572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2186e3c56761SPeter Portante      fi
2187de65fe0fSSebastian Herbszt      break
2188414f0dabSblueswir1    fi
2189de65fe0fSSebastian Herbszt  done
2190bd00d539SAndreas Färberfi
2191414f0dabSblueswir1
21924617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
21934dd75c70SChristoph Hellwig  echo
21944dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
21954dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
21964dd75c70SChristoph Hellwig  echo
21974dd75c70SChristoph Hellwig  exit 1
2198e5d355d1Saliguorifi
2199e5d355d1Saliguori
2200bf9298b9Saliguori##########################################
2201f27aaf4bSChristian Brunner# rbd probe
2202f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2203f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2204f27aaf4bSChristian Brunner#include <stdio.h>
2205ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2206f27aaf4bSChristian Brunnerint main(void) {
2207ad32e9c0SJosh Durgin    rados_t cluster;
2208ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2209f27aaf4bSChristian Brunner    return 0;
2210f27aaf4bSChristian Brunner}
2211f27aaf4bSChristian BrunnerEOF
2212ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2213f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2214f27aaf4bSChristian Brunner    rbd=yes
2215f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2216f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2217f27aaf4bSChristian Brunner  else
2218f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
2219f27aaf4bSChristian Brunner      feature_not_found "rados block device"
2220f27aaf4bSChristian Brunner    fi
2221f27aaf4bSChristian Brunner    rbd=no
2222f27aaf4bSChristian Brunner  fi
2223f27aaf4bSChristian Brunnerfi
2224f27aaf4bSChristian Brunner
2225f27aaf4bSChristian Brunner##########################################
22265c6c3a6cSChristoph Hellwig# linux-aio probe
22275c6c3a6cSChristoph Hellwig
22285c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
22295c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
22305c6c3a6cSChristoph Hellwig#include <libaio.h>
22315c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2232832ce9c2SScott Wood#include <stddef.h>
22335c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
22345c6c3a6cSChristoph HellwigEOF
22355c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
22365c6c3a6cSChristoph Hellwig    linux_aio=yes
2237048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2238048d179fSPaul Brook    libs_tools="$libs_tools -laio"
22395c6c3a6cSChristoph Hellwig  else
22405c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
22415c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
22425c6c3a6cSChristoph Hellwig    fi
22433cfcae3cSLuiz Capitulino    linux_aio=no
22445c6c3a6cSChristoph Hellwig  fi
22455c6c3a6cSChristoph Hellwigfi
22465c6c3a6cSChristoph Hellwig
22475c6c3a6cSChristoph Hellwig##########################################
2248758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2249758e8e38SVenkateswararao Jujjuri (JV)
2250758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2251758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2252758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2253758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2254f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2255f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2256f2338fb4SPavel Borzenkov#else
22574f26f2b6SAvi Kivity#include <sys/xattr.h>
2258f2338fb4SPavel Borzenkov#endif
2259758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2260758e8e38SVenkateswararao Jujjuri (JV)EOF
22614f26f2b6SAvi Kivity  if compile_prog "" "" ; then
22624f26f2b6SAvi Kivity    attr=yes
22634f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2264f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2265758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2266758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
22674f26f2b6SAvi Kivity    libattr=yes
2268758e8e38SVenkateswararao Jujjuri (JV)  else
2269758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2270758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2271758e8e38SVenkateswararao Jujjuri (JV)    fi
2272758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2273758e8e38SVenkateswararao Jujjuri (JV)  fi
2274758e8e38SVenkateswararao Jujjuri (JV)fi
2275758e8e38SVenkateswararao Jujjuri (JV)
2276758e8e38SVenkateswararao Jujjuri (JV)##########################################
2277bf9298b9Saliguori# iovec probe
2278bf9298b9Saliguoricat > $TMPC <<EOF
2279db34f0b3Sblueswir1#include <sys/types.h>
2280bf9298b9Saliguori#include <sys/uio.h>
2281db34f0b3Sblueswir1#include <unistd.h>
2282f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2283bf9298b9SaliguoriEOF
2284bf9298b9Saliguoriiovec=no
228552166aa0SJuan Quintelaif compile_prog "" "" ; then
2286bf9298b9Saliguori  iovec=yes
2287bf9298b9Saliguorifi
2288bf9298b9Saliguori
2289f652e6afSaurel32##########################################
2290ceb42de8Saliguori# preadv probe
2291ceb42de8Saliguoricat > $TMPC <<EOF
2292ceb42de8Saliguori#include <sys/types.h>
2293ceb42de8Saliguori#include <sys/uio.h>
2294ceb42de8Saliguori#include <unistd.h>
2295c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2296ceb42de8SaliguoriEOF
2297ceb42de8Saliguoripreadv=no
229852166aa0SJuan Quintelaif compile_prog "" "" ; then
2299ceb42de8Saliguori  preadv=yes
2300ceb42de8Saliguorifi
2301ceb42de8Saliguori
2302ceb42de8Saliguori##########################################
2303f652e6afSaurel32# fdt probe
23042df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2305b41af4baSJuan Quintela  fdt_libs="-lfdt"
2306f652e6afSaurel32  cat > $TMPC << EOF
2307f652e6afSaurel32int main(void) { return 0; }
2308f652e6afSaurel32EOF
230952166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2310f652e6afSaurel32    fdt=yes
23112df87df7SJuan Quintela  else
23122df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
23132df87df7SJuan Quintela      feature_not_found "fdt"
23142df87df7SJuan Quintela    fi
2315de3a354aSMichael Walle    fdt_libs=
23162df87df7SJuan Quintela    fdt=no
2317f652e6afSaurel32  fi
2318f652e6afSaurel32fi
2319f652e6afSaurel32
232020ff075bSMichael Walle##########################################
232120ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
232220ff075bSMichael Walleif test "$opengl" != "no" ; then
232320ff075bSMichael Walle  opengl_libs="-lGL"
232420ff075bSMichael Walle  cat > $TMPC << EOF
232520ff075bSMichael Walle#include <X11/Xlib.h>
232620ff075bSMichael Walle#include <GL/gl.h>
232720ff075bSMichael Walle#include <GL/glx.h>
232884972cbbSStefan Weilint main(void) { return GL_VERSION != 0; }
232920ff075bSMichael WalleEOF
233020ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
233120ff075bSMichael Walle    opengl=yes
233220ff075bSMichael Walle  else
233320ff075bSMichael Walle    if test "$opengl" = "yes" ; then
233420ff075bSMichael Walle      feature_not_found "opengl"
233520ff075bSMichael Walle    fi
2336de3a354aSMichael Walle    opengl_libs=
233720ff075bSMichael Walle    opengl=no
233820ff075bSMichael Walle  fi
233920ff075bSMichael Wallefi
234020ff075bSMichael Walle
23413b3f24adSaurel32#
23423b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
23433b3f24adSaurel32# emulator.  This is done because older glibc versions don't
23443b3f24adSaurel32# have syscall stubs for these implemented.
23453b3f24adSaurel32#
23463b3f24adSaurel32atfile=no
23473b3f24adSaurel32cat > $TMPC << EOF
23483b3f24adSaurel32#define _ATFILE_SOURCE
23493b3f24adSaurel32#include <sys/types.h>
23503b3f24adSaurel32#include <fcntl.h>
23513b3f24adSaurel32#include <unistd.h>
23523b3f24adSaurel32
23533b3f24adSaurel32int
23543b3f24adSaurel32main(void)
23553b3f24adSaurel32{
23563b3f24adSaurel32	/* try to unlink nonexisting file */
23573b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
23583b3f24adSaurel32}
23593b3f24adSaurel32EOF
236052166aa0SJuan Quintelaif compile_prog "" "" ; then
23613b3f24adSaurel32  atfile=yes
23623b3f24adSaurel32fi
23633b3f24adSaurel32
236439386ac7Saurel32# Check for inotify functions when we are building linux-user
23653b3f24adSaurel32# emulator.  This is done because older glibc versions don't
23663b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
23673b3f24adSaurel32# don't provide them even if kernel supports them.
23683b3f24adSaurel32#
23693b3f24adSaurel32inotify=no
23703b3f24adSaurel32cat > $TMPC << EOF
23713b3f24adSaurel32#include <sys/inotify.h>
23723b3f24adSaurel32
23733b3f24adSaurel32int
23743b3f24adSaurel32main(void)
23753b3f24adSaurel32{
23763b3f24adSaurel32	/* try to start inotify */
23778690e420Saurel32	return inotify_init();
23783b3f24adSaurel32}
23793b3f24adSaurel32EOF
238052166aa0SJuan Quintelaif compile_prog "" "" ; then
23813b3f24adSaurel32  inotify=yes
23823b3f24adSaurel32fi
23833b3f24adSaurel32
2384c05c7a73SRiku Voipioinotify1=no
2385c05c7a73SRiku Voipiocat > $TMPC << EOF
2386c05c7a73SRiku Voipio#include <sys/inotify.h>
2387c05c7a73SRiku Voipio
2388c05c7a73SRiku Voipioint
2389c05c7a73SRiku Voipiomain(void)
2390c05c7a73SRiku Voipio{
2391c05c7a73SRiku Voipio    /* try to start inotify */
2392c05c7a73SRiku Voipio    return inotify_init1(0);
2393c05c7a73SRiku Voipio}
2394c05c7a73SRiku VoipioEOF
2395c05c7a73SRiku Voipioif compile_prog "" "" ; then
2396c05c7a73SRiku Voipio  inotify1=yes
2397c05c7a73SRiku Voipiofi
2398c05c7a73SRiku Voipio
2399ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2400ebc996f3SRiku Voipioutimens=no
2401ebc996f3SRiku Voipiocat > $TMPC << EOF
2402ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2403ebc996f3SRiku Voipio#include <stddef.h>
2404ebc996f3SRiku Voipio#include <fcntl.h>
24053014ee00SPeter Maydell#include <sys/stat.h>
2406ebc996f3SRiku Voipio
2407ebc996f3SRiku Voipioint main(void)
2408ebc996f3SRiku Voipio{
2409ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2410ebc996f3SRiku Voipio    futimens(0, NULL);
2411ebc996f3SRiku Voipio    return 0;
2412ebc996f3SRiku Voipio}
2413ebc996f3SRiku VoipioEOF
241452166aa0SJuan Quintelaif compile_prog "" "" ; then
2415ebc996f3SRiku Voipio  utimens=yes
2416ebc996f3SRiku Voipiofi
2417ebc996f3SRiku Voipio
2418099d6b0fSRiku Voipio# check if pipe2 is there
2419099d6b0fSRiku Voipiopipe2=no
2420099d6b0fSRiku Voipiocat > $TMPC << EOF
2421099d6b0fSRiku Voipio#include <unistd.h>
2422099d6b0fSRiku Voipio#include <fcntl.h>
2423099d6b0fSRiku Voipio
2424099d6b0fSRiku Voipioint main(void)
2425099d6b0fSRiku Voipio{
2426099d6b0fSRiku Voipio    int pipefd[2];
2427099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2428099d6b0fSRiku Voipio    return 0;
2429099d6b0fSRiku Voipio}
2430099d6b0fSRiku VoipioEOF
243152166aa0SJuan Quintelaif compile_prog "" "" ; then
2432099d6b0fSRiku Voipio  pipe2=yes
2433099d6b0fSRiku Voipiofi
2434099d6b0fSRiku Voipio
243540ff6d7eSKevin Wolf# check if accept4 is there
243640ff6d7eSKevin Wolfaccept4=no
243740ff6d7eSKevin Wolfcat > $TMPC << EOF
243840ff6d7eSKevin Wolf#include <sys/socket.h>
243940ff6d7eSKevin Wolf#include <stddef.h>
244040ff6d7eSKevin Wolf
244140ff6d7eSKevin Wolfint main(void)
244240ff6d7eSKevin Wolf{
244340ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
244440ff6d7eSKevin Wolf    return 0;
244540ff6d7eSKevin Wolf}
244640ff6d7eSKevin WolfEOF
244740ff6d7eSKevin Wolfif compile_prog "" "" ; then
244840ff6d7eSKevin Wolf  accept4=yes
244940ff6d7eSKevin Wolffi
245040ff6d7eSKevin Wolf
24513ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
24523ce34dfbSvibisreenivasansplice=no
24533ce34dfbSvibisreenivasancat > $TMPC << EOF
24543ce34dfbSvibisreenivasan#include <unistd.h>
24553ce34dfbSvibisreenivasan#include <fcntl.h>
24563ce34dfbSvibisreenivasan#include <limits.h>
24573ce34dfbSvibisreenivasan
24583ce34dfbSvibisreenivasanint main(void)
24593ce34dfbSvibisreenivasan{
246066ea0f22SStefan Weil    int len, fd = 0;
24613ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
24623ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
24633ce34dfbSvibisreenivasan    return 0;
24643ce34dfbSvibisreenivasan}
24653ce34dfbSvibisreenivasanEOF
246652166aa0SJuan Quintelaif compile_prog "" "" ; then
24673ce34dfbSvibisreenivasan  splice=yes
24683ce34dfbSvibisreenivasanfi
24693ce34dfbSvibisreenivasan
2470dcc38d1cSMarcelo Tosatti##########################################
2471dcc38d1cSMarcelo Tosatti# signalfd probe
2472dcc38d1cSMarcelo Tosattisignalfd="no"
2473dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2474dcc38d1cSMarcelo Tosatti#include <unistd.h>
2475dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2476dcc38d1cSMarcelo Tosatti#include <signal.h>
2477dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2478dcc38d1cSMarcelo TosattiEOF
2479dcc38d1cSMarcelo Tosatti
2480dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2481dcc38d1cSMarcelo Tosatti  signalfd=yes
2482dcc38d1cSMarcelo Tosattifi
2483dcc38d1cSMarcelo Tosatti
2484c2882b96SRiku Voipio# check if eventfd is supported
2485c2882b96SRiku Voipioeventfd=no
2486c2882b96SRiku Voipiocat > $TMPC << EOF
2487c2882b96SRiku Voipio#include <sys/eventfd.h>
2488c2882b96SRiku Voipio
2489c2882b96SRiku Voipioint main(void)
2490c2882b96SRiku Voipio{
249155cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2492c2882b96SRiku Voipio}
2493c2882b96SRiku VoipioEOF
2494c2882b96SRiku Voipioif compile_prog "" "" ; then
2495c2882b96SRiku Voipio  eventfd=yes
2496c2882b96SRiku Voipiofi
2497c2882b96SRiku Voipio
2498d0927938SUlrich Hecht# check for fallocate
2499d0927938SUlrich Hechtfallocate=no
2500d0927938SUlrich Hechtcat > $TMPC << EOF
2501d0927938SUlrich Hecht#include <fcntl.h>
2502d0927938SUlrich Hecht
2503d0927938SUlrich Hechtint main(void)
2504d0927938SUlrich Hecht{
2505d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2506d0927938SUlrich Hecht    return 0;
2507d0927938SUlrich Hecht}
2508d0927938SUlrich HechtEOF
25098fb03151SPeter Maydellif compile_prog "" "" ; then
2510d0927938SUlrich Hecht  fallocate=yes
2511d0927938SUlrich Hechtfi
2512d0927938SUlrich Hecht
2513c727f47dSPeter Maydell# check for sync_file_range
2514c727f47dSPeter Maydellsync_file_range=no
2515c727f47dSPeter Maydellcat > $TMPC << EOF
2516c727f47dSPeter Maydell#include <fcntl.h>
2517c727f47dSPeter Maydell
2518c727f47dSPeter Maydellint main(void)
2519c727f47dSPeter Maydell{
2520c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2521c727f47dSPeter Maydell    return 0;
2522c727f47dSPeter Maydell}
2523c727f47dSPeter MaydellEOF
25248fb03151SPeter Maydellif compile_prog "" "" ; then
2525c727f47dSPeter Maydell  sync_file_range=yes
2526c727f47dSPeter Maydellfi
2527c727f47dSPeter Maydell
2528dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2529dace20dcSPeter Maydellfiemap=no
2530dace20dcSPeter Maydellcat > $TMPC << EOF
2531dace20dcSPeter Maydell#include <sys/ioctl.h>
2532dace20dcSPeter Maydell#include <linux/fs.h>
2533dace20dcSPeter Maydell#include <linux/fiemap.h>
2534dace20dcSPeter Maydell
2535dace20dcSPeter Maydellint main(void)
2536dace20dcSPeter Maydell{
2537dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2538dace20dcSPeter Maydell    return 0;
2539dace20dcSPeter Maydell}
2540dace20dcSPeter MaydellEOF
25418fb03151SPeter Maydellif compile_prog "" "" ; then
2542dace20dcSPeter Maydell  fiemap=yes
2543dace20dcSPeter Maydellfi
2544dace20dcSPeter Maydell
2545d0927938SUlrich Hecht# check for dup3
2546d0927938SUlrich Hechtdup3=no
2547d0927938SUlrich Hechtcat > $TMPC << EOF
2548d0927938SUlrich Hecht#include <unistd.h>
2549d0927938SUlrich Hecht
2550d0927938SUlrich Hechtint main(void)
2551d0927938SUlrich Hecht{
2552d0927938SUlrich Hecht    dup3(0, 0, 0);
2553d0927938SUlrich Hecht    return 0;
2554d0927938SUlrich Hecht}
2555d0927938SUlrich HechtEOF
255678f5d726SJan Kiszkaif compile_prog "" "" ; then
2557d0927938SUlrich Hecht  dup3=yes
2558d0927938SUlrich Hechtfi
2559d0927938SUlrich Hecht
25603b6edd16SPeter Maydell# check for epoll support
25613b6edd16SPeter Maydellepoll=no
25623b6edd16SPeter Maydellcat > $TMPC << EOF
25633b6edd16SPeter Maydell#include <sys/epoll.h>
25643b6edd16SPeter Maydell
25653b6edd16SPeter Maydellint main(void)
25663b6edd16SPeter Maydell{
25673b6edd16SPeter Maydell    epoll_create(0);
25683b6edd16SPeter Maydell    return 0;
25693b6edd16SPeter Maydell}
25703b6edd16SPeter MaydellEOF
25718fb03151SPeter Maydellif compile_prog "" "" ; then
25723b6edd16SPeter Maydell  epoll=yes
25733b6edd16SPeter Maydellfi
25743b6edd16SPeter Maydell
25753b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
25763b6edd16SPeter Maydell# so we must check separately for their presence
25773b6edd16SPeter Maydellepoll_create1=no
25783b6edd16SPeter Maydellcat > $TMPC << EOF
25793b6edd16SPeter Maydell#include <sys/epoll.h>
25803b6edd16SPeter Maydell
25813b6edd16SPeter Maydellint main(void)
25823b6edd16SPeter Maydell{
258319e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
258419e83f6bSPeter Maydell     * a function being called. This is necessary so that on
258519e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
258619e83f6bSPeter Maydell     * the library but not declared in the header file we will
258719e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
258819e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
258919e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
259019e83f6bSPeter Maydell     */
2591c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
25923b6edd16SPeter Maydell}
25933b6edd16SPeter MaydellEOF
25948fb03151SPeter Maydellif compile_prog "" "" ; then
25953b6edd16SPeter Maydell  epoll_create1=yes
25963b6edd16SPeter Maydellfi
25973b6edd16SPeter Maydell
25983b6edd16SPeter Maydellepoll_pwait=no
25993b6edd16SPeter Maydellcat > $TMPC << EOF
26003b6edd16SPeter Maydell#include <sys/epoll.h>
26013b6edd16SPeter Maydell
26023b6edd16SPeter Maydellint main(void)
26033b6edd16SPeter Maydell{
26043b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
26053b6edd16SPeter Maydell    return 0;
26063b6edd16SPeter Maydell}
26073b6edd16SPeter MaydellEOF
26088fb03151SPeter Maydellif compile_prog "" "" ; then
26093b6edd16SPeter Maydell  epoll_pwait=yes
26103b6edd16SPeter Maydellfi
26113b6edd16SPeter Maydell
2612cc8ae6deSpbrook# Check if tools are available to build documentation.
2613a25dba17SJuan Quintelaif test "$docs" != "no" ; then
261401668d98SStefan Weil  if has makeinfo && has pod2man; then
2615a25dba17SJuan Quintela    docs=yes
261683a3ab8bSJuan Quintela  else
2617a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2618a25dba17SJuan Quintela      feature_not_found "docs"
261983a3ab8bSJuan Quintela    fi
2620a25dba17SJuan Quintela    docs=no
262183a3ab8bSJuan Quintela  fi
2622cc8ae6deSpbrookfi
2623cc8ae6deSpbrook
2624f514f41cSStefan Weil# Search for bswap_32 function
26256ae9a1f4SJuan Quintelabyteswap_h=no
26266ae9a1f4SJuan Quintelacat > $TMPC << EOF
26276ae9a1f4SJuan Quintela#include <byteswap.h>
26286ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
26296ae9a1f4SJuan QuintelaEOF
263052166aa0SJuan Quintelaif compile_prog "" "" ; then
26316ae9a1f4SJuan Quintela  byteswap_h=yes
26326ae9a1f4SJuan Quintelafi
26336ae9a1f4SJuan Quintela
2634f514f41cSStefan Weil# Search for bswap_32 function
26356ae9a1f4SJuan Quintelabswap_h=no
26366ae9a1f4SJuan Quintelacat > $TMPC << EOF
26376ae9a1f4SJuan Quintela#include <sys/endian.h>
26386ae9a1f4SJuan Quintela#include <sys/types.h>
26396ae9a1f4SJuan Quintela#include <machine/bswap.h>
26406ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
26416ae9a1f4SJuan QuintelaEOF
264252166aa0SJuan Quintelaif compile_prog "" "" ; then
26436ae9a1f4SJuan Quintela  bswap_h=yes
26446ae9a1f4SJuan Quintelafi
26456ae9a1f4SJuan Quintela
2646da93a1fdSaliguori##########################################
2647c589b249SRonnie Sahlberg# Do we have libiscsi
2648fa6acb0cSRonnie Sahlberg# We check for iscsi_unmap_sync() to make sure we have a
2649fa6acb0cSRonnie Sahlberg# recent enough version of libiscsi.
2650c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2651c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2652fa6acb0cSRonnie Sahlberg#include <stdio.h>
2653c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2654fa6acb0cSRonnie Sahlbergint main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2655c589b249SRonnie SahlbergEOF
2656417c9d72SAlexander Graf  if compile_prog "" "-liscsi" ; then
2657c589b249SRonnie Sahlberg    libiscsi="yes"
2658c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2659c589b249SRonnie Sahlberg  else
2660c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2661c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2662c589b249SRonnie Sahlberg    fi
2663c589b249SRonnie Sahlberg    libiscsi="no"
2664c589b249SRonnie Sahlberg  fi
2665c589b249SRonnie Sahlbergfi
2666c589b249SRonnie Sahlberg
2667c589b249SRonnie Sahlberg
2668c589b249SRonnie Sahlberg##########################################
2669da93a1fdSaliguori# Do we need librt
2670da93a1fdSaliguoricat > $TMPC <<EOF
2671da93a1fdSaliguori#include <signal.h>
2672da93a1fdSaliguori#include <time.h>
267366ea0f22SStefan Weilint main(void) { return clock_gettime(CLOCK_REALTIME, NULL); }
2674da93a1fdSaliguoriEOF
2675da93a1fdSaliguori
267652166aa0SJuan Quintelaif compile_prog "" "" ; then
267707ffa4bdSJuan Quintela  :
267852166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
267907ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2680da93a1fdSaliguorifi
2681da93a1fdSaliguori
268231ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2683179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
26846362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
26856362a53fSJuan Quintelafi
26866362a53fSJuan Quintela
2687de5071c5SBlue Swirl##########################################
2688cd4ec0b4SGerd Hoffmann# spice probe
2689cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2690cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2691cd4ec0b4SGerd Hoffmann#include <spice.h>
2692cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2693cd4ec0b4SGerd HoffmannEOF
2694710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2695710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
26964295e15aSAlon Levy  if $pkg_config --atleast-version=0.8.2 spice-server >/dev/null 2>&1 && \
26977e3efdacSAlon Levy     $pkg_config --atleast-version=0.8.1 spice-protocol > /dev/null 2>&1 && \
2698cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2699cd4ec0b4SGerd Hoffmann    spice="yes"
2700cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2701cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
27022e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
27032e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
2704020af1c4SAlon Levy    if $pkg_config --atleast-version=0.12.0 spice-protocol >/dev/null 2>&1; then
2705020af1c4SAlon Levy        spice_qxl_io_monitors_config_async="yes"
2706020af1c4SAlon Levy    fi
2707cd4ec0b4SGerd Hoffmann  else
2708cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2709cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2710cd4ec0b4SGerd Hoffmann    fi
2711cd4ec0b4SGerd Hoffmann    spice="no"
2712cd4ec0b4SGerd Hoffmann  fi
2713cd4ec0b4SGerd Hoffmannfi
2714cd4ec0b4SGerd Hoffmann
2715111a38b0SRobert Relyea# check for libcacard for smartcard support
2716111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2717111a38b0SRobert Relyea    smartcard="yes"
2718111a38b0SRobert Relyea    smartcard_cflags=""
2719111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2720111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
27215f01e06fSSergei Trofimovich      cat > $TMPC << EOF
27225f01e06fSSergei Trofimovich#include <pk11pub.h>
27235f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
27245f01e06fSSergei TrofimovichEOF
27250b22ef0fSPeter Maydell        smartcard_includes="-I\$(SRC_PATH)/libcacard"
27268c741c22SAlon Levy        libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
27278c741c22SAlon Levy        libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
27286ca026cbSPeter Maydell        test_cflags="$libcacard_cflags"
27296ca026cbSPeter Maydell        # The header files in nss < 3.13.3 have a bug which causes them to
27306ca026cbSPeter Maydell        # emit a warning. If we're going to compile QEMU with -Werror, then
27316ca026cbSPeter Maydell        # test that the headers don't have this bug. Otherwise we would pass
27326ca026cbSPeter Maydell        # the configure test but fail to compile QEMU later.
27336ca026cbSPeter Maydell        if test "$werror" = "yes"; then
27346ca026cbSPeter Maydell            test_cflags="-Werror $test_cflags"
27356ca026cbSPeter Maydell        fi
27365f01e06fSSergei Trofimovich        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
27376ca026cbSPeter Maydell          compile_prog "$test_cflags" "$libcacard_libs"; then
27385f01e06fSSergei Trofimovich            smartcard_nss="yes"
27390b22ef0fSPeter Maydell            QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
27400b22ef0fSPeter Maydell            QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
2741ad4cf3f6SPaul Brook            libs_softmmu="$libcacard_libs $libs_softmmu"
2742111a38b0SRobert Relyea        else
2743111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2744111a38b0SRobert Relyea                feature_not_found "nss"
2745111a38b0SRobert Relyea            fi
2746111a38b0SRobert Relyea            smartcard_nss="no"
2747111a38b0SRobert Relyea        fi
2748111a38b0SRobert Relyea    fi
2749111a38b0SRobert Relyeafi
2750111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2751111a38b0SRobert Relyea    smartcard_nss="no"
2752111a38b0SRobert Relyeafi
2753111a38b0SRobert Relyea
275469354a83SHans de Goede# check for usbredirparser for usb network redirection support
275569354a83SHans de Goedeif test "$usb_redir" != "no" ; then
2756097a66efSHans de Goede    if $pkg_config --atleast-version=0.3.4 libusbredirparser >/dev/null 2>&1 ; then
275769354a83SHans de Goede        usb_redir="yes"
275869354a83SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
275969354a83SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
276069354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
276169354a83SHans de Goede        LIBS="$LIBS $usb_redir_libs"
276269354a83SHans de Goede    else
276369354a83SHans de Goede        if test "$usb_redir" = "yes"; then
276469354a83SHans de Goede            feature_not_found "usb-redir"
276569354a83SHans de Goede        fi
276669354a83SHans de Goede        usb_redir="no"
276769354a83SHans de Goede    fi
276869354a83SHans de Goedefi
276969354a83SHans de Goede
2770cd4ec0b4SGerd Hoffmann##########################################
2771cd4ec0b4SGerd Hoffmann
2772747bbdf7SBlue Swirl##########################################
27735f6b9e8fSBlue Swirl# check if we have fdatasync
27745f6b9e8fSBlue Swirl
27755f6b9e8fSBlue Swirlfdatasync=no
27765f6b9e8fSBlue Swirlcat > $TMPC << EOF
27775f6b9e8fSBlue Swirl#include <unistd.h>
2778d1722a27SAlexandre Raymondint main(void) {
2779d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2780d1722a27SAlexandre Raymondreturn fdatasync(0);
2781d1722a27SAlexandre Raymond#else
2782e172fe11SStefan Weil#error Not supported
2783d1722a27SAlexandre Raymond#endif
2784d1722a27SAlexandre Raymond}
27855f6b9e8fSBlue SwirlEOF
27865f6b9e8fSBlue Swirlif compile_prog "" "" ; then
27875f6b9e8fSBlue Swirl    fdatasync=yes
27885f6b9e8fSBlue Swirlfi
27895f6b9e8fSBlue Swirl
279094a420b1SStefan Hajnoczi##########################################
2791e78815a5SAndreas Färber# check if we have madvise
2792e78815a5SAndreas Färber
2793e78815a5SAndreas Färbermadvise=no
2794e78815a5SAndreas Färbercat > $TMPC << EOF
2795e78815a5SAndreas Färber#include <sys/types.h>
2796e78815a5SAndreas Färber#include <sys/mman.h>
2797832ce9c2SScott Wood#include <stddef.h>
2798e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2799e78815a5SAndreas FärberEOF
2800e78815a5SAndreas Färberif compile_prog "" "" ; then
2801e78815a5SAndreas Färber    madvise=yes
2802e78815a5SAndreas Färberfi
2803e78815a5SAndreas Färber
2804e78815a5SAndreas Färber##########################################
2805e78815a5SAndreas Färber# check if we have posix_madvise
2806e78815a5SAndreas Färber
2807e78815a5SAndreas Färberposix_madvise=no
2808e78815a5SAndreas Färbercat > $TMPC << EOF
2809e78815a5SAndreas Färber#include <sys/mman.h>
2810832ce9c2SScott Wood#include <stddef.h>
2811e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2812e78815a5SAndreas FärberEOF
2813e78815a5SAndreas Färberif compile_prog "" "" ; then
2814e78815a5SAndreas Färber    posix_madvise=yes
2815e78815a5SAndreas Färberfi
2816e78815a5SAndreas Färber
2817e78815a5SAndreas Färber##########################################
281894a420b1SStefan Hajnoczi# check if trace backend exists
281994a420b1SStefan Hajnoczi
2820650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
282194a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
282294a420b1SStefan Hajnoczi  echo
282394a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
282494a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
282594a420b1SStefan Hajnoczi  echo
282694a420b1SStefan Hajnoczi  exit 1
282794a420b1SStefan Hajnoczifi
282894a420b1SStefan Hajnoczi
28297e24e92aSStefan Hajnoczi##########################################
28307e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
28317e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
28327e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
28337e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
28347e24e92aSStefan Hajnoczi#include <ust/marker.h>
28357e24e92aSStefan Hajnocziint main(void) { return 0; }
28367e24e92aSStefan HajnocziEOF
28377e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
283894b4fefaSLluís Vilanova    LIBS="-lust -lurcu-bp $LIBS"
2839c9a2e37cSLluís Vilanova    libs_qga="-lust -lurcu-bp $libs_qga"
28407e24e92aSStefan Hajnoczi  else
28417e24e92aSStefan Hajnoczi    echo
28427e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
28437e24e92aSStefan Hajnoczi    echo
28447e24e92aSStefan Hajnoczi    exit 1
28457e24e92aSStefan Hajnoczi  fi
28467e24e92aSStefan Hajnoczifi
2847b3d08c02SDaniel P. Berrange
2848b3d08c02SDaniel P. Berrange##########################################
2849b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2850b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2851b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2852b3d08c02SDaniel P. Berrange    echo
2853b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2854b3d08c02SDaniel P. Berrange    echo
2855b3d08c02SDaniel P. Berrange    exit 1
2856b3d08c02SDaniel P. Berrange  fi
2857c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2858c276b17dSDaniel P. Berrange  if has 'stap' ; then
2859c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2860c276b17dSDaniel P. Berrange  fi
2861b3d08c02SDaniel P. Berrangefi
2862b3d08c02SDaniel P. Berrange
28637e24e92aSStefan Hajnoczi##########################################
2864023367e6SWolfgang Mauerer# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2865023367e6SWolfgang Mauerer# use i686 as default anyway, but for those that don't, an explicit
2866023367e6SWolfgang Mauerer# specification is necessary
28671ba16968SStefan Weilif test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
2868023367e6SWolfgang Mauerer  cat > $TMPC << EOF
28697ace252aSStefan Weilstatic int sfaa(int *ptr)
2870023367e6SWolfgang Mauerer{
2871023367e6SWolfgang Mauerer  return __sync_fetch_and_and(ptr, 0);
2872023367e6SWolfgang Mauerer}
2873023367e6SWolfgang Mauerer
2874023367e6SWolfgang Mauererint main(int argc, char **argv)
2875023367e6SWolfgang Mauerer{
2876023367e6SWolfgang Mauerer  int val = 42;
2877023367e6SWolfgang Mauerer  sfaa(&val);
2878023367e6SWolfgang Mauerer  return val;
2879023367e6SWolfgang Mauerer}
2880023367e6SWolfgang MauererEOF
2881023367e6SWolfgang Mauerer  if ! compile_prog "" "" ; then
2882caa50971SPeter Maydell    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2883023367e6SWolfgang Mauerer  fi
2884023367e6SWolfgang Mauererfi
2885023367e6SWolfgang Mauerer
2886023367e6SWolfgang Mauerer##########################################
2887519175a2SAlex Barcelo# check and set a backend for coroutine
2888d0e2fce5SAneesh Kumar K.V
2889519175a2SAlex Barcelo# default is ucontext, but always fallback to gthread
2890519175a2SAlex Barcelo# windows autodetected by make
2891519175a2SAlex Barceloif test "$coroutine" = "" -o "$coroutine" = "ucontext"; then
2892d0e2fce5SAneesh Kumar K.V  if test "$darwin" != "yes"; then
2893d0e2fce5SAneesh Kumar K.V    cat > $TMPC << EOF
2894d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
2895cdf84806SPeter Maydell#ifdef __stub_makecontext
2896cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
2897cdf84806SPeter Maydell#endif
289875cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
2899d0e2fce5SAneesh Kumar K.VEOF
2900d0e2fce5SAneesh Kumar K.V    if compile_prog "" "" ; then
2901519175a2SAlex Barcelo        coroutine_backend=ucontext
2902519175a2SAlex Barcelo    else
2903519175a2SAlex Barcelo	coroutine_backend=gthread
2904d0e2fce5SAneesh Kumar K.V    fi
2905519175a2SAlex Barcelo  else
2906519175a2SAlex Barcelo    echo "Silently falling back into gthread backend under darwin"
2907519175a2SAlex Barcelo  fi
2908519175a2SAlex Barceloelif test "$coroutine" = "gthread" ; then
2909519175a2SAlex Barcelo  coroutine_backend=gthread
2910519175a2SAlex Barceloelif test "$coroutine" = "windows" ; then
2911519175a2SAlex Barcelo  coroutine_backend=windows
2912fe91bfa8SAlex Barceloelif test "$coroutine" = "sigaltstack" ; then
2913fe91bfa8SAlex Barcelo  coroutine_backend=sigaltstack
2914519175a2SAlex Barceloelse
2915519175a2SAlex Barcelo  echo
2916519175a2SAlex Barcelo  echo "Error: unknown coroutine backend $coroutine"
2917519175a2SAlex Barcelo  echo
2918519175a2SAlex Barcelo  exit 1
2919d0e2fce5SAneesh Kumar K.Vfi
2920d0e2fce5SAneesh Kumar K.V
2921d0e2fce5SAneesh Kumar K.V##########################################
2922d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
2923d2042378SAneesh Kumar K.V
29244e1797f9SStefan Weilopen_by_handle_at=no
2925d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
2926d2042378SAneesh Kumar K.V#include <fcntl.h>
2927acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
2928acc55ba8SStefan Weil# error missing definition
2929acc55ba8SStefan Weil#else
293075cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
2931acc55ba8SStefan Weil#endif
2932d2042378SAneesh Kumar K.VEOF
2933d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
2934d2042378SAneesh Kumar K.V    open_by_handle_at=yes
2935d2042378SAneesh Kumar K.Vfi
2936d2042378SAneesh Kumar K.V
2937e06a765eSHarsh Prateek Bora########################################
2938e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
2939e06a765eSHarsh Prateek Bora
2940e06a765eSHarsh Prateek Boralinux_magic_h=no
2941e06a765eSHarsh Prateek Boracat > $TMPC << EOF
2942e06a765eSHarsh Prateek Bora#include <linux/magic.h>
2943e06a765eSHarsh Prateek Boraint main(void) {
294475cafad7SStefan Weil  return 0;
2945e06a765eSHarsh Prateek Bora}
2946e06a765eSHarsh Prateek BoraEOF
2947e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
2948e06a765eSHarsh Prateek Bora    linux_magic_h=yes
2949e06a765eSHarsh Prateek Borafi
2950e06a765eSHarsh Prateek Bora
29518ab1bf12SLuiz Capitulino########################################
295206d71fa1SPeter Maydell# check whether we can disable the -Wunused-but-set-variable
295306d71fa1SPeter Maydell# option with a pragma (this is needed to silence a warning in
295406d71fa1SPeter Maydell# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.)
295506d71fa1SPeter Maydell# This test has to be compiled with -Werror as otherwise an
295606d71fa1SPeter Maydell# unknown pragma is only a warning.
295706d71fa1SPeter Maydellpragma_disable_unused_but_set=no
295806d71fa1SPeter Maydellcat > $TMPC << EOF
295906d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
296006d71fa1SPeter Maydellint main(void) {
296106d71fa1SPeter Maydell    return 0;
296206d71fa1SPeter Maydell}
296306d71fa1SPeter MaydellEOF
296406d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
296506d71fa1SPeter Maydell    pragma_disable_unused_but_set=yes
296606d71fa1SPeter Maydellfi
296706d71fa1SPeter Maydell
296806d71fa1SPeter Maydell########################################
296962fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
29703f4349dcSKevin Wolf
29713f4349dcSKevin Wolfvalgrind_h=no
29723f4349dcSKevin Wolfcat > $TMPC << EOF
29733f4349dcSKevin Wolf#include <valgrind/valgrind.h>
297462fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
29753f4349dcSKevin Wolfint main(void) {
29763f4349dcSKevin Wolf  return 0;
29773f4349dcSKevin Wolf}
29783f4349dcSKevin WolfEOF
29793f4349dcSKevin Wolfif compile_prog "" "" ; then
29803f4349dcSKevin Wolf    valgrind_h=yes
29813f4349dcSKevin Wolffi
29823f4349dcSKevin Wolf
29833f4349dcSKevin Wolf########################################
29848ab1bf12SLuiz Capitulino# check if environ is declared
29858ab1bf12SLuiz Capitulino
29868ab1bf12SLuiz Capitulinohas_environ=no
29878ab1bf12SLuiz Capitulinocat > $TMPC << EOF
29888ab1bf12SLuiz Capitulino#include <unistd.h>
29898ab1bf12SLuiz Capitulinoint main(void) {
2990c075a723SBlue Swirl    environ = 0;
29918ab1bf12SLuiz Capitulino    return 0;
29928ab1bf12SLuiz Capitulino}
29938ab1bf12SLuiz CapitulinoEOF
29948ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
29958ab1bf12SLuiz Capitulino    has_environ=yes
29968ab1bf12SLuiz Capitulinofi
29978ab1bf12SLuiz Capitulino
2998d2042378SAneesh Kumar K.V##########################################
2999e86ecd4bSJuan Quintela# End of CC checks
3000e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3001e86ecd4bSJuan Quintela
3002e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
30038be74dc0SAvi Kivity  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3004e86ecd4bSJuan Quintelafi
3005a316e378SJuan Quintela
300620ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
300720ff6c80SAnthony Liguori# enable/disable
300820ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
300920ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
301020ff6c80SAnthony Liguori	zero_malloc="no"
301120ff6c80SAnthony Liguori    else
301220ff6c80SAnthony Liguori	zero_malloc="yes"
301320ff6c80SAnthony Liguori    fi
301420ff6c80SAnthony Liguorifi
301520ff6c80SAnthony Liguori
30166ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
30176ca026cbSPeter Maydellif test "$werror" = "yes"; then
30186ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
30196ca026cbSPeter Maydellfi
30206ca026cbSPeter Maydell
3021e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3022e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
30231156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3024e86ecd4bSJuan Quintela    fi
3025e86ecd4bSJuan Quintelafi
3026e86ecd4bSJuan Quintela
302794dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
302894dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
302994dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
303094dd53c5SGerd Hoffmannelse
303194dd53c5SGerd Hoffmann    POD2MAN="pod2man"
303294dd53c5SGerd Hoffmannfi
303394dd53c5SGerd Hoffmann
3034952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3035952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3036952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3037952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3038952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3039952afb71SBlue Swirl        fi
3040952afb71SBlue Swirl    done
3041952afb71SBlue Swirlfi
3042952afb71SBlue Swirl
304310ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3044528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
30455a67135aSbellard
3046ca35f780SPaolo Bonzinitools=
3047ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
3048ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
3049983eef5aSMeador Inge  if test "$virtfs" != no ; then
3050be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3051983eef5aSMeador Inge      virtfs=yes
305217bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3053983eef5aSMeador Inge    else
3054983eef5aSMeador Inge      if test "$virtfs" = yes; then
3055263ddcc8SHarsh Prateek Bora        echo "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3056263ddcc8SHarsh Prateek Bora        exit 1
3057983eef5aSMeador Inge      fi
305817500370SAndreas Färber      virtfs=no
3059983eef5aSMeador Inge    fi
306017bff52bSM. Mohan Kumar  fi
3061ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3062ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
3063d138cee9SMichael Roth    if [ "$guest_agent" = "yes" ]; then
306448ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
3065d138cee9SMichael Roth    fi
3066ca35f780SPaolo Bonzini  fi
3067ca35f780SPaolo Bonzinifi
306800c705fbSPaolo Bonziniif test "$smartcard_nss" = "yes" ; then
306900c705fbSPaolo Bonzini  tools="vscclient\$(EXESUF) $tools"
307000c705fbSPaolo Bonzinifi
3071ca35f780SPaolo Bonzini
3072ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3073ca35f780SPaolo Bonziniroms=
3074ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3075ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3076ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3077ca35f780SPaolo Bonzini  roms="optionrom"
3078ca35f780SPaolo Bonzinifi
3079d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
308039ac8455SDavid Gibson  roms="$roms spapr-rtas"
308139ac8455SDavid Gibsonfi
3082ca35f780SPaolo Bonzini
30837d13299dSbellardecho "Install prefix    $prefix"
3084c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3085f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
30863aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
30878bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
30880f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
30891c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
309011d9f695Sbellardif test "$mingw32" = "no" ; then
3091f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
309243ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
309311d9f695Sbellardfi
30945a67135aSbellardecho "Source path       $source_path"
30957d13299dSbellardecho "C compiler        $cc"
309683469015Sbellardecho "Host C compiler   $host_cc"
30973c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
30980c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3099a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
31000c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
31017d13299dSbellardecho "make              $make"
31026a882643Spbrookecho "install           $install"
3103c886edfbSBlue Swirlecho "python            $python"
3104e2d8830eSBradif test "$slirp" = "yes" ; then
3105e2d8830eSBrad    echo "smbd              $smbd"
3106e2d8830eSBradfi
3107a98fd896Sbellardecho "host CPU          $cpu"
3108de83cd02Sbellardecho "host big endian   $bigendian"
310997a847bcSbellardecho "target list       $target_list"
3110ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
31117d13299dSbellardecho "gprof enabled     $gprof"
311203b4fe7dSaliguoriecho "sparse enabled    $sparse"
31131625af87Saliguoriecho "strip binaries    $strip_opt"
311405c2a3e7Sbellardecho "profiler          $profiler"
311543ce4dfeSbellardecho "static build      $static"
311685aa5189Sbellardecho "-Werror enabled   $werror"
31175b0753e0Sbellardif test "$darwin" = "yes" ; then
31185b0753e0Sbellard    echo "Cocoa support     $cocoa"
31195b0753e0Sbellardfi
312097a847bcSbellardecho "SDL support       $sdl"
31214d3b6f6eSbalrogecho "curses support    $curses"
3122769ce76dSAlexander Grafecho "curl support      $curl"
312367b915a5Sbellardecho "mingw32 support   $mingw32"
31240c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
31250c58ac1cSmalcecho "Extra audio cards $audio_card_list"
3126eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
31278ff9cbf7Smalcecho "Mixer emulation   $mixemu"
3128983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3129821601eaSJes Sorensenecho "VNC support       $vnc"
3130821601eaSJes Sorensenif test "$vnc" = "yes" ; then
31318d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
31322f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
31332f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3134efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
3135821601eaSJes Sorensenfi
31363142255cSblueswir1if test -n "$sparc_cpu"; then
31373142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
31383142255cSblueswir1fi
3139e37630caSaliguoriecho "xen support       $xen"
31402e4d9fb1Saurel32echo "brlapi support    $brlapi"
3141a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3142a25dba17SJuan Quintelaecho "Documentation     $docs"
3143c5937220Spbrook[ ! -z "$uname_release" ] && \
3144c5937220Spbrookecho "uname -r          $uname_release"
3145bd0c5661Spbrookecho "NPTL support      $nptl"
3146379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
314740d6444eSAvi Kivityecho "PIE               $pie"
31488a16d273Sthsecho "vde support       $vde"
31495c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3150758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
315177755340Sthsecho "Install blobs     $blobs"
3152b31a0277SJuan Quintelaecho "KVM support       $kvm"
31539195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3154f652e6afSaurel32echo "fdt support       $fdt"
3155ceb42de8Saliguoriecho "preadv support    $preadv"
31565f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3157e78815a5SAndreas Färberecho "madvise           $madvise"
3158e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
3159ee682d27SStefan Weilecho "uuid support      $uuid"
316047e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3161d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
316294a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
31639410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
31642e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3165f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3166dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3167111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
316869354a83SHans de Goedeecho "usb net redir     $usb_redir"
316920ff075bSMichael Walleecho "OpenGL support    $opengl"
3170c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3171d138cee9SMichael Rothecho "build guest agent $guest_agent"
3172f794573eSEduardo Otuboecho "seccomp support   $seccomp"
3173519175a2SAlex Barceloecho "coroutine backend $coroutine_backend"
317467b915a5Sbellard
31751ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
317624b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3177e8cd23deSbellardfi
317897a847bcSbellard
317998ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
31804bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
318197a847bcSbellard
318298ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
318398ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
318498ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
318598ec69acSJuan Quintelaecho >> $config_host_mak
318698ec69acSJuan Quintela
3187e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
318899d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
318999d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
31903aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
31918bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
31920f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
319399d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
319499d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
319522d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
31969afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
31979afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
31988bf188aaSMichael Tokarevecho "CONFIG_QEMU_HELPERDIR=\"$libexecdir\"" >> $config_host_mak
3199804edf29SJuan Quintela
320098ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3201f8393946Saurel32if test "$debug_tcg" = "yes" ; then
32022358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3203f8393946Saurel32fi
3204f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
32052358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
3206f3d08ee6SPaul Brookfi
32071625af87Saliguoriif test "$strip_opt" = "yes" ; then
320852ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
32091625af87Saliguorifi
32107d13299dSbellardif test "$bigendian" = "yes" ; then
3211e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
321297a847bcSbellardfi
321367b915a5Sbellardif test "$mingw32" = "yes" ; then
321498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
32159fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
32169fe6de94SBlue Swirl  version_major=${rc_version%%.*}
32179fe6de94SBlue Swirl  rc_version=${rc_version#*.}
32189fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
32199fe6de94SBlue Swirl  rc_version=${rc_version#*.}
32209fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
32219fe6de94SBlue Swirl  version_micro=0
32229fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
32239fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3224210fa556Spbrookelse
322535f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3226210fa556Spbrookfi
3227128ab2ffSblueswir1
3228dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3229dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3230dffcb71cSMark McLoughlinfi
3231dffcb71cSMark McLoughlin
323283fb7adfSbellardif test "$darwin" = "yes" ; then
323398ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
323483fb7adfSbellardfi
3235b29fe3edSmalc
3236b29fe3edSmalcif test "$aix" = "yes" ; then
323798ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
3238b29fe3edSmalcfi
3239b29fe3edSmalc
3240ec530c81Sbellardif test "$solaris" = "yes" ; then
324198ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
32422358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
32430475a5caSths  if test "$needs_libsunmath" = "yes" ; then
324475b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
32450475a5caSths  fi
3246ec530c81Sbellardfi
3247179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3248179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3249179cf400SAndreas Färberfi
325097a847bcSbellardif test "$static" = "yes" ; then
325198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
325297a847bcSbellardfi
32531ba16968SStefan Weilif test "$profiler" = "yes" ; then
32542358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
325505c2a3e7Sbellardfi
3256c20709aaSbellardif test "$slirp" = "yes" ; then
325798ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
3258e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3259f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
3260c20709aaSbellardfi
32618a16d273Sthsif test "$vde" = "yes" ; then
326298ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
32638a16d273Sthsfi
326447e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
326547e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
326647e98658SCorey Bryantfi
32670c58ac1cSmalcfor card in $audio_card_list; do
3268bb55b712SStefan Weil    def=CONFIG_`echo $card | LC_ALL=C tr '[a-z]' '[A-Z]'`
326998ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
32700c58ac1cSmalcdone
32712358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
32720c58ac1cSmalcfor drv in $audio_drv_list; do
3273bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
327498ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
3275923e4521Smalc    if test "$drv" = "fmod"; then
32767aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3277fb065187Sbellard    fi
32780c58ac1cSmalcdone
327967f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
328067f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
328167f86e8eSJuan Quintelafi
3282d5631638Smalcif test "$audio_win_int" = "yes" ; then
3283d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3284d5631638Smalcfi
3285eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
32868ff9cbf7Smalcif test "$mixemu" = "yes" ; then
328798ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
32888ff9cbf7Smalcfi
3289821601eaSJes Sorensenif test "$vnc" = "yes" ; then
3290821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
3291821601eaSJes Sorensenfi
32928d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
329398ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
3294525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
32958d5d2d4cSthsfi
32962f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
329798ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
329860ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
32992f9606b3Saliguorifi
3300821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
33012f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
33022f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
33032f6f5c7aSCorentin Charyfi
3304821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
3305efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3306efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
3307efe556adSCorentin Charyfi
330876655d6dSaliguoriif test "$fnmatch" = "yes" ; then
33092358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
331076655d6dSaliguorifi
3311ee682d27SStefan Weilif test "$uuid" = "yes" ; then
3312ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
3313ee682d27SStefan Weilfi
3314dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3315dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3316dce512deSChristoph Hellwigfi
3317b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
331898ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
33192358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
332098ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
332198ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
3322a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
332398ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
3324cc8ae6deSpbrookfi
33251ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
332698ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
33278ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
332849ecc3faSbellardfi
332949ecc3faSbellardif test "$cocoa" = "yes" ; then
333098ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
333149ecc3faSbellardfi
33324d3b6f6eSbalrogif test "$curses" = "yes" ; then
333398ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
3334ab4e5602SJan Kiszkafi
33353b3f24adSaurel32if test "$atfile" = "yes" ; then
33362358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
33373b3f24adSaurel32fi
3338ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
33392358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3340ebc996f3SRiku Voipiofi
3341099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
33422358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
3343099d6b0fSRiku Voipiofi
334440ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
334540ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
334640ff6d7eSKevin Wolffi
33473ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
33482358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
33493ce34dfbSvibisreenivasanfi
3350c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
3351c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
3352c2882b96SRiku Voipiofi
3353d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
3354d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3355d0927938SUlrich Hechtfi
3356c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
3357c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3358c727f47dSPeter Maydellfi
3359dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
3360dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
3361dace20dcSPeter Maydellfi
3362d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
3363d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
3364d0927938SUlrich Hechtfi
33653b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
33663b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
33673b6edd16SPeter Maydellfi
33683b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
33693b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
33703b6edd16SPeter Maydellfi
33713b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
33723b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
33733b6edd16SPeter Maydellfi
33743b3f24adSaurel32if test "$inotify" = "yes" ; then
33752358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
33763b3f24adSaurel32fi
3377c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3378c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3379c05c7a73SRiku Voipiofi
33806ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
33816ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
33826ae9a1f4SJuan Quintelafi
33836ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
33846ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
33856ae9a1f4SJuan Quintelafi
3386769ce76dSAlexander Grafif test "$curl" = "yes" ; then
338798ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3388b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3389769ce76dSAlexander Graffi
33902e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
339198ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
33922e4d9fb1Saurel32fi
3393fb599c9aSbalrogif test "$bluez" = "yes" ; then
339498ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3395ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3396fb599c9aSbalrogfi
3397e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3398e37630caSaliguoriif test "$xen" = "yes" ; then
33996dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3400d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3401e37630caSaliguorifi
34025c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
34035c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
34045c6c3a6cSChristoph Hellwigfi
3405758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3406758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3407758e8e38SVenkateswararao Jujjuri (JV)fi
34084f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
34094f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
34104f26f2b6SAvi Kivityfi
3411983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
3412758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
3413758e8e38SVenkateswararao Jujjuri (JV)fi
341477755340Sthsif test "$blobs" = "yes" ; then
341598ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
341677755340Sthsfi
3417bf9298b9Saliguoriif test "$iovec" = "yes" ; then
34182358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3419bf9298b9Saliguorifi
3420ceb42de8Saliguoriif test "$preadv" = "yes" ; then
34212358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3422ceb42de8Saliguorifi
3423f652e6afSaurel32if test "$fdt" = "yes" ; then
34243f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3425f652e6afSaurel32fi
3426dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3427dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3428dcc38d1cSMarcelo Tosattifi
34299195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
34309195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
34319195b2c2SStefan Weilfi
34325f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
34335f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
34345f6b9e8fSBlue Swirlfi
3435e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3436e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3437e78815a5SAndreas Färberfi
3438e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3439e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3440e78815a5SAndreas Färberfi
344197a847bcSbellard
3442cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3443cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3444cd4ec0b4SGerd Hoffmannfi
3445cd4ec0b4SGerd Hoffmann
3446020af1c4SAlon Levyif test "$spice_qxl_io_monitors_config_async" = "yes" ; then
3447020af1c4SAlon Levy  echo "CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC=y" >> $config_host_mak
3448020af1c4SAlon Levyfi
3449020af1c4SAlon Levy
345036707144SAlon Levyif test "$smartcard" = "yes" ; then
345136707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
345236707144SAlon Levyfi
345336707144SAlon Levy
3454111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3455111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3456ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3457ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3458111a38b0SRobert Relyeafi
3459111a38b0SRobert Relyea
346069354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
346169354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
346269354a83SHans de Goedefi
346369354a83SHans de Goede
346420ff075bSMichael Walleif test "$opengl" = "yes" ; then
346520ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
346620ff075bSMichael Wallefi
346720ff075bSMichael Walle
3468c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3469c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3470c589b249SRonnie Sahlbergfi
3471c589b249SRonnie Sahlberg
3472f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
3473f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
3474f794573eSEduardo Otubofi
3475f794573eSEduardo Otubo
347683fb7adfSbellard# XXX: suppress that
34777d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
34782358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
34797d3505c5Sbellardfi
34807d3505c5Sbellard
34812358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3482c5937220Spbrook
348320ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
348420ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
348520ff6c80SAnthony Liguorifi
3486f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3487f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3488f27aaf4bSChristian Brunnerfi
348920ff6c80SAnthony Liguori
3490519175a2SAlex Barceloif test "$coroutine_backend" = "ucontext" ; then
3491d0e2fce5SAneesh Kumar K.V  echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
3492fe91bfa8SAlex Barceloelif test "$coroutine_backend" = "sigaltstack" ; then
3493fe91bfa8SAlex Barcelo  echo "CONFIG_SIGALTSTACK_COROUTINE=y" >> $config_host_mak
3494d0e2fce5SAneesh Kumar K.Vfi
3495d0e2fce5SAneesh Kumar K.V
3496d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
3497d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3498d2042378SAneesh Kumar K.Vfi
3499d2042378SAneesh Kumar K.V
3500e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
3501e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3502e06a765eSHarsh Prateek Borafi
3503e06a765eSHarsh Prateek Bora
350406d71fa1SPeter Maydellif test "$pragma_disable_unused_but_set" = "yes" ; then
350506d71fa1SPeter Maydell  echo "CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET=y" >> $config_host_mak
350606d71fa1SPeter Maydellfi
350706d71fa1SPeter Maydell
35083f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
35093f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
35103f4349dcSKevin Wolffi
35113f4349dcSKevin Wolf
35128ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
35138ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
35148ab1bf12SLuiz Capitulinofi
35158ab1bf12SLuiz Capitulino
351668063649Sblueswir1# USB host support
351768063649Sblueswir1case "$usb" in
351868063649Sblueswir1linux)
351998ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
352068063649Sblueswir1;;
352168063649Sblueswir1bsd)
352298ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
352368063649Sblueswir1;;
352468063649Sblueswir1*)
352598ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
352668063649Sblueswir1;;
352768063649Sblueswir1esac
352868063649Sblueswir1
3529e4858974SLluís# use default implementation for tracing backend-specific routines
3530e4858974SLluístrace_default=yes
353194a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
35326d8a764eSLluísif test "$trace_backend" = "nop"; then
35336d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
353422890ab5SPrerna Saxenafi
35359410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
35366d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
3537e4858974SLluís  trace_default=no
35386d8a764eSLluís  # Set the appropriate trace file.
3539953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
35409410b56cSPrerna Saxenafi
35416d8a764eSLluísif test "$trace_backend" = "stderr"; then
35426d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
35439a82b6a5SLluís  trace_default=no
35446d8a764eSLluísfi
35456d8a764eSLluísif test "$trace_backend" = "ust"; then
35466d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
35476d8a764eSLluísfi
35486d8a764eSLluísif test "$trace_backend" = "dtrace"; then
35496d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
35506d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
35516d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
35526d8a764eSLluís  fi
3553c276b17dSDaniel P. Berrangefi
35549410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
3555e4858974SLluísif test "$trace_default" = "yes"; then
3556e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3557e4858974SLluísfi
35589410b56cSPrerna Saxena
355998ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
356098ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3561804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3562804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
35631901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
35641901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
35651901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
3566c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
3567804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
35682b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3569804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
35703c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
3571804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3572804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3573804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
35749fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
357544dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3576e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3577a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3578f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3579e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3580e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3581e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3582e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3583e39f0062SPaolo Bonzinifi
3584c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
3585e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3586a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3587a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
358873da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
35893e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3590804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3591957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
359294dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
3593804edf29SJuan Quintela
35944bf6b55bSJuan Quintela# generate list of library paths for linker script
35954bf6b55bSJuan Quintela
35964bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
35974bf6b55bSJuan Quintela
35984bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
35994bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
36004bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
36014bf6b55bSJuan Quintela  else
36024bf6b55bSJuan Quintela    rm ${config_host_ld}~
36034bf6b55bSJuan Quintela  fi
36044bf6b55bSJuan Quintelafi
36054bf6b55bSJuan Quintela
36064d904533SBlue Swirlfor d in libdis libdis-user; do
360772b8b5a1SStefan Weil    symlink "$source_path/Makefile.dis" "$d/Makefile"
36084d904533SBlue Swirl    echo > $d/config.mak
36094d904533SBlue Swirldone
36104d904533SBlue Swirl
36116efd7517SPeter Maydell# use included Linux headers
36126efd7517SPeter Maydellif test "$linux" = "yes" ; then
3613a307beb6SAndreas Färber  mkdir -p linux-headers
36146efd7517SPeter Maydell  case "$cpu" in
36156efd7517SPeter Maydell  i386|x86_64)
361608312a63SPeter Maydell    linux_arch=x86
36176efd7517SPeter Maydell    ;;
36186efd7517SPeter Maydell  ppcemb|ppc|ppc64)
361908312a63SPeter Maydell    linux_arch=powerpc
36206efd7517SPeter Maydell    ;;
36216efd7517SPeter Maydell  s390x)
362208312a63SPeter Maydell    linux_arch=s390
362308312a63SPeter Maydell    ;;
362408312a63SPeter Maydell  *)
362508312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
362608312a63SPeter Maydell    linux_arch="$cpu"
36276efd7517SPeter Maydell    ;;
36286efd7517SPeter Maydell  esac
362908312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
363008312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
363108312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
363208312a63SPeter Maydell    fi
36336efd7517SPeter Maydellfi
36346efd7517SPeter Maydell
363597a847bcSbellardfor target in $target_list; do
363697a847bcSbellardtarget_dir="$target"
363725be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3638600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
363997a847bcSbellardtarget_bigendian="no"
36401f3d3c8fSJuan Quintela
3641ea2d6a39SJuan Quintelacase "$target_arch2" in
3642e67db06eSJia Liu  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
3643ea2d6a39SJuan Quintela  target_bigendian=yes
3644ea2d6a39SJuan Quintela  ;;
3645ea2d6a39SJuan Quintelaesac
364697a847bcSbellardtarget_softmmu="no"
3647997344f3Sbellardtarget_user_only="no"
3648831b7825Sthstarget_linux_user="no"
364984778508Sblueswir1target_bsd_user="no"
36509e407a85Spbrookcase "$target" in
3651600309b6SBlue Swirl  ${target_arch2}-softmmu)
36529e407a85Spbrook    target_softmmu="yes"
36539e407a85Spbrook    ;;
3654600309b6SBlue Swirl  ${target_arch2}-linux-user)
36559c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
36569c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
36579c7a4202SBlue Swirl      exit 1
36589c7a4202SBlue Swirl    fi
36599e407a85Spbrook    target_user_only="yes"
36609e407a85Spbrook    target_linux_user="yes"
36619e407a85Spbrook    ;;
3662600309b6SBlue Swirl  ${target_arch2}-bsd-user)
36639cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
36649c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
36659c7a4202SBlue Swirl      exit 1
36669c7a4202SBlue Swirl    fi
366784778508Sblueswir1    target_user_only="yes"
366884778508Sblueswir1    target_bsd_user="yes"
366984778508Sblueswir1    ;;
36709e407a85Spbrook  *)
36719e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
36729e407a85Spbrook    exit 1
36739e407a85Spbrook    ;;
36749e407a85Spbrookesac
3675831b7825Sths
367697a847bcSbellardmkdir -p $target_dir
367725be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
367897a847bcSbellard
3679e5fe0c52Spbrookbflt="no"
3680bd0c5661Spbrooktarget_nptl="no"
3681600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
368256aebc89Spbrookgdb_xml_files=""
3683c2e3dee6SLaurent Viviertarget_short_alignment=2
3684c2e3dee6SLaurent Viviertarget_int_alignment=4
3685c2e3dee6SLaurent Viviertarget_long_alignment=4
3686c2e3dee6SLaurent Viviertarget_llong_alignment=8
3687de3a354aSMichael Walletarget_libs_softmmu=
36887ba1e619Saliguori
3689938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
36906acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3691e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3692e73aae67SJuan Quintela
3693600309b6SBlue Swirlcase "$target_arch2" in
36942408a527Saurel32  i386)
369571deff27SAurelien Jarno    target_phys_bits=64
36962408a527Saurel32  ;;
36972408a527Saurel32  x86_64)
36986acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
36991ad2134fSPaul Brook    target_phys_bits=64
3700c2e3dee6SLaurent Vivier    target_long_alignment=8
37012408a527Saurel32  ;;
37022408a527Saurel32  alpha)
37031ad2134fSPaul Brook    target_phys_bits=64
3704c2e3dee6SLaurent Vivier    target_long_alignment=8
3705a4b388ffSRichard Henderson    target_nptl="yes"
37062408a527Saurel32  ;;
37072408a527Saurel32  arm|armeb)
3708b498c8a0SJuan Quintela    TARGET_ARCH=arm
3709e5fe0c52Spbrook    bflt="yes"
3710bd0c5661Spbrook    target_nptl="yes"
371156aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
37123cc0cd61SPeter Maydell    target_phys_bits=64
3713c2e3dee6SLaurent Vivier    target_llong_alignment=4
3714412beee6SGrant Likely    target_libs_softmmu="$fdt_libs"
37152408a527Saurel32  ;;
37162408a527Saurel32  cris)
3717253bd7f8Sedgar_igl    target_nptl="yes"
37181ad2134fSPaul Brook    target_phys_bits=32
37192408a527Saurel32  ;;
3720613a22c9SMichael Walle  lm32)
3721613a22c9SMichael Walle    target_phys_bits=32
3722de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3723613a22c9SMichael Walle  ;;
37242408a527Saurel32  m68k)
37250938cda5Saurel32    bflt="yes"
372656aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
37271ad2134fSPaul Brook    target_phys_bits=32
3728c2e3dee6SLaurent Vivier    target_int_alignment=2
3729c2e3dee6SLaurent Vivier    target_long_alignment=2
3730c2e3dee6SLaurent Vivier    target_llong_alignment=2
37312408a527Saurel32  ;;
3732877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3733877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
373472b675caSEdgar E. Iglesias    bflt="yes"
373572b675caSEdgar E. Iglesias    target_nptl="yes"
373672b675caSEdgar E. Iglesias    target_phys_bits=32
3737de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
373872b675caSEdgar E. Iglesias  ;;
37392408a527Saurel32  mips|mipsel)
3740b498c8a0SJuan Quintela    TARGET_ARCH=mips
374125be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3742f04dc72fSPaul Brook    target_nptl="yes"
37431ad2134fSPaul Brook    target_phys_bits=64
37442408a527Saurel32  ;;
37452408a527Saurel32  mipsn32|mipsn32el)
3746b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
37476acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
374825be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
37491ad2134fSPaul Brook    target_phys_bits=64
37502408a527Saurel32  ;;
37512408a527Saurel32  mips64|mips64el)
3752b498c8a0SJuan Quintela    TARGET_ARCH=mips64
37536acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
375425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
37551ad2134fSPaul Brook    target_phys_bits=64
3756c2e3dee6SLaurent Vivier    target_long_alignment=8
37572408a527Saurel32  ;;
3758e67db06eSJia Liu  or32)
3759e67db06eSJia Liu    TARGET_ARCH=openrisc
3760e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
3761e67db06eSJia Liu    target_phys_bits=32
3762e67db06eSJia Liu  ;;
37632408a527Saurel32  ppc)
3764c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
37658b242ebaSAlexander Graf    target_phys_bits=64
3766d6630708SNathan Froyd    target_nptl="yes"
3767de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37682408a527Saurel32  ;;
37692408a527Saurel32  ppcemb)
37706acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3771e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3772c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
37731ad2134fSPaul Brook    target_phys_bits=64
3774d6630708SNathan Froyd    target_nptl="yes"
3775de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37762408a527Saurel32  ;;
37772408a527Saurel32  ppc64)
37786acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3779e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3780c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
37811ad2134fSPaul Brook    target_phys_bits=64
3782c2e3dee6SLaurent Vivier    target_long_alignment=8
3783de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37842408a527Saurel32  ;;
37852408a527Saurel32  ppc64abi32)
3786b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
37876acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3788e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
378925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3790c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
37911ad2134fSPaul Brook    target_phys_bits=64
3792de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37932408a527Saurel32  ;;
37942408a527Saurel32  sh4|sh4eb)
3795b498c8a0SJuan Quintela    TARGET_ARCH=sh4
37964dbed897Spbrook    bflt="yes"
37970b6d3ae0Saurel32    target_nptl="yes"
37981ad2134fSPaul Brook    target_phys_bits=32
37992408a527Saurel32  ;;
38002408a527Saurel32  sparc)
38011ad2134fSPaul Brook    target_phys_bits=64
38022408a527Saurel32  ;;
38032408a527Saurel32  sparc64)
38046acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
38051ad2134fSPaul Brook    target_phys_bits=64
3806c2e3dee6SLaurent Vivier    target_long_alignment=8
38072408a527Saurel32  ;;
38082408a527Saurel32  sparc32plus)
3809b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
38106acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3811e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
381225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
38131ad2134fSPaul Brook    target_phys_bits=64
38142408a527Saurel32  ;;
381524e804ecSAlexander Graf  s390x)
3816bc434676SUlrich Hecht    target_nptl="yes"
381724e804ecSAlexander Graf    target_phys_bits=64
38187b3da903SAlexander Graf    target_long_alignment=8
381924e804ecSAlexander Graf  ;;
3820d2fbca94SGuan Xuetao  unicore32)
3821d2fbca94SGuan Xuetao    target_phys_bits=32
3822d2fbca94SGuan Xuetao  ;;
3823cfa550c6SMax Filippov  xtensa|xtensaeb)
3824cfa550c6SMax Filippov    TARGET_ARCH=xtensa
3825cfa550c6SMax Filippov    target_phys_bits=32
3826cfa550c6SMax Filippov  ;;
38272408a527Saurel32  *)
3828de83cd02Sbellard    echo "Unsupported target CPU"
3829de83cd02Sbellard    exit 1
38302408a527Saurel32  ;;
38312408a527Saurel32esac
38325e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
38335e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
38345e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
38355e8861a0SPaolo Bonzinifi
38365e8861a0SPaolo Bonzini
38375e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
38385e8861a0SPaolo Bonzini
38390184e266SBlue Swirl
38400184e266SBlue Swirlcase "$target_arch2" in
384119b0516fSBlue Swirl  alpha | i386 | or32 | s390x | sparc* | x86_64 | xtensa* | ppc*)
38420184e266SBlue Swirl    echo "CONFIG_TCG_PASS_AREG0=y" >> $config_target_mak
38430184e266SBlue Swirl  ;;
38440184e266SBlue Swirlesac
38450184e266SBlue Swirl
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
386764b3cfdbSAnthony PERARD      target_phys_bits=64
386825be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
3869eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
3870eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
3871eb6fda0fSAnthony PERARD      fi
387259d21e53SAlexander Graf    else
387359d21e53SAlexander Graf      echo "CONFIG_NO_XEN=y" >> $config_target_mak
3874432d268cSJun Nakajima    fi
387559d21e53SAlexander Graf    ;;
387659d21e53SAlexander Graf  *)
387759d21e53SAlexander Graf    echo "CONFIG_NO_XEN=y" >> $config_target_mak
38781b0c87fcSJuan Quintelaesac
3879c59249f9SJuan Quintelacase "$target_arch2" in
38800e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3881c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3882c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3883c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3884c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
38855f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3886adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3887adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3888c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3889c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
389025be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
38911ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
3892d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3893d5970055SMichael S. Tsirkin      fi
3894c59249f9SJuan Quintela    fi
3895c59249f9SJuan Quintelaesac
3896fae001f5SWen Congyangcase "$target_arch2" in
3897fae001f5SWen Congyang  i386|x86_64)
3898fae001f5SWen Congyang    echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
3899fae001f5SWen Congyangesac
39007f762366SBlue Swirlif test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then
39010a6b8ddeSAlexander Graf  echo "CONFIG_PSERIES=y" >> $config_target_mak
39020a6b8ddeSAlexander Graffi
3903de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
390425be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
390597a847bcSbellardfi
390697a847bcSbellardif test "$target_softmmu" = "yes" ; then
3907b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
390825be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3909de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
39100e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
39115791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3912ad4cf3f6SPaul Brook  if test "$smartcard_nss" = "yes" ; then
3913ad4cf3f6SPaul Brook    echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3914ad4cf3f6SPaul Brook  fi
39159fecbed0SWen Congyang  case "$target_arch2" in
39169fecbed0SWen Congyang    i386|x86_64)
39179fecbed0SWen Congyang      echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
39189fecbed0SWen Congyang  esac
3919de83cd02Sbellardfi
3920997344f3Sbellardif test "$target_user_only" = "yes" ; then
392125be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3922a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
3923997344f3Sbellardfi
3924831b7825Sthsif test "$target_linux_user" = "yes" ; then
392525be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3926831b7825Sthsfi
392756aebc89Spbrooklist=""
392856aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
392956aebc89Spbrook  for x in $gdb_xml_files; do
393056aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
393156aebc89Spbrook  done
393225be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
39333d0f1517SJuan Quintelafi
3934de83cd02Sbellard
3935e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
393625be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3937e5fe0c52Spbrookfi
3938bd0c5661Spbrookif test "$target_user_only" = "yes" \
3939bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
394025be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3941bd0c5661Spbrookfi
3942379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
394325be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3944379f6698SPaul Brookfi
394584778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
394625be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
394784778508Sblueswir1fi
39485b0753e0Sbellard
39495a4d701aSJan Kiszka# the static way of configuring available audio cards requires this workaround
39505a4d701aSJan Kiszkaif test "$target_user_only" != "yes" && grep -q CONFIG_PCSPK $source_path/default-configs/$target.mak; then
39515a4d701aSJan Kiszka  echo "CONFIG_PCSPK=y" >> $config_target_mak
39525a4d701aSJan Kiszkafi
39535a4d701aSJan Kiszka
39544afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3955fa282484SJuan Quintela
39564afddb55SJuan Quintelacflags=""
3957f9728943SPaolo Bonziniincludes=""
3958fa282484SJuan Quintelaldflags=""
39599b8e111fSJuan Quintela
39609195b2c2SStefan Weilif test "$tcg_interpreter" = "yes"; then
39619195b2c2SStefan Weil  includes="-I\$(SRC_PATH)/tcg/tci $includes"
39629195b2c2SStefan Weilelif test "$ARCH" = "sparc64" ; then
3963f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
396424e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3965f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
39665d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3967f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
396857ddfbf7SJuan Quintelaelse
3969f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
397057ddfbf7SJuan Quintelafi
3971f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
397257ddfbf7SJuan Quintela
39736efd7517SPeter Maydellif test "$linux" = "yes" ; then
39746efd7517SPeter Maydell  includes="-I\$(SRC_PATH)/linux-headers $includes"
39756efd7517SPeter Maydellfi
39766efd7517SPeter Maydell
39774d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
39784d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
39794d904533SBlue Swirlelse
39804d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
39814d904533SBlue Swirlfi
39824d904533SBlue Swirl
398364656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
398464656024SJuan Quintela  case "$i" in
398564656024SJuan Quintela  alpha)
398625be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
39874d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
398864656024SJuan Quintela  ;;
398964656024SJuan Quintela  arm)
399025be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
39914d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
399264656024SJuan Quintela  ;;
399364656024SJuan Quintela  cris)
399425be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
39954d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
399664656024SJuan Quintela  ;;
399764656024SJuan Quintela  hppa)
399825be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
39994d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
400064656024SJuan Quintela  ;;
400164656024SJuan Quintela  i386|x86_64)
400225be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
40034d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
400464656024SJuan Quintela  ;;
4005903ec55cSAurelien Jarno  ia64*)
4006903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
4007903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
4008903ec55cSAurelien Jarno  ;;
400979368f49SMichael Walle  lm32)
401079368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
401179368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $libdis_config_mak
401279368f49SMichael Walle  ;;
401364656024SJuan Quintela  m68k)
401425be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
40154d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
401664656024SJuan Quintela  ;;
4017877fdc12SEdgar E. Iglesias  microblaze*)
401825be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
40194d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
402064656024SJuan Quintela  ;;
402164656024SJuan Quintela  mips*)
402225be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
40234d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
402464656024SJuan Quintela  ;;
4025e67db06eSJia Liu  or32)
4026e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
4027e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $libdis_config_mak
4028e67db06eSJia Liu  ;;
402964656024SJuan Quintela  ppc*)
403025be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
40314d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
403264656024SJuan Quintela  ;;
403324e804ecSAlexander Graf  s390*)
403425be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
40354d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
403664656024SJuan Quintela  ;;
403764656024SJuan Quintela  sh4)
403825be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
40394d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
404064656024SJuan Quintela  ;;
404164656024SJuan Quintela  sparc*)
404225be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
40434d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
404464656024SJuan Quintela  ;;
4045cfa550c6SMax Filippov  xtensa*)
4046cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
4047cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $libdis_config_mak
4048cfa550c6SMax Filippov  ;;
404964656024SJuan Quintela  esac
405064656024SJuan Quinteladone
40519195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
40529195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
40539195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $libdis_config_mak
40549195b2c2SStefan Weilfi
405564656024SJuan Quintela
40566ee7126fSJuan Quintelacase "$ARCH" in
40576ee7126fSJuan Quintelaalpha)
40586ee7126fSJuan Quintela  # Ensure there's only a single GP
40596ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
40606ee7126fSJuan Quintela;;
40616ee7126fSJuan Quintelaesac
40626ee7126fSJuan Quintela
406355d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
406455d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
406555d9c04bSJuan Quintela  arm)
406655d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
406755d9c04bSJuan Quintela  ;;
406825a8bb96SMichael Walle  lm32)
406925a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
407025a8bb96SMichael Walle  ;;
407155d9c04bSJuan Quintela  i386|mips|ppc)
407255d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
407355d9c04bSJuan Quintela  ;;
407455d9c04bSJuan Quintela  esac
407555d9c04bSJuan Quintelafi
407655d9c04bSJuan Quintela
4077d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
407825be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4079d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4080d02c1db3SJuan Quintela    cflags="-p $cflags"
4081d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4082d02c1db3SJuan Quintela  fi
4083d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4084d02c1db3SJuan Quintela    ldflags="-p $ldflags"
408525be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4086d02c1db3SJuan Quintela  fi
4087d02c1db3SJuan Quintelafi
4088d02c1db3SJuan Quintela
40899195b2c2SStefan Weilif test "$ARCH" = "tci"; then
40909195b2c2SStefan Weil  linker_script=""
40919195b2c2SStefan Weilelse
40926ee7126fSJuan Quintela  linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
40939195b2c2SStefan Weilfi
40949195b2c2SStefan Weil
40959b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4096fa282484SJuan Quintela  case "$ARCH" in
4097fa282484SJuan Quintela  sparc)
4098fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
4099322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
4100fa282484SJuan Quintela    ;;
41014d58be06SRichard Henderson  alpha | s390x)
41024d58be06SRichard Henderson    # The default placement of the application is fine.
41034d58be06SRichard Henderson    ;;
4104fd76e73aSRichard Henderson  *)
4105322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
4106fa282484SJuan Quintela    ;;
4107fa282484SJuan Quintela  esac
4108fa282484SJuan Quintelafi
4109fa282484SJuan Quintela
411025be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
411125be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4112f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
4113fa282484SJuan Quintela
411497a847bcSbellarddone # for target in $targets
41157d13299dSbellard
4116d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
4117927b241dSMichael WalleDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32"
41182dee8d54SPaolo BonziniDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
41192d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
41202dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
412100c705fbSPaolo BonziniDIRS="$DIRS libcacard libcacard/libcacard libcacard/trace"
4122c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4123c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
412400c705fbSPaolo BonziniFILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile"
4125ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4126446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
41272d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4128753d11f2SRichard Hendersonfor bios_file in \
4129753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
4130753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4131753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4132753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4133753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4134753d11f2SRichard Hendersondo
41357ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
41367ea78b74SJan Kiszkadone
4137d1807a4fSPaolo Bonzinimkdir -p $DIRS
41387d13299dSbellardfor f in $FILES ; do
413972b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4140f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4141f9245e10SPeter Maydell    fi
41427d13299dSbellarddone
41431ad2134fSPaul Brook
4144c34ebfdcSAnthony Liguori# temporary config to build submodules
41452d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4146c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
414737116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4148c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
4149c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4150c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
4151c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
4152c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4153c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
4154c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4155c34ebfdcSAnthony Liguoridone
4156c34ebfdcSAnthony Liguori
41571ad2134fSPaul Brookfor hwlib in 32 64; do
41581ad2134fSPaul Brook  d=libhw$hwlib
415972b8b5a1SStefan Weil  symlink "$source_path/Makefile.hw" "$d/Makefile"
416037116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
41611ad2134fSPaul Brookdone
4162add16157SBlue Swirl
4163add16157SBlue Swirld=libuser
416472b8b5a1SStefan Weilsymlink "$source_path/Makefile.user" "$d/Makefile"
4165b40292e7SJan Kiszka
4166b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4167b40292e7SJan Kiszka  mkdir -p QMP
4168b40292e7SJan Kiszkafi
4169