forked from yan9a/ceutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ceutil.sh
107 lines (93 loc) · 2.72 KB
/
ceutil.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
#!/bin/bash
# fix script
# sed -i -e 's/\r$//' ceutil.sh
# chmod +x ceutil.sh
SCRIPTNAME=`basename "$0"`
PRJNAME="${SCRIPTNAME%.*}"
SCRIPTDIR="${0%/$PRJNAME.*}"
echo "Project: $PRJNAME"
echo "Script directory: $SCRIPTDIR"
opt_sh="build"
if [ $# == 1 ]; then
opt_sh=$1
else
echo "You can input argument:"
echo " 'install' : to install prerequisite packages, generate cmake files, build and install the lib"
echo " 'cmake' : to generate cmake files, build, and install"
echo " 'build': to build and run"
echo " ..."
read -p "Input an option: " opt_sh
fi
if [[ "$opt_sh" == "" ]]; then
opt_sh="build"
fi
echo "Option: $opt_sh"
echo " ."
echo " ."
echo " ."
if [[ "$opt_sh" == "install" ]]; then
# add the user to groups
opt_au="y"
read -p "Do you want to add current user to netdev and dialout groups [y/N]?: " opt_au
if [ $opt_au == "y" ] || [ $opt_au == "Y" ]; then
echo "Adding $USER to groups"
sudo usermod -a -G netdev $USER
sudo usermod -a -G dialout $USER
fi
opt_reqlib="y"
read -p "Do you want to install required libraries [y/N]?: " opt_reqlib
if [ $opt_reqlib == "y" ] || [ $opt_reqlib == "Y" ]; then
# install required lib
echo "Installing required lib ..."
sudo apt update \
&& sudo apt install --no-install-recommends --no-install-suggests -y build-essential cmake cmake-extras gdb\
libgtk-3-dev checkinstall libwxgtk3.0-gtk3-dev \
git pkg-config libavcodec-dev libavformat-dev libswscale-dev libopencv-dev \
libjsoncpp-dev apt-transport-https ca-certificates \
autoconf automake libtool gdb cmake-extras \
libssl-dev openssl
fi
echo " ."
echo " ."
echo " ."
fi # lib
cd $SCRIPTDIR
if [[ "$opt_sh" == "install" ]] || [[ "$opt_sh" == "cmake" ]]; then
echo "Preparing cmake file"
if [[ ! -d "./build" ]]; then
mkdir -p build
fi
rm -r ./build/*
cd build
cmake -D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
..
cd ..
echo " ."
echo " ."
echo " ."
fi
if [[ $opt_sh == "install" ]] || [[ $opt_sh == "cmake" ]] || [[ $opt_sh == "build" ]]; then
echo "Building ..."
cd build && make && sudo make install
if [[ $? == 0 ]]; then
echo "Build successful"
ls -l *ceutil.so
ldd *ceutil.so
# ls -l *$ceutil.a
# ar -t *$ceutil.a
else
echo "Error in compiling"
fi
else
echo "Invalid option for $PRJNAME ..."
fi
if [[ "$opt_sh" == "install" ]]; then
echo "Configuring lib path ..."
sudo sh -c "echo /usr/local/lib/ > /etc/ld.so.conf.d/ceutil.conf"
sudo ldconfig
echo " ."
echo " ."
echo " ."
fi # config