xref: /openbmc/qemu/configure (revision 1fc7bd4a86a2bfeafcec29445871eb97469a2699)
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=""
182377529c0SPaolo Bonzini
183ac0df51dSaliguori# parse CC options first
184ac0df51dSaliguorifor opt do
185ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
186ac0df51dSaliguori  case "$opt" in
187ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
188ac0df51dSaliguori  ;;
1893d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
190ac0df51dSaliguori  ;;
191ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
192ca4deeb1SPaolo Bonzini  ;;
1932ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
1942ff6b91eSJuan Quintela  ;;
195a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
196e2a2ed06SJuan Quintela  ;;
197e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
198e2a2ed06SJuan Quintela  ;;
19950e7b1a0SJuan Quintela  --sparc_cpu=*)
20050e7b1a0SJuan Quintela    sparc_cpu="$optarg"
20150e7b1a0SJuan Quintela    case $sparc_cpu in
202ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
20350e7b1a0SJuan Quintela      cpu="sparc"
20450e7b1a0SJuan Quintela    ;;
20550e7b1a0SJuan Quintela    v9)
20650e7b1a0SJuan Quintela      cpu="sparc64"
20750e7b1a0SJuan Quintela    ;;
20850e7b1a0SJuan Quintela    *)
20950e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
21050e7b1a0SJuan Quintela      exit 1
21150e7b1a0SJuan Quintela    ;;
21250e7b1a0SJuan Quintela    esac
21350e7b1a0SJuan Quintela  ;;
214ac0df51dSaliguori  esac
215ac0df51dSaliguoridone
216ac0df51dSaliguori# OS specific
217ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
218ac0df51dSaliguori# we can eliminate it's usage altogether
219ac0df51dSaliguori
2203d8df640SPaolo Bonzinicc="${cross_prefix}${CC-gcc}"
2213d8df640SPaolo Bonziniar="${cross_prefix}${AR-ar}"
2223d8df640SPaolo Bonziniobjcopy="${cross_prefix}${OBJCOPY-objcopy}"
2233d8df640SPaolo Bonzinild="${cross_prefix}${LD-ld}"
2243d8df640SPaolo Bonzinistrip="${cross_prefix}${STRIP-strip}"
2253d8df640SPaolo Bonziniwindres="${cross_prefix}${WINDRES-windres}"
226a8bd70adSPaolo Bonzinipkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
2273ec87ffeSPaolo Bonzinisdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
228ac0df51dSaliguori
229be17dc90SMichael S. Tsirkin# default flags for all hosts
230be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
231be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
232f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
233be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
234be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
23584958305SKirill A. ShutemovQEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
236f9728943SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH)"
237be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
238be17dc90SMichael S. Tsirkin
239ca4deeb1SPaolo Bonzini# make source path absolute
240ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
241ca4deeb1SPaolo Bonzini
242ac0df51dSaliguoricheck_define() {
243ac0df51dSaliguoricat > $TMPC <<EOF
244ac0df51dSaliguori#if !defined($1)
245ac0df51dSaliguori#error Not defined
246ac0df51dSaliguori#endif
247ac0df51dSaliguoriint main(void) { return 0; }
248ac0df51dSaliguoriEOF
24952166aa0SJuan Quintela  compile_object
250ac0df51dSaliguori}
251ac0df51dSaliguori
2522ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
2532ff6b91eSJuan Quintela  # command line argument
2542ff6b91eSJuan Quintela  :
2552ff6b91eSJuan Quintelaelif check_define __i386__ ; then
256ac0df51dSaliguori  cpu="i386"
257ac0df51dSaliguorielif check_define __x86_64__ ; then
258ac0df51dSaliguori  cpu="x86_64"
2593aa9bd6cSblueswir1elif check_define __sparc__ ; then
2603aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
2613aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
2623aa9bd6cSblueswir1  if check_define __arch64__ ; then
2633aa9bd6cSblueswir1    cpu="sparc64"
2643aa9bd6cSblueswir1  else
2653aa9bd6cSblueswir1    cpu="sparc"
2663aa9bd6cSblueswir1  fi
267fdf7ed96Smalcelif check_define _ARCH_PPC ; then
268fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
269fdf7ed96Smalc    cpu="ppc64"
270ac0df51dSaliguori  else
271fdf7ed96Smalc    cpu="ppc"
272fdf7ed96Smalc  fi
273afa05235SAurelien Jarnoelif check_define __mips__ ; then
274afa05235SAurelien Jarno  cpu="mips"
275477ba620SAurelien Jarnoelif check_define __ia64__ ; then
276477ba620SAurelien Jarno  cpu="ia64"
277d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
278d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
279d66ed0eaSAurelien Jarno    cpu="s390x"
280d66ed0eaSAurelien Jarno  else
281d66ed0eaSAurelien Jarno    cpu="s390"
282d66ed0eaSAurelien Jarno  fi
283fdf7ed96Smalcelse
284fdf7ed96Smalc  cpu=`uname -m`
285ac0df51dSaliguorifi
286ac0df51dSaliguori
2877d13299dSbellardcase "$cpu" in
288d2fbca94SGuan Xuetao  alpha|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64|unicore32)
289ea8f20f8SJuan Quintela    cpu="$cpu"
290ea8f20f8SJuan Quintela  ;;
2917d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
29297a847bcSbellard    cpu="i386"
2937d13299dSbellard  ;;
294aaa5fa14Saurel32  x86_64|amd64)
295aaa5fa14Saurel32    cpu="x86_64"
296aaa5fa14Saurel32  ;;
297ba68055eSbellard  armv*b)
298808c4954Sbellard    cpu="armv4b"
299808c4954Sbellard  ;;
300ba68055eSbellard  armv*l)
3017d13299dSbellard    cpu="armv4l"
3027d13299dSbellard  ;;
303f54b3f92Saurel32  parisc|parisc64)
304f54b3f92Saurel32    cpu="hppa"
305f54b3f92Saurel32  ;;
306afa05235SAurelien Jarno  mips*)
307afa05235SAurelien Jarno    cpu="mips"
308afa05235SAurelien Jarno  ;;
30924e804ecSAlexander Graf  s390)
310fb3e5849Sbellard    cpu="s390"
311fb3e5849Sbellard  ;;
31224e804ecSAlexander Graf  s390x)
31324e804ecSAlexander Graf    cpu="s390x"
31424e804ecSAlexander Graf  ;;
3153142255cSblueswir1  sparc|sun4[cdmuv])
316ae228531Sbellard    cpu="sparc"
317ae228531Sbellard  ;;
3187d13299dSbellard  *)
319a447d4dcSPaolo Bonzini    echo "Unsupported CPU = $cpu"
320a447d4dcSPaolo Bonzini    exit 1
3217d13299dSbellard  ;;
3227d13299dSbellardesac
323e2d52ad3SJuan Quintela
3247d13299dSbellard# OS specific
325ac0df51dSaliguoriif check_define __linux__ ; then
326ac0df51dSaliguori  targetos="Linux"
327ac0df51dSaliguorielif check_define _WIN32 ; then
328ac0df51dSaliguori  targetos='MINGW32'
329169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
330169dc5d3Sblueswir1  targetos='OpenBSD'
331169dc5d3Sblueswir1elif check_define __sun__ ; then
332169dc5d3Sblueswir1  targetos='SunOS'
333179cf400SAndreas Färberelif check_define __HAIKU__ ; then
334179cf400SAndreas Färber  targetos='Haiku'
335ac0df51dSaliguorielse
3367d13299dSbellard  targetos=`uname -s`
337ac0df51dSaliguorifi
3380dbfc675SJuan Quintela
3397d13299dSbellardcase $targetos in
340c326e0afSbellardCYGWIN*)
341c326e0afSbellard  mingw32="yes"
342a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
343d5631638Smalc  audio_possible_drivers="winwave sdl"
344d5631638Smalc  audio_drv_list="winwave"
345c326e0afSbellard;;
34667b915a5SbellardMINGW32*)
34767b915a5Sbellard  mingw32="yes"
348d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
349d5631638Smalc  audio_drv_list="winwave"
35067b915a5Sbellard;;
3515c40d2bdSthsGNU/kFreeBSD)
352a167ba50SAurelien Jarno  bsd="yes"
3530c58ac1cSmalc  audio_drv_list="oss"
354f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3555c40d2bdSths;;
3567d3505c5SbellardFreeBSD)
3577d3505c5Sbellard  bsd="yes"
3580db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3590c58ac1cSmalc  audio_drv_list="oss"
360f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
361f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
362f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3637d3505c5Sbellard;;
364c5e97233Sblueswir1DragonFly)
365c5e97233Sblueswir1  bsd="yes"
3660db4a067SPaolo Bonzini  make="${MAKE-gmake}"
367c5e97233Sblueswir1  audio_drv_list="oss"
368c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
369c5e97233Sblueswir1;;
3707d3505c5SbellardNetBSD)
3717d3505c5Sbellard  bsd="yes"
3720db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3730c58ac1cSmalc  audio_drv_list="oss"
374c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3758ef92a88Sblueswir1  oss_lib="-lossaudio"
3767d3505c5Sbellard;;
3777d3505c5SbellardOpenBSD)
3787d3505c5Sbellard  bsd="yes"
3790db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3800c58ac1cSmalc  audio_drv_list="oss"
381c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3822f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3837d3505c5Sbellard;;
38483fb7adfSbellardDarwin)
38583fb7adfSbellard  bsd="yes"
38683fb7adfSbellard  darwin="yes"
3870dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3880dbfc675SJuan Quintela  # run 64-bit userspace code
389aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3901b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
391aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3921b0f9cc2Saliguori  fi
3931b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
394a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3950c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3961b0f9cc2Saliguori  else
397a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3981b0f9cc2Saliguori  fi
399831b7825Sths  darwin_user="yes"
400fd677642Sths  cocoa="yes"
4010c58ac1cSmalc  audio_drv_list="coreaudio"
402c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4030c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4047973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
40583fb7adfSbellard;;
406ec530c81SbellardSunOS)
407ec530c81Sbellard  solaris="yes"
4080db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4090db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
410fa58948dSBlue Swirl  ld="gld"
4110475a5caSths  needs_libsunmath="no"
412c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
413ef18c883Sths  # have to select again, because `uname -m` returns i86pc
414ef18c883Sths  # even on an x86_64 box.
415ef18c883Sths  solariscpu=`isainfo -k`
416ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
417ef18c883Sths    cpu="x86_64"
418ef18c883Sths  fi
419c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4200475a5caSths    if test "$solarisrev" -le 9 ; then
4210475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4220475a5caSths        needs_libsunmath="yes"
423f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
424f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
425f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4260475a5caSths      else
4270475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4280475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4290475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4300475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4310475a5caSths        exit 1
4320475a5caSths      fi
4330475a5caSths    fi
43486b2bd93Sths  fi
4356b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4360c58ac1cSmalc    audio_drv_list="oss"
4376b4d2ba1Sths  fi
438c2de5c91Smalc  audio_possible_drivers="oss sdl"
439d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
440d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
441d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
442d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
443a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
444e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
445ec530c81Sbellard;;
446b29fe3edSmalcAIX)
447b29fe3edSmalc  aix="yes"
4480db4a067SPaolo Bonzini  make="${MAKE-gmake}"
449b29fe3edSmalc;;
450179cf400SAndreas FärberHaiku)
451179cf400SAndreas Färber  haiku="yes"
452179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
453179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
454179cf400SAndreas Färber;;
455fb065187Sbellard*)
4560c58ac1cSmalc  audio_drv_list="oss"
457b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4585327cf48Sbellard  linux="yes"
459831b7825Sths  linux_user="yes"
46068063649Sblueswir1  usb="linux"
461af2be207SJan Kiszka  kvm="yes"
462af2be207SJan Kiszka  vhost_net="yes"
46307f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
464c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
465c9ec1fe4Sbellard  fi
466fb065187Sbellard;;
4677d13299dSbellardesac
4687d13299dSbellard
4697d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
470b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
47168063649Sblueswir1    usb="bsd"
47283fb7adfSbellard  fi
47384778508Sblueswir1  bsd_user="yes"
4747d3505c5Sbellardfi
4757d3505c5Sbellard
4760db4a067SPaolo Bonzini: ${make=${MAKE-make}}
4770db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
4780db4a067SPaolo Bonzini
4793457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4803457a3f8SJuan Quintela  EXESUF=".exe"
481a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
482e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
483e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
48408f3896aSStefan Weil  LIBS="-lwinmm -lws2_32 -liberty -liphlpapi $LIBS"
485683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
486683035deSPaolo Bonzini  mandir="\${prefix}"
487683035deSPaolo Bonzini  datadir="\${prefix}"
488683035deSPaolo Bonzini  docdir="\${prefix}"
489683035deSPaolo Bonzini  bindir="\${prefix}"
490683035deSPaolo Bonzini  sysconfdir="\${prefix}"
491683035deSPaolo Bonzini  confsuffix=""
4923457a3f8SJuan Quintelafi
4933457a3f8SJuan Quintela
494487fefdbSAnthony Liguoriwerror=""
49585aa5189Sbellard
4967d13299dSbellardfor opt do
497a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4987d13299dSbellard  case "$opt" in
4992efc3265Sbellard  --help|-h) show_help=yes
5002efc3265Sbellard  ;;
50199123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
50299123e13SMike Frysinger  ;;
503b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5047d13299dSbellard  ;;
505b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
50632ce6337Sbellard  ;;
507ca4deeb1SPaolo Bonzini  --source-path=*)
5087d13299dSbellard  ;;
509ac0df51dSaliguori  --cross-prefix=*)
5107d13299dSbellard  ;;
511ac0df51dSaliguori  --cc=*)
5127d13299dSbellard  ;;
513b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
51483469015Sbellard  ;;
515b1a550a0Spbrook  --make=*) make="$optarg"
5167d13299dSbellard  ;;
5176a882643Spbrook  --install=*) install="$optarg"
5186a882643Spbrook  ;;
519e2a2ed06SJuan Quintela  --extra-cflags=*)
5207d13299dSbellard  ;;
521e2a2ed06SJuan Quintela  --extra-ldflags=*)
5227d13299dSbellard  ;;
5232ff6b91eSJuan Quintela  --cpu=*)
5247d13299dSbellard  ;;
525b1a550a0Spbrook  --target-list=*) target_list="$optarg"
526de83cd02Sbellard  ;;
52774242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
52894a420b1SStefan Hajnoczi  ;;
52974242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
5309410b56cSPrerna Saxena  ;;
5317d13299dSbellard  --enable-gprof) gprof="yes"
5327d13299dSbellard  ;;
53379427693SLoïc Minier  --static)
53479427693SLoïc Minier    static="yes"
53579427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
53643ce4dfeSbellard  ;;
5370b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5380b24e75fSPaolo Bonzini  ;;
5390b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5400b24e75fSPaolo Bonzini  ;;
5413aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
5423aa5d2beSAlon Levy  ;;
5430b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5440b24e75fSPaolo Bonzini  ;;
5450b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5460b24e75fSPaolo Bonzini  ;;
547ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
54807381cc1SAnthony Liguori  ;;
54997a847bcSbellard  --disable-sdl) sdl="no"
55097a847bcSbellard  ;;
551c4198157SJuan Quintela  --enable-sdl) sdl="yes"
552c4198157SJuan Quintela  ;;
553821601eaSJes Sorensen  --disable-vnc) vnc="no"
554821601eaSJes Sorensen  ;;
555821601eaSJes Sorensen  --enable-vnc) vnc="yes"
556821601eaSJes Sorensen  ;;
557b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
558102a52e4Sbellard  ;;
559c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
560c2de5c91Smalc  ;;
5612f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5622f6a1ab0Sblueswir1  ;;
5632fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5640c58ac1cSmalc  ;;
5650c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5660c58ac1cSmalc  ;;
567eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
568eb852011SMarkus Armbruster  ;;
569f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
570f8393946Saurel32  ;;
571f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
572f8393946Saurel32  ;;
573b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
574b4475aa2SLuiz Capitulino  ;;
575b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
576b4475aa2SLuiz Capitulino  ;;
577f3d08ee6SPaul Brook  --enable-debug)
578f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
579f3d08ee6SPaul Brook      debug_tcg="yes"
580b4475aa2SLuiz Capitulino      debug_mon="yes"
581f3d08ee6SPaul Brook      debug="yes"
582f3d08ee6SPaul Brook      strip_opt="no"
583f3d08ee6SPaul Brook  ;;
58403b4fe7dSaliguori  --enable-sparse) sparse="yes"
58503b4fe7dSaliguori  ;;
58603b4fe7dSaliguori  --disable-sparse) sparse="no"
58703b4fe7dSaliguori  ;;
5881625af87Saliguori  --disable-strip) strip_opt="no"
5891625af87Saliguori  ;;
5908d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5918d5d2d4cSths  ;;
5921be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
5931be10ad2SJuan Quintela  ;;
5942f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
5952f9606b3Saliguori  ;;
596ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
597ea784e3bSJuan Quintela  ;;
5982f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
5992f6f5c7aSCorentin Chary  ;;
6002f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
6012f6f5c7aSCorentin Chary  ;;
602efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
603efe556adSCorentin Chary  ;;
604efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
605efe556adSCorentin Chary  ;;
606bd023f95SCorentin Chary  --disable-vnc-thread) vnc_thread="no"
607bd023f95SCorentin Chary  ;;
608bd023f95SCorentin Chary  --enable-vnc-thread) vnc_thread="yes"
609bd023f95SCorentin Chary  ;;
610443f1376Sbellard  --disable-slirp) slirp="no"
611c20709aaSbellard  ;;
612ee682d27SStefan Weil  --disable-uuid) uuid="no"
613ee682d27SStefan Weil  ;;
614ee682d27SStefan Weil  --enable-uuid) uuid="yes"
615ee682d27SStefan Weil  ;;
616e0e6c8c0Saliguori  --disable-vde) vde="no"
6178a16d273Sths  ;;
618dfb278bdSJuan Quintela  --enable-vde) vde="yes"
619dfb278bdSJuan Quintela  ;;
620e37630caSaliguori  --disable-xen) xen="no"
621e37630caSaliguori  ;;
622fc321b4bSJuan Quintela  --enable-xen) xen="yes"
623fc321b4bSJuan Quintela  ;;
6242e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
6252e4d9fb1Saurel32  ;;
6264ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6274ffcedb6SJuan Quintela  ;;
628fb599c9aSbalrog  --disable-bluez) bluez="no"
629fb599c9aSbalrog  ;;
630a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
631a20a6f46SJuan Quintela  ;;
6327ba1e619Saliguori  --disable-kvm) kvm="no"
6337ba1e619Saliguori  ;;
634b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
635b31a0277SJuan Quintela  ;;
636cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
637cd4ec0b4SGerd Hoffmann  ;;
638cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
639cd4ec0b4SGerd Hoffmann  ;;
64005c2a3e7Sbellard  --enable-profiler) profiler="yes"
64105c2a3e7Sbellard  ;;
642c2de5c91Smalc  --enable-cocoa)
643c2de5c91Smalc      cocoa="yes" ;
644c2de5c91Smalc      sdl="no" ;
645c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6465b0753e0Sbellard  ;;
647cad25d69Spbrook  --disable-system) softmmu="no"
6480a8e90f4Spbrook  ;;
649cad25d69Spbrook  --enable-system) softmmu="yes"
6500a8e90f4Spbrook  ;;
6510953a80fSZachary Amsden  --disable-user)
6520953a80fSZachary Amsden      linux_user="no" ;
6530953a80fSZachary Amsden      bsd_user="no" ;
6540953a80fSZachary Amsden      darwin_user="no"
6550953a80fSZachary Amsden  ;;
6560953a80fSZachary Amsden  --enable-user) ;;
657831b7825Sths  --disable-linux-user) linux_user="no"
6580a8e90f4Spbrook  ;;
659831b7825Sths  --enable-linux-user) linux_user="yes"
660831b7825Sths  ;;
661831b7825Sths  --disable-darwin-user) darwin_user="no"
662831b7825Sths  ;;
663831b7825Sths  --enable-darwin-user) darwin_user="yes"
6640a8e90f4Spbrook  ;;
66584778508Sblueswir1  --disable-bsd-user) bsd_user="no"
66684778508Sblueswir1  ;;
66784778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
66884778508Sblueswir1  ;;
669379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
670379f6698SPaul Brook  ;;
671379f6698SPaul Brook  --disable-guest-base) guest_base="no"
672379f6698SPaul Brook  ;;
67334005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
67434005a00SKirill A. Shutemov  ;;
67534005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
67634005a00SKirill A. Shutemov  ;;
677c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
678c5937220Spbrook  ;;
6793142255cSblueswir1  --sparc_cpu=*)
6803142255cSblueswir1  ;;
68185aa5189Sbellard  --enable-werror) werror="yes"
68285aa5189Sbellard  ;;
68385aa5189Sbellard  --disable-werror) werror="no"
68485aa5189Sbellard  ;;
6854d3b6f6eSbalrog  --disable-curses) curses="no"
6864d3b6f6eSbalrog  ;;
687c584a6d0SJuan Quintela  --enable-curses) curses="yes"
688c584a6d0SJuan Quintela  ;;
689769ce76dSAlexander Graf  --disable-curl) curl="no"
690769ce76dSAlexander Graf  ;;
691788c8196SJuan Quintela  --enable-curl) curl="yes"
692788c8196SJuan Quintela  ;;
6932df87df7SJuan Quintela  --disable-fdt) fdt="no"
6942df87df7SJuan Quintela  ;;
6952df87df7SJuan Quintela  --enable-fdt) fdt="yes"
6962df87df7SJuan Quintela  ;;
6975495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
6985495ed11SLuiz Capitulino  ;;
6995495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
7005495ed11SLuiz Capitulino  ;;
701bd0c5661Spbrook  --disable-nptl) nptl="no"
702bd0c5661Spbrook  ;;
703b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
704b0a47e79SJuan Quintela  ;;
7058ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
7068ff9cbf7Smalc  ;;
7075c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
7085c6c3a6cSChristoph Hellwig  ;;
7095c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
7105c6c3a6cSChristoph Hellwig  ;;
711758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
712758e8e38SVenkateswararao Jujjuri (JV)  ;;
713758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
714758e8e38SVenkateswararao Jujjuri (JV)  ;;
715e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
716e5d355d1Saliguori  ;;
71777755340Sths  --disable-blobs) blobs="no"
71877755340Sths  ;;
7194a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
7204a19f1ecSpbrook  ;;
721a25dba17SJuan Quintela  --disable-docs) docs="no"
72270ec5dc0SAnthony Liguori  ;;
723a25dba17SJuan Quintela  --enable-docs) docs="yes"
72483a3ab8bSJuan Quintela  ;;
725d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
726d5970055SMichael S. Tsirkin  ;;
727d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
728d5970055SMichael S. Tsirkin  ;;
72920ff075bSMichael Walle  --disable-opengl) opengl="no"
73020ff075bSMichael Walle  ;;
73120ff075bSMichael Walle  --enable-opengl) opengl="yes"
73220ff075bSMichael Walle  ;;
7336bde81cbSPaolo Bonzini  --*dir)
7346bde81cbSPaolo Bonzini  ;;
735f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
736f27aaf4bSChristian Brunner  ;;
737f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
738f27aaf4bSChristian Brunner  ;;
73936707144SAlon Levy  --disable-smartcard) smartcard="no"
74036707144SAlon Levy  ;;
74136707144SAlon Levy  --enable-smartcard) smartcard="yes"
74236707144SAlon Levy  ;;
743111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
744111a38b0SRobert Relyea  ;;
745111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
746111a38b0SRobert Relyea  ;;
74769354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
74869354a83SHans de Goede  ;;
74969354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
75069354a83SHans de Goede  ;;
7517f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7527f1559c6Sbalrog  ;;
7537d13299dSbellard  esac
7547d13299dSbellarddone
7557d13299dSbellard
7563142255cSblueswir1#
7573142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
758a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7593142255cSblueswir1#
760379f6698SPaul Brookhost_guest_base="no"
76140293e58Sbellardcase "$cpu" in
762ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
763ed968ff1SJuan Quintela           v7|v8)
764a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
765ed968ff1SJuan Quintela           ;;
766ed968ff1SJuan Quintela           v8plus|v8plusa)
767a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
768ed968ff1SJuan Quintela           ;;
769ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
770a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
771ed968ff1SJuan Quintela           esac
7720c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
773a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
774762e8230Sblueswir1           if test "$solaris" = "no" ; then
775a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
776c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
777762e8230Sblueswir1           fi
7783142255cSblueswir1           ;;
779ed968ff1SJuan Quintela    sparc64)
780a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7810c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
782a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
783ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
784a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
785762e8230Sblueswir1           fi
7863142255cSblueswir1           ;;
78776d83bdeSths    s390)
78828d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
78928d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
79048bb3750SRichard Henderson           host_guest_base="yes"
79128d7cc49SRichard Henderson           ;;
79228d7cc49SRichard Henderson    s390x)
79328d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
79428d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
79548bb3750SRichard Henderson           host_guest_base="yes"
79676d83bdeSths           ;;
79740293e58Sbellard    i386)
798a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
7990c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
8002b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
801c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
802379f6698SPaul Brook           host_guest_base="yes"
80340293e58Sbellard           ;;
80440293e58Sbellard    x86_64)
805a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
8060c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8072b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
808379f6698SPaul Brook           host_guest_base="yes"
809379f6698SPaul Brook           ;;
810379f6698SPaul Brook    arm*)
811379f6698SPaul Brook           host_guest_base="yes"
81240293e58Sbellard           ;;
813f6548c0aSmalc    ppc*)
814f6548c0aSmalc           host_guest_base="yes"
815f6548c0aSmalc           ;;
816cc01cc8eSAurelien Jarno    mips*)
817cc01cc8eSAurelien Jarno           host_guest_base="yes"
818cc01cc8eSAurelien Jarno           ;;
819477ba620SAurelien Jarno    ia64*)
820477ba620SAurelien Jarno           host_guest_base="yes"
821477ba620SAurelien Jarno           ;;
822fd76e73aSRichard Henderson    hppa*)
823fd76e73aSRichard Henderson           host_guest_base="yes"
824fd76e73aSRichard Henderson           ;;
825d2fbca94SGuan Xuetao    unicore32*)
826d2fbca94SGuan Xuetao           host_guest_base="yes"
827d2fbca94SGuan Xuetao           ;;
8283142255cSblueswir1esac
8293142255cSblueswir1
830379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
831379f6698SPaul Brook
83260e0df25SPeter Maydell
83360e0df25SPeter Maydelldefault_target_list=""
83460e0df25SPeter Maydell
83560e0df25SPeter Maydell# these targets are portable
83660e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
83760e0df25SPeter Maydell    default_target_list="\
83860e0df25SPeter Maydelli386-softmmu \
83960e0df25SPeter Maydellx86_64-softmmu \
840b758aca1SRichard Hendersonalpha-softmmu \
84160e0df25SPeter Maydellarm-softmmu \
84260e0df25SPeter Maydellcris-softmmu \
84360e0df25SPeter Maydelllm32-softmmu \
84460e0df25SPeter Maydellm68k-softmmu \
84560e0df25SPeter Maydellmicroblaze-softmmu \
84660e0df25SPeter Maydellmicroblazeel-softmmu \
84760e0df25SPeter Maydellmips-softmmu \
84860e0df25SPeter Maydellmipsel-softmmu \
84960e0df25SPeter Maydellmips64-softmmu \
85060e0df25SPeter Maydellmips64el-softmmu \
85160e0df25SPeter Maydellppc-softmmu \
85260e0df25SPeter Maydellppcemb-softmmu \
85360e0df25SPeter Maydellppc64-softmmu \
85460e0df25SPeter Maydellsh4-softmmu \
85560e0df25SPeter Maydellsh4eb-softmmu \
85660e0df25SPeter Maydellsparc-softmmu \
85760e0df25SPeter Maydellsparc64-softmmu \
8580f3301d4SAlexander Grafs390x-softmmu \
85960e0df25SPeter Maydell"
86060e0df25SPeter Maydellfi
86160e0df25SPeter Maydell# the following are Linux specific
86260e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
86360e0df25SPeter Maydell    default_target_list="${default_target_list}\
86460e0df25SPeter Maydelli386-linux-user \
86560e0df25SPeter Maydellx86_64-linux-user \
86660e0df25SPeter Maydellalpha-linux-user \
86760e0df25SPeter Maydellarm-linux-user \
86860e0df25SPeter Maydellarmeb-linux-user \
86960e0df25SPeter Maydellcris-linux-user \
87060e0df25SPeter Maydellm68k-linux-user \
87160e0df25SPeter Maydellmicroblaze-linux-user \
87260e0df25SPeter Maydellmicroblazeel-linux-user \
87360e0df25SPeter Maydellmips-linux-user \
87460e0df25SPeter Maydellmipsel-linux-user \
87560e0df25SPeter Maydellppc-linux-user \
87660e0df25SPeter Maydellppc64-linux-user \
87760e0df25SPeter Maydellppc64abi32-linux-user \
87860e0df25SPeter Maydellsh4-linux-user \
87960e0df25SPeter Maydellsh4eb-linux-user \
88060e0df25SPeter Maydellsparc-linux-user \
88160e0df25SPeter Maydellsparc64-linux-user \
88260e0df25SPeter Maydellsparc32plus-linux-user \
88360e0df25SPeter Maydellunicore32-linux-user \
8840f3301d4SAlexander Grafs390x-linux-user \
88560e0df25SPeter Maydell"
88660e0df25SPeter Maydellfi
88760e0df25SPeter Maydell# the following are Darwin specific
88860e0df25SPeter Maydellif [ "$darwin_user" = "yes" ] ; then
88960e0df25SPeter Maydell    default_target_list="$default_target_list i386-darwin-user ppc-darwin-user "
89060e0df25SPeter Maydellfi
89160e0df25SPeter Maydell# the following are BSD specific
89260e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
89360e0df25SPeter Maydell    default_target_list="${default_target_list}\
89460e0df25SPeter Maydelli386-bsd-user \
89560e0df25SPeter Maydellx86_64-bsd-user \
89660e0df25SPeter Maydellsparc-bsd-user \
89760e0df25SPeter Maydellsparc64-bsd-user \
89860e0df25SPeter Maydell"
89960e0df25SPeter Maydellfi
90060e0df25SPeter Maydell
901af5db58eSpbrookif test x"$show_help" = x"yes" ; then
902af5db58eSpbrookcat << EOF
903af5db58eSpbrook
904af5db58eSpbrookUsage: configure [options]
905af5db58eSpbrookOptions: [defaults in brackets after descriptions]
906af5db58eSpbrook
907af5db58eSpbrookEOF
908af5db58eSpbrookecho "Standard options:"
909af5db58eSpbrookecho "  --help                   print this message"
910af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
911af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
912af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
91360e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
91460e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
91560e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
916af5db58eSpbrookecho ""
917af5db58eSpbrookecho "Advanced options (experts only):"
918af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
919af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
920af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
9210bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
9220bfe8cc0SPaolo Bonziniecho "                           build time"
923a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
924e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
925af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
9266a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
927af5db58eSpbrookecho "  --static                 enable static build [$static]"
9280b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
9290b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
9300b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
9310b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
9320b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
933f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
934f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
93509695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
936890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
937890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
9381625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
93985aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
940fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
941c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
942821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
943821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
944af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
945c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
946c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
9474c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
9484c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
949eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
950eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
9518ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
952e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
953fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
9542e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
9554ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
9568d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
9571be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
9582f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
959ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
9602f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
9612f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
96296763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
963efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
964bd023f95SCorentin Charyecho "  --disable-vnc-thread     disable threaded VNC server"
965bd023f95SCorentin Charyecho "  --enable-vnc-thread      enable threaded VNC server"
966af896aaaSpbrookecho "  --disable-curses         disable curses output"
967c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
968769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
969788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
9702df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
9712df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
9725495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
9735495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
974fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
975a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
9766093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
9777ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
978b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
979bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
980e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
981af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
982af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
9830953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
9840953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
985831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
986831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
987831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
988831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
98984778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
99084778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
991379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
992379f6698SPaul Brookecho "                           emulation targets"
993379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
99434005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
99534005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
996af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
997af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
9982f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
999c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
10003142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
1001ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1002ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1003e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1004dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
10055c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
10065c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
1007758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1008758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
1009e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
101077755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1011d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1012d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1013d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1014d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1015320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1016320fba2aSFabien Chouteauecho "                           Available backends:" $("$source_path"/scripts/tracetool --list-backends)
101774242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
10189410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1019cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1020cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1021f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
102236707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
102336707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1024111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1025111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
102669354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
102769354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1028af5db58eSpbrookecho ""
10295bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1030af5db58eSpbrookexit 1
1031af5db58eSpbrookfi
1032af5db58eSpbrook
10338d05095cSPaolo Bonzini# check that the C compiler works.
10348d05095cSPaolo Bonzinicat > $TMPC <<EOF
10358d05095cSPaolo Bonziniint main(void) {}
10368d05095cSPaolo BonziniEOF
10378d05095cSPaolo Bonzini
10388d05095cSPaolo Bonziniif compile_object ; then
10398d05095cSPaolo Bonzini  : C compiler works ok
10408d05095cSPaolo Bonzinielse
10418d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
10428d05095cSPaolo Bonzini    exit 1
10438d05095cSPaolo Bonzinifi
10448d05095cSPaolo Bonzini
10458d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
10468d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
10478d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1048f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
10498d05095cSPaolo Bonzinicat > $TMPC << EOF
10508d05095cSPaolo Bonziniint main(void) { return 0; }
10518d05095cSPaolo BonziniEOF
10528d05095cSPaolo Bonzinifor flag in $gcc_flags; do
10538d05095cSPaolo Bonzini    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
10548d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
10558d05095cSPaolo Bonzini    fi
10568d05095cSPaolo Bonzinidone
10578d05095cSPaolo Bonzini
1058ec530c81Sbellard#
1059ec530c81Sbellard# Solaris specific configure tool chain decisions
1060ec530c81Sbellard#
1061ec530c81Sbellardif test "$solaris" = "yes" ; then
10626792aa11SLoïc Minier  if has $install; then
10636792aa11SLoïc Minier    :
10646792aa11SLoïc Minier  else
1065ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1066ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1067ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1068ec530c81Sbellard    exit 1
1069ec530c81Sbellard  fi
10706792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1071ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1072ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1073ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1074ec530c81Sbellard    exit 1
1075ec530c81Sbellard  fi
10766792aa11SLoïc Minier  if has ar; then
10776792aa11SLoïc Minier    :
10786792aa11SLoïc Minier  else
1079ec530c81Sbellard    echo "Error: No path includes ar"
1080ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1081ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1082ec530c81Sbellard    fi
1083ec530c81Sbellard    exit 1
1084ec530c81Sbellard  fi
1085ec530c81Sbellardfi
1086ec530c81Sbellard
10875327cf48Sbellardif test -z "$target_list" ; then
108860e0df25SPeter Maydell    target_list="$default_target_list"
10896e20a45fSbellardelse
1090b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
10915327cf48Sbellardfi
10920a8e90f4Spbrookif test -z "$target_list" ; then
10930a8e90f4Spbrook    echo "No targets enabled"
10940a8e90f4Spbrook    exit 1
10950a8e90f4Spbrookfi
1096f55fe278SPaolo Bonzini# see if system emulation was really requested
1097f55fe278SPaolo Bonzinicase " $target_list " in
1098f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1099f55fe278SPaolo Bonzini  ;;
1100f55fe278SPaolo Bonzini  *) softmmu=no
1101f55fe278SPaolo Bonzini  ;;
1102f55fe278SPaolo Bonziniesac
11035327cf48Sbellard
1104249247c9SJuan Quintelafeature_not_found() {
1105249247c9SJuan Quintela  feature=$1
1106249247c9SJuan Quintela
1107249247c9SJuan Quintela  echo "ERROR"
1108249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
11099332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1110249247c9SJuan Quintela  echo "ERROR"
1111249247c9SJuan Quintela  exit 1;
1112249247c9SJuan Quintela}
1113249247c9SJuan Quintela
11147d13299dSbellardif test -z "$cross_prefix" ; then
11157d13299dSbellard
11167d13299dSbellard# ---
11177d13299dSbellard# big/little endian test
11187d13299dSbellardcat > $TMPC << EOF
11197d13299dSbellard#include <inttypes.h>
11207d13299dSbellardint main(int argc, char ** argv){
11217d13299dSbellard        volatile uint32_t i=0x01234567;
11227d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
11237d13299dSbellard}
11247d13299dSbellardEOF
11257d13299dSbellard
112652166aa0SJuan Quintelaif compile_prog "" "" ; then
11277d13299dSbellard$TMPE && bigendian="yes"
11287d13299dSbellardelse
11297d13299dSbellardecho big/little test failed
11307d13299dSbellardfi
11317d13299dSbellard
11327d13299dSbellardelse
11337d13299dSbellard
11347d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1135ea8f20f8SJuan Quintelacase "$cpu" in
113624e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1137ea8f20f8SJuan Quintela    bigendian=yes
1138ea8f20f8SJuan Quintela  ;;
1139ea8f20f8SJuan Quintelaesac
11407d13299dSbellard
11417d13299dSbellardfi
11427d13299dSbellard
114370be1a2eSPaolo Bonzini# host long bits test, actually a pointer size test
114470be1a2eSPaolo Bonzinicat > $TMPC << EOF
114570be1a2eSPaolo Bonziniint sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
114670be1a2eSPaolo BonziniEOF
114770be1a2eSPaolo Bonziniif compile_object; then
1148ea8f20f8SJuan Quintelahostlongbits=64
114970be1a2eSPaolo Bonzinielse
115070be1a2eSPaolo Bonzinihostlongbits=32
115170be1a2eSPaolo Bonzinifi
1152b6853697Sbellard
1153b0a47e79SJuan Quintela
1154b0a47e79SJuan Quintela##########################################
1155b0a47e79SJuan Quintela# NPTL probe
1156b0a47e79SJuan Quintela
1157b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1158bd0c5661Spbrook  cat > $TMPC <<EOF
1159bd0c5661Spbrook#include <sched.h>
116030813ceaSpbrook#include <linux/futex.h>
1161bd0c5661Spbrookvoid foo()
1162bd0c5661Spbrook{
1163bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1164bd0c5661Spbrook#error bork
1165bd0c5661Spbrook#endif
1166bd0c5661Spbrook}
1167bd0c5661SpbrookEOF
1168bd0c5661Spbrook
116952166aa0SJuan Quintela  if compile_object ; then
1170b0a47e79SJuan Quintela    nptl=yes
1171bd0c5661Spbrook  else
1172b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1173b0a47e79SJuan Quintela      feature_not_found "nptl"
1174b0a47e79SJuan Quintela    fi
1175b0a47e79SJuan Quintela    nptl=no
1176b0a47e79SJuan Quintela  fi
1177bd0c5661Spbrookfi
1178bd0c5661Spbrook
117911d9f695Sbellard##########################################
1180ac62922eSbalrog# zlib check
1181ac62922eSbalrog
1182ac62922eSbalrogcat > $TMPC << EOF
1183ac62922eSbalrog#include <zlib.h>
1184ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1185ac62922eSbalrogEOF
118652166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
1187ac62922eSbalrog    :
1188ac62922eSbalrogelse
1189ac62922eSbalrog    echo
1190ac62922eSbalrog    echo "Error: zlib check failed"
1191ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
1192ac62922eSbalrog    echo
1193ac62922eSbalrog    exit 1
1194ac62922eSbalrogfi
1195ac62922eSbalrog
1196ac62922eSbalrog##########################################
1197e37630caSaliguori# xen probe
1198e37630caSaliguori
1199fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1200b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1201d5b93ddfSAnthony PERARD
1202d5b93ddfSAnthony PERARD  # Xen unstable
1203e37630caSaliguori  cat > $TMPC <<EOF
1204e37630caSaliguori#include <xenctrl.h>
1205e37630caSaliguori#include <xs.h>
1206d5b93ddfSAnthony PERARD#include <stdint.h>
1207d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1208d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1209d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1210d5b93ddfSAnthony PERARD#endif
1211d5b93ddfSAnthony PERARDint main(void) {
1212d5b93ddfSAnthony PERARD  xc_interface *xc;
1213d5b93ddfSAnthony PERARD  xs_daemon_open();
1214d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1215d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1216d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1217b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1218d5b93ddfSAnthony PERARD  return 0;
1219d5b93ddfSAnthony PERARD}
1220e37630caSaliguoriEOF
122152166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1222d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1223fc321b4bSJuan Quintela    xen=yes
1224d5b93ddfSAnthony PERARD
1225d5b93ddfSAnthony PERARD  # Xen 4.0.0
1226d5b93ddfSAnthony PERARD  elif (
1227d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1228d5b93ddfSAnthony PERARD#include <xenctrl.h>
1229d5b93ddfSAnthony PERARD#include <xs.h>
1230d5b93ddfSAnthony PERARD#include <stdint.h>
1231d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1232d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1233d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1234d5b93ddfSAnthony PERARD#endif
1235d5b93ddfSAnthony PERARDint main(void) {
1236b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1237b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1238b87de24eSAnthony PERARD  };
1239d5b93ddfSAnthony PERARD  xs_daemon_open();
1240d5b93ddfSAnthony PERARD  xc_interface_open();
1241d5b93ddfSAnthony PERARD  xc_gnttab_open();
1242d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1243b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1244d5b93ddfSAnthony PERARD  return 0;
1245d5b93ddfSAnthony PERARD}
1246d5b93ddfSAnthony PERARDEOF
1247d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1248d5b93ddfSAnthony PERARD    ) ; then
1249d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1250d5b93ddfSAnthony PERARD    xen=yes
1251d5b93ddfSAnthony PERARD
1252b87de24eSAnthony PERARD  # Xen 3.4.0
1253b87de24eSAnthony PERARD  elif (
1254b87de24eSAnthony PERARD      cat > $TMPC <<EOF
1255b87de24eSAnthony PERARD#include <xenctrl.h>
1256b87de24eSAnthony PERARD#include <xs.h>
1257b87de24eSAnthony PERARDint main(void) {
1258b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1259b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1260b87de24eSAnthony PERARD  };
1261b87de24eSAnthony PERARD  xs_daemon_open();
1262b87de24eSAnthony PERARD  xc_interface_open();
1263b87de24eSAnthony PERARD  xc_gnttab_open();
1264b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1265b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1266b87de24eSAnthony PERARD  return 0;
1267b87de24eSAnthony PERARD}
1268b87de24eSAnthony PERARDEOF
1269b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
1270b87de24eSAnthony PERARD    ) ; then
1271b87de24eSAnthony PERARD    xen_ctrl_version=340
1272b87de24eSAnthony PERARD    xen=yes
1273b87de24eSAnthony PERARD
1274b87de24eSAnthony PERARD  # Xen 3.3.0
1275d5b93ddfSAnthony PERARD  elif (
1276d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1277d5b93ddfSAnthony PERARD#include <xenctrl.h>
1278d5b93ddfSAnthony PERARD#include <xs.h>
1279d5b93ddfSAnthony PERARDint main(void) {
1280d5b93ddfSAnthony PERARD  xs_daemon_open();
1281d5b93ddfSAnthony PERARD  xc_interface_open();
1282d5b93ddfSAnthony PERARD  xc_gnttab_open();
1283d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1284d5b93ddfSAnthony PERARD  return 0;
1285d5b93ddfSAnthony PERARD}
1286d5b93ddfSAnthony PERARDEOF
1287d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1288d5b93ddfSAnthony PERARD    ) ; then
1289d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1290d5b93ddfSAnthony PERARD    xen=yes
1291d5b93ddfSAnthony PERARD
1292d5b93ddfSAnthony PERARD  # Xen not found or unsupported
1293e37630caSaliguori  else
1294fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1295fc321b4bSJuan Quintela      feature_not_found "xen"
1296fc321b4bSJuan Quintela    fi
1297fc321b4bSJuan Quintela    xen=no
1298e37630caSaliguori  fi
1299d5b93ddfSAnthony PERARD
1300d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1301d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1302d5b93ddfSAnthony PERARD  fi
1303e37630caSaliguorifi
1304e37630caSaliguori
1305e37630caSaliguori##########################################
1306a8bd70adSPaolo Bonzini# pkg-config probe
1307f91672e5SPaolo Bonzini
1308a8bd70adSPaolo Bonziniif ! has $pkg_config; then
130908421541SPaolo Bonzini  echo warning: proceeding without "$pkg_config" >&2
131008421541SPaolo Bonzini  pkg_config=/bin/false
1311f91672e5SPaolo Bonzinifi
1312f91672e5SPaolo Bonzini
1313f91672e5SPaolo Bonzini##########################################
131444dc0ca3SAlon Levy# libtool probe
131544dc0ca3SAlon Levy
131644dc0ca3SAlon Levyif ! has libtool; then
131744dc0ca3SAlon Levy    libtool=
131844dc0ca3SAlon Levyelse
131944dc0ca3SAlon Levy    libtool=libtool
132044dc0ca3SAlon Levyfi
132144dc0ca3SAlon Levy
132244dc0ca3SAlon Levy##########################################
1323dfffc653SJuan Quintela# Sparse probe
1324dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
13250dba6195SLoïc Minier  if has cgcc; then
1326dfffc653SJuan Quintela    sparse=yes
1327dfffc653SJuan Quintela  else
1328dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1329dfffc653SJuan Quintela      feature_not_found "sparse"
1330dfffc653SJuan Quintela    fi
1331dfffc653SJuan Quintela    sparse=no
1332dfffc653SJuan Quintela  fi
1333dfffc653SJuan Quintelafi
1334dfffc653SJuan Quintela
1335dfffc653SJuan Quintela##########################################
133611d9f695Sbellard# SDL probe
133711d9f695Sbellard
13383ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
13393ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
13403ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
13413ec87ffeSPaolo Bonzini  sdl_config=sdl-config
13423ec87ffeSPaolo Bonzinifi
13433ec87ffeSPaolo Bonzini
13443ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1345a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1346fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
13473ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
13483ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
13499316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1350a0dfd8a4SLoïc Minierelse
1351a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1352a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1353a0dfd8a4SLoïc Minier  fi
1354a0dfd8a4SLoïc Minier  sdl=no
13559316f803SPaolo Bonzinifi
135629e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
13573ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
13583ec87ffeSPaolo Bonzinifi
135911d9f695Sbellard
13609316f803SPaolo Bonzinisdl_too_old=no
1361c4198157SJuan Quintelaif test "$sdl" != "no" ; then
136211d9f695Sbellard  cat > $TMPC << EOF
136311d9f695Sbellard#include <SDL.h>
136411d9f695Sbellard#undef main /* We don't want SDL to override our main() */
136511d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
136611d9f695SbellardEOF
13679316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
136874f42e18STeLeMan  if test "$static" = "yes" ; then
136974f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
137074f42e18STeLeMan  else
13719316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
137274f42e18STeLeMan  fi
137352166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
137411d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
137511d9f695Sbellard      sdl_too_old=yes
137611d9f695Sbellard    else
1377fd677642Sths      if test "$cocoa" = "no" ; then
137811d9f695Sbellard        sdl=yes
137911d9f695Sbellard      fi
1380fd677642Sths    fi
13817c1f25b4Sbellard
138267c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
13831ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
138467c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1385f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1386f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
138711d9f695Sbellard      fi
138852166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
13891ac88f28SJuan Quintela	:
13901ac88f28SJuan Quintela      else
13911ac88f28SJuan Quintela        sdl=no
13927c1f25b4Sbellard      fi
13937c1f25b4Sbellard    fi # static link
1394c4198157SJuan Quintela  else # sdl not found
1395c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1396c4198157SJuan Quintela      feature_not_found "sdl"
1397c4198157SJuan Quintela    fi
1398c4198157SJuan Quintela    sdl=no
13997c1f25b4Sbellard  fi # sdl compile test
1400fd677642Sthsfi
140111d9f695Sbellard
14025368a422Saliguoriif test "$sdl" = "yes" ; then
14035368a422Saliguori  cat > $TMPC <<EOF
14045368a422Saliguori#include <SDL.h>
14055368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
14065368a422Saliguori#include <X11/XKBlib.h>
14075368a422Saliguori#else
14085368a422Saliguori#error No x11 support
14095368a422Saliguori#endif
14105368a422Saliguoriint main(void) { return 0; }
14115368a422SaliguoriEOF
141252166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1413681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
14145368a422Saliguori  fi
141507d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
141607d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
141707d9ac44SJuan Quintela  fi
14180705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
14195368a422Saliguorifi
14205368a422Saliguori
14218f28f3fbSths##########################################
14228d5d2d4cSths# VNC TLS detection
1423821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1424ae6b5e5aSaliguori  cat > $TMPC <<EOF
1425ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1426ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1427ae6b5e5aSaliguoriEOF
1428a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1429a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
143052166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
14311be10ad2SJuan Quintela    vnc_tls=yes
1432a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1433ae6b5e5aSaliguori  else
14341be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
14351be10ad2SJuan Quintela      feature_not_found "vnc-tls"
14361be10ad2SJuan Quintela    fi
14371be10ad2SJuan Quintela    vnc_tls=no
14388d5d2d4cSths  fi
14398d5d2d4cSthsfi
14408d5d2d4cSths
14418d5d2d4cSths##########################################
14422f9606b3Saliguori# VNC SASL detection
1443821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
14442f9606b3Saliguori  cat > $TMPC <<EOF
14452f9606b3Saliguori#include <sasl/sasl.h>
14462f9606b3Saliguori#include <stdio.h>
14472f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
14482f9606b3SaliguoriEOF
14492f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
14502f9606b3Saliguori  vnc_sasl_cflags=""
14512f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
145252166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1453ea784e3bSJuan Quintela    vnc_sasl=yes
1454fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
14552f9606b3Saliguori  else
1456ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1457ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1458ea784e3bSJuan Quintela    fi
1459ea784e3bSJuan Quintela    vnc_sasl=no
14602f9606b3Saliguori  fi
14612f9606b3Saliguorifi
14622f9606b3Saliguori
14632f9606b3Saliguori##########################################
14642f6f5c7aSCorentin Chary# VNC JPEG detection
1465821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
14662f6f5c7aSCorentin Charycat > $TMPC <<EOF
14672f6f5c7aSCorentin Chary#include <stdio.h>
14682f6f5c7aSCorentin Chary#include <jpeglib.h>
14692f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
14702f6f5c7aSCorentin CharyEOF
14712f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
14722f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
14732f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
14742f6f5c7aSCorentin Chary    vnc_jpeg=yes
14752f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
14762f6f5c7aSCorentin Chary  else
14772f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
14782f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
14792f6f5c7aSCorentin Chary    fi
14802f6f5c7aSCorentin Chary    vnc_jpeg=no
14812f6f5c7aSCorentin Chary  fi
14822f6f5c7aSCorentin Charyfi
14832f6f5c7aSCorentin Chary
14842f6f5c7aSCorentin Chary##########################################
1485efe556adSCorentin Chary# VNC PNG detection
1486821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1487efe556adSCorentin Charycat > $TMPC <<EOF
1488efe556adSCorentin Chary//#include <stdio.h>
1489efe556adSCorentin Chary#include <png.h>
1490832ce9c2SScott Wood#include <stddef.h>
1491efe556adSCorentin Charyint main(void) {
1492efe556adSCorentin Chary    png_structp png_ptr;
1493efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1494efe556adSCorentin Chary    return 0;
1495efe556adSCorentin Chary}
1496efe556adSCorentin CharyEOF
1497efe556adSCorentin Chary    vnc_png_cflags=""
1498efe556adSCorentin Chary    vnc_png_libs="-lpng"
1499efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1500efe556adSCorentin Chary    vnc_png=yes
1501efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
1502efe556adSCorentin Chary  else
1503efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1504efe556adSCorentin Chary      feature_not_found "vnc-png"
1505efe556adSCorentin Chary    fi
1506efe556adSCorentin Chary    vnc_png=no
1507efe556adSCorentin Chary  fi
1508efe556adSCorentin Charyfi
1509efe556adSCorentin Chary
1510efe556adSCorentin Chary##########################################
151176655d6dSaliguori# fnmatch() probe, used for ACL routines
151276655d6dSaliguorifnmatch="no"
151376655d6dSaliguoricat > $TMPC << EOF
151476655d6dSaliguori#include <fnmatch.h>
151576655d6dSaliguoriint main(void)
151676655d6dSaliguori{
151776655d6dSaliguori    fnmatch("foo", "foo", 0);
151876655d6dSaliguori    return 0;
151976655d6dSaliguori}
152076655d6dSaliguoriEOF
152152166aa0SJuan Quintelaif compile_prog "" "" ; then
152276655d6dSaliguori   fnmatch="yes"
152376655d6dSaliguorifi
152476655d6dSaliguori
152576655d6dSaliguori##########################################
1526ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1527ee682d27SStefan Weilif test "$uuid" != "no" ; then
1528ee682d27SStefan Weil  uuid_libs="-luuid"
1529ee682d27SStefan Weil  cat > $TMPC << EOF
1530ee682d27SStefan Weil#include <uuid/uuid.h>
1531ee682d27SStefan Weilint main(void)
1532ee682d27SStefan Weil{
1533ee682d27SStefan Weil    uuid_t my_uuid;
1534ee682d27SStefan Weil    uuid_generate(my_uuid);
1535ee682d27SStefan Weil    return 0;
1536ee682d27SStefan Weil}
1537ee682d27SStefan WeilEOF
1538ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1539ee682d27SStefan Weil    uuid="yes"
1540ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1541ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1542ee682d27SStefan Weil  else
1543ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1544ee682d27SStefan Weil      feature_not_found "uuid"
1545ee682d27SStefan Weil    fi
1546ee682d27SStefan Weil    uuid=no
1547ee682d27SStefan Weil  fi
1548ee682d27SStefan Weilfi
1549ee682d27SStefan Weil
1550ee682d27SStefan Weil##########################################
1551dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1552dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1553dce512deSChristoph Hellwig  cat > $TMPC << EOF
1554dce512deSChristoph Hellwig#include <xfs/xfs.h>
1555dce512deSChristoph Hellwigint main(void)
1556dce512deSChristoph Hellwig{
1557dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1558dce512deSChristoph Hellwig    return 0;
1559dce512deSChristoph Hellwig}
1560dce512deSChristoph HellwigEOF
1561dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1562dce512deSChristoph Hellwig    xfs="yes"
1563dce512deSChristoph Hellwig  else
1564dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1565dce512deSChristoph Hellwig      feature_not_found "xfs"
1566dce512deSChristoph Hellwig    fi
1567dce512deSChristoph Hellwig    xfs=no
1568dce512deSChristoph Hellwig  fi
1569dce512deSChristoph Hellwigfi
1570dce512deSChristoph Hellwig
1571dce512deSChristoph Hellwig##########################################
15728a16d273Sths# vde libraries probe
1573dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
15744baae0acSJuan Quintela  vde_libs="-lvdeplug"
15758a16d273Sths  cat > $TMPC << EOF
15768a16d273Sths#include <libvdeplug.h>
15774a7f0e06Spbrookint main(void)
15784a7f0e06Spbrook{
15794a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
15804a7f0e06Spbrook    vde_open("", "", &a);
15814a7f0e06Spbrook    return 0;
15824a7f0e06Spbrook}
15838a16d273SthsEOF
158452166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
15854baae0acSJuan Quintela    vde=yes
15868e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
15878e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1588dfb278bdSJuan Quintela  else
1589dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1590dfb278bdSJuan Quintela      feature_not_found "vde"
1591dfb278bdSJuan Quintela    fi
1592dfb278bdSJuan Quintela    vde=no
15938a16d273Sths  fi
15948a16d273Sthsfi
15958a16d273Sths
15968a16d273Sths##########################################
1597c2de5c91Smalc# Sound support libraries probe
15988f28f3fbSths
1599c2de5c91Smalcaudio_drv_probe()
1600c2de5c91Smalc{
1601c2de5c91Smalc    drv=$1
1602c2de5c91Smalc    hdr=$2
1603c2de5c91Smalc    lib=$3
1604c2de5c91Smalc    exp=$4
1605c2de5c91Smalc    cfl=$5
16068f28f3fbSths        cat > $TMPC << EOF
1607c2de5c91Smalc#include <$hdr>
1608c2de5c91Smalcint main(void) { $exp }
16098f28f3fbSthsEOF
161052166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
16118f28f3fbSths        :
16128f28f3fbSths    else
16138f28f3fbSths        echo
1614c2de5c91Smalc        echo "Error: $drv check failed"
1615c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
16168f28f3fbSths        echo
16178f28f3fbSths        exit 1
16188f28f3fbSths    fi
1619c2de5c91Smalc}
1620c2de5c91Smalc
16212fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1622c2de5c91Smalcfor drv in $audio_drv_list; do
1623c2de5c91Smalc    case $drv in
1624c2de5c91Smalc    alsa)
1625c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1626c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1627a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1628c2de5c91Smalc    ;;
1629c2de5c91Smalc
1630c2de5c91Smalc    fmod)
1631c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1632c2de5c91Smalc        echo
1633c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1634c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1635c2de5c91Smalc        echo
1636c2de5c91Smalc        exit 1
16378f28f3fbSths    fi
1638c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1639a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1640c2de5c91Smalc    ;;
1641c2de5c91Smalc
1642c2de5c91Smalc    esd)
1643c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1644a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
164567f86e8eSJuan Quintela    audio_pt_int="yes"
1646c2de5c91Smalc    ;;
1647b8e59f18Smalc
1648b8e59f18Smalc    pa)
1649493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
165020fa53ecSMarc-Antoine Perennou        "pa_simple *s = 0; pa_simple_free(s); return 0;"
1651493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
165267f86e8eSJuan Quintela    audio_pt_int="yes"
1653b8e59f18Smalc    ;;
1654b8e59f18Smalc
1655997e690aSJuan Quintela    coreaudio)
1656997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1657997e690aSJuan Quintela    ;;
1658997e690aSJuan Quintela
1659a4bf6780SJuan Quintela    dsound)
1660a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1661d5631638Smalc      audio_win_int="yes"
1662a4bf6780SJuan Quintela    ;;
1663a4bf6780SJuan Quintela
1664a4bf6780SJuan Quintela    oss)
1665a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1666a4bf6780SJuan Quintela    ;;
1667a4bf6780SJuan Quintela
1668a4bf6780SJuan Quintela    sdl|wav)
16692f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
16702f6a1ab0Sblueswir1    ;;
16712f6a1ab0Sblueswir1
1672d5631638Smalc    winwave)
1673d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1674d5631638Smalc      audio_win_int="yes"
1675d5631638Smalc    ;;
1676d5631638Smalc
1677e4c63a6aSmalc    *)
16781c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1679e4c63a6aSmalc        echo
1680e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1681e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1682e4c63a6aSmalc        echo
1683e4c63a6aSmalc        exit 1
1684e4c63a6aSmalc    }
1685e4c63a6aSmalc    ;;
1686c2de5c91Smalc    esac
1687c2de5c91Smalcdone
16888f28f3fbSths
16894d3b6f6eSbalrog##########################################
16902e4d9fb1Saurel32# BrlAPI probe
16912e4d9fb1Saurel32
16924ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1693eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
16942e4d9fb1Saurel32  cat > $TMPC << EOF
16952e4d9fb1Saurel32#include <brlapi.h>
1696832ce9c2SScott Wood#include <stddef.h>
16972e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
16982e4d9fb1Saurel32EOF
169952166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
17002e4d9fb1Saurel32    brlapi=yes
1701264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
17024ffcedb6SJuan Quintela  else
17034ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
17044ffcedb6SJuan Quintela      feature_not_found "brlapi"
17054ffcedb6SJuan Quintela    fi
17064ffcedb6SJuan Quintela    brlapi=no
1707eb82284fSJuan Quintela  fi
1708eb82284fSJuan Quintelafi
17092e4d9fb1Saurel32
17102e4d9fb1Saurel32##########################################
17114d3b6f6eSbalrog# curses probe
1712e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
1713e095e2f3SStefan Weil    curses_list="-lpdcurses"
1714e095e2f3SStefan Weilelse
17154f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
1716e095e2f3SStefan Weilfi
17174d3b6f6eSbalrog
1718c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1719c584a6d0SJuan Quintela  curses_found=no
17204d3b6f6eSbalrog  cat > $TMPC << EOF
17214d3b6f6eSbalrog#include <curses.h>
17225a8ff3aaSblueswir1#ifdef __OpenBSD__
17235a8ff3aaSblueswir1#define resize_term resizeterm
17245a8ff3aaSblueswir1#endif
17255a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
17264d3b6f6eSbalrogEOF
17274f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
17284f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1729c584a6d0SJuan Quintela      curses_found=yes
17304f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
17314f78ef9aSJuan Quintela      break
17324d3b6f6eSbalrog    fi
17334f78ef9aSJuan Quintela  done
1734c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1735c584a6d0SJuan Quintela    curses=yes
1736c584a6d0SJuan Quintela  else
1737c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1738c584a6d0SJuan Quintela      feature_not_found "curses"
1739c584a6d0SJuan Quintela    fi
1740c584a6d0SJuan Quintela    curses=no
1741c584a6d0SJuan Quintela  fi
17424f78ef9aSJuan Quintelafi
17434d3b6f6eSbalrog
1744414f0dabSblueswir1##########################################
1745769ce76dSAlexander Graf# curl probe
1746769ce76dSAlexander Graf
1747a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
1748a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
17494e2b0658SPaolo Bonzinielse
17504e2b0658SPaolo Bonzini  curlconfig=curl-config
17514e2b0658SPaolo Bonzinifi
17524e2b0658SPaolo Bonzini
1753788c8196SJuan Quintelaif test "$curl" != "no" ; then
1754769ce76dSAlexander Graf  cat > $TMPC << EOF
1755769ce76dSAlexander Graf#include <curl/curl.h>
17560b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
1757769ce76dSAlexander GrafEOF
17584e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
17594e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1760b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1761769ce76dSAlexander Graf    curl=yes
1762f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1763f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1764788c8196SJuan Quintela  else
1765788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1766788c8196SJuan Quintela      feature_not_found "curl"
1767788c8196SJuan Quintela    fi
1768788c8196SJuan Quintela    curl=no
1769769ce76dSAlexander Graf  fi
1770769ce76dSAlexander Graffi # test "$curl"
1771769ce76dSAlexander Graf
1772769ce76dSAlexander Graf##########################################
17735495ed11SLuiz Capitulino# check framework probe
17745495ed11SLuiz Capitulino
17755495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
17765495ed11SLuiz Capitulino  cat > $TMPC << EOF
17775495ed11SLuiz Capitulino#include <check.h>
17785495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
17795495ed11SLuiz CapitulinoEOF
1780a8bd70adSPaolo Bonzini  check_libs=`$pkg_config --libs check`
17815495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
17825495ed11SLuiz Capitulino    check_utests=yes
17835495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
17845495ed11SLuiz Capitulino  else
17855495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
17865495ed11SLuiz Capitulino      feature_not_found "check"
17875495ed11SLuiz Capitulino    fi
17885495ed11SLuiz Capitulino    check_utests=no
17895495ed11SLuiz Capitulino  fi
17905495ed11SLuiz Capitulinofi # test "$check_utests"
17915495ed11SLuiz Capitulino
17925495ed11SLuiz Capitulino##########################################
1793fb599c9aSbalrog# bluez support probe
1794a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1795e820e3f4Sbalrog  cat > $TMPC << EOF
1796e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1797e820e3f4Sbalrogint main(void) { return bt_error(0); }
1798e820e3f4SbalrogEOF
1799a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1800a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
180152166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1802a20a6f46SJuan Quintela    bluez=yes
1803e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1804e820e3f4Sbalrog  else
1805a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1806a20a6f46SJuan Quintela      feature_not_found "bluez"
1807a20a6f46SJuan Quintela    fi
1808e820e3f4Sbalrog    bluez="no"
1809e820e3f4Sbalrog  fi
1810fb599c9aSbalrogfi
1811fb599c9aSbalrog
1812fb599c9aSbalrog##########################################
1813e18df141SAnthony Liguori# glib support probe
1814*1fc7bd4aSAnthony Liguoriif $pkg_config --modversion glib-2.0 > /dev/null 2>&1 ; then
1815*1fc7bd4aSAnthony Liguori    glib_cflags=`$pkg_config --cflags glib-2.0 2>/dev/null`
1816*1fc7bd4aSAnthony Liguori    glib_libs=`$pkg_config --libs glib-2.0 2>/dev/null`
1817e18df141SAnthony Liguori    libs_softmmu="$glib_libs $libs_softmmu"
1818e18df141SAnthony Liguori    libs_tools="$glib_libs $libs_tools"
1819e18df141SAnthony Liguorielse
1820e18df141SAnthony Liguori    echo "glib-2.0 required to compile QEMU"
1821e18df141SAnthony Liguori    exit 1
1822e18df141SAnthony Liguorifi
1823e18df141SAnthony Liguori
1824e18df141SAnthony Liguori##########################################
1825e5d355d1Saliguori# pthread probe
1826de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
18273c529d93Saliguori
1828e5d355d1Saliguoripthread=no
1829414f0dabSblueswir1cat > $TMPC << EOF
18303c529d93Saliguori#include <pthread.h>
1831de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1832414f0dabSblueswir1EOF
1833bd00d539SAndreas Färberif compile_prog "" "" ; then
1834bd00d539SAndreas Färber  pthread=yes
1835bd00d539SAndreas Färberelse
1836de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
183752166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
1838e5d355d1Saliguori      pthread=yes
18395572b539SJuan Quintela      LIBS="$pthread_lib $LIBS"
1840de65fe0fSSebastian Herbszt      break
1841414f0dabSblueswir1    fi
1842de65fe0fSSebastian Herbszt  done
1843bd00d539SAndreas Färberfi
1844414f0dabSblueswir1
18454617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
18464dd75c70SChristoph Hellwig  echo
18474dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
18484dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
18494dd75c70SChristoph Hellwig  echo
18504dd75c70SChristoph Hellwig  exit 1
1851e5d355d1Saliguorifi
1852e5d355d1Saliguori
1853bf9298b9Saliguori##########################################
1854f27aaf4bSChristian Brunner# rbd probe
1855f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
1856f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
1857f27aaf4bSChristian Brunner#include <stdio.h>
1858ad32e9c0SJosh Durgin#include <rbd/librbd.h>
1859f27aaf4bSChristian Brunnerint main(void) {
1860ad32e9c0SJosh Durgin    rados_t cluster;
1861ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
1862f27aaf4bSChristian Brunner    return 0;
1863f27aaf4bSChristian Brunner}
1864f27aaf4bSChristian BrunnerEOF
1865ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
1866f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
1867f27aaf4bSChristian Brunner    rbd=yes
1868f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
1869f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
1870f27aaf4bSChristian Brunner  else
1871f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
1872f27aaf4bSChristian Brunner      feature_not_found "rados block device"
1873f27aaf4bSChristian Brunner    fi
1874f27aaf4bSChristian Brunner    rbd=no
1875f27aaf4bSChristian Brunner  fi
1876f27aaf4bSChristian Brunnerfi
1877f27aaf4bSChristian Brunner
1878f27aaf4bSChristian Brunner##########################################
18795c6c3a6cSChristoph Hellwig# linux-aio probe
18805c6c3a6cSChristoph Hellwig
18815c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
18825c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
18835c6c3a6cSChristoph Hellwig#include <libaio.h>
18845c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
1885832ce9c2SScott Wood#include <stddef.h>
18865c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
18875c6c3a6cSChristoph HellwigEOF
18885c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
18895c6c3a6cSChristoph Hellwig    linux_aio=yes
1890048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1891048d179fSPaul Brook    libs_tools="$libs_tools -laio"
18925c6c3a6cSChristoph Hellwig  else
18935c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
18945c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
18955c6c3a6cSChristoph Hellwig    fi
18963cfcae3cSLuiz Capitulino    linux_aio=no
18975c6c3a6cSChristoph Hellwig  fi
18985c6c3a6cSChristoph Hellwigfi
18995c6c3a6cSChristoph Hellwig
19005c6c3a6cSChristoph Hellwig##########################################
1901758e8e38SVenkateswararao Jujjuri (JV)# attr probe
1902758e8e38SVenkateswararao Jujjuri (JV)
1903758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
1904758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
1905758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
1906758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
1907758e8e38SVenkateswararao Jujjuri (JV)#include <attr/xattr.h>
1908758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1909758e8e38SVenkateswararao Jujjuri (JV)EOF
1910758e8e38SVenkateswararao Jujjuri (JV)  if compile_prog "" "-lattr" ; then
1911758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
1912758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
1913758e8e38SVenkateswararao Jujjuri (JV)  else
1914758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
1915758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
1916758e8e38SVenkateswararao Jujjuri (JV)    fi
1917758e8e38SVenkateswararao Jujjuri (JV)    attr=no
1918758e8e38SVenkateswararao Jujjuri (JV)  fi
1919758e8e38SVenkateswararao Jujjuri (JV)fi
1920758e8e38SVenkateswararao Jujjuri (JV)
1921758e8e38SVenkateswararao Jujjuri (JV)##########################################
1922bf9298b9Saliguori# iovec probe
1923bf9298b9Saliguoricat > $TMPC <<EOF
1924db34f0b3Sblueswir1#include <sys/types.h>
1925bf9298b9Saliguori#include <sys/uio.h>
1926db34f0b3Sblueswir1#include <unistd.h>
1927bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1928bf9298b9SaliguoriEOF
1929bf9298b9Saliguoriiovec=no
193052166aa0SJuan Quintelaif compile_prog "" "" ; then
1931bf9298b9Saliguori  iovec=yes
1932bf9298b9Saliguorifi
1933bf9298b9Saliguori
1934f652e6afSaurel32##########################################
1935ceb42de8Saliguori# preadv probe
1936ceb42de8Saliguoricat > $TMPC <<EOF
1937ceb42de8Saliguori#include <sys/types.h>
1938ceb42de8Saliguori#include <sys/uio.h>
1939ceb42de8Saliguori#include <unistd.h>
1940ceb42de8Saliguoriint main(void) { preadv; }
1941ceb42de8SaliguoriEOF
1942ceb42de8Saliguoripreadv=no
194352166aa0SJuan Quintelaif compile_prog "" "" ; then
1944ceb42de8Saliguori  preadv=yes
1945ceb42de8Saliguorifi
1946ceb42de8Saliguori
1947ceb42de8Saliguori##########################################
1948f652e6afSaurel32# fdt probe
19492df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1950b41af4baSJuan Quintela  fdt_libs="-lfdt"
1951f652e6afSaurel32  cat > $TMPC << EOF
1952f652e6afSaurel32int main(void) { return 0; }
1953f652e6afSaurel32EOF
195452166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1955f652e6afSaurel32    fdt=yes
19562df87df7SJuan Quintela  else
19572df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
19582df87df7SJuan Quintela      feature_not_found "fdt"
19592df87df7SJuan Quintela    fi
1960de3a354aSMichael Walle    fdt_libs=
19612df87df7SJuan Quintela    fdt=no
1962f652e6afSaurel32  fi
1963f652e6afSaurel32fi
1964f652e6afSaurel32
196520ff075bSMichael Walle##########################################
196620ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
196720ff075bSMichael Walleif test "$opengl" != "no" ; then
196820ff075bSMichael Walle  opengl_libs="-lGL"
196920ff075bSMichael Walle  cat > $TMPC << EOF
197020ff075bSMichael Walle#include <X11/Xlib.h>
197120ff075bSMichael Walle#include <GL/gl.h>
197220ff075bSMichael Walle#include <GL/glx.h>
197320ff075bSMichael Walleint main(void) { GL_VERSION; return 0; }
197420ff075bSMichael WalleEOF
197520ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
197620ff075bSMichael Walle    opengl=yes
197720ff075bSMichael Walle  else
197820ff075bSMichael Walle    if test "$opengl" = "yes" ; then
197920ff075bSMichael Walle      feature_not_found "opengl"
198020ff075bSMichael Walle    fi
1981de3a354aSMichael Walle    opengl_libs=
198220ff075bSMichael Walle    opengl=no
198320ff075bSMichael Walle  fi
198420ff075bSMichael Wallefi
198520ff075bSMichael Walle
19863b3f24adSaurel32#
19873b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
19883b3f24adSaurel32# emulator.  This is done because older glibc versions don't
19893b3f24adSaurel32# have syscall stubs for these implemented.
19903b3f24adSaurel32#
19913b3f24adSaurel32atfile=no
19923b3f24adSaurel32cat > $TMPC << EOF
19933b3f24adSaurel32#define _ATFILE_SOURCE
19943b3f24adSaurel32#include <sys/types.h>
19953b3f24adSaurel32#include <fcntl.h>
19963b3f24adSaurel32#include <unistd.h>
19973b3f24adSaurel32
19983b3f24adSaurel32int
19993b3f24adSaurel32main(void)
20003b3f24adSaurel32{
20013b3f24adSaurel32	/* try to unlink nonexisting file */
20023b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
20033b3f24adSaurel32}
20043b3f24adSaurel32EOF
200552166aa0SJuan Quintelaif compile_prog "" "" ; then
20063b3f24adSaurel32  atfile=yes
20073b3f24adSaurel32fi
20083b3f24adSaurel32
200939386ac7Saurel32# Check for inotify functions when we are building linux-user
20103b3f24adSaurel32# emulator.  This is done because older glibc versions don't
20113b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
20123b3f24adSaurel32# don't provide them even if kernel supports them.
20133b3f24adSaurel32#
20143b3f24adSaurel32inotify=no
20153b3f24adSaurel32cat > $TMPC << EOF
20163b3f24adSaurel32#include <sys/inotify.h>
20173b3f24adSaurel32
20183b3f24adSaurel32int
20193b3f24adSaurel32main(void)
20203b3f24adSaurel32{
20213b3f24adSaurel32	/* try to start inotify */
20228690e420Saurel32	return inotify_init();
20233b3f24adSaurel32}
20243b3f24adSaurel32EOF
202552166aa0SJuan Quintelaif compile_prog "" "" ; then
20263b3f24adSaurel32  inotify=yes
20273b3f24adSaurel32fi
20283b3f24adSaurel32
2029c05c7a73SRiku Voipioinotify1=no
2030c05c7a73SRiku Voipiocat > $TMPC << EOF
2031c05c7a73SRiku Voipio#include <sys/inotify.h>
2032c05c7a73SRiku Voipio
2033c05c7a73SRiku Voipioint
2034c05c7a73SRiku Voipiomain(void)
2035c05c7a73SRiku Voipio{
2036c05c7a73SRiku Voipio    /* try to start inotify */
2037c05c7a73SRiku Voipio    return inotify_init1(0);
2038c05c7a73SRiku Voipio}
2039c05c7a73SRiku VoipioEOF
2040c05c7a73SRiku Voipioif compile_prog "" "" ; then
2041c05c7a73SRiku Voipio  inotify1=yes
2042c05c7a73SRiku Voipiofi
2043c05c7a73SRiku Voipio
2044ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2045ebc996f3SRiku Voipioutimens=no
2046ebc996f3SRiku Voipiocat > $TMPC << EOF
2047ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2048ebc996f3SRiku Voipio#include <stddef.h>
2049ebc996f3SRiku Voipio#include <fcntl.h>
2050ebc996f3SRiku Voipio
2051ebc996f3SRiku Voipioint main(void)
2052ebc996f3SRiku Voipio{
2053ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2054ebc996f3SRiku Voipio    futimens(0, NULL);
2055ebc996f3SRiku Voipio    return 0;
2056ebc996f3SRiku Voipio}
2057ebc996f3SRiku VoipioEOF
205852166aa0SJuan Quintelaif compile_prog "" "" ; then
2059ebc996f3SRiku Voipio  utimens=yes
2060ebc996f3SRiku Voipiofi
2061ebc996f3SRiku Voipio
2062099d6b0fSRiku Voipio# check if pipe2 is there
2063099d6b0fSRiku Voipiopipe2=no
2064099d6b0fSRiku Voipiocat > $TMPC << EOF
2065099d6b0fSRiku Voipio#include <unistd.h>
2066099d6b0fSRiku Voipio#include <fcntl.h>
2067099d6b0fSRiku Voipio
2068099d6b0fSRiku Voipioint main(void)
2069099d6b0fSRiku Voipio{
2070099d6b0fSRiku Voipio    int pipefd[2];
2071099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2072099d6b0fSRiku Voipio    return 0;
2073099d6b0fSRiku Voipio}
2074099d6b0fSRiku VoipioEOF
207552166aa0SJuan Quintelaif compile_prog "" "" ; then
2076099d6b0fSRiku Voipio  pipe2=yes
2077099d6b0fSRiku Voipiofi
2078099d6b0fSRiku Voipio
207940ff6d7eSKevin Wolf# check if accept4 is there
208040ff6d7eSKevin Wolfaccept4=no
208140ff6d7eSKevin Wolfcat > $TMPC << EOF
208240ff6d7eSKevin Wolf#include <sys/socket.h>
208340ff6d7eSKevin Wolf#include <stddef.h>
208440ff6d7eSKevin Wolf
208540ff6d7eSKevin Wolfint main(void)
208640ff6d7eSKevin Wolf{
208740ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
208840ff6d7eSKevin Wolf    return 0;
208940ff6d7eSKevin Wolf}
209040ff6d7eSKevin WolfEOF
209140ff6d7eSKevin Wolfif compile_prog "" "" ; then
209240ff6d7eSKevin Wolf  accept4=yes
209340ff6d7eSKevin Wolffi
209440ff6d7eSKevin Wolf
20953ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
20963ce34dfbSvibisreenivasansplice=no
20973ce34dfbSvibisreenivasancat > $TMPC << EOF
20983ce34dfbSvibisreenivasan#include <unistd.h>
20993ce34dfbSvibisreenivasan#include <fcntl.h>
21003ce34dfbSvibisreenivasan#include <limits.h>
21013ce34dfbSvibisreenivasan
21023ce34dfbSvibisreenivasanint main(void)
21033ce34dfbSvibisreenivasan{
21043ce34dfbSvibisreenivasan    int len, fd;
21053ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
21063ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
21073ce34dfbSvibisreenivasan    return 0;
21083ce34dfbSvibisreenivasan}
21093ce34dfbSvibisreenivasanEOF
211052166aa0SJuan Quintelaif compile_prog "" "" ; then
21113ce34dfbSvibisreenivasan  splice=yes
21123ce34dfbSvibisreenivasanfi
21133ce34dfbSvibisreenivasan
2114dcc38d1cSMarcelo Tosatti##########################################
2115dcc38d1cSMarcelo Tosatti# signalfd probe
2116dcc38d1cSMarcelo Tosattisignalfd="no"
2117dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2118dcc38d1cSMarcelo Tosatti#define _GNU_SOURCE
2119dcc38d1cSMarcelo Tosatti#include <unistd.h>
2120dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2121dcc38d1cSMarcelo Tosatti#include <signal.h>
2122dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2123dcc38d1cSMarcelo TosattiEOF
2124dcc38d1cSMarcelo Tosatti
2125dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2126dcc38d1cSMarcelo Tosatti  signalfd=yes
2127de758970SJan Kiszkaelif test "$kvm" = "yes" -a "$io_thread" != "yes"; then
2128de758970SJan Kiszka  echo
2129de758970SJan Kiszka  echo "ERROR: Host kernel lacks signalfd() support,"
2130de758970SJan Kiszka  echo "but KVM depends on it when the IO thread is disabled."
2131de758970SJan Kiszka  echo
2132de758970SJan Kiszka  exit 1
2133dcc38d1cSMarcelo Tosattifi
2134dcc38d1cSMarcelo Tosatti
2135c2882b96SRiku Voipio# check if eventfd is supported
2136c2882b96SRiku Voipioeventfd=no
2137c2882b96SRiku Voipiocat > $TMPC << EOF
2138c2882b96SRiku Voipio#include <sys/eventfd.h>
2139c2882b96SRiku Voipio
2140c2882b96SRiku Voipioint main(void)
2141c2882b96SRiku Voipio{
2142c2882b96SRiku Voipio    int efd = eventfd(0, 0);
2143c2882b96SRiku Voipio    return 0;
2144c2882b96SRiku Voipio}
2145c2882b96SRiku VoipioEOF
2146c2882b96SRiku Voipioif compile_prog "" "" ; then
2147c2882b96SRiku Voipio  eventfd=yes
2148c2882b96SRiku Voipiofi
2149c2882b96SRiku Voipio
2150d0927938SUlrich Hecht# check for fallocate
2151d0927938SUlrich Hechtfallocate=no
2152d0927938SUlrich Hechtcat > $TMPC << EOF
2153d0927938SUlrich Hecht#include <fcntl.h>
2154d0927938SUlrich Hecht
2155d0927938SUlrich Hechtint main(void)
2156d0927938SUlrich Hecht{
2157d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2158d0927938SUlrich Hecht    return 0;
2159d0927938SUlrich Hecht}
2160d0927938SUlrich HechtEOF
2161be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
2162d0927938SUlrich Hecht  fallocate=yes
2163d0927938SUlrich Hechtfi
2164d0927938SUlrich Hecht
2165c727f47dSPeter Maydell# check for sync_file_range
2166c727f47dSPeter Maydellsync_file_range=no
2167c727f47dSPeter Maydellcat > $TMPC << EOF
2168c727f47dSPeter Maydell#include <fcntl.h>
2169c727f47dSPeter Maydell
2170c727f47dSPeter Maydellint main(void)
2171c727f47dSPeter Maydell{
2172c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2173c727f47dSPeter Maydell    return 0;
2174c727f47dSPeter Maydell}
2175c727f47dSPeter MaydellEOF
2176c727f47dSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2177c727f47dSPeter Maydell  sync_file_range=yes
2178c727f47dSPeter Maydellfi
2179c727f47dSPeter Maydell
2180dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2181dace20dcSPeter Maydellfiemap=no
2182dace20dcSPeter Maydellcat > $TMPC << EOF
2183dace20dcSPeter Maydell#include <sys/ioctl.h>
2184dace20dcSPeter Maydell#include <linux/fs.h>
2185dace20dcSPeter Maydell#include <linux/fiemap.h>
2186dace20dcSPeter Maydell
2187dace20dcSPeter Maydellint main(void)
2188dace20dcSPeter Maydell{
2189dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2190dace20dcSPeter Maydell    return 0;
2191dace20dcSPeter Maydell}
2192dace20dcSPeter MaydellEOF
2193dace20dcSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2194dace20dcSPeter Maydell  fiemap=yes
2195dace20dcSPeter Maydellfi
2196dace20dcSPeter Maydell
2197d0927938SUlrich Hecht# check for dup3
2198d0927938SUlrich Hechtdup3=no
2199d0927938SUlrich Hechtcat > $TMPC << EOF
2200d0927938SUlrich Hecht#include <unistd.h>
2201d0927938SUlrich Hecht
2202d0927938SUlrich Hechtint main(void)
2203d0927938SUlrich Hecht{
2204d0927938SUlrich Hecht    dup3(0, 0, 0);
2205d0927938SUlrich Hecht    return 0;
2206d0927938SUlrich Hecht}
2207d0927938SUlrich HechtEOF
220878f5d726SJan Kiszkaif compile_prog "" "" ; then
2209d0927938SUlrich Hecht  dup3=yes
2210d0927938SUlrich Hechtfi
2211d0927938SUlrich Hecht
22123b6edd16SPeter Maydell# check for epoll support
22133b6edd16SPeter Maydellepoll=no
22143b6edd16SPeter Maydellcat > $TMPC << EOF
22153b6edd16SPeter Maydell#include <sys/epoll.h>
22163b6edd16SPeter Maydell
22173b6edd16SPeter Maydellint main(void)
22183b6edd16SPeter Maydell{
22193b6edd16SPeter Maydell    epoll_create(0);
22203b6edd16SPeter Maydell    return 0;
22213b6edd16SPeter Maydell}
22223b6edd16SPeter MaydellEOF
22233b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
22243b6edd16SPeter Maydell  epoll=yes
22253b6edd16SPeter Maydellfi
22263b6edd16SPeter Maydell
22273b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
22283b6edd16SPeter Maydell# so we must check separately for their presence
22293b6edd16SPeter Maydellepoll_create1=no
22303b6edd16SPeter Maydellcat > $TMPC << EOF
22313b6edd16SPeter Maydell#include <sys/epoll.h>
22323b6edd16SPeter Maydell
22333b6edd16SPeter Maydellint main(void)
22343b6edd16SPeter Maydell{
223519e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
223619e83f6bSPeter Maydell     * a function being called. This is necessary so that on
223719e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
223819e83f6bSPeter Maydell     * the library but not declared in the header file we will
223919e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
224019e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
224119e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
224219e83f6bSPeter Maydell     */
224319e83f6bSPeter Maydell    epoll_create1;
22443b6edd16SPeter Maydell    return 0;
22453b6edd16SPeter Maydell}
22463b6edd16SPeter MaydellEOF
22473b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
22483b6edd16SPeter Maydell  epoll_create1=yes
22493b6edd16SPeter Maydellfi
22503b6edd16SPeter Maydell
22513b6edd16SPeter Maydellepoll_pwait=no
22523b6edd16SPeter Maydellcat > $TMPC << EOF
22533b6edd16SPeter Maydell#include <sys/epoll.h>
22543b6edd16SPeter Maydell
22553b6edd16SPeter Maydellint main(void)
22563b6edd16SPeter Maydell{
22573b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
22583b6edd16SPeter Maydell    return 0;
22593b6edd16SPeter Maydell}
22603b6edd16SPeter MaydellEOF
22613b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
22623b6edd16SPeter Maydell  epoll_pwait=yes
22633b6edd16SPeter Maydellfi
22643b6edd16SPeter Maydell
2265cc8ae6deSpbrook# Check if tools are available to build documentation.
2266a25dba17SJuan Quintelaif test "$docs" != "no" ; then
226701668d98SStefan Weil  if has makeinfo && has pod2man; then
2268a25dba17SJuan Quintela    docs=yes
226983a3ab8bSJuan Quintela  else
2270a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2271a25dba17SJuan Quintela      feature_not_found "docs"
227283a3ab8bSJuan Quintela    fi
2273a25dba17SJuan Quintela    docs=no
227483a3ab8bSJuan Quintela  fi
2275cc8ae6deSpbrookfi
2276cc8ae6deSpbrook
2277f514f41cSStefan Weil# Search for bswap_32 function
22786ae9a1f4SJuan Quintelabyteswap_h=no
22796ae9a1f4SJuan Quintelacat > $TMPC << EOF
22806ae9a1f4SJuan Quintela#include <byteswap.h>
22816ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
22826ae9a1f4SJuan QuintelaEOF
228352166aa0SJuan Quintelaif compile_prog "" "" ; then
22846ae9a1f4SJuan Quintela  byteswap_h=yes
22856ae9a1f4SJuan Quintelafi
22866ae9a1f4SJuan Quintela
2287f514f41cSStefan Weil# Search for bswap_32 function
22886ae9a1f4SJuan Quintelabswap_h=no
22896ae9a1f4SJuan Quintelacat > $TMPC << EOF
22906ae9a1f4SJuan Quintela#include <sys/endian.h>
22916ae9a1f4SJuan Quintela#include <sys/types.h>
22926ae9a1f4SJuan Quintela#include <machine/bswap.h>
22936ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
22946ae9a1f4SJuan QuintelaEOF
229552166aa0SJuan Quintelaif compile_prog "" "" ; then
22966ae9a1f4SJuan Quintela  bswap_h=yes
22976ae9a1f4SJuan Quintelafi
22986ae9a1f4SJuan Quintela
2299da93a1fdSaliguori##########################################
2300da93a1fdSaliguori# Do we need librt
2301da93a1fdSaliguoricat > $TMPC <<EOF
2302da93a1fdSaliguori#include <signal.h>
2303da93a1fdSaliguori#include <time.h>
2304da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
2305da93a1fdSaliguoriEOF
2306da93a1fdSaliguori
230752166aa0SJuan Quintelaif compile_prog "" "" ; then
230807ffa4bdSJuan Quintela  :
230952166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
231007ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2311da93a1fdSaliguorifi
2312da93a1fdSaliguori
231331ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2314179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
23156362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
23166362a53fSJuan Quintelafi
23176362a53fSJuan Quintela
2318de5071c5SBlue Swirl##########################################
2319de5071c5SBlue Swirl# check if the compiler defines offsetof
2320de5071c5SBlue Swirl
2321de5071c5SBlue Swirlneed_offsetof=yes
2322de5071c5SBlue Swirlcat > $TMPC << EOF
2323de5071c5SBlue Swirl#include <stddef.h>
2324de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
2325de5071c5SBlue SwirlEOF
2326de5071c5SBlue Swirlif compile_prog "" "" ; then
2327de5071c5SBlue Swirl    need_offsetof=no
2328de5071c5SBlue Swirlfi
2329de5071c5SBlue Swirl
23305f6b9e8fSBlue Swirl##########################################
2331747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
2332747bbdf7SBlue Swirl#
2333747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
2334747bbdf7SBlue Swirl# about attribute warn_unused_result
2335747bbdf7SBlue Swirl
2336747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
2337747bbdf7SBlue Swirlcat > $TMPC << EOF
2338747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2339747bbdf7SBlue Swirl#error gcc 3.3 or older
2340747bbdf7SBlue Swirl#endif
2341747bbdf7SBlue Swirlint main(void) { return 0;}
2342747bbdf7SBlue SwirlEOF
2343747bbdf7SBlue Swirlif compile_prog "" ""; then
2344747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
2345747bbdf7SBlue Swirlfi
2346747bbdf7SBlue Swirl
2347cd4ec0b4SGerd Hoffmann# spice probe
2348cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2349cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2350cd4ec0b4SGerd Hoffmann#include <spice.h>
2351cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2352cd4ec0b4SGerd HoffmannEOF
2353710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2354710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2355012b80d3SGerd Hoffmann  if $pkg_config --atleast-version=0.6.0 spice-server >/dev/null 2>&1 && \
2356cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2357cd4ec0b4SGerd Hoffmann    spice="yes"
2358cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2359cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2360cd4ec0b4SGerd Hoffmann  else
2361cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2362cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2363cd4ec0b4SGerd Hoffmann    fi
2364cd4ec0b4SGerd Hoffmann    spice="no"
2365cd4ec0b4SGerd Hoffmann  fi
2366cd4ec0b4SGerd Hoffmannfi
2367cd4ec0b4SGerd Hoffmann
2368111a38b0SRobert Relyea# check for libcacard for smartcard support
2369111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2370111a38b0SRobert Relyea    smartcard="yes"
2371111a38b0SRobert Relyea    smartcard_cflags=""
2372111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2373111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
2374111a38b0SRobert Relyea        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then
2375111a38b0SRobert Relyea            smartcard_nss="yes"
2376111a38b0SRobert Relyea            smartcard_cflags="-I\$(SRC_PATH)/libcacard"
2377111a38b0SRobert Relyea            libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
2378111a38b0SRobert Relyea            libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
2379111a38b0SRobert Relyea            QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
2380111a38b0SRobert Relyea            LIBS="$libcacard_libs $LIBS"
2381111a38b0SRobert Relyea        else
2382111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2383111a38b0SRobert Relyea                feature_not_found "nss"
2384111a38b0SRobert Relyea            fi
2385111a38b0SRobert Relyea            smartcard_nss="no"
2386111a38b0SRobert Relyea        fi
2387111a38b0SRobert Relyea    fi
2388111a38b0SRobert Relyeafi
2389111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2390111a38b0SRobert Relyea    smartcard_nss="no"
2391111a38b0SRobert Relyeafi
2392111a38b0SRobert Relyea
239369354a83SHans de Goede# check for usbredirparser for usb network redirection support
239469354a83SHans de Goedeif test "$usb_redir" != "no" ; then
239569354a83SHans de Goede    if $pkg_config libusbredirparser >/dev/null 2>&1 ; then
239669354a83SHans de Goede        usb_redir="yes"
239769354a83SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
239869354a83SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
239969354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
240069354a83SHans de Goede        LIBS="$LIBS $usb_redir_libs"
240169354a83SHans de Goede    else
240269354a83SHans de Goede        if test "$usb_redir" = "yes"; then
240369354a83SHans de Goede            feature_not_found "usb-redir"
240469354a83SHans de Goede        fi
240569354a83SHans de Goede        usb_redir="no"
240669354a83SHans de Goede    fi
240769354a83SHans de Goedefi
240869354a83SHans de Goede
2409cd4ec0b4SGerd Hoffmann##########################################
2410cd4ec0b4SGerd Hoffmann
2411747bbdf7SBlue Swirl##########################################
24125f6b9e8fSBlue Swirl# check if we have fdatasync
24135f6b9e8fSBlue Swirl
24145f6b9e8fSBlue Swirlfdatasync=no
24155f6b9e8fSBlue Swirlcat > $TMPC << EOF
24165f6b9e8fSBlue Swirl#include <unistd.h>
2417d1722a27SAlexandre Raymondint main(void) {
2418d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2419d1722a27SAlexandre Raymondreturn fdatasync(0);
2420d1722a27SAlexandre Raymond#else
2421d1722a27SAlexandre Raymond#abort Not supported
2422d1722a27SAlexandre Raymond#endif
2423d1722a27SAlexandre Raymond}
24245f6b9e8fSBlue SwirlEOF
24255f6b9e8fSBlue Swirlif compile_prog "" "" ; then
24265f6b9e8fSBlue Swirl    fdatasync=yes
24275f6b9e8fSBlue Swirlfi
24285f6b9e8fSBlue Swirl
242994a420b1SStefan Hajnoczi##########################################
2430e78815a5SAndreas Färber# check if we have madvise
2431e78815a5SAndreas Färber
2432e78815a5SAndreas Färbermadvise=no
2433e78815a5SAndreas Färbercat > $TMPC << EOF
2434e78815a5SAndreas Färber#include <sys/types.h>
2435e78815a5SAndreas Färber#include <sys/mman.h>
2436832ce9c2SScott Wood#include <stddef.h>
2437e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2438e78815a5SAndreas FärberEOF
2439e78815a5SAndreas Färberif compile_prog "" "" ; then
2440e78815a5SAndreas Färber    madvise=yes
2441e78815a5SAndreas Färberfi
2442e78815a5SAndreas Färber
2443e78815a5SAndreas Färber##########################################
2444e78815a5SAndreas Färber# check if we have posix_madvise
2445e78815a5SAndreas Färber
2446e78815a5SAndreas Färberposix_madvise=no
2447e78815a5SAndreas Färbercat > $TMPC << EOF
2448e78815a5SAndreas Färber#include <sys/mman.h>
2449832ce9c2SScott Wood#include <stddef.h>
2450e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2451e78815a5SAndreas FärberEOF
2452e78815a5SAndreas Färberif compile_prog "" "" ; then
2453e78815a5SAndreas Färber    posix_madvise=yes
2454e78815a5SAndreas Färberfi
2455e78815a5SAndreas Färber
2456e78815a5SAndreas Färber##########################################
245794a420b1SStefan Hajnoczi# check if trace backend exists
245894a420b1SStefan Hajnoczi
24594c3b5a48SBlue Swirlsh "$source_path/scripts/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
246094a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
246194a420b1SStefan Hajnoczi  echo
246294a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
246394a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
246494a420b1SStefan Hajnoczi  echo
246594a420b1SStefan Hajnoczi  exit 1
246694a420b1SStefan Hajnoczifi
246794a420b1SStefan Hajnoczi
24687e24e92aSStefan Hajnoczi##########################################
24697e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
24707e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
24717e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
24727e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
24737e24e92aSStefan Hajnoczi#include <ust/marker.h>
24747e24e92aSStefan Hajnocziint main(void) { return 0; }
24757e24e92aSStefan HajnocziEOF
24767e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
24777e24e92aSStefan Hajnoczi    LIBS="-lust $LIBS"
24787e24e92aSStefan Hajnoczi  else
24797e24e92aSStefan Hajnoczi    echo
24807e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
24817e24e92aSStefan Hajnoczi    echo
24827e24e92aSStefan Hajnoczi    exit 1
24837e24e92aSStefan Hajnoczi  fi
24847e24e92aSStefan Hajnoczifi
2485b3d08c02SDaniel P. Berrange
2486b3d08c02SDaniel P. Berrange##########################################
2487b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2488b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2489b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2490b3d08c02SDaniel P. Berrange    echo
2491b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2492b3d08c02SDaniel P. Berrange    echo
2493b3d08c02SDaniel P. Berrange    exit 1
2494b3d08c02SDaniel P. Berrange  fi
2495c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2496c276b17dSDaniel P. Berrange  if has 'stap' ; then
2497c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2498c276b17dSDaniel P. Berrange  fi
2499b3d08c02SDaniel P. Berrangefi
2500b3d08c02SDaniel P. Berrange
25017e24e92aSStefan Hajnoczi##########################################
2502e86ecd4bSJuan Quintela# End of CC checks
2503e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2504e86ecd4bSJuan Quintela
2505e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
25061156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2507e86ecd4bSJuan Quintelafi
2508a316e378SJuan Quintela
2509e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2510e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2511e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
251220ff6c80SAnthony Liguori
251320ff6c80SAnthony Liguoriif test -z "$werror" ; then
2514e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2515e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2516e86ecd4bSJuan Quintela        werror="yes"
2517e86ecd4bSJuan Quintela    else
2518e86ecd4bSJuan Quintela        werror="no"
2519e86ecd4bSJuan Quintela    fi
2520e86ecd4bSJuan Quintelafi
2521e86ecd4bSJuan Quintela
252220ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
252320ff6c80SAnthony Liguori# enable/disable
252420ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
252520ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
252620ff6c80SAnthony Liguori	zero_malloc="no"
252720ff6c80SAnthony Liguori    else
252820ff6c80SAnthony Liguori	zero_malloc="yes"
252920ff6c80SAnthony Liguori    fi
253020ff6c80SAnthony Liguorifi
253120ff6c80SAnthony Liguori
2532e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2533a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2534e86ecd4bSJuan Quintelafi
2535e86ecd4bSJuan Quintela
2536e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2537e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
25381156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2539e86ecd4bSJuan Quintela    fi
2540e86ecd4bSJuan Quintelafi
2541e86ecd4bSJuan Quintela
2542952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
2543952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
2544952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
2545952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2546952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
2547952afb71SBlue Swirl        fi
2548952afb71SBlue Swirl    done
2549952afb71SBlue Swirlfi
2550952afb71SBlue Swirl
2551190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
25525a67135aSbellard
2553ca35f780SPaolo Bonzinitools=
2554ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2555ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2556ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2557ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
255848ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
2559ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2560ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2561ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2562ca35f780SPaolo Bonzini    fi
2563ca35f780SPaolo Bonzini  fi
2564ca35f780SPaolo Bonzinifi
2565ca35f780SPaolo Bonzini
2566ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2567ca35f780SPaolo Bonziniroms=
2568ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2569ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2570ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2571ca35f780SPaolo Bonzini  roms="optionrom"
2572ca35f780SPaolo Bonzinifi
2573d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
257439ac8455SDavid Gibson  roms="$roms spapr-rtas"
257539ac8455SDavid Gibsonfi
2576ca35f780SPaolo Bonzini
25777d13299dSbellardecho "Install prefix    $prefix"
2578f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2579f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
25803aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
25811c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
258211d9f695Sbellardif test "$mingw32" = "no" ; then
2583f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
258443ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
258511d9f695Sbellardfi
25865a67135aSbellardecho "Source path       $source_path"
25877d13299dSbellardecho "C compiler        $cc"
258883469015Sbellardecho "Host C compiler   $host_cc"
25890c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2590a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
25910c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
25927d13299dSbellardecho "make              $make"
25936a882643Spbrookecho "install           $install"
2594a98fd896Sbellardecho "host CPU          $cpu"
2595de83cd02Sbellardecho "host big endian   $bigendian"
259697a847bcSbellardecho "target list       $target_list"
2597ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2598b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
25997d13299dSbellardecho "gprof enabled     $gprof"
260003b4fe7dSaliguoriecho "sparse enabled    $sparse"
26011625af87Saliguoriecho "strip binaries    $strip_opt"
260205c2a3e7Sbellardecho "profiler          $profiler"
260343ce4dfeSbellardecho "static build      $static"
260485aa5189Sbellardecho "-Werror enabled   $werror"
26055b0753e0Sbellardif test "$darwin" = "yes" ; then
26065b0753e0Sbellard    echo "Cocoa support     $cocoa"
26075b0753e0Sbellardfi
260897a847bcSbellardecho "SDL support       $sdl"
26094d3b6f6eSbalrogecho "curses support    $curses"
2610769ce76dSAlexander Grafecho "curl support      $curl"
26115495ed11SLuiz Capitulinoecho "check support     $check_utests"
261267b915a5Sbellardecho "mingw32 support   $mingw32"
26130c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
26140c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2615eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
26168ff9cbf7Smalcecho "Mixer emulation   $mixemu"
2617821601eaSJes Sorensenecho "VNC support       $vnc"
2618821601eaSJes Sorensenif test "$vnc" = "yes" ; then
26198d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
26202f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
26212f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
2622efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
2623bd023f95SCorentin Chary    echo "VNC thread        $vnc_thread"
2624821601eaSJes Sorensenfi
26253142255cSblueswir1if test -n "$sparc_cpu"; then
26263142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
26273142255cSblueswir1fi
2628e37630caSaliguoriecho "xen support       $xen"
26292e4d9fb1Saurel32echo "brlapi support    $brlapi"
2630a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2631a25dba17SJuan Quintelaecho "Documentation     $docs"
2632c5937220Spbrook[ ! -z "$uname_release" ] && \
2633c5937220Spbrookecho "uname -r          $uname_release"
2634bd0c5661Spbrookecho "NPTL support      $nptl"
2635379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
263634005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
26378a16d273Sthsecho "vde support       $vde"
2638e5d355d1Saliguoriecho "IO thread         $io_thread"
26395c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2640758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
264177755340Sthsecho "Install blobs     $blobs"
2642b31a0277SJuan Quintelaecho "KVM support       $kvm"
2643f652e6afSaurel32echo "fdt support       $fdt"
2644ceb42de8Saliguoriecho "preadv support    $preadv"
26455f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2646e78815a5SAndreas Färberecho "madvise           $madvise"
2647e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
2648ee682d27SStefan Weilecho "uuid support      $uuid"
2649d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
265094a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
26519410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
2652cd4ec0b4SGerd Hoffmannecho "spice support     $spice"
2653f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
2654dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
2655111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
265669354a83SHans de Goedeecho "usb net redir     $usb_redir"
265720ff075bSMichael Walleecho "OpenGL support    $opengl"
265867b915a5Sbellard
265997a847bcSbellardif test $sdl_too_old = "yes"; then
266024b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2661e8cd23deSbellardfi
266297a847bcSbellard
266398ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
26644bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
266597a847bcSbellard
266698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
266798ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
266898ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
266998ec69acSJuan Quintelaecho >> $config_host_mak
267098ec69acSJuan Quintela
2671e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
267299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
267399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
26743aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
267599d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
267699d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
267799d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
267899d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
26791dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2680804edf29SJuan Quintela
26812408a527Saurel32case "$cpu" in
2682d2fbca94SGuan Xuetao  i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64|unicore32)
2683e0da9dd3SJuan Quintela    ARCH=$cpu
26842408a527Saurel32  ;;
2685a302c32dSLaurent Desnogues  armv4b|armv4l)
268616dbd14fSJuan Quintela    ARCH=arm
26872408a527Saurel32  ;;
26882408a527Saurel32esac
268998ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2690f8393946Saurel32if test "$debug_tcg" = "yes" ; then
26912358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2692f8393946Saurel32fi
2693b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2694b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2695b4475aa2SLuiz Capitulinofi
2696f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
26972358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2698f3d08ee6SPaul Brookfi
26991625af87Saliguoriif test "$strip_opt" = "yes" ; then
270052ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
27011625af87Saliguorifi
27027d13299dSbellardif test "$bigendian" = "yes" ; then
2703e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
270497a847bcSbellardfi
27052358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
270667b915a5Sbellardif test "$mingw32" = "yes" ; then
270798ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
27089fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
27099fe6de94SBlue Swirl  version_major=${rc_version%%.*}
27109fe6de94SBlue Swirl  rc_version=${rc_version#*.}
27119fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
27129fe6de94SBlue Swirl  rc_version=${rc_version#*.}
27139fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
27149fe6de94SBlue Swirl  version_micro=0
27159fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
27169fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2717210fa556Spbrookelse
271835f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2719210fa556Spbrookfi
2720128ab2ffSblueswir1
2721dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2722dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2723dffcb71cSMark McLoughlinfi
2724dffcb71cSMark McLoughlin
272583fb7adfSbellardif test "$darwin" = "yes" ; then
272698ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
272783fb7adfSbellardfi
2728b29fe3edSmalc
2729b29fe3edSmalcif test "$aix" = "yes" ; then
273098ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2731b29fe3edSmalcfi
2732b29fe3edSmalc
2733ec530c81Sbellardif test "$solaris" = "yes" ; then
273498ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
27352358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
27360475a5caSths  if test "$needs_libsunmath" = "yes" ; then
273775b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
27380475a5caSths  fi
2739ec530c81Sbellardfi
2740179cf400SAndreas Färberif test "$haiku" = "yes" ; then
2741179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
2742179cf400SAndreas Färberfi
274397a847bcSbellardif test "$static" = "yes" ; then
274498ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
274597a847bcSbellardfi
274605c2a3e7Sbellardif test $profiler = "yes" ; then
27472358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
274805c2a3e7Sbellardfi
2749c20709aaSbellardif test "$slirp" = "yes" ; then
275098ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2751f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
2752c20709aaSbellardfi
27538a16d273Sthsif test "$vde" = "yes" ; then
275498ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
27558a16d273Sthsfi
27560c58ac1cSmalcfor card in $audio_card_list; do
2757f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
275898ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
27590c58ac1cSmalcdone
27602358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
27610c58ac1cSmalcfor drv in $audio_drv_list; do
2762f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
276398ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2764923e4521Smalc    if test "$drv" = "fmod"; then
27657aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2766fb065187Sbellard    fi
27670c58ac1cSmalcdone
276867f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
276967f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
277067f86e8eSJuan Quintelafi
2771d5631638Smalcif test "$audio_win_int" = "yes" ; then
2772d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2773d5631638Smalcfi
2774eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
27758ff9cbf7Smalcif test "$mixemu" = "yes" ; then
277698ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
27778ff9cbf7Smalcfi
2778821601eaSJes Sorensenif test "$vnc" = "yes" ; then
2779821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
2780821601eaSJes Sorensenfi
27818d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
278298ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2783525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
27848d5d2d4cSthsfi
27852f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
278698ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
278760ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
27882f9606b3Saliguorifi
2789821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
27902f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
27912f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
27922f6f5c7aSCorentin Charyfi
2793821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
2794efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2795efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2796efe556adSCorentin Charyfi
2797821601eaSJes Sorensenif test "$vnc_thread" = "yes" ; then
2798bd023f95SCorentin Chary  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2799bd023f95SCorentin Charyfi
280076655d6dSaliguoriif test "$fnmatch" = "yes" ; then
28012358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
280276655d6dSaliguorifi
2803ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2804ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2805ee682d27SStefan Weilfi
2806dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
2807dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
2808dce512deSChristoph Hellwigfi
2809b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
281098ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
28112358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
281298ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
281398ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2814a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
281598ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2816cc8ae6deSpbrookfi
28171ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
281898ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
28198ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
282049ecc3faSbellardfi
282149ecc3faSbellardif test "$cocoa" = "yes" ; then
282298ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
282349ecc3faSbellardfi
28244d3b6f6eSbalrogif test "$curses" = "yes" ; then
282598ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2826ab4e5602SJan Kiszkafi
28273b3f24adSaurel32if test "$atfile" = "yes" ; then
28282358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
28293b3f24adSaurel32fi
2830ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
28312358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2832ebc996f3SRiku Voipiofi
2833099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
28342358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2835099d6b0fSRiku Voipiofi
283640ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
283740ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
283840ff6d7eSKevin Wolffi
28393ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
28402358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
28413ce34dfbSvibisreenivasanfi
2842c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2843c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2844c2882b96SRiku Voipiofi
2845d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2846d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2847d0927938SUlrich Hechtfi
2848c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
2849c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2850c727f47dSPeter Maydellfi
2851dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
2852dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
2853dace20dcSPeter Maydellfi
2854d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2855d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2856d0927938SUlrich Hechtfi
28573b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
28583b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
28593b6edd16SPeter Maydellfi
28603b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
28613b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
28623b6edd16SPeter Maydellfi
28633b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
28643b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
28653b6edd16SPeter Maydellfi
28663b3f24adSaurel32if test "$inotify" = "yes" ; then
28672358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
28683b3f24adSaurel32fi
2869c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2870c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2871c05c7a73SRiku Voipiofi
28726ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
28736ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
28746ae9a1f4SJuan Quintelafi
28756ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
28766ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
28776ae9a1f4SJuan Quintelafi
2878769ce76dSAlexander Grafif test "$curl" = "yes" ; then
287998ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2880b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2881769ce76dSAlexander Graffi
28822e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
288398ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
28842e4d9fb1Saurel32fi
2885fb599c9aSbalrogif test "$bluez" = "yes" ; then
288698ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2887ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2888fb599c9aSbalrogfi
2889e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
2890e37630caSaliguoriif test "$xen" = "yes" ; then
28916dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
2892d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
2893e37630caSaliguorifi
2894e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
289598ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2896e5d355d1Saliguorifi
28975c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
28985c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
28995c6c3a6cSChristoph Hellwigfi
2900758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
2901758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
2902758e8e38SVenkateswararao Jujjuri (JV)fi
2903758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
2904758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
2905758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2906758e8e38SVenkateswararao Jujjuri (JV)  fi
2907758e8e38SVenkateswararao Jujjuri (JV)fi
290877755340Sthsif test "$blobs" = "yes" ; then
290998ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
291077755340Sthsfi
2911bf9298b9Saliguoriif test "$iovec" = "yes" ; then
29122358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2913bf9298b9Saliguorifi
2914ceb42de8Saliguoriif test "$preadv" = "yes" ; then
29152358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2916ceb42de8Saliguorifi
2917f652e6afSaurel32if test "$fdt" = "yes" ; then
29183f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2919f652e6afSaurel32fi
2920dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
2921dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2922dcc38d1cSMarcelo Tosattifi
2923de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2924de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2925de5071c5SBlue Swirlfi
2926747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2927747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2928747bbdf7SBlue Swirlfi
29295f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
29305f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
29315f6b9e8fSBlue Swirlfi
2932e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
2933e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
2934e78815a5SAndreas Färberfi
2935e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
2936e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2937e78815a5SAndreas Färberfi
293897a847bcSbellard
2939cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
2940cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
2941cd4ec0b4SGerd Hoffmannfi
2942cd4ec0b4SGerd Hoffmann
294336707144SAlon Levyif test "$smartcard" = "yes" ; then
294436707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
294536707144SAlon Levyfi
294636707144SAlon Levy
2947111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
2948111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
2949111a38b0SRobert Relyeafi
2950111a38b0SRobert Relyea
295169354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
295269354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
295369354a83SHans de Goedefi
295469354a83SHans de Goede
295520ff075bSMichael Walleif test "$opengl" = "yes" ; then
295620ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
295720ff075bSMichael Wallefi
295820ff075bSMichael Walle
295983fb7adfSbellard# XXX: suppress that
29607d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
29612358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
29627d3505c5Sbellardfi
29637d3505c5Sbellard
29642358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2965c5937220Spbrook
296620ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
296720ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
296820ff6c80SAnthony Liguorifi
2969f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
2970f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
2971f27aaf4bSChristian Brunnerfi
297220ff6c80SAnthony Liguori
297368063649Sblueswir1# USB host support
297468063649Sblueswir1case "$usb" in
297568063649Sblueswir1linux)
297698ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
297768063649Sblueswir1;;
297868063649Sblueswir1bsd)
297998ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
298068063649Sblueswir1;;
298168063649Sblueswir1*)
298298ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
298368063649Sblueswir1;;
298468063649Sblueswir1esac
298568063649Sblueswir1
298694a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
298722890ab5SPrerna Saxenaif test "$trace_backend" = "simple"; then
298822890ab5SPrerna Saxena  echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
298922890ab5SPrerna Saxenafi
29909410b56cSPrerna Saxena# Set the appropriate trace file.
29919410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
2992953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
29939410b56cSPrerna Saxenafi
2994c276b17dSDaniel P. Berrangeif test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
2995c276b17dSDaniel P. Berrange  echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
2996c276b17dSDaniel P. Berrangefi
29979410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
29989410b56cSPrerna Saxena
299998ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
300098ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3001804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3002804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
3003804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
3004804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
3005804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
3006804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
30072b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3008804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
3009804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3010804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3011804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
30129fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
301344dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3014e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3015a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3016f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3017e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3018e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3019e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3020e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3021e39f0062SPaolo Bonzinifi
3022c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
3023e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3024a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3025a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
302673da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
30273e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3028804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3029804edf29SJuan Quintela
30304bf6b55bSJuan Quintela# generate list of library paths for linker script
30314bf6b55bSJuan Quintela
30324bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
30334bf6b55bSJuan Quintela
30344bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
30354bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
30364bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
30374bf6b55bSJuan Quintela  else
30384bf6b55bSJuan Quintela    rm ${config_host_ld}~
30394bf6b55bSJuan Quintela  fi
30404bf6b55bSJuan Quintelafi
30414bf6b55bSJuan Quintela
30424d904533SBlue Swirlfor d in libdis libdis-user; do
30434d904533SBlue Swirl    mkdir -p $d
304411568d6dSPaolo Bonzini    symlink $source_path/Makefile.dis $d/Makefile
30454d904533SBlue Swirl    echo > $d/config.mak
30464d904533SBlue Swirldone
3047d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
3048d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
3049d44cff22SRichard Hendersonfi
30504d904533SBlue Swirl
305197a847bcSbellardfor target in $target_list; do
305297a847bcSbellardtarget_dir="$target"
305325be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3054600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
305597a847bcSbellardtarget_bigendian="no"
30561f3d3c8fSJuan Quintela
3057ea2d6a39SJuan Quintelacase "$target_arch2" in
3058613a22c9SMichael Walle  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
3059ea2d6a39SJuan Quintela  target_bigendian=yes
3060ea2d6a39SJuan Quintela  ;;
3061ea2d6a39SJuan Quintelaesac
306297a847bcSbellardtarget_softmmu="no"
3063997344f3Sbellardtarget_user_only="no"
3064831b7825Sthstarget_linux_user="no"
3065831b7825Sthstarget_darwin_user="no"
306684778508Sblueswir1target_bsd_user="no"
30679e407a85Spbrookcase "$target" in
3068600309b6SBlue Swirl  ${target_arch2}-softmmu)
30699e407a85Spbrook    target_softmmu="yes"
30709e407a85Spbrook    ;;
3071600309b6SBlue Swirl  ${target_arch2}-linux-user)
30729c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
30739c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
30749c7a4202SBlue Swirl      exit 1
30759c7a4202SBlue Swirl    fi
30769e407a85Spbrook    target_user_only="yes"
30779e407a85Spbrook    target_linux_user="yes"
30789e407a85Spbrook    ;;
3079600309b6SBlue Swirl  ${target_arch2}-darwin-user)
30809c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
30819c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
30829c7a4202SBlue Swirl      exit 1
30839c7a4202SBlue Swirl    fi
30849e407a85Spbrook    target_user_only="yes"
3085831b7825Sths    target_darwin_user="yes"
30869e407a85Spbrook    ;;
3087600309b6SBlue Swirl  ${target_arch2}-bsd-user)
30889cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
30899c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
30909c7a4202SBlue Swirl      exit 1
30919c7a4202SBlue Swirl    fi
309284778508Sblueswir1    target_user_only="yes"
309384778508Sblueswir1    target_bsd_user="yes"
309484778508Sblueswir1    ;;
30959e407a85Spbrook  *)
30969e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
30979e407a85Spbrook    exit 1
30989e407a85Spbrook    ;;
30999e407a85Spbrookesac
3100831b7825Sths
310197a847bcSbellardmkdir -p $target_dir
3102158142c2Sbellardmkdir -p $target_dir/fpu
310357fec1feSbellardmkdir -p $target_dir/tcg
310459f2a787SGerd Hoffmannmkdir -p $target_dir/ide
3105353ac78dSAneesh Kumar K.Vmkdir -p $target_dir/9pfs
310684778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
310769de927cSbellard  mkdir -p $target_dir/nwfpe
310869de927cSbellardfi
310911568d6dSPaolo Bonzinisymlink $source_path/Makefile.target $target_dir/Makefile
3110ec530c81Sbellard
311197a847bcSbellard
311225be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
311397a847bcSbellard
3114e5fe0c52Spbrookbflt="no"
3115bd0c5661Spbrooktarget_nptl="no"
3116600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
31177ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
311856aebc89Spbrookgdb_xml_files=""
3119c2e3dee6SLaurent Viviertarget_short_alignment=2
3120c2e3dee6SLaurent Viviertarget_int_alignment=4
3121c2e3dee6SLaurent Viviertarget_long_alignment=4
3122c2e3dee6SLaurent Viviertarget_llong_alignment=8
3123de3a354aSMichael Walletarget_libs_softmmu=
31247ba1e619Saliguori
3125938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
31266acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3127e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3128e73aae67SJuan Quintela
3129600309b6SBlue Swirlcase "$target_arch2" in
31302408a527Saurel32  i386)
313171deff27SAurelien Jarno    target_phys_bits=64
31322408a527Saurel32  ;;
31332408a527Saurel32  x86_64)
31346acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
31351ad2134fSPaul Brook    target_phys_bits=64
3136c2e3dee6SLaurent Vivier    target_long_alignment=8
31372408a527Saurel32  ;;
31382408a527Saurel32  alpha)
31391ad2134fSPaul Brook    target_phys_bits=64
3140c2e3dee6SLaurent Vivier    target_long_alignment=8
3141a4b388ffSRichard Henderson    target_nptl="yes"
31422408a527Saurel32  ;;
31432408a527Saurel32  arm|armeb)
3144b498c8a0SJuan Quintela    TARGET_ARCH=arm
3145e5fe0c52Spbrook    bflt="yes"
3146bd0c5661Spbrook    target_nptl="yes"
314756aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
31481ad2134fSPaul Brook    target_phys_bits=32
3149c2e3dee6SLaurent Vivier    target_llong_alignment=4
31502408a527Saurel32  ;;
31512408a527Saurel32  cris)
3152253bd7f8Sedgar_igl    target_nptl="yes"
31531ad2134fSPaul Brook    target_phys_bits=32
31542408a527Saurel32  ;;
3155613a22c9SMichael Walle  lm32)
3156613a22c9SMichael Walle    target_phys_bits=32
3157de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3158613a22c9SMichael Walle  ;;
31592408a527Saurel32  m68k)
31600938cda5Saurel32    bflt="yes"
316156aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
31621ad2134fSPaul Brook    target_phys_bits=32
3163c2e3dee6SLaurent Vivier    target_int_alignment=2
3164c2e3dee6SLaurent Vivier    target_long_alignment=2
3165c2e3dee6SLaurent Vivier    target_llong_alignment=2
31662408a527Saurel32  ;;
3167877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3168877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
316972b675caSEdgar E. Iglesias    bflt="yes"
317072b675caSEdgar E. Iglesias    target_nptl="yes"
317172b675caSEdgar E. Iglesias    target_phys_bits=32
3172de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
317372b675caSEdgar E. Iglesias  ;;
31742408a527Saurel32  mips|mipsel)
3175b498c8a0SJuan Quintela    TARGET_ARCH=mips
317625be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3177f04dc72fSPaul Brook    target_nptl="yes"
31781ad2134fSPaul Brook    target_phys_bits=64
31792408a527Saurel32  ;;
31802408a527Saurel32  mipsn32|mipsn32el)
3181b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
31826acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
318325be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
31841ad2134fSPaul Brook    target_phys_bits=64
31852408a527Saurel32  ;;
31862408a527Saurel32  mips64|mips64el)
3187b498c8a0SJuan Quintela    TARGET_ARCH=mips64
31886acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
318925be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
31901ad2134fSPaul Brook    target_phys_bits=64
3191c2e3dee6SLaurent Vivier    target_long_alignment=8
31922408a527Saurel32  ;;
31932408a527Saurel32  ppc)
3194c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
31951ad2134fSPaul Brook    target_phys_bits=32
3196d6630708SNathan Froyd    target_nptl="yes"
3197de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
31982408a527Saurel32  ;;
31992408a527Saurel32  ppcemb)
32006acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3201e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3202c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32031ad2134fSPaul Brook    target_phys_bits=64
3204d6630708SNathan Froyd    target_nptl="yes"
3205de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32062408a527Saurel32  ;;
32072408a527Saurel32  ppc64)
32086acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3209e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3210c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32111ad2134fSPaul Brook    target_phys_bits=64
3212c2e3dee6SLaurent Vivier    target_long_alignment=8
3213de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32142408a527Saurel32  ;;
32152408a527Saurel32  ppc64abi32)
3216b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
32176acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3218e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
321925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3220c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32211ad2134fSPaul Brook    target_phys_bits=64
3222de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32232408a527Saurel32  ;;
32242408a527Saurel32  sh4|sh4eb)
3225b498c8a0SJuan Quintela    TARGET_ARCH=sh4
32264dbed897Spbrook    bflt="yes"
32270b6d3ae0Saurel32    target_nptl="yes"
32281ad2134fSPaul Brook    target_phys_bits=32
32292408a527Saurel32  ;;
32302408a527Saurel32  sparc)
32311ad2134fSPaul Brook    target_phys_bits=64
32322408a527Saurel32  ;;
32332408a527Saurel32  sparc64)
32346acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
32351ad2134fSPaul Brook    target_phys_bits=64
3236c2e3dee6SLaurent Vivier    target_long_alignment=8
32372408a527Saurel32  ;;
32382408a527Saurel32  sparc32plus)
3239b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
32406acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3241e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
324225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
32431ad2134fSPaul Brook    target_phys_bits=64
32442408a527Saurel32  ;;
324524e804ecSAlexander Graf  s390x)
3246bc434676SUlrich Hecht    target_nptl="yes"
324724e804ecSAlexander Graf    target_phys_bits=64
32487b3da903SAlexander Graf    target_long_alignment=8
324924e804ecSAlexander Graf  ;;
3250d2fbca94SGuan Xuetao  unicore32)
3251d2fbca94SGuan Xuetao    target_phys_bits=32
3252d2fbca94SGuan Xuetao  ;;
32532408a527Saurel32  *)
3254de83cd02Sbellard    echo "Unsupported target CPU"
3255de83cd02Sbellard    exit 1
32562408a527Saurel32  ;;
32572408a527Saurel32esac
3258c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3259c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3260c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3261c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
326225be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3263053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
326425be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
326525be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
326642bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
32676acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
32686acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
32696acff7daSJuan Quintelafi
327025be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3271e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3272e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3273e6e91b9cSJuan Quintelafi
327425be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
32751b0c87fcSJuan Quintelacase "$target_arch2" in
32761b0c87fcSJuan Quintela  i386|x86_64)
32771b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
327864b3cfdbSAnthony PERARD      target_phys_bits=64
327925be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
3280432d268cSJun Nakajima      if test "$cpu" = "i386" -o "$cpu" = "x86_64"; then
3281432d268cSJun Nakajima          echo "CONFIG_XEN_MAPCACHE=y" >> $config_target_mak
3282432d268cSJun Nakajima      fi
32831b0c87fcSJuan Quintela    fi
32841b0c87fcSJuan Quintelaesac
3285c59249f9SJuan Quintelacase "$target_arch2" in
32860e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3287c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3288c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3289c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3290c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
32915f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3292adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3293adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3294c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3295c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
329625be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
3297d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
3298d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3299d5970055SMichael S. Tsirkin      fi
3300c59249f9SJuan Quintela    fi
3301c59249f9SJuan Quintelaesac
3302de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
330325be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
330497a847bcSbellardfi
330597a847bcSbellardif test "$target_softmmu" = "yes" ; then
3306b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
330725be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3308de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
33090e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
33105791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3311de83cd02Sbellardfi
3312997344f3Sbellardif test "$target_user_only" = "yes" ; then
331325be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3314997344f3Sbellardfi
3315831b7825Sthsif test "$target_linux_user" = "yes" ; then
331625be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3317831b7825Sthsfi
3318831b7825Sthsif test "$target_darwin_user" = "yes" ; then
331925be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3320831b7825Sthsfi
3321111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3322111a38b0SRobert Relyea  echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3323111a38b0SRobert Relyea  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3324111a38b0SRobert Relyea  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3325111a38b0SRobert Relyeafi
332656aebc89Spbrooklist=""
332756aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
332856aebc89Spbrook  for x in $gdb_xml_files; do
332956aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
333056aebc89Spbrook  done
333125be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
33323d0f1517SJuan Quintelafi
3333de83cd02Sbellard
3334e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
333525be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3336e5fe0c52Spbrookfi
3337bd0c5661Spbrookif test "$target_user_only" = "yes" \
3338bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
333925be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3340bd0c5661Spbrookfi
3341379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
334225be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3343379f6698SPaul Brookfi
334484778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
334525be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
334684778508Sblueswir1fi
33475b0753e0Sbellard
33484afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3349fa282484SJuan Quintela
33504afddb55SJuan Quintelacflags=""
3351f9728943SPaolo Bonziniincludes=""
3352fa282484SJuan Quintelaldflags=""
33539b8e111fSJuan Quintela
335457ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
3355f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
335624e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3357f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
33585d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3359f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
336057ddfbf7SJuan Quintelaelse
3361f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
336257ddfbf7SJuan Quintelafi
3363f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
3364f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/fpu $includes"
336557ddfbf7SJuan Quintela
33664d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
33674d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
33684d904533SBlue Swirlelse
33694d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
33704d904533SBlue Swirlfi
33714d904533SBlue Swirl
337264656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
337364656024SJuan Quintela  case "$i" in
337464656024SJuan Quintela  alpha)
337525be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
33764d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
337764656024SJuan Quintela  ;;
337864656024SJuan Quintela  arm)
337925be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
33804d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
338164656024SJuan Quintela  ;;
338264656024SJuan Quintela  cris)
338325be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
33844d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
338564656024SJuan Quintela  ;;
338664656024SJuan Quintela  hppa)
338725be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
33884d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
338964656024SJuan Quintela  ;;
339064656024SJuan Quintela  i386|x86_64)
339125be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
33924d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
339364656024SJuan Quintela  ;;
3394903ec55cSAurelien Jarno  ia64*)
3395903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3396903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3397903ec55cSAurelien Jarno  ;;
339864656024SJuan Quintela  m68k)
339925be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
34004d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
340164656024SJuan Quintela  ;;
3402877fdc12SEdgar E. Iglesias  microblaze*)
340325be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
34044d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
340564656024SJuan Quintela  ;;
340664656024SJuan Quintela  mips*)
340725be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
34084d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
340964656024SJuan Quintela  ;;
341064656024SJuan Quintela  ppc*)
341125be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
34124d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
341364656024SJuan Quintela  ;;
341424e804ecSAlexander Graf  s390*)
341525be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
34164d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
341764656024SJuan Quintela  ;;
341864656024SJuan Quintela  sh4)
341925be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
34204d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
342164656024SJuan Quintela  ;;
342264656024SJuan Quintela  sparc*)
342325be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
34244d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
342564656024SJuan Quintela  ;;
342664656024SJuan Quintela  esac
342764656024SJuan Quinteladone
342864656024SJuan Quintela
34296ee7126fSJuan Quintelacase "$ARCH" in
34306ee7126fSJuan Quintelaalpha)
34316ee7126fSJuan Quintela  # Ensure there's only a single GP
34326ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
34336ee7126fSJuan Quintela;;
34346ee7126fSJuan Quintelaesac
34356ee7126fSJuan Quintela
343655d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
343755d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
343855d9c04bSJuan Quintela  arm)
343955d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
344055d9c04bSJuan Quintela  ;;
344125a8bb96SMichael Walle  lm32)
344225a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
344325a8bb96SMichael Walle  ;;
344455d9c04bSJuan Quintela  i386|mips|ppc)
344555d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
344655d9c04bSJuan Quintela  ;;
344755d9c04bSJuan Quintela  esac
344855d9c04bSJuan Quintelafi
344955d9c04bSJuan Quintela
345034005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
345134005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
345234005a00SKirill A. Shutemov  cflags="-fpie $cflags"
345334005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
345434005a00SKirill A. Shutemovfi
345534005a00SKirill A. Shutemov
3456471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
3457471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
3458471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
345925be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3460471857ddSJuan Quintelafi
3461471857ddSJuan Quintela
3462d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
346325be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
3464d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
3465d02c1db3SJuan Quintela    cflags="-p $cflags"
3466d02c1db3SJuan Quintela    ldflags="-p $ldflags"
3467d02c1db3SJuan Quintela  fi
3468d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
3469d02c1db3SJuan Quintela    ldflags="-p $ldflags"
347025be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3471d02c1db3SJuan Quintela  fi
3472d02c1db3SJuan Quintelafi
3473d02c1db3SJuan Quintela
34746ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
34759b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3476fa282484SJuan Quintela  case "$ARCH" in
3477fa282484SJuan Quintela  sparc)
3478fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
3479322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
3480fa282484SJuan Quintela    ;;
34814d58be06SRichard Henderson  alpha | s390x)
34824d58be06SRichard Henderson    # The default placement of the application is fine.
34834d58be06SRichard Henderson    ;;
3484fd76e73aSRichard Henderson  *)
3485322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
3486fa282484SJuan Quintela    ;;
3487fa282484SJuan Quintela  esac
3488fa282484SJuan Quintelafi
3489fa282484SJuan Quintela
3490e205c790SJan Kiszka# use included Linux headers
3491af2be207SJan Kiszkaif test "$linux" = "yes" ; then
3492e205c790SJan Kiszka  includes="-I\$(SRC_PATH)/linux-headers $includes"
3493e205c790SJan Kiszka  mkdir -p linux-headers
3494e205c790SJan Kiszka  case "$cpu" in
3495e205c790SJan Kiszka  i386|x86_64)
3496e205c790SJan Kiszka    symlink $source_path/linux-headers/asm-x86 linux-headers/asm
3497e205c790SJan Kiszka    ;;
3498e205c790SJan Kiszka  ppcemb|ppc|ppc64)
3499af2be207SJan Kiszka    symlink $source_path/linux-headers/asm-powerpc linux-headers/asm
3500e205c790SJan Kiszka    ;;
3501e205c790SJan Kiszka  s390x)
3502e205c790SJan Kiszka    symlink $source_path/linux-headers/asm-s390 linux-headers/asm
3503e205c790SJan Kiszka    ;;
3504e205c790SJan Kiszka  esac
3505af2be207SJan Kiszkafi
3506e205c790SJan Kiszka
350725be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
350825be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3509f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
3510fa282484SJuan Quintela
351197a847bcSbellarddone # for target in $targets
35127d13299dSbellard
3513d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
3514e1144d00SMark McLoughlinDIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3515446b9165SAndreas FärberDIRS="$DIRS pc-bios/spapr-rtas"
35162d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
35173e230dd2SCorentin CharyDIRS="$DIRS fsdev ui"
35182345c77cSMichael RothDIRS="$DIRS qapi"
351913a286d5SMichael RothDIRS="$DIRS qga"
35207d13299dSbellardFILES="Makefile tests/Makefile"
3521e7daa605SthsFILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3522ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3523446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
35242d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
35255ee8ad71SAlex 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
35267ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
35277ea78b74SJan Kiszkadone
3528d1807a4fSPaolo Bonzinimkdir -p $DIRS
35297d13299dSbellardfor f in $FILES ; do
3530f9245e10SPeter Maydell    if [ -e "$source_path/$f" ] && ! [ -e "$f" ]; then
3531f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
3532f9245e10SPeter Maydell    fi
35337d13299dSbellarddone
35341ad2134fSPaul Brook
3535c34ebfdcSAnthony Liguori# temporary config to build submodules
35362d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
3537c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
353837116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3539c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3540c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3541c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
3542c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
3543c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3544c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
3545c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
3546c34ebfdcSAnthony Liguoridone
3547c34ebfdcSAnthony Liguori
35481ad2134fSPaul Brookfor hwlib in 32 64; do
35491ad2134fSPaul Brook  d=libhw$hwlib
35501ad2134fSPaul Brook  mkdir -p $d
35519953b2fcSBlue Swirl  mkdir -p $d/ide
355211568d6dSPaolo Bonzini  symlink $source_path/Makefile.hw $d/Makefile
3553353ac78dSAneesh Kumar K.V  mkdir -p $d/9pfs
355437116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
35551ad2134fSPaul Brookdone
3556add16157SBlue Swirl
3557111a38b0SRobert Relyeaif [ "$source_path" != `pwd` ]; then
3558111a38b0SRobert Relyea    # out of tree build
3559111a38b0SRobert Relyea    mkdir -p libcacard
3560111a38b0SRobert Relyea    rm -f libcacard/Makefile
356144dc0ca3SAlon Levy    symlink "$source_path/libcacard/Makefile" libcacard/Makefile
3562111a38b0SRobert Relyeafi
3563111a38b0SRobert Relyea
3564add16157SBlue Swirld=libuser
3565add16157SBlue Swirlmkdir -p $d
356611568d6dSPaolo Bonzinisymlink $source_path/Makefile.user $d/Makefile
3567299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
3568299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3569299060a0SKirill A. Shutemovfi
3570b40292e7SJan Kiszka
3571b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
3572b40292e7SJan Kiszka  mkdir -p QMP
3573b40292e7SJan Kiszkafi
3574