kvm: qemu: expose MSI capability to guest
[kvm-userspace.git] / configure
bloba832cdf6ddf8b99bdb41cbce06c91a7f7d70d825
1 #!/bin/bash
3 prefix=/usr/local
4 kerneldir=/lib/modules/$(uname -r)/build
5 cc=gcc
6 ld=ld
7 objcopy=objcopy
8 ar=ar
9 want_module=1
10 qemu_cflags=
11 qemu_ldflags=
12 kvm_trace=
13 qemu_opts=()
14 cross_prefix=
15 arch=`uname -m`
16 target_exec=
17 # don't use uname if kerneldir is set
18 no_uname=
19 depmod_version=
20 if [ -z "TMPDIR" ] ; then
21 TMPDIR=.
24 usage() {
25 cat <<-EOF
26 Usage: $0 [options]
28 Options include:
29 --arch=ARCH architecture to compile for ($arch)
30 --cross-prefix=PREFIX prefix for cross compile
31 --prefix=PREFIX where to install things ($prefix)
32 --with-patched-kernel don't use external module
33 --with-kvm-trace Enable kvm_trace
34 --kerneldir=DIR kernel build directory ($kerneldir)
35 --qemu-cflags=CFLAGS CFLAGS to add to qemu configuration
36 --qemu-ldflags=LDFLAGS LDFLAGS to add to qemu configuration
38 Any additional option is given to qemu's configure verbatim; including:
40 EOF
41 cd qemu
42 ./configure --help | egrep "enable-|disable-" \
43 | grep -v user | grep -v system | grep -v kqemu | grep -v kvm \
44 | sed -e "s/^ / /g" \
45 | sed -e"s/ enable/enable/g" | sed -e "s/ disable/disable/g"
46 exit 1
49 while [[ "$1" = -* ]]; do
50 opt="$1"; shift
51 arg=
52 hasarg=
53 if [[ "$opt" = *=* ]]; then
54 arg="${opt#*=}"
55 opt="${opt%%=*}"
56 hasarg=1
58 case "$opt" in
59 --prefix)
60 prefix="$arg"
62 --kerneldir)
63 kerneldir="$arg"
64 no_uname=1
66 --with-patched-kernel)
67 want_module=
69 --with-kvm-trace)
70 kvm_trace=y
72 --qemu-cflags)
73 qemu_cflags="$arg"
75 --qemu-ldflags)
76 qemu_ldflags="$arg"
78 --arch)
79 arch="$arg"
81 --cross-prefix)
82 cross_prefix="$arg"
84 --help)
85 usage
88 qemu_opts=("${qemu_opts[@]}" "$opt${hasarg:+=$arg}")
90 esac
91 done
94 #set kenel directory
95 libkvm_kerneldir=$(readlink -f kernel)
97 case $arch in
98 i?86*|x86_64*)
99 arch=${arch/#i?86/i386}
100 target_exec="x86_64-softmmu"
101 qemu_cflags="$qemu_cflags -DCONFIG_X86"
103 ia64*)
104 target_exec="ia64-softmmu"
106 powerpc*)
107 target_exec="ppcemb-softmmu"
108 qemu_cflags="$qemu_cflags -I $PWD/libfdt"
109 qemu_ldflags="$qemu_ldflags -L $PWD/libfdt"
111 esac
113 processor=${arch#*-}
114 arch=${arch%%-*}
116 #configure kernel module
117 (cd kernel;
118 ./configure \
119 --kerneldir="$kerneldir" \
120 --arch="$arch" \
121 ${cross_prefix:+"--cross-prefix=$cross_prefix"} \
122 ${kvm_trace:+"--with-kvm-trace"}
125 #configure user dir
126 (cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
127 --arch="$arch" --processor="$processor" \
128 ${cross_prefix:+"--cross-prefix=$cross_prefix"})
130 #configure qemu
131 (cd qemu; ./configure --target-list=$target_exec \
132 --disable-kqemu \
133 --extra-cflags="-I $PWD/../libkvm $qemu_cflags" \
134 --extra-ldflags="-L $PWD/../libkvm $qemu_ldflags" \
135 --kerneldir="$libkvm_kerneldir" \
136 --prefix="$prefix" \
137 ${cross_prefix:+"--cross-prefix=$cross_prefix"} \
138 ${cross_prefix:+"--cpu=$arch"} "${qemu_opts[@]}"
139 ) || usage
142 cat <<EOF > config.mak
143 ARCH=$arch
144 PROCESSOR=$processor
145 PREFIX=$prefix
146 KERNELDIR=$kerneldir
147 KERNELSOURCEDIR=$kernelsourcedir
148 LIBKVM_KERNELDIR=$libkvm_kerneldir
149 WANT_MODULE=$want_module
150 CROSS_COMPILE=$cross_prefix
151 CC=$cross_prefix$cc
152 LD=$cross_prefix$ld
153 OBJCOPY=$cross_prefix$objcopy
154 AR=$cross_prefix$ar