Statistics
| Branch: | Revision:

root / configure @ 179cf400

History | View | Annotate | Download (78.2 kB)

1
#!/bin/sh
2
#
3
# qemu configure script (c) 2003 Fabrice Bellard
4
#
5
# set temporary file name
6
if test ! -z "$TMPDIR" ; then
7
    TMPDIR1="${TMPDIR}"
8
elif test ! -z "$TEMPDIR" ; then
9
    TMPDIR1="${TEMPDIR}"
10
else
11
    TMPDIR1="/tmp"
12
fi
13

    
14
TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
15
TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16
TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
17

    
18
# NB: do not call "exit" in the trap handler; this is buggy with some shells;
19
# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
20
trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21

    
22
compile_object() {
23
  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
24
}
25

    
26
compile_prog() {
27
  local_cflags="$1"
28
  local_ldflags="$2"
29
  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
30
}
31

    
32
# check whether a command is available to this shell (may be either an
33
# executable or a builtin)
34
has() {
35
    type "$1" >/dev/null 2>&1
36
}
37

    
38
# search for an executable in PATH
39
path_of() {
40
    local_command="$1"
41
    local_ifs="$IFS"
42
    local_dir=""
43

    
44
    # pathname has a dir component?
45
    if [ "${local_command#*/}" != "$local_command" ]; then
46
        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
47
            echo "$local_command"
48
            return 0
49
        fi
50
    fi
51
    if [ -z "$local_command" ]; then
52
        return 1
53
    fi
54

    
55
    IFS=:
56
    for local_dir in $PATH; do
57
        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
58
            echo "$local_dir/$local_command"
59
            IFS="${local_ifs:-$(printf ' \t\n')}"
60
            return 0
61
        fi
62
    done
63
    # not found
64
    IFS="${local_ifs:-$(printf ' \t\n')}"
65
    return 1
66
}
67

    
68
# default parameters
69
cpu=""
70
interp_prefix="/usr/gnemul/qemu-%M"
71
static="no"
72
sparc_cpu=""
73
cross_prefix=""
74
cc="gcc"
75
audio_drv_list=""
76
audio_card_list="ac97 es1370 sb16"
77
audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
78
block_drv_whitelist=""
79
host_cc="gcc"
80
ar="ar"
81
make="make"
82
install="install"
83
objcopy="objcopy"
84
ld="ld"
85
strip="strip"
86
windres="windres"
87
helper_cflags=""
88
libs_softmmu=""
89
libs_tools=""
90
audio_pt_int=""
91
audio_win_int=""
92

    
93
# parse CC options first
94
for opt do
95
  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
96
  case "$opt" in
97
  --cross-prefix=*) cross_prefix="$optarg"
98
  ;;
99
  --cc=*) cc="$optarg"
100
  ;;
101
  --cpu=*) cpu="$optarg"
102
  ;;
103
  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
104
  ;;
105
  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
106
  ;;
107
  --sparc_cpu=*)
108
    sparc_cpu="$optarg"
109
    case $sparc_cpu in
110
    v7|v8|v8plus|v8plusa)
111
      cpu="sparc"
112
    ;;
113
    v9)
114
      cpu="sparc64"
115
    ;;
116
    *)
117
      echo "undefined SPARC architecture. Exiting";
118
      exit 1
119
    ;;
120
    esac
121
  ;;
122
  esac
123
done
124
# OS specific
125
# Using uname is really, really broken.  Once we have the right set of checks
126
# we can eliminate it's usage altogether
127

    
128
cc="${cross_prefix}${cc}"
129
ar="${cross_prefix}${ar}"
130
objcopy="${cross_prefix}${objcopy}"
131
ld="${cross_prefix}${ld}"
132
strip="${cross_prefix}${strip}"
133
windres="${cross_prefix}${windres}"
134

    
135
# default flags for all hosts
136
QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
137
CFLAGS="-g $CFLAGS"
138
QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
139
QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
140
QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
141
QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
142
QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
143
LDFLAGS="-g $LDFLAGS"
144

    
145
gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
146
gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
147
gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
148
gcc_flags="-fstack-protector-all $gcc_flags"
149
cat > $TMPC << EOF
150
int main(void) { return 0; }
151
EOF
152
for flag in $gcc_flags; do
153
    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
154
	QEMU_CFLAGS="$flag $QEMU_CFLAGS"
155
    fi
156
done
157

    
158
# check that the C compiler works.
159
cat > $TMPC <<EOF
160
int main(void) {}
161
EOF
162

    
163
if compile_object ; then
164
  : C compiler works ok
165
else
166
    echo "ERROR: \"$cc\" either does not exist or does not work"
167
    exit 1
168
fi
169

    
170
check_define() {
171
cat > $TMPC <<EOF
172
#if !defined($1)
173
#error Not defined
174
#endif
175
int main(void) { return 0; }
176
EOF
177
  compile_object
178
}
179

    
180
if test ! -z "$cpu" ; then
181
  # command line argument
182
  :
183
elif check_define __i386__ ; then
184
  cpu="i386"
185
elif check_define __x86_64__ ; then
186
  cpu="x86_64"
187
elif check_define __sparc__ ; then
188
  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
189
  # They must be specified using --sparc_cpu
190
  if check_define __arch64__ ; then
191
    cpu="sparc64"
192
  else
193
    cpu="sparc"
194
  fi
195
elif check_define _ARCH_PPC ; then
196
  if check_define _ARCH_PPC64 ; then
197
    cpu="ppc64"
198
  else
199
    cpu="ppc"
200
  fi
201
elif check_define __mips__ ; then
202
  cpu="mips"
203
elif check_define __ia64__ ; then
204
  cpu="ia64"
205
elif check_define __s390__ ; then
206
  if check_define __s390x__ ; then
207
    cpu="s390x"
208
  else
209
    cpu="s390"
210
  fi
211
else
212
  cpu=`uname -m`
213
fi
214

    
215
target_list=""
216
case "$cpu" in
217
  alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
218
    cpu="$cpu"
219
  ;;
220
  i386|i486|i586|i686|i86pc|BePC)
221
    cpu="i386"
222
  ;;
223
  x86_64|amd64)
224
    cpu="x86_64"
225
  ;;
226
  armv*b)
227
    cpu="armv4b"
228
  ;;
229
  armv*l)
230
    cpu="armv4l"
231
  ;;
232
  parisc|parisc64)
233
    cpu="hppa"
234
  ;;
235
  mips*)
236
    cpu="mips"
237
  ;;
238
  s390)
239
    cpu="s390"
240
  ;;
241
  s390x)
242
    cpu="s390x"
243
  ;;
244
  sparc|sun4[cdmuv])
245
    cpu="sparc"
246
  ;;
247
  *)
248
    echo "Unsupported CPU = $cpu"
249
    exit 1
250
  ;;
251
esac
252

    
253
# Default value for a variable defining feature "foo".
254
#  * foo="no"  feature will only be used if --enable-foo arg is given
255
#  * foo=""    feature will be searched for, and if found, will be used
256
#              unless --disable-foo is given
257
#  * foo="yes" this value will only be set by --enable-foo flag.
258
#              feature will searched for,
259
#              if not found, configure exits with error
260
#
261
# Always add --enable-foo and --disable-foo command line args.
262
# Distributions want to ensure that several features are compiled in, and it
263
# is impossible without a --enable-foo that exits if a feature is not found.
264

    
265
bluez=""
266
brlapi=""
267
curl=""
268
curses=""
269
docs=""
270
fdt=""
271
kvm=""
272
kvm_para=""
273
nptl=""
274
sdl=""
275
sparse="no"
276
uuid=""
277
vde=""
278
vnc_tls=""
279
vnc_sasl=""
280
vnc_jpeg=""
281
vnc_png=""
282
vnc_thread="no"
283
xen=""
284
linux_aio=""
285
attr=""
286
vhost_net=""
287

    
288
gprof="no"
289
debug_tcg="no"
290
debug_mon="no"
291
debug="no"
292
strip_opt="yes"
293
bigendian="no"
294
mingw32="no"
295
EXESUF=""
296
prefix="/usr/local"
297
mandir="\${prefix}/share/man"
298
datadir="\${prefix}/share/qemu"
299
docdir="\${prefix}/share/doc/qemu"
300
bindir="\${prefix}/bin"
301
sysconfdir="\${prefix}/etc"
302
confsuffix="/qemu"
303
slirp="yes"
304
fmod_lib=""
305
fmod_inc=""
306
oss_lib=""
307
bsd="no"
308
linux="no"
309
solaris="no"
310
profiler="no"
311
cocoa="no"
312
softmmu="yes"
313
linux_user="no"
314
darwin_user="no"
315
bsd_user="no"
316
guest_base=""
317
uname_release=""
318
io_thread="no"
319
mixemu="no"
320
kerneldir=""
321
aix="no"
322
haiku="no"
323
blobs="yes"
324
pkgversion=""
325
check_utests="no"
326
user_pie="no"
327
zero_malloc=""
328
trace_backend="nop"
329
trace_file="trace"
330

    
331
# OS specific
332
if check_define __linux__ ; then
333
  targetos="Linux"
334
elif check_define _WIN32 ; then
335
  targetos='MINGW32'
336
elif check_define __OpenBSD__ ; then
337
  targetos='OpenBSD'
338
elif check_define __sun__ ; then
339
  targetos='SunOS'
340
elif check_define __HAIKU__ ; then
341
  targetos='Haiku'
342
else
343
  targetos=`uname -s`
344
fi
345

    
346
case $targetos in
347
CYGWIN*)
348
  mingw32="yes"
349
  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
350
  audio_possible_drivers="winwave sdl"
351
  audio_drv_list="winwave"
352
;;
353
MINGW32*)
354
  mingw32="yes"
355
  audio_possible_drivers="winwave dsound sdl fmod"
356
  audio_drv_list="winwave"
357
;;
358
GNU/kFreeBSD)
359
  bsd="yes"
360
  audio_drv_list="oss"
361
  audio_possible_drivers="oss sdl esd pa"
362
;;
363
FreeBSD)
364
  bsd="yes"
365
  make="gmake"
366
  audio_drv_list="oss"
367
  audio_possible_drivers="oss sdl esd pa"
368
  # needed for kinfo_getvmmap(3) in libutil.h
369
  LIBS="-lutil $LIBS"
370
;;
371
DragonFly)
372
  bsd="yes"
373
  make="gmake"
374
  audio_drv_list="oss"
375
  audio_possible_drivers="oss sdl esd pa"
376
;;
377
NetBSD)
378
  bsd="yes"
379
  make="gmake"
380
  audio_drv_list="oss"
381
  audio_possible_drivers="oss sdl esd"
382
  oss_lib="-lossaudio"
383
;;
384
OpenBSD)
385
  bsd="yes"
386
  make="gmake"
387
  audio_drv_list="oss"
388
  audio_possible_drivers="oss sdl esd"
389
  oss_lib="-lossaudio"
390
;;
391
Darwin)
392
  bsd="yes"
393
  darwin="yes"
394
  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
395
  # run 64-bit userspace code
396
  if [ "$cpu" = "i386" ] ; then
397
    is_x86_64=`sysctl -n hw.optional.x86_64`
398
    [ "$is_x86_64" = "1" ] && cpu=x86_64
399
  fi
400
  if [ "$cpu" = "x86_64" ] ; then
401
    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
402
    LDFLAGS="-arch x86_64 $LDFLAGS"
403
  else
404
    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
405
  fi
406
  darwin_user="yes"
407
  cocoa="yes"
408
  audio_drv_list="coreaudio"
409
  audio_possible_drivers="coreaudio sdl fmod"
410
  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
411
  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
412
;;
413
SunOS)
414
  solaris="yes"
415
  make="gmake"
416
  install="ginstall"
417
  ld="gld"
418
  needs_libsunmath="no"
419
  solarisrev=`uname -r | cut -f2 -d.`
420
  # have to select again, because `uname -m` returns i86pc
421
  # even on an x86_64 box.
422
  solariscpu=`isainfo -k`
423
  if test "${solariscpu}" = "amd64" ; then
424
    cpu="x86_64"
425
  fi
426
  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
427
    if test "$solarisrev" -le 9 ; then
428
      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
429
        needs_libsunmath="yes"
