xref: /openbmc/qemu/configure (revision 235e510c)
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=""
175377529c0SPaolo Bonziniuser_pie="no"
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  ;;
57297a847bcSbellard  --disable-sdl) sdl="no"
57397a847bcSbellard  ;;
574c4198157SJuan Quintela  --enable-sdl) sdl="yes"
575c4198157SJuan Quintela  ;;
576821601eaSJes Sorensen  --disable-vnc) vnc="no"
577821601eaSJes Sorensen  ;;
578821601eaSJes Sorensen  --enable-vnc) vnc="yes"
579821601eaSJes Sorensen  ;;
580b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
581102a52e4Sbellard  ;;
582c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
583c2de5c91Smalc  ;;
5842f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5852f6a1ab0Sblueswir1  ;;
5862fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5870c58ac1cSmalc  ;;
5880c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5890c58ac1cSmalc  ;;
590eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
591eb852011SMarkus Armbruster  ;;
592f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
593f8393946Saurel32  ;;
594f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
595f8393946Saurel32  ;;
596b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
597b4475aa2SLuiz Capitulino  ;;
598b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
599b4475aa2SLuiz Capitulino  ;;
600f3d08ee6SPaul Brook  --enable-debug)
601f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
602f3d08ee6SPaul Brook      debug_tcg="yes"
603b4475aa2SLuiz Capitulino      debug_mon="yes"
604f3d08ee6SPaul Brook      debug="yes"
605f3d08ee6SPaul Brook      strip_opt="no"
606f3d08ee6SPaul Brook  ;;
60703b4fe7dSaliguori  --enable-sparse) sparse="yes"
60803b4fe7dSaliguori  ;;
60903b4fe7dSaliguori  --disable-sparse) sparse="no"
61003b4fe7dSaliguori  ;;
6111625af87Saliguori  --disable-strip) strip_opt="no"
6121625af87Saliguori  ;;
6138d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
6148d5d2d4cSths  ;;
6151be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
6161be10ad2SJuan Quintela  ;;
6172f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
6182f9606b3Saliguori  ;;
619ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
620ea784e3bSJuan Quintela  ;;
6212f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
6222f6f5c7aSCorentin Chary  ;;
6232f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
6242f6f5c7aSCorentin Chary  ;;
625efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
626efe556adSCorentin Chary  ;;
627efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
628efe556adSCorentin Chary  ;;
629bd023f95SCorentin Chary  --disable-vnc-thread) vnc_thread="no"
630bd023f95SCorentin Chary  ;;
631bd023f95SCorentin Chary  --enable-vnc-thread) vnc_thread="yes"
632bd023f95SCorentin Chary  ;;
633443f1376Sbellard  --disable-slirp) slirp="no"
634c20709aaSbellard  ;;
635ee682d27SStefan Weil  --disable-uuid) uuid="no"
636ee682d27SStefan Weil  ;;
637ee682d27SStefan Weil  --enable-uuid) uuid="yes"
638ee682d27SStefan Weil  ;;
639e0e6c8c0Saliguori  --disable-vde) vde="no"
6408a16d273Sths  ;;
641dfb278bdSJuan Quintela  --enable-vde) vde="yes"
642dfb278bdSJuan Quintela  ;;
643e37630caSaliguori  --disable-xen) xen="no"
644e37630caSaliguori  ;;
645fc321b4bSJuan Quintela  --enable-xen) xen="yes"
646fc321b4bSJuan Quintela  ;;
6472e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
6482e4d9fb1Saurel32  ;;
6494ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6504ffcedb6SJuan Quintela  ;;
651fb599c9aSbalrog  --disable-bluez) bluez="no"
652fb599c9aSbalrog  ;;
653a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
654a20a6f46SJuan Quintela  ;;
6557ba1e619Saliguori  --disable-kvm) kvm="no"
6567ba1e619Saliguori  ;;
657b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
658b31a0277SJuan Quintela  ;;
6599195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
6609195b2c2SStefan Weil  ;;
6619195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
6629195b2c2SStefan Weil  ;;
663cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
664cd4ec0b4SGerd Hoffmann  ;;
665cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
666cd4ec0b4SGerd Hoffmann  ;;
667c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
668c589b249SRonnie Sahlberg  ;;
669c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
670c589b249SRonnie Sahlberg  ;;
67105c2a3e7Sbellard  --enable-profiler) profiler="yes"
67205c2a3e7Sbellard  ;;
673c2de5c91Smalc  --enable-cocoa)
674c2de5c91Smalc      cocoa="yes" ;
675c2de5c91Smalc      sdl="no" ;
676c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6775b0753e0Sbellard  ;;
678cad25d69Spbrook  --disable-system) softmmu="no"
6790a8e90f4Spbrook  ;;
680cad25d69Spbrook  --enable-system) softmmu="yes"
6810a8e90f4Spbrook  ;;
6820953a80fSZachary Amsden  --disable-user)
6830953a80fSZachary Amsden      linux_user="no" ;
6840953a80fSZachary Amsden      bsd_user="no" ;
6850953a80fSZachary Amsden      darwin_user="no"
6860953a80fSZachary Amsden  ;;
6870953a80fSZachary Amsden  --enable-user) ;;
688831b7825Sths  --disable-linux-user) linux_user="no"
6890a8e90f4Spbrook  ;;
690831b7825Sths  --enable-linux-user) linux_user="yes"
691831b7825Sths  ;;
692831b7825Sths  --disable-darwin-user) darwin_user="no"
693831b7825Sths  ;;
694831b7825Sths  --enable-darwin-user) darwin_user="yes"
6950a8e90f4Spbrook  ;;
69684778508Sblueswir1  --disable-bsd-user) bsd_user="no"
69784778508Sblueswir1  ;;
69884778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
69984778508Sblueswir1  ;;
700379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
701379f6698SPaul Brook  ;;
702379f6698SPaul Brook  --disable-guest-base) guest_base="no"
703379f6698SPaul Brook  ;;
70434005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
70534005a00SKirill A. Shutemov  ;;
70634005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
70734005a00SKirill A. Shutemov  ;;
708c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
709c5937220Spbrook  ;;
7103142255cSblueswir1  --sparc_cpu=*)
7113142255cSblueswir1  ;;
71285aa5189Sbellard  --enable-werror) werror="yes"
71385aa5189Sbellard  ;;
71485aa5189Sbellard  --disable-werror) werror="no"
71585aa5189Sbellard  ;;
7164d3b6f6eSbalrog  --disable-curses) curses="no"
7174d3b6f6eSbalrog  ;;
718c584a6d0SJuan Quintela  --enable-curses) curses="yes"
719c584a6d0SJuan Quintela  ;;
720769ce76dSAlexander Graf  --disable-curl) curl="no"
721769ce76dSAlexander Graf  ;;
722788c8196SJuan Quintela  --enable-curl) curl="yes"
723788c8196SJuan Quintela  ;;
7242df87df7SJuan Quintela  --disable-fdt) fdt="no"
7252df87df7SJuan Quintela  ;;
7262df87df7SJuan Quintela  --enable-fdt) fdt="yes"
7272df87df7SJuan Quintela  ;;
7285495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
7295495ed11SLuiz Capitulino  ;;
7305495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
7315495ed11SLuiz Capitulino  ;;
732bd0c5661Spbrook  --disable-nptl) nptl="no"
733bd0c5661Spbrook  ;;
734b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
735b0a47e79SJuan Quintela  ;;
7368ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
7378ff9cbf7Smalc  ;;
7385c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
7395c6c3a6cSChristoph Hellwig  ;;
7405c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
7415c6c3a6cSChristoph Hellwig  ;;
742758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
743758e8e38SVenkateswararao Jujjuri (JV)  ;;
744758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
745758e8e38SVenkateswararao Jujjuri (JV)  ;;
74677755340Sths  --disable-blobs) blobs="no"
74777755340Sths  ;;
7484a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
7494a19f1ecSpbrook  ;;
750a25dba17SJuan Quintela  --disable-docs) docs="no"
75170ec5dc0SAnthony Liguori  ;;
752a25dba17SJuan Quintela  --enable-docs) docs="yes"
75383a3ab8bSJuan Quintela  ;;
754d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
755d5970055SMichael S. Tsirkin  ;;
756d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
757d5970055SMichael S. Tsirkin  ;;
75820ff075bSMichael Walle  --disable-opengl) opengl="no"
75920ff075bSMichael Walle  ;;
76020ff075bSMichael Walle  --enable-opengl) opengl="yes"
76120ff075bSMichael Walle  ;;
7626bde81cbSPaolo Bonzini  --*dir)
7636bde81cbSPaolo Bonzini  ;;
764f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
765f27aaf4bSChristian Brunner  ;;
766f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
767f27aaf4bSChristian Brunner  ;;
76836707144SAlon Levy  --disable-smartcard) smartcard="no"
76936707144SAlon Levy  ;;
77036707144SAlon Levy  --enable-smartcard) smartcard="yes"
77136707144SAlon Levy  ;;
772111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
773111a38b0SRobert Relyea  ;;
774111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
775111a38b0SRobert Relyea  ;;
77669354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
77769354a83SHans de Goede  ;;
77869354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
77969354a83SHans de Goede  ;;
7801ece9905SAlon Levy  --disable-zlib-test) zlib="no"
7811ece9905SAlon Levy  ;;
782d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
783d138cee9SMichael Roth  ;;
784d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
785d138cee9SMichael Roth  ;;
7867f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7877f1559c6Sbalrog  ;;
7887d13299dSbellard  esac
7897d13299dSbellarddone
7907d13299dSbellard
7913142255cSblueswir1#
7923142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
793a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7943142255cSblueswir1#
795379f6698SPaul Brookhost_guest_base="no"
79640293e58Sbellardcase "$cpu" in
797ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
798ed968ff1SJuan Quintela           v7|v8)
799a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
800ed968ff1SJuan Quintela           ;;
801ed968ff1SJuan Quintela           v8plus|v8plusa)
802a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
803ed968ff1SJuan Quintela           ;;
804ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
805a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
806ed968ff1SJuan Quintela           esac
8070c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
808a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
809762e8230Sblueswir1           if test "$solaris" = "no" ; then
810a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
811c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
812762e8230Sblueswir1           fi
8133142255cSblueswir1           ;;
814ed968ff1SJuan Quintela    sparc64)
815a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
8160c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
817a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
818ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
819a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
820762e8230Sblueswir1           fi
8213142255cSblueswir1           ;;
82276d83bdeSths    s390)
82328d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
82428d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
82548bb3750SRichard Henderson           host_guest_base="yes"
82628d7cc49SRichard Henderson           ;;
82728d7cc49SRichard Henderson    s390x)
82828d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
82928d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
83048bb3750SRichard Henderson           host_guest_base="yes"
83176d83bdeSths           ;;
83240293e58Sbellard    i386)
833a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
8340c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
8352b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
836c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
837379f6698SPaul Brook           host_guest_base="yes"
83840293e58Sbellard           ;;
83940293e58Sbellard    x86_64)
840a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
8410c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8422b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
843379f6698SPaul Brook           host_guest_base="yes"
844379f6698SPaul Brook           ;;
845379f6698SPaul Brook    arm*)
846379f6698SPaul Brook           host_guest_base="yes"
84740293e58Sbellard           ;;
848f6548c0aSmalc    ppc*)
849f6548c0aSmalc           host_guest_base="yes"
850f6548c0aSmalc           ;;
851cc01cc8eSAurelien Jarno    mips*)
852cc01cc8eSAurelien Jarno           host_guest_base="yes"
853cc01cc8eSAurelien Jarno           ;;
854477ba620SAurelien Jarno    ia64*)
855477ba620SAurelien Jarno           host_guest_base="yes"
856477ba620SAurelien Jarno           ;;
857fd76e73aSRichard Henderson    hppa*)
858fd76e73aSRichard Henderson           host_guest_base="yes"
859fd76e73aSRichard Henderson           ;;
860d2fbca94SGuan Xuetao    unicore32*)
861d2fbca94SGuan Xuetao           host_guest_base="yes"
862d2fbca94SGuan Xuetao           ;;
8633142255cSblueswir1esac
8643142255cSblueswir1
865379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
866379f6698SPaul Brook
86760e0df25SPeter Maydell
86860e0df25SPeter Maydelldefault_target_list=""
86960e0df25SPeter Maydell
87060e0df25SPeter Maydell# these targets are portable
87160e0df25SPeter Maydellif [ "$softmmu" = "yes" ] ; then
87260e0df25SPeter Maydell    default_target_list="\
87360e0df25SPeter Maydelli386-softmmu \
87460e0df25SPeter Maydellx86_64-softmmu \
87527cdad67SRichard Hendersonalpha-softmmu \
87660e0df25SPeter Maydellarm-softmmu \
87760e0df25SPeter Maydellcris-softmmu \
87860e0df25SPeter Maydelllm32-softmmu \
87960e0df25SPeter Maydellm68k-softmmu \
88060e0df25SPeter Maydellmicroblaze-softmmu \
88160e0df25SPeter Maydellmicroblazeel-softmmu \
88260e0df25SPeter Maydellmips-softmmu \
88360e0df25SPeter Maydellmipsel-softmmu \
88460e0df25SPeter Maydellmips64-softmmu \
88560e0df25SPeter Maydellmips64el-softmmu \
88660e0df25SPeter Maydellppc-softmmu \
88760e0df25SPeter Maydellppcemb-softmmu \
88860e0df25SPeter Maydellppc64-softmmu \
88960e0df25SPeter Maydellsh4-softmmu \
89060e0df25SPeter Maydellsh4eb-softmmu \
89160e0df25SPeter Maydellsparc-softmmu \
89260e0df25SPeter Maydellsparc64-softmmu \
8930f3301d4SAlexander Grafs390x-softmmu \
894cfa550c6SMax Filippovxtensa-softmmu \
895cfa550c6SMax Filippovxtensaeb-softmmu \
89660e0df25SPeter Maydell"
89760e0df25SPeter Maydellfi
89860e0df25SPeter Maydell# the following are Linux specific
89960e0df25SPeter Maydellif [ "$linux_user" = "yes" ] ; then
90060e0df25SPeter Maydell    default_target_list="${default_target_list}\
90160e0df25SPeter Maydelli386-linux-user \
90260e0df25SPeter Maydellx86_64-linux-user \
90360e0df25SPeter Maydellalpha-linux-user \
90460e0df25SPeter Maydellarm-linux-user \
90560e0df25SPeter Maydellarmeb-linux-user \
90660e0df25SPeter Maydellcris-linux-user \
90760e0df25SPeter Maydellm68k-linux-user \
90860e0df25SPeter Maydellmicroblaze-linux-user \
90960e0df25SPeter Maydellmicroblazeel-linux-user \
91060e0df25SPeter Maydellmips-linux-user \
91160e0df25SPeter Maydellmipsel-linux-user \
91260e0df25SPeter Maydellppc-linux-user \
91360e0df25SPeter Maydellppc64-linux-user \
91460e0df25SPeter Maydellppc64abi32-linux-user \
91560e0df25SPeter Maydellsh4-linux-user \
91660e0df25SPeter Maydellsh4eb-linux-user \
91760e0df25SPeter Maydellsparc-linux-user \
91860e0df25SPeter Maydellsparc64-linux-user \
91960e0df25SPeter Maydellsparc32plus-linux-user \
92060e0df25SPeter Maydellunicore32-linux-user \
9210f3301d4SAlexander Grafs390x-linux-user \
92260e0df25SPeter Maydell"
92360e0df25SPeter Maydellfi
92460e0df25SPeter Maydell# the following are Darwin specific
92560e0df25SPeter Maydellif [ "$darwin_user" = "yes" ] ; then
92660e0df25SPeter Maydell    default_target_list="$default_target_list i386-darwin-user ppc-darwin-user "
92760e0df25SPeter Maydellfi
92860e0df25SPeter Maydell# the following are BSD specific
92960e0df25SPeter Maydellif [ "$bsd_user" = "yes" ] ; then
93060e0df25SPeter Maydell    default_target_list="${default_target_list}\
93160e0df25SPeter Maydelli386-bsd-user \
93260e0df25SPeter Maydellx86_64-bsd-user \
93360e0df25SPeter Maydellsparc-bsd-user \
93460e0df25SPeter Maydellsparc64-bsd-user \
93560e0df25SPeter Maydell"
93660e0df25SPeter Maydellfi
93760e0df25SPeter Maydell
938af5db58eSpbrookif test x"$show_help" = x"yes" ; then
939af5db58eSpbrookcat << EOF
940af5db58eSpbrook
941af5db58eSpbrookUsage: configure [options]
942af5db58eSpbrookOptions: [defaults in brackets after descriptions]
943af5db58eSpbrook
944af5db58eSpbrookEOF
945af5db58eSpbrookecho "Standard options:"
946af5db58eSpbrookecho "  --help                   print this message"
947af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
948af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
949af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
95060e0df25SPeter Maydellecho "  --target-list=LIST       set target list (default: build everything)"
95160e0df25SPeter Maydellecho "Available targets: $default_target_list" | \
95260e0df25SPeter Maydell    fold -s -w 53 | sed -e 's/^/                           /'
953af5db58eSpbrookecho ""
954af5db58eSpbrookecho "Advanced options (experts only):"
955af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
956af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
957af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
9580bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
9590bfe8cc0SPaolo Bonziniecho "                           build time"
960a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
961e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
962af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
9636a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
964c886edfbSBlue Swirlecho "  --python=PYTHON          use specified python [$python]"
965e2d8830eSBradecho "  --smbd=SMBD              use specified smbd [$smbd]"
966af5db58eSpbrookecho "  --static                 enable static build [$static]"
9670b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
9680b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
9690b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
9700b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
9710b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
972f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
973f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
97409695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
975890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
976890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
9771625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
97885aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
979fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
980c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
981821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
982821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
983af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
984c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
985c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
9864c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
9874c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
988eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
989eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
9908ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
991e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
992fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
9932e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
9944ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
9958d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
9961be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
9972f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
998ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
9992f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
10002f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
100196763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
1002efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
1003bd023f95SCorentin Charyecho "  --disable-vnc-thread     disable threaded VNC server"
1004bd023f95SCorentin Charyecho "  --enable-vnc-thread      enable threaded VNC server"
1005af896aaaSpbrookecho "  --disable-curses         disable curses output"
1006c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
1007769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
1008788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
10092df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
10102df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
10115495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
10125495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
1013fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
1014a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
10156093d3d4SPeter Maydellecho "  --disable-slirp          disable SLIRP userspace network connectivity"
10167ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
1017b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
10189195b2c2SStefan Weilecho "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1019bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
1020e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
1021af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
1022af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
10230953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
10240953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
1025831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
1026831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
1027831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
1028831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
102984778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
103084778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
1031379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
1032379f6698SPaul Brookecho "                           emulation targets"
1033379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
103434005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
103534005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
1036af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
1037af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
10382f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
1039c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
1040*235e510cS陳韋任echo "  --cpu=CPU                Build for host CPU [$cpu]"
10413142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
1042ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
1043ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
1044e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
1045dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
10465c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
10475c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
1048758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
1049758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
105077755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
1051d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
1052d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
1053d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
1054d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
1055320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
1056320fba2aSFabien Chouteauecho "                           Available backends:" $("$source_path"/scripts/tracetool --list-backends)
105774242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
10589410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
1059cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
1060cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
1061f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
1062c589b249SRonnie Sahlbergecho "  --disable-libiscsi       disable iscsi support"
1063c589b249SRonnie Sahlbergecho "  --enable-libiscsi        enable iscsi support"
106436707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
106536707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
1066111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
1067111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
106869354a83SHans de Goedeecho "  --disable-usb-redir      disable usb network redirection support"
106969354a83SHans de Goedeecho "  --enable-usb-redir       enable usb network redirection support"
1070d138cee9SMichael Rothecho "  --disable-guest-agent    disable building of the QEMU Guest Agent"
1071d138cee9SMichael Rothecho "  --enable-guest-agent     enable building of the QEMU Guest Agent"
1072af5db58eSpbrookecho ""
10735bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
1074af5db58eSpbrookexit 1
1075af5db58eSpbrookfi
1076af5db58eSpbrook
10778d05095cSPaolo Bonzini# check that the C compiler works.
10788d05095cSPaolo Bonzinicat > $TMPC <<EOF
10798d05095cSPaolo Bonziniint main(void) {}
10808d05095cSPaolo BonziniEOF
10818d05095cSPaolo Bonzini
10828d05095cSPaolo Bonziniif compile_object ; then
10838d05095cSPaolo Bonzini  : C compiler works ok
10848d05095cSPaolo Bonzinielse
10858d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
10868d05095cSPaolo Bonzini    exit 1
10878d05095cSPaolo Bonzinifi
10888d05095cSPaolo Bonzini
10898d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
10908d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
10918d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1092f9188227SMike Frysingergcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
10938d05095cSPaolo Bonzinicat > $TMPC << EOF
10948d05095cSPaolo Bonziniint main(void) { return 0; }
10958d05095cSPaolo BonziniEOF
10968d05095cSPaolo Bonzinifor flag in $gcc_flags; do
1097af2d37deSStefan Weil    if compile_prog "$flag -Werror" "" ; then
10988d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
10998d05095cSPaolo Bonzini    fi
11008d05095cSPaolo Bonzinidone
11018d05095cSPaolo Bonzini
1102ec530c81Sbellard#
1103ec530c81Sbellard# Solaris specific configure tool chain decisions
1104ec530c81Sbellard#
1105ec530c81Sbellardif test "$solaris" = "yes" ; then
11066792aa11SLoïc Minier  if has $install; then
11076792aa11SLoïc Minier    :
11086792aa11SLoïc Minier  else
1109ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1110ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1111ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1112ec530c81Sbellard    exit 1
1113ec530c81Sbellard  fi
11146792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
1115ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1116ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1117ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1118ec530c81Sbellard    exit 1
1119ec530c81Sbellard  fi
11206792aa11SLoïc Minier  if has ar; then
11216792aa11SLoïc Minier    :
11226792aa11SLoïc Minier  else
1123ec530c81Sbellard    echo "Error: No path includes ar"
1124ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1125ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1126ec530c81Sbellard    fi
1127ec530c81Sbellard    exit 1
1128ec530c81Sbellard  fi
1129ec530c81Sbellardfi
1130ec530c81Sbellard
1131d138cee9SMichael Rothif test "$guest_agent" != "no" ; then
1132c886edfbSBlue Swirl  if has $python; then
1133c886edfbSBlue Swirl    :
1134c886edfbSBlue Swirl  else
1135c886edfbSBlue Swirl    echo "Python not found. Use --python=/path/to/python"
1136c886edfbSBlue Swirl    exit 1
1137c886edfbSBlue Swirl  fi
1138d138cee9SMichael Rothfi
1139c886edfbSBlue Swirl
11405327cf48Sbellardif test -z "$target_list" ; then
114160e0df25SPeter Maydell    target_list="$default_target_list"
11426e20a45fSbellardelse
1143b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
11445327cf48Sbellardfi
11450a8e90f4Spbrookif test -z "$target_list" ; then
11460a8e90f4Spbrook    echo "No targets enabled"
11470a8e90f4Spbrook    exit 1
11480a8e90f4Spbrookfi
1149f55fe278SPaolo Bonzini# see if system emulation was really requested
1150f55fe278SPaolo Bonzinicase " $target_list " in
1151f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1152f55fe278SPaolo Bonzini  ;;
1153f55fe278SPaolo Bonzini  *) softmmu=no
1154f55fe278SPaolo Bonzini  ;;
1155f55fe278SPaolo Bonziniesac
11565327cf48Sbellard
1157249247c9SJuan Quintelafeature_not_found() {
1158249247c9SJuan Quintela  feature=$1
1159249247c9SJuan Quintela
1160249247c9SJuan Quintela  echo "ERROR"
1161249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
11629332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1163249247c9SJuan Quintela  echo "ERROR"
1164249247c9SJuan Quintela  exit 1;
1165249247c9SJuan Quintela}
1166249247c9SJuan Quintela
11677d13299dSbellardif test -z "$cross_prefix" ; then
11687d13299dSbellard
11697d13299dSbellard# ---
11707d13299dSbellard# big/little endian test
11717d13299dSbellardcat > $TMPC << EOF
11727d13299dSbellard#include <inttypes.h>
11737d13299dSbellardint main(int argc, char ** argv){
11747d13299dSbellard        volatile uint32_t i=0x01234567;
11757d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
11767d13299dSbellard}
11777d13299dSbellardEOF
11787d13299dSbellard
117952166aa0SJuan Quintelaif compile_prog "" "" ; then
11807d13299dSbellard$TMPE && bigendian="yes"
11817d13299dSbellardelse
11827d13299dSbellardecho big/little test failed
11837d13299dSbellardfi
11847d13299dSbellard
11857d13299dSbellardelse
11867d13299dSbellard
11877d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1188ea8f20f8SJuan Quintelacase "$cpu" in
118924e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1190ea8f20f8SJuan Quintela    bigendian=yes
1191ea8f20f8SJuan Quintela  ;;
1192ea8f20f8SJuan Quintelaesac
11937d13299dSbellard
11947d13299dSbellardfi
11957d13299dSbellard
119670be1a2eSPaolo Bonzini# host long bits test, actually a pointer size test
119770be1a2eSPaolo Bonzinicat > $TMPC << EOF
119870be1a2eSPaolo Bonziniint sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
119970be1a2eSPaolo BonziniEOF
120070be1a2eSPaolo Bonziniif compile_object; then
1201ea8f20f8SJuan Quintelahostlongbits=64
120270be1a2eSPaolo Bonzinielse
120370be1a2eSPaolo Bonzinihostlongbits=32
120470be1a2eSPaolo Bonzinifi
1205b6853697Sbellard
1206b0a47e79SJuan Quintela
1207b0a47e79SJuan Quintela##########################################
1208b0a47e79SJuan Quintela# NPTL probe
1209b0a47e79SJuan Quintela
1210b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1211bd0c5661Spbrook  cat > $TMPC <<EOF
1212bd0c5661Spbrook#include <sched.h>
121330813ceaSpbrook#include <linux/futex.h>
1214bd0c5661Spbrookvoid foo()
1215bd0c5661Spbrook{
1216bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1217bd0c5661Spbrook#error bork
1218bd0c5661Spbrook#endif
1219bd0c5661Spbrook}
1220bd0c5661SpbrookEOF
1221bd0c5661Spbrook
122252166aa0SJuan Quintela  if compile_object ; then
1223b0a47e79SJuan Quintela    nptl=yes
1224bd0c5661Spbrook  else
1225b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1226b0a47e79SJuan Quintela      feature_not_found "nptl"
1227b0a47e79SJuan Quintela    fi
1228b0a47e79SJuan Quintela    nptl=no
1229b0a47e79SJuan Quintela  fi
1230bd0c5661Spbrookfi
1231bd0c5661Spbrook
123211d9f695Sbellard##########################################
1233ac62922eSbalrog# zlib check
1234ac62922eSbalrog
12351ece9905SAlon Levyif test "$zlib" != "no" ; then
1236ac62922eSbalrog    cat > $TMPC << EOF
1237ac62922eSbalrog#include <zlib.h>
1238ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1239ac62922eSbalrogEOF
124052166aa0SJuan Quintela    if compile_prog "" "-lz" ; then
1241ac62922eSbalrog        :
1242ac62922eSbalrog    else
1243ac62922eSbalrog        echo
1244ac62922eSbalrog        echo "Error: zlib check failed"
1245ac62922eSbalrog        echo "Make sure to have the zlib libs and headers installed."
1246ac62922eSbalrog        echo
1247ac62922eSbalrog        exit 1
1248ac62922eSbalrog    fi
12491ece9905SAlon Levyfi
1250ac62922eSbalrog
1251ac62922eSbalrog##########################################
1252e37630caSaliguori# xen probe
1253e37630caSaliguori
1254fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1255b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1256d5b93ddfSAnthony PERARD
1257d5b93ddfSAnthony PERARD  # Xen unstable
1258e37630caSaliguori  cat > $TMPC <<EOF
1259e37630caSaliguori#include <xenctrl.h>
1260e37630caSaliguori#include <xs.h>
1261d5b93ddfSAnthony PERARD#include <stdint.h>
1262d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1263d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1264d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1265d5b93ddfSAnthony PERARD#endif
1266d5b93ddfSAnthony PERARDint main(void) {
1267d5b93ddfSAnthony PERARD  xc_interface *xc;
1268d5b93ddfSAnthony PERARD  xs_daemon_open();
1269d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1270d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1271d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1272b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1273d5b93ddfSAnthony PERARD  return 0;
1274d5b93ddfSAnthony PERARD}
1275e37630caSaliguoriEOF
127652166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1277d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1278fc321b4bSJuan Quintela    xen=yes
1279d5b93ddfSAnthony PERARD
1280d5b93ddfSAnthony PERARD  # Xen 4.0.0
1281d5b93ddfSAnthony PERARD  elif (
1282d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1283d5b93ddfSAnthony PERARD#include <xenctrl.h>
1284d5b93ddfSAnthony PERARD#include <xs.h>
1285d5b93ddfSAnthony PERARD#include <stdint.h>
1286d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1287d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1288d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1289d5b93ddfSAnthony PERARD#endif
1290d5b93ddfSAnthony PERARDint main(void) {
1291b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1292b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1293b87de24eSAnthony PERARD  };
1294d5b93ddfSAnthony PERARD  xs_daemon_open();
1295d5b93ddfSAnthony PERARD  xc_interface_open();
1296d5b93ddfSAnthony PERARD  xc_gnttab_open();
1297d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1298b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1299d5b93ddfSAnthony PERARD  return 0;
1300d5b93ddfSAnthony PERARD}
1301d5b93ddfSAnthony PERARDEOF
1302d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1303d5b93ddfSAnthony PERARD    ) ; then
1304d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1305d5b93ddfSAnthony PERARD    xen=yes
1306d5b93ddfSAnthony PERARD
1307b87de24eSAnthony PERARD  # Xen 3.4.0
1308b87de24eSAnthony PERARD  elif (
1309b87de24eSAnthony PERARD      cat > $TMPC <<EOF
1310b87de24eSAnthony PERARD#include <xenctrl.h>
1311b87de24eSAnthony PERARD#include <xs.h>
1312b87de24eSAnthony PERARDint main(void) {
1313b87de24eSAnthony PERARD  struct xen_add_to_physmap xatp = {
1314b87de24eSAnthony PERARD    .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1315b87de24eSAnthony PERARD  };
1316b87de24eSAnthony PERARD  xs_daemon_open();
1317b87de24eSAnthony PERARD  xc_interface_open();
1318b87de24eSAnthony PERARD  xc_gnttab_open();
1319b87de24eSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1320b87de24eSAnthony PERARD  xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1321b87de24eSAnthony PERARD  return 0;
1322b87de24eSAnthony PERARD}
1323b87de24eSAnthony PERARDEOF
1324b87de24eSAnthony PERARD      compile_prog "" "$xen_libs"
1325b87de24eSAnthony PERARD    ) ; then
1326b87de24eSAnthony PERARD    xen_ctrl_version=340
1327b87de24eSAnthony PERARD    xen=yes
1328b87de24eSAnthony PERARD
1329b87de24eSAnthony PERARD  # Xen 3.3.0
1330d5b93ddfSAnthony PERARD  elif (
1331d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1332d5b93ddfSAnthony PERARD#include <xenctrl.h>
1333d5b93ddfSAnthony PERARD#include <xs.h>
1334d5b93ddfSAnthony PERARDint main(void) {
1335d5b93ddfSAnthony PERARD  xs_daemon_open();
1336d5b93ddfSAnthony PERARD  xc_interface_open();
1337d5b93ddfSAnthony PERARD  xc_gnttab_open();
1338d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1339d5b93ddfSAnthony PERARD  return 0;
1340d5b93ddfSAnthony PERARD}
1341d5b93ddfSAnthony PERARDEOF
1342d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1343d5b93ddfSAnthony PERARD    ) ; then
1344d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1345d5b93ddfSAnthony PERARD    xen=yes
1346d5b93ddfSAnthony PERARD
1347d5b93ddfSAnthony PERARD  # Xen not found or unsupported
1348e37630caSaliguori  else
1349fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1350fc321b4bSJuan Quintela      feature_not_found "xen"
1351fc321b4bSJuan Quintela    fi
1352fc321b4bSJuan Quintela    xen=no
1353e37630caSaliguori  fi
1354d5b93ddfSAnthony PERARD
1355d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1356d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1357d5b93ddfSAnthony PERARD  fi
1358e37630caSaliguorifi
1359e37630caSaliguori
1360e37630caSaliguori##########################################
1361a8bd70adSPaolo Bonzini# pkg-config probe
1362f91672e5SPaolo Bonzini
1363a8bd70adSPaolo Bonziniif ! has $pkg_config; then
1364a213fcb2SPeter Maydell  echo "Error: pkg-config binary '$pkg_config' not found"
1365a213fcb2SPeter Maydell  exit 1
1366f91672e5SPaolo Bonzinifi
1367f91672e5SPaolo Bonzini
1368f91672e5SPaolo Bonzini##########################################
136944dc0ca3SAlon Levy# libtool probe
137044dc0ca3SAlon Levy
13713f534581SBradif ! has $libtool; then
137244dc0ca3SAlon Levy    libtool=
137344dc0ca3SAlon Levyfi
137444dc0ca3SAlon Levy
137544dc0ca3SAlon Levy##########################################
1376dfffc653SJuan Quintela# Sparse probe
1377dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
13780dba6195SLoïc Minier  if has cgcc; then
1379dfffc653SJuan Quintela    sparse=yes
1380dfffc653SJuan Quintela  else
1381dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1382dfffc653SJuan Quintela      feature_not_found "sparse"
1383dfffc653SJuan Quintela    fi
1384dfffc653SJuan Quintela    sparse=no
1385dfffc653SJuan Quintela  fi
1386dfffc653SJuan Quintelafi
1387dfffc653SJuan Quintela
1388dfffc653SJuan Quintela##########################################
138911d9f695Sbellard# SDL probe
139011d9f695Sbellard
13913ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
13923ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
13933ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
13943ec87ffeSPaolo Bonzini  sdl_config=sdl-config
13953ec87ffeSPaolo Bonzinifi
13963ec87ffeSPaolo Bonzini
13973ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1398a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1399fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
14003ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
14013ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
14029316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1403a0dfd8a4SLoïc Minierelse
1404a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1405a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1406a0dfd8a4SLoïc Minier  fi
1407a0dfd8a4SLoïc Minier  sdl=no
14089316f803SPaolo Bonzinifi
140929e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
14103ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
14113ec87ffeSPaolo Bonzinifi
141211d9f695Sbellard
14139316f803SPaolo Bonzinisdl_too_old=no
1414c4198157SJuan Quintelaif test "$sdl" != "no" ; then
141511d9f695Sbellard  cat > $TMPC << EOF
141611d9f695Sbellard#include <SDL.h>
141711d9f695Sbellard#undef main /* We don't want SDL to override our main() */
141811d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
141911d9f695SbellardEOF
14209316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
142174f42e18STeLeMan  if test "$static" = "yes" ; then
142274f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
142374f42e18STeLeMan  else
14249316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
142574f42e18STeLeMan  fi
142652166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
142711d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
142811d9f695Sbellard      sdl_too_old=yes
142911d9f695Sbellard    else
1430fd677642Sths      if test "$cocoa" = "no" ; then
143111d9f695Sbellard        sdl=yes
143211d9f695Sbellard      fi
1433fd677642Sths    fi
14347c1f25b4Sbellard
143567c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
14361ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
143767c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1438f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1439f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
144011d9f695Sbellard      fi
144152166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
14421ac88f28SJuan Quintela	:
14431ac88f28SJuan Quintela      else
14441ac88f28SJuan Quintela        sdl=no
14457c1f25b4Sbellard      fi
14467c1f25b4Sbellard    fi # static link
1447c4198157SJuan Quintela  else # sdl not found
1448c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1449c4198157SJuan Quintela      feature_not_found "sdl"
1450c4198157SJuan Quintela    fi
1451c4198157SJuan Quintela    sdl=no
14527c1f25b4Sbellard  fi # sdl compile test
1453fd677642Sthsfi
145411d9f695Sbellard
14555368a422Saliguoriif test "$sdl" = "yes" ; then
14565368a422Saliguori  cat > $TMPC <<EOF
14575368a422Saliguori#include <SDL.h>
14585368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
14595368a422Saliguori#include <X11/XKBlib.h>
14605368a422Saliguori#else
14615368a422Saliguori#error No x11 support
14625368a422Saliguori#endif
14635368a422Saliguoriint main(void) { return 0; }
14645368a422SaliguoriEOF
146552166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1466681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
14675368a422Saliguori  fi
146807d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
146907d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
147007d9ac44SJuan Quintela  fi
14710705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
14725368a422Saliguorifi
14735368a422Saliguori
14748f28f3fbSths##########################################
14758d5d2d4cSths# VNC TLS detection
1476821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1477ae6b5e5aSaliguori  cat > $TMPC <<EOF
1478ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1479ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1480ae6b5e5aSaliguoriEOF
1481a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1482a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
148352166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
14841be10ad2SJuan Quintela    vnc_tls=yes
1485a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1486ae6b5e5aSaliguori  else
14871be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
14881be10ad2SJuan Quintela      feature_not_found "vnc-tls"
14891be10ad2SJuan Quintela    fi
14901be10ad2SJuan Quintela    vnc_tls=no
14918d5d2d4cSths  fi
14928d5d2d4cSthsfi
14938d5d2d4cSths
14948d5d2d4cSths##########################################
14952f9606b3Saliguori# VNC SASL detection
1496821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
14972f9606b3Saliguori  cat > $TMPC <<EOF
14982f9606b3Saliguori#include <sasl/sasl.h>
14992f9606b3Saliguori#include <stdio.h>
15002f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
15012f9606b3SaliguoriEOF
15022f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
15032f9606b3Saliguori  vnc_sasl_cflags=""
15042f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
150552166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1506ea784e3bSJuan Quintela    vnc_sasl=yes
1507fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
15082f9606b3Saliguori  else
1509ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1510ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1511ea784e3bSJuan Quintela    fi
1512ea784e3bSJuan Quintela    vnc_sasl=no
15132f9606b3Saliguori  fi
15142f9606b3Saliguorifi
15152f9606b3Saliguori
15162f9606b3Saliguori##########################################
15172f6f5c7aSCorentin Chary# VNC JPEG detection
1518821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
15192f6f5c7aSCorentin Charycat > $TMPC <<EOF
15202f6f5c7aSCorentin Chary#include <stdio.h>
15212f6f5c7aSCorentin Chary#include <jpeglib.h>
15222f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
15232f6f5c7aSCorentin CharyEOF
15242f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
15252f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
15262f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
15272f6f5c7aSCorentin Chary    vnc_jpeg=yes
15282f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
15292f6f5c7aSCorentin Chary  else
15302f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
15312f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
15322f6f5c7aSCorentin Chary    fi
15332f6f5c7aSCorentin Chary    vnc_jpeg=no
15342f6f5c7aSCorentin Chary  fi
15352f6f5c7aSCorentin Charyfi
15362f6f5c7aSCorentin Chary
15372f6f5c7aSCorentin Chary##########################################
1538efe556adSCorentin Chary# VNC PNG detection
1539821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1540efe556adSCorentin Charycat > $TMPC <<EOF
1541efe556adSCorentin Chary//#include <stdio.h>
1542efe556adSCorentin Chary#include <png.h>
1543832ce9c2SScott Wood#include <stddef.h>
1544efe556adSCorentin Charyint main(void) {
1545efe556adSCorentin Chary    png_structp png_ptr;
1546efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1547efe556adSCorentin Chary    return 0;
1548efe556adSCorentin Chary}
1549efe556adSCorentin CharyEOF
15509af8025eSBrad  if $pkg_config libpng --modversion >/dev/null 2>&1; then
15519af8025eSBrad    vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
15529af8025eSBrad    vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
15539af8025eSBrad  else
1554efe556adSCorentin Chary    vnc_png_cflags=""
1555efe556adSCorentin Chary    vnc_png_libs="-lpng"
15569af8025eSBrad  fi
1557efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1558efe556adSCorentin Chary    vnc_png=yes
1559efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
15609af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1561efe556adSCorentin Chary  else
1562efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1563efe556adSCorentin Chary      feature_not_found "vnc-png"
1564efe556adSCorentin Chary    fi
1565efe556adSCorentin Chary    vnc_png=no
1566efe556adSCorentin Chary  fi
1567efe556adSCorentin Charyfi
1568efe556adSCorentin Chary
1569efe556adSCorentin Chary##########################################
157076655d6dSaliguori# fnmatch() probe, used for ACL routines
157176655d6dSaliguorifnmatch="no"
157276655d6dSaliguoricat > $TMPC << EOF
157376655d6dSaliguori#include <fnmatch.h>
157476655d6dSaliguoriint main(void)
157576655d6dSaliguori{
157676655d6dSaliguori    fnmatch("foo", "foo", 0);
157776655d6dSaliguori    return 0;
157876655d6dSaliguori}
157976655d6dSaliguoriEOF
158052166aa0SJuan Quintelaif compile_prog "" "" ; then
158176655d6dSaliguori   fnmatch="yes"
158276655d6dSaliguorifi
158376655d6dSaliguori
158476655d6dSaliguori##########################################
1585ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1586ee682d27SStefan Weilif test "$uuid" != "no" ; then
1587ee682d27SStefan Weil  uuid_libs="-luuid"
1588ee682d27SStefan Weil  cat > $TMPC << EOF
1589ee682d27SStefan Weil#include <uuid/uuid.h>
1590ee682d27SStefan Weilint main(void)
1591ee682d27SStefan Weil{
1592ee682d27SStefan Weil    uuid_t my_uuid;
1593ee682d27SStefan Weil    uuid_generate(my_uuid);
1594ee682d27SStefan Weil    return 0;
1595ee682d27SStefan Weil}
1596ee682d27SStefan WeilEOF
1597ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1598ee682d27SStefan Weil    uuid="yes"
1599ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1600ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1601ee682d27SStefan Weil  else
1602ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1603ee682d27SStefan Weil      feature_not_found "uuid"
1604ee682d27SStefan Weil    fi
1605ee682d27SStefan Weil    uuid=no
1606ee682d27SStefan Weil  fi
1607ee682d27SStefan Weilfi
1608ee682d27SStefan Weil
1609ee682d27SStefan Weil##########################################
1610dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1611dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1612dce512deSChristoph Hellwig  cat > $TMPC << EOF
1613dce512deSChristoph Hellwig#include <xfs/xfs.h>
1614dce512deSChristoph Hellwigint main(void)
1615dce512deSChristoph Hellwig{
1616dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1617dce512deSChristoph Hellwig    return 0;
1618dce512deSChristoph Hellwig}
1619dce512deSChristoph HellwigEOF
1620dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1621dce512deSChristoph Hellwig    xfs="yes"
1622dce512deSChristoph Hellwig  else
1623dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1624dce512deSChristoph Hellwig      feature_not_found "xfs"
1625dce512deSChristoph Hellwig    fi
1626dce512deSChristoph Hellwig    xfs=no
1627dce512deSChristoph Hellwig  fi
1628dce512deSChristoph Hellwigfi
1629dce512deSChristoph Hellwig
1630dce512deSChristoph Hellwig##########################################
16318a16d273Sths# vde libraries probe
1632dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
16334baae0acSJuan Quintela  vde_libs="-lvdeplug"
16348a16d273Sths  cat > $TMPC << EOF
16358a16d273Sths#include <libvdeplug.h>
16364a7f0e06Spbrookint main(void)
16374a7f0e06Spbrook{
16384a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
16394a7f0e06Spbrook    vde_open("", "", &a);
16404a7f0e06Spbrook    return 0;
16414a7f0e06Spbrook}
16428a16d273SthsEOF
164352166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
16444baae0acSJuan Quintela    vde=yes
16458e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
16468e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1647dfb278bdSJuan Quintela  else
1648dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1649dfb278bdSJuan Quintela      feature_not_found "vde"
1650dfb278bdSJuan Quintela    fi
1651dfb278bdSJuan Quintela    vde=no
16528a16d273Sths  fi
16538a16d273Sthsfi
16548a16d273Sths
16558a16d273Sths##########################################
1656c2de5c91Smalc# Sound support libraries probe
16578f28f3fbSths
1658c2de5c91Smalcaudio_drv_probe()
1659c2de5c91Smalc{
1660c2de5c91Smalc    drv=$1
1661c2de5c91Smalc    hdr=$2
1662c2de5c91Smalc    lib=$3
1663c2de5c91Smalc    exp=$4
1664c2de5c91Smalc    cfl=$5
16658f28f3fbSths        cat > $TMPC << EOF
1666c2de5c91Smalc#include <$hdr>
1667c2de5c91Smalcint main(void) { $exp }
16688f28f3fbSthsEOF
166952166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
16708f28f3fbSths        :
16718f28f3fbSths    else
16728f28f3fbSths        echo
1673c2de5c91Smalc        echo "Error: $drv check failed"
1674c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
16758f28f3fbSths        echo
16768f28f3fbSths        exit 1
16778f28f3fbSths    fi
1678c2de5c91Smalc}
1679c2de5c91Smalc
16802fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1681c2de5c91Smalcfor drv in $audio_drv_list; do
1682c2de5c91Smalc    case $drv in
1683c2de5c91Smalc    alsa)
1684c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1685c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1686a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1687c2de5c91Smalc    ;;
1688c2de5c91Smalc
1689c2de5c91Smalc    fmod)
1690c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1691c2de5c91Smalc        echo
1692c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1693c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1694c2de5c91Smalc        echo
1695c2de5c91Smalc        exit 1
16968f28f3fbSths    fi
1697c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1698a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1699c2de5c91Smalc    ;;
1700c2de5c91Smalc
1701c2de5c91Smalc    esd)
1702c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1703a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
170467f86e8eSJuan Quintela    audio_pt_int="yes"
1705c2de5c91Smalc    ;;
1706b8e59f18Smalc
1707b8e59f18Smalc    pa)
1708493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
170920fa53ecSMarc-Antoine Perennou        "pa_simple *s = 0; pa_simple_free(s); return 0;"
1710493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
171167f86e8eSJuan Quintela    audio_pt_int="yes"
1712b8e59f18Smalc    ;;
1713b8e59f18Smalc
1714997e690aSJuan Quintela    coreaudio)
1715997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1716997e690aSJuan Quintela    ;;
1717997e690aSJuan Quintela
1718a4bf6780SJuan Quintela    dsound)
1719a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1720d5631638Smalc      audio_win_int="yes"
1721a4bf6780SJuan Quintela    ;;
1722a4bf6780SJuan Quintela
1723a4bf6780SJuan Quintela    oss)
1724a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1725a4bf6780SJuan Quintela    ;;
1726a4bf6780SJuan Quintela
1727a4bf6780SJuan Quintela    sdl|wav)
17282f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
17292f6a1ab0Sblueswir1    ;;
17302f6a1ab0Sblueswir1
1731d5631638Smalc    winwave)
1732d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1733d5631638Smalc      audio_win_int="yes"
1734d5631638Smalc    ;;
1735d5631638Smalc
1736e4c63a6aSmalc    *)
17371c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1738e4c63a6aSmalc        echo
1739e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1740e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1741e4c63a6aSmalc        echo
1742e4c63a6aSmalc        exit 1
1743e4c63a6aSmalc    }
1744e4c63a6aSmalc    ;;
1745c2de5c91Smalc    esac
1746c2de5c91Smalcdone
17478f28f3fbSths
17484d3b6f6eSbalrog##########################################
17492e4d9fb1Saurel32# BrlAPI probe
17502e4d9fb1Saurel32
17514ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1752eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
17532e4d9fb1Saurel32  cat > $TMPC << EOF
17542e4d9fb1Saurel32#include <brlapi.h>
1755832ce9c2SScott Wood#include <stddef.h>
17562e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
17572e4d9fb1Saurel32EOF
175852166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
17592e4d9fb1Saurel32    brlapi=yes
1760264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
17614ffcedb6SJuan Quintela  else
17624ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
17634ffcedb6SJuan Quintela      feature_not_found "brlapi"
17644ffcedb6SJuan Quintela    fi
17654ffcedb6SJuan Quintela    brlapi=no
1766eb82284fSJuan Quintela  fi
1767eb82284fSJuan Quintelafi
17682e4d9fb1Saurel32
17692e4d9fb1Saurel32##########################################
17704d3b6f6eSbalrog# curses probe
1771e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
1772e095e2f3SStefan Weil    curses_list="-lpdcurses"
1773e095e2f3SStefan Weilelse
17744f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
1775e095e2f3SStefan Weilfi
17764d3b6f6eSbalrog
1777c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1778c584a6d0SJuan Quintela  curses_found=no
17794d3b6f6eSbalrog  cat > $TMPC << EOF
17804d3b6f6eSbalrog#include <curses.h>
17815a8ff3aaSblueswir1#ifdef __OpenBSD__
17825a8ff3aaSblueswir1#define resize_term resizeterm
17835a8ff3aaSblueswir1#endif
17845a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
17854d3b6f6eSbalrogEOF
17864f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
17874f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1788c584a6d0SJuan Quintela      curses_found=yes
17894f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
17904f78ef9aSJuan Quintela      break
17914d3b6f6eSbalrog    fi
17924f78ef9aSJuan Quintela  done
1793c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1794c584a6d0SJuan Quintela    curses=yes
1795c584a6d0SJuan Quintela  else
1796c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1797c584a6d0SJuan Quintela      feature_not_found "curses"
1798c584a6d0SJuan Quintela    fi
1799c584a6d0SJuan Quintela    curses=no
1800c584a6d0SJuan Quintela  fi
18014f78ef9aSJuan Quintelafi
18024d3b6f6eSbalrog
1803414f0dabSblueswir1##########################################
1804769ce76dSAlexander Graf# curl probe
1805769ce76dSAlexander Graf
1806a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
1807a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
18084e2b0658SPaolo Bonzinielse
18094e2b0658SPaolo Bonzini  curlconfig=curl-config
18104e2b0658SPaolo Bonzinifi
18114e2b0658SPaolo Bonzini
1812788c8196SJuan Quintelaif test "$curl" != "no" ; then
1813769ce76dSAlexander Graf  cat > $TMPC << EOF
1814769ce76dSAlexander Graf#include <curl/curl.h>
18150b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
1816769ce76dSAlexander GrafEOF
18174e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
18184e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1819b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1820769ce76dSAlexander Graf    curl=yes
1821f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1822f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1823788c8196SJuan Quintela  else
1824788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1825788c8196SJuan Quintela      feature_not_found "curl"
1826788c8196SJuan Quintela    fi
1827788c8196SJuan Quintela    curl=no
1828769ce76dSAlexander Graf  fi
1829769ce76dSAlexander Graffi # test "$curl"
1830769ce76dSAlexander Graf
1831769ce76dSAlexander Graf##########################################
18325495ed11SLuiz Capitulino# check framework probe
18335495ed11SLuiz Capitulino
18345495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
18355495ed11SLuiz Capitulino  cat > $TMPC << EOF
18365495ed11SLuiz Capitulino#include <check.h>
18375495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
18385495ed11SLuiz CapitulinoEOF
1839f809c0d6SPeter Maydell  check_libs=`$pkg_config --libs check 2>/dev/null`
18405495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
18415495ed11SLuiz Capitulino    check_utests=yes
18425495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
18435495ed11SLuiz Capitulino  else
18445495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
18455495ed11SLuiz Capitulino      feature_not_found "check"
18465495ed11SLuiz Capitulino    fi
18475495ed11SLuiz Capitulino    check_utests=no
18485495ed11SLuiz Capitulino  fi
18495495ed11SLuiz Capitulinofi # test "$check_utests"
18505495ed11SLuiz Capitulino
18515495ed11SLuiz Capitulino##########################################
1852fb599c9aSbalrog# bluez support probe
1853a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1854e820e3f4Sbalrog  cat > $TMPC << EOF
1855e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1856e820e3f4Sbalrogint main(void) { return bt_error(0); }
1857e820e3f4SbalrogEOF
1858a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1859a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
186052166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1861a20a6f46SJuan Quintela    bluez=yes
1862e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1863e820e3f4Sbalrog  else
1864a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1865a20a6f46SJuan Quintela      feature_not_found "bluez"
1866a20a6f46SJuan Quintela    fi
1867e820e3f4Sbalrog    bluez="no"
1868e820e3f4Sbalrog  fi
1869fb599c9aSbalrogfi
1870fb599c9aSbalrog
1871fb599c9aSbalrog##########################################
1872e18df141SAnthony Liguori# glib support probe
18734b76a481SStefan Hajnocziif $pkg_config --modversion gthread-2.0 > /dev/null 2>&1 ; then
18744b76a481SStefan Hajnoczi    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
18754b76a481SStefan Hajnoczi    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
187614015304SAnthony Liguori    LIBS="$glib_libs $LIBS"
1877957f1f99SMichael Roth    libs_qga="$glib_libs $libs_qga"
1878e18df141SAnthony Liguorielse
1879e18df141SAnthony Liguori    echo "glib-2.0 required to compile QEMU"
1880e18df141SAnthony Liguori    exit 1
1881e18df141SAnthony Liguorifi
1882e18df141SAnthony Liguori
1883e18df141SAnthony Liguori##########################################
1884e5d355d1Saliguori# pthread probe
18854b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
18863c529d93Saliguori
1887e5d355d1Saliguoripthread=no
1888414f0dabSblueswir1cat > $TMPC << EOF
18893c529d93Saliguori#include <pthread.h>
1890de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1891414f0dabSblueswir1EOF
1892bd00d539SAndreas Färberif compile_prog "" "" ; then
1893bd00d539SAndreas Färber  pthread=yes
1894bd00d539SAndreas Färberelse
1895de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
189652166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
1897e5d355d1Saliguori      pthread=yes
18985572b539SJuan Quintela      LIBS="$pthread_lib $LIBS"
1899de65fe0fSSebastian Herbszt      break
1900414f0dabSblueswir1    fi
1901de65fe0fSSebastian Herbszt  done
1902bd00d539SAndreas Färberfi
1903414f0dabSblueswir1
19044617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
19054dd75c70SChristoph Hellwig  echo
19064dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
19074dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
19084dd75c70SChristoph Hellwig  echo
19094dd75c70SChristoph Hellwig  exit 1
1910e5d355d1Saliguorifi
1911e5d355d1Saliguori
1912bf9298b9Saliguori##########################################
1913f27aaf4bSChristian Brunner# rbd probe
1914f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
1915f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
1916f27aaf4bSChristian Brunner#include <stdio.h>
1917ad32e9c0SJosh Durgin#include <rbd/librbd.h>
1918f27aaf4bSChristian Brunnerint main(void) {
1919ad32e9c0SJosh Durgin    rados_t cluster;
1920ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
1921f27aaf4bSChristian Brunner    return 0;
1922f27aaf4bSChristian Brunner}
1923f27aaf4bSChristian BrunnerEOF
1924ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
1925f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
1926f27aaf4bSChristian Brunner    rbd=yes
1927f27aaf4bSChristian Brunner    libs_tools="$rbd_libs $libs_tools"
1928f27aaf4bSChristian Brunner    libs_softmmu="$rbd_libs $libs_softmmu"
1929f27aaf4bSChristian Brunner  else
1930f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
1931f27aaf4bSChristian Brunner      feature_not_found "rados block device"
1932f27aaf4bSChristian Brunner    fi
1933f27aaf4bSChristian Brunner    rbd=no
1934f27aaf4bSChristian Brunner  fi
1935f27aaf4bSChristian Brunnerfi
1936f27aaf4bSChristian Brunner
1937f27aaf4bSChristian Brunner##########################################
19385c6c3a6cSChristoph Hellwig# linux-aio probe
19395c6c3a6cSChristoph Hellwig
19405c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
19415c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
19425c6c3a6cSChristoph Hellwig#include <libaio.h>
19435c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
1944832ce9c2SScott Wood#include <stddef.h>
19455c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
19465c6c3a6cSChristoph HellwigEOF
19475c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
19485c6c3a6cSChristoph Hellwig    linux_aio=yes
1949048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1950048d179fSPaul Brook    libs_tools="$libs_tools -laio"
19515c6c3a6cSChristoph Hellwig  else
19525c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
19535c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
19545c6c3a6cSChristoph Hellwig    fi
19553cfcae3cSLuiz Capitulino    linux_aio=no
19565c6c3a6cSChristoph Hellwig  fi
19575c6c3a6cSChristoph Hellwigfi
19585c6c3a6cSChristoph Hellwig
19595c6c3a6cSChristoph Hellwig##########################################
1960758e8e38SVenkateswararao Jujjuri (JV)# attr probe
1961758e8e38SVenkateswararao Jujjuri (JV)
1962758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
1963758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
1964758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
1965758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
19664f26f2b6SAvi Kivity#include <sys/xattr.h>
1967758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1968758e8e38SVenkateswararao Jujjuri (JV)EOF
19694f26f2b6SAvi Kivity  if compile_prog "" "" ; then
19704f26f2b6SAvi Kivity    attr=yes
19714f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
19724f26f2b6SAvi Kivity  elif sed -i s,sys/xattr,attr/xattr, $TMPC && compile_prog "" "-lattr" ; then
1973758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
1974758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
19754f26f2b6SAvi Kivity    libattr=yes
1976758e8e38SVenkateswararao Jujjuri (JV)  else
1977758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
1978758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
1979758e8e38SVenkateswararao Jujjuri (JV)    fi
1980758e8e38SVenkateswararao Jujjuri (JV)    attr=no
1981758e8e38SVenkateswararao Jujjuri (JV)  fi
1982758e8e38SVenkateswararao Jujjuri (JV)fi
1983758e8e38SVenkateswararao Jujjuri (JV)
1984758e8e38SVenkateswararao Jujjuri (JV)##########################################
1985bf9298b9Saliguori# iovec probe
1986bf9298b9Saliguoricat > $TMPC <<EOF
1987db34f0b3Sblueswir1#include <sys/types.h>
1988bf9298b9Saliguori#include <sys/uio.h>
1989db34f0b3Sblueswir1#include <unistd.h>
1990bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1991bf9298b9SaliguoriEOF
1992bf9298b9Saliguoriiovec=no
199352166aa0SJuan Quintelaif compile_prog "" "" ; then
1994bf9298b9Saliguori  iovec=yes
1995bf9298b9Saliguorifi
1996bf9298b9Saliguori
1997f652e6afSaurel32##########################################
1998ceb42de8Saliguori# preadv probe
1999ceb42de8Saliguoricat > $TMPC <<EOF
2000ceb42de8Saliguori#include <sys/types.h>
2001ceb42de8Saliguori#include <sys/uio.h>
2002ceb42de8Saliguori#include <unistd.h>
2003ceb42de8Saliguoriint main(void) { preadv; }
2004ceb42de8SaliguoriEOF
2005ceb42de8Saliguoripreadv=no
200652166aa0SJuan Quintelaif compile_prog "" "" ; then
2007ceb42de8Saliguori  preadv=yes
2008ceb42de8Saliguorifi
2009ceb42de8Saliguori
2010ceb42de8Saliguori##########################################
2011f652e6afSaurel32# fdt probe
20122df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2013b41af4baSJuan Quintela  fdt_libs="-lfdt"
2014f652e6afSaurel32  cat > $TMPC << EOF
2015f652e6afSaurel32int main(void) { return 0; }
2016f652e6afSaurel32EOF
201752166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2018f652e6afSaurel32    fdt=yes
20192df87df7SJuan Quintela  else
20202df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
20212df87df7SJuan Quintela      feature_not_found "fdt"
20222df87df7SJuan Quintela    fi
2023de3a354aSMichael Walle    fdt_libs=
20242df87df7SJuan Quintela    fdt=no
2025f652e6afSaurel32  fi
2026f652e6afSaurel32fi
2027f652e6afSaurel32
202820ff075bSMichael Walle##########################################
202920ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
203020ff075bSMichael Walleif test "$opengl" != "no" ; then
203120ff075bSMichael Walle  opengl_libs="-lGL"
203220ff075bSMichael Walle  cat > $TMPC << EOF
203320ff075bSMichael Walle#include <X11/Xlib.h>
203420ff075bSMichael Walle#include <GL/gl.h>
203520ff075bSMichael Walle#include <GL/glx.h>
203620ff075bSMichael Walleint main(void) { GL_VERSION; return 0; }
203720ff075bSMichael WalleEOF
203820ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
203920ff075bSMichael Walle    opengl=yes
204020ff075bSMichael Walle  else
204120ff075bSMichael Walle    if test "$opengl" = "yes" ; then
204220ff075bSMichael Walle      feature_not_found "opengl"
204320ff075bSMichael Walle    fi
2044de3a354aSMichael Walle    opengl_libs=
204520ff075bSMichael Walle    opengl=no
204620ff075bSMichael Walle  fi
204720ff075bSMichael Wallefi
204820ff075bSMichael Walle
20493b3f24adSaurel32#
20503b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
20513b3f24adSaurel32# emulator.  This is done because older glibc versions don't
20523b3f24adSaurel32# have syscall stubs for these implemented.
20533b3f24adSaurel32#
20543b3f24adSaurel32atfile=no
20553b3f24adSaurel32cat > $TMPC << EOF
20563b3f24adSaurel32#define _ATFILE_SOURCE
20573b3f24adSaurel32#include <sys/types.h>
20583b3f24adSaurel32#include <fcntl.h>
20593b3f24adSaurel32#include <unistd.h>
20603b3f24adSaurel32
20613b3f24adSaurel32int
20623b3f24adSaurel32main(void)
20633b3f24adSaurel32{
20643b3f24adSaurel32	/* try to unlink nonexisting file */
20653b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
20663b3f24adSaurel32}
20673b3f24adSaurel32EOF
206852166aa0SJuan Quintelaif compile_prog "" "" ; then
20693b3f24adSaurel32  atfile=yes
20703b3f24adSaurel32fi
20713b3f24adSaurel32
207239386ac7Saurel32# Check for inotify functions when we are building linux-user
20733b3f24adSaurel32# emulator.  This is done because older glibc versions don't
20743b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
20753b3f24adSaurel32# don't provide them even if kernel supports them.
20763b3f24adSaurel32#
20773b3f24adSaurel32inotify=no
20783b3f24adSaurel32cat > $TMPC << EOF
20793b3f24adSaurel32#include <sys/inotify.h>
20803b3f24adSaurel32
20813b3f24adSaurel32int
20823b3f24adSaurel32main(void)
20833b3f24adSaurel32{
20843b3f24adSaurel32	/* try to start inotify */
20858690e420Saurel32	return inotify_init();
20863b3f24adSaurel32}
20873b3f24adSaurel32EOF
208852166aa0SJuan Quintelaif compile_prog "" "" ; then
20893b3f24adSaurel32  inotify=yes
20903b3f24adSaurel32fi
20913b3f24adSaurel32
2092c05c7a73SRiku Voipioinotify1=no
2093c05c7a73SRiku Voipiocat > $TMPC << EOF
2094c05c7a73SRiku Voipio#include <sys/inotify.h>
2095c05c7a73SRiku Voipio
2096c05c7a73SRiku Voipioint
2097c05c7a73SRiku Voipiomain(void)
2098c05c7a73SRiku Voipio{
2099c05c7a73SRiku Voipio    /* try to start inotify */
2100c05c7a73SRiku Voipio    return inotify_init1(0);
2101c05c7a73SRiku Voipio}
2102c05c7a73SRiku VoipioEOF
2103c05c7a73SRiku Voipioif compile_prog "" "" ; then
2104c05c7a73SRiku Voipio  inotify1=yes
2105c05c7a73SRiku Voipiofi
2106c05c7a73SRiku Voipio
2107ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2108ebc996f3SRiku Voipioutimens=no
2109ebc996f3SRiku Voipiocat > $TMPC << EOF
2110ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2111ebc996f3SRiku Voipio#include <stddef.h>
2112ebc996f3SRiku Voipio#include <fcntl.h>
2113ebc996f3SRiku Voipio
2114ebc996f3SRiku Voipioint main(void)
2115ebc996f3SRiku Voipio{
2116ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2117ebc996f3SRiku Voipio    futimens(0, NULL);
2118ebc996f3SRiku Voipio    return 0;
2119ebc996f3SRiku Voipio}
2120ebc996f3SRiku VoipioEOF
212152166aa0SJuan Quintelaif compile_prog "" "" ; then
2122ebc996f3SRiku Voipio  utimens=yes
2123ebc996f3SRiku Voipiofi
2124ebc996f3SRiku Voipio
2125099d6b0fSRiku Voipio# check if pipe2 is there
2126099d6b0fSRiku Voipiopipe2=no
2127099d6b0fSRiku Voipiocat > $TMPC << EOF
2128099d6b0fSRiku Voipio#include <unistd.h>
2129099d6b0fSRiku Voipio#include <fcntl.h>
2130099d6b0fSRiku Voipio
2131099d6b0fSRiku Voipioint main(void)
2132099d6b0fSRiku Voipio{
2133099d6b0fSRiku Voipio    int pipefd[2];
2134099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2135099d6b0fSRiku Voipio    return 0;
2136099d6b0fSRiku Voipio}
2137099d6b0fSRiku VoipioEOF
213852166aa0SJuan Quintelaif compile_prog "" "" ; then
2139099d6b0fSRiku Voipio  pipe2=yes
2140099d6b0fSRiku Voipiofi
2141099d6b0fSRiku Voipio
214240ff6d7eSKevin Wolf# check if accept4 is there
214340ff6d7eSKevin Wolfaccept4=no
214440ff6d7eSKevin Wolfcat > $TMPC << EOF
214540ff6d7eSKevin Wolf#include <sys/socket.h>
214640ff6d7eSKevin Wolf#include <stddef.h>
214740ff6d7eSKevin Wolf
214840ff6d7eSKevin Wolfint main(void)
214940ff6d7eSKevin Wolf{
215040ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
215140ff6d7eSKevin Wolf    return 0;
215240ff6d7eSKevin Wolf}
215340ff6d7eSKevin WolfEOF
215440ff6d7eSKevin Wolfif compile_prog "" "" ; then
215540ff6d7eSKevin Wolf  accept4=yes
215640ff6d7eSKevin Wolffi
215740ff6d7eSKevin Wolf
21583ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
21593ce34dfbSvibisreenivasansplice=no
21603ce34dfbSvibisreenivasancat > $TMPC << EOF
21613ce34dfbSvibisreenivasan#include <unistd.h>
21623ce34dfbSvibisreenivasan#include <fcntl.h>
21633ce34dfbSvibisreenivasan#include <limits.h>
21643ce34dfbSvibisreenivasan
21653ce34dfbSvibisreenivasanint main(void)
21663ce34dfbSvibisreenivasan{
21673ce34dfbSvibisreenivasan    int len, fd;
21683ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
21693ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
21703ce34dfbSvibisreenivasan    return 0;
21713ce34dfbSvibisreenivasan}
21723ce34dfbSvibisreenivasanEOF
217352166aa0SJuan Quintelaif compile_prog "" "" ; then
21743ce34dfbSvibisreenivasan  splice=yes
21753ce34dfbSvibisreenivasanfi
21763ce34dfbSvibisreenivasan
2177dcc38d1cSMarcelo Tosatti##########################################
2178dcc38d1cSMarcelo Tosatti# signalfd probe
2179dcc38d1cSMarcelo Tosattisignalfd="no"
2180dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2181dcc38d1cSMarcelo Tosatti#define _GNU_SOURCE
2182dcc38d1cSMarcelo Tosatti#include <unistd.h>
2183dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2184dcc38d1cSMarcelo Tosatti#include <signal.h>
2185dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2186dcc38d1cSMarcelo TosattiEOF
2187dcc38d1cSMarcelo Tosatti
2188dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2189dcc38d1cSMarcelo Tosatti  signalfd=yes
2190dcc38d1cSMarcelo Tosattifi
2191dcc38d1cSMarcelo Tosatti
2192c2882b96SRiku Voipio# check if eventfd is supported
2193c2882b96SRiku Voipioeventfd=no
2194c2882b96SRiku Voipiocat > $TMPC << EOF
2195c2882b96SRiku Voipio#include <sys/eventfd.h>
2196c2882b96SRiku Voipio
2197c2882b96SRiku Voipioint main(void)
2198c2882b96SRiku Voipio{
2199c2882b96SRiku Voipio    int efd = eventfd(0, 0);
2200c2882b96SRiku Voipio    return 0;
2201c2882b96SRiku Voipio}
2202c2882b96SRiku VoipioEOF
2203c2882b96SRiku Voipioif compile_prog "" "" ; then
2204c2882b96SRiku Voipio  eventfd=yes
2205c2882b96SRiku Voipiofi
2206c2882b96SRiku Voipio
2207d0927938SUlrich Hecht# check for fallocate
2208d0927938SUlrich Hechtfallocate=no
2209d0927938SUlrich Hechtcat > $TMPC << EOF
2210d0927938SUlrich Hecht#include <fcntl.h>
2211d0927938SUlrich Hecht
2212d0927938SUlrich Hechtint main(void)
2213d0927938SUlrich Hecht{
2214d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2215d0927938SUlrich Hecht    return 0;
2216d0927938SUlrich Hecht}
2217d0927938SUlrich HechtEOF
2218be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
2219d0927938SUlrich Hecht  fallocate=yes
2220d0927938SUlrich Hechtfi
2221d0927938SUlrich Hecht
2222c727f47dSPeter Maydell# check for sync_file_range
2223c727f47dSPeter Maydellsync_file_range=no
2224c727f47dSPeter Maydellcat > $TMPC << EOF
2225c727f47dSPeter Maydell#include <fcntl.h>
2226c727f47dSPeter Maydell
2227c727f47dSPeter Maydellint main(void)
2228c727f47dSPeter Maydell{
2229c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2230c727f47dSPeter Maydell    return 0;
2231c727f47dSPeter Maydell}
2232c727f47dSPeter MaydellEOF
2233c727f47dSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2234c727f47dSPeter Maydell  sync_file_range=yes
2235c727f47dSPeter Maydellfi
2236c727f47dSPeter Maydell
2237dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2238dace20dcSPeter Maydellfiemap=no
2239dace20dcSPeter Maydellcat > $TMPC << EOF
2240dace20dcSPeter Maydell#include <sys/ioctl.h>
2241dace20dcSPeter Maydell#include <linux/fs.h>
2242dace20dcSPeter Maydell#include <linux/fiemap.h>
2243dace20dcSPeter Maydell
2244dace20dcSPeter Maydellint main(void)
2245dace20dcSPeter Maydell{
2246dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2247dace20dcSPeter Maydell    return 0;
2248dace20dcSPeter Maydell}
2249dace20dcSPeter MaydellEOF
2250dace20dcSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2251dace20dcSPeter Maydell  fiemap=yes
2252dace20dcSPeter Maydellfi
2253dace20dcSPeter Maydell
2254d0927938SUlrich Hecht# check for dup3
2255d0927938SUlrich Hechtdup3=no
2256d0927938SUlrich Hechtcat > $TMPC << EOF
2257d0927938SUlrich Hecht#include <unistd.h>
2258d0927938SUlrich Hecht
2259d0927938SUlrich Hechtint main(void)
2260d0927938SUlrich Hecht{
2261d0927938SUlrich Hecht    dup3(0, 0, 0);
2262d0927938SUlrich Hecht    return 0;
2263d0927938SUlrich Hecht}
2264d0927938SUlrich HechtEOF
226578f5d726SJan Kiszkaif compile_prog "" "" ; then
2266d0927938SUlrich Hecht  dup3=yes
2267d0927938SUlrich Hechtfi
2268d0927938SUlrich Hecht
22693b6edd16SPeter Maydell# check for epoll support
22703b6edd16SPeter Maydellepoll=no
22713b6edd16SPeter Maydellcat > $TMPC << EOF
22723b6edd16SPeter Maydell#include <sys/epoll.h>
22733b6edd16SPeter Maydell
22743b6edd16SPeter Maydellint main(void)
22753b6edd16SPeter Maydell{
22763b6edd16SPeter Maydell    epoll_create(0);
22773b6edd16SPeter Maydell    return 0;
22783b6edd16SPeter Maydell}
22793b6edd16SPeter MaydellEOF
22803b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
22813b6edd16SPeter Maydell  epoll=yes
22823b6edd16SPeter Maydellfi
22833b6edd16SPeter Maydell
22843b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
22853b6edd16SPeter Maydell# so we must check separately for their presence
22863b6edd16SPeter Maydellepoll_create1=no
22873b6edd16SPeter Maydellcat > $TMPC << EOF
22883b6edd16SPeter Maydell#include <sys/epoll.h>
22893b6edd16SPeter Maydell
22903b6edd16SPeter Maydellint main(void)
22913b6edd16SPeter Maydell{
229219e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
229319e83f6bSPeter Maydell     * a function being called. This is necessary so that on
229419e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
229519e83f6bSPeter Maydell     * the library but not declared in the header file we will
229619e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
229719e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
229819e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
229919e83f6bSPeter Maydell     */
230019e83f6bSPeter Maydell    epoll_create1;
23013b6edd16SPeter Maydell    return 0;
23023b6edd16SPeter Maydell}
23033b6edd16SPeter MaydellEOF
23043b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23053b6edd16SPeter Maydell  epoll_create1=yes
23063b6edd16SPeter Maydellfi
23073b6edd16SPeter Maydell
23083b6edd16SPeter Maydellepoll_pwait=no
23093b6edd16SPeter Maydellcat > $TMPC << EOF
23103b6edd16SPeter Maydell#include <sys/epoll.h>
23113b6edd16SPeter Maydell
23123b6edd16SPeter Maydellint main(void)
23133b6edd16SPeter Maydell{
23143b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
23153b6edd16SPeter Maydell    return 0;
23163b6edd16SPeter Maydell}
23173b6edd16SPeter MaydellEOF
23183b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23193b6edd16SPeter Maydell  epoll_pwait=yes
23203b6edd16SPeter Maydellfi
23213b6edd16SPeter Maydell
2322cc8ae6deSpbrook# Check if tools are available to build documentation.
2323a25dba17SJuan Quintelaif test "$docs" != "no" ; then
232401668d98SStefan Weil  if has makeinfo && has pod2man; then
2325a25dba17SJuan Quintela    docs=yes
232683a3ab8bSJuan Quintela  else
2327a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2328a25dba17SJuan Quintela      feature_not_found "docs"
232983a3ab8bSJuan Quintela    fi
2330a25dba17SJuan Quintela    docs=no
233183a3ab8bSJuan Quintela  fi
2332cc8ae6deSpbrookfi
2333cc8ae6deSpbrook
2334f514f41cSStefan Weil# Search for bswap_32 function
23356ae9a1f4SJuan Quintelabyteswap_h=no
23366ae9a1f4SJuan Quintelacat > $TMPC << EOF
23376ae9a1f4SJuan Quintela#include <byteswap.h>
23386ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
23396ae9a1f4SJuan QuintelaEOF
234052166aa0SJuan Quintelaif compile_prog "" "" ; then
23416ae9a1f4SJuan Quintela  byteswap_h=yes
23426ae9a1f4SJuan Quintelafi
23436ae9a1f4SJuan Quintela
2344f514f41cSStefan Weil# Search for bswap_32 function
23456ae9a1f4SJuan Quintelabswap_h=no
23466ae9a1f4SJuan Quintelacat > $TMPC << EOF
23476ae9a1f4SJuan Quintela#include <sys/endian.h>
23486ae9a1f4SJuan Quintela#include <sys/types.h>
23496ae9a1f4SJuan Quintela#include <machine/bswap.h>
23506ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
23516ae9a1f4SJuan QuintelaEOF
235252166aa0SJuan Quintelaif compile_prog "" "" ; then
23536ae9a1f4SJuan Quintela  bswap_h=yes
23546ae9a1f4SJuan Quintelafi
23556ae9a1f4SJuan Quintela
2356da93a1fdSaliguori##########################################
2357c589b249SRonnie Sahlberg# Do we have libiscsi
2358c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
2359c589b249SRonnie Sahlberg  cat > $TMPC << EOF
2360c589b249SRonnie Sahlberg#include <iscsi/iscsi.h>
2361c589b249SRonnie Sahlbergint main(void) { iscsi_create_context(""); return 0; }
2362c589b249SRonnie SahlbergEOF
2363c589b249SRonnie Sahlberg  if compile_prog "-Werror" "-liscsi" ; then
2364c589b249SRonnie Sahlberg    libiscsi="yes"
2365c589b249SRonnie Sahlberg    LIBS="$LIBS -liscsi"
2366c589b249SRonnie Sahlberg  else
2367c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
2368c589b249SRonnie Sahlberg      feature_not_found "libiscsi"
2369c589b249SRonnie Sahlberg    fi
2370c589b249SRonnie Sahlberg    libiscsi="no"
2371c589b249SRonnie Sahlberg  fi
2372c589b249SRonnie Sahlbergfi
2373c589b249SRonnie Sahlberg
2374c589b249SRonnie Sahlberg
2375c589b249SRonnie Sahlberg##########################################
2376da93a1fdSaliguori# Do we need librt
2377da93a1fdSaliguoricat > $TMPC <<EOF
2378da93a1fdSaliguori#include <signal.h>
2379da93a1fdSaliguori#include <time.h>
2380da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
2381da93a1fdSaliguoriEOF
2382da93a1fdSaliguori
238352166aa0SJuan Quintelaif compile_prog "" "" ; then
238407ffa4bdSJuan Quintela  :
238552166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
238607ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2387da93a1fdSaliguorifi
2388da93a1fdSaliguori
238931ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2390179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
23916362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
23926362a53fSJuan Quintelafi
23936362a53fSJuan Quintela
2394de5071c5SBlue Swirl##########################################
2395de5071c5SBlue Swirl# check if the compiler defines offsetof
2396de5071c5SBlue Swirl
2397de5071c5SBlue Swirlneed_offsetof=yes
2398de5071c5SBlue Swirlcat > $TMPC << EOF
2399de5071c5SBlue Swirl#include <stddef.h>
2400de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
2401de5071c5SBlue SwirlEOF
2402de5071c5SBlue Swirlif compile_prog "" "" ; then
2403de5071c5SBlue Swirl    need_offsetof=no
2404de5071c5SBlue Swirlfi
2405de5071c5SBlue Swirl
2406cd4ec0b4SGerd Hoffmann# spice probe
2407cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2408cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2409cd4ec0b4SGerd Hoffmann#include <spice.h>
2410cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2411cd4ec0b4SGerd HoffmannEOF
2412710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2413710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2414012b80d3SGerd Hoffmann  if $pkg_config --atleast-version=0.6.0 spice-server >/dev/null 2>&1 && \
2415cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2416cd4ec0b4SGerd Hoffmann    spice="yes"
2417cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2418cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2419cd4ec0b4SGerd Hoffmann  else
2420cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2421cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2422cd4ec0b4SGerd Hoffmann    fi
2423cd4ec0b4SGerd Hoffmann    spice="no"
2424cd4ec0b4SGerd Hoffmann  fi
2425cd4ec0b4SGerd Hoffmannfi
2426cd4ec0b4SGerd Hoffmann
2427111a38b0SRobert Relyea# check for libcacard for smartcard support
2428111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2429111a38b0SRobert Relyea    smartcard="yes"
2430111a38b0SRobert Relyea    smartcard_cflags=""
2431111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2432111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
2433111a38b0SRobert Relyea        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then
2434111a38b0SRobert Relyea            smartcard_nss="yes"
2435111a38b0SRobert Relyea            smartcard_cflags="-I\$(SRC_PATH)/libcacard"
2436111a38b0SRobert Relyea            libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
2437111a38b0SRobert Relyea            libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
2438111a38b0SRobert Relyea            QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
2439111a38b0SRobert Relyea            LIBS="$libcacard_libs $LIBS"
2440111a38b0SRobert Relyea        else
2441111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2442111a38b0SRobert Relyea                feature_not_found "nss"
2443111a38b0SRobert Relyea            fi
2444111a38b0SRobert Relyea            smartcard_nss="no"
2445111a38b0SRobert Relyea        fi
2446111a38b0SRobert Relyea    fi
2447111a38b0SRobert Relyeafi
2448111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2449111a38b0SRobert Relyea    smartcard_nss="no"
2450111a38b0SRobert Relyeafi
2451111a38b0SRobert Relyea
245269354a83SHans de Goede# check for usbredirparser for usb network redirection support
245369354a83SHans de Goedeif test "$usb_redir" != "no" ; then
245469354a83SHans de Goede    if $pkg_config libusbredirparser >/dev/null 2>&1 ; then
245569354a83SHans de Goede        usb_redir="yes"
245669354a83SHans de Goede        usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
245769354a83SHans de Goede        usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
245869354a83SHans de Goede        QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
245969354a83SHans de Goede        LIBS="$LIBS $usb_redir_libs"
246069354a83SHans de Goede    else
246169354a83SHans de Goede        if test "$usb_redir" = "yes"; then
246269354a83SHans de Goede            feature_not_found "usb-redir"
246369354a83SHans de Goede        fi
246469354a83SHans de Goede        usb_redir="no"
246569354a83SHans de Goede    fi
246669354a83SHans de Goedefi
246769354a83SHans de Goede
2468cd4ec0b4SGerd Hoffmann##########################################
2469cd4ec0b4SGerd Hoffmann
2470747bbdf7SBlue Swirl##########################################
24715f6b9e8fSBlue Swirl# check if we have fdatasync
24725f6b9e8fSBlue Swirl
24735f6b9e8fSBlue Swirlfdatasync=no
24745f6b9e8fSBlue Swirlcat > $TMPC << EOF
24755f6b9e8fSBlue Swirl#include <unistd.h>
2476d1722a27SAlexandre Raymondint main(void) {
2477d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2478d1722a27SAlexandre Raymondreturn fdatasync(0);
2479d1722a27SAlexandre Raymond#else
2480d1722a27SAlexandre Raymond#abort Not supported
2481d1722a27SAlexandre Raymond#endif
2482d1722a27SAlexandre Raymond}
24835f6b9e8fSBlue SwirlEOF
24845f6b9e8fSBlue Swirlif compile_prog "" "" ; then
24855f6b9e8fSBlue Swirl    fdatasync=yes
24865f6b9e8fSBlue Swirlfi
24875f6b9e8fSBlue Swirl
248894a420b1SStefan Hajnoczi##########################################
2489e78815a5SAndreas Färber# check if we have madvise
2490e78815a5SAndreas Färber
2491e78815a5SAndreas Färbermadvise=no
2492e78815a5SAndreas Färbercat > $TMPC << EOF
2493e78815a5SAndreas Färber#include <sys/types.h>
2494e78815a5SAndreas Färber#include <sys/mman.h>
2495832ce9c2SScott Wood#include <stddef.h>
2496e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2497e78815a5SAndreas FärberEOF
2498e78815a5SAndreas Färberif compile_prog "" "" ; then
2499e78815a5SAndreas Färber    madvise=yes
2500e78815a5SAndreas Färberfi
2501e78815a5SAndreas Färber
2502e78815a5SAndreas Färber##########################################
2503e78815a5SAndreas Färber# check if we have posix_madvise
2504e78815a5SAndreas Färber
2505e78815a5SAndreas Färberposix_madvise=no
2506e78815a5SAndreas Färbercat > $TMPC << EOF
2507e78815a5SAndreas Färber#include <sys/mman.h>
2508832ce9c2SScott Wood#include <stddef.h>
2509e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2510e78815a5SAndreas FärberEOF
2511e78815a5SAndreas Färberif compile_prog "" "" ; then
2512e78815a5SAndreas Färber    posix_madvise=yes
2513e78815a5SAndreas Färberfi
2514e78815a5SAndreas Färber
2515e78815a5SAndreas Färber##########################################
251694a420b1SStefan Hajnoczi# check if trace backend exists
251794a420b1SStefan Hajnoczi
25184c3b5a48SBlue Swirlsh "$source_path/scripts/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
251994a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
252094a420b1SStefan Hajnoczi  echo
252194a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
252294a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
252394a420b1SStefan Hajnoczi  echo
252494a420b1SStefan Hajnoczi  exit 1
252594a420b1SStefan Hajnoczifi
252694a420b1SStefan Hajnoczi
25277e24e92aSStefan Hajnoczi##########################################
25287e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
25297e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
25307e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
25317e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
25327e24e92aSStefan Hajnoczi#include <ust/marker.h>
25337e24e92aSStefan Hajnocziint main(void) { return 0; }
25347e24e92aSStefan HajnocziEOF
25357e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
25367e24e92aSStefan Hajnoczi    LIBS="-lust $LIBS"
25377e24e92aSStefan Hajnoczi  else
25387e24e92aSStefan Hajnoczi    echo
25397e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
25407e24e92aSStefan Hajnoczi    echo
25417e24e92aSStefan Hajnoczi    exit 1
25427e24e92aSStefan Hajnoczi  fi
25437e24e92aSStefan Hajnoczifi
2544b3d08c02SDaniel P. Berrange
2545b3d08c02SDaniel P. Berrange##########################################
2546b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2547b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2548b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2549b3d08c02SDaniel P. Berrange    echo
2550b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2551b3d08c02SDaniel P. Berrange    echo
2552b3d08c02SDaniel P. Berrange    exit 1
2553b3d08c02SDaniel P. Berrange  fi
2554c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2555c276b17dSDaniel P. Berrange  if has 'stap' ; then
2556c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2557c276b17dSDaniel P. Berrange  fi
2558b3d08c02SDaniel P. Berrangefi
2559b3d08c02SDaniel P. Berrange
25607e24e92aSStefan Hajnoczi##########################################
2561023367e6SWolfgang Mauerer# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2562023367e6SWolfgang Mauerer# use i686 as default anyway, but for those that don't, an explicit
2563023367e6SWolfgang Mauerer# specification is necessary
25641ba16968SStefan Weilif test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
2565023367e6SWolfgang Mauerer  cat > $TMPC << EOF
2566023367e6SWolfgang Mauererint sfaa(unsigned *ptr)
2567023367e6SWolfgang Mauerer{
2568023367e6SWolfgang Mauerer  return __sync_fetch_and_and(ptr, 0);
2569023367e6SWolfgang Mauerer}
2570023367e6SWolfgang Mauerer
2571023367e6SWolfgang Mauererint main(int argc, char **argv)
2572023367e6SWolfgang Mauerer{
2573023367e6SWolfgang Mauerer  int val = 42;
2574023367e6SWolfgang Mauerer  sfaa(&val);
2575023367e6SWolfgang Mauerer  return val;
2576023367e6SWolfgang Mauerer}
2577023367e6SWolfgang MauererEOF
2578023367e6SWolfgang Mauerer  if ! compile_prog "" "" ; then
2579023367e6SWolfgang Mauerer    CFLAGS+="-march=i486"
2580023367e6SWolfgang Mauerer  fi
2581023367e6SWolfgang Mauererfi
2582023367e6SWolfgang Mauerer
2583023367e6SWolfgang Mauerer##########################################
2584d0e2fce5SAneesh Kumar K.V# check if we have makecontext
2585d0e2fce5SAneesh Kumar K.V
2586d0e2fce5SAneesh Kumar K.Vucontext_coroutine=no
2587d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
2588d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
2589d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
2590d0e2fce5SAneesh Kumar K.Vint main(void) { makecontext(0, 0, 0); }
2591d0e2fce5SAneesh Kumar K.VEOF
2592d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
2593d0e2fce5SAneesh Kumar K.V      ucontext_coroutine=yes
2594d0e2fce5SAneesh Kumar K.V  fi
2595d0e2fce5SAneesh Kumar K.Vfi
2596d0e2fce5SAneesh Kumar K.V
2597d0e2fce5SAneesh Kumar K.V##########################################
2598d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
2599d2042378SAneesh Kumar K.V
2600d2042378SAneesh Kumar K.Vopen_by_hande_at=no
2601d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
2602d2042378SAneesh Kumar K.V#include <fcntl.h>
260315329e83SAneesh Kumar K.Vint main(void) { struct file_handle fh; open_by_handle_at(0, &fh, 0); }
2604d2042378SAneesh Kumar K.VEOF
2605d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
2606d2042378SAneesh Kumar K.V    open_by_handle_at=yes
2607d2042378SAneesh Kumar K.Vfi
2608d2042378SAneesh Kumar K.V
2609e06a765eSHarsh Prateek Bora########################################
2610e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
2611e06a765eSHarsh Prateek Bora
2612e06a765eSHarsh Prateek Boralinux_magic_h=no
2613e06a765eSHarsh Prateek Boracat > $TMPC << EOF
2614e06a765eSHarsh Prateek Bora#include <linux/magic.h>
2615e06a765eSHarsh Prateek Boraint main(void) {
2616e06a765eSHarsh Prateek Bora}
2617e06a765eSHarsh Prateek BoraEOF
2618e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
2619e06a765eSHarsh Prateek Bora    linux_magic_h=yes
2620e06a765eSHarsh Prateek Borafi
2621e06a765eSHarsh Prateek Bora
2622d2042378SAneesh Kumar K.V##########################################
2623e86ecd4bSJuan Quintela# End of CC checks
2624e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2625e86ecd4bSJuan Quintela
2626e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
26271156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2628e86ecd4bSJuan Quintelafi
2629a316e378SJuan Quintela
2630e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2631e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2632e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
263320ff6c80SAnthony Liguori
263420ff6c80SAnthony Liguoriif test -z "$werror" ; then
2635e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2636e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2637e86ecd4bSJuan Quintela        werror="yes"
2638e86ecd4bSJuan Quintela    else
2639e86ecd4bSJuan Quintela        werror="no"
2640e86ecd4bSJuan Quintela    fi
2641e86ecd4bSJuan Quintelafi
2642e86ecd4bSJuan Quintela
264320ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
264420ff6c80SAnthony Liguori# enable/disable
264520ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
264620ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
264720ff6c80SAnthony Liguori	zero_malloc="no"
264820ff6c80SAnthony Liguori    else
264920ff6c80SAnthony Liguori	zero_malloc="yes"
265020ff6c80SAnthony Liguori    fi
265120ff6c80SAnthony Liguorifi
265220ff6c80SAnthony Liguori
2653e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2654a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2655e86ecd4bSJuan Quintelafi
2656e86ecd4bSJuan Quintela
2657e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2658e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
26591156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2660e86ecd4bSJuan Quintela    fi
2661e86ecd4bSJuan Quintelafi
2662e86ecd4bSJuan Quintela
2663952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
2664952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
2665952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
2666952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2667952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
2668952afb71SBlue Swirl        fi
2669952afb71SBlue Swirl    done
2670952afb71SBlue Swirlfi
2671952afb71SBlue Swirl
2672190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
26735a67135aSbellard
2674ca35f780SPaolo Bonzinitools=
2675ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2676ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2677ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2678ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2679d138cee9SMichael Roth    if [ "$guest_agent" = "yes" ]; then
268048ff7a62SMichael Roth      tools="qemu-ga\$(EXESUF) $tools"
2681d138cee9SMichael Roth    fi
2682ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2683fffbeb75SGerd Hoffmann      checks="check-qint check-qstring check-qdict check-qlist"
2684695833bcSGerd Hoffmann      checks="check-qfloat check-qjson test-coroutine $checks"
2685ca35f780SPaolo Bonzini    fi
2686ca35f780SPaolo Bonzini  fi
2687ca35f780SPaolo Bonzinifi
2688ca35f780SPaolo Bonzini
2689ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2690ca35f780SPaolo Bonziniroms=
2691ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2692ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2693ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2694ca35f780SPaolo Bonzini  roms="optionrom"
2695ca35f780SPaolo Bonzinifi
2696d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
269739ac8455SDavid Gibson  roms="$roms spapr-rtas"
269839ac8455SDavid Gibsonfi
2699ca35f780SPaolo Bonzini
27007d13299dSbellardecho "Install prefix    $prefix"
2701f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2702f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
27033aa5d2beSAlon Levyecho "library directory `eval echo $libdir`"
27040f94d6daSAlon Levyecho "include directory `eval echo $includedir`"
27051c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
270611d9f695Sbellardif test "$mingw32" = "no" ; then
2707f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
270843ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
270911d9f695Sbellardfi
27105a67135aSbellardecho "Source path       $source_path"
27117d13299dSbellardecho "C compiler        $cc"
271283469015Sbellardecho "Host C compiler   $host_cc"
27130c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2714a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
27150c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
27167d13299dSbellardecho "make              $make"
27176a882643Spbrookecho "install           $install"
2718c886edfbSBlue Swirlecho "python            $python"
2719e2d8830eSBradif test "$slirp" = "yes" ; then
2720e2d8830eSBrad    echo "smbd              $smbd"
2721e2d8830eSBradfi
2722a98fd896Sbellardecho "host CPU          $cpu"
2723de83cd02Sbellardecho "host big endian   $bigendian"
272497a847bcSbellardecho "target list       $target_list"
2725ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2726b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
27277d13299dSbellardecho "gprof enabled     $gprof"
272803b4fe7dSaliguoriecho "sparse enabled    $sparse"
27291625af87Saliguoriecho "strip binaries    $strip_opt"
273005c2a3e7Sbellardecho "profiler          $profiler"
273143ce4dfeSbellardecho "static build      $static"
273285aa5189Sbellardecho "-Werror enabled   $werror"
27335b0753e0Sbellardif test "$darwin" = "yes" ; then
27345b0753e0Sbellard    echo "Cocoa support     $cocoa"
27355b0753e0Sbellardfi
273697a847bcSbellardecho "SDL support       $sdl"
27374d3b6f6eSbalrogecho "curses support    $curses"
2738769ce76dSAlexander Grafecho "curl support      $curl"
27395495ed11SLuiz Capitulinoecho "check support     $check_utests"
274067b915a5Sbellardecho "mingw32 support   $mingw32"
27410c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
27420c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2743eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
27448ff9cbf7Smalcecho "Mixer emulation   $mixemu"
2745821601eaSJes Sorensenecho "VNC support       $vnc"
2746821601eaSJes Sorensenif test "$vnc" = "yes" ; then
27478d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
27482f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
27492f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
2750efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
2751bd023f95SCorentin Chary    echo "VNC thread        $vnc_thread"
2752821601eaSJes Sorensenfi
27533142255cSblueswir1if test -n "$sparc_cpu"; then
27543142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
27553142255cSblueswir1fi
2756e37630caSaliguoriecho "xen support       $xen"
27572e4d9fb1Saurel32echo "brlapi support    $brlapi"
2758a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2759a25dba17SJuan Quintelaecho "Documentation     $docs"
2760c5937220Spbrook[ ! -z "$uname_release" ] && \
2761c5937220Spbrookecho "uname -r          $uname_release"
2762bd0c5661Spbrookecho "NPTL support      $nptl"
2763379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
276434005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
27658a16d273Sthsecho "vde support       $vde"
27665c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2767758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
276877755340Sthsecho "Install blobs     $blobs"
2769b31a0277SJuan Quintelaecho "KVM support       $kvm"
27709195b2c2SStefan Weilecho "TCG interpreter   $tcg_interpreter"
2771f652e6afSaurel32echo "fdt support       $fdt"
2772ceb42de8Saliguoriecho "preadv support    $preadv"
27735f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2774e78815a5SAndreas Färberecho "madvise           $madvise"
2775e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
2776ee682d27SStefan Weilecho "uuid support      $uuid"
2777d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
277894a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
27799410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
2780cd4ec0b4SGerd Hoffmannecho "spice support     $spice"
2781f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
2782dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
2783111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
278469354a83SHans de Goedeecho "usb net redir     $usb_redir"
278520ff075bSMichael Walleecho "OpenGL support    $opengl"
2786c589b249SRonnie Sahlbergecho "libiscsi support  $libiscsi"
2787d138cee9SMichael Rothecho "build guest agent $guest_agent"
278867b915a5Sbellard
27891ba16968SStefan Weilif test "$sdl_too_old" = "yes"; then
279024b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2791e8cd23deSbellardfi
279297a847bcSbellard
279398ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
27944bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
279597a847bcSbellard
279698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
279798ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
279898ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
279998ec69acSJuan Quintelaecho >> $config_host_mak
280098ec69acSJuan Quintela
2801e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
280299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
280399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
28043aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
28050f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
280699d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
280799d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
280899d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
280999d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
28101dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2811804edf29SJuan Quintela
28122408a527Saurel32case "$cpu" in
2813d2fbca94SGuan Xuetao  i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64|unicore32)
2814e0da9dd3SJuan Quintela    ARCH=$cpu
28152408a527Saurel32  ;;
2816a302c32dSLaurent Desnogues  armv4b|armv4l)
281716dbd14fSJuan Quintela    ARCH=arm
28182408a527Saurel32  ;;
28199195b2c2SStefan Weil  *)
28209195b2c2SStefan Weil    if test "$tcg_interpreter" = "yes" ; then
28219195b2c2SStefan Weil        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
28229195b2c2SStefan Weil        ARCH=tci
28239195b2c2SStefan Weil    else
28249195b2c2SStefan Weil        echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
28259195b2c2SStefan Weil        exit 1
28269195b2c2SStefan Weil    fi
28279195b2c2SStefan Weil  ;;
28282408a527Saurel32esac
282998ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2830f8393946Saurel32if test "$debug_tcg" = "yes" ; then
28312358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2832f8393946Saurel32fi
2833b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2834b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2835b4475aa2SLuiz Capitulinofi
2836f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
28372358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2838f3d08ee6SPaul Brookfi
28391625af87Saliguoriif test "$strip_opt" = "yes" ; then
284052ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
28411625af87Saliguorifi
28427d13299dSbellardif test "$bigendian" = "yes" ; then
2843e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
284497a847bcSbellardfi
28452358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
284667b915a5Sbellardif test "$mingw32" = "yes" ; then
284798ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
28489fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
28499fe6de94SBlue Swirl  version_major=${rc_version%%.*}
28509fe6de94SBlue Swirl  rc_version=${rc_version#*.}
28519fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
28529fe6de94SBlue Swirl  rc_version=${rc_version#*.}
28539fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
28549fe6de94SBlue Swirl  version_micro=0
28559fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
28569fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2857210fa556Spbrookelse
285835f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2859210fa556Spbrookfi
2860128ab2ffSblueswir1
2861dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2862dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2863dffcb71cSMark McLoughlinfi
2864dffcb71cSMark McLoughlin
286583fb7adfSbellardif test "$darwin" = "yes" ; then
286698ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
286783fb7adfSbellardfi
2868b29fe3edSmalc
2869b29fe3edSmalcif test "$aix" = "yes" ; then
287098ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2871b29fe3edSmalcfi
2872b29fe3edSmalc
2873ec530c81Sbellardif test "$solaris" = "yes" ; then
287498ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
28752358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
28760475a5caSths  if test "$needs_libsunmath" = "yes" ; then
287775b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
28780475a5caSths  fi
2879ec530c81Sbellardfi
2880179cf400SAndreas Färberif test "$haiku" = "yes" ; then
2881179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
2882179cf400SAndreas Färberfi
288397a847bcSbellardif test "$static" = "yes" ; then
288498ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
288597a847bcSbellardfi
28861ba16968SStefan Weilif test "$profiler" = "yes" ; then
28872358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
288805c2a3e7Sbellardfi
2889c20709aaSbellardif test "$slirp" = "yes" ; then
289098ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2891e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
2892f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
2893c20709aaSbellardfi
28948a16d273Sthsif test "$vde" = "yes" ; then
289598ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
28968a16d273Sthsfi
28970c58ac1cSmalcfor card in $audio_card_list; do
2898f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
289998ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
29000c58ac1cSmalcdone
29012358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
29020c58ac1cSmalcfor drv in $audio_drv_list; do
2903f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
290498ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2905923e4521Smalc    if test "$drv" = "fmod"; then
29067aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2907fb065187Sbellard    fi
29080c58ac1cSmalcdone
290967f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
291067f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
291167f86e8eSJuan Quintelafi
2912d5631638Smalcif test "$audio_win_int" = "yes" ; then
2913d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2914d5631638Smalcfi
2915eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
29168ff9cbf7Smalcif test "$mixemu" = "yes" ; then
291798ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
29188ff9cbf7Smalcfi
2919821601eaSJes Sorensenif test "$vnc" = "yes" ; then
2920821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
2921821601eaSJes Sorensenfi
29228d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
292398ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2924525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
29258d5d2d4cSthsfi
29262f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
292798ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
292860ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
29292f9606b3Saliguorifi
2930821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
29312f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
29322f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
29332f6f5c7aSCorentin Charyfi
2934821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
2935efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2936efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2937efe556adSCorentin Charyfi
2938821601eaSJes Sorensenif test "$vnc_thread" = "yes" ; then
2939bd023f95SCorentin Chary  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2940bd023f95SCorentin Charyfi
294176655d6dSaliguoriif test "$fnmatch" = "yes" ; then
29422358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
294376655d6dSaliguorifi
2944ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2945ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2946ee682d27SStefan Weilfi
2947dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
2948dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
2949dce512deSChristoph Hellwigfi
2950b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
295198ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
29522358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
295398ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
295498ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2955a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
295698ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2957cc8ae6deSpbrookfi
29581ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
295998ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
29608ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
296149ecc3faSbellardfi
296249ecc3faSbellardif test "$cocoa" = "yes" ; then
296398ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
296449ecc3faSbellardfi
29654d3b6f6eSbalrogif test "$curses" = "yes" ; then
296698ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2967ab4e5602SJan Kiszkafi
29683b3f24adSaurel32if test "$atfile" = "yes" ; then
29692358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
29703b3f24adSaurel32fi
2971ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
29722358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2973ebc996f3SRiku Voipiofi
2974099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
29752358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2976099d6b0fSRiku Voipiofi
297740ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
297840ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
297940ff6d7eSKevin Wolffi
29803ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
29812358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
29823ce34dfbSvibisreenivasanfi
2983c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2984c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2985c2882b96SRiku Voipiofi
2986d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2987d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2988d0927938SUlrich Hechtfi
2989c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
2990c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2991c727f47dSPeter Maydellfi
2992dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
2993dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
2994dace20dcSPeter Maydellfi
2995d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2996d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2997d0927938SUlrich Hechtfi
29983b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
29993b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
30003b6edd16SPeter Maydellfi
30013b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
30023b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
30033b6edd16SPeter Maydellfi
30043b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
30053b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
30063b6edd16SPeter Maydellfi
30073b3f24adSaurel32if test "$inotify" = "yes" ; then
30082358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
30093b3f24adSaurel32fi
3010c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
3011c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3012c05c7a73SRiku Voipiofi
30136ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
30146ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
30156ae9a1f4SJuan Quintelafi
30166ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
30176ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
30186ae9a1f4SJuan Quintelafi
3019769ce76dSAlexander Grafif test "$curl" = "yes" ; then
302098ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
3021b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3022769ce76dSAlexander Graffi
30232e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
302498ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
30252e4d9fb1Saurel32fi
3026fb599c9aSbalrogif test "$bluez" = "yes" ; then
302798ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
3028ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3029fb599c9aSbalrogfi
3030e18df141SAnthony Liguoriecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3031e37630caSaliguoriif test "$xen" = "yes" ; then
30326dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3033d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3034e37630caSaliguorifi
30355c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
30365c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
30375c6c3a6cSChristoph Hellwigfi
3038758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
3039758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
3040758e8e38SVenkateswararao Jujjuri (JV)fi
30414f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
30424f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
30434f26f2b6SAvi Kivityfi
3044758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
3045758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
3046758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
3047758e8e38SVenkateswararao Jujjuri (JV)  fi
3048758e8e38SVenkateswararao Jujjuri (JV)fi
304977755340Sthsif test "$blobs" = "yes" ; then
305098ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
305177755340Sthsfi
3052bf9298b9Saliguoriif test "$iovec" = "yes" ; then
30532358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
3054bf9298b9Saliguorifi
3055ceb42de8Saliguoriif test "$preadv" = "yes" ; then
30562358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
3057ceb42de8Saliguorifi
3058f652e6afSaurel32if test "$fdt" = "yes" ; then
30593f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
3060f652e6afSaurel32fi
3061dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
3062dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3063dcc38d1cSMarcelo Tosattifi
30649195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
30659195b2c2SStefan Weil  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
30669195b2c2SStefan Weilfi
3067de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
3068de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
3069de5071c5SBlue Swirlfi
30705f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
30715f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
30725f6b9e8fSBlue Swirlfi
3073e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
3074e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
3075e78815a5SAndreas Färberfi
3076e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
3077e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3078e78815a5SAndreas Färberfi
307997a847bcSbellard
3080cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
3081cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
3082cd4ec0b4SGerd Hoffmannfi
3083cd4ec0b4SGerd Hoffmann
308436707144SAlon Levyif test "$smartcard" = "yes" ; then
308536707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
308636707144SAlon Levyfi
308736707144SAlon Levy
3088111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3089111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3090111a38b0SRobert Relyeafi
3091111a38b0SRobert Relyea
309269354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
309369354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
309469354a83SHans de Goedefi
309569354a83SHans de Goede
309620ff075bSMichael Walleif test "$opengl" = "yes" ; then
309720ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
309820ff075bSMichael Wallefi
309920ff075bSMichael Walle
3100c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
3101c589b249SRonnie Sahlberg  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3102c589b249SRonnie Sahlbergfi
3103c589b249SRonnie Sahlberg
310483fb7adfSbellard# XXX: suppress that
31057d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
31062358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
31077d3505c5Sbellardfi
31087d3505c5Sbellard
31092358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3110c5937220Spbrook
311120ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
311220ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
311320ff6c80SAnthony Liguorifi
3114f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3115f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3116f27aaf4bSChristian Brunnerfi
311720ff6c80SAnthony Liguori
3118d0e2fce5SAneesh Kumar K.Vif test "$ucontext_coroutine" = "yes" ; then
3119d0e2fce5SAneesh Kumar K.V  echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
3120d0e2fce5SAneesh Kumar K.Vfi
3121d0e2fce5SAneesh Kumar K.V
3122d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
3123d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3124d2042378SAneesh Kumar K.Vfi
3125d2042378SAneesh Kumar K.V
3126e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
3127e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3128e06a765eSHarsh Prateek Borafi
3129e06a765eSHarsh Prateek Bora
313068063649Sblueswir1# USB host support
313168063649Sblueswir1case "$usb" in
313268063649Sblueswir1linux)
313398ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
313468063649Sblueswir1;;
313568063649Sblueswir1bsd)
313698ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
313768063649Sblueswir1;;
313868063649Sblueswir1*)
313998ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
314068063649Sblueswir1;;
314168063649Sblueswir1esac
314268063649Sblueswir1
3143e4858974SLluís# use default implementation for tracing backend-specific routines
3144e4858974SLluístrace_default=yes
314594a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
31466d8a764eSLluísif test "$trace_backend" = "nop"; then
31476d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
314822890ab5SPrerna Saxenafi
31499410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
31506d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
3151e4858974SLluís  trace_default=no
31526d8a764eSLluís  # Set the appropriate trace file.
3153953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
31549410b56cSPrerna Saxenafi
31556d8a764eSLluísif test "$trace_backend" = "stderr"; then
31566d8a764eSLluís  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
31579a82b6a5SLluís  trace_default=no
31586d8a764eSLluísfi
31596d8a764eSLluísif test "$trace_backend" = "ust"; then
31606d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
31616d8a764eSLluísfi
31626d8a764eSLluísif test "$trace_backend" = "dtrace"; then
31636d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
31646d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
31656d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
31666d8a764eSLluís  fi
3167c276b17dSDaniel P. Berrangefi
31689410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
3169e4858974SLluísif test "$trace_default" = "yes"; then
3170e4858974SLluís  echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3171e4858974SLluísfi
31729410b56cSPrerna Saxena
317398ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
3174fffbeb75SGerd Hoffmannecho "CHECKS=$checks" >> $config_host_mak
317598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3176804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3177804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
31781901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
31791901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
31801901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
3181c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
3182804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
31832b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3184804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
3185804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3186804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3187804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
31889fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
318944dc0ca3SAlon Levyecho "LIBTOOL=$libtool" >> $config_host_mak
3190e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3191a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3192f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3193e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3194e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3195e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3196e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3197e39f0062SPaolo Bonzinifi
3198c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
3199e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3200a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3201a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
320273da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
32033e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3204804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3205957f1f99SMichael Rothecho "LIBS_QGA+=$libs_qga" >> $config_host_mak
3206804edf29SJuan Quintela
32074bf6b55bSJuan Quintela# generate list of library paths for linker script
32084bf6b55bSJuan Quintela
32094bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
32104bf6b55bSJuan Quintela
32114bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
32124bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
32134bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
32144bf6b55bSJuan Quintela  else
32154bf6b55bSJuan Quintela    rm ${config_host_ld}~
32164bf6b55bSJuan Quintela  fi
32174bf6b55bSJuan Quintelafi
32184bf6b55bSJuan Quintela
32194d904533SBlue Swirlfor d in libdis libdis-user; do
32204d904533SBlue Swirl    mkdir -p $d
322111568d6dSPaolo Bonzini    symlink $source_path/Makefile.dis $d/Makefile
32224d904533SBlue Swirl    echo > $d/config.mak
32234d904533SBlue Swirldone
3224d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
3225d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
3226d44cff22SRichard Hendersonfi
32274d904533SBlue Swirl
322897a847bcSbellardfor target in $target_list; do
322997a847bcSbellardtarget_dir="$target"
323025be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3231600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
323297a847bcSbellardtarget_bigendian="no"
32331f3d3c8fSJuan Quintela
3234ea2d6a39SJuan Quintelacase "$target_arch2" in
3235cfa550c6SMax Filippov  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
3236ea2d6a39SJuan Quintela  target_bigendian=yes
3237ea2d6a39SJuan Quintela  ;;
3238ea2d6a39SJuan Quintelaesac
323997a847bcSbellardtarget_softmmu="no"
3240997344f3Sbellardtarget_user_only="no"
3241831b7825Sthstarget_linux_user="no"
3242831b7825Sthstarget_darwin_user="no"
324384778508Sblueswir1target_bsd_user="no"
32449e407a85Spbrookcase "$target" in
3245600309b6SBlue Swirl  ${target_arch2}-softmmu)
32469e407a85Spbrook    target_softmmu="yes"
32479e407a85Spbrook    ;;
3248600309b6SBlue Swirl  ${target_arch2}-linux-user)
32499c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
32509c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
32519c7a4202SBlue Swirl      exit 1
32529c7a4202SBlue Swirl    fi
32539e407a85Spbrook    target_user_only="yes"
32549e407a85Spbrook    target_linux_user="yes"
32559e407a85Spbrook    ;;
3256600309b6SBlue Swirl  ${target_arch2}-darwin-user)
32579c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
32589c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
32599c7a4202SBlue Swirl      exit 1
32609c7a4202SBlue Swirl    fi
32619e407a85Spbrook    target_user_only="yes"
3262831b7825Sths    target_darwin_user="yes"
32639e407a85Spbrook    ;;
3264600309b6SBlue Swirl  ${target_arch2}-bsd-user)
32659cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
32669c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
32679c7a4202SBlue Swirl      exit 1
32689c7a4202SBlue Swirl    fi
326984778508Sblueswir1    target_user_only="yes"
327084778508Sblueswir1    target_bsd_user="yes"
327184778508Sblueswir1    ;;
32729e407a85Spbrook  *)
32739e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
32749e407a85Spbrook    exit 1
32759e407a85Spbrook    ;;
32769e407a85Spbrookesac
3277831b7825Sths
327897a847bcSbellardmkdir -p $target_dir
3279158142c2Sbellardmkdir -p $target_dir/fpu
328057fec1feSbellardmkdir -p $target_dir/tcg
328159f2a787SGerd Hoffmannmkdir -p $target_dir/ide
3282353ac78dSAneesh Kumar K.Vmkdir -p $target_dir/9pfs
328384778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
328469de927cSbellard  mkdir -p $target_dir/nwfpe
328569de927cSbellardfi
328611568d6dSPaolo Bonzinisymlink $source_path/Makefile.target $target_dir/Makefile
3287ec530c81Sbellard
328897a847bcSbellard
328925be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
329097a847bcSbellard
3291e5fe0c52Spbrookbflt="no"
3292bd0c5661Spbrooktarget_nptl="no"
3293600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
32947ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
329556aebc89Spbrookgdb_xml_files=""
3296c2e3dee6SLaurent Viviertarget_short_alignment=2
3297c2e3dee6SLaurent Viviertarget_int_alignment=4
3298c2e3dee6SLaurent Viviertarget_long_alignment=4
3299c2e3dee6SLaurent Viviertarget_llong_alignment=8
3300de3a354aSMichael Walletarget_libs_softmmu=
33017ba1e619Saliguori
3302938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
33036acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3304e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3305e73aae67SJuan Quintela
3306600309b6SBlue Swirlcase "$target_arch2" in
33072408a527Saurel32  i386)
330871deff27SAurelien Jarno    target_phys_bits=64
33092408a527Saurel32  ;;
33102408a527Saurel32  x86_64)
33116acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
33121ad2134fSPaul Brook    target_phys_bits=64
3313c2e3dee6SLaurent Vivier    target_long_alignment=8
33142408a527Saurel32  ;;
33152408a527Saurel32  alpha)
33161ad2134fSPaul Brook    target_phys_bits=64
3317c2e3dee6SLaurent Vivier    target_long_alignment=8
3318a4b388ffSRichard Henderson    target_nptl="yes"
33192408a527Saurel32  ;;
33202408a527Saurel32  arm|armeb)
3321b498c8a0SJuan Quintela    TARGET_ARCH=arm
3322e5fe0c52Spbrook    bflt="yes"
3323bd0c5661Spbrook    target_nptl="yes"
332456aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
33251ad2134fSPaul Brook    target_phys_bits=32
3326c2e3dee6SLaurent Vivier    target_llong_alignment=4
33272408a527Saurel32  ;;
33282408a527Saurel32  cris)
3329253bd7f8Sedgar_igl    target_nptl="yes"
33301ad2134fSPaul Brook    target_phys_bits=32
33312408a527Saurel32  ;;
3332613a22c9SMichael Walle  lm32)
3333613a22c9SMichael Walle    target_phys_bits=32
3334de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3335613a22c9SMichael Walle  ;;
33362408a527Saurel32  m68k)
33370938cda5Saurel32    bflt="yes"
333856aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
33391ad2134fSPaul Brook    target_phys_bits=32
3340c2e3dee6SLaurent Vivier    target_int_alignment=2
3341c2e3dee6SLaurent Vivier    target_long_alignment=2
3342c2e3dee6SLaurent Vivier    target_llong_alignment=2
33432408a527Saurel32  ;;
3344877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3345877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
334672b675caSEdgar E. Iglesias    bflt="yes"
334772b675caSEdgar E. Iglesias    target_nptl="yes"
334872b675caSEdgar E. Iglesias    target_phys_bits=32
3349de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
335072b675caSEdgar E. Iglesias  ;;
33512408a527Saurel32  mips|mipsel)
3352b498c8a0SJuan Quintela    TARGET_ARCH=mips
335325be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3354f04dc72fSPaul Brook    target_nptl="yes"
33551ad2134fSPaul Brook    target_phys_bits=64
33562408a527Saurel32  ;;
33572408a527Saurel32  mipsn32|mipsn32el)
3358b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
33596acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
336025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
33611ad2134fSPaul Brook    target_phys_bits=64
33622408a527Saurel32  ;;
33632408a527Saurel32  mips64|mips64el)
3364b498c8a0SJuan Quintela    TARGET_ARCH=mips64
33656acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
336625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
33671ad2134fSPaul Brook    target_phys_bits=64
3368c2e3dee6SLaurent Vivier    target_long_alignment=8
33692408a527Saurel32  ;;
33702408a527Saurel32  ppc)
3371c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
33728b242ebaSAlexander Graf    target_phys_bits=64
3373d6630708SNathan Froyd    target_nptl="yes"
3374de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
33752408a527Saurel32  ;;
33762408a527Saurel32  ppcemb)
33776acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3378e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3379c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
33801ad2134fSPaul Brook    target_phys_bits=64
3381d6630708SNathan Froyd    target_nptl="yes"
3382de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
33832408a527Saurel32  ;;
33842408a527Saurel32  ppc64)
33856acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3386e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3387c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
33881ad2134fSPaul Brook    target_phys_bits=64
3389c2e3dee6SLaurent Vivier    target_long_alignment=8
3390de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
33912408a527Saurel32  ;;
33922408a527Saurel32  ppc64abi32)
3393b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
33946acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3395e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
339625be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3397c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
33981ad2134fSPaul Brook    target_phys_bits=64
3399de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
34002408a527Saurel32  ;;
34012408a527Saurel32  sh4|sh4eb)
3402b498c8a0SJuan Quintela    TARGET_ARCH=sh4
34034dbed897Spbrook    bflt="yes"
34040b6d3ae0Saurel32    target_nptl="yes"
34051ad2134fSPaul Brook    target_phys_bits=32
34062408a527Saurel32  ;;
34072408a527Saurel32  sparc)
34081ad2134fSPaul Brook    target_phys_bits=64
34092408a527Saurel32  ;;
34102408a527Saurel32  sparc64)
34116acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
34121ad2134fSPaul Brook    target_phys_bits=64
3413c2e3dee6SLaurent Vivier    target_long_alignment=8
34142408a527Saurel32  ;;
34152408a527Saurel32  sparc32plus)
3416b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
34176acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3418e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
341925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
34201ad2134fSPaul Brook    target_phys_bits=64
34212408a527Saurel32  ;;
342224e804ecSAlexander Graf  s390x)
3423bc434676SUlrich Hecht    target_nptl="yes"
342424e804ecSAlexander Graf    target_phys_bits=64
34257b3da903SAlexander Graf    target_long_alignment=8
342624e804ecSAlexander Graf  ;;
3427d2fbca94SGuan Xuetao  unicore32)
3428d2fbca94SGuan Xuetao    target_phys_bits=32
3429d2fbca94SGuan Xuetao  ;;
3430cfa550c6SMax Filippov  xtensa|xtensaeb)
3431cfa550c6SMax Filippov    TARGET_ARCH=xtensa
3432cfa550c6SMax Filippov    target_phys_bits=32
3433cfa550c6SMax Filippov  ;;
34342408a527Saurel32  *)
3435de83cd02Sbellard    echo "Unsupported target CPU"
3436de83cd02Sbellard    exit 1
34372408a527Saurel32  ;;
34382408a527Saurel32esac
3439c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3440c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3441c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3442c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
344325be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3444053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
344525be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
344625be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
344742bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
34486acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
34496acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
34506acff7daSJuan Quintelafi
345125be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3452e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3453e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3454e6e91b9cSJuan Quintelafi
345525be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
34561b0c87fcSJuan Quintelacase "$target_arch2" in
34571b0c87fcSJuan Quintela  i386|x86_64)
34581b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
345964b3cfdbSAnthony PERARD      target_phys_bits=64
346025be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
346159d21e53SAlexander Graf    else
346259d21e53SAlexander Graf      echo "CONFIG_NO_XEN=y" >> $config_target_mak
3463432d268cSJun Nakajima    fi
346459d21e53SAlexander Graf    ;;
346559d21e53SAlexander Graf  *)
346659d21e53SAlexander Graf    echo "CONFIG_NO_XEN=y" >> $config_target_mak
34671b0c87fcSJuan Quintelaesac
3468c59249f9SJuan Quintelacase "$target_arch2" in
34690e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3470c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3471c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3472c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3473c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
34745f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3475adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3476adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3477c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3478c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
347925be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
34801ba16968SStefan Weil      if test "$vhost_net" = "yes" ; then
3481d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3482d5970055SMichael S. Tsirkin      fi
3483c59249f9SJuan Quintela    fi
3484c59249f9SJuan Quintelaesac
34857f762366SBlue Swirlif test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then
34860a6b8ddeSAlexander Graf  echo "CONFIG_PSERIES=y" >> $config_target_mak
34870a6b8ddeSAlexander Graffi
3488de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
348925be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
349097a847bcSbellardfi
349197a847bcSbellardif test "$target_softmmu" = "yes" ; then
3492b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
349325be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3494de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
34950e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
34965791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3497de83cd02Sbellardfi
3498997344f3Sbellardif test "$target_user_only" = "yes" ; then
349925be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3500997344f3Sbellardfi
3501831b7825Sthsif test "$target_linux_user" = "yes" ; then
350225be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3503831b7825Sthsfi
3504831b7825Sthsif test "$target_darwin_user" = "yes" ; then
350525be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3506831b7825Sthsfi
3507111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3508111a38b0SRobert Relyea  echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3509111a38b0SRobert Relyea  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3510111a38b0SRobert Relyea  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3511111a38b0SRobert Relyeafi
351256aebc89Spbrooklist=""
351356aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
351456aebc89Spbrook  for x in $gdb_xml_files; do
351556aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
351656aebc89Spbrook  done
351725be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
35183d0f1517SJuan Quintelafi
3519de83cd02Sbellard
3520e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
352125be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3522e5fe0c52Spbrookfi
3523bd0c5661Spbrookif test "$target_user_only" = "yes" \
3524bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
352525be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3526bd0c5661Spbrookfi
3527379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
352825be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3529379f6698SPaul Brookfi
353084778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
353125be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
353284778508Sblueswir1fi
35335b0753e0Sbellard
35344afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3535fa282484SJuan Quintela
35364afddb55SJuan Quintelacflags=""
3537f9728943SPaolo Bonziniincludes=""
3538fa282484SJuan Quintelaldflags=""
35399b8e111fSJuan Quintela
35409195b2c2SStefan Weilif test "$tcg_interpreter" = "yes"; then
35419195b2c2SStefan Weil  includes="-I\$(SRC_PATH)/tcg/tci $includes"
35429195b2c2SStefan Weilelif test "$ARCH" = "sparc64" ; then
3543f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
354424e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3545f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
35465d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3547f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
354857ddfbf7SJuan Quintelaelse
3549f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
355057ddfbf7SJuan Quintelafi
3551f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
355257ddfbf7SJuan Quintela
35534d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
35544d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
35554d904533SBlue Swirlelse
35564d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
35574d904533SBlue Swirlfi
35584d904533SBlue Swirl
355964656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
356064656024SJuan Quintela  case "$i" in
356164656024SJuan Quintela  alpha)
356225be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
35634d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
356464656024SJuan Quintela  ;;
356564656024SJuan Quintela  arm)
356625be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
35674d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
356864656024SJuan Quintela  ;;
356964656024SJuan Quintela  cris)
357025be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
35714d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
357264656024SJuan Quintela  ;;
357364656024SJuan Quintela  hppa)
357425be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
35754d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
357664656024SJuan Quintela  ;;
357764656024SJuan Quintela  i386|x86_64)
357825be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
35794d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
358064656024SJuan Quintela  ;;
3581903ec55cSAurelien Jarno  ia64*)
3582903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3583903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3584903ec55cSAurelien Jarno  ;;
358564656024SJuan Quintela  m68k)
358625be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
35874d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
358864656024SJuan Quintela  ;;
3589877fdc12SEdgar E. Iglesias  microblaze*)
359025be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
35914d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
359264656024SJuan Quintela  ;;
359364656024SJuan Quintela  mips*)
359425be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
35954d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
359664656024SJuan Quintela  ;;
359764656024SJuan Quintela  ppc*)
359825be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
35994d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
360064656024SJuan Quintela  ;;
360124e804ecSAlexander Graf  s390*)
360225be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
36034d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
360464656024SJuan Quintela  ;;
360564656024SJuan Quintela  sh4)
360625be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
36074d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
360864656024SJuan Quintela  ;;
360964656024SJuan Quintela  sparc*)
361025be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
36114d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
361264656024SJuan Quintela  ;;
3613cfa550c6SMax Filippov  xtensa*)
3614cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $config_target_mak
3615cfa550c6SMax Filippov    echo "CONFIG_XTENSA_DIS=y"  >> $libdis_config_mak
3616cfa550c6SMax Filippov  ;;
361764656024SJuan Quintela  esac
361864656024SJuan Quinteladone
36199195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
36209195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $config_target_mak
36219195b2c2SStefan Weil  echo "CONFIG_TCI_DIS=y"  >> $libdis_config_mak
36229195b2c2SStefan Weilfi
362364656024SJuan Quintela
36246ee7126fSJuan Quintelacase "$ARCH" in
36256ee7126fSJuan Quintelaalpha)
36266ee7126fSJuan Quintela  # Ensure there's only a single GP
36276ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
36286ee7126fSJuan Quintela;;
36296ee7126fSJuan Quintelaesac
36306ee7126fSJuan Quintela
363155d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
363255d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
363355d9c04bSJuan Quintela  arm)
363455d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
363555d9c04bSJuan Quintela  ;;
363625a8bb96SMichael Walle  lm32)
363725a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
363825a8bb96SMichael Walle  ;;
363955d9c04bSJuan Quintela  i386|mips|ppc)
364055d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
364155d9c04bSJuan Quintela  ;;
364255d9c04bSJuan Quintela  esac
364355d9c04bSJuan Quintelafi
364455d9c04bSJuan Quintela
364534005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
364634005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
364734005a00SKirill A. Shutemov  cflags="-fpie $cflags"
364834005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
364934005a00SKirill A. Shutemovfi
365034005a00SKirill A. Shutemov
3651471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
3652471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
3653471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
365425be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3655471857ddSJuan Quintelafi
3656471857ddSJuan Quintela
3657d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
365825be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
3659d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
3660d02c1db3SJuan Quintela    cflags="-p $cflags"
3661d02c1db3SJuan Quintela    ldflags="-p $ldflags"
3662d02c1db3SJuan Quintela  fi
3663d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
3664d02c1db3SJuan Quintela    ldflags="-p $ldflags"
366525be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3666d02c1db3SJuan Quintela  fi
3667d02c1db3SJuan Quintelafi
3668d02c1db3SJuan Quintela
36699195b2c2SStefan Weilif test "$ARCH" = "tci"; then
36709195b2c2SStefan Weil  linker_script=""
36719195b2c2SStefan Weilelse
36726ee7126fSJuan Quintela  linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
36739195b2c2SStefan Weilfi
36749195b2c2SStefan Weil
36759b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3676fa282484SJuan Quintela  case "$ARCH" in
3677fa282484SJuan Quintela  sparc)
3678fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
3679322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
3680fa282484SJuan Quintela    ;;
36814d58be06SRichard Henderson  alpha | s390x)
36824d58be06SRichard Henderson    # The default placement of the application is fine.
36834d58be06SRichard Henderson    ;;
3684fd76e73aSRichard Henderson  *)
3685322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
3686fa282484SJuan Quintela    ;;
3687fa282484SJuan Quintela  esac
3688fa282484SJuan Quintelafi
3689fa282484SJuan Quintela
3690e205c790SJan Kiszka# use included Linux headers
3691af2be207SJan Kiszkaif test "$linux" = "yes" ; then
3692e205c790SJan Kiszka  includes="-I\$(SRC_PATH)/linux-headers $includes"
3693e205c790SJan Kiszka  mkdir -p linux-headers
3694e205c790SJan Kiszka  case "$cpu" in
3695e205c790SJan Kiszka  i386|x86_64)
3696e205c790SJan Kiszka    symlink $source_path/linux-headers/asm-x86 linux-headers/asm
3697e205c790SJan Kiszka    ;;
3698e205c790SJan Kiszka  ppcemb|ppc|ppc64)
3699af2be207SJan Kiszka    symlink $source_path/linux-headers/asm-powerpc linux-headers/asm
3700e205c790SJan Kiszka    ;;
3701e205c790SJan Kiszka  s390x)
3702e205c790SJan Kiszka    symlink $source_path/linux-headers/asm-s390 linux-headers/asm
3703e205c790SJan Kiszka    ;;
3704e205c790SJan Kiszka  esac
3705af2be207SJan Kiszkafi
3706e205c790SJan Kiszka
370725be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
370825be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3709f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
3710fa282484SJuan Quintela
371197a847bcSbellarddone # for target in $targets
37127d13299dSbellard
3713d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
3714e1144d00SMark McLoughlinDIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3715446b9165SAndreas FärberDIRS="$DIRS pc-bios/spapr-rtas"
37162d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
37173e230dd2SCorentin CharyDIRS="$DIRS fsdev ui"
3718e098fc3fSMichael RothDIRS="$DIRS qapi qapi-generated"
3719d9cd446bSAnthony LiguoriDIRS="$DIRS qga trace"
372070371cfbSLuiz CapitulinoFILES="Makefile tests/Makefile qdict-test-data.txt"
3721e7daa605SthsFILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3722ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3723446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
37242d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
3725753d11f2SRichard Hendersonfor bios_file in \
3726753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
3727753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
3728753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
3729753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
3730753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
3731753d11f2SRichard Hendersondo
37327ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
37337ea78b74SJan Kiszkadone
3734d1807a4fSPaolo Bonzinimkdir -p $DIRS
37357d13299dSbellardfor f in $FILES ; do
3736f9245e10SPeter Maydell    if [ -e "$source_path/$f" ] && ! [ -e "$f" ]; then
3737f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
3738f9245e10SPeter Maydell    fi
37397d13299dSbellarddone
37401ad2134fSPaul Brook
3741c34ebfdcSAnthony Liguori# temporary config to build submodules
37422d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
3743c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
374437116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3745c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3746c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3747c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
3748c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
3749c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3750c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
3751c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
3752c34ebfdcSAnthony Liguoridone
3753c34ebfdcSAnthony Liguori
37541ad2134fSPaul Brookfor hwlib in 32 64; do
37551ad2134fSPaul Brook  d=libhw$hwlib
37561ad2134fSPaul Brook  mkdir -p $d
37579953b2fcSBlue Swirl  mkdir -p $d/ide
375811568d6dSPaolo Bonzini  symlink $source_path/Makefile.hw $d/Makefile
3759353ac78dSAneesh Kumar K.V  mkdir -p $d/9pfs
376037116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
37611ad2134fSPaul Brookdone
3762add16157SBlue Swirl
3763111a38b0SRobert Relyeaif [ "$source_path" != `pwd` ]; then
3764111a38b0SRobert Relyea    # out of tree build
3765111a38b0SRobert Relyea    mkdir -p libcacard
3766111a38b0SRobert Relyea    rm -f libcacard/Makefile
376744dc0ca3SAlon Levy    symlink "$source_path/libcacard/Makefile" libcacard/Makefile
3768111a38b0SRobert Relyeafi
3769111a38b0SRobert Relyea
3770add16157SBlue Swirld=libuser
3771add16157SBlue Swirlmkdir -p $d
3772937b1258SLluís Vilanovamkdir -p $d/trace
377311568d6dSPaolo Bonzinisymlink $source_path/Makefile.user $d/Makefile
3774299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
3775299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3776299060a0SKirill A. Shutemovfi
3777b40292e7SJan Kiszka
3778b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
3779b40292e7SJan Kiszka  mkdir -p QMP
3780b40292e7SJan Kiszkafi
3781