Statistics
| Branch: | Revision:

root / configure @ e2a2ed06

History | View | Annotate | Download (54.5 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}"
17
TMPS="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.S"
18
TMPI="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.i"
19
TMPSDLLOG="${TMPDIR1}/qemu-conf-sdl-$$-${RANDOM}.log"
20

    
21
trap "rm -f $TMPC $TMPO $TMPE $TMPS $TMPI $TMPSDLLOG; exit" 0 2 3 15
22

    
23
# default parameters
24
cpu=""
25
prefix=""
26
interp_prefix="/usr/gnemul/qemu-%M"
27
static="no"
28
cross_prefix=""
29
cc="gcc"
30
audio_drv_list=""
31
audio_card_list="ac97 es1370 sb16"
32
audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
33
host_cc="gcc"
34
ar="ar"
35
make="make"
36
install="install"
37
objcopy="objcopy"
38
ld="ld"
39

    
40
# parse CC options first
41
for opt do
42
  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
43
  case "$opt" in
44
  --cross-prefix=*) cross_prefix="$optarg"
45
  ;;
46
  --cc=*) cc="$optarg"
47
  ;;
48
  --cpu=*) cpu="$optarg"
49
  ;;
50
  --extra-cflags=*) CFLAGS="$optarg $CFLAGS"
51
  ;;
52
  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
53
  ;;
54
  esac
55
done
56

    
57
# OS specific
58
# Using uname is really, really broken.  Once we have the right set of checks
59
# we can eliminate it's usage altogether
60

    
61
cc="${cross_prefix}${cc}"
62
ar="${cross_prefix}${ar}"
63
objcopy="${cross_prefix}${objcopy}"
64
ld="${cross_prefix}${ld}"
65

    
66
# check that the C compiler works.
67
cat > $TMPC <<EOF
68
int main(void) {}
69
EOF
70

    
71
if $cc $CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
72
  : C compiler works ok
73
else
74
    echo "ERROR: \"$cc\" either does not exist or does not work"
75
    exit 1
76
fi
77

    
78
check_define() {
79
cat > $TMPC <<EOF
80
#if !defined($1)
81
#error Not defined
82
#endif
83
int main(void) { return 0; }
84
EOF
85
  $cc $CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
86
}
87

    
88
if test ! -z "$cpu" ; then
89
  # command line argument
90
  :
91
elif check_define __i386__ ; then
92
  cpu="i386"
93
elif check_define __x86_64__ ; then
94
  cpu="x86_64"
95
elif check_define __sparc__ ; then
96
  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
97
  # They must be specified using --sparc_cpu
98
  if check_define __arch64__ ; then
99
    cpu="sparc64"
100
  else
101
    cpu="sparc"
102
  fi
103
elif check_define _ARCH_PPC ; then
104
  if check_define _ARCH_PPC64 ; then
105
    cpu="ppc64"
106
  else
107
    cpu="ppc"
108
  fi
109
else
110
  cpu=`uname -m`
111
fi
112

    
113
target_list=""
114
case "$cpu" in
115
  i386|i486|i586|i686|i86pc|BePC)
116
    cpu="i386"
117
  ;;
118
  x86_64|amd64)
119
    cpu="x86_64"
120
  ;;
121
  alpha)
122
    cpu="alpha"
123
  ;;
124
  armv*b)
125
    cpu="armv4b"
126
  ;;
127
  armv*l)
128
    cpu="armv4l"
129
  ;;
130
  cris)
131
    cpu="cris"
132
  ;;
133
  parisc|parisc64)
134
    cpu="hppa"
135
  ;;
136
  ia64)
137
    cpu="ia64"
138
  ;;
139
  m68k)
140
    cpu="m68k"
141
  ;;
142
  microblaze)
143
    cpu="microblaze"
144
  ;;
145
  mips)
146
    cpu="mips"
147
  ;;
148
  mips64)
149
    cpu="mips64"
150
  ;;
151
  ppc)
152
    cpu="ppc"
153
  ;;
154
  ppc64)
155
    cpu="ppc64"
156
  ;;
157
  s390*)
158
    cpu="s390"
159
  ;;
160
  sparc|sun4[cdmuv])
161
    cpu="sparc"
162
  ;;
163
  sparc64)
164
    cpu="sparc64"
165
  ;;
166
  *)
167
    cpu="unknown"
168
  ;;
169
esac
170
brlapi="yes"
171
gprof="no"
172
debug_tcg="no"
173
debug="no"
174
sparse="no"
175
strip_opt="yes"
176
bigendian="no"
177
mingw32="no"
178
EXESUF=""
179
slirp="yes"
180
vde="yes"
181
fmod_lib=""
182
fmod_inc=""
183
oss_lib=""
184
vnc_tls="yes"
185
vnc_sasl="yes"
186
bsd="no"
187
linux="no"
188
solaris="no"
189
kqemu="no"
190
profiler="no"
191
cocoa="no"
192
softmmu="yes"
193
linux_user="no"
194
darwin_user="no"
195
bsd_user="no"
196
guest_base=""
197
build_docs="yes"
198
uname_release=""
199
curses="yes"
200
curl="yes"
201
pthread="yes"
202
aio="yes"
203
io_thread="no"
204
nptl="yes"
205
mixemu="no"
206
bluez="yes"
207
kvm="no"
208
kerneldir=""
209
aix="no"
210
blobs="yes"
211
fdt="yes"
212
sdl="yes"
213
xen="yes"
214
pkgversion=""
215

    
216
# OS specific
217
if check_define __linux__ ; then
218
  targetos="Linux"
219
elif check_define _WIN32 ; then
220
  targetos='MINGW32'
221
elif check_define __OpenBSD__ ; then
222
  targetos='OpenBSD'
223
elif check_define __sun__ ; then
224
  targetos='SunOS'
225
else
226
  targetos=`uname -s`
227
fi
228
case $targetos in
229
CYGWIN*)
230
mingw32="yes"
231
CFLAGS="-mno-cygwin $CFLAGS"
232
if [ "$cpu" = "i386" ] ; then
233
    kqemu="yes"
234
fi
235
audio_possible_drivers="sdl"
236
;;
237
MINGW32*)
238
mingw32="yes"
239
if [ "$cpu" = "i386" ] ; then
240
    kqemu="yes"
241
fi
242
audio_possible_drivers="dsound sdl fmod"
243
;;
244
GNU/kFreeBSD)
245
audio_drv_list="oss"
246
audio_possible_drivers="oss sdl esd pa"
247
if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
248
    kqemu="yes"
249
fi
250
;;
251
FreeBSD)
252
bsd="yes"
253
audio_drv_list="oss"
254
audio_possible_drivers="oss sdl esd pa"
255
if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
256
    kqemu="yes"
257
fi
258
;;
259
DragonFly)
260
bsd="yes"
261
audio_drv_list="oss"
262
audio_possible_drivers="oss sdl esd pa"
263
if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
264
    kqemu="yes"
265
fi
266
aio="no"
267
;;
268
NetBSD)
269
bsd="yes"
270
audio_drv_list="oss"
271
audio_possible_drivers="oss sdl esd"
272
oss_lib="-lossaudio"
273
;;
274
OpenBSD)
275
bsd="yes"
276
audio_drv_list="oss"
277
audio_possible_drivers="oss sdl esd"
278
oss_lib="-lossaudio"
279
;;
280
Darwin)
281
bsd="yes"
282
darwin="yes"
283
# on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can run 64-bit userspace code
284
if [ "$cpu" = "i386" ] ; then
285
    is_x86_64=`sysctl -n hw.optional.x86_64`
286
    [ "$is_x86_64" = "1" ] && cpu=x86_64
287
fi
288
if [ "$cpu" = "x86_64" ] ; then
289
    CFLAGS="-arch x86_64 $CFLAGS"
290
    LDFLAGS="-arch x86_64 $LDFLAGS"
291
else
292
    CFLAGS="-mdynamic-no-pic $CFLAGS"
293
fi
294
darwin_user="yes"
295
cocoa="yes"
296
audio_drv_list="coreaudio"
297
audio_possible_drivers="coreaudio sdl fmod"
298
LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
299
;;
300
SunOS)
301
    solaris="yes"
302
    make="gmake"
303
    install="ginstall"
304
    needs_libsunmath="no"
305
    solarisrev=`uname -r | cut -f2 -d.`
306
    # have to select again, because `uname -m` returns i86pc
307
    # even on an x86_64 box.
308
    solariscpu=`isainfo -k`
309
    if test "${solariscpu}" = "amd64" ; then
310
        cpu="x86_64"
311
    fi
312
    if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
313
        if test "$solarisrev" -le 9 ; then
314
            if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
315
                needs_libsunmath="yes"
316
            else
317
                echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
318
                echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
319
                echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
320
                echo "Studio 11 can be downloaded from www.sun.com."
321
                exit 1
322
            fi
323
        fi
324
        if test "$solarisrev" -ge 9 ; then