430
        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
431
        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
432
        LIBS="-lsunmath $LIBS"
433
      else
434
        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
435
        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
436
        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
437
        echo "Studio 11 can be downloaded from www.sun.com."
438
        exit 1
439
      fi
440
    fi
441
  fi
442
  if test -f /usr/include/sys/soundcard.h ; then
443
    audio_drv_list="oss"
444
  fi
445
  audio_possible_drivers="oss sdl"
446
# needed for CMSG_ macros in sys/socket.h
447
  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
448
# needed for TIOCWIN* defines in termios.h
449
  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
450
  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
451
  LIBS="-lsocket -lnsl -lresolv $LIBS"
452
;;
453
AIX)
454
  aix="yes"
455
  make="gmake"
456
;;
457
Haiku)
458
  haiku="yes"
459
  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
460
  LIBS="-lposix_error_mapper -lnetwork $LIBS"
461
;;
462
*)
463
  audio_drv_list="oss"
464
  audio_possible_drivers="oss alsa sdl esd pa"
465
  linux="yes"
466
  linux_user="yes"
467
  usb="linux"
468
  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
469
    audio_possible_drivers="$audio_possible_drivers fmod"
470
  fi
471
;;
472
esac
473

    
474
if [ "$bsd" = "yes" ] ; then
475
  if [ "$darwin" != "yes" ] ; then
476
    usb="bsd"
477
  fi
478
  bsd_user="yes"
479
fi
480

    
481
if test "$mingw32" = "yes" ; then
482
  EXESUF=".exe"
483
  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
484
  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
485
  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
486
  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
487
  prefix="c:/Program Files/Qemu"
488
  mandir="\${prefix}"
489
  datadir="\${prefix}"
490
  docdir="\${prefix}"
491
  bindir="\${prefix}"
492
  sysconfdir="\${prefix}"
493
  confsuffix=""
494
fi
495

    
496
# find source path
497
source_path=`dirname "$0"`
498
source_path_used="no"
499
workdir=`pwd`
500
if [ -z "$source_path" ]; then
501
    source_path=$workdir
502
else
503
    source_path=`cd "$source_path"; pwd`
504
fi
505
[ -f "$workdir/vl.c" ] || source_path_used="yes"
506

    
507
werror=""
508

    
509
for opt do
510
  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
511
  case "$opt" in
512
  --help|-h) show_help=yes
513
  ;;
514
  --prefix=*) prefix="$optarg"
515
  ;;
516
  --interp-prefix=*) interp_prefix="$optarg"
517
  ;;
518
  --source-path=*) source_path="$optarg"
519
  source_path_used="yes"
520
  ;;
521
  --cross-prefix=*)
522
  ;;
523
  --cc=*)
524
  ;;
525
  --host-cc=*) host_cc="$optarg"
526
  ;;
527
  --make=*) make="$optarg"
528
  ;;
529
  --install=*) install="$optarg"
530
  ;;
531
  --extra-cflags=*)
532
  ;;
533
  --extra-ldflags=*)
534
  ;;
535
  --cpu=*)
536
  ;;
537
  --target-list=*) target_list="$optarg"
538
  ;;
539
  --trace-backend=*) trace_backend="$optarg"
540
  ;;
541
  --trace-file=*) trace_file="$optarg"
542
  ;;
543
  --enable-gprof) gprof="yes"
544
  ;;
545
  --static)
546
    static="yes"
547
    LDFLAGS="-static $LDFLAGS"
548
  ;;
549
  --mandir=*) mandir="$optarg"
550
  ;;
551
  --bindir=*) bindir="$optarg"
552
  ;;
553
  --datadir=*) datadir="$optarg"
554
  ;;
555
  --docdir=*) docdir="$optarg"
556
  ;;
557
  --sysconfdir=*) sysconfdir="$optarg"
558
  ;;
559
  --disable-sdl) sdl="no"
560
  ;;
561
  --enable-sdl) sdl="yes"
562
  ;;
563
  --fmod-lib=*) fmod_lib="$optarg"
564
  ;;
565
  --fmod-inc=*) fmod_inc="$optarg"
566
  ;;
567
  --oss-lib=*) oss_lib="$optarg"
568
  ;;
569
  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
570
  ;;
571
  --audio-drv-list=*) audio_drv_list="$optarg"
572
  ;;
573
  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
574
  ;;
575
  --enable-debug-tcg) debug_tcg="yes"
576
  ;;
577
  --disable-debug-tcg) debug_tcg="no"
578
  ;;
579
  --enable-debug-mon) debug_mon="yes"
580
  ;;
581
  --disable-debug-mon) debug_mon="no"
582
  ;;
583
  --enable-debug)
584
      # Enable debugging options that aren't excessively noisy
585
      debug_tcg="yes"
586
      debug_mon="yes"
587
      debug="yes"
588
      strip_opt="no"
589
  ;;
590
  --enable-sparse) sparse="yes"
591
  ;;
592
  --disable-sparse) sparse="no"
593
  ;;
594
  --disable-strip) strip_opt="no"
595
  ;;
596
  --disable-vnc-tls) vnc_tls="no"
597
  ;;
598
  --enable-vnc-tls) vnc_tls="yes"
599
  ;;
600
  --disable-vnc-sasl) vnc_sasl="no"
601
  ;;
602
  --enable-vnc-sasl) vnc_sasl="yes"
603
  ;;
604
  --disable-vnc-jpeg) vnc_jpeg="no"
605
  ;;
606
  --enable-vnc-jpeg) vnc_jpeg="yes"
607
  ;;
608
  --disable-vnc-png) vnc_png="no"
609
  ;;
610
  --enable-vnc-png) vnc_png="yes"
611
  ;;
612
  --disable-vnc-thread) vnc_thread="no"
613
  ;;
614
  --enable-vnc-thread) vnc_thread="yes"
615
  ;;
616
  --disable-slirp) slirp="no"
617
  ;;
618
  --disable-uuid) uuid="no"
619
  ;;
620
  --enable-uuid) uuid="yes"
621
  ;;
622
  --disable-vde) vde="no"
623
  ;;
624
  --enable-vde) vde="yes"
625
  ;;
626
  --disable-xen) xen="no"
627
  ;;
628
  --enable-xen) xen="yes"
629
  ;;
630
  --disable-brlapi) brlapi="no"
631
  ;;
632
  --enable-brlapi) brlapi="yes"
633
  ;;
634
  --disable-bluez) bluez="no"
635
  ;;
636
  --enable-bluez) bluez="yes"
637
  ;;
638
  --disable-kvm) kvm="no"
639
  ;;
640
  --enable-kvm) kvm="yes"
641
  ;;
642
  --enable-profiler) profiler="yes"
643
  ;;
644
  --enable-cocoa)
645
      cocoa="yes" ;
646
      sdl="no" ;
647
      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
648
  ;;
649
  --disable-system) softmmu="no"
650
  ;;
651
  --enable-system) softmmu="yes"
652
  ;;
653
  --disable-user)
654
      linux_user="no" ;
655
      bsd_user="no" ;
656
      darwin_user="no"
657
  ;;
658
  --enable-user) ;;
659
  --disable-linux-user) linux_user="no"
660
  ;;
661
  --enable-linux-user) linux_user="yes"
662
  ;;
663
  --disable-darwin-user) darwin_user="no"
664
  ;;
665
  --enable-darwin-user) darwin_user="yes"
666
  ;;
667
  --disable-bsd-user) bsd_user="no"
668
  ;;
669
  --enable-bsd-user) bsd_user="yes"
670
  ;;
671
  --enable-guest-base) guest_base="yes"
672
  ;;
673
  --disable-guest-base) guest_base="no"
674
  ;;
675
  --enable-user-pie) user_pie="yes"
676
  ;;
677
  --disable-user-pie) user_pie="no"
678
  ;;
679
  --enable-uname-release=*) uname_release="$optarg"
680
  ;;
681
  --sparc_cpu=*)
682
  ;;
683
  --enable-werror) werror="yes"
684
  ;;
685
  --disable-werror) werror="no"
686
  ;;
687
  --disable-curses) curses="no"
688
  ;;
689
  --enable-curses) curses="yes"
690
  ;;
691
  --disable-curl) curl="no"
692
  ;;
693
  --enable-curl) curl="yes"
694
  ;;
695
  --disable-fdt) fdt="no"
696
  ;;
697
  --enable-fdt) fdt="yes"
698
  ;;
699
  --disable-check-utests) check_utests="no"
700
  ;;
701
  --enable-check-utests) check_utests="yes"
702
  ;;
703
  --disable-nptl) nptl="no"
704
  ;;
705
  --enable-nptl) nptl="yes"
706
  ;;
707
  --enable-mixemu) mixemu="yes"
708
  ;;
709
  --disable-linux-aio) linux_aio="no"
710
  ;;
711
  --enable-linux-aio) linux_aio="yes"
712
  ;;
713
  --disable-attr) attr="no"
714
  ;;
715
  --enable-attr) attr="yes"
716
  ;;
717
  --enable-io-thread) io_thread="yes"
718
  ;;
719
  --disable-blobs) blobs="no"
720
  ;;
721
  --kerneldir=*) kerneldir="$optarg"
722
  ;;
723
  --with-pkgversion=*) pkgversion=" ($optarg)"
724
  ;;
725
  --disable-docs) docs="no"
726
  ;;
727
  --enable-docs) docs="yes"
728
  ;;
729
  --disable-vhost-net) vhost_net="no"
730
  ;;
731
  --enable-vhost-net) vhost_net="yes"
732
  ;;
733
  --*dir)
734
  ;;
735
  *) echo "ERROR: unknown option $opt"; show_help="yes"
736
  ;;
737
  esac
738
done
739

    
740
#
741
# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
742
# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
743
#
744
host_guest_base="no"
745
case "$cpu" in
746
    sparc) case $sparc_cpu in
747
           v7|v8)
748
             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
749
           ;;
750
           v8plus|v8plusa)
751
             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
752
           ;;
753
           *) # sparc_cpu not defined in the command line
754
             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
755
           esac
756
           LDFLAGS="-m32 $LDFLAGS"
757
           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
758
           if test "$solaris" = "no" ; then
759
             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
760
             helper_cflags="-ffixed-i0"
761
           fi
762
           ;;
763
    sparc64)
764
           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
765
           LDFLAGS="-m64 $LDFLAGS"
766
           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
767
           if test "$solaris" != "no" ; then
768
             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
769
           fi
770
           ;;
771
    s390)
772
           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
773
           LDFLAGS="-m31 $LDFLAGS"
774
           host_guest_base="yes"
775
           ;;
776
    s390x)
777
           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
778
           LDFLAGS="-m64 $LDFLAGS"
779
           host_guest_base="yes"
780
           ;;
781
    i386)
782
           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
783
           LDFLAGS="-m32 $LDFLAGS"
784
           helper_cflags="-fomit-frame-pointer"
785
           host_guest_base="yes"
786
           ;;
787
    x86_64)
788
           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
789
           LDFLAGS="-m64 $LDFLAGS"
790
           host_guest_base="yes"
791
           ;;
792
    arm*)
793
           host_guest_base="yes"
794
           ;;
795
    ppc*)
796
           host_guest_base="yes"
797
           ;;
798
    mips*)
799
           host_guest_base="yes"
800
           ;;
801
    ia64*)
802
           host_guest_base="yes"
803
           ;;
804
    hppa*)
805
           host_guest_base="yes"
806
           ;;
