xref: /openbmc/qemu/configure (revision adf82011ef33df8e4d2421e957ccdbd5bbd12ad1)
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
2352166aa0SJuan Quintelacompile_object() {
24da1d85e3SGerd Hoffmann  echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
25da1d85e3SGerd Hoffmann  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
2652166aa0SJuan Quintela}
2752166aa0SJuan Quintela
2852166aa0SJuan Quintelacompile_prog() {
2952166aa0SJuan Quintela  local_cflags="$1"
3052166aa0SJuan Quintela  local_ldflags="$2"
31da1d85e3SGerd Hoffmann  echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
32da1d85e3SGerd Hoffmann  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
3352166aa0SJuan Quintela}
3452166aa0SJuan Quintela
3511568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
3611568d6dSPaolo Bonzinisymlink() {
3711568d6dSPaolo Bonzini  rm -f $2
3811568d6dSPaolo Bonzini  ln -s $1 $2
3911568d6dSPaolo Bonzini}
4011568d6dSPaolo Bonzini
410dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
420dba6195SLoïc Minier# executable or a builtin)
430dba6195SLoïc Minierhas() {
440dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
450dba6195SLoïc Minier}
460dba6195SLoïc Minier
470dba6195SLoïc Minier# search for an executable in PATH
480dba6195SLoïc Minierpath_of() {
490dba6195SLoïc Minier    local_command="$1"
500dba6195SLoïc Minier    local_ifs="$IFS"
510dba6195SLoïc Minier    local_dir=""
520dba6195SLoïc Minier
530dba6195SLoïc Minier    # pathname has a dir component?
540dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
550dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
560dba6195SLoïc Minier            echo "$local_command"
570dba6195SLoïc Minier            return 0
580dba6195SLoïc Minier        fi
590dba6195SLoïc Minier    fi
600dba6195SLoïc Minier    if [ -z "$local_command" ]; then
610dba6195SLoïc Minier        return 1
620dba6195SLoïc Minier    fi
630dba6195SLoïc Minier
640dba6195SLoïc Minier    IFS=:
650dba6195SLoïc Minier    for local_dir in $PATH; do
660dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
670dba6195SLoïc Minier            echo "$local_dir/$local_command"
680dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
690dba6195SLoïc Minier            return 0
700dba6195SLoïc Minier        fi
710dba6195SLoïc Minier    done
720dba6195SLoïc Minier    # not found
730dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
740dba6195SLoïc Minier    return 1
750dba6195SLoïc Minier}
760dba6195SLoïc Minier
777d13299dSbellard# default parameters
78ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
792ff6b91eSJuan Quintelacpu=""
801e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
8143ce4dfeSbellardstatic="no"
82ed968ff1SJuan Quintelasparc_cpu=""
837d13299dSbellardcross_prefix=""
840c58ac1cSmalcaudio_drv_list=""
85d61a4ce8SGerd Hoffmannaudio_card_list="ac97 es1370 sb16 hda"
86d61a4ce8SGerd Hoffmannaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
87eb852011SMarkus Armbrusterblock_drv_whitelist=""
887d13299dSbellardhost_cc="gcc"
89c81da56eSJuan Quintelahelper_cflags=""
9073da375eSJuan Quintelalibs_softmmu=""
913e2e0e6bSJuan Quintelalibs_tools=""
9267f86e8eSJuan Quintelaaudio_pt_int=""
93d5631638Smalcaudio_win_int=""
942b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
95ac0df51dSaliguori
96377529c0SPaolo Bonzinitarget_list=""
97377529c0SPaolo Bonzini
98377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
99377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
100377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
101377529c0SPaolo Bonzini#              unless --disable-foo is given
102377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
103377529c0SPaolo Bonzini#              feature will searched for,
104377529c0SPaolo Bonzini#              if not found, configure exits with error
105377529c0SPaolo Bonzini#
106377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
107377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
108377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
109377529c0SPaolo Bonzini
110377529c0SPaolo Bonzinibluez=""
111377529c0SPaolo Bonzinibrlapi=""
112377529c0SPaolo Bonzinicurl=""
113377529c0SPaolo Bonzinicurses=""
114377529c0SPaolo Bonzinidocs=""
115377529c0SPaolo Bonzinifdt=""
116377529c0SPaolo Bonzinikvm=""
117377529c0SPaolo Bonzinikvm_para=""
118377529c0SPaolo Bonzininptl=""
119377529c0SPaolo Bonzinisdl=""
120377529c0SPaolo Bonzinisparse="no"
121377529c0SPaolo Bonziniuuid=""
122377529c0SPaolo Bonzinivde=""
123377529c0SPaolo Bonzinivnc_tls=""
124377529c0SPaolo Bonzinivnc_sasl=""
125377529c0SPaolo Bonzinivnc_jpeg=""
126377529c0SPaolo Bonzinivnc_png=""
127377529c0SPaolo Bonzinivnc_thread="no"
128377529c0SPaolo Bonzinixen=""
129377529c0SPaolo Bonzinilinux_aio=""
130377529c0SPaolo Bonziniattr=""
131377529c0SPaolo Bonzinivhost_net=""
132377529c0SPaolo Bonzinixfs=""
133377529c0SPaolo Bonzini
134377529c0SPaolo Bonzinigprof="no"
135377529c0SPaolo Bonzinidebug_tcg="no"
136377529c0SPaolo Bonzinidebug_mon="no"
137377529c0SPaolo Bonzinidebug="no"
138377529c0SPaolo Bonzinistrip_opt="yes"
139377529c0SPaolo Bonzinibigendian="no"
140377529c0SPaolo Bonzinimingw32="no"
141377529c0SPaolo BonziniEXESUF=""
142377529c0SPaolo Bonziniprefix="/usr/local"
143377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
144377529c0SPaolo Bonzinidatadir="\${prefix}/share/qemu"
145377529c0SPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
146377529c0SPaolo Bonzinibindir="\${prefix}/bin"
147377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
148377529c0SPaolo Bonziniconfsuffix="/qemu"
149377529c0SPaolo Bonzinislirp="yes"
150377529c0SPaolo Bonzinifmod_lib=""
151377529c0SPaolo Bonzinifmod_inc=""
152377529c0SPaolo Bonzinioss_lib=""
153377529c0SPaolo Bonzinibsd="no"
154377529c0SPaolo Bonzinilinux="no"
155377529c0SPaolo Bonzinisolaris="no"
156377529c0SPaolo Bonziniprofiler="no"
157377529c0SPaolo Bonzinicocoa="no"
158377529c0SPaolo Bonzinisoftmmu="yes"
159377529c0SPaolo Bonzinilinux_user="no"
160377529c0SPaolo Bonzinidarwin_user="no"
161377529c0SPaolo Bonzinibsd_user="no"
162377529c0SPaolo Bonziniguest_base=""
163377529c0SPaolo Bonziniuname_release=""
164377529c0SPaolo Bonziniio_thread="no"
165377529c0SPaolo Bonzinimixemu="no"
166377529c0SPaolo Bonzinikerneldir=""
167377529c0SPaolo Bonziniaix="no"
168377529c0SPaolo Bonziniblobs="yes"
169377529c0SPaolo Bonzinipkgversion=""
170377529c0SPaolo Bonzinicheck_utests="no"
171377529c0SPaolo Bonziniuser_pie="no"
172377529c0SPaolo Bonzinizero_malloc=""
173377529c0SPaolo Bonzinitrace_backend="nop"
174377529c0SPaolo Bonzinitrace_file="trace"
175377529c0SPaolo Bonzinispice=""
176377529c0SPaolo Bonzinirbd=""
177377529c0SPaolo Bonzini
178ac0df51dSaliguori# parse CC options first
179ac0df51dSaliguorifor opt do
180ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
181ac0df51dSaliguori  case "$opt" in
182ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
183ac0df51dSaliguori  ;;
1843d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
185ac0df51dSaliguori  ;;
186ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
187ca4deeb1SPaolo Bonzini  ;;
1882ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
1892ff6b91eSJuan Quintela  ;;
190a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
191e2a2ed06SJuan Quintela  ;;
192e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
193e2a2ed06SJuan Quintela  ;;
19450e7b1a0SJuan Quintela  --sparc_cpu=*)
19550e7b1a0SJuan Quintela    sparc_cpu="$optarg"
19650e7b1a0SJuan Quintela    case $sparc_cpu in
197ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
19850e7b1a0SJuan Quintela      cpu="sparc"
19950e7b1a0SJuan Quintela    ;;
20050e7b1a0SJuan Quintela    v9)
20150e7b1a0SJuan Quintela      cpu="sparc64"
20250e7b1a0SJuan Quintela    ;;
20350e7b1a0SJuan Quintela    *)
20450e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
20550e7b1a0SJuan Quintela      exit 1
20650e7b1a0SJuan Quintela    ;;
20750e7b1a0SJuan Quintela    esac
20850e7b1a0SJuan Quintela  ;;
209ac0df51dSaliguori  esac
210ac0df51dSaliguoridone
211ac0df51dSaliguori# OS specific
212ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
213ac0df51dSaliguori# we can eliminate it's usage altogether
214ac0df51dSaliguori
2153d8df640SPaolo Bonzinicc="${cross_prefix}${CC-gcc}"
2163d8df640SPaolo Bonziniar="${cross_prefix}${AR-ar}"
2173d8df640SPaolo Bonziniobjcopy="${cross_prefix}${OBJCOPY-objcopy}"
2183d8df640SPaolo Bonzinild="${cross_prefix}${LD-ld}"
2193d8df640SPaolo Bonzinistrip="${cross_prefix}${STRIP-strip}"
2203d8df640SPaolo Bonziniwindres="${cross_prefix}${WINDRES-windres}"
221a8bd70adSPaolo Bonzinipkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
2223ec87ffeSPaolo Bonzinisdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
223ac0df51dSaliguori
224be17dc90SMichael S. Tsirkin# default flags for all hosts
225be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
226be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
227be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
228be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
229be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
23084958305SKirill A. ShutemovQEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
231f9728943SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH)"
232be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
233be17dc90SMichael S. Tsirkin
234ca4deeb1SPaolo Bonzini# make source path absolute
235ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
236ca4deeb1SPaolo Bonzini
237ac0df51dSaliguoricheck_define() {
238ac0df51dSaliguoricat > $TMPC <<EOF
239ac0df51dSaliguori#if !defined($1)
240ac0df51dSaliguori#error Not defined
241ac0df51dSaliguori#endif
242ac0df51dSaliguoriint main(void) { return 0; }
243ac0df51dSaliguoriEOF
24452166aa0SJuan Quintela  compile_object
245ac0df51dSaliguori}
246ac0df51dSaliguori
2472ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
2482ff6b91eSJuan Quintela  # command line argument
2492ff6b91eSJuan Quintela  :
2502ff6b91eSJuan Quintelaelif check_define __i386__ ; then
251ac0df51dSaliguori  cpu="i386"
252ac0df51dSaliguorielif check_define __x86_64__ ; then
253ac0df51dSaliguori  cpu="x86_64"
2543aa9bd6cSblueswir1elif check_define __sparc__ ; then
2553aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
2563aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
2573aa9bd6cSblueswir1  if check_define __arch64__ ; then
2583aa9bd6cSblueswir1    cpu="sparc64"
2593aa9bd6cSblueswir1  else
2603aa9bd6cSblueswir1    cpu="sparc"
2613aa9bd6cSblueswir1  fi
262fdf7ed96Smalcelif check_define _ARCH_PPC ; then
263fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
264fdf7ed96Smalc    cpu="ppc64"
265ac0df51dSaliguori  else
266fdf7ed96Smalc    cpu="ppc"
267fdf7ed96Smalc  fi
268afa05235SAurelien Jarnoelif check_define __mips__ ; then
269afa05235SAurelien Jarno  cpu="mips"
270477ba620SAurelien Jarnoelif check_define __ia64__ ; then
271477ba620SAurelien Jarno  cpu="ia64"
272d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
273d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
274d66ed0eaSAurelien Jarno    cpu="s390x"
275d66ed0eaSAurelien Jarno  else
276d66ed0eaSAurelien Jarno    cpu="s390"
277d66ed0eaSAurelien Jarno  fi
278fdf7ed96Smalcelse
279fdf7ed96Smalc  cpu=`uname -m`
280ac0df51dSaliguorifi
281ac0df51dSaliguori
2827d13299dSbellardcase "$cpu" in
283613a22c9SMichael Walle  alpha|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64)
284ea8f20f8SJuan Quintela    cpu="$cpu"
285ea8f20f8SJuan Quintela  ;;
2867d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
28797a847bcSbellard    cpu="i386"
2887d13299dSbellard  ;;
289aaa5fa14Saurel32  x86_64|amd64)
290aaa5fa14Saurel32    cpu="x86_64"
291aaa5fa14Saurel32  ;;
292ba68055eSbellard  armv*b)
293808c4954Sbellard    cpu="armv4b"
294808c4954Sbellard  ;;
295ba68055eSbellard  armv*l)
2967d13299dSbellard    cpu="armv4l"
2977d13299dSbellard  ;;
298f54b3f92Saurel32  parisc|parisc64)
299f54b3f92Saurel32    cpu="hppa"
300f54b3f92Saurel32  ;;
301afa05235SAurelien Jarno  mips*)
302afa05235SAurelien Jarno    cpu="mips"
303afa05235SAurelien Jarno  ;;
30424e804ecSAlexander Graf  s390)
305fb3e5849Sbellard    cpu="s390"
306fb3e5849Sbellard  ;;
30724e804ecSAlexander Graf  s390x)
30824e804ecSAlexander Graf    cpu="s390x"
30924e804ecSAlexander Graf  ;;
3103142255cSblueswir1  sparc|sun4[cdmuv])
311ae228531Sbellard    cpu="sparc"
312ae228531Sbellard  ;;
3137d13299dSbellard  *)
314a447d4dcSPaolo Bonzini    echo "Unsupported CPU = $cpu"
315a447d4dcSPaolo Bonzini    exit 1
3167d13299dSbellard  ;;
3177d13299dSbellardesac
318e2d52ad3SJuan Quintela
3197d13299dSbellard# OS specific
320ac0df51dSaliguoriif check_define __linux__ ; then
321ac0df51dSaliguori  targetos="Linux"
322ac0df51dSaliguorielif check_define _WIN32 ; then
323ac0df51dSaliguori  targetos='MINGW32'
324169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
325169dc5d3Sblueswir1  targetos='OpenBSD'
326169dc5d3Sblueswir1elif check_define __sun__ ; then
327169dc5d3Sblueswir1  targetos='SunOS'
328179cf400SAndreas Färberelif check_define __HAIKU__ ; then
329179cf400SAndreas Färber  targetos='Haiku'
330ac0df51dSaliguorielse
3317d13299dSbellard  targetos=`uname -s`
332ac0df51dSaliguorifi
3330dbfc675SJuan Quintela
3347d13299dSbellardcase $targetos in
335c326e0afSbellardCYGWIN*)
336c326e0afSbellard  mingw32="yes"
337a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
338d5631638Smalc  audio_possible_drivers="winwave sdl"
339d5631638Smalc  audio_drv_list="winwave"
340c326e0afSbellard;;
34167b915a5SbellardMINGW32*)
34267b915a5Sbellard  mingw32="yes"
343d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
344d5631638Smalc  audio_drv_list="winwave"
34567b915a5Sbellard;;
3465c40d2bdSthsGNU/kFreeBSD)
347a167ba50SAurelien Jarno  bsd="yes"
3480c58ac1cSmalc  audio_drv_list="oss"
349f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3505c40d2bdSths;;
3517d3505c5SbellardFreeBSD)
3527d3505c5Sbellard  bsd="yes"
3530db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3540c58ac1cSmalc  audio_drv_list="oss"
355f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
356f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
357f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3587d3505c5Sbellard;;
359c5e97233Sblueswir1DragonFly)
360c5e97233Sblueswir1  bsd="yes"
3610db4a067SPaolo Bonzini  make="${MAKE-gmake}"
362c5e97233Sblueswir1  audio_drv_list="oss"
363c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
364c5e97233Sblueswir1;;
3657d3505c5SbellardNetBSD)
3667d3505c5Sbellard  bsd="yes"
3670db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3680c58ac1cSmalc  audio_drv_list="oss"
369c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3708ef92a88Sblueswir1  oss_lib="-lossaudio"
3717d3505c5Sbellard;;
3727d3505c5SbellardOpenBSD)
3737d3505c5Sbellard  bsd="yes"
3740db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3750c58ac1cSmalc  audio_drv_list="oss"
376c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3772f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3787d3505c5Sbellard;;
37983fb7adfSbellardDarwin)
38083fb7adfSbellard  bsd="yes"
38183fb7adfSbellard  darwin="yes"
3820dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3830dbfc675SJuan Quintela  # run 64-bit userspace code
384aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3851b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
386aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3871b0f9cc2Saliguori  fi
3881b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
389a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3900c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3911b0f9cc2Saliguori  else
392a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3931b0f9cc2Saliguori  fi
394831b7825Sths  darwin_user="yes"
395fd677642Sths  cocoa="yes"
3960c58ac1cSmalc  audio_drv_list="coreaudio"
397c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
3980c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
3997973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
40083fb7adfSbellard;;
401ec530c81SbellardSunOS)
402ec530c81Sbellard  solaris="yes"
4030db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4040db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
405fa58948dSBlue Swirl  ld="gld"
4060475a5caSths  needs_libsunmath="no"
407c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
408ef18c883Sths  # have to select again, because `uname -m` returns i86pc
409ef18c883Sths  # even on an x86_64 box.
410ef18c883Sths  solariscpu=`isainfo -k`
411ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
412ef18c883Sths    cpu="x86_64"
413ef18c883Sths  fi
414c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4150475a5caSths    if test "$solarisrev" -le 9 ; then
4160475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4170475a5caSths        needs_libsunmath="yes"
418f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
419f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
420f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4210475a5caSths      else
4220475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4230475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4240475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4250475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4260475a5caSths        exit 1
4270475a5caSths      fi
4280475a5caSths    fi
42986b2bd93Sths  fi
4306b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4310c58ac1cSmalc    audio_drv_list="oss"
4326b4d2ba1Sths  fi
433c2de5c91Smalc  audio_possible_drivers="oss sdl"
434d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
435d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
436d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
437d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
438a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
439e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
440ec530c81Sbellard;;
441b29fe3edSmalcAIX)
442b29fe3edSmalc  aix="yes"
4430db4a067SPaolo Bonzini  make="${MAKE-gmake}"
444b29fe3edSmalc;;
445179cf400SAndreas FärberHaiku)
446179cf400SAndreas Färber  haiku="yes"
447179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
448179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
449179cf400SAndreas Färber;;
450fb065187Sbellard*)
4510c58ac1cSmalc  audio_drv_list="oss"
452b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4535327cf48Sbellard  linux="yes"
454831b7825Sths  linux_user="yes"
45568063649Sblueswir1  usb="linux"
45607f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
457c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
458c9ec1fe4Sbellard  fi
459fb065187Sbellard;;
4607d13299dSbellardesac
4617d13299dSbellard
4627d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
463b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
46468063649Sblueswir1    usb="bsd"
46583fb7adfSbellard  fi
46684778508Sblueswir1  bsd_user="yes"
4677d3505c5Sbellardfi
4687d3505c5Sbellard
4690db4a067SPaolo Bonzini: ${make=${MAKE-make}}
4700db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
4710db4a067SPaolo Bonzini
4723457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4733457a3f8SJuan Quintela  EXESUF=".exe"
474a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
475e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
476e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
47708f3896aSStefan Weil  LIBS="-lwinmm -lws2_32 -liberty -liphlpapi $LIBS"
478683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
479683035deSPaolo Bonzini  mandir="\${prefix}"
480683035deSPaolo Bonzini  datadir="\${prefix}"
481683035deSPaolo Bonzini  docdir="\${prefix}"
482683035deSPaolo Bonzini  bindir="\${prefix}"
483683035deSPaolo Bonzini  sysconfdir="\${prefix}"
484683035deSPaolo Bonzini  confsuffix=""
4853457a3f8SJuan Quintelafi
4863457a3f8SJuan Quintela
487487fefdbSAnthony Liguoriwerror=""
48885aa5189Sbellard
4897d13299dSbellardfor opt do
490a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4917d13299dSbellard  case "$opt" in
4922efc3265Sbellard  --help|-h) show_help=yes
4932efc3265Sbellard  ;;
494b1a550a0Spbrook  --prefix=*) prefix="$optarg"
4957d13299dSbellard  ;;
496b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
49732ce6337Sbellard  ;;
498ca4deeb1SPaolo Bonzini  --source-path=*)
4997d13299dSbellard  ;;
500ac0df51dSaliguori  --cross-prefix=*)
5017d13299dSbellard  ;;
502ac0df51dSaliguori  --cc=*)
5037d13299dSbellard  ;;
504b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
50583469015Sbellard  ;;
506b1a550a0Spbrook  --make=*) make="$optarg"
5077d13299dSbellard  ;;
5086a882643Spbrook  --install=*) install="$optarg"
5096a882643Spbrook  ;;
510e2a2ed06SJuan Quintela  --extra-cflags=*)
5117d13299dSbellard  ;;
512e2a2ed06SJuan Quintela  --extra-ldflags=*)
5137d13299dSbellard  ;;
5142ff6b91eSJuan Quintela  --cpu=*)
5157d13299dSbellard  ;;
516b1a550a0Spbrook  --target-list=*) target_list="$optarg"
517de83cd02Sbellard  ;;
51874242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
51994a420b1SStefan Hajnoczi  ;;
52074242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
5219410b56cSPrerna Saxena  ;;
5227d13299dSbellard  --enable-gprof) gprof="yes"
5237d13299dSbellard  ;;
52479427693SLoïc Minier  --static)
52579427693SLoïc Minier    static="yes"
52679427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
52743ce4dfeSbellard  ;;
5280b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5290b24e75fSPaolo Bonzini  ;;
5300b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5310b24e75fSPaolo Bonzini  ;;
5320b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5330b24e75fSPaolo Bonzini  ;;
5340b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5350b24e75fSPaolo Bonzini  ;;
536ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
53707381cc1SAnthony Liguori  ;;
53897a847bcSbellard  --disable-sdl) sdl="no"
53997a847bcSbellard  ;;
540c4198157SJuan Quintela  --enable-sdl) sdl="yes"
541c4198157SJuan Quintela  ;;
542b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
543102a52e4Sbellard  ;;
544c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
545c2de5c91Smalc  ;;
5462f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5472f6a1ab0Sblueswir1  ;;
5482fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5490c58ac1cSmalc  ;;
5500c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5510c58ac1cSmalc  ;;
552eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
553eb852011SMarkus Armbruster  ;;
554f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
555f8393946Saurel32  ;;
556f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
557f8393946Saurel32  ;;
558b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
559b4475aa2SLuiz Capitulino  ;;
560b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
561b4475aa2SLuiz Capitulino  ;;
562f3d08ee6SPaul Brook  --enable-debug)
563f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
564f3d08ee6SPaul Brook      debug_tcg="yes"
565b4475aa2SLuiz Capitulino      debug_mon="yes"
566f3d08ee6SPaul Brook      debug="yes"
567f3d08ee6SPaul Brook      strip_opt="no"
568f3d08ee6SPaul Brook  ;;
56903b4fe7dSaliguori  --enable-sparse) sparse="yes"
57003b4fe7dSaliguori  ;;
57103b4fe7dSaliguori  --disable-sparse) sparse="no"
57203b4fe7dSaliguori  ;;
5731625af87Saliguori  --disable-strip) strip_opt="no"
5741625af87Saliguori  ;;
5758d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5768d5d2d4cSths  ;;
5771be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
5781be10ad2SJuan Quintela  ;;
5792f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
5802f9606b3Saliguori  ;;
581ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
582ea784e3bSJuan Quintela  ;;
5832f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
5842f6f5c7aSCorentin Chary  ;;
5852f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
5862f6f5c7aSCorentin Chary  ;;
587efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
588efe556adSCorentin Chary  ;;
589efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
590efe556adSCorentin Chary  ;;
591bd023f95SCorentin Chary  --disable-vnc-thread) vnc_thread="no"
592bd023f95SCorentin Chary  ;;
593bd023f95SCorentin Chary  --enable-vnc-thread) vnc_thread="yes"
594bd023f95SCorentin Chary  ;;
595443f1376Sbellard  --disable-slirp) slirp="no"
596c20709aaSbellard  ;;
597ee682d27SStefan Weil  --disable-uuid) uuid="no"
598ee682d27SStefan Weil  ;;
599ee682d27SStefan Weil  --enable-uuid) uuid="yes"
600ee682d27SStefan Weil  ;;
601e0e6c8c0Saliguori  --disable-vde) vde="no"
6028a16d273Sths  ;;
603dfb278bdSJuan Quintela  --enable-vde) vde="yes"
604dfb278bdSJuan Quintela  ;;
605e37630caSaliguori  --disable-xen) xen="no"
606e37630caSaliguori  ;;
607fc321b4bSJuan Quintela  --enable-xen) xen="yes"
608fc321b4bSJuan Quintela  ;;
6092e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
6102e4d9fb1Saurel32  ;;
6114ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6124ffcedb6SJuan Quintela  ;;
613fb599c9aSbalrog  --disable-bluez) bluez="no"
614fb599c9aSbalrog  ;;
615a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
616a20a6f46SJuan Quintela  ;;
6177ba1e619Saliguori  --disable-kvm) kvm="no"
6187ba1e619Saliguori  ;;
619b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
620b31a0277SJuan Quintela  ;;
621cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
622cd4ec0b4SGerd Hoffmann  ;;
623cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
624cd4ec0b4SGerd Hoffmann  ;;
62505c2a3e7Sbellard  --enable-profiler) profiler="yes"
62605c2a3e7Sbellard  ;;
627c2de5c91Smalc  --enable-cocoa)
628c2de5c91Smalc      cocoa="yes" ;
629c2de5c91Smalc      sdl="no" ;
630c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6315b0753e0Sbellard  ;;
632cad25d69Spbrook  --disable-system) softmmu="no"
6330a8e90f4Spbrook  ;;
634cad25d69Spbrook  --enable-system) softmmu="yes"
6350a8e90f4Spbrook  ;;
6360953a80fSZachary Amsden  --disable-user)
6370953a80fSZachary Amsden      linux_user="no" ;
6380953a80fSZachary Amsden      bsd_user="no" ;
6390953a80fSZachary Amsden      darwin_user="no"
6400953a80fSZachary Amsden  ;;
6410953a80fSZachary Amsden  --enable-user) ;;
642831b7825Sths  --disable-linux-user) linux_user="no"
6430a8e90f4Spbrook  ;;
644831b7825Sths  --enable-linux-user) linux_user="yes"
645831b7825Sths  ;;
646831b7825Sths  --disable-darwin-user) darwin_user="no"
647831b7825Sths  ;;
648831b7825Sths  --enable-darwin-user) darwin_user="yes"
6490a8e90f4Spbrook  ;;
65084778508Sblueswir1  --disable-bsd-user) bsd_user="no"
65184778508Sblueswir1  ;;
65284778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
65384778508Sblueswir1  ;;
654379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
655379f6698SPaul Brook  ;;
656379f6698SPaul Brook  --disable-guest-base) guest_base="no"
657379f6698SPaul Brook  ;;
65834005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
65934005a00SKirill A. Shutemov  ;;
66034005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
66134005a00SKirill A. Shutemov  ;;
662c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
663c5937220Spbrook  ;;
6643142255cSblueswir1  --sparc_cpu=*)
6653142255cSblueswir1  ;;
66685aa5189Sbellard  --enable-werror) werror="yes"
66785aa5189Sbellard  ;;
66885aa5189Sbellard  --disable-werror) werror="no"
66985aa5189Sbellard  ;;
6704d3b6f6eSbalrog  --disable-curses) curses="no"
6714d3b6f6eSbalrog  ;;
672c584a6d0SJuan Quintela  --enable-curses) curses="yes"
673c584a6d0SJuan Quintela  ;;
674769ce76dSAlexander Graf  --disable-curl) curl="no"
675769ce76dSAlexander Graf  ;;
676788c8196SJuan Quintela  --enable-curl) curl="yes"
677788c8196SJuan Quintela  ;;
6782df87df7SJuan Quintela  --disable-fdt) fdt="no"
6792df87df7SJuan Quintela  ;;
6802df87df7SJuan Quintela  --enable-fdt) fdt="yes"
6812df87df7SJuan Quintela  ;;
6825495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
6835495ed11SLuiz Capitulino  ;;
6845495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
6855495ed11SLuiz Capitulino  ;;
686bd0c5661Spbrook  --disable-nptl) nptl="no"
687bd0c5661Spbrook  ;;
688b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
689b0a47e79SJuan Quintela  ;;
6908ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
6918ff9cbf7Smalc  ;;
6925c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
6935c6c3a6cSChristoph Hellwig  ;;
6945c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
6955c6c3a6cSChristoph Hellwig  ;;
696758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
697758e8e38SVenkateswararao Jujjuri (JV)  ;;
698758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
699758e8e38SVenkateswararao Jujjuri (JV)  ;;
700e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
701e5d355d1Saliguori  ;;
70277755340Sths  --disable-blobs) blobs="no"
70377755340Sths  ;;
704eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
705eac30262Saliguori  ;;
7064a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
7074a19f1ecSpbrook  ;;
708a25dba17SJuan Quintela  --disable-docs) docs="no"
70970ec5dc0SAnthony Liguori  ;;
710a25dba17SJuan Quintela  --enable-docs) docs="yes"
71183a3ab8bSJuan Quintela  ;;
712d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
713d5970055SMichael S. Tsirkin  ;;
714d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
715d5970055SMichael S. Tsirkin  ;;
7166bde81cbSPaolo Bonzini  --*dir)
7176bde81cbSPaolo Bonzini  ;;
718f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
719f27aaf4bSChristian Brunner  ;;
720f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
721f27aaf4bSChristian Brunner  ;;
7227f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7237f1559c6Sbalrog  ;;
7247d13299dSbellard  esac
7257d13299dSbellarddone
7267d13299dSbellard
7273142255cSblueswir1#
7283142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
729a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7303142255cSblueswir1#
731379f6698SPaul Brookhost_guest_base="no"
73240293e58Sbellardcase "$cpu" in
733ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
734ed968ff1SJuan Quintela           v7|v8)
735a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
736ed968ff1SJuan Quintela           ;;
737ed968ff1SJuan Quintela           v8plus|v8plusa)
738a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
739ed968ff1SJuan Quintela           ;;
740ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
741a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
742ed968ff1SJuan Quintela           esac
7430c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
744a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
745762e8230Sblueswir1           if test "$solaris" = "no" ; then
746a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
747c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
748762e8230Sblueswir1           fi
7493142255cSblueswir1           ;;
750ed968ff1SJuan Quintela    sparc64)
751a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7520c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
753a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
754ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
755a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
756762e8230Sblueswir1           fi
7573142255cSblueswir1           ;;
75876d83bdeSths    s390)
75928d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
76028d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
76148bb3750SRichard Henderson           host_guest_base="yes"
76228d7cc49SRichard Henderson           ;;
76328d7cc49SRichard Henderson    s390x)
76428d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
76528d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
76648bb3750SRichard Henderson           host_guest_base="yes"
76776d83bdeSths           ;;
76840293e58Sbellard    i386)
769a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
7700c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
7712b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
772c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
773379f6698SPaul Brook           host_guest_base="yes"
77440293e58Sbellard           ;;
77540293e58Sbellard    x86_64)
776a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
7770c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
7782b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
779379f6698SPaul Brook           host_guest_base="yes"
780379f6698SPaul Brook           ;;
781379f6698SPaul Brook    arm*)
782379f6698SPaul Brook           host_guest_base="yes"
78340293e58Sbellard           ;;
784f6548c0aSmalc    ppc*)
785f6548c0aSmalc           host_guest_base="yes"
786f6548c0aSmalc           ;;
787cc01cc8eSAurelien Jarno    mips*)
788cc01cc8eSAurelien Jarno           host_guest_base="yes"
789cc01cc8eSAurelien Jarno           ;;
790477ba620SAurelien Jarno    ia64*)
791477ba620SAurelien Jarno           host_guest_base="yes"
792477ba620SAurelien Jarno           ;;
793fd76e73aSRichard Henderson    hppa*)
794fd76e73aSRichard Henderson           host_guest_base="yes"
795fd76e73aSRichard Henderson           ;;
7963142255cSblueswir1esac
7973142255cSblueswir1
798379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
799379f6698SPaul Brook
800af5db58eSpbrookif test x"$show_help" = x"yes" ; then
801af5db58eSpbrookcat << EOF
802af5db58eSpbrook
803af5db58eSpbrookUsage: configure [options]
804af5db58eSpbrookOptions: [defaults in brackets after descriptions]
805af5db58eSpbrook
806af5db58eSpbrookEOF
807af5db58eSpbrookecho "Standard options:"
808af5db58eSpbrookecho "  --help                   print this message"
809af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
810af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
811af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
812af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
813af5db58eSpbrookecho ""
814af5db58eSpbrookecho "Advanced options (experts only):"
815af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
816af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
817af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
8180bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
8190bfe8cc0SPaolo Bonziniecho "                           build time"
820a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
821e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
822af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
8236a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
824af5db58eSpbrookecho "  --static                 enable static build [$static]"
8250b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
8260b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
8270b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
8280b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
8290b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
830f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
831f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
83209695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
833890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
834890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
8351625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
83685aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
837fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
838c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
839af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
840c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
841c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
8424c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
8434c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
844eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
845eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
8468ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
847e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
848fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
8492e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
8504ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
8518d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
8521be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
8532f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
854ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
8552f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
8562f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
85796763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
858efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
859bd023f95SCorentin Charyecho "  --disable-vnc-thread     disable threaded VNC server"
860bd023f95SCorentin Charyecho "  --enable-vnc-thread      enable threaded VNC server"
861af896aaaSpbrookecho "  --disable-curses         disable curses output"
862c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
863769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
864788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
8652df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
8662df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
8675495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
8685495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
869fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
870a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
8717ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
872b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
873bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
874e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
875af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
876af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
8770953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
8780953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
879831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
880831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
881831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
882831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
88384778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
88484778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
885379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
886379f6698SPaul Brookecho "                           emulation targets"
887379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
88834005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
88934005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
890af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
891af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
8922f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
893c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
8943142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
895ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
896ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
897e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
898dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
8995c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
9005c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
901758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
902758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
903e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
90477755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
905eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
906d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
907d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
908d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
909d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
910320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
911320fba2aSFabien Chouteauecho "                           Available backends:" $("$source_path"/scripts/tracetool --list-backends)
91274242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
9139410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
914cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
915cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
916f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
917af5db58eSpbrookecho ""
9185bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
919af5db58eSpbrookexit 1
920af5db58eSpbrookfi
921af5db58eSpbrook
9228d05095cSPaolo Bonzini# check that the C compiler works.
9238d05095cSPaolo Bonzinicat > $TMPC <<EOF
9248d05095cSPaolo Bonziniint main(void) {}
9258d05095cSPaolo BonziniEOF
9268d05095cSPaolo Bonzini
9278d05095cSPaolo Bonziniif compile_object ; then
9288d05095cSPaolo Bonzini  : C compiler works ok
9298d05095cSPaolo Bonzinielse
9308d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
9318d05095cSPaolo Bonzini    exit 1
9328d05095cSPaolo Bonzinifi
9338d05095cSPaolo Bonzini
9348d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
9358d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
9368d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
9378d05095cSPaolo Bonzinigcc_flags="-fstack-protector-all $gcc_flags"
9388d05095cSPaolo Bonzinicat > $TMPC << EOF
9398d05095cSPaolo Bonziniint main(void) { return 0; }
9408d05095cSPaolo BonziniEOF
9418d05095cSPaolo Bonzinifor flag in $gcc_flags; do
9428d05095cSPaolo Bonzini    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
9438d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
9448d05095cSPaolo Bonzini    fi
9458d05095cSPaolo Bonzinidone
9468d05095cSPaolo Bonzini
947ec530c81Sbellard#
948ec530c81Sbellard# Solaris specific configure tool chain decisions
949ec530c81Sbellard#
950ec530c81Sbellardif test "$solaris" = "yes" ; then
9516792aa11SLoïc Minier  if has $install; then
9526792aa11SLoïc Minier    :
9536792aa11SLoïc Minier  else
954ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
955ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
956ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
957ec530c81Sbellard    exit 1
958ec530c81Sbellard  fi
9596792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
960ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
961ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
962ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
963ec530c81Sbellard    exit 1
964ec530c81Sbellard  fi
9656792aa11SLoïc Minier  if has ar; then
9666792aa11SLoïc Minier    :
9676792aa11SLoïc Minier  else
968ec530c81Sbellard    echo "Error: No path includes ar"
969ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
970ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
971ec530c81Sbellard    fi
972ec530c81Sbellard    exit 1
973ec530c81Sbellard  fi
974ec530c81Sbellardfi
975ec530c81Sbellard
976ec530c81Sbellard
9775327cf48Sbellardif test -z "$target_list" ; then
9785327cf48Sbellard# these targets are portable
9790a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
9802408a527Saurel32        target_list="\
9812408a527Saurel32i386-softmmu \
9822408a527Saurel32x86_64-softmmu \
9832408a527Saurel32arm-softmmu \
9842408a527Saurel32cris-softmmu \
985613a22c9SMichael Wallelm32-softmmu \
9862408a527Saurel32m68k-softmmu \
98772b675caSEdgar E. Iglesiasmicroblaze-softmmu \
988877fdc12SEdgar E. Iglesiasmicroblazeel-softmmu \
9892408a527Saurel32mips-softmmu \
9902408a527Saurel32mipsel-softmmu \
9912408a527Saurel32mips64-softmmu \
9922408a527Saurel32mips64el-softmmu \
9932408a527Saurel32ppc-softmmu \
9942408a527Saurel32ppcemb-softmmu \
9952408a527Saurel32ppc64-softmmu \
9962408a527Saurel32sh4-softmmu \
9972408a527Saurel32sh4eb-softmmu \
9982408a527Saurel32sparc-softmmu \
9991b64fcaeSIgor V. Kovalenkosparc64-softmmu \
10002408a527Saurel32"
10010a8e90f4Spbrook    fi
10025327cf48Sbellard# the following are Linux specific
1003831b7825Sths    if [ "$linux_user" = "yes" ] ; then
10042408a527Saurel32        target_list="${target_list}\
10052408a527Saurel32i386-linux-user \
10062408a527Saurel32x86_64-linux-user \
10072408a527Saurel32alpha-linux-user \
10082408a527Saurel32arm-linux-user \
10092408a527Saurel32armeb-linux-user \
10102408a527Saurel32cris-linux-user \
10112408a527Saurel32m68k-linux-user \
101272b675caSEdgar E. Iglesiasmicroblaze-linux-user \
1013877fdc12SEdgar E. Iglesiasmicroblazeel-linux-user \
10142408a527Saurel32mips-linux-user \
10152408a527Saurel32mipsel-linux-user \
10162408a527Saurel32ppc-linux-user \
10172408a527Saurel32ppc64-linux-user \
10182408a527Saurel32ppc64abi32-linux-user \
10192408a527Saurel32sh4-linux-user \
10202408a527Saurel32sh4eb-linux-user \
10212408a527Saurel32sparc-linux-user \
10222408a527Saurel32sparc64-linux-user \
10232408a527Saurel32sparc32plus-linux-user \
10242408a527Saurel32"
1025831b7825Sths    fi
1026831b7825Sths# the following are Darwin specific
1027831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
10282408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
10295327cf48Sbellard    fi
103084778508Sblueswir1# the following are BSD specific
103184778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
103284778508Sblueswir1        target_list="${target_list}\
103331fc12dfSblueswir1i386-bsd-user \
103431fc12dfSblueswir1x86_64-bsd-user \
103531fc12dfSblueswir1sparc-bsd-user \
103684778508Sblueswir1sparc64-bsd-user \
103784778508Sblueswir1"
103884778508Sblueswir1    fi
10396e20a45fSbellardelse
1040b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
10415327cf48Sbellardfi
10420a8e90f4Spbrookif test -z "$target_list" ; then
10430a8e90f4Spbrook    echo "No targets enabled"
10440a8e90f4Spbrook    exit 1
10450a8e90f4Spbrookfi
1046f55fe278SPaolo Bonzini# see if system emulation was really requested
1047f55fe278SPaolo Bonzinicase " $target_list " in
1048f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1049f55fe278SPaolo Bonzini  ;;
1050f55fe278SPaolo Bonzini  *) softmmu=no
1051f55fe278SPaolo Bonzini  ;;
1052f55fe278SPaolo Bonziniesac
10535327cf48Sbellard
1054249247c9SJuan Quintelafeature_not_found() {
1055249247c9SJuan Quintela  feature=$1
1056249247c9SJuan Quintela
1057249247c9SJuan Quintela  echo "ERROR"
1058249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
10599332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1060249247c9SJuan Quintela  echo "ERROR"
1061249247c9SJuan Quintela  exit 1;
1062249247c9SJuan Quintela}
1063249247c9SJuan Quintela
10647d13299dSbellardif test -z "$cross_prefix" ; then
10657d13299dSbellard
10667d13299dSbellard# ---
10677d13299dSbellard# big/little endian test
10687d13299dSbellardcat > $TMPC << EOF
10697d13299dSbellard#include <inttypes.h>
10707d13299dSbellardint main(int argc, char ** argv){
10717d13299dSbellard        volatile uint32_t i=0x01234567;
10727d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
10737d13299dSbellard}
10747d13299dSbellardEOF
10757d13299dSbellard
107652166aa0SJuan Quintelaif compile_prog "" "" ; then
10777d13299dSbellard$TMPE && bigendian="yes"
10787d13299dSbellardelse
10797d13299dSbellardecho big/little test failed
10807d13299dSbellardfi
10817d13299dSbellard
10827d13299dSbellardelse
10837d13299dSbellard
10847d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1085ea8f20f8SJuan Quintelacase "$cpu" in
108624e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1087ea8f20f8SJuan Quintela    bigendian=yes
1088ea8f20f8SJuan Quintela  ;;
1089ea8f20f8SJuan Quintelaesac
10907d13299dSbellard
10917d13299dSbellardfi
10927d13299dSbellard
109370be1a2eSPaolo Bonzini# host long bits test, actually a pointer size test
109470be1a2eSPaolo Bonzinicat > $TMPC << EOF
109570be1a2eSPaolo Bonziniint sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
109670be1a2eSPaolo BonziniEOF
109770be1a2eSPaolo Bonziniif compile_object; then
1098ea8f20f8SJuan Quintelahostlongbits=64
109970be1a2eSPaolo Bonzinielse
110070be1a2eSPaolo Bonzinihostlongbits=32
110170be1a2eSPaolo Bonzinifi
1102b6853697Sbellard
1103b0a47e79SJuan Quintela
1104b0a47e79SJuan Quintela##########################################
1105b0a47e79SJuan Quintela# NPTL probe
1106b0a47e79SJuan Quintela
1107b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1108bd0c5661Spbrook  cat > $TMPC <<EOF
1109bd0c5661Spbrook#include <sched.h>
111030813ceaSpbrook#include <linux/futex.h>
1111bd0c5661Spbrookvoid foo()
1112bd0c5661Spbrook{
1113bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1114bd0c5661Spbrook#error bork
1115bd0c5661Spbrook#endif
1116bd0c5661Spbrook}
1117bd0c5661SpbrookEOF
1118bd0c5661Spbrook
111952166aa0SJuan Quintela  if compile_object ; then
1120b0a47e79SJuan Quintela    nptl=yes
1121bd0c5661Spbrook  else
1122b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1123b0a47e79SJuan Quintela      feature_not_found "nptl"
1124b0a47e79SJuan Quintela    fi
1125b0a47e79SJuan Quintela    nptl=no
1126b0a47e79SJuan Quintela  fi
1127bd0c5661Spbrookfi
1128bd0c5661Spbrook
112911d9f695Sbellard##########################################
1130ac62922eSbalrog# zlib check
1131ac62922eSbalrog
1132ac62922eSbalrogcat > $TMPC << EOF
1133ac62922eSbalrog#include <zlib.h>
1134ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1135ac62922eSbalrogEOF
113652166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
1137ac62922eSbalrog    :
1138ac62922eSbalrogelse
1139ac62922eSbalrog    echo
1140ac62922eSbalrog    echo "Error: zlib check failed"
1141ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
1142ac62922eSbalrog    echo
1143ac62922eSbalrog    exit 1
1144ac62922eSbalrogfi
1145ac62922eSbalrog
1146ac62922eSbalrog##########################################
1147e37630caSaliguori# xen probe
1148e37630caSaliguori
1149fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1150b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1151e37630caSaliguori  cat > $TMPC <<EOF
1152e37630caSaliguori#include <xenctrl.h>
1153e37630caSaliguori#include <xs.h>
1154df7a607bSChristoph Eggerint main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1155e37630caSaliguoriEOF
115652166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1157fc321b4bSJuan Quintela    xen=yes
11583efd632bSJuan Quintela    libs_softmmu="$xen_libs $libs_softmmu"
1159e37630caSaliguori  else
1160fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1161fc321b4bSJuan Quintela      feature_not_found "xen"
1162fc321b4bSJuan Quintela    fi
1163fc321b4bSJuan Quintela    xen=no
1164e37630caSaliguori  fi
1165e37630caSaliguorifi
1166e37630caSaliguori
1167e37630caSaliguori##########################################
1168a8bd70adSPaolo Bonzini# pkg-config probe
1169f91672e5SPaolo Bonzini
1170a8bd70adSPaolo Bonziniif ! has $pkg_config; then
117108421541SPaolo Bonzini  echo warning: proceeding without "$pkg_config" >&2
117208421541SPaolo Bonzini  pkg_config=/bin/false
1173f91672e5SPaolo Bonzinifi
1174f91672e5SPaolo Bonzini
1175f91672e5SPaolo Bonzini##########################################
1176dfffc653SJuan Quintela# Sparse probe
1177dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
11780dba6195SLoïc Minier  if has cgcc; then
1179dfffc653SJuan Quintela    sparse=yes
1180dfffc653SJuan Quintela  else
1181dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1182dfffc653SJuan Quintela      feature_not_found "sparse"
1183dfffc653SJuan Quintela    fi
1184dfffc653SJuan Quintela    sparse=no
1185dfffc653SJuan Quintela  fi
1186dfffc653SJuan Quintelafi
1187dfffc653SJuan Quintela
1188dfffc653SJuan Quintela##########################################
118911d9f695Sbellard# SDL probe
119011d9f695Sbellard
11913ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
11923ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
11933ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
11943ec87ffeSPaolo Bonzini  sdl_config=sdl-config
11953ec87ffeSPaolo Bonzinifi
11963ec87ffeSPaolo Bonzini
11973ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1198a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1199fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
12003ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
12013ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
12029316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1203a0dfd8a4SLoïc Minierelse
1204a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1205a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1206a0dfd8a4SLoïc Minier  fi
1207a0dfd8a4SLoïc Minier  sdl=no
12089316f803SPaolo Bonzinifi
12093ec87ffeSPaolo Bonziniif test -n "$cross_prefix" && test "`basename $sdlconfig`" = sdl-config; then
12103ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
12113ec87ffeSPaolo Bonzinifi
121211d9f695Sbellard
12139316f803SPaolo Bonzinisdl_too_old=no
1214c4198157SJuan Quintelaif test "$sdl" != "no" ; then
121511d9f695Sbellard  cat > $TMPC << EOF
121611d9f695Sbellard#include <SDL.h>
121711d9f695Sbellard#undef main /* We don't want SDL to override our main() */
121811d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
121911d9f695SbellardEOF
12209316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
122174f42e18STeLeMan  if test "$static" = "yes" ; then
122274f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
122374f42e18STeLeMan  else
12249316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
122574f42e18STeLeMan  fi
122652166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
122711d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
122811d9f695Sbellard      sdl_too_old=yes
122911d9f695Sbellard    else
1230fd677642Sths      if test "$cocoa" = "no" ; then
123111d9f695Sbellard        sdl=yes
123211d9f695Sbellard      fi
1233fd677642Sths    fi
12347c1f25b4Sbellard
123567c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
12361ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
123767c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1238f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1239f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
124011d9f695Sbellard      fi
124152166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
12421ac88f28SJuan Quintela	:
12431ac88f28SJuan Quintela      else
12441ac88f28SJuan Quintela        sdl=no
12457c1f25b4Sbellard      fi
12467c1f25b4Sbellard    fi # static link
1247c4198157SJuan Quintela  else # sdl not found
1248c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1249c4198157SJuan Quintela      feature_not_found "sdl"
1250c4198157SJuan Quintela    fi
1251c4198157SJuan Quintela    sdl=no
12527c1f25b4Sbellard  fi # sdl compile test
1253fd677642Sthsfi
125411d9f695Sbellard
12555368a422Saliguoriif test "$sdl" = "yes" ; then
12565368a422Saliguori  cat > $TMPC <<EOF
12575368a422Saliguori#include <SDL.h>
12585368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
12595368a422Saliguori#include <X11/XKBlib.h>
12605368a422Saliguori#else
12615368a422Saliguori#error No x11 support
12625368a422Saliguori#endif
12635368a422Saliguoriint main(void) { return 0; }
12645368a422SaliguoriEOF
126552166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1266681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
12675368a422Saliguori  fi
126807d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
126907d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
127007d9ac44SJuan Quintela  fi
12710705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
12725368a422Saliguorifi
12735368a422Saliguori
12748f28f3fbSths##########################################
12758d5d2d4cSths# VNC TLS detection
12761be10ad2SJuan Quintelaif test "$vnc_tls" != "no" ; then
1277ae6b5e5aSaliguori  cat > $TMPC <<EOF
1278ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1279ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1280ae6b5e5aSaliguoriEOF
1281a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1282a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
128352166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
12841be10ad2SJuan Quintela    vnc_tls=yes
1285a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1286ae6b5e5aSaliguori  else
12871be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
12881be10ad2SJuan Quintela      feature_not_found "vnc-tls"
12891be10ad2SJuan Quintela    fi
12901be10ad2SJuan Quintela    vnc_tls=no
12918d5d2d4cSths  fi
12928d5d2d4cSthsfi
12938d5d2d4cSths
12948d5d2d4cSths##########################################
12952f9606b3Saliguori# VNC SASL detection
12963aefa744SJuan Quintelaif test "$vnc_sasl" != "no" ; then
12972f9606b3Saliguori  cat > $TMPC <<EOF
12982f9606b3Saliguori#include <sasl/sasl.h>
12992f9606b3Saliguori#include <stdio.h>
13002f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
13012f9606b3SaliguoriEOF
13022f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
13032f9606b3Saliguori  vnc_sasl_cflags=""
13042f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
130552166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1306ea784e3bSJuan Quintela    vnc_sasl=yes
1307fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
13082f9606b3Saliguori  else
1309ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1310ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1311ea784e3bSJuan Quintela    fi
1312ea784e3bSJuan Quintela    vnc_sasl=no
13132f9606b3Saliguori  fi
13142f9606b3Saliguorifi
13152f9606b3Saliguori
13162f9606b3Saliguori##########################################
13172f6f5c7aSCorentin Chary# VNC JPEG detection
131896763cf9SCorentin Charyif test "$vnc_jpeg" != "no" ; then
13192f6f5c7aSCorentin Charycat > $TMPC <<EOF
13202f6f5c7aSCorentin Chary#include <stdio.h>
13212f6f5c7aSCorentin Chary#include <jpeglib.h>
13222f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
13232f6f5c7aSCorentin CharyEOF
13242f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
13252f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
13262f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
13272f6f5c7aSCorentin Chary    vnc_jpeg=yes
13282f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
13292f6f5c7aSCorentin Chary  else
13302f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
13312f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
13322f6f5c7aSCorentin Chary    fi
13332f6f5c7aSCorentin Chary    vnc_jpeg=no
13342f6f5c7aSCorentin Chary  fi
13352f6f5c7aSCorentin Charyfi
13362f6f5c7aSCorentin Chary
13372f6f5c7aSCorentin Chary##########################################
1338efe556adSCorentin Chary# VNC PNG detection
133996763cf9SCorentin Charyif test "$vnc_png" != "no" ; then
1340efe556adSCorentin Charycat > $TMPC <<EOF
1341efe556adSCorentin Chary//#include <stdio.h>
1342efe556adSCorentin Chary#include <png.h>
1343832ce9c2SScott Wood#include <stddef.h>
1344efe556adSCorentin Charyint main(void) {
1345efe556adSCorentin Chary    png_structp png_ptr;
1346efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1347efe556adSCorentin Chary    return 0;
1348efe556adSCorentin Chary}
1349efe556adSCorentin CharyEOF
1350efe556adSCorentin Chary    vnc_png_cflags=""
1351efe556adSCorentin Chary    vnc_png_libs="-lpng"
1352efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1353efe556adSCorentin Chary    vnc_png=yes
1354efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
1355efe556adSCorentin Chary  else
1356efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1357efe556adSCorentin Chary      feature_not_found "vnc-png"
1358efe556adSCorentin Chary    fi
1359efe556adSCorentin Chary    vnc_png=no
1360efe556adSCorentin Chary  fi
1361efe556adSCorentin Charyfi
1362efe556adSCorentin Chary
1363efe556adSCorentin Chary##########################################
136476655d6dSaliguori# fnmatch() probe, used for ACL routines
136576655d6dSaliguorifnmatch="no"
136676655d6dSaliguoricat > $TMPC << EOF
136776655d6dSaliguori#include <fnmatch.h>
136876655d6dSaliguoriint main(void)
136976655d6dSaliguori{
137076655d6dSaliguori    fnmatch("foo", "foo", 0);
137176655d6dSaliguori    return 0;
137276655d6dSaliguori}
137376655d6dSaliguoriEOF
137452166aa0SJuan Quintelaif compile_prog "" "" ; then
137576655d6dSaliguori   fnmatch="yes"
137676655d6dSaliguorifi
137776655d6dSaliguori
137876655d6dSaliguori##########################################
1379ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1380ee682d27SStefan Weilif test "$uuid" != "no" ; then
1381ee682d27SStefan Weil  uuid_libs="-luuid"
1382ee682d27SStefan Weil  cat > $TMPC << EOF
1383ee682d27SStefan Weil#include <uuid/uuid.h>
1384ee682d27SStefan Weilint main(void)
1385ee682d27SStefan Weil{
1386ee682d27SStefan Weil    uuid_t my_uuid;
1387ee682d27SStefan Weil    uuid_generate(my_uuid);
1388ee682d27SStefan Weil    return 0;
1389ee682d27SStefan Weil}
1390ee682d27SStefan WeilEOF
1391ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1392ee682d27SStefan Weil    uuid="yes"
1393ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1394ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1395ee682d27SStefan Weil  else
1396ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1397ee682d27SStefan Weil      feature_not_found "uuid"
1398ee682d27SStefan Weil    fi
1399ee682d27SStefan Weil    uuid=no
1400ee682d27SStefan Weil  fi
1401ee682d27SStefan Weilfi
1402ee682d27SStefan Weil
1403ee682d27SStefan Weil##########################################
1404dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1405dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1406dce512deSChristoph Hellwig  cat > $TMPC << EOF
1407dce512deSChristoph Hellwig#include <xfs/xfs.h>
1408dce512deSChristoph Hellwigint main(void)
1409dce512deSChristoph Hellwig{
1410dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1411dce512deSChristoph Hellwig    return 0;
1412dce512deSChristoph Hellwig}
1413dce512deSChristoph HellwigEOF
1414dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1415dce512deSChristoph Hellwig    xfs="yes"
1416dce512deSChristoph Hellwig  else
1417dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1418dce512deSChristoph Hellwig      feature_not_found "xfs"
1419dce512deSChristoph Hellwig    fi
1420dce512deSChristoph Hellwig    xfs=no
1421dce512deSChristoph Hellwig  fi
1422dce512deSChristoph Hellwigfi
1423dce512deSChristoph Hellwig
1424dce512deSChristoph Hellwig##########################################
14258a16d273Sths# vde libraries probe
1426dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
14274baae0acSJuan Quintela  vde_libs="-lvdeplug"
14288a16d273Sths  cat > $TMPC << EOF
14298a16d273Sths#include <libvdeplug.h>
14304a7f0e06Spbrookint main(void)
14314a7f0e06Spbrook{
14324a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
14334a7f0e06Spbrook    vde_open("", "", &a);
14344a7f0e06Spbrook    return 0;
14354a7f0e06Spbrook}
14368a16d273SthsEOF
143752166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
14384baae0acSJuan Quintela    vde=yes
14398e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
14408e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1441dfb278bdSJuan Quintela  else
1442dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1443dfb278bdSJuan Quintela      feature_not_found "vde"
1444dfb278bdSJuan Quintela    fi
1445dfb278bdSJuan Quintela    vde=no
14468a16d273Sths  fi
14478a16d273Sthsfi
14488a16d273Sths
14498a16d273Sths##########################################
1450c2de5c91Smalc# Sound support libraries probe
14518f28f3fbSths
1452c2de5c91Smalcaudio_drv_probe()
1453c2de5c91Smalc{
1454c2de5c91Smalc    drv=$1
1455c2de5c91Smalc    hdr=$2
1456c2de5c91Smalc    lib=$3
1457c2de5c91Smalc    exp=$4
1458c2de5c91Smalc    cfl=$5
14598f28f3fbSths        cat > $TMPC << EOF
1460c2de5c91Smalc#include <$hdr>
1461c2de5c91Smalcint main(void) { $exp }
14628f28f3fbSthsEOF
146352166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
14648f28f3fbSths        :
14658f28f3fbSths    else
14668f28f3fbSths        echo
1467c2de5c91Smalc        echo "Error: $drv check failed"
1468c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
14698f28f3fbSths        echo
14708f28f3fbSths        exit 1
14718f28f3fbSths    fi
1472c2de5c91Smalc}
1473c2de5c91Smalc
14742fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1475c2de5c91Smalcfor drv in $audio_drv_list; do
1476c2de5c91Smalc    case $drv in
1477c2de5c91Smalc    alsa)
1478c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1479c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1480a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1481c2de5c91Smalc    ;;
1482c2de5c91Smalc
1483c2de5c91Smalc    fmod)
1484c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1485c2de5c91Smalc        echo
1486c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1487c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1488c2de5c91Smalc        echo
1489c2de5c91Smalc        exit 1
14908f28f3fbSths    fi
1491c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1492a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1493c2de5c91Smalc    ;;
1494c2de5c91Smalc
1495c2de5c91Smalc    esd)
1496c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1497a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
149867f86e8eSJuan Quintela    audio_pt_int="yes"
1499c2de5c91Smalc    ;;
1500b8e59f18Smalc
1501b8e59f18Smalc    pa)
1502493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1503b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1504493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
150567f86e8eSJuan Quintela    audio_pt_int="yes"
1506b8e59f18Smalc    ;;
1507b8e59f18Smalc
1508997e690aSJuan Quintela    coreaudio)
1509997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1510997e690aSJuan Quintela    ;;
1511997e690aSJuan Quintela
1512a4bf6780SJuan Quintela    dsound)
1513a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1514d5631638Smalc      audio_win_int="yes"
1515a4bf6780SJuan Quintela    ;;
1516a4bf6780SJuan Quintela
1517a4bf6780SJuan Quintela    oss)
1518a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1519a4bf6780SJuan Quintela    ;;
1520a4bf6780SJuan Quintela
1521a4bf6780SJuan Quintela    sdl|wav)
15222f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
15232f6a1ab0Sblueswir1    ;;
15242f6a1ab0Sblueswir1
1525d5631638Smalc    winwave)
1526d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1527d5631638Smalc      audio_win_int="yes"
1528d5631638Smalc    ;;
1529d5631638Smalc
1530e4c63a6aSmalc    *)
15311c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1532e4c63a6aSmalc        echo
1533e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1534e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1535e4c63a6aSmalc        echo
1536e4c63a6aSmalc        exit 1
1537e4c63a6aSmalc    }
1538e4c63a6aSmalc    ;;
1539c2de5c91Smalc    esac
1540c2de5c91Smalcdone
15418f28f3fbSths
15424d3b6f6eSbalrog##########################################
15432e4d9fb1Saurel32# BrlAPI probe
15442e4d9fb1Saurel32
15454ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1546eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
15472e4d9fb1Saurel32  cat > $TMPC << EOF
15482e4d9fb1Saurel32#include <brlapi.h>
1549832ce9c2SScott Wood#include <stddef.h>
15502e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
15512e4d9fb1Saurel32EOF
155252166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
15532e4d9fb1Saurel32    brlapi=yes
1554264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
15554ffcedb6SJuan Quintela  else
15564ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
15574ffcedb6SJuan Quintela      feature_not_found "brlapi"
15584ffcedb6SJuan Quintela    fi
15594ffcedb6SJuan Quintela    brlapi=no
1560eb82284fSJuan Quintela  fi
1561eb82284fSJuan Quintelafi
15622e4d9fb1Saurel32
15632e4d9fb1Saurel32##########################################
15644d3b6f6eSbalrog# curses probe
1565e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
1566e095e2f3SStefan Weil    curses_list="-lpdcurses"
1567e095e2f3SStefan Weilelse
15684f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
1569e095e2f3SStefan Weilfi
15704d3b6f6eSbalrog
1571c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1572c584a6d0SJuan Quintela  curses_found=no
15734d3b6f6eSbalrog  cat > $TMPC << EOF
15744d3b6f6eSbalrog#include <curses.h>
15755a8ff3aaSblueswir1#ifdef __OpenBSD__
15765a8ff3aaSblueswir1#define resize_term resizeterm
15775a8ff3aaSblueswir1#endif
15785a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
15794d3b6f6eSbalrogEOF
15804f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
15814f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1582c584a6d0SJuan Quintela      curses_found=yes
15834f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
15844f78ef9aSJuan Quintela      break
15854d3b6f6eSbalrog    fi
15864f78ef9aSJuan Quintela  done
1587c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1588c584a6d0SJuan Quintela    curses=yes
1589c584a6d0SJuan Quintela  else
1590c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1591c584a6d0SJuan Quintela      feature_not_found "curses"
1592c584a6d0SJuan Quintela    fi
1593c584a6d0SJuan Quintela    curses=no
1594c584a6d0SJuan Quintela  fi
15954f78ef9aSJuan Quintelafi
15964d3b6f6eSbalrog
1597414f0dabSblueswir1##########################################
1598769ce76dSAlexander Graf# curl probe
1599769ce76dSAlexander Graf
1600a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
1601a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
16024e2b0658SPaolo Bonzinielse
16034e2b0658SPaolo Bonzini  curlconfig=curl-config
16044e2b0658SPaolo Bonzinifi
16054e2b0658SPaolo Bonzini
1606788c8196SJuan Quintelaif test "$curl" != "no" ; then
1607769ce76dSAlexander Graf  cat > $TMPC << EOF
1608769ce76dSAlexander Graf#include <curl/curl.h>
1609769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1610769ce76dSAlexander GrafEOF
16114e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
16124e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1613b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1614769ce76dSAlexander Graf    curl=yes
1615f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1616f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1617788c8196SJuan Quintela  else
1618788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1619788c8196SJuan Quintela      feature_not_found "curl"
1620788c8196SJuan Quintela    fi
1621788c8196SJuan Quintela    curl=no
1622769ce76dSAlexander Graf  fi
1623769ce76dSAlexander Graffi # test "$curl"
1624769ce76dSAlexander Graf
1625769ce76dSAlexander Graf##########################################
16265495ed11SLuiz Capitulino# check framework probe
16275495ed11SLuiz Capitulino
16285495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
16295495ed11SLuiz Capitulino  cat > $TMPC << EOF
16305495ed11SLuiz Capitulino#include <check.h>
16315495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
16325495ed11SLuiz CapitulinoEOF
1633a8bd70adSPaolo Bonzini  check_libs=`$pkg_config --libs check`
16345495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
16355495ed11SLuiz Capitulino    check_utests=yes
16365495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
16375495ed11SLuiz Capitulino  else
16385495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
16395495ed11SLuiz Capitulino      feature_not_found "check"
16405495ed11SLuiz Capitulino    fi
16415495ed11SLuiz Capitulino    check_utests=no
16425495ed11SLuiz Capitulino  fi
16435495ed11SLuiz Capitulinofi # test "$check_utests"
16445495ed11SLuiz Capitulino
16455495ed11SLuiz Capitulino##########################################
1646fb599c9aSbalrog# bluez support probe
1647a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1648e820e3f4Sbalrog  cat > $TMPC << EOF
1649e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1650e820e3f4Sbalrogint main(void) { return bt_error(0); }
1651e820e3f4SbalrogEOF
1652a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1653a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
165452166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1655a20a6f46SJuan Quintela    bluez=yes
1656e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1657e820e3f4Sbalrog  else
1658a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1659a20a6f46SJuan Quintela      feature_not_found "bluez"
1660a20a6f46SJuan Quintela    fi
1661e820e3f4Sbalrog    bluez="no"
1662e820e3f4Sbalrog  fi
1663fb599c9aSbalrogfi
1664fb599c9aSbalrog
1665fb599c9aSbalrog##########################################
16667ba1e619Saliguori# kvm probe
1667b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
16687ba1e619Saliguori    cat > $TMPC <<EOF
16697ba1e619Saliguori#include <linux/kvm.h>
16709fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
16717ba1e619Saliguori#error Invalid KVM version
16727ba1e619Saliguori#endif
167394a8d39aSJan KiszkaEOF
167494a8d39aSJan Kiszka    must_have_caps="KVM_CAP_USER_MEMORY \
167594a8d39aSJan Kiszka                    KVM_CAP_DESTROY_MEMORY_REGION_WORKS \
167694a8d39aSJan Kiszka                    KVM_CAP_COALESCED_MMIO \
167794a8d39aSJan Kiszka                    KVM_CAP_SYNC_MMU \
167894a8d39aSJan Kiszka                   "
167994a8d39aSJan Kiszka    if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) ; then
168094a8d39aSJan Kiszka      must_have_caps="$caps \
168194a8d39aSJan Kiszka                      KVM_CAP_SET_TSS_ADDR \
168294a8d39aSJan Kiszka                      KVM_CAP_EXT_CPUID \
168394a8d39aSJan Kiszka                      KVM_CAP_CLOCKSOURCE \
168494a8d39aSJan Kiszka                      KVM_CAP_NOP_IO_DELAY \
168594a8d39aSJan Kiszka                      KVM_CAP_PV_MMU \
168694a8d39aSJan Kiszka                      KVM_CAP_MP_STATE \
168794a8d39aSJan Kiszka                      KVM_CAP_USER_NMI \
168894a8d39aSJan Kiszka                     "
168994a8d39aSJan Kiszka    fi
169094a8d39aSJan Kiszka    for c in $must_have_caps ; do
169194a8d39aSJan Kiszka      cat >> $TMPC <<EOF
169294a8d39aSJan Kiszka#if !defined($c)
169394a8d39aSJan Kiszka#error Missing KVM capability $c
16949fd8d8d7Saliguori#endif
169594a8d39aSJan KiszkaEOF
169694a8d39aSJan Kiszka    done
169794a8d39aSJan Kiszka    cat >> $TMPC <<EOF
16987ba1e619Saliguoriint main(void) { return 0; }
16997ba1e619SaliguoriEOF
1700eac30262Saliguori  if test "$kerneldir" != "" ; then
1701eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
17028444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
17038444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
17048444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1705406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1706406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
17070e60a699SAlexander Graf	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
17080e60a699SAlexander Graf	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
17098444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
17108444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
17118444eb6eSaliguori      fi
1712eac30262Saliguori  else
1713a8bd70adSPaolo Bonzini    kvm_cflags=`$pkg_config --cflags kvm-kmod 2>/dev/null`
1714eac30262Saliguori  fi
171552166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1716b31a0277SJuan Quintela    kvm=yes
1717dae5079aSJan Kiszka    cat > $TMPC <<EOF
1718dae5079aSJan Kiszka#include <linux/kvm_para.h>
1719dae5079aSJan Kiszkaint main(void) { return 0; }
1720dae5079aSJan KiszkaEOF
1721dae5079aSJan Kiszka    if compile_prog "$kvm_cflags" "" ; then
1722dae5079aSJan Kiszka      kvm_para=yes
1723dae5079aSJan Kiszka    fi
17247ba1e619Saliguori  else
1725b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
17260dba6195SLoïc Minier      if has awk && has grep; then
1727a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
17289fd8d8d7Saliguori	| grep "error: " \
17299fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
17309fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1731b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1732168ccc11SJan KiszkaNOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1733168ccc11SJan Kiszkarecent kvm-kmod from http://sourceforge.net/projects/kvm."
17349fd8d8d7Saliguori        fi
17359fd8d8d7Saliguori      fi
1736b31a0277SJuan Quintela      feature_not_found "kvm"
1737b31a0277SJuan Quintela    fi
1738b31a0277SJuan Quintela    kvm=no
17397ba1e619Saliguori  fi
17407ba1e619Saliguorifi
17417ba1e619Saliguori
17427ba1e619Saliguori##########################################
1743d5970055SMichael S. Tsirkin# test for vhost net
1744d5970055SMichael S. Tsirkin
1745d5970055SMichael S. Tsirkinif test "$vhost_net" != "no"; then
1746d5970055SMichael S. Tsirkin    if test "$kvm" != "no"; then
1747d5970055SMichael S. Tsirkin            cat > $TMPC <<EOF
1748d5970055SMichael S. Tsirkin    #include <linux/vhost.h>
1749d5970055SMichael S. Tsirkin    int main(void) { return 0; }
1750d5970055SMichael S. TsirkinEOF
1751d5970055SMichael S. Tsirkin            if compile_prog "$kvm_cflags" "" ; then
1752d5970055SMichael S. Tsirkin                vhost_net=yes
1753d5970055SMichael S. Tsirkin            else
1754d5970055SMichael S. Tsirkin                if test "$vhost_net" = "yes" ; then
1755d5970055SMichael S. Tsirkin                    feature_not_found "vhost-net"
1756d5970055SMichael S. Tsirkin                fi
1757d5970055SMichael S. Tsirkin                vhost_net=no
1758d5970055SMichael S. Tsirkin            fi
1759d5970055SMichael S. Tsirkin    else
1760d5970055SMichael S. Tsirkin            if test "$vhost_net" = "yes" ; then
17614021d247SAurelien Jarno                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1762d5970055SMichael S. Tsirkin                feature_not_found "vhost-net"
1763d5970055SMichael S. Tsirkin            fi
1764d5970055SMichael S. Tsirkin            vhost_net=no
1765d5970055SMichael S. Tsirkin    fi
1766d5970055SMichael S. Tsirkinfi
1767d5970055SMichael S. Tsirkin
1768d5970055SMichael S. Tsirkin##########################################
1769e5d355d1Saliguori# pthread probe
1770de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
17713c529d93Saliguori
1772e5d355d1Saliguoripthread=no
1773414f0dabSblueswir1cat > $TMPC << EOF
17743c529d93Saliguori#include <pthread.h>
1775de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1776414f0dabSblueswir1EOF
1777bd00d539SAndreas Färberif compile_prog "" "" ; then
1778bd00d539SAndreas Färber  pthread=yes
1779bd00d539SAndreas Färberelse
1780de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
178152166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
1782e5d355d1Saliguori      pthread=yes
17835572b539SJuan Quintela      LIBS="$pthread_lib $LIBS"
1784de65fe0fSSebastian Herbszt      break
1785414f0dabSblueswir1    fi
1786de65fe0fSSebastian Herbszt  done
1787bd00d539SAndreas Färberfi
1788414f0dabSblueswir1
17894617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
17904dd75c70SChristoph Hellwig  echo
17914dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
17924dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
17934dd75c70SChristoph Hellwig  echo
17944dd75c70SChristoph Hellwig  exit 1
1795e5d355d1Saliguorifi
1796e5d355d1Saliguori
1797bf9298b9Saliguori##########################################
1798f27aaf4bSChristian Brunner# rbd probe
1799f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
1800f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
1801f27aaf4bSChristian Brunner#include <stdio.h>
1802f27aaf4bSChristian Brunner#include <rados/librados.h>
1803f27aaf4bSChristian Brunnerint main(void) { rados_initialize(0, NULL); return 0; }
1804f27aaf4bSChristian BrunnerEOF
1805cc4e8741SAurelien Jarno  rbd_libs="-lrados"
1806f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
1807f27aaf4bSChristian Brunner    librados_too_old=no
1808f27aaf4bSChristian Brunner    cat > $TMPC <<EOF
1809f27aaf4bSChristian Brunner#include <stdio.h>
1810f27aaf4bSChristian Brunner#include <rados/librados.h>
1811f27aaf4bSChristian Brunner#ifndef CEPH_OSD_TMAP_SET
1812f27aaf4bSChristian Brunner#error missing CEPH_OSD_TMAP_SET
1813f27aaf4bSChristian Brunner#endif
1814f27aaf4bSChristian Brunnerint main(void) {
1815f27aaf4bSChristian Brunner    int (*func)(const rados_pool_t pool, uint64_t *snapid) = rados_selfmanaged_snap_create;
1816f27aaf4bSChristian Brunner    rados_initialize(0, NULL);
1817f27aaf4bSChristian Brunner    return 0;
1818f27aaf4bSChristian Brunner}
1819f27aaf4bSChristian BrunnerEOF
1820f27aaf4bSChristian Brunner    if compile_prog "" "$rbd_libs" ; then
1821f27aaf4bSChristian Brunner      rbd=yes
1822f27aaf4bSChristian Brunner      libs_tools="$rbd_libs $libs_tools"
1823f27aaf4bSChristian Brunner      libs_softmmu="$rbd_libs $libs_softmmu"
1824f27aaf4bSChristian Brunner    else
1825f27aaf4bSChristian Brunner      rbd=no
1826f27aaf4bSChristian Brunner      librados_too_old=yes
1827f27aaf4bSChristian Brunner    fi
1828f27aaf4bSChristian Brunner  else
1829f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
1830f27aaf4bSChristian Brunner      feature_not_found "rados block device"
1831f27aaf4bSChristian Brunner    fi
1832f27aaf4bSChristian Brunner    rbd=no
1833f27aaf4bSChristian Brunner  fi
1834f27aaf4bSChristian Brunner  if test "$librados_too_old" = "yes" ; then
1835f27aaf4bSChristian Brunner    echo "-> Your librados version is too old - upgrade needed to have rbd support"
1836f27aaf4bSChristian Brunner  fi
1837f27aaf4bSChristian Brunnerfi
1838f27aaf4bSChristian Brunner
1839f27aaf4bSChristian Brunner##########################################
18405c6c3a6cSChristoph Hellwig# linux-aio probe
18415c6c3a6cSChristoph Hellwig
18425c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
18435c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
18445c6c3a6cSChristoph Hellwig#include <libaio.h>
18455c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
1846832ce9c2SScott Wood#include <stddef.h>
18475c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
18485c6c3a6cSChristoph HellwigEOF
18495c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
18505c6c3a6cSChristoph Hellwig    linux_aio=yes
1851048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1852048d179fSPaul Brook    libs_tools="$libs_tools -laio"
18535c6c3a6cSChristoph Hellwig  else
18545c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
18555c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
18565c6c3a6cSChristoph Hellwig    fi
18573cfcae3cSLuiz Capitulino    linux_aio=no
18585c6c3a6cSChristoph Hellwig  fi
18595c6c3a6cSChristoph Hellwigfi
18605c6c3a6cSChristoph Hellwig
18615c6c3a6cSChristoph Hellwig##########################################
1862758e8e38SVenkateswararao Jujjuri (JV)# attr probe
1863758e8e38SVenkateswararao Jujjuri (JV)
1864758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
1865758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
1866758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
1867758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
1868758e8e38SVenkateswararao Jujjuri (JV)#include <attr/xattr.h>
1869758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1870758e8e38SVenkateswararao Jujjuri (JV)EOF
1871758e8e38SVenkateswararao Jujjuri (JV)  if compile_prog "" "-lattr" ; then
1872758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
1873758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
1874758e8e38SVenkateswararao Jujjuri (JV)  else
1875758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
1876758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
1877758e8e38SVenkateswararao Jujjuri (JV)    fi
1878758e8e38SVenkateswararao Jujjuri (JV)    attr=no
1879758e8e38SVenkateswararao Jujjuri (JV)  fi
1880758e8e38SVenkateswararao Jujjuri (JV)fi
1881758e8e38SVenkateswararao Jujjuri (JV)
1882758e8e38SVenkateswararao Jujjuri (JV)##########################################
1883bf9298b9Saliguori# iovec probe
1884bf9298b9Saliguoricat > $TMPC <<EOF
1885db34f0b3Sblueswir1#include <sys/types.h>
1886bf9298b9Saliguori#include <sys/uio.h>
1887db34f0b3Sblueswir1#include <unistd.h>
1888bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1889bf9298b9SaliguoriEOF
1890bf9298b9Saliguoriiovec=no
189152166aa0SJuan Quintelaif compile_prog "" "" ; then
1892bf9298b9Saliguori  iovec=yes
1893bf9298b9Saliguorifi
1894bf9298b9Saliguori
1895f652e6afSaurel32##########################################
1896ceb42de8Saliguori# preadv probe
1897ceb42de8Saliguoricat > $TMPC <<EOF
1898ceb42de8Saliguori#include <sys/types.h>
1899ceb42de8Saliguori#include <sys/uio.h>
1900ceb42de8Saliguori#include <unistd.h>
1901ceb42de8Saliguoriint main(void) { preadv; }
1902ceb42de8SaliguoriEOF
1903ceb42de8Saliguoripreadv=no
190452166aa0SJuan Quintelaif compile_prog "" "" ; then
1905ceb42de8Saliguori  preadv=yes
1906ceb42de8Saliguorifi
1907ceb42de8Saliguori
1908ceb42de8Saliguori##########################################
1909f652e6afSaurel32# fdt probe
19102df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1911b41af4baSJuan Quintela  fdt_libs="-lfdt"
1912f652e6afSaurel32  cat > $TMPC << EOF
1913f652e6afSaurel32int main(void) { return 0; }
1914f652e6afSaurel32EOF
191552166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1916f652e6afSaurel32    fdt=yes
1917e4782985SJuan Quintela    libs_softmmu="$fdt_libs $libs_softmmu"
19182df87df7SJuan Quintela  else
19192df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
19202df87df7SJuan Quintela      feature_not_found "fdt"
19212df87df7SJuan Quintela    fi
19222df87df7SJuan Quintela    fdt=no
1923f652e6afSaurel32  fi
1924f652e6afSaurel32fi
1925f652e6afSaurel32
19263b3f24adSaurel32#
19273b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
19283b3f24adSaurel32# emulator.  This is done because older glibc versions don't
19293b3f24adSaurel32# have syscall stubs for these implemented.
19303b3f24adSaurel32#
19313b3f24adSaurel32atfile=no
19323b3f24adSaurel32cat > $TMPC << EOF
19333b3f24adSaurel32#define _ATFILE_SOURCE
19343b3f24adSaurel32#include <sys/types.h>
19353b3f24adSaurel32#include <fcntl.h>
19363b3f24adSaurel32#include <unistd.h>
19373b3f24adSaurel32
19383b3f24adSaurel32int
19393b3f24adSaurel32main(void)
19403b3f24adSaurel32{
19413b3f24adSaurel32	/* try to unlink nonexisting file */
19423b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
19433b3f24adSaurel32}
19443b3f24adSaurel32EOF
194552166aa0SJuan Quintelaif compile_prog "" "" ; then
19463b3f24adSaurel32  atfile=yes
19473b3f24adSaurel32fi
19483b3f24adSaurel32
194939386ac7Saurel32# Check for inotify functions when we are building linux-user
19503b3f24adSaurel32# emulator.  This is done because older glibc versions don't
19513b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
19523b3f24adSaurel32# don't provide them even if kernel supports them.
19533b3f24adSaurel32#
19543b3f24adSaurel32inotify=no
19553b3f24adSaurel32cat > $TMPC << EOF
19563b3f24adSaurel32#include <sys/inotify.h>
19573b3f24adSaurel32
19583b3f24adSaurel32int
19593b3f24adSaurel32main(void)
19603b3f24adSaurel32{
19613b3f24adSaurel32	/* try to start inotify */
19628690e420Saurel32	return inotify_init();
19633b3f24adSaurel32}
19643b3f24adSaurel32EOF
196552166aa0SJuan Quintelaif compile_prog "" "" ; then
19663b3f24adSaurel32  inotify=yes
19673b3f24adSaurel32fi
19683b3f24adSaurel32
1969c05c7a73SRiku Voipioinotify1=no
1970c05c7a73SRiku Voipiocat > $TMPC << EOF
1971c05c7a73SRiku Voipio#include <sys/inotify.h>
1972c05c7a73SRiku Voipio
1973c05c7a73SRiku Voipioint
1974c05c7a73SRiku Voipiomain(void)
1975c05c7a73SRiku Voipio{
1976c05c7a73SRiku Voipio    /* try to start inotify */
1977c05c7a73SRiku Voipio    return inotify_init1(0);
1978c05c7a73SRiku Voipio}
1979c05c7a73SRiku VoipioEOF
1980c05c7a73SRiku Voipioif compile_prog "" "" ; then
1981c05c7a73SRiku Voipio  inotify1=yes
1982c05c7a73SRiku Voipiofi
1983c05c7a73SRiku Voipio
1984ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1985ebc996f3SRiku Voipioutimens=no
1986ebc996f3SRiku Voipiocat > $TMPC << EOF
1987ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1988ebc996f3SRiku Voipio#include <stddef.h>
1989ebc996f3SRiku Voipio#include <fcntl.h>
1990ebc996f3SRiku Voipio
1991ebc996f3SRiku Voipioint main(void)
1992ebc996f3SRiku Voipio{
1993ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1994ebc996f3SRiku Voipio    futimens(0, NULL);
1995ebc996f3SRiku Voipio    return 0;
1996ebc996f3SRiku Voipio}
1997ebc996f3SRiku VoipioEOF
199852166aa0SJuan Quintelaif compile_prog "" "" ; then
1999ebc996f3SRiku Voipio  utimens=yes
2000ebc996f3SRiku Voipiofi
2001ebc996f3SRiku Voipio
2002099d6b0fSRiku Voipio# check if pipe2 is there
2003099d6b0fSRiku Voipiopipe2=no
2004099d6b0fSRiku Voipiocat > $TMPC << EOF
2005099d6b0fSRiku Voipio#include <unistd.h>
2006099d6b0fSRiku Voipio#include <fcntl.h>
2007099d6b0fSRiku Voipio
2008099d6b0fSRiku Voipioint main(void)
2009099d6b0fSRiku Voipio{
2010099d6b0fSRiku Voipio    int pipefd[2];
2011099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2012099d6b0fSRiku Voipio    return 0;
2013099d6b0fSRiku Voipio}
2014099d6b0fSRiku VoipioEOF
201552166aa0SJuan Quintelaif compile_prog "" "" ; then
2016099d6b0fSRiku Voipio  pipe2=yes
2017099d6b0fSRiku Voipiofi
2018099d6b0fSRiku Voipio
201940ff6d7eSKevin Wolf# check if accept4 is there
202040ff6d7eSKevin Wolfaccept4=no
202140ff6d7eSKevin Wolfcat > $TMPC << EOF
202240ff6d7eSKevin Wolf#include <sys/socket.h>
202340ff6d7eSKevin Wolf#include <stddef.h>
202440ff6d7eSKevin Wolf
202540ff6d7eSKevin Wolfint main(void)
202640ff6d7eSKevin Wolf{
202740ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
202840ff6d7eSKevin Wolf    return 0;
202940ff6d7eSKevin Wolf}
203040ff6d7eSKevin WolfEOF
203140ff6d7eSKevin Wolfif compile_prog "" "" ; then
203240ff6d7eSKevin Wolf  accept4=yes
203340ff6d7eSKevin Wolffi
203440ff6d7eSKevin Wolf
20353ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
20363ce34dfbSvibisreenivasansplice=no
20373ce34dfbSvibisreenivasancat > $TMPC << EOF
20383ce34dfbSvibisreenivasan#include <unistd.h>
20393ce34dfbSvibisreenivasan#include <fcntl.h>
20403ce34dfbSvibisreenivasan#include <limits.h>
20413ce34dfbSvibisreenivasan
20423ce34dfbSvibisreenivasanint main(void)
20433ce34dfbSvibisreenivasan{
20443ce34dfbSvibisreenivasan    int len, fd;
20453ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
20463ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
20473ce34dfbSvibisreenivasan    return 0;
20483ce34dfbSvibisreenivasan}
20493ce34dfbSvibisreenivasanEOF
205052166aa0SJuan Quintelaif compile_prog "" "" ; then
20513ce34dfbSvibisreenivasan  splice=yes
20523ce34dfbSvibisreenivasanfi
20533ce34dfbSvibisreenivasan
2054dcc38d1cSMarcelo Tosatti##########################################
2055dcc38d1cSMarcelo Tosatti# signalfd probe
2056dcc38d1cSMarcelo Tosattisignalfd="no"
2057dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2058dcc38d1cSMarcelo Tosatti#define _GNU_SOURCE
2059dcc38d1cSMarcelo Tosatti#include <unistd.h>
2060dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2061dcc38d1cSMarcelo Tosatti#include <signal.h>
2062dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2063dcc38d1cSMarcelo TosattiEOF
2064dcc38d1cSMarcelo Tosatti
2065dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2066dcc38d1cSMarcelo Tosatti  signalfd=yes
2067de758970SJan Kiszkaelif test "$kvm" = "yes" -a "$io_thread" != "yes"; then
2068de758970SJan Kiszka  echo
2069de758970SJan Kiszka  echo "ERROR: Host kernel lacks signalfd() support,"
2070de758970SJan Kiszka  echo "but KVM depends on it when the IO thread is disabled."
2071de758970SJan Kiszka  echo
2072de758970SJan Kiszka  exit 1
2073dcc38d1cSMarcelo Tosattifi
2074dcc38d1cSMarcelo Tosatti
2075c2882b96SRiku Voipio# check if eventfd is supported
2076c2882b96SRiku Voipioeventfd=no
2077c2882b96SRiku Voipiocat > $TMPC << EOF
2078c2882b96SRiku Voipio#include <sys/eventfd.h>
2079c2882b96SRiku Voipio
2080c2882b96SRiku Voipioint main(void)
2081c2882b96SRiku Voipio{
2082c2882b96SRiku Voipio    int efd = eventfd(0, 0);
2083c2882b96SRiku Voipio    return 0;
2084c2882b96SRiku Voipio}
2085c2882b96SRiku VoipioEOF
2086c2882b96SRiku Voipioif compile_prog "" "" ; then
2087c2882b96SRiku Voipio  eventfd=yes
2088c2882b96SRiku Voipiofi
2089c2882b96SRiku Voipio
2090d0927938SUlrich Hecht# check for fallocate
2091d0927938SUlrich Hechtfallocate=no
2092d0927938SUlrich Hechtcat > $TMPC << EOF
2093d0927938SUlrich Hecht#include <fcntl.h>
2094d0927938SUlrich Hecht
2095d0927938SUlrich Hechtint main(void)
2096d0927938SUlrich Hecht{
2097d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2098d0927938SUlrich Hecht    return 0;
2099d0927938SUlrich Hecht}
2100d0927938SUlrich HechtEOF
2101be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
2102d0927938SUlrich Hecht  fallocate=yes
2103d0927938SUlrich Hechtfi
2104d0927938SUlrich Hecht
2105c727f47dSPeter Maydell# check for sync_file_range
2106c727f47dSPeter Maydellsync_file_range=no
2107c727f47dSPeter Maydellcat > $TMPC << EOF
2108c727f47dSPeter Maydell#include <fcntl.h>
2109c727f47dSPeter Maydell
2110c727f47dSPeter Maydellint main(void)
2111c727f47dSPeter Maydell{
2112c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2113c727f47dSPeter Maydell    return 0;
2114c727f47dSPeter Maydell}
2115c727f47dSPeter MaydellEOF
2116c727f47dSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2117c727f47dSPeter Maydell  sync_file_range=yes
2118c727f47dSPeter Maydellfi
2119c727f47dSPeter Maydell
2120dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2121dace20dcSPeter Maydellfiemap=no
2122dace20dcSPeter Maydellcat > $TMPC << EOF
2123dace20dcSPeter Maydell#include <sys/ioctl.h>
2124dace20dcSPeter Maydell#include <linux/fs.h>
2125dace20dcSPeter Maydell#include <linux/fiemap.h>
2126dace20dcSPeter Maydell
2127dace20dcSPeter Maydellint main(void)
2128dace20dcSPeter Maydell{
2129dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2130dace20dcSPeter Maydell    return 0;
2131dace20dcSPeter Maydell}
2132dace20dcSPeter MaydellEOF
2133dace20dcSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2134dace20dcSPeter Maydell  fiemap=yes
2135dace20dcSPeter Maydellfi
2136dace20dcSPeter Maydell
2137d0927938SUlrich Hecht# check for dup3
2138d0927938SUlrich Hechtdup3=no
2139d0927938SUlrich Hechtcat > $TMPC << EOF
2140d0927938SUlrich Hecht#include <unistd.h>
2141d0927938SUlrich Hecht
2142d0927938SUlrich Hechtint main(void)
2143d0927938SUlrich Hecht{
2144d0927938SUlrich Hecht    dup3(0, 0, 0);
2145d0927938SUlrich Hecht    return 0;
2146d0927938SUlrich Hecht}
2147d0927938SUlrich HechtEOF
214878f5d726SJan Kiszkaif compile_prog "" "" ; then
2149d0927938SUlrich Hecht  dup3=yes
2150d0927938SUlrich Hechtfi
2151d0927938SUlrich Hecht
21523b6edd16SPeter Maydell# check for epoll support
21533b6edd16SPeter Maydellepoll=no
21543b6edd16SPeter Maydellcat > $TMPC << EOF
21553b6edd16SPeter Maydell#include <sys/epoll.h>
21563b6edd16SPeter Maydell
21573b6edd16SPeter Maydellint main(void)
21583b6edd16SPeter Maydell{
21593b6edd16SPeter Maydell    epoll_create(0);
21603b6edd16SPeter Maydell    return 0;
21613b6edd16SPeter Maydell}
21623b6edd16SPeter MaydellEOF
21633b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
21643b6edd16SPeter Maydell  epoll=yes
21653b6edd16SPeter Maydellfi
21663b6edd16SPeter Maydell
21673b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
21683b6edd16SPeter Maydell# so we must check separately for their presence
21693b6edd16SPeter Maydellepoll_create1=no
21703b6edd16SPeter Maydellcat > $TMPC << EOF
21713b6edd16SPeter Maydell#include <sys/epoll.h>
21723b6edd16SPeter Maydell
21733b6edd16SPeter Maydellint main(void)
21743b6edd16SPeter Maydell{
21753b6edd16SPeter Maydell    epoll_create1(0);
21763b6edd16SPeter Maydell    return 0;
21773b6edd16SPeter Maydell}
21783b6edd16SPeter MaydellEOF
21793b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
21803b6edd16SPeter Maydell  epoll_create1=yes
21813b6edd16SPeter Maydellfi
21823b6edd16SPeter Maydell
21833b6edd16SPeter Maydellepoll_pwait=no
21843b6edd16SPeter Maydellcat > $TMPC << EOF
21853b6edd16SPeter Maydell#include <sys/epoll.h>
21863b6edd16SPeter Maydell
21873b6edd16SPeter Maydellint main(void)
21883b6edd16SPeter Maydell{
21893b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
21903b6edd16SPeter Maydell    return 0;
21913b6edd16SPeter Maydell}
21923b6edd16SPeter MaydellEOF
21933b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
21943b6edd16SPeter Maydell  epoll_pwait=yes
21953b6edd16SPeter Maydellfi
21963b6edd16SPeter Maydell
2197cc8ae6deSpbrook# Check if tools are available to build documentation.
2198a25dba17SJuan Quintelaif test "$docs" != "no" ; then
219901668d98SStefan Weil  if has makeinfo && has pod2man; then
2200a25dba17SJuan Quintela    docs=yes
220183a3ab8bSJuan Quintela  else
2202a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2203a25dba17SJuan Quintela      feature_not_found "docs"
220483a3ab8bSJuan Quintela    fi
2205a25dba17SJuan Quintela    docs=no
220683a3ab8bSJuan Quintela  fi
2207cc8ae6deSpbrookfi
2208cc8ae6deSpbrook
2209f514f41cSStefan Weil# Search for bswap_32 function
22106ae9a1f4SJuan Quintelabyteswap_h=no
22116ae9a1f4SJuan Quintelacat > $TMPC << EOF
22126ae9a1f4SJuan Quintela#include <byteswap.h>
22136ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
22146ae9a1f4SJuan QuintelaEOF
221552166aa0SJuan Quintelaif compile_prog "" "" ; then
22166ae9a1f4SJuan Quintela  byteswap_h=yes
22176ae9a1f4SJuan Quintelafi
22186ae9a1f4SJuan Quintela
2219f514f41cSStefan Weil# Search for bswap_32 function
22206ae9a1f4SJuan Quintelabswap_h=no
22216ae9a1f4SJuan Quintelacat > $TMPC << EOF
22226ae9a1f4SJuan Quintela#include <sys/endian.h>
22236ae9a1f4SJuan Quintela#include <sys/types.h>
22246ae9a1f4SJuan Quintela#include <machine/bswap.h>
22256ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
22266ae9a1f4SJuan QuintelaEOF
222752166aa0SJuan Quintelaif compile_prog "" "" ; then
22286ae9a1f4SJuan Quintela  bswap_h=yes
22296ae9a1f4SJuan Quintelafi
22306ae9a1f4SJuan Quintela
2231da93a1fdSaliguori##########################################
2232da93a1fdSaliguori# Do we need librt
2233da93a1fdSaliguoricat > $TMPC <<EOF
2234da93a1fdSaliguori#include <signal.h>
2235da93a1fdSaliguori#include <time.h>
2236da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
2237da93a1fdSaliguoriEOF
2238da93a1fdSaliguori
223952166aa0SJuan Quintelaif compile_prog "" "" ; then
224007ffa4bdSJuan Quintela  :
224152166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
224207ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2243da93a1fdSaliguorifi
2244da93a1fdSaliguori
224531ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2246179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
22476362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
22486362a53fSJuan Quintelafi
22496362a53fSJuan Quintela
2250de5071c5SBlue Swirl##########################################
2251de5071c5SBlue Swirl# check if the compiler defines offsetof
2252de5071c5SBlue Swirl
2253de5071c5SBlue Swirlneed_offsetof=yes
2254de5071c5SBlue Swirlcat > $TMPC << EOF
2255de5071c5SBlue Swirl#include <stddef.h>
2256de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
2257de5071c5SBlue SwirlEOF
2258de5071c5SBlue Swirlif compile_prog "" "" ; then
2259de5071c5SBlue Swirl    need_offsetof=no
2260de5071c5SBlue Swirlfi
2261de5071c5SBlue Swirl
22625f6b9e8fSBlue Swirl##########################################
2263747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
2264747bbdf7SBlue Swirl#
2265747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
2266747bbdf7SBlue Swirl# about attribute warn_unused_result
2267747bbdf7SBlue Swirl
2268747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
2269747bbdf7SBlue Swirlcat > $TMPC << EOF
2270747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2271747bbdf7SBlue Swirl#error gcc 3.3 or older
2272747bbdf7SBlue Swirl#endif
2273747bbdf7SBlue Swirlint main(void) { return 0;}
2274747bbdf7SBlue SwirlEOF
2275747bbdf7SBlue Swirlif compile_prog "" ""; then
2276747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
2277747bbdf7SBlue Swirlfi
2278747bbdf7SBlue Swirl
2279cd4ec0b4SGerd Hoffmann# spice probe
2280cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2281cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2282cd4ec0b4SGerd Hoffmann#include <spice.h>
2283cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2284cd4ec0b4SGerd HoffmannEOF
2285710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2286710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2287710fc4f5SJiri Denemark  if $pkg_config --atleast-version=0.5.3 spice-server >/dev/null 2>&1 && \
2288cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2289cd4ec0b4SGerd Hoffmann    spice="yes"
2290cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2291cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2292cd4ec0b4SGerd Hoffmann  else
2293cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2294cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2295cd4ec0b4SGerd Hoffmann    fi
2296cd4ec0b4SGerd Hoffmann    spice="no"
2297cd4ec0b4SGerd Hoffmann  fi
2298cd4ec0b4SGerd Hoffmannfi
2299cd4ec0b4SGerd Hoffmann
2300cd4ec0b4SGerd Hoffmann##########################################
2301cd4ec0b4SGerd Hoffmann
2302747bbdf7SBlue Swirl##########################################
23035f6b9e8fSBlue Swirl# check if we have fdatasync
23045f6b9e8fSBlue Swirl
23055f6b9e8fSBlue Swirlfdatasync=no
23065f6b9e8fSBlue Swirlcat > $TMPC << EOF
23075f6b9e8fSBlue Swirl#include <unistd.h>
23085f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
23095f6b9e8fSBlue SwirlEOF
23105f6b9e8fSBlue Swirlif compile_prog "" "" ; then
23115f6b9e8fSBlue Swirl    fdatasync=yes
23125f6b9e8fSBlue Swirlfi
23135f6b9e8fSBlue Swirl
231494a420b1SStefan Hajnoczi##########################################
2315e78815a5SAndreas Färber# check if we have madvise
2316e78815a5SAndreas Färber
2317e78815a5SAndreas Färbermadvise=no
2318e78815a5SAndreas Färbercat > $TMPC << EOF
2319e78815a5SAndreas Färber#include <sys/types.h>
2320e78815a5SAndreas Färber#include <sys/mman.h>
2321832ce9c2SScott Wood#include <stddef.h>
2322e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2323e78815a5SAndreas FärberEOF
2324e78815a5SAndreas Färberif compile_prog "" "" ; then
2325e78815a5SAndreas Färber    madvise=yes
2326e78815a5SAndreas Färberfi
2327e78815a5SAndreas Färber
2328e78815a5SAndreas Färber##########################################
2329e78815a5SAndreas Färber# check if we have posix_madvise
2330e78815a5SAndreas Färber
2331e78815a5SAndreas Färberposix_madvise=no
2332e78815a5SAndreas Färbercat > $TMPC << EOF
2333e78815a5SAndreas Färber#include <sys/mman.h>
2334832ce9c2SScott Wood#include <stddef.h>
2335e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2336e78815a5SAndreas FärberEOF
2337e78815a5SAndreas Färberif compile_prog "" "" ; then
2338e78815a5SAndreas Färber    posix_madvise=yes
2339e78815a5SAndreas Färberfi
2340e78815a5SAndreas Färber
2341e78815a5SAndreas Färber##########################################
234294a420b1SStefan Hajnoczi# check if trace backend exists
234394a420b1SStefan Hajnoczi
23444c3b5a48SBlue Swirlsh "$source_path/scripts/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
234594a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
234694a420b1SStefan Hajnoczi  echo
234794a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
234894a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
234994a420b1SStefan Hajnoczi  echo
235094a420b1SStefan Hajnoczi  exit 1
235194a420b1SStefan Hajnoczifi
235294a420b1SStefan Hajnoczi
23537e24e92aSStefan Hajnoczi##########################################
23547e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
23557e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
23567e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
23577e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
23587e24e92aSStefan Hajnoczi#include <ust/marker.h>
23597e24e92aSStefan Hajnocziint main(void) { return 0; }
23607e24e92aSStefan HajnocziEOF
23617e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
23627e24e92aSStefan Hajnoczi    LIBS="-lust $LIBS"
23637e24e92aSStefan Hajnoczi  else
23647e24e92aSStefan Hajnoczi    echo
23657e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
23667e24e92aSStefan Hajnoczi    echo
23677e24e92aSStefan Hajnoczi    exit 1
23687e24e92aSStefan Hajnoczi  fi
23697e24e92aSStefan Hajnoczifi
2370b3d08c02SDaniel P. Berrange
2371b3d08c02SDaniel P. Berrange##########################################
2372b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2373b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2374b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2375b3d08c02SDaniel P. Berrange    echo
2376b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2377b3d08c02SDaniel P. Berrange    echo
2378b3d08c02SDaniel P. Berrange    exit 1
2379b3d08c02SDaniel P. Berrange  fi
2380c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2381c276b17dSDaniel P. Berrange  if has 'stap' ; then
2382c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2383c276b17dSDaniel P. Berrange  fi
2384b3d08c02SDaniel P. Berrangefi
2385b3d08c02SDaniel P. Berrange
23867e24e92aSStefan Hajnoczi##########################################
2387e86ecd4bSJuan Quintela# End of CC checks
2388e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2389e86ecd4bSJuan Quintela
2390e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
23911156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2392e86ecd4bSJuan Quintelafi
2393a316e378SJuan Quintela
2394e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2395e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2396e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
239720ff6c80SAnthony Liguori
239820ff6c80SAnthony Liguoriif test -z "$werror" ; then
2399e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2400e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2401e86ecd4bSJuan Quintela        werror="yes"
2402e86ecd4bSJuan Quintela    else
2403e86ecd4bSJuan Quintela        werror="no"
2404e86ecd4bSJuan Quintela    fi
2405e86ecd4bSJuan Quintelafi
2406e86ecd4bSJuan Quintela
240720ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
240820ff6c80SAnthony Liguori# enable/disable
240920ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
241020ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
241120ff6c80SAnthony Liguori	zero_malloc="no"
241220ff6c80SAnthony Liguori    else
241320ff6c80SAnthony Liguori	zero_malloc="yes"
241420ff6c80SAnthony Liguori    fi
241520ff6c80SAnthony Liguorifi
241620ff6c80SAnthony Liguori
2417e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2418a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2419e86ecd4bSJuan Quintelafi
2420e86ecd4bSJuan Quintela
2421e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2422e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
24231156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2424e86ecd4bSJuan Quintela    fi
2425e86ecd4bSJuan Quintelafi
2426e86ecd4bSJuan Quintela
2427952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
2428952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
2429952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
2430952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2431952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
2432952afb71SBlue Swirl        fi
2433952afb71SBlue Swirl    done
2434952afb71SBlue Swirlfi
2435952afb71SBlue Swirl
2436190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
24375a67135aSbellard
2438ca35f780SPaolo Bonzinitools=
2439ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2440ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2441ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2442ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2443ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2444ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2445ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2446ca35f780SPaolo Bonzini    fi
2447ca35f780SPaolo Bonzini  fi
2448ca35f780SPaolo Bonzinifi
2449ca35f780SPaolo Bonzini
2450ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2451ca35f780SPaolo Bonziniroms=
2452ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2453ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2454ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2455ca35f780SPaolo Bonzini  roms="optionrom"
2456ca35f780SPaolo Bonzinifi
2457ca35f780SPaolo Bonzini
2458ca35f780SPaolo Bonzini
24597d13299dSbellardecho "Install prefix    $prefix"
2460f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2461f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
24621c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
246311d9f695Sbellardif test "$mingw32" = "no" ; then
2464f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
246543ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
246611d9f695Sbellardfi
24675a67135aSbellardecho "Source path       $source_path"
24687d13299dSbellardecho "C compiler        $cc"
246983469015Sbellardecho "Host C compiler   $host_cc"
24700c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2471a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
24720c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
24737d13299dSbellardecho "make              $make"
24746a882643Spbrookecho "install           $install"
2475a98fd896Sbellardecho "host CPU          $cpu"
2476de83cd02Sbellardecho "host big endian   $bigendian"
247797a847bcSbellardecho "target list       $target_list"
2478ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2479b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
24807d13299dSbellardecho "gprof enabled     $gprof"
248103b4fe7dSaliguoriecho "sparse enabled    $sparse"
24821625af87Saliguoriecho "strip binaries    $strip_opt"
248305c2a3e7Sbellardecho "profiler          $profiler"
248443ce4dfeSbellardecho "static build      $static"
248585aa5189Sbellardecho "-Werror enabled   $werror"
24865b0753e0Sbellardif test "$darwin" = "yes" ; then
24875b0753e0Sbellard    echo "Cocoa support     $cocoa"
24885b0753e0Sbellardfi
248997a847bcSbellardecho "SDL support       $sdl"
24904d3b6f6eSbalrogecho "curses support    $curses"
2491769ce76dSAlexander Grafecho "curl support      $curl"
24925495ed11SLuiz Capitulinoecho "check support     $check_utests"
249367b915a5Sbellardecho "mingw32 support   $mingw32"
24940c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
24950c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2496eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
24978ff9cbf7Smalcecho "Mixer emulation   $mixemu"
24988d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
24992f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
25002f6f5c7aSCorentin Charyecho "VNC JPEG support  $vnc_jpeg"
2501efe556adSCorentin Charyecho "VNC PNG support   $vnc_png"
2502bd023f95SCorentin Charyecho "VNC thread        $vnc_thread"
25033142255cSblueswir1if test -n "$sparc_cpu"; then
25043142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
25053142255cSblueswir1fi
2506e37630caSaliguoriecho "xen support       $xen"
25072e4d9fb1Saurel32echo "brlapi support    $brlapi"
2508a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2509a25dba17SJuan Quintelaecho "Documentation     $docs"
2510c5937220Spbrook[ ! -z "$uname_release" ] && \
2511c5937220Spbrookecho "uname -r          $uname_release"
2512bd0c5661Spbrookecho "NPTL support      $nptl"
2513379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
251434005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
25158a16d273Sthsecho "vde support       $vde"
2516e5d355d1Saliguoriecho "IO thread         $io_thread"
25175c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2518758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
251977755340Sthsecho "Install blobs     $blobs"
2520b31a0277SJuan Quintelaecho "KVM support       $kvm"
2521f652e6afSaurel32echo "fdt support       $fdt"
2522ceb42de8Saliguoriecho "preadv support    $preadv"
25235f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2524e78815a5SAndreas Färberecho "madvise           $madvise"
2525e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
2526ee682d27SStefan Weilecho "uuid support      $uuid"
2527d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
252894a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
25299410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
2530cd4ec0b4SGerd Hoffmannecho "spice support     $spice"
2531f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
2532dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
253367b915a5Sbellard
253497a847bcSbellardif test $sdl_too_old = "yes"; then
253524b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2536e8cd23deSbellardfi
253797a847bcSbellard
253898ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
25394bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
254097a847bcSbellard
254198ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
254298ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
254398ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
254498ec69acSJuan Quintelaecho >> $config_host_mak
254598ec69acSJuan Quintela
2546e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
254799d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
254899d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
254999d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
255099d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
255199d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
255299d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
25531dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2554804edf29SJuan Quintela
25552408a527Saurel32case "$cpu" in
2556613a22c9SMichael Walle  i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2557e0da9dd3SJuan Quintela    ARCH=$cpu
25582408a527Saurel32  ;;
2559a302c32dSLaurent Desnogues  armv4b|armv4l)
256016dbd14fSJuan Quintela    ARCH=arm
25612408a527Saurel32  ;;
25622408a527Saurel32esac
256398ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2564f8393946Saurel32if test "$debug_tcg" = "yes" ; then
25652358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2566f8393946Saurel32fi
2567b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2568b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2569b4475aa2SLuiz Capitulinofi
2570f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
25712358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2572f3d08ee6SPaul Brookfi
25731625af87Saliguoriif test "$strip_opt" = "yes" ; then
257452ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
25751625af87Saliguorifi
25767d13299dSbellardif test "$bigendian" = "yes" ; then
2577e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
257897a847bcSbellardfi
25792358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
258067b915a5Sbellardif test "$mingw32" = "yes" ; then
258198ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
25829fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
25839fe6de94SBlue Swirl  version_major=${rc_version%%.*}
25849fe6de94SBlue Swirl  rc_version=${rc_version#*.}
25859fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
25869fe6de94SBlue Swirl  rc_version=${rc_version#*.}
25879fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
25889fe6de94SBlue Swirl  version_micro=0
25899fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
25909fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2591210fa556Spbrookelse
259235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2593210fa556Spbrookfi
2594128ab2ffSblueswir1
2595dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2596dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2597dffcb71cSMark McLoughlinfi
2598dffcb71cSMark McLoughlin
259983fb7adfSbellardif test "$darwin" = "yes" ; then
260098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
260183fb7adfSbellardfi
2602b29fe3edSmalc
2603b29fe3edSmalcif test "$aix" = "yes" ; then
260498ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2605b29fe3edSmalcfi
2606b29fe3edSmalc
2607ec530c81Sbellardif test "$solaris" = "yes" ; then
260898ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
26092358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
26100475a5caSths  if test "$needs_libsunmath" = "yes" ; then
261175b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
26120475a5caSths  fi
2613ec530c81Sbellardfi
2614179cf400SAndreas Färberif test "$haiku" = "yes" ; then
2615179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
2616179cf400SAndreas Färberfi
261797a847bcSbellardif test "$static" = "yes" ; then
261898ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
261997a847bcSbellardfi
262005c2a3e7Sbellardif test $profiler = "yes" ; then
26212358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
262205c2a3e7Sbellardfi
2623c20709aaSbellardif test "$slirp" = "yes" ; then
262498ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2625f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
2626c20709aaSbellardfi
26278a16d273Sthsif test "$vde" = "yes" ; then
262898ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
26298a16d273Sthsfi
26300c58ac1cSmalcfor card in $audio_card_list; do
2631f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
263298ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
26330c58ac1cSmalcdone
26342358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
26350c58ac1cSmalcfor drv in $audio_drv_list; do
2636f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
263798ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2638923e4521Smalc    if test "$drv" = "fmod"; then
26397aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2640fb065187Sbellard    fi
26410c58ac1cSmalcdone
264267f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
264367f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
264467f86e8eSJuan Quintelafi
2645d5631638Smalcif test "$audio_win_int" = "yes" ; then
2646d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2647d5631638Smalcfi
2648eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
26498ff9cbf7Smalcif test "$mixemu" = "yes" ; then
265098ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
26518ff9cbf7Smalcfi
26528d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
265398ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2654525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
26558d5d2d4cSthsfi
26562f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
265798ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
265860ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
26592f9606b3Saliguorifi
266096763cf9SCorentin Charyif test "$vnc_jpeg" != "no" ; then
26612f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
26622f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
26632f6f5c7aSCorentin Charyfi
266496763cf9SCorentin Charyif test "$vnc_png" != "no" ; then
2665efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2666efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2667efe556adSCorentin Charyfi
266896763cf9SCorentin Charyif test "$vnc_thread" != "no" ; then
2669bd023f95SCorentin Chary  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2670bd023f95SCorentin Charyfi
267176655d6dSaliguoriif test "$fnmatch" = "yes" ; then
26722358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
267376655d6dSaliguorifi
2674ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2675ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2676ee682d27SStefan Weilfi
2677dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
2678dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
2679dce512deSChristoph Hellwigfi
2680b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
268198ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
26822358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
268398ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
268498ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2685a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
268698ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2687cc8ae6deSpbrookfi
26881ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
268998ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
26908ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
269149ecc3faSbellardfi
269249ecc3faSbellardif test "$cocoa" = "yes" ; then
269398ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
269449ecc3faSbellardfi
26954d3b6f6eSbalrogif test "$curses" = "yes" ; then
269698ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2697ab4e5602SJan Kiszkafi
26983b3f24adSaurel32if test "$atfile" = "yes" ; then
26992358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
27003b3f24adSaurel32fi
2701ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
27022358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2703ebc996f3SRiku Voipiofi
2704099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
27052358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2706099d6b0fSRiku Voipiofi
270740ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
270840ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
270940ff6d7eSKevin Wolffi
27103ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
27112358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
27123ce34dfbSvibisreenivasanfi
2713c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2714c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2715c2882b96SRiku Voipiofi
2716d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2717d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2718d0927938SUlrich Hechtfi
2719c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
2720c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2721c727f47dSPeter Maydellfi
2722dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
2723dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
2724dace20dcSPeter Maydellfi
2725d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2726d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2727d0927938SUlrich Hechtfi
27283b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
27293b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
27303b6edd16SPeter Maydellfi
27313b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
27323b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
27333b6edd16SPeter Maydellfi
27343b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
27353b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
27363b6edd16SPeter Maydellfi
27373b3f24adSaurel32if test "$inotify" = "yes" ; then
27382358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
27393b3f24adSaurel32fi
2740c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2741c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2742c05c7a73SRiku Voipiofi
27436ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
27446ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
27456ae9a1f4SJuan Quintelafi
27466ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
27476ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
27486ae9a1f4SJuan Quintelafi
2749769ce76dSAlexander Grafif test "$curl" = "yes" ; then
275098ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2751b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2752769ce76dSAlexander Graffi
27532e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
275498ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
27552e4d9fb1Saurel32fi
2756fb599c9aSbalrogif test "$bluez" = "yes" ; then
275798ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2758ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2759fb599c9aSbalrogfi
2760e37630caSaliguoriif test "$xen" = "yes" ; then
27615647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2762e37630caSaliguorifi
2763e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
276498ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2765e5d355d1Saliguorifi
27665c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
27675c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
27685c6c3a6cSChristoph Hellwigfi
2769758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
2770758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
2771758e8e38SVenkateswararao Jujjuri (JV)fi
2772758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
2773758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
2774758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2775758e8e38SVenkateswararao Jujjuri (JV)  fi
2776758e8e38SVenkateswararao Jujjuri (JV)fi
277777755340Sthsif test "$blobs" = "yes" ; then
277898ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
277977755340Sthsfi
2780bf9298b9Saliguoriif test "$iovec" = "yes" ; then
27812358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2782bf9298b9Saliguorifi
2783ceb42de8Saliguoriif test "$preadv" = "yes" ; then
27842358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2785ceb42de8Saliguorifi
2786f652e6afSaurel32if test "$fdt" = "yes" ; then
27873f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2788f652e6afSaurel32fi
2789dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
2790dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2791dcc38d1cSMarcelo Tosattifi
2792de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2793de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2794de5071c5SBlue Swirlfi
2795747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2796747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2797747bbdf7SBlue Swirlfi
27985f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
27995f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
28005f6b9e8fSBlue Swirlfi
2801e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
2802e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
2803e78815a5SAndreas Färberfi
2804e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
2805e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2806e78815a5SAndreas Färberfi
280797a847bcSbellard
2808cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
2809cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
2810cd4ec0b4SGerd Hoffmannfi
2811cd4ec0b4SGerd Hoffmann
281283fb7adfSbellard# XXX: suppress that
28137d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
28142358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
28157d3505c5Sbellardfi
28167d3505c5Sbellard
28172358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2818c5937220Spbrook
281920ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
282020ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
282120ff6c80SAnthony Liguorifi
2822f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
2823f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
2824f27aaf4bSChristian Brunnerfi
282520ff6c80SAnthony Liguori
282668063649Sblueswir1# USB host support
282768063649Sblueswir1case "$usb" in
282868063649Sblueswir1linux)
282998ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
283068063649Sblueswir1;;
283168063649Sblueswir1bsd)
283298ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
283368063649Sblueswir1;;
283468063649Sblueswir1*)
283598ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
283668063649Sblueswir1;;
283768063649Sblueswir1esac
283868063649Sblueswir1
283994a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
284022890ab5SPrerna Saxenaif test "$trace_backend" = "simple"; then
284122890ab5SPrerna Saxena  echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
284222890ab5SPrerna Saxenafi
28439410b56cSPrerna Saxena# Set the appropriate trace file.
28449410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
28459410b56cSPrerna Saxena  trace_file="\"$trace_file-%u\""
28469410b56cSPrerna Saxenafi
2847c276b17dSDaniel P. Berrangeif test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
2848c276b17dSDaniel P. Berrange  echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
2849c276b17dSDaniel P. Berrangefi
28509410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
28519410b56cSPrerna Saxena
285298ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
285398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2854804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2855804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
2856804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2857804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2858804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2859804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
28602b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
2861804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
2862804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2863804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2864804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
28659fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
2866e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
2867a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2868f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
2869e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
2870e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2871e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2872e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2873e39f0062SPaolo Bonzinifi
2874c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2875e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
2876a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2877a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
287873da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
28793e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2880804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2881804edf29SJuan Quintela
28824bf6b55bSJuan Quintela# generate list of library paths for linker script
28834bf6b55bSJuan Quintela
28844bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
28854bf6b55bSJuan Quintela
28864bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
28874bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
28884bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
28894bf6b55bSJuan Quintela  else
28904bf6b55bSJuan Quintela    rm ${config_host_ld}~
28914bf6b55bSJuan Quintela  fi
28924bf6b55bSJuan Quintelafi
28934bf6b55bSJuan Quintela
28944d904533SBlue Swirlfor d in libdis libdis-user; do
28954d904533SBlue Swirl    mkdir -p $d
289611568d6dSPaolo Bonzini    symlink $source_path/Makefile.dis $d/Makefile
28974d904533SBlue Swirl    echo > $d/config.mak
28984d904533SBlue Swirldone
2899d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
2900d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2901d44cff22SRichard Hendersonfi
29024d904533SBlue Swirl
290397a847bcSbellardfor target in $target_list; do
290497a847bcSbellardtarget_dir="$target"
290525be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
2906600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
290797a847bcSbellardtarget_bigendian="no"
29081f3d3c8fSJuan Quintela
2909ea2d6a39SJuan Quintelacase "$target_arch2" in
2910613a22c9SMichael Walle  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2911ea2d6a39SJuan Quintela  target_bigendian=yes
2912ea2d6a39SJuan Quintela  ;;
2913ea2d6a39SJuan Quintelaesac
291497a847bcSbellardtarget_softmmu="no"
2915997344f3Sbellardtarget_user_only="no"
2916831b7825Sthstarget_linux_user="no"
2917831b7825Sthstarget_darwin_user="no"
291884778508Sblueswir1target_bsd_user="no"
29199e407a85Spbrookcase "$target" in
2920600309b6SBlue Swirl  ${target_arch2}-softmmu)
29219e407a85Spbrook    target_softmmu="yes"
29229e407a85Spbrook    ;;
2923600309b6SBlue Swirl  ${target_arch2}-linux-user)
29249c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
29259c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
29269c7a4202SBlue Swirl      exit 1
29279c7a4202SBlue Swirl    fi
29289e407a85Spbrook    target_user_only="yes"
29299e407a85Spbrook    target_linux_user="yes"
29309e407a85Spbrook    ;;
2931600309b6SBlue Swirl  ${target_arch2}-darwin-user)
29329c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
29339c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
29349c7a4202SBlue Swirl      exit 1
29359c7a4202SBlue Swirl    fi
29369e407a85Spbrook    target_user_only="yes"
2937831b7825Sths    target_darwin_user="yes"
29389e407a85Spbrook    ;;
2939600309b6SBlue Swirl  ${target_arch2}-bsd-user)
29409cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
29419c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
29429c7a4202SBlue Swirl      exit 1
29439c7a4202SBlue Swirl    fi
294484778508Sblueswir1    target_user_only="yes"
294584778508Sblueswir1    target_bsd_user="yes"
294684778508Sblueswir1    ;;
29479e407a85Spbrook  *)
29489e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
29499e407a85Spbrook    exit 1
29509e407a85Spbrook    ;;
29519e407a85Spbrookesac
2952831b7825Sths
295397a847bcSbellardmkdir -p $target_dir
2954158142c2Sbellardmkdir -p $target_dir/fpu
295557fec1feSbellardmkdir -p $target_dir/tcg
295659f2a787SGerd Hoffmannmkdir -p $target_dir/ide
295784778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
295869de927cSbellard  mkdir -p $target_dir/nwfpe
295969de927cSbellardfi
296011568d6dSPaolo Bonzinisymlink $source_path/Makefile.target $target_dir/Makefile
2961ec530c81Sbellard
296297a847bcSbellard
296325be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
296497a847bcSbellard
2965e5fe0c52Spbrookbflt="no"
2966bd0c5661Spbrooktarget_nptl="no"
2967600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
29687ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
296956aebc89Spbrookgdb_xml_files=""
2970c2e3dee6SLaurent Viviertarget_short_alignment=2
2971c2e3dee6SLaurent Viviertarget_int_alignment=4
2972c2e3dee6SLaurent Viviertarget_long_alignment=4
2973c2e3dee6SLaurent Viviertarget_llong_alignment=8
29747ba1e619Saliguori
2975938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
29766acff7daSJuan QuintelaTARGET_BASE_ARCH=""
2977e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
2978e73aae67SJuan Quintela
2979600309b6SBlue Swirlcase "$target_arch2" in
29802408a527Saurel32  i386)
298171deff27SAurelien Jarno    target_phys_bits=64
29822408a527Saurel32  ;;
29832408a527Saurel32  x86_64)
29846acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
29851ad2134fSPaul Brook    target_phys_bits=64
2986c2e3dee6SLaurent Vivier    target_long_alignment=8
29872408a527Saurel32  ;;
29882408a527Saurel32  alpha)
29891ad2134fSPaul Brook    target_phys_bits=64
2990c2e3dee6SLaurent Vivier    target_long_alignment=8
2991a4b388ffSRichard Henderson    target_nptl="yes"
29922408a527Saurel32  ;;
29932408a527Saurel32  arm|armeb)
2994b498c8a0SJuan Quintela    TARGET_ARCH=arm
2995e5fe0c52Spbrook    bflt="yes"
2996bd0c5661Spbrook    target_nptl="yes"
299756aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
29981ad2134fSPaul Brook    target_phys_bits=32
2999c2e3dee6SLaurent Vivier    target_llong_alignment=4
30002408a527Saurel32  ;;
30012408a527Saurel32  cris)
3002253bd7f8Sedgar_igl    target_nptl="yes"
30031ad2134fSPaul Brook    target_phys_bits=32
30042408a527Saurel32  ;;
3005613a22c9SMichael Walle  lm32)
3006613a22c9SMichael Walle    target_phys_bits=32
3007613a22c9SMichael Walle  ;;
30082408a527Saurel32  m68k)
30090938cda5Saurel32    bflt="yes"
301056aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
30111ad2134fSPaul Brook    target_phys_bits=32
3012c2e3dee6SLaurent Vivier    target_int_alignment=2
3013c2e3dee6SLaurent Vivier    target_long_alignment=2
3014c2e3dee6SLaurent Vivier    target_llong_alignment=2
30152408a527Saurel32  ;;
3016877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3017877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
301872b675caSEdgar E. Iglesias    bflt="yes"
301972b675caSEdgar E. Iglesias    target_nptl="yes"
302072b675caSEdgar E. Iglesias    target_phys_bits=32
302172b675caSEdgar E. Iglesias  ;;
30222408a527Saurel32  mips|mipsel)
3023b498c8a0SJuan Quintela    TARGET_ARCH=mips
302425be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3025f04dc72fSPaul Brook    target_nptl="yes"
30261ad2134fSPaul Brook    target_phys_bits=64
30272408a527Saurel32  ;;
30282408a527Saurel32  mipsn32|mipsn32el)
3029b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
30306acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
303125be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
30321ad2134fSPaul Brook    target_phys_bits=64
30332408a527Saurel32  ;;
30342408a527Saurel32  mips64|mips64el)
3035b498c8a0SJuan Quintela    TARGET_ARCH=mips64
30366acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
303725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
30381ad2134fSPaul Brook    target_phys_bits=64
3039c2e3dee6SLaurent Vivier    target_long_alignment=8
30402408a527Saurel32  ;;
30412408a527Saurel32  ppc)
3042c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
30431ad2134fSPaul Brook    target_phys_bits=32
3044d6630708SNathan Froyd    target_nptl="yes"
30452408a527Saurel32  ;;
30462408a527Saurel32  ppcemb)
30476acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3048e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3049c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
30501ad2134fSPaul Brook    target_phys_bits=64
3051d6630708SNathan Froyd    target_nptl="yes"
30522408a527Saurel32  ;;
30532408a527Saurel32  ppc64)
30546acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3055e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3056c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
30571ad2134fSPaul Brook    target_phys_bits=64
3058c2e3dee6SLaurent Vivier    target_long_alignment=8
30592408a527Saurel32  ;;
30602408a527Saurel32  ppc64abi32)
3061b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
30626acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3063e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
306425be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3065c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
30661ad2134fSPaul Brook    target_phys_bits=64
30672408a527Saurel32  ;;
30682408a527Saurel32  sh4|sh4eb)
3069b498c8a0SJuan Quintela    TARGET_ARCH=sh4
30704dbed897Spbrook    bflt="yes"
30710b6d3ae0Saurel32    target_nptl="yes"
30721ad2134fSPaul Brook    target_phys_bits=32
30732408a527Saurel32  ;;
30742408a527Saurel32  sparc)
30751ad2134fSPaul Brook    target_phys_bits=64
30762408a527Saurel32  ;;
30772408a527Saurel32  sparc64)
30786acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
30791ad2134fSPaul Brook    target_phys_bits=64
3080c2e3dee6SLaurent Vivier    target_long_alignment=8
30812408a527Saurel32  ;;
30822408a527Saurel32  sparc32plus)
3083b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
30846acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3085e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
308625be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
30871ad2134fSPaul Brook    target_phys_bits=64
30882408a527Saurel32  ;;
308924e804ecSAlexander Graf  s390x)
309024e804ecSAlexander Graf    target_phys_bits=64
309124e804ecSAlexander Graf  ;;
30922408a527Saurel32  *)
3093de83cd02Sbellard    echo "Unsupported target CPU"
3094de83cd02Sbellard    exit 1
30952408a527Saurel32  ;;
30962408a527Saurel32esac
3097c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3098c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3099c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3100c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
310125be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3102053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
310325be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
310425be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
310542bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
31066acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
31076acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
31086acff7daSJuan Quintelafi
310925be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3110e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3111e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3112e6e91b9cSJuan Quintelafi
311325be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
31141b0c87fcSJuan Quintelacase "$target_arch2" in
31151b0c87fcSJuan Quintela  i386|x86_64)
31161b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
311725be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
31181b0c87fcSJuan Quintela    fi
31191b0c87fcSJuan Quintelaesac
3120c59249f9SJuan Quintelacase "$target_arch2" in
31210e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3122c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3123c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3124c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3125c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
31265f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3127*adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3128*adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3129c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3130c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
313125be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
313225be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
3133dae5079aSJan Kiszka      if test "$kvm_para" = "yes"; then
3134dae5079aSJan Kiszka        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
3135dae5079aSJan Kiszka      fi
3136d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
3137d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3138d5970055SMichael S. Tsirkin      fi
3139c59249f9SJuan Quintela    fi
3140c59249f9SJuan Quintelaesac
3141de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
314225be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
314397a847bcSbellardfi
314497a847bcSbellardif test "$target_softmmu" = "yes" ; then
3145b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
314625be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
314725be210fSJuan Quintela  echo "LIBS+=$libs_softmmu" >> $config_target_mak
31480e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
31495791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3150de83cd02Sbellardfi
3151997344f3Sbellardif test "$target_user_only" = "yes" ; then
315225be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3153997344f3Sbellardfi
3154831b7825Sthsif test "$target_linux_user" = "yes" ; then
315525be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3156831b7825Sthsfi
3157831b7825Sthsif test "$target_darwin_user" = "yes" ; then
315825be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3159831b7825Sthsfi
316056aebc89Spbrooklist=""
316156aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
316256aebc89Spbrook  for x in $gdb_xml_files; do
316356aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
316456aebc89Spbrook  done
316525be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
31663d0f1517SJuan Quintelafi
3167de83cd02Sbellard
3168f57975fbSJuan Quintelacase "$target_arch2" in
3169eb8f7776SAurelien Jarno  i386|x86_64)
3170eb8f7776SAurelien Jarno    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
3171f57975fbSJuan Quintela    ;;
3172d6b38939SJuan Quintela  *)
3173eb8f7776SAurelien Jarno    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
3174d6b38939SJuan Quintela    ;;
3175f57975fbSJuan Quintelaesac
3176f57975fbSJuan Quintela
3177e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
317825be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3179e5fe0c52Spbrookfi
3180bd0c5661Spbrookif test "$target_user_only" = "yes" \
3181bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
318225be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3183bd0c5661Spbrookfi
3184379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
318525be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3186379f6698SPaul Brookfi
318784778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
318825be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
318984778508Sblueswir1fi
31905b0753e0Sbellard
31914afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3192fa282484SJuan Quintela
31934afddb55SJuan Quintelacflags=""
3194f9728943SPaolo Bonziniincludes=""
3195fa282484SJuan Quintelaldflags=""
31969b8e111fSJuan Quintela
319757ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
3198f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
319924e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3200f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
32015d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3202f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
320357ddfbf7SJuan Quintelaelse
3204f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
320557ddfbf7SJuan Quintelafi
3206f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
3207f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/fpu $includes"
320857ddfbf7SJuan Quintela
32094d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
32104d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
32114d904533SBlue Swirlelse
32124d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
32134d904533SBlue Swirlfi
32144d904533SBlue Swirl
321564656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
321664656024SJuan Quintela  case "$i" in
321764656024SJuan Quintela  alpha)
321825be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
32194d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
322064656024SJuan Quintela  ;;
322164656024SJuan Quintela  arm)
322225be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
32234d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
322464656024SJuan Quintela  ;;
322564656024SJuan Quintela  cris)
322625be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
32274d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
322864656024SJuan Quintela  ;;
322964656024SJuan Quintela  hppa)
323025be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
32314d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
323264656024SJuan Quintela  ;;
323364656024SJuan Quintela  i386|x86_64)
323425be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
32354d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
323664656024SJuan Quintela  ;;
3237903ec55cSAurelien Jarno  ia64*)
3238903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3239903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3240903ec55cSAurelien Jarno  ;;
324164656024SJuan Quintela  m68k)
324225be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
32434d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
324464656024SJuan Quintela  ;;
3245877fdc12SEdgar E. Iglesias  microblaze*)
324625be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
32474d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
324864656024SJuan Quintela  ;;
324964656024SJuan Quintela  mips*)
325025be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
32514d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
325264656024SJuan Quintela  ;;
325364656024SJuan Quintela  ppc*)
325425be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
32554d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
325664656024SJuan Quintela  ;;
325724e804ecSAlexander Graf  s390*)
325825be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
32594d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
326064656024SJuan Quintela  ;;
326164656024SJuan Quintela  sh4)
326225be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
32634d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
326464656024SJuan Quintela  ;;
326564656024SJuan Quintela  sparc*)
326625be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
32674d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
326864656024SJuan Quintela  ;;
326964656024SJuan Quintela  esac
327064656024SJuan Quinteladone
327164656024SJuan Quintela
32726ee7126fSJuan Quintelacase "$ARCH" in
32736ee7126fSJuan Quintelaalpha)
32746ee7126fSJuan Quintela  # Ensure there's only a single GP
32756ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
32766ee7126fSJuan Quintela;;
32776ee7126fSJuan Quintelaesac
32786ee7126fSJuan Quintela
327955d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
328055d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
328155d9c04bSJuan Quintela  arm)
328255d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
328355d9c04bSJuan Quintela  ;;
328455d9c04bSJuan Quintela  i386|mips|ppc)
328555d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
328655d9c04bSJuan Quintela  ;;
328755d9c04bSJuan Quintela  esac
328855d9c04bSJuan Quintelafi
328955d9c04bSJuan Quintela
329034005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
329134005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
329234005a00SKirill A. Shutemov  cflags="-fpie $cflags"
329334005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
329434005a00SKirill A. Shutemovfi
329534005a00SKirill A. Shutemov
3296471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
3297471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
3298471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
329925be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3300471857ddSJuan Quintelafi
3301471857ddSJuan Quintela
3302d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
330325be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
3304d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
3305d02c1db3SJuan Quintela    cflags="-p $cflags"
3306d02c1db3SJuan Quintela    ldflags="-p $ldflags"
3307d02c1db3SJuan Quintela  fi
3308d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
3309d02c1db3SJuan Quintela    ldflags="-p $ldflags"
331025be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3311d02c1db3SJuan Quintela  fi
3312d02c1db3SJuan Quintelafi
3313d02c1db3SJuan Quintela
33146ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
33159b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3316fa282484SJuan Quintela  case "$ARCH" in
3317fa282484SJuan Quintela  sparc)
3318fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
3319322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
3320fa282484SJuan Quintela    ;;
33214d58be06SRichard Henderson  alpha | s390x)
33224d58be06SRichard Henderson    # The default placement of the application is fine.
33234d58be06SRichard Henderson    ;;
3324fd76e73aSRichard Henderson  *)
3325322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
3326fa282484SJuan Quintela    ;;
3327fa282484SJuan Quintela  esac
3328fa282484SJuan Quintelafi
3329fa282484SJuan Quintela
333025be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
333125be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3332f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
3333fa282484SJuan Quintela
333497a847bcSbellarddone # for target in $targets
33357d13299dSbellard
3336d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
3337e1144d00SMark McLoughlinDIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
33382d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
33393e230dd2SCorentin CharyDIRS="$DIRS fsdev ui"
33407d13299dSbellardFILES="Makefile tests/Makefile"
3341e7daa605SthsFILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3342ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
33432d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
33447ea78b74SJan Kiszkafor bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
33457ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
33467ea78b74SJan Kiszkadone
3347d1807a4fSPaolo Bonzinimkdir -p $DIRS
33487d13299dSbellardfor f in $FILES ; do
3349eae30c8fSAurelien Jarno    test -e $f || symlink $source_path/$f $f
33507d13299dSbellarddone
33511ad2134fSPaul Brook
3352c34ebfdcSAnthony Liguori# temporary config to build submodules
33532d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
3354c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
335537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3356c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3357c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3358c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
3359c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
3360c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3361c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
3362c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
3363c34ebfdcSAnthony Liguoridone
3364c34ebfdcSAnthony Liguori
33651ad2134fSPaul Brookfor hwlib in 32 64; do
33661ad2134fSPaul Brook  d=libhw$hwlib
33671ad2134fSPaul Brook  mkdir -p $d
33689953b2fcSBlue Swirl  mkdir -p $d/ide
336911568d6dSPaolo Bonzini  symlink $source_path/Makefile.hw $d/Makefile
337037116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
33711ad2134fSPaul Brookdone
3372add16157SBlue Swirl
3373add16157SBlue Swirld=libuser
3374add16157SBlue Swirlmkdir -p $d
337511568d6dSPaolo Bonzinisymlink $source_path/Makefile.user $d/Makefile
3376299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
3377299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3378299060a0SKirill A. Shutemovfi
3379b40292e7SJan Kiszka
3380b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
3381b40292e7SJan Kiszka  mkdir -p QMP
3382b40292e7SJan Kiszkafi
3383