kvm: build: don't sync headers if building userspace package only
[kvm-userspace.git] / configure
blobb9419c079dbcd7f42230d0f09d62df89833fe2d8
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 if [ ! -e kernel/Makefile ]; then
25 want_module=
28 usage() {
29 cat <<-EOF
30 Usage: $0 [options]
32 Options include:
33 --arch=ARCH architecture to compile for ($arch)
34 --cross-prefix=PREFIX prefix for cross compile
35 --prefix=PREFIX where to install things ($prefix)
36 --with-patched-kernel don't use external module
37 --with-kvm-trace Enable kvm_trace
38 --kerneldir=DIR kernel build directory ($kerneldir)
39 --qemu-cflags=CFLAGS CFLAGS to add to qemu configuration
40 --qemu-ldflags=LDFLAGS LDFLAGS to add to qemu configuration
42 Any additional option is given to qemu's configure verbatim; including:
44 EOF
45 cd qemu
46 ./configure --help | egrep "enable-|disable-" \
47 | grep -v user | grep -v system | grep -v kqemu | grep -v kvm \
48 | sed -e "s/^ / /g" \
49 | sed -e"s/ enable/enable/g" | sed -e "s/ disable/disable/g"
50 exit 1
53 while [[ "$1" = -* ]]; do
54 opt="$1"; shift
55 arg=
56 hasarg=
57 if [[ "$opt" = *=* ]]; then
58 arg="${opt#*=}"
59 opt="${opt%%=*}"
60 hasarg=1
62 case "$opt" in
63 --prefix)
64 prefix="$arg"
66 --kerneldir)
67 kerneldir="$arg"
68 no_uname=1
70 --with-patched-kernel)
71 want_module=
73 --with-kvm-trace)
74 kvm_trace=y
76 --qemu-cflags)
77 qemu_cflags="$arg"
79 --qemu-ldflags)
80 qemu_ldflags="$arg"
82 --arch)
83 arch="$arg"
85 --cross-prefix)
86 cross_prefix="$arg"
88 --help)
89 usage
92 qemu_opts=("${qemu_opts[@]}" "$opt${hasarg:+=$arg}")
94 esac
95 done
98 #set kenel directory
99 libkvm_kerneldir=$(readlink -f kernel)
101 case $arch in
102 i?86*|x86_64*)
103 arch=${arch/#i?86/i386}
104 target_exec="x86_64-softmmu"
105 qemu_cflags="$qemu_cflags -DCONFIG_X86"
107 ia64*)
108 target_exec="ia64-softmmu"
110 powerpc*)
111 target_exec="ppcemb-softmmu"
112 qemu_cflags="$qemu_cflags -I $PWD/libfdt"
113 qemu_ldflags="$qemu_ldflags -L $PWD/libfdt"
115 esac
117 processor=${arch#*-}
118 arch=${arch%%-*}
120 #configure kernel module
121 [[ -n "$want_module" ]] && (cd kernel;
122 ./configure \
123 --kerneldir="$kerneldir" \
124 --arch="$arch" \
125 ${cross_prefix:+"--cross-prefix=$cross_prefix"} \
126 ${kvm_trace:+"--with-kvm-trace"}
129 #configure user dir
130 (cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
131 --arch="$arch" --processor="$processor" \
132 ${cross_prefix:+"--cross-prefix=$cross_prefix"})
134 #configure qemu
135 (cd qemu; ./configure --target-list=$target_exec \
136 --disable-kqemu \
137 --extra-cflags="-I $PWD/../libkvm $qemu_cflags" \
138 --extra-ldflags="-L $PWD/../libkvm $qemu_ldflags" \
139 --kerneldir="$libkvm_kerneldir" \
140 --prefix="$prefix" \
141 ${cross_prefix:+"--cross-prefix=$cross_prefix"} \
142 ${cross_prefix:+"--cpu=$arch"} "${qemu_opts[@]}"
143 ) || usage
146 cat <<EOF > config.mak
147 ARCH=$arch
148 PROCESSOR=$processor
149 PREFIX=$prefix
150 KERNELDIR=$kerneldir
151 KERNELSOURCEDIR=$kernelsourcedir
152 LIBKVM_KERNELDIR=$libkvm_kerneldir
153 WANT_MODULE=$want_module
154 CROSS_COMPILE=$cross_prefix
155 CC=$cross_prefix$cc
156 LD=$cross_prefix$ld
157 OBJCOPY=$cross_prefix$objcopy
158 AR=$cross_prefix$ar