807
esac
808

    
809
[ -z "$guest_base" ] && guest_base="$host_guest_base"
810

    
811
if test x"$show_help" = x"yes" ; then
812
cat << EOF
813

    
814
Usage: configure [options]
815
Options: [defaults in brackets after descriptions]
816

    
817
EOF
818
echo "Standard options:"
819
echo "  --help                   print this message"
820
echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
821
echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
822
echo "                           use %M for cpu name [$interp_prefix]"
823
echo "  --target-list=LIST       set target list [$target_list]"
824
echo ""
825
echo "Advanced options (experts only):"
826
echo "  --source-path=PATH       path of source code [$source_path]"
827
echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
828
echo "  --cc=CC                  use C compiler CC [$cc]"
829
echo "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
830
echo "                           build time"
831
echo "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
832
echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
833
echo "  --make=MAKE              use specified make [$make]"
834
echo "  --install=INSTALL        use specified install [$install]"
835
echo "  --static                 enable static build [$static]"
836
echo "  --mandir=PATH            install man pages in PATH"
837
echo "  --datadir=PATH           install firmware in PATH"
838
echo "  --docdir=PATH            install documentation in PATH"
839
echo "  --bindir=PATH            install binaries in PATH"
840
echo "  --sysconfdir=PATH        install config in PATH/qemu"
841
echo "  --enable-debug-tcg       enable TCG debugging"
842
echo "  --disable-debug-tcg      disable TCG debugging (default)"
843
echo "  --enable-debug           enable common debug build options"
844
echo "  --enable-sparse          enable sparse checker"
845
echo "  --disable-sparse         disable sparse checker (default)"
846
echo "  --disable-strip          disable stripping binaries"
847
echo "  --disable-werror         disable compilation abort on warning"
848
echo "  --disable-sdl            disable SDL"
849
echo "  --enable-sdl             enable SDL"
850
echo "  --enable-cocoa           enable COCOA (Mac OS X only)"
851
echo "  --audio-drv-list=LIST    set audio drivers list:"
852
echo "                           Available drivers: $audio_possible_drivers"
853
echo "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
854
echo "                           Available cards: $audio_possible_cards"
855
echo "  --block-drv-whitelist=L  set block driver whitelist"
856
echo "                           (affects only QEMU, not qemu-img)"
857
echo "  --enable-mixemu          enable mixer emulation"
858
echo "  --disable-xen            disable xen backend driver support"
859
echo "  --enable-xen             enable xen backend driver support"
860
echo "  --disable-brlapi         disable BrlAPI"
861
echo "  --enable-brlapi          enable BrlAPI"
862
echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
863
echo "  --enable-vnc-tls         enable TLS encryption for VNC server"
864
echo "  --disable-vnc-sasl       disable SASL encryption for VNC server"
865
echo "  --enable-vnc-sasl        enable SASL encryption for VNC server"
866
echo "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
867
echo "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
868
echo "  --disable-vnc-png        disable PNG compression for VNC server (default)"
869
echo "  --enable-vnc-png         enable PNG compression for VNC server"
870
echo "  --disable-vnc-thread     disable threaded VNC server"
871
echo "  --enable-vnc-thread      enable threaded VNC server"
872
echo "  --disable-curses         disable curses output"
873
echo "  --enable-curses          enable curses output"
874
echo "  --disable-curl           disable curl connectivity"
875
echo "  --enable-curl            enable curl connectivity"
876
echo "  --disable-fdt            disable fdt device tree"
877
echo "  --enable-fdt             enable fdt device tree"
878
echo "  --disable-check-utests   disable check unit-tests"
879
echo "  --enable-check-utests    enable check unit-tests"
880
echo "  --disable-bluez          disable bluez stack connectivity"
881
echo "  --enable-bluez           enable bluez stack connectivity"
882
echo "  --disable-kvm            disable KVM acceleration support"
883
echo "  --enable-kvm             enable KVM acceleration support"
884
echo "  --disable-nptl           disable usermode NPTL support"
885
echo "  --enable-nptl            enable usermode NPTL support"
886
echo "  --enable-system          enable all system emulation targets"
887
echo "  --disable-system         disable all system emulation targets"
888
echo "  --enable-user            enable supported user emulation targets"
889
echo "  --disable-user           disable all user emulation targets"
890
echo "  --enable-linux-user      enable all linux usermode emulation targets"
891
echo "  --disable-linux-user     disable all linux usermode emulation targets"
892
echo "  --enable-darwin-user     enable all darwin usermode emulation targets"
893
echo "  --disable-darwin-user    disable all darwin usermode emulation targets"
894
echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
895
echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
896
echo "  --enable-guest-base      enable GUEST_BASE support for usermode"
897
echo "                           emulation targets"
898
echo "  --disable-guest-base     disable GUEST_BASE support"
899
echo "  --enable-user-pie        build usermode emulation targets as PIE"
900
echo "  --disable-user-pie       do not build usermode emulation targets as PIE"
901
echo "  --fmod-lib               path to FMOD library"
902
echo "  --fmod-inc               path to FMOD includes"
903
echo "  --oss-lib                path to OSS library"
904
echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
905
echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
906
echo "  --disable-uuid           disable uuid support"
907
echo "  --enable-uuid            enable uuid support"
908
echo "  --disable-vde            disable support for vde network"
909
echo "  --enable-vde             enable support for vde network"
910
echo "  --disable-linux-aio      disable Linux AIO support"
911
echo "  --enable-linux-aio       enable Linux AIO support"
912
echo "  --disable-attr           disables attr and xattr support"
913
echo "  --enable-attr            enable attr and xattr support"
914
echo "  --enable-io-thread       enable IO thread"
915
echo "  --disable-blobs          disable installing provided firmware blobs"
916
echo "  --kerneldir=PATH         look for kernel includes in PATH"
917
echo "  --enable-docs            enable documentation build"
918
echo "  --disable-docs           disable documentation build"
919
echo "  --disable-vhost-net      disable vhost-net acceleration support"
920
echo "  --enable-vhost-net       enable vhost-net acceleration support"
921
echo "  --trace-backend=B        Trace backend nop simple ust"
922
echo "  --trace-file=NAME        Full PATH,NAME of file to store traces"
923
echo "                           Default:trace-<pid>"
924
echo ""
925
echo "NOTE: The object files are built at the place where configure is launched"
926
exit 1
927
fi
928

    
929
#
930
# Solaris specific configure tool chain decisions
931
#
932
if test "$solaris" = "yes" ; then
933
  if has $install; then
934
    :
935
  else
936
    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
937
    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
938
    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
939
    exit 1
940
  fi
941
  if test "`path_of $install`" = "/usr/sbin/install" ; then
942
    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
943
    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
944
    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
945
    exit 1
946
  fi
947
  if has ar; then
948
    :
949
  else
950
    echo "Error: No path includes ar"
951
    if test -f /usr/ccs/bin/ar ; then
952
      echo "Add /usr/ccs/bin to your path and rerun configure"
953
    fi
954
    exit 1
955
  fi
956
fi
957

    
958

    
959
if test -z "$target_list" ; then
960
# these targets are portable
961
    if [ "$softmmu" = "yes" ] ; then
962
        target_list="\
963
i386-softmmu \
964
x86_64-softmmu \
965
arm-softmmu \
966
cris-softmmu \
967
m68k-softmmu \
968
microblaze-softmmu \
969
mips-softmmu \
970
mipsel-softmmu \
971
mips64-softmmu \
972
mips64el-softmmu \
973
ppc-softmmu \
974
ppcemb-softmmu \
975
ppc64-softmmu \
976
sh4-softmmu \
977
sh4eb-softmmu \
978
sparc-softmmu \
979
sparc64-softmmu \
980
"
981
    fi
982
# the following are Linux specific
983
    if [ "$linux_user" = "yes" ] ; then
984
        target_list="${target_list}\
985
i386-linux-user \
986
x86_64-linux-user \
987
alpha-linux-user \
988
arm-linux-user \
989
armeb-linux-user \
990
cris-linux-user \
991
m68k-linux-user \
992
microblaze-linux-user \
993
mips-linux-user \
994
mipsel-linux-user \
995
ppc-linux-user \
996
ppc64-linux-user \
997
ppc64abi32-linux-user \
998
sh4-linux-user \
999
sh4eb-linux-user \
1000
sparc-linux-user \
1001
sparc64-linux-user \
1002
sparc32plus-linux-user \
1003
"
1004
    fi
1005
# the following are Darwin specific
1006
    if [ "$darwin_user" = "yes" ] ; then
1007
        target_list="$target_list i386-darwin-user ppc-darwin-user "
1008
    fi
1009
# the following are BSD specific
1010
    if [ "$bsd_user" = "yes" ] ; then
1011
        target_list="${target_list}\
1012
i386-bsd-user \
1013
x86_64-bsd-user \
1014
sparc-bsd-user \
1015
sparc64-bsd-user \
1016
"
1017
    fi
1018
else
1019
    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
1020
fi
1021
if test -z "$target_list" ; then
1022
    echo "No targets enabled"
1023
    exit 1
1024
fi
1025
# see if system emulation was really requested
1026
case " $target_list " in
1027
  *"-softmmu "*) softmmu=yes
1028
  ;;
1029
  *) softmmu=no
1030
  ;;
1031
esac
1032

    
1033
feature_not_found() {
1034
  feature=$1
1035

    
1036
  echo "ERROR"
1037
  echo "ERROR: User requested feature $feature"
1038
  echo "ERROR: configure was not able to find it"
1039
  echo "ERROR"
1040
  exit 1;
1041
}
1042

    
1043
if test -z "$cross_prefix" ; then
1044

    
1045
# ---
1046
# big/little endian test
1047
cat > $TMPC << EOF
1048
#include <inttypes.h>
1049
int main(int argc, char ** argv){
1050
        volatile uint32_t i=0x01234567;
1051
        return (*((uint8_t*)(&i))) == 0x67;
1052
}
1053
EOF
1054

    
1055
if compile_prog "" "" ; then
1056
$TMPE && bigendian="yes"
1057
else
1058
echo big/little test failed
1059
fi
1060

    
1061
else
1062

    
1063
# if cross compiling, cannot launch a program, so make a static guess
1064
case "$cpu" in
1065
  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1066
    bigendian=yes
1067
  ;;
1068
esac
1069

    
1070
fi
1071

    
1072
# host long bits test
1073
hostlongbits="32"
1074
case "$cpu" in
1075
  x86_64|alpha|ia64|sparc64|ppc64|s390x)
1076
    hostlongbits=64
1077
  ;;
1078
esac
1079

    
1080

    
1081
##########################################
1082
# NPTL probe
1083

    
1084
if test "$nptl" != "no" ; then
1085
  cat > $TMPC <<EOF
1086
#include <sched.h>
1087
#include <linux/futex.h>
1088
void foo()
1089
{
1090
#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1091
#error bork
1092
#endif
1093
}
1094
EOF
1095

    
1096
  if compile_object ; then
1097
    nptl=yes
1098
  else
1099
    if test "$nptl" = "yes" ; then
1100
      feature_not_found "nptl"
1101
    fi
1102
    nptl=no
1103
  fi
1104
fi
1105

    
1106
##########################################
1107
# zlib check
1108

    
1109
cat > $TMPC << EOF
1110
#include <zlib.h>
1111
int main(void) { zlibVersion(); return 0; }
1112
EOF
1113
if compile_prog "" "-lz" ; then
1114
    :
1115
else
1116
    echo
1117
    echo "Error: zlib check failed"
1118
    echo "Make sure to have the zlib libs and headers installed."
1119
    echo
1120
    exit 1
1121
fi
1122

    
1123
##########################################
1124
# xen probe
1125

    
1126
if test "$xen" != "no" ; then
1127
  xen_libs="-lxenstore -lxenctrl -lxenguest"
1128
  cat > $TMPC <<EOF
1129
#include <xenctrl.h>
1130
#include <xs.h>
1131
int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1132
EOF
1133
  if compile_prog "" "$xen_libs" ; then
1134
    xen=yes
1135
    libs_softmmu="$xen_libs $libs_softmmu"
1136
  else
1137
    if test "$xen" = "yes" ; then
1138
      feature_not_found "xen"
1139
    fi
1140
    xen=no
1141
  fi
1142
fi
1143

    
1144
##########################################
1145
# pkgconfig probe
1146

    
1147
pkgconfig="${cross_prefix}pkg-config"
1148
if ! has $pkgconfig; then
1149
  # likely not cross compiling, or hope for the best
1150
  pkgconfig=pkg-config
1151
fi
1152

    
1153
##########################################
1154
# Sparse probe
1155
if test "$sparse" != "no" ; then
1156
  if has cgcc; then
1157
    sparse=yes
1158
  else
1159
    if test "$sparse" = "yes" ; then
1160
      feature_not_found "sparse"
1161
    fi
1162
    sparse=no
1163
  fi
