kvm: external module: Hack DEFINE_SIMPLE_ATTRIBUTE for lost_records_get() also
[qemu-kvm/fedora.git] / kvm / configure
blob3bb10ce9f5b1cf7b7704e6ce17826833714ca0a1
1 #!/bin/bash
3 prefix=/usr/local
4 kerneldir=/lib/modules/$(uname -r)/build
5 cc=gcc
6 ld=ld
7 objcopy=objcopy
8 want_module=1
9 qemu_cflags=
10 qemu_ldflags=
11 qemu_opts=()
12 cross_prefix=
13 arch=`uname -m`
14 target_exec=
16 usage() {
17 cat <<-EOF
18 Usage: $0 [options]
20 Options include:
21 --arch=ARCH architecture to compile for ($arch)
22 --cross-prefix=PREFIX prefix for cross compile
23 --prefix=PREFIX where to install things ($prefix)
24 --with-patched-kernel don't use external module
25 --kerneldir=DIR kernel build directory ($kerneldir)
26 --qemu-cflags=CFLAGS CFLAGS to add to qemu configuration
27 --qemu-ldflags=LDFLAGS LDFLAGS to add to qemu configuration
29 Any additional option is given to qemu's configure verbatim; including:
31 EOF
32 cd qemu
33 ./configure --help | egrep "enable-|disable-" \
34 | grep -v user | grep -v system | grep -v kqemu | grep -v kvm \
35 | sed -e "s/^ / /g" \
36 | sed -e"s/ enable/enable/g" | sed -e "s/ disable/disable/g"
37 exit 1
40 while [[ "$1" = -* ]]; do
41 opt="$1"; shift
42 arg=
43 hasarg=
44 if [[ "$opt" = *=* ]]; then
45 arg="${opt#*=}"
46 opt="${opt%%=*}"
47 hasarg=1
49 case "$opt" in
50 --prefix)
51 prefix="$arg"
53 --kerneldir)
54 kerneldir="$arg"
56 --with-patched-kernel)
57 want_module=
59 --qemu-cflags)
60 qemu_cflags="$arg"
62 --qemu-ldflags)
63 qemu_ldflags="$arg"
65 --arch)
66 arch="$arg"
68 --cross-prefix)
69 cross_prefix="$arg"
71 --help)
72 usage
75 qemu_opts=("${qemu_opts[@]}" "$opt${hasarg:+=$arg}")
77 esac
78 done
81 #set kenel directory
82 libkvm_kerneldir=$(readlink -f kernel)
84 #if arch is an x86 arch set to i386
85 if [[ $arch = i?86 ]]; then
86 arch="i386"
89 #set parameters compiling
90 if [ "$arch" = "i386" -o "$arch" = "x86_64" ]; then
91 target_exec="x86_64-softmmu"
92 qemu_cflags="$qemu_cflags -DCONFIG_X86"
95 if [ "$arch" = "ia64" ]; then
96 target_exec="ia64-softmmu"
99 if [ "$arch" = "powerpc" ]; then
100 target_exec="ppcemb-softmmu"
101 qemu_cflags="$qemu_cflags -I $PWD/libfdt"
102 qemu_ldflags="$qemu_ldflags -L $PWD/libfdt"
105 #configure user dir
106 (cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
107 --arch="$arch" \
108 ${cross_prefix:+"--cross-prefix=$cross_prefix"})
110 #configure qemu
111 (cd qemu; ./configure --target-list=$target_exec \
112 --disable-kqemu \
113 --disable-gcc-check \
114 --extra-cflags="-I $PWD/../libkvm $qemu_cflags" \
115 --extra-ldflags="-L $PWD/../libkvm $qemu_ldflags" \
116 --kernel-path="$libkvm_kerneldir" \
117 --prefix="$prefix" \
118 ${cross_prefix:+"--cross-prefix=$cross_prefix"} \
119 ${cross_prefix:+"--cpu=$arch"} "${qemu_opts[@]}"
120 ) || usage
123 cat <<EOF > config.mak
124 ARCH=$arch
125 PREFIX=$prefix
126 KERNELDIR=$kerneldir
127 LIBKVM_KERNELDIR=$libkvm_kerneldir
128 WANT_MODULE=$want_module
129 CROSS_COMPILE=$cross_prefix
130 CC=$cross_prefix$cc
131 LD=$cross_prefix$ld
132 OBJCOPY=$cross_prefix$objcopy