-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbuild
executable file
·284 lines (257 loc) · 9.3 KB
/
build
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#! /bin/bash
RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
if [ "$LGPL2_1" == "" ]; then
LGPL2_1=OFF
fi
echo -e "${YELLOW}COMMAND${NC} : ../FireSight/build"
echo "DATE : `date`"
echo "LGPL2_1 : $LGPL2_1"
cv="install"
installPrefix=/usr
function help() {
echo "Build FireSight for Linux (Debian) and Solaris"
echo
echo "EXAMPLES:"
echo " ./build"
echo
echo "OPTIONS:"
echo " -h"
echo " --help"
echo " Print this help text"
echo " -c install"
echo " Install pre-built OpenCV package if available (fast, simple). This is default."
echo " -c make"
echo " Rebuild OpenCV from latest source code (latest code, time-consuming)"
}
function packages() {
echo "${RED}ERROR${NC} : It seems that my programmer hasn't told me how to install these packages on your platform."
echo
echo "Please ensure you have the following packages installed on your *nix machine first before continuing:"
echo
echo "GCC"
echo "cmake"
echo "aclocal"
echo "libtool"
echo
echo "OPTIONAL: (not available on Solaris)"
echo
echo "libzbar"
echo
exit -1
}
while getopts "c:" flag
do
case "$flag" in
c) cv="$OPTARG";;
*) help ; exit 0;;
esac
done
if [ "$SUDO_USER" != "" ]; then
echo -e "\n\n${RED}ERROR${NC} : This script will call sudo as required and must be run by non-root user"
echo -e "${YELLOW}TRY${NC} : ./build\n\n"
exit -1
fi
if [ "$LGPL2_1" == "ON" ]; then
if [ -e /usr/lib/libzbar.so ]; then
echo -e "${GREEN}SUCCESS${NC} : libzbar installed\n"
else
echo -e "${YELLOW}INSTALL${NC} : apt-get install libzbar0\n"
sudo apt-get update
sudo apt-get install -y libzbar0
if [ $? -ne 0 ]; then echo -e "\n\n${RED}ERROR${NC} : Install failed\n\n"; exit -1; fi
echo -e "\n${YELLOW}INSTALL${NC} : apt-get install libzbar-dev\n"
sudo apt-get install -y libzbar-dev
if [ $? -ne 0 ]; then echo -e "\n\n${RED}ERROR${NC} : Install failed\n\n"; exit -1; fi
fi
fi
if [ `uname -o` == "Solaris" ]; then
echo "OS : SOLARIS"
sudo pkgin update
sudo crle -l /usr/local/lib -u
sudo ln -s -f /usr/local/bin/firesight /opt/local/bin/firesight
installPrefix=/usr/local
if [ "$(type -p install-sh)" == "" ]; then
echo -e "${YELLOW}COMMAND${NC} : pkgin -y install install-sh\n"
sudo pkgin -y install install-sh
else
echo -e "${GREEN}SUCCESS${NC} : install-sh installed\n"
fi
fi
if [ "$(type -p gcc)" == "" ]; then
if [ `uname -o` == "Solaris" ]; then
echo -e "${YELLOW}COMMAND${NC} : pkgin -y install scmgit-base gcc47\n"
sudo pkgin -y install scmgit-base gcc47
echo -e "${GREEN}SUCCESS${NC} : GCC installed\n"
elif [ "$(lsb_release -is)" == "Debian" ]; then
echo -e "${YELLOW}COMMAND${NC} : apt-get -y install gcc\n"
sudo apt-get -y install gcc git
echo -e "${GREEN}SUCCESS${NC} : GCC installed\n"
else
packages
fi
fi
if [ "$(type -p cmake)" == "" ]; then
if [ `uname -o` == "Solaris" ]; then
echo -e "${YELLOW}COMMAND${NC} : pkgin -y install gmake; pkgin -y install cmake\n"
sudo pkgin -y install gmake
sudo pkgin -y install cmake
echo -e "${GREEN}SUCCESS${NC} : cmake installed\n"
elif [ "$(lsb_release -is)" == "Debian" ]; then
echo -e "${YELLOW}COMMAND${NC} : apt-get -y install cmake\n"
sudo apt-get -y install cmake
echo -e "${GREEN}SUCCESS${NC} : cmake installed\n"
else
packages
fi
fi
if [ ! -d "/usr/share/libtool" ]; then
if [ `uname -o` == "Solaris" ]; then
echo -e "${YELLOW}COMMAND${NC} : pkgin -y install libtool\n"
sudo pkgin -y install libtool
echo -e "${GREEN}SUCCESS${NC} : libtool installed\n"
elif [ "$(lsb_release -is)" == "Debian" ]; then
echo -e "${YELLOW}COMMAND${NC} : apt-get -y install libtool\n"
sudo apt-get -y install libtool
echo -e "${GREEN}SUCCESS${NC} : libtool installed\n"
else
packages
fi
fi
if [ "$(type -p aclocal)" == "" ]; then
if [ `uname -o` == "Solaris" ]; then
echo -e "${YELLOW}COMMAND${NC} : pkgin -y install automake\n"
sudo pkgin -y install automake
echo -e "${GREEN}SUCCESS${NC} : automake installed\n"
elif [ "$(lsb_release -is)" == "Debian" ]; then
echo -e "${YELLOW}COMMAND${NC} : apt-get -y install automake\n"
sudo apt-get -y install automake
echo -e "${GREEN}SUCCESS${NC} : automake installed\n"
else
packages
fi
fi
grep 2.7 /usr/local/include/jansson.h
RC=$?
if [ $RC -eq 0 ]; then
echo -e "\n${YELLOW}STATUS${NC} : Jansson 2.7 already installed\n"
else
echo -e "\n${YELLOW}STATUS${NC} : installing Jansson 2.7\n"
if [ ! -e jannson ]; then
rm -rf jannson
fi
git clone https://github.com/akheron/jansson
pushd jansson
git checkout v2.7
autoreconf -i
./configure
cmake .
make $(nproc)
sudo -E make install
popd
echo -e "\n${GREEN}SUCCESS${NC} : Jansson 2.7 installed\n"
fi
if [ -e /usr/lib/libopencv_core.so.2.3 ]; then
echo -e "${YELLOW}STATUS${NC} : removing OpenCV 2.3 found in /usr/lib:\n"
sudo apt-get -y remove libopencv-dev
if [ $? -ne 0 ]; then echo -e "\n\n${RED}ERROR${NC} : Could not remove existing OpenCV 2.3\n\n"; exit -1; fi
sudo apt-get -y autoremove libopencv-dev
if [ $? -ne 0 ]; then echo -e "\n\n${RED}ERROR${NC} : Could not remove existing OpenCV 2.3\n\n"; exit -1; fi
fi
if [ -e /usr/local/lib/libopencv_core.so.3.* ]; then
ls /usr/local/lib/libopencv_core.so.*
echo -e "\n\n${RED}ERROR${NC} : FireSight does not yet work with OpenCV 3. Please use OpenCV 2.4.9 or earlier"
exit -1
elif [ -e /usr/local/lib/libopencv_core.so.2.4.8 ]; then
echo -e "${YELLOW}STATUS${NC} : OpenCV found in /usr/local/lib:"
ls /usr/local/lib/libopencv_core.so.*
elif [ "$cv" == "install" ]; then
echo -e "${YELLOW}STATUS${NC} : INSTALLING OPENCV C++ LIBRARIES\n"
if [ `uname -o` == "Solaris" ]; then
pkgin -y install opencv
echo -e "${GREEN}SUCCESS${NC} : OpenCV installed\n"
elif [ "`uname -m`" == "armv6l" ]; then
echo -e "${YELLOW}SYSTEM${NC} : Raspberry Pi 1"
echo -e "${YELLOW}COMMAND${NC} : sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip"
sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip
echo -e "\n${GREEN}SUCCESS${NC} : OpenCV 2.4.8 installed\n"
elif [ "`uname -m`" == "armv7l" ]; then
echo -e "${YELLOW}SYSTEM${NC} : Raspberry Pi 2"
echo -e "${YELLOW}COMMAND${NC} : sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip"
sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip
echo -e "\n${GREEN}SUCCESS${NC} : OpenCV 2.4.8 installed\n"
elif [ "`cat /proc/cpuinfo | grep a02082`" == "a02082"]; then
echo -e "${YELLOW}SYSTEM${NC} : Raspberry Pi 3 manufactured by Sony"
echo -e "${YELLOW}COMMAND${NC} : sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip"
sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip
echo -e "\n${GREEN}SUCCESS${NC} : OpenCV 2.4.8 installed\n"
elif [ "`cat /proc/cpuinfo | grep a22082`" == "a22082"]; then
echo -e "${YELLOW}SYSTEM${NC} : Raspberry Pi 3 manufactured by Embest"
echo -e "${YELLOW}COMMAND${NC} : sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip"
sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip
echo -e "\n${GREEN}SUCCESS${NC} : OpenCV 2.4.8 installed\n"
elif [ "$(type -p apt-get)" == "" ]; then
echo -e "\n\n${RED}ERROR${NC} : apt-get is UNAVAILABLE"
echo -e "${YELLOW}TRY${NC} : Install OpenCV using following command:"
echo -e "${YELLOW}TRY${NC} : sudo ./build -c make\n\n"
exit -1
fi
else
echo -e "\n${YELLOW}STATUS${NC} : BUILDING OPENCV C++ LIBRARIES\n"
#if [ `uname -o` == "Solaris" ]; then
if [ "$(type -p apt-get)" != "" ] [ `uname -o` == "Solaris" ]; then
echo -e "\n\n${RED}ERROR${NC} : apt-get: UNAVAILABLE"
echo -e "${YELLOW}ASSUME${NC} : (assuming OpenCV prerequisites are already on your system)...\n\n"
else
echo -e "${YELLOW}STATUS${NC} : apt-get installing needed libraries for libIlmImf.so.6\n"
sudo apt-get -y install openexr
sudo apt-get -y install libavcodec-dev
sudo apt-get -y install libavformat-dev
sudo apt-get -y install libswscale-dev
sudo apt-get -y install libdc1394-22
sudo apt-get -y install libz-dev
echo -e "\n${GREEN}SUCCESS${NC} : OpenCV C++ libraries installed\n"
fi
if [ ! -e opencv ] ; then
git clone https://github.com/firepick1/opencv -b 2.4
fi
mkdir opencv/build
pushd opencv/build
cmake \
-D WITH_OPENEXR=OFF \
-D CMAKE_BUILD_TYPE=DEBUG \
-D CMAKE_INSTALL_PREFIX=/usr/local \
..
sudo -E make -j$(nproc) install
popd
fi
if [ -e CMakeFiles ] ; then
echo -e "\n${YELLOW}STATUS${NC} : removing existing makefiles"
rm -rf CMakeCache.txt CMakeFiles CMakeFiles.txt target cmake_install.cmake CPackConfig.cmake CPackSourceConfig.cmake
mkdir target
fi
echo -e "${YELLOW}STATUS${NC} : creating makefile\n"
cmake \
-DBUILD_LGPL2_1=$LGPL2_1 \
-DCMAKE_${YELLOW}INSTALL${NC}_PREFIX:PATH=$installPrefix "$@" \
.
RC=$?; if [ $RC -ne 0 ]; then
echo -e "\n\n${RED}ERROR${NC} : cmake failed (RC=$RC)\n\n"
exit -1
fi
echo -e "\n${YELLOW}STATUS${NC} : building and installing FireSight...\n"
make -j$(nproc)
RC=$?; if [ $RC -ne 0 ]; then
echo -e "\n\n${RED}ERROR${NC} : make failed (RC=$RC)\n\n"
exit -1
fi
sudo -E make install
if [ $? -ne 0 ]; then
echo -e "\n\n${RED}ERROR${NC} : make failed\n\n"
exit -1
fi
echo "----------------------------------"
echo -e "\nDATE : `date`"
echo -e "${GREEN}SUCCESS${NC} : firesight installed\n"