Statistics
| Branch: | Revision:

root / configure @ 2834c3e0

History | View | Annotate | Download (80.4 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
rm -f config.log
22

    
23
compile_object() {
24
  echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
25
  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
26
}
27

    
28
compile_prog() {
29
  local_cflags="$1"
30
  local_ldflags="$2"
31
  echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
32
  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
33
}
34

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

    
41
# search for an executable in PATH
42
path_of() {
43
    local_command="$1"
44
    local_ifs="$IFS"
45
    local_dir=""
46

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

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

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

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

    
132
cc="${cross_prefix}${cc}"
133
ar="${cross_prefix}${ar}"
134
objcopy="${cross_prefix}${objcopy}"
135
ld="${cross_prefix}${ld}"
136
strip="${cross_prefix}${strip}"
137
windres="${cross_prefix}${windres}"
138

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

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

    
162
# check that the C compiler works.
163
cat > $TMPC <<EOF
164
int main(void) {}
165
EOF
166

    
167
if compile_object ; then
168
  : C compiler works ok
169
else
170
    echo "ERROR: \"$cc\" either does not exist or does not work"
171
    exit 1
172
fi
173

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

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

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

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

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

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

    
336
# OS specific
337
if check_define __linux__ ; then
338
  targetos="Linux"
339
elif check_define _WIN32 ; then
340
  targetos='MINGW32'
341
elif check_define __OpenBSD__ ; then
342
  targetos='OpenBSD'
343
elif check_define __sun__ ; then
344
  targetos='SunOS'
345
elif check_define __HAIKU__ ; then
346
  targetos='Haiku'
347
else
348
  targetos=`uname -s`
349
fi
350

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

    
479
if [ "$bsd" = "yes" ] ; then
480
  if [ "$darwin" != "yes" ] ; then
481
    usb="bsd"
482
  fi
483
  bsd_user="yes"
484
fi
485

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

    
501
# find source path
502
source_path=`dirname "$0"`
503
source_path_used="no"
504
workdir=`pwd`
505
if [ -z "$source_path" ]; then
506
    source_path=$workdir
507
else
508
    source_path=`cd "$source_path"; pwd`
509
fi
510
[ -f "$workdir/vl.c" ] || source_path_used="yes"
511

    
512
werror=""
513

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

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

    
820
[ -z "$guest_base" ] && guest_base="$host_guest_base"
821

    
822
if test x"$show_help" = x"yes" ; then
823
cat << EOF
824

    
825
Usage: configure [options]
826
Options: [defaults in brackets after descriptions]
827

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

    
942
#
943
# Solaris specific configure tool chain decisions
944
#
945
if test "$solaris" = "yes" ; then
946
  if has $install; then
947
    :
948
  else
949
    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
950
    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
951
    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
952
    exit 1
953
  fi
954
  if test "`path_of $install`" = "/usr/sbin/install" ; then
955
    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
956
    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
957
    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
958
    exit 1
959
  fi
960
  if has ar; then
961
    :
962
  else
963
    echo "Error: No path includes ar"
964
    if test -f /usr/ccs/bin/ar ; then
965
      echo "Add /usr/ccs/bin to your path and rerun configure"
966
    fi
967
    exit 1
968
  fi
969
fi
970

    
971

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

    
1046
feature_not_found() {
1047
  feature=$1
1048

    
1049
  echo "ERROR"
1050
  echo "ERROR: User requested feature $feature"
1051
  echo "ERROR: configure was not able to find it"
1052
  echo "ERROR"
1053
  exit 1;
1054
}
1055

    
1056
if test -z "$cross_prefix" ; then
1057

    
1058
# ---
1059
# big/little endian test
1060
cat > $TMPC << EOF
1061
#include <inttypes.h>
1062
int main(int argc, char ** argv){
1063
        volatile uint32_t i=0x01234567;
1064
        return (*((uint8_t*)(&i))) == 0x67;
1065
}
1066
EOF
1067

    
1068
if compile_prog "" "" ; then
1069
$TMPE && bigendian="yes"
1070
else
1071
echo big/little test failed
1072
fi
1073

    
1074
else
1075

    
1076
# if cross compiling, cannot launch a program, so make a static guess
1077
case "$cpu" in
1078
  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1079
    bigendian=yes
1080
  ;;
1081
esac
1082

    
1083
fi
1084

    
1085
# host long bits test
1086
hostlongbits="32"
1087
case "$cpu" in
1088
  x86_64|alpha|ia64|sparc64|ppc64|s390x)
1089
    hostlongbits=64
1090
  ;;
1091
esac
1092

    
1093

    
1094
##########################################
1095
# NPTL probe
1096

    
1097
if test "$nptl" != "no" ; then
1098
  cat > $TMPC <<EOF
1099
#include <sched.h>
1100
#include <linux/futex.h>
1101
void foo()
1102
{
1103
#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1104
#error bork
1105
#endif
1106
}
1107
EOF
1108

    
1109
  if compile_object ; then
1110
    nptl=yes
1111
  else
1112
    if test "$nptl" = "yes" ; then
1113
      feature_not_found "nptl"
1114
    fi
1115
    nptl=no
1116
  fi
1117
fi
1118

    
1119
##########################################
1120
# zlib check
1121

    
1122
cat > $TMPC << EOF
1123
#include <zlib.h>
1124
int main(void) { zlibVersion(); return 0; }
1125
EOF
1126
if compile_prog "" "-lz" ; then
1127
    :
1128
else
1129
    echo
1130
    echo "Error: zlib check failed"
1131
    echo "Make sure to have the zlib libs and headers installed."
1132
    echo
1133
    exit 1
1134
fi
1135

    
1136
##########################################
1137
# xen probe
1138

    
1139
if test "$xen" != "no" ; then
1140
  xen_libs="-lxenstore -lxenctrl -lxenguest"
1141
  cat > $TMPC <<EOF
1142
#include <xenctrl.h>
1143
#include <xs.h>
1144
int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1145
EOF
1146
  if compile_prog "" "$xen_libs" ; then
1147
    xen=yes
1148
    libs_softmmu="$xen_libs $libs_softmmu"
1149
  else
1150
    if test "$xen" = "yes" ; then
1151
      feature_not_found "xen"
1152
    fi
1153
    xen=no
1154
  fi
1155
fi
1156

    
1157
##########################################
1158
# pkgconfig probe
1159

    
1160
pkgconfig="${cross_prefix}pkg-config"
1161
if ! has $pkgconfig; then
1162
  # likely not cross compiling, or hope for the best
1163
  pkgconfig=pkg-config
1164
fi
1165

    
1166
##########################################
1167
# Sparse probe
1168
if test "$sparse" != "no" ; then
1169
  if has cgcc; then
1170
    sparse=yes
1171
  else
1172
    if test "$sparse" = "yes" ; then
1173
      feature_not_found "sparse"
1174
    fi
1175
    sparse=no
1176
  fi
1177
fi
1178

    
1179
##########################################
1180
# SDL probe
1181

    
1182
# Look for sdl configuration program (pkg-config or sdl-config).
1183
# Prefer variant with cross prefix if cross compiling,
1184
# and favour pkg-config with sdl over sdl-config.
1185
if test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
1186
     $pkgconfig sdl --modversion >/dev/null 2>&1; then
1187
  sdlconfig="$pkgconfig sdl"
1188
  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1189
elif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
1190
  sdlconfig="${cross_prefix}sdl-config"
1191
  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1192
elif $pkgconfig sdl --modversion >/dev/null 2>&1; then
1193
  sdlconfig="$pkgconfig sdl"
1194
  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1195
elif has sdl-config; then
1196
  sdlconfig='sdl-config'
1197
  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1198
else
1199
  if test "$sdl" = "yes" ; then
1200
    feature_not_found "sdl"
1201
  fi
1202
  sdl=no
1203
fi
1204

    
1205
sdl_too_old=no
1206
if test "$sdl" != "no" ; then
1207
  cat > $TMPC << EOF
1208
#include <SDL.h>
1209
#undef main /* We don't want SDL to override our main() */
1210
int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1211
EOF
1212
  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
1213
  if test "$static" = "yes" ; then
1214
    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
1215
  else
1216
    sdl_libs=`$sdlconfig --libs 2> /dev/null`
1217
  fi
1218
  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1219
    if test "$_sdlversion" -lt 121 ; then
1220
      sdl_too_old=yes
1221
    else
1222
      if test "$cocoa" = "no" ; then
1223
        sdl=yes
1224
      fi
1225
    fi
1226

    
1227
    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
1228
    if test "$sdl" = "yes" -a "$static" = "yes" ; then
1229
      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1230
         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1231
         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
1232
      fi
1233
      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1234
	:
1235
      else
1236
        sdl=no
1237
      fi
1238
    fi # static link
1239
  else # sdl not found
1240
    if test "$sdl" = "yes" ; then
1241
      feature_not_found "sdl"
1242
    fi
1243
    sdl=no
1244
  fi # sdl compile test
1245
fi
1246

    
1247
if test "$sdl" = "yes" ; then
1248
  cat > $TMPC <<EOF
1249
#include <SDL.h>
1250
#if defined(SDL_VIDEO_DRIVER_X11)
1251
#include <X11/XKBlib.h>
1252
#else
1253
#error No x11 support
1254
#endif
1255
int main(void) { return 0; }
1256
EOF
1257
  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1258
    sdl_libs="$sdl_libs -lX11"
1259
  fi
1260
  if test "$mingw32" = "yes" ; then
1261
    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1262
  fi
1263
  libs_softmmu="$sdl_libs $libs_softmmu"
1264
fi
1265

    
1266
##########################################
1267
# VNC TLS detection
1268
if test "$vnc_tls" != "no" ; then
1269
  cat > $TMPC <<EOF
1270
#include <gnutls/gnutls.h>
1271
int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1272
EOF
1273
  vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
1274
  vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
1275
  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1276
    vnc_tls=yes
1277
    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1278
  else
1279
    if test "$vnc_tls" = "yes" ; then
1280
      feature_not_found "vnc-tls"
1281
    fi
1282
    vnc_tls=no
1283
  fi
1284
fi
1285

    
1286
##########################################
1287
# VNC SASL detection
1288
if test "$vnc_sasl" != "no" ; then
1289
  cat > $TMPC <<EOF
1290
#include <sasl/sasl.h>
1291
#include <stdio.h>
1292
int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1293
EOF
1294
  # Assuming Cyrus-SASL installed in /usr prefix
1295
  vnc_sasl_cflags=""
1296
  vnc_sasl_libs="-lsasl2"
1297
  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1298
    vnc_sasl=yes
1299
    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1300
  else
1301
    if test "$vnc_sasl" = "yes" ; then
1302
      feature_not_found "vnc-sasl"
1303
    fi
1304
    vnc_sasl=no
1305
  fi
1306
fi
1307

    
1308
##########################################
1309
# VNC JPEG detection
1310
if test "$vnc_jpeg" != "no" ; then
1311
cat > $TMPC <<EOF
1312
#include <stdio.h>
1313
#include <jpeglib.h>
1314
int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
1315
EOF
1316
    vnc_jpeg_cflags=""
1317
    vnc_jpeg_libs="-ljpeg"
1318
  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
1319
    vnc_jpeg=yes
1320
    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1321
  else
1322
    if test "$vnc_jpeg" = "yes" ; then
1323
      feature_not_found "vnc-jpeg"
1324
    fi
1325
    vnc_jpeg=no
1326
  fi
1327
fi
1328

    
1329
##########################################
1330
# VNC PNG detection
1331
if test "$vnc_png" != "no" ; then
1332
cat > $TMPC <<EOF
1333
//#include <stdio.h>
1334
#include <png.h>
1335
#include <stddef.h>
1336
int main(void) {
1337
    png_structp png_ptr;
1338
    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1339
    return 0;
1340
}
1341
EOF
1342
    vnc_png_cflags=""
1343
    vnc_png_libs="-lpng"
1344
  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1345
    vnc_png=yes
1346
    libs_softmmu="$vnc_png_libs $libs_softmmu"
1347
  else
1348
    if test "$vnc_png" = "yes" ; then
1349
      feature_not_found "vnc-png"
1350
    fi
1351
    vnc_png=no
1352
  fi
1353
fi
1354

    
1355
##########################################
1356
# fnmatch() probe, used for ACL routines
1357
fnmatch="no"
1358
cat > $TMPC << EOF
1359
#include <fnmatch.h>
1360
int main(void)
1361
{
1362
    fnmatch("foo", "foo", 0);
1363
    return 0;
1364
}
1365
EOF
1366
if compile_prog "" "" ; then
1367
   fnmatch="yes"
1368
fi
1369

    
1370
##########################################
1371
# uuid_generate() probe, used for vdi block driver
1372
if test "$uuid" != "no" ; then
1373
  uuid_libs="-luuid"
1374
  cat > $TMPC << EOF
1375
#include <uuid/uuid.h>
1376
int main(void)
1377
{
1378
    uuid_t my_uuid;
1379
    uuid_generate(my_uuid);
1380
    return 0;
1381
}
1382
EOF
1383
  if compile_prog "" "$uuid_libs" ; then
1384
    uuid="yes"
1385
    libs_softmmu="$uuid_libs $libs_softmmu"
1386
    libs_tools="$uuid_libs $libs_tools"
1387
  else
1388
    if test "$uuid" = "yes" ; then
1389
      feature_not_found "uuid"
1390
    fi
1391
    uuid=no
1392
  fi
1393
fi
1394

    
1395
##########################################
1396
# vde libraries probe
1397
if test "$vde" != "no" ; then
1398
  vde_libs="-lvdeplug"
1399
  cat > $TMPC << EOF
1400
#include <libvdeplug.h>
1401
int main(void)
1402
{
1403
    struct vde_open_args a = {0, 0, 0};
1404
    vde_open("", "", &a);
1405
    return 0;
1406
}
1407
EOF
1408
  if compile_prog "" "$vde_libs" ; then
1409
    vde=yes
1410
    libs_softmmu="$vde_libs $libs_softmmu"
1411
    libs_tools="$vde_libs $libs_tools"
1412
  else
1413
    if test "$vde" = "yes" ; then
1414
      feature_not_found "vde"
1415
    fi
1416
    vde=no
1417
  fi
1418
fi
1419

    
1420
##########################################
1421
# Sound support libraries probe
1422

    
1423
audio_drv_probe()
1424
{
1425
    drv=$1
1426
    hdr=$2
1427
    lib=$3
1428
    exp=$4
1429
    cfl=$5
1430
        cat > $TMPC << EOF
1431
#include <$hdr>
1432
int main(void) { $exp }
1433
EOF
1434
    if compile_prog "$cfl" "$lib" ; then
1435
        :
1436
    else
1437
        echo
1438
        echo "Error: $drv check failed"
1439
        echo "Make sure to have the $drv libs and headers installed."
1440
        echo
1441
        exit 1
1442
    fi
1443
}
1444

    
1445
audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1446
for drv in $audio_drv_list; do
1447
    case $drv in
1448
    alsa)
