-
Notifications
You must be signed in to change notification settings - Fork 30
/
build.sh
237 lines (224 loc) · 6.38 KB
/
build.sh
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/bin/sh
set -e
SRC_PATH=$(pwd)
KAE_KERNEL_DIR=${SRC_PATH}/KAEKernelDriver
KAE_UADK_DIR=${SRC_PATH}/uadk
KAE_OPENSSL_DIR=${SRC_PATH}/KAEOpensslEngine
KAE_ZLIB_DIR=${SRC_PATH}/KAEZlib
KAE_ZSTD_DIR=${SRC_PATH}/KAEZstd
KAE_BUILD=${SRC_PATH}/kae_build/
KAE_BUILD_LIB=${SRC_PATH}/kae_build/lib
KAE_BUILD_HEAD=${SRC_PATH}/kae_build/head
function build_all_comp_v2()
{
if [ -d $KAE_BUILD ]; then
rm -rf $KAE_BUILD/*
else
mkdir $KAE_BUILD
fi
mkdir -p $KAE_BUILD_LIB
mkdir -p $KAE_BUILD_HEAD
# 编译Kernel
cd ${KAE_KERNEL_DIR}
make -j
cp ${KAE_KERNEL_DIR}/hisilicon/sec2/hisi_sec2.ko $KAE_BUILD_LIB
cp ${KAE_KERNEL_DIR}/hisilicon/hpre/hisi_hpre.ko $KAE_BUILD_LIB
cp ${KAE_KERNEL_DIR}/hisilicon/hisi_qm.ko $KAE_BUILD_LIB
cp ${KAE_KERNEL_DIR}/uacce/uacce.ko $KAE_BUILD_LIB
cp ${KAE_KERNEL_DIR}/hisilicon/zip/hisi_zip.ko $KAE_BUILD_LIB
# 编译uadk
cd $KAE_UADK_DIR
sh autogen.sh
sh conf.sh
make -j
cp ${KAE_UADK_DIR}/.libs/lib* $KAE_BUILD_LIB
mkdir -p $KAE_BUILD_HEAD/uadk
mkdir -p $KAE_BUILD_HEAD/uadk/v1
cp -r ${KAE_UADK_DIR}/include/* $KAE_BUILD_HEAD/uadk
cp -r ${KAE_UADK_DIR}/v1/*.h $KAE_BUILD_HEAD/uadk/v1
# 编译openssl
cd $KAE_OPENSSL_DIR
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
autoreconf -i
./configure --libdir=/usr/local/lib/engines-1.1/
make -j
cp $KAE_OPENSSL_DIR/src/.libs/*kae*so* $KAE_BUILD_LIB
# 编译zlib
cd $KAE_ZLIB_DIR
sh setup.sh devbuild KAE2
cp $KAE_ZLIB_DIR/lib* $KAE_BUILD_LIB
cp $KAE_ZLIB_DIR/open_source/zlib-1.2.11/lib* $KAE_BUILD_LIB
# 编译zstd
cd $KAE_ZSTD_DIR
sh build.sh devbuild
cp $KAE_ZSTD_DIR/lib* $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/programs/zstd $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/programs/zstdgrep $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/programs/zstdless $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/lib/libzstd.so* $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/lib/libzstd.a $KAE_BUILD_LIB
}
function build_driver()
{
cd ${SRC_PATH}/KAEKernelDriver
make -j
make install
}
function driver_clean()
{
cd ${SRC_PATH}/KAEKernelDriver
make uninstall
make clean
}
function build_driver_v1()
{
cd ${SRC_PATH}/KAEKernelDriver
make -j
make nosva
}
function build_uadk()
{
cd ${SRC_PATH}/uadk
sh autogen.sh
sh conf.sh
make -j
make install
}
function uadk_clean()
{
cd ${SRC_PATH}/uadk
make uninstall
make clean
sh cleanup.sh
}
function build_engine()
{
cd ${SRC_PATH}/KAEOpensslEngine
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
autoreconf -i
./configure --libdir=/usr/local/lib/engines-1.1/
make -j
make install
}
function engine_clean()
{
cd ${SRC_PATH}/KAEOpensslEngine
make uninstall
make clean
}
function build_engine_v1()
{
cd ${SRC_PATH}/KAEOpensslEngine
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
autoreconf -i
./configure --libdir=/usr/local/lib/engines-1.1/ --enable-kae
make -j
make install
}
function build_zlib()
{
cd ${SRC_PATH}/KAEZlib
sh setup.sh install KAE2
}
function build_zlib_v1()
{
cd ${SRC_PATH}/KAEZlib
sh setup.sh install
}
function zlib_clean()
{
cd ${SRC_PATH}/KAEZlib
sh setup.sh uninstall
}
function build_zstd()
{
cd ${SRC_PATH}/KAEZstd
sh build.sh install
}
function zstd_clean()
{
cd ${SRC_PATH}/KAEZstd
sh build.sh uninstall
}
function help()
{
echo "build KAE"
echo "sh build.sh all -- install all component"
echo "sh build.sh buildallv2 -- build all component"
echo "sh build.sh driver -- install KAE SVA driver"
echo "sh build.sh driver v1 -- install KAE NoSVA driver"
echo "sh build.sh driver clean -- uninstall KAE driver"
echo "sh build.sh uadk -- install uadk"
echo "sh build.sh uadk clean -- uninstall uadk"
echo "sh build.sh engine -- install KAE openssl engine"
echo "sh build.sh engine v1 -- install KAE openssl engine including v1 part"
echo "sh build.sh engine clean -- uninstall KAE openssl engine"
echo "sh build.sh zlib -- install zlib using KAE"
echo "sh build.sh zlib v1 -- install zlib using KAE v1"
echo "sh build.sh zlib clean -- uninstall zlib using KAE"
echo "sh build.sh zstd -- install zstd using KAE"
echo "sh build.sh zstd clean -- uninstall zstd using KAE"
echo "sh build.sh cleanup -- clean up all component"
}
function main()
{
if [ "$1" = "all" ];then
echo "build all"
build_driver
build_uadk
build_engine
build_zlib
build_zstd
elif [ "$1" = "driver" ];then
echo "build driver"
if [ "$2" = "v1" ];then
build_driver_v1
elif [ "$2" = "clean" ];then
driver_clean
else
build_driver
fi
elif [ "$1" = "uadk" ];then
if [ "$2" = "clean" ];then
uadk_clean
else
build_uadk
fi
elif [ "$1" = "engine" ];then
if [ "$2" = "v1" ];then
build_engine_v1
elif [ "$2" = "clean" ];then
engine_clean
else
build_engine
fi
elif [ "$1" = "zlib" ];then
if [ "$2" = "v1" ];then
build_zlib_v1
elif [ "$2" = "clean" ];then
zlib_clean
else
build_zlib
fi
elif [ "$1" = "zstd" ];then
if [ "$2" = "clean" ];then
zstd_clean
else
build_zstd
fi
elif [ "$1" = "cleanup" ];then
echo "cleanup all"
driver_clean
uadk_clean
engine_clean
zlib_clean
zstd_clean
rm -rf $KAE_BUILD/*
elif [ "$1" = "buildallv2" ];then
build_all_comp_v2
else
help
fi
}
main "$@"
exit $?