1164
fi
1165

    
1166
##########################################
1167
# SDL probe
1168

    
1169
# Look for sdl configuration program (pkg-config or sdl-config).
1170
# Prefer variant with cross prefix if cross compiling,
1171
# and favour pkg-config with sdl over sdl-config.
1172
if test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
1173
     $pkgconfig sdl --modversion >/dev/null 2>&1; then
1174
  sdlconfig="$pkgconfig sdl"
1175
  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1176
elif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
1177
  sdlconfig="${cross_prefix}sdl-config"
1178
  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1179
elif $pkgconfig sdl --modversion >/dev/null 2>&1; then
1180
  sdlconfig="$pkgconfig sdl"
1181
  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1182
elif has sdl-config; then
1183
  sdlconfig='sdl-config'
1184
  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1185
else
1186
  if test "$sdl" = "yes" ; then
1187
    feature_not_found "sdl"
1188
  fi
1189
  sdl=no
1190
fi
1191

    
1192
sdl_too_old=no
1193
if test "$sdl" != "no" ; then
1194
  cat > $TMPC << EOF
1195
#include <SDL.h>
1196
#undef main /* We don't want SDL to override our main() */
1197
int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1198
EOF
1199
  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
1200
  if test "$static" = "yes" ; then
1201
    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
1202
  else
1203
    sdl_libs=`$sdlconfig --libs 2> /dev/null`
1204
  fi
1205
  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1206
    if test "$_sdlversion" -lt 121 ; then
1207
      sdl_too_old=yes
1208
    else
1209
      if test "$cocoa" = "no" ; then
1210
        sdl=yes
1211
      fi
1212
    fi
1213

    
1214
    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
1215
    if test "$sdl" = "yes" -a "$static" = "yes" ; then
1216
      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1217
         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1218
         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
1219
      fi
1220
      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1221
	:
1222
      else
1223
        sdl=no
1224
      fi
1225
    fi # static link
1226
  else # sdl not found
1227
    if test "$sdl" = "yes" ; then
1228
      feature_not_found "sdl"
1229
    fi
1230
    sdl=no
1231
  fi # sdl compile test
1232
fi
1233

    
1234
if test "$sdl" = "yes" ; then
1235
  cat > $TMPC <<EOF
1236
#include <SDL.h>
1237
#if defined(SDL_VIDEO_DRIVER_X11)
1238
#include <X11/XKBlib.h>
1239
#else
1240
#error No x11 support
1241
#endif
1242
int main(void) { return 0; }
1243
EOF
1244
  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1245
    sdl_libs="$sdl_libs -lX11"
1246
  fi
1247
  if test "$mingw32" = "yes" ; then
1248
    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1249
  fi
1250
  libs_softmmu="$sdl_libs $libs_softmmu"
1251
fi
1252

    
1253
##########################################
1254
# VNC TLS detection
1255
if test "$vnc_tls" != "no" ; then
1256
  cat > $TMPC <<EOF
1257
#include <gnutls/gnutls.h>
1258
int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1259
EOF
1260
  vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
1261
  vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
1262
  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1263
    vnc_tls=yes
1264
    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1265
  else
1266
    if test "$vnc_tls" = "yes" ; then
1267
      feature_not_found "vnc-tls"
1268
    fi
1269
    vnc_tls=no
1270
  fi
1271
fi
1272

    
1273
##########################################
1274
# VNC SASL detection
1275
if test "$vnc_sasl" != "no" ; then
1276
  cat > $TMPC <<EOF
1277
#include <sasl/sasl.h>
1278
#include <stdio.h>
1279
int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1280
EOF
1281
  # Assuming Cyrus-SASL installed in /usr prefix
1282
  vnc_sasl_cflags=""
1283
  vnc_sasl_libs="-lsasl2"
1284
  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1285
    vnc_sasl=yes
1286
    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1287
  else
1288
    if test "$vnc_sasl" = "yes" ; then
1289
      feature_not_found "vnc-sasl"
1290
    fi
1291
    vnc_sasl=no
1292
  fi
1293
fi
1294

    
1295
##########################################
1296
# VNC JPEG detection
1297
if test "$vnc_jpeg" != "no" ; then
1298
cat > $TMPC <<EOF
1299
#include <stdio.h>
1300
#include <jpeglib.h>
1301
int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
1302
EOF
1303
    vnc_jpeg_cflags=""
1304
    vnc_jpeg_libs="-ljpeg"
1305
  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
1306
    vnc_jpeg=yes
1307
    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1308
  else
1309
    if test "$vnc_jpeg" = "yes" ; then
1310
      feature_not_found "vnc-jpeg"
1311
    fi
1312
    vnc_jpeg=no
1313
  fi
1314
fi
1315

    
1316
##########################################
1317
# VNC PNG detection
1318
if test "$vnc_png" != "no" ; then
1319
cat > $TMPC <<EOF
1320
//#include <stdio.h>
1321
#include <png.h>
1322
int main(void) {
1323
    png_structp png_ptr;
1324
    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1325
    return 0;
1326
}
1327
EOF
1328
    vnc_png_cflags=""
1329
    vnc_png_libs="-lpng"
1330
  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1331
    vnc_png=yes
1332
    libs_softmmu="$vnc_png_libs $libs_softmmu"
1333
  else
1334
    if test "$vnc_png" = "yes" ; then
1335
      feature_not_found "vnc-png"
1336
    fi
1337
    vnc_png=no
1338
  fi
1339
fi
1340

    
1341
##########################################
1342
# fnmatch() probe, used for ACL routines
1343
fnmatch="no"
1344
cat > $TMPC << EOF
1345
#include <fnmatch.h>
1346
int main(void)
1347
{
1348
    fnmatch("foo", "foo", 0);
1349
    return 0;
1350
}
1351
EOF
1352
if compile_prog "" "" ; then
1353
   fnmatch="yes"
1354
fi
1355

    
1356
##########################################
1357
# uuid_generate() probe, used for vdi block driver
1358
if test "$uuid" != "no" ; then
1359
  uuid_libs="-luuid"
1360
  cat > $TMPC << EOF
1361
#include <uuid/uuid.h>
1362
int main(void)
1363
{
1364
    uuid_t my_uuid;
1365
    uuid_generate(my_uuid);
1366
    return 0;
1367
}
1368
EOF
1369
  if compile_prog "" "$uuid_libs" ; then
1370
    uuid="yes"
1371
    libs_softmmu="$uuid_libs $libs_softmmu"
1372
    libs_tools="$uuid_libs $libs_tools"
1373
  else
1374
    if test "$uuid" = "yes" ; then
1375
      feature_not_found "uuid"
1376
    fi
1377
    uuid=no
1378
  fi
1379
fi
1380

    
1381
##########################################
1382
# vde libraries probe
1383
if test "$vde" != "no" ; then
1384
  vde_libs="-lvdeplug"
1385
  cat > $TMPC << EOF
1386
#include <libvdeplug.h>
1387
int main(void)
1388
{
1389
    struct vde_open_args a = {0, 0, 0};
1390
    vde_open("", "", &a);
1391
    return 0;
1392
}
1393
EOF
1394
  if compile_prog "" "$vde_libs" ; then
1395
    vde=yes
1396
    libs_softmmu="$vde_libs $libs_softmmu"
1397
    libs_tools="$vde_libs $libs_tools"
1398
  else
1399
    if test "$vde" = "yes" ; then
1400
      feature_not_found "vde"
1401
    fi
1402
    vde=no
1403
  fi
1404
fi
1405

    
1406
##########################################
1407
# Sound support libraries probe
1408

    
1409
audio_drv_probe()
1410
{
1411
    drv=$1
1412
    hdr=$2
1413
    lib=$3
1414
    exp=$4
1415
    cfl=$5
1416
        cat > $TMPC << EOF
1417
#include <$hdr>
1418
int main(void) { $exp }
1419
EOF
1420
    if compile_prog "$cfl" "$lib" ; then
1421
        :
1422
    else
1423
        echo
1424
        echo "Error: $drv check failed"
1425
        echo "Make sure to have the $drv libs and headers installed."
1426
        echo
1427
        exit 1
1428
    fi
1429
}
1430

    
1431
audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1432
for drv in $audio_drv_list; do
1433
    case $drv in
1434
    alsa)
1435
    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1436
        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1437
    libs_softmmu="-lasound $libs_softmmu"
1438
    ;;
1439

    
1440
    fmod)
1441
    if test -z $fmod_lib || test -z $fmod_inc; then
1442
        echo
1443
        echo "Error: You must specify path to FMOD library and headers"
1444
        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1445
        echo
1446
        exit 1
1447
    fi
1448
    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1449
    libs_softmmu="$fmod_lib $libs_softmmu"
1450
    ;;
1451

    
1452
    esd)
1453
    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1454
    libs_softmmu="-lesd $libs_softmmu"
1455
    audio_pt_int="yes"
1456
    ;;
1457

    
1458
    pa)
1459
    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1460
        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1461
    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
1462
    audio_pt_int="yes"
1463
    ;;
1464

    
1465
    coreaudio)
1466
      libs_softmmu="-framework CoreAudio $libs_softmmu"
1467
    ;;
1468

    
1469
    dsound)
1470
      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1471
      audio_win_int="yes"
1472
    ;;
1473

    
1474
    oss)
1475
      libs_softmmu="$oss_lib $libs_softmmu"
1476
    ;;
1477

    
1478
    sdl|wav)
1479
    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1480
    ;;
1481

    
1482
    winwave)
1483
      libs_softmmu="-lwinmm $libs_softmmu"
1484
      audio_win_int="yes"
1485
    ;;
1486

    
1487
    *)
1488
    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1489
        echo
1490
        echo "Error: Unknown driver '$drv' selected"
1491
        echo "Possible drivers are: $audio_possible_drivers"
1492
        echo
1493
        exit 1
1494
    }
1495
    ;;
1496
    esac
1497
done
1498

    
1499
##########################################
1500
# BrlAPI probe
1501

    
1502
if test "$brlapi" != "no" ; then
1503
  brlapi_libs="-lbrlapi"
1504
  cat > $TMPC << EOF
1505
#include <brlapi.h>
1506
int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1507
EOF
1508
  if compile_prog "" "$brlapi_libs" ; then
1509
    brlapi=yes
1510
    libs_softmmu="$brlapi_libs $libs_softmmu"
1511
  else
1512
    if test "$brlapi" = "yes" ; then
1513
      feature_not_found "brlapi"
1514
    fi
1515
    brlapi=no
1516
  fi
1517
fi
1518

    
1519
##########################################
1520
# curses probe
1521
curses_list="-lncurses -lcurses"
1522

    
1523
if test "$curses" != "no" ; then
1524
  curses_found=no
1525
  cat > $TMPC << EOF
1526
#include <curses.h>
1527
#ifdef __OpenBSD__
1528
#define resize_term resizeterm
1529
#endif
1530
int main(void) { resize_term(0, 0); return curses_version(); }
1531
EOF
1532
  for curses_lib in $curses_list; do
1533
    if compile_prog "" "$curses_lib" ; then
1534
      curses_found=yes
1535
      libs_softmmu="$curses_lib $libs_softmmu"
1536
      break
1537
    fi
1538
  done
1539
  if test "$curses_found" = "yes" ; then
1540
    curses=yes
1541
  else
1542
    if test "$curses" = "yes" ; then
1543
      feature_not_found "curses"
1544
    fi
1545
    curses=no
1546
  fi
1547
fi
1548

    
1549
##########################################
1550
# curl probe
1551

    
1552
if $pkgconfig libcurl --modversion >/dev/null 2>&1; then
1553
  curlconfig="$pkgconfig libcurl"
1554
else
1555
  curlconfig=curl-config
1556
fi
1557

    
1558
if test "$curl" != "no" ; then
1559
  cat > $TMPC << EOF
1560
#include <curl/curl.h>
1561
int main(void) { return curl_easy_init(); }
1562
EOF
1563
  curl_cflags=`$curlconfig --cflags 2>/dev/null`
1564
  curl_libs=`$curlconfig --libs 2>/dev/null`
1565
  if compile_prog "$curl_cflags" "$curl_libs" ; then
1566
    curl=yes
1567
    libs_tools="$curl_libs $libs_tools"
1568
    libs_softmmu="$curl_libs $libs_softmmu"
1569
  else
1570
    if test "$curl" = "yes" ; then
1571
      feature_not_found "curl"
1572
    fi
1573
    curl=no