1449
    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1450
        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1451
    libs_softmmu="-lasound $libs_softmmu"
1452
    ;;
1453

    
1454
    fmod)
1455
    if test -z $fmod_lib || test -z $fmod_inc; then
1456
        echo
1457
        echo "Error: You must specify path to FMOD library and headers"
1458
        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1459
        echo
1460
        exit 1
1461
    fi
1462
    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1463
    libs_softmmu="$fmod_lib $libs_softmmu"
1464
    ;;
1465

    
1466
    esd)
1467
    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1468
    libs_softmmu="-lesd $libs_softmmu"
1469
    audio_pt_int="yes"
1470
    ;;
1471

    
1472
    pa)
1473
    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1474
        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1475
    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
1476
    audio_pt_int="yes"
1477
    ;;
1478

    
1479
    coreaudio)
1480
      libs_softmmu="-framework CoreAudio $libs_softmmu"
1481
    ;;
1482

    
1483
    dsound)
1484
      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1485
      audio_win_int="yes"
1486
    ;;
1487

    
1488
    oss)
1489
      libs_softmmu="$oss_lib $libs_softmmu"
1490
    ;;
1491

    
1492
    sdl|wav)
1493
    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1494
    ;;
1495

    
1496
    winwave)
1497
      libs_softmmu="-lwinmm $libs_softmmu"
1498
      audio_win_int="yes"
1499
    ;;
1500

    
1501
    *)
1502
    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1503
        echo
1504
        echo "Error: Unknown driver '$drv' selected"
1505
        echo "Possible drivers are: $audio_possible_drivers"
1506
        echo
1507
        exit 1
1508
    }
1509
    ;;
1510
    esac
1511
done
1512

    
1513
##########################################
1514
# BrlAPI probe
1515

    
1516
if test "$brlapi" != "no" ; then
1517
  brlapi_libs="-lbrlapi"
1518
  cat > $TMPC << EOF
1519
#include <brlapi.h>
1520
#include <stddef.h>
1521
int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1522
EOF
1523
  if compile_prog "" "$brlapi_libs" ; then