325
            kqemu="yes"
326
        fi
327
    fi
328
    if test -f /usr/include/sys/soundcard.h ; then
329
        audio_drv_list="oss"
330
    fi
331
    audio_possible_drivers="oss sdl"
332
    CFLAGS="-std=gnu99 $CFLAGS"
333
;;
334
AIX)
335
aix="yes"
336
make="gmake"
337
;;
338
*)
339
audio_drv_list="oss"
340
audio_possible_drivers="oss alsa sdl esd pa"
341
linux="yes"
342
linux_user="yes"
343
usb="linux"
344
kvm="yes"
345
if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
346
    kqemu="yes"
347
    audio_possible_drivers="$audio_possible_drivers fmod"
348
fi
349
;;
350
esac
351

    
352
if [ "$bsd" = "yes" ] ; then
353
  if [ "$darwin" != "yes" ] ; then
354
    make="gmake"
355
    usb="bsd"
356
  fi
357
  bsd_user="yes"
358
fi
359

    
360
# find source path
361
source_path=`dirname "$0"`
362
source_path_used="no"
363
workdir=`pwd`
364
if [ -z "$source_path" ]; then
365
    source_path=$workdir
366
else
367
    source_path=`cd "$source_path"; pwd`
368
fi
369
[ -f "$workdir/vl.c" ] || source_path_used="yes"
370

    
371
werror=""
372

    
373
for opt do
374
  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
375
  case "$opt" in
376
  --help|-h) show_help=yes
377
  ;;
378
  --prefix=*) prefix="$optarg"
379
  ;;
380
  --interp-prefix=*) interp_prefix="$optarg"
381
  ;;
382
  --source-path=*) source_path="$optarg"
383
  source_path_used="yes"
384
  ;;
385
  --cross-prefix=*)
386
  ;;
387
  --cc=*)
388
  ;;
389
  --host-cc=*) host_cc="$optarg"
390
  ;;
391
  --make=*) make="$optarg"
392
  ;;
393
  --install=*) install="$optarg"
394
  ;;
395
  --extra-cflags=*)
396
  ;;
397
  --extra-ldflags=*)
398
  ;;
399
  --cpu=*)
400
  ;;
401
  --target-list=*) target_list="$optarg"
402
  ;;
403
  --enable-gprof) gprof="yes"
404
  ;;
405
  --static) static="yes"
406
  ;;
407
  --disable-sdl) sdl="no"
408
  ;;
409
  --fmod-lib=*) fmod_lib="$optarg"
410
  ;;
411
  --fmod-inc=*) fmod_inc="$optarg"
412
  ;;
413
  --oss-lib=*) oss_lib="$optarg"
414
  ;;
415
  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
416
  ;;
417
  --audio-drv-list=*) audio_drv_list="$optarg"
418
  ;;
419
  --enable-debug-tcg) debug_tcg="yes"
420
  ;;
421
  --disable-debug-tcg) debug_tcg="no"
422
  ;;
423
  --enable-debug)
424
      # Enable debugging options that aren't excessively noisy
425
      debug_tcg="yes"
426
      debug="yes"
427
      strip_opt="no"
428
  ;;
429
  --enable-sparse) sparse="yes"
430
  ;;
431
  --disable-sparse) sparse="no"
432
  ;;
433
  --disable-strip) strip_opt="no"
434
  ;;
435
  --disable-vnc-tls) vnc_tls="no"
436
  ;;
437
  --disable-vnc-sasl) vnc_sasl="no"
438
  ;;
439
  --disable-slirp) slirp="no"
440
  ;;
441
  --disable-vde) vde="no"
442
  ;;
443
  --disable-kqemu) kqemu="no"
444
  ;;
445
  --disable-xen) xen="no"
446
  ;;
447
  --disable-brlapi) brlapi="no"
448
  ;;
449
  --disable-bluez) bluez="no"
450
  ;;
451
  --disable-kvm) kvm="no"
452
  ;;
453
  --enable-profiler) profiler="yes"
454
  ;;
455
  --enable-cocoa)
456
      cocoa="yes" ;
457
      sdl="no" ;
458
      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
459
  ;;
460
  --disable-system) softmmu="no"
461
  ;;
462
  --enable-system) softmmu="yes"
463
  ;;
464
  --disable-linux-user) linux_user="no"
465
  ;;
466
  --enable-linux-user) linux_user="yes"
467
  ;;
468
  --disable-darwin-user) darwin_user="no"
469
  ;;
470
  --enable-darwin-user) darwin_user="yes"
471
  ;;
472
  --disable-bsd-user) bsd_user="no"
473
  ;;
474
  --enable-bsd-user) bsd_user="yes"
475
  ;;
476
  --enable-guest-base) guest_base="yes"
477
  ;;
478
  --disable-guest-base) guest_base="no"
479
  ;;
480
  --enable-uname-release=*) uname_release="$optarg"
481
  ;;
482
  --sparc_cpu=*)
483
      sparc_cpu="$optarg"
484
      case $sparc_cpu in
485
        v7|v8)
486
          CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $CFLAGS"
487
          LDFLAGS="-m32 $LDFLAGS"
488
          cpu="sparc"
489
        ;;
490
        v8plus|v8plusa)
491
          CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $CFLAGS"
492
          LDFLAGS="-m32 $LDFLAGS"
493
          cpu="sparc"
494
        ;;
495
        v9)
496
          CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $CFLAGS"
497
          LDFLAGS="-m64 $LDFLAGS"
498
          cpu="sparc64"
499
        ;;
500
        *)
501
          echo "undefined SPARC architecture. Exiting";
502
          exit 1
503
        ;;
504
      esac
505
  ;;
506
  --enable-werror) werror="yes"
507
  ;;
508
  --disable-werror) werror="no"
509
  ;;
510
  --disable-curses) curses="no"
511
  ;;
512
  --disable-curl) curl="no"
513
  ;;
514
  --disable-nptl) nptl="no"
515
  ;;
516
  --enable-mixemu) mixemu="yes"
517
  ;;
518
  --disable-pthread) pthread="no"
519
  ;;
520
  --disable-aio) aio="no"
521
  ;;
522
  --enable-io-thread) io_thread="yes"
523
  ;;
524
  --disable-blobs) blobs="no"
525
  ;;
526
  --kerneldir=*) kerneldir="$optarg"
527
  ;;
528
  --with-pkgversion=*) pkgversion=" ($optarg)"
529
  ;;
530
  --disable-docs) build_docs="no"
531
  ;;
532
  *) echo "ERROR: unknown option $opt"; show_help="yes"
533
  ;;
534
  esac
535
done
536

    
537
#
538
# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
539
# CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
540
#
541
host_guest_base="no"
542
case "$cpu" in
543
    sparc) if test -z "$sparc_cpu" ; then
544
               CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__ $CFLAGS"
545
               LDFLAGS="-m32 $LDFLAGS"
546
           fi
547
           CFLAGS="-ffixed-g2 -ffixed-g3 $CFLAGS"
548
           if test "$solaris" = "no" ; then
549
               CFLAGS="-ffixed-g1 -ffixed-g6 $CFLAGS"
550
           fi
551
           ;;
552
    sparc64) if test -z "$sparc_cpu" ; then
553
               CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $CFLAGS"
554
               LDFLAGS="-m64 $LDFLAGS"
555
           fi
556
           if test "$solaris" = "no" ; then
557
               CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $CFLAGS"
558
           else
559
               CFLAGS="-ffixed-g1 -ffixed-g5 -ffixed-g6 -ffixed-g7 $CFLAGS"
560
           fi
561
           ;;
562
    s390)
563
           CFLAGS="-march=z900 $CFLAGS"
564
           ;;
565
    i386)
566
           CFLAGS="-m32 $CFLAGS"
567
           LDFLAGS="-m32 $LDFLAGS"
568
           host_guest_base="yes"
569
           ;;
570
    x86_64)
571
           CFLAGS="-m64 $CFLAGS"
572
           LDFLAGS="-m64 $LDFLAGS"
573
           host_guest_base="yes"
574
           ;;
575
    arm*)
576
           host_guest_base="yes"
577
           ;;
578
    ppc*)
579
           host_guest_base="yes"
580
           ;;