1574
  fi
1575
fi # test "$curl"
1576

    
1577
##########################################
1578
# check framework probe
1579

    
1580
if test "$check_utests" != "no" ; then
1581
  cat > $TMPC << EOF
1582
#include <check.h>
1583
int main(void) { suite_create("qemu test"); return 0; }
1584
EOF
1585
  check_libs=`$pkgconfig --libs check`
1586
  if compile_prog "" $check_libs ; then
1587
    check_utests=yes
1588
    libs_tools="$check_libs $libs_tools"
1589
  else
1590
    if test "$check_utests" = "yes" ; then
1591
      feature_not_found "check"
1592
    fi
1593
    check_utests=no
1594
  fi
1595
fi # test "$check_utests"
1596

    
1597
##########################################
1598
# bluez support probe
1599
if test "$bluez" != "no" ; then
1600
  cat > $TMPC << EOF
1601
#include <bluetooth/bluetooth.h>
1602
int main(void) { return bt_error(0); }
1603
EOF
1604
  bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
1605
  bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
1606
  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1607
    bluez=yes
1608
    libs_softmmu="$bluez_libs $libs_softmmu"
1609
  else
1610
    if test "$bluez" = "yes" ; then
1611
      feature_not_found "bluez"
1612
    fi
1613
    bluez="no"
1614
  fi
1615
fi
1616

    
1617
##########################################
1618
# kvm probe
1619
if test "$kvm" != "no" ; then
1620
    cat > $TMPC <<EOF
1621
#include <linux/kvm.h>
1622
#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1623
#error Invalid KVM version
1624
#endif
1625
#if !defined(KVM_CAP_USER_MEMORY)
1626
#error Missing KVM capability KVM_CAP_USER_MEMORY
1627
#endif
1628
#if !defined(KVM_CAP_SET_TSS_ADDR)
1629
#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1630
#endif
1631
#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1632
#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1633
#endif
1634
int main(void) { return 0; }
1635
EOF
1636
  if test "$kerneldir" != "" ; then
1637
      kvm_cflags=-I"$kerneldir"/include
1638
      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1639
         -a -d "$kerneldir/arch/x86/include" ; then
1640
            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1641
	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1642
	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1643
	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
1644
	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
1645
        elif test -d "$kerneldir/arch/$cpu/include" ; then
1646
            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1647
      fi
1648
  else
1649
    kvm_cflags=`$pkgconfig --cflags kvm-kmod 2>/dev/null`
1650
  fi
1651
  if compile_prog "$kvm_cflags" "" ; then
1652
    kvm=yes
1653
    cat > $TMPC <<EOF
1654
#include <linux/kvm_para.h>
1655
int main(void) { return 0; }
1656
EOF
1657
    if compile_prog "$kvm_cflags" "" ; then
1658
      kvm_para=yes
1659
    fi
1660
  else
1661
    if test "$kvm" = "yes" ; then
1662
      if has awk && has grep; then
1663
        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1664
	| grep "error: " \
1665
	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1666
        if test "$kvmerr" != "" ; then
1667
          echo -e "${kvmerr}\n\
1668
      NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1669
  recent kvm-kmod from http://sourceforge.net/projects/kvm."
1670
        fi
1671
      fi
1672
      feature_not_found "kvm"
1673
    fi
1674
    kvm=no
1675
  fi
1676
fi
1677

    
1678
##########################################
1679
# test for vhost net
1680

    
1681
if test "$vhost_net" != "no"; then
1682
    if test "$kvm" != "no"; then
1683
            cat > $TMPC <<EOF
1684
    #include <linux/vhost.h>
1685
    int main(void) { return 0; }
1686
EOF
1687
            if compile_prog "$kvm_cflags" "" ; then
1688
                vhost_net=yes
1689
            else
1690
                if test "$vhost_net" = "yes" ; then
1691
                    feature_not_found "vhost-net"
1692
                fi
1693
                vhost_net=no
1694
            fi
1695
    else
1696
            if test "$vhost_net" = "yes" ; then
1697
                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1698
                feature_not_found "vhost-net"
1699
            fi
1700
            vhost_net=no
1701
    fi
1702
fi
1703

    
1704
##########################################
1705
# pthread probe
1706
PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1707

    
1708
pthread=no
1709
cat > $TMPC << EOF
1710
#include <pthread.h>
1711
int main(void) { pthread_create(0,0,0,0); return 0; }
1712
EOF
1713
for pthread_lib in $PTHREADLIBS_LIST; do
1714
  if compile_prog "" "$pthread_lib" ; then
1715
    pthread=yes
1716
    LIBS="$pthread_lib $LIBS"
1717
    break
1718
  fi
1719
done
1720

    
1721
if test "$mingw32" != yes -a "$pthread" = no; then
1722
  echo
1723
  echo "Error: pthread check failed"
1724
  echo "Make sure to have the pthread libs and headers installed."
1725
  echo
1726
  exit 1
1727
fi
1728

    
1729
##########################################
1730
# linux-aio probe
1731

    
1732
if test "$linux_aio" != "no" ; then
1733
  cat > $TMPC <<EOF
1734
#include <libaio.h>
1735
#include <sys/eventfd.h>
1736
int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1737
EOF
1738
  if compile_prog "" "-laio" ; then
1739
    linux_aio=yes
1740
    libs_softmmu="$libs_softmmu -laio"
1741
    libs_tools="$libs_tools -laio"
1742
  else
1743
    if test "$linux_aio" = "yes" ; then
1744
      feature_not_found "linux AIO"
1745
    fi
1746
    linux_aio=no
1747
  fi
1748
fi
1749

    
1750
##########################################
1751
# attr probe
1752

    
1753
if test "$attr" != "no" ; then
1754
  cat > $TMPC <<EOF
1755
#include <stdio.h>
1756
#include <sys/types.h>
1757
#include <attr/xattr.h>
1758
int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1759
EOF
1760
  if compile_prog "" "-lattr" ; then
1761
    attr=yes
1762
    LIBS="-lattr $LIBS"
1763
  else
1764
    if test "$attr" = "yes" ; then
1765
      feature_not_found "ATTR"
1766
    fi
1767
    attr=no
1768
  fi
1769
fi
1770

    
1771
##########################################
1772
# iovec probe
1773
cat > $TMPC <<EOF
1774
#include <sys/types.h>
1775
#include <sys/uio.h>
1776
#include <unistd.h>
1777
int main(void) { struct iovec iov; return 0; }
1778
EOF
1779
iovec=no
1780
if compile_prog "" "" ; then
1781
  iovec=yes
1782
fi
1783

    
1784
##########################################
1785
# preadv probe
1786
cat > $TMPC <<EOF
1787
#include <sys/types.h>
1788
#include <sys/uio.h>
1789
#include <unistd.h>
1790
int main(void) { preadv; }
1791
EOF
1792
preadv=no
1793
if compile_prog "" "" ; then
1794
  preadv=yes
1795
fi
1796

    
1797
##########################################
1798
# fdt probe
1799
if test "$fdt" != "no" ; then
1800
  fdt_libs="-lfdt"
1801
  cat > $TMPC << EOF
1802
int main(void) { return 0; }
1803
EOF
1804
  if compile_prog "" "$fdt_libs" ; then
1805
    fdt=yes
1806
    libs_softmmu="$fdt_libs $libs_softmmu"
1807
  else
1808
    if test "$fdt" = "yes" ; then
1809
      feature_not_found "fdt"
1810
    fi
1811
    fdt=no
1812
  fi
1813
fi
1814

    
1815
#
1816
# Check for xxxat() functions when we are building linux-user
1817
# emulator.  This is done because older glibc versions don't
1818
# have syscall stubs for these implemented.
1819
#
1820
atfile=no
1821
cat > $TMPC << EOF
1822
#define _ATFILE_SOURCE
1823
#include <sys/types.h>
1824
#include <fcntl.h>
1825
#include <unistd.h>
1826

    
1827
int
1828
main(void)
1829
{
1830
	/* try to unlink nonexisting file */
1831
	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1832
}
1833
EOF
1834
if compile_prog "" "" ; then
1835
  atfile=yes
1836
fi
1837

    
1838
# Check for inotify functions when we are building linux-user
1839
# emulator.  This is done because older glibc versions don't
1840
# have syscall stubs for these implemented.  In that case we
1841
# don't provide them even if kernel supports them.
1842
#
1843
inotify=no
1844
cat > $TMPC << EOF
1845
#include <sys/inotify.h>
1846

    
1847
int
1848
main(void)
1849
{
1850
	/* try to start inotify */
1851
	return inotify_init();
1852
}
1853
EOF
1854
if compile_prog "" "" ; then
1855
  inotify=yes
1856
fi
1857

    
1858
inotify1=no
1859
cat > $TMPC << EOF
1860
#include <sys/inotify.h>
1861

    
1862
int
1863
main(void)
1864
{
1865
    /* try to start inotify */
1866
    return inotify_init1(0);
1867
}
1868
EOF
1869
if compile_prog "" "" ; then
1870
  inotify1=yes
1871
fi
1872

    
1873
# check if utimensat and futimens are supported
1874
utimens=no
1875
cat > $TMPC << EOF
1876
#define _ATFILE_SOURCE
1877
#define _GNU_SOURCE
1878
#include <stddef.h>
1879
#include <fcntl.h>
1880

    
1881
int main(void)
1882
{
1883
    utimensat(AT_FDCWD, "foo", NULL, 0);
1884
    futimens(0, NULL);
1885
    return 0;
1886
}
1887
EOF
1888
if compile_prog "" "" ; then
1889
  utimens=yes
1890
fi
1891

    
1892
# check if pipe2 is there
1893
pipe2=no
1894
cat > $TMPC << EOF
1895
#define _GNU_SOURCE
1896
#include <unistd.h>
1897
#include <fcntl.h>
1898

    
1899
int main(void)
1900
{
1901
    int pipefd[2];
1902
    pipe2(pipefd, O_CLOEXEC);
1903
    return 0;
1904
}
1905
EOF
1906
if compile_prog "" "" ; then
1907
  pipe2=yes
1908
fi
1909

    
1910
# check if accept4 is there
1911
accept4=no
1912
cat > $TMPC << EOF
1913
#define _GNU_SOURCE
1914
#include <sys/socket.h>
1915
#include <stddef.h>
1916

    
1917
int main(void)
1918
{
1919
    accept4(0, NULL, NULL, SOCK_CLOEXEC);
1920
    return 0;
1921
}
1922
EOF
1923
if compile_prog "" "" ; then
1924
  accept4=yes
1925
fi
1926

    
1927
# check if tee/splice is there. vmsplice was added same time.
1928
splice=no
1929
cat > $TMPC << EOF
1930
#define _GNU_SOURCE
1931
#include <unistd.h>
1932
#include <fcntl.h>
1933
#include <limits.h>
1934

    
1935
int main(void)
1936
{
1937
    int len, fd;
1938
    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1939
    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1940
    return 0;
1941
}
1942
EOF
1943
if compile_prog "" "" ; then
1944
  splice=yes
1945
fi
1946

    
1947
# check if eventfd is supported
1948
eventfd=no
1949
cat > $TMPC << EOF
1950
#include <sys/eventfd.h>
1951

    
1952
int main(void)
1953
{
1954
    int efd = eventfd(0, 0);
1955
    return 0;
1956
}
1957
EOF
1958
if compile_prog "" "" ; then
1959
  eventfd=yes
1960
fi
1961

    
1962
# check for fallocate
1963
fallocate=no
1964
cat > $TMPC << EOF
1965
#include <fcntl.h>
1966

    
1967
int main(void)
1968
{
1969
    fallocate(0, 0, 0, 0);
1970
    return 0;
1971
}
1972
EOF
1973
if compile_prog "$ARCH_CFLAGS" "" ; then
1974
  fallocate=yes
1975
fi
1976

    
1977
# check for dup3
1978
dup3=no
1979
cat > $TMPC << EOF
1980
#include <unistd.h>
1981

    
1982
int main(void)
1983
{
1984
    dup3(0, 0, 0);
1985
    return 0;
1986
}
1987
EOF
1988
if compile_prog "" "" ; then
1989
  dup3=yes
1990
fi
1991

    
1992
# Check if tools are available to build documentation.
1993
if test "$docs" != "no" ; then
1994
  if has makeinfo && has pod2man; then