1524
    brlapi=yes
1525
    libs_softmmu="$brlapi_libs $libs_softmmu"
1526
  else
1527
    if test "$brlapi" = "yes" ; then
1528
      feature_not_found "brlapi"
1529
    fi
1530
    brlapi=no
1531
  fi
1532
fi
1533

    
1534
##########################################
1535
# curses probe
1536
curses_list="-lncurses -lcurses"
1537

    
1538
if test "$curses" != "no" ; then
1539
  curses_found=no
1540
  cat > $TMPC << EOF
1541
#include <curses.h>
1542
#ifdef __OpenBSD__
1543
#define resize_term resizeterm
1544
#endif
1545
int main(void) { resize_term(0, 0); return curses_version(); }
1546
EOF
1547
  for curses_lib in $curses_list; do
1548
    if compile_prog "" "$curses_lib" ; then
1549
      curses_found=yes
1550
      libs_softmmu="$curses_lib $libs_softmmu"
1551
      break
1552
    fi
1553
  done
1554
  if test "$curses_found" = "yes" ; then
1555
    curses=yes
1556
  else
1557
    if test "$curses" = "yes" ; then
1558
      feature_not_found "curses"
1559
    fi
1560
    curses=no
1561
  fi
1562
fi
1563

    
1564
##########################################
1565
# curl probe
1566

    
1567
if $pkgconfig libcurl --modversion >/dev/null 2>&1; then
1568
  curlconfig="$pkgconfig libcurl"
1569
else
1570
  curlconfig=curl-config
1571
fi
1572

    
1573
if test "$curl" != "no" ; then
1574
  cat > $TMPC << EOF
1575
#include <curl/curl.h>
1576
int main(void) { return curl_easy_init(); }
1577
EOF
1578
  curl_cflags=`$curlconfig --cflags 2>/dev/null`
1579
  curl_libs=`$curlconfig --libs 2>/dev/null`
1580
  if compile_prog "$curl_cflags" "$curl_libs" ; then
1581
    curl=yes
1582
    libs_tools="$curl_libs $libs_tools"
1583
    libs_softmmu="$curl_libs $libs_softmmu"
1584
  else
1585
    if test "$curl" = "yes" ; then
1586
      feature_not_found "curl"
1587
    fi
1588
    curl=no
1589
  fi
1590
fi # test "$curl"
1591

    
1592
##########################################
1593
# check framework probe
1594

    
1595
if test "$check_utests" != "no" ; then
1596
  cat > $TMPC << EOF
1597
#include <check.h>
1598
int main(void) { suite_create("qemu test"); return 0; }
1599
EOF
1600
  check_libs=`$pkgconfig --libs check`
1601
  if compile_prog "" $check_libs ; then
1602
    check_utests=yes
1603
    libs_tools="$check_libs $libs_tools"
1604
  else
1605
    if test "$check_utests" = "yes" ; then
1606
      feature_not_found "check"
1607
    fi
1608
    check_utests=no
1609
  fi
1610
fi # test "$check_utests"
1611

    
1612
##########################################
1613
# bluez support probe
1614
if test "$bluez" != "no" ; then
1615
  cat > $TMPC << EOF
1616
#include <bluetooth/bluetooth.h>
1617
int main(void) { return bt_error(0); }
1618
EOF
1619
  bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
1620
  bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
1621
  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1622
    bluez=yes
1623
    libs_softmmu="$bluez_libs $libs_softmmu"
1624
  else
1625
    if test "$bluez" = "yes" ; then
1626
      feature_not_found "bluez"
1627
    fi
1628
    bluez="no"
1629
  fi
1630
fi
1631

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

    
1693
##########################################
1694
# test for vhost net
1695

    
1696
if test "$vhost_net" != "no"; then
1697
    if test "$kvm" != "no"; then
1698
            cat > $TMPC <<EOF
1699
    #include <linux/vhost.h>
1700
    int main(void) { return 0; }
1701
EOF
1702
            if compile_prog "$kvm_cflags" "" ; then
1703
                vhost_net=yes
1704
            else
1705
                if test "$vhost_net" = "yes" ; then
1706
                    feature_not_found "vhost-net"
1707
                fi
1708
                vhost_net=no
1709
            fi
1710
    else
1711
            if test "$vhost_net" = "yes" ; then
1712
                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1713
                feature_not_found "vhost-net"
1714
            fi
1715
            vhost_net=no
1716
    fi
1717
fi
1718

    
1719
##########################################
1720
# pthread probe
1721
PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1722

    
1723
pthread=no
1724
cat > $TMPC << EOF
1725
#include <pthread.h>
1726
int main(void) { pthread_create(0,0,0,0); return 0; }
1727
EOF
1728
if compile_prog "" "" ; then
1729
  pthread=yes
1730
else
1731
  for pthread_lib in $PTHREADLIBS_LIST; do
1732
    if compile_prog "" "$pthread_lib" ; then
1733
      pthread=yes
1734
      LIBS="$pthread_lib $LIBS"
1735
      break
1736
    fi
1737
  done
1738
fi
1739

    
1740
if test "$mingw32" != yes -a "$pthread" = no; then
1741
  echo
1742
  echo "Error: pthread check failed"
1743
  echo "Make sure to have the pthread libs and headers installed."
1744
  echo
1745
  exit 1
1746
fi
1747

    
1748
##########################################
1749
# linux-aio probe
1750

    
1751
if test "$linux_aio" != "no" ; then
1752
  cat > $TMPC <<EOF
1753
#include <libaio.h>
1754
#include <sys/eventfd.h>
1755
#include <stddef.h>
1756
int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1757
EOF
1758
  if compile_prog "" "-laio" ; then
1759
    linux_aio=yes
1760
    libs_softmmu="$libs_softmmu -laio"
1761
    libs_tools="$libs_tools -laio"
1762
  else
1763
    if test "$linux_aio" = "yes" ; then
1764
      feature_not_found "linux AIO"
1765
    fi
1766
    linux_aio=no
1767
  fi
1768
fi
1769

    
1770
##########################################
1771
# attr probe
1772

    
1773
if test "$attr" != "no" ; then
1774
  cat > $TMPC <<EOF
1775
#include <stdio.h>
1776
#include <sys/types.h>
1777
#include <attr/xattr.h>
1778
int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1779
EOF
1780
  if compile_prog "" "-lattr" ; then
1781
    attr=yes
1782
    LIBS="-lattr $LIBS"
1783
  else
1784
    if test "$attr" = "yes" ; then
1785
      feature_not_found "ATTR"
1786
    fi
1787
    attr=no
1788
  fi
1789
fi
1790

    
1791
##########################################
1792
# iovec probe
1793
cat > $TMPC <<EOF
1794
#include <sys/types.h>
1795
#include <sys/uio.h>
1796
#include <unistd.h>
1797
int main(void) { struct iovec iov; return 0; }
1798
EOF
1799
iovec=no
1800
if compile_prog "" "" ; then
1801
  iovec=yes
1802
fi
1803

    
1804
##########################################
1805
# preadv probe
1806
cat > $TMPC <<EOF
1807
#include <sys/types.h>
1808
#include <sys/uio.h>
1809
#include <unistd.h>
1810
int main(void) { preadv; }
1811
EOF
1812
preadv=no
1813
if compile_prog "" "" ; then
1814
  preadv=yes
1815
fi
1816

    
1817
##########################################
1818
# fdt probe
1819
if test "$fdt" != "no" ; then
1820
  fdt_libs="-lfdt"
1821
  cat > $TMPC << EOF
1822
int main(void) { return 0; }
1823
EOF
1824
  if compile_prog "" "$fdt_libs" ; then
1825
    fdt=yes
1826
    libs_softmmu="$fdt_libs $libs_softmmu"
1827
  else
1828
    if test "$fdt" = "yes" ; then
1829
      feature_not_found "fdt"
1830
    fi
1831
    fdt=no
1832
  fi
1833
fi
1834

    
1835
#
1836
# Check for xxxat() functions when we are building linux-user
1837
# emulator.  This is done because older glibc versions don't
1838
# have syscall stubs for these implemented.
1839
#
1840
atfile=no
1841
cat > $TMPC << EOF
1842
#define _ATFILE_SOURCE
1843
#include <sys/types.h>
1844
#include <fcntl.h>
1845
#include <unistd.h>
1846

    
1847
int
1848
main(void)
1849
{
1850
	/* try to unlink nonexisting file */
1851
	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1852
}
1853
EOF
1854
if compile_prog "" "" ; then
1855
  atfile=yes
