Statistics
| Branch: | Revision:

root / configure @ e37630ca

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
prefix=""
25
interp_prefix="/usr/gnemul/qemu-%M"
26
static="no"
27
cross_prefix=""
28
cc="gcc"
29
audio_drv_list=""
30
audio_card_list="ac97 es1370 sb16"
31
audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
32
host_cc="gcc"
33
ar="ar"
34
make="make"
35
install="install"
36
strip="strip"
37

    
38
# parse CC options first
39
for opt do
40
  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
41
  case "$opt" in
42
  --cross-prefix=*) cross_prefix="$optarg"
43
  ;;
44
  --cc=*) cc="$optarg"
45
  ;;
46
  esac
47
done
48

    
49
# OS specific
50
# Using uname is really, really broken.  Once we have the right set of checks
51
# we can eliminate it's usage altogether
52

    
53
cc="${cross_prefix}${cc}"
54
ar="${cross_prefix}${ar}"
55
strip="${cross_prefix}${strip}"
56

    
57
# check that the C compiler works.
58
cat > $TMPC <<EOF
59
int main(void) {}
60
EOF
61

    
62
if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
63
  : C compiler works ok
64
else
65
    echo "ERROR: \"$cc\" either does not exist or does not work"
66
    exit 1
67
fi
68

    
69
check_define() {
70
cat > $TMPC <<EOF
71
#if !defined($1)
72
#error Not defined
73
#endif
74
int main(void) { return 0; }
75
EOF
76
  $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
77
}
78

    
79
if check_define __i386__ ; then
80
  cpu="i386"
81
elif check_define __x86_64__ ; then
82
  cpu="x86_64"
83
elif check_define __sparc__ ; then
84
  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
85
  # They must be specified using --sparc_cpu
86
  if check_define __arch64__ ; then
87
    cpu="sparc64"
88
  else
89
    cpu="sparc"
90
  fi
91
elif check_define _ARCH_PPC ; then
92
  if check_define _ARCH_PPC64 ; then
93
    cpu="ppc64"
94
  else
95
    cpu="ppc"
96
  fi
97
else
98
  cpu=`uname -m`
99
fi
100

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

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

    
334
if [ "$bsd" = "yes" ] ; then
335
  if [ "$darwin" != "yes" ] ; then
336
    make="gmake"
337
    usb="bsd"
338
  fi
339
  bsd_user="yes"
340
fi
341

    
342
# find source path
343
source_path=`dirname "$0"`
344
source_path_used="no"
345
workdir=`pwd`
346
if [ -z "$source_path" ]; then
347
    source_path=$workdir
348
else
349
    source_path=`cd "$source_path"; pwd`
350
fi
351
[ -f "$workdir/vl.c" ] || source_path_used="yes"
352

    
353
werror="no"
354
# generate compile errors on warnings for development builds
355
#if grep cvs $source_path/VERSION > /dev/null 2>&1 ; then
356
#werror="yes";
357
#fi
358

    
359
for opt do
360
  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
361
  case "$opt" in
362
  --help|-h) show_help=yes
363
  ;;
364
  --prefix=*) prefix="$optarg"
365
  ;;
366
  --interp-prefix=*) interp_prefix="$optarg"
367
  ;;
368
  --source-path=*) source_path="$optarg"
369
  source_path_used="yes"
370
  ;;
371
  --cross-prefix=*)
372
  ;;
373
  --cc=*)
374
  ;;
375
  --host-cc=*) host_cc="$optarg"
376
  ;;
377
  --make=*) make="$optarg"
378
  ;;
379
  --install=*) install="$optarg"
380
  ;;
381
  --extra-cflags=*) CFLAGS="$optarg"
382
  ;;
383
  --extra-ldflags=*) LDFLAGS="$optarg"
384
  ;;
385
  --cpu=*) cpu="$optarg"
386
  ;;
387
  --target-list=*) target_list="$optarg"
388
  ;;
389
  --enable-gprof) gprof="yes"
390
  ;;
391
  --static) static="yes"
392
  ;;
393
  --disable-sdl) sdl="no"
394
  ;;
395
  --fmod-lib=*) fmod_lib="$optarg"
396
  ;;
397
  --fmod-inc=*) fmod_inc="$optarg"
398
  ;;
399
  --oss-lib=*) oss_lib="$optarg"
400
  ;;
401
  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
402
  ;;
403
  --audio-drv-list=*) audio_drv_list="$optarg"
404
  ;;
405
  --enable-debug-tcg) debug_tcg="yes"
406
  ;;
407
  --disable-debug-tcg) debug_tcg="no"
408
  ;;
409
  --enable-sparse) sparse="yes"
410
  ;;
411
  --disable-sparse) sparse="no"
412
  ;;
413
  --disable-strip) strip_opt="no"
414
  ;;
415
  --disable-vnc-tls) vnc_tls="no"
416
  ;;
417
  --disable-vnc-sasl) vnc_sasl="no"
418
  ;;
419
  --disable-slirp) slirp="no"
420
  ;;
421
  --disable-vde) vde="no"
422
  ;;
423
  --disable-kqemu) kqemu="no"
424
  ;;
425
  --disable-xen) xen="no"
426
  ;;
427
  --disable-brlapi) brlapi="no"
428
  ;;
429
  --disable-bluez) bluez="no"
430
  ;;
431
  --disable-kvm) kvm="no"
432
  ;;
433
  --enable-profiler) profiler="yes"
434
  ;;
435
  --enable-cocoa)
436
      cocoa="yes" ;
437
      sdl="no" ;
438
      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
439
  ;;
440
  --disable-gfx-check) check_gfx="no"
441
  ;;
442
  --disable-system) softmmu="no"
443
  ;;
444
  --enable-system) softmmu="yes"
445
  ;;
446
  --disable-linux-user) linux_user="no"
447
  ;;
448
  --enable-linux-user) linux_user="yes"
449
  ;;
450
  --disable-darwin-user) darwin_user="no"
451
  ;;
452
  --enable-darwin-user) darwin_user="yes"
453
  ;;
454
  --disable-bsd-user) bsd_user="no"
455
  ;;
456
  --enable-bsd-user) bsd_user="yes"
457
  ;;
458
  --enable-uname-release=*) uname_release="$optarg"
459
  ;;
460
  --sparc_cpu=*)
461
      sparc_cpu="$optarg"
462
      case $sparc_cpu in
463
        v7|v8) SP_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
464
                 target_cpu="sparc"; cpu="sparc" ;;
465
        v8plus|v8plusa) SP_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
466
                 target_cpu="sparc"; cpu="sparc" ;;
467
        v9)    SP_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m64"
468
                 target_cpu="sparc64"; cpu="sparc64" ;;
469
        *)     echo "undefined SPARC architecture. Exiting";exit 1;;
470
      esac
471
  ;;
472
  --enable-werror) werror="yes"
473
  ;;
474
  --disable-werror) werror="no"
475
  ;;
476
  --disable-curses) curses="no"
477
  ;;
478
  --disable-nptl) nptl="no"
479
  ;;
480
  --enable-mixemu) mixemu="yes"
481
  ;;
482
  --disable-aio) aio="no"
483
  ;;
484
  --disable-blobs) blobs="no"
485
  ;;
486
  --kerneldir=*) kerneldir="$optarg"
487
  ;;
488
  --with-pkgversion=*) pkgversion=" ($optarg)"
489
  ;;
490
  *) echo "ERROR: unknown option $opt"; show_help="yes"
491
  ;;
492
  esac
493
done
494

    
495
# default flags for all hosts
496
CFLAGS="$CFLAGS -O2 -g -fno-strict-aliasing"
497
CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
498
LDFLAGS="$LDFLAGS -g"
499
if test "$werror" = "yes" ; then
500
CFLAGS="$CFLAGS -Werror"
501
fi
502

    
503
if test "$solaris" = "no" ; then
504
    if ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
505
        LDFLAGS="$LDFLAGS -Wl,--warn-common"
506
    fi
507
fi
508

    
509
#
510
# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
511
# ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
512
#
513
case "$cpu" in
514
    sparc) if test -z "$sparc_cpu" ; then
515
               ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
516
               ARCH_LDFLAGS="-m32"
517
           else