1995
    docs=yes
1996
  else
1997
    if test "$docs" = "yes" ; then
1998
      feature_not_found "docs"
1999
    fi
2000
    docs=no
2001
  fi
2002
fi
2003

    
2004
# Search for bswap_32 function
2005
byteswap_h=no
2006
cat > $TMPC << EOF
2007
#include <byteswap.h>
2008
int main(void) { return bswap_32(0); }
2009
EOF
2010
if compile_prog "" "" ; then
2011
  byteswap_h=yes
2012
fi
2013

    
2014
# Search for bswap_32 function
2015
bswap_h=no
2016
cat > $TMPC << EOF
2017
#include <sys/endian.h>
2018
#include <sys/types.h>
2019
#include <machine/bswap.h>
2020
int main(void) { return bswap32(0); }
2021
EOF
2022
if compile_prog "" "" ; then
2023
  bswap_h=yes
2024
fi
2025

    
2026
##########################################
2027
# Do we need librt
2028
cat > $TMPC <<EOF
2029
#include <signal.h>
2030
#include <time.h>
2031
int main(void) { clockid_t id; return clock_gettime(id, NULL); }
2032
EOF
2033

    
2034
if compile_prog "" "" ; then
2035
  :
2036
elif compile_prog "" "-lrt" ; then
2037
  LIBS="-lrt $LIBS"
2038
fi
2039

    
2040
if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2041
        "$aix" != "yes" -a "$haiku" != "yes" ; then
2042
    libs_softmmu="-lutil $libs_softmmu"
2043
fi
2044

    
2045
##########################################
2046
# check if the compiler defines offsetof
2047

    
2048
need_offsetof=yes
2049
cat > $TMPC << EOF
2050
#include <stddef.h>
2051
int main(void) { struct s { int f; }; return offsetof(struct s, f); }
2052
EOF
2053
if compile_prog "" "" ; then
2054
    need_offsetof=no
2055
fi
2056

    
2057
##########################################
2058
# check if the compiler understands attribute warn_unused_result
2059
#
2060
# This could be smarter, but gcc -Werror does not error out even when warning
2061
# about attribute warn_unused_result
2062

    
2063
gcc_attribute_warn_unused_result=no
2064
cat > $TMPC << EOF
2065
#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2066
#error gcc 3.3 or older
2067
#endif
2068
int main(void) { return 0;}
2069
EOF
2070
if compile_prog "" ""; then
2071
    gcc_attribute_warn_unused_result=yes
2072
fi
2073

    
2074
##########################################
2075
# check if we have fdatasync
2076

    
2077
fdatasync=no
2078
cat > $TMPC << EOF
2079
#include <unistd.h>
2080
int main(void) { return fdatasync(0); }
2081
EOF
2082
if compile_prog "" "" ; then
2083
    fdatasync=yes
2084
fi
2085

    
2086
##########################################
2087
# check if we have madvise
2088

    
2089
madvise=no
2090
cat > $TMPC << EOF
2091
#include <sys/types.h>
2092
#include <sys/mman.h>
2093
int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2094
EOF
2095
if compile_prog "" "" ; then
2096
    madvise=yes
2097
fi
2098

    
2099
##########################################
2100
# check if we have posix_madvise
2101

    
2102
posix_madvise=no
2103
cat > $TMPC << EOF
2104
#include <sys/mman.h>
2105
int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2106
EOF
2107
if compile_prog "" "" ; then
2108
    posix_madvise=yes
2109
fi
2110

    
2111
##########################################
2112
# check if trace backend exists
2113

    
2114
sh "$source_path/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
2115
if test "$?" -ne 0 ; then
2116
  echo
2117
  echo "Error: invalid trace backend"
2118
  echo "Please choose a supported trace backend."
2119
  echo
2120
  exit 1
2121
fi
2122

    
2123
##########################################
2124
# For 'ust' backend, test if ust headers are present
2125
if test "$trace_backend" = "ust"; then
2126
  cat > $TMPC << EOF
2127
#include <ust/tracepoint.h>
2128
#include <ust/marker.h>
2129
int main(void) { return 0; }
2130
EOF
2131
  if compile_prog "" "" ; then
2132
    LIBS="-lust $LIBS"
2133
  else
2134
    echo
2135
    echo "Error: Trace backend 'ust' missing libust header files"
2136
    echo
2137
    exit 1
2138
  fi
2139
fi
2140
##########################################
2141
# End of CC checks
2142
# After here, no more $cc or $ld runs
2143

    
2144
if test "$debug" = "no" ; then
2145
  CFLAGS="-O2 $CFLAGS"
2146
fi
2147

    
2148
# Consult white-list to determine whether to enable werror
2149
# by default.  Only enable by default for git builds
2150
z_version=`cut -f3 -d. $source_path/VERSION`
2151

    
2152
if test -z "$werror" ; then
2153
    if test "$z_version" = "50" -a \
2154
        "$linux" = "yes" ; then
2155
        werror="yes"
2156
    else
2157
        werror="no"
2158
    fi
2159
fi
2160

    
2161
# Disable zero malloc errors for official releases unless explicitly told to
2162
# enable/disable
2163
if test -z "$zero_malloc" ; then
2164
    if test "$z_version" = "50" ; then
2165
	zero_malloc="no"
2166
    else
2167
	zero_malloc="yes"
2168
    fi
2169
fi
2170

    
2171
if test "$werror" = "yes" ; then
2172
    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2173
fi
2174

    
2175
if test "$solaris" = "no" ; then
2176
    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
2177
        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2178
    fi
2179
fi
2180

    
2181
# Use ASLR, no-SEH and DEP if available
2182
if test "$mingw32" = "yes" ; then
2183
    for flag in --dynamicbase --no-seh --nxcompat; do
2184
        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2185
            LDFLAGS="-Wl,$flag $LDFLAGS"
2186
        fi
2187
    done
2188
fi
2189

    
2190
confdir=$sysconfdir$confsuffix
2191

    
2192
tools=
2193
if test "$softmmu" = yes ; then
2194
  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2195
  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2196
      tools="qemu-nbd\$(EXESUF) $tools"
2197
    if [ "$check_utests" = "yes" ]; then
2198
      tools="check-qint check-qstring check-qdict check-qlist $tools"
2199
      tools="check-qfloat check-qjson $tools"
2200
    fi
2201
  fi
2202
fi
2203

    
2204
# Mac OS X ships with a broken assembler
2205
roms=
2206
if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2207
        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2208
        "$softmmu" = yes ; then
2209
  roms="optionrom"
2210
fi
2211

    
2212

    
2213
echo "Install prefix    $prefix"
2214
echo "BIOS directory    `eval echo $datadir`"
2215
echo "binary directory  `eval echo $bindir`"
2216
echo "config directory  `eval echo $sysconfdir`"
2217
if test "$mingw32" = "no" ; then
2218
echo "Manual directory  `eval echo $mandir`"
2219
echo "ELF interp prefix $interp_prefix"
2220
fi
2221
echo "Source path       $source_path"
2222
echo "C compiler        $cc"
2223
echo "Host C compiler   $host_cc"
2224
echo "CFLAGS            $CFLAGS"
2225
echo "QEMU_CFLAGS       $QEMU_CFLAGS"
2226
echo "LDFLAGS           $LDFLAGS"
2227
echo "make              $make"
2228
echo "install           $install"
2229
echo "host CPU          $cpu"
2230
echo "host big endian   $bigendian"
2231
echo "target list       $target_list"
2232
echo "tcg debug enabled $debug_tcg"
2233
echo "Mon debug enabled $debug_mon"
2234
echo "gprof enabled     $gprof"
2235
echo "sparse enabled    $sparse"
2236
echo "strip binaries    $strip_opt"
2237
echo "profiler          $profiler"
2238
echo "static build      $static"
2239
echo "-Werror enabled   $werror"
2240
if test "$darwin" = "yes" ; then
2241
    echo "Cocoa support     $cocoa"
2242
fi
2243
echo "SDL support       $sdl"
2244
echo "curses support    $curses"
2245
echo "curl support      $curl"
2246
echo "check support     $check_utests"
2247
echo "mingw32 support   $mingw32"
2248
echo "Audio drivers     $audio_drv_list"
2249
echo "Extra audio cards $audio_card_list"
2250
echo "Block whitelist   $block_drv_whitelist"
2251
echo "Mixer emulation   $mixemu"
2252
echo "VNC TLS support   $vnc_tls"
2253
echo "VNC SASL support  $vnc_sasl"
2254
echo "VNC JPEG support  $vnc_jpeg"
2255
echo "VNC PNG support   $vnc_png"
2256
echo "VNC thread        $vnc_thread"
2257
if test -n "$sparc_cpu"; then
2258
    echo "Target Sparc Arch $sparc_cpu"
2259
fi
2260
echo "xen support       $xen"
2261
echo "brlapi support    $brlapi"
2262
echo "bluez  support    $bluez"
2263
echo "Documentation     $docs"
2264
[ ! -z "$uname_release" ] && \
2265
echo "uname -r          $uname_release"
2266
echo "NPTL support      $nptl"
2267
echo "GUEST_BASE        $guest_base"
2268
echo "PIE user targets  $user_pie"
2269
echo "vde support       $vde"
2270
echo "IO thread         $io_thread"
2271
echo "Linux AIO support $linux_aio"
2272
echo "ATTR/XATTR support $attr"
2273
echo "Install blobs     $blobs"
2274
echo "KVM support       $kvm"
2275
echo "fdt support       $fdt"
2276
echo "preadv support    $preadv"
2277
echo "fdatasync         $fdatasync"
2278
echo "madvise           $madvise"
2279
echo "posix_madvise     $posix_madvise"
2280
echo "uuid support      $uuid"
2281
echo "vhost-net support $vhost_net"
2282
echo "Trace backend     $trace_backend"
2283
echo "Trace output file $trace_file-<pid>"
2284

    
2285
if test $sdl_too_old = "yes"; then
2286
echo "-> Your SDL version is too old - please upgrade to have SDL support"
2287
fi
2288

    
2289
config_host_mak="config-host.mak"
2290
config_host_ld="config-host.ld"
2291

    
2292
echo "# Automatically generated by configure - do not modify" > $config_host_mak
2293
printf "# Configured with:" >> $config_host_mak
2294
printf " '%s'" "$0" "$@" >> $config_host_mak
2295
echo >> $config_host_mak
2296

    
2297
echo "prefix=$prefix" >> $config_host_mak
2298
echo "bindir=$bindir" >> $config_host_mak
2299
echo "mandir=$mandir" >> $config_host_mak
2300
echo "datadir=$datadir" >> $config_host_mak
2301
echo "sysconfdir=$sysconfdir" >> $config_host_mak
2302
echo "docdir=$docdir" >> $config_host_mak
2303
echo "confdir=$confdir" >> $config_host_mak
2304

    
2305
case "$cpu" in
2306
  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2307
    ARCH=$cpu
2308
  ;;
2309
  armv4b|armv4l)
2310
    ARCH=arm
2311
  ;;
2312
esac
2313
echo "ARCH=$ARCH" >> $config_host_mak
2314
if test "$debug_tcg" = "yes" ; then
2315
  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2316
fi
2317
if test "$debug_mon" = "yes" ; then
2318
  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2319
fi
2320
if test "$debug" = "yes" ; then
2321
  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2322
fi
2323
if test "$strip_opt" = "yes" ; then
2324
  echo "STRIP=${strip}" >> $config_host_mak
2325
fi
2326
if test "$bigendian" = "yes" ; then
2327
  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
2328
fi
2329
echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
2330
if test "$mingw32" = "yes" ; then
2331
  echo "CONFIG_WIN32=y" >> $config_host_mak
2332
  rc_version=`cat $source_path/VERSION`
2333
  version_major=${rc_version%%.*}