1856
fi
1857

    
1858
# Check for inotify functions when we are building linux-user
1859
# emulator.  This is done because older glibc versions don't
1860
# have syscall stubs for these implemented.  In that case we
1861
# don't provide them even if kernel supports them.
1862
#
1863
inotify=no
1864
cat > $TMPC << EOF
1865
#include <sys/inotify.h>
1866

    
1867
int
1868
main(void)
1869
{
1870
	/* try to start inotify */
1871
	return inotify_init();
1872
}
1873
EOF
1874
if compile_prog "" "" ; then
1875
  inotify=yes
1876
fi
1877

    
1878
inotify1=no
1879
cat > $TMPC << EOF
1880
#include <sys/inotify.h>
1881

    
1882
int
1883
main(void)
1884
{
1885
    /* try to start inotify */
1886
    return inotify_init1(0);
1887
}
1888
EOF
1889
if compile_prog "" "" ; then
1890
  inotify1=yes
1891
fi
1892

    
1893
# check if utimensat and futimens are supported
1894
utimens=no
1895
cat > $TMPC << EOF
1896
#define _ATFILE_SOURCE
1897
#include <stddef.h>
1898
#include <fcntl.h>
1899

    
1900
int main(void)
1901
{
1902
    utimensat(AT_FDCWD, "foo", NULL, 0);
1903
    futimens(0, NULL);
1904
    return 0;
1905
}
1906
EOF
1907
if compile_prog "" "" ; then
1908
  utimens=yes
1909
fi
1910

    
1911
# check if pipe2 is there
1912
pipe2=no
1913
cat > $TMPC << EOF
1914
#include <unistd.h>
1915
#include <fcntl.h>
1916

    
1917
int main(void)
1918
{
1919
    int pipefd[2];
1920
    pipe2(pipefd, O_CLOEXEC);
1921
    return 0;
1922
}
1923
EOF
1924
if compile_prog "" "" ; then
1925
  pipe2=yes
1926
fi
1927

    
1928
# check if accept4 is there
1929
accept4=no
1930
cat > $TMPC << EOF
1931
#include <sys/socket.h>
1932
#include <stddef.h>
1933

    
1934
int main(void)
1935
{
1936
    accept4(0, NULL, NULL, SOCK_CLOEXEC);
1937
    return 0;
1938
}
1939
EOF
1940
if compile_prog "" "" ; then
1941
  accept4=yes
1942
fi
1943

    
1944
# check if tee/splice is there. vmsplice was added same time.
1945
splice=no
1946
cat > $TMPC << EOF
1947
#include <unistd.h>
1948
#include <fcntl.h>
1949
#include <limits.h>
1950

    
1951
int main(void)
1952
{
1953
    int len, fd;
1954
    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1955
    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1956
    return 0;
1957
}
1958
EOF
1959
if compile_prog "" "" ; then
1960
  splice=yes
1961
fi
1962

    
1963
##########################################
1964
# signalfd probe
1965
signalfd="no"
1966
cat > $TMPC << EOF
1967
#define _GNU_SOURCE
1968
#include <unistd.h>
1969
#include <sys/syscall.h>
1970
#include <signal.h>
1971
int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
1972
EOF
1973

    
1974
if compile_prog "" "" ; then
1975
  signalfd=yes
1976
fi
1977

    
1978
# check if eventfd is supported
1979
eventfd=no
1980
cat > $TMPC << EOF
1981
#include <sys/eventfd.h>
1982

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

    
1993
# check for fallocate
1994
fallocate=no
1995
cat > $TMPC << EOF
1996
#include <fcntl.h>
1997

    
1998
int main(void)
1999
{
2000
    fallocate(0, 0, 0, 0);
2001
    return 0;
2002
}
2003
EOF
2004
if compile_prog "$ARCH_CFLAGS" "" ; then
2005
  fallocate=yes
2006
fi
2007

    
2008
# check for dup3
2009
dup3=no
2010
cat > $TMPC << EOF
2011
#include <unistd.h>
2012

    
2013
int main(void)
2014
{
2015
    dup3(0, 0, 0);
2016
    return 0;
2017
}
2018
EOF
2019
if compile_prog "" "" ; then
2020
  dup3=yes
2021
fi
2022

    
2023
# Check if tools are available to build documentation.
2024
if test "$docs" != "no" ; then
2025
  if has makeinfo && has pod2man; then
2026
    docs=yes
2027
  else
2028
    if test "$docs" = "yes" ; then
2029
      feature_not_found "docs"
2030
    fi
2031
    docs=no
2032
  fi
2033
fi
2034

    
2035
# Search for bswap_32 function
2036
byteswap_h=no
2037
cat > $TMPC << EOF
2038
#include <byteswap.h>
2039
int main(void) { return bswap_32(0); }
2040
EOF
2041
if compile_prog "" "" ; then
2042
  byteswap_h=yes
2043
fi
2044

    
2045
# Search for bswap_32 function
2046
bswap_h=no
2047
cat > $TMPC << EOF
2048
#include <sys/endian.h>
2049
#include <sys/types.h>
2050
#include <machine/bswap.h>
2051
int main(void) { return bswap32(0); }
2052
EOF
2053
if compile_prog "" "" ; then
2054
  bswap_h=yes
2055
fi
2056

    
2057
##########################################
2058
# Do we need librt
2059
cat > $TMPC <<EOF
2060
#include <signal.h>
2061
#include <time.h>
2062
int main(void) { clockid_t id; return clock_gettime(id, NULL); }
2063
EOF
2064

    
2065
if compile_prog "" "" ; then
2066
  :
2067
elif compile_prog "" "-lrt" ; then
2068
  LIBS="-lrt $LIBS"
2069
fi
2070

    
2071
if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2072
        "$aix" != "yes" -a "$haiku" != "yes" ; then
2073
    libs_softmmu="-lutil $libs_softmmu"
2074
fi
2075

    
2076
##########################################
2077
# check if the compiler defines offsetof
2078

    
2079
need_offsetof=yes
2080
cat > $TMPC << EOF
2081
#include <stddef.h>
2082
int main(void) { struct s { int f; }; return offsetof(struct s, f); }
2083
EOF
2084
if compile_prog "" "" ; then
2085
    need_offsetof=no
2086
fi
2087

    
2088
##########################################
2089
# check if the compiler understands attribute warn_unused_result
2090
#
2091
# This could be smarter, but gcc -Werror does not error out even when warning
2092
# about attribute warn_unused_result
2093

    
2094
gcc_attribute_warn_unused_result=no
2095
cat > $TMPC << EOF
2096
#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2097
#error gcc 3.3 or older
2098
#endif
2099
int main(void) { return 0;}
2100
EOF
2101
if compile_prog "" ""; then
2102
    gcc_attribute_warn_unused_result=yes
2103
fi
2104

    
2105
# spice probe
2106
if test "$spice" != "no" ; then
2107
  cat > $TMPC << EOF
2108
#include <spice.h>
2109
int main(void) { spice_server_new(); return 0; }
2110
EOF
2111
  spice_cflags=$($pkgconfig --cflags spice-protocol spice-server 2>/dev/null)
2112
  spice_libs=$($pkgconfig --libs spice-protocol spice-server 2>/dev/null)
2113
  if $pkgconfig --atleast-version=0.5.3 spice-server >/dev/null 2>&1 && \
2114
     compile_prog "$spice_cflags" "$spice_libs" ; then
2115
    spice="yes"
2116
    libs_softmmu="$libs_softmmu $spice_libs"
2117
    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2118
  else
2119
    if test "$spice" = "yes" ; then
2120
      feature_not_found "spice"
2121
    fi
2122
    spice="no"
2123
  fi
2124
fi
2125

    
2126
##########################################
2127

    
2128
##########################################
2129
# check if we have fdatasync
2130

    
2131
fdatasync=no
2132
cat > $TMPC << EOF
2133
#include <unistd.h>
2134
int main(void) { return fdatasync(0); }
2135
EOF
2136
if compile_prog "" "" ; then
2137
    fdatasync=yes
2138
fi
2139

    
2140
##########################################
2141
# check if we have madvise
2142

    
2143
madvise=no
2144
cat > $TMPC << EOF
2145
#include <sys/types.h>
2146
#include <sys/mman.h>
2147
#include <stddef.h>
2148
int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2149
EOF
2150
if compile_prog "" "" ; then
2151
    madvise=yes
2152
fi
2153

    
2154
##########################################
2155
# check if we have posix_madvise
2156

    
2157
posix_madvise=no
2158
cat > $TMPC << EOF
2159
#include <sys/mman.h>
2160
#include <stddef.h>
2161
int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2162
EOF
2163
if compile_prog "" "" ; then
2164
    posix_madvise=yes