581
esac
582

    
583
[ -z "$guest_base" ] && guest_base="$host_guest_base"
584

    
585
if test x"$show_help" = x"yes" ; then
586
cat << EOF
587

    
588
Usage: configure [options]
589
Options: [defaults in brackets after descriptions]
590

    
591
EOF
592
echo "Standard options:"
593
echo "  --help                   print this message"
594
echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
595
echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
596
echo "                           use %M for cpu name [$interp_prefix]"
597
echo "  --target-list=LIST       set target list [$target_list]"
598
echo ""
599
echo "kqemu kernel acceleration support:"
600
echo "  --disable-kqemu          disable kqemu support"
601
echo ""
602
echo "Advanced options (experts only):"
603
echo "  --source-path=PATH       path of source code [$source_path]"
604
echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
605
echo "  --cc=CC                  use C compiler CC [$cc]"
606
echo "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
607
echo "  --extra-cflags=CFLAGS    append extra C compiler flags CFLAGS"
608
echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
609
echo "  --make=MAKE              use specified make [$make]"
610
echo "  --install=INSTALL        use specified install [$install]"
611
echo "  --static                 enable static build [$static]"
612
echo "  --enable-debug-tcg       enable TCG debugging"
613
echo "  --disable-debug-tcg      disable TCG debugging (default)"
614
echo "  --enable-debug           enable common debug build options"
615
echo "  --enable-sparse          enable sparse checker"
616
echo "  --disable-sparse         disable sparse checker (default)"
617
echo "  --disable-strip          disable stripping binaries"
618
echo "  --disable-werror         disable compilation abort on warning"
619
echo "  --disable-sdl            disable SDL"
620
echo "  --enable-cocoa           enable COCOA (Mac OS X only)"
621
echo "  --audio-drv-list=LIST    set audio drivers list:"
622
echo "                           Available drivers: $audio_possible_drivers"
623
echo "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
624
echo "                           Available cards: $audio_possible_cards"
625
echo "  --enable-mixemu          enable mixer emulation"
626
echo "  --disable-xen            disable xen backend driver support"
627
echo "  --disable-brlapi         disable BrlAPI"
628
echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
629
echo "  --disable-vnc-sasl       disable SASL encryption for VNC server"
630
echo "  --disable-curses         disable curses output"
631
echo "  --disable-curl           disable curl connectivity"
632
echo "  --disable-bluez          disable bluez stack connectivity"
633
echo "  --disable-kvm            disable KVM acceleration support"
634
echo "  --disable-nptl           disable usermode NPTL support"
635
echo "  --enable-system          enable all system emulation targets"
636
echo "  --disable-system         disable all system emulation targets"
637
echo "  --enable-linux-user      enable all linux usermode emulation targets"
638
echo "  --disable-linux-user     disable all linux usermode emulation targets"
639
echo "  --enable-darwin-user     enable all darwin usermode emulation targets"
640
echo "  --disable-darwin-user    disable all darwin usermode emulation targets"
641
echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
642
echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
643
echo "  --enable-guest-base      enable GUEST_BASE support for usermode"
644
echo "                           emulation targets"
645
echo "  --disable-guest-base     disable GUEST_BASE support"
646
echo "  --fmod-lib               path to FMOD library"
647
echo "  --fmod-inc               path to FMOD includes"
648
echo "  --oss-lib                path to OSS library"
649
echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
650
echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
651
echo "  --disable-vde            disable support for vde network"
652
echo "  --disable-pthread        disable pthread support"
653
echo "  --disable-aio            disable AIO support"
654
echo "  --enable-io-thread       enable IO thread"
655
echo "  --disable-blobs          disable installing provided firmware blobs"
656
echo "  --kerneldir=PATH         look for kernel includes in PATH"
657
echo ""
658
echo "NOTE: The object files are built at the place where configure is launched"
659
exit 1
660
fi
661

    
662
if test "$mingw32" = "yes" ; then
663
    linux="no"
664
    EXESUF=".exe"
665
    linux_user="no"
666
    bsd_user="no"
667
    CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $CFLAGS"
668
fi
669

    
670
if test ! -x "$(which cgcc 2>/dev/null)"; then
671
    sparse="no"
672
fi
673

    
674
#
675
# Solaris specific configure tool chain decisions
676
#
677
if test "$solaris" = "yes" ; then
678
  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
679
  if test -z "$solinst" ; then
680
    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
681
    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
682
    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
683
    exit 1
684
  fi
685
  if test "$solinst" = "/usr/sbin/install" ; then
686
    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
687
    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
688
    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
689
    exit 1
690
  fi
691
  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
692
  if test -z "$sol_ar" ; then
693
    echo "Error: No path includes ar"
694
    if test -f /usr/ccs/bin/ar ; then
695
      echo "Add /usr/ccs/bin to your path and rerun configure"
696
    fi
697
    exit 1
698
  fi
699
fi
700

    
701

    
702
if test -z "$target_list" ; then
703
# these targets are portable
704
    if [ "$softmmu" = "yes" ] ; then
705
        target_list="\
706
i386-softmmu \
707
x86_64-softmmu \
708
arm-softmmu \
709
cris-softmmu \
710
m68k-softmmu \
711
microblaze-softmmu \
712
mips-softmmu \
713
mipsel-softmmu \
714
mips64-softmmu \
715
mips64el-softmmu \
716
ppc-softmmu \
717
ppcemb-softmmu \
718
ppc64-softmmu \
719
sh4-softmmu \
720
sh4eb-softmmu \
721
sparc-softmmu \
722
sparc64-softmmu \
723
"
724
    fi
725
# the following are Linux specific
726
    if [ "$linux_user" = "yes" ] ; then
727
        target_list="${target_list}\
728
i386-linux-user \
729
x86_64-linux-user \
730
alpha-linux-user \
731
arm-linux-user \
732
armeb-linux-user \
733
cris-linux-user \
734
m68k-linux-user \
735
microblaze-linux-user \
736
mips-linux-user \
737
mipsel-linux-user \
738
ppc-linux-user \
739
ppc64-linux-user \
740
ppc64abi32-linux-user \
741
sh4-linux-user \
742
sh4eb-linux-user \
743
sparc-linux-user \
744
sparc64-linux-user \
745
sparc32plus-linux-user \
746
"
747
    fi
748
# the following are Darwin specific
749
    if [ "$darwin_user" = "yes" ] ; then
750
        target_list="$target_list i386-darwin-user ppc-darwin-user "
751
    fi
752
# the following are BSD specific
753
    if [ "$bsd_user" = "yes" ] ; then
754
        target_list="${target_list}\
755
i386-bsd-user \
756
x86_64-bsd-user \
757
sparc-bsd-user \
758
sparc64-bsd-user \
759
"
760
    fi
761
else
762
    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
763
fi
764
if test -z "$target_list" ; then
765
    echo "No targets enabled"
766
    exit 1
767
fi
768

    
769
if test -z "$cross_prefix" ; then
770

    
771
# ---
772
# big/little endian test
773
cat > $TMPC << EOF
774
#include <inttypes.h>
775
int main(int argc, char ** argv){
776
        volatile uint32_t i=0x01234567;
777
        return (*((uint8_t*)(&i))) == 0x67;
778
}
779
EOF
780

    
781
if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
782
$TMPE && bigendian="yes"
783
else
784
echo big/little test failed
785
fi
786

    
787
else
788

    
789
# if cross compiling, cannot launch a program, so make a static guess
790
if test "$cpu" = "armv4b" \
791
     -o "$cpu" = "hppa" \
792
     -o "$cpu" = "m68k" \
793
     -o "$cpu" = "mips" \
794
     -o "$cpu" = "mips64" \
795
     -o "$cpu" = "ppc" \
796
     -o "$cpu" = "ppc64" \
797
     -o "$cpu" = "s390" \
798
     -o "$cpu" = "sparc" \
799
     -o "$cpu" = "sparc64"; then
800
    bigendian="yes"
801
fi
802

    
803
fi
804

    
805
# host long bits test
806
hostlongbits="32"
807
if test "$cpu" = "x86_64" \
808
     -o "$cpu" = "alpha" \
809
     -o "$cpu" = "ia64" \
810
     -o "$cpu" = "sparc64" \
811
     -o "$cpu" = "ppc64"; then
812
    hostlongbits="64"
813
fi
814

    
815
# Check host NPTL support
816
cat > $TMPC <<EOF
817
#include <sched.h>
818
#include <linux/futex.h>
819
void foo()
820
{
821
#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
822
#error bork
823
#endif
824
}
825
EOF
826

    
827
if $cc $CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
828
  :
829
else
830
   nptl="no"
831
fi
832

    
833
##########################################
834
# zlib check
835

    
836
cat > $TMPC << EOF
837
#include <zlib.h>
838
int main(void) { zlibVersion(); return 0; }
839
EOF
840
if $cc $CFLAGS -o $TMPE $TMPC -lz > /dev/null 2> /dev/null ; then
841
    :
842
else
843
    echo
844
    echo "Error: zlib check failed"
845
    echo "Make sure to have the zlib libs and headers installed."
846
    echo
847
    exit 1
848
fi
849

    
850
##########################################
851
# xen probe
852

    
853
if test "$xen" = "yes" ; then
854
  xen_libs="-lxenstore -lxenctrl -lxenguest"
855
  cat > $TMPC <<EOF
856
#include <xenctrl.h>
857
#include <xs.h>
858
int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
859
EOF
860
  if $cc $CFLAGS -c -o $TMPO $TMPC $LDFLAGS $xen_libs 2> /dev/null > /dev/null ; then
861
    :
862
  else
863
    xen="no"
864
  fi
