xref: /qemu/configure (revision 1ece9905747fb42ab6b2797c8ddde56496f14796)
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=""
116af2be207SJan Kiszkakvm=""
117377529c0SPaolo Bonzininptl=""
118377529c0SPaolo Bonzinisdl=""
119821601eaSJes Sorensenvnc="yes"
120377529c0SPaolo Bonzinisparse="no"
121377529c0SPaolo Bonziniuuid=""
122377529c0SPaolo Bonzinivde=""
123377529c0SPaolo Bonzinivnc_tls=""
124377529c0SPaolo Bonzinivnc_sasl=""
125377529c0SPaolo Bonzinivnc_jpeg=""
126377529c0SPaolo Bonzinivnc_png=""
127377529c0SPaolo Bonzinivnc_thread="no"
128377529c0SPaolo Bonzinixen=""
129d5b93ddfSAnthony PERARDxen_ctrl_version=""
130377529c0SPaolo Bonzinilinux_aio=""
131377529c0SPaolo Bonziniattr=""
132af2be207SJan Kiszkavhost_net=""
133377529c0SPaolo Bonzinixfs=""
134377529c0SPaolo Bonzini
135377529c0SPaolo Bonzinigprof="no"
136377529c0SPaolo Bonzinidebug_tcg="no"
137377529c0SPaolo Bonzinidebug_mon="no"
138377529c0SPaolo Bonzinidebug="no"
139377529c0SPaolo Bonzinistrip_opt="yes"
140377529c0SPaolo Bonzinibigendian="no"
141377529c0SPaolo Bonzinimingw32="no"
142377529c0SPaolo BonziniEXESUF=""
143377529c0SPaolo Bonziniprefix="/usr/local"
144377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
145377529c0SPaolo Bonzinidatadir="\${prefix}/share/qemu"
146377529c0SPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
147377529c0SPaolo Bonzinibindir="\${prefix}/bin"
1483aa5d2beSAlon Levylibdir="\${prefix}/lib"
149377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
150377529c0SPaolo Bonziniconfsuffix="/qemu"
151377529c0SPaolo Bonzinislirp="yes"
152377529c0SPaolo Bonzinifmod_lib=""
153377529c0SPaolo Bonzinifmod_inc=""
154377529c0SPaolo Bonzinioss_lib=""
155377529c0SPaolo Bonzinibsd="no"
156377529c0SPaolo Bonzinilinux="no"
157377529c0SPaolo Bonzinisolaris="no"
158377529c0SPaolo Bonziniprofiler="no"
159377529c0SPaolo Bonzinicocoa="no"
160377529c0SPaolo Bonzinisoftmmu="yes"
161377529c0SPaolo Bonzinilinux_user="no"
162377529c0SPaolo Bonzinidarwin_user="no"
163377529c0SPaolo Bonzinibsd_user="no"
164377529c0SPaolo Bonziniguest_base=""
165377529c0SPaolo Bonziniuname_release=""
166377529c0SPaolo Bonziniio_thread="no"
167377529c0SPaolo Bonzinimixemu="no"
168377529c0SPaolo Bonziniaix="no"
169377529c0SPaolo Bonziniblobs="yes"
170377529c0SPaolo Bonzinipkgversion=""
171377529c0SPaolo Bonzinicheck_utests="no"
172377529c0SPaolo Bonziniuser_pie="no"
173377529c0SPaolo Bonzinizero_malloc=""
174377529c0SPaolo Bonzinitrace_backend="nop"
175377529c0SPaolo Bonzinitrace_file="trace"
176377529c0SPaolo Bonzinispice=""
177377529c0SPaolo Bonzinirbd=""
17836707144SAlon Levysmartcard=""
179111a38b0SRobert Relyeasmartcard_nss=""
18069354a83SHans de Goedeusb_redir=""
181430a3c18SMichael Walleopengl=""
182*1ece9905SAlon Levyzlib="yes"
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"
237cbbab922SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu"
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"
462af2be207SJan Kiszka  kvm="yes"
463af2be207SJan Kiszka  vhost_net="yes"
46407f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
465c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
466c9ec1fe4Sbellard  fi
467fb065187Sbellard;;
4687d13299dSbellardesac
4697d13299dSbellard
4707d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
471b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
47268063649Sblueswir1    usb="bsd"
47383fb7adfSbellard  fi
47484778508Sblueswir1  bsd_user="yes"
4757d3505c5Sbellardfi
4767d3505c5Sbellard
4770db4a067SPaolo Bonzini: ${make=${MAKE-make}}
4780db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
479c886edfbSBlue Swirl: ${python=${PYTHON-python}}
4800db4a067SPaolo Bonzini
4813457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4823457a3f8SJuan Quintela  EXESUF=".exe"
483a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
484e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
485e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
48608f3896aSStefan Weil  LIBS="-lwinmm -lws2_32 -liberty -liphlpapi $LIBS"
487683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
488683035deSPaolo Bonzini  mandir="\${prefix}"
489683035deSPaolo Bonzini  datadir="\${prefix}"
490683035deSPaolo Bonzini  docdir="\${prefix}"
491683035deSPaolo Bonzini  bindir="\${prefix}"
492683035deSPaolo Bonzini  sysconfdir="\${prefix}"
493683035deSPaolo Bonzini  confsuffix=""
4943457a3f8SJuan Quintelafi
4953457a3f8SJuan Quintela
496487fefdbSAnthony Liguoriwerror=""
49785aa5189Sbellard
4987d13299dSbellardfor opt do
499a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
5007d13299dSbellard  case "$opt" in
5012efc3265Sbellard  --help|-h) show_help=yes
5022efc3265Sbellard  ;;
50399123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
50499123e13SMike Frysinger  ;;
505b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5067d13299dSbellard  ;;
507b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
50832ce6337Sbellard  ;;
509ca4deeb1SPaolo Bonzini  --source-path=*)
5107d13299dSbellard  ;;
511ac0df51dSaliguori  --cross-prefix=*)
5127d13299dSbellard  ;;
513ac0df51dSaliguori  --cc=*)
5147d13299dSbellard  ;;
515b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
51683469015Sbellard  ;;
517b1a550a0Spbrook  --make=*) make="$optarg"
5187d13299dSbellard  ;;
5196a882643Spbrook  --install=*) install="$optarg"
5206a882643Spbrook  ;;
521c886edfbSBlue Swirl  --python=*) python="$optarg"
522c886edfbSBlue Swirl  ;;
523e2a2ed06SJuan Quintela  --extra-cflags=*)
5247d13299dSbellard  ;;
525e2a2ed06SJuan Quintela  --extra-ldflags=*)
5267d13299dSbellard  ;;
5272ff6b91eSJuan Quintela  --cpu=*)
5287d13299dSbellard  ;;
529b1a550a0Spbrook  --target-list=*) target_list="$optarg"
530de83cd02Sbellard  ;;
53174242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
53294a420b1SStefan Hajnoczi  ;;
53374242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
5349410b56cSPrerna Saxena  ;;
5357d13299dSbellard  --enable-gprof) gprof="yes"
5367d13299dSbellard  ;;
53779427693SLoïc Minier  --static)
53879427693SLoïc Minier    static="yes"
53979427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
54043ce4dfeSbellard  ;;
5410b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5420b24e75fSPaolo Bonzini  ;;
5430b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5440b24e75fSPaolo Bonzini  ;;
5453aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
5463aa5d2beSAlon Levy  ;;
5470b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5480b24e75fSPaolo Bonzini  ;;
5490b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5500b24e75fSPaolo Bonzini  ;;
551ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
55207381cc1SAnthony Liguori  ;;
55397a847bcSbellard  --disable-sdl) sdl="no"
55497a847bcSbellard  ;;
555c4198157SJuan Quintela  --enable-sdl) sdl="yes"
556c4198157SJuan Quintela  ;;
557821601eaSJes Sorensen  --disable-vnc) vnc="no"
558821601eaSJes Sorensen  ;;
559821601eaSJes Sorensen  --enable-vnc) vnc="yes"
560821601eaSJes Sorensen  ;;
561b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
562102a52e4Sbellard  ;;
563c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
564c2de5c91Smalc  ;;
5652f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5662f6a1ab0Sblueswir1  ;;
5672fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5680c58ac1cSmalc  ;;
5690c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5700c58ac1cSmalc  ;;
571eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
572eb852011SMarkus Armbruster  ;;
573f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
574f8393946Saurel32  ;;
575f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
576f8393946Saurel32  ;;
577b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
578b4475aa2SLuiz Capitulino  ;;
579b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
580b4475aa2SLuiz Capitulino  ;;
581f3d08ee6SPaul Brook  --enable-debug)
582f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
583f3d08ee6SPaul Brook      debug_tcg="yes"
584b4475aa2SLuiz Capitulino      debug_mon="yes"
585f3d08ee6SPaul Brook      debug="yes"
586f3d08ee6SPaul Brook      strip_opt="no"
587f3d08ee6SPaul Brook  ;;
58803b4fe7dSaliguori  --enable-sparse) sparse="yes"
58903b4fe7dSaliguori  ;;
59003b4fe7dSaliguori  --disable-sparse) sparse="no"
59103b4fe7dSaliguori  ;;
5921625af87Saliguori  --disable-strip) strip_opt="no"
5931625af87Saliguori  ;;
5948d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5958d5d2d4cSths  ;;
5961be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
5971be10ad2SJuan Quintela  ;;
5982f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
5992f9606b3Saliguori  ;;
600ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
601ea784e3bSJuan Quintela  ;;
6022f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
6032f6f5c7aSCorentin Chary  ;;
6042f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
6052f6f5c7aSCorentin Chary  ;;
606efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
607efe556adSCorentin Chary  ;;
608efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
609efe556adSCorentin Chary  ;;
610bd023f95SCorentin Chary  --disable-vnc-thread) vnc_thread="no"
611bd023f95SCorentin Chary  ;;
612bd023f95SCorentin Chary  --enable-vnc-thread) vnc_thread="yes"
613bd023f95SCorentin Chary  ;;
614443f1376Sbellard  --disable-slirp) slirp="no"
615c20709aaSbellard  ;;
616ee682d27SStefan Weil  --disable-uuid) uuid="no"
617ee682d27SStefan Weil  ;;
618ee682d27SStefan Weil  --enable-uuid) uuid="yes"
619ee682d27SStefan Weil  ;;
620e0e6c8c0Saliguori  --disable-vde) vde="no"
6218a16d273Sths  ;;
622dfb278bdSJuan Quintela  --enable-vde) vde="yes"
623dfb278bdSJuan Quintela  ;;
624e37630caSaliguori  --disable-xen) xen="no"
625e37630caSaliguori  ;;
626fc321b4bSJuan Quintela  --enable-xen) xen="yes"
627fc321b4bSJuan Quintela  ;;
6282e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
6292e4d9fb1Saurel32  ;;
6304ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6314ffcedb6SJuan Quintela  ;;
632fb599c9aSbalrog  --disable-bluez) bluez="no"
633fb599c9aSbalrog  ;;
634a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
635a20a6f46SJuan Quintela  ;;
6367ba1e619Saliguori  --disable-kvm) kvm="no"
6377ba1e619Saliguori  ;;
638b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
639b31a0277SJuan Quintela  ;;
640cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
641cd4ec0b4SGerd Hoffmann  ;;
642cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
643cd4ec0b4SGerd Hoffmann  ;;
64405c2a3e7Sbellard  --enable-profiler) profiler="yes"
64505c2a3e7Sbellard  ;;
646c2de5c91Smalc  --enable-cocoa)
647c2de5c91Smalc      cocoa="yes" ;
648c2de5c91Smalc      sdl="no" ;
649c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6505b0753e0Sbellard  ;;
651cad25d69Spbrook  --disable-system) softmmu="no"
6520a8e90f4Spbrook  ;;
653cad25d69Spbrook  --enable-system) softmmu="yes"
6540a8e90f4Spbrook  ;;
6550953a80fSZachary Amsden  --disable-user)
6560953a80fSZachary Amsden      linux_user="no" ;
6570953a80fSZachary Amsden      bsd_user="no" ;
6580953a80fSZachary Amsden      darwin_user="no"
6590953a80fSZachary Amsden  ;;
6600953a80fSZachary Amsden  --enable-user) ;;
661831b7825Sths  --disable-linux-user) linux_user="no"
6620a8e90f4Spbrook  ;;
663831b7825Sths  --enable-linux-user) linux_user="yes"
664831b7825Sths  ;;
665831b7825Sths  --disable-darwin-user) darwin_user="no"
666831b7825Sths  ;;
667831b7825Sths  --enable-darwin-user) darwin_user="yes"
6680a8e90f4Spbrook  ;;
66984778508Sblueswir1  --disable-bsd-user) bsd_user="no"
67084778508Sblueswir1  ;;
67184778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
67284778508Sblueswir1  ;;
673379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
674379f6698SPaul Brook  ;;
675379f6698SPaul Brook  --disable-guest-base) guest_base="no"
676379f6698SPaul Brook  ;;
67734005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
67834005a00SKirill A. Shutemov  ;;
67934005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
68034005a00SKirill A. Shutemov  ;;
681c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
682c5937220Spbrook  ;;
6833142255cSblueswir1  --sparc_cpu=*)
6843142255cSblueswir1  ;;
68585aa5189Sbellard  --enable-werror) werror="yes"
68685aa5189Sbellard  ;;
68785aa5189Sbellard  --disable-werror) werror="no"
68885aa5189Sbellard  ;;
6894d3b6f6eSbalrog  --disable-curses) curses="no"
6904d3b6f6eSbalrog  ;;
691c584a6d0SJuan Quintela  --enable-curses) curses="yes"
692c584a6d0SJuan Quintela  ;;
693769ce76dSAlexander Graf  --disable-curl) curl="no"
694769ce76dSAlexander Graf  ;;
695788c8196SJuan Quintela  --enable-curl) curl="yes"
696788c8196SJuan Quintela  ;;
6972df87df7SJuan Quintela  --disable-fdt) fdt="no"
6982df87df7SJuan Quintela  ;;
6992df87df7SJuan Quintela  --enable-fdt) fdt="yes"
7002df87df7SJuan Quintela  ;;
7015495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
7025495ed11SLuiz Capitulino  ;;
7035495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
7045495ed11SLuiz Capitulino  ;;
705bd0c5661Spbrook  --disable-nptl) nptl="no"
706bd0c5661Spbrook  ;;
707b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
708b0a47e79SJuan Quintela  ;;
7098ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
7108ff9cbf7Smalc  ;;
7115c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
7125c6c3a6cSChristoph Hellwig  ;;
7135c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
7145c6c3a6cSChristoph Hellwig  ;;
715758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
716758e8e38SVenkateswararao Jujjuri (JV)  ;;
717758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
718758e8e38SVenkateswararao Jujjuri (JV)  ;;
719e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
720e5d355d1Saliguori  ;;
72177755340Sths  --disable-blobs) blobs="no"
72277755340Sths  ;;
7234a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
7244a19f1ecSpbrook  ;;
725a25dba17SJuan Quintela  --disable-docs) docs="no"
72670ec5dc0SAnthony Liguori  ;;
727a25dba17SJuan Quintela  --enable-docs) docs="yes"
72883a3ab8bSJuan Quintela  ;;
729d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
730d5970055SMichael S. Tsirkin  ;;
731d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
732d5970055SMichael S. Tsirkin  ;;
73320ff075bSMichael Walle  --disable-opengl) opengl="no"
73420ff075bSMichael Walle  ;;
73520ff075bSMichael Walle  --enable-opengl) opengl="yes"
73620ff075bSMichael Walle  ;;
7376bde81cbSPaolo Bonzini  --*dir)
7386bde81cbSPaolo Bonzini  ;;
739f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
740f27aaf4bSChristian Brunner  ;;
741f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
742f27aaf4bSChristian Brunner  ;;
74336707144SAlon Levy  --disable-smartcard) smartcard="no"
74436707144SAlon Levy  ;;
74536707144SAlon Levy  --enable-smartcard) smartcard="yes"
74636707144SAlon Levy  ;;
747111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
748111a38b0SRobert Relyea  ;;
749111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
750111a38b0SRobert Relyea  ;;
75169354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
75269354a83SHans de Goede  ;;
75369354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
75469354a83SHans de Goede  ;;
755*1ece9905SAlon Levy  --disable-zlib-test) zlib="no"
756*1ece9905SAlon Levy  ;;
7577f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7587f1559c6Sbalrog  ;;
7597d13299dSbellard  esac
7607d13299dSbellarddone
7617d13299dSbellard
7623142255cSblueswir1#
7633142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
764a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7653142255cSblueswir1#
766379f6698SPaul Brookhost_guest_base="no"
76740293e58Sbellardcase "$cpu" in
768ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
769ed968ff1SJuan Quintela           v7|v8)
770a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
771ed968ff1SJuan Quintela           ;;
772ed968ff1SJuan Quintela           v8plus|v8plusa)
773a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
774ed968ff1SJuan Quintela           ;;
775ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
776a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
777ed968ff1SJuan Quintela           esac
7780c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
779a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
780762e8230Sblueswir1           if test "$solaris" = "no" ; then
781a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
782c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
783762e8230Sblueswir1           fi
7843142255cSblueswir1           ;;
785ed968ff1SJuan Quintela    sparc64)
786a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7870c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
788a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
789ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
790a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
791762e8230Sblueswir1           fi
7923142255cSblueswir1           ;;
79376d83bdeSths    s390)
79428d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
79528d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
79648bb3750SRichard Henderson           host_guest_base="yes"
79728d7cc49SRichard Henderson           ;;
79828d7cc49SRichard Henderson    s390x)
79928d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
80028d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
80148bb3750SRichard Henderson           host_guest_base="yes"
80276d83bdeSths           ;;
80340293e58Sbellard    i386)
804a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
8050c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
8062b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
807c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
808379f6698SPaul Brook           host_guest_base="yes"
80940293e58Sbellard           ;;
81040293e58Sbellard    x86_64)
811a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
8120c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8132b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
814379f6698SPaul Brook           host_guest_base="yes"
815379f6698SPaul Brook           ;;
816379f6698SPaul Brook    arm*)
817379f6698SPaul Brook           host_guest_base="yes"
81840293e58Sbellard           ;;
819f6548c0aSmalc    ppc*)
820f6548c0aSmalc           host_guest_base="yes"
821f6548c0aSmalc           ;;
822cc01cc8eSAurelien Jarno    mips*)
823cc01cc8eSAurelien Jarno           host_guest_base="yes"
824cc01cc8eSAurelien Jarno           ;;
825477ba620SAurelien Jarno    ia64*)
826477ba620SAurelien Jarno           host_guest_base="yes"
827477ba620SAurelien Jarno           ;;
828fd76e73aSRichard Henderson    hppa*)
829fd76e73aSRichard Henderson           host_guest_base="yes"
830fd76e73aSRichard Henderson           ;;
831d2fbca94SGuan Xuetao    unicore32*)
832d2fbca94SGuan Xuetao           host_guest_base="yes"
833d2fbca94SGuan Xuetao           ;;
8343142255cSblueswir1esac
8353142255cSblueswir1
836379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
837379f6698SPaul Brook
83860e0df25SPeter Maydell
83960e0df25SPeter Maydelldefault_target_list=""
84060e0df25SPeter Maydell
84160e0df25SPeter Maydell# these targets are portable
84260e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
84360e0df25SPeter Maydell    default_target_list="\
84460e0df25SPeter Maydelli386-softmmu \
84560e0df25SPeter Maydellx86_64-softmmu \
846b758aca1SRichard Hendersonalpha-softmmu \
84760e0df25SPeter Maydellarm-softmmu \
84860e0df25SPeter Maydellcris-softmmu \
84960e0df25SPeter Maydelllm32-softmmu \
85060e0df25SPeter Maydellm68k-softmmu \
85160e0df25SPeter Maydellmicroblaze-softmmu \
85260e0df25SPeter Maydellmicroblazeel-softmmu \
85360e0df25SPeter Maydellmips-softmmu \
85460e0df25SPeter Maydellmipsel-softmmu \
85560e0df25SPeter Maydellmips64-softmmu \
85660e0df25SPeter Maydellmips64el-softmmu \
85760e0df25SPeter Maydellppc-softmmu \
85860e0df25SPeter Maydellppcemb-softmmu \
85960e0df25SPeter Maydellppc64-softmmu \
86060e0df25SPeter Maydellsh4-softmmu \
86160e0df25SPeter Maydellsh4eb-softmmu \
86260e0df25SPeter Maydellsparc-softmmu \
86360e0df25SPeter Maydellsparc64-softmmu \
8640f3301d4SAlexander Grafs390x-softmmu \
86560e0df25SPeter Maydell"
86660e0df25SPeter Maydellfi
86760e0df25SPeter Maydell# the following are Linux specific
86860e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
86960e0df25SPeter Maydell    default_target_list="${default_target_list}\
87060e0df25SPeter Maydelli386-linux-user \
87160e0df25SPeter Maydellx86_64-linux-user \
87260e0df25SPeter Maydellalpha-linux-user \
87360e0df25SPeter Maydellarm-linux-user \
87460e0df25SPeter Maydellarmeb-linux-user \
87560e0df25SPeter Maydellcris-linux-user \
87660e0df25SPeter Maydellm68k-linux-user \
87760e0df25SPeter Maydellmicroblaze-linux-user \
87860e0df25SPeter Maydellmicroblazeel-linux-user \
87960e0df25SPeter Maydellmips-linux-user \
88060e0df25SPeter Maydellmipsel-linux-user \
88160e0df25SPeter Maydellppc-linux-user \
88260e0df25SPeter Maydellppc64-linux-user \
88360e0df25SPeter Maydellppc64abi32-linux-user \
88460e0df25SPeter Maydellsh4-linux-user \
88560e0df25SPeter Maydellsh4eb-linux-user \
88660e0df25SPeter Maydellsparc-linux-user \
88760e0df25SPeter Maydellsparc64-linux-user \
88860e0df25SPeter Maydellsparc32plus-linux-user \
88960e0df25SPeter Maydellunicore32-linux-user \
8900f3301d4SAlexander Grafs390x-linux-user \
89160e0df25SPeter Maydell"
89260e0df25SPeter Maydellfi
89360e0df25SPeter Maydell# the following are Darwin specific
89460e0df25SPeter Maydellif [ "$darwin_user" = "yes" ] ; then
89560e0df25SPeter Maydell    default_target_list="$default_target_list i386-darwin-user ppc-darwin-user "
89660e0df25SPeter Maydellfi
89760e0df25SPeter Maydell# the following are BSD specific
89860e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
89960e0df25SPeter Maydell    default_target_list="${default_target_list}\
90060e0df25SPeter Maydelli386-bsd-user \
90160e0df25SPeter Maydellx86_64-bsd-user \
90260e0df25SPeter Maydellsparc-bsd-user \
90360e0df25SPeter Maydellsparc64-bsd-user \
90460e0df25SPeter Maydell"
90560e0df25SPeter Maydellfi
90660e0df25SPeter Maydell
907af5db58eSpbrookif test x"$show_help" = x"yes" ; then
908af5db58eSpbrookcat << EOF
909af5db58eSpbrook
910af5db58eSpbrookUsage: configure [options]
911af5db58eSpbrookOptions: [defaults in brackets after descriptions]
912af5db58eSpbrook
913af5db58eSpbrookEOF
914af5db58eSpbrookecho "Standard options:"
915af5db58eSpbrookecho "  --help                   print this message"
916af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
917af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
918af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
91960e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
92060e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
92160e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
922af5db58eSpbrookecho ""
923af5db58eSpbrookecho "Advanced options (experts only):"
924af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
925af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
926af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
9270bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
9280bfe8cc0SPaolo Bonziniecho "                           build time"
929a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
930e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
931af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
9326a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
933c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
934af5db58eSpbrookecho "  --static                 enable static build [$static]"
9350b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
9360b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
9370b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
9380b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
9390b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
940f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
941f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
94209695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
943890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
944890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
9451625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
94685aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
947fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
948c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
949821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
950821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
951af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
952c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
953c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
9544c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
9554c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
956eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
957eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
9588ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
959e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
960fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
9612e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
9624ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
9638d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
9641be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
9652f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
966ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
9672f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
9682f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
96996763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
970efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
971bd023f95SCorentin Charyecho "  --disable-vnc-thread     disable threaded VNC server"
972bd023f95SCorentin Charyecho "  --enable-vnc-thread      enable threaded VNC server"
973af896aaaSpbrookecho "  --disable-curses         disable curses output"
974c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
975769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
976788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
9772df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
9782df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
9795495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
9805495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
981fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
982a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
9836093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
9847ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
985b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
986bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
987e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
988af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
989af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
9900953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
9910953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
992831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
993831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
994831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
995831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
99684778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
99784778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
998379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
999379f6698SPaul Brookecho "                           emulation targets"
1000379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
100134005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
100234005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
1003af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1004af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
10052f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1006c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
10073142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
1008ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1009ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1010e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1011dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
10125c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
10135c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
1014758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1015758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
1016e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
101777755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1018d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1019d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1020d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1021d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1022320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1023320fba2aSFabien Chouteauecho "                           Available backends:" $("$source_path"/scripts/tracetool --list-backends)
102474242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
10259410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1026cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1027cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1028f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
102936707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
103036707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1031111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1032111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
103369354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
103469354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1035af5db58eSpbrookecho ""
10365bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1037af5db58eSpbrookexit 1
1038af5db58eSpbrookfi
1039af5db58eSpbrook
10408d05095cSPaolo Bonzini# check that the C compiler works.
10418d05095cSPaolo Bonzinicat > $TMPC <<EOF
10428d05095cSPaolo Bonziniint main(void) {}
10438d05095cSPaolo BonziniEOF
10448d05095cSPaolo Bonzini
10458d05095cSPaolo Bonziniif compile_object ; then
10468d05095cSPaolo Bonzini  : C compiler works ok
10478d05095cSPaolo Bonzinielse
10488d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
10498d05095cSPaolo Bonzini    exit 1
10508d05095cSPaolo Bonzinifi
10518d05095cSPaolo Bonzini
10528d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
10538d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
10548d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1055f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
10568d05095cSPaolo Bonzinicat > $TMPC << EOF
10578d05095cSPaolo Bonziniint main(void) { return 0; }
10588d05095cSPaolo BonziniEOF
10598d05095cSPaolo Bonzinifor flag in $gcc_flags; do
10608d05095cSPaolo Bonzini    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
10618d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
10628d05095cSPaolo Bonzini    fi
10638d05095cSPaolo Bonzinidone
10648d05095cSPaolo Bonzini
1065ec530c81Sbellard#
1066ec530c81Sbellard# Solaris specific configure tool chain decisions
1067ec530c81Sbellard#
1068ec530c81Sbellardif test "$solaris" = "yes" ; then
10696792aa11SLoïc Minier  if has $install; then
10706792aa11SLoïc Minier    :
10716792aa11SLoïc Minier  else
1072ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1073ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1074ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1075ec530c81Sbellard    exit 1
1076ec530c81Sbellard  fi
10776792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1078ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1079ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1080ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1081ec530c81Sbellard    exit 1
1082ec530c81Sbellard  fi
10836792aa11SLoïc Minier  if has ar; then
10846792aa11SLoïc Minier    :
10856792aa11SLoïc Minier  else
1086ec530c81Sbellard    echo "Error: No path includes ar"
1087ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1088ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1089ec530c81Sbellard    fi
1090ec530c81Sbellard    exit 1
1091ec530c81Sbellard  fi
1092ec530c81Sbellardfi
1093ec530c81Sbellard
1094c886edfbSBlue Swirlif has $python; then
1095c886edfbSBlue Swirl  :
1096c886edfbSBlue Swirlelse
1097c886edfbSBlue Swirl  echo "Python not found. Use --python=/path/to/python"
1098c886edfbSBlue Swirl  exit 1
1099c886edfbSBlue Swirlfi
1100c886edfbSBlue Swirl
11015327cf48Sbellardif test -z "$target_list" ; then
110260e0df25SPeter Maydell    target_list="$default_target_list"
11036e20a45fSbellardelse
1104b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
11055327cf48Sbellardfi
11060a8e90f4Spbrookif test -z "$target_list" ; then
11070a8e90f4Spbrook    echo "No targets enabled"
11080a8e90f4Spbrook    exit 1
11090a8e90f4Spbrookfi
1110f55fe278SPaolo Bonzini# see if system emulation was really requested
1111f55fe278SPaolo Bonzinicase " $target_list " in
1112f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1113f55fe278SPaolo Bonzini  ;;
1114f55fe278SPaolo Bonzini  *) softmmu=no
1115f55fe278SPaolo Bonzini  ;;
1116f55fe278SPaolo Bonziniesac
11175327cf48Sbellard
1118249247c9SJuan Quintelafeature_not_found() {
1119249247c9SJuan Quintela  feature=$1
1120249247c9SJuan Quintela
1121249247c9SJuan Quintela  echo "ERROR"
1122249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
11239332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1124249247c9SJuan Quintela  echo "ERROR"
1125249247c9SJuan Quintela  exit 1;
1126249247c9SJuan Quintela}
1127249247c9SJuan Quintela
11287d13299dSbellardif test -z "$cross_prefix" ; then
11297d13299dSbellard
11307d13299dSbellard# ---
11317d13299dSbellard# big/little endian test
11327d13299dSbellardcat > $TMPC << EOF
11337d13299dSbellard#include <inttypes.h>
11347d13299dSbellardint main(int argc, char ** argv){
11357d13299dSbellard        volatile uint32_t i=0x01234567;
11367d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
11377d13299dSbellard}
11387d13299dSbellardEOF
11397d13299dSbellard
114052166aa0SJuan Quintelaif compile_prog "" "" ; then
11417d13299dSbellard$TMPE && bigendian="yes"
11427d13299dSbellardelse
11437d13299dSbellardecho big/little test failed
11447d13299dSbellardfi
11457d13299dSbellard
11467d13299dSbellardelse
11477d13299dSbellard
11487d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1149ea8f20f8SJuan Quintelacase "$cpu" in
115024e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1151ea8f20f8SJuan Quintela    bigendian=yes
1152ea8f20f8SJuan Quintela  ;;
1153ea8f20f8SJuan Quintelaesac
11547d13299dSbellard
11557d13299dSbellardfi
11567d13299dSbellard
115770be1a2eSPaolo Bonzini# host long bits test, actually a pointer size test
115870be1a2eSPaolo Bonzinicat > $TMPC << EOF
115970be1a2eSPaolo Bonziniint sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
116070be1a2eSPaolo BonziniEOF
116170be1a2eSPaolo Bonziniif compile_object; then
1162ea8f20f8SJuan Quintelahostlongbits=64
116370be1a2eSPaolo Bonzinielse
116470be1a2eSPaolo Bonzinihostlongbits=32
116570be1a2eSPaolo Bonzinifi
1166b6853697Sbellard
1167b0a47e79SJuan Quintela
1168b0a47e79SJuan Quintela##########################################
1169b0a47e79SJuan Quintela# NPTL probe
1170b0a47e79SJuan Quintela
1171b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1172bd0c5661Spbrook  cat > $TMPC <<EOF
1173bd0c5661Spbrook#include <sched.h>
117430813ceaSpbrook#include <linux/futex.h>
1175bd0c5661Spbrookvoid foo()
1176bd0c5661Spbrook{
1177bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1178bd0c5661Spbrook#error bork
1179bd0c5661Spbrook#endif
1180bd0c5661Spbrook}
1181bd0c5661SpbrookEOF
1182bd0c5661Spbrook
118352166aa0SJuan Quintela  if compile_object ; then
1184b0a47e79SJuan Quintela    nptl=yes
1185bd0c5661Spbrook  else
1186b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1187b0a47e79SJuan Quintela      feature_not_found "nptl"
1188b0a47e79SJuan Quintela    fi
1189b0a47e79SJuan Quintela    nptl=no
1190b0a47e79SJuan Quintela  fi
1191bd0c5661Spbrookfi
1192bd0c5661Spbrook
119311d9f695Sbellard##########################################
1194ac62922eSbalrog# zlib check
1195ac62922eSbalrog
1196*1ece9905SAlon Levyif test "$zlib" != "no" ; then
1197ac62922eSbalrog    cat > $TMPC << EOF
1198ac62922eSbalrog#include <zlib.h>
1199ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1200ac62922eSbalrogEOF
120152166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1202ac62922eSbalrog        :
1203ac62922eSbalrog    else
1204ac62922eSbalrog        echo
1205ac62922eSbalrog        echo "Error: zlib check failed"
1206ac62922eSbalrog        echo "Make sure to have the zlib libs and headers installed."
1207ac62922eSbalrog        echo
1208ac62922eSbalrog        exit 1
1209ac62922eSbalrog    fi
1210*1ece9905SAlon Levyfi
1211ac62922eSbalrog
1212ac62922eSbalrog##########################################
1213e37630caSaliguori# xen probe
1214e37630caSaliguori
1215fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1216b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1217d5b93ddfSAnthony PERARD
1218d5b93ddfSAnthony PERARD  # Xen unstable
1219e37630caSaliguori  cat > $TMPC <<EOF
1220e37630caSaliguori#include <xenctrl.h>
1221e37630caSaliguori#include <xs.h>
1222d5b93ddfSAnthony PERARD#include <stdint.h>
1223d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1224d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1225d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1226d5b93ddfSAnthony PERARD#endif
1227d5b93ddfSAnthony PERARDint main(void) {
1228d5b93ddfSAnthony PERARD  xc_interface *xc;
1229d5b93ddfSAnthony PERARD  xs_daemon_open();
1230d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1231d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1232d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1233b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1234d5b93ddfSAnthony PERARD  return 0;
1235d5b93ddfSAnthony PERARD}
1236e37630caSaliguoriEOF
123752166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1238d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1239fc321b4bSJuan Quintela    xen=yes
1240d5b93ddfSAnthony PERARD
1241d5b93ddfSAnthony PERARD  # Xen 4.0.0
1242d5b93ddfSAnthony PERARD  elif (
1243d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1244d5b93ddfSAnthony PERARD#include <xenctrl.h>
1245d5b93ddfSAnthony PERARD#include <xs.h>
1246d5b93ddfSAnthony PERARD#include <stdint.h>
1247d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1248d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1249d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1250d5b93ddfSAnthony PERARD#endif
1251d5b93ddfSAnthony PERARDint main(void) {
1252b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1253b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1254b87de24eSAnthony PERARD  };
1255d5b93ddfSAnthony PERARD  xs_daemon_open();
1256d5b93ddfSAnthony PERARD  xc_interface_open();
1257d5b93ddfSAnthony PERARD  xc_gnttab_open();
1258d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1259b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1260d5b93ddfSAnthony PERARD  return 0;
1261d5b93ddfSAnthony PERARD}
1262d5b93ddfSAnthony PERARDEOF
1263d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1264d5b93ddfSAnthony PERARD    ) ; then
1265d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1266d5b93ddfSAnthony PERARD    xen=yes
1267d5b93ddfSAnthony PERARD
1268b87de24eSAnthony PERARD  # Xen 3.4.0
1269b87de24eSAnthony PERARD  elif (
1270b87de24eSAnthony PERARD      cat > $TMPC <<EOF
1271b87de24eSAnthony PERARD#include <xenctrl.h>
1272b87de24eSAnthony PERARD#include <xs.h>
1273b87de24eSAnthony PERARDint main(void) {
1274b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1275b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1276b87de24eSAnthony PERARD  };
1277b87de24eSAnthony PERARD  xs_daemon_open();
1278b87de24eSAnthony PERARD  xc_interface_open();
1279b87de24eSAnthony PERARD  xc_gnttab_open();
1280b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1281b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1282b87de24eSAnthony PERARD  return 0;
1283b87de24eSAnthony PERARD}
1284b87de24eSAnthony PERARDEOF
1285b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
1286b87de24eSAnthony PERARD    ) ; then
1287b87de24eSAnthony PERARD    xen_ctrl_version=340
1288b87de24eSAnthony PERARD    xen=yes
1289b87de24eSAnthony PERARD
1290b87de24eSAnthony PERARD  # Xen 3.3.0
1291d5b93ddfSAnthony PERARD  elif (
1292d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1293d5b93ddfSAnthony PERARD#include <xenctrl.h>
1294d5b93ddfSAnthony PERARD#include <xs.h>
1295d5b93ddfSAnthony PERARDint main(void) {
1296d5b93ddfSAnthony PERARD  xs_daemon_open();
1297d5b93ddfSAnthony PERARD  xc_interface_open();
1298d5b93ddfSAnthony PERARD  xc_gnttab_open();
1299d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1300d5b93ddfSAnthony PERARD  return 0;
1301d5b93ddfSAnthony PERARD}
1302d5b93ddfSAnthony PERARDEOF
1303d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1304d5b93ddfSAnthony PERARD    ) ; then
1305d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1306d5b93ddfSAnthony PERARD    xen=yes
1307d5b93ddfSAnthony PERARD
1308d5b93ddfSAnthony PERARD  # Xen not found or unsupported
1309e37630caSaliguori  else
1310fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1311fc321b4bSJuan Quintela      feature_not_found "xen"
1312fc321b4bSJuan Quintela    fi
1313fc321b4bSJuan Quintela    xen=no
1314e37630caSaliguori  fi
1315d5b93ddfSAnthony PERARD
1316d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1317d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1318d5b93ddfSAnthony PERARD  fi
1319e37630caSaliguorifi
1320e37630caSaliguori
1321e37630caSaliguori##########################################
1322a8bd70adSPaolo Bonzini# pkg-config probe
1323f91672e5SPaolo Bonzini
1324a8bd70adSPaolo Bonziniif ! has $pkg_config; then
132508421541SPaolo Bonzini  echo warning: proceeding without "$pkg_config" >&2
132608421541SPaolo Bonzini  pkg_config=/bin/false
1327f91672e5SPaolo Bonzinifi
1328f91672e5SPaolo Bonzini
1329f91672e5SPaolo Bonzini##########################################
133044dc0ca3SAlon Levy# libtool probe
133144dc0ca3SAlon Levy
133244dc0ca3SAlon Levyif ! has libtool; then
133344dc0ca3SAlon Levy    libtool=
133444dc0ca3SAlon Levyelse
133544dc0ca3SAlon Levy    libtool=libtool
133644dc0ca3SAlon Levyfi
133744dc0ca3SAlon Levy
133844dc0ca3SAlon Levy##########################################
1339dfffc653SJuan Quintela# Sparse probe
1340dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
13410dba6195SLoïc Minier  if has cgcc; then
1342dfffc653SJuan Quintela    sparse=yes
1343dfffc653SJuan Quintela  else
1344dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1345dfffc653SJuan Quintela      feature_not_found "sparse"
1346dfffc653SJuan Quintela    fi
1347dfffc653SJuan Quintela    sparse=no
1348dfffc653SJuan Quintela  fi
1349dfffc653SJuan Quintelafi
1350dfffc653SJuan Quintela
1351dfffc653SJuan Quintela##########################################
135211d9f695Sbellard# SDL probe
135311d9f695Sbellard
13543ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
13553ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
13563ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
13573ec87ffeSPaolo Bonzini  sdl_config=sdl-config
13583ec87ffeSPaolo Bonzinifi
13593ec87ffeSPaolo Bonzini
13603ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1361a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1362fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
13633ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
13643ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
13659316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1366a0dfd8a4SLoïc Minierelse
1367a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1368a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1369a0dfd8a4SLoïc Minier  fi
1370a0dfd8a4SLoïc Minier  sdl=no
13719316f803SPaolo Bonzinifi
137229e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
13733ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
13743ec87ffeSPaolo Bonzinifi
137511d9f695Sbellard
13769316f803SPaolo Bonzinisdl_too_old=no
1377c4198157SJuan Quintelaif test "$sdl" != "no" ; then
137811d9f695Sbellard  cat > $TMPC << EOF
137911d9f695Sbellard#include <SDL.h>
138011d9f695Sbellard#undef main /* We don't want SDL to override our main() */
138111d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
138211d9f695SbellardEOF
13839316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
138474f42e18STeLeMan  if test "$static" = "yes" ; then
138574f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
138674f42e18STeLeMan  else
13879316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
138874f42e18STeLeMan  fi
138952166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
139011d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
139111d9f695Sbellard      sdl_too_old=yes
139211d9f695Sbellard    else
1393fd677642Sths      if test "$cocoa" = "no" ; then
139411d9f695Sbellard        sdl=yes
139511d9f695Sbellard      fi
1396fd677642Sths    fi
13977c1f25b4Sbellard
139867c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
13991ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
140067c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1401f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1402f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
140311d9f695Sbellard      fi
140452166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
14051ac88f28SJuan Quintela	:
14061ac88f28SJuan Quintela      else
14071ac88f28SJuan Quintela        sdl=no
14087c1f25b4Sbellard      fi
14097c1f25b4Sbellard    fi # static link
1410c4198157SJuan Quintela  else # sdl not found
1411c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1412c4198157SJuan Quintela      feature_not_found "sdl"
1413c4198157SJuan Quintela    fi
1414c4198157SJuan Quintela    sdl=no
14157c1f25b4Sbellard  fi # sdl compile test
1416fd677642Sthsfi
141711d9f695Sbellard
14185368a422Saliguoriif test "$sdl" = "yes" ; then
14195368a422Saliguori  cat > $TMPC <<EOF
14205368a422Saliguori#include <SDL.h>
14215368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
14225368a422Saliguori#include <X11/XKBlib.h>
14235368a422Saliguori#else
14245368a422Saliguori#error No x11 support
14255368a422Saliguori#endif
14265368a422Saliguoriint main(void) { return 0; }
14275368a422SaliguoriEOF
142852166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1429681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
14305368a422Saliguori  fi
143107d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
143207d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
143307d9ac44SJuan Quintela  fi
14340705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
14355368a422Saliguorifi
14365368a422Saliguori
14378f28f3fbSths##########################################
14388d5d2d4cSths# VNC TLS detection
1439821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1440ae6b5e5aSaliguori  cat > $TMPC <<EOF
1441ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1442ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1443ae6b5e5aSaliguoriEOF
1444a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1445a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
144652166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
14471be10ad2SJuan Quintela    vnc_tls=yes
1448a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1449ae6b5e5aSaliguori  else
14501be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
14511be10ad2SJuan Quintela      feature_not_found "vnc-tls"
14521be10ad2SJuan Quintela    fi
14531be10ad2SJuan Quintela    vnc_tls=no
14548d5d2d4cSths  fi
14558d5d2d4cSthsfi
14568d5d2d4cSths
14578d5d2d4cSths##########################################
14582f9606b3Saliguori# VNC SASL detection
1459821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
14602f9606b3Saliguori  cat > $TMPC <<EOF
14612f9606b3Saliguori#include <sasl/sasl.h>
14622f9606b3Saliguori#include <stdio.h>
14632f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
14642f9606b3SaliguoriEOF
14652f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
14662f9606b3Saliguori  vnc_sasl_cflags=""
14672f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
146852166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1469ea784e3bSJuan Quintela    vnc_sasl=yes
1470fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
14712f9606b3Saliguori  else
1472ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1473ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1474ea784e3bSJuan Quintela    fi
1475ea784e3bSJuan Quintela    vnc_sasl=no
14762f9606b3Saliguori  fi
14772f9606b3Saliguorifi
14782f9606b3Saliguori
14792f9606b3Saliguori##########################################
14802f6f5c7aSCorentin Chary# VNC JPEG detection
1481821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
14822f6f5c7aSCorentin Charycat > $TMPC <<EOF
14832f6f5c7aSCorentin Chary#include <stdio.h>
14842f6f5c7aSCorentin Chary#include <jpeglib.h>
14852f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
14862f6f5c7aSCorentin CharyEOF
14872f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
14882f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
14892f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
14902f6f5c7aSCorentin Chary    vnc_jpeg=yes
14912f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
14922f6f5c7aSCorentin Chary  else
14932f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
14942f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
14952f6f5c7aSCorentin Chary    fi
14962f6f5c7aSCorentin Chary    vnc_jpeg=no
14972f6f5c7aSCorentin Chary  fi
14982f6f5c7aSCorentin Charyfi
14992f6f5c7aSCorentin Chary
15002f6f5c7aSCorentin Chary##########################################
1501efe556adSCorentin Chary# VNC PNG detection
1502821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1503efe556adSCorentin Charycat > $TMPC <<EOF
1504efe556adSCorentin Chary//#include <stdio.h>
1505efe556adSCorentin Chary#include <png.h>
1506832ce9c2SScott Wood#include <stddef.h>
1507efe556adSCorentin Charyint main(void) {
1508efe556adSCorentin Chary    png_structp png_ptr;
1509efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1510efe556adSCorentin Chary    return 0;
1511efe556adSCorentin Chary}
1512efe556adSCorentin CharyEOF
1513efe556adSCorentin Chary    vnc_png_cflags=""
1514efe556adSCorentin Chary    vnc_png_libs="-lpng"
1515efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1516efe556adSCorentin Chary    vnc_png=yes
1517efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
1518efe556adSCorentin Chary  else
1519efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1520efe556adSCorentin Chary      feature_not_found "vnc-png"
1521efe556adSCorentin Chary    fi
1522efe556adSCorentin Chary    vnc_png=no
1523efe556adSCorentin Chary  fi
1524efe556adSCorentin Charyfi
1525efe556adSCorentin Chary
1526efe556adSCorentin Chary##########################################
152776655d6dSaliguori# fnmatch() probe, used for ACL routines
152876655d6dSaliguorifnmatch="no"
152976655d6dSaliguoricat > $TMPC << EOF
153076655d6dSaliguori#include <fnmatch.h>
153176655d6dSaliguoriint main(void)
153276655d6dSaliguori{
153376655d6dSaliguori    fnmatch("foo", "foo", 0);
153476655d6dSaliguori    return 0;
153576655d6dSaliguori}
153676655d6dSaliguoriEOF
153752166aa0SJuan Quintelaif compile_prog "" "" ; then
153876655d6dSaliguori   fnmatch="yes"
153976655d6dSaliguorifi
154076655d6dSaliguori
154176655d6dSaliguori##########################################
1542ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1543ee682d27SStefan Weilif test "$uuid" != "no" ; then
1544ee682d27SStefan Weil  uuid_libs="-luuid"
1545ee682d27SStefan Weil  cat > $TMPC << EOF
1546ee682d27SStefan Weil#include <uuid/uuid.h>
1547ee682d27SStefan Weilint main(void)
1548ee682d27SStefan Weil{
1549ee682d27SStefan Weil    uuid_t my_uuid;
1550ee682d27SStefan Weil    uuid_generate(my_uuid);
1551ee682d27SStefan Weil    return 0;
1552ee682d27SStefan Weil}
1553ee682d27SStefan WeilEOF
1554ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1555ee682d27SStefan Weil    uuid="yes"
1556ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1557ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1558ee682d27SStefan Weil  else
1559ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1560ee682d27SStefan Weil      feature_not_found "uuid"
1561ee682d27SStefan Weil    fi
1562ee682d27SStefan Weil    uuid=no
1563ee682d27SStefan Weil  fi
1564ee682d27SStefan Weilfi
1565ee682d27SStefan Weil
1566ee682d27SStefan Weil##########################################
1567dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1568dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1569dce512deSChristoph Hellwig  cat > $TMPC << EOF
1570dce512deSChristoph Hellwig#include <xfs/xfs.h>
1571dce512deSChristoph Hellwigint main(void)
1572dce512deSChristoph Hellwig{
1573dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1574dce512deSChristoph Hellwig    return 0;
1575dce512deSChristoph Hellwig}
1576dce512deSChristoph HellwigEOF
1577dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1578dce512deSChristoph Hellwig    xfs="yes"
1579dce512deSChristoph Hellwig  else
1580dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1581dce512deSChristoph Hellwig      feature_not_found "xfs"
1582dce512deSChristoph Hellwig    fi
1583dce512deSChristoph Hellwig    xfs=no
1584dce512deSChristoph Hellwig  fi
1585dce512deSChristoph Hellwigfi
1586dce512deSChristoph Hellwig
1587dce512deSChristoph Hellwig##########################################
15888a16d273Sths# vde libraries probe
1589dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
15904baae0acSJuan Quintela  vde_libs="-lvdeplug"
15918a16d273Sths  cat > $TMPC << EOF
15928a16d273Sths#include <libvdeplug.h>
15934a7f0e06Spbrookint main(void)
15944a7f0e06Spbrook{
15954a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
15964a7f0e06Spbrook    vde_open("", "", &a);
15974a7f0e06Spbrook    return 0;
15984a7f0e06Spbrook}
15998a16d273SthsEOF
160052166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
16014baae0acSJuan Quintela    vde=yes
16028e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
16038e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1604dfb278bdSJuan Quintela  else
1605dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1606dfb278bdSJuan Quintela      feature_not_found "vde"
1607dfb278bdSJuan Quintela    fi
1608dfb278bdSJuan Quintela    vde=no
16098a16d273Sths  fi
16108a16d273Sthsfi
16118a16d273Sths
16128a16d273Sths##########################################
1613c2de5c91Smalc# Sound support libraries probe
16148f28f3fbSths
1615c2de5c91Smalcaudio_drv_probe()
1616c2de5c91Smalc{
1617c2de5c91Smalc    drv=$1
1618c2de5c91Smalc    hdr=$2
1619c2de5c91Smalc    lib=$3
1620c2de5c91Smalc    exp=$4
1621c2de5c91Smalc    cfl=$5
16228f28f3fbSths        cat > $TMPC << EOF
1623c2de5c91Smalc#include <$hdr>
1624c2de5c91Smalcint main(void) { $exp }
16258f28f3fbSthsEOF
162652166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
16278f28f3fbSths        :
16288f28f3fbSths    else
16298f28f3fbSths        echo
1630c2de5c91Smalc        echo "Error: $drv check failed"
1631c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
16328f28f3fbSths        echo
16338f28f3fbSths        exit 1
16348f28f3fbSths    fi
1635c2de5c91Smalc}
1636c2de5c91Smalc
16372fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1638c2de5c91Smalcfor drv in $audio_drv_list; do
1639c2de5c91Smalc    case $drv in
1640c2de5c91Smalc    alsa)
1641c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1642c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1643a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1644c2de5c91Smalc    ;;
1645c2de5c91Smalc
1646c2de5c91Smalc    fmod)
1647c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1648c2de5c91Smalc        echo
1649c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1650c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1651c2de5c91Smalc        echo
1652c2de5c91Smalc        exit 1
16538f28f3fbSths    fi
1654c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1655a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1656c2de5c91Smalc    ;;
1657c2de5c91Smalc
1658c2de5c91Smalc    esd)
1659c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1660a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
166167f86e8eSJuan Quintela    audio_pt_int="yes"
1662c2de5c91Smalc    ;;
1663b8e59f18Smalc
1664b8e59f18Smalc    pa)
1665493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
166620fa53ecSMarc-Antoine Perennou        "pa_simple *s = 0; pa_simple_free(s); return 0;"
1667493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
166867f86e8eSJuan Quintela    audio_pt_int="yes"
1669b8e59f18Smalc    ;;
1670b8e59f18Smalc
1671997e690aSJuan Quintela    coreaudio)
1672997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1673997e690aSJuan Quintela    ;;
1674997e690aSJuan Quintela
1675a4bf6780SJuan Quintela    dsound)
1676a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1677d5631638Smalc      audio_win_int="yes"
1678a4bf6780SJuan Quintela    ;;
1679a4bf6780SJuan Quintela
1680a4bf6780SJuan Quintela    oss)
1681a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1682a4bf6780SJuan Quintela    ;;
1683a4bf6780SJuan Quintela
1684a4bf6780SJuan Quintela    sdl|wav)
16852f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
16862f6a1ab0Sblueswir1    ;;
16872f6a1ab0Sblueswir1
1688d5631638Smalc    winwave)
1689d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1690d5631638Smalc      audio_win_int="yes"
1691d5631638Smalc    ;;
1692d5631638Smalc
1693e4c63a6aSmalc    *)
16941c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1695e4c63a6aSmalc        echo
1696e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1697e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1698e4c63a6aSmalc        echo
1699e4c63a6aSmalc        exit 1
1700e4c63a6aSmalc    }
1701e4c63a6aSmalc    ;;
1702c2de5c91Smalc    esac
1703c2de5c91Smalcdone
17048f28f3fbSths
17054d3b6f6eSbalrog##########################################
17062e4d9fb1Saurel32# BrlAPI probe
17072e4d9fb1Saurel32
17084ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1709eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
17102e4d9fb1Saurel32  cat > $TMPC << EOF
17112e4d9fb1Saurel32#include <brlapi.h>
1712832ce9c2SScott Wood#include <stddef.h>
17132e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
17142e4d9fb1Saurel32EOF
171552166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
17162e4d9fb1Saurel32    brlapi=yes
1717264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
17184ffcedb6SJuan Quintela  else
17194ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
17204ffcedb6SJuan Quintela      feature_not_found "brlapi"
17214ffcedb6SJuan Quintela    fi
17224ffcedb6SJuan Quintela    brlapi=no
1723eb82284fSJuan Quintela  fi
1724eb82284fSJuan Quintelafi
17252e4d9fb1Saurel32
17262e4d9fb1Saurel32##########################################
17274d3b6f6eSbalrog# curses probe
1728e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
1729e095e2f3SStefan Weil    curses_list="-lpdcurses"
1730e095e2f3SStefan Weilelse
17314f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
1732e095e2f3SStefan Weilfi
17334d3b6f6eSbalrog
1734c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1735c584a6d0SJuan Quintela  curses_found=no
17364d3b6f6eSbalrog  cat > $TMPC << EOF
17374d3b6f6eSbalrog#include <curses.h>
17385a8ff3aaSblueswir1#ifdef __OpenBSD__
17395a8ff3aaSblueswir1#define resize_term resizeterm
17405a8ff3aaSblueswir1#endif
17415a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
17424d3b6f6eSbalrogEOF
17434f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
17444f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1745c584a6d0SJuan Quintela      curses_found=yes
17464f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
17474f78ef9aSJuan Quintela      break
17484d3b6f6eSbalrog    fi
17494f78ef9aSJuan Quintela  done
1750c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1751c584a6d0SJuan Quintela    curses=yes
1752c584a6d0SJuan Quintela  else
1753c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1754c584a6d0SJuan Quintela      feature_not_found "curses"
1755c584a6d0SJuan Quintela    fi
1756c584a6d0SJuan Quintela    curses=no
1757c584a6d0SJuan Quintela  fi
17584f78ef9aSJuan Quintelafi
17594d3b6f6eSbalrog
1760414f0dabSblueswir1##########################################
1761769ce76dSAlexander Graf# curl probe
1762769ce76dSAlexander Graf
1763a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
1764a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
17654e2b0658SPaolo Bonzinielse
17664e2b0658SPaolo Bonzini  curlconfig=curl-config
17674e2b0658SPaolo Bonzinifi
17684e2b0658SPaolo Bonzini
1769788c8196SJuan Quintelaif test "$curl" != "no" ; then
1770769ce76dSAlexander Graf  cat > $TMPC << EOF
1771769ce76dSAlexander Graf#include <curl/curl.h>
17720b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
1773769ce76dSAlexander GrafEOF
17744e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
17754e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1776b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1777769ce76dSAlexander Graf    curl=yes
1778f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1779f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1780788c8196SJuan Quintela  else
1781788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1782788c8196SJuan Quintela      feature_not_found "curl"
1783788c8196SJuan Quintela    fi
1784788c8196SJuan Quintela    curl=no
1785769ce76dSAlexander Graf  fi
1786769ce76dSAlexander Graffi # test "$curl"
1787769ce76dSAlexander Graf
1788769ce76dSAlexander Graf##########################################
17895495ed11SLuiz Capitulino# check framework probe
17905495ed11SLuiz Capitulino
17915495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
17925495ed11SLuiz Capitulino  cat > $TMPC << EOF
17935495ed11SLuiz Capitulino#include <check.h>
17945495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
17955495ed11SLuiz CapitulinoEOF
1796a8bd70adSPaolo Bonzini  check_libs=`$pkg_config --libs check`
17975495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
17985495ed11SLuiz Capitulino    check_utests=yes
17995495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
18005495ed11SLuiz Capitulino  else
18015495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
18025495ed11SLuiz Capitulino      feature_not_found "check"
18035495ed11SLuiz Capitulino    fi
18045495ed11SLuiz Capitulino    check_utests=no
18055495ed11SLuiz Capitulino  fi
18065495ed11SLuiz Capitulinofi # test "$check_utests"
18075495ed11SLuiz Capitulino
18085495ed11SLuiz Capitulino##########################################
1809fb599c9aSbalrog# bluez support probe
1810a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1811e820e3f4Sbalrog  cat > $TMPC << EOF
1812e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1813e820e3f4Sbalrogint main(void) { return bt_error(0); }
1814e820e3f4SbalrogEOF
1815a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1816a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
181752166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1818a20a6f46SJuan Quintela    bluez=yes
1819e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1820e820e3f4Sbalrog  else
1821a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1822a20a6f46SJuan Quintela      feature_not_found "bluez"
1823a20a6f46SJuan Quintela    fi
1824e820e3f4Sbalrog    bluez="no"
1825e820e3f4Sbalrog  fi
1826fb599c9aSbalrogfi
1827fb599c9aSbalrog
1828fb599c9aSbalrog##########################################
1829e18df141SAnthony Liguori# glib support probe
18301fc7bd4aSAnthony Liguoriif $pkg_config --modversion glib-2.0 > /dev/null 2>&1 ; then
18311fc7bd4aSAnthony Liguori    glib_cflags=`$pkg_config --cflags glib-2.0 2>/dev/null`
18321fc7bd4aSAnthony Liguori    glib_libs=`$pkg_config --libs glib-2.0 2>/dev/null`
1833e18df141SAnthony Liguori    libs_softmmu="$glib_libs $libs_softmmu"
1834e18df141SAnthony Liguori    libs_tools="$glib_libs $libs_tools"
1835e18df141SAnthony Liguorielse
1836e18df141SAnthony Liguori    echo "glib-2.0 required to compile QEMU"
1837e18df141SAnthony Liguori    exit 1
1838e18df141SAnthony Liguorifi
1839e18df141SAnthony Liguori
1840e18df141SAnthony Liguori##########################################
1841e5d355d1Saliguori# pthread probe
1842de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
18433c529d93Saliguori
1844e5d355d1Saliguoripthread=no
1845414f0dabSblueswir1cat > $TMPC << EOF
18463c529d93Saliguori#include <pthread.h>
1847de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1848414f0dabSblueswir1EOF
1849bd00d539SAndreas Färberif compile_prog "" "" ; then
1850bd00d539SAndreas Färber  pthread=yes
1851bd00d539SAndreas Färberelse
1852de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
185352166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
1854e5d355d1Saliguori      pthread=yes
18555572b539SJuan Quintela      LIBS="$pthread_lib $LIBS"
1856de65fe0fSSebastian Herbszt      break
1857414f0dabSblueswir1    fi
1858de65fe0fSSebastian Herbszt  done
1859bd00d539SAndreas Färberfi
1860414f0dabSblueswir1
18614617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
18624dd75c70SChristoph Hellwig  echo
18634dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
18644dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
18654dd75c70SChristoph Hellwig  echo
18664dd75c70SChristoph Hellwig  exit 1
1867e5d355d1Saliguorifi
1868e5d355d1Saliguori
1869bf9298b9Saliguori##########################################
1870f27aaf4bSChristian Brunner# rbd probe
1871f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
1872f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
1873f27aaf4bSChristian Brunner#include <stdio.h>
1874ad32e9c0SJosh Durgin#include <rbd/librbd.h>
1875f27aaf4bSChristian Brunnerint main(void) {
1876ad32e9c0SJosh Durgin    rados_t cluster;
1877ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
1878f27aaf4bSChristian Brunner    return 0;
1879f27aaf4bSChristian Brunner}
1880f27aaf4bSChristian BrunnerEOF
1881ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
1882f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
1883f27aaf4bSChristian Brunner    rbd=yes
1884f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
1885f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
1886f27aaf4bSChristian Brunner  else
1887f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
1888f27aaf4bSChristian Brunner      feature_not_found "rados block device"
1889f27aaf4bSChristian Brunner    fi
1890f27aaf4bSChristian Brunner    rbd=no
1891f27aaf4bSChristian Brunner  fi
1892f27aaf4bSChristian Brunnerfi
1893f27aaf4bSChristian Brunner
1894f27aaf4bSChristian Brunner##########################################
18955c6c3a6cSChristoph Hellwig# linux-aio probe
18965c6c3a6cSChristoph Hellwig
18975c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
18985c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
18995c6c3a6cSChristoph Hellwig#include <libaio.h>
19005c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
1901832ce9c2SScott Wood#include <stddef.h>
19025c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
19035c6c3a6cSChristoph HellwigEOF
19045c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
19055c6c3a6cSChristoph Hellwig    linux_aio=yes
1906048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1907048d179fSPaul Brook    libs_tools="$libs_tools -laio"
19085c6c3a6cSChristoph Hellwig  else
19095c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
19105c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
19115c6c3a6cSChristoph Hellwig    fi
19123cfcae3cSLuiz Capitulino    linux_aio=no
19135c6c3a6cSChristoph Hellwig  fi
19145c6c3a6cSChristoph Hellwigfi
19155c6c3a6cSChristoph Hellwig
19165c6c3a6cSChristoph Hellwig##########################################
1917758e8e38SVenkateswararao Jujjuri (JV)# attr probe
1918758e8e38SVenkateswararao Jujjuri (JV)
1919758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
1920758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
1921758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
1922758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
1923758e8e38SVenkateswararao Jujjuri (JV)#include <attr/xattr.h>
1924758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1925758e8e38SVenkateswararao Jujjuri (JV)EOF
1926758e8e38SVenkateswararao Jujjuri (JV)  if compile_prog "" "-lattr" ; then
1927758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
1928758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
1929758e8e38SVenkateswararao Jujjuri (JV)  else
1930758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
1931758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
1932758e8e38SVenkateswararao Jujjuri (JV)    fi
1933758e8e38SVenkateswararao Jujjuri (JV)    attr=no
1934758e8e38SVenkateswararao Jujjuri (JV)  fi
1935758e8e38SVenkateswararao Jujjuri (JV)fi
1936758e8e38SVenkateswararao Jujjuri (JV)
1937758e8e38SVenkateswararao Jujjuri (JV)##########################################
1938bf9298b9Saliguori# iovec probe
1939bf9298b9Saliguoricat > $TMPC <<EOF
1940db34f0b3Sblueswir1#include <sys/types.h>
1941bf9298b9Saliguori#include <sys/uio.h>
1942db34f0b3Sblueswir1#include <unistd.h>
1943bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1944bf9298b9SaliguoriEOF
1945bf9298b9Saliguoriiovec=no
194652166aa0SJuan Quintelaif compile_prog "" "" ; then
1947bf9298b9Saliguori  iovec=yes
1948bf9298b9Saliguorifi
1949bf9298b9Saliguori
1950f652e6afSaurel32##########################################
1951ceb42de8Saliguori# preadv probe
1952ceb42de8Saliguoricat > $TMPC <<EOF
1953ceb42de8Saliguori#include <sys/types.h>
1954ceb42de8Saliguori#include <sys/uio.h>
1955ceb42de8Saliguori#include <unistd.h>
1956ceb42de8Saliguoriint main(void) { preadv; }
1957ceb42de8SaliguoriEOF
1958ceb42de8Saliguoripreadv=no
195952166aa0SJuan Quintelaif compile_prog "" "" ; then
1960ceb42de8Saliguori  preadv=yes
1961ceb42de8Saliguorifi
1962ceb42de8Saliguori
1963ceb42de8Saliguori##########################################
1964f652e6afSaurel32# fdt probe
19652df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1966b41af4baSJuan Quintela  fdt_libs="-lfdt"
1967f652e6afSaurel32  cat > $TMPC << EOF
1968f652e6afSaurel32int main(void) { return 0; }
1969f652e6afSaurel32EOF
197052166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1971f652e6afSaurel32    fdt=yes
19722df87df7SJuan Quintela  else
19732df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
19742df87df7SJuan Quintela      feature_not_found "fdt"
19752df87df7SJuan Quintela    fi
1976de3a354aSMichael Walle    fdt_libs=
19772df87df7SJuan Quintela    fdt=no
1978f652e6afSaurel32  fi
1979f652e6afSaurel32fi
1980f652e6afSaurel32
198120ff075bSMichael Walle##########################################
198220ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
198320ff075bSMichael Walleif test "$opengl" != "no" ; then
198420ff075bSMichael Walle  opengl_libs="-lGL"
198520ff075bSMichael Walle  cat > $TMPC << EOF
198620ff075bSMichael Walle#include <X11/Xlib.h>
198720ff075bSMichael Walle#include <GL/gl.h>
198820ff075bSMichael Walle#include <GL/glx.h>
198920ff075bSMichael Walleint main(void) { GL_VERSION; return 0; }
199020ff075bSMichael WalleEOF
199120ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
199220ff075bSMichael Walle    opengl=yes
199320ff075bSMichael Walle  else
199420ff075bSMichael Walle    if test "$opengl" = "yes" ; then
199520ff075bSMichael Walle      feature_not_found "opengl"
199620ff075bSMichael Walle    fi
1997de3a354aSMichael Walle    opengl_libs=
199820ff075bSMichael Walle    opengl=no
199920ff075bSMichael Walle  fi
200020ff075bSMichael Wallefi
200120ff075bSMichael Walle
20023b3f24adSaurel32#
20033b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
20043b3f24adSaurel32# emulator.  This is done because older glibc versions don't
20053b3f24adSaurel32# have syscall stubs for these implemented.
20063b3f24adSaurel32#
20073b3f24adSaurel32atfile=no
20083b3f24adSaurel32cat > $TMPC << EOF
20093b3f24adSaurel32#define _ATFILE_SOURCE
20103b3f24adSaurel32#include <sys/types.h>
20113b3f24adSaurel32#include <fcntl.h>
20123b3f24adSaurel32#include <unistd.h>
20133b3f24adSaurel32
20143b3f24adSaurel32int
20153b3f24adSaurel32main(void)
20163b3f24adSaurel32{
20173b3f24adSaurel32	/* try to unlink nonexisting file */
20183b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
20193b3f24adSaurel32}
20203b3f24adSaurel32EOF
202152166aa0SJuan Quintelaif compile_prog "" "" ; then
20223b3f24adSaurel32  atfile=yes
20233b3f24adSaurel32fi
20243b3f24adSaurel32
202539386ac7Saurel32# Check for inotify functions when we are building linux-user
20263b3f24adSaurel32# emulator.  This is done because older glibc versions don't
20273b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
20283b3f24adSaurel32# don't provide them even if kernel supports them.
20293b3f24adSaurel32#
20303b3f24adSaurel32inotify=no
20313b3f24adSaurel32cat > $TMPC << EOF
20323b3f24adSaurel32#include <sys/inotify.h>
20333b3f24adSaurel32
20343b3f24adSaurel32int
20353b3f24adSaurel32main(void)
20363b3f24adSaurel32{
20373b3f24adSaurel32	/* try to start inotify */
20388690e420Saurel32	return inotify_init();
20393b3f24adSaurel32}
20403b3f24adSaurel32EOF
204152166aa0SJuan Quintelaif compile_prog "" "" ; then
20423b3f24adSaurel32  inotify=yes
20433b3f24adSaurel32fi
20443b3f24adSaurel32
2045c05c7a73SRiku Voipioinotify1=no
2046c05c7a73SRiku Voipiocat > $TMPC << EOF
2047c05c7a73SRiku Voipio#include <sys/inotify.h>
2048c05c7a73SRiku Voipio
2049c05c7a73SRiku Voipioint
2050c05c7a73SRiku Voipiomain(void)
2051c05c7a73SRiku Voipio{
2052c05c7a73SRiku Voipio    /* try to start inotify */
2053c05c7a73SRiku Voipio    return inotify_init1(0);
2054c05c7a73SRiku Voipio}
2055c05c7a73SRiku VoipioEOF
2056c05c7a73SRiku Voipioif compile_prog "" "" ; then
2057c05c7a73SRiku Voipio  inotify1=yes
2058c05c7a73SRiku Voipiofi
2059c05c7a73SRiku Voipio
2060ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2061ebc996f3SRiku Voipioutimens=no
2062ebc996f3SRiku Voipiocat > $TMPC << EOF
2063ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2064ebc996f3SRiku Voipio#include <stddef.h>
2065ebc996f3SRiku Voipio#include <fcntl.h>
2066ebc996f3SRiku Voipio
2067ebc996f3SRiku Voipioint main(void)
2068ebc996f3SRiku Voipio{
2069ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2070ebc996f3SRiku Voipio    futimens(0, NULL);
2071ebc996f3SRiku Voipio    return 0;
2072ebc996f3SRiku Voipio}
2073ebc996f3SRiku VoipioEOF
207452166aa0SJuan Quintelaif compile_prog "" "" ; then
2075ebc996f3SRiku Voipio  utimens=yes
2076ebc996f3SRiku Voipiofi
2077ebc996f3SRiku Voipio
2078099d6b0fSRiku Voipio# check if pipe2 is there
2079099d6b0fSRiku Voipiopipe2=no
2080099d6b0fSRiku Voipiocat > $TMPC << EOF
2081099d6b0fSRiku Voipio#include <unistd.h>
2082099d6b0fSRiku Voipio#include <fcntl.h>
2083099d6b0fSRiku Voipio
2084099d6b0fSRiku Voipioint main(void)
2085099d6b0fSRiku Voipio{
2086099d6b0fSRiku Voipio    int pipefd[2];
2087099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2088099d6b0fSRiku Voipio    return 0;
2089099d6b0fSRiku Voipio}
2090099d6b0fSRiku VoipioEOF
209152166aa0SJuan Quintelaif compile_prog "" "" ; then
2092099d6b0fSRiku Voipio  pipe2=yes
2093099d6b0fSRiku Voipiofi
2094099d6b0fSRiku Voipio
209540ff6d7eSKevin Wolf# check if accept4 is there
209640ff6d7eSKevin Wolfaccept4=no
209740ff6d7eSKevin Wolfcat > $TMPC << EOF
209840ff6d7eSKevin Wolf#include <sys/socket.h>
209940ff6d7eSKevin Wolf#include <stddef.h>
210040ff6d7eSKevin Wolf
210140ff6d7eSKevin Wolfint main(void)
210240ff6d7eSKevin Wolf{
210340ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
210440ff6d7eSKevin Wolf    return 0;
210540ff6d7eSKevin Wolf}
210640ff6d7eSKevin WolfEOF
210740ff6d7eSKevin Wolfif compile_prog "" "" ; then
210840ff6d7eSKevin Wolf  accept4=yes
210940ff6d7eSKevin Wolffi
211040ff6d7eSKevin Wolf
21113ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
21123ce34dfbSvibisreenivasansplice=no
21133ce34dfbSvibisreenivasancat > $TMPC << EOF
21143ce34dfbSvibisreenivasan#include <unistd.h>
21153ce34dfbSvibisreenivasan#include <fcntl.h>
21163ce34dfbSvibisreenivasan#include <limits.h>
21173ce34dfbSvibisreenivasan
21183ce34dfbSvibisreenivasanint main(void)
21193ce34dfbSvibisreenivasan{
21203ce34dfbSvibisreenivasan    int len, fd;
21213ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
21223ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
21233ce34dfbSvibisreenivasan    return 0;
21243ce34dfbSvibisreenivasan}
21253ce34dfbSvibisreenivasanEOF
212652166aa0SJuan Quintelaif compile_prog "" "" ; then
21273ce34dfbSvibisreenivasan  splice=yes
21283ce34dfbSvibisreenivasanfi
21293ce34dfbSvibisreenivasan
2130dcc38d1cSMarcelo Tosatti##########################################
2131dcc38d1cSMarcelo Tosatti# signalfd probe
2132dcc38d1cSMarcelo Tosattisignalfd="no"
2133dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2134dcc38d1cSMarcelo Tosatti#define _GNU_SOURCE
2135dcc38d1cSMarcelo Tosatti#include <unistd.h>
2136dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2137dcc38d1cSMarcelo Tosatti#include <signal.h>
2138dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2139dcc38d1cSMarcelo TosattiEOF
2140dcc38d1cSMarcelo Tosatti
2141dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2142dcc38d1cSMarcelo Tosatti  signalfd=yes
2143de758970SJan Kiszkaelif test "$kvm" = "yes" -a "$io_thread" != "yes"; then
2144de758970SJan Kiszka  echo
2145de758970SJan Kiszka  echo "ERROR: Host kernel lacks signalfd() support,"
2146de758970SJan Kiszka  echo "but KVM depends on it when the IO thread is disabled."
2147de758970SJan Kiszka  echo
2148de758970SJan Kiszka  exit 1
2149dcc38d1cSMarcelo Tosattifi
2150dcc38d1cSMarcelo Tosatti
2151c2882b96SRiku Voipio# check if eventfd is supported
2152c2882b96SRiku Voipioeventfd=no
2153c2882b96SRiku Voipiocat > $TMPC << EOF
2154c2882b96SRiku Voipio#include <sys/eventfd.h>
2155c2882b96SRiku Voipio
2156c2882b96SRiku Voipioint main(void)
2157c2882b96SRiku Voipio{
2158c2882b96SRiku Voipio    int efd = eventfd(0, 0);
2159c2882b96SRiku Voipio    return 0;
2160c2882b96SRiku Voipio}
2161c2882b96SRiku VoipioEOF
2162c2882b96SRiku Voipioif compile_prog "" "" ; then
2163c2882b96SRiku Voipio  eventfd=yes
2164c2882b96SRiku Voipiofi
2165c2882b96SRiku Voipio
2166d0927938SUlrich Hecht# check for fallocate
2167d0927938SUlrich Hechtfallocate=no
2168d0927938SUlrich Hechtcat > $TMPC << EOF
2169d0927938SUlrich Hecht#include <fcntl.h>
2170d0927938SUlrich Hecht
2171d0927938SUlrich Hechtint main(void)
2172d0927938SUlrich Hecht{
2173d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2174d0927938SUlrich Hecht    return 0;
2175d0927938SUlrich Hecht}
2176d0927938SUlrich HechtEOF
2177be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
2178d0927938SUlrich Hecht  fallocate=yes
2179d0927938SUlrich Hechtfi
2180d0927938SUlrich Hecht
2181c727f47dSPeter Maydell# check for sync_file_range
2182c727f47dSPeter Maydellsync_file_range=no
2183c727f47dSPeter Maydellcat > $TMPC << EOF
2184c727f47dSPeter Maydell#include <fcntl.h>
2185c727f47dSPeter Maydell
2186c727f47dSPeter Maydellint main(void)
2187c727f47dSPeter Maydell{
2188c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2189c727f47dSPeter Maydell    return 0;
2190c727f47dSPeter Maydell}
2191c727f47dSPeter MaydellEOF
2192c727f47dSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2193c727f47dSPeter Maydell  sync_file_range=yes
2194c727f47dSPeter Maydellfi
2195c727f47dSPeter Maydell
2196dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2197dace20dcSPeter Maydellfiemap=no
2198dace20dcSPeter Maydellcat > $TMPC << EOF
2199dace20dcSPeter Maydell#include <sys/ioctl.h>
2200dace20dcSPeter Maydell#include <linux/fs.h>
2201dace20dcSPeter Maydell#include <linux/fiemap.h>
2202dace20dcSPeter Maydell
2203dace20dcSPeter Maydellint main(void)
2204dace20dcSPeter Maydell{
2205dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2206dace20dcSPeter Maydell    return 0;
2207dace20dcSPeter Maydell}
2208dace20dcSPeter MaydellEOF
2209dace20dcSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2210dace20dcSPeter Maydell  fiemap=yes
2211dace20dcSPeter Maydellfi
2212dace20dcSPeter Maydell
2213d0927938SUlrich Hecht# check for dup3
2214d0927938SUlrich Hechtdup3=no
2215d0927938SUlrich Hechtcat > $TMPC << EOF
2216d0927938SUlrich Hecht#include <unistd.h>
2217d0927938SUlrich Hecht
2218d0927938SUlrich Hechtint main(void)
2219d0927938SUlrich Hecht{
2220d0927938SUlrich Hecht    dup3(0, 0, 0);
2221d0927938SUlrich Hecht    return 0;
2222d0927938SUlrich Hecht}
2223d0927938SUlrich HechtEOF
222478f5d726SJan Kiszkaif compile_prog "" "" ; then
2225d0927938SUlrich Hecht  dup3=yes
2226d0927938SUlrich Hechtfi
2227d0927938SUlrich Hecht
22283b6edd16SPeter Maydell# check for epoll support
22293b6edd16SPeter Maydellepoll=no
22303b6edd16SPeter Maydellcat > $TMPC << EOF
22313b6edd16SPeter Maydell#include <sys/epoll.h>
22323b6edd16SPeter Maydell
22333b6edd16SPeter Maydellint main(void)
22343b6edd16SPeter Maydell{
22353b6edd16SPeter Maydell    epoll_create(0);
22363b6edd16SPeter Maydell    return 0;
22373b6edd16SPeter Maydell}
22383b6edd16SPeter MaydellEOF
22393b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
22403b6edd16SPeter Maydell  epoll=yes
22413b6edd16SPeter Maydellfi
22423b6edd16SPeter Maydell
22433b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
22443b6edd16SPeter Maydell# so we must check separately for their presence
22453b6edd16SPeter Maydellepoll_create1=no
22463b6edd16SPeter Maydellcat > $TMPC << EOF
22473b6edd16SPeter Maydell#include <sys/epoll.h>
22483b6edd16SPeter Maydell
22493b6edd16SPeter Maydellint main(void)
22503b6edd16SPeter Maydell{
225119e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
225219e83f6bSPeter Maydell     * a function being called. This is necessary so that on
225319e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
225419e83f6bSPeter Maydell     * the library but not declared in the header file we will
225519e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
225619e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
225719e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
225819e83f6bSPeter Maydell     */
225919e83f6bSPeter Maydell    epoll_create1;
22603b6edd16SPeter Maydell    return 0;
22613b6edd16SPeter Maydell}
22623b6edd16SPeter MaydellEOF
22633b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
22643b6edd16SPeter Maydell  epoll_create1=yes
22653b6edd16SPeter Maydellfi
22663b6edd16SPeter Maydell
22673b6edd16SPeter Maydellepoll_pwait=no
22683b6edd16SPeter Maydellcat > $TMPC << EOF
22693b6edd16SPeter Maydell#include <sys/epoll.h>
22703b6edd16SPeter Maydell
22713b6edd16SPeter Maydellint main(void)
22723b6edd16SPeter Maydell{
22733b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
22743b6edd16SPeter Maydell    return 0;
22753b6edd16SPeter Maydell}
22763b6edd16SPeter MaydellEOF
22773b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
22783b6edd16SPeter Maydell  epoll_pwait=yes
22793b6edd16SPeter Maydellfi
22803b6edd16SPeter Maydell
2281cc8ae6deSpbrook# Check if tools are available to build documentation.
2282a25dba17SJuan Quintelaif test "$docs" != "no" ; then
228301668d98SStefan Weil  if has makeinfo && has pod2man; then
2284a25dba17SJuan Quintela    docs=yes
228583a3ab8bSJuan Quintela  else
2286a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2287a25dba17SJuan Quintela      feature_not_found "docs"
228883a3ab8bSJuan Quintela    fi
2289a25dba17SJuan Quintela    docs=no
229083a3ab8bSJuan Quintela  fi
2291cc8ae6deSpbrookfi
2292cc8ae6deSpbrook
2293f514f41cSStefan Weil# Search for bswap_32 function
22946ae9a1f4SJuan Quintelabyteswap_h=no
22956ae9a1f4SJuan Quintelacat > $TMPC << EOF
22966ae9a1f4SJuan Quintela#include <byteswap.h>
22976ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
22986ae9a1f4SJuan QuintelaEOF
229952166aa0SJuan Quintelaif compile_prog "" "" ; then
23006ae9a1f4SJuan Quintela  byteswap_h=yes
23016ae9a1f4SJuan Quintelafi
23026ae9a1f4SJuan Quintela
2303f514f41cSStefan Weil# Search for bswap_32 function
23046ae9a1f4SJuan Quintelabswap_h=no
23056ae9a1f4SJuan Quintelacat > $TMPC << EOF
23066ae9a1f4SJuan Quintela#include <sys/endian.h>
23076ae9a1f4SJuan Quintela#include <sys/types.h>
23086ae9a1f4SJuan Quintela#include <machine/bswap.h>
23096ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
23106ae9a1f4SJuan QuintelaEOF
231152166aa0SJuan Quintelaif compile_prog "" "" ; then
23126ae9a1f4SJuan Quintela  bswap_h=yes
23136ae9a1f4SJuan Quintelafi
23146ae9a1f4SJuan Quintela
2315da93a1fdSaliguori##########################################
2316da93a1fdSaliguori# Do we need librt
2317da93a1fdSaliguoricat > $TMPC <<EOF
2318da93a1fdSaliguori#include <signal.h>
2319da93a1fdSaliguori#include <time.h>
2320da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
2321da93a1fdSaliguoriEOF
2322da93a1fdSaliguori
232352166aa0SJuan Quintelaif compile_prog "" "" ; then
232407ffa4bdSJuan Quintela  :
232552166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
232607ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2327da93a1fdSaliguorifi
2328da93a1fdSaliguori
232931ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2330179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
23316362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
23326362a53fSJuan Quintelafi
23336362a53fSJuan Quintela
2334de5071c5SBlue Swirl##########################################
2335de5071c5SBlue Swirl# check if the compiler defines offsetof
2336de5071c5SBlue Swirl
2337de5071c5SBlue Swirlneed_offsetof=yes
2338de5071c5SBlue Swirlcat > $TMPC << EOF
2339de5071c5SBlue Swirl#include <stddef.h>
2340de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
2341de5071c5SBlue SwirlEOF
2342de5071c5SBlue Swirlif compile_prog "" "" ; then
2343de5071c5SBlue Swirl    need_offsetof=no
2344de5071c5SBlue Swirlfi
2345de5071c5SBlue Swirl
23465f6b9e8fSBlue Swirl##########################################
2347747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
2348747bbdf7SBlue Swirl#
2349747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
2350747bbdf7SBlue Swirl# about attribute warn_unused_result
2351747bbdf7SBlue Swirl
2352747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
2353747bbdf7SBlue Swirlcat > $TMPC << EOF
2354747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2355747bbdf7SBlue Swirl#error gcc 3.3 or older
2356747bbdf7SBlue Swirl#endif
2357747bbdf7SBlue Swirlint main(void) { return 0;}
2358747bbdf7SBlue SwirlEOF
2359747bbdf7SBlue Swirlif compile_prog "" ""; then
2360747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
2361747bbdf7SBlue Swirlfi
2362747bbdf7SBlue Swirl
2363cd4ec0b4SGerd Hoffmann# spice probe
2364cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2365cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2366cd4ec0b4SGerd Hoffmann#include <spice.h>
2367cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2368cd4ec0b4SGerd HoffmannEOF
2369710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2370710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2371012b80d3SGerd Hoffmann  if $pkg_config --atleast-version=0.6.0 spice-server >/dev/null 2>&1 && \
2372cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2373cd4ec0b4SGerd Hoffmann    spice="yes"
2374cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2375cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2376cd4ec0b4SGerd Hoffmann  else
2377cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2378cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2379cd4ec0b4SGerd Hoffmann    fi
2380cd4ec0b4SGerd Hoffmann    spice="no"
2381cd4ec0b4SGerd Hoffmann  fi
2382cd4ec0b4SGerd Hoffmannfi
2383cd4ec0b4SGerd Hoffmann
2384111a38b0SRobert Relyea# check for libcacard for smartcard support
2385111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2386111a38b0SRobert Relyea    smartcard="yes"
2387111a38b0SRobert Relyea    smartcard_cflags=""
2388111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2389111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
2390111a38b0SRobert Relyea        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then
2391111a38b0SRobert Relyea            smartcard_nss="yes"
2392111a38b0SRobert Relyea            smartcard_cflags="-I\$(SRC_PATH)/libcacard"
2393111a38b0SRobert Relyea            libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
2394111a38b0SRobert Relyea            libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
2395111a38b0SRobert Relyea            QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
2396111a38b0SRobert Relyea            LIBS="$libcacard_libs $LIBS"
2397111a38b0SRobert Relyea        else
2398111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2399111a38b0SRobert Relyea                feature_not_found "nss"
2400111a38b0SRobert Relyea            fi
2401111a38b0SRobert Relyea            smartcard_nss="no"
2402111a38b0SRobert Relyea        fi
2403111a38b0SRobert Relyea    fi
2404111a38b0SRobert Relyeafi
2405111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2406111a38b0SRobert Relyea    smartcard_nss="no"
2407111a38b0SRobert Relyeafi
2408111a38b0SRobert Relyea
240969354a83SHans de Goede# check for usbredirparser for usb network redirection support
241069354a83SHans de Goedeif test "$usb_redir" != "no" ; then
241169354a83SHans de Goede    if $pkg_config libusbredirparser >/dev/null 2>&1 ; then
241269354a83SHans de Goede        usb_redir="yes"
241369354a83SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
241469354a83SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
241569354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
241669354a83SHans de Goede        LIBS="$LIBS $usb_redir_libs"
241769354a83SHans de Goede    else
241869354a83SHans de Goede        if test "$usb_redir" = "yes"; then
241969354a83SHans de Goede            feature_not_found "usb-redir"
242069354a83SHans de Goede        fi
242169354a83SHans de Goede        usb_redir="no"
242269354a83SHans de Goede    fi
242369354a83SHans de Goedefi
242469354a83SHans de Goede
2425cd4ec0b4SGerd Hoffmann##########################################
2426cd4ec0b4SGerd Hoffmann
2427747bbdf7SBlue Swirl##########################################
24285f6b9e8fSBlue Swirl# check if we have fdatasync
24295f6b9e8fSBlue Swirl
24305f6b9e8fSBlue Swirlfdatasync=no
24315f6b9e8fSBlue Swirlcat > $TMPC << EOF
24325f6b9e8fSBlue Swirl#include <unistd.h>
2433d1722a27SAlexandre Raymondint main(void) {
2434d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2435d1722a27SAlexandre Raymondreturn fdatasync(0);
2436d1722a27SAlexandre Raymond#else
2437d1722a27SAlexandre Raymond#abort Not supported
2438d1722a27SAlexandre Raymond#endif
2439d1722a27SAlexandre Raymond}
24405f6b9e8fSBlue SwirlEOF
24415f6b9e8fSBlue Swirlif compile_prog "" "" ; then
24425f6b9e8fSBlue Swirl    fdatasync=yes
24435f6b9e8fSBlue Swirlfi
24445f6b9e8fSBlue Swirl
244594a420b1SStefan Hajnoczi##########################################
2446e78815a5SAndreas Färber# check if we have madvise
2447e78815a5SAndreas Färber
2448e78815a5SAndreas Färbermadvise=no
2449e78815a5SAndreas Färbercat > $TMPC << EOF
2450e78815a5SAndreas Färber#include <sys/types.h>
2451e78815a5SAndreas Färber#include <sys/mman.h>
2452832ce9c2SScott Wood#include <stddef.h>
2453e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2454e78815a5SAndreas FärberEOF
2455e78815a5SAndreas Färberif compile_prog "" "" ; then
2456e78815a5SAndreas Färber    madvise=yes
2457e78815a5SAndreas Färberfi
2458e78815a5SAndreas Färber
2459e78815a5SAndreas Färber##########################################
2460e78815a5SAndreas Färber# check if we have posix_madvise
2461e78815a5SAndreas Färber
2462e78815a5SAndreas Färberposix_madvise=no
2463e78815a5SAndreas Färbercat > $TMPC << EOF
2464e78815a5SAndreas Färber#include <sys/mman.h>
2465832ce9c2SScott Wood#include <stddef.h>
2466e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2467e78815a5SAndreas FärberEOF
2468e78815a5SAndreas Färberif compile_prog "" "" ; then
2469e78815a5SAndreas Färber    posix_madvise=yes
2470e78815a5SAndreas Färberfi
2471e78815a5SAndreas Färber
2472e78815a5SAndreas Färber##########################################
247394a420b1SStefan Hajnoczi# check if trace backend exists
247494a420b1SStefan Hajnoczi
24754c3b5a48SBlue Swirlsh "$source_path/scripts/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
247694a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
247794a420b1SStefan Hajnoczi  echo
247894a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
247994a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
248094a420b1SStefan Hajnoczi  echo
248194a420b1SStefan Hajnoczi  exit 1
248294a420b1SStefan Hajnoczifi
248394a420b1SStefan Hajnoczi
24847e24e92aSStefan Hajnoczi##########################################
24857e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
24867e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
24877e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
24887e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
24897e24e92aSStefan Hajnoczi#include <ust/marker.h>
24907e24e92aSStefan Hajnocziint main(void) { return 0; }
24917e24e92aSStefan HajnocziEOF
24927e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
24937e24e92aSStefan Hajnoczi    LIBS="-lust $LIBS"
24947e24e92aSStefan Hajnoczi  else
24957e24e92aSStefan Hajnoczi    echo
24967e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
24977e24e92aSStefan Hajnoczi    echo
24987e24e92aSStefan Hajnoczi    exit 1
24997e24e92aSStefan Hajnoczi  fi
25007e24e92aSStefan Hajnoczifi
2501b3d08c02SDaniel P. Berrange
2502b3d08c02SDaniel P. Berrange##########################################
2503b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2504b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2505b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2506b3d08c02SDaniel P. Berrange    echo
2507b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2508b3d08c02SDaniel P. Berrange    echo
2509b3d08c02SDaniel P. Berrange    exit 1
2510b3d08c02SDaniel P. Berrange  fi
2511c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2512c276b17dSDaniel P. Berrange  if has 'stap' ; then
2513c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2514c276b17dSDaniel P. Berrange  fi
2515b3d08c02SDaniel P. Berrangefi
2516b3d08c02SDaniel P. Berrange
25177e24e92aSStefan Hajnoczi##########################################
2518e86ecd4bSJuan Quintela# End of CC checks
2519e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2520e86ecd4bSJuan Quintela
2521e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
25221156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2523e86ecd4bSJuan Quintelafi
2524a316e378SJuan Quintela
2525e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2526e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2527e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
252820ff6c80SAnthony Liguori
252920ff6c80SAnthony Liguoriif test -z "$werror" ; then
2530e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2531e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2532e86ecd4bSJuan Quintela        werror="yes"
2533e86ecd4bSJuan Quintela    else
2534e86ecd4bSJuan Quintela        werror="no"
2535e86ecd4bSJuan Quintela    fi
2536e86ecd4bSJuan Quintelafi
2537e86ecd4bSJuan Quintela
253820ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
253920ff6c80SAnthony Liguori# enable/disable
254020ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
254120ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
254220ff6c80SAnthony Liguori	zero_malloc="no"
254320ff6c80SAnthony Liguori    else
254420ff6c80SAnthony Liguori	zero_malloc="yes"
254520ff6c80SAnthony Liguori    fi
254620ff6c80SAnthony Liguorifi
254720ff6c80SAnthony Liguori
2548e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2549a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2550e86ecd4bSJuan Quintelafi
2551e86ecd4bSJuan Quintela
2552e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2553e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
25541156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2555e86ecd4bSJuan Quintela    fi
2556e86ecd4bSJuan Quintelafi
2557e86ecd4bSJuan Quintela
2558952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
2559952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
2560952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
2561952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2562952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
2563952afb71SBlue Swirl        fi
2564952afb71SBlue Swirl    done
2565952afb71SBlue Swirlfi
2566952afb71SBlue Swirl
2567190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
25685a67135aSbellard
2569ca35f780SPaolo Bonzinitools=
2570ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2571ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2572ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2573ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
257448ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
2575ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2576ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2577ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2578ca35f780SPaolo Bonzini    fi
2579ca35f780SPaolo Bonzini  fi
2580ca35f780SPaolo Bonzinifi
2581ca35f780SPaolo Bonzini
2582ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2583ca35f780SPaolo Bonziniroms=
2584ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2585ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2586ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2587ca35f780SPaolo Bonzini  roms="optionrom"
2588ca35f780SPaolo Bonzinifi
2589d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
259039ac8455SDavid Gibson  roms="$roms spapr-rtas"
259139ac8455SDavid Gibsonfi
2592ca35f780SPaolo Bonzini
25937d13299dSbellardecho "Install prefix    $prefix"
2594f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2595f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
25963aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
25971c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
259811d9f695Sbellardif test "$mingw32" = "no" ; then
2599f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
260043ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
260111d9f695Sbellardfi
26025a67135aSbellardecho "Source path       $source_path"
26037d13299dSbellardecho "C compiler        $cc"
260483469015Sbellardecho "Host C compiler   $host_cc"
26050c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2606a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
26070c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
26087d13299dSbellardecho "make              $make"
26096a882643Spbrookecho "install           $install"
2610c886edfbSBlue Swirlecho "python            $python"
2611a98fd896Sbellardecho "host CPU          $cpu"
2612de83cd02Sbellardecho "host big endian   $bigendian"
261397a847bcSbellardecho "target list       $target_list"
2614ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2615b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
26167d13299dSbellardecho "gprof enabled     $gprof"
261703b4fe7dSaliguoriecho "sparse enabled    $sparse"
26181625af87Saliguoriecho "strip binaries    $strip_opt"
261905c2a3e7Sbellardecho "profiler          $profiler"
262043ce4dfeSbellardecho "static build      $static"
262185aa5189Sbellardecho "-Werror enabled   $werror"
26225b0753e0Sbellardif test "$darwin" = "yes" ; then
26235b0753e0Sbellard    echo "Cocoa support     $cocoa"
26245b0753e0Sbellardfi
262597a847bcSbellardecho "SDL support       $sdl"
26264d3b6f6eSbalrogecho "curses support    $curses"
2627769ce76dSAlexander Grafecho "curl support      $curl"
26285495ed11SLuiz Capitulinoecho "check support     $check_utests"
262967b915a5Sbellardecho "mingw32 support   $mingw32"
26300c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
26310c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2632eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
26338ff9cbf7Smalcecho "Mixer emulation   $mixemu"
2634821601eaSJes Sorensenecho "VNC support       $vnc"
2635821601eaSJes Sorensenif test "$vnc" = "yes" ; then
26368d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
26372f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
26382f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
2639efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
2640bd023f95SCorentin Chary    echo "VNC thread        $vnc_thread"
2641821601eaSJes Sorensenfi
26423142255cSblueswir1if test -n "$sparc_cpu"; then
26433142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
26443142255cSblueswir1fi
2645e37630caSaliguoriecho "xen support       $xen"
26462e4d9fb1Saurel32echo "brlapi support    $brlapi"
2647a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2648a25dba17SJuan Quintelaecho "Documentation     $docs"
2649c5937220Spbrook[ ! -z "$uname_release" ] && \
2650c5937220Spbrookecho "uname -r          $uname_release"
2651bd0c5661Spbrookecho "NPTL support      $nptl"
2652379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
265334005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
26548a16d273Sthsecho "vde support       $vde"
2655e5d355d1Saliguoriecho "IO thread         $io_thread"
26565c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2657758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
265877755340Sthsecho "Install blobs     $blobs"
2659b31a0277SJuan Quintelaecho "KVM support       $kvm"
2660f652e6afSaurel32echo "fdt support       $fdt"
2661ceb42de8Saliguoriecho "preadv support    $preadv"
26625f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2663e78815a5SAndreas Färberecho "madvise           $madvise"
2664e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
2665ee682d27SStefan Weilecho "uuid support      $uuid"
2666d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
266794a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
26689410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
2669cd4ec0b4SGerd Hoffmannecho "spice support     $spice"
2670f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
2671dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
2672111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
267369354a83SHans de Goedeecho "usb net redir     $usb_redir"
267420ff075bSMichael Walleecho "OpenGL support    $opengl"
267567b915a5Sbellard
267697a847bcSbellardif test $sdl_too_old = "yes"; then
267724b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2678e8cd23deSbellardfi
267997a847bcSbellard
268098ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
26814bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
268297a847bcSbellard
268398ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
268498ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
268598ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
268698ec69acSJuan Quintelaecho >> $config_host_mak
268798ec69acSJuan Quintela
2688e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
268999d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
269099d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
26913aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
269299d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
269399d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
269499d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
269599d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
26961dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2697804edf29SJuan Quintela
26982408a527Saurel32case "$cpu" in
2699d2fbca94SGuan Xuetao  i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64|unicore32)
2700e0da9dd3SJuan Quintela    ARCH=$cpu
27012408a527Saurel32  ;;
2702a302c32dSLaurent Desnogues  armv4b|armv4l)
270316dbd14fSJuan Quintela    ARCH=arm
27042408a527Saurel32  ;;
27052408a527Saurel32esac
270698ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2707f8393946Saurel32if test "$debug_tcg" = "yes" ; then
27082358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2709f8393946Saurel32fi
2710b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2711b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2712b4475aa2SLuiz Capitulinofi
2713f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
27142358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2715f3d08ee6SPaul Brookfi
27161625af87Saliguoriif test "$strip_opt" = "yes" ; then
271752ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
27181625af87Saliguorifi
27197d13299dSbellardif test "$bigendian" = "yes" ; then
2720e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
272197a847bcSbellardfi
27222358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
272367b915a5Sbellardif test "$mingw32" = "yes" ; then
272498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
27259fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
27269fe6de94SBlue Swirl  version_major=${rc_version%%.*}
27279fe6de94SBlue Swirl  rc_version=${rc_version#*.}
27289fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
27299fe6de94SBlue Swirl  rc_version=${rc_version#*.}
27309fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
27319fe6de94SBlue Swirl  version_micro=0
27329fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
27339fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2734210fa556Spbrookelse
273535f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2736210fa556Spbrookfi
2737128ab2ffSblueswir1
2738dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2739dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2740dffcb71cSMark McLoughlinfi
2741dffcb71cSMark McLoughlin
274283fb7adfSbellardif test "$darwin" = "yes" ; then
274398ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
274483fb7adfSbellardfi
2745b29fe3edSmalc
2746b29fe3edSmalcif test "$aix" = "yes" ; then
274798ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2748b29fe3edSmalcfi
2749b29fe3edSmalc
2750ec530c81Sbellardif test "$solaris" = "yes" ; then
275198ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
27522358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
27530475a5caSths  if test "$needs_libsunmath" = "yes" ; then
275475b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
27550475a5caSths  fi
2756ec530c81Sbellardfi
2757179cf400SAndreas Färberif test "$haiku" = "yes" ; then
2758179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
2759179cf400SAndreas Färberfi
276097a847bcSbellardif test "$static" = "yes" ; then
276198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
276297a847bcSbellardfi
276305c2a3e7Sbellardif test $profiler = "yes" ; then
27642358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
276505c2a3e7Sbellardfi
2766c20709aaSbellardif test "$slirp" = "yes" ; then
276798ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2768f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
2769c20709aaSbellardfi
27708a16d273Sthsif test "$vde" = "yes" ; then
277198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
27728a16d273Sthsfi
27730c58ac1cSmalcfor card in $audio_card_list; do
2774f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
277598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
27760c58ac1cSmalcdone
27772358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
27780c58ac1cSmalcfor drv in $audio_drv_list; do
2779f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
278098ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2781923e4521Smalc    if test "$drv" = "fmod"; then
27827aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2783fb065187Sbellard    fi
27840c58ac1cSmalcdone
278567f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
278667f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
278767f86e8eSJuan Quintelafi
2788d5631638Smalcif test "$audio_win_int" = "yes" ; then
2789d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2790d5631638Smalcfi
2791eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
27928ff9cbf7Smalcif test "$mixemu" = "yes" ; then
279398ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
27948ff9cbf7Smalcfi
2795821601eaSJes Sorensenif test "$vnc" = "yes" ; then
2796821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
2797821601eaSJes Sorensenfi
27988d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
279998ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2800525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
28018d5d2d4cSthsfi
28022f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
280398ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
280460ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
28052f9606b3Saliguorifi
2806821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
28072f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
28082f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
28092f6f5c7aSCorentin Charyfi
2810821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
2811efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2812efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2813efe556adSCorentin Charyfi
2814821601eaSJes Sorensenif test "$vnc_thread" = "yes" ; then
2815bd023f95SCorentin Chary  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2816bd023f95SCorentin Charyfi
281776655d6dSaliguoriif test "$fnmatch" = "yes" ; then
28182358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
281976655d6dSaliguorifi
2820ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2821ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2822ee682d27SStefan Weilfi
2823dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
2824dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
2825dce512deSChristoph Hellwigfi
2826b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
282798ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
28282358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
282998ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
283098ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2831a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
283298ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2833cc8ae6deSpbrookfi
28341ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
283598ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
28368ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
283749ecc3faSbellardfi
283849ecc3faSbellardif test "$cocoa" = "yes" ; then
283998ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
284049ecc3faSbellardfi
28414d3b6f6eSbalrogif test "$curses" = "yes" ; then
284298ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2843ab4e5602SJan Kiszkafi
28443b3f24adSaurel32if test "$atfile" = "yes" ; then
28452358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
28463b3f24adSaurel32fi
2847ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
28482358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2849ebc996f3SRiku Voipiofi
2850099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
28512358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2852099d6b0fSRiku Voipiofi
285340ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
285440ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
285540ff6d7eSKevin Wolffi
28563ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
28572358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
28583ce34dfbSvibisreenivasanfi
2859c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2860c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2861c2882b96SRiku Voipiofi
2862d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2863d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2864d0927938SUlrich Hechtfi
2865c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
2866c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2867c727f47dSPeter Maydellfi
2868dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
2869dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
2870dace20dcSPeter Maydellfi
2871d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2872d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2873d0927938SUlrich Hechtfi
28743b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
28753b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
28763b6edd16SPeter Maydellfi
28773b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
28783b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
28793b6edd16SPeter Maydellfi
28803b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
28813b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
28823b6edd16SPeter Maydellfi
28833b3f24adSaurel32if test "$inotify" = "yes" ; then
28842358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
28853b3f24adSaurel32fi
2886c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2887c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2888c05c7a73SRiku Voipiofi
28896ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
28906ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
28916ae9a1f4SJuan Quintelafi
28926ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
28936ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
28946ae9a1f4SJuan Quintelafi
2895769ce76dSAlexander Grafif test "$curl" = "yes" ; then
289698ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2897b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2898769ce76dSAlexander Graffi
28992e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
290098ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
29012e4d9fb1Saurel32fi
2902fb599c9aSbalrogif test "$bluez" = "yes" ; then
290398ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2904ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2905fb599c9aSbalrogfi
2906e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
2907e37630caSaliguoriif test "$xen" = "yes" ; then
29086dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
2909d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
2910e37630caSaliguorifi
2911e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
291298ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2913e5d355d1Saliguorifi
29145c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
29155c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
29165c6c3a6cSChristoph Hellwigfi
2917758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
2918758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
2919758e8e38SVenkateswararao Jujjuri (JV)fi
2920758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
2921758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
2922758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2923758e8e38SVenkateswararao Jujjuri (JV)  fi
2924758e8e38SVenkateswararao Jujjuri (JV)fi
292577755340Sthsif test "$blobs" = "yes" ; then
292698ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
292777755340Sthsfi
2928bf9298b9Saliguoriif test "$iovec" = "yes" ; then
29292358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2930bf9298b9Saliguorifi
2931ceb42de8Saliguoriif test "$preadv" = "yes" ; then
29322358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2933ceb42de8Saliguorifi
2934f652e6afSaurel32if test "$fdt" = "yes" ; then
29353f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2936f652e6afSaurel32fi
2937dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
2938dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2939dcc38d1cSMarcelo Tosattifi
2940de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2941de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2942de5071c5SBlue Swirlfi
2943747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2944747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2945747bbdf7SBlue Swirlfi
29465f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
29475f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
29485f6b9e8fSBlue Swirlfi
2949e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
2950e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
2951e78815a5SAndreas Färberfi
2952e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
2953e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2954e78815a5SAndreas Färberfi
295597a847bcSbellard
2956cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
2957cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
2958cd4ec0b4SGerd Hoffmannfi
2959cd4ec0b4SGerd Hoffmann
296036707144SAlon Levyif test "$smartcard" = "yes" ; then
296136707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
296236707144SAlon Levyfi
296336707144SAlon Levy
2964111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
2965111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
2966111a38b0SRobert Relyeafi
2967111a38b0SRobert Relyea
296869354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
296969354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
297069354a83SHans de Goedefi
297169354a83SHans de Goede
297220ff075bSMichael Walleif test "$opengl" = "yes" ; then
297320ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
297420ff075bSMichael Wallefi
297520ff075bSMichael Walle
297683fb7adfSbellard# XXX: suppress that
29777d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
29782358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
29797d3505c5Sbellardfi
29807d3505c5Sbellard
29812358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2982c5937220Spbrook
298320ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
298420ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
298520ff6c80SAnthony Liguorifi
2986f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
2987f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
2988f27aaf4bSChristian Brunnerfi
298920ff6c80SAnthony Liguori
299068063649Sblueswir1# USB host support
299168063649Sblueswir1case "$usb" in
299268063649Sblueswir1linux)
299398ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
299468063649Sblueswir1;;
299568063649Sblueswir1bsd)
299698ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
299768063649Sblueswir1;;
299868063649Sblueswir1*)
299998ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
300068063649Sblueswir1;;
300168063649Sblueswir1esac
300268063649Sblueswir1
300394a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
300422890ab5SPrerna Saxenaif test "$trace_backend" = "simple"; then
300522890ab5SPrerna Saxena  echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
300622890ab5SPrerna Saxenafi
30079410b56cSPrerna Saxena# Set the appropriate trace file.
30089410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
3009953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
30109410b56cSPrerna Saxenafi
3011c276b17dSDaniel P. Berrangeif test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
3012c276b17dSDaniel P. Berrange  echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
3013c276b17dSDaniel P. Berrangefi
30149410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
30159410b56cSPrerna Saxena
301698ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
301798ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3018804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3019804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
3020804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
3021804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
3022804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
3023c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
3024804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
30252b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3026804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
3027804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3028804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3029804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
30309fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
303144dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3032e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3033a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3034f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3035e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3036e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3037e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3038e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3039e39f0062SPaolo Bonzinifi
3040c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
3041e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3042a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3043a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
304473da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
30453e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3046804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3047804edf29SJuan Quintela
30484bf6b55bSJuan Quintela# generate list of library paths for linker script
30494bf6b55bSJuan Quintela
30504bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
30514bf6b55bSJuan Quintela
30524bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
30534bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
30544bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
30554bf6b55bSJuan Quintela  else
30564bf6b55bSJuan Quintela    rm ${config_host_ld}~
30574bf6b55bSJuan Quintela  fi
30584bf6b55bSJuan Quintelafi
30594bf6b55bSJuan Quintela
30604d904533SBlue Swirlfor d in libdis libdis-user; do
30614d904533SBlue Swirl    mkdir -p $d
306211568d6dSPaolo Bonzini    symlink $source_path/Makefile.dis $d/Makefile
30634d904533SBlue Swirl    echo > $d/config.mak
30644d904533SBlue Swirldone
3065d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
3066d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
3067d44cff22SRichard Hendersonfi
30684d904533SBlue Swirl
306997a847bcSbellardfor target in $target_list; do
307097a847bcSbellardtarget_dir="$target"
307125be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3072600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
307397a847bcSbellardtarget_bigendian="no"
30741f3d3c8fSJuan Quintela
3075ea2d6a39SJuan Quintelacase "$target_arch2" in
3076613a22c9SMichael Walle  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
3077ea2d6a39SJuan Quintela  target_bigendian=yes
3078ea2d6a39SJuan Quintela  ;;
3079ea2d6a39SJuan Quintelaesac
308097a847bcSbellardtarget_softmmu="no"
3081997344f3Sbellardtarget_user_only="no"
3082831b7825Sthstarget_linux_user="no"
3083831b7825Sthstarget_darwin_user="no"
308484778508Sblueswir1target_bsd_user="no"
30859e407a85Spbrookcase "$target" in
3086600309b6SBlue Swirl  ${target_arch2}-softmmu)
30879e407a85Spbrook    target_softmmu="yes"
30889e407a85Spbrook    ;;
3089600309b6SBlue Swirl  ${target_arch2}-linux-user)
30909c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
30919c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
30929c7a4202SBlue Swirl      exit 1
30939c7a4202SBlue Swirl    fi
30949e407a85Spbrook    target_user_only="yes"
30959e407a85Spbrook    target_linux_user="yes"
30969e407a85Spbrook    ;;
3097600309b6SBlue Swirl  ${target_arch2}-darwin-user)
30989c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
30999c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
31009c7a4202SBlue Swirl      exit 1
31019c7a4202SBlue Swirl    fi
31029e407a85Spbrook    target_user_only="yes"
3103831b7825Sths    target_darwin_user="yes"
31049e407a85Spbrook    ;;
3105600309b6SBlue Swirl  ${target_arch2}-bsd-user)
31069cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
31079c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
31089c7a4202SBlue Swirl      exit 1
31099c7a4202SBlue Swirl    fi
311084778508Sblueswir1    target_user_only="yes"
311184778508Sblueswir1    target_bsd_user="yes"
311284778508Sblueswir1    ;;
31139e407a85Spbrook  *)
31149e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
31159e407a85Spbrook    exit 1
31169e407a85Spbrook    ;;
31179e407a85Spbrookesac
3118831b7825Sths
311997a847bcSbellardmkdir -p $target_dir
3120158142c2Sbellardmkdir -p $target_dir/fpu
312157fec1feSbellardmkdir -p $target_dir/tcg
312259f2a787SGerd Hoffmannmkdir -p $target_dir/ide
3123353ac78dSAneesh Kumar K.Vmkdir -p $target_dir/9pfs
312484778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
312569de927cSbellard  mkdir -p $target_dir/nwfpe
312669de927cSbellardfi
312711568d6dSPaolo Bonzinisymlink $source_path/Makefile.target $target_dir/Makefile
3128ec530c81Sbellard
312997a847bcSbellard
313025be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
313197a847bcSbellard
3132e5fe0c52Spbrookbflt="no"
3133bd0c5661Spbrooktarget_nptl="no"
3134600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
31357ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
313656aebc89Spbrookgdb_xml_files=""
3137c2e3dee6SLaurent Viviertarget_short_alignment=2
3138c2e3dee6SLaurent Viviertarget_int_alignment=4
3139c2e3dee6SLaurent Viviertarget_long_alignment=4
3140c2e3dee6SLaurent Viviertarget_llong_alignment=8
3141de3a354aSMichael Walletarget_libs_softmmu=
31427ba1e619Saliguori
3143938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
31446acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3145e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3146e73aae67SJuan Quintela
3147600309b6SBlue Swirlcase "$target_arch2" in
31482408a527Saurel32  i386)
314971deff27SAurelien Jarno    target_phys_bits=64
31502408a527Saurel32  ;;
31512408a527Saurel32  x86_64)
31526acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
31531ad2134fSPaul Brook    target_phys_bits=64
3154c2e3dee6SLaurent Vivier    target_long_alignment=8
31552408a527Saurel32  ;;
31562408a527Saurel32  alpha)
31571ad2134fSPaul Brook    target_phys_bits=64
3158c2e3dee6SLaurent Vivier    target_long_alignment=8
3159a4b388ffSRichard Henderson    target_nptl="yes"
31602408a527Saurel32  ;;
31612408a527Saurel32  arm|armeb)
3162b498c8a0SJuan Quintela    TARGET_ARCH=arm
3163e5fe0c52Spbrook    bflt="yes"
3164bd0c5661Spbrook    target_nptl="yes"
316556aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
31661ad2134fSPaul Brook    target_phys_bits=32
3167c2e3dee6SLaurent Vivier    target_llong_alignment=4
31682408a527Saurel32  ;;
31692408a527Saurel32  cris)
3170253bd7f8Sedgar_igl    target_nptl="yes"
31711ad2134fSPaul Brook    target_phys_bits=32
31722408a527Saurel32  ;;
3173613a22c9SMichael Walle  lm32)
3174613a22c9SMichael Walle    target_phys_bits=32
3175de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3176613a22c9SMichael Walle  ;;
31772408a527Saurel32  m68k)
31780938cda5Saurel32    bflt="yes"
317956aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
31801ad2134fSPaul Brook    target_phys_bits=32
3181c2e3dee6SLaurent Vivier    target_int_alignment=2
3182c2e3dee6SLaurent Vivier    target_long_alignment=2
3183c2e3dee6SLaurent Vivier    target_llong_alignment=2
31842408a527Saurel32  ;;
3185877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3186877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
318772b675caSEdgar E. Iglesias    bflt="yes"
318872b675caSEdgar E. Iglesias    target_nptl="yes"
318972b675caSEdgar E. Iglesias    target_phys_bits=32
3190de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
319172b675caSEdgar E. Iglesias  ;;
31922408a527Saurel32  mips|mipsel)
3193b498c8a0SJuan Quintela    TARGET_ARCH=mips
319425be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3195f04dc72fSPaul Brook    target_nptl="yes"
31961ad2134fSPaul Brook    target_phys_bits=64
31972408a527Saurel32  ;;
31982408a527Saurel32  mipsn32|mipsn32el)
3199b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
32006acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
320125be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
32021ad2134fSPaul Brook    target_phys_bits=64
32032408a527Saurel32  ;;
32042408a527Saurel32  mips64|mips64el)
3205b498c8a0SJuan Quintela    TARGET_ARCH=mips64
32066acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
320725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
32081ad2134fSPaul Brook    target_phys_bits=64
3209c2e3dee6SLaurent Vivier    target_long_alignment=8
32102408a527Saurel32  ;;
32112408a527Saurel32  ppc)
3212c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32131ad2134fSPaul Brook    target_phys_bits=32
3214d6630708SNathan Froyd    target_nptl="yes"
3215de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32162408a527Saurel32  ;;
32172408a527Saurel32  ppcemb)
32186acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3219e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3220c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32211ad2134fSPaul Brook    target_phys_bits=64
3222d6630708SNathan Froyd    target_nptl="yes"
3223de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32242408a527Saurel32  ;;
32252408a527Saurel32  ppc64)
32266acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3227e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3228c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32291ad2134fSPaul Brook    target_phys_bits=64
3230c2e3dee6SLaurent Vivier    target_long_alignment=8
3231de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32322408a527Saurel32  ;;
32332408a527Saurel32  ppc64abi32)
3234b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
32356acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3236e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
323725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3238c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32391ad2134fSPaul Brook    target_phys_bits=64
3240de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32412408a527Saurel32  ;;
32422408a527Saurel32  sh4|sh4eb)
3243b498c8a0SJuan Quintela    TARGET_ARCH=sh4
32444dbed897Spbrook    bflt="yes"
32450b6d3ae0Saurel32    target_nptl="yes"
32461ad2134fSPaul Brook    target_phys_bits=32
32472408a527Saurel32  ;;
32482408a527Saurel32  sparc)
32491ad2134fSPaul Brook    target_phys_bits=64
32502408a527Saurel32  ;;
32512408a527Saurel32  sparc64)
32526acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
32531ad2134fSPaul Brook    target_phys_bits=64
3254c2e3dee6SLaurent Vivier    target_long_alignment=8
32552408a527Saurel32  ;;
32562408a527Saurel32  sparc32plus)
3257b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
32586acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3259e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
326025be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
32611ad2134fSPaul Brook    target_phys_bits=64
32622408a527Saurel32  ;;
326324e804ecSAlexander Graf  s390x)
3264bc434676SUlrich Hecht    target_nptl="yes"
326524e804ecSAlexander Graf    target_phys_bits=64
32667b3da903SAlexander Graf    target_long_alignment=8
326724e804ecSAlexander Graf  ;;
3268d2fbca94SGuan Xuetao  unicore32)
3269d2fbca94SGuan Xuetao    target_phys_bits=32
3270d2fbca94SGuan Xuetao  ;;
32712408a527Saurel32  *)
3272de83cd02Sbellard    echo "Unsupported target CPU"
3273de83cd02Sbellard    exit 1
32742408a527Saurel32  ;;
32752408a527Saurel32esac
3276c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3277c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3278c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3279c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
328025be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3281053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
328225be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
328325be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
328442bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
32856acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
32866acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
32876acff7daSJuan Quintelafi
328825be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3289e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3290e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3291e6e91b9cSJuan Quintelafi
329225be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
32931b0c87fcSJuan Quintelacase "$target_arch2" in
32941b0c87fcSJuan Quintela  i386|x86_64)
32951b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
329664b3cfdbSAnthony PERARD      target_phys_bits=64
329725be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
3298432d268cSJun Nakajima      if test "$cpu" = "i386" -o "$cpu" = "x86_64"; then
3299432d268cSJun Nakajima          echo "CONFIG_XEN_MAPCACHE=y" >> $config_target_mak
3300432d268cSJun Nakajima      fi
33011b0c87fcSJuan Quintela    fi
33021b0c87fcSJuan Quintelaesac
3303c59249f9SJuan Quintelacase "$target_arch2" in
33040e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3305c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3306c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3307c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3308c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
33095f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3310adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3311adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3312c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3313c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
331425be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
3315d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
3316d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3317d5970055SMichael S. Tsirkin      fi
3318c59249f9SJuan Quintela    fi
3319c59249f9SJuan Quintelaesac
3320de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
332125be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
332297a847bcSbellardfi
332397a847bcSbellardif test "$target_softmmu" = "yes" ; then
3324b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
332525be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3326de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
33270e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
33285791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3329de83cd02Sbellardfi
3330997344f3Sbellardif test "$target_user_only" = "yes" ; then
333125be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3332997344f3Sbellardfi
3333831b7825Sthsif test "$target_linux_user" = "yes" ; then
333425be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3335831b7825Sthsfi
3336831b7825Sthsif test "$target_darwin_user" = "yes" ; then
333725be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3338831b7825Sthsfi
3339111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3340111a38b0SRobert Relyea  echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3341111a38b0SRobert Relyea  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3342111a38b0SRobert Relyea  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3343111a38b0SRobert Relyeafi
334456aebc89Spbrooklist=""
334556aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
334656aebc89Spbrook  for x in $gdb_xml_files; do
334756aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
334856aebc89Spbrook  done
334925be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
33503d0f1517SJuan Quintelafi
3351de83cd02Sbellard
3352e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
335325be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3354e5fe0c52Spbrookfi
3355bd0c5661Spbrookif test "$target_user_only" = "yes" \
3356bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
335725be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3358bd0c5661Spbrookfi
3359379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
336025be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3361379f6698SPaul Brookfi
336284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
336325be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
336484778508Sblueswir1fi
33655b0753e0Sbellard
33664afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3367fa282484SJuan Quintela
33684afddb55SJuan Quintelacflags=""
3369f9728943SPaolo Bonziniincludes=""
3370fa282484SJuan Quintelaldflags=""
33719b8e111fSJuan Quintela
337257ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
3373f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
337424e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3375f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
33765d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3377f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
337857ddfbf7SJuan Quintelaelse
3379f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
338057ddfbf7SJuan Quintelafi
3381f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
338257ddfbf7SJuan Quintela
33834d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
33844d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
33854d904533SBlue Swirlelse
33864d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
33874d904533SBlue Swirlfi
33884d904533SBlue Swirl
338964656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
339064656024SJuan Quintela  case "$i" in
339164656024SJuan Quintela  alpha)
339225be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
33934d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
339464656024SJuan Quintela  ;;
339564656024SJuan Quintela  arm)
339625be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
33974d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
339864656024SJuan Quintela  ;;
339964656024SJuan Quintela  cris)
340025be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
34014d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
340264656024SJuan Quintela  ;;
340364656024SJuan Quintela  hppa)
340425be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
34054d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
340664656024SJuan Quintela  ;;
340764656024SJuan Quintela  i386|x86_64)
340825be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
34094d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
341064656024SJuan Quintela  ;;
3411903ec55cSAurelien Jarno  ia64*)
3412903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3413903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3414903ec55cSAurelien Jarno  ;;
341564656024SJuan Quintela  m68k)
341625be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
34174d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
341864656024SJuan Quintela  ;;
3419877fdc12SEdgar E. Iglesias  microblaze*)
342025be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
34214d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
342264656024SJuan Quintela  ;;
342364656024SJuan Quintela  mips*)
342425be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
34254d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
342664656024SJuan Quintela  ;;
342764656024SJuan Quintela  ppc*)
342825be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
34294d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
343064656024SJuan Quintela  ;;
343124e804ecSAlexander Graf  s390*)
343225be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
34334d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
343464656024SJuan Quintela  ;;
343564656024SJuan Quintela  sh4)
343625be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
34374d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
343864656024SJuan Quintela  ;;
343964656024SJuan Quintela  sparc*)
344025be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
34414d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
344264656024SJuan Quintela  ;;
344364656024SJuan Quintela  esac
344464656024SJuan Quinteladone
344564656024SJuan Quintela
34466ee7126fSJuan Quintelacase "$ARCH" in
34476ee7126fSJuan Quintelaalpha)
34486ee7126fSJuan Quintela  # Ensure there's only a single GP
34496ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
34506ee7126fSJuan Quintela;;
34516ee7126fSJuan Quintelaesac
34526ee7126fSJuan Quintela
345355d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
345455d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
345555d9c04bSJuan Quintela  arm)
345655d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
345755d9c04bSJuan Quintela  ;;
345825a8bb96SMichael Walle  lm32)
345925a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
346025a8bb96SMichael Walle  ;;
346155d9c04bSJuan Quintela  i386|mips|ppc)
346255d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
346355d9c04bSJuan Quintela  ;;
346455d9c04bSJuan Quintela  esac
346555d9c04bSJuan Quintelafi
346655d9c04bSJuan Quintela
346734005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
346834005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
346934005a00SKirill A. Shutemov  cflags="-fpie $cflags"
347034005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
347134005a00SKirill A. Shutemovfi
347234005a00SKirill A. Shutemov
3473471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
3474471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
3475471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
347625be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3477471857ddSJuan Quintelafi
3478471857ddSJuan Quintela
3479d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
348025be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
3481d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
3482d02c1db3SJuan Quintela    cflags="-p $cflags"
3483d02c1db3SJuan Quintela    ldflags="-p $ldflags"
3484d02c1db3SJuan Quintela  fi
3485d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
3486d02c1db3SJuan Quintela    ldflags="-p $ldflags"
348725be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3488d02c1db3SJuan Quintela  fi
3489d02c1db3SJuan Quintelafi
3490d02c1db3SJuan Quintela
34916ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
34929b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3493fa282484SJuan Quintela  case "$ARCH" in
3494fa282484SJuan Quintela  sparc)
3495fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
3496322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
3497fa282484SJuan Quintela    ;;
34984d58be06SRichard Henderson  alpha | s390x)
34994d58be06SRichard Henderson    # The default placement of the application is fine.
35004d58be06SRichard Henderson    ;;
3501fd76e73aSRichard Henderson  *)
3502322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
3503fa282484SJuan Quintela    ;;
3504fa282484SJuan Quintela  esac
3505fa282484SJuan Quintelafi
3506fa282484SJuan Quintela
3507e205c790SJan Kiszka# use included Linux headers
3508af2be207SJan Kiszkaif test "$linux" = "yes" ; then
3509e205c790SJan Kiszka  includes="-I\$(SRC_PATH)/linux-headers $includes"
3510e205c790SJan Kiszka  mkdir -p linux-headers
3511e205c790SJan Kiszka  case "$cpu" in
3512e205c790SJan Kiszka  i386|x86_64)
3513e205c790SJan Kiszka    symlink $source_path/linux-headers/asm-x86 linux-headers/asm
3514e205c790SJan Kiszka    ;;
3515e205c790SJan Kiszka  ppcemb|ppc|ppc64)
3516af2be207SJan Kiszka    symlink $source_path/linux-headers/asm-powerpc linux-headers/asm
3517e205c790SJan Kiszka    ;;
3518e205c790SJan Kiszka  s390x)
3519e205c790SJan Kiszka    symlink $source_path/linux-headers/asm-s390 linux-headers/asm
3520e205c790SJan Kiszka    ;;
3521e205c790SJan Kiszka  esac
3522af2be207SJan Kiszkafi
3523e205c790SJan Kiszka
352425be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
352525be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3526f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
3527fa282484SJuan Quintela
352897a847bcSbellarddone # for target in $targets
35297d13299dSbellard
3530d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
3531e1144d00SMark McLoughlinDIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3532446b9165SAndreas FärberDIRS="$DIRS pc-bios/spapr-rtas"
35332d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
35343e230dd2SCorentin CharyDIRS="$DIRS fsdev ui"
35352345c77cSMichael RothDIRS="$DIRS qapi"
353613a286d5SMichael RothDIRS="$DIRS qga"
35377d13299dSbellardFILES="Makefile tests/Makefile"
3538e7daa605SthsFILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3539ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3540446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
35412d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
35425ee8ad71SAlex 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
35437ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
35447ea78b74SJan Kiszkadone
3545d1807a4fSPaolo Bonzinimkdir -p $DIRS
35467d13299dSbellardfor f in $FILES ; do
3547f9245e10SPeter Maydell    if [ -e "$source_path/$f" ] && ! [ -e "$f" ]; then
3548f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
3549f9245e10SPeter Maydell    fi
35507d13299dSbellarddone
35511ad2134fSPaul Brook
3552c34ebfdcSAnthony Liguori# temporary config to build submodules
35532d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
3554c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
355537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3556c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3557c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3558c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
3559c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
3560c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3561c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
3562c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
3563c34ebfdcSAnthony Liguoridone
3564c34ebfdcSAnthony Liguori
35651ad2134fSPaul Brookfor hwlib in 32 64; do
35661ad2134fSPaul Brook  d=libhw$hwlib
35671ad2134fSPaul Brook  mkdir -p $d
35689953b2fcSBlue Swirl  mkdir -p $d/ide
356911568d6dSPaolo Bonzini  symlink $source_path/Makefile.hw $d/Makefile
3570353ac78dSAneesh Kumar K.V  mkdir -p $d/9pfs
357137116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
35721ad2134fSPaul Brookdone
3573add16157SBlue Swirl
3574111a38b0SRobert Relyeaif [ "$source_path" != `pwd` ]; then
3575111a38b0SRobert Relyea    # out of tree build
3576111a38b0SRobert Relyea    mkdir -p libcacard
3577111a38b0SRobert Relyea    rm -f libcacard/Makefile
357844dc0ca3SAlon Levy    symlink "$source_path/libcacard/Makefile" libcacard/Makefile
3579111a38b0SRobert Relyeafi
3580111a38b0SRobert Relyea
3581add16157SBlue Swirld=libuser
3582add16157SBlue Swirlmkdir -p $d
358311568d6dSPaolo Bonzinisymlink $source_path/Makefile.user $d/Makefile
3584299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
3585299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3586299060a0SKirill A. Shutemovfi
3587b40292e7SJan Kiszka
3588b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
3589b40292e7SJan Kiszka  mkdir -p QMP
3590b40292e7SJan Kiszkafi
3591