2165
fi
2166

    
2167
##########################################
2168
# check if trace backend exists
2169

    
2170
sh "$source_path/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
2171
if test "$?" -ne 0 ; then
2172
  echo
2173
  echo "Error: invalid trace backend"
2174
  echo "Please choose a supported trace backend."
2175
  echo
2176
  exit 1
2177
fi
2178

    
2179
##########################################
2180
# For 'ust' backend, test if ust headers are present
2181
if test "$trace_backend" = "ust"; then
2182
  cat > $TMPC << EOF
2183
#include <ust/tracepoint.h>
2184
#include <ust/marker.h>
2185
int main(void) { return 0; }
2186
EOF
2187
  if compile_prog "" "" ; then
2188
    LIBS="-lust $LIBS"
2189
  else
2190
    echo
2191
    echo "Error: Trace backend 'ust' missing libust header files"
2192
    echo
2193
    exit 1
2194
  fi
2195
  trace_backend_stap="no"
2196
  if has 'stap' ; then
2197
    trace_backend_stap="yes"
2198
  fi
2199
fi
2200

    
2201
##########################################
2202
# For 'dtrace' backend, test if 'dtrace' command is present
2203
if test "$trace_backend" = "dtrace"; then
2204
  if ! has 'dtrace' ; then
2205
    echo
2206
    echo "Error: dtrace command is not found in PATH $PATH"
2207
    echo
2208
    exit 1
2209
  fi
2210
fi
2211

    
2212
##########################################
2213
# End of CC checks
2214
# After here, no more $cc or $ld runs
2215

    
2216
if test "$debug" = "no" ; then
2217
  CFLAGS="-O2 $CFLAGS"
2218
fi
2219

    
2220
# Consult white-list to determine whether to enable werror
2221
# by default.  Only enable by default for git builds
2222
z_version=`cut -f3 -d. $source_path/VERSION`
2223

    
2224
if test -z "$werror" ; then
2225
    if test "$z_version" = "50" -a \
2226
        "$linux" = "yes" ; then
2227
        werror="yes"
2228
    else
2229
        werror="no"
2230
    fi
2231
fi
2232

    
2233
# Disable zero malloc errors for official releases unless explicitly told to
2234
# enable/disable
2235
if test -z "$zero_malloc" ; then
2236
    if test "$z_version" = "50" ; then
2237
	zero_malloc="no"
2238
    else
2239
	zero_malloc="yes"
2240
    fi
2241
fi
2242

    
2243
if test "$werror" = "yes" ; then
2244
    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2245
fi
2246

    
2247
if test "$solaris" = "no" ; then
2248
    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
2249
        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2250
    fi
2251
fi
2252

    
2253
# Use ASLR, no-SEH and DEP if available
2254
if test "$mingw32" = "yes" ; then
2255
    for flag in --dynamicbase --no-seh --nxcompat; do
2256
        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2257
            LDFLAGS="-Wl,$flag $LDFLAGS"
2258
        fi
2259
    done
2260
fi
2261

    
2262
confdir=$sysconfdir$confsuffix
2263

    
2264
tools=
2265
if test "$softmmu" = yes ; then
2266
  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2267
  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2268
      tools="qemu-nbd\$(EXESUF) $tools"
2269
    if [ "$check_utests" = "yes" ]; then
2270
      tools="check-qint check-qstring check-qdict check-qlist $tools"
2271
      tools="check-qfloat check-qjson $tools"
2272
    fi
2273
  fi
2274
fi
2275

    
2276
# Mac OS X ships with a broken assembler
2277
roms=
2278
if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2279
        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2280
        "$softmmu" = yes ; then
2281
  roms="optionrom"
2282
fi
2283

    
2284

    
2285
echo "Install prefix    $prefix"
2286
echo "BIOS directory    `eval echo $datadir`"
2287
echo "binary directory  `eval echo $bindir`"
2288
echo "config directory  `eval echo $sysconfdir`"
2289
if test "$mingw32" = "no" ; then
2290
echo "Manual directory  `eval echo $mandir`"
2291
echo "ELF interp prefix $interp_prefix"
2292
fi
2293
echo "Source path       $source_path"
2294
echo "C compiler        $cc"
2295
echo "Host C compiler   $host_cc"
2296
echo "CFLAGS            $CFLAGS"
2297
echo "QEMU_CFLAGS       $QEMU_CFLAGS"
2298
echo "LDFLAGS           $LDFLAGS"
2299
echo "make              $make"
2300
echo "install           $install"
2301
echo "host CPU          $cpu"
2302
echo "host big endian   $bigendian"
2303
echo "target list       $target_list"
2304
echo "tcg debug enabled $debug_tcg"
2305
echo "Mon debug enabled $debug_mon"
2306
echo "gprof enabled     $gprof"
2307
echo "sparse enabled    $sparse"
2308
echo "strip binaries    $strip_opt"
2309
echo "profiler          $profiler"
2310
echo "static build      $static"
2311
echo "-Werror enabled   $werror"
2312
if test "$darwin" = "yes" ; then
2313
    echo "Cocoa support     $cocoa"
2314
fi
2315
echo "SDL support       $sdl"
2316
echo "curses support    $curses"
2317
echo "curl support      $curl"
2318
echo "check support     $check_utests"
2319
echo "mingw32 support   $mingw32"
2320
echo "Audio drivers     $audio_drv_list"
2321
echo "Extra audio cards $audio_card_list"
2322
echo "Block whitelist   $block_drv_whitelist"
2323
echo "Mixer emulation   $mixemu"
2324
echo "VNC TLS support   $vnc_tls"
2325
echo "VNC SASL support  $vnc_sasl"
2326
echo "VNC JPEG support  $vnc_jpeg"
2327
echo "VNC PNG support   $vnc_png"
2328
echo "VNC thread        $vnc_thread"
2329
if test -n "$sparc_cpu"; then
2330
    echo "Target Sparc Arch $sparc_cpu"
2331
fi
2332
echo "xen support       $xen"
2333
echo "brlapi support    $brlapi"
2334
echo "bluez  support    $bluez"
2335
echo "Documentation     $docs"
2336
[ ! -z "$uname_release" ] && \
2337
echo "uname -r          $uname_release"
2338
echo "NPTL support      $nptl"
2339
echo "GUEST_BASE        $guest_base"
2340
echo "PIE user targets  $user_pie"
2341
echo "vde support       $vde"
2342
echo "IO thread         $io_thread"
2343
echo "Linux AIO support $linux_aio"
2344
echo "ATTR/XATTR support $attr"
2345
echo "Install blobs     $blobs"
2346
echo "KVM support       $kvm"
2347
echo "fdt support       $fdt"
2348
echo "preadv support    $preadv"
2349
echo "fdatasync         $fdatasync"
2350
echo "madvise           $madvise"
2351
echo "posix_madvise     $posix_madvise"
2352
echo "uuid support      $uuid"
2353
echo "vhost-net support $vhost_net"
2354
echo "Trace backend     $trace_backend"
2355
echo "Trace output file $trace_file-<pid>"
2356
echo "spice support     $spice"
2357

    
2358
if test $sdl_too_old = "yes"; then
2359
echo "-> Your SDL version is too old - please upgrade to have SDL support"
2360
fi
2361

    
2362
config_host_mak="config-host.mak"
2363
config_host_ld="config-host.ld"
2364

    
2365
echo "# Automatically generated by configure - do not modify" > $config_host_mak
2366
printf "# Configured with:" >> $config_host_mak
2367
printf " '%s'" "$0" "$@" >> $config_host_mak
2368
echo >> $config_host_mak
2369

    
2370
echo all: >> $config_host_mak
2371
echo "prefix=$prefix" >> $config_host_mak
2372
echo "bindir=$bindir" >> $config_host_mak
2373
echo "mandir=$mandir" >> $config_host_mak
2374
echo "datadir=$datadir" >> $config_host_mak
2375
echo "sysconfdir=$sysconfdir" >> $config_host_mak
2376
echo "docdir=$docdir" >> $config_host_mak
2377
echo "confdir=$confdir" >> $config_host_mak
2378

    
2379
case "$cpu" in
2380
  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2381
    ARCH=$cpu
2382
  ;;
2383
  armv4b|armv4l)
2384
    ARCH=arm
2385
  ;;
2386
esac
2387
echo "ARCH=$ARCH" >> $config_host_mak
2388
if test "$debug_tcg" = "yes" ; then
2389
  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2390
fi
2391
if test "$debug_mon" = "yes" ; then
2392
  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2393
fi
2394
if test "$debug" = "yes" ; then
2395
  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2396