518
               ARCH_CFLAGS="${SP_CFLAGS}"
519
               ARCH_LDFLAGS="${SP_LDFLAGS}"
520
           fi
521
           ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g2 -ffixed-g3"
522
           if test "$solaris" = "no" ; then
523
               ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g1 -ffixed-g6"
524
           fi
525
           ;;
526
    sparc64) if test -z "$sparc_cpu" ; then
527
               ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
528
               ARCH_LDFLAGS="-m64"
529
           else
530
               ARCH_CFLAGS="${SP_CFLAGS}"
531
               ARCH_LDFLAGS="${SP_LDFLAGS}"
532
           fi
533
           if test "$solaris" = "no" ; then
534
               ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g5 -ffixed-g6 -ffixed-g7"
535
           else
536
               ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g1 -ffixed-g5 -ffixed-g6 -ffixed-g7"
537
           fi
538
           ;;
539
    s390)
540
           ARCH_CFLAGS="-march=z900"
541
           ;;
542
    i386)
543
           ARCH_CFLAGS="-m32"
544
           ARCH_LDFLAGS="-m32"
545
           ;;
546
    x86_64)
547
           ARCH_CFLAGS="-m64"
548
           ARCH_LDFLAGS="-m64"
549
           ;;
550
esac
551

    
552
if test x"$show_help" = x"yes" ; then
553
cat << EOF
554

    
555
Usage: configure [options]
556
Options: [defaults in brackets after descriptions]
557

    
558
EOF
559
echo "Standard options:"
560
echo "  --help                   print this message"
561
echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
562
echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
563
echo "                           use %M for cpu name [$interp_prefix]"
564
echo "  --target-list=LIST       set target list [$target_list]"
565
echo ""
566
echo "kqemu kernel acceleration support:"
567
echo "  --disable-kqemu          disable kqemu support"
568
echo ""
569
echo "Advanced options (experts only):"
570
echo "  --source-path=PATH       path of source code [$source_path]"
571
echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
572
echo "  --cc=CC                  use C compiler CC [$cc]"
573
echo "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
574
echo "  --extra-cflags=CFLAGS    add C compiler flags CFLAGS"
575
echo "  --extra-ldflags=LDFLAGS  add linker flags LDFLAGS"
576
echo "  --make=MAKE              use specified make [$make]"
577
echo "  --install=INSTALL        use specified install [$install]"
578
echo "  --static                 enable static build [$static]"
579
echo "  --enable-debug-tcg       enable TCG debugging"
580
echo "  --disable-debug-tcg      disable TCG debugging (default)"
581
echo "  --enable-sparse          enable sparse checker"
582
echo "  --disable-sparse         disable sparse checker (default)"
583
echo "  --disable-strip          disable stripping binaries"
584
echo "  --disable-werror         disable compilation abort on warning"
585
echo "  --disable-sdl            disable SDL"
586
echo "  --enable-cocoa           enable COCOA (Mac OS X only)"
587
echo "  --audio-drv-list=LIST    set audio drivers list:"
588
echo "                           Available drivers: $audio_possible_drivers"
589
echo "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
590
echo "                           Available cards: $audio_possible_cards"
591
echo "  --enable-mixemu          enable mixer emulation"
592
echo "  --disable-xen            disable xen backend driver support"
593
echo "  --disable-brlapi         disable BrlAPI"
594
echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
595
echo "  --disable-vnc-sasl       disable SASL encryption for VNC server"
596
echo "  --disable-curses         disable curses output"
597
echo "  --disable-bluez          disable bluez stack connectivity"
598
echo "  --disable-kvm            disable KVM acceleration support"
599
echo "  --disable-nptl           disable usermode NPTL support"
600
echo "  --enable-system          enable all system emulation targets"
601
echo "  --disable-system         disable all system emulation targets"
602
echo "  --enable-linux-user      enable all linux usermode emulation targets"
603
echo "  --disable-linux-user     disable all linux usermode emulation targets"
604
echo "  --enable-darwin-user     enable all darwin usermode emulation targets"
605
echo "  --disable-darwin-user    disable all darwin usermode emulation targets"
606
echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
607
echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
608
echo "  --fmod-lib               path to FMOD library"
609
echo "  --fmod-inc               path to FMOD includes"
610
echo "  --oss-lib                path to OSS library"
611
echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
612
echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
613
echo "  --disable-vde            disable support for vde network"
614
echo "  --disable-aio            disable AIO support"
615
echo "  --disable-blobs          disable installing provided firmware blobs"
616
echo "  --kerneldir=PATH         look for kernel includes in PATH"
617
echo ""
618
echo "NOTE: The object files are built at the place where configure is launched"
619
exit 1
620
fi
621

    
622
if test "$mingw32" = "yes" ; then
623
    linux="no"
624
    EXESUF=".exe"
625
    oss="no"
626
    linux_user="no"
627
    bsd_user="no"
628
    OS_CFLAGS="$OS_CFLAGS -DWIN32_LEAN_AND_MEAN -DWINVER=0x501"
629
fi
630

    
631
if test ! -x "$(which cgcc 2>/dev/null)"; then
632
    sparse="no"
633
fi
634

    
635
#
636
# Solaris specific configure tool chain decisions
637
#
638
if test "$solaris" = "yes" ; then
639
  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
640
  if test -z "$solinst" ; then
641
    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
642
    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
643
    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
644
    exit 1
645
  fi
646
  if test "$solinst" = "/usr/sbin/install" ; then
647
    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
648
    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
649
    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
650
    exit 1
651
  fi
652
  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
653
  if test -z "$sol_ar" ; then
654
    echo "Error: No path includes ar"
655
    if test -f /usr/ccs/bin/ar ; then
656
      echo "Add /usr/ccs/bin to your path and rerun configure"
657
    fi
658
    exit 1
659
  fi
660
fi
661

    
662

    
663
if test -z "$target_list" ; then
664
# these targets are portable
665
    if [ "$softmmu" = "yes" ] ; then
666
        target_list="\
667
i386-softmmu \
668
x86_64-softmmu \
669
arm-softmmu \
670
cris-softmmu \
671
m68k-softmmu \
672
mips-softmmu \
673
mipsel-softmmu \
674
mips64-softmmu \
675
mips64el-softmmu \
676
ppc-softmmu \
677
ppcemb-softmmu \
678
ppc64-softmmu \
679
sh4-softmmu \
680
sh4eb-softmmu \
681
sparc-softmmu \
682
"
683
    fi
684
# the following are Linux specific
685
    if [ "$linux_user" = "yes" ] ; then
686
        target_list="${target_list}\
687
i386-linux-user \
688
x86_64-linux-user \
689
alpha-linux-user \
690
arm-linux-user \
691
armeb-linux-user \
692
cris-linux-user \
693
m68k-linux-user \
694
mips-linux-user \
695
mipsel-linux-user \
696
ppc-linux-user \
697
ppc64-linux-user \
698
ppc64abi32-linux-user \
699
sh4-linux-user \
700
sh4eb-linux-user \
701
sparc-linux-user \
702
sparc64-linux-user \
703
sparc32plus-linux-user \
704
"
705
    fi
706
# the following are Darwin specific
707
    if [ "$darwin_user" = "yes" ] ; then
708
        target_list="$target_list i386-darwin-user ppc-darwin-user "
709
    fi
710
# the following are BSD specific
711
    if [ "$bsd_user" = "yes" ] ; then
712
        target_list="${target_list}\
713
i386-bsd-user \
714
x86_64-bsd-user \
715
sparc-bsd-user \
716
sparc64-bsd-user \
717
"
718
    fi
719
else
720
    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
721
fi
722
if test -z "$target_list" ; then
723
    echo "No targets enabled"
724
    exit 1
725
fi
726

    
727
if test -z "$cross_prefix" ; then
728

    
729
# ---
730
# big/little endian test
731
cat > $TMPC << EOF
732
#include <inttypes.h>
733
int main(int argc, char ** argv){
734
        volatile uint32_t i=0x01234567;
735
        return (*((uint8_t*)(&i))) == 0x67;
736
}
737
EOF
738

    
739
if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
740
$TMPE && bigendian="yes"
741
else
742
echo big/little test failed
743
fi
744

    
745
else
746

    
747
# if cross compiling, cannot launch a program, so make a static guess
748
if test "$cpu" = "armv4b" \
749
     -o "$cpu" = "hppa" \