865
fi
866

    
867
##########################################
868
# SDL probe
869

    
870
sdl_too_old=no
871

    
872
if test "$sdl" = "yes" ; then
873
  sdl=no
874
  cat > $TMPC << EOF
875
#include <SDL.h>
876
#undef main /* We don't want SDL to override our main() */
877
int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
878
EOF
879
  sdl_cflags=`sdl-config --cflags 2> /dev/null`
880
  sdl_libs=`sdl-config --libs 2> /dev/null`
881
  if $cc $CFLAGS -o $TMPE $sdl_cflags $TMPC $sdl_libs > $TMPSDLLOG 2>&1 ; then
882
    _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
883
    if test "$_sdlversion" -lt 121 ; then
884
      sdl_too_old=yes
885
    else
886
      if test "$cocoa" = "no" ; then
887
        sdl=yes
888
      fi
889
    fi
890

    
891
    # static link with sdl ?
892
    if test "$sdl" = "yes" -a "$static" = "yes" ; then
893
      sdl_libs=`sdl-config --static-libs 2>/dev/null`
894
      if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
895
         sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
896
         sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
897
      fi
898
      if $cc -o $TMPE $CFLAGS $sdl_cflags $TMPC $sdl_libs > /dev/null 2> /dev/null; then
899
	:
900
      else
901
        sdl=no
902
      fi
903
    fi # static link
904
  fi # sdl compile test
905
fi
906

    
907
if test "$sdl" = "yes" ; then
908
  cat > $TMPC <<EOF
909
#include <SDL.h>
910
#if defined(SDL_VIDEO_DRIVER_X11)
911
#include <X11/XKBlib.h>
912
#else
913
#error No x11 support
914
#endif
915
int main(void) { return 0; }
916
EOF
917
  if $cc $CFLAGS -o $TMPE $sdl_cflags $TMPC $sdl_libs > /dev/null 2>&1 ; then
918
    sdl_libs="$sdl_libs -lX11"
919
  fi
920
fi
921

    
922
##########################################
923
# VNC TLS detection
924
if test "$vnc_tls" = "yes" ; then
925
cat > $TMPC <<EOF
926
#include <gnutls/gnutls.h>
927
int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
928
EOF
929
    vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
930
    vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
931
    if $cc $CFLAGS -o $TMPE $vnc_tls_cflags $TMPC \
932
           $vnc_tls_libs > /dev/null 2> /dev/null ; then
933
	:
934
    else
935
	vnc_tls="no"
936
    fi
937
fi
938

    
939
##########################################
940
# VNC SASL detection
941
if test "$vnc_sasl" = "yes" ; then
942
cat > $TMPC <<EOF
943
#include <sasl/sasl.h>
944
#include <stdio.h>
945
int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
946
EOF
947
    # Assuming Cyrus-SASL installed in /usr prefix
948
    vnc_sasl_cflags=""
949
    vnc_sasl_libs="-lsasl2"
950
    if $cc $CFLAGS -o $TMPE $vnc_sasl_cflags $TMPC \
951
           $vnc_sasl_libs 2> /dev/null > /dev/null ; then
952
	:
953
    else
954
	vnc_sasl="no"
955
    fi
956
fi
957

    
958
##########################################
959
# fnmatch() probe, used for ACL routines
960
fnmatch="no"
961
cat > $TMPC << EOF
962
#include <fnmatch.h>
963
int main(void)
964
{
965
    fnmatch("foo", "foo", 0);
966
    return 0;
967
}
968
EOF
969
if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
970
   fnmatch="yes"
971
fi
972

    
973
##########################################
974
# vde libraries probe
975
if test "$vde" = "yes" ; then
976
  vde=no
977
  vde_libs="-lvdeplug"
978
  cat > $TMPC << EOF
979
#include <libvdeplug.h>
980
int main(void)
981
{
982
    struct vde_open_args a = {0, 0, 0};
983
    vde_open("", "", &a);
984
    return 0;
985
}
986
EOF
987
  if $cc $CFLAGS -o $TMPE $TMPC $vde_libs > /dev/null 2> /dev/null ; then
988
    vde=yes
989
  fi
990
fi
991

    
992
##########################################
993
# Sound support libraries probe
994

    
995
audio_drv_probe()
996
{
997
    drv=$1
998
    hdr=$2
999
    lib=$3
1000
    exp=$4
1001
    cfl=$5
1002
        cat > $TMPC << EOF
1003
#include <$hdr>
1004
int main(void) { $exp }
1005
EOF
1006
    if $cc $CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
1007
        :
1008
    else
1009
        echo
1010
        echo "Error: $drv check failed"
1011
        echo "Make sure to have the $drv libs and headers installed."
1012
        echo
1013
        exit 1
1014
    fi
1015
}
1016

    
1017
audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1018
for drv in $audio_drv_list; do
1019
    case $drv in
1020
    alsa)
1021
    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1022
        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1023
    ;;
1024

    
1025
    fmod)
1026
    if test -z $fmod_lib || test -z $fmod_inc; then
1027
        echo
1028
        echo "Error: You must specify path to FMOD library and headers"
1029
        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1030
        echo
1031
        exit 1
1032
    fi
1033
    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1034
    ;;
1035

    
1036
    esd)
1037
    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1038
    ;;
1039

    
1040
    pa)
1041
    audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1042
        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1043
    ;;
1044

    
1045
    oss|sdl|core|wav|dsound)
1046
    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1047
    ;;
1048

    
1049
    *)
1050
    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1051
        echo
1052
        echo "Error: Unknown driver '$drv' selected"
1053
        echo "Possible drivers are: $audio_possible_drivers"
1054
        echo
1055
        exit 1
1056
    }
1057
    ;;
1058
    esac
1059
done
1060

    
1061
##########################################
1062
# BrlAPI probe
1063

    
1064
if test "$brlapi" = "yes" ; then
1065
  brlapi=no
1066
  brlapi_libs="-lbrlapi"
1067
  cat > $TMPC << EOF
1068
#include <brlapi.h>
1069
int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1070
EOF
1071
  if $cc $CFLAGS -o $TMPE $TMPC $brlapi_libs > /dev/null 2> /dev/null ; then
1072
    brlapi=yes
1073
  fi
1074
fi
1075

    
1076
##########################################
1077
# curses probe
1078

    
1079
if test "$curses" = "yes" ; then
1080
  cat > $TMPC << EOF
1081
#include <curses.h>
1082
#ifdef __OpenBSD__
1083
#define resize_term resizeterm
1084
#endif
1085
int main(void) { resize_term(0, 0); return curses_version(); }
1086
EOF
1087
  if $cc $CFLAGS -o $TMPE $TMPC -lncurses > /dev/null 2> /dev/null ; then
1088
    curses_libs="-lncurses"
1089
  elif $cc $CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
1090
    curses_libs="-lcurses"
1091
  else
1092
    curses=no
1093
  fi
1094
fi # test "$curses"
1095

    
1096
##########################################
1097
# curl probe
1098

    
1099
if test "$curl" = "yes" ; then
1100
  curl=no
1101
  cat > $TMPC << EOF
1102
#include <curl/curl.h>
1103
int main(void) { return curl_easy_init(); }
1104
EOF
1105
  curl_libs=`curl-config --libs 2>/dev/null`
1106
 if $cc $CFLAGS $curl_libs -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1107
    curl=yes
1108
  fi
1109
fi # test "$curl"
1110

    
1111
##########################################
1112
# bluez support probe
1113
if test "$bluez" = "yes" ; then
1114
  `pkg-config bluez 2> /dev/null` || bluez="no"
1115
fi
1116
if test "$bluez" = "yes" ; then
1117
  cat > $TMPC << EOF
1118
#include <bluetooth/bluetooth.h>
1119
int main(void) { return bt_error(0); }
1120
EOF
1121
  bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1122
  bluez_libs=`pkg-config --libs bluez 2> /dev/null`
1123
  if $cc $CFLAGS -o $TMPE $bluez_cflags $TMPC \
1124
      $bluez_libs > /dev/null 2> /dev/null ; then
1125
    :
1126
  else
1127
    bluez="no"
1128
  fi
1129
fi
1130

    
1131
##########################################
1132
# kvm probe
1133
if test "$kvm" = "yes" ; then
1134
    cat > $TMPC <<EOF
1135
#include <linux/kvm.h>
1136
#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1137
#error Invalid KVM version
1138
#endif
1139
#if !defined(KVM_CAP_USER_MEMORY)
1140
#error Missing KVM capability KVM_CAP_USER_MEMORY
1141
#endif
1142
#if !defined(KVM_CAP_SET_TSS_ADDR)
1143
#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1144
#endif
1145
#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1146
#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1147
#endif
1148
int main(void) { return 0; }
1149
EOF
1150
  if test "$kerneldir" != "" ; then
1151
      kvm_cflags=-I"$kerneldir"/include
1152
      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1153
         -a -d "$kerneldir/arch/x86/include" ; then
