xref: /openbmc/qemu/configure (revision e39f0062)
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
350dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
360dba6195SLoïc Minier# executable or a builtin)
370dba6195SLoïc Minierhas() {
380dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
390dba6195SLoïc Minier}
400dba6195SLoïc Minier
410dba6195SLoïc Minier# search for an executable in PATH
420dba6195SLoïc Minierpath_of() {
430dba6195SLoïc Minier    local_command="$1"
440dba6195SLoïc Minier    local_ifs="$IFS"
450dba6195SLoïc Minier    local_dir=""
460dba6195SLoïc Minier
470dba6195SLoïc Minier    # pathname has a dir component?
480dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
490dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
500dba6195SLoïc Minier            echo "$local_command"
510dba6195SLoïc Minier            return 0
520dba6195SLoïc Minier        fi
530dba6195SLoïc Minier    fi
540dba6195SLoïc Minier    if [ -z "$local_command" ]; then
550dba6195SLoïc Minier        return 1
560dba6195SLoïc Minier    fi
570dba6195SLoïc Minier
580dba6195SLoïc Minier    IFS=:
590dba6195SLoïc Minier    for local_dir in $PATH; do
600dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
610dba6195SLoïc Minier            echo "$local_dir/$local_command"
620dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
630dba6195SLoïc Minier            return 0
640dba6195SLoïc Minier        fi
650dba6195SLoïc Minier    done
660dba6195SLoïc Minier    # not found
670dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
680dba6195SLoïc Minier    return 1
690dba6195SLoïc Minier}
700dba6195SLoïc Minier
717d13299dSbellard# default parameters
722ff6b91eSJuan Quintelacpu=""
731e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
7443ce4dfeSbellardstatic="no"
75ed968ff1SJuan Quintelasparc_cpu=""
767d13299dSbellardcross_prefix=""
770c58ac1cSmalcaudio_drv_list=""
78d61a4ce8SGerd Hoffmannaudio_card_list="ac97 es1370 sb16 hda"
79d61a4ce8SGerd Hoffmannaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
80eb852011SMarkus Armbrusterblock_drv_whitelist=""
817d13299dSbellardhost_cc="gcc"
82c81da56eSJuan Quintelahelper_cflags=""
8373da375eSJuan Quintelalibs_softmmu=""
843e2e0e6bSJuan Quintelalibs_tools=""
8567f86e8eSJuan Quintelaaudio_pt_int=""
86d5631638Smalcaudio_win_int=""
872b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
88ac0df51dSaliguori
89377529c0SPaolo Bonzinitarget_list=""
90377529c0SPaolo Bonzini
91377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
92377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
93377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
94377529c0SPaolo Bonzini#              unless --disable-foo is given
95377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
96377529c0SPaolo Bonzini#              feature will searched for,
97377529c0SPaolo Bonzini#              if not found, configure exits with error
98377529c0SPaolo Bonzini#
99377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
100377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
101377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
102377529c0SPaolo Bonzini
103377529c0SPaolo Bonzinibluez=""
104377529c0SPaolo Bonzinibrlapi=""
105377529c0SPaolo Bonzinicurl=""
106377529c0SPaolo Bonzinicurses=""
107377529c0SPaolo Bonzinidocs=""
108377529c0SPaolo Bonzinifdt=""
109377529c0SPaolo Bonzinikvm=""
110377529c0SPaolo Bonzinikvm_para=""
111377529c0SPaolo Bonzininptl=""
112377529c0SPaolo Bonzinisdl=""
113377529c0SPaolo Bonzinisparse="no"
114377529c0SPaolo Bonziniuuid=""
115377529c0SPaolo Bonzinivde=""
116377529c0SPaolo Bonzinivnc_tls=""
117377529c0SPaolo Bonzinivnc_sasl=""
118377529c0SPaolo Bonzinivnc_jpeg=""
119377529c0SPaolo Bonzinivnc_png=""
120377529c0SPaolo Bonzinivnc_thread="no"
121377529c0SPaolo Bonzinixen=""
122377529c0SPaolo Bonzinilinux_aio=""
123377529c0SPaolo Bonziniattr=""
124377529c0SPaolo Bonzinivhost_net=""
125377529c0SPaolo Bonzinixfs=""
126377529c0SPaolo Bonzini
127377529c0SPaolo Bonzinigprof="no"
128377529c0SPaolo Bonzinidebug_tcg="no"
129377529c0SPaolo Bonzinidebug_mon="no"
130377529c0SPaolo Bonzinidebug="no"
131377529c0SPaolo Bonzinistrip_opt="yes"
132377529c0SPaolo Bonzinibigendian="no"
133377529c0SPaolo Bonzinimingw32="no"
134377529c0SPaolo BonziniEXESUF=""
135377529c0SPaolo Bonziniprefix="/usr/local"
136377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
137377529c0SPaolo Bonzinidatadir="\${prefix}/share/qemu"
138377529c0SPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
139377529c0SPaolo Bonzinibindir="\${prefix}/bin"
140377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
141377529c0SPaolo Bonziniconfsuffix="/qemu"
142377529c0SPaolo Bonzinislirp="yes"
143377529c0SPaolo Bonzinifmod_lib=""
144377529c0SPaolo Bonzinifmod_inc=""
145377529c0SPaolo Bonzinioss_lib=""
146377529c0SPaolo Bonzinibsd="no"
147377529c0SPaolo Bonzinilinux="no"
148377529c0SPaolo Bonzinisolaris="no"
149377529c0SPaolo Bonziniprofiler="no"
150377529c0SPaolo Bonzinicocoa="no"
151377529c0SPaolo Bonzinisoftmmu="yes"
152377529c0SPaolo Bonzinilinux_user="no"
153377529c0SPaolo Bonzinidarwin_user="no"
154377529c0SPaolo Bonzinibsd_user="no"
155377529c0SPaolo Bonziniguest_base=""
156377529c0SPaolo Bonziniuname_release=""
157377529c0SPaolo Bonziniio_thread="no"
158377529c0SPaolo Bonzinimixemu="no"
159377529c0SPaolo Bonzinikerneldir=""
160377529c0SPaolo Bonziniaix="no"
161377529c0SPaolo Bonziniblobs="yes"
162377529c0SPaolo Bonzinipkgversion=""
163377529c0SPaolo Bonzinicheck_utests="no"
164377529c0SPaolo Bonziniuser_pie="no"
165377529c0SPaolo Bonzinizero_malloc=""
166377529c0SPaolo Bonzinitrace_backend="nop"
167377529c0SPaolo Bonzinitrace_file="trace"
168377529c0SPaolo Bonzinispice=""
169377529c0SPaolo Bonzinirbd=""
170377529c0SPaolo Bonzini
171ac0df51dSaliguori# parse CC options first
172ac0df51dSaliguorifor opt do
173ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
174ac0df51dSaliguori  case "$opt" in
175ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
176ac0df51dSaliguori  ;;
1773d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
178ac0df51dSaliguori  ;;
1792ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
1802ff6b91eSJuan Quintela  ;;
181a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
182e2a2ed06SJuan Quintela  ;;
183e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
184e2a2ed06SJuan Quintela  ;;
18550e7b1a0SJuan Quintela  --sparc_cpu=*)
18650e7b1a0SJuan Quintela    sparc_cpu="$optarg"
18750e7b1a0SJuan Quintela    case $sparc_cpu in
188ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
18950e7b1a0SJuan Quintela      cpu="sparc"
19050e7b1a0SJuan Quintela    ;;
19150e7b1a0SJuan Quintela    v9)
19250e7b1a0SJuan Quintela      cpu="sparc64"
19350e7b1a0SJuan Quintela    ;;
19450e7b1a0SJuan Quintela    *)
19550e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
19650e7b1a0SJuan Quintela      exit 1
19750e7b1a0SJuan Quintela    ;;
19850e7b1a0SJuan Quintela    esac
19950e7b1a0SJuan Quintela  ;;
200ac0df51dSaliguori  esac
201ac0df51dSaliguoridone
202ac0df51dSaliguori# OS specific
203ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
204ac0df51dSaliguori# we can eliminate it's usage altogether
205ac0df51dSaliguori
2063d8df640SPaolo Bonzinicc="${cross_prefix}${CC-gcc}"
2073d8df640SPaolo Bonziniar="${cross_prefix}${AR-ar}"
2083d8df640SPaolo Bonziniobjcopy="${cross_prefix}${OBJCOPY-objcopy}"
2093d8df640SPaolo Bonzinild="${cross_prefix}${LD-ld}"
2103d8df640SPaolo Bonzinistrip="${cross_prefix}${STRIP-strip}"
2113d8df640SPaolo Bonziniwindres="${cross_prefix}${WINDRES-windres}"
212ac0df51dSaliguori
213be17dc90SMichael S. Tsirkin# default flags for all hosts
214be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
215be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
216be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
217be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
218be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
21984958305SKirill A. ShutemovQEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
220be17dc90SMichael S. TsirkinQEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
221be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
222be17dc90SMichael S. Tsirkin
223a21493e0SBlue Swirlgcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
224a21493e0SBlue Swirlgcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
2250b65b9e1SBlue Swirlgcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
226a21493e0SBlue Swirlgcc_flags="-fstack-protector-all $gcc_flags"
227be17dc90SMichael S. Tsirkincat > $TMPC << EOF
228aa527b65SAurelien Jarnoint main(void) { return 0; }
229be17dc90SMichael S. TsirkinEOF
230be17dc90SMichael S. Tsirkinfor flag in $gcc_flags; do
231aa527b65SAurelien Jarno    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
2321e027be7SMarkus Armbruster	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
233be17dc90SMichael S. Tsirkin    fi
234be17dc90SMichael S. Tsirkindone
235be17dc90SMichael S. Tsirkin
236ac0df51dSaliguori# check that the C compiler works.
237ac0df51dSaliguoricat > $TMPC <<EOF
238ac0df51dSaliguoriint main(void) {}
239ac0df51dSaliguoriEOF
240ac0df51dSaliguori
24152166aa0SJuan Quintelaif compile_object ; then
242ac0df51dSaliguori  : C compiler works ok
243ac0df51dSaliguorielse
244ac0df51dSaliguori    echo "ERROR: \"$cc\" either does not exist or does not work"
245ac0df51dSaliguori    exit 1
246ac0df51dSaliguorifi
247ac0df51dSaliguori
248ac0df51dSaliguoricheck_define() {
249ac0df51dSaliguoricat > $TMPC <<EOF
250ac0df51dSaliguori#if !defined($1)
251ac0df51dSaliguori#error Not defined
252ac0df51dSaliguori#endif
253ac0df51dSaliguoriint main(void) { return 0; }
254ac0df51dSaliguoriEOF
25552166aa0SJuan Quintela  compile_object
256ac0df51dSaliguori}
257ac0df51dSaliguori
2582ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
2592ff6b91eSJuan Quintela  # command line argument
2602ff6b91eSJuan Quintela  :
2612ff6b91eSJuan Quintelaelif check_define __i386__ ; then
262ac0df51dSaliguori  cpu="i386"
263ac0df51dSaliguorielif check_define __x86_64__ ; then
264ac0df51dSaliguori  cpu="x86_64"
2653aa9bd6cSblueswir1elif check_define __sparc__ ; then
2663aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
2673aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
2683aa9bd6cSblueswir1  if check_define __arch64__ ; then
2693aa9bd6cSblueswir1    cpu="sparc64"
2703aa9bd6cSblueswir1  else
2713aa9bd6cSblueswir1    cpu="sparc"
2723aa9bd6cSblueswir1  fi
273fdf7ed96Smalcelif check_define _ARCH_PPC ; then
274fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
275fdf7ed96Smalc    cpu="ppc64"
276ac0df51dSaliguori  else
277fdf7ed96Smalc    cpu="ppc"
278fdf7ed96Smalc  fi
279afa05235SAurelien Jarnoelif check_define __mips__ ; then
280afa05235SAurelien Jarno  cpu="mips"
281477ba620SAurelien Jarnoelif check_define __ia64__ ; then
282477ba620SAurelien Jarno  cpu="ia64"
283d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
284d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
285d66ed0eaSAurelien Jarno    cpu="s390x"
286d66ed0eaSAurelien Jarno  else
287d66ed0eaSAurelien Jarno    cpu="s390"
288d66ed0eaSAurelien Jarno  fi
289fdf7ed96Smalcelse
290fdf7ed96Smalc  cpu=`uname -m`
291ac0df51dSaliguorifi
292ac0df51dSaliguori
2937d13299dSbellardcase "$cpu" in
294afa05235SAurelien Jarno  alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
295ea8f20f8SJuan Quintela    cpu="$cpu"
296ea8f20f8SJuan Quintela  ;;
2977d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
29897a847bcSbellard    cpu="i386"
2997d13299dSbellard  ;;
300aaa5fa14Saurel32  x86_64|amd64)
301aaa5fa14Saurel32    cpu="x86_64"
302aaa5fa14Saurel32  ;;
303ba68055eSbellard  armv*b)
304808c4954Sbellard    cpu="armv4b"
305808c4954Sbellard  ;;
306ba68055eSbellard  armv*l)
3077d13299dSbellard    cpu="armv4l"
3087d13299dSbellard  ;;
309f54b3f92Saurel32  parisc|parisc64)
310f54b3f92Saurel32    cpu="hppa"
311f54b3f92Saurel32  ;;
312afa05235SAurelien Jarno  mips*)
313afa05235SAurelien Jarno    cpu="mips"
314afa05235SAurelien Jarno  ;;
31524e804ecSAlexander Graf  s390)
316fb3e5849Sbellard    cpu="s390"
317fb3e5849Sbellard  ;;
31824e804ecSAlexander Graf  s390x)
31924e804ecSAlexander Graf    cpu="s390x"
32024e804ecSAlexander Graf  ;;
3213142255cSblueswir1  sparc|sun4[cdmuv])
322ae228531Sbellard    cpu="sparc"
323ae228531Sbellard  ;;
3247d13299dSbellard  *)
325a447d4dcSPaolo Bonzini    echo "Unsupported CPU = $cpu"
326a447d4dcSPaolo Bonzini    exit 1
3277d13299dSbellard  ;;
3287d13299dSbellardesac
329e2d52ad3SJuan Quintela
3307d13299dSbellard# OS specific
331ac0df51dSaliguoriif check_define __linux__ ; then
332ac0df51dSaliguori  targetos="Linux"
333ac0df51dSaliguorielif check_define _WIN32 ; then
334ac0df51dSaliguori  targetos='MINGW32'
335169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
336169dc5d3Sblueswir1  targetos='OpenBSD'
337169dc5d3Sblueswir1elif check_define __sun__ ; then
338169dc5d3Sblueswir1  targetos='SunOS'
339179cf400SAndreas Färberelif check_define __HAIKU__ ; then
340179cf400SAndreas Färber  targetos='Haiku'
341ac0df51dSaliguorielse
3427d13299dSbellard  targetos=`uname -s`
343ac0df51dSaliguorifi
3440dbfc675SJuan Quintela
3457d13299dSbellardcase $targetos in
346c326e0afSbellardCYGWIN*)
347c326e0afSbellard  mingw32="yes"
348a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
349d5631638Smalc  audio_possible_drivers="winwave sdl"
350d5631638Smalc  audio_drv_list="winwave"
351c326e0afSbellard;;
35267b915a5SbellardMINGW32*)
35367b915a5Sbellard  mingw32="yes"
354d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
355d5631638Smalc  audio_drv_list="winwave"
35667b915a5Sbellard;;
3575c40d2bdSthsGNU/kFreeBSD)
358a167ba50SAurelien Jarno  bsd="yes"
3590c58ac1cSmalc  audio_drv_list="oss"
360f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3615c40d2bdSths;;
3627d3505c5SbellardFreeBSD)
3637d3505c5Sbellard  bsd="yes"
3640db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3650c58ac1cSmalc  audio_drv_list="oss"
366f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
367f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
368f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3697d3505c5Sbellard;;
370c5e97233Sblueswir1DragonFly)
371c5e97233Sblueswir1  bsd="yes"
3720db4a067SPaolo Bonzini  make="${MAKE-gmake}"
373c5e97233Sblueswir1  audio_drv_list="oss"
374c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
375c5e97233Sblueswir1;;
3767d3505c5SbellardNetBSD)
3777d3505c5Sbellard  bsd="yes"
3780db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3790c58ac1cSmalc  audio_drv_list="oss"
380c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3818ef92a88Sblueswir1  oss_lib="-lossaudio"
3827d3505c5Sbellard;;
3837d3505c5SbellardOpenBSD)
3847d3505c5Sbellard  bsd="yes"
3850db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3860c58ac1cSmalc  audio_drv_list="oss"
387c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3882f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3897d3505c5Sbellard;;
39083fb7adfSbellardDarwin)
39183fb7adfSbellard  bsd="yes"
39283fb7adfSbellard  darwin="yes"
3930dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3940dbfc675SJuan Quintela  # run 64-bit userspace code
395aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3961b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
397aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3981b0f9cc2Saliguori  fi
3991b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
400a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4010c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4021b0f9cc2Saliguori  else
403a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
4041b0f9cc2Saliguori  fi
405831b7825Sths  darwin_user="yes"
406fd677642Sths  cocoa="yes"
4070c58ac1cSmalc  audio_drv_list="coreaudio"
408c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4090c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4107973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
41183fb7adfSbellard;;
412ec530c81SbellardSunOS)
413ec530c81Sbellard  solaris="yes"
4140db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4150db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
416fa58948dSBlue Swirl  ld="gld"
4170475a5caSths  needs_libsunmath="no"
418c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
419ef18c883Sths  # have to select again, because `uname -m` returns i86pc
420ef18c883Sths  # even on an x86_64 box.
421ef18c883Sths  solariscpu=`isainfo -k`
422ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
423ef18c883Sths    cpu="x86_64"
424ef18c883Sths  fi
425c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4260475a5caSths    if test "$solarisrev" -le 9 ; then
4270475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4280475a5caSths        needs_libsunmath="yes"
429f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
430f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
431f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4320475a5caSths      else
4330475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4340475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4350475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4360475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4370475a5caSths        exit 1
4380475a5caSths      fi
4390475a5caSths    fi
44086b2bd93Sths  fi
4416b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4420c58ac1cSmalc    audio_drv_list="oss"
4436b4d2ba1Sths  fi
444c2de5c91Smalc  audio_possible_drivers="oss sdl"
445d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
446d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
447d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
448d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
449a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
450e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
451ec530c81Sbellard;;
452b29fe3edSmalcAIX)
453b29fe3edSmalc  aix="yes"
4540db4a067SPaolo Bonzini  make="${MAKE-gmake}"
455b29fe3edSmalc;;
456179cf400SAndreas FärberHaiku)
457179cf400SAndreas Färber  haiku="yes"
458179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
459179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
460179cf400SAndreas Färber;;
461fb065187Sbellard*)
4620c58ac1cSmalc  audio_drv_list="oss"
463b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4645327cf48Sbellard  linux="yes"
465831b7825Sths  linux_user="yes"
46668063649Sblueswir1  usb="linux"
46707f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
468c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
469c9ec1fe4Sbellard  fi
470fb065187Sbellard;;
4717d13299dSbellardesac
4727d13299dSbellard
4737d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
474b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
47568063649Sblueswir1    usb="bsd"
47683fb7adfSbellard  fi
47784778508Sblueswir1  bsd_user="yes"
4787d3505c5Sbellardfi
4797d3505c5Sbellard
4800db4a067SPaolo Bonzini: ${make=${MAKE-make}}
4810db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
4820db4a067SPaolo Bonzini
4833457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4843457a3f8SJuan Quintela  EXESUF=".exe"
485a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
486e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
487e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
488884044aaSJuan Quintela  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
489683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
490683035deSPaolo Bonzini  mandir="\${prefix}"
491683035deSPaolo Bonzini  datadir="\${prefix}"
492683035deSPaolo Bonzini  docdir="\${prefix}"
493683035deSPaolo Bonzini  bindir="\${prefix}"
494683035deSPaolo Bonzini  sysconfdir="\${prefix}"
495683035deSPaolo Bonzini  confsuffix=""
4963457a3f8SJuan Quintelafi
4973457a3f8SJuan Quintela
4987d13299dSbellard# find source path
499ad064840Spbrooksource_path=`dirname "$0"`
50059faef3aSbalrogsource_path_used="no"
50159faef3aSbalrogworkdir=`pwd`
502ad064840Spbrookif [ -z "$source_path" ]; then
50359faef3aSbalrog    source_path=$workdir
504ad064840Spbrookelse
505ad064840Spbrook    source_path=`cd "$source_path"; pwd`
5067d13299dSbellardfi
507724db118Spbrook[ -f "$workdir/vl.c" ] || source_path_used="yes"
5087d13299dSbellard
509487fefdbSAnthony Liguoriwerror=""
51085aa5189Sbellard
5117d13299dSbellardfor opt do
512a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
5137d13299dSbellard  case "$opt" in
5142efc3265Sbellard  --help|-h) show_help=yes
5152efc3265Sbellard  ;;
516b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5177d13299dSbellard  ;;
518b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
51932ce6337Sbellard  ;;
520b1a550a0Spbrook  --source-path=*) source_path="$optarg"
521ad064840Spbrook  source_path_used="yes"
5227d13299dSbellard  ;;
523ac0df51dSaliguori  --cross-prefix=*)
5247d13299dSbellard  ;;
525ac0df51dSaliguori  --cc=*)
5267d13299dSbellard  ;;
527b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
52883469015Sbellard  ;;
529b1a550a0Spbrook  --make=*) make="$optarg"
5307d13299dSbellard  ;;
5316a882643Spbrook  --install=*) install="$optarg"
5326a882643Spbrook  ;;
533e2a2ed06SJuan Quintela  --extra-cflags=*)
5347d13299dSbellard  ;;
535e2a2ed06SJuan Quintela  --extra-ldflags=*)
5367d13299dSbellard  ;;
5372ff6b91eSJuan Quintela  --cpu=*)
5387d13299dSbellard  ;;
539b1a550a0Spbrook  --target-list=*) target_list="$optarg"
540de83cd02Sbellard  ;;
54194a420b1SStefan Hajnoczi  --trace-backend=*) trace_backend="$optarg"
54294a420b1SStefan Hajnoczi  ;;
5439410b56cSPrerna Saxena  --trace-file=*) trace_file="$optarg"
5449410b56cSPrerna Saxena  ;;
5457d13299dSbellard  --enable-gprof) gprof="yes"
5467d13299dSbellard  ;;
54779427693SLoïc Minier  --static)
54879427693SLoïc Minier    static="yes"
54979427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
55043ce4dfeSbellard  ;;
5510b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5520b24e75fSPaolo Bonzini  ;;
5530b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5540b24e75fSPaolo Bonzini  ;;
5550b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5560b24e75fSPaolo Bonzini  ;;
5570b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5580b24e75fSPaolo Bonzini  ;;
559ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
56007381cc1SAnthony Liguori  ;;
56197a847bcSbellard  --disable-sdl) sdl="no"
56297a847bcSbellard  ;;
563c4198157SJuan Quintela  --enable-sdl) sdl="yes"
564c4198157SJuan Quintela  ;;
565b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
566102a52e4Sbellard  ;;
567c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
568c2de5c91Smalc  ;;
5692f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5702f6a1ab0Sblueswir1  ;;
5712fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5720c58ac1cSmalc  ;;
5730c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5740c58ac1cSmalc  ;;
575eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
576eb852011SMarkus Armbruster  ;;
577f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
578f8393946Saurel32  ;;
579f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
580f8393946Saurel32  ;;
581b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
582b4475aa2SLuiz Capitulino  ;;
583b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
584b4475aa2SLuiz Capitulino  ;;
585f3d08ee6SPaul Brook  --enable-debug)
586f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
587f3d08ee6SPaul Brook      debug_tcg="yes"
588b4475aa2SLuiz Capitulino      debug_mon="yes"
589f3d08ee6SPaul Brook      debug="yes"
590f3d08ee6SPaul Brook      strip_opt="no"
591f3d08ee6SPaul Brook  ;;
59203b4fe7dSaliguori  --enable-sparse) sparse="yes"
59303b4fe7dSaliguori  ;;
59403b4fe7dSaliguori  --disable-sparse) sparse="no"
59503b4fe7dSaliguori  ;;
5961625af87Saliguori  --disable-strip) strip_opt="no"
5971625af87Saliguori  ;;
5988d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5998d5d2d4cSths  ;;
6001be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
6011be10ad2SJuan Quintela  ;;
6022f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
6032f9606b3Saliguori  ;;
604ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
605ea784e3bSJuan Quintela  ;;
6062f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
6072f6f5c7aSCorentin Chary  ;;
6082f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
6092f6f5c7aSCorentin Chary  ;;
610efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
611efe556adSCorentin Chary  ;;
612efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
613efe556adSCorentin Chary  ;;
614bd023f95SCorentin Chary  --disable-vnc-thread) vnc_thread="no"
615bd023f95SCorentin Chary  ;;
616bd023f95SCorentin Chary  --enable-vnc-thread) vnc_thread="yes"
617bd023f95SCorentin Chary  ;;
618443f1376Sbellard  --disable-slirp) slirp="no"
619c20709aaSbellard  ;;
620ee682d27SStefan Weil  --disable-uuid) uuid="no"
621ee682d27SStefan Weil  ;;
622ee682d27SStefan Weil  --enable-uuid) uuid="yes"
623ee682d27SStefan Weil  ;;
624e0e6c8c0Saliguori  --disable-vde) vde="no"
6258a16d273Sths  ;;
626dfb278bdSJuan Quintela  --enable-vde) vde="yes"
627dfb278bdSJuan Quintela  ;;
628e37630caSaliguori  --disable-xen) xen="no"
629e37630caSaliguori  ;;
630fc321b4bSJuan Quintela  --enable-xen) xen="yes"
631fc321b4bSJuan Quintela  ;;
6322e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
6332e4d9fb1Saurel32  ;;
6344ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6354ffcedb6SJuan Quintela  ;;
636fb599c9aSbalrog  --disable-bluez) bluez="no"
637fb599c9aSbalrog  ;;
638a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
639a20a6f46SJuan Quintela  ;;
6407ba1e619Saliguori  --disable-kvm) kvm="no"
6417ba1e619Saliguori  ;;
642b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
643b31a0277SJuan Quintela  ;;
644cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
645cd4ec0b4SGerd Hoffmann  ;;
646cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
647cd4ec0b4SGerd Hoffmann  ;;
64805c2a3e7Sbellard  --enable-profiler) profiler="yes"
64905c2a3e7Sbellard  ;;
650c2de5c91Smalc  --enable-cocoa)
651c2de5c91Smalc      cocoa="yes" ;
652c2de5c91Smalc      sdl="no" ;
653c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6545b0753e0Sbellard  ;;
655cad25d69Spbrook  --disable-system) softmmu="no"
6560a8e90f4Spbrook  ;;
657cad25d69Spbrook  --enable-system) softmmu="yes"
6580a8e90f4Spbrook  ;;
6590953a80fSZachary Amsden  --disable-user)
6600953a80fSZachary Amsden      linux_user="no" ;
6610953a80fSZachary Amsden      bsd_user="no" ;
6620953a80fSZachary Amsden      darwin_user="no"
6630953a80fSZachary Amsden  ;;
6640953a80fSZachary Amsden  --enable-user) ;;
665831b7825Sths  --disable-linux-user) linux_user="no"
6660a8e90f4Spbrook  ;;
667831b7825Sths  --enable-linux-user) linux_user="yes"
668831b7825Sths  ;;
669831b7825Sths  --disable-darwin-user) darwin_user="no"
670831b7825Sths  ;;
671831b7825Sths  --enable-darwin-user) darwin_user="yes"
6720a8e90f4Spbrook  ;;
67384778508Sblueswir1  --disable-bsd-user) bsd_user="no"
67484778508Sblueswir1  ;;
67584778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
67684778508Sblueswir1  ;;
677379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
678379f6698SPaul Brook  ;;
679379f6698SPaul Brook  --disable-guest-base) guest_base="no"
680379f6698SPaul Brook  ;;
68134005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
68234005a00SKirill A. Shutemov  ;;
68334005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
68434005a00SKirill A. Shutemov  ;;
685c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
686c5937220Spbrook  ;;
6873142255cSblueswir1  --sparc_cpu=*)
6883142255cSblueswir1  ;;
68985aa5189Sbellard  --enable-werror) werror="yes"
69085aa5189Sbellard  ;;
69185aa5189Sbellard  --disable-werror) werror="no"
69285aa5189Sbellard  ;;
6934d3b6f6eSbalrog  --disable-curses) curses="no"
6944d3b6f6eSbalrog  ;;
695c584a6d0SJuan Quintela  --enable-curses) curses="yes"
696c584a6d0SJuan Quintela  ;;
697769ce76dSAlexander Graf  --disable-curl) curl="no"
698769ce76dSAlexander Graf  ;;
699788c8196SJuan Quintela  --enable-curl) curl="yes"
700788c8196SJuan Quintela  ;;
7012df87df7SJuan Quintela  --disable-fdt) fdt="no"
7022df87df7SJuan Quintela  ;;
7032df87df7SJuan Quintela  --enable-fdt) fdt="yes"
7042df87df7SJuan Quintela  ;;
7055495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
7065495ed11SLuiz Capitulino  ;;
7075495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
7085495ed11SLuiz Capitulino  ;;
709bd0c5661Spbrook  --disable-nptl) nptl="no"
710bd0c5661Spbrook  ;;
711b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
712b0a47e79SJuan Quintela  ;;
7138ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
7148ff9cbf7Smalc  ;;
7155c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
7165c6c3a6cSChristoph Hellwig  ;;
7175c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
7185c6c3a6cSChristoph Hellwig  ;;
719758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
720758e8e38SVenkateswararao Jujjuri (JV)  ;;
721758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
722758e8e38SVenkateswararao Jujjuri (JV)  ;;
723e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
724e5d355d1Saliguori  ;;
72577755340Sths  --disable-blobs) blobs="no"
72677755340Sths  ;;
727eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
728eac30262Saliguori  ;;
7294a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
7304a19f1ecSpbrook  ;;
731a25dba17SJuan Quintela  --disable-docs) docs="no"
73270ec5dc0SAnthony Liguori  ;;
733a25dba17SJuan Quintela  --enable-docs) docs="yes"
73483a3ab8bSJuan Quintela  ;;
735d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
736d5970055SMichael S. Tsirkin  ;;
737d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
738d5970055SMichael S. Tsirkin  ;;
7396bde81cbSPaolo Bonzini  --*dir)
7406bde81cbSPaolo Bonzini  ;;
741f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
742f27aaf4bSChristian Brunner  ;;
743f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
744f27aaf4bSChristian Brunner  ;;
7457f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7467f1559c6Sbalrog  ;;
7477d13299dSbellard  esac
7487d13299dSbellarddone
7497d13299dSbellard
7503142255cSblueswir1#
7513142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
752a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7533142255cSblueswir1#
754379f6698SPaul Brookhost_guest_base="no"
75540293e58Sbellardcase "$cpu" in
756ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
757ed968ff1SJuan Quintela           v7|v8)
758a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
759ed968ff1SJuan Quintela           ;;
760ed968ff1SJuan Quintela           v8plus|v8plusa)
761a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
762ed968ff1SJuan Quintela           ;;
763ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
764a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
765ed968ff1SJuan Quintela           esac
7660c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
767a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
768762e8230Sblueswir1           if test "$solaris" = "no" ; then
769a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
770c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
771762e8230Sblueswir1           fi
7723142255cSblueswir1           ;;
773ed968ff1SJuan Quintela    sparc64)
774a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7750c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
776a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
777ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
778a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
779762e8230Sblueswir1           fi
7803142255cSblueswir1           ;;
78176d83bdeSths    s390)
78228d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
78328d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
78448bb3750SRichard Henderson           host_guest_base="yes"
78528d7cc49SRichard Henderson           ;;
78628d7cc49SRichard Henderson    s390x)
78728d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
78828d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
78948bb3750SRichard Henderson           host_guest_base="yes"
79076d83bdeSths           ;;
79140293e58Sbellard    i386)
792a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
7930c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
7942b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
795c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
796379f6698SPaul Brook           host_guest_base="yes"
79740293e58Sbellard           ;;
79840293e58Sbellard    x86_64)
799a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
8000c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8012b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
802379f6698SPaul Brook           host_guest_base="yes"
803379f6698SPaul Brook           ;;
804379f6698SPaul Brook    arm*)
805379f6698SPaul Brook           host_guest_base="yes"
80640293e58Sbellard           ;;
807f6548c0aSmalc    ppc*)
808f6548c0aSmalc           host_guest_base="yes"
809f6548c0aSmalc           ;;
810cc01cc8eSAurelien Jarno    mips*)
811cc01cc8eSAurelien Jarno           host_guest_base="yes"
812cc01cc8eSAurelien Jarno           ;;
813477ba620SAurelien Jarno    ia64*)
814477ba620SAurelien Jarno           host_guest_base="yes"
815477ba620SAurelien Jarno           ;;
816fd76e73aSRichard Henderson    hppa*)
817fd76e73aSRichard Henderson           host_guest_base="yes"
818fd76e73aSRichard Henderson           ;;
8193142255cSblueswir1esac
8203142255cSblueswir1
821379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
822379f6698SPaul Brook
823af5db58eSpbrookif test x"$show_help" = x"yes" ; then
824af5db58eSpbrookcat << EOF
825af5db58eSpbrook
826af5db58eSpbrookUsage: configure [options]
827af5db58eSpbrookOptions: [defaults in brackets after descriptions]
828af5db58eSpbrook
829af5db58eSpbrookEOF
830af5db58eSpbrookecho "Standard options:"
831af5db58eSpbrookecho "  --help                   print this message"
832af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
833af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
834af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
835af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
836af5db58eSpbrookecho ""
837af5db58eSpbrookecho "Advanced options (experts only):"
838af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
839af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
840af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
8410bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
8420bfe8cc0SPaolo Bonziniecho "                           build time"
843a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
844e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
845af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
8466a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
847af5db58eSpbrookecho "  --static                 enable static build [$static]"
8480b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
8490b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
8500b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
8510b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
8520b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
853f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
854f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
85509695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
856890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
857890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
8581625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
85985aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
860fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
861c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
862af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
863c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
864c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
8654c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
8664c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
867eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
868eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
8698ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
870e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
871fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
8722e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
8734ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
8748d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
8751be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
8762f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
877ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
8782f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
8792f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
88096763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
881efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
882bd023f95SCorentin Charyecho "  --disable-vnc-thread     disable threaded VNC server"
883bd023f95SCorentin Charyecho "  --enable-vnc-thread      enable threaded VNC server"
884af896aaaSpbrookecho "  --disable-curses         disable curses output"
885c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
886769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
887788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
8882df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
8892df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
8905495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
8915495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
892fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
893a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
8947ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
895b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
896bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
897e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
898af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
899af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
9000953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
9010953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
902831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
903831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
904831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
905831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
90684778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
90784778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
908379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
909379f6698SPaul Brookecho "                           emulation targets"
910379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
91134005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
91234005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
913af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
914af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
9152f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
916c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
9173142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
918ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
919ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
920e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
921dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
9225c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
9235c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
924758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
925758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
926e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
92777755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
928eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
929d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
930d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
931d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
932d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
933b3d08c02SDaniel P. Berrangeecho "  --trace-backend=B        Trace backend nop simple ust dtrace"
9349410b56cSPrerna Saxenaecho "  --trace-file=NAME        Full PATH,NAME of file to store traces"
9359410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
936cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
937cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
938f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
939af5db58eSpbrookecho ""
9405bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
941af5db58eSpbrookexit 1
942af5db58eSpbrookfi
943af5db58eSpbrook
944ec530c81Sbellard#
945ec530c81Sbellard# Solaris specific configure tool chain decisions
946ec530c81Sbellard#
947ec530c81Sbellardif test "$solaris" = "yes" ; then
9486792aa11SLoïc Minier  if has $install; then
9496792aa11SLoïc Minier    :
9506792aa11SLoïc Minier  else
951ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
952ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
953ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
954ec530c81Sbellard    exit 1
955ec530c81Sbellard  fi
9566792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
957ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
958ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
959ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
960ec530c81Sbellard    exit 1
961ec530c81Sbellard  fi
9626792aa11SLoïc Minier  if has ar; then
9636792aa11SLoïc Minier    :
9646792aa11SLoïc Minier  else
965ec530c81Sbellard    echo "Error: No path includes ar"
966ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
967ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
968ec530c81Sbellard    fi
969ec530c81Sbellard    exit 1
970ec530c81Sbellard  fi
971ec530c81Sbellardfi
972ec530c81Sbellard
973ec530c81Sbellard
9745327cf48Sbellardif test -z "$target_list" ; then
9755327cf48Sbellard# these targets are portable
9760a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
9772408a527Saurel32        target_list="\
9782408a527Saurel32i386-softmmu \
9792408a527Saurel32x86_64-softmmu \
9802408a527Saurel32arm-softmmu \
9812408a527Saurel32cris-softmmu \
9822408a527Saurel32m68k-softmmu \
98372b675caSEdgar E. Iglesiasmicroblaze-softmmu \
9842408a527Saurel32mips-softmmu \
9852408a527Saurel32mipsel-softmmu \
9862408a527Saurel32mips64-softmmu \
9872408a527Saurel32mips64el-softmmu \
9882408a527Saurel32ppc-softmmu \
9892408a527Saurel32ppcemb-softmmu \
9902408a527Saurel32ppc64-softmmu \
9912408a527Saurel32sh4-softmmu \
9922408a527Saurel32sh4eb-softmmu \
9932408a527Saurel32sparc-softmmu \
9941b64fcaeSIgor V. Kovalenkosparc64-softmmu \
9952408a527Saurel32"
9960a8e90f4Spbrook    fi
9975327cf48Sbellard# the following are Linux specific
998831b7825Sths    if [ "$linux_user" = "yes" ] ; then
9992408a527Saurel32        target_list="${target_list}\
10002408a527Saurel32i386-linux-user \
10012408a527Saurel32x86_64-linux-user \
10022408a527Saurel32alpha-linux-user \
10032408a527Saurel32arm-linux-user \
10042408a527Saurel32armeb-linux-user \
10052408a527Saurel32cris-linux-user \
10062408a527Saurel32m68k-linux-user \
100772b675caSEdgar E. Iglesiasmicroblaze-linux-user \
10082408a527Saurel32mips-linux-user \
10092408a527Saurel32mipsel-linux-user \
10102408a527Saurel32ppc-linux-user \
10112408a527Saurel32ppc64-linux-user \
10122408a527Saurel32ppc64abi32-linux-user \
10132408a527Saurel32sh4-linux-user \
10142408a527Saurel32sh4eb-linux-user \
10152408a527Saurel32sparc-linux-user \
10162408a527Saurel32sparc64-linux-user \
10172408a527Saurel32sparc32plus-linux-user \
10182408a527Saurel32"
1019831b7825Sths    fi
1020831b7825Sths# the following are Darwin specific
1021831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
10222408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
10235327cf48Sbellard    fi
102484778508Sblueswir1# the following are BSD specific
102584778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
102684778508Sblueswir1        target_list="${target_list}\
102731fc12dfSblueswir1i386-bsd-user \
102831fc12dfSblueswir1x86_64-bsd-user \
102931fc12dfSblueswir1sparc-bsd-user \
103084778508Sblueswir1sparc64-bsd-user \
103184778508Sblueswir1"
103284778508Sblueswir1    fi
10336e20a45fSbellardelse
1034b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
10355327cf48Sbellardfi
10360a8e90f4Spbrookif test -z "$target_list" ; then
10370a8e90f4Spbrook    echo "No targets enabled"
10380a8e90f4Spbrook    exit 1
10390a8e90f4Spbrookfi
1040f55fe278SPaolo Bonzini# see if system emulation was really requested
1041f55fe278SPaolo Bonzinicase " $target_list " in
1042f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1043f55fe278SPaolo Bonzini  ;;
1044f55fe278SPaolo Bonzini  *) softmmu=no
1045f55fe278SPaolo Bonzini  ;;
1046f55fe278SPaolo Bonziniesac
10475327cf48Sbellard
1048249247c9SJuan Quintelafeature_not_found() {
1049249247c9SJuan Quintela  feature=$1
1050249247c9SJuan Quintela
1051249247c9SJuan Quintela  echo "ERROR"
1052249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
10539332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1054249247c9SJuan Quintela  echo "ERROR"
1055249247c9SJuan Quintela  exit 1;
1056249247c9SJuan Quintela}
1057249247c9SJuan Quintela
10587d13299dSbellardif test -z "$cross_prefix" ; then
10597d13299dSbellard
10607d13299dSbellard# ---
10617d13299dSbellard# big/little endian test
10627d13299dSbellardcat > $TMPC << EOF
10637d13299dSbellard#include <inttypes.h>
10647d13299dSbellardint main(int argc, char ** argv){
10657d13299dSbellard        volatile uint32_t i=0x01234567;
10667d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
10677d13299dSbellard}
10687d13299dSbellardEOF
10697d13299dSbellard
107052166aa0SJuan Quintelaif compile_prog "" "" ; then
10717d13299dSbellard$TMPE && bigendian="yes"
10727d13299dSbellardelse
10737d13299dSbellardecho big/little test failed
10747d13299dSbellardfi
10757d13299dSbellard
10767d13299dSbellardelse
10777d13299dSbellard
10787d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1079ea8f20f8SJuan Quintelacase "$cpu" in
108024e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1081ea8f20f8SJuan Quintela    bigendian=yes
1082ea8f20f8SJuan Quintela  ;;
1083ea8f20f8SJuan Quintelaesac
10847d13299dSbellard
10857d13299dSbellardfi
10867d13299dSbellard
1087b6853697Sbellard# host long bits test
1088b6853697Sbellardhostlongbits="32"
1089ea8f20f8SJuan Quintelacase "$cpu" in
109024e804ecSAlexander Graf  x86_64|alpha|ia64|sparc64|ppc64|s390x)
1091ea8f20f8SJuan Quintela    hostlongbits=64
1092ea8f20f8SJuan Quintela  ;;
1093ea8f20f8SJuan Quintelaesac
1094b6853697Sbellard
1095b0a47e79SJuan Quintela
1096b0a47e79SJuan Quintela##########################################
1097b0a47e79SJuan Quintela# NPTL probe
1098b0a47e79SJuan Quintela
1099b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1100bd0c5661Spbrook  cat > $TMPC <<EOF
1101bd0c5661Spbrook#include <sched.h>
110230813ceaSpbrook#include <linux/futex.h>
1103bd0c5661Spbrookvoid foo()
1104bd0c5661Spbrook{
1105bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1106bd0c5661Spbrook#error bork
1107bd0c5661Spbrook#endif
1108bd0c5661Spbrook}
1109bd0c5661SpbrookEOF
1110bd0c5661Spbrook
111152166aa0SJuan Quintela  if compile_object ; then
1112b0a47e79SJuan Quintela    nptl=yes
1113bd0c5661Spbrook  else
1114b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1115b0a47e79SJuan Quintela      feature_not_found "nptl"
1116b0a47e79SJuan Quintela    fi
1117b0a47e79SJuan Quintela    nptl=no
1118b0a47e79SJuan Quintela  fi
1119bd0c5661Spbrookfi
1120bd0c5661Spbrook
112111d9f695Sbellard##########################################
1122ac62922eSbalrog# zlib check
1123ac62922eSbalrog
1124ac62922eSbalrogcat > $TMPC << EOF
1125ac62922eSbalrog#include <zlib.h>
1126ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1127ac62922eSbalrogEOF
112852166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
1129ac62922eSbalrog    :
1130ac62922eSbalrogelse
1131ac62922eSbalrog    echo
1132ac62922eSbalrog    echo "Error: zlib check failed"
1133ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
1134ac62922eSbalrog    echo
1135ac62922eSbalrog    exit 1
1136ac62922eSbalrogfi
1137ac62922eSbalrog
1138ac62922eSbalrog##########################################
1139e37630caSaliguori# xen probe
1140e37630caSaliguori
1141fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1142b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1143e37630caSaliguori  cat > $TMPC <<EOF
1144e37630caSaliguori#include <xenctrl.h>
1145e37630caSaliguori#include <xs.h>
1146df7a607bSChristoph Eggerint main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1147e37630caSaliguoriEOF
114852166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1149fc321b4bSJuan Quintela    xen=yes
11503efd632bSJuan Quintela    libs_softmmu="$xen_libs $libs_softmmu"
1151e37630caSaliguori  else
1152fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1153fc321b4bSJuan Quintela      feature_not_found "xen"
1154fc321b4bSJuan Quintela    fi
1155fc321b4bSJuan Quintela    xen=no
1156e37630caSaliguori  fi
1157e37630caSaliguorifi
1158e37630caSaliguori
1159e37630caSaliguori##########################################
1160f91672e5SPaolo Bonzini# pkgconfig probe
1161f91672e5SPaolo Bonzini
1162f91672e5SPaolo Bonzinipkgconfig="${cross_prefix}pkg-config"
11630dba6195SLoïc Minierif ! has $pkgconfig; then
1164f91672e5SPaolo Bonzini  # likely not cross compiling, or hope for the best
1165f91672e5SPaolo Bonzini  pkgconfig=pkg-config
1166f91672e5SPaolo Bonzinifi
1167f91672e5SPaolo Bonzini
1168f91672e5SPaolo Bonzini##########################################
1169dfffc653SJuan Quintela# Sparse probe
1170dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
11710dba6195SLoïc Minier  if has cgcc; then
1172dfffc653SJuan Quintela    sparse=yes
1173dfffc653SJuan Quintela  else
1174dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1175dfffc653SJuan Quintela      feature_not_found "sparse"
1176dfffc653SJuan Quintela    fi
1177dfffc653SJuan Quintela    sparse=no
1178dfffc653SJuan Quintela  fi
1179dfffc653SJuan Quintelafi
1180dfffc653SJuan Quintela
1181dfffc653SJuan Quintela##########################################
118211d9f695Sbellard# SDL probe
118311d9f695Sbellard
1184fec0e3e8SStefan Weil# Look for sdl configuration program (pkg-config or sdl-config).
1185fec0e3e8SStefan Weil# Prefer variant with cross prefix if cross compiling,
1186fec0e3e8SStefan Weil# and favour pkg-config with sdl over sdl-config.
1187fec0e3e8SStefan Weilif test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
1188fec0e3e8SStefan Weil     $pkgconfig sdl --modversion >/dev/null 2>&1; then
1189fec0e3e8SStefan Weil  sdlconfig="$pkgconfig sdl"
1190fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1191fec0e3e8SStefan Weilelif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
1192fec0e3e8SStefan Weil  sdlconfig="${cross_prefix}sdl-config"
1193fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1194fec0e3e8SStefan Weilelif $pkgconfig sdl --modversion >/dev/null 2>&1; then
11959316f803SPaolo Bonzini  sdlconfig="$pkgconfig sdl"
11969316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
11970dba6195SLoïc Minierelif has sdl-config; then
11989316f803SPaolo Bonzini  sdlconfig='sdl-config'
11999316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1200a0dfd8a4SLoïc Minierelse
1201a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1202a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1203a0dfd8a4SLoïc Minier  fi
1204a0dfd8a4SLoïc Minier  sdl=no
12059316f803SPaolo Bonzinifi
120611d9f695Sbellard
12079316f803SPaolo Bonzinisdl_too_old=no
1208c4198157SJuan Quintelaif test "$sdl" != "no" ; then
120911d9f695Sbellard  cat > $TMPC << EOF
121011d9f695Sbellard#include <SDL.h>
121111d9f695Sbellard#undef main /* We don't want SDL to override our main() */
121211d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
121311d9f695SbellardEOF
12149316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
121574f42e18STeLeMan  if test "$static" = "yes" ; then
121674f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
121774f42e18STeLeMan  else
12189316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
121974f42e18STeLeMan  fi
122052166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
122111d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
122211d9f695Sbellard      sdl_too_old=yes
122311d9f695Sbellard    else
1224fd677642Sths      if test "$cocoa" = "no" ; then
122511d9f695Sbellard        sdl=yes
122611d9f695Sbellard      fi
1227fd677642Sths    fi
12287c1f25b4Sbellard
122967c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
12301ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
123167c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1232f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1233f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
123411d9f695Sbellard      fi
123552166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
12361ac88f28SJuan Quintela	:
12371ac88f28SJuan Quintela      else
12381ac88f28SJuan Quintela        sdl=no
12397c1f25b4Sbellard      fi
12407c1f25b4Sbellard    fi # static link
1241c4198157SJuan Quintela  else # sdl not found
1242c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1243c4198157SJuan Quintela      feature_not_found "sdl"
1244c4198157SJuan Quintela    fi
1245c4198157SJuan Quintela    sdl=no
12467c1f25b4Sbellard  fi # sdl compile test
1247fd677642Sthsfi
124811d9f695Sbellard
12495368a422Saliguoriif test "$sdl" = "yes" ; then
12505368a422Saliguori  cat > $TMPC <<EOF
12515368a422Saliguori#include <SDL.h>
12525368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
12535368a422Saliguori#include <X11/XKBlib.h>
12545368a422Saliguori#else
12555368a422Saliguori#error No x11 support
12565368a422Saliguori#endif
12575368a422Saliguoriint main(void) { return 0; }
12585368a422SaliguoriEOF
125952166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1260681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
12615368a422Saliguori  fi
126207d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
126307d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
126407d9ac44SJuan Quintela  fi
12650705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
12665368a422Saliguorifi
12675368a422Saliguori
12688f28f3fbSths##########################################
12698d5d2d4cSths# VNC TLS detection
12701be10ad2SJuan Quintelaif test "$vnc_tls" != "no" ; then
1271ae6b5e5aSaliguori  cat > $TMPC <<EOF
1272ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1273ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1274ae6b5e5aSaliguoriEOF
1275f91672e5SPaolo Bonzini  vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
1276f91672e5SPaolo Bonzini  vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
127752166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
12781be10ad2SJuan Quintela    vnc_tls=yes
1279a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1280ae6b5e5aSaliguori  else
12811be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
12821be10ad2SJuan Quintela      feature_not_found "vnc-tls"
12831be10ad2SJuan Quintela    fi
12841be10ad2SJuan Quintela    vnc_tls=no
12858d5d2d4cSths  fi
12868d5d2d4cSthsfi
12878d5d2d4cSths
12888d5d2d4cSths##########################################
12892f9606b3Saliguori# VNC SASL detection
12903aefa744SJuan Quintelaif test "$vnc_sasl" != "no" ; then
12912f9606b3Saliguori  cat > $TMPC <<EOF
12922f9606b3Saliguori#include <sasl/sasl.h>
12932f9606b3Saliguori#include <stdio.h>
12942f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
12952f9606b3SaliguoriEOF
12962f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
12972f9606b3Saliguori  vnc_sasl_cflags=""
12982f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
129952166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1300ea784e3bSJuan Quintela    vnc_sasl=yes
1301fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
13022f9606b3Saliguori  else
1303ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1304ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1305ea784e3bSJuan Quintela    fi
1306ea784e3bSJuan Quintela    vnc_sasl=no
13072f9606b3Saliguori  fi
13082f9606b3Saliguorifi
13092f9606b3Saliguori
13102f9606b3Saliguori##########################################
13112f6f5c7aSCorentin Chary# VNC JPEG detection
131296763cf9SCorentin Charyif test "$vnc_jpeg" != "no" ; then
13132f6f5c7aSCorentin Charycat > $TMPC <<EOF
13142f6f5c7aSCorentin Chary#include <stdio.h>
13152f6f5c7aSCorentin Chary#include <jpeglib.h>
13162f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
13172f6f5c7aSCorentin CharyEOF
13182f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
13192f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
13202f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
13212f6f5c7aSCorentin Chary    vnc_jpeg=yes
13222f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
13232f6f5c7aSCorentin Chary  else
13242f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
13252f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
13262f6f5c7aSCorentin Chary    fi
13272f6f5c7aSCorentin Chary    vnc_jpeg=no
13282f6f5c7aSCorentin Chary  fi
13292f6f5c7aSCorentin Charyfi
13302f6f5c7aSCorentin Chary
13312f6f5c7aSCorentin Chary##########################################
1332efe556adSCorentin Chary# VNC PNG detection
133396763cf9SCorentin Charyif test "$vnc_png" != "no" ; then
1334efe556adSCorentin Charycat > $TMPC <<EOF
1335efe556adSCorentin Chary//#include <stdio.h>
1336efe556adSCorentin Chary#include <png.h>
1337832ce9c2SScott Wood#include <stddef.h>
1338efe556adSCorentin Charyint main(void) {
1339efe556adSCorentin Chary    png_structp png_ptr;
1340efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1341efe556adSCorentin Chary    return 0;
1342efe556adSCorentin Chary}
1343efe556adSCorentin CharyEOF
1344efe556adSCorentin Chary    vnc_png_cflags=""
1345efe556adSCorentin Chary    vnc_png_libs="-lpng"
1346efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1347efe556adSCorentin Chary    vnc_png=yes
1348efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
1349efe556adSCorentin Chary  else
1350efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1351efe556adSCorentin Chary      feature_not_found "vnc-png"
1352efe556adSCorentin Chary    fi
1353efe556adSCorentin Chary    vnc_png=no
1354efe556adSCorentin Chary  fi
1355efe556adSCorentin Charyfi
1356efe556adSCorentin Chary
1357efe556adSCorentin Chary##########################################
135876655d6dSaliguori# fnmatch() probe, used for ACL routines
135976655d6dSaliguorifnmatch="no"
136076655d6dSaliguoricat > $TMPC << EOF
136176655d6dSaliguori#include <fnmatch.h>
136276655d6dSaliguoriint main(void)
136376655d6dSaliguori{
136476655d6dSaliguori    fnmatch("foo", "foo", 0);
136576655d6dSaliguori    return 0;
136676655d6dSaliguori}
136776655d6dSaliguoriEOF
136852166aa0SJuan Quintelaif compile_prog "" "" ; then
136976655d6dSaliguori   fnmatch="yes"
137076655d6dSaliguorifi
137176655d6dSaliguori
137276655d6dSaliguori##########################################
1373ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1374ee682d27SStefan Weilif test "$uuid" != "no" ; then
1375ee682d27SStefan Weil  uuid_libs="-luuid"
1376ee682d27SStefan Weil  cat > $TMPC << EOF
1377ee682d27SStefan Weil#include <uuid/uuid.h>
1378ee682d27SStefan Weilint main(void)
1379ee682d27SStefan Weil{
1380ee682d27SStefan Weil    uuid_t my_uuid;
1381ee682d27SStefan Weil    uuid_generate(my_uuid);
1382ee682d27SStefan Weil    return 0;
1383ee682d27SStefan Weil}
1384ee682d27SStefan WeilEOF
1385ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1386ee682d27SStefan Weil    uuid="yes"
1387ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1388ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1389ee682d27SStefan Weil  else
1390ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1391ee682d27SStefan Weil      feature_not_found "uuid"
1392ee682d27SStefan Weil    fi
1393ee682d27SStefan Weil    uuid=no
1394ee682d27SStefan Weil  fi
1395ee682d27SStefan Weilfi
1396ee682d27SStefan Weil
1397ee682d27SStefan Weil##########################################
1398dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1399dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1400dce512deSChristoph Hellwig  cat > $TMPC << EOF
1401dce512deSChristoph Hellwig#include <xfs/xfs.h>
1402dce512deSChristoph Hellwigint main(void)
1403dce512deSChristoph Hellwig{
1404dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1405dce512deSChristoph Hellwig    return 0;
1406dce512deSChristoph Hellwig}
1407dce512deSChristoph HellwigEOF
1408dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1409dce512deSChristoph Hellwig    xfs="yes"
1410dce512deSChristoph Hellwig  else
1411dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1412dce512deSChristoph Hellwig      feature_not_found "xfs"
1413dce512deSChristoph Hellwig    fi
1414dce512deSChristoph Hellwig    xfs=no
1415dce512deSChristoph Hellwig  fi
1416dce512deSChristoph Hellwigfi
1417dce512deSChristoph Hellwig
1418dce512deSChristoph Hellwig##########################################
14198a16d273Sths# vde libraries probe
1420dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
14214baae0acSJuan Quintela  vde_libs="-lvdeplug"
14228a16d273Sths  cat > $TMPC << EOF
14238a16d273Sths#include <libvdeplug.h>
14244a7f0e06Spbrookint main(void)
14254a7f0e06Spbrook{
14264a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
14274a7f0e06Spbrook    vde_open("", "", &a);
14284a7f0e06Spbrook    return 0;
14294a7f0e06Spbrook}
14308a16d273SthsEOF
143152166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
14324baae0acSJuan Quintela    vde=yes
14338e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
14348e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1435dfb278bdSJuan Quintela  else
1436dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1437dfb278bdSJuan Quintela      feature_not_found "vde"
1438dfb278bdSJuan Quintela    fi
1439dfb278bdSJuan Quintela    vde=no
14408a16d273Sths  fi
14418a16d273Sthsfi
14428a16d273Sths
14438a16d273Sths##########################################
1444c2de5c91Smalc# Sound support libraries probe
14458f28f3fbSths
1446c2de5c91Smalcaudio_drv_probe()
1447c2de5c91Smalc{
1448c2de5c91Smalc    drv=$1
1449c2de5c91Smalc    hdr=$2
1450c2de5c91Smalc    lib=$3
1451c2de5c91Smalc    exp=$4
1452c2de5c91Smalc    cfl=$5
14538f28f3fbSths        cat > $TMPC << EOF
1454c2de5c91Smalc#include <$hdr>
1455c2de5c91Smalcint main(void) { $exp }
14568f28f3fbSthsEOF
145752166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
14588f28f3fbSths        :
14598f28f3fbSths    else
14608f28f3fbSths        echo
1461c2de5c91Smalc        echo "Error: $drv check failed"
1462c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
14638f28f3fbSths        echo
14648f28f3fbSths        exit 1
14658f28f3fbSths    fi
1466c2de5c91Smalc}
1467c2de5c91Smalc
14682fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1469c2de5c91Smalcfor drv in $audio_drv_list; do
1470c2de5c91Smalc    case $drv in
1471c2de5c91Smalc    alsa)
1472c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1473c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1474a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1475c2de5c91Smalc    ;;
1476c2de5c91Smalc
1477c2de5c91Smalc    fmod)
1478c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1479c2de5c91Smalc        echo
1480c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1481c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1482c2de5c91Smalc        echo
1483c2de5c91Smalc        exit 1
14848f28f3fbSths    fi
1485c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1486a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1487c2de5c91Smalc    ;;
1488c2de5c91Smalc
1489c2de5c91Smalc    esd)
1490c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1491a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
149267f86e8eSJuan Quintela    audio_pt_int="yes"
1493c2de5c91Smalc    ;;
1494b8e59f18Smalc
1495b8e59f18Smalc    pa)
1496493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1497b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1498493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
149967f86e8eSJuan Quintela    audio_pt_int="yes"
1500b8e59f18Smalc    ;;
1501b8e59f18Smalc
1502997e690aSJuan Quintela    coreaudio)
1503997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1504997e690aSJuan Quintela    ;;
1505997e690aSJuan Quintela
1506a4bf6780SJuan Quintela    dsound)
1507a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1508d5631638Smalc      audio_win_int="yes"
1509a4bf6780SJuan Quintela    ;;
1510a4bf6780SJuan Quintela
1511a4bf6780SJuan Quintela    oss)
1512a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1513a4bf6780SJuan Quintela    ;;
1514a4bf6780SJuan Quintela
1515a4bf6780SJuan Quintela    sdl|wav)
15162f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
15172f6a1ab0Sblueswir1    ;;
15182f6a1ab0Sblueswir1
1519d5631638Smalc    winwave)
1520d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1521d5631638Smalc      audio_win_int="yes"
1522d5631638Smalc    ;;
1523d5631638Smalc
1524e4c63a6aSmalc    *)
15251c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1526e4c63a6aSmalc        echo
1527e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1528e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1529e4c63a6aSmalc        echo
1530e4c63a6aSmalc        exit 1
1531e4c63a6aSmalc    }
1532e4c63a6aSmalc    ;;
1533c2de5c91Smalc    esac
1534c2de5c91Smalcdone
15358f28f3fbSths
15364d3b6f6eSbalrog##########################################
15372e4d9fb1Saurel32# BrlAPI probe
15382e4d9fb1Saurel32
15394ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1540eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
15412e4d9fb1Saurel32  cat > $TMPC << EOF
15422e4d9fb1Saurel32#include <brlapi.h>
1543832ce9c2SScott Wood#include <stddef.h>
15442e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
15452e4d9fb1Saurel32EOF
154652166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
15472e4d9fb1Saurel32    brlapi=yes
1548264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
15494ffcedb6SJuan Quintela  else
15504ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
15514ffcedb6SJuan Quintela      feature_not_found "brlapi"
15524ffcedb6SJuan Quintela    fi
15534ffcedb6SJuan Quintela    brlapi=no
1554eb82284fSJuan Quintela  fi
1555eb82284fSJuan Quintelafi
15562e4d9fb1Saurel32
15572e4d9fb1Saurel32##########################################
15584d3b6f6eSbalrog# curses probe
15594f78ef9aSJuan Quintelacurses_list="-lncurses -lcurses"
15604d3b6f6eSbalrog
1561c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1562c584a6d0SJuan Quintela  curses_found=no
15634d3b6f6eSbalrog  cat > $TMPC << EOF
15644d3b6f6eSbalrog#include <curses.h>
15655a8ff3aaSblueswir1#ifdef __OpenBSD__
15665a8ff3aaSblueswir1#define resize_term resizeterm
15675a8ff3aaSblueswir1#endif
15685a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
15694d3b6f6eSbalrogEOF
15704f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
15714f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1572c584a6d0SJuan Quintela      curses_found=yes
15734f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
15744f78ef9aSJuan Quintela      break
15754d3b6f6eSbalrog    fi
15764f78ef9aSJuan Quintela  done
1577c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1578c584a6d0SJuan Quintela    curses=yes
1579c584a6d0SJuan Quintela  else
1580c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1581c584a6d0SJuan Quintela      feature_not_found "curses"
1582c584a6d0SJuan Quintela    fi
1583c584a6d0SJuan Quintela    curses=no
1584c584a6d0SJuan Quintela  fi
15854f78ef9aSJuan Quintelafi
15864d3b6f6eSbalrog
1587414f0dabSblueswir1##########################################
1588769ce76dSAlexander Graf# curl probe
1589769ce76dSAlexander Graf
15904e2b0658SPaolo Bonziniif $pkgconfig libcurl --modversion >/dev/null 2>&1; then
15914e2b0658SPaolo Bonzini  curlconfig="$pkgconfig libcurl"
15924e2b0658SPaolo Bonzinielse
15934e2b0658SPaolo Bonzini  curlconfig=curl-config
15944e2b0658SPaolo Bonzinifi
15954e2b0658SPaolo Bonzini
1596788c8196SJuan Quintelaif test "$curl" != "no" ; then
1597769ce76dSAlexander Graf  cat > $TMPC << EOF
1598769ce76dSAlexander Graf#include <curl/curl.h>
1599769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1600769ce76dSAlexander GrafEOF
16014e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
16024e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1603b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1604769ce76dSAlexander Graf    curl=yes
1605f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1606f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1607788c8196SJuan Quintela  else
1608788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1609788c8196SJuan Quintela      feature_not_found "curl"
1610788c8196SJuan Quintela    fi
1611788c8196SJuan Quintela    curl=no
1612769ce76dSAlexander Graf  fi
1613769ce76dSAlexander Graffi # test "$curl"
1614769ce76dSAlexander Graf
1615769ce76dSAlexander Graf##########################################
16165495ed11SLuiz Capitulino# check framework probe
16175495ed11SLuiz Capitulino
16185495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
16195495ed11SLuiz Capitulino  cat > $TMPC << EOF
16205495ed11SLuiz Capitulino#include <check.h>
16215495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
16225495ed11SLuiz CapitulinoEOF
1623f91672e5SPaolo Bonzini  check_libs=`$pkgconfig --libs check`
16245495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
16255495ed11SLuiz Capitulino    check_utests=yes
16265495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
16275495ed11SLuiz Capitulino  else
16285495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
16295495ed11SLuiz Capitulino      feature_not_found "check"
16305495ed11SLuiz Capitulino    fi
16315495ed11SLuiz Capitulino    check_utests=no
16325495ed11SLuiz Capitulino  fi
16335495ed11SLuiz Capitulinofi # test "$check_utests"
16345495ed11SLuiz Capitulino
16355495ed11SLuiz Capitulino##########################################
1636fb599c9aSbalrog# bluez support probe
1637a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1638e820e3f4Sbalrog  cat > $TMPC << EOF
1639e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1640e820e3f4Sbalrogint main(void) { return bt_error(0); }
1641e820e3f4SbalrogEOF
1642f91672e5SPaolo Bonzini  bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
1643f91672e5SPaolo Bonzini  bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
164452166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1645a20a6f46SJuan Quintela    bluez=yes
1646e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1647e820e3f4Sbalrog  else
1648a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1649a20a6f46SJuan Quintela      feature_not_found "bluez"
1650a20a6f46SJuan Quintela    fi
1651e820e3f4Sbalrog    bluez="no"
1652e820e3f4Sbalrog  fi
1653fb599c9aSbalrogfi
1654fb599c9aSbalrog
1655fb599c9aSbalrog##########################################
16567ba1e619Saliguori# kvm probe
1657b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
16587ba1e619Saliguori    cat > $TMPC <<EOF
16597ba1e619Saliguori#include <linux/kvm.h>
16609fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
16617ba1e619Saliguori#error Invalid KVM version
16627ba1e619Saliguori#endif
16639fd8d8d7Saliguori#if !defined(KVM_CAP_USER_MEMORY)
16649fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_USER_MEMORY
16659fd8d8d7Saliguori#endif
16669fd8d8d7Saliguori#if !defined(KVM_CAP_SET_TSS_ADDR)
16679fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
16689fd8d8d7Saliguori#endif
16699fd8d8d7Saliguori#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
16709fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
16719fd8d8d7Saliguori#endif
16727ba1e619Saliguoriint main(void) { return 0; }
16737ba1e619SaliguoriEOF
1674eac30262Saliguori  if test "$kerneldir" != "" ; then
1675eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
16768444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
16778444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
16788444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1679406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1680406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
16810e60a699SAlexander Graf	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
16820e60a699SAlexander Graf	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
16838444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
16848444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
16858444eb6eSaliguori      fi
1686eac30262Saliguori  else
1687f038e8f7SStefan Weil    kvm_cflags=`$pkgconfig --cflags kvm-kmod 2>/dev/null`
1688eac30262Saliguori  fi
168952166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1690b31a0277SJuan Quintela    kvm=yes
1691dae5079aSJan Kiszka    cat > $TMPC <<EOF
1692dae5079aSJan Kiszka#include <linux/kvm_para.h>
1693dae5079aSJan Kiszkaint main(void) { return 0; }
1694dae5079aSJan KiszkaEOF
1695dae5079aSJan Kiszka    if compile_prog "$kvm_cflags" "" ; then
1696dae5079aSJan Kiszka      kvm_para=yes
1697dae5079aSJan Kiszka    fi
16987ba1e619Saliguori  else
1699b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
17000dba6195SLoïc Minier      if has awk && has grep; then
1701a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
17029fd8d8d7Saliguori	| grep "error: " \
17039fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
17049fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1705b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1706168ccc11SJan Kiszka      NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1707168ccc11SJan Kiszka  recent kvm-kmod from http://sourceforge.net/projects/kvm."
17089fd8d8d7Saliguori        fi
17099fd8d8d7Saliguori      fi
1710b31a0277SJuan Quintela      feature_not_found "kvm"
1711b31a0277SJuan Quintela    fi
1712b31a0277SJuan Quintela    kvm=no
17137ba1e619Saliguori  fi
17147ba1e619Saliguorifi
17157ba1e619Saliguori
17167ba1e619Saliguori##########################################
1717d5970055SMichael S. Tsirkin# test for vhost net
1718d5970055SMichael S. Tsirkin
1719d5970055SMichael S. Tsirkinif test "$vhost_net" != "no"; then
1720d5970055SMichael S. Tsirkin    if test "$kvm" != "no"; then
1721d5970055SMichael S. Tsirkin            cat > $TMPC <<EOF
1722d5970055SMichael S. Tsirkin    #include <linux/vhost.h>
1723d5970055SMichael S. Tsirkin    int main(void) { return 0; }
1724d5970055SMichael S. TsirkinEOF
1725d5970055SMichael S. Tsirkin            if compile_prog "$kvm_cflags" "" ; then
1726d5970055SMichael S. Tsirkin                vhost_net=yes
1727d5970055SMichael S. Tsirkin            else
1728d5970055SMichael S. Tsirkin                if test "$vhost_net" = "yes" ; then
1729d5970055SMichael S. Tsirkin                    feature_not_found "vhost-net"
1730d5970055SMichael S. Tsirkin                fi
1731d5970055SMichael S. Tsirkin                vhost_net=no
1732d5970055SMichael S. Tsirkin            fi
1733d5970055SMichael S. Tsirkin    else
1734d5970055SMichael S. Tsirkin            if test "$vhost_net" = "yes" ; then
17354021d247SAurelien Jarno                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1736d5970055SMichael S. Tsirkin                feature_not_found "vhost-net"
1737d5970055SMichael S. Tsirkin            fi
1738d5970055SMichael S. Tsirkin            vhost_net=no
1739d5970055SMichael S. Tsirkin    fi
1740d5970055SMichael S. Tsirkinfi
1741d5970055SMichael S. Tsirkin
1742d5970055SMichael S. Tsirkin##########################################
1743e5d355d1Saliguori# pthread probe
1744de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
17453c529d93Saliguori
1746e5d355d1Saliguoripthread=no
1747414f0dabSblueswir1cat > $TMPC << EOF
17483c529d93Saliguori#include <pthread.h>
1749de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1750414f0dabSblueswir1EOF
1751bd00d539SAndreas Färberif compile_prog "" "" ; then
1752bd00d539SAndreas Färber  pthread=yes
1753bd00d539SAndreas Färberelse
1754de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
175552166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
1756e5d355d1Saliguori      pthread=yes
17575572b539SJuan Quintela      LIBS="$pthread_lib $LIBS"
1758de65fe0fSSebastian Herbszt      break
1759414f0dabSblueswir1    fi
1760de65fe0fSSebastian Herbszt  done
1761bd00d539SAndreas Färberfi
1762414f0dabSblueswir1
17634617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
17644dd75c70SChristoph Hellwig  echo
17654dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
17664dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
17674dd75c70SChristoph Hellwig  echo
17684dd75c70SChristoph Hellwig  exit 1
1769e5d355d1Saliguorifi
1770e5d355d1Saliguori
1771bf9298b9Saliguori##########################################
1772f27aaf4bSChristian Brunner# rbd probe
1773f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
1774f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
1775f27aaf4bSChristian Brunner#include <stdio.h>
1776f27aaf4bSChristian Brunner#include <rados/librados.h>
1777f27aaf4bSChristian Brunnerint main(void) { rados_initialize(0, NULL); return 0; }
1778f27aaf4bSChristian BrunnerEOF
1779f27aaf4bSChristian Brunner  rbd_libs="-lrados -lcrypto"
1780f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
1781f27aaf4bSChristian Brunner    librados_too_old=no
1782f27aaf4bSChristian Brunner    cat > $TMPC <<EOF
1783f27aaf4bSChristian Brunner#include <stdio.h>
1784f27aaf4bSChristian Brunner#include <rados/librados.h>
1785f27aaf4bSChristian Brunner#ifndef CEPH_OSD_TMAP_SET
1786f27aaf4bSChristian Brunner#error missing CEPH_OSD_TMAP_SET
1787f27aaf4bSChristian Brunner#endif
1788f27aaf4bSChristian Brunnerint main(void) {
1789f27aaf4bSChristian Brunner    int (*func)(const rados_pool_t pool, uint64_t *snapid) = rados_selfmanaged_snap_create;
1790f27aaf4bSChristian Brunner    rados_initialize(0, NULL);
1791f27aaf4bSChristian Brunner    return 0;
1792f27aaf4bSChristian Brunner}
1793f27aaf4bSChristian BrunnerEOF
1794f27aaf4bSChristian Brunner    if compile_prog "" "$rbd_libs" ; then
1795f27aaf4bSChristian Brunner      rbd=yes
1796f27aaf4bSChristian Brunner      libs_tools="$rbd_libs $libs_tools"
1797f27aaf4bSChristian Brunner      libs_softmmu="$rbd_libs $libs_softmmu"
1798f27aaf4bSChristian Brunner    else
1799f27aaf4bSChristian Brunner      rbd=no
1800f27aaf4bSChristian Brunner      librados_too_old=yes
1801f27aaf4bSChristian Brunner    fi
1802f27aaf4bSChristian Brunner  else
1803f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
1804f27aaf4bSChristian Brunner      feature_not_found "rados block device"
1805f27aaf4bSChristian Brunner    fi
1806f27aaf4bSChristian Brunner    rbd=no
1807f27aaf4bSChristian Brunner  fi
1808f27aaf4bSChristian Brunner  if test "$librados_too_old" = "yes" ; then
1809f27aaf4bSChristian Brunner    echo "-> Your librados version is too old - upgrade needed to have rbd support"
1810f27aaf4bSChristian Brunner  fi
1811f27aaf4bSChristian Brunnerfi
1812f27aaf4bSChristian Brunner
1813f27aaf4bSChristian Brunner##########################################
18145c6c3a6cSChristoph Hellwig# linux-aio probe
18155c6c3a6cSChristoph Hellwig
18165c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
18175c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
18185c6c3a6cSChristoph Hellwig#include <libaio.h>
18195c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
1820832ce9c2SScott Wood#include <stddef.h>
18215c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
18225c6c3a6cSChristoph HellwigEOF
18235c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
18245c6c3a6cSChristoph Hellwig    linux_aio=yes
1825048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1826048d179fSPaul Brook    libs_tools="$libs_tools -laio"
18275c6c3a6cSChristoph Hellwig  else
18285c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
18295c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
18305c6c3a6cSChristoph Hellwig    fi
18313cfcae3cSLuiz Capitulino    linux_aio=no
18325c6c3a6cSChristoph Hellwig  fi
18335c6c3a6cSChristoph Hellwigfi
18345c6c3a6cSChristoph Hellwig
18355c6c3a6cSChristoph Hellwig##########################################
1836758e8e38SVenkateswararao Jujjuri (JV)# attr probe
1837758e8e38SVenkateswararao Jujjuri (JV)
1838758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
1839758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
1840758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
1841758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
1842758e8e38SVenkateswararao Jujjuri (JV)#include <attr/xattr.h>
1843758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1844758e8e38SVenkateswararao Jujjuri (JV)EOF
1845758e8e38SVenkateswararao Jujjuri (JV)  if compile_prog "" "-lattr" ; then
1846758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
1847758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
1848758e8e38SVenkateswararao Jujjuri (JV)  else
1849758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
1850758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
1851758e8e38SVenkateswararao Jujjuri (JV)    fi
1852758e8e38SVenkateswararao Jujjuri (JV)    attr=no
1853758e8e38SVenkateswararao Jujjuri (JV)  fi
1854758e8e38SVenkateswararao Jujjuri (JV)fi
1855758e8e38SVenkateswararao Jujjuri (JV)
1856758e8e38SVenkateswararao Jujjuri (JV)##########################################
1857bf9298b9Saliguori# iovec probe
1858bf9298b9Saliguoricat > $TMPC <<EOF
1859db34f0b3Sblueswir1#include <sys/types.h>
1860bf9298b9Saliguori#include <sys/uio.h>
1861db34f0b3Sblueswir1#include <unistd.h>
1862bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1863bf9298b9SaliguoriEOF
1864bf9298b9Saliguoriiovec=no
186552166aa0SJuan Quintelaif compile_prog "" "" ; then
1866bf9298b9Saliguori  iovec=yes
1867bf9298b9Saliguorifi
1868bf9298b9Saliguori
1869f652e6afSaurel32##########################################
1870ceb42de8Saliguori# preadv probe
1871ceb42de8Saliguoricat > $TMPC <<EOF
1872ceb42de8Saliguori#include <sys/types.h>
1873ceb42de8Saliguori#include <sys/uio.h>
1874ceb42de8Saliguori#include <unistd.h>
1875ceb42de8Saliguoriint main(void) { preadv; }
1876ceb42de8SaliguoriEOF
1877ceb42de8Saliguoripreadv=no
187852166aa0SJuan Quintelaif compile_prog "" "" ; then
1879ceb42de8Saliguori  preadv=yes
1880ceb42de8Saliguorifi
1881ceb42de8Saliguori
1882ceb42de8Saliguori##########################################
1883f652e6afSaurel32# fdt probe
18842df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1885b41af4baSJuan Quintela  fdt_libs="-lfdt"
1886f652e6afSaurel32  cat > $TMPC << EOF
1887f652e6afSaurel32int main(void) { return 0; }
1888f652e6afSaurel32EOF
188952166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1890f652e6afSaurel32    fdt=yes
1891e4782985SJuan Quintela    libs_softmmu="$fdt_libs $libs_softmmu"
18922df87df7SJuan Quintela  else
18932df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
18942df87df7SJuan Quintela      feature_not_found "fdt"
18952df87df7SJuan Quintela    fi
18962df87df7SJuan Quintela    fdt=no
1897f652e6afSaurel32  fi
1898f652e6afSaurel32fi
1899f652e6afSaurel32
19003b3f24adSaurel32#
19013b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
19023b3f24adSaurel32# emulator.  This is done because older glibc versions don't
19033b3f24adSaurel32# have syscall stubs for these implemented.
19043b3f24adSaurel32#
19053b3f24adSaurel32atfile=no
19063b3f24adSaurel32cat > $TMPC << EOF
19073b3f24adSaurel32#define _ATFILE_SOURCE
19083b3f24adSaurel32#include <sys/types.h>
19093b3f24adSaurel32#include <fcntl.h>
19103b3f24adSaurel32#include <unistd.h>
19113b3f24adSaurel32
19123b3f24adSaurel32int
19133b3f24adSaurel32main(void)
19143b3f24adSaurel32{
19153b3f24adSaurel32	/* try to unlink nonexisting file */
19163b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
19173b3f24adSaurel32}
19183b3f24adSaurel32EOF
191952166aa0SJuan Quintelaif compile_prog "" "" ; then
19203b3f24adSaurel32  atfile=yes
19213b3f24adSaurel32fi
19223b3f24adSaurel32
192339386ac7Saurel32# Check for inotify functions when we are building linux-user
19243b3f24adSaurel32# emulator.  This is done because older glibc versions don't
19253b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
19263b3f24adSaurel32# don't provide them even if kernel supports them.
19273b3f24adSaurel32#
19283b3f24adSaurel32inotify=no
19293b3f24adSaurel32cat > $TMPC << EOF
19303b3f24adSaurel32#include <sys/inotify.h>
19313b3f24adSaurel32
19323b3f24adSaurel32int
19333b3f24adSaurel32main(void)
19343b3f24adSaurel32{
19353b3f24adSaurel32	/* try to start inotify */
19368690e420Saurel32	return inotify_init();
19373b3f24adSaurel32}
19383b3f24adSaurel32EOF
193952166aa0SJuan Quintelaif compile_prog "" "" ; then
19403b3f24adSaurel32  inotify=yes
19413b3f24adSaurel32fi
19423b3f24adSaurel32
1943c05c7a73SRiku Voipioinotify1=no
1944c05c7a73SRiku Voipiocat > $TMPC << EOF
1945c05c7a73SRiku Voipio#include <sys/inotify.h>
1946c05c7a73SRiku Voipio
1947c05c7a73SRiku Voipioint
1948c05c7a73SRiku Voipiomain(void)
1949c05c7a73SRiku Voipio{
1950c05c7a73SRiku Voipio    /* try to start inotify */
1951c05c7a73SRiku Voipio    return inotify_init1(0);
1952c05c7a73SRiku Voipio}
1953c05c7a73SRiku VoipioEOF
1954c05c7a73SRiku Voipioif compile_prog "" "" ; then
1955c05c7a73SRiku Voipio  inotify1=yes
1956c05c7a73SRiku Voipiofi
1957c05c7a73SRiku Voipio
1958ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1959ebc996f3SRiku Voipioutimens=no
1960ebc996f3SRiku Voipiocat > $TMPC << EOF
1961ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1962ebc996f3SRiku Voipio#include <stddef.h>
1963ebc996f3SRiku Voipio#include <fcntl.h>
1964ebc996f3SRiku Voipio
1965ebc996f3SRiku Voipioint main(void)
1966ebc996f3SRiku Voipio{
1967ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1968ebc996f3SRiku Voipio    futimens(0, NULL);
1969ebc996f3SRiku Voipio    return 0;
1970ebc996f3SRiku Voipio}
1971ebc996f3SRiku VoipioEOF
197252166aa0SJuan Quintelaif compile_prog "" "" ; then
1973ebc996f3SRiku Voipio  utimens=yes
1974ebc996f3SRiku Voipiofi
1975ebc996f3SRiku Voipio
1976099d6b0fSRiku Voipio# check if pipe2 is there
1977099d6b0fSRiku Voipiopipe2=no
1978099d6b0fSRiku Voipiocat > $TMPC << EOF
1979099d6b0fSRiku Voipio#include <unistd.h>
1980099d6b0fSRiku Voipio#include <fcntl.h>
1981099d6b0fSRiku Voipio
1982099d6b0fSRiku Voipioint main(void)
1983099d6b0fSRiku Voipio{
1984099d6b0fSRiku Voipio    int pipefd[2];
1985099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
1986099d6b0fSRiku Voipio    return 0;
1987099d6b0fSRiku Voipio}
1988099d6b0fSRiku VoipioEOF
198952166aa0SJuan Quintelaif compile_prog "" "" ; then
1990099d6b0fSRiku Voipio  pipe2=yes
1991099d6b0fSRiku Voipiofi
1992099d6b0fSRiku Voipio
199340ff6d7eSKevin Wolf# check if accept4 is there
199440ff6d7eSKevin Wolfaccept4=no
199540ff6d7eSKevin Wolfcat > $TMPC << EOF
199640ff6d7eSKevin Wolf#include <sys/socket.h>
199740ff6d7eSKevin Wolf#include <stddef.h>
199840ff6d7eSKevin Wolf
199940ff6d7eSKevin Wolfint main(void)
200040ff6d7eSKevin Wolf{
200140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
200240ff6d7eSKevin Wolf    return 0;
200340ff6d7eSKevin Wolf}
200440ff6d7eSKevin WolfEOF
200540ff6d7eSKevin Wolfif compile_prog "" "" ; then
200640ff6d7eSKevin Wolf  accept4=yes
200740ff6d7eSKevin Wolffi
200840ff6d7eSKevin Wolf
20093ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
20103ce34dfbSvibisreenivasansplice=no
20113ce34dfbSvibisreenivasancat > $TMPC << EOF
20123ce34dfbSvibisreenivasan#include <unistd.h>
20133ce34dfbSvibisreenivasan#include <fcntl.h>
20143ce34dfbSvibisreenivasan#include <limits.h>
20153ce34dfbSvibisreenivasan
20163ce34dfbSvibisreenivasanint main(void)
20173ce34dfbSvibisreenivasan{
20183ce34dfbSvibisreenivasan    int len, fd;
20193ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
20203ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
20213ce34dfbSvibisreenivasan    return 0;
20223ce34dfbSvibisreenivasan}
20233ce34dfbSvibisreenivasanEOF
202452166aa0SJuan Quintelaif compile_prog "" "" ; then
20253ce34dfbSvibisreenivasan  splice=yes
20263ce34dfbSvibisreenivasanfi
20273ce34dfbSvibisreenivasan
2028dcc38d1cSMarcelo Tosatti##########################################
2029dcc38d1cSMarcelo Tosatti# signalfd probe
2030dcc38d1cSMarcelo Tosattisignalfd="no"
2031dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2032dcc38d1cSMarcelo Tosatti#define _GNU_SOURCE
2033dcc38d1cSMarcelo Tosatti#include <unistd.h>
2034dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2035dcc38d1cSMarcelo Tosatti#include <signal.h>
2036dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2037dcc38d1cSMarcelo TosattiEOF
2038dcc38d1cSMarcelo Tosatti
2039dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2040dcc38d1cSMarcelo Tosatti  signalfd=yes
2041dcc38d1cSMarcelo Tosattifi
2042dcc38d1cSMarcelo Tosatti
2043c2882b96SRiku Voipio# check if eventfd is supported
2044c2882b96SRiku Voipioeventfd=no
2045c2882b96SRiku Voipiocat > $TMPC << EOF
2046c2882b96SRiku Voipio#include <sys/eventfd.h>
2047c2882b96SRiku Voipio
2048c2882b96SRiku Voipioint main(void)
2049c2882b96SRiku Voipio{
2050c2882b96SRiku Voipio    int efd = eventfd(0, 0);
2051c2882b96SRiku Voipio    return 0;
2052c2882b96SRiku Voipio}
2053c2882b96SRiku VoipioEOF
2054c2882b96SRiku Voipioif compile_prog "" "" ; then
2055c2882b96SRiku Voipio  eventfd=yes
2056c2882b96SRiku Voipiofi
2057c2882b96SRiku Voipio
2058d0927938SUlrich Hecht# check for fallocate
2059d0927938SUlrich Hechtfallocate=no
2060d0927938SUlrich Hechtcat > $TMPC << EOF
2061d0927938SUlrich Hecht#include <fcntl.h>
2062d0927938SUlrich Hecht
2063d0927938SUlrich Hechtint main(void)
2064d0927938SUlrich Hecht{
2065d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2066d0927938SUlrich Hecht    return 0;
2067d0927938SUlrich Hecht}
2068d0927938SUlrich HechtEOF
2069be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
2070d0927938SUlrich Hecht  fallocate=yes
2071d0927938SUlrich Hechtfi
2072d0927938SUlrich Hecht
2073c727f47dSPeter Maydell# check for sync_file_range
2074c727f47dSPeter Maydellsync_file_range=no
2075c727f47dSPeter Maydellcat > $TMPC << EOF
2076c727f47dSPeter Maydell#include <fcntl.h>
2077c727f47dSPeter Maydell
2078c727f47dSPeter Maydellint main(void)
2079c727f47dSPeter Maydell{
2080c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2081c727f47dSPeter Maydell    return 0;
2082c727f47dSPeter Maydell}
2083c727f47dSPeter MaydellEOF
2084c727f47dSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2085c727f47dSPeter Maydell  sync_file_range=yes
2086c727f47dSPeter Maydellfi
2087c727f47dSPeter Maydell
2088dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2089dace20dcSPeter Maydellfiemap=no
2090dace20dcSPeter Maydellcat > $TMPC << EOF
2091dace20dcSPeter Maydell#include <sys/ioctl.h>
2092dace20dcSPeter Maydell#include <linux/fs.h>
2093dace20dcSPeter Maydell#include <linux/fiemap.h>
2094dace20dcSPeter Maydell
2095dace20dcSPeter Maydellint main(void)
2096dace20dcSPeter Maydell{
2097dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2098dace20dcSPeter Maydell    return 0;
2099dace20dcSPeter Maydell}
2100dace20dcSPeter MaydellEOF
2101dace20dcSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2102dace20dcSPeter Maydell  fiemap=yes
2103dace20dcSPeter Maydellfi
2104dace20dcSPeter Maydell
2105d0927938SUlrich Hecht# check for dup3
2106d0927938SUlrich Hechtdup3=no
2107d0927938SUlrich Hechtcat > $TMPC << EOF
2108d0927938SUlrich Hecht#include <unistd.h>
2109d0927938SUlrich Hecht
2110d0927938SUlrich Hechtint main(void)
2111d0927938SUlrich Hecht{
2112d0927938SUlrich Hecht    dup3(0, 0, 0);
2113d0927938SUlrich Hecht    return 0;
2114d0927938SUlrich Hecht}
2115d0927938SUlrich HechtEOF
211678f5d726SJan Kiszkaif compile_prog "" "" ; then
2117d0927938SUlrich Hecht  dup3=yes
2118d0927938SUlrich Hechtfi
2119d0927938SUlrich Hecht
2120cc8ae6deSpbrook# Check if tools are available to build documentation.
2121a25dba17SJuan Quintelaif test "$docs" != "no" ; then
212201668d98SStefan Weil  if has makeinfo && has pod2man; then
2123a25dba17SJuan Quintela    docs=yes
212483a3ab8bSJuan Quintela  else
2125a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2126a25dba17SJuan Quintela      feature_not_found "docs"
212783a3ab8bSJuan Quintela    fi
2128a25dba17SJuan Quintela    docs=no
212983a3ab8bSJuan Quintela  fi
2130cc8ae6deSpbrookfi
2131cc8ae6deSpbrook
2132f514f41cSStefan Weil# Search for bswap_32 function
21336ae9a1f4SJuan Quintelabyteswap_h=no
21346ae9a1f4SJuan Quintelacat > $TMPC << EOF
21356ae9a1f4SJuan Quintela#include <byteswap.h>
21366ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
21376ae9a1f4SJuan QuintelaEOF
213852166aa0SJuan Quintelaif compile_prog "" "" ; then
21396ae9a1f4SJuan Quintela  byteswap_h=yes
21406ae9a1f4SJuan Quintelafi
21416ae9a1f4SJuan Quintela
2142f514f41cSStefan Weil# Search for bswap_32 function
21436ae9a1f4SJuan Quintelabswap_h=no
21446ae9a1f4SJuan Quintelacat > $TMPC << EOF
21456ae9a1f4SJuan Quintela#include <sys/endian.h>
21466ae9a1f4SJuan Quintela#include <sys/types.h>
21476ae9a1f4SJuan Quintela#include <machine/bswap.h>
21486ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
21496ae9a1f4SJuan QuintelaEOF
215052166aa0SJuan Quintelaif compile_prog "" "" ; then
21516ae9a1f4SJuan Quintela  bswap_h=yes
21526ae9a1f4SJuan Quintelafi
21536ae9a1f4SJuan Quintela
2154da93a1fdSaliguori##########################################
2155da93a1fdSaliguori# Do we need librt
2156da93a1fdSaliguoricat > $TMPC <<EOF
2157da93a1fdSaliguori#include <signal.h>
2158da93a1fdSaliguori#include <time.h>
2159da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
2160da93a1fdSaliguoriEOF
2161da93a1fdSaliguori
216252166aa0SJuan Quintelaif compile_prog "" "" ; then
216307ffa4bdSJuan Quintela  :
216452166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
216507ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2166da93a1fdSaliguorifi
2167da93a1fdSaliguori
216831ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2169179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
21706362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
21716362a53fSJuan Quintelafi
21726362a53fSJuan Quintela
2173de5071c5SBlue Swirl##########################################
2174de5071c5SBlue Swirl# check if the compiler defines offsetof
2175de5071c5SBlue Swirl
2176de5071c5SBlue Swirlneed_offsetof=yes
2177de5071c5SBlue Swirlcat > $TMPC << EOF
2178de5071c5SBlue Swirl#include <stddef.h>
2179de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
2180de5071c5SBlue SwirlEOF
2181de5071c5SBlue Swirlif compile_prog "" "" ; then
2182de5071c5SBlue Swirl    need_offsetof=no
2183de5071c5SBlue Swirlfi
2184de5071c5SBlue Swirl
21855f6b9e8fSBlue Swirl##########################################
2186747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
2187747bbdf7SBlue Swirl#
2188747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
2189747bbdf7SBlue Swirl# about attribute warn_unused_result
2190747bbdf7SBlue Swirl
2191747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
2192747bbdf7SBlue Swirlcat > $TMPC << EOF
2193747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2194747bbdf7SBlue Swirl#error gcc 3.3 or older
2195747bbdf7SBlue Swirl#endif
2196747bbdf7SBlue Swirlint main(void) { return 0;}
2197747bbdf7SBlue SwirlEOF
2198747bbdf7SBlue Swirlif compile_prog "" ""; then
2199747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
2200747bbdf7SBlue Swirlfi
2201747bbdf7SBlue Swirl
2202cd4ec0b4SGerd Hoffmann# spice probe
2203cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2204cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2205cd4ec0b4SGerd Hoffmann#include <spice.h>
2206cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2207cd4ec0b4SGerd HoffmannEOF
2208cd4ec0b4SGerd Hoffmann  spice_cflags=$($pkgconfig --cflags spice-protocol spice-server 2>/dev/null)
2209cd4ec0b4SGerd Hoffmann  spice_libs=$($pkgconfig --libs spice-protocol spice-server 2>/dev/null)
2210ba807829SStefan Weil  if $pkgconfig --atleast-version=0.5.3 spice-server >/dev/null 2>&1 && \
2211cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2212cd4ec0b4SGerd Hoffmann    spice="yes"
2213cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2214cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2215cd4ec0b4SGerd Hoffmann  else
2216cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2217cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2218cd4ec0b4SGerd Hoffmann    fi
2219cd4ec0b4SGerd Hoffmann    spice="no"
2220cd4ec0b4SGerd Hoffmann  fi
2221cd4ec0b4SGerd Hoffmannfi
2222cd4ec0b4SGerd Hoffmann
2223cd4ec0b4SGerd Hoffmann##########################################
2224cd4ec0b4SGerd Hoffmann
2225747bbdf7SBlue Swirl##########################################
22265f6b9e8fSBlue Swirl# check if we have fdatasync
22275f6b9e8fSBlue Swirl
22285f6b9e8fSBlue Swirlfdatasync=no
22295f6b9e8fSBlue Swirlcat > $TMPC << EOF
22305f6b9e8fSBlue Swirl#include <unistd.h>
22315f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
22325f6b9e8fSBlue SwirlEOF
22335f6b9e8fSBlue Swirlif compile_prog "" "" ; then
22345f6b9e8fSBlue Swirl    fdatasync=yes
22355f6b9e8fSBlue Swirlfi
22365f6b9e8fSBlue Swirl
223794a420b1SStefan Hajnoczi##########################################
2238e78815a5SAndreas Färber# check if we have madvise
2239e78815a5SAndreas Färber
2240e78815a5SAndreas Färbermadvise=no
2241e78815a5SAndreas Färbercat > $TMPC << EOF
2242e78815a5SAndreas Färber#include <sys/types.h>
2243e78815a5SAndreas Färber#include <sys/mman.h>
2244832ce9c2SScott Wood#include <stddef.h>
2245e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2246e78815a5SAndreas FärberEOF
2247e78815a5SAndreas Färberif compile_prog "" "" ; then
2248e78815a5SAndreas Färber    madvise=yes
2249e78815a5SAndreas Färberfi
2250e78815a5SAndreas Färber
2251e78815a5SAndreas Färber##########################################
2252e78815a5SAndreas Färber# check if we have posix_madvise
2253e78815a5SAndreas Färber
2254e78815a5SAndreas Färberposix_madvise=no
2255e78815a5SAndreas Färbercat > $TMPC << EOF
2256e78815a5SAndreas Färber#include <sys/mman.h>
2257832ce9c2SScott Wood#include <stddef.h>
2258e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2259e78815a5SAndreas FärberEOF
2260e78815a5SAndreas Färberif compile_prog "" "" ; then
2261e78815a5SAndreas Färber    posix_madvise=yes
2262e78815a5SAndreas Färberfi
2263e78815a5SAndreas Färber
2264e78815a5SAndreas Färber##########################################
226594a420b1SStefan Hajnoczi# check if trace backend exists
226694a420b1SStefan Hajnoczi
226794a420b1SStefan Hajnoczish "$source_path/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
226894a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
226994a420b1SStefan Hajnoczi  echo
227094a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
227194a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
227294a420b1SStefan Hajnoczi  echo
227394a420b1SStefan Hajnoczi  exit 1
227494a420b1SStefan Hajnoczifi
227594a420b1SStefan Hajnoczi
22767e24e92aSStefan Hajnoczi##########################################
22777e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
22787e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
22797e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
22807e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
22817e24e92aSStefan Hajnoczi#include <ust/marker.h>
22827e24e92aSStefan Hajnocziint main(void) { return 0; }
22837e24e92aSStefan HajnocziEOF
22847e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
22857e24e92aSStefan Hajnoczi    LIBS="-lust $LIBS"
22867e24e92aSStefan Hajnoczi  else
22877e24e92aSStefan Hajnoczi    echo
22887e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
22897e24e92aSStefan Hajnoczi    echo
22907e24e92aSStefan Hajnoczi    exit 1
22917e24e92aSStefan Hajnoczi  fi
22927e24e92aSStefan Hajnoczifi
2293b3d08c02SDaniel P. Berrange
2294b3d08c02SDaniel P. Berrange##########################################
2295b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2296b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2297b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2298b3d08c02SDaniel P. Berrange    echo
2299b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2300b3d08c02SDaniel P. Berrange    echo
2301b3d08c02SDaniel P. Berrange    exit 1
2302b3d08c02SDaniel P. Berrange  fi
2303c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2304c276b17dSDaniel P. Berrange  if has 'stap' ; then
2305c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2306c276b17dSDaniel P. Berrange  fi
2307b3d08c02SDaniel P. Berrangefi
2308b3d08c02SDaniel P. Berrange
23097e24e92aSStefan Hajnoczi##########################################
2310e86ecd4bSJuan Quintela# End of CC checks
2311e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2312e86ecd4bSJuan Quintela
2313e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
23141156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2315e86ecd4bSJuan Quintelafi
2316a316e378SJuan Quintela
2317e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2318e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2319e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
232020ff6c80SAnthony Liguori
232120ff6c80SAnthony Liguoriif test -z "$werror" ; then
2322e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2323e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2324e86ecd4bSJuan Quintela        werror="yes"
2325e86ecd4bSJuan Quintela    else
2326e86ecd4bSJuan Quintela        werror="no"
2327e86ecd4bSJuan Quintela    fi
2328e86ecd4bSJuan Quintelafi
2329e86ecd4bSJuan Quintela
233020ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
233120ff6c80SAnthony Liguori# enable/disable
233220ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
233320ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
233420ff6c80SAnthony Liguori	zero_malloc="no"
233520ff6c80SAnthony Liguori    else
233620ff6c80SAnthony Liguori	zero_malloc="yes"
233720ff6c80SAnthony Liguori    fi
233820ff6c80SAnthony Liguorifi
233920ff6c80SAnthony Liguori
2340e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2341a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2342e86ecd4bSJuan Quintelafi
2343e86ecd4bSJuan Quintela
2344e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2345e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
23461156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2347e86ecd4bSJuan Quintela    fi
2348e86ecd4bSJuan Quintelafi
2349e86ecd4bSJuan Quintela
2350952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
2351952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
2352952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
2353952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2354952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
2355952afb71SBlue Swirl        fi
2356952afb71SBlue Swirl    done
2357952afb71SBlue Swirlfi
2358952afb71SBlue Swirl
2359190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
23605a67135aSbellard
2361ca35f780SPaolo Bonzinitools=
2362ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2363ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2364ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2365ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2366ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2367ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2368ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2369ca35f780SPaolo Bonzini    fi
2370ca35f780SPaolo Bonzini  fi
2371ca35f780SPaolo Bonzinifi
2372ca35f780SPaolo Bonzini
2373ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2374ca35f780SPaolo Bonziniroms=
2375ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2376ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2377ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2378ca35f780SPaolo Bonzini  roms="optionrom"
2379ca35f780SPaolo Bonzinifi
2380ca35f780SPaolo Bonzini
2381ca35f780SPaolo Bonzini
23827d13299dSbellardecho "Install prefix    $prefix"
2383f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2384f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
23851c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
238611d9f695Sbellardif test "$mingw32" = "no" ; then
2387f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
238843ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
238911d9f695Sbellardfi
23905a67135aSbellardecho "Source path       $source_path"
23917d13299dSbellardecho "C compiler        $cc"
239283469015Sbellardecho "Host C compiler   $host_cc"
23930c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2394a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
23950c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
23967d13299dSbellardecho "make              $make"
23976a882643Spbrookecho "install           $install"
2398a98fd896Sbellardecho "host CPU          $cpu"
2399de83cd02Sbellardecho "host big endian   $bigendian"
240097a847bcSbellardecho "target list       $target_list"
2401ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2402b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
24037d13299dSbellardecho "gprof enabled     $gprof"
240403b4fe7dSaliguoriecho "sparse enabled    $sparse"
24051625af87Saliguoriecho "strip binaries    $strip_opt"
240605c2a3e7Sbellardecho "profiler          $profiler"
240743ce4dfeSbellardecho "static build      $static"
240885aa5189Sbellardecho "-Werror enabled   $werror"
24095b0753e0Sbellardif test "$darwin" = "yes" ; then
24105b0753e0Sbellard    echo "Cocoa support     $cocoa"
24115b0753e0Sbellardfi
241297a847bcSbellardecho "SDL support       $sdl"
24134d3b6f6eSbalrogecho "curses support    $curses"
2414769ce76dSAlexander Grafecho "curl support      $curl"
24155495ed11SLuiz Capitulinoecho "check support     $check_utests"
241667b915a5Sbellardecho "mingw32 support   $mingw32"
24170c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
24180c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2419eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
24208ff9cbf7Smalcecho "Mixer emulation   $mixemu"
24218d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
24222f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
24232f6f5c7aSCorentin Charyecho "VNC JPEG support  $vnc_jpeg"
2424efe556adSCorentin Charyecho "VNC PNG support   $vnc_png"
2425bd023f95SCorentin Charyecho "VNC thread        $vnc_thread"
24263142255cSblueswir1if test -n "$sparc_cpu"; then
24273142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
24283142255cSblueswir1fi
2429e37630caSaliguoriecho "xen support       $xen"
24302e4d9fb1Saurel32echo "brlapi support    $brlapi"
2431a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2432a25dba17SJuan Quintelaecho "Documentation     $docs"
2433c5937220Spbrook[ ! -z "$uname_release" ] && \
2434c5937220Spbrookecho "uname -r          $uname_release"
2435bd0c5661Spbrookecho "NPTL support      $nptl"
2436379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
243734005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
24388a16d273Sthsecho "vde support       $vde"
2439e5d355d1Saliguoriecho "IO thread         $io_thread"
24405c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2441758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
244277755340Sthsecho "Install blobs     $blobs"
2443b31a0277SJuan Quintelaecho "KVM support       $kvm"
2444f652e6afSaurel32echo "fdt support       $fdt"
2445ceb42de8Saliguoriecho "preadv support    $preadv"
24465f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2447e78815a5SAndreas Färberecho "madvise           $madvise"
2448e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
2449ee682d27SStefan Weilecho "uuid support      $uuid"
2450d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
245194a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
24529410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
2453cd4ec0b4SGerd Hoffmannecho "spice support     $spice"
2454f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
2455dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
245667b915a5Sbellard
245797a847bcSbellardif test $sdl_too_old = "yes"; then
245824b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2459e8cd23deSbellardfi
246097a847bcSbellard
246198ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
24624bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
246397a847bcSbellard
246498ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
246598ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
246698ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
246798ec69acSJuan Quintelaecho >> $config_host_mak
246898ec69acSJuan Quintela
2469e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
247099d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
247199d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
247299d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
247399d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
247499d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
247599d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
24761dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2477804edf29SJuan Quintela
24782408a527Saurel32case "$cpu" in
247924e804ecSAlexander Graf  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2480e0da9dd3SJuan Quintela    ARCH=$cpu
24812408a527Saurel32  ;;
2482a302c32dSLaurent Desnogues  armv4b|armv4l)
248316dbd14fSJuan Quintela    ARCH=arm
24842408a527Saurel32  ;;
24852408a527Saurel32esac
248698ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2487f8393946Saurel32if test "$debug_tcg" = "yes" ; then
24882358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2489f8393946Saurel32fi
2490b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2491b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2492b4475aa2SLuiz Capitulinofi
2493f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
24942358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2495f3d08ee6SPaul Brookfi
24961625af87Saliguoriif test "$strip_opt" = "yes" ; then
249752ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
24981625af87Saliguorifi
24997d13299dSbellardif test "$bigendian" = "yes" ; then
2500e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
250197a847bcSbellardfi
25022358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
250367b915a5Sbellardif test "$mingw32" = "yes" ; then
250498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
25059fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
25069fe6de94SBlue Swirl  version_major=${rc_version%%.*}
25079fe6de94SBlue Swirl  rc_version=${rc_version#*.}
25089fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
25099fe6de94SBlue Swirl  rc_version=${rc_version#*.}
25109fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
25119fe6de94SBlue Swirl  version_micro=0
25129fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
25139fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2514210fa556Spbrookelse
251535f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2516210fa556Spbrookfi
2517128ab2ffSblueswir1
2518dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2519dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2520dffcb71cSMark McLoughlinfi
2521dffcb71cSMark McLoughlin
252283fb7adfSbellardif test "$darwin" = "yes" ; then
252398ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
252483fb7adfSbellardfi
2525b29fe3edSmalc
2526b29fe3edSmalcif test "$aix" = "yes" ; then
252798ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2528b29fe3edSmalcfi
2529b29fe3edSmalc
2530ec530c81Sbellardif test "$solaris" = "yes" ; then
253198ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
25322358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
25330475a5caSths  if test "$needs_libsunmath" = "yes" ; then
253475b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
25350475a5caSths  fi
2536ec530c81Sbellardfi
2537179cf400SAndreas Färberif test "$haiku" = "yes" ; then
2538179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
2539179cf400SAndreas Färberfi
254097a847bcSbellardif test "$static" = "yes" ; then
254198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
254297a847bcSbellardfi
254305c2a3e7Sbellardif test $profiler = "yes" ; then
25442358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
254505c2a3e7Sbellardfi
2546c20709aaSbellardif test "$slirp" = "yes" ; then
254798ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2548b6e31c12SJuan Quintela  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
2549c20709aaSbellardfi
25508a16d273Sthsif test "$vde" = "yes" ; then
255198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
25528a16d273Sthsfi
25530c58ac1cSmalcfor card in $audio_card_list; do
2554f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
255598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
25560c58ac1cSmalcdone
25572358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
25580c58ac1cSmalcfor drv in $audio_drv_list; do
2559f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
256098ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2561923e4521Smalc    if test "$drv" = "fmod"; then
25627aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2563fb065187Sbellard    fi
25640c58ac1cSmalcdone
256567f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
256667f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
256767f86e8eSJuan Quintelafi
2568d5631638Smalcif test "$audio_win_int" = "yes" ; then
2569d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2570d5631638Smalcfi
2571eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
25728ff9cbf7Smalcif test "$mixemu" = "yes" ; then
257398ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
25748ff9cbf7Smalcfi
25758d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
257698ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2577525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
25788d5d2d4cSthsfi
25792f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
258098ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
258160ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
25822f9606b3Saliguorifi
258396763cf9SCorentin Charyif test "$vnc_jpeg" != "no" ; then
25842f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
25852f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
25862f6f5c7aSCorentin Charyfi
258796763cf9SCorentin Charyif test "$vnc_png" != "no" ; then
2588efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2589efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2590efe556adSCorentin Charyfi
259196763cf9SCorentin Charyif test "$vnc_thread" != "no" ; then
2592bd023f95SCorentin Chary  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2593bd023f95SCorentin Chary  echo "CONFIG_THREAD=y" >> $config_host_mak
2594bd023f95SCorentin Charyfi
259576655d6dSaliguoriif test "$fnmatch" = "yes" ; then
25962358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
259776655d6dSaliguorifi
2598ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2599ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2600ee682d27SStefan Weilfi
2601dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
2602dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
2603dce512deSChristoph Hellwigfi
2604b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
260598ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
26062358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
260798ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
260898ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2609a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
261098ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2611cc8ae6deSpbrookfi
26121ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
261398ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
26148ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
261549ecc3faSbellardfi
261649ecc3faSbellardif test "$cocoa" = "yes" ; then
261798ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
261849ecc3faSbellardfi
26194d3b6f6eSbalrogif test "$curses" = "yes" ; then
262098ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2621ab4e5602SJan Kiszkafi
26223b3f24adSaurel32if test "$atfile" = "yes" ; then
26232358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
26243b3f24adSaurel32fi
2625ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
26262358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2627ebc996f3SRiku Voipiofi
2628099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
26292358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2630099d6b0fSRiku Voipiofi
263140ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
263240ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
263340ff6d7eSKevin Wolffi
26343ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
26352358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
26363ce34dfbSvibisreenivasanfi
2637c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2638c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2639c2882b96SRiku Voipiofi
2640d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2641d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2642d0927938SUlrich Hechtfi
2643c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
2644c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2645c727f47dSPeter Maydellfi
2646dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
2647dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
2648dace20dcSPeter Maydellfi
2649d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2650d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2651d0927938SUlrich Hechtfi
26523b3f24adSaurel32if test "$inotify" = "yes" ; then
26532358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
26543b3f24adSaurel32fi
2655c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2656c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2657c05c7a73SRiku Voipiofi
26586ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
26596ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
26606ae9a1f4SJuan Quintelafi
26616ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
26626ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
26636ae9a1f4SJuan Quintelafi
2664769ce76dSAlexander Grafif test "$curl" = "yes" ; then
266598ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2666b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2667769ce76dSAlexander Graffi
26682e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
266998ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
26702e4d9fb1Saurel32fi
2671fb599c9aSbalrogif test "$bluez" = "yes" ; then
267298ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2673ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2674fb599c9aSbalrogfi
2675e37630caSaliguoriif test "$xen" = "yes" ; then
26765647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2677e37630caSaliguorifi
2678e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
267998ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2680bd023f95SCorentin Chary  echo "CONFIG_THREAD=y" >> $config_host_mak
2681e5d355d1Saliguorifi
26825c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
26835c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
26845c6c3a6cSChristoph Hellwigfi
2685758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
2686758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
2687758e8e38SVenkateswararao Jujjuri (JV)fi
2688758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
2689758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
2690758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2691758e8e38SVenkateswararao Jujjuri (JV)  fi
2692758e8e38SVenkateswararao Jujjuri (JV)fi
269377755340Sthsif test "$blobs" = "yes" ; then
269498ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
269577755340Sthsfi
2696bf9298b9Saliguoriif test "$iovec" = "yes" ; then
26972358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2698bf9298b9Saliguorifi
2699ceb42de8Saliguoriif test "$preadv" = "yes" ; then
27002358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2701ceb42de8Saliguorifi
2702f652e6afSaurel32if test "$fdt" = "yes" ; then
27033f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2704f652e6afSaurel32fi
2705dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
2706dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2707dcc38d1cSMarcelo Tosattifi
2708de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2709de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2710de5071c5SBlue Swirlfi
2711747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2712747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2713747bbdf7SBlue Swirlfi
27145f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
27155f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
27165f6b9e8fSBlue Swirlfi
2717e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
2718e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
2719e78815a5SAndreas Färberfi
2720e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
2721e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2722e78815a5SAndreas Färberfi
272397a847bcSbellard
2724cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
2725cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
2726cd4ec0b4SGerd Hoffmannfi
2727cd4ec0b4SGerd Hoffmann
272883fb7adfSbellard# XXX: suppress that
27297d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
27302358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
27317d3505c5Sbellardfi
27327d3505c5Sbellard
27332358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2734c5937220Spbrook
273520ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
273620ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
273720ff6c80SAnthony Liguorifi
2738f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
2739f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
2740f27aaf4bSChristian Brunnerfi
274120ff6c80SAnthony Liguori
274268063649Sblueswir1# USB host support
274368063649Sblueswir1case "$usb" in
274468063649Sblueswir1linux)
274598ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
274668063649Sblueswir1;;
274768063649Sblueswir1bsd)
274898ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
274968063649Sblueswir1;;
275068063649Sblueswir1*)
275198ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
275268063649Sblueswir1;;
275368063649Sblueswir1esac
275468063649Sblueswir1
275594a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
275622890ab5SPrerna Saxenaif test "$trace_backend" = "simple"; then
275722890ab5SPrerna Saxena  echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
275822890ab5SPrerna Saxenafi
27599410b56cSPrerna Saxena# Set the appropriate trace file.
27609410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
27619410b56cSPrerna Saxena  trace_file="\"$trace_file-%u\""
27629410b56cSPrerna Saxenafi
2763c276b17dSDaniel P. Berrangeif test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
2764c276b17dSDaniel P. Berrange  echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
2765c276b17dSDaniel P. Berrangefi
27669410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
27679410b56cSPrerna Saxena
276898ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
276998ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2770804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2771804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
2772804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2773804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2774804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2775804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
27762b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
2777804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
2778804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2779804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2780804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
27819fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
2782e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
2783a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2784*e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
2785*e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2786*e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2787*e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2788*e39f0062SPaolo Bonzinifi
2789c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2790e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
2791a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2792a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
279373da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
27943e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2795804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2796804edf29SJuan Quintela
27974bf6b55bSJuan Quintela# generate list of library paths for linker script
27984bf6b55bSJuan Quintela
27994bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
28004bf6b55bSJuan Quintela
28014bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
28024bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
28034bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
28044bf6b55bSJuan Quintela  else
28054bf6b55bSJuan Quintela    rm ${config_host_ld}~
28064bf6b55bSJuan Quintela  fi
28074bf6b55bSJuan Quintelafi
28084bf6b55bSJuan Quintela
28094d904533SBlue Swirlfor d in libdis libdis-user; do
28104d904533SBlue Swirl    mkdir -p $d
28114d904533SBlue Swirl    rm -f $d/Makefile
28124d904533SBlue Swirl    ln -s $source_path/Makefile.dis $d/Makefile
28134d904533SBlue Swirl    echo > $d/config.mak
28144d904533SBlue Swirldone
2815d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
2816d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2817d44cff22SRichard Hendersonfi
28184d904533SBlue Swirl
281997a847bcSbellardfor target in $target_list; do
282097a847bcSbellardtarget_dir="$target"
282125be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
2822600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
282397a847bcSbellardtarget_bigendian="no"
28241f3d3c8fSJuan Quintela
2825ea2d6a39SJuan Quintelacase "$target_arch2" in
282624e804ecSAlexander Graf  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2827ea2d6a39SJuan Quintela  target_bigendian=yes
2828ea2d6a39SJuan Quintela  ;;
2829ea2d6a39SJuan Quintelaesac
283097a847bcSbellardtarget_softmmu="no"
2831997344f3Sbellardtarget_user_only="no"
2832831b7825Sthstarget_linux_user="no"
2833831b7825Sthstarget_darwin_user="no"
283484778508Sblueswir1target_bsd_user="no"
28359e407a85Spbrookcase "$target" in
2836600309b6SBlue Swirl  ${target_arch2}-softmmu)
28379e407a85Spbrook    target_softmmu="yes"
28389e407a85Spbrook    ;;
2839600309b6SBlue Swirl  ${target_arch2}-linux-user)
28409c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
28419c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
28429c7a4202SBlue Swirl      exit 1
28439c7a4202SBlue Swirl    fi
28449e407a85Spbrook    target_user_only="yes"
28459e407a85Spbrook    target_linux_user="yes"
28469e407a85Spbrook    ;;
2847600309b6SBlue Swirl  ${target_arch2}-darwin-user)
28489c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
28499c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
28509c7a4202SBlue Swirl      exit 1
28519c7a4202SBlue Swirl    fi
28529e407a85Spbrook    target_user_only="yes"
2853831b7825Sths    target_darwin_user="yes"
28549e407a85Spbrook    ;;
2855600309b6SBlue Swirl  ${target_arch2}-bsd-user)
28569cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
28579c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
28589c7a4202SBlue Swirl      exit 1
28599c7a4202SBlue Swirl    fi
286084778508Sblueswir1    target_user_only="yes"
286184778508Sblueswir1    target_bsd_user="yes"
286284778508Sblueswir1    ;;
28639e407a85Spbrook  *)
28649e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
28659e407a85Spbrook    exit 1
28669e407a85Spbrook    ;;
28679e407a85Spbrookesac
2868831b7825Sths
286997a847bcSbellardmkdir -p $target_dir
2870158142c2Sbellardmkdir -p $target_dir/fpu
287157fec1feSbellardmkdir -p $target_dir/tcg
287259f2a787SGerd Hoffmannmkdir -p $target_dir/ide
287384778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
287469de927cSbellard  mkdir -p $target_dir/nwfpe
287569de927cSbellardfi
287669de927cSbellard
2877ec530c81Sbellard#
2878ec530c81Sbellard# don't use ln -sf as not all "ln -sf" over write the file/link
2879ec530c81Sbellard#
2880ec530c81Sbellardrm -f $target_dir/Makefile
2881ec530c81Sbellardln -s $source_path/Makefile.target $target_dir/Makefile
2882ec530c81Sbellard
288397a847bcSbellard
288425be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
288597a847bcSbellard
2886e5fe0c52Spbrookbflt="no"
2887bd0c5661Spbrooktarget_nptl="no"
2888600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
28897ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
289056aebc89Spbrookgdb_xml_files=""
28917ba1e619Saliguori
2892938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
28936acff7daSJuan QuintelaTARGET_BASE_ARCH=""
2894e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
2895e73aae67SJuan Quintela
2896600309b6SBlue Swirlcase "$target_arch2" in
28972408a527Saurel32  i386)
28981ad2134fSPaul Brook    target_phys_bits=32
28992408a527Saurel32  ;;
29002408a527Saurel32  x86_64)
29016acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
29021ad2134fSPaul Brook    target_phys_bits=64
29032408a527Saurel32  ;;
29042408a527Saurel32  alpha)
29051ad2134fSPaul Brook    target_phys_bits=64
2906a4b388ffSRichard Henderson    target_nptl="yes"
29072408a527Saurel32  ;;
29082408a527Saurel32  arm|armeb)
2909b498c8a0SJuan Quintela    TARGET_ARCH=arm
2910e5fe0c52Spbrook    bflt="yes"
2911bd0c5661Spbrook    target_nptl="yes"
291256aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
29131ad2134fSPaul Brook    target_phys_bits=32
29142408a527Saurel32  ;;
29152408a527Saurel32  cris)
2916253bd7f8Sedgar_igl    target_nptl="yes"
29171ad2134fSPaul Brook    target_phys_bits=32
29182408a527Saurel32  ;;
29192408a527Saurel32  m68k)
29200938cda5Saurel32    bflt="yes"
292156aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
29221ad2134fSPaul Brook    target_phys_bits=32
29232408a527Saurel32  ;;
292472b675caSEdgar E. Iglesias  microblaze)
292572b675caSEdgar E. Iglesias    bflt="yes"
292672b675caSEdgar E. Iglesias    target_nptl="yes"
292772b675caSEdgar E. Iglesias    target_phys_bits=32
292872b675caSEdgar E. Iglesias  ;;
29292408a527Saurel32  mips|mipsel)
2930b498c8a0SJuan Quintela    TARGET_ARCH=mips
293125be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2932f04dc72fSPaul Brook    target_nptl="yes"
29331ad2134fSPaul Brook    target_phys_bits=64
29342408a527Saurel32  ;;
29352408a527Saurel32  mipsn32|mipsn32el)
2936b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
29376acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
293825be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
29391ad2134fSPaul Brook    target_phys_bits=64
29402408a527Saurel32  ;;
29412408a527Saurel32  mips64|mips64el)
2942b498c8a0SJuan Quintela    TARGET_ARCH=mips64
29436acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
294425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
29451ad2134fSPaul Brook    target_phys_bits=64
29462408a527Saurel32  ;;
29472408a527Saurel32  ppc)
2948c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
29491ad2134fSPaul Brook    target_phys_bits=32
2950d6630708SNathan Froyd    target_nptl="yes"
29512408a527Saurel32  ;;
29522408a527Saurel32  ppcemb)
29536acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2954e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2955c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
29561ad2134fSPaul Brook    target_phys_bits=64
2957d6630708SNathan Froyd    target_nptl="yes"
29582408a527Saurel32  ;;
29592408a527Saurel32  ppc64)
29606acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2961e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2962c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
29631ad2134fSPaul Brook    target_phys_bits=64
29642408a527Saurel32  ;;
29652408a527Saurel32  ppc64abi32)
2966b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
29676acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2968e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
296925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
2970c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
29711ad2134fSPaul Brook    target_phys_bits=64
29722408a527Saurel32  ;;
29732408a527Saurel32  sh4|sh4eb)
2974b498c8a0SJuan Quintela    TARGET_ARCH=sh4
29754dbed897Spbrook    bflt="yes"
29760b6d3ae0Saurel32    target_nptl="yes"
29771ad2134fSPaul Brook    target_phys_bits=32
29782408a527Saurel32  ;;
29792408a527Saurel32  sparc)
29801ad2134fSPaul Brook    target_phys_bits=64
29812408a527Saurel32  ;;
29822408a527Saurel32  sparc64)
29836acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
29841ad2134fSPaul Brook    target_phys_bits=64
29852408a527Saurel32  ;;
29862408a527Saurel32  sparc32plus)
2987b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
29886acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
2989e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
299025be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
29911ad2134fSPaul Brook    target_phys_bits=64
29922408a527Saurel32  ;;
299324e804ecSAlexander Graf  s390x)
299424e804ecSAlexander Graf    target_phys_bits=64
299524e804ecSAlexander Graf  ;;
29962408a527Saurel32  *)
2997de83cd02Sbellard    echo "Unsupported target CPU"
2998de83cd02Sbellard    exit 1
29992408a527Saurel32  ;;
30002408a527Saurel32esac
300125be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3002053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
300325be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
300425be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
300542bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
30066acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
30076acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
30086acff7daSJuan Quintelafi
300925be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3010e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3011e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3012e6e91b9cSJuan Quintelafi
301325be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
30141b0c87fcSJuan Quintelacase "$target_arch2" in
30151b0c87fcSJuan Quintela  i386|x86_64)
30161b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
301725be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
30181b0c87fcSJuan Quintela    fi
30191b0c87fcSJuan Quintelaesac
3020c59249f9SJuan Quintelacase "$target_arch2" in
30210e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3022c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3023c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3024c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3025c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
30265f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3027c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3028c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
302925be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
303025be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
3031dae5079aSJan Kiszka      if test "$kvm_para" = "yes"; then
3032dae5079aSJan Kiszka        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
3033dae5079aSJan Kiszka      fi
3034d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
3035d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3036d5970055SMichael S. Tsirkin      fi
3037c59249f9SJuan Quintela    fi
3038c59249f9SJuan Quintelaesac
3039de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
304025be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
304197a847bcSbellardfi
304297a847bcSbellardif test "$target_softmmu" = "yes" ; then
3043b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
304425be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
304525be210fSJuan Quintela  echo "LIBS+=$libs_softmmu" >> $config_target_mak
30460e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
30475791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3048de83cd02Sbellardfi
3049997344f3Sbellardif test "$target_user_only" = "yes" ; then
305025be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3051997344f3Sbellardfi
3052831b7825Sthsif test "$target_linux_user" = "yes" ; then
305325be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3054831b7825Sthsfi
3055831b7825Sthsif test "$target_darwin_user" = "yes" ; then
305625be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3057831b7825Sthsfi
305856aebc89Spbrooklist=""
305956aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
306056aebc89Spbrook  for x in $gdb_xml_files; do
306156aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
306256aebc89Spbrook  done
306325be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
30643d0f1517SJuan Quintelafi
3065de83cd02Sbellard
3066f57975fbSJuan Quintelacase "$target_arch2" in
3067990b3e19SRichard Henderson  alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
306825be210fSJuan Quintela    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
3069f57975fbSJuan Quintela    ;;
3070d6b38939SJuan Quintela  *)
307125be210fSJuan Quintela    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
3072d6b38939SJuan Quintela    ;;
3073f57975fbSJuan Quintelaesac
3074f57975fbSJuan Quintela
3075e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
307625be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3077e5fe0c52Spbrookfi
3078bd0c5661Spbrookif test "$target_user_only" = "yes" \
3079bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
308025be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3081bd0c5661Spbrookfi
3082379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
308325be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3084379f6698SPaul Brookfi
308584778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
308625be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
308784778508Sblueswir1fi
30885b0753e0Sbellard
30894afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3090fa282484SJuan Quintela
30914afddb55SJuan Quintelacflags=""
3092fa282484SJuan Quintelaldflags=""
30939b8e111fSJuan Quintela
309457ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
309557ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
309624e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
309724e804ecSAlexander Graf  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
30985d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
30995d8a4f8fSRichard Henderson  cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
310057ddfbf7SJuan Quintelaelse
310157ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
310257ddfbf7SJuan Quintelafi
310357ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/tcg $cflags"
310457ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/fpu $cflags"
310557ddfbf7SJuan Quintela
31064d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
31074d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
31084d904533SBlue Swirlelse
31094d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
31104d904533SBlue Swirlfi
31114d904533SBlue Swirl
311264656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
311364656024SJuan Quintela  case "$i" in
311464656024SJuan Quintela  alpha)
311525be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
31164d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
311764656024SJuan Quintela  ;;
311864656024SJuan Quintela  arm)
311925be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
31204d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
312164656024SJuan Quintela  ;;
312264656024SJuan Quintela  cris)
312325be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
31244d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
312564656024SJuan Quintela  ;;
312664656024SJuan Quintela  hppa)
312725be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
31284d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
312964656024SJuan Quintela  ;;
313064656024SJuan Quintela  i386|x86_64)
313125be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
31324d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
313364656024SJuan Quintela  ;;
3134903ec55cSAurelien Jarno  ia64*)
3135903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3136903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3137903ec55cSAurelien Jarno  ;;
313864656024SJuan Quintela  m68k)
313925be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
31404d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
314164656024SJuan Quintela  ;;
314264656024SJuan Quintela  microblaze)
314325be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
31444d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
314564656024SJuan Quintela  ;;
314664656024SJuan Quintela  mips*)
314725be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
31484d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
314964656024SJuan Quintela  ;;
315064656024SJuan Quintela  ppc*)
315125be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
31524d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
315364656024SJuan Quintela  ;;
315424e804ecSAlexander Graf  s390*)
315525be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
31564d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
315764656024SJuan Quintela  ;;
315864656024SJuan Quintela  sh4)
315925be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
31604d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
316164656024SJuan Quintela  ;;
316264656024SJuan Quintela  sparc*)
316325be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
31644d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
316564656024SJuan Quintela  ;;
316664656024SJuan Quintela  esac
316764656024SJuan Quinteladone
316864656024SJuan Quintela
31696ee7126fSJuan Quintelacase "$ARCH" in
31706ee7126fSJuan Quintelaalpha)
31716ee7126fSJuan Quintela  # Ensure there's only a single GP
31726ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
31736ee7126fSJuan Quintela;;
31746ee7126fSJuan Quintelaesac
31756ee7126fSJuan Quintela
317655d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
317755d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
317855d9c04bSJuan Quintela  arm)
317955d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
318055d9c04bSJuan Quintela  ;;
318155d9c04bSJuan Quintela  i386|mips|ppc)
318255d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
318355d9c04bSJuan Quintela  ;;
318455d9c04bSJuan Quintela  esac
318555d9c04bSJuan Quintelafi
318655d9c04bSJuan Quintela
318734005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
318834005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
318934005a00SKirill A. Shutemov  cflags="-fpie $cflags"
319034005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
319134005a00SKirill A. Shutemovfi
319234005a00SKirill A. Shutemov
3193471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
3194471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
3195471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
319625be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3197471857ddSJuan Quintelafi
3198471857ddSJuan Quintela
3199d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
320025be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
3201d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
3202d02c1db3SJuan Quintela    cflags="-p $cflags"
3203d02c1db3SJuan Quintela    ldflags="-p $ldflags"
3204d02c1db3SJuan Quintela  fi
3205d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
3206d02c1db3SJuan Quintela    ldflags="-p $ldflags"
320725be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3208d02c1db3SJuan Quintela  fi
3209d02c1db3SJuan Quintelafi
3210d02c1db3SJuan Quintela
32116ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
32129b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3213fa282484SJuan Quintela  case "$ARCH" in
3214fa282484SJuan Quintela  sparc)
3215fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
3216322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
3217fa282484SJuan Quintela    ;;
32184d58be06SRichard Henderson  alpha | s390x)
32194d58be06SRichard Henderson    # The default placement of the application is fine.
32204d58be06SRichard Henderson    ;;
3221fd76e73aSRichard Henderson  *)
3222322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
3223fa282484SJuan Quintela    ;;
3224fa282484SJuan Quintela  esac
3225fa282484SJuan Quintelafi
3226fa282484SJuan Quintela
322725be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
322825be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3229fa282484SJuan Quintela
323097a847bcSbellarddone # for target in $targets
32317d13299dSbellard
32327d13299dSbellard# build tree in object directory if source path is different from current one
32337d13299dSbellardif test "$source_path_used" = "yes" ; then
3234e1144d00SMark McLoughlin    DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
32352d9f27d2SAnthony Liguori    DIRS="$DIRS roms/seabios roms/vgabios"
32363e230dd2SCorentin Chary    DIRS="$DIRS fsdev ui"
32377d13299dSbellard    FILES="Makefile tests/Makefile"
3238e7daa605Sths    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3239e1ffb0f1Sedgar_igl    FILES="$FILES tests/test-mmap.c"
3240ae0bfb79SBlue Swirl    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
32412d9f27d2SAnthony Liguori    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
32427ea78b74SJan Kiszka    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
32437ea78b74SJan Kiszka        FILES="$FILES pc-bios/`basename $bios_file`"
32447ea78b74SJan Kiszka    done
32457d13299dSbellard    for dir in $DIRS ; do
32467d13299dSbellard            mkdir -p $dir
32477d13299dSbellard    done
3248ec530c81Sbellard    # remove the link and recreate it, as not all "ln -sf" overwrite the link
32497d13299dSbellard    for f in $FILES ; do
3250ec530c81Sbellard        rm -f $f
3251ec530c81Sbellard        ln -s $source_path/$f $f
32527d13299dSbellard    done
32537d13299dSbellardfi
32541ad2134fSPaul Brook
3255c34ebfdcSAnthony Liguori# temporary config to build submodules
32562d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
3257c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
325837116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3259c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3260c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3261c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
3262c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
3263c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3264c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
3265c34ebfdcSAnthony Liguori    echo "HOST_CC=$host_cc" >> $config_mak
3266c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
3267c34ebfdcSAnthony Liguoridone
3268c34ebfdcSAnthony Liguori
32691ad2134fSPaul Brookfor hwlib in 32 64; do
32701ad2134fSPaul Brook  d=libhw$hwlib
32711ad2134fSPaul Brook  mkdir -p $d
32729953b2fcSBlue Swirl  mkdir -p $d/ide
32731ad2134fSPaul Brook  rm -f $d/Makefile
32741ad2134fSPaul Brook  ln -s $source_path/Makefile.hw $d/Makefile
327537116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
32761ad2134fSPaul Brookdone
3277add16157SBlue Swirl
3278add16157SBlue Swirld=libuser
3279add16157SBlue Swirlmkdir -p $d
3280add16157SBlue Swirlrm -f $d/Makefile
3281add16157SBlue Swirlln -s $source_path/Makefile.user $d/Makefile
3282299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
3283299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3284299060a0SKirill A. Shutemovfi
3285b40292e7SJan Kiszka
3286b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
3287b40292e7SJan Kiszka  mkdir -p QMP
3288b40292e7SJan Kiszkafi
3289