2334
  rc_version=${rc_version#*.}
2335
  version_minor=${rc_version%%.*}
2336
  rc_version=${rc_version#*.}
2337
  version_subminor=${rc_version%%.*}
2338
  version_micro=0
2339
  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2340
  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2341
else
2342
  echo "CONFIG_POSIX=y" >> $config_host_mak
2343
fi
2344

    
2345
if test "$linux" = "yes" ; then
2346
  echo "CONFIG_LINUX=y" >> $config_host_mak
2347
fi
2348

    
2349
if test "$darwin" = "yes" ; then
2350
  echo "CONFIG_DARWIN=y" >> $config_host_mak
2351
fi
2352

    
2353
if test "$aix" = "yes" ; then
2354
  echo "CONFIG_AIX=y" >> $config_host_mak
2355
fi
2356

    
2357
if test "$solaris" = "yes" ; then
2358
  echo "CONFIG_SOLARIS=y" >> $config_host_mak
2359
  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
2360
  if test "$needs_libsunmath" = "yes" ; then
2361
    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
2362
  fi
2363
fi
2364
if test "$haiku" = "yes" ; then
2365
  echo "CONFIG_HAIKU=y" >> $config_host_mak
2366
fi
2367
if test "$static" = "yes" ; then
2368
  echo "CONFIG_STATIC=y" >> $config_host_mak
2369
fi
2370
if test $profiler = "yes" ; then
2371
  echo "CONFIG_PROFILER=y" >> $config_host_mak
2372
fi
2373
if test "$slirp" = "yes" ; then
2374
  echo "CONFIG_SLIRP=y" >> $config_host_mak
2375
  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
2376
fi
2377
if test "$vde" = "yes" ; then
2378
  echo "CONFIG_VDE=y" >> $config_host_mak
2379
fi
2380
for card in $audio_card_list; do
2381
    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
2382
    echo "$def=y" >> $config_host_mak
2383
done
2384
echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
2385
for drv in $audio_drv_list; do
2386
    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
2387
    echo "$def=y" >> $config_host_mak
2388
    if test "$drv" = "fmod"; then
2389
        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2390
    fi
2391
done
2392
if test "$audio_pt_int" = "yes" ; then
2393
  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
2394
fi
2395
if test "$audio_win_int" = "yes" ; then
2396
  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2397
fi
2398
echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
2399
if test "$mixemu" = "yes" ; then
2400
  echo "CONFIG_MIXEMU=y" >> $config_host_mak
2401
fi
2402
if test "$vnc_tls" = "yes" ; then
2403
  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2404
  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
2405
fi
2406
if test "$vnc_sasl" = "yes" ; then
2407
  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2408
  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
2409
fi
2410
if test "$vnc_jpeg" != "no" ; then
2411
  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2412
  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
2413
fi
2414
if test "$vnc_png" != "no" ; then
2415
  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2416
  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2417
fi
2418
if test "$vnc_thread" != "no" ; then
2419
  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2420
  echo "CONFIG_THREAD=y" >> $config_host_mak
2421
fi
2422
if test "$fnmatch" = "yes" ; then
2423
  echo "CONFIG_FNMATCH=y" >> $config_host_mak
2424
fi
2425
if test "$uuid" = "yes" ; then
2426
  echo "CONFIG_UUID=y" >> $config_host_mak
2427
fi
2428
qemu_version=`head $source_path/VERSION`
2429
echo "VERSION=$qemu_version" >>$config_host_mak
2430
echo "PKGVERSION=$pkgversion" >>$config_host_mak
2431
echo "SRC_PATH=$source_path" >> $config_host_mak
2432
echo "TARGET_DIRS=$target_list" >> $config_host_mak
2433
if [ "$docs" = "yes" ] ; then
2434
  echo "BUILD_DOCS=yes" >> $config_host_mak
2435
fi
2436
if test "$sdl" = "yes" ; then
2437
  echo "CONFIG_SDL=y" >> $config_host_mak
2438
  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
2439
fi
2440
if test "$cocoa" = "yes" ; then
2441
  echo "CONFIG_COCOA=y" >> $config_host_mak
2442
fi
2443
if test "$curses" = "yes" ; then
2444
  echo "CONFIG_CURSES=y" >> $config_host_mak
2445
fi
2446
if test "$atfile" = "yes" ; then
2447
  echo "CONFIG_ATFILE=y" >> $config_host_mak
2448
fi
2449
if test "$utimens" = "yes" ; then
2450
  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2451
fi
2452
if test "$pipe2" = "yes" ; then
2453
  echo "CONFIG_PIPE2=y" >> $config_host_mak
2454
fi
2455
if test "$accept4" = "yes" ; then
2456
  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
2457
fi
2458
if test "$splice" = "yes" ; then
2459
  echo "CONFIG_SPLICE=y" >> $config_host_mak
2460
fi
2461
if test "$eventfd" = "yes" ; then
2462
  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2463
fi
2464
if test "$fallocate" = "yes" ; then
2465
  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2466
fi
2467
if test "$dup3" = "yes" ; then
2468
  echo "CONFIG_DUP3=y" >> $config_host_mak
2469
fi
2470
if test "$inotify" = "yes" ; then
2471
  echo "CONFIG_INOTIFY=y" >> $config_host_mak
2472
fi
2473
if test "$inotify1" = "yes" ; then
2474
  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2475
fi
2476
if test "$byteswap_h" = "yes" ; then
2477
  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
2478
fi
2479
if test "$bswap_h" = "yes" ; then
2480
  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
2481
fi
2482
if test "$curl" = "yes" ; then
2483
  echo "CONFIG_CURL=y" >> $config_host_mak
2484
  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2485
fi
2486
if test "$brlapi" = "yes" ; then
2487
  echo "CONFIG_BRLAPI=y" >> $config_host_mak
2488
fi
2489
if test "$bluez" = "yes" ; then
2490
  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2491
  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2492
fi
2493
if test "$xen" = "yes" ; then
2494
  echo "CONFIG_XEN=y" >> $config_host_mak
2495
fi
2496
if test "$io_thread" = "yes" ; then
2497
  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2498
  echo "CONFIG_THREAD=y" >> $config_host_mak
2499
fi
2500
if test "$linux_aio" = "yes" ; then
2501
  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
2502
fi
2503
if test "$attr" = "yes" ; then
2504
  echo "CONFIG_ATTR=y" >> $config_host_mak
2505
fi
2506
if test "$linux" = "yes" ; then
2507
  if test "$attr" = "yes" ; then
2508
    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2509
  fi
2510
fi
2511
if test "$blobs" = "yes" ; then
2512
  echo "INSTALL_BLOBS=yes" >> $config_host_mak
2513
fi
2514
if test "$iovec" = "yes" ; then
2515
  echo "CONFIG_IOVEC=y" >> $config_host_mak
2516
fi
2517
if test "$preadv" = "yes" ; then
2518
  echo "CONFIG_PREADV=y" >> $config_host_mak
2519
fi
2520
if test "$fdt" = "yes" ; then
2521
  echo "CONFIG_FDT=y" >> $config_host_mak
2522
fi
2523
if test "$need_offsetof" = "yes" ; then
2524
  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2525
fi
2526
if test "$gcc_attribute_warn_unused_result" = "yes" ; then
2527
  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2528
fi
2529
if test "$fdatasync" = "yes" ; then
2530
  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
2531
fi
2532
if test "$madvise" = "yes" ; then
2533
  echo "CONFIG_MADVISE=y" >> $config_host_mak
2534
fi
2535
if test "$posix_madvise" = "yes" ; then
2536
  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2537
fi
2538

    
2539
# XXX: suppress that
2540
if [ "$bsd" = "yes" ] ; then
2541
  echo "CONFIG_BSD=y" >> $config_host_mak
2542
fi
2543

    
2544
echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2545

    
2546
if test "$zero_malloc" = "yes" ; then
2547
  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
2548
fi
2549

    
2550
# USB host support
2551
case "$usb" in
2552
linux)
2553
  echo "HOST_USB=linux" >> $config_host_mak
2554
;;
2555
bsd)
2556
  echo "HOST_USB=bsd" >> $config_host_mak
2557
;;
2558
*)
2559
  echo "HOST_USB=stub" >> $config_host_mak
2560
;;
2561
esac
2562

    
2563
echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
2564
if test "$trace_backend" = "simple"; then
2565
  echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
2566
fi
2567
# Set the appropriate trace file.
2568
if test "$trace_backend" = "simple"; then
2569
  trace_file="\"$trace_file-%u\""
2570
fi
2571
echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
2572

    
2573
echo "TOOLS=$tools" >> $config_host_mak
2574
echo "ROMS=$roms" >> $config_host_mak
2575
echo "MAKE=$make" >> $config_host_mak
2576
echo "INSTALL=$install" >> $config_host_mak
2577
echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2578
echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2579
echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2580
echo "CC=$cc" >> $config_host_mak
2581
echo "HOST_CC=$host_cc" >> $config_host_mak
2582
if test "$sparse" = "yes" ; then
2583
  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2584
  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2585
  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2586
fi
2587
echo "AR=$ar" >> $config_host_mak
2588
echo "OBJCOPY=$objcopy" >> $config_host_mak
2589
echo "LD=$ld" >> $config_host_mak
2590
echo "WINDRES=$windres" >> $config_host_mak
2591
echo "CFLAGS=$CFLAGS" >> $config_host_mak
2592
echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2593
echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2594
echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
2595
echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2596
echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
2597
echo "LIBS+=$LIBS" >> $config_host_mak
2598
echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2599
echo "EXESUF=$EXESUF" >> $config_host_mak
2600

    
2601
# generate list of library paths for linker script
2602

    
2603
$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
2604

    
2605
if test -f ${config_host_ld}~ ; then
2606
  if cmp -s $config_host_ld ${config_host_ld}~ ; then
2607
    mv ${config_host_ld}~ $config_host_ld
2608
  else
2609
    rm ${config_host_ld}~
2610
  fi
2611
fi
2612

    
2613
for d in libdis libdis-user; do
2614
    mkdir -p $d
2615
    rm -f $d/Makefile
2616
    ln -s $source_path/Makefile.dis $d/Makefile
2617
    echo > $d/config.mak
2618
done
2619
if test "$static" = "no" -a "$user_pie" = "yes" ; then
2620
  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2621
fi
2622

    
2623
for target in $target_list; do
2624
target_dir="$target"
2625
config_target_mak=$target_dir/config-target.mak
2626
target_arch2=`echo $target | cut -d '-' -f 1`
2627
target_bigendian="no"
2628

    
2629
case "$target_arch2" in
2630
  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2631
  target_bigendian=yes
2632
  ;;
2633
esac
2634
target_softmmu="no"
2635
target_user_only="no"
2636
target_linux_user="no"
2637
target_darwin_user="no"
2638
target_bsd_user="no"
2639
case "$target" in
2640
  ${target_arch2}-softmmu)
2641
    target_softmmu="yes"
2642
    ;;
2643
  ${target_arch2}-linux-user)
2644
    if test "$linux" != "yes" ; then
2645
      echo "ERROR: Target '$target' is only available on a Linux host"
2646
      exit 1
2647
    fi
2648
    target_user_only="yes"
2649
    target_linux_user="yes"
2650
    ;;
2651
  ${target_arch2}-darwin-user)
2652
    if test "$darwin" != "yes" ; then
2653
      echo "ERROR: Target '$target' is only available on a Darwin host"
2654
      exit 1
2655
    fi
2656
    target_user_only="yes"
2657
    target_darwin_user="yes"
2658
    ;;
2659
  ${target_arch2}-bsd-user)
2660
    if test "$bsd" != "yes" ; then
2661
      echo "ERROR: Target '$target' is only available on a BSD host"
2662
      exit 1
2663
    fi
2664
    target_user_only="yes"
2665
    target_bsd_user="yes"
2666
    ;;
2667
  *)
2668
    echo "ERROR: Target '$target' not recognised"
2669
    exit 1
2670
    ;;
2671
esac
2672

    
2673
mkdir -p $target_dir
2674
mkdir -p $target_dir/fpu
2675
mkdir -p $target_dir/tcg
2676
mkdir -p $target_dir/ide
2677
if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
2678
  mkdir -p $target_dir/nwfpe
2679
fi
2680

    
2681
#
2682
# don't use ln -sf as not all "ln -sf" over write the file/link
2683
#
2684
rm -f $target_dir/Makefile
2685
ln -s $source_path/Makefile.target $target_dir/Makefile
2686

    
2687

    
2688
echo "# Automatically generated by configure - do not modify" > $config_target_mak
2689

    
2690
bflt="no"
2691
target_nptl="no"
2692
interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
2693
echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
2694
gdb_xml_files=""
2695

    
2696
TARGET_ARCH="$target_arch2"
2697
TARGET_BASE_ARCH=""
2698
TARGET_ABI_DIR=""
2699

    
2700
case "$target_arch2" in
2701
  i386)