fi
2397
if test "$strip_opt" = "yes" ; then
2398
  echo "STRIP=${strip}" >> $config_host_mak
2399
fi
2400
if test "$bigendian" = "yes" ; then
2401
  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
2402
fi
2403
echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
2404
if test "$mingw32" = "yes" ; then
2405
  echo "CONFIG_WIN32=y" >> $config_host_mak
2406
  rc_version=`cat $source_path/VERSION`
2407
  version_major=${rc_version%%.*}
2408
  rc_version=${rc_version#*.}
2409
  version_minor=${rc_version%%.*}
2410
  rc_version=${rc_version#*.}
2411
  version_subminor=${rc_version%%.*}
2412
  version_micro=0
2413
  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2414
  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2415
else
2416
  echo "CONFIG_POSIX=y" >> $config_host_mak
2417
fi
2418

    
2419
if test "$linux" = "yes" ; then
2420
  echo "CONFIG_LINUX=y" >> $config_host_mak
2421
fi
2422

    
2423
if test "$darwin" = "yes" ; then
2424
  echo "CONFIG_DARWIN=y" >> $config_host_mak
2425
fi
2426

    
2427
if test "$aix" = "yes" ; then
2428
  echo "CONFIG_AIX=y" >> $config_host_mak
2429
fi
2430

    
2431
if test "$solaris" = "yes" ; then
2432
  echo "CONFIG_SOLARIS=y" >> $config_host_mak
2433
  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
2434
  if test "$needs_libsunmath" = "yes" ; then
2435
    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
2436
  fi
2437
fi
2438
if test "$haiku" = "yes" ; then
2439
  echo "CONFIG_HAIKU=y" >> $config_host_mak
2440
fi
2441
if test "$static" = "yes" ; then
2442
  echo "CONFIG_STATIC=y" >> $config_host_mak
2443
fi
2444
if test $profiler = "yes" ; then
2445
  echo "CONFIG_PROFILER=y" >> $config_host_mak
2446
fi
2447
if test "$slirp" = "yes" ; then
2448
  echo "CONFIG_SLIRP=y" >> $config_host_mak
2449
  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
2450
fi
2451
if test "$vde" = "yes" ; then
2452
  echo "CONFIG_VDE=y" >> $config_host_mak
2453
fi
2454
for card in $audio_card_list; do
2455
    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
2456
    echo "$def=y" >> $config_host_mak
2457
done
2458
echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
2459
for drv in $audio_drv_list; do
2460
    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
2461
    echo "$def=y" >> $config_host_mak
2462
    if test "$drv" = "fmod"; then
2463
        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2464
    fi
2465
done
2466
if test "$audio_pt_int" = "yes" ; then
2467
  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
2468
fi
2469
if test "$audio_win_int" = "yes" ; then
2470
  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2471
fi
2472
echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
2473
if test "$mixemu" = "yes" ; then
2474
  echo "CONFIG_MIXEMU=y" >> $config_host_mak
2475
fi
2476
if test "$vnc_tls" = "yes" ; then
2477
  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2478
  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
2479
fi
2480
if test "$vnc_sasl" = "yes" ; then
2481
  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2482
  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
2483
fi
2484
if test "$vnc_jpeg" != "no" ; then
2485
  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2486
  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
2487
fi
2488
if test "$vnc_png" != "no" ; then
2489
  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2490
  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2491
fi
2492
if test "$vnc_thread" != "no" ; then
2493
  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2494
  echo "CONFIG_THREAD=y" >> $config_host_mak
2495
fi
2496
if test "$fnmatch" = "yes" ; then
2497
  echo "CONFIG_FNMATCH=y" >> $config_host_mak
2498
fi
2499
if test "$uuid" = "yes" ; then
2500
  echo "CONFIG_UUID=y" >> $config_host_mak
2501
fi
2502
qemu_version=`head $source_path/VERSION`
2503
echo "VERSION=$qemu_version" >>$config_host_mak
2504
echo "PKGVERSION=$pkgversion" >>$config_host_mak
2505
echo "SRC_PATH=$source_path" >> $config_host_mak
2506
echo "TARGET_DIRS=$target_list" >> $config_host_mak
2507
if [ "$docs" = "yes" ] ; then
2508
  echo "BUILD_DOCS=yes" >> $config_host_mak
2509
fi
2510
if test "$sdl" = "yes" ; then
2511
  echo "CONFIG_SDL=y" >> $config_host_mak
2512
  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
2513
fi
2514
if test "$cocoa" = "yes" ; then
2515
  echo "CONFIG_COCOA=y" >> $config_host_mak
2516
fi
2517
if test "$curses" = "yes" ; then
2518
  echo "CONFIG_CURSES=y" >> $config_host_mak
2519
fi
2520
if test "$atfile" = "yes" ; then
2521
  echo "CONFIG_ATFILE=y" >> $config_host_mak
2522
fi
2523
if test "$utimens" = "yes" ; then
2524
  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2525
fi
2526
if test "$pipe2" = "yes" ; then
2527
  echo "CONFIG_PIPE2=y" >> $config_host_mak
2528
fi
2529
if test "$accept4" = "yes" ; then
2530
  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
2531
fi
2532
if test "$splice" = "yes" ; then
2533
  echo "CONFIG_SPLICE=y" >> $config_host_mak
2534
fi
2535
if test "$eventfd" = "yes" ; then
2536
  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2537
fi
2538
if test "$fallocate" = "yes" ; then
2539
  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2540
fi
2541
if test "$dup3" = "yes" ; then
2542
  echo "CONFIG_DUP3=y" >> $config_host_mak
2543
fi
2544
if test "$inotify" = "yes" ; then
2545
  echo "CONFIG_INOTIFY=y" >> $config_host_mak
2546
fi
2547
if test "$inotify1" = "yes" ; then
2548
  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2549
fi
2550
if test "$byteswap_h" = "yes" ; then
2551
  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
2552
fi
2553
if test "$bswap_h" = "yes" ; then
2554
  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
2555
fi
2556
if test "$curl" = "yes" ; then
2557
  echo "CONFIG_CURL=y" >> $config_host_mak
2558
  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2559
fi
2560
if test "$brlapi" = "yes" ; then
2561
  echo "CONFIG_BRLAPI=y" >> $config_host_mak
2562
fi
2563
if test "$bluez" = "yes" ; then
2564
  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2565
  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2566
fi
2567
if test "$xen" = "yes" ; then
2568
  echo "CONFIG_XEN=y" >> $config_host_mak
2569
fi
2570
if test "$io_thread" = "yes" ; then
2571
  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2572
  echo "CONFIG_THREAD=y" >> $config_host_mak
2573
fi
2574
if test "$linux_aio" = "yes" ; then
2575
  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
2576
fi
2577
if test "$attr" = "yes" ; then
2578
  echo "CONFIG_ATTR=y" >> $config_host_mak
2579
fi
2580
if test "$linux" = "yes" ; then
2581
  if test "$attr" = "yes" ; then
2582
    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2583
  fi
2584
fi
2585
if test "$blobs" = "yes" ; then
2586
  echo "INSTALL_BLOBS=yes" >> $config_host_mak
2587
fi
2588
if test "$iovec" = "yes" ; then
2589
  echo "CONFIG_IOVEC=y" >> $config_host_mak
2590
fi
2591
if test "$preadv" = "yes" ; then
2592
  echo "CONFIG_PREADV=y" >> $config_host_mak
2593
fi
2594
if test "$fdt" = "yes" ; then
2595
  echo "CONFIG_FDT=y" >> $config_host_mak
2596
fi
2597
if test "$signalfd" = "yes" ; then
2598
  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2599
fi
2600
if test "$need_offsetof" = "yes" ; then
2601
  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2602
fi
2603
if test "$gcc_attribute_warn_unused_result" = "yes" ; then
2604
  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2605
fi
2606
if test "$fdatasync" = "yes" ; then
2607
  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
2608
fi
2609
if test "$madvise" = "yes" ; then
2610
  echo "CONFIG_MADVISE=y" >> $config_host_mak
2611
fi
2612
if test "$posix_madvise" = "yes" ; then
2613
  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2614
fi
2615

    
2616
if test "$spice" = "yes" ; then
2617
  echo "CONFIG_SPICE=y" >> $config_host_mak
2618
fi
2619

    
2620
# XXX: suppress that
2621
if [ "$bsd" = "yes" ] ; then
2622
  echo "CONFIG_BSD=y" >> $config_host_mak
2623
fi
2624

    
2625
echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2626

    
2627
if test "$zero_malloc" = "yes" ; then
2628
  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
2629
fi
2630

    
2631
# USB host support
2632
case "$usb" in
2633
linux)
2634
  echo "HOST_USB=linux" >> $config_host_mak
2635
;;
2636
bsd)
2637
  echo "HOST_USB=bsd" >> $config_host_mak