1154
            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1155
	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1156
	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1157
        elif test -d "$kerneldir/arch/$cpu/include" ; then
1158
            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1159
      fi
1160
  else
1161
      kvm_cflags=""
1162
  fi
1163
  if $cc $CFLAGS -o $TMPE $kvm_cflags $TMPC \
1164
      > /dev/null 2>/dev/null ; then
1165
    :
1166
  else
1167
    kvm="no";
1168
    if [ -x "`which awk 2>/dev/null`" ] && \
1169
       [ -x "`which grep 2>/dev/null`" ]; then
1170
      kvmerr=`LANG=C $cc $CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1171
	| grep "error: " \
1172
	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1173
      if test "$kvmerr" != "" ; then
1174
        kvm="no - (${kvmerr})\n\
1175
    NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1176
recent kvm-kmod from http://sourceforge.net/projects/kvm."
1177
      fi
1178
    fi
1179
  fi
1180
fi
1181

    
1182
##########################################
1183
# pthread probe
1184
PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1185
PTHREADLIBS=""
1186

    
1187
if test "$pthread" = yes; then
1188
  pthread=no
1189
cat > $TMPC << EOF
1190
#include <pthread.h>
1191
int main(void) { pthread_create(0,0,0,0); return 0; }
1192
EOF
1193
  for pthread_lib in $PTHREADLIBS_LIST; do
1194
    if $cc $CFLAGS -o $TMPE $TMPC $pthread_lib 2> /dev/null > /dev/null ; then
1195
      pthread=yes
1196
      PTHREADLIBS="$pthread_lib"
1197
      break
1198
    fi
1199
  done
1200
fi
1201

    
1202
if test "$pthread" = no; then
1203
   aio=no
1204
   io_thread=no
1205
fi
1206

    
1207
##########################################
1208
# iovec probe
1209
cat > $TMPC <<EOF
1210
#include <sys/types.h>
1211
#include <sys/uio.h>
1212
#include <unistd.h>
1213
int main(void) { struct iovec iov; return 0; }
1214
EOF
1215
iovec=no
1216
if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1217
  iovec=yes
1218
fi
1219

    
1220
##########################################
1221
# preadv probe
1222
cat > $TMPC <<EOF
1223
#include <sys/types.h>
1224
#include <sys/uio.h>
1225
#include <unistd.h>
1226
int main(void) { preadv; }
1227
EOF
1228
preadv=no
1229
if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1230
  preadv=yes
1231
fi
1232

    
1233
##########################################
1234
# fdt probe
1235
if test "$fdt" = "yes" ; then
1236
  fdt=no
1237
  fdt_libs="-lfdt"
1238
  cat > $TMPC << EOF
1239
int main(void) { return 0; }
1240
EOF
1241
  if $cc $CFLAGS -o $TMPE $TMPC $fdt_libs 2> /dev/null > /dev/null ; then
1242
    fdt=yes
1243
  fi
1244
fi
1245

    
1246
#
1247
# Check for xxxat() functions when we are building linux-user
1248
# emulator.  This is done because older glibc versions don't
1249
# have syscall stubs for these implemented.
1250
#
1251
atfile=no
1252
cat > $TMPC << EOF
1253
#define _ATFILE_SOURCE
1254
#include <sys/types.h>
1255
#include <fcntl.h>
1256
#include <unistd.h>
1257

    
1258
int
1259
main(void)
1260
{
1261
	/* try to unlink nonexisting file */
1262
	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1263
}
1264
EOF
1265
if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
1266
  atfile=yes
1267
fi
1268

    
1269
# Check for inotify functions when we are building linux-user
1270
# emulator.  This is done because older glibc versions don't
1271
# have syscall stubs for these implemented.  In that case we
1272
# don't provide them even if kernel supports them.
1273
#
1274
inotify=no
1275
cat > $TMPC << EOF
1276
#include <sys/inotify.h>
1277

    
1278
int
1279
main(void)
1280
{
1281
	/* try to start inotify */
1282
	return inotify_init();
1283
}
1284
EOF
1285
if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
1286
  inotify=yes
1287
fi
1288

    
1289
# check if utimensat and futimens are supported
1290
utimens=no
1291
cat > $TMPC << EOF
1292
#define _ATFILE_SOURCE
1293
#define _GNU_SOURCE
1294
#include <stddef.h>
1295
#include <fcntl.h>
1296

    
1297
int main(void)
1298
{
1299
    utimensat(AT_FDCWD, "foo", NULL, 0);
1300
    futimens(0, NULL);
1301
    return 0;
1302
}
1303
EOF
1304
if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1305
  utimens=yes
1306
fi
1307

    
1308
# check if pipe2 is there
1309
pipe2=no
1310
cat > $TMPC << EOF
1311
#define _GNU_SOURCE
1312
#include <unistd.h>
1313
#include <fcntl.h>
1314

    
1315
int main(void)
1316
{
1317
    int pipefd[2];
1318
    pipe2(pipefd, O_CLOEXEC);
1319
    return 0;
1320
}
1321
EOF
1322
if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1323
  pipe2=yes
1324
fi
1325

    
1326
# check if tee/splice is there. vmsplice was added same time.
1327
splice=no
1328
cat > $TMPC << EOF
1329
#define _GNU_SOURCE
1330
#include <unistd.h>
1331
#include <fcntl.h>
1332
#include <limits.h>
1333

    
1334
int main(void)
1335
{
1336
    int len, fd;
1337
    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1338
    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1339
    return 0;
1340
}
1341
EOF
1342
if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1343
  splice=yes
1344
fi
1345

    
1346
# Check if tools are available to build documentation.
1347
if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then
1348
  build_docs="no"
1349
fi
1350

    
1351
# Search for bsawp_32 function
1352
byteswap_h=no
1353
cat > $TMPC << EOF
1354
#include <byteswap.h>
1355
int main(void) { return bswap_32(0); }
1356
EOF
1357
if $cc $CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1358
  byteswap_h=yes
1359
fi
1360

    
1361
# Search for bsawp_32 function
1362
bswap_h=no
1363
cat > $TMPC << EOF
1364
#include <sys/endian.h>
1365
#include <sys/types.h>
1366
#include <machine/bswap.h>
1367
int main(void) { return bswap32(0); }
1368
EOF
1369
if $cc $CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1370
  bswap_h=yes
1371
fi
1372

    
1373
##########################################
1374
# Do we need librt
1375
cat > $TMPC <<EOF
1376
#include <signal.h>
1377
#include <time.h>
1378
int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1379
EOF
1380

    
1381
if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1382
  CLOCKLIBS=""
1383
elif $cc $CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
1384
  CLOCKLIBS="-lrt"
1385
fi
1386

    
1387
# Determine what linker flags to use to force archive inclusion
1388
check_linker_flags()
1389
{
1390
    w2=
1391
    if test "$2" ; then
1392
	w2=-Wl,$2
1393
    fi
1394
    $cc $CFLAGS -o $TMPE $TMPC -Wl,$1 ${w2} >/dev/null 2>/dev/null
1395
}
1396

    
1397
cat > $TMPC << EOF
1398
int main(void) { }
1399
EOF
1400
if check_linker_flags --whole-archive --no-whole-archive ; then
1401
    # GNU ld
1402
    arlibs_begin="-Wl,--whole-archive"
1403
    arlibs_end="-Wl,--no-whole-archive"
1404
elif check_linker_flags -z,allextract -z,defaultextract ; then
1405
    # Solaris ld
1406
    arlibs_begin"=-Wl,-z,allextract"
1407
    arlibs_end="-Wl,-z,defaultextract"
1408
elif check_linker_flags -all_load ; then
1409
    # Mac OS X
1410
    arlibs_begin="-all_load"
1411
    arlibs_end=""
1412
else
1413
    echo "Error: your linker does not support --whole-archive or -z."
1414
    echo "Please report to qemu-devel@nongnu.org"
1415
    exit 1
1416
fi
1417

    
1418
# End of CC checks
1419
# After here, no more $cc or $ld runs
1420

    
1421
# default flags for all hosts
1422
CFLAGS="-g -fno-strict-aliasing $CFLAGS"
1423
if test "$debug" = "no" ; then
1424
  CFLAGS="-O2 $CFLAGS"
1425
fi
1426
CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls $CFLAGS"
1427
LDFLAGS="-g $LDFLAGS"
1428

    
1429
# Consult white-list to determine whether to enable werror
1430
# by default.  Only enable by default for git builds
1431
if test -z "$werror" ; then
1432
    z_version=`cut -f3 -d. $source_path/VERSION`
1433
    if test "$z_version" = "50" -a \
1434
        "$linux" = "yes" ; then
1435
        werror="yes"
1436
    else
1437
        werror="no"
1438
    fi
1439
fi
1440

    
1441
if test "$werror" = "yes" ; then
1442
    CFLAGS="-Werror $CFLAGS"
1443
fi
1444

    
1445
if test "$solaris" = "no" ; then
1446
    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1447
        LDFLAGS="-Wl,--warn-common $LDFLAGS"
1448
    fi
1449
fi
1450

    
1451
if test "$mingw32" = "yes" ; then
1452
  if test -z "$prefix" ; then
1453
      prefix="c:/Program Files/Qemu"
1454
  fi
1455
  mansuffix=""
1456
  datasuffix=""
1457
  docsuffix=""
1458
  binsuffix=""
1459
else
1460
  if test -z "$prefix" ; then
1461
      prefix="/usr/local"
1462
  fi
1463
  mansuffix="/share/man"
1464
  datasuffix="/share/qemu"
1465
  docsuffix="/share/doc/qemu"
1466
  binsuffix="/bin"
1467
fi
1468

    
1469
echo "Install prefix    $prefix"
1470
echo "BIOS directory    $prefix$datasuffix"
1471
echo "binary directory  $prefix$binsuffix"
1472
if test "$mingw32" = "no" ; then
1473
echo "Manual directory  $prefix$mansuffix"
1474
echo "ELF interp prefix $interp_prefix"
1475
fi
1476
echo "Source path       $source_path"
1477
echo "C compiler        $cc"
1478
echo "Host C compiler   $host_cc"
1479
echo "CFLAGS            $CFLAGS"
1480
echo "LDFLAGS           $LDFLAGS"
1481
echo "make              $make"
1482
echo "install           $install"
1483
echo "host CPU          $cpu"
1484
echo "host big endian   $bigendian"
1485
echo "target list       $target_list"
1486
echo "tcg debug enabled $debug_tcg"
1487
echo "gprof enabled     $gprof"
1488
echo "sparse enabled    $sparse"
1489
echo "strip binaries    $strip_opt"
1490
echo "profiler          $profiler"
1491
echo "static build      $static"
1492
echo "-Werror enabled   $werror"
1493
if test "$darwin" = "yes" ; then
1494
    echo "Cocoa support     $cocoa"
1495
fi
1496
echo "SDL support       $sdl"
1497
echo "curses support    $curses"
1498
echo "curl support      $curl"
1499
echo "mingw32 support   $mingw32"
1500
echo "Audio drivers     $audio_drv_list"
1501
echo "Extra audio cards $audio_card_list"
1502
echo "Mixer emulation   $mixemu"
1503
echo "VNC TLS support   $vnc_tls"
1504
if test "$vnc_tls" = "yes" ; then
1505
    echo "    TLS CFLAGS    $vnc_tls_cflags"
1506
    echo "    TLS LIBS      $vnc_tls_libs"
1507
fi
1508
echo "VNC SASL support  $vnc_sasl"
1509
if test "$vnc_sasl" = "yes" ; then
1510
    echo "    SASL CFLAGS    $vnc_sasl_cflags"
1511
    echo "    SASL LIBS      $vnc_sasl_libs"
1512
fi
1513
if test -n "$sparc_cpu"; then
1514
    echo "Target Sparc Arch $sparc_cpu"
1515
fi
1516
echo "kqemu support     $kqemu"
1517
echo "xen support       $xen"
1518
echo "brlapi support    $brlapi"
1519
echo "Documentation     $build_docs"
1520
[ ! -z "$uname_release" ] && \
1521
echo "uname -r          $uname_release"
1522
echo "NPTL support      $nptl"
1523
echo "GUEST_BASE        $guest_base"
1524
echo "vde support       $vde"
1525
echo "AIO support       $aio"
1526
echo "IO thread         $io_thread"
1527
echo "Install blobs     $blobs"
1528
echo -e "KVM support       $kvm"
1529
echo "fdt support       $fdt"
1530
echo "preadv support    $preadv"
1531

    
1532
if test $sdl_too_old = "yes"; then
1533
echo "-> Your SDL version is too old - please upgrade to have SDL support"
1534
fi
1535

    
1536
config_host_mak="config-host.mak"
1537
config_host_h="config-host.h"
1538
config_host_ld="config-host.ld"
1539

    
1540
#echo "Creating $config_host_mak and $config_host_h"
1541

    
1542
test -f $config_host_h && mv $config_host_h ${config_host_h}~
1543

    
1544
echo "# Automatically generated by configure - do not modify" > $config_host_mak
1545
printf "# Configured with:" >> $config_host_mak
1546
printf " '%s'" "$0" "$@" >> $config_host_mak
1547
echo >> $config_host_mak
1548

    
1549
echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1550

    
1551
case "$cpu" in
1552
  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
1553
    ARCH=$cpu
1554
  ;;
1555
  armv4b|armv4l)
1556
    ARCH=arm
1557
  ;;
1558
  *)
1559
    echo "Unsupported CPU = $cpu"
1560
    exit 1
1561
  ;;
1562
esac
1563
echo "ARCH=$ARCH" >> $config_host_mak
1564
if test "$debug_tcg" = "yes" ; then
1565
  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1566
fi
1567
if test "$debug" = "yes" ; then
1568
  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1569
fi
1570
if test "$strip_opt" = "yes" ; then
1571
  echo "STRIP_OPT=-s" >> $config_host_mak
1572
fi
1573
if test "$bigendian" = "yes" ; then
1574
  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
1575
fi
1576
echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
1577
if test "$mingw32" = "yes" ; then
1578
  echo "CONFIG_WIN32=y" >> $config_host_mak
1579
else
1580
  echo "CONFIG_POSIX=y" >> $config_host_mak
1581
fi
1582

    
1583
if test "$darwin" = "yes" ; then
1584
  echo "CONFIG_DARWIN=y" >> $config_host_mak
1585
fi
1586

    
1587
if test "$aix" = "yes" ; then
1588
  echo "CONFIG_AIX=y" >> $config_host_mak
1589
fi
1590

    
1591
if test "$solaris" = "yes" ; then
1592
  echo "CONFIG_SOLARIS=y" >> $config_host_mak
1593
  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
1594
  if test "$needs_libsunmath" = "yes" ; then
1595
    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
1596
  fi
1597
fi
1598
if test -n "$sparc_cpu"; then
1599
  echo "CONFIG__sparc_${sparc_cpu}__=y" >> $config_host_mak
1600
fi
1601
if test "$gprof" = "yes" ; then
1602
  echo "TARGET_GPROF=yes" >> $config_host_mak
1603
fi
1604
if test "$static" = "yes" ; then
1605
  echo "CONFIG_STATIC=y" >> $config_host_mak
1606
  LDFLAGS="-static $LDFLAGS"
1607
fi
1608
if test $profiler = "yes" ; then
1609
  echo "CONFIG_PROFILER=y" >> $config_host_mak
1610
fi
1611
if test "$slirp" = "yes" ; then
1612
  echo "CONFIG_SLIRP=y" >> $config_host_mak
1613
fi
1614
if test "$vde" = "yes" ; then
1615
  echo "CONFIG_VDE=y" >> $config_host_mak
1616
  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
1617
fi
1618
for card in $audio_card_list; do
1619
    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1620
    echo "$def=y" >> $config_host_mak
1621
done
1622
echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
1623
for drv in $audio_drv_list; do
1624
    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1625
    echo "$def=y" >> $config_host_mak
1626
    if test "$drv" = "fmod"; then
1627
        echo "FMOD_LIBS=$fmod_lib" >> $config_host_mak
1628
        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1629
    elif test "$drv" = "oss"; then
1630
        echo "OSS_LIBS=$oss_lib" >> $config_host_mak
1631
    fi
1632
done
1633
if test "$mixemu" = "yes" ; then
1634
  echo "CONFIG_MIXEMU=y" >> $config_host_mak
1635
fi
1636
if test "$vnc_tls" = "yes" ; then
1637
  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
1638
  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
1639
  echo "VNC_TLS_LIBS=$vnc_tls_libs" >> $config_host_mak
1640
fi
1641
if test "$vnc_sasl" = "yes" ; then
1642
  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
1643
  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
1644
  echo "VNC_SASL_LIBS=$vnc_sasl_libs" >> $config_host_mak
1645
fi
1646
if test "$fnmatch" = "yes" ; then
1647
  echo "CONFIG_FNMATCH=y" >> $config_host_mak
1648
fi
1649
qemu_version=`head $source_path/VERSION`
1650
echo "VERSION=$qemu_version" >>$config_host_mak
1651
echo "PKGVERSION=$pkgversion" >>$config_host_mak
1652
echo "SRC_PATH=$source_path" >> $config_host_mak
1653
if [ "$source_path_used" = "yes" ]; then
1654
  echo "VPATH=$source_path" >> $config_host_mak
1655
fi
1656
echo "TARGET_DIRS=$target_list" >> $config_host_mak
1657
if [ "$build_docs" = "yes" ] ; then
1658
  echo "BUILD_DOCS=yes" >> $config_host_mak
1659
fi
1660
if test "$sdl" = "yes" ; then
1661
  echo "CONFIG_SDL=y" >> $config_host_mak
1662
  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
1663
  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
1664
fi
1665
if test "$cocoa" = "yes" ; then
1666
  echo "CONFIG_COCOA=y" >> $config_host_mak
1667
fi
1668
if test "$curses" = "yes" ; then
1669
  echo "CONFIG_CURSES=y" >> $config_host_mak
1670
  echo "CURSES_LIBS=$curses_libs" >> $config_host_mak
1671
fi
1672
if test "$atfile" = "yes" ; then
1673
  echo "CONFIG_ATFILE=y" >> $config_host_mak
1674
fi
1675
if test "$utimens" = "yes" ; then
1676
  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
1677
fi
1678
if test "$pipe2" = "yes" ; then
1679
  echo "CONFIG_PIPE2=y" >> $config_host_mak
1680
fi
1681
if test "$splice" = "yes" ; then
1682
  echo "CONFIG_SPLICE=y" >> $config_host_mak
1683
fi
1684
if test "$inotify" = "yes" ; then
1685
  echo "CONFIG_INOTIFY=y" >> $config_host_mak
1686
fi
1687
if test "$byteswap_h" = "yes" ; then
1688
  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
1689
fi
1690
if test "$bswap_h" = "yes" ; then
1691
  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
1692
fi
1693
if test "$curl" = "yes" ; then
1694
  echo "CONFIG_CURL=y" >> $config_host_mak
1695
  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
1696
fi
1697
if test "$brlapi" = "yes" ; then
1698
  echo "CONFIG_BRLAPI=y" >> $config_host_mak
1699
  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
1700
fi
1701
if test "$bluez" = "yes" ; then
1702
  echo "CONFIG_BLUEZ=y" >> $config_host_mak
1703
  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
1704
  echo "BLUEZ_LIBS=$bluez_libs" >> $config_host_mak
1705
fi
1706
if test "$xen" = "yes" ; then
1707
  echo "CONFIG_XEN=y" >> $config_host_mak
1708
  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
1709
fi
1710
if test "$aio" = "yes" ; then
1711
  echo "CONFIG_AIO=y" >> $config_host_mak
1712
fi
1713
if test "$io_thread" = "yes" ; then
1714
  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
1715
fi
1716
if test "$blobs" = "yes" ; then
1717
  echo "INSTALL_BLOBS=yes" >> $config_host_mak
1718
fi
1719
if test "$iovec" = "yes" ; then
1720
  echo "CONFIG_IOVEC=y" >> $config_host_mak
1721
fi
1722
if test "$preadv" = "yes" ; then
1723
  echo "CONFIG_PREADV=y" >> $config_host_mak
1724
fi
1725
if test "$fdt" = "yes" ; then
1726
  echo "CONFIG_FDT=y" >> $config_host_mak
1727
  echo "FDT_LIBS=$fdt_libs" >> $config_host_mak
1728
fi
1729

    
1730
# XXX: suppress that
1731
if [ "$bsd" = "yes" ] ; then
1732
  echo "CONFIG_BSD=y" >> $config_host_mak
1733
fi
1734

    
1735
echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
1736

    
1737
# USB host support
1738
case "$usb" in
1739
linux)
1740
  echo "HOST_USB=linux" >> $config_host_mak
1741
;;
1742
bsd)
1743
  echo "HOST_USB=bsd" >> $config_host_mak
1744
;;
1745
*)
1746
  echo "HOST_USB=stub" >> $config_host_mak
1747
;;
1748
esac
1749

    
1750
tools=
1751
if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1752
  tools="qemu-img\$(EXESUF) $tools"
1753
  if [ "$linux" = "yes" ] ; then
1754
      tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
1755
  fi
1756
fi
1757
echo "TOOLS=$tools" >> $config_host_mak
1758

    
1759
# Mac OS X ships with a broken assembler
1760
roms=
1761
if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
1762
        "$targetos" != "Darwin" ; then
1763
  roms="optionrom"
1764
fi
1765
echo "ROMS=$roms" >> $config_host_mak
1766

    
1767
echo "prefix=$prefix" >> $config_host_mak
1768
echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
1769
echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
1770
echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
1771
echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
1772
echo "MAKE=$make" >> $config_host_mak
1773
echo "INSTALL=$install" >> $config_host_mak
1774
echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
1775
echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
1776
echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
1777
echo "CC=$cc" >> $config_host_mak
1778
echo "HOST_CC=$host_cc" >> $config_host_mak
1779
if test "$sparse" = "yes" ; then
1780
  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
1781
  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
1782
  echo "CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
1783
fi
1784
echo "AR=$ar" >> $config_host_mak
1785
echo "OBJCOPY=$objcopy" >> $config_host_mak
1786
echo "LD=$ld" >> $config_host_mak
1787
echo "CFLAGS=$CFLAGS" >> $config_host_mak
1788
echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
1789
echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
1790
echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
1791
echo "EXESUF=$EXESUF" >> $config_host_mak
1792
echo "PTHREADLIBS=$PTHREADLIBS" >> $config_host_mak
1793
echo "CLOCKLIBS=$CLOCKLIBS" >> $config_host_mak
1794

    
1795
echo "/* Automatically generated by configure - do not modify */" > $config_host_h
1796

    
1797
$SHELL $source_path/create_config < $config_host_mak >> $config_host_h
1798

    
1799
if test -f ${config_host_h}~ ; then
1800
  if cmp -s $config_host_h ${config_host_h}~ ; then
1801
    mv ${config_host_h}~ $config_host_h
1802
  else
1803
    rm ${config_host_h}~
1804
  fi
1805
fi
1806

    
1807
# generate list of library paths for linker script
1808

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

    
1811
if test -f ${config_host_ld}~ ; then
1812
  if cmp -s $config_host_ld ${config_host_ld}~ ; then
1813
    mv ${config_host_ld}~ $config_host_ld
1814
  else
1815
    rm ${config_host_ld}~
1816
  fi
1817
fi
1818

    
1819
for target in $target_list; do
1820
target_dir="$target"
1821
config_mak=$target_dir/config.mak
1822
config_h=$target_dir/config.h
1823
target_arch2=`echo $target | cut -d '-' -f 1`
1824
target_bigendian="no"
1825
case "$target_arch2" in
1826
  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
1827
  target_bigendian=yes
1828
  ;;
1829
esac
1830
target_softmmu="no"
1831
target_user_only="no"
1832
target_linux_user="no"
1833
target_darwin_user="no"
1834
target_bsd_user="no"
1835
case "$target" in
1836
  ${target_arch2}-softmmu)
1837
    target_softmmu="yes"
1838
    ;;
1839
  ${target_arch2}-linux-user)
1840
    target_user_only="yes"
1841
    target_linux_user="yes"
1842
    ;;
1843
  ${target_arch2}-darwin-user)
1844
    target_user_only="yes"
1845
    target_darwin_user="yes"
1846
    ;;
1847
  ${target_arch2}-bsd-user)
1848
    target_user_only="yes"
1849
    target_bsd_user="yes"
1850
    ;;
1851
  *)
1852
    echo "ERROR: Target '$target' not recognised"
1853
    exit 1
1854
    ;;
1855
esac
1856

    
1857
#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
1858

    
1859
test -f $config_h && mv $config_h ${config_h}~
1860

    
1861
mkdir -p $target_dir
1862
mkdir -p $target_dir/fpu
1863
mkdir -p $target_dir/tcg
1864
if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
1865
  mkdir -p $target_dir/nwfpe
1866
fi
1867

    
1868
#
1869
# don't use ln -sf as not all "ln -sf" over write the file/link
1870
#
1871
rm -f $target_dir/Makefile
1872
ln -s $source_path/Makefile.target $target_dir/Makefile
1873

    
1874

    
1875
echo "# Automatically generated by configure - do not modify" > $config_mak
1876

    
1877
echo "include ../config-host.mak" >> $config_mak
1878

    
1879
bflt="no"
1880
elfload32="no"
1881
target_nptl="no"
1882
interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
1883
echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_mak
1884
gdb_xml_files=""
1885

    
1886
TARGET_ARCH="$target_arch2"
1887
TARGET_BASE_ARCH=""
1888
TARGET_ABI_DIR=""
1889

    
1890
case "$target_arch2" in
1891
  i386)
1892
    target_phys_bits=32
1893
  ;;
1894
  x86_64)
1895
    TARGET_BASE_ARCH=i386
1896
    target_phys_bits=64
1897
  ;;
1898
  alpha)
1899
    target_phys_bits=64
1900
  ;;
1901
  arm|armeb)
1902
    TARGET_ARCH=arm
1903
    bflt="yes"
1904
    target_nptl="yes"
1905
    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1906
    target_phys_bits=32
1907
  ;;
1908
  cris)
1909
    target_nptl="yes"
1910
    target_phys_bits=32
1911
  ;;
1912
  m68k)
1913
    bflt="yes"
1914
    gdb_xml_files="cf-core.xml cf-fp.xml"
1915
    target_phys_bits=32
1916
  ;;
1917
  microblaze)
1918
    bflt="yes"
1919
    target_nptl="yes"
1920
    target_phys_bits=32
1921
  ;;
1922
  mips|mipsel)
1923
    TARGET_ARCH=mips
1924
    echo "TARGET_ABI_MIPSO32=y" >> $config_mak
1925
    target_nptl="yes"
1926
    target_phys_bits=64
1927
  ;;
1928
  mipsn32|mipsn32el)
1929
    TARGET_ARCH=mipsn32
1930
    TARGET_BASE_ARCH=mips
1931
    echo "TARGET_ABI_MIPSN32=y" >> $config_mak
1932
    target_phys_bits=64
1933
  ;;
1934
  mips64|mips64el)
1935
    TARGET_ARCH=mips64
1936
    TARGET_BASE_ARCH=mips
1937
    echo "TARGET_ABI_MIPSN64=y" >> $config_mak
1938
    target_phys_bits=64
1939
  ;;
1940
  ppc)
1941
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1942
    target_phys_bits=32
1943
    target_nptl="yes"
1944
  ;;
1945
  ppcemb)
1946
    TARGET_BASE_ARCH=ppc
1947
    TARGET_ABI_DIR=ppc
1948
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1949
    target_phys_bits=64
1950
    target_nptl="yes"
1951
  ;;
1952
  ppc64)
1953
    TARGET_BASE_ARCH=ppc
1954
    TARGET_ABI_DIR=ppc
1955
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1956
    target_phys_bits=64
1957
  ;;
1958
  ppc64abi32)
1959
    TARGET_ARCH=ppc64
1960
    TARGET_BASE_ARCH=ppc
1961
    TARGET_ABI_DIR=ppc
1962
    echo "TARGET_ABI32=y" >> $config_mak
1963
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1964
    target_phys_bits=64
1965
  ;;
1966
  sh4|sh4eb)
1967
    TARGET_ARCH=sh4
1968
    bflt="yes"
1969
    target_nptl="yes"
1970
    target_phys_bits=32
1971
  ;;
1972
  sparc)
1973
    target_phys_bits=64
1974
  ;;
1975
  sparc64)
1976
    TARGET_BASE_ARCH=sparc
1977
    elfload32="yes"
1978
    target_phys_bits=64
1979
  ;;
1980
  sparc32plus)
1981
    TARGET_ARCH=sparc64
1982
    TARGET_BASE_ARCH=sparc
1983
    TARGET_ABI_DIR=sparc
1984
    echo "TARGET_ABI32=y" >> $config_mak
1985
    target_phys_bits=64
1986
  ;;
1987
  *)
1988
    echo "Unsupported target CPU"
1989
    exit 1
1990
  ;;
1991
esac
1992
echo "TARGET_ARCH=$TARGET_ARCH" >> $config_mak
1993
echo "TARGET_ARCH2=$target_arch2" >> $config_mak
1994
# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
1995
if [ "$TARGET_BASE_ARCH" = "" ]; then
1996
  TARGET_BASE_ARCH=$TARGET_ARCH
1997
fi
1998
echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_mak
1999
if [ "$TARGET_ABI_DIR" = "" ]; then
2000
  TARGET_ABI_DIR=$TARGET_ARCH
2001
fi
2002
echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_mak
2003
if [ $target_phys_bits -lt $hostlongbits ] ; then
2004
  target_phys_bits=$hostlongbits
2005
fi
2006
case "$target_arch2" in
2007
  i386|x86_64)
2008
    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2009
      echo "CONFIG_XEN=y" >> $config_mak
2010
    fi
2011
    if test $kqemu = "yes" -a "$target_softmmu" = "yes"
2012
    then
2013
      echo "CONFIG_KQEMU=y" >> $config_mak
2014
    fi
2015
esac
2016
case "$target_arch2" in
2017
  i386|x86_64|ppcemb|ppc|ppc64)
2018
    # Make sure the target and host cpus are compatible
2019
    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2020
      \( "$target_arch2" = "$cpu" -o \
2021
      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2022
      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2023
      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2024
      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
2025
      echo "CONFIG_KVM=y" >> $config_mak
2026
      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
2027
    fi
2028
esac
2029
echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
2030
echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_mak
2031
echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2032
if test "$target_bigendian" = "yes" ; then
2033
  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_mak
2034
fi
2035
if test "$target_softmmu" = "yes" ; then
2036
  echo "CONFIG_SOFTMMU=y" >> $config_mak
2037
fi
2038
if test "$target_user_only" = "yes" ; then
2039
  echo "CONFIG_USER_ONLY=y" >> $config_mak
2040
fi
2041
if test "$target_linux_user" = "yes" ; then
2042
  echo "CONFIG_LINUX_USER=y" >> $config_mak
2043
fi
2044
if test "$target_darwin_user" = "yes" ; then
2045
  echo "CONFIG_DARWIN_USER=y" >> $config_mak
2046
fi
2047
list=""
2048
if test ! -z "$gdb_xml_files" ; then
2049
  for x in $gdb_xml_files; do
2050
    list="$list $source_path/gdb-xml/$x"
2051
  done
2052
fi
2053
echo "TARGET_XML_FILES=$list" >> $config_mak
2054

    
2055
case "$target_arch2" in
2056
  arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
2057
    echo "CONFIG_SOFTFLOAT=y" >> $config_mak
2058
    ;;
2059
esac
2060

    
2061
if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2062
  echo "TARGET_HAS_BFLT=y" >> $config_mak
2063
fi
2064
if test "$target_user_only" = "yes" \
2065
        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2066
  echo "CONFIG_USE_NPTL=y" >> $config_mak
2067
fi
2068
# 32 bit ELF loader in addition to native 64 bit loader?
2069
if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2070
  echo "TARGET_HAS_ELFLOAD32=y" >> $config_mak
2071
fi
2072
if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2073
  echo "CONFIG_USE_GUEST_BASE=y" >> $config_mak
2074
fi
2075
if test "$target_bsd_user" = "yes" ; then
2076
  echo "CONFIG_BSD_USER=y" >> $config_mak
2077
fi
2078

    
2079
# generate LDFLAGS for targets
2080

    
2081
ldflags=""
2082
if test "$target_linux_user" = "yes" -o "$target_linux_user" = "yes" ; then
2083
  case "$ARCH" in
2084
  i386)
2085
    if test "$gprof" = "yes" -o "$static" = "yes" ; then
2086
      ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld'
2087
    else
2088
      # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
2089
      # that the kernel ELF loader considers as an executable. I think this
2090
      # is the simplest way to make it self virtualizable!
2091
      ldflags='-Wl,-shared'
2092
    fi
2093
    ;;
2094
  sparc)
2095
    # -static is used to avoid g1/g3 usage by the dynamic linker
2096
    ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
2097
    ;;
2098
  ia64)
2099
    ldflags='-Wl,-G0 -Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
2100
    ;;
2101
  x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2102
    ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld'
2103
    ;;
2104
  esac
2105
fi
2106
if test "$target_softmmu" = "yes" ; then
2107
  case "$ARCH" in
2108
  ia64)
2109
    ldflags='-Wl,-G0 -Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
2110
    ;;
2111
  esac
2112
fi
2113

    
2114
if test "$ldflags" != "" ; then
2115
  echo "LDFLAGS+=$ldflags" >> $config_mak
2116
fi
2117

    
2118
echo "/* Automatically generated by configure - do not modify */" > $config_h
2119
echo "#include \"../config-host.h\"" >> $config_h
2120

    
2121
$SHELL $source_path/create_config < $config_mak >> $config_h
2122

    
2123
if test -f ${config_h}~ ; then
2124
  if cmp -s $config_h ${config_h}~ ; then
2125
    mv ${config_h}~ $config_h
2126
  else
2127
    rm ${config_h}~
2128
  fi
2129
fi
2130

    
2131
done # for target in $targets
2132

    
2133
# build tree in object directory if source path is different from current one
2134
if test "$source_path_used" = "yes" ; then
2135
    DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
2136
    FILES="Makefile tests/Makefile"
2137
    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2138
    FILES="$FILES tests/test-mmap.c"
2139
    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2140
    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2141
        FILES="$FILES pc-bios/`basename $bios_file`"
2142
    done
2143
    for dir in $DIRS ; do
2144
            mkdir -p $dir
2145
    done
2146
    # remove the link and recreate it, as not all "ln -sf" overwrite the link
2147
    for f in $FILES ; do
2148
        rm -f $f
2149
        ln -s $source_path/$f $f
2150
    done
2151
fi
2152

    
2153
for hwlib in 32 64; do
2154
  d=libhw$hwlib
2155
  mkdir -p $d
2156
  rm -f $d/Makefile
2157
  ln -s $source_path/Makefile.hw $d/Makefile
2158
  echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2159
  echo "CPPFLAGS=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
2160
done