2702
    target_phys_bits=32
2703
  ;;
2704
  x86_64)
2705
    TARGET_BASE_ARCH=i386
2706
    target_phys_bits=64
2707
  ;;
2708
  alpha)
2709
    target_phys_bits=64
2710
    target_nptl="yes"
2711
  ;;
2712
  arm|armeb)
2713
    TARGET_ARCH=arm
2714
    bflt="yes"
2715
    target_nptl="yes"
2716
    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2717
    target_phys_bits=32
2718
  ;;
2719
  cris)
2720
    target_nptl="yes"
2721
    target_phys_bits=32
2722
  ;;
2723
  m68k)
2724
    bflt="yes"
2725
    gdb_xml_files="cf-core.xml cf-fp.xml"
2726
    target_phys_bits=32
2727
  ;;
2728
  microblaze)
2729
    bflt="yes"
2730
    target_nptl="yes"
2731
    target_phys_bits=32
2732
  ;;
2733
  mips|mipsel)
2734
    TARGET_ARCH=mips
2735
    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2736
    target_nptl="yes"
2737
    target_phys_bits=64
2738
  ;;
2739
  mipsn32|mipsn32el)
2740
    TARGET_ARCH=mipsn32
2741
    TARGET_BASE_ARCH=mips
2742
    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
2743
    target_phys_bits=64
2744
  ;;
2745
  mips64|mips64el)
2746
    TARGET_ARCH=mips64
2747
    TARGET_BASE_ARCH=mips
2748
    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2749
    target_phys_bits=64
2750
  ;;
2751
  ppc)
2752
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2753
    target_phys_bits=32
2754
    target_nptl="yes"
2755
  ;;
2756
  ppcemb)
2757
    TARGET_BASE_ARCH=ppc
2758
    TARGET_ABI_DIR=ppc
2759
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2760
    target_phys_bits=64
2761
    target_nptl="yes"
2762
  ;;
2763
  ppc64)
2764
    TARGET_BASE_ARCH=ppc
2765
    TARGET_ABI_DIR=ppc
2766
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2767
    target_phys_bits=64
2768
  ;;
2769
  ppc64abi32)
2770
    TARGET_ARCH=ppc64
2771
    TARGET_BASE_ARCH=ppc
2772
    TARGET_ABI_DIR=ppc
2773
    echo "TARGET_ABI32=y" >> $config_target_mak
2774
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2775
    target_phys_bits=64
2776
  ;;
2777
  sh4|sh4eb)
2778
    TARGET_ARCH=sh4
2779
    bflt="yes"
2780
    target_nptl="yes"
2781
    target_phys_bits=32
2782
  ;;
2783
  sparc)
2784
    target_phys_bits=64
2785
  ;;
2786
  sparc64)
2787
    TARGET_BASE_ARCH=sparc
2788
    target_phys_bits=64
2789
  ;;
2790
  sparc32plus)
2791
    TARGET_ARCH=sparc64
2792
    TARGET_BASE_ARCH=sparc
2793
    TARGET_ABI_DIR=sparc
2794
    echo "TARGET_ABI32=y" >> $config_target_mak
2795
    target_phys_bits=64
2796
  ;;
2797
  s390x)
2798
    target_phys_bits=64
2799
  ;;
2800
  *)
2801
    echo "Unsupported target CPU"
2802
    exit 1
2803
  ;;
2804
esac
2805
echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2806
target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
2807
echo "TARGET_$target_arch_name=y" >> $config_target_mak
2808
echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
2809
# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
2810
if [ "$TARGET_BASE_ARCH" = "" ]; then
2811
  TARGET_BASE_ARCH=$TARGET_ARCH
2812
fi
2813
echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2814
if [ "$TARGET_ABI_DIR" = "" ]; then
2815
  TARGET_ABI_DIR=$TARGET_ARCH
2816
fi
2817
echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
2818
case "$target_arch2" in
2819
  i386|x86_64)
2820
    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2821
      echo "CONFIG_XEN=y" >> $config_target_mak
2822
    fi
2823
esac
2824
case "$target_arch2" in
2825
  i386|x86_64|ppcemb|ppc|ppc64|s390x)
2826
    # Make sure the target and host cpus are compatible
2827
    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2828
      \( "$target_arch2" = "$cpu" -o \
2829
      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2830
      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2831
      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2832
      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
2833
      echo "CONFIG_KVM=y" >> $config_target_mak
2834
      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2835
      if test "$kvm_para" = "yes"; then
2836
        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
2837
      fi
2838
      if test $vhost_net = "yes" ; then
2839
        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
2840
      fi
2841
    fi
2842
esac
2843
if test "$target_bigendian" = "yes" ; then
2844
  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
2845
fi
2846
if test "$target_softmmu" = "yes" ; then
2847
  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
2848
  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
2849
  echo "LIBS+=$libs_softmmu" >> $config_target_mak
2850
  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
2851
  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2852
fi
2853
if test "$target_user_only" = "yes" ; then
2854
  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2855
fi
2856
if test "$target_linux_user" = "yes" ; then
2857
  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2858
fi
2859
if test "$target_darwin_user" = "yes" ; then
2860
  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2861
fi
2862
list=""
2863
if test ! -z "$gdb_xml_files" ; then
2864
  for x in $gdb_xml_files; do
2865
    list="$list $source_path/gdb-xml/$x"
2866
  done
2867
  echo "TARGET_XML_FILES=$list" >> $config_target_mak
2868
fi
2869

    
2870
case "$target_arch2" in
2871
  alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
2872
    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2873
    ;;
2874
  *)
2875
    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2876
    ;;
2877
esac
2878

    
2879
if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2880
  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2881
fi
2882
if test "$target_user_only" = "yes" \
2883
        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2884
  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2885
fi
2886
if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2887
  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2888
fi
2889
if test "$target_bsd_user" = "yes" ; then
2890
  echo "CONFIG_BSD_USER=y" >> $config_target_mak
2891
fi
2892

    
2893
# generate QEMU_CFLAGS/LDFLAGS for targets
2894

    
2895
cflags=""
2896
ldflags=""
2897

    
2898
if test "$ARCH" = "sparc64" ; then
2899
  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
2900
elif test "$ARCH" = "s390x" ; then
2901
  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
2902
elif test "$ARCH" = "x86_64" ; then
2903
  cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
2904
else
2905
  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
2906
fi
2907
cflags="-I\$(SRC_PATH)/tcg $cflags"
2908
cflags="-I\$(SRC_PATH)/fpu $cflags"
2909

    
2910
if test "$target_user_only" = "yes" ; then
2911
    libdis_config_mak=libdis-user/config.mak
2912
else
2913
    libdis_config_mak=libdis/config.mak
2914
fi
2915

    
2916
for i in $ARCH $TARGET_BASE_ARCH ; do
2917
  case "$i" in
2918
  alpha)
2919
    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
2920
    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
2921
  ;;
2922
  arm)
2923
    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
2924
    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
2925
  ;;
2926
  cris)
2927
    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
2928
    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
2929
  ;;
2930
  hppa)
2931
    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
2932
    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
2933
  ;;
2934
  i386|x86_64)
2935
    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
2936
    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
2937
  ;;
2938
  ia64*)
2939
    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
2940
    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
2941
  ;;
2942
  m68k)
2943
    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
2944
    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
2945
  ;;
2946
  microblaze)
2947
    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
2948
    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
2949
  ;;
2950
  mips*)
2951
    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
2952
    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
2953
  ;;
2954
  ppc*)
2955
    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
2956
    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
2957
  ;;
2958
  s390*)
2959
    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
2960
    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
2961
  ;;
2962
  sh4)
2963
    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
2964
    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
2965
  ;;
2966
  sparc*)
2967
    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
2968
    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
2969
  ;;
2970
  esac
2971
done
2972

    
2973
case "$ARCH" in
2974
alpha)
2975
  # Ensure there's only a single GP
2976
  cflags="-msmall-data $cflags"
2977
;;
2978
esac
2979

    
2980
if test "$target_softmmu" = "yes" ; then
2981
  case "$TARGET_BASE_ARCH" in
2982
  arm)
2983
    cflags="-DHAS_AUDIO $cflags"
2984
  ;;
2985
  i386|mips|ppc)
2986
    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
2987
  ;;
2988
  esac
2989
fi
2990

    
2991
if test "$target_user_only" = "yes" -a "$static" = "no" -a \
2992
	"$user_pie" = "yes" ; then
2993
  cflags="-fpie $cflags"
2994
  ldflags="-pie $ldflags"
2995
fi
2996

    
2997
if test "$target_softmmu" = "yes" -a \( \
2998
        "$TARGET_ARCH" = "microblaze" -o \
2999
        "$TARGET_ARCH" = "cris" \) ; then
3000
  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3001
fi
3002

    
3003
if test "$gprof" = "yes" ; then
3004
  echo "TARGET_GPROF=yes" >> $config_target_mak
3005
  if test "$target_linux_user" = "yes" ; then
3006
    cflags="-p $cflags"
3007
    ldflags="-p $ldflags"
3008
  fi
3009
  if test "$target_softmmu" = "yes" ; then
3010
    ldflags="-p $ldflags"
3011
    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3012
  fi
3013
fi
3014

    
3015
linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
3016
if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3017
  case "$ARCH" in
3018
  sparc)
3019
    # -static is used to avoid g1/g3 usage by the dynamic linker
3020
    ldflags="$linker_script -static $ldflags"
3021
    ;;
3022
  alpha | s390x)
3023
    # The default placement of the application is fine.
3024
    ;;
3025
  *)
3026
    ldflags="$linker_script $ldflags"
3027
    ;;
3028
  esac
3029
fi
3030

    
3031
echo "LDFLAGS+=$ldflags" >> $config_target_mak
3032
echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3033

    
3034
done # for target in $targets
3035

    
3036
# build tree in object directory if source path is different from current one
3037
if test "$source_path_used" = "yes" ; then
3038
    DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3039
    DIRS="$DIRS roms/seabios roms/vgabios"
3040
    DIRS="$DIRS fsdev ui"
3041
    FILES="Makefile tests/Makefile"
3042
    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3043
    FILES="$FILES tests/test-mmap.c"
3044
    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
3045
    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
3046
    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
3047
        FILES="$FILES pc-bios/`basename $bios_file`"
3048
    done
3049
    for dir in $DIRS ; do
3050
            mkdir -p $dir
3051
    done
3052
    # remove the link and recreate it, as not all "ln -sf" overwrite the link
3053
    for f in $FILES ; do
3054
        rm -f $f
3055
        ln -s $source_path/$f $f
3056
    done
3057
fi
3058

    
3059
# temporary config to build submodules
3060
for rom in seabios vgabios ; do
3061
    config_mak=roms/$rom/config.mak
3062
    echo "# Automatically generated by configure - do not modify" > $config_mak
3063
    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3064
    echo "CC=$cc" >> $config_mak
3065
    echo "BCC=bcc" >> $config_mak
3066
    echo "CPP=${cross_prefix}cpp" >> $config_mak
3067
    echo "OBJCOPY=objcopy" >> $config_mak
3068
    echo "IASL=iasl" >> $config_mak
3069
    echo "HOST_CC=$host_cc" >> $config_mak
3070
    echo "LD=$ld" >> $config_mak
3071
done
3072

    
3073
for hwlib in 32 64; do
3074
  d=libhw$hwlib
3075
  mkdir -p $d
3076
  mkdir -p $d/ide
3077
  rm -f $d/Makefile
3078
  ln -s $source_path/Makefile.hw $d/Makefile
3079
  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
3080
done
3081

    
3082
d=libuser
3083
mkdir -p $d
3084
rm -f $d/Makefile
3085
ln -s $source_path/Makefile.user $d/Makefile
3086
if test "$static" = "no" -a "$user_pie" = "yes" ; then
3087
  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3088
fi
3089

    
3090
if test "$docs" = "yes" ; then
3091
  mkdir -p QMP
3092
fi