xref: /openbmc/qemu/configure (revision 023ddd743136d2b1f7a2e6b3772736f96bfca1ff)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
57d13299dSbellard# set temporary file name
67d13299dSbellardif test ! -z "$TMPDIR" ; then
77d13299dSbellard    TMPDIR1="${TMPDIR}"
87d13299dSbellardelif test ! -z "$TEMPDIR" ; then
97d13299dSbellard    TMPDIR1="${TEMPDIR}"
107d13299dSbellardelse
117d13299dSbellard    TMPDIR1="/tmp"
127d13299dSbellardfi
137d13299dSbellard
143ef693a0SbellardTMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
153ef693a0SbellardTMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16a91b857cSmalcTMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
177d13299dSbellard
180ba8681eSLoïc Minier# NB: do not call "exit" in the trap handler; this is buggy with some shells;
190ba8681eSLoïc Minier# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
200ba8681eSLoïc Miniertrap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21da1d85e3SGerd Hoffmannrm -f config.log
229ac81bbbSmalc
2352166aa0SJuan Quintelacompile_object() {
24da1d85e3SGerd Hoffmann  echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
25da1d85e3SGerd Hoffmann  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
2652166aa0SJuan Quintela}
2752166aa0SJuan Quintela
2852166aa0SJuan Quintelacompile_prog() {
2952166aa0SJuan Quintela  local_cflags="$1"
3052166aa0SJuan Quintela  local_ldflags="$2"
31da1d85e3SGerd Hoffmann  echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
32da1d85e3SGerd Hoffmann  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
3352166aa0SJuan Quintela}
3452166aa0SJuan Quintela
3511568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
3611568d6dSPaolo Bonzinisymlink() {
3711568d6dSPaolo Bonzini  rm -f $2
3811568d6dSPaolo Bonzini  ln -s $1 $2
3911568d6dSPaolo Bonzini}
4011568d6dSPaolo Bonzini
410dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
420dba6195SLoïc Minier# executable or a builtin)
430dba6195SLoïc Minierhas() {
440dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
450dba6195SLoïc Minier}
460dba6195SLoïc Minier
470dba6195SLoïc Minier# search for an executable in PATH
480dba6195SLoïc Minierpath_of() {
490dba6195SLoïc Minier    local_command="$1"
500dba6195SLoïc Minier    local_ifs="$IFS"
510dba6195SLoïc Minier    local_dir=""
520dba6195SLoïc Minier
530dba6195SLoïc Minier    # pathname has a dir component?
540dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
550dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
560dba6195SLoïc Minier            echo "$local_command"
570dba6195SLoïc Minier            return 0
580dba6195SLoïc Minier        fi
590dba6195SLoïc Minier    fi
600dba6195SLoïc Minier    if [ -z "$local_command" ]; then
610dba6195SLoïc Minier        return 1
620dba6195SLoïc Minier    fi
630dba6195SLoïc Minier
640dba6195SLoïc Minier    IFS=:
650dba6195SLoïc Minier    for local_dir in $PATH; do
660dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
670dba6195SLoïc Minier            echo "$local_dir/$local_command"
680dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
690dba6195SLoïc Minier            return 0
700dba6195SLoïc Minier        fi
710dba6195SLoïc Minier    done
720dba6195SLoïc Minier    # not found
730dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
740dba6195SLoïc Minier    return 1
750dba6195SLoïc Minier}
760dba6195SLoïc Minier
777d13299dSbellard# default parameters
78ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
792ff6b91eSJuan Quintelacpu=""
801e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
8143ce4dfeSbellardstatic="no"
82ed968ff1SJuan Quintelasparc_cpu=""
837d13299dSbellardcross_prefix=""
840c58ac1cSmalcaudio_drv_list=""
85d61a4ce8SGerd Hoffmannaudio_card_list="ac97 es1370 sb16 hda"
86d61a4ce8SGerd Hoffmannaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
87eb852011SMarkus Armbrusterblock_drv_whitelist=""
887d13299dSbellardhost_cc="gcc"
89c81da56eSJuan Quintelahelper_cflags=""
9073da375eSJuan Quintelalibs_softmmu=""
913e2e0e6bSJuan Quintelalibs_tools=""
9267f86e8eSJuan Quintelaaudio_pt_int=""
93d5631638Smalcaudio_win_int=""
942b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
95957f1f99SMichael Rothlibs_qga=""
96ac0df51dSaliguori
97377529c0SPaolo Bonzinitarget_list=""
98377529c0SPaolo Bonzini
99377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
100377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
101377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
102377529c0SPaolo Bonzini#              unless --disable-foo is given
103377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
104377529c0SPaolo Bonzini#              feature will searched for,
105377529c0SPaolo Bonzini#              if not found, configure exits with error
106377529c0SPaolo Bonzini#
107377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
108377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
109377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
110377529c0SPaolo Bonzini
111377529c0SPaolo Bonzinibluez=""
112377529c0SPaolo Bonzinibrlapi=""
113377529c0SPaolo Bonzinicurl=""
114377529c0SPaolo Bonzinicurses=""
115377529c0SPaolo Bonzinidocs=""
116377529c0SPaolo Bonzinifdt=""
117377529c0SPaolo Bonzininptl=""
118377529c0SPaolo Bonzinisdl=""
119821601eaSJes Sorensenvnc="yes"
120377529c0SPaolo Bonzinisparse="no"
121377529c0SPaolo Bonziniuuid=""
122377529c0SPaolo Bonzinivde=""
123377529c0SPaolo Bonzinivnc_tls=""
124377529c0SPaolo Bonzinivnc_sasl=""
125377529c0SPaolo Bonzinivnc_jpeg=""
126377529c0SPaolo Bonzinivnc_png=""
127377529c0SPaolo Bonzinivnc_thread="no"
128377529c0SPaolo Bonzinixen=""
129d5b93ddfSAnthony PERARDxen_ctrl_version=""
130377529c0SPaolo Bonzinilinux_aio=""
131377529c0SPaolo Bonziniattr=""
1324f26f2b6SAvi Kivitylibattr=""
133377529c0SPaolo Bonzinixfs=""
134377529c0SPaolo Bonzini
135d41a75a2SBradvhost_net="no"
136d41a75a2SBradkvm="no"
137377529c0SPaolo Bonzinigprof="no"
138377529c0SPaolo Bonzinidebug_tcg="no"
139377529c0SPaolo Bonzinidebug_mon="no"
140377529c0SPaolo Bonzinidebug="no"
141377529c0SPaolo Bonzinistrip_opt="yes"
1429195b2c2SStefan Weiltcg_interpreter="no"
143377529c0SPaolo Bonzinibigendian="no"
144377529c0SPaolo Bonzinimingw32="no"
145377529c0SPaolo BonziniEXESUF=""
146377529c0SPaolo Bonziniprefix="/usr/local"
147377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
148377529c0SPaolo Bonzinidatadir="\${prefix}/share/qemu"
149377529c0SPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
150377529c0SPaolo Bonzinibindir="\${prefix}/bin"
1513aa5d2beSAlon Levylibdir="\${prefix}/lib"
1520f94d6daSAlon Levyincludedir="\${prefix}/include"
153377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
154377529c0SPaolo Bonziniconfsuffix="/qemu"
155377529c0SPaolo Bonzinislirp="yes"
156377529c0SPaolo Bonzinifmod_lib=""
157377529c0SPaolo Bonzinifmod_inc=""
158377529c0SPaolo Bonzinioss_lib=""
159377529c0SPaolo Bonzinibsd="no"
160377529c0SPaolo Bonzinilinux="no"
161377529c0SPaolo Bonzinisolaris="no"
162377529c0SPaolo Bonziniprofiler="no"
163377529c0SPaolo Bonzinicocoa="no"
164377529c0SPaolo Bonzinisoftmmu="yes"
165377529c0SPaolo Bonzinilinux_user="no"
166377529c0SPaolo Bonzinidarwin_user="no"
167377529c0SPaolo Bonzinibsd_user="no"
168377529c0SPaolo Bonziniguest_base=""
169377529c0SPaolo Bonziniuname_release=""
170377529c0SPaolo Bonzinimixemu="no"
171377529c0SPaolo Bonziniaix="no"
172377529c0SPaolo Bonziniblobs="yes"
173377529c0SPaolo Bonzinipkgversion=""
17425b651beSGerd Hoffmanncheck_utests=""
17540d6444eSAvi Kivitypie=""
176377529c0SPaolo Bonzinizero_malloc=""
177377529c0SPaolo Bonzinitrace_backend="nop"
178377529c0SPaolo Bonzinitrace_file="trace"
179377529c0SPaolo Bonzinispice=""
180377529c0SPaolo Bonzinirbd=""
18136707144SAlon Levysmartcard=""
182111a38b0SRobert Relyeasmartcard_nss=""
18369354a83SHans de Goedeusb_redir=""
184430a3c18SMichael Walleopengl=""
1851ece9905SAlon Levyzlib="yes"
186d138cee9SMichael Rothguest_agent="yes"
187c589b249SRonnie Sahlberglibiscsi=""
188377529c0SPaolo Bonzini
189ac0df51dSaliguori# parse CC options first
190ac0df51dSaliguorifor opt do
191ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
192ac0df51dSaliguori  case "$opt" in
193ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
194ac0df51dSaliguori  ;;
1953d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
196ac0df51dSaliguori  ;;
197ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
198ca4deeb1SPaolo Bonzini  ;;
1992ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
2002ff6b91eSJuan Quintela  ;;
201a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
202e2a2ed06SJuan Quintela  ;;
203e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
204e2a2ed06SJuan Quintela  ;;
20550e7b1a0SJuan Quintela  --sparc_cpu=*)
20650e7b1a0SJuan Quintela    sparc_cpu="$optarg"
20750e7b1a0SJuan Quintela    case $sparc_cpu in
208ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
20950e7b1a0SJuan Quintela      cpu="sparc"
21050e7b1a0SJuan Quintela    ;;
21150e7b1a0SJuan Quintela    v9)
21250e7b1a0SJuan Quintela      cpu="sparc64"
21350e7b1a0SJuan Quintela    ;;
21450e7b1a0SJuan Quintela    *)
21550e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
21650e7b1a0SJuan Quintela      exit 1
21750e7b1a0SJuan Quintela    ;;
21850e7b1a0SJuan Quintela    esac
21950e7b1a0SJuan Quintela  ;;
220ac0df51dSaliguori  esac
221ac0df51dSaliguoridone
222ac0df51dSaliguori# OS specific
223ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
224ac0df51dSaliguori# we can eliminate it's usage altogether
225ac0df51dSaliguori
226b3198cc2SStuart Yodercc="${CC-${cross_prefix}gcc}"
227b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
228b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
229b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
2303f534581SBradlibtool="${LIBTOOL-${cross_prefix}libtool}"
231b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
232b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
233b3198cc2SStuart Yoderpkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
234b3198cc2SStuart Yodersdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
235ac0df51dSaliguori
236be17dc90SMichael S. Tsirkin# default flags for all hosts
237be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
238be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
239f9188227SMike FrysingerQEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
240be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
241be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
24284958305SKirill A. ShutemovQEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
243cbbab922SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu"
244be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
245be17dc90SMichael S. Tsirkin
246ca4deeb1SPaolo Bonzini# make source path absolute
247ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
248ca4deeb1SPaolo Bonzini
249ac0df51dSaliguoricheck_define() {
250ac0df51dSaliguoricat > $TMPC <<EOF
251ac0df51dSaliguori#if !defined($1)
252ac0df51dSaliguori#error Not defined
253ac0df51dSaliguori#endif
254ac0df51dSaliguoriint main(void) { return 0; }
255ac0df51dSaliguoriEOF
25652166aa0SJuan Quintela  compile_object
257ac0df51dSaliguori}
258ac0df51dSaliguori
2592ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
2602ff6b91eSJuan Quintela  # command line argument
2612ff6b91eSJuan Quintela  :
2622ff6b91eSJuan Quintelaelif check_define __i386__ ; then
263ac0df51dSaliguori  cpu="i386"
264ac0df51dSaliguorielif check_define __x86_64__ ; then
265ac0df51dSaliguori  cpu="x86_64"
2663aa9bd6cSblueswir1elif check_define __sparc__ ; then
2673aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
2683aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
2693aa9bd6cSblueswir1  if check_define __arch64__ ; then
2703aa9bd6cSblueswir1    cpu="sparc64"
2713aa9bd6cSblueswir1  else
2723aa9bd6cSblueswir1    cpu="sparc"
2733aa9bd6cSblueswir1  fi
274fdf7ed96Smalcelif check_define _ARCH_PPC ; then
275fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
276fdf7ed96Smalc    cpu="ppc64"
277ac0df51dSaliguori  else
278fdf7ed96Smalc    cpu="ppc"
279fdf7ed96Smalc  fi
280afa05235SAurelien Jarnoelif check_define __mips__ ; then
281afa05235SAurelien Jarno  cpu="mips"
282477ba620SAurelien Jarnoelif check_define __ia64__ ; then
283477ba620SAurelien Jarno  cpu="ia64"
284d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
285d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
286d66ed0eaSAurelien Jarno    cpu="s390x"
287d66ed0eaSAurelien Jarno  else
288d66ed0eaSAurelien Jarno    cpu="s390"
289d66ed0eaSAurelien Jarno  fi
290f28ffed5SBradelif check_define __ARMEB__ ; then
291f28ffed5SBrad  cpu="armv4b"
292f28ffed5SBradelif check_define __ARMEL__ ; then
293f28ffed5SBrad  cpu="armv4l"
294f28ffed5SBradelif check_define __hppa__ ; then
295f28ffed5SBrad  cpu="hppa"
296fdf7ed96Smalcelse
297fdf7ed96Smalc  cpu=`uname -m`
298ac0df51dSaliguorifi
299ac0df51dSaliguori
3007d13299dSbellardcase "$cpu" in
301d2fbca94SGuan Xuetao  alpha|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64|unicore32)
302ea8f20f8SJuan Quintela    cpu="$cpu"
303ea8f20f8SJuan Quintela  ;;
3047d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
30597a847bcSbellard    cpu="i386"
3067d13299dSbellard  ;;
307aaa5fa14Saurel32  x86_64|amd64)
308aaa5fa14Saurel32    cpu="x86_64"
309aaa5fa14Saurel32  ;;
310ba68055eSbellard  armv*b)
311808c4954Sbellard    cpu="armv4b"
312808c4954Sbellard  ;;
313ba68055eSbellard  armv*l)
3147d13299dSbellard    cpu="armv4l"
3157d13299dSbellard  ;;
316f28ffed5SBrad  hppa|parisc|parisc64)
317f54b3f92Saurel32    cpu="hppa"
318f54b3f92Saurel32  ;;
319afa05235SAurelien Jarno  mips*)
320afa05235SAurelien Jarno    cpu="mips"
321afa05235SAurelien Jarno  ;;
32224e804ecSAlexander Graf  s390)
323fb3e5849Sbellard    cpu="s390"
324fb3e5849Sbellard  ;;
32524e804ecSAlexander Graf  s390x)
32624e804ecSAlexander Graf    cpu="s390x"
32724e804ecSAlexander Graf  ;;
3283142255cSblueswir1  sparc|sun4[cdmuv])
329ae228531Sbellard    cpu="sparc"
330ae228531Sbellard  ;;
3317d13299dSbellard  *)
332a447d4dcSPaolo Bonzini    echo "Unsupported CPU = $cpu"
333a447d4dcSPaolo Bonzini    exit 1
3347d13299dSbellard  ;;
3357d13299dSbellardesac
336e2d52ad3SJuan Quintela
3377d13299dSbellard# OS specific
338ac0df51dSaliguoriif check_define __linux__ ; then
339ac0df51dSaliguori  targetos="Linux"
340ac0df51dSaliguorielif check_define _WIN32 ; then
341ac0df51dSaliguori  targetos='MINGW32'
342169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
343169dc5d3Sblueswir1  targetos='OpenBSD'
344169dc5d3Sblueswir1elif check_define __sun__ ; then
345169dc5d3Sblueswir1  targetos='SunOS'
346179cf400SAndreas Färberelif check_define __HAIKU__ ; then
347179cf400SAndreas Färber  targetos='Haiku'
348ac0df51dSaliguorielse
3497d13299dSbellard  targetos=`uname -s`
350ac0df51dSaliguorifi
3510dbfc675SJuan Quintela
3527d13299dSbellardcase $targetos in
353c326e0afSbellardCYGWIN*)
354c326e0afSbellard  mingw32="yes"
355a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
356d5631638Smalc  audio_possible_drivers="winwave sdl"
357d5631638Smalc  audio_drv_list="winwave"
358c326e0afSbellard;;
35967b915a5SbellardMINGW32*)
36067b915a5Sbellard  mingw32="yes"
361d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
362d5631638Smalc  audio_drv_list="winwave"
36367b915a5Sbellard;;
3645c40d2bdSthsGNU/kFreeBSD)
365a167ba50SAurelien Jarno  bsd="yes"
3660c58ac1cSmalc  audio_drv_list="oss"
367f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3685c40d2bdSths;;
3697d3505c5SbellardFreeBSD)
3707d3505c5Sbellard  bsd="yes"
3710db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3720c58ac1cSmalc  audio_drv_list="oss"
373f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
374f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
375f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3767d3505c5Sbellard;;
377c5e97233Sblueswir1DragonFly)
378c5e97233Sblueswir1  bsd="yes"
3790db4a067SPaolo Bonzini  make="${MAKE-gmake}"
380c5e97233Sblueswir1  audio_drv_list="oss"
381c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
382c5e97233Sblueswir1;;
3837d3505c5SbellardNetBSD)
3847d3505c5Sbellard  bsd="yes"
3850db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3860c58ac1cSmalc  audio_drv_list="oss"
387c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3888ef92a88Sblueswir1  oss_lib="-lossaudio"
3897d3505c5Sbellard;;
3907d3505c5SbellardOpenBSD)
3917d3505c5Sbellard  bsd="yes"
3920db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3930c58ac1cSmalc  audio_drv_list="oss"
394c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3952f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3967d3505c5Sbellard;;
39783fb7adfSbellardDarwin)
39883fb7adfSbellard  bsd="yes"
39983fb7adfSbellard  darwin="yes"
4000dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
4010dbfc675SJuan Quintela  # run 64-bit userspace code
402aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
4031b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
404aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
4051b0f9cc2Saliguori  fi
4061b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
407a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
4080c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
4091b0f9cc2Saliguori  else
410a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
4111b0f9cc2Saliguori  fi
412831b7825Sths  darwin_user="yes"
413fd677642Sths  cocoa="yes"
4140c58ac1cSmalc  audio_drv_list="coreaudio"
415c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4160c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4177973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
41883fb7adfSbellard;;
419ec530c81SbellardSunOS)
420ec530c81Sbellard  solaris="yes"
4210db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4220db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
423fa58948dSBlue Swirl  ld="gld"
424e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
4250475a5caSths  needs_libsunmath="no"
426c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
427ef18c883Sths  # have to select again, because `uname -m` returns i86pc
428ef18c883Sths  # even on an x86_64 box.
429ef18c883Sths  solariscpu=`isainfo -k`
430ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
431ef18c883Sths    cpu="x86_64"
432ef18c883Sths  fi
433c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4340475a5caSths    if test "$solarisrev" -le 9 ; then
4350475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4360475a5caSths        needs_libsunmath="yes"
437f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
438f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
439f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4400475a5caSths      else
4410475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4420475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4430475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4440475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4450475a5caSths        exit 1
4460475a5caSths      fi
4470475a5caSths    fi
44886b2bd93Sths  fi
4496b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4500c58ac1cSmalc    audio_drv_list="oss"
4516b4d2ba1Sths  fi
452c2de5c91Smalc  audio_possible_drivers="oss sdl"
453d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
454d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
455d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
456d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
457a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
458e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
459ec530c81Sbellard;;
460b29fe3edSmalcAIX)
461b29fe3edSmalc  aix="yes"
4620db4a067SPaolo Bonzini  make="${MAKE-gmake}"
463b29fe3edSmalc;;
464179cf400SAndreas FärberHaiku)
465179cf400SAndreas Färber  haiku="yes"
466179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
467179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
468179cf400SAndreas Färber;;
469fb065187Sbellard*)
4700c58ac1cSmalc  audio_drv_list="oss"
471b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4725327cf48Sbellard  linux="yes"
473831b7825Sths  linux_user="yes"
47468063649Sblueswir1  usb="linux"
475af2be207SJan Kiszka  kvm="yes"
476af2be207SJan Kiszka  vhost_net="yes"
47707f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
478c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
479c9ec1fe4Sbellard  fi
480fb065187Sbellard;;
4817d13299dSbellardesac
4827d13299dSbellard
4837d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
484b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
48568063649Sblueswir1    usb="bsd"
48683fb7adfSbellard  fi
48784778508Sblueswir1  bsd_user="yes"
4887d3505c5Sbellardfi
4897d3505c5Sbellard
4900db4a067SPaolo Bonzini: ${make=${MAKE-make}}
4910db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
492c886edfbSBlue Swirl: ${python=${PYTHON-python}}
493e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
4940db4a067SPaolo Bonzini
4953457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4963457a3f8SJuan Quintela  EXESUF=".exe"
497a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
498e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
499e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
50008f3896aSStefan Weil  LIBS="-lwinmm -lws2_32 -liberty -liphlpapi $LIBS"
501683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
502683035deSPaolo Bonzini  mandir="\${prefix}"
503683035deSPaolo Bonzini  datadir="\${prefix}"
504683035deSPaolo Bonzini  docdir="\${prefix}"
505683035deSPaolo Bonzini  bindir="\${prefix}"
506683035deSPaolo Bonzini  sysconfdir="\${prefix}"
507683035deSPaolo Bonzini  confsuffix=""
50883b2f0a0SStefan Weil  guest_agent="no"
5093457a3f8SJuan Quintelafi
5103457a3f8SJuan Quintela
511487fefdbSAnthony Liguoriwerror=""
51285aa5189Sbellard
5137d13299dSbellardfor opt do
514a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
5157d13299dSbellard  case "$opt" in
5162efc3265Sbellard  --help|-h) show_help=yes
5172efc3265Sbellard  ;;
51899123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
51999123e13SMike Frysinger  ;;
520b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5217d13299dSbellard  ;;
522b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
52332ce6337Sbellard  ;;
524ca4deeb1SPaolo Bonzini  --source-path=*)
5257d13299dSbellard  ;;
526ac0df51dSaliguori  --cross-prefix=*)
5277d13299dSbellard  ;;
528ac0df51dSaliguori  --cc=*)
5297d13299dSbellard  ;;
530b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
53183469015Sbellard  ;;
532b1a550a0Spbrook  --make=*) make="$optarg"
5337d13299dSbellard  ;;
5346a882643Spbrook  --install=*) install="$optarg"
5356a882643Spbrook  ;;
536c886edfbSBlue Swirl  --python=*) python="$optarg"
537c886edfbSBlue Swirl  ;;
538e2d8830eSBrad  --smbd=*) smbd="$optarg"
539e2d8830eSBrad  ;;
540e2a2ed06SJuan Quintela  --extra-cflags=*)
5417d13299dSbellard  ;;
542e2a2ed06SJuan Quintela  --extra-ldflags=*)
5437d13299dSbellard  ;;
5442ff6b91eSJuan Quintela  --cpu=*)
5457d13299dSbellard  ;;
546b1a550a0Spbrook  --target-list=*) target_list="$optarg"
547de83cd02Sbellard  ;;
54874242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
54994a420b1SStefan Hajnoczi  ;;
55074242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
5519410b56cSPrerna Saxena  ;;
5527d13299dSbellard  --enable-gprof) gprof="yes"
5537d13299dSbellard  ;;
55479427693SLoïc Minier  --static)
55579427693SLoïc Minier    static="yes"
55679427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
55743ce4dfeSbellard  ;;
5580b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5590b24e75fSPaolo Bonzini  ;;
5600b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5610b24e75fSPaolo Bonzini  ;;
5623aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
5633aa5d2beSAlon Levy  ;;
5640f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
5650f94d6daSAlon Levy  ;;
5660b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5670b24e75fSPaolo Bonzini  ;;
5680b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5690b24e75fSPaolo Bonzini  ;;
570ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
57107381cc1SAnthony Liguori  ;;
572*023ddd74SMax Filippov  --sbindir=*|--libexecdir=*|--sharedstatedir=*|--localstatedir=*|\
573*023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
574*023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
575*023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
576*023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
577*023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
578*023ddd74SMax Filippov    # lots of directory switches by default.
579*023ddd74SMax Filippov  ;;
58097a847bcSbellard  --disable-sdl) sdl="no"
58197a847bcSbellard  ;;
582c4198157SJuan Quintela  --enable-sdl) sdl="yes"
583c4198157SJuan Quintela  ;;
584821601eaSJes Sorensen  --disable-vnc) vnc="no"
585821601eaSJes Sorensen  ;;
586821601eaSJes Sorensen  --enable-vnc) vnc="yes"
587821601eaSJes Sorensen  ;;
588b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
589102a52e4Sbellard  ;;
590c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
591c2de5c91Smalc  ;;
5922f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5932f6a1ab0Sblueswir1  ;;
5942fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5950c58ac1cSmalc  ;;
5960c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5970c58ac1cSmalc  ;;
598eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
599eb852011SMarkus Armbruster  ;;
600f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
601f8393946Saurel32  ;;
602f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
603f8393946Saurel32  ;;
604b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
605b4475aa2SLuiz Capitulino  ;;
606b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
607b4475aa2SLuiz Capitulino  ;;
608f3d08ee6SPaul Brook  --enable-debug)
609f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
610f3d08ee6SPaul Brook      debug_tcg="yes"
611b4475aa2SLuiz Capitulino      debug_mon="yes"
612f3d08ee6SPaul Brook      debug="yes"
613f3d08ee6SPaul Brook      strip_opt="no"
614f3d08ee6SPaul Brook  ;;
61503b4fe7dSaliguori  --enable-sparse) sparse="yes"
61603b4fe7dSaliguori  ;;
61703b4fe7dSaliguori  --disable-sparse) sparse="no"
61803b4fe7dSaliguori  ;;
6191625af87Saliguori  --disable-strip) strip_opt="no"
6201625af87Saliguori  ;;
6218d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
6228d5d2d4cSths  ;;
6231be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
6241be10ad2SJuan Quintela  ;;
6252f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
6262f9606b3Saliguori  ;;
627ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
628ea784e3bSJuan Quintela  ;;
6292f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
6302f6f5c7aSCorentin Chary  ;;
6312f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
6322f6f5c7aSCorentin Chary  ;;
633efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
634efe556adSCorentin Chary  ;;
635efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
636efe556adSCorentin Chary  ;;
637bd023f95SCorentin Chary  --disable-vnc-thread) vnc_thread="no"
638bd023f95SCorentin Chary  ;;
639bd023f95SCorentin Chary  --enable-vnc-thread) vnc_thread="yes"
640bd023f95SCorentin Chary  ;;
641443f1376Sbellard  --disable-slirp) slirp="no"
642c20709aaSbellard  ;;
643ee682d27SStefan Weil  --disable-uuid) uuid="no"
644ee682d27SStefan Weil  ;;
645ee682d27SStefan Weil  --enable-uuid) uuid="yes"
646ee682d27SStefan Weil  ;;
647e0e6c8c0Saliguori  --disable-vde) vde="no"
6488a16d273Sths  ;;
649dfb278bdSJuan Quintela  --enable-vde) vde="yes"
650dfb278bdSJuan Quintela  ;;
651e37630caSaliguori  --disable-xen) xen="no"
652e37630caSaliguori  ;;
653fc321b4bSJuan Quintela  --enable-xen) xen="yes"
654fc321b4bSJuan Quintela  ;;
6552e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
6562e4d9fb1Saurel32  ;;
6574ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6584ffcedb6SJuan Quintela  ;;
659fb599c9aSbalrog  --disable-bluez) bluez="no"
660fb599c9aSbalrog  ;;
661a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
662a20a6f46SJuan Quintela  ;;
6637ba1e619Saliguori  --disable-kvm) kvm="no"
6647ba1e619Saliguori  ;;
665b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
666b31a0277SJuan Quintela  ;;
6679195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
6689195b2c2SStefan Weil  ;;
6699195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
6709195b2c2SStefan Weil  ;;
671cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
672cd4ec0b4SGerd Hoffmann  ;;
673cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
674cd4ec0b4SGerd Hoffmann  ;;
675c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
676c589b249SRonnie Sahlberg  ;;
677c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
678c589b249SRonnie Sahlberg  ;;
67905c2a3e7Sbellard  --enable-profiler) profiler="yes"
68005c2a3e7Sbellard  ;;
681c2de5c91Smalc  --enable-cocoa)
682c2de5c91Smalc      cocoa="yes" ;
683c2de5c91Smalc      sdl="no" ;
684c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6855b0753e0Sbellard  ;;
686cad25d69Spbrook  --disable-system) softmmu="no"
6870a8e90f4Spbrook  ;;
688cad25d69Spbrook  --enable-system) softmmu="yes"
6890a8e90f4Spbrook  ;;
6900953a80fSZachary Amsden  --disable-user)
6910953a80fSZachary Amsden      linux_user="no" ;
6920953a80fSZachary Amsden      bsd_user="no" ;
6930953a80fSZachary Amsden      darwin_user="no"
6940953a80fSZachary Amsden  ;;
6950953a80fSZachary Amsden  --enable-user) ;;
696831b7825Sths  --disable-linux-user) linux_user="no"
6970a8e90f4Spbrook  ;;
698831b7825Sths  --enable-linux-user) linux_user="yes"
699831b7825Sths  ;;
700831b7825Sths  --disable-darwin-user) darwin_user="no"
701831b7825Sths  ;;
702831b7825Sths  --enable-darwin-user) darwin_user="yes"
7030a8e90f4Spbrook  ;;
70484778508Sblueswir1  --disable-bsd-user) bsd_user="no"
70584778508Sblueswir1  ;;
70684778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
70784778508Sblueswir1  ;;
708379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
709379f6698SPaul Brook  ;;
710379f6698SPaul Brook  --disable-guest-base) guest_base="no"
711379f6698SPaul Brook  ;;
71240d6444eSAvi Kivity  --enable-pie) pie="yes"
71334005a00SKirill A. Shutemov  ;;
71440d6444eSAvi Kivity  --disable-pie) pie="no"
71534005a00SKirill A. Shutemov  ;;
716c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
717c5937220Spbrook  ;;
7183142255cSblueswir1  --sparc_cpu=*)
7193142255cSblueswir1  ;;
72085aa5189Sbellard  --enable-werror) werror="yes"
72185aa5189Sbellard  ;;
72285aa5189Sbellard  --disable-werror) werror="no"
72385aa5189Sbellard  ;;
7244d3b6f6eSbalrog  --disable-curses) curses="no"
7254d3b6f6eSbalrog  ;;
726c584a6d0SJuan Quintela  --enable-curses) curses="yes"
727c584a6d0SJuan Quintela  ;;
728769ce76dSAlexander Graf  --disable-curl) curl="no"
729769ce76dSAlexander Graf  ;;
730788c8196SJuan Quintela  --enable-curl) curl="yes"
731788c8196SJuan Quintela  ;;
7322df87df7SJuan Quintela  --disable-fdt) fdt="no"
7332df87df7SJuan Quintela  ;;
7342df87df7SJuan Quintela  --enable-fdt) fdt="yes"
7352df87df7SJuan Quintela  ;;
7365495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
7375495ed11SLuiz Capitulino  ;;
7385495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
7395495ed11SLuiz Capitulino  ;;
740bd0c5661Spbrook  --disable-nptl) nptl="no"
741bd0c5661Spbrook  ;;
742b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
743b0a47e79SJuan Quintela  ;;
7448ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
7458ff9cbf7Smalc  ;;
7465c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
7475c6c3a6cSChristoph Hellwig  ;;
7485c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
7495c6c3a6cSChristoph Hellwig  ;;
750758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
751758e8e38SVenkateswararao Jujjuri (JV)  ;;
752758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
753758e8e38SVenkateswararao Jujjuri (JV)  ;;
75477755340Sths  --disable-blobs) blobs="no"
75577755340Sths  ;;
7564a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
7574a19f1ecSpbrook  ;;
758a25dba17SJuan Quintela  --disable-docs) docs="no"
75970ec5dc0SAnthony Liguori  ;;
760a25dba17SJuan Quintela  --enable-docs) docs="yes"
76183a3ab8bSJuan Quintela  ;;
762d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
763d5970055SMichael S. Tsirkin  ;;
764d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
765d5970055SMichael S. Tsirkin  ;;
76620ff075bSMichael Walle  --disable-opengl) opengl="no"
76720ff075bSMichael Walle  ;;
76820ff075bSMichael Walle  --enable-opengl) opengl="yes"
76920ff075bSMichael Walle  ;;
770f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
771f27aaf4bSChristian Brunner  ;;
772f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
773f27aaf4bSChristian Brunner  ;;
77436707144SAlon Levy  --disable-smartcard) smartcard="no"
77536707144SAlon Levy  ;;
77636707144SAlon Levy  --enable-smartcard) smartcard="yes"
77736707144SAlon Levy  ;;
778111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
779111a38b0SRobert Relyea  ;;
780111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
781111a38b0SRobert Relyea  ;;
78269354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
78369354a83SHans de Goede  ;;
78469354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
78569354a83SHans de Goede  ;;
7861ece9905SAlon Levy  --disable-zlib-test) zlib="no"
7871ece9905SAlon Levy  ;;
788d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
789d138cee9SMichael Roth  ;;
790d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
791d138cee9SMichael Roth  ;;
7927f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7937f1559c6Sbalrog  ;;
7947d13299dSbellard  esac
7957d13299dSbellarddone
7967d13299dSbellard
7973142255cSblueswir1#
7983142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
799a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
8003142255cSblueswir1#
801379f6698SPaul Brookhost_guest_base="no"
80240293e58Sbellardcase "$cpu" in
803ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
804ed968ff1SJuan Quintela           v7|v8)
805a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
806ed968ff1SJuan Quintela           ;;
807ed968ff1SJuan Quintela           v8plus|v8plusa)
808a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
809ed968ff1SJuan Quintela           ;;
810ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
811a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
812ed968ff1SJuan Quintela           esac
8130c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
814a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
815762e8230Sblueswir1           if test "$solaris" = "no" ; then
816a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
817c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
818762e8230Sblueswir1           fi
8193142255cSblueswir1           ;;
820ed968ff1SJuan Quintela    sparc64)
821a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
8220c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
823a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
824ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
825a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
826762e8230Sblueswir1           fi
8273142255cSblueswir1           ;;
82876d83bdeSths    s390)
82928d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
83028d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
83148bb3750SRichard Henderson           host_guest_base="yes"
83228d7cc49SRichard Henderson           ;;
83328d7cc49SRichard Henderson    s390x)
83428d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
83528d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
83648bb3750SRichard Henderson           host_guest_base="yes"
83776d83bdeSths           ;;
83840293e58Sbellard    i386)
839a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
8400c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
8412b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
842c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
843379f6698SPaul Brook           host_guest_base="yes"
84440293e58Sbellard           ;;
84540293e58Sbellard    x86_64)
846a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
8470c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8482b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
849379f6698SPaul Brook           host_guest_base="yes"
850379f6698SPaul Brook           ;;
851379f6698SPaul Brook    arm*)
852379f6698SPaul Brook           host_guest_base="yes"
85340293e58Sbellard           ;;
854f6548c0aSmalc    ppc*)
855f6548c0aSmalc           host_guest_base="yes"
856f6548c0aSmalc           ;;
857cc01cc8eSAurelien Jarno    mips*)
858cc01cc8eSAurelien Jarno           host_guest_base="yes"
859cc01cc8eSAurelien Jarno           ;;
860477ba620SAurelien Jarno    ia64*)
861477ba620SAurelien Jarno           host_guest_base="yes"
862477ba620SAurelien Jarno           ;;
863fd76e73aSRichard Henderson    hppa*)
864fd76e73aSRichard Henderson           host_guest_base="yes"
865fd76e73aSRichard Henderson           ;;
866d2fbca94SGuan Xuetao    unicore32*)
867d2fbca94SGuan Xuetao           host_guest_base="yes"
868d2fbca94SGuan Xuetao           ;;
8693142255cSblueswir1esac
8703142255cSblueswir1
871379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
872379f6698SPaul Brook
87360e0df25SPeter Maydell
87460e0df25SPeter Maydelldefault_target_list=""
87560e0df25SPeter Maydell
87660e0df25SPeter Maydell# these targets are portable
87760e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
87860e0df25SPeter Maydell    default_target_list="\
87960e0df25SPeter Maydelli386-softmmu \
88060e0df25SPeter Maydellx86_64-softmmu \
88127cdad67SRichard Hendersonalpha-softmmu \
88260e0df25SPeter Maydellarm-softmmu \
88360e0df25SPeter Maydellcris-softmmu \
88460e0df25SPeter Maydelllm32-softmmu \
88560e0df25SPeter Maydellm68k-softmmu \
88660e0df25SPeter Maydellmicroblaze-softmmu \
88760e0df25SPeter Maydellmicroblazeel-softmmu \
88860e0df25SPeter Maydellmips-softmmu \
88960e0df25SPeter Maydellmipsel-softmmu \
89060e0df25SPeter Maydellmips64-softmmu \
89160e0df25SPeter Maydellmips64el-softmmu \
89260e0df25SPeter Maydellppc-softmmu \
89360e0df25SPeter Maydellppcemb-softmmu \
89460e0df25SPeter Maydellppc64-softmmu \
89560e0df25SPeter Maydellsh4-softmmu \
89660e0df25SPeter Maydellsh4eb-softmmu \
89760e0df25SPeter Maydellsparc-softmmu \
89860e0df25SPeter Maydellsparc64-softmmu \
8990f3301d4SAlexander Grafs390x-softmmu \
900cfa550c6SMax Filippovxtensa-softmmu \
901cfa550c6SMax Filippovxtensaeb-softmmu \
90260e0df25SPeter Maydell"
90360e0df25SPeter Maydellfi
90460e0df25SPeter Maydell# the following are Linux specific
90560e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
90660e0df25SPeter Maydell    default_target_list="${default_target_list}\
90760e0df25SPeter Maydelli386-linux-user \
90860e0df25SPeter Maydellx86_64-linux-user \
90960e0df25SPeter Maydellalpha-linux-user \
91060e0df25SPeter Maydellarm-linux-user \
91160e0df25SPeter Maydellarmeb-linux-user \
91260e0df25SPeter Maydellcris-linux-user \
91360e0df25SPeter Maydellm68k-linux-user \
91460e0df25SPeter Maydellmicroblaze-linux-user \
91560e0df25SPeter Maydellmicroblazeel-linux-user \
91660e0df25SPeter Maydellmips-linux-user \
91760e0df25SPeter Maydellmipsel-linux-user \
91860e0df25SPeter Maydellppc-linux-user \
91960e0df25SPeter Maydellppc64-linux-user \
92060e0df25SPeter Maydellppc64abi32-linux-user \
92160e0df25SPeter Maydellsh4-linux-user \
92260e0df25SPeter Maydellsh4eb-linux-user \
92360e0df25SPeter Maydellsparc-linux-user \
92460e0df25SPeter Maydellsparc64-linux-user \
92560e0df25SPeter Maydellsparc32plus-linux-user \
92660e0df25SPeter Maydellunicore32-linux-user \
9270f3301d4SAlexander Grafs390x-linux-user \
92860e0df25SPeter Maydell"
92960e0df25SPeter Maydellfi
93060e0df25SPeter Maydell# the following are Darwin specific
93160e0df25SPeter Maydellif [ "$darwin_user" = "yes" ] ; then
93260e0df25SPeter Maydell    default_target_list="$default_target_list i386-darwin-user ppc-darwin-user "
93360e0df25SPeter Maydellfi
93460e0df25SPeter Maydell# the following are BSD specific
93560e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
93660e0df25SPeter Maydell    default_target_list="${default_target_list}\
93760e0df25SPeter Maydelli386-bsd-user \
93860e0df25SPeter Maydellx86_64-bsd-user \
93960e0df25SPeter Maydellsparc-bsd-user \
94060e0df25SPeter Maydellsparc64-bsd-user \
94160e0df25SPeter Maydell"
94260e0df25SPeter Maydellfi
94360e0df25SPeter Maydell
944af5db58eSpbrookif test x"$show_help" = x"yes" ; then
945af5db58eSpbrookcat << EOF
946af5db58eSpbrook
947af5db58eSpbrookUsage: configure [options]
948af5db58eSpbrookOptions: [defaults in brackets after descriptions]
949af5db58eSpbrook
950af5db58eSpbrookEOF
951af5db58eSpbrookecho "Standard options:"
952af5db58eSpbrookecho "  --help                   print this message"
953af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
954af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
955af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
95660e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
95760e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
95860e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
959af5db58eSpbrookecho ""
960af5db58eSpbrookecho "Advanced options (experts only):"
961af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
962af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
963af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
9640bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
9650bfe8cc0SPaolo Bonziniecho "                           build time"
966a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
967e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
968af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
9696a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
970c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
971e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
972af5db58eSpbrookecho "  --static                 enable static build [$static]"
9730b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
9740b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
9750b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
9760b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
9770b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
978f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
979f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
98009695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
981890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
982890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
9831625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
98485aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
985fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
986c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
987821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
988821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
989af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
990c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
991c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
9924c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
9934c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
994eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
995eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
9968ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
997e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
998fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
9992e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
10004ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
10018d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
10021be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
10032f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
1004ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
10052f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
10062f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
100796763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1008efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
1009bd023f95SCorentin Charyecho "  --disable-vnc-thread     disable threaded VNC server"
1010bd023f95SCorentin Charyecho "  --enable-vnc-thread      enable threaded VNC server"
1011af896aaaSpbrookecho "  --disable-curses         disable curses output"
1012c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1013769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1014788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
10152df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
10162df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
10175495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
10185495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
1019fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1020a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
10216093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
10227ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1023b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
10249195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1025bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
1026e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
1027af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1028af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
10290953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
10300953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1031831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1032831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
1033831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
1034831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
103584778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
103684778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1037379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1038379f6698SPaul Brookecho "                           emulation targets"
1039379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
104040d6444eSAvi Kivityecho "  --enable-pie             build Position Independent Executables"
104140d6444eSAvi Kivityecho "  --disable-pie            do not build Position Independent Executables"
1042af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1043af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
10442f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1045c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1046235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
10473142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
1048ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1049ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1050e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1051dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
10525c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
10535c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
1054758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1055758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
105677755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1057d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1058d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1059d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1060d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1061320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1062320fba2aSFabien Chouteauecho "                           Available backends:" $("$source_path"/scripts/tracetool --list-backends)
106374242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
10649410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1065cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1066cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1067f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1068c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1069c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
107036707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
107136707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1072111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1073111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
107469354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
107569354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1076d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1077d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1078af5db58eSpbrookecho ""
10795bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1080af5db58eSpbrookexit 1
1081af5db58eSpbrookfi
1082af5db58eSpbrook
10838d05095cSPaolo Bonzini# check that the C compiler works.
10848d05095cSPaolo Bonzinicat > $TMPC <<EOF
10858d05095cSPaolo Bonziniint main(void) {}
10868d05095cSPaolo BonziniEOF
10878d05095cSPaolo Bonzini
10888d05095cSPaolo Bonziniif compile_object ; then
10898d05095cSPaolo Bonzini  : C compiler works ok
10908d05095cSPaolo Bonzinielse
10918d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
10928d05095cSPaolo Bonzini    exit 1
10938d05095cSPaolo Bonzinifi
10948d05095cSPaolo Bonzini
10958d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
10968d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
10978d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1098f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
10998d05095cSPaolo Bonzinicat > $TMPC << EOF
11008d05095cSPaolo Bonziniint main(void) { return 0; }
11018d05095cSPaolo BonziniEOF
11028d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1103af2d37deSStefan Weil    if compile_prog "$flag -Werror" "" ; then
11048d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
11058d05095cSPaolo Bonzini    fi
11068d05095cSPaolo Bonzinidone
11078d05095cSPaolo Bonzini
110840d6444eSAvi Kivityif test "$static" = "yes" ; then
110940d6444eSAvi Kivity  if test "$pie" = "yes" ; then
111040d6444eSAvi Kivity    echo "static and pie are mutually incompatible"
111140d6444eSAvi Kivity    exit 1
111240d6444eSAvi Kivity  else
111340d6444eSAvi Kivity    pie="no"
111440d6444eSAvi Kivity  fi
111540d6444eSAvi Kivityfi
111640d6444eSAvi Kivity
111740d6444eSAvi Kivityif test "$pie" = ""; then
111840d6444eSAvi Kivity  case "$cpu-$targetos" in
111940d6444eSAvi Kivity    i386-Linux|x86_64-Linux)
112040d6444eSAvi Kivity      ;;
112140d6444eSAvi Kivity    *)
112240d6444eSAvi Kivity      pie="no"
112340d6444eSAvi Kivity      ;;
112440d6444eSAvi Kivity  esac
112540d6444eSAvi Kivityfi
112640d6444eSAvi Kivity
112740d6444eSAvi Kivityif test "$pie" != "no" ; then
112840d6444eSAvi Kivity  cat > $TMPC << EOF
112921d4a791SAvi Kivity
113021d4a791SAvi Kivity#ifdef __linux__
113121d4a791SAvi Kivity#  define THREAD __thread
113221d4a791SAvi Kivity#else
113321d4a791SAvi Kivity#  define THREAD
113421d4a791SAvi Kivity#endif
113521d4a791SAvi Kivity
113621d4a791SAvi Kivitystatic THREAD int tls_var;
113721d4a791SAvi Kivity
113821d4a791SAvi Kivityint main(void) { return tls_var; }
113921d4a791SAvi Kivity
114040d6444eSAvi KivityEOF
114140d6444eSAvi Kivity  if compile_prog "-fPIE -DPIE" "-pie"; then
114240d6444eSAvi Kivity    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
114340d6444eSAvi Kivity    LDFLAGS="-pie $LDFLAGS"
114440d6444eSAvi Kivity    pie="yes"
114540d6444eSAvi Kivity    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
114640d6444eSAvi Kivity      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
114740d6444eSAvi Kivity    fi
114840d6444eSAvi Kivity  else
114940d6444eSAvi Kivity    if test "$pie" = "yes"; then
115040d6444eSAvi Kivity      echo "PIE not available due to missing toolchain support"
115140d6444eSAvi Kivity      exit 1
115240d6444eSAvi Kivity    else
115340d6444eSAvi Kivity      echo "Disabling PIE due to missing toolchain support"
115440d6444eSAvi Kivity      pie="no"
115540d6444eSAvi Kivity    fi
115640d6444eSAvi Kivity  fi
115740d6444eSAvi Kivityfi
115840d6444eSAvi Kivity
1159ec530c81Sbellard#
1160ec530c81Sbellard# Solaris specific configure tool chain decisions
1161ec530c81Sbellard#
1162ec530c81Sbellardif test "$solaris" = "yes" ; then
11636792aa11SLoïc Minier  if has $install; then
11646792aa11SLoïc Minier    :
11656792aa11SLoïc Minier  else
1166ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1167ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1168ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1169ec530c81Sbellard    exit 1
1170ec530c81Sbellard  fi
11716792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1172ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1173ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1174ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1175ec530c81Sbellard    exit 1
1176ec530c81Sbellard  fi
11776792aa11SLoïc Minier  if has ar; then
11786792aa11SLoïc Minier    :
11796792aa11SLoïc Minier  else
1180ec530c81Sbellard    echo "Error: No path includes ar"
1181ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1182ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1183ec530c81Sbellard    fi
1184ec530c81Sbellard    exit 1
1185ec530c81Sbellard  fi
1186ec530c81Sbellardfi
1187ec530c81Sbellard
1188d138cee9SMichael Rothif test "$guest_agent" != "no" ; then
1189c886edfbSBlue Swirl  if has $python; then
1190c886edfbSBlue Swirl    :
1191c886edfbSBlue Swirl  else
1192c886edfbSBlue Swirl    echo "Python not found. Use --python=/path/to/python"
1193c886edfbSBlue Swirl    exit 1
1194c886edfbSBlue Swirl  fi
1195d138cee9SMichael Rothfi
1196c886edfbSBlue Swirl
11975327cf48Sbellardif test -z "$target_list" ; then
119860e0df25SPeter Maydell    target_list="$default_target_list"
11996e20a45fSbellardelse
1200b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
12015327cf48Sbellardfi
12020a8e90f4Spbrookif test -z "$target_list" ; then
12030a8e90f4Spbrook    echo "No targets enabled"
12040a8e90f4Spbrook    exit 1
12050a8e90f4Spbrookfi
1206f55fe278SPaolo Bonzini# see if system emulation was really requested
1207f55fe278SPaolo Bonzinicase " $target_list " in
1208f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1209f55fe278SPaolo Bonzini  ;;
1210f55fe278SPaolo Bonzini  *) softmmu=no
1211f55fe278SPaolo Bonzini  ;;
1212f55fe278SPaolo Bonziniesac
12135327cf48Sbellard
1214249247c9SJuan Quintelafeature_not_found() {
1215249247c9SJuan Quintela  feature=$1
1216249247c9SJuan Quintela
1217249247c9SJuan Quintela  echo "ERROR"
1218249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
12199332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1220249247c9SJuan Quintela  echo "ERROR"
1221249247c9SJuan Quintela  exit 1;
1222249247c9SJuan Quintela}
1223249247c9SJuan Quintela
12247d13299dSbellardif test -z "$cross_prefix" ; then
12257d13299dSbellard
12267d13299dSbellard# ---
12277d13299dSbellard# big/little endian test
12287d13299dSbellardcat > $TMPC << EOF
12297d13299dSbellard#include <inttypes.h>
12307d13299dSbellardint main(int argc, char ** argv){
12317d13299dSbellard        volatile uint32_t i=0x01234567;
12327d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
12337d13299dSbellard}
12347d13299dSbellardEOF
12357d13299dSbellard
123652166aa0SJuan Quintelaif compile_prog "" "" ; then
12377d13299dSbellard$TMPE && bigendian="yes"
12387d13299dSbellardelse
12397d13299dSbellardecho big/little test failed
12407d13299dSbellardfi
12417d13299dSbellard
12427d13299dSbellardelse
12437d13299dSbellard
12447d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1245ea8f20f8SJuan Quintelacase "$cpu" in
124624e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1247ea8f20f8SJuan Quintela    bigendian=yes
1248ea8f20f8SJuan Quintela  ;;
1249ea8f20f8SJuan Quintelaesac
12507d13299dSbellard
12517d13299dSbellardfi
12527d13299dSbellard
125370be1a2eSPaolo Bonzini# host long bits test, actually a pointer size test
125470be1a2eSPaolo Bonzinicat > $TMPC << EOF
125570be1a2eSPaolo Bonziniint sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
125670be1a2eSPaolo BonziniEOF
125770be1a2eSPaolo Bonziniif compile_object; then
1258ea8f20f8SJuan Quintelahostlongbits=64
125970be1a2eSPaolo Bonzinielse
126070be1a2eSPaolo Bonzinihostlongbits=32
126170be1a2eSPaolo Bonzinifi
1262b6853697Sbellard
1263b0a47e79SJuan Quintela
1264b0a47e79SJuan Quintela##########################################
1265b0a47e79SJuan Quintela# NPTL probe
1266b0a47e79SJuan Quintela
1267b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1268bd0c5661Spbrook  cat > $TMPC <<EOF
1269bd0c5661Spbrook#include <sched.h>
127030813ceaSpbrook#include <linux/futex.h>
1271bd0c5661Spbrookvoid foo()
1272bd0c5661Spbrook{
1273bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1274bd0c5661Spbrook#error bork
1275bd0c5661Spbrook#endif
1276bd0c5661Spbrook}
1277bd0c5661SpbrookEOF
1278bd0c5661Spbrook
127952166aa0SJuan Quintela  if compile_object ; then
1280b0a47e79SJuan Quintela    nptl=yes
1281bd0c5661Spbrook  else
1282b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1283b0a47e79SJuan Quintela      feature_not_found "nptl"
1284b0a47e79SJuan Quintela    fi
1285b0a47e79SJuan Quintela    nptl=no
1286b0a47e79SJuan Quintela  fi
1287bd0c5661Spbrookfi
1288bd0c5661Spbrook
128911d9f695Sbellard##########################################
1290ac62922eSbalrog# zlib check
1291ac62922eSbalrog
12921ece9905SAlon Levyif test "$zlib" != "no" ; then
1293ac62922eSbalrog    cat > $TMPC << EOF
1294ac62922eSbalrog#include <zlib.h>
1295ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1296ac62922eSbalrogEOF
129752166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1298ac62922eSbalrog        :
1299ac62922eSbalrog    else
1300ac62922eSbalrog        echo
1301ac62922eSbalrog        echo "Error: zlib check failed"
1302ac62922eSbalrog        echo "Make sure to have the zlib libs and headers installed."
1303ac62922eSbalrog        echo
1304ac62922eSbalrog        exit 1
1305ac62922eSbalrog    fi
13061ece9905SAlon Levyfi
1307ac62922eSbalrog
1308ac62922eSbalrog##########################################
1309e37630caSaliguori# xen probe
1310e37630caSaliguori
1311fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1312b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1313d5b93ddfSAnthony PERARD
1314d5b93ddfSAnthony PERARD  # Xen unstable
1315e37630caSaliguori  cat > $TMPC <<EOF
1316e37630caSaliguori#include <xenctrl.h>
1317e37630caSaliguori#include <xs.h>
1318d5b93ddfSAnthony PERARD#include <stdint.h>
1319d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1320d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1321d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1322d5b93ddfSAnthony PERARD#endif
1323d5b93ddfSAnthony PERARDint main(void) {
1324d5b93ddfSAnthony PERARD  xc_interface *xc;
1325d5b93ddfSAnthony PERARD  xs_daemon_open();
1326d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1327d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1328d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1329b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1330d5b93ddfSAnthony PERARD  return 0;
1331d5b93ddfSAnthony PERARD}
1332e37630caSaliguoriEOF
133352166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1334d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1335fc321b4bSJuan Quintela    xen=yes
1336d5b93ddfSAnthony PERARD
1337d5b93ddfSAnthony PERARD  # Xen 4.0.0
1338d5b93ddfSAnthony PERARD  elif (
1339d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1340d5b93ddfSAnthony PERARD#include <xenctrl.h>
1341d5b93ddfSAnthony PERARD#include <xs.h>
1342d5b93ddfSAnthony PERARD#include <stdint.h>
1343d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1344d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1345d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1346d5b93ddfSAnthony PERARD#endif
1347d5b93ddfSAnthony PERARDint main(void) {
1348b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1349b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1350b87de24eSAnthony PERARD  };
1351d5b93ddfSAnthony PERARD  xs_daemon_open();
1352d5b93ddfSAnthony PERARD  xc_interface_open();
1353d5b93ddfSAnthony PERARD  xc_gnttab_open();
1354d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1355b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1356d5b93ddfSAnthony PERARD  return 0;
1357d5b93ddfSAnthony PERARD}
1358d5b93ddfSAnthony PERARDEOF
1359d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1360d5b93ddfSAnthony PERARD    ) ; then
1361d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1362d5b93ddfSAnthony PERARD    xen=yes
1363d5b93ddfSAnthony PERARD
1364b87de24eSAnthony PERARD  # Xen 3.4.0
1365b87de24eSAnthony PERARD  elif (
1366b87de24eSAnthony PERARD      cat > $TMPC <<EOF
1367b87de24eSAnthony PERARD#include <xenctrl.h>
1368b87de24eSAnthony PERARD#include <xs.h>
1369b87de24eSAnthony PERARDint main(void) {
1370b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1371b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1372b87de24eSAnthony PERARD  };
1373b87de24eSAnthony PERARD  xs_daemon_open();
1374b87de24eSAnthony PERARD  xc_interface_open();
1375b87de24eSAnthony PERARD  xc_gnttab_open();
1376b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1377b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1378b87de24eSAnthony PERARD  return 0;
1379b87de24eSAnthony PERARD}
1380b87de24eSAnthony PERARDEOF
1381b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
1382b87de24eSAnthony PERARD    ) ; then
1383b87de24eSAnthony PERARD    xen_ctrl_version=340
1384b87de24eSAnthony PERARD    xen=yes
1385b87de24eSAnthony PERARD
1386b87de24eSAnthony PERARD  # Xen 3.3.0
1387d5b93ddfSAnthony PERARD  elif (
1388d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1389d5b93ddfSAnthony PERARD#include <xenctrl.h>
1390d5b93ddfSAnthony PERARD#include <xs.h>
1391d5b93ddfSAnthony PERARDint main(void) {
1392d5b93ddfSAnthony PERARD  xs_daemon_open();
1393d5b93ddfSAnthony PERARD  xc_interface_open();
1394d5b93ddfSAnthony PERARD  xc_gnttab_open();
1395d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1396d5b93ddfSAnthony PERARD  return 0;
1397d5b93ddfSAnthony PERARD}
1398d5b93ddfSAnthony PERARDEOF
1399d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1400d5b93ddfSAnthony PERARD    ) ; then
1401d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1402d5b93ddfSAnthony PERARD    xen=yes
1403d5b93ddfSAnthony PERARD
1404d5b93ddfSAnthony PERARD  # Xen not found or unsupported
1405e37630caSaliguori  else
1406fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1407fc321b4bSJuan Quintela      feature_not_found "xen"
1408fc321b4bSJuan Quintela    fi
1409fc321b4bSJuan Quintela    xen=no
1410e37630caSaliguori  fi
1411d5b93ddfSAnthony PERARD
1412d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1413d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1414d5b93ddfSAnthony PERARD  fi
1415e37630caSaliguorifi
1416e37630caSaliguori
1417e37630caSaliguori##########################################
1418a8bd70adSPaolo Bonzini# pkg-config probe
1419f91672e5SPaolo Bonzini
1420a8bd70adSPaolo Bonziniif ! has $pkg_config; then
1421a213fcb2SPeter Maydell  echo "Error: pkg-config binary '$pkg_config' not found"
1422a213fcb2SPeter Maydell  exit 1
1423f91672e5SPaolo Bonzinifi
1424f91672e5SPaolo Bonzini
1425f91672e5SPaolo Bonzini##########################################
142644dc0ca3SAlon Levy# libtool probe
142744dc0ca3SAlon Levy
14283f534581SBradif ! has $libtool; then
142944dc0ca3SAlon Levy    libtool=
143044dc0ca3SAlon Levyfi
143144dc0ca3SAlon Levy
143244dc0ca3SAlon Levy##########################################
1433dfffc653SJuan Quintela# Sparse probe
1434dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
14350dba6195SLoïc Minier  if has cgcc; then
1436dfffc653SJuan Quintela    sparse=yes
1437dfffc653SJuan Quintela  else
1438dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1439dfffc653SJuan Quintela      feature_not_found "sparse"
1440dfffc653SJuan Quintela    fi
1441dfffc653SJuan Quintela    sparse=no
1442dfffc653SJuan Quintela  fi
1443dfffc653SJuan Quintelafi
1444dfffc653SJuan Quintela
1445dfffc653SJuan Quintela##########################################
144611d9f695Sbellard# SDL probe
144711d9f695Sbellard
14483ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
14493ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
14503ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
14513ec87ffeSPaolo Bonzini  sdl_config=sdl-config
14523ec87ffeSPaolo Bonzinifi
14533ec87ffeSPaolo Bonzini
14543ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1455a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1456fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
14573ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
14583ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
14599316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1460a0dfd8a4SLoïc Minierelse
1461a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1462a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1463a0dfd8a4SLoïc Minier  fi
1464a0dfd8a4SLoïc Minier  sdl=no
14659316f803SPaolo Bonzinifi
146629e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
14673ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
14683ec87ffeSPaolo Bonzinifi
146911d9f695Sbellard
14709316f803SPaolo Bonzinisdl_too_old=no
1471c4198157SJuan Quintelaif test "$sdl" != "no" ; then
147211d9f695Sbellard  cat > $TMPC << EOF
147311d9f695Sbellard#include <SDL.h>
147411d9f695Sbellard#undef main /* We don't want SDL to override our main() */
147511d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
147611d9f695SbellardEOF
14779316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
147874f42e18STeLeMan  if test "$static" = "yes" ; then
147974f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
148074f42e18STeLeMan  else
14819316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
148274f42e18STeLeMan  fi
148352166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
148411d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
148511d9f695Sbellard      sdl_too_old=yes
148611d9f695Sbellard    else
1487fd677642Sths      if test "$cocoa" = "no" ; then
148811d9f695Sbellard        sdl=yes
148911d9f695Sbellard      fi
1490fd677642Sths    fi
14917c1f25b4Sbellard
149267c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
14931ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
149467c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1495f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1496f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
149711d9f695Sbellard      fi
149852166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
14991ac88f28SJuan Quintela	:
15001ac88f28SJuan Quintela      else
15011ac88f28SJuan Quintela        sdl=no
15027c1f25b4Sbellard      fi
15037c1f25b4Sbellard    fi # static link
1504c4198157SJuan Quintela  else # sdl not found
1505c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1506c4198157SJuan Quintela      feature_not_found "sdl"
1507c4198157SJuan Quintela    fi
1508c4198157SJuan Quintela    sdl=no
15097c1f25b4Sbellard  fi # sdl compile test
1510fd677642Sthsfi
151111d9f695Sbellard
15125368a422Saliguoriif test "$sdl" = "yes" ; then
15135368a422Saliguori  cat > $TMPC <<EOF
15145368a422Saliguori#include <SDL.h>
15155368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
15165368a422Saliguori#include <X11/XKBlib.h>
15175368a422Saliguori#else
15185368a422Saliguori#error No x11 support
15195368a422Saliguori#endif
15205368a422Saliguoriint main(void) { return 0; }
15215368a422SaliguoriEOF
152252166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1523681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
15245368a422Saliguori  fi
152507d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
152607d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
152707d9ac44SJuan Quintela  fi
15280705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
15295368a422Saliguorifi
15305368a422Saliguori
15318f28f3fbSths##########################################
15328d5d2d4cSths# VNC TLS detection
1533821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1534ae6b5e5aSaliguori  cat > $TMPC <<EOF
1535ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1536ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1537ae6b5e5aSaliguoriEOF
1538a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1539a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
154052166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
15411be10ad2SJuan Quintela    vnc_tls=yes
1542a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1543ae6b5e5aSaliguori  else
15441be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
15451be10ad2SJuan Quintela      feature_not_found "vnc-tls"
15461be10ad2SJuan Quintela    fi
15471be10ad2SJuan Quintela    vnc_tls=no
15488d5d2d4cSths  fi
15498d5d2d4cSthsfi
15508d5d2d4cSths
15518d5d2d4cSths##########################################
15522f9606b3Saliguori# VNC SASL detection
1553821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
15542f9606b3Saliguori  cat > $TMPC <<EOF
15552f9606b3Saliguori#include <sasl/sasl.h>
15562f9606b3Saliguori#include <stdio.h>
15572f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
15582f9606b3SaliguoriEOF
15592f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
15602f9606b3Saliguori  vnc_sasl_cflags=""
15612f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
156252166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1563ea784e3bSJuan Quintela    vnc_sasl=yes
1564fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
15652f9606b3Saliguori  else
1566ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1567ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1568ea784e3bSJuan Quintela    fi
1569ea784e3bSJuan Quintela    vnc_sasl=no
15702f9606b3Saliguori  fi
15712f9606b3Saliguorifi
15722f9606b3Saliguori
15732f9606b3Saliguori##########################################
15742f6f5c7aSCorentin Chary# VNC JPEG detection
1575821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
15762f6f5c7aSCorentin Charycat > $TMPC <<EOF
15772f6f5c7aSCorentin Chary#include <stdio.h>
15782f6f5c7aSCorentin Chary#include <jpeglib.h>
15792f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
15802f6f5c7aSCorentin CharyEOF
15812f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
15822f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
15832f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
15842f6f5c7aSCorentin Chary    vnc_jpeg=yes
15852f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
15862f6f5c7aSCorentin Chary  else
15872f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
15882f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
15892f6f5c7aSCorentin Chary    fi
15902f6f5c7aSCorentin Chary    vnc_jpeg=no
15912f6f5c7aSCorentin Chary  fi
15922f6f5c7aSCorentin Charyfi
15932f6f5c7aSCorentin Chary
15942f6f5c7aSCorentin Chary##########################################
1595efe556adSCorentin Chary# VNC PNG detection
1596821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1597efe556adSCorentin Charycat > $TMPC <<EOF
1598efe556adSCorentin Chary//#include <stdio.h>
1599efe556adSCorentin Chary#include <png.h>
1600832ce9c2SScott Wood#include <stddef.h>
1601efe556adSCorentin Charyint main(void) {
1602efe556adSCorentin Chary    png_structp png_ptr;
1603efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1604efe556adSCorentin Chary    return 0;
1605efe556adSCorentin Chary}
1606efe556adSCorentin CharyEOF
16079af8025eSBrad  if $pkg_config libpng --modversion >/dev/null 2>&1; then
16089af8025eSBrad    vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
16099af8025eSBrad    vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
16109af8025eSBrad  else
1611efe556adSCorentin Chary    vnc_png_cflags=""
1612efe556adSCorentin Chary    vnc_png_libs="-lpng"
16139af8025eSBrad  fi
1614efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1615efe556adSCorentin Chary    vnc_png=yes
1616efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
16179af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1618efe556adSCorentin Chary  else
1619efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1620efe556adSCorentin Chary      feature_not_found "vnc-png"
1621efe556adSCorentin Chary    fi
1622efe556adSCorentin Chary    vnc_png=no
1623efe556adSCorentin Chary  fi
1624efe556adSCorentin Charyfi
1625efe556adSCorentin Chary
1626efe556adSCorentin Chary##########################################
162776655d6dSaliguori# fnmatch() probe, used for ACL routines
162876655d6dSaliguorifnmatch="no"
162976655d6dSaliguoricat > $TMPC << EOF
163076655d6dSaliguori#include <fnmatch.h>
163176655d6dSaliguoriint main(void)
163276655d6dSaliguori{
163376655d6dSaliguori    fnmatch("foo", "foo", 0);
163476655d6dSaliguori    return 0;
163576655d6dSaliguori}
163676655d6dSaliguoriEOF
163752166aa0SJuan Quintelaif compile_prog "" "" ; then
163876655d6dSaliguori   fnmatch="yes"
163976655d6dSaliguorifi
164076655d6dSaliguori
164176655d6dSaliguori##########################################
1642ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1643ee682d27SStefan Weilif test "$uuid" != "no" ; then
1644ee682d27SStefan Weil  uuid_libs="-luuid"
1645ee682d27SStefan Weil  cat > $TMPC << EOF
1646ee682d27SStefan Weil#include <uuid/uuid.h>
1647ee682d27SStefan Weilint main(void)
1648ee682d27SStefan Weil{
1649ee682d27SStefan Weil    uuid_t my_uuid;
1650ee682d27SStefan Weil    uuid_generate(my_uuid);
1651ee682d27SStefan Weil    return 0;
1652ee682d27SStefan Weil}
1653ee682d27SStefan WeilEOF
1654ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1655ee682d27SStefan Weil    uuid="yes"
1656ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1657ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1658ee682d27SStefan Weil  else
1659ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1660ee682d27SStefan Weil      feature_not_found "uuid"
1661ee682d27SStefan Weil    fi
1662ee682d27SStefan Weil    uuid=no
1663ee682d27SStefan Weil  fi
1664ee682d27SStefan Weilfi
1665ee682d27SStefan Weil
1666ee682d27SStefan Weil##########################################
1667dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1668dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1669dce512deSChristoph Hellwig  cat > $TMPC << EOF
1670dce512deSChristoph Hellwig#include <xfs/xfs.h>
1671dce512deSChristoph Hellwigint main(void)
1672dce512deSChristoph Hellwig{
1673dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1674dce512deSChristoph Hellwig    return 0;
1675dce512deSChristoph Hellwig}
1676dce512deSChristoph HellwigEOF
1677dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1678dce512deSChristoph Hellwig    xfs="yes"
1679dce512deSChristoph Hellwig  else
1680dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1681dce512deSChristoph Hellwig      feature_not_found "xfs"
1682dce512deSChristoph Hellwig    fi
1683dce512deSChristoph Hellwig    xfs=no
1684dce512deSChristoph Hellwig  fi
1685dce512deSChristoph Hellwigfi
1686dce512deSChristoph Hellwig
1687dce512deSChristoph Hellwig##########################################
16888a16d273Sths# vde libraries probe
1689dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
16904baae0acSJuan Quintela  vde_libs="-lvdeplug"
16918a16d273Sths  cat > $TMPC << EOF
16928a16d273Sths#include <libvdeplug.h>
16934a7f0e06Spbrookint main(void)
16944a7f0e06Spbrook{
16954a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
16964a7f0e06Spbrook    vde_open("", "", &a);
16974a7f0e06Spbrook    return 0;
16984a7f0e06Spbrook}
16998a16d273SthsEOF
170052166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
17014baae0acSJuan Quintela    vde=yes
17028e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
17038e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1704dfb278bdSJuan Quintela  else
1705dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1706dfb278bdSJuan Quintela      feature_not_found "vde"
1707dfb278bdSJuan Quintela    fi
1708dfb278bdSJuan Quintela    vde=no
17098a16d273Sths  fi
17108a16d273Sthsfi
17118a16d273Sths
17128a16d273Sths##########################################
1713c2de5c91Smalc# Sound support libraries probe
17148f28f3fbSths
1715c2de5c91Smalcaudio_drv_probe()
1716c2de5c91Smalc{
1717c2de5c91Smalc    drv=$1
1718c2de5c91Smalc    hdr=$2
1719c2de5c91Smalc    lib=$3
1720c2de5c91Smalc    exp=$4
1721c2de5c91Smalc    cfl=$5
17228f28f3fbSths        cat > $TMPC << EOF
1723c2de5c91Smalc#include <$hdr>
1724c2de5c91Smalcint main(void) { $exp }
17258f28f3fbSthsEOF
172652166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
17278f28f3fbSths        :
17288f28f3fbSths    else
17298f28f3fbSths        echo
1730c2de5c91Smalc        echo "Error: $drv check failed"
1731c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
17328f28f3fbSths        echo
17338f28f3fbSths        exit 1
17348f28f3fbSths    fi
1735c2de5c91Smalc}
1736c2de5c91Smalc
17372fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1738c2de5c91Smalcfor drv in $audio_drv_list; do
1739c2de5c91Smalc    case $drv in
1740c2de5c91Smalc    alsa)
1741c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1742c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1743a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1744c2de5c91Smalc    ;;
1745c2de5c91Smalc
1746c2de5c91Smalc    fmod)
1747c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1748c2de5c91Smalc        echo
1749c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1750c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1751c2de5c91Smalc        echo
1752c2de5c91Smalc        exit 1
17538f28f3fbSths    fi
1754c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1755a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1756c2de5c91Smalc    ;;
1757c2de5c91Smalc
1758c2de5c91Smalc    esd)
1759c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1760a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
176167f86e8eSJuan Quintela    audio_pt_int="yes"
1762c2de5c91Smalc    ;;
1763b8e59f18Smalc
1764b8e59f18Smalc    pa)
1765493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
176620fa53ecSMarc-Antoine Perennou        "pa_simple *s = 0; pa_simple_free(s); return 0;"
1767493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
176867f86e8eSJuan Quintela    audio_pt_int="yes"
1769b8e59f18Smalc    ;;
1770b8e59f18Smalc
1771997e690aSJuan Quintela    coreaudio)
1772997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1773997e690aSJuan Quintela    ;;
1774997e690aSJuan Quintela
1775a4bf6780SJuan Quintela    dsound)
1776a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1777d5631638Smalc      audio_win_int="yes"
1778a4bf6780SJuan Quintela    ;;
1779a4bf6780SJuan Quintela
1780a4bf6780SJuan Quintela    oss)
1781a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1782a4bf6780SJuan Quintela    ;;
1783a4bf6780SJuan Quintela
1784a4bf6780SJuan Quintela    sdl|wav)
17852f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
17862f6a1ab0Sblueswir1    ;;
17872f6a1ab0Sblueswir1
1788d5631638Smalc    winwave)
1789d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1790d5631638Smalc      audio_win_int="yes"
1791d5631638Smalc    ;;
1792d5631638Smalc
1793e4c63a6aSmalc    *)
17941c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1795e4c63a6aSmalc        echo
1796e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1797e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1798e4c63a6aSmalc        echo
1799e4c63a6aSmalc        exit 1
1800e4c63a6aSmalc    }
1801e4c63a6aSmalc    ;;
1802c2de5c91Smalc    esac
1803c2de5c91Smalcdone
18048f28f3fbSths
18054d3b6f6eSbalrog##########################################
18062e4d9fb1Saurel32# BrlAPI probe
18072e4d9fb1Saurel32
18084ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1809eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
18102e4d9fb1Saurel32  cat > $TMPC << EOF
18112e4d9fb1Saurel32#include <brlapi.h>
1812832ce9c2SScott Wood#include <stddef.h>
18132e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
18142e4d9fb1Saurel32EOF
181552166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
18162e4d9fb1Saurel32    brlapi=yes
1817264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
18184ffcedb6SJuan Quintela  else
18194ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
18204ffcedb6SJuan Quintela      feature_not_found "brlapi"
18214ffcedb6SJuan Quintela    fi
18224ffcedb6SJuan Quintela    brlapi=no
1823eb82284fSJuan Quintela  fi
1824eb82284fSJuan Quintelafi
18252e4d9fb1Saurel32
18262e4d9fb1Saurel32##########################################
18274d3b6f6eSbalrog# curses probe
1828e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
1829e095e2f3SStefan Weil    curses_list="-lpdcurses"
1830e095e2f3SStefan Weilelse
18314f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
1832e095e2f3SStefan Weilfi
18334d3b6f6eSbalrog
1834c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1835c584a6d0SJuan Quintela  curses_found=no
18364d3b6f6eSbalrog  cat > $TMPC << EOF
18374d3b6f6eSbalrog#include <curses.h>
18385a8ff3aaSblueswir1#ifdef __OpenBSD__
18395a8ff3aaSblueswir1#define resize_term resizeterm
18405a8ff3aaSblueswir1#endif
18415a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
18424d3b6f6eSbalrogEOF
18434f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
18444f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1845c584a6d0SJuan Quintela      curses_found=yes
18464f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
18474f78ef9aSJuan Quintela      break
18484d3b6f6eSbalrog    fi
18494f78ef9aSJuan Quintela  done
1850c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1851c584a6d0SJuan Quintela    curses=yes
1852c584a6d0SJuan Quintela  else
1853c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1854c584a6d0SJuan Quintela      feature_not_found "curses"
1855c584a6d0SJuan Quintela    fi
1856c584a6d0SJuan Quintela    curses=no
1857c584a6d0SJuan Quintela  fi
18584f78ef9aSJuan Quintelafi
18594d3b6f6eSbalrog
1860414f0dabSblueswir1##########################################
1861769ce76dSAlexander Graf# curl probe
1862769ce76dSAlexander Graf
1863a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
1864a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
18654e2b0658SPaolo Bonzinielse
18664e2b0658SPaolo Bonzini  curlconfig=curl-config
18674e2b0658SPaolo Bonzinifi
18684e2b0658SPaolo Bonzini
1869788c8196SJuan Quintelaif test "$curl" != "no" ; then
1870769ce76dSAlexander Graf  cat > $TMPC << EOF
1871769ce76dSAlexander Graf#include <curl/curl.h>
18720b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
1873769ce76dSAlexander GrafEOF
18744e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
18754e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1876b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1877769ce76dSAlexander Graf    curl=yes
1878f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1879f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1880788c8196SJuan Quintela  else
1881788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1882788c8196SJuan Quintela      feature_not_found "curl"
1883788c8196SJuan Quintela    fi
1884788c8196SJuan Quintela    curl=no
1885769ce76dSAlexander Graf  fi
1886769ce76dSAlexander Graffi # test "$curl"
1887769ce76dSAlexander Graf
1888769ce76dSAlexander Graf##########################################
18895495ed11SLuiz Capitulino# check framework probe
18905495ed11SLuiz Capitulino
18915495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
18925495ed11SLuiz Capitulino  cat > $TMPC << EOF
18935495ed11SLuiz Capitulino#include <check.h>
18945495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
18955495ed11SLuiz CapitulinoEOF
1896f809c0d6SPeter Maydell  check_libs=`$pkg_config --libs check 2>/dev/null`
18975495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
18985495ed11SLuiz Capitulino    check_utests=yes
18995495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
19005495ed11SLuiz Capitulino  else
19015495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
19025495ed11SLuiz Capitulino      feature_not_found "check"
19035495ed11SLuiz Capitulino    fi
19045495ed11SLuiz Capitulino    check_utests=no
19055495ed11SLuiz Capitulino  fi
19065495ed11SLuiz Capitulinofi # test "$check_utests"
19075495ed11SLuiz Capitulino
19085495ed11SLuiz Capitulino##########################################
1909fb599c9aSbalrog# bluez support probe
1910a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1911e820e3f4Sbalrog  cat > $TMPC << EOF
1912e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1913e820e3f4Sbalrogint main(void) { return bt_error(0); }
1914e820e3f4SbalrogEOF
1915a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1916a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
191752166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1918a20a6f46SJuan Quintela    bluez=yes
1919e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1920e820e3f4Sbalrog  else
1921a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1922a20a6f46SJuan Quintela      feature_not_found "bluez"
1923a20a6f46SJuan Quintela    fi
1924e820e3f4Sbalrog    bluez="no"
1925e820e3f4Sbalrog  fi
1926fb599c9aSbalrogfi
1927fb599c9aSbalrog
1928fb599c9aSbalrog##########################################
1929e18df141SAnthony Liguori# glib support probe
19304b76a481SStefan Hajnocziif $pkg_config --modversion gthread-2.0 > /dev/null 2>&1 ; then
19314b76a481SStefan Hajnoczi    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
19324b76a481SStefan Hajnoczi    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
193314015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
1934957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
1935e18df141SAnthony Liguorielse
1936e18df141SAnthony Liguori    echo "glib-2.0 required to compile QEMU"
1937e18df141SAnthony Liguori    exit 1
1938e18df141SAnthony Liguorifi
1939e18df141SAnthony Liguori
1940e18df141SAnthony Liguori##########################################
1941e5d355d1Saliguori# pthread probe
19424b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
19433c529d93Saliguori
1944e5d355d1Saliguoripthread=no
1945414f0dabSblueswir1cat > $TMPC << EOF
19463c529d93Saliguori#include <pthread.h>
1947de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1948414f0dabSblueswir1EOF
1949bd00d539SAndreas Färberif compile_prog "" "" ; then
1950bd00d539SAndreas Färber  pthread=yes
1951bd00d539SAndreas Färberelse
1952de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
195352166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
1954e5d355d1Saliguori      pthread=yes
19555572b539SJuan Quintela      LIBS="$pthread_lib $LIBS"
1956de65fe0fSSebastian Herbszt      break
1957414f0dabSblueswir1    fi
1958de65fe0fSSebastian Herbszt  done
1959bd00d539SAndreas Färberfi
1960414f0dabSblueswir1
19614617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
19624dd75c70SChristoph Hellwig  echo
19634dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
19644dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
19654dd75c70SChristoph Hellwig  echo
19664dd75c70SChristoph Hellwig  exit 1
1967e5d355d1Saliguorifi
1968e5d355d1Saliguori
1969bf9298b9Saliguori##########################################
1970f27aaf4bSChristian Brunner# rbd probe
1971f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
1972f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
1973f27aaf4bSChristian Brunner#include <stdio.h>
1974ad32e9c0SJosh Durgin#include <rbd/librbd.h>
1975f27aaf4bSChristian Brunnerint main(void) {
1976ad32e9c0SJosh Durgin    rados_t cluster;
1977ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
1978f27aaf4bSChristian Brunner    return 0;
1979f27aaf4bSChristian Brunner}
1980f27aaf4bSChristian BrunnerEOF
1981ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
1982f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
1983f27aaf4bSChristian Brunner    rbd=yes
1984f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
1985f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
1986f27aaf4bSChristian Brunner  else
1987f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
1988f27aaf4bSChristian Brunner      feature_not_found "rados block device"
1989f27aaf4bSChristian Brunner    fi
1990f27aaf4bSChristian Brunner    rbd=no
1991f27aaf4bSChristian Brunner  fi
1992f27aaf4bSChristian Brunnerfi
1993f27aaf4bSChristian Brunner
1994f27aaf4bSChristian Brunner##########################################
19955c6c3a6cSChristoph Hellwig# linux-aio probe
19965c6c3a6cSChristoph Hellwig
19975c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
19985c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
19995c6c3a6cSChristoph Hellwig#include <libaio.h>
20005c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
2001832ce9c2SScott Wood#include <stddef.h>
20025c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
20035c6c3a6cSChristoph HellwigEOF
20045c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
20055c6c3a6cSChristoph Hellwig    linux_aio=yes
2006048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
2007048d179fSPaul Brook    libs_tools="$libs_tools -laio"
20085c6c3a6cSChristoph Hellwig  else
20095c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
20105c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
20115c6c3a6cSChristoph Hellwig    fi
20123cfcae3cSLuiz Capitulino    linux_aio=no
20135c6c3a6cSChristoph Hellwig  fi
20145c6c3a6cSChristoph Hellwigfi
20155c6c3a6cSChristoph Hellwig
20165c6c3a6cSChristoph Hellwig##########################################
2017758e8e38SVenkateswararao Jujjuri (JV)# attr probe
2018758e8e38SVenkateswararao Jujjuri (JV)
2019758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
2020758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
2021758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
2022758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
2023f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
2024f2338fb4SPavel Borzenkov#include <attr/xattr.h>
2025f2338fb4SPavel Borzenkov#else
20264f26f2b6SAvi Kivity#include <sys/xattr.h>
2027f2338fb4SPavel Borzenkov#endif
2028758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2029758e8e38SVenkateswararao Jujjuri (JV)EOF
20304f26f2b6SAvi Kivity  if compile_prog "" "" ; then
20314f26f2b6SAvi Kivity    attr=yes
20324f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
2033f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2034758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
2035758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
20364f26f2b6SAvi Kivity    libattr=yes
2037758e8e38SVenkateswararao Jujjuri (JV)  else
2038758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
2039758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
2040758e8e38SVenkateswararao Jujjuri (JV)    fi
2041758e8e38SVenkateswararao Jujjuri (JV)    attr=no
2042758e8e38SVenkateswararao Jujjuri (JV)  fi
2043758e8e38SVenkateswararao Jujjuri (JV)fi
2044758e8e38SVenkateswararao Jujjuri (JV)
2045758e8e38SVenkateswararao Jujjuri (JV)##########################################
2046bf9298b9Saliguori# iovec probe
2047bf9298b9Saliguoricat > $TMPC <<EOF
2048db34f0b3Sblueswir1#include <sys/types.h>
2049bf9298b9Saliguori#include <sys/uio.h>
2050db34f0b3Sblueswir1#include <unistd.h>
2051bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
2052bf9298b9SaliguoriEOF
2053bf9298b9Saliguoriiovec=no
205452166aa0SJuan Quintelaif compile_prog "" "" ; then
2055bf9298b9Saliguori  iovec=yes
2056bf9298b9Saliguorifi
2057bf9298b9Saliguori
2058f652e6afSaurel32##########################################
2059ceb42de8Saliguori# preadv probe
2060ceb42de8Saliguoricat > $TMPC <<EOF
2061ceb42de8Saliguori#include <sys/types.h>
2062ceb42de8Saliguori#include <sys/uio.h>
2063ceb42de8Saliguori#include <unistd.h>
2064ceb42de8Saliguoriint main(void) { preadv; }
2065ceb42de8SaliguoriEOF
2066ceb42de8Saliguoripreadv=no
206752166aa0SJuan Quintelaif compile_prog "" "" ; then
2068ceb42de8Saliguori  preadv=yes
2069ceb42de8Saliguorifi
2070ceb42de8Saliguori
2071ceb42de8Saliguori##########################################
2072f652e6afSaurel32# fdt probe
20732df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2074b41af4baSJuan Quintela  fdt_libs="-lfdt"
2075f652e6afSaurel32  cat > $TMPC << EOF
2076f652e6afSaurel32int main(void) { return 0; }
2077f652e6afSaurel32EOF
207852166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2079f652e6afSaurel32    fdt=yes
20802df87df7SJuan Quintela  else
20812df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
20822df87df7SJuan Quintela      feature_not_found "fdt"
20832df87df7SJuan Quintela    fi
2084de3a354aSMichael Walle    fdt_libs=
20852df87df7SJuan Quintela    fdt=no
2086f652e6afSaurel32  fi
2087f652e6afSaurel32fi
2088f652e6afSaurel32
208920ff075bSMichael Walle##########################################
209020ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
209120ff075bSMichael Walleif test "$opengl" != "no" ; then
209220ff075bSMichael Walle  opengl_libs="-lGL"
209320ff075bSMichael Walle  cat > $TMPC << EOF
209420ff075bSMichael Walle#include <X11/Xlib.h>
209520ff075bSMichael Walle#include <GL/gl.h>
209620ff075bSMichael Walle#include <GL/glx.h>
209720ff075bSMichael Walleint main(void) { GL_VERSION; return 0; }
209820ff075bSMichael WalleEOF
209920ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
210020ff075bSMichael Walle    opengl=yes
210120ff075bSMichael Walle  else
210220ff075bSMichael Walle    if test "$opengl" = "yes" ; then
210320ff075bSMichael Walle      feature_not_found "opengl"
210420ff075bSMichael Walle    fi
2105de3a354aSMichael Walle    opengl_libs=
210620ff075bSMichael Walle    opengl=no
210720ff075bSMichael Walle  fi
210820ff075bSMichael Wallefi
210920ff075bSMichael Walle
21103b3f24adSaurel32#
21113b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
21123b3f24adSaurel32# emulator.  This is done because older glibc versions don't
21133b3f24adSaurel32# have syscall stubs for these implemented.
21143b3f24adSaurel32#
21153b3f24adSaurel32atfile=no
21163b3f24adSaurel32cat > $TMPC << EOF
21173b3f24adSaurel32#define _ATFILE_SOURCE
21183b3f24adSaurel32#include <sys/types.h>
21193b3f24adSaurel32#include <fcntl.h>
21203b3f24adSaurel32#include <unistd.h>
21213b3f24adSaurel32
21223b3f24adSaurel32int
21233b3f24adSaurel32main(void)
21243b3f24adSaurel32{
21253b3f24adSaurel32	/* try to unlink nonexisting file */
21263b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
21273b3f24adSaurel32}
21283b3f24adSaurel32EOF
212952166aa0SJuan Quintelaif compile_prog "" "" ; then
21303b3f24adSaurel32  atfile=yes
21313b3f24adSaurel32fi
21323b3f24adSaurel32
213339386ac7Saurel32# Check for inotify functions when we are building linux-user
21343b3f24adSaurel32# emulator.  This is done because older glibc versions don't
21353b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
21363b3f24adSaurel32# don't provide them even if kernel supports them.
21373b3f24adSaurel32#
21383b3f24adSaurel32inotify=no
21393b3f24adSaurel32cat > $TMPC << EOF
21403b3f24adSaurel32#include <sys/inotify.h>
21413b3f24adSaurel32
21423b3f24adSaurel32int
21433b3f24adSaurel32main(void)
21443b3f24adSaurel32{
21453b3f24adSaurel32	/* try to start inotify */
21468690e420Saurel32	return inotify_init();
21473b3f24adSaurel32}
21483b3f24adSaurel32EOF
214952166aa0SJuan Quintelaif compile_prog "" "" ; then
21503b3f24adSaurel32  inotify=yes
21513b3f24adSaurel32fi
21523b3f24adSaurel32
2153c05c7a73SRiku Voipioinotify1=no
2154c05c7a73SRiku Voipiocat > $TMPC << EOF
2155c05c7a73SRiku Voipio#include <sys/inotify.h>
2156c05c7a73SRiku Voipio
2157c05c7a73SRiku Voipioint
2158c05c7a73SRiku Voipiomain(void)
2159c05c7a73SRiku Voipio{
2160c05c7a73SRiku Voipio    /* try to start inotify */
2161c05c7a73SRiku Voipio    return inotify_init1(0);
2162c05c7a73SRiku Voipio}
2163c05c7a73SRiku VoipioEOF
2164c05c7a73SRiku Voipioif compile_prog "" "" ; then
2165c05c7a73SRiku Voipio  inotify1=yes
2166c05c7a73SRiku Voipiofi
2167c05c7a73SRiku Voipio
2168ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2169ebc996f3SRiku Voipioutimens=no
2170ebc996f3SRiku Voipiocat > $TMPC << EOF
2171ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2172ebc996f3SRiku Voipio#include <stddef.h>
2173ebc996f3SRiku Voipio#include <fcntl.h>
2174ebc996f3SRiku Voipio
2175ebc996f3SRiku Voipioint main(void)
2176ebc996f3SRiku Voipio{
2177ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2178ebc996f3SRiku Voipio    futimens(0, NULL);
2179ebc996f3SRiku Voipio    return 0;
2180ebc996f3SRiku Voipio}
2181ebc996f3SRiku VoipioEOF
218252166aa0SJuan Quintelaif compile_prog "" "" ; then
2183ebc996f3SRiku Voipio  utimens=yes
2184ebc996f3SRiku Voipiofi
2185ebc996f3SRiku Voipio
2186099d6b0fSRiku Voipio# check if pipe2 is there
2187099d6b0fSRiku Voipiopipe2=no
2188099d6b0fSRiku Voipiocat > $TMPC << EOF
2189099d6b0fSRiku Voipio#include <unistd.h>
2190099d6b0fSRiku Voipio#include <fcntl.h>
2191099d6b0fSRiku Voipio
2192099d6b0fSRiku Voipioint main(void)
2193099d6b0fSRiku Voipio{
2194099d6b0fSRiku Voipio    int pipefd[2];
2195099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2196099d6b0fSRiku Voipio    return 0;
2197099d6b0fSRiku Voipio}
2198099d6b0fSRiku VoipioEOF
219952166aa0SJuan Quintelaif compile_prog "" "" ; then
2200099d6b0fSRiku Voipio  pipe2=yes
2201099d6b0fSRiku Voipiofi
2202099d6b0fSRiku Voipio
220340ff6d7eSKevin Wolf# check if accept4 is there
220440ff6d7eSKevin Wolfaccept4=no
220540ff6d7eSKevin Wolfcat > $TMPC << EOF
220640ff6d7eSKevin Wolf#include <sys/socket.h>
220740ff6d7eSKevin Wolf#include <stddef.h>
220840ff6d7eSKevin Wolf
220940ff6d7eSKevin Wolfint main(void)
221040ff6d7eSKevin Wolf{
221140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
221240ff6d7eSKevin Wolf    return 0;
221340ff6d7eSKevin Wolf}
221440ff6d7eSKevin WolfEOF
221540ff6d7eSKevin Wolfif compile_prog "" "" ; then
221640ff6d7eSKevin Wolf  accept4=yes
221740ff6d7eSKevin Wolffi
221840ff6d7eSKevin Wolf
22193ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
22203ce34dfbSvibisreenivasansplice=no
22213ce34dfbSvibisreenivasancat > $TMPC << EOF
22223ce34dfbSvibisreenivasan#include <unistd.h>
22233ce34dfbSvibisreenivasan#include <fcntl.h>
22243ce34dfbSvibisreenivasan#include <limits.h>
22253ce34dfbSvibisreenivasan
22263ce34dfbSvibisreenivasanint main(void)
22273ce34dfbSvibisreenivasan{
22283ce34dfbSvibisreenivasan    int len, fd;
22293ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
22303ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
22313ce34dfbSvibisreenivasan    return 0;
22323ce34dfbSvibisreenivasan}
22333ce34dfbSvibisreenivasanEOF
223452166aa0SJuan Quintelaif compile_prog "" "" ; then
22353ce34dfbSvibisreenivasan  splice=yes
22363ce34dfbSvibisreenivasanfi
22373ce34dfbSvibisreenivasan
2238dcc38d1cSMarcelo Tosatti##########################################
2239dcc38d1cSMarcelo Tosatti# signalfd probe
2240dcc38d1cSMarcelo Tosattisignalfd="no"
2241dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2242dcc38d1cSMarcelo Tosatti#define _GNU_SOURCE
2243dcc38d1cSMarcelo Tosatti#include <unistd.h>
2244dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2245dcc38d1cSMarcelo Tosatti#include <signal.h>
2246dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2247dcc38d1cSMarcelo TosattiEOF
2248dcc38d1cSMarcelo Tosatti
2249dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2250dcc38d1cSMarcelo Tosatti  signalfd=yes
2251dcc38d1cSMarcelo Tosattifi
2252dcc38d1cSMarcelo Tosatti
2253c2882b96SRiku Voipio# check if eventfd is supported
2254c2882b96SRiku Voipioeventfd=no
2255c2882b96SRiku Voipiocat > $TMPC << EOF
2256c2882b96SRiku Voipio#include <sys/eventfd.h>
2257c2882b96SRiku Voipio
2258c2882b96SRiku Voipioint main(void)
2259c2882b96SRiku Voipio{
22603439eec3SMax Filippov    int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2261c2882b96SRiku Voipio    return 0;
2262c2882b96SRiku Voipio}
2263c2882b96SRiku VoipioEOF
2264c2882b96SRiku Voipioif compile_prog "" "" ; then
2265c2882b96SRiku Voipio  eventfd=yes
2266c2882b96SRiku Voipiofi
2267c2882b96SRiku Voipio
2268d0927938SUlrich Hecht# check for fallocate
2269d0927938SUlrich Hechtfallocate=no
2270d0927938SUlrich Hechtcat > $TMPC << EOF
2271d0927938SUlrich Hecht#include <fcntl.h>
2272d0927938SUlrich Hecht
2273d0927938SUlrich Hechtint main(void)
2274d0927938SUlrich Hecht{
2275d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2276d0927938SUlrich Hecht    return 0;
2277d0927938SUlrich Hecht}
2278d0927938SUlrich HechtEOF
2279be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
2280d0927938SUlrich Hecht  fallocate=yes
2281d0927938SUlrich Hechtfi
2282d0927938SUlrich Hecht
2283c727f47dSPeter Maydell# check for sync_file_range
2284c727f47dSPeter Maydellsync_file_range=no
2285c727f47dSPeter Maydellcat > $TMPC << EOF
2286c727f47dSPeter Maydell#include <fcntl.h>
2287c727f47dSPeter Maydell
2288c727f47dSPeter Maydellint main(void)
2289c727f47dSPeter Maydell{
2290c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2291c727f47dSPeter Maydell    return 0;
2292c727f47dSPeter Maydell}
2293c727f47dSPeter MaydellEOF
2294c727f47dSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2295c727f47dSPeter Maydell  sync_file_range=yes
2296c727f47dSPeter Maydellfi
2297c727f47dSPeter Maydell
2298dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2299dace20dcSPeter Maydellfiemap=no
2300dace20dcSPeter Maydellcat > $TMPC << EOF
2301dace20dcSPeter Maydell#include <sys/ioctl.h>
2302dace20dcSPeter Maydell#include <linux/fs.h>
2303dace20dcSPeter Maydell#include <linux/fiemap.h>
2304dace20dcSPeter Maydell
2305dace20dcSPeter Maydellint main(void)
2306dace20dcSPeter Maydell{
2307dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2308dace20dcSPeter Maydell    return 0;
2309dace20dcSPeter Maydell}
2310dace20dcSPeter MaydellEOF
2311dace20dcSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2312dace20dcSPeter Maydell  fiemap=yes
2313dace20dcSPeter Maydellfi
2314dace20dcSPeter Maydell
2315d0927938SUlrich Hecht# check for dup3
2316d0927938SUlrich Hechtdup3=no
2317d0927938SUlrich Hechtcat > $TMPC << EOF
2318d0927938SUlrich Hecht#include <unistd.h>
2319d0927938SUlrich Hecht
2320d0927938SUlrich Hechtint main(void)
2321d0927938SUlrich Hecht{
2322d0927938SUlrich Hecht    dup3(0, 0, 0);
2323d0927938SUlrich Hecht    return 0;
2324d0927938SUlrich Hecht}
2325d0927938SUlrich HechtEOF
232678f5d726SJan Kiszkaif compile_prog "" "" ; then
2327d0927938SUlrich Hecht  dup3=yes
2328d0927938SUlrich Hechtfi
2329d0927938SUlrich Hecht
23303b6edd16SPeter Maydell# check for epoll support
23313b6edd16SPeter Maydellepoll=no
23323b6edd16SPeter Maydellcat > $TMPC << EOF
23333b6edd16SPeter Maydell#include <sys/epoll.h>
23343b6edd16SPeter Maydell
23353b6edd16SPeter Maydellint main(void)
23363b6edd16SPeter Maydell{
23373b6edd16SPeter Maydell    epoll_create(0);
23383b6edd16SPeter Maydell    return 0;
23393b6edd16SPeter Maydell}
23403b6edd16SPeter MaydellEOF
23413b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23423b6edd16SPeter Maydell  epoll=yes
23433b6edd16SPeter Maydellfi
23443b6edd16SPeter Maydell
23453b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
23463b6edd16SPeter Maydell# so we must check separately for their presence
23473b6edd16SPeter Maydellepoll_create1=no
23483b6edd16SPeter Maydellcat > $TMPC << EOF
23493b6edd16SPeter Maydell#include <sys/epoll.h>
23503b6edd16SPeter Maydell
23513b6edd16SPeter Maydellint main(void)
23523b6edd16SPeter Maydell{
235319e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
235419e83f6bSPeter Maydell     * a function being called. This is necessary so that on
235519e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
235619e83f6bSPeter Maydell     * the library but not declared in the header file we will
235719e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
235819e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
235919e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
236019e83f6bSPeter Maydell     */
236119e83f6bSPeter Maydell    epoll_create1;
23623b6edd16SPeter Maydell    return 0;
23633b6edd16SPeter Maydell}
23643b6edd16SPeter MaydellEOF
23653b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23663b6edd16SPeter Maydell  epoll_create1=yes
23673b6edd16SPeter Maydellfi
23683b6edd16SPeter Maydell
23693b6edd16SPeter Maydellepoll_pwait=no
23703b6edd16SPeter Maydellcat > $TMPC << EOF
23713b6edd16SPeter Maydell#include <sys/epoll.h>
23723b6edd16SPeter Maydell
23733b6edd16SPeter Maydellint main(void)
23743b6edd16SPeter Maydell{
23753b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
23763b6edd16SPeter Maydell    return 0;
23773b6edd16SPeter Maydell}
23783b6edd16SPeter MaydellEOF
23793b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23803b6edd16SPeter Maydell  epoll_pwait=yes
23813b6edd16SPeter Maydellfi
23823b6edd16SPeter Maydell
2383cc8ae6deSpbrook# Check if tools are available to build documentation.
2384a25dba17SJuan Quintelaif test "$docs" != "no" ; then
238501668d98SStefan Weil  if has makeinfo && has pod2man; then
2386a25dba17SJuan Quintela    docs=yes
238783a3ab8bSJuan Quintela  else
2388a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2389a25dba17SJuan Quintela      feature_not_found "docs"
239083a3ab8bSJuan Quintela    fi
2391a25dba17SJuan Quintela    docs=no
239283a3ab8bSJuan Quintela  fi
2393cc8ae6deSpbrookfi
2394cc8ae6deSpbrook
2395f514f41cSStefan Weil# Search for bswap_32 function
23966ae9a1f4SJuan Quintelabyteswap_h=no
23976ae9a1f4SJuan Quintelacat > $TMPC << EOF
23986ae9a1f4SJuan Quintela#include <byteswap.h>
23996ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
24006ae9a1f4SJuan QuintelaEOF
240152166aa0SJuan Quintelaif compile_prog "" "" ; then
24026ae9a1f4SJuan Quintela  byteswap_h=yes
24036ae9a1f4SJuan Quintelafi
24046ae9a1f4SJuan Quintela
2405f514f41cSStefan Weil# Search for bswap_32 function
24066ae9a1f4SJuan Quintelabswap_h=no
24076ae9a1f4SJuan Quintelacat > $TMPC << EOF
24086ae9a1f4SJuan Quintela#include <sys/endian.h>
24096ae9a1f4SJuan Quintela#include <sys/types.h>
24106ae9a1f4SJuan Quintela#include <machine/bswap.h>
24116ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
24126ae9a1f4SJuan QuintelaEOF
241352166aa0SJuan Quintelaif compile_prog "" "" ; then
24146ae9a1f4SJuan Quintela  bswap_h=yes
24156ae9a1f4SJuan Quintelafi
24166ae9a1f4SJuan Quintela
2417da93a1fdSaliguori##########################################
2418c589b249SRonnie Sahlberg# Do we have libiscsi
2419c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2420c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2421c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2422c589b249SRonnie Sahlbergint main(void) { iscsi_create_context(""); return 0; }
2423c589b249SRonnie SahlbergEOF
2424c589b249SRonnie Sahlberg  if compile_prog "-Werror" "-liscsi" ; then
2425c589b249SRonnie Sahlberg    libiscsi="yes"
2426c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2427c589b249SRonnie Sahlberg  else
2428c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2429c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2430c589b249SRonnie Sahlberg    fi
2431c589b249SRonnie Sahlberg    libiscsi="no"
2432c589b249SRonnie Sahlberg  fi
2433c589b249SRonnie Sahlbergfi
2434c589b249SRonnie Sahlberg
2435c589b249SRonnie Sahlberg
2436c589b249SRonnie Sahlberg##########################################
2437da93a1fdSaliguori# Do we need librt
2438da93a1fdSaliguoricat > $TMPC <<EOF
2439da93a1fdSaliguori#include <signal.h>
2440da93a1fdSaliguori#include <time.h>
2441da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
2442da93a1fdSaliguoriEOF
2443da93a1fdSaliguori
244452166aa0SJuan Quintelaif compile_prog "" "" ; then
244507ffa4bdSJuan Quintela  :
244652166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
244707ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2448da93a1fdSaliguorifi
2449da93a1fdSaliguori
245031ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2451179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
24526362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
24536362a53fSJuan Quintelafi
24546362a53fSJuan Quintela
2455de5071c5SBlue Swirl##########################################
2456de5071c5SBlue Swirl# check if the compiler defines offsetof
2457de5071c5SBlue Swirl
2458de5071c5SBlue Swirlneed_offsetof=yes
2459de5071c5SBlue Swirlcat > $TMPC << EOF
2460de5071c5SBlue Swirl#include <stddef.h>
2461de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
2462de5071c5SBlue SwirlEOF
2463de5071c5SBlue Swirlif compile_prog "" "" ; then
2464de5071c5SBlue Swirl    need_offsetof=no
2465de5071c5SBlue Swirlfi
2466de5071c5SBlue Swirl
2467cd4ec0b4SGerd Hoffmann# spice probe
2468cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2469cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2470cd4ec0b4SGerd Hoffmann#include <spice.h>
2471cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2472cd4ec0b4SGerd HoffmannEOF
2473710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2474710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2475012b80d3SGerd Hoffmann  if $pkg_config --atleast-version=0.6.0 spice-server >/dev/null 2>&1 && \
2476cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2477cd4ec0b4SGerd Hoffmann    spice="yes"
2478cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2479cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2480cd4ec0b4SGerd Hoffmann  else
2481cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2482cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2483cd4ec0b4SGerd Hoffmann    fi
2484cd4ec0b4SGerd Hoffmann    spice="no"
2485cd4ec0b4SGerd Hoffmann  fi
2486cd4ec0b4SGerd Hoffmannfi
2487cd4ec0b4SGerd Hoffmann
2488111a38b0SRobert Relyea# check for libcacard for smartcard support
2489111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2490111a38b0SRobert Relyea    smartcard="yes"
2491111a38b0SRobert Relyea    smartcard_cflags=""
2492111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2493111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
2494111a38b0SRobert Relyea        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then
2495111a38b0SRobert Relyea            smartcard_nss="yes"
2496111a38b0SRobert Relyea            smartcard_cflags="-I\$(SRC_PATH)/libcacard"
2497111a38b0SRobert Relyea            libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
2498111a38b0SRobert Relyea            libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
2499111a38b0SRobert Relyea            QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
2500111a38b0SRobert Relyea            LIBS="$libcacard_libs $LIBS"
2501111a38b0SRobert Relyea        else
2502111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2503111a38b0SRobert Relyea                feature_not_found "nss"
2504111a38b0SRobert Relyea            fi
2505111a38b0SRobert Relyea            smartcard_nss="no"
2506111a38b0SRobert Relyea        fi
2507111a38b0SRobert Relyea    fi
2508111a38b0SRobert Relyeafi
2509111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2510111a38b0SRobert Relyea    smartcard_nss="no"
2511111a38b0SRobert Relyeafi
2512111a38b0SRobert Relyea
251369354a83SHans de Goede# check for usbredirparser for usb network redirection support
251469354a83SHans de Goedeif test "$usb_redir" != "no" ; then
251569354a83SHans de Goede    if $pkg_config libusbredirparser >/dev/null 2>&1 ; then
251669354a83SHans de Goede        usb_redir="yes"
251769354a83SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
251869354a83SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
251969354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
252069354a83SHans de Goede        LIBS="$LIBS $usb_redir_libs"
252169354a83SHans de Goede    else
252269354a83SHans de Goede        if test "$usb_redir" = "yes"; then
252369354a83SHans de Goede            feature_not_found "usb-redir"
252469354a83SHans de Goede        fi
252569354a83SHans de Goede        usb_redir="no"
252669354a83SHans de Goede    fi
252769354a83SHans de Goedefi
252869354a83SHans de Goede
2529cd4ec0b4SGerd Hoffmann##########################################
2530cd4ec0b4SGerd Hoffmann
2531747bbdf7SBlue Swirl##########################################
25325f6b9e8fSBlue Swirl# check if we have fdatasync
25335f6b9e8fSBlue Swirl
25345f6b9e8fSBlue Swirlfdatasync=no
25355f6b9e8fSBlue Swirlcat > $TMPC << EOF
25365f6b9e8fSBlue Swirl#include <unistd.h>
2537d1722a27SAlexandre Raymondint main(void) {
2538d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2539d1722a27SAlexandre Raymondreturn fdatasync(0);
2540d1722a27SAlexandre Raymond#else
2541d1722a27SAlexandre Raymond#abort Not supported
2542d1722a27SAlexandre Raymond#endif
2543d1722a27SAlexandre Raymond}
25445f6b9e8fSBlue SwirlEOF
25455f6b9e8fSBlue Swirlif compile_prog "" "" ; then
25465f6b9e8fSBlue Swirl    fdatasync=yes
25475f6b9e8fSBlue Swirlfi
25485f6b9e8fSBlue Swirl
254994a420b1SStefan Hajnoczi##########################################
2550e78815a5SAndreas Färber# check if we have madvise
2551e78815a5SAndreas Färber
2552e78815a5SAndreas Färbermadvise=no
2553e78815a5SAndreas Färbercat > $TMPC << EOF
2554e78815a5SAndreas Färber#include <sys/types.h>
2555e78815a5SAndreas Färber#include <sys/mman.h>
2556832ce9c2SScott Wood#include <stddef.h>
2557e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2558e78815a5SAndreas FärberEOF
2559e78815a5SAndreas Färberif compile_prog "" "" ; then
2560e78815a5SAndreas Färber    madvise=yes
2561e78815a5SAndreas Färberfi
2562e78815a5SAndreas Färber
2563e78815a5SAndreas Färber##########################################
2564e78815a5SAndreas Färber# check if we have posix_madvise
2565e78815a5SAndreas Färber
2566e78815a5SAndreas Färberposix_madvise=no
2567e78815a5SAndreas Färbercat > $TMPC << EOF
2568e78815a5SAndreas Färber#include <sys/mman.h>
2569832ce9c2SScott Wood#include <stddef.h>
2570e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2571e78815a5SAndreas FärberEOF
2572e78815a5SAndreas Färberif compile_prog "" "" ; then
2573e78815a5SAndreas Färber    posix_madvise=yes
2574e78815a5SAndreas Färberfi
2575e78815a5SAndreas Färber
2576e78815a5SAndreas Färber##########################################
257794a420b1SStefan Hajnoczi# check if trace backend exists
257894a420b1SStefan Hajnoczi
25794c3b5a48SBlue Swirlsh "$source_path/scripts/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
258094a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
258194a420b1SStefan Hajnoczi  echo
258294a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
258394a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
258494a420b1SStefan Hajnoczi  echo
258594a420b1SStefan Hajnoczi  exit 1
258694a420b1SStefan Hajnoczifi
258794a420b1SStefan Hajnoczi
25887e24e92aSStefan Hajnoczi##########################################
25897e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
25907e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
25917e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
25927e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
25937e24e92aSStefan Hajnoczi#include <ust/marker.h>
25947e24e92aSStefan Hajnocziint main(void) { return 0; }
25957e24e92aSStefan HajnocziEOF
25967e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
25977e24e92aSStefan Hajnoczi    LIBS="-lust $LIBS"
25987e24e92aSStefan Hajnoczi  else
25997e24e92aSStefan Hajnoczi    echo
26007e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
26017e24e92aSStefan Hajnoczi    echo
26027e24e92aSStefan Hajnoczi    exit 1
26037e24e92aSStefan Hajnoczi  fi
26047e24e92aSStefan Hajnoczifi
2605b3d08c02SDaniel P. Berrange
2606b3d08c02SDaniel P. Berrange##########################################
2607b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2608b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2609b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2610b3d08c02SDaniel P. Berrange    echo
2611b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2612b3d08c02SDaniel P. Berrange    echo
2613b3d08c02SDaniel P. Berrange    exit 1
2614b3d08c02SDaniel P. Berrange  fi
2615c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2616c276b17dSDaniel P. Berrange  if has 'stap' ; then
2617c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2618c276b17dSDaniel P. Berrange  fi
2619b3d08c02SDaniel P. Berrangefi
2620b3d08c02SDaniel P. Berrange
26217e24e92aSStefan Hajnoczi##########################################
2622023367e6SWolfgang Mauerer# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2623023367e6SWolfgang Mauerer# use i686 as default anyway, but for those that don't, an explicit
2624023367e6SWolfgang Mauerer# specification is necessary
26251ba16968SStefan Weilif test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
2626023367e6SWolfgang Mauerer  cat > $TMPC << EOF
2627023367e6SWolfgang Mauererint sfaa(unsigned *ptr)
2628023367e6SWolfgang Mauerer{
2629023367e6SWolfgang Mauerer  return __sync_fetch_and_and(ptr, 0);
2630023367e6SWolfgang Mauerer}
2631023367e6SWolfgang Mauerer
2632023367e6SWolfgang Mauererint main(int argc, char **argv)
2633023367e6SWolfgang Mauerer{
2634023367e6SWolfgang Mauerer  int val = 42;
2635023367e6SWolfgang Mauerer  sfaa(&val);
2636023367e6SWolfgang Mauerer  return val;
2637023367e6SWolfgang Mauerer}
2638023367e6SWolfgang MauererEOF
2639023367e6SWolfgang Mauerer  if ! compile_prog "" "" ; then
2640023367e6SWolfgang Mauerer    CFLAGS+="-march=i486"
2641023367e6SWolfgang Mauerer  fi
2642023367e6SWolfgang Mauererfi
2643023367e6SWolfgang Mauerer
2644023367e6SWolfgang Mauerer##########################################
2645d0e2fce5SAneesh Kumar K.V# check if we have makecontext
2646d0e2fce5SAneesh Kumar K.V
2647d0e2fce5SAneesh Kumar K.Vucontext_coroutine=no
2648d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
2649d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
2650d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
2651d0e2fce5SAneesh Kumar K.Vint main(void) { makecontext(0, 0, 0); }
2652d0e2fce5SAneesh Kumar K.VEOF
2653d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
2654d0e2fce5SAneesh Kumar K.V      ucontext_coroutine=yes
2655d0e2fce5SAneesh Kumar K.V  fi
2656d0e2fce5SAneesh Kumar K.Vfi
2657d0e2fce5SAneesh Kumar K.V
2658d0e2fce5SAneesh Kumar K.V##########################################
2659d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
2660d2042378SAneesh Kumar K.V
2661d2042378SAneesh Kumar K.Vopen_by_hande_at=no
2662d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
2663d2042378SAneesh Kumar K.V#include <fcntl.h>
266415329e83SAneesh Kumar K.Vint main(void) { struct file_handle fh; open_by_handle_at(0, &fh, 0); }
2665d2042378SAneesh Kumar K.VEOF
2666d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
2667d2042378SAneesh Kumar K.V    open_by_handle_at=yes
2668d2042378SAneesh Kumar K.Vfi
2669d2042378SAneesh Kumar K.V
2670e06a765eSHarsh Prateek Bora########################################
2671e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
2672e06a765eSHarsh Prateek Bora
2673e06a765eSHarsh Prateek Boralinux_magic_h=no
2674e06a765eSHarsh Prateek Boracat > $TMPC << EOF
2675e06a765eSHarsh Prateek Bora#include <linux/magic.h>
2676e06a765eSHarsh Prateek Boraint main(void) {
2677e06a765eSHarsh Prateek Bora}
2678e06a765eSHarsh Prateek BoraEOF
2679e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
2680e06a765eSHarsh Prateek Bora    linux_magic_h=yes
2681e06a765eSHarsh Prateek Borafi
2682e06a765eSHarsh Prateek Bora
2683d2042378SAneesh Kumar K.V##########################################
2684e86ecd4bSJuan Quintela# End of CC checks
2685e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2686e86ecd4bSJuan Quintela
2687e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
26881156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2689e86ecd4bSJuan Quintelafi
2690a316e378SJuan Quintela
2691e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2692e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2693e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
269420ff6c80SAnthony Liguori
269520ff6c80SAnthony Liguoriif test -z "$werror" ; then
2696e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2697e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2698e86ecd4bSJuan Quintela        werror="yes"
2699e86ecd4bSJuan Quintela    else
2700e86ecd4bSJuan Quintela        werror="no"
2701e86ecd4bSJuan Quintela    fi
2702e86ecd4bSJuan Quintelafi
2703e86ecd4bSJuan Quintela
270420ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
270520ff6c80SAnthony Liguori# enable/disable
270620ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
270720ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
270820ff6c80SAnthony Liguori	zero_malloc="no"
270920ff6c80SAnthony Liguori    else
271020ff6c80SAnthony Liguori	zero_malloc="yes"
271120ff6c80SAnthony Liguori    fi
271220ff6c80SAnthony Liguorifi
271320ff6c80SAnthony Liguori
2714e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2715a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2716e86ecd4bSJuan Quintelafi
2717e86ecd4bSJuan Quintela
2718e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2719e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
27201156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2721e86ecd4bSJuan Quintela    fi
2722e86ecd4bSJuan Quintelafi
2723e86ecd4bSJuan Quintela
2724952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
2725952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
2726952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
2727952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2728952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
2729952afb71SBlue Swirl        fi
2730952afb71SBlue Swirl    done
2731952afb71SBlue Swirlfi
2732952afb71SBlue Swirl
2733190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
27345a67135aSbellard
2735ca35f780SPaolo Bonzinitools=
2736ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2737ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2738ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2739ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2740d138cee9SMichael Roth    if [ "$guest_agent" = "yes" ]; then
274148ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
2742d138cee9SMichael Roth    fi
2743ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2744fffbeb75SGerd Hoffmann      checks="check-qint check-qstring check-qdict check-qlist"
2745695833bcSGerd Hoffmann      checks="check-qfloat check-qjson test-coroutine $checks"
2746ca35f780SPaolo Bonzini    fi
2747ca35f780SPaolo Bonzini  fi
2748ca35f780SPaolo Bonzinifi
2749ca35f780SPaolo Bonzini
2750ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2751ca35f780SPaolo Bonziniroms=
2752ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2753ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2754ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2755ca35f780SPaolo Bonzini  roms="optionrom"
2756ca35f780SPaolo Bonzinifi
2757d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
275839ac8455SDavid Gibson  roms="$roms spapr-rtas"
275939ac8455SDavid Gibsonfi
2760ca35f780SPaolo Bonzini
27617d13299dSbellardecho "Install prefix    $prefix"
2762f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2763f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
27643aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
27650f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
27661c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
276711d9f695Sbellardif test "$mingw32" = "no" ; then
2768f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
276943ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
277011d9f695Sbellardfi
27715a67135aSbellardecho "Source path       $source_path"
27727d13299dSbellardecho "C compiler        $cc"
277383469015Sbellardecho "Host C compiler   $host_cc"
27740c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2775a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
27760c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
27777d13299dSbellardecho "make              $make"
27786a882643Spbrookecho "install           $install"
2779c886edfbSBlue Swirlecho "python            $python"
2780e2d8830eSBradif test "$slirp" = "yes" ; then
2781e2d8830eSBrad    echo "smbd              $smbd"
2782e2d8830eSBradfi
2783a98fd896Sbellardecho "host CPU          $cpu"
2784de83cd02Sbellardecho "host big endian   $bigendian"
278597a847bcSbellardecho "target list       $target_list"
2786ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2787b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
27887d13299dSbellardecho "gprof enabled     $gprof"
278903b4fe7dSaliguoriecho "sparse enabled    $sparse"
27901625af87Saliguoriecho "strip binaries    $strip_opt"
279105c2a3e7Sbellardecho "profiler          $profiler"
279243ce4dfeSbellardecho "static build      $static"
279385aa5189Sbellardecho "-Werror enabled   $werror"
27945b0753e0Sbellardif test "$darwin" = "yes" ; then
27955b0753e0Sbellard    echo "Cocoa support     $cocoa"
27965b0753e0Sbellardfi
279797a847bcSbellardecho "SDL support       $sdl"
27984d3b6f6eSbalrogecho "curses support    $curses"
2799769ce76dSAlexander Grafecho "curl support      $curl"
28005495ed11SLuiz Capitulinoecho "check support     $check_utests"
280167b915a5Sbellardecho "mingw32 support   $mingw32"
28020c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
28030c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2804eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
28058ff9cbf7Smalcecho "Mixer emulation   $mixemu"
2806821601eaSJes Sorensenecho "VNC support       $vnc"
2807821601eaSJes Sorensenif test "$vnc" = "yes" ; then
28088d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
28092f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
28102f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
2811efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
2812bd023f95SCorentin Chary    echo "VNC thread        $vnc_thread"
2813821601eaSJes Sorensenfi
28143142255cSblueswir1if test -n "$sparc_cpu"; then
28153142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
28163142255cSblueswir1fi
2817e37630caSaliguoriecho "xen support       $xen"
28182e4d9fb1Saurel32echo "brlapi support    $brlapi"
2819a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2820a25dba17SJuan Quintelaecho "Documentation     $docs"
2821c5937220Spbrook[ ! -z "$uname_release" ] && \
2822c5937220Spbrookecho "uname -r          $uname_release"
2823bd0c5661Spbrookecho "NPTL support      $nptl"
2824379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
282540d6444eSAvi Kivityecho "PIE               $pie"
28268a16d273Sthsecho "vde support       $vde"
28275c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2828758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
282977755340Sthsecho "Install blobs     $blobs"
2830b31a0277SJuan Quintelaecho "KVM support       $kvm"
28319195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
2832f652e6afSaurel32echo "fdt support       $fdt"
2833ceb42de8Saliguoriecho "preadv support    $preadv"
28345f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2835e78815a5SAndreas Färberecho "madvise           $madvise"
2836e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
2837ee682d27SStefan Weilecho "uuid support      $uuid"
2838d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
283994a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
28409410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
2841cd4ec0b4SGerd Hoffmannecho "spice support     $spice"
2842f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
2843dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
2844111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
284569354a83SHans de Goedeecho "usb net redir     $usb_redir"
284620ff075bSMichael Walleecho "OpenGL support    $opengl"
2847c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
2848d138cee9SMichael Rothecho "build guest agent $guest_agent"
284967b915a5Sbellard
28501ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
285124b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2852e8cd23deSbellardfi
285397a847bcSbellard
285498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
28554bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
285697a847bcSbellard
285798ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
285898ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
285998ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
286098ec69acSJuan Quintelaecho >> $config_host_mak
286198ec69acSJuan Quintela
2862e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
286399d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
286499d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
28653aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
28660f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
286799d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
286899d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
286999d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
287099d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
28711dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2872804edf29SJuan Quintela
28732408a527Saurel32case "$cpu" in
2874d2fbca94SGuan Xuetao  i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64|unicore32)
2875e0da9dd3SJuan Quintela    ARCH=$cpu
28762408a527Saurel32  ;;
2877a302c32dSLaurent Desnogues  armv4b|armv4l)
287816dbd14fSJuan Quintela    ARCH=arm
28792408a527Saurel32  ;;
28809195b2c2SStefan Weil  *)
28819195b2c2SStefan Weil    if test "$tcg_interpreter" = "yes" ; then
28829195b2c2SStefan Weil        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
28839195b2c2SStefan Weil        ARCH=tci
28849195b2c2SStefan Weil    else
28859195b2c2SStefan Weil        echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
28869195b2c2SStefan Weil        exit 1
28879195b2c2SStefan Weil    fi
28889195b2c2SStefan Weil  ;;
28892408a527Saurel32esac
289098ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2891f8393946Saurel32if test "$debug_tcg" = "yes" ; then
28922358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2893f8393946Saurel32fi
2894b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2895b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2896b4475aa2SLuiz Capitulinofi
2897f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
28982358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2899f3d08ee6SPaul Brookfi
29001625af87Saliguoriif test "$strip_opt" = "yes" ; then
290152ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
29021625af87Saliguorifi
29037d13299dSbellardif test "$bigendian" = "yes" ; then
2904e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
290597a847bcSbellardfi
29062358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
290767b915a5Sbellardif test "$mingw32" = "yes" ; then
290898ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
29099fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
29109fe6de94SBlue Swirl  version_major=${rc_version%%.*}
29119fe6de94SBlue Swirl  rc_version=${rc_version#*.}
29129fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
29139fe6de94SBlue Swirl  rc_version=${rc_version#*.}
29149fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
29159fe6de94SBlue Swirl  version_micro=0
29169fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
29179fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2918210fa556Spbrookelse
291935f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2920210fa556Spbrookfi
2921128ab2ffSblueswir1
2922dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2923dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2924dffcb71cSMark McLoughlinfi
2925dffcb71cSMark McLoughlin
292683fb7adfSbellardif test "$darwin" = "yes" ; then
292798ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
292883fb7adfSbellardfi
2929b29fe3edSmalc
2930b29fe3edSmalcif test "$aix" = "yes" ; then
293198ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2932b29fe3edSmalcfi
2933b29fe3edSmalc
2934ec530c81Sbellardif test "$solaris" = "yes" ; then
293598ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
29362358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
29370475a5caSths  if test "$needs_libsunmath" = "yes" ; then
293875b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
29390475a5caSths  fi
2940ec530c81Sbellardfi
2941179cf400SAndreas Färberif test "$haiku" = "yes" ; then
2942179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
2943179cf400SAndreas Färberfi
294497a847bcSbellardif test "$static" = "yes" ; then
294598ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
294697a847bcSbellardfi
29471ba16968SStefan Weilif test "$profiler" = "yes" ; then
29482358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
294905c2a3e7Sbellardfi
2950c20709aaSbellardif test "$slirp" = "yes" ; then
295198ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2952e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
2953f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
2954c20709aaSbellardfi
29558a16d273Sthsif test "$vde" = "yes" ; then
295698ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
29578a16d273Sthsfi
29580c58ac1cSmalcfor card in $audio_card_list; do
2959f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
296098ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
29610c58ac1cSmalcdone
29622358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
29630c58ac1cSmalcfor drv in $audio_drv_list; do
2964f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
296598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2966923e4521Smalc    if test "$drv" = "fmod"; then
29677aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2968fb065187Sbellard    fi
29690c58ac1cSmalcdone
297067f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
297167f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
297267f86e8eSJuan Quintelafi
2973d5631638Smalcif test "$audio_win_int" = "yes" ; then
2974d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2975d5631638Smalcfi
2976eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
29778ff9cbf7Smalcif test "$mixemu" = "yes" ; then
297898ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
29798ff9cbf7Smalcfi
2980821601eaSJes Sorensenif test "$vnc" = "yes" ; then
2981821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
2982821601eaSJes Sorensenfi
29838d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
298498ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2985525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
29868d5d2d4cSthsfi
29872f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
298898ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
298960ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
29902f9606b3Saliguorifi
2991821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
29922f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
29932f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
29942f6f5c7aSCorentin Charyfi
2995821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
2996efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2997efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2998efe556adSCorentin Charyfi
2999821601eaSJes Sorensenif test "$vnc_thread" = "yes" ; then
3000bd023f95SCorentin Chary  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
3001bd023f95SCorentin Charyfi
300276655d6dSaliguoriif test "$fnmatch" = "yes" ; then
30032358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
300476655d6dSaliguorifi
3005ee682d27SStefan Weilif test "$uuid" = "yes" ; then
3006ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
3007ee682d27SStefan Weilfi
3008dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3009dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3010dce512deSChristoph Hellwigfi
3011b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
301298ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
30132358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
301498ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
301598ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
3016a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
301798ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
3018cc8ae6deSpbrookfi
30191ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
302098ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
30218ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
302249ecc3faSbellardfi
302349ecc3faSbellardif test "$cocoa" = "yes" ; then
302498ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
302549ecc3faSbellardfi
30264d3b6f6eSbalrogif test "$curses" = "yes" ; then
302798ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
3028ab4e5602SJan Kiszkafi
30293b3f24adSaurel32if test "$atfile" = "yes" ; then
30302358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
30313b3f24adSaurel32fi
3032ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
30332358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3034ebc996f3SRiku Voipiofi
3035099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
30362358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
3037099d6b0fSRiku Voipiofi
303840ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
303940ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
304040ff6d7eSKevin Wolffi
30413ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
30422358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
30433ce34dfbSvibisreenivasanfi
3044c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
3045c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
3046c2882b96SRiku Voipiofi
3047d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
3048d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3049d0927938SUlrich Hechtfi
3050c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
3051c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3052c727f47dSPeter Maydellfi
3053dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
3054dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
3055dace20dcSPeter Maydellfi
3056d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
3057d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
3058d0927938SUlrich Hechtfi
30593b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
30603b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
30613b6edd16SPeter Maydellfi
30623b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
30633b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
30643b6edd16SPeter Maydellfi
30653b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
30663b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
30673b6edd16SPeter Maydellfi
30683b3f24adSaurel32if test "$inotify" = "yes" ; then
30692358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
30703b3f24adSaurel32fi
3071c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3072c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3073c05c7a73SRiku Voipiofi
30746ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
30756ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
30766ae9a1f4SJuan Quintelafi
30776ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
30786ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
30796ae9a1f4SJuan Quintelafi
3080769ce76dSAlexander Grafif test "$curl" = "yes" ; then
308198ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3082b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3083769ce76dSAlexander Graffi
30842e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
308598ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
30862e4d9fb1Saurel32fi
3087fb599c9aSbalrogif test "$bluez" = "yes" ; then
308898ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3089ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3090fb599c9aSbalrogfi
3091e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3092e37630caSaliguoriif test "$xen" = "yes" ; then
30936dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3094d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3095e37630caSaliguorifi
30965c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
30975c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
30985c6c3a6cSChristoph Hellwigfi
3099758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3100758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3101758e8e38SVenkateswararao Jujjuri (JV)fi
31024f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
31034f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
31044f26f2b6SAvi Kivityfi
3105758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
3106758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
3107758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
3108758e8e38SVenkateswararao Jujjuri (JV)  fi
3109758e8e38SVenkateswararao Jujjuri (JV)fi
311077755340Sthsif test "$blobs" = "yes" ; then
311198ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
311277755340Sthsfi
3113bf9298b9Saliguoriif test "$iovec" = "yes" ; then
31142358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3115bf9298b9Saliguorifi
3116ceb42de8Saliguoriif test "$preadv" = "yes" ; then
31172358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3118ceb42de8Saliguorifi
3119f652e6afSaurel32if test "$fdt" = "yes" ; then
31203f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3121f652e6afSaurel32fi
3122dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3123dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3124dcc38d1cSMarcelo Tosattifi
31259195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
31269195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
31279195b2c2SStefan Weilfi
3128de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
3129de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
3130de5071c5SBlue Swirlfi
31315f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
31325f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
31335f6b9e8fSBlue Swirlfi
3134e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3135e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3136e78815a5SAndreas Färberfi
3137e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3138e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3139e78815a5SAndreas Färberfi
314097a847bcSbellard
3141cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3142cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3143cd4ec0b4SGerd Hoffmannfi
3144cd4ec0b4SGerd Hoffmann
314536707144SAlon Levyif test "$smartcard" = "yes" ; then
314636707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
314736707144SAlon Levyfi
314836707144SAlon Levy
3149111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3150111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3151111a38b0SRobert Relyeafi
3152111a38b0SRobert Relyea
315369354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
315469354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
315569354a83SHans de Goedefi
315669354a83SHans de Goede
315720ff075bSMichael Walleif test "$opengl" = "yes" ; then
315820ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
315920ff075bSMichael Wallefi
316020ff075bSMichael Walle
3161c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3162c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3163c589b249SRonnie Sahlbergfi
3164c589b249SRonnie Sahlberg
316583fb7adfSbellard# XXX: suppress that
31667d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
31672358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
31687d3505c5Sbellardfi
31697d3505c5Sbellard
31702358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3171c5937220Spbrook
317220ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
317320ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
317420ff6c80SAnthony Liguorifi
3175f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3176f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3177f27aaf4bSChristian Brunnerfi
317820ff6c80SAnthony Liguori
3179d0e2fce5SAneesh Kumar K.Vif test "$ucontext_coroutine" = "yes" ; then
3180d0e2fce5SAneesh Kumar K.V  echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
3181d0e2fce5SAneesh Kumar K.Vfi
3182d0e2fce5SAneesh Kumar K.V
3183d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
3184d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3185d2042378SAneesh Kumar K.Vfi
3186d2042378SAneesh Kumar K.V
3187e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
3188e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3189e06a765eSHarsh Prateek Borafi
3190e06a765eSHarsh Prateek Bora
319168063649Sblueswir1# USB host support
319268063649Sblueswir1case "$usb" in
319368063649Sblueswir1linux)
319498ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
319568063649Sblueswir1;;
319668063649Sblueswir1bsd)
319798ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
319868063649Sblueswir1;;
319968063649Sblueswir1*)
320098ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
320168063649Sblueswir1;;
320268063649Sblueswir1esac
320368063649Sblueswir1
3204e4858974SLluís# use default implementation for tracing backend-specific routines
3205e4858974SLluístrace_default=yes
320694a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
32076d8a764eSLluísif test "$trace_backend" = "nop"; then
32086d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
320922890ab5SPrerna Saxenafi
32109410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
32116d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
3212e4858974SLluís  trace_default=no
32136d8a764eSLluís  # Set the appropriate trace file.
3214953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
32159410b56cSPrerna Saxenafi
32166d8a764eSLluísif test "$trace_backend" = "stderr"; then
32176d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
32189a82b6a5SLluís  trace_default=no
32196d8a764eSLluísfi
32206d8a764eSLluísif test "$trace_backend" = "ust"; then
32216d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
32226d8a764eSLluísfi
32236d8a764eSLluísif test "$trace_backend" = "dtrace"; then
32246d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
32256d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
32266d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
32276d8a764eSLluís  fi
3228c276b17dSDaniel P. Berrangefi
32299410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
3230e4858974SLluísif test "$trace_default" = "yes"; then
3231e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3232e4858974SLluísfi
32339410b56cSPrerna Saxena
323498ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
3235fffbeb75SGerd Hoffmannecho "CHECKS=$checks" >> $config_host_mak
323698ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3237804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3238804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
32391901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
32401901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
32411901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
3242c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
3243804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
32442b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3245804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
3246804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3247804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3248804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
32499fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
325044dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3251e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3252a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3253f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3254e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3255e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3256e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3257e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3258e39f0062SPaolo Bonzinifi
3259c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
3260e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3261a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3262a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
326373da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
32643e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3265804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3266957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
3267804edf29SJuan Quintela
32684bf6b55bSJuan Quintela# generate list of library paths for linker script
32694bf6b55bSJuan Quintela
32704bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
32714bf6b55bSJuan Quintela
32724bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
32734bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
32744bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
32754bf6b55bSJuan Quintela  else
32764bf6b55bSJuan Quintela    rm ${config_host_ld}~
32774bf6b55bSJuan Quintela  fi
32784bf6b55bSJuan Quintelafi
32794bf6b55bSJuan Quintela
32804d904533SBlue Swirlfor d in libdis libdis-user; do
32814d904533SBlue Swirl    mkdir -p $d
328211568d6dSPaolo Bonzini    symlink $source_path/Makefile.dis $d/Makefile
32834d904533SBlue Swirl    echo > $d/config.mak
32844d904533SBlue Swirldone
32854d904533SBlue Swirl
328697a847bcSbellardfor target in $target_list; do
328797a847bcSbellardtarget_dir="$target"
328825be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3289600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
329097a847bcSbellardtarget_bigendian="no"
32911f3d3c8fSJuan Quintela
3292ea2d6a39SJuan Quintelacase "$target_arch2" in
3293cfa550c6SMax Filippov  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
3294ea2d6a39SJuan Quintela  target_bigendian=yes
3295ea2d6a39SJuan Quintela  ;;
3296ea2d6a39SJuan Quintelaesac
329797a847bcSbellardtarget_softmmu="no"
3298997344f3Sbellardtarget_user_only="no"
3299831b7825Sthstarget_linux_user="no"
3300831b7825Sthstarget_darwin_user="no"
330184778508Sblueswir1target_bsd_user="no"
33029e407a85Spbrookcase "$target" in
3303600309b6SBlue Swirl  ${target_arch2}-softmmu)
33049e407a85Spbrook    target_softmmu="yes"
33059e407a85Spbrook    ;;
3306600309b6SBlue Swirl  ${target_arch2}-linux-user)
33079c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
33089c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
33099c7a4202SBlue Swirl      exit 1
33109c7a4202SBlue Swirl    fi
33119e407a85Spbrook    target_user_only="yes"
33129e407a85Spbrook    target_linux_user="yes"
33139e407a85Spbrook    ;;
3314600309b6SBlue Swirl  ${target_arch2}-darwin-user)
33159c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
33169c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
33179c7a4202SBlue Swirl      exit 1
33189c7a4202SBlue Swirl    fi
33199e407a85Spbrook    target_user_only="yes"
3320831b7825Sths    target_darwin_user="yes"
33219e407a85Spbrook    ;;
3322600309b6SBlue Swirl  ${target_arch2}-bsd-user)
33239cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
33249c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
33259c7a4202SBlue Swirl      exit 1
33269c7a4202SBlue Swirl    fi
332784778508Sblueswir1    target_user_only="yes"
332884778508Sblueswir1    target_bsd_user="yes"
332984778508Sblueswir1    ;;
33309e407a85Spbrook  *)
33319e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
33329e407a85Spbrook    exit 1
33339e407a85Spbrook    ;;
33349e407a85Spbrookesac
3335831b7825Sths
333697a847bcSbellardmkdir -p $target_dir
3337158142c2Sbellardmkdir -p $target_dir/fpu
333857fec1feSbellardmkdir -p $target_dir/tcg
333959f2a787SGerd Hoffmannmkdir -p $target_dir/ide
3340353ac78dSAneesh Kumar K.Vmkdir -p $target_dir/9pfs
334184778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
334269de927cSbellard  mkdir -p $target_dir/nwfpe
334369de927cSbellardfi
334411568d6dSPaolo Bonzinisymlink $source_path/Makefile.target $target_dir/Makefile
3345ec530c81Sbellard
334697a847bcSbellard
334725be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
334897a847bcSbellard
3349e5fe0c52Spbrookbflt="no"
3350bd0c5661Spbrooktarget_nptl="no"
3351600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
33527ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
335356aebc89Spbrookgdb_xml_files=""
3354c2e3dee6SLaurent Viviertarget_short_alignment=2
3355c2e3dee6SLaurent Viviertarget_int_alignment=4
3356c2e3dee6SLaurent Viviertarget_long_alignment=4
3357c2e3dee6SLaurent Viviertarget_llong_alignment=8
3358de3a354aSMichael Walletarget_libs_softmmu=
33597ba1e619Saliguori
3360938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
33616acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3362e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3363e73aae67SJuan Quintela
3364600309b6SBlue Swirlcase "$target_arch2" in
33652408a527Saurel32  i386)
336671deff27SAurelien Jarno    target_phys_bits=64
33672408a527Saurel32  ;;
33682408a527Saurel32  x86_64)
33696acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
33701ad2134fSPaul Brook    target_phys_bits=64
3371c2e3dee6SLaurent Vivier    target_long_alignment=8
33722408a527Saurel32  ;;
33732408a527Saurel32  alpha)
33741ad2134fSPaul Brook    target_phys_bits=64
3375c2e3dee6SLaurent Vivier    target_long_alignment=8
3376a4b388ffSRichard Henderson    target_nptl="yes"
33772408a527Saurel32  ;;
33782408a527Saurel32  arm|armeb)
3379b498c8a0SJuan Quintela    TARGET_ARCH=arm
3380e5fe0c52Spbrook    bflt="yes"
3381bd0c5661Spbrook    target_nptl="yes"
338256aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
33831ad2134fSPaul Brook    target_phys_bits=32
3384c2e3dee6SLaurent Vivier    target_llong_alignment=4
33852408a527Saurel32  ;;
33862408a527Saurel32  cris)
3387253bd7f8Sedgar_igl    target_nptl="yes"
33881ad2134fSPaul Brook    target_phys_bits=32
33892408a527Saurel32  ;;
3390613a22c9SMichael Walle  lm32)
3391613a22c9SMichael Walle    target_phys_bits=32
3392de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3393613a22c9SMichael Walle  ;;
33942408a527Saurel32  m68k)
33950938cda5Saurel32    bflt="yes"
339656aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
33971ad2134fSPaul Brook    target_phys_bits=32
3398c2e3dee6SLaurent Vivier    target_int_alignment=2
3399c2e3dee6SLaurent Vivier    target_long_alignment=2
3400c2e3dee6SLaurent Vivier    target_llong_alignment=2
34012408a527Saurel32  ;;
3402877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3403877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
340472b675caSEdgar E. Iglesias    bflt="yes"
340572b675caSEdgar E. Iglesias    target_nptl="yes"
340672b675caSEdgar E. Iglesias    target_phys_bits=32
3407de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
340872b675caSEdgar E. Iglesias  ;;
34092408a527Saurel32  mips|mipsel)
3410b498c8a0SJuan Quintela    TARGET_ARCH=mips
341125be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3412f04dc72fSPaul Brook    target_nptl="yes"
34131ad2134fSPaul Brook    target_phys_bits=64
34142408a527Saurel32  ;;
34152408a527Saurel32  mipsn32|mipsn32el)
3416b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
34176acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
341825be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
34191ad2134fSPaul Brook    target_phys_bits=64
34202408a527Saurel32  ;;
34212408a527Saurel32  mips64|mips64el)
3422b498c8a0SJuan Quintela    TARGET_ARCH=mips64
34236acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
342425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
34251ad2134fSPaul Brook    target_phys_bits=64
3426c2e3dee6SLaurent Vivier    target_long_alignment=8
34272408a527Saurel32  ;;
34282408a527Saurel32  ppc)
3429c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
34308b242ebaSAlexander Graf    target_phys_bits=64
3431d6630708SNathan Froyd    target_nptl="yes"
3432de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
34332408a527Saurel32  ;;
34342408a527Saurel32  ppcemb)
34356acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3436e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3437c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
34381ad2134fSPaul Brook    target_phys_bits=64
3439d6630708SNathan Froyd    target_nptl="yes"
3440de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
34412408a527Saurel32  ;;
34422408a527Saurel32  ppc64)
34436acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3444e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3445c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
34461ad2134fSPaul Brook    target_phys_bits=64
3447c2e3dee6SLaurent Vivier    target_long_alignment=8
3448de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
34492408a527Saurel32  ;;
34502408a527Saurel32  ppc64abi32)
3451b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
34526acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3453e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
345425be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3455c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
34561ad2134fSPaul Brook    target_phys_bits=64
3457de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
34582408a527Saurel32  ;;
34592408a527Saurel32  sh4|sh4eb)
3460b498c8a0SJuan Quintela    TARGET_ARCH=sh4
34614dbed897Spbrook    bflt="yes"
34620b6d3ae0Saurel32    target_nptl="yes"
34631ad2134fSPaul Brook    target_phys_bits=32
34642408a527Saurel32  ;;
34652408a527Saurel32  sparc)
34661ad2134fSPaul Brook    target_phys_bits=64
34672408a527Saurel32  ;;
34682408a527Saurel32  sparc64)
34696acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
34701ad2134fSPaul Brook    target_phys_bits=64
3471c2e3dee6SLaurent Vivier    target_long_alignment=8
34722408a527Saurel32  ;;
34732408a527Saurel32  sparc32plus)
3474b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
34756acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3476e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
347725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
34781ad2134fSPaul Brook    target_phys_bits=64
34792408a527Saurel32  ;;
348024e804ecSAlexander Graf  s390x)
3481bc434676SUlrich Hecht    target_nptl="yes"
348224e804ecSAlexander Graf    target_phys_bits=64
34837b3da903SAlexander Graf    target_long_alignment=8
348424e804ecSAlexander Graf  ;;
3485d2fbca94SGuan Xuetao  unicore32)
3486d2fbca94SGuan Xuetao    target_phys_bits=32
3487d2fbca94SGuan Xuetao  ;;
3488cfa550c6SMax Filippov  xtensa|xtensaeb)
3489cfa550c6SMax Filippov    TARGET_ARCH=xtensa
3490cfa550c6SMax Filippov    target_phys_bits=32
3491cfa550c6SMax Filippov  ;;
34922408a527Saurel32  *)
3493de83cd02Sbellard    echo "Unsupported target CPU"
3494de83cd02Sbellard    exit 1
34952408a527Saurel32  ;;
34962408a527Saurel32esac
3497c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3498c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3499c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3500c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
350125be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3502053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
350325be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
350425be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
350542bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
35066acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
35076acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
35086acff7daSJuan Quintelafi
350925be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3510e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3511e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3512e6e91b9cSJuan Quintelafi
351325be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
35141b0c87fcSJuan Quintelacase "$target_arch2" in
35151b0c87fcSJuan Quintela  i386|x86_64)
35161b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
351764b3cfdbSAnthony PERARD      target_phys_bits=64
351825be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
351959d21e53SAlexander Graf    else
352059d21e53SAlexander Graf      echo "CONFIG_NO_XEN=y" >> $config_target_mak
3521432d268cSJun Nakajima    fi
352259d21e53SAlexander Graf    ;;
352359d21e53SAlexander Graf  *)
352459d21e53SAlexander Graf    echo "CONFIG_NO_XEN=y" >> $config_target_mak
35251b0c87fcSJuan Quintelaesac
3526c59249f9SJuan Quintelacase "$target_arch2" in
35270e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3528c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3529c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3530c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3531c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
35325f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3533adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3534adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3535c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3536c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
353725be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
35381ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
3539d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3540d5970055SMichael S. Tsirkin      fi
3541c59249f9SJuan Quintela    fi
3542c59249f9SJuan Quintelaesac
35437f762366SBlue Swirlif test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then
35440a6b8ddeSAlexander Graf  echo "CONFIG_PSERIES=y" >> $config_target_mak
35450a6b8ddeSAlexander Graffi
3546de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
354725be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
354897a847bcSbellardfi
354997a847bcSbellardif test "$target_softmmu" = "yes" ; then
3550b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
355125be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3552de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
35530e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
35545791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3555de83cd02Sbellardfi
3556997344f3Sbellardif test "$target_user_only" = "yes" ; then
355725be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3558997344f3Sbellardfi
3559831b7825Sthsif test "$target_linux_user" = "yes" ; then
356025be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3561831b7825Sthsfi
3562831b7825Sthsif test "$target_darwin_user" = "yes" ; then
356325be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3564831b7825Sthsfi
3565111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3566111a38b0SRobert Relyea  echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3567111a38b0SRobert Relyea  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3568111a38b0SRobert Relyea  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3569111a38b0SRobert Relyeafi
357056aebc89Spbrooklist=""
357156aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
357256aebc89Spbrook  for x in $gdb_xml_files; do
357356aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
357456aebc89Spbrook  done
357525be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
35763d0f1517SJuan Quintelafi
3577de83cd02Sbellard
3578e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
357925be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3580e5fe0c52Spbrookfi
3581bd0c5661Spbrookif test "$target_user_only" = "yes" \
3582bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
358325be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3584bd0c5661Spbrookfi
3585379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
358625be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3587379f6698SPaul Brookfi
358884778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
358925be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
359084778508Sblueswir1fi
35915b0753e0Sbellard
35924afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3593fa282484SJuan Quintela
35944afddb55SJuan Quintelacflags=""
3595f9728943SPaolo Bonziniincludes=""
3596fa282484SJuan Quintelaldflags=""
35979b8e111fSJuan Quintela
35989195b2c2SStefan Weilif test "$tcg_interpreter" = "yes"; then
35999195b2c2SStefan Weil  includes="-I\$(SRC_PATH)/tcg/tci $includes"
36009195b2c2SStefan Weilelif test "$ARCH" = "sparc64" ; then
3601f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
360224e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3603f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
36045d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3605f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
360657ddfbf7SJuan Quintelaelse
3607f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
360857ddfbf7SJuan Quintelafi
3609f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
361057ddfbf7SJuan Quintela
36114d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
36124d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
36134d904533SBlue Swirlelse
36144d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
36154d904533SBlue Swirlfi
36164d904533SBlue Swirl
361764656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
361864656024SJuan Quintela  case "$i" in
361964656024SJuan Quintela  alpha)
362025be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
36214d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
362264656024SJuan Quintela  ;;
362364656024SJuan Quintela  arm)
362425be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
36254d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
362664656024SJuan Quintela  ;;
362764656024SJuan Quintela  cris)
362825be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
36294d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
363064656024SJuan Quintela  ;;
363164656024SJuan Quintela  hppa)
363225be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
36334d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
363464656024SJuan Quintela  ;;
363564656024SJuan Quintela  i386|x86_64)
363625be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
36374d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
363864656024SJuan Quintela  ;;
3639903ec55cSAurelien Jarno  ia64*)
3640903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3641903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3642903ec55cSAurelien Jarno  ;;
364364656024SJuan Quintela  m68k)
364425be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
36454d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
364664656024SJuan Quintela  ;;
3647877fdc12SEdgar E. Iglesias  microblaze*)
364825be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
36494d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
365064656024SJuan Quintela  ;;
365164656024SJuan Quintela  mips*)
365225be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
36534d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
365464656024SJuan Quintela  ;;
365564656024SJuan Quintela  ppc*)
365625be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
36574d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
365864656024SJuan Quintela  ;;
365924e804ecSAlexander Graf  s390*)
366025be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
36614d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
366264656024SJuan Quintela  ;;
366364656024SJuan Quintela  sh4)
366425be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
36654d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
366664656024SJuan Quintela  ;;
366764656024SJuan Quintela  sparc*)
366825be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
36694d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
367064656024SJuan Quintela  ;;
3671cfa550c6SMax Filippov  xtensa*)
3672cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
3673cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $libdis_config_mak
3674cfa550c6SMax Filippov  ;;
367564656024SJuan Quintela  esac
367664656024SJuan Quinteladone
36779195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
36789195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
36799195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $libdis_config_mak
36809195b2c2SStefan Weilfi
368164656024SJuan Quintela
36826ee7126fSJuan Quintelacase "$ARCH" in
36836ee7126fSJuan Quintelaalpha)
36846ee7126fSJuan Quintela  # Ensure there's only a single GP
36856ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
36866ee7126fSJuan Quintela;;
36876ee7126fSJuan Quintelaesac
36886ee7126fSJuan Quintela
368955d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
369055d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
369155d9c04bSJuan Quintela  arm)
369255d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
369355d9c04bSJuan Quintela  ;;
369425a8bb96SMichael Walle  lm32)
369525a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
369625a8bb96SMichael Walle  ;;
369755d9c04bSJuan Quintela  i386|mips|ppc)
369855d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
369955d9c04bSJuan Quintela  ;;
370055d9c04bSJuan Quintela  esac
370155d9c04bSJuan Quintelafi
370255d9c04bSJuan Quintela
3703471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
3704471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
3705471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
370625be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3707471857ddSJuan Quintelafi
3708471857ddSJuan Quintela
3709d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
371025be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
3711d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
3712d02c1db3SJuan Quintela    cflags="-p $cflags"
3713d02c1db3SJuan Quintela    ldflags="-p $ldflags"
3714d02c1db3SJuan Quintela  fi
3715d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
3716d02c1db3SJuan Quintela    ldflags="-p $ldflags"
371725be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3718d02c1db3SJuan Quintela  fi
3719d02c1db3SJuan Quintelafi
3720d02c1db3SJuan Quintela
37219195b2c2SStefan Weilif test "$ARCH" = "tci"; then
37229195b2c2SStefan Weil  linker_script=""
37239195b2c2SStefan Weilelse
37246ee7126fSJuan Quintela  linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
37259195b2c2SStefan Weilfi
37269195b2c2SStefan Weil
37279b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3728fa282484SJuan Quintela  case "$ARCH" in
3729fa282484SJuan Quintela  sparc)
3730fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
3731322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
3732fa282484SJuan Quintela    ;;
37334d58be06SRichard Henderson  alpha | s390x)
37344d58be06SRichard Henderson    # The default placement of the application is fine.
37354d58be06SRichard Henderson    ;;
3736fd76e73aSRichard Henderson  *)
3737322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
3738fa282484SJuan Quintela    ;;
3739fa282484SJuan Quintela  esac
3740fa282484SJuan Quintelafi
3741fa282484SJuan Quintela
3742e205c790SJan Kiszka# use included Linux headers
3743af2be207SJan Kiszkaif test "$linux" = "yes" ; then
3744e205c790SJan Kiszka  includes="-I\$(SRC_PATH)/linux-headers $includes"
3745e205c790SJan Kiszka  mkdir -p linux-headers
3746e205c790SJan Kiszka  case "$cpu" in
3747e205c790SJan Kiszka  i386|x86_64)
3748e205c790SJan Kiszka    symlink $source_path/linux-headers/asm-x86 linux-headers/asm
3749e205c790SJan Kiszka    ;;
3750e205c790SJan Kiszka  ppcemb|ppc|ppc64)
3751af2be207SJan Kiszka    symlink $source_path/linux-headers/asm-powerpc linux-headers/asm
3752e205c790SJan Kiszka    ;;
3753e205c790SJan Kiszka  s390x)
3754e205c790SJan Kiszka    symlink $source_path/linux-headers/asm-s390 linux-headers/asm
3755e205c790SJan Kiszka    ;;
3756e205c790SJan Kiszka  esac
3757af2be207SJan Kiszkafi
3758e205c790SJan Kiszka
375925be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
376025be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3761f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
3762fa282484SJuan Quintela
376397a847bcSbellarddone # for target in $targets
37647d13299dSbellard
3765d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
3766e1144d00SMark McLoughlinDIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3767446b9165SAndreas FärberDIRS="$DIRS pc-bios/spapr-rtas"
37682d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
37693e230dd2SCorentin CharyDIRS="$DIRS fsdev ui"
3770e098fc3fSMichael RothDIRS="$DIRS qapi qapi-generated"
3771d9cd446bSAnthony LiguoriDIRS="$DIRS qga trace"
377270371cfbSLuiz CapitulinoFILES="Makefile tests/Makefile qdict-test-data.txt"
3773e7daa605SthsFILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3774ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3775446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
37762d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
3777753d11f2SRichard Hendersonfor bios_file in \
3778753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
3779753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
3780753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
3781753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
3782753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
3783753d11f2SRichard Hendersondo
37847ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
37857ea78b74SJan Kiszkadone
3786d1807a4fSPaolo Bonzinimkdir -p $DIRS
37877d13299dSbellardfor f in $FILES ; do
3788f9245e10SPeter Maydell    if [ -e "$source_path/$f" ] && ! [ -e "$f" ]; then
3789f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
3790f9245e10SPeter Maydell    fi
37917d13299dSbellarddone
37921ad2134fSPaul Brook
3793c34ebfdcSAnthony Liguori# temporary config to build submodules
37942d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
3795c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
379637116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3797c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3798c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3799c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
3800c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
3801c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3802c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
3803c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
3804c34ebfdcSAnthony Liguoridone
3805c34ebfdcSAnthony Liguori
38061ad2134fSPaul Brookfor hwlib in 32 64; do
38071ad2134fSPaul Brook  d=libhw$hwlib
38081ad2134fSPaul Brook  mkdir -p $d
38099953b2fcSBlue Swirl  mkdir -p $d/ide
381011568d6dSPaolo Bonzini  symlink $source_path/Makefile.hw $d/Makefile
3811353ac78dSAneesh Kumar K.V  mkdir -p $d/9pfs
381237116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
38131ad2134fSPaul Brookdone
3814add16157SBlue Swirl
3815111a38b0SRobert Relyeaif [ "$source_path" != `pwd` ]; then
3816111a38b0SRobert Relyea    # out of tree build
3817111a38b0SRobert Relyea    mkdir -p libcacard
3818111a38b0SRobert Relyea    rm -f libcacard/Makefile
381944dc0ca3SAlon Levy    symlink "$source_path/libcacard/Makefile" libcacard/Makefile
3820111a38b0SRobert Relyeafi
3821111a38b0SRobert Relyea
3822add16157SBlue Swirld=libuser
3823add16157SBlue Swirlmkdir -p $d
3824937b1258SLluís Vilanovamkdir -p $d/trace
382511568d6dSPaolo Bonzinisymlink $source_path/Makefile.user $d/Makefile
3826b40292e7SJan Kiszka
3827b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
3828b40292e7SJan Kiszka  mkdir -p QMP
3829b40292e7SJan Kiszkafi
3830