2638
;;
2639
*)
2640
  echo "HOST_USB=stub" >> $config_host_mak
2641
;;
2642
esac
2643

    
2644
echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
2645
if test "$trace_backend" = "simple"; then
2646
  echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
2647
fi
2648
# Set the appropriate trace file.
2649
if test "$trace_backend" = "simple"; then
2650
  trace_file="\"$trace_file-%u\""
2651
fi
2652
if test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
2653
  echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
2654
fi
2655
echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
2656

    
2657
echo "TOOLS=$tools" >> $config_host_mak
2658
echo "ROMS=$roms" >> $config_host_mak
2659
echo "MAKE=$make" >> $config_host_mak
2660
echo "INSTALL=$install" >> $config_host_mak
2661
echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2662
echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2663
echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2664
echo "CC=$cc" >> $config_host_mak
2665
echo "CC_I386=$cc_i386" >> $config_host_mak
2666
echo "HOST_CC=$host_cc" >> $config_host_mak
2667
if test "$sparse" = "yes" ; then
2668
  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2669
  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2670
  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2671
fi
2672
echo "AR=$ar" >> $config_host_mak
2673
echo "OBJCOPY=$objcopy" >> $config_host_mak
2674
echo "LD=$ld" >> $config_host_mak
2675
echo "WINDRES=$windres" >> $config_host_mak
2676
echo "CFLAGS=$CFLAGS" >> $config_host_mak
2677
echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2678
echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2679
echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
2680
echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2681
echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
2682
echo "LIBS+=$LIBS" >> $config_host_mak
2683
echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2684
echo "EXESUF=$EXESUF" >> $config_host_mak
2685

    
2686
# generate list of library paths for linker script
2687

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

    
2690
if test -f ${config_host_ld}~ ; then
2691
  if cmp -s $config_host_ld ${config_host_ld}~ ; then
2692
    mv ${config_host_ld}~ $config_host_ld
2693
  else
2694
    rm ${config_host_ld}~
2695
  fi
2696
fi
2697

    
2698
for d in libdis libdis-user; do
2699
    mkdir -p $d
2700
    rm -f $d/Makefile
2701
    ln -s $source_path/Makefile.dis $d/Makefile
2702
    echo > $d/config.mak
2703
done
2704
if test "$static" = "no" -a "$user_pie" = "yes" ; then
2705
  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2706
fi
2707

    
2708
for target in $target_list; do
2709
target_dir="$target"
2710
config_target_mak=$target_dir/config-target.mak
2711
target_arch2=`echo $target | cut -d '-' -f 1`
2712
target_bigendian="no"
2713

    
2714
case "$target_arch2" in
2715
  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2716
  target_bigendian=yes
2717
  ;;
2718
esac
2719
target_softmmu="no"
2720
target_user_only="no"
2721
target_linux_user="no"
2722
target_darwin_user="no"
2723
target_bsd_user="no"
2724
case "$target" in
2725
  ${target_arch2}-softmmu)
2726
    target_softmmu="yes"
2727
    ;;
2728
  ${target_arch2}-linux-user)
2729
    if test "$linux" != "yes" ; then
2730
      echo "ERROR: Target '$target' is only available on a Linux host"
2731
      exit 1
2732
    fi
2733
    target_user_only="yes"
2734
    target_linux_user="yes"
2735
    ;;
2736
  ${target_arch2}-darwin-user)
2737
    if test "$darwin" != "yes" ; then
2738
      echo "ERROR: Target '$target' is only available on a Darwin host"
2739
      exit 1
2740
    fi
2741
    target_user_only="yes"
2742
    target_darwin_user="yes"
2743
    ;;
2744
  ${target_arch2}-bsd-user)
2745
    if test "$bsd" != "yes" ; then
2746
      echo "ERROR: Target '$target' is only available on a BSD host"
2747
      exit 1
2748
    fi
2749
    target_user_only="yes"
2750
    target_bsd_user="yes"
2751
    ;;
2752
  *)
2753
    echo "ERROR: Target '$target' not recognised"
2754
    exit 1
2755
    ;;
2756
esac
2757

    
2758
mkdir -p $target_dir
2759
mkdir -p $target_dir/fpu
2760
mkdir -p $target_dir/tcg
2761
mkdir -p $target_dir/ide
2762
if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
2763
  mkdir -p $target_dir/nwfpe
2764
fi
2765

    
2766
#
2767
# don't use ln -sf as not all "ln -sf" over write the file/link
2768
#
2769
rm -f $target_dir/Makefile
2770
ln -s $source_path/Makefile.target $target_dir/Makefile
2771

    
2772

    
2773
echo "# Automatically generated by configure - do not modify" > $config_target_mak
2774

    
2775
bflt="no"
2776
target_nptl="no"
2777
interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
2778
echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
2779
gdb_xml_files=""
2780

    
2781
TARGET_ARCH="$target_arch2"
2782
TARGET_BASE_ARCH=""
2783
TARGET_ABI_DIR=""
2784

    
2785
case "$target_arch2" in
2786
  i386)
2787
    target_phys_bits=32
2788
  ;;
2789
  x86_64)
2790
    TARGET_BASE_ARCH=i386
2791
    target_phys_bits=64
2792
  ;;
2793
  alpha)
2794
    target_phys_bits=64
2795
    target_nptl="yes"
2796
  ;;
2797
  arm|armeb)
2798
    TARGET_ARCH=arm
2799
    bflt="yes"
2800
    target_nptl="yes"
2801
    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2802
    target_phys_bits=32
2803
  ;;
2804
  cris)
2805
    target_nptl="yes"
2806
    target_phys_bits=32
2807
  ;;
2808
  m68k)
2809
    bflt="yes"
2810
    gdb_xml_files="cf-core.xml cf-fp.xml"
2811
    target_phys_bits=32
2812
  ;;
2813
  microblaze)
2814
    bflt="yes"
2815
    target_nptl="yes"
2816
    target_phys_bits=32
2817
  ;;
2818
  mips|mipsel)
2819
    TARGET_ARCH=mips
2820
    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2821
    target_nptl="yes"
2822
    target_phys_bits=64
2823
  ;;
2824
  mipsn32|mipsn32el)
2825
    TARGET_ARCH=mipsn32
2826
    TARGET_BASE_ARCH=mips
2827
    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
2828
    target_phys_bits=64
2829
  ;;
2830
  mips64|mips64el)
2831
    TARGET_ARCH=mips64
2832
    TARGET_BASE_ARCH=mips
2833
    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2834
    target_phys_bits=64
2835
  ;;
2836
  ppc)
2837
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2838
    target_phys_bits=32
2839
    target_nptl="yes"
2840
  ;;
2841
  ppcemb)
2842
    TARGET_BASE_ARCH=ppc
2843
    TARGET_ABI_DIR=ppc
2844
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2845
    target_phys_bits=64
2846
    target_nptl="yes"
2847
  ;;
2848
  ppc64)
2849
    TARGET_BASE_ARCH=ppc
2850
    TARGET_ABI_DIR=ppc
2851
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2852
    target_phys_bits=64
2853
  ;;
2854
  ppc64abi32)
2855
    TARGET_ARCH=ppc64
2856
    TARGET_BASE_ARCH=ppc
2857
    TARGET_ABI_DIR=ppc
2858
    echo "TARGET_ABI32=y" >> $config_target_mak
2859
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2860
    target_phys_bits=64
2861
  ;;
2862
  sh4|sh4eb)
2863
    TARGET_ARCH=sh4
2864
    bflt="yes"
2865
    target_nptl="yes"
2866
    target_phys_bits=32
2867
  ;;
2868
  sparc)
2869
    target_phys_bits=64
2870
  ;;
2871
  sparc64)
2872
    TARGET_BASE_ARCH=sparc
2873
    target_phys_bits=64
2874
  ;;
2875
  sparc32plus)
2876
    TARGET_ARCH=sparc64
2877
    TARGET_BASE_ARCH=sparc
2878
    TARGET_ABI_DIR=sparc
2879
    echo "TARGET_ABI32=y" >> $config_target_mak
2880
    target_phys_bits=64
2881
  ;;
2882
  s390x)
2883
    target_phys_bits=64
2884
  ;;
2885
  *)
2886
    echo "Unsupported target CPU"
2887
    exit 1
2888
  ;;
