-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·134 lines (122 loc) · 2.45 KB
/
configure
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/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/ | sed -e 's/arm.*/arm/'`
cross_prefix=
usage() {
cat <<-EOF
Usage: $0 [options]
Options include:
--arch=ARCH architecture to compile for ($arch)
--processor=PROCESSOR processor 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
arch_name=$arch
[ "$arch" = "aarch64" ] && arch="arm64"
[ "$arch_name" = "arm64" ] && arch_name="aarch64"
[ -z "$processor" ] && processor="$arch"
if [ "$processor" = "arm64" ]; then
processor="cortex-a57"
elif [ "$processor" = "arm" ]; then
processor="cortex-a15"
fi
if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
testdir=x86
elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
testdir=arm
else
testdir=$arch
fi
if [ ! -d $testdir ]; then
echo "$testdir does not exist!"
exit 1
fi
if [ -f $testdir/run ]; then
ln -fs $testdir/run $testdir-run
fi
# check for dependent 32 bit libraries
if [ "$arch" != "arm" ]; then
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
fi
# link lib/asm for the architecture
rm -f lib/asm
asm=asm-generic
if [ -d lib/$arch/asm ]; then
asm=$arch/asm
elif [ -d lib/$testdir/asm ]; then
asm=$testdir/asm
fi
ln -s $asm lib/asm
# create the config
cat <<EOF > config.mak
PREFIX=$prefix
KERNELDIR=$(readlink -f $kerneldir)
ARCH=$arch
ARCH_NAME=$arch_name
PROCESSOR=$processor
CC=$cross_prefix$cc
LD=$cross_prefix$ld
OBJCOPY=$cross_prefix$objcopy
AR=$cross_prefix$ar
API=$api
TEST_DIR=$testdir
EOF