]> Git Repo - qemu.git/blob - configure
configure: clean up temporary dependency files
[qemu.git] / configure
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 TMPD="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.d"
18
19 trap "rm -f $TMPC $TMPO $TMPE $TMPD ; exit" 0 2 3 15
20
21 compile_object() {
22   $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
23 }
24
25 compile_prog() {
26   local_cflags="$1"
27   local_ldflags="$2"
28   $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
29 }
30
31 # default parameters
32 cpu=""
33 prefix=""
34 interp_prefix="/usr/gnemul/qemu-%M"
35 static="no"
36 sparc_cpu=""
37 cross_prefix=""
38 cc="gcc"
39 audio_drv_list=""
40 audio_card_list="ac97 es1370 sb16"
41 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
42 host_cc="gcc"
43 ar="ar"
44 make="make"
45 install="install"
46 objcopy="objcopy"
47 ld="ld"
48 helper_cflags=""
49 libs_softmmu=""
50 libs_tools=""
51 audio_pt_int=""
52 audio_win_int=""
53
54 # parse CC options first
55 for opt do
56   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
57   case "$opt" in
58   --cross-prefix=*) cross_prefix="$optarg"
59   ;;
60   --cc=*) cc="$optarg"
61   ;;
62   --cpu=*) cpu="$optarg"
63   ;;
64   --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
65   ;;
66   --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
67   ;;
68   --sparc_cpu=*)
69     sparc_cpu="$optarg"
70     case $sparc_cpu in
71     v7|v8|v8plus|v8plusa)
72       cpu="sparc"
73     ;;
74     v9)
75       cpu="sparc64"
76     ;;
77     *)
78       echo "undefined SPARC architecture. Exiting";
79       exit 1
80     ;;
81     esac
82   ;;
83   esac
84 done
85 # OS specific
86 # Using uname is really, really broken.  Once we have the right set of checks
87 # we can eliminate it's usage altogether
88
89 cc="${cross_prefix}${cc}"
90 ar="${cross_prefix}${ar}"
91 objcopy="${cross_prefix}${objcopy}"
92 ld="${cross_prefix}${ld}"
93
94 # check that the C compiler works.
95 cat > $TMPC <<EOF
96 int main(void) {}
97 EOF
98
99 if compile_object ; then
100   : C compiler works ok
101 else
102     echo "ERROR: \"$cc\" either does not exist or does not work"
103     exit 1
104 fi
105
106 check_define() {
107 cat > $TMPC <<EOF
108 #if !defined($1)
109 #error Not defined
110 #endif
111 int main(void) { return 0; }
112 EOF
113   compile_object
114 }
115
116 if test ! -z "$cpu" ; then
117   # command line argument
118   :
119 elif check_define __i386__ ; then
120   cpu="i386"
121 elif check_define __x86_64__ ; then
122   cpu="x86_64"
123 elif check_define __sparc__ ; then
124   # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
125   # They must be specified using --sparc_cpu
126   if check_define __arch64__ ; then
127     cpu="sparc64"
128   else
129     cpu="sparc"
130   fi
131 elif check_define _ARCH_PPC ; then
132   if check_define _ARCH_PPC64 ; then
133     cpu="ppc64"
134   else
135     cpu="ppc"
136   fi
137 else
138   cpu=`uname -m`
139 fi
140
141 target_list=""
142 case "$cpu" in
143   alpha|cris|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|sparc64)
144     cpu="$cpu"
145   ;;
146   i386|i486|i586|i686|i86pc|BePC)
147     cpu="i386"
148   ;;
149   x86_64|amd64)
150     cpu="x86_64"
151   ;;
152   armv*b)
153     cpu="armv4b"
154   ;;
155   armv*l)
156     cpu="armv4l"
157   ;;
158   parisc|parisc64)
159     cpu="hppa"
160   ;;
161   s390*)
162     cpu="s390"
163   ;;
164   sparc|sun4[cdmuv])
165     cpu="sparc"
166   ;;
167   *)
168     cpu="unknown"
169   ;;
170 esac
171
172 # Default value for a variable defining feature "foo"
173 #  * foo="no", feature will only be used if --enable-foo arg is given
174 #  * foo="", feature will be searched for, and if found, will be used
175 #  * foo="yes", this value vill only be set by --enable-foo flag.
176 #                   feature will searched for, if not found, configure exits with error
177 #
178 # Always add --enable-foo and --disable-foo command line args.  Distributions want
179 # to ensure that several features are compiled in, and it is impossible without a
180 # --enable-foo that exits if feature is not found
181
182 bluez=""
183 brlapi=""
184 curl=""
185 curses=""
186 docs=""
187 fdt=""
188 kvm=""
189 nptl=""
190 sdl=""
191 sparse="no"
192 uuid=""
193 vde=""
194 vnc_tls=""
195 vnc_sasl=""
196 xen=""
197 linux_aio=""
198
199 gprof="no"
200 debug_tcg="no"
201 debug="no"
202 strip_opt="yes"
203 bigendian="no"
204 mingw32="no"
205 EXESUF=""
206 slirp="yes"
207 fmod_lib=""
208 fmod_inc=""
209 oss_lib=""
210 bsd="no"
211 linux="no"
212 solaris="no"
213 profiler="no"
214 cocoa="no"
215 softmmu="yes"
216 linux_user="no"
217 darwin_user="no"
218 bsd_user="no"
219 guest_base=""
220 uname_release=""
221 io_thread="no"
222 mixemu="no"
223 kerneldir=""
224 aix="no"
225 blobs="yes"
226 pkgversion=""
227 check_utests="no"
228 user_pie="no"
229
230 # OS specific
231 if check_define __linux__ ; then
232   targetos="Linux"
233 elif check_define _WIN32 ; then
234   targetos='MINGW32'
235 elif check_define __OpenBSD__ ; then
236   targetos='OpenBSD'
237 elif check_define __sun__ ; then
238   targetos='SunOS'
239 else
240   targetos=`uname -s`
241 fi
242
243 case $targetos in
244 CYGWIN*)
245   mingw32="yes"
246   QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
247   audio_possible_drivers="winwave sdl"
248   audio_drv_list="winwave"
249 ;;
250 MINGW32*)
251   mingw32="yes"
252   audio_possible_drivers="winwave dsound sdl fmod"
253   audio_drv_list="winwave"
254 ;;
255 GNU/kFreeBSD)
256   audio_drv_list="oss"
257   audio_possible_drivers="oss sdl esd pa"
258 ;;
259 FreeBSD)
260   bsd="yes"
261   audio_drv_list="oss"
262   audio_possible_drivers="oss sdl esd pa"
263 ;;
264 DragonFly)
265   bsd="yes"
266   audio_drv_list="oss"
267   audio_possible_drivers="oss sdl esd pa"
268 ;;
269 NetBSD)
270   bsd="yes"
271   audio_drv_list="oss"
272   audio_possible_drivers="oss sdl esd"
273   oss_lib="-lossaudio"
274 ;;
275 OpenBSD)
276   bsd="yes"
277   audio_drv_list="oss"
278   audio_possible_drivers="oss sdl esd"
279   oss_lib="-lossaudio"
280 ;;
281 Darwin)
282   bsd="yes"
283   darwin="yes"
284   # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
285   # run 64-bit userspace code
286   if [ "$cpu" = "i386" ] ; then
287     is_x86_64=`sysctl -n hw.optional.x86_64`
288     [ "$is_x86_64" = "1" ] && cpu=x86_64
289   fi
290   if [ "$cpu" = "x86_64" ] ; then
291     QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
292     LDFLAGS="-arch x86_64 $LDFLAGS"
293   else
294     QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
295   fi
296   darwin_user="yes"
297   cocoa="yes"
298   audio_drv_list="coreaudio"
299   audio_possible_drivers="coreaudio sdl fmod"
300   LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
301   libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
302 ;;
303 SunOS)
304   solaris="yes"
305   make="gmake"
306   install="ginstall"
307   ld="gld"
308   needs_libsunmath="no"
309   solarisrev=`uname -r | cut -f2 -d.`
310   # have to select again, because `uname -m` returns i86pc
311   # even on an x86_64 box.
312   solariscpu=`isainfo -k`
313   if test "${solariscpu}" = "amd64" ; then
314     cpu="x86_64"
315   fi
316   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
317     if test "$solarisrev" -le 9 ; then
318       if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
319         needs_libsunmath="yes"
320         QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
321         LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
322         LIBS="-lsunmath $LIBS"
323       else
324         echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
325         echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
326         echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
327         echo "Studio 11 can be downloaded from www.sun.com."
328         exit 1
329       fi
330     fi
331   fi
332   if test -f /usr/include/sys/soundcard.h ; then
333     audio_drv_list="oss"
334   fi
335   audio_possible_drivers="oss sdl"
336 # needed for CMSG_ macros in sys/socket.h
337   QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
338 # needed for TIOCWIN* defines in termios.h
339   QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
340   QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
341   LIBS="-lsocket -lnsl -lresolv $LIBS"
342 ;;
343 AIX)
344   aix="yes"
345   make="gmake"
346 ;;
347 *)
348   audio_drv_list="oss"
349   audio_possible_drivers="oss alsa sdl esd pa"
350   linux="yes"
351   linux_user="yes"
352   usb="linux"
353   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
354     audio_possible_drivers="$audio_possible_drivers fmod"
355   fi
356 ;;
357 esac
358
359 if [ "$bsd" = "yes" ] ; then
360   if [ "$darwin" != "yes" ] ; then
361     make="gmake"
362     usb="bsd"
363   fi
364   bsd_user="yes"
365 fi
366
367 if test "$mingw32" = "yes" ; then
368   EXESUF=".exe"
369   QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
370   LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
371 fi
372
373 # find source path
374 source_path=`dirname "$0"`
375 source_path_used="no"
376 workdir=`pwd`
377 if [ -z "$source_path" ]; then
378     source_path=$workdir
379 else
380     source_path=`cd "$source_path"; pwd`
381 fi
382 [ -f "$workdir/vl.c" ] || source_path_used="yes"
383
384 werror=""
385
386 for opt do
387   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
388   case "$opt" in
389   --help|-h) show_help=yes
390   ;;
391   --prefix=*) prefix="$optarg"
392   ;;
393   --interp-prefix=*) interp_prefix="$optarg"
394   ;;
395   --source-path=*) source_path="$optarg"
396   source_path_used="yes"
397   ;;
398   --cross-prefix=*)
399   ;;
400   --cc=*)
401   ;;
402   --host-cc=*) host_cc="$optarg"
403   ;;
404   --make=*) make="$optarg"
405   ;;
406   --install=*) install="$optarg"
407   ;;
408   --extra-cflags=*)
409   ;;
410   --extra-ldflags=*)
411   ;;
412   --cpu=*)
413   ;;
414   --target-list=*) target_list="$optarg"
415   ;;
416   --enable-gprof) gprof="yes"
417   ;;
418   --static) static="yes"
419   ;;
420   --disable-sdl) sdl="no"
421   ;;
422   --enable-sdl) sdl="yes"
423   ;;
424   --fmod-lib=*) fmod_lib="$optarg"
425   ;;
426   --fmod-inc=*) fmod_inc="$optarg"
427   ;;
428   --oss-lib=*) oss_lib="$optarg"
429   ;;
430   --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
431   ;;
432   --audio-drv-list=*) audio_drv_list="$optarg"
433   ;;
434   --enable-debug-tcg) debug_tcg="yes"
435   ;;
436   --disable-debug-tcg) debug_tcg="no"
437   ;;
438   --enable-debug)
439       # Enable debugging options that aren't excessively noisy
440       debug_tcg="yes"
441       debug="yes"
442       strip_opt="no"
443   ;;
444   --enable-sparse) sparse="yes"
445   ;;
446   --disable-sparse) sparse="no"
447   ;;
448   --disable-strip) strip_opt="no"
449   ;;
450   --disable-vnc-tls) vnc_tls="no"
451   ;;
452   --enable-vnc-tls) vnc_tls="yes"
453   ;;
454   --disable-vnc-sasl) vnc_sasl="no"
455   ;;
456   --enable-vnc-sasl) vnc_sasl="yes"
457   ;;
458   --disable-slirp) slirp="no"
459   ;;
460   --disable-uuid) uuid="no"
461   ;;
462   --enable-uuid) uuid="yes"
463   ;;
464   --disable-vde) vde="no"
465   ;;
466   --enable-vde) vde="yes"
467   ;;
468   --disable-xen) xen="no"
469   ;;
470   --enable-xen) xen="yes"
471   ;;
472   --disable-brlapi) brlapi="no"
473   ;;
474   --enable-brlapi) brlapi="yes"
475   ;;
476   --disable-bluez) bluez="no"
477   ;;
478   --enable-bluez) bluez="yes"
479   ;;
480   --disable-kvm) kvm="no"
481   ;;
482   --enable-kvm) kvm="yes"
483   ;;
484   --enable-profiler) profiler="yes"
485   ;;
486   --enable-cocoa)
487       cocoa="yes" ;
488       sdl="no" ;
489       audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
490   ;;
491   --disable-system) softmmu="no"
492   ;;
493   --enable-system) softmmu="yes"
494   ;;
495   --disable-user)
496       linux_user="no" ;
497       bsd_user="no" ;
498       darwin_user="no"
499   ;;
500   --enable-user) ;;
501   --disable-linux-user) linux_user="no"
502   ;;
503   --enable-linux-user) linux_user="yes"
504   ;;
505   --disable-darwin-user) darwin_user="no"
506   ;;
507   --enable-darwin-user) darwin_user="yes"
508   ;;
509   --disable-bsd-user) bsd_user="no"
510   ;;
511   --enable-bsd-user) bsd_user="yes"
512   ;;
513   --enable-guest-base) guest_base="yes"
514   ;;
515   --disable-guest-base) guest_base="no"
516   ;;
517   --enable-user-pie) user_pie="yes"
518   ;;
519   --disable-user-pie) user_pie="no"
520   ;;
521   --enable-uname-release=*) uname_release="$optarg"
522   ;;
523   --sparc_cpu=*)
524   ;;
525   --enable-werror) werror="yes"
526   ;;
527   --disable-werror) werror="no"
528   ;;
529   --disable-curses) curses="no"
530   ;;
531   --enable-curses) curses="yes"
532   ;;
533   --disable-curl) curl="no"
534   ;;
535   --enable-curl) curl="yes"
536   ;;
537   --disable-fdt) fdt="no"
538   ;;
539   --enable-fdt) fdt="yes"
540   ;;
541   --disable-check-utests) check_utests="no"
542   ;;
543   --enable-check-utests) check_utests="yes"
544   ;;
545   --disable-nptl) nptl="no"
546   ;;
547   --enable-nptl) nptl="yes"
548   ;;
549   --enable-mixemu) mixemu="yes"
550   ;;
551   --disable-linux-aio) linux_aio="no"
552   ;;
553   --enable-linux-aio) linux_aio="yes"
554   ;;
555   --enable-io-thread) io_thread="yes"
556   ;;
557   --disable-blobs) blobs="no"
558   ;;
559   --kerneldir=*) kerneldir="$optarg"
560   ;;
561   --with-pkgversion=*) pkgversion=" ($optarg)"
562   ;;
563   --disable-docs) docs="no"
564   ;;
565   --enable-docs) docs="yes"
566   ;;
567   *) echo "ERROR: unknown option $opt"; show_help="yes"
568   ;;
569   esac
570 done
571
572 #
573 # If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
574 # QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
575 #
576 host_guest_base="no"
577 case "$cpu" in
578     sparc) case $sparc_cpu in
579            v7|v8)
580              QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
581            ;;
582            v8plus|v8plusa)
583              QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
584            ;;
585            *) # sparc_cpu not defined in the command line
586              QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
587            esac
588            LDFLAGS="-m32 $LDFLAGS"
589            QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
590            if test "$solaris" = "no" ; then
591              QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
592              helper_cflags="-ffixed-i0"
593            fi
594            ;;
595     sparc64)
596            QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
597            LDFLAGS="-m64 $LDFLAGS"
598            QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
599            if test "$solaris" != "no" ; then
600              QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
601            fi
602            ;;
603     s390)
604            QEMU_CFLAGS="-march=z900 $QEMU_CFLAGS"
605            ;;
606     i386)
607            QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
608            LDFLAGS="-m32 $LDFLAGS"
609            helper_cflags="-fomit-frame-pointer"
610            host_guest_base="yes"
611            ;;
612     x86_64)
613            QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
614            LDFLAGS="-m64 $LDFLAGS"
615            host_guest_base="yes"
616            ;;
617     arm*)
618            host_guest_base="yes"
619            ;;
620     ppc*)
621            host_guest_base="yes"
622            ;;
623 esac
624
625 [ -z "$guest_base" ] && guest_base="$host_guest_base"
626
627 if test x"$show_help" = x"yes" ; then
628 cat << EOF
629
630 Usage: configure [options]
631 Options: [defaults in brackets after descriptions]
632
633 EOF
634 echo "Standard options:"
635 echo "  --help                   print this message"
636 echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
637 echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
638 echo "                           use %M for cpu name [$interp_prefix]"
639 echo "  --target-list=LIST       set target list [$target_list]"
640 echo ""
641 echo "Advanced options (experts only):"
642 echo "  --source-path=PATH       path of source code [$source_path]"
643 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
644 echo "  --cc=CC                  use C compiler CC [$cc]"
645 echo "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
646 echo "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
647 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
648 echo "  --make=MAKE              use specified make [$make]"
649 echo "  --install=INSTALL        use specified install [$install]"
650 echo "  --static                 enable static build [$static]"
651 echo "  --enable-debug-tcg       enable TCG debugging"
652 echo "  --disable-debug-tcg      disable TCG debugging (default)"
653 echo "  --enable-debug           enable common debug build options"
654 echo "  --enable-sparse          enable sparse checker"
655 echo "  --disable-sparse         disable sparse checker (default)"
656 echo "  --disable-strip          disable stripping binaries"
657 echo "  --disable-werror         disable compilation abort on warning"
658 echo "  --disable-sdl            disable SDL"
659 echo "  --enable-sdl             enable SDL"
660 echo "  --enable-cocoa           enable COCOA (Mac OS X only)"
661 echo "  --audio-drv-list=LIST    set audio drivers list:"
662 echo "                           Available drivers: $audio_possible_drivers"
663 echo "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
664 echo "                           Available cards: $audio_possible_cards"
665 echo "  --enable-mixemu          enable mixer emulation"
666 echo "  --disable-xen            disable xen backend driver support"
667 echo "  --enable-xen             enable xen backend driver support"
668 echo "  --disable-brlapi         disable BrlAPI"
669 echo "  --enable-brlapi          enable BrlAPI"
670 echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
671 echo "  --enable-vnc-tls         enable TLS encryption for VNC server"
672 echo "  --disable-vnc-sasl       disable SASL encryption for VNC server"
673 echo "  --enable-vnc-sasl        enable SASL encryption for VNC server"
674 echo "  --disable-curses         disable curses output"
675 echo "  --enable-curses          enable curses output"
676 echo "  --disable-curl           disable curl connectivity"
677 echo "  --enable-curl            enable curl connectivity"
678 echo "  --disable-fdt            disable fdt device tree"
679 echo "  --enable-fdt             enable fdt device tree"
680 echo "  --disable-check-utests   disable check unit-tests"
681 echo "  --enable-check-utests    enable check unit-tests"
682 echo "  --disable-bluez          disable bluez stack connectivity"
683 echo "  --enable-bluez           enable bluez stack connectivity"
684 echo "  --disable-kvm            disable KVM acceleration support"
685 echo "  --enable-kvm             enable KVM acceleration support"
686 echo "  --disable-nptl           disable usermode NPTL support"
687 echo "  --enable-nptl            enable usermode NPTL support"
688 echo "  --enable-system          enable all system emulation targets"
689 echo "  --disable-system         disable all system emulation targets"
690 echo "  --enable-user            enable supported user emulation targets"
691 echo "  --disable-user           disable all user emulation targets"
692 echo "  --enable-linux-user      enable all linux usermode emulation targets"
693 echo "  --disable-linux-user     disable all linux usermode emulation targets"
694 echo "  --enable-darwin-user     enable all darwin usermode emulation targets"
695 echo "  --disable-darwin-user    disable all darwin usermode emulation targets"
696 echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
697 echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
698 echo "  --enable-guest-base      enable GUEST_BASE support for usermode"
699 echo "                           emulation targets"
700 echo "  --disable-guest-base     disable GUEST_BASE support"
701 echo "  --enable-user-pie        build usermode emulation targets as PIE"
702 echo "  --disable-user-pie       do not build usermode emulation targets as PIE"
703 echo "  --fmod-lib               path to FMOD library"
704 echo "  --fmod-inc               path to FMOD includes"
705 echo "  --oss-lib                path to OSS library"
706 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
707 echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
708 echo "  --disable-uuid           disable uuid support"
709 echo "  --enable-uuid            enable uuid support"
710 echo "  --disable-vde            disable support for vde network"
711 echo "  --enable-vde             enable support for vde network"
712 echo "  --disable-linux-aio      disable Linux AIO support"
713 echo "  --enable-linux-aio       enable Linux AIO support"
714 echo "  --enable-io-thread       enable IO thread"
715 echo "  --disable-blobs          disable installing provided firmware blobs"
716 echo "  --kerneldir=PATH         look for kernel includes in PATH"
717 echo ""
718 echo "NOTE: The object files are built at the place where configure is launched"
719 exit 1
720 fi
721
722 #
723 # Solaris specific configure tool chain decisions
724 #
725 if test "$solaris" = "yes" ; then
726   solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
727   if test -z "$solinst" ; then
728     echo "Solaris install program not found. Use --install=/usr/ucb/install or"
729     echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
730     echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
731     exit 1
732   fi
733   if test "$solinst" = "/usr/sbin/install" ; then
734     echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
735     echo "try ginstall from the GNU fileutils available from www.blastwave.org"
736     echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
737     exit 1
738   fi
739   sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
740   if test -z "$sol_ar" ; then
741     echo "Error: No path includes ar"
742     if test -f /usr/ccs/bin/ar ; then
743       echo "Add /usr/ccs/bin to your path and rerun configure"
744     fi
745     exit 1
746   fi
747 fi
748
749
750 if test -z "$target_list" ; then
751 # these targets are portable
752     if [ "$softmmu" = "yes" ] ; then
753         target_list="\
754 i386-softmmu \
755 x86_64-softmmu \
756 arm-softmmu \
757 cris-softmmu \
758 m68k-softmmu \
759 microblaze-softmmu \
760 mips-softmmu \
761 mipsel-softmmu \
762 mips64-softmmu \
763 mips64el-softmmu \
764 ppc-softmmu \
765 ppcemb-softmmu \
766 ppc64-softmmu \
767 sh4-softmmu \
768 sh4eb-softmmu \
769 sparc-softmmu \
770 sparc64-softmmu \
771 "
772     fi
773 # the following are Linux specific
774     if [ "$linux_user" = "yes" ] ; then
775         target_list="${target_list}\
776 i386-linux-user \
777 x86_64-linux-user \
778 alpha-linux-user \
779 arm-linux-user \
780 armeb-linux-user \
781 cris-linux-user \
782 m68k-linux-user \
783 microblaze-linux-user \
784 mips-linux-user \
785 mipsel-linux-user \
786 ppc-linux-user \
787 ppc64-linux-user \
788 ppc64abi32-linux-user \
789 sh4-linux-user \
790 sh4eb-linux-user \
791 sparc-linux-user \
792 sparc64-linux-user \
793 sparc32plus-linux-user \
794 "
795     fi
796 # the following are Darwin specific
797     if [ "$darwin_user" = "yes" ] ; then
798         target_list="$target_list i386-darwin-user ppc-darwin-user "
799     fi
800 # the following are BSD specific
801     if [ "$bsd_user" = "yes" ] ; then
802         target_list="${target_list}\
803 i386-bsd-user \
804 x86_64-bsd-user \
805 sparc-bsd-user \
806 sparc64-bsd-user \
807 "
808     fi
809 else
810     target_list=`echo "$target_list" | sed -e 's/,/ /g'`
811 fi
812 if test -z "$target_list" ; then
813     echo "No targets enabled"
814     exit 1
815 fi
816
817 feature_not_found() {
818   feature=$1
819
820   echo "ERROR"
821   echo "ERROR: User requested feature $feature"
822   echo "ERROR: configure was not able to find it"
823   echo "ERROR"
824   exit 1;
825 }
826
827 if test -z "$cross_prefix" ; then
828
829 # ---
830 # big/little endian test
831 cat > $TMPC << EOF
832 #include <inttypes.h>
833 int main(int argc, char ** argv){
834         volatile uint32_t i=0x01234567;
835         return (*((uint8_t*)(&i))) == 0x67;
836 }
837 EOF
838
839 if compile_prog "" "" ; then
840 $TMPE && bigendian="yes"
841 else
842 echo big/little test failed
843 fi
844
845 else
846
847 # if cross compiling, cannot launch a program, so make a static guess
848 case "$cpu" in
849   armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
850     bigendian=yes
851   ;;
852 esac
853
854 fi
855
856 # host long bits test
857 hostlongbits="32"
858 case "$cpu" in
859   x86_64|alpha|ia64|sparc64|ppc64)
860     hostlongbits=64
861   ;;
862 esac
863
864
865 ##########################################
866 # NPTL probe
867
868 if test "$nptl" != "no" ; then
869   cat > $TMPC <<EOF
870 #include <sched.h>
871 #include <linux/futex.h>
872 void foo()
873 {
874 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
875 #error bork
876 #endif
877 }
878 EOF
879
880   if compile_object ; then
881     nptl=yes
882   else
883     if test "$nptl" = "yes" ; then
884       feature_not_found "nptl"
885     fi
886     nptl=no
887   fi
888 fi
889
890 ##########################################
891 # zlib check
892
893 cat > $TMPC << EOF
894 #include <zlib.h>
895 int main(void) { zlibVersion(); return 0; }
896 EOF
897 if compile_prog "" "-lz" ; then
898     :
899 else
900     echo
901     echo "Error: zlib check failed"
902     echo "Make sure to have the zlib libs and headers installed."
903     echo
904     exit 1
905 fi
906
907 ##########################################
908 # xen probe
909
910 if test "$xen" != "no" ; then
911   xen_libs="-lxenstore -lxenctrl -lxenguest"
912   cat > $TMPC <<EOF
913 #include <xenctrl.h>
914 #include <xs.h>
915 int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
916 EOF
917   if compile_prog "" "$xen_libs" ; then
918     xen=yes
919     libs_softmmu="$xen_libs $libs_softmmu"
920   else
921     if test "$xen" = "yes" ; then
922       feature_not_found "xen"
923     fi
924     xen=no
925   fi
926 fi
927
928 ##########################################
929 # Sparse probe
930 if test "$sparse" != "no" ; then
931   if test -x "$(which cgcc 2>/dev/null)"; then
932     sparse=yes
933   else
934     if test "$sparse" = "yes" ; then
935       feature_not_found "sparse"
936     fi
937     sparse=no
938   fi
939 fi
940
941 ##########################################
942 # SDL probe
943
944 sdl_too_old=no
945
946 if test "$sdl" != "no" ; then
947   cat > $TMPC << EOF
948 #include <SDL.h>
949 #undef main /* We don't want SDL to override our main() */
950 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
951 EOF
952   sdl_cflags=`sdl-config --cflags 2> /dev/null`
953   sdl_libs=`sdl-config --libs 2> /dev/null`
954   if compile_prog "$sdl_cflags" "$sdl_libs" ; then
955     _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
956     if test "$_sdlversion" -lt 121 ; then
957       sdl_too_old=yes
958     else
959       if test "$cocoa" = "no" ; then
960         sdl=yes
961       fi
962     fi
963
964     # static link with sdl ?
965     if test "$sdl" = "yes" -a "$static" = "yes" ; then
966       sdl_libs=`sdl-config --static-libs 2>/dev/null`
967       if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
968          sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
969          sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
970       fi
971       if compile_prog "$sdl_cflags" "$sdl_libs" ; then
972         :
973       else
974         sdl=no
975       fi
976     fi # static link
977   else # sdl not found
978     if test "$sdl" = "yes" ; then
979       feature_not_found "sdl"
980     fi
981     sdl=no
982   fi # sdl compile test
983 fi
984
985 if test "$sdl" = "yes" ; then
986   cat > $TMPC <<EOF
987 #include <SDL.h>
988 #if defined(SDL_VIDEO_DRIVER_X11)
989 #include <X11/XKBlib.h>
990 #else
991 #error No x11 support
992 #endif
993 int main(void) { return 0; }
994 EOF
995   if compile_prog "$sdl_cflags" "$sdl_libs" ; then
996     sdl_libs="$sdl_libs -lX11"
997   fi
998   if test "$mingw32" = "yes" ; then
999     sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1000   fi
1001   libs_softmmu="$sdl_libs $libs_softmmu"
1002 fi
1003
1004 ##########################################
1005 # VNC TLS detection
1006 if test "$vnc_tls" != "no" ; then
1007   cat > $TMPC <<EOF
1008 #include <gnutls/gnutls.h>
1009 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1010 EOF
1011   vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
1012   vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
1013   if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1014     vnc_tls=yes
1015     libs_softmmu="$vnc_tls_libs $libs_softmmu"
1016   else
1017     if test "$vnc_tls" = "yes" ; then
1018       feature_not_found "vnc-tls"
1019     fi
1020     vnc_tls=no
1021   fi
1022 fi
1023
1024 ##########################################
1025 # VNC SASL detection
1026 if test "$vnc_sasl" != "no" ; then
1027   cat > $TMPC <<EOF
1028 #include <sasl/sasl.h>
1029 #include <stdio.h>
1030 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1031 EOF
1032   # Assuming Cyrus-SASL installed in /usr prefix
1033   vnc_sasl_cflags=""
1034   vnc_sasl_libs="-lsasl2"
1035   if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1036     vnc_sasl=yes
1037     libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1038   else
1039     if test "$vnc_sasl" = "yes" ; then
1040       feature_not_found "vnc-sasl"
1041     fi
1042     vnc_sasl=no
1043   fi
1044 fi
1045
1046 ##########################################
1047 # fnmatch() probe, used for ACL routines
1048 fnmatch="no"
1049 cat > $TMPC << EOF
1050 #include <fnmatch.h>
1051 int main(void)
1052 {
1053     fnmatch("foo", "foo", 0);
1054     return 0;
1055 }
1056 EOF
1057 if compile_prog "" "" ; then
1058    fnmatch="yes"
1059 fi
1060
1061 ##########################################
1062 # uuid_generate() probe, used for vdi block driver
1063 if test "$uuid" != "no" ; then
1064   uuid_libs="-luuid"
1065   cat > $TMPC << EOF
1066 #include <uuid/uuid.h>
1067 int main(void)
1068 {
1069     uuid_t my_uuid;
1070     uuid_generate(my_uuid);
1071     return 0;
1072 }
1073 EOF
1074   if compile_prog "" "$uuid_libs" ; then
1075     uuid="yes"
1076     libs_softmmu="$uuid_libs $libs_softmmu"
1077     libs_tools="$uuid_libs $libs_tools"
1078   else
1079     if test "$uuid" = "yes" ; then
1080       feature_not_found "uuid"
1081     fi
1082     uuid=no
1083   fi
1084 fi
1085
1086 ##########################################
1087 # vde libraries probe
1088 if test "$vde" != "no" ; then
1089   vde_libs="-lvdeplug"
1090   cat > $TMPC << EOF
1091 #include <libvdeplug.h>
1092 int main(void)
1093 {
1094     struct vde_open_args a = {0, 0, 0};
1095     vde_open("", "", &a);
1096     return 0;
1097 }
1098 EOF
1099   if compile_prog "" "$vde_libs" ; then
1100     vde=yes
1101     libs_softmmu="$vde_libs $libs_softmmu"
1102     libs_tools="$vde_libs $libs_tools"
1103   else
1104     if test "$vde" = "yes" ; then
1105       feature_not_found "vde"
1106     fi
1107     vde=no
1108   fi
1109 fi
1110
1111 ##########################################
1112 # Sound support libraries probe
1113
1114 audio_drv_probe()
1115 {
1116     drv=$1
1117     hdr=$2
1118     lib=$3
1119     exp=$4
1120     cfl=$5
1121         cat > $TMPC << EOF
1122 #include <$hdr>
1123 int main(void) { $exp }
1124 EOF
1125     if compile_prog "$cfl" "$lib" ; then
1126         :
1127     else
1128         echo
1129         echo "Error: $drv check failed"
1130         echo "Make sure to have the $drv libs and headers installed."
1131         echo
1132         exit 1
1133     fi
1134 }
1135
1136 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1137 for drv in $audio_drv_list; do
1138     case $drv in
1139     alsa)
1140     audio_drv_probe $drv alsa/asoundlib.h -lasound \
1141         "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1142     libs_softmmu="-lasound $libs_softmmu"
1143     ;;
1144
1145     fmod)
1146     if test -z $fmod_lib || test -z $fmod_inc; then
1147         echo
1148         echo "Error: You must specify path to FMOD library and headers"
1149         echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1150         echo
1151         exit 1
1152     fi
1153     audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1154     libs_softmmu="$fmod_lib $libs_softmmu"
1155     ;;
1156
1157     esd)
1158     audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1159     libs_softmmu="-lesd $libs_softmmu"
1160     audio_pt_int="yes"
1161     ;;
1162
1163     pa)
1164     audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1165         "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1166     libs_softmmu="-lpulse-simple $libs_softmmu"
1167     audio_pt_int="yes"
1168     ;;
1169
1170     coreaudio)
1171       libs_softmmu="-framework CoreAudio $libs_softmmu"
1172     ;;
1173
1174     dsound)
1175       libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1176       audio_win_int="yes"
1177     ;;
1178
1179     oss)
1180       libs_softmmu="$oss_lib $libs_softmmu"
1181     ;;
1182
1183     sdl|wav)
1184     # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1185     ;;
1186
1187     winwave)
1188       libs_softmmu="-lwinmm $libs_softmmu"
1189       audio_win_int="yes"
1190     ;;
1191
1192     *)
1193     echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1194         echo
1195         echo "Error: Unknown driver '$drv' selected"
1196         echo "Possible drivers are: $audio_possible_drivers"
1197         echo
1198         exit 1
1199     }
1200     ;;
1201     esac
1202 done
1203
1204 ##########################################
1205 # BrlAPI probe
1206
1207 if test "$brlapi" != "no" ; then
1208   brlapi_libs="-lbrlapi"
1209   cat > $TMPC << EOF
1210 #include <brlapi.h>
1211 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1212 EOF
1213   if compile_prog "" "$brlapi_libs" ; then
1214     brlapi=yes
1215     libs_softmmu="$brlapi_libs $libs_softmmu"
1216   else
1217     if test "$brlapi" = "yes" ; then
1218       feature_not_found "brlapi"
1219     fi
1220     brlapi=no
1221   fi
1222 fi
1223
1224 ##########################################
1225 # curses probe
1226 curses_list="-lncurses -lcurses"
1227
1228 if test "$curses" != "no" ; then
1229   curses_found=no
1230   cat > $TMPC << EOF
1231 #include <curses.h>
1232 #ifdef __OpenBSD__
1233 #define resize_term resizeterm
1234 #endif
1235 int main(void) { resize_term(0, 0); return curses_version(); }
1236 EOF
1237   for curses_lib in $curses_list; do
1238     if compile_prog "" "$curses_lib" ; then
1239       curses_found=yes
1240       libs_softmmu="$curses_lib $libs_softmmu"
1241       break
1242     fi
1243   done
1244   if test "$curses_found" = "yes" ; then
1245     curses=yes
1246   else
1247     if test "$curses" = "yes" ; then
1248       feature_not_found "curses"
1249     fi
1250     curses=no
1251   fi
1252 fi
1253
1254 ##########################################
1255 # curl probe
1256
1257 if test "$curl" != "no" ; then
1258   cat > $TMPC << EOF
1259 #include <curl/curl.h>
1260 int main(void) { return curl_easy_init(); }
1261 EOF
1262   curl_cflags=`curl-config --cflags 2>/dev/null`
1263   curl_libs=`curl-config --libs 2>/dev/null`
1264   if compile_prog "$curl_cflags" "$curl_libs" ; then
1265     curl=yes
1266     libs_tools="$curl_libs $libs_tools"
1267     libs_softmmu="$curl_libs $libs_softmmu"
1268   else
1269     if test "$curl" = "yes" ; then
1270       feature_not_found "curl"
1271     fi
1272     curl=no
1273   fi
1274 fi # test "$curl"
1275
1276 ##########################################
1277 # check framework probe
1278
1279 if test "$check_utests" != "no" ; then
1280   cat > $TMPC << EOF
1281 #include <check.h>
1282 int main(void) { suite_create("qemu test"); return 0; }
1283 EOF
1284   check_libs=`pkg-config --libs check`
1285   if compile_prog "" $check_libs ; then
1286     check_utests=yes
1287     libs_tools="$check_libs $libs_tools"
1288   else
1289     if test "$check_utests" = "yes" ; then
1290       feature_not_found "check"
1291     fi
1292     check_utests=no
1293   fi
1294 fi # test "$check_utests"
1295
1296 ##########################################
1297 # bluez support probe
1298 if test "$bluez" != "no" ; then
1299   cat > $TMPC << EOF
1300 #include <bluetooth/bluetooth.h>
1301 int main(void) { return bt_error(0); }
1302 EOF
1303   bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1304   bluez_libs=`pkg-config --libs bluez 2> /dev/null`
1305   if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1306     bluez=yes
1307     libs_softmmu="$bluez_libs $libs_softmmu"
1308   else
1309     if test "$bluez" = "yes" ; then
1310       feature_not_found "bluez"
1311     fi
1312     bluez="no"
1313   fi
1314 fi
1315
1316 ##########################################
1317 # kvm probe
1318 if test "$kvm" != "no" ; then
1319     cat > $TMPC <<EOF
1320 #include <linux/kvm.h>
1321 #if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1322 #error Invalid KVM version
1323 #endif
1324 #if !defined(KVM_CAP_USER_MEMORY)
1325 #error Missing KVM capability KVM_CAP_USER_MEMORY
1326 #endif
1327 #if !defined(KVM_CAP_SET_TSS_ADDR)
1328 #error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1329 #endif
1330 #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1331 #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1332 #endif
1333 int main(void) { return 0; }
1334 EOF
1335   if test "$kerneldir" != "" ; then
1336       kvm_cflags=-I"$kerneldir"/include
1337       if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1338          -a -d "$kerneldir/arch/x86/include" ; then
1339             kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1340         elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1341             kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1342         elif test -d "$kerneldir/arch/$cpu/include" ; then
1343             kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1344       fi
1345   else
1346       kvm_cflags=""
1347   fi
1348   if compile_prog "$kvm_cflags" "" ; then
1349     kvm=yes
1350   else
1351     if test "$kvm" = "yes" ; then
1352       if [ -x "`which awk 2>/dev/null`" ] && \
1353          [ -x "`which grep 2>/dev/null`" ]; then
1354         kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1355         | grep "error: " \
1356         | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1357         if test "$kvmerr" != "" ; then
1358           echo -e "${kvmerr}\n\
1359       NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1360   recent kvm-kmod from http://sourceforge.net/projects/kvm."
1361         fi
1362       fi
1363       feature_not_found "kvm"
1364     fi
1365     kvm=no
1366   fi
1367 fi
1368
1369 ##########################################
1370 # pthread probe
1371 PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1372
1373 pthread=no
1374 cat > $TMPC << EOF
1375 #include <pthread.h>
1376 int main(void) { pthread_create(0,0,0,0); return 0; }
1377 EOF
1378 for pthread_lib in $PTHREADLIBS_LIST; do
1379   if compile_prog "" "$pthread_lib" ; then
1380     pthread=yes
1381     LIBS="$pthread_lib $LIBS"
1382     break
1383   fi
1384 done
1385
1386 if test "$mingw32" != yes -a "$pthread" = no; then
1387   echo
1388   echo "Error: pthread check failed"
1389   echo "Make sure to have the pthread libs and headers installed."
1390   echo
1391   exit 1
1392 fi
1393
1394 ##########################################
1395 # linux-aio probe
1396
1397 if test "$linux_aio" != "no" ; then
1398   cat > $TMPC <<EOF
1399 #include <libaio.h>
1400 #include <sys/eventfd.h>
1401 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1402 EOF
1403   if compile_prog "" "-laio" ; then
1404     linux_aio=yes
1405     LIBS="$LIBS -laio"
1406   else
1407     if test "$linux_aio" = "yes" ; then
1408       feature_not_found "linux AIO"
1409     fi
1410     linux_aio=no
1411   fi
1412 fi
1413
1414 ##########################################
1415 # iovec probe
1416 cat > $TMPC <<EOF
1417 #include <sys/types.h>
1418 #include <sys/uio.h>
1419 #include <unistd.h>
1420 int main(void) { struct iovec iov; return 0; }
1421 EOF
1422 iovec=no
1423 if compile_prog "" "" ; then
1424   iovec=yes
1425 fi
1426
1427 ##########################################
1428 # preadv probe
1429 cat > $TMPC <<EOF
1430 #include <sys/types.h>
1431 #include <sys/uio.h>
1432 #include <unistd.h>
1433 int main(void) { preadv; }
1434 EOF
1435 preadv=no
1436 if compile_prog "" "" ; then
1437   preadv=yes
1438 fi
1439
1440 ##########################################
1441 # fdt probe
1442 if test "$fdt" != "no" ; then
1443   fdt_libs="-lfdt"
1444   cat > $TMPC << EOF
1445 int main(void) { return 0; }
1446 EOF
1447   if compile_prog "" "$fdt_libs" ; then
1448     fdt=yes
1449     libs_softmmu="$fdt_libs $libs_softmmu"
1450   else
1451     if test "$fdt" = "yes" ; then
1452       feature_not_found "fdt"
1453     fi
1454     fdt=no
1455   fi
1456 fi
1457
1458 #
1459 # Check for xxxat() functions when we are building linux-user
1460 # emulator.  This is done because older glibc versions don't
1461 # have syscall stubs for these implemented.
1462 #
1463 atfile=no
1464 cat > $TMPC << EOF
1465 #define _ATFILE_SOURCE
1466 #include <sys/types.h>
1467 #include <fcntl.h>
1468 #include <unistd.h>
1469
1470 int
1471 main(void)
1472 {
1473         /* try to unlink nonexisting file */
1474         return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1475 }
1476 EOF
1477 if compile_prog "" "" ; then
1478   atfile=yes
1479 fi
1480
1481 # Check for inotify functions when we are building linux-user
1482 # emulator.  This is done because older glibc versions don't
1483 # have syscall stubs for these implemented.  In that case we
1484 # don't provide them even if kernel supports them.
1485 #
1486 inotify=no
1487 cat > $TMPC << EOF
1488 #include <sys/inotify.h>
1489
1490 int
1491 main(void)
1492 {
1493         /* try to start inotify */
1494         return inotify_init();
1495 }
1496 EOF
1497 if compile_prog "" "" ; then
1498   inotify=yes
1499 fi
1500
1501 # check if utimensat and futimens are supported
1502 utimens=no
1503 cat > $TMPC << EOF
1504 #define _ATFILE_SOURCE
1505 #define _GNU_SOURCE
1506 #include <stddef.h>
1507 #include <fcntl.h>
1508
1509 int main(void)
1510 {
1511     utimensat(AT_FDCWD, "foo", NULL, 0);
1512     futimens(0, NULL);
1513     return 0;
1514 }
1515 EOF
1516 if compile_prog "" "" ; then
1517   utimens=yes
1518 fi
1519
1520 # check if pipe2 is there
1521 pipe2=no
1522 cat > $TMPC << EOF
1523 #define _GNU_SOURCE
1524 #include <unistd.h>
1525 #include <fcntl.h>
1526
1527 int main(void)
1528 {
1529     int pipefd[2];
1530     pipe2(pipefd, O_CLOEXEC);
1531     return 0;
1532 }
1533 EOF
1534 if compile_prog "" "" ; then
1535   pipe2=yes
1536 fi
1537
1538 # check if tee/splice is there. vmsplice was added same time.
1539 splice=no
1540 cat > $TMPC << EOF
1541 #define _GNU_SOURCE
1542 #include <unistd.h>
1543 #include <fcntl.h>
1544 #include <limits.h>
1545
1546 int main(void)
1547 {
1548     int len, fd;
1549     len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1550     splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1551     return 0;
1552 }
1553 EOF
1554 if compile_prog "" "" ; then
1555   splice=yes
1556 fi
1557
1558 # check if eventfd is supported
1559 eventfd=no
1560 cat > $TMPC << EOF
1561 #include <sys/eventfd.h>
1562
1563 int main(void)
1564 {
1565     int efd = eventfd(0, 0);
1566     return 0;
1567 }
1568 EOF
1569 if compile_prog "" "" ; then
1570   eventfd=yes
1571 fi
1572
1573 # Check if tools are available to build documentation.
1574 if test "$docs" != "no" ; then
1575   if test -x "`which texi2html 2>/dev/null`" -a \
1576           -x "`which pod2man 2>/dev/null`" ; then
1577     docs=yes
1578   else
1579     if test "$docs" = "yes" ; then
1580       feature_not_found "docs"
1581     fi
1582     docs=no
1583   fi
1584 fi
1585
1586 # Search for bsawp_32 function
1587 byteswap_h=no
1588 cat > $TMPC << EOF
1589 #include <byteswap.h>
1590 int main(void) { return bswap_32(0); }
1591 EOF
1592 if compile_prog "" "" ; then
1593   byteswap_h=yes
1594 fi
1595
1596 # Search for bsawp_32 function
1597 bswap_h=no
1598 cat > $TMPC << EOF
1599 #include <sys/endian.h>
1600 #include <sys/types.h>
1601 #include <machine/bswap.h>
1602 int main(void) { return bswap32(0); }
1603 EOF
1604 if compile_prog "" "" ; then
1605   bswap_h=yes
1606 fi
1607
1608 ##########################################
1609 # Do we need librt
1610 cat > $TMPC <<EOF
1611 #include <signal.h>
1612 #include <time.h>
1613 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1614 EOF
1615
1616 if compile_prog "" "" ; then
1617   :
1618 elif compile_prog "" "-lrt" ; then
1619   LIBS="-lrt $LIBS"
1620 fi
1621
1622 # Determine what linker flags to use to force archive inclusion
1623 check_linker_flags()
1624 {
1625     w2=
1626     if test "$2" ; then
1627         w2=-Wl,$2
1628     fi
1629     compile_prog "" "-Wl,$1 ${w2}"
1630 }
1631
1632 cat > $TMPC << EOF
1633 int main(void) { }
1634 EOF
1635 if check_linker_flags --whole-archive --no-whole-archive ; then
1636     # GNU ld
1637     arlibs_begin="-Wl,--whole-archive"
1638     arlibs_end="-Wl,--no-whole-archive"
1639 elif check_linker_flags -z,allextract -z,defaultextract ; then
1640     # Solaris ld
1641     arlibs_begin="-Wl,-z,allextract"
1642     arlibs_end="-Wl,-z,defaultextract"
1643 elif check_linker_flags -all_load ; then
1644     # Mac OS X
1645     arlibs_begin="-all_load"
1646     arlibs_end=""
1647 else
1648     echo "Error: your linker does not support --whole-archive or -z."
1649     echo "Please report to [email protected]"
1650     exit 1
1651 fi
1652
1653 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
1654         "$aix" != "yes" ; then
1655     libs_softmmu="-lutil $libs_softmmu"
1656 fi
1657
1658 ##########################################
1659 # check if the compiler defines offsetof
1660
1661 need_offsetof=yes
1662 cat > $TMPC << EOF
1663 #include <stddef.h>
1664 int main(void) { struct s { int f; }; return offsetof(struct s, f); }
1665 EOF
1666 if compile_prog "" "" ; then
1667     need_offsetof=no
1668 fi
1669
1670 ##########################################
1671 # check if we have fdatasync
1672
1673 fdatasync=no
1674 cat > $TMPC << EOF
1675 #include <unistd.h>
1676 int main(void) { return fdatasync(0); }
1677 EOF
1678 if compile_prog "" "" ; then
1679     fdatasync=yes
1680 fi
1681
1682 # End of CC checks
1683 # After here, no more $cc or $ld runs
1684
1685 # default flags for all hosts
1686 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
1687 CFLAGS="-g $CFLAGS"
1688 if test "$debug" = "no" ; then
1689   CFLAGS="-O2 $CFLAGS"
1690 fi
1691 QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
1692 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
1693 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
1694 QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS"
1695 QEMU_CFLAGS="-I. -I\$(SRC_PATH) -MMD -MP -MT \$@ $QEMU_CFLAGS"
1696 LDFLAGS="-g $LDFLAGS"
1697
1698 gcc_flags="-Wold-style-declaration -Wold-style-definition"
1699 cat > $TMPC << EOF
1700 int main(void) { }
1701 EOF
1702 for flag in $gcc_flags; do
1703     if compile_prog "$QEMU_CFLAGS" "$flag" ; then
1704         QEMU_CFLAGS="$flag $QEMU_CFLAGS"
1705     fi
1706 done
1707
1708 # Consult white-list to determine whether to enable werror
1709 # by default.  Only enable by default for git builds
1710 if test -z "$werror" ; then
1711     z_version=`cut -f3 -d. $source_path/VERSION`
1712     if test "$z_version" = "50" -a \
1713         "$linux" = "yes" ; then
1714         werror="yes"
1715     else
1716         werror="no"
1717     fi
1718 fi
1719
1720 if test "$werror" = "yes" ; then
1721     QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
1722 fi
1723
1724 if test "$solaris" = "no" ; then
1725     if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1726         LDFLAGS="-Wl,--warn-common $LDFLAGS"
1727     fi
1728 fi
1729
1730 if test "$mingw32" = "yes" ; then
1731   if test -z "$prefix" ; then
1732       prefix="c:/Program Files/Qemu"
1733   fi
1734   mansuffix=""
1735   datasuffix=""
1736   docsuffix=""
1737   binsuffix=""
1738 else
1739   if test -z "$prefix" ; then
1740       prefix="/usr/local"
1741   fi
1742   mansuffix="/share/man"
1743   datasuffix="/share/qemu"
1744   docsuffix="/share/doc/qemu"
1745   binsuffix="/bin"
1746 fi
1747
1748 echo "Install prefix    $prefix"
1749 echo "BIOS directory    $prefix$datasuffix"
1750 echo "binary directory  $prefix$binsuffix"
1751 if test "$mingw32" = "no" ; then
1752 echo "Manual directory  $prefix$mansuffix"
1753 echo "ELF interp prefix $interp_prefix"
1754 fi
1755 echo "Source path       $source_path"
1756 echo "C compiler        $cc"
1757 echo "Host C compiler   $host_cc"
1758 echo "CFLAGS            $CFLAGS"
1759 echo "QEMU_CFLAGS       $QEMU_CFLAGS"
1760 echo "LDFLAGS           $LDFLAGS"
1761 echo "make              $make"
1762 echo "install           $install"
1763 echo "host CPU          $cpu"
1764 echo "host big endian   $bigendian"
1765 echo "target list       $target_list"
1766 echo "tcg debug enabled $debug_tcg"
1767 echo "gprof enabled     $gprof"
1768 echo "sparse enabled    $sparse"
1769 echo "strip binaries    $strip_opt"
1770 echo "profiler          $profiler"
1771 echo "static build      $static"
1772 echo "-Werror enabled   $werror"
1773 if test "$darwin" = "yes" ; then
1774     echo "Cocoa support     $cocoa"
1775 fi
1776 echo "SDL support       $sdl"
1777 echo "curses support    $curses"
1778 echo "curl support      $curl"
1779 echo "check support     $check_utests"
1780 echo "mingw32 support   $mingw32"
1781 echo "Audio drivers     $audio_drv_list"
1782 echo "Extra audio cards $audio_card_list"
1783 echo "Mixer emulation   $mixemu"
1784 echo "VNC TLS support   $vnc_tls"
1785 echo "VNC SASL support  $vnc_sasl"
1786 if test -n "$sparc_cpu"; then
1787     echo "Target Sparc Arch $sparc_cpu"
1788 fi
1789 echo "xen support       $xen"
1790 echo "brlapi support    $brlapi"
1791 echo "bluez  support    $bluez"
1792 echo "Documentation     $docs"
1793 [ ! -z "$uname_release" ] && \
1794 echo "uname -r          $uname_release"
1795 echo "NPTL support      $nptl"
1796 echo "GUEST_BASE        $guest_base"
1797 echo "PIE user targets  $user_pie"
1798 echo "vde support       $vde"
1799 echo "IO thread         $io_thread"
1800 echo "Linux AIO support $linux_aio"
1801 echo "Install blobs     $blobs"
1802 echo "KVM support       $kvm"
1803 echo "fdt support       $fdt"
1804 echo "preadv support    $preadv"
1805 echo "fdatasync         $fdatasync"
1806 echo "uuid support      $uuid"
1807
1808 if test $sdl_too_old = "yes"; then
1809 echo "-> Your SDL version is too old - please upgrade to have SDL support"
1810 fi
1811
1812 config_host_mak="config-host.mak"
1813 config_host_ld="config-host.ld"
1814
1815 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1816 printf "# Configured with:" >> $config_host_mak
1817 printf " '%s'" "$0" "$@" >> $config_host_mak
1818 echo >> $config_host_mak
1819
1820 echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1821
1822 case "$cpu" in
1823   i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
1824     ARCH=$cpu
1825   ;;
1826   armv4b|armv4l)
1827     ARCH=arm
1828   ;;
1829   *)
1830     echo "Unsupported CPU = $cpu"
1831     exit 1
1832   ;;
1833 esac
1834 echo "ARCH=$ARCH" >> $config_host_mak
1835 if test "$debug_tcg" = "yes" ; then
1836   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1837 fi
1838 if test "$debug" = "yes" ; then
1839   echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1840 fi
1841 if test "$strip_opt" = "yes" ; then
1842   echo "STRIP_OPT=-s" >> $config_host_mak
1843 fi
1844 if test "$bigendian" = "yes" ; then
1845   echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
1846 fi
1847 echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
1848 if test "$mingw32" = "yes" ; then
1849   echo "CONFIG_WIN32=y" >> $config_host_mak
1850 else
1851   echo "CONFIG_POSIX=y" >> $config_host_mak
1852 fi
1853
1854 if test "$darwin" = "yes" ; then
1855   echo "CONFIG_DARWIN=y" >> $config_host_mak
1856 fi
1857
1858 if test "$aix" = "yes" ; then
1859   echo "CONFIG_AIX=y" >> $config_host_mak
1860 fi
1861
1862 if test "$solaris" = "yes" ; then
1863   echo "CONFIG_SOLARIS=y" >> $config_host_mak
1864   echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
1865   if test "$needs_libsunmath" = "yes" ; then
1866     echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
1867   fi
1868 fi
1869 if test "$static" = "yes" ; then
1870   echo "CONFIG_STATIC=y" >> $config_host_mak
1871   LDFLAGS="-static $LDFLAGS"
1872 fi
1873 if test $profiler = "yes" ; then
1874   echo "CONFIG_PROFILER=y" >> $config_host_mak
1875 fi
1876 if test "$slirp" = "yes" ; then
1877   echo "CONFIG_SLIRP=y" >> $config_host_mak
1878   QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
1879 fi
1880 if test "$vde" = "yes" ; then
1881   echo "CONFIG_VDE=y" >> $config_host_mak
1882 fi
1883 for card in $audio_card_list; do
1884     def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1885     echo "$def=y" >> $config_host_mak
1886 done
1887 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
1888 for drv in $audio_drv_list; do
1889     def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1890     echo "$def=y" >> $config_host_mak
1891     if test "$drv" = "fmod"; then
1892         echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1893     fi
1894 done
1895 if test "$audio_pt_int" = "yes" ; then
1896   echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
1897 fi
1898 if test "$audio_win_int" = "yes" ; then
1899   echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
1900 fi
1901 if test "$mixemu" = "yes" ; then
1902   echo "CONFIG_MIXEMU=y" >> $config_host_mak
1903 fi
1904 if test "$vnc_tls" = "yes" ; then
1905   echo "CONFIG_VNC_TLS=y" >> $config_host_mak
1906   echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
1907 fi
1908 if test "$vnc_sasl" = "yes" ; then
1909   echo "CONFIG_VNC_SASL=y" >> $config_host_mak
1910   echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
1911 fi
1912 if test "$fnmatch" = "yes" ; then
1913   echo "CONFIG_FNMATCH=y" >> $config_host_mak
1914 fi
1915 if test "$uuid" = "yes" ; then
1916   echo "CONFIG_UUID=y" >> $config_host_mak
1917 fi
1918 qemu_version=`head $source_path/VERSION`
1919 echo "VERSION=$qemu_version" >>$config_host_mak
1920 echo "PKGVERSION=$pkgversion" >>$config_host_mak
1921 echo "SRC_PATH=$source_path" >> $config_host_mak
1922 if [ "$source_path_used" = "yes" ]; then
1923   echo "VPATH=$source_path" >> $config_host_mak
1924 fi
1925 echo "TARGET_DIRS=$target_list" >> $config_host_mak
1926 if [ "$docs" = "yes" ] ; then
1927   echo "BUILD_DOCS=yes" >> $config_host_mak
1928 fi
1929 if test "$sdl" = "yes" ; then
1930   echo "CONFIG_SDL=y" >> $config_host_mak
1931   echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
1932 fi
1933 if test "$cocoa" = "yes" ; then
1934   echo "CONFIG_COCOA=y" >> $config_host_mak
1935 fi
1936 if test "$curses" = "yes" ; then
1937   echo "CONFIG_CURSES=y" >> $config_host_mak
1938 fi
1939 if test "$atfile" = "yes" ; then
1940   echo "CONFIG_ATFILE=y" >> $config_host_mak
1941 fi
1942 if test "$utimens" = "yes" ; then
1943   echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
1944 fi
1945 if test "$pipe2" = "yes" ; then
1946   echo "CONFIG_PIPE2=y" >> $config_host_mak
1947 fi
1948 if test "$splice" = "yes" ; then
1949   echo "CONFIG_SPLICE=y" >> $config_host_mak
1950 fi
1951 if test "$eventfd" = "yes" ; then
1952   echo "CONFIG_EVENTFD=y" >> $config_host_mak
1953 fi
1954 if test "$inotify" = "yes" ; then
1955   echo "CONFIG_INOTIFY=y" >> $config_host_mak
1956 fi
1957 if test "$byteswap_h" = "yes" ; then
1958   echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
1959 fi
1960 if test "$bswap_h" = "yes" ; then
1961   echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
1962 fi
1963 if test "$curl" = "yes" ; then
1964   echo "CONFIG_CURL=y" >> $config_host_mak
1965   echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
1966 fi
1967 if test "$brlapi" = "yes" ; then
1968   echo "CONFIG_BRLAPI=y" >> $config_host_mak
1969 fi
1970 if test "$bluez" = "yes" ; then
1971   echo "CONFIG_BLUEZ=y" >> $config_host_mak
1972   echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
1973 fi
1974 if test "$xen" = "yes" ; then
1975   echo "CONFIG_XEN=y" >> $config_host_mak
1976 fi
1977 if test "$io_thread" = "yes" ; then
1978   echo "CONFIG_IOTHREAD=y" >> $config_host_mak
1979 fi
1980 if test "$linux_aio" = "yes" ; then
1981   echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
1982 fi
1983 if test "$blobs" = "yes" ; then
1984   echo "INSTALL_BLOBS=yes" >> $config_host_mak
1985 fi
1986 if test "$iovec" = "yes" ; then
1987   echo "CONFIG_IOVEC=y" >> $config_host_mak
1988 fi
1989 if test "$preadv" = "yes" ; then
1990   echo "CONFIG_PREADV=y" >> $config_host_mak
1991 fi
1992 if test "$fdt" = "yes" ; then
1993   echo "CONFIG_FDT=y" >> $config_host_mak
1994 fi
1995 if test "$need_offsetof" = "yes" ; then
1996   echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
1997 fi
1998 if test "$fdatasync" = "yes" ; then
1999   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
2000 fi
2001
2002 # XXX: suppress that
2003 if [ "$bsd" = "yes" ] ; then
2004   echo "CONFIG_BSD=y" >> $config_host_mak
2005 fi
2006
2007 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2008
2009 # USB host support
2010 case "$usb" in
2011 linux)
2012   echo "HOST_USB=linux" >> $config_host_mak
2013 ;;
2014 bsd)
2015   echo "HOST_USB=bsd" >> $config_host_mak
2016 ;;
2017 *)
2018   echo "HOST_USB=stub" >> $config_host_mak
2019 ;;
2020 esac
2021
2022 tools=
2023 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2024   tools="qemu-img\$(EXESUF) $tools"
2025   if [ "$linux" = "yes" ] ; then
2026       tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
2027     if [ "$check_utests" = "yes" ]; then
2028       tools="check-qint check-qstring check-qdict check-qlist $tools"
2029     fi
2030   elif test "$mingw32" = "yes" ; then
2031       tools="qemu-io\$(EXESUF) $tools"
2032   fi
2033 fi
2034 echo "TOOLS=$tools" >> $config_host_mak
2035
2036 # Mac OS X ships with a broken assembler
2037 roms=
2038 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2039         "$targetos" != "Darwin" -a \
2040         `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2041   roms="optionrom"
2042 fi
2043 echo "ROMS=$roms" >> $config_host_mak
2044
2045 echo "prefix=$prefix" >> $config_host_mak
2046 echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
2047 echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
2048 echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
2049 echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
2050 echo "MAKE=$make" >> $config_host_mak
2051 echo "INSTALL=$install" >> $config_host_mak
2052 echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2053 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2054 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2055 echo "CC=$cc" >> $config_host_mak
2056 echo "HOST_CC=$host_cc" >> $config_host_mak
2057 if test "$sparse" = "yes" ; then
2058   echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2059   echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2060   echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2061 fi
2062 echo "AR=$ar" >> $config_host_mak
2063 echo "OBJCOPY=$objcopy" >> $config_host_mak
2064 echo "LD=$ld" >> $config_host_mak
2065 echo "CFLAGS=$CFLAGS" >> $config_host_mak
2066 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2067 echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2068 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
2069 echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2070 echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
2071 echo "LIBS+=$LIBS" >> $config_host_mak
2072 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2073 echo "EXESUF=$EXESUF" >> $config_host_mak
2074
2075 # generate list of library paths for linker script
2076
2077 $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
2078
2079 if test -f ${config_host_ld}~ ; then
2080   if cmp -s $config_host_ld ${config_host_ld}~ ; then
2081     mv ${config_host_ld}~ $config_host_ld
2082   else
2083     rm ${config_host_ld}~
2084   fi
2085 fi
2086
2087 for target in $target_list; do
2088 target_dir="$target"
2089 config_target_mak=$target_dir/config-target.mak
2090 target_arch2=`echo $target | cut -d '-' -f 1`
2091 target_bigendian="no"
2092
2093 case "$target_arch2" in
2094   armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
2095   target_bigendian=yes
2096   ;;
2097 esac
2098 target_softmmu="no"
2099 target_user_only="no"
2100 target_linux_user="no"
2101 target_darwin_user="no"
2102 target_bsd_user="no"
2103 case "$target" in
2104   ${target_arch2}-softmmu)
2105     target_softmmu="yes"
2106     ;;
2107   ${target_arch2}-linux-user)
2108     target_user_only="yes"
2109     target_linux_user="yes"
2110     ;;
2111   ${target_arch2}-darwin-user)
2112     target_user_only="yes"
2113     target_darwin_user="yes"
2114     ;;
2115   ${target_arch2}-bsd-user)
2116     target_user_only="yes"
2117     target_bsd_user="yes"
2118     ;;
2119   *)
2120     echo "ERROR: Target '$target' not recognised"
2121     exit 1
2122     ;;
2123 esac
2124
2125 mkdir -p $target_dir
2126 mkdir -p $target_dir/fpu
2127 mkdir -p $target_dir/tcg
2128 mkdir -p $target_dir/ide
2129 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
2130   mkdir -p $target_dir/nwfpe
2131 fi
2132
2133 if test ! -f $target_dir/config-devices.mak ; then
2134   cp $source_path/default-configs/${target}.mak $target_dir/config-devices.mak
2135 fi
2136
2137 #
2138 # don't use ln -sf as not all "ln -sf" over write the file/link
2139 #
2140 rm -f $target_dir/Makefile
2141 ln -s $source_path/Makefile.target $target_dir/Makefile
2142
2143
2144 echo "# Automatically generated by configure - do not modify" > $config_target_mak
2145
2146 bflt="no"
2147 elfload32="no"
2148 target_nptl="no"
2149 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
2150 echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
2151 gdb_xml_files=""
2152
2153 TARGET_ARCH="$target_arch2"
2154 TARGET_BASE_ARCH=""
2155 TARGET_ABI_DIR=""
2156
2157 case "$target_arch2" in
2158   i386)
2159     target_phys_bits=32
2160   ;;
2161   x86_64)
2162     TARGET_BASE_ARCH=i386
2163     target_phys_bits=64
2164   ;;
2165   alpha)
2166     target_phys_bits=64
2167   ;;
2168   arm|armeb)
2169     TARGET_ARCH=arm
2170     bflt="yes"
2171     target_nptl="yes"
2172     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2173     target_phys_bits=32
2174   ;;
2175   cris)
2176     target_nptl="yes"
2177     target_phys_bits=32
2178   ;;
2179   m68k)
2180     bflt="yes"
2181     gdb_xml_files="cf-core.xml cf-fp.xml"
2182     target_phys_bits=32
2183   ;;
2184   microblaze)
2185     bflt="yes"
2186     target_nptl="yes"
2187     target_phys_bits=32
2188   ;;
2189   mips|mipsel)
2190     TARGET_ARCH=mips
2191     echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2192     target_nptl="yes"
2193     target_phys_bits=64
2194   ;;
2195   mipsn32|mipsn32el)
2196     TARGET_ARCH=mipsn32
2197     TARGET_BASE_ARCH=mips
2198     echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
2199     target_phys_bits=64
2200   ;;
2201   mips64|mips64el)
2202     TARGET_ARCH=mips64
2203     TARGET_BASE_ARCH=mips
2204     echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2205     target_phys_bits=64
2206   ;;
2207   ppc)
2208     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2209     target_phys_bits=32
2210     target_nptl="yes"
2211   ;;
2212   ppcemb)
2213     TARGET_BASE_ARCH=ppc
2214     TARGET_ABI_DIR=ppc
2215     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2216     target_phys_bits=64
2217     target_nptl="yes"
2218   ;;
2219   ppc64)
2220     TARGET_BASE_ARCH=ppc
2221     TARGET_ABI_DIR=ppc
2222     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2223     target_phys_bits=64
2224   ;;
2225   ppc64abi32)
2226     TARGET_ARCH=ppc64
2227     TARGET_BASE_ARCH=ppc
2228     TARGET_ABI_DIR=ppc
2229     echo "TARGET_ABI32=y" >> $config_target_mak
2230     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2231     target_phys_bits=64
2232   ;;
2233   sh4|sh4eb)
2234     TARGET_ARCH=sh4
2235     bflt="yes"
2236     target_nptl="yes"
2237     target_phys_bits=32
2238   ;;
2239   sparc)
2240     target_phys_bits=64
2241   ;;
2242   sparc64)
2243     TARGET_BASE_ARCH=sparc
2244     elfload32="yes"
2245     target_phys_bits=64
2246   ;;
2247   sparc32plus)
2248     TARGET_ARCH=sparc64
2249     TARGET_BASE_ARCH=sparc
2250     TARGET_ABI_DIR=sparc
2251     echo "TARGET_ABI32=y" >> $config_target_mak
2252     target_phys_bits=64
2253   ;;
2254   *)
2255     echo "Unsupported target CPU"
2256     exit 1
2257   ;;
2258 esac
2259 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2260 target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
2261 echo "TARGET_$target_arch_name=y" >> $config_target_mak
2262 echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
2263 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
2264 if [ "$TARGET_BASE_ARCH" = "" ]; then
2265   TARGET_BASE_ARCH=$TARGET_ARCH
2266 fi
2267 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2268 if [ "$TARGET_ABI_DIR" = "" ]; then
2269   TARGET_ABI_DIR=$TARGET_ARCH
2270 fi
2271 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
2272 if [ $target_phys_bits -lt $hostlongbits ] ; then
2273   target_phys_bits=$hostlongbits
2274 fi
2275 case "$target_arch2" in
2276   i386|x86_64)
2277     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2278       echo "CONFIG_XEN=y" >> $config_target_mak
2279     fi
2280 esac
2281 case "$target_arch2" in
2282   i386|x86_64|ppcemb|ppc|ppc64)
2283     # Make sure the target and host cpus are compatible
2284     if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2285       \( "$target_arch2" = "$cpu" -o \
2286       \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2287       \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2288       \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2289       \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
2290       echo "CONFIG_KVM=y" >> $config_target_mak
2291       echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2292     fi
2293 esac
2294 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
2295 if test "$target_bigendian" = "yes" ; then
2296   echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
2297 fi
2298 if test "$target_softmmu" = "yes" ; then
2299   echo "CONFIG_SOFTMMU=y" >> $config_target_mak
2300   echo "LIBS+=$libs_softmmu" >> $config_target_mak
2301   echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_target_mak
2302   echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2303 fi
2304 if test "$target_user_only" = "yes" ; then
2305   echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2306 fi
2307 if test "$target_linux_user" = "yes" ; then
2308   echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2309 fi
2310 if test "$target_darwin_user" = "yes" ; then
2311   echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2312 fi
2313 list=""
2314 if test ! -z "$gdb_xml_files" ; then
2315   for x in $gdb_xml_files; do
2316     list="$list $source_path/gdb-xml/$x"
2317   done
2318   echo "TARGET_XML_FILES=$list" >> $config_target_mak
2319 fi
2320
2321 case "$target_arch2" in
2322   arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
2323     echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2324     ;;
2325   *)
2326     echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2327     ;;
2328 esac
2329
2330 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2331   echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2332 fi
2333 if test "$target_user_only" = "yes" \
2334         -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2335   echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2336 fi
2337 # 32 bit ELF loader in addition to native 64 bit loader?
2338 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2339   echo "TARGET_HAS_ELFLOAD32=y" >> $config_target_mak
2340 fi
2341 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2342   echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2343 fi
2344 if test "$target_bsd_user" = "yes" ; then
2345   echo "CONFIG_BSD_USER=y" >> $config_target_mak
2346 fi
2347
2348 # generate QEMU_CFLAGS/LDFLAGS for targets
2349
2350 cflags=""
2351 ldflags=""
2352
2353 if test "$ARCH" = "sparc64" ; then
2354   cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
2355 else
2356   cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
2357 fi
2358 cflags="-I\$(SRC_PATH)/tcg $cflags"
2359 cflags="-I\$(SRC_PATH)/fpu $cflags"
2360
2361 for i in $ARCH $TARGET_BASE_ARCH ; do
2362   case "$i" in
2363   alpha)
2364     echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
2365   ;;
2366   arm)
2367     echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
2368   ;;
2369   cris)
2370     echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
2371   ;;
2372   hppa)
2373     echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
2374   ;;
2375   i386|x86_64)
2376     echo "CONFIG_I386_DIS=y"  >> $config_target_mak
2377   ;;
2378   m68k)
2379     echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
2380   ;;
2381   microblaze)
2382     echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
2383   ;;
2384   mips*)
2385     echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
2386   ;;
2387   ppc*)
2388     echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
2389   ;;
2390   s390)
2391     echo "CONFIG_S390_DIS=y"  >> $config_target_mak
2392   ;;
2393   sh4)
2394     echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
2395   ;;
2396   sparc*)
2397     echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
2398   ;;
2399   esac
2400 done
2401
2402 case "$ARCH" in
2403 alpha)
2404   # Ensure there's only a single GP
2405   cflags="-msmall-data $cflags"
2406 ;;
2407 ia64)
2408   cflags="-mno-sdata $cflags"
2409 ;;
2410 esac
2411
2412 if test "$target_softmmu" = "yes" ; then
2413   case "$TARGET_BASE_ARCH" in
2414   arm)
2415     cflags="-DHAS_AUDIO $cflags"
2416   ;;
2417   i386|mips|ppc)
2418     cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
2419   ;;
2420   esac
2421 fi
2422
2423 if test "$target_user_only" = "yes" -a "$static" = "no" -a \
2424         "$user_pie" = "yes" ; then
2425   cflags="-fpie $cflags"
2426   ldflags="-pie $ldflags"
2427 fi
2428
2429 if test "$target_softmmu" = "yes" -a \( \
2430         "$TARGET_ARCH" = "microblaze" -o \
2431         "$TARGET_ARCH" = "cris" \) ; then
2432   echo "CONFIG_NEED_MMU=y" >> $config_target_mak
2433 fi
2434
2435 if test "$gprof" = "yes" ; then
2436   echo "TARGET_GPROF=yes" >> $config_target_mak
2437   if test "$target_linux_user" = "yes" ; then
2438     cflags="-p $cflags"
2439     ldflags="-p $ldflags"
2440   fi
2441   if test "$target_softmmu" = "yes" ; then
2442     ldflags="-p $ldflags"
2443     echo "GPROF_CFLAGS=-p" >> $config_target_mak
2444   fi
2445 fi
2446
2447 linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
2448 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2449   case "$ARCH" in
2450   sparc)
2451     # -static is used to avoid g1/g3 usage by the dynamic linker
2452     ldflags="$linker_script -static $ldflags"
2453     ;;
2454   ia64)
2455     ldflags="-Wl,-G0 $linker_script -static $ldflags"
2456     ;;
2457   i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2458     ldflags="$linker_script $ldflags"
2459     ;;
2460   esac
2461 fi
2462 if test "$target_softmmu" = "yes" ; then
2463   case "$ARCH" in
2464   ia64)
2465     ldflags="-Wl,-G0 $linker_script -static $ldflags"
2466     ;;
2467   esac
2468 fi
2469
2470 echo "LDFLAGS+=$ldflags" >> $config_target_mak
2471 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
2472
2473 done # for target in $targets
2474
2475 # build tree in object directory if source path is different from current one
2476 if test "$source_path_used" = "yes" ; then
2477     DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
2478     DIRS="$DIRS roms/pcbios roms/seabios roms/vgabios"
2479     FILES="Makefile tests/Makefile"
2480     FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2481     FILES="$FILES tests/test-mmap.c"
2482     FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2483     FILES="$FILES roms/pcbios/Makefile roms/seabios/Makefile roms/vgabios/Makefile"
2484     for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2485         FILES="$FILES pc-bios/`basename $bios_file`"
2486     done
2487     for dir in $DIRS ; do
2488             mkdir -p $dir
2489     done
2490     # remove the link and recreate it, as not all "ln -sf" overwrite the link
2491     for f in $FILES ; do
2492         rm -f $f
2493         ln -s $source_path/$f $f
2494     done
2495 fi
2496
2497 # temporary config to build submodules
2498 for rom in seabios vgabios pcbios; do
2499     config_mak=roms/$rom/config.mak
2500     echo "# Automatically generated by configure - do not modify" >> $config_mak
2501     echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2502     echo "CC=$cc" >> $config_mak
2503     echo "BCC=bcc" >> $config_mak
2504     echo "CPP=${cross_prefix}cpp" >> $config_mak
2505     echo "OBJCOPY=objcopy" >> $config_mak
2506     echo "IASL=iasl" >> $config_mak
2507     echo "HOST_CC=$host_cc" >> $config_mak
2508     echo "LD=$ld" >> $config_mak
2509 done
2510
2511 for hwlib in 32 64; do
2512   d=libhw$hwlib
2513   mkdir -p $d
2514   rm -f $d/Makefile
2515   ln -s $source_path/Makefile.hw $d/Makefile
2516   echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2517   echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
2518 done
2519
2520 d=libuser
2521 mkdir -p $d
2522 rm -f $d/Makefile
2523 ln -s $source_path/Makefile.user $d/Makefile
This page took 0.166028 seconds and 4 git commands to generate.