summaryrefslogtreecommitdiff
path: root/configure
blob: 060df707ab82163e7444c5aec3b5a51a2efcc8f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash

prefix=/usr/local
kerneldir=/lib/modules/$(uname -r)/build
want_module=1
qemu_cc=$(ls /usr/bin/gcc3* /usr/bin/gcc-3* 2>/dev/null | tail -n1)

usage() {
    cat <<-EOF
	Usage: $0 [options]

	Options include:

	    --prefix=PREFIX        where to install things ($prefix)
	    --with-patched-kernel  don't use external module
	    --kerneldir=DIR        kernel build directory ($kerneldir)
	    --qemu-cc="$qemu_cc"   compiler for qemu (needs gcc3.x) ($qemu_cc)
EOF
    exit 1
}

while [[ "$1" = -* ]]; do
    opt="$1"; shift
    arg=
    if [[ "$opt" = *=* ]]; then
	arg="${opt#*=}"
	opt="${opt%%=*}"
    fi
    case "$opt" in
	--prefix)
	    prefix="$arg"
	    ;;
	--kerneldir)
	    kerneldir="$arg"
	    ;;
	--with-patched-kernel)
	    want_module=
	    ;;
	--qemu-cc)
	    qemu_cc="$arg"
	    ;;
	--help)
	    usage
	    ;;
	*)
	    usage
	    ;;
    esac
done

libkvm_kerneldir="$kerneldir"
if (( want_module )); then
    libkvm_kerneldir=$(readlink -f kernel)
fi

target_cpu() {
    if [[ $(uname -m) = i?86 ]]; then
	echo i386
    else
	uname -m
    fi
}

(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir")
(cd qemu; ./configure --target-list=$(target_cpu)-softmmu --cc="$qemu_cc" \
    --disable-kqemu --extra-cflags="-I $PWD/../user" \
    --extra-ldflags="-L $PWD/../user" \
    --enable-kvm --kernel-path="$libkvm_kerneldir" \
    --prefix="$prefix"
)



cat <<EOF > config.mak
PREFIX=$prefix
KERNELDIR=$(readlink -f $kerneldir)
WANT_MODULE=$want_module
EOF