2889
esac
2890
echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2891
target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
2892
echo "TARGET_$target_arch_name=y" >> $config_target_mak
2893
echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
2894
# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
2895
if [ "$TARGET_BASE_ARCH" = "" ]; then
2896
  TARGET_BASE_ARCH=$TARGET_ARCH
2897
fi
2898
echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2899
if [ "$TARGET_ABI_DIR" = "" ]; then
2900
  TARGET_ABI_DIR=$TARGET_ARCH
2901
fi
2902
echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
2903
case "$target_arch2" in
2904
  i386|x86_64)
2905
    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2906
      echo "CONFIG_XEN=y" >> $config_target_mak
2907
    fi
2908
esac
2909
case "$target_arch2" in
2910
  i386|x86_64|ppcemb|ppc|ppc64|s390x)
2911
    # Make sure the target and host cpus are compatible
2912
    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2913
      \( "$target_arch2" = "$cpu" -o \
2914
      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2915
      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2916
      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2917
      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
2918
      echo "CONFIG_KVM=y" >> $config_target_mak
2919
      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2920
      if test "$kvm_para" = "yes"; then
2921
        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
2922
      fi
2923
      if test $vhost_net = "yes" ; then
2924
        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
2925
      fi
2926
    fi
2927
esac
2928
if test "$target_bigendian" = "yes" ; then
2929
  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
2930
fi
2931
if test "$target_softmmu" = "yes" ; then
2932
  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
2933
  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
2934
  echo "LIBS+=$libs_softmmu" >> $config_target_mak
2935
  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
2936
  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2937
fi
2938
if test "$target_user_only" = "yes" ; then
2939
  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2940
fi
2941
if test "$target_linux_user" = "yes" ; then
2942
  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2943
fi
2944
if test "$target_darwin_user" = "yes" ; then
2945
  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2946
fi
2947
list=""
2948
if test ! -z "$gdb_xml_files" ; then
2949
  for x in $gdb_xml_files; do
2950
    list="$list $source_path/gdb-xml/$x"
2951
  done
2952
  echo "TARGET_XML_FILES=$list" >> $config_target_mak
2953
fi
2954

    
2955
case "$target_arch2" in
2956
  alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
2957
    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2958
    ;;
2959
  *)
2960
    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2961
    ;;
2962
esac
2963

    
2964
if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2965
  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2966
fi
2967
if test "$target_user_only" = "yes" \
2968
        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2969
  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2970
fi
2971
if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2972
  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2973
fi
2974
if test "$target_bsd_user" = "yes" ; then
2975
  echo "CONFIG_BSD_USER=y" >> $config_target_mak
2976
fi
2977

    
2978
# generate QEMU_CFLAGS/LDFLAGS for targets
2979

    
2980
cflags=""
2981
ldflags=""
2982

    
2983
if test "$ARCH" = "sparc64" ; then
2984
  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
2985
elif test "$ARCH" = "s390x" ; then
2986
  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
2987
elif test "$ARCH" = "x86_64" ; then
2988
  cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
2989
else
2990
  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
2991
fi
2992
cflags="-I\$(SRC_PATH)/tcg $cflags"
2993
cflags="-I\$(SRC_PATH)/fpu $cflags"
2994

    
2995
if test "$target_user_only" = "yes" ; then
2996
    libdis_config_mak=libdis-user/config.mak
2997
else
2998
    libdis_config_mak=libdis/config.mak
2999
fi
3000

    
3001
for i in $ARCH $TARGET_BASE_ARCH ; do
3002
  case "$i" in
3003
  alpha)
3004
    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
3005
    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
3006
  ;;
3007
  arm)
3008
    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
3009
    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
3010
  ;;
3011
  cris)
3012
    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
3013
    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
3014
  ;;
3015
  hppa)
3016
    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
3017
    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
3018
  ;;
3019
  i386|x86_64)
3020
    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
3021
    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
3022
  ;;
3023
  ia64*)
3024
    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3025
    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3026
  ;;
3027
  m68k)
3028
    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
3029
    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
3030
  ;;
3031
  microblaze)
3032
    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
3033
    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
3034
  ;;
3035
  mips*)
3036
    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
3037
    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
3038
  ;;
3039
  ppc*)
3040
    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
3041
    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
3042
  ;;
3043
  s390*)
3044
    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
3045
    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
3046
  ;;
3047
  sh4)
3048
    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
3049
    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
3050
  ;;
3051
  sparc*)
3052
    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
3053
    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
3054
  ;;
3055
  esac
3056
done
3057

    
3058
case "$ARCH" in
3059
alpha)
3060
  # Ensure there's only a single GP
3061
  cflags="-msmall-data $cflags"
3062
;;
3063
esac
3064

    
3065
if test "$target_softmmu" = "yes" ; then
3066
  case "$TARGET_BASE_ARCH" in
3067
  arm)
3068
    cflags="-DHAS_AUDIO $cflags"
3069
  ;;
3070
  i386|mips|ppc)
3071
    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
3072
  ;;
3073
  esac
3074
fi
3075

    
3076
if test "$target_user_only" = "yes" -a "$static" = "no" -a \
3077
	"$user_pie" = "yes" ; then
3078
  cflags="-fpie $cflags"
3079
  ldflags="-pie $ldflags"
3080
fi
3081

    
3082
if test "$target_softmmu" = "yes" -a \( \
3083
        "$TARGET_ARCH" = "microblaze" -o \
3084
        "$TARGET_ARCH" = "cris" \) ; then
3085
  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3086
fi
3087

    
3088
if test "$gprof" = "yes" ; then
3089
  echo "TARGET_GPROF=yes" >> $config_target_mak
3090
  if test "$target_linux_user" = "yes" ; then
3091
    cflags="-p $cflags"
3092
    ldflags="-p $ldflags"
3093
  fi
3094
  if test "$target_softmmu" = "yes" ; then
3095
    ldflags="-p $ldflags"
3096
    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3097
  fi
3098
fi
3099

    
3100
linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
3101
if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3102
  case "$ARCH" in
3103
  sparc)
3104
    # -static is used to avoid g1/g3 usage by the dynamic linker
3105
    ldflags="$linker_script -static $ldflags"
3106
    ;;
3107
  alpha | s390x)
3108
    # The default placement of the application is fine.
3109
    ;;
3110
  *)
3111
    ldflags="$linker_script $ldflags"
3112
    ;;
3113
  esac
3114
fi
3115

    
3116
echo "LDFLAGS+=$ldflags" >> $config_target_mak
3117
echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3118

    
3119
done # for target in $targets
3120

    
3121
# build tree in object directory if source path is different from current one
3122
if test "$source_path_used" = "yes" ; then
3123
    DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3124
    DIRS="$DIRS roms/seabios roms/vgabios"
3125
    DIRS="$DIRS fsdev ui"
3126
    FILES="Makefile tests/Makefile"
3127
    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3128
    FILES="$FILES tests/test-mmap.c"
3129
    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3130
    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
3131
    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
3132
        FILES="$FILES pc-bios/`basename $bios_file`"
3133
    done
3134
    for dir in $DIRS ; do
3135
            mkdir -p $dir
3136
    done
3137
    # remove the link and recreate it, as not all "ln -sf" overwrite the link
3138
    for f in $FILES ; do
3139
        rm -f $f
3140
        ln -s $source_path/$f $f
3141
    done
3142
fi
3143

    
3144
# temporary config to build submodules
3145
for rom in seabios vgabios ; do
3146
    config_mak=roms/$rom/config.mak
3147
    echo "# Automatically generated by configure - do not modify" > $config_mak
3148
    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3149
    echo "CC=$cc" >> $config_mak
3150
    echo "BCC=bcc" >> $config_mak
3151
    echo "CPP=${cross_prefix}cpp" >> $config_mak
3152
    echo "OBJCOPY=objcopy" >> $config_mak
3153
    echo "IASL=iasl" >> $config_mak
3154
    echo "HOST_CC=$host_cc" >> $config_mak
3155
    echo "LD=$ld" >> $config_mak
3156
done
3157

    
3158
for hwlib in 32 64; do
3159
  d=libhw$hwlib
3160
  mkdir -p $d
3161
  mkdir -p $d/ide
3162
  rm -f $d/Makefile
3163
  ln -s $source_path/Makefile.hw $d/Makefile
3164
  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
3165
done
3166

    
3167
d=libuser
3168
mkdir -p $d
3169
rm -f $d/Makefile
3170
ln -s $source_path/Makefile.user $d/Makefile
3171
if test "$static" = "no" -a "$user_pie" = "yes" ; then
3172
  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3173
fi
3174

    
3175
if test "$docs" = "yes" ; then
3176
  mkdir -p QMP
3177
fi