xref: /openbmc/qemu/configure (revision be4a892846651e06dbbd9a48aa877f4e0397d01e)
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
13066d5499bSDaniel 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"
2204b1c11fdSDaniel P. Berrangewant_tools="yes"
221c589b249SRonnie Sahlberglibiscsi=""
222519175a2SAlex Barcelocoroutine=""
223f794573eSEduardo Otuboseccomp=""
224377529c0SPaolo Bonzini
225ac0df51dSaliguori# parse CC options first
226ac0df51dSaliguorifor opt do
227ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
228ac0df51dSaliguori  case "$opt" in
229ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
230ac0df51dSaliguori  ;;
2313d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
232ac0df51dSaliguori  ;;
233ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
234ca4deeb1SPaolo Bonzini  ;;
2352ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2362ff6b91eSJuan Quintela  ;;
237a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
238e2a2ed06SJuan Quintela  ;;
239e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
240e2a2ed06SJuan Quintela  ;;
2415bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
2425bc62e01SGerd Hoffmann  ;;
2435bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
2445bc62e01SGerd Hoffmann  ;;
24550e7b1a0SJuan Quintela  --sparc_cpu=*)
24650e7b1a0SJuan Quintela    sparc_cpu="$optarg"
24750e7b1a0SJuan Quintela    case $sparc_cpu in
248ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
24950e7b1a0SJuan Quintela      cpu="sparc"
25050e7b1a0SJuan Quintela    ;;
25150e7b1a0SJuan Quintela    v9)
25250e7b1a0SJuan Quintela      cpu="sparc64"
25350e7b1a0SJuan Quintela    ;;
25450e7b1a0SJuan Quintela    *)
25550e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
25650e7b1a0SJuan Quintela      exit 1
25750e7b1a0SJuan Quintela    ;;
25850e7b1a0SJuan Quintela    esac
25950e7b1a0SJuan Quintela  ;;
260ac0df51dSaliguori  esac
261ac0df51dSaliguoridone
262ac0df51dSaliguori# OS specific
263ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
26493148aa5SStefan Weil# we can eliminate its usage altogether.
265ac0df51dSaliguori
266b3198cc2SStuart Yodercc="${CC-${cross_prefix}gcc}"
267b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
268b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
269b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
2703f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
271b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
272b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
27317884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
27417884d7bSSergei Trofimovichquery_pkg_config() {
27517884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
27617884d7bSSergei Trofimovich}
27717884d7bSSergei Trofimovichpkg_config=query_pkg_config
278b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
279ac0df51dSaliguori
280be17dc90SMichael S. Tsirkin# default flags for all hosts
281be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
282f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
283be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
284be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
285cbbab922SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu"
2865bc62e01SGerd Hoffmannif test "$debug_info" = "yes"; then
2875bc62e01SGerd Hoffmann    CFLAGS="-g $CFLAGS"
288be17dc90SMichael S. Tsirkin    LDFLAGS="-g $LDFLAGS"
2895bc62e01SGerd Hoffmannfi
290be17dc90SMichael S. Tsirkin
291ca4deeb1SPaolo Bonzini# make source path absolute
292ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
293ca4deeb1SPaolo Bonzini
294ac0df51dSaliguoricheck_define() {
295ac0df51dSaliguoricat > $TMPC <<EOF
296ac0df51dSaliguori#if !defined($1)
297fd786e1aSPeter Maydell#error $1 not defined
298ac0df51dSaliguori#endif
299ac0df51dSaliguoriint main(void) { return 0; }
300ac0df51dSaliguoriEOF
30152166aa0SJuan Quintela  compile_object
302ac0df51dSaliguori}
303ac0df51dSaliguori
304bbea4050SPeter Maydellif check_define __linux__ ; then
305bbea4050SPeter Maydell  targetos="Linux"
306bbea4050SPeter Maydellelif check_define _WIN32 ; then
307bbea4050SPeter Maydell  targetos='MINGW32'
308bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
309bbea4050SPeter Maydell  targetos='OpenBSD'
310bbea4050SPeter Maydellelif check_define __sun__ ; then
311bbea4050SPeter Maydell  targetos='SunOS'
312bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
313bbea4050SPeter Maydell  targetos='Haiku'
314bbea4050SPeter Maydellelse
315bbea4050SPeter Maydell  targetos=`uname -s`
316bbea4050SPeter Maydellfi
317bbea4050SPeter Maydell
318bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
319bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
320bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
321bbea4050SPeter Maydell# the correct CPU with the --cpu option.
322bbea4050SPeter Maydellcase $targetos in
323bbea4050SPeter MaydellDarwin)
324bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
325bbea4050SPeter Maydell  # run 64-bit userspace code.
326bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
327bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
328bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
329bbea4050SPeter Maydell    cpu="x86_64"
330bbea4050SPeter Maydell  fi
331bbea4050SPeter Maydell  ;;
332bbea4050SPeter MaydellSunOS)
333bbea4050SPeter Maydell  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
334bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
335bbea4050SPeter Maydell    cpu="x86_64"
336bbea4050SPeter Maydell  fi
337bbea4050SPeter Maydellesac
338bbea4050SPeter Maydell
3392ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
3402ff6b91eSJuan Quintela  # command line argument
3412ff6b91eSJuan Quintela  :
3422ff6b91eSJuan Quintelaelif check_define __i386__ ; then
343ac0df51dSaliguori  cpu="i386"
344ac0df51dSaliguorielif check_define __x86_64__ ; then
345ac0df51dSaliguori  cpu="x86_64"
3463aa9bd6cSblueswir1elif check_define __sparc__ ; then
3473aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
3483aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
3493aa9bd6cSblueswir1  if check_define __arch64__ ; then
3503aa9bd6cSblueswir1    cpu="sparc64"
3513aa9bd6cSblueswir1  else
3523aa9bd6cSblueswir1    cpu="sparc"
3533aa9bd6cSblueswir1  fi
354fdf7ed96Smalcelif check_define _ARCH_PPC ; then
355fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
356fdf7ed96Smalc    cpu="ppc64"
357ac0df51dSaliguori  else
358fdf7ed96Smalc    cpu="ppc"
359fdf7ed96Smalc  fi
360afa05235SAurelien Jarnoelif check_define __mips__ ; then
361afa05235SAurelien Jarno  cpu="mips"
362477ba620SAurelien Jarnoelif check_define __ia64__ ; then
363477ba620SAurelien Jarno  cpu="ia64"
364d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
365d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
366d66ed0eaSAurelien Jarno    cpu="s390x"
367d66ed0eaSAurelien Jarno  else
368d66ed0eaSAurelien Jarno    cpu="s390"
369d66ed0eaSAurelien Jarno  fi
37021d89f84SPeter Maydellelif check_define __arm__ ; then
37121d89f84SPeter Maydell  cpu="arm"
372f28ffed5SBradelif check_define __hppa__ ; then
373f28ffed5SBrad  cpu="hppa"
374fdf7ed96Smalcelse
375fdf7ed96Smalc  cpu=`uname -m`
376ac0df51dSaliguorifi
377ac0df51dSaliguori
378359bc95dSPeter MaydellARCH=
379359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
380359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
3817d13299dSbellardcase "$cpu" in
382359bc95dSPeter Maydell  ia64|ppc|ppc64|s390|s390x|sparc64)
383ea8f20f8SJuan Quintela    cpu="$cpu"
384ea8f20f8SJuan Quintela  ;;
3857d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
38697a847bcSbellard    cpu="i386"
3877d13299dSbellard  ;;
388aaa5fa14Saurel32  x86_64|amd64)
389aaa5fa14Saurel32    cpu="x86_64"
390aaa5fa14Saurel32  ;;
39121d89f84SPeter Maydell  armv*b|armv*l|arm)
39221d89f84SPeter Maydell    cpu="arm"
3937d13299dSbellard  ;;
394f28ffed5SBrad  hppa|parisc|parisc64)
395f54b3f92Saurel32    cpu="hppa"
396f54b3f92Saurel32  ;;
397afa05235SAurelien Jarno  mips*)
398afa05235SAurelien Jarno    cpu="mips"
399afa05235SAurelien Jarno  ;;
4003142255cSblueswir1  sparc|sun4[cdmuv])
401ae228531Sbellard    cpu="sparc"
402ae228531Sbellard  ;;
4037d13299dSbellard  *)
404359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
405359bc95dSPeter Maydell    ARCH=unknown
4067d13299dSbellard  ;;
4077d13299dSbellardesac
408359bc95dSPeter Maydellif test -z "$ARCH"; then
409359bc95dSPeter Maydell  ARCH="$cpu"
410359bc95dSPeter Maydellfi
411e2d52ad3SJuan Quintela
4127d13299dSbellard# OS specific
4130dbfc675SJuan Quintela
4147d13299dSbellardcase $targetos in
415c326e0afSbellardCYGWIN*)
416c326e0afSbellard  mingw32="yes"
417a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
418d5631638Smalc  audio_possible_drivers="winwave sdl"
419d5631638Smalc  audio_drv_list="winwave"
420c326e0afSbellard;;
42167b915a5SbellardMINGW32*)
42267b915a5Sbellard  mingw32="yes"
423d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
424d5631638Smalc  audio_drv_list="winwave"
42567b915a5Sbellard;;
4265c40d2bdSthsGNU/kFreeBSD)
427a167ba50SAurelien Jarno  bsd="yes"
4280c58ac1cSmalc  audio_drv_list="oss"
429f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
4305c40d2bdSths;;
4317d3505c5SbellardFreeBSD)
4327d3505c5Sbellard  bsd="yes"
4330db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4340c58ac1cSmalc  audio_drv_list="oss"
435f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
436f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
437f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
4387d3505c5Sbellard;;
439c5e97233Sblueswir1DragonFly)
440c5e97233Sblueswir1  bsd="yes"
4410db4a067SPaolo Bonzini  make="${MAKE-gmake}"
442c5e97233Sblueswir1  audio_drv_list="oss"
443c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
444c5e97233Sblueswir1;;
4457d3505c5SbellardNetBSD)
4467d3505c5Sbellard  bsd="yes"
4470db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4480c58ac1cSmalc  audio_drv_list="oss"
449c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4508ef92a88Sblueswir1  oss_lib="-lossaudio"
4517d3505c5Sbellard;;
4527d3505c5SbellardOpenBSD)
4537d3505c5Sbellard  bsd="yes"
4540db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4550c58ac1cSmalc  audio_drv_list="oss"
456c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
4572f6a1ab0Sblueswir1  oss_lib="-lossaudio"
4587d3505c5Sbellard;;
45983fb7adfSbellardDarwin)
46083fb7adfSbellard  bsd="yes"
46183fb7adfSbellard  darwin="yes"
4621b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
463a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4640c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4651b0f9cc2Saliguori  else
466a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
4671b0f9cc2Saliguori  fi
468fd677642Sths  cocoa="yes"
4690c58ac1cSmalc  audio_drv_list="coreaudio"
470c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4710c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4727973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
473a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
474a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
475a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
47683fb7adfSbellard;;
477ec530c81SbellardSunOS)
478ec530c81Sbellard  solaris="yes"
4790db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4800db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
481fa58948dSBlue Swirl  ld="gld"
482e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
4830475a5caSths  needs_libsunmath="no"
484c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
485c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4860475a5caSths    if test "$solarisrev" -le 9 ; then
4870475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4880475a5caSths        needs_libsunmath="yes"
489f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
490f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
491f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4920475a5caSths      else
4930475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4940475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4950475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4960475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4970475a5caSths        exit 1
4980475a5caSths      fi
4990475a5caSths    fi
50086b2bd93Sths  fi
5016b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
5020c58ac1cSmalc    audio_drv_list="oss"
5036b4d2ba1Sths  fi
504c2de5c91Smalc  audio_possible_drivers="oss sdl"
505d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
506d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
507d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
508d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
509a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
510560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
511560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
512560d375fSAndreas Färber  libs_qga="$solarisnetlibs $libs_qga"
513ec530c81Sbellard;;
514b29fe3edSmalcAIX)
515b29fe3edSmalc  aix="yes"
5160db4a067SPaolo Bonzini  make="${MAKE-gmake}"
517b29fe3edSmalc;;
518179cf400SAndreas FärberHaiku)
519179cf400SAndreas Färber  haiku="yes"
520179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
521179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
522179cf400SAndreas Färber;;
523fb065187Sbellard*)
5240c58ac1cSmalc  audio_drv_list="oss"
525b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
5265327cf48Sbellard  linux="yes"
527831b7825Sths  linux_user="yes"
52868063649Sblueswir1  usb="linux"
529af2be207SJan Kiszka  kvm="yes"
530af2be207SJan Kiszka  vhost_net="yes"
53107f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
532c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
533c9ec1fe4Sbellard  fi
534fb065187Sbellard;;
5357d13299dSbellardesac
5367d13299dSbellard
5377d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
538b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
53968063649Sblueswir1    usb="bsd"
54084778508Sblueswir1    bsd_user="yes"
5417d3505c5Sbellard  fi
54208de3949SAndreas Färberfi
5437d3505c5Sbellard
5440db4a067SPaolo Bonzini: ${make=${MAKE-make}}
5450db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
546c886edfbSBlue Swirl: ${python=${PYTHON-python}}
547e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
5480db4a067SPaolo Bonzini
5493c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
5503c4a4d0dSPeter Maydellif has clang; then
5513c4a4d0dSPeter Maydell  objcc=clang
5523c4a4d0dSPeter Maydellelse
5533c4a4d0dSPeter Maydell  objcc="$cc"
5543c4a4d0dSPeter Maydellfi
5553c4a4d0dSPeter Maydell
5563457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
5573457a3f8SJuan Quintela  EXESUF=".exe"
558a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
559e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
560e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
561f7cf5d5bSStefan Weil  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
562f7cf5d5bSStefan Weilcat > $TMPC << EOF
563f7cf5d5bSStefan Weilint main(void) { return 0; }
564f7cf5d5bSStefan WeilEOF
565f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
566f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
567f7cf5d5bSStefan Weil  fi
568c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
569683035deSPaolo Bonzini  mandir="\${prefix}"
570528ae5b8SEduardo Habkost  datadir="\${prefix}"
571850da188SEduardo Habkost  qemu_docdir="\${prefix}"
572683035deSPaolo Bonzini  bindir="\${prefix}"
573683035deSPaolo Bonzini  sysconfdir="\${prefix}"
574683035deSPaolo Bonzini  confsuffix=""
575368542b8SStefan Hajnoczi  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
5763457a3f8SJuan Quintelafi
5773457a3f8SJuan Quintela
578487fefdbSAnthony Liguoriwerror=""
57985aa5189Sbellard
5807d13299dSbellardfor opt do
581a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
5827d13299dSbellard  case "$opt" in
5832efc3265Sbellard  --help|-h) show_help=yes
5842efc3265Sbellard  ;;
58599123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
58699123e13SMike Frysinger  ;;
587b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5887d13299dSbellard  ;;
589b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
59032ce6337Sbellard  ;;
591ca4deeb1SPaolo Bonzini  --source-path=*)
5927d13299dSbellard  ;;
593ac0df51dSaliguori  --cross-prefix=*)
5947d13299dSbellard  ;;
595ac0df51dSaliguori  --cc=*)
5967d13299dSbellard  ;;
597b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
59883469015Sbellard  ;;
5993c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
6003c4a4d0dSPeter Maydell  ;;
601b1a550a0Spbrook  --make=*) make="$optarg"
6027d13299dSbellard  ;;
6036a882643Spbrook  --install=*) install="$optarg"
6046a882643Spbrook  ;;
605c886edfbSBlue Swirl  --python=*) python="$optarg"
606c886edfbSBlue Swirl  ;;
607e2d8830eSBrad  --smbd=*) smbd="$optarg"
608e2d8830eSBrad  ;;
609e2a2ed06SJuan Quintela  --extra-cflags=*)
6107d13299dSbellard  ;;
611e2a2ed06SJuan Quintela  --extra-ldflags=*)
6127d13299dSbellard  ;;
6135bc62e01SGerd Hoffmann  --enable-debug-info)
6145bc62e01SGerd Hoffmann  ;;
6155bc62e01SGerd Hoffmann  --disable-debug-info)
6165bc62e01SGerd Hoffmann  ;;
6172ff6b91eSJuan Quintela  --cpu=*)
6187d13299dSbellard  ;;
619b1a550a0Spbrook  --target-list=*) target_list="$optarg"
620de83cd02Sbellard  ;;
62174242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
62294a420b1SStefan Hajnoczi  ;;
62374242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
6249410b56cSPrerna Saxena  ;;
6257d13299dSbellard  --enable-gprof) gprof="yes"
6267d13299dSbellard  ;;
62779427693SLoïc Minier  --static)
62879427693SLoïc Minier    static="yes"
62979427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
63017884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
63143ce4dfeSbellard  ;;
6320b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
6330b24e75fSPaolo Bonzini  ;;
6340b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
6350b24e75fSPaolo Bonzini  ;;
6363aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
6373aa5d2beSAlon Levy  ;;
6388bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
6398bf188aaSMichael Tokarev  ;;
6400f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
6410f94d6daSAlon Levy  ;;
642528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
6430b24e75fSPaolo Bonzini  ;;
644023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
645023d3d67SEduardo Habkost  ;;
646850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
6470b24e75fSPaolo Bonzini  ;;
648ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
64907381cc1SAnthony Liguori  ;;
6508bf188aaSMichael Tokarev  --sbindir=*|--sharedstatedir=*|--localstatedir=*|\
651023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
652023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
653023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
654023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
655023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
656023ddd74SMax Filippov    # lots of directory switches by default.
657023ddd74SMax Filippov  ;;
65897a847bcSbellard  --disable-sdl) sdl="no"
65997a847bcSbellard  ;;
660c4198157SJuan Quintela  --enable-sdl) sdl="yes"
661c4198157SJuan Quintela  ;;
662983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
663983eef5aSMeador Inge  ;;
664983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
665983eef5aSMeador Inge  ;;
666821601eaSJes Sorensen  --disable-vnc) vnc="no"
667821601eaSJes Sorensen  ;;
668821601eaSJes Sorensen  --enable-vnc) vnc="yes"
669821601eaSJes Sorensen  ;;
670b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
671102a52e4Sbellard  ;;
672c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
673c2de5c91Smalc  ;;
6742f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
6752f6a1ab0Sblueswir1  ;;
6762fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
6770c58ac1cSmalc  ;;
6780c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
6790c58ac1cSmalc  ;;
680eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
681eb852011SMarkus Armbruster  ;;
682f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
683f8393946Saurel32  ;;
684f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
685f8393946Saurel32  ;;
686f3d08ee6SPaul Brook  --enable-debug)
687f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
688f3d08ee6SPaul Brook      debug_tcg="yes"
689f3d08ee6SPaul Brook      debug="yes"
690f3d08ee6SPaul Brook      strip_opt="no"
691f3d08ee6SPaul Brook  ;;
69203b4fe7dSaliguori  --enable-sparse) sparse="yes"
69303b4fe7dSaliguori  ;;
69403b4fe7dSaliguori  --disable-sparse) sparse="no"
69503b4fe7dSaliguori  ;;
6961625af87Saliguori  --disable-strip) strip_opt="no"
6971625af87Saliguori  ;;
6988d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
6998d5d2d4cSths  ;;
7001be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
7011be10ad2SJuan Quintela  ;;
7022f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
7032f9606b3Saliguori  ;;
704ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
705ea784e3bSJuan Quintela  ;;
7062f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
7072f6f5c7aSCorentin Chary  ;;
7082f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
7092f6f5c7aSCorentin Chary  ;;
710efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
711efe556adSCorentin Chary  ;;
712efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
713efe556adSCorentin Chary  ;;
714443f1376Sbellard  --disable-slirp) slirp="no"
715c20709aaSbellard  ;;
716ee682d27SStefan Weil  --disable-uuid) uuid="no"
717ee682d27SStefan Weil  ;;
718ee682d27SStefan Weil  --enable-uuid) uuid="yes"
719ee682d27SStefan Weil  ;;
720e0e6c8c0Saliguori  --disable-vde) vde="no"
7218a16d273Sths  ;;
722dfb278bdSJuan Quintela  --enable-vde) vde="yes"
723dfb278bdSJuan Quintela  ;;
724e37630caSaliguori  --disable-xen) xen="no"
725e37630caSaliguori  ;;
726fc321b4bSJuan Quintela  --enable-xen) xen="yes"
727fc321b4bSJuan Quintela  ;;
728eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
729eb6fda0fSAnthony PERARD  ;;
730eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
731eb6fda0fSAnthony PERARD  ;;
7322e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
7332e4d9fb1Saurel32  ;;
7344ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
7354ffcedb6SJuan Quintela  ;;
736fb599c9aSbalrog  --disable-bluez) bluez="no"
737fb599c9aSbalrog  ;;
738a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
739a20a6f46SJuan Quintela  ;;
7407ba1e619Saliguori  --disable-kvm) kvm="no"
7417ba1e619Saliguori  ;;
742b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
743b31a0277SJuan Quintela  ;;
7449195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
7459195b2c2SStefan Weil  ;;
7469195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
7479195b2c2SStefan Weil  ;;
74847e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
74947e98658SCorey Bryant  ;;
75047e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
75147e98658SCorey Bryant  ;;
752cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
753cd4ec0b4SGerd Hoffmann  ;;
754cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
755cd4ec0b4SGerd Hoffmann  ;;
756c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
757c589b249SRonnie Sahlberg  ;;
758c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
759c589b249SRonnie Sahlberg  ;;
76005c2a3e7Sbellard  --enable-profiler) profiler="yes"
76105c2a3e7Sbellard  ;;
76214821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
76314821030SPavel Borzenkov  ;;
764c2de5c91Smalc  --enable-cocoa)
765c2de5c91Smalc      cocoa="yes" ;
766c2de5c91Smalc      sdl="no" ;
767c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
7685b0753e0Sbellard  ;;
769cad25d69Spbrook  --disable-system) softmmu="no"
7700a8e90f4Spbrook  ;;
771cad25d69Spbrook  --enable-system) softmmu="yes"
7720a8e90f4Spbrook  ;;
7730953a80fSZachary Amsden  --disable-user)
7740953a80fSZachary Amsden      linux_user="no" ;
7750953a80fSZachary Amsden      bsd_user="no" ;
7760953a80fSZachary Amsden  ;;
7770953a80fSZachary Amsden  --enable-user) ;;
778831b7825Sths  --disable-linux-user) linux_user="no"
7790a8e90f4Spbrook  ;;
780831b7825Sths  --enable-linux-user) linux_user="yes"
781831b7825Sths  ;;
78284778508Sblueswir1  --disable-bsd-user) bsd_user="no"
78384778508Sblueswir1  ;;
78484778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
78584778508Sblueswir1  ;;
786379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
787379f6698SPaul Brook  ;;
788379f6698SPaul Brook  --disable-guest-base) guest_base="no"
789379f6698SPaul Brook  ;;
79040d6444eSAvi Kivity  --enable-pie) pie="yes"
79134005a00SKirill A. Shutemov  ;;
79240d6444eSAvi Kivity  --disable-pie) pie="no"
79334005a00SKirill A. Shutemov  ;;
794c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
795c5937220Spbrook  ;;
7963142255cSblueswir1  --sparc_cpu=*)
7973142255cSblueswir1  ;;
79885aa5189Sbellard  --enable-werror) werror="yes"
79985aa5189Sbellard  ;;
80085aa5189Sbellard  --disable-werror) werror="no"
80185aa5189Sbellard  ;;
8024d3b6f6eSbalrog  --disable-curses) curses="no"
8034d3b6f6eSbalrog  ;;
804c584a6d0SJuan Quintela  --enable-curses) curses="yes"
805c584a6d0SJuan Quintela  ;;
806769ce76dSAlexander Graf  --disable-curl) curl="no"
807769ce76dSAlexander Graf  ;;
808788c8196SJuan Quintela  --enable-curl) curl="yes"
809788c8196SJuan Quintela  ;;
8102df87df7SJuan Quintela  --disable-fdt) fdt="no"
8112df87df7SJuan Quintela  ;;
8122df87df7SJuan Quintela  --enable-fdt) fdt="yes"
8132df87df7SJuan Quintela  ;;
814bd0c5661Spbrook  --disable-nptl) nptl="no"
815bd0c5661Spbrook  ;;
816b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
817b0a47e79SJuan Quintela  ;;
8188ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
8198ff9cbf7Smalc  ;;
8205c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
8215c6c3a6cSChristoph Hellwig  ;;
8225c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
8235c6c3a6cSChristoph Hellwig  ;;
824758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
825758e8e38SVenkateswararao Jujjuri (JV)  ;;
826758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
827758e8e38SVenkateswararao Jujjuri (JV)  ;;
82877755340Sths  --disable-blobs) blobs="no"
82977755340Sths  ;;
8304a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
8314a19f1ecSpbrook  ;;
832519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
833519175a2SAlex Barcelo  ;;
834a25dba17SJuan Quintela  --disable-docs) docs="no"
83570ec5dc0SAnthony Liguori  ;;
836a25dba17SJuan Quintela  --enable-docs) docs="yes"
83783a3ab8bSJuan Quintela  ;;
838d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
839d5970055SMichael S. Tsirkin  ;;
840d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
841d5970055SMichael S. Tsirkin  ;;
84220ff075bSMichael Walle  --disable-opengl) opengl="no"
84320ff075bSMichael Walle  ;;
84420ff075bSMichael Walle  --enable-opengl) opengl="yes"
84520ff075bSMichael Walle  ;;
846f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
847f27aaf4bSChristian Brunner  ;;
848f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
849f27aaf4bSChristian Brunner  ;;
8508c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
8518c84cf11SSergei Trofimovich  ;;
8528c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
8538c84cf11SSergei Trofimovich  ;;
85436707144SAlon Levy  --disable-smartcard) smartcard="no"
85536707144SAlon Levy  ;;
85636707144SAlon Levy  --enable-smartcard) smartcard="yes"
85736707144SAlon Levy  ;;
858111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
859111a38b0SRobert Relyea  ;;
860111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
861111a38b0SRobert Relyea  ;;
86269354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
86369354a83SHans de Goede  ;;
86469354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
86569354a83SHans de Goede  ;;
8661ece9905SAlon Levy  --disable-zlib-test) zlib="no"
8671ece9905SAlon Levy  ;;
868d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
869d138cee9SMichael Roth  ;;
870d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
871d138cee9SMichael Roth  ;;
8724b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
8734b1c11fdSDaniel P. Berrange  ;;
8744b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
8754b1c11fdSDaniel P. Berrange  ;;
876f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
877f794573eSEduardo Otubo  ;;
878f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
879f794573eSEduardo Otubo  ;;
8807f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
8817f1559c6Sbalrog  ;;
8827d13299dSbellard  esac
8837d13299dSbellarddone
8847d13299dSbellard
8853142255cSblueswir1#
8863142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
887a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
8883142255cSblueswir1#
889379f6698SPaul Brookhost_guest_base="no"
89040293e58Sbellardcase "$cpu" in
891ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
892ed968ff1SJuan Quintela           v7|v8)
893a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
894ed968ff1SJuan Quintela           ;;
895ed968ff1SJuan Quintela           v8plus|v8plusa)
896a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
897ed968ff1SJuan Quintela           ;;
898ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
899a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
900ed968ff1SJuan Quintela           esac
9010c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
902a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
903762e8230Sblueswir1           if test "$solaris" = "no" ; then
904a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
905c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
906762e8230Sblueswir1           fi
9073142255cSblueswir1           ;;
908ed968ff1SJuan Quintela    sparc64)
909a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
9100c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
911a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
912ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
913a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
914762e8230Sblueswir1           fi
9153142255cSblueswir1           ;;
91676d83bdeSths    s390)
91728d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
91828d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
91948bb3750SRichard Henderson           host_guest_base="yes"
92028d7cc49SRichard Henderson           ;;
92128d7cc49SRichard Henderson    s390x)
92228d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
92328d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
92448bb3750SRichard Henderson           host_guest_base="yes"
92576d83bdeSths           ;;
92640293e58Sbellard    i386)
927a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
9280c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
9292b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
930c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
931379f6698SPaul Brook           host_guest_base="yes"
93240293e58Sbellard           ;;
93340293e58Sbellard    x86_64)
934a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
9350c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
9362b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
937379f6698SPaul Brook           host_guest_base="yes"
938379f6698SPaul Brook           ;;
939379f6698SPaul Brook    arm*)
940379f6698SPaul Brook           host_guest_base="yes"
94140293e58Sbellard           ;;
942f6548c0aSmalc    ppc*)
943f6548c0aSmalc           host_guest_base="yes"
944f6548c0aSmalc           ;;
945cc01cc8eSAurelien Jarno    mips*)
946cc01cc8eSAurelien Jarno           host_guest_base="yes"
947cc01cc8eSAurelien Jarno           ;;
948477ba620SAurelien Jarno    ia64*)
949477ba620SAurelien Jarno           host_guest_base="yes"
950477ba620SAurelien Jarno           ;;
951fd76e73aSRichard Henderson    hppa*)
952fd76e73aSRichard Henderson           host_guest_base="yes"
953fd76e73aSRichard Henderson           ;;
954d2fbca94SGuan Xuetao    unicore32*)
955d2fbca94SGuan Xuetao           host_guest_base="yes"
956d2fbca94SGuan Xuetao           ;;
9573142255cSblueswir1esac
9583142255cSblueswir1
959379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
960379f6698SPaul Brook
96160e0df25SPeter Maydell
96260e0df25SPeter Maydelldefault_target_list=""
96360e0df25SPeter Maydell
96460e0df25SPeter Maydell# these targets are portable
96560e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
96660e0df25SPeter Maydell    default_target_list="\
96760e0df25SPeter Maydelli386-softmmu \
96860e0df25SPeter Maydellx86_64-softmmu \
96927cdad67SRichard Hendersonalpha-softmmu \
97060e0df25SPeter Maydellarm-softmmu \
97160e0df25SPeter Maydellcris-softmmu \
97260e0df25SPeter Maydelllm32-softmmu \
97360e0df25SPeter Maydellm68k-softmmu \
97460e0df25SPeter Maydellmicroblaze-softmmu \
97560e0df25SPeter Maydellmicroblazeel-softmmu \
97660e0df25SPeter Maydellmips-softmmu \
97760e0df25SPeter Maydellmipsel-softmmu \
97860e0df25SPeter Maydellmips64-softmmu \
97960e0df25SPeter Maydellmips64el-softmmu \
980e67db06eSJia Liuor32-softmmu \
98160e0df25SPeter Maydellppc-softmmu \
98260e0df25SPeter Maydellppcemb-softmmu \
98360e0df25SPeter Maydellppc64-softmmu \
98460e0df25SPeter Maydellsh4-softmmu \
98560e0df25SPeter Maydellsh4eb-softmmu \
98660e0df25SPeter Maydellsparc-softmmu \
98760e0df25SPeter Maydellsparc64-softmmu \
9880f3301d4SAlexander Grafs390x-softmmu \
989cfa550c6SMax Filippovxtensa-softmmu \
990cfa550c6SMax Filippovxtensaeb-softmmu \
9914f23a1e6SGuan Xuetaounicore32-softmmu \
99260e0df25SPeter Maydell"
99360e0df25SPeter Maydellfi
99460e0df25SPeter Maydell# the following are Linux specific
99560e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
99660e0df25SPeter Maydell    default_target_list="${default_target_list}\
99760e0df25SPeter Maydelli386-linux-user \
99860e0df25SPeter Maydellx86_64-linux-user \
99960e0df25SPeter Maydellalpha-linux-user \
100060e0df25SPeter Maydellarm-linux-user \
100160e0df25SPeter Maydellarmeb-linux-user \
100260e0df25SPeter Maydellcris-linux-user \
100360e0df25SPeter Maydellm68k-linux-user \
100460e0df25SPeter Maydellmicroblaze-linux-user \
100560e0df25SPeter Maydellmicroblazeel-linux-user \
100660e0df25SPeter Maydellmips-linux-user \
100760e0df25SPeter Maydellmipsel-linux-user \
1008d962783eSJia Liuor32-linux-user \
100960e0df25SPeter Maydellppc-linux-user \
101060e0df25SPeter Maydellppc64-linux-user \
101160e0df25SPeter Maydellppc64abi32-linux-user \
101260e0df25SPeter Maydellsh4-linux-user \
101360e0df25SPeter Maydellsh4eb-linux-user \
101460e0df25SPeter Maydellsparc-linux-user \
101560e0df25SPeter Maydellsparc64-linux-user \
101660e0df25SPeter Maydellsparc32plus-linux-user \
101760e0df25SPeter Maydellunicore32-linux-user \
10180f3301d4SAlexander Grafs390x-linux-user \
101960e0df25SPeter Maydell"
102060e0df25SPeter Maydellfi
102160e0df25SPeter Maydell# the following are BSD specific
102260e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
102360e0df25SPeter Maydell    default_target_list="${default_target_list}\
102460e0df25SPeter Maydelli386-bsd-user \
102560e0df25SPeter Maydellx86_64-bsd-user \
102660e0df25SPeter Maydellsparc-bsd-user \
102760e0df25SPeter Maydellsparc64-bsd-user \
102860e0df25SPeter Maydell"
102960e0df25SPeter Maydellfi
103060e0df25SPeter Maydell
1031af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1032af5db58eSpbrookcat << EOF
1033af5db58eSpbrook
1034af5db58eSpbrookUsage: configure [options]
1035af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1036af5db58eSpbrook
1037af5db58eSpbrookEOF
1038af5db58eSpbrookecho "Standard options:"
1039af5db58eSpbrookecho "  --help                   print this message"
1040af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
1041af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
1042af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
104360e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
104460e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
104560e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
1046af5db58eSpbrookecho ""
1047af5db58eSpbrookecho "Advanced options (experts only):"
1048af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
1049af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
1050af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
10510bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
10520bfe8cc0SPaolo Bonziniecho "                           build time"
10533c4a4d0dSPeter Maydellecho "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
1054a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
1055e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
1056af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
10576a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
1058c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
1059e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
1060af5db58eSpbrookecho "  --static                 enable static build [$static]"
10610b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
1062023d3d67SEduardo Habkostecho "  --datadir=PATH           install firmware in PATH$confsuffix"
1063023d3d67SEduardo Habkostecho "  --docdir=PATH            install documentation in PATH$confsuffix"
10640b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
1065023d3d67SEduardo Habkostecho "  --sysconfdir=PATH        install config in PATH$confsuffix"
10662ae4748fSStefan Weilecho "  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1067f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
1068f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
106909695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
1070890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
1071890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
10721625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
107385aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
1074fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
1075c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
1076983eef5aSMeador Ingeecho "  --disable-virtfs         disable VirtFS"
1077983eef5aSMeador Ingeecho "  --enable-virtfs          enable VirtFS"
1078821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
1079821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
108014821030SPavel Borzenkovecho "  --disable-cocoa          disable Cocoa (Mac OS X only)"
108114821030SPavel Borzenkovecho "  --enable-cocoa           enable Cocoa (default on Mac OS X)"
1082c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
1083c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
10844c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
10854c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
1086eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
1087eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
10888ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
1089e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
1090fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
1091eb6fda0fSAnthony PERARDecho "  --disable-xen-pci-passthrough"
1092eb6fda0fSAnthony PERARDecho "  --enable-xen-pci-passthrough"
10932e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
10944ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
10958d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
10961be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
10972f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1098ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
10992f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
11002f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
110196763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1102efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
1103af896aaaSpbrookecho "  --disable-curses         disable curses output"
1104c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1105769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1106788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
11072df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
11082df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
1109fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1110a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
11116093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
11127ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1113b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
11149195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1115bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
1116e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
1117af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1118af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
11190953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
11200953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1121831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1122831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
112384778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
112484778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1125379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1126379f6698SPaul Brookecho "                           emulation targets"
1127379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
112840d6444eSAvi Kivityecho "  --enable-pie             build Position Independent Executables"
112940d6444eSAvi Kivityecho "  --disable-pie            do not build Position Independent Executables"
1130af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1131af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
11322f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1133c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1134235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
11353142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
1136ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1137ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1138e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1139dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
11405c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
11415c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
114247e98658SCorey Bryantecho "  --disable-cap-ng         disable libcap-ng support"
114347e98658SCorey Bryantecho "  --enable-cap-ng          enable libcap-ng support"
1144758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1145758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
114677755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1147d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1148d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1149d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1150d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1151320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1152650ab98dSLluís Vilanovaecho "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
115374242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
11549410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1155cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1156cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1157f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1158c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1159c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
116036707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
116136707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1162111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1163111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
116469354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
116569354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1166d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1167d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1168f794573eSEduardo Otuboecho "  --disable-seccomp        disable seccomp support"
1169f794573eSEduardo Otuboecho "  --enable-seccomp         enables seccomp support"
1170519175a2SAlex Barceloecho "  --with-coroutine=BACKEND coroutine backend. Supported options:"
1171fe91bfa8SAlex Barceloecho "                           gthread, ucontext, sigaltstack, windows"
1172af5db58eSpbrookecho ""
11735bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1174af5db58eSpbrookexit 1
1175af5db58eSpbrookfi
1176af5db58eSpbrook
1177359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
1178359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
1179359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
1180359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
1181359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1182359bc95dSPeter Maydell        ARCH=tci
1183359bc95dSPeter Maydell    else
1184359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1185359bc95dSPeter Maydell        exit 1
1186359bc95dSPeter Maydell    fi
1187359bc95dSPeter Maydellfi
1188359bc95dSPeter Maydell
11898d05095cSPaolo Bonzini# check that the C compiler works.
11908d05095cSPaolo Bonzinicat > $TMPC <<EOF
119175cafad7SStefan Weilint main(void) { return 0; }
11928d05095cSPaolo BonziniEOF
11938d05095cSPaolo Bonzini
11948d05095cSPaolo Bonziniif compile_object ; then
11958d05095cSPaolo Bonzini  : C compiler works ok
11968d05095cSPaolo Bonzinielse
11978d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
11988d05095cSPaolo Bonzini    exit 1
11998d05095cSPaolo Bonzinifi
12008d05095cSPaolo Bonzini
1201417c9d72SAlexander Graf# Consult white-list to determine whether to enable werror
1202417c9d72SAlexander Graf# by default.  Only enable by default for git builds
1203417c9d72SAlexander Grafz_version=`cut -f3 -d. $source_path/VERSION`
1204417c9d72SAlexander Graf
1205417c9d72SAlexander Grafif test -z "$werror" ; then
1206417c9d72SAlexander Graf    if test "$z_version" = "50" -a \
1207417c9d72SAlexander Graf        "$linux" = "yes" ; then
1208417c9d72SAlexander Graf        werror="yes"
1209417c9d72SAlexander Graf    else
1210417c9d72SAlexander Graf        werror="no"
1211417c9d72SAlexander Graf    fi
1212417c9d72SAlexander Graffi
1213417c9d72SAlexander Graf
12148d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
12158d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
12168d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1217f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
12186ca026cbSPeter Maydell# Note that we do not add -Werror to gcc_flags here, because that would
12196ca026cbSPeter Maydell# enable it for all configure tests. If a configure test failed due
12206ca026cbSPeter Maydell# to -Werror this would just silently disable some features,
12216ca026cbSPeter Maydell# so it's too error prone.
12228d05095cSPaolo Bonzinicat > $TMPC << EOF
12238d05095cSPaolo Bonziniint main(void) { return 0; }
12248d05095cSPaolo BonziniEOF
12258d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1226bd947d30SStefan Weil    if compile_prog "-Werror $flag" "" ; then
12278d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
12288d05095cSPaolo Bonzini    fi
12298d05095cSPaolo Bonzinidone
12308d05095cSPaolo Bonzini
123140d6444eSAvi Kivityif test "$static" = "yes" ; then
123240d6444eSAvi Kivity  if test "$pie" = "yes" ; then
123340d6444eSAvi Kivity    echo "static and pie are mutually incompatible"
123440d6444eSAvi Kivity    exit 1
123540d6444eSAvi Kivity  else
123640d6444eSAvi Kivity    pie="no"
123740d6444eSAvi Kivity  fi
123840d6444eSAvi Kivityfi
123940d6444eSAvi Kivity
124040d6444eSAvi Kivityif test "$pie" = ""; then
124140d6444eSAvi Kivity  case "$cpu-$targetos" in
1242f9db31a2SBrad    i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD)
124340d6444eSAvi Kivity      ;;
124440d6444eSAvi Kivity    *)
124540d6444eSAvi Kivity      pie="no"
124640d6444eSAvi Kivity      ;;
124740d6444eSAvi Kivity  esac
124840d6444eSAvi Kivityfi
124940d6444eSAvi Kivity
125040d6444eSAvi Kivityif test "$pie" != "no" ; then
125140d6444eSAvi Kivity  cat > $TMPC << EOF
125221d4a791SAvi Kivity
125321d4a791SAvi Kivity#ifdef __linux__
125421d4a791SAvi Kivity#  define THREAD __thread
125521d4a791SAvi Kivity#else
125621d4a791SAvi Kivity#  define THREAD
125721d4a791SAvi Kivity#endif
125821d4a791SAvi Kivity
125921d4a791SAvi Kivitystatic THREAD int tls_var;
126021d4a791SAvi Kivity
126121d4a791SAvi Kivityint main(void) { return tls_var; }
126221d4a791SAvi Kivity
126340d6444eSAvi KivityEOF
126440d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
126540d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
126640d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
126740d6444eSAvi Kivity    pie="yes"
126840d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
126940d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
127040d6444eSAvi Kivity    fi
127140d6444eSAvi Kivity  else
127240d6444eSAvi Kivity    if test "$pie" = "yes"; then
127340d6444eSAvi Kivity      echo "PIE not available due to missing toolchain support"
127440d6444eSAvi Kivity      exit 1
127540d6444eSAvi Kivity    else
127640d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
127740d6444eSAvi Kivity      pie="no"
127840d6444eSAvi Kivity    fi
127940d6444eSAvi Kivity  fi
128040d6444eSAvi Kivityfi
128140d6444eSAvi Kivity
1282ec530c81Sbellard#
1283ec530c81Sbellard# Solaris specific configure tool chain decisions
1284ec530c81Sbellard#
1285ec530c81Sbellardif test "$solaris" = "yes" ; then
12866792aa11SLoïc Minier  if has $install; then
12876792aa11SLoïc Minier    :
12886792aa11SLoïc Minier  else
1289ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1290ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1291ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1292ec530c81Sbellard    exit 1
1293ec530c81Sbellard  fi
12946792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1295ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1296ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1297ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1298ec530c81Sbellard    exit 1
1299ec530c81Sbellard  fi
13006792aa11SLoïc Minier  if has ar; then
13016792aa11SLoïc Minier    :
13026792aa11SLoïc Minier  else
1303ec530c81Sbellard    echo "Error: No path includes ar"
1304ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1305ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1306ec530c81Sbellard    fi
1307ec530c81Sbellard    exit 1
1308ec530c81Sbellard  fi
1309ec530c81Sbellardfi
1310ec530c81Sbellard
13117a3fc891SSebastian Herbsztif ! has $python; then
1312c886edfbSBlue Swirl  echo "Python not found. Use --python=/path/to/python"
1313c886edfbSBlue Swirl  exit 1
1314c886edfbSBlue Swirlfi
1315c886edfbSBlue Swirl
13166ccea1e4SPeter Maydell# Note that if the Python conditional here evaluates True we will exit
13176ccea1e4SPeter Maydell# with status 1 which is a shell 'false' value.
1318e120d449SStefan Hajnocziif ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1319e120d449SStefan Hajnoczi  echo "Cannot use '$python', Python 2.4 or later is required."
1320e120d449SStefan Hajnoczi  echo "Note that Python 3 or later is not yet supported."
1321e120d449SStefan Hajnoczi  echo "Use --python=/path/to/python to specify a supported Python."
13226ccea1e4SPeter Maydell  exit 1
13236ccea1e4SPeter Maydellfi
13246ccea1e4SPeter Maydell
132566d5499bSDaniel P. Berrangeif test "$target_list" = "DEFAULT" ; then
132666d5499bSDaniel P. Berrange    target_list=`echo "$default_target_list" | sed -e 's/,/ /g'`
13275327cf48Sbellardfi
132866d5499bSDaniel P. Berrange
1329f55fe278SPaolo Bonzini# see if system emulation was really requested
1330f55fe278SPaolo Bonzinicase " $target_list " in
1331f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1332f55fe278SPaolo Bonzini  ;;
1333f55fe278SPaolo Bonzini  *) softmmu=no
1334f55fe278SPaolo Bonzini  ;;
1335f55fe278SPaolo Bonziniesac
13365327cf48Sbellard
1337249247c9SJuan Quintelafeature_not_found() {
1338249247c9SJuan Quintela  feature=$1
1339249247c9SJuan Quintela
1340249247c9SJuan Quintela  echo "ERROR"
1341249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
13429332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1343249247c9SJuan Quintela  echo "ERROR"
1344249247c9SJuan Quintela  exit 1;
1345249247c9SJuan Quintela}
1346249247c9SJuan Quintela
13477d13299dSbellardif test -z "$cross_prefix" ; then
13487d13299dSbellard
13497d13299dSbellard# ---
13507d13299dSbellard# big/little endian test
13517d13299dSbellardcat > $TMPC << EOF
13527d13299dSbellard#include <inttypes.h>
13537d13299dSbellardint main(int argc, char ** argv){
13547d13299dSbellard        volatile uint32_t i=0x01234567;
13557d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
13567d13299dSbellard}
13577d13299dSbellardEOF
13587d13299dSbellard
135952166aa0SJuan Quintelaif compile_prog "" "" ; then
13607d13299dSbellard$TMPE && bigendian="yes"
13617d13299dSbellardelse
13627d13299dSbellardecho big/little test failed
13637d13299dSbellardfi
13647d13299dSbellard
13657d13299dSbellardelse
13667d13299dSbellard
13677d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1368ea8f20f8SJuan Quintelacase "$cpu" in
136921d89f84SPeter Maydell  arm)
137021d89f84SPeter Maydell    # ARM can be either way; ask the compiler which one we are
137121d89f84SPeter Maydell    if check_define __ARMEB__; then
137221d89f84SPeter Maydell      bigendian=yes
137321d89f84SPeter Maydell    fi
137421d89f84SPeter Maydell  ;;
137521d89f84SPeter Maydell  hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1376ea8f20f8SJuan Quintela    bigendian=yes
1377ea8f20f8SJuan Quintela  ;;
1378ea8f20f8SJuan Quintelaesac
13797d13299dSbellard
13807d13299dSbellardfi
13817d13299dSbellard
1382b0a47e79SJuan Quintela##########################################
1383b0a47e79SJuan Quintela# NPTL probe
1384b0a47e79SJuan Quintela
1385b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1386bd0c5661Spbrook  cat > $TMPC <<EOF
1387bd0c5661Spbrook#include <sched.h>
138830813ceaSpbrook#include <linux/futex.h>
1389182eacc0SStefan Weilint main(void) {
1390bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1391bd0c5661Spbrook#error bork
1392bd0c5661Spbrook#endif
1393182eacc0SStefan Weil  return 0;
1394bd0c5661Spbrook}
1395bd0c5661SpbrookEOF
1396bd0c5661Spbrook
139752166aa0SJuan Quintela  if compile_object ; then
1398b0a47e79SJuan Quintela    nptl=yes
1399bd0c5661Spbrook  else
1400b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1401b0a47e79SJuan Quintela      feature_not_found "nptl"
1402b0a47e79SJuan Quintela    fi
1403b0a47e79SJuan Quintela    nptl=no
1404b0a47e79SJuan Quintela  fi
1405bd0c5661Spbrookfi
1406bd0c5661Spbrook
140711d9f695Sbellard##########################################
1408ac62922eSbalrog# zlib check
1409ac62922eSbalrog
14101ece9905SAlon Levyif test "$zlib" != "no" ; then
1411ac62922eSbalrog    cat > $TMPC << EOF
1412ac62922eSbalrog#include <zlib.h>
1413ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1414ac62922eSbalrogEOF
141552166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1416ac62922eSbalrog        :
1417ac62922eSbalrog    else
1418ac62922eSbalrog        echo
1419ac62922eSbalrog        echo "Error: zlib check failed"
1420ac62922eSbalrog        echo "Make sure to have the zlib libs and headers installed."
1421ac62922eSbalrog        echo
1422ac62922eSbalrog        exit 1
1423ac62922eSbalrog    fi
14241ece9905SAlon Levyfi
1425ac62922eSbalrog
1426ac62922eSbalrog##########################################
1427f794573eSEduardo Otubo# libseccomp check
1428f794573eSEduardo Otubo
1429f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
1430f794573eSEduardo Otubo    if $pkg_config libseccomp --modversion >/dev/null 2>&1; then
1431f794573eSEduardo Otubo        LIBS=`$pkg_config --libs libseccomp`
1432f794573eSEduardo Otubo	seccomp="yes"
1433f794573eSEduardo Otubo    else
1434f794573eSEduardo Otubo	seccomp="no"
1435f794573eSEduardo Otubo	if test "$seccomp" = "yes"; then
1436f794573eSEduardo Otubo            feature_not_found "libseccomp"
1437f794573eSEduardo Otubo	fi
1438f794573eSEduardo Otubo    fi
1439f794573eSEduardo Otubofi
1440f794573eSEduardo Otubo##########################################
1441e37630caSaliguori# xen probe
1442e37630caSaliguori
1443fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1444b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1445d5b93ddfSAnthony PERARD
144650ced5b3SStefan Weil  # First we test whether Xen headers and libraries are available.
144750ced5b3SStefan Weil  # If no, we are done and there is no Xen support.
144850ced5b3SStefan Weil  # If yes, more tests are run to detect the Xen version.
144950ced5b3SStefan Weil
145050ced5b3SStefan Weil  # Xen (any)
145150ced5b3SStefan Weil  cat > $TMPC <<EOF
145250ced5b3SStefan Weil#include <xenctrl.h>
145350ced5b3SStefan Weilint main(void) {
145450ced5b3SStefan Weil  return 0;
145550ced5b3SStefan Weil}
145650ced5b3SStefan WeilEOF
145750ced5b3SStefan Weil  if ! compile_prog "" "$xen_libs" ; then
145850ced5b3SStefan Weil    # Xen not found
145950ced5b3SStefan Weil    if test "$xen" = "yes" ; then
146050ced5b3SStefan Weil      feature_not_found "xen"
146150ced5b3SStefan Weil    fi
146250ced5b3SStefan Weil    xen=no
146350ced5b3SStefan Weil
1464d5b93ddfSAnthony PERARD  # Xen unstable
146569deef08SPeter Maydell  elif
146669deef08SPeter Maydell      cat > $TMPC <<EOF &&
1467e37630caSaliguori#include <xenctrl.h>
1468e108a3c1SAnthony PERARD#include <xenstore.h>
1469d5b93ddfSAnthony PERARD#include <stdint.h>
1470d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1471d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1472d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1473d5b93ddfSAnthony PERARD#endif
1474d5b93ddfSAnthony PERARDint main(void) {
1475d5b93ddfSAnthony PERARD  xc_interface *xc;
1476d5b93ddfSAnthony PERARD  xs_daemon_open();
1477d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1478d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1479d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1480b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
14818688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
14828688e065SStefano Stabellini  return 0;
14838688e065SStefano Stabellini}
14848688e065SStefano StabelliniEOF
14858688e065SStefano Stabellini      compile_prog "" "$xen_libs"
148669deef08SPeter Maydell    then
14878688e065SStefano Stabellini    xen_ctrl_version=420
14888688e065SStefano Stabellini    xen=yes
14898688e065SStefano Stabellini
149069deef08SPeter Maydell  elif
149169deef08SPeter Maydell      cat > $TMPC <<EOF &&
14928688e065SStefano Stabellini#include <xenctrl.h>
14938688e065SStefano Stabellini#include <xs.h>
14948688e065SStefano Stabellini#include <stdint.h>
14958688e065SStefano Stabellini#include <xen/hvm/hvm_info_table.h>
14968688e065SStefano Stabellini#if !defined(HVM_MAX_VCPUS)
14978688e065SStefano Stabellini# error HVM_MAX_VCPUS not defined
14988688e065SStefano Stabellini#endif
14998688e065SStefano Stabelliniint main(void) {
15008688e065SStefano Stabellini  xs_daemon_open();
15019b4c0b56SPeter Maydell  xc_interface_open(0, 0, 0);
15028688e065SStefano Stabellini  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
15038688e065SStefano Stabellini  xc_gnttab_open(NULL, 0);
15048688e065SStefano Stabellini  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1505d5b93ddfSAnthony PERARD  return 0;
1506d5b93ddfSAnthony PERARD}
1507e37630caSaliguoriEOF
150850ced5b3SStefan Weil      compile_prog "" "$xen_libs"
150969deef08SPeter Maydell    then
1510d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1511fc321b4bSJuan Quintela    xen=yes
1512d5b93ddfSAnthony PERARD
1513d5b93ddfSAnthony PERARD  # Xen 4.0.0
151469deef08SPeter Maydell  elif
151569deef08SPeter Maydell      cat > $TMPC <<EOF &&
1516d5b93ddfSAnthony PERARD#include <xenctrl.h>
1517d5b93ddfSAnthony PERARD#include <xs.h>
1518d5b93ddfSAnthony PERARD#include <stdint.h>
1519d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1520d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1521d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1522d5b93ddfSAnthony PERARD#endif
1523d5b93ddfSAnthony PERARDint main(void) {
1524b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1525b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1526b87de24eSAnthony PERARD  };
1527d5b93ddfSAnthony PERARD  xs_daemon_open();
1528d5b93ddfSAnthony PERARD  xc_interface_open();
1529d5b93ddfSAnthony PERARD  xc_gnttab_open();
1530d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1531b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1532d5b93ddfSAnthony PERARD  return 0;
1533d5b93ddfSAnthony PERARD}
1534d5b93ddfSAnthony PERARDEOF
1535d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
153669deef08SPeter Maydell    then
1537d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1538d5b93ddfSAnthony PERARD    xen=yes
1539d5b93ddfSAnthony PERARD
1540b87de24eSAnthony PERARD  # Xen 3.4.0
154169deef08SPeter Maydell  elif
154269deef08SPeter Maydell      cat > $TMPC <<EOF &&
1543b87de24eSAnthony PERARD#include <xenctrl.h>
1544b87de24eSAnthony PERARD#include <xs.h>
1545b87de24eSAnthony PERARDint main(void) {
1546b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1547b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1548b87de24eSAnthony PERARD  };
1549b87de24eSAnthony PERARD  xs_daemon_open();
1550b87de24eSAnthony PERARD  xc_interface_open();
1551b87de24eSAnthony PERARD  xc_gnttab_open();
1552b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1553b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1554b87de24eSAnthony PERARD  return 0;
1555b87de24eSAnthony PERARD}
1556b87de24eSAnthony PERARDEOF
1557b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
155869deef08SPeter Maydell    then
1559b87de24eSAnthony PERARD    xen_ctrl_version=340
1560b87de24eSAnthony PERARD    xen=yes
1561b87de24eSAnthony PERARD
1562b87de24eSAnthony PERARD  # Xen 3.3.0
156369deef08SPeter Maydell  elif
156469deef08SPeter Maydell      cat > $TMPC <<EOF &&
1565d5b93ddfSAnthony PERARD#include <xenctrl.h>
1566d5b93ddfSAnthony PERARD#include <xs.h>
1567d5b93ddfSAnthony PERARDint main(void) {
1568d5b93ddfSAnthony PERARD  xs_daemon_open();
1569d5b93ddfSAnthony PERARD  xc_interface_open();
1570d5b93ddfSAnthony PERARD  xc_gnttab_open();
1571d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1572d5b93ddfSAnthony PERARD  return 0;
1573d5b93ddfSAnthony PERARD}
1574d5b93ddfSAnthony PERARDEOF
1575d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
157669deef08SPeter Maydell    then
1577d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1578d5b93ddfSAnthony PERARD    xen=yes
1579d5b93ddfSAnthony PERARD
158050ced5b3SStefan Weil  # Xen version unsupported
1581e37630caSaliguori  else
1582fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
158350ced5b3SStefan Weil      feature_not_found "xen (unsupported version)"
1584fc321b4bSJuan Quintela    fi
1585fc321b4bSJuan Quintela    xen=no
1586e37630caSaliguori  fi
1587d5b93ddfSAnthony PERARD
1588d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1589d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1590d5b93ddfSAnthony PERARD  fi
1591e37630caSaliguorifi
1592e37630caSaliguori
1593eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
1594eb6fda0fSAnthony PERARD  if test "$xen" = "yes" && test "$linux" = "yes" &&
1595eb6fda0fSAnthony PERARD    test "$xen_ctrl_version" -ge 340; then
1596eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
1597eb6fda0fSAnthony PERARD  else
1598eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
1599eb6fda0fSAnthony PERARD      echo "ERROR"
1600eb6fda0fSAnthony PERARD      echo "ERROR: User requested feature Xen PCI Passthrough"
1601eb6fda0fSAnthony PERARD      echo "ERROR: but this feature require /sys from Linux"
1602eb6fda0fSAnthony PERARD      if test "$xen_ctrl_version" -lt 340; then
1603eb6fda0fSAnthony PERARD        echo "ERROR: This feature does not work with Xen 3.3"
1604eb6fda0fSAnthony PERARD      fi
1605eb6fda0fSAnthony PERARD      echo "ERROR"
1606eb6fda0fSAnthony PERARD      exit 1;
1607eb6fda0fSAnthony PERARD    fi
1608eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
1609eb6fda0fSAnthony PERARD  fi
1610eb6fda0fSAnthony PERARDfi
1611eb6fda0fSAnthony PERARD
1612e37630caSaliguori##########################################
1613a8bd70adSPaolo Bonzini# pkg-config probe
1614f91672e5SPaolo Bonzini
161517884d7bSSergei Trofimovichif ! has "$pkg_config_exe"; then
161617884d7bSSergei Trofimovich  echo "Error: pkg-config binary '$pkg_config_exe' not found"
1617a213fcb2SPeter Maydell  exit 1
1618f91672e5SPaolo Bonzinifi
1619f91672e5SPaolo Bonzini
1620f91672e5SPaolo Bonzini##########################################
162144dc0ca3SAlon Levy# libtool probe
162244dc0ca3SAlon Levy
16233f534581SBradif ! has $libtool; then
162444dc0ca3SAlon Levy    libtool=
162544dc0ca3SAlon Levyfi
162644dc0ca3SAlon Levy
162744dc0ca3SAlon Levy##########################################
1628dfffc653SJuan Quintela# Sparse probe
1629dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
16300dba6195SLoïc Minier  if has cgcc; then
1631dfffc653SJuan Quintela    sparse=yes
1632dfffc653SJuan Quintela  else
1633dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1634dfffc653SJuan Quintela      feature_not_found "sparse"
1635dfffc653SJuan Quintela    fi
1636dfffc653SJuan Quintela    sparse=no
1637dfffc653SJuan Quintela  fi
1638dfffc653SJuan Quintelafi
1639dfffc653SJuan Quintela
1640dfffc653SJuan Quintela##########################################
164111d9f695Sbellard# SDL probe
164211d9f695Sbellard
16433ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
16443ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
16453ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
16463ec87ffeSPaolo Bonzini  sdl_config=sdl-config
16473ec87ffeSPaolo Bonzinifi
16483ec87ffeSPaolo Bonzini
16493ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1650a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1651fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
16523ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
16533ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
16549316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1655a0dfd8a4SLoïc Minierelse
1656a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1657a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1658a0dfd8a4SLoïc Minier  fi
1659a0dfd8a4SLoïc Minier  sdl=no
16609316f803SPaolo Bonzinifi
166129e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
16623ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
16633ec87ffeSPaolo Bonzinifi
166411d9f695Sbellard
16659316f803SPaolo Bonzinisdl_too_old=no
1666c4198157SJuan Quintelaif test "$sdl" != "no" ; then
166711d9f695Sbellard  cat > $TMPC << EOF
166811d9f695Sbellard#include <SDL.h>
166911d9f695Sbellard#undef main /* We don't want SDL to override our main() */
167011d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
167111d9f695SbellardEOF
16729316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
167374f42e18STeLeMan  if test "$static" = "yes" ; then
167474f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
167574f42e18STeLeMan  else
16769316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
167774f42e18STeLeMan  fi
167852166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
167911d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
168011d9f695Sbellard      sdl_too_old=yes
168111d9f695Sbellard    else
1682fd677642Sths      if test "$cocoa" = "no" ; then
168311d9f695Sbellard        sdl=yes
168411d9f695Sbellard      fi
1685fd677642Sths    fi
16867c1f25b4Sbellard
168767c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
16881ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
168967c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1690f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1691f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
169211d9f695Sbellard      fi
169352166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
16941ac88f28SJuan Quintela	:
16951ac88f28SJuan Quintela      else
16961ac88f28SJuan Quintela        sdl=no
16977c1f25b4Sbellard      fi
16987c1f25b4Sbellard    fi # static link
1699c4198157SJuan Quintela  else # sdl not found
1700c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1701c4198157SJuan Quintela      feature_not_found "sdl"
1702c4198157SJuan Quintela    fi
1703c4198157SJuan Quintela    sdl=no
17047c1f25b4Sbellard  fi # sdl compile test
1705fd677642Sthsfi
170611d9f695Sbellard
17075368a422Saliguoriif test "$sdl" = "yes" ; then
17085368a422Saliguori  cat > $TMPC <<EOF
17095368a422Saliguori#include <SDL.h>
17105368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
17115368a422Saliguori#include <X11/XKBlib.h>
17125368a422Saliguori#else
17135368a422Saliguori#error No x11 support
17145368a422Saliguori#endif
17155368a422Saliguoriint main(void) { return 0; }
17165368a422SaliguoriEOF
171752166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1718681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
17195368a422Saliguori  fi
17200705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
17215368a422Saliguorifi
17225368a422Saliguori
17238f28f3fbSths##########################################
17248d5d2d4cSths# VNC TLS detection
1725821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1726ae6b5e5aSaliguori  cat > $TMPC <<EOF
1727ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1728ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1729ae6b5e5aSaliguoriEOF
1730a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1731a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
173252166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
17331be10ad2SJuan Quintela    vnc_tls=yes
1734a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1735ae6b5e5aSaliguori  else
17361be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
17371be10ad2SJuan Quintela      feature_not_found "vnc-tls"
17381be10ad2SJuan Quintela    fi
17391be10ad2SJuan Quintela    vnc_tls=no
17408d5d2d4cSths  fi
17418d5d2d4cSthsfi
17428d5d2d4cSths
17438d5d2d4cSths##########################################
17442f9606b3Saliguori# VNC SASL detection
1745821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
17462f9606b3Saliguori  cat > $TMPC <<EOF
17472f9606b3Saliguori#include <sasl/sasl.h>
17482f9606b3Saliguori#include <stdio.h>
17492f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
17502f9606b3SaliguoriEOF
17512f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
17522f9606b3Saliguori  vnc_sasl_cflags=""
17532f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
175452166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1755ea784e3bSJuan Quintela    vnc_sasl=yes
1756fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
17572f9606b3Saliguori  else
1758ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1759ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1760ea784e3bSJuan Quintela    fi
1761ea784e3bSJuan Quintela    vnc_sasl=no
17622f9606b3Saliguori  fi
17632f9606b3Saliguorifi
17642f9606b3Saliguori
17652f9606b3Saliguori##########################################
17662f6f5c7aSCorentin Chary# VNC JPEG detection
1767821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
17682f6f5c7aSCorentin Charycat > $TMPC <<EOF
17692f6f5c7aSCorentin Chary#include <stdio.h>
17702f6f5c7aSCorentin Chary#include <jpeglib.h>
17712f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
17722f6f5c7aSCorentin CharyEOF
17732f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
17742f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
17752f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
17762f6f5c7aSCorentin Chary    vnc_jpeg=yes
17772f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
17782f6f5c7aSCorentin Chary  else
17792f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
17802f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
17812f6f5c7aSCorentin Chary    fi
17822f6f5c7aSCorentin Chary    vnc_jpeg=no
17832f6f5c7aSCorentin Chary  fi
17842f6f5c7aSCorentin Charyfi
17852f6f5c7aSCorentin Chary
17862f6f5c7aSCorentin Chary##########################################
1787efe556adSCorentin Chary# VNC PNG detection
1788821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1789efe556adSCorentin Charycat > $TMPC <<EOF
1790efe556adSCorentin Chary//#include <stdio.h>
1791efe556adSCorentin Chary#include <png.h>
1792832ce9c2SScott Wood#include <stddef.h>
1793efe556adSCorentin Charyint main(void) {
1794efe556adSCorentin Chary    png_structp png_ptr;
1795efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
17967edc3fedSPeter Maydell    return png_ptr != 0;
1797efe556adSCorentin Chary}
1798efe556adSCorentin CharyEOF
17999af8025eSBrad  if $pkg_config libpng --modversion >/dev/null 2>&1; then
18009af8025eSBrad    vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
18019af8025eSBrad    vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
18029af8025eSBrad  else
1803efe556adSCorentin Chary    vnc_png_cflags=""
1804efe556adSCorentin Chary    vnc_png_libs="-lpng"
18059af8025eSBrad  fi
1806efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1807efe556adSCorentin Chary    vnc_png=yes
1808efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
18099af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1810efe556adSCorentin Chary  else
1811efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1812efe556adSCorentin Chary      feature_not_found "vnc-png"
1813efe556adSCorentin Chary    fi
1814efe556adSCorentin Chary    vnc_png=no
1815efe556adSCorentin Chary  fi
1816efe556adSCorentin Charyfi
1817efe556adSCorentin Chary
1818efe556adSCorentin Chary##########################################
181976655d6dSaliguori# fnmatch() probe, used for ACL routines
182076655d6dSaliguorifnmatch="no"
182176655d6dSaliguoricat > $TMPC << EOF
182276655d6dSaliguori#include <fnmatch.h>
182376655d6dSaliguoriint main(void)
182476655d6dSaliguori{
182576655d6dSaliguori    fnmatch("foo", "foo", 0);
182676655d6dSaliguori    return 0;
182776655d6dSaliguori}
182876655d6dSaliguoriEOF
182952166aa0SJuan Quintelaif compile_prog "" "" ; then
183076655d6dSaliguori   fnmatch="yes"
183176655d6dSaliguorifi
183276655d6dSaliguori
183376655d6dSaliguori##########################################
1834ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1835ee682d27SStefan Weilif test "$uuid" != "no" ; then
1836ee682d27SStefan Weil  uuid_libs="-luuid"
1837ee682d27SStefan Weil  cat > $TMPC << EOF
1838ee682d27SStefan Weil#include <uuid/uuid.h>
1839ee682d27SStefan Weilint main(void)
1840ee682d27SStefan Weil{
1841ee682d27SStefan Weil    uuid_t my_uuid;
1842ee682d27SStefan Weil    uuid_generate(my_uuid);
1843ee682d27SStefan Weil    return 0;
1844ee682d27SStefan Weil}
1845ee682d27SStefan WeilEOF
1846ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1847ee682d27SStefan Weil    uuid="yes"
1848ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1849ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1850ee682d27SStefan Weil  else
1851ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1852ee682d27SStefan Weil      feature_not_found "uuid"
1853ee682d27SStefan Weil    fi
1854ee682d27SStefan Weil    uuid=no
1855ee682d27SStefan Weil  fi
1856ee682d27SStefan Weilfi
1857ee682d27SStefan Weil
1858ee682d27SStefan Weil##########################################
1859dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1860dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1861dce512deSChristoph Hellwig  cat > $TMPC << EOF
1862ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
1863dce512deSChristoph Hellwig#include <xfs/xfs.h>
1864dce512deSChristoph Hellwigint main(void)
1865dce512deSChristoph Hellwig{
1866dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1867dce512deSChristoph Hellwig    return 0;
1868dce512deSChristoph Hellwig}
1869dce512deSChristoph HellwigEOF
1870dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1871dce512deSChristoph Hellwig    xfs="yes"
1872dce512deSChristoph Hellwig  else
1873dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1874dce512deSChristoph Hellwig      feature_not_found "xfs"
1875dce512deSChristoph Hellwig    fi
1876dce512deSChristoph Hellwig    xfs=no
1877dce512deSChristoph Hellwig  fi
1878dce512deSChristoph Hellwigfi
1879dce512deSChristoph Hellwig
1880dce512deSChristoph Hellwig##########################################
18818a16d273Sths# vde libraries probe
1882dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
18834baae0acSJuan Quintela  vde_libs="-lvdeplug"
18848a16d273Sths  cat > $TMPC << EOF
18858a16d273Sths#include <libvdeplug.h>
18864a7f0e06Spbrookint main(void)
18874a7f0e06Spbrook{
18884a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
1889fea08e08SPeter Maydell    char s[] = "";
1890fea08e08SPeter Maydell    vde_open(s, s, &a);
18914a7f0e06Spbrook    return 0;
18924a7f0e06Spbrook}
18938a16d273SthsEOF
189452166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
18954baae0acSJuan Quintela    vde=yes
18968e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
18978e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1898dfb278bdSJuan Quintela  else
1899dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1900dfb278bdSJuan Quintela      feature_not_found "vde"
1901dfb278bdSJuan Quintela    fi
1902dfb278bdSJuan Quintela    vde=no
19038a16d273Sths  fi
19048a16d273Sthsfi
19058a16d273Sths
19068a16d273Sths##########################################
190747e98658SCorey Bryant# libcap-ng library probe
190847e98658SCorey Bryantif test "$cap_ng" != "no" ; then
190947e98658SCorey Bryant  cap_libs="-lcap-ng"
191047e98658SCorey Bryant  cat > $TMPC << EOF
191147e98658SCorey Bryant#include <cap-ng.h>
191247e98658SCorey Bryantint main(void)
191347e98658SCorey Bryant{
191447e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
191547e98658SCorey Bryant    return 0;
191647e98658SCorey Bryant}
191747e98658SCorey BryantEOF
191847e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
191947e98658SCorey Bryant    cap_ng=yes
192047e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
192147e98658SCorey Bryant  else
192247e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
192347e98658SCorey Bryant      feature_not_found "cap_ng"
192447e98658SCorey Bryant    fi
192547e98658SCorey Bryant    cap_ng=no
192647e98658SCorey Bryant  fi
192747e98658SCorey Bryantfi
192847e98658SCorey Bryant
192947e98658SCorey Bryant##########################################
1930c2de5c91Smalc# Sound support libraries probe
19318f28f3fbSths
1932c2de5c91Smalcaudio_drv_probe()
1933c2de5c91Smalc{
1934c2de5c91Smalc    drv=$1
1935c2de5c91Smalc    hdr=$2
1936c2de5c91Smalc    lib=$3
1937c2de5c91Smalc    exp=$4
1938c2de5c91Smalc    cfl=$5
19398f28f3fbSths        cat > $TMPC << EOF
1940c2de5c91Smalc#include <$hdr>
1941c2de5c91Smalcint main(void) { $exp }
19428f28f3fbSthsEOF
194352166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
19448f28f3fbSths        :
19458f28f3fbSths    else
19468f28f3fbSths        echo
1947c2de5c91Smalc        echo "Error: $drv check failed"
1948c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
19498f28f3fbSths        echo
19508f28f3fbSths        exit 1
19518f28f3fbSths    fi
1952c2de5c91Smalc}
1953c2de5c91Smalc
19542fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1955c2de5c91Smalcfor drv in $audio_drv_list; do
1956c2de5c91Smalc    case $drv in
1957c2de5c91Smalc    alsa)
1958c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1959e35bcb0cSStefan Weil        "return snd_pcm_close((snd_pcm_t *)0);"
1960a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1961c2de5c91Smalc    ;;
1962c2de5c91Smalc
1963c2de5c91Smalc    fmod)
1964c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1965c2de5c91Smalc        echo
1966c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1967c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1968c2de5c91Smalc        echo
1969c2de5c91Smalc        exit 1
19708f28f3fbSths    fi
1971c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1972a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1973c2de5c91Smalc    ;;
1974c2de5c91Smalc
1975c2de5c91Smalc    esd)
1976c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1977a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
197867f86e8eSJuan Quintela    audio_pt_int="yes"
1979c2de5c91Smalc    ;;
1980b8e59f18Smalc
1981b8e59f18Smalc    pa)
1982a394aed2SMarc-André Lureau    audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
1983a394aed2SMarc-André Lureau        "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
1984a394aed2SMarc-André Lureau    libs_softmmu="-lpulse $libs_softmmu"
198567f86e8eSJuan Quintela    audio_pt_int="yes"
1986b8e59f18Smalc    ;;
1987b8e59f18Smalc
1988997e690aSJuan Quintela    coreaudio)
1989997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1990997e690aSJuan Quintela    ;;
1991997e690aSJuan Quintela
1992a4bf6780SJuan Quintela    dsound)
1993a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1994d5631638Smalc      audio_win_int="yes"
1995a4bf6780SJuan Quintela    ;;
1996a4bf6780SJuan Quintela
1997a4bf6780SJuan Quintela    oss)
1998a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1999a4bf6780SJuan Quintela    ;;
2000a4bf6780SJuan Quintela
2001a4bf6780SJuan Quintela    sdl|wav)
20022f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
20032f6a1ab0Sblueswir1    ;;
20042f6a1ab0Sblueswir1
2005d5631638Smalc    winwave)
2006d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
2007d5631638Smalc      audio_win_int="yes"
2008d5631638Smalc    ;;
2009d5631638Smalc
2010e4c63a6aSmalc    *)
20111c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
2012e4c63a6aSmalc        echo
2013e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
2014e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
2015e4c63a6aSmalc        echo
2016e4c63a6aSmalc        exit 1
2017e4c63a6aSmalc    }
2018e4c63a6aSmalc    ;;
2019c2de5c91Smalc    esac
2020c2de5c91Smalcdone
20218f28f3fbSths
20224d3b6f6eSbalrog##########################################
20232e4d9fb1Saurel32# BrlAPI probe
20242e4d9fb1Saurel32
20254ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
2026eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
20272e4d9fb1Saurel32  cat > $TMPC << EOF
20282e4d9fb1Saurel32#include <brlapi.h>
2029832ce9c2SScott Wood#include <stddef.h>
20302e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
20312e4d9fb1Saurel32EOF
203252166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
20332e4d9fb1Saurel32    brlapi=yes
2034264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
20354ffcedb6SJuan Quintela  else
20364ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
20374ffcedb6SJuan Quintela      feature_not_found "brlapi"
20384ffcedb6SJuan Quintela    fi
20394ffcedb6SJuan Quintela    brlapi=no
2040eb82284fSJuan Quintela  fi
2041eb82284fSJuan Quintelafi
20422e4d9fb1Saurel32
20432e4d9fb1Saurel32##########################################
20444d3b6f6eSbalrog# curses probe
2045e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
2046e095e2f3SStefan Weil    curses_list="-lpdcurses"
2047e095e2f3SStefan Weilelse
20484f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
2049e095e2f3SStefan Weilfi
20504d3b6f6eSbalrog
2051c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
2052c584a6d0SJuan Quintela  curses_found=no
20534d3b6f6eSbalrog  cat > $TMPC << EOF
20544d3b6f6eSbalrog#include <curses.h>
2055ef9a2524SStefan Weilint main(void) {
2056ef9a2524SStefan Weil  const char *s = curses_version();
2057ef9a2524SStefan Weil  resize_term(0, 0);
2058ef9a2524SStefan Weil  return s != 0;
2059ef9a2524SStefan Weil}
20604d3b6f6eSbalrogEOF
20614f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
20624f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
2063c584a6d0SJuan Quintela      curses_found=yes
20644f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
20654f78ef9aSJuan Quintela      break
20664d3b6f6eSbalrog    fi
20674f78ef9aSJuan Quintela  done
2068c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
2069c584a6d0SJuan Quintela    curses=yes
2070c584a6d0SJuan Quintela  else
2071c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
2072c584a6d0SJuan Quintela      feature_not_found "curses"
2073c584a6d0SJuan Quintela    fi
2074c584a6d0SJuan Quintela    curses=no
2075c584a6d0SJuan Quintela  fi
20764f78ef9aSJuan Quintelafi
20774d3b6f6eSbalrog
2078414f0dabSblueswir1##########################################
2079769ce76dSAlexander Graf# curl probe
2080769ce76dSAlexander Graf
2081a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
2082a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
20834e2b0658SPaolo Bonzinielse
20844e2b0658SPaolo Bonzini  curlconfig=curl-config
20854e2b0658SPaolo Bonzinifi
20864e2b0658SPaolo Bonzini
2087788c8196SJuan Quintelaif test "$curl" != "no" ; then
2088769ce76dSAlexander Graf  cat > $TMPC << EOF
2089769ce76dSAlexander Graf#include <curl/curl.h>
20900b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2091769ce76dSAlexander GrafEOF
20924e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
20934e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
2094b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
2095769ce76dSAlexander Graf    curl=yes
2096f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
2097f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
2098788c8196SJuan Quintela  else
2099788c8196SJuan Quintela    if test "$curl" = "yes" ; then
2100788c8196SJuan Quintela      feature_not_found "curl"
2101788c8196SJuan Quintela    fi
2102788c8196SJuan Quintela    curl=no
2103769ce76dSAlexander Graf  fi
2104769ce76dSAlexander Graffi # test "$curl"
2105769ce76dSAlexander Graf
2106769ce76dSAlexander Graf##########################################
2107fb599c9aSbalrog# bluez support probe
2108a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
2109e820e3f4Sbalrog  cat > $TMPC << EOF
2110e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
2111e820e3f4Sbalrogint main(void) { return bt_error(0); }
2112e820e3f4SbalrogEOF
2113a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2114a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
211552166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2116a20a6f46SJuan Quintela    bluez=yes
2117e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
2118e820e3f4Sbalrog  else
2119a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
2120a20a6f46SJuan Quintela      feature_not_found "bluez"
2121a20a6f46SJuan Quintela    fi
2122e820e3f4Sbalrog    bluez="no"
2123e820e3f4Sbalrog  fi
2124fb599c9aSbalrogfi
2125fb599c9aSbalrog
2126fb599c9aSbalrog##########################################
2127e18df141SAnthony Liguori# glib support probe
2128a52d28afSPaolo Bonzini
2129a52d28afSPaolo Bonziniif test "$mingw32" = yes; then
2130a52d28afSPaolo Bonzini    # g_poll is required in order to integrate with the glib main loop.
2131a52d28afSPaolo Bonzini    glib_req_ver=2.20
2132a52d28afSPaolo Bonzinielse
2133a52d28afSPaolo Bonzini    glib_req_ver=2.12
2134a52d28afSPaolo Bonzinifi
2135a52d28afSPaolo Bonziniif $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
2136a52d28afSPaolo Bonzinithen
21374b76a481SStefan Hajnoczi    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
21384b76a481SStefan Hajnoczi    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
213914015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
2140957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
2141e18df141SAnthony Liguorielse
2142a52d28afSPaolo Bonzini    echo "glib-$glib_req_ver required to compile QEMU"
2143e18df141SAnthony Liguori    exit 1
2144e18df141SAnthony Liguorifi
2145e18df141SAnthony Liguori
2146e18df141SAnthony Liguori##########################################
214717bff52bSM. Mohan Kumar# libcap probe
214817bff52bSM. Mohan Kumar
214917bff52bSM. Mohan Kumarif test "$cap" != "no" ; then
215017bff52bSM. Mohan Kumar  cat > $TMPC <<EOF
215117bff52bSM. Mohan Kumar#include <stdio.h>
215217bff52bSM. Mohan Kumar#include <sys/capability.h>
2153cc939743SStefan Weilint main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
215417bff52bSM. Mohan KumarEOF
215517bff52bSM. Mohan Kumar  if compile_prog "" "-lcap" ; then
215617bff52bSM. Mohan Kumar    cap=yes
215717bff52bSM. Mohan Kumar  else
215817bff52bSM. Mohan Kumar    cap=no
215917bff52bSM. Mohan Kumar  fi
216017bff52bSM. Mohan Kumarfi
216117bff52bSM. Mohan Kumar
216217bff52bSM. Mohan Kumar##########################################
2163e5d355d1Saliguori# pthread probe
21644b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
21653c529d93Saliguori
2166e5d355d1Saliguoripthread=no
2167414f0dabSblueswir1cat > $TMPC << EOF
21683c529d93Saliguori#include <pthread.h>
21697a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
21707a42bbe4SStefan Weilint main(void) {
21717a42bbe4SStefan Weil  pthread_t thread;
21727a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
21737a42bbe4SStefan Weil  return 0;
21747a42bbe4SStefan Weil}
2175414f0dabSblueswir1EOF
2176bd00d539SAndreas Färberif compile_prog "" "" ; then
2177bd00d539SAndreas Färber  pthread=yes
2178bd00d539SAndreas Färberelse
2179de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
218052166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
2181e5d355d1Saliguori      pthread=yes
2182e3c56761SPeter Portante      found=no
2183e3c56761SPeter Portante      for lib_entry in $LIBS; do
2184e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
2185e3c56761SPeter Portante          found=yes
2186e3c56761SPeter Portante          break
2187e3c56761SPeter Portante        fi
2188e3c56761SPeter Portante      done
2189e3c56761SPeter Portante      if test "$found" = "no"; then
21905572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
2191e3c56761SPeter Portante      fi
2192de65fe0fSSebastian Herbszt      break
2193414f0dabSblueswir1    fi
2194de65fe0fSSebastian Herbszt  done
2195bd00d539SAndreas Färberfi
2196414f0dabSblueswir1
21974617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
21984dd75c70SChristoph Hellwig  echo
21994dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
22004dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
22014dd75c70SChristoph Hellwig  echo
22024dd75c70SChristoph Hellwig  exit 1
2203e5d355d1Saliguorifi
2204e5d355d1Saliguori
2205bf9298b9Saliguori##########################################
2206f27aaf4bSChristian Brunner# rbd probe
2207f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
2208f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
2209f27aaf4bSChristian Brunner#include <stdio.h>
2210ad32e9c0SJosh Durgin#include <rbd/librbd.h>
2211f27aaf4bSChristian Brunnerint main(void) {
2212ad32e9c0SJosh Durgin    rados_t cluster;
2213ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
2214f27aaf4bSChristian Brunner    return 0;
2215f27aaf4bSChristian Brunner}
2216f27aaf4bSChristian BrunnerEOF
2217ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
2218f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
2219f27aaf4bSChristian Brunner    rbd=yes
2220f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
2221f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
2222f27aaf4bSChristian Brunner  else
2223f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
2224f27aaf4bSChristian Brunner      feature_not_found "rados block device"
2225f27aaf4bSChristian Brunner    fi
2226f27aaf4bSChristian Brunner    rbd=no
2227f27aaf4bSChristian Brunner  fi
2228f27aaf4bSChristian Brunnerfi
2229f27aaf4bSChristian Brunner
2230f27aaf4bSChristian Brunner##########################################
22315c6c3a6cSChristoph Hellwig# linux-aio probe
22325c6c3a6cSChristoph Hellwig
22335c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
22345c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
22355c6c3a6cSChristoph Hellwig#include <libaio.h>
22365c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2237832ce9c2SScott Wood#include <stddef.h>
22385c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
22395c6c3a6cSChristoph HellwigEOF
22405c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
22415c6c3a6cSChristoph Hellwig    linux_aio=yes
2242048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2243048d179fSPaul Brook    libs_tools="$libs_tools -laio"
22445c6c3a6cSChristoph Hellwig  else
22455c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
22465c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
22475c6c3a6cSChristoph Hellwig    fi
22483cfcae3cSLuiz Capitulino    linux_aio=no
22495c6c3a6cSChristoph Hellwig  fi
22505c6c3a6cSChristoph Hellwigfi
22515c6c3a6cSChristoph Hellwig
22525c6c3a6cSChristoph Hellwig##########################################
2253758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2254758e8e38SVenkateswararao Jujjuri (JV)
2255758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2256758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2257758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2258758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2259f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2260f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2261f2338fb4SPavel Borzenkov#else
22624f26f2b6SAvi Kivity#include <sys/xattr.h>
2263f2338fb4SPavel Borzenkov#endif
2264758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2265758e8e38SVenkateswararao Jujjuri (JV)EOF
22664f26f2b6SAvi Kivity  if compile_prog "" "" ; then
22674f26f2b6SAvi Kivity    attr=yes
22684f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2269f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2270758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2271758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
22724f26f2b6SAvi Kivity    libattr=yes
2273758e8e38SVenkateswararao Jujjuri (JV)  else
2274758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2275758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2276758e8e38SVenkateswararao Jujjuri (JV)    fi
2277758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2278758e8e38SVenkateswararao Jujjuri (JV)  fi
2279758e8e38SVenkateswararao Jujjuri (JV)fi
2280758e8e38SVenkateswararao Jujjuri (JV)
2281758e8e38SVenkateswararao Jujjuri (JV)##########################################
2282bf9298b9Saliguori# iovec probe
2283bf9298b9Saliguoricat > $TMPC <<EOF
2284db34f0b3Sblueswir1#include <sys/types.h>
2285bf9298b9Saliguori#include <sys/uio.h>
2286db34f0b3Sblueswir1#include <unistd.h>
2287f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
2288bf9298b9SaliguoriEOF
2289bf9298b9Saliguoriiovec=no
229052166aa0SJuan Quintelaif compile_prog "" "" ; then
2291bf9298b9Saliguori  iovec=yes
2292bf9298b9Saliguorifi
2293bf9298b9Saliguori
2294f652e6afSaurel32##########################################
2295ceb42de8Saliguori# preadv probe
2296ceb42de8Saliguoricat > $TMPC <<EOF
2297ceb42de8Saliguori#include <sys/types.h>
2298ceb42de8Saliguori#include <sys/uio.h>
2299ceb42de8Saliguori#include <unistd.h>
2300c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
2301ceb42de8SaliguoriEOF
2302ceb42de8Saliguoripreadv=no
230352166aa0SJuan Quintelaif compile_prog "" "" ; then
2304ceb42de8Saliguori  preadv=yes
2305ceb42de8Saliguorifi
2306ceb42de8Saliguori
2307ceb42de8Saliguori##########################################
2308f652e6afSaurel32# fdt probe
23092df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2310b41af4baSJuan Quintela  fdt_libs="-lfdt"
2311f652e6afSaurel32  cat > $TMPC << EOF
2312f652e6afSaurel32int main(void) { return 0; }
2313f652e6afSaurel32EOF
231452166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2315f652e6afSaurel32    fdt=yes
23162df87df7SJuan Quintela  else
23172df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
23182df87df7SJuan Quintela      feature_not_found "fdt"
23192df87df7SJuan Quintela    fi
2320de3a354aSMichael Walle    fdt_libs=
23212df87df7SJuan Quintela    fdt=no
2322f652e6afSaurel32  fi
2323f652e6afSaurel32fi
2324f652e6afSaurel32
232520ff075bSMichael Walle##########################################
232620ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
232720ff075bSMichael Walleif test "$opengl" != "no" ; then
232820ff075bSMichael Walle  opengl_libs="-lGL"
232920ff075bSMichael Walle  cat > $TMPC << EOF
233020ff075bSMichael Walle#include <X11/Xlib.h>
233120ff075bSMichael Walle#include <GL/gl.h>
233220ff075bSMichael Walle#include <GL/glx.h>
233384972cbbSStefan Weilint main(void) { return GL_VERSION != 0; }
233420ff075bSMichael WalleEOF
233520ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
233620ff075bSMichael Walle    opengl=yes
233720ff075bSMichael Walle  else
233820ff075bSMichael Walle    if test "$opengl" = "yes" ; then
233920ff075bSMichael Walle      feature_not_found "opengl"
234020ff075bSMichael Walle    fi
2341de3a354aSMichael Walle    opengl_libs=
234220ff075bSMichael Walle    opengl=no
234320ff075bSMichael Walle  fi
234420ff075bSMichael Wallefi
234520ff075bSMichael Walle
23463b3f24adSaurel32#
23473b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
23483b3f24adSaurel32# emulator.  This is done because older glibc versions don't
23493b3f24adSaurel32# have syscall stubs for these implemented.
23503b3f24adSaurel32#
23513b3f24adSaurel32atfile=no
23523b3f24adSaurel32cat > $TMPC << EOF
23533b3f24adSaurel32#define _ATFILE_SOURCE
23543b3f24adSaurel32#include <sys/types.h>
23553b3f24adSaurel32#include <fcntl.h>
23563b3f24adSaurel32#include <unistd.h>
23573b3f24adSaurel32
23583b3f24adSaurel32int
23593b3f24adSaurel32main(void)
23603b3f24adSaurel32{
23613b3f24adSaurel32	/* try to unlink nonexisting file */
23623b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
23633b3f24adSaurel32}
23643b3f24adSaurel32EOF
236552166aa0SJuan Quintelaif compile_prog "" "" ; then
23663b3f24adSaurel32  atfile=yes
23673b3f24adSaurel32fi
23683b3f24adSaurel32
236939386ac7Saurel32# Check for inotify functions when we are building linux-user
23703b3f24adSaurel32# emulator.  This is done because older glibc versions don't
23713b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
23723b3f24adSaurel32# don't provide them even if kernel supports them.
23733b3f24adSaurel32#
23743b3f24adSaurel32inotify=no
23753b3f24adSaurel32cat > $TMPC << EOF
23763b3f24adSaurel32#include <sys/inotify.h>
23773b3f24adSaurel32
23783b3f24adSaurel32int
23793b3f24adSaurel32main(void)
23803b3f24adSaurel32{
23813b3f24adSaurel32	/* try to start inotify */
23828690e420Saurel32	return inotify_init();
23833b3f24adSaurel32}
23843b3f24adSaurel32EOF
238552166aa0SJuan Quintelaif compile_prog "" "" ; then
23863b3f24adSaurel32  inotify=yes
23873b3f24adSaurel32fi
23883b3f24adSaurel32
2389c05c7a73SRiku Voipioinotify1=no
2390c05c7a73SRiku Voipiocat > $TMPC << EOF
2391c05c7a73SRiku Voipio#include <sys/inotify.h>
2392c05c7a73SRiku Voipio
2393c05c7a73SRiku Voipioint
2394c05c7a73SRiku Voipiomain(void)
2395c05c7a73SRiku Voipio{
2396c05c7a73SRiku Voipio    /* try to start inotify */
2397c05c7a73SRiku Voipio    return inotify_init1(0);
2398c05c7a73SRiku Voipio}
2399c05c7a73SRiku VoipioEOF
2400c05c7a73SRiku Voipioif compile_prog "" "" ; then
2401c05c7a73SRiku Voipio  inotify1=yes
2402c05c7a73SRiku Voipiofi
2403c05c7a73SRiku Voipio
2404ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2405ebc996f3SRiku Voipioutimens=no
2406ebc996f3SRiku Voipiocat > $TMPC << EOF
2407ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2408ebc996f3SRiku Voipio#include <stddef.h>
2409ebc996f3SRiku Voipio#include <fcntl.h>
24103014ee00SPeter Maydell#include <sys/stat.h>
2411ebc996f3SRiku Voipio
2412ebc996f3SRiku Voipioint main(void)
2413ebc996f3SRiku Voipio{
2414ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2415ebc996f3SRiku Voipio    futimens(0, NULL);
2416ebc996f3SRiku Voipio    return 0;
2417ebc996f3SRiku Voipio}
2418ebc996f3SRiku VoipioEOF
241952166aa0SJuan Quintelaif compile_prog "" "" ; then
2420ebc996f3SRiku Voipio  utimens=yes
2421ebc996f3SRiku Voipiofi
2422ebc996f3SRiku Voipio
2423099d6b0fSRiku Voipio# check if pipe2 is there
2424099d6b0fSRiku Voipiopipe2=no
2425099d6b0fSRiku Voipiocat > $TMPC << EOF
2426099d6b0fSRiku Voipio#include <unistd.h>
2427099d6b0fSRiku Voipio#include <fcntl.h>
2428099d6b0fSRiku Voipio
2429099d6b0fSRiku Voipioint main(void)
2430099d6b0fSRiku Voipio{
2431099d6b0fSRiku Voipio    int pipefd[2];
2432099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2433099d6b0fSRiku Voipio    return 0;
2434099d6b0fSRiku Voipio}
2435099d6b0fSRiku VoipioEOF
243652166aa0SJuan Quintelaif compile_prog "" "" ; then
2437099d6b0fSRiku Voipio  pipe2=yes
2438099d6b0fSRiku Voipiofi
2439099d6b0fSRiku Voipio
244040ff6d7eSKevin Wolf# check if accept4 is there
244140ff6d7eSKevin Wolfaccept4=no
244240ff6d7eSKevin Wolfcat > $TMPC << EOF
244340ff6d7eSKevin Wolf#include <sys/socket.h>
244440ff6d7eSKevin Wolf#include <stddef.h>
244540ff6d7eSKevin Wolf
244640ff6d7eSKevin Wolfint main(void)
244740ff6d7eSKevin Wolf{
244840ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
244940ff6d7eSKevin Wolf    return 0;
245040ff6d7eSKevin Wolf}
245140ff6d7eSKevin WolfEOF
245240ff6d7eSKevin Wolfif compile_prog "" "" ; then
245340ff6d7eSKevin Wolf  accept4=yes
245440ff6d7eSKevin Wolffi
245540ff6d7eSKevin Wolf
24563ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
24573ce34dfbSvibisreenivasansplice=no
24583ce34dfbSvibisreenivasancat > $TMPC << EOF
24593ce34dfbSvibisreenivasan#include <unistd.h>
24603ce34dfbSvibisreenivasan#include <fcntl.h>
24613ce34dfbSvibisreenivasan#include <limits.h>
24623ce34dfbSvibisreenivasan
24633ce34dfbSvibisreenivasanint main(void)
24643ce34dfbSvibisreenivasan{
246566ea0f22SStefan Weil    int len, fd = 0;
24663ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
24673ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
24683ce34dfbSvibisreenivasan    return 0;
24693ce34dfbSvibisreenivasan}
24703ce34dfbSvibisreenivasanEOF
247152166aa0SJuan Quintelaif compile_prog "" "" ; then
24723ce34dfbSvibisreenivasan  splice=yes
24733ce34dfbSvibisreenivasanfi
24743ce34dfbSvibisreenivasan
2475dcc38d1cSMarcelo Tosatti##########################################
2476dcc38d1cSMarcelo Tosatti# signalfd probe
2477dcc38d1cSMarcelo Tosattisignalfd="no"
2478dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2479dcc38d1cSMarcelo Tosatti#include <unistd.h>
2480dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2481dcc38d1cSMarcelo Tosatti#include <signal.h>
2482dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2483dcc38d1cSMarcelo TosattiEOF
2484dcc38d1cSMarcelo Tosatti
2485dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2486dcc38d1cSMarcelo Tosatti  signalfd=yes
2487dcc38d1cSMarcelo Tosattifi
2488dcc38d1cSMarcelo Tosatti
2489c2882b96SRiku Voipio# check if eventfd is supported
2490c2882b96SRiku Voipioeventfd=no
2491c2882b96SRiku Voipiocat > $TMPC << EOF
2492c2882b96SRiku Voipio#include <sys/eventfd.h>
2493c2882b96SRiku Voipio
2494c2882b96SRiku Voipioint main(void)
2495c2882b96SRiku Voipio{
249655cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2497c2882b96SRiku Voipio}
2498c2882b96SRiku VoipioEOF
2499c2882b96SRiku Voipioif compile_prog "" "" ; then
2500c2882b96SRiku Voipio  eventfd=yes
2501c2882b96SRiku Voipiofi
2502c2882b96SRiku Voipio
2503d0927938SUlrich Hecht# check for fallocate
2504d0927938SUlrich Hechtfallocate=no
2505d0927938SUlrich Hechtcat > $TMPC << EOF
2506d0927938SUlrich Hecht#include <fcntl.h>
2507d0927938SUlrich Hecht
2508d0927938SUlrich Hechtint main(void)
2509d0927938SUlrich Hecht{
2510d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2511d0927938SUlrich Hecht    return 0;
2512d0927938SUlrich Hecht}
2513d0927938SUlrich HechtEOF
25148fb03151SPeter Maydellif compile_prog "" "" ; then
2515d0927938SUlrich Hecht  fallocate=yes
2516d0927938SUlrich Hechtfi
2517d0927938SUlrich Hecht
2518c727f47dSPeter Maydell# check for sync_file_range
2519c727f47dSPeter Maydellsync_file_range=no
2520c727f47dSPeter Maydellcat > $TMPC << EOF
2521c727f47dSPeter Maydell#include <fcntl.h>
2522c727f47dSPeter Maydell
2523c727f47dSPeter Maydellint main(void)
2524c727f47dSPeter Maydell{
2525c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2526c727f47dSPeter Maydell    return 0;
2527c727f47dSPeter Maydell}
2528c727f47dSPeter MaydellEOF
25298fb03151SPeter Maydellif compile_prog "" "" ; then
2530c727f47dSPeter Maydell  sync_file_range=yes
2531c727f47dSPeter Maydellfi
2532c727f47dSPeter Maydell
2533dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2534dace20dcSPeter Maydellfiemap=no
2535dace20dcSPeter Maydellcat > $TMPC << EOF
2536dace20dcSPeter Maydell#include <sys/ioctl.h>
2537dace20dcSPeter Maydell#include <linux/fs.h>
2538dace20dcSPeter Maydell#include <linux/fiemap.h>
2539dace20dcSPeter Maydell
2540dace20dcSPeter Maydellint main(void)
2541dace20dcSPeter Maydell{
2542dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2543dace20dcSPeter Maydell    return 0;
2544dace20dcSPeter Maydell}
2545dace20dcSPeter MaydellEOF
25468fb03151SPeter Maydellif compile_prog "" "" ; then
2547dace20dcSPeter Maydell  fiemap=yes
2548dace20dcSPeter Maydellfi
2549dace20dcSPeter Maydell
2550d0927938SUlrich Hecht# check for dup3
2551d0927938SUlrich Hechtdup3=no
2552d0927938SUlrich Hechtcat > $TMPC << EOF
2553d0927938SUlrich Hecht#include <unistd.h>
2554d0927938SUlrich Hecht
2555d0927938SUlrich Hechtint main(void)
2556d0927938SUlrich Hecht{
2557d0927938SUlrich Hecht    dup3(0, 0, 0);
2558d0927938SUlrich Hecht    return 0;
2559d0927938SUlrich Hecht}
2560d0927938SUlrich HechtEOF
256178f5d726SJan Kiszkaif compile_prog "" "" ; then
2562d0927938SUlrich Hecht  dup3=yes
2563d0927938SUlrich Hechtfi
2564d0927938SUlrich Hecht
25653b6edd16SPeter Maydell# check for epoll support
25663b6edd16SPeter Maydellepoll=no
25673b6edd16SPeter Maydellcat > $TMPC << EOF
25683b6edd16SPeter Maydell#include <sys/epoll.h>
25693b6edd16SPeter Maydell
25703b6edd16SPeter Maydellint main(void)
25713b6edd16SPeter Maydell{
25723b6edd16SPeter Maydell    epoll_create(0);
25733b6edd16SPeter Maydell    return 0;
25743b6edd16SPeter Maydell}
25753b6edd16SPeter MaydellEOF
25768fb03151SPeter Maydellif compile_prog "" "" ; then
25773b6edd16SPeter Maydell  epoll=yes
25783b6edd16SPeter Maydellfi
25793b6edd16SPeter Maydell
25803b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
25813b6edd16SPeter Maydell# so we must check separately for their presence
25823b6edd16SPeter Maydellepoll_create1=no
25833b6edd16SPeter Maydellcat > $TMPC << EOF
25843b6edd16SPeter Maydell#include <sys/epoll.h>
25853b6edd16SPeter Maydell
25863b6edd16SPeter Maydellint main(void)
25873b6edd16SPeter Maydell{
258819e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
258919e83f6bSPeter Maydell     * a function being called. This is necessary so that on
259019e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
259119e83f6bSPeter Maydell     * the library but not declared in the header file we will
259219e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
259319e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
259419e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
259519e83f6bSPeter Maydell     */
2596c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
25973b6edd16SPeter Maydell}
25983b6edd16SPeter MaydellEOF
25998fb03151SPeter Maydellif compile_prog "" "" ; then
26003b6edd16SPeter Maydell  epoll_create1=yes
26013b6edd16SPeter Maydellfi
26023b6edd16SPeter Maydell
26033b6edd16SPeter Maydellepoll_pwait=no
26043b6edd16SPeter Maydellcat > $TMPC << EOF
26053b6edd16SPeter Maydell#include <sys/epoll.h>
26063b6edd16SPeter Maydell
26073b6edd16SPeter Maydellint main(void)
26083b6edd16SPeter Maydell{
26093b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
26103b6edd16SPeter Maydell    return 0;
26113b6edd16SPeter Maydell}
26123b6edd16SPeter MaydellEOF
26138fb03151SPeter Maydellif compile_prog "" "" ; then
26143b6edd16SPeter Maydell  epoll_pwait=yes
26153b6edd16SPeter Maydellfi
26163b6edd16SPeter Maydell
2617cc8ae6deSpbrook# Check if tools are available to build documentation.
2618a25dba17SJuan Quintelaif test "$docs" != "no" ; then
261901668d98SStefan Weil  if has makeinfo && has pod2man; then
2620a25dba17SJuan Quintela    docs=yes
262183a3ab8bSJuan Quintela  else
2622a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2623a25dba17SJuan Quintela      feature_not_found "docs"
262483a3ab8bSJuan Quintela    fi
2625a25dba17SJuan Quintela    docs=no
262683a3ab8bSJuan Quintela  fi
2627cc8ae6deSpbrookfi
2628cc8ae6deSpbrook
2629f514f41cSStefan Weil# Search for bswap_32 function
26306ae9a1f4SJuan Quintelabyteswap_h=no
26316ae9a1f4SJuan Quintelacat > $TMPC << EOF
26326ae9a1f4SJuan Quintela#include <byteswap.h>
26336ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
26346ae9a1f4SJuan QuintelaEOF
263552166aa0SJuan Quintelaif compile_prog "" "" ; then
26366ae9a1f4SJuan Quintela  byteswap_h=yes
26376ae9a1f4SJuan Quintelafi
26386ae9a1f4SJuan Quintela
2639f514f41cSStefan Weil# Search for bswap_32 function
26406ae9a1f4SJuan Quintelabswap_h=no
26416ae9a1f4SJuan Quintelacat > $TMPC << EOF
26426ae9a1f4SJuan Quintela#include <sys/endian.h>
26436ae9a1f4SJuan Quintela#include <sys/types.h>
26446ae9a1f4SJuan Quintela#include <machine/bswap.h>
26456ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
26466ae9a1f4SJuan QuintelaEOF
264752166aa0SJuan Quintelaif compile_prog "" "" ; then
26486ae9a1f4SJuan Quintela  bswap_h=yes
26496ae9a1f4SJuan Quintelafi
26506ae9a1f4SJuan Quintela
2651da93a1fdSaliguori##########################################
2652c589b249SRonnie Sahlberg# Do we have libiscsi
2653fa6acb0cSRonnie Sahlberg# We check for iscsi_unmap_sync() to make sure we have a
2654fa6acb0cSRonnie Sahlberg# recent enough version of libiscsi.
2655c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2656c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2657fa6acb0cSRonnie Sahlberg#include <stdio.h>
2658c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2659fa6acb0cSRonnie Sahlbergint main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2660c589b249SRonnie SahlbergEOF
2661417c9d72SAlexander Graf  if compile_prog "" "-liscsi" ; then
2662c589b249SRonnie Sahlberg    libiscsi="yes"
2663c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2664c589b249SRonnie Sahlberg  else
2665c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2666c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2667c589b249SRonnie Sahlberg    fi
2668c589b249SRonnie Sahlberg    libiscsi="no"
2669c589b249SRonnie Sahlberg  fi
2670c589b249SRonnie Sahlbergfi
2671c589b249SRonnie Sahlberg
2672c589b249SRonnie Sahlberg
2673c589b249SRonnie Sahlberg##########################################
2674da93a1fdSaliguori# Do we need librt
2675da93a1fdSaliguoricat > $TMPC <<EOF
2676da93a1fdSaliguori#include <signal.h>
2677da93a1fdSaliguori#include <time.h>
267866ea0f22SStefan Weilint main(void) { return clock_gettime(CLOCK_REALTIME, NULL); }
2679da93a1fdSaliguoriEOF
2680da93a1fdSaliguori
268152166aa0SJuan Quintelaif compile_prog "" "" ; then
268207ffa4bdSJuan Quintela  :
268352166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
268407ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2685da93a1fdSaliguorifi
2686da93a1fdSaliguori
268731ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2688179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
26896362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
26906362a53fSJuan Quintelafi
26916362a53fSJuan Quintela
2692de5071c5SBlue Swirl##########################################
2693cd4ec0b4SGerd Hoffmann# spice probe
2694cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2695cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2696cd4ec0b4SGerd Hoffmann#include <spice.h>
2697cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2698cd4ec0b4SGerd HoffmannEOF
2699710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2700710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
27014295e15aSAlon Levy  if $pkg_config --atleast-version=0.8.2 spice-server >/dev/null 2>&1 && \
27027e3efdacSAlon Levy     $pkg_config --atleast-version=0.8.1 spice-protocol > /dev/null 2>&1 && \
2703cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2704cd4ec0b4SGerd Hoffmann    spice="yes"
2705cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2706cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
27072e0e3c39SAlon Levy    spice_protocol_version=$($pkg_config --modversion spice-protocol)
27082e0e3c39SAlon Levy    spice_server_version=$($pkg_config --modversion spice-server)
2709020af1c4SAlon Levy    if $pkg_config --atleast-version=0.12.0 spice-protocol >/dev/null 2>&1; then
2710020af1c4SAlon Levy        spice_qxl_io_monitors_config_async="yes"
2711020af1c4SAlon Levy    fi
2712cd4ec0b4SGerd Hoffmann  else
2713cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2714cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2715cd4ec0b4SGerd Hoffmann    fi
2716cd4ec0b4SGerd Hoffmann    spice="no"
2717cd4ec0b4SGerd Hoffmann  fi
2718cd4ec0b4SGerd Hoffmannfi
2719cd4ec0b4SGerd Hoffmann
2720111a38b0SRobert Relyea# check for libcacard for smartcard support
2721111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2722111a38b0SRobert Relyea    smartcard="yes"
2723111a38b0SRobert Relyea    smartcard_cflags=""
2724111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2725111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
27265f01e06fSSergei Trofimovich      cat > $TMPC << EOF
27275f01e06fSSergei Trofimovich#include <pk11pub.h>
27285f01e06fSSergei Trofimovichint main(void) { PK11_FreeSlot(0); return 0; }
27295f01e06fSSergei TrofimovichEOF
27300b22ef0fSPeter Maydell        smartcard_includes="-I\$(SRC_PATH)/libcacard"
27318c741c22SAlon Levy        libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
27328c741c22SAlon Levy        libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
27336ca026cbSPeter Maydell        test_cflags="$libcacard_cflags"
27346ca026cbSPeter Maydell        # The header files in nss < 3.13.3 have a bug which causes them to
27356ca026cbSPeter Maydell        # emit a warning. If we're going to compile QEMU with -Werror, then
27366ca026cbSPeter Maydell        # test that the headers don't have this bug. Otherwise we would pass
27376ca026cbSPeter Maydell        # the configure test but fail to compile QEMU later.
27386ca026cbSPeter Maydell        if test "$werror" = "yes"; then
27396ca026cbSPeter Maydell            test_cflags="-Werror $test_cflags"
27406ca026cbSPeter Maydell        fi
27415f01e06fSSergei Trofimovich        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
27426ca026cbSPeter Maydell          compile_prog "$test_cflags" "$libcacard_libs"; then
27435f01e06fSSergei Trofimovich            smartcard_nss="yes"
27440b22ef0fSPeter Maydell            QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
27450b22ef0fSPeter Maydell            QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
2746ad4cf3f6SPaul Brook            libs_softmmu="$libcacard_libs $libs_softmmu"
2747111a38b0SRobert Relyea        else
2748111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2749111a38b0SRobert Relyea                feature_not_found "nss"
2750111a38b0SRobert Relyea            fi
2751111a38b0SRobert Relyea            smartcard_nss="no"
2752111a38b0SRobert Relyea        fi
2753111a38b0SRobert Relyea    fi
2754111a38b0SRobert Relyeafi
2755111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2756111a38b0SRobert Relyea    smartcard_nss="no"
2757111a38b0SRobert Relyeafi
2758111a38b0SRobert Relyea
275969354a83SHans de Goede# check for usbredirparser for usb network redirection support
276069354a83SHans de Goedeif test "$usb_redir" != "no" ; then
2761*be4a8928SHans de Goede    if $pkg_config --atleast-version=0.5 libusbredirparser >/dev/null 2>&1 ; then
276269354a83SHans de Goede        usb_redir="yes"
276369354a83SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
276469354a83SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
276569354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
276669354a83SHans de Goede        LIBS="$LIBS $usb_redir_libs"
276769354a83SHans de Goede    else
276869354a83SHans de Goede        if test "$usb_redir" = "yes"; then
276969354a83SHans de Goede            feature_not_found "usb-redir"
277069354a83SHans de Goede        fi
277169354a83SHans de Goede        usb_redir="no"
277269354a83SHans de Goede    fi
277369354a83SHans de Goedefi
277469354a83SHans de Goede
2775cd4ec0b4SGerd Hoffmann##########################################
2776cd4ec0b4SGerd Hoffmann
2777747bbdf7SBlue Swirl##########################################
27785f6b9e8fSBlue Swirl# check if we have fdatasync
27795f6b9e8fSBlue Swirl
27805f6b9e8fSBlue Swirlfdatasync=no
27815f6b9e8fSBlue Swirlcat > $TMPC << EOF
27825f6b9e8fSBlue Swirl#include <unistd.h>
2783d1722a27SAlexandre Raymondint main(void) {
2784d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2785d1722a27SAlexandre Raymondreturn fdatasync(0);
2786d1722a27SAlexandre Raymond#else
2787e172fe11SStefan Weil#error Not supported
2788d1722a27SAlexandre Raymond#endif
2789d1722a27SAlexandre Raymond}
27905f6b9e8fSBlue SwirlEOF
27915f6b9e8fSBlue Swirlif compile_prog "" "" ; then
27925f6b9e8fSBlue Swirl    fdatasync=yes
27935f6b9e8fSBlue Swirlfi
27945f6b9e8fSBlue Swirl
279594a420b1SStefan Hajnoczi##########################################
2796e78815a5SAndreas Färber# check if we have madvise
2797e78815a5SAndreas Färber
2798e78815a5SAndreas Färbermadvise=no
2799e78815a5SAndreas Färbercat > $TMPC << EOF
2800e78815a5SAndreas Färber#include <sys/types.h>
2801e78815a5SAndreas Färber#include <sys/mman.h>
2802832ce9c2SScott Wood#include <stddef.h>
2803e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2804e78815a5SAndreas FärberEOF
2805e78815a5SAndreas Färberif compile_prog "" "" ; then
2806e78815a5SAndreas Färber    madvise=yes
2807e78815a5SAndreas Färberfi
2808e78815a5SAndreas Färber
2809e78815a5SAndreas Färber##########################################
2810e78815a5SAndreas Färber# check if we have posix_madvise
2811e78815a5SAndreas Färber
2812e78815a5SAndreas Färberposix_madvise=no
2813e78815a5SAndreas Färbercat > $TMPC << EOF
2814e78815a5SAndreas Färber#include <sys/mman.h>
2815832ce9c2SScott Wood#include <stddef.h>
2816e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2817e78815a5SAndreas FärberEOF
2818e78815a5SAndreas Färberif compile_prog "" "" ; then
2819e78815a5SAndreas Färber    posix_madvise=yes
2820e78815a5SAndreas Färberfi
2821e78815a5SAndreas Färber
2822e78815a5SAndreas Färber##########################################
282394a420b1SStefan Hajnoczi# check if trace backend exists
282494a420b1SStefan Hajnoczi
2825650ab98dSLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
282694a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
282794a420b1SStefan Hajnoczi  echo
282894a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
282994a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
283094a420b1SStefan Hajnoczi  echo
283194a420b1SStefan Hajnoczi  exit 1
283294a420b1SStefan Hajnoczifi
283394a420b1SStefan Hajnoczi
28347e24e92aSStefan Hajnoczi##########################################
28357e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
28367e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
28377e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
28387e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
28397e24e92aSStefan Hajnoczi#include <ust/marker.h>
28407e24e92aSStefan Hajnocziint main(void) { return 0; }
28417e24e92aSStefan HajnocziEOF
28427e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
284394b4fefaSLluís Vilanova    LIBS="-lust -lurcu-bp $LIBS"
2844c9a2e37cSLluís Vilanova    libs_qga="-lust -lurcu-bp $libs_qga"
28457e24e92aSStefan Hajnoczi  else
28467e24e92aSStefan Hajnoczi    echo
28477e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
28487e24e92aSStefan Hajnoczi    echo
28497e24e92aSStefan Hajnoczi    exit 1
28507e24e92aSStefan Hajnoczi  fi
28517e24e92aSStefan Hajnoczifi
2852b3d08c02SDaniel P. Berrange
2853b3d08c02SDaniel P. Berrange##########################################
2854b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2855b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2856b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2857b3d08c02SDaniel P. Berrange    echo
2858b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2859b3d08c02SDaniel P. Berrange    echo
2860b3d08c02SDaniel P. Berrange    exit 1
2861b3d08c02SDaniel P. Berrange  fi
2862c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2863c276b17dSDaniel P. Berrange  if has 'stap' ; then
2864c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2865c276b17dSDaniel P. Berrange  fi
2866b3d08c02SDaniel P. Berrangefi
2867b3d08c02SDaniel P. Berrange
28687e24e92aSStefan Hajnoczi##########################################
2869023367e6SWolfgang Mauerer# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2870023367e6SWolfgang Mauerer# use i686 as default anyway, but for those that don't, an explicit
2871023367e6SWolfgang Mauerer# specification is necessary
28721ba16968SStefan Weilif test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
2873023367e6SWolfgang Mauerer  cat > $TMPC << EOF
28747ace252aSStefan Weilstatic int sfaa(int *ptr)
2875023367e6SWolfgang Mauerer{
2876023367e6SWolfgang Mauerer  return __sync_fetch_and_and(ptr, 0);
2877023367e6SWolfgang Mauerer}
2878023367e6SWolfgang Mauerer
2879023367e6SWolfgang Mauererint main(int argc, char **argv)
2880023367e6SWolfgang Mauerer{
2881023367e6SWolfgang Mauerer  int val = 42;
2882023367e6SWolfgang Mauerer  sfaa(&val);
2883023367e6SWolfgang Mauerer  return val;
2884023367e6SWolfgang Mauerer}
2885023367e6SWolfgang MauererEOF
2886023367e6SWolfgang Mauerer  if ! compile_prog "" "" ; then
2887caa50971SPeter Maydell    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2888023367e6SWolfgang Mauerer  fi
2889023367e6SWolfgang Mauererfi
2890023367e6SWolfgang Mauerer
2891023367e6SWolfgang Mauerer##########################################
2892519175a2SAlex Barcelo# check and set a backend for coroutine
2893d0e2fce5SAneesh Kumar K.V
2894519175a2SAlex Barcelo# default is ucontext, but always fallback to gthread
2895519175a2SAlex Barcelo# windows autodetected by make
2896519175a2SAlex Barceloif test "$coroutine" = "" -o "$coroutine" = "ucontext"; then
2897d0e2fce5SAneesh Kumar K.V  if test "$darwin" != "yes"; then
2898d0e2fce5SAneesh Kumar K.V    cat > $TMPC << EOF
2899d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
2900cdf84806SPeter Maydell#ifdef __stub_makecontext
2901cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
2902cdf84806SPeter Maydell#endif
290375cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
2904d0e2fce5SAneesh Kumar K.VEOF
2905d0e2fce5SAneesh Kumar K.V    if compile_prog "" "" ; then
2906519175a2SAlex Barcelo        coroutine_backend=ucontext
2907519175a2SAlex Barcelo    else
2908519175a2SAlex Barcelo	coroutine_backend=gthread
2909d0e2fce5SAneesh Kumar K.V    fi
2910519175a2SAlex Barcelo  else
2911519175a2SAlex Barcelo    echo "Silently falling back into gthread backend under darwin"
2912519175a2SAlex Barcelo  fi
2913519175a2SAlex Barceloelif test "$coroutine" = "gthread" ; then
2914519175a2SAlex Barcelo  coroutine_backend=gthread
2915519175a2SAlex Barceloelif test "$coroutine" = "windows" ; then
2916519175a2SAlex Barcelo  coroutine_backend=windows
2917fe91bfa8SAlex Barceloelif test "$coroutine" = "sigaltstack" ; then
2918fe91bfa8SAlex Barcelo  coroutine_backend=sigaltstack
2919519175a2SAlex Barceloelse
2920519175a2SAlex Barcelo  echo
2921519175a2SAlex Barcelo  echo "Error: unknown coroutine backend $coroutine"
2922519175a2SAlex Barcelo  echo
2923519175a2SAlex Barcelo  exit 1
2924d0e2fce5SAneesh Kumar K.Vfi
2925d0e2fce5SAneesh Kumar K.V
2926d0e2fce5SAneesh Kumar K.V##########################################
2927d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
2928d2042378SAneesh Kumar K.V
29294e1797f9SStefan Weilopen_by_handle_at=no
2930d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
2931d2042378SAneesh Kumar K.V#include <fcntl.h>
2932acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
2933acc55ba8SStefan Weil# error missing definition
2934acc55ba8SStefan Weil#else
293575cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
2936acc55ba8SStefan Weil#endif
2937d2042378SAneesh Kumar K.VEOF
2938d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
2939d2042378SAneesh Kumar K.V    open_by_handle_at=yes
2940d2042378SAneesh Kumar K.Vfi
2941d2042378SAneesh Kumar K.V
2942e06a765eSHarsh Prateek Bora########################################
2943e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
2944e06a765eSHarsh Prateek Bora
2945e06a765eSHarsh Prateek Boralinux_magic_h=no
2946e06a765eSHarsh Prateek Boracat > $TMPC << EOF
2947e06a765eSHarsh Prateek Bora#include <linux/magic.h>
2948e06a765eSHarsh Prateek Boraint main(void) {
294975cafad7SStefan Weil  return 0;
2950e06a765eSHarsh Prateek Bora}
2951e06a765eSHarsh Prateek BoraEOF
2952e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
2953e06a765eSHarsh Prateek Bora    linux_magic_h=yes
2954e06a765eSHarsh Prateek Borafi
2955e06a765eSHarsh Prateek Bora
29568ab1bf12SLuiz Capitulino########################################
295706d71fa1SPeter Maydell# check whether we can disable the -Wunused-but-set-variable
295806d71fa1SPeter Maydell# option with a pragma (this is needed to silence a warning in
295906d71fa1SPeter Maydell# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.)
296006d71fa1SPeter Maydell# This test has to be compiled with -Werror as otherwise an
296106d71fa1SPeter Maydell# unknown pragma is only a warning.
296206d71fa1SPeter Maydellpragma_disable_unused_but_set=no
296306d71fa1SPeter Maydellcat > $TMPC << EOF
296406d71fa1SPeter Maydell#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
296506d71fa1SPeter Maydellint main(void) {
296606d71fa1SPeter Maydell    return 0;
296706d71fa1SPeter Maydell}
296806d71fa1SPeter MaydellEOF
296906d71fa1SPeter Maydellif compile_prog "-Werror" "" ; then
297006d71fa1SPeter Maydell    pragma_disable_unused_but_set=yes
297106d71fa1SPeter Maydellfi
297206d71fa1SPeter Maydell
297306d71fa1SPeter Maydell########################################
297462fe8331SChristian Borntraeger# check if we have valgrind/valgrind.h and valgrind/memcheck.h
29753f4349dcSKevin Wolf
29763f4349dcSKevin Wolfvalgrind_h=no
29773f4349dcSKevin Wolfcat > $TMPC << EOF
29783f4349dcSKevin Wolf#include <valgrind/valgrind.h>
297962fe8331SChristian Borntraeger#include <valgrind/memcheck.h>
29803f4349dcSKevin Wolfint main(void) {
29813f4349dcSKevin Wolf  return 0;
29823f4349dcSKevin Wolf}
29833f4349dcSKevin WolfEOF
29843f4349dcSKevin Wolfif compile_prog "" "" ; then
29853f4349dcSKevin Wolf    valgrind_h=yes
29863f4349dcSKevin Wolffi
29873f4349dcSKevin Wolf
29883f4349dcSKevin Wolf########################################
29898ab1bf12SLuiz Capitulino# check if environ is declared
29908ab1bf12SLuiz Capitulino
29918ab1bf12SLuiz Capitulinohas_environ=no
29928ab1bf12SLuiz Capitulinocat > $TMPC << EOF
29938ab1bf12SLuiz Capitulino#include <unistd.h>
29948ab1bf12SLuiz Capitulinoint main(void) {
2995c075a723SBlue Swirl    environ = 0;
29968ab1bf12SLuiz Capitulino    return 0;
29978ab1bf12SLuiz Capitulino}
29988ab1bf12SLuiz CapitulinoEOF
29998ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
30008ab1bf12SLuiz Capitulino    has_environ=yes
30018ab1bf12SLuiz Capitulinofi
30028ab1bf12SLuiz Capitulino
3003d2042378SAneesh Kumar K.V##########################################
3004e86ecd4bSJuan Quintela# End of CC checks
3005e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3006e86ecd4bSJuan Quintela
3007e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
30088be74dc0SAvi Kivity  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3009e86ecd4bSJuan Quintelafi
3010a316e378SJuan Quintela
301120ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
301220ff6c80SAnthony Liguori# enable/disable
301320ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
301420ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
301520ff6c80SAnthony Liguori	zero_malloc="no"
301620ff6c80SAnthony Liguori    else
301720ff6c80SAnthony Liguori	zero_malloc="yes"
301820ff6c80SAnthony Liguori    fi
301920ff6c80SAnthony Liguorifi
302020ff6c80SAnthony Liguori
30216ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
30226ca026cbSPeter Maydellif test "$werror" = "yes"; then
30236ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
30246ca026cbSPeter Maydellfi
30256ca026cbSPeter Maydell
3026e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
3027e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
30281156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
3029e86ecd4bSJuan Quintela    fi
3030e86ecd4bSJuan Quintelafi
3031e86ecd4bSJuan Quintela
303294dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
303394dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
303494dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
303594dd53c5SGerd Hoffmannelse
303694dd53c5SGerd Hoffmann    POD2MAN="pod2man"
303794dd53c5SGerd Hoffmannfi
303894dd53c5SGerd Hoffmann
3039952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3040952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3041952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
3042952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3043952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
3044952afb71SBlue Swirl        fi
3045952afb71SBlue Swirl    done
3046952afb71SBlue Swirlfi
3047952afb71SBlue Swirl
304810ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
3049528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
30505a67135aSbellard
30514b1c11fdSDaniel P. Berrangetools=""
30524b1c11fdSDaniel P. Berrangeif test "$want_tools" = "yes" ; then
3053ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
30544b1c11fdSDaniel P. Berrange  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
30554b1c11fdSDaniel P. Berrange    tools="qemu-nbd\$(EXESUF) $tools"
30564b1c11fdSDaniel P. Berrange  fi
30574b1c11fdSDaniel P. Berrangefi
30584b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
3059983eef5aSMeador Inge  if test "$virtfs" != no ; then
3060be5ea8edSAnthony Liguori    if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3061983eef5aSMeador Inge      virtfs=yes
306217bff52bSM. Mohan Kumar      tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3063983eef5aSMeador Inge    else
3064983eef5aSMeador Inge      if test "$virtfs" = yes; then
3065263ddcc8SHarsh Prateek Bora        echo "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3066263ddcc8SHarsh Prateek Bora        exit 1
3067983eef5aSMeador Inge      fi
306817500370SAndreas Färber      virtfs=no
3069983eef5aSMeador Inge    fi
307017bff52bSM. Mohan Kumar  fi
3071ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3072d138cee9SMichael Roth    if [ "$guest_agent" = "yes" ]; then
307348ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
3074d138cee9SMichael Roth    fi
3075ca35f780SPaolo Bonzini  fi
307600c705fbSPaolo Bonzini  if test "$smartcard_nss" = "yes" ; then
307700c705fbSPaolo Bonzini    tools="vscclient\$(EXESUF) $tools"
307800c705fbSPaolo Bonzini  fi
30794b1c11fdSDaniel P. Berrangefi
3080ca35f780SPaolo Bonzini
3081ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3082ca35f780SPaolo Bonziniroms=
3083ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3084ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3085ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
3086ca35f780SPaolo Bonzini  roms="optionrom"
3087ca35f780SPaolo Bonzinifi
3088d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
308939ac8455SDavid Gibson  roms="$roms spapr-rtas"
309039ac8455SDavid Gibsonfi
3091ca35f780SPaolo Bonzini
30927d13299dSbellardecho "Install prefix    $prefix"
3093c00b2808SEduardo Habkostecho "BIOS directory    `eval echo $qemu_datadir`"
3094f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
30953aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
30968bf188aaSMichael Tokarevecho "libexec directory `eval echo $libexecdir`"
30970f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
30981c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
309911d9f695Sbellardif test "$mingw32" = "no" ; then
3100f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
310143ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
310211d9f695Sbellardfi
31035a67135aSbellardecho "Source path       $source_path"
31047d13299dSbellardecho "C compiler        $cc"
310583469015Sbellardecho "Host C compiler   $host_cc"
31063c4a4d0dSPeter Maydellecho "Objective-C compiler $objcc"
31070c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
3108a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
31090c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
31107d13299dSbellardecho "make              $make"
31116a882643Spbrookecho "install           $install"
3112c886edfbSBlue Swirlecho "python            $python"
3113e2d8830eSBradif test "$slirp" = "yes" ; then
3114e2d8830eSBrad    echo "smbd              $smbd"
3115e2d8830eSBradfi
3116a98fd896Sbellardecho "host CPU          $cpu"
3117de83cd02Sbellardecho "host big endian   $bigendian"
311897a847bcSbellardecho "target list       $target_list"
3119ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
31207d13299dSbellardecho "gprof enabled     $gprof"
312103b4fe7dSaliguoriecho "sparse enabled    $sparse"
31221625af87Saliguoriecho "strip binaries    $strip_opt"
312305c2a3e7Sbellardecho "profiler          $profiler"
312443ce4dfeSbellardecho "static build      $static"
312585aa5189Sbellardecho "-Werror enabled   $werror"
31265b0753e0Sbellardif test "$darwin" = "yes" ; then
31275b0753e0Sbellard    echo "Cocoa support     $cocoa"
31285b0753e0Sbellardfi
312997a847bcSbellardecho "SDL support       $sdl"
31304d3b6f6eSbalrogecho "curses support    $curses"
3131769ce76dSAlexander Grafecho "curl support      $curl"
313267b915a5Sbellardecho "mingw32 support   $mingw32"
31330c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
31340c58ac1cSmalcecho "Extra audio cards $audio_card_list"
3135eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
31368ff9cbf7Smalcecho "Mixer emulation   $mixemu"
3137983eef5aSMeador Ingeecho "VirtFS support    $virtfs"
3138821601eaSJes Sorensenecho "VNC support       $vnc"
3139821601eaSJes Sorensenif test "$vnc" = "yes" ; then
31408d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
31412f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
31422f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
3143efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
3144821601eaSJes Sorensenfi
31453142255cSblueswir1if test -n "$sparc_cpu"; then
31463142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
31473142255cSblueswir1fi
3148e37630caSaliguoriecho "xen support       $xen"
31492e4d9fb1Saurel32echo "brlapi support    $brlapi"
3150a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
3151a25dba17SJuan Quintelaecho "Documentation     $docs"
3152c5937220Spbrook[ ! -z "$uname_release" ] && \
3153c5937220Spbrookecho "uname -r          $uname_release"
3154bd0c5661Spbrookecho "NPTL support      $nptl"
3155379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
315640d6444eSAvi Kivityecho "PIE               $pie"
31578a16d273Sthsecho "vde support       $vde"
31585c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
3159758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
316077755340Sthsecho "Install blobs     $blobs"
3161b31a0277SJuan Quintelaecho "KVM support       $kvm"
31629195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
3163f652e6afSaurel32echo "fdt support       $fdt"
3164ceb42de8Saliguoriecho "preadv support    $preadv"
31655f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
3166e78815a5SAndreas Färberecho "madvise           $madvise"
3167e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
3168ee682d27SStefan Weilecho "uuid support      $uuid"
316947e98658SCorey Bryantecho "libcap-ng support $cap_ng"
3170d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
317194a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
31729410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
31732e0e3c39SAlon Levyecho "spice support     $spice ($spice_protocol_version/$spice_server_version)"
3174f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
3175dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
3176111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
317769354a83SHans de Goedeecho "usb net redir     $usb_redir"
317820ff075bSMichael Walleecho "OpenGL support    $opengl"
3179c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
3180d138cee9SMichael Rothecho "build guest agent $guest_agent"
3181f794573eSEduardo Otuboecho "seccomp support   $seccomp"
3182519175a2SAlex Barceloecho "coroutine backend $coroutine_backend"
318367b915a5Sbellard
31841ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
318524b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
3186e8cd23deSbellardfi
318797a847bcSbellard
318898ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
31894bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
319097a847bcSbellard
319198ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
319298ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
319398ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
319498ec69acSJuan Quintelaecho >> $config_host_mak
319598ec69acSJuan Quintela
3196e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
319799d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
319899d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
31993aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
32008bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
32010f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
320299d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
320399d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
320422d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
32059afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
32069afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
32078bf188aaSMichael Tokarevecho "CONFIG_QEMU_HELPERDIR=\"$libexecdir\"" >> $config_host_mak
3208804edf29SJuan Quintela
320998ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3210f8393946Saurel32if test "$debug_tcg" = "yes" ; then
32112358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3212f8393946Saurel32fi
3213f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
32142358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
3215f3d08ee6SPaul Brookfi
32161625af87Saliguoriif test "$strip_opt" = "yes" ; then
321752ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
32181625af87Saliguorifi
32197d13299dSbellardif test "$bigendian" = "yes" ; then
3220e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
322197a847bcSbellardfi
322267b915a5Sbellardif test "$mingw32" = "yes" ; then
322398ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
32249fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
32259fe6de94SBlue Swirl  version_major=${rc_version%%.*}
32269fe6de94SBlue Swirl  rc_version=${rc_version#*.}
32279fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
32289fe6de94SBlue Swirl  rc_version=${rc_version#*.}
32299fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
32309fe6de94SBlue Swirl  version_micro=0
32319fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
32329fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3233210fa556Spbrookelse
323435f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3235210fa556Spbrookfi
3236128ab2ffSblueswir1
3237dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3238dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3239dffcb71cSMark McLoughlinfi
3240dffcb71cSMark McLoughlin
324183fb7adfSbellardif test "$darwin" = "yes" ; then
324298ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
324383fb7adfSbellardfi
3244b29fe3edSmalc
3245b29fe3edSmalcif test "$aix" = "yes" ; then
324698ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
3247b29fe3edSmalcfi
3248b29fe3edSmalc
3249ec530c81Sbellardif test "$solaris" = "yes" ; then
325098ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
32512358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
32520475a5caSths  if test "$needs_libsunmath" = "yes" ; then
325375b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
32540475a5caSths  fi
3255ec530c81Sbellardfi
3256179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3257179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3258179cf400SAndreas Färberfi
325997a847bcSbellardif test "$static" = "yes" ; then
326098ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
326197a847bcSbellardfi
32621ba16968SStefan Weilif test "$profiler" = "yes" ; then
32632358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
326405c2a3e7Sbellardfi
3265c20709aaSbellardif test "$slirp" = "yes" ; then
326698ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
3267e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3268f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
3269c20709aaSbellardfi
32708a16d273Sthsif test "$vde" = "yes" ; then
327198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
32728a16d273Sthsfi
327347e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
327447e98658SCorey Bryant  echo "CONFIG_LIBCAP=y" >> $config_host_mak
327547e98658SCorey Bryantfi
32760c58ac1cSmalcfor card in $audio_card_list; do
3277bb55b712SStefan Weil    def=CONFIG_`echo $card | LC_ALL=C tr '[a-z]' '[A-Z]'`
327898ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
32790c58ac1cSmalcdone
32802358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
32810c58ac1cSmalcfor drv in $audio_drv_list; do
3282bb55b712SStefan Weil    def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
328398ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
3284923e4521Smalc    if test "$drv" = "fmod"; then
32857aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3286fb065187Sbellard    fi
32870c58ac1cSmalcdone
328867f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
328967f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
329067f86e8eSJuan Quintelafi
3291d5631638Smalcif test "$audio_win_int" = "yes" ; then
3292d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3293d5631638Smalcfi
3294eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
32958ff9cbf7Smalcif test "$mixemu" = "yes" ; then
329698ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
32978ff9cbf7Smalcfi
3298821601eaSJes Sorensenif test "$vnc" = "yes" ; then
3299821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
3300821601eaSJes Sorensenfi
33018d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
330298ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
3303525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
33048d5d2d4cSthsfi
33052f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
330698ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
330760ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
33082f9606b3Saliguorifi
3309821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
33102f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
33112f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
33122f6f5c7aSCorentin Charyfi
3313821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
3314efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3315efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
3316efe556adSCorentin Charyfi
331776655d6dSaliguoriif test "$fnmatch" = "yes" ; then
33182358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
331976655d6dSaliguorifi
3320ee682d27SStefan Weilif test "$uuid" = "yes" ; then
3321ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
3322ee682d27SStefan Weilfi
3323dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3324dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3325dce512deSChristoph Hellwigfi
3326b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
332798ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
33282358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
332998ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
333098ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
3331a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
333298ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
3333cc8ae6deSpbrookfi
33341ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
333598ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
33368ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
333749ecc3faSbellardfi
333849ecc3faSbellardif test "$cocoa" = "yes" ; then
333998ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
334049ecc3faSbellardfi
33414d3b6f6eSbalrogif test "$curses" = "yes" ; then
334298ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
3343ab4e5602SJan Kiszkafi
33443b3f24adSaurel32if test "$atfile" = "yes" ; then
33452358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
33463b3f24adSaurel32fi
3347ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
33482358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3349ebc996f3SRiku Voipiofi
3350099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
33512358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
3352099d6b0fSRiku Voipiofi
335340ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
335440ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
335540ff6d7eSKevin Wolffi
33563ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
33572358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
33583ce34dfbSvibisreenivasanfi
3359c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
3360c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
3361c2882b96SRiku Voipiofi
3362d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
3363d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3364d0927938SUlrich Hechtfi
3365c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
3366c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3367c727f47dSPeter Maydellfi
3368dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
3369dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
3370dace20dcSPeter Maydellfi
3371d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
3372d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
3373d0927938SUlrich Hechtfi
33743b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
33753b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
33763b6edd16SPeter Maydellfi
33773b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
33783b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
33793b6edd16SPeter Maydellfi
33803b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
33813b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
33823b6edd16SPeter Maydellfi
33833b3f24adSaurel32if test "$inotify" = "yes" ; then
33842358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
33853b3f24adSaurel32fi
3386c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3387c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3388c05c7a73SRiku Voipiofi
33896ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
33906ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
33916ae9a1f4SJuan Quintelafi
33926ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
33936ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
33946ae9a1f4SJuan Quintelafi
3395769ce76dSAlexander Grafif test "$curl" = "yes" ; then
339698ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3397b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3398769ce76dSAlexander Graffi
33992e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
340098ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
34012e4d9fb1Saurel32fi
3402fb599c9aSbalrogif test "$bluez" = "yes" ; then
340398ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3404ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3405fb599c9aSbalrogfi
3406e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3407e37630caSaliguoriif test "$xen" = "yes" ; then
34086dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3409d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3410e37630caSaliguorifi
34115c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
34125c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
34135c6c3a6cSChristoph Hellwigfi
3414758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3415758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3416758e8e38SVenkateswararao Jujjuri (JV)fi
34174f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
34184f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
34194f26f2b6SAvi Kivityfi
3420983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
3421758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
3422758e8e38SVenkateswararao Jujjuri (JV)fi
342377755340Sthsif test "$blobs" = "yes" ; then
342498ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
342577755340Sthsfi
3426bf9298b9Saliguoriif test "$iovec" = "yes" ; then
34272358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3428bf9298b9Saliguorifi
3429ceb42de8Saliguoriif test "$preadv" = "yes" ; then
34302358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3431ceb42de8Saliguorifi
3432f652e6afSaurel32if test "$fdt" = "yes" ; then
34333f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3434f652e6afSaurel32fi
3435dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3436dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3437dcc38d1cSMarcelo Tosattifi
34389195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
34399195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
34409195b2c2SStefan Weilfi
34415f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
34425f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
34435f6b9e8fSBlue Swirlfi
3444e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3445e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3446e78815a5SAndreas Färberfi
3447e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3448e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3449e78815a5SAndreas Färberfi
345097a847bcSbellard
3451cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3452cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3453cd4ec0b4SGerd Hoffmannfi
3454cd4ec0b4SGerd Hoffmann
3455020af1c4SAlon Levyif test "$spice_qxl_io_monitors_config_async" = "yes" ; then
3456020af1c4SAlon Levy  echo "CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC=y" >> $config_host_mak
3457020af1c4SAlon Levyfi
3458020af1c4SAlon Levy
345936707144SAlon Levyif test "$smartcard" = "yes" ; then
346036707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
346136707144SAlon Levyfi
346236707144SAlon Levy
3463111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3464111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3465ad4cf3f6SPaul Brook  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3466ad4cf3f6SPaul Brook  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3467111a38b0SRobert Relyeafi
3468111a38b0SRobert Relyea
346969354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
347069354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
347169354a83SHans de Goedefi
347269354a83SHans de Goede
347320ff075bSMichael Walleif test "$opengl" = "yes" ; then
347420ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
347520ff075bSMichael Wallefi
347620ff075bSMichael Walle
3477c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3478c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3479c589b249SRonnie Sahlbergfi
3480c589b249SRonnie Sahlberg
3481f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
3482f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
3483f794573eSEduardo Otubofi
3484f794573eSEduardo Otubo
348583fb7adfSbellard# XXX: suppress that
34867d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
34872358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
34887d3505c5Sbellardfi
34897d3505c5Sbellard
34902358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3491c5937220Spbrook
349220ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
349320ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
349420ff6c80SAnthony Liguorifi
3495f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3496f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3497f27aaf4bSChristian Brunnerfi
349820ff6c80SAnthony Liguori
3499519175a2SAlex Barceloif test "$coroutine_backend" = "ucontext" ; then
3500d0e2fce5SAneesh Kumar K.V  echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
3501fe91bfa8SAlex Barceloelif test "$coroutine_backend" = "sigaltstack" ; then
3502fe91bfa8SAlex Barcelo  echo "CONFIG_SIGALTSTACK_COROUTINE=y" >> $config_host_mak
3503d0e2fce5SAneesh Kumar K.Vfi
3504d0e2fce5SAneesh Kumar K.V
3505d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
3506d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3507d2042378SAneesh Kumar K.Vfi
3508d2042378SAneesh Kumar K.V
3509e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
3510e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3511e06a765eSHarsh Prateek Borafi
3512e06a765eSHarsh Prateek Bora
351306d71fa1SPeter Maydellif test "$pragma_disable_unused_but_set" = "yes" ; then
351406d71fa1SPeter Maydell  echo "CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET=y" >> $config_host_mak
351506d71fa1SPeter Maydellfi
351606d71fa1SPeter Maydell
35173f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
35183f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
35193f4349dcSKevin Wolffi
35203f4349dcSKevin Wolf
35218ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
35228ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
35238ab1bf12SLuiz Capitulinofi
35248ab1bf12SLuiz Capitulino
352568063649Sblueswir1# USB host support
352668063649Sblueswir1case "$usb" in
352768063649Sblueswir1linux)
352898ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
352968063649Sblueswir1;;
353068063649Sblueswir1bsd)
353198ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
353268063649Sblueswir1;;
353368063649Sblueswir1*)
353498ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
353568063649Sblueswir1;;
353668063649Sblueswir1esac
353768063649Sblueswir1
3538e4858974SLluís# use default implementation for tracing backend-specific routines
3539e4858974SLluístrace_default=yes
354094a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
35416d8a764eSLluísif test "$trace_backend" = "nop"; then
35426d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
354322890ab5SPrerna Saxenafi
35449410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
35456d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
3546e4858974SLluís  trace_default=no
35476d8a764eSLluís  # Set the appropriate trace file.
3548953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
35499410b56cSPrerna Saxenafi
35506d8a764eSLluísif test "$trace_backend" = "stderr"; then
35516d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
35529a82b6a5SLluís  trace_default=no
35536d8a764eSLluísfi
35546d8a764eSLluísif test "$trace_backend" = "ust"; then
35556d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
35566d8a764eSLluísfi
35576d8a764eSLluísif test "$trace_backend" = "dtrace"; then
35586d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
35596d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
35606d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
35616d8a764eSLluís  fi
3562c276b17dSDaniel P. Berrangefi
35639410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
3564e4858974SLluísif test "$trace_default" = "yes"; then
3565e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3566e4858974SLluísfi
35679410b56cSPrerna Saxena
356898ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
356998ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3570804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3571804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
35721901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
35731901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
35741901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
3575c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
3576804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
35772b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3578804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
35793c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
3580804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3581804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3582804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
35839fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
358444dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3585e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3586a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3587f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3588e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3589e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3590e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3591e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3592e39f0062SPaolo Bonzinifi
3593c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
3594e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3595a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3596a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
359773da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
35983e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3599804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3600957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
360194dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
3602804edf29SJuan Quintela
36034bf6b55bSJuan Quintela# generate list of library paths for linker script
36044bf6b55bSJuan Quintela
36054bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
36064bf6b55bSJuan Quintela
36074bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
36084bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
36094bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
36104bf6b55bSJuan Quintela  else
36114bf6b55bSJuan Quintela    rm ${config_host_ld}~
36124bf6b55bSJuan Quintela  fi
36134bf6b55bSJuan Quintelafi
36144bf6b55bSJuan Quintela
36154d904533SBlue Swirlfor d in libdis libdis-user; do
361672b8b5a1SStefan Weil    symlink "$source_path/Makefile.dis" "$d/Makefile"
36174d904533SBlue Swirl    echo > $d/config.mak
36184d904533SBlue Swirldone
36194d904533SBlue Swirl
36206efd7517SPeter Maydell# use included Linux headers
36216efd7517SPeter Maydellif test "$linux" = "yes" ; then
3622a307beb6SAndreas Färber  mkdir -p linux-headers
36236efd7517SPeter Maydell  case "$cpu" in
36246efd7517SPeter Maydell  i386|x86_64)
362508312a63SPeter Maydell    linux_arch=x86
36266efd7517SPeter Maydell    ;;
36276efd7517SPeter Maydell  ppcemb|ppc|ppc64)
362808312a63SPeter Maydell    linux_arch=powerpc
36296efd7517SPeter Maydell    ;;
36306efd7517SPeter Maydell  s390x)
363108312a63SPeter Maydell    linux_arch=s390
363208312a63SPeter Maydell    ;;
363308312a63SPeter Maydell  *)
363408312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
363508312a63SPeter Maydell    linux_arch="$cpu"
36366efd7517SPeter Maydell    ;;
36376efd7517SPeter Maydell  esac
363808312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
363908312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
364008312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
364108312a63SPeter Maydell    fi
36426efd7517SPeter Maydellfi
36436efd7517SPeter Maydell
364497a847bcSbellardfor target in $target_list; do
364597a847bcSbellardtarget_dir="$target"
364625be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3647600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
364897a847bcSbellardtarget_bigendian="no"
36491f3d3c8fSJuan Quintela
3650ea2d6a39SJuan Quintelacase "$target_arch2" in
3651e67db06eSJia Liu  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
3652ea2d6a39SJuan Quintela  target_bigendian=yes
3653ea2d6a39SJuan Quintela  ;;
3654ea2d6a39SJuan Quintelaesac
365597a847bcSbellardtarget_softmmu="no"
3656997344f3Sbellardtarget_user_only="no"
3657831b7825Sthstarget_linux_user="no"
365884778508Sblueswir1target_bsd_user="no"
36599e407a85Spbrookcase "$target" in
3660600309b6SBlue Swirl  ${target_arch2}-softmmu)
36619e407a85Spbrook    target_softmmu="yes"
36629e407a85Spbrook    ;;
3663600309b6SBlue Swirl  ${target_arch2}-linux-user)
36649c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
36659c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
36669c7a4202SBlue Swirl      exit 1
36679c7a4202SBlue Swirl    fi
36689e407a85Spbrook    target_user_only="yes"
36699e407a85Spbrook    target_linux_user="yes"
36709e407a85Spbrook    ;;
3671600309b6SBlue Swirl  ${target_arch2}-bsd-user)
36729cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
36739c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
36749c7a4202SBlue Swirl      exit 1
36759c7a4202SBlue Swirl    fi
367684778508Sblueswir1    target_user_only="yes"
367784778508Sblueswir1    target_bsd_user="yes"
367884778508Sblueswir1    ;;
36799e407a85Spbrook  *)
36809e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
36819e407a85Spbrook    exit 1
36829e407a85Spbrook    ;;
36839e407a85Spbrookesac
3684831b7825Sths
368597a847bcSbellardmkdir -p $target_dir
368625be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
368797a847bcSbellard
3688e5fe0c52Spbrookbflt="no"
3689bd0c5661Spbrooktarget_nptl="no"
3690600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
369156aebc89Spbrookgdb_xml_files=""
3692c2e3dee6SLaurent Viviertarget_short_alignment=2
3693c2e3dee6SLaurent Viviertarget_int_alignment=4
3694c2e3dee6SLaurent Viviertarget_long_alignment=4
3695c2e3dee6SLaurent Viviertarget_llong_alignment=8
3696de3a354aSMichael Walletarget_libs_softmmu=
36977ba1e619Saliguori
3698938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
36996acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3700e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3701e73aae67SJuan Quintela
3702600309b6SBlue Swirlcase "$target_arch2" in
37032408a527Saurel32  i386)
370471deff27SAurelien Jarno    target_phys_bits=64
37052408a527Saurel32  ;;
37062408a527Saurel32  x86_64)
37076acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
37081ad2134fSPaul Brook    target_phys_bits=64
3709c2e3dee6SLaurent Vivier    target_long_alignment=8
37102408a527Saurel32  ;;
37112408a527Saurel32  alpha)
37121ad2134fSPaul Brook    target_phys_bits=64
3713c2e3dee6SLaurent Vivier    target_long_alignment=8
3714a4b388ffSRichard Henderson    target_nptl="yes"
37152408a527Saurel32  ;;
37162408a527Saurel32  arm|armeb)
3717b498c8a0SJuan Quintela    TARGET_ARCH=arm
3718e5fe0c52Spbrook    bflt="yes"
3719bd0c5661Spbrook    target_nptl="yes"
372056aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
37213cc0cd61SPeter Maydell    target_phys_bits=64
3722c2e3dee6SLaurent Vivier    target_llong_alignment=4
3723412beee6SGrant Likely    target_libs_softmmu="$fdt_libs"
37242408a527Saurel32  ;;
37252408a527Saurel32  cris)
3726253bd7f8Sedgar_igl    target_nptl="yes"
37271ad2134fSPaul Brook    target_phys_bits=32
37282408a527Saurel32  ;;
3729613a22c9SMichael Walle  lm32)
3730613a22c9SMichael Walle    target_phys_bits=32
3731de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3732613a22c9SMichael Walle  ;;
37332408a527Saurel32  m68k)
37340938cda5Saurel32    bflt="yes"
373556aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
37361ad2134fSPaul Brook    target_phys_bits=32
3737c2e3dee6SLaurent Vivier    target_int_alignment=2
3738c2e3dee6SLaurent Vivier    target_long_alignment=2
3739c2e3dee6SLaurent Vivier    target_llong_alignment=2
37402408a527Saurel32  ;;
3741877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3742877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
374372b675caSEdgar E. Iglesias    bflt="yes"
374472b675caSEdgar E. Iglesias    target_nptl="yes"
374572b675caSEdgar E. Iglesias    target_phys_bits=32
3746de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
374772b675caSEdgar E. Iglesias  ;;
37482408a527Saurel32  mips|mipsel)
3749b498c8a0SJuan Quintela    TARGET_ARCH=mips
375025be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3751f04dc72fSPaul Brook    target_nptl="yes"
37521ad2134fSPaul Brook    target_phys_bits=64
37532408a527Saurel32  ;;
37542408a527Saurel32  mipsn32|mipsn32el)
3755b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
37566acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
375725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
37581ad2134fSPaul Brook    target_phys_bits=64
37592408a527Saurel32  ;;
37602408a527Saurel32  mips64|mips64el)
3761b498c8a0SJuan Quintela    TARGET_ARCH=mips64
37626acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
376325be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
37641ad2134fSPaul Brook    target_phys_bits=64
3765c2e3dee6SLaurent Vivier    target_long_alignment=8
37662408a527Saurel32  ;;
3767e67db06eSJia Liu  or32)
3768e67db06eSJia Liu    TARGET_ARCH=openrisc
3769e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
3770e67db06eSJia Liu    target_phys_bits=32
3771e67db06eSJia Liu  ;;
37722408a527Saurel32  ppc)
3773c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
37748b242ebaSAlexander Graf    target_phys_bits=64
3775d6630708SNathan Froyd    target_nptl="yes"
3776de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37772408a527Saurel32  ;;
37782408a527Saurel32  ppcemb)
37796acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3780e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3781c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
37821ad2134fSPaul Brook    target_phys_bits=64
3783d6630708SNathan Froyd    target_nptl="yes"
3784de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37852408a527Saurel32  ;;
37862408a527Saurel32  ppc64)
37876acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3788e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3789c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
37901ad2134fSPaul Brook    target_phys_bits=64
3791c2e3dee6SLaurent Vivier    target_long_alignment=8
3792de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
37932408a527Saurel32  ;;
37942408a527Saurel32  ppc64abi32)
3795b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
37966acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3797e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
379825be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3799c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
38001ad2134fSPaul Brook    target_phys_bits=64
3801de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
38022408a527Saurel32  ;;
38032408a527Saurel32  sh4|sh4eb)
3804b498c8a0SJuan Quintela    TARGET_ARCH=sh4
38054dbed897Spbrook    bflt="yes"
38060b6d3ae0Saurel32    target_nptl="yes"
38071ad2134fSPaul Brook    target_phys_bits=32
38082408a527Saurel32  ;;
38092408a527Saurel32  sparc)
38101ad2134fSPaul Brook    target_phys_bits=64
38112408a527Saurel32  ;;
38122408a527Saurel32  sparc64)
38136acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
38141ad2134fSPaul Brook    target_phys_bits=64
3815c2e3dee6SLaurent Vivier    target_long_alignment=8
38162408a527Saurel32  ;;
38172408a527Saurel32  sparc32plus)
3818b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
38196acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3820e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
382125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
38221ad2134fSPaul Brook    target_phys_bits=64
38232408a527Saurel32  ;;
382424e804ecSAlexander Graf  s390x)
3825bc434676SUlrich Hecht    target_nptl="yes"
382624e804ecSAlexander Graf    target_phys_bits=64
38277b3da903SAlexander Graf    target_long_alignment=8
382824e804ecSAlexander Graf  ;;
3829d2fbca94SGuan Xuetao  unicore32)
3830d2fbca94SGuan Xuetao    target_phys_bits=32
3831d2fbca94SGuan Xuetao  ;;
3832cfa550c6SMax Filippov  xtensa|xtensaeb)
3833cfa550c6SMax Filippov    TARGET_ARCH=xtensa
3834cfa550c6SMax Filippov    target_phys_bits=32
3835cfa550c6SMax Filippov  ;;
38362408a527Saurel32  *)
3837de83cd02Sbellard    echo "Unsupported target CPU"
3838de83cd02Sbellard    exit 1
38392408a527Saurel32  ;;
38402408a527Saurel32esac
38415e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
38425e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
38435e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
38445e8861a0SPaolo Bonzinifi
38455e8861a0SPaolo Bonzini
38465e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
38475e8861a0SPaolo Bonzini
38480184e266SBlue Swirl
38490184e266SBlue Swirlcase "$target_arch2" in
385019b0516fSBlue Swirl  alpha | i386 | or32 | s390x | sparc* | x86_64 | xtensa* | ppc*)
38510184e266SBlue Swirl    echo "CONFIG_TCG_PASS_AREG0=y" >> $config_target_mak
38520184e266SBlue Swirl  ;;
38530184e266SBlue Swirlesac
38540184e266SBlue Swirl
385599afc91dSDaniel P. Berrangeupper() {
385699afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
385799afc91dSDaniel P. Berrange}
385899afc91dSDaniel P. Berrange
3859c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3860c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3861c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3862c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
386325be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
386499afc91dSDaniel P. Berrangetarget_arch_name="`upper $TARGET_ARCH`"
386525be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
386625be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
386799afc91dSDaniel P. Berrangeecho "TARGET_TYPE=TARGET_TYPE_`upper $target_arch2`" >> $config_target_mak
386825be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3869e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3870e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3871e6e91b9cSJuan Quintelafi
387225be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
38731b0c87fcSJuan Quintelacase "$target_arch2" in
38741b0c87fcSJuan Quintela  i386|x86_64)
38751b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
387664b3cfdbSAnthony PERARD      target_phys_bits=64
387725be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
3878eb6fda0fSAnthony PERARD      if test "$xen_pci_passthrough" = yes; then
3879eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
3880eb6fda0fSAnthony PERARD      fi
388159d21e53SAlexander Graf    else
388259d21e53SAlexander Graf      echo "CONFIG_NO_XEN=y" >> $config_target_mak
3883432d268cSJun Nakajima    fi
388459d21e53SAlexander Graf    ;;
388559d21e53SAlexander Graf  *)
388659d21e53SAlexander Graf    echo "CONFIG_NO_XEN=y" >> $config_target_mak
38871b0c87fcSJuan Quintelaesac
3888c59249f9SJuan Quintelacase "$target_arch2" in
38890e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3890c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3891c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3892c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3893c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
38945f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3895adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3896adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3897c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3898c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
389925be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
39001ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
3901d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3902d5970055SMichael S. Tsirkin      fi
3903c59249f9SJuan Quintela    fi
3904c59249f9SJuan Quintelaesac
3905fae001f5SWen Congyangcase "$target_arch2" in
3906fae001f5SWen Congyang  i386|x86_64)
3907fae001f5SWen Congyang    echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
3908fae001f5SWen Congyangesac
39097f762366SBlue Swirlif test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then
39100a6b8ddeSAlexander Graf  echo "CONFIG_PSERIES=y" >> $config_target_mak
39110a6b8ddeSAlexander Graffi
3912de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
391325be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
391497a847bcSbellardfi
391597a847bcSbellardif test "$target_softmmu" = "yes" ; then
3916b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
391725be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3918de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
39190e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
39205791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3921ad4cf3f6SPaul Brook  if test "$smartcard_nss" = "yes" ; then
3922ad4cf3f6SPaul Brook    echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3923ad4cf3f6SPaul Brook  fi
39249fecbed0SWen Congyang  case "$target_arch2" in
39259fecbed0SWen Congyang    i386|x86_64)
39269fecbed0SWen Congyang      echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
39279fecbed0SWen Congyang  esac
3928de83cd02Sbellardfi
3929997344f3Sbellardif test "$target_user_only" = "yes" ; then
393025be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3931a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
3932997344f3Sbellardfi
3933831b7825Sthsif test "$target_linux_user" = "yes" ; then
393425be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3935831b7825Sthsfi
393656aebc89Spbrooklist=""
393756aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
393856aebc89Spbrook  for x in $gdb_xml_files; do
393956aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
394056aebc89Spbrook  done
394125be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
39423d0f1517SJuan Quintelafi
3943de83cd02Sbellard
3944e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
394525be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3946e5fe0c52Spbrookfi
3947bd0c5661Spbrookif test "$target_user_only" = "yes" \
3948bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
394925be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3950bd0c5661Spbrookfi
3951379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
395225be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3953379f6698SPaul Brookfi
395484778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
395525be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
395684778508Sblueswir1fi
39575b0753e0Sbellard
39585a4d701aSJan Kiszka# the static way of configuring available audio cards requires this workaround
39595a4d701aSJan Kiszkaif test "$target_user_only" != "yes" && grep -q CONFIG_PCSPK $source_path/default-configs/$target.mak; then
39605a4d701aSJan Kiszka  echo "CONFIG_PCSPK=y" >> $config_target_mak
39615a4d701aSJan Kiszkafi
39625a4d701aSJan Kiszka
39634afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3964fa282484SJuan Quintela
39654afddb55SJuan Quintelacflags=""
3966f9728943SPaolo Bonziniincludes=""
3967fa282484SJuan Quintelaldflags=""
39689b8e111fSJuan Quintela
39699195b2c2SStefan Weilif test "$tcg_interpreter" = "yes"; then
39709195b2c2SStefan Weil  includes="-I\$(SRC_PATH)/tcg/tci $includes"
39719195b2c2SStefan Weilelif test "$ARCH" = "sparc64" ; then
3972f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
397324e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3974f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
39755d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3976f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
397757ddfbf7SJuan Quintelaelse
3978f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
397957ddfbf7SJuan Quintelafi
3980f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
398157ddfbf7SJuan Quintela
39826efd7517SPeter Maydellif test "$linux" = "yes" ; then
39836efd7517SPeter Maydell  includes="-I\$(SRC_PATH)/linux-headers $includes"
39846efd7517SPeter Maydellfi
39856efd7517SPeter Maydell
39864d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
39874d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
39884d904533SBlue Swirlelse
39894d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
39904d904533SBlue Swirlfi
39914d904533SBlue Swirl
399264656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
399364656024SJuan Quintela  case "$i" in
399464656024SJuan Quintela  alpha)
399525be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
39964d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
399764656024SJuan Quintela  ;;
399864656024SJuan Quintela  arm)
399925be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
40004d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
400164656024SJuan Quintela  ;;
400264656024SJuan Quintela  cris)
400325be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
40044d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
400564656024SJuan Quintela  ;;
400664656024SJuan Quintela  hppa)
400725be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
40084d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
400964656024SJuan Quintela  ;;
401064656024SJuan Quintela  i386|x86_64)
401125be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
40124d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
401364656024SJuan Quintela  ;;
4014903ec55cSAurelien Jarno  ia64*)
4015903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
4016903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
4017903ec55cSAurelien Jarno  ;;
401879368f49SMichael Walle  lm32)
401979368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $config_target_mak
402079368f49SMichael Walle    echo "CONFIG_LM32_DIS=y"  >> $libdis_config_mak
402179368f49SMichael Walle  ;;
402264656024SJuan Quintela  m68k)
402325be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
40244d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
402564656024SJuan Quintela  ;;
4026877fdc12SEdgar E. Iglesias  microblaze*)
402725be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
40284d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
402964656024SJuan Quintela  ;;
403064656024SJuan Quintela  mips*)
403125be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
40324d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
403364656024SJuan Quintela  ;;
4034e67db06eSJia Liu  or32)
4035e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $config_target_mak
4036e67db06eSJia Liu    echo "CONFIG_OPENRISC_DIS=y"  >> $libdis_config_mak
4037e67db06eSJia Liu  ;;
403864656024SJuan Quintela  ppc*)
403925be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
40404d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
404164656024SJuan Quintela  ;;
404224e804ecSAlexander Graf  s390*)
404325be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
40444d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
404564656024SJuan Quintela  ;;
404664656024SJuan Quintela  sh4)
404725be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
40484d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
404964656024SJuan Quintela  ;;
405064656024SJuan Quintela  sparc*)
405125be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
40524d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
405364656024SJuan Quintela  ;;
4054cfa550c6SMax Filippov  xtensa*)
4055cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
4056cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $libdis_config_mak
4057cfa550c6SMax Filippov  ;;
405864656024SJuan Quintela  esac
405964656024SJuan Quinteladone
40609195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
40619195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
40629195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $libdis_config_mak
40639195b2c2SStefan Weilfi
406464656024SJuan Quintela
40656ee7126fSJuan Quintelacase "$ARCH" in
40666ee7126fSJuan Quintelaalpha)
40676ee7126fSJuan Quintela  # Ensure there's only a single GP
40686ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
40696ee7126fSJuan Quintela;;
40706ee7126fSJuan Quintelaesac
40716ee7126fSJuan Quintela
407255d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
407355d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
407455d9c04bSJuan Quintela  arm)
407555d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
407655d9c04bSJuan Quintela  ;;
407725a8bb96SMichael Walle  lm32)
407825a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
407925a8bb96SMichael Walle  ;;
408055d9c04bSJuan Quintela  i386|mips|ppc)
408155d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
408255d9c04bSJuan Quintela  ;;
408355d9c04bSJuan Quintela  esac
408455d9c04bSJuan Quintelafi
408555d9c04bSJuan Quintela
4086d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
408725be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
4088d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
4089d02c1db3SJuan Quintela    cflags="-p $cflags"
4090d02c1db3SJuan Quintela    ldflags="-p $ldflags"
4091d02c1db3SJuan Quintela  fi
4092d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
4093d02c1db3SJuan Quintela    ldflags="-p $ldflags"
409425be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
4095d02c1db3SJuan Quintela  fi
4096d02c1db3SJuan Quintelafi
4097d02c1db3SJuan Quintela
40989195b2c2SStefan Weilif test "$ARCH" = "tci"; then
40999195b2c2SStefan Weil  linker_script=""
41009195b2c2SStefan Weilelse
41016ee7126fSJuan Quintela  linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
41029195b2c2SStefan Weilfi
41039195b2c2SStefan Weil
41049b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4105fa282484SJuan Quintela  case "$ARCH" in
4106fa282484SJuan Quintela  sparc)
4107fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
4108322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
4109fa282484SJuan Quintela    ;;
41104d58be06SRichard Henderson  alpha | s390x)
41114d58be06SRichard Henderson    # The default placement of the application is fine.
41124d58be06SRichard Henderson    ;;
4113fd76e73aSRichard Henderson  *)
4114322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
4115fa282484SJuan Quintela    ;;
4116fa282484SJuan Quintela  esac
4117fa282484SJuan Quintelafi
4118fa282484SJuan Quintela
411925be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
412025be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4121f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
4122fa282484SJuan Quintela
412397a847bcSbellarddone # for target in $targets
41247d13299dSbellard
4125d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
4126927b241dSMichael WalleDIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32"
41272dee8d54SPaolo BonziniDIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
41282d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
41292dee8d54SPaolo BonziniDIRS="$DIRS qapi-generated"
413000c705fbSPaolo BonziniDIRS="$DIRS libcacard libcacard/libcacard libcacard/trace"
4131c09015ddSAnthony LiguoriFILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4132c09015ddSAnthony LiguoriFILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
413300c705fbSPaolo BonziniFILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile"
4134ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4135446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
41362d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4137753d11f2SRichard Hendersonfor bios_file in \
4138753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
4139753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4140753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4141753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
4142753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
4143753d11f2SRichard Hendersondo
41447ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
41457ea78b74SJan Kiszkadone
4146d1807a4fSPaolo Bonzinimkdir -p $DIRS
41477d13299dSbellardfor f in $FILES ; do
414872b8b5a1SStefan Weil    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4149f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4150f9245e10SPeter Maydell    fi
41517d13299dSbellarddone
41521ad2134fSPaul Brook
4153c34ebfdcSAnthony Liguori# temporary config to build submodules
41542d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
4155c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
415637116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4157c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
4158c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4159c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
4160c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
4161c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4162c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
4163c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
4164c34ebfdcSAnthony Liguoridone
4165c34ebfdcSAnthony Liguori
41661ad2134fSPaul Brookfor hwlib in 32 64; do
41671ad2134fSPaul Brook  d=libhw$hwlib
416872b8b5a1SStefan Weil  symlink "$source_path/Makefile.hw" "$d/Makefile"
416937116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
41701ad2134fSPaul Brookdone
4171add16157SBlue Swirl
4172add16157SBlue Swirld=libuser
417372b8b5a1SStefan Weilsymlink "$source_path/Makefile.user" "$d/Makefile"
4174b40292e7SJan Kiszka
4175b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
4176b40292e7SJan Kiszka  mkdir -p QMP
4177b40292e7SJan Kiszkafi
4178