forked from firepick1/FireSight
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build
executable file
·216 lines (194 loc) · 5.83 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
#! /bin/bash
if [ "$LGPL2_1" == "" ]; then
LGPL2_1=ON
fi
echo "COMMAND : ../FireSight/build"
echo "DATE : `date`"
echo "LGPL2_1 : $LGPL2_1"
cv="install"
function help() {
echo "Build FireSight (non-Windows)"
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)"
}
while getopts "c:" flag
do
case "$flag" in
c) cv="$OPTARG";;
*) help ; exit 0;;
esac
done
if [ "$SUDO_USER" != "" ]; then
echo "ERROR : This script will call sudo as required and must be run by non-root user"
echo "TRY : ./build"
exit -1
fi
installPrefix=/usr
if [ "$LGPL2_1" == "ON" ]; then
if [ -e /usr/lib/libzbar.so ]; then
echo "STATUS : libzbar installed"
else
echo "INSTALL : apt-get install libzbar0"
sudo apt-get update
sudo apt-get install -y libzbar0
if [ $? -ne 0 ]; then echo "ERROR : Install failed"; exit -1; fi
echo "INSTALL : npm install libzbar-dev"
sudo apt-get install -y libzbar-dev
if [ $? -ne 0 ]; then echo "ERROR : Install failed"; 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 "COMMAND : pkgin -y install install-sh"
sudo pkgin -y install install-sh
else
echo "STATUS : install-sh installed"
fi
fi
if [ "$(type -p gcc)" == "" ]; then
echo "COMMAND : pkgin -y install scmgit-base gcc47"
sudo pkgin -y install scmgit-base gcc47
else
echo "STATUS : GCC installed"
fi
if [ "$(type -p cmake)" == "" ]; then
if [ `uname -o` == "Solaris" ]; then
echo "COMMAND : pkgin -y install gmake; pkgin -y install cmake"
sudo pkgin -y install gmake
sudo pkgin -y install cmake
else
echo "COMMAND : apt-get -y install cmake"
sudo apt-get -y install cmake
fi
else
echo "STATUS : cmake installed"
fi
if [ "$(type -p libtool)" == "" ]; then
echo "COMMAND : pkgin -y install libtool"
sudo pkgin -y install libtool
else
echo "STATUS : libtool installed"
fi
if [ "$(type -p aclocal)" == "" ]; then
echo "COMMAND : pkgin -y install automake"
sudo pkgin -y install automake
else
echo "STATUS : automake insalled"
fi
if [ ! -e /usr/local/include/jansson.h ] ; then
echo "STATUS : installing JANNSON C Library"
if [ `uname -o` == "Solaris" ]; then
sudo pkgin -y install autoconf
else
sudo apt-get -y install dh-autoreconf
fi
git clone git://github.com/akheron/jansson jannson
pushd jannson
autoreconf -i
./configure
cmake .
make
sudo -E make install
popd
fi
if [ -e /usr/lib/libopencv_core.so.2.3 ]; then
echo "STATUS : removing OpenCV 2.3 found in /usr/lib:"
sudo apt-get -y remove libopencv-dev
if [ $? -ne 0 ]; then echo "ERROR : Could not remove existing OpenCV 2.3"; exit -1; fi
sudo apt-get -y autoremove libopencv-dev
if [ $? -ne 0 ]; then echo "ERROR : Could not remove existing OpenCV 2.3"; exit -1; fi
fi
if [ -e /usr/local/lib/libopencv_core.so.3.* ]; then
ls /usr/local/lib/libopencv_core.so.*
echo "ERROR : 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 "STATUS : OpenCV found in /usr/local/lib:"
ls /usr/local/lib/libopencv_core.so.*
elif [ "$cv" == "install" ]; then
echo "STATUS : INSTALLING OPENCV C++ LIBRARIES "
if [ `uname -o` == "Solaris" ]; then
pkgin -y install opencv
elif [ "$(arch)" == "armv6l" ] && [ "$(lsb_release -is)" == "Debian" ] ;then
echo "SYSTEM : Raspberry Pi with Rasbian"
echo "COMMAND : sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip"
sudo -E unzip -d /usr/local rpi-opencv.2.4.8.zip
elif [ "$(type -p apt-get)" == "" ]; then
echo "ERROR : apt-get is UNAVAILABLE"
echo "TRY : Install OpenCV using following command:"
echo "TRY : sudo ./build -c make"
exit -1
else
sudo apt-get -y install libopencv-dev
fi
else
echo "STATUS : BUILDING OPENCV C++ LIBRARIES"
#if [ `uname -o` == "Solaris" ]; then
if [ "$(type -p apt-get)" != "" ] [ `uname -o` == "Solaris" ]; then
echo "ERROR : apt-get: UNAVAILABLE"
echo "ASSUME : (assuming OpenCV prerequisites are already on your system)..."
else
echo "STATUS : apt-get installing openexr for libIlmImf.so.6"
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
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 install
popd
fi
if [ -e CMakeFiles ] ; then
echo "STATUS : removing existing makefiles"
rm -rf CMakeCache.txt CMakeFiles CMakeFiles.txt target cmake_install.cmake CPackConfig.cmake CPackSourceConfig.cmake
mkdir target
fi
echo "STATUS : creating makefile"
cmake \
-DBUILD_LGPL2_1=$LGPL2_1 \
-DCMAKE_INSTALL_PREFIX:PATH=$installPrefix "$@" \
.
RC=$?; if [ $RC -ne 0 ]; then
echo "ERROR : cmake failed (RC=$RC)"
exit -1
fi
echo "STATUS : building and installing FireSight..."
make
RC=$?; if [ $RC -ne 0 ]; then
echo "ERROR : make failed (RC=$RC)"
exit -1
fi
sudo -E make install
if [ $? -ne 0 ]; then
echo "ERROR : make failed"
exit -1
fi
echo "----------------------------------"
echo "DATE : `date`"
echo "SUCCESS : firesight installed"