750
     -o "$cpu" = "m68k" \
751
     -o "$cpu" = "mips" \
752
     -o "$cpu" = "mips64" \
753
     -o "$cpu" = "ppc" \
754
     -o "$cpu" = "ppc64" \
755
     -o "$cpu" = "s390" \
756
     -o "$cpu" = "sparc" \
757
     -o "$cpu" = "sparc64"; then
758
    bigendian="yes"
759
fi
760

    
761
fi
762

    
763
# host long bits test
764
hostlongbits="32"
765
if test "$cpu" = "x86_64" \
766
     -o "$cpu" = "alpha" \
767
     -o "$cpu" = "ia64" \
768
     -o "$cpu" = "sparc64" \
769
     -o "$cpu" = "ppc64"; then
770
    hostlongbits="64"
771
fi
772

    
773
# Check host NPTL support
774
cat > $TMPC <<EOF
775
#include <sched.h>
776
#include <linux/futex.h>
777
void foo()
778
{
779
#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
780
#error bork
781
#endif
782
}
783
EOF
784

    
785
if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
786
  :
787
else
788
   nptl="no"
789
fi
790

    
791
##########################################
792
# zlib check
793

    
794
cat > $TMPC << EOF
795
#include <zlib.h>
796
int main(void) { zlibVersion(); return 0; }
797
EOF
798
if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lz > /dev/null 2> /dev/null ; then
799
    :
800
else
801
    echo
802
    echo "Error: zlib check failed"
803
    echo "Make sure to have the zlib libs and headers installed."
804
    echo
805
    exit 1
806
fi
807

    
808
##########################################
809
# xen probe
810

    
811
if test "$xen" = "yes" ; then
812
cat > $TMPC <<EOF
813
#include <xenctrl.h>
814
#include <xs.h>
815
int main(void) { xs_daemon_open; xc_interface_open; }
816
EOF
817
   if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC -lxenstore -lxenctrl 2> /dev/null ; then
818
      :
819
   else
820
      xen="no"
821
   fi
822
fi
823

    
824
##########################################
825
# SDL probe
826

    
827
sdl_too_old=no
828

    
829
if test -z "$sdl" ; then
830
    sdl_config="sdl-config"
831
    sdl=no
832
    sdl_static=no
833

    
834
cat > $TMPC << EOF
835
#include <SDL.h>
836
#undef main /* We don't want SDL to override our main() */
837
int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
838
EOF
839
    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > $TMPSDLLOG 2>&1 ; then
840
        _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
841
        if test "$_sdlversion" -lt 121 ; then
842
            sdl_too_old=yes
843
        else
844
            if test "$cocoa" = "no" ; then
845
                sdl=yes
846
            fi
847
        fi
848

    
849
        # static link with sdl ?
850
        if test "$sdl" = "yes" ; then
851
            aa="no"
852
            `$sdl_config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` && aa="yes"
853
            sdl_static_libs=`$sdl_config --static-libs 2>/dev/null`
854
            if [ "$aa" = "yes" ] ; then
855
                sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
856
            fi
857

    
858
            if $cc -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs > /dev/null 2> /dev/null; then
859
                sdl_static=yes
860
            fi
861
        fi # static link
862
    fi # sdl compile test
863
else
864
    # Make sure to disable cocoa if sdl was set
865
    if test "$sdl" = "yes" ; then
866
       cocoa="no"
867
       audio_drv_list="`echo $audio_drv_list | sed s,coreaudio,,g`"
868
    fi
869
fi # -z $sdl
870

    
871
if test "$sdl" = "yes" ; then
872
cat > $TMPC <<EOF
873
#include <SDL.h>
874
#if defined(SDL_VIDEO_DRIVER_X11)
875
#include <X11/XKBlib.h>
876
#else
877
#error No x11 support
878
#endif
879
int main(void) { return 0; }
880
EOF
881
    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > /dev/null 2>&1 ; then
882
	sdl_x11="yes"
883
    fi
884
fi
885

    
886
##########################################
887
# VNC TLS detection
888
if test "$vnc_tls" = "yes" ; then
889
cat > $TMPC <<EOF
890
#include <gnutls/gnutls.h>
891
int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
892
EOF
893
    vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
894
    vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
895
    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_tls_cflags $TMPC \
896
           $vnc_tls_libs > /dev/null 2> /dev/null ; then
897
	:
898
    else
899
	vnc_tls="no"
900
    fi
901
fi
902

    
903
##########################################
904
# VNC SASL detection
905
if test "$vnc_sasl" = "yes" ; then
906
cat > $TMPC <<EOF
907
#include <sasl/sasl.h>
908
#include <stdio.h>
909
int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
910
EOF
911
    # Assuming Cyrus-SASL installed in /usr prefix
912
    vnc_sasl_cflags=""
913
    vnc_sasl_libs="-lsasl2"
914
    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_sasl_cflags $TMPC \
915
           $vnc_sasl_libs 2> /dev/null ; then
916
	:
917
    else
918
	vnc_sasl="no"
919
    fi
920
fi
921

    
922
##########################################
923
# fnmatch() probe, used for ACL routines
924
fnmatch="no"
925
cat > $TMPC << EOF
926
#include <fnmatch.h>
927
int main(void)
928
{
929
    fnmatch("foo", "foo", 0);
930
    return 0;
931
}
932
EOF
933
if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
934
   fnmatch="yes"
935
fi
936

    
937
##########################################
938
# vde libraries probe
939
if test "$vde" = "yes" ; then
940
  cat > $TMPC << EOF
941
#include <libvdeplug.h>
942
int main(void)
943
{
944
    struct vde_open_args a = {0, 0, 0};
945
    vde_open("", "", &a);
946
    return 0;
947
}
948
EOF
949
    if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lvdeplug > /dev/null 2> /dev/null ; then
950
        :
951
    else
952
        vde="no"
953
    fi
954
fi
955

    
956
##########################################
957
# Sound support libraries probe
958

    
959
audio_drv_probe()
960
{
961
    drv=$1
962
    hdr=$2
963
    lib=$3
964
    exp=$4
965
    cfl=$5
966
        cat > $TMPC << EOF
967
#include <$hdr>
968
int main(void) { $exp }
969
EOF
970
    if $cc $ARCH_CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
971
        :
972
    else
973
        echo
974
        echo "Error: $drv check failed"
975
        echo "Make sure to have the $drv libs and headers installed."
976
        echo
977
        exit 1
978
    fi
979
}
980

    
981
audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
982
for drv in $audio_drv_list; do
983
    case $drv in
984
    alsa)
985
    audio_drv_probe $drv alsa/asoundlib.h -lasound \
986
        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
987
    ;;
988

    
989
    fmod)
990
    if test -z $fmod_lib || test -z $fmod_inc; then
991
        echo
992
        echo "Error: You must specify path to FMOD library and headers"
993
        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
994
        echo
995
        exit 1
996
    fi
997
    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
998
    ;;
999

    
1000
    esd)
1001
    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1002
    ;;
1003

    
1004
    pa)
1005
    audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1006
        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1007
    ;;
1008

    
1009
    oss|sdl|core|wav|dsound)
1010
    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1011
    ;;
1012

    
1013
    *)
1014
    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1015
        echo
1016
        echo "Error: Unknown driver '$drv' selected"
1017
        echo "Possible drivers are: $audio_possible_drivers"
1018
        echo
1019
        exit 1
1020
    }
1021
    ;;
1022
    esac
1023
done
1024

    
1025
##########################################
1026
# BrlAPI probe
1027

    
1028
if test -z "$brlapi" ; then
1029
    brlapi=no
1030
cat > $TMPC << EOF
1031
#include <brlapi.h>
1032
int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1033
EOF
1034
    if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi > /dev/null 2> /dev/null ; then
1035
	    brlapi=yes
1036
    fi # brlapi compile test
1037
fi # -z $brlapi
1038

    
1039
##########################################
1040
# curses probe
1041

    
1042
if test "$curses" = "yes" ; then
1043
  curses=no
1044
  cat > $TMPC << EOF
