xref: /openbmc/qemu/configure (revision b87de24e6c568d40d4f231b10e1707aed1ebe92e)
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=""
120821601eaSJes Sorensenvnc="yes"
121377529c0SPaolo Bonzinisparse="no"
122377529c0SPaolo Bonziniuuid=""
123377529c0SPaolo Bonzinivde=""
124377529c0SPaolo Bonzinivnc_tls=""
125377529c0SPaolo Bonzinivnc_sasl=""
126377529c0SPaolo Bonzinivnc_jpeg=""
127377529c0SPaolo Bonzinivnc_png=""
128377529c0SPaolo Bonzinivnc_thread="no"
129377529c0SPaolo Bonzinixen=""
130d5b93ddfSAnthony PERARDxen_ctrl_version=""
131377529c0SPaolo Bonzinilinux_aio=""
132377529c0SPaolo Bonziniattr=""
133377529c0SPaolo Bonzinivhost_net=""
134377529c0SPaolo Bonzinixfs=""
135377529c0SPaolo Bonzini
136377529c0SPaolo Bonzinigprof="no"
137377529c0SPaolo Bonzinidebug_tcg="no"
138377529c0SPaolo Bonzinidebug_mon="no"
139377529c0SPaolo Bonzinidebug="no"
140377529c0SPaolo Bonzinistrip_opt="yes"
141377529c0SPaolo Bonzinibigendian="no"
142377529c0SPaolo Bonzinimingw32="no"
143377529c0SPaolo BonziniEXESUF=""
144377529c0SPaolo Bonziniprefix="/usr/local"
145377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
146377529c0SPaolo Bonzinidatadir="\${prefix}/share/qemu"
147377529c0SPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
148377529c0SPaolo Bonzinibindir="\${prefix}/bin"
1493aa5d2beSAlon Levylibdir="\${prefix}/lib"
150377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
151377529c0SPaolo Bonziniconfsuffix="/qemu"
152377529c0SPaolo Bonzinislirp="yes"
153377529c0SPaolo Bonzinifmod_lib=""
154377529c0SPaolo Bonzinifmod_inc=""
155377529c0SPaolo Bonzinioss_lib=""
156377529c0SPaolo Bonzinibsd="no"
157377529c0SPaolo Bonzinilinux="no"
158377529c0SPaolo Bonzinisolaris="no"
159377529c0SPaolo Bonziniprofiler="no"
160377529c0SPaolo Bonzinicocoa="no"
161377529c0SPaolo Bonzinisoftmmu="yes"
162377529c0SPaolo Bonzinilinux_user="no"
163377529c0SPaolo Bonzinidarwin_user="no"
164377529c0SPaolo Bonzinibsd_user="no"
165377529c0SPaolo Bonziniguest_base=""
166377529c0SPaolo Bonziniuname_release=""
167377529c0SPaolo Bonziniio_thread="no"
168377529c0SPaolo Bonzinimixemu="no"
169377529c0SPaolo Bonzinikerneldir=""
170377529c0SPaolo Bonziniaix="no"
171377529c0SPaolo Bonziniblobs="yes"
172377529c0SPaolo Bonzinipkgversion=""
173377529c0SPaolo Bonzinicheck_utests="no"
174377529c0SPaolo Bonziniuser_pie="no"
175377529c0SPaolo Bonzinizero_malloc=""
176377529c0SPaolo Bonzinitrace_backend="nop"
177377529c0SPaolo Bonzinitrace_file="trace"
178377529c0SPaolo Bonzinispice=""
179377529c0SPaolo Bonzinirbd=""
18036707144SAlon Levysmartcard=""
181111a38b0SRobert Relyeasmartcard_nss=""
182430a3c18SMichael Walleopengl=""
183377529c0SPaolo Bonzini
184ac0df51dSaliguori# parse CC options first
185ac0df51dSaliguorifor opt do
186ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
187ac0df51dSaliguori  case "$opt" in
188ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
189ac0df51dSaliguori  ;;
1903d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
191ac0df51dSaliguori  ;;
192ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
193ca4deeb1SPaolo Bonzini  ;;
1942ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
1952ff6b91eSJuan Quintela  ;;
196a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
197e2a2ed06SJuan Quintela  ;;
198e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
199e2a2ed06SJuan Quintela  ;;
20050e7b1a0SJuan Quintela  --sparc_cpu=*)
20150e7b1a0SJuan Quintela    sparc_cpu="$optarg"
20250e7b1a0SJuan Quintela    case $sparc_cpu in
203ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
20450e7b1a0SJuan Quintela      cpu="sparc"
20550e7b1a0SJuan Quintela    ;;
20650e7b1a0SJuan Quintela    v9)
20750e7b1a0SJuan Quintela      cpu="sparc64"
20850e7b1a0SJuan Quintela    ;;
20950e7b1a0SJuan Quintela    *)
21050e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
21150e7b1a0SJuan Quintela      exit 1
21250e7b1a0SJuan Quintela    ;;
21350e7b1a0SJuan Quintela    esac
21450e7b1a0SJuan Quintela  ;;
215ac0df51dSaliguori  esac
216ac0df51dSaliguoridone
217ac0df51dSaliguori# OS specific
218ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
219ac0df51dSaliguori# we can eliminate it's usage altogether
220ac0df51dSaliguori
2213d8df640SPaolo Bonzinicc="${cross_prefix}${CC-gcc}"
2223d8df640SPaolo Bonziniar="${cross_prefix}${AR-ar}"
2233d8df640SPaolo Bonziniobjcopy="${cross_prefix}${OBJCOPY-objcopy}"
2243d8df640SPaolo Bonzinild="${cross_prefix}${LD-ld}"
2253d8df640SPaolo Bonzinistrip="${cross_prefix}${STRIP-strip}"
2263d8df640SPaolo Bonziniwindres="${cross_prefix}${WINDRES-windres}"
227a8bd70adSPaolo Bonzinipkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
2283ec87ffeSPaolo Bonzinisdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
229ac0df51dSaliguori
230be17dc90SMichael S. Tsirkin# default flags for all hosts
231be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
232be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
233f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
234be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
235be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
23684958305SKirill A. ShutemovQEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
237f9728943SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH)"
238be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
239be17dc90SMichael S. Tsirkin
240ca4deeb1SPaolo Bonzini# make source path absolute
241ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
242ca4deeb1SPaolo Bonzini
243ac0df51dSaliguoricheck_define() {
244ac0df51dSaliguoricat > $TMPC <<EOF
245ac0df51dSaliguori#if !defined($1)
246ac0df51dSaliguori#error Not defined
247ac0df51dSaliguori#endif
248ac0df51dSaliguoriint main(void) { return 0; }
249ac0df51dSaliguoriEOF
25052166aa0SJuan Quintela  compile_object
251ac0df51dSaliguori}
252ac0df51dSaliguori
2532ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
2542ff6b91eSJuan Quintela  # command line argument
2552ff6b91eSJuan Quintela  :
2562ff6b91eSJuan Quintelaelif check_define __i386__ ; then
257ac0df51dSaliguori  cpu="i386"
258ac0df51dSaliguorielif check_define __x86_64__ ; then
259ac0df51dSaliguori  cpu="x86_64"
2603aa9bd6cSblueswir1elif check_define __sparc__ ; then
2613aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
2623aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
2633aa9bd6cSblueswir1  if check_define __arch64__ ; then
2643aa9bd6cSblueswir1    cpu="sparc64"
2653aa9bd6cSblueswir1  else
2663aa9bd6cSblueswir1    cpu="sparc"
2673aa9bd6cSblueswir1  fi
268fdf7ed96Smalcelif check_define _ARCH_PPC ; then
269fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
270fdf7ed96Smalc    cpu="ppc64"
271ac0df51dSaliguori  else
272fdf7ed96Smalc    cpu="ppc"
273fdf7ed96Smalc  fi
274afa05235SAurelien Jarnoelif check_define __mips__ ; then
275afa05235SAurelien Jarno  cpu="mips"
276477ba620SAurelien Jarnoelif check_define __ia64__ ; then
277477ba620SAurelien Jarno  cpu="ia64"
278d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
279d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
280d66ed0eaSAurelien Jarno    cpu="s390x"
281d66ed0eaSAurelien Jarno  else
282d66ed0eaSAurelien Jarno    cpu="s390"
283d66ed0eaSAurelien Jarno  fi
284fdf7ed96Smalcelse
285fdf7ed96Smalc  cpu=`uname -m`
286ac0df51dSaliguorifi
287ac0df51dSaliguori
2887d13299dSbellardcase "$cpu" in
289d2fbca94SGuan Xuetao  alpha|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64|unicore32)
290ea8f20f8SJuan Quintela    cpu="$cpu"
291ea8f20f8SJuan Quintela  ;;
2927d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
29397a847bcSbellard    cpu="i386"
2947d13299dSbellard  ;;
295aaa5fa14Saurel32  x86_64|amd64)
296aaa5fa14Saurel32    cpu="x86_64"
297aaa5fa14Saurel32  ;;
298ba68055eSbellard  armv*b)
299808c4954Sbellard    cpu="armv4b"
300808c4954Sbellard  ;;
301ba68055eSbellard  armv*l)
3027d13299dSbellard    cpu="armv4l"
3037d13299dSbellard  ;;
304f54b3f92Saurel32  parisc|parisc64)
305f54b3f92Saurel32    cpu="hppa"
306f54b3f92Saurel32  ;;
307afa05235SAurelien Jarno  mips*)
308afa05235SAurelien Jarno    cpu="mips"
309afa05235SAurelien Jarno  ;;
31024e804ecSAlexander Graf  s390)
311fb3e5849Sbellard    cpu="s390"
312fb3e5849Sbellard  ;;
31324e804ecSAlexander Graf  s390x)
31424e804ecSAlexander Graf    cpu="s390x"
31524e804ecSAlexander Graf  ;;
3163142255cSblueswir1  sparc|sun4[cdmuv])
317ae228531Sbellard    cpu="sparc"
318ae228531Sbellard  ;;
3197d13299dSbellard  *)
320a447d4dcSPaolo Bonzini    echo "Unsupported CPU = $cpu"
321a447d4dcSPaolo Bonzini    exit 1
3227d13299dSbellard  ;;
3237d13299dSbellardesac
324e2d52ad3SJuan Quintela
3257d13299dSbellard# OS specific
326ac0df51dSaliguoriif check_define __linux__ ; then
327ac0df51dSaliguori  targetos="Linux"
328ac0df51dSaliguorielif check_define _WIN32 ; then
329ac0df51dSaliguori  targetos='MINGW32'
330169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
331169dc5d3Sblueswir1  targetos='OpenBSD'
332169dc5d3Sblueswir1elif check_define __sun__ ; then
333169dc5d3Sblueswir1  targetos='SunOS'
334179cf400SAndreas Färberelif check_define __HAIKU__ ; then
335179cf400SAndreas Färber  targetos='Haiku'
336ac0df51dSaliguorielse
3377d13299dSbellard  targetos=`uname -s`
338ac0df51dSaliguorifi
3390dbfc675SJuan Quintela
3407d13299dSbellardcase $targetos in
341c326e0afSbellardCYGWIN*)
342c326e0afSbellard  mingw32="yes"
343a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
344d5631638Smalc  audio_possible_drivers="winwave sdl"
345d5631638Smalc  audio_drv_list="winwave"
346c326e0afSbellard;;
34767b915a5SbellardMINGW32*)
34867b915a5Sbellard  mingw32="yes"
349d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
350d5631638Smalc  audio_drv_list="winwave"
35167b915a5Sbellard;;
3525c40d2bdSthsGNU/kFreeBSD)
353a167ba50SAurelien Jarno  bsd="yes"
3540c58ac1cSmalc  audio_drv_list="oss"
355f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3565c40d2bdSths;;
3577d3505c5SbellardFreeBSD)
3587d3505c5Sbellard  bsd="yes"
3590db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3600c58ac1cSmalc  audio_drv_list="oss"
361f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
362f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
363f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3647d3505c5Sbellard;;
365c5e97233Sblueswir1DragonFly)
366c5e97233Sblueswir1  bsd="yes"
3670db4a067SPaolo Bonzini  make="${MAKE-gmake}"
368c5e97233Sblueswir1  audio_drv_list="oss"
369c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
370c5e97233Sblueswir1;;
3717d3505c5SbellardNetBSD)
3727d3505c5Sbellard  bsd="yes"
3730db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3740c58ac1cSmalc  audio_drv_list="oss"
375c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3768ef92a88Sblueswir1  oss_lib="-lossaudio"
3777d3505c5Sbellard;;
3787d3505c5SbellardOpenBSD)
3797d3505c5Sbellard  bsd="yes"
3800db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3810c58ac1cSmalc  audio_drv_list="oss"
382c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3832f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3847d3505c5Sbellard;;
38583fb7adfSbellardDarwin)
38683fb7adfSbellard  bsd="yes"
38783fb7adfSbellard  darwin="yes"
3880dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3890dbfc675SJuan Quintela  # run 64-bit userspace code
390aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3911b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
392aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3931b0f9cc2Saliguori  fi
3941b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
395a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3960c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3971b0f9cc2Saliguori  else
398a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3991b0f9cc2Saliguori  fi
400831b7825Sths  darwin_user="yes"
401fd677642Sths  cocoa="yes"
4020c58ac1cSmalc  audio_drv_list="coreaudio"
403c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4040c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4057973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
40683fb7adfSbellard;;
407ec530c81SbellardSunOS)
408ec530c81Sbellard  solaris="yes"
4090db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4100db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
411fa58948dSBlue Swirl  ld="gld"
4120475a5caSths  needs_libsunmath="no"
413c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
414ef18c883Sths  # have to select again, because `uname -m` returns i86pc
415ef18c883Sths  # even on an x86_64 box.
416ef18c883Sths  solariscpu=`isainfo -k`
417ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
418ef18c883Sths    cpu="x86_64"
419ef18c883Sths  fi
420c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4210475a5caSths    if test "$solarisrev" -le 9 ; then
4220475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4230475a5caSths        needs_libsunmath="yes"
424f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
425f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
426f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4270475a5caSths      else
4280475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4290475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4300475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4310475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4320475a5caSths        exit 1
4330475a5caSths      fi
4340475a5caSths    fi
43586b2bd93Sths  fi
4366b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4370c58ac1cSmalc    audio_drv_list="oss"
4386b4d2ba1Sths  fi
439c2de5c91Smalc  audio_possible_drivers="oss sdl"
440d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
441d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
442d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
443d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
444a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
445e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
446ec530c81Sbellard;;
447b29fe3edSmalcAIX)
448b29fe3edSmalc  aix="yes"
4490db4a067SPaolo Bonzini  make="${MAKE-gmake}"
450b29fe3edSmalc;;
451179cf400SAndreas FärberHaiku)
452179cf400SAndreas Färber  haiku="yes"
453179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
454179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
455179cf400SAndreas Färber;;
456fb065187Sbellard*)
4570c58ac1cSmalc  audio_drv_list="oss"
458b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4595327cf48Sbellard  linux="yes"
460831b7825Sths  linux_user="yes"
46168063649Sblueswir1  usb="linux"
46207f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
463c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
464c9ec1fe4Sbellard  fi
465fb065187Sbellard;;
4667d13299dSbellardesac
4677d13299dSbellard
4687d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
469b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
47068063649Sblueswir1    usb="bsd"
47183fb7adfSbellard  fi
47284778508Sblueswir1  bsd_user="yes"
4737d3505c5Sbellardfi
4747d3505c5Sbellard
4750db4a067SPaolo Bonzini: ${make=${MAKE-make}}
4760db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
4770db4a067SPaolo Bonzini
4783457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4793457a3f8SJuan Quintela  EXESUF=".exe"
480a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
481e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
482e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
48308f3896aSStefan Weil  LIBS="-lwinmm -lws2_32 -liberty -liphlpapi $LIBS"
484683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
485683035deSPaolo Bonzini  mandir="\${prefix}"
486683035deSPaolo Bonzini  datadir="\${prefix}"
487683035deSPaolo Bonzini  docdir="\${prefix}"
488683035deSPaolo Bonzini  bindir="\${prefix}"
489683035deSPaolo Bonzini  sysconfdir="\${prefix}"
490683035deSPaolo Bonzini  confsuffix=""
4913457a3f8SJuan Quintelafi
4923457a3f8SJuan Quintela
493487fefdbSAnthony Liguoriwerror=""
49485aa5189Sbellard
4957d13299dSbellardfor opt do
496a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4977d13299dSbellard  case "$opt" in
4982efc3265Sbellard  --help|-h) show_help=yes
4992efc3265Sbellard  ;;
50099123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
50199123e13SMike Frysinger  ;;
502b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5037d13299dSbellard  ;;
504b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
50532ce6337Sbellard  ;;
506ca4deeb1SPaolo Bonzini  --source-path=*)
5077d13299dSbellard  ;;
508ac0df51dSaliguori  --cross-prefix=*)
5097d13299dSbellard  ;;
510ac0df51dSaliguori  --cc=*)
5117d13299dSbellard  ;;
512b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
51383469015Sbellard  ;;
514b1a550a0Spbrook  --make=*) make="$optarg"
5157d13299dSbellard  ;;
5166a882643Spbrook  --install=*) install="$optarg"
5176a882643Spbrook  ;;
518e2a2ed06SJuan Quintela  --extra-cflags=*)
5197d13299dSbellard  ;;
520e2a2ed06SJuan Quintela  --extra-ldflags=*)
5217d13299dSbellard  ;;
5222ff6b91eSJuan Quintela  --cpu=*)
5237d13299dSbellard  ;;
524b1a550a0Spbrook  --target-list=*) target_list="$optarg"
525de83cd02Sbellard  ;;
52674242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
52794a420b1SStefan Hajnoczi  ;;
52874242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
5299410b56cSPrerna Saxena  ;;
5307d13299dSbellard  --enable-gprof) gprof="yes"
5317d13299dSbellard  ;;
53279427693SLoïc Minier  --static)
53379427693SLoïc Minier    static="yes"
53479427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
53543ce4dfeSbellard  ;;
5360b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5370b24e75fSPaolo Bonzini  ;;
5380b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5390b24e75fSPaolo Bonzini  ;;
5403aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
5413aa5d2beSAlon Levy  ;;
5420b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5430b24e75fSPaolo Bonzini  ;;
5440b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5450b24e75fSPaolo Bonzini  ;;
546ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
54707381cc1SAnthony Liguori  ;;
54897a847bcSbellard  --disable-sdl) sdl="no"
54997a847bcSbellard  ;;
550c4198157SJuan Quintela  --enable-sdl) sdl="yes"
551c4198157SJuan Quintela  ;;
552821601eaSJes Sorensen  --disable-vnc) vnc="no"
553821601eaSJes Sorensen  ;;
554821601eaSJes Sorensen  --enable-vnc) vnc="yes"
555821601eaSJes Sorensen  ;;
556b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
557102a52e4Sbellard  ;;
558c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
559c2de5c91Smalc  ;;
5602f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5612f6a1ab0Sblueswir1  ;;
5622fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5630c58ac1cSmalc  ;;
5640c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5650c58ac1cSmalc  ;;
566eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
567eb852011SMarkus Armbruster  ;;
568f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
569f8393946Saurel32  ;;
570f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
571f8393946Saurel32  ;;
572b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
573b4475aa2SLuiz Capitulino  ;;
574b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
575b4475aa2SLuiz Capitulino  ;;
576f3d08ee6SPaul Brook  --enable-debug)
577f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
578f3d08ee6SPaul Brook      debug_tcg="yes"
579b4475aa2SLuiz Capitulino      debug_mon="yes"
580f3d08ee6SPaul Brook      debug="yes"
581f3d08ee6SPaul Brook      strip_opt="no"
582f3d08ee6SPaul Brook  ;;
58303b4fe7dSaliguori  --enable-sparse) sparse="yes"
58403b4fe7dSaliguori  ;;
58503b4fe7dSaliguori  --disable-sparse) sparse="no"
58603b4fe7dSaliguori  ;;
5871625af87Saliguori  --disable-strip) strip_opt="no"
5881625af87Saliguori  ;;
5898d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5908d5d2d4cSths  ;;
5911be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
5921be10ad2SJuan Quintela  ;;
5932f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
5942f9606b3Saliguori  ;;
595ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
596ea784e3bSJuan Quintela  ;;
5972f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
5982f6f5c7aSCorentin Chary  ;;
5992f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
6002f6f5c7aSCorentin Chary  ;;
601efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
602efe556adSCorentin Chary  ;;
603efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
604efe556adSCorentin Chary  ;;
605bd023f95SCorentin Chary  --disable-vnc-thread) vnc_thread="no"
606bd023f95SCorentin Chary  ;;
607bd023f95SCorentin Chary  --enable-vnc-thread) vnc_thread="yes"
608bd023f95SCorentin Chary  ;;
609443f1376Sbellard  --disable-slirp) slirp="no"
610c20709aaSbellard  ;;
611ee682d27SStefan Weil  --disable-uuid) uuid="no"
612ee682d27SStefan Weil  ;;
613ee682d27SStefan Weil  --enable-uuid) uuid="yes"
614ee682d27SStefan Weil  ;;
615e0e6c8c0Saliguori  --disable-vde) vde="no"
6168a16d273Sths  ;;
617dfb278bdSJuan Quintela  --enable-vde) vde="yes"
618dfb278bdSJuan Quintela  ;;
619e37630caSaliguori  --disable-xen) xen="no"
620e37630caSaliguori  ;;
621fc321b4bSJuan Quintela  --enable-xen) xen="yes"
622fc321b4bSJuan Quintela  ;;
6232e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
6242e4d9fb1Saurel32  ;;
6254ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6264ffcedb6SJuan Quintela  ;;
627fb599c9aSbalrog  --disable-bluez) bluez="no"
628fb599c9aSbalrog  ;;
629a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
630a20a6f46SJuan Quintela  ;;
6317ba1e619Saliguori  --disable-kvm) kvm="no"
6327ba1e619Saliguori  ;;
633b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
634b31a0277SJuan Quintela  ;;
635cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
636cd4ec0b4SGerd Hoffmann  ;;
637cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
638cd4ec0b4SGerd Hoffmann  ;;
63905c2a3e7Sbellard  --enable-profiler) profiler="yes"
64005c2a3e7Sbellard  ;;
641c2de5c91Smalc  --enable-cocoa)
642c2de5c91Smalc      cocoa="yes" ;
643c2de5c91Smalc      sdl="no" ;
644c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6455b0753e0Sbellard  ;;
646cad25d69Spbrook  --disable-system) softmmu="no"
6470a8e90f4Spbrook  ;;
648cad25d69Spbrook  --enable-system) softmmu="yes"
6490a8e90f4Spbrook  ;;
6500953a80fSZachary Amsden  --disable-user)
6510953a80fSZachary Amsden      linux_user="no" ;
6520953a80fSZachary Amsden      bsd_user="no" ;
6530953a80fSZachary Amsden      darwin_user="no"
6540953a80fSZachary Amsden  ;;
6550953a80fSZachary Amsden  --enable-user) ;;
656831b7825Sths  --disable-linux-user) linux_user="no"
6570a8e90f4Spbrook  ;;
658831b7825Sths  --enable-linux-user) linux_user="yes"
659831b7825Sths  ;;
660831b7825Sths  --disable-darwin-user) darwin_user="no"
661831b7825Sths  ;;
662831b7825Sths  --enable-darwin-user) darwin_user="yes"
6630a8e90f4Spbrook  ;;
66484778508Sblueswir1  --disable-bsd-user) bsd_user="no"
66584778508Sblueswir1  ;;
66684778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
66784778508Sblueswir1  ;;
668379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
669379f6698SPaul Brook  ;;
670379f6698SPaul Brook  --disable-guest-base) guest_base="no"
671379f6698SPaul Brook  ;;
67234005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
67334005a00SKirill A. Shutemov  ;;
67434005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
67534005a00SKirill A. Shutemov  ;;
676c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
677c5937220Spbrook  ;;
6783142255cSblueswir1  --sparc_cpu=*)
6793142255cSblueswir1  ;;
68085aa5189Sbellard  --enable-werror) werror="yes"
68185aa5189Sbellard  ;;
68285aa5189Sbellard  --disable-werror) werror="no"
68385aa5189Sbellard  ;;
6844d3b6f6eSbalrog  --disable-curses) curses="no"
6854d3b6f6eSbalrog  ;;
686c584a6d0SJuan Quintela  --enable-curses) curses="yes"
687c584a6d0SJuan Quintela  ;;
688769ce76dSAlexander Graf  --disable-curl) curl="no"
689769ce76dSAlexander Graf  ;;
690788c8196SJuan Quintela  --enable-curl) curl="yes"
691788c8196SJuan Quintela  ;;
6922df87df7SJuan Quintela  --disable-fdt) fdt="no"
6932df87df7SJuan Quintela  ;;
6942df87df7SJuan Quintela  --enable-fdt) fdt="yes"
6952df87df7SJuan Quintela  ;;
6965495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
6975495ed11SLuiz Capitulino  ;;
6985495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
6995495ed11SLuiz Capitulino  ;;
700bd0c5661Spbrook  --disable-nptl) nptl="no"
701bd0c5661Spbrook  ;;
702b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
703b0a47e79SJuan Quintela  ;;
7048ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
7058ff9cbf7Smalc  ;;
7065c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
7075c6c3a6cSChristoph Hellwig  ;;
7085c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
7095c6c3a6cSChristoph Hellwig  ;;
710758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
711758e8e38SVenkateswararao Jujjuri (JV)  ;;
712758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
713758e8e38SVenkateswararao Jujjuri (JV)  ;;
714e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
715e5d355d1Saliguori  ;;
71677755340Sths  --disable-blobs) blobs="no"
71777755340Sths  ;;
718eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
719eac30262Saliguori  ;;
7204a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
7214a19f1ecSpbrook  ;;
722a25dba17SJuan Quintela  --disable-docs) docs="no"
72370ec5dc0SAnthony Liguori  ;;
724a25dba17SJuan Quintela  --enable-docs) docs="yes"
72583a3ab8bSJuan Quintela  ;;
726d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
727d5970055SMichael S. Tsirkin  ;;
728d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
729d5970055SMichael S. Tsirkin  ;;
73020ff075bSMichael Walle  --disable-opengl) opengl="no"
73120ff075bSMichael Walle  ;;
73220ff075bSMichael Walle  --enable-opengl) opengl="yes"
73320ff075bSMichael Walle  ;;
7346bde81cbSPaolo Bonzini  --*dir)
7356bde81cbSPaolo Bonzini  ;;
736f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
737f27aaf4bSChristian Brunner  ;;
738f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
739f27aaf4bSChristian Brunner  ;;
74036707144SAlon Levy  --disable-smartcard) smartcard="no"
74136707144SAlon Levy  ;;
74236707144SAlon Levy  --enable-smartcard) smartcard="yes"
74336707144SAlon Levy  ;;
744111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
745111a38b0SRobert Relyea  ;;
746111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
747111a38b0SRobert Relyea  ;;
7487f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7497f1559c6Sbalrog  ;;
7507d13299dSbellard  esac
7517d13299dSbellarddone
7527d13299dSbellard
7533142255cSblueswir1#
7543142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
755a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7563142255cSblueswir1#
757379f6698SPaul Brookhost_guest_base="no"
75840293e58Sbellardcase "$cpu" in
759ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
760ed968ff1SJuan Quintela           v7|v8)
761a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
762ed968ff1SJuan Quintela           ;;
763ed968ff1SJuan Quintela           v8plus|v8plusa)
764a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
765ed968ff1SJuan Quintela           ;;
766ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
767a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
768ed968ff1SJuan Quintela           esac
7690c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
770a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
771762e8230Sblueswir1           if test "$solaris" = "no" ; then
772a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
773c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
774762e8230Sblueswir1           fi
7753142255cSblueswir1           ;;
776ed968ff1SJuan Quintela    sparc64)
777a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7780c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
779a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
780ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
781a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
782762e8230Sblueswir1           fi
7833142255cSblueswir1           ;;
78476d83bdeSths    s390)
78528d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
78628d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
78748bb3750SRichard Henderson           host_guest_base="yes"
78828d7cc49SRichard Henderson           ;;
78928d7cc49SRichard Henderson    s390x)
79028d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
79128d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
79248bb3750SRichard Henderson           host_guest_base="yes"
79376d83bdeSths           ;;
79440293e58Sbellard    i386)
795a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
7960c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
7972b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
798c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
799379f6698SPaul Brook           host_guest_base="yes"
80040293e58Sbellard           ;;
80140293e58Sbellard    x86_64)
802a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
8030c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8042b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
805379f6698SPaul Brook           host_guest_base="yes"
806379f6698SPaul Brook           ;;
807379f6698SPaul Brook    arm*)
808379f6698SPaul Brook           host_guest_base="yes"
80940293e58Sbellard           ;;
810f6548c0aSmalc    ppc*)
811f6548c0aSmalc           host_guest_base="yes"
812f6548c0aSmalc           ;;
813cc01cc8eSAurelien Jarno    mips*)
814cc01cc8eSAurelien Jarno           host_guest_base="yes"
815cc01cc8eSAurelien Jarno           ;;
816477ba620SAurelien Jarno    ia64*)
817477ba620SAurelien Jarno           host_guest_base="yes"
818477ba620SAurelien Jarno           ;;
819fd76e73aSRichard Henderson    hppa*)
820fd76e73aSRichard Henderson           host_guest_base="yes"
821fd76e73aSRichard Henderson           ;;
822d2fbca94SGuan Xuetao    unicore32*)
823d2fbca94SGuan Xuetao           host_guest_base="yes"
824d2fbca94SGuan Xuetao           ;;
8253142255cSblueswir1esac
8263142255cSblueswir1
827379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
828379f6698SPaul Brook
82960e0df25SPeter Maydell
83060e0df25SPeter Maydelldefault_target_list=""
83160e0df25SPeter Maydell
83260e0df25SPeter Maydell# these targets are portable
83360e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
83460e0df25SPeter Maydell    default_target_list="\
83560e0df25SPeter Maydelli386-softmmu \
83660e0df25SPeter Maydellx86_64-softmmu \
837b758aca1SRichard Hendersonalpha-softmmu \
83860e0df25SPeter Maydellarm-softmmu \
83960e0df25SPeter Maydellcris-softmmu \
84060e0df25SPeter Maydelllm32-softmmu \
84160e0df25SPeter Maydellm68k-softmmu \
84260e0df25SPeter Maydellmicroblaze-softmmu \
84360e0df25SPeter Maydellmicroblazeel-softmmu \
84460e0df25SPeter Maydellmips-softmmu \
84560e0df25SPeter Maydellmipsel-softmmu \
84660e0df25SPeter Maydellmips64-softmmu \
84760e0df25SPeter Maydellmips64el-softmmu \
84860e0df25SPeter Maydellppc-softmmu \
84960e0df25SPeter Maydellppcemb-softmmu \
85060e0df25SPeter Maydellppc64-softmmu \
85160e0df25SPeter Maydellsh4-softmmu \
85260e0df25SPeter Maydellsh4eb-softmmu \
85360e0df25SPeter Maydellsparc-softmmu \
85460e0df25SPeter Maydellsparc64-softmmu \
8550f3301d4SAlexander Grafs390x-softmmu \
85660e0df25SPeter Maydell"
85760e0df25SPeter Maydellfi
85860e0df25SPeter Maydell# the following are Linux specific
85960e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
86060e0df25SPeter Maydell    default_target_list="${default_target_list}\
86160e0df25SPeter Maydelli386-linux-user \
86260e0df25SPeter Maydellx86_64-linux-user \
86360e0df25SPeter Maydellalpha-linux-user \
86460e0df25SPeter Maydellarm-linux-user \
86560e0df25SPeter Maydellarmeb-linux-user \
86660e0df25SPeter Maydellcris-linux-user \
86760e0df25SPeter Maydellm68k-linux-user \
86860e0df25SPeter Maydellmicroblaze-linux-user \
86960e0df25SPeter Maydellmicroblazeel-linux-user \
87060e0df25SPeter Maydellmips-linux-user \
87160e0df25SPeter Maydellmipsel-linux-user \
87260e0df25SPeter Maydellppc-linux-user \
87360e0df25SPeter Maydellppc64-linux-user \
87460e0df25SPeter Maydellppc64abi32-linux-user \
87560e0df25SPeter Maydellsh4-linux-user \
87660e0df25SPeter Maydellsh4eb-linux-user \
87760e0df25SPeter Maydellsparc-linux-user \
87860e0df25SPeter Maydellsparc64-linux-user \
87960e0df25SPeter Maydellsparc32plus-linux-user \
88060e0df25SPeter Maydellunicore32-linux-user \
8810f3301d4SAlexander Grafs390x-linux-user \
88260e0df25SPeter Maydell"
88360e0df25SPeter Maydellfi
88460e0df25SPeter Maydell# the following are Darwin specific
88560e0df25SPeter Maydellif [ "$darwin_user" = "yes" ] ; then
88660e0df25SPeter Maydell    default_target_list="$default_target_list i386-darwin-user ppc-darwin-user "
88760e0df25SPeter Maydellfi
88860e0df25SPeter Maydell# the following are BSD specific
88960e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
89060e0df25SPeter Maydell    default_target_list="${default_target_list}\
89160e0df25SPeter Maydelli386-bsd-user \
89260e0df25SPeter Maydellx86_64-bsd-user \
89360e0df25SPeter Maydellsparc-bsd-user \
89460e0df25SPeter Maydellsparc64-bsd-user \
89560e0df25SPeter Maydell"
89660e0df25SPeter Maydellfi
89760e0df25SPeter Maydell
898af5db58eSpbrookif test x"$show_help" = x"yes" ; then
899af5db58eSpbrookcat << EOF
900af5db58eSpbrook
901af5db58eSpbrookUsage: configure [options]
902af5db58eSpbrookOptions: [defaults in brackets after descriptions]
903af5db58eSpbrook
904af5db58eSpbrookEOF
905af5db58eSpbrookecho "Standard options:"
906af5db58eSpbrookecho "  --help                   print this message"
907af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
908af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
909af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
91060e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
91160e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
91260e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
913af5db58eSpbrookecho ""
914af5db58eSpbrookecho "Advanced options (experts only):"
915af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
916af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
917af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
9180bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
9190bfe8cc0SPaolo Bonziniecho "                           build time"
920a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
921e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
922af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
9236a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
924af5db58eSpbrookecho "  --static                 enable static build [$static]"
9250b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
9260b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
9270b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
9280b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
9290b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
930f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
931f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
93209695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
933890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
934890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
9351625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
93685aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
937fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
938c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
939821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
940821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
941af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
942c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
943c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
9444c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
9454c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
946eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
947eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
9488ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
949e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
950fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
9512e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
9524ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
9538d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
9541be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
9552f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
956ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
9572f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
9582f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
95996763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
960efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
961bd023f95SCorentin Charyecho "  --disable-vnc-thread     disable threaded VNC server"
962bd023f95SCorentin Charyecho "  --enable-vnc-thread      enable threaded VNC server"
963af896aaaSpbrookecho "  --disable-curses         disable curses output"
964c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
965769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
966788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
9672df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
9682df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
9695495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
9705495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
971fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
972a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
9736093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
9747ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
975b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
976bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
977e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
978af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
979af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
9800953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
9810953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
982831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
983831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
984831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
985831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
98684778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
98784778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
988379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
989379f6698SPaul Brookecho "                           emulation targets"
990379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
99134005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
99234005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
993af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
994af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
9952f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
996c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
9973142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
998ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
999ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1000e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1001dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
10025c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
10035c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
1004758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1005758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
1006e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
100777755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1008eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
1009d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1010d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1011d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1012d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1013320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1014320fba2aSFabien Chouteauecho "                           Available backends:" $("$source_path"/scripts/tracetool --list-backends)
101574242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
10169410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1017cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1018cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1019f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
102036707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
102136707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1022111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1023111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
1024af5db58eSpbrookecho ""
10255bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1026af5db58eSpbrookexit 1
1027af5db58eSpbrookfi
1028af5db58eSpbrook
10298d05095cSPaolo Bonzini# check that the C compiler works.
10308d05095cSPaolo Bonzinicat > $TMPC <<EOF
10318d05095cSPaolo Bonziniint main(void) {}
10328d05095cSPaolo BonziniEOF
10338d05095cSPaolo Bonzini
10348d05095cSPaolo Bonziniif compile_object ; then
10358d05095cSPaolo Bonzini  : C compiler works ok
10368d05095cSPaolo Bonzinielse
10378d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
10388d05095cSPaolo Bonzini    exit 1
10398d05095cSPaolo Bonzinifi
10408d05095cSPaolo Bonzini
10418d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
10428d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
10438d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1044f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
10458d05095cSPaolo Bonzinicat > $TMPC << EOF
10468d05095cSPaolo Bonziniint main(void) { return 0; }
10478d05095cSPaolo BonziniEOF
10488d05095cSPaolo Bonzinifor flag in $gcc_flags; do
10498d05095cSPaolo Bonzini    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
10508d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
10518d05095cSPaolo Bonzini    fi
10528d05095cSPaolo Bonzinidone
10538d05095cSPaolo Bonzini
1054ec530c81Sbellard#
1055ec530c81Sbellard# Solaris specific configure tool chain decisions
1056ec530c81Sbellard#
1057ec530c81Sbellardif test "$solaris" = "yes" ; then
10586792aa11SLoïc Minier  if has $install; then
10596792aa11SLoïc Minier    :
10606792aa11SLoïc Minier  else
1061ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1062ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1063ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1064ec530c81Sbellard    exit 1
1065ec530c81Sbellard  fi
10666792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1067ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1068ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1069ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1070ec530c81Sbellard    exit 1
1071ec530c81Sbellard  fi
10726792aa11SLoïc Minier  if has ar; then
10736792aa11SLoïc Minier    :
10746792aa11SLoïc Minier  else
1075ec530c81Sbellard    echo "Error: No path includes ar"
1076ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1077ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1078ec530c81Sbellard    fi
1079ec530c81Sbellard    exit 1
1080ec530c81Sbellard  fi
1081ec530c81Sbellardfi
1082ec530c81Sbellard
10835327cf48Sbellardif test -z "$target_list" ; then
108460e0df25SPeter Maydell    target_list="$default_target_list"
10856e20a45fSbellardelse
1086b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
10875327cf48Sbellardfi
10880a8e90f4Spbrookif test -z "$target_list" ; then
10890a8e90f4Spbrook    echo "No targets enabled"
10900a8e90f4Spbrook    exit 1
10910a8e90f4Spbrookfi
1092f55fe278SPaolo Bonzini# see if system emulation was really requested
1093f55fe278SPaolo Bonzinicase " $target_list " in
1094f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1095f55fe278SPaolo Bonzini  ;;
1096f55fe278SPaolo Bonzini  *) softmmu=no
1097f55fe278SPaolo Bonzini  ;;
1098f55fe278SPaolo Bonziniesac
10995327cf48Sbellard
1100249247c9SJuan Quintelafeature_not_found() {
1101249247c9SJuan Quintela  feature=$1
1102249247c9SJuan Quintela
1103249247c9SJuan Quintela  echo "ERROR"
1104249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
11059332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1106249247c9SJuan Quintela  echo "ERROR"
1107249247c9SJuan Quintela  exit 1;
1108249247c9SJuan Quintela}
1109249247c9SJuan Quintela
11107d13299dSbellardif test -z "$cross_prefix" ; then
11117d13299dSbellard
11127d13299dSbellard# ---
11137d13299dSbellard# big/little endian test
11147d13299dSbellardcat > $TMPC << EOF
11157d13299dSbellard#include <inttypes.h>
11167d13299dSbellardint main(int argc, char ** argv){
11177d13299dSbellard        volatile uint32_t i=0x01234567;
11187d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
11197d13299dSbellard}
11207d13299dSbellardEOF
11217d13299dSbellard
112252166aa0SJuan Quintelaif compile_prog "" "" ; then
11237d13299dSbellard$TMPE && bigendian="yes"
11247d13299dSbellardelse
11257d13299dSbellardecho big/little test failed
11267d13299dSbellardfi
11277d13299dSbellard
11287d13299dSbellardelse
11297d13299dSbellard
11307d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1131ea8f20f8SJuan Quintelacase "$cpu" in
113224e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1133ea8f20f8SJuan Quintela    bigendian=yes
1134ea8f20f8SJuan Quintela  ;;
1135ea8f20f8SJuan Quintelaesac
11367d13299dSbellard
11377d13299dSbellardfi
11387d13299dSbellard
113970be1a2eSPaolo Bonzini# host long bits test, actually a pointer size test
114070be1a2eSPaolo Bonzinicat > $TMPC << EOF
114170be1a2eSPaolo Bonziniint sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
114270be1a2eSPaolo BonziniEOF
114370be1a2eSPaolo Bonziniif compile_object; then
1144ea8f20f8SJuan Quintelahostlongbits=64
114570be1a2eSPaolo Bonzinielse
114670be1a2eSPaolo Bonzinihostlongbits=32
114770be1a2eSPaolo Bonzinifi
1148b6853697Sbellard
1149b0a47e79SJuan Quintela
1150b0a47e79SJuan Quintela##########################################
1151b0a47e79SJuan Quintela# NPTL probe
1152b0a47e79SJuan Quintela
1153b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1154bd0c5661Spbrook  cat > $TMPC <<EOF
1155bd0c5661Spbrook#include <sched.h>
115630813ceaSpbrook#include <linux/futex.h>
1157bd0c5661Spbrookvoid foo()
1158bd0c5661Spbrook{
1159bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1160bd0c5661Spbrook#error bork
1161bd0c5661Spbrook#endif
1162bd0c5661Spbrook}
1163bd0c5661SpbrookEOF
1164bd0c5661Spbrook
116552166aa0SJuan Quintela  if compile_object ; then
1166b0a47e79SJuan Quintela    nptl=yes
1167bd0c5661Spbrook  else
1168b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1169b0a47e79SJuan Quintela      feature_not_found "nptl"
1170b0a47e79SJuan Quintela    fi
1171b0a47e79SJuan Quintela    nptl=no
1172b0a47e79SJuan Quintela  fi
1173bd0c5661Spbrookfi
1174bd0c5661Spbrook
117511d9f695Sbellard##########################################
1176ac62922eSbalrog# zlib check
1177ac62922eSbalrog
1178ac62922eSbalrogcat > $TMPC << EOF
1179ac62922eSbalrog#include <zlib.h>
1180ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1181ac62922eSbalrogEOF
118252166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
1183ac62922eSbalrog    :
1184ac62922eSbalrogelse
1185ac62922eSbalrog    echo
1186ac62922eSbalrog    echo "Error: zlib check failed"
1187ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
1188ac62922eSbalrog    echo
1189ac62922eSbalrog    exit 1
1190ac62922eSbalrogfi
1191ac62922eSbalrog
1192ac62922eSbalrog##########################################
1193e37630caSaliguori# xen probe
1194e37630caSaliguori
1195fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1196b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1197d5b93ddfSAnthony PERARD
1198d5b93ddfSAnthony PERARD  # Xen unstable
1199e37630caSaliguori  cat > $TMPC <<EOF
1200e37630caSaliguori#include <xenctrl.h>
1201e37630caSaliguori#include <xs.h>
1202d5b93ddfSAnthony PERARD#include <stdint.h>
1203d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1204d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1205d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1206d5b93ddfSAnthony PERARD#endif
1207d5b93ddfSAnthony PERARDint main(void) {
1208d5b93ddfSAnthony PERARD  xc_interface *xc;
1209d5b93ddfSAnthony PERARD  xs_daemon_open();
1210d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1211d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1212d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1213*b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1214d5b93ddfSAnthony PERARD  return 0;
1215d5b93ddfSAnthony PERARD}
1216e37630caSaliguoriEOF
121752166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1218d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1219fc321b4bSJuan Quintela    xen=yes
1220d5b93ddfSAnthony PERARD
1221d5b93ddfSAnthony PERARD  # Xen 4.0.0
1222d5b93ddfSAnthony PERARD  elif (
1223d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1224d5b93ddfSAnthony PERARD#include <xenctrl.h>
1225d5b93ddfSAnthony PERARD#include <xs.h>
1226d5b93ddfSAnthony PERARD#include <stdint.h>
1227d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1228d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1229d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1230d5b93ddfSAnthony PERARD#endif
1231d5b93ddfSAnthony PERARDint main(void) {
1232*b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1233*b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1234*b87de24eSAnthony PERARD  };
1235d5b93ddfSAnthony PERARD  xs_daemon_open();
1236d5b93ddfSAnthony PERARD  xc_interface_open();
1237d5b93ddfSAnthony PERARD  xc_gnttab_open();
1238d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1239*b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1240d5b93ddfSAnthony PERARD  return 0;
1241d5b93ddfSAnthony PERARD}
1242d5b93ddfSAnthony PERARDEOF
1243d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1244d5b93ddfSAnthony PERARD    ) ; then
1245d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1246d5b93ddfSAnthony PERARD    xen=yes
1247d5b93ddfSAnthony PERARD
1248*b87de24eSAnthony PERARD  # Xen 3.4.0
1249*b87de24eSAnthony PERARD  elif (
1250*b87de24eSAnthony PERARD      cat > $TMPC <<EOF
1251*b87de24eSAnthony PERARD#include <xenctrl.h>
1252*b87de24eSAnthony PERARD#include <xs.h>
1253*b87de24eSAnthony PERARDint main(void) {
1254*b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1255*b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1256*b87de24eSAnthony PERARD  };
1257*b87de24eSAnthony PERARD  xs_daemon_open();
1258*b87de24eSAnthony PERARD  xc_interface_open();
1259*b87de24eSAnthony PERARD  xc_gnttab_open();
1260*b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1261*b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1262*b87de24eSAnthony PERARD  return 0;
1263*b87de24eSAnthony PERARD}
1264*b87de24eSAnthony PERARDEOF
1265*b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
1266*b87de24eSAnthony PERARD    ) ; then
1267*b87de24eSAnthony PERARD    xen_ctrl_version=340
1268*b87de24eSAnthony PERARD    xen=yes
1269*b87de24eSAnthony PERARD
1270*b87de24eSAnthony PERARD  # Xen 3.3.0
1271d5b93ddfSAnthony PERARD  elif (
1272d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1273d5b93ddfSAnthony PERARD#include <xenctrl.h>
1274d5b93ddfSAnthony PERARD#include <xs.h>
1275d5b93ddfSAnthony PERARDint main(void) {
1276d5b93ddfSAnthony PERARD  xs_daemon_open();
1277d5b93ddfSAnthony PERARD  xc_interface_open();
1278d5b93ddfSAnthony PERARD  xc_gnttab_open();
1279d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1280d5b93ddfSAnthony PERARD  return 0;
1281d5b93ddfSAnthony PERARD}
1282d5b93ddfSAnthony PERARDEOF
1283d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1284d5b93ddfSAnthony PERARD    ) ; then
1285d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1286d5b93ddfSAnthony PERARD    xen=yes
1287d5b93ddfSAnthony PERARD
1288d5b93ddfSAnthony PERARD  # Xen not found or unsupported
1289e37630caSaliguori  else
1290fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1291fc321b4bSJuan Quintela      feature_not_found "xen"
1292fc321b4bSJuan Quintela    fi
1293fc321b4bSJuan Quintela    xen=no
1294e37630caSaliguori  fi
1295d5b93ddfSAnthony PERARD
1296d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1297d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1298d5b93ddfSAnthony PERARD  fi
1299e37630caSaliguorifi
1300e37630caSaliguori
1301e37630caSaliguori##########################################
1302a8bd70adSPaolo Bonzini# pkg-config probe
1303f91672e5SPaolo Bonzini
1304a8bd70adSPaolo Bonziniif ! has $pkg_config; then
130508421541SPaolo Bonzini  echo warning: proceeding without "$pkg_config" >&2
130608421541SPaolo Bonzini  pkg_config=/bin/false
1307f91672e5SPaolo Bonzinifi
1308f91672e5SPaolo Bonzini
1309f91672e5SPaolo Bonzini##########################################
131044dc0ca3SAlon Levy# libtool probe
131144dc0ca3SAlon Levy
131244dc0ca3SAlon Levyif ! has libtool; then
131344dc0ca3SAlon Levy    libtool=
131444dc0ca3SAlon Levyelse
131544dc0ca3SAlon Levy    libtool=libtool
131644dc0ca3SAlon Levyfi
131744dc0ca3SAlon Levy
131844dc0ca3SAlon Levy##########################################
1319dfffc653SJuan Quintela# Sparse probe
1320dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
13210dba6195SLoïc Minier  if has cgcc; then
1322dfffc653SJuan Quintela    sparse=yes
1323dfffc653SJuan Quintela  else
1324dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1325dfffc653SJuan Quintela      feature_not_found "sparse"
1326dfffc653SJuan Quintela    fi
1327dfffc653SJuan Quintela    sparse=no
1328dfffc653SJuan Quintela  fi
1329dfffc653SJuan Quintelafi
1330dfffc653SJuan Quintela
1331dfffc653SJuan Quintela##########################################
133211d9f695Sbellard# SDL probe
133311d9f695Sbellard
13343ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
13353ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
13363ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
13373ec87ffeSPaolo Bonzini  sdl_config=sdl-config
13383ec87ffeSPaolo Bonzinifi
13393ec87ffeSPaolo Bonzini
13403ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1341a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1342fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
13433ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
13443ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
13459316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1346a0dfd8a4SLoïc Minierelse
1347a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1348a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1349a0dfd8a4SLoïc Minier  fi
1350a0dfd8a4SLoïc Minier  sdl=no
13519316f803SPaolo Bonzinifi
135229e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
13533ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
13543ec87ffeSPaolo Bonzinifi
135511d9f695Sbellard
13569316f803SPaolo Bonzinisdl_too_old=no
1357c4198157SJuan Quintelaif test "$sdl" != "no" ; then
135811d9f695Sbellard  cat > $TMPC << EOF
135911d9f695Sbellard#include <SDL.h>
136011d9f695Sbellard#undef main /* We don't want SDL to override our main() */
136111d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
136211d9f695SbellardEOF
13639316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
136474f42e18STeLeMan  if test "$static" = "yes" ; then
136574f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
136674f42e18STeLeMan  else
13679316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
136874f42e18STeLeMan  fi
136952166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
137011d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
137111d9f695Sbellard      sdl_too_old=yes
137211d9f695Sbellard    else
1373fd677642Sths      if test "$cocoa" = "no" ; then
137411d9f695Sbellard        sdl=yes
137511d9f695Sbellard      fi
1376fd677642Sths    fi
13777c1f25b4Sbellard
137867c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
13791ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
138067c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1381f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1382f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
138311d9f695Sbellard      fi
138452166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
13851ac88f28SJuan Quintela	:
13861ac88f28SJuan Quintela      else
13871ac88f28SJuan Quintela        sdl=no
13887c1f25b4Sbellard      fi
13897c1f25b4Sbellard    fi # static link
1390c4198157SJuan Quintela  else # sdl not found
1391c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1392c4198157SJuan Quintela      feature_not_found "sdl"
1393c4198157SJuan Quintela    fi
1394c4198157SJuan Quintela    sdl=no
13957c1f25b4Sbellard  fi # sdl compile test
1396fd677642Sthsfi
139711d9f695Sbellard
13985368a422Saliguoriif test "$sdl" = "yes" ; then
13995368a422Saliguori  cat > $TMPC <<EOF
14005368a422Saliguori#include <SDL.h>
14015368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
14025368a422Saliguori#include <X11/XKBlib.h>
14035368a422Saliguori#else
14045368a422Saliguori#error No x11 support
14055368a422Saliguori#endif
14065368a422Saliguoriint main(void) { return 0; }
14075368a422SaliguoriEOF
140852166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1409681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
14105368a422Saliguori  fi
141107d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
141207d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
141307d9ac44SJuan Quintela  fi
14140705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
14155368a422Saliguorifi
14165368a422Saliguori
14178f28f3fbSths##########################################
14188d5d2d4cSths# VNC TLS detection
1419821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1420ae6b5e5aSaliguori  cat > $TMPC <<EOF
1421ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1422ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1423ae6b5e5aSaliguoriEOF
1424a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1425a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
142652166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
14271be10ad2SJuan Quintela    vnc_tls=yes
1428a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1429ae6b5e5aSaliguori  else
14301be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
14311be10ad2SJuan Quintela      feature_not_found "vnc-tls"
14321be10ad2SJuan Quintela    fi
14331be10ad2SJuan Quintela    vnc_tls=no
14348d5d2d4cSths  fi
14358d5d2d4cSthsfi
14368d5d2d4cSths
14378d5d2d4cSths##########################################
14382f9606b3Saliguori# VNC SASL detection
1439821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
14402f9606b3Saliguori  cat > $TMPC <<EOF
14412f9606b3Saliguori#include <sasl/sasl.h>
14422f9606b3Saliguori#include <stdio.h>
14432f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
14442f9606b3SaliguoriEOF
14452f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
14462f9606b3Saliguori  vnc_sasl_cflags=""
14472f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
144852166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1449ea784e3bSJuan Quintela    vnc_sasl=yes
1450fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
14512f9606b3Saliguori  else
1452ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1453ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1454ea784e3bSJuan Quintela    fi
1455ea784e3bSJuan Quintela    vnc_sasl=no
14562f9606b3Saliguori  fi
14572f9606b3Saliguorifi
14582f9606b3Saliguori
14592f9606b3Saliguori##########################################
14602f6f5c7aSCorentin Chary# VNC JPEG detection
1461821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
14622f6f5c7aSCorentin Charycat > $TMPC <<EOF
14632f6f5c7aSCorentin Chary#include <stdio.h>
14642f6f5c7aSCorentin Chary#include <jpeglib.h>
14652f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
14662f6f5c7aSCorentin CharyEOF
14672f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
14682f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
14692f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
14702f6f5c7aSCorentin Chary    vnc_jpeg=yes
14712f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
14722f6f5c7aSCorentin Chary  else
14732f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
14742f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
14752f6f5c7aSCorentin Chary    fi
14762f6f5c7aSCorentin Chary    vnc_jpeg=no
14772f6f5c7aSCorentin Chary  fi
14782f6f5c7aSCorentin Charyfi
14792f6f5c7aSCorentin Chary
14802f6f5c7aSCorentin Chary##########################################
1481efe556adSCorentin Chary# VNC PNG detection
1482821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1483efe556adSCorentin Charycat > $TMPC <<EOF
1484efe556adSCorentin Chary//#include <stdio.h>
1485efe556adSCorentin Chary#include <png.h>
1486832ce9c2SScott Wood#include <stddef.h>
1487efe556adSCorentin Charyint main(void) {
1488efe556adSCorentin Chary    png_structp png_ptr;
1489efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1490efe556adSCorentin Chary    return 0;
1491efe556adSCorentin Chary}
1492efe556adSCorentin CharyEOF
1493efe556adSCorentin Chary    vnc_png_cflags=""
1494efe556adSCorentin Chary    vnc_png_libs="-lpng"
1495efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1496efe556adSCorentin Chary    vnc_png=yes
1497efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
1498efe556adSCorentin Chary  else
1499efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1500efe556adSCorentin Chary      feature_not_found "vnc-png"
1501efe556adSCorentin Chary    fi
1502efe556adSCorentin Chary    vnc_png=no
1503efe556adSCorentin Chary  fi
1504efe556adSCorentin Charyfi
1505efe556adSCorentin Chary
1506efe556adSCorentin Chary##########################################
150776655d6dSaliguori# fnmatch() probe, used for ACL routines
150876655d6dSaliguorifnmatch="no"
150976655d6dSaliguoricat > $TMPC << EOF
151076655d6dSaliguori#include <fnmatch.h>
151176655d6dSaliguoriint main(void)
151276655d6dSaliguori{
151376655d6dSaliguori    fnmatch("foo", "foo", 0);
151476655d6dSaliguori    return 0;
151576655d6dSaliguori}
151676655d6dSaliguoriEOF
151752166aa0SJuan Quintelaif compile_prog "" "" ; then
151876655d6dSaliguori   fnmatch="yes"
151976655d6dSaliguorifi
152076655d6dSaliguori
152176655d6dSaliguori##########################################
1522ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1523ee682d27SStefan Weilif test "$uuid" != "no" ; then
1524ee682d27SStefan Weil  uuid_libs="-luuid"
1525ee682d27SStefan Weil  cat > $TMPC << EOF
1526ee682d27SStefan Weil#include <uuid/uuid.h>
1527ee682d27SStefan Weilint main(void)
1528ee682d27SStefan Weil{
1529ee682d27SStefan Weil    uuid_t my_uuid;
1530ee682d27SStefan Weil    uuid_generate(my_uuid);
1531ee682d27SStefan Weil    return 0;
1532ee682d27SStefan Weil}
1533ee682d27SStefan WeilEOF
1534ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1535ee682d27SStefan Weil    uuid="yes"
1536ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1537ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1538ee682d27SStefan Weil  else
1539ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1540ee682d27SStefan Weil      feature_not_found "uuid"
1541ee682d27SStefan Weil    fi
1542ee682d27SStefan Weil    uuid=no
1543ee682d27SStefan Weil  fi
1544ee682d27SStefan Weilfi
1545ee682d27SStefan Weil
1546ee682d27SStefan Weil##########################################
1547dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1548dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1549dce512deSChristoph Hellwig  cat > $TMPC << EOF
1550dce512deSChristoph Hellwig#include <xfs/xfs.h>
1551dce512deSChristoph Hellwigint main(void)
1552dce512deSChristoph Hellwig{
1553dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1554dce512deSChristoph Hellwig    return 0;
1555dce512deSChristoph Hellwig}
1556dce512deSChristoph HellwigEOF
1557dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1558dce512deSChristoph Hellwig    xfs="yes"
1559dce512deSChristoph Hellwig  else
1560dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1561dce512deSChristoph Hellwig      feature_not_found "xfs"
1562dce512deSChristoph Hellwig    fi
1563dce512deSChristoph Hellwig    xfs=no
1564dce512deSChristoph Hellwig  fi
1565dce512deSChristoph Hellwigfi
1566dce512deSChristoph Hellwig
1567dce512deSChristoph Hellwig##########################################
15688a16d273Sths# vde libraries probe
1569dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
15704baae0acSJuan Quintela  vde_libs="-lvdeplug"
15718a16d273Sths  cat > $TMPC << EOF
15728a16d273Sths#include <libvdeplug.h>
15734a7f0e06Spbrookint main(void)
15744a7f0e06Spbrook{
15754a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
15764a7f0e06Spbrook    vde_open("", "", &a);
15774a7f0e06Spbrook    return 0;
15784a7f0e06Spbrook}
15798a16d273SthsEOF
158052166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
15814baae0acSJuan Quintela    vde=yes
15828e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
15838e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1584dfb278bdSJuan Quintela  else
1585dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1586dfb278bdSJuan Quintela      feature_not_found "vde"
1587dfb278bdSJuan Quintela    fi
1588dfb278bdSJuan Quintela    vde=no
15898a16d273Sths  fi
15908a16d273Sthsfi
15918a16d273Sths
15928a16d273Sths##########################################
1593c2de5c91Smalc# Sound support libraries probe
15948f28f3fbSths
1595c2de5c91Smalcaudio_drv_probe()
1596c2de5c91Smalc{
1597c2de5c91Smalc    drv=$1
1598c2de5c91Smalc    hdr=$2
1599c2de5c91Smalc    lib=$3
1600c2de5c91Smalc    exp=$4
1601c2de5c91Smalc    cfl=$5
16028f28f3fbSths        cat > $TMPC << EOF
1603c2de5c91Smalc#include <$hdr>
1604c2de5c91Smalcint main(void) { $exp }
16058f28f3fbSthsEOF
160652166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
16078f28f3fbSths        :
16088f28f3fbSths    else
16098f28f3fbSths        echo
1610c2de5c91Smalc        echo "Error: $drv check failed"
1611c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
16128f28f3fbSths        echo
16138f28f3fbSths        exit 1
16148f28f3fbSths    fi
1615c2de5c91Smalc}
1616c2de5c91Smalc
16172fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1618c2de5c91Smalcfor drv in $audio_drv_list; do
1619c2de5c91Smalc    case $drv in
1620c2de5c91Smalc    alsa)
1621c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1622c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1623a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1624c2de5c91Smalc    ;;
1625c2de5c91Smalc
1626c2de5c91Smalc    fmod)
1627c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1628c2de5c91Smalc        echo
1629c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1630c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1631c2de5c91Smalc        echo
1632c2de5c91Smalc        exit 1
16338f28f3fbSths    fi
1634c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1635a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1636c2de5c91Smalc    ;;
1637c2de5c91Smalc
1638c2de5c91Smalc    esd)
1639c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1640a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
164167f86e8eSJuan Quintela    audio_pt_int="yes"
1642c2de5c91Smalc    ;;
1643b8e59f18Smalc
1644b8e59f18Smalc    pa)
1645493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1646b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1647493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
164867f86e8eSJuan Quintela    audio_pt_int="yes"
1649b8e59f18Smalc    ;;
1650b8e59f18Smalc
1651997e690aSJuan Quintela    coreaudio)
1652997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1653997e690aSJuan Quintela    ;;
1654997e690aSJuan Quintela
1655a4bf6780SJuan Quintela    dsound)
1656a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1657d5631638Smalc      audio_win_int="yes"
1658a4bf6780SJuan Quintela    ;;
1659a4bf6780SJuan Quintela
1660a4bf6780SJuan Quintela    oss)
1661a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1662a4bf6780SJuan Quintela    ;;
1663a4bf6780SJuan Quintela
1664a4bf6780SJuan Quintela    sdl|wav)
16652f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
16662f6a1ab0Sblueswir1    ;;
16672f6a1ab0Sblueswir1
1668d5631638Smalc    winwave)
1669d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1670d5631638Smalc      audio_win_int="yes"
1671d5631638Smalc    ;;
1672d5631638Smalc
1673e4c63a6aSmalc    *)
16741c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1675e4c63a6aSmalc        echo
1676e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1677e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1678e4c63a6aSmalc        echo
1679e4c63a6aSmalc        exit 1
1680e4c63a6aSmalc    }
1681e4c63a6aSmalc    ;;
1682c2de5c91Smalc    esac
1683c2de5c91Smalcdone
16848f28f3fbSths
16854d3b6f6eSbalrog##########################################
16862e4d9fb1Saurel32# BrlAPI probe
16872e4d9fb1Saurel32
16884ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1689eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
16902e4d9fb1Saurel32  cat > $TMPC << EOF
16912e4d9fb1Saurel32#include <brlapi.h>
1692832ce9c2SScott Wood#include <stddef.h>
16932e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
16942e4d9fb1Saurel32EOF
169552166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
16962e4d9fb1Saurel32    brlapi=yes
1697264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
16984ffcedb6SJuan Quintela  else
16994ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
17004ffcedb6SJuan Quintela      feature_not_found "brlapi"
17014ffcedb6SJuan Quintela    fi
17024ffcedb6SJuan Quintela    brlapi=no
1703eb82284fSJuan Quintela  fi
1704eb82284fSJuan Quintelafi
17052e4d9fb1Saurel32
17062e4d9fb1Saurel32##########################################
17074d3b6f6eSbalrog# curses probe
1708e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
1709e095e2f3SStefan Weil    curses_list="-lpdcurses"
1710e095e2f3SStefan Weilelse
17114f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
1712e095e2f3SStefan Weilfi
17134d3b6f6eSbalrog
1714c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1715c584a6d0SJuan Quintela  curses_found=no
17164d3b6f6eSbalrog  cat > $TMPC << EOF
17174d3b6f6eSbalrog#include <curses.h>
17185a8ff3aaSblueswir1#ifdef __OpenBSD__
17195a8ff3aaSblueswir1#define resize_term resizeterm
17205a8ff3aaSblueswir1#endif
17215a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
17224d3b6f6eSbalrogEOF
17234f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
17244f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1725c584a6d0SJuan Quintela      curses_found=yes
17264f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
17274f78ef9aSJuan Quintela      break
17284d3b6f6eSbalrog    fi
17294f78ef9aSJuan Quintela  done
1730c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1731c584a6d0SJuan Quintela    curses=yes
1732c584a6d0SJuan Quintela  else
1733c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1734c584a6d0SJuan Quintela      feature_not_found "curses"
1735c584a6d0SJuan Quintela    fi
1736c584a6d0SJuan Quintela    curses=no
1737c584a6d0SJuan Quintela  fi
17384f78ef9aSJuan Quintelafi
17394d3b6f6eSbalrog
1740414f0dabSblueswir1##########################################
1741769ce76dSAlexander Graf# curl probe
1742769ce76dSAlexander Graf
1743a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
1744a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
17454e2b0658SPaolo Bonzinielse
17464e2b0658SPaolo Bonzini  curlconfig=curl-config
17474e2b0658SPaolo Bonzinifi
17484e2b0658SPaolo Bonzini
1749788c8196SJuan Quintelaif test "$curl" != "no" ; then
1750769ce76dSAlexander Graf  cat > $TMPC << EOF
1751769ce76dSAlexander Graf#include <curl/curl.h>
17520b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
1753769ce76dSAlexander GrafEOF
17544e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
17554e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1756b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1757769ce76dSAlexander Graf    curl=yes
1758f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1759f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1760788c8196SJuan Quintela  else
1761788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1762788c8196SJuan Quintela      feature_not_found "curl"
1763788c8196SJuan Quintela    fi
1764788c8196SJuan Quintela    curl=no
1765769ce76dSAlexander Graf  fi
1766769ce76dSAlexander Graffi # test "$curl"
1767769ce76dSAlexander Graf
1768769ce76dSAlexander Graf##########################################
17695495ed11SLuiz Capitulino# check framework probe
17705495ed11SLuiz Capitulino
17715495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
17725495ed11SLuiz Capitulino  cat > $TMPC << EOF
17735495ed11SLuiz Capitulino#include <check.h>
17745495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
17755495ed11SLuiz CapitulinoEOF
1776a8bd70adSPaolo Bonzini  check_libs=`$pkg_config --libs check`
17775495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
17785495ed11SLuiz Capitulino    check_utests=yes
17795495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
17805495ed11SLuiz Capitulino  else
17815495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
17825495ed11SLuiz Capitulino      feature_not_found "check"
17835495ed11SLuiz Capitulino    fi
17845495ed11SLuiz Capitulino    check_utests=no
17855495ed11SLuiz Capitulino  fi
17865495ed11SLuiz Capitulinofi # test "$check_utests"
17875495ed11SLuiz Capitulino
17885495ed11SLuiz Capitulino##########################################
1789fb599c9aSbalrog# bluez support probe
1790a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1791e820e3f4Sbalrog  cat > $TMPC << EOF
1792e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1793e820e3f4Sbalrogint main(void) { return bt_error(0); }
1794e820e3f4SbalrogEOF
1795a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1796a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
179752166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1798a20a6f46SJuan Quintela    bluez=yes
1799e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1800e820e3f4Sbalrog  else
1801a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1802a20a6f46SJuan Quintela      feature_not_found "bluez"
1803a20a6f46SJuan Quintela    fi
1804e820e3f4Sbalrog    bluez="no"
1805e820e3f4Sbalrog  fi
1806fb599c9aSbalrogfi
1807fb599c9aSbalrog
1808fb599c9aSbalrog##########################################
18097ba1e619Saliguori# kvm probe
1810b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
18117ba1e619Saliguori    cat > $TMPC <<EOF
18127ba1e619Saliguori#include <linux/kvm.h>
18139fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
18147ba1e619Saliguori#error Invalid KVM version
18157ba1e619Saliguori#endif
181694a8d39aSJan KiszkaEOF
181794a8d39aSJan Kiszka    must_have_caps="KVM_CAP_USER_MEMORY \
181894a8d39aSJan Kiszka                    KVM_CAP_DESTROY_MEMORY_REGION_WORKS \
181994a8d39aSJan Kiszka                    KVM_CAP_COALESCED_MMIO \
182094a8d39aSJan Kiszka                    KVM_CAP_SYNC_MMU \
182194a8d39aSJan Kiszka                   "
182294a8d39aSJan Kiszka    if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) ; then
182394a8d39aSJan Kiszka      must_have_caps="$caps \
182494a8d39aSJan Kiszka                      KVM_CAP_SET_TSS_ADDR \
182594a8d39aSJan Kiszka                      KVM_CAP_EXT_CPUID \
182694a8d39aSJan Kiszka                      KVM_CAP_CLOCKSOURCE \
182794a8d39aSJan Kiszka                      KVM_CAP_NOP_IO_DELAY \
182894a8d39aSJan Kiszka                      KVM_CAP_PV_MMU \
182994a8d39aSJan Kiszka                      KVM_CAP_MP_STATE \
183094a8d39aSJan Kiszka                      KVM_CAP_USER_NMI \
183194a8d39aSJan Kiszka                     "
183294a8d39aSJan Kiszka    fi
183394a8d39aSJan Kiszka    for c in $must_have_caps ; do
183494a8d39aSJan Kiszka      cat >> $TMPC <<EOF
183594a8d39aSJan Kiszka#if !defined($c)
183694a8d39aSJan Kiszka#error Missing KVM capability $c
18379fd8d8d7Saliguori#endif
183894a8d39aSJan KiszkaEOF
183994a8d39aSJan Kiszka    done
184094a8d39aSJan Kiszka    cat >> $TMPC <<EOF
18417ba1e619Saliguoriint main(void) { return 0; }
18427ba1e619SaliguoriEOF
1843eac30262Saliguori  if test "$kerneldir" != "" ; then
1844eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
18458444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
18468444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
18478444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1848406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1849406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
18500e60a699SAlexander Graf	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
18510e60a699SAlexander Graf	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
18528444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
18538444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
18548444eb6eSaliguori      fi
1855eac30262Saliguori  else
1856a8bd70adSPaolo Bonzini    kvm_cflags=`$pkg_config --cflags kvm-kmod 2>/dev/null`
1857eac30262Saliguori  fi
185852166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1859b31a0277SJuan Quintela    kvm=yes
1860dae5079aSJan Kiszka    cat > $TMPC <<EOF
1861dae5079aSJan Kiszka#include <linux/kvm_para.h>
1862dae5079aSJan Kiszkaint main(void) { return 0; }
1863dae5079aSJan KiszkaEOF
1864dae5079aSJan Kiszka    if compile_prog "$kvm_cflags" "" ; then
1865dae5079aSJan Kiszka      kvm_para=yes
1866dae5079aSJan Kiszka    fi
18677ba1e619Saliguori  else
1868b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
18690dba6195SLoïc Minier      if has awk && has grep; then
1870a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
18719fd8d8d7Saliguori	| grep "error: " \
18729fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
18739fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1874b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1875168ccc11SJan KiszkaNOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1876168ccc11SJan Kiszkarecent kvm-kmod from http://sourceforge.net/projects/kvm."
18779fd8d8d7Saliguori        fi
18789fd8d8d7Saliguori      fi
1879b31a0277SJuan Quintela      feature_not_found "kvm"
1880b31a0277SJuan Quintela    fi
1881b31a0277SJuan Quintela    kvm=no
18827ba1e619Saliguori  fi
18837ba1e619Saliguorifi
18847ba1e619Saliguori
18857ba1e619Saliguori##########################################
188664e07be5SAlexander Graf# test for ppc kvm pvr setting
188764e07be5SAlexander Graf
188864e07be5SAlexander Grafif test "$kvm" = "yes" && test "$cpu" = "ppc" -o "$cpu" = "ppc64"; then
188964e07be5SAlexander Graf            cat > $TMPC <<EOF
189064e07be5SAlexander Graf    #include <asm/kvm.h>
189164e07be5SAlexander Graf    int main(void) { struct kvm_sregs s; s.pvr = 0; return 0; }
189264e07be5SAlexander GrafEOF
189364e07be5SAlexander Graf    if compile_prog "$kvm_cflags" "" ; then
189464e07be5SAlexander Graf        kvm_ppc_pvr=yes
189564e07be5SAlexander Graf    else
189664e07be5SAlexander Graf        kvm_ppc_pvr=no
189764e07be5SAlexander Graf    fi
189864e07be5SAlexander Graffi
189964e07be5SAlexander Graf
190064e07be5SAlexander Graf##########################################
1901d5970055SMichael S. Tsirkin# test for vhost net
1902d5970055SMichael S. Tsirkin
1903d5970055SMichael S. Tsirkinif test "$vhost_net" != "no"; then
1904d5970055SMichael S. Tsirkin    if test "$kvm" != "no"; then
1905d5970055SMichael S. Tsirkin            cat > $TMPC <<EOF
1906d5970055SMichael S. Tsirkin    #include <linux/vhost.h>
1907d5970055SMichael S. Tsirkin    int main(void) { return 0; }
1908d5970055SMichael S. TsirkinEOF
1909d5970055SMichael S. Tsirkin            if compile_prog "$kvm_cflags" "" ; then
1910d5970055SMichael S. Tsirkin                vhost_net=yes
1911d5970055SMichael S. Tsirkin            else
1912d5970055SMichael S. Tsirkin                if test "$vhost_net" = "yes" ; then
1913d5970055SMichael S. Tsirkin                    feature_not_found "vhost-net"
1914d5970055SMichael S. Tsirkin                fi
1915d5970055SMichael S. Tsirkin                vhost_net=no
1916d5970055SMichael S. Tsirkin            fi
1917d5970055SMichael S. Tsirkin    else
1918d5970055SMichael S. Tsirkin            if test "$vhost_net" = "yes" ; then
19194021d247SAurelien Jarno                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1920d5970055SMichael S. Tsirkin                feature_not_found "vhost-net"
1921d5970055SMichael S. Tsirkin            fi
1922d5970055SMichael S. Tsirkin            vhost_net=no
1923d5970055SMichael S. Tsirkin    fi
1924d5970055SMichael S. Tsirkinfi
1925d5970055SMichael S. Tsirkin
1926d5970055SMichael S. Tsirkin##########################################
1927e5d355d1Saliguori# pthread probe
1928de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
19293c529d93Saliguori
1930e5d355d1Saliguoripthread=no
1931414f0dabSblueswir1cat > $TMPC << EOF
19323c529d93Saliguori#include <pthread.h>
1933de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1934414f0dabSblueswir1EOF
1935bd00d539SAndreas Färberif compile_prog "" "" ; then
1936bd00d539SAndreas Färber  pthread=yes
1937bd00d539SAndreas Färberelse
1938de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
193952166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
1940e5d355d1Saliguori      pthread=yes
19415572b539SJuan Quintela      LIBS="$pthread_lib $LIBS"
1942de65fe0fSSebastian Herbszt      break
1943414f0dabSblueswir1    fi
1944de65fe0fSSebastian Herbszt  done
1945bd00d539SAndreas Färberfi
1946414f0dabSblueswir1
19474617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
19484dd75c70SChristoph Hellwig  echo
19494dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
19504dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
19514dd75c70SChristoph Hellwig  echo
19524dd75c70SChristoph Hellwig  exit 1
1953e5d355d1Saliguorifi
1954e5d355d1Saliguori
1955bf9298b9Saliguori##########################################
1956f27aaf4bSChristian Brunner# rbd probe
1957f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
1958f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
1959f27aaf4bSChristian Brunner#include <stdio.h>
1960ad32e9c0SJosh Durgin#include <rbd/librbd.h>
1961f27aaf4bSChristian Brunnerint main(void) {
1962ad32e9c0SJosh Durgin    rados_t cluster;
1963ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
1964f27aaf4bSChristian Brunner    return 0;
1965f27aaf4bSChristian Brunner}
1966f27aaf4bSChristian BrunnerEOF
1967ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
1968f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
1969f27aaf4bSChristian Brunner    rbd=yes
1970f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
1971f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
1972f27aaf4bSChristian Brunner  else
1973f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
1974f27aaf4bSChristian Brunner      feature_not_found "rados block device"
1975f27aaf4bSChristian Brunner    fi
1976f27aaf4bSChristian Brunner    rbd=no
1977f27aaf4bSChristian Brunner  fi
1978f27aaf4bSChristian Brunnerfi
1979f27aaf4bSChristian Brunner
1980f27aaf4bSChristian Brunner##########################################
19815c6c3a6cSChristoph Hellwig# linux-aio probe
19825c6c3a6cSChristoph Hellwig
19835c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
19845c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
19855c6c3a6cSChristoph Hellwig#include <libaio.h>
19865c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
1987832ce9c2SScott Wood#include <stddef.h>
19885c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
19895c6c3a6cSChristoph HellwigEOF
19905c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
19915c6c3a6cSChristoph Hellwig    linux_aio=yes
1992048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1993048d179fSPaul Brook    libs_tools="$libs_tools -laio"
19945c6c3a6cSChristoph Hellwig  else
19955c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
19965c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
19975c6c3a6cSChristoph Hellwig    fi
19983cfcae3cSLuiz Capitulino    linux_aio=no
19995c6c3a6cSChristoph Hellwig  fi
20005c6c3a6cSChristoph Hellwigfi
20015c6c3a6cSChristoph Hellwig
20025c6c3a6cSChristoph Hellwig##########################################
2003758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2004758e8e38SVenkateswararao Jujjuri (JV)
2005758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2006758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2007758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2008758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2009758e8e38SVenkateswararao Jujjuri (JV)#include <attr/xattr.h>
2010758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2011758e8e38SVenkateswararao Jujjuri (JV)EOF
2012758e8e38SVenkateswararao Jujjuri (JV)  if compile_prog "" "-lattr" ; then
2013758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2014758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
2015758e8e38SVenkateswararao Jujjuri (JV)  else
2016758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2017758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2018758e8e38SVenkateswararao Jujjuri (JV)    fi
2019758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2020758e8e38SVenkateswararao Jujjuri (JV)  fi
2021758e8e38SVenkateswararao Jujjuri (JV)fi
2022758e8e38SVenkateswararao Jujjuri (JV)
2023758e8e38SVenkateswararao Jujjuri (JV)##########################################
2024bf9298b9Saliguori# iovec probe
2025bf9298b9Saliguoricat > $TMPC <<EOF
2026db34f0b3Sblueswir1#include <sys/types.h>
2027bf9298b9Saliguori#include <sys/uio.h>
2028db34f0b3Sblueswir1#include <unistd.h>
2029bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
2030bf9298b9SaliguoriEOF
2031bf9298b9Saliguoriiovec=no
203252166aa0SJuan Quintelaif compile_prog "" "" ; then
2033bf9298b9Saliguori  iovec=yes
2034bf9298b9Saliguorifi
2035bf9298b9Saliguori
2036f652e6afSaurel32##########################################
2037ceb42de8Saliguori# preadv probe
2038ceb42de8Saliguoricat > $TMPC <<EOF
2039ceb42de8Saliguori#include <sys/types.h>
2040ceb42de8Saliguori#include <sys/uio.h>
2041ceb42de8Saliguori#include <unistd.h>
2042ceb42de8Saliguoriint main(void) { preadv; }
2043ceb42de8SaliguoriEOF
2044ceb42de8Saliguoripreadv=no
204552166aa0SJuan Quintelaif compile_prog "" "" ; then
2046ceb42de8Saliguori  preadv=yes
2047ceb42de8Saliguorifi
2048ceb42de8Saliguori
2049ceb42de8Saliguori##########################################
2050f652e6afSaurel32# fdt probe
20512df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2052b41af4baSJuan Quintela  fdt_libs="-lfdt"
2053f652e6afSaurel32  cat > $TMPC << EOF
2054f652e6afSaurel32int main(void) { return 0; }
2055f652e6afSaurel32EOF
205652166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2057f652e6afSaurel32    fdt=yes
20582df87df7SJuan Quintela  else
20592df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
20602df87df7SJuan Quintela      feature_not_found "fdt"
20612df87df7SJuan Quintela    fi
2062de3a354aSMichael Walle    fdt_libs=
20632df87df7SJuan Quintela    fdt=no
2064f652e6afSaurel32  fi
2065f652e6afSaurel32fi
2066f652e6afSaurel32
206720ff075bSMichael Walle##########################################
206820ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
206920ff075bSMichael Walleif test "$opengl" != "no" ; then
207020ff075bSMichael Walle  opengl_libs="-lGL"
207120ff075bSMichael Walle  cat > $TMPC << EOF
207220ff075bSMichael Walle#include <X11/Xlib.h>
207320ff075bSMichael Walle#include <GL/gl.h>
207420ff075bSMichael Walle#include <GL/glx.h>
207520ff075bSMichael Walleint main(void) { GL_VERSION; return 0; }
207620ff075bSMichael WalleEOF
207720ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
207820ff075bSMichael Walle    opengl=yes
207920ff075bSMichael Walle  else
208020ff075bSMichael Walle    if test "$opengl" = "yes" ; then
208120ff075bSMichael Walle      feature_not_found "opengl"
208220ff075bSMichael Walle    fi
2083de3a354aSMichael Walle    opengl_libs=
208420ff075bSMichael Walle    opengl=no
208520ff075bSMichael Walle  fi
208620ff075bSMichael Wallefi
208720ff075bSMichael Walle
20883b3f24adSaurel32#
20893b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
20903b3f24adSaurel32# emulator.  This is done because older glibc versions don't
20913b3f24adSaurel32# have syscall stubs for these implemented.
20923b3f24adSaurel32#
20933b3f24adSaurel32atfile=no
20943b3f24adSaurel32cat > $TMPC << EOF
20953b3f24adSaurel32#define _ATFILE_SOURCE
20963b3f24adSaurel32#include <sys/types.h>
20973b3f24adSaurel32#include <fcntl.h>
20983b3f24adSaurel32#include <unistd.h>
20993b3f24adSaurel32
21003b3f24adSaurel32int
21013b3f24adSaurel32main(void)
21023b3f24adSaurel32{
21033b3f24adSaurel32	/* try to unlink nonexisting file */
21043b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
21053b3f24adSaurel32}
21063b3f24adSaurel32EOF
210752166aa0SJuan Quintelaif compile_prog "" "" ; then
21083b3f24adSaurel32  atfile=yes
21093b3f24adSaurel32fi
21103b3f24adSaurel32
211139386ac7Saurel32# Check for inotify functions when we are building linux-user
21123b3f24adSaurel32# emulator.  This is done because older glibc versions don't
21133b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
21143b3f24adSaurel32# don't provide them even if kernel supports them.
21153b3f24adSaurel32#
21163b3f24adSaurel32inotify=no
21173b3f24adSaurel32cat > $TMPC << EOF
21183b3f24adSaurel32#include <sys/inotify.h>
21193b3f24adSaurel32
21203b3f24adSaurel32int
21213b3f24adSaurel32main(void)
21223b3f24adSaurel32{
21233b3f24adSaurel32	/* try to start inotify */
21248690e420Saurel32	return inotify_init();
21253b3f24adSaurel32}
21263b3f24adSaurel32EOF
212752166aa0SJuan Quintelaif compile_prog "" "" ; then
21283b3f24adSaurel32  inotify=yes
21293b3f24adSaurel32fi
21303b3f24adSaurel32
2131c05c7a73SRiku Voipioinotify1=no
2132c05c7a73SRiku Voipiocat > $TMPC << EOF
2133c05c7a73SRiku Voipio#include <sys/inotify.h>
2134c05c7a73SRiku Voipio
2135c05c7a73SRiku Voipioint
2136c05c7a73SRiku Voipiomain(void)
2137c05c7a73SRiku Voipio{
2138c05c7a73SRiku Voipio    /* try to start inotify */
2139c05c7a73SRiku Voipio    return inotify_init1(0);
2140c05c7a73SRiku Voipio}
2141c05c7a73SRiku VoipioEOF
2142c05c7a73SRiku Voipioif compile_prog "" "" ; then
2143c05c7a73SRiku Voipio  inotify1=yes
2144c05c7a73SRiku Voipiofi
2145c05c7a73SRiku Voipio
2146ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2147ebc996f3SRiku Voipioutimens=no
2148ebc996f3SRiku Voipiocat > $TMPC << EOF
2149ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2150ebc996f3SRiku Voipio#include <stddef.h>
2151ebc996f3SRiku Voipio#include <fcntl.h>
2152ebc996f3SRiku Voipio
2153ebc996f3SRiku Voipioint main(void)
2154ebc996f3SRiku Voipio{
2155ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2156ebc996f3SRiku Voipio    futimens(0, NULL);
2157ebc996f3SRiku Voipio    return 0;
2158ebc996f3SRiku Voipio}
2159ebc996f3SRiku VoipioEOF
216052166aa0SJuan Quintelaif compile_prog "" "" ; then
2161ebc996f3SRiku Voipio  utimens=yes
2162ebc996f3SRiku Voipiofi
2163ebc996f3SRiku Voipio
2164099d6b0fSRiku Voipio# check if pipe2 is there
2165099d6b0fSRiku Voipiopipe2=no
2166099d6b0fSRiku Voipiocat > $TMPC << EOF
2167099d6b0fSRiku Voipio#include <unistd.h>
2168099d6b0fSRiku Voipio#include <fcntl.h>
2169099d6b0fSRiku Voipio
2170099d6b0fSRiku Voipioint main(void)
2171099d6b0fSRiku Voipio{
2172099d6b0fSRiku Voipio    int pipefd[2];
2173099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2174099d6b0fSRiku Voipio    return 0;
2175099d6b0fSRiku Voipio}
2176099d6b0fSRiku VoipioEOF
217752166aa0SJuan Quintelaif compile_prog "" "" ; then
2178099d6b0fSRiku Voipio  pipe2=yes
2179099d6b0fSRiku Voipiofi
2180099d6b0fSRiku Voipio
218140ff6d7eSKevin Wolf# check if accept4 is there
218240ff6d7eSKevin Wolfaccept4=no
218340ff6d7eSKevin Wolfcat > $TMPC << EOF
218440ff6d7eSKevin Wolf#include <sys/socket.h>
218540ff6d7eSKevin Wolf#include <stddef.h>
218640ff6d7eSKevin Wolf
218740ff6d7eSKevin Wolfint main(void)
218840ff6d7eSKevin Wolf{
218940ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
219040ff6d7eSKevin Wolf    return 0;
219140ff6d7eSKevin Wolf}
219240ff6d7eSKevin WolfEOF
219340ff6d7eSKevin Wolfif compile_prog "" "" ; then
219440ff6d7eSKevin Wolf  accept4=yes
219540ff6d7eSKevin Wolffi
219640ff6d7eSKevin Wolf
21973ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
21983ce34dfbSvibisreenivasansplice=no
21993ce34dfbSvibisreenivasancat > $TMPC << EOF
22003ce34dfbSvibisreenivasan#include <unistd.h>
22013ce34dfbSvibisreenivasan#include <fcntl.h>
22023ce34dfbSvibisreenivasan#include <limits.h>
22033ce34dfbSvibisreenivasan
22043ce34dfbSvibisreenivasanint main(void)
22053ce34dfbSvibisreenivasan{
22063ce34dfbSvibisreenivasan    int len, fd;
22073ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
22083ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
22093ce34dfbSvibisreenivasan    return 0;
22103ce34dfbSvibisreenivasan}
22113ce34dfbSvibisreenivasanEOF
221252166aa0SJuan Quintelaif compile_prog "" "" ; then
22133ce34dfbSvibisreenivasan  splice=yes
22143ce34dfbSvibisreenivasanfi
22153ce34dfbSvibisreenivasan
2216dcc38d1cSMarcelo Tosatti##########################################
2217dcc38d1cSMarcelo Tosatti# signalfd probe
2218dcc38d1cSMarcelo Tosattisignalfd="no"
2219dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2220dcc38d1cSMarcelo Tosatti#define _GNU_SOURCE
2221dcc38d1cSMarcelo Tosatti#include <unistd.h>
2222dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2223dcc38d1cSMarcelo Tosatti#include <signal.h>
2224dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2225dcc38d1cSMarcelo TosattiEOF
2226dcc38d1cSMarcelo Tosatti
2227dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2228dcc38d1cSMarcelo Tosatti  signalfd=yes
2229de758970SJan Kiszkaelif test "$kvm" = "yes" -a "$io_thread" != "yes"; then
2230de758970SJan Kiszka  echo
2231de758970SJan Kiszka  echo "ERROR: Host kernel lacks signalfd() support,"
2232de758970SJan Kiszka  echo "but KVM depends on it when the IO thread is disabled."
2233de758970SJan Kiszka  echo
2234de758970SJan Kiszka  exit 1
2235dcc38d1cSMarcelo Tosattifi
2236dcc38d1cSMarcelo Tosatti
2237c2882b96SRiku Voipio# check if eventfd is supported
2238c2882b96SRiku Voipioeventfd=no
2239c2882b96SRiku Voipiocat > $TMPC << EOF
2240c2882b96SRiku Voipio#include <sys/eventfd.h>
2241c2882b96SRiku Voipio
2242c2882b96SRiku Voipioint main(void)
2243c2882b96SRiku Voipio{
2244c2882b96SRiku Voipio    int efd = eventfd(0, 0);
2245c2882b96SRiku Voipio    return 0;
2246c2882b96SRiku Voipio}
2247c2882b96SRiku VoipioEOF
2248c2882b96SRiku Voipioif compile_prog "" "" ; then
2249c2882b96SRiku Voipio  eventfd=yes
2250c2882b96SRiku Voipiofi
2251c2882b96SRiku Voipio
2252d0927938SUlrich Hecht# check for fallocate
2253d0927938SUlrich Hechtfallocate=no
2254d0927938SUlrich Hechtcat > $TMPC << EOF
2255d0927938SUlrich Hecht#include <fcntl.h>
2256d0927938SUlrich Hecht
2257d0927938SUlrich Hechtint main(void)
2258d0927938SUlrich Hecht{
2259d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2260d0927938SUlrich Hecht    return 0;
2261d0927938SUlrich Hecht}
2262d0927938SUlrich HechtEOF
2263be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
2264d0927938SUlrich Hecht  fallocate=yes
2265d0927938SUlrich Hechtfi
2266d0927938SUlrich Hecht
2267c727f47dSPeter Maydell# check for sync_file_range
2268c727f47dSPeter Maydellsync_file_range=no
2269c727f47dSPeter Maydellcat > $TMPC << EOF
2270c727f47dSPeter Maydell#include <fcntl.h>
2271c727f47dSPeter Maydell
2272c727f47dSPeter Maydellint main(void)
2273c727f47dSPeter Maydell{
2274c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2275c727f47dSPeter Maydell    return 0;
2276c727f47dSPeter Maydell}
2277c727f47dSPeter MaydellEOF
2278c727f47dSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2279c727f47dSPeter Maydell  sync_file_range=yes
2280c727f47dSPeter Maydellfi
2281c727f47dSPeter Maydell
2282dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2283dace20dcSPeter Maydellfiemap=no
2284dace20dcSPeter Maydellcat > $TMPC << EOF
2285dace20dcSPeter Maydell#include <sys/ioctl.h>
2286dace20dcSPeter Maydell#include <linux/fs.h>
2287dace20dcSPeter Maydell#include <linux/fiemap.h>
2288dace20dcSPeter Maydell
2289dace20dcSPeter Maydellint main(void)
2290dace20dcSPeter Maydell{
2291dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2292dace20dcSPeter Maydell    return 0;
2293dace20dcSPeter Maydell}
2294dace20dcSPeter MaydellEOF
2295dace20dcSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2296dace20dcSPeter Maydell  fiemap=yes
2297dace20dcSPeter Maydellfi
2298dace20dcSPeter Maydell
2299d0927938SUlrich Hecht# check for dup3
2300d0927938SUlrich Hechtdup3=no
2301d0927938SUlrich Hechtcat > $TMPC << EOF
2302d0927938SUlrich Hecht#include <unistd.h>
2303d0927938SUlrich Hecht
2304d0927938SUlrich Hechtint main(void)
2305d0927938SUlrich Hecht{
2306d0927938SUlrich Hecht    dup3(0, 0, 0);
2307d0927938SUlrich Hecht    return 0;
2308d0927938SUlrich Hecht}
2309d0927938SUlrich HechtEOF
231078f5d726SJan Kiszkaif compile_prog "" "" ; then
2311d0927938SUlrich Hecht  dup3=yes
2312d0927938SUlrich Hechtfi
2313d0927938SUlrich Hecht
23143b6edd16SPeter Maydell# check for epoll support
23153b6edd16SPeter Maydellepoll=no
23163b6edd16SPeter Maydellcat > $TMPC << EOF
23173b6edd16SPeter Maydell#include <sys/epoll.h>
23183b6edd16SPeter Maydell
23193b6edd16SPeter Maydellint main(void)
23203b6edd16SPeter Maydell{
23213b6edd16SPeter Maydell    epoll_create(0);
23223b6edd16SPeter Maydell    return 0;
23233b6edd16SPeter Maydell}
23243b6edd16SPeter MaydellEOF
23253b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23263b6edd16SPeter Maydell  epoll=yes
23273b6edd16SPeter Maydellfi
23283b6edd16SPeter Maydell
23293b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
23303b6edd16SPeter Maydell# so we must check separately for their presence
23313b6edd16SPeter Maydellepoll_create1=no
23323b6edd16SPeter Maydellcat > $TMPC << EOF
23333b6edd16SPeter Maydell#include <sys/epoll.h>
23343b6edd16SPeter Maydell
23353b6edd16SPeter Maydellint main(void)
23363b6edd16SPeter Maydell{
233719e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
233819e83f6bSPeter Maydell     * a function being called. This is necessary so that on
233919e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
234019e83f6bSPeter Maydell     * the library but not declared in the header file we will
234119e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
234219e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
234319e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
234419e83f6bSPeter Maydell     */
234519e83f6bSPeter Maydell    epoll_create1;
23463b6edd16SPeter Maydell    return 0;
23473b6edd16SPeter Maydell}
23483b6edd16SPeter MaydellEOF
23493b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23503b6edd16SPeter Maydell  epoll_create1=yes
23513b6edd16SPeter Maydellfi
23523b6edd16SPeter Maydell
23533b6edd16SPeter Maydellepoll_pwait=no
23543b6edd16SPeter Maydellcat > $TMPC << EOF
23553b6edd16SPeter Maydell#include <sys/epoll.h>
23563b6edd16SPeter Maydell
23573b6edd16SPeter Maydellint main(void)
23583b6edd16SPeter Maydell{
23593b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
23603b6edd16SPeter Maydell    return 0;
23613b6edd16SPeter Maydell}
23623b6edd16SPeter MaydellEOF
23633b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23643b6edd16SPeter Maydell  epoll_pwait=yes
23653b6edd16SPeter Maydellfi
23663b6edd16SPeter Maydell
2367cc8ae6deSpbrook# Check if tools are available to build documentation.
2368a25dba17SJuan Quintelaif test "$docs" != "no" ; then
236901668d98SStefan Weil  if has makeinfo && has pod2man; then
2370a25dba17SJuan Quintela    docs=yes
237183a3ab8bSJuan Quintela  else
2372a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2373a25dba17SJuan Quintela      feature_not_found "docs"
237483a3ab8bSJuan Quintela    fi
2375a25dba17SJuan Quintela    docs=no
237683a3ab8bSJuan Quintela  fi
2377cc8ae6deSpbrookfi
2378cc8ae6deSpbrook
2379f514f41cSStefan Weil# Search for bswap_32 function
23806ae9a1f4SJuan Quintelabyteswap_h=no
23816ae9a1f4SJuan Quintelacat > $TMPC << EOF
23826ae9a1f4SJuan Quintela#include <byteswap.h>
23836ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
23846ae9a1f4SJuan QuintelaEOF
238552166aa0SJuan Quintelaif compile_prog "" "" ; then
23866ae9a1f4SJuan Quintela  byteswap_h=yes
23876ae9a1f4SJuan Quintelafi
23886ae9a1f4SJuan Quintela
2389f514f41cSStefan Weil# Search for bswap_32 function
23906ae9a1f4SJuan Quintelabswap_h=no
23916ae9a1f4SJuan Quintelacat > $TMPC << EOF
23926ae9a1f4SJuan Quintela#include <sys/endian.h>
23936ae9a1f4SJuan Quintela#include <sys/types.h>
23946ae9a1f4SJuan Quintela#include <machine/bswap.h>
23956ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
23966ae9a1f4SJuan QuintelaEOF
239752166aa0SJuan Quintelaif compile_prog "" "" ; then
23986ae9a1f4SJuan Quintela  bswap_h=yes
23996ae9a1f4SJuan Quintelafi
24006ae9a1f4SJuan Quintela
2401da93a1fdSaliguori##########################################
2402da93a1fdSaliguori# Do we need librt
2403da93a1fdSaliguoricat > $TMPC <<EOF
2404da93a1fdSaliguori#include <signal.h>
2405da93a1fdSaliguori#include <time.h>
2406da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
2407da93a1fdSaliguoriEOF
2408da93a1fdSaliguori
240952166aa0SJuan Quintelaif compile_prog "" "" ; then
241007ffa4bdSJuan Quintela  :
241152166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
241207ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2413da93a1fdSaliguorifi
2414da93a1fdSaliguori
241531ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2416179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
24176362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
24186362a53fSJuan Quintelafi
24196362a53fSJuan Quintela
2420de5071c5SBlue Swirl##########################################
2421de5071c5SBlue Swirl# check if the compiler defines offsetof
2422de5071c5SBlue Swirl
2423de5071c5SBlue Swirlneed_offsetof=yes
2424de5071c5SBlue Swirlcat > $TMPC << EOF
2425de5071c5SBlue Swirl#include <stddef.h>
2426de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
2427de5071c5SBlue SwirlEOF
2428de5071c5SBlue Swirlif compile_prog "" "" ; then
2429de5071c5SBlue Swirl    need_offsetof=no
2430de5071c5SBlue Swirlfi
2431de5071c5SBlue Swirl
24325f6b9e8fSBlue Swirl##########################################
2433747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
2434747bbdf7SBlue Swirl#
2435747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
2436747bbdf7SBlue Swirl# about attribute warn_unused_result
2437747bbdf7SBlue Swirl
2438747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
2439747bbdf7SBlue Swirlcat > $TMPC << EOF
2440747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2441747bbdf7SBlue Swirl#error gcc 3.3 or older
2442747bbdf7SBlue Swirl#endif
2443747bbdf7SBlue Swirlint main(void) { return 0;}
2444747bbdf7SBlue SwirlEOF
2445747bbdf7SBlue Swirlif compile_prog "" ""; then
2446747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
2447747bbdf7SBlue Swirlfi
2448747bbdf7SBlue Swirl
2449cd4ec0b4SGerd Hoffmann# spice probe
2450cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2451cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2452cd4ec0b4SGerd Hoffmann#include <spice.h>
2453cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2454cd4ec0b4SGerd HoffmannEOF
2455710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2456710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2457012b80d3SGerd Hoffmann  if $pkg_config --atleast-version=0.6.0 spice-server >/dev/null 2>&1 && \
2458cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2459cd4ec0b4SGerd Hoffmann    spice="yes"
2460cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2461cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2462cd4ec0b4SGerd Hoffmann  else
2463cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2464cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2465cd4ec0b4SGerd Hoffmann    fi
2466cd4ec0b4SGerd Hoffmann    spice="no"
2467cd4ec0b4SGerd Hoffmann  fi
2468cd4ec0b4SGerd Hoffmannfi
2469cd4ec0b4SGerd Hoffmann
2470111a38b0SRobert Relyea# check for libcacard for smartcard support
2471111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2472111a38b0SRobert Relyea    smartcard="yes"
2473111a38b0SRobert Relyea    smartcard_cflags=""
2474111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2475111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
2476111a38b0SRobert Relyea        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then
2477111a38b0SRobert Relyea            smartcard_nss="yes"
2478111a38b0SRobert Relyea            smartcard_cflags="-I\$(SRC_PATH)/libcacard"
2479111a38b0SRobert Relyea            libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
2480111a38b0SRobert Relyea            libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
2481111a38b0SRobert Relyea            QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
2482111a38b0SRobert Relyea            LIBS="$libcacard_libs $LIBS"
2483111a38b0SRobert Relyea        else
2484111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2485111a38b0SRobert Relyea                feature_not_found "nss"
2486111a38b0SRobert Relyea            fi
2487111a38b0SRobert Relyea            smartcard_nss="no"
2488111a38b0SRobert Relyea        fi
2489111a38b0SRobert Relyea    fi
2490111a38b0SRobert Relyeafi
2491111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2492111a38b0SRobert Relyea    smartcard_nss="no"
2493111a38b0SRobert Relyeafi
2494111a38b0SRobert Relyea
2495cd4ec0b4SGerd Hoffmann##########################################
2496cd4ec0b4SGerd Hoffmann
2497747bbdf7SBlue Swirl##########################################
24985f6b9e8fSBlue Swirl# check if we have fdatasync
24995f6b9e8fSBlue Swirl
25005f6b9e8fSBlue Swirlfdatasync=no
25015f6b9e8fSBlue Swirlcat > $TMPC << EOF
25025f6b9e8fSBlue Swirl#include <unistd.h>
2503d1722a27SAlexandre Raymondint main(void) {
2504d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2505d1722a27SAlexandre Raymondreturn fdatasync(0);
2506d1722a27SAlexandre Raymond#else
2507d1722a27SAlexandre Raymond#abort Not supported
2508d1722a27SAlexandre Raymond#endif
2509d1722a27SAlexandre Raymond}
25105f6b9e8fSBlue SwirlEOF
25115f6b9e8fSBlue Swirlif compile_prog "" "" ; then
25125f6b9e8fSBlue Swirl    fdatasync=yes
25135f6b9e8fSBlue Swirlfi
25145f6b9e8fSBlue Swirl
251594a420b1SStefan Hajnoczi##########################################
2516e78815a5SAndreas Färber# check if we have madvise
2517e78815a5SAndreas Färber
2518e78815a5SAndreas Färbermadvise=no
2519e78815a5SAndreas Färbercat > $TMPC << EOF
2520e78815a5SAndreas Färber#include <sys/types.h>
2521e78815a5SAndreas Färber#include <sys/mman.h>
2522832ce9c2SScott Wood#include <stddef.h>
2523e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2524e78815a5SAndreas FärberEOF
2525e78815a5SAndreas Färberif compile_prog "" "" ; then
2526e78815a5SAndreas Färber    madvise=yes
2527e78815a5SAndreas Färberfi
2528e78815a5SAndreas Färber
2529e78815a5SAndreas Färber##########################################
2530e78815a5SAndreas Färber# check if we have posix_madvise
2531e78815a5SAndreas Färber
2532e78815a5SAndreas Färberposix_madvise=no
2533e78815a5SAndreas Färbercat > $TMPC << EOF
2534e78815a5SAndreas Färber#include <sys/mman.h>
2535832ce9c2SScott Wood#include <stddef.h>
2536e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2537e78815a5SAndreas FärberEOF
2538e78815a5SAndreas Färberif compile_prog "" "" ; then
2539e78815a5SAndreas Färber    posix_madvise=yes
2540e78815a5SAndreas Färberfi
2541e78815a5SAndreas Färber
2542e78815a5SAndreas Färber##########################################
254394a420b1SStefan Hajnoczi# check if trace backend exists
254494a420b1SStefan Hajnoczi
25454c3b5a48SBlue Swirlsh "$source_path/scripts/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
254694a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
254794a420b1SStefan Hajnoczi  echo
254894a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
254994a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
255094a420b1SStefan Hajnoczi  echo
255194a420b1SStefan Hajnoczi  exit 1
255294a420b1SStefan Hajnoczifi
255394a420b1SStefan Hajnoczi
25547e24e92aSStefan Hajnoczi##########################################
25557e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
25567e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
25577e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
25587e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
25597e24e92aSStefan Hajnoczi#include <ust/marker.h>
25607e24e92aSStefan Hajnocziint main(void) { return 0; }
25617e24e92aSStefan HajnocziEOF
25627e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
25637e24e92aSStefan Hajnoczi    LIBS="-lust $LIBS"
25647e24e92aSStefan Hajnoczi  else
25657e24e92aSStefan Hajnoczi    echo
25667e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
25677e24e92aSStefan Hajnoczi    echo
25687e24e92aSStefan Hajnoczi    exit 1
25697e24e92aSStefan Hajnoczi  fi
25707e24e92aSStefan Hajnoczifi
2571b3d08c02SDaniel P. Berrange
2572b3d08c02SDaniel P. Berrange##########################################
2573b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2574b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2575b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2576b3d08c02SDaniel P. Berrange    echo
2577b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2578b3d08c02SDaniel P. Berrange    echo
2579b3d08c02SDaniel P. Berrange    exit 1
2580b3d08c02SDaniel P. Berrange  fi
2581c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2582c276b17dSDaniel P. Berrange  if has 'stap' ; then
2583c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2584c276b17dSDaniel P. Berrange  fi
2585b3d08c02SDaniel P. Berrangefi
2586b3d08c02SDaniel P. Berrange
25877e24e92aSStefan Hajnoczi##########################################
2588e86ecd4bSJuan Quintela# End of CC checks
2589e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2590e86ecd4bSJuan Quintela
2591e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
25921156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2593e86ecd4bSJuan Quintelafi
2594a316e378SJuan Quintela
2595e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2596e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2597e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
259820ff6c80SAnthony Liguori
259920ff6c80SAnthony Liguoriif test -z "$werror" ; then
2600e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2601e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2602e86ecd4bSJuan Quintela        werror="yes"
2603e86ecd4bSJuan Quintela    else
2604e86ecd4bSJuan Quintela        werror="no"
2605e86ecd4bSJuan Quintela    fi
2606e86ecd4bSJuan Quintelafi
2607e86ecd4bSJuan Quintela
260820ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
260920ff6c80SAnthony Liguori# enable/disable
261020ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
261120ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
261220ff6c80SAnthony Liguori	zero_malloc="no"
261320ff6c80SAnthony Liguori    else
261420ff6c80SAnthony Liguori	zero_malloc="yes"
261520ff6c80SAnthony Liguori    fi
261620ff6c80SAnthony Liguorifi
261720ff6c80SAnthony Liguori
2618e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2619a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2620e86ecd4bSJuan Quintelafi
2621e86ecd4bSJuan Quintela
2622e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2623e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
26241156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2625e86ecd4bSJuan Quintela    fi
2626e86ecd4bSJuan Quintelafi
2627e86ecd4bSJuan Quintela
2628952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
2629952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
2630952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
2631952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2632952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
2633952afb71SBlue Swirl        fi
2634952afb71SBlue Swirl    done
2635952afb71SBlue Swirlfi
2636952afb71SBlue Swirl
2637190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
26385a67135aSbellard
2639ca35f780SPaolo Bonzinitools=
2640ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2641ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2642ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2643ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2644ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2645ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2646ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2647ca35f780SPaolo Bonzini    fi
2648ca35f780SPaolo Bonzini  fi
2649ca35f780SPaolo Bonzinifi
2650ca35f780SPaolo Bonzini
2651ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2652ca35f780SPaolo Bonziniroms=
2653ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2654ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2655ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2656ca35f780SPaolo Bonzini  roms="optionrom"
2657ca35f780SPaolo Bonzinifi
2658d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
265939ac8455SDavid Gibson  roms="$roms spapr-rtas"
266039ac8455SDavid Gibsonfi
2661ca35f780SPaolo Bonzini
26627d13299dSbellardecho "Install prefix    $prefix"
2663f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2664f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
26653aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
26661c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
266711d9f695Sbellardif test "$mingw32" = "no" ; then
2668f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
266943ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
267011d9f695Sbellardfi
26715a67135aSbellardecho "Source path       $source_path"
26727d13299dSbellardecho "C compiler        $cc"
267383469015Sbellardecho "Host C compiler   $host_cc"
26740c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2675a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
26760c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
26777d13299dSbellardecho "make              $make"
26786a882643Spbrookecho "install           $install"
2679a98fd896Sbellardecho "host CPU          $cpu"
2680de83cd02Sbellardecho "host big endian   $bigendian"
268197a847bcSbellardecho "target list       $target_list"
2682ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2683b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
26847d13299dSbellardecho "gprof enabled     $gprof"
268503b4fe7dSaliguoriecho "sparse enabled    $sparse"
26861625af87Saliguoriecho "strip binaries    $strip_opt"
268705c2a3e7Sbellardecho "profiler          $profiler"
268843ce4dfeSbellardecho "static build      $static"
268985aa5189Sbellardecho "-Werror enabled   $werror"
26905b0753e0Sbellardif test "$darwin" = "yes" ; then
26915b0753e0Sbellard    echo "Cocoa support     $cocoa"
26925b0753e0Sbellardfi
269397a847bcSbellardecho "SDL support       $sdl"
26944d3b6f6eSbalrogecho "curses support    $curses"
2695769ce76dSAlexander Grafecho "curl support      $curl"
26965495ed11SLuiz Capitulinoecho "check support     $check_utests"
269767b915a5Sbellardecho "mingw32 support   $mingw32"
26980c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
26990c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2700eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
27018ff9cbf7Smalcecho "Mixer emulation   $mixemu"
2702821601eaSJes Sorensenecho "VNC support       $vnc"
2703821601eaSJes Sorensenif test "$vnc" = "yes" ; then
27048d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
27052f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
27062f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
2707efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
2708bd023f95SCorentin Chary    echo "VNC thread        $vnc_thread"
2709821601eaSJes Sorensenfi
27103142255cSblueswir1if test -n "$sparc_cpu"; then
27113142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
27123142255cSblueswir1fi
2713e37630caSaliguoriecho "xen support       $xen"
27142e4d9fb1Saurel32echo "brlapi support    $brlapi"
2715a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2716a25dba17SJuan Quintelaecho "Documentation     $docs"
2717c5937220Spbrook[ ! -z "$uname_release" ] && \
2718c5937220Spbrookecho "uname -r          $uname_release"
2719bd0c5661Spbrookecho "NPTL support      $nptl"
2720379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
272134005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
27228a16d273Sthsecho "vde support       $vde"
2723e5d355d1Saliguoriecho "IO thread         $io_thread"
27245c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2725758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
272677755340Sthsecho "Install blobs     $blobs"
2727b31a0277SJuan Quintelaecho "KVM support       $kvm"
2728f652e6afSaurel32echo "fdt support       $fdt"
2729ceb42de8Saliguoriecho "preadv support    $preadv"
27305f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2731e78815a5SAndreas Färberecho "madvise           $madvise"
2732e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
2733ee682d27SStefan Weilecho "uuid support      $uuid"
2734d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
273594a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
27369410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
2737cd4ec0b4SGerd Hoffmannecho "spice support     $spice"
2738f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
2739dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
2740111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
274120ff075bSMichael Walleecho "OpenGL support    $opengl"
274267b915a5Sbellard
274397a847bcSbellardif test $sdl_too_old = "yes"; then
274424b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2745e8cd23deSbellardfi
274697a847bcSbellard
274798ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
27484bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
274997a847bcSbellard
275098ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
275198ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
275298ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
275398ec69acSJuan Quintelaecho >> $config_host_mak
275498ec69acSJuan Quintela
2755e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
275699d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
275799d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
27583aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
275999d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
276099d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
276199d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
276299d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
27631dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2764804edf29SJuan Quintela
27652408a527Saurel32case "$cpu" in
2766d2fbca94SGuan Xuetao  i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64|unicore32)
2767e0da9dd3SJuan Quintela    ARCH=$cpu
27682408a527Saurel32  ;;
2769a302c32dSLaurent Desnogues  armv4b|armv4l)
277016dbd14fSJuan Quintela    ARCH=arm
27712408a527Saurel32  ;;
27722408a527Saurel32esac
277398ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2774f8393946Saurel32if test "$debug_tcg" = "yes" ; then
27752358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2776f8393946Saurel32fi
2777b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2778b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2779b4475aa2SLuiz Capitulinofi
2780f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
27812358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2782f3d08ee6SPaul Brookfi
27831625af87Saliguoriif test "$strip_opt" = "yes" ; then
278452ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
27851625af87Saliguorifi
27867d13299dSbellardif test "$bigendian" = "yes" ; then
2787e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
278897a847bcSbellardfi
27892358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
279067b915a5Sbellardif test "$mingw32" = "yes" ; then
279198ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
27929fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
27939fe6de94SBlue Swirl  version_major=${rc_version%%.*}
27949fe6de94SBlue Swirl  rc_version=${rc_version#*.}
27959fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
27969fe6de94SBlue Swirl  rc_version=${rc_version#*.}
27979fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
27989fe6de94SBlue Swirl  version_micro=0
27999fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
28009fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2801210fa556Spbrookelse
280235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2803210fa556Spbrookfi
2804128ab2ffSblueswir1
2805dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2806dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2807dffcb71cSMark McLoughlinfi
2808dffcb71cSMark McLoughlin
280983fb7adfSbellardif test "$darwin" = "yes" ; then
281098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
281183fb7adfSbellardfi
2812b29fe3edSmalc
2813b29fe3edSmalcif test "$aix" = "yes" ; then
281498ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2815b29fe3edSmalcfi
2816b29fe3edSmalc
2817ec530c81Sbellardif test "$solaris" = "yes" ; then
281898ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
28192358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
28200475a5caSths  if test "$needs_libsunmath" = "yes" ; then
282175b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
28220475a5caSths  fi
2823ec530c81Sbellardfi
2824179cf400SAndreas Färberif test "$haiku" = "yes" ; then
2825179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
2826179cf400SAndreas Färberfi
282797a847bcSbellardif test "$static" = "yes" ; then
282898ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
282997a847bcSbellardfi
283005c2a3e7Sbellardif test $profiler = "yes" ; then
28312358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
283205c2a3e7Sbellardfi
2833c20709aaSbellardif test "$slirp" = "yes" ; then
283498ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2835f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
2836c20709aaSbellardfi
28378a16d273Sthsif test "$vde" = "yes" ; then
283898ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
28398a16d273Sthsfi
28400c58ac1cSmalcfor card in $audio_card_list; do
2841f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
284298ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
28430c58ac1cSmalcdone
28442358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
28450c58ac1cSmalcfor drv in $audio_drv_list; do
2846f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
284798ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2848923e4521Smalc    if test "$drv" = "fmod"; then
28497aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2850fb065187Sbellard    fi
28510c58ac1cSmalcdone
285267f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
285367f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
285467f86e8eSJuan Quintelafi
2855d5631638Smalcif test "$audio_win_int" = "yes" ; then
2856d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2857d5631638Smalcfi
2858eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
28598ff9cbf7Smalcif test "$mixemu" = "yes" ; then
286098ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
28618ff9cbf7Smalcfi
2862821601eaSJes Sorensenif test "$vnc" = "yes" ; then
2863821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
2864821601eaSJes Sorensenfi
28658d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
286698ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2867525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
28688d5d2d4cSthsfi
28692f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
287098ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
287160ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
28722f9606b3Saliguorifi
2873821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
28742f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
28752f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
28762f6f5c7aSCorentin Charyfi
2877821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
2878efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2879efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2880efe556adSCorentin Charyfi
2881821601eaSJes Sorensenif test "$vnc_thread" = "yes" ; then
2882bd023f95SCorentin Chary  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2883bd023f95SCorentin Charyfi
288476655d6dSaliguoriif test "$fnmatch" = "yes" ; then
28852358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
288676655d6dSaliguorifi
2887ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2888ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2889ee682d27SStefan Weilfi
2890dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
2891dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
2892dce512deSChristoph Hellwigfi
2893b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
289498ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
28952358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
289698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
289798ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2898a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
289998ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2900cc8ae6deSpbrookfi
29011ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
290298ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
29038ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
290449ecc3faSbellardfi
290549ecc3faSbellardif test "$cocoa" = "yes" ; then
290698ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
290749ecc3faSbellardfi
29084d3b6f6eSbalrogif test "$curses" = "yes" ; then
290998ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2910ab4e5602SJan Kiszkafi
29113b3f24adSaurel32if test "$atfile" = "yes" ; then
29122358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
29133b3f24adSaurel32fi
2914ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
29152358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2916ebc996f3SRiku Voipiofi
2917099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
29182358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2919099d6b0fSRiku Voipiofi
292040ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
292140ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
292240ff6d7eSKevin Wolffi
29233ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
29242358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
29253ce34dfbSvibisreenivasanfi
2926c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2927c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2928c2882b96SRiku Voipiofi
2929d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2930d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2931d0927938SUlrich Hechtfi
2932c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
2933c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2934c727f47dSPeter Maydellfi
2935dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
2936dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
2937dace20dcSPeter Maydellfi
2938d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2939d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2940d0927938SUlrich Hechtfi
29413b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
29423b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
29433b6edd16SPeter Maydellfi
29443b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
29453b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
29463b6edd16SPeter Maydellfi
29473b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
29483b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
29493b6edd16SPeter Maydellfi
29503b3f24adSaurel32if test "$inotify" = "yes" ; then
29512358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
29523b3f24adSaurel32fi
2953c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2954c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2955c05c7a73SRiku Voipiofi
29566ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
29576ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
29586ae9a1f4SJuan Quintelafi
29596ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
29606ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
29616ae9a1f4SJuan Quintelafi
2962769ce76dSAlexander Grafif test "$curl" = "yes" ; then
296398ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2964b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2965769ce76dSAlexander Graffi
29662e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
296798ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
29682e4d9fb1Saurel32fi
2969fb599c9aSbalrogif test "$bluez" = "yes" ; then
297098ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2971ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2972fb599c9aSbalrogfi
2973e37630caSaliguoriif test "$xen" = "yes" ; then
29745647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2975d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
2976e37630caSaliguorifi
2977e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
297898ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2979e5d355d1Saliguorifi
29805c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
29815c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
29825c6c3a6cSChristoph Hellwigfi
2983758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
2984758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
2985758e8e38SVenkateswararao Jujjuri (JV)fi
2986758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
2987758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
2988758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2989758e8e38SVenkateswararao Jujjuri (JV)  fi
2990758e8e38SVenkateswararao Jujjuri (JV)fi
299177755340Sthsif test "$blobs" = "yes" ; then
299298ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
299377755340Sthsfi
2994bf9298b9Saliguoriif test "$iovec" = "yes" ; then
29952358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2996bf9298b9Saliguorifi
2997ceb42de8Saliguoriif test "$preadv" = "yes" ; then
29982358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2999ceb42de8Saliguorifi
3000f652e6afSaurel32if test "$fdt" = "yes" ; then
30013f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3002f652e6afSaurel32fi
3003dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3004dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3005dcc38d1cSMarcelo Tosattifi
3006de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
3007de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
3008de5071c5SBlue Swirlfi
3009747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
3010747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
3011747bbdf7SBlue Swirlfi
30125f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
30135f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
30145f6b9e8fSBlue Swirlfi
3015e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3016e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3017e78815a5SAndreas Färberfi
3018e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3019e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3020e78815a5SAndreas Färberfi
302197a847bcSbellard
3022cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3023cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3024cd4ec0b4SGerd Hoffmannfi
3025cd4ec0b4SGerd Hoffmann
302636707144SAlon Levyif test "$smartcard" = "yes" ; then
302736707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
302836707144SAlon Levyfi
302936707144SAlon Levy
3030111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3031111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3032111a38b0SRobert Relyeafi
3033111a38b0SRobert Relyea
303420ff075bSMichael Walleif test "$opengl" = "yes" ; then
303520ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
303620ff075bSMichael Wallefi
303720ff075bSMichael Walle
303883fb7adfSbellard# XXX: suppress that
30397d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
30402358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
30417d3505c5Sbellardfi
30427d3505c5Sbellard
30432358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3044c5937220Spbrook
304520ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
304620ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
304720ff6c80SAnthony Liguorifi
3048f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3049f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3050f27aaf4bSChristian Brunnerfi
305120ff6c80SAnthony Liguori
305268063649Sblueswir1# USB host support
305368063649Sblueswir1case "$usb" in
305468063649Sblueswir1linux)
305598ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
305668063649Sblueswir1;;
305768063649Sblueswir1bsd)
305898ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
305968063649Sblueswir1;;
306068063649Sblueswir1*)
306198ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
306268063649Sblueswir1;;
306368063649Sblueswir1esac
306468063649Sblueswir1
306594a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
306622890ab5SPrerna Saxenaif test "$trace_backend" = "simple"; then
306722890ab5SPrerna Saxena  echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
306822890ab5SPrerna Saxenafi
30699410b56cSPrerna Saxena# Set the appropriate trace file.
30709410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
3071953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
30729410b56cSPrerna Saxenafi
3073c276b17dSDaniel P. Berrangeif test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
3074c276b17dSDaniel P. Berrange  echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
3075c276b17dSDaniel P. Berrangefi
30769410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
30779410b56cSPrerna Saxena
307898ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
307998ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3080804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3081804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
3082804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
3083804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
3084804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
3085804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
30862b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3087804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
3088804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3089804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3090804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
30919fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
309244dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3093e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3094a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3095f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3096e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3097e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3098e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3099e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3100e39f0062SPaolo Bonzinifi
3101c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
3102e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3103a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3104a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
310573da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
31063e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3107804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3108804edf29SJuan Quintela
31094bf6b55bSJuan Quintela# generate list of library paths for linker script
31104bf6b55bSJuan Quintela
31114bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
31124bf6b55bSJuan Quintela
31134bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
31144bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
31154bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
31164bf6b55bSJuan Quintela  else
31174bf6b55bSJuan Quintela    rm ${config_host_ld}~
31184bf6b55bSJuan Quintela  fi
31194bf6b55bSJuan Quintelafi
31204bf6b55bSJuan Quintela
31214d904533SBlue Swirlfor d in libdis libdis-user; do
31224d904533SBlue Swirl    mkdir -p $d
312311568d6dSPaolo Bonzini    symlink $source_path/Makefile.dis $d/Makefile
31244d904533SBlue Swirl    echo > $d/config.mak
31254d904533SBlue Swirldone
3126d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
3127d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
3128d44cff22SRichard Hendersonfi
31294d904533SBlue Swirl
313097a847bcSbellardfor target in $target_list; do
313197a847bcSbellardtarget_dir="$target"
313225be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3133600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
313497a847bcSbellardtarget_bigendian="no"
31351f3d3c8fSJuan Quintela
3136ea2d6a39SJuan Quintelacase "$target_arch2" in
3137613a22c9SMichael Walle  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
3138ea2d6a39SJuan Quintela  target_bigendian=yes
3139ea2d6a39SJuan Quintela  ;;
3140ea2d6a39SJuan Quintelaesac
314197a847bcSbellardtarget_softmmu="no"
3142997344f3Sbellardtarget_user_only="no"
3143831b7825Sthstarget_linux_user="no"
3144831b7825Sthstarget_darwin_user="no"
314584778508Sblueswir1target_bsd_user="no"
31469e407a85Spbrookcase "$target" in
3147600309b6SBlue Swirl  ${target_arch2}-softmmu)
31489e407a85Spbrook    target_softmmu="yes"
31499e407a85Spbrook    ;;
3150600309b6SBlue Swirl  ${target_arch2}-linux-user)
31519c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
31529c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
31539c7a4202SBlue Swirl      exit 1
31549c7a4202SBlue Swirl    fi
31559e407a85Spbrook    target_user_only="yes"
31569e407a85Spbrook    target_linux_user="yes"
31579e407a85Spbrook    ;;
3158600309b6SBlue Swirl  ${target_arch2}-darwin-user)
31599c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
31609c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
31619c7a4202SBlue Swirl      exit 1
31629c7a4202SBlue Swirl    fi
31639e407a85Spbrook    target_user_only="yes"
3164831b7825Sths    target_darwin_user="yes"
31659e407a85Spbrook    ;;
3166600309b6SBlue Swirl  ${target_arch2}-bsd-user)
31679cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
31689c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
31699c7a4202SBlue Swirl      exit 1
31709c7a4202SBlue Swirl    fi
317184778508Sblueswir1    target_user_only="yes"
317284778508Sblueswir1    target_bsd_user="yes"
317384778508Sblueswir1    ;;
31749e407a85Spbrook  *)
31759e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
31769e407a85Spbrook    exit 1
31779e407a85Spbrook    ;;
31789e407a85Spbrookesac
3179831b7825Sths
318097a847bcSbellardmkdir -p $target_dir
3181158142c2Sbellardmkdir -p $target_dir/fpu
318257fec1feSbellardmkdir -p $target_dir/tcg
318359f2a787SGerd Hoffmannmkdir -p $target_dir/ide
3184353ac78dSAneesh Kumar K.Vmkdir -p $target_dir/9pfs
318584778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
318669de927cSbellard  mkdir -p $target_dir/nwfpe
318769de927cSbellardfi
318811568d6dSPaolo Bonzinisymlink $source_path/Makefile.target $target_dir/Makefile
3189ec530c81Sbellard
319097a847bcSbellard
319125be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
319297a847bcSbellard
3193e5fe0c52Spbrookbflt="no"
3194bd0c5661Spbrooktarget_nptl="no"
3195600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
31967ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
319756aebc89Spbrookgdb_xml_files=""
3198c2e3dee6SLaurent Viviertarget_short_alignment=2
3199c2e3dee6SLaurent Viviertarget_int_alignment=4
3200c2e3dee6SLaurent Viviertarget_long_alignment=4
3201c2e3dee6SLaurent Viviertarget_llong_alignment=8
3202de3a354aSMichael Walletarget_libs_softmmu=
32037ba1e619Saliguori
3204938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
32056acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3206e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3207e73aae67SJuan Quintela
3208600309b6SBlue Swirlcase "$target_arch2" in
32092408a527Saurel32  i386)
321071deff27SAurelien Jarno    target_phys_bits=64
32112408a527Saurel32  ;;
32122408a527Saurel32  x86_64)
32136acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
32141ad2134fSPaul Brook    target_phys_bits=64
3215c2e3dee6SLaurent Vivier    target_long_alignment=8
32162408a527Saurel32  ;;
32172408a527Saurel32  alpha)
32181ad2134fSPaul Brook    target_phys_bits=64
3219c2e3dee6SLaurent Vivier    target_long_alignment=8
3220a4b388ffSRichard Henderson    target_nptl="yes"
32212408a527Saurel32  ;;
32222408a527Saurel32  arm|armeb)
3223b498c8a0SJuan Quintela    TARGET_ARCH=arm
3224e5fe0c52Spbrook    bflt="yes"
3225bd0c5661Spbrook    target_nptl="yes"
322656aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
32271ad2134fSPaul Brook    target_phys_bits=32
3228c2e3dee6SLaurent Vivier    target_llong_alignment=4
32292408a527Saurel32  ;;
32302408a527Saurel32  cris)
3231253bd7f8Sedgar_igl    target_nptl="yes"
32321ad2134fSPaul Brook    target_phys_bits=32
32332408a527Saurel32  ;;
3234613a22c9SMichael Walle  lm32)
3235613a22c9SMichael Walle    target_phys_bits=32
3236de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3237613a22c9SMichael Walle  ;;
32382408a527Saurel32  m68k)
32390938cda5Saurel32    bflt="yes"
324056aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
32411ad2134fSPaul Brook    target_phys_bits=32
3242c2e3dee6SLaurent Vivier    target_int_alignment=2
3243c2e3dee6SLaurent Vivier    target_long_alignment=2
3244c2e3dee6SLaurent Vivier    target_llong_alignment=2
32452408a527Saurel32  ;;
3246877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3247877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
324872b675caSEdgar E. Iglesias    bflt="yes"
324972b675caSEdgar E. Iglesias    target_nptl="yes"
325072b675caSEdgar E. Iglesias    target_phys_bits=32
3251de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
325272b675caSEdgar E. Iglesias  ;;
32532408a527Saurel32  mips|mipsel)
3254b498c8a0SJuan Quintela    TARGET_ARCH=mips
325525be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3256f04dc72fSPaul Brook    target_nptl="yes"
32571ad2134fSPaul Brook    target_phys_bits=64
32582408a527Saurel32  ;;
32592408a527Saurel32  mipsn32|mipsn32el)
3260b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
32616acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
326225be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
32631ad2134fSPaul Brook    target_phys_bits=64
32642408a527Saurel32  ;;
32652408a527Saurel32  mips64|mips64el)
3266b498c8a0SJuan Quintela    TARGET_ARCH=mips64
32676acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
326825be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
32691ad2134fSPaul Brook    target_phys_bits=64
3270c2e3dee6SLaurent Vivier    target_long_alignment=8
32712408a527Saurel32  ;;
32722408a527Saurel32  ppc)
3273c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32741ad2134fSPaul Brook    target_phys_bits=32
3275d6630708SNathan Froyd    target_nptl="yes"
3276de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32772408a527Saurel32  ;;
32782408a527Saurel32  ppcemb)
32796acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3280e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3281c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32821ad2134fSPaul Brook    target_phys_bits=64
3283d6630708SNathan Froyd    target_nptl="yes"
3284de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32852408a527Saurel32  ;;
32862408a527Saurel32  ppc64)
32876acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3288e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3289c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32901ad2134fSPaul Brook    target_phys_bits=64
3291c2e3dee6SLaurent Vivier    target_long_alignment=8
3292de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32932408a527Saurel32  ;;
32942408a527Saurel32  ppc64abi32)
3295b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
32966acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3297e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
329825be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3299c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
33001ad2134fSPaul Brook    target_phys_bits=64
3301de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
33022408a527Saurel32  ;;
33032408a527Saurel32  sh4|sh4eb)
3304b498c8a0SJuan Quintela    TARGET_ARCH=sh4
33054dbed897Spbrook    bflt="yes"
33060b6d3ae0Saurel32    target_nptl="yes"
33071ad2134fSPaul Brook    target_phys_bits=32
33082408a527Saurel32  ;;
33092408a527Saurel32  sparc)
33101ad2134fSPaul Brook    target_phys_bits=64
33112408a527Saurel32  ;;
33122408a527Saurel32  sparc64)
33136acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
33141ad2134fSPaul Brook    target_phys_bits=64
3315c2e3dee6SLaurent Vivier    target_long_alignment=8
33162408a527Saurel32  ;;
33172408a527Saurel32  sparc32plus)
3318b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
33196acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3320e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
332125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
33221ad2134fSPaul Brook    target_phys_bits=64
33232408a527Saurel32  ;;
332424e804ecSAlexander Graf  s390x)
3325bc434676SUlrich Hecht    target_nptl="yes"
332624e804ecSAlexander Graf    target_phys_bits=64
33277b3da903SAlexander Graf    target_long_alignment=8
332824e804ecSAlexander Graf  ;;
3329d2fbca94SGuan Xuetao  unicore32)
3330d2fbca94SGuan Xuetao    target_phys_bits=32
3331d2fbca94SGuan Xuetao  ;;
33322408a527Saurel32  *)
3333de83cd02Sbellard    echo "Unsupported target CPU"
3334de83cd02Sbellard    exit 1
33352408a527Saurel32  ;;
33362408a527Saurel32esac
3337c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3338c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3339c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3340c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
334125be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3342053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
334325be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
334425be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
334542bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
33466acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
33476acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
33486acff7daSJuan Quintelafi
334925be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3350e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3351e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3352e6e91b9cSJuan Quintelafi
335325be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
33541b0c87fcSJuan Quintelacase "$target_arch2" in
33551b0c87fcSJuan Quintela  i386|x86_64)
33561b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
335764b3cfdbSAnthony PERARD      target_phys_bits=64
335825be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
3359432d268cSJun Nakajima      if test "$cpu" = "i386" -o "$cpu" = "x86_64"; then
3360432d268cSJun Nakajima          echo "CONFIG_XEN_MAPCACHE=y" >> $config_target_mak
3361432d268cSJun Nakajima      fi
33621b0c87fcSJuan Quintela    fi
33631b0c87fcSJuan Quintelaesac
3364c59249f9SJuan Quintelacase "$target_arch2" in
33650e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3366c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3367c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3368c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3369c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
33705f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3371adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3372adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3373c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3374c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
337525be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
337625be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
3377dae5079aSJan Kiszka      if test "$kvm_para" = "yes"; then
3378dae5079aSJan Kiszka        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
3379dae5079aSJan Kiszka      fi
3380d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
3381d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3382d5970055SMichael S. Tsirkin      fi
33837dd31902SAurelien Jarno      if test "$kvm_ppc_pvr" = "yes" ; then
338464e07be5SAlexander Graf        echo "CONFIG_KVM_PPC_PVR=y" >> $config_target_mak
338564e07be5SAlexander Graf      fi
3386c59249f9SJuan Quintela    fi
3387c59249f9SJuan Quintelaesac
3388de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
338925be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
339097a847bcSbellardfi
339197a847bcSbellardif test "$target_softmmu" = "yes" ; then
3392b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
339325be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3394de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
33950e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
33965791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3397de83cd02Sbellardfi
3398997344f3Sbellardif test "$target_user_only" = "yes" ; then
339925be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3400997344f3Sbellardfi
3401831b7825Sthsif test "$target_linux_user" = "yes" ; then
340225be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3403831b7825Sthsfi
3404831b7825Sthsif test "$target_darwin_user" = "yes" ; then
340525be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3406831b7825Sthsfi
3407111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3408111a38b0SRobert Relyea  echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3409111a38b0SRobert Relyea  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3410111a38b0SRobert Relyea  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3411111a38b0SRobert Relyeafi
341256aebc89Spbrooklist=""
341356aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
341456aebc89Spbrook  for x in $gdb_xml_files; do
341556aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
341656aebc89Spbrook  done
341725be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
34183d0f1517SJuan Quintelafi
3419de83cd02Sbellard
3420e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
342125be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3422e5fe0c52Spbrookfi
3423bd0c5661Spbrookif test "$target_user_only" = "yes" \
3424bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
342525be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3426bd0c5661Spbrookfi
3427379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
342825be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3429379f6698SPaul Brookfi
343084778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
343125be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
343284778508Sblueswir1fi
34335b0753e0Sbellard
34344afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3435fa282484SJuan Quintela
34364afddb55SJuan Quintelacflags=""
3437f9728943SPaolo Bonziniincludes=""
3438fa282484SJuan Quintelaldflags=""
34399b8e111fSJuan Quintela
344057ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
3441f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
344224e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3443f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
34445d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3445f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
344657ddfbf7SJuan Quintelaelse
3447f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
344857ddfbf7SJuan Quintelafi
3449f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
3450f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/fpu $includes"
345157ddfbf7SJuan Quintela
34524d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
34534d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
34544d904533SBlue Swirlelse
34554d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
34564d904533SBlue Swirlfi
34574d904533SBlue Swirl
345864656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
345964656024SJuan Quintela  case "$i" in
346064656024SJuan Quintela  alpha)
346125be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
34624d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
346364656024SJuan Quintela  ;;
346464656024SJuan Quintela  arm)
346525be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
34664d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
346764656024SJuan Quintela  ;;
346864656024SJuan Quintela  cris)
346925be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
34704d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
347164656024SJuan Quintela  ;;
347264656024SJuan Quintela  hppa)
347325be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
34744d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
347564656024SJuan Quintela  ;;
347664656024SJuan Quintela  i386|x86_64)
347725be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
34784d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
347964656024SJuan Quintela  ;;
3480903ec55cSAurelien Jarno  ia64*)
3481903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3482903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3483903ec55cSAurelien Jarno  ;;
348464656024SJuan Quintela  m68k)
348525be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
34864d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
348764656024SJuan Quintela  ;;
3488877fdc12SEdgar E. Iglesias  microblaze*)
348925be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
34904d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
349164656024SJuan Quintela  ;;
349264656024SJuan Quintela  mips*)
349325be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
34944d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
349564656024SJuan Quintela  ;;
349664656024SJuan Quintela  ppc*)
349725be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
34984d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
349964656024SJuan Quintela  ;;
350024e804ecSAlexander Graf  s390*)
350125be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
35024d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
350364656024SJuan Quintela  ;;
350464656024SJuan Quintela  sh4)
350525be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
35064d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
350764656024SJuan Quintela  ;;
350864656024SJuan Quintela  sparc*)
350925be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
35104d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
351164656024SJuan Quintela  ;;
351264656024SJuan Quintela  esac
351364656024SJuan Quinteladone
351464656024SJuan Quintela
35156ee7126fSJuan Quintelacase "$ARCH" in
35166ee7126fSJuan Quintelaalpha)
35176ee7126fSJuan Quintela  # Ensure there's only a single GP
35186ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
35196ee7126fSJuan Quintela;;
35206ee7126fSJuan Quintelaesac
35216ee7126fSJuan Quintela
352255d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
352355d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
352455d9c04bSJuan Quintela  arm)
352555d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
352655d9c04bSJuan Quintela  ;;
352725a8bb96SMichael Walle  lm32)
352825a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
352925a8bb96SMichael Walle  ;;
353055d9c04bSJuan Quintela  i386|mips|ppc)
353155d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
353255d9c04bSJuan Quintela  ;;
353355d9c04bSJuan Quintela  esac
353455d9c04bSJuan Quintelafi
353555d9c04bSJuan Quintela
353634005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
353734005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
353834005a00SKirill A. Shutemov  cflags="-fpie $cflags"
353934005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
354034005a00SKirill A. Shutemovfi
354134005a00SKirill A. Shutemov
3542471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
3543471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
3544471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
354525be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3546471857ddSJuan Quintelafi
3547471857ddSJuan Quintela
3548d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
354925be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
3550d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
3551d02c1db3SJuan Quintela    cflags="-p $cflags"
3552d02c1db3SJuan Quintela    ldflags="-p $ldflags"
3553d02c1db3SJuan Quintela  fi
3554d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
3555d02c1db3SJuan Quintela    ldflags="-p $ldflags"
355625be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3557d02c1db3SJuan Quintela  fi
3558d02c1db3SJuan Quintelafi
3559d02c1db3SJuan Quintela
35606ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
35619b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3562fa282484SJuan Quintela  case "$ARCH" in
3563fa282484SJuan Quintela  sparc)
3564fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
3565322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
3566fa282484SJuan Quintela    ;;
35674d58be06SRichard Henderson  alpha | s390x)
35684d58be06SRichard Henderson    # The default placement of the application is fine.
35694d58be06SRichard Henderson    ;;
3570fd76e73aSRichard Henderson  *)
3571322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
3572fa282484SJuan Quintela    ;;
3573fa282484SJuan Quintela  esac
3574fa282484SJuan Quintelafi
3575fa282484SJuan Quintela
357625be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
357725be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3578f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
3579fa282484SJuan Quintela
358097a847bcSbellarddone # for target in $targets
35817d13299dSbellard
3582d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
3583e1144d00SMark McLoughlinDIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3584446b9165SAndreas FärberDIRS="$DIRS pc-bios/spapr-rtas"
35852d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
35863e230dd2SCorentin CharyDIRS="$DIRS fsdev ui"
35877d13299dSbellardFILES="Makefile tests/Makefile"
3588e7daa605SthsFILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3589ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3590446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
35912d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
35925ee8ad71SAlex Williamsonfor bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.rom $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
35937ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
35947ea78b74SJan Kiszkadone
3595d1807a4fSPaolo Bonzinimkdir -p $DIRS
35967d13299dSbellardfor f in $FILES ; do
3597eae30c8fSAurelien Jarno    test -e $f || symlink $source_path/$f $f
35987d13299dSbellarddone
35991ad2134fSPaul Brook
3600c34ebfdcSAnthony Liguori# temporary config to build submodules
36012d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
3602c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
360337116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3604c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3605c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3606c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
3607c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
3608c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3609c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
3610c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
3611c34ebfdcSAnthony Liguoridone
3612c34ebfdcSAnthony Liguori
36131ad2134fSPaul Brookfor hwlib in 32 64; do
36141ad2134fSPaul Brook  d=libhw$hwlib
36151ad2134fSPaul Brook  mkdir -p $d
36169953b2fcSBlue Swirl  mkdir -p $d/ide
361711568d6dSPaolo Bonzini  symlink $source_path/Makefile.hw $d/Makefile
3618353ac78dSAneesh Kumar K.V  mkdir -p $d/9pfs
361937116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
36201ad2134fSPaul Brookdone
3621add16157SBlue Swirl
3622111a38b0SRobert Relyeaif [ "$source_path" != `pwd` ]; then
3623111a38b0SRobert Relyea    # out of tree build
3624111a38b0SRobert Relyea    mkdir -p libcacard
3625111a38b0SRobert Relyea    rm -f libcacard/Makefile
362644dc0ca3SAlon Levy    symlink "$source_path/libcacard/Makefile" libcacard/Makefile
3627111a38b0SRobert Relyeafi
3628111a38b0SRobert Relyea
3629add16157SBlue Swirld=libuser
3630add16157SBlue Swirlmkdir -p $d
363111568d6dSPaolo Bonzinisymlink $source_path/Makefile.user $d/Makefile
3632299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
3633299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3634299060a0SKirill A. Shutemovfi
3635b40292e7SJan Kiszka
3636b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
3637b40292e7SJan Kiszka  mkdir -p QMP
3638b40292e7SJan Kiszkafi
3639