-
Notifications
You must be signed in to change notification settings - Fork 10
/
configure
executable file
·125 lines (108 loc) · 3.82 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
#!/bin/bash
#
# VeriSilicon configure script
#
# Prevent locale nonsense from breaking basic text processing.
LC_ALL=C
export LC_ALL
# make sure we are running under a compatible shell
# try to make this part work with most shells
try_exec(){
echo "Trying shell $1"
type "$1" > /dev/null 2>&1 && exec "$@"
}
print_config(){
echo "arch=$arch"
echo "cross=$cross"
echo "sysroot=$sysroot"
echo "kernel=$kernel"
echo "debug=$debug"
echo "installpath=$installpath"
echo "Create VPE build config file successfully!"
}
print_usage(){
echo "VPE configure tool help menu:"
echo "Toolchain:"
echo "--arch= target platform CPU arch, can be x86_64 or arm64. can be empty."
echo "--cross= prefix of the cross compiling tool, for example: aarch64-linux-gnu-. can be empty. if the toolchain bin files are not accessible directly, please set this value with full path."
echo "--sysroot= the sysroot path of the target cross compiling system. can be empty."
echo "--kernel= kernel source code of the target system. it will be used to compiling VPE driver. for cross compiling, it's MUST."
echo "Config:"
echo "--debug if compiling VPE in debug mode. if it's not set then release version will be built"
echo "--installpath= the installation base path, default is /. For cross compiling, please set this to target root files system"
echo "--help show help menu"
}
debug=n
arch=`uname -m`
cross=
sysroot=
kernel=
installpath=
TEMP=`getopt -o a:c:s:dk:p:h, --long arch:,cross:,sysroot:,debug,kernel:,installpath:,help\
-n ' ' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$TEMP"
while true ; do
case "$1" in
-a|--arch) arch=$2 ; shift 2 ;;
-c|--cross) cross=$2 ; shift 2 ;;
-s|--sysroot) sysroot=$2 ; shift 2 ;;
-k|--kernel) kernel=$2 ; shift 2 ;;
-d|--debug) debug=y ; shift ;;
-o|--installpath) installpath=$2; shift 2;;
-h|--help) print_usage ; exit 1 ;;
--) shift ; break ;;
*) echo "Invalid parameters" ; print_usage ; exit 1 ;;
esac
done
for arg do
echo "Error! Opition \`$arg' is unknown" ;
print_usage;
exit 1 ;
done
if [ ! -z "$LD_LIBRARY_PATH" ]; then
unset LD_LIBRARY_PATH
fi
iscross=n
host_arch=`uname -m`
if [[ "$arch" != "$host_arch" ]]; then
echo "Target arch is $arch, host arch is $host_arch, enable cross compiling"
iscross=y
fi
echo "export SDKTARGETSYSROOT=$sysroot" > config.mk
if [ "$kernel" != "" ]; then
echo "export KERN_DIR=$kernel" >> config.mk
fi
echo "export CROSS_COMPILE=$cross" >> config.mk
echo "export PKG_CONFIG_SYSROOT_DIR=$sysroot" >> config.mk
echo "export PKG_CONFIG_PATH=$sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig" >> config.mk
echo "export ARCH=$arch" >> config.mk
if [ "$arch" == "aarch64" ]; then
echo "export ENV=arm_linux_pci" >> config.mk
else
echo "export ENV=x86_linux_pci" >> config.mk
fi
echo "export DEBUG=$debug" >> config.mk
if [ "$installpath" != "" ]; then
echo "export installpath=$installpath" >> config.mk
fi
echo "export cross=$iscross" >> config.mk
if [ "$sysroot" != "" ]; then
echo "export CC=\"${cross}gcc --sysroot=$sysroot\"" >> config.mk
echo "export CXX=\"${cross}g++ --sysroot=$sysroot\"" >> config.mk
echo "export CPP=\"${cross}gcc -E --sysroot=$sysroot\"" >> config.mk
echo "export LD=\"${cross}ld --sysroot=$sysroot\"" >> config.mk
else
echo "export CC=${cross}gcc" >> config.mk
echo "export CXX=${cross}g++" >> config.mk
echo "export CPP=${cross}gcc" >> config.mk
echo "export LD=${cross}ld" >> config.mk
fi
echo "export AS="${cross}as"" >> config.mk
echo "export GDB=${cross}gdb" >> config.mk
echo "export STRIP=${cross}strip" >> config.mk
echo "export RANLIB=${cross}ranlib" >> config.mk
echo "export OBJCOPY=${cross}objcopy" >> config.mk
echo "export OBJDUMP=${cross}objdump" >> config.mk
echo "export AR=\"${cross}ar rcs\"" >> config.mk
echo "export NM=${cross}nm" >> config.mk