1045
#include <curses.h>
1046
#ifdef __OpenBSD__
1047
#define resize_term resizeterm
1048
#endif
1049
int main(void) { resize_term(0, 0); return curses_version(); }
1050
EOF
1051
  if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
1052
    curses=yes
1053
  fi
1054
fi # test "$curses"
1055

    
1056
##########################################
1057
# bluez support probe
1058
if test "$bluez" = "yes" ; then
1059
  `pkg-config bluez` || bluez="no"
1060
fi
1061
if test "$bluez" = "yes" ; then
1062
  cat > $TMPC << EOF
1063
#include <bluetooth/bluetooth.h>
1064
int main(void) { return bt_error(0); }
1065
EOF
1066
  bluez_cflags=`pkg-config --cflags bluez`
1067
  bluez_libs=`pkg-config --libs bluez`
1068
  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $bluez_cflags $TMPC \
1069
      $bluez_libs > /dev/null 2> /dev/null ; then
1070
    :
1071
  else
1072
    bluez="no"
1073
  fi
1074
fi
1075

    
1076
##########################################
1077
# kvm probe
1078
if test "$kvm" = "yes" ; then
1079
    cat > $TMPC <<EOF
1080
#include <linux/kvm.h>
1081
#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1082
#error Invalid KVM version
1083
#endif
1084
#if !defined(KVM_CAP_USER_MEMORY)
1085
#error Missing KVM capability KVM_CAP_USER_MEMORY
1086
#endif
1087
#if !defined(KVM_CAP_SET_TSS_ADDR)
1088
#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1089
#endif
1090
#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1091
#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1092
#endif
1093
int main(void) { return 0; }
1094
EOF
1095
  if test "$kerneldir" != "" ; then
1096
      kvm_cflags=-I"$kerneldir"/include
1097
      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1098
         -a -d "$kerneldir/arch/x86/include" ; then
1099
            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1100
	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1101
	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1102
        elif test -d "$kerneldir/arch/$cpu/include" ; then
1103
            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1104
      fi
1105
  else
1106
      kvm_cflags=""
1107
  fi
1108
  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC \
1109
      > /dev/null 2>/dev/null ; then
1110
    :
1111
  else
1112
    kvm="no";
1113
    if [ -x "`which awk 2>/dev/null`" ] && \
1114
       [ -x "`which grep 2>/dev/null`" ]; then
