configure 1.53 KB
Newer Older
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
#!/bin/bash

prefix=/usr/local
kerneldir=/lib/modules/$(uname -r)/build
cc=gcc
ld=ld
objcopy=objcopy
ar=ar
arch=`uname -m | sed -e s/i.86/i386/`
processor="$arch"
cross_prefix=

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

	Options include:
	    --arch=ARCH            architecture to compile for ($arch)
	    --cross-prefix=PREFIX  cross compiler prefix
	    --cc=CC		   c compiler to use ($cc)
	    --ld=LD		   ld linker to use ($ld)
	    --prefix=PREFIX        where to install things ($prefix)
	    --kerneldir=DIR        kernel build directory for kvm.h ($kerneldir)
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"
	    ;;
        --arch)
	    arch="$arg"
	    ;;
        --processor)
	    processor="$arg"
	    ;;
	--cross-prefix)
	    cross_prefix="$arg"
	    ;;
	--cc)
	    cc="$arg"
	    ;;
	--ld)
	    ld="$arg"
	    ;;
	--help)
	    usage
	    ;;
	*)
	    usage
	    ;;
    esac
done

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# check for dependent 32 bit libraries
cat << EOF > lib_test.c
#include <stdc++.h>
#include <boost_thread-mt.h>
#include <pthread.h>

int main ()
{}
EOF
$cc -m32 -o /dev/null lib_test.c &> /dev/null
exit=$?
if [ $exit -eq 0 ]; then
    api=true
fi
rm -f lib_test.c

82
83
84
85
86
87
88
89
90
cat <<EOF > config.mak
PREFIX=$prefix
KERNELDIR=$(readlink -f $kerneldir)
ARCH=$arch
PROCESSOR=$processor
CC=$cross_prefix$cc
LD=$cross_prefix$ld
OBJCOPY=$cross_prefix$objcopy
AR=$cross_prefix$ar
91
API=$api
92
EOF