1115
      kvmerr=`LANG=C $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC 2>&1 \
1116
	| grep "error: " \
1117
	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1118
      if test "$kvmerr" != "" ; then
1119
        kvm="no - (${kvmerr})"
1120
      fi
1121
    fi
1122
  fi
1123
fi
1124

    
1125
##########################################
1126
# AIO probe
1127
AIOLIBS=""
1128

    
1129
if test "$aio" = "yes" ; then
1130
  aio=no
1131
  cat > $TMPC << EOF
1132
#include <pthread.h>
1133
int main(void) { pthread_mutex_t lock;  return 0; }
1134
EOF
1135
  if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
1136
    aio=yes
1137
    AIOLIBS="-lpthread"
1138
  fi
1139
fi
1140

    
1141
##########################################
1142
# iovec probe
1143
cat > $TMPC <<EOF
1144
#include <sys/types.h>
1145
#include <sys/uio.h>
1146
#include <unistd.h>
1147
int main(void) { struct iovec iov; return 0; }
1148
EOF
1149
iovec=no
1150
if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1151
  iovec=yes
1152
fi
1153

    
1154
##########################################
1155
# preadv probe
1156
cat > $TMPC <<EOF
1157
#include <sys/types.h>
1158
#include <sys/uio.h>
1159
#include <unistd.h>
1160
int main(void) { preadv; }
1161
EOF
1162
preadv=no
1163
if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1164
  preadv=yes
1165
fi
1166

    
1167
##########################################
1168
# fdt probe
1169
if test "$fdt" = "yes" ; then
1170
    fdt=no
1171
    cat > $TMPC << EOF
1172
int main(void) { return 0; }
1173
EOF
1174
  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lfdt 2> /dev/null ; then
1175
    fdt=yes
1176
  fi
1177
fi
1178

    
1179
#
1180
# Check for xxxat() functions when we are building linux-user
1181
# emulator.  This is done because older glibc versions don't
1182
# have syscall stubs for these implemented.
1183
#
1184
atfile=no
1185
if [ "$linux_user" = "yes" ] ; then
1186
  cat > $TMPC << EOF
1187
#define _ATFILE_SOURCE
1188
#include <sys/types.h>
1189
#include <fcntl.h>
1190
#include <unistd.h>
1191

    
1192
int
1193
main(void)
1194
{
1195
	/* try to unlink nonexisting file */
1196
	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1197
}
1198
EOF
1199
  if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1200
    atfile=yes
1201
  fi
1202
fi
1203

    
1204
# Check for inotify functions when we are building linux-user
1205
# emulator.  This is done because older glibc versions don't
1206
# have syscall stubs for these implemented.  In that case we
1207
# don't provide them even if kernel supports them.
1208
#
1209
inotify=no
1210
if [ "$linux_user" = "yes" ] ; then
1211
  cat > $TMPC << EOF
1212
#include <sys/inotify.h>
1213

    
1214
int
1215
main(void)
1216
{
1217
	/* try to start inotify */
1218
	return inotify_init();
1219
}
1220
EOF
1221
  if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1222
    inotify=yes
1223
  fi
1224
fi
1225

    
1226
# Check if tools are available to build documentation.
1227
if [ -x "`which texi2html 2>/dev/null`" ] && \
1228
   [ -x "`which pod2man 2>/dev/null`" ]; then
1229
  build_docs="yes"
1230
fi
1231

    
1232
##########################################
1233
# Do we need librt
1234
cat > $TMPC <<EOF
1235
#include <signal.h>
1236
#include <time.h>
1237
int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1238
EOF
1239

    
1240
rt=no
1241
if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1242
  :
1243
elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
1244
  rt=yes
1245
fi
1246

    
1247
if test "$rt" = "yes" ; then
1248
  # Hack, we should have a general purpose LIBS for this sort of thing
1249
  AIOLIBS="$AIOLIBS -lrt"
1250
fi
1251

    
1252
if test "$mingw32" = "yes" ; then
1253
  if test -z "$prefix" ; then
1254
      prefix="c:\\\\Program Files\\\\Qemu"
1255
  fi
1256
  mansuffix=""
1257
  datasuffix=""
1258
  docsuffix=""
1259
  binsuffix=""
1260
else
1261
  if test -z "$prefix" ; then
1262
      prefix="/usr/local"
1263
  fi
1264
  mansuffix="/share/man"
1265
  datasuffix="/share/qemu"
1266
  docsuffix="/share/doc/qemu"
1267
  binsuffix="/bin"
1268
fi
1269

    
1270
echo "Install prefix    $prefix"
1271
echo "BIOS directory    $prefix$datasuffix"
1272
echo "binary directory  $prefix$binsuffix"
1273
if test "$mingw32" = "no" ; then
1274
echo "Manual directory  $prefix$mansuffix"
1275
echo "ELF interp prefix $interp_prefix"
1276
fi
1277
echo "Source path       $source_path"
1278
echo "C compiler        $cc"
1279
echo "Host C compiler   $host_cc"
1280
echo "ARCH_CFLAGS       $ARCH_CFLAGS"
1281
echo "make              $make"
1282
echo "install           $install"
1283
echo "host CPU          $cpu"
1284
echo "host big endian   $bigendian"
1285
echo "target list       $target_list"
1286
echo "tcg debug enabled $debug_tcg"
1287
echo "gprof enabled     $gprof"
1288
echo "sparse enabled    $sparse"
1289
echo "strip binaries    $strip_opt"
1290
echo "profiler          $profiler"
1291
echo "static build      $static"
1292
echo "-Werror enabled   $werror"
1293
if test "$darwin" = "yes" ; then
1294
    echo "Cocoa support     $cocoa"
1295
fi
1296
echo "SDL support       $sdl"
1297
if test "$sdl" != "no" ; then
1298
    echo "SDL static link   $sdl_static"
1299
fi
1300
echo "curses support    $curses"
1301
echo "mingw32 support   $mingw32"
1302
echo "Audio drivers     $audio_drv_list"
1303
echo "Extra audio cards $audio_card_list"
1304
echo "Mixer emulation   $mixemu"
1305
echo "VNC TLS support   $vnc_tls"
1306
if test "$vnc_tls" = "yes" ; then
1307
    echo "    TLS CFLAGS    $vnc_tls_cflags"
1308
    echo "    TLS LIBS      $vnc_tls_libs"
1309
fi
1310
echo "VNC SASL support  $vnc_sasl"
1311
if test "$vnc_sasl" = "yes" ; then
1312
    echo "    SASL CFLAGS    $vnc_sasl_cflags"
1313
    echo "    SASL LIBS      $vnc_sasl_libs"
1314
fi
1315
if test -n "$sparc_cpu"; then
1316
    echo "Target Sparc Arch $sparc_cpu"
1317
fi
1318
echo "kqemu support     $kqemu"
1319
echo "xen support       $xen"
1320
echo "brlapi support    $brlapi"
1321
echo "Documentation     $build_docs"
1322
[ ! -z "$uname_release" ] && \
1323
echo "uname -r          $uname_release"
1324
echo "NPTL support      $nptl"
1325
echo "vde support       $vde"
1326
echo "AIO support       $aio"
1327
echo "Install blobs     $blobs"
1328
echo "KVM support       $kvm"
1329
echo "fdt support       $fdt"
1330
echo "preadv support    $preadv"
1331

    
1332
if test $sdl_too_old = "yes"; then
1333
echo "-> Your SDL version is too old - please upgrade to have SDL support"
1334
fi
1335
if [ -s $TMPSDLLOG ]; then
1336
  echo "The error log from compiling the libSDL test is: "
1337
  cat $TMPSDLLOG
1338
fi
1339
#if test "$sdl_static" = "no"; then
1340
#  echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
1341
#fi
1342
config_mak="config-host.mak"
1343
config_h="config-host.h"
1344

    
1345
#echo "Creating $config_mak and $config_h"
1346

    
1347
test -f $config_h && mv $config_h ${config_h}~
1348

    
1349
echo "# Automatically generated by configure - do not modify" > $config_mak
1350
printf "# Configured with:" >> $config_mak
1351
printf " '%s'" "$0" "$@" >> $config_mak
1352
echo >> $config_mak
1353
echo "/* Automatically generated by configure - do not modify */" > $config_h
1354

    
1355
echo "prefix=$prefix" >> $config_mak
1356
echo "bindir=\${prefix}$binsuffix" >> $config_mak
1357
echo "mandir=\${prefix}$mansuffix" >> $config_mak
1358
echo "datadir=\${prefix}$datasuffix" >> $config_mak
1359
echo "docdir=\${prefix}$docsuffix" >> $config_mak
1360
echo "#define CONFIG_QEMU_SHAREDIR \"$prefix$datasuffix\"" >> $config_h
1361
echo "MAKE=$make" >> $config_mak
1362
echo "INSTALL=$install" >> $config_mak
1363
echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_mak
1364
echo "INSTALL_DATA=$install -m0644 -p" >> $config_mak
1365
echo "INSTALL_PROG=$install -m0755 -p" >> $config_mak
1366
echo "CC=$cc" >> $config_mak
1367
echo "HOST_CC=$host_cc" >> $config_mak
1368
echo "AR=$ar" >> $config_mak
1369
# XXX: only use CFLAGS and LDFLAGS ?  
1370
# XXX: should export HOST_CFLAGS and HOST_LDFLAGS for cross
1371
# compilation of dyngen tool (useful for win32 build on Linux host)
1372
echo "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
1373
echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
1374
echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
1375
echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
1376
echo "CFLAGS=$CFLAGS" >> $config_mak
1377
echo "LDFLAGS=$LDFLAGS" >> $config_mak
1378
echo "EXESUF=$EXESUF" >> $config_mak
1379
echo "AIOLIBS=$AIOLIBS" >> $config_mak
1380
case "$cpu" in
1381
  i386)
1382
    echo "ARCH=i386" >> $config_mak
1383
    echo "#define HOST_I386 1" >> $config_h
1384
  ;;
1385
  x86_64)
1386
    echo "ARCH=x86_64" >> $config_mak
1387
    echo "#define HOST_X86_64 1" >> $config_h
1388
  ;;
1389
  alpha)
1390
    echo "ARCH=alpha" >> $config_mak
1391
    echo "#define HOST_ALPHA 1" >> $config_h
1392
  ;;
1393
  armv4b)
1394
    echo "ARCH=arm" >> $config_mak
1395
    echo "#define HOST_ARM 1" >> $config_h
1396
  ;;
1397
  armv4l)
1398
    echo "ARCH=arm" >> $config_mak
1399
    echo "#define HOST_ARM 1" >> $config_h
1400
  ;;
1401
  cris)
1402
    echo "ARCH=cris" >> $config_mak
1403
    echo "#define HOST_CRIS 1" >> $config_h
1404
  ;;
1405
  hppa)
1406
    echo "ARCH=hppa" >> $config_mak
1407
    echo "#define HOST_HPPA 1" >> $config_h
1408
  ;;
1409
  ia64)
1410
    echo "ARCH=ia64" >> $config_mak
1411
    echo "#define HOST_IA64 1" >> $config_h
1412
  ;;
1413
  m68k)
1414
    echo "ARCH=m68k" >> $config_mak
1415
    echo "#define HOST_M68K 1" >> $config_h
1416
  ;;
1417
  mips)
1418
    echo "ARCH=mips" >> $config_mak
1419
    echo "#define HOST_MIPS 1" >> $config_h
1420
  ;;
1421
  mips64)
1422
    echo "ARCH=mips64" >> $config_mak
1423
    echo "#define HOST_MIPS64 1" >> $config_h
1424
  ;;
1425
  ppc)
1426
    echo "ARCH=ppc" >> $config_mak
1427
    echo "#define HOST_PPC 1" >> $config_h
1428
  ;;
1429
  ppc64)
1430
    echo "ARCH=ppc64" >> $config_mak
1431
    echo "#define HOST_PPC64 1" >> $config_h
1432
  ;;
1433
  s390)
1434
    echo "ARCH=s390" >> $config_mak
1435
    echo "#define HOST_S390 1" >> $config_h
1436
  ;;
1437
  sparc)
1438
    echo "ARCH=sparc" >> $config_mak
1439
    echo "#define HOST_SPARC 1" >> $config_h
1440
  ;;
1441
  sparc64)
1442
    echo "ARCH=sparc64" >> $config_mak
1443
    echo "#define HOST_SPARC64 1" >> $config_h
1444
  ;;
1445
  *)
1446
    echo "Unsupported CPU = $cpu"
1447
    exit 1
1448
  ;;
1449
esac
1450
if test "$debug_tcg" = "yes" ; then
1451
  echo "#define DEBUG_TCG 1" >> $config_h
1452
fi
1453
if test "$sparse" = "yes" ; then
1454
  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_mak
1455
  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_mak
1456
  echo "CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_mak
1457
fi
1458
if test "$strip_opt" = "yes" ; then
1459
  echo "STRIP_OPT=-s" >> $config_mak
1460
fi
1461
if test "$bigendian" = "yes" ; then
1462
  echo "WORDS_BIGENDIAN=yes" >> $config_mak
1463
  echo "#define WORDS_BIGENDIAN 1" >> $config_h
1464
fi
1465
echo "#define HOST_LONG_BITS $hostlongbits" >> $config_h
1466
if test "$mingw32" = "yes" ; then
1467
  echo "CONFIG_WIN32=yes" >> $config_mak
1468
  echo "#define CONFIG_WIN32 1" >> $config_h
1469
else
1470
  cat > $TMPC << EOF
1471
#include <byteswap.h>
1472
int main(void) { return bswap_32(0); }
1473
EOF
1474
  if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1475
    echo "#define HAVE_BYTESWAP_H 1" >> $config_h
1476
  fi
1477
  cat > $TMPC << EOF
1478
#include <sys/endian.h>
1479
#include <sys/types.h>
1480
#include <machine/bswap.h>
1481
int main(void) { return bswap32(0); }
1482
EOF
1483
  if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1484
    echo "#define HAVE_MACHINE_BSWAP_H 1" >> $config_h
1485
  fi
1486
fi
1487

    
1488
if [ "$openbsd" = "yes" ] ; then
1489
  echo "#define ENOTSUP 4096" >> $config_h
1490
fi
1491

    
1492
if test "$darwin" = "yes" ; then
1493
  echo "CONFIG_DARWIN=yes" >> $config_mak
1494
  echo "#define CONFIG_DARWIN 1" >> $config_h
1495
fi
1496

    
1497
if test "$aix" = "yes" ; then
1498
  echo "CONFIG_AIX=yes" >> $config_mak
1499
  echo "#define CONFIG_AIX 1" >> $config_h
1500
fi
1501

    
1502
if test "$solaris" = "yes" ; then
1503
  echo "CONFIG_SOLARIS=yes" >> $config_mak
1504
  echo "#define HOST_SOLARIS $solarisrev" >> $config_h
1505
  if test "$needs_libsunmath" = "yes" ; then
1506
    echo "NEEDS_LIBSUNMATH=yes" >> $config_mak
1507
    echo "#define NEEDS_LIBSUNMATH 1" >> $config_h
1508
  fi
1509
fi
1510
if test -n "$sparc_cpu"; then
1511
  echo "CONFIG__sparc_${sparc_cpu}__=yes" >> $config_mak
1512
  echo "#define __sparc_${sparc_cpu}__ 1" >> $config_h
1513
fi
1514
if test "$gdbstub" = "yes" ; then
1515
  echo "CONFIG_GDBSTUB=yes" >> $config_mak
1516
  echo "#define CONFIG_GDBSTUB 1" >> $config_h
1517
fi
1518
if test "$gprof" = "yes" ; then
1519
  echo "TARGET_GPROF=yes" >> $config_mak
1520
  echo "#define HAVE_GPROF 1" >> $config_h
1521
fi
1522
if test "$static" = "yes" ; then
1523
  echo "CONFIG_STATIC=yes" >> $config_mak
1524
  echo "#define CONFIG_STATIC 1" >> $config_h
1525
fi
1526
if test $profiler = "yes" ; then
1527
  echo "#define CONFIG_PROFILER 1" >> $config_h
1528
fi
1529
if test "$slirp" = "yes" ; then
1530
  echo "CONFIG_SLIRP=yes" >> $config_mak
1531
  echo "#define CONFIG_SLIRP 1" >> $config_h
1532
fi
1533
if test "$vde" = "yes" ; then
1534
  echo "CONFIG_VDE=yes" >> $config_mak
1535
  echo "#define CONFIG_VDE 1" >> $config_h
1536
  echo "VDE_LIBS=-lvdeplug" >> $config_mak
1537
fi
1538
for card in $audio_card_list; do
1539
    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1540
    echo "$def=yes" >> $config_mak
1541
    echo "#define $def 1" >> $config_h
1542
done
1543
echo "#define AUDIO_DRIVERS \\" >> $config_h
1544
for drv in $audio_drv_list; do
1545
    echo "    &${drv}_audio_driver, \\" >>$config_h
1546
    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1547
    echo "$def=yes" >> $config_mak
1548
    if test "$drv" = "fmod"; then
1549
        echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
1550
        echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
1551
    elif test "$drv" = "oss"; then
1552
        echo "CONFIG_OSS_LIB=$oss_lib" >> $config_mak
1553
    fi
1554
done
1555
echo "" >>$config_h
1556
if test "$mixemu" = "yes" ; then
1557
  echo "CONFIG_MIXEMU=yes" >> $config_mak
1558
  echo "#define CONFIG_MIXEMU 1" >> $config_h
1559
fi
1560
if test "$vnc_tls" = "yes" ; then
1561
  echo "CONFIG_VNC_TLS=yes" >> $config_mak
1562
  echo "CONFIG_VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_mak
1563
  echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
1564
  echo "#define CONFIG_VNC_TLS 1" >> $config_h
1565
fi
1566
if test "$vnc_sasl" = "yes" ; then
1567
  echo "CONFIG_VNC_SASL=yes" >> $config_mak
1568
  echo "CONFIG_VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_mak
1569
  echo "CONFIG_VNC_SASL_LIBS=$vnc_sasl_libs" >> $config_mak
1570
  echo "#define CONFIG_VNC_SASL 1" >> $config_h
1571
fi
1572
if test "$fnmatch" = "yes" ; then
1573
  echo "#define HAVE_FNMATCH_H 1" >> $config_h
1574
fi
1575
qemu_version=`head $source_path/VERSION`
1576
echo "VERSION=$qemu_version" >>$config_mak
1577
echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
1578

    
1579
echo "#define QEMU_PKGVERSION \"$pkgversion\"" >> $config_h
1580

    
1581
echo "SRC_PATH=$source_path" >> $config_mak
1582
if [ "$source_path_used" = "yes" ]; then
1583
  echo "VPATH=$source_path" >> $config_mak
1584
fi
1585
echo "TARGET_DIRS=$target_list" >> $config_mak
1586
if [ "$build_docs" = "yes" ] ; then
1587
  echo "BUILD_DOCS=yes" >> $config_mak
1588
fi
1589
if test "$static" = "yes"; then
1590
  sdl1=$sdl_static
1591
else
1592
  sdl1=$sdl
1593
fi
1594
if test "$sdl1" = "yes" ; then
1595
  echo "#define CONFIG_SDL 1" >> $config_h
1596
  echo "CONFIG_SDL=yes" >> $config_mak
1597
  if test "$target_softmmu" = "no" -o "$static" = "yes"; then
1598
    echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
1599
  elif test "$sdl_x11" = "yes" ; then
1600
    echo "SDL_LIBS=`$sdl_config --libs` -lX11" >> $config_mak
1601
  else
1602
    echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
1603
  fi
1604
  if [ "${aa}" = "yes" ] ; then
1605
    echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak
1606
  else
1607
    echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
1608
  fi
1609
fi
1610
if test "$cocoa" = "yes" ; then
1611
  echo "#define CONFIG_COCOA 1" >> $config_h
1612
  echo "CONFIG_COCOA=yes" >> $config_mak
1613
fi
1614
if test "$curses" = "yes" ; then
1615
  echo "#define CONFIG_CURSES 1" >> $config_h
1616
  echo "CONFIG_CURSES=yes" >> $config_mak
1617
  echo "CURSES_LIBS=-lcurses" >> $config_mak
1618
fi
1619
if test "$atfile" = "yes" ; then
1620
  echo "#define CONFIG_ATFILE 1" >> $config_h
1621
fi
1622
if test "$inotify" = "yes" ; then
1623
  echo "#define CONFIG_INOTIFY 1" >> $config_h
1624
fi
1625
if test "$brlapi" = "yes" ; then
1626
  echo "CONFIG_BRLAPI=yes" >> $config_mak
1627
  echo "#define CONFIG_BRLAPI 1" >> $config_h
1628
  echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
1629
fi
1630
if test "$bluez" = "yes" ; then
1631
  echo "CONFIG_BLUEZ=yes" >> $config_mak
1632
  echo "CONFIG_BLUEZ_CFLAGS=$bluez_cflags" >> $config_mak
1633
  echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak
1634
  echo "#define CONFIG_BLUEZ 1" >> $config_h
1635
fi
1636
if test "$xen" = "yes" ; then
1637
  echo "XEN_LIBS=-lxenstore -lxenctrl" >> $config_mak
1638
fi
1639
if test "$aio" = "yes" ; then
1640
  echo "#define CONFIG_AIO 1" >> $config_h
1641
  echo "CONFIG_AIO=yes" >> $config_mak
1642
fi
1643
if test "$blobs" = "yes" ; then
1644
  echo "INSTALL_BLOBS=yes" >> $config_mak
1645
fi
1646
if test "$iovec" = "yes" ; then
1647
  echo "#define HAVE_IOVEC 1" >> $config_h
1648
fi
1649
if test "$preadv" = "yes" ; then
1650
  echo "#define HAVE_PREADV 1" >> $config_h
1651
fi
1652
if test "$fdt" = "yes" ; then
1653
  echo "#define HAVE_FDT 1" >> $config_h
1654
  echo "FDT_LIBS=-lfdt" >> $config_mak
1655
fi
1656

    
1657
# XXX: suppress that
1658
if [ "$bsd" = "yes" ] ; then
1659
  echo "#define O_LARGEFILE 0" >> $config_h
1660
  echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
1661
  echo "#define HOST_BSD 1" >> $config_h
1662
fi
1663

    
1664
echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
1665

    
1666
# USB host support
1667
case "$usb" in
1668
linux)
1669
  echo "HOST_USB=linux" >> $config_mak
1670
;;
1671
bsd)
1672
  echo "HOST_USB=bsd" >> $config_mak
1673
;;
1674
*)
1675
  echo "HOST_USB=stub" >> $config_mak
1676
;;
1677
esac
1678

    
1679
tools=
1680
if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1681
  tools="qemu-img\$(EXESUF) $tools"
1682
  if [ "$linux" = "yes" ] ; then
1683
      tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
1684
  fi
1685
fi
1686
echo "TOOLS=$tools" >> $config_mak
1687

    
1688
test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1689

    
1690
for target in $target_list; do
1691
target_dir="$target"
1692
config_mak=$target_dir/config.mak
1693
config_h=$target_dir/config.h
1694
target_cpu=`echo $target | cut -d '-' -f 1`
1695
target_bigendian="no"
1696
[ "$target_cpu" = "armeb" ] && target_bigendian=yes
1697
[ "$target_cpu" = "m68k" ] && target_bigendian=yes
1698
[ "$target_cpu" = "mips" ] && target_bigendian=yes
1699
[ "$target_cpu" = "mipsn32" ] && target_bigendian=yes
1700
[ "$target_cpu" = "mips64" ] && target_bigendian=yes
1701
[ "$target_cpu" = "ppc" ] && target_bigendian=yes
1702
[ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
1703
[ "$target_cpu" = "ppc64" ] && target_bigendian=yes
1704
[ "$target_cpu" = "ppc64abi32" ] && target_bigendian=yes
1705
[ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
1706
[ "$target_cpu" = "sparc" ] && target_bigendian=yes
1707
[ "$target_cpu" = "sparc64" ] && target_bigendian=yes
1708
[ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes
1709
target_softmmu="no"
1710
target_user_only="no"
1711
target_linux_user="no"
1712
target_darwin_user="no"
1713
target_bsd_user="no"
1714
case "$target" in
1715
  ${target_cpu}-softmmu)
1716
    target_softmmu="yes"
1717
    ;;
1718
  ${target_cpu}-linux-user)
1719
    target_user_only="yes"
1720
    target_linux_user="yes"
1721
    ;;
1722
  ${target_cpu}-darwin-user)
1723
    target_user_only="yes"
1724
    target_darwin_user="yes"
1725
    ;;
1726
  ${target_cpu}-bsd-user)
1727
    target_user_only="yes"
1728
    target_bsd_user="yes"
1729
    ;;
1730
  *)
1731
    echo "ERROR: Target '$target' not recognised"
1732
    exit 1
1733
    ;;
1734
esac
1735

    
1736
if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
1737
        -a "$sdl" = "no" -a "$cocoa" = "no" ; then
1738
    echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
1739
    echo "To build QEMU without graphical output configure with --disable-gfx-check"
1740
    echo "Note that this will disable all output from the virtual graphics card"
1741
    echo "except through VNC or curses."
1742
    exit 1;
1743
fi
1744

    
1745
#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
1746

    
1747
test -f $config_h && mv $config_h ${config_h}~
1748

    
1749
mkdir -p $target_dir
1750
mkdir -p $target_dir/fpu
1751
mkdir -p $target_dir/tcg
1752
if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
1753
  mkdir -p $target_dir/nwfpe
1754
fi
1755

    
1756
#
1757
# don't use ln -sf as not all "ln -sf" over write the file/link
1758
#
1759
rm -f $target_dir/Makefile
1760
ln -s $source_path/Makefile.target $target_dir/Makefile
1761

    
1762

    
1763
echo "# Automatically generated by configure - do not modify" > $config_mak
1764
echo "/* Automatically generated by configure - do not modify */" > $config_h
1765

    
1766

    
1767
echo "include ../config-host.mak" >> $config_mak
1768
echo "#include \"../config-host.h\"" >> $config_h
1769

    
1770
bflt="no"
1771
elfload32="no"
1772
target_nptl="no"
1773
interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
1774
echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
1775
gdb_xml_files=""
1776

    
1777
# Make sure the target and host cpus are compatible
1778
if test "$kvm" = "yes" -a ! \( "$target_cpu" = "$cpu" -o \
1779
  \( "$target_cpu" = "ppcemb" -a "$cpu" = "ppc" \) -o \
1780
  \( "$target_cpu" = "x86_64" -a "$cpu" = "i386"   \) -o \
1781
  \( "$target_cpu" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
1782
  kvm="no"
1783
fi
1784
# Disable KVM for linux-user
1785
if test "$kvm" = "yes" -a "$target_softmmu" = "no" ; then
1786
  kvm="no"
1787
fi
1788

    
1789
case "$target_cpu" in
1790
  i386)
1791
    echo "TARGET_ARCH=i386" >> $config_mak
1792
    echo "#define TARGET_ARCH \"i386\"" >> $config_h
1793
    echo "#define TARGET_I386 1" >> $config_h
1794
    if test $kqemu = "yes" -a "$target_softmmu" = "yes"
1795
    then
1796
      echo "CONFIG_KQEMU=yes" >> $config_mak
1797
      echo "#define CONFIG_KQEMU 1" >> $config_h
1798
    fi
1799
    if test "$kvm" = "yes" ; then
1800
      echo "CONFIG_KVM=yes" >> $config_mak
1801
      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1802
      echo "#define CONFIG_KVM 1" >> $config_h
1803
    fi
1804
    if test "$xen" = "yes" -a "$target_softmmu" = "yes";
1805
    then
1806
      echo "CONFIG_XEN=yes" >> $config_mak
1807
      echo "#define CONFIG_XEN 1" >> $config_h
1808
    fi
1809
  ;;
1810
  x86_64)
1811
    echo "TARGET_ARCH=x86_64" >> $config_mak
1812
    echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
1813
    echo "#define TARGET_I386 1" >> $config_h
1814
    echo "#define TARGET_X86_64 1" >> $config_h
1815
    if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"
1816
    then
1817
      echo "CONFIG_KQEMU=yes" >> $config_mak
1818
      echo "#define CONFIG_KQEMU 1" >> $config_h
1819
    fi
1820
    if test "$kvm" = "yes" ; then
1821
      echo "CONFIG_KVM=yes" >> $config_mak
1822
      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1823
      echo "#define CONFIG_KVM 1" >> $config_h
1824
    fi
1825
    if test "$xen" = "yes" -a "$target_softmmu" = "yes"
1826
    then
1827
      echo "CONFIG_XEN=yes" >> $config_mak
1828
      echo "#define CONFIG_XEN 1" >> $config_h
1829
    fi
1830
  ;;
1831
  alpha)
1832
    echo "TARGET_ARCH=alpha" >> $config_mak
1833
    echo "#define TARGET_ARCH \"alpha\"" >> $config_h
1834
    echo "#define TARGET_ALPHA 1" >> $config_h
1835
  ;;
1836
  arm|armeb)
1837
    echo "TARGET_ARCH=arm" >> $config_mak
1838
    echo "#define TARGET_ARCH \"arm\"" >> $config_h
1839
    echo "#define TARGET_ARM 1" >> $config_h
1840
    bflt="yes"
1841
    target_nptl="yes"
1842
    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1843
  ;;
1844
  cris)
1845
    echo "TARGET_ARCH=cris" >> $config_mak
1846
    echo "#define TARGET_ARCH \"cris\"" >> $config_h
1847
    echo "#define TARGET_CRIS 1" >> $config_h
1848
    target_nptl="yes"
1849
  ;;
1850
  m68k)
1851
    echo "TARGET_ARCH=m68k" >> $config_mak
1852
    echo "#define TARGET_ARCH \"m68k\"" >> $config_h
1853
    echo "#define TARGET_M68K 1" >> $config_h
1854
    bflt="yes"
1855
    gdb_xml_files="cf-core.xml cf-fp.xml"
1856
  ;;
1857
  mips|mipsel)
1858
    echo "TARGET_ARCH=mips" >> $config_mak
1859
    echo "#define TARGET_ARCH \"mips\"" >> $config_h
1860
    echo "#define TARGET_MIPS 1" >> $config_h
1861
    echo "#define TARGET_ABI_MIPSO32 1" >> $config_h
1862
  ;;
1863
  mipsn32|mipsn32el)
1864
    echo "TARGET_ARCH=mipsn32" >> $config_mak
1865
    echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h
1866
    echo "#define TARGET_MIPS 1" >> $config_h
1867
    echo "#define TARGET_ABI_MIPSN32 1" >> $config_h
1868
  ;;
1869
  mips64|mips64el)
1870
    echo "TARGET_ARCH=mips64" >> $config_mak
1871
    echo "#define TARGET_ARCH \"mips64\"" >> $config_h
1872
    echo "#define TARGET_MIPS 1" >> $config_h
1873
    echo "#define TARGET_MIPS64 1" >> $config_h
1874
    echo "#define TARGET_ABI_MIPSN64 1" >> $config_h
1875
  ;;
1876
  ppc)
1877
    echo "TARGET_ARCH=ppc" >> $config_mak
1878
    echo "#define TARGET_ARCH \"ppc\"" >> $config_h
1879
    echo "#define TARGET_PPC 1" >> $config_h
1880
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1881
  ;;
1882
  ppcemb)
1883
    echo "TARGET_ARCH=ppcemb" >> $config_mak
1884
    echo "TARGET_ABI_DIR=ppc" >> $config_mak
1885
    echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
1886
    echo "#define TARGET_PPC 1" >> $config_h
1887
    echo "#define TARGET_PPCEMB 1" >> $config_h
1888
    if test "$kvm" = "yes" ; then
1889
      echo "CONFIG_KVM=yes" >> $config_mak
1890
      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1891
      echo "#define CONFIG_KVM 1" >> $config_h
1892
    fi
1893
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1894
  ;;
1895
  ppc64)
1896
    echo "TARGET_ARCH=ppc64" >> $config_mak
1897
    echo "TARGET_ABI_DIR=ppc" >> $config_mak
1898
    echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1899
    echo "#define TARGET_PPC 1" >> $config_h
1900
    echo "#define TARGET_PPC64 1" >> $config_h
1901
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1902
  ;;
1903
  ppc64abi32)
1904
    echo "TARGET_ARCH=ppc64" >> $config_mak
1905
    echo "TARGET_ABI_DIR=ppc" >> $config_mak
1906
    echo "TARGET_ARCH2=ppc64abi32" >> $config_mak
1907
    echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1908
    echo "#define TARGET_PPC 1" >> $config_h
1909
    echo "#define TARGET_PPC64 1" >> $config_h
1910
    echo "#define TARGET_ABI32 1" >> $config_h
1911
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1912
  ;;
1913
  sh4|sh4eb)
1914
    echo "TARGET_ARCH=sh4" >> $config_mak
1915
    echo "#define TARGET_ARCH \"sh4\"" >> $config_h
1916
    echo "#define TARGET_SH4 1" >> $config_h
1917
    bflt="yes"
1918
    target_nptl="yes"
1919
  ;;
1920
  sparc)
1921
    echo "TARGET_ARCH=sparc" >> $config_mak
1922
    echo "#define TARGET_ARCH \"sparc\"" >> $config_h
1923
    echo "#define TARGET_SPARC 1" >> $config_h
1924
  ;;
1925
  sparc64)
1926
    echo "TARGET_ARCH=sparc64" >> $config_mak
1927
    echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1928
    echo "#define TARGET_SPARC 1" >> $config_h
1929
    echo "#define TARGET_SPARC64 1" >> $config_h
1930
    elfload32="yes"
1931
  ;;
1932
  sparc32plus)
1933
    echo "TARGET_ARCH=sparc64" >> $config_mak
1934
    echo "TARGET_ABI_DIR=sparc" >> $config_mak
1935
    echo "TARGET_ARCH2=sparc32plus" >> $config_mak
1936
    echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1937
    echo "#define TARGET_SPARC 1" >> $config_h
1938
    echo "#define TARGET_SPARC64 1" >> $config_h
1939
    echo "#define TARGET_ABI32 1" >> $config_h
1940
  ;;
1941
  *)
1942
    echo "Unsupported target CPU"
1943
    exit 1
1944
  ;;
1945
esac
1946
if test "$target_bigendian" = "yes" ; then
1947
  echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
1948
  echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
1949
fi
1950
if test "$target_softmmu" = "yes" ; then
1951
  echo "CONFIG_SOFTMMU=yes" >> $config_mak
1952
  echo "#define CONFIG_SOFTMMU 1" >> $config_h
1953
fi
1954
if test "$target_user_only" = "yes" ; then
1955
  echo "CONFIG_USER_ONLY=yes" >> $config_mak
1956
  echo "#define CONFIG_USER_ONLY 1" >> $config_h
1957
fi
1958
if test "$target_linux_user" = "yes" ; then
1959
  echo "CONFIG_LINUX_USER=yes" >> $config_mak
1960
  echo "#define CONFIG_LINUX_USER 1" >> $config_h
1961
fi
1962
if test "$target_darwin_user" = "yes" ; then
1963
  echo "CONFIG_DARWIN_USER=yes" >> $config_mak
1964
  echo "#define CONFIG_DARWIN_USER 1" >> $config_h
1965
fi
1966
list=""
1967
if test ! -z "$gdb_xml_files" ; then
1968
  for x in $gdb_xml_files; do
1969
    list="$list $source_path/gdb-xml/$x"
1970
  done
1971
fi
1972
echo "TARGET_XML_FILES=$list" >> $config_mak
1973

    
1974
if test "$target_cpu" = "arm" \
1975
     -o "$target_cpu" = "armeb" \
1976
     -o "$target_cpu" = "m68k" \
1977
     -o "$target_cpu" = "mips" \
1978
     -o "$target_cpu" = "mipsel" \
1979
     -o "$target_cpu" = "mipsn32" \
1980
     -o "$target_cpu" = "mipsn32el" \
1981
     -o "$target_cpu" = "mips64" \
1982
     -o "$target_cpu" = "mips64el" \
1983
     -o "$target_cpu" = "ppc" \
1984
     -o "$target_cpu" = "ppc64" \
1985
     -o "$target_cpu" = "ppc64abi32" \
1986
     -o "$target_cpu" = "ppcemb" \
1987
     -o "$target_cpu" = "sparc" \
1988
     -o "$target_cpu" = "sparc64" \
1989
     -o "$target_cpu" = "sparc32plus"; then
1990
  echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
1991
  echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
1992
fi
1993
if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
1994
  echo "TARGET_HAS_BFLT=yes" >> $config_mak
1995
  echo "#define TARGET_HAS_BFLT 1" >> $config_h
1996
fi
1997
if test "$target_user_only" = "yes" \
1998
        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
1999
  echo "#define USE_NPTL 1" >> $config_h
2000
fi
2001
# 32 bit ELF loader in addition to native 64 bit loader?
2002
if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2003
  echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
2004
  echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
2005
fi
2006
if test "$target_bsd_user" = "yes" ; then
2007
  echo "CONFIG_BSD_USER=yes" >> $config_mak
2008
  echo "#define CONFIG_BSD_USER 1" >> $config_h
2009
fi
2010

    
2011
test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
2012

    
2013
done # for target in $targets
2014

    
2015
# build tree in object directory if source path is different from current one
2016
if test "$source_path_used" = "yes" ; then
2017
    DIRS="tests tests/cris slirp audio"
2018
    FILES="Makefile tests/Makefile"
2019
    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2020
    FILES="$FILES tests/test-mmap.c"
2021
    for dir in $DIRS ; do
2022
            mkdir -p $dir
2023
    done
2024
    # remove the link and recreate it, as not all "ln -sf" overwrite the link
2025
    for f in $FILES ; do
2026
        rm -f $f
2027
        ln -s $source_path/$f $f
2028
    done
2029
fi